@noxickon/onyx 0.0.4-dev.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/onyx.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("./chunks/jsx-runtime-CITbqOLs.js"),b=require("react"),n=require("./chunks/Button-D-v4l8ZE.js"),M=require("./chunks/Input-CLi1H63d.js"),ee=require("react-dom"),de=require("./chunks/constants-B1_n9ezb.js"),ue=require("./chunks/formatTimestamp-TTsNcy7u.js"),te=require("./chunks/useAuth-BTjqOcRK.js"),me=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex items-center gap-3",s),children:t}),G={rounded:"rounded-full",square:"rounded-lg"},K={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10",xl:"h-12 w-12","2xl":"h-16 w-16"},pe={sm:"h-2 w-2",md:"h-2.5 w-2.5",lg:"h-3 w-3",xl:"h-3.5 w-3.5","2xl":"h-4 w-4"},fe={online:"bg-green-500",offline:"bg-neutral-500",away:"bg-yellow-500",busy:"bg-red-500"},be={sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-base","2xl":"text-lg"},se=({alt:t,className:s,fallback:o,showStatus:i=!1,size:r="md",skeleton:x=!1,src:a,status:l,type:u="square"})=>{const[h,d]=b.useState(!1),[p,g]=b.useState(!1),[f,j]=b.useState(!0);b.useEffect(()=>{if(!a){d(!1),g(!0),j(!1);return}j(!0);const R=new Image;R.src=a;const O=()=>{d(!0),g(!1),j(!1)},c=()=>{d(!1),g(!0),j(!1)};return R.addEventListener("load",O),R.addEventListener("error",c),()=>{R.removeEventListener("load",O),R.removeEventListener("error",c)}},[a]);const v=()=>f&&x?e.jsxRuntimeExports.jsx("div",{className:n.twJoin("animate-pulse bg-zinc-800",G[u],K[r])}):h&&!p?e.jsxRuntimeExports.jsx("img",{alt:t,className:n.twMerge(G[u],K[r],"object-cover",s),loading:"lazy",src:a}):e.jsxRuntimeExports.jsx("div",{"aria-label":t,className:n.twMerge("flex items-center justify-center bg-zinc-800 font-medium text-white",G[u],K[r],be[r],s),role:"img",children:typeof o=="string"&&o.length>2?o.substring(0,2):o});return e.jsxRuntimeExports.jsxs("div",{className:"relative shrink-0",children:[v(),i&&l&&e.jsxRuntimeExports.jsx("span",{"aria-label":`Status: ${l}`,className:n.twJoin("absolute right-0 bottom-0 rounded-full border-2 border-zinc-900",pe[r],fe[l]),role:"status"})]})},he=({className:t,size:s="md",subtext:o,username:i})=>{const r={sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-lg","2xl":"text-xl"},x={sm:"text-xs",md:"text-xs",lg:"text-sm",xl:"text-sm","2xl":"text-base"};return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("flex flex-col justify-center overflow-hidden",t),children:[e.jsxRuntimeExports.jsx("span",{className:n.twJoin("block truncate font-medium text-white",r[s]),children:i}),o&&e.jsxRuntimeExports.jsx("span",{className:n.twJoin("block truncate text-neutral-400",x[s]),children:o})]})},ge={sm:"px-1 py-0.5 text-xs",md:"px-1.5 py-0.5 text-sm",lg:"px-2 py-1 text-base"},je={purple:"bg-purple-500/25 text-purple-400",lime:"bg-lime-400/10 text-lime-300",red:"bg-red-500/25 text-red-400",yellow:"bg-yellow-500/25 text-yellow-400",green:"bg-green-500/25 text-green-400",blue:"bg-blue-500/25 text-blue-400",indigo:"bg-indigo-500/25 text-indigo-400",pink:"bg-pink-500/25 text-pink-400",amber:"bg-amber-500/25 text-amber-400",emerald:"bg-emerald-500/25 text-emerald-400",teal:"bg-teal-500/25 text-teal-400",cyan:"bg-cyan-500/25 text-cyan-400",sky:"bg-sky-500/25 text-sky-400",violet:"bg-violet-500/25 text-violet-400",fuchsia:"bg-fuchsia-500/25 text-fuchsia-400",gray:"bg-gray-500/25 text-gray-400"};function we(t){const s=t.startsWith("#")?t.substring(1):t;if(!/^[0-9A-Fa-f]{3,6}$/.test(s))return"#FFFFFF";const i=parseInt(s.length===3?s[0]+s[0]:s.substr(0,2),16),r=parseInt(s.length===3?s[1]+s[1]:s.substr(2,2),16),x=parseInt(s.length===3?s[2]+s[2]:s.substr(4,2),16);return(.299*i+.587*r+.114*x)/255>.5?"#000000":"#FFFFFF"}const q=({bgColor:t,children:s,className:o,color:i="purple",size:r="md",textColor:x})=>{const a=!t&&!x?je[i]:"",l={};return t&&(l.backgroundColor=t,x||(l.color=we(t))),x&&(l.color=x),e.jsxRuntimeExports.jsx("span",{className:n.twMerge("inline-flex items-center rounded-md font-medium",ge[r],a,o),style:Object.keys(l).length?l:void 0,children:s})},Ee={default:"bg-zinc-900/90 border border-zinc-800",outline:"bg-transparent border border-zinc-700",gradient:"bg-gradient-to-br from-zinc-900 via-purple-900/20 to-zinc-900 border border-purple-800/30"},ve={none:"p-0",sm:"p-3",md:"p-4",lg:"p-6"},Re={none:"",lift:"hover:scale-[1.01] hover:-translate-y-1",glow:"hover:shadow-lg hover:shadow-purple-500/10",border:"hover:border-purple-500/50"},ye={purple:"hover:border-purple-500/50",blue:"hover:border-blue-500/50",emerald:"hover:border-emerald-500/50",orange:"hover:border-orange-500/50",rose:"hover:border-rose-500/50",amber:"hover:border-amber-500/50",cyan:"hover:border-cyan-500/50",indigo:"hover:border-indigo-500/50"},Oe={purple:"from-purple-500/5 to-pink-500/5",blue:"from-blue-500/5 to-cyan-500/5",emerald:"from-emerald-500/5 to-teal-500/5",orange:"from-orange-500/5 to-red-500/5",rose:"from-rose-500/5 to-pink-500/5",amber:"from-amber-500/5 to-orange-500/5",cyan:"from-cyan-500/5 to-blue-500/5",indigo:"from-indigo-500/5 to-purple-500/5"},Ne=({backdropBlur:t=!1,children:s,className:o,color:i="purple",equalHeight:r=!1,hoverVariant:x="lift",hoverable:a=!1,padding:l="md",variant:u="default",...h})=>{const d=a?x:"none",p=a&&d!=="none";return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("relative overflow-hidden rounded-lg transition-all duration-300",Ee[u],ve[l],r&&"flex flex-col",t&&"backdrop-blur-sm",p&&Re[d],p&&"group hover:bg-white/5",p&&ye[i],o),...h,children:[p&&e.jsxRuntimeExports.jsx("div",{className:n.twMerge("absolute inset-0 bg-gradient-to-br opacity-0 transition-opacity duration-300 group-hover:opacity-100",Oe[i])}),e.jsxRuntimeExports.jsx("div",{className:"relative z-10",children:s})]})},ke={purple:{border:"border-purple-500/20",bg:"bg-purple-500/10",text:"text-purple-400"},blue:{border:"border-blue-500/20",bg:"bg-blue-500/10",text:"text-blue-400"},emerald:{border:"border-emerald-500/20",bg:"bg-emerald-500/10",text:"text-emerald-400"},orange:{border:"border-orange-500/20",bg:"bg-orange-500/10",text:"text-orange-400"},rose:{border:"border-rose-500/20",bg:"bg-rose-500/10",text:"text-rose-400"},amber:{border:"border-amber-500/20",bg:"bg-amber-500/10",text:"text-amber-400"},cyan:{border:"border-cyan-500/20",bg:"bg-cyan-500/10",text:"text-cyan-400"},indigo:{border:"border-indigo-500/20",bg:"bg-indigo-500/10",text:"text-indigo-400"}},Ce=({action:t,children:s,className:o,color:i="purple",icon:r,iconColor:x,subtitle:a,title:l,...u})=>{if(s)return e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mb-4",o),...u,children:s});const d=ke[x||i];return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("mb-4 flex items-start justify-between gap-3",o),...u,children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsxRuntimeExports.jsx("div",{className:n.twMerge("rounded-lg border p-2",d.border,d.bg),children:e.jsxRuntimeExports.jsx(n.OxIcon,{className:d.text,icon:r})}),e.jsxRuntimeExports.jsxs("div",{children:[l&&e.jsxRuntimeExports.jsx("h3",{className:"text-base font-semibold text-white",children:l}),a&&e.jsxRuntimeExports.jsx("p",{className:"text-sm text-neutral-400",children:a})]})]}),t&&e.jsxRuntimeExports.jsx("div",{children:t})]})},Ie=({children:t,className:s,flexGrow:o=!0,...i})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("py-2",o&&"flex-grow",s),...i,children:t}),Me=({children:t,className:s,...o})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mt-4 flex items-center justify-end border-t border-neutral-800 pt-4",s),...o,children:t}),Se={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},ze={sm:.5,md:.7,lg:.9},Le=({checked:t,className:s,defaultChecked:o,description:i,disabled:r=!1,error:x=!1,errorMessage:a,id:l,label:u,name:h,onChange:d,required:p=!1,size:g="md",value:f,...j})=>{const v=b.useId(),R=l||v,O=`${R}-checkbox`,c=`${R}-description`,w=`${R}-error`,y=x&&a,I=e.jsxRuntimeExports.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxRuntimeExports.jsx("input",{id:O,"aria-describedby":[i?c:"",y?w:""].filter(Boolean).join(" ")||void 0,"aria-invalid":x,"aria-required":p,checked:t,className:n.twMerge("peer cursor-pointer appearance-none rounded-sm","checked:bg-violet-700","default-outset-focus","disabled:cursor-not-allowed disabled:opacity-50",x?"default-error-border":"default-border",Se[g],s),defaultChecked:o,disabled:r,name:h,type:"checkbox",value:f,onChange:d,...j}),e.jsxRuntimeExports.jsx(n.OxIcon,{className:"pointer-events-none absolute inset-0 m-auto opacity-0 peer-checked:opacity-80",icon:"mdiCheck",size:ze[g]||.7})]});return e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-start gap-2",children:[I,u&&e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:O,required:p,children:u}),i?e.jsxRuntimeExports.jsx(M.OxDescription,{id:c,disabled:r,children:i}):null]})]}),y?e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:w,children:a}):null]})},Y=({align:t="center",ariaHaspopup:s,children:o,className:i,content:r,contentClassName:x,contentRole:a,contentStyle:l,disabled:u=!1,id:h,offset:d=8,onOpenChange:p,open:g,portal:f=!0,position:j="top",trigger:v="hover",useAriaControls:R=!1})=>{const O=b.useId(),[c,w]=b.useState(!1),y=b.useRef(null),I=b.useRef(null),L=g!==void 0,N=u?!1:L?g:c,F=h||O,S=b.useCallback(m=>{u||(p?.(m),L||w(m))},[u,L,p]),D=b.useCallback(()=>{if(!y.current||!I.current||!N)return;const m=y.current.getBoundingClientRect(),E=I.current.getBoundingClientRect(),C={width:window.innerWidth,height:window.innerHeight};let z=j;j==="top"&&m.top<E.height+d?z="bottom":j==="bottom"&&m.bottom+E.height+d>C.height?z="top":j==="left"&&m.left<E.width+d?z="right":j==="right"&&m.right+E.width+d>C.width&&(z="left");const $=P(m,E,z,t,d);I.current&&(I.current.style.left=`${$.x}px`,I.current.style.top=`${$.y}px`)},[N,j,t,d]);b.useEffect(()=>{if(!N||v!=="click")return;const m=E=>{y.current&&!y.current.contains(E.target)&&I.current&&!I.current.contains(E.target)&&S(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[N,S,v]),b.useEffect(()=>{if(N){D();const m=()=>D(),E=()=>D();return window.addEventListener("resize",m),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",E,!0)}}},[N,j,t,d,D]);const P=(m,E,C,z,$)=>{let T=0,B=0;switch(C){case"top":T=m.left,B=m.top-E.height-$;break;case"bottom":T=m.left,B=m.bottom+$;break;case"left":T=m.left-E.width-$,B=m.top;break;case"right":T=m.right+$,B=m.top;break}if(C==="top"||C==="bottom")switch(z){case"start":break;case"center":T=m.left+(m.width-E.width)/2;break;case"end":T=m.right-E.width;break}else if(C==="left"||C==="right")switch(z){case"start":break;case"center":B=m.top+(m.height-E.height)/2;break;case"end":B=m.bottom-E.height;break}return{x:T,y:B}},W=()=>{v==="hover"&&S(!0)},V=()=>{v==="hover"&&S(!1)},H=()=>{v==="click"&&S(!N)},J=()=>{v==="focus"&&S(!0)},A=()=>{v==="focus"&&S(!1)},k=N?e.jsxRuntimeExports.jsx("div",{id:F,"aria-hidden":!N,className:n.twMerge("fixed z-50 transition-opacity duration-200",N?"opacity-100":"pointer-events-none opacity-0",x),ref:I,role:a,style:{left:-9999,top:-9999,...l},children:e.jsxRuntimeExports.jsx("div",{className:"relative",children:r})}):null;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{"aria-controls":R&&N?F:void 0,"aria-describedby":!R&&N?F:void 0,"aria-expanded":R?N:void 0,"aria-haspopup":s,className:n.twMerge("w-full",i),ref:y,onBlur:A,onClick:H,onFocus:J,onMouseEnter:W,onMouseLeave:V,children:o}),f&&typeof document<"u"?ee.createPortal(k,document.body):k]})},Q=({children:t})=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t}),re=({children:t})=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t}),X=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("sticky top-0 flex-shrink-0 border-b border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-lg",s),children:t}),ne=b.createContext({open:!1,setOpen:()=>{},disabled:!1});function oe(){const t=b.useContext(ne);if(t===void 0)throw new Error("useDropdownContext must be used within a DropdownProvider");return t}const Z=({animateIcon:t=!1,children:s,className:o,disabled:i=!1,icon:r,outline:x=!1,unstyled:a=!1,...l})=>{const{disabled:u,open:h}=oe(),d=i||u;return e.jsxRuntimeExports.jsxs("button",{"aria-expanded":h,"aria-haspopup":"menu",className:n.twMerge(!a&&["flex h-10 items-center justify-between rounded-lg px-3 py-2 text-sm enabled:cursor-pointer enabled:text-white enabled:hover:bg-white/6","default-outset-focus",x?"default-border":"bg-transparent","default-disabled"],o),disabled:d,type:"button",...l,children:[a?s:e.jsxRuntimeExports.jsx("span",{className:"flex items-center gap-2",children:s}),r&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin(!a&&"ml-2",d&&"text-neutral-500",t&&["transition-transform duration-200",h&&"rotate-180"]),icon:r,size:.8})]})},ie=({children:t,className:s,defaultOpen:o=!1,disabled:i=!1,onOpenChange:r,open:x})=>{const[a,l]=b.useState(o),u=x!==void 0,h=u?x:a,d=c=>{i||(u||l(c),r?.(c))},p={open:h,setOpen:d,disabled:i};let g=null,f=null;const j={children:null,className:""},v={children:null,className:""};let R={side:"bottom",align:"start",className:""};b.Children.forEach(t,c=>{if(b.isValidElement(c)){if(c.type===Z)g=c;else if(c.type===X){const w=c.props;j.className=w.className,j.children=w.children}else if(c.type===re){const w=c.props;v.className=w.className,v.children=w.children}else if(c.type===Q){const w=c.props;f=w.children,R={side:w.side||"bottom",align:w.align||"start",className:w.className||""}}}});const O=e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("default-border z-50 flex max-h-96 min-w-[8rem] flex-col overflow-hidden rounded-lg bg-zinc-1000/50 p-1 backdrop-blur-xl",R.side==="bottom"&&"animate-dropdown-in-bottom",R.side==="top"&&"animate-dropdown-in-top",R.className),children:[j.children?e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex-shrink-0 border-b border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-sm",j.className),children:j.children}):null,e.jsxRuntimeExports.jsx("ul",{className:n.twMerge("min-h-0 flex-1 overflow-y-auto"),children:f}),v.children?e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex-shrink-0 border-t border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-sm",v.className),children:v.children}):null]});return e.jsxRuntimeExports.jsx(ne.Provider,{value:p,children:e.jsxRuntimeExports.jsx("div",{className:n.twMerge("inline-block",s),children:e.jsxRuntimeExports.jsx(Y,{align:R.align,content:O,contentRole:"menu",disabled:i,open:h,portal:!0,position:R.side,trigger:"click",onOpenChange:d,children:g})})})},le=({children:t,className:s,disabled:o=!1,icon:i,onClick:r,unstyled:x=!1})=>{const{setOpen:a}=oe(),l=u=>{o||(r&&r(u),a(!1))};return e.jsxRuntimeExports.jsx("li",{children:e.jsxRuntimeExports.jsxs("button",{className:n.twMerge(!x&&["group flex w-full items-center rounded-sm px-2 py-1.5 text-left text-sm enabled:text-white","enabled:cursor-pointer enabled:hover:bg-white/6","default-inset-focus","default-disabled"],s),disabled:o,role:"menuitem",onClick:l,children:[i&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin("mr-2",o&&"text-neutral-500"),icon:i,size:.75}),t]})})},Fe=({className:t})=>e.jsxRuntimeExports.jsx("li",{className:"px-1 py-1",children:e.jsxRuntimeExports.jsx("hr",{className:n.twMerge("border-t-neutral-700",t)})}),De=({children:t,className:s})=>e.jsxRuntimeExports.jsx("span",{className:n.twMerge("ml-auto text-xs tracking-widest text-neutral-500",s),"data-part":"dropdown-shortcut",children:t}),$e={error:{background:"bg-rose-500/20",iconClass:"text-rose-400",icon:"mdiAlertCircleOutline"},success:{background:"bg-green-500/20",iconClass:"text-green-400",icon:"mdiCheckCircleOutline"},warning:{background:"bg-amber-500/20",iconClass:"text-amber-400",icon:"mdiAlertOutline"},info:{background:"bg-blue-500/20",iconClass:"text-blue-400",icon:"mdiInformationOutline"},default:{background:"bg-neutral-500/20",iconClass:"text-neutral-400",icon:"mdiBellOutline"}},Te=({className:t,disabled:s=!1,emptyMessage:o="No notifications",maxHeight:i="max-h-96",notifications:r,onMarkAllRead:x,onNotificationClick:a,unreadCount:l=0})=>{const[u,h]=b.useState(!1),[d,p]=b.useState(!1),g=l>99?"99+":l.toString(),f=l>0,j=r.length>0;b.useEffect(()=>{const c=()=>{const w=window.innerWidth<de.MOBILE_BREAKPOINT;p(w),w&&u?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")};return c(),window.addEventListener("resize",c),()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("resize",c)}},[u]);const v=c=>{a?.(c),d&&h(!1)},R=()=>{x?.(),d&&h(!1)},O=()=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j?e.jsxRuntimeExports.jsx("div",{className:"divide-y divide-neutral-800/50",children:r.map((c,w)=>{const y=$e[c.type||"default"];return e.jsxRuntimeExports.jsxs(le,{className:n.twMerge("secondary-inset-focus flex w-full items-start gap-3 px-3 py-3 text-left hover:bg-white/6",!c.read&&"bg-white/3",w===r.length-1&&"pb-4"),unstyled:!0,onClick:()=>v(c),children:[e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg",y.background),children:c.img?e.jsxRuntimeExports.jsx(se,{alt:"User avatar",fallback:"NA",size:"md",src:c.img}):e.jsxRuntimeExports.jsx(n.OxIcon,{className:y.iconClass,icon:c.icon??y.icon,size:.75})}),e.jsxRuntimeExports.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxRuntimeExports.jsx("p",{className:"mb-1 text-sm leading-5 text-white",children:c.title}),c.message&&e.jsxRuntimeExports.jsx("p",{className:"mb-1 text-xs leading-4 text-neutral-400",children:c.message}),e.jsxRuntimeExports.jsx("p",{className:"text-xs text-neutral-500",children:ue.formatTimestamp(c.timestamp)})]}),!c.read&&e.jsxRuntimeExports.jsx("div",{className:"mt-1.5 h-2 w-2 flex-shrink-0 rounded-full bg-rose-500"})]},c.id)})}):e.jsxRuntimeExports.jsxs("div",{"aria-label":"No notifications available",className:"px-3 py-8 text-center",role:"status",children:[e.jsxRuntimeExports.jsx(n.OxIcon,{className:"mx-auto mb-2 text-neutral-500",icon:"mdiBellOffOutline",size:2}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-neutral-400",children:o})]})});return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d?e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(n.OxButton,{"aria-expanded":u,"aria-label":`Notifications${f?` (${l} unread)`:""}`,disabled:s,icon:"mdiBellOutline",variant:"ghost",onClick:()=>h(!u)}),f?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx("div",{className:"absolute -top-2 -right-2",children:e.jsxRuntimeExports.jsx(q,{className:"min-w-[1.25rem] justify-center px-1",color:"violet",size:"sm",children:g})})}):null]}),ee.createPortal(e.jsxRuntimeExports.jsxs("div",{"aria-labelledby":"notifications-title-mobile","aria-modal":"true",className:n.twMerge("fixed inset-y-0 z-50 flex w-full flex-col bg-zinc-1000/50 backdrop-blur-xl transition-transform duration-300",u?"translate-x-0":"translate-x-full"),role:"dialog",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex h-15 items-center justify-between border-b border-neutral-800 px-4",children:[d?e.jsxRuntimeExports.jsx(n.OxButton,{"aria-label":"Close sidebar",icon:"mdiClose",variant:"ghost",onClick:()=>h(!1)}):null,e.jsxRuntimeExports.jsx("h3",{id:"notifications-title-mobile",className:"text-sm font-semibold text-white",children:"Notifications"}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:f&&x&&e.jsxRuntimeExports.jsx("button",{className:"cursor-pointer text-xs text-neutral-400 transition-colors hover:text-white",onClick:R,children:"Mark all read"})})]}),e.jsxRuntimeExports.jsx("ul",{className:"flex-1 overflow-y-auto",children:e.jsxRuntimeExports.jsx(O,{})})]}),document.body)]}):e.jsxRuntimeExports.jsxs(ie,{className:t,disabled:s,children:[e.jsxRuntimeExports.jsx(Z,{"aria-label":`Notifications${f?` (${l} unread)`:""}`,className:n.twJoin("relative flex h-10 w-10 items-center justify-center px-2 text-sm","secondary-outset-focus group rounded-lg border border-transparent bg-transparent text-white enabled:cursor-pointer enabled:hover:bg-white/6"),disabled:s,icon:"mdiBellOutline",unstyled:!0,children:f?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx("div",{className:"absolute -top-2 -right-2",children:e.jsxRuntimeExports.jsx(q,{className:"min-w-[1.25rem] justify-center px-1",color:"violet",size:"sm",children:g})})}):null}),e.jsxRuntimeExports.jsx(X,{children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("h3",{id:"notifications-title",className:"text-sm font-semibold text-white",children:"Notifications"}),f&&x&&e.jsxRuntimeExports.jsx("button",{className:"secondary-outset-focus cursor-pointer rounded-lg p-1 text-xs text-neutral-400 transition-colors hover:text-white",onClick:x,children:"Mark all read"})]})}),e.jsxRuntimeExports.jsx(Q,{align:"end","aria-labelledby":"notifications-title",className:n.twMerge("flex w-85 flex-col overflow-hidden p-0",i),side:"bottom",children:e.jsxRuntimeExports.jsx(O,{})})]})})},ae=b.createContext(void 0),Be=()=>{const t=b.useContext(ae);if(!t)throw new Error("Select components must be used within an OxSelect");return t},xe=({children:t,className:s,disabled:o=!1,id:i,value:r})=>{const{closeDropdown:x,onSelect:a,selectedValue:l}=Be(),u=()=>{a({value:r,label:t})},h=p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a({value:r,label:t})),p.key==="Escape"&&x()},d=l.includes(r);return e.jsxRuntimeExports.jsx("li",{role:"none",children:e.jsxRuntimeExports.jsxs("button",{id:i,"aria-selected":d,className:n.twMerge("group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm enabled:text-white","enabled:cursor-pointer enabled:hover:bg-white/6","default-inset-focus","default-disabled",d&&"bg-white/5",s),disabled:o,role:"option",tabIndex:o?-1:0,onClick:u,onKeyDown:h,children:[t,d&&!o&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:"text-violet-700",icon:"mdiCheck",size:.8})]})})};let U=null,_=null;const Pe=()=>(U||(U=document.createElement("canvas"),_=U.getContext("2d"),_.font="0.875rem system-ui, sans-serif"),_),We=(t,s,o)=>{if(t.length===0)return[];if(!s.current)return t.slice(0,1);const i=s.current.offsetWidth||0,r=12,x=32,a=32;let l=i-r-x;t.length>1&&(l-=a);const u=Pe();if(!u)return t.slice(0,2);const h=o?4:8,d=o?12:0;let p=0,g=0;for(let f=0;f<t.length;f++){const j=t[f],v=String(j.label),O=u.measureText(v).width+(o?d:0),c=f>0?p+O+h:p+O;if(c<=l)p=c,g++;else break}return g=Math.max(1,g),t.slice(0,g)},He=t=>t==null?[]:Array.isArray(t)?t:[t],qe=({badgeColor:t="purple",children:s,className:o,defaultValue:i=null,description:r,disabled:x=!1,displayAsBadges:a=!1,error:l=!1,errorMessage:u,id:h,label:d,multiple:p=!1,name:g,onChange:f,placeholder:j="Select an option",required:v=!1})=>{const R=b.useId(),O=b.useRef(null),[c,w]=b.useState(!1),[y,I]=b.useState([]),L=h||R,N=`${L}-select`,F=`${L}-description`,S=`${L}-error`,D=l&&u,P=(k,m)=>{let E=null;return b.Children.forEach(k,C=>{if(b.isValidElement(C)&&C.type===xe){const z=C.props;z.value===m&&(E={value:z.value,label:z.children})}}),E},W=k=>{let m;if(p?y.some(C=>C.value===k.value)?m=y.filter(C=>C.value!==k.value):m=[...y,k]:(m=[k],w(!1)),I(m),f){const E=p?m.map(C=>C.value):m[0]?.value??null;f(E)}};b.useEffect(()=>{if(i!==void 0){const k=He(i),m=[];k.forEach(E=>{const C=P(s,E);C&&m.push(C)}),I(p?m:m.slice(0,1))}},[i,s,p]);const V=e.jsxRuntimeExports.jsx("ul",{id:`${N}-listbox`,"aria-multiselectable":p,className:"max-h-72 space-y-0.5 overflow-hidden overflow-y-auto",role:"listbox",children:s}),H=We(y,O,a),J=y.length-H.length,A=J>0;return e.jsxRuntimeExports.jsx(ae.Provider,{value:{selectedValue:y.map(k=>k.value),multiple:p,onSelect:W,closeDropdown:()=>w(!1)},children:e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("flex w-full flex-col gap-1",o),children:[d&&e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:N,required:v,children:d}),e.jsxRuntimeExports.jsx(Y,{align:"start",content:V,contentClassName:"default-border bg-zinc-1000/70 rounded-lg p-1 backdrop-blur-xl animate-dropdown-in-bottom",contentStyle:{minWidth:`${O.current?.offsetWidth||200}px`},disabled:x,open:c,position:"bottom",trigger:"click",onOpenChange:w,children:e.jsxRuntimeExports.jsxs("button",{id:N,"aria-controls":`${N}-listbox`,"aria-describedby":[r?F:"",D?S:""].filter(Boolean).join(" ")||void 0,"aria-disabled":x,"aria-expanded":c,"aria-haspopup":"listbox","aria-invalid":l,"aria-required":v,className:n.twJoin("relative flex h-10 w-full gap-x-2 rounded-lg py-2 ps-3 pe-8 text-start text-sm enabled:cursor-pointer enabled:text-white","default-outset-focus default-disabled",l?"default-error-border":"default-border",c&&"default-active-border"),disabled:x,ref:O,role:"combobox",type:"button",children:[e.jsxRuntimeExports.jsx("span",{className:n.twJoin("w-full overflow-hidden text-ellipsis",a?p&&"flex flex-wrap gap-1":"whitespace-nowrap",x&&a&&"opacity-50"),children:y.length>0?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&p?H.map(k=>e.jsxRuntimeExports.jsx(q,{color:t,size:"sm",children:k.label},String(k.value))):H.map((k,m,E)=>e.jsxRuntimeExports.jsxs(b.Fragment,{children:[k.label,m<E.length-1&&", "]},String(k.value))),A&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!(a&&p)&&" ",e.jsxRuntimeExports.jsxs(q,{color:t,size:"sm",children:["+",J]})]})]}):j}),e.jsxRuntimeExports.jsx("div",{className:"absolute end-3 top-1/2 -translate-y-1/2",children:e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin("transition-transform duration-300 ease-in-out",x&&"text-neutral-500",c&&"rotate-180"),icon:"mdiChevronDown",size:.8})})]})}),g&&e.jsxRuntimeExports.jsx("input",{name:g,type:"hidden",value:y.map(k=>k.value).join(",")}),r&&e.jsxRuntimeExports.jsx(M.OxDescription,{id:F,disabled:x,children:r}),D&&e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:S,children:u})]})})},Je=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("px-2 py-1 text-xs font-medium text-neutral-400",s),children:t}),Ve={default:"bg-zinc-800/80",purple:"bg-purple-950/50",blue:"bg-blue-950/50",gray:"bg-gray-800/50"},Ae={rectangle:"rounded-md",circle:"rounded-full"},ce=({animate:t=!0,className:s,color:o="default",fullWidth:i=!1,height:r,shape:x="rectangle",width:a,...l})=>{const u={height:typeof r=="number"?`${r}px`:r,width:typeof a=="number"?`${a}px`:a};return e.jsxRuntimeExports.jsx("div",{"aria-busy":"true","aria-label":"Loading...",className:n.twMerge("relative overflow-hidden",Ve[o],Ae[x],t&&"animate-pulse",i&&"w-full",s),role:"status",style:u,...l})},Ge=({animate:t=!0,className:s,color:o="default",fullWidth:i=!1,gap:r=8,height:x=20,lines:a=1,width:l,...u})=>{const h=g=>g<=1?`${g*100}%`:`${g}px`,d=g=>{if(!i){if(Array.isArray(l)){const f=l[g%l.length];return f==null?void 0:typeof f=="number"?h(f):f}if(typeof l=="number"){if(a>1&&g===a-1){const f=l<=1?l*.6:Math.max(100,l*.6);return h(f)}return h(l)}return"200px"}},p={4:"space-y-1",8:"space-y-2",12:"space-y-3",16:"space-y-4",20:"space-y-5"}[r]||"space-y-2";return e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex flex-col",p,s),...u,children:Array.from({length:a}).map((g,f)=>e.jsxRuntimeExports.jsx(ce,{animate:t,color:o,fullWidth:i,height:x,width:d(f)},f))})},Ke=({className:t,description:s,disabled:o=!1,error:i=!1,errorMessage:r,id:x,label:a,name:l,onChange:u,placeholder:h="Enter text...",readOnly:d=!1,required:p=!1,rows:g=3,showMaxLength:f=!1,value:j,...v})=>{const R=b.useId(),[O,c]=b.useState(typeof j=="string"?j.length:0),w=x||R,y=`${w}-textarea`,I=`${w}-description`,L=`${w}-error`,N=v.maxLength,F=i&&r;b.useEffect(()=>{typeof j=="string"&&c(j.length)},[j]);const S=P=>{const W=P.target.value.length;c(W),u?.(P)},D=e.jsxRuntimeExports.jsx("textarea",{id:y,"aria-describedby":[s?I:"",F?L:""].filter(Boolean).join(" ")||void 0,"aria-invalid":i,"aria-required":p,className:n.twMerge("flex min-h-10 w-full resize-y rounded-lg bg-transparent px-2 py-2 text-sm text-white","placeholder:text-neutral-500","default-outset-focus","default-disabled",i?"default-error-border":"default-border",t),disabled:o,name:l,placeholder:h,readOnly:d,rows:g,value:j,onChange:S,...v});return e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[a?e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:y,required:p,children:a}):null,D,f&&typeof N=="number"?e.jsxRuntimeExports.jsxs("div",{className:"pointer-events-none mt-1 text-right text-xs text-neutral-400",children:[O,"/",N]}):null,s?e.jsxRuntimeExports.jsx(M.OxDescription,{id:I,disabled:o,children:s}):null,F?e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:L,children:r}):null]})},Ue={default:"default-border backdrop-blur-xl text-white bg-zinc-1000/70",error:"bg-red-900/70 text-red-200 border-red-700",warning:"bg-amber-900/70 text-amber-200 border-amber-700",info:"bg-blue-900/70 text-blue-200 border-blue-700",success:"bg-green-900/70 text-green-200 border-green-700"},_e=({align:t="center",children:s,className:o,content:i,disabled:r=!1,id:x,onOpenChange:a,open:l,position:u="top",trigger:h="hover",variant:d="default"})=>{const p=e.jsxRuntimeExports.jsx("div",{className:n.twMerge("max-w-xs rounded-md border px-2 py-1 text-xs break-words backdrop-blur-sm",Ue[d],o),children:i});return e.jsxRuntimeExports.jsx(Y,{id:x,align:t,content:p,contentRole:"tooltip",disabled:r,offset:8,open:l,position:u,trigger:h,useAriaControls:!1,onOpenChange:a,children:s})},Ye=({children:t,onAuthenticated:s=null,onLoading:o=null})=>{const{isLoggedIn:i,loading:r}=te.useOxAuth();return r?o:i?s:t},Qe=({children:t,onLoading:s=null,onUnauthenticated:o=null})=>{const{isLoggedIn:i,loading:r}=te.useOxAuth();return r?s:i?t:o};exports.OxButton=n.OxButton;exports.OxIcon=n.OxIcon;exports.OxDescription=M.OxDescription;exports.OxErrorMessage=M.OxErrorMessage;exports.OxForm=M.OxForm;exports.OxInput=M.OxInput;exports.OxLabel=M.OxLabel;exports.OxAvatar=me;exports.OxAvatarImage=se;exports.OxAvatarText=he;exports.OxBadge=q;exports.OxCard=Ne;exports.OxCardContent=Ie;exports.OxCardFooter=Me;exports.OxCardHeader=Ce;exports.OxCheckbox=Le;exports.OxDropdown=ie;exports.OxDropdownContent=Q;exports.OxDropdownFooter=re;exports.OxDropdownHeader=X;exports.OxDropdownItem=le;exports.OxDropdownSeparator=Fe;exports.OxDropdownShortcut=De;exports.OxDropdownTrigger=Z;exports.OxGuestRoute=Ye;exports.OxNotificationDropdown=Te;exports.OxProtectedRoute=Qe;exports.OxSelect=qe;exports.OxSelectLabel=Je;exports.OxSelectOption=xe;exports.OxSkeleton=ce;exports.OxSkeletonText=Ge;exports.OxTextarea=Ke;exports.OxTooltip=_e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const e=require("./chunks/jsx-runtime-CITbqOLs.js"),b=require("react"),n=require("./chunks/Button-D-v4l8ZE.js"),M=require("./chunks/Input-CLi1H63d.js"),ee=require("react-dom"),de=require("./chunks/constants-B1_n9ezb.js"),ue=require("./chunks/formatTimestamp-TTsNcy7u.js");require("./chunks/AuthContext-uU1aP9gj.js");const te=require("./chunks/useAuth-BsWbsZD5.js"),me=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex items-center gap-3",s),children:t}),G={rounded:"rounded-full",square:"rounded-lg"},K={sm:"h-6 w-6",md:"h-8 w-8",lg:"h-10 w-10",xl:"h-12 w-12","2xl":"h-16 w-16"},pe={sm:"h-2 w-2",md:"h-2.5 w-2.5",lg:"h-3 w-3",xl:"h-3.5 w-3.5","2xl":"h-4 w-4"},fe={online:"bg-green-500",offline:"bg-neutral-500",away:"bg-yellow-500",busy:"bg-red-500"},be={sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-base","2xl":"text-lg"},se=({alt:t,className:s,fallback:o,showStatus:i=!1,size:r="md",skeleton:x=!1,src:a,status:l,type:u="square"})=>{const[h,d]=b.useState(!1),[p,g]=b.useState(!1),[f,j]=b.useState(!0);b.useEffect(()=>{if(!a){d(!1),g(!0),j(!1);return}j(!0);const R=new Image;R.src=a;const O=()=>{d(!0),g(!1),j(!1)},c=()=>{d(!1),g(!0),j(!1)};return R.addEventListener("load",O),R.addEventListener("error",c),()=>{R.removeEventListener("load",O),R.removeEventListener("error",c)}},[a]);const v=()=>f&&x?e.jsxRuntimeExports.jsx("div",{className:n.twJoin("animate-pulse bg-zinc-800",G[u],K[r])}):h&&!p?e.jsxRuntimeExports.jsx("img",{alt:t,className:n.twMerge(G[u],K[r],"object-cover",s),loading:"lazy",src:a}):e.jsxRuntimeExports.jsx("div",{"aria-label":t,className:n.twMerge("flex items-center justify-center bg-zinc-800 font-medium text-white",G[u],K[r],be[r],s),role:"img",children:typeof o=="string"&&o.length>2?o.substring(0,2):o});return e.jsxRuntimeExports.jsxs("div",{className:"relative shrink-0",children:[v(),i&&l&&e.jsxRuntimeExports.jsx("span",{"aria-label":`Status: ${l}`,className:n.twJoin("absolute right-0 bottom-0 rounded-full border-2 border-zinc-900",pe[r],fe[l]),role:"status"})]})},he=({className:t,size:s="md",subtext:o,username:i})=>{const r={sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-lg","2xl":"text-xl"},x={sm:"text-xs",md:"text-xs",lg:"text-sm",xl:"text-sm","2xl":"text-base"};return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("flex flex-col justify-center overflow-hidden",t),children:[e.jsxRuntimeExports.jsx("span",{className:n.twJoin("block truncate font-medium text-white",r[s]),children:i}),o&&e.jsxRuntimeExports.jsx("span",{className:n.twJoin("block truncate text-neutral-400",x[s]),children:o})]})},ge={sm:"px-1 py-0.5 text-xs",md:"px-1.5 py-0.5 text-sm",lg:"px-2 py-1 text-base"},je={purple:"bg-purple-500/25 text-purple-400",lime:"bg-lime-400/10 text-lime-300",red:"bg-red-500/25 text-red-400",yellow:"bg-yellow-500/25 text-yellow-400",green:"bg-green-500/25 text-green-400",blue:"bg-blue-500/25 text-blue-400",indigo:"bg-indigo-500/25 text-indigo-400",pink:"bg-pink-500/25 text-pink-400",amber:"bg-amber-500/25 text-amber-400",emerald:"bg-emerald-500/25 text-emerald-400",teal:"bg-teal-500/25 text-teal-400",cyan:"bg-cyan-500/25 text-cyan-400",sky:"bg-sky-500/25 text-sky-400",violet:"bg-violet-500/25 text-violet-400",fuchsia:"bg-fuchsia-500/25 text-fuchsia-400",gray:"bg-gray-500/25 text-gray-400"};function we(t){const s=t.startsWith("#")?t.substring(1):t;if(!/^[0-9A-Fa-f]{3,6}$/.test(s))return"#FFFFFF";const i=parseInt(s.length===3?s[0]+s[0]:s.substr(0,2),16),r=parseInt(s.length===3?s[1]+s[1]:s.substr(2,2),16),x=parseInt(s.length===3?s[2]+s[2]:s.substr(4,2),16);return(.299*i+.587*r+.114*x)/255>.5?"#000000":"#FFFFFF"}const H=({bgColor:t,children:s,className:o,color:i="purple",size:r="md",textColor:x})=>{const a=!t&&!x?je[i]:"",l={};return t&&(l.backgroundColor=t,x||(l.color=we(t))),x&&(l.color=x),e.jsxRuntimeExports.jsx("span",{className:n.twMerge("inline-flex items-center rounded-md font-medium",ge[r],a,o),style:Object.keys(l).length?l:void 0,children:s})},Ee={default:"bg-zinc-900/90 border border-zinc-800",outline:"bg-transparent border border-zinc-700",gradient:"bg-gradient-to-br from-zinc-900 via-purple-900/20 to-zinc-900 border border-purple-800/30"},ve={none:"p-0",sm:"p-3",md:"p-4",lg:"p-6"},Re={none:"",lift:"hover:scale-[1.01] hover:-translate-y-1",glow:"hover:shadow-lg hover:shadow-purple-500/10",border:"hover:border-purple-500/50"},ye={purple:"hover:border-purple-500/50",blue:"hover:border-blue-500/50",emerald:"hover:border-emerald-500/50",orange:"hover:border-orange-500/50",rose:"hover:border-rose-500/50",amber:"hover:border-amber-500/50",cyan:"hover:border-cyan-500/50",indigo:"hover:border-indigo-500/50"},Oe={purple:"from-purple-500/5 to-pink-500/5",blue:"from-blue-500/5 to-cyan-500/5",emerald:"from-emerald-500/5 to-teal-500/5",orange:"from-orange-500/5 to-red-500/5",rose:"from-rose-500/5 to-pink-500/5",amber:"from-amber-500/5 to-orange-500/5",cyan:"from-cyan-500/5 to-blue-500/5",indigo:"from-indigo-500/5 to-purple-500/5"},Ne=({backdropBlur:t=!1,children:s,className:o,color:i="purple",equalHeight:r=!1,hoverVariant:x="lift",hoverable:a=!1,padding:l="md",variant:u="default",...h})=>{const d=a?x:"none",p=a&&d!=="none";return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("relative overflow-hidden rounded-lg transition-all duration-300",Ee[u],ve[l],r&&"flex flex-col",t&&"backdrop-blur-sm",p&&Re[d],p&&"group hover:bg-white/5",p&&ye[i],o),...h,children:[p&&e.jsxRuntimeExports.jsx("div",{className:n.twMerge("absolute inset-0 bg-gradient-to-br opacity-0 transition-opacity duration-300 group-hover:opacity-100",Oe[i])}),e.jsxRuntimeExports.jsx("div",{className:"relative z-10",children:s})]})},ke={purple:{border:"border-purple-500/20",bg:"bg-purple-500/10",text:"text-purple-400"},blue:{border:"border-blue-500/20",bg:"bg-blue-500/10",text:"text-blue-400"},emerald:{border:"border-emerald-500/20",bg:"bg-emerald-500/10",text:"text-emerald-400"},orange:{border:"border-orange-500/20",bg:"bg-orange-500/10",text:"text-orange-400"},rose:{border:"border-rose-500/20",bg:"bg-rose-500/10",text:"text-rose-400"},amber:{border:"border-amber-500/20",bg:"bg-amber-500/10",text:"text-amber-400"},cyan:{border:"border-cyan-500/20",bg:"bg-cyan-500/10",text:"text-cyan-400"},indigo:{border:"border-indigo-500/20",bg:"bg-indigo-500/10",text:"text-indigo-400"}},Ce=({action:t,children:s,className:o,color:i="purple",icon:r,iconColor:x,subtitle:a,title:l,...u})=>{if(s)return e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mb-4",o),...u,children:s});const d=ke[x||i];return e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("mb-4 flex items-start justify-between gap-3",o),...u,children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsxRuntimeExports.jsx("div",{className:n.twMerge("rounded-lg border p-2",d.border,d.bg),children:e.jsxRuntimeExports.jsx(n.OxIcon,{className:d.text,icon:r})}),e.jsxRuntimeExports.jsxs("div",{children:[l&&e.jsxRuntimeExports.jsx("h3",{className:"text-base font-semibold text-white",children:l}),a&&e.jsxRuntimeExports.jsx("p",{className:"text-sm text-neutral-400",children:a})]})]}),t&&e.jsxRuntimeExports.jsx("div",{children:t})]})},Ie=({children:t,className:s,flexGrow:o=!0,...i})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("py-2",o&&"flex-grow",s),...i,children:t}),Me=({children:t,className:s,...o})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mt-4 flex items-center justify-end border-t border-neutral-800 pt-4",s),...o,children:t}),Se={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"},ze={sm:.5,md:.7,lg:.9},Le=({checked:t,className:s,defaultChecked:o,description:i,disabled:r=!1,error:x=!1,errorMessage:a,id:l,label:u,name:h,onChange:d,required:p=!1,size:g="md",value:f,...j})=>{const v=b.useId(),R=l||v,O=`${R}-checkbox`,c=`${R}-description`,w=`${R}-error`,y=x&&a,I=e.jsxRuntimeExports.jsxs("div",{className:"relative inline-flex shrink-0",children:[e.jsxRuntimeExports.jsx("input",{id:O,"aria-describedby":[i?c:"",y?w:""].filter(Boolean).join(" ")||void 0,"aria-invalid":x,"aria-required":p,checked:t,className:n.twMerge("peer cursor-pointer appearance-none rounded-sm","checked:bg-violet-700","default-outset-focus","disabled:cursor-not-allowed disabled:opacity-50",x?"default-error-border":"default-border",Se[g],s),defaultChecked:o,disabled:r,name:h,type:"checkbox",value:f,onChange:d,...j}),e.jsxRuntimeExports.jsx(n.OxIcon,{className:"pointer-events-none absolute inset-0 m-auto opacity-0 peer-checked:opacity-80",icon:"mdiCheck",size:ze[g]||.7})]});return e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-start gap-2",children:[I,u&&e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:O,required:p,children:u}),i?e.jsxRuntimeExports.jsx(M.OxDescription,{id:c,disabled:r,children:i}):null]})]}),y?e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:w,children:a}):null]})},Y=({align:t="center",ariaHaspopup:s,children:o,className:i,content:r,contentClassName:x,contentRole:a,contentStyle:l,disabled:u=!1,id:h,offset:d=8,onOpenChange:p,open:g,portal:f=!0,position:j="top",trigger:v="hover",useAriaControls:R=!1})=>{const O=b.useId(),[c,w]=b.useState(!1),y=b.useRef(null),I=b.useRef(null),L=g!==void 0,N=u?!1:L?g:c,F=h||O,S=b.useCallback(m=>{u||(p?.(m),L||w(m))},[u,L,p]),D=b.useCallback(()=>{if(!y.current||!I.current||!N)return;const m=y.current.getBoundingClientRect(),E=I.current.getBoundingClientRect(),C={width:window.innerWidth,height:window.innerHeight};let z=j;j==="top"&&m.top<E.height+d?z="bottom":j==="bottom"&&m.bottom+E.height+d>C.height?z="top":j==="left"&&m.left<E.width+d?z="right":j==="right"&&m.right+E.width+d>C.width&&(z="left");const $=P(m,E,z,t,d);I.current&&(I.current.style.left=`${$.x}px`,I.current.style.top=`${$.y}px`)},[N,j,t,d]);b.useEffect(()=>{if(!N||v!=="click")return;const m=E=>{y.current&&!y.current.contains(E.target)&&I.current&&!I.current.contains(E.target)&&S(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[N,S,v]),b.useEffect(()=>{if(N){D();const m=()=>D(),E=()=>D();return window.addEventListener("resize",m),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",E,!0)}}},[N,j,t,d,D]);const P=(m,E,C,z,$)=>{let T=0,B=0;switch(C){case"top":T=m.left,B=m.top-E.height-$;break;case"bottom":T=m.left,B=m.bottom+$;break;case"left":T=m.left-E.width-$,B=m.top;break;case"right":T=m.right+$,B=m.top;break}if(C==="top"||C==="bottom")switch(z){case"start":break;case"center":T=m.left+(m.width-E.width)/2;break;case"end":T=m.right-E.width;break}else if(C==="left"||C==="right")switch(z){case"start":break;case"center":B=m.top+(m.height-E.height)/2;break;case"end":B=m.bottom-E.height;break}return{x:T,y:B}},W=()=>{v==="hover"&&S(!0)},V=()=>{v==="hover"&&S(!1)},q=()=>{v==="click"&&S(!N)},J=()=>{v==="focus"&&S(!0)},A=()=>{v==="focus"&&S(!1)},k=N?e.jsxRuntimeExports.jsx("div",{id:F,"aria-hidden":!N,className:n.twMerge("fixed z-50 transition-opacity duration-200",N?"opacity-100":"pointer-events-none opacity-0",x),ref:I,role:a,style:{left:-9999,top:-9999,...l},children:e.jsxRuntimeExports.jsx("div",{className:"relative",children:r})}):null;return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{"aria-controls":R&&N?F:void 0,"aria-describedby":!R&&N?F:void 0,"aria-expanded":R?N:void 0,"aria-haspopup":s,className:n.twMerge("w-full",i),ref:y,onBlur:A,onClick:q,onFocus:J,onMouseEnter:W,onMouseLeave:V,children:o}),f&&typeof document<"u"?ee.createPortal(k,document.body):k]})},Q=({children:t})=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t}),re=({children:t})=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t}),X=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("sticky top-0 flex-shrink-0 border-b border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-lg",s),children:t}),ne=b.createContext({open:!1,setOpen:()=>{},disabled:!1});function oe(){const t=b.useContext(ne);if(t===void 0)throw new Error("useDropdownContext must be used within a DropdownProvider");return t}const Z=({animateIcon:t=!1,children:s,className:o,disabled:i=!1,icon:r,outline:x=!1,unstyled:a=!1,...l})=>{const{disabled:u,open:h}=oe(),d=i||u;return e.jsxRuntimeExports.jsxs("button",{"aria-expanded":h,"aria-haspopup":"menu",className:n.twMerge(!a&&["flex h-10 items-center justify-between rounded-lg px-3 py-2 text-sm enabled:cursor-pointer enabled:text-white enabled:hover:bg-white/6","default-outset-focus",x?"default-border":"bg-transparent","default-disabled"],o),disabled:d,type:"button",...l,children:[a?s:e.jsxRuntimeExports.jsx("span",{className:"flex items-center gap-2",children:s}),r&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin(!a&&"ml-2",d&&"text-neutral-500",t&&["transition-transform duration-200",h&&"rotate-180"]),icon:r,size:.8})]})},ie=({children:t,className:s,defaultOpen:o=!1,disabled:i=!1,onOpenChange:r,open:x})=>{const[a,l]=b.useState(o),u=x!==void 0,h=u?x:a,d=c=>{i||(u||l(c),r?.(c))},p={open:h,setOpen:d,disabled:i};let g=null,f=null;const j={children:null,className:""},v={children:null,className:""};let R={side:"bottom",align:"start",className:""};b.Children.forEach(t,c=>{if(b.isValidElement(c)){if(c.type===Z)g=c;else if(c.type===X){const w=c.props;j.className=w.className,j.children=w.children}else if(c.type===re){const w=c.props;v.className=w.className,v.children=w.children}else if(c.type===Q){const w=c.props;f=w.children,R={side:w.side||"bottom",align:w.align||"start",className:w.className||""}}}});const O=e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("default-border z-50 flex max-h-96 min-w-[8rem] flex-col overflow-hidden rounded-lg bg-zinc-1000/50 p-1 backdrop-blur-xl",R.side==="bottom"&&"animate-dropdown-in-bottom",R.side==="top"&&"animate-dropdown-in-top",R.className),children:[j.children?e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex-shrink-0 border-b border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-sm",j.className),children:j.children}):null,e.jsxRuntimeExports.jsx("ul",{className:n.twMerge("min-h-0 flex-1 overflow-y-auto"),children:f}),v.children?e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex-shrink-0 border-t border-neutral-700 bg-zinc-1000/95 px-3 py-2 backdrop-blur-sm",v.className),children:v.children}):null]});return e.jsxRuntimeExports.jsx(ne.Provider,{value:p,children:e.jsxRuntimeExports.jsx("div",{className:n.twMerge("inline-block",s),children:e.jsxRuntimeExports.jsx(Y,{align:R.align,content:O,contentRole:"menu",disabled:i,open:h,portal:!0,position:R.side,trigger:"click",onOpenChange:d,children:g})})})},le=({children:t,className:s,disabled:o=!1,icon:i,onClick:r,unstyled:x=!1})=>{const{setOpen:a}=oe(),l=u=>{o||(r&&r(u),a(!1))};return e.jsxRuntimeExports.jsx("li",{children:e.jsxRuntimeExports.jsxs("button",{className:n.twMerge(!x&&["group flex w-full items-center rounded-sm px-2 py-1.5 text-left text-sm enabled:text-white","enabled:cursor-pointer enabled:hover:bg-white/6","default-inset-focus","default-disabled"],s),disabled:o,role:"menuitem",onClick:l,children:[i&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin("mr-2",o&&"text-neutral-500"),icon:i,size:.75}),t]})})},Fe=({className:t})=>e.jsxRuntimeExports.jsx("li",{className:"px-1 py-1",children:e.jsxRuntimeExports.jsx("hr",{className:n.twMerge("border-t-neutral-700",t)})}),De=({children:t,className:s})=>e.jsxRuntimeExports.jsx("span",{className:n.twMerge("ml-auto text-xs tracking-widest text-neutral-500",s),"data-part":"dropdown-shortcut",children:t}),$e={error:{background:"bg-rose-500/20",iconClass:"text-rose-400",icon:"mdiAlertCircleOutline"},success:{background:"bg-green-500/20",iconClass:"text-green-400",icon:"mdiCheckCircleOutline"},warning:{background:"bg-amber-500/20",iconClass:"text-amber-400",icon:"mdiAlertOutline"},info:{background:"bg-blue-500/20",iconClass:"text-blue-400",icon:"mdiInformationOutline"},default:{background:"bg-neutral-500/20",iconClass:"text-neutral-400",icon:"mdiBellOutline"}},Te=({className:t,disabled:s=!1,emptyMessage:o="No notifications",maxHeight:i="max-h-96",notifications:r,onMarkAllRead:x,onNotificationClick:a,unreadCount:l=0})=>{const[u,h]=b.useState(!1),[d,p]=b.useState(!1),g=l>99?"99+":l.toString(),f=l>0,j=r.length>0;b.useEffect(()=>{const c=()=>{const w=window.innerWidth<de.MOBILE_BREAKPOINT;p(w),w&&u?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")};return c(),window.addEventListener("resize",c),()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("resize",c)}},[u]);const v=c=>{a?.(c),d&&h(!1)},R=()=>{x?.(),d&&h(!1)},O=()=>e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:j?e.jsxRuntimeExports.jsx("div",{className:"divide-y divide-neutral-800/50",children:r.map((c,w)=>{const y=$e[c.type||"default"];return e.jsxRuntimeExports.jsxs(le,{className:n.twMerge("secondary-inset-focus flex w-full items-start gap-3 px-3 py-3 text-left hover:bg-white/6",!c.read&&"bg-white/3",w===r.length-1&&"pb-4"),unstyled:!0,onClick:()=>v(c),children:[e.jsxRuntimeExports.jsx("div",{className:n.twMerge("mt-0.5 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg",y.background),children:c.img?e.jsxRuntimeExports.jsx(se,{alt:"User avatar",fallback:"NA",size:"md",src:c.img}):e.jsxRuntimeExports.jsx(n.OxIcon,{className:y.iconClass,icon:c.icon??y.icon,size:.75})}),e.jsxRuntimeExports.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxRuntimeExports.jsx("p",{className:"mb-1 text-sm leading-5 text-white",children:c.title}),c.message&&e.jsxRuntimeExports.jsx("p",{className:"mb-1 text-xs leading-4 text-neutral-400",children:c.message}),e.jsxRuntimeExports.jsx("p",{className:"text-xs text-neutral-500",children:ue.formatTimestamp(c.timestamp)})]}),!c.read&&e.jsxRuntimeExports.jsx("div",{className:"mt-1.5 h-2 w-2 flex-shrink-0 rounded-full bg-rose-500"})]},c.id)})}):e.jsxRuntimeExports.jsxs("div",{"aria-label":"No notifications available",className:"px-3 py-8 text-center",role:"status",children:[e.jsxRuntimeExports.jsx(n.OxIcon,{className:"mx-auto mb-2 text-neutral-500",icon:"mdiBellOffOutline",size:2}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-neutral-400",children:o})]})});return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:d?e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(n.OxButton,{"aria-expanded":u,"aria-label":`Notifications${f?` (${l} unread)`:""}`,disabled:s,icon:"mdiBellOutline",variant:"ghost",onClick:()=>h(!u)}),f?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx("div",{className:"absolute -top-2 -right-2",children:e.jsxRuntimeExports.jsx(H,{className:"min-w-[1.25rem] justify-center px-1",color:"violet",size:"sm",children:g})})}):null]}),ee.createPortal(e.jsxRuntimeExports.jsxs("div",{"aria-labelledby":"notifications-title-mobile","aria-modal":"true",className:n.twMerge("fixed inset-y-0 z-50 flex w-full flex-col bg-zinc-1000/50 backdrop-blur-xl transition-transform duration-300",u?"translate-x-0":"translate-x-full"),role:"dialog",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex h-15 items-center justify-between border-b border-neutral-800 px-4",children:[d?e.jsxRuntimeExports.jsx(n.OxButton,{"aria-label":"Close sidebar",icon:"mdiClose",variant:"ghost",onClick:()=>h(!1)}):null,e.jsxRuntimeExports.jsx("h3",{id:"notifications-title-mobile",className:"text-sm font-semibold text-white",children:"Notifications"}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:f&&x&&e.jsxRuntimeExports.jsx("button",{className:"cursor-pointer text-xs text-neutral-400 transition-colors hover:text-white",onClick:R,children:"Mark all read"})})]}),e.jsxRuntimeExports.jsx("ul",{className:"flex-1 overflow-y-auto",children:e.jsxRuntimeExports.jsx(O,{})})]}),document.body)]}):e.jsxRuntimeExports.jsxs(ie,{className:t,disabled:s,children:[e.jsxRuntimeExports.jsx(Z,{"aria-label":`Notifications${f?` (${l} unread)`:""}`,className:n.twJoin("relative flex h-10 w-10 items-center justify-center px-2 text-sm","secondary-outset-focus group rounded-lg border border-transparent bg-transparent text-white enabled:cursor-pointer enabled:hover:bg-white/6"),disabled:s,icon:"mdiBellOutline",unstyled:!0,children:f?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx("div",{className:"absolute -top-2 -right-2",children:e.jsxRuntimeExports.jsx(H,{className:"min-w-[1.25rem] justify-center px-1",color:"violet",size:"sm",children:g})})}):null}),e.jsxRuntimeExports.jsx(X,{children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("h3",{id:"notifications-title",className:"text-sm font-semibold text-white",children:"Notifications"}),f&&x&&e.jsxRuntimeExports.jsx("button",{className:"secondary-outset-focus cursor-pointer rounded-lg p-1 text-xs text-neutral-400 transition-colors hover:text-white",onClick:x,children:"Mark all read"})]})}),e.jsxRuntimeExports.jsx(Q,{align:"end","aria-labelledby":"notifications-title",className:n.twMerge("flex w-85 flex-col overflow-hidden p-0",i),side:"bottom",children:e.jsxRuntimeExports.jsx(O,{})})]})})},ae=b.createContext(void 0),Be=()=>{const t=b.useContext(ae);if(!t)throw new Error("Select components must be used within an OxSelect");return t},xe=({children:t,className:s,disabled:o=!1,id:i,value:r})=>{const{closeDropdown:x,onSelect:a,selectedValue:l}=Be(),u=()=>{a({value:r,label:t})},h=p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a({value:r,label:t})),p.key==="Escape"&&x()},d=l.includes(r);return e.jsxRuntimeExports.jsx("li",{role:"none",children:e.jsxRuntimeExports.jsxs("button",{id:i,"aria-selected":d,className:n.twMerge("group flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-left text-sm enabled:text-white","enabled:cursor-pointer enabled:hover:bg-white/6","default-inset-focus","default-disabled",d&&"bg-white/5",s),disabled:o,role:"option",tabIndex:o?-1:0,onClick:u,onKeyDown:h,children:[t,d&&!o&&e.jsxRuntimeExports.jsx(n.OxIcon,{className:"text-violet-700",icon:"mdiCheck",size:.8})]})})};let U=null,_=null;const Pe=()=>(U||(U=document.createElement("canvas"),_=U.getContext("2d"),_.font="0.875rem system-ui, sans-serif"),_),We=(t,s,o)=>{if(t.length===0)return[];if(!s.current)return t.slice(0,1);const i=s.current.offsetWidth||0,r=12,x=32,a=32;let l=i-r-x;t.length>1&&(l-=a);const u=Pe();if(!u)return t.slice(0,2);const h=o?4:8,d=o?12:0;let p=0,g=0;for(let f=0;f<t.length;f++){const j=t[f],v=String(j.label),O=u.measureText(v).width+(o?d:0),c=f>0?p+O+h:p+O;if(c<=l)p=c,g++;else break}return g=Math.max(1,g),t.slice(0,g)},qe=t=>t==null?[]:Array.isArray(t)?t:[t],He=({badgeColor:t="purple",children:s,className:o,defaultValue:i=null,description:r,disabled:x=!1,displayAsBadges:a=!1,error:l=!1,errorMessage:u,id:h,label:d,multiple:p=!1,name:g,onChange:f,placeholder:j="Select an option",required:v=!1})=>{const R=b.useId(),O=b.useRef(null),[c,w]=b.useState(!1),[y,I]=b.useState([]),L=h||R,N=`${L}-select`,F=`${L}-description`,S=`${L}-error`,D=l&&u,P=(k,m)=>{let E=null;return b.Children.forEach(k,C=>{if(b.isValidElement(C)&&C.type===xe){const z=C.props;z.value===m&&(E={value:z.value,label:z.children})}}),E},W=k=>{let m;if(p?y.some(C=>C.value===k.value)?m=y.filter(C=>C.value!==k.value):m=[...y,k]:(m=[k],w(!1)),I(m),f){const E=p?m.map(C=>C.value):m[0]?.value??null;f(E)}};b.useEffect(()=>{if(i!==void 0){const k=qe(i),m=[];k.forEach(E=>{const C=P(s,E);C&&m.push(C)}),I(p?m:m.slice(0,1))}},[i,s,p]);const V=e.jsxRuntimeExports.jsx("ul",{id:`${N}-listbox`,"aria-multiselectable":p,className:"max-h-72 space-y-0.5 overflow-hidden overflow-y-auto",role:"listbox",children:s}),q=We(y,O,a),J=y.length-q.length,A=J>0;return e.jsxRuntimeExports.jsx(ae.Provider,{value:{selectedValue:y.map(k=>k.value),multiple:p,onSelect:W,closeDropdown:()=>w(!1)},children:e.jsxRuntimeExports.jsxs("div",{className:n.twMerge("flex w-full flex-col gap-1",o),children:[d&&e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:N,required:v,children:d}),e.jsxRuntimeExports.jsx(Y,{align:"start",content:V,contentClassName:"default-border bg-zinc-1000/70 rounded-lg p-1 backdrop-blur-xl animate-dropdown-in-bottom",contentStyle:{minWidth:`${O.current?.offsetWidth||200}px`},disabled:x,open:c,position:"bottom",trigger:"click",onOpenChange:w,children:e.jsxRuntimeExports.jsxs("button",{id:N,"aria-controls":`${N}-listbox`,"aria-describedby":[r?F:"",D?S:""].filter(Boolean).join(" ")||void 0,"aria-disabled":x,"aria-expanded":c,"aria-haspopup":"listbox","aria-invalid":l,"aria-required":v,className:n.twJoin("relative flex h-10 w-full gap-x-2 rounded-lg py-2 ps-3 pe-8 text-start text-sm enabled:cursor-pointer enabled:text-white","default-outset-focus default-disabled",l?"default-error-border":"default-border",c&&"default-active-border"),disabled:x,ref:O,role:"combobox",type:"button",children:[e.jsxRuntimeExports.jsx("span",{className:n.twJoin("w-full overflow-hidden text-ellipsis",a?p&&"flex flex-wrap gap-1":"whitespace-nowrap",x&&a&&"opacity-50"),children:y.length>0?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&p?q.map(k=>e.jsxRuntimeExports.jsx(H,{color:t,size:"sm",children:k.label},String(k.value))):q.map((k,m,E)=>e.jsxRuntimeExports.jsxs(b.Fragment,{children:[k.label,m<E.length-1&&", "]},String(k.value))),A&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!(a&&p)&&" ",e.jsxRuntimeExports.jsxs(H,{color:t,size:"sm",children:["+",J]})]})]}):j}),e.jsxRuntimeExports.jsx("div",{className:"absolute end-3 top-1/2 -translate-y-1/2",children:e.jsxRuntimeExports.jsx(n.OxIcon,{className:n.twJoin("transition-transform duration-300 ease-in-out",x&&"text-neutral-500",c&&"rotate-180"),icon:"mdiChevronDown",size:.8})})]})}),g&&e.jsxRuntimeExports.jsx("input",{name:g,type:"hidden",value:y.map(k=>k.value).join(",")}),r&&e.jsxRuntimeExports.jsx(M.OxDescription,{id:F,disabled:x,children:r}),D&&e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:S,children:u})]})})},Je=({children:t,className:s})=>e.jsxRuntimeExports.jsx("div",{className:n.twMerge("px-2 py-1 text-xs font-medium text-neutral-400",s),children:t}),Ve={default:"bg-zinc-800/80",purple:"bg-purple-950/50",blue:"bg-blue-950/50",gray:"bg-gray-800/50"},Ae={rectangle:"rounded-md",circle:"rounded-full"},ce=({animate:t=!0,className:s,color:o="default",fullWidth:i=!1,height:r,shape:x="rectangle",width:a,...l})=>{const u={height:typeof r=="number"?`${r}px`:r,width:typeof a=="number"?`${a}px`:a};return e.jsxRuntimeExports.jsx("div",{"aria-busy":"true","aria-label":"Loading...",className:n.twMerge("relative overflow-hidden",Ve[o],Ae[x],t&&"animate-pulse",i&&"w-full",s),role:"status",style:u,...l})},Ge=({animate:t=!0,className:s,color:o="default",fullWidth:i=!1,gap:r=8,height:x=20,lines:a=1,width:l,...u})=>{const h=g=>g<=1?`${g*100}%`:`${g}px`,d=g=>{if(!i){if(Array.isArray(l)){const f=l[g%l.length];return f==null?void 0:typeof f=="number"?h(f):f}if(typeof l=="number"){if(a>1&&g===a-1){const f=l<=1?l*.6:Math.max(100,l*.6);return h(f)}return h(l)}return"200px"}},p={4:"space-y-1",8:"space-y-2",12:"space-y-3",16:"space-y-4",20:"space-y-5"}[r]||"space-y-2";return e.jsxRuntimeExports.jsx("div",{className:n.twMerge("flex flex-col",p,s),...u,children:Array.from({length:a}).map((g,f)=>e.jsxRuntimeExports.jsx(ce,{animate:t,color:o,fullWidth:i,height:x,width:d(f)},f))})},Ke=({className:t,description:s,disabled:o=!1,error:i=!1,errorMessage:r,id:x,label:a,name:l,onChange:u,placeholder:h="Enter text...",readOnly:d=!1,required:p=!1,rows:g=3,showMaxLength:f=!1,value:j,...v})=>{const R=b.useId(),[O,c]=b.useState(typeof j=="string"?j.length:0),w=x||R,y=`${w}-textarea`,I=`${w}-description`,L=`${w}-error`,N=v.maxLength,F=i&&r;b.useEffect(()=>{typeof j=="string"&&c(j.length)},[j]);const S=P=>{const W=P.target.value.length;c(W),u?.(P)},D=e.jsxRuntimeExports.jsx("textarea",{id:y,"aria-describedby":[s?I:"",F?L:""].filter(Boolean).join(" ")||void 0,"aria-invalid":i,"aria-required":p,className:n.twMerge("flex min-h-10 w-full resize-y rounded-lg bg-transparent px-2 py-2 text-sm text-white","placeholder:text-neutral-500","default-outset-focus","default-disabled",i?"default-error-border":"default-border",t),disabled:o,name:l,placeholder:h,readOnly:d,rows:g,value:j,onChange:S,...v});return e.jsxRuntimeExports.jsxs("div",{className:"flex w-full flex-col gap-1",children:[a?e.jsxRuntimeExports.jsx(M.OxLabel,{htmlFor:y,required:p,children:a}):null,D,f&&typeof N=="number"?e.jsxRuntimeExports.jsxs("div",{className:"pointer-events-none mt-1 text-right text-xs text-neutral-400",children:[O,"/",N]}):null,s?e.jsxRuntimeExports.jsx(M.OxDescription,{id:I,disabled:o,children:s}):null,F?e.jsxRuntimeExports.jsx(M.OxErrorMessage,{id:L,children:r}):null]})},Ue={default:"default-border backdrop-blur-xl text-white bg-zinc-1000/70",error:"bg-red-900/70 text-red-200 border-red-700",warning:"bg-amber-900/70 text-amber-200 border-amber-700",info:"bg-blue-900/70 text-blue-200 border-blue-700",success:"bg-green-900/70 text-green-200 border-green-700"},_e=({align:t="center",children:s,className:o,content:i,disabled:r=!1,id:x,onOpenChange:a,open:l,position:u="top",trigger:h="hover",variant:d="default"})=>{const p=e.jsxRuntimeExports.jsx("div",{className:n.twMerge("max-w-xs rounded-md border px-2 py-1 text-xs break-words backdrop-blur-sm",Ue[d],o),children:i});return e.jsxRuntimeExports.jsx(Y,{id:x,align:t,content:p,contentRole:"tooltip",disabled:r,offset:8,open:l,position:u,trigger:h,useAriaControls:!1,onOpenChange:a,children:s})},Ye=({children:t,onAuthenticated:s=null,onLoading:o=null})=>{const{isLoggedIn:i,loading:r}=te.useOxAuth();return r?o:i?s:t},Qe=({children:t,onLoading:s=null,onUnauthenticated:o=null})=>{const{isLoggedIn:i,loading:r}=te.useOxAuth();return r?s:i?t:o};exports.OxButton=n.OxButton;exports.OxIcon=n.OxIcon;exports.OxDescription=M.OxDescription;exports.OxErrorMessage=M.OxErrorMessage;exports.OxForm=M.OxForm;exports.OxInput=M.OxInput;exports.OxLabel=M.OxLabel;exports.OxAvatar=me;exports.OxAvatarImage=se;exports.OxAvatarText=he;exports.OxBadge=H;exports.OxCard=Ne;exports.OxCardContent=Ie;exports.OxCardFooter=Me;exports.OxCardHeader=Ce;exports.OxCheckbox=Le;exports.OxDropdown=ie;exports.OxDropdownContent=Q;exports.OxDropdownFooter=re;exports.OxDropdownHeader=X;exports.OxDropdownItem=le;exports.OxDropdownSeparator=Fe;exports.OxDropdownShortcut=De;exports.OxDropdownTrigger=Z;exports.OxGuestRoute=Ye;exports.OxNotificationDropdown=Te;exports.OxProtectedRoute=Qe;exports.OxSelect=He;exports.OxSelectLabel=Je;exports.OxSelectOption=xe;exports.OxSkeleton=ce;exports.OxSkeletonText=Ge;exports.OxTextarea=Ke;exports.OxTooltip=_e;
package/dist/onyx.es.js CHANGED
@@ -2,12 +2,13 @@ import { j as e } from "./chunks/jsx-runtime--oOP9f8K.js";
2
2
  import U, { useState as S, useEffect as V, useId as G, useRef as ee, useCallback as oe, createContext as ae, useContext as ie } from "react";
3
3
  import { t as b, b as $, a as B, O as le } from "./chunks/Button-bARrxYyo.js";
4
4
  import { c as te, d as se, b as re } from "./chunks/Input-dfvmdIHi.js";
5
- import { O as wt, a as jt } from "./chunks/Input-dfvmdIHi.js";
5
+ import { O as jt, a as yt } from "./chunks/Input-dfvmdIHi.js";
6
6
  import { createPortal as ce } from "react-dom";
7
7
  import { M as pe } from "./chunks/constants-CDXq37n6.js";
8
8
  import { f as ge } from "./chunks/formatTimestamp-CMxOnPo1.js";
9
- import { u as de } from "./chunks/useAuth-DDN3TSQr.js";
10
- import './index.css';const tt = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx("div", { className: b("flex items-center gap-3", s), children: t }), Q = {
9
+ import "./chunks/AuthContext-CaZKJMxQ.js";
10
+ import { u as de } from "./chunks/useAuth-CkaMowHd.js";
11
+ import './index.css';const st = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx("div", { className: b("flex items-center gap-3", s), children: t }), Q = {
11
12
  rounded: "rounded-full",
12
13
  square: "rounded-lg"
13
14
  }, X = {
@@ -100,7 +101,7 @@ import './index.css';const tt = ({ children: t, className: s }) => /* @__PURE__
100
101
  }
101
102
  )
102
103
  ] });
103
- }, st = ({
104
+ }, rt = ({
104
105
  className: t,
105
106
  size: s = "md",
106
107
  subtext: n,
@@ -205,7 +206,7 @@ const q = ({
205
206
  amber: "from-amber-500/5 to-orange-500/5",
206
207
  cyan: "from-cyan-500/5 to-blue-500/5",
207
208
  indigo: "from-indigo-500/5 to-purple-500/5"
208
- }, rt = ({
209
+ }, nt = ({
209
210
  backdropBlur: t = !1,
210
211
  children: s,
211
212
  className: n,
@@ -288,7 +289,7 @@ const q = ({
288
289
  bg: "bg-indigo-500/10",
289
290
  text: "text-indigo-400"
290
291
  }
291
- }, nt = ({
292
+ }, ot = ({
292
293
  action: t,
293
294
  children: s,
294
295
  className: n,
@@ -312,12 +313,12 @@ const q = ({
312
313
  ] }),
313
314
  t && /* @__PURE__ */ e.jsx("div", { children: t })
314
315
  ] });
315
- }, ot = ({
316
+ }, lt = ({
316
317
  children: t,
317
318
  className: s,
318
319
  flexGrow: n = !0,
319
320
  ...o
320
- }) => /* @__PURE__ */ e.jsx("div", { className: b("py-2", n && "flex-grow", s), ...o, children: t }), lt = ({ children: t, className: s, ...n }) => /* @__PURE__ */ e.jsx(
321
+ }) => /* @__PURE__ */ e.jsx("div", { className: b("py-2", n && "flex-grow", s), ...o, children: t }), at = ({ children: t, className: s, ...n }) => /* @__PURE__ */ e.jsx(
321
322
  "div",
322
323
  {
323
324
  className: b(
@@ -335,7 +336,7 @@ const q = ({
335
336
  sm: 0.5,
336
337
  md: 0.7,
337
338
  lg: 0.9
338
- }, at = ({
339
+ }, it = ({
339
340
  checked: t,
340
341
  className: s,
341
342
  defaultChecked: n,
@@ -731,7 +732,7 @@ const be = ({
731
732
  ]
732
733
  }
733
734
  ) });
734
- }, it = ({ className: t }) => /* @__PURE__ */ e.jsx("li", { className: "px-1 py-1", children: /* @__PURE__ */ e.jsx("hr", { className: b("border-t-neutral-700", t) }) }), ct = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx(
735
+ }, ct = ({ className: t }) => /* @__PURE__ */ e.jsx("li", { className: "px-1 py-1", children: /* @__PURE__ */ e.jsx("hr", { className: b("border-t-neutral-700", t) }) }), dt = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx(
735
736
  "span",
736
737
  {
737
738
  className: b("ml-auto text-xs tracking-widest text-neutral-500", s),
@@ -764,7 +765,7 @@ const be = ({
764
765
  iconClass: "text-neutral-400",
765
766
  icon: "mdiBellOutline"
766
767
  }
767
- }, dt = ({
768
+ }, ut = ({
768
769
  className: t,
769
770
  disabled: s = !1,
770
771
  emptyMessage: n = "No notifications",
@@ -999,7 +1000,7 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
999
1000
  break;
1000
1001
  }
1001
1002
  return p = Math.max(1, p), t.slice(0, p);
1002
- }, Ae = (t) => t == null ? [] : Array.isArray(t) ? t : [t], ut = ({
1003
+ }, Ae = (t) => t == null ? [] : Array.isArray(t) ? t : [t], xt = ({
1003
1004
  badgeColor: t = "purple",
1004
1005
  children: s,
1005
1006
  className: n,
@@ -1149,7 +1150,7 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1149
1150
  ] })
1150
1151
  }
1151
1152
  );
1152
- }, xt = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx("div", { className: b("px-2 py-1 text-xs font-medium text-neutral-400", s), children: t }), Ke = {
1153
+ }, mt = ({ children: t, className: s }) => /* @__PURE__ */ e.jsx("div", { className: b("px-2 py-1 text-xs font-medium text-neutral-400", s), children: t }), Ke = {
1153
1154
  default: "bg-zinc-800/80",
1154
1155
  purple: "bg-purple-950/50",
1155
1156
  blue: "bg-blue-950/50",
@@ -1189,7 +1190,7 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1189
1190
  ...l
1190
1191
  }
1191
1192
  );
1192
- }, mt = ({
1193
+ }, ft = ({
1193
1194
  animate: t = !0,
1194
1195
  className: s,
1195
1196
  color: n = "default",
@@ -1233,7 +1234,7 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1233
1234
  },
1234
1235
  f
1235
1236
  )) });
1236
- }, ft = ({
1237
+ }, bt = ({
1237
1238
  className: t,
1238
1239
  description: s,
1239
1240
  disabled: n = !1,
@@ -1302,7 +1303,7 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1302
1303
  warning: "bg-amber-900/70 text-amber-200 border-amber-700",
1303
1304
  info: "bg-blue-900/70 text-blue-200 border-blue-700",
1304
1305
  success: "bg-green-900/70 text-green-200 border-green-700"
1305
- }, bt = ({
1306
+ }, ht = ({
1306
1307
  align: t = "center",
1307
1308
  children: s,
1308
1309
  className: n,
@@ -1343,14 +1344,14 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1343
1344
  children: s
1344
1345
  }
1345
1346
  );
1346
- }, ht = ({
1347
+ }, pt = ({
1347
1348
  children: t,
1348
1349
  onAuthenticated: s = null,
1349
1350
  onLoading: n = null
1350
1351
  }) => {
1351
1352
  const { isLoggedIn: o, loading: r } = de();
1352
1353
  return r ? n : o ? s : t;
1353
- }, pt = ({
1354
+ }, gt = ({
1354
1355
  children: t,
1355
1356
  onLoading: s = null,
1356
1357
  onUnauthenticated: n = null
@@ -1359,38 +1360,38 @@ const He = () => (Z || (Z = document.createElement("canvas"), R = Z.getContext("
1359
1360
  return r ? s : o ? t : n;
1360
1361
  };
1361
1362
  export {
1362
- tt as OxAvatar,
1363
+ st as OxAvatar,
1363
1364
  ye as OxAvatarImage,
1364
- st as OxAvatarText,
1365
+ rt as OxAvatarText,
1365
1366
  q as OxBadge,
1366
1367
  le as OxButton,
1367
- rt as OxCard,
1368
- ot as OxCardContent,
1369
- lt as OxCardFooter,
1370
- nt as OxCardHeader,
1371
- at as OxCheckbox,
1368
+ nt as OxCard,
1369
+ lt as OxCardContent,
1370
+ at as OxCardFooter,
1371
+ ot as OxCardHeader,
1372
+ it as OxCheckbox,
1372
1373
  se as OxDescription,
1373
1374
  We as OxDropdown,
1374
1375
  ue as OxDropdownContent,
1375
1376
  De as OxDropdownFooter,
1376
1377
  xe as OxDropdownHeader,
1377
1378
  Be as OxDropdownItem,
1378
- it as OxDropdownSeparator,
1379
- ct as OxDropdownShortcut,
1379
+ ct as OxDropdownSeparator,
1380
+ dt as OxDropdownShortcut,
1380
1381
  be as OxDropdownTrigger,
1381
1382
  re as OxErrorMessage,
1382
- wt as OxForm,
1383
- ht as OxGuestRoute,
1383
+ jt as OxForm,
1384
+ pt as OxGuestRoute,
1384
1385
  B as OxIcon,
1385
- jt as OxInput,
1386
+ yt as OxInput,
1386
1387
  te as OxLabel,
1387
- dt as OxNotificationDropdown,
1388
- pt as OxProtectedRoute,
1389
- ut as OxSelect,
1390
- xt as OxSelectLabel,
1388
+ ut as OxNotificationDropdown,
1389
+ gt as OxProtectedRoute,
1390
+ xt as OxSelect,
1391
+ mt as OxSelectLabel,
1391
1392
  Te as OxSelectOption,
1392
1393
  _e as OxSkeleton,
1393
- mt as OxSkeletonText,
1394
- ft as OxTextarea,
1395
- bt as OxTooltip
1394
+ ft as OxSkeletonText,
1395
+ bt as OxTextarea,
1396
+ ht as OxTooltip
1396
1397
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/jsx-runtime-CITbqOLs.js");require("react");const o=require("../chunks/Button-D-v4l8ZE.js"),n=require("../chunks/Input-CLi1H63d.js"),a=require("../chunks/useAuth-BTjqOcRK.js"),p=require("../chunks/useForm-DUviJ7xS.js"),g=require("../chunks/errorHelper-DaP_XxEx.js"),h=a.gql`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/jsx-runtime-CITbqOLs.js");require("react");const o=require("../chunks/Button-D-v4l8ZE.js"),n=require("../chunks/Input-CLi1H63d.js"),i=require("../chunks/AuthContext-uU1aP9gj.js"),p=require("../chunks/useForm-F8doF8lW.js"),g=require("../chunks/errorHelper-DbQKxxQA.js"),j=i.gql`
2
2
  mutation Login($input: LoginInput!) {
3
3
  login(input: $input) {
4
4
  success
@@ -10,4 +10,4 @@
10
10
  }
11
11
  }
12
12
  }
13
- `,j=({className:i,mutation:u=h,onSubmit:l,subtitle:d="",title:m="noxickon"})=>{const{setUser:x}=a.useOxAuth(),e=p.useForm({initialData:{username:"",password:""},validationRules:{username:["required"],password:["required"]},operation:u}),c=async t=>{t.preventDefault(),e.submit({onError:s=>{g.OxHandleGraphQLFormErrors(s,e)},onSuccess:s=>{s.data&&s.data.login.success?(x(s.data?s.data.login.me:null),l?.(s)):console.error("Something went wrong",s)}})};return r.jsxRuntimeExports.jsx("div",{className:o.twMerge("w-80",i),children:r.jsxRuntimeExports.jsxs("div",{className:"rounded-lg border border-neutral-700 bg-zinc-900/50 p-6 backdrop-blur-xl",children:[r.jsxRuntimeExports.jsxs("div",{className:"mb-4 text-center",children:[r.jsxRuntimeExports.jsx("h1",{className:"px-2 font-mono text-2xl text-white",children:m}),r.jsxRuntimeExports.jsx("p",{className:"px-2 py-1 font-mono text-xs text-neutral-400",children:d})]}),r.jsxRuntimeExports.jsxs(n.OxForm,{className:"space-y-6",onSubmit:c,children:[r.jsxRuntimeExports.jsx(n.OxInput,{autoComplete:"off",disabled:e.isLoading,error:e.hasError("username"),icon:"mdiAccount",label:"username",name:"username",placeholder:"Enter your username",required:!0,type:"text",value:e.data.username,onChange:t=>e.setData("username",t.target.value)}),r.jsxRuntimeExports.jsx(n.OxInput,{autoComplete:"off",disabled:e.isLoading,error:e.hasError("password"),icon:"mdiLockOutline",label:"password",name:"password",placeholder:"Enter your password",required:!0,type:"password",value:e.data.password,onChange:t=>e.setData("password",t.target.value)}),e.hasErrors&&r.jsxRuntimeExports.jsx(n.OxErrorMessage,{icon:"mdiAlertCircleOutline",children:"username or password is wrong"}),r.jsxRuntimeExports.jsx(o.OxButton,{disabled:e.isLoading,fullWidth:!0,isLoading:e.isLoading,size:"md",type:"submit",variant:"primary",children:e.isLoading?"Signing in...":"Sign In"})]})]})})};exports.OxLogin=j;
13
+ `,E=({cacheQuery:a=i.DEFAULT_GET_CURRENT_USER,className:u,mutation:l=j,onSubmit:d,subtitle:m="",title:x="noxickon"})=>{const e=p.useForm({initialData:{username:"",password:""},validationRules:{username:["required"],password:["required"]},operation:l,options:{update:(t,{data:s})=>{s?.login.success&&t.writeQuery({query:a,data:{me:s.login.me}})}}}),c=async t=>{t.preventDefault(),e.submit({onError:s=>{g.OxHandleGraphQLFormErrors(s,e)},onSuccess:s=>{s.data&&s.data.login.success?d?.(s):console.error("Login failed: Invalid credentials")}})};return r.jsxRuntimeExports.jsx("div",{className:o.twMerge("w-80",u),children:r.jsxRuntimeExports.jsxs("div",{className:"rounded-lg border border-neutral-700 bg-zinc-900/50 p-6 backdrop-blur-xl",children:[r.jsxRuntimeExports.jsxs("div",{className:"mb-4 text-center",children:[r.jsxRuntimeExports.jsx("h1",{className:"px-2 font-mono text-2xl text-white",children:x}),r.jsxRuntimeExports.jsx("p",{className:"px-2 py-1 font-mono text-xs text-neutral-400",children:m})]}),r.jsxRuntimeExports.jsxs(n.OxForm,{className:"space-y-6",onSubmit:c,children:[r.jsxRuntimeExports.jsx(n.OxInput,{autoComplete:"off",disabled:e.isLoading,error:e.hasError("username"),icon:"mdiAccount",label:"username",name:"username",placeholder:"Enter your username",required:!0,type:"text",value:e.data.username,onChange:t=>e.setData("username",t.target.value)}),r.jsxRuntimeExports.jsx(n.OxInput,{autoComplete:"off",disabled:e.isLoading,error:e.hasError("password"),icon:"mdiLockOutline",label:"password",name:"password",placeholder:"Enter your password",required:!0,type:"password",value:e.data.password,onChange:t=>e.setData("password",t.target.value)}),e.hasErrors&&r.jsxRuntimeExports.jsx(n.OxErrorMessage,{icon:"mdiAlertCircleOutline",children:"username or password is wrong"}),r.jsxRuntimeExports.jsx(o.OxButton,{disabled:e.isLoading,fullWidth:!0,isLoading:e.isLoading,size:"md",type:"submit",variant:"primary",children:e.isLoading?"Signing in...":"Sign In"})]})]})})};exports.OxLogin=E;
@@ -2,10 +2,10 @@ import { j as r } from "../chunks/jsx-runtime--oOP9f8K.js";
2
2
  import "react";
3
3
  import { t as c, O as p } from "../chunks/Button-bARrxYyo.js";
4
4
  import { O as x, a as o, b as g } from "../chunks/Input-dfvmdIHi.js";
5
- import { g as h, u as b } from "../chunks/useAuth-DDN3TSQr.js";
6
- import { u as f } from "../chunks/useForm-D4co95Vn.js";
7
- import { b as w } from "../chunks/errorHelper--G-SWQzN.js";
8
- const O = h`
5
+ import { g as h, D as f } from "../chunks/AuthContext-CaZKJMxQ.js";
6
+ import { u as b } from "../chunks/useForm-BuzPPZZE.js";
7
+ import { b as w } from "../chunks/errorHelper-qN6iGI6f.js";
8
+ const L = h`
9
9
  mutation Login($input: LoginInput!) {
10
10
  login(input: $input) {
11
11
  success
@@ -17,14 +17,15 @@ const O = h`
17
17
  }
18
18
  }
19
19
  }
20
- `, q = ({
21
- className: t,
22
- mutation: n = O,
23
- onSubmit: i,
24
- subtitle: d = "",
25
- title: l = "noxickon"
20
+ `, C = ({
21
+ cacheQuery: i = f,
22
+ className: n,
23
+ mutation: t = L,
24
+ onSubmit: d,
25
+ subtitle: l = "",
26
+ title: u = "noxickon"
26
27
  }) => {
27
- const { setUser: u } = b(), e = f({
28
+ const e = b({
28
29
  initialData: {
29
30
  username: "",
30
31
  password: ""
@@ -33,21 +34,29 @@ const O = h`
33
34
  username: ["required"],
34
35
  password: ["required"]
35
36
  },
36
- operation: n
37
- }), m = async (s) => {
38
- s.preventDefault(), e.submit({
39
- onError: (a) => {
40
- w(a, e);
37
+ operation: t,
38
+ options: {
39
+ update: (a, { data: s }) => {
40
+ s?.login.success && a.writeQuery({
41
+ query: i,
42
+ data: { me: s.login.me }
43
+ });
44
+ }
45
+ }
46
+ }), m = async (a) => {
47
+ a.preventDefault(), e.submit({
48
+ onError: (s) => {
49
+ w(s, e);
41
50
  },
42
- onSuccess: (a) => {
43
- a.data && a.data.login.success ? (u(a.data ? a.data.login.me : null), i?.(a)) : console.error("Something went wrong", a);
51
+ onSuccess: (s) => {
52
+ s.data && s.data.login.success ? d?.(s) : console.error("Login failed: Invalid credentials");
44
53
  }
45
54
  });
46
55
  };
47
- return /* @__PURE__ */ r.jsx("div", { className: c("w-80", t), children: /* @__PURE__ */ r.jsxs("div", { className: "rounded-lg border border-neutral-700 bg-zinc-900/50 p-6 backdrop-blur-xl", children: [
56
+ return /* @__PURE__ */ r.jsx("div", { className: c("w-80", n), children: /* @__PURE__ */ r.jsxs("div", { className: "rounded-lg border border-neutral-700 bg-zinc-900/50 p-6 backdrop-blur-xl", children: [
48
57
  /* @__PURE__ */ r.jsxs("div", { className: "mb-4 text-center", children: [
49
- /* @__PURE__ */ r.jsx("h1", { className: "px-2 font-mono text-2xl text-white", children: l }),
50
- /* @__PURE__ */ r.jsx("p", { className: "px-2 py-1 font-mono text-xs text-neutral-400", children: d })
58
+ /* @__PURE__ */ r.jsx("h1", { className: "px-2 font-mono text-2xl text-white", children: u }),
59
+ /* @__PURE__ */ r.jsx("p", { className: "px-2 py-1 font-mono text-xs text-neutral-400", children: l })
51
60
  ] }),
52
61
  /* @__PURE__ */ r.jsxs(x, { className: "space-y-6", onSubmit: m, children: [
53
62
  /* @__PURE__ */ r.jsx(
@@ -63,7 +72,7 @@ const O = h`
63
72
  required: !0,
64
73
  type: "text",
65
74
  value: e.data.username,
66
- onChange: (s) => e.setData("username", s.target.value)
75
+ onChange: (a) => e.setData("username", a.target.value)
67
76
  }
68
77
  ),
69
78
  /* @__PURE__ */ r.jsx(
@@ -79,7 +88,7 @@ const O = h`
79
88
  required: !0,
80
89
  type: "password",
81
90
  value: e.data.password,
82
- onChange: (s) => e.setData("password", s.target.value)
91
+ onChange: (a) => e.setData("password", a.target.value)
83
92
  }
84
93
  ),
85
94
  e.hasErrors && /* @__PURE__ */ r.jsx(g, { icon: "mdiAlertCircleOutline", children: "username or password is wrong" }),
@@ -99,5 +108,5 @@ const O = h`
99
108
  ] }) });
100
109
  };
101
110
  export {
102
- q as OxLogin
111
+ C as OxLogin
103
112
  };
package/dist/pages.d.ts CHANGED
@@ -4,6 +4,7 @@ import { DocumentNode } from 'graphql';
4
4
  export declare const OxLogin: default_2.FC<OxLoginProps>;
5
5
 
6
6
  export declare interface OxLoginProps {
7
+ cacheQuery?: DocumentNode;
7
8
  className?: string;
8
9
  mutation?: DocumentNode;
9
10
  onSubmit: (response: unknown) => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/formatTimestamp-TTsNcy7u.js"),r=require("../chunks/errorHelper-DaP_XxEx.js");exports.formatTimestamp=e.formatTimestamp;exports.OxHandleFormErrors=r.OxHandleFormErrors;exports.OxHandleGraphQLFormErrors=r.OxHandleGraphQLFormErrors;exports.OxParseGraphQLErrors=r.OxParseGraphQLErrors;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/formatTimestamp-TTsNcy7u.js"),r=require("../chunks/errorHelper-DbQKxxQA.js");exports.formatTimestamp=e.formatTimestamp;exports.OxHandleFormErrors=r.OxHandleFormErrors;exports.OxHandleGraphQLFormErrors=r.OxHandleGraphQLFormErrors;exports.OxParseGraphQLErrors=r.OxParseGraphQLErrors;
@@ -1,5 +1,5 @@
1
1
  import { f as o } from "../chunks/formatTimestamp-CMxOnPo1.js";
2
- import { a as m, b as e, O as p } from "../chunks/errorHelper--G-SWQzN.js";
2
+ import { a as m, b as e, O as p } from "../chunks/errorHelper-qN6iGI6f.js";
3
3
  export {
4
4
  m as OxHandleFormErrors,
5
5
  e as OxHandleGraphQLFormErrors,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noxickon/onyx",
3
- "version": "0.0.4-dev.6",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "readme": "./NPM_README.md",
6
6
  "main": "./dist/onyx.umd.js",