@objectstack/account 6.7.0 → 6.7.1
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.
|
@@ -114,5 +114,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
114
114
|
|
|
115
115
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
116
116
|
|
|
117
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Cw=`DialogDescriptionWarning`,ww=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xw(Cw).contentName}}.`;return j.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Tw=XC,Ew=nw,Dw=iw,Ow=cw,kw=pw,Aw=hw,jw=_w,Mw=Tw,Nw=Ew,Pw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Dw,{className:Z(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));Pw.displayName=Dw.displayName;var Fw=$v(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`}},defaultVariants:{side:`right`}}),Iw=j.forwardRef(({side:e=`right`,className:t,children:n,...r},i)=>(0,M.jsxs)(Nw,{children:[(0,M.jsx)(Pw,{}),(0,M.jsxs)(Ow,{ref:i,className:Z(Fw({side:e}),t),...r,children:[n,(0,M.jsxs)(jw,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,M.jsx)(eb,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Iw.displayName=Ow.displayName;var Lw=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});Lw.displayName=`SheetHeader`;var Rw=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Rw.displayName=`SheetFooter`;var zw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(kw,{ref:n,className:Z(`text-lg font-semibold text-foreground`,e),...t}));zw.displayName=kw.displayName;var Bw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Aw,{ref:n,className:Z(`text-sm text-muted-foreground`,e),...t}));Bw.displayName=Aw.displayName;function Vw({className:e,...t}){return(0,M.jsx)(`div`,{className:Z(`bg-muted animate-pulse rounded-md`,e),...t})}var Hw=[`top`,`right`,`bottom`,`left`],Uw=Math.min,Ww=Math.max,Gw=Math.round,Kw=Math.floor,qw=e=>({x:e,y:e}),Jw={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Yw(e,t,n){return Ww(e,Uw(t,n))}function Xw(e,t){return typeof e==`function`?e(t):e}function Zw(e){return e.split(`-`)[0]}function Qw(e){return e.split(`-`)[1]}function $w(e){return e===`x`?`y`:`x`}function eT(e){return e===`y`?`height`:`width`}function tT(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function nT(e){return $w(tT(e))}function rT(e,t,n){n===void 0&&(n=!1);let r=Qw(e),i=nT(e),a=eT(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=fT(o)),[o,fT(o)]}function iT(e){let t=fT(e);return[aT(e),t,aT(t)]}function aT(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var oT=[`left`,`right`],sT=[`right`,`left`],cT=[`top`,`bottom`],lT=[`bottom`,`top`];function uT(e,t,n){switch(e){case`top`:case`bottom`:return n?t?sT:oT:t?oT:sT;case`left`:case`right`:return t?cT:lT;default:return[]}}function dT(e,t,n,r){let i=Qw(e),a=uT(Zw(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(aT)))),a}function fT(e){let t=Zw(e);return Jw[t]+e.slice(t.length)}function pT(e){return{top:0,right:0,bottom:0,left:0,...e}}function mT(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:pT(e)}function hT(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function gT(e,t,n){let{reference:r,floating:i}=e,a=tT(t),o=nT(t),s=eT(o),c=Zw(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Qw(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function _T(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Xw(t,e),p=mT(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=hT(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=hT(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var vT=50,yT=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_T},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gT(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<vT&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=gT(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},bT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Xw(e,t)||{};if(l==null)return{};let d=mT(u),f={x:n,y:r},p=nT(i),m=eT(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Uw(d[_],T),D=Uw(d[v],T),O=E,ee=C-h[m]-D,te=C/2-h[m]/2+w,ne=Yw(O,te,ee),re=!c.arrow&&Qw(i)!=null&&te!==ne&&a.reference[m]/2-(te<O?E:D)-h[m]/2<0,ie=re?te<O?te-O:te-ee:0;return{[p]:f[p]+ie,data:{[p]:ne,centerOffset:te-ne-ie,...re&&{alignmentOffset:ie}},reset:re}}}),xT=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Xw(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Zw(r),_=tT(o),v=Zw(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[fT(o)]:iT(o)),x=p!==`none`;!d&&x&&b.push(...dT(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=rT(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==tT(t))||T.every(e=>tT(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=tT(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ST(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function CT(e){return Hw.some(t=>e[t]>=0)}var wT=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Xw(e,t);switch(i){case`referenceHidden`:{let e=ST(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:CT(e)}}}case`escaped`:{let e=ST(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:CT(e)}}}default:return{}}}}},TT=new Set([`left`,`top`]);async function ET(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Zw(n),s=Qw(n),c=tT(n)===`y`,l=TT.has(o)?-1:1,u=a&&c?-1:1,d=Xw(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var DT=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ET(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},OT=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Xw(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=tT(Zw(i)),p=$w(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Yw(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Yw(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},kT=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Xw(e,t),u={x:n,y:r},d=tT(i),f=$w(d),p=u[f],m=u[d],h=Xw(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=TT.has(Zw(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},AT=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Xw(e,t),u=await o.detectOverflow(t,l),d=Zw(i),f=Qw(i),p=tT(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Uw(h-u[g],v),x=Uw(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Ww(u.left,0),t=Ww(u.right,0),n=Ww(u.top,0),r=Ww(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Ww(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Ww(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function jT(){return typeof window<`u`}function MT(e){return FT(e)?(e.nodeName||``).toLowerCase():`#document`}function NT(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function PT(e){return((FT(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function FT(e){return jT()?e instanceof Node||e instanceof NT(e).Node:!1}function IT(e){return jT()?e instanceof Element||e instanceof NT(e).Element:!1}function LT(e){return jT()?e instanceof HTMLElement||e instanceof NT(e).HTMLElement:!1}function RT(e){return!jT()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof NT(e).ShadowRoot}function zT(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=XT(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function BT(e){return/^(table|td|th)$/.test(MT(e))}function VT(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var HT=/transform|translate|scale|rotate|perspective|filter/,UT=/paint|layout|strict|content/,WT=e=>!!e&&e!==`none`,GT;function KT(e){let t=IT(e)?XT(e):e;return WT(t.transform)||WT(t.translate)||WT(t.scale)||WT(t.rotate)||WT(t.perspective)||!JT()&&(WT(t.backdropFilter)||WT(t.filter))||HT.test(t.willChange||``)||UT.test(t.contain||``)}function qT(e){let t=QT(e);for(;LT(t)&&!YT(t);){if(KT(t))return t;if(VT(t))return null;t=QT(t)}return null}function JT(){return GT??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),GT}function YT(e){return/^(html|body|#document)$/.test(MT(e))}function XT(e){return NT(e).getComputedStyle(e)}function ZT(e){return IT(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function QT(e){if(MT(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||RT(e)&&e.host||PT(e);return RT(t)?t.host:t}function $T(e){let t=QT(e);return YT(t)?e.ownerDocument?e.ownerDocument.body:e.body:LT(t)&&zT(t)?t:$T(t)}function eE(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$T(e),i=r===e.ownerDocument?.body,a=NT(r);if(i){let e=tE(a);return t.concat(a,a.visualViewport||[],zT(r)?r:[],e&&n?eE(e):[])}else return t.concat(r,eE(r,[],n))}function tE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nE(e){let t=XT(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=LT(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Gw(n)!==a||Gw(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function rE(e){return IT(e)?e:e.contextElement}function iE(e){let t=rE(e);if(!LT(t))return qw(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=nE(t),o=(a?Gw(n.width):n.width)/r,s=(a?Gw(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var aE=qw(0);function oE(e){let t=NT(e);return!JT()||!t.visualViewport?aE:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sE(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==NT(e)?!1:t}function cE(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=rE(e),o=qw(1);t&&(r?IT(r)&&(o=iE(r)):o=iE(e));let s=sE(a,n,r)?oE(a):qw(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=NT(a),t=r&&IT(r)?NT(r):r,n=e,i=tE(n);for(;i&&r&&t!==n;){let e=iE(i),t=i.getBoundingClientRect(),r=XT(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=NT(i),i=tE(n)}}return hT({width:u,height:d,x:c,y:l})}function lE(e,t){let n=ZT(e).scrollLeft;return t?t.left+n:cE(PT(e)).left+n}function uE(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-lE(e,n),y:n.top+t.scrollTop}}function dE(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=PT(r),s=t?VT(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qw(1),u=qw(0),d=LT(r);if((d||!d&&!a)&&((MT(r)!==`body`||zT(o))&&(c=ZT(r)),d)){let e=cE(r);l=iE(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?uE(o,c):qw(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function fE(e){return Array.from(e.getClientRects())}function pE(e){let t=PT(e),n=ZT(e),r=e.ownerDocument.body,i=Ww(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ww(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+lE(e),s=-n.scrollTop;return XT(r).direction===`rtl`&&(o+=Ww(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var mE=25;function hE(e,t){let n=NT(e),r=PT(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=JT();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=lE(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=mE&&(a-=o)}else l<=mE&&(a+=l);return{width:a,height:o,x:s,y:c}}function gE(e,t){let n=cE(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=LT(e)?iE(e):qw(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _E(e,t,n){let r;if(t===`viewport`)r=hE(e,n);else if(t===`document`)r=pE(PT(e));else if(IT(t))r=gE(t,n);else{let n=oE(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return hT(r)}function vE(e,t){let n=QT(e);return n===t||!IT(n)||YT(n)?!1:XT(n).position===`fixed`||vE(n,t)}function yE(e,t){let n=t.get(e);if(n)return n;let r=eE(e,[],!1).filter(e=>IT(e)&&MT(e)!==`body`),i=null,a=XT(e).position===`fixed`,o=a?QT(e):e;for(;IT(o)&&!YT(o);){let t=XT(o),n=KT(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||zT(o)&&!n&&vE(e,o))?r=r.filter(e=>e!==o):i=t,o=QT(o)}return t.set(e,r),r}function bE(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?VT(t)?[]:yE(t,this._c):[].concat(n),r],o=_E(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=_E(t,a[e],i);s=Ww(n.top,s),c=Uw(n.right,c),l=Uw(n.bottom,l),u=Ww(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function xE(e){let{width:t,height:n}=nE(e);return{width:t,height:n}}function SE(e,t,n){let r=LT(t),i=PT(t),a=n===`fixed`,o=cE(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=qw(0);function l(){c.x=lE(i)}if(r||!r&&!a)if((MT(t)!==`body`||zT(i))&&(s=ZT(t)),r){let e=cE(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?uE(i,s):qw(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function CE(e){return XT(e).position===`static`}function wE(e,t){if(!LT(e)||XT(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return PT(e)===n&&(n=n.ownerDocument.body),n}function TE(e,t){let n=NT(e);if(VT(e))return n;if(!LT(e)){let t=QT(e);for(;t&&!YT(t);){if(IT(t)&&!CE(t))return t;t=QT(t)}return n}let r=wE(e,t);for(;r&&BT(r)&&CE(r);)r=wE(r,t);return r&&YT(r)&&CE(r)&&!KT(r)?n:r||qT(e)||n}var EE=async function(e){let t=this.getOffsetParent||TE,n=this.getDimensions,r=await n(e.floating);return{reference:SE(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DE(e){return XT(e).direction===`rtl`}var OE={convertOffsetParentRelativeRectToViewportRelativeRect:dE,getDocumentElement:PT,getClippingRect:bE,getOffsetParent:TE,getElementRects:EE,getClientRects:fE,getDimensions:xE,getScale:iE,isElement:IT,isRTL:DE};function kE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function AE(e,t){let n=null,r,i=PT(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Kw(d),h=Kw(i.clientWidth-(u+f)),g=Kw(i.clientHeight-(d+p)),_=Kw(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ww(0,Uw(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!kE(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function jE(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=rE(e),u=i||a?[...l?eE(l):[],...t?eE(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?AE(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?cE(e):null;c&&g();function g(){let t=cE(e);h&&!kE(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ME=DT,NE=OT,PE=xT,FE=AT,IE=wT,LE=bT,RE=kT,zE=(e,t,n)=>{let r=new Map,i={platform:OE,...n},a={...i.platform,_c:r};return yT(e,t,{...i,platform:a})},BE=typeof document<`u`?j.useLayoutEffect:function(){};function VE(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!VE(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!VE(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function HE(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function UE(e,t){let n=HE(e);return Math.round(t*n)/n}function WE(e){let t=j.useRef(e);return BE(()=>{t.current=e}),t}function GE(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=j.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=j.useState(r);VE(f,r)||p(r);let[m,h]=j.useState(null),[g,_]=j.useState(null),v=j.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=j.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=j.useRef(null),C=j.useRef(null),w=j.useRef(u),T=c!=null,E=WE(c),D=WE(i),O=WE(l),ee=j.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),zE(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};te.current&&!VE(w.current,t)&&(w.current=t,Gi.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);BE(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=j.useRef(!1);BE(()=>(te.current=!0,()=>{te.current=!1}),[]),BE(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,ee);ee()}},[b,x,ee,E,T]);let ne=j.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),re=j.useMemo(()=>({reference:b,floating:x}),[b,x]),ie=j.useMemo(()=>{let e={position:n,left:0,top:0};if(!re.floating)return e;let t=UE(re.floating,u.x),r=UE(re.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...HE(re.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,re.floating,u.x,u.y]);return j.useMemo(()=>({...u,update:ee,refs:ne,elements:re,floatingStyles:ie}),[u,ee,ne,re,ie])}var KE=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:LE({element:r.current,padding:i}).fn(n):r?LE({element:r,padding:i}).fn(n):{}}}},qE=(e,t)=>{let n=ME(e);return{name:n.name,fn:n.fn,options:[e,t]}},JE=(e,t)=>{let n=NE(e);return{name:n.name,fn:n.fn,options:[e,t]}},YE=(e,t)=>({fn:RE(e).fn,options:[e,t]}),XE=(e,t)=>{let n=PE(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZE=(e,t)=>{let n=FE(e);return{name:n.name,fn:n.fn,options:[e,t]}},QE=(e,t)=>{let n=IE(e);return{name:n.name,fn:n.fn,options:[e,t]}},$E=(e,t)=>{let n=KE(e);return{name:n.name,fn:n.fn,options:[e,t]}},eD=`Arrow`,tD=j.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,M.jsx)(y_.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,M.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});tD.displayName=eD;var nD=tD;function rD(e){let[t,n]=j.useState(void 0);return R_(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var iD=`Popper`,[aD,oD]=l_(iD),[sD,cD]=aD(iD),lD=e=>{let{__scopePopper:t,children:n}=e,[r,i]=j.useState(null);return(0,M.jsx)(sD,{scope:t,anchor:r,onAnchorChange:i,children:n})};lD.displayName=iD;var uD=`PopperAnchor`,dD=j.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=cD(uD,n),o=j.useRef(null),s=s_(t,o),c=j.useRef(null);return j.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,M.jsx)(y_.div,{...i,ref:s})});dD.displayName=uD;var fD=`PopperContent`,[pD,mD]=aD(fD),hD=j.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=cD(fD,n),[_,v]=j.useState(null),y=s_(t,e=>v(e)),[b,x]=j.useState(null),S=rD(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,ee={padding:E,boundary:D.filter(yD),altBoundary:O},{refs:te,floatingStyles:ne,placement:re,isPositioned:ie,middlewareData:ae}=GE({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>jE(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[qE({mainAxis:i+w,alignmentAxis:o}),c&&JE({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?YE():void 0,...ee}),c&&XE({...ee}),ZE({...ee,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&$E({element:b,padding:s}),bD({arrowWidth:C,arrowHeight:w}),f&&QE({strategy:`referenceHidden`,...ee})]}),[oe,k]=xD(re),se=x_(m);R_(()=>{ie&&se?.()},[ie,se]);let ce=ae.arrow?.x,le=ae.arrow?.y,ue=ae.arrow?.centerOffset!==0,[A,de]=j.useState();return R_(()=>{_&&de(window.getComputedStyle(_).zIndex)},[_]),(0,M.jsx)(`div`,{ref:te.setFloating,"data-radix-popper-content-wrapper":``,style:{...ne,transform:ie?ne.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:A,"--radix-popper-transform-origin":[ae.transformOrigin?.x,ae.transformOrigin?.y].join(` `),...ae.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,M.jsx)(pD,{scope:n,placedSide:oe,onArrowChange:x,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,M.jsx)(y_.div,{"data-side":oe,"data-align":k,...h,ref:y,style:{...h.style,animation:ie?void 0:`none`}})})})});hD.displayName=fD;var gD=`PopperArrow`,_D={top:`bottom`,right:`left`,bottom:`top`,left:`right`},vD=j.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=mD(gD,n),a=_D[i.placedSide];return(0,M.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,M.jsx)(nD,{...r,ref:t,style:{...r.style,display:`block`}})})});vD.displayName=gD;function yD(e){return e!==null}var bD=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=xD(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function xD(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var SD=lD,CD=dD,wD=hD,TD=vD,[ED,DD]=l_(`Tooltip`,[oD]),OD=oD(),kD=`TooltipProvider`,AD=700,jD=`tooltip.open`,[MD,ND]=ED(kD),PD=e=>{let{__scopeTooltip:t,delayDuration:n=AD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,M.jsx)(MD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};PD.displayName=kD;var FD=`Tooltip`,[ID,LD]=ED(FD),RD=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ND(FD,e.__scopeTooltip),l=OD(t),[u,d]=j.useState(null),f=sS(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=q_({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(jD))):c.onClose(),a?.(e)},caller:FD}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,M.jsx)(SD,{...l,children:(0,M.jsx)(ID,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};RD.displayName=FD;var zD=`TooltipTrigger`,BD=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=LD(zD,n),a=ND(zD,n),o=OD(n),s=s_(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,M.jsx)(CD,{asChild:!0,...o,children:(0,M.jsx)(y_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:J(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:J(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:J(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:J(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:J(e.onBlur,i.onClose),onClick:J(e.onClick,i.onClose)})})});BD.displayName=zD;var VD=`TooltipPortal`,[HD,UD]=ED(VD,{forceMount:void 0}),WD=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=LD(VD,t);return(0,M.jsx)(HD,{scope:t,forceMount:n,children:(0,M.jsx)(H_,{present:n||a.open,children:(0,M.jsx)(B_,{asChild:!0,container:i,children:r})})})};WD.displayName=VD;var GD=`TooltipContent`,KD=j.forwardRef((e,t)=>{let n=UD(GD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=LD(GD,e.__scopeTooltip);return(0,M.jsx)(H_,{present:r||o.open,children:o.disableHoverableContent?(0,M.jsx)(ZD,{side:i,...a,ref:t}):(0,M.jsx)(qD,{side:i,...a,ref:t})})}),qD=j.forwardRef((e,t)=>{let n=LD(GD,e.__scopeTooltip),r=ND(GD,e.__scopeTooltip),i=j.useRef(null),a=s_(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=tO(r,eO(r,n.getBoundingClientRect())),a=nO(t.getBoundingClientRect());s(iO([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!rO(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,M.jsx)(ZD,{...e,ref:a})}),[JD,YD]=ED(FD,{isInside:!1}),XD=m_(`TooltipContent`),ZD=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=LD(GD,n),l=OD(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(jD,u),()=>document.removeEventListener(jD,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,M.jsx)(k_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,M.jsxs)(wD,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.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:[(0,M.jsx)(XD,{children:r}),(0,M.jsx)(JD,{scope:n,isInside:!0,children:(0,M.jsx)($_,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});KD.displayName=GD;var QD=`TooltipArrow`,$D=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=OD(n);return YD(QD,n).isInside?null:(0,M.jsx)(TD,{...i,...r,ref:t})});$D.displayName=QD;function eO(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function tO(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function nO(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function rO(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function iO(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),aO(t)}function aO(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var oO=PD,sO=RD,cO=BD,lO=KD,uO=oO,dO=sO,fO=cO,pO=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,M.jsx)(lO,{ref:r,sideOffset:t,className:Z(`z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));pO.displayName=lO.displayName;var mO=`sidebar_state`,hO=3600*24*7,gO=`16rem`,_O=`18rem`,vO=`3rem`,yO=`b`,bO=j.createContext(null);function xO(){let e=j.useContext(bO);if(!e)throw Error(`useSidebar must be used within a SidebarProvider`);return e}var SO=j.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o},s)=>{let c=Jx(),[l,u]=j.useState(!1),[d,f]=j.useState(e),p=t??d,m=j.useCallback(e=>{let t=typeof e==`function`?e(p):e;n?n(t):f(t),document.cookie=`${mO}=${t}; path=/; max-age=${hO}`},[n,p]),h=j.useCallback(()=>c?u(e=>!e):m(e=>!e),[c,m,u]);j.useEffect(()=>{let e=e=>{e.key===yO&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]);let g=p?`expanded`:`collapsed`,_=j.useMemo(()=>({state:g,open:p,setOpen:m,isMobile:c,openMobile:l,setOpenMobile:u,toggleSidebar:h}),[g,p,m,c,l,u,h]);return(0,M.jsx)(bO.Provider,{value:_,children:(0,M.jsx)(uO,{delayDuration:0,children:(0,M.jsx)(`div`,{style:{"--sidebar-width":gO,"--sidebar-width-icon":vO,...i},className:Z(`group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-0 w-full`,r),ref:s,...o,children:a})})})});SO.displayName=`SidebarProvider`;var CO=j.forwardRef(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a},o)=>{let{isMobile:s,state:c,openMobile:l,setOpenMobile:u}=xO();return n===`none`?(0,M.jsx)(`div`,{className:Z(`bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col`,r),ref:o,...a,children:i}):s?(0,M.jsx)(Mw,{open:l,onOpenChange:u,...a,children:(0,M.jsx)(Iw,{"data-sidebar":`sidebar`,"data-mobile":`true`,className:`bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden`,style:{"--sidebar-width":_O},side:e,children:(0,M.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})})}):(0,M.jsx)(`div`,{ref:o,className:Z(`bg-sidebar text-sidebar-foreground hidden md:flex h-svh w-[var(--sidebar-width)] shrink-0 flex-col border-r transition-[width] duration-200 ease-linear overflow-hidden`,c===`collapsed`&&n===`offcanvas`&&`w-0 border-0`,c===`collapsed`&&n===`icon`&&`w-[var(--sidebar-width-icon)]`,r),"data-state":c,"data-collapsible":c===`collapsed`?n:``,"data-variant":t,"data-side":e,...a,children:i})});CO.displayName=`Sidebar`;var wO=j.forwardRef(({className:e,onClick:t,...n},r)=>{let{toggleSidebar:i}=xO();return(0,M.jsxs)(Q,{ref:r,"data-sidebar":`trigger`,variant:`ghost`,size:`icon`,className:Z(`h-7 w-7`,e),onClick:e=>{t?.(e),i()},...n,children:[(0,M.jsx)(Iy,{}),(0,M.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})});wO.displayName=`SidebarTrigger`;var TO=j.forwardRef(({className:e,...t},n)=>{let{toggleSidebar:r}=xO();return(0,M.jsx)(`button`,{ref:n,"data-sidebar":`rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:r,title:`Toggle Sidebar`,className:Z(`hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex`,`[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...t})});TO.displayName=`SidebarRail`;var EO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`main`,{ref:n,className:Z(`relative flex min-h-svh flex-1 flex-col bg-background`,`peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow`,e),...t}));EO.displayName=`SidebarInset`;var DO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Xx,{ref:n,"data-sidebar":`input`,className:Z(`h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,e),...t}));DO.displayName=`SidebarInput`;var OO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`header`,className:Z(`flex flex-col gap-2 p-2`,e),...t}));OO.displayName=`SidebarHeader`;var kO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`footer`,className:Z(`flex flex-col gap-2 p-2`,e),...t}));kO.displayName=`SidebarFooter`;var AO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(iS,{ref:n,"data-sidebar":`separator`,className:Z(`mx-2 w-auto bg-sidebar-border`,e),...t}));AO.displayName=`SidebarSeparator`;var jO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`content`,className:Z(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto`,e),...t}));jO.displayName=`SidebarContent`;var MO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`group`,className:Z(`relative flex w-full min-w-0 flex-col p-2`,e),...t}));MO.displayName=`SidebarGroup`;var NO=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,M.jsx)(t?Vx:`div`,{ref:r,"data-sidebar":`group-label`,className:Z(`text-xs/6 font-medium text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 outline-none transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 [[data-collapsible=icon]_&]:-mt-8 [[data-collapsible=icon]_&]:opacity-0 [[data-collapsible=icon]_&]:overflow-hidden`,e),...n}));NO.displayName=`SidebarGroupLabel`;var PO=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,M.jsx)(t?Vx:`button`,{ref:r,"data-sidebar":`group-action`,className:Z(`absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:md:hidden`,`group-data-[collapsible=icon]:hidden`,e),...n}));PO.displayName=`SidebarGroupAction`;var FO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`group-content`,className:Z(`w-full text-sm`,e),...t}));FO.displayName=`SidebarGroupContent`;var IO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ul`,{ref:n,"data-sidebar":`menu`,className:Z(`flex w-full min-w-0 flex-col gap-1`,e),...t}));IO.displayName=`SidebarMenu`;var LO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`li`,{ref:n,"data-sidebar":`menu-item`,className:Z(`group/menu-item relative`,e),...t}));LO.displayName=`SidebarMenuItem`;var RO=j.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o},s)=>{let c=e?Vx:`button`,{isMobile:l,state:u}=xO(),d=(0,M.jsx)(c,{ref:s,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:Z(zO({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,M.jsxs)(dO,{children:[(0,M.jsx)(fO,{asChild:!0,children:d}),(0,M.jsx)(pO,{side:`right`,align:`center`,hidden:u!==`collapsed`||l,...i})]})):d});RO.displayName=`SidebarMenuButton`;var zO=$v(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:!p-0`}},defaultVariants:{variant:`default`,size:`default`}}),BO=j.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>(0,M.jsx)(t?Vx:`button`,{ref:i,"data-sidebar":`menu-action`,className:Z(`absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:md:hidden`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0`,e),...r}));BO.displayName=`SidebarMenuAction`;var VO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`menu-badge`,className:Z(`text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));VO.displayName=`SidebarMenuBadge`;var HO=j.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{let i=j.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return(0,M.jsxs)(`div`,{ref:r,"data-sidebar":`menu-skeleton`,className:Z(`rounded-md h-8 flex gap-2 px-2 items-center`,e),...n,children:[t&&(0,M.jsx)(Vw,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),(0,M.jsx)(Vw,{className:`h-4 flex-1 max-w-[var(--skeleton-width)]`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":i}})]})});HO.displayName=`SidebarMenuSkeleton`;var UO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ul`,{ref:n,"data-sidebar":`menu-sub`,className:Z(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));UO.displayName=`SidebarMenuSub`;var WO=j.forwardRef(({...e},t)=>(0,M.jsx)(`li`,{ref:t,...e}));WO.displayName=`SidebarMenuSubItem`;var GO=j.forwardRef(({asChild:e=!1,size:t=`md`,isActive:n,className:r,...i},a)=>(0,M.jsx)(e?Vx:`a`,{ref:a,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:Z(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,r),...i}));GO.displayName=`SidebarMenuSubButton`;var KO=$v(`text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5`),qO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`nav`,{ref:n,"aria-label":`breadcrumb`,className:Z(KO(),e),...t}));qO.displayName=`Breadcrumb`;var JO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ol`,{ref:n,className:Z(`text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5`,e),...t}));JO.displayName=`BreadcrumbList`;var YO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`li`,{ref:n,className:Z(`inline-flex items-center gap-1.5`,e),...t}));YO.displayName=`BreadcrumbItem`;var XO=j.forwardRef(({asChild:e,className:t,...n},r)=>(0,M.jsx)(e?Vx:`a`,{ref:r,className:Z(`hover:text-foreground transition-colors`,t),...n}));XO.displayName=`BreadcrumbLink`;var ZO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`span`,{ref:n,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:Z(`text-foreground font-normal`,e),...t}));ZO.displayName=`BreadcrumbPage`;var QO=({children:e,className:t,...n})=>(0,M.jsx)(`li`,{role:`presentation`,"aria-hidden":`true`,className:Z(`[&>svg]:size-3.5`,t),...n,children:e??(0,M.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,M.jsx)(`path`,{d:`m9 18 6-6-6-6`})})});QO.displayName=`BreadcrumbSeparator`;var $O=({className:e,...t})=>(0,M.jsxs)(`span`,{role:`presentation`,"aria-hidden":`true`,className:Z(`flex h-9 w-9 items-center justify-center`,e),...t,children:[(0,M.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:[(0,M.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,M.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1`}),(0,M.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1`})]}),(0,M.jsx)(`span`,{className:`sr-only`,children:`More`})]});$O.displayName=`BreadcrumbElipssis`;var ek=j.createContext(void 0);function tk(e){let t=j.useContext(ek);return e||t||`ltr`}var nk=`rovingFocusGroup.onEntryFocus`,rk={bubbles:!1,cancelable:!0},ik=`RovingFocusGroup`,[ak,ok,sk]=v_(ik),[ck,lk]=l_(ik,[sk]),[uk,dk]=ck(ik),fk=j.forwardRef((e,t)=>(0,M.jsx)(ak.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(ak.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(pk,{...e,ref:t})})}));fk.displayName=ik;var pk=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=j.useRef(null),p=s_(t,f),m=tk(a),[h,g]=q_({prop:o,defaultProp:s??null,onChange:c,caller:ik}),[_,v]=j.useState(!1),y=x_(l),b=ok(n),x=j.useRef(!1),[S,C]=j.useState(0);return j.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(nk,y),()=>e.removeEventListener(nk,y)},[y]),(0,M.jsx)(uk,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:j.useCallback(e=>g(e),[g]),onItemShiftTab:j.useCallback(()=>v(!0),[]),onFocusableItemAdd:j.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:j.useCallback(()=>C(e=>e-1),[]),children:(0,M.jsx)(y_.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{x.current=!0}),onFocus:J(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(nk,rk);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);yk([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:J(e.onBlur,()=>v(!1))})})}),mk=`RovingFocusGroupItem`,hk=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=sS(),l=a||c,u=dk(mk,n),d=u.currentTabStopId===l,f=ok(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return j.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,M.jsx)(ak.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,M.jsx)(y_.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=vk(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?bk(n,r+1):n.slice(r+1)}setTimeout(()=>yk(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});hk.displayName=mk;var gk={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function _k(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function vk(e,t,n){let r=_k(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return gk[r]}function yk(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function bk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xk=fk,Sk=hk,Ck=[`Enter`,` `],wk=[`ArrowDown`,`PageUp`,`Home`],Tk=[`ArrowUp`,`PageDown`,`End`],Ek=[...wk,...Tk],Dk={ltr:[...Ck,`ArrowRight`],rtl:[...Ck,`ArrowLeft`]},Ok={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},kk=`Menu`,[Ak,jk,Mk]=v_(kk),[Nk,Pk]=l_(kk,[Mk,oD,lk]),Fk=oD(),Ik=lk(),[Lk,Rk]=Nk(kk),[zk,Bk]=Nk(kk),Vk=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Fk(t),[c,l]=j.useState(null),u=j.useRef(!1),d=x_(a),f=tk(i);return j.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,M.jsx)(SD,{...s,children:(0,M.jsx)(Lk,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,M.jsx)(zk,{scope:t,onClose:j.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Vk.displayName=kk;var Hk=`MenuAnchor`,Uk=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Fk(n);return(0,M.jsx)(CD,{...i,...r,ref:t})});Uk.displayName=Hk;var Wk=`MenuPortal`,[Gk,Kk]=Nk(Wk,{forceMount:void 0}),qk=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Rk(Wk,t);return(0,M.jsx)(Gk,{scope:t,forceMount:n,children:(0,M.jsx)(H_,{present:n||a.open,children:(0,M.jsx)(B_,{asChild:!0,container:i,children:r})})})};qk.displayName=Wk;var Jk=`MenuContent`,[Yk,Xk]=Nk(Jk),Zk=j.forwardRef((e,t)=>{let n=Kk(Jk,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Rk(Jk,e.__scopeMenu),o=Bk(Jk,e.__scopeMenu);return(0,M.jsx)(Ak.Provider,{scope:e.__scopeMenu,children:(0,M.jsx)(H_,{present:r||a.open,children:(0,M.jsx)(Ak.Slot,{scope:e.__scopeMenu,children:o.modal?(0,M.jsx)(Qk,{...i,ref:t}):(0,M.jsx)($k,{...i,ref:t})})})})}),Qk=j.forwardRef((e,t)=>{let n=Rk(Jk,e.__scopeMenu),r=j.useRef(null),i=s_(t,r);return j.useEffect(()=>{let e=r.current;if(e)return WC(e)},[]),(0,M.jsx)(tA,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$k=j.forwardRef((e,t)=>{let n=Rk(Jk,e.__scopeMenu);return(0,M.jsx)(tA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),eA=d_(`MenuContent.ScrollLock`),tA=j.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Rk(Jk,n),_=Bk(Jk,n),v=Fk(n),y=Ik(n),b=jk(n),[x,S]=j.useState(null),C=j.useRef(null),w=s_(t,C,g.onContentChange),T=j.useRef(0),E=j.useRef(``),D=j.useRef(0),O=j.useRef(null),ee=j.useRef(`right`),te=j.useRef(0),ne=m?FC:j.Fragment,re=m?{as:eA,allowPinchZoom:!0}:void 0,ie=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=zA(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};j.useEffect(()=>()=>window.clearTimeout(T.current),[]),TS();let ae=j.useCallback(e=>ee.current===O.current?.side&&VA(e,O.current?.area),[]);return(0,M.jsx)(Yk,{scope:n,searchRef:E,onItemEnter:j.useCallback(e=>{ae(e)&&e.preventDefault()},[ae]),onItemLeave:j.useCallback(e=>{ae(e)||(C.current?.focus(),S(null))},[ae]),onTriggerLeave:j.useCallback(e=>{ae(e)&&e.preventDefault()},[ae]),pointerGraceTimerRef:D,onPointerGraceIntentChange:j.useCallback(e=>{O.current=e},[]),children:(0,M.jsx)(ne,{...re,children:(0,M.jsx)(fS,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,M.jsx)(k_,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,M.jsx)(xk,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,M.jsx)(wD,{role:`menu`,"aria-orientation":`vertical`,"data-state":PA(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ie(e.key));let i=C.current;if(e.target!==i||!Ek.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Tk.includes(e.key)&&a.reverse(),LA(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:J(e.onPointerMove,HA(e=>{let t=e.target,n=te.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ee.current=e.clientX>te.current?`right`:`left`,te.current=e.clientX)}))})})})})})})});Zk.displayName=Jk;var nA=`MenuGroup`,rA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{role:`group`,...r,ref:t})});rA.displayName=nA;var iA=`MenuLabel`,aA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{...r,ref:t})});aA.displayName=iA;var oA=`MenuItem`,sA=`menu.itemSelect`,cA=j.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=j.useRef(null),o=Bk(oA,e.__scopeMenu),s=Xk(oA,e.__scopeMenu),c=s_(t,a),l=j.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(sA,{bubbles:!0,cancelable:!0});e.addEventListener(sA,e=>r?.(e),{once:!0}),b_(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,M.jsx)(lA,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Ck.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});cA.displayName=oA;var lA=j.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Xk(oA,n),s=Ik(n),c=j.useRef(null),l=s_(t,c),[u,d]=j.useState(!1),[f,p]=j.useState(``);return j.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,M.jsx)(Ak.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,M.jsx)(Sk,{asChild:!0,...s,focusable:!r,children:(0,M.jsx)(y_.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,HA(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,HA(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})}),uA=`MenuCheckboxItem`,dA=j.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,M.jsx)(yA,{scope:e.__scopeMenu,checked:n,children:(0,M.jsx)(cA,{role:`menuitemcheckbox`,"aria-checked":FA(n)?`mixed`:n,...i,ref:t,"data-state":IA(n),onSelect:J(i.onSelect,()=>r?.(FA(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dA.displayName=uA;var fA=`MenuRadioGroup`,[pA,mA]=Nk(fA,{value:void 0,onValueChange:()=>{}}),hA=j.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=x_(r);return(0,M.jsx)(pA,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,M.jsx)(rA,{...i,ref:t})})});hA.displayName=fA;var gA=`MenuRadioItem`,_A=j.forwardRef((e,t)=>{let{value:n,...r}=e,i=mA(gA,e.__scopeMenu),a=n===i.value;return(0,M.jsx)(yA,{scope:e.__scopeMenu,checked:a,children:(0,M.jsx)(cA,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":IA(a),onSelect:J(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});_A.displayName=gA;var vA=`MenuItemIndicator`,[yA,bA]=Nk(vA,{checked:!1}),xA=j.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=bA(vA,n);return(0,M.jsx)(H_,{present:r||FA(a.checked)||a.checked===!0,children:(0,M.jsx)(y_.span,{...i,ref:t,"data-state":IA(a.checked)})})});xA.displayName=vA;var SA=`MenuSeparator`,CA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});CA.displayName=SA;var wA=`MenuArrow`,TA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Fk(n);return(0,M.jsx)(TD,{...i,...r,ref:t})});TA.displayName=wA;var EA=`MenuSub`,[DA,OA]=Nk(EA),kA=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Rk(EA,t),o=Fk(t),[s,c]=j.useState(null),[l,u]=j.useState(null),d=x_(i);return j.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,M.jsx)(SD,{...o,children:(0,M.jsx)(Lk,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,M.jsx)(DA,{scope:t,contentId:sS(),triggerId:sS(),trigger:s,onTriggerChange:c,children:n})})})};kA.displayName=EA;var AA=`MenuSubTrigger`,jA=j.forwardRef((e,t)=>{let n=Rk(AA,e.__scopeMenu),r=Bk(AA,e.__scopeMenu),i=OA(AA,e.__scopeMenu),a=Xk(AA,e.__scopeMenu),o=j.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=j.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return j.useEffect(()=>u,[u]),j.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,M.jsx)(Uk,{asChild:!0,...l,children:(0,M.jsx)(lA,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":PA(n.open),...e,ref:o_(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:J(e.onPointerMove,HA(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:J(e.onPointerLeave,HA(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:J(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Dk[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});jA.displayName=AA;var MA=`MenuSubContent`,NA=j.forwardRef((e,t)=>{let n=Kk(Jk,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Rk(Jk,e.__scopeMenu),o=Bk(Jk,e.__scopeMenu),s=OA(MA,e.__scopeMenu),c=j.useRef(null),l=s_(t,c);return(0,M.jsx)(Ak.Provider,{scope:e.__scopeMenu,children:(0,M.jsx)(H_,{present:r||a.open,children:(0,M.jsx)(Ak.Slot,{scope:e.__scopeMenu,children:(0,M.jsx)(tA,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:J(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:J(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:J(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Ok[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});NA.displayName=MA;function PA(e){return e?`open`:`closed`}function FA(e){return e===`indeterminate`}function IA(e){return FA(e)?`indeterminate`:e?`checked`:`unchecked`}function LA(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function RA(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function zA(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=RA(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function BA(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function VA(e,t){return t?BA({x:e.clientX,y:e.clientY},t):!1}function HA(e){return t=>t.pointerType===`mouse`?e(t):void 0}var UA=Vk,WA=Uk,GA=qk,KA=Zk,qA=rA,JA=aA,YA=cA,XA=dA,ZA=hA,QA=_A,$A=xA,ej=CA,tj=TA,nj=jA,rj=NA,ij=`DropdownMenu`,[aj,oj]=l_(ij,[Pk]),sj=Pk(),[cj,lj]=aj(ij),uj=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=sj(t),l=j.useRef(null),[u,d]=q_({prop:i,defaultProp:a??!1,onChange:o,caller:ij});return(0,M.jsx)(cj,{scope:t,triggerId:sS(),triggerRef:l,contentId:sS(),open:u,onOpenChange:d,onOpenToggle:j.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,M.jsx)(UA,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};uj.displayName=ij;var dj=`DropdownMenuTrigger`,fj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=lj(dj,n),o=sj(n);return(0,M.jsx)(WA,{asChild:!0,...o,children:(0,M.jsx)(y_.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:o_(t,a.triggerRef),onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fj.displayName=dj;var pj=`DropdownMenuPortal`,mj=e=>{let{__scopeDropdownMenu:t,...n}=e,r=sj(t);return(0,M.jsx)(GA,{...r,...n})};mj.displayName=pj;var hj=`DropdownMenuContent`,gj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=lj(hj,n),a=sj(n),o=j.useRef(!1);return(0,M.jsx)(KA,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gj.displayName=hj;var _j=`DropdownMenuGroup`,vj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(qA,{...i,...r,ref:t})});vj.displayName=_j;var yj=`DropdownMenuLabel`,bj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(JA,{...i,...r,ref:t})});bj.displayName=yj;var xj=`DropdownMenuItem`,Sj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(YA,{...i,...r,ref:t})});Sj.displayName=xj;var Cj=`DropdownMenuCheckboxItem`,wj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(XA,{...i,...r,ref:t})});wj.displayName=Cj;var Tj=`DropdownMenuRadioGroup`,Ej=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(ZA,{...i,...r,ref:t})});Ej.displayName=Tj;var Dj=`DropdownMenuRadioItem`,Oj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(QA,{...i,...r,ref:t})});Oj.displayName=Dj;var kj=`DropdownMenuItemIndicator`,Aj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)($A,{...i,...r,ref:t})});Aj.displayName=kj;var jj=`DropdownMenuSeparator`,Mj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(ej,{...i,...r,ref:t})});Mj.displayName=jj;var Nj=`DropdownMenuArrow`,Pj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(tj,{...i,...r,ref:t})});Pj.displayName=Nj;var Fj=`DropdownMenuSubTrigger`,Ij=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(nj,{...i,...r,ref:t})});Ij.displayName=Fj;var Lj=`DropdownMenuSubContent`,Rj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(rj,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rj.displayName=Lj;var zj=uj,Bj=fj,Vj=mj,Hj=gj,Uj=bj,Wj=Sj,Gj=wj,Kj=Oj,qj=Aj,Jj=Mj,Yj=Ij,Xj=Rj,Zj=zj,Qj=Bj,$j=j.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,M.jsxs)(Yj,{ref:i,className:Z(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,M.jsx)(my,{className:`ml-auto`})]}));$j.displayName=Yj.displayName;var eM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Xj,{ref:n,className:Z(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));eM.displayName=Xj.displayName;var tM=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,M.jsx)(Vj,{children:(0,M.jsx)(Hj,{ref:r,sideOffset:t,className:Z(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tM.displayName=Hj.displayName;var nM=j.forwardRef(({className:e,inset:t,...n},r)=>(0,M.jsx)(Wj,{ref:r,className:Z(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));nM.displayName=Wj.displayName;var rM=j.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,M.jsxs)(Gj,{ref:i,className:Z(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,M.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,M.jsx)(qj,{children:(0,M.jsx)(fy,{className:`h-4 w-4`})})}),t]}));rM.displayName=Gj.displayName;var iM=j.forwardRef(({className:e,children:t,...n},r)=>(0,M.jsxs)(Kj,{ref:r,className:Z(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,M.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,M.jsx)(qj,{children:(0,M.jsx)(by,{className:`h-2 w-2 fill-current`})})}),t]}));iM.displayName=Kj.displayName;var aM=j.forwardRef(({className:e,inset:t,...n},r)=>(0,M.jsx)(Uj,{ref:r,className:Z(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));aM.displayName=Uj.displayName;var oM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Jj,{ref:n,className:Z(`-mx-1 my-1 h-px bg-muted`,e),...t}));oM.displayName=Jj.displayName;var sM=({className:e,...t})=>(0,M.jsx)(`span`,{className:Z(`ml-auto text-xs tracking-widest opacity-60`,e),...t});sM.displayName=`DropdownMenuShortcut`;var cM=`modulepreload`,lM=function(e){return`/_account/`+e},uM={},dM=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=lM(t,n),t in uM)return;uM[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:cM,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fM=[`en`,`zh-CN`],pM={en:()=>dM(()=>import(`./en-BM3I2v7J.js`),[]),"zh-CN":()=>dM(()=>import(`./zh-CN-f2PfHJHM.js`),[])};function mM(e){return fM.includes(e)?e:e.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}async function hM(e){let t=mM(e);try{return(await pM[t]()).default}catch(t){return console.warn(`[account/i18n] Failed to load language pack '${e}':`,t),{}}}var gM={en:`English`,"zh-CN":`中文`};function _M(){let{t:e,language:t,changeLanguage:n}=vt();async function r(e){await n(e);try{localStorage.setItem(`account.lang`,e)}catch{}}return(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":e(`common.language`),children:[(0,M.jsx)(ky,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{className:`sr-only`,children:e(`common.language`)})]})}),(0,M.jsx)(tM,{align:`end`,children:fM.map(e=>(0,M.jsx)(nM,{onSelect:()=>void r(e),className:e===t?`font-medium`:void 0,children:gM[e]},e))})]})}function vM(e){let t=document.documentElement;e===`dark`?t.classList.add(`dark`):t.classList.remove(`dark`)}function yM(){let{t:e}=vt(),[,t]=(0,j.useState)(`light`);(0,j.useEffect)(()=>{let e=localStorage.getItem(`theme`);e?(t(e),vM(e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e)):(t(`system`),vM(window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`))},[]);function n(e){t(e),localStorage.setItem(`theme`,e),vM(e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e)}return(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,M.jsx)(Wy,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),(0,M.jsx)(Fy,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),(0,M.jsx)(`span`,{className:`sr-only`,children:e(`common.toggleTheme`)})]})}),(0,M.jsxs)(tM,{align:`end`,children:[(0,M.jsxs)(nM,{onClick:()=>n(`light`),children:[(0,M.jsx)(Wy,{className:`mr-2 h-4 w-4`}),e(`common.light`)]}),(0,M.jsxs)(nM,{onClick:()=>n(`dark`),children:[(0,M.jsx)(Fy,{className:`mr-2 h-4 w-4`}),e(`common.dark`)]}),(0,M.jsx)(nM,{onClick:()=>n(`system`),children:e(`common.system`)})]})]})}function bM(e,t=[]){let n=[];function r(t,r){let i=j.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=j.useMemo(()=>o,Object.values(o));return(0,M.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=j.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>j.createContext(e));return function(n){let r=n?.[e]||t;return j.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,xM(i,...t)]}function xM(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function SM(){return(0,ot.useSyncExternalStore)(CM,()=>!0,()=>!1)}function CM(){return()=>{}}var wM=`Avatar`,[TM,EM]=bM(wM),[DM,OM]=TM(wM),kM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,...r}=e,[i,a]=j.useState(`idle`);return(0,M.jsx)(DM,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:a,children:(0,M.jsx)(Zx.span,{...r,ref:t})})});kM.displayName=wM;var AM=`AvatarImage`,jM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,src:r,onLoadingStatusChange:i=()=>{},...a}=e,o=OM(AM,n),s=FM(r,a),c=x_(e=>{i(e),o.onImageLoadingStatusChange(e)});return R_(()=>{s!==`idle`&&c(s)},[s,c]),s===`loaded`?(0,M.jsx)(Zx.img,{...a,ref:t,src:r}):null});jM.displayName=AM;var MM=`AvatarFallback`,NM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,delayMs:r,...i}=e,a=OM(MM,n),[o,s]=j.useState(r===void 0);return j.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,M.jsx)(Zx.span,{...i,ref:t}):null});NM.displayName=MM;function PM(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?`loaded`:`loading`):`error`:`idle`}function FM(e,{referrerPolicy:t,crossOrigin:n}){let r=SM(),i=j.useRef(null),a=r?(i.current||=new window.Image,i.current):null,[o,s]=j.useState(()=>PM(a,e));return R_(()=>{s(PM(a,e))},[a,e]),R_(()=>{let e=e=>()=>{s(e)};if(!a)return;let r=e(`loaded`),i=e(`error`);return a.addEventListener(`load`,r),a.addEventListener(`error`,i),t&&(a.referrerPolicy=t),typeof n==`string`&&(a.crossOrigin=n),()=>{a.removeEventListener(`load`,r),a.removeEventListener(`error`,i)}},[a,n,t]),o}var IM=kM,LM=jM,RM=NM,zM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(IM,{ref:n,className:Z(`relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...t}));zM.displayName=IM.displayName;var BM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(LM,{ref:n,className:Z(`aspect-square h-full w-full`,e),...t}));BM.displayName=LM.displayName;var VM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(RM,{ref:n,className:Z(`flex h-full w-full items-center justify-center rounded-full bg-muted`,e),...t}));VM.displayName=RM.displayName;var HM=(0,j.createContext)(null),UM=`auth-session-token`,WM=`auth-active-organization-id`;function GM(e){if(!(typeof window>`u`))try{e?.token?localStorage.setItem(UM,e.token):localStorage.removeItem(UM),e?.activeOrganizationId?localStorage.setItem(WM,e.activeOrganizationId):localStorage.removeItem(WM)}catch{}}function KM(e){if(!e)return{user:null,session:null};let t=e.data===void 0?e:e.data;return t?{user:t.user??null,session:t.session??null}:{user:null,session:null}}function qM({children:e}){let t=qg(),[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)([]),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(!1),g=(0,j.useCallback)(async()=>{if(t?.organizations){p(!0);try{d((await t.organizations.list())?.organizations??[])}catch{d([])}finally{p(!1),h(!0)}}},[t]),_=(0,j.useCallback)(async()=>{if(t?.auth){s(!0),l(null);try{let{user:e,session:n}=KM(await t.auth.me());r(e),a(n),GM(e?n:null)}catch(e){l(e),r(null),a(null),GM(null)}finally{s(!1)}}},[t]);(0,j.useEffect)(()=>{_()},[_]),(0,j.useEffect)(()=>{n?g():(d([]),h(!1))},[n,g]);let v=(0,j.useCallback)(async()=>{if(t?.auth)try{await t.auth.logout()}finally{r(null),a(null),d([]),h(!1),GM(null)}},[t]),y=(0,j.useCallback)(async e=>{if(t?.organizations){await t.organizations.setActive(e),await _();try{localStorage.setItem(WM,e)}catch{}}},[t,_]),b=(0,j.useMemo)(()=>({user:n,session:i,loading:o,error:c,refresh:_,logout:v,setActiveOrganization:y,organizations:u,organizationsLoading:f,organizationsFetched:m,reloadOrganizations:g}),[n,i,o,c,_,v,y,u,f,m,g]);return(0,j.createElement)(HM.Provider,{value:b},e)}function JM(){let e=(0,j.useContext)(HM);if(!e)throw Error(`useSession must be used inside <SessionProvider>.`);return e}function YM(){let{organizations:e,organizationsLoading:t,reloadOrganizations:n}=JM();return{organizations:e,loading:t,error:null,reload:n}}function XM(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{create:(0,j.useCallback)(async t=>{if(!e?.organizations)throw Error(`Client not ready`);n(!0),i(null);try{return await e.organizations.create(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),creating:t,error:r}}function ZM(){let e=qg(),{reloadOrganizations:t,refresh:n}=JM(),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);return{update:(0,j.useCallback)(async(r,a)=>{if(!e?.organizations?.update)throw Error(`Client not ready`);i(!0),o(null);try{let i=await e.organizations.update(r,a);return await t(),await n(),i}catch(e){throw o(e),e}finally{i(!1)}},[e,t,n]),updating:r,error:a}}function QM(){let e=qg(),{reloadOrganizations:t,refresh:n}=JM(),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);return{remove:(0,j.useCallback)(async r=>{if(!e?.organizations?.delete)throw Error(`Client not ready`);i(!0),o(null);try{let i=await e.organizations.delete(r);return await t(),await n(),i}catch(e){throw o(e),e}finally{i(!1)}},[e,t,n]),deleting:r,error:a}}function $M({message:e}){return typeof document>`u`?null:(0,Gi.createPortal)((0,M.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-8 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:e})]})}),document.body)}function eN(e,t){let n=(e||t||`?`).trim(),r=n.split(/\s+/);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():n.slice(0,2).toUpperCase()}function tN(){let{t:e}=vt(),t=Hi(),{user:n,loading:r,logout:i}=JM(),[a,o]=(0,j.useState)(!1);return r&&!n?(0,M.jsx)(`div`,{className:`h-8 w-8 animate-pulse rounded-full bg-muted`,"aria-hidden":!0}):n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,children:(0,M.jsxs)(zM,{className:`h-7 w-7`,children:[n.image?(0,M.jsx)(BM,{src:n.image,alt:n.name??n.email??e(`userMenu.user`)}):null,(0,M.jsx)(VM,{className:`text-[11px]`,children:eN(n.name,n.email)})]})})}),(0,M.jsxs)(tM,{align:`end`,className:`w-64`,children:[(0,M.jsx)(aM,{children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name||n.email}),n.email&&(0,M.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:n.email})]})}),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:()=>t({to:`/account`}),children:[(0,M.jsx)(Zy,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.account`)]}),(0,M.jsxs)(nM,{onSelect:()=>t({to:`/organizations`}),children:[(0,M.jsx)(dy,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.organizations`)]}),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:async()=>{o(!0);try{await i()}finally{window.location.assign(`/_account/login`)}},disabled:a,children:[(0,M.jsx)(My,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.signOut`)]})]})]}),a?(0,M.jsx)($M,{message:e(`auth.userMenu.signingOut`,{defaultValue:`Signing you out…`})}):null]}):(0,M.jsx)(Q,{variant:`outline`,size:`sm`,className:`h-8`,onClick:()=>t({to:`/login`}),children:e(`userMenu.signIn`)})}function nN(){let{t:e}=vt(),t=Hi(),n=Oa(),{organizations:r,loading:i,reload:a}=YM(),{session:o,setActiveOrganization:s}=JM(),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(!1),f=o?.activeOrganizationId??void 0,p=(0,j.useMemo)(()=>r.find(e=>e.id===f)??null,[r,f]),m=async r=>{if(l(!1),r===f){t({to:`/organizations/$orgId/general`,params:{orgId:r}});return}d(!0);try{await s(r),await a(),q({title:e(`organizations.general.switched`)});let i=n.pathname.match(/^\/organizations\/[^/]+\/(general|members)\/?$/);t({to:(i?i[1]:`general`)===`members`?`/organizations/$orgId/members`:`/organizations/$orgId/general`,params:{orgId:r}})}catch(t){q({title:e(`organizations.switchFailed`),description:t.message,variant:`destructive`})}finally{d(!1)}};return(0,M.jsxs)(Zj,{open:c,onOpenChange:l,children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`sm`,className:`h-8 gap-2 px-2 text-sm font-medium`,disabled:u,children:[p?(0,M.jsx)(`span`,{className:`max-w-[160px] truncate`,children:p.name}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(i?`organizations.loading`:`organizationSwitcher.select`)}),(0,M.jsx)(gy,{className:`h-3 w-3 opacity-50`})]})}),(0,M.jsxs)(tM,{align:`start`,className:`w-[280px]`,sideOffset:4,children:[(0,M.jsx)(aM,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`organizations.title`)}),r.length===0&&!i&&(0,M.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:e(`organizations.emptyTitle`)}),r.map(e=>(0,M.jsxs)(nM,{onSelect:t=>{t.preventDefault(),m(e.id)},className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),e.slug&&(0,M.jsx)(`code`,{className:`text-[11px] text-muted-foreground font-mono`,children:e.slug})]}),e.id===f&&(0,M.jsx)(fy,{className:`h-3.5 w-3.5 text-primary`})]},e.id)),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:e=>{e.preventDefault(),l(!1),t({to:`/organizations/new`})},className:`gap-2 text-sm`,children:[(0,M.jsx)(Ly,{className:`h-3.5 w-3.5`}),e(`organizationSwitcher.new`)]}),(0,M.jsx)(nM,{onSelect:e=>{e.preventDefault(),l(!1),t({to:`/organizations`})},className:`gap-2 text-sm text-muted-foreground`,children:e(`organizationSwitcher.manage`)})]})]})}function rN({label:e}){return(0,M.jsx)(ra,{to:`/account`,className:`flex h-8 w-8 items-center justify-center rounded-md bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15 transition-transform hover:scale-105`,"aria-label":e,children:(0,M.jsx)(vy,{className:`h-4 w-4`})})}function iN(){return(0,M.jsx)(my,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground/50`})}function aN(){let{t:e}=vt(),t=Oa(),n=Bi({strict:!1}),r=(0,j.useMemo)(()=>{let r=t.pathname,i=t=>e(`topBar.breadcrumb.${t}`);if(r.startsWith(`/account`)){let e=[{label:i(`account`)}];return r===`/account/profile`?e.push({label:i(`profile`)}):r===`/account/security`?e.push({label:i(`security`)}):r===`/account/sessions`?e.push({label:i(`sessions`)}):r===`/account/two-factor`?e.push({label:i(`twoFactor`)}):r===`/account/oauth-applications`?e.push({label:i(`oauthApps`)}):r===`/account/oauth-applications/new`?e.push({label:i(`oauthApps`)},{label:i(`new`)}):r.startsWith(`/account/oauth-applications/`)&&e.push({label:i(`oauthApps`)}),e}if(r===`/organizations/new`)return[{label:i(`organizations`)},{label:i(`new`)}];if(n.orgId){let e=r.endsWith(`/general`)?i(`general`):r.endsWith(`/members`)?i(`members`):i(`settings`);return[{label:i(`organizations`)},{label:e}]}return r===`/organizations`||r.startsWith(`/organizations/`)?[{label:i(`organizations`)}]:r.startsWith(`/accept-invitation/`)?[{label:i(`acceptInvitation`)}]:r.startsWith(`/auth/device`)?[{label:i(`deviceAuthorization`)}]:[{label:i(`account`)}]},[t.pathname,n.orgId,e]);return(0,M.jsxs)(`header`,{className:`sticky top-0 z-30 flex h-14 shrink-0 items-center justify-between gap-2 border-b bg-background/80 px-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:px-4`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 sm:gap-2.5`,children:[(0,M.jsx)(`div`,{className:`sm:hidden`,children:(0,M.jsx)(wO,{className:`h-9 w-9`})}),(0,M.jsx)(rN,{label:e(`topBar.accountHome`)}),(0,M.jsx)(`span`,{className:`hidden text-sm font-semibold tracking-tight sm:inline`,children:e(`topBar.brand`)}),(0,M.jsxs)(`div`,{className:`hidden items-center gap-1.5 sm:flex`,children:[(0,M.jsx)(iS,{orientation:`vertical`,className:`mx-1 h-4`}),(0,M.jsx)(nN,{}),(0,M.jsx)(iN,{}),(0,M.jsx)(qO,{children:(0,M.jsx)(JO,{children:r.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center`,children:[t>0&&(0,M.jsx)(QO,{}),(0,M.jsx)(YO,{children:(0,M.jsx)(ZO,{className:`font-medium`,children:e.label})})]},t))})})]}),(0,M.jsx)(`div`,{className:`min-w-0 flex-1 sm:hidden`,children:r.length>0&&(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:r[r.length-1].label})})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[(0,M.jsx)(`div`,{className:`hidden sm:block`,children:(0,M.jsx)(_M,{})}),(0,M.jsx)(`div`,{className:`hidden sm:block`,children:(0,M.jsx)(yM,{})}),(0,M.jsx)(tN,{})]})]})}var oN=[{to:`/account`,label:`home`,icon:Ey,exact:!0},{to:`/account/profile`,label:`profile`,icon:Zy},{to:`/account/security`,label:`security`,icon:Hy},{to:`/account/sessions`,label:`sessions`,icon:Py},{to:`/account/two-factor`,label:`twoFactor`,icon:Vy},{to:`/account/invitations`,label:`invitations`,icon:Dy},{to:`/account/linked-accounts`,label:`linkedAccounts`,icon:jy}],sN=[`group/nav relative transition-all duration-150`,`before:absolute before:left-0 before:top-1/2 before:h-5 before:w-[3px] before:-translate-y-1/2 before:rounded-r-full before:bg-brand-gradient before:opacity-0 before:transition-opacity`,`data-[active=true]:before:opacity-100`,`data-[active=true]:bg-sidebar-accent/80 data-[active=true]:text-sidebar-accent-foreground`,`[&>svg]:transition-transform [&>svg]:duration-150 hover:[&>svg]:scale-110`,`data-[active=true]:[&>svg]:text-primary`].join(` `);function cN(){let{t:e}=vt(),{pathname:t}=Oa(),{organizations:n}=YM(),r=t,i=t.match(/^\/organizations\/([^/]+)(?:\/.*)?$/),a=i&&n.some(e=>e.id===i[1])?i[1]:null;return(0,M.jsxs)(CO,{collapsible:`icon`,className:`h-full`,children:[(0,M.jsxs)(jO,{children:[(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.account`)}),(0,M.jsx)(FO,{children:(0,M.jsx)(IO,{children:oN.map(t=>{let n=t.icon;return(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t.exact?r===t.to||r===`${t.to}/`:r===t.to||r.startsWith(`${t.to}/`),tooltip:e(`sidebar.items.${t.label}`),className:sN,children:(0,M.jsxs)(ra,{to:t.to,children:[(0,M.jsx)(n,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.${t.label}`)})]})})},t.to)})})})]}),(0,M.jsx)(AO,{}),(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.organization`)}),(0,M.jsx)(FO,{children:(0,M.jsxs)(IO,{children:[(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations`,tooltip:e(`sidebar.items.overview`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations`,children:[(0,M.jsx)(dy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.overview`)})]})})}),a&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/general`,tooltip:e(`sidebar.items.general`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/general`,params:{orgId:a},children:[(0,M.jsx)(By,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.general`)})]})})}),(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/members`,tooltip:e(`sidebar.items.members`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/members`,params:{orgId:a},children:[(0,M.jsx)($y,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.members`)})]})})}),(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/teams`,tooltip:e(`sidebar.items.teams`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/teams`,params:{orgId:a},children:[(0,M.jsx)(Qy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.teams`)})]})})})]})]})})]}),(0,M.jsx)(AO,{}),(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.developer`)}),(0,M.jsx)(FO,{children:(0,M.jsx)(IO,{children:(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t.startsWith(`/account/oauth-applications`),tooltip:e(`sidebar.items.oauthApps`),className:sN,children:(0,M.jsxs)(ra,{to:`/account/oauth-applications`,children:[(0,M.jsx)(Oy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.oauthApps`)})]})})})})})]})]}),(0,M.jsx)(kO,{children:(0,M.jsx)(IO,{children:(0,M.jsx)(LO,{children:(0,M.jsx)(lN,{})})})})]})}function lN(){let{t:e}=vt(),{state:t,toggleSidebar:n}=xO(),r=e(t===`collapsed`?`sidebar.expand`:`sidebar.collapse`);return(0,M.jsx)(RO,{onClick:n,tooltip:r,"aria-label":r,children:(0,M.jsx)(Iy,{className:`size-4`})})}function uN(){return typeof window<`u`&&window.location.pathname.startsWith(`/_account`)?window.location.origin:`http://localhost:3000`}var dN=new Set([`/login`,`/register`,`/forgot-password`,`/reset-password`,`/verify-email`,`/auth/device`,`/setup`]);function fN(e){return dN.has(e)||e.startsWith(`/accept-invitation/`)}function pN(){let[e,t]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/v1/auth/bootstrap-status`);if(!n.ok){e||t(!0);return}let r=await n.json();e||t(r.hasOwner!==!1)}catch{e||t(!0)}})(),()=>{e=!0}},[]),e}function mN({children:e}){let{user:t,loading:n}=JM(),r=Hi(),i=Oa(),a=fN(i.pathname),o=i.pathname.startsWith(`/oauth/`),s=pN(),c=i.pathname===`/setup`;return(0,j.useEffect)(()=>{s===!1&&!c&&!t&&r({to:`/setup`,replace:!0})},[s,c,t,r]),(0,j.useEffect)(()=>{n||s!==!1&&!t&&!a&&r({to:`/login`,search:{redirect:i.pathname+i.searchStr},replace:!0})},[t,n,a,r,i.pathname,i.searchStr,s]),s===null||n&&!t?(0,M.jsx)(`div`,{className:`flex min-h-screen w-full flex-1 items-center justify-center bg-background`,children:(0,M.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted border-t-primary`})}):s===!1&&!c||!t&&!a?null:a||o?(0,M.jsx)(`div`,{className:`flex min-h-screen w-full`,children:e}):(0,M.jsxs)(SO,{className:`flex h-svh w-full flex-col`,children:[(0,M.jsx)(aN,{}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 w-full`,children:[(0,M.jsx)(cN,{}),(0,M.jsx)(EO,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-auto bg-background`,children:e})})]})]})}function hN(){let e=uN();return(0,M.jsx)(Kg,{client:(0,j.useMemo)(()=>new Ug({baseUrl:e}),[e]),children:(0,M.jsxs)(qM,{children:[(0,M.jsx)(mN,{children:(0,M.jsx)(ya,{})}),(0,M.jsx)(Fx,{})]})})}var gN=ca({component:hN}),$=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));$.displayName=`Card`;var _N=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`flex flex-col space-y-1.5 p-6`,e),...t}));_N.displayName=`CardHeader`;var vN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`h3`,{ref:n,className:Z(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));vN.displayName=`CardTitle`;var yN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`p`,{ref:n,className:Z(`text-sm text-muted-foreground`,e),...t}));yN.displayName=`CardDescription`;var bN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`p-6 pt-0`,e),...t}));bN.displayName=`CardContent`;var xN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`flex items-center p-6 pt-0`,e),...t}));xN.displayName=`CardFooter`;function SN(e){let t=e.split(`:`)[0].toLowerCase();return/^cloud\./.test(t)}function CN(){return typeof window>`u`?null:window.location.host||null}function wN({children:e,headline:t,subline:n,formWidth:r=`sm`}){let{t:i}=vt(),a=r===`md`?`max-w-md`:`max-w-sm`,o=CN(),s=!!o&&!SN(o);return j.useEffect(()=>{if(typeof document>`u`||!o)return;let e=document.title;return document.title=s?`${o} · ObjectStack`:e,()=>{document.title=e}},[o,s]),(0,M.jsxs)(`div`,{className:`relative grid min-h-svh w-full lg:grid-cols-2`,children:[(0,M.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-6 bg-background p-6 md:p-10`,children:(0,M.jsxs)(`div`,{className:Z(`flex w-full flex-col gap-6`,a),children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 self-center`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 font-semibold tracking-tight`,children:[(0,M.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30`,children:(0,M.jsx)(wy,{className:`size-4`})}),(0,M.jsx)(`span`,{children:`ObjectStack`})]}),s?(0,M.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide text-muted-foreground`,title:i(`auth.shell.tenantHostHint`,{defaultValue:`You are signing in to this workspace`}),children:o}):null]}),e]})}),(0,M.jsxs)(`aside`,{"aria-hidden":!0,className:`relative hidden overflow-hidden bg-brand-mesh text-white lg:flex lg:flex-col lg:justify-between lg:p-12`,children:[(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-[0.12]`,style:{backgroundImage:`linear-gradient(rgba(255,255,255,0.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.6) 1px, transparent 1px)`,backgroundSize:`48px 48px`,maskImage:`radial-gradient(ellipse at center, black 40%, transparent 75%)`}}),(0,M.jsx)(`div`,{className:`pointer-events-none absolute -left-24 top-1/3 size-[28rem] rounded-full bg-white/15 blur-3xl`}),(0,M.jsx)(`div`,{className:`pointer-events-none absolute -right-20 -bottom-20 size-[24rem] rounded-full bg-white/10 blur-3xl`}),(0,M.jsxs)(`div`,{className:`relative flex items-center gap-2 text-sm font-semibold tracking-tight`,children:[(0,M.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-white/15 ring-1 ring-white/30 backdrop-blur`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsxs)(`div`,{className:`relative max-w-md space-y-5`,children:[(0,M.jsx)(`h2`,{className:`text-balance text-3xl font-semibold leading-tight tracking-tight md:text-4xl`,children:t??i(`auth.login.brandHeadline`,{defaultValue:`The AI-native backend for business software.`})}),(0,M.jsx)(`p`,{className:`text-balance text-base/relaxed text-white/80`,children:n??i(`auth.login.brandSubline`,{defaultValue:`One identity, every workspace. Sign in to manage your account, organizations and connected apps.`})})]}),(0,M.jsxs)(`div`,{className:`relative text-xs text-white/60`,children:[`© `,new Date().getFullYear(),` ObjectStack`]})]})]})}var TN=la(`/verify-email`)({validateSearch:e=>{let t=e.token;return typeof t==`string`?{token:t}:{}},component:EN});function EN(){let{t:e}=vt(),{token:t}=TN.useSearch(),n=qg(),[r,i]=(0,j.useState)(`loading`),[a,o]=(0,j.useState)(``);return(0,j.useEffect)(()=>{if(!t){i(`error`),o(e(`auth.verifyEmail.missingToken`));return}let r=!1;return(async()=>{try{await n.auth.verifyEmail({token:t}),r||i(`success`)}catch(t){r||(i(`error`),o(t.message||e(`auth.verifyEmail.errorDescription`)))}})(),()=>{r=!0}},[t,e,n]),(0,M.jsx)(wN,{headline:e(`auth.verifyEmail.brandHeadline`,{defaultValue:`One more step to get started.`}),subline:e(`auth.verifyEmail.brandSubline`,{defaultValue:`Verifying your email keeps your ObjectStack account secure.`}),children:(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[r===`loading`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.verifyingTitle`)}),(0,M.jsx)(yN,{children:e(`auth.verifyEmail.verifyingDescription`)})]}),(0,M.jsx)(bN,{className:`flex justify-center py-6`,children:(0,M.jsx)(`div`,{className:`h-10 w-10 animate-spin rounded-full border-4 border-muted border-t-primary`})})]}),r===`success`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-500 ring-1 ring-emerald-500/30`,children:(0,M.jsx)(_y,{className:`size-6`})}),(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.successTitle`)}),(0,M.jsx)(yN,{children:e(`auth.verifyEmail.successDescription`)})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.signInLink`)})})]}),r===`error`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-destructive/10 text-destructive ring-1 ring-destructive/30`,children:(0,M.jsx)(yy,{className:`size-6`})}),(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.errorTitle`)}),(0,M.jsx)(yN,{children:a||e(`auth.verifyEmail.errorDescription`)})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.backToSignIn`)})})]})]})})}var DN=`Label`,ON=j.forwardRef((e,t)=>(0,M.jsx)(Zx.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ON.displayName=DN;var kN=ON,AN=$v(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),jN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(kN,{ref:n,className:Z(AN(),e),...t}));jN.displayName=kN.displayName;var MN=la(`/setup`)({component:PN});function NN(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function PN(){let{t:e}=vt(),t=Hi(),n=qg(),{user:r,refresh:i}=JM(),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let{hasOwner:t}=await n.auth.bootstrapStatus();e||g(t)}catch{e||g(!1)}})(),()=>{e=!0}},[n]),(0,j.useEffect)(()=>{h===!0&&!r&&t({to:`/login`,replace:!0})},[h,r,t]),(0,j.useEffect)(()=>{r&&window.location.assign(`/`)},[r]),h===null?(0,M.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted`,children:(0,M.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted-foreground/20 border-t-primary`})}):(0,M.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted p-6`,children:(0,M.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-6`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,M.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.setup.welcomeTitle`)}),(0,M.jsx)(yN,{children:e(`auth.setup.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),n?.auth){m(!0);try{await n.auth.register({name:a,email:s,password:l}),await i();let e=d.trim();if(e)try{let{organizations:t}=await n.organizations.list(),r=t?.[0],i;if(r?.id)await n.organizations.update(r.id,{name:e,slug:NN(e)}),i=r.id;else{let t=await n.organizations.create({name:e,slug:NN(e)});i=t?.id??t?.data?.id}i&&await n.organizations.setActive(i).catch(()=>{})}catch(e){console.warn(`[setup] organization rename/create failed`,e)}window.location.assign(`/`)}catch(t){q({title:e(`auth.setup.failed`),description:t.message,variant:`destructive`})}finally{m(!1)}}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`auth.setup.yourName`)}),(0,M.jsx)(Xx,{id:`name`,autoComplete:`name`,required:!0,value:a,onChange:e=>o(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`orgName`,children:e(`auth.setup.orgName`)}),(0,M.jsx)(Xx,{id:`orgName`,required:!0,placeholder:e(`auth.setup.orgNamePlaceholder`),value:d,onChange:e=>f(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,placeholder:e(`auth.setup.passwordHint`),value:l,onChange:e=>u(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`mt-2 w-full`,disabled:p,children:e(p?`auth.setup.submitting`:`auth.setup.submit`)})]})})]})]})})}var FN=la(`/reset-password`)({validateSearch:e=>{let t=e.token;return typeof t==`string`?{token:t}:{}},component:IN});function IN(){let{t:e}=vt(),t=Hi(),{token:n}=FN.useSearch(),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(!1);return(0,M.jsx)(wN,{headline:e(`auth.resetPassword.brandHeadline`,{defaultValue:`Choose a new password.`}),subline:e(`auth.resetPassword.brandSubline`,{defaultValue:`Make it strong — at least 8 characters with a mix of letters and numbers.`}),children:(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.resetPassword.title`)}),(0,M.jsx)(yN,{children:e(`auth.resetPassword.description`)})]}),(0,M.jsx)(bN,{children:n?(0,M.jsxs)(`form`,{onSubmit:async i=>{if(i.preventDefault(),r!==a){q({title:e(`auth.resetPassword.passwordsMismatch`),variant:`destructive`});return}if(!n){q({title:e(`auth.resetPassword.missingToken`),variant:`destructive`});return}c(!0);try{let i=await fetch(`/api/v1/auth/reset-password`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({token:n,newPassword:r})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e?.message||`Request failed: ${i.status}`)}q({title:e(`auth.resetPassword.success`)}),t({to:`/login`})}catch(t){q({title:e(`auth.resetPassword.failed`),description:t.message,variant:`destructive`})}finally{c(!1)}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`new-password`,children:e(`auth.resetPassword.newPassword`)}),(0,M.jsx)(Xx,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:r,onChange:e=>i(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`confirm-password`,children:e(`auth.resetPassword.confirmPassword`)}),(0,M.jsx)(Xx,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:a,onChange:e=>o(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:s,children:e(s?`auth.resetPassword.submitting`:`auth.resetPassword.submit`)})]}):(0,M.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center`,children:[e(`auth.resetPassword.invalidToken`),` `,(0,M.jsx)(ra,{to:`/forgot-password`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.resetPassword.requestNewLink`)})]})})]})})}function LN({mode:e,redirect:t}){let{t:n}=vt(),r=qg(),[i,a]=(0,j.useState)([]),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(null);if((0,j.useEffect)(()=>{r?.auth?.getConfig&&r.auth.getConfig().then(e=>{a((e?.socialProviders??e?.data?.socialProviders??[]).filter(e=>e.enabled))}).catch(e=>{console.warn(`[SocialSignInButtons] failed to load auth config`,e)}).finally(()=>s(!1))},[r]),o||i.length===0)return null;let u=n(e===`sign-in`?`auth.social.continueWith`:`auth.social.signUpWith`),d=window.location.origin+`/_account/login`+(t?`?redirect=${encodeURIComponent(t)}`:``),f=e=>{c||(l(e),Promise.resolve(r.auth.signInWithProvider(e.id,{callbackURL:d,errorCallbackURL:d,type:e.type??`social`})).catch(e=>{console.warn(`[SocialSignInButtons] signInWithProvider failed`,e),l(null)}))};return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.map(e=>{let t=c?.id===e.id;return(0,M.jsxs)(Q,{type:`button`,variant:`outline`,className:`w-full`,disabled:!!c,onClick:()=>f(e),children:[t?(0,M.jsx)(`span`,{className:`mr-2 inline-block size-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}):(0,M.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center rounded-sm bg-muted text-[10px] font-bold uppercase`,children:e.id[0]}),t?n(`auth.social.redirectingTo`,{provider:e.name,defaultValue:`Redirecting to ${e.name}…`}):`${u} ${e.name}`]},e.id)}),(0,M.jsxs)(`div`,{className:`relative my-1`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,M.jsx)(`span`,{className:`w-full border-t`})}),(0,M.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,M.jsx)(`span`,{className:`bg-card px-2 text-muted-foreground`,children:n(`auth.social.orContinueEmail`)})})]}),c&&typeof document<`u`?(0,Gi.createPortal)((0,M.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-8 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:n(`auth.social.redirectingTo`,{provider:c.name,defaultValue:`Redirecting to ${c.name}…`})})]})}),document.body):null]})}var RN=la(`/register`)({validateSearch:e=>{let t=e.redirect;return typeof t==`string`?{redirect:t}:{}},component:VN});function zN(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function BN(e){return e.startsWith(`/_`)?e:`/_account/`.replace(/\/$/,``)+e}function VN(){let{t:e}=vt(),t=Hi(),{redirect:n}=RN.useSearch(),r=qg(),{session:i,user:a,loading:o,refresh:s,organizations:c,organizationsLoading:l,organizationsFetched:u,setActiveOrganization:d}=JM(),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(``),[g,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(a){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){window.location.assign(`/api/v1/auth/oauth2/authorize${window.location.search}`);return}}if(!i?.activeOrganizationId){if(!u||l||b)return;if(c.length===1){x(!0),d(c[0].id).catch(()=>void 0).finally(()=>x(!1));return}if(c.length>1){t({to:`/organizations`});return}t({to:`/organizations/new`});return}if(!b){if(zN(n)){window.location.assign(BN(n));return}window.location.assign(`/`)}}},[a,i,t,n,c,l,u,b,d]),(0,M.jsx)(wN,{headline:e(`auth.register.brandHeadline`,{defaultValue:`Create your ObjectStack account.`}),subline:e(`auth.register.brandSubline`,{defaultValue:`One identity for every workspace, app and integration in your stack.`}),children:o||a?(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:a?e(`auth.register.signingIn`,{defaultValue:`Setting up your account…`}):e(`auth.login.redirecting`,{defaultValue:`Loading…`})})]}):(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.register.title`)}),(0,M.jsx)(yN,{children:e(`auth.register.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),r?.auth){y(!0);try{await r.auth.register({name:f,email:m,password:g}),await s(),q({title:e(`auth.register.successToast`)})}catch(t){q({title:e(`auth.register.failed`),description:t.message,variant:`destructive`})}finally{y(!1)}}},children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsx)(LN,{mode:`sign-up`,redirect:n}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`auth.nameLabel`)}),(0,M.jsx)(Xx,{id:`name`,autoComplete:`name`,required:!0,value:f,onChange:e=>p(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:m,onChange:e=>h(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:g,onChange:e=>_(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:v,children:e(v?`auth.register.submitting`:`auth.register.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.register.haveAccount`),` `,(0,M.jsx)(ra,{to:`/login`,search:n?{redirect:n}:void 0,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.register.signIn`)})]})]})})})]}),(0,M.jsxs)(`p`,{className:`px-6 text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary`,children:[e(`legal.agreementPrefix`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.termsOfService`)}),` `,e(`legal.and`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.privacyPolicy`)}),`.`]})]})})}var HN=la(`/login`)({validateSearch:e=>{let t=e.redirect;return typeof t==`string`?{redirect:t}:{}},component:GN});function UN(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function WN(e){return e.startsWith(`/_`)?e:`/_account/`.replace(/\/$/,``)+e}function GN(){let{t:e}=vt(),t=Hi(),{redirect:n}=HN.useSearch(),r=qg(),i=null;if(typeof window<`u`){let e=new URLSearchParams(window.location.search),t=e.get(`redirect_uri`);if(e.has(`client_id`)&&t)try{i=new URL(t).host}catch{i=null}}let{session:a,user:o,loading:s,refresh:c,organizations:l,organizationsLoading:u,organizationsFetched:d,setActiveOrganization:f}=JM(),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)(!1),[y,b]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(o){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){window.location.assign(`/api/v1/auth/oauth2/authorize${window.location.search}`);return}}if(!a?.activeOrganizationId){if(!d||u||y)return;if(l.length===1){b(!0),f(l[0].id).catch(()=>void 0).finally(()=>b(!1));return}if(l.length===0){t({to:`/organizations/new`});return}t({to:`/organizations`});return}if(!y){if(UN(n)){window.location.assign(WN(n));return}window.location.assign(`/`)}}},[o,a,t,n,l,u,d,y,f]),s||o?(0,M.jsx)(wN,{children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})})]})}):(0,M.jsxs)(wN,{children:[_?(0,M.jsx)($M,{message:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})}):null,(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i?(0,M.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-md border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 inline-block size-2 shrink-0 rounded-full bg-primary`}),(0,M.jsx)(`span`,{children:e(`auth.login.ssoHandoff`,{target:i,defaultValue:`Sign in to ObjectStack to continue to ${i}`})})]}):null,(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.login.title`)}),(0,M.jsx)(yN,{children:e(`auth.login.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),r?.auth){v(!0);try{await r.auth.login({type:`email`,email:p,password:h}),await c(),q({title:e(`auth.login.welcomeToast`)})}catch(t){q({title:e(`auth.login.failed`),description:t.message,variant:`destructive`})}finally{v(!1)}}},children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsx)(LN,{mode:`sign-in`,redirect:n}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:p,onChange:e=>m(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(ra,{to:`/forgot-password`,className:`ml-auto text-sm underline-offset-4 hover:underline`,children:e(`auth.login.forgotPassword`)})]}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`current-password`,required:!0,value:h,onChange:e=>g(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:_,children:e(_?`auth.login.submitting`:`auth.login.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.login.noAccount`),` `,(0,M.jsx)(ra,{to:`/register`,search:n?{redirect:n}:void 0,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.login.signUp`)})]})]})})})]}),(0,M.jsxs)(`p`,{className:`px-6 text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary`,children:[e(`legal.agreementPrefix`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.termsOfService`)}),` `,e(`legal.and`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.privacyPolicy`)}),`.`]})]})]})}var KN=la(`/forgot-password`)({component:qN});function qN(){let{t:e}=vt(),[t,n]=(0,j.useState)(``),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(!1);return(0,M.jsx)(wN,{headline:e(`auth.forgotPassword.brandHeadline`,{defaultValue:`Forgot your password?`}),subline:e(`auth.forgotPassword.brandSubline`,{defaultValue:`No problem — we will send you a secure link to reset it.`}),children:(0,M.jsx)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:a?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.forgotPassword.checkEmailTitle`)}),(0,M.jsx)(yN,{children:e(`auth.forgotPassword.checkEmailDescription`,{email:t})})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.forgotPassword.backToSignIn`)})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.forgotPassword.title`)}),(0,M.jsx)(yN,{children:e(`auth.forgotPassword.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),i(!0);try{let e=window.location.origin+`/_account/`.replace(/\/$/,``)+`/reset-password`,n=await fetch(`/api/v1/auth/forget-password`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({email:t,redirectTo:e})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e?.message||`Request failed: ${n.status}`)}o(!0)}catch(t){q({title:e(`auth.forgotPassword.failed`),description:t.message,variant:`destructive`})}finally{i(!1)}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:t,onChange:e=>n(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:r,children:e(r?`auth.forgotPassword.submitting`:`auth.forgotPassword.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.forgotPassword.rememberPassword`),` `,(0,M.jsx)(ra,{to:`/login`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.forgotPassword.signIn`)})]})]})})]})})})}var JN=la(`/account`)({component:YN});function YN(){return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-4 py-6 sm:px-6 sm:py-8`,children:(0,M.jsx)(`div`,{className:`page-enter mx-auto flex max-w-4xl flex-col gap-6`,children:(0,M.jsx)(ya,{})})})})}var XN=la(`/`)({component:ZN});function ZN(){return(0,M.jsx)(Ui,{to:`/login`})}var QN=$v(`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 $N({className:e,variant:t,...n}){return(0,M.jsx)(`div`,{className:Z(QN({variant:t}),e),...n})}function eP({title:e,description:t,icon:n,actions:r,className:i,...a}){return(0,M.jsxs)(`div`,{className:Z(`relative overflow-hidden rounded-xl border bg-brand-gradient-subtle`,`px-5 py-5 sm:px-6 sm:py-6`,i),...a,children:[(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-60`,style:{backgroundImage:`radial-gradient(ellipse 60% 80% at 0% 0%, hsl(var(--brand-from) / 0.12), transparent 60%)`},"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`relative flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between sm:gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-start gap-4`,children:[n?(0,M.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15`,children:(0,M.jsx)(n,{className:`size-5`})}):null,(0,M.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,M.jsx)(`h1`,{className:`truncate text-xl font-semibold tracking-tight sm:text-2xl`,children:e}),t?(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t}):null]})]}),r?(0,M.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})]})}var tP=la(`/organizations/`)({component:nP});function nP(){let{t:e}=vt(),{organizations:t,loading:n}=YM(),{session:r,setActiveOrganization:i}=JM(),a=Hi(),o=r?.activeOrganizationId??void 0,s=async t=>{try{t!==o&&await i(t),a({to:`/organizations/$orgId`,params:{orgId:t}})}catch(t){q({title:e(`organizations.switchFailed`),description:t.message,variant:`destructive`})}},c=e=>e.split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase();return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-4 py-6 sm:px-6 sm:py-8`,children:(0,M.jsxs)(`div`,{className:`page-enter mx-auto flex max-w-3xl flex-col gap-6`,children:[(0,M.jsx)(eP,{icon:dy,title:e(`organizations.title`),description:e(`organizations.description`),actions:(0,M.jsxs)(Q,{onClick:()=>a({to:`/organizations/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`organizations.newOrganization`)]})}),n&&(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`organizations.loading`)}),!n&&t.length===0&&(0,M.jsxs)($,{className:`p-10 text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-3 flex size-12 items-center justify-center rounded-lg bg-brand-gradient-subtle text-primary ring-1 ring-primary/15`,children:(0,M.jsx)(dy,{className:`h-6 w-6`})}),(0,M.jsx)(`h3`,{className:`text-base font-medium`,children:e(`organizations.emptyTitle`)}),(0,M.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:e(`organizations.emptyDescription`)}),(0,M.jsxs)(Q,{onClick:()=>a({to:`/organizations/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`organizations.createOrganization`)]})]}),(0,M.jsx)(`div`,{className:`grid gap-3`,children:t.map(t=>{let n=t.id===o;return(0,M.jsx)($,{role:`button`,tabIndex:0,onClick:()=>s(t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(t.id))},className:`group cursor-pointer p-4 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-md hover:shadow-primary/5 focus:outline-none focus:ring-2 focus:ring-ring ${n?`border-primary/50 bg-brand-gradient-subtle ring-1 ring-primary/30`:``}`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,M.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg font-semibold `+(n?`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15`:`bg-muted text-muted-foreground group-hover:bg-brand-gradient-subtle group-hover:text-primary`),children:c(t.name)||(0,M.jsx)(dy,{className:`h-5 w-5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`h3`,{className:`truncate text-base font-medium`,children:t.name}),n&&(0,M.jsxs)($N,{className:`gap-1 border-transparent bg-emerald-500/15 text-[10px] font-medium text-emerald-600 dark:text-emerald-400`,children:[(0,M.jsx)(fy,{className:`h-3 w-3`}),e(`organizations.active`)]})]}),t.slug&&(0,M.jsx)(`code`,{className:`mt-0.5 block font-mono text-xs text-muted-foreground`,children:t.slug})]}),(0,M.jsx)(my,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-primary`})]})},t.id)})})]})})})}var rP=la(`/account/`)({component:iP});function iP(){let{t:e}=vt(),{user:t}=JM(),{organizations:n}=YM(),r=[!!t?.emailVerified,!!t?.twoFactorEnabled,!!t?.name,!!t?.image].filter(Boolean).length*25,i=r>=75?`success`:r>=50?`warn`:`danger`,a=(t?.name??t?.email??`?`).split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase(),o=[{to:`/account/profile`,label:e(`home.tiles.profile.title`,{defaultValue:`Profile`}),description:e(`home.tiles.profile.description`,{defaultValue:`Display name, avatar and contact info.`}),icon:Zy},{to:`/account/security`,label:e(`home.tiles.security.title`,{defaultValue:`Security`}),description:e(`home.tiles.security.description`,{defaultValue:`Change your password and review activity.`}),icon:Hy},{to:`/account/two-factor`,label:e(`home.tiles.twoFactor.title`,{defaultValue:`Two-factor auth`}),description:e(`home.tiles.twoFactor.description`,{defaultValue:`Add an authenticator app for stronger sign-in.`}),icon:Vy},{to:`/account/sessions`,label:e(`home.tiles.sessions.title`,{defaultValue:`Active sessions`}),description:e(`home.tiles.sessions.description`,{defaultValue:`See and revoke devices that are signed in.`}),icon:Py},{to:`/account/linked-accounts`,label:e(`home.tiles.linked.title`,{defaultValue:`Linked accounts`}),description:e(`home.tiles.linked.description`,{defaultValue:`Manage your social and SSO providers.`}),icon:jy},{to:`/account/oauth-applications`,label:e(`home.tiles.oauth.title`,{defaultValue:`OAuth applications`}),description:e(`home.tiles.oauth.description`,{defaultValue:`Apps you have authorised to access your account.`}),icon:Oy}];return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border bg-card`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 bg-brand-gradient`,"aria-hidden":!0}),(0,M.jsx)(`div`,{className:`absolute inset-0 opacity-40 mix-blend-soft-light`,style:{backgroundImage:`radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.4), transparent 60%), radial-gradient(ellipse at 100% 100%, rgba(0,0,0,0.25), transparent 60%)`},"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`relative flex flex-col gap-4 p-6 text-white sm:flex-row sm:items-center sm:gap-6 sm:p-8`,children:[(0,M.jsxs)(zM,{className:`size-16 shrink-0 ring-4 ring-white/30 shadow-md sm:size-20`,children:[t?.image?(0,M.jsx)(BM,{src:t.image,alt:t?.name??``}):null,(0,M.jsx)(VM,{className:`bg-white/20 text-base font-semibold text-white backdrop-blur`,children:a})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,M.jsx)(`p`,{className:`text-xs uppercase tracking-wider text-white/70`,children:e(`home.welcome`,{defaultValue:`Welcome back`})}),(0,M.jsx)(`h2`,{className:`truncate text-2xl font-semibold tracking-tight`,children:t?.name||t?.email||`ObjectStack user`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-white/80`,children:[(0,M.jsx)(Ny,{className:`size-3.5`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`truncate`,children:t?.email}),t?.emailVerified?(0,M.jsx)($N,{className:`border-white/30 bg-white/15 text-[10px] font-medium text-white backdrop-blur hover:bg-white/20`,children:e(`home.verified`,{defaultValue:`Verified`})}):null]})]})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,M.jsx)(aP,{icon:Vy,label:e(`home.stats.score`,{defaultValue:`Security score`}),value:`${r}%`,tone:i,extra:(0,M.jsx)(`div`,{className:`mt-2 h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,M.jsx)(`div`,{className:`h-full bg-brand-gradient transition-[width] duration-500`,style:{width:`${r}%`}})})}),(0,M.jsx)(aP,{icon:dy,label:e(`home.stats.orgs`,{defaultValue:`Organizations`}),value:String(n.length),extra:(0,M.jsxs)(ra,{to:`/organizations`,className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline`,children:[e(`home.stats.manage`,{defaultValue:`Manage`}),(0,M.jsx)(uy,{className:`size-3`})]})}),(0,M.jsx)(aP,{icon:t?.twoFactorEnabled?Vy:Hy,label:e(`home.stats.twoFactor`,{defaultValue:`Two-factor auth`}),value:t?.twoFactorEnabled?e(`home.stats.enabled`,{defaultValue:`Enabled`}):e(`home.stats.disabled`,{defaultValue:`Disabled`}),tone:t?.twoFactorEnabled?`success`:`warn`,extra:(0,M.jsxs)(ra,{to:`/account/two-factor`,className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline`,children:[t?.twoFactorEnabled?e(`home.stats.review`,{defaultValue:`Review`}):e(`home.stats.enable`,{defaultValue:`Enable now`}),(0,M.jsx)(uy,{className:`size-3`})]})})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-muted-foreground`,children:e(`home.quickAccess`,{defaultValue:`Quick access`})}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:o.map(({to:e,label:t,description:n,icon:r})=>(0,M.jsxs)(ra,{to:e,className:`group relative flex items-start gap-3 rounded-lg border bg-card p-4 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-md hover:shadow-primary/5`,children:[(0,M.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-brand-gradient-subtle text-primary ring-1 ring-primary/10 transition-transform group-hover:scale-110`,children:(0,M.jsx)(r,{className:`size-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate font-medium`,children:t}),(0,M.jsx)(uy,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-primary`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:n})]})]},e))})]})]})}function aP({icon:e,label:t,value:n,tone:r=`neutral`,extra:i}){let a=r===`success`?`text-emerald-600 dark:text-emerald-400`:r===`warn`?`text-amber-600 dark:text-amber-400`:r===`danger`?`text-destructive`:`text-foreground`;return(0,M.jsx)($,{className:`overflow-hidden`,children:(0,M.jsxs)(bN,{className:`p-5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t}),(0,M.jsx)(e,{className:`size-4 ${a}`})]}),(0,M.jsx)(`p`,{className:`mt-1 text-2xl font-semibold tracking-tight ${a}`,children:n}),i]})})}var oP=la(`/organizations/new`)({component:cP});function sP(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function cP(){let{t:e}=vt(),t=Hi(),{create:n,creating:r}=XM(),{setActiveOrganization:i,reloadOrganizations:a}=JM(),[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),f=e=>{s(e),u||l(sP(e))};return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 px-6 py-8 overflow-auto`,children:(0,M.jsx)(`div`,{className:`mx-auto max-w-lg`,children:(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{children:e(`organizations.new.title`)}),(0,M.jsx)(yN,{children:e(`organizations.new.description`)})]}),(0,M.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();try{let t=await n({name:o,slug:c||void 0}),r=t?.data??t,s=r?.id??r?.organization?.id;s&&await i(s).catch(()=>{}),await a().catch(()=>{}),q({title:e(`organizations.new.successToast`)}),window.location.assign(`/`)}catch(t){q({title:e(`organizations.new.failed`),description:t.message,variant:`destructive`})}},children:[(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`organizations.new.name`)}),(0,M.jsx)(Xx,{id:`name`,required:!0,value:o,onChange:e=>f(e.target.value),placeholder:e(`organizations.new.namePlaceholder`)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`slug`,children:e(`organizations.new.slug`)}),(0,M.jsx)(Xx,{id:`slug`,value:c,onChange:e=>{l(e.target.value),d(!0)},placeholder:e(`organizations.new.slugPlaceholder`),pattern:`[a-z0-9-]+`}),(0,M.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`organizations.new.slugHint`)})]})]}),(0,M.jsxs)(xN,{className:`flex justify-between`,children:[(0,M.jsx)(Q,{type:`button`,variant:`ghost`,onClick:()=>t({to:`/organizations`}),children:e(`organizations.new.cancel`)}),(0,M.jsx)(Q,{type:`submit`,disabled:r||!o,children:e(r?`organizations.new.submitting`:`organizations.new.submit`)})]})]})]})})})})}var lP=la(`/organizations/$orgId`)({component:uP});function uP(){let{t:e}=vt(),{orgId:t}=lP.useParams(),{organizations:n}=YM(),r=n.find(e=>e.id===t);return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-6 py-8`,children:(0,M.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-6`,children:[(0,M.jsxs)(`header`,{children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:r?.name??e(`organizations.title`)}),r?.slug&&(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground font-mono`,children:r.slug})]}),(0,M.jsx)(ya,{})]})})})}function dP(){let e=qg(),[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null),s=(0,j.useCallback)(async()=>{if(e?.oauth?.applications){i(!0),o(null);try{n((await e.oauth.applications.list())?.applications??[])}catch(e){o(e),n([])}finally{i(!1)}}},[e]);return(0,j.useEffect)(()=>{s()},[s]),{applications:t,loading:r,error:a,reload:s}}function fP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(null);return{register:(0,j.useCallback)(async t=>{if(!e?.oauth?.applications?.register)throw Error(`Client not ready`);n(!0),i(null);try{let n=await e.oauth.applications.register(t);return o(n),n}catch(e){throw i(e),e}finally{n(!1)}},[e]),registering:t,error:r,lastResult:a}}function pP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{remove:(0,j.useCallback)(async t=>{if(!e?.oauth?.applications?.delete)throw Error(`Client not ready`);n(!0),i(null);try{return await e.oauth.applications.delete(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),deleting:t,error:r}}function mP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{submit:(0,j.useCallback)(async t=>{if(!e?.oauth?.consent)throw Error(`Client not ready`);n(!0),i(null);try{return await e.oauth.consent(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),submitting:t,error:r}}var hP=la(`/oauth/consent`)({validateSearch:e=>e,component:gP});function gP(){let{t:e}=vt(),t=Hi(),n=qg(),{user:r,loading:i}=JM(),{submit:a,submitting:o}=mP(),[s,c]=(0,j.useState)(null),l=typeof window<`u`?window.location.search:``,u=l.startsWith(`?`)?l.slice(1):l,d=new URLSearchParams(u),f=d.get(`client_id`)??void 0,p=d.get(`scope`)??``;(0,j.useEffect)(()=>{i||r||t({to:`/login`,search:{redirect:window.location.pathname+window.location.search}})},[r,i,t]),(0,j.useEffect)(()=>{if(!f||!n?.oauth?.applications?.getPublic)return;let e=!1;return n.oauth.applications.getPublic(f).then(t=>{if(e)return;let n=t?.data??t;c({name:n?.name??n?.client_name,icon:n?.icon??n?.logo_uri})},()=>{}),()=>{e=!0}},[n,f]);let m=p.split(/\s+/).filter(Boolean),h=async t=>{try{let n=await a({accept:t,oauth_query:u}),r=n?.redirect_uri??n?.redirectURI??n?.url;if(r){window.location.href=r;return}q({title:e(t?`oauth.consent.granted`:`oauth.consent.denied`),description:e(`oauth.consent.noRedirect`),variant:t?void 0:`destructive`})}catch(t){q({title:e(`oauth.consent.failed`),description:t.message,variant:`destructive`})}},g=s?.name??f??e(`oauth.consent.unknownApp`);return(0,M.jsx)(`div`,{className:`flex min-h-svh w-full flex-1 items-center justify-center bg-background px-4`,children:(0,M.jsxs)($,{className:`w-full max-w-md`,children:[(0,M.jsxs)(_N,{className:`items-center text-center`,children:[(0,M.jsx)(`div`,{className:`mb-3 rounded-full border bg-muted p-3`,children:s?.icon?(0,M.jsx)(`img`,{src:s.icon,alt:``,className:`h-8 w-8 rounded`,onError:e=>e.currentTarget.style.display=`none`}):(0,M.jsx)(Oy,{className:`h-7 w-7 text-muted-foreground`})}),(0,M.jsx)(vN,{className:`text-xl`,children:e(`oauth.consent.title`,{appName:g})}),(0,M.jsx)(yN,{children:e(`oauth.consent.request`,{appName:g,suffix:r?.email?` (${r.email})`:``})})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[m.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:e(`oauth.consent.willAllow`)}),(0,M.jsx)(`ul`,{className:`space-y-1.5 rounded-md border bg-muted/40 p-3 text-sm`,children:m.map(t=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(fy,{className:`mt-0.5 h-4 w-4 text-green-600 dark:text-green-400`}),(0,M.jsx)(`span`,{children:_P(t,e)})]},t))})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pt-2`,children:[(0,M.jsxs)(Q,{variant:`outline`,onClick:()=>h(!1),disabled:o,children:[(0,M.jsx)(eb,{className:`mr-2 h-4 w-4`}),e(`oauth.consent.deny`)]}),(0,M.jsxs)(Q,{onClick:()=>h(!0),disabled:o,children:[(0,M.jsx)(fy,{className:`mr-2 h-4 w-4`}),e(o?`oauth.consent.submitting`:`oauth.consent.authorize`)]})]}),(0,M.jsx)(`p`,{className:`pt-2 text-center text-xs text-muted-foreground`,children:e(`oauth.consent.footer`)})]})]})})}function _P(e,t){switch(e){case`openid`:return t(`oauth.consent.scope.openid`);case`profile`:return t(`oauth.consent.scope.profile`);case`email`:return t(`oauth.consent.scope.email`);case`offline_access`:return t(`oauth.consent.scope.offlineAccess`);default:return e}}var vP=la(`/auth/device`)({validateSearch:e=>({user_code:e.user_code??e.code??``}),component:bP});function yP({children:e}){return(0,M.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,M.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,M.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsx)(`div`,{className:`flex flex-col gap-6`,children:e})]})})}function bP(){let{t:e}=vt(),{user_code:t}=vP.useSearch(),{user:n,loading:r}=JM(),i=Hi(),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);return t?r?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsx)(_N,{className:`text-center`,children:(0,M.jsx)(yN,{children:e(`auth.device.loading`)})})})}):n?l?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(_y,{className:`h-10 w-10 text-green-500 mx-auto mb-2`}),(0,M.jsx)(vN,{children:e(`auth.device.approvedTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.approvedDescription`)})]})})}):d?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.deniedTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.deniedDescription`)})]})})}):(0,M.jsx)(yP,{children:(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.title`)}),(0,M.jsx)(yN,{children:e(`auth.device.subtitle`,{email:n.email})})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e(`auth.device.userCodeLabel`)}),(0,M.jsx)(`p`,{className:`font-mono font-semibold tracking-widest text-lg`,children:t})]}),(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(`p`,{className:`text-sm text-center text-muted-foreground`,children:e(`auth.device.loggedInAs`,{email:n.email})}),p&&(0,M.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:p}),(0,M.jsx)(Q,{onClick:async()=>{m(``),o(!0);try{let n=await fetch(`/api/v1/auth/device/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:t})});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t?.message??t?.error?.message??e(`auth.device.approveFailed`))}u(!0),q({title:e(`auth.device.approveSuccess`),description:e(`auth.device.approveSuccessDescription`)})}catch(t){m(t?.message??e(`auth.device.approveFailed`))}finally{o(!1)}},className:`w-full`,disabled:a||s,children:e(a?`auth.device.approving`:`auth.device.approve`)}),(0,M.jsx)(Q,{onClick:async()=>{m(``),c(!0);try{await fetch(`/api/v1/auth/device/deny`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:t})}),f(!0)}catch(t){m(t?.message??e(`auth.device.denyFailed`))}finally{c(!1)}},variant:`outline`,className:`w-full`,disabled:a||s,children:e(s?`auth.device.denying`:`auth.device.deny`)}),(0,M.jsx)(`div`,{className:`text-center`,children:(0,M.jsx)(`button`,{type:`button`,className:`text-sm text-muted-foreground underline-offset-4 hover:underline`,onClick:()=>i({to:`/`}),children:e(`auth.device.cancel`)})})]})]})]})}):(0,M.jsx)(Ui,{to:`/login`,search:{redirect:`/auth/device?user_code=${encodeURIComponent(t)}`}}):(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.invalidTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.invalidDescription`)})]})})})}var xP=la(`/account/two-factor`)({component:SP});function SP(){let{t:e}=vt(),t=qg(),{user:n,loading:r,refresh:i}=JM(),[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(null),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(!1),[T,E]=(0,j.useState)(``),[D,O]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(null);(0,j.useEffect)(()=>{r||o(!!n?.twoFactorEnabled)},[r,n?.twoFactorEnabled]);let ne=async n=>{n.preventDefault(),u(!0);try{let e=await t.auth.twoFactor.enable({password:s});f(e?.totpURI??null),m(e?.backupCodes??null),c(``)}catch(t){q({title:e(`twoFactor.enableFailed`),description:t.message,variant:`destructive`})}finally{u(!1)}},re=async n=>{n.preventDefault(),b(!0);try{await t.auth.twoFactor.verifyTotp({code:_,trustDevice:h}),q({title:e(`twoFactor.enableSuccess`)}),o(!0),f(null),v(``),await i()}catch(t){q({title:e(`twoFactor.invalidCode`),description:t.message,variant:`destructive`})}finally{b(!1)}},ie=async n=>{n.preventDefault(),w(!0);try{await t.auth.twoFactor.disable({password:x}),q({title:e(`twoFactor.disableSuccess`)}),o(!1),S(``),te(null),await i()}catch(t){q({title:e(`twoFactor.disableFailed`),description:t.message,variant:`destructive`})}finally{w(!1)}},ae=async n=>{n.preventDefault(),O(!0);try{te((await t.auth.twoFactor.generateBackupCodes({password:T}))?.backupCodes??[]),E(``),q({title:e(`twoFactor.backupCodes.regenerated`)})}catch(t){q({title:e(`twoFactor.backupCodes.regenerateFailed`),description:t.message,variant:`destructive`})}finally{O(!1)}},oe=async t=>{try{await navigator.clipboard.writeText(t.join(`
|
|
117
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Cw=`DialogDescriptionWarning`,ww=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xw(Cw).contentName}}.`;return j.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Tw=XC,Ew=nw,Dw=iw,Ow=cw,kw=pw,Aw=hw,jw=_w,Mw=Tw,Nw=Ew,Pw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Dw,{className:Z(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));Pw.displayName=Dw.displayName;var Fw=$v(`fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500`,{variants:{side:{top:`inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,bottom:`inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,left:`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,right:`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`}},defaultVariants:{side:`right`}}),Iw=j.forwardRef(({side:e=`right`,className:t,children:n,...r},i)=>(0,M.jsxs)(Nw,{children:[(0,M.jsx)(Pw,{}),(0,M.jsxs)(Ow,{ref:i,className:Z(Fw({side:e}),t),...r,children:[n,(0,M.jsxs)(jw,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,M.jsx)(eb,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Iw.displayName=Ow.displayName;var Lw=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});Lw.displayName=`SheetHeader`;var Rw=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Rw.displayName=`SheetFooter`;var zw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(kw,{ref:n,className:Z(`text-lg font-semibold text-foreground`,e),...t}));zw.displayName=kw.displayName;var Bw=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Aw,{ref:n,className:Z(`text-sm text-muted-foreground`,e),...t}));Bw.displayName=Aw.displayName;function Vw({className:e,...t}){return(0,M.jsx)(`div`,{className:Z(`bg-muted animate-pulse rounded-md`,e),...t})}var Hw=[`top`,`right`,`bottom`,`left`],Uw=Math.min,Ww=Math.max,Gw=Math.round,Kw=Math.floor,qw=e=>({x:e,y:e}),Jw={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Yw(e,t,n){return Ww(e,Uw(t,n))}function Xw(e,t){return typeof e==`function`?e(t):e}function Zw(e){return e.split(`-`)[0]}function Qw(e){return e.split(`-`)[1]}function $w(e){return e===`x`?`y`:`x`}function eT(e){return e===`y`?`height`:`width`}function tT(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function nT(e){return $w(tT(e))}function rT(e,t,n){n===void 0&&(n=!1);let r=Qw(e),i=nT(e),a=eT(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=fT(o)),[o,fT(o)]}function iT(e){let t=fT(e);return[aT(e),t,aT(t)]}function aT(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var oT=[`left`,`right`],sT=[`right`,`left`],cT=[`top`,`bottom`],lT=[`bottom`,`top`];function uT(e,t,n){switch(e){case`top`:case`bottom`:return n?t?sT:oT:t?oT:sT;case`left`:case`right`:return t?cT:lT;default:return[]}}function dT(e,t,n,r){let i=Qw(e),a=uT(Zw(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(aT)))),a}function fT(e){let t=Zw(e);return Jw[t]+e.slice(t.length)}function pT(e){return{top:0,right:0,bottom:0,left:0,...e}}function mT(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:pT(e)}function hT(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function gT(e,t,n){let{reference:r,floating:i}=e,a=tT(t),o=nT(t),s=eT(o),c=Zw(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Qw(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function _T(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Xw(t,e),p=mT(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=hT(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=hT(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var vT=50,yT=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_T},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gT(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<vT&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=gT(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},bT=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Xw(e,t)||{};if(l==null)return{};let d=mT(u),f={x:n,y:r},p=nT(i),m=eT(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Uw(d[_],T),D=Uw(d[v],T),O=E,ee=C-h[m]-D,te=C/2-h[m]/2+w,ne=Yw(O,te,ee),re=!c.arrow&&Qw(i)!=null&&te!==ne&&a.reference[m]/2-(te<O?E:D)-h[m]/2<0,ie=re?te<O?te-O:te-ee:0;return{[p]:f[p]+ie,data:{[p]:ne,centerOffset:te-ne-ie,...re&&{alignmentOffset:ie}},reset:re}}}),xT=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Xw(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Zw(r),_=tT(o),v=Zw(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[fT(o)]:iT(o)),x=p!==`none`;!d&&x&&b.push(...dT(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=rT(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==tT(t))||T.every(e=>tT(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=tT(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ST(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function CT(e){return Hw.some(t=>e[t]>=0)}var wT=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Xw(e,t);switch(i){case`referenceHidden`:{let e=ST(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:CT(e)}}}case`escaped`:{let e=ST(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:CT(e)}}}default:return{}}}}},TT=new Set([`left`,`top`]);async function ET(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Zw(n),s=Qw(n),c=tT(n)===`y`,l=TT.has(o)?-1:1,u=a&&c?-1:1,d=Xw(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var DT=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ET(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},OT=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Xw(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=tT(Zw(i)),p=$w(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Yw(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Yw(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},kT=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Xw(e,t),u={x:n,y:r},d=tT(i),f=$w(d),p=u[f],m=u[d],h=Xw(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=TT.has(Zw(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},AT=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=Xw(e,t),u=await o.detectOverflow(t,l),d=Zw(i),f=Qw(i),p=tT(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Uw(h-u[g],v),x=Uw(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=Ww(u.left,0),t=Ww(u.right,0),n=Ww(u.top,0),r=Ww(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Ww(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Ww(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function jT(){return typeof window<`u`}function MT(e){return FT(e)?(e.nodeName||``).toLowerCase():`#document`}function NT(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function PT(e){return((FT(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function FT(e){return jT()?e instanceof Node||e instanceof NT(e).Node:!1}function IT(e){return jT()?e instanceof Element||e instanceof NT(e).Element:!1}function LT(e){return jT()?e instanceof HTMLElement||e instanceof NT(e).HTMLElement:!1}function RT(e){return!jT()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof NT(e).ShadowRoot}function zT(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=XT(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function BT(e){return/^(table|td|th)$/.test(MT(e))}function VT(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var HT=/transform|translate|scale|rotate|perspective|filter/,UT=/paint|layout|strict|content/,WT=e=>!!e&&e!==`none`,GT;function KT(e){let t=IT(e)?XT(e):e;return WT(t.transform)||WT(t.translate)||WT(t.scale)||WT(t.rotate)||WT(t.perspective)||!JT()&&(WT(t.backdropFilter)||WT(t.filter))||HT.test(t.willChange||``)||UT.test(t.contain||``)}function qT(e){let t=QT(e);for(;LT(t)&&!YT(t);){if(KT(t))return t;if(VT(t))return null;t=QT(t)}return null}function JT(){return GT??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),GT}function YT(e){return/^(html|body|#document)$/.test(MT(e))}function XT(e){return NT(e).getComputedStyle(e)}function ZT(e){return IT(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function QT(e){if(MT(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||RT(e)&&e.host||PT(e);return RT(t)?t.host:t}function $T(e){let t=QT(e);return YT(t)?e.ownerDocument?e.ownerDocument.body:e.body:LT(t)&&zT(t)?t:$T(t)}function eE(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$T(e),i=r===e.ownerDocument?.body,a=NT(r);if(i){let e=tE(a);return t.concat(a,a.visualViewport||[],zT(r)?r:[],e&&n?eE(e):[])}else return t.concat(r,eE(r,[],n))}function tE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nE(e){let t=XT(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=LT(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Gw(n)!==a||Gw(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function rE(e){return IT(e)?e:e.contextElement}function iE(e){let t=rE(e);if(!LT(t))return qw(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=nE(t),o=(a?Gw(n.width):n.width)/r,s=(a?Gw(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var aE=qw(0);function oE(e){let t=NT(e);return!JT()||!t.visualViewport?aE:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sE(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==NT(e)?!1:t}function cE(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=rE(e),o=qw(1);t&&(r?IT(r)&&(o=iE(r)):o=iE(e));let s=sE(a,n,r)?oE(a):qw(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=NT(a),t=r&&IT(r)?NT(r):r,n=e,i=tE(n);for(;i&&r&&t!==n;){let e=iE(i),t=i.getBoundingClientRect(),r=XT(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=NT(i),i=tE(n)}}return hT({width:u,height:d,x:c,y:l})}function lE(e,t){let n=ZT(e).scrollLeft;return t?t.left+n:cE(PT(e)).left+n}function uE(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-lE(e,n),y:n.top+t.scrollTop}}function dE(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=PT(r),s=t?VT(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qw(1),u=qw(0),d=LT(r);if((d||!d&&!a)&&((MT(r)!==`body`||zT(o))&&(c=ZT(r)),d)){let e=cE(r);l=iE(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?uE(o,c):qw(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function fE(e){return Array.from(e.getClientRects())}function pE(e){let t=PT(e),n=ZT(e),r=e.ownerDocument.body,i=Ww(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ww(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+lE(e),s=-n.scrollTop;return XT(r).direction===`rtl`&&(o+=Ww(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var mE=25;function hE(e,t){let n=NT(e),r=PT(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=JT();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=lE(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=mE&&(a-=o)}else l<=mE&&(a+=l);return{width:a,height:o,x:s,y:c}}function gE(e,t){let n=cE(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=LT(e)?iE(e):qw(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _E(e,t,n){let r;if(t===`viewport`)r=hE(e,n);else if(t===`document`)r=pE(PT(e));else if(IT(t))r=gE(t,n);else{let n=oE(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return hT(r)}function vE(e,t){let n=QT(e);return n===t||!IT(n)||YT(n)?!1:XT(n).position===`fixed`||vE(n,t)}function yE(e,t){let n=t.get(e);if(n)return n;let r=eE(e,[],!1).filter(e=>IT(e)&&MT(e)!==`body`),i=null,a=XT(e).position===`fixed`,o=a?QT(e):e;for(;IT(o)&&!YT(o);){let t=XT(o),n=KT(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||zT(o)&&!n&&vE(e,o))?r=r.filter(e=>e!==o):i=t,o=QT(o)}return t.set(e,r),r}function bE(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?VT(t)?[]:yE(t,this._c):[].concat(n),r],o=_E(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=_E(t,a[e],i);s=Ww(n.top,s),c=Uw(n.right,c),l=Uw(n.bottom,l),u=Ww(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function xE(e){let{width:t,height:n}=nE(e);return{width:t,height:n}}function SE(e,t,n){let r=LT(t),i=PT(t),a=n===`fixed`,o=cE(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=qw(0);function l(){c.x=lE(i)}if(r||!r&&!a)if((MT(t)!==`body`||zT(i))&&(s=ZT(t)),r){let e=cE(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?uE(i,s):qw(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function CE(e){return XT(e).position===`static`}function wE(e,t){if(!LT(e)||XT(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return PT(e)===n&&(n=n.ownerDocument.body),n}function TE(e,t){let n=NT(e);if(VT(e))return n;if(!LT(e)){let t=QT(e);for(;t&&!YT(t);){if(IT(t)&&!CE(t))return t;t=QT(t)}return n}let r=wE(e,t);for(;r&&BT(r)&&CE(r);)r=wE(r,t);return r&&YT(r)&&CE(r)&&!KT(r)?n:r||qT(e)||n}var EE=async function(e){let t=this.getOffsetParent||TE,n=this.getDimensions,r=await n(e.floating);return{reference:SE(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DE(e){return XT(e).direction===`rtl`}var OE={convertOffsetParentRelativeRectToViewportRelativeRect:dE,getDocumentElement:PT,getClippingRect:bE,getOffsetParent:TE,getElementRects:EE,getClientRects:fE,getDimensions:xE,getScale:iE,isElement:IT,isRTL:DE};function kE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function AE(e,t){let n=null,r,i=PT(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Kw(d),h=Kw(i.clientWidth-(u+f)),g=Kw(i.clientHeight-(d+p)),_=Kw(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Ww(0,Uw(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!kE(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function jE(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=rE(e),u=i||a?[...l?eE(l):[],...t?eE(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?AE(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?cE(e):null;c&&g();function g(){let t=cE(e);h&&!kE(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ME=DT,NE=OT,PE=xT,FE=AT,IE=wT,LE=bT,RE=kT,zE=(e,t,n)=>{let r=new Map,i={platform:OE,...n},a={...i.platform,_c:r};return yT(e,t,{...i,platform:a})},BE=typeof document<`u`?j.useLayoutEffect:function(){};function VE(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!VE(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!VE(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function HE(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function UE(e,t){let n=HE(e);return Math.round(t*n)/n}function WE(e){let t=j.useRef(e);return BE(()=>{t.current=e}),t}function GE(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=j.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=j.useState(r);VE(f,r)||p(r);let[m,h]=j.useState(null),[g,_]=j.useState(null),v=j.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=j.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=j.useRef(null),C=j.useRef(null),w=j.useRef(u),T=c!=null,E=WE(c),D=WE(i),O=WE(l),ee=j.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),zE(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};te.current&&!VE(w.current,t)&&(w.current=t,Gi.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);BE(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=j.useRef(!1);BE(()=>(te.current=!0,()=>{te.current=!1}),[]),BE(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,ee);ee()}},[b,x,ee,E,T]);let ne=j.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),re=j.useMemo(()=>({reference:b,floating:x}),[b,x]),ie=j.useMemo(()=>{let e={position:n,left:0,top:0};if(!re.floating)return e;let t=UE(re.floating,u.x),r=UE(re.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...HE(re.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,re.floating,u.x,u.y]);return j.useMemo(()=>({...u,update:ee,refs:ne,elements:re,floatingStyles:ie}),[u,ee,ne,re,ie])}var KE=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:LE({element:r.current,padding:i}).fn(n):r?LE({element:r,padding:i}).fn(n):{}}}},qE=(e,t)=>{let n=ME(e);return{name:n.name,fn:n.fn,options:[e,t]}},JE=(e,t)=>{let n=NE(e);return{name:n.name,fn:n.fn,options:[e,t]}},YE=(e,t)=>({fn:RE(e).fn,options:[e,t]}),XE=(e,t)=>{let n=PE(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZE=(e,t)=>{let n=FE(e);return{name:n.name,fn:n.fn,options:[e,t]}},QE=(e,t)=>{let n=IE(e);return{name:n.name,fn:n.fn,options:[e,t]}},$E=(e,t)=>{let n=KE(e);return{name:n.name,fn:n.fn,options:[e,t]}},eD=`Arrow`,tD=j.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,M.jsx)(y_.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,M.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});tD.displayName=eD;var nD=tD;function rD(e){let[t,n]=j.useState(void 0);return R_(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var iD=`Popper`,[aD,oD]=l_(iD),[sD,cD]=aD(iD),lD=e=>{let{__scopePopper:t,children:n}=e,[r,i]=j.useState(null);return(0,M.jsx)(sD,{scope:t,anchor:r,onAnchorChange:i,children:n})};lD.displayName=iD;var uD=`PopperAnchor`,dD=j.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=cD(uD,n),o=j.useRef(null),s=s_(t,o),c=j.useRef(null);return j.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,M.jsx)(y_.div,{...i,ref:s})});dD.displayName=uD;var fD=`PopperContent`,[pD,mD]=aD(fD),hD=j.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=cD(fD,n),[_,v]=j.useState(null),y=s_(t,e=>v(e)),[b,x]=j.useState(null),S=rD(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,ee={padding:E,boundary:D.filter(yD),altBoundary:O},{refs:te,floatingStyles:ne,placement:re,isPositioned:ie,middlewareData:ae}=GE({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>jE(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[qE({mainAxis:i+w,alignmentAxis:o}),c&&JE({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?YE():void 0,...ee}),c&&XE({...ee}),ZE({...ee,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&$E({element:b,padding:s}),bD({arrowWidth:C,arrowHeight:w}),f&&QE({strategy:`referenceHidden`,...ee})]}),[oe,k]=xD(re),se=x_(m);R_(()=>{ie&&se?.()},[ie,se]);let ce=ae.arrow?.x,le=ae.arrow?.y,ue=ae.arrow?.centerOffset!==0,[A,de]=j.useState();return R_(()=>{_&&de(window.getComputedStyle(_).zIndex)},[_]),(0,M.jsx)(`div`,{ref:te.setFloating,"data-radix-popper-content-wrapper":``,style:{...ne,transform:ie?ne.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:A,"--radix-popper-transform-origin":[ae.transformOrigin?.x,ae.transformOrigin?.y].join(` `),...ae.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,M.jsx)(pD,{scope:n,placedSide:oe,onArrowChange:x,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,M.jsx)(y_.div,{"data-side":oe,"data-align":k,...h,ref:y,style:{...h.style,animation:ie?void 0:`none`}})})})});hD.displayName=fD;var gD=`PopperArrow`,_D={top:`bottom`,right:`left`,bottom:`top`,left:`right`},vD=j.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=mD(gD,n),a=_D[i.placedSide];return(0,M.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,M.jsx)(nD,{...r,ref:t,style:{...r.style,display:`block`}})})});vD.displayName=gD;function yD(e){return e!==null}var bD=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=xD(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function xD(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var SD=lD,CD=dD,wD=hD,TD=vD,[ED,DD]=l_(`Tooltip`,[oD]),OD=oD(),kD=`TooltipProvider`,AD=700,jD=`tooltip.open`,[MD,ND]=ED(kD),PD=e=>{let{__scopeTooltip:t,delayDuration:n=AD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=j.useRef(!0),s=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,M.jsx)(MD,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:j.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};PD.displayName=kD;var FD=`Tooltip`,[ID,LD]=ED(FD),RD=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=ND(FD,e.__scopeTooltip),l=OD(t),[u,d]=j.useState(null),f=sS(),p=j.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=j.useRef(!1),[_,v]=q_({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(jD))):c.onClose(),a?.(e)},caller:FD}),y=j.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return j.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,M.jsx)(SD,{...l,children:(0,M.jsx)(ID,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:j.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};RD.displayName=FD;var zD=`TooltipTrigger`,BD=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=LD(zD,n),a=ND(zD,n),o=OD(n),s=s_(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,M.jsx)(CD,{asChild:!0,...o,children:(0,M.jsx)(y_.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:J(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:J(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:J(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:J(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:J(e.onBlur,i.onClose),onClick:J(e.onClick,i.onClose)})})});BD.displayName=zD;var VD=`TooltipPortal`,[HD,UD]=ED(VD,{forceMount:void 0}),WD=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=LD(VD,t);return(0,M.jsx)(HD,{scope:t,forceMount:n,children:(0,M.jsx)(H_,{present:n||a.open,children:(0,M.jsx)(B_,{asChild:!0,container:i,children:r})})})};WD.displayName=VD;var GD=`TooltipContent`,KD=j.forwardRef((e,t)=>{let n=UD(GD,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=LD(GD,e.__scopeTooltip);return(0,M.jsx)(H_,{present:r||o.open,children:o.disableHoverableContent?(0,M.jsx)(ZD,{side:i,...a,ref:t}):(0,M.jsx)(qD,{side:i,...a,ref:t})})}),qD=j.forwardRef((e,t)=>{let n=LD(GD,e.__scopeTooltip),r=ND(GD,e.__scopeTooltip),i=j.useRef(null),a=s_(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=tO(r,eO(r,n.getBoundingClientRect())),a=nO(t.getBoundingClientRect());s(iO([...i,...a])),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!rO(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,M.jsx)(ZD,{...e,ref:a})}),[JD,YD]=ED(FD,{isInside:!1}),XD=m_(`TooltipContent`),ZD=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=LD(GD,n),l=OD(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(jD,u),()=>document.removeEventListener(jD,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,M.jsx)(k_,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,M.jsxs)(wD,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.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:[(0,M.jsx)(XD,{children:r}),(0,M.jsx)(JD,{scope:n,isInside:!0,children:(0,M.jsx)($_,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});KD.displayName=GD;var QD=`TooltipArrow`,$D=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=OD(n);return YD(QD,n).isInside?null:(0,M.jsx)(TD,{...i,...r,ref:t})});$D.displayName=QD;function eO(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function tO(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function nO(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function rO(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function iO(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),aO(t)}function aO(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var oO=PD,sO=RD,cO=BD,lO=KD,uO=oO,dO=sO,fO=cO,pO=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,M.jsx)(lO,{ref:r,sideOffset:t,className:Z(`z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n}));pO.displayName=lO.displayName;var mO=`sidebar_state`,hO=3600*24*7,gO=`16rem`,_O=`18rem`,vO=`3rem`,yO=`b`,bO=j.createContext(null);function xO(){let e=j.useContext(bO);if(!e)throw Error(`useSidebar must be used within a SidebarProvider`);return e}var SO=j.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o},s)=>{let c=Jx(),[l,u]=j.useState(!1),[d,f]=j.useState(e),p=t??d,m=j.useCallback(e=>{let t=typeof e==`function`?e(p):e;n?n(t):f(t),document.cookie=`${mO}=${t}; path=/; max-age=${hO}`},[n,p]),h=j.useCallback(()=>c?u(e=>!e):m(e=>!e),[c,m,u]);j.useEffect(()=>{let e=e=>{e.key===yO&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]);let g=p?`expanded`:`collapsed`,_=j.useMemo(()=>({state:g,open:p,setOpen:m,isMobile:c,openMobile:l,setOpenMobile:u,toggleSidebar:h}),[g,p,m,c,l,u,h]);return(0,M.jsx)(bO.Provider,{value:_,children:(0,M.jsx)(uO,{delayDuration:0,children:(0,M.jsx)(`div`,{style:{"--sidebar-width":gO,"--sidebar-width-icon":vO,...i},className:Z(`group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-0 w-full`,r),ref:s,...o,children:a})})})});SO.displayName=`SidebarProvider`;var CO=j.forwardRef(({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a},o)=>{let{isMobile:s,state:c,openMobile:l,setOpenMobile:u}=xO();return n===`none`?(0,M.jsx)(`div`,{className:Z(`bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col`,r),ref:o,...a,children:i}):s?(0,M.jsx)(Mw,{open:l,onOpenChange:u,...a,children:(0,M.jsx)(Iw,{"data-sidebar":`sidebar`,"data-mobile":`true`,className:`bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden`,style:{"--sidebar-width":_O},side:e,children:(0,M.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})})}):(0,M.jsx)(`div`,{ref:o,className:Z(`bg-sidebar text-sidebar-foreground hidden md:flex h-svh w-[var(--sidebar-width)] shrink-0 flex-col border-r transition-[width] duration-200 ease-linear overflow-hidden`,c===`collapsed`&&n===`offcanvas`&&`w-0 border-0`,c===`collapsed`&&n===`icon`&&`w-[var(--sidebar-width-icon)]`,r),"data-state":c,"data-collapsible":c===`collapsed`?n:``,"data-variant":t,"data-side":e,...a,children:i})});CO.displayName=`Sidebar`;var wO=j.forwardRef(({className:e,onClick:t,...n},r)=>{let{toggleSidebar:i}=xO();return(0,M.jsxs)(Q,{ref:r,"data-sidebar":`trigger`,variant:`ghost`,size:`icon`,className:Z(`h-7 w-7`,e),onClick:e=>{t?.(e),i()},...n,children:[(0,M.jsx)(Iy,{}),(0,M.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})});wO.displayName=`SidebarTrigger`;var TO=j.forwardRef(({className:e,...t},n)=>{let{toggleSidebar:r}=xO();return(0,M.jsx)(`button`,{ref:n,"data-sidebar":`rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onClick:r,title:`Toggle Sidebar`,className:Z(`hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex`,`[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,e),...t})});TO.displayName=`SidebarRail`;var EO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`main`,{ref:n,className:Z(`relative flex min-h-svh flex-1 flex-col bg-background`,`peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow`,e),...t}));EO.displayName=`SidebarInset`;var DO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Xx,{ref:n,"data-sidebar":`input`,className:Z(`h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring`,e),...t}));DO.displayName=`SidebarInput`;var OO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`header`,className:Z(`flex flex-col gap-2 p-2`,e),...t}));OO.displayName=`SidebarHeader`;var kO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`footer`,className:Z(`flex flex-col gap-2 p-2`,e),...t}));kO.displayName=`SidebarFooter`;var AO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(iS,{ref:n,"data-sidebar":`separator`,className:Z(`mx-2 w-auto bg-sidebar-border`,e),...t}));AO.displayName=`SidebarSeparator`;var jO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`content`,className:Z(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto`,e),...t}));jO.displayName=`SidebarContent`;var MO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`group`,className:Z(`relative flex w-full min-w-0 flex-col p-2`,e),...t}));MO.displayName=`SidebarGroup`;var NO=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,M.jsx)(t?Vx:`div`,{ref:r,"data-sidebar":`group-label`,className:Z(`text-xs/6 font-medium text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 outline-none transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 [[data-collapsible=icon]_&]:-mt-8 [[data-collapsible=icon]_&]:opacity-0 [[data-collapsible=icon]_&]:overflow-hidden`,e),...n}));NO.displayName=`SidebarGroupLabel`;var PO=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>(0,M.jsx)(t?Vx:`button`,{ref:r,"data-sidebar":`group-action`,className:Z(`absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:md:hidden`,`group-data-[collapsible=icon]:hidden`,e),...n}));PO.displayName=`SidebarGroupAction`;var FO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`group-content`,className:Z(`w-full text-sm`,e),...t}));FO.displayName=`SidebarGroupContent`;var IO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ul`,{ref:n,"data-sidebar":`menu`,className:Z(`flex w-full min-w-0 flex-col gap-1`,e),...t}));IO.displayName=`SidebarMenu`;var LO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`li`,{ref:n,"data-sidebar":`menu-item`,className:Z(`group/menu-item relative`,e),...t}));LO.displayName=`SidebarMenuItem`;var RO=j.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o},s)=>{let c=e?Vx:`button`,{isMobile:l,state:u}=xO(),d=(0,M.jsx)(c,{ref:s,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:Z(zO({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,M.jsxs)(dO,{children:[(0,M.jsx)(fO,{asChild:!0,children:d}),(0,M.jsx)(pO,{side:`right`,align:`center`,hidden:u!==`collapsed`||l,...i})]})):d});RO.displayName=`SidebarMenuButton`;var zO=$v(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:!p-0`}},defaultVariants:{variant:`default`,size:`default`}}),BO=j.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>(0,M.jsx)(t?Vx:`button`,{ref:i,"data-sidebar":`menu-action`,className:Z(`absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`after:absolute after:-inset-2 after:md:hidden`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,n&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0`,e),...r}));BO.displayName=`SidebarMenuAction`;var VO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,"data-sidebar":`menu-badge`,className:Z(`text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));VO.displayName=`SidebarMenuBadge`;var HO=j.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{let i=j.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return(0,M.jsxs)(`div`,{ref:r,"data-sidebar":`menu-skeleton`,className:Z(`rounded-md h-8 flex gap-2 px-2 items-center`,e),...n,children:[t&&(0,M.jsx)(Vw,{className:`size-4 rounded-md`,"data-sidebar":`menu-skeleton-icon`}),(0,M.jsx)(Vw,{className:`h-4 flex-1 max-w-[var(--skeleton-width)]`,"data-sidebar":`menu-skeleton-text`,style:{"--skeleton-width":i}})]})});HO.displayName=`SidebarMenuSkeleton`;var UO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ul`,{ref:n,"data-sidebar":`menu-sub`,className:Z(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t}));UO.displayName=`SidebarMenuSub`;var WO=j.forwardRef(({...e},t)=>(0,M.jsx)(`li`,{ref:t,...e}));WO.displayName=`SidebarMenuSubItem`;var GO=j.forwardRef(({asChild:e=!1,size:t=`md`,isActive:n,className:r,...i},a)=>(0,M.jsx)(e?Vx:`a`,{ref:a,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:Z(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,r),...i}));GO.displayName=`SidebarMenuSubButton`;var KO=$v(`text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5`),qO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`nav`,{ref:n,"aria-label":`breadcrumb`,className:Z(KO(),e),...t}));qO.displayName=`Breadcrumb`;var JO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`ol`,{ref:n,className:Z(`text-muted-foreground flex flex-wrap items-center gap-1.5 break-words text-sm sm:gap-2.5`,e),...t}));JO.displayName=`BreadcrumbList`;var YO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`li`,{ref:n,className:Z(`inline-flex items-center gap-1.5`,e),...t}));YO.displayName=`BreadcrumbItem`;var XO=j.forwardRef(({asChild:e,className:t,...n},r)=>(0,M.jsx)(e?Vx:`a`,{ref:r,className:Z(`hover:text-foreground transition-colors`,t),...n}));XO.displayName=`BreadcrumbLink`;var ZO=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`span`,{ref:n,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:Z(`text-foreground font-normal`,e),...t}));ZO.displayName=`BreadcrumbPage`;var QO=({children:e,className:t,...n})=>(0,M.jsx)(`li`,{role:`presentation`,"aria-hidden":`true`,className:Z(`[&>svg]:size-3.5`,t),...n,children:e??(0,M.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:(0,M.jsx)(`path`,{d:`m9 18 6-6-6-6`})})});QO.displayName=`BreadcrumbSeparator`;var $O=({className:e,...t})=>(0,M.jsxs)(`span`,{role:`presentation`,"aria-hidden":`true`,className:Z(`flex h-9 w-9 items-center justify-center`,e),...t,children:[(0,M.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,children:[(0,M.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,M.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1`}),(0,M.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1`})]}),(0,M.jsx)(`span`,{className:`sr-only`,children:`More`})]});$O.displayName=`BreadcrumbElipssis`;var ek=j.createContext(void 0);function tk(e){let t=j.useContext(ek);return e||t||`ltr`}var nk=`rovingFocusGroup.onEntryFocus`,rk={bubbles:!1,cancelable:!0},ik=`RovingFocusGroup`,[ak,ok,sk]=v_(ik),[ck,lk]=l_(ik,[sk]),[uk,dk]=ck(ik),fk=j.forwardRef((e,t)=>(0,M.jsx)(ak.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(ak.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(pk,{...e,ref:t})})}));fk.displayName=ik;var pk=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=j.useRef(null),p=s_(t,f),m=tk(a),[h,g]=q_({prop:o,defaultProp:s??null,onChange:c,caller:ik}),[_,v]=j.useState(!1),y=x_(l),b=ok(n),x=j.useRef(!1),[S,C]=j.useState(0);return j.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(nk,y),()=>e.removeEventListener(nk,y)},[y]),(0,M.jsx)(uk,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:j.useCallback(e=>g(e),[g]),onItemShiftTab:j.useCallback(()=>v(!0),[]),onFocusableItemAdd:j.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:j.useCallback(()=>C(e=>e-1),[]),children:(0,M.jsx)(y_.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{x.current=!0}),onFocus:J(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(nk,rk);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);yk([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:J(e.onBlur,()=>v(!1))})})}),mk=`RovingFocusGroupItem`,hk=j.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=sS(),l=a||c,u=dk(mk,n),d=u.currentTabStopId===l,f=ok(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return j.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,M.jsx)(ak.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,M.jsx)(y_.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=vk(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?bk(n,r+1):n.slice(r+1)}setTimeout(()=>yk(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});hk.displayName=mk;var gk={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function _k(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function vk(e,t,n){let r=_k(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return gk[r]}function yk(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function bk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xk=fk,Sk=hk,Ck=[`Enter`,` `],wk=[`ArrowDown`,`PageUp`,`Home`],Tk=[`ArrowUp`,`PageDown`,`End`],Ek=[...wk,...Tk],Dk={ltr:[...Ck,`ArrowRight`],rtl:[...Ck,`ArrowLeft`]},Ok={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},kk=`Menu`,[Ak,jk,Mk]=v_(kk),[Nk,Pk]=l_(kk,[Mk,oD,lk]),Fk=oD(),Ik=lk(),[Lk,Rk]=Nk(kk),[zk,Bk]=Nk(kk),Vk=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Fk(t),[c,l]=j.useState(null),u=j.useRef(!1),d=x_(a),f=tk(i);return j.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,M.jsx)(SD,{...s,children:(0,M.jsx)(Lk,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,M.jsx)(zk,{scope:t,onClose:j.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Vk.displayName=kk;var Hk=`MenuAnchor`,Uk=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Fk(n);return(0,M.jsx)(CD,{...i,...r,ref:t})});Uk.displayName=Hk;var Wk=`MenuPortal`,[Gk,Kk]=Nk(Wk,{forceMount:void 0}),qk=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Rk(Wk,t);return(0,M.jsx)(Gk,{scope:t,forceMount:n,children:(0,M.jsx)(H_,{present:n||a.open,children:(0,M.jsx)(B_,{asChild:!0,container:i,children:r})})})};qk.displayName=Wk;var Jk=`MenuContent`,[Yk,Xk]=Nk(Jk),Zk=j.forwardRef((e,t)=>{let n=Kk(Jk,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Rk(Jk,e.__scopeMenu),o=Bk(Jk,e.__scopeMenu);return(0,M.jsx)(Ak.Provider,{scope:e.__scopeMenu,children:(0,M.jsx)(H_,{present:r||a.open,children:(0,M.jsx)(Ak.Slot,{scope:e.__scopeMenu,children:o.modal?(0,M.jsx)(Qk,{...i,ref:t}):(0,M.jsx)($k,{...i,ref:t})})})})}),Qk=j.forwardRef((e,t)=>{let n=Rk(Jk,e.__scopeMenu),r=j.useRef(null),i=s_(t,r);return j.useEffect(()=>{let e=r.current;if(e)return WC(e)},[]),(0,M.jsx)(tA,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$k=j.forwardRef((e,t)=>{let n=Rk(Jk,e.__scopeMenu);return(0,M.jsx)(tA,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),eA=d_(`MenuContent.ScrollLock`),tA=j.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Rk(Jk,n),_=Bk(Jk,n),v=Fk(n),y=Ik(n),b=jk(n),[x,S]=j.useState(null),C=j.useRef(null),w=s_(t,C,g.onContentChange),T=j.useRef(0),E=j.useRef(``),D=j.useRef(0),O=j.useRef(null),ee=j.useRef(`right`),te=j.useRef(0),ne=m?FC:j.Fragment,re=m?{as:eA,allowPinchZoom:!0}:void 0,ie=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=zA(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};j.useEffect(()=>()=>window.clearTimeout(T.current),[]),TS();let ae=j.useCallback(e=>ee.current===O.current?.side&&VA(e,O.current?.area),[]);return(0,M.jsx)(Yk,{scope:n,searchRef:E,onItemEnter:j.useCallback(e=>{ae(e)&&e.preventDefault()},[ae]),onItemLeave:j.useCallback(e=>{ae(e)||(C.current?.focus(),S(null))},[ae]),onTriggerLeave:j.useCallback(e=>{ae(e)&&e.preventDefault()},[ae]),pointerGraceTimerRef:D,onPointerGraceIntentChange:j.useCallback(e=>{O.current=e},[]),children:(0,M.jsx)(ne,{...re,children:(0,M.jsx)(fS,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,M.jsx)(k_,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,M.jsx)(xk,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,M.jsx)(wD,{role:`menu`,"aria-orientation":`vertical`,"data-state":PA(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ie(e.key));let i=C.current;if(e.target!==i||!Ek.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Tk.includes(e.key)&&a.reverse(),LA(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:J(e.onPointerMove,HA(e=>{let t=e.target,n=te.current!==e.clientX;e.currentTarget.contains(t)&&n&&(ee.current=e.clientX>te.current?`right`:`left`,te.current=e.clientX)}))})})})})})})});Zk.displayName=Jk;var nA=`MenuGroup`,rA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{role:`group`,...r,ref:t})});rA.displayName=nA;var iA=`MenuLabel`,aA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{...r,ref:t})});aA.displayName=iA;var oA=`MenuItem`,sA=`menu.itemSelect`,cA=j.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=j.useRef(null),o=Bk(oA,e.__scopeMenu),s=Xk(oA,e.__scopeMenu),c=s_(t,a),l=j.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(sA,{bubbles:!0,cancelable:!0});e.addEventListener(sA,e=>r?.(e),{once:!0}),b_(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,M.jsx)(lA,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Ck.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});cA.displayName=oA;var lA=j.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Xk(oA,n),s=Ik(n),c=j.useRef(null),l=s_(t,c),[u,d]=j.useState(!1),[f,p]=j.useState(``);return j.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,M.jsx)(Ak.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,M.jsx)(Sk,{asChild:!0,...s,focusable:!r,children:(0,M.jsx)(y_.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,HA(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,HA(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})}),uA=`MenuCheckboxItem`,dA=j.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,M.jsx)(yA,{scope:e.__scopeMenu,checked:n,children:(0,M.jsx)(cA,{role:`menuitemcheckbox`,"aria-checked":FA(n)?`mixed`:n,...i,ref:t,"data-state":IA(n),onSelect:J(i.onSelect,()=>r?.(FA(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dA.displayName=uA;var fA=`MenuRadioGroup`,[pA,mA]=Nk(fA,{value:void 0,onValueChange:()=>{}}),hA=j.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=x_(r);return(0,M.jsx)(pA,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,M.jsx)(rA,{...i,ref:t})})});hA.displayName=fA;var gA=`MenuRadioItem`,_A=j.forwardRef((e,t)=>{let{value:n,...r}=e,i=mA(gA,e.__scopeMenu),a=n===i.value;return(0,M.jsx)(yA,{scope:e.__scopeMenu,checked:a,children:(0,M.jsx)(cA,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":IA(a),onSelect:J(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});_A.displayName=gA;var vA=`MenuItemIndicator`,[yA,bA]=Nk(vA,{checked:!1}),xA=j.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=bA(vA,n);return(0,M.jsx)(H_,{present:r||FA(a.checked)||a.checked===!0,children:(0,M.jsx)(y_.span,{...i,ref:t,"data-state":IA(a.checked)})})});xA.displayName=vA;var SA=`MenuSeparator`,CA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,M.jsx)(y_.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});CA.displayName=SA;var wA=`MenuArrow`,TA=j.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Fk(n);return(0,M.jsx)(TD,{...i,...r,ref:t})});TA.displayName=wA;var EA=`MenuSub`,[DA,OA]=Nk(EA),kA=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Rk(EA,t),o=Fk(t),[s,c]=j.useState(null),[l,u]=j.useState(null),d=x_(i);return j.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,M.jsx)(SD,{...o,children:(0,M.jsx)(Lk,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,M.jsx)(DA,{scope:t,contentId:sS(),triggerId:sS(),trigger:s,onTriggerChange:c,children:n})})})};kA.displayName=EA;var AA=`MenuSubTrigger`,jA=j.forwardRef((e,t)=>{let n=Rk(AA,e.__scopeMenu),r=Bk(AA,e.__scopeMenu),i=OA(AA,e.__scopeMenu),a=Xk(AA,e.__scopeMenu),o=j.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=j.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return j.useEffect(()=>u,[u]),j.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,M.jsx)(Uk,{asChild:!0,...l,children:(0,M.jsx)(lA,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":PA(n.open),...e,ref:o_(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:J(e.onPointerMove,HA(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:J(e.onPointerLeave,HA(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:J(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Dk[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});jA.displayName=AA;var MA=`MenuSubContent`,NA=j.forwardRef((e,t)=>{let n=Kk(Jk,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Rk(Jk,e.__scopeMenu),o=Bk(Jk,e.__scopeMenu),s=OA(MA,e.__scopeMenu),c=j.useRef(null),l=s_(t,c);return(0,M.jsx)(Ak.Provider,{scope:e.__scopeMenu,children:(0,M.jsx)(H_,{present:r||a.open,children:(0,M.jsx)(Ak.Slot,{scope:e.__scopeMenu,children:(0,M.jsx)(tA,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:J(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:J(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:J(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Ok[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});NA.displayName=MA;function PA(e){return e?`open`:`closed`}function FA(e){return e===`indeterminate`}function IA(e){return FA(e)?`indeterminate`:e?`checked`:`unchecked`}function LA(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function RA(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function zA(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=RA(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function BA(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function VA(e,t){return t?BA({x:e.clientX,y:e.clientY},t):!1}function HA(e){return t=>t.pointerType===`mouse`?e(t):void 0}var UA=Vk,WA=Uk,GA=qk,KA=Zk,qA=rA,JA=aA,YA=cA,XA=dA,ZA=hA,QA=_A,$A=xA,ej=CA,tj=TA,nj=jA,rj=NA,ij=`DropdownMenu`,[aj,oj]=l_(ij,[Pk]),sj=Pk(),[cj,lj]=aj(ij),uj=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=sj(t),l=j.useRef(null),[u,d]=q_({prop:i,defaultProp:a??!1,onChange:o,caller:ij});return(0,M.jsx)(cj,{scope:t,triggerId:sS(),triggerRef:l,contentId:sS(),open:u,onOpenChange:d,onOpenToggle:j.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,M.jsx)(UA,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};uj.displayName=ij;var dj=`DropdownMenuTrigger`,fj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=lj(dj,n),o=sj(n);return(0,M.jsx)(WA,{asChild:!0,...o,children:(0,M.jsx)(y_.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:o_(t,a.triggerRef),onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fj.displayName=dj;var pj=`DropdownMenuPortal`,mj=e=>{let{__scopeDropdownMenu:t,...n}=e,r=sj(t);return(0,M.jsx)(GA,{...r,...n})};mj.displayName=pj;var hj=`DropdownMenuContent`,gj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=lj(hj,n),a=sj(n),o=j.useRef(!1);return(0,M.jsx)(KA,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gj.displayName=hj;var _j=`DropdownMenuGroup`,vj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(qA,{...i,...r,ref:t})});vj.displayName=_j;var yj=`DropdownMenuLabel`,bj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(JA,{...i,...r,ref:t})});bj.displayName=yj;var xj=`DropdownMenuItem`,Sj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(YA,{...i,...r,ref:t})});Sj.displayName=xj;var Cj=`DropdownMenuCheckboxItem`,wj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(XA,{...i,...r,ref:t})});wj.displayName=Cj;var Tj=`DropdownMenuRadioGroup`,Ej=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(ZA,{...i,...r,ref:t})});Ej.displayName=Tj;var Dj=`DropdownMenuRadioItem`,Oj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(QA,{...i,...r,ref:t})});Oj.displayName=Dj;var kj=`DropdownMenuItemIndicator`,Aj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)($A,{...i,...r,ref:t})});Aj.displayName=kj;var jj=`DropdownMenuSeparator`,Mj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(ej,{...i,...r,ref:t})});Mj.displayName=jj;var Nj=`DropdownMenuArrow`,Pj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(tj,{...i,...r,ref:t})});Pj.displayName=Nj;var Fj=`DropdownMenuSubTrigger`,Ij=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(nj,{...i,...r,ref:t})});Ij.displayName=Fj;var Lj=`DropdownMenuSubContent`,Rj=j.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=sj(n);return(0,M.jsx)(rj,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rj.displayName=Lj;var zj=uj,Bj=fj,Vj=mj,Hj=gj,Uj=bj,Wj=Sj,Gj=wj,Kj=Oj,qj=Aj,Jj=Mj,Yj=Ij,Xj=Rj,Zj=zj,Qj=Bj,$j=j.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,M.jsxs)(Yj,{ref:i,className:Z(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,M.jsx)(my,{className:`ml-auto`})]}));$j.displayName=Yj.displayName;var eM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Xj,{ref:n,className:Z(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));eM.displayName=Xj.displayName;var tM=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,M.jsx)(Vj,{children:(0,M.jsx)(Hj,{ref:r,sideOffset:t,className:Z(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tM.displayName=Hj.displayName;var nM=j.forwardRef(({className:e,inset:t,...n},r)=>(0,M.jsx)(Wj,{ref:r,className:Z(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));nM.displayName=Wj.displayName;var rM=j.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,M.jsxs)(Gj,{ref:i,className:Z(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,M.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,M.jsx)(qj,{children:(0,M.jsx)(fy,{className:`h-4 w-4`})})}),t]}));rM.displayName=Gj.displayName;var iM=j.forwardRef(({className:e,children:t,...n},r)=>(0,M.jsxs)(Kj,{ref:r,className:Z(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,M.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,M.jsx)(qj,{children:(0,M.jsx)(by,{className:`h-2 w-2 fill-current`})})}),t]}));iM.displayName=Kj.displayName;var aM=j.forwardRef(({className:e,inset:t,...n},r)=>(0,M.jsx)(Uj,{ref:r,className:Z(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));aM.displayName=Uj.displayName;var oM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Jj,{ref:n,className:Z(`-mx-1 my-1 h-px bg-muted`,e),...t}));oM.displayName=Jj.displayName;var sM=({className:e,...t})=>(0,M.jsx)(`span`,{className:Z(`ml-auto text-xs tracking-widest opacity-60`,e),...t});sM.displayName=`DropdownMenuShortcut`;var cM=`modulepreload`,lM=function(e){return`/_account/`+e},uM={},dM=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=lM(t,n),t in uM)return;uM[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:cM,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},fM=[`en`,`zh-CN`],pM={en:()=>dM(()=>import(`./en-BM3I2v7J.js`),[]),"zh-CN":()=>dM(()=>import(`./zh-CN-f2PfHJHM.js`),[])};function mM(e){return fM.includes(e)?e:e.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`}async function hM(e){let t=mM(e);try{return(await pM[t]()).default}catch(t){return console.warn(`[account/i18n] Failed to load language pack '${e}':`,t),{}}}var gM={en:`English`,"zh-CN":`中文`};function _M(){let{t:e,language:t,changeLanguage:n}=vt();async function r(e){await n(e);try{localStorage.setItem(`account.lang`,e)}catch{}}return(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,"aria-label":e(`common.language`),children:[(0,M.jsx)(ky,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{className:`sr-only`,children:e(`common.language`)})]})}),(0,M.jsx)(tM,{align:`end`,children:fM.map(e=>(0,M.jsx)(nM,{onSelect:()=>void r(e),className:e===t?`font-medium`:void 0,children:gM[e]},e))})]})}function vM(e){let t=document.documentElement;e===`dark`?t.classList.add(`dark`):t.classList.remove(`dark`)}function yM(){let{t:e}=vt(),[,t]=(0,j.useState)(`light`);(0,j.useEffect)(()=>{let e=localStorage.getItem(`theme`);e?(t(e),vM(e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e)):(t(`system`),vM(window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`))},[]);function n(e){t(e),localStorage.setItem(`theme`,e),vM(e===`system`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e)}return(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,M.jsx)(Wy,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),(0,M.jsx)(Fy,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),(0,M.jsx)(`span`,{className:`sr-only`,children:e(`common.toggleTheme`)})]})}),(0,M.jsxs)(tM,{align:`end`,children:[(0,M.jsxs)(nM,{onClick:()=>n(`light`),children:[(0,M.jsx)(Wy,{className:`mr-2 h-4 w-4`}),e(`common.light`)]}),(0,M.jsxs)(nM,{onClick:()=>n(`dark`),children:[(0,M.jsx)(Fy,{className:`mr-2 h-4 w-4`}),e(`common.dark`)]}),(0,M.jsx)(nM,{onClick:()=>n(`system`),children:e(`common.system`)})]})]})}function bM(e,t=[]){let n=[];function r(t,r){let i=j.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=j.useMemo(()=>o,Object.values(o));return(0,M.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=j.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>j.createContext(e));return function(n){let r=n?.[e]||t;return j.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,xM(i,...t)]}function xM(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function SM(){return(0,ot.useSyncExternalStore)(CM,()=>!0,()=>!1)}function CM(){return()=>{}}var wM=`Avatar`,[TM,EM]=bM(wM),[DM,OM]=TM(wM),kM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,...r}=e,[i,a]=j.useState(`idle`);return(0,M.jsx)(DM,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:a,children:(0,M.jsx)(Zx.span,{...r,ref:t})})});kM.displayName=wM;var AM=`AvatarImage`,jM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,src:r,onLoadingStatusChange:i=()=>{},...a}=e,o=OM(AM,n),s=FM(r,a),c=x_(e=>{i(e),o.onImageLoadingStatusChange(e)});return R_(()=>{s!==`idle`&&c(s)},[s,c]),s===`loaded`?(0,M.jsx)(Zx.img,{...a,ref:t,src:r}):null});jM.displayName=AM;var MM=`AvatarFallback`,NM=j.forwardRef((e,t)=>{let{__scopeAvatar:n,delayMs:r,...i}=e,a=OM(MM,n),[o,s]=j.useState(r===void 0);return j.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,M.jsx)(Zx.span,{...i,ref:t}):null});NM.displayName=MM;function PM(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?`loaded`:`loading`):`error`:`idle`}function FM(e,{referrerPolicy:t,crossOrigin:n}){let r=SM(),i=j.useRef(null),a=r?(i.current||=new window.Image,i.current):null,[o,s]=j.useState(()=>PM(a,e));return R_(()=>{s(PM(a,e))},[a,e]),R_(()=>{let e=e=>()=>{s(e)};if(!a)return;let r=e(`loaded`),i=e(`error`);return a.addEventListener(`load`,r),a.addEventListener(`error`,i),t&&(a.referrerPolicy=t),typeof n==`string`&&(a.crossOrigin=n),()=>{a.removeEventListener(`load`,r),a.removeEventListener(`error`,i)}},[a,n,t]),o}var IM=kM,LM=jM,RM=NM,zM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(IM,{ref:n,className:Z(`relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...t}));zM.displayName=IM.displayName;var BM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(LM,{ref:n,className:Z(`aspect-square h-full w-full`,e),...t}));BM.displayName=LM.displayName;var VM=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(RM,{ref:n,className:Z(`flex h-full w-full items-center justify-center rounded-full bg-muted`,e),...t}));VM.displayName=RM.displayName;var HM=(0,j.createContext)(null),UM=`auth-session-token`,WM=`auth-active-organization-id`;function GM(e){if(!(typeof window>`u`))try{e?.token?localStorage.setItem(UM,e.token):localStorage.removeItem(UM),e?.activeOrganizationId?localStorage.setItem(WM,e.activeOrganizationId):localStorage.removeItem(WM)}catch{}}function KM(e){if(!e)return{user:null,session:null};let t=e.data===void 0?e:e.data;return t?{user:t.user??null,session:t.session??null}:{user:null,session:null}}function qM({children:e}){let t=qg(),[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)([]),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(null);(0,j.useEffect)(()=>{if(!t?.auth?.getConfig)return;let e=!1;return t.auth.getConfig().then(t=>{e||_(t?.features??t?.data?.features??null)}).catch(()=>{e||_(null)}),()=>{e=!0}},[t]);let v=(0,j.useCallback)(async()=>{if(t?.organizations){p(!0);try{d((await t.organizations.list())?.organizations??[])}catch{d([])}finally{p(!1),h(!0)}}},[t]),y=(0,j.useCallback)(async()=>{if(t?.auth){s(!0),l(null);try{let{user:e,session:n}=KM(await t.auth.me());r(e),a(n),GM(e?n:null)}catch(e){l(e),r(null),a(null),GM(null)}finally{s(!1)}}},[t]);(0,j.useEffect)(()=>{y()},[y]),(0,j.useEffect)(()=>{n?v():(d([]),h(!1))},[n,v]);let b=(0,j.useCallback)(async()=>{if(t?.auth)try{await t.auth.logout()}finally{r(null),a(null),d([]),h(!1),GM(null)}},[t]),x=(0,j.useCallback)(async e=>{if(t?.organizations){await t.organizations.setActive(e),await y();try{localStorage.setItem(WM,e)}catch{}}},[t,y]),S=(0,j.useMemo)(()=>({user:n,session:i,loading:o,error:c,refresh:y,logout:b,setActiveOrganization:x,organizations:u,organizationsLoading:f,organizationsFetched:m,reloadOrganizations:v,features:g}),[n,i,o,c,y,b,x,u,f,m,v,g]);return(0,j.createElement)(HM.Provider,{value:S},e)}function JM(){let e=(0,j.useContext)(HM);if(!e)throw Error(`useSession must be used inside <SessionProvider>.`);return e}function YM(){let{organizations:e,organizationsLoading:t,reloadOrganizations:n}=JM();return{organizations:e,loading:t,error:null,reload:n}}function XM(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{create:(0,j.useCallback)(async t=>{if(!e?.organizations)throw Error(`Client not ready`);n(!0),i(null);try{return await e.organizations.create(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),creating:t,error:r}}function ZM(){let e=qg(),{reloadOrganizations:t,refresh:n}=JM(),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);return{update:(0,j.useCallback)(async(r,a)=>{if(!e?.organizations?.update)throw Error(`Client not ready`);i(!0),o(null);try{let i=await e.organizations.update(r,a);return await t(),await n(),i}catch(e){throw o(e),e}finally{i(!1)}},[e,t,n]),updating:r,error:a}}function QM(){let e=qg(),{reloadOrganizations:t,refresh:n}=JM(),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null);return{remove:(0,j.useCallback)(async r=>{if(!e?.organizations?.delete)throw Error(`Client not ready`);i(!0),o(null);try{let i=await e.organizations.delete(r);return await t(),await n(),i}catch(e){throw o(e),e}finally{i(!1)}},[e,t,n]),deleting:r,error:a}}function $M({message:e}){return typeof document>`u`?null:(0,Gi.createPortal)((0,M.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-8 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:e})]})}),document.body)}function eN(e,t){let n=(e||t||`?`).trim(),r=n.split(/\s+/);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():n.slice(0,2).toUpperCase()}function tN(){let{t:e}=vt(),t=Hi(),{user:n,loading:r,logout:i}=JM(),[a,o]=(0,j.useState)(!1);return r&&!n?(0,M.jsx)(`div`,{className:`h-8 w-8 animate-pulse rounded-full bg-muted`,"aria-hidden":!0}):n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,children:(0,M.jsxs)(zM,{className:`h-7 w-7`,children:[n.image?(0,M.jsx)(BM,{src:n.image,alt:n.name??n.email??e(`userMenu.user`)}):null,(0,M.jsx)(VM,{className:`text-[11px]`,children:eN(n.name,n.email)})]})})}),(0,M.jsxs)(tM,{align:`end`,className:`w-64`,children:[(0,M.jsx)(aM,{children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name||n.email}),n.email&&(0,M.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,children:n.email})]})}),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:()=>t({to:`/account`}),children:[(0,M.jsx)(Zy,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.account`)]}),(0,M.jsxs)(nM,{onSelect:()=>t({to:`/organizations`}),children:[(0,M.jsx)(dy,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.organizations`)]}),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:async()=>{o(!0);try{await i()}finally{window.location.assign(`/_account/login`)}},disabled:a,children:[(0,M.jsx)(My,{className:`mr-2 h-3.5 w-3.5`}),e(`userMenu.signOut`)]})]})]}),a?(0,M.jsx)($M,{message:e(`auth.userMenu.signingOut`,{defaultValue:`Signing you out…`})}):null]}):(0,M.jsx)(Q,{variant:`outline`,size:`sm`,className:`h-8`,onClick:()=>t({to:`/login`}),children:e(`userMenu.signIn`)})}function nN(){let{t:e}=vt(),t=Hi(),n=Oa(),{organizations:r,loading:i,reload:a}=YM(),{session:o,setActiveOrganization:s}=JM(),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(!1),f=o?.activeOrganizationId??void 0,p=(0,j.useMemo)(()=>r.find(e=>e.id===f)??null,[r,f]),m=async r=>{if(l(!1),r===f){t({to:`/organizations/$orgId/general`,params:{orgId:r}});return}d(!0);try{await s(r),await a(),q({title:e(`organizations.general.switched`)});let i=n.pathname.match(/^\/organizations\/[^/]+\/(general|members)\/?$/);t({to:(i?i[1]:`general`)===`members`?`/organizations/$orgId/members`:`/organizations/$orgId/general`,params:{orgId:r}})}catch(t){q({title:e(`organizations.switchFailed`),description:t.message,variant:`destructive`})}finally{d(!1)}};return(0,M.jsxs)(Zj,{open:c,onOpenChange:l,children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsxs)(Q,{variant:`ghost`,size:`sm`,className:`h-8 gap-2 px-2 text-sm font-medium`,disabled:u,children:[p?(0,M.jsx)(`span`,{className:`max-w-[160px] truncate`,children:p.name}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(i?`organizations.loading`:`organizationSwitcher.select`)}),(0,M.jsx)(gy,{className:`h-3 w-3 opacity-50`})]})}),(0,M.jsxs)(tM,{align:`start`,className:`w-[280px]`,sideOffset:4,children:[(0,M.jsx)(aM,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e(`organizations.title`)}),r.length===0&&!i&&(0,M.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:e(`organizations.emptyTitle`)}),r.map(e=>(0,M.jsxs)(nM,{onSelect:t=>{t.preventDefault(),m(e.id)},className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),e.slug&&(0,M.jsx)(`code`,{className:`text-[11px] text-muted-foreground font-mono`,children:e.slug})]}),e.id===f&&(0,M.jsx)(fy,{className:`h-3.5 w-3.5 text-primary`})]},e.id)),(0,M.jsx)(oM,{}),(0,M.jsxs)(nM,{onSelect:e=>{e.preventDefault(),l(!1),t({to:`/organizations/new`})},className:`gap-2 text-sm`,children:[(0,M.jsx)(Ly,{className:`h-3.5 w-3.5`}),e(`organizationSwitcher.new`)]}),(0,M.jsx)(nM,{onSelect:e=>{e.preventDefault(),l(!1),t({to:`/organizations`})},className:`gap-2 text-sm text-muted-foreground`,children:e(`organizationSwitcher.manage`)})]})]})}function rN({label:e}){return(0,M.jsx)(ra,{to:`/account`,className:`flex h-8 w-8 items-center justify-center rounded-md bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15 transition-transform hover:scale-105`,"aria-label":e,children:(0,M.jsx)(vy,{className:`h-4 w-4`})})}function iN(){return(0,M.jsx)(my,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground/50`})}function aN(){let{t:e}=vt(),t=Oa(),n=Bi({strict:!1}),r=(0,j.useMemo)(()=>{let r=t.pathname,i=t=>e(`topBar.breadcrumb.${t}`);if(r.startsWith(`/account`)){let e=[{label:i(`account`)}];return r===`/account/profile`?e.push({label:i(`profile`)}):r===`/account/security`?e.push({label:i(`security`)}):r===`/account/sessions`?e.push({label:i(`sessions`)}):r===`/account/two-factor`?e.push({label:i(`twoFactor`)}):r===`/account/oauth-applications`?e.push({label:i(`oauthApps`)}):r===`/account/oauth-applications/new`?e.push({label:i(`oauthApps`)},{label:i(`new`)}):r.startsWith(`/account/oauth-applications/`)&&e.push({label:i(`oauthApps`)}),e}if(r===`/organizations/new`)return[{label:i(`organizations`)},{label:i(`new`)}];if(n.orgId){let e=r.endsWith(`/general`)?i(`general`):r.endsWith(`/members`)?i(`members`):i(`settings`);return[{label:i(`organizations`)},{label:e}]}return r===`/organizations`||r.startsWith(`/organizations/`)?[{label:i(`organizations`)}]:r.startsWith(`/accept-invitation/`)?[{label:i(`acceptInvitation`)}]:r.startsWith(`/auth/device`)?[{label:i(`deviceAuthorization`)}]:[{label:i(`account`)}]},[t.pathname,n.orgId,e]);return(0,M.jsxs)(`header`,{className:`sticky top-0 z-30 flex h-14 shrink-0 items-center justify-between gap-2 border-b bg-background/80 px-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:px-4`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 sm:gap-2.5`,children:[(0,M.jsx)(`div`,{className:`sm:hidden`,children:(0,M.jsx)(wO,{className:`h-9 w-9`})}),(0,M.jsx)(rN,{label:e(`topBar.accountHome`)}),(0,M.jsx)(`span`,{className:`hidden text-sm font-semibold tracking-tight sm:inline`,children:e(`topBar.brand`)}),(0,M.jsxs)(`div`,{className:`hidden items-center gap-1.5 sm:flex`,children:[(0,M.jsx)(iS,{orientation:`vertical`,className:`mx-1 h-4`}),(0,M.jsx)(nN,{}),(0,M.jsx)(iN,{}),(0,M.jsx)(qO,{children:(0,M.jsx)(JO,{children:r.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center`,children:[t>0&&(0,M.jsx)(QO,{}),(0,M.jsx)(YO,{children:(0,M.jsx)(ZO,{className:`font-medium`,children:e.label})})]},t))})})]}),(0,M.jsx)(`div`,{className:`min-w-0 flex-1 sm:hidden`,children:r.length>0&&(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:r[r.length-1].label})})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2`,children:[(0,M.jsx)(`div`,{className:`hidden sm:block`,children:(0,M.jsx)(_M,{})}),(0,M.jsx)(`div`,{className:`hidden sm:block`,children:(0,M.jsx)(yM,{})}),(0,M.jsx)(tN,{})]})]})}var oN=[{to:`/account`,label:`home`,icon:Ey,exact:!0},{to:`/account/profile`,label:`profile`,icon:Zy},{to:`/account/security`,label:`security`,icon:Hy},{to:`/account/sessions`,label:`sessions`,icon:Py},{to:`/account/two-factor`,label:`twoFactor`,icon:Vy},{to:`/account/invitations`,label:`invitations`,icon:Dy},{to:`/account/linked-accounts`,label:`linkedAccounts`,icon:jy}],sN=[`group/nav relative transition-all duration-150`,`before:absolute before:left-0 before:top-1/2 before:h-5 before:w-[3px] before:-translate-y-1/2 before:rounded-r-full before:bg-brand-gradient before:opacity-0 before:transition-opacity`,`data-[active=true]:before:opacity-100`,`data-[active=true]:bg-sidebar-accent/80 data-[active=true]:text-sidebar-accent-foreground`,`[&>svg]:transition-transform [&>svg]:duration-150 hover:[&>svg]:scale-110`,`data-[active=true]:[&>svg]:text-primary`].join(` `);function cN(){let{t:e}=vt(),{pathname:t}=Oa(),{organizations:n}=YM(),r=t,i=t.match(/^\/organizations\/([^/]+)(?:\/.*)?$/),a=i&&n.some(e=>e.id===i[1])?i[1]:null;return(0,M.jsxs)(CO,{collapsible:`icon`,className:`h-full`,children:[(0,M.jsxs)(jO,{children:[(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.account`)}),(0,M.jsx)(FO,{children:(0,M.jsx)(IO,{children:oN.map(t=>{let n=t.icon;return(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t.exact?r===t.to||r===`${t.to}/`:r===t.to||r.startsWith(`${t.to}/`),tooltip:e(`sidebar.items.${t.label}`),className:sN,children:(0,M.jsxs)(ra,{to:t.to,children:[(0,M.jsx)(n,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.${t.label}`)})]})})},t.to)})})})]}),(0,M.jsx)(AO,{}),(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.organization`)}),(0,M.jsx)(FO,{children:(0,M.jsxs)(IO,{children:[(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations`,tooltip:e(`sidebar.items.overview`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations`,children:[(0,M.jsx)(dy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.overview`)})]})})}),a&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/general`,tooltip:e(`sidebar.items.general`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/general`,params:{orgId:a},children:[(0,M.jsx)(By,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.general`)})]})})}),(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/members`,tooltip:e(`sidebar.items.members`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/members`,params:{orgId:a},children:[(0,M.jsx)($y,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.members`)})]})})}),(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t===`/organizations/${a}/teams`,tooltip:e(`sidebar.items.teams`),className:sN,children:(0,M.jsxs)(ra,{to:`/organizations/$orgId/teams`,params:{orgId:a},children:[(0,M.jsx)(Qy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.teams`)})]})})})]})]})})]}),(0,M.jsx)(AO,{}),(0,M.jsxs)(MO,{children:[(0,M.jsx)(NO,{children:e(`sidebar.groups.developer`)}),(0,M.jsx)(FO,{children:(0,M.jsx)(IO,{children:(0,M.jsx)(LO,{children:(0,M.jsx)(RO,{asChild:!0,isActive:t.startsWith(`/account/oauth-applications`),tooltip:e(`sidebar.items.oauthApps`),className:sN,children:(0,M.jsxs)(ra,{to:`/account/oauth-applications`,children:[(0,M.jsx)(Oy,{className:`size-4`}),(0,M.jsx)(`span`,{children:e(`sidebar.items.oauthApps`)})]})})})})})]})]}),(0,M.jsx)(kO,{children:(0,M.jsx)(IO,{children:(0,M.jsx)(LO,{children:(0,M.jsx)(lN,{})})})})]})}function lN(){let{t:e}=vt(),{state:t,toggleSidebar:n}=xO(),r=e(t===`collapsed`?`sidebar.expand`:`sidebar.collapse`);return(0,M.jsx)(RO,{onClick:n,tooltip:r,"aria-label":r,children:(0,M.jsx)(Iy,{className:`size-4`})})}function uN(){return typeof window<`u`&&window.location.pathname.startsWith(`/_account`)?window.location.origin:`http://localhost:3000`}var dN=new Set([`/login`,`/register`,`/forgot-password`,`/reset-password`,`/verify-email`,`/auth/device`,`/setup`]);function fN(e){return dN.has(e)||e.startsWith(`/accept-invitation/`)}function pN(){let[e,t]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let n=await fetch(`/api/v1/auth/bootstrap-status`);if(!n.ok){e||t(!0);return}let r=await n.json();e||t(r.hasOwner!==!1)}catch{e||t(!0)}})(),()=>{e=!0}},[]),e}function mN({children:e}){let{user:t,loading:n}=JM(),r=Hi(),i=Oa(),a=fN(i.pathname),o=i.pathname.startsWith(`/oauth/`),s=pN(),c=i.pathname===`/setup`;return(0,j.useEffect)(()=>{s===!1&&!c&&!t&&r({to:`/setup`,replace:!0})},[s,c,t,r]),(0,j.useEffect)(()=>{n||s!==!1&&!t&&!a&&r({to:`/login`,search:{redirect:i.pathname+i.searchStr},replace:!0})},[t,n,a,r,i.pathname,i.searchStr,s]),s===null||n&&!t?(0,M.jsx)(`div`,{className:`flex min-h-screen w-full flex-1 items-center justify-center bg-background`,children:(0,M.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted border-t-primary`})}):s===!1&&!c||!t&&!a?null:a||o?(0,M.jsx)(`div`,{className:`flex min-h-screen w-full`,children:e}):(0,M.jsxs)(SO,{className:`flex h-svh w-full flex-col`,children:[(0,M.jsx)(aN,{}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 w-full`,children:[(0,M.jsx)(cN,{}),(0,M.jsx)(EO,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-auto bg-background`,children:e})})]})]})}function hN(){let e=uN();return(0,M.jsx)(Kg,{client:(0,j.useMemo)(()=>new Ug({baseUrl:e}),[e]),children:(0,M.jsxs)(qM,{children:[(0,M.jsx)(mN,{children:(0,M.jsx)(ya,{})}),(0,M.jsx)(Fx,{})]})})}var gN=ca({component:hN}),$=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));$.displayName=`Card`;var _N=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`flex flex-col space-y-1.5 p-6`,e),...t}));_N.displayName=`CardHeader`;var vN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`h3`,{ref:n,className:Z(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));vN.displayName=`CardTitle`;var yN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`p`,{ref:n,className:Z(`text-sm text-muted-foreground`,e),...t}));yN.displayName=`CardDescription`;var bN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`p-6 pt-0`,e),...t}));bN.displayName=`CardContent`;var xN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`div`,{ref:n,className:Z(`flex items-center p-6 pt-0`,e),...t}));xN.displayName=`CardFooter`;function SN(e){let t=e.split(`:`)[0].toLowerCase();return/^cloud\./.test(t)}function CN(){return typeof window>`u`?null:window.location.host||null}function wN({children:e,headline:t,subline:n,formWidth:r=`sm`}){let{t:i}=vt(),a=r===`md`?`max-w-md`:`max-w-sm`,o=CN(),s=!!o&&!SN(o);return j.useEffect(()=>{if(typeof document>`u`||!o)return;let e=document.title;return document.title=s?`${o} · ObjectStack`:e,()=>{document.title=e}},[o,s]),(0,M.jsxs)(`div`,{className:`relative grid min-h-svh w-full lg:grid-cols-2`,children:[(0,M.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-6 bg-background p-6 md:p-10`,children:(0,M.jsxs)(`div`,{className:Z(`flex w-full flex-col gap-6`,a),children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-1 self-center`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 font-semibold tracking-tight`,children:[(0,M.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30`,children:(0,M.jsx)(wy,{className:`size-4`})}),(0,M.jsx)(`span`,{children:`ObjectStack`})]}),s?(0,M.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide text-muted-foreground`,title:i(`auth.shell.tenantHostHint`,{defaultValue:`You are signing in to this workspace`}),children:o}):null]}),e]})}),(0,M.jsxs)(`aside`,{"aria-hidden":!0,className:`relative hidden overflow-hidden bg-brand-mesh text-white lg:flex lg:flex-col lg:justify-between lg:p-12`,children:[(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-[0.12]`,style:{backgroundImage:`linear-gradient(rgba(255,255,255,0.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.6) 1px, transparent 1px)`,backgroundSize:`48px 48px`,maskImage:`radial-gradient(ellipse at center, black 40%, transparent 75%)`}}),(0,M.jsx)(`div`,{className:`pointer-events-none absolute -left-24 top-1/3 size-[28rem] rounded-full bg-white/15 blur-3xl`}),(0,M.jsx)(`div`,{className:`pointer-events-none absolute -right-20 -bottom-20 size-[24rem] rounded-full bg-white/10 blur-3xl`}),(0,M.jsxs)(`div`,{className:`relative flex items-center gap-2 text-sm font-semibold tracking-tight`,children:[(0,M.jsx)(`div`,{className:`flex size-7 items-center justify-center rounded-md bg-white/15 ring-1 ring-white/30 backdrop-blur`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsxs)(`div`,{className:`relative max-w-md space-y-5`,children:[(0,M.jsx)(`h2`,{className:`text-balance text-3xl font-semibold leading-tight tracking-tight md:text-4xl`,children:t??i(`auth.login.brandHeadline`,{defaultValue:`The AI-native backend for business software.`})}),(0,M.jsx)(`p`,{className:`text-balance text-base/relaxed text-white/80`,children:n??i(`auth.login.brandSubline`,{defaultValue:`One identity, every workspace. Sign in to manage your account, organizations and connected apps.`})})]}),(0,M.jsxs)(`div`,{className:`relative text-xs text-white/60`,children:[`© `,new Date().getFullYear(),` ObjectStack`]})]})]})}var TN=la(`/verify-email`)({validateSearch:e=>{let t=e.token;return typeof t==`string`?{token:t}:{}},component:EN});function EN(){let{t:e}=vt(),{token:t}=TN.useSearch(),n=qg(),[r,i]=(0,j.useState)(`loading`),[a,o]=(0,j.useState)(``);return(0,j.useEffect)(()=>{if(!t){i(`error`),o(e(`auth.verifyEmail.missingToken`));return}let r=!1;return(async()=>{try{await n.auth.verifyEmail({token:t}),r||i(`success`)}catch(t){r||(i(`error`),o(t.message||e(`auth.verifyEmail.errorDescription`)))}})(),()=>{r=!0}},[t,e,n]),(0,M.jsx)(wN,{headline:e(`auth.verifyEmail.brandHeadline`,{defaultValue:`One more step to get started.`}),subline:e(`auth.verifyEmail.brandSubline`,{defaultValue:`Verifying your email keeps your ObjectStack account secure.`}),children:(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[r===`loading`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.verifyingTitle`)}),(0,M.jsx)(yN,{children:e(`auth.verifyEmail.verifyingDescription`)})]}),(0,M.jsx)(bN,{className:`flex justify-center py-6`,children:(0,M.jsx)(`div`,{className:`h-10 w-10 animate-spin rounded-full border-4 border-muted border-t-primary`})})]}),r===`success`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-500 ring-1 ring-emerald-500/30`,children:(0,M.jsx)(_y,{className:`size-6`})}),(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.successTitle`)}),(0,M.jsx)(yN,{children:e(`auth.verifyEmail.successDescription`)})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.signInLink`)})})]}),r===`error`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-destructive/10 text-destructive ring-1 ring-destructive/30`,children:(0,M.jsx)(yy,{className:`size-6`})}),(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.errorTitle`)}),(0,M.jsx)(yN,{children:a||e(`auth.verifyEmail.errorDescription`)})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.backToSignIn`)})})]})]})})}var DN=`Label`,ON=j.forwardRef((e,t)=>(0,M.jsx)(Zx.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ON.displayName=DN;var kN=ON,AN=$v(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),jN=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(kN,{ref:n,className:Z(AN(),e),...t}));jN.displayName=kN.displayName;var MN=la(`/setup`)({component:PN});function NN(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function PN(){let{t:e}=vt(),t=Hi(),n=qg(),{user:r,refresh:i}=JM(),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null);return(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let{hasOwner:t}=await n.auth.bootstrapStatus();e||g(t)}catch{e||g(!1)}})(),()=>{e=!0}},[n]),(0,j.useEffect)(()=>{h===!0&&!r&&t({to:`/login`,replace:!0})},[h,r,t]),(0,j.useEffect)(()=>{r&&window.location.assign(`/`)},[r]),h===null?(0,M.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted`,children:(0,M.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted-foreground/20 border-t-primary`})}):(0,M.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted p-6`,children:(0,M.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-6`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,M.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.setup.welcomeTitle`)}),(0,M.jsx)(yN,{children:e(`auth.setup.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),n?.auth){m(!0);try{await n.auth.register({name:a,email:s,password:l}),await i();let e=d.trim();if(e)try{let{organizations:t}=await n.organizations.list(),r=t?.[0],i;if(r?.id)await n.organizations.update(r.id,{name:e,slug:NN(e)}),i=r.id;else{let t=await n.organizations.create({name:e,slug:NN(e)});i=t?.id??t?.data?.id}i&&await n.organizations.setActive(i).catch(()=>{})}catch(e){console.warn(`[setup] organization rename/create failed`,e)}window.location.assign(`/`)}catch(t){q({title:e(`auth.setup.failed`),description:t.message,variant:`destructive`})}finally{m(!1)}}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`auth.setup.yourName`)}),(0,M.jsx)(Xx,{id:`name`,autoComplete:`name`,required:!0,value:a,onChange:e=>o(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`orgName`,children:e(`auth.setup.orgName`)}),(0,M.jsx)(Xx,{id:`orgName`,required:!0,placeholder:e(`auth.setup.orgNamePlaceholder`),value:d,onChange:e=>f(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:s,onChange:e=>c(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,placeholder:e(`auth.setup.passwordHint`),value:l,onChange:e=>u(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`mt-2 w-full`,disabled:p,children:e(p?`auth.setup.submitting`:`auth.setup.submit`)})]})})]})]})})}var FN=la(`/reset-password`)({validateSearch:e=>{let t=e.token;return typeof t==`string`?{token:t}:{}},component:IN});function IN(){let{t:e}=vt(),t=Hi(),{token:n}=FN.useSearch(),[r,i]=(0,j.useState)(``),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(!1);return(0,M.jsx)(wN,{headline:e(`auth.resetPassword.brandHeadline`,{defaultValue:`Choose a new password.`}),subline:e(`auth.resetPassword.brandSubline`,{defaultValue:`Make it strong — at least 8 characters with a mix of letters and numbers.`}),children:(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.resetPassword.title`)}),(0,M.jsx)(yN,{children:e(`auth.resetPassword.description`)})]}),(0,M.jsx)(bN,{children:n?(0,M.jsxs)(`form`,{onSubmit:async i=>{if(i.preventDefault(),r!==a){q({title:e(`auth.resetPassword.passwordsMismatch`),variant:`destructive`});return}if(!n){q({title:e(`auth.resetPassword.missingToken`),variant:`destructive`});return}c(!0);try{let i=await fetch(`/api/v1/auth/reset-password`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({token:n,newPassword:r})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e?.message||`Request failed: ${i.status}`)}q({title:e(`auth.resetPassword.success`)}),t({to:`/login`})}catch(t){q({title:e(`auth.resetPassword.failed`),description:t.message,variant:`destructive`})}finally{c(!1)}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`new-password`,children:e(`auth.resetPassword.newPassword`)}),(0,M.jsx)(Xx,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:r,onChange:e=>i(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`confirm-password`,children:e(`auth.resetPassword.confirmPassword`)}),(0,M.jsx)(Xx,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:a,onChange:e=>o(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:s,children:e(s?`auth.resetPassword.submitting`:`auth.resetPassword.submit`)})]}):(0,M.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center`,children:[e(`auth.resetPassword.invalidToken`),` `,(0,M.jsx)(ra,{to:`/forgot-password`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.resetPassword.requestNewLink`)})]})})]})})}function LN({mode:e,redirect:t}){let{t:n}=vt(),r=qg(),[i,a]=(0,j.useState)([]),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(null);if((0,j.useEffect)(()=>{r?.auth?.getConfig&&r.auth.getConfig().then(e=>{a((e?.socialProviders??e?.data?.socialProviders??[]).filter(e=>e.enabled))}).catch(e=>{console.warn(`[SocialSignInButtons] failed to load auth config`,e)}).finally(()=>s(!1))},[r]),o||i.length===0)return null;let u=n(e===`sign-in`?`auth.social.continueWith`:`auth.social.signUpWith`),d=window.location.origin+`/_account/login`+(t?`?redirect=${encodeURIComponent(t)}`:``),f=e=>{c||(l(e),Promise.resolve(r.auth.signInWithProvider(e.id,{callbackURL:d,errorCallbackURL:d,type:e.type??`social`})).catch(e=>{console.warn(`[SocialSignInButtons] signInWithProvider failed`,e),l(null)}))};return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i.map(e=>{let t=c?.id===e.id;return(0,M.jsxs)(Q,{type:`button`,variant:`outline`,className:`w-full`,disabled:!!c,onClick:()=>f(e),children:[t?(0,M.jsx)(`span`,{className:`mr-2 inline-block size-4 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}):(0,M.jsx)(`span`,{className:`mr-2 flex h-4 w-4 items-center justify-center rounded-sm bg-muted text-[10px] font-bold uppercase`,children:e.id[0]}),t?n(`auth.social.redirectingTo`,{provider:e.name,defaultValue:`Redirecting to ${e.name}…`}):`${u} ${e.name}`]},e.id)}),(0,M.jsxs)(`div`,{className:`relative my-1`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,M.jsx)(`span`,{className:`w-full border-t`})}),(0,M.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,M.jsx)(`span`,{className:`bg-card px-2 text-muted-foreground`,children:n(`auth.social.orContinueEmail`)})})]}),c&&typeof document<`u`?(0,Gi.createPortal)((0,M.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`fixed inset-0 z-[100] flex items-center justify-center bg-background/80 backdrop-blur-sm`,children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-8 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:n(`auth.social.redirectingTo`,{provider:c.name,defaultValue:`Redirecting to ${c.name}…`})})]})}),document.body):null]})}var RN=la(`/register`)({validateSearch:e=>{let t=e.redirect;return typeof t==`string`?{redirect:t}:{}},component:VN});function zN(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function BN(e){return e.startsWith(`/_`)?e:`/_account/`.replace(/\/$/,``)+e}function VN(){let{t:e}=vt(),t=Hi(),{redirect:n}=RN.useSearch(),r=qg(),{session:i,user:a,loading:o,refresh:s,organizations:c,organizationsLoading:l,organizationsFetched:u,setActiveOrganization:d}=JM(),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(``),[g,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(a){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){window.location.assign(`/api/v1/auth/oauth2/authorize${window.location.search}`);return}}if(!i?.activeOrganizationId){if(!u||l||b)return;if(c.length===1){x(!0),d(c[0].id).catch(()=>void 0).finally(()=>x(!1));return}if(c.length>1){t({to:`/organizations`});return}t({to:`/organizations/new`});return}if(!b){if(zN(n)){window.location.assign(BN(n));return}window.location.assign(`/`)}}},[a,i,t,n,c,l,u,b,d]),(0,M.jsx)(wN,{headline:e(`auth.register.brandHeadline`,{defaultValue:`Create your ObjectStack account.`}),subline:e(`auth.register.brandSubline`,{defaultValue:`One identity for every workspace, app and integration in your stack.`}),children:o||a?(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:a?e(`auth.register.signingIn`,{defaultValue:`Setting up your account…`}):e(`auth.login.redirecting`,{defaultValue:`Loading…`})})]}):(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.register.title`)}),(0,M.jsx)(yN,{children:e(`auth.register.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),r?.auth){y(!0);try{await r.auth.register({name:f,email:m,password:g}),await s(),q({title:e(`auth.register.successToast`)})}catch(t){q({title:e(`auth.register.failed`),description:t.message,variant:`destructive`})}finally{y(!1)}}},children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsx)(LN,{mode:`sign-up`,redirect:n}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`auth.nameLabel`)}),(0,M.jsx)(Xx,{id:`name`,autoComplete:`name`,required:!0,value:f,onChange:e=>p(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:m,onChange:e=>h(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:g,onChange:e=>_(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:v,children:e(v?`auth.register.submitting`:`auth.register.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.register.haveAccount`),` `,(0,M.jsx)(ra,{to:`/login`,search:n?{redirect:n}:void 0,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.register.signIn`)})]})]})})})]}),(0,M.jsxs)(`p`,{className:`px-6 text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary`,children:[e(`legal.agreementPrefix`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.termsOfService`)}),` `,e(`legal.and`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.privacyPolicy`)}),`.`]})]})})}var HN=la(`/login`)({validateSearch:e=>{let t=e.redirect;return typeof t==`string`?{redirect:t}:{}},component:GN});function UN(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function WN(e){return e.startsWith(`/_`)?e:`/_account/`.replace(/\/$/,``)+e}function GN(){let{t:e}=vt(),t=Hi(),{redirect:n}=HN.useSearch(),r=qg(),i=null;if(typeof window<`u`){let e=new URLSearchParams(window.location.search),t=e.get(`redirect_uri`);if(e.has(`client_id`)&&t)try{i=new URL(t).host}catch{i=null}}let{session:a,user:o,loading:s,refresh:c,organizations:l,organizationsLoading:u,organizationsFetched:d,setActiveOrganization:f}=JM(),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)(!1),[y,b]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(o){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){window.location.assign(`/api/v1/auth/oauth2/authorize${window.location.search}`);return}}if(!a?.activeOrganizationId){if(!d||u||y)return;if(l.length===1){b(!0),f(l[0].id).catch(()=>void 0).finally(()=>b(!1));return}if(l.length===0){t({to:`/organizations/new`});return}t({to:`/organizations`});return}if(!y){if(UN(n)){window.location.assign(WN(n));return}window.location.assign(`/`)}}},[o,a,t,n,l,u,d,y,f]),s||o?(0,M.jsx)(wN,{children:(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,M.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,M.jsx)(`span`,{children:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})})]})}):(0,M.jsxs)(wN,{children:[_?(0,M.jsx)($M,{message:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})}):null,(0,M.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i?(0,M.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-md border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 inline-block size-2 shrink-0 rounded-full bg-primary`}),(0,M.jsx)(`span`,{children:e(`auth.login.ssoHandoff`,{target:i,defaultValue:`Sign in to ObjectStack to continue to ${i}`})})]}):null,(0,M.jsxs)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.login.title`)}),(0,M.jsx)(yN,{children:e(`auth.login.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsx)(`form`,{onSubmit:async t=>{if(t.preventDefault(),r?.auth){v(!0);try{await r.auth.login({type:`email`,email:p,password:h}),await c(),q({title:e(`auth.login.welcomeToast`)})}catch(t){q({title:e(`auth.login.failed`),description:t.message,variant:`destructive`})}finally{v(!1)}}},children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,M.jsx)(LN,{mode:`sign-in`,redirect:n}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:p,onChange:e=>m(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center`,children:[(0,M.jsx)(jN,{htmlFor:`password`,children:e(`auth.passwordLabel`)}),(0,M.jsx)(ra,{to:`/forgot-password`,className:`ml-auto text-sm underline-offset-4 hover:underline`,children:e(`auth.login.forgotPassword`)})]}),(0,M.jsx)(Xx,{id:`password`,type:`password`,autoComplete:`current-password`,required:!0,value:h,onChange:e=>g(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:_,children:e(_?`auth.login.submitting`:`auth.login.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.login.noAccount`),` `,(0,M.jsx)(ra,{to:`/register`,search:n?{redirect:n}:void 0,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.login.signUp`)})]})]})})})]}),(0,M.jsxs)(`p`,{className:`px-6 text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary`,children:[e(`legal.agreementPrefix`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.termsOfService`)}),` `,e(`legal.and`),` `,(0,M.jsx)(`a`,{href:`#`,children:e(`legal.privacyPolicy`)}),`.`]})]})]})}var KN=la(`/forgot-password`)({component:qN});function qN(){let{t:e}=vt(),[t,n]=(0,j.useState)(``),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(!1);return(0,M.jsx)(wN,{headline:e(`auth.forgotPassword.brandHeadline`,{defaultValue:`Forgot your password?`}),subline:e(`auth.forgotPassword.brandSubline`,{defaultValue:`No problem — we will send you a secure link to reset it.`}),children:(0,M.jsx)($,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:a?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.forgotPassword.checkEmailTitle`)}),(0,M.jsx)(yN,{children:e(`auth.forgotPassword.checkEmailDescription`,{email:t})})]}),(0,M.jsx)(bN,{className:`text-center`,children:(0,M.jsx)(ra,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.forgotPassword.backToSignIn`)})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl tracking-tight`,children:e(`auth.forgotPassword.title`)}),(0,M.jsx)(yN,{children:e(`auth.forgotPassword.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),i(!0);try{let e=window.location.origin+`/_account/`.replace(/\/$/,``)+`/reset-password`,n=await fetch(`/api/v1/auth/forget-password`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({email:t,redirectTo:e})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e?.message||`Request failed: ${n.status}`)}o(!0)}catch(t){q({title:e(`auth.forgotPassword.failed`),description:t.message,variant:`destructive`})}finally{i(!1)}},className:`flex flex-col gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(jN,{htmlFor:`email`,children:e(`auth.emailLabel`)}),(0,M.jsx)(Xx,{id:`email`,type:`email`,placeholder:e(`auth.emailPlaceholder`),autoComplete:`email`,required:!0,value:t,onChange:e=>n(e.target.value)})]}),(0,M.jsx)(Q,{type:`submit`,className:`w-full bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,disabled:r,children:e(r?`auth.forgotPassword.submitting`:`auth.forgotPassword.submit`)}),(0,M.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.forgotPassword.rememberPassword`),` `,(0,M.jsx)(ra,{to:`/login`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.forgotPassword.signIn`)})]})]})})]})})})}var JN=la(`/account`)({component:YN});function YN(){return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-4 py-6 sm:px-6 sm:py-8`,children:(0,M.jsx)(`div`,{className:`page-enter mx-auto flex max-w-4xl flex-col gap-6`,children:(0,M.jsx)(ya,{})})})})}var XN=la(`/`)({component:ZN});function ZN(){return(0,M.jsx)(Ui,{to:`/login`})}var QN=$v(`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 $N({className:e,variant:t,...n}){return(0,M.jsx)(`div`,{className:Z(QN({variant:t}),e),...n})}function eP({title:e,description:t,icon:n,actions:r,className:i,...a}){return(0,M.jsxs)(`div`,{className:Z(`relative overflow-hidden rounded-xl border bg-brand-gradient-subtle`,`px-5 py-5 sm:px-6 sm:py-6`,i),...a,children:[(0,M.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-60`,style:{backgroundImage:`radial-gradient(ellipse 60% 80% at 0% 0%, hsl(var(--brand-from) / 0.12), transparent 60%)`},"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`relative flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between sm:gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-start gap-4`,children:[n?(0,M.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15`,children:(0,M.jsx)(n,{className:`size-5`})}):null,(0,M.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,M.jsx)(`h1`,{className:`truncate text-xl font-semibold tracking-tight sm:text-2xl`,children:e}),t?(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t}):null]})]}),r?(0,M.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})]})}var tP=la(`/organizations/`)({component:nP});function nP(){let{t:e}=vt(),{organizations:t,loading:n}=YM(),{session:r,setActiveOrganization:i,features:a}=JM(),o=Hi(),s=r?.activeOrganizationId??void 0,c=a?.multiOrgEnabled!==!1,l=async t=>{try{t!==s&&await i(t),o({to:`/organizations/$orgId`,params:{orgId:t}})}catch(t){q({title:e(`organizations.switchFailed`),description:t.message,variant:`destructive`})}},u=e=>e.split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase();return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-4 py-6 sm:px-6 sm:py-8`,children:(0,M.jsxs)(`div`,{className:`page-enter mx-auto flex max-w-3xl flex-col gap-6`,children:[(0,M.jsx)(eP,{icon:dy,title:e(`organizations.title`),description:e(`organizations.description`),actions:c?(0,M.jsxs)(Q,{onClick:()=>o({to:`/organizations/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`organizations.newOrganization`)]}):null}),n&&(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`organizations.loading`)}),!n&&t.length===0&&(0,M.jsxs)($,{className:`p-10 text-center`,children:[(0,M.jsx)(`div`,{className:`mx-auto mb-3 flex size-12 items-center justify-center rounded-lg bg-brand-gradient-subtle text-primary ring-1 ring-primary/15`,children:(0,M.jsx)(dy,{className:`h-6 w-6`})}),(0,M.jsx)(`h3`,{className:`text-base font-medium`,children:e(`organizations.emptyTitle`)}),(0,M.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:e(`organizations.emptyDescription`)}),c&&(0,M.jsxs)(Q,{onClick:()=>o({to:`/organizations/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`organizations.createOrganization`)]})]}),(0,M.jsx)(`div`,{className:`grid gap-3`,children:t.map(t=>{let n=t.id===s;return(0,M.jsx)($,{role:`button`,tabIndex:0,onClick:()=>l(t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l(t.id))},className:`group cursor-pointer p-4 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-md hover:shadow-primary/5 focus:outline-none focus:ring-2 focus:ring-ring ${n?`border-primary/50 bg-brand-gradient-subtle ring-1 ring-primary/30`:``}`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,M.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-lg font-semibold `+(n?`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30 ring-1 ring-white/15`:`bg-muted text-muted-foreground group-hover:bg-brand-gradient-subtle group-hover:text-primary`),children:u(t.name)||(0,M.jsx)(dy,{className:`h-5 w-5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`h3`,{className:`truncate text-base font-medium`,children:t.name}),n&&(0,M.jsxs)($N,{className:`gap-1 border-transparent bg-emerald-500/15 text-[10px] font-medium text-emerald-600 dark:text-emerald-400`,children:[(0,M.jsx)(fy,{className:`h-3 w-3`}),e(`organizations.active`)]})]}),t.slug&&(0,M.jsx)(`code`,{className:`mt-0.5 block font-mono text-xs text-muted-foreground`,children:t.slug})]}),(0,M.jsx)(my,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-primary`})]})},t.id)})})]})})})}var rP=la(`/account/`)({component:iP});function iP(){let{t:e}=vt(),{user:t}=JM(),{organizations:n}=YM(),r=[!!t?.emailVerified,!!t?.twoFactorEnabled,!!t?.name,!!t?.image].filter(Boolean).length*25,i=r>=75?`success`:r>=50?`warn`:`danger`,a=(t?.name??t?.email??`?`).split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase(),o=[{to:`/account/profile`,label:e(`home.tiles.profile.title`,{defaultValue:`Profile`}),description:e(`home.tiles.profile.description`,{defaultValue:`Display name, avatar and contact info.`}),icon:Zy},{to:`/account/security`,label:e(`home.tiles.security.title`,{defaultValue:`Security`}),description:e(`home.tiles.security.description`,{defaultValue:`Change your password and review activity.`}),icon:Hy},{to:`/account/two-factor`,label:e(`home.tiles.twoFactor.title`,{defaultValue:`Two-factor auth`}),description:e(`home.tiles.twoFactor.description`,{defaultValue:`Add an authenticator app for stronger sign-in.`}),icon:Vy},{to:`/account/sessions`,label:e(`home.tiles.sessions.title`,{defaultValue:`Active sessions`}),description:e(`home.tiles.sessions.description`,{defaultValue:`See and revoke devices that are signed in.`}),icon:Py},{to:`/account/linked-accounts`,label:e(`home.tiles.linked.title`,{defaultValue:`Linked accounts`}),description:e(`home.tiles.linked.description`,{defaultValue:`Manage your social and SSO providers.`}),icon:jy},{to:`/account/oauth-applications`,label:e(`home.tiles.oauth.title`,{defaultValue:`OAuth applications`}),description:e(`home.tiles.oauth.description`,{defaultValue:`Apps you have authorised to access your account.`}),icon:Oy}];return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border bg-card`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 bg-brand-gradient`,"aria-hidden":!0}),(0,M.jsx)(`div`,{className:`absolute inset-0 opacity-40 mix-blend-soft-light`,style:{backgroundImage:`radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.4), transparent 60%), radial-gradient(ellipse at 100% 100%, rgba(0,0,0,0.25), transparent 60%)`},"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`relative flex flex-col gap-4 p-6 text-white sm:flex-row sm:items-center sm:gap-6 sm:p-8`,children:[(0,M.jsxs)(zM,{className:`size-16 shrink-0 ring-4 ring-white/30 shadow-md sm:size-20`,children:[t?.image?(0,M.jsx)(BM,{src:t.image,alt:t?.name??``}):null,(0,M.jsx)(VM,{className:`bg-white/20 text-base font-semibold text-white backdrop-blur`,children:a})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,M.jsx)(`p`,{className:`text-xs uppercase tracking-wider text-white/70`,children:e(`home.welcome`,{defaultValue:`Welcome back`})}),(0,M.jsx)(`h2`,{className:`truncate text-2xl font-semibold tracking-tight`,children:t?.name||t?.email||`ObjectStack user`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-white/80`,children:[(0,M.jsx)(Ny,{className:`size-3.5`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`truncate`,children:t?.email}),t?.emailVerified?(0,M.jsx)($N,{className:`border-white/30 bg-white/15 text-[10px] font-medium text-white backdrop-blur hover:bg-white/20`,children:e(`home.verified`,{defaultValue:`Verified`})}):null]})]})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,M.jsx)(aP,{icon:Vy,label:e(`home.stats.score`,{defaultValue:`Security score`}),value:`${r}%`,tone:i,extra:(0,M.jsx)(`div`,{className:`mt-2 h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,M.jsx)(`div`,{className:`h-full bg-brand-gradient transition-[width] duration-500`,style:{width:`${r}%`}})})}),(0,M.jsx)(aP,{icon:dy,label:e(`home.stats.orgs`,{defaultValue:`Organizations`}),value:String(n.length),extra:(0,M.jsxs)(ra,{to:`/organizations`,className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline`,children:[e(`home.stats.manage`,{defaultValue:`Manage`}),(0,M.jsx)(uy,{className:`size-3`})]})}),(0,M.jsx)(aP,{icon:t?.twoFactorEnabled?Vy:Hy,label:e(`home.stats.twoFactor`,{defaultValue:`Two-factor auth`}),value:t?.twoFactorEnabled?e(`home.stats.enabled`,{defaultValue:`Enabled`}):e(`home.stats.disabled`,{defaultValue:`Disabled`}),tone:t?.twoFactorEnabled?`success`:`warn`,extra:(0,M.jsxs)(ra,{to:`/account/two-factor`,className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline`,children:[t?.twoFactorEnabled?e(`home.stats.review`,{defaultValue:`Review`}):e(`home.stats.enable`,{defaultValue:`Enable now`}),(0,M.jsx)(uy,{className:`size-3`})]})})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-muted-foreground`,children:e(`home.quickAccess`,{defaultValue:`Quick access`})}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:o.map(({to:e,label:t,description:n,icon:r})=>(0,M.jsxs)(ra,{to:e,className:`group relative flex items-start gap-3 rounded-lg border bg-card p-4 transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-md hover:shadow-primary/5`,children:[(0,M.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-md bg-brand-gradient-subtle text-primary ring-1 ring-primary/10 transition-transform group-hover:scale-110`,children:(0,M.jsx)(r,{className:`size-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate font-medium`,children:t}),(0,M.jsx)(uy,{className:`size-4 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-primary`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:n})]})]},e))})]})]})}function aP({icon:e,label:t,value:n,tone:r=`neutral`,extra:i}){let a=r===`success`?`text-emerald-600 dark:text-emerald-400`:r===`warn`?`text-amber-600 dark:text-amber-400`:r===`danger`?`text-destructive`:`text-foreground`;return(0,M.jsx)($,{className:`overflow-hidden`,children:(0,M.jsxs)(bN,{className:`p-5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t}),(0,M.jsx)(e,{className:`size-4 ${a}`})]}),(0,M.jsx)(`p`,{className:`mt-1 text-2xl font-semibold tracking-tight ${a}`,children:n}),i]})})}var oP=la(`/organizations/new`)({component:cP});function sP(e){return e.toLowerCase().trim().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function cP(){let{t:e}=vt(),t=Hi(),{create:n,creating:r}=XM(),{setActiveOrganization:i,reloadOrganizations:a,features:o}=JM(),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(!1);(0,j.useEffect)(()=>{o&&o.multiOrgEnabled===!1&&t({to:`/organizations`})},[o,t]);let p=e=>{c(e),d||u(sP(e))};return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 px-6 py-8 overflow-auto`,children:(0,M.jsx)(`div`,{className:`mx-auto max-w-lg`,children:(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{children:e(`organizations.new.title`)}),(0,M.jsx)(yN,{children:e(`organizations.new.description`)})]}),(0,M.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();try{let t=await n({name:s,slug:l||void 0}),r=t?.data??t,o=r?.id??r?.organization?.id;o&&await i(o).catch(()=>{}),await a().catch(()=>{}),q({title:e(`organizations.new.successToast`)}),window.location.assign(`/`)}catch(t){q({title:e(`organizations.new.failed`),description:t.message,variant:`destructive`})}},children:[(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`name`,children:e(`organizations.new.name`)}),(0,M.jsx)(Xx,{id:`name`,required:!0,value:s,onChange:e=>p(e.target.value),placeholder:e(`organizations.new.namePlaceholder`)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`slug`,children:e(`organizations.new.slug`)}),(0,M.jsx)(Xx,{id:`slug`,value:l,onChange:e=>{u(e.target.value),f(!0)},placeholder:e(`organizations.new.slugPlaceholder`),pattern:`[a-z0-9-]+`}),(0,M.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`organizations.new.slugHint`)})]})]}),(0,M.jsxs)(xN,{className:`flex justify-between`,children:[(0,M.jsx)(Q,{type:`button`,variant:`ghost`,onClick:()=>t({to:`/organizations`}),children:e(`organizations.new.cancel`)}),(0,M.jsx)(Q,{type:`submit`,disabled:r||!s,children:e(r?`organizations.new.submitting`:`organizations.new.submit`)})]})]})]})})})})}var lP=la(`/organizations/$orgId`)({component:uP});function uP(){let{t:e}=vt(),{orgId:t}=lP.useParams(),{organizations:n}=YM(),r=n.find(e=>e.id===t);return(0,M.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex-1 overflow-auto px-6 py-8`,children:(0,M.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-6`,children:[(0,M.jsxs)(`header`,{children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:r?.name??e(`organizations.title`)}),r?.slug&&(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground font-mono`,children:r.slug})]}),(0,M.jsx)(ya,{})]})})})}function dP(){let e=qg(),[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null),s=(0,j.useCallback)(async()=>{if(e?.oauth?.applications){i(!0),o(null);try{n((await e.oauth.applications.list())?.applications??[])}catch(e){o(e),n([])}finally{i(!1)}}},[e]);return(0,j.useEffect)(()=>{s()},[s]),{applications:t,loading:r,error:a,reload:s}}function fP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(null);return{register:(0,j.useCallback)(async t=>{if(!e?.oauth?.applications?.register)throw Error(`Client not ready`);n(!0),i(null);try{let n=await e.oauth.applications.register(t);return o(n),n}catch(e){throw i(e),e}finally{n(!1)}},[e]),registering:t,error:r,lastResult:a}}function pP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{remove:(0,j.useCallback)(async t=>{if(!e?.oauth?.applications?.delete)throw Error(`Client not ready`);n(!0),i(null);try{return await e.oauth.applications.delete(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),deleting:t,error:r}}function mP(){let e=qg(),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(null);return{submit:(0,j.useCallback)(async t=>{if(!e?.oauth?.consent)throw Error(`Client not ready`);n(!0),i(null);try{return await e.oauth.consent(t)}catch(e){throw i(e),e}finally{n(!1)}},[e]),submitting:t,error:r}}var hP=la(`/oauth/consent`)({validateSearch:e=>e,component:gP});function gP(){let{t:e}=vt(),t=Hi(),n=qg(),{user:r,loading:i}=JM(),{submit:a,submitting:o}=mP(),[s,c]=(0,j.useState)(null),l=typeof window<`u`?window.location.search:``,u=l.startsWith(`?`)?l.slice(1):l,d=new URLSearchParams(u),f=d.get(`client_id`)??void 0,p=d.get(`scope`)??``;(0,j.useEffect)(()=>{i||r||t({to:`/login`,search:{redirect:window.location.pathname+window.location.search}})},[r,i,t]),(0,j.useEffect)(()=>{if(!f||!n?.oauth?.applications?.getPublic)return;let e=!1;return n.oauth.applications.getPublic(f).then(t=>{if(e)return;let n=t?.data??t;c({name:n?.name??n?.client_name,icon:n?.icon??n?.logo_uri})},()=>{}),()=>{e=!0}},[n,f]);let m=p.split(/\s+/).filter(Boolean),h=async t=>{try{let n=await a({accept:t,oauth_query:u}),r=n?.redirect_uri??n?.redirectURI??n?.url;if(r){window.location.href=r;return}q({title:e(t?`oauth.consent.granted`:`oauth.consent.denied`),description:e(`oauth.consent.noRedirect`),variant:t?void 0:`destructive`})}catch(t){q({title:e(`oauth.consent.failed`),description:t.message,variant:`destructive`})}},g=s?.name??f??e(`oauth.consent.unknownApp`);return(0,M.jsx)(`div`,{className:`flex min-h-svh w-full flex-1 items-center justify-center bg-background px-4`,children:(0,M.jsxs)($,{className:`w-full max-w-md`,children:[(0,M.jsxs)(_N,{className:`items-center text-center`,children:[(0,M.jsx)(`div`,{className:`mb-3 rounded-full border bg-muted p-3`,children:s?.icon?(0,M.jsx)(`img`,{src:s.icon,alt:``,className:`h-8 w-8 rounded`,onError:e=>e.currentTarget.style.display=`none`}):(0,M.jsx)(Oy,{className:`h-7 w-7 text-muted-foreground`})}),(0,M.jsx)(vN,{className:`text-xl`,children:e(`oauth.consent.title`,{appName:g})}),(0,M.jsx)(yN,{children:e(`oauth.consent.request`,{appName:g,suffix:r?.email?` (${r.email})`:``})})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[m.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:e(`oauth.consent.willAllow`)}),(0,M.jsx)(`ul`,{className:`space-y-1.5 rounded-md border bg-muted/40 p-3 text-sm`,children:m.map(t=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(fy,{className:`mt-0.5 h-4 w-4 text-green-600 dark:text-green-400`}),(0,M.jsx)(`span`,{children:_P(t,e)})]},t))})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pt-2`,children:[(0,M.jsxs)(Q,{variant:`outline`,onClick:()=>h(!1),disabled:o,children:[(0,M.jsx)(eb,{className:`mr-2 h-4 w-4`}),e(`oauth.consent.deny`)]}),(0,M.jsxs)(Q,{onClick:()=>h(!0),disabled:o,children:[(0,M.jsx)(fy,{className:`mr-2 h-4 w-4`}),e(o?`oauth.consent.submitting`:`oauth.consent.authorize`)]})]}),(0,M.jsx)(`p`,{className:`pt-2 text-center text-xs text-muted-foreground`,children:e(`oauth.consent.footer`)})]})]})})}function _P(e,t){switch(e){case`openid`:return t(`oauth.consent.scope.openid`);case`profile`:return t(`oauth.consent.scope.profile`);case`email`:return t(`oauth.consent.scope.email`);case`offline_access`:return t(`oauth.consent.scope.offlineAccess`);default:return e}}var vP=la(`/auth/device`)({validateSearch:e=>({user_code:e.user_code??e.code??``}),component:bP});function yP({children:e}){return(0,M.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,M.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,M.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsx)(`div`,{className:`flex flex-col gap-6`,children:e})]})})}function bP(){let{t:e}=vt(),{user_code:t}=vP.useSearch(),{user:n,loading:r}=JM(),i=Hi(),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);return t?r?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsx)(_N,{className:`text-center`,children:(0,M.jsx)(yN,{children:e(`auth.device.loading`)})})})}):n?l?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(_y,{className:`h-10 w-10 text-green-500 mx-auto mb-2`}),(0,M.jsx)(vN,{children:e(`auth.device.approvedTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.approvedDescription`)})]})})}):d?(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.deniedTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.deniedDescription`)})]})})}):(0,M.jsx)(yP,{children:(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.title`)}),(0,M.jsx)(yN,{children:e(`auth.device.subtitle`,{email:n.email})})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e(`auth.device.userCodeLabel`)}),(0,M.jsx)(`p`,{className:`font-mono font-semibold tracking-widest text-lg`,children:t})]}),(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(`p`,{className:`text-sm text-center text-muted-foreground`,children:e(`auth.device.loggedInAs`,{email:n.email})}),p&&(0,M.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:p}),(0,M.jsx)(Q,{onClick:async()=>{m(``),o(!0);try{let n=await fetch(`/api/v1/auth/device/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:t})});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t?.message??t?.error?.message??e(`auth.device.approveFailed`))}u(!0),q({title:e(`auth.device.approveSuccess`),description:e(`auth.device.approveSuccessDescription`)})}catch(t){m(t?.message??e(`auth.device.approveFailed`))}finally{o(!1)}},className:`w-full`,disabled:a||s,children:e(a?`auth.device.approving`:`auth.device.approve`)}),(0,M.jsx)(Q,{onClick:async()=>{m(``),c(!0);try{await fetch(`/api/v1/auth/device/deny`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:t})}),f(!0)}catch(t){m(t?.message??e(`auth.device.denyFailed`))}finally{c(!1)}},variant:`outline`,className:`w-full`,disabled:a||s,children:e(s?`auth.device.denying`:`auth.device.deny`)}),(0,M.jsx)(`div`,{className:`text-center`,children:(0,M.jsx)(`button`,{type:`button`,className:`text-sm text-muted-foreground underline-offset-4 hover:underline`,onClick:()=>i({to:`/`}),children:e(`auth.device.cancel`)})})]})]})]})}):(0,M.jsx)(Ui,{to:`/login`,search:{redirect:`/auth/device?user_code=${encodeURIComponent(t)}`}}):(0,M.jsx)(yP,{children:(0,M.jsx)($,{children:(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{children:e(`auth.device.invalidTitle`)}),(0,M.jsx)(yN,{children:e(`auth.device.invalidDescription`)})]})})})}var xP=la(`/account/two-factor`)({component:SP});function SP(){let{t:e}=vt(),t=qg(),{user:n,loading:r,refresh:i}=JM(),[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(null),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(!1),[T,E]=(0,j.useState)(``),[D,O]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(null);(0,j.useEffect)(()=>{r||o(!!n?.twoFactorEnabled)},[r,n?.twoFactorEnabled]);let ne=async n=>{n.preventDefault(),u(!0);try{let e=await t.auth.twoFactor.enable({password:s});f(e?.totpURI??null),m(e?.backupCodes??null),c(``)}catch(t){q({title:e(`twoFactor.enableFailed`),description:t.message,variant:`destructive`})}finally{u(!1)}},re=async n=>{n.preventDefault(),b(!0);try{await t.auth.twoFactor.verifyTotp({code:_,trustDevice:h}),q({title:e(`twoFactor.enableSuccess`)}),o(!0),f(null),v(``),await i()}catch(t){q({title:e(`twoFactor.invalidCode`),description:t.message,variant:`destructive`})}finally{b(!1)}},ie=async n=>{n.preventDefault(),w(!0);try{await t.auth.twoFactor.disable({password:x}),q({title:e(`twoFactor.disableSuccess`)}),o(!1),S(``),te(null),await i()}catch(t){q({title:e(`twoFactor.disableFailed`),description:t.message,variant:`destructive`})}finally{w(!1)}},ae=async n=>{n.preventDefault(),O(!0);try{te((await t.auth.twoFactor.generateBackupCodes({password:T}))?.backupCodes??[]),E(``),q({title:e(`twoFactor.backupCodes.regenerated`)})}catch(t){q({title:e(`twoFactor.backupCodes.regenerateFailed`),description:t.message,variant:`destructive`})}finally{O(!1)}},oe=async t=>{try{await navigator.clipboard.writeText(t.join(`
|
|
118
118
|
`)),q({title:e(`twoFactor.backupCodes.copied`)})}catch{q({title:e(`twoFactor.backupCodes.copyFailed`),variant:`destructive`})}},k=(0,M.jsx)(eP,{icon:Vy,title:e(`twoFactor.title`),description:e(`twoFactor.notEnabledDescription`),actions:a===!0?(0,M.jsx)($N,{className:`border-transparent bg-emerald-500/15 font-medium text-emerald-600 dark:text-emerald-400`,children:e(`twoFactor.enabled`)}):a===!1?(0,M.jsx)($N,{variant:`outline`,className:`font-medium`,children:e(`twoFactor.notEnabled`)}):null});if(a===null)return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[k,(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsx)(vN,{className:`text-base`,children:e(`twoFactor.loadingStatus`)})}),(0,M.jsxs)(bN,{className:`space-y-2`,children:[(0,M.jsx)(Vw,{className:`h-4 w-48`}),(0,M.jsx)(Vw,{className:`h-9 w-full`}),(0,M.jsx)(Vw,{className:`h-9 w-32`})]})]})]});if(d){let t=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(d)}`;return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[k,(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`twoFactor.setupTitle`)}),(0,M.jsx)(yN,{children:e(`twoFactor.setupDescription`)})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,M.jsx)(`img`,{src:t,alt:e(`twoFactor.qrAlt`),width:200,height:200,className:`rounded border bg-white p-2`}),(0,M.jsx)(`div`,{className:`w-full rounded bg-muted p-3 font-mono text-xs break-all`,children:d}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`twoFactor.uriHint`)})]}),p&&p.length>0&&(0,M.jsxs)(`div`,{className:`rounded border bg-muted/40 p-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:e(`twoFactor.backupCodes.savedTitle`)}),(0,M.jsxs)(Q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>oe(p),children:[(0,M.jsx)(Sy,{className:`mr-1 h-3 w-3`}),e(`twoFactor.backupCodes.copy`)]})]}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`twoFactor.backupCodes.savedHint`)}),(0,M.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-1 font-mono text-xs`,children:p.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-background px-2 py-1`,children:e},e))})]}),(0,M.jsx)(iS,{}),(0,M.jsxs)(`form`,{onSubmit:re,className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`totp-code`,children:e(`twoFactor.verificationCode`)}),(0,M.jsx)(Xx,{id:`totp-code`,placeholder:`000000`,maxLength:6,inputMode:`numeric`,autoComplete:`one-time-code`,value:_,onChange:e=>v(e.target.value),required:!0})]}),(0,M.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),e(`twoFactor.trustDevice`)]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(Q,{type:`submit`,disabled:y||_.length<6,children:e(y?`twoFactor.verifying`:`twoFactor.verify`)}),(0,M.jsx)(Q,{type:`button`,variant:`outline`,onClick:()=>f(null),children:e(`twoFactor.cancel`)})]})]})]})]})]})}return a===!0?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[k,(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`twoFactor.enabledTitle`,{defaultValue:`Authenticator app`})}),(0,M.jsx)(yN,{children:e(`twoFactor.enabledDescription`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:ie,className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`disable-password`,children:e(`twoFactor.password`)}),(0,M.jsx)(Xx,{id:`disable-password`,type:`password`,autoComplete:`current-password`,required:!0,value:x,onChange:e=>S(e.target.value)})]}),(0,M.jsx)(Q,{variant:`destructive`,type:`submit`,disabled:C,children:e(C?`twoFactor.disabling`:`twoFactor.disable`)})]})})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsxs)(vN,{className:`text-base flex items-center gap-2`,children:[(0,M.jsx)(Oy,{className:`h-4 w-4`}),e(`twoFactor.backupCodes.title`)]}),(0,M.jsx)(yN,{children:e(`twoFactor.backupCodes.description`)})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`form`,{onSubmit:ae,className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`backup-password`,children:e(`twoFactor.password`)}),(0,M.jsx)(Xx,{id:`backup-password`,type:`password`,autoComplete:`current-password`,required:!0,value:T,onChange:e=>E(e.target.value)})]}),(0,M.jsxs)(Q,{type:`submit`,variant:`outline`,disabled:D,children:[(0,M.jsx)(Ry,{className:`mr-2 h-4 w-4`}),e(D?`common.saving`:`twoFactor.backupCodes.regenerate`)]})]}),ee&&ee.length>0&&(0,M.jsxs)(`div`,{className:`rounded border bg-muted/40 p-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:e(`twoFactor.backupCodes.newTitle`)}),(0,M.jsxs)(Q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>oe(ee),children:[(0,M.jsx)(Sy,{className:`mr-1 h-3 w-3`}),e(`twoFactor.backupCodes.copy`)]})]}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`twoFactor.backupCodes.savedHint`)}),(0,M.jsx)(`div`,{className:`mt-2 grid grid-cols-2 gap-1 font-mono text-xs`,children:ee.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-background px-2 py-1`,children:e},e))})]})]})]})]}):(0,M.jsxs)(`div`,{className:`space-y-6`,children:[k,(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`twoFactor.enable`)}),(0,M.jsx)(yN,{children:e(`twoFactor.notEnabledDescription`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:ne,className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`enable-password`,children:e(`twoFactor.password`)}),(0,M.jsx)(Xx,{id:`enable-password`,type:`password`,autoComplete:`current-password`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:e(`twoFactor.passwordPlaceholder`)})]}),(0,M.jsx)(Q,{type:`submit`,disabled:l,className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,children:e(l?`twoFactor.loading`:`twoFactor.enable`)})]})})]})]})}var CP=[[/Edg\//i,`Edge`],[/OPR\//i,`Opera`],[/Chrome\//i,`Chrome`],[/Firefox\//i,`Firefox`],[/Safari\//i,`Safari`]],wP=[[/Windows NT 10/i,`Windows 10/11`],[/Windows/i,`Windows`],[/Mac OS X|Macintosh/i,`macOS`],[/iPhone|iOS/i,`iOS`],[/iPad/i,`iPadOS`],[/Android/i,`Android`],[/Linux/i,`Linux`]];function TP(e){if(!e)return{browser:`Unknown`,os:`Unknown`,device:`desktop`,label:`Unknown device`,icon:Ty};let t=CP.find(([t])=>t.test(e))?.[1]??`Browser`,n=wP.find(([t])=>t.test(e))?.[1]??`Unknown OS`,r=/iPad|Tablet/i.test(e),i=!r&&/Mobile|Android|iPhone|iPod/i.test(e),a=r?`tablet`:i?`mobile`:`desktop`,o=Py;return o=a===`mobile`?Uy:a===`tablet`?Gy:/Linux|Windows|Mac/i.test(e)?Py:Ty,{browser:t,os:n,device:a,label:`${t} · ${n}`,icon:o}}var EP=la(`/account/sessions`)({component:DP});function DP(){let{t:e}=vt(),t=qg(),{session:n}=JM(),[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(!0),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(!1),d=async()=>{try{i((await t.auth.sessions.list())?.sessions??[])}catch(t){q({title:e(`sessions.loadFailed`),description:t.message,variant:`destructive`})}finally{o(!1)}};(0,j.useEffect)(()=>{d()},[]);let f=async n=>{c(n);try{await t.auth.sessions.revoke(n),q({title:e(`sessions.revoked`)}),await d()}catch(t){q({title:e(`sessions.revokeFailed`),description:t.message,variant:`destructive`})}finally{c(null)}},p=async()=>{u(!0);try{await t.auth.sessions.revokeOthers(),q({title:e(`sessions.othersRevoked`)}),await d()}catch(t){q({title:e(`sessions.revokeOthersFailed`),description:t.message,variant:`destructive`})}finally{u(!1)}},m=n?.token,h=r.find(e=>e.token===m),g=r.filter(e=>e.token!==m);return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(eP,{icon:Py,title:e(`sessions.title`),description:e(`sessions.description`),actions:r.length>1?(0,M.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:p,disabled:l,children:[(0,M.jsx)(My,{className:`mr-2 h-4 w-4`}),e(l?`sessions.revokingOthers`:`sessions.revokeOthers`)]}):null}),a&&(0,M.jsx)(`div`,{className:`space-y-3`,children:[0,1,2].map(e=>(0,M.jsx)($,{className:`overflow-hidden`,children:(0,M.jsxs)(bN,{className:`flex items-center gap-3 p-4`,children:[(0,M.jsx)(Vw,{className:`size-10 rounded-lg`}),(0,M.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,M.jsx)(Vw,{className:`h-4 w-40`}),(0,M.jsx)(Vw,{className:`h-3 w-64`})]})]})},e))}),!a&&r.length===0&&(0,M.jsx)($,{children:(0,M.jsxs)(bN,{className:`flex flex-col items-center gap-3 p-10 text-center text-sm text-muted-foreground`,children:[(0,M.jsx)(Py,{className:`size-10 text-muted-foreground/50`}),e(`sessions.empty`)]})}),!a&&h&&(0,M.jsx)(OP,{session:h,isCurrent:!0,revoking:!1,onRevoke:()=>void 0,t:e}),!a&&g.length>0&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:e(`sessions.otherDevices`,{defaultValue:`Other signed-in devices`})}),(0,M.jsx)(`div`,{className:`space-y-2`,children:g.map(t=>(0,M.jsx)(OP,{session:t,isCurrent:!1,revoking:s===t.token,onRevoke:()=>f(t.token),t:e},t.id))})]})]})}function OP({session:e,isCurrent:t,revoking:n,onRevoke:r,t:i}){let a=TP(e.userAgent),o=a.icon;return(0,M.jsx)($,{className:t?`border-primary/40 bg-brand-gradient-subtle shadow-sm shadow-primary/10`:`transition-colors hover:bg-accent/30`,children:(0,M.jsxs)(bN,{className:`flex items-center gap-3 p-4`,children:[(0,M.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg `+(t?`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/30`:`bg-muted text-muted-foreground`),children:(0,M.jsx)(o,{className:`size-5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium`,children:a.label}),t&&(0,M.jsx)($N,{className:`border-transparent bg-emerald-500/15 text-[10px] font-medium text-emerald-600 dark:text-emerald-400`,children:i(`sessions.current`)})]}),(0,M.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[e.ipAddress&&(0,M.jsx)(`span`,{className:`font-mono`,children:e.ipAddress}),(0,M.jsx)(`span`,{children:i(`sessions.expires`,{date:new Date(e.expiresAt).toLocaleDateString()})})]})]}),!t&&(0,M.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:r,disabled:n,className:`ml-3 shrink-0 text-muted-foreground hover:text-destructive`,children:[(0,M.jsx)(My,{className:`mr-1.5 h-4 w-4`}),i(`sessions.revoke`,{defaultValue:`Revoke`})]})]})})}var kP=Tw,AP=Ew,jP=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Dw,{ref:n,className:Z(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));jP.displayName=Dw.displayName;var MP=j.forwardRef(({className:e,children:t,...n},r)=>(0,M.jsxs)(AP,{children:[(0,M.jsx)(jP,{}),(0,M.jsxs)(Ow,{ref:r,className:Z(`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]: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-1/2 data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-1/2 sm:rounded-lg`,e),...n,children:[t,(0,M.jsxs)(jw,{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:[(0,M.jsx)(eb,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));MP.displayName=Ow.displayName;var NP=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});NP.displayName=`DialogHeader`;var PP=({className:e,...t})=>(0,M.jsx)(`div`,{className:Z(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});PP.displayName=`DialogFooter`;var FP=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(kw,{ref:n,className:Z(`text-lg font-semibold leading-none tracking-tight`,e),...t}));FP.displayName=kw.displayName;var IP=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(Aw,{ref:n,className:Z(`text-sm text-muted-foreground`,e),...t}));IP.displayName=Aw.displayName;var LP=la(`/account/security`)({component:RP});function RP(){let{t:e}=vt(),t=qg(),n=Hi(),{user:r,logout:i}=JM(),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(!0),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)(!1),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(``),[T,E]=(0,j.useState)(!1);return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(eP,{icon:Hy,title:e(`security.title`),description:e(`security.description`)}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsxs)(vN,{className:`text-base flex items-center gap-2`,children:[(0,M.jsx)(Hy,{className:`h-4 w-4 text-primary`}),e(`security.changePasswordTitle`,{defaultValue:`Change password`})]}),(0,M.jsx)(yN,{children:e(`security.changePasswordDescription`,{defaultValue:`Use at least 8 characters. Mix letters, numbers and symbols for strength.`})})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),s!==l){q({title:e(`security.passwordsMismatch`),variant:`destructive`});return}m(!0);try{await t.auth.changePassword({currentPassword:a,newPassword:s,revokeOtherSessions:d}),q({title:e(`security.changed`)}),o(``),c(``),u(``)}catch(t){q({title:e(`security.changeFailed`),description:t.message,variant:`destructive`})}finally{m(!1)}},className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`current-password`,children:e(`security.currentPassword`)}),(0,M.jsx)(Xx,{id:`current-password`,type:`password`,autoComplete:`current-password`,required:!0,value:a,onChange:e=>o(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`new-password`,children:e(`security.newPassword`)}),(0,M.jsx)(Xx,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:s,onChange:e=>c(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`confirm-new-password`,children:e(`security.confirmPassword`)}),(0,M.jsx)(Xx,{id:`confirm-new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:l,onChange:e=>u(e.target.value)})]}),(0,M.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),e(`security.revokeOtherSessions`)]}),(0,M.jsx)(Q,{type:`submit`,disabled:p,children:e(p?`common.saving`:`security.submit`)})]})})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsxs)(vN,{className:`text-base flex items-center gap-2`,children:[(0,M.jsx)(Ny,{className:`h-4 w-4 text-primary`}),e(`security.email.title`)]}),(0,M.jsx)(yN,{children:e(`security.email.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!(!h||h===r?.email)){v(!0);try{await t.auth.changeEmail({newEmail:h,callbackURL:window.location.origin+`/login`}),q({title:e(`security.email.requested`),description:e(`security.email.checkInbox`,{email:h})}),g(``)}catch(t){q({title:e(`security.email.requestFailed`),description:t.message,variant:`destructive`})}finally{v(!1)}}},className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`current-email`,children:e(`security.email.current`)}),(0,M.jsx)(Xx,{id:`current-email`,value:r?.email??``,disabled:!0})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`new-email`,children:e(`security.email.new`)}),(0,M.jsx)(Xx,{id:`new-email`,type:`email`,value:h,onChange:e=>g(e.target.value),placeholder:e(`security.email.placeholder`),required:!0})]}),(0,M.jsx)(Q,{type:`submit`,disabled:_||!h||h===r?.email,children:e(_?`common.saving`:`security.email.submit`)})]})})]}),(0,M.jsxs)($,{className:`border-destructive/40 bg-destructive/5`,children:[(0,M.jsxs)(_N,{children:[(0,M.jsxs)(vN,{className:`text-base flex items-center gap-2 text-destructive`,children:[(0,M.jsx)(qy,{className:`h-4 w-4`}),e(`security.delete.title`)]}),(0,M.jsx)(yN,{children:e(`security.delete.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(Q,{variant:`destructive`,onClick:()=>b(!0),children:[(0,M.jsx)(Ky,{className:`mr-2 h-4 w-4`}),e(`security.delete.cta`)]})})]}),(0,M.jsx)(kP,{open:y,onOpenChange:b,children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{children:e(`security.delete.dialogTitle`)}),(0,M.jsx)(IP,{children:e(`security.delete.dialogDescription`,{email:r?.email??``})})]}),(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`delete-password`,children:e(`security.delete.password`)}),(0,M.jsx)(Xx,{id:`delete-password`,type:`password`,autoComplete:`current-password`,value:x,onChange:e=>S(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`delete-confirm`,children:e(`security.delete.typeEmail`,{email:r?.email??``})}),(0,M.jsx)(Xx,{id:`delete-confirm`,value:C,onChange:e=>w(e.target.value),placeholder:r?.email??``})]})]}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>b(!1),disabled:T,children:e(`common.cancel`)}),(0,M.jsx)(Q,{variant:`destructive`,onClick:async()=>{if(C!==r?.email){q({title:e(`security.delete.confirmationMismatch`),description:e(`security.delete.confirmationHint`,{email:r?.email??``}),variant:`destructive`});return}E(!0);try{await t.auth.deleteUser({password:x}),q({title:e(`security.delete.success`)});try{await i()}catch{}n({to:`/login`,replace:!0})}catch(t){q({title:e(`security.delete.failed`),description:t.message,variant:`destructive`})}finally{E(!1)}},disabled:T||C!==r?.email,children:e(T?`common.saving`:`security.delete.confirm`)})]})]})})]})}var zP=la(`/account/profile`)({component:BP});function BP(){let{t:e}=vt(),t=qg(),{user:n,refresh:r}=JM(),[i,a]=(0,j.useState)(n?.name??``),[o,s]=(0,j.useState)(n?.image??null),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(!1),f=(0,j.useRef)(null);(0,j.useEffect)(()=>{a(n?.name??``),s(n?.image??null)},[n?.id,n?.name,n?.image]);let p=async n=>{n.preventDefault(),l(!0);try{await t.auth.updateUser({name:i,image:o}),await r(),q({title:e(`profile.updated`)})}catch(t){q({title:e(`profile.updateFailed`),description:t.message,variant:`destructive`})}finally{l(!1)}},m=()=>f.current?.click(),h=async n=>{let i=n.target.files?.[0];if(n.target.value=``,i){d(!0);try{if(!t?.storage?.upload)throw Error(e(`profile.avatarStorageUnavailable`));let n=await t.storage.upload(i,`user`),a=n?.data?.url??n?.url;if(!a)throw Error(`Upload returned no URL`);s(a),await t.auth.updateUser({image:a}),await r(),q({title:e(`profile.avatarUpdated`)})}catch(t){q({title:e(`profile.avatarUploadFailed`),description:t.message,variant:`destructive`})}finally{d(!1)}}},g=(n?.name??n?.email??`?`).split(/\s+/).map(e=>e[0]).join(``).slice(0,2).toUpperCase();return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border bg-card`,children:[(0,M.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-24 bg-brand-gradient`,"aria-hidden":!0}),(0,M.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-24 opacity-30`,style:{backgroundImage:`radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.4), transparent 60%)`},"aria-hidden":!0}),(0,M.jsx)(`div`,{className:`relative px-5 pb-5 pt-12 sm:px-6 sm:pb-6 sm:pt-16`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-end sm:gap-5`,children:[(0,M.jsxs)(zM,{className:`size-20 shrink-0 ring-4 ring-card shadow-md`,children:[o?(0,M.jsx)(BM,{src:o,alt:n?.name??``}):null,(0,M.jsx)(VM,{className:`bg-brand-gradient text-base font-semibold text-primary-foreground`,children:g})]}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,M.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:n?.name||e(`profile.namePlaceholder`)}),(0,M.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:n?.email})]}),(0,M.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:m,disabled:u,className:`self-start sm:self-auto`,children:[(0,M.jsx)(Jy,{className:`mr-2 h-4 w-4`}),e(u?`profile.avatarUploading`:`profile.changeAvatar`)]}),(0,M.jsx)(`input`,{ref:f,type:`file`,accept:`image/*`,className:`hidden`,onChange:h})]})})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`profile.title`)}),(0,M.jsx)(yN,{children:e(`profile.description`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(`form`,{onSubmit:p,className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`profile-email`,children:e(`profile.email`)}),(0,M.jsx)(Xx,{id:`profile-email`,value:n?.email??``,disabled:!0})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(jN,{htmlFor:`profile-name`,children:e(`profile.name`)}),(0,M.jsx)(Xx,{id:`profile-name`,value:i,onChange:e=>a(e.target.value),placeholder:e(`profile.namePlaceholder`)})]}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`profile.avatarHint`)}),(0,M.jsx)(Q,{type:`submit`,disabled:c,className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,children:e(c?`common.saving`:`profile.save`)})]})})]})]})}var VP=la(`/account/linked-accounts`)({component:UP}),HP={google:`Google`,github:`GitHub`,microsoft:`Microsoft`,apple:`Apple`,discord:`Discord`,gitlab:`GitLab`,twitter:`Twitter / X`,facebook:`Facebook`};function UP(){let{t:e}=vt(),t=qg(),[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)(!0),[o,s]=(0,j.useState)(null),c=(0,j.useCallback)(async()=>{if(t?.auth?.accounts){a(!0);try{let e=await t.auth.accounts.list();r(e?.accounts??e?.data??(Array.isArray(e)?e:[]))}catch{r([])}finally{a(!1)}}},[t]);(0,j.useEffect)(()=>{c()},[c]);let l=async n=>{if(confirm(e(`linkedAccounts.unlinkConfirm`,{provider:HP[n.providerId]??n.providerId}))){s(n.id);try{await t.auth.accounts.unlink({providerId:n.providerId,accountId:n.accountId}),q({title:e(`linkedAccounts.unlinked`)}),await c()}catch(t){q({title:e(`linkedAccounts.unlinkFailed`),description:t.message,variant:`destructive`})}finally{s(null)}}},u=async n=>{try{let r=await t.auth.accounts.linkSocial({provider:n,callbackURL:window.location.href}),i=r?.url??r?.data?.url;i?window.location.assign(i):q({title:e(`linkedAccounts.linkFailed`),variant:`destructive`})}catch(t){q({title:e(`linkedAccounts.linkFailed`),description:t.message,variant:`destructive`})}},d=new Set(n.map(e=>e.providerId)),f=Object.keys(HP).filter(e=>!d.has(e));return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(eP,{icon:jy,title:e(`linkedAccounts.title`),description:e(`linkedAccounts.description`)}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`linkedAccounts.connectedTitle`,{defaultValue:`Connected providers`})}),(0,M.jsx)(yN,{children:e(`linkedAccounts.connectedDescription`,{defaultValue:`Sign-in providers currently linked to this account.`})})]}),(0,M.jsxs)(bN,{children:[i&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(Vw,{className:`h-12 w-full`}),(0,M.jsx)(Vw,{className:`h-12 w-full`})]}),!i&&n.length===0&&(0,M.jsxs)(`div`,{className:`text-center py-8`,children:[(0,M.jsx)(jy,{className:`mx-auto h-12 w-12 text-muted-foreground/50`}),(0,M.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e(`linkedAccounts.empty`)})]}),!i&&n.length>0&&(0,M.jsx)(`div`,{className:`divide-y`,children:n.map(t=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)($N,{variant:`secondary`,children:HP[t.providerId]??t.providerId}),t.createdAt&&(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`linkedAccounts.linkedOn`,{date:new Date(t.createdAt).toLocaleDateString()})})]}),(0,M.jsxs)(Q,{variant:`ghost`,size:`sm`,disabled:o===t.id,onClick:()=>l(t),children:[(0,M.jsx)(Ay,{className:`mr-1 h-4 w-4`}),e(`linkedAccounts.unlink`)]})]},t.id))})]})]}),f.length>0&&(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`linkedAccounts.addTitle`)}),(0,M.jsx)(yN,{children:e(`linkedAccounts.addDescription`)})]}),(0,M.jsx)(bN,{children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,M.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:()=>u(e),children:[(0,M.jsx)(Ly,{className:`mr-1 h-3 w-3`}),HP[e]]},e))})})]})]})}function WP(e){let t=qg(),[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null),c=(0,j.useCallback)(async()=>{if(!(!e||!t?.organizations)){a(!0),s(null);try{let n=await t.organizations.listMembers(e);r(n?.members??n?.data?.members??(Array.isArray(n)?n:[]))}catch(e){s(e),r([])}finally{a(!1)}}},[t,e]);return(0,j.useEffect)(()=>{c()},[c]),{members:n,loading:i,error:o,reload:c,inviteMember:(0,j.useCallback)(async(n,r=`member`)=>{if(!e||!t?.organizations)throw Error(`Organization ID or client not available`);let i=await t.organizations.invite({email:n,role:r,organizationId:e});return await c(),i},[t,e,c]),removeMember:(0,j.useCallback)(async n=>{if(!e||!t?.organizations?.removeMember)throw Error(`Organization ID or client not available`);let r=await t.organizations.removeMember(e,{memberIdOrEmail:n});return await c(),r},[t,e,c]),updateMemberRole:(0,j.useCallback)(async(n,r)=>{if(!e||!t?.organizations?.updateMemberRole)throw Error(`Organization ID or client not available`);let i=await t.organizations.updateMemberRole(e,{memberId:n,role:r});return await c(),i},[t,e,c])}}function GP(e){let t=qg(),[n,r]=(0,j.useState)([]),[i,a]=(0,j.useState)(!1),[o,s]=(0,j.useState)(null),c=(0,j.useCallback)(async()=>{if(!(!e||!t?.organizations?.invitations)){a(!0),s(null);try{let n=await t.organizations.invitations.list(e);r(n?.invitations??n?.data?.invitations??(Array.isArray(n)?n:[]))}catch(e){s(e),r([])}finally{a(!1)}}},[t,e]);return(0,j.useEffect)(()=>{c()},[c]),{invitations:n,loading:i,error:o,reload:c,cancelInvitation:(0,j.useCallback)(async e=>{if(!t?.organizations?.invitations?.cancel)throw Error(`Client not available`);let n=await t.organizations.invitations.cancel(e);return await c(),n},[t,c]),resendInvitation:(0,j.useCallback)(async e=>{if(!t?.organizations?.invitations?.resend)throw Error(`Client not available`);let n=await t.organizations.invitations.resend({id:e.id,email:e.email,role:e.role,organizationId:e.organizationId,teamId:e.teamId??null});return await c(),n},[t,c])}}function KP(){let e=qg(),[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null),s=(0,j.useCallback)(async()=>{if(e?.organizations?.invitations?.listMine){i(!0),o(null);try{let t=await e.organizations.invitations.listMine();n(t?.invitations??t?.data?.invitations??(Array.isArray(t)?t:[]))}catch(e){o(e),n([])}finally{i(!1)}}},[e]);return(0,j.useEffect)(()=>{s()},[s]),{invitations:t,loading:r,error:a,reload:s,accept:(0,j.useCallback)(async t=>{let n=await e.organizations.invitations.accept(t);return await s(),n},[e,s]),reject:(0,j.useCallback)(async t=>{let n=await e.organizations.invitations.reject(t);return await s(),n},[e,s])}}var qP=la(`/account/invitations`)({component:JP});function JP(){let{t:e}=vt(),{invitations:t,loading:n,accept:r,reject:i}=KP(),a=t.filter(e=>e.status===`pending`),o=async t=>{try{await r(t),q({title:e(`invitations.accepted`)})}catch(t){q({title:e(`invitations.acceptFailed`),description:t.message,variant:`destructive`})}},s=async t=>{try{await i(t),q({title:e(`invitations.rejected`)})}catch(t){q({title:e(`invitations.rejectFailed`),description:t.message,variant:`destructive`})}};return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(eP,{icon:Dy,title:e(`invitations.title`),description:e(`invitations.description`),actions:a.length>0?(0,M.jsx)($N,{variant:`outline`,className:`font-medium`,children:e(`invitations.pendingCount`,{count:a.length,defaultValue:`{{count}} pending`})}):null}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`invitations.pendingTitle`,{defaultValue:`Pending invitations`})}),(0,M.jsx)(yN,{children:e(`invitations.pendingDescription`,{defaultValue:`Accept to join an organization, or reject to remove it from your inbox.`})})]}),(0,M.jsxs)(bN,{children:[n&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(Vw,{className:`h-12 w-full`}),(0,M.jsx)(Vw,{className:`h-12 w-full`})]}),!n&&a.length===0&&(0,M.jsxs)(`div`,{className:`text-center py-8`,children:[(0,M.jsx)(Dy,{className:`mx-auto h-12 w-12 text-muted-foreground/50`}),(0,M.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e(`invitations.empty`)})]}),!n&&a.length>0&&(0,M.jsx)(`div`,{className:`divide-y`,children:a.map(t=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`div`,{className:`text-sm font-medium`,children:t.organizationId}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,M.jsx)($N,{variant:`outline`,className:`text-xs`,children:e(`common.roles.${t.role}`)}),(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`invitations.expires`,{date:new Date(t.expiresAt).toLocaleDateString()})})]})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(Q,{size:`sm`,onClick:()=>o(t.id),children:[(0,M.jsx)(fy,{className:`mr-1 h-4 w-4`}),e(`invitations.accept`)]}),(0,M.jsxs)(Q,{size:`sm`,variant:`outline`,onClick:()=>s(t.id),children:[(0,M.jsx)(eb,{className:`mr-1 h-4 w-4`}),e(`invitations.reject`)]})]})]},t.id))})]})]})]})}var YP=la(`/accept-invitation/$invitationId`)({component:XP});function XP(){let{t:e}=vt(),{invitationId:t}=YP.useParams(),n=Hi(),r=qg(),{user:i,loading:a,reloadOrganizations:o}=JM(),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{a||i||n({to:`/login`,search:{redirect:`/accept-invitation/${t}`},replace:!0})},[a,i,t,n]),(0,M.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,M.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:[(0,M.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,M.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground`,children:(0,M.jsx)(wy,{className:`size-4`})}),`ObjectStack`]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{className:`text-center`,children:[(0,M.jsx)(vN,{className:`text-xl`,children:e(`acceptInvitation.title`)}),(0,M.jsx)(yN,{children:e(`acceptInvitation.description`)})]}),(0,M.jsxs)(bN,{className:`flex flex-col gap-3`,children:[(0,M.jsx)(Q,{className:`w-full`,onClick:async()=>{c(!0);try{await r.organizations.invitations.accept(t),await o().catch(()=>{}),q({title:e(`acceptInvitation.accepted`)}),n({to:`/organizations`})}catch(t){q({title:e(`acceptInvitation.acceptFailed`),description:t.message,variant:`destructive`})}finally{c(!1)}},disabled:s||l,children:e(s?`acceptInvitation.accepting`:`acceptInvitation.accept`)}),(0,M.jsx)(Q,{variant:`outline`,className:`w-full`,onClick:async()=>{u(!0);try{await r.organizations.invitations.reject(t),q({title:e(`acceptInvitation.declined`)}),n({to:`/organizations`})}catch(t){q({title:e(`acceptInvitation.declineFailed`),description:t.message,variant:`destructive`})}finally{u(!1)}},disabled:s||l,children:e(l?`acceptInvitation.declining`:`acceptInvitation.decline`)})]})]})]})})}var ZP=la(`/organizations/$orgId/`)({component:()=>{let{orgId:e}=ZP.useParams();return(0,M.jsx)(Ui,{to:`/organizations/$orgId/general`,params:{orgId:e},replace:!0})}}),QP=la(`/account/oauth-applications/`)({component:$P});function $P(){let{t:e}=vt(),t=Hi(),{applications:n,loading:r,reload:i}=dP(),{remove:a,deleting:o}=pP(),[s,c]=(0,j.useState)(null);return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(eP,{icon:Oy,title:e(`oauth.applications.title`),description:e(`oauth.applications.description`),actions:(0,M.jsxs)(Q,{onClick:()=>t({to:`/account/oauth-applications/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20 transition-all hover:opacity-95 hover:shadow-md hover:shadow-primary/30`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`oauth.applications.new`)]})}),r?(0,M.jsx)(`div`,{className:`space-y-3`,children:[0,1,2].map(e=>(0,M.jsx)($,{children:(0,M.jsxs)(bN,{className:`flex items-center gap-3 p-4`,children:[(0,M.jsx)(Vw,{className:`size-10 rounded-md`}),(0,M.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,M.jsx)(Vw,{className:`h-4 w-40`}),(0,M.jsx)(Vw,{className:`h-3 w-64`})]})]})},e))}):n.length===0?(0,M.jsx)($,{children:(0,M.jsxs)(bN,{className:`flex flex-col items-center gap-3 p-12 text-center`,children:[(0,M.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-lg bg-brand-gradient-subtle text-primary ring-1 ring-primary/15`,children:(0,M.jsx)(Oy,{className:`h-6 w-6`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`font-medium`,children:e(`oauth.applications.emptyTitle`)}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`oauth.applications.emptyDescription`)})]}),(0,M.jsxs)(Q,{onClick:()=>t({to:`/account/oauth-applications/new`}),className:`bg-brand-gradient text-primary-foreground shadow-sm shadow-primary/20`,children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`oauth.applications.register`)]})]})}):(0,M.jsx)(`div`,{className:`grid gap-3`,children:n.map(t=>(0,M.jsx)($,{className:`group transition-all hover:-translate-y-0.5 hover:border-primary/30 hover:shadow-md hover:shadow-primary/5`,children:(0,M.jsx)(_N,{className:`pb-3`,children:(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsxs)(ra,{to:`/account/oauth-applications/$clientId`,params:{clientId:t.client_id},className:`flex flex-1 items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-md bg-brand-gradient-subtle text-primary ring-1 ring-primary/15 transition-transform group-hover:scale-105`,children:(0,M.jsx)(Oy,{className:`h-5 w-5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(vN,{className:`text-base`,children:t.name}),(0,M.jsx)(yN,{className:`font-mono text-xs`,children:t.client_id})]}),(0,M.jsx)($N,{variant:`outline`,className:`capitalize`,children:t.type}),t.disabled&&(0,M.jsx)($N,{variant:`destructive`,children:e(`oauth.applications.disabled`)})]}),(0,M.jsx)(Q,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c(t)},children:(0,M.jsx)(Ky,{className:`h-4 w-4`})})]})})},t.id))}),(0,M.jsx)(kP,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{children:e(`oauth.applications.deleteDialogTitle`)}),(0,M.jsx)(IP,{children:e(`oauth.applications.deleteDialogDescription`,{name:s?.name??``})})]}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>c(null),disabled:o,children:e(`common.cancel`)}),(0,M.jsx)(Q,{variant:`destructive`,onClick:async()=>{if(s)try{await a(s.client_id),q({title:e(`oauth.applications.deleted`)}),c(null),await i()}catch(t){q({title:e(`oauth.applications.deleteFailed`),description:t.message,variant:`destructive`})}},disabled:o,children:e(o?`oauth.applications.deleting`:`common.delete`)})]})]})})]})}function eF(e,[t,n]){return Math.min(n,Math.max(t,e))}function tF(e){let t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var nF=[` `,`Enter`,`ArrowUp`,`ArrowDown`],rF=[` `,`Enter`],iF=`Select`,[aF,oF,sF]=v_(iF),[cF,lF]=l_(iF,[sF,oD]),uF=oD(),[dF,fF]=cF(iF),[pF,mF]=cF(iF),hF=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=uF(t),[g,_]=j.useState(null),[v,y]=j.useState(null),[b,x]=j.useState(!1),S=tk(l),[C,w]=q_({prop:r,defaultProp:i??!1,onChange:a,caller:iF}),[T,E]=q_({prop:o,defaultProp:s,onChange:c,caller:iF}),D=j.useRef(null),O=g?m||!!g.closest(`form`):!0,[ee,te]=j.useState(new Set),ne=Array.from(ee).map(e=>e.props.value).join(`;`);return(0,M.jsx)(SD,{...h,children:(0,M.jsxs)(dF,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:sS(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,M.jsx)(aF.Provider,{scope:t,children:(0,M.jsx)(pF,{scope:e.__scopeSelect,onNativeOptionAdd:j.useCallback(e=>{te(t=>new Set(t).add(e))},[]),onNativeOptionRemove:j.useCallback(e=>{te(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,M.jsxs)(uI,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,M.jsx)(`option`,{value:``}):null,Array.from(ee)]},ne):null]})})};hF.displayName=iF;var gF=`SelectTrigger`,_F=j.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=uF(n),o=fF(gF,n),s=o.disabled||r,c=s_(t,o.onTriggerChange),l=oF(n),u=j.useRef(`touch`),[d,f,p]=fI(e=>{let t=l().filter(e=>!e.disabled),n=pI(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,M.jsx)(CD,{asChild:!0,...a,children:(0,M.jsx)(y_.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":dI(o.value)?``:void 0,...i,ref:c,onClick:J(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:J(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:J(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&nF.includes(e.key)&&(m(),e.preventDefault())})})})});_F.displayName=gF;var vF=`SelectValue`,yF=j.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=fF(vF,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=s_(t,c.onValueNodeChange);return R_(()=>{l(u)},[l,u]),(0,M.jsx)(y_.span,{...s,ref:d,style:{pointerEvents:`none`},children:dI(c.value)?(0,M.jsx)(M.Fragment,{children:o}):a})});yF.displayName=vF;var bF=`SelectIcon`,xF=j.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,M.jsx)(y_.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});xF.displayName=bF;var SF=`SelectPortal`,CF=e=>(0,M.jsx)(B_,{asChild:!0,...e});CF.displayName=SF;var wF=`SelectContent`,TF=j.forwardRef((e,t)=>{let n=fF(wF,e.__scopeSelect),[r,i]=j.useState();if(R_(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Gi.createPortal((0,M.jsx)(DF,{scope:e.__scopeSelect,children:(0,M.jsx)(aF.Slot,{scope:e.__scopeSelect,children:(0,M.jsx)(`div`,{children:e.children})})}),t):null}return(0,M.jsx)(jF,{...e,ref:t})});TF.displayName=wF;var EF=10,[DF,OF]=cF(wF),kF=`SelectContentImpl`,AF=d_(`SelectContent.RemoveScroll`),jF=j.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=fF(wF,n),[y,b]=j.useState(null),[x,S]=j.useState(null),C=s_(t,e=>b(e)),[w,T]=j.useState(null),[E,D]=j.useState(null),O=oF(n),[ee,te]=j.useState(!1),ne=j.useRef(!1);j.useEffect(()=>{if(y)return WC(y)},[y]),TS();let re=j.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),ie=j.useCallback(()=>re([w,y]),[re,w,y]);j.useEffect(()=>{ee&&ie()},[ee,ie]);let{onOpenChange:ae,triggerPointerDownPosRef:oe}=v;j.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(oe.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(oe.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||ae(!1),document.removeEventListener(`pointermove`,t),oe.current=null};return oe.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,ae,oe]),j.useEffect(()=>{let e=()=>ae(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[ae]);let[k,se]=fI(e=>{let t=O().filter(e=>!e.disabled),n=pI(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ce=j.useCallback((e,t,n)=>{let r=!ne.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(ne.current=!0))},[v.value]),le=j.useCallback(()=>y?.focus(),[y]),ue=j.useCallback((e,t,n)=>{let r=!ne.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),A=r===`popper`?FF:NF,de=A===FF?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,M.jsx)(DF,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ce,selectedItem:w,onItemLeave:le,itemTextRefCallback:ue,focusSelectedItem:ie,selectedItemText:E,position:r,isPositioned:ee,searchRef:k,children:(0,M.jsx)(FC,{as:AF,allowPinchZoom:!0,children:(0,M.jsx)(fS,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:J(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,M.jsx)(k_,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,M.jsx)(A,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...de,onPlaced:()=>te(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:J(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&se(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>re(t)),e.preventDefault()}})})})})})})});jF.displayName=kF;var MF=`SelectItemAlignedPosition`,NF=j.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=fF(wF,n),o=OF(wF,n),[s,c]=j.useState(null),[l,u]=j.useState(null),d=s_(t,e=>u(e)),f=oF(n),p=j.useRef(!1),m=j.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=j.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-EF,d=eF(a,[EF,Math.max(EF,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-EF,d=eF(a,[EF,Math.max(EF,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-EF*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-EF,D=c-E,O=g.offsetHeight/2,ee=g.offsetTop+O,te=m+v+ee,ne=x-te;if(te<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=te+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+ne;s.style.height=t+`px`,h.scrollTop=te-E+h.offsetTop}s.style.margin=`${EF}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);R_(()=>y(),[y]);let[b,x]=j.useState();return R_(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,M.jsx)(IF,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:j.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,M.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,M.jsx)(y_.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});NF.displayName=MF;var PF=`SelectPopperPosition`,FF=j.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=EF,...a}=e,o=uF(n);return(0,M.jsx)(wD,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.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)`}})});FF.displayName=PF;var[IF,LF]=cF(wF,{}),RF=`SelectViewport`,zF=j.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=OF(RF,n),o=LF(RF,n),s=s_(t,a.onViewportChange),c=j.useRef(0);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,M.jsx)(aF.Slot,{scope:n,children:(0,M.jsx)(y_.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:J(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-EF*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});zF.displayName=RF;var BF=`SelectGroup`,[VF,HF]=cF(BF),UF=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=sS();return(0,M.jsx)(VF,{scope:n,id:i,children:(0,M.jsx)(y_.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});UF.displayName=BF;var WF=`SelectLabel`,GF=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=HF(WF,n);return(0,M.jsx)(y_.div,{id:i.id,...r,ref:t})});GF.displayName=WF;var KF=`SelectItem`,[qF,JF]=cF(KF),YF=j.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=fF(KF,n),c=OF(KF,n),l=s.value===r,[u,d]=j.useState(a??``),[f,p]=j.useState(!1),m=s_(t,e=>c.itemRefCallback?.(e,r,i)),h=sS(),g=j.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,M.jsx)(qF,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:j.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,M.jsx)(aF.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,M.jsx)(y_.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:J(o.onFocus,()=>p(!0)),onBlur:J(o.onBlur,()=>p(!1)),onClick:J(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:J(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:J(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:J(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:J(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:J(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(rF.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});YF.displayName=KF;var XF=`SelectItemText`,ZF=j.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=fF(XF,n),s=OF(XF,n),c=JF(XF,n),l=mF(XF,n),[u,d]=j.useState(null),f=s_(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=j.useMemo(()=>(0,M.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return R_(()=>(h(m),()=>g(m)),[h,g,m]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y_.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Gi.createPortal(a.children,o.valueNode):null]})});ZF.displayName=XF;var QF=`SelectItemIndicator`,$F=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return JF(QF,n).isSelected?(0,M.jsx)(y_.span,{"aria-hidden":!0,...r,ref:t}):null});$F.displayName=QF;var eI=`SelectScrollUpButton`,tI=j.forwardRef((e,t)=>{let n=OF(eI,e.__scopeSelect),r=LF(eI,e.__scopeSelect),[i,a]=j.useState(!1),o=s_(t,r.onScrollButtonChange);return R_(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,M.jsx)(iI,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});tI.displayName=eI;var nI=`SelectScrollDownButton`,rI=j.forwardRef((e,t)=>{let n=OF(nI,e.__scopeSelect),r=LF(nI,e.__scopeSelect),[i,a]=j.useState(!1),o=s_(t,r.onScrollButtonChange);return R_(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,M.jsx)(iI,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});rI.displayName=nI;var iI=j.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=OF(`SelectScrollButton`,n),o=j.useRef(null),s=oF(n),c=j.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),R_(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,M.jsx)(y_.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:J(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:J(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:J(i.onPointerLeave,()=>{c()})})}),aI=`SelectSeparator`,oI=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,M.jsx)(y_.div,{"aria-hidden":!0,...r,ref:t})});oI.displayName=aI;var sI=`SelectArrow`,cI=j.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=uF(n),a=fF(sI,n),o=OF(sI,n);return a.open&&o.position===`popper`?(0,M.jsx)(TD,{...i,...r,ref:t}):null});cI.displayName=sI;var lI=`SelectBubbleInput`,uI=j.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=j.useRef(null),a=s_(r,i),o=tF(t);return j.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,M.jsx)(y_.select,{...n,style:{...X_,...n.style},ref:a,defaultValue:t})});uI.displayName=lI;function dI(e){return e===``||e===void 0}function fI(e){let t=x_(e),n=j.useRef(``),r=j.useRef(0),i=j.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=j.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function pI(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=mI(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function mI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var hI=hF,gI=_F,_I=yF,vI=xF,yI=CF,bI=TF,xI=zF,SI=GF,CI=YF,wI=ZF,TI=$F,EI=tI,DI=rI,OI=oI,kI=hI,AI=_I,jI=j.forwardRef(({className:e,children:t,...n},r)=>(0,M.jsxs)(gI,{ref:r,className:Z(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,M.jsx)(vI,{asChild:!0,children:(0,M.jsx)(py,{className:`h-4 w-4 opacity-50`})})]}));jI.displayName=gI.displayName;var MI=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(EI,{ref:n,className:Z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,M.jsx)(hy,{className:`h-4 w-4`})}));MI.displayName=EI.displayName;var NI=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(DI,{ref:n,className:Z(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,M.jsx)(py,{className:`h-4 w-4`})}));NI.displayName=DI.displayName;var PI=j.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,M.jsx)(yI,{children:(0,M.jsxs)(bI,{ref:i,className:Z(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,M.jsx)(MI,{}),(0,M.jsx)(xI,{className:Z(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,M.jsx)(NI,{})]})}));PI.displayName=bI.displayName;var FI=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(SI,{ref:n,className:Z(`px-2 py-1.5 text-sm font-semibold`,e),...t}));FI.displayName=SI.displayName;var II=j.forwardRef(({className:e,children:t,...n},r)=>(0,M.jsxs)(CI,{ref:r,className:Z(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,M.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,M.jsx)(TI,{children:(0,M.jsx)(fy,{className:`h-4 w-4`})})}),(0,M.jsx)(wI,{children:t})]}));II.displayName=CI.displayName;var LI=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(OI,{ref:n,className:Z(`-mx-1 my-1 h-px bg-muted`,e),...t}));LI.displayName=OI.displayName;var RI=la(`/organizations/$orgId/teams`)({component:zI});function zI(){let{t:e}=vt(),{orgId:t}=RI.useParams(),n=qg(),{members:r}=WP(t),[i,a]=(0,j.useState)([]),[o,s]=(0,j.useState)(!0),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)([]),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(``),w=(0,j.useCallback)(async()=>{if(n?.organizations?.teams){s(!0);try{a((await n.organizations.teams.list(t))?.teams??[])}catch{a([])}finally{s(!1)}}},[n,t]);(0,j.useEffect)(()=>{w()},[w]);let T=(0,j.useCallback)(async e=>{if(n?.organizations?.teams){y(!0);try{_((await n.organizations.teams.listMembers(e))?.members??[])}catch{_([])}finally{y(!1)}}},[n]);(0,j.useEffect)(()=>{m&&T(m)},[m,T]);let E=async r=>{if(r.preventDefault(),u.trim()){p(!0);try{await n.organizations.teams.create({name:u.trim(),organizationId:t}),q({title:e(`teams.created`)}),l(!1),d(``),await w()}catch(t){q({title:e(`teams.createFailed`),description:t.message,variant:`destructive`})}finally{p(!1)}}},D=async r=>{if(confirm(e(`teams.deleteConfirm`,{name:r.name})))try{await n.organizations.teams.delete({teamId:r.id,organizationId:t}),q({title:e(`teams.deleted`)}),m===r.id&&h(null),await w()}catch(t){q({title:e(`teams.deleteFailed`),description:t.message,variant:`destructive`})}},O=async()=>{if(!(!m||!S))try{await n.organizations.teams.addMember({teamId:m,userId:S}),q({title:e(`teams.memberAdded`)}),x(!1),C(``),await T(m)}catch(t){q({title:e(`teams.addMemberFailed`),description:t.message,variant:`destructive`})}},ee=async(t,r)=>{try{await n.organizations.teams.removeMember({teamId:t,userId:r}),q({title:e(`teams.memberRemoved`)}),await T(t)}catch(t){q({title:e(`teams.removeMemberFailed`),description:t.message,variant:`destructive`})}},te=Object.fromEntries(r.map(e=>[e.userId,e])),ne=new Set(g.map(e=>e.userId)),re=r.filter(e=>!ne.has(e.userId));return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`teams.title`,{count:i.length})}),(0,M.jsx)(yN,{children:e(`teams.description`)})]}),(0,M.jsxs)(Q,{size:`sm`,onClick:()=>l(!0),children:[(0,M.jsx)(Ly,{className:`mr-2 h-4 w-4`}),e(`teams.create`)]})]})}),(0,M.jsxs)(bN,{children:[o&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(Vw,{className:`h-12 w-full`}),(0,M.jsx)(Vw,{className:`h-12 w-full`})]}),!o&&i.length===0&&(0,M.jsxs)(`div`,{className:`text-center py-8`,children:[(0,M.jsx)(Qy,{className:`mx-auto h-12 w-12 text-muted-foreground/50`}),(0,M.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e(`teams.empty`)})]}),!o&&i.length>0&&(0,M.jsx)(`div`,{className:`divide-y`,children:i.map(t=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`flex-1 text-left`,onClick:()=>h(m===t.id?null:t.id),children:[(0,M.jsx)(`div`,{className:`font-medium text-sm`,children:t.name}),t.createdAt&&(0,M.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:new Date(t.createdAt).toLocaleDateString()})]}),(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,children:(0,M.jsx)(Cy,{className:`h-4 w-4`})})}),(0,M.jsx)(tM,{align:`end`,children:(0,M.jsxs)(nM,{className:`text-destructive`,onClick:()=>D(t),children:[(0,M.jsx)(Ky,{className:`mr-2 h-4 w-4`}),e(`teams.delete`)]})})]})]}),m===t.id&&(0,M.jsxs)(`div`,{className:`pb-3 pl-4 border-l-2 ml-2 space-y-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e(`teams.members`,{count:g.length})}),(0,M.jsxs)(Q,{size:`sm`,variant:`outline`,onClick:()=>x(!0),children:[(0,M.jsx)(Xy,{className:`mr-1 h-3 w-3`}),e(`teams.addMember`)]})]}),v&&(0,M.jsx)(Vw,{className:`h-8 w-full`}),!v&&g.length===0&&(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`teams.noMembers`)}),!v&&g.map(e=>{let n=te[e.userId];return(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,M.jsx)(`span`,{className:`text-sm`,children:n?.user?.name||n?.user?.email||e.userId}),(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>ee(t.id,e.userId),children:(0,M.jsx)(Yy,{className:`h-3 w-3`})})]},e.id)})]})]},t.id))})]})]}),(0,M.jsx)(kP,{open:c,onOpenChange:l,children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{children:e(`teams.createTitle`)}),(0,M.jsx)(IP,{children:e(`teams.createDescription`)})]}),(0,M.jsxs)(`form`,{onSubmit:E,children:[(0,M.jsx)(`div`,{className:`space-y-4 py-4`,children:(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`team-name`,children:e(`teams.nameLabel`)}),(0,M.jsx)(Xx,{id:`team-name`,required:!0,placeholder:e(`teams.namePlaceholder`),value:u,onChange:e=>d(e.target.value)})]})}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,type:`button`,onClick:()=>l(!1),children:e(`common.cancel`)}),(0,M.jsx)(Q,{type:`submit`,disabled:f,children:e(f?`common.saving`:`teams.create`)})]})]})]})}),(0,M.jsx)(kP,{open:b,onOpenChange:x,children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{children:e(`teams.addMemberTitle`)}),(0,M.jsx)(IP,{children:e(`teams.addMemberDescription`)})]}),(0,M.jsx)(`div`,{className:`space-y-4 py-4`,children:(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{children:e(`teams.selectMember`)}),(0,M.jsxs)(kI,{value:S,onValueChange:C,children:[(0,M.jsx)(jI,{children:(0,M.jsx)(AI,{placeholder:e(`teams.selectMemberPlaceholder`)})}),(0,M.jsx)(PI,{children:re.map(e=>(0,M.jsx)(II,{value:e.userId,children:e.user?.name||e.user?.email||e.userId},e.userId))})]})]})}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>x(!1),children:e(`common.cancel`)}),(0,M.jsx)(Q,{onClick:O,disabled:!S,children:e(`teams.addMember`)})]})]})})]})}var BI=j.forwardRef(({className:e,...t},n)=>(0,M.jsx)(`textarea`,{className:Z(`flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));BI.displayName=`Textarea`;var VI=la(`/organizations/$orgId/members`)({component:HI});function HI(){let{t:e}=vt(),{orgId:t}=VI.useParams(),{organizations:n}=YM(),{user:r}=JM(),i=qg(),a=n.find(e=>e.id===t),{members:o,loading:s,inviteMember:c,removeMember:l,updateMemberRole:u}=WP(t),{invitations:d,loading:f,cancelInvitation:p,resendInvitation:m}=GP(t),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(!1),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(`member`),[T,E]=(0,j.useState)(!1),[D,O]=(0,j.useState)(!1),ee=d.filter(e=>e.status===`pending`),te=o.find(e=>e.userId===r?.id),ne=te?.role===`owner`||te?.role===`admin`,re=async()=>{let t=_?x.split(/[,;\n]+/).map(e=>e.trim()).filter(Boolean):[y.trim()].filter(Boolean);if(t.length===0){q({title:e(`organizations.members.emailRequired`),variant:`destructive`});return}E(!0);let n=0;try{for(let e of t)try{await c(e,C)}catch{n++}n>0&&n<t.length?q({title:e(`organizations.members.invitePartialSuccess`,{sent:t.length-n,failed:n}),variant:`destructive`}):n===t.length?q({title:e(`organizations.members.inviteFailed`),variant:`destructive`}):q({title:e(`organizations.members.invitationSent`)}),g(!1),b(``),S(``),w(`member`)}finally{E(!1)}},ie=async(t,n)=>{if(confirm(e(`organizations.members.removeConfirm`,{name:n})))try{await l(t),q({title:e(`organizations.members.memberRemoved`)})}catch(t){q({title:e(`organizations.members.removeFailed`),description:t.message,variant:`destructive`})}},ae=async(t,n)=>{try{await u(t,n),q({title:e(`organizations.members.roleUpdated`)})}catch(t){q({title:e(`organizations.members.roleUpdateFailed`),description:t.message,variant:`destructive`})}},oe=async()=>{if(confirm(e(`organizations.members.leaveConfirm`,{org:a?.name??t}))){O(!0);try{await i.organizations.leave(t),q({title:e(`organizations.members.leftOrg`)}),window.location.assign(`/`)}catch(t){q({title:e(`organizations.members.leaveFailed`),description:t.message,variant:`destructive`})}finally{O(!1)}}},k=async(t,n)=>{if(confirm(e(`organizations.members.cancelConfirm`,{email:n})))try{await p(t),q({title:e(`organizations.members.invitationCanceled`)})}catch(t){q({title:e(`organizations.members.cancelFailed`),description:t.message,variant:`destructive`})}},se=async t=>{try{await m(t),q({title:e(`organizations.members.invitationResent`)})}catch(t){q({title:e(`organizations.members.resendFailed`),description:t.message,variant:`destructive`})}},ce=async t=>{let n=`${window.location.origin}/accept-invitation/${t}`;try{await navigator.clipboard.writeText(n),q({title:e(`organizations.members.linkCopied`)})}catch{q({title:e(`organizations.members.linkCopyFailed`),variant:`destructive`})}};return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`organizations.members.title`,{count:o.length})}),(0,M.jsx)(yN,{children:e(`organizations.members.description`)})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[te&&te.role!==`owner`&&(0,M.jsxs)(Q,{size:`sm`,variant:`outline`,onClick:oe,disabled:D,children:[(0,M.jsx)(My,{className:`mr-2 h-4 w-4`}),e(`organizations.members.leave`)]}),ne&&(0,M.jsxs)(Q,{size:`sm`,onClick:()=>g(!0),children:[(0,M.jsx)(Xy,{className:`mr-2 h-4 w-4`}),e(`organizations.members.invite`)]})]})]})}),(0,M.jsxs)(bN,{children:[s&&(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organizations.members.loadingMembers`)}),!s&&o.length===0&&(0,M.jsxs)(`div`,{className:`text-center py-8`,children:[(0,M.jsx)($y,{className:`mx-auto h-12 w-12 text-muted-foreground/50`}),(0,M.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e(`organizations.members.empty`)})]}),!s&&o.length>0&&(0,M.jsx)(`div`,{className:`divide-y`,children:o.map(t=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsxs)(`div`,{className:`font-medium text-sm`,children:[t.user?.name||t.user?.email||t.userId,t.userId===r?.id&&(0,M.jsx)($N,{variant:`secondary`,className:`ml-2 text-xs`,children:e(`organizations.members.you`)})]}),t.user?.email&&(0,M.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.user.email})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ne&&t.role!==`owner`&&t.userId!==r?.id?(0,M.jsxs)(kI,{value:t.role,onValueChange:e=>ae(t.id,e),children:[(0,M.jsx)(jI,{className:`h-7 w-24 text-xs`,children:(0,M.jsx)(AI,{})}),(0,M.jsxs)(PI,{children:[(0,M.jsx)(II,{value:`admin`,children:e(`common.roles.admin`)}),(0,M.jsx)(II,{value:`member`,children:e(`common.roles.member`)})]})]}):(0,M.jsx)($N,{variant:`secondary`,className:`text-xs`,children:e(`common.roles.${t.role??`member`}`)}),ne&&t.role!==`owner`&&t.userId!==r?.id&&(0,M.jsxs)(Zj,{children:[(0,M.jsx)(Qj,{asChild:!0,children:(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,children:(0,M.jsx)(Cy,{className:`h-4 w-4`})})}),(0,M.jsx)(tM,{align:`end`,children:(0,M.jsxs)(nM,{className:`text-destructive`,onClick:()=>ie(t.id,t.user?.name||t.user?.email||t.userId),children:[(0,M.jsx)(Ky,{className:`mr-2 h-4 w-4`}),e(`organizations.members.removeMember`)]})})]})]})]},t.id))})]})]}),(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(vN,{className:`text-base`,children:e(`organizations.members.pendingTitle`,{count:ee.length})}),(0,M.jsx)(yN,{children:e(`organizations.members.pendingDescription`)})]}),ne&&(0,M.jsxs)(Q,{size:`sm`,variant:`outline`,onClick:()=>g(!0),children:[(0,M.jsx)(Xy,{className:`mr-2 h-4 w-4`}),e(`organizations.members.sendInvitation`)]})]})}),(0,M.jsxs)(bN,{children:[f&&(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organizations.members.loadingInvitations`)}),!f&&ee.length===0&&(0,M.jsxs)(`div`,{className:`text-center py-8`,children:[(0,M.jsx)(Ny,{className:`mx-auto h-12 w-12 text-muted-foreground/50`}),(0,M.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e(`organizations.members.noPending`)})]}),!f&&ee.length>0&&(0,M.jsx)(`div`,{className:`divide-y`,children:ee.map(t=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`div`,{className:`font-medium text-sm`,children:t.email}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,M.jsx)($N,{variant:`outline`,className:`text-xs`,children:e(`common.roles.${t.role}`)}),(0,M.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,M.jsx)(xy,{className:`h-3 w-3`}),e(`organizations.members.expires`,{date:new Date(t.expiresAt).toLocaleDateString()})]})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,title:e(`organizations.members.copyLink`),onClick:()=>ce(t.id),children:(0,M.jsx)(Sy,{className:`h-4 w-4`})}),(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,title:e(`organizations.members.resend`),onClick:()=>se(t),children:(0,M.jsx)(Ry,{className:`h-4 w-4`})}),(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,title:e(`organizations.members.cancel`),onClick:()=>k(t.id,t.email),children:(0,M.jsx)(eb,{className:`h-4 w-4`})})]})]},t.id))})]})]}),(0,M.jsx)(kP,{open:h,onOpenChange:g,children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{children:e(`organizations.members.inviteDialogTitle`)}),(0,M.jsx)(IP,{children:e(`organizations.members.inviteDialogDescription`,{organization:a?.name??``})})]}),(0,M.jsxs)(`div`,{className:`space-y-4 py-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(Q,{type:`button`,variant:_?`outline`:`default`,size:`sm`,onClick:()=>v(!1),children:e(`organizations.members.singleInvite`)}),(0,M.jsx)(Q,{type:`button`,variant:_?`default`:`outline`,size:`sm`,onClick:()=>v(!0),children:e(`organizations.members.bulkInvite`)})]}),_?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{children:e(`organizations.members.bulkEmails`)}),(0,M.jsx)(BI,{placeholder:e(`organizations.members.bulkEmailsPlaceholder`),rows:5,value:x,onChange:e=>S(e.target.value)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organizations.members.bulkEmailsHint`)})]}):(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`invite-email`,children:e(`organizations.members.email`)}),(0,M.jsx)(Xx,{id:`invite-email`,type:`email`,placeholder:e(`organizations.members.emailPlaceholder`),value:y,onChange:e=>b(e.target.value)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`role`,children:e(`organizations.members.role`)}),(0,M.jsxs)(kI,{value:C,onValueChange:w,children:[(0,M.jsx)(jI,{id:`role`,children:(0,M.jsx)(AI,{})}),(0,M.jsxs)(PI,{children:[(0,M.jsx)(II,{value:`owner`,children:e(`common.roles.owner`)}),(0,M.jsx)(II,{value:`admin`,children:e(`common.roles.admin`)}),(0,M.jsx)(II,{value:`member`,children:e(`common.roles.member`)})]})]})]})]}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>g(!1),disabled:T,children:e(`common.cancel`)}),(0,M.jsx)(Q,{onClick:re,disabled:T,children:e(T?`organizations.members.sending`:`organizations.members.sendInvitation`)})]})]})})]})}var UI=la(`/organizations/$orgId/general`)({component:WI});function WI(){let{t:e}=vt(),{orgId:t}=UI.useParams(),n=Hi(),{organizations:r}=YM(),{session:i,user:a,setActiveOrganization:o}=JM(),s=r.find(e=>e.id===t),{members:c}=WP(t),{invitations:l}=GP(t),{remove:u,deleting:d}=QM(),{update:f,updating:p}=ZM(),[m,h]=(0,j.useState)(``),[g,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(``),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(``);(0,j.useEffect)(()=>{h(s?.name??``),_(s?.slug??``),y(s?.logo??``)},[s?.id,s?.name,s?.slug,s?.logo]);let w=i?.activeOrganizationId===t,T=l.filter(e=>e.status===`pending`),E=(a?c.find(e=>e.userId===a.id):void 0)?.role??null,D=E===`owner`||E===`admin`,O=D&&s!=null&&(m.trim()!==(s.name??``)||g.trim()!==(s.slug??``)||v.trim()!==(s.logo??``));return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,M.jsx)($N,{variant:`outline`,children:e(`organizations.active`)}),E&&(0,M.jsx)($N,{variant:`secondary`,className:`capitalize`,children:e(`common.roles.${E}`)})]}),!w&&(0,M.jsx)(Q,{size:`sm`,variant:`outline`,onClick:async()=>{try{await o(t),q({title:e(`organizations.general.switched`)})}catch(t){q({title:e(`organizations.general.switchFailed`),description:t.message,variant:`destructive`})}},children:e(`organizations.general.setActive`)})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{children:e(`organizations.general.detailsTitle`)}),(0,M.jsx)(yN,{children:e(D?`organizations.general.detailsDescription`:`organizations.general.detailsReadOnly`)})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`org-name`,children:e(`organizations.new.name`)}),(0,M.jsx)(Xx,{id:`org-name`,value:m,onChange:e=>h(e.target.value),disabled:!D||p,placeholder:e(`organizations.general.namePlaceholder`)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`org-slug`,children:e(`organizations.new.slug`)}),(0,M.jsx)(Xx,{id:`org-slug`,value:g,onChange:e=>_(e.target.value),disabled:!D||p,placeholder:e(`organizations.general.slugPlaceholder`),className:`font-mono text-sm`}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organizations.general.slugHint`)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`org-logo`,children:e(`organizations.general.logo`)}),(0,M.jsx)(Xx,{id:`org-logo`,value:v,onChange:e=>y(e.target.value),disabled:!D||p,placeholder:e(`organizations.general.logoPlaceholder`)})]}),(0,M.jsxs)(`div`,{className:`flex justify-between border-t pt-4 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organizations.general.organizationId`)}),(0,M.jsx)(`code`,{className:`font-mono`,children:t})]})]}),D&&(0,M.jsxs)(bN,{className:`flex justify-end gap-2 border-t pt-4`,children:[(0,M.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{h(s?.name??``),_(s?.slug??``),y(s?.logo??``)},disabled:!O||p,children:e(`organizations.general.reset`)}),(0,M.jsxs)(Q,{size:`sm`,onClick:async()=>{if(!s||!D||!O)return;let n=m.trim();if(!n){q({title:e(`organizations.general.nameRequired`),variant:`destructive`});return}try{await f(t,{name:n,slug:g.trim()||void 0,logo:v.trim()||void 0}),q({title:e(`organizations.general.updated`)})}catch(t){q({title:e(`organizations.general.updateFailed`),description:t.message,variant:`destructive`})}},disabled:!O||p,children:[(0,M.jsx)(zy,{className:`mr-2 h-4 w-4`}),e(p?`common.saving`:`organizations.general.save`)]})]})]}),(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsx)(vN,{className:`text-base`,children:e(`organizations.general.overviewTitle`)})}),(0,M.jsxs)(bN,{className:`space-y-3 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex justify-between`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organizations.general.members`)}),(0,M.jsx)(`span`,{children:c.length})]}),(0,M.jsxs)(`div`,{className:`flex justify-between`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organizations.general.pendingInvitations`)}),(0,M.jsx)(`span`,{children:T.length})]})]})]}),D&&(0,M.jsxs)($,{className:`border-destructive/40`,children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base text-destructive`,children:e(`organizations.general.dangerTitle`)}),(0,M.jsx)(yN,{children:e(`organizations.general.dangerDescription`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(Q,{variant:`destructive`,size:`sm`,onClick:()=>x(!0),disabled:d,children:[(0,M.jsx)(Ky,{className:`mr-2 h-4 w-4`}),e(`organizations.general.delete`)]})})]}),(0,M.jsx)(kP,{open:b,onOpenChange:e=>{x(e),e||C(``)},children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{className:`text-destructive`,children:e(`organizations.general.deleteDialogTitle`)}),(0,M.jsx)(IP,{children:e(`organizations.general.deleteDialogDescription`,{name:s?.name??``})})]}),(0,M.jsx)(`div`,{className:`space-y-4 py-2`,children:(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`delete-confirm`,children:e(`organizations.general.deleteDialogLabel`,{name:s?.name??``})}),(0,M.jsx)(Xx,{id:`delete-confirm`,value:S,onChange:e=>C(e.target.value),placeholder:s?.name??``,disabled:d})]})}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>x(!1),disabled:d,children:e(`common.cancel`)}),(0,M.jsx)(Q,{variant:`destructive`,onClick:async()=>{if(s){if(S!==s.name){q({title:e(`organizations.general.confirmationMismatch`),description:e(`organizations.general.confirmationHint`,{name:s.name}),variant:`destructive`});return}try{let r=await u(t),i=r?.warnings,a=r?.deletedProjects??0;q({title:e(`organizations.general.deleted`),description:i?.length?e(`organizations.general.deletedWithWarnings`,{deletedProjects:a,warning:i[0],extraCount:Math.max(i.length-1,0)}):e(`organizations.general.deletedDescription`,{name:s.name,deletedProjects:a}),variant:i?.length?`destructive`:void 0}),x(!1),C(``),n({to:`/organizations`})}catch(t){q({title:e(`organizations.general.deleteFailed`),description:t.message,variant:`destructive`})}}},disabled:d||!s||S!==s.name,children:e(d?`organizations.general.deleting`:`organizations.general.delete`)})]})]})})]})}var GI=la(`/account/oauth-applications/new`)({component:KI});function KI(){let{t:e}=vt(),t=Hi(),{register:n,registering:r}=fP(),[i,a]=(0,j.useState)(``),[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(`client_secret_basic`),[u,d]=(0,j.useState)(``),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(null),g=async()=>{let t=i.trim(),r=o.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean);if(!t){q({title:e(`oauth.applications.form.nameRequired`),variant:`destructive`});return}if(r.length===0){q({title:e(`oauth.applications.form.redirectRequired`),variant:`destructive`});return}try{let i=await n({client_name:t,redirect_uris:r,token_endpoint_auth_method:c,...u.trim()?{client_uri:u.trim()}:{},...f.trim()?{logo_uri:f.trim()}:{}});h({client_id:i?.client_id??``,client_secret:i?.client_secret}),q({title:e(`oauth.applications.registered`)})}catch(t){q({title:e(`oauth.applications.registerFailed`),description:t.message,variant:`destructive`})}},_=(t,n)=>{navigator.clipboard.writeText(t).then(()=>q({title:e(`oauth.applications.copied`,{label:n})}),()=>q({title:e(`oauth.applications.copyFailed`,{label:n}),variant:`destructive`}))};return m?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`oauth.applications.registeredTitle`)}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`oauth.applications.registeredDescription`)})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{children:e(`oauth.applications.credentials`)}),(0,M.jsx)(yN,{children:e(`oauth.applications.credentialsDescription`)})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(jN,{children:e(`oauth.applications.clientId`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`code`,{className:`flex-1 rounded-md border bg-muted px-3 py-2 font-mono text-xs`,children:m.client_id}),(0,M.jsx)(Q,{size:`icon`,variant:`outline`,onClick:()=>_(m.client_id,e(`oauth.applications.clientId`)),children:(0,M.jsx)(Sy,{className:`h-4 w-4`})})]})]}),m.client_secret&&(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(jN,{children:e(`oauth.applications.clientSecret`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`code`,{className:`flex-1 break-all rounded-md border bg-muted px-3 py-2 font-mono text-xs`,children:m.client_secret}),(0,M.jsx)(Q,{size:`icon`,variant:`outline`,onClick:()=>_(m.client_secret,e(`oauth.applications.clientSecret`)),children:(0,M.jsx)(Sy,{className:`h-4 w-4`})})]}),(0,M.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`oauth.applications.clientSecretWarning`)})]})]})]}),(0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>t({to:`/account/oauth-applications`}),children:e(`oauth.applications.backToList`)}),(0,M.jsx)(Q,{onClick:()=>t({to:`/account/oauth-applications/$clientId`,params:{clientId:m.client_id}}),children:e(`oauth.applications.viewApplication`)})]})]}):(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`oauth.applications.form.title`)}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`oauth.applications.form.description`)})]}),(0,M.jsxs)($,{children:[(0,M.jsx)(_N,{children:(0,M.jsxs)(vN,{className:`flex items-center gap-2 text-base`,children:[(0,M.jsx)(Oy,{className:`h-4 w-4`}),e(`oauth.applications.form.details`)]})}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`oauth-name`,children:e(`oauth.applications.form.name`)}),(0,M.jsx)(Xx,{id:`oauth-name`,value:i,onChange:e=>a(e.target.value),placeholder:e(`oauth.applications.form.namePlaceholder`),disabled:r})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`oauth-redirect`,children:e(`oauth.applications.form.redirectUris`)}),(0,M.jsx)(BI,{id:`oauth-redirect`,value:o,onChange:e=>s(e.target.value),placeholder:e(`oauth.applications.form.redirectPlaceholder`),rows:3,disabled:r}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`oauth.applications.form.redirectHint`)})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{children:e(`oauth.applications.form.authMethod`)}),(0,M.jsxs)(kI,{value:c,onValueChange:e=>l(e),disabled:r,children:[(0,M.jsx)(jI,{children:(0,M.jsx)(AI,{})}),(0,M.jsxs)(PI,{children:[(0,M.jsx)(II,{value:`client_secret_basic`,children:e(`oauth.applications.form.authMethodBasic`)}),(0,M.jsx)(II,{value:`client_secret_post`,children:e(`oauth.applications.form.authMethodPost`)}),(0,M.jsx)(II,{value:`none`,children:e(`oauth.applications.form.authMethodNone`)})]})]})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`oauth-client-uri`,children:e(`oauth.applications.form.clientUri`)}),(0,M.jsx)(Xx,{id:`oauth-client-uri`,value:u,onChange:e=>d(e.target.value),placeholder:e(`oauth.applications.form.clientUriPlaceholder`),disabled:r})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(jN,{htmlFor:`oauth-logo`,children:e(`oauth.applications.form.logoUri`)}),(0,M.jsx)(Xx,{id:`oauth-logo`,value:f,onChange:e=>p(e.target.value),placeholder:e(`oauth.applications.form.logoUriPlaceholder`),disabled:r}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`oauth.applications.form.logoHint`)})]})]})]}),(0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,M.jsx)(Q,{variant:`ghost`,onClick:()=>t({to:`/account/oauth-applications`}),disabled:r,children:e(`common.cancel`)}),(0,M.jsx)(Q,{onClick:g,disabled:r,children:e(r?`oauth.applications.form.registering`:`oauth.applications.register`)})]})]})}var qI=la(`/account/oauth-applications/$clientId`)({component:JI});function JI(){let{t:e}=vt(),{clientId:t}=qI.useParams(),n=Hi(),{applications:r,loading:i,reload:a}=dP(),{remove:o,deleting:s}=pP(),c=qg(),l=r.find(e=>e.client_id===t),[u,d]=(0,j.useState)(null);(0,j.useEffect)(()=>{let e=!1;if(!l&&c?.oauth?.applications?.get)return c.oauth.applications.get(t).then(t=>{e||d(t?.data??t)},()=>{}),()=>{e=!0}},[c,t,l]);let f=l??u,[p,m]=(0,j.useState)(!1),h=(t,n)=>{navigator.clipboard.writeText(t).then(()=>q({title:e(`oauth.applications.copied`,{label:n})}),()=>q({title:e(`oauth.applications.copyFailed`,{label:n}),variant:`destructive`}))},g=async()=>{if(f)try{await o(f.client_id),q({title:e(`oauth.applications.deleted`)}),await a(),n({to:`/account/oauth-applications`})}catch(t){q({title:e(`oauth.applications.deleteFailed`),description:t.message,variant:`destructive`})}};if(i&&!f)return(0,M.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:e(`common.loading`)});if(!f)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:e(`oauth.applications.notFoundTitle`)}),(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`oauth.applications.notFoundDescription`)}),(0,M.jsx)(Q,{onClick:()=>n({to:`/account/oauth-applications`}),children:e(`oauth.applications.backToList`)})]});let _=typeof f.redirect_urls==`string`?f.redirect_urls.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean):Array.isArray(f.redirect_urls)?f.redirect_urls:[];return(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`text-2xl font-semibold`,children:f.name}),(0,M.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:f.client_id})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f.type&&(0,M.jsx)($N,{variant:`outline`,className:`capitalize`,children:f.type}),f.disabled&&(0,M.jsx)($N,{variant:`destructive`,children:e(`oauth.applications.disabled`)})]})]}),(0,M.jsxs)($,{children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{children:e(`oauth.applications.credentials`)}),(0,M.jsx)(yN,{children:e(`oauth.applications.credentialsDescriptionDetail`)})]}),(0,M.jsxs)(bN,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(jN,{children:e(`oauth.applications.clientId`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`code`,{className:`flex-1 rounded-md border bg-muted px-3 py-2 font-mono text-xs`,children:f.client_id}),(0,M.jsx)(Q,{size:`icon`,variant:`outline`,onClick:()=>h(f.client_id,e(`oauth.applications.clientId`)),children:(0,M.jsx)(Sy,{className:`h-4 w-4`})})]})]}),(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsx)(jN,{children:e(`oauth.applications.redirectUris`)}),_.length===0?(0,M.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`oauth.applications.noRedirectUris`)}):(0,M.jsx)(`ul`,{className:`space-y-1`,children:_.map((e,t)=>(0,M.jsx)(`li`,{className:`rounded-md border bg-muted px-3 py-2 font-mono text-xs`,children:e},t))})]})]})]}),(0,M.jsxs)($,{className:`border-destructive/40`,children:[(0,M.jsxs)(_N,{children:[(0,M.jsx)(vN,{className:`text-base text-destructive`,children:e(`oauth.applications.dangerTitle`)}),(0,M.jsx)(yN,{children:e(`oauth.applications.dangerDescription`)})]}),(0,M.jsx)(bN,{children:(0,M.jsxs)(Q,{variant:`destructive`,size:`sm`,onClick:()=>m(!0),disabled:s,children:[(0,M.jsx)(Ky,{className:`mr-2 h-4 w-4`}),e(`oauth.applications.delete`)]})})]}),(0,M.jsx)(kP,{open:p,onOpenChange:m,children:(0,M.jsxs)(MP,{children:[(0,M.jsxs)(NP,{children:[(0,M.jsx)(FP,{className:`text-destructive`,children:e(`oauth.applications.deleteDialogTitle`)}),(0,M.jsx)(IP,{children:e(`oauth.applications.deleteDialogDescription`,{name:f.name})})]}),(0,M.jsxs)(PP,{children:[(0,M.jsx)(Q,{variant:`outline`,onClick:()=>m(!1),disabled:s,children:e(`common.cancel`)}),(0,M.jsx)(Q,{variant:`destructive`,onClick:g,disabled:s,children:e(s?`oauth.applications.deleting`:`common.delete`)})]})]})})]})}var YI=TN.update({id:`/verify-email`,path:`/verify-email`,getParentRoute:()=>gN}),XI=MN.update({id:`/setup`,path:`/setup`,getParentRoute:()=>gN}),ZI=FN.update({id:`/reset-password`,path:`/reset-password`,getParentRoute:()=>gN}),QI=RN.update({id:`/register`,path:`/register`,getParentRoute:()=>gN}),$I=HN.update({id:`/login`,path:`/login`,getParentRoute:()=>gN}),eL=KN.update({id:`/forgot-password`,path:`/forgot-password`,getParentRoute:()=>gN}),tL=JN.update({id:`/account`,path:`/account`,getParentRoute:()=>gN}),nL=XN.update({id:`/`,path:`/`,getParentRoute:()=>gN}),rL=tP.update({id:`/organizations/`,path:`/organizations/`,getParentRoute:()=>gN}),iL=rP.update({id:`/`,path:`/`,getParentRoute:()=>tL}),aL=oP.update({id:`/organizations/new`,path:`/organizations/new`,getParentRoute:()=>gN}),oL=lP.update({id:`/organizations/$orgId`,path:`/organizations/$orgId`,getParentRoute:()=>gN}),sL=hP.update({id:`/oauth/consent`,path:`/oauth/consent`,getParentRoute:()=>gN}),cL=vP.update({id:`/auth/device`,path:`/auth/device`,getParentRoute:()=>gN}),lL=xP.update({id:`/two-factor`,path:`/two-factor`,getParentRoute:()=>tL}),uL=EP.update({id:`/sessions`,path:`/sessions`,getParentRoute:()=>tL}),dL=LP.update({id:`/security`,path:`/security`,getParentRoute:()=>tL}),fL=zP.update({id:`/profile`,path:`/profile`,getParentRoute:()=>tL}),pL=VP.update({id:`/linked-accounts`,path:`/linked-accounts`,getParentRoute:()=>tL}),mL=qP.update({id:`/invitations`,path:`/invitations`,getParentRoute:()=>tL}),hL=YP.update({id:`/accept-invitation/$invitationId`,path:`/accept-invitation/$invitationId`,getParentRoute:()=>gN}),gL=ZP.update({id:`/`,path:`/`,getParentRoute:()=>oL}),_L=QP.update({id:`/oauth-applications/`,path:`/oauth-applications/`,getParentRoute:()=>tL}),vL=RI.update({id:`/teams`,path:`/teams`,getParentRoute:()=>oL}),yL=VI.update({id:`/members`,path:`/members`,getParentRoute:()=>oL}),bL=UI.update({id:`/general`,path:`/general`,getParentRoute:()=>oL}),xL=GI.update({id:`/oauth-applications/new`,path:`/oauth-applications/new`,getParentRoute:()=>tL}),SL={AccountInvitationsRoute:mL,AccountLinkedAccountsRoute:pL,AccountProfileRoute:fL,AccountSecurityRoute:dL,AccountSessionsRoute:uL,AccountTwoFactorRoute:lL,AccountIndexRoute:iL,AccountOauthApplicationsClientIdRoute:qI.update({id:`/oauth-applications/$clientId`,path:`/oauth-applications/$clientId`,getParentRoute:()=>tL}),AccountOauthApplicationsNewRoute:xL,AccountOauthApplicationsIndexRoute:_L},CL=tL._addFileChildren(SL),wL={OrganizationsOrgIdGeneralRoute:bL,OrganizationsOrgIdMembersRoute:yL,OrganizationsOrgIdTeamsRoute:vL,OrganizationsOrgIdIndexRoute:gL},TL={IndexRoute:nL,AccountRoute:CL,ForgotPasswordRoute:eL,LoginRoute:$I,RegisterRoute:QI,ResetPasswordRoute:ZI,SetupRoute:XI,VerifyEmailRoute:YI,AcceptInvitationInvitationIdRoute:hL,AuthDeviceRoute:cL,OauthConsentRoute:sL,OrganizationsOrgIdRoute:oL._addFileChildren(wL),OrganizationsNewRoute:aL,OrganizationsIndexRoute:rL},EL=gN._addFileChildren(TL)._addFileTypes();function DL(){let e=`/_account/`;return e.endsWith(`/`)?e.slice(0,-1):e}var OL=wa({routeTree:EL,basepath:DL()});function kL(){return(0,M.jsx)(Da,{router:OL})}var AL=typeof localStorage<`u`&&localStorage.getItem(`account.lang`)||typeof navigator<`u`&&navigator.language||`en`;function jL({children:e}){let{i18n:t,language:n}=yt(),[r,i]=j.useReducer(e=>e+1,0),[a,o]=j.useState(!1);return j.useEffect(()=>{let e=()=>i();t.on(`loaded`,e),t.on(`languageChanged`,e);let n=window.setTimeout(()=>o(!0),1500);return()=>{t.off(`loaded`,e),t.off(`languageChanged`,e),window.clearTimeout(n)}},[t]),a||t.isInitialized&&t.hasResourceBundle?.(n,`translation`)?(0,M.jsx)(M.Fragment,{children:e}):null}qf.createRoot(document.getElementById(`root`)).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(_t,{config:{defaultLanguage:AL,fallbackLanguage:`en`},loadLanguage:hM,children:(0,M.jsx)(jL,{children:(0,M.jsx)(kL,{})})})}));
|
package/dist/index.html
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
@keyframes boot-skeleton-spin { to { transform: rotate(360deg); } }
|
|
52
52
|
</style>
|
|
53
|
-
<script type="module" crossorigin src="/_account/assets/index-
|
|
53
|
+
<script type="module" crossorigin src="/_account/assets/index-OkFgLXf6.js"></script>
|
|
54
54
|
<link rel="stylesheet" crossorigin href="/_account/assets/index-Bdj8EUtE.css">
|
|
55
55
|
</head>
|
|
56
56
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/account",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.1",
|
|
4
4
|
"description": "ObjectStack Account - End-user account & organization self-service portal",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"dependencies": {
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"devDependencies": {
|
|
14
15
|
"@object-ui/i18n": "^6.1.0",
|
|
15
16
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
16
17
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
@@ -34,11 +35,6 @@
|
|
|
34
35
|
"react-dom": "^19.2.6",
|
|
35
36
|
"react-resizable-panels": "^4.11.2",
|
|
36
37
|
"tailwind-merge": "^3.6.0",
|
|
37
|
-
"@objectstack/client": "6.7.0",
|
|
38
|
-
"@objectstack/client-react": "6.7.0",
|
|
39
|
-
"@objectstack/spec": "6.7.0"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
38
|
"@tailwindcss/postcss": "^4.3.0",
|
|
43
39
|
"@tanstack/router-plugin": "^1.168.11",
|
|
44
40
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -54,7 +50,10 @@
|
|
|
54
50
|
"tailwindcss": "^4.3.0",
|
|
55
51
|
"typescript": "^6.0.3",
|
|
56
52
|
"vite": "^8.0.14",
|
|
57
|
-
"vitest": "^4.1.7"
|
|
53
|
+
"vitest": "^4.1.7",
|
|
54
|
+
"@objectstack/client": "6.7.1",
|
|
55
|
+
"@objectstack/client-react": "6.7.1",
|
|
56
|
+
"@objectstack/spec": "6.7.1"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
59
|
"dev": "vite",
|