@nymbalhq/admin 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
var La=e=>{throw TypeError(e)};var Vs=(e,t,n)=>t.has(e)||La("Cannot "+n);var b=(e,t,n)=>(Vs(e,t,"read from private field"),n?n.call(e):t.get(e)),F=(e,t,n)=>t.has(e)?La("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(Vs(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),J=(e,t,n)=>(Vs(e,t,"access private method"),n);var Dr=(e,t,n,r)=>({set _(o){M(e,t,o,n)},get _(){return b(e,t,r)}});import{r as l,a as Cr,u as vt,N as Tf,b as Af,L as sn,R as Ko,c as Mf,d as He,O as _f,e as Ho,f as If,g as Of,h as Df}from"./vendor-dpy99fWE.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();var Yi={exports:{}},hs={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var zf=l,Lf=Symbol.for("react.element"),Ff=Symbol.for("react.fragment"),$f=Object.prototype.hasOwnProperty,Uf=zf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Vf={key:!0,ref:!0,__self:!0,__source:!0};function Xi(e,t,n){var r,o={},a=null,i=null;n!==void 0&&(a=""+n),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)$f.call(t,r)&&!Vf.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)o[r]===void 0&&(o[r]=t[r]);return{$$typeof:Lf,type:e,key:a,ref:i,props:o,_owner:Uf.current}}hs.Fragment=Ff;hs.jsx=Xi;hs.jsxs=Xi;Yi.exports=hs;var s=Yi.exports,Zi,Fa=Cr;Zi=Fa.createRoot,Fa.hydrateRoot;var Bn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Qt,St,Sn,Fi,Bf=(Fi=class extends Bn{constructor(){super();F(this,Qt);F(this,St);F(this,Sn);M(this,Sn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){b(this,St)||this.setEventListener(b(this,Sn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,St))==null||t.call(this),M(this,St,void 0))}setEventListener(t){var n;M(this,Sn,t),(n=b(this,St))==null||n.call(this),M(this,St,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){b(this,Qt)!==t&&(M(this,Qt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof b(this,Qt)=="boolean"?b(this,Qt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Qt=new WeakMap,St=new WeakMap,Sn=new WeakMap,Fi),qo=new Bf,Kf={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Et,Bo,$i,Hf=($i=class{constructor(){F(this,Et,Kf);F(this,Bo,!1)}setTimeoutProvider(e){M(this,Et,e)}setTimeout(e,t){return b(this,Et).setTimeout(e,t)}clearTimeout(e){b(this,Et).clearTimeout(e)}setInterval(e,t){return b(this,Et).setInterval(e,t)}clearInterval(e){b(this,Et).clearInterval(e)}},Et=new WeakMap,Bo=new WeakMap,$i),qt=new Hf;function qf(e){setTimeout(e,0)}var Wf=typeof window>"u"||"Deno"in globalThis;function Ee(){}function Gf(e,t){return typeof e=="function"?e(t):e}function lo(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ji(e,t){return Math.max(e+(t||0)-Date.now(),0)}function It(e,t){return typeof e=="function"?e(t):e}function Ie(e,t){return typeof e=="function"?e(t):e}function $a(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:a,queryKey:i,stale:c}=e;if(i){if(r){if(t.queryHash!==Wo(i,t.options))return!1}else if(!ur(t.queryKey,i))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof c=="boolean"&&t.isStale()!==c||o&&o!==t.state.fetchStatus||a&&!a(t))}function Ua(e,t){const{exact:n,status:r,predicate:o,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(an(t.options.mutationKey)!==an(a))return!1}else if(!ur(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function Wo(e,t){return((t==null?void 0:t.queryKeyHashFn)||an)(e)}function an(e){return JSON.stringify(e,(t,n)=>uo(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function ur(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>ur(e[n],t[n])):!1}var Qf=Object.prototype.hasOwnProperty;function ec(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Va(e)&&Va(t);if(!r&&!(uo(e)&&uo(t)))return t;const a=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),c=i.length,u=r?new Array(c):{};let d=0;for(let h=0;h<c;h++){const f=r?h:i[h],m=e[f],x=t[f];if(m===x){u[f]=m,(r?h<a:Qf.call(e,f))&&d++;continue}if(m===null||x===null||typeof m!="object"||typeof x!="object"){u[f]=x;continue}const v=ec(m,x,n+1);u[f]=v,v===m&&d++}return a===c&&d===a?e:u}function Zr(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Va(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function uo(e){if(!Ba(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Ba(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ba(e){return Object.prototype.toString.call(e)==="[object Object]"}function Yf(e){return new Promise(t=>{qt.setTimeout(t,e)})}function fo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?ec(e,t):t}function Xf(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Zf(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Go=Symbol();function tc(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Go?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Qo(e,t){return typeof e=="function"?e(...t):!!e}function Jf(e,t,n){let r=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??(o=t()),r||(r=!0,o.aborted?n():o.addEventListener("abort",n,{once:!0})),o)}),e}var fr=(()=>{let e=()=>Wf;return{isServer(){return e()},setIsServer(t){e=t}}})();function ho(){let e,t;const n=new Promise((o,a)=>{e=o,t=a});n.status="pending",n.catch(()=>{});function r(o){Object.assign(n,o),delete n.resolve,delete n.reject}return n.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},n.reject=o=>{r({status:"rejected",reason:o}),t(o)},n}var eh=qf;function th(){let e=[],t=0,n=c=>{c()},r=c=>{c()},o=eh;const a=c=>{t?e.push(c):o(()=>{n(c)})},i=()=>{const c=e;e=[],c.length&&o(()=>{r(()=>{c.forEach(u=>{n(u)})})})};return{batch:c=>{let u;t++;try{u=c()}finally{t--,t||i()}return u},batchCalls:c=>(...u)=>{a(()=>{c(...u)})},schedule:a,setNotifyFunction:c=>{n=c},setBatchNotifyFunction:c=>{r=c},setScheduler:c=>{o=c}}}var ve=th(),En,Rt,Rn,Ui,nh=(Ui=class extends Bn{constructor(){super();F(this,En,!0);F(this,Rt);F(this,Rn);M(this,Rn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){b(this,Rt)||this.setEventListener(b(this,Rn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Rt))==null||t.call(this),M(this,Rt,void 0))}setEventListener(t){var n;M(this,Rn,t),(n=b(this,Rt))==null||n.call(this),M(this,Rt,t(this.setOnline.bind(this)))}setOnline(t){b(this,En)!==t&&(M(this,En,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return b(this,En)}},En=new WeakMap,Rt=new WeakMap,Rn=new WeakMap,Ui),Jr=new nh;function rh(e){return Math.min(1e3*2**e,3e4)}function nc(e){return(e??"online")==="online"?Jr.isOnline():!0}var mo=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function rc(e){let t=!1,n=0,r;const o=ho(),a=()=>o.status!=="pending",i=p=>{var g;if(!a()){const w=new mo(p);m(w),(g=e.onCancel)==null||g.call(e,w)}},c=()=>{t=!0},u=()=>{t=!1},d=()=>qo.isFocused()&&(e.networkMode==="always"||Jr.isOnline())&&e.canRun(),h=()=>nc(e.networkMode)&&e.canRun(),f=p=>{a()||(r==null||r(),o.resolve(p))},m=p=>{a()||(r==null||r(),o.reject(p))},x=()=>new Promise(p=>{var g;r=w=>{(a()||d())&&p(w)},(g=e.onPause)==null||g.call(e)}).then(()=>{var p;r=void 0,a()||(p=e.onContinue)==null||p.call(e)}),v=()=>{if(a())return;let p;const g=n===0?e.initialPromise:void 0;try{p=g??e.fn()}catch(w){p=Promise.reject(w)}Promise.resolve(p).then(f).catch(w=>{var E;if(a())return;const y=e.retry??(fr.isServer()?0:3),N=e.retryDelay??rh,j=typeof N=="function"?N(n,w):N,C=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,w);if(t||!C){m(w);return}n++,(E=e.onFail)==null||E.call(e,n,w),Yf(j).then(()=>d()?void 0:x()).then(()=>{t?m(w):v()})})};return{promise:o,status:()=>o.status,cancel:i,continue:()=>(r==null||r(),o),cancelRetry:c,continueRetry:u,canStart:h,start:()=>(h()?v():x().then(v),o)}}var Yt,Vi,sc=(Vi=class{constructor(){F(this,Yt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),lo(this.gcTime)&&M(this,Yt,qt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(fr.isServer()?1/0:5*60*1e3))}clearGcTimeout(){b(this,Yt)!==void 0&&(qt.clearTimeout(b(this,Yt)),M(this,Yt,void 0))}},Yt=new WeakMap,Vi),Xt,Pn,Fe,Zt,ye,yr,Jt,_e,oc,lt,Bi,sh=(Bi=class extends sc{constructor(t){super();F(this,_e);F(this,Xt);F(this,Pn);F(this,Fe);F(this,Zt);F(this,ye);F(this,yr);F(this,Jt);M(this,Jt,!1),M(this,yr,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Zt,t.client),M(this,Fe,b(this,Zt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,Xt,Ha(this.options)),this.state=t.state??b(this,Xt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=b(this,ye))==null?void 0:t.promise}setOptions(t){if(this.options={...b(this,yr),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Ha(this.options);n.data!==void 0&&(this.setState(Ka(n.data,n.dataUpdatedAt)),M(this,Xt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&b(this,Fe).remove(this)}setData(t,n){const r=fo(this.state.data,t,this.options);return J(this,_e,lt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){J(this,_e,lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,o;const n=(r=b(this,ye))==null?void 0:r.promise;return(o=b(this,ye))==null||o.cancel(t),n?n.then(Ee).catch(Ee):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return b(this,Xt)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Ie(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Go||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>It(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Ji(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,ye))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,ye))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),b(this,Fe).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(b(this,ye)&&(b(this,Jt)||J(this,_e,oc).call(this)?b(this,ye).cancel({revert:!0}):b(this,ye).cancelRetry()),this.scheduleGc()),b(this,Fe).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||J(this,_e,lt).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,h,f,m,x,v,p,g,w,y,N;if(this.state.fetchStatus!=="idle"&&((u=b(this,ye))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(b(this,ye))return b(this,ye).continueRetry(),b(this,ye).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,o=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,Jt,!0),r.signal)})},a=()=>{const j=tc(this.options,n),E=(()=>{const S={client:b(this,Zt),queryKey:this.queryKey,meta:this.meta};return o(S),S})();return M(this,Jt,!1),this.options.persister?this.options.persister(j,E,this):j(E)},c=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:b(this,Zt),state:this.state,fetchFn:a};return o(j),j})();(d=this.options.behavior)==null||d.onFetch(c,this),M(this,Pn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=c.fetchOptions)==null?void 0:h.meta))&&J(this,_e,lt).call(this,{type:"fetch",meta:(f=c.fetchOptions)==null?void 0:f.meta}),M(this,ye,rc({initialPromise:n==null?void 0:n.initialPromise,fn:c.fetchFn,onCancel:j=>{j instanceof mo&&j.revert&&this.setState({...b(this,Pn),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{J(this,_e,lt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{J(this,_e,lt).call(this,{type:"pause"})},onContinue:()=>{J(this,_e,lt).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0}));try{const j=await b(this,ye).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(m=b(this,Fe).config).onSuccess)==null||x.call(m,j,this),(p=(v=b(this,Fe).config).onSettled)==null||p.call(v,j,this.state.error,this),j}catch(j){if(j instanceof mo){if(j.silent)return b(this,ye).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw J(this,_e,lt).call(this,{type:"error",error:j}),(w=(g=b(this,Fe).config).onError)==null||w.call(g,j,this),(N=(y=b(this,Fe).config).onSettled)==null||N.call(y,this.state.data,j,this),j}finally{this.scheduleGc()}}},Xt=new WeakMap,Pn=new WeakMap,Fe=new WeakMap,Zt=new WeakMap,ye=new WeakMap,yr=new WeakMap,Jt=new WeakMap,_e=new WeakSet,oc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},lt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ac(r.data,this.options),fetchMeta:t.meta??null};case"success":const o={...r,...Ka(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,Pn,t.manual?o:void 0),o;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ve.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),b(this,Fe).notify({query:this,type:"updated",action:t})})},Bi);function ac(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ka(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ha(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Pe,ne,br,Se,en,kn,dt,Pt,wr,Tn,An,tn,nn,kt,Mn,le,ir,po,xo,go,vo,yo,bo,wo,ic,Ki,oh=(Ki=class extends Bn{constructor(t,n){super();F(this,le);F(this,Pe);F(this,ne);F(this,br);F(this,Se);F(this,en);F(this,kn);F(this,dt);F(this,Pt);F(this,wr);F(this,Tn);F(this,An);F(this,tn);F(this,nn);F(this,kt);F(this,Mn,new Set);this.options=n,M(this,Pe,t),M(this,Pt,null),M(this,dt,ho()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(b(this,ne).addObserver(this),qa(b(this,ne),this.options)?J(this,le,ir).call(this):this.updateResult(),J(this,le,vo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return No(b(this,ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return No(b(this,ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,J(this,le,yo).call(this),J(this,le,bo).call(this),b(this,ne).removeObserver(this)}setOptions(t){const n=this.options,r=b(this,ne);if(this.options=b(this,Pe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ie(this.options.enabled,b(this,ne))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");J(this,le,wo).call(this),b(this,ne).setOptions(this.options),n._defaulted&&!Zr(this.options,n)&&b(this,Pe).getQueryCache().notify({type:"observerOptionsUpdated",query:b(this,ne),observer:this});const o=this.hasListeners();o&&Wa(b(this,ne),r,this.options,n)&&J(this,le,ir).call(this),this.updateResult(),o&&(b(this,ne)!==r||Ie(this.options.enabled,b(this,ne))!==Ie(n.enabled,b(this,ne))||It(this.options.staleTime,b(this,ne))!==It(n.staleTime,b(this,ne)))&&J(this,le,po).call(this);const a=J(this,le,xo).call(this);o&&(b(this,ne)!==r||Ie(this.options.enabled,b(this,ne))!==Ie(n.enabled,b(this,ne))||a!==b(this,kt))&&J(this,le,go).call(this,a)}getOptimisticResult(t){const n=b(this,Pe).getQueryCache().build(b(this,Pe),t),r=this.createResult(n,t);return ih(this,r)&&(M(this,Se,r),M(this,kn,this.options),M(this,en,b(this,ne).state)),r}getCurrentResult(){return b(this,Se)}trackResult(t,n){return new Proxy(t,{get:(r,o)=>(this.trackProp(o),n==null||n(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&b(this,dt).status==="pending"&&b(this,dt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(t){b(this,Mn).add(t)}getCurrentQuery(){return b(this,ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=b(this,Pe).defaultQueryOptions(t),r=b(this,Pe).getQueryCache().build(b(this,Pe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return J(this,le,ir).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),b(this,Se)))}createResult(t,n){var D;const r=b(this,ne),o=this.options,a=b(this,Se),i=b(this,en),c=b(this,kn),d=t!==r?t.state:b(this,br),{state:h}=t;let f={...h},m=!1,x;if(n._optimisticResults){const O=this.hasListeners(),$=!O&&qa(t,n),_=O&&Wa(t,r,n,o);($||_)&&(f={...f,...ac(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:p,status:g}=f;x=f.data;let w=!1;if(n.placeholderData!==void 0&&x===void 0&&g==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(c==null?void 0:c.placeholderData)?(O=a.data,w=!0):O=typeof n.placeholderData=="function"?n.placeholderData((D=b(this,An))==null?void 0:D.state.data,b(this,An)):n.placeholderData,O!==void 0&&(g="success",x=fo(a==null?void 0:a.data,O,n),m=!0)}if(n.select&&x!==void 0&&!w)if(a&&x===(i==null?void 0:i.data)&&n.select===b(this,wr))x=b(this,Tn);else try{M(this,wr,n.select),x=n.select(x),x=fo(a==null?void 0:a.data,x,n),M(this,Tn,x),M(this,Pt,null)}catch(O){M(this,Pt,O)}b(this,Pt)&&(v=b(this,Pt),x=b(this,Tn),p=Date.now(),g="error");const y=f.fetchStatus==="fetching",N=g==="pending",j=g==="error",C=N&&y,E=x!==void 0,P={status:g,fetchStatus:f.fetchStatus,isPending:N,isSuccess:g==="success",isError:j,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:p,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:y,isRefetching:y&&!N,isLoadingError:j&&!E,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&E,isStale:Yo(t,n),refetch:this.refetch,promise:b(this,dt),isEnabled:Ie(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=P.data!==void 0,$=P.status==="error"&&!O,_=X=>{$?X.reject(P.error):O&&X.resolve(P.data)},G=()=>{const X=M(this,dt,P.promise=ho());_(X)},U=b(this,dt);switch(U.status){case"pending":t.queryHash===r.queryHash&&_(U);break;case"fulfilled":($||P.data!==U.value)&&G();break;case"rejected":(!$||P.error!==U.reason)&&G();break}}return P}updateResult(){const t=b(this,Se),n=this.createResult(b(this,ne),this.options);if(M(this,en,b(this,ne).state),M(this,kn,this.options),b(this,en).data!==void 0&&M(this,An,b(this,ne)),Zr(n,t))return;M(this,Se,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:o}=this.options,a=typeof o=="function"?o():o;if(a==="all"||!a&&!b(this,Mn).size)return!0;const i=new Set(a??b(this,Mn));return this.options.throwOnError&&i.add("error"),Object.keys(b(this,Se)).some(c=>{const u=c;return b(this,Se)[u]!==t[u]&&i.has(u)})};J(this,le,ic).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&J(this,le,vo).call(this)}},Pe=new WeakMap,ne=new WeakMap,br=new WeakMap,Se=new WeakMap,en=new WeakMap,kn=new WeakMap,dt=new WeakMap,Pt=new WeakMap,wr=new WeakMap,Tn=new WeakMap,An=new WeakMap,tn=new WeakMap,nn=new WeakMap,kt=new WeakMap,Mn=new WeakMap,le=new WeakSet,ir=function(t){J(this,le,wo).call(this);let n=b(this,ne).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ee)),n},po=function(){J(this,le,yo).call(this);const t=It(this.options.staleTime,b(this,ne));if(fr.isServer()||b(this,Se).isStale||!lo(t))return;const r=Ji(b(this,Se).dataUpdatedAt,t)+1;M(this,tn,qt.setTimeout(()=>{b(this,Se).isStale||this.updateResult()},r))},xo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(b(this,ne)):this.options.refetchInterval)??!1},go=function(t){J(this,le,bo).call(this),M(this,kt,t),!(fr.isServer()||Ie(this.options.enabled,b(this,ne))===!1||!lo(b(this,kt))||b(this,kt)===0)&&M(this,nn,qt.setInterval(()=>{(this.options.refetchIntervalInBackground||qo.isFocused())&&J(this,le,ir).call(this)},b(this,kt)))},vo=function(){J(this,le,po).call(this),J(this,le,go).call(this,J(this,le,xo).call(this))},yo=function(){b(this,tn)!==void 0&&(qt.clearTimeout(b(this,tn)),M(this,tn,void 0))},bo=function(){b(this,nn)!==void 0&&(qt.clearInterval(b(this,nn)),M(this,nn,void 0))},wo=function(){const t=b(this,Pe).getQueryCache().build(b(this,Pe),this.options);if(t===b(this,ne))return;const n=b(this,ne);M(this,ne,t),M(this,br,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ic=function(t){ve.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(b(this,Se))}),b(this,Pe).getQueryCache().notify({query:b(this,ne),type:"observerResultsUpdated"})})},Ki);function ah(e,t){return Ie(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Ie(t.retryOnMount,e)===!1)}function qa(e,t){return ah(e,t)||e.state.data!==void 0&&No(e,t,t.refetchOnMount)}function No(e,t,n){if(Ie(t.enabled,e)!==!1&&It(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Yo(e,t)}return!1}function Wa(e,t,n,r){return(e!==t||Ie(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Yo(e,n)}function Yo(e,t){return Ie(t.enabled,e)!==!1&&e.isStaleByTime(It(t.staleTime,e))}function ih(e,t){return!Zr(e.getCurrentResult(),t)}function Ga(e){return{onFetch:(t,n)=>{var h,f,m,x,v;const r=t.options,o=(m=(f=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],i=((v=t.state.data)==null?void 0:v.pageParams)||[];let c={pages:[],pageParams:[]},u=0;const d=async()=>{let p=!1;const g=N=>{Jf(N,()=>t.signal,()=>p=!0)},w=tc(t.options,t.fetchOptions),y=async(N,j,C)=>{if(p)return Promise.reject();if(j==null&&N.pages.length)return Promise.resolve(N);const S=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return g($),$})(),P=await w(S),{maxPages:D}=t.options,O=C?Zf:Xf;return{pages:O(N.pages,P,D),pageParams:O(N.pageParams,j,D)}};if(o&&a.length){const N=o==="backward",j=N?ch:Qa,C={pages:a,pageParams:i},E=j(r,C);c=await y(C,E,N)}else{const N=e??a.length;do{const j=u===0?i[0]??r.initialPageParam:Qa(r,c);if(u>0&&j==null)break;c=await y(c,j),u++}while(u<N)}return c};t.options.persister?t.fetchFn=()=>{var p,g;return(g=(p=t.options).persister)==null?void 0:g.call(p,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function Qa(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ch(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Nr,Xe,je,rn,Ze,jt,Hi,lh=(Hi=class extends sc{constructor(t){super();F(this,Ze);F(this,Nr);F(this,Xe);F(this,je);F(this,rn);M(this,Nr,t.client),this.mutationId=t.mutationId,M(this,je,t.mutationCache),M(this,Xe,[]),this.state=t.state||cc(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){b(this,Xe).includes(t)||(b(this,Xe).push(t),this.clearGcTimeout(),b(this,je).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,Xe,b(this,Xe).filter(n=>n!==t)),this.scheduleGc(),b(this,je).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){b(this,Xe).length||(this.state.status==="pending"?this.scheduleGc():b(this,je).remove(this))}continue(){var t;return((t=b(this,rn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,c,u,d,h,f,m,x,v,p,g,w,y,N,j,C,E,S;const n=()=>{J(this,Ze,jt).call(this,{type:"continue"})},r={client:b(this,Nr),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,rn,rc({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(P,D)=>{J(this,Ze,jt).call(this,{type:"failed",failureCount:P,error:D})},onPause:()=>{J(this,Ze,jt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>b(this,je).canRun(this)}));const o=this.state.status==="pending",a=!b(this,rn).canStart();try{if(o)n();else{J(this,Ze,jt).call(this,{type:"pending",variables:t,isPaused:a}),b(this,je).config.onMutate&&await b(this,je).config.onMutate(t,this,r);const D=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,t,r));D!==this.state.context&&J(this,Ze,jt).call(this,{type:"pending",context:D,variables:t,isPaused:a})}const P=await b(this,rn).start();return await((d=(u=b(this,je).config).onSuccess)==null?void 0:d.call(u,P,t,this.state.context,this,r)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,P,t,this.state.context,r)),await((x=(m=b(this,je).config).onSettled)==null?void 0:x.call(m,P,null,this.state.variables,this.state.context,this,r)),await((p=(v=this.options).onSettled)==null?void 0:p.call(v,P,null,t,this.state.context,r)),J(this,Ze,jt).call(this,{type:"success",data:P}),P}catch(P){try{await((w=(g=b(this,je).config).onError)==null?void 0:w.call(g,P,t,this.state.context,this,r))}catch(D){Promise.reject(D)}try{await((N=(y=this.options).onError)==null?void 0:N.call(y,P,t,this.state.context,r))}catch(D){Promise.reject(D)}try{await((C=(j=b(this,je).config).onSettled)==null?void 0:C.call(j,void 0,P,this.state.variables,this.state.context,this,r))}catch(D){Promise.reject(D)}try{await((S=(E=this.options).onSettled)==null?void 0:S.call(E,void 0,P,t,this.state.context,r))}catch(D){Promise.reject(D)}throw J(this,Ze,jt).call(this,{type:"error",error:P}),P}finally{b(this,je).runNext(this)}}},Nr=new WeakMap,Xe=new WeakMap,je=new WeakMap,rn=new WeakMap,Ze=new WeakSet,jt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ve.batch(()=>{b(this,Xe).forEach(r=>{r.onMutationUpdate(t)}),b(this,je).notify({mutation:this,type:"updated",action:t})})},Hi);function cc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ut,Ke,jr,qi,dh=(qi=class extends Bn{constructor(t={}){super();F(this,ut);F(this,Ke);F(this,jr);this.config=t,M(this,ut,new Set),M(this,Ke,new Map),M(this,jr,0)}build(t,n,r){const o=new lh({client:t,mutationCache:this,mutationId:++Dr(this,jr)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){b(this,ut).add(t);const n=zr(t);if(typeof n=="string"){const r=b(this,Ke).get(n);r?r.push(t):b(this,Ke).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(b(this,ut).delete(t)){const n=zr(t);if(typeof n=="string"){const r=b(this,Ke).get(n);if(r)if(r.length>1){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}else r[0]===t&&b(this,Ke).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=zr(t);if(typeof n=="string"){const r=b(this,Ke).get(n),o=r==null?void 0:r.find(a=>a.state.status==="pending");return!o||o===t}else return!0}runNext(t){var r;const n=zr(t);if(typeof n=="string"){const o=(r=b(this,Ke).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ve.batch(()=>{b(this,ut).forEach(t=>{this.notify({type:"removed",mutation:t})}),b(this,ut).clear(),b(this,Ke).clear()})}getAll(){return Array.from(b(this,ut))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ua(n,r))}findAll(t={}){return this.getAll().filter(n=>Ua(t,n))}notify(t){ve.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ve.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ee))))}},ut=new WeakMap,Ke=new WeakMap,jr=new WeakMap,qi);function zr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var ft,Tt,ke,ht,pt,Hr,jo,Wi,uh=(Wi=class extends Bn{constructor(n,r){super();F(this,pt);F(this,ft);F(this,Tt);F(this,ke);F(this,ht);M(this,ft,n),this.setOptions(r),this.bindMethods(),J(this,pt,Hr).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var o;const r=this.options;this.options=b(this,ft).defaultMutationOptions(n),Zr(this.options,r)||b(this,ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:b(this,ke),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&an(r.mutationKey)!==an(this.options.mutationKey)?this.reset():((o=b(this,ke))==null?void 0:o.state.status)==="pending"&&b(this,ke).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=b(this,ke))==null||n.removeObserver(this)}onMutationUpdate(n){J(this,pt,Hr).call(this),J(this,pt,jo).call(this,n)}getCurrentResult(){return b(this,Tt)}reset(){var n;(n=b(this,ke))==null||n.removeObserver(this),M(this,ke,void 0),J(this,pt,Hr).call(this),J(this,pt,jo).call(this)}mutate(n,r){var o;return M(this,ht,r),(o=b(this,ke))==null||o.removeObserver(this),M(this,ke,b(this,ft).getMutationCache().build(b(this,ft),this.options)),b(this,ke).addObserver(this),b(this,ke).execute(n)}},ft=new WeakMap,Tt=new WeakMap,ke=new WeakMap,ht=new WeakMap,pt=new WeakSet,Hr=function(){var r;const n=((r=b(this,ke))==null?void 0:r.state)??cc();M(this,Tt,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},jo=function(n){ve.batch(()=>{var r,o,a,i,c,u,d,h;if(b(this,ht)&&this.hasListeners()){const f=b(this,Tt).variables,m=b(this,Tt).context,x={client:b(this,ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(o=(r=b(this,ht)).onSuccess)==null||o.call(r,n.data,f,m,x)}catch(v){Promise.reject(v)}try{(i=(a=b(this,ht)).onSettled)==null||i.call(a,n.data,null,f,m,x)}catch(v){Promise.reject(v)}}else if((n==null?void 0:n.type)==="error"){try{(u=(c=b(this,ht)).onError)==null||u.call(c,n.error,f,m,x)}catch(v){Promise.reject(v)}try{(h=(d=b(this,ht)).onSettled)==null||h.call(d,void 0,n.error,f,m,x)}catch(v){Promise.reject(v)}}}this.listeners.forEach(f=>{f(b(this,Tt))})})},Wi),Je,Gi,fh=(Gi=class extends Bn{constructor(t={}){super();F(this,Je);this.config=t,M(this,Je,new Map)}build(t,n,r){const o=n.queryKey,a=n.queryHash??Wo(o,n);let i=this.get(a);return i||(i=new sh({client:t,queryKey:o,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(i)),i}add(t){b(this,Je).has(t.queryHash)||(b(this,Je).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=b(this,Je).get(t.queryHash);n&&(t.destroy(),n===t&&b(this,Je).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ve.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return b(this,Je).get(t)}getAll(){return[...b(this,Je).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>$a(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>$a(t,r)):n}notify(t){ve.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ve.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ve.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Je=new WeakMap,Gi),xe,At,Mt,_n,In,_t,On,Dn,Qi,hh=(Qi=class{constructor(e={}){F(this,xe);F(this,At);F(this,Mt);F(this,_n);F(this,In);F(this,_t);F(this,On);F(this,Dn);M(this,xe,e.queryCache||new fh),M(this,At,e.mutationCache||new dh),M(this,Mt,e.defaultOptions||{}),M(this,_n,new Map),M(this,In,new Map),M(this,_t,0)}mount(){Dr(this,_t)._++,b(this,_t)===1&&(M(this,On,qo.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,xe).onFocus())})),M(this,Dn,Jr.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,xe).onOnline())})))}unmount(){var e,t;Dr(this,_t)._--,b(this,_t)===0&&((e=b(this,On))==null||e.call(this),M(this,On,void 0),(t=b(this,Dn))==null||t.call(this),M(this,Dn,void 0))}isFetching(e){return b(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return b(this,At).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=b(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(It(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return b(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=b(this,xe).get(r.queryHash),a=o==null?void 0:o.state.data,i=Gf(t,a);if(i!==void 0)return b(this,xe).build(this,r).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return ve.batch(()=>b(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=b(this,xe);ve.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=b(this,xe);return ve.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ve.batch(()=>b(this,xe).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(Ee).catch(Ee)}invalidateQueries(e,t={}){return ve.batch(()=>(b(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ve.batch(()=>b(this,xe).findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let a=o.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ee)),o.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ee)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=b(this,xe).build(this,t);return n.isStaleByTime(It(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ee).catch(Ee)}fetchInfiniteQuery(e){return e.behavior=Ga(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ee).catch(Ee)}ensureInfiniteQueryData(e){return e.behavior=Ga(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Jr.isOnline()?b(this,At).resumePausedMutations():Promise.resolve()}getQueryCache(){return b(this,xe)}getMutationCache(){return b(this,At)}getDefaultOptions(){return b(this,Mt)}setDefaultOptions(e){M(this,Mt,e)}setQueryDefaults(e,t){b(this,_n).set(an(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...b(this,_n).values()],n={};return t.forEach(r=>{ur(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){b(this,In).set(an(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...b(this,In).values()],n={};return t.forEach(r=>{ur(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...b(this,Mt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Wo(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Go&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...b(this,Mt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){b(this,xe).clear(),b(this,At).clear()}},xe=new WeakMap,At=new WeakMap,Mt=new WeakMap,_n=new WeakMap,In=new WeakMap,_t=new WeakMap,On=new WeakMap,Dn=new WeakMap,Qi),lc=l.createContext(void 0),Ne=e=>{const t=l.useContext(lc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},mh=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(lc.Provider,{value:e,children:t})),dc=l.createContext(!1),ph=()=>l.useContext(dc);dc.Provider;function xh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var gh=l.createContext(xh()),vh=()=>l.useContext(gh),yh=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Qo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},bh=e=>{l.useEffect(()=>{e.clearReset()},[e])},wh=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Qo(n,[e.error,r])),Nh=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},jh=(e,t)=>e.isLoading&&e.isFetching&&!t,Ch=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ya=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Sh(e,t,n){var m,x,v,p;const r=ph(),o=vh(),a=Ne(),i=a.defaultQueryOptions(e);(x=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||x.call(m,i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=r?"isRestoring":"optimistic",Nh(i),yh(i,o,c),bh(o);const u=!a.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(a,i)),h=d.getOptimisticResult(i),f=!r&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(g=>{const w=f?d.subscribe(ve.batchCalls(g)):Ee;return d.updateResult(),w},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Ch(i,h))throw Ya(i,d,o);if(wh({result:h,errorResetBoundary:o,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw h.error;if((p=(v=a.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||p.call(v,i,h),i.experimental_prefetchInRender&&!fr.isServer()&&jh(h,r)){const g=u?Ya(i,d,o):c==null?void 0:c.promise;g==null||g.catch(Ee).finally(()=>{d.updateResult()})}return i.notifyOnChangeProps?h:d.trackResult(h)}function Le(e,t){return Sh(e,oh)}function Te(e,t){const n=Ne(),[r]=l.useState(()=>new uh(n,e));l.useEffect(()=>{r.setOptions(e)},[r,e]);const o=l.useSyncExternalStore(l.useCallback(i=>r.subscribe(ve.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=l.useCallback((i,c)=>{r.mutate(i,c).catch(Ee)},[r]);if(o.error&&Qo(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}const es=new hh({defaultOptions:{queries:{staleTime:3e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});class ts extends Error{constructor(t,n,r,o){super(n),this.code=t,this.status=r,this.context=o,this.name="ApiError"}}const Eh="x-csrf-token",Rh=new Set(["POST","PUT","PATCH","DELETE"]);let qr=null;function Ph(){return qr??(qr=fetch("/api/csrf").then(async e=>{var n;const t=await e.json();if(!e.ok||!((n=t.data)!=null&&n.token))throw new ts("csrf.unavailable",`GET /api/csrf answered ${e.status}`,e.status);return t.data.token}).catch(e=>{throw qr=null,e})),qr}async function kh(e){var n;return e.status!==403?!1:((n=(await e.clone().json().catch(()=>({}))).error)==null?void 0:n.code)==="csrf.invalid"}async function Xo(e,t={}){const n=(t.method??"GET").toUpperCase();if(!Rh.has(n))return fetch(e,t);const r=async()=>{const a=new Headers(t.headers);return a.set(Eh,await Ph()),fetch(e,{...t,headers:a})},o=await r();return await kh(o)?(qr=null,r()):o}function Th(e,t){if(!t)return e;const n=new URLSearchParams;for(const[o,a]of Object.entries(t))a!=null&&a!==""&&n.set(o,String(a));const r=n.toString();return r?`${e}?${r}`:e}async function Ah(e){const t=fc();return t!==e?t!==null:Oh()}async function cr(e,t,n,r,o=!1){const a=fc(),i={};a&&(i.Authorization=`Bearer ${a}`);const c=Th(t,r),u={method:e,headers:i};n!==void 0&&(i["Content-Type"]="application/json",u.body=JSON.stringify(n));const d=await Xo(c,u);if(d.status===401){if(!o&&a!==null&&!t.startsWith("/api/auth/")&&await Ah(a))return cr(e,t,n,r,!0);const m=(await d.json().catch(()=>({}))).error;throw new ts((m==null?void 0:m.code)??"UNAUTHORIZED",(m==null?void 0:m.message)??"Unauthorized",401)}const h=await d.json();if(!d.ok){const f=h.error;throw new ts((f==null?void 0:f.code)??"UNKNOWN_ERROR",(f==null?void 0:f.message)??`HTTP ${d.status}`,d.status,f==null?void 0:f.context)}return"data"in h?h.data:h}const de={get(e,t){return cr("GET",e,void 0,t)},post(e,t){return cr("POST",e,t)},patch(e,t){return cr("PATCH",e,t)},delete(e){return cr("DELETE",e)}};let ms=null,Bs=null;const Co=new Set;function uc(e){ms=e}function fc(){return ms}function hc(){ms=null}function ns(){return ms!==null}function Mh(e){return Co.add(e),()=>{Co.delete(e)}}async function _h(e){var t,n;try{const r=await fetch("/api/admin/me",{headers:{Authorization:`Bearer ${e}`}});return r.ok?((n=(t=(await r.json()).data)==null?void 0:t.roles)==null?void 0:n.includes("admin"))??!1:!1}catch{return!1}}async function Ih(){var t;let e;try{const n=await Xo("/api/auth/refresh",{method:"POST"});if(!n.ok)return!1;e=(t=(await n.json()).data)==null?void 0:t.accessToken}catch{return!1}return!e||!await _h(e)?!1:(uc(e),!0)}function mc(e){return Bs??(Bs=Ih().then(t=>{if(Bs=null,!t&&(hc(),e))for(const n of[...Co])n();return t})),Bs}function Oh(){return mc(!0)}function Dh(){return mc(!1)}/**
|
|
10
|
+
* @license lucide-react v0.462.0 - ISC
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the ISC license.
|
|
13
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/const zh=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pc=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
|
15
|
+
* @license lucide-react v0.462.0 - ISC
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the ISC license.
|
|
18
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/var Lh={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
20
|
+
* @license lucide-react v0.462.0 - ISC
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the ISC license.
|
|
23
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/const Fh=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:a,iconNode:i,...c},u)=>l.createElement("svg",{ref:u,...Lh,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:pc("lucide",o),...c},[...i.map(([d,h])=>l.createElement(d,h)),...Array.isArray(a)?a:[a]]));/**
|
|
25
|
+
* @license lucide-react v0.462.0 - ISC
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the ISC license.
|
|
28
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
29
|
+
*/const H=(e,t)=>{const n=l.forwardRef(({className:r,...o},a)=>l.createElement(Fh,{ref:a,iconNode:t,className:pc(`lucide-${zh(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
|
|
30
|
+
* @license lucide-react v0.462.0 - ISC
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the ISC license.
|
|
33
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/const $h=H("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
|
|
35
|
+
* @license lucide-react v0.462.0 - ISC
|
|
36
|
+
*
|
|
37
|
+
* This source code is licensed under the ISC license.
|
|
38
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
39
|
+
*/const Zo=H("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
40
|
+
* @license lucide-react v0.462.0 - ISC
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the ISC license.
|
|
43
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/const Uh=H("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
|
|
45
|
+
* @license lucide-react v0.462.0 - ISC
|
|
46
|
+
*
|
|
47
|
+
* This source code is licensed under the ISC license.
|
|
48
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
49
|
+
*/const xc=H("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/**
|
|
50
|
+
* @license lucide-react v0.462.0 - ISC
|
|
51
|
+
*
|
|
52
|
+
* This source code is licensed under the ISC license.
|
|
53
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
54
|
+
*/const Vh=H("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
|
55
|
+
* @license lucide-react v0.462.0 - ISC
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the ISC license.
|
|
58
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/const Bh=H("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/**
|
|
60
|
+
* @license lucide-react v0.462.0 - ISC
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the ISC license.
|
|
63
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
64
|
+
*/const Kn=H("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
65
|
+
* @license lucide-react v0.462.0 - ISC
|
|
66
|
+
*
|
|
67
|
+
* This source code is licensed under the ISC license.
|
|
68
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
69
|
+
*/const gc=H("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
70
|
+
* @license lucide-react v0.462.0 - ISC
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the ISC license.
|
|
73
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/const vc=H("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
75
|
+
* @license lucide-react v0.462.0 - ISC
|
|
76
|
+
*
|
|
77
|
+
* This source code is licensed under the ISC license.
|
|
78
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
79
|
+
*/const Kh=H("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
|
80
|
+
* @license lucide-react v0.462.0 - ISC
|
|
81
|
+
*
|
|
82
|
+
* This source code is licensed under the ISC license.
|
|
83
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
84
|
+
*/const Hh=H("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
85
|
+
* @license lucide-react v0.462.0 - ISC
|
|
86
|
+
*
|
|
87
|
+
* This source code is licensed under the ISC license.
|
|
88
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
89
|
+
*/const Xa=H("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
|
90
|
+
* @license lucide-react v0.462.0 - ISC
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the ISC license.
|
|
93
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
94
|
+
*/const qh=H("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
95
|
+
* @license lucide-react v0.462.0 - ISC
|
|
96
|
+
*
|
|
97
|
+
* This source code is licensed under the ISC license.
|
|
98
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
99
|
+
*/const Wh=H("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
100
|
+
* @license lucide-react v0.462.0 - ISC
|
|
101
|
+
*
|
|
102
|
+
* This source code is licensed under the ISC license.
|
|
103
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
104
|
+
*/const Za=H("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
|
105
|
+
* @license lucide-react v0.462.0 - ISC
|
|
106
|
+
*
|
|
107
|
+
* This source code is licensed under the ISC license.
|
|
108
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
109
|
+
*/const Gh=H("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
110
|
+
* @license lucide-react v0.462.0 - ISC
|
|
111
|
+
*
|
|
112
|
+
* This source code is licensed under the ISC license.
|
|
113
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
114
|
+
*/const Qh=H("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
|
|
115
|
+
* @license lucide-react v0.462.0 - ISC
|
|
116
|
+
*
|
|
117
|
+
* This source code is licensed under the ISC license.
|
|
118
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
119
|
+
*/const Yh=H("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
|
|
120
|
+
* @license lucide-react v0.462.0 - ISC
|
|
121
|
+
*
|
|
122
|
+
* This source code is licensed under the ISC license.
|
|
123
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
124
|
+
*/const yc=H("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
125
|
+
* @license lucide-react v0.462.0 - ISC
|
|
126
|
+
*
|
|
127
|
+
* This source code is licensed under the ISC license.
|
|
128
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
129
|
+
*/const Xh=H("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
130
|
+
* @license lucide-react v0.462.0 - ISC
|
|
131
|
+
*
|
|
132
|
+
* This source code is licensed under the ISC license.
|
|
133
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
134
|
+
*/const Zh=H("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
135
|
+
* @license lucide-react v0.462.0 - ISC
|
|
136
|
+
*
|
|
137
|
+
* This source code is licensed under the ISC license.
|
|
138
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
139
|
+
*/const Jh=H("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
|
140
|
+
* @license lucide-react v0.462.0 - ISC
|
|
141
|
+
*
|
|
142
|
+
* This source code is licensed under the ISC license.
|
|
143
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
144
|
+
*/const em=H("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
|
|
145
|
+
* @license lucide-react v0.462.0 - ISC
|
|
146
|
+
*
|
|
147
|
+
* This source code is licensed under the ISC license.
|
|
148
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
149
|
+
*/const tm=H("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
150
|
+
* @license lucide-react v0.462.0 - ISC
|
|
151
|
+
*
|
|
152
|
+
* This source code is licensed under the ISC license.
|
|
153
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
154
|
+
*/const bc=H("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
155
|
+
* @license lucide-react v0.462.0 - ISC
|
|
156
|
+
*
|
|
157
|
+
* This source code is licensed under the ISC license.
|
|
158
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
159
|
+
*/const nm=H("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
160
|
+
* @license lucide-react v0.462.0 - ISC
|
|
161
|
+
*
|
|
162
|
+
* This source code is licensed under the ISC license.
|
|
163
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
164
|
+
*/const wc=H("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
165
|
+
* @license lucide-react v0.462.0 - ISC
|
|
166
|
+
*
|
|
167
|
+
* This source code is licensed under the ISC license.
|
|
168
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
169
|
+
*/const rm=H("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
170
|
+
* @license lucide-react v0.462.0 - ISC
|
|
171
|
+
*
|
|
172
|
+
* This source code is licensed under the ISC license.
|
|
173
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
174
|
+
*/const sm=H("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
|
175
|
+
* @license lucide-react v0.462.0 - ISC
|
|
176
|
+
*
|
|
177
|
+
* This source code is licensed under the ISC license.
|
|
178
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
179
|
+
*/const om=H("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
180
|
+
* @license lucide-react v0.462.0 - ISC
|
|
181
|
+
*
|
|
182
|
+
* This source code is licensed under the ISC license.
|
|
183
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
184
|
+
*/const cn=H("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
|
|
185
|
+
* @license lucide-react v0.462.0 - ISC
|
|
186
|
+
*
|
|
187
|
+
* This source code is licensed under the ISC license.
|
|
188
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
189
|
+
*/const am=H("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
|
|
190
|
+
* @license lucide-react v0.462.0 - ISC
|
|
191
|
+
*
|
|
192
|
+
* This source code is licensed under the ISC license.
|
|
193
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
194
|
+
*/const hr=H("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
195
|
+
* @license lucide-react v0.462.0 - ISC
|
|
196
|
+
*
|
|
197
|
+
* This source code is licensed under the ISC license.
|
|
198
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
199
|
+
*/const im=H("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
|
200
|
+
* @license lucide-react v0.462.0 - ISC
|
|
201
|
+
*
|
|
202
|
+
* This source code is licensed under the ISC license.
|
|
203
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
204
|
+
*/const Hn=H("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
205
|
+
* @license lucide-react v0.462.0 - ISC
|
|
206
|
+
*
|
|
207
|
+
* This source code is licensed under the ISC license.
|
|
208
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
209
|
+
*/const Nc=H("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
|
210
|
+
* @license lucide-react v0.462.0 - ISC
|
|
211
|
+
*
|
|
212
|
+
* This source code is licensed under the ISC license.
|
|
213
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
214
|
+
*/const zn=H("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/**
|
|
215
|
+
* @license lucide-react v0.462.0 - ISC
|
|
216
|
+
*
|
|
217
|
+
* This source code is licensed under the ISC license.
|
|
218
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
219
|
+
*/const cm=H("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
220
|
+
* @license lucide-react v0.462.0 - ISC
|
|
221
|
+
*
|
|
222
|
+
* This source code is licensed under the ISC license.
|
|
223
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
224
|
+
*/const lm=H("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
|
|
225
|
+
* @license lucide-react v0.462.0 - ISC
|
|
226
|
+
*
|
|
227
|
+
* This source code is licensed under the ISC license.
|
|
228
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
229
|
+
*/const jc=H("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
230
|
+
* @license lucide-react v0.462.0 - ISC
|
|
231
|
+
*
|
|
232
|
+
* This source code is licensed under the ISC license.
|
|
233
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
234
|
+
*/const So=H("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
|
|
235
|
+
* @license lucide-react v0.462.0 - ISC
|
|
236
|
+
*
|
|
237
|
+
* This source code is licensed under the ISC license.
|
|
238
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
239
|
+
*/const rs=H("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
240
|
+
* @license lucide-react v0.462.0 - ISC
|
|
241
|
+
*
|
|
242
|
+
* This source code is licensed under the ISC license.
|
|
243
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
244
|
+
*/const Cc=H("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/**
|
|
245
|
+
* @license lucide-react v0.462.0 - ISC
|
|
246
|
+
*
|
|
247
|
+
* This source code is licensed under the ISC license.
|
|
248
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
249
|
+
*/const Jo=H("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
|
250
|
+
* @license lucide-react v0.462.0 - ISC
|
|
251
|
+
*
|
|
252
|
+
* This source code is licensed under the ISC license.
|
|
253
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
254
|
+
*/const ps=H("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Sc(){return Le({queryKey:["me"],queryFn:()=>de.get("/api/admin/me"),staleTime:5*6e4})}function Ec(){const e=vt(),t=l.useCallback(async(r,o)=>{var d;const a=await Xo("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r,password:o})}),i=await a.json();if(!a.ok||!i.data)throw new Error(((d=i.error)==null?void 0:d.message)??"Login failed");const{accessToken:c,customer:u}=i.data;if(!u.roles.includes("admin"))throw new Error("Not authorized: admin role required");uc(c),await es.invalidateQueries({queryKey:["me"]}),e("/")},[e]),n=l.useCallback(async()=>{await de.post("/api/auth/logout").catch(()=>{}),hc(),es.clear(),e("/login")},[e]);return{isAuthenticated:ns(),login:t,logout:n}}function Rc(e={}){return Le({queryKey:["orders","list",e],queryFn:()=>de.get("/api/admin/orders",e)})}function dm(e){return Le({queryKey:["orders","detail",e],queryFn:()=>de.get(`/api/admin/orders/${e}`),enabled:!!e})}function um(e){return Le({queryKey:["orders","notes",e],queryFn:()=>de.get(`/api/admin/orders/${e}/notes`),enabled:!!e})}function fm(){const e=Ne();return Te({mutationFn:async({orderId:t,action:n,body:r})=>de.post(`/api/admin/orders/${t}/${n}`,r),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","detail",t.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})}})}function hm(){const e=Ne();return Te({mutationFn:({orderId:t,reason:n})=>de.post(`/api/admin/orders/${t}/cancel`,{reason:n}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function Pc(){const e=Ne();return Te({mutationFn:({orderId:t,note:n})=>de.post(`/api/admin/orders/${t}/mark-paid`,n?{note:n}:{}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","detail",t.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})}})}function mm(){const e=Ne();return Te({mutationFn:t=>de.post(`/api/admin/orders/${t}/mark-delivered`),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function pm(){const e=Ne();return Te({mutationFn:({orderId:t,trackingNumber:n,carrier:r})=>de.post(`/api/admin/orders/${t}/ship`,{trackingNumber:n,carrier:r}),onSuccess:t=>{e.setQueryData(["orders","detail",t.orderNumber],n=>n?{...n,...t}:t),e.invalidateQueries({queryKey:["orders","list"]})}})}function xm(){const e=Ne();return Te({mutationFn:({orderId:t,amountMinor:n,reason:r,requestId:o})=>de.post(`/api/admin/orders/${t}/refund`,r?{amountMinor:n,reason:r,requestId:o}:{amountMinor:n,requestId:o}),onSuccess:async t=>{await Promise.all([e.invalidateQueries({queryKey:["orders","detail",t.order.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})])}})}function gm(){const e=Ne();return Te({mutationFn:({orderId:t,body:n})=>de.post(`/api/admin/orders/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["orders","notes",n.orderId]})}})}function q(...e){return["admin",...e].join("-")}function kc(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=kc(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Tc(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=kc(e))&&(r&&(r+=" "),r+=t);return r}const ea="-",vm=e=>{const t=bm(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{const c=i.split(ea);return c[0]===""&&c.length!==1&&c.shift(),Ac(c,t)||ym(i)},getConflictingClassGroupIds:(i,c)=>{const u=n[i]||[];return c&&r[i]?[...u,...r[i]]:u}}},Ac=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?Ac(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const a=e.join(ea);return(i=t.validators.find(({validator:c})=>c(a)))==null?void 0:i.classGroupId},Ja=/^\[(.+)\]$/,ym=e=>{if(Ja.test(e)){const t=Ja.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},bm=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Nm(Object.entries(e.classGroups),n).forEach(([a,i])=>{Eo(i,r,a,t)}),r},Eo=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?t:ei(t,o);a.classGroupId=n;return}if(typeof o=="function"){if(wm(o)){Eo(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([a,i])=>{Eo(i,ei(t,a),n,r)})})},ei=(e,t)=>{let n=e;return t.split(ea).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},wm=e=>e.isThemeGetter,Nm=(e,t)=>t?e.map(([n,r])=>{const o=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,c])=>[t+i,c])):a);return[n,o]}):e,jm=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(a,i)=>{n.set(a,i),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let i=n.get(a);if(i!==void 0)return i;if((i=r.get(a))!==void 0)return o(a,i),i},set(a,i){n.has(a)?n.set(a,i):o(a,i)}}},Mc="!",Cm=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],a=t.length,i=c=>{const u=[];let d=0,h=0,f;for(let g=0;g<c.length;g++){let w=c[g];if(d===0){if(w===o&&(r||c.slice(g,g+a)===t)){u.push(c.slice(h,g)),h=g+a;continue}if(w==="/"){f=g;continue}}w==="["?d++:w==="]"&&d--}const m=u.length===0?c:c.substring(h),x=m.startsWith(Mc),v=x?m.substring(1):m,p=f&&f>h?f-h:void 0;return{modifiers:u,hasImportantModifier:x,baseClassName:v,maybePostfixModifierPosition:p}};return n?c=>n({className:c,parseClassName:i}):i},Sm=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},Em=e=>({cache:jm(e.cacheSize),parseClassName:Cm(e),...vm(e)}),Rm=/\s+/,Pm=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,a=[],i=e.trim().split(Rm);let c="";for(let u=i.length-1;u>=0;u-=1){const d=i[u],{modifiers:h,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:x}=n(d);let v=!!x,p=r(v?m.substring(0,x):m);if(!p){if(!v){c=d+(c.length>0?" "+c:c);continue}if(p=r(m),!p){c=d+(c.length>0?" "+c:c);continue}v=!1}const g=Sm(h).join(":"),w=f?g+Mc:g,y=w+p;if(a.includes(y))continue;a.push(y);const N=o(p,v);for(let j=0;j<N.length;++j){const C=N[j];a.push(w+C)}c=d+(c.length>0?" "+c:c)}return c};function km(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=_c(t))&&(r&&(r+=" "),r+=n);return r}const _c=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=_c(e[r]))&&(n&&(n+=" "),n+=t);return n};function Tm(e,...t){let n,r,o,a=i;function i(u){const d=t.reduce((h,f)=>f(h),e());return n=Em(d),r=n.cache.get,o=n.cache.set,a=c,c(u)}function c(u){const d=r(u);if(d)return d;const h=Pm(u,n);return o(u,h),h}return function(){return a(km.apply(null,arguments))}}const he=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Ic=/^\[(?:([a-z-]+):)?(.+)\]$/i,Am=/^\d+\/\d+$/,Mm=new Set(["px","full","screen"]),_m=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Im=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Om=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Dm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zm=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ct=e=>Nn(e)||Mm.has(e)||Am.test(e),wt=e=>qn(e,"length",Hm),Nn=e=>!!e&&!Number.isNaN(Number(e)),Ks=e=>qn(e,"number",Nn),sr=e=>!!e&&Number.isInteger(Number(e)),Lm=e=>e.endsWith("%")&&Nn(e.slice(0,-1)),ee=e=>Ic.test(e),Nt=e=>_m.test(e),Fm=new Set(["length","size","percentage"]),$m=e=>qn(e,Fm,Oc),Um=e=>qn(e,"position",Oc),Vm=new Set(["image","url"]),Bm=e=>qn(e,Vm,Wm),Km=e=>qn(e,"",qm),or=()=>!0,qn=(e,t,n)=>{const r=Ic.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},Hm=e=>Im.test(e)&&!Om.test(e),Oc=()=>!1,qm=e=>Dm.test(e),Wm=e=>zm.test(e),Gm=()=>{const e=he("colors"),t=he("spacing"),n=he("blur"),r=he("brightness"),o=he("borderColor"),a=he("borderRadius"),i=he("borderSpacing"),c=he("borderWidth"),u=he("contrast"),d=he("grayscale"),h=he("hueRotate"),f=he("invert"),m=he("gap"),x=he("gradientColorStops"),v=he("gradientColorStopPositions"),p=he("inset"),g=he("margin"),w=he("opacity"),y=he("padding"),N=he("saturate"),j=he("scale"),C=he("sepia"),E=he("skew"),S=he("space"),P=he("translate"),D=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto",ee,t],_=()=>[ee,t],G=()=>["",ct,wt],U=()=>["auto",Nn,ee],X=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],V=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],L=()=>["start","end","center","between","around","evenly","stretch"],T=()=>["","0",ee],ae=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ie=()=>[Nn,ee];return{cacheSize:500,separator:":",theme:{colors:[or],spacing:[ct,wt],blur:["none","",Nt,ee],brightness:ie(),borderColor:[e],borderRadius:["none","","full",Nt,ee],borderSpacing:_(),borderWidth:G(),contrast:ie(),grayscale:T(),hueRotate:ie(),invert:T(),gap:_(),gradientColorStops:[e],gradientColorStopPositions:[Lm,wt],inset:$(),margin:$(),opacity:ie(),padding:_(),saturate:ie(),scale:ie(),sepia:T(),skew:ie(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],container:["container"],columns:[{columns:[Nt]}],"break-after":[{"break-after":ae()}],"break-before":[{"break-before":ae()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...X(),ee]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",sr,ee]}],basis:[{basis:$()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",sr,ee]}],"grid-cols":[{"grid-cols":[or]}],"col-start-end":[{col:["auto",{span:["full",sr,ee]},ee]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[or]}],"row-start-end":[{row:["auto",{span:[sr,ee]},ee]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...L()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...L(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...L(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,t]}],"min-w":[{"min-w":[ee,t,"min","max","fit"]}],"max-w":[{"max-w":[ee,t,"none","full","min","max","fit","prose",{screen:[Nt]},Nt]}],h:[{h:[ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Nt,wt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ks]}],"font-family":[{font:[or]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ee]}],"line-clamp":[{"line-clamp":["none",Nn,Ks]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ct,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ct,wt]}],"underline-offset":[{"underline-offset":["auto",ct,ee]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...X(),Um]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",$m]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Bm]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[v]}],"gradient-via-pos":[{via:[v]}],"gradient-to-pos":[{to:[v]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[c]}],"border-w-x":[{"border-x":[c]}],"border-w-y":[{"border-y":[c]}],"border-w-s":[{"border-s":[c]}],"border-w-e":[{"border-e":[c]}],"border-w-t":[{"border-t":[c]}],"border-w-r":[{"border-r":[c]}],"border-w-b":[{"border-b":[c]}],"border-w-l":[{"border-l":[c]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...V(),"hidden"]}],"divide-x":[{"divide-x":[c]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[c]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[w]}],"divide-style":[{divide:V()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...V()]}],"outline-offset":[{"outline-offset":[ct,ee]}],"outline-w":[{outline:[ct,wt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[ct,wt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Nt,Km]}],"shadow-color":[{shadow:[or]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Nt,ee]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[f]}],saturate:[{saturate:[N]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ee]}],duration:[{duration:ie()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:ie()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[sr,ee]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"skew-x":[{"skew-x":[E]}],"skew-y":[{"skew-y":[E]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ee]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ee]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[ct,wt,Ks]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Qm=Tm(Gm);function k(...e){return Qm(Tc(e))}const Ym=[{to:"/",label:"Dashboard",icon:tm,end:!0},{to:"/orders",label:"Orders",icon:zn,end:!1},{to:"/products",label:"Products",icon:cn,end:!1},{to:"/inventory",label:"Inventory",icon:xc,end:!1},{to:"/customers",label:"Customers",icon:Jo,end:!1}];function Xm(){const{data:e}=Rc({status:"pending",limit:1});return!e||e.length===0?null:s.jsx("span",{className:"ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-blue-500/20 px-1 text-[10px] font-semibold text-blue-400",children:e.length})}function Zm({open:e,onClose:t}){const{data:n}=Sc(),{logout:r}=Ec(),o=()=>{r()};return s.jsxs("aside",{id:"admin-sidebar","data-testid":q("sidebar"),"data-state":e?"open":"closed",className:k("fixed inset-y-0 left-0 z-50 flex w-60 flex-col bg-zinc-950 transition-transform duration-150 md:visible md:translate-x-0",e?"visible translate-x-0":"invisible -translate-x-full"),children:[s.jsxs("div",{className:"flex h-14 items-center border-b border-zinc-800/60 px-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600",children:s.jsx("span",{className:"text-xs font-bold text-white",children:"N"})}),s.jsx("span",{className:"text-sm font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"})]}),(n==null?void 0:n.storeName)&&s.jsx("span",{className:"ml-2 truncate text-[10px] font-medium text-zinc-500 border-l border-zinc-700 pl-2",children:n.storeName})]}),s.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:s.jsx("ul",{className:"space-y-0.5",children:Ym.map(a=>s.jsx("li",{children:s.jsx(Tf,{to:a.to,end:a.end,"data-testid":q("nav",a.label.toLowerCase()),onClick:t,className:({isActive:i})=>k("flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium transition-all duration-100",i?"border-l-2 border-blue-500 bg-blue-600/10 pl-[10px] text-blue-400":"text-zinc-400 hover:bg-zinc-800/50 hover:text-zinc-200"),children:({isActive:i})=>s.jsxs(s.Fragment,{children:[s.jsx(a.icon,{className:k("h-4 w-4 shrink-0",i?"text-blue-400":"text-zinc-500")}),s.jsx("span",{children:a.label}),a.label==="Orders"&&s.jsx(Xm,{})]})})},a.to))})}),s.jsx("div",{className:"border-t border-zinc-800/60"}),s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-3 rounded-md px-3 py-2.5",children:[s.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-zinc-700 text-xs font-semibold text-zinc-300",children:n?n.userId.slice(0,2).toUpperCase():s.jsx(bc,{className:"h-3.5 w-3.5 animate-spin"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-xs font-medium text-zinc-300",children:(n==null?void 0:n.storeName)??"Loading..."}),s.jsx("p",{className:"truncate text-[10px] text-zinc-500 capitalize",children:(n==null?void 0:n.environment)??""})]}),s.jsx("button",{onClick:o,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 transition-colors",title:"Sign out",children:s.jsx(nm,{className:"h-3.5 w-3.5"})})]})})]})}function Jm(){const t=Af().filter(n=>{const r=n.handle;return(r==null?void 0:r.breadcrumb)!=null}).map(n=>{var a;const r=n.handle;return{label:(a=r.breadcrumb)==null?void 0:a.call(r,n.params),pathname:n.pathname}}).filter(n=>n.label!=null);return t.length===0?null:s.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:t.map((n,r)=>{const o=r===t.length-1;return s.jsxs("span",{className:"flex items-center gap-1",children:[r>0&&s.jsx(vc,{className:"h-3.5 w-3.5 text-zinc-400"}),o?s.jsx("span",{className:"font-medium text-zinc-900",children:n.label}):s.jsx(sn,{to:n.pathname,className:k("text-zinc-500 hover:text-zinc-700 transition-colors","font-normal"),children:n.label})]},n.pathname)})})}const ti=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ni=Tc,xs=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return ni(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(d=>{const h=n==null?void 0:n[d],f=a==null?void 0:a[d];if(h===null)return null;const m=ti(h)||ti(f);return o[d][m]}),c=n&&Object.entries(n).reduce((d,h)=>{let[f,m]=h;return m===void 0||(d[f]=m),d},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,h)=>{let{class:f,className:m,...x}=h;return Object.entries(x).every(v=>{let[p,g]=v;return Array.isArray(g)?g.includes({...a,...c}[p]):{...a,...c}[p]===g})?[...d,f,m]:d},[]);return ni(e,i,u,n==null?void 0:n.class,n==null?void 0:n.className)},ep=xs("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800",secondary:"bg-zinc-100 text-zinc-900 hover:bg-zinc-200 active:bg-zinc-300 border border-zinc-200",destructive:"bg-red-600 text-white hover:bg-red-700 active:bg-red-800",outline:"border border-zinc-200 bg-white text-zinc-900 hover:bg-zinc-50 active:bg-zinc-100",ghost:"text-zinc-700 hover:bg-zinc-100 hover:text-zinc-900 active:bg-zinc-200",link:"text-blue-600 underline-offset-4 hover:underline p-0 h-auto"},size:{default:"h-9 px-4 py-2",sm:"h-7 rounded px-3 text-xs",lg:"h-11 rounded-md px-8 text-base",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),pe=l.forwardRef(({className:e,variant:t,size:n,...r},o)=>s.jsx("button",{className:k(ep({variant:t,size:n,className:e})),ref:o,...r}));pe.displayName="Button";function I(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ri(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function rt(...e){return t=>{let n=!1;const r=e.map(o=>{const a=ri(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():ri(e[o],null)}}}}function ce(...e){return l.useCallback(rt(...e),e)}function tp(e,t){const n=l.createContext(t),r=a=>{const{children:i,...c}=a,u=l.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:i})};r.displayName=e+"Provider";function o(a){const i=l.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function ot(e,t=[]){let n=[];function r(a,i){const c=l.createContext(i),u=n.length;n=[...n,i];const d=f=>{var w;const{scope:m,children:x,...v}=f,p=((w=m==null?void 0:m[e])==null?void 0:w[u])||c,g=l.useMemo(()=>v,Object.values(v));return s.jsx(p.Provider,{value:g,children:x})};d.displayName=a+"Provider";function h(f,m){var p;const x=((p=m==null?void 0:m[e])==null?void 0:p[u])||c,v=l.useContext(x);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[d,h]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const u=(c==null?void 0:c[e])||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return o.scopeName=e,[r,np(o,...t)]}function np(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((c,{useScope:u,scopeName:d})=>{const f=u(a)[`__scope${d}`];return{...c,...f}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ln(e){const t=rp(e),n=l.forwardRef((r,o)=>{const{children:a,...i}=r,c=l.Children.toArray(a),u=c.find(op);if(u){const d=u.props.children,h=c.map(f=>f===u?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:f);return s.jsx(t,{...i,ref:o,children:l.isValidElement(d)?l.cloneElement(d,void 0,h):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function rp(e){const t=l.forwardRef((n,r)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=ip(o),c=ap(a,o.props);return o.type!==l.Fragment&&(c.ref=r?rt(r,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var sp=Symbol("radix.slottable");function op(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===sp}function ap(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const u=a(...c);return o(...c),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ip(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var cp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],W=cp.reduce((e,t)=>{const n=ln(`Primitive.${t}`),r=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Dc(e,t){e&&Cr.flushSync(()=>e.dispatchEvent(t))}function st(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lp(e,t=globalThis==null?void 0:globalThis.document){const n=st(e);l.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var dp="DismissableLayer",Ro="dismissableLayer.update",up="dismissableLayer.pointerDownOutside",fp="dismissableLayer.focusOutside",si,zc=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...u}=e,d=l.useContext(zc),[h,f]=l.useState(null),m=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=l.useState({}),v=ce(t,S=>f(S)),p=Array.from(d.layers),[g]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),w=p.indexOf(g),y=h?p.indexOf(h):-1,N=d.layersWithOutsidePointerEventsDisabled.size>0,j=y>=w,C=pp(S=>{const P=S.target,D=[...d.branches].some(O=>O.contains(P));!j||D||(o==null||o(S),i==null||i(S),S.defaultPrevented||c==null||c())},m),E=xp(S=>{const P=S.target;[...d.branches].some(O=>O.contains(P))||(a==null||a(S),i==null||i(S),S.defaultPrevented||c==null||c())},m);return lp(S=>{y===d.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&c&&(S.preventDefault(),c()))},m),l.useEffect(()=>{if(h)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(si=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),oi(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=si)}},[h,m,n,d]),l.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),oi())},[h,d]),l.useEffect(()=>{const S=()=>x({});return document.addEventListener(Ro,S),()=>document.removeEventListener(Ro,S)},[]),s.jsx(W.div,{...u,ref:v,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:I(e.onFocusCapture,E.onFocusCapture),onBlurCapture:I(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:I(e.onPointerDownCapture,C.onPointerDownCapture)})});Sr.displayName=dp;var hp="DismissableLayerBranch",mp=l.forwardRef((e,t)=>{const n=l.useContext(zc),r=l.useRef(null),o=ce(t,r);return l.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(W.div,{...e,ref:o})});mp.displayName=hp;function pp(e,t=globalThis==null?void 0:globalThis.document){const n=st(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let u=function(){Lc(up,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function xp(e,t=globalThis==null?void 0:globalThis.document){const n=st(e),r=l.useRef(!1);return l.useEffect(()=>{const o=a=>{a.target&&!r.current&&Lc(fp,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function oi(){const e=new CustomEvent(Ro);document.dispatchEvent(e)}function Lc(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Dc(o,a):o.dispatchEvent(a)}var Hs=0;function gs(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ai()),document.body.insertAdjacentElement("beforeend",e[1]??ai()),Hs++,()=>{Hs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hs--}},[])}function ai(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var qs="focusScope.autoFocusOnMount",Ws="focusScope.autoFocusOnUnmount",ii={bubbles:!1,cancelable:!0},gp="FocusScope",Er=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,u]=l.useState(null),d=st(o),h=st(a),f=l.useRef(null),m=ce(t,p=>u(p)),x=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let p=function(N){if(x.paused||!c)return;const j=N.target;c.contains(j)?f.current=j:Ct(f.current,{select:!0})},g=function(N){if(x.paused||!c)return;const j=N.relatedTarget;j!==null&&(c.contains(j)||Ct(f.current,{select:!0}))},w=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&Ct(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",g);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",g),y.disconnect()}}},[r,c,x.paused]),l.useEffect(()=>{if(c){li.add(x);const p=document.activeElement;if(!c.contains(p)){const w=new CustomEvent(qs,ii);c.addEventListener(qs,d),c.dispatchEvent(w),w.defaultPrevented||(vp(jp(Fc(c)),{select:!0}),document.activeElement===p&&Ct(c))}return()=>{c.removeEventListener(qs,d),setTimeout(()=>{const w=new CustomEvent(Ws,ii);c.addEventListener(Ws,h),c.dispatchEvent(w),w.defaultPrevented||Ct(p??document.body,{select:!0}),c.removeEventListener(Ws,h),li.remove(x)},0)}}},[c,d,h,x]);const v=l.useCallback(p=>{if(!n&&!r||x.paused)return;const g=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,w=document.activeElement;if(g&&w){const y=p.currentTarget,[N,j]=yp(y);N&&j?!p.shiftKey&&w===j?(p.preventDefault(),n&&Ct(N,{select:!0})):p.shiftKey&&w===N&&(p.preventDefault(),n&&Ct(j,{select:!0})):w===y&&p.preventDefault()}},[n,r,x.paused]);return s.jsx(W.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Er.displayName=gp;function vp(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ct(r,{select:t}),document.activeElement!==n)return}function yp(e){const t=Fc(e),n=ci(t,e),r=ci(t.reverse(),e);return[n,r]}function Fc(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ci(e,t){for(const n of e)if(!bp(n,{upTo:t}))return n}function bp(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function wp(e){return e instanceof HTMLInputElement&&"select"in e}function Ct(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&wp(e)&&t&&e.select()}}var li=Np();function Np(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=di(e,t),e.unshift(t)},remove(t){var n;e=di(e,t),(n=e[0])==null||n.resume()}}}function di(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jp(e){return e.filter(t=>t.tagName!=="A")}var Ce=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},Cp=Ko[" useId ".trim().toString()]||(()=>{}),Sp=0;function we(e){const[t,n]=l.useState(Cp());return Ce(()=>{n(r=>r??String(Sp++))},[e]),t?`radix-${t}`:""}const Ep=["top","right","bottom","left"],Dt=Math.min,Oe=Math.max,ss=Math.round,Lr=Math.floor,nt=e=>({x:e,y:e}),Rp={left:"right",right:"left",bottom:"top",top:"bottom"};function Po(e,t,n){return Oe(e,Dt(t,n))}function xt(e,t){return typeof e=="function"?e(t):e}function gt(e){return e.split("-")[0]}function Wn(e){return e.split("-")[1]}function ta(e){return e==="x"?"y":"x"}function na(e){return e==="y"?"height":"width"}function tt(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ra(e){return ta(tt(e))}function Pp(e,t,n){n===void 0&&(n=!1);const r=Wn(e),o=ra(e),a=na(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=os(i)),[i,os(i)]}function kp(e){const t=os(e);return[ko(e),t,ko(t)]}function ko(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ui=["left","right"],fi=["right","left"],Tp=["top","bottom"],Ap=["bottom","top"];function Mp(e,t,n){switch(e){case"top":case"bottom":return n?t?fi:ui:t?ui:fi;case"left":case"right":return t?Tp:Ap;default:return[]}}function _p(e,t,n,r){const o=Wn(e);let a=Mp(gt(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(ko)))),a}function os(e){const t=gt(e);return Rp[t]+e.slice(t.length)}function Ip(e){return{top:0,right:0,bottom:0,left:0,...e}}function $c(e){return typeof e!="number"?Ip(e):{top:e,right:e,bottom:e,left:e}}function as(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function hi(e,t,n){let{reference:r,floating:o}=e;const a=tt(t),i=ra(t),c=na(i),u=gt(t),d=a==="y",h=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[c]/2-o[c]/2;let x;switch(u){case"top":x={x:h,y:r.y-o.height};break;case"bottom":x={x:h,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:f};break;case"left":x={x:r.x-o.width,y:f};break;default:x={x:r.x,y:r.y}}switch(Wn(t)){case"start":x[i]-=m*(n&&d?-1:1);break;case"end":x[i]+=m*(n&&d?-1:1);break}return x}async function Op(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:m=!1,padding:x=0}=xt(t,e),v=$c(x),g=c[m?f==="floating"?"reference":"floating":f],w=as(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))==null||n?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:h,strategy:u})),y=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),j=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},C=as(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:N,strategy:u}):y);return{top:(w.top-C.top+v.top)/j.y,bottom:(C.bottom-w.bottom+v.bottom)/j.y,left:(w.left-C.left+v.left)/j.x,right:(C.right-w.right+v.right)/j.x}}const Dp=50,zp=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Op},u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:h,y:f}=hi(d,r,u),m=r,x=0;const v={};for(let p=0;p<a.length;p++){const g=a[p];if(!g)continue;const{name:w,fn:y}=g,{x:N,y:j,data:C,reset:E}=await y({x:h,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:v,rects:d,platform:c,elements:{reference:e,floating:t}});h=N??h,f=j??f,v[w]={...v[w],...C},E&&x<Dp&&(x++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(d=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:h,y:f}=hi(d,m,u)),p=-1)}return{x:h,y:f,placement:m,strategy:o,middlewareData:v}},Lp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:d,padding:h=0}=xt(e,t)||{};if(d==null)return{};const f=$c(h),m={x:n,y:r},x=ra(o),v=na(x),p=await i.getDimensions(d),g=x==="y",w=g?"top":"left",y=g?"bottom":"right",N=g?"clientHeight":"clientWidth",j=a.reference[v]+a.reference[x]-m[x]-a.floating[v],C=m[x]-a.reference[x],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let S=E?E[N]:0;(!S||!await(i.isElement==null?void 0:i.isElement(E)))&&(S=c.floating[N]||a.floating[v]);const P=j/2-C/2,D=S/2-p[v]/2-1,O=Dt(f[w],D),$=Dt(f[y],D),_=O,G=S-p[v]-$,U=S/2-p[v]/2+P,X=Po(_,U,G),V=!u.arrow&&Wn(o)!=null&&U!==X&&a.reference[v]/2-(U<_?O:$)-p[v]/2<0,te=V?U<_?U-_:U-G:0;return{[x]:m[x]+te,data:{[x]:X,centerOffset:U-X-te,...V&&{alignmentOffset:te}},reset:V}}}),Fp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:p=!0,...g}=xt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=gt(o),y=tt(c),N=gt(c)===c,j=await(u.isRTL==null?void 0:u.isRTL(d.floating)),C=m||(N||!p?[os(c)]:kp(c)),E=v!=="none";!m&&E&&C.push(..._p(c,p,v,j));const S=[c,...C],P=await u.detectOverflow(t,g),D=[];let O=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&D.push(P[w]),f){const U=Pp(o,i,j);D.push(P[U[0]],P[U[1]])}if(O=[...O,{placement:o,overflows:D}],!D.every(U=>U<=0)){var $,_;const U=((($=a.flip)==null?void 0:$.index)||0)+1,X=S[U];if(X&&(!(f==="alignment"?y!==tt(X):!1)||O.every(L=>tt(L.placement)===y?L.overflows[0]>0:!0)))return{data:{index:U,overflows:O},reset:{placement:X}};let V=(_=O.filter(te=>te.overflows[0]<=0).sort((te,L)=>te.overflows[1]-L.overflows[1])[0])==null?void 0:_.placement;if(!V)switch(x){case"bestFit":{var G;const te=(G=O.filter(L=>{if(E){const T=tt(L.placement);return T===y||T==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(T=>T>0).reduce((T,ae)=>T+ae,0)]).sort((L,T)=>L[1]-T[1])[0])==null?void 0:G[0];te&&(V=te);break}case"initialPlacement":V=c;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function mi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pi(e){return Ep.some(t=>e[t]>=0)}const $p=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...a}=xt(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),c=mi(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:pi(c)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),c=mi(i,n.floating);return{data:{escapedOffsets:c,escaped:pi(c)}}}default:return{}}}}},Uc=new Set(["left","top"]);async function Up(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=gt(n),c=Wn(n),u=tt(n)==="y",d=Uc.has(i)?-1:1,h=a&&u?-1:1,f=xt(t,e);let{mainAxis:m,crossAxis:x,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof v=="number"&&(x=c==="end"?v*-1:v),u?{x:x*h,y:m*d}:{x:m*d,y:x*h}}const Vp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:c}=t,u=await Up(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:i}}}}},Bp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:a}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:u={fn:w=>{let{x:y,y:N}=w;return{x:y,y:N}}},...d}=xt(e,t),h={x:n,y:r},f=await a.detectOverflow(t,d),m=tt(gt(o)),x=ta(m);let v=h[x],p=h[m];if(i){const w=x==="y"?"top":"left",y=x==="y"?"bottom":"right",N=v+f[w],j=v-f[y];v=Po(N,v,j)}if(c){const w=m==="y"?"top":"left",y=m==="y"?"bottom":"right",N=p+f[w],j=p-f[y];p=Po(N,p,j)}const g=u.fn({...t,[x]:v,[m]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[x]:i,[m]:c}}}}}},Kp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:u=!0,crossAxis:d=!0}=xt(e,t),h={x:n,y:r},f=tt(o),m=ta(f);let x=h[m],v=h[f];const p=xt(c,t),g=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const N=m==="y"?"height":"width",j=a.reference[m]-a.floating[N]+g.mainAxis,C=a.reference[m]+a.reference[N]-g.mainAxis;x<j?x=j:x>C&&(x=C)}if(d){var w,y;const N=m==="y"?"width":"height",j=Uc.has(gt(o)),C=a.reference[f]-a.floating[N]+(j&&((w=i.offset)==null?void 0:w[f])||0)+(j?0:g.crossAxis),E=a.reference[f]+a.reference[N]+(j?0:((y=i.offset)==null?void 0:y[f])||0)-(j?g.crossAxis:0);v<C?v=C:v>E&&(v=E)}return{[m]:x,[f]:v}}}},Hp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:u=()=>{},...d}=xt(e,t),h=await i.detectOverflow(t,d),f=gt(o),m=Wn(o),x=tt(o)==="y",{width:v,height:p}=a.floating;let g,w;f==="top"||f==="bottom"?(g=f,w=m===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(w=f,g=m==="end"?"top":"bottom");const y=p-h.top-h.bottom,N=v-h.left-h.right,j=Dt(p-h[g],y),C=Dt(v-h[w],N),E=!t.middlewareData.shift;let S=j,P=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=N),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=y),E&&!m){const O=Oe(h.left,0),$=Oe(h.right,0),_=Oe(h.top,0),G=Oe(h.bottom,0);x?P=v-2*(O!==0||$!==0?O+$:Oe(h.left,h.right)):S=p-2*(_!==0||G!==0?_+G:Oe(h.top,h.bottom))}await u({...t,availableWidth:P,availableHeight:S});const D=await i.getDimensions(c.floating);return v!==D.width||p!==D.height?{reset:{rects:!0}}:{}}}};function vs(){return typeof window<"u"}function Gn(e){return Vc(e)?(e.nodeName||"").toLowerCase():"#document"}function ze(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function at(e){var t;return(t=(Vc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Vc(e){return vs()?e instanceof Node||e instanceof ze(e).Node:!1}function qe(e){return vs()?e instanceof Element||e instanceof ze(e).Element:!1}function yt(e){return vs()?e instanceof HTMLElement||e instanceof ze(e).HTMLElement:!1}function xi(e){return!vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ze(e).ShadowRoot}function Rr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=We(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function qp(e){return/^(table|td|th)$/.test(Gn(e))}function ys(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Wp=/transform|translate|scale|rotate|perspective|filter/,Gp=/paint|layout|strict|content/,Kt=e=>!!e&&e!=="none";let Gs;function sa(e){const t=qe(e)?We(e):e;return Kt(t.transform)||Kt(t.translate)||Kt(t.scale)||Kt(t.rotate)||Kt(t.perspective)||!oa()&&(Kt(t.backdropFilter)||Kt(t.filter))||Wp.test(t.willChange||"")||Gp.test(t.contain||"")}function Qp(e){let t=zt(e);for(;yt(t)&&!Ln(t);){if(sa(t))return t;if(ys(t))return null;t=zt(t)}return null}function oa(){return Gs==null&&(Gs=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gs}function Ln(e){return/^(html|body|#document)$/.test(Gn(e))}function We(e){return ze(e).getComputedStyle(e)}function bs(e){return qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function zt(e){if(Gn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xi(e)&&e.host||at(e);return xi(t)?t.host:t}function Bc(e){const t=zt(e);return Ln(t)?e.ownerDocument?e.ownerDocument.body:e.body:yt(t)&&Rr(t)?t:Bc(t)}function mr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Bc(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=ze(o);if(a){const c=To(i);return t.concat(i,i.visualViewport||[],Rr(o)?o:[],c&&n?mr(c):[])}else return t.concat(o,mr(o,[],n))}function To(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Kc(e){const t=We(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yt(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=ss(n)!==a||ss(r)!==i;return c&&(n=a,r=i),{width:n,height:r,$:c}}function aa(e){return qe(e)?e:e.contextElement}function jn(e){const t=aa(e);if(!yt(t))return nt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Kc(t);let i=(a?ss(n.width):n.width)/r,c=(a?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Yp=nt(0);function Hc(e){const t=ze(e);return!oa()||!t.visualViewport?Yp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ze(e)?!1:t}function dn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=aa(e);let i=nt(1);t&&(r?qe(r)&&(i=jn(r)):i=jn(e));const c=Xp(a,n,r)?Hc(a):nt(0);let u=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,h=o.width/i.x,f=o.height/i.y;if(a){const m=ze(a),x=r&&qe(r)?ze(r):r;let v=m,p=To(v);for(;p&&r&&x!==v;){const g=jn(p),w=p.getBoundingClientRect(),y=We(p),N=w.left+(p.clientLeft+parseFloat(y.paddingLeft))*g.x,j=w.top+(p.clientTop+parseFloat(y.paddingTop))*g.y;u*=g.x,d*=g.y,h*=g.x,f*=g.y,u+=N,d+=j,v=ze(p),p=To(v)}}return as({width:h,height:f,x:u,y:d})}function ws(e,t){const n=bs(e).scrollLeft;return t?t.left+n:dn(at(e)).left+n}function qc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ws(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Zp(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=at(r),c=t?ys(t.floating):!1;if(r===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=nt(1);const h=nt(0),f=yt(r);if((f||!f&&!a)&&((Gn(r)!=="body"||Rr(i))&&(u=bs(r)),f)){const x=dn(r);d=jn(r),h.x=x.x+r.clientLeft,h.y=x.y+r.clientTop}const m=i&&!f&&!a?qc(i,u):nt(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+m.x,y:n.y*d.y-u.scrollTop*d.y+h.y+m.y}}function Jp(e){return Array.from(e.getClientRects())}function ex(e){const t=at(e),n=bs(e),r=e.ownerDocument.body,o=Oe(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Oe(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ws(e);const c=-n.scrollTop;return We(r).direction==="rtl"&&(i+=Oe(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:c}}const gi=25;function tx(e,t){const n=ze(e),r=at(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,c=0,u=0;if(o){a=o.width,i=o.height;const h=oa();(!h||h&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const d=ws(r);if(d<=0){const h=r.ownerDocument,f=h.body,m=getComputedStyle(f),x=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-x);v<=gi&&(a-=v)}else d<=gi&&(a+=d);return{width:a,height:i,x:c,y:u}}function nx(e,t){const n=dn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=yt(e)?jn(e):nt(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=o*a.x,d=r*a.y;return{width:i,height:c,x:u,y:d}}function vi(e,t,n){let r;if(t==="viewport")r=tx(e,n);else if(t==="document")r=ex(at(e));else if(qe(t))r=nx(t,n);else{const o=Hc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return as(r)}function Wc(e,t){const n=zt(e);return n===t||!qe(n)||Ln(n)?!1:We(n).position==="fixed"||Wc(n,t)}function rx(e,t){const n=t.get(e);if(n)return n;let r=mr(e,[],!1).filter(c=>qe(c)&&Gn(c)!=="body"),o=null;const a=We(e).position==="fixed";let i=a?zt(e):e;for(;qe(i)&&!Ln(i);){const c=We(i),u=sa(i);!u&&c.position==="fixed"&&(o=null),(a?!u&&!o:!u&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Rr(i)&&!u&&Wc(e,i))?r=r.filter(h=>h!==i):o=c,i=zt(i)}return t.set(e,r),r}function sx(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ys(t)?[]:rx(t,this._c):[].concat(n),r],c=vi(t,i[0],o);let u=c.top,d=c.right,h=c.bottom,f=c.left;for(let m=1;m<i.length;m++){const x=vi(t,i[m],o);u=Oe(x.top,u),d=Dt(x.right,d),h=Dt(x.bottom,h),f=Oe(x.left,f)}return{width:d-f,height:h-u,x:f,y:u}}function ox(e){const{width:t,height:n}=Kc(e);return{width:t,height:n}}function ax(e,t,n){const r=yt(t),o=at(t),a=n==="fixed",i=dn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=nt(0);function d(){u.x=ws(o)}if(r||!r&&!a)if((Gn(t)!=="body"||Rr(o))&&(c=bs(t)),r){const x=dn(t,!0,a,t);u.x=x.x+t.clientLeft,u.y=x.y+t.clientTop}else o&&d();a&&!r&&o&&d();const h=o&&!r&&!a?qc(o,c):nt(0),f=i.left+c.scrollLeft-u.x-h.x,m=i.top+c.scrollTop-u.y-h.y;return{x:f,y:m,width:i.width,height:i.height}}function Qs(e){return We(e).position==="static"}function yi(e,t){if(!yt(e)||We(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return at(e)===n&&(n=n.ownerDocument.body),n}function Gc(e,t){const n=ze(e);if(ys(e))return n;if(!yt(e)){let o=zt(e);for(;o&&!Ln(o);){if(qe(o)&&!Qs(o))return o;o=zt(o)}return n}let r=yi(e,t);for(;r&&qp(r)&&Qs(r);)r=yi(r,t);return r&&Ln(r)&&Qs(r)&&!sa(r)?n:r||Qp(e)||n}const ix=async function(e){const t=this.getOffsetParent||Gc,n=this.getDimensions,r=await n(e.floating);return{reference:ax(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cx(e){return We(e).direction==="rtl"}const lx={convertOffsetParentRelativeRectToViewportRelativeRect:Zp,getDocumentElement:at,getClippingRect:sx,getOffsetParent:Gc,getElementRects:ix,getClientRects:Jp,getDimensions:ox,getScale:jn,isElement:qe,isRTL:cx};function Qc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dx(e,t){let n=null,r;const o=at(e);function a(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const d=e.getBoundingClientRect(),{left:h,top:f,width:m,height:x}=d;if(c||t(),!m||!x)return;const v=Lr(f),p=Lr(o.clientWidth-(h+m)),g=Lr(o.clientHeight-(f+x)),w=Lr(h),N={rootMargin:-v+"px "+-p+"px "+-g+"px "+-w+"px",threshold:Oe(0,Dt(1,u))||1};let j=!0;function C(E){const S=E[0].intersectionRatio;if(S!==u){if(!j)return i();S?i(!1,S):r=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!Qc(d,e.getBoundingClientRect())&&i(),j=!1}try{n=new IntersectionObserver(C,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,N)}n.observe(e)}return i(!0),a}function ux(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=aa(e),h=o||a?[...d?mr(d):[],...t?mr(t):[]]:[];h.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const f=d&&c?dx(d,n):null;let m=-1,x=null;i&&(x=new ResizeObserver(w=>{let[y]=w;y&&y.target===d&&x&&t&&(x.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),d&&!u&&x.observe(d),t&&x.observe(t));let v,p=u?dn(e):null;u&&g();function g(){const w=dn(e);p&&!Qc(p,w)&&n(),p=w,v=requestAnimationFrame(g)}return n(),()=>{var w;h.forEach(y=>{o&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),f==null||f(),(w=x)==null||w.disconnect(),x=null,u&&cancelAnimationFrame(v)}}const fx=Vp,hx=Bp,mx=Fp,px=Hp,xx=$p,bi=Lp,gx=Kp,vx=(e,t,n)=>{const r=new Map,o={platform:lx,...n},a={...o.platform,_c:r};return zp(e,t,{...o,platform:a})};var yx=typeof document<"u",bx=function(){},Wr=yx?l.useLayoutEffect:bx;function is(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!is(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!is(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Yc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wi(e,t){const n=Yc(e);return Math.round(t*n)/n}function Ys(e){const t=l.useRef(e);return Wr(()=>{t.current=e}),t}function wx(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:u,open:d}=e,[h,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,x]=l.useState(r);is(m,r)||x(r);const[v,p]=l.useState(null),[g,w]=l.useState(null),y=l.useCallback(L=>{L!==E.current&&(E.current=L,p(L))},[]),N=l.useCallback(L=>{L!==S.current&&(S.current=L,w(L))},[]),j=a||v,C=i||g,E=l.useRef(null),S=l.useRef(null),P=l.useRef(h),D=u!=null,O=Ys(u),$=Ys(o),_=Ys(d),G=l.useCallback(()=>{if(!E.current||!S.current)return;const L={placement:t,strategy:n,middleware:m};$.current&&(L.platform=$.current),vx(E.current,S.current,L).then(T=>{const ae={...T,isPositioned:_.current!==!1};U.current&&!is(P.current,ae)&&(P.current=ae,Cr.flushSync(()=>{f(ae)}))})},[m,t,n,$,_]);Wr(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[d]);const U=l.useRef(!1);Wr(()=>(U.current=!0,()=>{U.current=!1}),[]),Wr(()=>{if(j&&(E.current=j),C&&(S.current=C),j&&C){if(O.current)return O.current(j,C,G);G()}},[j,C,G,O,D]);const X=l.useMemo(()=>({reference:E,floating:S,setReference:y,setFloating:N}),[y,N]),V=l.useMemo(()=>({reference:j,floating:C}),[j,C]),te=l.useMemo(()=>{const L={position:n,left:0,top:0};if(!V.floating)return L;const T=wi(V.floating,h.x),ae=wi(V.floating,h.y);return c?{...L,transform:"translate("+T+"px, "+ae+"px)",...Yc(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:ae}},[n,c,V.floating,h.x,h.y]);return l.useMemo(()=>({...h,update:G,refs:X,elements:V,floatingStyles:te}),[h,G,X,V,te])}const Nx=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?bi({element:r.current,padding:o}).fn(n):{}:r?bi({element:r,padding:o}).fn(n):{}}}},jx=(e,t)=>{const n=fx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cx=(e,t)=>{const n=hx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sx=(e,t)=>({fn:gx(e).fn,options:[e,t]}),Ex=(e,t)=>{const n=mx(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rx=(e,t)=>{const n=px(e);return{name:n.name,fn:n.fn,options:[e,t]}},Px=(e,t)=>{const n=xx(e);return{name:n.name,fn:n.fn,options:[e,t]}},kx=(e,t)=>{const n=Nx(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Tx="Arrow",Xc=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return s.jsx(W.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Xc.displayName=Tx;var Ax=Xc;function Zc(e){const[t,n]=l.useState(void 0);return Ce(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;i=d.inlineSize,c=d.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ia="Popper",[Jc,Qn]=ot(ia),[Mx,el]=Jc(ia),tl=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return s.jsx(Mx,{scope:t,anchor:r,onAnchorChange:o,children:n})};tl.displayName=ia;var nl="PopperAnchor",rl=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=el(nl,n),i=l.useRef(null),c=ce(t,i),u=l.useRef(null);return l.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||i.current,d!==u.current&&a.onAnchorChange(u.current)}),r?null:s.jsx(W.div,{...o,ref:c})});rl.displayName=nl;var ca="PopperContent",[_x,Ix]=Jc(ca),sl=l.forwardRef((e,t)=>{var A,Q,Y,oe,ue,fe;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:x="optimized",onPlaced:v,...p}=e,g=el(ca,n),[w,y]=l.useState(null),N=ce(t,Me=>y(Me)),[j,C]=l.useState(null),E=Zc(j),S=(E==null?void 0:E.width)??0,P=(E==null?void 0:E.height)??0,D=r+(a!=="center"?"-"+a:""),O=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(d)?d:[d],_=$.length>0,G={padding:O,boundary:$.filter(Dx),altBoundary:_},{refs:U,floatingStyles:X,placement:V,isPositioned:te,middlewareData:L}=wx({strategy:"fixed",placement:D,whileElementsMounted:(...Me)=>ux(...Me,{animationFrame:x==="always"}),elements:{reference:g.anchor},middleware:[jx({mainAxis:o+P,alignmentAxis:i}),u&&Cx({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Sx():void 0,...G}),u&&Ex({...G}),Rx({...G,apply:({elements:Me,rects:Ye,availableWidth:tr,availableHeight:nr})=>{const{width:rr,height:kf}=Ye.reference,Or=Me.floating.style;Or.setProperty("--radix-popper-available-width",`${tr}px`),Or.setProperty("--radix-popper-available-height",`${nr}px`),Or.setProperty("--radix-popper-anchor-width",`${rr}px`),Or.setProperty("--radix-popper-anchor-height",`${kf}px`)}}),j&&kx({element:j,padding:c}),zx({arrowWidth:S,arrowHeight:P}),m&&Px({strategy:"referenceHidden",...G})]}),[T,ae]=il(V),ie=st(v);Ce(()=>{te&&(ie==null||ie())},[te,ie]);const R=(A=L.arrow)==null?void 0:A.x,B=(Q=L.arrow)==null?void 0:Q.y,K=((Y=L.arrow)==null?void 0:Y.centerOffset)!==0,[z,Z]=l.useState();return Ce(()=>{w&&Z(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:te?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[(oe=L.transformOrigin)==null?void 0:oe.x,(ue=L.transformOrigin)==null?void 0:ue.y].join(" "),...((fe=L.hide)==null?void 0:fe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(_x,{scope:n,placedSide:T,onArrowChange:C,arrowX:R,arrowY:B,shouldHideArrow:K,children:s.jsx(W.div,{"data-side":T,"data-align":ae,...p,ref:N,style:{...p.style,animation:te?void 0:"none"}})})})});sl.displayName=ca;var ol="PopperArrow",Ox={top:"bottom",right:"left",bottom:"top",left:"right"},al=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=Ix(ol,r),i=Ox[a.placedSide];return s.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:s.jsx(Ax,{...o,ref:n,style:{...o.style,display:"block"}})})});al.displayName=ol;function Dx(e){return e!==null}var zx=e=>({name:"transformOrigin",options:e,fn(t){var g,w,y;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,c=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[d,h]=il(n),f={start:"0%",center:"50%",end:"100%"}[h],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,x=(((y=o.arrow)==null?void 0:y.y)??0)+u/2;let v="",p="";return d==="bottom"?(v=i?f:`${m}px`,p=`${-u}px`):d==="top"?(v=i?f:`${m}px`,p=`${r.floating.height+u}px`):d==="right"?(v=`${-u}px`,p=i?f:`${x}px`):d==="left"&&(v=`${r.floating.width+u}px`,p=i?f:`${x}px`),{data:{x:v,y:p}}}});function il(e){const[t,n="center"]=e.split("-");return[t,n]}var la=tl,Ns=rl,da=sl,ua=al,Lx="Portal",Pr=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,a]=l.useState(!1);Ce(()=>a(!0),[]);const i=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return i?Mf.createPortal(s.jsx(W.div,{...r,ref:t}),i):null});Pr.displayName=Lx;function Fx(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Ve=e=>{const{present:t,children:n}=e,r=$x(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),a=ce(r.ref,Ux(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:a}):null};Ve.displayName="Presence";function $x(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=e?"mounted":"unmounted",[c,u]=Fx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const d=Fr(r.current);a.current=c==="mounted"?d:"none"},[c]),Ce(()=>{const d=r.current,h=o.current;if(h!==e){const m=a.current,x=Fr(d);e?u("MOUNT"):x==="none"||(d==null?void 0:d.display)==="none"?u("UNMOUNT"):u(h&&m!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ce(()=>{if(t){let d;const h=t.ownerDocument.defaultView??window,f=x=>{const p=Fr(r.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(u("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",d=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},m=x=>{x.target===t&&(a.current=Fr(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{h.clearTimeout(d),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function Fr(e){return(e==null?void 0:e.animationName)||"none"}function Ux(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Vx=Ko[" useInsertionEffect ".trim().toString()]||Ce;function Lt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=Bx({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:o;{const h=l.useRef(e!==void 0);l.useEffect(()=>{const f=h.current;f!==c&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=c},[c,r])}const d=l.useCallback(h=>{var f;if(c){const m=Kx(h)?h(e):h;m!==e&&((f=i.current)==null||f.call(i,m))}else a(h)},[c,e,a,i]);return[u,d]}function Bx({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),a=l.useRef(t);return Vx(()=>{a.current=t},[t]),l.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,r,a]}function Kx(e){return typeof e=="function"}var Hx=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gn=new WeakMap,$r=new WeakMap,Ur={},Xs=0,cl=function(e){return e&&(e.host||cl(e.parentNode))},qx=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=cl(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Wx=function(e,t,n,r){var o=qx(t,Array.isArray(e)?e:[e]);Ur[n]||(Ur[n]=new WeakMap);var a=Ur[n],i=[],c=new Set,u=new Set(o),d=function(f){!f||c.has(f)||(c.add(f),d(f.parentNode))};o.forEach(d);var h=function(f){!f||u.has(f)||Array.prototype.forEach.call(f.children,function(m){if(c.has(m))h(m);else try{var x=m.getAttribute(r),v=x!==null&&x!=="false",p=(gn.get(m)||0)+1,g=(a.get(m)||0)+1;gn.set(m,p),a.set(m,g),i.push(m),p===1&&v&&$r.set(m,!0),g===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return h(t),c.clear(),Xs++,function(){i.forEach(function(f){var m=gn.get(f)-1,x=a.get(f)-1;gn.set(f,m),a.set(f,x),m||($r.has(f)||f.removeAttribute(r),$r.delete(f)),x||f.removeAttribute(n)}),Xs--,Xs||(gn=new WeakMap,gn=new WeakMap,$r=new WeakMap,Ur={})}},js=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Hx(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Wx(r,o,n,"aria-hidden")):function(){return null}},et=function(){return et=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},et.apply(this,arguments)};function ll(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Gx(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Gr="right-scroll-bar-position",Qr="width-before-scroll-bar",Qx="with-scroll-bars-hidden",Yx="--removed-body-scroll-bar-size";function Zs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Xx(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Zx=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ni=new WeakMap;function Jx(e,t){var n=Xx(null,function(r){return e.forEach(function(o){return Zs(o,r)})});return Zx(function(){var r=Ni.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||Zs(c,null)}),a.forEach(function(c){o.has(c)||Zs(c,i)})}Ni.set(n,e)},[e]),n}function eg(e){return e}function tg(e,t){t===void 0&&(t=eg);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var u=function(){var h=i;i=[],h.forEach(a)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(h){i.push(h),d()},filter:function(h){return i=i.filter(h),n}}}};return o}function ng(e){e===void 0&&(e={});var t=tg(null);return t.options=et({async:!0,ssr:!1},e),t}var dl=function(e){var t=e.sideCar,n=ll(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,et({},n))};dl.isSideCarExport=!0;function rg(e,t){return e.useMedium(t),dl}var ul=ng(),Js=function(){},Cs=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Js,onWheelCapture:Js,onTouchMoveCapture:Js}),o=r[0],a=r[1],i=e.forwardProps,c=e.children,u=e.className,d=e.removeScrollBar,h=e.enabled,f=e.shards,m=e.sideCar,x=e.noRelative,v=e.noIsolation,p=e.inert,g=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,N=e.gapMode,j=ll(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,E=Jx([n,t]),S=et(et({},j),o);return l.createElement(l.Fragment,null,h&&l.createElement(C,{sideCar:ul,removeScrollBar:d,shards:f,noRelative:x,noIsolation:v,inert:p,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:N}),i?l.cloneElement(l.Children.only(c),et(et({},S),{ref:E})):l.createElement(y,et({},S,{className:u,ref:E}),c))});Cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cs.classNames={fullWidth:Qr,zeroRight:Gr};var sg=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function og(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=sg();return t&&e.setAttribute("nonce",t),e}function ag(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ig(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var cg=function(){var e=0,t=null;return{add:function(n){e==0&&(t=og())&&(ag(t,n),ig(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lg=function(){var e=cg();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},fl=function(){var e=lg(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},dg={left:0,top:0,right:0,gap:0},eo=function(e){return parseInt(e||"",10)||0},ug=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[eo(n),eo(r),eo(o)]},fg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return dg;var t=ug(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},hg=fl(),Cn="data-scroll-locked",mg=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
255
|
+
.`.concat(Qx,` {
|
|
256
|
+
overflow: hidden `).concat(r,`;
|
|
257
|
+
padding-right: `).concat(c,"px ").concat(r,`;
|
|
258
|
+
}
|
|
259
|
+
body[`).concat(Cn,`] {
|
|
260
|
+
overflow: hidden `).concat(r,`;
|
|
261
|
+
overscroll-behavior: contain;
|
|
262
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
263
|
+
padding-left: `.concat(o,`px;
|
|
264
|
+
padding-top: `).concat(a,`px;
|
|
265
|
+
padding-right: `).concat(i,`px;
|
|
266
|
+
margin-left:0;
|
|
267
|
+
margin-top:0;
|
|
268
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
269
|
+
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.`).concat(Gr,` {
|
|
273
|
+
right: `).concat(c,"px ").concat(r,`;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.`).concat(Qr,` {
|
|
277
|
+
margin-right: `).concat(c,"px ").concat(r,`;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.`).concat(Gr," .").concat(Gr,` {
|
|
281
|
+
right: 0 `).concat(r,`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.`).concat(Qr," .").concat(Qr,` {
|
|
285
|
+
margin-right: 0 `).concat(r,`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
body[`).concat(Cn,`] {
|
|
289
|
+
`).concat(Yx,": ").concat(c,`px;
|
|
290
|
+
}
|
|
291
|
+
`)},ji=function(){var e=parseInt(document.body.getAttribute(Cn)||"0",10);return isFinite(e)?e:0},pg=function(){l.useEffect(function(){return document.body.setAttribute(Cn,(ji()+1).toString()),function(){var e=ji()-1;e<=0?document.body.removeAttribute(Cn):document.body.setAttribute(Cn,e.toString())}},[])},xg=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;pg();var a=l.useMemo(function(){return fg(o)},[o]);return l.createElement(hg,{styles:mg(a,!t,o,n?"":"!important")})},Ao=!1;if(typeof window<"u")try{var Vr=Object.defineProperty({},"passive",{get:function(){return Ao=!0,!0}});window.addEventListener("test",Vr,Vr),window.removeEventListener("test",Vr,Vr)}catch{Ao=!1}var vn=Ao?{passive:!1}:!1,gg=function(e){return e.tagName==="TEXTAREA"},hl=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!gg(e)&&n[t]==="visible")},vg=function(e){return hl(e,"overflowY")},yg=function(e){return hl(e,"overflowX")},Ci=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ml(e,r);if(o){var a=pl(e,r),i=a[1],c=a[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},bg=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},wg=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ml=function(e,t){return e==="v"?vg(t):yg(t)},pl=function(e,t){return e==="v"?bg(t):wg(t)},Ng=function(e,t){return e==="h"&&t==="rtl"?-1:1},jg=function(e,t,n,r,o){var a=Ng(e,window.getComputedStyle(t).direction),i=a*r,c=n.target,u=t.contains(c),d=!1,h=i>0,f=0,m=0;do{if(!c)break;var x=pl(e,c),v=x[0],p=x[1],g=x[2],w=p-g-a*v;(v||w)&&ml(e,c)&&(f+=w,m+=v);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(h&&Math.abs(f)<1||!h&&Math.abs(m)<1)&&(d=!0),d},Br=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Si=function(e){return[e.deltaX,e.deltaY]},Ei=function(e){return e&&"current"in e?e.current:e},Cg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Sg=function(e){return`
|
|
292
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
293
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
294
|
+
`)},Eg=0,yn=[];function Rg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(Eg++)[0],a=l.useState(fl)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Gx([e.lockRef.current],(e.shards||[]).map(Ei),!0).filter(Boolean);return p.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(p,g){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!i.current.allowPinchZoom;var w=Br(p),y=n.current,N="deltaX"in p?p.deltaX:y[0]-w[0],j="deltaY"in p?p.deltaY:y[1]-w[1],C,E=p.target,S=Math.abs(N)>Math.abs(j)?"h":"v";if("touches"in p&&S==="h"&&E.type==="range")return!1;var P=window.getSelection(),D=P&&P.anchorNode,O=D?D===E||D.contains(E):!1;if(O)return!1;var $=Ci(S,E);if(!$)return!0;if($?C=S:(C=S==="v"?"h":"v",$=Ci(S,E)),!$)return!1;if(!r.current&&"changedTouches"in p&&(N||j)&&(r.current=C),!C)return!0;var _=r.current||C;return jg(_,g,p,_==="h"?N:j)},[]),u=l.useCallback(function(p){var g=p;if(!(!yn.length||yn[yn.length-1]!==a)){var w="deltaY"in g?Si(g):Br(g),y=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Cg(C.delta,w)})[0];if(y&&y.should){g.cancelable&&g.preventDefault();return}if(!y){var N=(i.current.shards||[]).map(Ei).filter(Boolean).filter(function(C){return C.contains(g.target)}),j=N.length>0?c(g,N[0]):!i.current.noIsolation;j&&g.cancelable&&g.preventDefault()}}},[]),d=l.useCallback(function(p,g,w,y){var N={name:p,delta:g,target:w,should:y,shadowParent:Pg(w)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(j){return j!==N})},1)},[]),h=l.useCallback(function(p){n.current=Br(p),r.current=void 0},[]),f=l.useCallback(function(p){d(p.type,Si(p),p.target,c(p,e.lockRef.current))},[]),m=l.useCallback(function(p){d(p.type,Br(p),p.target,c(p,e.lockRef.current))},[]);l.useEffect(function(){return yn.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",u,vn),document.addEventListener("touchmove",u,vn),document.addEventListener("touchstart",h,vn),function(){yn=yn.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,vn),document.removeEventListener("touchmove",u,vn),document.removeEventListener("touchstart",h,vn)}},[]);var x=e.removeScrollBar,v=e.inert;return l.createElement(l.Fragment,null,v?l.createElement(a,{styles:Sg(o)}):null,x?l.createElement(xg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Pg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const kg=rg(ul,Rg);var kr=l.forwardRef(function(e,t){return l.createElement(Cs,et({},e,{ref:t,sideCar:kg}))});kr.classNames=Cs.classNames;var Ss="Popover",[xl]=ot(Ss,[Qn]),Tr=Qn(),[Tg,$t]=xl(Ss),gl=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!1}=e,c=Tr(t),u=l.useRef(null),[d,h]=l.useState(!1),[f,m]=Lt({prop:r,defaultProp:o??!1,onChange:a,caller:Ss});return s.jsx(la,{...c,children:s.jsx(Tg,{scope:t,contentId:we(),triggerRef:u,open:f,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(x=>!x),[m]),hasCustomAnchor:d,onCustomAnchorAdd:l.useCallback(()=>h(!0),[]),onCustomAnchorRemove:l.useCallback(()=>h(!1),[]),modal:i,children:n})})};gl.displayName=Ss;var vl="PopoverAnchor",Ag=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=$t(vl,n),a=Tr(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:c}=o;return l.useEffect(()=>(i(),()=>c()),[i,c]),s.jsx(Ns,{...a,...r,ref:t})});Ag.displayName=vl;var yl="PopoverTrigger",bl=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=$t(yl,n),a=Tr(n),i=ce(t,o.triggerRef),c=s.jsx(W.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Sl(o.open),...r,ref:i,onClick:I(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?c:s.jsx(Ns,{asChild:!0,...a,children:c})});bl.displayName=yl;var fa="PopoverPortal",[Mg,_g]=xl(fa,{forceMount:void 0}),wl=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,a=$t(fa,t);return s.jsx(Mg,{scope:t,forceMount:n,children:s.jsx(Ve,{present:n||a.open,children:s.jsx(Pr,{asChild:!0,container:o,children:r})})})};wl.displayName=fa;var Fn="PopoverContent",Nl=l.forwardRef((e,t)=>{const n=_g(Fn,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,a=$t(Fn,e.__scopePopover);return s.jsx(Ve,{present:r||a.open,children:a.modal?s.jsx(Og,{...o,ref:t}):s.jsx(Dg,{...o,ref:t})})});Nl.displayName=Fn;var Ig=ln("PopoverContent.RemoveScroll"),Og=l.forwardRef((e,t)=>{const n=$t(Fn,e.__scopePopover),r=l.useRef(null),o=ce(t,r),a=l.useRef(!1);return l.useEffect(()=>{const i=r.current;if(i)return js(i)},[]),s.jsx(kr,{as:Ig,allowPinchZoom:!0,children:s.jsx(jl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:I(e.onCloseAutoFocus,i=>{var c;i.preventDefault(),a.current||(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:I(e.onPointerDownOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;a.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:I(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),Dg=l.forwardRef((e,t)=>{const n=$t(Fn,e.__scopePopover),r=l.useRef(!1),o=l.useRef(!1);return s.jsx(jl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),jl=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:i,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...f}=e,m=$t(Fn,n),x=Tr(n);return gs(),s.jsx(Er,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>m.onOpenChange(!1),children:s.jsx(da,{"data-state":Sl(m.open),role:"dialog",id:m.contentId,...x,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Cl="PopoverClose",zg=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=$t(Cl,n);return s.jsx(W.button,{type:"button",...r,ref:t,onClick:I(e.onClick,()=>o.onOpenChange(!1))})});zg.displayName=Cl;var Lg="PopoverArrow",Fg=l.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Tr(n);return s.jsx(ua,{...o,...r,ref:t})});Fg.displayName=Lg;function Sl(e){return e?"open":"closed"}var $g=gl,Ug=bl,Vg=wl,El=Nl;const Bg=$g,Kg=Ug,Rl=l.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>s.jsx(Vg,{children:s.jsx(El,{ref:o,align:t,sideOffset:n,className:k("z-50 w-72 rounded-md border border-zinc-200 bg-white p-4 text-zinc-900 shadow-md outline-none","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),...r})}));Rl.displayName=El.displayName;const Ri=e=>{let t;const n=new Set,r=(d,h)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const m=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(x=>x(t,m))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d))},u=t=e(r,o,c);return c},Hg=e=>e?Ri(e):Ri,qg=e=>e;function Wg(e,t=qg){const n=He.useSyncExternalStore(e.subscribe,He.useCallback(()=>t(e.getState()),[e,t]),He.useCallback(()=>t(e.getInitialState()),[e,t]));return He.useDebugValue(n),n}const Pi=e=>{const t=Hg(e),n=r=>Wg(t,r);return Object.assign(n,t),n},ha=e=>e?Pi(e):Pi,Pl=ha(e=>({notifications:[],unreadCount:0,pushNotification:t=>{const n={...t,id:crypto.randomUUID(),at:new Date().toISOString(),read:!1};e(r=>({notifications:[n,...r.notifications].slice(0,50),unreadCount:r.unreadCount+1}))},markAllRead:()=>{e(t=>({notifications:t.notifications.map(n=>({...n,read:!0})),unreadCount:0}))},clearAll:()=>{e({notifications:[],unreadCount:0})}}));function Ut(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}function Gg(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function it(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),o=Math.floor(r/1e3),a=Math.floor(o/60),i=Math.floor(a/60),c=Math.floor(i/24);return o<30?"just now":o<60?`${o}s ago`:a<60?`${a}m ago`:i<24?`${i}h ago`:c===1?"yesterday":c<7?`${c} days ago`:c<30?`${Math.floor(c/7)}w ago`:Gg(e)}function Qg({type:e}){return e==="error"?s.jsx(Hh,{className:"h-4 w-4 text-red-500"}):e==="warning"?s.jsx(rs,{className:"h-4 w-4 text-amber-500"}):s.jsx(em,{className:"h-4 w-4 text-blue-500"})}function Yg(){const{notifications:e,unreadCount:t,markAllRead:n}=Pl(),r=e.slice(0,10);return s.jsxs(Bg,{children:[s.jsx(Kg,{asChild:!0,children:s.jsxs(pe,{variant:"ghost",size:"icon","aria-label":"Notifications",className:"relative text-zinc-500 hover:text-zinc-700",children:[s.jsx(Uh,{className:"h-4 w-4"}),t>0&&s.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",children:t>9?"9+":t})]})}),s.jsxs(Rl,{align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[s.jsx("span",{className:"text-sm font-semibold text-zinc-900",children:"Notifications"}),t>0&&s.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 font-medium",children:[s.jsx(Kn,{className:"h-3 w-3"}),"Mark all read"]})]}),s.jsx("div",{className:"max-h-80 overflow-y-auto",children:r.length===0?s.jsx("div",{className:"py-8 text-center text-sm text-zinc-400",children:"No notifications"}):r.map(o=>s.jsxs("div",{className:k("flex gap-3 border-b border-zinc-50 px-4 py-3 last:border-0",!o.read&&"bg-blue-50/30"),children:[s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(Qg,{type:o.type})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs font-medium text-zinc-900",children:o.title}),s.jsx("p",{className:"mt-0.5 text-xs text-zinc-500 line-clamp-2",children:o.message}),s.jsx("p",{className:"mt-1 text-[10px] text-zinc-400",children:it(o.at)})]}),!o.read&&s.jsx("div",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"})]},o.id))})]})]})}var ki=1,Xg=.9,Zg=.8,Jg=.17,to=.1,no=.999,ev=.9999,tv=.99,nv=/[\\\/_+.#"@\[\(\{&]/,rv=/[\\\/_+.#"@\[\(\{&]/g,sv=/[\s-]/,kl=/[\s-]/g;function Mo(e,t,n,r,o,a,i){if(a===t.length)return o===e.length?ki:tv;var c=`${o},${a}`;if(i[c]!==void 0)return i[c];for(var u=r.charAt(a),d=n.indexOf(u,o),h=0,f,m,x,v;d>=0;)f=Mo(e,t,n,r,d+1,a+1,i),f>h&&(d===o?f*=ki:nv.test(e.charAt(d-1))?(f*=Zg,x=e.slice(o,d-1).match(rv),x&&o>0&&(f*=Math.pow(no,x.length))):sv.test(e.charAt(d-1))?(f*=Xg,v=e.slice(o,d-1).match(kl),v&&o>0&&(f*=Math.pow(no,v.length))):(f*=Jg,o>0&&(f*=Math.pow(no,d-o))),e.charAt(d)!==t.charAt(a)&&(f*=ev)),(f<to&&n.charAt(d-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(d-1)!==r.charAt(a))&&(m=Mo(e,t,n,r,d+1,a+2,i),m*to>f&&(f=m*to)),f>h&&(h=f),d=n.indexOf(u,d+1);return i[c]=h,h}function Ti(e){return e.toLowerCase().replace(kl," ")}function ov(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Mo(e,t,Ti(e),Ti(t),0,0,{})}var Es="Dialog",[Tl]=ot(Es),[av,Qe]=Tl(Es),Al=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),u=l.useRef(null),[d,h]=Lt({prop:r,defaultProp:o??!1,onChange:a,caller:Es});return s.jsx(av,{scope:t,triggerRef:c,contentRef:u,contentId:we(),titleId:we(),descriptionId:we(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(f=>!f),[h]),modal:i,children:n})};Al.displayName=Es;var Ml="DialogTrigger",iv=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qe(Ml,n),a=ce(t,o.triggerRef);return s.jsx(W.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":xa(o.open),...r,ref:a,onClick:I(e.onClick,o.onOpenToggle)})});iv.displayName=Ml;var ma="DialogPortal",[cv,_l]=Tl(ma,{forceMount:void 0}),Il=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,a=Qe(ma,t);return s.jsx(cv,{scope:t,forceMount:n,children:l.Children.map(r,i=>s.jsx(Ve,{present:n||a.open,children:s.jsx(Pr,{asChild:!0,container:o,children:i})}))})};Il.displayName=ma;var cs="DialogOverlay",Ol=l.forwardRef((e,t)=>{const n=_l(cs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Qe(cs,e.__scopeDialog);return a.modal?s.jsx(Ve,{present:r||a.open,children:s.jsx(dv,{...o,ref:t})}):null});Ol.displayName=cs;var lv=ln("DialogOverlay.RemoveScroll"),dv=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qe(cs,n);return s.jsx(kr,{as:lv,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(W.div,{"data-state":xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),un="DialogContent",Dl=l.forwardRef((e,t)=>{const n=_l(un,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,a=Qe(un,e.__scopeDialog);return s.jsx(Ve,{present:r||a.open,children:a.modal?s.jsx(uv,{...o,ref:t}):s.jsx(fv,{...o,ref:t})})});Dl.displayName=un;var uv=l.forwardRef((e,t)=>{const n=Qe(un,e.__scopeDialog),r=l.useRef(null),o=ce(t,n.contentRef,r);return l.useEffect(()=>{const a=r.current;if(a)return js(a)},[]),s.jsx(zl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:I(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:I(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:I(e.onFocusOutside,a=>a.preventDefault())})}),fv=l.forwardRef((e,t)=>{const n=Qe(un,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return s.jsx(zl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),zl=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Qe(un,n),u=l.useRef(null),d=ce(t,u);return gs(),s.jsxs(s.Fragment,{children:[s.jsx(Er,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:s.jsx(Sr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":xa(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(hv,{titleId:c.titleId}),s.jsx(pv,{contentRef:u,descriptionId:c.descriptionId})]})]})}),pa="DialogTitle",Ll=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qe(pa,n);return s.jsx(W.h2,{id:o.titleId,...r,ref:t})});Ll.displayName=pa;var Fl="DialogDescription",$l=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qe(Fl,n);return s.jsx(W.p,{id:o.descriptionId,...r,ref:t})});$l.displayName=Fl;var Ul="DialogClose",Vl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qe(Ul,n);return s.jsx(W.button,{type:"button",...r,ref:t,onClick:I(e.onClick,()=>o.onOpenChange(!1))})});Vl.displayName=Ul;function xa(e){return e?"open":"closed"}var Bl="DialogTitleWarning",[SN,Kl]=tp(Bl,{contentName:un,titleName:pa,docsSlug:"dialog"}),hv=({titleId:e})=>{const t=Kl(Bl),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
295
|
+
|
|
296
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
297
|
+
|
|
298
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},mv="DialogDescriptionWarning",pv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kl(mv).contentName}}.`;return l.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},ga=Al,va=Il,Rs=Ol,Ps=Dl,ya=Ll,ba=$l,Hl=Vl,xv=Symbol.for("react.lazy"),ls=Ko[" use ".trim().toString()];function gv(e){return typeof e=="object"&&e!==null&&"then"in e}function ql(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===xv&&"_payload"in e&&gv(e._payload)}function vv(e){const t=yv(e),n=l.forwardRef((r,o)=>{let{children:a,...i}=r;ql(a)&&typeof ls=="function"&&(a=ls(a._payload));const c=l.Children.toArray(a),u=c.find(wv);if(u){const d=u.props.children,h=c.map(f=>f===u?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:f);return s.jsx(t,{...i,ref:o,children:l.isValidElement(d)?l.cloneElement(d,void 0,h):null})}return s.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function yv(e){const t=l.forwardRef((n,r)=>{let{children:o,...a}=n;if(ql(o)&&typeof ls=="function"&&(o=ls(o._payload)),l.isValidElement(o)){const i=jv(o),c=Nv(a,o.props);return o.type!==l.Fragment&&(c.ref=r?rt(r,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bv=Symbol("radix.slottable");function wv(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bv}function Nv(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...c)=>{const u=a(...c);return o(...c),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function jv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Cv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bt=Cv.reduce((e,t)=>{const n=vv(`Primitive.${t}`),r=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),ar='[cmdk-group=""]',ro='[cmdk-group-items=""]',Sv='[cmdk-group-heading=""]',Wl='[cmdk-item=""]',Ai=`${Wl}:not([aria-disabled="true"])`,_o="cmdk-item-select",bn="data-value",Ev=(e,t,n)=>ov(e,t,n),Gl=l.createContext(void 0),Ar=()=>l.useContext(Gl),Ql=l.createContext(void 0),wa=()=>l.useContext(Ql),Yl=l.createContext(void 0),Xl=l.forwardRef((e,t)=>{let n=wn(()=>{var R,B;return{search:"",value:(B=(R=e.value)!=null?R:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=wn(()=>new Set),o=wn(()=>new Map),a=wn(()=>new Map),i=wn(()=>new Set),c=Zl(e),{label:u,children:d,value:h,onValueChange:f,filter:m,shouldFilter:x,loop:v,disablePointerSelection:p=!1,vimBindings:g=!0,...w}=e,y=we(),N=we(),j=we(),C=l.useRef(null),E=zv();fn(()=>{if(h!==void 0){let R=h.trim();n.current.value=R,S.emit()}},[h]),fn(()=>{E(6,G)},[]);let S=l.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,B,K)=>{var z,Z,A,Q;if(!Object.is(n.current[R],B)){if(n.current[R]=B,R==="search")_(),O(),E(1,$);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(j);Y?Y.focus():(z=document.getElementById(y))==null||z.focus()}if(E(7,()=>{var Y;n.current.selectedItemId=(Y=U())==null?void 0:Y.id,S.emit()}),K||E(5,G),((Z=c.current)==null?void 0:Z.value)!==void 0){let Y=B??"";(Q=(A=c.current).onValueChange)==null||Q.call(A,Y);return}}S.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),P=l.useMemo(()=>({value:(R,B,K)=>{var z;B!==((z=a.current.get(R))==null?void 0:z.value)&&(a.current.set(R,{value:B,keywords:K}),n.current.filtered.items.set(R,D(B,K)),E(2,()=>{O(),S.emit()}))},item:(R,B)=>(r.current.add(R),B&&(o.current.has(B)?o.current.get(B).add(R):o.current.set(B,new Set([R]))),E(3,()=>{_(),O(),n.current.value||$(),S.emit()}),()=>{a.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let K=U();E(4,()=>{_(),(K==null?void 0:K.getAttribute("id"))===R&&$(),S.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{a.current.delete(R),o.current.delete(R)}),filter:()=>c.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:y,inputId:j,labelId:N,listInnerRef:C}),[]);function D(R,B){var K,z;let Z=(z=(K=c.current)==null?void 0:K.filter)!=null?z:Ev;return R?Z(R,n.current.search,B):0}function O(){if(!n.current.search||c.current.shouldFilter===!1)return;let R=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(z=>{let Z=o.current.get(z),A=0;Z.forEach(Q=>{let Y=R.get(Q);A=Math.max(Y,A)}),B.push([z,A])});let K=C.current;X().sort((z,Z)=>{var A,Q;let Y=z.getAttribute("id"),oe=Z.getAttribute("id");return((A=R.get(oe))!=null?A:0)-((Q=R.get(Y))!=null?Q:0)}).forEach(z=>{let Z=z.closest(ro);Z?Z.appendChild(z.parentElement===Z?z:z.closest(`${ro} > *`)):K.appendChild(z.parentElement===K?z:z.closest(`${ro} > *`))}),B.sort((z,Z)=>Z[1]-z[1]).forEach(z=>{var Z;let A=(Z=C.current)==null?void 0:Z.querySelector(`${ar}[${bn}="${encodeURIComponent(z[0])}"]`);A==null||A.parentElement.appendChild(A)})}function $(){let R=X().find(K=>K.getAttribute("aria-disabled")!=="true"),B=R==null?void 0:R.getAttribute(bn);S.setState("value",B||void 0)}function _(){var R,B,K,z;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Z=0;for(let A of r.current){let Q=(B=(R=a.current.get(A))==null?void 0:R.value)!=null?B:"",Y=(z=(K=a.current.get(A))==null?void 0:K.keywords)!=null?z:[],oe=D(Q,Y);n.current.filtered.items.set(A,oe),oe>0&&Z++}for(let[A,Q]of o.current)for(let Y of Q)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(A);break}n.current.filtered.count=Z}function G(){var R,B,K;let z=U();z&&(((R=z.parentElement)==null?void 0:R.firstChild)===z&&((K=(B=z.closest(ar))==null?void 0:B.querySelector(Sv))==null||K.scrollIntoView({block:"nearest"})),z.scrollIntoView({block:"nearest"}))}function U(){var R;return(R=C.current)==null?void 0:R.querySelector(`${Wl}[aria-selected="true"]`)}function X(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(Ai))||[])}function V(R){let B=X()[R];B&&S.setState("value",B.getAttribute(bn))}function te(R){var B;let K=U(),z=X(),Z=z.findIndex(Q=>Q===K),A=z[Z+R];(B=c.current)!=null&&B.loop&&(A=Z+R<0?z[z.length-1]:Z+R===z.length?z[0]:z[Z+R]),A&&S.setState("value",A.getAttribute(bn))}function L(R){let B=U(),K=B==null?void 0:B.closest(ar),z;for(;K&&!z;)K=R>0?Ov(K,ar):Dv(K,ar),z=K==null?void 0:K.querySelector(Ai);z?S.setState("value",z.getAttribute(bn)):te(R)}let T=()=>V(X().length-1),ae=R=>{R.preventDefault(),R.metaKey?T():R.altKey?L(1):te(1)},ie=R=>{R.preventDefault(),R.metaKey?V(0):R.altKey?L(-1):te(-1)};return l.createElement(bt.div,{ref:t,tabIndex:-1,...w,"cmdk-root":"",onKeyDown:R=>{var B;(B=w.onKeyDown)==null||B.call(w,R);let K=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||K))switch(R.key){case"n":case"j":{g&&R.ctrlKey&&ae(R);break}case"ArrowDown":{ae(R);break}case"p":case"k":{g&&R.ctrlKey&&ie(R);break}case"ArrowUp":{ie(R);break}case"Home":{R.preventDefault(),V(0);break}case"End":{R.preventDefault(),T();break}case"Enter":{R.preventDefault();let z=U();if(z){let Z=new Event(_o);z.dispatchEvent(Z)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:Fv},u),ks(e,R=>l.createElement(Ql.Provider,{value:S},l.createElement(Gl.Provider,{value:P},R))))}),Rv=l.forwardRef((e,t)=>{var n,r;let o=we(),a=l.useRef(null),i=l.useContext(Yl),c=Ar(),u=Zl(e),d=(r=(n=u.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;fn(()=>{if(!d)return c.item(o,i==null?void 0:i.id)},[d]);let h=Jl(o,a,[e.value,e.children,a],e.keywords),f=wa(),m=Ft(E=>E.value&&E.value===h.current),x=Ft(E=>d||c.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);l.useEffect(()=>{let E=a.current;if(!(!E||e.disabled))return E.addEventListener(_o,v),()=>E.removeEventListener(_o,v)},[x,e.onSelect,e.disabled]);function v(){var E,S;p(),(S=(E=u.current).onSelect)==null||S.call(E,h.current)}function p(){f.setState("value",h.current,!0)}if(!x)return null;let{disabled:g,value:w,onSelect:y,forceMount:N,keywords:j,...C}=e;return l.createElement(bt.div,{ref:rt(a,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!m,"data-disabled":!!g,"data-selected":!!m,onPointerMove:g||c.getDisablePointerSelection()?void 0:p,onClick:g?void 0:v},e.children)}),Pv=l.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...a}=e,i=we(),c=l.useRef(null),u=l.useRef(null),d=we(),h=Ar(),f=Ft(x=>o||h.filter()===!1?!0:x.search?x.filtered.groups.has(i):!0);fn(()=>h.group(i),[]),Jl(i,c,[e.value,e.heading,u]);let m=l.useMemo(()=>({id:i,forceMount:o}),[o]);return l.createElement(bt.div,{ref:rt(c,t),...a,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&l.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),ks(e,x=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},l.createElement(Yl.Provider,{value:m},x))))}),kv=l.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=l.useRef(null),a=Ft(i=>!i.search);return!n&&!a?null:l.createElement(bt.div,{ref:rt(o,t),...r,"cmdk-separator":"",role:"separator"})}),Tv=l.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,a=wa(),i=Ft(d=>d.search),c=Ft(d=>d.selectedItemId),u=Ar();return l.useEffect(()=>{e.value!=null&&a.setState("search",e.value)},[e.value]),l.createElement(bt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":c,id:u.inputId,type:"text",value:o?e.value:i,onChange:d=>{o||a.setState("search",d.target.value),n==null||n(d.target.value)}})}),Av=l.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,a=l.useRef(null),i=l.useRef(null),c=Ft(d=>d.selectedItemId),u=Ar();return l.useEffect(()=>{if(i.current&&a.current){let d=i.current,h=a.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let x=d.offsetHeight;h.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return m.observe(d),()=>{cancelAnimationFrame(f),m.unobserve(d)}}},[]),l.createElement(bt.div,{ref:rt(a,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:u.listId},ks(e,d=>l.createElement("div",{ref:rt(i,u.listInnerRef),"cmdk-list-sizer":""},d)))}),Mv=l.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:a,container:i,...c}=e;return l.createElement(ga,{open:n,onOpenChange:r},l.createElement(va,{container:i},l.createElement(Rs,{"cmdk-overlay":"",className:o}),l.createElement(Ps,{"aria-label":e.label,"cmdk-dialog":"",className:a},l.createElement(Xl,{ref:t,...c}))))}),_v=l.forwardRef((e,t)=>Ft(n=>n.filtered.count===0)?l.createElement(bt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Iv=l.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...a}=e;return l.createElement(bt.div,{ref:t,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ks(e,i=>l.createElement("div",{"aria-hidden":!0},i)))}),Ae=Object.assign(Xl,{List:Av,Item:Rv,Input:Tv,Group:Pv,Separator:kv,Dialog:Mv,Empty:_v,Loading:Iv});function Ov(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Dv(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Zl(e){let t=l.useRef(e);return fn(()=>{t.current=e}),t}var fn=typeof window>"u"?l.useEffect:l.useLayoutEffect;function wn(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Ft(e){let t=wa(),n=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,n,n)}function Jl(e,t,n,r=[]){let o=l.useRef(),a=Ar();return fn(()=>{var i;let c=(()=>{var d;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(d=h.current.textContent)==null?void 0:d.trim():o.current}})(),u=r.map(d=>d.trim());a.value(e,c,u),(i=t.current)==null||i.setAttribute(bn,c),o.current=c}),o}var zv=()=>{let[e,t]=l.useState(),n=wn(()=>new Map);return fn(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Lv(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ks({asChild:e,children:t},n){return e&&l.isValidElement(t)?l.cloneElement(Lv(t),{ref:t.ref},n(t.props.children)):n(t)}var Fv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ed=ga,$v=va,td=l.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:k("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));td.displayName=Rs.displayName;const Na=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs($v,{children:[s.jsx(td,{}),s.jsxs(Ps,{ref:r,className:k("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-zinc-200 bg-white p-6 shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","rounded-lg",e),...n,children:[t,s.jsxs(Hl,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-500",children:[s.jsx(ps,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=Ps.displayName;const nd=({className:e,...t})=>s.jsx("div",{className:k("flex flex-col space-y-1.5 text-left",e),...t});nd.displayName="DialogHeader";const rd=({className:e,...t})=>s.jsx("div",{className:k("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});rd.displayName="DialogFooter";const sd=l.forwardRef(({className:e,...t},n)=>s.jsx(ya,{ref:n,className:k("text-lg font-semibold leading-none tracking-tight",e),...t}));sd.displayName=ya.displayName;const Uv=l.forwardRef(({className:e,...t},n)=>s.jsx(ba,{ref:n,className:k("text-sm text-zinc-500",e),...t}));Uv.displayName=ba.displayName;const od=l.forwardRef(({className:e,...t},n)=>s.jsx(Ae,{ref:n,className:k("flex h-full w-full flex-col overflow-hidden rounded-md bg-white text-zinc-900",e),...t}));od.displayName=Ae.displayName;const Vv=({children:e,...t})=>s.jsx(ed,{...t,children:s.jsx(Na,{className:"overflow-hidden p-0 shadow-2xl max-w-2xl",children:s.jsx(od,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-zinc-500 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),ad=l.forwardRef(({className:e,...t},n)=>s.jsxs("div",{className:"flex items-center border-b border-zinc-200 px-3","cmdk-input-wrapper":"",children:[s.jsx(Hn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx(Ae.Input,{ref:n,className:k("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-zinc-400 disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));ad.displayName=Ae.Input.displayName;const id=l.forwardRef(({className:e,...t},n)=>s.jsx(Ae.List,{ref:n,className:k("max-h-[400px] overflow-y-auto overflow-x-hidden",e),...t}));id.displayName=Ae.List.displayName;const cd=l.forwardRef((e,t)=>s.jsx(Ae.Empty,{ref:t,className:"py-6 text-center text-sm text-zinc-500",...e}));cd.displayName=Ae.Empty.displayName;const Yr=l.forwardRef(({className:e,...t},n)=>s.jsx(Ae.Group,{ref:n,className:k("overflow-hidden p-1 text-zinc-900 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wider [&_[cmdk-group-heading]]:text-zinc-500",e),...t}));Yr.displayName=Ae.Group.displayName;const Io=l.forwardRef(({className:e,...t},n)=>s.jsx(Ae.Separator,{ref:n,className:k("-mx-1 h-px bg-zinc-100",e),...t}));Io.displayName=Ae.Separator.displayName;const Xr=l.forwardRef(({className:e,...t},n)=>s.jsx(Ae.Item,{ref:n,className:k("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","data-[disabled=true]:pointer-events-none data-[selected=true]:bg-zinc-100 data-[selected=true]:text-zinc-900 data-[disabled=true]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));Xr.displayName=Ae.Item.displayName;const ld=ha(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(t=>({isOpen:!t.isOpen}))}));function Bv(e){return Le({queryKey:["search",e],queryFn:()=>de.get("/api/admin/search",{q:e}),enabled:e.length>=2,staleTime:1e4})}function Kv(e,t){const[n,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function Hv(){const{isOpen:e,close:t}=ld(),n=vt(),[r,o]=l.useState(""),a=Kv(r,300),{data:i}=Bv(a),c=l.useCallback(u=>{t(),u()},[t]);return s.jsxs(Vv,{open:e,onOpenChange:u=>!u&&t(),children:[s.jsx(ad,{placeholder:"Search orders, products, customers...",value:r,onValueChange:o,"data-testid":q("search","input")}),s.jsxs(id,{"data-testid":q("search"),children:[s.jsx(cd,{children:a.length<2?s.jsx("span",{className:"text-zinc-400",children:"Type at least 2 characters to search"}):s.jsxs("span",{children:['No results for "',a,'"']})}),(i==null?void 0:i.orders)&&i.orders.length>0&&s.jsx(Yr,{heading:"Orders",children:i.orders.slice(0,5).map(u=>s.jsxs(Xr,{value:`order-${u.orderNumber}`,onSelect:()=>c(()=>n(`/orders/${u.orderNumber}`)),children:[s.jsx(zn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("span",{className:"font-mono text-sm font-medium",children:["#",u.orderNumber]}),s.jsx("span",{className:"text-xs text-zinc-500 truncate",children:u.email})]})]},u.id))}),(i==null?void 0:i.products)&&i.products.length>0&&s.jsxs(s.Fragment,{children:[i.orders&&i.orders.length>0&&s.jsx(Io,{}),s.jsx(Yr,{heading:"Products",children:i.products.slice(0,5).map(u=>s.jsxs(Xr,{value:`product-${u.id}`,onSelect:()=>c(()=>n(`/products/${u.slug}`)),children:[s.jsx(cn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsx("span",{className:"text-sm font-medium truncate",children:u.name}),s.jsx("span",{className:"text-xs text-zinc-500 capitalize",children:u.status})]})]},u.id))})]}),(i==null?void 0:i.customers)&&i.customers.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Io,{}),s.jsx(Yr,{heading:"Customers",children:i.customers.slice(0,5).map(u=>s.jsxs(Xr,{value:`customer-${u.id}`,onSelect:()=>c(()=>n(`/customers/${u.id}`)),children:[s.jsx(Jo,{className:"h-4 w-4 text-zinc-400 shrink-0"}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("span",{className:"text-sm font-medium",children:[u.firstName," ",u.lastName]}),s.jsx("span",{className:"text-xs text-zinc-500 truncate",children:u.email})]})]},u.id))})]})]})]})}function qv(){const{open:e}=ld();return l.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),s.jsxs("button",{onClick:e,className:"flex items-center gap-2 rounded-md border border-zinc-200 bg-white px-3 py-1.5 text-sm text-zinc-500 hover:border-zinc-300 hover:text-zinc-700 transition-colors","data-testid":q("search","trigger"),children:[s.jsx(Hn,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"hidden sm:inline",children:"Search"}),s.jsxs("kbd",{className:"hidden sm:inline-flex items-center gap-1 rounded border border-zinc-200 bg-zinc-50 px-1.5 text-[10px] font-medium text-zinc-400",children:[s.jsx("span",{children:"⌘"}),"K"]})]})}const dd=["orders","list"],Ht=e=>e===void 0;function ud(e,t){return Ht(e.status)||e.status===t.status}function Wv(e,t){return ud(e,t)&&Ht(e.q)&&Ht(e.dateFrom)&&Ht(e.dateTo)&&Ht(e.customer)&&(Ht(e.offset)||e.offset===0)&&(Ht(e.sort)||e.sort==="createdAt:desc")}function Gv(e,t){for(const n of e.getQueryCache().findAll({queryKey:dd})){const r=n.queryKey[2]??{};if(!ud(r,t))continue;const o=e.getQueryData(n.queryKey);if(o&&Wv(r,t)){const a=[t,...o.filter(i=>i.id!==t.id)];e.setQueryData(n.queryKey,a.slice(0,r.limit??a.length))}else e.invalidateQueries({queryKey:n.queryKey,exact:!0})}}function Qv(e){const t=Pl.getState().pushNotification;function n(r){switch(r.type){case"order.placed.v1":{const{order:o}=r.payload;Gv(e,o),e.invalidateQueries({queryKey:["dashboard"]}),t({type:"info",title:"New Order",message:`Order #${o.orderNumber} placed by ${o.email}`});break}case"order.paid.v1":case"order.fulfilled.v1":case"order.shipped.v1":case"order.delivered.v1":case"order.cancelled.v1":case"order.refunded.v1":case"order.partially_refunded.v1":{e.invalidateQueries({queryKey:dd}),e.invalidateQueries({queryKey:["orders","detail"]}),e.invalidateQueries({queryKey:["dashboard"]});break}case"inventory.changed.v1":{e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.low_stock.v1":{const{variantId:o,currentQty:a,threshold:i}=r.payload;t({type:"warning",title:"Low Stock Alert",message:`Variant ${o} is running low: ${a} left (threshold ${i})`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.out_of_stock.v1":{t({type:"error",title:"Out of Stock",message:`Variant ${r.payload.variantId} is out of stock`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"payment.failed.v1":{const{orderId:o,reason:a}=r.payload;t({type:"error",title:"Payment Failed",message:`Payment failed for order ${o}: ${a}`});break}case"adapter.error.v1":{const{adapterType:o,adapterName:a,error:i}=r.payload;t({type:"error",title:"Adapter Error",message:`${o} adapter ${a}: ${i.message}`});break}}}return function(o,a){n({type:o,payload:a})}}const fd=ha(e=>({events:[],pushEvent:(t,n)=>{const r={id:crypto.randomUUID(),type:t,label:n,at:new Date().toISOString()};e(o=>({events:[r,...o.events].slice(0,20)}))}}));function Yv(e){return e.includes("error")||e.includes("failed")||e.includes("out_of_stock")?"bg-red-500/10 text-red-500 border-red-500/20":e.includes("low_stock")||e.includes("warning")?"bg-amber-500/10 text-amber-600 border-amber-500/20":e.includes("placed")||e.includes("paid")?"bg-green-500/10 text-green-600 border-green-500/20":"bg-zinc-100 text-zinc-600 border-zinc-200"}function Xv(){const e=fd(r=>r.events),t=l.useRef(null),n=e.slice(0,3);return l.useEffect(()=>{t.current&&e.length>0&&(t.current.scrollLeft=0)},[e.length]),n.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),s.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400",children:"Live"})]}),s.jsx("span",{className:"text-zinc-300",children:"—"}),s.jsx("span",{className:"text-zinc-400",children:"No recent events"})]}):s.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",ref:t,children:[s.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsxs("span",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),s.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400 shrink-0",children:"Live"})]}),s.jsx("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:n.map(r=>s.jsx("span",{className:k("flex shrink-0 items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium whitespace-nowrap",Yv(r.type)),children:r.label},r.id))})]})}function Zv({navOpen:e,onToggleNav:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"fixed left-0 right-0 top-0 z-30 flex h-14 items-center border-b border-zinc-200 bg-white px-3 sm:px-5 md:left-60",children:[s.jsx("button",{type:"button","data-testid":q("nav","toggle"),"aria-label":"Navigation","aria-controls":"admin-sidebar","aria-expanded":e,onClick:t,className:"mr-2 rounded p-1.5 text-zinc-600 hover:bg-zinc-100 md:hidden",children:s.jsx(rm,{className:"h-5 w-5"})}),s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:s.jsx(Jm,{})}),s.jsx("div",{className:"mx-8 hidden flex-1 items-center justify-center overflow-hidden md:flex",children:s.jsx(Xv,{})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(qv,{}),s.jsx(Yg,{})]})]}),s.jsx(Hv,{})]})}var Jv={pending:["confirmed","cancelled"],confirmed:["processing","cancelled","refunded","partially_refunded"],processing:["shipped","cancelled","refunded","partially_refunded"],shipped:["delivered","refunded","partially_refunded"],delivered:["refunded","partially_refunded"],cancelled:[],refunded:[],partially_refunded:["refunded"]};function e0(e){return e.capturedMinor<=0?"unpaid":e.refundedMinor<=0?"paid":e.refundedMinor<e.capturedMinor?"partially_refunded":"refunded"}var t0="product.created.v1",n0="product.updated.v1",r0="product.deleted.v1",s0="product.published.v1",o0="product.unpublished.v1",a0="category.created.v1",i0="category.updated.v1",c0="category.deleted.v1",l0="order.placed.v1",d0="order.paid.v1",u0="order.fulfilled.v1",f0="order.shipped.v1",h0="order.delivered.v1",m0="order.cancelled.v1",p0="order.refunded.v1",x0="order.partially_refunded.v1",g0="inventory.changed.v1",v0="inventory.reserved.v1",y0="inventory.released.v1",b0="inventory.low_stock.v1",w0="inventory.out_of_stock.v1",N0="customer.created.v1",j0="customer.updated.v1",C0="customer.deleted.v1",S0="cart.created.v1",E0="cart.item_added.v1",R0="cart.item_removed.v1",P0="cart.updated.v1",k0="cart.abandoned.v1",T0="cart.converted.v1",A0="payment.captured.v1",M0="payment.failed.v1",_0="payment.refunded.v1",I0="adapter.error.v1",O0=[t0,n0,r0,s0,o0,a0,i0,c0,l0,d0,u0,f0,h0,m0,p0,x0,g0,v0,y0,b0,w0,N0,j0,C0,S0,E0,R0,P0,k0,T0,A0,M0,_0,I0];const Mi=[1e3,2e3,5e3,1e4,3e4];function D0(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"payload"in t)return t.payload}catch{}}function z0(e){let t=null,n=0,r=null,o=!1;async function a(){return(await de.post("/api/admin/events/ticket")).ticket}function i(){if(o)return;const u=Mi[Math.min(n,Mi.length-1)]??3e4;n++,r=setTimeout(()=>{c()},u)}async function c(){if(!o)try{const u=await a();if(o)return;t=new EventSource(`/api/admin/events?ticket=${encodeURIComponent(u)}`),t.onopen=()=>{n=0};for(const d of O0)t.addEventListener(d,h=>{const f=D0(h.data);f!==void 0&&e(d,f)});t.onerror=()=>{t==null||t.close(),t=null,i()}}catch{i()}}return{connect(){o=!1,c()},disconnect(){o=!0,r!==null&&(clearTimeout(r),r=null),t==null||t.close(),t=null}}}function L0(e){switch(e.type){case"order.placed.v1":return`New order #${e.payload.order.orderNumber}`;case"order.paid.v1":return"Payment received";case"order.shipped.v1":return`Order shipped (${e.payload.carrier})`;case"order.delivered.v1":return"Order delivered";case"inventory.low_stock.v1":return`Low stock: ${e.payload.currentQty} left`;case"inventory.out_of_stock.v1":return"Out of stock";case"payment.failed.v1":return"Payment failed";default:return e.type.replace(/\./g," ").replace(/v\d+$/,"").trim()}}function F0({children:e}){const t=Ne(),n=l.useRef(null),r=fd(o=>o.pushEvent);return l.useEffect(()=>{if(!ns())return;const o=Qv(t),a=z0((i,c)=>{o(i,c),r(i,L0({type:i,payload:c}))});return n.current=a,a.connect(),()=>{a.disconnect(),n.current=null}},[t,r]),s.jsx(s.Fragment,{children:e})}function $0(){const[e,t]=l.useState(!1);return s.jsx(F0,{children:s.jsxs("div",{className:"min-h-screen bg-zinc-100",children:[e&&s.jsx("div",{"aria-hidden":"true",className:"fixed inset-0 z-40 bg-zinc-950/50 md:hidden",onClick:()=>t(!1)}),s.jsx(Zm,{open:e,onClose:()=>t(!1)}),s.jsx(Zv,{navOpen:e,onToggleNav:()=>t(n=>!n)}),s.jsx("main",{className:"md:ml-60 pt-14 min-h-screen",children:s.jsx("div",{className:"p-6",children:s.jsx(_f,{})})})]})})}const be=l.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:k("flex h-9 w-full rounded-md border border-zinc-200 bg-white px-3 py-1 text-sm shadow-none transition-colors","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-0 focus:border-blue-500","disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));be.displayName="Input";var U0="Label",hd=l.forwardRef((e,t)=>s.jsx(bt.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));hd.displayName=U0;var md=hd;const V0=xs("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),De=l.forwardRef(({className:e,...t},n)=>s.jsx(md,{ref:n,className:k(V0(),e),...t}));De.displayName=md.displayName;function B0({size:e="md",className:t}){return s.jsx("div",{className:k("inline-block animate-spin rounded-full border-2 border-zinc-200 border-t-blue-600",e==="sm"&&"h-4 w-4",e==="md"&&"h-6 w-6",e==="lg"&&"h-8 w-8",t),role:"status","aria-label":"Loading"})}function K0(){const{login:e}=Ec(),[t,n]=l.useState(""),[r,o]=l.useState(""),[a,i]=l.useState(null),[c,u]=l.useState(!1),d=async h=>{h.preventDefault(),i(null),u(!0);try{await e(t,r)}catch(f){i(f instanceof Error?f.message:"Login failed")}finally{u(!1)}};return s.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4",children:[s.jsx("div",{className:"pointer-events-none fixed inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #fff 1px, transparent 1px)",backgroundSize:"24px 24px"}}),s.jsxs("div",{className:"relative w-full max-w-sm",children:[s.jsxs("div",{className:"mb-8 flex flex-col items-center gap-3",children:[s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-blue-600 shadow-lg shadow-blue-500/20",children:s.jsx("span",{className:"text-xl font-bold text-white",children:"N"})}),s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"text-xl font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"}),s.jsx("p",{className:"text-sm text-zinc-500",children:"Admin Dashboard"})]})]}),s.jsxs("div",{className:"rounded-xl border border-zinc-800 bg-zinc-900 p-6 shadow-2xl",children:[s.jsx("h2",{className:"mb-1 text-base font-semibold text-zinc-100",children:"Sign in"}),s.jsx("p",{className:"mb-6 text-sm text-zinc-500",children:"Enter your admin credentials"}),s.jsxs("form",{onSubmit:h=>void d(h),"data-testid":q("login","form"),className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(De,{className:"text-zinc-300 text-xs",children:"Email"}),s.jsx(be,{type:"email",value:t,onChange:h=>n(h.target.value),placeholder:"admin@yourstore.com",autoComplete:"email",required:!0,disabled:c,"data-testid":q("login","email"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(De,{className:"text-zinc-300 text-xs",children:"Password"}),s.jsx(be,{type:"password",value:r,onChange:h=>o(h.target.value),placeholder:"••••••••",autoComplete:"current-password",required:!0,disabled:c,"data-testid":q("login","password"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),a&&s.jsx("div",{role:"alert","data-testid":q("login","error"),className:"rounded-md border border-red-800/50 bg-red-900/20 px-3 py-2 text-sm text-red-400",children:a}),s.jsx(pe,{type:"submit",className:"w-full",disabled:c||!t||!r,"data-testid":q("login","submit"),children:c?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(B0,{size:"sm",className:"border-blue-200 border-t-white"}),"Signing in..."]}):"Sign in"})]})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-zinc-600",children:"Nymbal Admin · Precision Workspace"})]})]})}function ge({className:e,...t}){return s.jsx("div",{className:k("animate-pulse rounded-md bg-zinc-200",e),...t})}const H0={pending:"bg-zinc-100 text-zinc-700",confirmed:"bg-blue-100 text-blue-700",processing:"bg-indigo-100 text-indigo-700",shipped:"bg-violet-100 text-violet-700",delivered:"bg-green-100 text-green-700",cancelled:"bg-red-100 text-red-700",refunded:"bg-orange-100 text-orange-700",partially_refunded:"bg-amber-100 text-amber-700"},q0={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Part. Refunded"};function $n({status:e,size:t="md",className:n,"data-testid":r}){return s.jsx("span",{"data-testid":r,className:k("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-[10px]":"px-2.5 py-0.5 text-xs",H0[e],n),children:q0[e]})}function Yn({icon:e,title:t,description:n,action:r,className:o}){return s.jsxs("div",{className:k("flex flex-col items-center justify-center py-16 px-4 text-center",o),children:[e&&s.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-zinc-100 text-zinc-400",children:e}),s.jsx("h3",{className:"text-sm font-medium text-zinc-900",children:t}),n&&s.jsx("p",{className:"mt-1 text-sm text-zinc-500",children:n}),r&&s.jsx("div",{className:"mt-4",children:r})]})}function W0(){return Le({queryKey:["dashboard"],queryFn:()=>de.get("/api/admin/dashboard"),refetchInterval:6e4})}function me(e,t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:t,minimumFractionDigits:2}).format(e/100)}function G0(e){const t=e.trim();if(!/^\d+(\.\d{1,2})?$/.test(t))return null;const[n="0",r=""]=t.split(".");return Number(n)*100+Number(r.padEnd(2,"0"))}function Q0(e,t){const n=e/100,r=Y0(t);return n>=1e6?`${r}${(n/1e6).toFixed(1)}M`:n>=1e3?`${r}${(n/1e3).toFixed(1)}k`:me(e,t)}function Y0(e){try{return new Intl.NumberFormat("en-GB",{style:"currency",currency:e,minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/[\d\s,]/g,"").trim()}catch{return e}}function X0(){return s.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-green-50 border border-green-200 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-green-600",children:[s.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[s.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-green-500"})]}),"Live"]})}function so({icon:e,label:t,value:n,subtext:r,loading:o,color:a="blue"}){const i={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",violet:"bg-violet-50 text-violet-600"};return s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsx("div",{className:k("flex h-9 w-9 items-center justify-center rounded-lg",i[a]),children:e}),s.jsx(So,{className:"h-4 w-4 text-zinc-300"})]}),o?s.jsxs(s.Fragment,{children:[s.jsx(ge,{className:"h-7 w-24 mb-1"}),s.jsx(ge,{className:"h-3.5 w-16"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900",children:n}),s.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:t}),r&&s.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:r})]})]})}function Z0(){var a,i;const{data:e}=Sc(),{data:t,isLoading:n}=W0(),r=vt(),o="GBP";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:(e==null?void 0:e.storeName)??"Dashboard"}),s.jsx("p",{className:"text-sm text-zinc-500",children:"Today's performance at a glance"})]}),s.jsx(X0,{})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[s.jsx(so,{icon:s.jsx(zn,{className:"h-4.5 w-4.5"}),label:"Orders today",value:String((t==null?void 0:t.today.orderCount)??0),loading:n,color:"blue"}),s.jsx(so,{icon:s.jsx(Yh,{className:"h-4.5 w-4.5"}),label:"Revenue today",value:t?Q0(t.today.revenueMinor,o):"—",subtext:t?me(t.today.revenueMinor,o):void 0,loading:n,color:"green"}),s.jsx(so,{icon:s.jsx(Cc,{className:"h-4.5 w-4.5"}),label:"Items shipped",value:String((t==null?void 0:t.today.itemsShipped)??0),loading:n,color:"violet"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[s.jsx("div",{className:"md:col-span-2",children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[s.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Recent Orders"}),s.jsx("button",{onClick:()=>r("/orders"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"View all →"})]}),n?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:5}).map((c,u)=>s.jsx(ge,{className:"h-11 w-full"},u))}):(a=t==null?void 0:t.recentOrders)!=null&&a.length?s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"border-b border-zinc-100",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Order"}),s.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Customer"}),s.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Status"}),s.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Total"}),s.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Time"})]})}),s.jsx("tbody",{children:t.recentOrders.map(c=>s.jsxs("tr",{className:"cursor-pointer border-b border-zinc-50 last:border-0 hover:bg-zinc-50 transition-colors",onClick:()=>r(`/orders/${c.orderNumber}`),children:[s.jsx("td",{className:"px-4 py-2.5",children:s.jsxs("span",{className:"font-mono text-sm font-medium text-blue-600",children:["#",c.orderNumber]})}),s.jsx("td",{className:"px-4 py-2.5 text-zinc-600 truncate max-w-[160px]",children:c.email}),s.jsx("td",{className:"px-4 py-2.5",children:s.jsx($n,{status:c.status,size:"sm"})}),s.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-sm text-zinc-700",children:me(c.totalMinor,c.currency)}),s.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-zinc-400",children:it(c.createdAt)})]},c.id))})]}):s.jsx(Yn,{icon:s.jsx(zn,{className:"h-5 w-5"}),title:"No orders yet",description:"Orders will appear here as they come in."})]})}),s.jsx("div",{children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Low Stock"}),(t==null?void 0:t.lowStock)&&t.lowStock.length>0&&s.jsx("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:t.lowStock.length})]}),s.jsx("button",{onClick:()=>r("/inventory"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"Manage →"})]}),n?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:4}).map((c,u)=>s.jsx(ge,{className:"h-10 w-full"},u))}):(i=t==null?void 0:t.lowStock)!=null&&i.length?s.jsx("div",{className:"divide-y divide-zinc-50",children:t.lowStock.map(c=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-zinc-50 transition-colors",onClick:()=>r("/inventory"),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-xs font-medium text-zinc-700",children:c.productName}),s.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:c.sku})]}),s.jsxs("div",{className:"ml-3 text-right",children:[s.jsx("span",{className:k("font-mono text-sm font-semibold",c.status==="out_of_stock"?"text-red-600":"text-amber-600"),children:c.stock}),s.jsxs("p",{className:"text-[10px] text-zinc-400",children:["/",c.threshold]})]})]},c.variantId))}):s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"mx-auto mb-2 flex h-8 w-8 items-center justify-center rounded-full bg-green-50",children:s.jsx(rs,{className:"h-4 w-4 text-green-500"})}),s.jsx("p",{className:"text-xs text-zinc-500",children:"All stock levels are healthy"})]})]})})]})]})}const Xn=l.forwardRef(({className:e,...t},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:k("w-full caption-bottom text-sm",e),...t})}));Xn.displayName="Table";const Zn=l.forwardRef(({className:e,...t},n)=>s.jsx("thead",{ref:n,className:k("[&_tr]:border-b [&_tr]:border-zinc-200",e),...t}));Zn.displayName="TableHeader";const Jn=l.forwardRef(({className:e,...t},n)=>s.jsx("tbody",{ref:n,className:k("[&_tr:last-child]:border-0",e),...t}));Jn.displayName="TableBody";const J0=l.forwardRef(({className:e,...t},n)=>s.jsx("tfoot",{ref:n,className:k("border-t border-zinc-200 bg-zinc-50/50 font-medium [&>tr]:last:border-b-0",e),...t}));J0.displayName="TableFooter";const Ge=l.forwardRef(({className:e,...t},n)=>s.jsx("tr",{ref:n,className:k("border-b border-zinc-100 transition-colors hover:bg-zinc-50/60 data-[state=selected]:bg-blue-50",e),...t}));Ge.displayName="TableRow";const re=l.forwardRef(({className:e,...t},n)=>s.jsx("th",{ref:n,className:k("h-10 px-4 text-left align-middle text-xs font-medium uppercase tracking-wider text-zinc-500 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));re.displayName="TableHead";const se=l.forwardRef(({className:e,...t},n)=>s.jsx("td",{ref:n,className:k("h-11 px-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));se.displayName="TableCell";const ey=l.forwardRef(({className:e,...t},n)=>s.jsx("caption",{ref:n,className:k("mt-4 text-sm text-zinc-500",e),...t}));ey.displayName="TableCaption";function pd(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ts="Checkbox",[ty]=ot(Ts),[ny,ja]=ty(Ts);function ry(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:a,form:i,name:c,onCheckedChange:u,required:d,value:h="on",internal_do_not_use_render:f}=e,[m,x]=Lt({prop:n,defaultProp:o??!1,onChange:u,caller:Ts}),[v,p]=l.useState(null),[g,w]=l.useState(null),y=l.useRef(!1),N=v?!!i||!!v.closest("form"):!0,j={checked:m,disabled:a,setChecked:x,control:v,setControl:p,name:c,form:i,value:h,hasConsumerStoppedPropagationRef:y,required:d,defaultChecked:Ot(o)?!1:o,isFormControl:N,bubbleInput:g,setBubbleInput:w};return s.jsx(ny,{scope:t,...j,children:sy(f)?f(j):r})}var xd="CheckboxTrigger",gd=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:a,value:i,disabled:c,checked:u,required:d,setControl:h,setChecked:f,hasConsumerStoppedPropagationRef:m,isFormControl:x,bubbleInput:v}=ja(xd,e),p=ce(o,h),g=l.useRef(u);return l.useEffect(()=>{const w=a==null?void 0:a.form;if(w){const y=()=>f(g.current);return w.addEventListener("reset",y),()=>w.removeEventListener("reset",y)}},[a,f]),s.jsx(W.button,{type:"button",role:"checkbox","aria-checked":Ot(u)?"mixed":u,"aria-required":d,"data-state":Nd(u),"data-disabled":c?"":void 0,disabled:c,value:i,...r,ref:p,onKeyDown:I(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:I(n,w=>{f(y=>Ot(y)?!0:!y),v&&x&&(m.current=w.isPropagationStopped(),m.current||w.stopPropagation())})})});gd.displayName=xd;var Ca=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:a,required:i,disabled:c,value:u,onCheckedChange:d,form:h,...f}=e;return s.jsx(ry,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:c,required:i,onCheckedChange:d,name:r,form:h,value:u,internal_do_not_use_render:({isFormControl:m})=>s.jsxs(s.Fragment,{children:[s.jsx(gd,{...f,ref:t,__scopeCheckbox:n}),m&&s.jsx(wd,{__scopeCheckbox:n})]})})});Ca.displayName=Ts;var vd="CheckboxIndicator",yd=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,a=ja(vd,n);return s.jsx(Ve,{present:r||Ot(a.checked)||a.checked===!0,children:s.jsx(W.span,{"data-state":Nd(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});yd.displayName=vd;var bd="CheckboxBubbleInput",wd=l.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:i,required:c,disabled:u,name:d,value:h,form:f,bubbleInput:m,setBubbleInput:x}=ja(bd,e),v=ce(n,x),p=pd(a),g=Zc(r);l.useEffect(()=>{const y=m;if(!y)return;const N=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(N,"checked").set,E=!o.current;if(p!==a&&C){const S=new Event("click",{bubbles:E});y.indeterminate=Ot(a),C.call(y,Ot(a)?!1:a),y.dispatchEvent(S)}},[m,p,a,o]);const w=l.useRef(Ot(a)?!1:a);return s.jsx(W.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??w.current,required:c,disabled:u,name:d,value:h,form:f,...t,tabIndex:-1,ref:v,style:{...t.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});wd.displayName=bd;function sy(e){return typeof e=="function"}function Ot(e){return e==="indeterminate"}function Nd(e){return Ot(e)?"indeterminate":e?"checked":"unchecked"}const Oo=l.forwardRef(({className:e,...t},n)=>s.jsx(Ca,{ref:n,className:k("peer h-4 w-4 shrink-0 rounded-sm border border-zinc-300 ring-offset-white","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-[state=checked]:bg-blue-600 data-[state=checked]:border-blue-600 data-[state=checked]:text-white",e),...t,children:s.jsx(yd,{className:k("flex items-center justify-center text-current"),children:s.jsx(Kn,{className:"h-3 w-3",strokeWidth:3})})}));Oo.displayName=Ca.displayName;function Sa(e){const t=e+"CollectionProvider",[n,r]=ot(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:g,children:w}=p,y=He.useRef(null),N=He.useRef(new Map).current;return s.jsx(o,{scope:g,itemMap:N,collectionRef:y,children:w})};i.displayName=t;const c=e+"CollectionSlot",u=ln(c),d=He.forwardRef((p,g)=>{const{scope:w,children:y}=p,N=a(c,w),j=ce(g,N.collectionRef);return s.jsx(u,{ref:j,children:y})});d.displayName=c;const h=e+"CollectionItemSlot",f="data-radix-collection-item",m=ln(h),x=He.forwardRef((p,g)=>{const{scope:w,children:y,...N}=p,j=He.useRef(null),C=ce(g,j),E=a(h,w);return He.useEffect(()=>(E.itemMap.set(j,{ref:j,...N}),()=>void E.itemMap.delete(j))),s.jsx(m,{[f]:"",ref:C,children:y})});x.displayName=h;function v(p){const g=a(e+"CollectionConsumer",p);return He.useCallback(()=>{const y=g.collectionRef.current;if(!y)return[];const N=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((E,S)=>N.indexOf(E.ref.current)-N.indexOf(S.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:d,ItemSlot:x},v,r]}var oy=l.createContext(void 0);function As(e){const t=l.useContext(oy);return e||t||"ltr"}var oo="rovingFocusGroup.onEntryFocus",ay={bubbles:!1,cancelable:!0},Mr="RovingFocusGroup",[Do,jd,iy]=Sa(Mr),[cy,Ms]=ot(Mr,[iy]),[ly,dy]=cy(Mr),Cd=l.forwardRef((e,t)=>s.jsx(Do.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Do.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(uy,{...e,ref:t})})}));Cd.displayName=Mr;var uy=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...f}=e,m=l.useRef(null),x=ce(t,m),v=As(a),[p,g]=Lt({prop:i,defaultProp:c??null,onChange:u,caller:Mr}),[w,y]=l.useState(!1),N=st(d),j=jd(n),C=l.useRef(!1),[E,S]=l.useState(0);return l.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(oo,N),()=>P.removeEventListener(oo,N)},[N]),s.jsx(ly,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:p,onItemFocus:l.useCallback(P=>g(P),[g]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>S(P=>P+1),[]),onFocusableItemRemove:l.useCallback(()=>S(P=>P-1),[]),children:s.jsx(W.div,{tabIndex:w||E===0?-1:0,"data-orientation":r,...f,ref:x,style:{outline:"none",...e.style},onMouseDown:I(e.onMouseDown,()=>{C.current=!0}),onFocus:I(e.onFocus,P=>{const D=!C.current;if(P.target===P.currentTarget&&D&&!w){const O=new CustomEvent(oo,ay);if(P.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=j().filter(V=>V.focusable),_=$.find(V=>V.active),G=$.find(V=>V.id===p),X=[_,G,...$].filter(Boolean).map(V=>V.ref.current);Rd(X,h)}}C.current=!1}),onBlur:I(e.onBlur,()=>y(!1))})})}),Sd="RovingFocusGroupItem",Ed=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:a,children:i,...c}=e,u=we(),d=a||u,h=dy(Sd,n),f=h.currentTabStopId===d,m=jd(n),{onFocusableItemAdd:x,onFocusableItemRemove:v,currentTabStopId:p}=h;return l.useEffect(()=>{if(r)return x(),()=>v()},[r,x,v]),s.jsx(Do.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(W.span,{tabIndex:f?0:-1,"data-orientation":h.orientation,...c,ref:t,onMouseDown:I(e.onMouseDown,g=>{r?h.onItemFocus(d):g.preventDefault()}),onFocus:I(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:I(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){h.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const w=my(g,h.orientation,h.dir);if(w!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let N=m().filter(j=>j.focusable).map(j=>j.ref.current);if(w==="last")N.reverse();else if(w==="prev"||w==="next"){w==="prev"&&N.reverse();const j=N.indexOf(g.currentTarget);N=h.loop?py(N,j+1):N.slice(j+1)}setTimeout(()=>Rd(N))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:p!=null}):i})})});Ed.displayName=Sd;var fy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function hy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function my(e,t,n){const r=hy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return fy[r]}function Rd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function py(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Pd=Cd,kd=Ed,zo=["Enter"," "],xy=["ArrowDown","PageUp","Home"],Td=["ArrowUp","PageDown","End"],gy=[...xy,...Td],vy={ltr:[...zo,"ArrowRight"],rtl:[...zo,"ArrowLeft"]},yy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_r="Menu",[pr,by,wy]=Sa(_r),[pn,Ad]=ot(_r,[wy,Qn,Ms]),_s=Qn(),Md=Ms(),[Ny,xn]=pn(_r),[jy,Ir]=pn(_r),_d=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:a,modal:i=!0}=e,c=_s(t),[u,d]=l.useState(null),h=l.useRef(!1),f=st(a),m=As(o);return l.useEffect(()=>{const x=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),s.jsx(la,{...c,children:s.jsx(Ny,{scope:t,open:n,onOpenChange:f,content:u,onContentChange:d,children:s.jsx(jy,{scope:t,onClose:l.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:m,modal:i,children:r})})})};_d.displayName=_r;var Cy="MenuAnchor",Ea=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=_s(n);return s.jsx(Ns,{...o,...r,ref:t})});Ea.displayName=Cy;var Ra="MenuPortal",[Sy,Id]=pn(Ra,{forceMount:void 0}),Od=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,a=xn(Ra,t);return s.jsx(Sy,{scope:t,forceMount:n,children:s.jsx(Ve,{present:n||a.open,children:s.jsx(Pr,{asChild:!0,container:o,children:r})})})};Od.displayName=Ra;var Ue="MenuContent",[Ey,Pa]=pn(Ue),Dd=l.forwardRef((e,t)=>{const n=Id(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=xn(Ue,e.__scopeMenu),i=Ir(Ue,e.__scopeMenu);return s.jsx(pr.Provider,{scope:e.__scopeMenu,children:s.jsx(Ve,{present:r||a.open,children:s.jsx(pr.Slot,{scope:e.__scopeMenu,children:i.modal?s.jsx(Ry,{...o,ref:t}):s.jsx(Py,{...o,ref:t})})})})}),Ry=l.forwardRef((e,t)=>{const n=xn(Ue,e.__scopeMenu),r=l.useRef(null),o=ce(t,r);return l.useEffect(()=>{const a=r.current;if(a)return js(a)},[]),s.jsx(ka,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:I(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Py=l.forwardRef((e,t)=>{const n=xn(Ue,e.__scopeMenu);return s.jsx(ka,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ky=ln("MenuContent.ScrollLock"),ka=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,onDismiss:x,disableOutsideScroll:v,...p}=e,g=xn(Ue,n),w=Ir(Ue,n),y=_s(n),N=Md(n),j=by(n),[C,E]=l.useState(null),S=l.useRef(null),P=ce(t,S,g.onContentChange),D=l.useRef(0),O=l.useRef(""),$=l.useRef(0),_=l.useRef(null),G=l.useRef("right"),U=l.useRef(0),X=v?kr:l.Fragment,V=v?{as:ky,allowPinchZoom:!0}:void 0,te=T=>{var A,Q;const ae=O.current+T,ie=j().filter(Y=>!Y.disabled),R=document.activeElement,B=(A=ie.find(Y=>Y.ref.current===R))==null?void 0:A.textValue,K=ie.map(Y=>Y.textValue),z=Uy(K,ae,B),Z=(Q=ie.find(Y=>Y.textValue===z))==null?void 0:Q.ref.current;(function Y(oe){O.current=oe,window.clearTimeout(D.current),oe!==""&&(D.current=window.setTimeout(()=>Y(""),1e3))})(ae),Z&&setTimeout(()=>Z.focus())};l.useEffect(()=>()=>window.clearTimeout(D.current),[]),gs();const L=l.useCallback(T=>{var ie,R;return G.current===((ie=_.current)==null?void 0:ie.side)&&By(T,(R=_.current)==null?void 0:R.area)},[]);return s.jsx(Ey,{scope:n,searchRef:O,onItemEnter:l.useCallback(T=>{L(T)&&T.preventDefault()},[L]),onItemLeave:l.useCallback(T=>{var ae;L(T)||((ae=S.current)==null||ae.focus(),E(null))},[L]),onTriggerLeave:l.useCallback(T=>{L(T)&&T.preventDefault()},[L]),pointerGraceTimerRef:$,onPointerGraceIntentChange:l.useCallback(T=>{_.current=T},[]),children:s.jsx(X,{...V,children:s.jsx(Er,{asChild:!0,trapped:o,onMountAutoFocus:I(a,T=>{var ae;T.preventDefault(),(ae=S.current)==null||ae.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:s.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,onDismiss:x,children:s.jsx(Pd,{asChild:!0,...N,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:E,onEntryFocus:I(u,T=>{w.isUsingKeyboardRef.current||T.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(da,{role:"menu","aria-orientation":"vertical","data-state":Zd(g.open),"data-radix-menu-content":"",dir:w.dir,...y,...p,ref:P,style:{outline:"none",...p.style},onKeyDown:I(p.onKeyDown,T=>{const ie=T.target.closest("[data-radix-menu-content]")===T.currentTarget,R=T.ctrlKey||T.altKey||T.metaKey,B=T.key.length===1;ie&&(T.key==="Tab"&&T.preventDefault(),!R&&B&&te(T.key));const K=S.current;if(T.target!==K||!gy.includes(T.key))return;T.preventDefault();const Z=j().filter(A=>!A.disabled).map(A=>A.ref.current);Td.includes(T.key)&&Z.reverse(),Fy(Z)}),onBlur:I(e.onBlur,T=>{T.currentTarget.contains(T.target)||(window.clearTimeout(D.current),O.current="")}),onPointerMove:I(e.onPointerMove,xr(T=>{const ae=T.target,ie=U.current!==T.clientX;if(T.currentTarget.contains(ae)&&ie){const R=T.clientX>U.current?"right":"left";G.current=R,U.current=T.clientX}}))})})})})})})});Dd.displayName=Ue;var Ty="MenuGroup",Ta=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(W.div,{role:"group",...r,ref:t})});Ta.displayName=Ty;var Ay="MenuLabel",zd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(W.div,{...r,ref:t})});zd.displayName=Ay;var ds="MenuItem",_i="menu.itemSelect",Is=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,a=l.useRef(null),i=Ir(ds,e.__scopeMenu),c=Pa(ds,e.__scopeMenu),u=ce(t,a),d=l.useRef(!1),h=()=>{const f=a.current;if(!n&&f){const m=new CustomEvent(_i,{bubbles:!0,cancelable:!0});f.addEventListener(_i,x=>r==null?void 0:r(x),{once:!0}),Dc(f,m),m.defaultPrevented?d.current=!1:i.onClose()}};return s.jsx(Ld,{...o,ref:u,disabled:n,onClick:I(e.onClick,h),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),d.current=!0},onPointerUp:I(e.onPointerUp,f=>{var m;d.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:I(e.onKeyDown,f=>{const m=c.searchRef.current!=="";n||m&&f.key===" "||zo.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Is.displayName=ds;var Ld=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...a}=e,i=Pa(ds,n),c=Md(n),u=l.useRef(null),d=ce(t,u),[h,f]=l.useState(!1),[m,x]=l.useState("");return l.useEffect(()=>{const v=u.current;v&&x((v.textContent??"").trim())},[a.children]),s.jsx(pr.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:s.jsx(kd,{asChild:!0,...c,focusable:!r,children:s.jsx(W.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:d,onPointerMove:I(e.onPointerMove,xr(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:I(e.onPointerLeave,xr(v=>i.onItemLeave(v))),onFocus:I(e.onFocus,()=>f(!0)),onBlur:I(e.onBlur,()=>f(!1))})})})}),My="MenuCheckboxItem",Fd=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return s.jsx(Kd,{scope:e.__scopeMenu,checked:n,children:s.jsx(Is,{role:"menuitemcheckbox","aria-checked":us(n)?"mixed":n,...o,ref:t,"data-state":Ma(n),onSelect:I(o.onSelect,()=>r==null?void 0:r(us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Fd.displayName=My;var $d="MenuRadioGroup",[_y,Iy]=pn($d,{value:void 0,onValueChange:()=>{}}),Ud=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,a=st(r);return s.jsx(_y,{scope:e.__scopeMenu,value:n,onValueChange:a,children:s.jsx(Ta,{...o,ref:t})})});Ud.displayName=$d;var Vd="MenuRadioItem",Bd=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=Iy(Vd,e.__scopeMenu),a=n===o.value;return s.jsx(Kd,{scope:e.__scopeMenu,checked:a,children:s.jsx(Is,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":Ma(a),onSelect:I(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Bd.displayName=Vd;var Aa="MenuItemIndicator",[Kd,Oy]=pn(Aa,{checked:!1}),Hd=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,a=Oy(Aa,n);return s.jsx(Ve,{present:r||us(a.checked)||a.checked===!0,children:s.jsx(W.span,{...o,ref:t,"data-state":Ma(a.checked)})})});Hd.displayName=Aa;var Dy="MenuSeparator",qd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(W.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qd.displayName=Dy;var zy="MenuArrow",Wd=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=_s(n);return s.jsx(ua,{...o,...r,ref:t})});Wd.displayName=zy;var Ly="MenuSub",[EN,Gd]=pn(Ly),lr="MenuSubTrigger",Qd=l.forwardRef((e,t)=>{const n=xn(lr,e.__scopeMenu),r=Ir(lr,e.__scopeMenu),o=Gd(lr,e.__scopeMenu),a=Pa(lr,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=a,d={__scopeMenu:e.__scopeMenu},h=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>h,[h]),l.useEffect(()=>{const f=c.current;return()=>{window.clearTimeout(f),u(null)}},[c,u]),s.jsx(Ea,{asChild:!0,...d,children:s.jsx(Ld,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Zd(n.open),...e,ref:rt(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:I(e.onPointerMove,xr(f=>{a.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:I(e.onPointerLeave,xr(f=>{var x,v;h();const m=(x=n.content)==null?void 0:x.getBoundingClientRect();if(m){const p=(v=n.content)==null?void 0:v.dataset.side,g=p==="right",w=g?-5:5,y=m[g?"left":"right"],N=m[g?"right":"left"];a.onPointerGraceIntentChange({area:[{x:f.clientX+w,y:f.clientY},{x:y,y:m.top},{x:N,y:m.top},{x:N,y:m.bottom},{x:y,y:m.bottom}],side:p}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(f),f.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:I(e.onKeyDown,f=>{var x;const m=a.searchRef.current!=="";e.disabled||m&&f.key===" "||vy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(x=n.content)==null||x.focus(),f.preventDefault())})})})});Qd.displayName=lr;var Yd="MenuSubContent",Xd=l.forwardRef((e,t)=>{const n=Id(Ue,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,a=xn(Ue,e.__scopeMenu),i=Ir(Ue,e.__scopeMenu),c=Gd(Yd,e.__scopeMenu),u=l.useRef(null),d=ce(t,u);return s.jsx(pr.Provider,{scope:e.__scopeMenu,children:s.jsx(Ve,{present:r||a.open,children:s.jsx(pr.Slot,{scope:e.__scopeMenu,children:s.jsx(ka,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:d,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var f;i.isUsingKeyboardRef.current&&((f=u.current)==null||f.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:I(e.onFocusOutside,h=>{h.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:I(e.onEscapeKeyDown,h=>{i.onClose(),h.preventDefault()}),onKeyDown:I(e.onKeyDown,h=>{var x;const f=h.currentTarget.contains(h.target),m=yy[i.dir].includes(h.key);f&&m&&(a.onOpenChange(!1),(x=c.trigger)==null||x.focus(),h.preventDefault())})})})})})});Xd.displayName=Yd;function Zd(e){return e?"open":"closed"}function us(e){return e==="indeterminate"}function Ma(e){return us(e)?"indeterminate":e?"checked":"unchecked"}function Fy(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Uy(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=$y(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const u=i.find(d=>d.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function Vy(e,t){const{x:n,y:r}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],u=t[i],d=c.x,h=c.y,f=u.x,m=u.y;h>r!=m>r&&n<(f-d)*(r-h)/(m-h)+d&&(o=!o)}return o}function By(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Vy(n,t)}function xr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ky=_d,Hy=Ea,qy=Od,Wy=Dd,Gy=Ta,Qy=zd,Yy=Is,Xy=Fd,Zy=Ud,Jy=Bd,eb=Hd,tb=qd,nb=Wd,rb=Qd,sb=Xd,Os="DropdownMenu",[ob]=ot(Os,[Ad]),Re=Ad(),[ab,Jd]=ob(Os),eu=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,u=Re(t),d=l.useRef(null),[h,f]=Lt({prop:o,defaultProp:a??!1,onChange:i,caller:Os});return s.jsx(ab,{scope:t,triggerId:we(),triggerRef:d,contentId:we(),open:h,onOpenChange:f,onOpenToggle:l.useCallback(()=>f(m=>!m),[f]),modal:c,children:s.jsx(Ky,{...u,open:h,onOpenChange:f,dir:r,modal:c,children:n})})};eu.displayName=Os;var tu="DropdownMenuTrigger",nu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,a=Jd(tu,n),i=Re(n);return s.jsx(Hy,{asChild:!0,...i,children:s.jsx(W.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:rt(t,a.triggerRef),onPointerDown:I(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:I(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});nu.displayName=tu;var ib="DropdownMenuPortal",ru=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Re(t);return s.jsx(qy,{...r,...n})};ru.displayName=ib;var su="DropdownMenuContent",ou=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Jd(su,n),a=Re(n),i=l.useRef(!1);return s.jsx(Wy,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...r,ref:t,onCloseAutoFocus:I(e.onCloseAutoFocus,c=>{var u;i.current||(u=o.triggerRef.current)==null||u.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:I(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!o.modal||h)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ou.displayName=su;var cb="DropdownMenuGroup",lb=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Gy,{...o,...r,ref:t})});lb.displayName=cb;var db="DropdownMenuLabel",au=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Qy,{...o,...r,ref:t})});au.displayName=db;var ub="DropdownMenuItem",iu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Yy,{...o,...r,ref:t})});iu.displayName=ub;var fb="DropdownMenuCheckboxItem",cu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Xy,{...o,...r,ref:t})});cu.displayName=fb;var hb="DropdownMenuRadioGroup",mb=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Zy,{...o,...r,ref:t})});mb.displayName=hb;var pb="DropdownMenuRadioItem",lu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(Jy,{...o,...r,ref:t})});lu.displayName=pb;var xb="DropdownMenuItemIndicator",du=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(eb,{...o,...r,ref:t})});du.displayName=xb;var gb="DropdownMenuSeparator",uu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(tb,{...o,...r,ref:t})});uu.displayName=gb;var vb="DropdownMenuArrow",yb=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(nb,{...o,...r,ref:t})});yb.displayName=vb;var bb="DropdownMenuSubTrigger",fu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(rb,{...o,...r,ref:t})});fu.displayName=bb;var wb="DropdownMenuSubContent",hu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Re(n);return s.jsx(sb,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});hu.displayName=wb;var Nb=eu,jb=nu,Cb=ru,mu=ou,pu=au,xu=iu,gu=cu,vu=lu,yu=du,bu=uu,wu=fu,Nu=hu;const _a=Nb,Ia=jb,Sb=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>s.jsxs(wu,{ref:o,className:k("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-zinc-100 data-[state=open]:bg-zinc-100 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,s.jsx(vc,{className:"ml-auto"})]}));Sb.displayName=wu.displayName;const Eb=l.forwardRef(({className:e,...t},n)=>s.jsx(Nu,{ref:n,className:k("z-50 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white p-1 text-zinc-900 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}));Eb.displayName=Nu.displayName;const Ds=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(Cb,{children:s.jsx(mu,{ref:r,sideOffset:t,className:k("z-50 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white p-1 text-zinc-900 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})}));Ds.displayName=mu.displayName;const mt=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(xu,{ref:r,className:k("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-zinc-100 focus:text-zinc-900","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n}));mt.displayName=xu.displayName;const Rb=l.forwardRef(({className:e,children:t,checked:n=!1,...r},o)=>s.jsxs(gu,{ref:o,className:k("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-zinc-100 focus:text-zinc-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(yu,{children:s.jsx(Kn,{className:"h-4 w-4"})})}),t]}));Rb.displayName=gu.displayName;const Pb=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(vu,{ref:r,className:k("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-zinc-100 focus:text-zinc-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(yu,{children:s.jsx(Wh,{className:"h-2 w-2 fill-current"})})}),t]}));Pb.displayName=vu.displayName;const kb=l.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(pu,{ref:r,className:k("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",t&&"pl-8",e),...n}));kb.displayName=pu.displayName;const zs=l.forwardRef(({className:e,...t},n)=>s.jsx(bu,{ref:n,className:k("-mx-1 my-1 h-px bg-zinc-100",e),...t}));zs.displayName=bu.displayName;const Tb=[{label:"All",value:"all"},{label:"Pending",value:"pending"},{label:"Confirmed",value:"confirmed"},{label:"Processing",value:"processing"},{label:"Shipped",value:"shipped"},{label:"Delivered",value:"delivered"},{label:"Cancelled",value:"cancelled"},{label:"Refunded",value:"refunded"},{label:"Partially refunded",value:"partially_refunded"}],Ab={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"};function Mb(){const e=vt(),[t,n]=l.useState("all"),[r,o]=l.useState(""),[a,i]=l.useState(new Set),{data:c,isLoading:u}=Rc({status:t==="all"?void 0:t,q:r||void 0,sort:"createdAt:desc",limit:100}),d=m=>{i(x=>{const v=new Set(x);return v.has(m)?v.delete(m):v.add(m),v})},h=()=>{c&&(a.size===c.length?i(new Set):i(new Set(c.map(m=>m.id))))},f=c?a.size===c.length&&c.length>0:!1;return s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Orders"}),s.jsx("p",{className:"text-sm text-zinc-500",children:c?`${c.length} orders`:"Loading..."})]})}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[s.jsx("div",{className:"flex flex-wrap gap-1.5",children:Tb.map(m=>s.jsx("button",{onClick:()=>n(m.value),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===m.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:m.label},m.value))}),s.jsxs("div",{className:"flex flex-1 items-center gap-2 sm:justify-end",children:[s.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[s.jsx(Hn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),s.jsx(be,{placeholder:"Search orders...",value:r,onChange:m=>o(m.target.value),className:"pl-9 h-8 text-sm"})]}),s.jsxs(pe,{variant:"outline",size:"sm",className:"gap-1.5",children:[s.jsx(Xh,{className:"h-3.5 w-3.5"}),"Filter"]})]})]}),a.size>0&&s.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-blue-200 bg-blue-50 px-4 py-2.5",children:[s.jsxs("span",{className:"text-sm font-medium text-blue-700",children:[a.size," selected"]}),s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsxs(pe,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-blue-200 text-blue-700 hover:bg-blue-100",children:[s.jsx(Bh,{className:"h-3.5 w-3.5"}),"Confirm All"]}),s.jsxs(pe,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-red-200 text-red-600 hover:bg-red-50",children:[s.jsx(jc,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:u?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>s.jsx(ge,{className:"h-11 w-full"},x))}):c!=null&&c.length?s.jsxs(Xn,{children:[s.jsx(Zn,{children:s.jsxs(Ge,{children:[s.jsx(re,{className:"w-10 pl-4",children:s.jsx(Oo,{checked:f,onCheckedChange:h,"aria-label":"Select all"})}),s.jsx(re,{children:"Order #"}),s.jsx(re,{children:"Customer"}),s.jsx(re,{children:"Status"}),s.jsx(re,{children:"Payment"}),s.jsx(re,{className:"text-center",children:"Items"}),s.jsx(re,{className:"text-right",children:"Total"}),s.jsx(re,{className:"text-right",children:"Date"}),s.jsx(re,{className:"w-10",children:s.jsx("span",{className:"sr-only",children:"Actions"})})]})}),s.jsx(Jn,{children:c.map(m=>s.jsxs(Ge,{"data-testid":q("orders","row",m.orderNumber),"data-state":a.has(m.id)?"selected":void 0,className:k("cursor-pointer",a.has(m.id)&&"bg-blue-50/50"),children:[s.jsx(se,{className:"pl-4",onClick:x=>x.stopPropagation(),children:s.jsx(Oo,{checked:a.has(m.id),onCheckedChange:()=>d(m.id),"aria-label":`Select order ${m.orderNumber}`})}),s.jsxs(se,{className:"font-mono text-sm font-medium text-blue-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:["#",m.orderNumber]}),s.jsx(se,{className:"text-zinc-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:s.jsx("div",{className:"truncate max-w-[180px]",children:m.email})}),s.jsx(se,{onClick:()=>e(`/orders/${m.orderNumber}`),children:s.jsx($n,{status:m.status})}),s.jsx(se,{className:"text-sm text-zinc-600",onClick:()=>e(`/orders/${m.orderNumber}`),"data-testid":q("orders","payment",m.orderNumber),children:Ab[e0(m)]}),s.jsx(se,{className:"text-center text-zinc-500",onClick:()=>e(`/orders/${m.orderNumber}`),children:m.lineItems.length}),s.jsx(se,{className:"text-right font-mono text-sm",onClick:()=>e(`/orders/${m.orderNumber}`),children:me(m.totalMinor,m.currency)}),s.jsx(se,{className:"text-right text-sm text-zinc-400",onClick:()=>e(`/orders/${m.orderNumber}`),children:it(m.createdAt)}),s.jsx(se,{onClick:x=>x.stopPropagation(),children:s.jsxs(_a,{children:[s.jsx(Ia,{asChild:!0,children:s.jsx(pe,{variant:"ghost",size:"icon","aria-label":`Actions for order ${m.orderNumber}`,className:"h-8 w-8 text-zinc-400",children:s.jsx(yc,{className:"h-4 w-4"})})}),s.jsxs(Ds,{align:"end",children:[s.jsx(mt,{onClick:()=>e(`/orders/${m.orderNumber}`),children:"View details"}),s.jsx(zs,{}),s.jsx(mt,{className:"text-red-600",children:"Cancel order"})]})]})})]},m.id))})]}):s.jsx(Yn,{icon:s.jsx(cn,{className:"h-5 w-5"}),title:"No orders found",description:r||t!=="all"?"Try adjusting your filters.":"Orders will appear here as they come in."})})]})}const _b={breadcrumb:()=>"Orders"};var Ls="Tabs",[Ib]=ot(Ls,[Ms]),ju=Ms(),[Ob,Oa]=Ib(Ls),Cu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:u="automatic",...d}=e,h=As(c),[f,m]=Lt({prop:r,onChange:o,defaultProp:a??"",caller:Ls});return s.jsx(Ob,{scope:n,baseId:we(),value:f,onValueChange:m,orientation:i,dir:h,activationMode:u,children:s.jsx(W.div,{dir:h,"data-orientation":i,...d,ref:t})})});Cu.displayName=Ls;var Su="TabsList",Eu=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,a=Oa(Su,n),i=ju(n);return s.jsx(Pd,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(W.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});Eu.displayName=Su;var Ru="TabsTrigger",Pu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...a}=e,i=Oa(Ru,n),c=ju(n),u=Au(i.baseId,r),d=Mu(i.baseId,r),h=r===i.value;return s.jsx(kd,{asChild:!0,...c,focusable:!o,active:h,children:s.jsx(W.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...a,ref:t,onMouseDown:I(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(r):f.preventDefault()}),onKeyDown:I(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(r)}),onFocus:I(e.onFocus,()=>{const f=i.activationMode!=="manual";!h&&!o&&f&&i.onValueChange(r)})})})});Pu.displayName=Ru;var ku="TabsContent",Tu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:a,...i}=e,c=Oa(ku,n),u=Au(c.baseId,r),d=Mu(c.baseId,r),h=r===c.value,f=l.useRef(h);return l.useEffect(()=>{const m=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(Ve,{present:o||h,children:({present:m})=>s.jsx(W.div,{"data-state":h?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:m&&a})})});Tu.displayName=ku;function Au(e,t){return`${e}-trigger-${t}`}function Mu(e,t){return`${e}-content-${t}`}var Db=Cu,_u=Eu,Iu=Pu,Ou=Tu;const Du=Db,Da=l.forwardRef(({className:e,...t},n)=>s.jsx(_u,{ref:n,className:k("inline-flex h-9 items-center justify-center rounded-lg bg-zinc-100 p-1 text-zinc-500",e),...t}));Da.displayName=_u.displayName;const Wt=l.forwardRef(({className:e,...t},n)=>s.jsx(Iu,{ref:n,className:k("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-white transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","data-[state=active]:bg-white data-[state=active]:text-zinc-900 data-[state=active]:shadow-sm",e),...t}));Wt.displayName=Iu.displayName;const Gt=l.forwardRef(({className:e,...t},n)=>s.jsx(Ou,{ref:n,className:k("mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",e),...t}));Gt.displayName=Ou.displayName;function Ii(e,[t,n]){return Math.min(n,Math.max(t,e))}var zu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),zb="VisuallyHidden",Lb=l.forwardRef((e,t)=>s.jsx(W.span,{...e,ref:t,style:{...zu,...e.style}}));Lb.displayName=zb;var Fb=[" ","Enter","ArrowUp","ArrowDown"],$b=[" ","Enter"],hn="Select",[Fs,$s,Ub]=Sa(hn),[er]=ot(hn,[Ub,Qn]),Us=Qn(),[Vb,Vt]=er(hn),[Bb,Kb]=er(hn),Lu=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:u,dir:d,name:h,autoComplete:f,disabled:m,required:x,form:v}=e,p=Us(t),[g,w]=l.useState(null),[y,N]=l.useState(null),[j,C]=l.useState(!1),E=As(d),[S,P]=Lt({prop:r,defaultProp:o??!1,onChange:a,caller:hn}),[D,O]=Lt({prop:i,defaultProp:c,onChange:u,caller:hn}),$=l.useRef(null),_=g?v||!!g.closest("form"):!0,[G,U]=l.useState(new Set),X=Array.from(G).map(V=>V.props.value).join(";");return s.jsx(la,{...p,children:s.jsxs(Vb,{required:x,scope:t,trigger:g,onTriggerChange:w,valueNode:y,onValueNodeChange:N,valueNodeHasChildren:j,onValueNodeHasChildrenChange:C,contentId:we(),value:D,onValueChange:O,open:S,onOpenChange:P,dir:E,triggerPointerDownPosRef:$,disabled:m,children:[s.jsx(Fs.Provider,{scope:t,children:s.jsx(Bb,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(V=>{U(te=>new Set(te).add(V))},[]),onNativeOptionRemove:l.useCallback(V=>{U(te=>{const L=new Set(te);return L.delete(V),L})},[]),children:n})}),_?s.jsxs(lf,{"aria-hidden":!0,required:x,tabIndex:-1,name:h,autoComplete:f,value:D,onChange:V=>O(V.target.value),disabled:m,form:v,children:[D===void 0?s.jsx("option",{value:""}):null,Array.from(G)]},X):null]})})};Lu.displayName=hn;var Fu="SelectTrigger",$u=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,a=Us(n),i=Vt(Fu,n),c=i.disabled||r,u=ce(t,i.onTriggerChange),d=$s(n),h=l.useRef("touch"),[f,m,x]=uf(p=>{const g=d().filter(N=>!N.disabled),w=g.find(N=>N.value===i.value),y=ff(g,p,w);y!==void 0&&i.onValueChange(y.value)}),v=p=>{c||(i.onOpenChange(!0),x()),p&&(i.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return s.jsx(Ns,{asChild:!0,...a,children:s.jsx(W.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":df(i.value)?"":void 0,...o,ref:u,onClick:I(o.onClick,p=>{p.currentTarget.focus(),h.current!=="mouse"&&v(p)}),onPointerDown:I(o.onPointerDown,p=>{h.current=p.pointerType;const g=p.target;g.hasPointerCapture(p.pointerId)&&g.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(v(p),p.preventDefault())}),onKeyDown:I(o.onKeyDown,p=>{const g=f.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&m(p.key),!(g&&p.key===" ")&&Fb.includes(p.key)&&(v(),p.preventDefault())})})})});$u.displayName=Fu;var Uu="SelectValue",Vu=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:a,placeholder:i="",...c}=e,u=Vt(Uu,n),{onValueNodeHasChildrenChange:d}=u,h=a!==void 0,f=ce(t,u.onValueNodeChange);return Ce(()=>{d(h)},[d,h]),s.jsx(W.span,{...c,ref:f,style:{pointerEvents:"none"},children:df(u.value)?s.jsx(s.Fragment,{children:i}):a})});Vu.displayName=Uu;var Hb="SelectIcon",Bu=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(W.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Bu.displayName=Hb;var qb="SelectPortal",Ku=e=>s.jsx(Pr,{asChild:!0,...e});Ku.displayName=qb;var mn="SelectContent",Hu=l.forwardRef((e,t)=>{const n=Vt(mn,e.__scopeSelect),[r,o]=l.useState();if(Ce(()=>{o(new DocumentFragment)},[]),!n.open){const a=r;return a?Cr.createPortal(s.jsx(qu,{scope:e.__scopeSelect,children:s.jsx(Fs.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),a):null}return s.jsx(Wu,{...e,ref:t})});Hu.displayName=mn;var Be=10,[qu,Bt]=er(mn),Wb="SelectContentImpl",Gb=ln("SelectContent.RemoveScroll"),Wu=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:m,collisionPadding:x,sticky:v,hideWhenDetached:p,avoidCollisions:g,...w}=e,y=Vt(mn,n),[N,j]=l.useState(null),[C,E]=l.useState(null),S=ce(t,A=>j(A)),[P,D]=l.useState(null),[O,$]=l.useState(null),_=$s(n),[G,U]=l.useState(!1),X=l.useRef(!1);l.useEffect(()=>{if(N)return js(N)},[N]),gs();const V=l.useCallback(A=>{const[Q,...Y]=_().map(fe=>fe.ref.current),[oe]=Y.slice(-1),ue=document.activeElement;for(const fe of A)if(fe===ue||(fe==null||fe.scrollIntoView({block:"nearest"}),fe===Q&&C&&(C.scrollTop=0),fe===oe&&C&&(C.scrollTop=C.scrollHeight),fe==null||fe.focus(),document.activeElement!==ue))return},[_,C]),te=l.useCallback(()=>V([P,N]),[V,P,N]);l.useEffect(()=>{G&&te()},[G,te]);const{onOpenChange:L,triggerPointerDownPosRef:T}=y;l.useEffect(()=>{if(N){let A={x:0,y:0};const Q=oe=>{var ue,fe;A={x:Math.abs(Math.round(oe.pageX)-(((ue=T.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((fe=T.current)==null?void 0:fe.y)??0))}},Y=oe=>{A.x<=10&&A.y<=10?oe.preventDefault():N.contains(oe.target)||L(!1),document.removeEventListener("pointermove",Q),T.current=null};return T.current!==null&&(document.addEventListener("pointermove",Q),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Q),document.removeEventListener("pointerup",Y,{capture:!0})}}},[N,L,T]),l.useEffect(()=>{const A=()=>L(!1);return window.addEventListener("blur",A),window.addEventListener("resize",A),()=>{window.removeEventListener("blur",A),window.removeEventListener("resize",A)}},[L]);const[ae,ie]=uf(A=>{const Q=_().filter(ue=>!ue.disabled),Y=Q.find(ue=>ue.ref.current===document.activeElement),oe=ff(Q,A,Y);oe&&setTimeout(()=>oe.ref.current.focus())}),R=l.useCallback((A,Q,Y)=>{const oe=!X.current&&!Y;(y.value!==void 0&&y.value===Q||oe)&&(D(A),oe&&(X.current=!0))},[y.value]),B=l.useCallback(()=>N==null?void 0:N.focus(),[N]),K=l.useCallback((A,Q,Y)=>{const oe=!X.current&&!Y;(y.value!==void 0&&y.value===Q||oe)&&$(A)},[y.value]),z=r==="popper"?Lo:Gu,Z=z===Lo?{side:c,sideOffset:u,align:d,alignOffset:h,arrowPadding:f,collisionBoundary:m,collisionPadding:x,sticky:v,hideWhenDetached:p,avoidCollisions:g}:{};return s.jsx(qu,{scope:n,content:N,viewport:C,onViewportChange:E,itemRefCallback:R,selectedItem:P,onItemLeave:B,itemTextRefCallback:K,focusSelectedItem:te,selectedItemText:O,position:r,isPositioned:G,searchRef:ae,children:s.jsx(kr,{as:Gb,allowPinchZoom:!0,children:s.jsx(Er,{asChild:!0,trapped:y.open,onMountAutoFocus:A=>{A.preventDefault()},onUnmountAutoFocus:I(o,A=>{var Q;(Q=y.trigger)==null||Q.focus({preventScroll:!0}),A.preventDefault()}),children:s.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:A=>A.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:s.jsx(z,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:A=>A.preventDefault(),...w,...Z,onPlaced:()=>U(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:I(w.onKeyDown,A=>{const Q=A.ctrlKey||A.altKey||A.metaKey;if(A.key==="Tab"&&A.preventDefault(),!Q&&A.key.length===1&&ie(A.key),["ArrowUp","ArrowDown","Home","End"].includes(A.key)){let oe=_().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(A.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(A.key)){const ue=A.target,fe=oe.indexOf(ue);oe=oe.slice(fe+1)}setTimeout(()=>V(oe)),A.preventDefault()}})})})})})})});Wu.displayName=Wb;var Qb="SelectItemAlignedPosition",Gu=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,a=Vt(mn,n),i=Bt(mn,n),[c,u]=l.useState(null),[d,h]=l.useState(null),f=ce(t,S=>h(S)),m=$s(n),x=l.useRef(!1),v=l.useRef(!0),{viewport:p,selectedItem:g,selectedItemText:w,focusSelectedItem:y}=i,N=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&p&&g&&w){const S=a.trigger.getBoundingClientRect(),P=d.getBoundingClientRect(),D=a.valueNode.getBoundingClientRect(),O=w.getBoundingClientRect();if(a.dir!=="rtl"){const ue=O.left-P.left,fe=D.left-ue,Me=S.left-fe,Ye=S.width+Me,tr=Math.max(Ye,P.width),nr=window.innerWidth-Be,rr=Ii(fe,[Be,Math.max(Be,nr-tr)]);c.style.minWidth=Ye+"px",c.style.left=rr+"px"}else{const ue=P.right-O.right,fe=window.innerWidth-D.right-ue,Me=window.innerWidth-S.right-fe,Ye=S.width+Me,tr=Math.max(Ye,P.width),nr=window.innerWidth-Be,rr=Ii(fe,[Be,Math.max(Be,nr-tr)]);c.style.minWidth=Ye+"px",c.style.right=rr+"px"}const $=m(),_=window.innerHeight-Be*2,G=p.scrollHeight,U=window.getComputedStyle(d),X=parseInt(U.borderTopWidth,10),V=parseInt(U.paddingTop,10),te=parseInt(U.borderBottomWidth,10),L=parseInt(U.paddingBottom,10),T=X+V+G+L+te,ae=Math.min(g.offsetHeight*5,T),ie=window.getComputedStyle(p),R=parseInt(ie.paddingTop,10),B=parseInt(ie.paddingBottom,10),K=S.top+S.height/2-Be,z=_-K,Z=g.offsetHeight/2,A=g.offsetTop+Z,Q=X+V+A,Y=T-Q;if(Q<=K){const ue=$.length>0&&g===$[$.length-1].ref.current;c.style.bottom="0px";const fe=d.clientHeight-p.offsetTop-p.offsetHeight,Me=Math.max(z,Z+(ue?B:0)+fe+te),Ye=Q+Me;c.style.height=Ye+"px"}else{const ue=$.length>0&&g===$[0].ref.current;c.style.top="0px";const Me=Math.max(K,X+p.offsetTop+(ue?R:0)+Z)+Y;c.style.height=Me+"px",p.scrollTop=Q-K+p.offsetTop}c.style.margin=`${Be}px 0`,c.style.minHeight=ae+"px",c.style.maxHeight=_+"px",r==null||r(),requestAnimationFrame(()=>x.current=!0)}},[m,a.trigger,a.valueNode,c,d,p,g,w,a.dir,r]);Ce(()=>N(),[N]);const[j,C]=l.useState();Ce(()=>{d&&C(window.getComputedStyle(d).zIndex)},[d]);const E=l.useCallback(S=>{S&&v.current===!0&&(N(),y==null||y(),v.current=!1)},[N,y]);return s.jsx(Xb,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:x,onScrollButtonChange:E,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:s.jsx(W.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Gu.displayName=Qb;var Yb="SelectPopperPosition",Lo=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Be,...a}=e,i=Us(n);return s.jsx(da,{...i,...a,ref:t,align:r,collisionPadding:o,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)"}})});Lo.displayName=Yb;var[Xb,za]=er(mn,{}),Fo="SelectViewport",Qu=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,a=Bt(Fo,n),i=za(Fo,n),c=ce(t,a.onViewportChange),u=l.useRef(0);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(Fs.Slot,{scope:n,children:s.jsx(W.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:I(o.onScroll,d=>{const h=d.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const x=Math.abs(u.current-h.scrollTop);if(x>0){const v=window.innerHeight-Be*2,p=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),w=Math.max(p,g);if(w<v){const y=w+x,N=Math.min(v,y),j=y-N;f.style.height=N+"px",f.style.bottom==="0px"&&(h.scrollTop=j>0?j:0,f.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});Qu.displayName=Fo;var Yu="SelectGroup",[Zb,Jb]=er(Yu),ew=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=we();return s.jsx(Zb,{scope:n,id:o,children:s.jsx(W.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ew.displayName=Yu;var Xu="SelectLabel",Zu=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Jb(Xu,n);return s.jsx(W.div,{id:o.id,...r,ref:t})});Zu.displayName=Xu;var fs="SelectItem",[tw,Ju]=er(fs),ef=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:a,...i}=e,c=Vt(fs,n),u=Bt(fs,n),d=c.value===r,[h,f]=l.useState(a??""),[m,x]=l.useState(!1),v=ce(t,y=>{var N;return(N=u.itemRefCallback)==null?void 0:N.call(u,y,r,o)}),p=we(),g=l.useRef("touch"),w=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(tw,{scope:n,value:r,disabled:o,textId:p,isSelected:d,onItemTextChange:l.useCallback(y=>{f(N=>N||((y==null?void 0:y.textContent)??"").trim())},[]),children:s.jsx(Fs.ItemSlot,{scope:n,value:r,disabled:o,textValue:h,children:s.jsx(W.div,{role:"option","aria-labelledby":p,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:I(i.onFocus,()=>x(!0)),onBlur:I(i.onBlur,()=>x(!1)),onClick:I(i.onClick,()=>{g.current!=="mouse"&&w()}),onPointerUp:I(i.onPointerUp,()=>{g.current==="mouse"&&w()}),onPointerDown:I(i.onPointerDown,y=>{g.current=y.pointerType}),onPointerMove:I(i.onPointerMove,y=>{var N;g.current=y.pointerType,o?(N=u.onItemLeave)==null||N.call(u):g.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:I(i.onPointerLeave,y=>{var N;y.currentTarget===document.activeElement&&((N=u.onItemLeave)==null||N.call(u))}),onKeyDown:I(i.onKeyDown,y=>{var j;((j=u.searchRef)==null?void 0:j.current)!==""&&y.key===" "||($b.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});ef.displayName=fs;var dr="SelectItemText",tf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...a}=e,i=Vt(dr,n),c=Bt(dr,n),u=Ju(dr,n),d=Kb(dr,n),[h,f]=l.useState(null),m=ce(t,w=>f(w),u.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,u.value,u.disabled)}),x=h==null?void 0:h.textContent,v=l.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:x},u.value),[u.disabled,u.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:g}=d;return Ce(()=>(p(v),()=>g(v)),[p,g,v]),s.jsxs(s.Fragment,{children:[s.jsx(W.span,{id:u.textId,...a,ref:m}),u.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Cr.createPortal(a.children,i.valueNode):null]})});tf.displayName=dr;var nf="SelectItemIndicator",rf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ju(nf,n).isSelected?s.jsx(W.span,{"aria-hidden":!0,...r,ref:t}):null});rf.displayName=nf;var $o="SelectScrollUpButton",sf=l.forwardRef((e,t)=>{const n=Bt($o,e.__scopeSelect),r=za($o,e.__scopeSelect),[o,a]=l.useState(!1),i=ce(t,r.onScrollButtonChange);return Ce(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=u.scrollTop>0;a(d)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(af,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});sf.displayName=$o;var Uo="SelectScrollDownButton",of=l.forwardRef((e,t)=>{const n=Bt(Uo,e.__scopeSelect),r=za(Uo,e.__scopeSelect),[o,a]=l.useState(!1),i=ce(t,r.onScrollButtonChange);return Ce(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;a(h)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?s.jsx(af,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});of.displayName=Uo;var af=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,a=Bt("SelectScrollButton",n),i=l.useRef(null),c=$s(n),u=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>u(),[u]),Ce(()=>{var h;const d=c().find(f=>f.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[c]),s.jsx(W.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:I(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:I(o.onPointerMove,()=>{var d;(d=a.onItemLeave)==null||d.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:I(o.onPointerLeave,()=>{u()})})}),nw="SelectSeparator",cf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(W.div,{"aria-hidden":!0,...r,ref:t})});cf.displayName=nw;var Vo="SelectArrow",rw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Us(n),a=Vt(Vo,n),i=Bt(Vo,n);return a.open&&i.position==="popper"?s.jsx(ua,{...o,...r,ref:t}):null});rw.displayName=Vo;var sw="SelectBubbleInput",lf=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),a=ce(r,o),i=pd(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(i!==t&&h){const f=new Event("change",{bubbles:!0});h.call(c,t),c.dispatchEvent(f)}},[i,t]),s.jsx(W.select,{...n,style:{...zu,...n.style},ref:a,defaultValue:t})});lf.displayName=sw;function df(e){return e===""||e===void 0}function uf(e){const t=st(e),n=l.useRef(""),r=l.useRef(0),o=l.useCallback(i=>{const c=n.current+i;t(c),function u(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}(c)},[t]),a=l.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,a]}function ff(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=ow(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const u=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function ow(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var aw=Lu,hf=$u,iw=Vu,cw=Bu,lw=Ku,mf=Hu,dw=Qu,pf=Zu,xf=ef,uw=tf,fw=rf,gf=sf,vf=of,yf=cf;const gr=aw,vr=iw,Un=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(hf,{ref:r,className:k("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm shadow-none ring-offset-white","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-0","disabled:cursor-not-allowed disabled:opacity-50","[&>span]:line-clamp-1",e),...n,children:[t,s.jsx(cw,{asChild:!0,children:s.jsx(gc,{className:"h-4 w-4 opacity-50 shrink-0"})})]}));Un.displayName=hf.displayName;const bf=l.forwardRef(({className:e,...t},n)=>s.jsx(gf,{ref:n,className:k("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Kh,{className:"h-4 w-4"})}));bf.displayName=gf.displayName;const wf=l.forwardRef(({className:e,...t},n)=>s.jsx(vf,{ref:n,className:k("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(gc,{className:"h-4 w-4"})}));wf.displayName=vf.displayName;const Vn=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>s.jsx(lw,{children:s.jsxs(mf,{ref:o,className:k("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white text-zinc-900 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:[s.jsx(bf,{}),s.jsx(dw,{className:k("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),s.jsx(wf,{})]})}));Vn.displayName=mf.displayName;const hw=l.forwardRef(({className:e,...t},n)=>s.jsx(pf,{ref:n,className:k("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",e),...t}));hw.displayName=pf.displayName;const $e=l.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(xf,{ref:r,className:k("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-zinc-100 focus:text-zinc-900","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[s.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(fw,{children:s.jsx(Kn,{className:"h-4 w-4"})})}),s.jsx(uw,{children:t})]}));$e.displayName=xf.displayName;const mw=l.forwardRef(({className:e,...t},n)=>s.jsx(yf,{ref:n,className:k("-mx-1 my-1 h-px bg-zinc-100",e),...t}));mw.displayName=yf.displayName;const Kr="record-payment",ao={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Partially Refunded"},pw={confirmed:"confirm",processing:"process",shipped:"ship",delivered:"mark-delivered",cancelled:"cancel"};function xw(e,t){return Jv[e].filter(n=>n!=="refunded"&&n!=="partially_refunded"&&n!=="confirmed"&&!(n==="cancelled"&&t>0))}function gw({orderId:e,currentStatus:t,orderNumber:n,capturedMinor:r}){const o=Ne(),{mutateAsync:a,isPending:i}=fm(),{mutateAsync:c,isPending:u}=Pc(),[d,h]=l.useState(null),f=xw(t,r),m=t==="pending"&&r===0,x=d??t,v=i||u;if(f.length===0&&!m)return s.jsx("span",{className:"text-sm text-zinc-500 font-medium capitalize",children:ao[t]});const p=async g=>{const w=g===Kr?"confirmed":g;h(w);try{g===Kr?await c({orderId:e}):await a({orderId:e,action:pw[w]??w})}catch(y){console.error("[OrderStatusSelect] status update failed",y),h(null),o.invalidateQueries({queryKey:["orders","detail",n]})}};return s.jsxs(gr,{value:x,onValueChange:g=>void p(g),disabled:v,children:[s.jsx(Un,{className:k("w-44 h-8 text-xs",v&&"opacity-50"),"aria-label":"Order status","data-testid":q("order","status-select"),children:s.jsx(vr,{})}),s.jsxs(Vn,{children:[s.jsxs($e,{value:t,disabled:!0,"data-testid":q("order","status-option",t),children:[ao[t]," (current)"]}),m&&s.jsx($e,{value:Kr,"data-testid":q("order","status-option",Kr),children:"Record payment"}),f.map(g=>s.jsx($e,{value:g,"data-testid":q("order","status-option",g),children:ao[g]},g))]})]})}function vw({entries:e}){const t=[...e].sort((n,r)=>new Date(r.timestamp).getTime()-new Date(n.timestamp).getTime());return s.jsx("div",{className:"flow-root",children:s.jsx("ul",{className:"-mb-8",children:t.map((n,r)=>s.jsx("li",{"data-testid":q("order","timeline-entry",n.toStatus),children:s.jsxs("div",{className:"relative pb-8",children:[r<t.length-1&&s.jsx("span",{className:"absolute left-4 top-5 -ml-px h-full w-0.5 bg-zinc-200","aria-hidden":"true"}),s.jsxs("div",{className:"relative flex gap-3",children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-zinc-200 bg-white",children:s.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})}),s.jsxs("div",{className:"min-w-0 flex-1 pt-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.fromStatus&&s.jsxs(s.Fragment,{children:[s.jsx($n,{status:n.fromStatus,size:"sm"}),s.jsx("span",{className:"text-zinc-400 text-xs",children:"→"})]}),s.jsx($n,{status:n.toStatus,size:"sm"})]}),n.note&&s.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:n.note}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-zinc-400",children:[s.jsx("span",{children:n.actor}),s.jsx("span",{children:"·"}),s.jsx("time",{dateTime:n.timestamp,title:Ut(n.timestamp),children:it(n.timestamp)})]})]})]})]})},n.id))})})}const on=l.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:k("flex min-h-[80px] w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm","placeholder:text-zinc-400","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),ref:n,...t}));on.displayName="Textarea";function yw({orderId:e,notes:t}){const[n,r]=l.useState(""),o=gm(),a=async i=>{i.preventDefault(),n.trim()&&(await o.mutateAsync({orderId:e,body:n.trim()}),r(""))};return s.jsxs("div",{"data-testid":q("order","notes"),children:[s.jsx("div",{className:"space-y-3",children:t.length===0?s.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...t].sort((i,c)=>new Date(c.at).getTime()-new Date(i.at).getTime()).map((i,c)=>s.jsx(bw,{note:i},c))}),s.jsxs("form",{onSubmit:i=>void a(i),className:"mt-4 flex gap-2",children:[s.jsx(on,{placeholder:"Add an internal note...",value:n,onChange:i=>r(i.target.value),rows:2,className:"flex-1 text-sm",onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),a(i))}}),s.jsx(pe,{type:"submit",size:"icon","aria-label":"Add note",disabled:!n.trim()||o.isPending,className:"self-end h-9 w-9",children:s.jsx(Nc,{className:"h-4 w-4"})})]})]})}function bw({note:e}){return s.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[s.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:e.body}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-zinc-400",children:[s.jsx("span",{className:"font-medium text-zinc-500",children:e.actor}),s.jsx("span",{children:"·"}),s.jsx("time",{dateTime:e.at,title:Ut(e.at),children:it(e.at)})]})]})}function ww(e,t){if(!(e instanceof ts))return"The refund could not be made.";const{amountMinor:n,refundableMinor:r}=e.context??{};return e.code==="refund.exceeds_captured"&&typeof n=="number"&&typeof r=="number"?`A refund of ${me(n,t)} is more than the ${me(r,t)} left to refund.`:e.message}function Nw({order:e,onClose:t}){const{refundableMinor:n,currency:r}=e.payment,[o,a]=l.useState((n/100).toFixed(2)),[i,c]=l.useState(""),[u,d]=l.useState(null),[h,f]=l.useState(()=>crypto.randomUUID()),m=l.useRef(!1),[x,v]=l.useState(!1),p=xm(),g=G0(o),w=g!==null&&g>0&&g<=n,y=async()=>{if(!(!w||g===null||m.current)){m.current=!0,v(!0),d(null);try{if((await p.mutateAsync({orderId:e.id,amountMinor:g,requestId:h,...i.trim()&&{reason:i.trim()}})).refund.status==="failed"){f(crypto.randomUUID()),d("The payment provider refused the refund.");return}t()}catch(N){d(ww(N,r))}finally{m.current=!1,v(!1)}}};return s.jsx(ed,{open:!0,onOpenChange:N=>!N&&t(),children:s.jsxs(Na,{className:"max-w-md","data-testid":q("order","refund-dialog"),children:[s.jsx(nd,{children:s.jsxs(sd,{children:["Refund Order #",e.orderNumber]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"rounded-md border border-zinc-200 p-3 bg-zinc-50",children:s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:"text-zinc-600",children:"Refundable"}),s.jsx("span",{className:"font-mono font-semibold text-zinc-900",children:me(n,r)})]})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(De,{htmlFor:"refund-amount",children:["Amount (",r,")"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(be,{id:"refund-amount",inputMode:"decimal",value:o,onChange:N=>a(N.target.value),"aria-invalid":!w,"data-testid":q("order","refund-amount")}),s.jsx(pe,{variant:"outline",type:"button",onClick:()=>a((n/100).toFixed(2)),children:"Full refund"})]}),!w&&s.jsxs("p",{className:"text-xs text-red-600",children:["Enter an amount above 0 and up to ",me(n,r),"."]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(De,{htmlFor:"refund-reason",children:"Reason (optional)"}),s.jsx(on,{id:"refund-reason",placeholder:"Enter refund reason...",value:i,onChange:N=>c(N.target.value),rows:3,"data-testid":q("order","refund-reason")})]}),u&&s.jsx("p",{role:"alert",className:"text-sm text-red-600",children:u})]}),s.jsxs(rd,{children:[s.jsx(pe,{variant:"outline",type:"button",onClick:t,children:"Cancel"}),s.jsx(pe,{variant:"destructive",type:"button",onClick:()=>void y(),disabled:!w||x,"data-testid":q("order","refund-confirm"),children:x?"Processing...":`Refund ${g!==null?me(g,r):""}`})]})]})})}const jw={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"},Cw={unpaid:"bg-zinc-100 text-zinc-700",paid:"bg-green-100 text-green-700",partially_refunded:"bg-amber-100 text-amber-700",refunded:"bg-orange-100 text-orange-700"},Sw={provider:"Payment provider",manual:"Recorded manually",import:"Imported"},Ew={pending:"Refund pending",succeeded:"Refunded",failed:"Failed"};function Rw({order:e}){const{payment:t}=e;return s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Payment"}),s.jsx("span",{className:k("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",Cw[t.state]),"data-testid":q("order","payment-state"),children:jw[t.state]})]}),s.jsxs("dl",{className:"space-y-1.5 text-sm",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("dt",{className:"text-zinc-500",children:"Captured"}),s.jsx("dd",{className:"font-mono text-zinc-700","data-testid":q("order","captured"),children:me(t.capturedMinor,t.currency)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("dt",{className:"text-zinc-500",children:"Refunded"}),s.jsx("dd",{className:"font-mono text-zinc-700","data-testid":q("order","refunded"),children:me(t.refundedMinor,t.currency)})]}),s.jsxs("div",{className:"flex justify-between font-semibold",children:[s.jsx("dt",{className:"text-zinc-700",children:"Net"}),s.jsx("dd",{className:"font-mono text-zinc-900","data-testid":q("order","net"),children:me(t.capturedMinor-t.refundedMinor,t.currency)})]}),e.captureMethod&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("dt",{className:"text-zinc-500",children:"Method"}),s.jsx("dd",{className:"text-zinc-700",children:Sw[e.captureMethod]})]}),e.paymentIntentId&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("dt",{className:"text-zinc-500",children:"Intent ID"}),s.jsx("dd",{className:"font-mono text-xs text-zinc-600 truncate max-w-[120px]",children:e.paymentIntentId})]})]}),t.refunds.length>0&&s.jsx("ul",{className:"space-y-1 border-t border-zinc-100 pt-2 text-sm",children:t.refunds.map(n=>s.jsxs("li",{className:"flex justify-between gap-2","data-testid":q("order","refund-row",n.id),children:[s.jsxs("span",{className:"text-zinc-500",children:[Ew[n.status]," · ",Ut(n.createdAt)]}),s.jsx("span",{className:"font-mono text-zinc-700",children:me(n.amountMinor,n.currency)})]},n.id))})]})}function Oi({address:e,label:t}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-1.5",children:t}),s.jsxs("div",{className:"text-sm text-zinc-600 space-y-0.5",children:[s.jsxs("p",{children:[e.firstName," ",e.lastName]}),e.company&&s.jsx("p",{children:e.company}),s.jsx("p",{children:e.addressLine1}),e.addressLine2&&s.jsx("p",{children:e.addressLine2}),s.jsxs("p",{children:[e.city,", ",e.region," ",e.postalCode]}),s.jsx("p",{children:e.country})]})]})}function Pw(){const{orderNumber:e}=Ho(),[t,n]=l.useState(!1),{data:r,isLoading:o}=dm(e??""),{data:a=[]}=um((r==null?void 0:r.id)??""),i=Pc(),c=hm(),u=mm(),d=pm();if(o)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(ge,{className:"h-8 w-40"}),s.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[s.jsxs("div",{className:"md:col-span-3 space-y-4",children:[s.jsx(ge,{className:"h-48 w-full"}),s.jsx(ge,{className:"h-32 w-full"})]}),s.jsxs("div",{className:"md:col-span-2 space-y-4",children:[s.jsx(ge,{className:"h-40 w-full"}),s.jsx(ge,{className:"h-48 w-full"})]})]})]});if(!r)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx(cn,{className:"mb-3 h-8 w-8 text-zinc-300"}),s.jsx("p",{className:"text-sm text-zinc-500",children:"Order not found"}),s.jsx(sn,{to:"/orders",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to orders"})]});const f=r.status==="pending"&&r.payment.capturedMinor===0?{label:"Record payment",icon:Xa,action:()=>void i.mutateAsync({orderId:r.id})}:r.status==="processing"?{label:"Mark Shipped",icon:Cc,action:()=>void d.mutateAsync({orderId:r.id,trackingNumber:"",carrier:""})}:r.status==="shipped"?{label:"Mark Delivered",icon:Xa,action:()=>void u.mutateAsync(r.id)}:null;return s.jsxs("div",{className:"space-y-4","data-testid":q("order","detail"),children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs(sn,{to:"/orders",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700 transition-colors",children:[s.jsx(Zo,{className:"h-4 w-4"}),"Orders"]}),s.jsx("span",{className:"text-zinc-300",children:"/"}),s.jsxs("h1",{className:"font-mono text-base font-semibold text-zinc-900",children:["#",r.orderNumber]}),s.jsx($n,{status:r.status,"data-testid":q("order","status-badge")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs(pe,{size:"sm",onClick:f.action,className:"gap-1.5",children:[s.jsx(f.icon,{className:"h-4 w-4"}),f.label]}),s.jsxs(_a,{children:[s.jsx(Ia,{asChild:!0,children:s.jsx(pe,{variant:"outline",size:"sm","data-testid":q("order","actions"),children:"Actions"})}),s.jsxs(Ds,{align:"end",className:"w-44",children:[s.jsxs(mt,{className:"gap-2",children:[s.jsx(wc,{className:"h-4 w-4"}),"Resend confirmation"]}),s.jsx(zs,{}),r.payment.refundableMinor>0&&s.jsxs(mt,{onClick:()=>n(!0),className:"gap-2","data-testid":q("order","action","refund"),children:[s.jsx(Qh,{className:"h-4 w-4"}),"Issue refund"]}),s.jsxs(mt,{onClick:()=>void c.mutateAsync({orderId:r.id}),className:"gap-2 text-red-600",disabled:r.payment.capturedMinor>0||["cancelled","refunded","delivered"].includes(r.status),children:[s.jsx(qh,{className:"h-4 w-4"}),"Cancel order"]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-zinc-500",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Za,{className:"h-3.5 w-3.5"}),"Placed ",Ut(r.createdAt)]}),s.jsx("span",{className:"text-zinc-300",children:"·"}),s.jsx(gw,{orderId:r.id,currentStatus:r.status,orderNumber:r.orderNumber,capturedMinor:r.payment.capturedMinor})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[s.jsxs("div",{className:"md:col-span-3 space-y-5",children:[s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[s.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:s.jsxs("h2",{className:"text-sm font-semibold text-zinc-900",children:["Items (",r.lineItems.length,")"]})}),s.jsx("div",{className:"divide-y divide-zinc-50",children:r.lineItems.map(m=>s.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[m.imageUrl?s.jsx("img",{src:m.imageUrl,alt:m.productName,className:"h-12 w-12 rounded border border-zinc-100 object-cover"}):s.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:s.jsx(cn,{className:"h-5 w-5 text-zinc-300"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm font-medium text-zinc-800",children:m.productName}),s.jsxs("p",{className:"text-xs text-zinc-400",children:[m.variantName," · ",m.sku]})]}),s.jsxs("div",{className:"text-right",children:[s.jsx("p",{className:"font-mono text-sm text-zinc-700",children:me(m.lineTotalMinor,r.currency)}),s.jsxs("p",{className:"text-xs text-zinc-400",children:[m.qty," × ",me(m.unitPriceMinor,r.currency)]})]})]},m.variantId))}),s.jsxs("div",{className:"border-t border-zinc-100 bg-zinc-50 px-4 py-3 space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[s.jsx("span",{children:"Subtotal"}),s.jsx("span",{className:"font-mono",children:me(r.subtotalMinor,r.currency)})]}),r.taxTotalMinor>0&&s.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[s.jsx("span",{children:"Tax"}),s.jsx("span",{className:"font-mono",children:me(r.taxTotalMinor,r.currency)})]}),r.shippingTotalMinor>0&&s.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[s.jsx("span",{children:"Shipping"}),s.jsx("span",{className:"font-mono",children:me(r.shippingTotalMinor,r.currency)})]}),r.discountTotalMinor>0&&s.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[s.jsx("span",{children:"Discount"}),s.jsxs("span",{className:"font-mono",children:["-",me(r.discountTotalMinor,r.currency)]})]}),s.jsxs("div",{className:"flex justify-between border-t border-zinc-200 pt-2 text-sm font-semibold text-zinc-800",children:[s.jsx("span",{children:"Total"}),s.jsx("span",{className:"font-mono text-base",children:me(r.totalMinor,r.currency)})]})]})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:s.jsxs(Du,{defaultValue:"notes",children:[s.jsx("div",{className:"border-b border-zinc-100 px-4 py-2",children:s.jsxs(Da,{className:"h-8",children:[s.jsxs(Wt,{value:"notes",className:"gap-1.5 text-xs",children:[s.jsx(sm,{className:"h-3.5 w-3.5"}),"Notes",a.length>0&&s.jsx("span",{className:"rounded-full bg-zinc-100 px-1.5 text-[10px]",children:a.length})]}),s.jsxs(Wt,{value:"timeline",className:"gap-1.5 text-xs","data-testid":q("order","tab","timeline"),children:[s.jsx(Za,{className:"h-3.5 w-3.5"}),"Timeline"]})]})}),s.jsx(Gt,{value:"notes",className:"p-4",children:s.jsx(yw,{orderId:r.id,notes:a})}),s.jsx(Gt,{value:"timeline",className:"p-4",children:r.history&&r.history.length>0?s.jsx(vw,{entries:r.history}):s.jsx("p",{className:"text-sm text-zinc-400 text-center py-4",children:"No history yet."})})]})})]}),s.jsxs("div",{className:"md:col-span-2 space-y-4",children:[s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Customer"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-zinc-100 text-sm font-semibold text-zinc-600",children:(r.email[0]??"?").toUpperCase()}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-zinc-800",children:r.email}),r.customerId&&s.jsx(sn,{to:`/customers/${r.customerId}`,className:"text-xs text-blue-600 hover:underline",children:"View customer →"})]})]})]}),s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-3",children:"Addresses"}),s.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[s.jsx(Oi,{address:r.shippingAddress,label:"Shipping"}),s.jsx(Oi,{address:r.billingAddress,label:"Billing"})]})]}),s.jsx(Rw,{order:r}),r.notes&&s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-amber-50 p-4",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-600 mb-1.5",children:"Order Note"}),s.jsx("p",{className:"text-sm text-amber-800",children:r.notes})]})]})]}),t&&s.jsx(Nw,{order:r,onClose:()=>n(!1)})]})}const kw={breadcrumb:e=>`#${e.orderNumber??""}`},Tw=xs("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"bg-zinc-100 text-zinc-700",secondary:"bg-zinc-200 text-zinc-800",destructive:"bg-red-100 text-red-700",outline:"border border-zinc-200 text-zinc-700",success:"bg-green-100 text-green-700",warning:"bg-amber-100 text-amber-700",info:"bg-blue-100 text-blue-700"}},defaultVariants:{variant:"default"}});function Nf({className:e,variant:t,...n}){return s.jsx("div",{className:k(Tw({variant:t}),e),...n})}function Aw(e={}){return Le({queryKey:["products","list",e],queryFn:()=>de.get("/api/admin/products",e)})}function Mw(e){return Le({queryKey:["products","detail",e],queryFn:()=>de.get(`/api/admin/products/${e}`),enabled:!!e&&e!=="new"})}function _w(){const e=Ne();return Te({mutationFn:t=>de.post("/api/admin/products",t),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function Iw(){const e=Ne();return Te({mutationFn:({id:t,data:n})=>de.patch(`/api/admin/products/${t}`,n),onSuccess:t=>{e.setQueryData(["products","detail",t.id],t),e.setQueryData(["products","detail",t.slug],t),e.invalidateQueries({queryKey:["products","list"]})}})}function Ow(){const e=Ne();return Te({mutationFn:t=>de.post(`/api/admin/products/${t}/duplicate`),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function Dw(){const e=Ne();return Te({mutationFn:t=>de.post(`/api/admin/products/${t}/archive`),onSuccess:()=>{e.invalidateQueries({queryKey:["products"]})}})}function zw(){return Te({mutationFn:({id:e,field:t,context:n})=>de.post(`/api/admin/products/${e}/enhance`,{field:t,context:n})})}const Lw=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Draft",value:"draft"},{label:"Archived",value:"archived"}],Fw={active:"success",draft:"default",archived:"secondary"};function $w(){const e=vt(),[t,n]=l.useState("all"),[r,o]=l.useState(""),{data:a,isLoading:i}=Aw({status:t==="all"?void 0:t,q:r||void 0,limit:100}),c=Ow(),u=Dw();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Products"}),s.jsx("p",{className:"text-sm text-zinc-500",children:a?`${a.length} products`:"Loading..."})]}),s.jsxs(pe,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[s.jsx(hr,{className:"h-4 w-4"}),"Add Product"]})]}),s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[s.jsx("div",{className:"flex flex-wrap gap-1.5",children:Lw.map(d=>s.jsx("button",{onClick:()=>n(d.value),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===d.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:d.label},d.value))}),s.jsxs("div",{className:"relative flex-1 sm:max-w-xs sm:ml-auto",children:[s.jsx(Hn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),s.jsx(be,{placeholder:"Search products...",value:r,onChange:d=>o(d.target.value),className:"pl-9 h-8 text-sm"})]})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:i?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:6}).map((d,h)=>s.jsx(ge,{className:"h-11 w-full"},h))}):a!=null&&a.length?s.jsxs(Xn,{children:[s.jsx(Zn,{children:s.jsxs(Ge,{children:[s.jsx(re,{className:"w-12",children:"Image"}),s.jsx(re,{children:"Name"}),s.jsx(re,{children:"Status"}),s.jsx(re,{children:"Type"}),s.jsx(re,{className:"text-right",children:"Price"}),s.jsx(re,{children:"Stock"}),s.jsx(re,{className:"text-right",children:"Updated"}),s.jsx(re,{className:"w-10"})]})}),s.jsx(Jn,{children:a.map(d=>{const h=d.media[0],f=d.variants[0],m=d.variants.reduce((p,g)=>p+g.stock,0),x=d.variants.some(p=>p.stock<=p.lowStockThreshold),v=d.variants.some(p=>p.stock===0);return s.jsxs(Ge,{"data-testid":q("products","row",d.id),className:"cursor-pointer",onClick:()=>e(`/products/${d.slug}`),children:[s.jsx(se,{children:h?s.jsx("img",{src:h.url,alt:h.altText,className:"h-8 w-8 rounded border border-zinc-100 object-cover"}):s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:s.jsx(cn,{className:"h-3.5 w-3.5 text-zinc-300"})})}),s.jsx(se,{children:s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-zinc-800",children:d.name}),s.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:d.slug})]})}),s.jsx(se,{children:s.jsx(Nf,{variant:Fw[d.status],className:"capitalize",children:d.status})}),s.jsx(se,{className:"text-xs text-zinc-500 capitalize",children:d.type}),s.jsx(se,{className:"text-right font-mono text-sm",children:f?me(f.priceMinor,"GBP"):"—"}),s.jsx(se,{children:s.jsx("span",{className:k("text-sm font-mono font-medium",v?"text-red-600":x?"text-amber-600":"text-zinc-700"),children:m})}),s.jsx(se,{className:"text-right text-xs text-zinc-400",children:it(d.updatedAt)}),s.jsx(se,{onClick:p=>p.stopPropagation(),children:s.jsxs(_a,{children:[s.jsx(Ia,{asChild:!0,children:s.jsx(pe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-zinc-400 opacity-0 group-hover:opacity-100",children:s.jsx(yc,{className:"h-4 w-4"})})}),s.jsxs(Ds,{align:"end",children:[s.jsx(mt,{onClick:()=>e(`/products/${d.slug}`),children:"Edit"}),s.jsxs(mt,{onClick:()=>void c.mutateAsync(d.id),className:"gap-2",children:[s.jsx(Gh,{className:"h-3.5 w-3.5"}),"Duplicate"]}),s.jsx(zs,{}),s.jsxs(mt,{onClick:()=>void u.mutateAsync(d.id),className:"gap-2 text-zinc-500",children:[s.jsx($h,{className:"h-3.5 w-3.5"}),"Archive"]})]})]})})]},d.id)})})]}):s.jsx(Yn,{icon:s.jsx(cn,{className:"h-5 w-5"}),title:"No products found",description:r?"Try a different search.":"Create your first product.",action:s.jsxs(pe,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[s.jsx(hr,{className:"h-4 w-4"}),"Add Product"]})})})]})}const Uw={breadcrumb:()=>"Products"};function Vw(e){return{id:`new-${crypto.randomUUID()}`,productId:e,sku:"",name:"New Variant",priceMinor:0,compareAtPriceMinor:null,weightGrams:null,dimensions:null,stock:0,lowStockThreshold:5,options:[],status:"active",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}function Bw({productId:e,variants:t,onChange:n,currency:r}){const[o,a]=l.useState(t.map(d=>({...d,_priceDisplay:(d.priceMinor/100).toFixed(2)}))),i=(d,h,f)=>{a(m=>{const x=m.map(v=>{if(v.id!==d)return v;if(h==="_priceDisplay"){const p=parseFloat(f);return{...v,_priceDisplay:f,priceMinor:isNaN(p)?v.priceMinor:Math.round(p*100)}}return{...v,[h]:f}});return n(x.map(({_priceDisplay:v,...p})=>p)),x})},c=()=>{const d=Vw(e),h=[...o,{...d,_priceDisplay:"0.00"}];a(h),n(h.map(({_priceDisplay:f,...m})=>m))},u=d=>{const h=o.filter(f=>f.id!==d);a(h),n(h.map(({_priceDisplay:f,...m})=>m))};return s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"SKU"}),s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Name"}),s.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Price"}),s.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Stock"}),s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Status"}),s.jsx("th",{className:"w-10 px-3 py-2"})]})}),s.jsxs("tbody",{children:[o.length===0&&s.jsx("tr",{children:s.jsx("td",{colSpan:6,className:"px-3 py-6 text-center text-sm text-zinc-400",children:"No variants yet. Add one below."})}),o.map(d=>s.jsxs("tr",{className:"border-b border-zinc-100 last:border-0","data-testid":q("product","variant-row",d.id),children:[s.jsx("td",{className:"px-3 py-2",children:s.jsx(be,{value:d.sku,onChange:h=>i(d.id,"sku",h.target.value),placeholder:"SKU-001",className:"h-7 font-mono text-xs w-28"})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(be,{value:d.name,onChange:h=>i(d.id,"name",h.target.value),placeholder:"Variant name",className:"h-7 text-xs"})}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx("span",{className:"text-xs text-zinc-400",children:r}),s.jsx(be,{value:d._priceDisplay,onChange:h=>i(d.id,"_priceDisplay",h.target.value),onBlur:h=>{const f=parseFloat(h.target.value);isNaN(f)||i(d.id,"_priceDisplay",f.toFixed(2))},className:"h-7 w-20 text-right font-mono text-xs"})]})}),s.jsx("td",{className:"px-3 py-2 text-right",children:s.jsx(be,{type:"number",value:d.stock,onChange:h=>i(d.id,"stock",parseInt(h.target.value)||0),className:"h-7 w-16 text-right font-mono text-xs ml-auto",min:0})}),s.jsx("td",{className:"px-3 py-2",children:s.jsxs(gr,{value:d.status,onValueChange:h=>i(d.id,"status",h),children:[s.jsx(Un,{className:"h-7 w-24 text-xs",children:s.jsx(vr,{})}),s.jsxs(Vn,{children:[s.jsx($e,{value:"active",children:"Active"}),s.jsx($e,{value:"inactive",children:"Inactive"})]})]})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx("button",{onClick:()=>u(d.id),className:"rounded p-1 text-zinc-400 hover:bg-red-50 hover:text-red-500 transition-colors",title:"Remove variant",children:s.jsx(jc,{className:"h-3.5 w-3.5"})})})]},d.id))]})]})}),s.jsxs("div",{className:"flex items-center justify-between pt-1",children:[s.jsxs("p",{className:"text-xs text-zinc-400",children:[o.length," variant",o.length!==1?"s":"",o.length>0&&s.jsxs(s.Fragment,{children:[" · Total stock: ",o.reduce((d,h)=>d+h.stock,0)]})]}),s.jsxs(pe,{variant:"outline",size:"sm",onClick:c,className:"gap-1.5",children:[s.jsx(hr,{className:"h-3.5 w-3.5"}),"Add Variant"]})]})]})}function Kw({media:e,onChange:t}){const[n,r]=l.useState(""),[o,a]=l.useState(""),[i,c]=l.useState(!1),[u,d]=l.useState(null),h=()=>{if(!n.trim())return;const v=[...e,{url:n.trim(),altText:o.trim(),position:e.length}];t(v),r(""),a("")},f=v=>{const p=e.filter((g,w)=>w!==v).map((g,w)=>({...g,position:w}));t(p)},m=v=>{const p=e[v];if(!p)return;const g=[p,...e.filter((w,y)=>y!==v)].map((w,y)=>({...w,position:y}));t(g)},x=(v,p)=>{const g=e.map((w,y)=>y===v?{...w,altText:p}:w);t(g)};return s.jsxs("div",{className:"space-y-3",children:[e.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:e.map((v,p)=>s.jsxs("div",{className:k("group relative rounded-md border bg-zinc-50 overflow-hidden",p===0?"border-blue-300 ring-1 ring-blue-300":"border-zinc-200"),children:[s.jsx("div",{className:"aspect-square flex items-center justify-center",children:v.url?s.jsx("img",{src:v.url,alt:v.altText||"Product image",className:"h-full w-full object-cover",onError:g=>{g.target.style.display="none"}}):s.jsx(Jh,{className:"h-6 w-6 text-zinc-300"})}),p===0&&s.jsx("div",{className:"absolute left-1 top-1 rounded bg-blue-500 px-1 py-0.5 text-[9px] font-semibold text-white",children:"Primary"}),s.jsxs("div",{className:"absolute inset-0 flex items-center justify-center gap-1 bg-black/40 opacity-0 transition-opacity group-hover:opacity-100",children:[p!==0&&s.jsx("button",{onClick:()=>m(p),className:"rounded bg-white/90 p-1 text-zinc-700 hover:bg-white",title:"Set as primary",children:s.jsx(lm,{className:"h-3 w-3"})}),s.jsx("button",{onClick:()=>f(p),className:"rounded bg-white/90 p-1 text-red-600 hover:bg-white",title:"Remove",children:s.jsx(ps,{className:"h-3 w-3"})})]}),s.jsx("div",{className:"border-t border-zinc-100 px-1.5 py-1",children:u===p?s.jsx("input",{autoFocus:!0,value:v.altText,onChange:g=>x(p,g.target.value),onBlur:()=>d(null),className:"w-full text-[10px] bg-transparent border-b border-zinc-300 outline-none",placeholder:"Alt text..."}):s.jsx("button",{onClick:()=>d(p),className:"w-full text-left text-[10px] text-zinc-400 hover:text-zinc-600 truncate",children:v.altText||"Add alt text"})})]},p))}),s.jsx("div",{className:k("rounded-md border-2 border-dashed p-4 transition-colors",i?"border-blue-400 bg-blue-50":"border-zinc-200"),onDragOver:v=>{v.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:v=>{v.preventDefault(),c(!1)},children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-zinc-500 text-center",children:"Add image by URL"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1 space-y-1.5",children:[s.jsx(De,{className:"text-xs",children:"Image URL"}),s.jsx(be,{value:n,onChange:v=>r(v.target.value),placeholder:"https://cdn.example.com/image.jpg",className:"text-xs h-8",onKeyDown:v=>v.key==="Enter"&&h()})]}),s.jsxs("div",{className:"flex-1 space-y-1.5",children:[s.jsx(De,{className:"text-xs",children:"Alt Text"}),s.jsx(be,{value:o,onChange:v=>a(v.target.value),placeholder:"Describe the image",className:"text-xs h-8",onKeyDown:v=>v.key==="Enter"&&h()})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(pe,{type:"button",size:"sm",onClick:h,disabled:!n.trim(),className:"h-8 gap-1",children:[s.jsx(hr,{className:"h-3.5 w-3.5"}),"Add"]})})]})]})}),s.jsxs("p",{className:"text-xs text-zinc-400",children:[e.length," image",e.length!==1?"s":""," · Drag to reorder (coming soon)"]})]})}function Hw({title:e,description:t,url:n}){const a=e.length>60,i=t.length>155,c=a?e.slice(0,60)+"...":e,u=i?t.slice(0,155)+"...":t;return s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:s.jsxs("div",{className:"max-w-lg",children:[s.jsx("p",{className:"text-xs text-zinc-400 mb-1 truncate",children:n||"https://yourstore.com/products/..."}),s.jsx("p",{className:k("text-[17px] leading-snug text-blue-700 cursor-pointer hover:underline mb-1",!e&&"text-zinc-300 italic"),children:c||"Page title appears here"}),s.jsx("p",{className:k("text-sm leading-relaxed text-zinc-500",!t&&"text-zinc-300 italic"),children:u||"Meta description appears here..."})]})}),(a||i)&&s.jsxs("div",{className:"space-y-1.5",children:[a&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[s.jsx(rs,{className:"h-3.5 w-3.5 shrink-0"}),"Title is ",e.length," chars — Google shows ~60. Consider shortening."]}),i&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[s.jsx(rs,{className:"h-3.5 w-3.5 shrink-0"}),"Description is ",t.length," chars — Google shows ~155. Consider shortening."]})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-zinc-400",children:[s.jsxs("span",{className:k(a?"text-amber-500":"text-zinc-400"),children:["Title: ",e.length,"/",60]}),s.jsxs("span",{className:k(i?"text-amber-500":"text-zinc-400"),children:["Description: ",t.length,"/",155]})]})]})}function io({productId:e,field:t,context:n,onApply:r,className:o}){const[a,i]=l.useState(null),c=zw(),u=async()=>{i(null);const f={};n.name&&(f.name=n.name),n.current&&(f.current=n.current);const m=await c.mutateAsync({id:e,field:t,context:f});i(m.suggestion)},d=()=>{a&&(r(a),i(null))},h=()=>{i(null)};return s.jsxs("div",{className:k("space-y-2",o),"data-testid":q("product","ai-enrich",t),children:[s.jsxs(pe,{type:"button",variant:"outline",size:"sm",onClick:()=>void u(),disabled:c.isPending,className:"gap-1.5 text-xs text-purple-700 border-purple-200 hover:bg-purple-50 hover:border-purple-300",children:[s.jsx(cm,{className:k("h-3.5 w-3.5",c.isPending&&"animate-spin")}),c.isPending?"Enhancing...":"Enhance with AI"]}),a&&s.jsxs("div",{className:"rounded-md border border-purple-200 bg-purple-50 p-3 space-y-2",children:[s.jsx("p",{className:"text-xs font-medium text-purple-800 uppercase tracking-wider",children:"AI Suggestion"}),s.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:a}),s.jsxs("div",{className:"flex gap-2 pt-1",children:[s.jsxs(pe,{type:"button",size:"sm",onClick:d,className:"gap-1.5 bg-purple-600 hover:bg-purple-700 text-white text-xs",children:[s.jsx(Kn,{className:"h-3.5 w-3.5"}),"Apply"]}),s.jsxs(pe,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"gap-1.5 text-zinc-500 text-xs",children:[s.jsx(ps,{className:"h-3.5 w-3.5"}),"Dismiss"]})]})]})]})}const qw={name:"",slug:"",description:"",shortDescription:"",status:"draft",type:"simple",seoTitle:"",seoDescription:"",media:[],variants:[],categoryIds:[],metadata:{}};function Ww(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Di(){const{slug:e}=Ho(),t=vt(),n=!e||e==="new",{data:r,isLoading:o}=Mw(n?"":e??""),a=_w(),i=Iw(),[c,u]=l.useState(qw),[d,h]=l.useState(!1),[f,m]=l.useState(!1);l.useEffect(()=>{r&&u(r)},[r]);const x=(y,N)=>{h(!0),u(j=>{const C={...j,[y]:N};return y==="name"&&!f&&(C.slug=Ww(N)),C})},v=async()=>{if(n){const y=await a.mutateAsync(c);t(`/products/${y.slug}`)}else r&&(await i.mutateAsync({id:r.id,data:c}),h(!1))},p=a.isPending||i.isPending;if(!n&&o)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(ge,{className:"h-8 w-48"}),s.jsx(ge,{className:"h-96 w-full"})]});const g=(r==null?void 0:r.id)??"new";return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs(sn,{to:"/products",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[s.jsx(Zo,{className:"h-4 w-4"}),"Products"]}),s.jsx("span",{className:"text-zinc-300",children:"/"}),s.jsx("h1",{className:"text-base font-semibold text-zinc-900",children:n?"New Product":c.name||"Edit Product"}),d&&s.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:"Unsaved changes"})]}),s.jsx(pe,{onClick:()=>void v(),disabled:p||!c.name,className:"gap-1.5","data-testid":q("product","save"),children:p?s.jsxs(s.Fragment,{children:[s.jsx(bc,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:[s.jsx(im,{className:"h-4 w-4"}),n?"Create Product":"Save Changes"]})})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[s.jsx("div",{className:"md:col-span-2",children:s.jsxs(Du,{defaultValue:"general",children:[s.jsxs(Da,{className:"mb-4",children:[s.jsx(Wt,{value:"general",children:"General"}),s.jsx(Wt,{value:"variants",children:"Variants"}),s.jsx(Wt,{value:"media",children:"Media"}),s.jsx(Wt,{value:"seo",children:"SEO"})]}),s.jsx(Gt,{value:"general",className:"space-y-4",children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(De,{children:["Product Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx(be,{value:c.name??"",onChange:y=>x("name",y.target.value),placeholder:"e.g. Classic White T-Shirt","data-testid":q("product","name"),className:"text-base"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(De,{children:"Slug"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-zinc-400 shrink-0",children:"/products/"}),s.jsx(be,{value:c.slug??"",onChange:y=>{m(!0),x("slug",y.target.value)},placeholder:"classic-white-t-shirt",className:"font-mono text-sm"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(De,{children:"Description"}),!n&&s.jsx(io,{productId:g,field:"description",context:{...c.name?{name:c.name}:{},...c.description?{current:c.description}:{}},onApply:y=>x("description",y)})]}),s.jsx(on,{value:c.description??"",onChange:y=>x("description",y.target.value),placeholder:"Describe this product...",rows:5})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(De,{children:"Short Description"}),s.jsx(on,{value:c.shortDescription??"",onChange:y=>x("shortDescription",y.target.value),placeholder:"Brief one-line description...",rows:2})]})]})}),s.jsx(Gt,{value:"variants",children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[s.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Variants"}),s.jsx(Bw,{productId:g,variants:c.variants??[],onChange:y=>x("variants",y),currency:"GBP"})]})}),s.jsx(Gt,{value:"media",children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[s.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Media"}),s.jsx(Kw,{media:c.media??[],onChange:y=>x("media",y)})]})}),s.jsx(Gt,{value:"seo",className:"space-y-4",children:s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(De,{children:"SEO Title"}),!n&&s.jsx(io,{productId:g,field:"title",context:c.name?{name:c.name}:{},onApply:y=>x("seoTitle",y),className:"scale-90 origin-right"})]}),s.jsx(be,{value:c.seoTitle??"",onChange:y=>x("seoTitle",y.target.value),placeholder:c.name??"SEO title..."})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(De,{children:"SEO Description"}),!n&&s.jsx(io,{productId:g,field:"seoDescription",context:{...c.name?{name:c.name}:{},...c.seoDescription?{current:c.seoDescription}:{}},onApply:y=>x("seoDescription",y),className:"scale-90 origin-right"})]}),s.jsx(on,{value:c.seoDescription??"",onChange:y=>x("seoDescription",y.target.value),placeholder:"Meta description for search engines...",rows:3})]}),s.jsxs("div",{className:"pt-2 border-t border-zinc-100",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-3",children:"Preview"}),s.jsx(Hw,{title:c.seoTitle||c.name||"",description:c.seoDescription||c.shortDescription||"",url:`https://yourstore.com/products/${c.slug??""}`})]})]})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Status"}),s.jsxs(gr,{value:c.status??"draft",onValueChange:y=>x("status",y),children:[s.jsx(Un,{"data-testid":q("product","status"),children:s.jsx(vr,{})}),s.jsxs(Vn,{children:[s.jsx($e,{value:"draft",children:"Draft"}),s.jsx($e,{value:"active",children:"Active"}),s.jsx($e,{value:"archived",children:"Archived"})]})]}),s.jsxs("p",{className:"text-xs text-zinc-400",children:[c.status==="draft"&&"Not visible to customers.",c.status==="active"&&"Visible and purchasable.",c.status==="archived"&&"Hidden, not purchasable."]})]}),s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Product Type"}),s.jsxs(gr,{value:c.type??"simple",onValueChange:y=>x("type",y),children:[s.jsx(Un,{children:s.jsx(vr,{})}),s.jsxs(Vn,{children:[s.jsx($e,{value:"simple",children:"Simple"}),s.jsx($e,{value:"variable",children:"Variable"})]})]})]}),!n&&r&&s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-2 text-xs text-zinc-500",children:[s.jsx("h3",{className:"font-semibold uppercase tracking-wider text-zinc-400",children:"Summary"}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Variants"}),s.jsx("span",{className:"font-medium text-zinc-700",children:r.variants.length})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Total stock"}),s.jsx("span",{className:"font-mono font-medium text-zinc-700",children:r.variants.reduce((y,N)=>y+N.stock,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{children:"Media"}),s.jsx("span",{className:"font-medium text-zinc-700",children:r.media.length})]})]})]})]})]})}const Gw={breadcrumb:e=>"Edit"},Qw={breadcrumb:()=>"New Product"},Yw=[{value:"manual",label:"Manual"},{value:"return",label:"Return"},{value:"import",label:"Import"},{value:"sale",label:"Sale"},{value:"reservation-commit",label:"Reservation"},{value:"reservation-release",label:"Release"}];function Xw({row:e,onAdjust:t}){const[n,r]=l.useState(0),[o,a]=l.useState("manual"),[i,c]=l.useState(!1),u=()=>{n!==0&&(t(n,o),r(0),c(!0),setTimeout(()=>c(!1),1500))};return s.jsxs("div",{className:"flex items-center gap-2","data-testid":q("inventory","adjust",e.variantId),children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>r(d=>d-1),className:"flex h-7 w-7 items-center justify-center rounded border border-zinc-200 text-zinc-500 hover:bg-zinc-50 hover:text-zinc-700",children:s.jsx(om,{className:"h-3 w-3"})}),s.jsx("input",{type:"number",value:n,onChange:d=>r(parseInt(d.target.value)||0),className:k("h-7 w-16 rounded border text-center text-sm font-mono focus:outline-none focus:ring-1 focus:ring-blue-500",n>0&&"border-green-300 text-green-700 bg-green-50",n<0&&"border-red-300 text-red-700 bg-red-50",n===0&&"border-zinc-200")}),s.jsx("button",{onClick:()=>r(d=>d+1),className:"flex h-7 w-7 items-center justify-center rounded border border-zinc-200 text-zinc-500 hover:bg-zinc-50 hover:text-zinc-700",children:s.jsx(hr,{className:"h-3 w-3"})})]}),s.jsxs(gr,{value:o,onValueChange:d=>a(d),children:[s.jsx(Un,{className:"h-7 w-28 text-xs",children:s.jsx(vr,{})}),s.jsx(Vn,{children:Yw.map(d=>s.jsx($e,{value:d.value,children:d.label},d.value))})]}),s.jsx(pe,{size:"sm",variant:i?"secondary":"default",className:"h-7 px-2 text-xs gap-1",onClick:u,disabled:n===0||i,children:i?s.jsxs(s.Fragment,{children:[s.jsx(Kn,{className:"h-3 w-3 text-green-600"}),s.jsx("span",{className:"text-green-600",children:"Done"})]}):"Apply"})]})}const Zw=ga,Jw=va,jf=l.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{className:k("fixed inset-0 z-50 bg-black/40 backdrop-blur-sm 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}));jf.displayName="SheetOverlay";const eN=xs("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{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-lg"}},defaultVariants:{side:"right"}}),Cf=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>s.jsxs(Jw,{children:[s.jsx(jf,{}),s.jsxs(Ps,{ref:o,className:k(eN({side:e}),"border-zinc-200",t),...r,children:[n,s.jsxs(Hl,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:pointer-events-none",children:[s.jsx(ps,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Cf.displayName="SheetContent";const Sf=({className:e,...t})=>s.jsx("div",{className:k("flex flex-col space-y-2 text-left",e),...t});Sf.displayName="SheetHeader";const Ef=l.forwardRef(({className:e,...t},n)=>s.jsx(ya,{ref:n,className:k("text-lg font-semibold text-zinc-900",e),...t}));Ef.displayName="SheetTitle";const tN=l.forwardRef(({className:e,...t},n)=>s.jsx(ba,{ref:n,className:k("text-sm text-zinc-500",e),...t}));tN.displayName="SheetDescription";function nN(e={}){return Le({queryKey:["inventory","list",e],queryFn:()=>de.get("/api/admin/inventory",e)})}function rN(e){return Le({queryKey:["inventory","history",e],queryFn:async()=>(await de.get(`/api/admin/inventory/${e}/history`)).history,enabled:!!e})}function sN(){const e=Ne();return Te({mutationFn:({variantId:t,delta:n,reason:r})=>de.post(`/api/admin/inventory/${t}/adjust`,{delta:n,reason:r}),onMutate:async({variantId:t,delta:n})=>{await e.cancelQueries({queryKey:["inventory","list"]});const r=e.getQueryData(["inventory","list",{}]);return r&&e.setQueryData(["inventory","list",{}],r.map(o=>o.variantId===t?{...o,stock:Math.max(0,o.stock+n)}:o)),{previousData:r}},onError:(t,n,r)=>{r!=null&&r.previousData&&e.setQueryData(["inventory","list",{}],r.previousData)},onSuccess:()=>{e.invalidateQueries({queryKey:["inventory"]})}})}function oN({variantId:e,productName:t,sku:n,onClose:r}){const{data:o,isLoading:a}=rN(e);return s.jsx(Zw,{open:!0,onOpenChange:i=>!i&&r(),children:s.jsxs(Cf,{className:"w-[480px] sm:max-w-[480px] overflow-y-auto",children:[s.jsxs(Sf,{children:[s.jsx(Ef,{children:"Stock History"}),s.jsxs("div",{className:"mt-1",children:[s.jsx("p",{className:"text-sm font-medium text-zinc-700",children:t}),s.jsx("p",{className:"font-mono text-xs text-zinc-400",children:n})]})]}),s.jsx("div",{className:"mt-6",children:a?s.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((i,c)=>s.jsx(ge,{className:"h-12 w-full"},c))}):!o||o.length===0?s.jsx("p",{className:"text-sm text-zinc-400 text-center py-8",children:"No adjustment history found."}):s.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Date"}),s.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Adj"}),s.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"New Qty"}),s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Reason"}),s.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Actor"})]})}),s.jsx("tbody",{children:o.map(i=>s.jsxs("tr",{className:"border-b border-zinc-100 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 whitespace-nowrap",children:Ut(i.timestamp)}),s.jsxs("td",{className:k("px-3 py-2 text-right font-mono text-sm font-medium",i.adjustment>0?"text-green-600":"text-red-600"),children:[i.adjustment>0?"+":"",i.adjustment]}),s.jsx("td",{className:"px-3 py-2 text-right font-mono text-sm text-zinc-700",children:i.newQty}),s.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 capitalize",children:i.reason.replace(/-/g," ")}),s.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500",children:i.actor})]},i.id))})]})})})]})})}const aN={in_stock:"success",low_stock:"warning",out_of_stock:"destructive"},zi={in_stock:"In Stock",low_stock:"Low Stock",out_of_stock:"Out of Stock"};function iN(){const[e,t]=l.useState(""),[n,r]=l.useState("all"),[o,a]=l.useState(null),{data:i,isLoading:c}=nN({q:e||void 0,status:n==="all"?void 0:n,sort:"urgency",limit:200}),u=sN(),d=f=>(m,x)=>{u.mutateAsync({variantId:f,delta:m,reason:x})},h=f=>f==="out_of_stock"?"border-l-4 border-l-red-300":f==="low_stock"?"border-l-4 border-l-amber-300":"";return s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inventory"}),s.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} variants`:"Loading..."})]})}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx("div",{className:"flex gap-1.5",children:["all","out_of_stock","low_stock","in_stock"].map(f=>s.jsx("button",{onClick:()=>r(f),className:k("rounded-full px-3 py-1 text-xs font-medium transition-colors",n===f?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:f==="all"?"All":zi[f]},f))}),s.jsxs("div",{className:"relative ml-auto max-w-xs flex-1",children:[s.jsx(Hn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),s.jsx(be,{placeholder:"Search SKU or product...",value:e,onChange:f=>t(f.target.value),className:"pl-9 h-8 text-sm"})]})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:c?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((f,m)=>s.jsx(ge,{className:"h-11 w-full"},m))}):i!=null&&i.length?s.jsxs(Xn,{children:[s.jsx(Zn,{children:s.jsxs(Ge,{children:[s.jsx(re,{children:"Product"}),s.jsx(re,{children:"SKU / Options"}),s.jsx(re,{className:"text-right",children:"Stock"}),s.jsx(re,{className:"text-right",children:"Threshold"}),s.jsx(re,{children:"Status"}),s.jsx(re,{children:"Adjust"}),s.jsx(re,{className:"text-right",children:"History"})]})}),s.jsx(Jn,{children:i.map(f=>s.jsxs(Ge,{"data-testid":q("inventory","row",f.variantId),className:k("transition-colors",h(f.status)),children:[s.jsx(se,{children:s.jsx("p",{className:"font-medium text-zinc-800 text-sm",children:f.productName})}),s.jsx(se,{children:s.jsxs("div",{children:[s.jsx("p",{className:"font-mono text-xs text-zinc-500",children:f.sku}),f.options.length>0&&s.jsx("p",{className:"text-[10px] text-zinc-400",children:f.options.map(m=>`${m.name}: ${m.value}`).join(" · ")})]})}),s.jsx(se,{className:k("text-right font-mono text-base font-semibold",f.status==="out_of_stock"?"text-red-600":f.status==="low_stock"?"text-amber-600":"text-zinc-800"),children:f.stock}),s.jsx(se,{className:"text-right font-mono text-sm text-zinc-400",children:f.threshold}),s.jsx(se,{children:s.jsx(Nf,{variant:aN[f.status],className:"text-[10px]",children:zi[f.status]})}),s.jsx(se,{children:s.jsx(Xw,{row:f,onAdjust:d(f.variantId)})}),s.jsx(se,{className:"text-right",children:s.jsxs("button",{onClick:()=>a(f),className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium ml-auto",children:[s.jsx(Zh,{className:"h-3.5 w-3.5"}),"History"]})})]},f.variantId))})]}):s.jsx(Yn,{icon:s.jsx(xc,{className:"h-5 w-5"}),title:"No inventory found",description:"No variants match your filters."})}),o&&s.jsx(oN,{variantId:o.variantId,productName:o.productName,sku:o.sku,onClose:()=>a(null)})]})}const cN={breadcrumb:()=>"Inventory"};function lN(e={}){return Le({queryKey:["customers","list",e],queryFn:async()=>(await de.get("/api/admin/customers",e)).customers})}function dN(e){return Le({queryKey:["customers","detail",e],queryFn:()=>de.get(`/api/admin/customers/${e}`),enabled:!!e})}function uN(e){return Le({queryKey:["customers","orders",e],queryFn:async()=>(await de.get(`/api/admin/customers/${e}/orders`)).orders,enabled:!!e})}function fN(){const e=Ne();return Te({mutationFn:({customerId:t,body:n})=>de.post(`/api/admin/customers/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["customers","detail",n.customerId]})}})}function hN(){const e=vt(),[t,n]=l.useState(""),{data:r,isLoading:o}=lN({q:t||void 0,limit:100});return s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Customers"}),s.jsx("p",{className:"text-sm text-zinc-500",children:r?`${r.length} customers`:"Loading..."})]})}),s.jsxs("div",{className:"relative max-w-sm",children:[s.jsx(Hn,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),s.jsx(be,{placeholder:"Search by name or email...",value:t,onChange:a=>n(a.target.value),className:"pl-9 h-8 text-sm"})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:o?s.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((a,i)=>s.jsx(ge,{className:"h-11 w-full"},i))}):r!=null&&r.length?s.jsxs(Xn,{children:[s.jsx(Zn,{children:s.jsxs(Ge,{children:[s.jsx(re,{children:"Customer"}),s.jsx(re,{className:"text-right",children:"Orders"}),s.jsx(re,{className:"text-right",children:"Total Spent"}),s.jsx(re,{children:"Since"}),s.jsx(re,{className:"text-right",children:"Last Order"})]})}),s.jsx(Jn,{children:r.map(a=>{var c;const i=[a.firstName,a.lastName].filter(Boolean).join(" ");return s.jsxs(Ge,{"data-testid":q("customers","row",a.id),className:"cursor-pointer",onClick:()=>e(`/customers/${a.id}`),children:[s.jsx(se,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-zinc-100 text-xs font-semibold text-zinc-600",children:(((c=a.firstName)==null?void 0:c[0])??a.email[0]??"?").toUpperCase()}),s.jsxs("div",{children:[i&&s.jsx("p",{className:"text-sm font-medium text-zinc-800",children:i}),s.jsx("p",{className:"text-xs text-zinc-500",children:a.email})]})]})}),s.jsx(se,{className:"text-right font-mono text-sm text-zinc-700",children:a.orderCount}),s.jsx(se,{className:"text-right font-mono text-sm text-zinc-700",children:me(a.totalSpentMinor,"GBP")}),s.jsx(se,{className:"text-sm text-zinc-500",children:Ut(a.createdAt)}),s.jsx(se,{className:"text-right text-sm text-zinc-400",children:a.orderCount>0?it(a.updatedAt):"—"})]},a.id)})})]}):s.jsx(Yn,{icon:s.jsx(Jo,{className:"h-5 w-5"}),title:"No customers found",description:t?"Try a different search.":"Customers will appear as orders are placed."})})]})}const mN={breadcrumb:()=>"Customers"};function pN({customer:e,stats:t}){var r;const n=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.email;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-zinc-200 text-lg font-semibold text-zinc-600",children:(((r=e.firstName)==null?void 0:r[0])??e.email[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-base font-semibold text-zinc-900 truncate",children:n}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3 text-sm text-zinc-500",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(wc,{className:"h-3.5 w-3.5"}),e.email]}),e.phone&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(am,{className:"h-3.5 w-3.5"}),e.phone]})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-zinc-400",children:[s.jsx(Vh,{className:"h-3 w-3"}),"Customer since ",Ut(e.createdAt)]})]}),e.requiresPasswordReset&&s.jsx("span",{className:"shrink-0 rounded-full bg-amber-100 px-2.5 py-0.5 text-xs font-medium text-amber-700",children:"Needs reset"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[s.jsx(co,{icon:s.jsx(zn,{className:"h-4 w-4 text-blue-500"}),label:"Total Orders",value:String(t.orderCount)}),s.jsx(co,{icon:s.jsx(So,{className:"h-4 w-4 text-green-500"}),label:"Lifetime Value",value:me(t.lifetimeRevenueMinor,"GBP"),mono:!0}),s.jsx(co,{icon:s.jsx(So,{className:"h-4 w-4 text-indigo-500"}),label:"Avg Order",value:me(t.avgOrderValueMinor,"GBP"),mono:!0})]}),t.lastOrderAt&&s.jsxs("p",{className:"text-xs text-zinc-400",children:["Last order: ",it(t.lastOrderAt)]})]})}function co({icon:e,label:t,value:n,mono:r}){return s.jsxs("div",{className:"rounded-md border border-zinc-200 bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e,s.jsx("span",{className:"text-xs text-zinc-500",children:t})]}),s.jsx("p",{className:`text-base font-semibold text-zinc-900 ${r?"font-mono":""}`,children:n})]})}function xN({orders:e,isLoading:t}){const n=vt();return t?s.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((r,o)=>s.jsx(ge,{className:"h-11 w-full"},o))}):!e||e.length===0?s.jsx(Yn,{icon:s.jsx(zn,{className:"h-5 w-5"}),title:"No orders",description:"This customer hasn't placed any orders yet."}):s.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:s.jsxs(Xn,{children:[s.jsx(Zn,{children:s.jsxs(Ge,{children:[s.jsx(re,{children:"Order #"}),s.jsx(re,{children:"Status"}),s.jsx(re,{children:"Items"}),s.jsx(re,{className:"text-right",children:"Total"}),s.jsx(re,{className:"text-right",children:"Date"})]})}),s.jsx(Jn,{children:e.map(r=>s.jsxs(Ge,{className:"cursor-pointer",onClick:()=>n(`/orders/${r.orderNumber}`),children:[s.jsxs(se,{className:"font-mono text-sm font-medium text-blue-600",children:["#",r.orderNumber]}),s.jsx(se,{children:s.jsx($n,{status:r.status})}),s.jsxs(se,{className:"text-zinc-500",children:[r.lineItems.length," item",r.lineItems.length!==1?"s":""]}),s.jsx(se,{className:"text-right font-mono text-sm",children:me(r.totalMinor,r.currency)}),s.jsx(se,{className:"text-right text-sm text-zinc-500",children:it(r.createdAt)})]},r.id))})]})})}function gN({notes:e}){return s.jsx("div",{className:"space-y-2",children:e.length===0?s.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...e].sort((t,n)=>new Date(n.at).getTime()-new Date(t.at).getTime()).map((t,n)=>s.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[s.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:t.body}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-zinc-400",children:[s.jsx("span",{className:"font-medium text-zinc-500",children:t.actor}),s.jsx("span",{children:"·"}),s.jsx("time",{dateTime:t.at,title:Ut(t.at),children:it(t.at)})]})]},n))})}function vN(){const{id:e}=Ho(),[t,n]=l.useState(""),{data:r,isLoading:o}=dN(e??""),{data:a,isLoading:i}=uN(e??""),c=fN(),u=async x=>{x.preventDefault(),!(!t.trim()||!e)&&(await c.mutateAsync({customerId:e,body:t.trim()}),n(""))};if(o)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(ge,{className:"h-8 w-32"}),s.jsx(ge,{className:"h-32 w-full"}),s.jsx(ge,{className:"h-48 w-full"})]});if(!r)return s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx("p",{className:"text-sm text-zinc-500",children:"Customer not found"}),s.jsx(sn,{to:"/customers",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to customers"})]});const{customer:d,stats:h}=r,f=[d.firstName,d.lastName].filter(Boolean).join(" ")||d.email,m=d.notes??[];return s.jsxs("div",{className:"space-y-5","data-testid":q("customer","detail"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(sn,{to:"/customers",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[s.jsx(Zo,{className:"h-4 w-4"}),"Customers"]}),s.jsx("span",{className:"text-zinc-300",children:"/"}),s.jsx("span",{className:"text-sm font-medium text-zinc-900",children:f})]}),s.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:s.jsx(pN,{customer:d,stats:h})}),s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[s.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:s.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Order History"})}),s.jsx("div",{className:"p-4",children:s.jsx(xN,{orders:a,isLoading:i})})]}),s.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-3","data-testid":q("customer","notes"),children:[s.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Notes"}),s.jsx(gN,{notes:m}),s.jsxs("form",{onSubmit:x=>void u(x),className:"flex gap-2 pt-2",children:[s.jsx(on,{placeholder:"Add a note about this customer...",value:t,onChange:x=>n(x.target.value),rows:2,className:"flex-1 text-sm"}),s.jsx(pe,{type:"submit",size:"icon",disabled:!t.trim()||c.isPending,className:"self-end h-9 w-9",children:s.jsx(Nc,{className:"h-4 w-4"})})]})]})]})}const yN={breadcrumb:e=>"Customer"};function bN(){const e=vt();return s.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[s.jsx("p",{className:"font-mono text-5xl font-bold text-zinc-200",children:"404"}),s.jsx("h2",{className:"mt-3 text-base font-semibold text-zinc-700",children:"Page not found"}),s.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"The page you're looking for doesn't exist."}),s.jsx("div",{className:"mt-6",children:s.jsx(pe,{variant:"outline",onClick:()=>e("/"),children:"Go to Dashboard"})})]})}let Li=null;async function wN(){return ns()?null:(Li??(Li=Dh()),await Li,ns()?null:Of("/login"))}const Rf=If([{path:"/login",element:s.jsx(K0,{})},{path:"/",element:s.jsx($0,{}),loader:wN,handle:{breadcrumb:()=>null},children:[{index:!0,element:s.jsx(Z0,{}),handle:{breadcrumb:()=>"Dashboard"}},{path:"orders",handle:_b,children:[{index:!0,element:s.jsx(Mb,{})},{path:":orderNumber",element:s.jsx(Pw,{}),handle:kw}]},{path:"products",handle:Uw,children:[{index:!0,element:s.jsx($w,{})},{path:"new",element:s.jsx(Di,{}),handle:Qw},{path:":slug",element:s.jsx(Di,{}),handle:Gw}]},{path:"inventory",element:s.jsx(iN,{}),handle:cN},{path:"customers",handle:mN,children:[{index:!0,element:s.jsx(hN,{})},{path:":id",element:s.jsx(vN,{}),handle:yN}]},{path:"*",element:s.jsx(bN,{})}]}],{basename:"/admin"});Mh(()=>{es.clear(),Rf.navigate("/login")});const Pf=document.getElementById("root");if(!Pf)throw new Error("Root element not found");Zi(Pf).render(s.jsx(l.StrictMode,{children:s.jsx(mh,{client:es,children:s.jsx(Df,{router:Rf})})}));
|