import{r as c,j as t,P as de,c as ts,a as Fn,u as ke,B as Hi,b as Yt,d as fr,e as Z,f as Gt,g as pr,R as zi,h as An,i as tt,k as Wi,o as _,v as Vi,l as vs,D as qn,C as Ln,m as Qi,A as $n,n as Bn,p as Ki,S as Yi,q as Un,s as Gi,I as Xi,t as Hn,w as bs,x as Ji,y as Zi,z as el,E as tl,F as sl,G as rl,H as nl,O as zn,J as al,K as Wn,L as ol,T as Vn,M as Qn,N as il}from"./ui-70fXDbkr.js";import{b as ll}from"./vendor-D8-FJEVI.js";import{c as cl}from"./supabase-3JoSmvXt.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();var os={},Hr;function dl(){if(Hr)return os;Hr=1;var e=ll();return os.createRoot=e.createRoot,os.hydrateRoot=e.hydrateRoot,os}var ul=dl();const hl=1,ml=1e6;let Ls=0;function fl(){return Ls=(Ls+1)%Number.MAX_SAFE_INTEGER,Ls.toString()}const $s=new Map,zr=e=>{if($s.has(e))return;const s=setTimeout(()=>{$s.delete(e),Kt({type:"REMOVE_TOAST",toastId:e})},ml);$s.set(e,s)},pl=(e,s)=>{switch(s.type){case"ADD_TOAST":return{...e,toasts:[s.toast,...e.toasts].slice(0,hl)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?zr(r):e.toasts.forEach(n=>{zr(n.id)}),{...e,toasts:e.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==s.toastId)}}},ds=[];let us={toasts:[]};function Kt(e){us=pl(us,e),ds.forEach(s=>{s(us)})}function Vs({...e}){const s=fl(),r=a=>Kt({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>Kt({type:"DISMISS_TOAST",toastId:s});return Kt({type:"ADD_TOAST",toast:{...e,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function xl(){const[e,s]=c.useState(us);return c.useEffect(()=>(ds.push(s),()=>{const r=ds.indexOf(s);r>-1&&ds.splice(r,1)}),[e]),{...e,toast:Vs,dismiss:r=>Kt({type:"DISMISS_TOAST",toastId:r})}}var Kn=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"}),gl="VisuallyHidden",ws=c.forwardRef((e,s)=>t.jsx(de.span,{...e,ref:s,style:{...Kn,...e.style}}));ws.displayName=gl;var yl=ws,xr="ToastProvider",[gr,vl,bl]=Fn("Toast"),[Yn]=ts("Toast",[bl]),[wl,js]=Yn(xr),Gn=e=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:i}=e,[l,d]=c.useState(null),[u,h]=c.useState(0),p=c.useRef(!1),g=c.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${xr}\`. Expected non-empty \`string\`.`),t.jsx(gr.Provider,{scope:s,children:t.jsx(wl,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:l,onViewportChange:d,onToastAdd:c.useCallback(()=>h(f=>f+1),[]),onToastRemove:c.useCallback(()=>h(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:g,children:i})})};Gn.displayName=xr;var Xn="ToastViewport",jl=["F8"],Qs="toast.viewportPause",Ks="toast.viewportResume",Jn=c.forwardRef((e,s)=>{const{__scopeToast:r,hotkey:n=jl,label:a="Notifications ({hotkey})",...o}=e,i=js(Xn,r),l=vl(r),d=c.useRef(null),u=c.useRef(null),h=c.useRef(null),p=c.useRef(null),g=ke(s,p,i.onViewportChange),f=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=i.toastCount>0;c.useEffect(()=>{const v=b=>{n.length!==0&&n.every(w=>b[w]||b.code===w)&&p.current?.focus()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),c.useEffect(()=>{const v=d.current,b=p.current;if(j&&v&&b){const m=()=>{if(!i.isClosePausedRef.current){const y=new CustomEvent(Qs);b.dispatchEvent(y),i.isClosePausedRef.current=!0}},w=()=>{if(i.isClosePausedRef.current){const y=new CustomEvent(Ks);b.dispatchEvent(y),i.isClosePausedRef.current=!1}},P=y=>{!v.contains(y.relatedTarget)&&w()},R=()=>{v.contains(document.activeElement)||w()};return v.addEventListener("focusin",m),v.addEventListener("focusout",P),v.addEventListener("pointermove",m),v.addEventListener("pointerleave",R),window.addEventListener("blur",m),window.addEventListener("focus",w),()=>{v.removeEventListener("focusin",m),v.removeEventListener("focusout",P),v.removeEventListener("pointermove",m),v.removeEventListener("pointerleave",R),window.removeEventListener("blur",m),window.removeEventListener("focus",w)}}},[j,i.isClosePausedRef]);const x=c.useCallback(({tabbingDirection:v})=>{const m=l().map(w=>{const P=w.ref.current,R=[P,...Dl(P)];return v==="forwards"?R:R.reverse()});return(v==="forwards"?m.reverse():m).flat()},[l]);return c.useEffect(()=>{const v=p.current;if(v){const b=m=>{const w=m.altKey||m.ctrlKey||m.metaKey;if(m.key==="Tab"&&!w){const R=document.activeElement,y=m.shiftKey;if(m.target===v&&y){u.current?.focus();return}const E=x({tabbingDirection:y?"backwards":"forwards"}),M=E.findIndex(L=>L===R);Bs(E.slice(M+1))?m.preventDefault():y?u.current?.focus():h.current?.focus()}};return v.addEventListener("keydown",b),()=>v.removeEventListener("keydown",b)}},[l,x]),t.jsxs(Hi,{ref:d,role:"region","aria-label":a.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:j?void 0:"none"},children:[j&&t.jsx(Ys,{ref:u,onFocusFromOutsideViewport:()=>{const v=x({tabbingDirection:"forwards"});Bs(v)}}),t.jsx(gr.Slot,{scope:r,children:t.jsx(de.ol,{tabIndex:-1,...o,ref:g})}),j&&t.jsx(Ys,{ref:h,onFocusFromOutsideViewport:()=>{const v=x({tabbingDirection:"backwards"});Bs(v)}})]})});Jn.displayName=Xn;var Zn="ToastFocusProxy",Ys=c.forwardRef((e,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=e,o=js(Zn,r);return t.jsx(ws,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:i=>{const l=i.relatedTarget;!o.viewport?.contains(l)&&n()}})});Ys.displayName=Zn;var ss="Toast",Nl="toast.swipeStart",Cl="toast.swipeMove",Sl="toast.swipeCancel",Tl="toast.swipeEnd",ea=c.forwardRef((e,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...i}=e,[l,d]=Yt({prop:n,defaultProp:a??!0,onChange:o,caller:ss});return t.jsx(fr,{present:r||l,children:t.jsx(kl,{open:l,...i,ref:s,onClose:()=>d(!1),onPause:Gt(e.onPause),onResume:Gt(e.onResume),onSwipeStart:Z(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Z(e.onSwipeMove,u=>{const{x:h,y:p}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${h}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:Z(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Z(e.onSwipeEnd,u=>{const{x:h,y:p}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${h}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),d(!1)})})})});ea.displayName=ss;var[El,Pl]=Yn(ss,{onClose(){}}),kl=c.forwardRef((e,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:i,onEscapeKeyDown:l,onPause:d,onResume:u,onSwipeStart:h,onSwipeMove:p,onSwipeCancel:g,onSwipeEnd:f,...j}=e,x=js(ss,r),[v,b]=c.useState(null),m=ke(s,T=>b(T)),w=c.useRef(null),P=c.useRef(null),R=a||x.duration,y=c.useRef(0),C=c.useRef(R),B=c.useRef(0),{onToastAdd:E,onToastRemove:M}=x,L=Gt(()=>{v?.contains(document.activeElement)&&x.viewport?.focus(),i()}),N=c.useCallback(T=>{!T||T===1/0||(window.clearTimeout(B.current),y.current=new Date().getTime(),B.current=window.setTimeout(L,T))},[L]);c.useEffect(()=>{const T=x.viewport;if(T){const H=()=>{N(C.current),u?.()},z=()=>{const G=new Date().getTime()-y.current;C.current=C.current-G,window.clearTimeout(B.current),d?.()};return T.addEventListener(Qs,z),T.addEventListener(Ks,H),()=>{T.removeEventListener(Qs,z),T.removeEventListener(Ks,H)}}},[x.viewport,R,d,u,N]),c.useEffect(()=>{o&&!x.isClosePausedRef.current&&N(R)},[o,R,x.isClosePausedRef,N]),c.useEffect(()=>(E(),()=>M()),[E,M]);const S=c.useMemo(()=>v?ia(v):null,[v]);return x.viewport?t.jsxs(t.Fragment,{children:[S&&t.jsx(Rl,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:S}),t.jsx(El,{scope:r,onClose:L,children:pr.createPortal(t.jsx(gr.ItemSlot,{scope:r,children:t.jsx(zi,{asChild:!0,onEscapeKeyDown:Z(l,()=>{x.isFocusedToastEscapeKeyDownRef.current||L(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:t.jsx(de.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":x.swipeDirection,...j,ref:m,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Z(e.onKeyDown,T=>{T.key==="Escape"&&(l?.(T.nativeEvent),T.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,L()))}),onPointerDown:Z(e.onPointerDown,T=>{T.button===0&&(w.current={x:T.clientX,y:T.clientY})}),onPointerMove:Z(e.onPointerMove,T=>{if(!w.current)return;const H=T.clientX-w.current.x,z=T.clientY-w.current.y,G=!!P.current,ue=["left","right"].includes(x.swipeDirection),V=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,xe=ue?V(0,H):0,ye=ue?0:V(0,z),ee=T.pointerType==="touch"?10:2,se={x:xe,y:ye},re={originalEvent:T,delta:se};G?(P.current=se,is(Cl,p,re,{discrete:!1})):Wr(se,x.swipeDirection,ee)?(P.current=se,is(Nl,h,re,{discrete:!1}),T.target.setPointerCapture(T.pointerId)):(Math.abs(H)>ee||Math.abs(z)>ee)&&(w.current=null)}),onPointerUp:Z(e.onPointerUp,T=>{const H=P.current,z=T.target;if(z.hasPointerCapture(T.pointerId)&&z.releasePointerCapture(T.pointerId),P.current=null,w.current=null,H){const G=T.currentTarget,ue={originalEvent:T,delta:H};Wr(H,x.swipeDirection,x.swipeThreshold)?is(Tl,f,ue,{discrete:!0}):is(Sl,g,ue,{discrete:!0}),G.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),Rl=e=>{const{__scopeToast:s,children:r,...n}=e,a=js(ss,s),[o,i]=c.useState(!1),[l,d]=c.useState(!1);return Ml(()=>i(!0)),c.useEffect(()=>{const u=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:t.jsx(An,{asChild:!0,children:t.jsx(ws,{...n,children:o&&t.jsxs(t.Fragment,{children:[a.label," ",r]})})})},Il="ToastTitle",ta=c.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(de.div,{...n,ref:s})});ta.displayName=Il;var _l="ToastDescription",sa=c.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(de.div,{...n,ref:s})});sa.displayName=_l;var ra="ToastAction",na=c.forwardRef((e,s)=>{const{altText:r,...n}=e;return r.trim()?t.jsx(oa,{altText:r,asChild:!0,children:t.jsx(yr,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${ra}\`. Expected non-empty \`string\`.`),null)});na.displayName=ra;var aa="ToastClose",yr=c.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e,a=Pl(aa,r);return t.jsx(oa,{asChild:!0,children:t.jsx(de.button,{type:"button",...n,ref:s,onClick:Z(e.onClick,a.onClose)})})});yr.displayName=aa;var oa=c.forwardRef((e,s)=>{const{__scopeToast:r,altText:n,...a}=e;return t.jsx(de.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function ia(e){const s=[];return Array.from(e.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Ol(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!a)if(o){const i=n.dataset.radixToastAnnounceAlt;i&&s.push(i)}else s.push(...ia(n))}}),s}function is(e,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?Wi(a,o):a.dispatchEvent(o)}var Wr=(e,s,r=0)=>{const n=Math.abs(e.x),a=Math.abs(e.y),o=n>a;return s==="left"||s==="right"?o&&n>r:!o&&a>r};function Ml(e=()=>{}){const s=Gt(e);tt(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Ol(e){return e.nodeType===e.ELEMENT_NODE}function Dl(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function Bs(e){const s=document.activeElement;return e.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Fl=Gn,la=Jn,ca=ea,da=ta,ua=sa,ha=na,ma=yr;function fa(e){var s,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(s=0;stypeof e=="boolean"?`${e}`:e===0?"0":e,Qr=pa,Ns=(e,s)=>r=>{var n;if(s?.variants==null)return Qr(e,r?.class,r?.className);const{variants:a,defaultVariants:o}=s,i=Object.keys(a).map(u=>{const h=r?.[u],p=o?.[u];if(h===null)return null;const g=Vr(h)||Vr(p);return a[u][g]}),l=r&&Object.entries(r).reduce((u,h)=>{let[p,g]=h;return g===void 0||(u[p]=g),u},{}),d=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,h)=>{let{class:p,className:g,...f}=h;return Object.entries(f).every(j=>{let[x,v]=j;return Array.isArray(v)?v.includes({...o,...l}[x]):{...o,...l}[x]===v})?[...u,p,g]:u},[]);return Qr(e,i,d,r?.class,r?.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Al=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xa=(...e)=>e.filter((s,r,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var ql={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"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ll=c.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:i,...l},d)=>c.createElement("svg",{ref:d,...ql,width:s,height:s,stroke:e,strokeWidth:n?Number(r)*24/Number(s):r,className:xa("lucide",a),...l},[...i.map(([u,h])=>c.createElement(u,h)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const te=(e,s)=>{const r=c.forwardRef(({className:n,...a},o)=>c.createElement(Ll,{ref:o,iconNode:s,className:xa(`lucide-${Al(e)}`,n),...a}));return r.displayName=`${e}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $l=te("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ga=te("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bl=te("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wt=te("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ya=te("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ul=te("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vt=te("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hl=te("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zl=te("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const va=te("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gs=te("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const We=te("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ut=te("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ba=te("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wl=te("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const st=te("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vl=te("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"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ql=te("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"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wa=te("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kr=te("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xs=te("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kl=te("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yl=te("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gl=te("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hs=te("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yr=te("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ja=te("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xl=te("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Na=te("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fs=te("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jl=te("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zl=te("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vr=te("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"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ca=te("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sa=te("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),br="-",ec=e=>{const s=sc(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{const l=i.split(br);return l[0]===""&&l.length!==1&&l.shift(),Ta(l,s)||tc(i)},getConflictingClassGroupIds:(i,l)=>{const d=r[i]||[];return l&&n[i]?[...d,...n[i]]:d}}},Ta=(e,s)=>{if(e.length===0)return s.classGroupId;const r=e[0],n=s.nextPart.get(r),a=n?Ta(e.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=e.join(br);return s.validators.find(({validator:i})=>i(o))?.classGroupId},Gr=/^\[(.+)\]$/,tc=e=>{if(Gr.test(e)){const s=Gr.exec(e)[1],r=s?.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},sc=e=>{const{theme:s,prefix:r}=e,n={nextPart:new Map,validators:[]};return nc(Object.entries(e.classGroups),r).forEach(([o,i])=>{Js(i,n,o,s)}),n},Js=(e,s,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?s:Xr(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(rc(a)){Js(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,i])=>{Js(i,Xr(s,o),r,n)})})},Xr=(e,s)=>{let r=e;return s.split(br).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},rc=e=>e.isThemeGetter,nc=(e,s)=>s?e.map(([r,n])=>{const a=n.map(o=>typeof o=="string"?s+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,l])=>[s+i,l])):o);return[r,a]}):e,ac=e=>{if(e<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(o,i)=>{r.set(o,i),s++,s>e&&(s=0,n=r,r=new Map)};return{get(o){let i=r.get(o);if(i!==void 0)return i;if((i=n.get(o))!==void 0)return a(o,i),i},set(o,i){r.has(o)?r.set(o,i):a(o,i)}}},Ea="!",oc=e=>{const{separator:s,experimentalParseClassName:r}=e,n=s.length===1,a=s[0],o=s.length,i=l=>{const d=[];let u=0,h=0,p;for(let v=0;vh?p-h:void 0;return{modifiers:d,hasImportantModifier:f,baseClassName:j,maybePostfixModifierPosition:x}};return r?l=>r({className:l,parseClassName:i}):i},ic=e=>{if(e.length<=1)return e;const s=[];let r=[];return e.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},lc=e=>({cache:ac(e.cacheSize),parseClassName:oc(e),...ec(e)}),cc=/\s+/,dc=(e,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],i=e.trim().split(cc);let l="";for(let d=i.length-1;d>=0;d-=1){const u=i[d],{modifiers:h,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:f}=r(u);let j=!!f,x=n(j?g.substring(0,f):g);if(!x){if(!j){l=u+(l.length>0?" "+l:l);continue}if(x=n(g),!x){l=u+(l.length>0?" "+l:l);continue}j=!1}const v=ic(h).join(":"),b=p?v+Ea:v,m=b+x;if(o.includes(m))continue;o.push(m);const w=a(x,j);for(let P=0;P0?" "+l:l)}return l};function uc(){let e=0,s,r,n="";for(;e{if(typeof e=="string")return e;let s,r="";for(let n=0;np(h),e());return r=lc(u),n=r.cache.get,a=r.cache.set,o=l,l(d)}function l(d){const u=n(d);if(u)return u;const h=dc(d,r);return a(d,h),h}return function(){return o(uc.apply(null,arguments))}}const he=e=>{const s=r=>r[e]||[];return s.isThemeGetter=!0,s},ka=/^\[(?:([a-z-]+):)?(.+)\]$/i,mc=/^\d+\/\d+$/,fc=new Set(["px","full","screen"]),pc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,xc=/\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$/,gc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,yc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,vc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,et=e=>It(e)||fc.has(e)||mc.test(e),ot=e=>Mt(e,"length",Ec),It=e=>!!e&&!Number.isNaN(Number(e)),Us=e=>Mt(e,"number",It),Bt=e=>!!e&&Number.isInteger(Number(e)),bc=e=>e.endsWith("%")&&It(e.slice(0,-1)),J=e=>ka.test(e),it=e=>pc.test(e),wc=new Set(["length","size","percentage"]),jc=e=>Mt(e,wc,Ra),Nc=e=>Mt(e,"position",Ra),Cc=new Set(["image","url"]),Sc=e=>Mt(e,Cc,kc),Tc=e=>Mt(e,"",Pc),Ut=()=>!0,Mt=(e,s,r)=>{const n=ka.exec(e);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Ec=e=>xc.test(e)&&!gc.test(e),Ra=()=>!1,Pc=e=>yc.test(e),kc=e=>vc.test(e),Rc=()=>{const e=he("colors"),s=he("spacing"),r=he("blur"),n=he("brightness"),a=he("borderColor"),o=he("borderRadius"),i=he("borderSpacing"),l=he("borderWidth"),d=he("contrast"),u=he("grayscale"),h=he("hueRotate"),p=he("invert"),g=he("gap"),f=he("gradientColorStops"),j=he("gradientColorStopPositions"),x=he("inset"),v=he("margin"),b=he("opacity"),m=he("padding"),w=he("saturate"),P=he("scale"),R=he("sepia"),y=he("skew"),C=he("space"),B=he("translate"),E=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],L=()=>["auto",J,s],N=()=>[J,s],S=()=>["",et,ot],T=()=>["auto",It,J],H=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],z=()=>["solid","dashed","dotted","double","none"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ue=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",J],xe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ye=()=>[It,J];return{cacheSize:500,separator:":",theme:{colors:[Ut],spacing:[et,ot],blur:["none","",it,J],brightness:ye(),borderColor:[e],borderRadius:["none","","full",it,J],borderSpacing:N(),borderWidth:S(),contrast:ye(),grayscale:V(),hueRotate:ye(),invert:V(),gap:N(),gradientColorStops:[e],gradientColorStopPositions:[bc,ot],inset:L(),margin:L(),opacity:ye(),padding:N(),saturate:ye(),scale:ye(),sepia:V(),skew:ye(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",J]}],container:["container"],columns:[{columns:[it]}],"break-after":[{"break-after":xe()}],"break-before":[{"break-before":xe()}],"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:[...H(),J]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[x]}],"inset-x":[{"inset-x":[x]}],"inset-y":[{"inset-y":[x]}],start:[{start:[x]}],end:[{end:[x]}],top:[{top:[x]}],right:[{right:[x]}],bottom:[{bottom:[x]}],left:[{left:[x]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Bt,J]}],basis:[{basis:L()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",J]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",Bt,J]}],"grid-cols":[{"grid-cols":[Ut]}],"col-start-end":[{col:["auto",{span:["full",Bt,J]},J]}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":[Ut]}],"row-start-end":[{row:["auto",{span:[Bt,J]},J]}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",J]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",J]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ue()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ue(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ue(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[m]}],px:[{px:[m]}],py:[{py:[m]}],ps:[{ps:[m]}],pe:[{pe:[m]}],pt:[{pt:[m]}],pr:[{pr:[m]}],pb:[{pb:[m]}],pl:[{pl:[m]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",J,s]}],"min-w":[{"min-w":[J,s,"min","max","fit"]}],"max-w":[{"max-w":[J,s,"none","full","min","max","fit","prose",{screen:[it]},it]}],h:[{h:[J,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[J,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[J,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[J,s,"auto","min","max","fit"]}],"font-size":[{text:["base",it,ot]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Us]}],"font-family":[{font:[Ut]}],"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",J]}],"line-clamp":[{"line-clamp":["none",It,Us]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",et,J]}],"list-image":[{"list-image":["none",J]}],"list-style-type":[{list:["none","disc","decimal",J]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",et,ot]}],"underline-offset":[{"underline-offset":["auto",et,J]}],"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:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",J]}],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",J]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...H(),Nc]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",jc]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Sc]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[j]}],"gradient-via-pos":[{via:[j]}],"gradient-to-pos":[{to:[j]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...z(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:z()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...z()]}],"outline-offset":[{"outline-offset":[et,J]}],"outline-w":[{outline:[et,ot]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:S()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[et,ot]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",it,Tc]}],"shadow-color":[{shadow:[Ut]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...G(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":G()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",it,J]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[p]}],saturate:[{saturate:[w]}],sepia:[{sepia:[R]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",J]}],duration:[{duration:ye()}],ease:[{ease:["linear","in","out","in-out",J]}],delay:[{delay:ye()}],animate:[{animate:["none","spin","ping","pulse","bounce",J]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[Bt,J]}],"translate-x":[{"translate-x":[B]}],"translate-y":[{"translate-y":[B]}],"skew-x":[{"skew-x":[y]}],"skew-y":[{"skew-y":[y]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",J]}],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",J]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"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",J]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[et,ot,Us]}],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"]}}},Ic=hc(Rc);function Y(...e){return Ic(pa(e))}const _c=Fl,Ia=c.forwardRef(({className:e,...s},r)=>t.jsx(la,{ref:r,className:Y("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),...s}));Ia.displayName=la.displayName;const Mc=Ns("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"}}),_a=c.forwardRef(({className:e,variant:s,...r},n)=>t.jsx(ca,{ref:n,className:Y(Mc({variant:s}),e),...r}));_a.displayName=ca.displayName;const Oc=c.forwardRef(({className:e,...s},r)=>t.jsx(ha,{ref:r,className:Y("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...s}));Oc.displayName=ha.displayName;const Ma=c.forwardRef(({className:e,...s},r)=>t.jsx(ma,{ref:r,className:Y("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...s,children:t.jsx(Ca,{className:"h-4 w-4"})}));Ma.displayName=ma.displayName;const Oa=c.forwardRef(({className:e,...s},r)=>t.jsx(da,{ref:r,className:Y("text-sm font-semibold",e),...s}));Oa.displayName=da.displayName;const Da=c.forwardRef(({className:e,...s},r)=>t.jsx(ua,{ref:r,className:Y("text-sm opacity-90",e),...s}));Da.displayName=ua.displayName;function Dc(){const{toasts:e}=xl();return t.jsxs(_c,{children:[e.map(function({id:s,title:r,description:n,action:a,...o}){return t.jsxs(_a,{...o,children:[t.jsxs("div",{className:"grid gap-1",children:[r&&t.jsx(Oa,{children:r}),n&&t.jsx(Da,{children:n})]}),a,t.jsx(Ma,{})]},s)}),t.jsx(Ia,{})]})}var Jr=["light","dark"],Fc="(prefers-color-scheme: dark)",Ac=c.createContext(void 0),qc={setTheme:e=>{},themes:[]},Lc=()=>{var e;return(e=c.useContext(Ac))!=null?e:qc};c.memo(({forcedTheme:e,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:i,attrs:l,nonce:d})=>{let u=o==="system",h=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(j=>`'${j}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,p=a?Jr.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(j,x=!1,v=!0)=>{let b=i?i[j]:j,m=x?j+"|| ''":`'${b}'`,w="";return a&&v&&!x&&Jr.includes(j)&&(w+=`d.style.colorScheme = '${j}';`),r==="class"?x||b?w+=`c.add(${m})`:w+="null":b&&(w+=`d[s](n,${m})`),w},f=e?`!function(){${h}${g(e)}}()`:n?`!function(){try{${h}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${Fc}',m=window.matchMedia(t);if(m.media!==t||m.matches){${g("dark")}}else{${g("light")}}}else if(e){${i?`var x=${JSON.stringify(i)};`:""}${g(i?"x[e]":"e",!0)}}${u?"":"else{"+g(o,!1,!1)+"}"}${p}}catch(e){}}()`:`!function(){try{${h}var e=localStorage.getItem('${s}');if(e){${i?`var x=${JSON.stringify(i)};`:""}${g(i?"x[e]":"e",!0)}}else{${g(o,!1,!1)};}${p}}catch(t){}}();`;return c.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:f}})});var $c=e=>{switch(e){case"success":return Hc;case"info":return Wc;case"warning":return zc;case"error":return Vc;default:return null}},Bc=Array(12).fill(0),Uc=({visible:e,className:s})=>_.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":e},_.createElement("div",{className:"sonner-spinner"},Bc.map((r,n)=>_.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Hc=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),zc=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},_.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"})),Wc=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),Vc=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),Qc=_.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"},_.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Kc=()=>{let[e,s]=_.useState(document.hidden);return _.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e},Zs=1,Yc=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let s=this.subscribers.indexOf(e);this.subscribers.splice(s,1)}),this.publish=e=>{this.subscribers.forEach(s=>s(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var s;let{message:r,...n}=e,a=typeof e?.id=="number"||((s=e.id)==null?void 0:s.length)>0?e.id:Zs++,o=this.toasts.find(l=>l.id===a),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...e,id:a,title:r}),{...l,...e,id:a,dismissible:i,title:r}):l):this.addToast({title:r,...n,dismissible:i,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(s=>{this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:e,dismiss:!0})),e),this.message=(e,s)=>this.create({...s,message:e}),this.error=(e,s)=>this.create({...s,message:e,type:"error"}),this.success=(e,s)=>this.create({...s,type:"success",message:e}),this.info=(e,s)=>this.create({...s,type:"info",message:e}),this.warning=(e,s)=>this.create({...s,type:"warning",message:e}),this.loading=(e,s)=>this.create({...s,type:"loading",message:e}),this.promise=(e,s)=>{if(!s)return;let r;s.loading!==void 0&&(r=this.create({...s,promise:e,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let n=e instanceof Promise?e:e(),a=r!==void 0,o,i=n.then(async d=>{if(o=["resolve",d],_.isValidElement(d))a=!1,this.create({id:r,type:"default",message:d});else if(Xc(d)&&!d.ok){a=!1;let u=typeof s.error=="function"?await s.error(`HTTP error! status: ${d.status}`):s.error,h=typeof s.description=="function"?await s.description(`HTTP error! status: ${d.status}`):s.description;this.create({id:r,type:"error",message:u,description:h})}else if(s.success!==void 0){a=!1;let u=typeof s.success=="function"?await s.success(d):s.success,h=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"success",message:u,description:h})}}).catch(async d=>{if(o=["reject",d],s.error!==void 0){a=!1;let u=typeof s.error=="function"?await s.error(d):s.error,h=typeof s.description=="function"?await s.description(d):s.description;this.create({id:r,type:"error",message:u,description:h})}}).finally(()=>{var d;a&&(this.dismiss(r),r=void 0),(d=s.finally)==null||d.call(s)}),l=()=>new Promise((d,u)=>i.then(()=>o[0]==="reject"?u(o[1]):d(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(e,s)=>{let r=s?.id||Zs++;return this.create({jsx:e(r),id:r,...s}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ie=new Yc,Gc=(e,s)=>{let r=s?.id||Zs++;return Ie.addToast({title:e,...s,id:r}),r},Xc=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Jc=Gc,Zc=()=>Ie.toasts,ed=()=>Ie.getActiveToasts(),Q=Object.assign(Jc,{success:Ie.success,info:Ie.info,warning:Ie.warning,error:Ie.error,custom:Ie.custom,message:Ie.message,promise:Ie.promise,dismiss:Ie.dismiss,loading:Ie.loading},{getHistory:Zc,getToasts:ed});function td(e,{insertAt:s}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",s==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}td(`: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%)} `);function ls(e){return e.label!==void 0}var sd=3,rd="32px",nd="16px",Zr=4e3,ad=356,od=14,id=20,ld=200;function Ye(...e){return e.filter(Boolean).join(" ")}function cd(e){let[s,r]=e.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var dd=e=>{var s,r,n,a,o,i,l,d,u,h,p;let{invert:g,toast:f,unstyled:j,interacting:x,setHeights:v,visibleToasts:b,heights:m,index:w,toasts:P,expanded:R,removeToast:y,defaultRichColors:C,closeButton:B,style:E,cancelButtonStyle:M,actionButtonStyle:L,className:N="",descriptionClassName:S="",duration:T,position:H,gap:z,loadingIcon:G,expandByDefault:ue,classNames:V,icons:xe,closeButtonAriaLabel:ye="Close toast",pauseWhenPageIsHidden:ee}=e,[se,re]=_.useState(null),[ve,Ue]=_.useState(null),[O,pe]=_.useState(!1),[be,ie]=_.useState(!1),[le,ge]=_.useState(!1),[Xe,Ze]=_.useState(!1),[qt,St]=_.useState(!1),[Lt,Fs]=_.useState(0),[Mi,Ar]=_.useState(0),$t=_.useRef(f.duration||T||Zr),qr=_.useRef(null),ft=_.useRef(null),Oi=w===0,Di=w+1<=b,He=f.type,Tt=f.dismissible!==!1,Fi=f.className||"",Ai=f.descriptionClassName||"",as=_.useMemo(()=>m.findIndex(X=>X.toastId===f.id)||0,[m,f.id]),qi=_.useMemo(()=>{var X;return(X=f.closeButton)!=null?X:B},[f.closeButton,B]),Lr=_.useMemo(()=>f.duration||T||Zr,[f.duration,T]),As=_.useRef(0),Et=_.useRef(0),$r=_.useRef(0),Pt=_.useRef(null),[Li,$i]=H.split("-"),Br=_.useMemo(()=>m.reduce((X,ce,me)=>me>=as?X:X+ce.height,0),[m,as]),Ur=Kc(),Bi=f.invert||g,qs=He==="loading";Et.current=_.useMemo(()=>as*z+Br,[as,Br]),_.useEffect(()=>{$t.current=Lr},[Lr]),_.useEffect(()=>{pe(!0)},[]),_.useEffect(()=>{let X=ft.current;if(X){let ce=X.getBoundingClientRect().height;return Ar(ce),v(me=>[{toastId:f.id,height:ce,position:f.position},...me]),()=>v(me=>me.filter(Ve=>Ve.toastId!==f.id))}},[v,f.id]),_.useLayoutEffect(()=>{if(!O)return;let X=ft.current,ce=X.style.height;X.style.height="auto";let me=X.getBoundingClientRect().height;X.style.height=ce,Ar(me),v(Ve=>Ve.find(Qe=>Qe.toastId===f.id)?Ve.map(Qe=>Qe.toastId===f.id?{...Qe,height:me}:Qe):[{toastId:f.id,height:me,position:f.position},...Ve])},[O,f.title,f.description,v,f.id]);let rt=_.useCallback(()=>{ie(!0),Fs(Et.current),v(X=>X.filter(ce=>ce.toastId!==f.id)),setTimeout(()=>{y(f)},ld)},[f,y,v,Et]);_.useEffect(()=>{if(f.promise&&He==="loading"||f.duration===1/0||f.type==="loading")return;let X;return R||x||ee&&Ur?(()=>{if($r.current{var ce;(ce=f.onAutoClose)==null||ce.call(f,f),rt()},$t.current)),()=>clearTimeout(X)},[R,x,f,He,ee,Ur,rt]),_.useEffect(()=>{f.delete&&rt()},[rt,f.delete]);function Ui(){var X,ce,me;return xe!=null&&xe.loading?_.createElement("div",{className:Ye(V?.loader,(X=f?.classNames)==null?void 0:X.loader,"sonner-loader"),"data-visible":He==="loading"},xe.loading):G?_.createElement("div",{className:Ye(V?.loader,(ce=f?.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":He==="loading"},G):_.createElement(Uc,{className:Ye(V?.loader,(me=f?.classNames)==null?void 0:me.loader),visible:He==="loading"})}return _.createElement("li",{tabIndex:0,ref:ft,className:Ye(N,Fi,V?.toast,(s=f?.classNames)==null?void 0:s.toast,V?.default,V?.[He],(r=f?.classNames)==null?void 0:r[He]),"data-sonner-toast":"","data-rich-colors":(n=f.richColors)!=null?n:C,"data-styled":!(f.jsx||f.unstyled||j),"data-mounted":O,"data-promise":!!f.promise,"data-swiped":qt,"data-removed":be,"data-visible":Di,"data-y-position":Li,"data-x-position":$i,"data-index":w,"data-front":Oi,"data-swiping":le,"data-dismissible":Tt,"data-type":He,"data-invert":Bi,"data-swipe-out":Xe,"data-swipe-direction":ve,"data-expanded":!!(R||ue&&O),style:{"--index":w,"--toasts-before":w,"--z-index":P.length-w,"--offset":`${be?Lt:Et.current}px`,"--initial-height":ue?"auto":`${Mi}px`,...E,...f.style},onDragEnd:()=>{ge(!1),re(null),Pt.current=null},onPointerDown:X=>{qs||!Tt||(qr.current=new Date,Fs(Et.current),X.target.setPointerCapture(X.pointerId),X.target.tagName!=="BUTTON"&&(ge(!0),Pt.current={x:X.clientX,y:X.clientY}))},onPointerUp:()=>{var X,ce,me,Ve;if(Xe||!Tt)return;Pt.current=null;let Qe=Number(((X=ft.current)==null?void 0:X.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),nt=Number(((ce=ft.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),pt=new Date().getTime()-((me=qr.current)==null?void 0:me.getTime()),Ke=se==="x"?Qe:nt,at=Math.abs(Ke)/pt;if(Math.abs(Ke)>=id||at>.11){Fs(Et.current),(Ve=f.onDismiss)==null||Ve.call(f,f),Ue(se==="x"?Qe>0?"right":"left":nt>0?"down":"up"),rt(),Ze(!0),St(!1);return}ge(!1),re(null)},onPointerMove:X=>{var ce,me,Ve,Qe;if(!Pt.current||!Tt||((ce=window.getSelection())==null?void 0:ce.toString().length)>0)return;let nt=X.clientY-Pt.current.y,pt=X.clientX-Pt.current.x,Ke=(me=e.swipeDirections)!=null?me:cd(H);!se&&(Math.abs(pt)>1||Math.abs(nt)>1)&&re(Math.abs(pt)>Math.abs(nt)?"x":"y");let at={x:0,y:0};se==="y"?(Ke.includes("top")||Ke.includes("bottom"))&&(Ke.includes("top")&&nt<0||Ke.includes("bottom")&&nt>0)&&(at.y=nt):se==="x"&&(Ke.includes("left")||Ke.includes("right"))&&(Ke.includes("left")&&pt<0||Ke.includes("right")&&pt>0)&&(at.x=pt),(Math.abs(at.x)>0||Math.abs(at.y)>0)&&St(!0),(Ve=ft.current)==null||Ve.style.setProperty("--swipe-amount-x",`${at.x}px`),(Qe=ft.current)==null||Qe.style.setProperty("--swipe-amount-y",`${at.y}px`)}},qi&&!f.jsx?_.createElement("button",{"aria-label":ye,"data-disabled":qs,"data-close-button":!0,onClick:qs||!Tt?()=>{}:()=>{var X;rt(),(X=f.onDismiss)==null||X.call(f,f)},className:Ye(V?.closeButton,(a=f?.classNames)==null?void 0:a.closeButton)},(o=xe?.close)!=null?o:Qc):null,f.jsx||c.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:_.createElement(_.Fragment,null,He||f.icon||f.promise?_.createElement("div",{"data-icon":"",className:Ye(V?.icon,(i=f?.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ui():null,f.type!=="loading"?f.icon||xe?.[He]||$c(He):null):null,_.createElement("div",{"data-content":"",className:Ye(V?.content,(l=f?.classNames)==null?void 0:l.content)},_.createElement("div",{"data-title":"",className:Ye(V?.title,(d=f?.classNames)==null?void 0:d.title)},typeof f.title=="function"?f.title():f.title),f.description?_.createElement("div",{"data-description":"",className:Ye(S,Ai,V?.description,(u=f?.classNames)==null?void 0:u.description)},typeof f.description=="function"?f.description():f.description):null),c.isValidElement(f.cancel)?f.cancel:f.cancel&&ls(f.cancel)?_.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||M,onClick:X=>{var ce,me;ls(f.cancel)&&Tt&&((me=(ce=f.cancel).onClick)==null||me.call(ce,X),rt())},className:Ye(V?.cancelButton,(h=f?.classNames)==null?void 0:h.cancelButton)},f.cancel.label):null,c.isValidElement(f.action)?f.action:f.action&&ls(f.action)?_.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||L,onClick:X=>{var ce,me;ls(f.action)&&((me=(ce=f.action).onClick)==null||me.call(ce,X),!X.defaultPrevented&&rt())},className:Ye(V?.actionButton,(p=f?.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function en(){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 ud(e,s){let r={};return[e,s].forEach((n,a)=>{let o=a===1,i=o?"--mobile-offset":"--offset",l=o?nd:rd;function d(u){["top","right","bottom","left"].forEach(h=>{r[`${i}-${h}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${i}-${u}`]=l:r[`${i}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):d(l)}),r}var hd=c.forwardRef(function(e,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:i,className:l,offset:d,mobileOffset:u,theme:h="light",richColors:p,duration:g,style:f,visibleToasts:j=sd,toastOptions:x,dir:v=en(),gap:b=od,loadingIcon:m,icons:w,containerAriaLabel:P="Notifications",pauseWhenPageIsHidden:R}=e,[y,C]=_.useState([]),B=_.useMemo(()=>Array.from(new Set([n].concat(y.filter(ee=>ee.position).map(ee=>ee.position)))),[y,n]),[E,M]=_.useState([]),[L,N]=_.useState(!1),[S,T]=_.useState(!1),[H,z]=_.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=_.useRef(null),ue=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=_.useRef(null),xe=_.useRef(!1),ye=_.useCallback(ee=>{C(se=>{var re;return(re=se.find(ve=>ve.id===ee.id))!=null&&re.delete||Ie.dismiss(ee.id),se.filter(({id:ve})=>ve!==ee.id)})},[]);return _.useEffect(()=>Ie.subscribe(ee=>{if(ee.dismiss){C(se=>se.map(re=>re.id===ee.id?{...re,delete:!0}:re));return}setTimeout(()=>{Vi.flushSync(()=>{C(se=>{let re=se.findIndex(ve=>ve.id===ee.id);return re!==-1?[...se.slice(0,re),{...se[re],...ee},...se.slice(re+1)]:[ee,...se]})})})}),[]),_.useEffect(()=>{if(h!=="system"){z(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?z("dark"):z("light")),typeof window>"u")return;let ee=window.matchMedia("(prefers-color-scheme: dark)");try{ee.addEventListener("change",({matches:se})=>{z(se?"dark":"light")})}catch{ee.addListener(({matches:re})=>{try{z(re?"dark":"light")}catch(ve){console.error(ve)}})}},[h]),_.useEffect(()=>{y.length<=1&&N(!1)},[y]),_.useEffect(()=>{let ee=se=>{var re,ve;a.every(Ue=>se[Ue]||se.code===Ue)&&(N(!0),(re=G.current)==null||re.focus()),se.code==="Escape"&&(document.activeElement===G.current||(ve=G.current)!=null&&ve.contains(document.activeElement))&&N(!1)};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[a]),_.useEffect(()=>{if(G.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,xe.current=!1)}},[G.current]),_.createElement("section",{ref:s,"aria-label":`${P} ${ue}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},B.map((ee,se)=>{var re;let[ve,Ue]=ee.split("-");return y.length?_.createElement("ol",{key:ee,dir:v==="auto"?en():v,tabIndex:-1,ref:G,className:l,"data-sonner-toaster":!0,"data-theme":H,"data-y-position":ve,"data-lifted":L&&y.length>1&&!o,"data-x-position":Ue,style:{"--front-toast-height":`${((re=E[0])==null?void 0:re.height)||0}px`,"--width":`${ad}px`,"--gap":`${b}px`,...f,...ud(d,u)},onBlur:O=>{xe.current&&!O.currentTarget.contains(O.relatedTarget)&&(xe.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||xe.current||(xe.current=!0,V.current=O.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{S||N(!1)},onDragEnd:()=>N(!1),onPointerDown:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||T(!0)},onPointerUp:()=>T(!1)},y.filter(O=>!O.position&&se===0||O.position===ee).map((O,pe)=>{var be,ie;return _.createElement(dd,{key:O.id,icons:w,index:pe,toast:O,defaultRichColors:p,duration:(be=x?.duration)!=null?be:g,className:x?.className,descriptionClassName:x?.descriptionClassName,invert:r,visibleToasts:j,closeButton:(ie=x?.closeButton)!=null?ie:i,interacting:S,position:ee,style:x?.style,unstyled:x?.unstyled,classNames:x?.classNames,cancelButtonStyle:x?.cancelButtonStyle,actionButtonStyle:x?.actionButtonStyle,removeToast:ye,toasts:y.filter(le=>le.position==O.position),heights:E.filter(le=>le.position==O.position),setHeights:M,expandByDefault:o,gap:b,loadingIcon:m,expanded:L,pauseWhenPageIsHidden:R,swipeDirections:e.swipeDirections})})):null}))});const md=({...e})=>{const{theme:s="system"}=Lc();return t.jsx(hd,{theme:s,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})};var[Cs]=ts("Tooltip",[vs]),wr=vs(),Fa="TooltipProvider",fd=700,tn="tooltip.open",[pd,Aa]=Cs(Fa),qa=e=>{const{__scopeTooltip:s,delayDuration:r=fd,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=e,i=c.useRef(!0),l=c.useRef(!1),d=c.useRef(0);return c.useEffect(()=>{const u=d.current;return()=>window.clearTimeout(u)},[]),t.jsx(pd,{scope:s,isOpenDelayedRef:i,delayDuration:r,onOpen:c.useCallback(()=>{window.clearTimeout(d.current),i.current=!1},[]),onClose:c.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:c.useCallback(u=>{l.current=u},[]),disableHoverableContent:a,children:o})};qa.displayName=Fa;var La="Tooltip",[Wf,Ss]=Cs(La),er="TooltipTrigger",xd=c.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=Ss(er,r),o=Aa(er,r),i=wr(r),l=c.useRef(null),d=ke(s,l,a.onTriggerChange),u=c.useRef(!1),h=c.useRef(!1),p=c.useCallback(()=>u.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),t.jsx($n,{asChild:!0,...i,children:t.jsx(de.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Z(e.onPointerMove,g=>{g.pointerType!=="touch"&&!h.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:Z(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:Z(e.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Z(e.onFocus,()=>{u.current||a.onOpen()}),onBlur:Z(e.onBlur,a.onClose),onClick:Z(e.onClick,a.onClose)})})});xd.displayName=er;var gd="TooltipPortal",[Vf,yd]=Cs(gd,{forceMount:void 0}),_t="TooltipContent",$a=c.forwardRef((e,s)=>{const r=yd(_t,e.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=e,i=Ss(_t,e.__scopeTooltip);return t.jsx(fr,{present:n||i.open,children:i.disableHoverableContent?t.jsx(Ba,{side:a,...o,ref:s}):t.jsx(vd,{side:a,...o,ref:s})})}),vd=c.forwardRef((e,s)=>{const r=Ss(_t,e.__scopeTooltip),n=Aa(_t,e.__scopeTooltip),a=c.useRef(null),o=ke(s,a),[i,l]=c.useState(null),{trigger:d,onClose:u}=r,h=a.current,{onPointerInTransitChange:p}=n,g=c.useCallback(()=>{l(null),p(!1)},[p]),f=c.useCallback((j,x)=>{const v=j.currentTarget,b={x:j.clientX,y:j.clientY},m=Cd(b,v.getBoundingClientRect()),w=Sd(b,m),P=Td(x.getBoundingClientRect()),R=Pd([...w,...P]);l(R),p(!0)},[p]);return c.useEffect(()=>()=>g(),[g]),c.useEffect(()=>{if(d&&h){const j=v=>f(v,h),x=v=>f(v,d);return d.addEventListener("pointerleave",j),h.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",j),h.removeEventListener("pointerleave",x)}}},[d,h,f,g]),c.useEffect(()=>{if(i){const j=x=>{const v=x.target,b={x:x.clientX,y:x.clientY},m=d?.contains(v)||h?.contains(v),w=!Ed(b,i);m?g():w&&(g(),u())};return document.addEventListener("pointermove",j),()=>document.removeEventListener("pointermove",j)}},[d,h,i,u,g]),t.jsx(Ba,{...e,ref:o})}),[bd,wd]=Cs(La,{isInside:!1}),jd=Qi("TooltipContent"),Ba=c.forwardRef((e,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:i,...l}=e,d=Ss(_t,r),u=wr(r),{onClose:h}=d;return c.useEffect(()=>(document.addEventListener(tn,h),()=>document.removeEventListener(tn,h)),[h]),c.useEffect(()=>{if(d.trigger){const p=g=>{g.target?.contains(d.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,h]),t.jsx(qn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:t.jsxs(Ln,{"data-state":d.stateAttribute,...u,...l,ref:s,style:{...l.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:[t.jsx(jd,{children:n}),t.jsx(bd,{scope:r,isInside:!0,children:t.jsx(yl,{id:d.contentId,role:"tooltip",children:a||n})})]})})});$a.displayName=_t;var Ua="TooltipArrow",Nd=c.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=wr(r);return wd(Ua,r).isInside?null:t.jsx(Bn,{...a,...n,ref:s})});Nd.displayName=Ua;function Cd(e,s){const r=Math.abs(s.top-e.y),n=Math.abs(s.bottom-e.y),a=Math.abs(s.right-e.x),o=Math.abs(s.left-e.x);switch(Math.min(r,n,a,o)){case o:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Sd(e,s,r=5){const n=[];switch(s){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function Td(e){const{top:s,right:r,bottom:n,left:a}=e;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function Ed(e,s){const{x:r,y:n}=e;let a=!1;for(let o=0,i=s.length-1;on!=g>n&&r<(p-u)*(n-h)/(g-h)+u&&(a=!a)}return a}function Pd(e){const s=e.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),kd(s)}function kd(e){if(e.length<=1)return e.slice();const s=[];for(let n=0;n=2;){const o=s[s.length-1],i=s[s.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=e.length-1;n>=0;n--){const a=e[n];for(;r.length>=2;){const o=r[r.length-1],i=r[r.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))r.pop();else break}r.push(a)}return r.pop(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var Rd=qa,Ha=$a;const Id=Rd,_d=c.forwardRef(({className:e,sideOffset:s=4,...r},n)=>t.jsx(Ha,{ref:n,sideOffset:s,className:Y("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),...r}));_d.displayName=Ha.displayName;var Ot=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},bt=typeof window>"u"||"Deno"in globalThis;function Re(){}function Md(e,s){return typeof e=="function"?e(s):e}function tr(e){return typeof e=="number"&&e>=0&&e!==1/0}function za(e,s){return Math.max(e+(s||0)-Date.now(),0)}function dt(e,s){return typeof e=="function"?e(s):e}function ze(e,s){return typeof e=="function"?e(s):e}function sn(e,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:i,stale:l}=e;if(i){if(n){if(s.queryHash!==jr(i,s.options))return!1}else if(!Xt(s.queryKey,i))return!1}if(r!=="all"){const d=s.isActive();if(r==="active"&&!d||r==="inactive"&&d)return!1}return!(typeof l=="boolean"&&s.isStale()!==l||a&&a!==s.state.fetchStatus||o&&!o(s))}function rn(e,s){const{exact:r,status:n,predicate:a,mutationKey:o}=e;if(o){if(!s.options.mutationKey)return!1;if(r){if(wt(s.options.mutationKey)!==wt(o))return!1}else if(!Xt(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function jr(e,s){return(s?.queryKeyHashFn||wt)(e)}function wt(e){return JSON.stringify(e,(s,r)=>sr(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function Xt(e,s){return e===s?!0:typeof e!=typeof s?!1:e&&s&&typeof e=="object"&&typeof s=="object"?Object.keys(s).every(r=>Xt(e[r],s[r])):!1}function Wa(e,s){if(e===s)return e;const r=nn(e)&&nn(s);if(r||sr(e)&&sr(s)){const n=r?e:Object.keys(e),a=n.length,o=r?s:Object.keys(s),i=o.length,l=r?[]:{},d=new Set(n);let u=0;for(let h=0;h{setTimeout(s,e)})}function rr(e,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,s):r.structuralSharing!==!1?Wa(e,s):s}function Dd(e,s,r=0){const n=[...e,s];return r&&n.length>r?n.slice(1):n}function Fd(e,s,r=0){const n=[s,...e];return r&&n.length>r?n.slice(0,-1):n}var Nr=Symbol();function Va(e,s){return!e.queryFn&&s?.initialPromise?()=>s.initialPromise:!e.queryFn||e.queryFn===Nr?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Qa(e,s){return typeof e=="function"?e(...s):!!e}var Ad=class extends Ot{#t;#e;#s;constructor(){super(),this.#s=e=>{if(!bt&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},Cr=new Ad,qd=class extends Ot{#t=!0;#e;#s;constructor(){super(),this.#s=e=>{if(!bt&&window.addEventListener){const s=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#s=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#t}},xs=new qd;function nr(){let e,s;const r=new Promise((a,o)=>{e=a,s=o});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function Ld(e){return Math.min(1e3*2**e,3e4)}function Ka(e){return(e??"online")==="online"?xs.isOnline():!0}var Ya=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Hs(e){return e instanceof Ya}function Ga(e){let s=!1,r=0,n=!1,a;const o=nr(),i=x=>{n||(g(new Ya(x)),e.abort?.())},l=()=>{s=!0},d=()=>{s=!1},u=()=>Cr.isFocused()&&(e.networkMode==="always"||xs.isOnline())&&e.canRun(),h=()=>Ka(e.networkMode)&&e.canRun(),p=x=>{n||(n=!0,e.onSuccess?.(x),a?.(),o.resolve(x))},g=x=>{n||(n=!0,e.onError?.(x),a?.(),o.reject(x))},f=()=>new Promise(x=>{a=v=>{(n||u())&&x(v)},e.onPause?.()}).then(()=>{a=void 0,n||e.onContinue?.()}),j=()=>{if(n)return;let x;const v=r===0?e.initialPromise:void 0;try{x=v??e.fn()}catch(b){x=Promise.reject(b)}Promise.resolve(x).then(p).catch(b=>{if(n)return;const m=e.retry??(bt?0:3),w=e.retryDelay??Ld,P=typeof w=="function"?w(r,b):w,R=m===!0||typeof m=="number"&&ru()?void 0:f()).then(()=>{s?g(b):j()})})};return{promise:o,cancel:i,continue:()=>(a?.(),o),cancelRetry:l,continueRetry:d,canStart:h,start:()=>(h()?j():f().then(j),o)}}var $d=e=>setTimeout(e,0);function Bd(){let e=[],s=0,r=l=>{l()},n=l=>{l()},a=$d;const o=l=>{s?e.push(l):a(()=>{r(l)})},i=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(d=>{r(d)})})})};return{batch:l=>{let d;s++;try{d=l()}finally{s--,s||i()}return d},batchCalls:l=>(...d)=>{o(()=>{l(...d)})},schedule:o,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var we=Bd(),Xa=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),tr(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(bt?1/0:300*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},Ud=class extends Xa{#t;#e;#s;#r;#n;#o;#i;constructor(e){super(),this.#i=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#s=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Hd(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){this.options={...this.#o,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,s){const r=rr(this.state.data,e,this.options);return this.#a({data:r,type:"success",dataUpdatedAt:s?.updatedAt,manual:s?.manual}),r}setState(e,s){this.#a({type:"setState",state:e,setStateOptions:s})}cancel(e){const s=this.#n?.promise;return this.#n?.cancel(e),s?s.then(Re).catch(Re):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>ze(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Nr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>dt(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!za(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(s=>s.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(s=>s.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(s=>s!==e),this.observers.length||(this.#n&&(this.#i?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}fetch(e,s){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&s?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const d=this.observers.find(u=>u.options.queryFn);d&&this.setOptions(d.options)}const r=new AbortController,n=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(this.#i=!0,r.signal)})},a=()=>{const d=Va(this.options,s),h=(()=>{const p={client:this.#r,queryKey:this.queryKey,meta:this.meta};return n(p),p})();return this.#i=!1,this.options.persister?this.options.persister(d,h,this):d(h)},i=(()=>{const d={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:a};return n(d),d})();this.options.behavior?.onFetch(i,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#a({type:"fetch",meta:i.fetchOptions?.meta});const l=d=>{Hs(d)&&d.silent||this.#a({type:"error",error:d}),Hs(d)||(this.#s.config.onError?.(d,this),this.#s.config.onSettled?.(this.state.data,d,this)),this.scheduleGc()};return this.#n=Ga({initialPromise:s?.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:d=>{if(d===void 0){l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(d)}catch(u){l(u);return}this.#s.config.onSuccess?.(d,this),this.#s.config.onSettled?.(d,this.state.error,this),this.scheduleGc()},onError:l,onFail:(d,u)=>{this.#a({type:"failed",failureCount:d,error:u})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#n.start()}#a(e){const s=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ja(r.data,this.options),fetchMeta:e.meta??null};case"success":return this.#e=void 0,{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Hs(n)&&n.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),we.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function Ja(e,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ka(s.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Hd(e){const s=typeof e.initialData=="function"?e.initialData():e.initialData,r=s!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var zd=class extends Ot{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,s,r){const n=s.queryKey,a=s.queryHash??jr(n,s);let o=this.get(a);return o||(o=new Ud({client:e,queryKey:n,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(o)),o}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const s=this.#t.get(e.queryHash);s&&(e.destroy(),s===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){we.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>sn(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>sn(e,r)):s}notify(e){we.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){we.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){we.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Wd=class extends Xa{#t;#e;#s;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||Za(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(s=>s!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){const s=()=>{this.#r({type:"continue"})};this.#s=Ga({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const r=this.state.status==="pending",n=!this.#s.canStart();try{if(r)s();else{this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const o=await this.options.onMutate?.(e);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:n})}const a=await this.#s.start();return await this.#e.config.onSuccess?.(a,e,this.state.context,this),await this.options.onSuccess?.(a,e,this.state.context),await this.#e.config.onSettled?.(a,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(a,null,e,this.state.context),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#e.config.onError?.(a,e,this.state.context,this),await this.options.onError?.(a,e,this.state.context),await this.#e.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,a,e,this.state.context),a}finally{this.#r({type:"error",error:a})}}finally{this.#e.runNext(this)}}#r(e){const s=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=s(this.state),we.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function Za(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Vd=class extends Ot{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#s=0}#t;#e;#s;build(e,s,r){const n=new Wd({mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(s),state:r});return this.add(n),n}add(e){this.#t.add(e);const s=cs(e);if(typeof s=="string"){const r=this.#e.get(s);r?r.push(e):this.#e.set(s,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const s=cs(e);if(typeof s=="string"){const r=this.#e.get(s);if(r)if(r.length>1){const n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#e.delete(s)}}this.notify({type:"removed",mutation:e})}canRun(e){const s=cs(e);if(typeof s=="string"){const n=this.#e.get(s)?.find(a=>a.state.status==="pending");return!n||n===e}else return!0}runNext(e){const s=cs(e);return typeof s=="string"?this.#e.get(s)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){we.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const s={exact:!0,...e};return this.getAll().find(r=>rn(s,r))}findAll(e={}){return this.getAll().filter(s=>rn(e,s))}notify(e){we.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return we.batch(()=>Promise.all(e.map(s=>s.continue().catch(Re))))}};function cs(e){return e.options.scope?.id}function on(e){return{onFetch:(s,r)=>{const n=s.options,a=s.fetchOptions?.meta?.fetchMore?.direction,o=s.state.data?.pages||[],i=s.state.data?.pageParams||[];let l={pages:[],pageParams:[]},d=0;const u=async()=>{let h=!1;const p=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(s.signal.aborted?h=!0:s.signal.addEventListener("abort",()=>{h=!0}),s.signal)})},g=Va(s.options,s.fetchOptions),f=async(j,x,v)=>{if(h)return Promise.reject();if(x==null&&j.pages.length)return Promise.resolve(j);const m=(()=>{const y={client:s.client,queryKey:s.queryKey,pageParam:x,direction:v?"backward":"forward",meta:s.options.meta};return p(y),y})(),w=await g(m),{maxPages:P}=s.options,R=v?Fd:Dd;return{pages:R(j.pages,w,P),pageParams:R(j.pageParams,x,P)}};if(a&&o.length){const j=a==="backward",x=j?Qd:ln,v={pages:o,pageParams:i},b=x(n,v);l=await f(v,b,j)}else{const j=e??o.length;do{const x=d===0?i[0]??n.initialPageParam:ln(n,l);if(d>0&&x==null)break;l=await f(l,x),d++}while(ds.options.persister?.(u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r):s.fetchFn=u}}}function ln(e,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?e.getNextPageParam(s[n],s,r[n],r):void 0}function Qd(e,{pages:s,pageParams:r}){return s.length>0?e.getPreviousPageParam?.(s[0],s,r[0],r):void 0}var Kd=class{#t;#e;#s;#r;#n;#o;#i;#a;constructor(e={}){this.#t=e.queryCache||new zd,this.#e=e.mutationCache||new Vd,this.#s=e.defaultOptions||{},this.#r=new Map,this.#n=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=Cr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#a=xs.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#a?.(),this.#a=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const s=this.defaultQueryOptions({queryKey:e});return this.#t.get(s.queryHash)?.state.data}ensureQueryData(e){const s=this.defaultQueryOptions(e),r=this.#t.build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(dt(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(e,s,r){const n=this.defaultQueryOptions({queryKey:e}),o=this.#t.get(n.queryHash)?.state.data,i=Md(s,o);if(i!==void 0)return this.#t.build(this,n).setData(i,{...r,manual:!0})}setQueriesData(e,s,r){return we.batch(()=>this.#t.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(e){const s=this.defaultQueryOptions({queryKey:e});return this.#t.get(s.queryHash)?.state}removeQueries(e){const s=this.#t;we.batch(()=>{s.findAll(e).forEach(r=>{s.remove(r)})})}resetQueries(e,s){const r=this.#t;return we.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},s)))}cancelQueries(e,s={}){const r={revert:!0,...s},n=we.batch(()=>this.#t.findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(Re).catch(Re)}invalidateQueries(e,s={}){return we.batch(()=>(this.#t.findAll(e).forEach(r=>{r.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},s)))}refetchQueries(e,s={}){const r={...s,cancelRefetch:s.cancelRefetch??!0},n=we.batch(()=>this.#t.findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(Re)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Re)}fetchQuery(e){const s=this.defaultQueryOptions(e);s.retry===void 0&&(s.retry=!1);const r=this.#t.build(this,s);return r.isStaleByTime(dt(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Re).catch(Re)}fetchInfiniteQuery(e){return e.behavior=on(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Re).catch(Re)}ensureInfiniteQueryData(e){return e.behavior=on(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return xs.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,s){this.#r.set(wt(e),{queryKey:e,defaultOptions:s})}getQueryDefaults(e){const s=[...this.#r.values()],r={};return s.forEach(n=>{Xt(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,s){this.#n.set(wt(e),{mutationKey:e,defaultOptions:s})}getMutationDefaults(e){const s=[...this.#n.values()],r={};return s.forEach(n=>{Xt(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const s={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return s.queryHash||(s.queryHash=jr(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===Nr&&(s.enabled=!1),s}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},Yd=class extends Ot{constructor(e,s){super(),this.options=s,this.#t=e,this.#a=null,this.#i=nr(),this.options.experimental_prefetchInRender||this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}#t;#e=void 0;#s=void 0;#r=void 0;#n;#o;#i;#a;#p;#h;#m;#c;#d;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),cn(this.#e,this.options)?this.#u():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ar(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ar(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const s=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ze(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#e.setOptions(this.options),s._defaulted&&!ps(this.options,s)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&dn(this.#e,r,this.options,s)&&this.#u(),this.updateResult(),n&&(this.#e!==r||ze(this.options.enabled,this.#e)!==ze(s.enabled,this.#e)||dt(this.options.staleTime,this.#e)!==dt(s.staleTime,this.#e))&&this.#x();const a=this.#g();n&&(this.#e!==r||ze(this.options.enabled,this.#e)!==ze(s.enabled,this.#e)||a!==this.#l)&&this.#y(a)}getOptimisticResult(e){const s=this.#t.getQueryCache().build(this.#t,e),r=this.createResult(s,e);return Xd(this,r)&&(this.#r=r,this.#o=this.options,this.#n=this.#e.state),r}getCurrentResult(){return this.#r}trackResult(e,s){return new Proxy(e,{get:(r,n)=>(this.trackProp(n),s?.(n),Reflect.get(r,n))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=this.#t.defaultQueryOptions(e),r=this.#t.getQueryCache().build(this.#t,s);return r.fetch().then(()=>this.createResult(r,s))}fetch(e){return this.#u({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#u(e){this.#j();let s=this.#e.fetch(this.options,e);return e?.throwOnError||(s=s.catch(Re)),s}#x(){this.#b();const e=dt(this.options.staleTime,this.#e);if(bt||this.#r.isStale||!tr(e))return;const r=za(this.#r.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#r.isStale||this.updateResult()},r)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#l=e,!(bt||ze(this.options.enabled,this.#e)===!1||!tr(this.#l)||this.#l===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||Cr.isFocused())&&this.#u()},this.#l))}#v(){this.#x(),this.#y(this.#g())}#b(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,s){const r=this.#e,n=this.options,a=this.#r,o=this.#n,i=this.#o,d=e!==r?e.state:this.#s,{state:u}=e;let h={...u},p=!1,g;if(s._optimisticResults){const B=this.hasListeners(),E=!B&&cn(e,s),M=B&&dn(e,r,s,n);(E||M)&&(h={...h,...Ja(u.data,e.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:f,errorUpdatedAt:j,status:x}=h;g=h.data;let v=!1;if(s.placeholderData!==void 0&&g===void 0&&x==="pending"){let B;a?.isPlaceholderData&&s.placeholderData===i?.placeholderData?(B=a.data,v=!0):B=typeof s.placeholderData=="function"?s.placeholderData(this.#m?.state.data,this.#m):s.placeholderData,B!==void 0&&(x="success",g=rr(a?.data,B,s),p=!0)}if(s.select&&g!==void 0&&!v)if(a&&g===o?.data&&s.select===this.#p)g=this.#h;else try{this.#p=s.select,g=s.select(g),g=rr(a?.data,g,s),this.#h=g,this.#a=null}catch(B){this.#a=B}this.#a&&(f=this.#a,g=this.#h,j=Date.now(),x="error");const b=h.fetchStatus==="fetching",m=x==="pending",w=x==="error",P=m&&b,R=g!==void 0,C={status:x,fetchStatus:h.fetchStatus,isPending:m,isSuccess:x==="success",isError:w,isInitialLoading:P,isLoading:P,data:g,dataUpdatedAt:h.dataUpdatedAt,error:f,errorUpdatedAt:j,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:b,isRefetching:b&&!m,isLoadingError:w&&!R,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&R,isStale:Sr(e,s),refetch:this.refetch,promise:this.#i,isEnabled:ze(s.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const B=L=>{C.status==="error"?L.reject(C.error):C.data!==void 0&&L.resolve(C.data)},E=()=>{const L=this.#i=C.promise=nr();B(L)},M=this.#i;switch(M.status){case"pending":e.queryHash===r.queryHash&&B(M);break;case"fulfilled":(C.status==="error"||C.data!==M.value)&&E();break;case"rejected":(C.status!=="error"||C.error!==M.reason)&&E();break}}return C}updateResult(){const e=this.#r,s=this.createResult(this.#e,this.options);if(this.#n=this.#e.state,this.#o=this.options,this.#n.data!==void 0&&(this.#m=this.#e),ps(s,e))return;this.#r=s;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!this.#f.size)return!0;const o=new Set(a??this.#f);return this.options.throwOnError&&o.add("error"),Object.keys(this.#r).some(i=>{const l=i;return this.#r[l]!==e[l]&&o.has(l)})};this.#N({listeners:r()})}#j(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const s=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(s?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#N(e){we.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Gd(e,s){return ze(s.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&s.retryOnMount===!1)}function cn(e,s){return Gd(e,s)||e.state.data!==void 0&&ar(e,s,s.refetchOnMount)}function ar(e,s,r){if(ze(s.enabled,e)!==!1&&dt(s.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Sr(e,s)}return!1}function dn(e,s,r,n){return(e!==s||ze(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Sr(e,r)}function Sr(e,s){return ze(s.enabled,e)!==!1&&e.isStaleByTime(dt(s.staleTime,e))}function Xd(e,s){return!ps(e.getCurrentResult(),s)}var Jd=class extends Ot{#t;#e=void 0;#s;#r;constructor(s,r){super(),this.#t=s,this.setOptions(r),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){const r=this.options;this.options=this.#t.defaultMutationOptions(s),ps(this.options,r)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),r?.mutationKey&&this.options.mutationKey&&wt(r.mutationKey)!==wt(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(s){this.#n(),this.#o(s)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#o()}mutate(s,r){return this.#r=r,this.#s?.removeObserver(this),this.#s=this.#t.getMutationCache().build(this.#t,this.options),this.#s.addObserver(this),this.#s.execute(s)}#n(){const s=this.#s?.state??Za();this.#e={...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset}}#o(s){we.batch(()=>{if(this.#r&&this.hasListeners()){const r=this.#e.variables,n=this.#e.context;s?.type==="success"?(this.#r.onSuccess?.(s.data,r,n),this.#r.onSettled?.(s.data,null,r,n)):s?.type==="error"&&(this.#r.onError?.(s.error,r,n),this.#r.onSettled?.(void 0,s.error,r,n))}this.listeners.forEach(r=>{r(this.#e)})})}},eo=c.createContext(void 0),Be=e=>{const s=c.useContext(eo);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Zd=({client:e,children:s})=>(c.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),t.jsx(eo.Provider,{value:e,children:s})),to=c.createContext(!1),eu=()=>c.useContext(to);to.Provider;function tu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var su=c.createContext(tu()),ru=()=>c.useContext(su),nu=(e,s)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(s.isReset()||(e.retryOnMount=!1))},au=e=>{c.useEffect(()=>{e.clearReset()},[e])},ou=({result:e,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>e.isError&&!s.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||Qa(r,[e.error,n])),iu=e=>{if(e.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},lu=(e,s)=>e.isLoading&&e.isFetching&&!s,cu=(e,s)=>e?.suspense&&s.isPending,un=(e,s,r)=>s.fetchOptimistic(e).catch(()=>{r.clearReset()});function du(e,s,r){const n=eu(),a=ru(),o=Be(),i=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=n?"isRestoring":"optimistic",iu(i),nu(i,a),au(a);const l=!o.getQueryCache().get(i.queryHash),[d]=c.useState(()=>new s(o,i)),u=d.getOptimisticResult(i),h=!n&&e.subscribed!==!1;if(c.useSyncExternalStore(c.useCallback(p=>{const g=h?d.subscribe(we.batchCalls(p)):Re;return d.updateResult(),g},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),c.useEffect(()=>{d.setOptions(i)},[i,d]),cu(i,u))throw un(i,d,a);if(ou({result:u,errorResetBoundary:a,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!bt&&lu(u,n)&&(l?un(i,d,a):o.getQueryCache().get(i.queryHash)?.promise)?.catch(Re).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?u:d.trackResult(u)}function fe(e,s){return du(e,Yd)}function Te(e,s){const r=Be(),[n]=c.useState(()=>new Jd(r,e));c.useEffect(()=>{n.setOptions(e)},[n,e]);const a=c.useSyncExternalStore(c.useCallback(i=>n.subscribe(we.batchCalls(i)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=c.useCallback((i,l)=>{n.mutate(i,l).catch(Re)},[n]);if(a.error&&Qa(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Jt(){return Jt=Object.assign?Object.assign.bind():function(e){for(var s=1;s"u")throw new Error(s)}function so(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hu(){return Math.random().toString(36).substr(2,8)}function mn(e,s){return{usr:e.state,key:e.key,idx:s}}function or(e,s,r,n){return r===void 0&&(r=null),Jt({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof s=="string"?Dt(s):s,{state:r,key:s&&s.key||n||hu()})}function ro(e){let{pathname:s="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function Dt(e){let s={};if(e){let r=e.indexOf("#");r>=0&&(s.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(s.search=e.substr(n),e=e.substr(0,n)),e&&(s.pathname=e)}return s}function mu(e,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,i=a.history,l=ct.Pop,d=null,u=h();u==null&&(u=0,i.replaceState(Jt({},i.state,{idx:u}),""));function h(){return(i.state||{idx:null}).idx}function p(){l=ct.Pop;let v=h(),b=v==null?null:v-u;u=v,d&&d({action:l,location:x.location,delta:b})}function g(v,b){l=ct.Push;let m=or(x.location,v,b);u=h()+1;let w=mn(m,u),P=x.createHref(m);try{i.pushState(w,"",P)}catch(R){if(R instanceof DOMException&&R.name==="DataCloneError")throw R;a.location.assign(P)}o&&d&&d({action:l,location:x.location,delta:1})}function f(v,b){l=ct.Replace;let m=or(x.location,v,b);u=h();let w=mn(m,u),P=x.createHref(m);i.replaceState(w,"",P),o&&d&&d({action:l,location:x.location,delta:0})}function j(v){let b=a.location.origin!=="null"?a.location.origin:a.location.href,m=typeof v=="string"?v:ro(v);return m=m.replace(/ $/,"%20"),Ne(b,"No window.location.(origin|href) available to create URL for href: "+m),new URL(m,b)}let x={get action(){return l},get location(){return e(a,i)},listen(v){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(hn,p),d=v,()=>{a.removeEventListener(hn,p),d=null}},createHref(v){return s(a,v)},createURL:j,encodeLocation(v){let b=j(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:f,go(v){return i.go(v)}};return x}var fn;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(fn||(fn={}));function fu(e,s,r){return r===void 0&&(r="/"),pu(e,s,r)}function pu(e,s,r,n){let a=typeof s=="string"?Dt(s):s,o=oo(a.pathname||"/",r);if(o==null)return null;let i=no(e);xu(i);let l=null;for(let d=0;l==null&&d{let d={relativePath:l===void 0?o.path||"":l,caseSensitive:o.caseSensitive===!0,childrenIndex:i,route:o};d.relativePath.startsWith("/")&&(Ne(d.relativePath.startsWith(n),'Absolute route path "'+d.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),d.relativePath=d.relativePath.slice(n.length));let u=vt([n,d.relativePath]),h=r.concat(d);o.children&&o.children.length>0&&(Ne(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),no(o.children,s,h,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Nu(u,o.index),routesMeta:h})};return e.forEach((o,i)=>{var l;if(o.path===""||!((l=o.path)!=null&&l.includes("?")))a(o,i);else for(let d of ao(o.path))a(o,i,d)}),s}function ao(e){let s=e.split("/");if(s.length===0)return[];let[r,...n]=s,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let i=ao(n.join("/")),l=[];return l.push(...i.map(d=>d===""?o:[o,d].join("/"))),a&&l.push(...i),l.map(d=>e.startsWith("/")&&d===""?"/":d)}function xu(e){e.sort((s,r)=>s.score!==r.score?r.score-s.score:Cu(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const gu=/^:[\w-]+$/,yu=3,vu=2,bu=1,wu=10,ju=-2,pn=e=>e==="*";function Nu(e,s){let r=e.split("/"),n=r.length;return r.some(pn)&&(n+=ju),s&&(n+=vu),r.filter(a=>!pn(a)).reduce((a,o)=>a+(gu.test(o)?yu:o===""?bu:wu),n)}function Cu(e,s){return e.length===s.length&&e.slice(0,-1).every((n,a)=>n===s[a])?e[e.length-1]-s[s.length-1]:0}function Su(e,s,r){let{routesMeta:n}=e,a={},o="/",i=[];for(let l=0;l{let{paramName:g,isOptional:f}=h;if(g==="*"){let x=l[p]||"";i=o.slice(0,o.length-x.length).replace(/(.)\/+$/,"$1")}const j=l[p];return f&&!j?u[g]=void 0:u[g]=(j||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Eu(e,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),so(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,d)=>(n.push({paramName:l,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function Pu(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return so(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),e}}function oo(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function ku(e,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Dt(e):e;return{pathname:r?r.startsWith("/")?r:Ru(r,s):s,search:Du(n),hash:Fu(a)}}function Ru(e,s){let r=s.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function zs(e,s,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Iu(e){return e.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function _u(e,s){let r=Iu(e);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Mu(e,s,r,n){n===void 0&&(n=!1);let a;typeof e=="string"?a=Dt(e):(a=Jt({},e),Ne(!a.pathname||!a.pathname.includes("?"),zs("?","pathname","search",a)),Ne(!a.pathname||!a.pathname.includes("#"),zs("#","pathname","hash",a)),Ne(!a.search||!a.search.includes("#"),zs("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,l;if(i==null)l=r;else{let p=s.length-1;if(!n&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),p-=1;a.pathname=g.join("/")}l=p>=0?s[p]:"/"}let d=ku(a,l),u=i&&i!=="/"&&i.endsWith("/"),h=(o||i===".")&&r.endsWith("/");return!d.pathname.endsWith("/")&&(u||h)&&(d.pathname+="/"),d}const vt=e=>e.join("/").replace(/\/\/+/g,"/"),Ou=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Du=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Fu=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Au(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const io=["post","put","patch","delete"];new Set(io);const qu=["get",...io];new Set(qu);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Zt(){return Zt=Object.assign?Object.assign.bind():function(e){for(var s=1;s{l.current=!0}),c.useCallback(function(u,h){if(h===void 0&&(h={}),!l.current)return;if(typeof u=="number"){n.go(u);return}let p=Mu(u,JSON.parse(i),o,h.relative==="path");e==null&&s!=="/"&&(p.pathname=p.pathname==="/"?s:vt([s,p.pathname])),(h.replace?n.replace:n.push)(p,h.state,h)},[s,n,i,o,e])}function Bu(e,s){return Uu(e,s)}function Uu(e,s,r,n){Ps()||Ne(!1);let{navigator:a}=c.useContext(Ts),{matches:o}=c.useContext(Ft),i=o[o.length-1],l=i?i.params:{};i&&i.pathname;let d=i?i.pathnameBase:"/";i&&i.route;let u=ks(),h;if(s){var p;let v=typeof s=="string"?Dt(s):s;d==="/"||(p=v.pathname)!=null&&p.startsWith(d)||Ne(!1),h=v}else h=u;let g=h.pathname||"/",f=g;if(d!=="/"){let v=d.replace(/^\//,"").split("/");f="/"+g.replace(/^\//,"").split("/").slice(v.length).join("/")}let j=fu(e,{pathname:f}),x=Qu(j&&j.map(v=>Object.assign({},v,{params:Object.assign({},l,v.params),pathname:vt([d,a.encodeLocation?a.encodeLocation(v.pathname).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?d:vt([d,a.encodeLocation?a.encodeLocation(v.pathnameBase).pathname:v.pathnameBase])})),o,r,n);return s&&x?c.createElement(Es.Provider,{value:{location:Zt({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:ct.Pop}},x):x}function Hu(){let e=Xu(),s=Au(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return c.createElement(c.Fragment,null,c.createElement("h2",null,"Unexpected Application Error!"),c.createElement("h3",{style:{fontStyle:"italic"}},s),r?c.createElement("pre",{style:a},r):null,null)}const zu=c.createElement(Hu,null);class Wu extends c.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?c.createElement(Ft.Provider,{value:this.props.routeContext},c.createElement(lo.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Vu(e){let{routeContext:s,match:r,children:n}=e,a=c.useContext(Tr);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),c.createElement(Ft.Provider,{value:s},n)}function Qu(e,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var o;if(!r)return null;if(r.errors)e=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,l=(a=r)==null?void 0:a.errors;if(l!=null){let h=i.findIndex(p=>p.route.id&&l?.[p.route.id]!==void 0);h>=0||Ne(!1),i=i.slice(0,Math.min(i.length,h+1))}let d=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let h=0;h=0?i=i.slice(0,u+1):i=[i[0]];break}}}return i.reduceRight((h,p,g)=>{let f,j=!1,x=null,v=null;r&&(f=l&&p.route.id?l[p.route.id]:void 0,x=p.route.errorElement||zu,d&&(u<0&&g===0?(Zu("route-fallback"),j=!0,v=null):u===g&&(j=!0,v=p.route.hydrateFallbackElement||null)));let b=s.concat(i.slice(0,g+1)),m=()=>{let w;return f?w=x:j?w=v:p.route.Component?w=c.createElement(p.route.Component,null):p.route.element?w=p.route.element:w=h,c.createElement(Vu,{match:p,routeContext:{outlet:h,matches:b,isDataRoute:r!=null},children:w})};return r&&(p.route.ErrorBoundary||p.route.errorElement||g===0)?c.createElement(Wu,{location:r.location,revalidation:r.revalidation,component:x,error:f,children:m(),routeContext:{outlet:null,matches:b,isDataRoute:!0}}):m()},null)}var uo=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(uo||{}),ho=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(ho||{});function Ku(e){let s=c.useContext(Tr);return s||Ne(!1),s}function Yu(e){let s=c.useContext(Lu);return s||Ne(!1),s}function Gu(e){let s=c.useContext(Ft);return s||Ne(!1),s}function mo(e){let s=Gu(),r=s.matches[s.matches.length-1];return r.route.id||Ne(!1),r.route.id}function Xu(){var e;let s=c.useContext(lo),r=Yu(),n=mo();return s!==void 0?s:(e=r.errors)==null?void 0:e[n]}function Ju(){let{router:e}=Ku(uo.UseNavigateStable),s=mo(ho.UseNavigateStable),r=c.useRef(!1);return co(()=>{r.current=!0}),c.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Zt({fromRouteId:s},o)))},[e,s])}const xn={};function Zu(e,s,r){xn[e]||(xn[e]=!0)}function eh(e,s){e?.v7_startTransition,e?.v7_relativeSplatPath}function gt(e){Ne(!1)}function th(e){let{basename:s="/",children:r=null,location:n,navigationType:a=ct.Pop,navigator:o,static:i=!1,future:l}=e;Ps()&&Ne(!1);let d=s.replace(/^\/*/,"/"),u=c.useMemo(()=>({basename:d,navigator:o,static:i,future:Zt({v7_relativeSplatPath:!1},l)}),[d,l,o,i]);typeof n=="string"&&(n=Dt(n));let{pathname:h="/",search:p="",hash:g="",state:f=null,key:j="default"}=n,x=c.useMemo(()=>{let v=oo(h,d);return v==null?null:{location:{pathname:v,search:p,hash:g,state:f,key:j},navigationType:a}},[d,h,p,g,f,j,a]);return x==null?null:c.createElement(Ts.Provider,{value:u},c.createElement(Es.Provider,{children:r,value:x}))}function sh(e){let{children:s,location:r}=e;return Bu(ir(s),r)}new Promise(()=>{});function ir(e,s){s===void 0&&(s=[]);let r=[];return c.Children.forEach(e,(n,a)=>{if(!c.isValidElement(n))return;let o=[...s,a];if(n.type===c.Fragment){r.push.apply(r,ir(n.props.children,o));return}n.type!==gt&&Ne(!1),!n.props.index||!n.props.children||Ne(!1);let i={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(i.children=ir(n.props.children,o)),r.push(i)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function lr(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((s,r)=>{let n=e[r];return s.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function rh(e,s){let r=lr(e);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const nh="6";try{window.__reactRouterVersion=nh}catch{}const ah="startTransition",gn=Ki[ah];function oh(e){let{basename:s,children:r,future:n,window:a}=e,o=c.useRef();o.current==null&&(o.current=uu({window:a,v5Compat:!0}));let i=o.current,[l,d]=c.useState({action:i.action,location:i.location}),{v7_startTransition:u}=n||{},h=c.useCallback(p=>{u&&gn?gn(()=>d(p)):d(p)},[d,u]);return c.useLayoutEffect(()=>i.listen(h),[i,h]),c.useEffect(()=>eh(n),[n]),c.createElement(th,{basename:s,children:r,location:l.location,navigationType:l.action,navigator:i,future:n})}var yn;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(yn||(yn={}));var vn;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(vn||(vn={}));function ih(e){let s=c.useRef(lr(e)),r=c.useRef(!1),n=ks(),a=c.useMemo(()=>rh(n.search,r.current?null:s.current),[n.search]),o=rs(),i=c.useCallback((l,d)=>{const u=lr(typeof l=="function"?l(a):l);r.current=!0,o("?"+u,d)},[o,a]);return[a,i]}const lh=Ns("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"}}),U=c.forwardRef(({className:e,variant:s,size:r,asChild:n=!1,...a},o)=>{const i=n?Yi:"button";return t.jsx(i,{className:Y(lh({variant:s,size:r,className:e})),ref:o,...a})});U.displayName="Button";const D=c.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Y("rounded-lg border bg-card text-card-foreground shadow-sm",e),...s}));D.displayName="Card";const A=c.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Y("flex flex-col space-y-1.5 p-6",e),...s}));A.displayName="CardHeader";const q=c.forwardRef(({className:e,...s},r)=>t.jsx("h3",{ref:r,className:Y("text-2xl font-semibold leading-none tracking-tight",e),...s}));q.displayName="CardTitle";const qe=c.forwardRef(({className:e,...s},r)=>t.jsx("p",{ref:r,className:Y("text-sm text-muted-foreground",e),...s}));qe.displayName="CardDescription";const F=c.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Y("p-6 pt-0",e),...s}));F.displayName="CardContent";const fo=c.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Y("flex items-center p-6 pt-0",e),...s}));fo.displayName="CardFooter";const ch="https://ezdmasftbvaohoghiflo.supabase.co",dh="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImV6ZG1hc2Z0YnZhb2hvZ2hpZmxvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ5NDg1MDcsImV4cCI6MjA3MDUyNDUwN30.ftjY1OgDM3MftuplHE3vf_ht-k2M8FeT0_gGcMEXWtc",W=cl(ch,dh,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),bn=()=>{try{localStorage.removeItem("supabase.auth.token"),Object.keys(localStorage).forEach(e=>{(e.startsWith("supabase.auth.")||e.includes("sb-"))&&localStorage.removeItem(e)});try{Object.keys(sessionStorage||{}).forEach(e=>{(e.startsWith("supabase.auth.")||e.includes("sb-"))&&sessionStorage.removeItem(e)})}catch{}}catch{}},po=c.createContext(void 0),uh=({children:e})=>{const[s,r]=c.useState(null),[n,a]=c.useState(null),[o,i]=c.useState(!0);c.useEffect(()=>{const{data:{subscription:p}}=W.auth.onAuthStateChange((g,f)=>{a(f),r(f?.user??null),g==="SIGNED_IN"&&setTimeout(()=>{},0)});return W.auth.getSession().then(({data:{session:g}})=>{a(g),r(g?.user??null),i(!1)}),()=>p.unsubscribe()},[]);const l=async(p,g)=>{bn();try{await W.auth.signOut({scope:"global"})}catch{}const{error:f}=await W.auth.signInWithPassword({email:p,password:g});if(f)throw f;window.location.href="/dashboard"},d=async(p,g)=>{const f=`${window.location.origin}/`,{error:j}=await W.auth.signUp({email:p,password:g,options:{emailRedirectTo:f}});if(j)throw j},u=async()=>{bn();try{await W.auth.signOut({scope:"global"})}catch{}window.location.href="/auth"},h=c.useMemo(()=>({user:s,session:n,loading:o,signIn:l,signUp:d,signOut:u}),[s,n,o]);return t.jsx(po.Provider,{value:h,children:e})},Ce=()=>{const e=c.useContext(po);if(!e)throw new Error("useAuth must be used within AuthProvider");return e},xo=[{id:"pro_tier",priceId:"pro_tier",name:"Pro",description:"Pro membership with advanced features",mode:"subscription",price:4.99,currency:"USD"}],hh=e=>xo.find(s=>s.priceId===e);function mh(e,s,r){if(typeof document>"u")return;document.title=e,((l,d)=>{let u=document.querySelector(`meta[name="${l}"]`);u||(u=document.createElement("meta"),u.setAttribute("name",l),document.head.appendChild(u)),u.setAttribute("content",d)})("description",s);let a=document.querySelector('link[rel="canonical"]');a||(a=document.createElement("link"),a.setAttribute("rel","canonical"),document.head.appendChild(a)),a.setAttribute("href",r||window.location.origin+"/");const o={"@context":"https://schema.org","@type":"SoftwareApplication",name:"HonestInvoice",applicationCategory:"BusinessApplication",operatingSystem:"Web",description:s,offers:{"@type":"Offer",price:"0",priceCurrency:"USD",availability:"https://schema.org/InStock"}};let i=document.getElementById("ld-json-landing");i||(i=document.createElement("script"),i.id="ld-json-landing",i.type="application/ld+json",document.head.appendChild(i)),i.textContent=JSON.stringify(o)}const fh=()=>{const{user:e,signOut:s}=Ce(),r=rs();c.useEffect(()=>{mh("HonestInvoice – Simple invoicing for freelancers","Create invoices, manage clients, and get paid faster with HonestInvoice.",window.location.origin+"/")},[]);const n=c.useMemo(()=>[{name:"Free",price:"$0",period:"/forever",highlight:!1,features:["Up to 5 clients","Unlimited invoices","Basic branding","Email support"],cta:e?()=>r("/dashboard"):()=>r("/auth"),ctaLabel:e?"Use Free plan":"Get started free"},...xo.map((a,o)=>({name:a.name,price:`$${a.price}`,period:"/month",highlight:o===0,features:ph(a.name),cta:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),ctaLabel:`Get ${a.name}`}))],[r,e]);return t.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted",children:[t.jsx("header",{className:"border-b",children:t.jsxs("div",{className:"container mx-auto flex items-center justify-between py-4 px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground font-bold",children:"HI"}),t.jsx("span",{className:"font-semibold",children:"HonestInvoice"})]}),t.jsxs("nav",{className:"hidden md:flex items-center gap-6 text-sm text-muted-foreground",children:[t.jsx("button",{onClick:()=>document.getElementById("features")?.scrollIntoView({behavior:"smooth"}),className:"hover:text-foreground",children:"Features"}),t.jsx("button",{onClick:()=>document.getElementById("pricing")?.scrollIntoView({behavior:"smooth"}),className:"hover:text-foreground",children:"Pricing"})]}),t.jsx("div",{className:"flex items-center gap-2 md:ml-auto",children:e?t.jsxs(t.Fragment,{children:[t.jsx(U,{variant:"ghost",onClick:()=>r("/dashboard"),children:"Dashboard"}),t.jsx(U,{variant:"secondary",onClick:s,children:"Sign out"})]}):t.jsx(U,{onClick:()=>r("/auth"),children:"Sign in"})})]})}),t.jsxs("main",{children:[t.jsxs("section",{className:"container mx-auto py-16 px-4 sm:py-20 md:py-28 text-center",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10 blur-3xl -z-10"}),t.jsx("h1",{className:"text-3xl sm:text-4xl md:text-6xl font-bold tracking-tight max-w-3xl mx-auto bg-gradient-to-r from-foreground to-primary bg-clip-text text-transparent",children:"Invoicing that's honest, fast, and effortless"})]}),t.jsx("p",{className:"mt-4 text-base sm:text-lg md:text-xl text-muted-foreground max-w-2xl mx-auto",children:"Manage clients, create professional invoices, and get paid quickly. Everything you need, nothing you don't."}),t.jsx("div",{className:"mt-8 flex flex-col sm:flex-row items-center justify-center gap-3",children:e?t.jsx(U,{size:"lg",onClick:()=>r("/dashboard"),className:"w-full sm:w-auto",children:"Go to Dashboard"}):t.jsxs(t.Fragment,{children:[t.jsx(U,{size:"lg",onClick:()=>r("/auth"),className:"w-full sm:w-auto",children:"Get started"}),t.jsx(U,{size:"lg",variant:"outline",onClick:()=>r("/auth"),className:"w-full sm:w-auto",children:"Sign in"})]})})]}),t.jsxs("section",{id:"features",className:"container mx-auto py-12 md:py-16 px-4",children:[t.jsxs("div",{className:"text-center mb-12",children:[t.jsx("h2",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-primary mb-4",children:"Everything you need to invoice professionally"}),t.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto text-sm sm:text-base",children:"Simple tools that work together to help you manage your business and get paid faster."})]}),t.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[t.jsxs(D,{className:"border-primary/20 hover:border-primary/40 transition-colors",children:[t.jsxs(A,{children:[t.jsx(q,{className:"text-primary",children:"Client management"}),t.jsx(qe,{children:"All your client details in one place."})]}),t.jsx(F,{children:t.jsx("ul",{className:"space-y-2 text-sm",children:["Add and edit clients","Quick search and filtering","Contact info at a glance"].map(a=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Wt,{className:"text-primary h-5 w-5"}),t.jsx("span",{children:a})]},a))})})]}),t.jsxs(D,{className:"border-primary/20 hover:border-primary/40 transition-colors",children:[t.jsxs(A,{children:[t.jsx(q,{className:"text-primary",children:"Invoice creation"}),t.jsx(qe,{children:"Create beautiful invoices in seconds."})]}),t.jsx(F,{children:t.jsx("ul",{className:"space-y-2 text-sm",children:["Customizable line items","Auto totals and taxes","PDF export and sharing"].map(a=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Wt,{className:"text-primary h-5 w-5"}),t.jsx("span",{children:a})]},a))})})]}),t.jsxs(D,{className:"border-primary/20 hover:border-primary/40 transition-colors md:col-span-2 lg:col-span-1",children:[t.jsxs(A,{children:[t.jsx(q,{className:"text-primary",children:"Stay organized"}),t.jsx(qe,{children:"Track status and keep everything tidy."})]}),t.jsx(F,{children:t.jsx("ul",{className:"space-y-2 text-sm",children:["Paid / Unpaid status","Due dates and reminders","Exportable reports"].map(a=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Wt,{className:"text-primary h-5 w-5"}),t.jsx("span",{children:a})]},a))})})]})]})]}),t.jsxs("section",{id:"pricing",className:"container mx-auto py-16 md:py-24 px-4",children:[t.jsxs("div",{className:"text-center mb-10",children:[t.jsx("h2",{className:"text-2xl sm:text-3xl md:text-4xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent",children:"Simple, honest pricing"}),t.jsx("p",{className:"mt-2 text-muted-foreground text-sm sm:text-base",children:"Start free and upgrade anytime."})]}),t.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:n.map(a=>t.jsxs(D,{className:`${a.highlight?"border-primary shadow-md":""} ${n.length===2&&"md:col-span-1"}`,children:[t.jsxs(A,{children:[t.jsxs(q,{className:"flex items-baseline justify-between",children:[t.jsx("span",{children:a.name}),a.highlight&&t.jsx("span",{className:"text-xs font-medium rounded-md px-2 py-1 bg-primary text-primary-foreground",children:"Most Popular"})]}),t.jsxs(qe,{children:[t.jsx("span",{className:"text-3xl font-semibold text-foreground",children:a.price}),t.jsx("span",{className:"ml-1 text-muted-foreground",children:a.period})]})]}),t.jsx(F,{children:t.jsx("ul",{className:"space-y-2 text-sm",children:a.features.map(o=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Wt,{className:"text-primary h-5 w-5"}),t.jsx("span",{children:o})]},o))})}),t.jsx(fo,{children:t.jsx(U,{className:"w-full",variant:a.highlight?"default":"secondary",onClick:a.cta,children:a.ctaLabel})})]},a.name))})]})]}),t.jsx("footer",{className:"border-t",children:t.jsxs("div",{className:"container mx-auto py-8 text-sm text-muted-foreground flex flex-col md:flex-row items-center justify-between gap-4",children:[t.jsxs("p",{children:["© ",new Date().getFullYear()," HonestInvoice. All rights reserved."]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx("button",{onClick:()=>document.getElementById("pricing")?.scrollIntoView({behavior:"smooth"}),className:"hover:text-foreground",children:"Pricing"}),t.jsx("button",{onClick:()=>document.getElementById("features")?.scrollIntoView({behavior:"smooth"}),className:"hover:text-foreground",children:"Features"})]})]})})]})},ph=e=>({Pro:["Unlimited clients","Custom branding & logo","Advanced reporting","Priority support","Export to PDF"]})[e]||[],xh=()=>{const e=ks();return c.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h1",{className:"text-4xl font-bold mb-4",children:"404"}),t.jsx("p",{className:"text-xl text-muted-foreground mb-4",children:"Oops! Page not found"}),t.jsx("a",{href:"/",className:"text-primary underline-offset-4 hover:underline",children:"Return to Home"})]})})},K=c.forwardRef(({className:e,type:s,...r},n)=>t.jsx("input",{type:s,className:Y("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:n,...r}));K.displayName="Input";var gh="Label",go=c.forwardRef((e,s)=>t.jsx(de.label,{...e,ref:s,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));go.displayName=gh;var yo=go;const yh=Ns("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),$=c.forwardRef(({className:e,...s},r)=>t.jsx(yo,{ref:r,className:Y(yh(),e),...s}));$.displayName=yo.displayName;const vh=(e,s)=>{document.title=e;const r=(o,i)=>{let l=document.head.querySelector(o);return l||(l=i(),document.head.appendChild(l)),l};r('meta[name="description"]',()=>{const o=document.createElement("meta");return o.setAttribute("name","description"),o}).setAttribute("content",s),r('link[rel="canonical"]',()=>{const o=document.createElement("link");return o.setAttribute("rel","canonical"),o}).setAttribute("href",window.location.href)},bh=()=>{const{user:e,loading:s,signIn:r,signUp:n}=Ce(),a=rs(),[o,i]=c.useState("signin"),[l,d]=c.useState(""),[u,h]=c.useState(""),p=c.useMemo(()=>o==="signin"?"Sign in to HonestInvoice":"Create your HonestInvoice account",[o]);c.useEffect(()=>{vh(`${p} | HonestInvoice`,"Sign in or create your HonestInvoice account to manage clients, invoices, and subscriptions.")},[p]),c.useEffect(()=>{e&&!s&&a("/dashboard",{replace:!0})},[e,s,a]);const g=async f=>{f.preventDefault();try{o==="signin"?await r(l,u):(await n(l,u),Vs({title:"Check your email",description:"We sent you a confirmation link to complete sign up."}))}catch(j){Vs({title:"Authentication error",description:j?.message||"Something went wrong."})}};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"px-4 py-6",children:t.jsx("h1",{className:"sr-only",children:"HonestInvoice Account"})}),t.jsx("main",{className:"container mx-auto max-w-md px-4",children:t.jsx("section",{"aria-labelledby":"auth-title",className:"mt-10",children:t.jsxs("div",{className:"rounded-lg border bg-card p-6 shadow-sm",children:[t.jsxs("div",{className:"mb-6 text-center",children:[t.jsx("h2",{id:"auth-title",className:"text-2xl font-semibold",children:o==="signin"?"Sign in":"Create account"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:o==="signin"?"Welcome back!":"Join HonestInvoice in seconds."})]}),t.jsxs("form",{onSubmit:g,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx($,{htmlFor:"email",children:"Email"}),t.jsx(K,{id:"email",type:"email",placeholder:"you@example.com",value:l,onChange:f=>d(f.target.value),required:!0,autoComplete:"email"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx($,{htmlFor:"password",children:"Password"}),t.jsx(K,{id:"password",type:"password",placeholder:"••••••••",value:u,onChange:f=>h(f.target.value),required:!0,autoComplete:o==="signin"?"current-password":"new-password"})]}),t.jsx(U,{type:"submit",className:"w-full",disabled:s,children:o==="signin"?"Sign in":"Create account"})]}),t.jsx("div",{className:"mt-4 text-center text-sm",children:o==="signin"?t.jsx("button",{className:"text-primary underline-offset-4 hover:underline",onClick:()=>i("signup"),children:"New here? Create an account"}):t.jsx("button",{className:"text-primary underline-offset-4 hover:underline",onClick:()=>i("signin"),children:"Already have an account? Sign in"})})]})})})]})};var Rs="Tabs",[wh]=ts(Rs,[Un]),vo=Un(),[jh,Er]=wh(Rs),bo=c.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:i="horizontal",dir:l,activationMode:d="automatic",...u}=e,h=Hn(l),[p,g]=Yt({prop:n,onChange:a,defaultProp:o??"",caller:Rs});return t.jsx(jh,{scope:r,baseId:bs(),value:p,onValueChange:g,orientation:i,dir:h,activationMode:d,children:t.jsx(de.div,{dir:h,"data-orientation":i,...u,ref:s})})});bo.displayName=Rs;var wo="TabsList",jo=c.forwardRef((e,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=e,o=Er(wo,r),i=vo(r);return t.jsx(Gi,{asChild:!0,...i,orientation:o.orientation,dir:o.dir,loop:n,children:t.jsx(de.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});jo.displayName=wo;var No="TabsTrigger",Co=c.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=e,i=Er(No,r),l=vo(r),d=Eo(i.baseId,n),u=Po(i.baseId,n),h=n===i.value;return t.jsx(Xi,{asChild:!0,...l,focusable:!a,active:h,children:t.jsx(de.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":u,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:s,onMouseDown:Z(e.onMouseDown,p=>{!a&&p.button===0&&p.ctrlKey===!1?i.onValueChange(n):p.preventDefault()}),onKeyDown:Z(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(n)}),onFocus:Z(e.onFocus,()=>{const p=i.activationMode!=="manual";!h&&!a&&p&&i.onValueChange(n)})})})});Co.displayName=No;var So="TabsContent",To=c.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...i}=e,l=Er(So,r),d=Eo(l.baseId,n),u=Po(l.baseId,n),h=n===l.value,p=c.useRef(h);return c.useEffect(()=>{const g=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(g)},[]),t.jsx(fr,{present:a||h,children:({present:g})=>t.jsx(de.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":d,hidden:!g,id:u,tabIndex:0,...i,ref:s,style:{...e.style,animationDuration:p.current?"0s":void 0},children:g&&o})})});To.displayName=So;function Eo(e,s){return`${e}-trigger-${s}`}function Po(e,s){return`${e}-content-${s}`}var Nh=bo,ko=jo,Ro=Co,Io=To;const _o=Nh,Pr=c.forwardRef(({className:e,...s},r)=>t.jsx(ko,{ref:r,className:Y("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...s}));Pr.displayName=ko.displayName;const Ae=c.forwardRef(({className:e,...s},r)=>t.jsx(Ro,{ref:r,className:Y("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...s}));Ae.displayName=Ro.displayName;const Pe=c.forwardRef(({className:e,...s},r)=>t.jsx(Io,{ref:r,className:Y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...s}));Pe.displayName=Io.displayName;const Ch=()=>{const{user:e}=Ce();return fe({queryKey:["subscription",e?.id],enabled:!!e,queryFn:async()=>{const{data:s,error:r}=await W.from("stripe_user_subscriptions").select("*").eq("user_id",e.id).maybeSingle();if(r)throw console.error("Error fetching subscription:",r),r;return s}})},Sh=()=>{const e=Be();return Te({mutationFn:async()=>{const{data:{session:s}}=await W.auth.getSession();if(!s?.access_token)throw new Error("Not authenticated");const r=await fetch("undefined/functions/v1/refresh-subscription",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.access_token}`}});if(!r.ok){const n=await r.json();throw new Error(n.error||"Failed to refresh subscription")}return r.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["subscription"]}),Q.success("Subscription status refreshed")},onError:s=>{console.error("Refresh error:",s),Q.error(s.message||"Failed to refresh subscription")}})},Th=Ns("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function je({className:e,variant:s,...r}){return t.jsx("div",{className:Y(Th({variant:s}),e),...r})}const wn=()=>{const{data:e,isLoading:s}=Ch();if(Sh(),s)return t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("div",{className:"h-4 w-16 bg-muted animate-pulse rounded"})});if(!e||!e.price_id)return t.jsx(je,{variant:"secondary",className:"flex items-center gap-1",children:"Free Plan"});const r=hh(e.price_id),n=e.status==="active";if(!r)return t.jsx(je,{variant:"secondary",children:"Unknown Plan"});const a=()=>r.name==="Business"?t.jsx(We,{className:"h-3 w-3"}):r.name==="Pro"?t.jsx(Sa,{className:"h-3 w-3"}):null;return t.jsxs(je,{variant:n?"default":"secondary",className:"flex items-center gap-1",children:[a(),r.name,!n&&` (${e.status})`]})},_e=c.forwardRef(({className:e,...s},r)=>t.jsx("div",{className:"relative w-full overflow-auto",children:t.jsx("table",{ref:r,className:Y("w-full caption-bottom text-sm",e),...s})}));_e.displayName="Table";const Me=c.forwardRef(({className:e,...s},r)=>t.jsx("thead",{ref:r,className:Y("[&_tr]:border-b",e),...s}));Me.displayName="TableHeader";const Oe=c.forwardRef(({className:e,...s},r)=>t.jsx("tbody",{ref:r,className:Y("[&_tr:last-child]:border-0",e),...s}));Oe.displayName="TableBody";const Eh=c.forwardRef(({className:e,...s},r)=>t.jsx("tfoot",{ref:r,className:Y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...s}));Eh.displayName="TableFooter";const ne=c.forwardRef(({className:e,...s},r)=>t.jsx("tr",{ref:r,className:Y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...s}));ne.displayName="TableRow";const I=c.forwardRef(({className:e,...s},r)=>t.jsx("th",{ref:r,className:Y("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...s}));I.displayName="TableHead";const k=c.forwardRef(({className:e,...s},r)=>t.jsx("td",{ref:r,className:Y("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...s}));k.displayName="TableCell";const Ph=c.forwardRef(({className:e,...s},r)=>t.jsx("caption",{ref:r,className:Y("mt-4 text-sm text-muted-foreground",e),...s}));Ph.displayName="TableCaption";function jn(e,[s,r]){return Math.min(r,Math.max(s,e))}function Mo(e){const s=c.useRef({value:e,previous:e});return c.useMemo(()=>(s.current.value!==e&&(s.current.previous=s.current.value,s.current.value=e),s.current.previous),[e])}var kh=[" ","Enter","ArrowUp","ArrowDown"],Rh=[" ","Enter"],jt="Select",[Is,_s,Ih]=Fn(jt),[At]=ts(jt,[Ih,vs]),Ms=vs(),[_h,ht]=At(jt),[Mh,Oh]=At(jt),Oo=e=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:i,defaultValue:l,onValueChange:d,dir:u,name:h,autoComplete:p,disabled:g,required:f,form:j}=e,x=Ms(s),[v,b]=c.useState(null),[m,w]=c.useState(null),[P,R]=c.useState(!1),y=Hn(u),[C,B]=Yt({prop:n,defaultProp:a??!1,onChange:o,caller:jt}),[E,M]=Yt({prop:i,defaultProp:l,onChange:d,caller:jt}),L=c.useRef(null),N=v?j||!!v.closest("form"):!0,[S,T]=c.useState(new Set),H=Array.from(S).map(z=>z.props.value).join(";");return t.jsx(rl,{...x,children:t.jsxs(_h,{required:f,scope:s,trigger:v,onTriggerChange:b,valueNode:m,onValueNodeChange:w,valueNodeHasChildren:P,onValueNodeHasChildrenChange:R,contentId:bs(),value:E,onValueChange:M,open:C,onOpenChange:B,dir:y,triggerPointerDownPosRef:L,disabled:g,children:[t.jsx(Is.Provider,{scope:s,children:t.jsx(Mh,{scope:e.__scopeSelect,onNativeOptionAdd:c.useCallback(z=>{T(G=>new Set(G).add(z))},[]),onNativeOptionRemove:c.useCallback(z=>{T(G=>{const ue=new Set(G);return ue.delete(z),ue})},[]),children:r})}),N?t.jsxs(ni,{"aria-hidden":!0,required:f,tabIndex:-1,name:h,autoComplete:p,value:E,onChange:z=>M(z.target.value),disabled:g,form:j,children:[E===void 0?t.jsx("option",{value:""}):null,Array.from(S)]},H):null]})})};Oo.displayName=jt;var Do="SelectTrigger",Fo=c.forwardRef((e,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,o=Ms(r),i=ht(Do,r),l=i.disabled||n,d=ke(s,i.onTriggerChange),u=_s(r),h=c.useRef("touch"),[p,g,f]=oi(x=>{const v=u().filter(w=>!w.disabled),b=v.find(w=>w.value===i.value),m=ii(v,x,b);m!==void 0&&i.onValueChange(m.value)}),j=x=>{l||(i.onOpenChange(!0),f()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return t.jsx($n,{asChild:!0,...o,children:t.jsx(de.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":ai(i.value)?"":void 0,...a,ref:d,onClick:Z(a.onClick,x=>{x.currentTarget.focus(),h.current!=="mouse"&&j(x)}),onPointerDown:Z(a.onPointerDown,x=>{h.current=x.pointerType;const v=x.target;v.hasPointerCapture(x.pointerId)&&v.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(j(x),x.preventDefault())}),onKeyDown:Z(a.onKeyDown,x=>{const v=p.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&g(x.key),!(v&&x.key===" ")&&kh.includes(x.key)&&(j(),x.preventDefault())})})})});Fo.displayName=Do;var Ao="SelectValue",qo=c.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:i="",...l}=e,d=ht(Ao,r),{onValueNodeHasChildrenChange:u}=d,h=o!==void 0,p=ke(s,d.onValueNodeChange);return tt(()=>{u(h)},[u,h]),t.jsx(de.span,{...l,ref:p,style:{pointerEvents:"none"},children:ai(d.value)?t.jsx(t.Fragment,{children:i}):o})});qo.displayName=Ao;var Dh="SelectIcon",Lo=c.forwardRef((e,s)=>{const{__scopeSelect:r,children:n,...a}=e;return t.jsx(de.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});Lo.displayName=Dh;var Fh="SelectPortal",$o=e=>t.jsx(An,{asChild:!0,...e});$o.displayName=Fh;var Nt="SelectContent",Bo=c.forwardRef((e,s)=>{const r=ht(Nt,e.__scopeSelect),[n,a]=c.useState();if(tt(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?pr.createPortal(t.jsx(Uo,{scope:e.__scopeSelect,children:t.jsx(Is.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),o):null}return t.jsx(Ho,{...e,ref:s})});Bo.displayName=Nt;var Ge=10,[Uo,mt]=At(Nt),Ah="SelectContentImpl",qh=tl("SelectContent.RemoveScroll"),Ho=c.forwardRef((e,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:i,side:l,sideOffset:d,align:u,alignOffset:h,arrowPadding:p,collisionBoundary:g,collisionPadding:f,sticky:j,hideWhenDetached:x,avoidCollisions:v,...b}=e,m=ht(Nt,r),[w,P]=c.useState(null),[R,y]=c.useState(null),C=ke(s,O=>P(O)),[B,E]=c.useState(null),[M,L]=c.useState(null),N=_s(r),[S,T]=c.useState(!1),H=c.useRef(!1);c.useEffect(()=>{if(w)return Ji(w)},[w]),Zi();const z=c.useCallback(O=>{const[pe,...be]=N().map(ge=>ge.ref.current),[ie]=be.slice(-1),le=document.activeElement;for(const ge of O)if(ge===le||(ge?.scrollIntoView({block:"nearest"}),ge===pe&&R&&(R.scrollTop=0),ge===ie&&R&&(R.scrollTop=R.scrollHeight),ge?.focus(),document.activeElement!==le))return},[N,R]),G=c.useCallback(()=>z([B,w]),[z,B,w]);c.useEffect(()=>{S&&G()},[S,G]);const{onOpenChange:ue,triggerPointerDownPosRef:V}=m;c.useEffect(()=>{if(w){let O={x:0,y:0};const pe=ie=>{O={x:Math.abs(Math.round(ie.pageX)-(V.current?.x??0)),y:Math.abs(Math.round(ie.pageY)-(V.current?.y??0))}},be=ie=>{O.x<=10&&O.y<=10?ie.preventDefault():w.contains(ie.target)||ue(!1),document.removeEventListener("pointermove",pe),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",pe),document.addEventListener("pointerup",be,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",pe),document.removeEventListener("pointerup",be,{capture:!0})}}},[w,ue,V]),c.useEffect(()=>{const O=()=>ue(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[ue]);const[xe,ye]=oi(O=>{const pe=N().filter(le=>!le.disabled),be=pe.find(le=>le.ref.current===document.activeElement),ie=ii(pe,O,be);ie&&setTimeout(()=>ie.ref.current.focus())}),ee=c.useCallback((O,pe,be)=>{const ie=!H.current&&!be;(m.value!==void 0&&m.value===pe||ie)&&(E(O),ie&&(H.current=!0))},[m.value]),se=c.useCallback(()=>w?.focus(),[w]),re=c.useCallback((O,pe,be)=>{const ie=!H.current&&!be;(m.value!==void 0&&m.value===pe||ie)&&L(O)},[m.value]),ve=n==="popper"?cr:zo,Ue=ve===cr?{side:l,sideOffset:d,align:u,alignOffset:h,arrowPadding:p,collisionBoundary:g,collisionPadding:f,sticky:j,hideWhenDetached:x,avoidCollisions:v}:{};return t.jsx(Uo,{scope:r,content:w,viewport:R,onViewportChange:y,itemRefCallback:ee,selectedItem:B,onItemLeave:se,itemTextRefCallback:re,focusSelectedItem:G,selectedItemText:M,position:n,isPositioned:S,searchRef:xe,children:t.jsx(el,{as:qh,allowPinchZoom:!0,children:t.jsx(sl,{asChild:!0,trapped:m.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:Z(a,O=>{m.trigger?.focus({preventScroll:!0}),O.preventDefault()}),children:t.jsx(qn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>m.onOpenChange(!1),children:t.jsx(ve,{role:"listbox",id:m.contentId,"data-state":m.open?"open":"closed",dir:m.dir,onContextMenu:O=>O.preventDefault(),...b,...Ue,onPlaced:()=>T(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Z(b.onKeyDown,O=>{const pe=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!pe&&O.key.length===1&&ye(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let ie=N().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(O.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const le=O.target,ge=ie.indexOf(le);ie=ie.slice(ge+1)}setTimeout(()=>z(ie)),O.preventDefault()}})})})})})})});Ho.displayName=Ah;var Lh="SelectItemAlignedPosition",zo=c.forwardRef((e,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,o=ht(Nt,r),i=mt(Nt,r),[l,d]=c.useState(null),[u,h]=c.useState(null),p=ke(s,C=>h(C)),g=_s(r),f=c.useRef(!1),j=c.useRef(!0),{viewport:x,selectedItem:v,selectedItemText:b,focusSelectedItem:m}=i,w=c.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&u&&x&&v&&b){const C=o.trigger.getBoundingClientRect(),B=u.getBoundingClientRect(),E=o.valueNode.getBoundingClientRect(),M=b.getBoundingClientRect();if(o.dir!=="rtl"){const le=M.left-B.left,ge=E.left-le,Xe=C.left-ge,Ze=C.width+Xe,qt=Math.max(Ze,B.width),St=window.innerWidth-Ge,Lt=jn(ge,[Ge,Math.max(Ge,St-qt)]);l.style.minWidth=Ze+"px",l.style.left=Lt+"px"}else{const le=B.right-M.right,ge=window.innerWidth-E.right-le,Xe=window.innerWidth-C.right-ge,Ze=C.width+Xe,qt=Math.max(Ze,B.width),St=window.innerWidth-Ge,Lt=jn(ge,[Ge,Math.max(Ge,St-qt)]);l.style.minWidth=Ze+"px",l.style.right=Lt+"px"}const L=g(),N=window.innerHeight-Ge*2,S=x.scrollHeight,T=window.getComputedStyle(u),H=parseInt(T.borderTopWidth,10),z=parseInt(T.paddingTop,10),G=parseInt(T.borderBottomWidth,10),ue=parseInt(T.paddingBottom,10),V=H+z+S+ue+G,xe=Math.min(v.offsetHeight*5,V),ye=window.getComputedStyle(x),ee=parseInt(ye.paddingTop,10),se=parseInt(ye.paddingBottom,10),re=C.top+C.height/2-Ge,ve=N-re,Ue=v.offsetHeight/2,O=v.offsetTop+Ue,pe=H+z+O,be=V-pe;if(pe<=re){const le=L.length>0&&v===L[L.length-1].ref.current;l.style.bottom="0px";const ge=u.clientHeight-x.offsetTop-x.offsetHeight,Xe=Math.max(ve,Ue+(le?se:0)+ge+G),Ze=pe+Xe;l.style.height=Ze+"px"}else{const le=L.length>0&&v===L[0].ref.current;l.style.top="0px";const Xe=Math.max(re,H+x.offsetTop+(le?ee:0)+Ue)+be;l.style.height=Xe+"px",x.scrollTop=pe-re+x.offsetTop}l.style.margin=`${Ge}px 0`,l.style.minHeight=xe+"px",l.style.maxHeight=N+"px",n?.(),requestAnimationFrame(()=>f.current=!0)}},[g,o.trigger,o.valueNode,l,u,x,v,b,o.dir,n]);tt(()=>w(),[w]);const[P,R]=c.useState();tt(()=>{u&&R(window.getComputedStyle(u).zIndex)},[u]);const y=c.useCallback(C=>{C&&j.current===!0&&(w(),m?.(),j.current=!1)},[w,m]);return t.jsx(Bh,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:f,onScrollButtonChange:y,children:t.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:t.jsx(de.div,{...a,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});zo.displayName=Lh;var $h="SelectPopperPosition",cr=c.forwardRef((e,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Ge,...o}=e,i=Ms(r);return t.jsx(Ln,{...i,...o,ref:s,align:n,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});cr.displayName=$h;var[Bh,kr]=At(Nt,{}),dr="SelectViewport",Wo=c.forwardRef((e,s)=>{const{__scopeSelect:r,nonce:n,...a}=e,o=mt(dr,r),i=kr(dr,r),l=ke(s,o.onViewportChange),d=c.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),t.jsx(Is.Slot,{scope:r,children:t.jsx(de.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Z(a.onScroll,u=>{const h=u.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=i;if(g?.current&&p){const f=Math.abs(d.current-h.scrollTop);if(f>0){const j=window.innerHeight-Ge*2,x=parseFloat(p.style.minHeight),v=parseFloat(p.style.height),b=Math.max(x,v);if(b0?P:0,p.style.justifyContent="flex-end")}}}d.current=h.scrollTop})})})]})});Wo.displayName=dr;var Vo="SelectGroup",[Uh,Hh]=At(Vo),zh=c.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=bs();return t.jsx(Uh,{scope:r,id:a,children:t.jsx(de.div,{role:"group","aria-labelledby":a,...n,ref:s})})});zh.displayName=Vo;var Qo="SelectLabel",Ko=c.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=Hh(Qo,r);return t.jsx(de.div,{id:a.id,...n,ref:s})});Ko.displayName=Qo;var gs="SelectItem",[Wh,Yo]=At(gs),Go=c.forwardRef((e,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...i}=e,l=ht(gs,r),d=mt(gs,r),u=l.value===n,[h,p]=c.useState(o??""),[g,f]=c.useState(!1),j=ke(s,m=>d.itemRefCallback?.(m,n,a)),x=bs(),v=c.useRef("touch"),b=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(Wh,{scope:r,value:n,disabled:a,textId:x,isSelected:u,onItemTextChange:c.useCallback(m=>{p(w=>w||(m?.textContent??"").trim())},[]),children:t.jsx(Is.ItemSlot,{scope:r,value:n,disabled:a,textValue:h,children:t.jsx(de.div,{role:"option","aria-labelledby":x,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...i,ref:j,onFocus:Z(i.onFocus,()=>f(!0)),onBlur:Z(i.onBlur,()=>f(!1)),onClick:Z(i.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Z(i.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Z(i.onPointerDown,m=>{v.current=m.pointerType}),onPointerMove:Z(i.onPointerMove,m=>{v.current=m.pointerType,a?d.onItemLeave?.():v.current==="mouse"&&m.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Z(i.onPointerLeave,m=>{m.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Z(i.onKeyDown,m=>{d.searchRef?.current!==""&&m.key===" "||(Rh.includes(m.key)&&b(),m.key===" "&&m.preventDefault())})})})})});Go.displayName=gs;var Qt="SelectItemText",Xo=c.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=e,i=ht(Qt,r),l=mt(Qt,r),d=Yo(Qt,r),u=Oh(Qt,r),[h,p]=c.useState(null),g=ke(s,b=>p(b),d.onItemTextChange,b=>l.itemTextRefCallback?.(b,d.value,d.disabled)),f=h?.textContent,j=c.useMemo(()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:f},d.value),[d.disabled,d.value,f]),{onNativeOptionAdd:x,onNativeOptionRemove:v}=u;return tt(()=>(x(j),()=>v(j)),[x,v,j]),t.jsxs(t.Fragment,{children:[t.jsx(de.span,{id:d.textId,...o,ref:g}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?pr.createPortal(o.children,i.valueNode):null]})});Xo.displayName=Qt;var Jo="SelectItemIndicator",Zo=c.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return Yo(Jo,r).isSelected?t.jsx(de.span,{"aria-hidden":!0,...n,ref:s}):null});Zo.displayName=Jo;var ur="SelectScrollUpButton",ei=c.forwardRef((e,s)=>{const r=mt(ur,e.__scopeSelect),n=kr(ur,e.__scopeSelect),[a,o]=c.useState(!1),i=ke(s,n.onScrollButtonChange);return tt(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=d.scrollTop>0;o(u)};const d=r.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?t.jsx(si,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});ei.displayName=ur;var hr="SelectScrollDownButton",ti=c.forwardRef((e,s)=>{const r=mt(hr,e.__scopeSelect),n=kr(hr,e.__scopeSelect),[a,o]=c.useState(!1),i=ke(s,n.onScrollButtonChange);return tt(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=d.scrollHeight-d.clientHeight,h=Math.ceil(d.scrollTop)d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?t.jsx(si,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});ti.displayName=hr;var si=c.forwardRef((e,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,o=mt("SelectScrollButton",r),i=c.useRef(null),l=_s(r),d=c.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return c.useEffect(()=>()=>d(),[d]),tt(()=>{l().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),t.jsx(de.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Z(a.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Z(a.onPointerMove,()=>{o.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Z(a.onPointerLeave,()=>{d()})})}),Vh="SelectSeparator",ri=c.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return t.jsx(de.div,{"aria-hidden":!0,...n,ref:s})});ri.displayName=Vh;var mr="SelectArrow",Qh=c.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=Ms(r),o=ht(mr,r),i=mt(mr,r);return o.open&&i.position==="popper"?t.jsx(Bn,{...a,...n,ref:s}):null});Qh.displayName=mr;var Kh="SelectBubbleInput",ni=c.forwardRef(({__scopeSelect:e,value:s,...r},n)=>{const a=c.useRef(null),o=ke(n,a),i=Mo(s);return c.useEffect(()=>{const l=a.current;if(!l)return;const d=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==s&&h){const p=new Event("change",{bubbles:!0});h.call(l,s),l.dispatchEvent(p)}},[i,s]),t.jsx(de.select,{...r,style:{...Kn,...r.style},ref:o,defaultValue:s})});ni.displayName=Kh;function ai(e){return e===""||e===void 0}function oi(e){const s=Gt(e),r=c.useRef(""),n=c.useRef(0),a=c.useCallback(i=>{const l=r.current+i;s(l),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(l)},[s]),o=c.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function ii(e,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?e.indexOf(r):-1;let i=Yh(e,Math.max(o,0));a.length===1&&(i=i.filter(u=>u!==r));const d=i.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function Yh(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var Gh=Oo,li=Fo,Xh=qo,Jh=Lo,Zh=$o,ci=Bo,em=Wo,di=Ko,ui=Go,tm=Xo,sm=Zo,hi=ei,mi=ti,fi=ri;const Le=Gh,$e=Xh,De=c.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(li,{ref:n,className:Y("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[s,t.jsx(Jh,{asChild:!0,children:t.jsx(ya,{className:"h-4 w-4 opacity-50"})})]}));De.displayName=li.displayName;const pi=c.forwardRef(({className:e,...s},r)=>t.jsx(hi,{ref:r,className:Y("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(Ul,{className:"h-4 w-4"})}));pi.displayName=hi.displayName;const xi=c.forwardRef(({className:e,...s},r)=>t.jsx(mi,{ref:r,className:Y("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(ya,{className:"h-4 w-4"})}));xi.displayName=mi.displayName;const Fe=c.forwardRef(({className:e,children:s,position:r="popper",...n},a)=>t.jsx(Zh,{children:t.jsxs(ci,{ref:a,className:Y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[t.jsx(pi,{}),t.jsx(em,{className:Y("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),t.jsx(xi,{})]})}));Fe.displayName=ci.displayName;const rm=c.forwardRef(({className:e,...s},r)=>t.jsx(di,{ref:r,className:Y("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s}));rm.displayName=di.displayName;const oe=c.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(ui,{ref:n,className:Y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(sm,{children:t.jsx(Wt,{className:"h-4 w-4"})})}),t.jsx(tm,{children:s})]}));oe.displayName=ui.displayName;const nm=c.forwardRef(({className:e,...s},r)=>t.jsx(fi,{ref:r,className:Y("-mx-1 my-1 h-px bg-muted",e),...s}));nm.displayName=fi.displayName;function Ee(e){const s=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&s==="[object Date]"?new e.constructor(+e):typeof e=="number"||s==="[object Number]"||typeof e=="string"||s==="[object String]"?new Date(e):new Date(NaN)}function Je(e,s){return e instanceof Date?new e.constructor(s):new Date(s)}function gi(e,s){const r=Ee(e);return isNaN(s)?Je(e,NaN):(s&&r.setDate(r.getDate()+s),r)}function ms(e,s){const r=Ee(e);if(isNaN(s))return Je(e,NaN);if(!s)return r;const n=r.getDate(),a=Je(e,r.getTime());a.setMonth(r.getMonth()+s+1,0);const o=a.getDate();return n>=o?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const yi=6048e5,am=864e5;let om={};function Os(){return om}function es(e,s){const r=Os(),n=s?.weekStartsOn??s?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Ee(e),o=a.getDay(),i=(o=a.getTime()?r+1:s.getTime()>=i.getTime()?r:r-1}function Nn(e){const s=Ee(e);return s.setHours(0,0,0,0),s}function Cn(e){const s=Ee(e),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+e-+r}function bi(e,s){const r=Nn(e),n=Nn(s),a=+r-Cn(r),o=+n-Cn(n);return Math.round((a-o)/am)}function im(e){const s=vi(e),r=Je(e,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),ys(r)}function lm(e,s){const r=s*7;return gi(e,r)}function cm(e,s){return ms(e,s*12)}function dm(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function um(e){if(!dm(e)&&typeof e!="number")return!1;const s=Ee(e);return!isNaN(Number(s))}function Sn(e,s){const r=Ee(e),n=Ee(s),a=Tn(r,n),o=Math.abs(bi(r,n));r.setDate(r.getDate()-a*o);const i=+(Tn(r,n)===-a),l=a*(o-i);return l===0?0:l}function Tn(e,s){const r=e.getFullYear()-s.getFullYear()||e.getMonth()-s.getMonth()||e.getDate()-s.getDate()||e.getHours()-s.getHours()||e.getMinutes()-s.getMinutes()||e.getSeconds()-s.getSeconds()||e.getMilliseconds()-s.getMilliseconds();return r<0?-1:r>0?1:r}function En(e){const s=Ee(e),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function Pn(e){const s=Ee(e);return s.setDate(1),s.setHours(0,0,0,0),s}function hm(e){const s=Ee(e),r=s.getFullYear();return s.setFullYear(r+1,0,0),s.setHours(23,59,59,999),s}function wi(e){const s=Ee(e),r=Je(e,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}const mm={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"}},fm=(e,s,r)=>{let n;const a=mm[e];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Ws(e){return(s={})=>{const r=s.width?String(s.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const pm={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},xm={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},gm={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ym={date:Ws({formats:pm,defaultWidth:"full"}),time:Ws({formats:xm,defaultWidth:"full"}),dateTime:Ws({formats:gm,defaultWidth:"full"})},vm={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},bm=(e,s,r,n)=>vm[e];function Ht(e){return(s,r)=>{const n=r?.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,l=r?.width?String(r.width):i;a=e.formattingValues[l]||e.formattingValues[i]}else{const i=e.defaultWidth,l=r?.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[i]}const o=e.argumentCallback?e.argumentCallback(s):s;return a[o]}}const wm={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},jm={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Nm={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"]},Cm={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"]},Sm={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"}},Tm={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"}},Em=(e,s)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},Pm={ordinalNumber:Em,era:Ht({values:wm,defaultWidth:"wide"}),quarter:Ht({values:jm,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ht({values:Nm,defaultWidth:"wide"}),day:Ht({values:Cm,defaultWidth:"wide"}),dayPeriod:Ht({values:Sm,defaultWidth:"wide",formattingValues:Tm,defaultFormattingWidth:"wide"})};function zt(e){return(s,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],o=s.match(a);if(!o)return null;const i=o[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(l)?Rm(l,p=>p.test(i)):km(l,p=>p.test(i));let u;u=e.valueCallback?e.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const h=s.slice(i.length);return{value:u,rest:h}}}function km(e,s){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&s(e[r]))return r}function Rm(e,s){for(let r=0;r{const n=s.match(e.matchPattern);if(!n)return null;const a=n[0],o=s.match(e.parsePattern);if(!o)return null;let i=e.valueCallback?e.valueCallback(o[0]):o[0];i=r.valueCallback?r.valueCallback(i):i;const l=s.slice(a.length);return{value:i,rest:l}}}const _m=/^(\d+)(th|st|nd|rd)?/i,Mm=/\d+/i,Om={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},Dm={any:[/^b/i,/^(a|c)/i]},Fm={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Am={any:[/1/i,/2/i,/3/i,/4/i]},qm={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},Lm={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]},$m={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},Bm={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]},Um={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},Hm={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}},zm={ordinalNumber:Im({matchPattern:_m,parsePattern:Mm,valueCallback:e=>parseInt(e,10)}),era:zt({matchPatterns:Om,defaultMatchWidth:"wide",parsePatterns:Dm,defaultParseWidth:"any"}),quarter:zt({matchPatterns:Fm,defaultMatchWidth:"wide",parsePatterns:Am,defaultParseWidth:"any",valueCallback:e=>e+1}),month:zt({matchPatterns:qm,defaultMatchWidth:"wide",parsePatterns:Lm,defaultParseWidth:"any"}),day:zt({matchPatterns:$m,defaultMatchWidth:"wide",parsePatterns:Bm,defaultParseWidth:"any"}),dayPeriod:zt({matchPatterns:Um,defaultMatchWidth:"any",parsePatterns:Hm,defaultParseWidth:"any"})},Wm={code:"en-US",formatDistance:fm,formatLong:ym,formatRelative:bm,localize:Pm,match:zm,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Vm(e){const s=Ee(e);return bi(s,wi(s))+1}function Qm(e){const s=Ee(e),r=+ys(s)-+im(s);return Math.round(r/yi)+1}function ji(e,s){const r=Ee(e),n=r.getFullYear(),a=Os(),o=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,i=Je(e,0);i.setFullYear(n+1,0,o),i.setHours(0,0,0,0);const l=es(i,s),d=Je(e,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const u=es(d,s);return r.getTime()>=l.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Km(e,s){const r=Os(),n=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=ji(e,s),o=Je(e,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),es(o,s)}function Ym(e,s){const r=Ee(e),n=+es(r,s)-+Km(r,s);return Math.round(n/yi)+1}function ae(e,s){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(s,"0");return r+n}const lt={y(e,s){const r=e.getFullYear(),n=r>0?r:1-r;return ae(s==="yy"?n%100:n,s.length)},M(e,s){const r=e.getMonth();return s==="M"?String(r+1):ae(r+1,2)},d(e,s){return ae(e.getDate(),s.length)},a(e,s){const r=e.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,s){return ae(e.getHours()%12||12,s.length)},H(e,s){return ae(e.getHours(),s.length)},m(e,s){return ae(e.getMinutes(),s.length)},s(e,s){return ae(e.getSeconds(),s.length)},S(e,s){const r=s.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return ae(a,s.length)}},kt={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},kn={G:function(e,s,r){const n=e.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,s,r){if(s==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return lt.y(e,s)},Y:function(e,s,r,n){const a=ji(e,n),o=a>0?a:1-a;if(s==="YY"){const i=o%100;return ae(i,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):ae(o,s.length)},R:function(e,s){const r=vi(e);return ae(r,s.length)},u:function(e,s){const r=e.getFullYear();return ae(r,s.length)},Q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return ae(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return ae(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,s,r){const n=e.getMonth();switch(s){case"M":case"MM":return lt.M(e,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,s,r){const n=e.getMonth();switch(s){case"L":return String(n+1);case"LL":return ae(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,s,r,n){const a=Ym(e,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):ae(a,s.length)},I:function(e,s,r){const n=Qm(e);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):ae(n,s.length)},d:function(e,s,r){return s==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):lt.d(e,s)},D:function(e,s,r){const n=Vm(e);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):ae(n,s.length)},E:function(e,s,r){const n=e.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,s,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(o);case"ee":return ae(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,s,r,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(o);case"cc":return ae(o,s.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,s,r){const n=e.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return ae(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,s,r){const a=e.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,s,r){const n=e.getHours();let a;switch(n===12?a=kt.noon:n===0?a=kt.midnight:a=n/12>=1?"pm":"am",s){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,s,r){const n=e.getHours();let a;switch(n>=17?a=kt.evening:n>=12?a=kt.afternoon:n>=4?a=kt.morning:a=kt.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,s,r){if(s==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return lt.h(e,s)},H:function(e,s,r){return s==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):lt.H(e,s)},K:function(e,s,r){const n=e.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):ae(n,s.length)},k:function(e,s,r){let n=e.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):ae(n,s.length)},m:function(e,s,r){return s==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):lt.m(e,s)},s:function(e,s,r){return s==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):lt.s(e,s)},S:function(e,s){return lt.S(e,s)},X:function(e,s,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return In(n);case"XXXX":case"XX":return yt(n);case"XXXXX":case"XXX":default:return yt(n,":")}},x:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"x":return In(n);case"xxxx":case"xx":return yt(n);case"xxxxx":case"xxx":default:return yt(n,":")}},O:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+Rn(n,":");case"OOOO":default:return"GMT"+yt(n,":")}},z:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+Rn(n,":");case"zzzz":default:return"GMT"+yt(n,":")}},t:function(e,s,r){const n=Math.trunc(e.getTime()/1e3);return ae(n,s.length)},T:function(e,s,r){const n=e.getTime();return ae(n,s.length)}};function Rn(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+s+ae(o,2)}function In(e,s){return e%60===0?(e>0?"-":"+")+ae(Math.abs(e)/60,2):yt(e,s)}function yt(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=ae(Math.trunc(n/60),2),o=ae(n%60,2);return r+a+s+o}const _n=(e,s)=>{switch(e){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},Ni=(e,s)=>{switch(e){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},Gm=(e,s)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return _n(e,s);let o;switch(n){case"P":o=s.dateTime({width:"short"});break;case"PP":o=s.dateTime({width:"medium"});break;case"PPP":o=s.dateTime({width:"long"});break;case"PPPP":default:o=s.dateTime({width:"full"});break}return o.replace("{{date}}",_n(n,s)).replace("{{time}}",Ni(a,s))},Xm={p:Ni,P:Gm},Jm=/^D+$/,Zm=/^Y+$/,ef=["D","DD","YY","YYYY"];function tf(e){return Jm.test(e)}function sf(e){return Zm.test(e)}function rf(e,s,r){const n=nf(e,s,r);if(console.warn(n),ef.includes(e))throw new RangeError(n)}function nf(e,s,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const af=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,of=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,lf=/^'([^]*?)'?$/,cf=/''/g,df=/[a-zA-Z]/;function Se(e,s,r){const n=Os(),a=n.locale??Wm,o=n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=Ee(e);if(!um(l))throw new RangeError("Invalid time value");let d=s.match(of).map(h=>{const p=h[0];if(p==="p"||p==="P"){const g=Xm[p];return g(h,a.formatLong)}return h}).join("").match(af).map(h=>{if(h==="''")return{isToken:!1,value:"'"};const p=h[0];if(p==="'")return{isToken:!1,value:uf(h)};if(kn[p])return{isToken:!0,value:h};if(p.match(df))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:h}});a.localize.preprocessor&&(d=a.localize.preprocessor(l,d));const u={firstWeekContainsDate:o,weekStartsOn:i,locale:a};return d.map(h=>{if(!h.isToken)return h.value;const p=h.value;(sf(p)||tf(p))&&rf(p,s,String(e));const g=kn[p[0]];return g(l,p,a.localize,u)}).join("")}function uf(e){const s=e.match(lf);return s?s[1].replace(cf,"'"):e}function hf(e,s){return gi(e,-30)}const mf=()=>{const{user:e}=Ce(),[s,r]=c.useState("this_month"),n=b=>{const m=new Date;switch(b){case"last_30_days":return{start:hf(m),end:m};case"this_month":return{start:Pn(m),end:En(m)};case"this_year":return{start:wi(m),end:hm(m)};default:return{start:Pn(m),end:En(m)}}},{start:a,end:o}=n(s),{data:i}=fe({queryKey:["dashboard-reports",e?.id,s],queryFn:async()=>{const[b,m,w,P,R]=await Promise.all([W.from("invoices").select("*, client:clients(name, company)").eq("user_id",e.id).gte("created_at",a.toISOString()).lte("created_at",o.toISOString()),W.from("quotes").select("*").eq("user_id",e.id).gte("created_at",a.toISOString()).lte("created_at",o.toISOString()),W.from("clients").select("*").eq("user_id",e.id),W.from("time_entries").select("*").eq("user_id",e.id).gte("date",a.toISOString().split("T")[0]).lte("date",o.toISOString().split("T")[0]),W.from("expenses").select("*").eq("user_id",e.id).gte("date",a.toISOString().split("T")[0]).lte("date",o.toISOString().split("T")[0])]);return{invoices:b.data||[],quotes:m.data||[],clients:w.data||[],timeEntries:P.data||[],expenses:R.data||[]}},enabled:!!e?.id}),l=i?.invoices.reduce((b,m)=>m.status==="paid"?b+m.total:b,0)||0,d=i?.invoices.reduce((b,m)=>m.status==="sent"||m.status==="overdue"?b+m.total:b,0)||0;i?.quotes.reduce((b,m)=>b+m.total,0);const u=i?.quotes.filter(b=>b.status==="approved").length||0,h=i?.timeEntries.reduce((b,m)=>b+m.hours_worked,0)||0,p=i?.timeEntries.reduce((b,m)=>m.is_billable?b+m.hours_worked:b,0)||0,g=i?.expenses.reduce((b,m)=>b+m.amount,0)||0,f=i?.invoices.reduce((b,m)=>{if(m.status==="paid"&&m.client){const w=m.client.name;b[w]=(b[w]||0)+m.total}return b},{})||{},j=Object.entries(f).sort(([,b],[,m])=>m-b).slice(0,5),x=i?.invoices.reduce((b,m)=>(b[m.status]=(b[m.status]||0)+1,b),{})||{},v=[...i?.invoices.map(b=>({type:"invoice",description:`Invoice ${b.number} for ${b.client?.name}`,amount:b.total,date:b.created_at,status:b.status}))||[],...i?.quotes.map(b=>({type:"quote",description:`Quote ${b.quote_number}`,amount:b.total,date:b.created_at,status:b.status}))||[]].sort((b,m)=>new Date(m.date).getTime()-new Date(b.date).getTime()).slice(0,10);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-2xl font-bold",children:"Reports & Analytics"}),t.jsxs(Le,{value:s,onValueChange:r,children:[t.jsx(De,{className:"w-40",children:t.jsx($e,{})}),t.jsxs(Fe,{children:[t.jsx(oe,{value:"last_30_days",children:"Last 30 Days"}),t.jsx(oe,{value:"this_month",children:"This Month"}),t.jsx(oe,{value:"this_year",children:"This Year"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Revenue"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:["$",l.toFixed(2)]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"From paid invoices"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Outstanding"}),t.jsx(fs,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:["$",d.toFixed(2)]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending payments"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Clients"}),t.jsx(vr,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:i?.clients.length||0}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Active clients"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Billable Hours"}),t.jsx(va,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:p.toFixed(1)}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Out of ",h.toFixed(1)," total"]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Quote Conversion"}),t.jsx(st,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[i?.quotes.length?Math.round(u/i.quotes.length*100):0,"%"]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[u," of ",i?.quotes.length||0," quotes approved"]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Expenses"}),t.jsx(Na,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:["$",g.toFixed(2)]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Business expenses"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Net Profit"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:["$",(l-g).toFixed(2)]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Revenue minus expenses"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Top Clients by Revenue"})}),t.jsx(F,{children:j.length>0?t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Client"}),t.jsx(I,{className:"text-right",children:"Revenue"})]})}),t.jsx(Oe,{children:j.map(([b,m],w)=>t.jsxs(ne,{children:[t.jsxs(k,{className:"font-medium",children:["#",w+1," ",b]}),t.jsxs(k,{className:"text-right",children:["$",m.toFixed(2)]})]},b))})]}):t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No revenue data available"})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Invoice Status Overview"})}),t.jsx(F,{children:Object.keys(x).length>0?t.jsx("div",{className:"space-y-3",children:Object.entries(x).map(([b,m])=>t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(je,{variant:"outline",className:"capitalize",children:b}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[m," invoice",m!==1?"s":""]})]}),t.jsxs("span",{className:"font-medium",children:[Math.round(m/(i?.invoices.length||1)*100),"%"]})]},b))}):t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No invoice data available"})})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Recent Activity"})}),t.jsx(F,{children:v.length>0?t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Type"}),t.jsx(I,{children:"Description"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Date"})]})}),t.jsx(Oe,{children:v.map((b,m)=>t.jsxs(ne,{children:[t.jsx(k,{children:t.jsx(je,{variant:"outline",className:"capitalize",children:b.type})}),t.jsx(k,{children:b.description}),t.jsxs(k,{children:["$",b.amount.toFixed(2)]}),t.jsx(k,{children:t.jsx(je,{variant:"secondary",className:"capitalize",children:b.status})}),t.jsx(k,{children:Se(new Date(b.date),"MMM dd, yyyy")})]},m))})]}):t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No recent activity"})})]})]})},Mn=W,ff=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState(""),h=fe({queryKey:["clients",e?.id],enabled:!!e,queryFn:async()=>{const{data:g,error:f}=await Mn.from("clients").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});if(f)throw f;return g}}),p=Te({mutationFn:async()=>{if(!e)throw new Error("Not authenticated");const g={user_id:e.id,name:r,email:a||null,company:i||null,address:d||null},{error:f}=await Mn.from("clients").insert([g]);if(f)throw f},onSuccess:()=>{s.invalidateQueries({queryKey:["clients",e?.id]}),n(""),o(""),l(""),u(""),Q.success("Client added")},onError:g=>Q.error(g.message||"Failed to add client")});return t.jsxs("section",{className:"space-y-6",children:[t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Add Client"})}),t.jsx(F,{children:t.jsxs("form",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",onSubmit:g=>{g.preventDefault(),p.mutate()},children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"name",children:"Name"}),t.jsx(K,{id:"name",value:r,onChange:g=>n(g.target.value),required:!0})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"email",children:"Email"}),t.jsx(K,{id:"email",type:"email",value:a,onChange:g=>o(g.target.value)})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"company",children:"Company"}),t.jsx(K,{id:"company",value:i,onChange:g=>l(g.target.value)})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"address",children:"Address"}),t.jsx(K,{id:"address",value:d,onChange:g=>u(g.target.value)})]}),t.jsx("div",{className:"md:col-span-2",children:t.jsx(U,{type:"submit",disabled:p.isPending,children:"Save Client"})})]})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Clients"})}),t.jsx(F,{children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{className:"min-w-[120px]",children:"Name"}),t.jsx(I,{className:"min-w-[160px]",children:"Email"}),t.jsx(I,{className:"min-w-[120px]",children:"Company"}),t.jsx(I,{className:"min-w-[100px]",children:"Created"})]})}),t.jsx(Oe,{children:h.isLoading?t.jsx(ne,{children:t.jsx(k,{colSpan:4,children:"Loading…"})}):h.data&&h.data.length>0?h.data.map(g=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:g.name}),t.jsx(k,{className:"text-sm",children:g.email||"—"}),t.jsx(k,{className:"text-sm",children:g.company||"—"}),t.jsx(k,{className:"text-sm",children:new Date(g.created_at).toLocaleDateString()})]},g.id)):t.jsx(ne,{children:t.jsx(k,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No clients yet"})})})]})})})]})]})},Ct=c.forwardRef(({className:e,...s},r)=>t.jsx("textarea",{className:Y("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:r,...s}));Ct.displayName="Textarea";const pf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(`QUO-${new Date().getFullYear()}-${Date.now().toString().slice(-4)}`),[a,o]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState(""),[h,p]=c.useState(""),[g,f]=c.useState(""),[j,x]=c.useState([{description:"",quantity:1,unitPrice:0}]),{data:v}=fe({queryKey:["quote-clients",e?.id],queryFn:async()=>{const{data:E,error:M}=await W.from("clients").select("*").eq("user_id",e.id);if(M)throw M;return E},enabled:!!e?.id}),{data:b,isLoading:m}=fe({queryKey:["quotes",e?.id],queryFn:async()=>{const{data:E,error:M}=await W.from("quotes").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});if(M)throw M;return await Promise.all((E||[]).map(async N=>{const{data:S}=await W.from("clients").select("name, company").eq("id",N.client_id).single();return{...N,client:S}}))},enabled:!!e?.id}),w=Te({mutationFn:async E=>{if(!e?.id)throw new Error("User not authenticated");if(!a)throw new Error("Please select a client");if(!i||isNaN(parseFloat(i)))throw new Error("Please enter a valid subtotal");const M=parseFloat(i),L=parseFloat(d)||0,N=M+L,{data:S,error:T}=await W.from("quotes").insert({user_id:e.id,client_id:a,quote_number:r,subtotal:M,tax:L,total:N,notes:g,expiry_date:h||null}).select().single();if(T)throw T;for(const[H,z]of j.entries())if(z.description){const{error:G}=await W.from("quote_items").insert({quote_id:S.id,description:z.description,quantity:z.quantity,unit_price:z.unitPrice,amount:z.quantity*z.unitPrice,position:H+1});if(G)throw G}},onSuccess:()=>{s.invalidateQueries({queryKey:["quotes"]}),Q.success("Quote created successfully"),n(`QUO-${new Date().getFullYear()}-${Date.now().toString().slice(-4)}`),o(""),l(""),u(""),p(""),f(""),x([{description:"",quantity:1,unitPrice:0}])},onError:E=>{const M=E?.message||"Failed to create quote";Q.error(M),console.error("Error creating quote:",E)}}),P=Te({mutationFn:async E=>{const{data:M,error:L}=await W.rpc("convert_quote_to_invoice",{quote_id:E});if(L)throw L;return M},onSuccess:()=>{s.invalidateQueries({queryKey:["quotes"]}),s.invalidateQueries({queryKey:["invoices"]}),Q.success("Quote converted to invoice successfully")},onError:E=>{Q.error("Failed to convert quote to invoice"),console.error("Error converting quote:",E)}}),R=()=>{x([...j,{description:"",quantity:1,unitPrice:0}])},y=E=>{x(j.filter((M,L)=>L!==E))},C=(E,M,L)=>{const N=[...j];N[E]={...N[E],[M]:L},x(N);const S=N.reduce((T,H)=>T+H.quantity*H.unitPrice,0);l(S.toString())},B=E=>{const M={draft:"bg-gray-100 text-gray-800",sent:"bg-blue-100 text-blue-800",approved:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800",converted:"bg-purple-100 text-purple-800"};return M[E]||M.draft};return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("h2",{className:"text-2xl font-bold",children:"Quotes"})}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Create New Quote"})}),t.jsxs(F,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"quoteNumber",children:"Quote Number"}),t.jsx(K,{id:"quoteNumber",value:r,onChange:E=>n(E.target.value),placeholder:"Quote number"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"client",children:"Client"}),t.jsxs(Le,{value:a,onValueChange:o,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select a client"})}),t.jsx(Fe,{children:v?.map(E=>t.jsxs(oe,{value:E.id,children:[E.name," ",E.company&&`- ${E.company}`]},E.id))})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"expiryDate",children:"Expiry Date"}),t.jsx(K,{id:"expiryDate",type:"date",value:h,onChange:E=>p(E.target.value)})]})]}),t.jsxs("div",{children:[t.jsx($,{children:"Quote Items"}),t.jsx("div",{className:"space-y-2 mt-2",children:j.map((E,M)=>t.jsxs("div",{className:"grid grid-cols-12 gap-2 items-end",children:[t.jsx("div",{className:"col-span-5",children:t.jsx(K,{placeholder:"Description",value:E.description,onChange:L=>C(M,"description",L.target.value)})}),t.jsx("div",{className:"col-span-2",children:t.jsx(K,{type:"number",placeholder:"Qty",value:E.quantity,onChange:L=>C(M,"quantity",parseFloat(L.target.value)||0)})}),t.jsx("div",{className:"col-span-2",children:t.jsx(K,{type:"number",step:"0.01",placeholder:"Unit Price",value:E.unitPrice,onChange:L=>C(M,"unitPrice",parseFloat(L.target.value)||0)})}),t.jsx("div",{className:"col-span-2",children:t.jsx(K,{value:`$${(E.quantity*E.unitPrice).toFixed(2)}`,readOnly:!0,className:"bg-gray-50"})}),t.jsx("div",{className:"col-span-1",children:t.jsx(U,{type:"button",variant:"outline",size:"sm",onClick:()=>y(M),disabled:j.length===1,children:t.jsx(ja,{className:"h-4 w-4"})})})]},M))}),t.jsxs(U,{type:"button",variant:"outline",onClick:R,className:"mt-2",children:[t.jsx(Xs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"subtotal",children:"Subtotal"}),t.jsx(K,{id:"subtotal",type:"number",step:"0.01",value:i,onChange:E=>l(E.target.value),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"tax",children:"Tax"}),t.jsx(K,{id:"tax",type:"number",step:"0.01",value:d,onChange:E=>u(E.target.value),placeholder:"0.00"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"total",children:"Total"}),t.jsx(K,{id:"total",value:`$${((parseFloat(i)||0)+(parseFloat(d)||0)).toFixed(2)}`,readOnly:!0,className:"bg-gray-50"})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"notes",children:"Notes"}),t.jsx(Ct,{id:"notes",value:g,onChange:E=>f(E.target.value),placeholder:"Additional notes..."})]}),t.jsx(U,{onClick:()=>w.mutate({}),disabled:!a||!i||w.isPending,className:"w-full",children:"Create Quote"})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Existing Quotes"})}),t.jsx(F,{children:m?t.jsx("div",{className:"text-center py-8",children:"Loading quotes..."}):b?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No quotes found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Quote #"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Total"}),t.jsx(I,{children:"Issue Date"}),t.jsx(I,{children:"Expiry Date"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:b?.map(E=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:E.quote_number}),t.jsxs(k,{children:[E.client?.name," ",E.client?.company&&`- ${E.client.company}`]}),t.jsx(k,{children:t.jsx(je,{className:B(E.status),children:E.status})}),t.jsxs(k,{children:["$",E.total?.toFixed(2)]}),t.jsx(k,{children:Se(new Date(E.issue_date),"MMM dd, yyyy")}),t.jsx(k,{children:E.expiry_date?Se(new Date(E.expiry_date),"MMM dd, yyyy"):"-"}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{size:"sm",variant:"outline",onClick:()=>P.mutate(E.id),disabled:E.status==="converted"||P.isPending,title:"Convert to Invoice",children:t.jsx(Hl,{className:"h-4 w-4"})}),t.jsx(U,{size:"sm",variant:"outline",title:"View Quote",children:t.jsx(st,{className:"h-4 w-4"})})]})})]},E.id))})]})})]})]})},Rr=()=>{const{user:e}=Ce(),{data:s,isLoading:r}=fe({queryKey:["subscription",e?.id],queryFn:async()=>{if(!e?.id)return null;const{data:a,error:o}=await W.from("stripe_user_subscriptions").select("*").eq("user_id",e.id).single();return o?(console.error("Error fetching subscription:",o),null):a},enabled:!!e?.id,staleTime:1800*1e3,gcTime:3600*1e3,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return{isPro:s?.status==="active",isLoading:r,subscription:s}},Ci=()=>{const{isPro:e,isLoading:s}=Rr();return{hasAccess:e,isLoading:s,needsUpgrade:!e&&!s}},Rt=W,xf=()=>{const{user:e}=Ce(),s=Be(),{isPro:r}=Rr(),[n,a]=c.useState(""),[o,i]=c.useState(""),[l,d]=c.useState("draft"),[u,h]=c.useState(""),[p,g]=c.useState([{description:"",quantity:1,unit_price:""}]),[f,j]=c.useState(""),{data:x,isLoading:v}=fe({queryKey:["latest-invoice-number",e?.id],enabled:!!e,queryFn:async()=>{if(!e)return null;const{data:N,error:S}=await Rt.from("invoices").select("number").eq("user_id",e.id).order("created_at",{ascending:!1}).limit(1).single();if(S&&S.code!=="PGRST116")throw S;return N}});c.useEffect(()=>{if(v)a("...");else if(x&&x.number){const N=parseInt(x.number,10);isNaN(N)?a("1"):a((N+1).toString())}else a("1")},[x,v]);const b=fe({queryKey:["invoice-clients",e?.id],enabled:!!e,queryFn:async()=>{const{data:N,error:S}=await Rt.from("clients").select("id,name").eq("user_id",e.id).order("name");if(S)throw S;return N}}),m=fe({queryKey:["invoices",e?.id],enabled:!!e,queryFn:async()=>{const{data:N,error:S}=await Rt.from("invoices").select("id, number, status, total, issue_date, due_date, client:clients(name)").eq("user_id",e.id).order("created_at",{ascending:!1});if(S)throw S;return N}}),{subtotal:w,taxAmount:P,total:R}=c.useMemo(()=>{const N=p.reduce((H,z)=>{const G=Number(z.quantity)||0,ue=Number(z.unit_price)||0;return H+G*ue},0),S=N*(Number(f)/100),T=N+S;return{subtotal:N,taxAmount:S,total:T}},[p,f]),y=Te({mutationFn:async()=>{if(!e)throw new Error("Not authenticated");if(!o)throw new Error("Please choose a client");if(p.some(G=>!G.description||!G.quantity||!G.unit_price))throw new Error("Please fill all item fields.");const{data:N,error:S}=await Rt.from("invoices").insert([{user_id:e.id,client_id:o,number:n,status:l,issue_date:new Date().toISOString().slice(0,10),due_date:u||null,subtotal:w,tax:P,total:R}]).select();if(S)throw S;const T=N[0].id,H=p.map(G=>({invoice_id:T,description:G.description,quantity:Number(G.quantity),unit_price:Number(G.unit_price)})),{error:z}=await Rt.from("invoice_items").insert(H);if(z)throw await Rt.from("invoices").delete().eq("id",T),z},onSuccess:()=>{s.invalidateQueries({queryKey:["invoices",e?.id]}),a(""),i(""),g([{description:"",quantity:1,unit_price:""}]),j(""),d("draft"),h(""),Q.success("Invoice created successfully")},onError:N=>Q.error(N.message||"Failed to create invoice")}),C=(N,S,T)=>{const H=[...p];H[N][S]=T,g(H)},B=()=>{g([...p,{description:"",quantity:1,unit_price:""}])},E=N=>{if(p.length>1){const S=p.filter((T,H)=>H!==N);g(S)}},M=async N=>{try{const{data:S,error:T}=await W.functions.invoke("generate-invoice-pdf",{body:{invoiceId:N}});if(T)throw T;const H=new Blob([S],{type:"text/html"}),z=window.URL.createObjectURL(H);window.open(z,"_blank"),Q.success("Invoice opened in new tab. Use Print to save as PDF.")}catch(S){console.error("PDF generation error:",S),Q.error("Failed to generate invoice: "+(S.message||"Unknown error"))}},L=async(N,S)=>{try{const{data:{session:T}}=await W.auth.getSession(),H=await W.functions.invoke("send-invoice-email",{body:{invoiceId:N},headers:{Authorization:`Bearer ${T?.access_token}`}});if(H.error)throw H.error;Q.success(`Invoice ${S} sent successfully`)}catch(T){console.error("Email sending error:",T),Q.error("Failed to send invoice: "+(T.message||"Unknown error"))}};return t.jsxs("section",{className:"space-y-6",children:[t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Create Invoice"})}),t.jsx(F,{children:t.jsxs("form",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",onSubmit:N=>{N.preventDefault(),y.mutate()},children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"number",children:"Invoice #"}),t.jsx(K,{id:"number",value:n,readOnly:!0,disabled:v})]}),t.jsxs("div",{children:[t.jsx($,{children:"Client"}),t.jsxs(Le,{value:o,onValueChange:i,required:!0,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select client"})}),t.jsx(Fe,{children:b.data?.map(N=>t.jsx(oe,{value:N.id,children:N.name},N.id))})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"due",children:"Due date"}),t.jsx(K,{id:"due",type:"date",value:u,onChange:N=>h(N.target.value)})]}),t.jsxs("div",{className:"md:col-span-2 lg:col-span-3 space-y-4",children:[t.jsx($,{children:"Items"}),t.jsx("div",{className:"space-y-2",children:p.map((N,S)=>t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2",children:[t.jsx(K,{placeholder:"Item description",value:N.description,onChange:T=>C(S,"description",T.target.value),className:"w-full",required:!0}),t.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[t.jsx(K,{type:"number",placeholder:"Qty",value:N.quantity,onChange:T=>C(S,"quantity",T.target.value?Number(T.target.value):""),className:"w-1/2 sm:w-20",min:"1",required:!0}),t.jsx(K,{type:"number",step:"0.01",placeholder:"Unit Price",value:N.unit_price,onChange:T=>C(S,"unit_price",T.target.value?Number(T.target.value):""),className:"w-1/2 sm:w-28",min:"0",required:!0})]}),t.jsx(U,{type:"button",variant:"destructive",size:"icon",onClick:()=>E(S),disabled:p.length<=1,children:t.jsx(Xl,{className:"h-4 w-4"})})]},S))}),t.jsx(U,{type:"button",variant:"outline",size:"sm",onClick:B,children:"Add Item"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"tax",children:"Tax Rate (%)"}),t.jsx(K,{id:"tax",type:"number",step:"0.01",value:f,onChange:N=>j(N.target.value),placeholder:"e.g. 10"})]}),t.jsxs("div",{children:[t.jsx($,{children:"Status"}),t.jsxs(Le,{value:l,onValueChange:d,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select status"})}),t.jsxs(Fe,{children:[t.jsx(oe,{value:"draft",children:"Draft"}),t.jsx(oe,{value:"sent",children:"Sent"}),t.jsx(oe,{value:"paid",children:"Paid"}),t.jsx(oe,{value:"overdue",children:"Overdue"}),t.jsx(oe,{value:"void",children:"Void"})]})]})]}),t.jsx("div",{className:"md:col-span-2 lg:col-span-3",children:t.jsxs("div",{className:"text-lg font-semibold",children:["Total: $",R.toFixed(2)]})}),t.jsx("div",{className:"md:col-span-2 lg:col-span-3",children:t.jsx(U,{type:"submit",disabled:y.isPending||v,children:"Create Invoice"})})]})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Invoices"})}),t.jsx(F,{children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{className:"min-w-[80px]",children:"#"}),t.jsx(I,{className:"min-w-[120px]",children:"Client"}),t.jsx(I,{className:"min-w-[80px]",children:"Status"}),t.jsx(I,{className:"min-w-[80px]",children:"Total"}),t.jsx(I,{className:"min-w-[100px]",children:"Issued"}),t.jsx(I,{className:"min-w-[100px]",children:"Due"}),t.jsx(I,{className:"min-w-[200px]",children:"Actions"})]})}),t.jsx(Oe,{children:m.isLoading?t.jsx(ne,{children:t.jsx(k,{colSpan:7,children:"Loading…"})}):m.data&&m.data.length>0?m.data.map(N=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium text-sm",children:N.number}),t.jsx(k,{className:"text-sm",children:N.client?.name??"—"}),t.jsx(k,{className:"capitalize text-sm",children:t.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${N.status==="paid"?"bg-green-100 text-green-700":N.status==="sent"?"bg-blue-100 text-blue-700":N.status==="overdue"?"bg-red-100 text-red-700":"bg-gray-100 text-gray-700"}`,children:N.status})}),t.jsxs(k,{className:"font-medium text-sm",children:["$",Number(N.total).toFixed(2)]}),t.jsx(k,{className:"text-sm",children:N.issue_date}),t.jsx(k,{className:"text-sm",children:N.due_date||"—"}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-1 flex-wrap",children:[t.jsx(U,{size:"sm",variant:"outline",className:"text-xs px-2",children:"Edit"}),r?t.jsxs(t.Fragment,{children:[t.jsxs(U,{size:"sm",variant:"secondary",className:"flex items-center gap-1 text-xs px-2",onClick:()=>M(N.id),children:[t.jsx(ba,{className:"h-3 w-3"}),t.jsx("span",{className:"hidden sm:inline",children:"HTML"})]}),t.jsxs(U,{size:"sm",variant:"default",className:"flex items-center gap-1 text-xs px-2",onClick:()=>L(N.id,N.number),children:[t.jsx(hs,{className:"h-3 w-3"}),t.jsx("span",{className:"hidden sm:inline",children:"Send"})]})]}):t.jsxs(U,{size:"sm",variant:"secondary",onClick:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),className:"text-xs flex items-center gap-1 px-2",children:[t.jsx(We,{className:"h-3 w-3"}),t.jsx("span",{className:"hidden sm:inline",children:"Pro"})]}),t.jsxs(U,{size:"sm",variant:"destructive",className:"text-xs px-2",children:[t.jsx("span",{className:"hidden sm:inline",children:"Delete"}),t.jsx("span",{className:"sm:hidden",children:"×"})]})]})})]},N.id)):t.jsx(ne,{children:t.jsx(k,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No invoices yet"})})})]})})})]})]})};var Ds="Switch",[gf]=ts(Ds),[yf,vf]=gf(Ds),Si=c.forwardRef((e,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:i,disabled:l,value:d="on",onCheckedChange:u,form:h,...p}=e,[g,f]=c.useState(null),j=ke(s,w=>f(w)),x=c.useRef(!1),v=g?h||!!g.closest("form"):!0,[b,m]=Yt({prop:a,defaultProp:o??!1,onChange:u,caller:Ds});return t.jsxs(yf,{scope:r,checked:b,disabled:l,children:[t.jsx(de.button,{type:"button",role:"switch","aria-checked":b,"aria-required":i,"data-state":ki(b),"data-disabled":l?"":void 0,disabled:l,value:d,...p,ref:j,onClick:Z(e.onClick,w=>{m(P=>!P),v&&(x.current=w.isPropagationStopped(),x.current||w.stopPropagation())})}),v&&t.jsx(Pi,{control:g,bubbles:!x.current,name:n,value:d,checked:b,required:i,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});Si.displayName=Ds;var Ti="SwitchThumb",Ei=c.forwardRef((e,s)=>{const{__scopeSwitch:r,...n}=e,a=vf(Ti,r);return t.jsx(de.span,{"data-state":ki(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});Ei.displayName=Ti;var bf="SwitchBubbleInput",Pi=c.forwardRef(({__scopeSwitch:e,control:s,checked:r,bubbles:n=!0,...a},o)=>{const i=c.useRef(null),l=ke(i,o),d=Mo(r),u=nl(s);return c.useEffect(()=>{const h=i.current;if(!h)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==r&&f){const j=new Event("click",{bubbles:n});f.call(h,r),h.dispatchEvent(j)}},[d,r,n]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Pi.displayName=bf;function ki(e){return e?"checked":"unchecked"}var Ri=Si,wf=Ei;const ns=c.forwardRef(({className:e,...s},r)=>t.jsx(Ri,{className:Y("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:r,children:t.jsx(wf,{className:Y("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));ns.displayName=Ri.displayName;const jf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState(""),[h,p]=c.useState(""),[g,f]=c.useState(new Date().toISOString().split("T")[0]),[j,x]=c.useState(!0),[v,b]=c.useState(!1),[m,w]=c.useState(null),{data:P}=fe({queryKey:["time-clients",e?.id],queryFn:async()=>{const{data:S,error:T}=await W.from("clients").select("*").eq("user_id",e.id);if(T)throw T;return S},enabled:!!e?.id}),{data:R,isLoading:y}=fe({queryKey:["time-entries",e?.id],queryFn:async()=>{const{data:S,error:T}=await W.from("time_entries").select("*").eq("user_id",e.id).order("date",{ascending:!1});if(T)throw T;return await Promise.all((S||[]).map(async z=>{if(!z.client_id)return{...z,client:null};const{data:G}=await W.from("clients").select("name, company").eq("id",z.client_id).single();return{...z,client:G}}))},enabled:!!e?.id}),C=Te({mutationFn:async S=>{const T=parseFloat(d)*parseFloat(h),{error:H}=await W.from("time_entries").insert({user_id:e.id,client_id:r||null,project_name:a||null,description:i,hours_worked:parseFloat(d),hourly_rate:parseFloat(h),total_amount:T,date:g,is_billable:j});if(H)throw H},onSuccess:()=>{s.invalidateQueries({queryKey:["time-entries"]}),Q.success("Time entry created successfully"),n(""),o(""),l(""),u(""),p(""),f(new Date().toISOString().split("T")[0]),x(!0)},onError:S=>{Q.error("Failed to create time entry"),console.error("Error creating time entry:",S)}}),B=()=>{b(!0),w(new Date),Q.success("Timer started")},E=()=>{if(m){const H=(new Date().getTime()-m.getTime())/(1e3*60*60);u(H.toFixed(2)),Q.success(`Timer stopped. Logged ${H.toFixed(2)} hours`)}b(!1),w(null)},M=Te({mutationFn:async S=>{for(const T of S){const{error:H}=await W.from("time_entries").update({is_invoiced:!0}).eq("id",T);if(H)throw H}},onSuccess:()=>{s.invalidateQueries({queryKey:["time-entries"]}),Q.success("Time entries converted to invoice")},onError:S=>{Q.error("Failed to convert time entries"),console.error("Error converting entries:",S)}}),L=R?.reduce((S,T)=>T.is_billable&&!T.is_invoiced?S+T.hours_worked:S,0)||0,N=R?.reduce((S,T)=>T.is_billable&&!T.is_invoiced?S+T.total_amount:S,0)||0;return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("h2",{className:"text-2xl font-bold",children:"Time Tracking"})}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Unbilled Hours"}),t.jsx(va,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsx("div",{className:"text-2xl font-bold",children:L.toFixed(2)})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Unbilled Amount"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",N.toFixed(2)]})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Timer Status"}),v?t.jsx(Kr,{className:"h-4 w-4 text-green-600"}):t.jsx(Yr,{className:"h-4 w-4 text-gray-400"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:v?"Running":"Stopped"}),v&&m&&t.jsxs("div",{className:"text-sm text-muted-foreground",children:["Started: ",Se(m,"HH:mm")]})]})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Log Time Entry"})}),t.jsxs(F,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"client",children:"Client"}),t.jsxs(Le,{value:r,onValueChange:n,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select a client (optional)"})}),t.jsx(Fe,{children:P?.map(S=>t.jsxs(oe,{value:S.id,children:[S.name," ",S.company&&`- ${S.company}`]},S.id))})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"projectName",children:"Project Name"}),t.jsx(K,{id:"projectName",value:a,onChange:S=>o(S.target.value),placeholder:"Project name (optional)"})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"description",children:"Description"}),t.jsx(Ct,{id:"description",value:i,onChange:S=>l(S.target.value),placeholder:"What did you work on?",required:!0})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"hoursWorked",children:"Hours Worked"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(K,{id:"hoursWorked",type:"number",step:"0.25",value:d,onChange:S=>u(S.target.value),placeholder:"0.00",required:!0}),v?t.jsx(U,{onClick:E,variant:"outline",size:"sm",children:t.jsx(Yr,{className:"h-4 w-4"})}):t.jsx(U,{onClick:B,variant:"outline",size:"sm",children:t.jsx(Kr,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"hourlyRate",children:"Hourly Rate"}),t.jsx(K,{id:"hourlyRate",type:"number",step:"0.01",value:h,onChange:S=>p(S.target.value),placeholder:"0.00",required:!0})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"date",children:"Date"}),t.jsx(K,{id:"date",type:"date",value:g,onChange:S=>f(S.target.value),required:!0})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(ns,{id:"billable",checked:j,onCheckedChange:x}),t.jsx($,{htmlFor:"billable",children:"Billable"})]})})]}),t.jsxs("div",{children:[t.jsx($,{children:"Total Amount"}),t.jsx(K,{value:`$${((parseFloat(d)||0)*(parseFloat(h)||0)).toFixed(2)}`,readOnly:!0,className:"bg-gray-50"})]}),t.jsx(U,{onClick:()=>C.mutate({}),disabled:!i||!d||!h||C.isPending,className:"w-full",children:"Log Time Entry"})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Time Entries"})}),t.jsx(F,{children:y?t.jsx("div",{className:"text-center py-8",children:"Loading time entries..."}):R?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No time entries found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Date"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Project"}),t.jsx(I,{children:"Description"}),t.jsx(I,{children:"Hours"}),t.jsx(I,{children:"Rate"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:R?.map(S=>t.jsxs(ne,{children:[t.jsx(k,{children:Se(new Date(S.date),"MMM dd, yyyy")}),t.jsx(k,{children:S.client?.name||"-"}),t.jsx(k,{children:S.project_name||"-"}),t.jsx(k,{className:"max-w-xs truncate",children:S.description}),t.jsx(k,{children:S.hours_worked}),t.jsxs(k,{children:["$",S.hourly_rate]}),t.jsxs(k,{children:["$",S.total_amount?.toFixed(2)]}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-1",children:[S.is_billable&&t.jsx(je,{variant:"secondary",className:"text-xs",children:"Billable"}),S.is_invoiced&&t.jsx(je,{variant:"default",className:"text-xs",children:"Invoiced"})]})}),t.jsx(k,{children:S.is_billable&&!S.is_invoiced&&t.jsx(U,{size:"sm",variant:"outline",onClick:()=>M.mutate([S.id]),disabled:M.isPending,title:"Convert to Invoice",children:t.jsx(st,{className:"h-4 w-4"})})})]},S.id))})]})})]})]})},Nf=["Travel & Transportation","Meals & Entertainment","Office Supplies","Equipment","Software & Subscriptions","Marketing & Advertising","Professional Services","Utilities","Rent & Facilities","Other"],Cf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState(new Date().toISOString().split("T")[0]),[h,p]=c.useState(""),[g,f]=c.useState(!1),{data:j}=fe({queryKey:["expense-clients",e?.id],queryFn:async()=>{const{data:y,error:C}=await W.from("clients").select("*").eq("user_id",e.id);if(C)throw C;return y},enabled:!!e?.id}),{data:x,isLoading:v}=fe({queryKey:["expenses",e?.id],queryFn:async()=>{const{data:y,error:C}=await W.from("expenses").select("*").eq("user_id",e.id).order("date",{ascending:!1});if(C)throw C;return await Promise.all((y||[]).map(async E=>{if(!E.client_id)return{...E,client:null};const{data:M}=await W.from("clients").select("name, company").eq("id",E.client_id).single();return{...E,client:M}}))},enabled:!!e?.id}),b=Te({mutationFn:async y=>{const{error:C}=await W.from("expenses").insert({user_id:e.id,client_id:r||null,description:a,amount:parseFloat(i),date:d,category:h||null,is_billable:g});if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["expenses"]}),Q.success("Expense created successfully"),n(""),o(""),l(""),u(new Date().toISOString().split("T")[0]),p(""),f(!1)},onError:y=>{Q.error("Failed to create expense"),console.error("Error creating expense:",y)}}),m=Te({mutationFn:async y=>{for(const C of y){const{error:B}=await W.from("expenses").update({is_invoiced:!0}).eq("id",C);if(B)throw B}},onSuccess:()=>{s.invalidateQueries({queryKey:["expenses"]}),Q.success("Expenses converted to invoice")},onError:y=>{Q.error("Failed to convert expenses"),console.error("Error converting expenses:",y)}}),w=x?.reduce((y,C)=>y+C.amount,0)||0,P=x?.reduce((y,C)=>C.is_billable&&!C.is_invoiced?y+C.amount:y,0)||0,R=x?.reduce((y,C)=>{const B=new Date(C.date),E=new Date;return B.getMonth()===E.getMonth()&&B.getFullYear()===E.getFullYear()?y+C.amount:y},0)||0;return t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsx("h2",{className:"text-2xl font-bold",children:"Expenses"})}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Expenses"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",w.toFixed(2)]})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"This Month"}),t.jsx(Na,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",R.toFixed(2)]})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Billable Expenses"}),t.jsx(Kl,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",P.toFixed(2)]})})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Add New Expense"})}),t.jsxs(F,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"description",children:"Description"}),t.jsx(Ct,{id:"description",value:a,onChange:y=>o(y.target.value),placeholder:"What was this expense for?",required:!0})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"amount",children:"Amount"}),t.jsx(K,{id:"amount",type:"number",step:"0.01",value:i,onChange:y=>l(y.target.value),placeholder:"0.00",required:!0})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"date",children:"Date"}),t.jsx(K,{id:"date",type:"date",value:d,onChange:y=>u(y.target.value),required:!0})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"category",children:"Category"}),t.jsxs(Le,{value:h,onValueChange:p,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select a category"})}),t.jsx(Fe,{children:Nf.map(y=>t.jsx(oe,{value:y,children:y},y))})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"client",children:"Client (if billable)"}),t.jsxs(Le,{value:r,onValueChange:n,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select a client (optional)"})}),t.jsx(Fe,{children:j?.map(y=>t.jsxs(oe,{value:y.id,children:[y.name," ",y.company&&`- ${y.company}`]},y.id))})]})]})]}),t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(ns,{id:"billable",checked:g,onCheckedChange:f}),t.jsx($,{htmlFor:"billable",children:"This is a billable expense"})]}),t.jsx(U,{onClick:()=>b.mutate({}),disabled:!a||!i||b.isPending,className:"w-full",children:"Add Expense"})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Expense History"})}),t.jsx(F,{children:v?t.jsx("div",{className:"text-center py-8",children:"Loading expenses..."}):x?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No expenses found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Date"}),t.jsx(I,{children:"Description"}),t.jsx(I,{children:"Category"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:x?.map(y=>t.jsxs(ne,{children:[t.jsx(k,{children:Se(new Date(y.date),"MMM dd, yyyy")}),t.jsx(k,{className:"max-w-xs truncate",children:y.description}),t.jsx(k,{children:y.category||"-"}),t.jsx(k,{children:y.client?.name||"-"}),t.jsxs(k,{children:["$",y.amount.toFixed(2)]}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-1",children:[y.is_billable&&t.jsx(je,{variant:"secondary",className:"text-xs",children:"Billable"}),y.is_invoiced&&t.jsx(je,{variant:"default",className:"text-xs",children:"Invoiced"})]})}),t.jsx(k,{children:y.is_billable&&!y.is_invoiced&&t.jsx(U,{size:"sm",variant:"outline",onClick:()=>m.mutate([y.id]),disabled:m.isPending,title:"Convert to Invoice",children:t.jsx(st,{className:"h-4 w-4"})})})]},y.id))})]})})]})]})},Sf=(e,s)=>{document.title=e;const r=(n,a)=>{let o=document.head.querySelector(n);return o||(o=a(),document.head.appendChild(o)),o};r('meta[name="description"]',()=>{const n=document.createElement("meta");return n.setAttribute("name","description"),n}).setAttribute("content",s),r('link[rel="canonical"]',()=>{const n=document.createElement("link");return n.setAttribute("rel","canonical"),n}).setAttribute("href",window.location.href)},On=W,Tf=()=>{const{user:e}=Ce(),{isPro:s,isLoading:r}=Rr();c.useEffect(()=>{Sf("Dashboard Overview | HonestInvoice","Your business at a glance: recent invoices, client activity, payment reminders, and key metrics.")},[]);const n=fe({queryKey:["clients-count",e?.id],enabled:!!e,queryFn:async()=>{const{count:o,error:i}=await On.from("clients").select("*",{count:"exact",head:!0}).eq("user_id",e.id);if(i)throw i;return o??0}}),a=fe({queryKey:["invoices-count",e?.id],enabled:!!e,queryFn:async()=>{const{count:o,error:i}=await On.from("invoices").select("*",{count:"exact",head:!0}).eq("user_id",e.id);if(i)throw i;return o??0}});return t.jsxs("section",{className:"space-y-6",children:[!r&&t.jsx(D,{className:`border-2 ${s?"border-primary bg-primary/5":"border-accent bg-accent/10"}`,children:t.jsx(F,{className:"pt-6",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[t.jsx("div",{className:"flex items-center gap-3",children:s?t.jsxs(t.Fragment,{children:[t.jsx(We,{className:"h-6 w-6 text-primary flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-primary",children:"Pro Account Active"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Enjoy unlimited features and priority support"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(We,{className:"h-6 w-6 text-accent flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-accent",children:"Upgrade to Pro"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Unlock advanced features like custom branding, analytics, and PDF exports"})]})]})}),!s&&t.jsxs(U,{onClick:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),className:"flex items-center gap-2 w-full sm:w-auto justify-center",children:["Upgrade Now",t.jsx($l,{className:"h-4 w-4"})]})]})})}),t.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Clients"}),t.jsx(vr,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:n.isLoading?"—":n.data}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Active client relationships"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Invoices"}),t.jsx(st,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:a.isLoading?"—":a.data}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Invoices created"})]})]})]}),!s&&t.jsxs(D,{className:"border-primary/20",children:[t.jsx(A,{children:t.jsxs(q,{className:"flex items-center gap-2",children:[t.jsx(We,{className:"h-5 w-5 text-primary"}),"Pro Features"]})}),t.jsxs(F,{children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[t.jsx(fs,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),t.jsx("h4",{className:"font-semibold mb-1",children:"Advanced Analytics"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Detailed business insights and revenue tracking"})]}),t.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[t.jsx(We,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),t.jsx("h4",{className:"font-semibold mb-1",children:"Custom Branding"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Add your logo and colors to invoices"})]}),t.jsxs("div",{className:"text-center p-4 border rounded-lg",children:[t.jsx(st,{className:"h-8 w-8 mx-auto mb-2 text-primary"}),t.jsx("h4",{className:"font-semibold mb-1",children:"PDF Export"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Export and send professional invoices"})]})]}),t.jsx("div",{className:"text-center mt-6",children:t.jsxs(U,{onClick:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),size:"lg",className:"flex items-center gap-2 w-full sm:w-auto justify-center",children:[t.jsx(We,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Upgrade to Pro - $4.99/month"}),t.jsx("span",{className:"sm:hidden",children:"Upgrade to Pro"})]})})]})]})]})},Ef=[{value:"gentle",label:"Gentle Reminder",daysAfter:3},{value:"standard",label:"Standard Reminder",daysAfter:7},{value:"urgent",label:"Urgent Reminder",daysAfter:14},{value:"final",label:"Final Notice",daysAfter:30}],Pf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState(!1),{data:d}=fe({queryKey:["overdue-invoices",e?.id],queryFn:async()=>{const{data:m,error:w}=await W.from("invoices").select(` *, client:clients(name, email, company) `).eq("user_id",e.id).in("status",["sent","overdue"]).order("due_date",{ascending:!0});if(w)throw w;const P=new Date;return(m||[]).map(R=>({...R,daysOverdue:R.due_date?Math.max(0,Sn(P,new Date(R.due_date))):0}))},enabled:!!e?.id}),{data:u,isLoading:h}=fe({queryKey:["payment-reminders",e?.id],queryFn:async()=>{const{data:m,error:w}=await W.from("payment_reminders").select("*").eq("user_id",e.id).order("created_at",{ascending:!1});if(w)throw w;return await Promise.all((m||[]).map(async R=>{const{data:y}=await W.from("invoices").select(` number, total, client:clients(name, company) `).eq("id",R.invoice_id).single();return{...R,invoice:y}}))},enabled:!!e?.id}),p=Te({mutationFn:async({invoiceId:m,type:w})=>{const P=d?.find(C=>C.id===m);if(!P)throw new Error("Invoice not found");const{error:R}=await W.from("payment_reminders").insert({user_id:e.id,invoice_id:m,reminder_type:w,days_overdue:P.daysOverdue,sent_at:new Date().toISOString()});if(R)throw R;const{error:y}=await W.functions.invoke("send-invoice-email",{body:{invoiceId:m,isReminder:!0,reminderType:w}});if(y)throw y;return{invoiceId:m,type:w}},onSuccess:m=>{s.invalidateQueries({queryKey:["payment-reminders"]}),s.invalidateQueries({queryKey:["overdue-invoices"]}),Q.success(`${m.type} reminder sent successfully`),n(""),o("")},onError:m=>{Q.error("Failed to send reminder"),console.error("Error sending reminder:",m)}}),g=Te({mutationFn:async()=>{if(!d)return;const m=[];for(const w of d){let P="gentle";if(w.daysOverdue>=30?P="final":w.daysOverdue>=14?P="urgent":w.daysOverdue>=7&&(P="standard"),!(await W.from("payment_reminders").select("*").eq("invoice_id",w.id).eq("reminder_type",P).single()).data)try{await W.from("payment_reminders").insert({user_id:e.id,invoice_id:w.id,reminder_type:P,days_overdue:w.daysOverdue,sent_at:new Date().toISOString()}),await W.functions.invoke("send-invoice-email",{body:{invoiceId:w.id,isReminder:!0,reminderType:P}}),m.push({invoice:w.number,type:P,success:!0})}catch(y){m.push({invoice:w.number,type:P,success:!1,error:y})}}return m},onSuccess:m=>{s.invalidateQueries({queryKey:["payment-reminders"]}),s.invalidateQueries({queryKey:["overdue-invoices"]});const w=m?.filter(R=>R.success).length||0,P=m?.length||0;w===P?Q.success(`Successfully sent ${w} payment reminders`):Q.warning(`Sent ${w} of ${P} reminders. Some failed.`)},onError:m=>{Q.error("Failed to send bulk reminders"),console.error("Error sending bulk reminders:",m)}}),f=d?.reduce((m,w)=>m+w.total,0)||0,j=d?.filter(m=>m.daysOverdue>30).length||0,x=u?.filter(m=>Sn(new Date,new Date(m.created_at))<=7).length||0,v=m=>{const w={gentle:"bg-blue-100 text-blue-800",standard:"bg-yellow-100 text-yellow-800",urgent:"bg-orange-100 text-orange-800",final:"bg-red-100 text-red-800"};return w[m]||w.gentle},b=m=>m===0?"bg-green-100 text-green-800":m<=7?"bg-yellow-100 text-yellow-800":m<=30?"bg-orange-100 text-orange-800":"bg-red-100 text-red-800";return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-2xl font-bold",children:"Payment Reminders"}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(ns,{id:"auto-reminders",checked:i,onCheckedChange:l}),t.jsx($,{htmlFor:"auto-reminders",children:"Auto-send reminders"})]}),t.jsxs(U,{onClick:()=>g.mutate(),disabled:g.isPending||!d?.length,children:[t.jsx(hs,{className:"h-4 w-4 mr-2"}),"Send All Due"]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Overdue"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:["$",f.toFixed(2)]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[d?.length||0," overdue invoices"]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Critical (30+ days)"}),t.jsx(Jl,{className:"h-4 w-4 text-red-500"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:j}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Need immediate attention"})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Reminders Sent (7 days)"}),t.jsx(Ql,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:x}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"This week"})]})]})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Send Payment Reminder"})}),t.jsx(F,{className:"space-y-4",children:t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"invoice",children:"Select Invoice"}),t.jsxs(Le,{value:r,onValueChange:n,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Choose an overdue invoice"})}),t.jsx(Fe,{children:d?.map(m=>t.jsxs(oe,{value:m.id,children:[m.number," - ",m.client?.name,m.daysOverdue>0&&` (${m.daysOverdue} days overdue)`]},m.id))})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"reminderType",children:"Reminder Type"}),t.jsxs(Le,{value:a,onValueChange:o,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select reminder type"})}),t.jsx(Fe,{children:Ef.map(m=>t.jsx(oe,{value:m.value,children:m.label},m.value))})]})]}),t.jsx("div",{className:"flex items-end",children:t.jsxs(U,{onClick:()=>p.mutate({invoiceId:r,type:a}),disabled:!r||!a||p.isPending,className:"w-full",children:[t.jsx(hs,{className:"h-4 w-4 mr-2"}),"Send Reminder"]})})]})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Overdue Invoices"})}),t.jsx(F,{children:d?.length?t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Invoice #"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Due Date"}),t.jsx(I,{children:"Days Overdue"}),t.jsx(I,{children:"Last Reminder"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:d.map(m=>{const w=u?.find(P=>P.invoice_id===m.id);return t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:m.number}),t.jsx(k,{children:t.jsxs("div",{children:[t.jsx("div",{className:"font-medium",children:m.client?.name}),t.jsx("div",{className:"text-sm text-gray-500",children:m.client?.email})]})}),t.jsxs(k,{children:["$",m.total.toFixed(2)]}),t.jsx(k,{children:m.due_date?Se(new Date(m.due_date),"MMM dd, yyyy"):"-"}),t.jsx(k,{children:t.jsx(je,{className:b(m.daysOverdue),children:m.daysOverdue===0?"Due today":`${m.daysOverdue} days`})}),t.jsx(k,{children:w?t.jsxs("div",{className:"text-sm",children:[t.jsx(je,{className:v(w.reminder_type),children:w.reminder_type}),t.jsx("div",{className:"text-xs text-gray-500 mt-1",children:Se(new Date(w.sent_at),"MMM dd")})]}):t.jsx("span",{className:"text-gray-400",children:"None sent"})}),t.jsx(k,{children:t.jsx(U,{size:"sm",variant:"outline",onClick:()=>{n(m.id);let P="gentle";m.daysOverdue>=30?P="final":m.daysOverdue>=14?P="urgent":m.daysOverdue>=7&&(P="standard"),o(P)},title:"Send Reminder",children:t.jsx(hs,{className:"h-4 w-4"})})})]},m.id)})})]}):t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No overdue invoices found! 🎉"})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Reminder History"})}),t.jsx(F,{children:h?t.jsx("div",{className:"text-center py-8",children:"Loading reminder history..."}):u?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No reminders sent yet"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Date Sent"}),t.jsx(I,{children:"Invoice #"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Type"}),t.jsx(I,{children:"Days Overdue"}),t.jsx(I,{children:"Status"})]})}),t.jsx(Oe,{children:u?.map(m=>t.jsxs(ne,{children:[t.jsx(k,{children:m.sent_at?Se(new Date(m.sent_at),"MMM dd, yyyy HH:mm"):"-"}),t.jsx(k,{className:"font-medium",children:m.invoice?.number}),t.jsx(k,{children:m.invoice?.client?.name}),t.jsx(k,{children:t.jsx(je,{className:v(m.reminder_type),children:m.reminder_type})}),t.jsxs(k,{children:[m.days_overdue," days"]}),t.jsx(k,{children:t.jsx(je,{variant:"outline",className:"bg-green-100 text-green-800",children:"Sent"})})]},m.id))})]})})]})]})},Ir=({children:e,featureName:s,description:r,fallback:n})=>{const{hasAccess:a,isLoading:o}=Ci();return o?t.jsx("div",{className:"flex items-center justify-center p-8",children:t.jsx("div",{className:"h-6 w-20 bg-muted animate-pulse rounded"})}):a?t.jsx(t.Fragment,{children:e}):n?t.jsx(t.Fragment,{children:n}):t.jsxs(D,{className:"border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:[t.jsxs(A,{className:"text-center",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[t.jsx(Vl,{className:"h-5 w-5 text-primary"}),t.jsxs(je,{variant:"secondary",className:"flex items-center gap-1",children:[t.jsx(We,{className:"h-3 w-3"}),"Pro Feature"]})]}),t.jsx(q,{className:"flex items-center justify-center gap-2",children:s}),r&&t.jsx(qe,{className:"text-center",children:r})]}),t.jsxs(F,{className:"text-center",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upgrade to Pro to unlock this feature and get access to advanced tools."}),t.jsxs(U,{onClick:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),className:"w-full",children:[t.jsx(We,{className:"h-4 w-4 mr-2"}),"Upgrade to Pro - $4.99/month"]})]})]})},xt=W,kf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState("monthly"),[d,u]=c.useState(""),[h,p]=c.useState(""),[g,f]=c.useState(""),[j,x]=c.useState(""),v=fe({queryKey:["recurring-clients",e?.id],enabled:!!e,queryFn:async()=>{const{data:y,error:C}=await xt.from("clients").select("id,name").eq("user_id",e.id).order("name");if(C)throw C;return y}}),b=fe({queryKey:["recurring-invoices",e?.id],enabled:!!e,queryFn:async()=>{const{data:y,error:C}=await xt.from("recurring_invoices").select(` id, template_number, frequency, next_due_date, last_generated_date, is_active, total, notes, created_at, client:clients(name) `).eq("user_id",e.id).order("created_at",{ascending:!1});if(C)throw C;return y}}),m=Te({mutationFn:async()=>{if(!e)throw new Error("Not authenticated");if(!a)throw new Error("Please choose a client");if(!d)throw new Error("Please set next due date");const y=Number(h||0)+Number(g||0),{error:C}=await xt.from("recurring_invoices").insert([{user_id:e.id,client_id:a,template_number:r,frequency:i,next_due_date:d,subtotal:Number(h||0),tax:Number(g||0),total:y,notes:j||null}]);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["recurring-invoices",e?.id]}),n(""),o(""),l("monthly"),u(""),p(""),f(""),x(""),Q.success("Recurring invoice template created")},onError:y=>Q.error(y.message||"Failed to create recurring invoice")}),w=Te({mutationFn:async({id:y,isActive:C})=>{const{error:B}=await xt.from("recurring_invoices").update({is_active:!C}).eq("id",y);if(B)throw B},onSuccess:()=>{s.invalidateQueries({queryKey:["recurring-invoices",e?.id]}),Q.success("Recurring invoice updated")},onError:y=>Q.error(y.message||"Failed to update recurring invoice")}),P=Te({mutationFn:async y=>{const{error:C}=await xt.from("recurring_invoices").delete().eq("id",y);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["recurring-invoices",e?.id]}),Q.success("Recurring invoice deleted")},onError:y=>Q.error(y.message||"Failed to delete recurring invoice")}),R=Te({mutationFn:async y=>{const C=b.data?.find(S=>S.id===y);if(!C)throw new Error("Recurring invoice not found");const B=`${C.template_number}-${Date.now()}`,{error:E}=await xt.from("invoices").insert([{user_id:e.id,client_id:C.client_id,number:B,status:"sent",issue_date:new Date().toISOString().slice(0,10),subtotal:C.subtotal,tax:C.tax,total:C.total,notes:C.notes}]);if(E)throw E;const M=new Date;let L;switch(C.frequency){case"weekly":L=lm(M,1);break;case"monthly":L=ms(M,1);break;case"quarterly":L=ms(M,3);break;case"annually":L=cm(M,1);break;default:L=ms(M,1)}const{error:N}=await xt.from("recurring_invoices").update({next_due_date:Se(L,"yyyy-MM-dd"),last_generated_date:Se(M,"yyyy-MM-dd")}).eq("id",y);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["recurring-invoices",e?.id]}),s.invalidateQueries({queryKey:["invoices",e?.id]}),Q.success("Invoice generated successfully")},onError:y=>Q.error(y.message||"Failed to generate invoice")});return t.jsx(Ir,{featureName:"Recurring Invoices",description:"Set up automatic recurring invoices for your regular clients. Invoices will be generated automatically based on your schedule.",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yl,{className:"h-6 w-6 text-primary"}),t.jsx("h2",{className:"text-2xl font-bold text-primary",children:"Recurring Invoices"})]}),t.jsxs(D,{className:"border-primary/20",children:[t.jsx(A,{children:t.jsxs(q,{className:"flex items-center gap-2",children:[t.jsx(Xs,{className:"h-5 w-5"}),"Create Recurring Invoice Template"]})}),t.jsx(F,{children:t.jsxs("form",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",onSubmit:y=>{y.preventDefault(),m.mutate()},children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"template_number",children:"Template Number"}),t.jsx(K,{id:"template_number",value:r,onChange:y=>n(y.target.value),placeholder:"e.g., REC-001",required:!0})]}),t.jsxs("div",{children:[t.jsx($,{children:"Client"}),t.jsxs(Le,{value:a,onValueChange:o,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select client"})}),t.jsx(Fe,{children:v.data?.map(y=>t.jsx(oe,{value:y.id,children:y.name},y.id))})]})]}),t.jsxs("div",{children:[t.jsx($,{children:"Frequency"}),t.jsxs(Le,{value:i,onValueChange:l,children:[t.jsx(De,{children:t.jsx($e,{})}),t.jsxs(Fe,{children:[t.jsx(oe,{value:"weekly",children:"Weekly"}),t.jsx(oe,{value:"monthly",children:"Monthly"}),t.jsx(oe,{value:"quarterly",children:"Quarterly"}),t.jsx(oe,{value:"annually",children:"Annually"})]})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"next_due",children:"Next Due Date"}),t.jsx(K,{id:"next_due",type:"date",value:d,onChange:y=>u(y.target.value),required:!0})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"subtotal",children:"Subtotal"}),t.jsx(K,{id:"subtotal",type:"number",step:"0.01",value:h,onChange:y=>p(y.target.value)})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"tax",children:"Tax"}),t.jsx(K,{id:"tax",type:"number",step:"0.01",value:g,onChange:y=>f(y.target.value)})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx($,{htmlFor:"notes",children:"Notes"}),t.jsx(Ct,{id:"notes",value:j,onChange:y=>x(y.target.value),placeholder:"Additional notes for this recurring invoice...",rows:3})]}),t.jsx("div",{className:"md:col-span-2",children:t.jsxs(U,{type:"submit",disabled:m.isPending,className:"flex items-center gap-2",children:[t.jsx(Xs,{className:"h-4 w-4"}),"Create Recurring Invoice"]})})]})})]}),t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Recurring Invoice Templates"})}),t.jsx(F,{children:t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Template #"}),t.jsx(I,{children:"Client"}),t.jsx(I,{children:"Frequency"}),t.jsx(I,{children:"Next Due"}),t.jsx(I,{children:"Last Generated"}),t.jsx(I,{children:"Total"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:b.isLoading?t.jsx(ne,{children:t.jsx(k,{colSpan:8,children:"Loading…"})}):b.data&&b.data.length>0?b.data.map(y=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:y.template_number}),t.jsx(k,{children:y.client?.name??"—"}),t.jsx(k,{className:"capitalize",children:y.frequency}),t.jsx(k,{children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ga,{className:"h-3 w-3"}),Se(new Date(y.next_due_date),"MMM dd, yyyy")]})}),t.jsx(k,{children:y.last_generated_date?Se(new Date(y.last_generated_date),"MMM dd, yyyy"):"Never"}),t.jsxs(k,{children:["$",Number(y.total).toFixed(2)]}),t.jsx(k,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ns,{checked:y.is_active,onCheckedChange:()=>w.mutate({id:y.id,isActive:y.is_active})}),t.jsx("span",{className:y.is_active?"text-primary":"text-muted-foreground",children:y.is_active?"Active":"Inactive"})]})}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{size:"sm",variant:"default",onClick:()=>R.mutate(y.id),disabled:!y.is_active||R.isPending,children:"Generate"}),t.jsx(U,{size:"sm",variant:"destructive",onClick:()=>P.mutate(y.id),children:t.jsx(ja,{className:"h-3 w-3"})})]})})]},y.id)):t.jsx(ne,{children:t.jsx(k,{colSpan:8,className:"text-center text-muted-foreground",children:"No recurring invoice templates yet. Create one to get started!"})})})]})})]})]})})},Dn=W,Rf=()=>{const{user:e}=Ce(),s=Be(),[r,n]=c.useState(""),[a,o]=c.useState(""),[i,l]=c.useState(""),[d,u]=c.useState("USD"),h=fe({queryKey:["user-settings",e?.id],enabled:!!e,queryFn:async()=>{const{data:g,error:f}=await Dn.from("user_settings").select("*").eq("user_id",e.id).maybeSingle();if(f)throw f;return g}});c.useEffect(()=>{h.data&&(n(h.data.display_name||""),o(h.data.company_name||""),l(h.data.address||""),u(h.data.currency||"USD"))},[h.data]);const p=Te({mutationFn:async()=>{if(!e)throw new Error("Not authenticated");const{error:g}=await Dn.from("user_settings").upsert({user_id:e.id,display_name:r||null,company_name:a||null,address:i||null,currency:d});if(g)throw g},onSuccess:()=>{s.invalidateQueries({queryKey:["user-settings",e?.id]}),Q.success("Settings saved")},onError:g=>Q.error(g.message||"Failed to save settings")});return t.jsx("section",{children:t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Account & Company Settings"})}),t.jsx(F,{children:t.jsxs("form",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",onSubmit:g=>{g.preventDefault(),p.mutate()},children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"display",children:"Display name"}),t.jsx(K,{id:"display",value:r,onChange:g=>n(g.target.value)})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"company",children:"Company name"}),t.jsx(K,{id:"company",value:a,onChange:g=>o(g.target.value)})]}),t.jsxs("div",{className:"md:col-span-2",children:[t.jsx($,{htmlFor:"addr",children:"Address"}),t.jsx(K,{id:"addr",value:i,onChange:g=>l(g.target.value)})]}),t.jsxs("div",{children:[t.jsx($,{children:"Currency"}),t.jsxs(Le,{value:d,onValueChange:u,children:[t.jsx(De,{children:t.jsx($e,{placeholder:"Select currency"})}),t.jsxs(Fe,{children:[t.jsx(oe,{value:"USD",children:"USD"}),t.jsx(oe,{value:"EUR",children:"EUR"}),t.jsx(oe,{value:"GBP",children:"GBP"}),t.jsx(oe,{value:"JPY",children:"JPY"})]})]})]}),t.jsx("div",{className:"md:col-span-2",children:t.jsx(U,{type:"submit",disabled:p.isPending,children:"Save Settings"})})]})})]})})},If=()=>{const{user:e}=Ce(),s=fe({queryKey:["analytics",e?.id],enabled:!!e,queryFn:async()=>{const[r,n,a]=await Promise.all([W.from("clients").select("created_at").eq("user_id",e.id),W.from("invoices").select("total, status, created_at, due_date").eq("user_id",e.id),W.from("invoices").select("total").eq("user_id",e.id).eq("status","paid")]);if(r.error)throw r.error;if(n.error)throw n.error;if(a.error)throw a.error;const o=r.data||[],i=n.data||[],l=a.data||[],d=l.reduce((x,v)=>x+(v.total||0),0),u=i.filter(x=>x.status==="sent"||x.status==="overdue").reduce((x,v)=>x+(v.total||0),0),h=new Date,p=new Date(h.getTime()-720*60*60*1e3),g=o.filter(x=>new Date(x.created_at)>=p).length,f=i.filter(x=>new Date(x.created_at)>=p).length,j=i.filter(x=>x.due_date&&new Date(x.due_date)t.jsx("div",{className:"h-32 bg-muted animate-pulse rounded-lg"},n))}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs(D,{className:"border-green-200 bg-green-50 dark:bg-green-950/20",children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Revenue"}),t.jsx(ut,{className:"h-4 w-4 text-green-600"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",s.data?.totalRevenue?.toFixed(2)||"0.00"]}),t.jsxs("p",{className:"text-xs text-green-600 dark:text-green-500",children:["From ",s.data?.paidInvoices||0," paid invoices"]})]})]}),t.jsxs(D,{className:"border-yellow-200 bg-yellow-50 dark:bg-yellow-950/20",children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Pending Revenue"}),t.jsx(ga,{className:"h-4 w-4 text-yellow-600"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold text-yellow-700 dark:text-yellow-400",children:["$",s.data?.pendingRevenue?.toFixed(2)||"0.00"]}),t.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"Awaiting payment"})]})]}),t.jsxs(D,{className:"border-red-200 bg-red-50 dark:bg-red-950/20",children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Overdue Invoices"}),t.jsx(st,{className:"h-4 w-4 text-red-600"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold text-red-700 dark:text-red-400",children:s.data?.overdueInvoices||0}),t.jsx("p",{className:"text-xs text-red-600 dark:text-red-500",children:"Need attention"})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"New Clients (30 days)"}),t.jsx(vr,{className:"h-4 w-4 text-primary"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:s.data?.recentClients||0}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total: ",s.data?.totalClients||0," clients"]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"New Invoices (30 days)"}),t.jsx(st,{className:"h-4 w-4 text-primary"})]}),t.jsxs(F,{children:[t.jsx("div",{className:"text-2xl font-bold",children:s.data?.recentInvoices||0}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Total: ",s.data?.totalInvoices||0," invoices"]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Collection Rate"}),t.jsx(fs,{className:"h-4 w-4 text-primary"})]}),t.jsxs(F,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[s.data?.totalInvoices?Math.round(s.data.paidInvoices/s.data.totalInvoices*100):0,"%"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Invoices paid on time"})]})]})]})]})]})})},_f=()=>{const[e,s]=c.useState({companyName:"",tagline:"",primaryColor:"#3b82f6",secondaryColor:"#64748b",logoUrl:"",footerText:""}),r=a=>{a.preventDefault(),Q.success("Branding settings saved successfully!")},n=a=>{const o=a.target.files?.[0];if(o){const i=URL.createObjectURL(o);s(l=>({...l,logoUrl:i})),Q.success("Logo uploaded successfully!")}};return t.jsx(Ir,{featureName:"Custom Branding",description:"Customize your invoices with your company logo, colors, and branding to create a professional appearance.",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(wa,{className:"h-6 w-6 text-primary"}),t.jsx("h2",{className:"text-2xl font-bold",children:"Custom Branding"})]}),t.jsxs("form",{onSubmit:r,className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t.jsxs(D,{children:[t.jsxs(A,{children:[t.jsx(q,{children:"Company Information"}),t.jsx(qe,{children:"Set up your company details for invoices"})]}),t.jsxs(F,{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"companyName",children:"Company Name"}),t.jsx(K,{id:"companyName",value:e.companyName,onChange:a=>s(o=>({...o,companyName:a.target.value})),placeholder:"Your Company Name"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"tagline",children:"Tagline"}),t.jsx(K,{id:"tagline",value:e.tagline,onChange:a=>s(o=>({...o,tagline:a.target.value})),placeholder:"Your company tagline"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"footerText",children:"Invoice Footer Text"}),t.jsx(Ct,{id:"footerText",value:e.footerText,onChange:a=>s(o=>({...o,footerText:a.target.value})),placeholder:"Thank you for your business...",rows:3})]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{children:[t.jsx(q,{children:"Visual Branding"}),t.jsx(qe,{children:"Upload your logo and customize colors"})]}),t.jsxs(F,{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx($,{children:"Company Logo"}),t.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/20 hover:border-primary/40 transition-colors rounded-lg p-6 text-center",children:[e.logoUrl?t.jsxs("div",{className:"space-y-2",children:[t.jsx("img",{src:e.logoUrl,alt:"Company Logo",className:"max-h-16 mx-auto"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Logo uploaded"})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(Zl,{className:"h-8 w-8 mx-auto text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload your company logo"})]}),t.jsx(K,{type:"file",accept:"image/*",onChange:n,className:"mt-2"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"primaryColor",children:"Primary Color"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(K,{type:"color",id:"primaryColor",value:e.primaryColor,onChange:a=>s(o=>({...o,primaryColor:a.target.value})),className:"w-16 h-10 p-1"}),t.jsx(K,{value:e.primaryColor,onChange:a=>s(o=>({...o,primaryColor:a.target.value})),placeholder:"#3b82f6"})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"secondaryColor",children:"Secondary Color"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(K,{type:"color",id:"secondaryColor",value:e.secondaryColor,onChange:a=>s(o=>({...o,secondaryColor:a.target.value})),className:"w-16 h-10 p-1"}),t.jsx(K,{value:e.secondaryColor,onChange:a=>s(o=>({...o,secondaryColor:a.target.value})),placeholder:"#64748b"})]})]})]})]})]})]}),t.jsxs(D,{children:[t.jsxs(A,{children:[t.jsx(q,{children:"Invoice Preview"}),t.jsx(qe,{children:"See how your branding will look on invoices"})]}),t.jsx(F,{children:t.jsxs("div",{className:"border rounded-lg p-6 bg-white dark:bg-gray-900",style:{borderColor:e.primaryColor,borderWidth:"2px"},children:[t.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.logoUrl&&t.jsx("img",{src:e.logoUrl,alt:"Logo",className:"max-h-12"}),t.jsxs("div",{className:"text-right",children:[t.jsx("h3",{className:"text-xl font-bold",style:{color:e.primaryColor},children:e.companyName||"Your Company"}),e.tagline&&t.jsx("p",{className:"text-sm",style:{color:e.secondaryColor},children:e.tagline})]})]}),t.jsxs("div",{className:"border-t pt-4",style:{borderColor:e.secondaryColor},children:[t.jsx("h4",{className:"font-semibold mb-2",children:"INVOICE #001"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sample invoice content..."})]}),e.footerText&&t.jsx("div",{className:"mt-6 pt-4 border-t text-center text-sm",style:{borderColor:e.secondaryColor,color:e.secondaryColor},children:e.footerText})]})})]}),t.jsx("div",{className:"flex justify-end",children:t.jsxs(U,{type:"submit",className:"flex items-center gap-2",children:[t.jsx(Gl,{className:"h-4 w-4"}),"Save Branding Settings"]})})]})]})})},Mf=(e,s)=>{document.title=e;const r=(n,a)=>{let o=document.head.querySelector(n);return o||(o=a(),document.head.appendChild(o)),o};r('meta[name="description"]',()=>{const n=document.createElement("meta");return n.setAttribute("name","description"),n}).setAttribute("content",s),r('link[rel="canonical"]',()=>{const n=document.createElement("link");return n.setAttribute("rel","canonical"),n}).setAttribute("href",window.location.href)},Of=()=>{const{user:e,signOut:s}=Ce(),[r]=ih();return r.get("tab"),c.useEffect(()=>{Mf("Dashboard | HonestInvoice","HonestInvoice dashboard: manage clients, quotes, invoices, time tracking, expenses and more.")},[]),t.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted",children:[t.jsxs("header",{className:"px-4 sm:px-6 py-4 border-b border-primary/20 bg-gradient-to-r from-background to-primary/5",children:[t.jsxs("div",{className:"flex flex-col gap-3 sm:hidden",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground font-bold text-sm",children:"HI"}),t.jsx("h1",{className:"text-xl font-semibold text-primary",children:"Dashboard"})]}),t.jsx(U,{variant:"secondary",size:"sm",onClick:s,children:"Sign out"})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx(wn,{})})]}),t.jsxs("div",{className:"hidden sm:flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground font-bold",children:"HI"}),t.jsx("h1",{className:"text-2xl font-semibold text-primary",children:"Dashboard"})]}),t.jsx(wn,{})]}),t.jsx("div",{children:t.jsx(U,{variant:"secondary",onClick:s,children:"Sign out"})})]})]}),t.jsx("main",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-8",children:t.jsxs(_o,{defaultValue:"reports",children:[t.jsx("div",{className:"mb-6 sm:mb-8",children:t.jsxs(Pr,{className:"grid w-full grid-cols-2 sm:grid-cols-4 lg:flex lg:w-auto lg:justify-center gap-1 h-auto p-1",children:[t.jsx(Ae,{value:"overview",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Overview"}),t.jsx(Ae,{value:"clients",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Clients"}),t.jsx(Ae,{value:"quotes",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Quotes"}),t.jsx(Ae,{value:"invoices",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Invoices"}),t.jsx(Ae,{value:"time",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Time"}),t.jsx(Ae,{value:"expenses",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Expenses"}),t.jsx(Ae,{value:"reminders",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Reminders"}),t.jsx(Ae,{value:"reports",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",defaultChecked:!0,children:"Reports"}),t.jsx(Ae,{value:"settings",className:"text-xs sm:text-sm px-2 sm:px-3 py-2 flex-shrink-0",children:"Settings"})]})}),t.jsx(Pe,{value:"overview",children:t.jsx(mf,{})}),t.jsx(Pe,{value:"clients",children:t.jsx(ff,{})}),t.jsx(Pe,{value:"quotes",children:t.jsx(pf,{})}),t.jsx(Pe,{value:"invoices",children:t.jsx(xf,{})}),t.jsx(Pe,{value:"time",children:t.jsx(jf,{})}),t.jsx(Pe,{value:"expenses",children:t.jsx(Cf,{})}),t.jsx(Pe,{value:"reminders",children:t.jsx(Pf,{})}),t.jsx(Pe,{value:"reports",children:t.jsx(Tf,{})}),t.jsx(Pe,{value:"analytics",children:t.jsx(If,{})}),t.jsx(Pe,{value:"branding",children:t.jsx(_f,{})}),t.jsx(Pe,{value:"recurring",children:t.jsx(kf,{})}),t.jsx(Pe,{value:"settings",children:t.jsx(Rf,{})})]})})]})},Df=()=>{const{hasAccess:e,isLoading:s,needsUpgrade:r}=Ci(),n=rs();return c.useEffect(()=>{},[e,s,r]),s?t.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 to-primary/10 flex items-center justify-center",children:t.jsx("div",{className:"h-8 w-32 bg-muted animate-pulse rounded"})}):e?t.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 to-primary/10 p-8",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsxs(je,{variant:"default",className:"mb-4",children:[t.jsx(We,{className:"h-4 w-4 mr-2"}),"Pro Member"]}),t.jsx("h1",{className:"text-4xl font-bold mb-4",children:"Welcome to Pro Access"}),t.jsx("p",{className:"text-xl text-muted-foreground",children:"You have full access to all premium features"})]}),t.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8",children:[t.jsxs(D,{className:"border-primary/20",children:[t.jsxs(A,{children:[t.jsx(Bl,{className:"h-8 w-8 text-primary mb-2"}),t.jsx(q,{children:"Advanced Analytics"}),t.jsx(qe,{children:"Detailed insights into your business performance"})]}),t.jsx(F,{children:t.jsx(U,{onClick:()=>n("/dashboard?tab=analytics"),className:"w-full",children:"View Analytics"})})]}),t.jsxs(D,{className:"border-primary/20",children:[t.jsxs(A,{children:[t.jsx(Sa,{className:"h-8 w-8 text-primary mb-2"}),t.jsx(q,{children:"Recurring Invoices"}),t.jsx(qe,{children:"Automate your billing with recurring templates"})]}),t.jsx(F,{children:t.jsx(U,{onClick:()=>n("/dashboard?tab=recurring"),className:"w-full",children:"Manage Recurring"})})]}),t.jsxs(D,{className:"border-primary/20",children:[t.jsxs(A,{children:[t.jsx(wa,{className:"h-8 w-8 text-primary mb-2"}),t.jsx(q,{children:"Custom Branding"}),t.jsx(qe,{children:"Customize your invoices with your brand"})]}),t.jsx(F,{children:t.jsx(U,{onClick:()=>n("/dashboard?tab=branding"),className:"w-full",children:"Customize Branding"})})]})]}),t.jsx("div",{className:"text-center",children:t.jsx(U,{variant:"outline",onClick:()=>n("/dashboard"),className:"mr-4",children:"Back to Dashboard"})})]})}):t.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 to-primary/10 flex items-center justify-center p-8",children:t.jsxs(D,{className:"max-w-2xl w-full border-primary/20",children:[t.jsxs(A,{className:"text-center pb-8",children:[t.jsx("div",{className:"flex justify-center mb-4",children:t.jsx(We,{className:"h-16 w-16 text-primary"})}),t.jsx(q,{className:"text-3xl mb-2",children:"Upgrade to Pro"}),t.jsx(qe,{className:"text-lg",children:"Unlock powerful features to grow your business"})]}),t.jsxs(F,{className:"space-y-6",children:[t.jsxs("div",{className:"grid gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vt,{className:"h-5 w-5 text-green-500"}),t.jsx("span",{children:"Advanced Analytics & Reporting"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vt,{className:"h-5 w-5 text-green-500"}),t.jsx("span",{children:"Automated Recurring Invoices"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vt,{className:"h-5 w-5 text-green-500"}),t.jsx("span",{children:"Custom Branding & Templates"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vt,{className:"h-5 w-5 text-green-500"}),t.jsx("span",{children:"Priority Support"})]})]}),t.jsxs("div",{className:"text-center pt-6",children:[t.jsxs(U,{size:"lg",className:"w-full text-lg py-6",onClick:()=>window.open("https://buy.stripe.com/aFaeVd2ub23leHdf3p7kc03","_blank"),children:[t.jsx(We,{className:"h-5 w-5 mr-2"}),"Upgrade to Pro - $4.99/month"]}),t.jsx(U,{variant:"ghost",onClick:()=>n("/dashboard"),className:"w-full mt-4",children:"Back to Dashboard"})]})]})]})})},Ii=il,Ff=al,_i=c.forwardRef(({className:e,...s},r)=>t.jsx(zn,{ref:r,className:Y("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),...s}));_i.displayName=zn.displayName;const _r=c.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(Ff,{children:[t.jsx(_i,{}),t.jsxs(Wn,{ref:n,className:Y("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),...r,children:[s,t.jsxs(ol,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Ca,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_r.displayName=Wn.displayName;const Mr=({className:e,...s})=>t.jsx("div",{className:Y("flex flex-col space-y-1.5 text-center sm:text-left",e),...s});Mr.displayName="DialogHeader";const Or=({className:e,...s})=>t.jsx("div",{className:Y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});Or.displayName="DialogFooter";const Dr=c.forwardRef(({className:e,...s},r)=>t.jsx(Vn,{ref:r,className:Y("text-lg font-semibold leading-none tracking-tight",e),...s}));Dr.displayName=Vn.displayName;const Fr=c.forwardRef(({className:e,...s},r)=>t.jsx(Qn,{ref:r,className:Y("text-sm text-muted-foreground",e),...s}));Fr.displayName=Qn.displayName;const Af=({quote:e,isOpen:s,onClose:r})=>{const{user:n}=Ce(),a=Be(),[o,i]=c.useState(""),[l,d]=c.useState(null),u=Te({mutationFn:async({quoteId:g,status:f,comments:j})=>{const x={status:f};j&&(x.notes=(e.notes||"")+` Customer ${f}: ${j}`);const{error:v}=await W.from("quotes").update(x).eq("id",g);if(v)throw v},onSuccess:()=>{a.invalidateQueries({queryKey:["customer-quotes"]}),Q.success(`Quote ${l}d successfully`),r(),i(""),d(null)},onError:g=>{Q.error(`Failed to ${l} quote`),console.error("Error updating quote:",g)}}),h=()=>{d("approve"),u.mutate({quoteId:e.id,status:"approved",comments:o})},p=()=>{d("reject"),u.mutate({quoteId:e.id,status:"rejected",comments:o})};return t.jsx(Ii,{open:s,onOpenChange:r,children:t.jsxs(_r,{className:"sm:max-w-[525px]",children:[t.jsxs(Mr,{children:[t.jsxs(Dr,{children:["Quote Review: ",e?.quote_number]}),t.jsx(Fr,{children:"Please review the quote details and provide your decision."})]}),e&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Quote Number:"})," ",e.quote_number]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Total Amount:"})," $",e.total?.toFixed(2)]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Issue Date:"})," ",new Date(e.issue_date).toLocaleDateString()]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Expiry Date:"})," ",e.expiry_date?new Date(e.expiry_date).toLocaleDateString():"No expiry"]})]}),e.notes&&t.jsxs("div",{children:[t.jsx($,{children:"Quote Notes"}),t.jsx("div",{className:"p-3 bg-gray-50 rounded-md text-sm",children:e.notes})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx($,{htmlFor:"comments",children:"Comments (Optional)"}),t.jsx(Ct,{id:"comments",placeholder:"Add any comments or feedback...",value:o,onChange:g=>i(g.target.value)})]})]}),t.jsxs(Or,{className:"gap-2",children:[t.jsx(U,{variant:"outline",onClick:r,children:"Cancel"}),t.jsx(U,{variant:"destructive",onClick:p,disabled:u.isPending,children:"Reject Quote"}),t.jsx(U,{onClick:h,disabled:u.isPending,children:"Approve Quote"})]})]})})},qf=({invoice:e,isOpen:s,onClose:r})=>{const{user:n}=Ce(),a=Be(),[o,i]=c.useState("credit_card"),[l,d]=c.useState(e?.total?.toString()||""),[u,h]=c.useState(!1),p=Te({mutationFn:async({invoiceId:f,amount:j,method:x})=>{h(!0),await new Promise(b=>setTimeout(b,2e3));const{error:v}=await W.from("invoices").update({status:"paid",updated_at:new Date().toISOString()}).eq("id",f);if(v)throw v;return{invoiceId:f,amount:j,method:x}},onSuccess:f=>{a.invalidateQueries({queryKey:["customer-invoices"]}),a.invalidateQueries({queryKey:["customer-payments"]}),Q.success(`Payment of $${f.amount} processed successfully!`),r(),h(!1)},onError:f=>{Q.error("Payment failed. Please try again."),console.error("Payment error:",f),h(!1)}}),g=()=>{if(!l||parseFloat(l)<=0){Q.error("Please enter a valid amount");return}if(parseFloat(l)>e.total){Q.error("Payment amount cannot exceed invoice total");return}p.mutate({invoiceId:e.id,amount:parseFloat(l),method:o})};return t.jsx(Ii,{open:s,onOpenChange:r,children:t.jsxs(_r,{className:"sm:max-w-[525px]",children:[t.jsxs(Mr,{children:[t.jsxs(Dr,{className:"flex items-center gap-2",children:[t.jsx(Gs,{className:"h-5 w-5"}),"Pay Invoice: ",e?.number]}),t.jsx(Fr,{children:"Complete your payment securely. Your payment will be processed immediately."})]}),e&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg space-y-2",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-medium",children:"Invoice Number:"}),t.jsx("span",{children:e.number})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-medium",children:"Issue Date:"}),t.jsx("span",{children:new Date(e.issue_date).toLocaleDateString()})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"font-medium",children:"Due Date:"}),t.jsx("span",{children:e.due_date?new Date(e.due_date).toLocaleDateString():"No due date"})]}),t.jsxs("div",{className:"flex justify-between text-lg font-bold",children:[t.jsx("span",{children:"Total Amount:"}),t.jsxs("span",{className:"text-primary",children:["$",e.total.toFixed(2)]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"amount",children:"Payment Amount"}),t.jsxs("div",{className:"relative",children:[t.jsx(ut,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),t.jsx(K,{id:"amount",type:"number",step:"0.01",placeholder:"0.00",value:l,onChange:f=>d(f.target.value),className:"pl-9"})]})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"paymentMethod",children:"Payment Method"}),t.jsxs(Le,{value:o,onValueChange:i,children:[t.jsx(De,{children:t.jsx($e,{})}),t.jsxs(Fe,{children:[t.jsx(oe,{value:"credit_card",children:"Credit Card"}),t.jsx(oe,{value:"debit_card",children:"Debit Card"}),t.jsx(oe,{value:"bank_transfer",children:"Bank Transfer"}),t.jsx(oe,{value:"paypal",children:"PayPal"})]})]})]}),o==="credit_card"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"cardNumber",children:"Card Number"}),t.jsx(K,{id:"cardNumber",placeholder:"1234 5678 9012 3456",className:"font-mono"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx($,{htmlFor:"expiry",children:"Expiry Date"}),t.jsx(K,{id:"expiry",placeholder:"MM/YY",className:"font-mono"})]}),t.jsxs("div",{children:[t.jsx($,{htmlFor:"cvv",children:"CVV"}),t.jsx(K,{id:"cvv",placeholder:"123",type:"password",className:"font-mono"})]})]})]})]}),t.jsxs("div",{className:"p-3 bg-blue-50 rounded-lg text-sm text-blue-800",children:[t.jsx("strong",{children:"Note:"})," This is a demo payment system. In production, this would integrate with a real payment processor like Stripe."]})]}),t.jsxs(Or,{className:"gap-2",children:[t.jsx(U,{variant:"outline",onClick:r,disabled:u,children:"Cancel"}),t.jsx(U,{onClick:g,disabled:p.isPending||u||!l,className:"min-w-[120px]",children:u?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Processing..."]}):`Pay $${l||"0.00"}`})]})]})})},Lf=()=>{const{user:e,signOut:s}=Ce(),r=rs(),[n,a]=c.useState(null),[o,i]=c.useState(null),[l,d]=c.useState(null),[u,h]=c.useState(!1),[p,g]=c.useState(!1);c.useEffect(()=>{(async()=>{if(!e?.id)return;const{data:C,error:B}=await W.from("customer_users").select(` *, client:clients(*) `).eq("user_id",e.id).single();if(B||!C){Q.error("Access denied. This portal is for customers only."),r("/auth");return}a(C)})()},[e,r]);const{data:f}=fe({queryKey:["customer-invoices",n?.client_id],queryFn:async()=>{if(!n?.client_id)return[];const{data:y,error:C}=await W.from("invoices").select("*").eq("client_id",n.client_id).order("created_at",{ascending:!1});if(C)throw C;return y},enabled:!!n?.client_id}),{data:j}=fe({queryKey:["customer-quotes",n?.client_id],queryFn:async()=>{if(!n?.client_id)return[];const{data:y,error:C}=await W.from("quotes").select("*").eq("client_id",n.client_id).order("created_at",{ascending:!1});if(C)throw C;return y},enabled:!!n?.client_id}),{data:x}=fe({queryKey:["customer-payments",n?.client_id],queryFn:async()=>{if(!n?.client_id)return[];const{data:y,error:C}=await W.from("invoices").select("*").eq("client_id",n.client_id).eq("status","paid").order("updated_at",{ascending:!1});if(C)throw C;return y},enabled:!!n?.client_id}),v=(y,C)=>{i(y),h(!0)},b=y=>{d(y),g(!0)},m=async(y,C)=>{try{const{data:B,error:E}=await W.functions.invoke("generate-invoice-pdf",{body:{invoiceId:y}});if(E)throw E;const M=new Blob([B.html],{type:"text/html"}),L=URL.createObjectURL(M),N=document.createElement("a");N.href=L,N.download=`invoice-${C}.html`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(L),Q.success("Invoice downloaded successfully")}catch(B){Q.error("Failed to download invoice"),console.error("Download error:",B)}};if(!n)return t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."});const w=y=>{const C={draft:"bg-gray-100 text-gray-800",sent:"bg-blue-100 text-blue-800",paid:"bg-green-100 text-green-800",overdue:"bg-red-100 text-red-800",approved:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800"};return C[y]||C.draft},P=f?.reduce((y,C)=>C.status==="sent"||C.status==="overdue"?y+C.total:y,0)||0,R=x?.reduce((y,C)=>y+C.total,0)||0;return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("div",{className:"border-b",children:t.jsxs("div",{className:"container mx-auto px-4 py-4 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold",children:"Customer Portal"}),t.jsxs("p",{className:"text-muted-foreground",children:["Welcome back, ",n.client.name]})]}),t.jsx(U,{onClick:s,variant:"outline",children:"Sign Out"})]})}),t.jsxs("div",{className:"container mx-auto px-4 py-6 space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Outstanding Balance"}),t.jsx(ut,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",P.toFixed(2)]})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Total Paid"}),t.jsx(Gs,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsxs("div",{className:"text-2xl font-bold",children:["$",R.toFixed(2)]})})]}),t.jsxs(D,{children:[t.jsxs(A,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(q,{className:"text-sm font-medium",children:"Open Invoices"}),t.jsx(st,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(F,{children:t.jsx("div",{className:"text-2xl font-bold",children:f?.filter(y=>y.status==="sent"||y.status==="overdue").length||0})})]})]}),t.jsxs(_o,{defaultValue:"invoices",className:"space-y-4",children:[t.jsxs(Pr,{children:[t.jsx(Ae,{value:"invoices",children:"Invoices"}),t.jsx(Ae,{value:"quotes",children:"Quotes"}),t.jsx(Ae,{value:"payments",children:"Payment History"})]}),t.jsx(Pe,{value:"invoices",className:"space-y-4",children:t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"My Invoices"})}),t.jsx(F,{children:f?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No invoices found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Invoice #"}),t.jsx(I,{children:"Issue Date"}),t.jsx(I,{children:"Due Date"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:f?.map(y=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:y.number}),t.jsx(k,{children:Se(new Date(y.issue_date),"MMM dd, yyyy")}),t.jsx(k,{children:y.due_date?Se(new Date(y.due_date),"MMM dd, yyyy"):"-"}),t.jsxs(k,{children:["$",y.total.toFixed(2)]}),t.jsx(k,{children:t.jsx(je,{className:w(y.status),children:y.status})}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{size:"sm",variant:"outline",onClick:()=>m(y.id,y.number),title:"Download Invoice",children:t.jsx(ba,{className:"h-4 w-4"})}),(y.status==="sent"||y.status==="overdue")&&t.jsxs(U,{size:"sm",onClick:()=>b(y),title:"Pay Now",className:"bg-primary hover:bg-primary/90",children:[t.jsx(Gs,{className:"h-4 w-4 mr-1"}),"Pay Now"]})]})})]},y.id))})]})})]})}),t.jsx(Pe,{value:"quotes",className:"space-y-4",children:t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"My Quotes"})}),t.jsx(F,{children:j?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No quotes found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Quote #"}),t.jsx(I,{children:"Issue Date"}),t.jsx(I,{children:"Expiry Date"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Status"}),t.jsx(I,{children:"Actions"})]})}),t.jsx(Oe,{children:j?.map(y=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:y.quote_number}),t.jsx(k,{children:Se(new Date(y.issue_date),"MMM dd, yyyy")}),t.jsx(k,{children:y.expiry_date?Se(new Date(y.expiry_date),"MMM dd, yyyy"):"-"}),t.jsxs(k,{children:["$",y.total.toFixed(2)]}),t.jsx(k,{children:t.jsx(je,{className:w(y.status),children:y.status})}),t.jsx(k,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{size:"sm",variant:"outline",title:"View Quote",children:t.jsx(Wl,{className:"h-4 w-4"})}),y.status==="sent"&&t.jsxs(t.Fragment,{children:[t.jsxs(U,{size:"sm",onClick:()=>v(y),title:"Approve Quote",className:"bg-green-600 hover:bg-green-700",children:[t.jsx(Vt,{className:"h-4 w-4 mr-1"}),"Approve"]}),t.jsxs(U,{size:"sm",variant:"destructive",onClick:()=>v(y),title:"Reject Quote",children:[t.jsx(zl,{className:"h-4 w-4 mr-1"}),"Reject"]})]})]})})]},y.id))})]})})]})}),t.jsx(Pe,{value:"payments",className:"space-y-4",children:t.jsxs(D,{children:[t.jsx(A,{children:t.jsx(q,{children:"Payment History"})}),t.jsx(F,{children:x?.length===0?t.jsx("div",{className:"text-center py-8 text-gray-500",children:"No payment history found"}):t.jsxs(_e,{children:[t.jsx(Me,{children:t.jsxs(ne,{children:[t.jsx(I,{children:"Invoice #"}),t.jsx(I,{children:"Payment Date"}),t.jsx(I,{children:"Amount"}),t.jsx(I,{children:"Method"})]})}),t.jsx(Oe,{children:x?.map(y=>t.jsxs(ne,{children:[t.jsx(k,{className:"font-medium",children:y.number}),t.jsx(k,{children:Se(new Date(y.updated_at),"MMM dd, yyyy")}),t.jsxs(k,{children:["$",y.total.toFixed(2)]}),t.jsx(k,{children:"Credit Card"})]},y.id))})]})})]})})]}),t.jsx(Af,{quote:o,isOpen:u,onClose:()=>{h(!1),i(null)}}),t.jsx(qf,{invoice:l,isOpen:p,onClose:()=>{g(!1),d(null)}})]})]})},$f=new Kd,Bf=()=>t.jsx(Zd,{client:$f,children:t.jsx(uh,{children:t.jsxs(Id,{children:[t.jsx(Dc,{}),t.jsx(md,{}),t.jsx(oh,{children:t.jsxs(sh,{children:[t.jsx(gt,{path:"/",element:t.jsx(fh,{})}),t.jsx(gt,{path:"/dashboard",element:t.jsx(Of,{})}),t.jsx(gt,{path:"/auth",element:t.jsx(bh,{})}),t.jsx(gt,{path:"/pro",element:t.jsx(Df,{})}),t.jsx(gt,{path:"/portal",element:t.jsx(Lf,{})}),t.jsx(gt,{path:"*",element:t.jsx(xh,{})})]})})]})})});ul.createRoot(document.getElementById("root")).render(t.jsx(Bf,{}));