@nymbalhq/admin 1.6.0 → 1.7.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.
@@ -1,4 +1,4 @@
1
- var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(e,t,n)=>(oa(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?fi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_=(e,t,n,s)=>(oa(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),ee=(e,t,n)=>(oa(e,t,"access private method"),n);var Wr=(e,t,n,s)=>({set _(a){_(e,t,a,n)},get _(){return b(e,t,s)}});import{r as ih,a as ch,b as l,u as Ct,N as lh,c as dh,L as Ze,d as Rs,R as po,e as uh,f as Xe,g as fh,O as hh,h as xo,i as kc,j as mh,k as ph,l as xh}from"./vendor-0v2ry8Wl.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var ia={exports:{}},ur={};/**
1
+ var fi=e=>{throw TypeError(e)};var ia=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(e,t,n)=>(ia(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?fi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_=(e,t,n,s)=>(ia(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),ee=(e,t,n)=>(ia(e,t,"access private method"),n);var Wr=(e,t,n,s)=>({set _(a){_(e,t,a,n)},get _(){return b(e,t,s)}});import{r as ih,a as ch,b as l,u as Ct,N as lh,c as dh,L as Ze,d as Ps,R as po,e as uh,f as Xe,g as fh,O as hh,h as xo,i as kc,j as mh,k as ph,l as xh}from"./vendor-0v2ry8Wl.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var ca={exports:{}},ur={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@ var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var hi;function gh(){if(hi)return ur;hi=1;var e=ih(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(i,f,u){var d,h={},m=null,x=null;u!==void 0&&(m=""+u),f.key!==void 0&&(m=""+f.key),f.ref!==void 0&&(x=f.ref);for(d in f)s.call(f,d)&&!o.hasOwnProperty(d)&&(h[d]=f[d]);if(i&&i.defaultProps)for(d in f=i.defaultProps,f)h[d]===void 0&&(h[d]=f[d]);return{$$typeof:t,type:i,key:m,ref:x,props:h,_owner:a.current}}return ur.Fragment=n,ur.jsx=c,ur.jsxs=c,ur}var mi;function vh(){return mi||(mi=1,ia.exports=gh()),ia.exports}var r=vh(),Gr={},pi;function yh(){if(pi)return Gr;pi=1;var e=ch();return Gr.createRoot=e.createRoot,Gr.hydrateRoot=e.hydrateRoot,Gr}var bh=yh(),er=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(){}},sn,_t,On,vc,wh=(vc=class extends er{constructor(){super();$(this,sn);$(this,_t);$(this,On);_(this,On,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){b(this,_t)||this.setEventListener(b(this,On))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,_t))==null||t.call(this),_(this,_t,void 0))}setEventListener(t){var n;_(this,On,t),(n=b(this,_t))==null||n.call(this),_(this,_t,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){b(this,sn)!==t&&(_(this,sn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof b(this,sn)=="boolean"?b(this,sn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},sn=new WeakMap,_t=new WeakMap,On=new WeakMap,vc),go=new wh,jh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},It,mo,yc,Nh=(yc=class{constructor(){$(this,It,jh);$(this,mo,!1)}setTimeoutProvider(e){_(this,It,e)}setTimeout(e,t){return b(this,It).setTimeout(e,t)}clearTimeout(e){b(this,It).clearTimeout(e)}setInterval(e,t){return b(this,It).setInterval(e,t)}clearInterval(e){b(this,It).clearInterval(e)}},It=new WeakMap,mo=new WeakMap,yc),rn=new Nh;function Ch(e){setTimeout(e,0)}var Sh=typeof window>"u"||"Deno"in globalThis;function ke(){}function Eh(e,t){return typeof e=="function"?e(t):e}function ka(e){return typeof e=="number"&&e>=0&&e!==1/0}function Tc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Vt(e,t){return typeof e=="function"?e(t):e}function Fe(e,t){return typeof e=="function"?e(t):e}function xi(e,t){const{type:n="all",exact:s,fetchStatus:a,predicate:o,queryKey:c,stale:i}=e;if(c){if(s){if(t.queryHash!==vo(c,t.options))return!1}else if(!vr(t.queryKey,c))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="inactive"&&f)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||a&&a!==t.state.fetchStatus||o&&!o(t))}function gi(e,t){const{exact:n,status:s,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(mn(t.options.mutationKey)!==mn(o))return!1}else if(!vr(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function vo(e,t){return((t==null?void 0:t.queryKeyHashFn)||mn)(e)}function mn(e){return JSON.stringify(e,(t,n)=>Ta(n)?Object.keys(n).sort().reduce((s,a)=>(s[a]=n[a],s),{}):n)}function vr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>vr(e[n],t[n])):!1}var Rh=Object.prototype.hasOwnProperty;function Ac(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=vi(e)&&vi(t);if(!s&&!(Ta(e)&&Ta(t)))return t;const o=(s?e:Object.keys(e)).length,c=s?t:Object.keys(t),i=c.length,f=s?new Array(i):{};let u=0;for(let d=0;d<i;d++){const h=s?d:c[d],m=e[h],x=t[h];if(m===x){f[h]=m,(s?d<o:Rh.call(e,h))&&u++;continue}if(m===null||x===null||typeof m!="object"||typeof x!="object"){f[h]=x;continue}const g=Ac(m,x,n+1);f[h]=g,g===m&&u++}return o===i&&u===o?e:f}function fs(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 vi(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ta(e){if(!yi(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!yi(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function yi(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ph(e){return new Promise(t=>{rn.setTimeout(t,e)})}function Aa(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Ac(e,t):t}function kh(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Th(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var yo=Symbol();function Mc(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===yo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function bo(e,t){return typeof e=="function"?e(...t):!!e}function Ah(e,t,n){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var yr=(()=>{let e=()=>Sh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ma(){let e,t;const n=new Promise((a,o)=>{e=a,t=o});n.status="pending",n.catch(()=>{});function s(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},n.reject=a=>{s({status:"rejected",reason:a}),t(a)},n}var Mh=Ch;function _h(){let e=[],t=0,n=i=>{i()},s=i=>{i()},a=Mh;const o=i=>{t?e.push(i):a(()=>{n(i)})},c=()=>{const i=e;e=[],i.length&&a(()=>{s(()=>{i.forEach(f=>{n(f)})})})};return{batch:i=>{let f;t++;try{f=i()}finally{t--,t||c()}return f},batchCalls:i=>(...f)=>{o(()=>{i(...f)})},schedule:o,setNotifyFunction:i=>{n=i},setBatchNotifyFunction:i=>{s=i},setScheduler:i=>{a=i}}}var be=_h(),Dn,Ot,zn,bc,Ih=(bc=class extends er{constructor(){super();$(this,Dn,!0);$(this,Ot);$(this,zn);_(this,zn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}onSubscribe(){b(this,Ot)||this.setEventListener(b(this,zn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Ot))==null||t.call(this),_(this,Ot,void 0))}setEventListener(t){var n;_(this,zn,t),(n=b(this,Ot))==null||n.call(this),_(this,Ot,t(this.setOnline.bind(this)))}setOnline(t){b(this,Dn)!==t&&(_(this,Dn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return b(this,Dn)}},Dn=new WeakMap,Ot=new WeakMap,zn=new WeakMap,bc),hs=new Ih;function Oh(e){return Math.min(1e3*2**e,3e4)}function _c(e){return(e??"online")==="online"?hs.isOnline():!0}var _a=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Ic(e){let t=!1,n=0,s;const a=Ma(),o=()=>a.status!=="pending",c=p=>{var v;if(!o()){const y=new _a(p);m(y),(v=e.onCancel)==null||v.call(e,y)}},i=()=>{t=!0},f=()=>{t=!1},u=()=>go.isFocused()&&(e.networkMode==="always"||hs.isOnline())&&e.canRun(),d=()=>_c(e.networkMode)&&e.canRun(),h=p=>{o()||(s==null||s(),a.resolve(p))},m=p=>{o()||(s==null||s(),a.reject(p))},x=()=>new Promise(p=>{var v;s=y=>{(o()||u())&&p(y)},(v=e.onPause)==null||v.call(e)}).then(()=>{var p;s=void 0,o()||(p=e.onContinue)==null||p.call(e)}),g=()=>{if(o())return;let p;const v=n===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(h).catch(y=>{var S;if(o())return;const w=e.retry??(yr.isServer()?0:3),N=e.retryDelay??Oh,j=typeof N=="function"?N(n,y):N,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!C){m(y);return}n++,(S=e.onFail)==null||S.call(e,n,y),Ph(j).then(()=>u()?void 0:x()).then(()=>{t?m(y):g()})})};return{promise:a,status:()=>a.status,cancel:c,continue:()=>(s==null||s(),a),cancelRetry:i,continueRetry:f,canStart:d,start:()=>(d()?g():x().then(g),a)}}var an,wc,Oc=(wc=class{constructor(){$(this,an)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ka(this.gcTime)&&_(this,an,rn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(yr.isServer()?1/0:300*1e3))}clearGcTimeout(){b(this,an)!==void 0&&(rn.clearTimeout(b(this,an)),_(this,an,void 0))}},an=new WeakMap,wc),on,Ln,Ke,cn,je,Rr,ln,Le,Dc,pt,jc,Dh=(jc=class extends Oc{constructor(t){super();$(this,Le);$(this,on);$(this,Ln);$(this,Ke);$(this,cn);$(this,je);$(this,Rr);$(this,ln);_(this,ln,!1),_(this,Rr,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,cn,t.client),_(this,Ke,b(this,cn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,on,wi(this.options)),this.state=t.state??b(this,on),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=b(this,je))==null?void 0:t.promise}setOptions(t){if(this.options={...b(this,Rr),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=wi(this.options);n.data!==void 0&&(this.setState(bi(n.data,n.dataUpdatedAt)),_(this,on,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&b(this,Ke).remove(this)}setData(t,n){const s=Aa(this.state.data,t,this.options);return ee(this,Le,pt).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t,n){ee(this,Le,pt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var s,a;const n=(s=b(this,je))==null?void 0:s.promise;return(a=b(this,je))==null||a.cancel(t),n?n.then(ke).catch(ke):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return b(this,on)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Fe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===yo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Vt(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:!Tc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}onOnline(){var n;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),b(this,Ke).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,je)&&(b(this,ln)||ee(this,Le,Dc).call(this)?b(this,je).cancel({revert:!0}):b(this,je).cancelRetry()),this.scheduleGc()),b(this,Ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ee(this,Le,pt).call(this,{type:"invalidate"})}async fetch(t,n){var f,u,d,h,m,x,g,p,v,y,w,N;if(this.state.fetchStatus!=="idle"&&((f=b(this,je))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(b(this,je))return b(this,je).continueRetry(),b(this,je).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const s=new AbortController,a=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(_(this,ln,!0),s.signal)})},o=()=>{const j=Mc(this.options,n),S=(()=>{const E={client:b(this,cn),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return _(this,ln,!1),this.options.persister?this.options.persister(j,S,this):j(S)},i=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:b(this,cn),state:this.state,fetchFn:o};return a(j),j})();(u=this.options.behavior)==null||u.onFetch(i,this),_(this,Ln,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=i.fetchOptions)==null?void 0:d.meta))&&ee(this,Le,pt).call(this,{type:"fetch",meta:(h=i.fetchOptions)==null?void 0:h.meta}),_(this,je,Ic({initialPromise:n==null?void 0:n.initialPromise,fn:i.fetchFn,onCancel:j=>{j instanceof _a&&j.revert&&this.setState({...b(this,Ln),fetchStatus:"idle"}),s.abort()},onFail:(j,C)=>{ee(this,Le,pt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{ee(this,Le,pt).call(this,{type:"pause"})},onContinue:()=>{ee(this,Le,pt).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const j=await b(this,je).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(m=b(this,Ke).config).onSuccess)==null||x.call(m,j,this),(p=(g=b(this,Ke).config).onSettled)==null||p.call(g,j,this.state.error,this),j}catch(j){if(j instanceof _a){if(j.silent)return b(this,je).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw ee(this,Le,pt).call(this,{type:"error",error:j}),(y=(v=b(this,Ke).config).onError)==null||y.call(v,j,this),(N=(w=b(this,Ke).config).onSettled)==null||N.call(w,this.state.data,j,this),j}finally{this.scheduleGc()}}},on=new WeakMap,Ln=new WeakMap,Ke=new WeakMap,cn=new WeakMap,je=new WeakMap,Rr=new WeakMap,ln=new WeakMap,Le=new WeakSet,Dc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},pt=function(t){const n=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...zc(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...bi(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Ln,t.manual?a:void 0),a;case"error":const o=t.error;return{...s,error:o,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),b(this,Ke).notify({query:this,type:"updated",action:t})})},jc);function zc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:_c(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function bi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wi(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var _e,oe,Pr,Pe,dn,Fn,xt,Dt,kr,$n,Un,un,fn,zt,Vn,ue,pr,Ia,Oa,Da,za,La,Fa,$a,Fc,Nc,Lc=(Nc=class extends er{constructor(t,n){super();$(this,ue);$(this,_e);$(this,oe);$(this,Pr);$(this,Pe);$(this,dn);$(this,Fn);$(this,xt);$(this,Dt);$(this,kr);$(this,$n);$(this,Un);$(this,un);$(this,fn);$(this,zt);$(this,Vn,new Set);this.options=n,_(this,_e,t),_(this,Dt,null),_(this,xt,Ma()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(b(this,oe).addObserver(this),ji(b(this,oe),this.options)?ee(this,ue,pr).call(this):this.updateResult(),ee(this,ue,za).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ua(b(this,oe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ua(b(this,oe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ee(this,ue,La).call(this),ee(this,ue,Fa).call(this),b(this,oe).removeObserver(this)}setOptions(t){const n=this.options,s=b(this,oe);if(this.options=b(this,_e).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Fe(this.options.enabled,b(this,oe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ee(this,ue,$a).call(this),b(this,oe).setOptions(this.options),n._defaulted&&!fs(this.options,n)&&b(this,_e).getQueryCache().notify({type:"observerOptionsUpdated",query:b(this,oe),observer:this});const a=this.hasListeners();a&&Ni(b(this,oe),s,this.options,n)&&ee(this,ue,pr).call(this),this.updateResult(),a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||Vt(this.options.staleTime,b(this,oe))!==Vt(n.staleTime,b(this,oe)))&&ee(this,ue,Ia).call(this);const o=ee(this,ue,Oa).call(this);a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||o!==b(this,zt))&&ee(this,ue,Da).call(this,o)}getOptimisticResult(t){const n=b(this,_e).getQueryCache().build(b(this,_e),t),s=this.createResult(n,t);return Lh(this,s)&&(_(this,Pe,s),_(this,Fn,this.options),_(this,dn,b(this,oe).state)),s}getCurrentResult(){return b(this,Pe)}trackResult(t,n){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&b(this,xt).status==="pending"&&b(this,xt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){b(this,Vn).add(t)}getCurrentQuery(){return b(this,oe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=b(this,_e).defaultQueryOptions(t),s=b(this,_e).getQueryCache().build(b(this,_e),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(t){return ee(this,ue,pr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),b(this,Pe)))}createResult(t,n){var z;const s=b(this,oe),a=this.options,o=b(this,Pe),c=b(this,dn),i=b(this,Fn),u=t!==s?t.state:b(this,Pr),{state:d}=t;let h={...d},m=!1,x;if(n._optimisticResults){const O=this.hasListeners(),U=!O&&ji(t,n),I=O&&Ni(t,s,n,a);(U||I)&&(h={...h,...zc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:g,errorUpdatedAt:p,status:v}=h;x=h.data;let y=!1;if(n.placeholderData!==void 0&&x===void 0&&v==="pending"){let O;o!=null&&o.isPlaceholderData&&n.placeholderData===(i==null?void 0:i.placeholderData)?(O=o.data,y=!0):O=typeof n.placeholderData=="function"?n.placeholderData((z=b(this,Un))==null?void 0:z.state.data,b(this,Un)):n.placeholderData,O!==void 0&&(v="success",x=Aa(o==null?void 0:o.data,O,n),m=!0)}if(n.select&&x!==void 0&&!y)if(o&&x===(c==null?void 0:c.data)&&n.select===b(this,kr))x=b(this,$n);else try{_(this,kr,n.select),x=n.select(x),x=Aa(o==null?void 0:o.data,x,n),_(this,$n,x),_(this,Dt,null)}catch(O){_(this,Dt,O)}b(this,Dt)&&(g=b(this,Dt),x=b(this,$n),p=Date.now(),v="error");const w=h.fetchStatus==="fetching",N=v==="pending",j=v==="error",C=N&&w,S=x!==void 0,k={status:v,fetchStatus:h.fetchStatus,isPending:N,isSuccess:v==="success",isError:j,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!N,isLoadingError:j&&!S,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:wo(t,n),refetch:this.refetch,promise:b(this,xt),isEnabled:Fe(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=k.data!==void 0,U=k.status==="error"&&!O,I=Z=>{U?Z.reject(k.error):O&&Z.resolve(k.data)},Q=()=>{const Z=_(this,xt,k.promise=Ma());I(Z)},V=b(this,xt);switch(V.status){case"pending":t.queryHash===s.queryHash&&I(V);break;case"fulfilled":(U||k.data!==V.value)&&Q();break;case"rejected":(!U||k.error!==V.reason)&&Q();break}}return k}updateResult(){const t=b(this,Pe),n=this.createResult(b(this,oe),this.options);if(_(this,dn,b(this,oe).state),_(this,Fn,this.options),b(this,dn).data!==void 0&&_(this,Un,b(this,oe)),fs(n,t))return;_(this,Pe,n);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!b(this,Vn).size)return!0;const c=new Set(o??b(this,Vn));return this.options.throwOnError&&c.add("error"),Object.keys(b(this,Pe)).some(i=>{const f=i;return b(this,Pe)[f]!==t[f]&&c.has(f)})};ee(this,ue,Fc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ee(this,ue,za).call(this)}},_e=new WeakMap,oe=new WeakMap,Pr=new WeakMap,Pe=new WeakMap,dn=new WeakMap,Fn=new WeakMap,xt=new WeakMap,Dt=new WeakMap,kr=new WeakMap,$n=new WeakMap,Un=new WeakMap,un=new WeakMap,fn=new WeakMap,zt=new WeakMap,Vn=new WeakMap,ue=new WeakSet,pr=function(t){ee(this,ue,$a).call(this);let n=b(this,oe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(ke)),n},Ia=function(){ee(this,ue,La).call(this);const t=Vt(this.options.staleTime,b(this,oe));if(yr.isServer()||b(this,Pe).isStale||!ka(t))return;const s=Tc(b(this,Pe).dataUpdatedAt,t)+1;_(this,un,rn.setTimeout(()=>{b(this,Pe).isStale||this.updateResult()},s))},Oa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(b(this,oe)):this.options.refetchInterval)??!1},Da=function(t){ee(this,ue,Fa).call(this),_(this,zt,t),!(yr.isServer()||Fe(this.options.enabled,b(this,oe))===!1||!ka(b(this,zt))||b(this,zt)===0)&&_(this,fn,rn.setInterval(()=>{(this.options.refetchIntervalInBackground||go.isFocused())&&ee(this,ue,pr).call(this)},b(this,zt)))},za=function(){ee(this,ue,Ia).call(this),ee(this,ue,Da).call(this,ee(this,ue,Oa).call(this))},La=function(){b(this,un)!==void 0&&(rn.clearTimeout(b(this,un)),_(this,un,void 0))},Fa=function(){b(this,fn)!==void 0&&(rn.clearInterval(b(this,fn)),_(this,fn,void 0))},$a=function(){const t=b(this,_e).getQueryCache().build(b(this,_e),this.options);if(t===b(this,oe))return;const n=b(this,oe);_(this,oe,t),_(this,Pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Fc=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(b(this,Pe))}),b(this,_e).getQueryCache().notify({query:b(this,oe),type:"observerResultsUpdated"})})},Nc);function zh(e,t){return Fe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Fe(t.retryOnMount,e)===!1)}function ji(e,t){return zh(e,t)||e.state.data!==void 0&&Ua(e,t,t.refetchOnMount)}function Ua(e,t,n){if(Fe(t.enabled,e)!==!1&&Vt(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&wo(e,t)}return!1}function Ni(e,t,n,s){return(e!==t||Fe(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&wo(e,n)}function wo(e,t){return Fe(t.enabled,e)!==!1&&e.isStaleByTime(Vt(t.staleTime,e))}function Lh(e,t){return!fs(e.getCurrentResult(),t)}function ms(e){return{onFetch:(t,n)=>{var d,h,m,x,g;const s=t.options,a=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,o=((x=t.state.data)==null?void 0:x.pages)||[],c=((g=t.state.data)==null?void 0:g.pageParams)||[];let i={pages:[],pageParams:[]},f=0;const u=async()=>{let p=!1;const v=N=>{Ah(N,()=>t.signal,()=>p=!0)},y=Mc(t.options,t.fetchOptions),w=async(N,j,C)=>{if(p)return Promise.reject();if(j==null&&N.pages.length)return Promise.resolve(N);const E=(()=>{const U={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return v(U),U})(),k=await y(E),{maxPages:z}=t.options,O=C?Th:kh;return{pages:O(N.pages,k,z),pageParams:O(N.pageParams,j,z)}};if(a&&o.length){const N=a==="backward",j=N?$c:Va,C={pages:o,pageParams:c},S=j(s,C);i=await w(C,S,N)}else{const N=e??o.length;do{const j=f===0?c[0]??s.initialPageParam:Va(s,i);if(f>0&&j==null)break;i=await w(i,j),f++}while(f<N)}return i};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Va(e,{pages:t,pageParams:n}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,n[s],n):void 0}function $c(e,{pages:t,pageParams:n}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,n[0],n):void 0}function Fh(e,t){return t?Va(e,t)!=null:!1}function $h(e,t){return!t||!e.getPreviousPageParam?!1:$c(e,t)!=null}var Uh=class extends Lc{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ms()})}getOptimisticResult(e){return e.behavior=ms(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var g,p;const{state:n}=e,s=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:c,isRefetchError:i}=s,f=(p=(g=n.fetchMeta)==null?void 0:g.fetchMore)==null?void 0:p.direction,u=c&&f==="forward",d=a&&f==="forward",h=c&&f==="backward",m=a&&f==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fh(t,n.data),hasPreviousPage:$h(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:m,isRefetchError:i&&!u&&!h,isRefetching:o&&!d&&!m}}},Tr,rt,Se,hn,st,Tt,Cc,Vh=(Cc=class extends Oc{constructor(t){super();$(this,st);$(this,Tr);$(this,rt);$(this,Se);$(this,hn);_(this,Tr,t.client),this.mutationId=t.mutationId,_(this,Se,t.mutationCache),_(this,rt,[]),this.state=t.state||Uc(),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,rt).includes(t)||(b(this,rt).push(t),this.clearGcTimeout(),b(this,Se).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,rt,b(this,rt).filter(n=>n!==t)),this.scheduleGc(),b(this,Se).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){b(this,rt).length||(this.state.status==="pending"?this.scheduleGc():b(this,Se).remove(this))}continue(){var t;return((t=b(this,hn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var c,i,f,u,d,h,m,x,g,p,v,y,w,N,j,C,S,E;const n=()=>{ee(this,st,Tt).call(this,{type:"continue"})},s={client:b(this,Tr),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,hn,Ic({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(k,z)=>{ee(this,st,Tt).call(this,{type:"failed",failureCount:k,error:z})},onPause:()=>{ee(this,st,Tt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>b(this,Se).canRun(this)}));const a=this.state.status==="pending",o=!b(this,hn).canStart();try{if(a)n();else{ee(this,st,Tt).call(this,{type:"pending",variables:t,isPaused:o}),b(this,Se).config.onMutate&&await b(this,Se).config.onMutate(t,this,s);const z=await((i=(c=this.options).onMutate)==null?void 0:i.call(c,t,s));z!==this.state.context&&ee(this,st,Tt).call(this,{type:"pending",context:z,variables:t,isPaused:o})}const k=await b(this,hn).start();return await((u=(f=b(this,Se).config).onSuccess)==null?void 0:u.call(f,k,t,this.state.context,this,s)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,k,t,this.state.context,s)),await((x=(m=b(this,Se).config).onSettled)==null?void 0:x.call(m,k,null,this.state.variables,this.state.context,this,s)),await((p=(g=this.options).onSettled)==null?void 0:p.call(g,k,null,t,this.state.context,s)),ee(this,st,Tt).call(this,{type:"success",data:k}),k}catch(k){try{await((y=(v=b(this,Se).config).onError)==null?void 0:y.call(v,k,t,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((N=(w=this.options).onError)==null?void 0:N.call(w,k,t,this.state.context,s))}catch(z){Promise.reject(z)}try{await((C=(j=b(this,Se).config).onSettled)==null?void 0:C.call(j,void 0,k,this.state.variables,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((E=(S=this.options).onSettled)==null?void 0:E.call(S,void 0,k,t,this.state.context,s))}catch(z){Promise.reject(z)}throw ee(this,st,Tt).call(this,{type:"error",error:k}),k}finally{b(this,Se).runNext(this)}}},Tr=new WeakMap,rt=new WeakMap,Se=new WeakMap,hn=new WeakMap,st=new WeakSet,Tt=function(t){const n=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{b(this,rt).forEach(s=>{s.onMutationUpdate(t)}),b(this,Se).notify({mutation:this,type:"updated",action:t})})},Cc);function Uc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var gt,Ye,Ar,Sc,Bh=(Sc=class extends er{constructor(t={}){super();$(this,gt);$(this,Ye);$(this,Ar);this.config=t,_(this,gt,new Set),_(this,Ye,new Map),_(this,Ar,0)}build(t,n,s){const a=new Vh({client:t,mutationCache:this,mutationId:++Wr(this,Ar)._,options:t.defaultMutationOptions(n),state:s});return this.add(a),a}add(t){b(this,gt).add(t);const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n);s?s.push(t):b(this,Ye).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(b(this,gt).delete(t)){const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&b(this,Ye).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n),a=s==null?void 0:s.find(o=>o.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const n=Qr(t);if(typeof n=="string"){const a=(s=b(this,Ye).get(n))==null?void 0:s.find(o=>o!==t&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{b(this,gt).forEach(t=>{this.notify({type:"removed",mutation:t})}),b(this,gt).clear(),b(this,Ye).clear()})}getAll(){return Array.from(b(this,gt))}find(t){const n={exact:!0,...t};return this.getAll().find(s=>gi(n,s))}findAll(t={}){return this.getAll().filter(n=>gi(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(ke))))}},gt=new WeakMap,Ye=new WeakMap,Ar=new WeakMap,Sc);function Qr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var vt,Lt,Ie,yt,wt,as,Ba,Ec,Kh=(Ec=class extends er{constructor(n,s){super();$(this,wt);$(this,vt);$(this,Lt);$(this,Ie);$(this,yt);_(this,vt,n),this.setOptions(s),this.bindMethods(),ee(this,wt,as).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const s=this.options;this.options=b(this,vt).defaultMutationOptions(n),fs(this.options,s)||b(this,vt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:b(this,Ie),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&mn(s.mutationKey)!==mn(this.options.mutationKey)?this.reset():((a=b(this,Ie))==null?void 0:a.state.status)==="pending"&&b(this,Ie).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=b(this,Ie))==null||n.removeObserver(this)}onMutationUpdate(n){ee(this,wt,as).call(this),ee(this,wt,Ba).call(this,n)}getCurrentResult(){return b(this,Lt)}reset(){var n;(n=b(this,Ie))==null||n.removeObserver(this),_(this,Ie,void 0),ee(this,wt,as).call(this),ee(this,wt,Ba).call(this)}mutate(n,s){var a;return _(this,yt,s),(a=b(this,Ie))==null||a.removeObserver(this),_(this,Ie,b(this,vt).getMutationCache().build(b(this,vt),this.options)),b(this,Ie).addObserver(this),b(this,Ie).execute(n)}},vt=new WeakMap,Lt=new WeakMap,Ie=new WeakMap,yt=new WeakMap,wt=new WeakSet,as=function(){var s;const n=((s=b(this,Ie))==null?void 0:s.state)??Uc();_(this,Lt,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ba=function(n){be.batch(()=>{var s,a,o,c,i,f,u,d;if(b(this,yt)&&this.hasListeners()){const h=b(this,Lt).variables,m=b(this,Lt).context,x={client:b(this,vt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(s=b(this,yt)).onSuccess)==null||a.call(s,n.data,h,m,x)}catch(g){Promise.reject(g)}try{(c=(o=b(this,yt)).onSettled)==null||c.call(o,n.data,null,h,m,x)}catch(g){Promise.reject(g)}}else if((n==null?void 0:n.type)==="error"){try{(f=(i=b(this,yt)).onError)==null||f.call(i,n.error,h,m,x)}catch(g){Promise.reject(g)}try{(d=(u=b(this,yt)).onSettled)==null||d.call(u,void 0,n.error,h,m,x)}catch(g){Promise.reject(g)}}}this.listeners.forEach(h=>{h(b(this,Lt))})})},Ec),at,Rc,qh=(Rc=class extends er{constructor(t={}){super();$(this,at);this.config=t,_(this,at,new Map)}build(t,n,s){const a=n.queryKey,o=n.queryHash??vo(a,n);let c=this.get(o);return c||(c=new Dh({client:t,queryKey:a,queryHash:o,options:t.defaultQueryOptions(n),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(c)),c}add(t){b(this,at).has(t.queryHash)||(b(this,at).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=b(this,at).get(t.queryHash);n&&(t.destroy(),n===t&&b(this,at).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return b(this,at).get(t)}getAll(){return[...b(this,at).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(s=>xi(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>xi(t,s)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},at=new WeakMap,Rc),ve,Ft,$t,Bn,Kn,Ut,qn,Hn,Pc,Hh=(Pc=class{constructor(e={}){$(this,ve);$(this,Ft);$(this,$t);$(this,Bn);$(this,Kn);$(this,Ut);$(this,qn);$(this,Hn);_(this,ve,e.queryCache||new qh),_(this,Ft,e.mutationCache||new Bh),_(this,$t,e.defaultOptions||{}),_(this,Bn,new Map),_(this,Kn,new Map),_(this,Ut,0)}mount(){Wr(this,Ut)._++,b(this,Ut)===1&&(_(this,qn,go.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onFocus())})),_(this,Hn,hs.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onOnline())})))}unmount(){var e,t;Wr(this,Ut)._--,b(this,Ut)===0&&((e=b(this,qn))==null||e.call(this),_(this,qn,void 0),(t=b(this,Hn))==null||t.call(this),_(this,Hn,void 0))}isFetching(e){return b(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return b(this,Ft).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=b(this,ve).build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Vt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return b(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),a=b(this,ve).get(s.queryHash),o=a==null?void 0:a.state.data,c=Eh(t,o);if(c!==void 0)return b(this,ve).build(this,s).setData(c,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>b(this,ve).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=b(this,ve);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=b(this,ve);return be.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=be.batch(()=>b(this,ve).findAll(e).map(a=>a.cancel(n)));return Promise.all(s).then(ke).catch(ke)}invalidateQueries(e,t={}){return be.batch(()=>(b(this,ve).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},s=be.batch(()=>b(this,ve).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,n);return n.throwOnError||(o=o.catch(ke)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(s).then(ke)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=b(this,ve).build(this,t);return n.isStaleByTime(Vt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ke).catch(ke)}fetchInfiniteQuery(e){return e.behavior=ms(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ke).catch(ke)}ensureInfiniteQueryData(e){return e.behavior=ms(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return hs.isOnline()?b(this,Ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return b(this,ve)}getMutationCache(){return b(this,Ft)}getDefaultOptions(){return b(this,$t)}setDefaultOptions(e){_(this,$t,e)}setQueryDefaults(e,t){b(this,Bn).set(mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...b(this,Bn).values()],n={};return t.forEach(s=>{vr(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){b(this,Kn).set(mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...b(this,Kn).values()],n={};return t.forEach(s=>{vr(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...b(this,$t).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vo(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===yo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...b(this,$t).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){b(this,ve).clear(),b(this,Ft).clear()}},ve=new WeakMap,Ft=new WeakMap,$t=new WeakMap,Bn=new WeakMap,Kn=new WeakMap,Ut=new WeakMap,qn=new WeakMap,Hn=new WeakMap,Pc),Vc=l.createContext(void 0),ye=e=>{const t=l.useContext(Vc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Wh=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(Vc.Provider,{value:e,children:t})),Bc=l.createContext(!1),Gh=()=>l.useContext(Bc);Bc.Provider;function Qh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Yh=l.createContext(Qh()),Xh=()=>l.useContext(Yh),Zh=(e,t,n)=>{const s=n!=null&&n.state.error&&typeof e.throwOnError=="function"?bo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},Jh=e=>{l.useEffect(()=>{e.clearReset()},[e])},em=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||bo(n,[e.error,s])),tm=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>n(s(...a)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},nm=(e,t)=>e.isLoading&&e.isFetching&&!t,rm=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ci=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Kc(e,t,n){var m,x,g,p;const s=Gh(),a=Xh(),o=ye(),c=o.defaultQueryOptions(e);(x=(m=o.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||x.call(m,c);const i=o.getQueryCache().get(c.queryHash);c._optimisticResults=s?"isRestoring":"optimistic",tm(c),Zh(c,a,i),Jh(a);const f=!o.getQueryCache().get(c.queryHash),[u]=l.useState(()=>new t(o,c)),d=u.getOptimisticResult(c),h=!s&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(v=>{const y=h?u.subscribe(be.batchCalls(v)):ke;return u.updateResult(),y},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(c)},[c,u]),rm(c,d))throw Ci(c,u,a);if(em({result:d,errorResetBoundary:a,throwOnError:c.throwOnError,query:i,suspense:c.suspense}))throw d.error;if((p=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||p.call(g,c,d),c.experimental_prefetchInRender&&!yr.isServer()&&nm(d,s)){const v=f?Ci(c,u,a):i==null?void 0:i.promise;v==null||v.catch(ke).finally(()=>{u.updateResult()})}return c.notifyOnChangeProps?d:u.trackResult(d)}function Ce(e,t){return Kc(e,Lc)}function we(e,t){const n=ye(),[s]=l.useState(()=>new Kh(n,e));l.useEffect(()=>{s.setOptions(e)},[s,e]);const a=l.useSyncExternalStore(l.useCallback(c=>s.subscribe(be.batchCalls(c)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),o=l.useCallback((c,i)=>{s.mutate(c,i).catch(ke)},[s]);if(a.error&&bo(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function jo(e,t){return Kc(e,Uh)}const ps=new Hh({defaultOptions:{queries:{staleTime:3e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});var sm={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 am(e){return e.capturedMinor<=0?"unpaid":e.refundedMinor<=0?"paid":e.refundedMinor<e.capturedMinor?"partially_refunded":"refunded"}var om="product.created.v1",im="product.updated.v1",cm="product.deleted.v1",lm="product.published.v1",dm="product.unpublished.v1",um="product.viewed.v1",fm="product.restocked.v1",hm="product.variant_price_changed.v1",mm="category.created.v1",pm="category.updated.v1",xm="category.deleted.v1",gm="order.placed.v1",vm="order.paid.v1",ym="order.fulfilled.v1",bm="order.shipped.v1",wm="order.delivered.v1",jm="order.cancelled.v1",Nm="order.refunded.v1",Cm="order.partially_refunded.v1",Sm="order.status_changed.v1",Em="order.confirmation_resend_requested.v1",Rm="order.deleted.v1",Pm="inventory.changed.v1",km="inventory.reserved.v1",Tm="inventory.released.v1",Am="inventory.low_stock.v1",Mm="inventory.out_of_stock.v1",_m="customer.created.v1",Im="customer.updated.v1",Om="customer.deleted.v1",Dm="visitor.merged.v1",zm="cart.created.v1",Lm="cart.item_added.v1",Fm="cart.item_removed.v1",$m="cart.updated.v1",Um="cart.abandoned.v1",Vm="cart.converted.v1",Bm="payment.intent_created.v1",Km="payment.captured.v1",qm="payment.failed.v1",Hm="payment.refunded.v1",Wm="alert.requested.v1",Gm="alert.repeated.v1",Qm="alert.confirmed.v1",Ym="alert.unsubscribed.v1",Xm="alert.sent.v1",Zm="alert.confirmation_sent.v1",Jm="review.submitted.v1",ep="proposal.created.v1",tp="proposal.approved.v1",np="proposal.rejected.v1",rp="proposal.applied.v1",sp="proposal.failed.v1",ap="adapter.error.v1",op="settings.changed.v1",ip=[om,im,cm,lm,dm,um,fm,hm,mm,pm,xm,gm,vm,ym,bm,wm,jm,Nm,Cm,Sm,Em,Rm,Pm,km,Tm,Am,Mm,_m,Im,Om,Dm,zm,Lm,Fm,$m,Um,Vm,Bm,Km,qm,Hm,Wm,Gm,Qm,Ym,Xm,Zm,Jm,ep,tp,np,rp,sp,ap,op],cp="idempotency-key",lp=["product.update","inventory.adjust","order.refund","order.cancel"];class Ae extends Error{constructor(t,n,s,a){super(n),this.code=t,this.status=s,this.context=a,this.name="ApiError"}}const dp="x-csrf-token",up=new Set(["POST","PUT","PATCH","DELETE"]);let os=null;function fp(){return os??(os=fetch("/api/csrf").then(async e=>{var n;const t=await e.json();if(!e.ok||!((n=t.data)!=null&&n.token))throw new Ae("csrf.unavailable",`GET /api/csrf answered ${e.status}`,e.status);return t.data.token}).catch(e=>{throw os=null,e})),os}async function hp(e){var n;return e.status!==403?!1:((n=(await e.clone().json().catch(()=>({}))).error)==null?void 0:n.code)==="csrf.invalid"}async function No(e,t={}){const n=(t.method??"GET").toUpperCase();if(!up.has(n))return fetch(e,t);const s=async()=>{const o=new Headers(t.headers);return o.set(dp,await fp()),fetch(e,{...t,headers:o})},a=await s();return await hp(a)?(os=null,s()):a}function mp(e,t){if(!t)return e;const n=new URLSearchParams;for(const[a,o]of Object.entries(t))o!=null&&o!==""&&n.set(a,String(o));const s=n.toString();return s?`${e}?${s}`:e}async function pp(e){const t=Hc();return t!==e?t!==null:yp()}function Ka(){return crypto.randomUUID()}async function At(e,t,n,s={}){const{query:a,retried:o=!1}=s,c=Hc(),i={};c&&(i.Authorization=`Bearer ${c}`),s.idempotencyKey!==void 0&&(i[cp]=s.idempotencyKey);const f=mp(t,a),u={method:e,headers:i};n!==void 0&&(i["Content-Type"]="application/json",u.body=JSON.stringify(n));const d=await No(f,u);if(d.status===401){if(!o&&c!==null&&!t.startsWith("/api/auth/")&&await pp(c))return At(e,t,n,{...s,retried:!0});const x=(await d.json().catch(()=>({}))).error;throw new Ae((x==null?void 0:x.code)??"UNAUTHORIZED",(x==null?void 0:x.message)??"Unauthorized",401)}if(s.text&&d.ok)return await d.text();const h=await d.json();if(!d.ok){const m=h.error;throw new Ae((m==null?void 0:m.code)??"UNKNOWN_ERROR",(m==null?void 0:m.message)??`HTTP ${d.status}`,d.status,m==null?void 0:m.context)}return s.envelope?h:"data"in h?h.data:h}function Yr(e,t){const n=(e==null?void 0:e.idempotencyKey)??(t.startsWith("/api/admin/")?Ka():void 0);return n===void 0?{}:{idempotencyKey:n}}const W={get(e,t){return At("GET",e,void 0,t===void 0?{}:{query:t})},getPage(e,t){return At("GET",e,void 0,{envelope:!0,...t&&{query:t}})},getText(e,t){return At("GET",e,void 0,{text:!0,...t&&{query:t}})},post(e,t,n){return At("POST",e,t,Yr(n,e))},patch(e,t,n){return At("PATCH",e,t,Yr(n,e))},put(e,t,n){return At("PUT",e,t,Yr(n,e))},delete(e,t){return At("DELETE",e,void 0,Yr(t,e))}};let Ps=null,ca=null;const qa=new Set;function qc(e){Ps=e}function Hc(){return Ps}function Wc(){Ps=null}function xs(){return Ps!==null}function xp(e){return qa.add(e),()=>{qa.delete(e)}}async function Gc(e){var t;return await((t=e.body)==null?void 0:t.cancel()),!1}async function gp(e){var t,n;try{const s=await fetch("/api/admin/me",{headers:{Authorization:`Bearer ${e}`}});return s.ok?((n=(t=(await s.json()).data)==null?void 0:t.roles)==null?void 0:n.includes("admin"))??!1:Gc(s)}catch{return!1}}async function vp(){var t;let e;try{const n=await No("/api/auth/refresh",{method:"POST"});if(!n.ok)return Gc(n);e=(t=(await n.json()).data)==null?void 0:t.accessToken}catch{return!1}return!e||!await gp(e)?!1:(qc(e),!0)}function Qc(e){return ca??(ca=vp().then(t=>{if(ca=null,!t&&(Wc(),e))for(const n of[...qa])n();return t})),ca}function yp(){return Qc(!0)}function bp(){return Qc(!1)}/**
9
+ */var hi;function gh(){if(hi)return ur;hi=1;var e=ih(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(i,f,u){var d,h={},m=null,x=null;u!==void 0&&(m=""+u),f.key!==void 0&&(m=""+f.key),f.ref!==void 0&&(x=f.ref);for(d in f)s.call(f,d)&&!o.hasOwnProperty(d)&&(h[d]=f[d]);if(i&&i.defaultProps)for(d in f=i.defaultProps,f)h[d]===void 0&&(h[d]=f[d]);return{$$typeof:t,type:i,key:m,ref:x,props:h,_owner:a.current}}return ur.Fragment=n,ur.jsx=c,ur.jsxs=c,ur}var mi;function vh(){return mi||(mi=1,ca.exports=gh()),ca.exports}var r=vh(),Gr={},pi;function yh(){if(pi)return Gr;pi=1;var e=ch();return Gr.createRoot=e.createRoot,Gr.hydrateRoot=e.hydrateRoot,Gr}var bh=yh(),er=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(){}},sn,_t,On,vc,wh=(vc=class extends er{constructor(){super();$(this,sn);$(this,_t);$(this,On);_(this,On,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){b(this,_t)||this.setEventListener(b(this,On))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,_t))==null||t.call(this),_(this,_t,void 0))}setEventListener(t){var n;_(this,On,t),(n=b(this,_t))==null||n.call(this),_(this,_t,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){b(this,sn)!==t&&(_(this,sn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof b(this,sn)=="boolean"?b(this,sn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},sn=new WeakMap,_t=new WeakMap,On=new WeakMap,vc),go=new wh,jh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},It,mo,yc,Nh=(yc=class{constructor(){$(this,It,jh);$(this,mo,!1)}setTimeoutProvider(e){_(this,It,e)}setTimeout(e,t){return b(this,It).setTimeout(e,t)}clearTimeout(e){b(this,It).clearTimeout(e)}setInterval(e,t){return b(this,It).setInterval(e,t)}clearInterval(e){b(this,It).clearInterval(e)}},It=new WeakMap,mo=new WeakMap,yc),rn=new Nh;function Ch(e){setTimeout(e,0)}var Sh=typeof window>"u"||"Deno"in globalThis;function ke(){}function Eh(e,t){return typeof e=="function"?e(t):e}function ka(e){return typeof e=="number"&&e>=0&&e!==1/0}function Tc(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Vt(e,t){return typeof e=="function"?e(t):e}function Fe(e,t){return typeof e=="function"?e(t):e}function xi(e,t){const{type:n="all",exact:s,fetchStatus:a,predicate:o,queryKey:c,stale:i}=e;if(c){if(s){if(t.queryHash!==vo(c,t.options))return!1}else if(!vr(t.queryKey,c))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="inactive"&&f)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||a&&a!==t.state.fetchStatus||o&&!o(t))}function gi(e,t){const{exact:n,status:s,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(mn(t.options.mutationKey)!==mn(o))return!1}else if(!vr(t.options.mutationKey,o))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function vo(e,t){return((t==null?void 0:t.queryKeyHashFn)||mn)(e)}function mn(e){return JSON.stringify(e,(t,n)=>Ta(n)?Object.keys(n).sort().reduce((s,a)=>(s[a]=n[a],s),{}):n)}function vr(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>vr(e[n],t[n])):!1}var Rh=Object.prototype.hasOwnProperty;function Ac(e,t,n=0){if(e===t)return e;if(n>500)return t;const s=vi(e)&&vi(t);if(!s&&!(Ta(e)&&Ta(t)))return t;const o=(s?e:Object.keys(e)).length,c=s?t:Object.keys(t),i=c.length,f=s?new Array(i):{};let u=0;for(let d=0;d<i;d++){const h=s?d:c[d],m=e[h],x=t[h];if(m===x){f[h]=m,(s?d<o:Rh.call(e,h))&&u++;continue}if(m===null||x===null||typeof m!="object"||typeof x!="object"){f[h]=x;continue}const g=Ac(m,x,n+1);f[h]=g,g===m&&u++}return o===i&&u===o?e:f}function hs(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 vi(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ta(e){if(!yi(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!yi(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function yi(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ph(e){return new Promise(t=>{rn.setTimeout(t,e)})}function Aa(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Ac(e,t):t}function kh(e,t,n=0){const s=[...e,t];return n&&s.length>n?s.slice(1):s}function Th(e,t,n=0){const s=[t,...e];return n&&s.length>n?s.slice(0,-1):s}var yo=Symbol();function Mc(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===yo?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function bo(e,t){return typeof e=="function"?e(...t):!!e}function Ah(e,t,n){let s=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),s||(s=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var yr=(()=>{let e=()=>Sh;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ma(){let e,t;const n=new Promise((a,o)=>{e=a,t=o});n.status="pending",n.catch(()=>{});function s(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},n.reject=a=>{s({status:"rejected",reason:a}),t(a)},n}var Mh=Ch;function _h(){let e=[],t=0,n=i=>{i()},s=i=>{i()},a=Mh;const o=i=>{t?e.push(i):a(()=>{n(i)})},c=()=>{const i=e;e=[],i.length&&a(()=>{s(()=>{i.forEach(f=>{n(f)})})})};return{batch:i=>{let f;t++;try{f=i()}finally{t--,t||c()}return f},batchCalls:i=>(...f)=>{o(()=>{i(...f)})},schedule:o,setNotifyFunction:i=>{n=i},setBatchNotifyFunction:i=>{s=i},setScheduler:i=>{a=i}}}var be=_h(),Dn,Ot,zn,bc,Ih=(bc=class extends er{constructor(){super();$(this,Dn,!0);$(this,Ot);$(this,zn);_(this,zn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}onSubscribe(){b(this,Ot)||this.setEventListener(b(this,zn))}onUnsubscribe(){var t;this.hasListeners()||((t=b(this,Ot))==null||t.call(this),_(this,Ot,void 0))}setEventListener(t){var n;_(this,zn,t),(n=b(this,Ot))==null||n.call(this),_(this,Ot,t(this.setOnline.bind(this)))}setOnline(t){b(this,Dn)!==t&&(_(this,Dn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return b(this,Dn)}},Dn=new WeakMap,Ot=new WeakMap,zn=new WeakMap,bc),ms=new Ih;function Oh(e){return Math.min(1e3*2**e,3e4)}function _c(e){return(e??"online")==="online"?ms.isOnline():!0}var _a=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Ic(e){let t=!1,n=0,s;const a=Ma(),o=()=>a.status!=="pending",c=p=>{var v;if(!o()){const y=new _a(p);m(y),(v=e.onCancel)==null||v.call(e,y)}},i=()=>{t=!0},f=()=>{t=!1},u=()=>go.isFocused()&&(e.networkMode==="always"||ms.isOnline())&&e.canRun(),d=()=>_c(e.networkMode)&&e.canRun(),h=p=>{o()||(s==null||s(),a.resolve(p))},m=p=>{o()||(s==null||s(),a.reject(p))},x=()=>new Promise(p=>{var v;s=y=>{(o()||u())&&p(y)},(v=e.onPause)==null||v.call(e)}).then(()=>{var p;s=void 0,o()||(p=e.onContinue)==null||p.call(e)}),g=()=>{if(o())return;let p;const v=n===0?e.initialPromise:void 0;try{p=v??e.fn()}catch(y){p=Promise.reject(y)}Promise.resolve(p).then(h).catch(y=>{var S;if(o())return;const w=e.retry??(yr.isServer()?0:3),N=e.retryDelay??Oh,j=typeof N=="function"?N(n,y):N,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,y);if(t||!C){m(y);return}n++,(S=e.onFail)==null||S.call(e,n,y),Ph(j).then(()=>u()?void 0:x()).then(()=>{t?m(y):g()})})};return{promise:a,status:()=>a.status,cancel:c,continue:()=>(s==null||s(),a),cancelRetry:i,continueRetry:f,canStart:d,start:()=>(d()?g():x().then(g),a)}}var an,wc,Oc=(wc=class{constructor(){$(this,an)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ka(this.gcTime)&&_(this,an,rn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(yr.isServer()?1/0:300*1e3))}clearGcTimeout(){b(this,an)!==void 0&&(rn.clearTimeout(b(this,an)),_(this,an,void 0))}},an=new WeakMap,wc),on,Ln,Ke,cn,je,Rr,ln,Le,Dc,pt,jc,Dh=(jc=class extends Oc{constructor(t){super();$(this,Le);$(this,on);$(this,Ln);$(this,Ke);$(this,cn);$(this,je);$(this,Rr);$(this,ln);_(this,ln,!1),_(this,Rr,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,cn,t.client),_(this,Ke,b(this,cn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,on,wi(this.options)),this.state=t.state??b(this,on),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=b(this,je))==null?void 0:t.promise}setOptions(t){if(this.options={...b(this,Rr),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=wi(this.options);n.data!==void 0&&(this.setState(bi(n.data,n.dataUpdatedAt)),_(this,on,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&b(this,Ke).remove(this)}setData(t,n){const s=Aa(this.state.data,t,this.options);return ee(this,Le,pt).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(t,n){ee(this,Le,pt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var s,a;const n=(s=b(this,je))==null?void 0:s.promise;return(a=b(this,je))==null||a.cancel(t),n?n.then(ke).catch(ke):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return b(this,on)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Fe(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===yo||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Vt(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:!Tc(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}onOnline(){var n;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=b(this,je))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),b(this,Ke).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,je)&&(b(this,ln)||ee(this,Le,Dc).call(this)?b(this,je).cancel({revert:!0}):b(this,je).cancelRetry()),this.scheduleGc()),b(this,Ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ee(this,Le,pt).call(this,{type:"invalidate"})}async fetch(t,n){var f,u,d,h,m,x,g,p,v,y,w,N;if(this.state.fetchStatus!=="idle"&&((f=b(this,je))==null?void 0:f.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(b(this,je))return b(this,je).continueRetry(),b(this,je).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const s=new AbortController,a=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(_(this,ln,!0),s.signal)})},o=()=>{const j=Mc(this.options,n),S=(()=>{const E={client:b(this,cn),queryKey:this.queryKey,meta:this.meta};return a(E),E})();return _(this,ln,!1),this.options.persister?this.options.persister(j,S,this):j(S)},i=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:b(this,cn),state:this.state,fetchFn:o};return a(j),j})();(u=this.options.behavior)==null||u.onFetch(i,this),_(this,Ln,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=i.fetchOptions)==null?void 0:d.meta))&&ee(this,Le,pt).call(this,{type:"fetch",meta:(h=i.fetchOptions)==null?void 0:h.meta}),_(this,je,Ic({initialPromise:n==null?void 0:n.initialPromise,fn:i.fetchFn,onCancel:j=>{j instanceof _a&&j.revert&&this.setState({...b(this,Ln),fetchStatus:"idle"}),s.abort()},onFail:(j,C)=>{ee(this,Le,pt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{ee(this,Le,pt).call(this,{type:"pause"})},onContinue:()=>{ee(this,Le,pt).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const j=await b(this,je).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(m=b(this,Ke).config).onSuccess)==null||x.call(m,j,this),(p=(g=b(this,Ke).config).onSettled)==null||p.call(g,j,this.state.error,this),j}catch(j){if(j instanceof _a){if(j.silent)return b(this,je).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw ee(this,Le,pt).call(this,{type:"error",error:j}),(y=(v=b(this,Ke).config).onError)==null||y.call(v,j,this),(N=(w=b(this,Ke).config).onSettled)==null||N.call(w,this.state.data,j,this),j}finally{this.scheduleGc()}}},on=new WeakMap,Ln=new WeakMap,Ke=new WeakMap,cn=new WeakMap,je=new WeakMap,Rr=new WeakMap,ln=new WeakMap,Le=new WeakSet,Dc=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},pt=function(t){const n=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...zc(s.data,this.options),fetchMeta:t.meta??null};case"success":const a={...s,...bi(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Ln,t.manual?a:void 0),a;case"error":const o=t.error;return{...s,error:o,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),b(this,Ke).notify({query:this,type:"updated",action:t})})},jc);function zc(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:_c(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function bi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wi(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,s=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var _e,oe,Pr,Pe,dn,Fn,xt,Dt,kr,$n,Un,un,fn,zt,Vn,ue,pr,Ia,Oa,Da,za,La,Fa,$a,Fc,Nc,Lc=(Nc=class extends er{constructor(t,n){super();$(this,ue);$(this,_e);$(this,oe);$(this,Pr);$(this,Pe);$(this,dn);$(this,Fn);$(this,xt);$(this,Dt);$(this,kr);$(this,$n);$(this,Un);$(this,un);$(this,fn);$(this,zt);$(this,Vn,new Set);this.options=n,_(this,_e,t),_(this,Dt,null),_(this,xt,Ma()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(b(this,oe).addObserver(this),ji(b(this,oe),this.options)?ee(this,ue,pr).call(this):this.updateResult(),ee(this,ue,za).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ua(b(this,oe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ua(b(this,oe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ee(this,ue,La).call(this),ee(this,ue,Fa).call(this),b(this,oe).removeObserver(this)}setOptions(t){const n=this.options,s=b(this,oe);if(this.options=b(this,_e).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Fe(this.options.enabled,b(this,oe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ee(this,ue,$a).call(this),b(this,oe).setOptions(this.options),n._defaulted&&!hs(this.options,n)&&b(this,_e).getQueryCache().notify({type:"observerOptionsUpdated",query:b(this,oe),observer:this});const a=this.hasListeners();a&&Ni(b(this,oe),s,this.options,n)&&ee(this,ue,pr).call(this),this.updateResult(),a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||Vt(this.options.staleTime,b(this,oe))!==Vt(n.staleTime,b(this,oe)))&&ee(this,ue,Ia).call(this);const o=ee(this,ue,Oa).call(this);a&&(b(this,oe)!==s||Fe(this.options.enabled,b(this,oe))!==Fe(n.enabled,b(this,oe))||o!==b(this,zt))&&ee(this,ue,Da).call(this,o)}getOptimisticResult(t){const n=b(this,_e).getQueryCache().build(b(this,_e),t),s=this.createResult(n,t);return Lh(this,s)&&(_(this,Pe,s),_(this,Fn,this.options),_(this,dn,b(this,oe).state)),s}getCurrentResult(){return b(this,Pe)}trackResult(t,n){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&b(this,xt).status==="pending"&&b(this,xt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,a))})}trackProp(t){b(this,Vn).add(t)}getCurrentQuery(){return b(this,oe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=b(this,_e).defaultQueryOptions(t),s=b(this,_e).getQueryCache().build(b(this,_e),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(t){return ee(this,ue,pr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),b(this,Pe)))}createResult(t,n){var z;const s=b(this,oe),a=this.options,o=b(this,Pe),c=b(this,dn),i=b(this,Fn),u=t!==s?t.state:b(this,Pr),{state:d}=t;let h={...d},m=!1,x;if(n._optimisticResults){const O=this.hasListeners(),U=!O&&ji(t,n),I=O&&Ni(t,s,n,a);(U||I)&&(h={...h,...zc(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:g,errorUpdatedAt:p,status:v}=h;x=h.data;let y=!1;if(n.placeholderData!==void 0&&x===void 0&&v==="pending"){let O;o!=null&&o.isPlaceholderData&&n.placeholderData===(i==null?void 0:i.placeholderData)?(O=o.data,y=!0):O=typeof n.placeholderData=="function"?n.placeholderData((z=b(this,Un))==null?void 0:z.state.data,b(this,Un)):n.placeholderData,O!==void 0&&(v="success",x=Aa(o==null?void 0:o.data,O,n),m=!0)}if(n.select&&x!==void 0&&!y)if(o&&x===(c==null?void 0:c.data)&&n.select===b(this,kr))x=b(this,$n);else try{_(this,kr,n.select),x=n.select(x),x=Aa(o==null?void 0:o.data,x,n),_(this,$n,x),_(this,Dt,null)}catch(O){_(this,Dt,O)}b(this,Dt)&&(g=b(this,Dt),x=b(this,$n),p=Date.now(),v="error");const w=h.fetchStatus==="fetching",N=v==="pending",j=v==="error",C=N&&w,S=x!==void 0,k={status:v,fetchStatus:h.fetchStatus,isPending:N,isSuccess:v==="success",isError:j,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!N,isLoadingError:j&&!S,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:wo(t,n),refetch:this.refetch,promise:b(this,xt),isEnabled:Fe(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=k.data!==void 0,U=k.status==="error"&&!O,I=Z=>{U?Z.reject(k.error):O&&Z.resolve(k.data)},Q=()=>{const Z=_(this,xt,k.promise=Ma());I(Z)},V=b(this,xt);switch(V.status){case"pending":t.queryHash===s.queryHash&&I(V);break;case"fulfilled":(U||k.data!==V.value)&&Q();break;case"rejected":(!U||k.error!==V.reason)&&Q();break}}return k}updateResult(){const t=b(this,Pe),n=this.createResult(b(this,oe),this.options);if(_(this,dn,b(this,oe).state),_(this,Fn,this.options),b(this,dn).data!==void 0&&_(this,Un,b(this,oe)),hs(n,t))return;_(this,Pe,n);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!b(this,Vn).size)return!0;const c=new Set(o??b(this,Vn));return this.options.throwOnError&&c.add("error"),Object.keys(b(this,Pe)).some(i=>{const f=i;return b(this,Pe)[f]!==t[f]&&c.has(f)})};ee(this,ue,Fc).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ee(this,ue,za).call(this)}},_e=new WeakMap,oe=new WeakMap,Pr=new WeakMap,Pe=new WeakMap,dn=new WeakMap,Fn=new WeakMap,xt=new WeakMap,Dt=new WeakMap,kr=new WeakMap,$n=new WeakMap,Un=new WeakMap,un=new WeakMap,fn=new WeakMap,zt=new WeakMap,Vn=new WeakMap,ue=new WeakSet,pr=function(t){ee(this,ue,$a).call(this);let n=b(this,oe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(ke)),n},Ia=function(){ee(this,ue,La).call(this);const t=Vt(this.options.staleTime,b(this,oe));if(yr.isServer()||b(this,Pe).isStale||!ka(t))return;const s=Tc(b(this,Pe).dataUpdatedAt,t)+1;_(this,un,rn.setTimeout(()=>{b(this,Pe).isStale||this.updateResult()},s))},Oa=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(b(this,oe)):this.options.refetchInterval)??!1},Da=function(t){ee(this,ue,Fa).call(this),_(this,zt,t),!(yr.isServer()||Fe(this.options.enabled,b(this,oe))===!1||!ka(b(this,zt))||b(this,zt)===0)&&_(this,fn,rn.setInterval(()=>{(this.options.refetchIntervalInBackground||go.isFocused())&&ee(this,ue,pr).call(this)},b(this,zt)))},za=function(){ee(this,ue,Ia).call(this),ee(this,ue,Da).call(this,ee(this,ue,Oa).call(this))},La=function(){b(this,un)!==void 0&&(rn.clearTimeout(b(this,un)),_(this,un,void 0))},Fa=function(){b(this,fn)!==void 0&&(rn.clearInterval(b(this,fn)),_(this,fn,void 0))},$a=function(){const t=b(this,_e).getQueryCache().build(b(this,_e),this.options);if(t===b(this,oe))return;const n=b(this,oe);_(this,oe,t),_(this,Pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Fc=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(b(this,Pe))}),b(this,_e).getQueryCache().notify({query:b(this,oe),type:"observerResultsUpdated"})})},Nc);function zh(e,t){return Fe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Fe(t.retryOnMount,e)===!1)}function ji(e,t){return zh(e,t)||e.state.data!==void 0&&Ua(e,t,t.refetchOnMount)}function Ua(e,t,n){if(Fe(t.enabled,e)!==!1&&Vt(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&wo(e,t)}return!1}function Ni(e,t,n,s){return(e!==t||Fe(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&wo(e,n)}function wo(e,t){return Fe(t.enabled,e)!==!1&&e.isStaleByTime(Vt(t.staleTime,e))}function Lh(e,t){return!hs(e.getCurrentResult(),t)}function ps(e){return{onFetch:(t,n)=>{var d,h,m,x,g;const s=t.options,a=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,o=((x=t.state.data)==null?void 0:x.pages)||[],c=((g=t.state.data)==null?void 0:g.pageParams)||[];let i={pages:[],pageParams:[]},f=0;const u=async()=>{let p=!1;const v=N=>{Ah(N,()=>t.signal,()=>p=!0)},y=Mc(t.options,t.fetchOptions),w=async(N,j,C)=>{if(p)return Promise.reject();if(j==null&&N.pages.length)return Promise.resolve(N);const E=(()=>{const U={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return v(U),U})(),k=await y(E),{maxPages:z}=t.options,O=C?Th:kh;return{pages:O(N.pages,k,z),pageParams:O(N.pageParams,j,z)}};if(a&&o.length){const N=a==="backward",j=N?$c:Va,C={pages:o,pageParams:c},S=j(s,C);i=await w(C,S,N)}else{const N=e??o.length;do{const j=f===0?c[0]??s.initialPageParam:Va(s,i);if(f>0&&j==null)break;i=await w(i,j),f++}while(f<N)}return i};t.options.persister?t.fetchFn=()=>{var p,v;return(v=(p=t.options).persister)==null?void 0:v.call(p,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Va(e,{pages:t,pageParams:n}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,n[s],n):void 0}function $c(e,{pages:t,pageParams:n}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,n[0],n):void 0}function Fh(e,t){return t?Va(e,t)!=null:!1}function $h(e,t){return!t||!e.getPreviousPageParam?!1:$c(e,t)!=null}var Uh=class extends Lc{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ps()})}getOptimisticResult(e){return e.behavior=ps(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var g,p;const{state:n}=e,s=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:c,isRefetchError:i}=s,f=(p=(g=n.fetchMeta)==null?void 0:g.fetchMore)==null?void 0:p.direction,u=c&&f==="forward",d=a&&f==="forward",h=c&&f==="backward",m=a&&f==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Fh(t,n.data),hasPreviousPage:$h(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:m,isRefetchError:i&&!u&&!h,isRefetching:o&&!d&&!m}}},Tr,rt,Se,hn,st,Tt,Cc,Vh=(Cc=class extends Oc{constructor(t){super();$(this,st);$(this,Tr);$(this,rt);$(this,Se);$(this,hn);_(this,Tr,t.client),this.mutationId=t.mutationId,_(this,Se,t.mutationCache),_(this,rt,[]),this.state=t.state||Uc(),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,rt).includes(t)||(b(this,rt).push(t),this.clearGcTimeout(),b(this,Se).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,rt,b(this,rt).filter(n=>n!==t)),this.scheduleGc(),b(this,Se).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){b(this,rt).length||(this.state.status==="pending"?this.scheduleGc():b(this,Se).remove(this))}continue(){var t;return((t=b(this,hn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var c,i,f,u,d,h,m,x,g,p,v,y,w,N,j,C,S,E;const n=()=>{ee(this,st,Tt).call(this,{type:"continue"})},s={client:b(this,Tr),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,hn,Ic({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(k,z)=>{ee(this,st,Tt).call(this,{type:"failed",failureCount:k,error:z})},onPause:()=>{ee(this,st,Tt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>b(this,Se).canRun(this)}));const a=this.state.status==="pending",o=!b(this,hn).canStart();try{if(a)n();else{ee(this,st,Tt).call(this,{type:"pending",variables:t,isPaused:o}),b(this,Se).config.onMutate&&await b(this,Se).config.onMutate(t,this,s);const z=await((i=(c=this.options).onMutate)==null?void 0:i.call(c,t,s));z!==this.state.context&&ee(this,st,Tt).call(this,{type:"pending",context:z,variables:t,isPaused:o})}const k=await b(this,hn).start();return await((u=(f=b(this,Se).config).onSuccess)==null?void 0:u.call(f,k,t,this.state.context,this,s)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,k,t,this.state.context,s)),await((x=(m=b(this,Se).config).onSettled)==null?void 0:x.call(m,k,null,this.state.variables,this.state.context,this,s)),await((p=(g=this.options).onSettled)==null?void 0:p.call(g,k,null,t,this.state.context,s)),ee(this,st,Tt).call(this,{type:"success",data:k}),k}catch(k){try{await((y=(v=b(this,Se).config).onError)==null?void 0:y.call(v,k,t,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((N=(w=this.options).onError)==null?void 0:N.call(w,k,t,this.state.context,s))}catch(z){Promise.reject(z)}try{await((C=(j=b(this,Se).config).onSettled)==null?void 0:C.call(j,void 0,k,this.state.variables,this.state.context,this,s))}catch(z){Promise.reject(z)}try{await((E=(S=this.options).onSettled)==null?void 0:E.call(S,void 0,k,t,this.state.context,s))}catch(z){Promise.reject(z)}throw ee(this,st,Tt).call(this,{type:"error",error:k}),k}finally{b(this,Se).runNext(this)}}},Tr=new WeakMap,rt=new WeakMap,Se=new WeakMap,hn=new WeakMap,st=new WeakSet,Tt=function(t){const n=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{b(this,rt).forEach(s=>{s.onMutationUpdate(t)}),b(this,Se).notify({mutation:this,type:"updated",action:t})})},Cc);function Uc(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var gt,Ye,Ar,Sc,Bh=(Sc=class extends er{constructor(t={}){super();$(this,gt);$(this,Ye);$(this,Ar);this.config=t,_(this,gt,new Set),_(this,Ye,new Map),_(this,Ar,0)}build(t,n,s){const a=new Vh({client:t,mutationCache:this,mutationId:++Wr(this,Ar)._,options:t.defaultMutationOptions(n),state:s});return this.add(a),a}add(t){b(this,gt).add(t);const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n);s?s.push(t):b(this,Ye).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(b(this,gt).delete(t)){const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&b(this,Ye).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Qr(t);if(typeof n=="string"){const s=b(this,Ye).get(n),a=s==null?void 0:s.find(o=>o.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const n=Qr(t);if(typeof n=="string"){const a=(s=b(this,Ye).get(n))==null?void 0:s.find(o=>o!==t&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{b(this,gt).forEach(t=>{this.notify({type:"removed",mutation:t})}),b(this,gt).clear(),b(this,Ye).clear()})}getAll(){return Array.from(b(this,gt))}find(t){const n={exact:!0,...t};return this.getAll().find(s=>gi(n,s))}findAll(t={}){return this.getAll().filter(n=>gi(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(ke))))}},gt=new WeakMap,Ye=new WeakMap,Ar=new WeakMap,Sc);function Qr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var vt,Lt,Ie,yt,wt,os,Ba,Ec,Kh=(Ec=class extends er{constructor(n,s){super();$(this,wt);$(this,vt);$(this,Lt);$(this,Ie);$(this,yt);_(this,vt,n),this.setOptions(s),this.bindMethods(),ee(this,wt,os).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const s=this.options;this.options=b(this,vt).defaultMutationOptions(n),hs(this.options,s)||b(this,vt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:b(this,Ie),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&mn(s.mutationKey)!==mn(this.options.mutationKey)?this.reset():((a=b(this,Ie))==null?void 0:a.state.status)==="pending"&&b(this,Ie).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=b(this,Ie))==null||n.removeObserver(this)}onMutationUpdate(n){ee(this,wt,os).call(this),ee(this,wt,Ba).call(this,n)}getCurrentResult(){return b(this,Lt)}reset(){var n;(n=b(this,Ie))==null||n.removeObserver(this),_(this,Ie,void 0),ee(this,wt,os).call(this),ee(this,wt,Ba).call(this)}mutate(n,s){var a;return _(this,yt,s),(a=b(this,Ie))==null||a.removeObserver(this),_(this,Ie,b(this,vt).getMutationCache().build(b(this,vt),this.options)),b(this,Ie).addObserver(this),b(this,Ie).execute(n)}},vt=new WeakMap,Lt=new WeakMap,Ie=new WeakMap,yt=new WeakMap,wt=new WeakSet,os=function(){var s;const n=((s=b(this,Ie))==null?void 0:s.state)??Uc();_(this,Lt,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ba=function(n){be.batch(()=>{var s,a,o,c,i,f,u,d;if(b(this,yt)&&this.hasListeners()){const h=b(this,Lt).variables,m=b(this,Lt).context,x={client:b(this,vt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(s=b(this,yt)).onSuccess)==null||a.call(s,n.data,h,m,x)}catch(g){Promise.reject(g)}try{(c=(o=b(this,yt)).onSettled)==null||c.call(o,n.data,null,h,m,x)}catch(g){Promise.reject(g)}}else if((n==null?void 0:n.type)==="error"){try{(f=(i=b(this,yt)).onError)==null||f.call(i,n.error,h,m,x)}catch(g){Promise.reject(g)}try{(d=(u=b(this,yt)).onSettled)==null||d.call(u,void 0,n.error,h,m,x)}catch(g){Promise.reject(g)}}}this.listeners.forEach(h=>{h(b(this,Lt))})})},Ec),at,Rc,qh=(Rc=class extends er{constructor(t={}){super();$(this,at);this.config=t,_(this,at,new Map)}build(t,n,s){const a=n.queryKey,o=n.queryHash??vo(a,n);let c=this.get(o);return c||(c=new Dh({client:t,queryKey:a,queryHash:o,options:t.defaultQueryOptions(n),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(c)),c}add(t){b(this,at).has(t.queryHash)||(b(this,at).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=b(this,at).get(t.queryHash);n&&(t.destroy(),n===t&&b(this,at).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return b(this,at).get(t)}getAll(){return[...b(this,at).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(s=>xi(n,s))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(s=>xi(t,s)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},at=new WeakMap,Rc),ve,Ft,$t,Bn,Kn,Ut,qn,Hn,Pc,Hh=(Pc=class{constructor(e={}){$(this,ve);$(this,Ft);$(this,$t);$(this,Bn);$(this,Kn);$(this,Ut);$(this,qn);$(this,Hn);_(this,ve,e.queryCache||new qh),_(this,Ft,e.mutationCache||new Bh),_(this,$t,e.defaultOptions||{}),_(this,Bn,new Map),_(this,Kn,new Map),_(this,Ut,0)}mount(){Wr(this,Ut)._++,b(this,Ut)===1&&(_(this,qn,go.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onFocus())})),_(this,Hn,ms.subscribe(async e=>{e&&(await this.resumePausedMutations(),b(this,ve).onOnline())})))}unmount(){var e,t;Wr(this,Ut)._--,b(this,Ut)===0&&((e=b(this,qn))==null||e.call(this),_(this,qn,void 0),(t=b(this,Hn))==null||t.call(this),_(this,Hn,void 0))}isFetching(e){return b(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return b(this,Ft).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=b(this,ve).build(this,t),s=n.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Vt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return b(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const s=n.data;return[t,s]})}setQueryData(e,t,n){const s=this.defaultQueryOptions({queryKey:e}),a=b(this,ve).get(s.queryHash),o=a==null?void 0:a.state.data,c=Eh(t,o);if(c!==void 0)return b(this,ve).build(this,s).setData(c,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>b(this,ve).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=b(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=b(this,ve);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=b(this,ve);return be.batch(()=>(n.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},s=be.batch(()=>b(this,ve).findAll(e).map(a=>a.cancel(n)));return Promise.all(s).then(ke).catch(ke)}invalidateQueries(e,t={}){return be.batch(()=>(b(this,ve).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},s=be.batch(()=>b(this,ve).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,n);return n.throwOnError||(o=o.catch(ke)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(s).then(ke)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=b(this,ve).build(this,t);return n.isStaleByTime(Vt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ke).catch(ke)}fetchInfiniteQuery(e){return e.behavior=ps(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ke).catch(ke)}ensureInfiniteQueryData(e){return e.behavior=ps(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ms.isOnline()?b(this,Ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return b(this,ve)}getMutationCache(){return b(this,Ft)}getDefaultOptions(){return b(this,$t)}setDefaultOptions(e){_(this,$t,e)}setQueryDefaults(e,t){b(this,Bn).set(mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...b(this,Bn).values()],n={};return t.forEach(s=>{vr(e,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(e,t){b(this,Kn).set(mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...b(this,Kn).values()],n={};return t.forEach(s=>{vr(e,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...b(this,$t).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vo(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===yo&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...b(this,$t).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){b(this,ve).clear(),b(this,Ft).clear()}},ve=new WeakMap,Ft=new WeakMap,$t=new WeakMap,Bn=new WeakMap,Kn=new WeakMap,Ut=new WeakMap,qn=new WeakMap,Hn=new WeakMap,Pc),Vc=l.createContext(void 0),ye=e=>{const t=l.useContext(Vc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Wh=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(Vc.Provider,{value:e,children:t})),Bc=l.createContext(!1),Gh=()=>l.useContext(Bc);Bc.Provider;function Qh(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Yh=l.createContext(Qh()),Xh=()=>l.useContext(Yh),Zh=(e,t,n)=>{const s=n!=null&&n.state.error&&typeof e.throwOnError=="function"?bo(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},Jh=e=>{l.useEffect(()=>{e.clearReset()},[e])},em=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||bo(n,[e.error,s])),tm=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...a)=>n(s(...a)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},nm=(e,t)=>e.isLoading&&e.isFetching&&!t,rm=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ci=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Kc(e,t,n){var m,x,g,p;const s=Gh(),a=Xh(),o=ye(),c=o.defaultQueryOptions(e);(x=(m=o.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||x.call(m,c);const i=o.getQueryCache().get(c.queryHash);c._optimisticResults=s?"isRestoring":"optimistic",tm(c),Zh(c,a,i),Jh(a);const f=!o.getQueryCache().get(c.queryHash),[u]=l.useState(()=>new t(o,c)),d=u.getOptimisticResult(c),h=!s&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(v=>{const y=h?u.subscribe(be.batchCalls(v)):ke;return u.updateResult(),y},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(c)},[c,u]),rm(c,d))throw Ci(c,u,a);if(em({result:d,errorResetBoundary:a,throwOnError:c.throwOnError,query:i,suspense:c.suspense}))throw d.error;if((p=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||p.call(g,c,d),c.experimental_prefetchInRender&&!yr.isServer()&&nm(d,s)){const v=f?Ci(c,u,a):i==null?void 0:i.promise;v==null||v.catch(ke).finally(()=>{u.updateResult()})}return c.notifyOnChangeProps?d:u.trackResult(d)}function Ce(e,t){return Kc(e,Lc)}function we(e,t){const n=ye(),[s]=l.useState(()=>new Kh(n,e));l.useEffect(()=>{s.setOptions(e)},[s,e]);const a=l.useSyncExternalStore(l.useCallback(c=>s.subscribe(be.batchCalls(c)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),o=l.useCallback((c,i)=>{s.mutate(c,i).catch(ke)},[s]);if(a.error&&bo(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function jo(e,t){return Kc(e,Uh)}const xs=new Hh({defaultOptions:{queries:{staleTime:3e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!1}}});var sm={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 am(e){return e.capturedMinor<=0?"unpaid":e.refundedMinor<=0?"paid":e.refundedMinor<e.capturedMinor?"partially_refunded":"refunded"}var om="product.created.v1",im="product.updated.v1",cm="product.deleted.v1",lm="product.published.v1",dm="product.unpublished.v1",um="product.viewed.v1",fm="product.restocked.v1",hm="product.variant_price_changed.v1",mm="category.created.v1",pm="category.updated.v1",xm="category.deleted.v1",gm="order.placed.v1",vm="order.paid.v1",ym="order.fulfilled.v1",bm="order.shipped.v1",wm="order.delivered.v1",jm="order.cancelled.v1",Nm="order.refunded.v1",Cm="order.partially_refunded.v1",Sm="order.status_changed.v1",Em="order.confirmation_resend_requested.v1",Rm="order.deleted.v1",Pm="inventory.changed.v1",km="inventory.reserved.v1",Tm="inventory.released.v1",Am="inventory.low_stock.v1",Mm="inventory.out_of_stock.v1",_m="customer.created.v1",Im="customer.updated.v1",Om="customer.deleted.v1",Dm="visitor.merged.v1",zm="cart.created.v1",Lm="cart.item_added.v1",Fm="cart.item_removed.v1",$m="cart.updated.v1",Um="cart.abandoned.v1",Vm="cart.converted.v1",Bm="payment.intent_created.v1",Km="payment.captured.v1",qm="payment.failed.v1",Hm="payment.refunded.v1",Wm="alert.requested.v1",Gm="alert.repeated.v1",Qm="alert.confirmed.v1",Ym="alert.unsubscribed.v1",Xm="alert.sent.v1",Zm="alert.confirmation_sent.v1",Jm="review.submitted.v1",ep="proposal.created.v1",tp="proposal.approved.v1",np="proposal.rejected.v1",rp="proposal.applied.v1",sp="proposal.failed.v1",ap="adapter.error.v1",op="settings.changed.v1",ip=[om,im,cm,lm,dm,um,fm,hm,mm,pm,xm,gm,vm,ym,bm,wm,jm,Nm,Cm,Sm,Em,Rm,Pm,km,Tm,Am,Mm,_m,Im,Om,Dm,zm,Lm,Fm,$m,Um,Vm,Bm,Km,qm,Hm,Wm,Gm,Qm,Ym,Xm,Zm,Jm,ep,tp,np,rp,sp,ap,op],cp="idempotency-key",lp=["product.update","inventory.adjust","order.refund","order.cancel"];class Ae extends Error{constructor(t,n,s,a){super(n),this.code=t,this.status=s,this.context=a,this.name="ApiError"}}const dp="x-csrf-token",up=new Set(["POST","PUT","PATCH","DELETE"]);let is=null;function fp(){return is??(is=fetch("/api/csrf").then(async e=>{var n;const t=await e.json();if(!e.ok||!((n=t.data)!=null&&n.token))throw new Ae("csrf.unavailable",`GET /api/csrf answered ${e.status}`,e.status);return t.data.token}).catch(e=>{throw is=null,e})),is}async function hp(e){var n;return e.status!==403?!1:((n=(await e.clone().json().catch(()=>({}))).error)==null?void 0:n.code)==="csrf.invalid"}async function No(e,t={}){const n=(t.method??"GET").toUpperCase();if(!up.has(n))return fetch(e,t);const s=async()=>{const o=new Headers(t.headers);return o.set(dp,await fp()),fetch(e,{...t,headers:o})},a=await s();return await hp(a)?(is=null,s()):a}function mp(e,t){if(!t)return e;const n=new URLSearchParams;for(const[a,o]of Object.entries(t))o!=null&&o!==""&&n.set(a,String(o));const s=n.toString();return s?`${e}?${s}`:e}async function pp(e){const t=Hc();return t!==e?t!==null:yp()}function Ka(){return crypto.randomUUID()}async function At(e,t,n,s={}){const{query:a,retried:o=!1}=s,c=Hc(),i={};c&&(i.Authorization=`Bearer ${c}`),s.idempotencyKey!==void 0&&(i[cp]=s.idempotencyKey);const f=mp(t,a),u={method:e,headers:i};n!==void 0&&(i["Content-Type"]="application/json",u.body=JSON.stringify(n));const d=await No(f,u);if(d.status===401){if(!o&&c!==null&&!t.startsWith("/api/auth/")&&await pp(c))return At(e,t,n,{...s,retried:!0});const x=(await d.json().catch(()=>({}))).error;throw new Ae((x==null?void 0:x.code)??"UNAUTHORIZED",(x==null?void 0:x.message)??"Unauthorized",401)}if(s.text&&d.ok)return await d.text();const h=await d.json();if(!d.ok){const m=h.error;throw new Ae((m==null?void 0:m.code)??"UNKNOWN_ERROR",(m==null?void 0:m.message)??`HTTP ${d.status}`,d.status,m==null?void 0:m.context)}return s.envelope?h:"data"in h?h.data:h}function Yr(e,t){const n=(e==null?void 0:e.idempotencyKey)??(t.startsWith("/api/admin/")?Ka():void 0);return n===void 0?{}:{idempotencyKey:n}}const W={get(e,t){return At("GET",e,void 0,t===void 0?{}:{query:t})},getPage(e,t){return At("GET",e,void 0,{envelope:!0,...t&&{query:t}})},getText(e,t){return At("GET",e,void 0,{text:!0,...t&&{query:t}})},post(e,t,n){return At("POST",e,t,Yr(n,e))},patch(e,t,n){return At("PATCH",e,t,Yr(n,e))},put(e,t,n){return At("PUT",e,t,Yr(n,e))},delete(e,t){return At("DELETE",e,void 0,Yr(t,e))}};let ks=null,la=null;const qa=new Set;function qc(e){ks=e}function Hc(){return ks}function Wc(){ks=null}function gs(){return ks!==null}function xp(e){return qa.add(e),()=>{qa.delete(e)}}async function Gc(e){var t;return await((t=e.body)==null?void 0:t.cancel()),!1}async function gp(e){var t,n;try{const s=await fetch("/api/admin/me",{headers:{Authorization:`Bearer ${e}`}});return s.ok?((n=(t=(await s.json()).data)==null?void 0:t.roles)==null?void 0:n.includes("admin"))??!1:Gc(s)}catch{return!1}}async function vp(){var t;let e;try{const n=await No("/api/auth/refresh",{method:"POST"});if(!n.ok)return Gc(n);e=(t=(await n.json()).data)==null?void 0:t.accessToken}catch{return!1}return!e||!await gp(e)?!1:(qc(e),!0)}function Qc(e){return la??(la=vp().then(t=>{if(la=null,!t&&(Wc(),e))for(const n of[...qa])n();return t})),la}function yp(){return Qc(!0)}function bp(){return Qc(!1)}/**
10
10
  * @license lucide-react v0.462.0 - ISC
11
11
  *
12
12
  * This source code is licensed under the ISC license.
@@ -261,7 +261,7 @@ var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(
261
261
  *
262
262
  * This source code is licensed under the ISC license.
263
263
  * See the LICENSE file in the root directory of this source tree.
264
- */const gs=q("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"}]]);/**
264
+ */const vs=q("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"}]]);/**
265
265
  * @license lucide-react v0.462.0 - ISC
266
266
  *
267
267
  * This source code is licensed under the ISC license.
@@ -276,7 +276,7 @@ var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(
276
276
  *
277
277
  * This source code is licensed under the ISC license.
278
278
  * See the LICENSE file in the root directory of this source tree.
279
- */const Yt=q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Eo(){return Ce({queryKey:["me"],queryFn:()=>W.get("/api/admin/me"),staleTime:5*6e4})}function ol(){const e=Ct(),t=l.useCallback(async(s,a)=>{var u;const o=await No("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,password:a})}),c=await o.json();if(!o.ok||!c.data)throw new Error(((u=c.error)==null?void 0:u.message)??"Login failed");const{accessToken:i,customer:f}=c.data;if(!f.roles.includes("admin"))throw new Error("Not authorized: admin role required");qc(i),await ps.invalidateQueries({queryKey:["me"]}),e("/")},[e]),n=l.useCallback(async()=>{await W.post("/api/auth/logout").catch(()=>{}),Wc(),ps.clear(),e("/login")},[e]);return{isAuthenticated:xs(),login:t,logout:n}}function Xt(){const[e,t]=l.useState(Ka),n=l.useCallback(()=>t(Ka()),[]);return[e,n]}function il(e={}){return Ce({queryKey:["orders","list",e],queryFn:()=>W.get("/api/admin/orders",e)})}function Qp(e){return Ce({queryKey:["orders","detail",e],queryFn:()=>W.get(`/api/admin/orders/${e}`),enabled:!!e})}function Yp(e){return Ce({queryKey:["orders","notes",e],queryFn:()=>W.get(`/api/admin/orders/${e}/notes`),enabled:!!e})}function ks(e){return e.invalidateQueries({queryKey:["orders","detail"]})}function Xp(){const e=ye();return we({mutationFn:async({orderId:t,action:n,body:s})=>W.post(`/api/admin/orders/${t}/${n}`,s),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 Zp(){const e=ye();return we({mutationFn:({orderId:t,reason:n})=>W.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"]})},onError:()=>ks(e)})}function cl(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,note:a})=>W.post(`/api/admin/orders/${s}/mark-paid`,a?{note:a}:{},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","detail",s.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})},onError:()=>ks(e),onSettled:n})}function Jp(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/orders/${s}/mark-delivered`,void 0,{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>ks(e),onSettled:n})}function ex(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,trackingNumber:a,carrier:o})=>W.post(`/api/admin/orders/${s}/ship`,{trackingNumber:a,carrier:o},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>ks(e),onSettled:n})}function tx(){const e=ye();return we({mutationFn:({orderId:t,amountMinor:n,reason:s,requestId:a})=>W.post(`/api/admin/orders/${t}/refund`,s?{amountMinor:n,reason:s,requestId:a}:{amountMinor:n,requestId:a}),onSuccess:async t=>{await Promise.all([e.invalidateQueries({queryKey:["orders","detail",t.order.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})])}})}function nx(){const[e,t]=Xt();return we({mutationFn:({orderId:n})=>W.post(`/api/admin/orders/${n}/resend-confirmation`,void 0,{idempotencyKey:e}),onSettled:t})}function rx(){const e=ye();return we({mutationFn:({orderId:t,body:n})=>W.post(`/api/admin/orders/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["orders","notes",n.orderId]})}})}const sx=50;function ax(e){return jo({queryKey:["proposals","list",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.get("/api/admin/proposals",{status:e,limit:sx,cursor:t}),getNextPageParam:t=>t.nextCursor??void 0})}function ox(e,t){return Ce({queryKey:["proposals","one",e],queryFn:()=>W.get(`/api/admin/proposals/${encodeURIComponent(e)}`),enabled:t})}function ix(){return Ce({queryKey:["proposals","count"],queryFn:async()=>(await W.get("/api/admin/proposals",{status:"pending",limit:1})).pending})}function ll(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/approve`,void 0,{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function dl(){const e=ye(),[t,n]=Xt();return we({mutationFn:({id:s,reason:a})=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/reject`,a===""?{}:{reason:a},{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function P(...e){return["admin",...e].join("-")}function ul(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=ul(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function fl(){for(var e,t,n=0,s="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=ul(e))&&(s&&(s+=" "),s+=t);return s}const Ro="-",cx=e=>{const t=dx(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:c=>{const i=c.split(Ro);return i[0]===""&&i.length!==1&&i.shift(),hl(i,t)||lx(c)},getConflictingClassGroupIds:(c,i)=>{const f=n[c]||[];return i&&s[c]?[...f,...s[c]]:f}}},hl=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),a=s?hl(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const o=e.join(Ro);return(c=t.validators.find(({validator:i})=>i(o)))==null?void 0:c.classGroupId},Ri=/^\[(.+)\]$/,lx=e=>{if(Ri.test(e)){const t=Ri.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},dx=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return fx(Object.entries(e.classGroups),n).forEach(([o,c])=>{Qa(c,s,o,t)}),s},Qa=(e,t,n,s)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?t:Pi(t,a);o.classGroupId=n;return}if(typeof a=="function"){if(ux(a)){Qa(a(s),t,n,s);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([o,c])=>{Qa(c,Pi(t,o),n,s)})})},Pi=(e,t)=>{let n=e;return t.split(Ro).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},ux=e=>e.isThemeGetter,fx=(e,t)=>t?e.map(([n,s])=>{const a=s.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([c,i])=>[t+c,i])):o);return[n,a]}):e,hx=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const a=(o,c)=>{n.set(o,c),t++,t>e&&(t=0,s=n,n=new Map)};return{get(o){let c=n.get(o);if(c!==void 0)return c;if((c=s.get(o))!==void 0)return a(o,c),c},set(o,c){n.has(o)?n.set(o,c):a(o,c)}}},ml="!",mx=e=>{const{separator:t,experimentalParseClassName:n}=e,s=t.length===1,a=t[0],o=t.length,c=i=>{const f=[];let u=0,d=0,h;for(let v=0;v<i.length;v++){let y=i[v];if(u===0){if(y===a&&(s||i.slice(v,v+o)===t)){f.push(i.slice(d,v)),d=v+o;continue}if(y==="/"){h=v;continue}}y==="["?u++:y==="]"&&u--}const m=f.length===0?i:i.substring(d),x=m.startsWith(ml),g=x?m.substring(1):m,p=h&&h>d?h-d:void 0;return{modifiers:f,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:p}};return n?i=>n({className:i,parseClassName:c}):c},px=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(s=>{s[0]==="["?(t.push(...n.sort(),s),n=[]):n.push(s)}),t.push(...n.sort()),t},xx=e=>({cache:hx(e.cacheSize),parseClassName:mx(e),...cx(e)}),gx=/\s+/,vx=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a}=t,o=[],c=e.trim().split(gx);let i="";for(let f=c.length-1;f>=0;f-=1){const u=c[f],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:x}=n(u);let g=!!x,p=s(g?m.substring(0,x):m);if(!p){if(!g){i=u+(i.length>0?" "+i:i);continue}if(p=s(m),!p){i=u+(i.length>0?" "+i:i);continue}g=!1}const v=px(d).join(":"),y=h?v+ml:v,w=y+p;if(o.includes(w))continue;o.push(w);const N=a(p,g);for(let j=0;j<N.length;++j){const C=N[j];o.push(y+C)}i=u+(i.length>0?" "+i:i)}return i};function yx(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=pl(t))&&(s&&(s+=" "),s+=n);return s}const pl=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=pl(e[s]))&&(n&&(n+=" "),n+=t);return n};function bx(e,...t){let n,s,a,o=c;function c(f){const u=t.reduce((d,h)=>h(d),e());return n=xx(u),s=n.cache.get,a=n.cache.set,o=i,i(f)}function i(f){const u=s(f);if(u)return u;const d=vx(f,n);return a(f,d),d}return function(){return o(yx.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},xl=/^\[(?:([a-z-]+):)?(.+)\]$/i,wx=/^\d+\/\d+$/,jx=new Set(["px","full","screen"]),Nx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Cx=/\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$/,Sx=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Rx=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,mt=e=>Mn(e)||jx.has(e)||wx.test(e),Pt=e=>nr(e,"length",Ox),Mn=e=>!!e&&!Number.isNaN(Number(e)),la=e=>nr(e,"number",Mn),fr=e=>!!e&&Number.isInteger(Number(e)),Px=e=>e.endsWith("%")&&Mn(e.slice(0,-1)),te=e=>xl.test(e),kt=e=>Nx.test(e),kx=new Set(["length","size","percentage"]),Tx=e=>nr(e,kx,gl),Ax=e=>nr(e,"position",gl),Mx=new Set(["image","url"]),_x=e=>nr(e,Mx,zx),Ix=e=>nr(e,"",Dx),hr=()=>!0,nr=(e,t,n)=>{const s=xl.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):n(s[2]):!1},Ox=e=>Cx.test(e)&&!Sx.test(e),gl=()=>!1,Dx=e=>Ex.test(e),zx=e=>Rx.test(e),Lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),s=ge("brightness"),a=ge("borderColor"),o=ge("borderRadius"),c=ge("borderSpacing"),i=ge("borderWidth"),f=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),x=ge("gradientColorStops"),g=ge("gradientColorStopPositions"),p=ge("inset"),v=ge("margin"),y=ge("opacity"),w=ge("padding"),N=ge("saturate"),j=ge("scale"),C=ge("sepia"),S=ge("skew"),E=ge("space"),k=ge("translate"),z=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto",te,t],I=()=>[te,t],Q=()=>["",mt,Pt],V=()=>["auto",Mn,te],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",te],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],le=()=>[Mn,te];return{cacheSize:500,separator:":",theme:{colors:[hr],spacing:[mt,Pt],blur:["none","",kt,te],brightness:le(),borderColor:[e],borderRadius:["none","","full",kt,te],borderSpacing:I(),borderWidth:Q(),contrast:le(),grayscale:A(),hueRotate:le(),invert:A(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Px,Pt],inset:U(),margin:U(),opacity:le(),padding:I(),saturate:le(),scale:le(),sepia:A(),skew:le(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",te]}],container:["container"],columns:[{columns:[kt]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"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:[...Z(),te]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],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",fr,te]}],basis:[{basis:U()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",te]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",fr,te]}],"grid-cols":[{"grid-cols":[hr]}],"col-start-end":[{col:["auto",{span:["full",fr,te]},te]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[hr]}],"row-start-end":[{row:["auto",{span:[fr,te]},te]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",te]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",te,t]}],"min-w":[{"min-w":[te,t,"min","max","fit"]}],"max-w":[{"max-w":[te,t,"none","full","min","max","fit","prose",{screen:[kt]},kt]}],h:[{h:[te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",kt,Pt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",la]}],"font-family":[{font:[hr]}],"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",te]}],"line-clamp":[{"line-clamp":["none",Mn,la]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",mt,te]}],"list-image":[{"list-image":["none",te]}],"list-style-type":[{list:["none","disc","decimal",te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",mt,Pt]}],"underline-offset":[{"underline-offset":["auto",mt,te]}],"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:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te]}],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",te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),Ax]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Tx]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_x]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:B()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[mt,te]}],"outline-w":[{outline:[mt,Pt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[mt,Pt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",kt,Ix]}],"shadow-color":[{shadow:[hr]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",kt,te]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[N]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",te]}],duration:[{duration:le()}],ease:[{ease:["linear","in","out","in-out",te]}],delay:[{delay:le()}],animate:[{animate:["none","spin","ping","pulse","bounce",te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[fr,te]}],"translate-x":[{"translate-x":[k]}],"translate-y":[{"translate-y":[k]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",te]}],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",te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[mt,Pt,la]}],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"]}}},Fx=bx(Lx);function T(...e){return Fx(fl(e))}const $x=[{to:"/",label:"Dashboard",icon:$p,end:!0},{to:"/orders",label:"Orders",icon:Gn,end:!1},{to:"/products",label:"Products",icon:qt,end:!1},{to:"/inventory",label:"Inventory",icon:Xc,end:!1},{to:"/customers",label:"Customers",icon:So,end:!1},{to:"/activity",label:"Activity",icon:Wn,end:!1},{to:"/inbox",label:"Inbox",icon:Ha,end:!1},{to:"/settings",label:"Settings",icon:Wp,end:!1}];function Ux(){const{data:e}=il({status:"pending",limit:1});return!e||e.length===0?null:r.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 Vx(){const{data:e}=ix();return e===void 0||e===0?null:r.jsx("span",{className:"ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-amber-500/20 px-1 text-[10px] font-semibold text-amber-400","data-testid":P("inbox","count"),children:e})}function Bx({open:e,onClose:t}){const{data:n}=Eo(),{logout:s}=ol(),a=()=>{s()};return r.jsxs("aside",{id:"admin-sidebar","data-testid":P("sidebar"),"data-state":e?"open":"closed",className:T("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:[r.jsxs("div",{className:"flex h-14 items-center border-b border-zinc-800/60 px-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"N"})}),r.jsx("span",{className:"text-sm font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"})]}),(n==null?void 0:n.storeName)&&r.jsx("span",{className:"ml-2 truncate text-[10px] font-medium text-zinc-500 border-l border-zinc-700 pl-2",children:n.storeName})]}),r.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:r.jsx("ul",{className:"space-y-0.5",children:$x.map(o=>r.jsx("li",{children:r.jsx(lh,{to:o.to,end:o.end,"data-testid":P("nav",o.label.toLowerCase()),onClick:t,className:({isActive:c})=>T("flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium transition-all duration-100",c?"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:c})=>r.jsxs(r.Fragment,{children:[r.jsx(o.icon,{className:T("h-4 w-4 shrink-0",c?"text-blue-400":"text-zinc-500")}),r.jsx("span",{children:o.label}),o.label==="Orders"&&r.jsx(Ux,{}),o.label==="Inbox"&&r.jsx(Vx,{})]})})},o.to))})}),r.jsx("div",{className:"border-t border-zinc-800/60"}),r.jsx("div",{className:"p-3",children:r.jsxs("div",{className:"flex items-center gap-3 rounded-md px-3 py-2.5",children:[r.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():r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-300",children:(n==null?void 0:n.storeName)??"Loading..."}),r.jsx("p",{className:"truncate text-[10px] text-zinc-500 capitalize",children:(n==null?void 0:n.environment)??""})]}),r.jsx("button",{onClick:a,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 transition-colors",title:"Sign out",children:r.jsx(Up,{className:"h-3.5 w-3.5"})})]})})]})}function Kx(){const t=dh().filter(n=>{const s=n.handle;return(s==null?void 0:s.breadcrumb)!=null}).map(n=>{var o;const s=n.handle;return{label:(o=s.breadcrumb)==null?void 0:o.call(s,n.params),pathname:n.pathname}}).filter(n=>n.label!=null);return t.length===0?null:r.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:t.map((n,s)=>{const a=s===t.length-1;return r.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&r.jsx(Jc,{className:"h-3.5 w-3.5 text-zinc-400"}),a?r.jsx("span",{className:"font-medium text-zinc-900",children:n.label}):r.jsx(Ze,{to:n.pathname,className:T("text-zinc-500 hover:text-zinc-700 transition-colors","font-normal"),children:n.label})]},n.pathname)})})}const ki=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ti=fl,Ts=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return Ti(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:o}=t,c=Object.keys(a).map(u=>{const d=n==null?void 0:n[u],h=o==null?void 0:o[u];if(d===null)return null;const m=ki(d)||ki(h);return a[u][m]}),i=n&&Object.entries(n).reduce((u,d)=>{let[h,m]=d;return m===void 0||(u[h]=m),u},{}),f=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,d)=>{let{class:h,className:m,...x}=d;return Object.entries(x).every(g=>{let[p,v]=g;return Array.isArray(v)?v.includes({...o,...i}[p]):{...o,...i}[p]===v})?[...u,h,m]:u},[]);return Ti(e,c,f,n==null?void 0:n.class,n==null?void 0:n.className)},qx=Ts("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"}}),se=l.forwardRef(({className:e,variant:t,size:n,...s},a)=>r.jsx("button",{className:T(qx({variant:t,size:n,className:e})),ref:a,...s}));se.displayName="Button";function D(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function Ai(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function lt(...e){return t=>{let n=!1;const s=e.map(a=>{const o=Ai(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<s.length;a++){const o=s[a];typeof o=="function"?o():Ai(e[a],null)}}}}function de(...e){return l.useCallback(lt(...e),e)}function Hx(e,t){const n=l.createContext(t),s=o=>{const{children:c,...i}=o,f=l.useMemo(()=>i,Object.values(i));return r.jsx(n.Provider,{value:f,children:c})};s.displayName=e+"Provider";function a(o){const c=l.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[s,a]}function ut(e,t=[]){let n=[];function s(o,c){const i=l.createContext(c),f=n.length;n=[...n,c];const u=h=>{var y;const{scope:m,children:x,...g}=h,p=((y=m==null?void 0:m[e])==null?void 0:y[f])||i,v=l.useMemo(()=>g,Object.values(g));return r.jsx(p.Provider,{value:v,children:x})};u.displayName=o+"Provider";function d(h,m){var p;const x=((p=m==null?void 0:m[e])==null?void 0:p[f])||i,g=l.useContext(x);if(g)return g;if(c!==void 0)return c;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[u,d]}const a=()=>{const o=n.map(c=>l.createContext(c));return function(i){const f=(i==null?void 0:i[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...i,[e]:f}}),[i,f])}};return a.scopeName=e,[s,Wx(a,...t)]}function Wx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const c=s.reduce((i,{useScope:f,scopeName:u})=>{const h=f(o)[`__scope${u}`];return{...i,...h}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function pn(e){const t=Gx(e),n=l.forwardRef((s,a)=>{const{children:o,...c}=s,i=l.Children.toArray(o),f=i.find(Yx);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function Gx(e){const t=l.forwardRef((n,s)=>{const{children:a,...o}=n;if(l.isValidElement(a)){const c=Zx(a),i=Xx(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Qx=Symbol("radix.slottable");function Yx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Qx}function Xx(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function Zx(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],G=Jx.reduce((e,t)=>{const n=pn(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function vl(e,t){e&&Rs.flushSync(()=>e.dispatchEvent(t))}function dt(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function eg(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e);l.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var tg="DismissableLayer",Ya="dismissableLayer.update",ng="dismissableLayer.pointerDownOutside",rg="dismissableLayer.focusOutside",Mi,yl=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_r=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:i,...f}=e,u=l.useContext(yl),[d,h]=l.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=l.useState({}),g=de(t,E=>h(E)),p=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=p.indexOf(v),w=d?p.indexOf(d):-1,N=u.layersWithOutsidePointerEventsDisabled.size>0,j=w>=y,C=og(E=>{const k=E.target,z=[...u.branches].some(O=>O.contains(k));!j||z||(a==null||a(E),c==null||c(E),E.defaultPrevented||i==null||i())},m),S=ig(E=>{const k=E.target;[...u.branches].some(O=>O.contains(k))||(o==null||o(E),c==null||c(E),E.defaultPrevented||i==null||i())},m);return eg(E=>{w===u.layers.size-1&&(s==null||s(E),!E.defaultPrevented&&i&&(E.preventDefault(),i()))},m),l.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Mi=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),_i(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Mi)}},[d,m,n,u]),l.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),_i())},[d,u]),l.useEffect(()=>{const E=()=>x({});return document.addEventListener(Ya,E),()=>document.removeEventListener(Ya,E)},[]),r.jsx(G.div,{...f,ref:g,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:D(e.onFocusCapture,S.onFocusCapture),onBlurCapture:D(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:D(e.onPointerDownCapture,C.onPointerDownCapture)})});_r.displayName=tg;var sg="DismissableLayerBranch",ag=l.forwardRef((e,t)=>{const n=l.useContext(yl),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),r.jsx(G.div,{...e,ref:a})});ag.displayName=sg;function og(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1),a=l.useRef(()=>{});return l.useEffect(()=>{const o=i=>{if(i.target&&!s.current){let f=function(){bl(ng,n,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=f,t.addEventListener("click",a.current,{once:!0})):f()}else t.removeEventListener("click",a.current);s.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",o),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function ig(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1);return l.useEffect(()=>{const a=o=>{o.target&&!s.current&&bl(rg,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function _i(){const e=new CustomEvent(Ya);document.dispatchEvent(e)}function bl(e,t,n,{discrete:s}){const a=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),s?vl(a,o):a.dispatchEvent(o)}var da=0;function As(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ii()),document.body.insertAdjacentElement("beforeend",e[1]??Ii()),da++,()=>{da===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),da--}},[])}function Ii(){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 ua="focusScope.autoFocusOnMount",fa="focusScope.autoFocusOnUnmount",Oi={bubbles:!1,cancelable:!0},cg="FocusScope",Ir=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...c}=e,[i,f]=l.useState(null),u=dt(a),d=dt(o),h=l.useRef(null),m=de(t,p=>f(p)),x=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(s){let p=function(N){if(x.paused||!i)return;const j=N.target;i.contains(j)?h.current=j:Mt(h.current,{select:!0})},v=function(N){if(x.paused||!i)return;const j=N.relatedTarget;j!==null&&(i.contains(j)||Mt(h.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&Mt(i)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const w=new MutationObserver(y);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),w.disconnect()}}},[s,i,x.paused]),l.useEffect(()=>{if(i){zi.add(x);const p=document.activeElement;if(!i.contains(p)){const y=new CustomEvent(ua,Oi);i.addEventListener(ua,u),i.dispatchEvent(y),y.defaultPrevented||(lg(mg(wl(i)),{select:!0}),document.activeElement===p&&Mt(i))}return()=>{i.removeEventListener(ua,u),setTimeout(()=>{const y=new CustomEvent(fa,Oi);i.addEventListener(fa,d),i.dispatchEvent(y),y.defaultPrevented||Mt(p??document.body,{select:!0}),i.removeEventListener(fa,d),zi.remove(x)},0)}}},[i,u,d,x]);const g=l.useCallback(p=>{if(!n&&!s||x.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(v&&y){const w=p.currentTarget,[N,j]=dg(w);N&&j?!p.shiftKey&&y===j?(p.preventDefault(),n&&Mt(N,{select:!0})):p.shiftKey&&y===N&&(p.preventDefault(),n&&Mt(j,{select:!0})):y===w&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(G.div,{tabIndex:-1,...c,ref:m,onKeyDown:g})});Ir.displayName=cg;function lg(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Mt(s,{select:t}),document.activeElement!==n)return}function dg(e){const t=wl(e),n=Di(t,e),s=Di(t.reverse(),e);return[n,s]}function wl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Di(e,t){for(const n of e)if(!ug(n,{upTo:t}))return n}function ug(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 fg(e){return e instanceof HTMLInputElement&&"select"in e}function Mt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&fg(e)&&t&&e.select()}}var zi=hg();function hg(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Li(e,t),e.unshift(t)},remove(t){var n;e=Li(e,t),(n=e[0])==null||n.resume()}}}function Li(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function mg(e){return e.filter(t=>t.tagName!=="A")}var Re=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},pg=po[" useId ".trim().toString()]||(()=>{}),xg=0;function Ne(e){const[t,n]=l.useState(pg());return Re(()=>{n(s=>s??String(xg++))},[e]),t?`radix-${t}`:""}const gg=["top","right","bottom","left"],Ht=Math.min,$e=Math.max,vs=Math.round,Xr=Math.floor,ct=e=>({x:e,y:e}),vg={left:"right",right:"left",bottom:"top",top:"bottom"};function Xa(e,t,n){return $e(e,Ht(t,n))}function jt(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function rr(e){return e.split("-")[1]}function Po(e){return e==="x"?"y":"x"}function ko(e){return e==="y"?"height":"width"}function it(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function To(e){return Po(it(e))}function yg(e,t,n){n===void 0&&(n=!1);const s=rr(e),a=To(e),o=ko(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=ys(c)),[c,ys(c)]}function bg(e){const t=ys(e);return[Za(e),t,Za(t)]}function Za(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Fi=["left","right"],$i=["right","left"],wg=["top","bottom"],jg=["bottom","top"];function Ng(e,t,n){switch(e){case"top":case"bottom":return n?t?$i:Fi:t?Fi:$i;case"left":case"right":return t?wg:jg;default:return[]}}function Cg(e,t,n,s){const a=rr(e);let o=Ng(Nt(e),n==="start",s);return a&&(o=o.map(c=>c+"-"+a),t&&(o=o.concat(o.map(Za)))),o}function ys(e){const t=Nt(e);return vg[t]+e.slice(t.length)}function Sg(e){return{top:0,right:0,bottom:0,left:0,...e}}function jl(e){return typeof e!="number"?Sg(e):{top:e,right:e,bottom:e,left:e}}function bs(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Ui(e,t,n){let{reference:s,floating:a}=e;const o=it(t),c=To(t),i=ko(c),f=Nt(t),u=o==="y",d=s.x+s.width/2-a.width/2,h=s.y+s.height/2-a.height/2,m=s[i]/2-a[i]/2;let x;switch(f){case"top":x={x:d,y:s.y-a.height};break;case"bottom":x={x:d,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:h};break;case"left":x={x:s.x-a.width,y:h};break;default:x={x:s.x,y:s.y}}switch(rr(t)){case"start":x[c]-=m*(n&&u?-1:1);break;case"end":x[c]+=m*(n&&u?-1:1);break}return x}async function Eg(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:o,rects:c,elements:i,strategy:f}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:x=0}=jt(t,e),g=jl(x),v=i[m?h==="floating"?"reference":"floating":h],y=bs(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:u,rootBoundary:d,strategy:f})),w=h==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),j=await(o.isElement==null?void 0:o.isElement(N))?await(o.getScale==null?void 0:o.getScale(N))||{x:1,y:1}:{x:1,y:1},C=bs(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:N,strategy:f}):w);return{top:(y.top-C.top+g.top)/j.y,bottom:(C.bottom-y.bottom+g.bottom)/j.y,left:(y.left-C.left+g.left)/j.x,right:(C.right-y.right+g.right)/j.x}}const Rg=50,Pg=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:c}=n,i=c.detectOverflow?c:{...c,detectOverflow:Eg},f=await(c.isRTL==null?void 0:c.isRTL(t));let u=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:h}=Ui(u,s,f),m=s,x=0;const g={};for(let p=0;p<o.length;p++){const v=o[p];if(!v)continue;const{name:y,fn:w}=v,{x:N,y:j,data:C,reset:S}=await w({x:d,y:h,initialPlacement:s,placement:m,strategy:a,middlewareData:g,rects:u,platform:i,elements:{reference:e,floating:t}});d=N??d,h=j??h,g[y]={...g[y],...C},S&&x<Rg&&(x++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(u=S.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):S.rects),{x:d,y:h}=Ui(u,m,f)),p=-1)}return{x:d,y:h,placement:m,strategy:a,middlewareData:g}},kg=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:o,platform:c,elements:i,middlewareData:f}=t,{element:u,padding:d=0}=jt(e,t)||{};if(u==null)return{};const h=jl(d),m={x:n,y:s},x=To(a),g=ko(x),p=await c.getDimensions(u),v=x==="y",y=v?"top":"left",w=v?"bottom":"right",N=v?"clientHeight":"clientWidth",j=o.reference[g]+o.reference[x]-m[x]-o.floating[g],C=m[x]-o.reference[x],S=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let E=S?S[N]:0;(!E||!await(c.isElement==null?void 0:c.isElement(S)))&&(E=i.floating[N]||o.floating[g]);const k=j/2-C/2,z=E/2-p[g]/2-1,O=Ht(h[y],z),U=Ht(h[w],z),I=O,Q=E-p[g]-U,V=E/2-p[g]/2+k,Z=Xa(I,V,Q),B=!f.arrow&&rr(a)!=null&&V!==Z&&o.reference[g]/2-(V<I?O:U)-p[g]/2<0,ae=B?V<I?V-I:V-Q:0;return{[x]:m[x]+ae,data:{[x]:Z,centerOffset:V-Z-ae,...B&&{alignmentOffset:ae}},reset:B}}}),Tg=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:o,rects:c,initialPlacement:i,platform:f,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...v}=jt(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(a),w=it(i),N=Nt(i)===i,j=await(f.isRTL==null?void 0:f.isRTL(u.floating)),C=m||(N||!p?[ys(i)]:bg(i)),S=g!=="none";!m&&S&&C.push(...Cg(i,p,g,j));const E=[i,...C],k=await f.detectOverflow(t,v),z=[];let O=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&z.push(k[y]),h){const V=yg(a,c,j);z.push(k[V[0]],k[V[1]])}if(O=[...O,{placement:a,overflows:z}],!z.every(V=>V<=0)){var U,I;const V=(((U=o.flip)==null?void 0:U.index)||0)+1,Z=E[V];if(Z&&(!(h==="alignment"?w!==it(Z):!1)||O.every(F=>it(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:V,overflows:O},reset:{placement:Z}};let B=(I=O.filter(ae=>ae.overflows[0]<=0).sort((ae,F)=>ae.overflows[1]-F.overflows[1])[0])==null?void 0:I.placement;if(!B)switch(x){case"bestFit":{var Q;const ae=(Q=O.filter(F=>{if(S){const A=it(F.placement);return A===w||A==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(A=>A>0).reduce((A,ce)=>A+ce,0)]).sort((F,A)=>F[1]-A[1])[0])==null?void 0:Q[0];ae&&(B=ae);break}case"initialPlacement":B=i;break}if(a!==B)return{reset:{placement:B}}}return{}}}};function Vi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Bi(e){return gg.some(t=>e[t]>=0)}const Ag=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...o}=jt(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...o,elementContext:"reference"}),i=Vi(c,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Bi(i)}}}case"escaped":{const c=await s.detectOverflow(t,{...o,altBoundary:!0}),i=Vi(c,n.floating);return{data:{escapedOffsets:i,escaped:Bi(i)}}}default:return{}}}}},Nl=new Set(["left","top"]);async function Mg(e,t){const{placement:n,platform:s,elements:a}=e,o=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Nt(n),i=rr(n),f=it(n)==="y",u=Nl.has(c)?-1:1,d=o&&f?-1:1,h=jt(t,e);let{mainAxis:m,crossAxis:x,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return i&&typeof g=="number"&&(x=i==="end"?g*-1:g),f?{x:x*d,y:m*u}:{x:m*u,y:x*d}}const _g=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:o,placement:c,middlewareData:i}=t,f=await Mg(t,e);return c===((n=i.offset)==null?void 0:n.placement)&&(s=i.arrow)!=null&&s.alignmentOffset?{}:{x:a+f.x,y:o+f.y,data:{...f,placement:c}}}}},Ig=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:o}=t,{mainAxis:c=!0,crossAxis:i=!1,limiter:f={fn:y=>{let{x:w,y:N}=y;return{x:w,y:N}}},...u}=jt(e,t),d={x:n,y:s},h=await o.detectOverflow(t,u),m=it(Nt(a)),x=Po(m);let g=d[x],p=d[m];if(c){const y=x==="y"?"top":"left",w=x==="y"?"bottom":"right",N=g+h[y],j=g-h[w];g=Xa(N,g,j)}if(i){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",N=p+h[y],j=p-h[w];p=Xa(N,p,j)}const v=f.fn({...t,[x]:g,[m]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[x]:c,[m]:i}}}}}},Og=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:o,middlewareData:c}=t,{offset:i=0,mainAxis:f=!0,crossAxis:u=!0}=jt(e,t),d={x:n,y:s},h=it(a),m=Po(h);let x=d[m],g=d[h];const p=jt(i,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(f){const N=m==="y"?"height":"width",j=o.reference[m]-o.floating[N]+v.mainAxis,C=o.reference[m]+o.reference[N]-v.mainAxis;x<j?x=j:x>C&&(x=C)}if(u){var y,w;const N=m==="y"?"width":"height",j=Nl.has(Nt(a)),C=o.reference[h]-o.floating[N]+(j&&((y=c.offset)==null?void 0:y[h])||0)+(j?0:v.crossAxis),S=o.reference[h]+o.reference[N]+(j?0:((w=c.offset)==null?void 0:w[h])||0)-(j?v.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[m]:x,[h]:g}}}},Dg=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:o,platform:c,elements:i}=t,{apply:f=()=>{},...u}=jt(e,t),d=await c.detectOverflow(t,u),h=Nt(a),m=rr(a),x=it(a)==="y",{width:g,height:p}=o.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=m===(await(c.isRTL==null?void 0:c.isRTL(i.floating))?"start":"end")?"left":"right"):(y=h,v=m==="end"?"top":"bottom");const w=p-d.top-d.bottom,N=g-d.left-d.right,j=Ht(p-d[v],w),C=Ht(g-d[y],N),S=!t.middlewareData.shift;let E=j,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(E=w),S&&!m){const O=$e(d.left,0),U=$e(d.right,0),I=$e(d.top,0),Q=$e(d.bottom,0);x?k=g-2*(O!==0||U!==0?O+U:$e(d.left,d.right)):E=p-2*(I!==0||Q!==0?I+Q:$e(d.top,d.bottom))}await f({...t,availableWidth:k,availableHeight:E});const z=await c.getDimensions(i.floating);return g!==z.width||p!==z.height?{reset:{rects:!0}}:{}}}};function Ms(){return typeof window<"u"}function sr(e){return Cl(e)?(e.nodeName||"").toLowerCase():"#document"}function Ve(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ft(e){var t;return(t=(Cl(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cl(e){return Ms()?e instanceof Node||e instanceof Ve(e).Node:!1}function Je(e){return Ms()?e instanceof Element||e instanceof Ve(e).Element:!1}function Et(e){return Ms()?e instanceof HTMLElement||e instanceof Ve(e).HTMLElement:!1}function Ki(e){return!Ms()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ve(e).ShadowRoot}function Or(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=et(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function zg(e){return/^(table|td|th)$/.test(sr(e))}function _s(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Lg=/transform|translate|scale|rotate|perspective|filter/,Fg=/paint|layout|strict|content/,tn=e=>!!e&&e!=="none";let ha;function Ao(e){const t=Je(e)?et(e):e;return tn(t.transform)||tn(t.translate)||tn(t.scale)||tn(t.rotate)||tn(t.perspective)||!Mo()&&(tn(t.backdropFilter)||tn(t.filter))||Lg.test(t.willChange||"")||Fg.test(t.contain||"")}function $g(e){let t=Wt(e);for(;Et(t)&&!Qn(t);){if(Ao(t))return t;if(_s(t))return null;t=Wt(t)}return null}function Mo(){return ha==null&&(ha=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ha}function Qn(e){return/^(html|body|#document)$/.test(sr(e))}function et(e){return Ve(e).getComputedStyle(e)}function Is(e){return Je(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wt(e){if(sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ki(e)&&e.host||ft(e);return Ki(t)?t.host:t}function Sl(e){const t=Wt(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Et(t)&&Or(t)?t:Sl(t)}function wr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=Sl(e),o=a===((s=e.ownerDocument)==null?void 0:s.body),c=Ve(a);if(o){const i=Ja(c);return t.concat(c,c.visualViewport||[],Or(a)?a:[],i&&n?wr(i):[])}else return t.concat(a,wr(a,[],n))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function El(e){const t=et(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Et(e),o=a?e.offsetWidth:n,c=a?e.offsetHeight:s,i=vs(n)!==o||vs(s)!==c;return i&&(n=o,s=c),{width:n,height:s,$:i}}function _o(e){return Je(e)?e:e.contextElement}function _n(e){const t=_o(e);if(!Et(t))return ct(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:o}=El(t);let c=(o?vs(n.width):n.width)/s,i=(o?vs(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!i||!Number.isFinite(i))&&(i=1),{x:c,y:i}}const Ug=ct(0);function Rl(e){const t=Ve(e);return!Mo()||!t.visualViewport?Ug:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Vg(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ve(e)?!1:t}function xn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=_o(e);let c=ct(1);t&&(s?Je(s)&&(c=_n(s)):c=_n(e));const i=Vg(o,n,s)?Rl(o):ct(0);let f=(a.left+i.x)/c.x,u=(a.top+i.y)/c.y,d=a.width/c.x,h=a.height/c.y;if(o){const m=Ve(o),x=s&&Je(s)?Ve(s):s;let g=m,p=Ja(g);for(;p&&s&&x!==g;){const v=_n(p),y=p.getBoundingClientRect(),w=et(p),N=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*v.x,j=y.top+(p.clientTop+parseFloat(w.paddingTop))*v.y;f*=v.x,u*=v.y,d*=v.x,h*=v.y,f+=N,u+=j,g=Ve(p),p=Ja(g)}}return bs({width:d,height:h,x:f,y:u})}function Os(e,t){const n=Is(e).scrollLeft;return t?t.left+n:xn(ft(e)).left+n}function Pl(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Os(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function Bg(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const o=a==="fixed",c=ft(s),i=t?_s(t.floating):!1;if(s===c||i&&o)return n;let f={scrollLeft:0,scrollTop:0},u=ct(1);const d=ct(0),h=Et(s);if((h||!h&&!o)&&((sr(s)!=="body"||Or(c))&&(f=Is(s)),h)){const x=xn(s);u=_n(s),d.x=x.x+s.clientLeft,d.y=x.y+s.clientTop}const m=c&&!h&&!o?Pl(c,f):ct(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-f.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-f.scrollTop*u.y+d.y+m.y}}function Kg(e){return Array.from(e.getClientRects())}function qg(e){const t=ft(e),n=Is(e),s=e.ownerDocument.body,a=$e(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=$e(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Os(e);const i=-n.scrollTop;return et(s).direction==="rtl"&&(c+=$e(t.clientWidth,s.clientWidth)-a),{width:a,height:o,x:c,y:i}}const qi=25;function Hg(e,t){const n=Ve(e),s=ft(e),a=n.visualViewport;let o=s.clientWidth,c=s.clientHeight,i=0,f=0;if(a){o=a.width,c=a.height;const d=Mo();(!d||d&&t==="fixed")&&(i=a.offsetLeft,f=a.offsetTop)}const u=Os(s);if(u<=0){const d=s.ownerDocument,h=d.body,m=getComputedStyle(h),x=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-x);g<=qi&&(o-=g)}else u<=qi&&(o+=u);return{width:o,height:c,x:i,y:f}}function Wg(e,t){const n=xn(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,o=Et(e)?_n(e):ct(1),c=e.clientWidth*o.x,i=e.clientHeight*o.y,f=a*o.x,u=s*o.y;return{width:c,height:i,x:f,y:u}}function Hi(e,t,n){let s;if(t==="viewport")s=Hg(e,n);else if(t==="document")s=qg(ft(e));else if(Je(t))s=Wg(t,n);else{const a=Rl(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return bs(s)}function kl(e,t){const n=Wt(e);return n===t||!Je(n)||Qn(n)?!1:et(n).position==="fixed"||kl(n,t)}function Gg(e,t){const n=t.get(e);if(n)return n;let s=wr(e,[],!1).filter(i=>Je(i)&&sr(i)!=="body"),a=null;const o=et(e).position==="fixed";let c=o?Wt(e):e;for(;Je(c)&&!Qn(c);){const i=et(c),f=Ao(c);!f&&i.position==="fixed"&&(a=null),(o?!f&&!a:!f&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Or(c)&&!f&&kl(e,c))?s=s.filter(d=>d!==c):a=i,c=Wt(c)}return t.set(e,s),s}function Qg(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?_s(t)?[]:Gg(t,this._c):[].concat(n),s],i=Hi(t,c[0],a);let f=i.top,u=i.right,d=i.bottom,h=i.left;for(let m=1;m<c.length;m++){const x=Hi(t,c[m],a);f=$e(x.top,f),u=Ht(x.right,u),d=Ht(x.bottom,d),h=$e(x.left,h)}return{width:u-h,height:d-f,x:h,y:f}}function Yg(e){const{width:t,height:n}=El(e);return{width:t,height:n}}function Xg(e,t,n){const s=Et(t),a=ft(t),o=n==="fixed",c=xn(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const f=ct(0);function u(){f.x=Os(a)}if(s||!s&&!o)if((sr(t)!=="body"||Or(a))&&(i=Is(t)),s){const x=xn(t,!0,o,t);f.x=x.x+t.clientLeft,f.y=x.y+t.clientTop}else a&&u();o&&!s&&a&&u();const d=a&&!s&&!o?Pl(a,i):ct(0),h=c.left+i.scrollLeft-f.x-d.x,m=c.top+i.scrollTop-f.y-d.y;return{x:h,y:m,width:c.width,height:c.height}}function ma(e){return et(e).position==="static"}function Wi(e,t){if(!Et(e)||et(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ft(e)===n&&(n=n.ownerDocument.body),n}function Tl(e,t){const n=Ve(e);if(_s(e))return n;if(!Et(e)){let a=Wt(e);for(;a&&!Qn(a);){if(Je(a)&&!ma(a))return a;a=Wt(a)}return n}let s=Wi(e,t);for(;s&&zg(s)&&ma(s);)s=Wi(s,t);return s&&Qn(s)&&ma(s)&&!Ao(s)?n:s||$g(e)||n}const Zg=async function(e){const t=this.getOffsetParent||Tl,n=this.getDimensions,s=await n(e.floating);return{reference:Xg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Jg(e){return et(e).direction==="rtl"}const ev={convertOffsetParentRelativeRectToViewportRelativeRect:Bg,getDocumentElement:ft,getClippingRect:Qg,getOffsetParent:Tl,getElementRects:Zg,getClientRects:Kg,getDimensions:Yg,getScale:_n,isElement:Je,isRTL:Jg};function Al(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tv(e,t){let n=null,s;const a=ft(e);function o(){var i;clearTimeout(s),(i=n)==null||i.disconnect(),n=null}function c(i,f){i===void 0&&(i=!1),f===void 0&&(f=1),o();const u=e.getBoundingClientRect(),{left:d,top:h,width:m,height:x}=u;if(i||t(),!m||!x)return;const g=Xr(h),p=Xr(a.clientWidth-(d+m)),v=Xr(a.clientHeight-(h+x)),y=Xr(d),N={rootMargin:-g+"px "+-p+"px "+-v+"px "+-y+"px",threshold:$e(0,Ht(1,f))||1};let j=!0;function C(S){const E=S[0].intersectionRatio;if(E!==f){if(!j)return c();E?c(!1,E):s=setTimeout(()=>{c(!1,1e-7)},1e3)}E===1&&!Al(u,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver(C,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(C,N)}n.observe(e)}return c(!0),o}function nv(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:f=!1}=s,u=_o(e),d=a||o?[...u?wr(u):[],...t?wr(t):[]]:[];d.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const h=u&&i?tv(u,n):null;let m=-1,x=null;c&&(x=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),u&&!f&&x.observe(u),t&&x.observe(t));let g,p=f?xn(e):null;f&&v();function v(){const y=xn(e);p&&!Al(p,y)&&n(),p=y,g=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(w=>{a&&w.removeEventListener("scroll",n),o&&w.removeEventListener("resize",n)}),h==null||h(),(y=x)==null||y.disconnect(),x=null,f&&cancelAnimationFrame(g)}}const rv=_g,sv=Ig,av=Tg,ov=Dg,iv=Ag,Gi=kg,cv=Og,lv=(e,t,n)=>{const s=new Map,a={platform:ev,...n},o={...a.platform,_c:s};return Pg(e,t,{...a,platform:o})};var dv=typeof document<"u",uv=function(){},is=dv?l.useLayoutEffect:uv;function ws(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,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!ws(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const o=a[s];if(!(o==="_owner"&&e.$$typeof)&&!ws(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Ml(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Qi(e,t){const n=Ml(e);return Math.round(t*n)/n}function pa(e){const t=l.useRef(e);return is(()=>{t.current=e}),t}function fv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:o,floating:c}={},transform:i=!0,whileElementsMounted:f,open:u}=e,[d,h]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,x]=l.useState(s);ws(m,s)||x(s);const[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useCallback(F=>{F!==S.current&&(S.current=F,p(F))},[]),N=l.useCallback(F=>{F!==E.current&&(E.current=F,y(F))},[]),j=o||g,C=c||v,S=l.useRef(null),E=l.useRef(null),k=l.useRef(d),z=f!=null,O=pa(f),U=pa(a),I=pa(u),Q=l.useCallback(()=>{if(!S.current||!E.current)return;const F={placement:t,strategy:n,middleware:m};U.current&&(F.platform=U.current),lv(S.current,E.current,F).then(A=>{const ce={...A,isPositioned:I.current!==!1};V.current&&!ws(k.current,ce)&&(k.current=ce,Rs.flushSync(()=>{h(ce)}))})},[m,t,n,U,I]);is(()=>{u===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[u]);const V=l.useRef(!1);is(()=>(V.current=!0,()=>{V.current=!1}),[]),is(()=>{if(j&&(S.current=j),C&&(E.current=C),j&&C){if(O.current)return O.current(j,C,Q);Q()}},[j,C,Q,O,z]);const Z=l.useMemo(()=>({reference:S,floating:E,setReference:w,setFloating:N}),[w,N]),B=l.useMemo(()=>({reference:j,floating:C}),[j,C]),ae=l.useMemo(()=>{const F={position:n,left:0,top:0};if(!B.floating)return F;const A=Qi(B.floating,d.x),ce=Qi(B.floating,d.y);return i?{...F,transform:"translate("+A+"px, "+ce+"px)",...Ml(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:ce}},[n,i,B.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:Q,refs:Z,elements:B,floatingStyles:ae}),[d,Q,Z,B,ae])}const hv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Gi({element:s.current,padding:a}).fn(n):{}:s?Gi({element:s,padding:a}).fn(n):{}}}},mv=(e,t)=>{const n=rv(e);return{name:n.name,fn:n.fn,options:[e,t]}},pv=(e,t)=>{const n=sv(e);return{name:n.name,fn:n.fn,options:[e,t]}},xv=(e,t)=>({fn:cv(e).fn,options:[e,t]}),gv=(e,t)=>{const n=av(e);return{name:n.name,fn:n.fn,options:[e,t]}},vv=(e,t)=>{const n=ov(e);return{name:n.name,fn:n.fn,options:[e,t]}},yv=(e,t)=>{const n=iv(e);return{name:n.name,fn:n.fn,options:[e,t]}},bv=(e,t)=>{const n=hv(e);return{name:n.name,fn:n.fn,options:[e,t]}};var wv="Arrow",_l=l.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...o}=e;return r.jsx(G.svg,{...o,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});_l.displayName=wv;var jv=_l;function Il(e){const[t,n]=l.useState(void 0);return Re(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let c,i;if("borderBoxSize"in o){const f=o.borderBoxSize,u=Array.isArray(f)?f[0]:f;c=u.inlineSize,i=u.blockSize}else c=e.offsetWidth,i=e.offsetHeight;n({width:c,height:i})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Io="Popper",[Ol,ar]=ut(Io),[Nv,Dl]=Ol(Io),zl=e=>{const{__scopePopper:t,children:n}=e,[s,a]=l.useState(null);return r.jsx(Nv,{scope:t,anchor:s,onAnchorChange:a,children:n})};zl.displayName=Io;var Ll="PopperAnchor",Fl=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,o=Dl(Ll,n),c=l.useRef(null),i=de(t,c),f=l.useRef(null);return l.useEffect(()=>{const u=f.current;f.current=(s==null?void 0:s.current)||c.current,u!==f.current&&o.onAnchorChange(f.current)}),s?null:r.jsx(G.div,{...a,ref:i})});Fl.displayName=Ll;var Oo="PopperContent",[Cv,Sv]=Ol(Oo),$l=l.forwardRef((e,t)=>{var M,Y,X,ie,fe,he;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:c=0,arrowPadding:i=0,avoidCollisions:f=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:x="optimized",onPlaced:g,...p}=e,v=Dl(Oo,n),[y,w]=l.useState(null),N=de(t,ze=>w(ze)),[j,C]=l.useState(null),S=Il(j),E=(S==null?void 0:S.width)??0,k=(S==null?void 0:S.height)??0,z=s+(o!=="center"?"-"+o:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},U=Array.isArray(u)?u:[u],I=U.length>0,Q={padding:O,boundary:U.filter(Rv),altBoundary:I},{refs:V,floatingStyles:Z,placement:B,isPositioned:ae,middlewareData:F}=fv({strategy:"fixed",placement:z,whileElementsMounted:(...ze)=>nv(...ze,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[mv({mainAxis:a+k,alignmentAxis:c}),f&&pv({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?xv():void 0,...Q}),f&&gv({...Q}),vv({...Q,apply:({elements:ze,rects:nt,availableWidth:cr,availableHeight:lr})=>{const{width:dr,height:oh}=nt.reference,Hr=ze.floating.style;Hr.setProperty("--radix-popper-available-width",`${cr}px`),Hr.setProperty("--radix-popper-available-height",`${lr}px`),Hr.setProperty("--radix-popper-anchor-width",`${dr}px`),Hr.setProperty("--radix-popper-anchor-height",`${oh}px`)}}),j&&bv({element:j,padding:i}),Pv({arrowWidth:E,arrowHeight:k}),m&&yv({strategy:"referenceHidden",...Q})]}),[A,ce]=Bl(B),le=dt(g);Re(()=>{ae&&(le==null||le())},[ae,le]);const R=(M=F.arrow)==null?void 0:M.x,K=(Y=F.arrow)==null?void 0:Y.y,H=((X=F.arrow)==null?void 0:X.centerOffset)!==0,[L,J]=l.useState();return Re(()=>{y&&J(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:ae?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(ie=F.transformOrigin)==null?void 0:ie.x,(fe=F.transformOrigin)==null?void 0:fe.y].join(" "),...((he=F.hide)==null?void 0:he.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(Cv,{scope:n,placedSide:A,onArrowChange:C,arrowX:R,arrowY:K,shouldHideArrow:H,children:r.jsx(G.div,{"data-side":A,"data-align":ce,...p,ref:N,style:{...p.style,animation:ae?void 0:"none"}})})})});$l.displayName=Oo;var Ul="PopperArrow",Ev={top:"bottom",right:"left",bottom:"top",left:"right"},Vl=l.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,o=Sv(Ul,s),c=Ev[o.placedSide];return r.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:r.jsx(jv,{...a,ref:n,style:{...a.style,display:"block"}})})});Vl.displayName=Ul;function Rv(e){return e!==null}var Pv=e=>({name:"transformOrigin",options:e,fn(t){var v,y,w;const{placement:n,rects:s,middlewareData:a}=t,c=((v=a.arrow)==null?void 0:v.centerOffset)!==0,i=c?0:e.arrowWidth,f=c?0:e.arrowHeight,[u,d]=Bl(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=a.arrow)==null?void 0:y.x)??0)+i/2,x=(((w=a.arrow)==null?void 0:w.y)??0)+f/2;let g="",p="";return u==="bottom"?(g=c?h:`${m}px`,p=`${-f}px`):u==="top"?(g=c?h:`${m}px`,p=`${s.floating.height+f}px`):u==="right"?(g=`${-f}px`,p=c?h:`${x}px`):u==="left"&&(g=`${s.floating.width+f}px`,p=c?h:`${x}px`),{data:{x:g,y:p}}}});function Bl(e){const[t,n="center"]=e.split("-");return[t,n]}var Do=zl,Ds=Fl,zo=$l,Lo=Vl,kv="Portal",Dr=l.forwardRef((e,t)=>{var i;const{container:n,...s}=e,[a,o]=l.useState(!1);Re(()=>o(!0),[]);const c=n||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return c?uh.createPortal(r.jsx(G.div,{...s,ref:t}),c):null});Dr.displayName=kv;function Tv(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var Ge=e=>{const{present:t,children:n}=e,s=Av(t),a=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),o=de(s.ref,Mv(a));return typeof n=="function"||s.isPresent?l.cloneElement(a,{ref:o}):null};Ge.displayName="Presence";function Av(e){const[t,n]=l.useState(),s=l.useRef(null),a=l.useRef(e),o=l.useRef("none"),c=e?"mounted":"unmounted",[i,f]=Tv(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=Zr(s.current);o.current=i==="mounted"?u:"none"},[i]),Re(()=>{const u=s.current,d=a.current;if(d!==e){const m=o.current,x=Zr(u);e?f("MOUNT"):x==="none"||(u==null?void 0:u.display)==="none"?f("UNMOUNT"):f(d&&m!==x?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),Re(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=x=>{const p=Zr(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(f("ANIMATION_END"),!a.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=x=>{x.target===t&&(o.current=Zr(s.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function Zr(e){return(e==null?void 0:e.animationName)||"none"}function Mv(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _v=po[" useInsertionEffect ".trim().toString()]||Re;function Gt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[a,o,c]=Iv({defaultProp:t,onChange:n}),i=e!==void 0,f=i?e:a;{const d=l.useRef(e!==void 0);l.useEffect(()=>{const h=d.current;h!==i&&console.warn(`${s} is changing from ${h?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=i},[i,s])}const u=l.useCallback(d=>{var h;if(i){const m=Ov(d)?d(e):d;m!==e&&((h=c.current)==null||h.call(c,m))}else o(d)},[i,e,o,c]);return[f,u]}function Iv({defaultProp:e,onChange:t}){const[n,s]=l.useState(e),a=l.useRef(n),o=l.useRef(t);return _v(()=>{o.current=t},[t]),l.useEffect(()=>{var c;a.current!==n&&((c=o.current)==null||c.call(o,n),a.current=n)},[n,a]),[n,s,o]}function Ov(e){return typeof e=="function"}var Dv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},En=new WeakMap,Jr=new WeakMap,es={},xa=0,Kl=function(e){return e&&(e.host||Kl(e.parentNode))},zv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Kl(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Lv=function(e,t,n,s){var a=zv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var o=es[n],c=[],i=new Set,f=new Set(a),u=function(h){!h||i.has(h)||(i.add(h),u(h.parentNode))};a.forEach(u);var d=function(h){!h||f.has(h)||Array.prototype.forEach.call(h.children,function(m){if(i.has(m))d(m);else try{var x=m.getAttribute(s),g=x!==null&&x!=="false",p=(En.get(m)||0)+1,v=(o.get(m)||0)+1;En.set(m,p),o.set(m,v),c.push(m),p===1&&g&&Jr.set(m,!0),v===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),i.clear(),xa++,function(){c.forEach(function(h){var m=En.get(h)-1,x=o.get(h)-1;En.set(h,m),o.set(h,x),m||(Jr.has(h)||h.removeAttribute(s),Jr.delete(h)),x||h.removeAttribute(n)}),xa--,xa||(En=new WeakMap,En=new WeakMap,Jr=new WeakMap,es={})}},zs=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=Dv(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),Lv(s,a,n,"aria-hidden")):function(){return null}},ot=function(){return ot=Object.assign||function(t){for(var n,s=1,a=arguments.length;s<a;s++){n=arguments[s];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ot.apply(this,arguments)};function ql(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]]);return n}function Fv(e,t,n){if(n||arguments.length===2)for(var s=0,a=t.length,o;s<a;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}var cs="right-scroll-bar-position",ls="width-before-scroll-bar",$v="with-scroll-bars-hidden",Uv="--removed-body-scroll-bar-size";function ga(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Vv(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var a=n.value;a!==s&&(n.value=s,n.callback(s,a))}}}})[0];return n.callback=t,n.facade}var Bv=typeof window<"u"?l.useLayoutEffect:l.useEffect,Yi=new WeakMap;function Kv(e,t){var n=Vv(null,function(s){return e.forEach(function(a){return ga(a,s)})});return Bv(function(){var s=Yi.get(n);if(s){var a=new Set(s),o=new Set(e),c=n.current;a.forEach(function(i){o.has(i)||ga(i,null)}),o.forEach(function(i){a.has(i)||ga(i,c)})}Yi.set(n,e)},[e]),n}function qv(e){return e}function Hv(e,t){t===void 0&&(t=qv);var n=[],s=!1,a={read:function(){if(s)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(o){var c=t(o,s);return n.push(c),function(){n=n.filter(function(i){return i!==c})}},assignSyncMedium:function(o){for(s=!0;n.length;){var c=n;n=[],c.forEach(o)}n={push:function(i){return o(i)},filter:function(){return n}}},assignMedium:function(o){s=!0;var c=[];if(n.length){var i=n;n=[],i.forEach(o),c=n}var f=function(){var d=c;c=[],d.forEach(o)},u=function(){return Promise.resolve().then(f)};u(),n={push:function(d){c.push(d),u()},filter:function(d){return c=c.filter(d),n}}}};return a}function Wv(e){e===void 0&&(e={});var t=Hv(null);return t.options=ot({async:!0,ssr:!1},e),t}var Hl=function(e){var t=e.sideCar,n=ql(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return l.createElement(s,ot({},n))};Hl.isSideCarExport=!0;function Gv(e,t){return e.useMedium(t),Hl}var Wl=Wv(),va=function(){},Ls=l.forwardRef(function(e,t){var n=l.useRef(null),s=l.useState({onScrollCapture:va,onWheelCapture:va,onTouchMoveCapture:va}),a=s[0],o=s[1],c=e.forwardProps,i=e.children,f=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,x=e.noRelative,g=e.noIsolation,p=e.inert,v=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,N=e.gapMode,j=ql(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,S=Kv([n,t]),E=ot(ot({},j),a);return l.createElement(l.Fragment,null,d&&l.createElement(C,{sideCar:Wl,removeScrollBar:u,shards:h,noRelative:x,noIsolation:g,inert:p,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:N}),c?l.cloneElement(l.Children.only(i),ot(ot({},E),{ref:S})):l.createElement(w,ot({},E,{className:f,ref:S}),i))});Ls.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ls.classNames={fullWidth:ls,zeroRight:cs};var Qv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Qv();return t&&e.setAttribute("nonce",t),e}function Xv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Zv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yv())&&(Xv(t,n),Zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},e0=function(){var e=Jv();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Gl=function(){var e=e0(),t=function(n){var s=n.styles,a=n.dynamic;return e(s,a),null};return t},t0={left:0,top:0,right:0,gap:0},ya=function(e){return parseInt(e||"",10)||0},n0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[ya(n),ya(s),ya(a)]},r0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return t0;var t=n0(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},s0=Gl(),In="data-scroll-locked",a0=function(e,t,n,s){var a=e.left,o=e.top,c=e.right,i=e.gap;return n===void 0&&(n="margin"),`
279
+ */const Yt=q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Eo(){return Ce({queryKey:["me"],queryFn:()=>W.get("/api/admin/me"),staleTime:5*6e4})}function ol(){const e=Ct(),t=l.useCallback(async(s,a)=>{var u;const o=await No("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,password:a})}),c=await o.json();if(!o.ok||!c.data)throw new Error(((u=c.error)==null?void 0:u.message)??"Login failed");const{accessToken:i,customer:f}=c.data;if(!f.roles.includes("admin"))throw new Error("Not authorized: admin role required");qc(i),await xs.invalidateQueries({queryKey:["me"]}),e("/")},[e]),n=l.useCallback(async()=>{await W.post("/api/auth/logout").catch(()=>{}),Wc(),xs.clear(),e("/login")},[e]);return{isAuthenticated:gs(),login:t,logout:n}}function Xt(){const[e,t]=l.useState(Ka),n=l.useCallback(()=>t(Ka()),[]);return[e,n]}function il(e={}){return Ce({queryKey:["orders","list",e],queryFn:()=>W.get("/api/admin/orders",e)})}function Qp(e){return Ce({queryKey:["orders","detail",e],queryFn:()=>W.get(`/api/admin/orders/${e}`),enabled:!!e})}function Yp(e){return Ce({queryKey:["orders","notes",e],queryFn:()=>W.get(`/api/admin/orders/${e}/notes`),enabled:!!e})}function Ts(e){return e.invalidateQueries({queryKey:["orders","detail"]})}function Xp(){const e=ye();return we({mutationFn:async({orderId:t,action:n,body:s})=>W.post(`/api/admin/orders/${t}/${n}`,s),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 Zp(){const e=ye();return we({mutationFn:({orderId:t,reason:n})=>W.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"]})},onError:()=>Ts(e)})}function cl(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,note:a})=>W.post(`/api/admin/orders/${s}/mark-paid`,a?{note:a}:{},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","detail",s.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})},onError:()=>Ts(e),onSettled:n})}function Jp(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/orders/${s}/mark-delivered`,void 0,{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>Ts(e),onSettled:n})}function ex(){const e=ye(),[t,n]=Xt();return we({mutationFn:({orderId:s,trackingNumber:a,carrier:o})=>W.post(`/api/admin/orders/${s}/ship`,{trackingNumber:a,carrier:o},{idempotencyKey:t}),onSuccess:s=>{e.setQueryData(["orders","detail",s.orderNumber],a=>a?{...a,...s}:s),e.invalidateQueries({queryKey:["orders","list"]})},onError:()=>Ts(e),onSettled:n})}function tx(){const e=ye();return we({mutationFn:({orderId:t,amountMinor:n,reason:s,requestId:a})=>W.post(`/api/admin/orders/${t}/refund`,s?{amountMinor:n,reason:s,requestId:a}:{amountMinor:n,requestId:a}),onSuccess:async t=>{await Promise.all([e.invalidateQueries({queryKey:["orders","detail",t.order.orderNumber]}),e.invalidateQueries({queryKey:["orders","list"]}),e.invalidateQueries({queryKey:["dashboard"]})])}})}function nx(){const[e,t]=Xt();return we({mutationFn:({orderId:n})=>W.post(`/api/admin/orders/${n}/resend-confirmation`,void 0,{idempotencyKey:e}),onSettled:t})}function rx(){const e=ye();return we({mutationFn:({orderId:t,body:n})=>W.post(`/api/admin/orders/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["orders","notes",n.orderId]})}})}const sx=50;function ax(e){return jo({queryKey:["proposals","list",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.get("/api/admin/proposals",{status:e,limit:sx,cursor:t}),getNextPageParam:t=>t.nextCursor??void 0})}function ox(e,t){return Ce({queryKey:["proposals","one",e],queryFn:()=>W.get(`/api/admin/proposals/${encodeURIComponent(e)}`),enabled:t})}function ix(){return Ce({queryKey:["proposals","count"],queryFn:async()=>(await W.get("/api/admin/proposals",{status:"pending",limit:1})).pending})}function ll(){const e=ye(),[t,n]=Xt();return we({mutationFn:s=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/approve`,void 0,{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function dl(){const e=ye(),[t,n]=Xt();return we({mutationFn:({id:s,reason:a})=>W.post(`/api/admin/proposals/${encodeURIComponent(s)}/reject`,a===""?{}:{reason:a},{idempotencyKey:t}),onSettled:()=>{n(),e.invalidateQueries({queryKey:["proposals"]})}})}function P(...e){return["admin",...e].join("-")}function ul(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=ul(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function fl(){for(var e,t,n=0,s="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=ul(e))&&(s&&(s+=" "),s+=t);return s}const Ro="-",cx=e=>{const t=dx(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:c=>{const i=c.split(Ro);return i[0]===""&&i.length!==1&&i.shift(),hl(i,t)||lx(c)},getConflictingClassGroupIds:(c,i)=>{const f=n[c]||[];return i&&s[c]?[...f,...s[c]]:f}}},hl=(e,t)=>{var c;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),a=s?hl(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const o=e.join(Ro);return(c=t.validators.find(({validator:i})=>i(o)))==null?void 0:c.classGroupId},Ri=/^\[(.+)\]$/,lx=e=>{if(Ri.test(e)){const t=Ri.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},dx=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return fx(Object.entries(e.classGroups),n).forEach(([o,c])=>{Qa(c,s,o,t)}),s},Qa=(e,t,n,s)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?t:Pi(t,a);o.classGroupId=n;return}if(typeof a=="function"){if(ux(a)){Qa(a(s),t,n,s);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([o,c])=>{Qa(c,Pi(t,o),n,s)})})},Pi=(e,t)=>{let n=e;return t.split(Ro).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},ux=e=>e.isThemeGetter,fx=(e,t)=>t?e.map(([n,s])=>{const a=s.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([c,i])=>[t+c,i])):o);return[n,a]}):e,hx=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const a=(o,c)=>{n.set(o,c),t++,t>e&&(t=0,s=n,n=new Map)};return{get(o){let c=n.get(o);if(c!==void 0)return c;if((c=s.get(o))!==void 0)return a(o,c),c},set(o,c){n.has(o)?n.set(o,c):a(o,c)}}},ml="!",mx=e=>{const{separator:t,experimentalParseClassName:n}=e,s=t.length===1,a=t[0],o=t.length,c=i=>{const f=[];let u=0,d=0,h;for(let v=0;v<i.length;v++){let y=i[v];if(u===0){if(y===a&&(s||i.slice(v,v+o)===t)){f.push(i.slice(d,v)),d=v+o;continue}if(y==="/"){h=v;continue}}y==="["?u++:y==="]"&&u--}const m=f.length===0?i:i.substring(d),x=m.startsWith(ml),g=x?m.substring(1):m,p=h&&h>d?h-d:void 0;return{modifiers:f,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:p}};return n?i=>n({className:i,parseClassName:c}):c},px=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(s=>{s[0]==="["?(t.push(...n.sort(),s),n=[]):n.push(s)}),t.push(...n.sort()),t},xx=e=>({cache:hx(e.cacheSize),parseClassName:mx(e),...cx(e)}),gx=/\s+/,vx=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a}=t,o=[],c=e.trim().split(gx);let i="";for(let f=c.length-1;f>=0;f-=1){const u=c[f],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:x}=n(u);let g=!!x,p=s(g?m.substring(0,x):m);if(!p){if(!g){i=u+(i.length>0?" "+i:i);continue}if(p=s(m),!p){i=u+(i.length>0?" "+i:i);continue}g=!1}const v=px(d).join(":"),y=h?v+ml:v,w=y+p;if(o.includes(w))continue;o.push(w);const N=a(p,g);for(let j=0;j<N.length;++j){const C=N[j];o.push(y+C)}i=u+(i.length>0?" "+i:i)}return i};function yx(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=pl(t))&&(s&&(s+=" "),s+=n);return s}const pl=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=pl(e[s]))&&(n&&(n+=" "),n+=t);return n};function bx(e,...t){let n,s,a,o=c;function c(f){const u=t.reduce((d,h)=>h(d),e());return n=xx(u),s=n.cache.get,a=n.cache.set,o=i,i(f)}function i(f){const u=s(f);if(u)return u;const d=vx(f,n);return a(f,d),d}return function(){return o(yx.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},xl=/^\[(?:([a-z-]+):)?(.+)\]$/i,wx=/^\d+\/\d+$/,jx=new Set(["px","full","screen"]),Nx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Cx=/\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$/,Sx=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Rx=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,mt=e=>Mn(e)||jx.has(e)||wx.test(e),Pt=e=>nr(e,"length",Ox),Mn=e=>!!e&&!Number.isNaN(Number(e)),da=e=>nr(e,"number",Mn),fr=e=>!!e&&Number.isInteger(Number(e)),Px=e=>e.endsWith("%")&&Mn(e.slice(0,-1)),te=e=>xl.test(e),kt=e=>Nx.test(e),kx=new Set(["length","size","percentage"]),Tx=e=>nr(e,kx,gl),Ax=e=>nr(e,"position",gl),Mx=new Set(["image","url"]),_x=e=>nr(e,Mx,zx),Ix=e=>nr(e,"",Dx),hr=()=>!0,nr=(e,t,n)=>{const s=xl.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):n(s[2]):!1},Ox=e=>Cx.test(e)&&!Sx.test(e),gl=()=>!1,Dx=e=>Ex.test(e),zx=e=>Rx.test(e),Lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),s=ge("brightness"),a=ge("borderColor"),o=ge("borderRadius"),c=ge("borderSpacing"),i=ge("borderWidth"),f=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),x=ge("gradientColorStops"),g=ge("gradientColorStopPositions"),p=ge("inset"),v=ge("margin"),y=ge("opacity"),w=ge("padding"),N=ge("saturate"),j=ge("scale"),C=ge("sepia"),S=ge("skew"),E=ge("space"),k=ge("translate"),z=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],U=()=>["auto",te,t],I=()=>[te,t],Q=()=>["",mt,Pt],V=()=>["auto",Mn,te],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>["start","end","center","between","around","evenly","stretch"],A=()=>["","0",te],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],le=()=>[Mn,te];return{cacheSize:500,separator:":",theme:{colors:[hr],spacing:[mt,Pt],blur:["none","",kt,te],brightness:le(),borderColor:[e],borderRadius:["none","","full",kt,te],borderSpacing:I(),borderWidth:Q(),contrast:le(),grayscale:A(),hueRotate:le(),invert:A(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Px,Pt],inset:U(),margin:U(),opacity:le(),padding:I(),saturate:le(),scale:le(),sepia:A(),skew:le(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",te]}],container:["container"],columns:[{columns:[kt]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"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:[...Z(),te]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],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",fr,te]}],basis:[{basis:U()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",te]}],grow:[{grow:A()}],shrink:[{shrink:A()}],order:[{order:["first","last","none",fr,te]}],"grid-cols":[{"grid-cols":[hr]}],"col-start-end":[{col:["auto",{span:["full",fr,te]},te]}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":[hr]}],"row-start-end":[{row:["auto",{span:[fr,te]},te]}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",te]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...F()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...F(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...F(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",te,t]}],"min-w":[{"min-w":[te,t,"min","max","fit"]}],"max-w":[{"max-w":[te,t,"none","full","min","max","fit","prose",{screen:[kt]},kt]}],h:[{h:[te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",kt,Pt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",da]}],"font-family":[{font:[hr]}],"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",te]}],"line-clamp":[{"line-clamp":["none",Mn,da]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",mt,te]}],"list-image":[{"list-image":["none",te]}],"list-style-type":[{list:["none","disc","decimal",te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",mt,Pt]}],"underline-offset":[{"underline-offset":["auto",mt,te]}],"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:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",te]}],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",te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),Ax]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Tx]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_x]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:B()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[mt,te]}],"outline-w":[{outline:[mt,Pt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[mt,Pt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",kt,Ix]}],"shadow-color":[{shadow:[hr]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",kt,te]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[N]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[c]}],"border-spacing-x":[{"border-spacing-x":[c]}],"border-spacing-y":[{"border-spacing-y":[c]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",te]}],duration:[{duration:le()}],ease:[{ease:["linear","in","out","in-out",te]}],delay:[{delay:le()}],animate:[{animate:["none","spin","ping","pulse","bounce",te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[fr,te]}],"translate-x":[{"translate-x":[k]}],"translate-y":[{"translate-y":[k]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",te]}],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",te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[mt,Pt,da]}],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"]}}},Fx=bx(Lx);function T(...e){return Fx(fl(e))}const $x=[{to:"/",label:"Dashboard",icon:$p,end:!0},{to:"/orders",label:"Orders",icon:Gn,end:!1},{to:"/products",label:"Products",icon:qt,end:!1},{to:"/inventory",label:"Inventory",icon:Xc,end:!1},{to:"/customers",label:"Customers",icon:So,end:!1},{to:"/activity",label:"Activity",icon:Wn,end:!1},{to:"/inbox",label:"Inbox",icon:Ha,end:!1},{to:"/settings",label:"Settings",icon:Wp,end:!1}];function Ux(){const{data:e}=il({status:"pending",limit:1});return!e||e.length===0?null:r.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 Vx(){const{data:e}=ix();return e===void 0||e===0?null:r.jsx("span",{className:"ml-auto flex h-4 min-w-4 items-center justify-center rounded-full bg-amber-500/20 px-1 text-[10px] font-semibold text-amber-400","data-testid":P("inbox","count"),children:e})}function Bx({open:e,onClose:t}){const{data:n}=Eo(),{logout:s}=ol(),a=()=>{s()};return r.jsxs("aside",{id:"admin-sidebar","data-testid":P("sidebar"),"data-state":e?"open":"closed",className:T("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:[r.jsxs("div",{className:"flex h-14 items-center border-b border-zinc-800/60 px-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"N"})}),r.jsx("span",{className:"text-sm font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"})]}),(n==null?void 0:n.storeName)&&r.jsx("span",{className:"ml-2 truncate text-[10px] font-medium text-zinc-500 border-l border-zinc-700 pl-2",children:n.storeName})]}),r.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:r.jsx("ul",{className:"space-y-0.5",children:$x.map(o=>r.jsx("li",{children:r.jsx(lh,{to:o.to,end:o.end,"data-testid":P("nav",o.label.toLowerCase()),onClick:t,className:({isActive:c})=>T("flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium transition-all duration-100",c?"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:c})=>r.jsxs(r.Fragment,{children:[r.jsx(o.icon,{className:T("h-4 w-4 shrink-0",c?"text-blue-400":"text-zinc-500")}),r.jsx("span",{children:o.label}),o.label==="Orders"&&r.jsx(Ux,{}),o.label==="Inbox"&&r.jsx(Vx,{})]})})},o.to))})}),r.jsx("div",{className:"border-t border-zinc-800/60"}),r.jsx("div",{className:"p-3",children:r.jsxs("div",{className:"flex items-center gap-3 rounded-md px-3 py-2.5",children:[r.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():r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-300",children:(n==null?void 0:n.storeName)??"Loading..."}),r.jsx("p",{className:"truncate text-[10px] text-zinc-500 capitalize",children:(n==null?void 0:n.environment)??""})]}),r.jsx("button",{onClick:a,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300 transition-colors",title:"Sign out",children:r.jsx(Up,{className:"h-3.5 w-3.5"})})]})})]})}function Kx(){const t=dh().filter(n=>{const s=n.handle;return(s==null?void 0:s.breadcrumb)!=null}).map(n=>{var o;const s=n.handle;return{label:(o=s.breadcrumb)==null?void 0:o.call(s,n.params),pathname:n.pathname}}).filter(n=>n.label!=null);return t.length===0?null:r.jsx("nav",{className:"flex items-center gap-1 text-sm","aria-label":"Breadcrumb",children:t.map((n,s)=>{const a=s===t.length-1;return r.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&r.jsx(Jc,{className:"h-3.5 w-3.5 text-zinc-400"}),a?r.jsx("span",{className:"font-medium text-zinc-900",children:n.label}):r.jsx(Ze,{to:n.pathname,className:T("text-zinc-500 hover:text-zinc-700 transition-colors","font-normal"),children:n.label})]},n.pathname)})})}const ki=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ti=fl,As=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return Ti(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:o}=t,c=Object.keys(a).map(u=>{const d=n==null?void 0:n[u],h=o==null?void 0:o[u];if(d===null)return null;const m=ki(d)||ki(h);return a[u][m]}),i=n&&Object.entries(n).reduce((u,d)=>{let[h,m]=d;return m===void 0||(u[h]=m),u},{}),f=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((u,d)=>{let{class:h,className:m,...x}=d;return Object.entries(x).every(g=>{let[p,v]=g;return Array.isArray(v)?v.includes({...o,...i}[p]):{...o,...i}[p]===v})?[...u,h,m]:u},[]);return Ti(e,c,f,n==null?void 0:n.class,n==null?void 0:n.className)},qx=As("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"}}),se=l.forwardRef(({className:e,variant:t,size:n,...s},a)=>r.jsx("button",{className:T(qx({variant:t,size:n,className:e})),ref:a,...s}));se.displayName="Button";function D(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function Ai(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function lt(...e){return t=>{let n=!1;const s=e.map(a=>{const o=Ai(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<s.length;a++){const o=s[a];typeof o=="function"?o():Ai(e[a],null)}}}}function de(...e){return l.useCallback(lt(...e),e)}function Hx(e,t){const n=l.createContext(t),s=o=>{const{children:c,...i}=o,f=l.useMemo(()=>i,Object.values(i));return r.jsx(n.Provider,{value:f,children:c})};s.displayName=e+"Provider";function a(o){const c=l.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[s,a]}function ut(e,t=[]){let n=[];function s(o,c){const i=l.createContext(c),f=n.length;n=[...n,c];const u=h=>{var y;const{scope:m,children:x,...g}=h,p=((y=m==null?void 0:m[e])==null?void 0:y[f])||i,v=l.useMemo(()=>g,Object.values(g));return r.jsx(p.Provider,{value:v,children:x})};u.displayName=o+"Provider";function d(h,m){var p;const x=((p=m==null?void 0:m[e])==null?void 0:p[f])||i,g=l.useContext(x);if(g)return g;if(c!==void 0)return c;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[u,d]}const a=()=>{const o=n.map(c=>l.createContext(c));return function(i){const f=(i==null?void 0:i[e])||o;return l.useMemo(()=>({[`__scope${e}`]:{...i,[e]:f}}),[i,f])}};return a.scopeName=e,[s,Wx(a,...t)]}function Wx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const c=s.reduce((i,{useScope:f,scopeName:u})=>{const h=f(o)[`__scope${u}`];return{...i,...h}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function pn(e){const t=Gx(e),n=l.forwardRef((s,a)=>{const{children:o,...c}=s,i=l.Children.toArray(o),f=i.find(Yx);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function Gx(e){const t=l.forwardRef((n,s)=>{const{children:a,...o}=n;if(l.isValidElement(a)){const c=Zx(a),i=Xx(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Qx=Symbol("radix.slottable");function Yx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Qx}function Xx(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function Zx(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],G=Jx.reduce((e,t)=>{const n=pn(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function vl(e,t){e&&Ps.flushSync(()=>e.dispatchEvent(t))}function dt(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function eg(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e);l.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var tg="DismissableLayer",Ya="dismissableLayer.update",ng="dismissableLayer.pointerDownOutside",rg="dismissableLayer.focusOutside",Mi,yl=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_r=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:c,onDismiss:i,...f}=e,u=l.useContext(yl),[d,h]=l.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=l.useState({}),g=de(t,E=>h(E)),p=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=p.indexOf(v),w=d?p.indexOf(d):-1,N=u.layersWithOutsidePointerEventsDisabled.size>0,j=w>=y,C=og(E=>{const k=E.target,z=[...u.branches].some(O=>O.contains(k));!j||z||(a==null||a(E),c==null||c(E),E.defaultPrevented||i==null||i())},m),S=ig(E=>{const k=E.target;[...u.branches].some(O=>O.contains(k))||(o==null||o(E),c==null||c(E),E.defaultPrevented||i==null||i())},m);return eg(E=>{w===u.layers.size-1&&(s==null||s(E),!E.defaultPrevented&&i&&(E.preventDefault(),i()))},m),l.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Mi=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),_i(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Mi)}},[d,m,n,u]),l.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),_i())},[d,u]),l.useEffect(()=>{const E=()=>x({});return document.addEventListener(Ya,E),()=>document.removeEventListener(Ya,E)},[]),r.jsx(G.div,{...f,ref:g,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:D(e.onFocusCapture,S.onFocusCapture),onBlurCapture:D(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:D(e.onPointerDownCapture,C.onPointerDownCapture)})});_r.displayName=tg;var sg="DismissableLayerBranch",ag=l.forwardRef((e,t)=>{const n=l.useContext(yl),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),r.jsx(G.div,{...e,ref:a})});ag.displayName=sg;function og(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1),a=l.useRef(()=>{});return l.useEffect(()=>{const o=i=>{if(i.target&&!s.current){let f=function(){bl(ng,n,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=f,t.addEventListener("click",a.current,{once:!0})):f()}else t.removeEventListener("click",a.current);s.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",o),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function ig(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),s=l.useRef(!1);return l.useEffect(()=>{const a=o=>{o.target&&!s.current&&bl(rg,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function _i(){const e=new CustomEvent(Ya);document.dispatchEvent(e)}function bl(e,t,n,{discrete:s}){const a=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),s?vl(a,o):a.dispatchEvent(o)}var ua=0;function Ms(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ii()),document.body.insertAdjacentElement("beforeend",e[1]??Ii()),ua++,()=>{ua===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ua--}},[])}function Ii(){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 fa="focusScope.autoFocusOnMount",ha="focusScope.autoFocusOnUnmount",Oi={bubbles:!1,cancelable:!0},cg="FocusScope",Ir=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...c}=e,[i,f]=l.useState(null),u=dt(a),d=dt(o),h=l.useRef(null),m=de(t,p=>f(p)),x=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(s){let p=function(N){if(x.paused||!i)return;const j=N.target;i.contains(j)?h.current=j:Mt(h.current,{select:!0})},v=function(N){if(x.paused||!i)return;const j=N.relatedTarget;j!==null&&(i.contains(j)||Mt(h.current,{select:!0}))},y=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&Mt(i)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const w=new MutationObserver(y);return i&&w.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),w.disconnect()}}},[s,i,x.paused]),l.useEffect(()=>{if(i){zi.add(x);const p=document.activeElement;if(!i.contains(p)){const y=new CustomEvent(fa,Oi);i.addEventListener(fa,u),i.dispatchEvent(y),y.defaultPrevented||(lg(mg(wl(i)),{select:!0}),document.activeElement===p&&Mt(i))}return()=>{i.removeEventListener(fa,u),setTimeout(()=>{const y=new CustomEvent(ha,Oi);i.addEventListener(ha,d),i.dispatchEvent(y),y.defaultPrevented||Mt(p??document.body,{select:!0}),i.removeEventListener(ha,d),zi.remove(x)},0)}}},[i,u,d,x]);const g=l.useCallback(p=>{if(!n&&!s||x.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(v&&y){const w=p.currentTarget,[N,j]=dg(w);N&&j?!p.shiftKey&&y===j?(p.preventDefault(),n&&Mt(N,{select:!0})):p.shiftKey&&y===N&&(p.preventDefault(),n&&Mt(j,{select:!0})):y===w&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(G.div,{tabIndex:-1,...c,ref:m,onKeyDown:g})});Ir.displayName=cg;function lg(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Mt(s,{select:t}),document.activeElement!==n)return}function dg(e){const t=wl(e),n=Di(t,e),s=Di(t.reverse(),e);return[n,s]}function wl(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Di(e,t){for(const n of e)if(!ug(n,{upTo:t}))return n}function ug(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 fg(e){return e instanceof HTMLInputElement&&"select"in e}function Mt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&fg(e)&&t&&e.select()}}var zi=hg();function hg(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Li(e,t),e.unshift(t)},remove(t){var n;e=Li(e,t),(n=e[0])==null||n.resume()}}}function Li(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function mg(e){return e.filter(t=>t.tagName!=="A")}var Re=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},pg=po[" useId ".trim().toString()]||(()=>{}),xg=0;function Ne(e){const[t,n]=l.useState(pg());return Re(()=>{n(s=>s??String(xg++))},[e]),t?`radix-${t}`:""}const gg=["top","right","bottom","left"],Ht=Math.min,$e=Math.max,ys=Math.round,Xr=Math.floor,ct=e=>({x:e,y:e}),vg={left:"right",right:"left",bottom:"top",top:"bottom"};function Xa(e,t,n){return $e(e,Ht(t,n))}function jt(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function rr(e){return e.split("-")[1]}function Po(e){return e==="x"?"y":"x"}function ko(e){return e==="y"?"height":"width"}function it(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function To(e){return Po(it(e))}function yg(e,t,n){n===void 0&&(n=!1);const s=rr(e),a=To(e),o=ko(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=bs(c)),[c,bs(c)]}function bg(e){const t=bs(e);return[Za(e),t,Za(t)]}function Za(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Fi=["left","right"],$i=["right","left"],wg=["top","bottom"],jg=["bottom","top"];function Ng(e,t,n){switch(e){case"top":case"bottom":return n?t?$i:Fi:t?Fi:$i;case"left":case"right":return t?wg:jg;default:return[]}}function Cg(e,t,n,s){const a=rr(e);let o=Ng(Nt(e),n==="start",s);return a&&(o=o.map(c=>c+"-"+a),t&&(o=o.concat(o.map(Za)))),o}function bs(e){const t=Nt(e);return vg[t]+e.slice(t.length)}function Sg(e){return{top:0,right:0,bottom:0,left:0,...e}}function jl(e){return typeof e!="number"?Sg(e):{top:e,right:e,bottom:e,left:e}}function ws(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Ui(e,t,n){let{reference:s,floating:a}=e;const o=it(t),c=To(t),i=ko(c),f=Nt(t),u=o==="y",d=s.x+s.width/2-a.width/2,h=s.y+s.height/2-a.height/2,m=s[i]/2-a[i]/2;let x;switch(f){case"top":x={x:d,y:s.y-a.height};break;case"bottom":x={x:d,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:h};break;case"left":x={x:s.x-a.width,y:h};break;default:x={x:s.x,y:s.y}}switch(rr(t)){case"start":x[c]-=m*(n&&u?-1:1);break;case"end":x[c]+=m*(n&&u?-1:1);break}return x}async function Eg(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:o,rects:c,elements:i,strategy:f}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:x=0}=jt(t,e),g=jl(x),v=i[m?h==="floating"?"reference":"floating":h],y=ws(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(v)))==null||n?v:v.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(i.floating)),boundary:u,rootBoundary:d,strategy:f})),w=h==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(i.floating)),j=await(o.isElement==null?void 0:o.isElement(N))?await(o.getScale==null?void 0:o.getScale(N))||{x:1,y:1}:{x:1,y:1},C=ws(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:w,offsetParent:N,strategy:f}):w);return{top:(y.top-C.top+g.top)/j.y,bottom:(C.bottom-y.bottom+g.bottom)/j.y,left:(y.left-C.left+g.left)/j.x,right:(C.right-y.right+g.right)/j.x}}const Rg=50,Pg=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:c}=n,i=c.detectOverflow?c:{...c,detectOverflow:Eg},f=await(c.isRTL==null?void 0:c.isRTL(t));let u=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:h}=Ui(u,s,f),m=s,x=0;const g={};for(let p=0;p<o.length;p++){const v=o[p];if(!v)continue;const{name:y,fn:w}=v,{x:N,y:j,data:C,reset:S}=await w({x:d,y:h,initialPlacement:s,placement:m,strategy:a,middlewareData:g,rects:u,platform:i,elements:{reference:e,floating:t}});d=N??d,h=j??h,g[y]={...g[y],...C},S&&x<Rg&&(x++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(u=S.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):S.rects),{x:d,y:h}=Ui(u,m,f)),p=-1)}return{x:d,y:h,placement:m,strategy:a,middlewareData:g}},kg=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:o,platform:c,elements:i,middlewareData:f}=t,{element:u,padding:d=0}=jt(e,t)||{};if(u==null)return{};const h=jl(d),m={x:n,y:s},x=To(a),g=ko(x),p=await c.getDimensions(u),v=x==="y",y=v?"top":"left",w=v?"bottom":"right",N=v?"clientHeight":"clientWidth",j=o.reference[g]+o.reference[x]-m[x]-o.floating[g],C=m[x]-o.reference[x],S=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let E=S?S[N]:0;(!E||!await(c.isElement==null?void 0:c.isElement(S)))&&(E=i.floating[N]||o.floating[g]);const k=j/2-C/2,z=E/2-p[g]/2-1,O=Ht(h[y],z),U=Ht(h[w],z),I=O,Q=E-p[g]-U,V=E/2-p[g]/2+k,Z=Xa(I,V,Q),B=!f.arrow&&rr(a)!=null&&V!==Z&&o.reference[g]/2-(V<I?O:U)-p[g]/2<0,ae=B?V<I?V-I:V-Q:0;return{[x]:m[x]+ae,data:{[x]:Z,centerOffset:V-Z-ae,...B&&{alignmentOffset:ae}},reset:B}}}),Tg=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:o,rects:c,initialPlacement:i,platform:f,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...v}=jt(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(a),w=it(i),N=Nt(i)===i,j=await(f.isRTL==null?void 0:f.isRTL(u.floating)),C=m||(N||!p?[bs(i)]:bg(i)),S=g!=="none";!m&&S&&C.push(...Cg(i,p,g,j));const E=[i,...C],k=await f.detectOverflow(t,v),z=[];let O=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&z.push(k[y]),h){const V=yg(a,c,j);z.push(k[V[0]],k[V[1]])}if(O=[...O,{placement:a,overflows:z}],!z.every(V=>V<=0)){var U,I;const V=(((U=o.flip)==null?void 0:U.index)||0)+1,Z=E[V];if(Z&&(!(h==="alignment"?w!==it(Z):!1)||O.every(F=>it(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:V,overflows:O},reset:{placement:Z}};let B=(I=O.filter(ae=>ae.overflows[0]<=0).sort((ae,F)=>ae.overflows[1]-F.overflows[1])[0])==null?void 0:I.placement;if(!B)switch(x){case"bestFit":{var Q;const ae=(Q=O.filter(F=>{if(S){const A=it(F.placement);return A===w||A==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(A=>A>0).reduce((A,ce)=>A+ce,0)]).sort((F,A)=>F[1]-A[1])[0])==null?void 0:Q[0];ae&&(B=ae);break}case"initialPlacement":B=i;break}if(a!==B)return{reset:{placement:B}}}return{}}}};function Vi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Bi(e){return gg.some(t=>e[t]>=0)}const Ag=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...o}=jt(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...o,elementContext:"reference"}),i=Vi(c,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Bi(i)}}}case"escaped":{const c=await s.detectOverflow(t,{...o,altBoundary:!0}),i=Vi(c,n.floating);return{data:{escapedOffsets:i,escaped:Bi(i)}}}default:return{}}}}},Nl=new Set(["left","top"]);async function Mg(e,t){const{placement:n,platform:s,elements:a}=e,o=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Nt(n),i=rr(n),f=it(n)==="y",u=Nl.has(c)?-1:1,d=o&&f?-1:1,h=jt(t,e);let{mainAxis:m,crossAxis:x,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return i&&typeof g=="number"&&(x=i==="end"?g*-1:g),f?{x:x*d,y:m*u}:{x:m*u,y:x*d}}const _g=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:o,placement:c,middlewareData:i}=t,f=await Mg(t,e);return c===((n=i.offset)==null?void 0:n.placement)&&(s=i.arrow)!=null&&s.alignmentOffset?{}:{x:a+f.x,y:o+f.y,data:{...f,placement:c}}}}},Ig=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:o}=t,{mainAxis:c=!0,crossAxis:i=!1,limiter:f={fn:y=>{let{x:w,y:N}=y;return{x:w,y:N}}},...u}=jt(e,t),d={x:n,y:s},h=await o.detectOverflow(t,u),m=it(Nt(a)),x=Po(m);let g=d[x],p=d[m];if(c){const y=x==="y"?"top":"left",w=x==="y"?"bottom":"right",N=g+h[y],j=g-h[w];g=Xa(N,g,j)}if(i){const y=m==="y"?"top":"left",w=m==="y"?"bottom":"right",N=p+h[y],j=p-h[w];p=Xa(N,p,j)}const v=f.fn({...t,[x]:g,[m]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[x]:c,[m]:i}}}}}},Og=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:o,middlewareData:c}=t,{offset:i=0,mainAxis:f=!0,crossAxis:u=!0}=jt(e,t),d={x:n,y:s},h=it(a),m=Po(h);let x=d[m],g=d[h];const p=jt(i,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(f){const N=m==="y"?"height":"width",j=o.reference[m]-o.floating[N]+v.mainAxis,C=o.reference[m]+o.reference[N]-v.mainAxis;x<j?x=j:x>C&&(x=C)}if(u){var y,w;const N=m==="y"?"width":"height",j=Nl.has(Nt(a)),C=o.reference[h]-o.floating[N]+(j&&((y=c.offset)==null?void 0:y[h])||0)+(j?0:v.crossAxis),S=o.reference[h]+o.reference[N]+(j?0:((w=c.offset)==null?void 0:w[h])||0)-(j?v.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[m]:x,[h]:g}}}},Dg=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:o,platform:c,elements:i}=t,{apply:f=()=>{},...u}=jt(e,t),d=await c.detectOverflow(t,u),h=Nt(a),m=rr(a),x=it(a)==="y",{width:g,height:p}=o.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=m===(await(c.isRTL==null?void 0:c.isRTL(i.floating))?"start":"end")?"left":"right"):(y=h,v=m==="end"?"top":"bottom");const w=p-d.top-d.bottom,N=g-d.left-d.right,j=Ht(p-d[v],w),C=Ht(g-d[y],N),S=!t.middlewareData.shift;let E=j,k=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(E=w),S&&!m){const O=$e(d.left,0),U=$e(d.right,0),I=$e(d.top,0),Q=$e(d.bottom,0);x?k=g-2*(O!==0||U!==0?O+U:$e(d.left,d.right)):E=p-2*(I!==0||Q!==0?I+Q:$e(d.top,d.bottom))}await f({...t,availableWidth:k,availableHeight:E});const z=await c.getDimensions(i.floating);return g!==z.width||p!==z.height?{reset:{rects:!0}}:{}}}};function _s(){return typeof window<"u"}function sr(e){return Cl(e)?(e.nodeName||"").toLowerCase():"#document"}function Ve(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ft(e){var t;return(t=(Cl(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cl(e){return _s()?e instanceof Node||e instanceof Ve(e).Node:!1}function Je(e){return _s()?e instanceof Element||e instanceof Ve(e).Element:!1}function Et(e){return _s()?e instanceof HTMLElement||e instanceof Ve(e).HTMLElement:!1}function Ki(e){return!_s()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ve(e).ShadowRoot}function Or(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=et(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function zg(e){return/^(table|td|th)$/.test(sr(e))}function Is(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Lg=/transform|translate|scale|rotate|perspective|filter/,Fg=/paint|layout|strict|content/,tn=e=>!!e&&e!=="none";let ma;function Ao(e){const t=Je(e)?et(e):e;return tn(t.transform)||tn(t.translate)||tn(t.scale)||tn(t.rotate)||tn(t.perspective)||!Mo()&&(tn(t.backdropFilter)||tn(t.filter))||Lg.test(t.willChange||"")||Fg.test(t.contain||"")}function $g(e){let t=Wt(e);for(;Et(t)&&!Qn(t);){if(Ao(t))return t;if(Is(t))return null;t=Wt(t)}return null}function Mo(){return ma==null&&(ma=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ma}function Qn(e){return/^(html|body|#document)$/.test(sr(e))}function et(e){return Ve(e).getComputedStyle(e)}function Os(e){return Je(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wt(e){if(sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ki(e)&&e.host||ft(e);return Ki(t)?t.host:t}function Sl(e){const t=Wt(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Et(t)&&Or(t)?t:Sl(t)}function wr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=Sl(e),o=a===((s=e.ownerDocument)==null?void 0:s.body),c=Ve(a);if(o){const i=Ja(c);return t.concat(c,c.visualViewport||[],Or(a)?a:[],i&&n?wr(i):[])}else return t.concat(a,wr(a,[],n))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function El(e){const t=et(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Et(e),o=a?e.offsetWidth:n,c=a?e.offsetHeight:s,i=ys(n)!==o||ys(s)!==c;return i&&(n=o,s=c),{width:n,height:s,$:i}}function _o(e){return Je(e)?e:e.contextElement}function _n(e){const t=_o(e);if(!Et(t))return ct(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:o}=El(t);let c=(o?ys(n.width):n.width)/s,i=(o?ys(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!i||!Number.isFinite(i))&&(i=1),{x:c,y:i}}const Ug=ct(0);function Rl(e){const t=Ve(e);return!Mo()||!t.visualViewport?Ug:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Vg(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ve(e)?!1:t}function xn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=_o(e);let c=ct(1);t&&(s?Je(s)&&(c=_n(s)):c=_n(e));const i=Vg(o,n,s)?Rl(o):ct(0);let f=(a.left+i.x)/c.x,u=(a.top+i.y)/c.y,d=a.width/c.x,h=a.height/c.y;if(o){const m=Ve(o),x=s&&Je(s)?Ve(s):s;let g=m,p=Ja(g);for(;p&&s&&x!==g;){const v=_n(p),y=p.getBoundingClientRect(),w=et(p),N=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*v.x,j=y.top+(p.clientTop+parseFloat(w.paddingTop))*v.y;f*=v.x,u*=v.y,d*=v.x,h*=v.y,f+=N,u+=j,g=Ve(p),p=Ja(g)}}return ws({width:d,height:h,x:f,y:u})}function Ds(e,t){const n=Os(e).scrollLeft;return t?t.left+n:xn(ft(e)).left+n}function Pl(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Ds(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function Bg(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const o=a==="fixed",c=ft(s),i=t?Is(t.floating):!1;if(s===c||i&&o)return n;let f={scrollLeft:0,scrollTop:0},u=ct(1);const d=ct(0),h=Et(s);if((h||!h&&!o)&&((sr(s)!=="body"||Or(c))&&(f=Os(s)),h)){const x=xn(s);u=_n(s),d.x=x.x+s.clientLeft,d.y=x.y+s.clientTop}const m=c&&!h&&!o?Pl(c,f):ct(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-f.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-f.scrollTop*u.y+d.y+m.y}}function Kg(e){return Array.from(e.getClientRects())}function qg(e){const t=ft(e),n=Os(e),s=e.ownerDocument.body,a=$e(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=$e(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Ds(e);const i=-n.scrollTop;return et(s).direction==="rtl"&&(c+=$e(t.clientWidth,s.clientWidth)-a),{width:a,height:o,x:c,y:i}}const qi=25;function Hg(e,t){const n=Ve(e),s=ft(e),a=n.visualViewport;let o=s.clientWidth,c=s.clientHeight,i=0,f=0;if(a){o=a.width,c=a.height;const d=Mo();(!d||d&&t==="fixed")&&(i=a.offsetLeft,f=a.offsetTop)}const u=Ds(s);if(u<=0){const d=s.ownerDocument,h=d.body,m=getComputedStyle(h),x=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-x);g<=qi&&(o-=g)}else u<=qi&&(o+=u);return{width:o,height:c,x:i,y:f}}function Wg(e,t){const n=xn(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,o=Et(e)?_n(e):ct(1),c=e.clientWidth*o.x,i=e.clientHeight*o.y,f=a*o.x,u=s*o.y;return{width:c,height:i,x:f,y:u}}function Hi(e,t,n){let s;if(t==="viewport")s=Hg(e,n);else if(t==="document")s=qg(ft(e));else if(Je(t))s=Wg(t,n);else{const a=Rl(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return ws(s)}function kl(e,t){const n=Wt(e);return n===t||!Je(n)||Qn(n)?!1:et(n).position==="fixed"||kl(n,t)}function Gg(e,t){const n=t.get(e);if(n)return n;let s=wr(e,[],!1).filter(i=>Je(i)&&sr(i)!=="body"),a=null;const o=et(e).position==="fixed";let c=o?Wt(e):e;for(;Je(c)&&!Qn(c);){const i=et(c),f=Ao(c);!f&&i.position==="fixed"&&(a=null),(o?!f&&!a:!f&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Or(c)&&!f&&kl(e,c))?s=s.filter(d=>d!==c):a=i,c=Wt(c)}return t.set(e,s),s}function Qg(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?Is(t)?[]:Gg(t,this._c):[].concat(n),s],i=Hi(t,c[0],a);let f=i.top,u=i.right,d=i.bottom,h=i.left;for(let m=1;m<c.length;m++){const x=Hi(t,c[m],a);f=$e(x.top,f),u=Ht(x.right,u),d=Ht(x.bottom,d),h=$e(x.left,h)}return{width:u-h,height:d-f,x:h,y:f}}function Yg(e){const{width:t,height:n}=El(e);return{width:t,height:n}}function Xg(e,t,n){const s=Et(t),a=ft(t),o=n==="fixed",c=xn(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const f=ct(0);function u(){f.x=Ds(a)}if(s||!s&&!o)if((sr(t)!=="body"||Or(a))&&(i=Os(t)),s){const x=xn(t,!0,o,t);f.x=x.x+t.clientLeft,f.y=x.y+t.clientTop}else a&&u();o&&!s&&a&&u();const d=a&&!s&&!o?Pl(a,i):ct(0),h=c.left+i.scrollLeft-f.x-d.x,m=c.top+i.scrollTop-f.y-d.y;return{x:h,y:m,width:c.width,height:c.height}}function pa(e){return et(e).position==="static"}function Wi(e,t){if(!Et(e)||et(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ft(e)===n&&(n=n.ownerDocument.body),n}function Tl(e,t){const n=Ve(e);if(Is(e))return n;if(!Et(e)){let a=Wt(e);for(;a&&!Qn(a);){if(Je(a)&&!pa(a))return a;a=Wt(a)}return n}let s=Wi(e,t);for(;s&&zg(s)&&pa(s);)s=Wi(s,t);return s&&Qn(s)&&pa(s)&&!Ao(s)?n:s||$g(e)||n}const Zg=async function(e){const t=this.getOffsetParent||Tl,n=this.getDimensions,s=await n(e.floating);return{reference:Xg(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Jg(e){return et(e).direction==="rtl"}const ev={convertOffsetParentRelativeRectToViewportRelativeRect:Bg,getDocumentElement:ft,getClippingRect:Qg,getOffsetParent:Tl,getElementRects:Zg,getClientRects:Kg,getDimensions:Yg,getScale:_n,isElement:Je,isRTL:Jg};function Al(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tv(e,t){let n=null,s;const a=ft(e);function o(){var i;clearTimeout(s),(i=n)==null||i.disconnect(),n=null}function c(i,f){i===void 0&&(i=!1),f===void 0&&(f=1),o();const u=e.getBoundingClientRect(),{left:d,top:h,width:m,height:x}=u;if(i||t(),!m||!x)return;const g=Xr(h),p=Xr(a.clientWidth-(d+m)),v=Xr(a.clientHeight-(h+x)),y=Xr(d),N={rootMargin:-g+"px "+-p+"px "+-v+"px "+-y+"px",threshold:$e(0,Ht(1,f))||1};let j=!0;function C(S){const E=S[0].intersectionRatio;if(E!==f){if(!j)return c();E?c(!1,E):s=setTimeout(()=>{c(!1,1e-7)},1e3)}E===1&&!Al(u,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver(C,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(C,N)}n.observe(e)}return c(!0),o}function nv(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:f=!1}=s,u=_o(e),d=a||o?[...u?wr(u):[],...t?wr(t):[]]:[];d.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});const h=u&&i?tv(u,n):null;let m=-1,x=null;c&&(x=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),u&&!f&&x.observe(u),t&&x.observe(t));let g,p=f?xn(e):null;f&&v();function v(){const y=xn(e);p&&!Al(p,y)&&n(),p=y,g=requestAnimationFrame(v)}return n(),()=>{var y;d.forEach(w=>{a&&w.removeEventListener("scroll",n),o&&w.removeEventListener("resize",n)}),h==null||h(),(y=x)==null||y.disconnect(),x=null,f&&cancelAnimationFrame(g)}}const rv=_g,sv=Ig,av=Tg,ov=Dg,iv=Ag,Gi=kg,cv=Og,lv=(e,t,n)=>{const s=new Map,a={platform:ev,...n},o={...a.platform,_c:s};return Pg(e,t,{...a,platform:o})};var dv=typeof document<"u",uv=function(){},cs=dv?l.useLayoutEffect:uv;function js(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,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!js(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const o=a[s];if(!(o==="_owner"&&e.$$typeof)&&!js(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Ml(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Qi(e,t){const n=Ml(e);return Math.round(t*n)/n}function xa(e){const t=l.useRef(e);return cs(()=>{t.current=e}),t}function fv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:o,floating:c}={},transform:i=!0,whileElementsMounted:f,open:u}=e,[d,h]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,x]=l.useState(s);js(m,s)||x(s);const[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useCallback(F=>{F!==S.current&&(S.current=F,p(F))},[]),N=l.useCallback(F=>{F!==E.current&&(E.current=F,y(F))},[]),j=o||g,C=c||v,S=l.useRef(null),E=l.useRef(null),k=l.useRef(d),z=f!=null,O=xa(f),U=xa(a),I=xa(u),Q=l.useCallback(()=>{if(!S.current||!E.current)return;const F={placement:t,strategy:n,middleware:m};U.current&&(F.platform=U.current),lv(S.current,E.current,F).then(A=>{const ce={...A,isPositioned:I.current!==!1};V.current&&!js(k.current,ce)&&(k.current=ce,Ps.flushSync(()=>{h(ce)}))})},[m,t,n,U,I]);cs(()=>{u===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[u]);const V=l.useRef(!1);cs(()=>(V.current=!0,()=>{V.current=!1}),[]),cs(()=>{if(j&&(S.current=j),C&&(E.current=C),j&&C){if(O.current)return O.current(j,C,Q);Q()}},[j,C,Q,O,z]);const Z=l.useMemo(()=>({reference:S,floating:E,setReference:w,setFloating:N}),[w,N]),B=l.useMemo(()=>({reference:j,floating:C}),[j,C]),ae=l.useMemo(()=>{const F={position:n,left:0,top:0};if(!B.floating)return F;const A=Qi(B.floating,d.x),ce=Qi(B.floating,d.y);return i?{...F,transform:"translate("+A+"px, "+ce+"px)",...Ml(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:ce}},[n,i,B.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:Q,refs:Z,elements:B,floatingStyles:ae}),[d,Q,Z,B,ae])}const hv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Gi({element:s.current,padding:a}).fn(n):{}:s?Gi({element:s,padding:a}).fn(n):{}}}},mv=(e,t)=>{const n=rv(e);return{name:n.name,fn:n.fn,options:[e,t]}},pv=(e,t)=>{const n=sv(e);return{name:n.name,fn:n.fn,options:[e,t]}},xv=(e,t)=>({fn:cv(e).fn,options:[e,t]}),gv=(e,t)=>{const n=av(e);return{name:n.name,fn:n.fn,options:[e,t]}},vv=(e,t)=>{const n=ov(e);return{name:n.name,fn:n.fn,options:[e,t]}},yv=(e,t)=>{const n=iv(e);return{name:n.name,fn:n.fn,options:[e,t]}},bv=(e,t)=>{const n=hv(e);return{name:n.name,fn:n.fn,options:[e,t]}};var wv="Arrow",_l=l.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...o}=e;return r.jsx(G.svg,{...o,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});_l.displayName=wv;var jv=_l;function Il(e){const[t,n]=l.useState(void 0);return Re(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let c,i;if("borderBoxSize"in o){const f=o.borderBoxSize,u=Array.isArray(f)?f[0]:f;c=u.inlineSize,i=u.blockSize}else c=e.offsetWidth,i=e.offsetHeight;n({width:c,height:i})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Io="Popper",[Ol,ar]=ut(Io),[Nv,Dl]=Ol(Io),zl=e=>{const{__scopePopper:t,children:n}=e,[s,a]=l.useState(null);return r.jsx(Nv,{scope:t,anchor:s,onAnchorChange:a,children:n})};zl.displayName=Io;var Ll="PopperAnchor",Fl=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,o=Dl(Ll,n),c=l.useRef(null),i=de(t,c),f=l.useRef(null);return l.useEffect(()=>{const u=f.current;f.current=(s==null?void 0:s.current)||c.current,u!==f.current&&o.onAnchorChange(f.current)}),s?null:r.jsx(G.div,{...a,ref:i})});Fl.displayName=Ll;var Oo="PopperContent",[Cv,Sv]=Ol(Oo),$l=l.forwardRef((e,t)=>{var M,Y,X,ie,fe,he;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:c=0,arrowPadding:i=0,avoidCollisions:f=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:x="optimized",onPlaced:g,...p}=e,v=Dl(Oo,n),[y,w]=l.useState(null),N=de(t,ze=>w(ze)),[j,C]=l.useState(null),S=Il(j),E=(S==null?void 0:S.width)??0,k=(S==null?void 0:S.height)??0,z=s+(o!=="center"?"-"+o:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},U=Array.isArray(u)?u:[u],I=U.length>0,Q={padding:O,boundary:U.filter(Rv),altBoundary:I},{refs:V,floatingStyles:Z,placement:B,isPositioned:ae,middlewareData:F}=fv({strategy:"fixed",placement:z,whileElementsMounted:(...ze)=>nv(...ze,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[mv({mainAxis:a+k,alignmentAxis:c}),f&&pv({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?xv():void 0,...Q}),f&&gv({...Q}),vv({...Q,apply:({elements:ze,rects:nt,availableWidth:cr,availableHeight:lr})=>{const{width:dr,height:oh}=nt.reference,Hr=ze.floating.style;Hr.setProperty("--radix-popper-available-width",`${cr}px`),Hr.setProperty("--radix-popper-available-height",`${lr}px`),Hr.setProperty("--radix-popper-anchor-width",`${dr}px`),Hr.setProperty("--radix-popper-anchor-height",`${oh}px`)}}),j&&bv({element:j,padding:i}),Pv({arrowWidth:E,arrowHeight:k}),m&&yv({strategy:"referenceHidden",...Q})]}),[A,ce]=Bl(B),le=dt(g);Re(()=>{ae&&(le==null||le())},[ae,le]);const R=(M=F.arrow)==null?void 0:M.x,K=(Y=F.arrow)==null?void 0:Y.y,H=((X=F.arrow)==null?void 0:X.centerOffset)!==0,[L,J]=l.useState();return Re(()=>{y&&J(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:ae?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(ie=F.transformOrigin)==null?void 0:ie.x,(fe=F.transformOrigin)==null?void 0:fe.y].join(" "),...((he=F.hide)==null?void 0:he.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(Cv,{scope:n,placedSide:A,onArrowChange:C,arrowX:R,arrowY:K,shouldHideArrow:H,children:r.jsx(G.div,{"data-side":A,"data-align":ce,...p,ref:N,style:{...p.style,animation:ae?void 0:"none"}})})})});$l.displayName=Oo;var Ul="PopperArrow",Ev={top:"bottom",right:"left",bottom:"top",left:"right"},Vl=l.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,o=Sv(Ul,s),c=Ev[o.placedSide];return r.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:r.jsx(jv,{...a,ref:n,style:{...a.style,display:"block"}})})});Vl.displayName=Ul;function Rv(e){return e!==null}var Pv=e=>({name:"transformOrigin",options:e,fn(t){var v,y,w;const{placement:n,rects:s,middlewareData:a}=t,c=((v=a.arrow)==null?void 0:v.centerOffset)!==0,i=c?0:e.arrowWidth,f=c?0:e.arrowHeight,[u,d]=Bl(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=a.arrow)==null?void 0:y.x)??0)+i/2,x=(((w=a.arrow)==null?void 0:w.y)??0)+f/2;let g="",p="";return u==="bottom"?(g=c?h:`${m}px`,p=`${-f}px`):u==="top"?(g=c?h:`${m}px`,p=`${s.floating.height+f}px`):u==="right"?(g=`${-f}px`,p=c?h:`${x}px`):u==="left"&&(g=`${s.floating.width+f}px`,p=c?h:`${x}px`),{data:{x:g,y:p}}}});function Bl(e){const[t,n="center"]=e.split("-");return[t,n]}var Do=zl,zs=Fl,zo=$l,Lo=Vl,kv="Portal",Dr=l.forwardRef((e,t)=>{var i;const{container:n,...s}=e,[a,o]=l.useState(!1);Re(()=>o(!0),[]);const c=n||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return c?uh.createPortal(r.jsx(G.div,{...s,ref:t}),c):null});Dr.displayName=kv;function Tv(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var Ge=e=>{const{present:t,children:n}=e,s=Av(t),a=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),o=de(s.ref,Mv(a));return typeof n=="function"||s.isPresent?l.cloneElement(a,{ref:o}):null};Ge.displayName="Presence";function Av(e){const[t,n]=l.useState(),s=l.useRef(null),a=l.useRef(e),o=l.useRef("none"),c=e?"mounted":"unmounted",[i,f]=Tv(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=Zr(s.current);o.current=i==="mounted"?u:"none"},[i]),Re(()=>{const u=s.current,d=a.current;if(d!==e){const m=o.current,x=Zr(u);e?f("MOUNT"):x==="none"||(u==null?void 0:u.display)==="none"?f("UNMOUNT"):f(d&&m!==x?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),Re(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=x=>{const p=Zr(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(f("ANIMATION_END"),!a.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},m=x=>{x.target===t&&(o.current=Zr(s.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function Zr(e){return(e==null?void 0:e.animationName)||"none"}function Mv(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _v=po[" useInsertionEffect ".trim().toString()]||Re;function Gt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[a,o,c]=Iv({defaultProp:t,onChange:n}),i=e!==void 0,f=i?e:a;{const d=l.useRef(e!==void 0);l.useEffect(()=>{const h=d.current;h!==i&&console.warn(`${s} is changing from ${h?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=i},[i,s])}const u=l.useCallback(d=>{var h;if(i){const m=Ov(d)?d(e):d;m!==e&&((h=c.current)==null||h.call(c,m))}else o(d)},[i,e,o,c]);return[f,u]}function Iv({defaultProp:e,onChange:t}){const[n,s]=l.useState(e),a=l.useRef(n),o=l.useRef(t);return _v(()=>{o.current=t},[t]),l.useEffect(()=>{var c;a.current!==n&&((c=o.current)==null||c.call(o,n),a.current=n)},[n,a]),[n,s,o]}function Ov(e){return typeof e=="function"}var Dv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},En=new WeakMap,Jr=new WeakMap,es={},ga=0,Kl=function(e){return e&&(e.host||Kl(e.parentNode))},zv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Kl(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Lv=function(e,t,n,s){var a=zv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var o=es[n],c=[],i=new Set,f=new Set(a),u=function(h){!h||i.has(h)||(i.add(h),u(h.parentNode))};a.forEach(u);var d=function(h){!h||f.has(h)||Array.prototype.forEach.call(h.children,function(m){if(i.has(m))d(m);else try{var x=m.getAttribute(s),g=x!==null&&x!=="false",p=(En.get(m)||0)+1,v=(o.get(m)||0)+1;En.set(m,p),o.set(m,v),c.push(m),p===1&&g&&Jr.set(m,!0),v===1&&m.setAttribute(n,"true"),g||m.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),i.clear(),ga++,function(){c.forEach(function(h){var m=En.get(h)-1,x=o.get(h)-1;En.set(h,m),o.set(h,x),m||(Jr.has(h)||h.removeAttribute(s),Jr.delete(h)),x||h.removeAttribute(n)}),ga--,ga||(En=new WeakMap,En=new WeakMap,Jr=new WeakMap,es={})}},Ls=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=Dv(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),Lv(s,a,n,"aria-hidden")):function(){return null}},ot=function(){return ot=Object.assign||function(t){for(var n,s=1,a=arguments.length;s<a;s++){n=arguments[s];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ot.apply(this,arguments)};function ql(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]]);return n}function Fv(e,t,n){if(n||arguments.length===2)for(var s=0,a=t.length,o;s<a;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}var ls="right-scroll-bar-position",ds="width-before-scroll-bar",$v="with-scroll-bars-hidden",Uv="--removed-body-scroll-bar-size";function va(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Vv(e,t){var n=l.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var a=n.value;a!==s&&(n.value=s,n.callback(s,a))}}}})[0];return n.callback=t,n.facade}var Bv=typeof window<"u"?l.useLayoutEffect:l.useEffect,Yi=new WeakMap;function Kv(e,t){var n=Vv(null,function(s){return e.forEach(function(a){return va(a,s)})});return Bv(function(){var s=Yi.get(n);if(s){var a=new Set(s),o=new Set(e),c=n.current;a.forEach(function(i){o.has(i)||va(i,null)}),o.forEach(function(i){a.has(i)||va(i,c)})}Yi.set(n,e)},[e]),n}function qv(e){return e}function Hv(e,t){t===void 0&&(t=qv);var n=[],s=!1,a={read:function(){if(s)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(o){var c=t(o,s);return n.push(c),function(){n=n.filter(function(i){return i!==c})}},assignSyncMedium:function(o){for(s=!0;n.length;){var c=n;n=[],c.forEach(o)}n={push:function(i){return o(i)},filter:function(){return n}}},assignMedium:function(o){s=!0;var c=[];if(n.length){var i=n;n=[],i.forEach(o),c=n}var f=function(){var d=c;c=[],d.forEach(o)},u=function(){return Promise.resolve().then(f)};u(),n={push:function(d){c.push(d),u()},filter:function(d){return c=c.filter(d),n}}}};return a}function Wv(e){e===void 0&&(e={});var t=Hv(null);return t.options=ot({async:!0,ssr:!1},e),t}var Hl=function(e){var t=e.sideCar,n=ql(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return l.createElement(s,ot({},n))};Hl.isSideCarExport=!0;function Gv(e,t){return e.useMedium(t),Hl}var Wl=Wv(),ya=function(){},Fs=l.forwardRef(function(e,t){var n=l.useRef(null),s=l.useState({onScrollCapture:ya,onWheelCapture:ya,onTouchMoveCapture:ya}),a=s[0],o=s[1],c=e.forwardProps,i=e.children,f=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,x=e.noRelative,g=e.noIsolation,p=e.inert,v=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,N=e.gapMode,j=ql(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,S=Kv([n,t]),E=ot(ot({},j),a);return l.createElement(l.Fragment,null,d&&l.createElement(C,{sideCar:Wl,removeScrollBar:u,shards:h,noRelative:x,noIsolation:g,inert:p,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:N}),c?l.cloneElement(l.Children.only(i),ot(ot({},E),{ref:S})):l.createElement(w,ot({},E,{className:f,ref:S}),i))});Fs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Fs.classNames={fullWidth:ds,zeroRight:ls};var Qv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Yv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Qv();return t&&e.setAttribute("nonce",t),e}function Xv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Zv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yv())&&(Xv(t,n),Zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},e0=function(){var e=Jv();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Gl=function(){var e=e0(),t=function(n){var s=n.styles,a=n.dynamic;return e(s,a),null};return t},t0={left:0,top:0,right:0,gap:0},ba=function(e){return parseInt(e||"",10)||0},n0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[ba(n),ba(s),ba(a)]},r0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return t0;var t=n0(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},s0=Gl(),In="data-scroll-locked",a0=function(e,t,n,s){var a=e.left,o=e.top,c=e.right,i=e.gap;return n===void 0&&(n="margin"),`
280
280
  .`.concat($v,` {
281
281
  overflow: hidden `).concat(s,`;
282
282
  padding-right: `).concat(i,"px ").concat(s,`;
@@ -294,19 +294,19 @@ var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(
294
294
  `),n==="padding"&&"padding-right: ".concat(i,"px ").concat(s,";")].filter(Boolean).join(""),`
295
295
  }
296
296
 
297
- .`).concat(cs,` {
297
+ .`).concat(ls,` {
298
298
  right: `).concat(i,"px ").concat(s,`;
299
299
  }
300
300
 
301
- .`).concat(ls,` {
301
+ .`).concat(ds,` {
302
302
  margin-right: `).concat(i,"px ").concat(s,`;
303
303
  }
304
304
 
305
- .`).concat(cs," .").concat(cs,` {
305
+ .`).concat(ls," .").concat(ls,` {
306
306
  right: 0 `).concat(s,`;
307
307
  }
308
308
 
309
- .`).concat(ls," .").concat(ls,` {
309
+ .`).concat(ds," .").concat(ds,` {
310
310
  margin-right: 0 `).concat(s,`;
311
311
  }
312
312
 
@@ -316,8 +316,8 @@ var fi=e=>{throw TypeError(e)};var oa=(e,t,n)=>t.has(e)||fi("Cannot "+n);var b=(
316
316
  `)},Xi=function(){var e=parseInt(document.body.getAttribute(In)||"0",10);return isFinite(e)?e:0},o0=function(){l.useEffect(function(){return document.body.setAttribute(In,(Xi()+1).toString()),function(){var e=Xi()-1;e<=0?document.body.removeAttribute(In):document.body.setAttribute(In,e.toString())}},[])},i0=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,a=s===void 0?"margin":s;o0();var o=l.useMemo(function(){return r0(a)},[a]);return l.createElement(s0,{styles:a0(o,!t,a,n?"":"!important")})},eo=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return eo=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{eo=!1}var Rn=eo?{passive:!1}:!1,c0=function(e){return e.tagName==="TEXTAREA"},Ql=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!c0(e)&&n[t]==="visible")},l0=function(e){return Ql(e,"overflowY")},d0=function(e){return Ql(e,"overflowX")},Zi=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Yl(e,s);if(a){var o=Xl(e,s),c=o[1],i=o[2];if(c>i)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},u0=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},f0=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Yl=function(e,t){return e==="v"?l0(t):d0(t)},Xl=function(e,t){return e==="v"?u0(t):f0(t)},h0=function(e,t){return e==="h"&&t==="rtl"?-1:1},m0=function(e,t,n,s,a){var o=h0(e,window.getComputedStyle(t).direction),c=o*s,i=n.target,f=t.contains(i),u=!1,d=c>0,h=0,m=0;do{if(!i)break;var x=Xl(e,i),g=x[0],p=x[1],v=x[2],y=p-v-o*g;(g||y)&&Yl(e,i)&&(h+=y,m+=g);var w=i.parentNode;i=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!f&&i!==document.body||f&&(t.contains(i)||t===i));return(d&&Math.abs(h)<1||!d&&Math.abs(m)<1)&&(u=!0),u},ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ji=function(e){return[e.deltaX,e.deltaY]},ec=function(e){return e&&"current"in e?e.current:e},p0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x0=function(e){return`
317
317
  .block-interactivity-`.concat(e,` {pointer-events: none;}
318
318
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
319
- `)},g0=0,Pn=[];function v0(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),a=l.useState(g0++)[0],o=l.useState(Gl)[0],c=l.useRef(e);l.useEffect(function(){c.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var p=Fv([e.lockRef.current],(e.shards||[]).map(ec),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var i=l.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!c.current.allowPinchZoom;var y=ns(p),w=n.current,N="deltaX"in p?p.deltaX:w[0]-y[0],j="deltaY"in p?p.deltaY:w[1]-y[1],C,S=p.target,E=Math.abs(N)>Math.abs(j)?"h":"v";if("touches"in p&&E==="h"&&S.type==="range")return!1;var k=window.getSelection(),z=k&&k.anchorNode,O=z?z===S||z.contains(S):!1;if(O)return!1;var U=Zi(E,S);if(!U)return!0;if(U?C=E:(C=E==="v"?"h":"v",U=Zi(E,S)),!U)return!1;if(!s.current&&"changedTouches"in p&&(N||j)&&(s.current=C),!C)return!0;var I=s.current||C;return m0(I,v,p,I==="h"?N:j)},[]),f=l.useCallback(function(p){var v=p;if(!(!Pn.length||Pn[Pn.length-1]!==o)){var y="deltaY"in v?Ji(v):ns(v),w=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&p0(C.delta,y)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var N=(c.current.shards||[]).map(ec).filter(Boolean).filter(function(C){return C.contains(v.target)}),j=N.length>0?i(v,N[0]):!c.current.noIsolation;j&&v.cancelable&&v.preventDefault()}}},[]),u=l.useCallback(function(p,v,y,w){var N={name:p,delta:v,target:y,should:w,shadowParent:y0(y)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(j){return j!==N})},1)},[]),d=l.useCallback(function(p){n.current=ns(p),s.current=void 0},[]),h=l.useCallback(function(p){u(p.type,Ji(p),p.target,i(p,e.lockRef.current))},[]),m=l.useCallback(function(p){u(p.type,ns(p),p.target,i(p,e.lockRef.current))},[]);l.useEffect(function(){return Pn.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",f,Rn),document.addEventListener("touchmove",f,Rn),document.addEventListener("touchstart",d,Rn),function(){Pn=Pn.filter(function(p){return p!==o}),document.removeEventListener("wheel",f,Rn),document.removeEventListener("touchmove",f,Rn),document.removeEventListener("touchstart",d,Rn)}},[]);var x=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(o,{styles:x0(a)}):null,x?l.createElement(i0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function y0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const b0=Gv(Wl,v0);var zr=l.forwardRef(function(e,t){return l.createElement(Ls,ot({},e,{ref:t,sideCar:b0}))});zr.classNames=Ls.classNames;var Fs="Popover",[Zl]=ut(Fs,[ar]),Lr=ar(),[w0,Zt]=Zl(Fs),Jl=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!1}=e,i=Lr(t),f=l.useRef(null),[u,d]=l.useState(!1),[h,m]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:Fs});return r.jsx(Do,{...i,children:r.jsx(w0,{scope:t,contentId:Ne(),triggerRef:f,open:h,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(x=>!x),[m]),hasCustomAnchor:u,onCustomAnchorAdd:l.useCallback(()=>d(!0),[]),onCustomAnchorRemove:l.useCallback(()=>d(!1),[]),modal:c,children:n})})};Jl.displayName=Fs;var ed="PopoverAnchor",j0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(ed,n),o=Lr(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=a;return l.useEffect(()=>(c(),()=>i()),[c,i]),r.jsx(Ds,{...o,...s,ref:t})});j0.displayName=ed;var td="PopoverTrigger",nd=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(td,n),o=Lr(n),c=de(t,a.triggerRef),i=r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":id(a.open),...s,ref:c,onClick:D(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:r.jsx(Ds,{asChild:!0,...o,children:i})});nd.displayName=td;var Fo="PopoverPortal",[N0,C0]=Zl(Fo,{forceMount:void 0}),rd=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=Zt(Fo,t);return r.jsx(N0,{scope:t,forceMount:n,children:r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:s})})})};rd.displayName=Fo;var Yn="PopoverContent",sd=l.forwardRef((e,t)=>{const n=C0(Yn,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=Zt(Yn,e.__scopePopover);return r.jsx(Ge,{present:s||o.open,children:o.modal?r.jsx(E0,{...a,ref:t}):r.jsx(R0,{...a,ref:t})})});sd.displayName=Yn;var S0=pn("PopoverContent.RemoveScroll"),E0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(null),a=de(t,s),o=l.useRef(!1);return l.useEffect(()=>{const c=s.current;if(c)return zs(c)},[]),r.jsx(zr,{as:S0,allowPinchZoom:!0,children:r.jsx(ad,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),o.current||(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,u=i.button===2||f;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:D(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),R0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(ad,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),ad=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onInteractOutside:d,...h}=e,m=Zt(Yn,n),x=Lr(n);return As(),r.jsx(Ir,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:d,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:r.jsx(zo,{"data-state":id(m.open),role:"dialog",id:m.contentId,...x,...h,ref:t,style:{...h.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)"}})})})}),od="PopoverClose",P0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(od,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});P0.displayName=od;var k0="PopoverArrow",T0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Lr(n);return r.jsx(Lo,{...a,...s,ref:t})});T0.displayName=k0;function id(e){return e?"open":"closed"}var A0=Jl,M0=nd,_0=rd,cd=sd;const I0=A0,O0=M0,ld=l.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>r.jsx(_0,{children:r.jsx(cd,{ref:a,align:t,sideOffset:n,className:T("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),...s})}));ld.displayName=cd.displayName;const tc=e=>{let t;const n=new Set,s=(u,d)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=d??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(x=>x(t,m))}},a=()=>t,i={setState:s,getState:a,getInitialState:()=>f,subscribe:u=>(n.add(u),()=>n.delete(u))},f=t=e(s,a,i);return i},D0=(e=>e?tc(e):tc),z0=e=>e;function L0(e,t=z0){const n=Xe.useSyncExternalStore(e.subscribe,Xe.useCallback(()=>t(e.getState()),[e,t]),Xe.useCallback(()=>t(e.getInitialState()),[e,t]));return Xe.useDebugValue(n),n}const nc=e=>{const t=D0(e),n=s=>L0(t,s);return Object.assign(n,t),n},$s=(e=>e?nc(e):nc),dd=$s(e=>({notifications:[],unreadCount:0,pushNotification:t=>{const n={...t,id:crypto.randomUUID(),at:new Date().toISOString(),read:!1};e(s=>({notifications:[n,...s.notifications].slice(0,50),unreadCount:s.unreadCount+1}))},markAllRead:()=>{e(t=>({notifications:t.notifications.map(n=>({...n,read:!0})),unreadCount:0}))},clearAll:()=>{e({notifications:[],unreadCount:0})}}));function Oe(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 F0(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function ht(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),a=Math.floor(s/1e3),o=Math.floor(a/60),c=Math.floor(o/60),i=Math.floor(c/24);return a<30?"just now":a<60?`${a}s ago`:o<60?`${o}m ago`:c<24?`${c}h ago`:i===1?"yesterday":i<7?`${i} days ago`:i<30?`${Math.floor(i/7)}w ago`:F0(e)}function $0({type:e}){return e==="error"?r.jsx(el,{className:"h-4 w-4 text-red-500"}):e==="warning"?r.jsx(gs,{className:"h-4 w-4 text-amber-500"}):r.jsx(Lp,{className:"h-4 w-4 text-blue-500"})}function U0(){const{notifications:e,unreadCount:t,markAllRead:n}=dd(),s=e.slice(0,10);return r.jsxs(I0,{children:[r.jsx(O0,{asChild:!0,children:r.jsxs(se,{variant:"ghost",size:"icon","aria-label":"Notifications",className:"relative text-zinc-500 hover:text-zinc-700",children:[r.jsx(Sp,{className:"h-4 w-4"}),t>0&&r.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})]})}),r.jsxs(ld,{align:"end",className:"w-80 p-0",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("span",{className:"text-sm font-semibold text-zinc-900",children:"Notifications"}),t>0&&r.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 font-medium",children:[r.jsx(St,{className:"h-3 w-3"}),"Mark all read"]})]}),r.jsx("div",{className:"max-h-80 overflow-y-auto",children:s.length===0?r.jsx("div",{className:"py-8 text-center text-sm text-zinc-400",children:"No notifications"}):s.map(a=>r.jsxs("div",{className:T("flex gap-3 border-b border-zinc-50 px-4 py-3 last:border-0",!a.read&&"bg-blue-50/30"),children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx($0,{type:a.type})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-zinc-900",children:a.title}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500 line-clamp-2",children:a.message}),r.jsx("p",{className:"mt-1 text-[10px] text-zinc-400",children:ht(a.at)})]}),!a.read&&r.jsx("div",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"})]},a.id))})]})]})}var rc=1,V0=.9,B0=.8,K0=.17,ba=.1,wa=.999,q0=.9999,H0=.99,W0=/[\\\/_+.#"@\[\(\{&]/,G0=/[\\\/_+.#"@\[\(\{&]/g,Q0=/[\s-]/,ud=/[\s-]/g;function to(e,t,n,s,a,o,c){if(o===t.length)return a===e.length?rc:H0;var i=`${a},${o}`;if(c[i]!==void 0)return c[i];for(var f=s.charAt(o),u=n.indexOf(f,a),d=0,h,m,x,g;u>=0;)h=to(e,t,n,s,u+1,o+1,c),h>d&&(u===a?h*=rc:W0.test(e.charAt(u-1))?(h*=B0,x=e.slice(a,u-1).match(G0),x&&a>0&&(h*=Math.pow(wa,x.length))):Q0.test(e.charAt(u-1))?(h*=V0,g=e.slice(a,u-1).match(ud),g&&a>0&&(h*=Math.pow(wa,g.length))):(h*=K0,a>0&&(h*=Math.pow(wa,u-a))),e.charAt(u)!==t.charAt(o)&&(h*=q0)),(h<ba&&n.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(u-1)!==s.charAt(o))&&(m=to(e,t,n,s,u+1,o+2,c),m*ba>h&&(h=m*ba)),h>d&&(d=h),u=n.indexOf(f,u+1);return c[i]=d,d}function sc(e){return e.toLowerCase().replace(ud," ")}function Y0(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,to(e,t,sc(e),sc(t),0,0,{})}var Us="Dialog",[fd]=ut(Us),[X0,tt]=fd(Us),hd=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!0}=e,i=l.useRef(null),f=l.useRef(null),[u,d]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:Us});return r.jsx(X0,{scope:t,triggerRef:i,contentRef:f,contentId:Ne(),titleId:Ne(),descriptionId:Ne(),open:u,onOpenChange:d,onOpenToggle:l.useCallback(()=>d(h=>!h),[d]),modal:c,children:n})};hd.displayName=Us;var md="DialogTrigger",Z0=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(md,n),o=de(t,a.triggerRef);return r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Vo(a.open),...s,ref:o,onClick:D(e.onClick,a.onOpenToggle)})});Z0.displayName=md;var $o="DialogPortal",[J0,pd]=fd($o,{forceMount:void 0}),xd=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:a}=e,o=tt($o,t);return r.jsx(J0,{scope:t,forceMount:n,children:l.Children.map(s,c=>r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:c})}))})};xd.displayName=$o;var js="DialogOverlay",gd=l.forwardRef((e,t)=>{const n=pd(js,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(js,e.__scopeDialog);return o.modal?r.jsx(Ge,{present:s||o.open,children:r.jsx(ty,{...a,ref:t})}):null});gd.displayName=js;var ey=pn("DialogOverlay.RemoveScroll"),ty=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(js,n);return r.jsx(zr,{as:ey,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(G.div,{"data-state":Vo(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),gn="DialogContent",vd=l.forwardRef((e,t)=>{const n=pd(gn,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(gn,e.__scopeDialog);return r.jsx(Ge,{present:s||o.open,children:o.modal?r.jsx(ny,{...a,ref:t}):r.jsx(ry,{...a,ref:t})})});vd.displayName=gn;var ny=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(null),a=de(t,n.contentRef,s);return l.useEffect(()=>{const o=s.current;if(o)return zs(o)},[]),r.jsx(yd,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,o=>{var c;o.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&o.preventDefault()}),onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault())})}),ry=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(yd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),yd=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,...c}=e,i=tt(gn,n),f=l.useRef(null),u=de(t,f);return As(),r.jsxs(r.Fragment,{children:[r.jsx(Ir,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(_r,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Vo(i.open),...c,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(sy,{titleId:i.titleId}),r.jsx(oy,{contentRef:f,descriptionId:i.descriptionId})]})]})}),Uo="DialogTitle",bd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Uo,n);return r.jsx(G.h2,{id:a.titleId,...s,ref:t})});bd.displayName=Uo;var wd="DialogDescription",jd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(wd,n);return r.jsx(G.p,{id:a.descriptionId,...s,ref:t})});jd.displayName=wd;var Nd="DialogClose",Cd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Nd,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});Cd.displayName=Nd;function Vo(e){return e?"open":"closed"}var Sd="DialogTitleWarning",[E1,Ed]=Hx(Sd,{contentName:gn,titleName:Uo,docsSlug:"dialog"}),sy=({titleId:e})=>{const t=Ed(Sd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
319
+ `)},g0=0,Pn=[];function v0(e){var t=l.useRef([]),n=l.useRef([0,0]),s=l.useRef(),a=l.useState(g0++)[0],o=l.useState(Gl)[0],c=l.useRef(e);l.useEffect(function(){c.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var p=Fv([e.lockRef.current],(e.shards||[]).map(ec),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var i=l.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!c.current.allowPinchZoom;var y=ns(p),w=n.current,N="deltaX"in p?p.deltaX:w[0]-y[0],j="deltaY"in p?p.deltaY:w[1]-y[1],C,S=p.target,E=Math.abs(N)>Math.abs(j)?"h":"v";if("touches"in p&&E==="h"&&S.type==="range")return!1;var k=window.getSelection(),z=k&&k.anchorNode,O=z?z===S||z.contains(S):!1;if(O)return!1;var U=Zi(E,S);if(!U)return!0;if(U?C=E:(C=E==="v"?"h":"v",U=Zi(E,S)),!U)return!1;if(!s.current&&"changedTouches"in p&&(N||j)&&(s.current=C),!C)return!0;var I=s.current||C;return m0(I,v,p,I==="h"?N:j)},[]),f=l.useCallback(function(p){var v=p;if(!(!Pn.length||Pn[Pn.length-1]!==o)){var y="deltaY"in v?Ji(v):ns(v),w=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&p0(C.delta,y)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var N=(c.current.shards||[]).map(ec).filter(Boolean).filter(function(C){return C.contains(v.target)}),j=N.length>0?i(v,N[0]):!c.current.noIsolation;j&&v.cancelable&&v.preventDefault()}}},[]),u=l.useCallback(function(p,v,y,w){var N={name:p,delta:v,target:y,should:w,shadowParent:y0(y)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(j){return j!==N})},1)},[]),d=l.useCallback(function(p){n.current=ns(p),s.current=void 0},[]),h=l.useCallback(function(p){u(p.type,Ji(p),p.target,i(p,e.lockRef.current))},[]),m=l.useCallback(function(p){u(p.type,ns(p),p.target,i(p,e.lockRef.current))},[]);l.useEffect(function(){return Pn.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",f,Rn),document.addEventListener("touchmove",f,Rn),document.addEventListener("touchstart",d,Rn),function(){Pn=Pn.filter(function(p){return p!==o}),document.removeEventListener("wheel",f,Rn),document.removeEventListener("touchmove",f,Rn),document.removeEventListener("touchstart",d,Rn)}},[]);var x=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(o,{styles:x0(a)}):null,x?l.createElement(i0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function y0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const b0=Gv(Wl,v0);var zr=l.forwardRef(function(e,t){return l.createElement(Fs,ot({},e,{ref:t,sideCar:b0}))});zr.classNames=Fs.classNames;var $s="Popover",[Zl]=ut($s,[ar]),Lr=ar(),[w0,Zt]=Zl($s),Jl=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!1}=e,i=Lr(t),f=l.useRef(null),[u,d]=l.useState(!1),[h,m]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:$s});return r.jsx(Do,{...i,children:r.jsx(w0,{scope:t,contentId:Ne(),triggerRef:f,open:h,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(x=>!x),[m]),hasCustomAnchor:u,onCustomAnchorAdd:l.useCallback(()=>d(!0),[]),onCustomAnchorRemove:l.useCallback(()=>d(!1),[]),modal:c,children:n})})};Jl.displayName=$s;var ed="PopoverAnchor",j0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(ed,n),o=Lr(n),{onCustomAnchorAdd:c,onCustomAnchorRemove:i}=a;return l.useEffect(()=>(c(),()=>i()),[c,i]),r.jsx(zs,{...o,...s,ref:t})});j0.displayName=ed;var td="PopoverTrigger",nd=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(td,n),o=Lr(n),c=de(t,a.triggerRef),i=r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":id(a.open),...s,ref:c,onClick:D(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:r.jsx(zs,{asChild:!0,...o,children:i})});nd.displayName=td;var Fo="PopoverPortal",[N0,C0]=Zl(Fo,{forceMount:void 0}),rd=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=Zt(Fo,t);return r.jsx(N0,{scope:t,forceMount:n,children:r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:s})})})};rd.displayName=Fo;var Yn="PopoverContent",sd=l.forwardRef((e,t)=>{const n=C0(Yn,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=Zt(Yn,e.__scopePopover);return r.jsx(Ge,{present:s||o.open,children:o.modal?r.jsx(E0,{...a,ref:t}):r.jsx(R0,{...a,ref:t})})});sd.displayName=Yn;var S0=pn("PopoverContent.RemoveScroll"),E0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(null),a=de(t,s),o=l.useRef(!1);return l.useEffect(()=>{const c=s.current;if(c)return Ls(c)},[]),r.jsx(zr,{as:S0,allowPinchZoom:!0,children:r.jsx(ad,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,c=>{var i;c.preventDefault(),o.current||(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,c=>{const i=c.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,u=i.button===2||f;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:D(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1})})})}),R0=l.forwardRef((e,t)=>{const n=Zt(Yn,e.__scopePopover),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(ad,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),ad=l.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onInteractOutside:d,...h}=e,m=Zt(Yn,n),x=Lr(n);return Ms(),r.jsx(Ir,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:c,onInteractOutside:d,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:r.jsx(zo,{"data-state":id(m.open),role:"dialog",id:m.contentId,...x,...h,ref:t,style:{...h.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)"}})})})}),od="PopoverClose",P0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Zt(od,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});P0.displayName=od;var k0="PopoverArrow",T0=l.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=Lr(n);return r.jsx(Lo,{...a,...s,ref:t})});T0.displayName=k0;function id(e){return e?"open":"closed"}var A0=Jl,M0=nd,_0=rd,cd=sd;const I0=A0,O0=M0,ld=l.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>r.jsx(_0,{children:r.jsx(cd,{ref:a,align:t,sideOffset:n,className:T("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),...s})}));ld.displayName=cd.displayName;const tc=e=>{let t;const n=new Set,s=(u,d)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=d??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(x=>x(t,m))}},a=()=>t,i={setState:s,getState:a,getInitialState:()=>f,subscribe:u=>(n.add(u),()=>n.delete(u))},f=t=e(s,a,i);return i},D0=(e=>e?tc(e):tc),z0=e=>e;function L0(e,t=z0){const n=Xe.useSyncExternalStore(e.subscribe,Xe.useCallback(()=>t(e.getState()),[e,t]),Xe.useCallback(()=>t(e.getInitialState()),[e,t]));return Xe.useDebugValue(n),n}const nc=e=>{const t=D0(e),n=s=>L0(t,s);return Object.assign(n,t),n},Us=(e=>e?nc(e):nc),dd=Us(e=>({notifications:[],unreadCount:0,pushNotification:t=>{const n={...t,id:crypto.randomUUID(),at:new Date().toISOString(),read:!1};e(s=>({notifications:[n,...s.notifications].slice(0,50),unreadCount:s.unreadCount+1}))},markAllRead:()=>{e(t=>({notifications:t.notifications.map(n=>({...n,read:!0})),unreadCount:0}))},clearAll:()=>{e({notifications:[],unreadCount:0})}}));function Oe(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 F0(e){const t=new Date(e);return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function ht(e){const t=new Date(e),s=new Date().getTime()-t.getTime(),a=Math.floor(s/1e3),o=Math.floor(a/60),c=Math.floor(o/60),i=Math.floor(c/24);return a<30?"just now":a<60?`${a}s ago`:o<60?`${o}m ago`:c<24?`${c}h ago`:i===1?"yesterday":i<7?`${i} days ago`:i<30?`${Math.floor(i/7)}w ago`:F0(e)}function $0({type:e}){return e==="error"?r.jsx(el,{className:"h-4 w-4 text-red-500"}):e==="warning"?r.jsx(vs,{className:"h-4 w-4 text-amber-500"}):r.jsx(Lp,{className:"h-4 w-4 text-blue-500"})}function U0(){const{notifications:e,unreadCount:t,markAllRead:n}=dd(),s=e.slice(0,10);return r.jsxs(I0,{children:[r.jsx(O0,{asChild:!0,children:r.jsxs(se,{variant:"ghost",size:"icon","aria-label":"Notifications",className:"relative text-zinc-500 hover:text-zinc-700",children:[r.jsx(Sp,{className:"h-4 w-4"}),t>0&&r.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})]})}),r.jsxs(ld,{align:"end",className:"w-80 p-0",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("span",{className:"text-sm font-semibold text-zinc-900",children:"Notifications"}),t>0&&r.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 font-medium",children:[r.jsx(St,{className:"h-3 w-3"}),"Mark all read"]})]}),r.jsx("div",{className:"max-h-80 overflow-y-auto",children:s.length===0?r.jsx("div",{className:"py-8 text-center text-sm text-zinc-400",children:"No notifications"}):s.map(a=>r.jsxs("div",{className:T("flex gap-3 border-b border-zinc-50 px-4 py-3 last:border-0",!a.read&&"bg-blue-50/30"),children:[r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx($0,{type:a.type})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-zinc-900",children:a.title}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500 line-clamp-2",children:a.message}),r.jsx("p",{className:"mt-1 text-[10px] text-zinc-400",children:ht(a.at)})]}),!a.read&&r.jsx("div",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"})]},a.id))})]})]})}var rc=1,V0=.9,B0=.8,K0=.17,wa=.1,ja=.999,q0=.9999,H0=.99,W0=/[\\\/_+.#"@\[\(\{&]/,G0=/[\\\/_+.#"@\[\(\{&]/g,Q0=/[\s-]/,ud=/[\s-]/g;function to(e,t,n,s,a,o,c){if(o===t.length)return a===e.length?rc:H0;var i=`${a},${o}`;if(c[i]!==void 0)return c[i];for(var f=s.charAt(o),u=n.indexOf(f,a),d=0,h,m,x,g;u>=0;)h=to(e,t,n,s,u+1,o+1,c),h>d&&(u===a?h*=rc:W0.test(e.charAt(u-1))?(h*=B0,x=e.slice(a,u-1).match(G0),x&&a>0&&(h*=Math.pow(ja,x.length))):Q0.test(e.charAt(u-1))?(h*=V0,g=e.slice(a,u-1).match(ud),g&&a>0&&(h*=Math.pow(ja,g.length))):(h*=K0,a>0&&(h*=Math.pow(ja,u-a))),e.charAt(u)!==t.charAt(o)&&(h*=q0)),(h<wa&&n.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(u-1)!==s.charAt(o))&&(m=to(e,t,n,s,u+1,o+2,c),m*wa>h&&(h=m*wa)),h>d&&(d=h),u=n.indexOf(f,u+1);return c[i]=d,d}function sc(e){return e.toLowerCase().replace(ud," ")}function Y0(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,to(e,t,sc(e),sc(t),0,0,{})}var Vs="Dialog",[fd]=ut(Vs),[X0,tt]=fd(Vs),hd=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:c=!0}=e,i=l.useRef(null),f=l.useRef(null),[u,d]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:Vs});return r.jsx(X0,{scope:t,triggerRef:i,contentRef:f,contentId:Ne(),titleId:Ne(),descriptionId:Ne(),open:u,onOpenChange:d,onOpenToggle:l.useCallback(()=>d(h=>!h),[d]),modal:c,children:n})};hd.displayName=Vs;var md="DialogTrigger",Z0=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(md,n),o=de(t,a.triggerRef);return r.jsx(G.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Vo(a.open),...s,ref:o,onClick:D(e.onClick,a.onOpenToggle)})});Z0.displayName=md;var $o="DialogPortal",[J0,pd]=fd($o,{forceMount:void 0}),xd=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:a}=e,o=tt($o,t);return r.jsx(J0,{scope:t,forceMount:n,children:l.Children.map(s,c=>r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:c})}))})};xd.displayName=$o;var Ns="DialogOverlay",gd=l.forwardRef((e,t)=>{const n=pd(Ns,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(Ns,e.__scopeDialog);return o.modal?r.jsx(Ge,{present:s||o.open,children:r.jsx(ty,{...a,ref:t})}):null});gd.displayName=Ns;var ey=pn("DialogOverlay.RemoveScroll"),ty=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Ns,n);return r.jsx(zr,{as:ey,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(G.div,{"data-state":Vo(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),gn="DialogContent",vd=l.forwardRef((e,t)=>{const n=pd(gn,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=tt(gn,e.__scopeDialog);return r.jsx(Ge,{present:s||o.open,children:o.modal?r.jsx(ny,{...a,ref:t}):r.jsx(ry,{...a,ref:t})})});vd.displayName=gn;var ny=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(null),a=de(t,n.contentRef,s);return l.useEffect(()=>{const o=s.current;if(o)return Ls(o)},[]),r.jsx(yd,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:D(e.onCloseAutoFocus,o=>{var c;o.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:D(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,i=c.button===0&&c.ctrlKey===!0;(c.button===2||i)&&o.preventDefault()}),onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault())})}),ry=l.forwardRef((e,t)=>{const n=tt(gn,e.__scopeDialog),s=l.useRef(!1),a=l.useRef(!1);return r.jsx(yd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var c,i;(c=e.onCloseAutoFocus)==null||c.call(e,o),o.defaultPrevented||(s.current||(i=n.triggerRef.current)==null||i.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var f,u;(f=e.onInteractOutside)==null||f.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=o.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),yd=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,...c}=e,i=tt(gn,n),f=l.useRef(null),u=de(t,f);return Ms(),r.jsxs(r.Fragment,{children:[r.jsx(Ir,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(_r,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Vo(i.open),...c,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(sy,{titleId:i.titleId}),r.jsx(oy,{contentRef:f,descriptionId:i.descriptionId})]})]})}),Uo="DialogTitle",bd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Uo,n);return r.jsx(G.h2,{id:a.titleId,...s,ref:t})});bd.displayName=Uo;var wd="DialogDescription",jd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(wd,n);return r.jsx(G.p,{id:a.descriptionId,...s,ref:t})});jd.displayName=wd;var Nd="DialogClose",Cd=l.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=tt(Nd,n);return r.jsx(G.button,{type:"button",...s,ref:t,onClick:D(e.onClick,()=>a.onOpenChange(!1))})});Cd.displayName=Nd;function Vo(e){return e?"open":"closed"}var Sd="DialogTitleWarning",[E1,Ed]=Hx(Sd,{contentName:gn,titleName:Uo,docsSlug:"dialog"}),sy=({titleId:e})=>{const t=Ed(Sd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
320
320
 
321
321
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
322
322
 
323
- 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},ay="DialogDescriptionWarning",oy=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ed(ay).contentName}}.`;return l.useEffect(()=>{var o;const a=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Bo=hd,Ko=xd,Vs=gd,Bs=vd,qo=bd,Ho=jd,Rd=Cd,iy=Symbol.for("react.lazy"),Ns=po[" use ".trim().toString()];function cy(e){return typeof e=="object"&&e!==null&&"then"in e}function Pd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===iy&&"_payload"in e&&cy(e._payload)}function ly(e){const t=dy(e),n=l.forwardRef((s,a)=>{let{children:o,...c}=s;Pd(o)&&typeof Ns=="function"&&(o=Ns(o._payload));const i=l.Children.toArray(o),f=i.find(fy);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function dy(e){const t=l.forwardRef((n,s)=>{let{children:a,...o}=n;if(Pd(a)&&typeof Ns=="function"&&(a=Ns(a._payload)),l.isValidElement(a)){const c=my(a),i=hy(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var uy=Symbol("radix.slottable");function fy(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===uy}function hy(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function my(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var py=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=py.reduce((e,t)=>{const n=ly(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),mr='[cmdk-group=""]',ja='[cmdk-group-items=""]',xy='[cmdk-group-heading=""]',kd='[cmdk-item=""]',ac=`${kd}:not([aria-disabled="true"])`,no="cmdk-item-select",Tn="data-value",gy=(e,t,n)=>Y0(e,t,n),Td=l.createContext(void 0),Fr=()=>l.useContext(Td),Ad=l.createContext(void 0),Wo=()=>l.useContext(Ad),Md=l.createContext(void 0),_d=l.forwardRef((e,t)=>{let n=An(()=>{var R,K;return{search:"",value:(K=(R=e.value)!=null?R:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=An(()=>new Set),a=An(()=>new Map),o=An(()=>new Map),c=An(()=>new Set),i=Id(e),{label:f,children:u,value:d,onValueChange:h,filter:m,shouldFilter:x,loop:g,disablePointerSelection:p=!1,vimBindings:v=!0,...y}=e,w=Ne(),N=Ne(),j=Ne(),C=l.useRef(null),S=Py();vn(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),vn(()=>{S(6,Q)},[]);let E=l.useMemo(()=>({subscribe:R=>(c.current.add(R),()=>c.current.delete(R)),snapshot:()=>n.current,setState:(R,K,H)=>{var L,J,M,Y;if(!Object.is(n.current[R],K)){if(n.current[R]=K,R==="search")I(),O(),S(1,U);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(j);X?X.focus():(L=document.getElementById(w))==null||L.focus()}if(S(7,()=>{var X;n.current.selectedItemId=(X=V())==null?void 0:X.id,E.emit()}),H||S(5,Q),((J=i.current)==null?void 0:J.value)!==void 0){let X=K??"";(Y=(M=i.current).onValueChange)==null||Y.call(M,X);return}}E.emit()}},emit:()=>{c.current.forEach(R=>R())}}),[]),k=l.useMemo(()=>({value:(R,K,H)=>{var L;K!==((L=o.current.get(R))==null?void 0:L.value)&&(o.current.set(R,{value:K,keywords:H}),n.current.filtered.items.set(R,z(K,H)),S(2,()=>{O(),E.emit()}))},item:(R,K)=>(s.current.add(R),K&&(a.current.has(K)?a.current.get(K).add(R):a.current.set(K,new Set([R]))),S(3,()=>{I(),O(),n.current.value||U(),E.emit()}),()=>{o.current.delete(R),s.current.delete(R),n.current.filtered.items.delete(R);let H=V();S(4,()=>{I(),(H==null?void 0:H.getAttribute("id"))===R&&U(),E.emit()})}),group:R=>(a.current.has(R)||a.current.set(R,new Set),()=>{o.current.delete(R),a.current.delete(R)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:w,inputId:j,labelId:N,listInnerRef:C}),[]);function z(R,K){var H,L;let J=(L=(H=i.current)==null?void 0:H.filter)!=null?L:gy;return R?J(R,n.current.search,K):0}function O(){if(!n.current.search||i.current.shouldFilter===!1)return;let R=n.current.filtered.items,K=[];n.current.filtered.groups.forEach(L=>{let J=a.current.get(L),M=0;J.forEach(Y=>{let X=R.get(Y);M=Math.max(X,M)}),K.push([L,M])});let H=C.current;Z().sort((L,J)=>{var M,Y;let X=L.getAttribute("id"),ie=J.getAttribute("id");return((M=R.get(ie))!=null?M:0)-((Y=R.get(X))!=null?Y:0)}).forEach(L=>{let J=L.closest(ja);J?J.appendChild(L.parentElement===J?L:L.closest(`${ja} > *`)):H.appendChild(L.parentElement===H?L:L.closest(`${ja} > *`))}),K.sort((L,J)=>J[1]-L[1]).forEach(L=>{var J;let M=(J=C.current)==null?void 0:J.querySelector(`${mr}[${Tn}="${encodeURIComponent(L[0])}"]`);M==null||M.parentElement.appendChild(M)})}function U(){let R=Z().find(H=>H.getAttribute("aria-disabled")!=="true"),K=R==null?void 0:R.getAttribute(Tn);E.setState("value",K||void 0)}function I(){var R,K,H,L;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let M of s.current){let Y=(K=(R=o.current.get(M))==null?void 0:R.value)!=null?K:"",X=(L=(H=o.current.get(M))==null?void 0:H.keywords)!=null?L:[],ie=z(Y,X);n.current.filtered.items.set(M,ie),ie>0&&J++}for(let[M,Y]of a.current)for(let X of Y)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=J}function Q(){var R,K,H;let L=V();L&&(((R=L.parentElement)==null?void 0:R.firstChild)===L&&((H=(K=L.closest(mr))==null?void 0:K.querySelector(xy))==null||H.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function V(){var R;return(R=C.current)==null?void 0:R.querySelector(`${kd}[aria-selected="true"]`)}function Z(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(ac))||[])}function B(R){let K=Z()[R];K&&E.setState("value",K.getAttribute(Tn))}function ae(R){var K;let H=V(),L=Z(),J=L.findIndex(Y=>Y===H),M=L[J+R];(K=i.current)!=null&&K.loop&&(M=J+R<0?L[L.length-1]:J+R===L.length?L[0]:L[J+R]),M&&E.setState("value",M.getAttribute(Tn))}function F(R){let K=V(),H=K==null?void 0:K.closest(mr),L;for(;H&&!L;)H=R>0?Ey(H,mr):Ry(H,mr),L=H==null?void 0:H.querySelector(ac);L?E.setState("value",L.getAttribute(Tn)):ae(R)}let A=()=>B(Z().length-1),ce=R=>{R.preventDefault(),R.metaKey?A():R.altKey?F(1):ae(1)},le=R=>{R.preventDefault(),R.metaKey?B(0):R.altKey?F(-1):ae(-1)};return l.createElement(Rt.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var K;(K=y.onKeyDown)==null||K.call(y,R);let H=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||H))switch(R.key){case"n":case"j":{v&&R.ctrlKey&&ce(R);break}case"ArrowDown":{ce(R);break}case"p":case"k":{v&&R.ctrlKey&&le(R);break}case"ArrowUp":{le(R);break}case"Home":{R.preventDefault(),B(0);break}case"End":{R.preventDefault(),A();break}case"Enter":{R.preventDefault();let L=V();if(L){let J=new Event(no);L.dispatchEvent(J)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:Ty},f),Ks(e,R=>l.createElement(Ad.Provider,{value:E},l.createElement(Td.Provider,{value:k},R))))}),vy=l.forwardRef((e,t)=>{var n,s;let a=Ne(),o=l.useRef(null),c=l.useContext(Md),i=Fr(),f=Id(e),u=(s=(n=f.current)==null?void 0:n.forceMount)!=null?s:c==null?void 0:c.forceMount;vn(()=>{if(!u)return i.item(a,c==null?void 0:c.id)},[u]);let d=Od(a,o,[e.value,e.children,o],e.keywords),h=Wo(),m=Qt(S=>S.value&&S.value===d.current),x=Qt(S=>u||i.filter()===!1?!0:S.search?S.filtered.items.get(a)>0:!0);l.useEffect(()=>{let S=o.current;if(!(!S||e.disabled))return S.addEventListener(no,g),()=>S.removeEventListener(no,g)},[x,e.onSelect,e.disabled]);function g(){var S,E;p(),(E=(S=f.current).onSelect)==null||E.call(S,d.current)}function p(){h.setState("value",d.current,!0)}if(!x)return null;let{disabled:v,value:y,onSelect:w,forceMount:N,keywords:j,...C}=e;return l.createElement(Rt.div,{ref:lt(o,t),...C,id:a,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||i.getDisablePointerSelection()?void 0:p,onClick:v?void 0:g},e.children)}),yy=l.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,c=Ne(),i=l.useRef(null),f=l.useRef(null),u=Ne(),d=Fr(),h=Qt(x=>a||d.filter()===!1?!0:x.search?x.filtered.groups.has(c):!0);vn(()=>d.group(c),[]),Od(c,i,[e.value,e.heading,f]);let m=l.useMemo(()=>({id:c,forceMount:a}),[a]);return l.createElement(Rt.div,{ref:lt(i,t),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Ks(e,x=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},l.createElement(Md.Provider,{value:m},x))))}),by=l.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=l.useRef(null),o=Qt(c=>!c.search);return!n&&!o?null:l.createElement(Rt.div,{ref:lt(a,t),...s,"cmdk-separator":"",role:"separator"})}),wy=l.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=Wo(),c=Qt(u=>u.search),i=Qt(u=>u.selectedItemId),f=Fr();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(Rt.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":i,id:f.inputId,type:"text",value:a?e.value:c,onChange:u=>{a||o.setState("search",u.target.value),n==null||n(u.target.value)}})}),jy=l.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=l.useRef(null),c=l.useRef(null),i=Qt(u=>u.selectedItemId),f=Fr();return l.useEffect(()=>{if(c.current&&o.current){let u=c.current,d=o.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let x=u.offsetHeight;d.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(h),m.unobserve(u)}}},[]),l.createElement(Rt.div,{ref:lt(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":s,id:f.listId},Ks(e,u=>l.createElement("div",{ref:lt(c,f.listInnerRef),"cmdk-list-sizer":""},u)))}),Ny=l.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:c,...i}=e;return l.createElement(Bo,{open:n,onOpenChange:s},l.createElement(Ko,{container:c},l.createElement(Vs,{"cmdk-overlay":"",className:a}),l.createElement(Bs,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(_d,{ref:t,...i}))))}),Cy=l.forwardRef((e,t)=>Qt(n=>n.filtered.count===0)?l.createElement(Rt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sy=l.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return l.createElement(Rt.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Ks(e,c=>l.createElement("div",{"aria-hidden":!0},c)))}),De=Object.assign(_d,{List:jy,Item:vy,Input:wy,Group:yy,Separator:by,Dialog:Ny,Empty:Cy,Loading:Sy});function Ey(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ry(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Id(e){let t=l.useRef(e);return vn(()=>{t.current=e}),t}var vn=typeof window>"u"?l.useEffect:l.useLayoutEffect;function An(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Qt(e){let t=Wo(),n=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,n,n)}function Od(e,t,n,s=[]){let a=l.useRef(),o=Fr();return vn(()=>{var c;let i=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():a.current}})(),f=s.map(u=>u.trim());o.value(e,i,f),(c=t.current)==null||c.setAttribute(Tn,i),a.current=i}),a}var Py=()=>{let[e,t]=l.useState(),n=An(()=>new Map);return vn(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function ky(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(ky(t),{ref:t.ref},n(t.props.children)):n(t)}var Ty={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const qs=Bo,Ay=Ko,Dd=l.forwardRef(({className:e,...t},n)=>r.jsx(Vs,{ref:n,className:T("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}));Dd.displayName=Vs.displayName;const $r=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ay,{children:[r.jsx(Dd,{}),r.jsxs(Bs,{ref:s,className:T("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,r.jsxs(Rd,{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:[r.jsx(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$r.displayName=Bs.displayName;const Hs=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-1.5 text-left",e),...t});Hs.displayName="DialogHeader";const Ws=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ws.displayName="DialogFooter";const Ur=l.forwardRef(({className:e,...t},n)=>r.jsx(qo,{ref:n,className:T("text-lg font-semibold leading-none tracking-tight",e),...t}));Ur.displayName=qo.displayName;const My=l.forwardRef(({className:e,...t},n)=>r.jsx(Ho,{ref:n,className:T("text-sm text-zinc-500",e),...t}));My.displayName=Ho.displayName;const zd=l.forwardRef(({className:e,...t},n)=>r.jsx(De,{ref:n,className:T("flex h-full w-full flex-col overflow-hidden rounded-md bg-white text-zinc-900",e),...t}));zd.displayName=De.displayName;const Ld=l.forwardRef(({className:e,...t},n)=>r.jsxs("div",{className:"flex items-center border-b border-zinc-200 px-3","cmdk-input-wrapper":"",children:[r.jsx(tr,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(De.Input,{ref:n,className:T("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})]}));Ld.displayName=De.Input.displayName;const Fd=l.forwardRef(({className:e,...t},n)=>r.jsx(De.List,{ref:n,className:T("max-h-[400px] overflow-y-auto overflow-x-hidden",e),...t}));Fd.displayName=De.List.displayName;const $d=l.forwardRef((e,t)=>r.jsx(De.Empty,{ref:t,className:"py-6 text-center text-sm text-zinc-500",...e}));$d.displayName=De.Empty.displayName;const ds=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Group,{ref:n,className:T("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}));ds.displayName=De.Group.displayName;const ro=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Separator,{ref:n,className:T("-mx-1 h-px bg-zinc-100",e),...t}));ro.displayName=De.Separator.displayName;const us=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Item,{ref:n,className:T("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}));us.displayName=De.Item.displayName;function Go(e){const t=e+"CollectionProvider",[n,s]=ut(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=p=>{const{scope:v,children:y}=p,w=Xe.useRef(null),N=Xe.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:N,collectionRef:w,children:y})};c.displayName=t;const i=e+"CollectionSlot",f=pn(i),u=Xe.forwardRef((p,v)=>{const{scope:y,children:w}=p,N=o(i,y),j=de(v,N.collectionRef);return r.jsx(f,{ref:j,children:w})});u.displayName=i;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=pn(d),x=Xe.forwardRef((p,v)=>{const{scope:y,children:w,...N}=p,j=Xe.useRef(null),C=de(v,j),S=o(d,y);return Xe.useEffect(()=>(S.itemMap.set(j,{ref:j,...N}),()=>void S.itemMap.delete(j))),r.jsx(m,{[h]:"",ref:C,children:w})});x.displayName=d;function g(p){const v=o(e+"CollectionConsumer",p);return Xe.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const N=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((S,E)=>N.indexOf(S.ref.current)-N.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:u,ItemSlot:x},g,s]}var _y=l.createContext(void 0);function Gs(e){const t=l.useContext(_y);return e||t||"ltr"}var Na="rovingFocusGroup.onEntryFocus",Iy={bubbles:!1,cancelable:!0},Vr="RovingFocusGroup",[so,Ud,Oy]=Go(Vr),[Dy,Qs]=ut(Vr,[Oy]),[zy,Ly]=Dy(Vr),Vd=l.forwardRef((e,t)=>r.jsx(so.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(so.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Fy,{...e,ref:t})})}));Vd.displayName=Vr;var Fy=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:f,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=e,m=l.useRef(null),x=de(t,m),g=Gs(o),[p,v]=Gt({prop:c,defaultProp:i??null,onChange:f,caller:Vr}),[y,w]=l.useState(!1),N=dt(u),j=Ud(n),C=l.useRef(!1),[S,E]=l.useState(0);return l.useEffect(()=>{const k=m.current;if(k)return k.addEventListener(Na,N),()=>k.removeEventListener(Na,N)},[N]),r.jsx(zy,{scope:n,orientation:s,dir:g,loop:a,currentTabStopId:p,onItemFocus:l.useCallback(k=>v(k),[v]),onItemShiftTab:l.useCallback(()=>w(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(k=>k+1),[]),onFocusableItemRemove:l.useCallback(()=>E(k=>k-1),[]),children:r.jsx(G.div,{tabIndex:y||S===0?-1:0,"data-orientation":s,...h,ref:x,style:{outline:"none",...e.style},onMouseDown:D(e.onMouseDown,()=>{C.current=!0}),onFocus:D(e.onFocus,k=>{const z=!C.current;if(k.target===k.currentTarget&&z&&!y){const O=new CustomEvent(Na,Iy);if(k.currentTarget.dispatchEvent(O),!O.defaultPrevented){const U=j().filter(B=>B.focusable),I=U.find(B=>B.active),Q=U.find(B=>B.id===p),Z=[I,Q,...U].filter(Boolean).map(B=>B.ref.current);qd(Z,d)}}C.current=!1}),onBlur:D(e.onBlur,()=>w(!1))})})}),Bd="RovingFocusGroupItem",Kd=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:o,children:c,...i}=e,f=Ne(),u=o||f,d=Ly(Bd,n),h=d.currentTabStopId===u,m=Ud(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=d;return l.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(so.ItemSlot,{scope:n,id:u,focusable:s,active:a,children:r.jsx(G.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...i,ref:t,onMouseDown:D(e.onMouseDown,v=>{s?d.onItemFocus(u):v.preventDefault()}),onFocus:D(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:D(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Vy(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let N=m().filter(j=>j.focusable).map(j=>j.ref.current);if(y==="last")N.reverse();else if(y==="prev"||y==="next"){y==="prev"&&N.reverse();const j=N.indexOf(v.currentTarget);N=d.loop?By(N,j+1):N.slice(j+1)}setTimeout(()=>qd(N))}}),children:typeof c=="function"?c({isCurrentTabStop:h,hasTabStop:p!=null}):c})})});Kd.displayName=Bd;var $y={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Uy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Vy(e,t,n){const s=Uy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return $y[s]}function qd(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function By(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Hd=Vd,Wd=Kd,Ys="Tabs",[Ky]=ut(Ys,[Qs]),Gd=Qs(),[qy,Qo]=Ky(Ys),Qd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:o,orientation:c="horizontal",dir:i,activationMode:f="automatic",...u}=e,d=Gs(i),[h,m]=Gt({prop:s,onChange:a,defaultProp:o??"",caller:Ys});return r.jsx(qy,{scope:n,baseId:Ne(),value:h,onValueChange:m,orientation:c,dir:d,activationMode:f,children:r.jsx(G.div,{dir:d,"data-orientation":c,...u,ref:t})})});Qd.displayName=Ys;var Yd="TabsList",Xd=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,o=Qo(Yd,n),c=Gd(n);return r.jsx(Hd,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:s,children:r.jsx(G.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});Xd.displayName=Yd;var Zd="TabsTrigger",Jd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...o}=e,c=Qo(Zd,n),i=Gd(n),f=nu(c.baseId,s),u=ru(c.baseId,s),d=s===c.value;return r.jsx(Wd,{asChild:!0,...i,focusable:!a,active:d,children:r.jsx(G.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:f,...o,ref:t,onMouseDown:D(e.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?c.onValueChange(s):h.preventDefault()}),onKeyDown:D(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&c.onValueChange(s)}),onFocus:D(e.onFocus,()=>{const h=c.activationMode!=="manual";!d&&!a&&h&&c.onValueChange(s)})})})});Jd.displayName=Zd;var eu="TabsContent",tu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:o,...c}=e,i=Qo(eu,n),f=nu(i.baseId,s),u=ru(i.baseId,s),d=s===i.value,h=l.useRef(d);return l.useEffect(()=>{const m=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(Ge,{present:a||d,children:({present:m})=>r.jsx(G.div,{"data-state":d?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":f,hidden:!m,id:u,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:m&&o})})});tu.displayName=eu;function nu(e,t){return`${e}-trigger-${t}`}function ru(e,t){return`${e}-content-${t}`}var Hy=Qd,su=Xd,au=Jd,ou=tu;const Br=Hy,or=l.forwardRef(({className:e,...t},n)=>r.jsx(su,{ref:n,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-zinc-100 p-1 text-zinc-500",e),...t}));or.displayName=su.displayName;const Te=l.forwardRef(({className:e,...t},n)=>r.jsx(au,{ref:n,className:T("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}));Te.displayName=au.displayName;const Ue=l.forwardRef(({className:e,...t},n)=>r.jsx(ou,{ref:n,className:T("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}));Ue.displayName=ou.displayName;const Wy=/^\/[A-Za-z0-9/_.-]*$/,Ca=8e3;function Gy(e,t){var a;const n=[];for(const o of e)n.push({role:"user",content:o.question.slice(0,Ca)}),o.answer.trim()!==""&&n.push({role:"assistant",content:o.answer.slice(0,Ca)});n.push({role:"user",content:t.slice(0,Ca)});const s=n.slice(-40);for(;((a=s[0])==null?void 0:a.role)!=="user";)s.shift();return s}function rs(e){try{return JSON.parse(e.data)}catch{return}}let kn=null,Qy=1;const Yo=$s((e,t)=>{const n=(o,c)=>e(i=>({exchanges:i.exchanges.map(f=>f.id===o?{...f,...c(f)}:f)})),s=(o,c)=>{kn==null||kn.close(),kn=null,n(o,()=>c),e({busy:!1})},a=(o,c)=>{const i=new EventSource(`/api/admin/assistant/turns/${encodeURIComponent(c.turnId)}/stream?ticket=${encodeURIComponent(c.ticket)}`);kn=i;const f=()=>kn===i;i.addEventListener("text",u=>{const d=rs(u);f()&&d!==void 0&&n(o,h=>({answer:h.answer+d.delta}))}),i.addEventListener("tool",u=>{const d=rs(u);f()&&d!==void 0&&n(o,h=>({steps:[...h.steps,d]}))}),i.addEventListener("proposal",u=>{const d=rs(u);f()&&d!==void 0&&n(o,h=>({proposals:[...h.proposals,d]}))}),i.addEventListener("done",()=>{f()&&s(o,{state:"done"})}),i.addEventListener("error",u=>{if(!f())return;const d="data"in u?rs(u):void 0;s(o,{state:"error",error:d??{code:"assistant.disconnected",message:"The answer was cut off"}})})};return{exchanges:[],busy:!1,ask(o,c){const i=o.trim();if(i===""||t().busy)return;const f=Qy++,u=Gy(t().exchanges.filter(h=>!h.unavailable),i);e(h=>({busy:!0,exchanges:[...h.exchanges,{id:f,question:i,answer:"",state:"streaming",steps:[],proposals:[]}]}));const d=c.slice(0,200);W.post("/api/admin/assistant/turns",{messages:u,...Wy.test(d)&&{page:d}}).then(h=>{var m;((m=t().exchanges.find(x=>x.id===f))==null?void 0:m.state)==="streaming"&&a(f,h)}).catch(h=>{const m=h instanceof Ae?h.code:"assistant.failed";s(f,{state:"error",...m==="assistant.unavailable"&&{unavailable:!0},error:{code:m,message:h instanceof Ae?h.message:"The question could not be sent"}})})},stop(){const o=t().exchanges.find(c=>c.state==="streaming");o!==void 0&&s(o.id,{state:"stopped"})},updateProposal(o){e(c=>({exchanges:c.exchanges.map(i=>({...i,proposals:i.proposals.map(f=>f.id===o.id?o:f)}))}))}}}),Xo=$s(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(t=>({isOpen:!t.isOpen}))}));function me(e,t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:t,minimumFractionDigits:2}).format(e/100)}function Yy(e){const t=e.trim();if(!/^\d+(\.\d{1,2})?$/.test(t))return null;const[n="0",s=""]=t.split(".");return Number(n)*100+Number(s.padEnd(2,"0"))}function Xy(e,t){const n=e/100,s=Zy(t);return n>=1e6?`${s}${(n/1e6).toFixed(1)}M`:n>=1e3?`${s}${(n/1e3).toFixed(1)}k`:me(e,t)}function Zy(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}}const oc=120;function ic(e,t,n){if(e===null)return"none";if(t==="money"&&typeof e=="number")return me(e,n);const s=String(e);return s.length>oc?`${s.slice(0,oc)}…`:s}function Jy(e,t){const{label:n,kind:s,current:a,proposed:o}=e;return s==="collection"?`${n}: ${a??0} → ${o??0} items${e.changed===!0?", changed":""}`:`${n}: ${ic(a,s,t)} → ${ic(o,s,t)}`}const eb=e=>String(e.args[e.command==="inventory.adjust"?"variantId":"id"]??"");function iu({proposal:e,scope:t}){const n=e.status==="pending"&&lp.includes(e.command),{data:s}=ox(e.id,n),a=n?s==null?void 0:s.preview:void 0;if(a===void 0)return null;const{target:o,changes:c,currency:i}=a;return r.jsxs("div",{className:"space-y-1 text-xs",children:[r.jsx("p",{className:"font-medium break-words text-zinc-900","data-testid":P(t,"target",e.id),children:o===null?`Not found: ${eb(e)}`:o.label}),c.length>0&&r.jsx("ul",{className:"space-y-0.5 break-words text-zinc-700",children:c.map((f,u)=>r.jsx("li",{"data-testid":P(t,"change",e.id),children:Jy(f,i)},u))})]})}const cc={pending:{label:"Pending approval",style:"bg-amber-50 text-amber-700"},approved:{label:"Approved",style:"bg-blue-50 text-blue-700"},applied:{label:"Applied",style:"bg-green-50 text-green-700"},rejected:{label:"Rejected",style:"bg-zinc-100 text-zinc-600"},failed:{label:"Failed",style:"bg-red-50 text-red-700"}};function tb({proposal:e}){const t=ll(),n=dl(),s=Yo(m=>m.updateProposal),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,status:d}=e,h=async m=>{if(!a.current){a.current=!0,c(!0),f(null);try{s(await m())}catch(x){f(x instanceof Ae?x.message:"The proposal could not be decided.")}finally{a.current=!1,c(!1)}}};return r.jsxs("article",{className:"space-y-2 rounded-md border border-zinc-200 bg-white p-3","data-testid":P("assistant","proposal",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsx("p",{className:"font-mono text-xs font-semibold break-all text-zinc-900",children:e.command}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",cc[d].style),"data-testid":P("assistant","proposal","status",u),children:cc[d].label})]}),r.jsx(iu,{proposal:e,scope:"assistant"}),r.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-zinc-50 p-2 font-mono text-[11px] whitespace-pre-wrap break-all text-zinc-700",children:JSON.stringify(e.args,null,1)}),d==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>t.mutateAsync(u)),"data-testid":P("assistant","approve",u),children:[o?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>n.mutateAsync({id:u,reason:""})),"data-testid":P("assistant","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}function nb({exchange:e}){const t=Xo(a=>a.close),{state:n,error:s}=e;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"ml-auto w-fit max-w-[85%] rounded-lg bg-blue-600 px-3 py-2 text-sm whitespace-pre-wrap text-white","data-testid":P("assistant","message"),"data-role":"user",children:e.question}),r.jsxs("div",{className:"space-y-2","data-testid":P("assistant","message"),"data-role":"assistant",children:[e.steps.map((a,o)=>r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-zinc-500","data-testid":P("assistant","step"),"data-tool":a.name,"data-ok":String(a.ok),children:[a.ok?r.jsx(St,{className:"h-3 w-3 text-green-600"}):r.jsx(Yt,{className:"h-3 w-3 text-red-500"}),r.jsx("span",{className:"font-mono",children:a.title}),a.code!==void 0&&r.jsx("span",{className:"text-red-500",children:a.code})]},o)),e.proposals.map(a=>r.jsx(tb,{proposal:a},a.id)),e.unavailable===!0?r.jsxs("p",{className:"rounded-md bg-amber-50 p-3 text-sm text-amber-800","data-testid":P("assistant","unavailable"),children:["The assistant needs an AI provider that can call tools."," ",r.jsx(Ze,{to:"/settings",className:"font-medium underline",onClick:t,children:"Set one up in Settings"}),"."]}):r.jsxs("p",{className:"text-sm whitespace-pre-wrap text-zinc-800","data-testid":P("assistant","answer"),"data-state":n,children:[e.answer,n==="stopped"&&r.jsx("span",{className:"ml-1 text-xs text-zinc-400 italic",children:"(Stopped)"})]}),n==="streaming"&&e.answer===""&&r.jsx("p",{className:"text-xs text-zinc-400",children:"Thinking…"}),s!==void 0&&e.unavailable!==!0&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-red-600","data-testid":P("assistant","error"),"data-code":s.code,children:[r.jsx(el,{className:"h-3.5 w-3.5"}),s.message]})]})]})}function rb({draft:e,onDraftChange:t}){const{exchanges:n,busy:s,ask:a}=Yo(),{pathname:o}=fh(),c=l.useRef(null),i=l.useRef(null),f=n.at(-1);l.useEffect(()=>{var d;(d=i.current)==null||d.scrollIntoView({block:"end"})},[n.length,f==null?void 0:f.answer,f==null?void 0:f.steps.length,f==null?void 0:f.proposals.length]),l.useEffect(()=>{var d;s||(d=c.current)==null||d.focus()},[s]);const u=d=>{d.key!=="Enter"||d.nativeEvent.isComposing||(d.preventDefault(),!(s||e.trim()==="")&&(a(e,o),t("")))};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"max-h-[400px] min-h-24 space-y-4 overflow-y-auto px-4 py-3",children:[n.length===0&&r.jsxs("p",{className:"flex items-center gap-2 py-6 text-sm text-zinc-500",children:[r.jsx(Wa,{className:"h-4 w-4"}),"Ask about your store: orders, products, stock. A change it suggests waits for your approval."]}),n.map(d=>r.jsx(nb,{exchange:d},d.id)),r.jsx("div",{ref:i})]}),r.jsxs("div",{className:"flex items-center border-t border-zinc-200 px-3",children:[r.jsx(Wa,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx("input",{ref:c,className:"flex h-12 w-full bg-transparent py-3 text-sm outline-none placeholder:text-zinc-400 disabled:cursor-not-allowed disabled:opacity-50",placeholder:s?"Answering…":"Ask about your store, then press Enter",value:e,maxLength:8e3,disabled:s,onChange:d=>t(d.target.value),onKeyDown:u,"data-testid":P("assistant","input")})]})]})}function sb(e){return Ce({queryKey:["search",e],queryFn:()=>W.get("/api/admin/search",{q:e}),enabled:e.length>=2,staleTime:1e4})}function ab(e,t){const[n,s]=l.useState(e);return l.useEffect(()=>{const a=setTimeout(()=>s(e),t);return()=>clearTimeout(a)},[e,t]),n}function ob(){const{isOpen:e,close:t}=Xo(),n=Yo(g=>g.stop),s=Ct(),[a,o]=l.useState("search"),[c,i]=l.useState(""),[f,u]=l.useState(""),d=ab(c,300);l.useEffect(()=>{e||(n(),o("search"))},[e,n]);const h=g=>{if(!g.startsWith("?"))return i(g);i(""),u(g.slice(1)),o("ask")},{data:m}=sb(d),x=l.useCallback(g=>{t(),g()},[t]);return r.jsx(qs,{open:e,onOpenChange:g=>!g&&t(),children:r.jsxs($r,{className:"max-w-2xl gap-0 overflow-hidden p-0 shadow-2xl","aria-describedby":void 0,children:[r.jsx(Ur,{className:"sr-only",children:"Search or ask"}),r.jsxs(Br,{value:a,onValueChange:g=>o(g),children:[r.jsxs(or,{className:"mx-3 mt-3",children:[r.jsx(Te,{value:"search","data-testid":P("search","tab","search"),children:"Search"}),r.jsx(Te,{value:"ask","data-testid":P("search","tab","ask"),children:"Ask"})]}),r.jsx(Ue,{value:"search",className:"mt-0",children:r.jsxs(zd,{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:[r.jsx(Ld,{placeholder:"Search orders, products, customers... (? to ask)",value:c,onValueChange:h,"data-testid":P("search","input")}),r.jsxs(Fd,{"data-testid":P("search"),children:[r.jsx($d,{children:d.length<2?r.jsx("span",{className:"text-zinc-400",children:"Type at least 2 characters to search"}):r.jsxs("span",{children:['No results for "',d,'"']})}),(m==null?void 0:m.orders)&&m.orders.length>0&&r.jsx(ds,{heading:"Orders",children:m.orders.slice(0,5).map(g=>r.jsxs(us,{value:`order-${g.orderNumber}`,onSelect:()=>x(()=>s(`/orders/${g.orderNumber}`)),children:[r.jsx(Gn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"font-mono text-sm font-medium",children:["#",g.orderNumber]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))}),(m==null?void 0:m.products)&&m.products.length>0&&r.jsxs(r.Fragment,{children:[m.orders&&m.orders.length>0&&r.jsx(ro,{}),r.jsx(ds,{heading:"Products",children:m.products.slice(0,5).map(g=>r.jsxs(us,{value:`product-${g.id}`,onSelect:()=>x(()=>s(`/products/${g.slug}`)),children:[r.jsx(qt,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsx("span",{className:"text-sm font-medium truncate",children:g.name}),r.jsx("span",{className:"text-xs text-zinc-500 capitalize",children:g.status})]})]},g.id))})]}),(m==null?void 0:m.customers)&&m.customers.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(ro,{}),r.jsx(ds,{heading:"Customers",children:m.customers.slice(0,5).map(g=>r.jsxs(us,{value:`customer-${g.id}`,onSelect:()=>x(()=>s(`/customers/${g.id}`)),children:[r.jsx(So,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"text-sm font-medium",children:[g.firstName," ",g.lastName]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))})]})]})]})}),r.jsx(Ue,{value:"ask",className:"mt-0",children:r.jsx(rb,{draft:f,onDraftChange:u})})]})]})})}function ib(){const{open:e}=Xo();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]),r.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":P("search","trigger"),children:[r.jsx(tr,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:"Search"}),r.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:[r.jsx("span",{children:"⌘"}),"K"]})]})}const Zo=["orders","list"],nn=e=>e===void 0;function cu(e,t){return nn(e.status)||e.status===t.status}function cb(e,t){return cu(e,t)&&nn(e.q)&&nn(e.dateFrom)&&nn(e.dateTo)&&nn(e.customer)&&(nn(e.offset)||e.offset===0)&&(nn(e.sort)||e.sort==="createdAt:desc")}function lb(e,t){for(const n of e.getQueryCache().findAll({queryKey:Zo})){const s=n.queryKey[2]??{};if(!cu(s,t))continue;const a={queryKey:n.queryKey,exact:!0},o=n.state.fetchStatus==="fetching"?e.cancelQueries(a):void 0,c=e.getQueryData(n.queryKey),i=c!==void 0&&cb(s,t);if(i){const f=[t,...c.filter(u=>u.id!==t.id)];e.setQueryData(n.queryKey,f.slice(0,s.limit??f.length))}o?o.then(()=>e.invalidateQueries(a)):i||e.invalidateQueries(a)}}const db=[Zo,["orders","detail"],["dashboard"],["inventory","list"],["proposals"]];async function ub(e){await Promise.all(db.map(async t=>{await e.cancelQueries({queryKey:t}),e.invalidateQueries({queryKey:t})}))}function fb(e){const t=dd.getState().pushNotification;function n(s){switch(s.type){case"order.placed.v1":{const{order:a}=s.payload;lb(e,a),e.invalidateQueries({queryKey:["dashboard"]}),t({type:"info",title:"New Order",message:`Order #${a.orderNumber} placed by ${a.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:Zo}),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:a,currentQty:o,threshold:c}=s.payload;t({type:"warning",title:"Low Stock Alert",message:`Variant ${a} is running low: ${o} left (threshold ${c})`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.out_of_stock.v1":{t({type:"error",title:"Out of Stock",message:`Variant ${s.payload.variantId} is out of stock`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"payment.failed.v1":{const{orderId:a,reason:o}=s.payload;t({type:"error",title:"Payment Failed",message:`Payment failed for order ${a}: ${o}`});break}case"proposal.created.v1":{e.invalidateQueries({queryKey:["proposals"]}),t({type:"info",title:"Inbox",message:`Agent proposal: ${s.payload.command}`});break}case"proposal.approved.v1":case"proposal.rejected.v1":case"proposal.applied.v1":case"proposal.failed.v1":{e.invalidateQueries({queryKey:["proposals"]});break}case"adapter.error.v1":{const{adapterType:a,adapterName:o,error:c}=s.payload;t({type:"error",title:"Adapter Error",message:`${a} adapter ${o}: ${c.message}`});break}}}return function(a,o){n({type:a,payload:o})}}const jr=$s(e=>({events:[],connected:!1,setConnected:t=>e({connected:t}),pushEvent:(t,n)=>{const s={id:crypto.randomUUID(),type:t,label:n,at:new Date().toISOString()};e(a=>({events:[s,...a.events].slice(0,20)}))}}));function hb(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 lc(){const e=jr(t=>t.connected);return r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0","data-testid":P("topbar","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-2 w-2 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),r.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400",children:e?"Live":"Offline"})]})}function mb(){const e=jr(s=>s.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?r.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx(lc,{}),r.jsx("span",{className:"text-zinc-300",children:"—"}),r.jsx("span",{className:"text-zinc-400",children:"No recent events"})]}):r.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",ref:t,children:[r.jsx(lc,{}),r.jsx("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:n.map(s=>r.jsx("span",{className:T("flex shrink-0 items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium whitespace-nowrap",hb(s.type)),children:s.label},s.id))})]})}function pb({navOpen:e,onToggleNav:t}){return r.jsxs(r.Fragment,{children:[r.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:[r.jsx("button",{type:"button","data-testid":P("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:r.jsx(Vp,{className:"h-5 w-5"})}),r.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:r.jsx(Kx,{})}),r.jsx("div",{className:"mx-8 hidden flex-1 items-center justify-center overflow-hidden md:flex",children:r.jsx(mb,{})}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(ib,{}),r.jsx(U0,{})]})]}),r.jsx(ob,{})]})}const dc=[1e3,2e3,5e3,1e4,3e4];function xb(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"payload"in t)return t.payload}catch{}}function gb(e,t={}){let n=null,s=0,a=null,o=!1;async function c(){return(await W.post("/api/admin/events/ticket")).ticket}function i(){if(o)return;const u=dc[Math.min(s,dc.length-1)]??3e4;s++,a=setTimeout(()=>{f()},u)}async function f(){var u;if(!o)try{const d=await c();if(o)return;n=new EventSource(`/api/admin/events?ticket=${encodeURIComponent(d)}`),n.onopen=()=>{s=0},n.addEventListener("connected",()=>{var h;(h=t.onConnected)==null||h.call(t)});for(const h of ip)n.addEventListener(h,m=>{const x=xb(m.data);x!==void 0&&e(h,x)});n.onerror=()=>{var h;n==null||n.close(),n=null,!o&&((h=t.onDisconnected)==null||h.call(t),i())}}catch{if(o)return;(u=t.onDisconnected)==null||u.call(t),i()}}return{connect(){o=!1,f()},disconnect(){o=!0,a!==null&&(clearTimeout(a),a=null),n==null||n.close(),n=null}}}function vb(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"order.confirmation_resend_requested.v1":return"Confirmation resend queued";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 yb({children:e}){const t=ye(),n=l.useRef(null),s=jr(o=>o.pushEvent),a=jr(o=>o.setConnected);return l.useEffect(()=>{if(!xs())return;const o=fb(t),c=gb((i,f)=>{o(i,f),s(i,vb({type:i,payload:f}))},{onConnected:()=>{a(!0),ub(t)},onDisconnected:()=>a(!1)});return n.current=c,c.connect(),()=>{c.disconnect(),n.current=null,a(!1)}},[t,s,a]),r.jsx(r.Fragment,{children:e})}function bb(){const[e,t]=l.useState(!1);return r.jsx(yb,{children:r.jsxs("div",{className:"min-h-screen bg-zinc-100",children:[e&&r.jsx("div",{"aria-hidden":"true",className:"fixed inset-0 z-40 bg-zinc-950/50 md:hidden",onClick:()=>t(!1)}),r.jsx(Bx,{open:e,onClose:()=>t(!1)}),r.jsx(pb,{navOpen:e,onToggleNav:()=>t(n=>!n)}),r.jsx("main",{className:"md:ml-60 pt-14 min-h-screen",children:r.jsx("div",{className:"p-6",children:r.jsx(hh,{})})})]})})}const pe=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:T("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:s,...n}));pe.displayName="Input";var wb="Label",lu=l.forwardRef((e,t)=>r.jsx(Rt.label,{...e,ref:t,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));lu.displayName=wb;var du=lu;const jb=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ee=l.forwardRef(({className:e,...t},n)=>r.jsx(du,{ref:n,className:T(jb(),e),...t}));Ee.displayName=du.displayName;function Nb({size:e="md",className:t}){return r.jsx("div",{className:T("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 Cb(){const{login:e}=ol(),[t,n]=l.useState(""),[s,a]=l.useState(""),[o,c]=l.useState(null),[i,f]=l.useState(!1),u=async d=>{d.preventDefault(),c(null),f(!0);try{await e(t,s)}catch(h){c(h instanceof Error?h.message:"Login failed")}finally{f(!1)}};return r.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4",children:[r.jsx("div",{className:"pointer-events-none fixed inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #fff 1px, transparent 1px)",backgroundSize:"24px 24px"}}),r.jsxs("div",{className:"relative w-full max-w-sm",children:[r.jsxs("div",{className:"mb-8 flex flex-col items-center gap-3",children:[r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-blue-600 shadow-lg shadow-blue-500/20",children:r.jsx("span",{className:"text-xl font-bold text-white",children:"N"})}),r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-xl font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Admin Dashboard"})]})]}),r.jsxs("div",{className:"rounded-xl border border-zinc-800 bg-zinc-900 p-6 shadow-2xl",children:[r.jsx("h2",{className:"mb-1 text-base font-semibold text-zinc-100",children:"Sign in"}),r.jsx("p",{className:"mb-6 text-sm text-zinc-500",children:"Enter your admin credentials"}),r.jsxs("form",{onSubmit:d=>void u(d),"data-testid":P("login","form"),className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-zinc-300 text-xs",children:"Email"}),r.jsx(pe,{type:"email",value:t,onChange:d=>n(d.target.value),placeholder:"admin@yourstore.com",autoComplete:"email",required:!0,disabled:i,"data-testid":P("login","email"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-zinc-300 text-xs",children:"Password"}),r.jsx(pe,{type:"password",value:s,onChange:d=>a(d.target.value),placeholder:"••••••••",autoComplete:"current-password",required:!0,disabled:i,"data-testid":P("login","password"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),o&&r.jsx("div",{role:"alert","data-testid":P("login","error"),className:"rounded-md border border-red-800/50 bg-red-900/20 px-3 py-2 text-sm text-red-400",children:o}),r.jsx(se,{type:"submit",className:"w-full",disabled:i||!t||!s,"data-testid":P("login","submit"),children:i?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Nb,{size:"sm",className:"border-blue-200 border-t-white"}),"Signing in..."]}):"Sign in"})]})]}),r.jsx("p",{className:"mt-4 text-center text-xs text-zinc-600",children:"Nymbal Admin · Precision Workspace"})]})]})}function xe({className:e,...t}){return r.jsx("div",{className:T("animate-pulse rounded-md bg-zinc-200",e),...t})}const Sb={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"},Eb={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Part. Refunded"};function Xn({status:e,size:t="md",className:n,"data-testid":s}){return r.jsx("span",{"data-testid":s,className:T("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",Sb[e],n),children:Eb[e]})}function We({icon:e,title:t,description:n,action:s,className:a}){return r.jsxs("div",{className:T("flex flex-col items-center justify-center py-16 px-4 text-center",a),children:[e&&r.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-zinc-100 text-zinc-400",children:e}),r.jsx("h3",{className:"text-sm font-medium text-zinc-900",children:t}),n&&r.jsx("p",{className:"mt-1 text-sm text-zinc-500",children:n}),s&&r.jsx("div",{className:"mt-4",children:s})]})}function Rb(){return Ce({queryKey:["dashboard"],queryFn:()=>W.get("/api/admin/dashboard"),refetchInterval:6e4})}function Pb(){const e=jr(t=>t.connected);return r.jsxs("span",{className:T("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider",e?"bg-green-50 border-green-200 text-green-600":"bg-zinc-50 border-zinc-200 text-zinc-500"),"data-testid":P("dashboard","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-1.5 w-1.5 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),e?"Live":"Offline"]})}function Sa({icon:e,label:t,value:n,subtext:s,loading:a,color:o="blue"}){const c={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",violet:"bg-violet-50 text-violet-600"};return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsx("div",{className:T("flex h-9 w-9 items-center justify-center rounded-lg",c[o]),children:e}),r.jsx(Ga,{className:"h-4 w-4 text-zinc-300"})]}),a?r.jsxs(r.Fragment,{children:[r.jsx(xe,{className:"h-7 w-24 mb-1"}),r.jsx(xe,{className:"h-3.5 w-16"})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900",children:n}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:t}),s&&r.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:s})]})]})}function kb({search:e,lookup:t,checkout:n}){return[...e?["search"]:[],...t?["lookup"]:[],...n==="none"?[]:[`checkout ${n}`]]}function Tb({agents:e,loading:t}){return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5","data-testid":P("dashboard","agents"),children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-50 text-amber-600",children:r.jsx(Ep,{className:"h-4.5 w-4.5"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Agents"}),r.jsx("p",{className:"text-xs text-zinc-500",children:"Orders shopping agents brought, last 30 days"})]})]}),t||e===void 0?r.jsx(xe,{className:"h-16 w-full"}):r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900","data-testid":P("dashboard","agents","orders"),children:e.orders.count}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Agent orders"}),r.jsx("p",{className:"mt-2 font-mono text-sm text-zinc-900","data-testid":P("dashboard","agents","revenue"),"data-minor":e.orders.revenueMinor,children:me(e.orders.revenueMinor,e.currency)}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Revenue"})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"By agent"}),e.bySource.length===0?r.jsx("p",{className:"text-xs text-zinc-500",children:"No agent orders yet"}):r.jsx("ul",{className:"space-y-1 text-xs",children:e.bySource.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":P("dashboard","agents","source"),"data-source":n.source,"data-count":n.count,"data-minor":n.revenueMinor,children:[r.jsx("span",{className:"truncate text-zinc-700",children:n.source.slice(6)}),r.jsxs("span",{className:"shrink-0 font-mono text-zinc-500",children:[n.count," · ",me(n.revenueMinor,e.currency)]})]},n.source))})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Surfaces"}),r.jsxs("ul",{className:"space-y-1 text-xs text-zinc-700",children:[e.surfaces.map(n=>r.jsxs("li",{"data-testid":P("dashboard","agents","surface",n.name),children:[r.jsx("span",{className:"font-medium uppercase",children:n.name}),":"," ",kb(n.capabilities).join(", ")]},n.name)),r.jsxs("li",{children:[r.jsx("span",{className:"font-medium uppercase",children:"MCP"}),":"," ",e.mcp.enabled?`on, ${e.mcp.writes}`:"off"]})]}),e.profilePath!==null&&r.jsx("a",{href:e.profilePath,className:"mt-2 inline-block text-xs font-medium text-blue-600 hover:text-blue-700",children:"Agent profile →"})]})]})]})}function Ab(){var o,c;const{data:e}=Eo(),{data:t,isLoading:n}=Rb(),s=Ct(),a="GBP";return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:(e==null?void 0:e.storeName)??"Dashboard"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Today's performance at a glance"})]}),r.jsx(Pb,{})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsx(Sa,{icon:r.jsx(Gn,{className:"h-4.5 w-4.5"}),label:"Orders today",value:String((t==null?void 0:t.today.orderCount)??0),loading:n,color:"blue"}),r.jsx(Sa,{icon:r.jsx(Ip,{className:"h-4.5 w-4.5"}),label:"Revenue today",value:t?Xy(t.today.revenueMinor,a):"—",subtext:t?me(t.today.revenueMinor,a):void 0,loading:n,color:"green"}),r.jsx(Sa,{icon:r.jsx(al,{className:"h-4.5 w-4.5"}),label:"Items shipped",value:String((t==null?void 0:t.today.itemsShipped)??0),loading:n,color:"violet"})]}),r.jsx(Tb,{agents:t==null?void 0:t.agents,loading:n}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Recent Orders"}),r.jsx("button",{onClick:()=>s("/orders"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"View all →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:5}).map((i,f)=>r.jsx(xe,{className:"h-11 w-full"},f))}):(o=t==null?void 0:t.recentOrders)!=null&&o.length?r.jsx("div",{className:"overflow-x-auto",role:"region",tabIndex:0,"aria-label":"Recent orders","data-testid":P("dashboard","recent-orders"),children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"border-b border-zinc-100",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Order"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Total"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Time"})]})}),r.jsx("tbody",{children:t.recentOrders.map(i=>r.jsxs("tr",{className:"cursor-pointer border-b border-zinc-50 last:border-0 hover:bg-zinc-50 transition-colors",onClick:()=>s(`/orders/${i.orderNumber}`),children:[r.jsx("td",{className:"px-4 py-2.5",children:r.jsxs("span",{className:"font-mono text-sm font-medium text-blue-600",children:["#",i.orderNumber]})}),r.jsx("td",{className:"px-4 py-2.5 text-zinc-600 truncate max-w-[160px]",children:i.email}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx(Xn,{status:i.status,size:"sm"})}),r.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-sm text-zinc-700",children:me(i.totalMinor,i.currency)}),r.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-zinc-400",children:ht(i.createdAt)})]},i.id))})]})}):r.jsx(We,{icon:r.jsx(Gn,{className:"h-5 w-5"}),title:"No orders yet",description:"Orders will appear here as they come in."})]})}),r.jsx("div",{children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Low Stock"}),(t==null?void 0:t.lowStock)&&t.lowStock.length>0&&r.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})]}),r.jsx("button",{onClick:()=>s("/inventory"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"Manage →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:4}).map((i,f)=>r.jsx(xe,{className:"h-10 w-full"},f))}):(c=t==null?void 0:t.lowStock)!=null&&c.length?r.jsx("div",{className:"divide-y divide-zinc-50",children:t.lowStock.map(i=>r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-zinc-50 transition-colors",onClick:()=>s("/inventory"),children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-700",children:i.productName}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:i.sku})]}),r.jsxs("div",{className:"ml-3 text-right",children:[r.jsx("span",{className:T("font-mono text-sm font-semibold",i.status==="out_of_stock"?"text-red-600":"text-amber-600"),children:i.stock}),r.jsxs("p",{className:"text-[10px] text-zinc-400",children:["/",i.threshold]})]})]},i.variantId))}):r.jsxs("div",{className:"p-6 text-center",children:[r.jsx("div",{className:"mx-auto mb-2 flex h-8 w-8 items-center justify-center rounded-full bg-green-50",children:r.jsx(gs,{className:"h-4 w-4 text-green-500"})}),r.jsx("p",{className:"text-xs text-zinc-500",children:"All stock levels are healthy"})]})]})})]})]})}const wn=l.forwardRef(({className:e,...t},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:T("w-full caption-bottom text-sm",e),...t})}));wn.displayName="Table";const jn=l.forwardRef(({className:e,...t},n)=>r.jsx("thead",{ref:n,className:T("[&_tr]:border-b [&_tr]:border-zinc-200",e),...t}));jn.displayName="TableHeader";const Nn=l.forwardRef(({className:e,...t},n)=>r.jsx("tbody",{ref:n,className:T("[&_tr:last-child]:border-0",e),...t}));Nn.displayName="TableBody";const Mb=l.forwardRef(({className:e,...t},n)=>r.jsx("tfoot",{ref:n,className:T("border-t border-zinc-200 bg-zinc-50/50 font-medium [&>tr]:last:border-b-0",e),...t}));Mb.displayName="TableFooter";const Be=l.forwardRef(({className:e,...t},n)=>r.jsx("tr",{ref:n,className:T("border-b border-zinc-100 transition-colors hover:bg-zinc-50/60 data-[state=selected]:bg-blue-50",e),...t}));Be.displayName="TableRow";const ne=l.forwardRef(({className:e,...t},n)=>r.jsx("th",{ref:n,className:T("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}));ne.displayName="TableHead";const re=l.forwardRef(({className:e,...t},n)=>r.jsx("td",{ref:n,className:T("h-11 px-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));re.displayName="TableCell";const _b=l.forwardRef(({className:e,...t},n)=>r.jsx("caption",{ref:n,className:T("mt-4 text-sm text-zinc-500",e),...t}));_b.displayName="TableCaption";function uu(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 Xs="Checkbox",[Ib]=ut(Xs),[Ob,Jo]=Ib(Xs);function Db(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:c,name:i,onCheckedChange:f,required:u,value:d="on",internal_do_not_use_render:h}=e,[m,x]=Gt({prop:n,defaultProp:a??!1,onChange:f,caller:Xs}),[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useRef(!1),N=g?!!c||!!g.closest("form"):!0,j={checked:m,disabled:o,setChecked:x,control:g,setControl:p,name:i,form:c,value:d,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:Bt(a)?!1:a,isFormControl:N,bubbleInput:v,setBubbleInput:y};return r.jsx(Ob,{scope:t,...j,children:zb(h)?h(j):s})}var fu="CheckboxTrigger",hu=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:c,disabled:i,checked:f,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:m,isFormControl:x,bubbleInput:g}=Jo(fu,e),p=de(a,d),v=l.useRef(f);return l.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>h(v.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,h]),r.jsx(G.button,{type:"button",role:"checkbox","aria-checked":Bt(f)?"mixed":f,"aria-required":u,"data-state":vu(f),"data-disabled":i?"":void 0,disabled:i,value:c,...s,ref:p,onKeyDown:D(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:D(n,y=>{h(w=>Bt(w)?!0:!w),g&&x&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})})});hu.displayName=fu;var ei=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:c,disabled:i,value:f,onCheckedChange:u,form:d,...h}=e;return r.jsx(Db,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:i,required:c,onCheckedChange:u,name:s,form:d,value:f,internal_do_not_use_render:({isFormControl:m})=>r.jsxs(r.Fragment,{children:[r.jsx(hu,{...h,ref:t,__scopeCheckbox:n}),m&&r.jsx(gu,{__scopeCheckbox:n})]})})});ei.displayName=Xs;var mu="CheckboxIndicator",pu=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=Jo(mu,n);return r.jsx(Ge,{present:s||Bt(o.checked)||o.checked===!0,children:r.jsx(G.span,{"data-state":vu(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});pu.displayName=mu;var xu="CheckboxBubbleInput",gu=l.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:c,required:i,disabled:f,name:u,value:d,form:h,bubbleInput:m,setBubbleInput:x}=Jo(xu,e),g=de(n,x),p=uu(o),v=Il(s);l.useEffect(()=>{const w=m;if(!w)return;const N=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(N,"checked").set,S=!a.current;if(p!==o&&C){const E=new Event("click",{bubbles:S});w.indeterminate=Bt(o),C.call(w,Bt(o)?!1:o),w.dispatchEvent(E)}},[m,p,o,a]);const y=l.useRef(Bt(o)?!1:o);return r.jsx(G.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??y.current,required:i,disabled:f,name:u,value:d,form:h,...t,tabIndex:-1,ref:g,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});gu.displayName=xu;function zb(e){return typeof e=="function"}function Bt(e){return e==="indeterminate"}function vu(e){return Bt(e)?"indeterminate":e?"checked":"unchecked"}const ao=l.forwardRef(({className:e,...t},n)=>r.jsx(ei,{ref:n,className:T("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:r.jsx(pu,{className:T("flex items-center justify-center text-current"),children:r.jsx(St,{className:"h-3 w-3",strokeWidth:3})})}));ao.displayName=ei.displayName;var oo=["Enter"," "],Lb=["ArrowDown","PageUp","Home"],yu=["ArrowUp","PageDown","End"],Fb=[...Lb,...yu],$b={ltr:[...oo,"ArrowRight"],rtl:[...oo,"ArrowLeft"]},Ub={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Kr="Menu",[Nr,Vb,Bb]=Go(Kr),[Cn,bu]=ut(Kr,[Bb,ar,Qs]),Zs=ar(),wu=Qs(),[Kb,Sn]=Cn(Kr),[qb,qr]=Cn(Kr),ju=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:a,onOpenChange:o,modal:c=!0}=e,i=Zs(t),[f,u]=l.useState(null),d=l.useRef(!1),h=dt(o),m=Gs(a);return l.useEffect(()=>{const x=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),r.jsx(Do,{...i,children:r.jsx(Kb,{scope:t,open:n,onOpenChange:h,content:f,onContentChange:u,children:r.jsx(qb,{scope:t,onClose:l.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:c,children:s})})})};ju.displayName=Kr;var Hb="MenuAnchor",ti=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=Zs(n);return r.jsx(Ds,{...a,...s,ref:t})});ti.displayName=Hb;var ni="MenuPortal",[Wb,Nu]=Cn(ni,{forceMount:void 0}),Cu=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:a}=e,o=Sn(ni,t);return r.jsx(Wb,{scope:t,forceMount:n,children:r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:s})})})};Cu.displayName=ni;var He="MenuContent",[Gb,ri]=Cn(He),Su=l.forwardRef((e,t)=>{const n=Nu(He,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(He,e.__scopeMenu),c=qr(He,e.__scopeMenu);return r.jsx(Nr.Provider,{scope:e.__scopeMenu,children:r.jsx(Ge,{present:s||o.open,children:r.jsx(Nr.Slot,{scope:e.__scopeMenu,children:c.modal?r.jsx(Qb,{...a,ref:t}):r.jsx(Yb,{...a,ref:t})})})})}),Qb=l.forwardRef((e,t)=>{const n=Sn(He,e.__scopeMenu),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return zs(o)},[]),r.jsx(si,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yb=l.forwardRef((e,t)=>{const n=Sn(He,e.__scopeMenu);return r.jsx(si,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xb=pn("MenuContent.ScrollLock"),si=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:i,onEntryFocus:f,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,disableOutsideScroll:g,...p}=e,v=Sn(He,n),y=qr(He,n),w=Zs(n),N=wu(n),j=Vb(n),[C,S]=l.useState(null),E=l.useRef(null),k=de(t,E,v.onContentChange),z=l.useRef(0),O=l.useRef(""),U=l.useRef(0),I=l.useRef(null),Q=l.useRef("right"),V=l.useRef(0),Z=g?zr:l.Fragment,B=g?{as:Xb,allowPinchZoom:!0}:void 0,ae=A=>{var M,Y;const ce=O.current+A,le=j().filter(X=>!X.disabled),R=document.activeElement,K=(M=le.find(X=>X.ref.current===R))==null?void 0:M.textValue,H=le.map(X=>X.textValue),L=lw(H,ce,K),J=(Y=le.find(X=>X.textValue===L))==null?void 0:Y.ref.current;(function X(ie){O.current=ie,window.clearTimeout(z.current),ie!==""&&(z.current=window.setTimeout(()=>X(""),1e3))})(ce),J&&setTimeout(()=>J.focus())};l.useEffect(()=>()=>window.clearTimeout(z.current),[]),As();const F=l.useCallback(A=>{var le,R;return Q.current===((le=I.current)==null?void 0:le.side)&&uw(A,(R=I.current)==null?void 0:R.area)},[]);return r.jsx(Gb,{scope:n,searchRef:O,onItemEnter:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),onItemLeave:l.useCallback(A=>{var ce;F(A)||((ce=E.current)==null||ce.focus(),S(null))},[F]),onTriggerLeave:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),pointerGraceTimerRef:U,onPointerGraceIntentChange:l.useCallback(A=>{I.current=A},[]),children:r.jsx(Z,{...B,children:r.jsx(Ir,{asChild:!0,trapped:a,onMountAutoFocus:D(o,A=>{var ce;A.preventDefault(),(ce=E.current)==null||ce.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,children:r.jsx(Hd,{asChild:!0,...N,dir:y.dir,orientation:"vertical",loop:s,currentTabStopId:C,onCurrentTabStopIdChange:S,onEntryFocus:D(f,A=>{y.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(zo,{role:"menu","aria-orientation":"vertical","data-state":Uu(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...p,ref:k,style:{outline:"none",...p.style},onKeyDown:D(p.onKeyDown,A=>{const le=A.target.closest("[data-radix-menu-content]")===A.currentTarget,R=A.ctrlKey||A.altKey||A.metaKey,K=A.key.length===1;le&&(A.key==="Tab"&&A.preventDefault(),!R&&K&&ae(A.key));const H=E.current;if(A.target!==H||!Fb.includes(A.key))return;A.preventDefault();const J=j().filter(M=>!M.disabled).map(M=>M.ref.current);yu.includes(A.key)&&J.reverse(),iw(J)}),onBlur:D(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(z.current),O.current="")}),onPointerMove:D(e.onPointerMove,Cr(A=>{const ce=A.target,le=V.current!==A.clientX;if(A.currentTarget.contains(ce)&&le){const R=A.clientX>V.current?"right":"left";Q.current=R,V.current=A.clientX}}))})})})})})})});Su.displayName=He;var Zb="MenuGroup",ai=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"group",...s,ref:t})});ai.displayName=Zb;var Jb="MenuLabel",Eu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{...s,ref:t})});Eu.displayName=Jb;var Cs="MenuItem",uc="menu.itemSelect",Js=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...a}=e,o=l.useRef(null),c=qr(Cs,e.__scopeMenu),i=ri(Cs,e.__scopeMenu),f=de(t,o),u=l.useRef(!1),d=()=>{const h=o.current;if(!n&&h){const m=new CustomEvent(uc,{bubbles:!0,cancelable:!0});h.addEventListener(uc,x=>s==null?void 0:s(x),{once:!0}),vl(h,m),m.defaultPrevented?u.current=!1:c.onClose()}};return r.jsx(Ru,{...a,ref:f,disabled:n,onClick:D(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:D(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:D(e.onKeyDown,h=>{const m=i.searchRef.current!=="";n||m&&h.key===" "||oo.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Js.displayName=Cs;var Ru=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:a,...o}=e,c=ri(Cs,n),i=wu(n),f=l.useRef(null),u=de(t,f),[d,h]=l.useState(!1),[m,x]=l.useState("");return l.useEffect(()=>{const g=f.current;g&&x((g.textContent??"").trim())},[o.children]),r.jsx(Nr.ItemSlot,{scope:n,disabled:s,textValue:a??m,children:r.jsx(Wd,{asChild:!0,...i,focusable:!s,children:r.jsx(G.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...o,ref:u,onPointerMove:D(e.onPointerMove,Cr(g=>{s?c.onItemLeave(g):(c.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:D(e.onPointerLeave,Cr(g=>c.onItemLeave(g))),onFocus:D(e.onFocus,()=>h(!0)),onBlur:D(e.onBlur,()=>h(!1))})})})}),ew="MenuCheckboxItem",Pu=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...a}=e;return r.jsx(_u,{scope:e.__scopeMenu,checked:n,children:r.jsx(Js,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...a,ref:t,"data-state":ii(n),onSelect:D(a.onSelect,()=>s==null?void 0:s(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Pu.displayName=ew;var ku="MenuRadioGroup",[tw,nw]=Cn(ku,{value:void 0,onValueChange:()=>{}}),Tu=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...a}=e,o=dt(s);return r.jsx(tw,{scope:e.__scopeMenu,value:n,onValueChange:o,children:r.jsx(ai,{...a,ref:t})})});Tu.displayName=ku;var Au="MenuRadioItem",Mu=l.forwardRef((e,t)=>{const{value:n,...s}=e,a=nw(Au,e.__scopeMenu),o=n===a.value;return r.jsx(_u,{scope:e.__scopeMenu,checked:o,children:r.jsx(Js,{role:"menuitemradio","aria-checked":o,...s,ref:t,"data-state":ii(o),onSelect:D(s.onSelect,()=>{var c;return(c=a.onValueChange)==null?void 0:c.call(a,n)},{checkForDefaultPrevented:!1})})})});Mu.displayName=Au;var oi="MenuItemIndicator",[_u,rw]=Cn(oi,{checked:!1}),Iu=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...a}=e,o=rw(oi,n);return r.jsx(Ge,{present:s||Ss(o.checked)||o.checked===!0,children:r.jsx(G.span,{...a,ref:t,"data-state":ii(o.checked)})})});Iu.displayName=oi;var sw="MenuSeparator",Ou=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Ou.displayName=sw;var aw="MenuArrow",Du=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=Zs(n);return r.jsx(Lo,{...a,...s,ref:t})});Du.displayName=aw;var ow="MenuSub",[R1,zu]=Cn(ow),xr="MenuSubTrigger",Lu=l.forwardRef((e,t)=>{const n=Sn(xr,e.__scopeMenu),s=qr(xr,e.__scopeMenu),a=zu(xr,e.__scopeMenu),o=ri(xr,e.__scopeMenu),c=l.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:f}=o,u={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const h=i.current;return()=>{window.clearTimeout(h),f(null)}},[i,f]),r.jsx(ti,{asChild:!0,...u,children:r.jsx(Ru,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":Uu(n.open),...e,ref:lt(t,a.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:D(e.onPointerMove,Cr(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:D(e.onPointerLeave,Cr(h=>{var x,g;d();const m=(x=n.content)==null?void 0:x.getBoundingClientRect();if(m){const p=(g=n.content)==null?void 0:g.dataset.side,v=p==="right",y=v?-5:5,w=m[v?"left":"right"],N=m[v?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:N,y:m.top},{x:N,y:m.bottom},{x:w,y:m.bottom}],side:p}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:D(e.onKeyDown,h=>{var x;const m=o.searchRef.current!=="";e.disabled||m&&h.key===" "||$b[s.dir].includes(h.key)&&(n.onOpenChange(!0),(x=n.content)==null||x.focus(),h.preventDefault())})})})});Lu.displayName=xr;var Fu="MenuSubContent",$u=l.forwardRef((e,t)=>{const n=Nu(He,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(He,e.__scopeMenu),c=qr(He,e.__scopeMenu),i=zu(Fu,e.__scopeMenu),f=l.useRef(null),u=de(t,f);return r.jsx(Nr.Provider,{scope:e.__scopeMenu,children:r.jsx(Ge,{present:s||o.open,children:r.jsx(Nr.Slot,{scope:e.__scopeMenu,children:r.jsx(si,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;c.isUsingKeyboardRef.current&&((h=f.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:D(e.onFocusOutside,d=>{d.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:D(e.onEscapeKeyDown,d=>{c.onClose(),d.preventDefault()}),onKeyDown:D(e.onKeyDown,d=>{var x;const h=d.currentTarget.contains(d.target),m=Ub[c.dir].includes(d.key);h&&m&&(o.onOpenChange(!1),(x=i.trigger)==null||x.focus(),d.preventDefault())})})})})})});$u.displayName=Fu;function Uu(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ii(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function iw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function cw(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function lw(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=cw(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function dw(e,t){const{x:n,y:s}=e;let a=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const i=t[o],f=t[c],u=i.x,d=i.y,h=f.x,m=f.y;d>s!=m>s&&n<(h-u)*(s-d)/(m-d)+u&&(a=!a)}return a}function uw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return dw(n,t)}function Cr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var fw=ju,hw=ti,mw=Cu,pw=Su,xw=ai,gw=Eu,vw=Js,yw=Pu,bw=Tu,ww=Mu,jw=Iu,Nw=Ou,Cw=Du,Sw=Lu,Ew=$u,ea="DropdownMenu",[Rw]=ut(ea,[bu]),Me=bu(),[Pw,Vu]=Rw(ea),Bu=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:a,defaultOpen:o,onOpenChange:c,modal:i=!0}=e,f=Me(t),u=l.useRef(null),[d,h]=Gt({prop:a,defaultProp:o??!1,onChange:c,caller:ea});return r.jsx(Pw,{scope:t,triggerId:Ne(),triggerRef:u,contentId:Ne(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(m=>!m),[h]),modal:i,children:r.jsx(fw,{...f,open:d,onOpenChange:h,dir:s,modal:i,children:n})})};Bu.displayName=ea;var Ku="DropdownMenuTrigger",qu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...a}=e,o=Vu(Ku,n),c=Me(n);return r.jsx(hw,{asChild:!0,...c,children:r.jsx(G.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...a,ref:lt(t,o.triggerRef),onPointerDown:D(e.onPointerDown,i=>{!s&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:D(e.onKeyDown,i=>{s||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});qu.displayName=Ku;var kw="DropdownMenuPortal",Hu=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Me(t);return r.jsx(mw,{...s,...n})};Hu.displayName=kw;var Wu="DropdownMenuContent",Gu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Vu(Wu,n),o=Me(n),c=l.useRef(!1);return r.jsx(pw,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...s,ref:t,onCloseAutoFocus:D(e.onCloseAutoFocus,i=>{var f;c.current||(f=a.triggerRef.current)==null||f.focus(),c.current=!1,i.preventDefault()}),onInteractOutside:D(e.onInteractOutside,i=>{const f=i.detail.originalEvent,u=f.button===0&&f.ctrlKey===!0,d=f.button===2||u;(!a.modal||d)&&(c.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Gu.displayName=Wu;var Tw="DropdownMenuGroup",Aw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(xw,{...a,...s,ref:t})});Aw.displayName=Tw;var Mw="DropdownMenuLabel",Qu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(gw,{...a,...s,ref:t})});Qu.displayName=Mw;var _w="DropdownMenuItem",Yu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(vw,{...a,...s,ref:t})});Yu.displayName=_w;var Iw="DropdownMenuCheckboxItem",Xu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(yw,{...a,...s,ref:t})});Xu.displayName=Iw;var Ow="DropdownMenuRadioGroup",Dw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(bw,{...a,...s,ref:t})});Dw.displayName=Ow;var zw="DropdownMenuRadioItem",Zu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(ww,{...a,...s,ref:t})});Zu.displayName=zw;var Lw="DropdownMenuItemIndicator",Ju=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(jw,{...a,...s,ref:t})});Ju.displayName=Lw;var Fw="DropdownMenuSeparator",ef=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Nw,{...a,...s,ref:t})});ef.displayName=Fw;var $w="DropdownMenuArrow",Uw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Cw,{...a,...s,ref:t})});Uw.displayName=$w;var Vw="DropdownMenuSubTrigger",tf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Sw,{...a,...s,ref:t})});tf.displayName=Vw;var Bw="DropdownMenuSubContent",nf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Ew,{...a,...s,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)"}})});nf.displayName=Bw;var Kw=Bu,qw=qu,Hw=Hu,rf=Gu,sf=Qu,af=Yu,of=Xu,cf=Zu,lf=Ju,df=ef,uf=tf,ff=nf;const ci=Kw,li=qw,Ww=l.forwardRef(({className:e,inset:t,children:n,...s},a)=>r.jsxs(uf,{ref:a,className:T("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),...s,children:[n,r.jsx(Jc,{className:"ml-auto"})]}));Ww.displayName=uf.displayName;const Gw=l.forwardRef(({className:e,...t},n)=>r.jsx(ff,{ref:n,className:T("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}));Gw.displayName=ff.displayName;const ta=l.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(Hw,{children:r.jsx(rf,{ref:s,sideOffset:t,className:T("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})}));ta.displayName=rf.displayName;const bt=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(af,{ref:s,className:T("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}));bt.displayName=af.displayName;const Qw=l.forwardRef(({className:e,children:t,checked:n=!1,...s},a)=>r.jsxs(of,{ref:a,className:T("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,...s,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(lf,{children:r.jsx(St,{className:"h-4 w-4"})})}),t]}));Qw.displayName=of.displayName;const Yw=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(cf,{ref:s,className:T("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:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(lf,{children:r.jsx(Ap,{className:"h-2 w-2 fill-current"})})}),t]}));Yw.displayName=cf.displayName;const Xw=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(sf,{ref:s,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",t&&"pl-8",e),...n}));Xw.displayName=sf.displayName;const na=l.forwardRef(({className:e,...t},n)=>r.jsx(df,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));na.displayName=df.displayName;const Zw=[{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"}],Jw={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"};function ej(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),[o,c]=l.useState(new Set),{data:i,isLoading:f}=il({status:t==="all"?void 0:t,q:s||void 0,sort:"createdAt:desc",limit:100}),u=m=>{c(x=>{const g=new Set(x);return g.has(m)?g.delete(m):g.add(m),g})},d=()=>{i&&(o.size===i.length?c(new Set):c(new Set(i.map(m=>m.id))))},h=i?o.size===i.length&&i.length>0:!1;return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Orders"}),r.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} orders`:"Loading..."})]})}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:Zw.map(m=>r.jsx("button",{onClick:()=>n(m.value),className:T("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))}),r.jsxs("div",{className:"flex flex-1 items-center gap-2 sm:justify-end",children:[r.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search orders...",value:s,onChange:m=>a(m.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsxs(se,{variant:"outline",size:"sm",className:"gap-1.5",children:[r.jsx(Dp,{className:"h-3.5 w-3.5"}),"Filter"]})]})]}),o.size>0&&r.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-blue-200 bg-blue-50 px-4 py-2.5",children:[r.jsxs("span",{className:"text-sm font-medium text-blue-700",children:[o.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[r.jsxs(se,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-blue-200 text-blue-700 hover:bg-blue-100",children:[r.jsx(Pp,{className:"h-3.5 w-3.5"}),"Confirm All"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-red-200 text-red-600 hover:bg-red-50",children:[r.jsx(sl,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{className:"w-10 pl-4",children:r.jsx(ao,{checked:h,onCheckedChange:d,"aria-label":"Select all"})}),r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Customer"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Payment"}),r.jsx(ne,{className:"text-center",children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"}),r.jsx(ne,{className:"w-10",children:r.jsx("span",{className:"sr-only",children:"Actions"})})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Be,{"data-testid":P("orders","row",m.orderNumber),"data-state":o.has(m.id)?"selected":void 0,className:T("cursor-pointer",o.has(m.id)&&"bg-blue-50/50"),children:[r.jsx(re,{className:"pl-4",onClick:x=>x.stopPropagation(),children:r.jsx(ao,{checked:o.has(m.id),onCheckedChange:()=>u(m.id),"aria-label":`Select order ${m.orderNumber}`})}),r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:["#",m.orderNumber]}),r.jsx(re,{className:"text-zinc-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx("div",{className:"truncate max-w-[180px]",children:m.email})}),r.jsx(re,{onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx(Xn,{status:m.status})}),r.jsx(re,{className:"text-sm text-zinc-600",onClick:()=>e(`/orders/${m.orderNumber}`),"data-testid":P("orders","payment",m.orderNumber),children:Jw[am(m)]}),r.jsx(re,{className:"text-center text-zinc-500",onClick:()=>e(`/orders/${m.orderNumber}`),children:m.lineItems.length}),r.jsx(re,{className:"text-right font-mono text-sm",onClick:()=>e(`/orders/${m.orderNumber}`),children:me(m.totalMinor,m.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",onClick:()=>e(`/orders/${m.orderNumber}`),children:ht(m.createdAt)}),r.jsx(re,{onClick:x=>x.stopPropagation(),children:r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon","aria-label":`Actions for order ${m.orderNumber}`,className:"h-8 w-8 text-zinc-400",children:r.jsx(tl,{className:"h-4 w-4"})})}),r.jsxs(ta,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/orders/${m.orderNumber}`),children:"View details"}),r.jsx(na,{}),r.jsx(bt,{className:"text-red-600",children:"Cancel order"})]})]})})]},m.id))})]}):r.jsx(We,{icon:r.jsx(qt,{className:"h-5 w-5"}),title:"No orders found",description:s||t!=="all"?"Try adjusting your filters.":"Orders will appear here as they come in."})})]})}const tj={breadcrumb:()=>"Orders"};function fc(e,[t,n]){return Math.min(n,Math.max(t,e))}var hf=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"}),nj="VisuallyHidden",rj=l.forwardRef((e,t)=>r.jsx(G.span,{...e,ref:t,style:{...hf,...e.style}}));rj.displayName=nj;var sj=[" ","Enter","ArrowUp","ArrowDown"],aj=[" ","Enter"],yn="Select",[ra,sa,oj]=Go(yn),[ir]=ut(yn,[oj,ar]),aa=ar(),[ij,Jt]=ir(yn),[cj,lj]=ir(yn),mf=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:c,defaultValue:i,onValueChange:f,dir:u,name:d,autoComplete:h,disabled:m,required:x,form:g}=e,p=aa(t),[v,y]=l.useState(null),[w,N]=l.useState(null),[j,C]=l.useState(!1),S=Gs(u),[E,k]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:yn}),[z,O]=Gt({prop:c,defaultProp:i,onChange:f,caller:yn}),U=l.useRef(null),I=v?g||!!v.closest("form"):!0,[Q,V]=l.useState(new Set),Z=Array.from(Q).map(B=>B.props.value).join(";");return r.jsx(Do,{...p,children:r.jsxs(ij,{required:x,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:j,onValueNodeHasChildrenChange:C,contentId:Ne(),value:z,onValueChange:O,open:E,onOpenChange:k,dir:S,triggerPointerDownPosRef:U,disabled:m,children:[r.jsx(ra.Provider,{scope:t,children:r.jsx(cj,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(B=>{V(ae=>new Set(ae).add(B))},[]),onNativeOptionRemove:l.useCallback(B=>{V(ae=>{const F=new Set(ae);return F.delete(B),F})},[]),children:n})}),I?r.jsxs(Lf,{"aria-hidden":!0,required:x,tabIndex:-1,name:d,autoComplete:h,value:z,onChange:B=>O(B.target.value),disabled:m,form:g,children:[z===void 0?r.jsx("option",{value:""}):null,Array.from(Q)]},Z):null]})})};mf.displayName=yn;var pf="SelectTrigger",xf=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=aa(n),c=Jt(pf,n),i=c.disabled||s,f=de(t,c.onTriggerChange),u=sa(n),d=l.useRef("touch"),[h,m,x]=$f(p=>{const v=u().filter(N=>!N.disabled),y=v.find(N=>N.value===c.value),w=Uf(v,p,y);w!==void 0&&c.onValueChange(w.value)}),g=p=>{i||(c.onOpenChange(!0),x()),p&&(c.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(Ds,{asChild:!0,...o,children:r.jsx(G.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":Ff(c.value)?"":void 0,...a,ref:f,onClick:D(a.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&g(p)}),onPointerDown:D(a.onPointerDown,p=>{d.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:D(a.onKeyDown,p=>{const v=h.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&m(p.key),!(v&&p.key===" ")&&sj.includes(p.key)&&(g(),p.preventDefault())})})})});xf.displayName=pf;var gf="SelectValue",vf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:c="",...i}=e,f=Jt(gf,n),{onValueNodeHasChildrenChange:u}=f,d=o!==void 0,h=de(t,f.onValueNodeChange);return Re(()=>{u(d)},[u,d]),r.jsx(G.span,{...i,ref:h,style:{pointerEvents:"none"},children:Ff(f.value)?r.jsx(r.Fragment,{children:c}):o})});vf.displayName=gf;var dj="SelectIcon",yf=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return r.jsx(G.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});yf.displayName=dj;var uj="SelectPortal",bf=e=>r.jsx(Dr,{asChild:!0,...e});bf.displayName=uj;var bn="SelectContent",wf=l.forwardRef((e,t)=>{const n=Jt(bn,e.__scopeSelect),[s,a]=l.useState();if(Re(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?Rs.createPortal(r.jsx(jf,{scope:e.__scopeSelect,children:r.jsx(ra.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),o):null}return r.jsx(Nf,{...e,ref:t})});wf.displayName=bn;var Qe=10,[jf,en]=ir(bn),fj="SelectContentImpl",hj=pn("SelectContent.RemoveScroll"),Nf=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:c,side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v,...y}=e,w=Jt(bn,n),[N,j]=l.useState(null),[C,S]=l.useState(null),E=de(t,M=>j(M)),[k,z]=l.useState(null),[O,U]=l.useState(null),I=sa(n),[Q,V]=l.useState(!1),Z=l.useRef(!1);l.useEffect(()=>{if(N)return zs(N)},[N]),As();const B=l.useCallback(M=>{const[Y,...X]=I().map(he=>he.ref.current),[ie]=X.slice(-1),fe=document.activeElement;for(const he of M)if(he===fe||(he==null||he.scrollIntoView({block:"nearest"}),he===Y&&C&&(C.scrollTop=0),he===ie&&C&&(C.scrollTop=C.scrollHeight),he==null||he.focus(),document.activeElement!==fe))return},[I,C]),ae=l.useCallback(()=>B([k,N]),[B,k,N]);l.useEffect(()=>{Q&&ae()},[Q,ae]);const{onOpenChange:F,triggerPointerDownPosRef:A}=w;l.useEffect(()=>{if(N){let M={x:0,y:0};const Y=ie=>{var fe,he;M={x:Math.abs(Math.round(ie.pageX)-(((fe=A.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((he=A.current)==null?void 0:he.y)??0))}},X=ie=>{M.x<=10&&M.y<=10?ie.preventDefault():N.contains(ie.target)||F(!1),document.removeEventListener("pointermove",Y),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",X,{capture:!0})}}},[N,F,A]),l.useEffect(()=>{const M=()=>F(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[F]);const[ce,le]=$f(M=>{const Y=I().filter(fe=>!fe.disabled),X=Y.find(fe=>fe.ref.current===document.activeElement),ie=Uf(Y,M,X);ie&&setTimeout(()=>ie.ref.current.focus())}),R=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&(z(M),ie&&(Z.current=!0))},[w.value]),K=l.useCallback(()=>N==null?void 0:N.focus(),[N]),H=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&U(M)},[w.value]),L=s==="popper"?io:Cf,J=L===io?{side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(jf,{scope:n,content:N,viewport:C,onViewportChange:S,itemRefCallback:R,selectedItem:k,onItemLeave:K,itemTextRefCallback:H,focusSelectedItem:ae,selectedItemText:O,position:s,isPositioned:Q,searchRef:ce,children:r.jsx(zr,{as:hj,allowPinchZoom:!0,children:r.jsx(Ir,{asChild:!0,trapped:w.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:D(a,M=>{var Y;(Y=w.trigger)==null||Y.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:r.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:M=>M.preventDefault(),...y,...J,onPlaced:()=>V(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:D(y.onKeyDown,M=>{const Y=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Y&&M.key.length===1&&le(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let ie=I().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(M.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const fe=M.target,he=ie.indexOf(fe);ie=ie.slice(he+1)}setTimeout(()=>B(ie)),M.preventDefault()}})})})})})})});Nf.displayName=fj;var mj="SelectItemAlignedPosition",Cf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=Jt(bn,n),c=en(bn,n),[i,f]=l.useState(null),[u,d]=l.useState(null),h=de(t,E=>d(E)),m=sa(n),x=l.useRef(!1),g=l.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:y,focusSelectedItem:w}=c,N=l.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&p&&v&&y){const E=o.trigger.getBoundingClientRect(),k=u.getBoundingClientRect(),z=o.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(o.dir!=="rtl"){const fe=O.left-k.left,he=z.left-fe,ze=E.left-he,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Qe,dr=fc(he,[Qe,Math.max(Qe,lr-cr)]);i.style.minWidth=nt+"px",i.style.left=dr+"px"}else{const fe=k.right-O.right,he=window.innerWidth-z.right-fe,ze=window.innerWidth-E.right-he,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Qe,dr=fc(he,[Qe,Math.max(Qe,lr-cr)]);i.style.minWidth=nt+"px",i.style.right=dr+"px"}const U=m(),I=window.innerHeight-Qe*2,Q=p.scrollHeight,V=window.getComputedStyle(u),Z=parseInt(V.borderTopWidth,10),B=parseInt(V.paddingTop,10),ae=parseInt(V.borderBottomWidth,10),F=parseInt(V.paddingBottom,10),A=Z+B+Q+F+ae,ce=Math.min(v.offsetHeight*5,A),le=window.getComputedStyle(p),R=parseInt(le.paddingTop,10),K=parseInt(le.paddingBottom,10),H=E.top+E.height/2-Qe,L=I-H,J=v.offsetHeight/2,M=v.offsetTop+J,Y=Z+B+M,X=A-Y;if(Y<=H){const fe=U.length>0&&v===U[U.length-1].ref.current;i.style.bottom="0px";const he=u.clientHeight-p.offsetTop-p.offsetHeight,ze=Math.max(L,J+(fe?K:0)+he+ae),nt=Y+ze;i.style.height=nt+"px"}else{const fe=U.length>0&&v===U[0].ref.current;i.style.top="0px";const ze=Math.max(H,Z+p.offsetTop+(fe?R:0)+J)+X;i.style.height=ze+"px",p.scrollTop=Y-H+p.offsetTop}i.style.margin=`${Qe}px 0`,i.style.minHeight=ce+"px",i.style.maxHeight=I+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[m,o.trigger,o.valueNode,i,u,p,v,y,o.dir,s]);Re(()=>N(),[N]);const[j,C]=l.useState();Re(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const S=l.useCallback(E=>{E&&g.current===!0&&(N(),w==null||w(),g.current=!1)},[N,w]);return r.jsx(xj,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:x,onScrollButtonChange:S,children:r.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(G.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Cf.displayName=mj;var pj="SelectPopperPosition",io=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=Qe,...o}=e,c=aa(n);return r.jsx(zo,{...c,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});io.displayName=pj;var[xj,di]=ir(bn,{}),co="SelectViewport",Sf=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=en(co,n),c=di(co,n),i=de(t,o.onViewportChange),f=l.useRef(0);return r.jsxs(r.Fragment,{children:[r.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:s}),r.jsx(ra.Slot,{scope:n,children:r.jsx(G.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:D(a.onScroll,u=>{const d=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&h){const x=Math.abs(f.current-d.scrollTop);if(x>0){const g=window.innerHeight-Qe*2,p=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),y=Math.max(p,v);if(y<g){const w=y+x,N=Math.min(g,w),j=w-N;h.style.height=N+"px",h.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,h.style.justifyContent="flex-end")}}}f.current=d.scrollTop})})})]})});Sf.displayName=co;var Ef="SelectGroup",[gj,vj]=ir(Ef),yj=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=Ne();return r.jsx(gj,{scope:n,id:a,children:r.jsx(G.div,{role:"group","aria-labelledby":a,...s,ref:t})})});yj.displayName=Ef;var Rf="SelectLabel",Pf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=vj(Rf,n);return r.jsx(G.div,{id:a.id,...s,ref:t})});Pf.displayName=Rf;var Es="SelectItem",[bj,kf]=ir(Es),Tf=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...c}=e,i=Jt(Es,n),f=en(Es,n),u=i.value===s,[d,h]=l.useState(o??""),[m,x]=l.useState(!1),g=de(t,w=>{var N;return(N=f.itemRefCallback)==null?void 0:N.call(f,w,s,a)}),p=Ne(),v=l.useRef("touch"),y=()=>{a||(i.onValueChange(s),i.onOpenChange(!1))};if(s==="")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 r.jsx(bj,{scope:n,value:s,disabled:a,textId:p,isSelected:u,onItemTextChange:l.useCallback(w=>{h(N=>N||((w==null?void 0:w.textContent)??"").trim())},[]),children:r.jsx(ra.ItemSlot,{scope:n,value:s,disabled:a,textValue:d,children:r.jsx(G.div,{role:"option","aria-labelledby":p,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...c,ref:g,onFocus:D(c.onFocus,()=>x(!0)),onBlur:D(c.onBlur,()=>x(!1)),onClick:D(c.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:D(c.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:D(c.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:D(c.onPointerMove,w=>{var N;v.current=w.pointerType,a?(N=f.onItemLeave)==null||N.call(f):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:D(c.onPointerLeave,w=>{var N;w.currentTarget===document.activeElement&&((N=f.onItemLeave)==null||N.call(f))}),onKeyDown:D(c.onKeyDown,w=>{var j;((j=f.searchRef)==null?void 0:j.current)!==""&&w.key===" "||(aj.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Tf.displayName=Es;var gr="SelectItemText",Af=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,c=Jt(gr,n),i=en(gr,n),f=kf(gr,n),u=lj(gr,n),[d,h]=l.useState(null),m=de(t,y=>h(y),f.onItemTextChange,y=>{var w;return(w=i.itemTextRefCallback)==null?void 0:w.call(i,y,f.value,f.disabled)}),x=d==null?void 0:d.textContent,g=l.useMemo(()=>r.jsx("option",{value:f.value,disabled:f.disabled,children:x},f.value),[f.disabled,f.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=u;return Re(()=>(p(g),()=>v(g)),[p,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(G.span,{id:f.textId,...o,ref:m}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren?Rs.createPortal(o.children,c.valueNode):null]})});Af.displayName=gr;var Mf="SelectItemIndicator",_f=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return kf(Mf,n).isSelected?r.jsx(G.span,{"aria-hidden":!0,...s,ref:t}):null});_f.displayName=Mf;var lo="SelectScrollUpButton",If=l.forwardRef((e,t)=>{const n=en(lo,e.__scopeSelect),s=di(lo,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Re(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollTop>0;o(u)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Df,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop-f.offsetHeight)}}):null});If.displayName=lo;var uo="SelectScrollDownButton",Of=l.forwardRef((e,t)=>{const n=en(uo,e.__scopeSelect),s=di(uo,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Re(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollHeight-f.clientHeight,d=Math.ceil(f.scrollTop)<u;o(d)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Df,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop+f.offsetHeight)}}):null});Of.displayName=uo;var Df=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=en("SelectScrollButton",n),c=l.useRef(null),i=sa(n),f=l.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return l.useEffect(()=>()=>f(),[f]),Re(()=>{var d;const u=i().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[i]),r.jsx(G.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:D(a.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:D(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:D(a.onPointerLeave,()=>{f()})})}),wj="SelectSeparator",zf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(G.div,{"aria-hidden":!0,...s,ref:t})});zf.displayName=wj;var fo="SelectArrow",jj=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=aa(n),o=Jt(fo,n),c=en(fo,n);return o.open&&c.position==="popper"?r.jsx(Lo,{...a,...s,ref:t}):null});jj.displayName=fo;var Nj="SelectBubbleInput",Lf=l.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=l.useRef(null),o=de(s,a),c=uu(t);return l.useEffect(()=>{const i=a.current;if(!i)return;const f=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==t&&d){const h=new Event("change",{bubbles:!0});d.call(i,t),i.dispatchEvent(h)}},[c,t]),r.jsx(G.select,{...n,style:{...hf,...n.style},ref:o,defaultValue:t})});Lf.displayName=Nj;function Ff(e){return e===""||e===void 0}function $f(e){const t=dt(e),n=l.useRef(""),s=l.useRef(0),a=l.useCallback(c=>{const i=n.current+c;t(i),(function f(u){n.current=u,window.clearTimeout(s.current),u!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(i)},[t]),o=l.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function Uf(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=Cj(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function Cj(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Sj=mf,Vf=xf,Ej=vf,Rj=yf,Pj=bf,Bf=wf,kj=Sf,Kf=Pf,qf=Tf,Tj=Af,Aj=_f,Hf=If,Wf=Of,Gf=zf;const Sr=Sj,Er=Ej,Zn=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Vf,{ref:s,className:T("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,r.jsx(Rj,{asChild:!0,children:r.jsx(Zc,{className:"h-4 w-4 opacity-50 shrink-0"})})]}));Zn.displayName=Vf.displayName;const Qf=l.forwardRef(({className:e,...t},n)=>r.jsx(Hf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(kp,{className:"h-4 w-4"})}));Qf.displayName=Hf.displayName;const Yf=l.forwardRef(({className:e,...t},n)=>r.jsx(Wf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Zc,{className:"h-4 w-4"})}));Yf.displayName=Wf.displayName;const Jn=l.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>r.jsx(Pj,{children:r.jsxs(Bf,{ref:a,className:T("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,...s,children:[r.jsx(Qf,{}),r.jsx(kj,{className:T("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Yf,{})]})}));Jn.displayName=Bf.displayName;const Mj=l.forwardRef(({className:e,...t},n)=>r.jsx(Kf,{ref:n,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",e),...t}));Mj.displayName=Kf.displayName;const qe=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(qf,{ref:s,className:T("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:[r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Aj,{children:r.jsx(St,{className:"h-4 w-4"})})}),r.jsx(Tj,{children:t})]}));qe.displayName=qf.displayName;const _j=l.forwardRef(({className:e,...t},n)=>r.jsx(Gf,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));_j.displayName=Gf.displayName;function Xf({orderId:e,orderNumber:t,open:n,onOpenChange:s}){const[a,o]=l.useState(""),[c,i]=l.useState(""),[f,u]=l.useState(null),d=l.useRef(!1),[h,m]=l.useState(!1),x=ex();l.useEffect(()=>{n&&u(null)},[n]);const g=a.trim()!==""&&c.trim()!=="",p=()=>{o(""),i(""),u(null),s(!1)},v=async()=>{if(!(!g||d.current)){d.current=!0,m(!0),u(null);try{await x.mutateAsync({orderId:e,carrier:a.trim(),trackingNumber:c.trim()}),p()}catch(y){u(y instanceof Ae?y.message:"The order could not be shipped.")}finally{d.current=!1,m(!1)}}};return r.jsx(qs,{open:n,onOpenChange:y=>y?s(!0):p(),children:r.jsxs($r,{className:"max-w-md","data-testid":P("order","ship-dialog"),children:[r.jsx(Hs,{children:r.jsxs(Ur,{children:["Ship Order #",t]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-carrier",children:"Carrier"}),r.jsx(pe,{id:"ship-carrier",value:a,onChange:y=>o(y.target.value),"data-testid":P("order","ship-carrier")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-tracking",children:"Tracking number"}),r.jsx(pe,{id:"ship-tracking",value:c,onChange:y=>i(y.target.value),"data-testid":P("order","ship-tracking")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600","data-testid":P("order","ship-error"),children:f})]}),r.jsxs(Ws,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:p,"data-testid":P("order","ship-cancel"),children:"Cancel"}),r.jsx(se,{type:"button",onClick:()=>void v(),disabled:!g||h,"data-testid":P("order","ship-submit"),children:h?"Shipping...":"Ship order"})]})]})})}const ss="record-payment",Ea={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Partially Refunded"},Ij={confirmed:"confirm",processing:"process",delivered:"mark-delivered",cancelled:"cancel"};function Oj(e,t){return sm[e].filter(n=>n!=="refunded"&&n!=="partially_refunded"&&n!=="confirmed"&&!(n==="cancelled"&&t>0))}function Dj({orderId:e,currentStatus:t,orderNumber:n,capturedMinor:s}){const a=ye(),{mutateAsync:o,isPending:c}=Xp(),{mutateAsync:i,isPending:f}=cl(),[u,d]=l.useState(null),[h,m]=l.useState(null),[x,g]=l.useState(!1),p=Oj(t,s),v=t==="pending"&&s===0,y=u??t,w=c||f,N=p.length===0&&!v,j=async C=>{if(m(null),C==="shipped"){g(!0);return}const S=C===ss?"confirmed":C;d(S);try{C===ss?await i({orderId:e}):await o({orderId:e,action:Ij[S]??S})}catch(E){m(E instanceof Ae?E.message:"The status could not be changed."),d(null),a.invalidateQueries({queryKey:["orders","detail",n]})}};return r.jsxs(r.Fragment,{children:[N?r.jsx("span",{className:"text-sm text-zinc-500 font-medium capitalize",children:Ea[t]}):r.jsxs(Sr,{value:y,onValueChange:C=>void j(C),disabled:w,children:[r.jsx(Zn,{className:T("w-44 h-8 text-xs",w&&"opacity-50"),"aria-label":"Order status","data-testid":P("order","status-select"),children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsxs(qe,{value:t,disabled:!0,"data-testid":P("order","status-option",t),children:[Ea[t]," (current)"]}),v&&r.jsx(qe,{value:ss,"data-testid":P("order","status-option",ss),children:"Record payment"}),p.map(C=>r.jsx(qe,{value:C,"data-testid":P("order","status-option",C),children:Ea[C]},C))]})]}),h&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","status-error"),children:h}),r.jsx(Xf,{orderId:e,orderNumber:n,open:x,onOpenChange:g})]})}function zj({entries:e}){const t=[...e].sort((n,s)=>new Date(s.timestamp).getTime()-new Date(n.timestamp).getTime());return r.jsx("div",{className:"flow-root",children:r.jsx("ul",{className:"-mb-8",children:t.map((n,s)=>r.jsx("li",{"data-testid":P("order","timeline-entry",n.toStatus),children:r.jsxs("div",{className:"relative pb-8",children:[s<t.length-1&&r.jsx("span",{className:"absolute left-4 top-5 -ml-px h-full w-0.5 bg-zinc-200","aria-hidden":"true"}),r.jsxs("div",{className:"relative flex gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-zinc-200 bg-white",children:r.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})}),r.jsxs("div",{className:"min-w-0 flex-1 pt-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.fromStatus&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{status:n.fromStatus,size:"sm"}),r.jsx("span",{className:"text-zinc-400 text-xs",children:"→"})]}),r.jsx(Xn,{status:n.toStatus,size:"sm"})]}),n.note&&r.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:n.note}),r.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{children:n.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:n.timestamp,title:Oe(n.timestamp),children:ht(n.timestamp)})]})]})]})]})},n.id))})})}const Kt=l.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{className:T("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}));Kt.displayName="Textarea";function Lj({orderId:e,notes:t}){const[n,s]=l.useState(""),a=rx(),o=async c=>{c.preventDefault(),n.trim()&&(await a.mutateAsync({orderId:e,body:n.trim()}),s(""))};return r.jsxs("div",{"data-testid":P("order","notes"),children:[r.jsx("div",{className:"space-y-3",children:t.length===0?r.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...t].sort((c,i)=>new Date(i.at).getTime()-new Date(c.at).getTime()).map((c,i)=>r.jsx(Fj,{note:c},i))}),r.jsxs("form",{onSubmit:c=>void o(c),className:"mt-4 flex gap-2",children:[r.jsx(Kt,{placeholder:"Add an internal note...",value:n,onChange:c=>s(c.target.value),rows:2,className:"flex-1 text-sm",onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),o(c))}}),r.jsx(se,{type:"submit",size:"icon","aria-label":"Add note",disabled:!n.trim()||a.isPending,className:"self-end h-9 w-9",children:r.jsx(rl,{className:"h-4 w-4"})})]})]})}function Fj({note:e}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:e.body}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:e.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:e.at,title:Oe(e.at),children:ht(e.at)})]})]})}function $j(e,t){if(!(e instanceof Ae))return"The refund could not be made.";const{amountMinor:n,refundableMinor:s}=e.context??{};return e.code==="refund.exceeds_captured"&&typeof n=="number"&&typeof s=="number"?`A refund of ${me(n,t)} is more than the ${me(s,t)} left to refund.`:e.message}function Uj({order:e,onClose:t}){const{refundableMinor:n,currency:s}=e.payment,[a,o]=l.useState((n/100).toFixed(2)),[c,i]=l.useState(""),[f,u]=l.useState(null),[d,h]=l.useState(()=>crypto.randomUUID()),m=l.useRef(!1),[x,g]=l.useState(!1),p=tx(),v=Yy(a),y=v!==null&&v>0&&v<=n,w=async()=>{if(!(!y||v===null||m.current)){m.current=!0,g(!0),u(null);try{if((await p.mutateAsync({orderId:e.id,amountMinor:v,requestId:d,...c.trim()&&{reason:c.trim()}})).refund.status==="failed"){h(crypto.randomUUID()),u("The payment provider refused the refund.");return}t()}catch(N){u($j(N,s))}finally{m.current=!1,g(!1)}}};return r.jsx(qs,{open:!0,onOpenChange:N=>!N&&t(),children:r.jsxs($r,{className:"max-w-md","data-testid":P("order","refund-dialog"),children:[r.jsx(Hs,{children:r.jsxs(Ur,{children:["Refund Order #",e.orderNumber]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 p-3 bg-zinc-50",children:r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-zinc-600",children:"Refundable"}),r.jsx("span",{className:"font-mono font-semibold text-zinc-900",children:me(n,s)})]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{htmlFor:"refund-amount",children:["Amount (",s,")"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{id:"refund-amount",inputMode:"decimal",value:a,onChange:N=>o(N.target.value),"aria-invalid":!y,"data-testid":P("order","refund-amount")}),r.jsx(se,{variant:"outline",type:"button",onClick:()=>o((n/100).toFixed(2)),children:"Full refund"})]}),!y&&r.jsxs("p",{className:"text-xs text-red-600",children:["Enter an amount above 0 and up to ",me(n,s),"."]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"refund-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"refund-reason",placeholder:"Enter refund reason...",value:c,onChange:N=>i(N.target.value),rows:3,"data-testid":P("order","refund-reason")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:f})]}),r.jsxs(Ws,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:t,children:"Cancel"}),r.jsx(se,{variant:"destructive",type:"button",onClick:()=>void w(),disabled:!y||x,"data-testid":P("order","refund-confirm"),children:x?"Processing...":`Refund ${v!==null?me(v,s):""}`})]})]})})}const Vj=50;function Bj(e,t){return jo({queryKey:["history",e,t],initialPageParam:void 0,queryFn:({pageParam:n})=>W.get(`/api/admin/${e}/${encodeURIComponent(t)}/history`,{limit:Vj,cursor:n}),getNextPageParam:n=>n.nextCursor??void 0,enabled:t!==""})}function Kj(e,t){return Ce({queryKey:["history","as-of",e,t],queryFn:()=>W.get(e,{at:t}),enabled:t!==null,retry:!1})}function ho(e){return e==null?"—":typeof e=="object"?JSON.stringify(e):String(e)}function qj({seq:e,change:t}){return r.jsxs("li",{className:"font-mono text-xs text-zinc-600 break-all","data-testid":`history-change-${e}-${t.path}`,children:[r.jsxs("span",{className:"text-zinc-400",children:[t.path,": "]}),r.jsx("span",{className:"text-red-700",children:ho(t.from)}),r.jsx("span",{className:"text-zinc-400",children:" → "}),r.jsx("span",{className:"text-green-700",children:ho(t.to)})]})}function Hj({entry:e,onAsOf:t}){return r.jsxs("li",{className:"py-3 space-y-1.5","data-testid":`history-row-${e.seq}`,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[r.jsx("time",{dateTime:e.at,className:"text-zinc-500",children:Oe(e.at)}),r.jsx("span",{className:"font-mono text-zinc-800",children:e.type}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-actor`,children:e.actor===null?"system":`${e.actor.kind}:${e.actor.id}`}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-command`,children:e.command??""}),r.jsx(se,{type:"button",variant:"outline",size:"sm",className:"ml-auto h-6 px-2 text-xs",onClick:()=>t(e.at),"data-testid":`history-as-of-${e.seq}`,children:"View as of"})]}),e.base?r.jsx("p",{className:"text-xs text-zinc-400",children:"The earliest state the event log holds."}):r.jsx("ul",{className:"space-y-0.5",children:e.changes.map(n=>r.jsx(qj,{seq:e.seq,change:n},n.path))})]})}function Wj({detailPath:e,at:t,onClose:n}){const{data:s,error:a,isLoading:o}=Kj(e,t);return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3 space-y-2","data-testid":"history-as-of-panel",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("h4",{className:"text-xs font-semibold text-zinc-700",children:["As of ",Oe(t)]}),r.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:n,children:r.jsx(Yt,{className:"h-3.5 w-3.5"})})]}),o?r.jsx(xe,{className:"h-24 w-full"}):a?r.jsx("p",{className:"text-xs text-red-600",children:a instanceof Ae?a.message:"The record could not be read as of then."}):s?r.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:Object.entries(s.record).map(([c,i])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"text-zinc-400",children:c}),r.jsx("dd",{className:"font-mono text-zinc-700 break-all","data-testid":`history-as-of-field-${c}`,children:ho(i)})]},c))}):null]})}function ui({collection:e,id:t,detailPath:n}){const{data:s,isLoading:a,isError:o,hasNextPage:c,fetchNextPage:i,isFetchingNextPage:f}=Bj(e,t),[u,d]=l.useState(null);if(a)return r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((x,g)=>r.jsx(xe,{className:"h-10 w-full"},g))});if(o||!s)return r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"History could not be loaded"});const h=s.pages[0];if(h.historyStartsAt===null)return r.jsxs("p",{className:"py-4 text-center text-sm text-zinc-500","data-testid":"history-empty",children:["This record predates the event log’s window: the log keeps ",h.retentionDays," days of changes (events.retentionDays), so its earlier history is no longer held."]});const m=s.pages.flatMap(x=>x.entries);return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:["From ",Oe(h.historyStartsAt),": the event log keeps ",h.retentionDays," days of changes."]}),u!==null&&r.jsx(Wj,{detailPath:n,at:u,onClose:()=>d(null)}),r.jsx("ul",{className:"divide-y divide-zinc-100",children:m.map(x=>r.jsx(Hj,{entry:x,onAsOf:d},x.seq))}),c&&r.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void i(),disabled:f,children:f?"Loading…":"Load more"})]})}const Gj=["pending","cancelled"],Qj={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"},Yj={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"},Xj={provider:"Payment provider",manual:"Recorded manually",import:"Imported"};function Zj(e){return e==="storefront"?"Storefront":e==="import"?"Imported":`Agent · ${e.slice(6)}`}const Jj={pending:"Refund pending",succeeded:"Refunded",failed:"Failed"};function eN({order:e}){const{payment:t}=e;return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Payment"}),r.jsx("span",{className:T("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",Yj[t.state]),"data-testid":P("order","payment-state"),children:Qj[t.state]})]}),r.jsxs("dl",{className:"space-y-1.5 text-sm",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Captured"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":P("order","captured"),children:me(t.capturedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Refunded"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":P("order","refunded"),children:me(t.refundedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between font-semibold",children:[r.jsx("dt",{className:"text-zinc-700",children:"Net"}),r.jsx("dd",{className:"font-mono text-zinc-900","data-testid":P("order","net"),children:me(t.capturedMinor-t.refundedMinor,t.currency)})]}),e.captureMethod&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Method"}),r.jsx("dd",{className:"text-zinc-700",children:Xj[e.captureMethod]})]}),r.jsxs("div",{className:"flex justify-between gap-3",children:[r.jsx("dt",{className:"text-zinc-500",children:"Source"}),r.jsx("dd",{className:"truncate text-zinc-700","data-testid":P("order","source"),"data-source":e.source,children:Zj(e.source)})]}),e.paymentIntentId&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Intent ID"}),r.jsx("dd",{className:"font-mono text-xs text-zinc-600 truncate max-w-[120px]",children:e.paymentIntentId})]})]}),t.refunds.length>0&&r.jsx("ul",{className:"space-y-1 border-t border-zinc-100 pt-2 text-sm",children:t.refunds.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":P("order","refund-row",n.id),children:[r.jsxs("span",{className:"text-zinc-500",children:[Jj[n.status]," · ",Oe(n.createdAt)]}),r.jsx("span",{className:"font-mono text-zinc-700",children:me(n.amountMinor,n.currency)})]},n.id))})]})}function hc({address:e,label:t}){return r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-1.5",children:t}),r.jsxs("div",{className:"text-sm text-zinc-600 space-y-0.5",children:[r.jsxs("p",{children:[e.firstName," ",e.lastName]}),e.company&&r.jsx("p",{children:e.company}),r.jsx("p",{children:e.addressLine1}),e.addressLine2&&r.jsx("p",{children:e.addressLine2}),r.jsxs("p",{children:[e.city,", ",e.region," ",e.postalCode]}),r.jsx("p",{children:e.country})]})]})}function tN(){const{orderNumber:e}=xo(),[t,n]=l.useState(!1),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=l.useRef(!1),[f,u]=l.useState(!1),{data:d,isLoading:h}=Qp(e??""),{data:m=[]}=Yp((d==null?void 0:d.id)??""),x=cl(),g=Zp(),p=Jp(),v=nx(),y=async S=>{if(!i.current){i.current=!0,u(!0),c(null);try{await S()}catch(E){c(E instanceof Ae?E.message:"The order could not be updated.")}finally{i.current=!1,u(!1)}}};if(h)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-40"}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-4",children:[r.jsx(xe,{className:"h-48 w-full"}),r.jsx(xe,{className:"h-32 w-full"})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(xe,{className:"h-40 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]})]})]});if(!d)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Order not found"}),r.jsx(Ze,{to:"/orders",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to orders"})]});const N=d.status==="pending"&&d.payment.capturedMinor===0?{label:"Record payment",icon:Si,action:()=>void y(()=>x.mutateAsync({orderId:d.id}))}:d.status==="processing"?{label:"Mark Shipped",icon:al,action:()=>a(!0)}:d.status==="shipped"?{label:"Mark Delivered",icon:Si,action:()=>void y(()=>p.mutateAsync(d.id))}:null,j=Gj.includes(d.status)||v.isPending,C=v.isError?v.error.message:v.data?`Confirmation queued to ${v.data.email}`:null;return r.jsxs("div",{className:"space-y-4","data-testid":P("order","detail"),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(Ze,{to:"/orders",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700 transition-colors",children:[r.jsx(Co,{className:"h-4 w-4"}),"Orders"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsxs("h1",{className:"font-mono text-base font-semibold text-zinc-900",children:["#",d.orderNumber]}),r.jsx(Xn,{status:d.status,"data-testid":P("order","status-badge")})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o!==null&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","action-error"),children:o}),C!==null&&r.jsx("span",{role:"status",className:"text-xs text-zinc-500","data-testid":P("order","resend-result"),children:C}),N&&r.jsxs(se,{size:"sm",onClick:N.action,disabled:f,className:"gap-1.5","data-testid":P("order","primary-action"),children:[r.jsx(N.icon,{className:"h-4 w-4"}),N.label]}),r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"outline",size:"sm","data-testid":P("order","actions"),children:"Actions"})}),r.jsxs(ta,{align:"end",className:"w-44",children:[r.jsxs(bt,{onSelect:()=>{j||v.mutate({orderId:d.id})},className:"gap-2",disabled:j,"data-testid":P("order","action","resend-confirmation"),children:[r.jsx(nl,{className:"h-4 w-4"}),"Resend confirmation"]}),r.jsx(na,{}),d.payment.refundableMinor>0&&r.jsxs(bt,{onClick:()=>n(!0),className:"gap-2","data-testid":P("order","action","refund"),children:[r.jsx(_p,{className:"h-4 w-4"}),"Issue refund"]}),r.jsxs(bt,{onClick:()=>void y(()=>g.mutateAsync({orderId:d.id})),className:"gap-2 text-red-600","data-testid":P("order","action","cancel"),disabled:d.payment.capturedMinor>0||["cancelled","refunded","delivered"].includes(d.status),children:[r.jsx(Tp,{className:"h-4 w-4"}),"Cancel order"]})]})]})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Ei,{className:"h-3.5 w-3.5"}),"Placed ",Oe(d.createdAt)]}),r.jsx("span",{className:"text-zinc-300",children:"·"}),r.jsx(Dj,{orderId:d.id,currentStatus:d.status,orderNumber:d.orderNumber,capturedMinor:d.payment.capturedMinor})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-5",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsxs("h2",{className:"text-sm font-semibold text-zinc-900",children:["Items (",d.lineItems.length,")"]})}),r.jsx("div",{className:"divide-y divide-zinc-50",children:d.lineItems.map(S=>r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[S.imageUrl?r.jsx("img",{src:S.imageUrl,alt:S.productName,className:"h-12 w-12 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(qt,{className:"h-5 w-5 text-zinc-300"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:S.productName}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[S.variantName," · ",S.sku]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("p",{className:"font-mono text-sm text-zinc-700",children:me(S.lineTotalMinor,d.currency)}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[S.qty," × ",me(S.unitPriceMinor,d.currency)]})]})]},S.variantId))}),r.jsxs("div",{className:"border-t border-zinc-100 bg-zinc-50 px-4 py-3 space-y-1",children:[r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Subtotal"}),r.jsx("span",{className:"font-mono",children:me(d.subtotalMinor,d.currency)})]}),d.taxTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Tax"}),r.jsx("span",{className:"font-mono",children:me(d.taxTotalMinor,d.currency)})]}),d.shippingTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Shipping"}),r.jsx("span",{className:"font-mono",children:me(d.shippingTotalMinor,d.currency)})]}),d.discountTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[r.jsx("span",{children:"Discount"}),r.jsxs("span",{className:"font-mono",children:["-",me(d.discountTotalMinor,d.currency)]})]}),r.jsxs("div",{className:"flex justify-between border-t border-zinc-200 pt-2 text-sm font-semibold text-zinc-800",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{className:"font-mono text-base",children:me(d.totalMinor,d.currency)})]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:r.jsxs(Br,{defaultValue:"notes",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-2",children:r.jsxs(or,{className:"h-8",children:[r.jsxs(Te,{value:"notes",className:"gap-1.5 text-xs",children:[r.jsx(Bp,{className:"h-3.5 w-3.5"}),"Notes",m.length>0&&r.jsx("span",{className:"rounded-full bg-zinc-100 px-1.5 text-[10px]",children:m.length})]}),r.jsxs(Te,{value:"timeline",className:"gap-1.5 text-xs","data-testid":P("order","tab","timeline"),children:[r.jsx(Ei,{className:"h-3.5 w-3.5"}),"Timeline"]}),r.jsxs(Te,{value:"history",className:"gap-1.5 text-xs","data-testid":P("order","tab","history"),children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})]})}),r.jsx(Ue,{value:"notes",className:"p-4",children:r.jsx(Lj,{orderId:d.id,notes:m})}),r.jsx(Ue,{value:"timeline",className:"p-4",children:d.history&&d.history.length>0?r.jsx(zj,{entries:d.history}):r.jsx("p",{className:"text-sm text-zinc-400 text-center py-4",children:"No history yet."})}),r.jsx(Ue,{value:"history",className:"p-4",children:r.jsx(ui,{collection:"orders",id:d.id,detailPath:`/api/admin/orders/${encodeURIComponent(d.orderNumber)}`})})]})})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-zinc-100 text-sm font-semibold text-zinc-600",children:(d.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800 [overflow-wrap:anywhere]",children:d.email}),d.customerId&&r.jsx(Ze,{to:`/customers/${d.customerId}`,className:"text-xs text-blue-600 hover:underline",children:"View customer →"})]})]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-3",children:"Addresses"}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[r.jsx(hc,{address:d.shippingAddress,label:"Shipping"}),r.jsx(hc,{address:d.billingAddress,label:"Billing"})]})]}),r.jsx(eN,{order:d}),d.notes&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-amber-50 p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-600 mb-1.5",children:"Order Note"}),r.jsx("p",{className:"text-sm text-amber-800",children:d.notes})]})]})]}),t&&r.jsx(Uj,{order:d,onClose:()=>n(!1)}),r.jsx(Xf,{orderId:d.id,orderNumber:d.orderNumber,open:s,onOpenChange:a})]})}const nN={breadcrumb:e=>`#${e.orderNumber??""}`},rN=Ts("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 Zf({className:e,variant:t,...n}){return r.jsx("div",{className:T(rN({variant:t}),e),...n})}function sN(e={}){return Ce({queryKey:["products","list",e],queryFn:()=>W.get("/api/admin/products",e)})}function aN(e){return Ce({queryKey:["products","detail",e],queryFn:()=>W.get(`/api/admin/products/${e}`),enabled:!!e&&e!=="new"})}function oN(){const e=ye();return we({mutationFn:({product:t,idempotencyKey:n})=>W.post("/api/admin/products",t,n===void 0?void 0:{idempotencyKey:n}),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function iN(){const e=ye();return we({mutationFn:({id:t,data:n,idempotencyKey:s})=>W.patch(`/api/admin/products/${t}`,n,s===void 0?void 0:{idempotencyKey:s}),onSuccess:t=>{e.setQueryData(["products","detail",t.id],t),e.setQueryData(["products","detail",t.slug],t),e.invalidateQueries({queryKey:["products","list"]})}})}function cN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/duplicate`),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function lN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/archive`),onSuccess:()=>{e.invalidateQueries({queryKey:["products"]})}})}function dN(){return we({mutationFn:({id:e,field:t,context:n})=>W.post(`/api/admin/products/${e}/enhance`,{field:t,context:n})})}const uN=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Draft",value:"draft"},{label:"Archived",value:"archived"}],fN={active:"success",draft:"default",archived:"secondary"};function hN(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),{data:o,isLoading:c}=sN({status:t==="all"?void 0:t,q:s||void 0,limit:100}),i=cN(),f=lN();return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Products"}),r.jsx("p",{className:"text-sm text-zinc-500",children:o?`${o.length} products`:"Loading..."})]}),r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(br,{className:"h-4 w-4"}),"Add Product"]})]}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:uN.map(u=>r.jsx("button",{onClick:()=>n(u.value),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===u.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:u.label},u.value))}),r.jsxs("div",{className:"relative flex-1 sm:max-w-xs sm:ml-auto",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search products...",value:s,onChange:u=>a(u.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:c?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:6}).map((u,d)=>r.jsx(xe,{className:"h-11 w-full"},d))}):o!=null&&o.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{className:"w-12",children:"Image"}),r.jsx(ne,{children:"Name"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Type"}),r.jsx(ne,{className:"text-right",children:"Price"}),r.jsx(ne,{children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Updated"}),r.jsx(ne,{className:"w-10"})]})}),r.jsx(Nn,{children:o.map(u=>{const d=u.media[0],h=u.variants[0],m=u.variants.reduce((p,v)=>p+v.stock,0),x=u.variants.some(p=>p.stock<=p.lowStockThreshold),g=u.variants.some(p=>p.stock===0);return r.jsxs(Be,{"data-testid":P("products","row",u.id),className:"cursor-pointer",onClick:()=>e(`/products/${u.slug}`),children:[r.jsx(re,{children:d?r.jsx("img",{src:d.url,alt:d.altText,className:"h-8 w-8 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(qt,{className:"h-3.5 w-3.5 text-zinc-300"})})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-zinc-800",children:u.name}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:u.slug})]})}),r.jsx(re,{children:r.jsx(Zf,{variant:fN[u.status],className:"capitalize",children:u.status})}),r.jsx(re,{className:"text-xs text-zinc-500 capitalize",children:u.type}),r.jsx(re,{className:"text-right font-mono text-sm",children:h?me(h.priceMinor,"GBP"):"—"}),r.jsx(re,{children:r.jsx("span",{className:T("text-sm font-mono font-medium",g?"text-red-600":x?"text-amber-600":"text-zinc-700"),children:m})}),r.jsx(re,{className:"text-right text-xs text-zinc-400",children:ht(u.updatedAt)}),r.jsx(re,{onClick:p=>p.stopPropagation(),children:r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-zinc-400 opacity-0 group-hover:opacity-100",children:r.jsx(tl,{className:"h-4 w-4"})})}),r.jsxs(ta,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/products/${u.slug}`),children:"Edit"}),r.jsxs(bt,{onClick:()=>void i.mutateAsync(u.id),className:"gap-2",children:[r.jsx(Mp,{className:"h-3.5 w-3.5"}),"Duplicate"]}),r.jsx(na,{}),r.jsxs(bt,{onClick:()=>void f.mutateAsync(u.id),className:"gap-2 text-zinc-500",children:[r.jsx(Cp,{className:"h-3.5 w-3.5"}),"Archive"]})]})]})})]},u.id)})})]}):r.jsx(We,{icon:r.jsx(qt,{className:"h-5 w-5"}),title:"No products found",description:s?"Try a different search.":"Create your first product.",action:r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(br,{className:"h-4 w-4"}),"Add Product"]})})})]})}const mN={breadcrumb:()=>"Products"};function pN(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 xN({productId:e,variants:t,onChange:n,currency:s,existing:a=!1}){const[o,c]=l.useState(t.map(d=>({...d,_priceDisplay:(d.priceMinor/100).toFixed(2)}))),i=(d,h,m)=>{c(x=>{const g=x.map(p=>{if(p.id!==d)return p;if(h==="_priceDisplay"){const v=parseFloat(m);return{...p,_priceDisplay:m,priceMinor:isNaN(v)?p.priceMinor:Math.round(v*100)}}return{...p,[h]:m}});return n(g.map(({_priceDisplay:p,...v})=>v)),g})},f=()=>{const d=pN(e),h=[...o,{...d,_priceDisplay:"0.00"}];c(h),n(h.map(({_priceDisplay:m,...x})=>x))},u=d=>{const h=o.filter(m=>m.id!==d);c(h),n(h.map(({_priceDisplay:m,...x})=>x))};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"SKU"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Name"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Price"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Stock"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Status"}),r.jsx("th",{className:"w-10 px-3 py-2"})]})}),r.jsxs("tbody",{children:[o.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-3 py-6 text-center text-sm text-zinc-400",children:a?"No variants.":"No variants yet. Add one below."})}),o.map(d=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0","data-testid":P("product","variant-row",d.id),children:[r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"font-mono text-xs",children:d.sku}):r.jsx(pe,{value:d.sku,onChange:h=>i(d.id,"sku",h.target.value),placeholder:"SKU-001",className:"h-7 font-mono text-xs w-28"})}),r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"text-xs",children:d.name}):r.jsx(pe,{value:d.name,onChange:h=>i(d.id,"name",h.target.value),placeholder:"Variant name",className:"h-7 text-xs"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx("span",{className:"text-xs text-zinc-400",children:s}),r.jsx(pe,{value:d._priceDisplay,onChange:h=>i(d.id,"_priceDisplay",h.target.value),"data-testid":P("product","variant-price",d.id),onBlur:h=>{const m=parseFloat(h.target.value);isNaN(m)||i(d.id,"_priceDisplay",m.toFixed(2))},className:"h-7 w-20 text-right font-mono text-xs"})]})}),r.jsx("td",{className:"px-3 py-2 text-right",children:a?r.jsx(Ze,{to:`/inventory?q=${encodeURIComponent(d.sku)}`,"data-testid":P("product","variant-stock",d.id),title:"Adjust stock in Inventory",className:"font-mono text-xs text-zinc-700 underline underline-offset-2 hover:text-zinc-900",children:d.stock}):r.jsx(pe,{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})}),r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"text-xs capitalize",children:d.status}):r.jsxs(Sr,{value:d.status,onValueChange:h=>i(d.id,"status",h),children:[r.jsx(Zn,{className:"h-7 w-24 text-xs",children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"active",children:"Active"}),r.jsx(qe,{value:"inactive",children:"Inactive"})]})]})}),r.jsx("td",{className:"px-3 py-2",children:!a&&r.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:r.jsx(sl,{className:"h-3.5 w-3.5"})})})]},d.id))]})]})}),r.jsxs("div",{className:"flex items-center justify-between pt-1",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:[o.length," variant",o.length!==1?"s":"",o.length>0&&r.jsxs(r.Fragment,{children:[" · Total stock: ",o.reduce((d,h)=>d+h.stock,0)]})]}),!a&&r.jsxs(se,{variant:"outline",size:"sm",onClick:f,className:"gap-1.5",children:[r.jsx(br,{className:"h-3.5 w-3.5"}),"Add Variant"]})]})]})}function gN({media:e,onChange:t}){const[n,s]=l.useState(""),[a,o]=l.useState(""),[c,i]=l.useState(!1),[f,u]=l.useState(null),d=()=>{if(!n.trim())return;const g=[...e,{url:n.trim(),altText:a.trim(),position:e.length}];t(g),s(""),o("")},h=g=>{const p=e.filter((v,y)=>y!==g).map((v,y)=>({...v,position:y}));t(p)},m=g=>{const p=e[g];if(!p)return;const v=[p,...e.filter((y,w)=>w!==g)].map((y,w)=>({...y,position:w}));t(v)},x=(g,p)=>{const v=e.map((y,w)=>w===g?{...y,altText:p}:y);t(v)};return r.jsxs("div",{className:"space-y-3",children:[e.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:e.map((g,p)=>r.jsxs("div",{className:T("group relative rounded-md border bg-zinc-50 overflow-hidden",p===0?"border-blue-300 ring-1 ring-blue-300":"border-zinc-200"),children:[r.jsx("div",{className:"aspect-square flex items-center justify-center",children:g.url?r.jsx("img",{src:g.url,alt:g.altText||"Product image",className:"h-full w-full object-cover",onError:v=>{v.target.style.display="none"}}):r.jsx(zp,{className:"h-6 w-6 text-zinc-300"})}),p===0&&r.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"}),r.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&&r.jsx("button",{onClick:()=>m(p),className:"rounded bg-white/90 p-1 text-zinc-700 hover:bg-white",title:"Set as primary",children:r.jsx(Gp,{className:"h-3 w-3"})}),r.jsx("button",{onClick:()=>h(p),className:"rounded bg-white/90 p-1 text-red-600 hover:bg-white",title:"Remove",children:r.jsx(Yt,{className:"h-3 w-3"})})]}),r.jsx("div",{className:"border-t border-zinc-100 px-1.5 py-1",children:f===p?r.jsx("input",{autoFocus:!0,value:g.altText,onChange:v=>x(p,v.target.value),onBlur:()=>u(null),className:"w-full text-[10px] bg-transparent border-b border-zinc-300 outline-none",placeholder:"Alt text..."}):r.jsx("button",{onClick:()=>u(p),className:"w-full text-left text-[10px] text-zinc-400 hover:text-zinc-600 truncate",children:g.altText||"Add alt text"})})]},p))}),r.jsx("div",{className:T("rounded-md border-2 border-dashed p-4 transition-colors",c?"border-blue-400 bg-blue-50":"border-zinc-200"),onDragOver:g=>{g.preventDefault(),i(!0)},onDragLeave:()=>i(!1),onDrop:g=>{g.preventDefault(),i(!1)},children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs text-zinc-500 text-center",children:"Add image by URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Ee,{className:"text-xs",children:"Image URL"}),r.jsx(pe,{value:n,onChange:g=>s(g.target.value),placeholder:"https://cdn.example.com/image.jpg",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Ee,{className:"text-xs",children:"Alt Text"}),r.jsx(pe,{value:a,onChange:g=>o(g.target.value),placeholder:"Describe the image",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(se,{type:"button",size:"sm",onClick:d,disabled:!n.trim(),className:"h-8 gap-1",children:[r.jsx(br,{className:"h-3.5 w-3.5"}),"Add"]})})]})]})}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[e.length," image",e.length!==1?"s":""," · Drag to reorder (coming soon)"]})]})}function vN({title:e,description:t,url:n}){const o=e.length>60,c=t.length>155,i=o?e.slice(0,60)+"...":e,f=c?t.slice(0,155)+"...":t;return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:r.jsxs("div",{className:"max-w-lg",children:[r.jsx("p",{className:"text-xs text-zinc-400 mb-1 truncate",children:n||"https://yourstore.com/products/..."}),r.jsx("p",{className:T("text-[17px] leading-snug text-blue-700 cursor-pointer hover:underline mb-1",!e&&"text-zinc-300 italic"),children:i||"Page title appears here"}),r.jsx("p",{className:T("text-sm leading-relaxed text-zinc-500",!t&&"text-zinc-300 italic"),children:f||"Meta description appears here..."})]})}),(o||c)&&r.jsxs("div",{className:"space-y-1.5",children:[o&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(gs,{className:"h-3.5 w-3.5 shrink-0"}),"Title is ",e.length," chars — Google shows ~60. Consider shortening."]}),c&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(gs,{className:"h-3.5 w-3.5 shrink-0"}),"Description is ",t.length," chars — Google shows ~155. Consider shortening."]})]}),r.jsxs("div",{className:"flex gap-4 text-xs text-zinc-400",children:[r.jsxs("span",{className:T(o?"text-amber-500":"text-zinc-400"),children:["Title: ",e.length,"/",60]}),r.jsxs("span",{className:T(c?"text-amber-500":"text-zinc-400"),children:["Description: ",t.length,"/",155]})]})]})}function Ra({productId:e,field:t,context:n,onApply:s,className:a}){const[o,c]=l.useState(null),i=dN(),f=async()=>{c(null);const h={};n.name&&(h.name=n.name),n.current&&(h.current=n.current);const m=await i.mutateAsync({id:e,field:t,context:h});c(m.suggestion)},u=()=>{o&&(s(o),c(null))},d=()=>{c(null)};return r.jsxs("div",{className:T("space-y-2",a),"data-testid":P("product","ai-enrich",t),children:[r.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void f(),disabled:i.isPending,className:"gap-1.5 text-xs text-purple-700 border-purple-200 hover:bg-purple-50 hover:border-purple-300",children:[r.jsx(Wa,{className:T("h-3.5 w-3.5",i.isPending&&"animate-spin")}),i.isPending?"Enhancing...":"Enhance with AI"]}),o&&r.jsxs("div",{className:"rounded-md border border-purple-200 bg-purple-50 p-3 space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-purple-800 uppercase tracking-wider",children:"AI Suggestion"}),r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:o}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(se,{type:"button",size:"sm",onClick:u,className:"gap-1.5 bg-purple-600 hover:bg-purple-700 text-white text-xs",children:[r.jsx(St,{className:"h-3.5 w-3.5"}),"Apply"]}),r.jsxs(se,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"gap-1.5 text-zinc-500 text-xs",children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Dismiss"]})]})]})]})}const yN={name:"",slug:"",description:"",shortDescription:"",status:"draft",type:"simple",seoTitle:"",seoDescription:"",media:[],variants:[],categoryIds:[],metadata:{}};function bN(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function mc(){const{slug:e}=xo(),t=Ct(),n=!e||e==="new",{data:s,isLoading:a}=aN(n?"":e??""),o=oN(),c=iN(),[i,f]=l.useState(yN),[u,d]=l.useState(!1),[h,m]=l.useState(!1),[x,g]=Xt();l.useEffect(()=>{s&&f(s)},[s]);const p=(j,C)=>{d(!0),f(S=>{const E={...S,[j]:C};return j==="name"&&!h&&(E.slug=bN(C)),E})},v=async()=>{const j=x;if(g(),n){const C=await o.mutateAsync({product:i,idempotencyKey:j});t(`/products/${C.slug}`)}else if(s){const C=new Set(s.variants.map(k=>k.id)),S=(i.variants??[]).filter(k=>C.has(k.id)).map(({id:k,priceMinor:z,compareAtPriceMinor:O})=>({id:k,priceMinor:z,compareAtPriceMinor:O})),E={...i,variants:S};await c.mutateAsync({id:s.id,data:E,idempotencyKey:j}),d(!1)}},y=o.isPending||c.isPending;if(!n&&a)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-48"}),r.jsx(xe,{className:"h-96 w-full"})]});if(!n&&!s)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Product not found"}),r.jsx(Ze,{to:"/products",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to products"})]});const w=(s==null?void 0:s.id)??"new";return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(Ze,{to:"/products",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Co,{className:"h-4 w-4"}),"Products"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("h1",{className:"text-base font-semibold text-zinc-900",children:n?"New Product":i.name||"Edit Product"}),u&&r.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:"Unsaved changes"})]}),r.jsx(se,{onClick:()=>void v(),disabled:y||!i.name,className:"gap-1.5","data-testid":P("product","save"),children:y?r.jsxs(r.Fragment,{children:[r.jsx(Mr,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Hp,{className:"h-4 w-4"}),n?"Create Product":"Save Changes"]})})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs(Br,{defaultValue:"general",children:[r.jsxs(or,{className:"mb-4",children:[r.jsx(Te,{value:"general",children:"General"}),r.jsx(Te,{value:"variants","data-testid":P("product","tab","variants"),children:"Variants"}),r.jsx(Te,{value:"media",children:"Media"}),r.jsx(Te,{value:"seo",children:"SEO"}),s&&r.jsx(Te,{value:"history","data-testid":P("product","tab","history"),children:"History"})]}),r.jsx(Ue,{value:"general",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{children:["Product Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(pe,{value:i.name??"",onChange:j=>p("name",j.target.value),placeholder:"e.g. Classic White T-Shirt","data-testid":P("product","name"),className:"text-base"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Slug"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-zinc-400 shrink-0",children:"/products/"}),r.jsx(pe,{value:i.slug??"",onChange:j=>{m(!0),p("slug",j.target.value)},placeholder:"classic-white-t-shirt",className:"font-mono text-sm"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Description"}),!n&&r.jsx(Ra,{productId:w,field:"description",context:{...i.name?{name:i.name}:{},...i.description?{current:i.description}:{}},onApply:j=>p("description",j)})]}),r.jsx(Kt,{value:i.description??"",onChange:j=>p("description",j.target.value),placeholder:"Describe this product...",rows:5})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Short Description"}),r.jsx(Kt,{value:i.shortDescription??"",onChange:j=>p("shortDescription",j.target.value),placeholder:"Brief one-line description...",rows:2})]})]})}),r.jsx(Ue,{value:"variants",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Variants"}),r.jsx(xN,{productId:w,variants:i.variants??[],onChange:j=>p("variants",j),currency:"GBP",existing:!n})]})}),r.jsx(Ue,{value:"media",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Media"}),r.jsx(gN,{media:i.media??[],onChange:j=>p("media",j)})]})}),r.jsx(Ue,{value:"seo",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"SEO Title"}),!n&&r.jsx(Ra,{productId:w,field:"title",context:i.name?{name:i.name}:{},onApply:j=>p("seoTitle",j),className:"scale-90 origin-right"})]}),r.jsx(pe,{value:i.seoTitle??"",onChange:j=>p("seoTitle",j.target.value),placeholder:i.name??"SEO title..."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"SEO Description"}),!n&&r.jsx(Ra,{productId:w,field:"seoDescription",context:{...i.name?{name:i.name}:{},...i.seoDescription?{current:i.seoDescription}:{}},onApply:j=>p("seoDescription",j),className:"scale-90 origin-right"})]}),r.jsx(Kt,{value:i.seoDescription??"",onChange:j=>p("seoDescription",j.target.value),placeholder:"Meta description for search engines...",rows:3})]}),r.jsxs("div",{className:"pt-2 border-t border-zinc-100",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-3",children:"Preview"}),r.jsx(vN,{title:i.seoTitle||i.name||"",description:i.seoDescription||i.shortDescription||"",url:`https://yourstore.com/products/${i.slug??""}`})]})]})}),s&&r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(ui,{collection:"products",id:s.id,detailPath:`/api/admin/products/${encodeURIComponent(s.id)}`})})})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsxs(Sr,{value:i.status??"draft",onValueChange:j=>p("status",j),children:[r.jsx(Zn,{"data-testid":P("product","status"),children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"draft",children:"Draft"}),r.jsx(qe,{value:"active",children:"Active"}),r.jsx(qe,{value:"archived",children:"Archived"})]})]}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[i.status==="draft"&&"Not visible to customers.",i.status==="active"&&"Visible and purchasable.",i.status==="archived"&&"Hidden, not purchasable."]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Product Type"}),r.jsxs(Sr,{value:i.type??"simple",onValueChange:j=>p("type",j),children:[r.jsx(Zn,{children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"simple",children:"Simple"}),r.jsx(qe,{value:"variable",children:"Variable"})]})]})]}),!n&&s&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-2 text-xs text-zinc-500",children:[r.jsx("h3",{className:"font-semibold uppercase tracking-wider text-zinc-400",children:"Summary"}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Variants"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.variants.length})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Total stock"}),r.jsx("span",{className:"font-mono font-medium text-zinc-700",children:s.variants.reduce((j,C)=>j+C.stock,0)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Media"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.media.length})]})]})]})]})]})}const wN={breadcrumb:e=>"Edit"},jN={breadcrumb:()=>"New Product"},NN=[{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 CN({row:e,onAdjust:t}){const[n,s]=l.useState(0),[a,o]=l.useState("manual"),[c,i]=l.useState(!1),[f,u]=Xt(),d=()=>{n!==0&&(t(n,a,f),u(),s(0),i(!0),setTimeout(()=>i(!1),1500))};return r.jsxs("div",{className:"flex items-center gap-2","data-testid":P("inventory","adjust",e.variantId),children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>s(h=>h-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:r.jsx(Kp,{className:"h-3 w-3"})}),r.jsx("input",{type:"number",value:n,onChange:h=>s(parseInt(h.target.value)||0),className:T("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")}),r.jsx("button",{onClick:()=>s(h=>h+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:r.jsx(br,{className:"h-3 w-3"})})]}),r.jsxs(Sr,{value:a,onValueChange:h=>o(h),children:[r.jsx(Zn,{className:"h-7 w-28 text-xs",children:r.jsx(Er,{})}),r.jsx(Jn,{children:NN.map(h=>r.jsx(qe,{value:h.value,children:h.label},h.value))})]}),r.jsx(se,{size:"sm",variant:c?"secondary":"default",className:"h-7 px-2 text-xs gap-1",onClick:d,disabled:n===0||c,children:c?r.jsxs(r.Fragment,{children:[r.jsx(St,{className:"h-3 w-3 text-green-600"}),r.jsx("span",{className:"text-green-600",children:"Done"})]}):"Apply"})]})}const SN=Bo,EN=Ko,Jf=l.forwardRef(({className:e,...t},n)=>r.jsx(Vs,{className:T("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 RN=Ts("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"}}),eh=l.forwardRef(({side:e="right",className:t,children:n,...s},a)=>r.jsxs(EN,{children:[r.jsx(Jf,{}),r.jsxs(Bs,{ref:a,className:T(RN({side:e}),"border-zinc-200",t),...s,children:[n,r.jsxs(Rd,{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:[r.jsx(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));eh.displayName="SheetContent";const th=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-2 text-left",e),...t});th.displayName="SheetHeader";const nh=l.forwardRef(({className:e,...t},n)=>r.jsx(qo,{ref:n,className:T("text-lg font-semibold text-zinc-900",e),...t}));nh.displayName="SheetTitle";const PN=l.forwardRef(({className:e,...t},n)=>r.jsx(Ho,{ref:n,className:T("text-sm text-zinc-500",e),...t}));PN.displayName="SheetDescription";function kN(e={}){return Ce({queryKey:["inventory","list",e],queryFn:()=>W.get("/api/admin/inventory",e)})}function TN(e){return Ce({queryKey:["inventory","history",e],queryFn:()=>W.get(`/api/admin/inventory/${e}/history`),enabled:!!e})}function AN(){const e=ye();return we({mutationFn:({variantId:t,delta:n,reason:s,idempotencyKey:a})=>W.post(`/api/admin/inventory/${t}/adjust`,{delta:n,reason:s},a===void 0?void 0:{idempotencyKey:a}),onMutate:async({variantId:t,delta:n})=>{await e.cancelQueries({queryKey:["inventory","list"]});const s=e.getQueryData(["inventory","list",{}]);return s&&e.setQueryData(["inventory","list",{}],s.map(a=>a.variantId===t?{...a,stock:Math.max(0,a.stock+n)}:a)),{previousData:s}},onError:(t,n,s)=>{s!=null&&s.previousData&&e.setQueryData(["inventory","list",{}],s.previousData)},onSuccess:()=>{e.invalidateQueries({queryKey:["inventory"]})}})}function MN({variantId:e,productName:t,sku:n,onClose:s}){const{data:a,isLoading:o}=TN(e);return r.jsx(SN,{open:!0,onOpenChange:c=>!c&&s(),children:r.jsxs(eh,{className:"w-[480px] sm:max-w-[480px] overflow-y-auto",children:[r.jsxs(th,{children:[r.jsx(nh,{children:"Stock History"}),r.jsxs("div",{className:"mt-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-700",children:t}),r.jsx("p",{className:"font-mono text-xs text-zinc-400",children:n})]})]}),r.jsx("div",{className:"mt-6",children:o?r.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((c,i)=>r.jsx(xe,{className:"h-12 w-full"},i))}):!a||a.length===0?r.jsx("p",{className:"text-sm text-zinc-400 text-center py-8",children:"No adjustment history found."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Date"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Adj"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"New Qty"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Reason"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Actor"})]})}),r.jsx("tbody",{children:a.map(c=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0",children:[r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 whitespace-nowrap",children:Oe(c.timestamp)}),r.jsxs("td",{className:T("px-3 py-2 text-right font-mono text-sm font-medium",c.adjustment>0?"text-green-600":"text-red-600"),children:[c.adjustment>0?"+":"",c.adjustment]}),r.jsx("td",{className:"px-3 py-2 text-right font-mono text-sm text-zinc-700",children:c.newQty}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 capitalize",children:c.reason.replace(/-/g," ")}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500",children:c.actor})]},c.id))})]})})})]})})}const _N={in_stock:"success",low_stock:"warning",out_of_stock:"destructive"},pc={in_stock:"In Stock",low_stock:"Low Stock",out_of_stock:"Out of Stock"};function IN(){const[e]=kc(),[t,n]=l.useState(()=>e.get("q")??""),[s,a]=l.useState("all"),[o,c]=l.useState(null),{data:i,isLoading:f}=kN({q:t||void 0,status:s==="all"?void 0:s,sort:"urgency",limit:200}),u=AN(),d=m=>(x,g,p)=>{u.mutateAsync({variantId:m,delta:x,reason:g,idempotencyKey:p})},h=m=>m==="out_of_stock"?"border-l-4 border-l-red-300":m==="low_stock"?"border-l-4 border-l-amber-300":"";return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inventory"}),r.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} variants`:"Loading..."})]})}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx("div",{className:"flex gap-1.5",children:["all","out_of_stock","low_stock","in_stock"].map(m=>r.jsx("button",{onClick:()=>a(m),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",s===m?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:m==="all"?"All":pc[m]},m))}),r.jsxs("div",{className:"relative ml-auto max-w-xs flex-1",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search SKU or product...",value:t,onChange:m=>n(m.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Product"}),r.jsx(ne,{children:"SKU / Options"}),r.jsx(ne,{className:"text-right",children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Threshold"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Adjust"}),r.jsx(ne,{className:"text-right",children:"History"})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Be,{"data-testid":P("inventory","row",m.variantId),className:T("transition-colors",h(m.status)),children:[r.jsx(re,{children:r.jsx("p",{className:"font-medium text-zinc-800 text-sm",children:m.productName})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-mono text-xs text-zinc-500",children:m.sku}),m.options.length>0&&r.jsx("p",{className:"text-[10px] text-zinc-400",children:m.options.map(x=>`${x.name}: ${x.value}`).join(" · ")})]})}),r.jsx(re,{className:T("text-right font-mono text-base font-semibold",m.status==="out_of_stock"?"text-red-600":m.status==="low_stock"?"text-amber-600":"text-zinc-800"),children:m.stock}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-400",children:m.threshold}),r.jsx(re,{children:r.jsx(Zf,{variant:_N[m.status],className:"text-[10px]",children:pc[m.status]})}),r.jsx(re,{children:r.jsx(CN,{row:m,onAdjust:d(m.variantId)})}),r.jsx(re,{className:"text-right",children:r.jsxs("button",{onClick:()=>c(m),className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium ml-auto",children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})})]},m.variantId))})]}):r.jsx(We,{icon:r.jsx(Xc,{className:"h-5 w-5"}),title:"No inventory found",description:"No variants match your filters."})}),o&&r.jsx(MN,{variantId:o.variantId,productName:o.productName,sku:o.sku,onClose:()=>c(null)})]})}const ON={breadcrumb:()=>"Inventory"};function DN(e={}){return Ce({queryKey:["customers","list",e],queryFn:async()=>(await W.get("/api/admin/customers",e)).customers})}function zN(e){return Ce({queryKey:["customers","detail",e],queryFn:()=>W.get(`/api/admin/customers/${e}`),enabled:!!e})}function LN(e){return Ce({queryKey:["customers","orders",e],queryFn:()=>W.get(`/api/admin/customers/${e}/orders`),enabled:!!e})}function FN(){const e=ye();return we({mutationFn:({customerId:t,body:n})=>W.post(`/api/admin/customers/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["customers","detail",n.customerId]})}})}function $N(){const e=Ct(),[t,n]=l.useState(""),{data:s,isLoading:a}=DN({q:t||void 0,limit:100});return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Customers"}),r.jsx("p",{className:"text-sm text-zinc-500",children:s?`${s.length} customers`:"Loading..."})]})}),r.jsxs("div",{className:"relative max-w-sm",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search by name or email...",value:t,onChange:o=>n(o.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:a?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((o,c)=>r.jsx(xe,{className:"h-11 w-full"},c))}):s!=null&&s.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Customer"}),r.jsx(ne,{className:"text-right",children:"Orders"}),r.jsx(ne,{className:"text-right",children:"Total Spent"}),r.jsx(ne,{children:"Since"}),r.jsx(ne,{className:"text-right",children:"Last Order"})]})}),r.jsx(Nn,{children:s.map(o=>{var i;const c=[o.firstName,o.lastName].filter(Boolean).join(" ");return r.jsxs(Be,{"data-testid":P("customers","row",o.id),className:"cursor-pointer",onClick:()=>e(`/customers/${o.id}`),children:[r.jsx(re,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.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:(((i=o.firstName)==null?void 0:i[0])??o.email[0]??"?").toUpperCase()}),r.jsxs("div",{children:[c&&r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:c}),r.jsx("p",{className:"text-xs text-zinc-500",children:o.email})]})]})}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:o.orderCount}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:me(o.totalSpentMinor,"GBP")}),r.jsx(re,{className:"text-sm text-zinc-500",children:Oe(o.createdAt)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",children:o.orderCount>0?ht(o.updatedAt):"—"})]},o.id)})})]}):r.jsx(We,{icon:r.jsx(So,{className:"h-5 w-5"}),title:"No customers found",description:t?"Try a different search.":"Customers will appear as orders are placed."})})]})}const UN={breadcrumb:()=>"Customers"};function VN({customer:e,stats:t}){var s;const n=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.email;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-4",children:[r.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:(((s=e.firstName)==null?void 0:s[0])??e.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h2",{className:"text-base font-semibold text-zinc-900 truncate",children:n}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(nl,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.email})]}),e.phone&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(qp,{className:"h-3.5 w-3.5"}),e.phone]})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-zinc-400",children:[r.jsx(Rp,{className:"h-3 w-3"}),"Customer since ",Oe(e.createdAt)]})]}),e.requiresPasswordReset&&r.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"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[r.jsx(Pa,{icon:r.jsx(Gn,{className:"h-4 w-4 text-blue-500"}),label:"Total Orders",value:String(t.orderCount)}),r.jsx(Pa,{icon:r.jsx(Ga,{className:"h-4 w-4 text-green-500"}),label:"Lifetime Value","data-testid":P("customer","stat","lifetime-value"),value:me(t.lifetimeRevenueMinor,"GBP"),mono:!0}),r.jsx(Pa,{icon:r.jsx(Ga,{className:"h-4 w-4 text-indigo-500"}),label:"Avg Order","data-testid":P("customer","stat","avg-order"),value:me(t.avgOrderValueMinor,"GBP"),mono:!0})]}),t.lastOrderAt&&r.jsxs("p",{className:"text-xs text-zinc-400",children:["Last order: ",ht(t.lastOrderAt)]})]})}function Pa({icon:e,label:t,value:n,mono:s,"data-testid":a}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-white p-3","data-testid":a,children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e,r.jsx("span",{className:"text-xs text-zinc-500",children:t})]}),r.jsx("p",{className:`text-base font-semibold text-zinc-900 ${s?"font-mono":""}`,children:n})]})}function BN({orders:e,isLoading:t}){const n=Ct();return t?r.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>r.jsx(xe,{className:"h-11 w-full"},a))}):!e||e.length===0?r.jsx(We,{icon:r.jsx(Gn,{className:"h-5 w-5"}),title:"No orders",description:"This customer hasn't placed any orders yet."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"})]})}),r.jsx(Nn,{children:e.map(s=>r.jsxs(Be,{"data-testid":P("customer","orders-row",s.id),className:"cursor-pointer",onClick:()=>n(`/orders/${s.orderNumber}`),children:[r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600",children:["#",s.orderNumber]}),r.jsx(re,{children:r.jsx(Xn,{status:s.status})}),r.jsxs(re,{className:"text-zinc-500",children:[s.lineItems.length," item",s.lineItems.length!==1?"s":""]}),r.jsx(re,{className:"text-right font-mono text-sm",children:me(s.totalMinor,s.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-500",children:ht(s.createdAt)})]},s.id))})]})})}function KN({notes:e}){return r.jsx("div",{className:"space-y-2",children:e.length===0?r.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)=>r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:t.body}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:t.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:t.at,title:Oe(t.at),children:ht(t.at)})]})]},n))})}function qN(){const{id:e}=xo(),[t,n]=l.useState(""),s=l.useRef(!1),[a,o]=l.useState(!1),{data:c,isLoading:i}=zN(e??""),{data:f,isLoading:u}=LN(e??""),d=FN(),h=async v=>{if(v.preventDefault(),!(!t.trim()||!e||s.current)){s.current=!0,o(!0);try{await d.mutateAsync({customerId:e,body:t.trim()}),n("")}finally{s.current=!1,o(!1)}}};if(i)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-32"}),r.jsx(xe,{className:"h-32 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]});if(!c)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx("p",{className:"text-sm text-zinc-500",children:"Customer not found"}),r.jsx(Ze,{to:"/customers",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to customers"})]});const{customer:m,stats:x}=c,g=[m.firstName,m.lastName].filter(Boolean).join(" ")||m.email,p=m.metadata.adminNotes??[];return r.jsxs("div",{className:"space-y-5","data-testid":P("customer","detail"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ze,{to:"/customers",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Co,{className:"h-4 w-4"}),"Customers"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("span",{className:"min-w-0 text-sm font-medium text-zinc-900 [overflow-wrap:anywhere]",children:g})]}),r.jsxs(Br,{defaultValue:"overview",children:[r.jsxs(or,{children:[r.jsx(Te,{value:"overview","data-testid":P("customer","tab","overview"),children:"Overview"}),r.jsx(Te,{value:"history","data-testid":P("customer","tab","history"),children:"History"})]}),r.jsxs(Ue,{value:"overview",className:"space-y-5",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(VN,{customer:m,stats:x})}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Order History"})}),r.jsx("div",{className:"p-4",children:r.jsx(BN,{orders:f,isLoading:u})})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-3","data-testid":P("customer","notes"),children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Notes"}),r.jsx(KN,{notes:p}),r.jsxs("form",{onSubmit:v=>void h(v),className:"flex gap-2 pt-2",children:[r.jsx(Kt,{placeholder:"Add a note about this customer...",value:t,onChange:v=>n(v.target.value),rows:2,className:"flex-1 text-sm"}),r.jsx(se,{type:"submit",size:"icon",disabled:!t.trim()||a,className:"self-end h-9 w-9",children:r.jsx(rl,{className:"h-4 w-4"})})]})]})]}),r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(ui,{collection:"customers",id:m.id,detailPath:`/api/admin/customers/${encodeURIComponent(m.id)}`})})})]})]})}const HN={breadcrumb:e=>"Customer"},rh=(e,t)=>`/api/admin/settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;function WN(){return Ce({queryKey:["settings"],queryFn:()=>W.get("/api/admin/settings")})}function GN(){const e=ye();return we({mutationFn:({slot:t,path:n,value:s})=>W.put(rh(t,n),{value:s}),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}function QN(){const e=ye();return we({mutationFn:({slot:t,path:n})=>W.delete(rh(t,n)),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}const YN={payments:"Payments",email:"Email",reviews:"Reviews",search:"Search",analytics:"Analytics",shipping:"Shipping",tax:"Tax",ai:"AI"},XN=(e,t)=>`${e}-${t}`;function ZN(e){return e.source==="config"||e.source==="env"?"Set by environment":e.secret?e.state==="set"?"Set":"Not set":e.state==="set"?String(e.value??""):"Not set"}function JN({slot:e,field:t,onSaved:n}){const s=l.useRef(null),a=GN(),o=QN(),[c,i]=l.useState(null),f=l.useRef(!1),u=XN(e,t.path),d=t.source==="config"||t.source==="env",h=async()=>{var g;const x=((g=s.current)==null?void 0:g.value)??"";if(!(x===""||f.current)){f.current=!0,i(null);try{await a.mutateAsync({slot:e,path:t.path,value:x}),s.current&&(s.current.value=""),n()}catch(p){i(p instanceof Ae?p.message:"The value was not saved")}finally{f.current=!1}}},m=async()=>{i(null);try{await o.mutateAsync({slot:e,path:t.path}),n()}catch(x){i(x instanceof Ae?x.message:"The value was not cleared")}};return r.jsxs("div",{"data-testid":`settings-field-${u}`,className:"flex flex-col gap-2 border-b border-zinc-100 py-3 last:border-b-0 sm:flex-row sm:items-center",children:[r.jsxs("div",{className:"min-w-0 sm:w-56",children:[r.jsx("label",{htmlFor:`settings-input-${u}`,className:"text-sm font-medium text-zinc-900",children:t.label}),r.jsx("p",{className:"font-mono text-[11px] text-zinc-500",children:t.path})]}),r.jsx("span",{"data-testid":`settings-state-${u}`,className:"min-w-0 truncate text-sm text-zinc-600 sm:w-44",children:ZN(t)}),!d&&r.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{ref:s,id:`settings-input-${u}`,"data-testid":`settings-input-${u}`,type:t.secret?"password":"text",autoComplete:"off",spellCheck:!1,placeholder:t.secret&&t.state==="set"?"Enter a new value":""}),r.jsx(se,{type:"button",size:"sm",className:"h-9","data-testid":`settings-save-${u}`,disabled:a.isPending,onClick:()=>void h(),children:"Save"}),t.source==="settings"&&r.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-9","data-testid":`settings-clear-${u}`,disabled:o.isPending,onClick:()=>void m(),children:"Clear"})]}),c!==null&&r.jsx("p",{role:"alert",className:"text-xs text-red-600",children:c})]})]})}function e1({slot:e,onSaved:t}){return r.jsxs("section",{className:"rounded-lg border border-zinc-200 bg-white px-4",children:[r.jsxs("header",{className:"flex items-baseline gap-2 border-b border-zinc-100 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:YN[e.slot]??e.slot}),r.jsx("span",{className:"text-xs text-zinc-500",children:e.provider})]}),e.fields.map(n=>r.jsx(JN,{slot:e.slot,field:n,onSaved:t},n.path))]})}function t1(){const{data:e,isLoading:t}=WN(),[n,s]=l.useState(!1);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Settings"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Keys and credentials for the services this store uses. The config and environment always win."})]}),n&&r.jsx("p",{"data-testid":"settings-restart-note",role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:"Saved. Restart the store to apply."}),t?r.jsx(xe,{className:"h-40 w-full"}):e===void 0||e.slots.length===0?r.jsx(We,{icon:r.jsx(Fp,{className:"h-5 w-5"}),title:"Nothing to set here",description:"None of this store's providers takes keys from Settings."}):e.slots.map(a=>r.jsx(e1,{slot:a,onSaved:()=>s(!0)},a.slot))]})}const n1={breadcrumb:()=>"Settings"},r1=100;function s1(e){return jo({queryKey:["activity",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.getPage("/api/admin/activity",{...e,limit:r1,cursor:t}),getNextPageParam:t=>{var s;const n=(s=t.meta)==null?void 0:s.nextCursor;return typeof n=="string"&&n!==""?n:void 0}})}function a1(e){return W.getText("/api/admin/activity/export",e)}const o1={applied:"bg-green-50 text-green-700",refused:"bg-red-50 text-red-700",replayed:"bg-zinc-100 text-zinc-600"};function xc(e){if(e==="")return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function i1(e){const t={};for(const a of["actor","command","subject","correlation","outcome"]){const o=e[a].trim();o!==""&&(t[a]=o)}const n=xc(e.since),s=xc(e.until);return n!==void 0&&(t.since=n),s!==void 0&&(t.until=s),t}function c1(e){const t=URL.createObjectURL(new Blob([e],{type:"application/x-ndjson"})),n=document.createElement("a");n.href=t,n.download=`activity-${new Date().toISOString().slice(0,10)}.ndjson`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)}const l1={actor:"",command:"",subject:"",correlation:"",outcome:"",since:"",until:""};function d1(){const[e]=kc(),[t,n]=l.useState(()=>({...l1,correlation:e.get("correlation")??""})),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=i1(t),{data:f,isLoading:u,isError:d,fetchNextPage:h,hasNextPage:m,isFetchingNextPage:x}=s1(i),g=(f==null?void 0:f.pages.flatMap(y=>y.data))??[],p=y=>w=>n(N=>({...N,[y]:w})),v=async()=>{a(!0),c(null);try{const{since:y,until:w,correlation:N}=i;c1(await a1({...y!==void 0&&{since:y},...w!==void 0&&{until:w},...N!==void 0&&{correlation:N}}))}catch(y){c(y instanceof Error?y.message:String(y))}finally{a(!1)}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Activity"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Who changed what, newest first. The export covers the time and correlation filters."})]}),r.jsxs(se,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void v(),disabled:s,"data-testid":"activity-export",children:[s?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(Op,{className:"h-3.5 w-3.5"}),"Export"]})]}),o&&r.jsxs("p",{className:"text-sm text-red-600",children:["Export failed: ",o]}),r.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(pe,{placeholder:"Actor (admin:<id>, system, …)",value:t.actor,onChange:y=>p("actor")(y.target.value),className:"h-8 text-sm","aria-label":"Actor","data-testid":"activity-filter-actor"}),r.jsx(pe,{placeholder:"Command (inventory.adjust, …)",value:t.command,onChange:y=>p("command")(y.target.value),className:"h-8 text-sm","aria-label":"Command","data-testid":"activity-filter-command"}),r.jsx(pe,{placeholder:"Subject id",value:t.subject,onChange:y=>p("subject")(y.target.value),className:"h-8 text-sm","aria-label":"Subject","data-testid":"activity-filter-subject"}),r.jsx(pe,{placeholder:"Correlation id",value:t.correlation,onChange:y=>p("correlation")(y.target.value),className:"h-8 text-sm","aria-label":"Correlation id","data-testid":"activity-filter-correlation"}),r.jsxs("select",{value:t.outcome,onChange:y=>p("outcome")(y.target.value),className:"h-8 rounded-md border border-zinc-200 bg-white px-2 text-sm","aria-label":"Outcome","data-testid":"activity-filter-outcome",children:[r.jsx("option",{value:"",children:"Any outcome"}),r.jsx("option",{value:"applied",children:"Applied"}),r.jsx("option",{value:"refused",children:"Refused"}),r.jsx("option",{value:"replayed",children:"Replayed"})]}),r.jsx(pe,{type:"datetime-local",value:t.since,onChange:y=>p("since")(y.target.value),className:"h-8 text-sm","aria-label":"From","data-testid":"activity-filter-since"}),r.jsx(pe,{type:"datetime-local",value:t.until,onChange:y=>p("until")(y.target.value),className:"h-8 text-sm","aria-label":"Until","data-testid":"activity-filter-until"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-x-auto",children:u?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((y,w)=>r.jsx(xe,{className:"h-11 w-full"},w))}):d?r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"Activity could not be loaded"}):g.length===0?r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"No activity found",description:"Changes to the store appear here as they are made."}):r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Time"}),r.jsx(ne,{children:"Actor"}),r.jsx(ne,{children:"Command"}),r.jsx(ne,{children:"Subjects"}),r.jsx(ne,{children:"Outcome"}),r.jsx(ne,{children:"Correlation id"})]})}),r.jsx(Nn,{children:g.map(y=>r.jsxs(Be,{"data-testid":`activity-row-${y.id}`,children:[r.jsx(re,{className:"whitespace-nowrap text-xs text-zinc-500",children:Oe(y.at)}),r.jsxs(re,{className:"font-mono text-xs",children:[y.actor.kind,":",y.actor.id]}),r.jsx(re,{className:"font-mono text-xs",children:y.command}),r.jsx(re,{className:"font-mono text-xs text-zinc-600",children:y.subjects.map(w=>r.jsxs("div",{children:[w.type,":",w.id]},`${w.type}:${w.id}`))}),r.jsx(re,{children:r.jsxs("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",o1[y.outcome]),children:[y.outcome,y.responseStatus!==null&&` ${y.responseStatus}`]})}),r.jsx(re,{className:"font-mono text-xs text-zinc-500",children:y.correlationId??""})]},y.id))})]})}),m&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void h(),disabled:x,children:x?"Loading…":"Load more"})]})}const u1={breadcrumb:()=>"Activity"},f1={pending:"bg-amber-50 text-amber-700",approved:"bg-blue-50 text-blue-700",applied:"bg-green-50 text-green-700",rejected:"bg-zinc-100 text-zinc-600",failed:"bg-red-50 text-red-700"},h1={pending:"Pending",approved:"Approved",applied:"Applied",rejected:"Rejected",failed:"Failed"};function m1(e){return typeof e=="string"?e:JSON.stringify(e)}function p1(e,t){return e.kind==="policy"?`policy ${e.rule}`:e.id===t?"you":`admin ${e.id}`}function x1({proposal:e,me:t,onReject:n}){const s=ll(),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,decision:d,outcome:h}=e,m=e.proposer.agent,x=e.proposer.userId,g=async()=>{if(!a.current){a.current=!0,c(!0),f(null);try{await s.mutateAsync(u)}catch(v){f(v instanceof Ae?v.message:"The proposal could not be approved.")}finally{a.current=!1,c(!1)}}},p=Object.entries(e.args);return r.jsxs("article",{className:"min-w-0 space-y-3 rounded-lg border border-zinc-200 bg-white p-4","data-testid":P("inbox","row",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-mono text-sm font-semibold break-all text-zinc-900",children:e.command}),r.jsx("p",{className:"font-mono text-xs break-all text-zinc-500",children:e.tool})]}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",f1[e.status]),"data-testid":P("inbox","status",u),children:h1[e.status]})]}),r.jsxs("p",{className:"text-xs break-words text-zinc-500",children:[m.name,m.version!==void 0&&` ${m.version}`," for"," ",x===null?"a shopper":x===t?"you":`admin ${x}`,","," ",Oe(e.createdAt)]}),r.jsx(iu,{proposal:e,scope:"inbox"}),(p.length>0||e.handles.length>0)&&r.jsxs("dl",{className:"grid min-w-0 grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-3 gap-y-1 rounded-md bg-zinc-50 p-2 text-xs",children:[p.map(([v,y])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsx("dd",{className:"font-mono whitespace-pre-wrap break-all text-zinc-800",children:m1(y)})]},v)),e.handles.map(v=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsxs("dd",{className:"text-zinc-400 italic",children:["the agent’s ",v]})]},v))]}),d!==void 0&&r.jsxs("p",{className:"text-xs break-words text-zinc-600",children:[e.status==="rejected"?"Rejected":"Approved"," by"," ",p1(d.by,t),", ",Oe(d.at),d.reason!==void 0&&`: ${d.reason}`]}),e.status==="failed"&&(h==null?void 0:h.message)!==void 0&&r.jsx("p",{className:"text-xs break-words text-red-600",children:h.message}),e.status==="applied"&&r.jsx(Ze,{to:`/activity?correlation=${encodeURIComponent(e.correlationId)}`,className:"text-xs text-blue-600 hover:underline",children:"See what it changed"}),e.status==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",onClick:()=>void g(),disabled:o,"data-testid":P("inbox","approve",u),children:[o?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>n(e),disabled:o,"data-testid":P("inbox","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}const g1=500;function v1({proposal:e,onClose:t}){const[n,s]=l.useState(""),[a,o]=l.useState(null),c=l.useRef(!1),[i,f]=l.useState(!1),u=dl();l.useEffect(()=>{e!==null&&(s(""),o(null))},[e]);const d=async()=>{if(!(e===null||c.current)){c.current=!0,f(!0),o(null);try{await u.mutateAsync({id:e.id,reason:n.trim()}),t()}catch(h){o(h instanceof Ae?h.message:"The proposal could not be rejected.")}finally{c.current=!1,f(!1)}}};return r.jsx(qs,{open:e!==null,onOpenChange:h=>!h&&t(),children:r.jsxs($r,{className:"max-w-md",children:[r.jsx(Hs,{children:r.jsxs(Ur,{children:["Reject ",e==null?void 0:e.command]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"proposal-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"proposal-reason",value:n,maxLength:g1,onChange:h=>s(h.target.value),"data-testid":P("inbox","reason")})]}),a!==null&&r.jsx("p",{className:"text-sm text-red-600",children:a}),r.jsxs(Ws,{children:[r.jsx(se,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),r.jsx(se,{variant:"destructive",onClick:()=>void d(),disabled:i,"data-testid":P("inbox","reject-confirm"),children:"Reject"})]})]})})}function y1(){const[e,t]=l.useState("pending"),[n,s]=l.useState(null),{data:a}=Eo(),{data:o,isLoading:c,isError:i,fetchNextPage:f,hasNextPage:u,isFetchingNextPage:d}=ax(e),h=(o==null?void 0:o.pages.flatMap(m=>m.items))??[];return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inbox"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Changes agents asked for. Nothing runs until you approve it, as you."})]}),r.jsx(Br,{value:e,onValueChange:m=>t(m),children:r.jsxs(or,{children:[r.jsx(Te,{value:"pending","data-testid":P("inbox","tab","pending"),children:"Pending"}),r.jsx(Te,{value:"decided","data-testid":P("inbox","tab","decided"),children:"Decided"})]})}),c?r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((m,x)=>r.jsx(xe,{className:"h-28 w-full"},x))}):i?r.jsx(We,{icon:r.jsx(Ha,{className:"h-5 w-5"}),title:"The inbox could not be loaded"}):h.length===0?r.jsx(We,{icon:r.jsx(Ha,{className:"h-5 w-5"}),title:e==="pending"?"Nothing waiting":"Nothing decided yet",description:"An agent's change to the store appears here until someone decides it."}):r.jsx("div",{className:"space-y-3",children:h.map(m=>r.jsx(x1,{proposal:m,me:a==null?void 0:a.userId,onReject:s},m.id))}),u&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void f(),disabled:d,children:d?"Loading…":"Load more"}),r.jsx(v1,{proposal:n,onClose:()=>s(null)})]})}const b1={breadcrumb:()=>"Inbox"};function w1(){const e=Ct();return r.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[r.jsx("p",{className:"font-mono text-5xl font-bold text-zinc-200",children:"404"}),r.jsx("h2",{className:"mt-3 text-base font-semibold text-zinc-700",children:"Page not found"}),r.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"The page you're looking for doesn't exist."}),r.jsx("div",{className:"mt-6",children:r.jsx(se,{variant:"outline",onClick:()=>e("/"),children:"Go to Dashboard"})})]})}let gc=null;async function j1(){return xs()?null:(gc??(gc=bp()),await gc,xs()?null:ph("/login"))}const sh=mh([{path:"/login",element:r.jsx(Cb,{})},{path:"/",element:r.jsx(bb,{}),loader:j1,handle:{breadcrumb:()=>null},children:[{index:!0,element:r.jsx(Ab,{}),handle:{breadcrumb:()=>"Dashboard"}},{path:"orders",handle:tj,children:[{index:!0,element:r.jsx(ej,{})},{path:":orderNumber",element:r.jsx(tN,{}),handle:nN}]},{path:"products",handle:mN,children:[{index:!0,element:r.jsx(hN,{})},{path:"new",element:r.jsx(mc,{}),handle:jN},{path:":slug",element:r.jsx(mc,{}),handle:wN}]},{path:"inventory",element:r.jsx(IN,{}),handle:ON},{path:"customers",handle:UN,children:[{index:!0,element:r.jsx($N,{})},{path:":id",element:r.jsx(qN,{}),handle:HN}]},{path:"activity",element:r.jsx(d1,{}),handle:u1},{path:"inbox",element:r.jsx(y1,{}),handle:b1},{path:"settings",element:r.jsx(t1,{}),handle:n1},{path:"*",element:r.jsx(w1,{})}]}],{basename:"/admin"});xp(()=>{ps.clear(),sh.navigate("/login")});const ah=document.getElementById("root");if(!ah)throw new Error("Root element not found");bh.createRoot(ah).render(r.jsx(l.StrictMode,{children:r.jsx(Wh,{client:ps,children:r.jsx(xh,{router:sh})})}));
323
+ 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},ay="DialogDescriptionWarning",oy=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ed(ay).contentName}}.`;return l.useEffect(()=>{var o;const a=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Bo=hd,Ko=xd,Bs=gd,Ks=vd,qo=bd,Ho=jd,Rd=Cd,iy=Symbol.for("react.lazy"),Cs=po[" use ".trim().toString()];function cy(e){return typeof e=="object"&&e!==null&&"then"in e}function Pd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===iy&&"_payload"in e&&cy(e._payload)}function ly(e){const t=dy(e),n=l.forwardRef((s,a)=>{let{children:o,...c}=s;Pd(o)&&typeof Cs=="function"&&(o=Cs(o._payload));const i=l.Children.toArray(o),f=i.find(fy);if(f){const u=f.props.children,d=i.map(h=>h===f?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:h);return r.jsx(t,{...c,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,d):null})}return r.jsx(t,{...c,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function dy(e){const t=l.forwardRef((n,s)=>{let{children:a,...o}=n;if(Pd(a)&&typeof Cs=="function"&&(a=Cs(a._payload)),l.isValidElement(a)){const c=my(a),i=hy(o,a.props);return a.type!==l.Fragment&&(i.ref=s?lt(s,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var uy=Symbol("radix.slottable");function fy(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===uy}function hy(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...i)=>{const f=o(...i);return a(...i),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function my(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var py=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Rt=py.reduce((e,t)=>{const n=ly(`Primitive.${t}`),s=l.forwardRef((a,o)=>{const{asChild:c,...i}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(f,{...i,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),mr='[cmdk-group=""]',Na='[cmdk-group-items=""]',xy='[cmdk-group-heading=""]',kd='[cmdk-item=""]',ac=`${kd}:not([aria-disabled="true"])`,no="cmdk-item-select",Tn="data-value",gy=(e,t,n)=>Y0(e,t,n),Td=l.createContext(void 0),Fr=()=>l.useContext(Td),Ad=l.createContext(void 0),Wo=()=>l.useContext(Ad),Md=l.createContext(void 0),_d=l.forwardRef((e,t)=>{let n=An(()=>{var R,K;return{search:"",value:(K=(R=e.value)!=null?R:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=An(()=>new Set),a=An(()=>new Map),o=An(()=>new Map),c=An(()=>new Set),i=Id(e),{label:f,children:u,value:d,onValueChange:h,filter:m,shouldFilter:x,loop:g,disablePointerSelection:p=!1,vimBindings:v=!0,...y}=e,w=Ne(),N=Ne(),j=Ne(),C=l.useRef(null),S=Py();vn(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),vn(()=>{S(6,Q)},[]);let E=l.useMemo(()=>({subscribe:R=>(c.current.add(R),()=>c.current.delete(R)),snapshot:()=>n.current,setState:(R,K,H)=>{var L,J,M,Y;if(!Object.is(n.current[R],K)){if(n.current[R]=K,R==="search")I(),O(),S(1,U);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(j);X?X.focus():(L=document.getElementById(w))==null||L.focus()}if(S(7,()=>{var X;n.current.selectedItemId=(X=V())==null?void 0:X.id,E.emit()}),H||S(5,Q),((J=i.current)==null?void 0:J.value)!==void 0){let X=K??"";(Y=(M=i.current).onValueChange)==null||Y.call(M,X);return}}E.emit()}},emit:()=>{c.current.forEach(R=>R())}}),[]),k=l.useMemo(()=>({value:(R,K,H)=>{var L;K!==((L=o.current.get(R))==null?void 0:L.value)&&(o.current.set(R,{value:K,keywords:H}),n.current.filtered.items.set(R,z(K,H)),S(2,()=>{O(),E.emit()}))},item:(R,K)=>(s.current.add(R),K&&(a.current.has(K)?a.current.get(K).add(R):a.current.set(K,new Set([R]))),S(3,()=>{I(),O(),n.current.value||U(),E.emit()}),()=>{o.current.delete(R),s.current.delete(R),n.current.filtered.items.delete(R);let H=V();S(4,()=>{I(),(H==null?void 0:H.getAttribute("id"))===R&&U(),E.emit()})}),group:R=>(a.current.has(R)||a.current.set(R,new Set),()=>{o.current.delete(R),a.current.delete(R)}),filter:()=>i.current.shouldFilter,label:f||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:w,inputId:j,labelId:N,listInnerRef:C}),[]);function z(R,K){var H,L;let J=(L=(H=i.current)==null?void 0:H.filter)!=null?L:gy;return R?J(R,n.current.search,K):0}function O(){if(!n.current.search||i.current.shouldFilter===!1)return;let R=n.current.filtered.items,K=[];n.current.filtered.groups.forEach(L=>{let J=a.current.get(L),M=0;J.forEach(Y=>{let X=R.get(Y);M=Math.max(X,M)}),K.push([L,M])});let H=C.current;Z().sort((L,J)=>{var M,Y;let X=L.getAttribute("id"),ie=J.getAttribute("id");return((M=R.get(ie))!=null?M:0)-((Y=R.get(X))!=null?Y:0)}).forEach(L=>{let J=L.closest(Na);J?J.appendChild(L.parentElement===J?L:L.closest(`${Na} > *`)):H.appendChild(L.parentElement===H?L:L.closest(`${Na} > *`))}),K.sort((L,J)=>J[1]-L[1]).forEach(L=>{var J;let M=(J=C.current)==null?void 0:J.querySelector(`${mr}[${Tn}="${encodeURIComponent(L[0])}"]`);M==null||M.parentElement.appendChild(M)})}function U(){let R=Z().find(H=>H.getAttribute("aria-disabled")!=="true"),K=R==null?void 0:R.getAttribute(Tn);E.setState("value",K||void 0)}function I(){var R,K,H,L;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let M of s.current){let Y=(K=(R=o.current.get(M))==null?void 0:R.value)!=null?K:"",X=(L=(H=o.current.get(M))==null?void 0:H.keywords)!=null?L:[],ie=z(Y,X);n.current.filtered.items.set(M,ie),ie>0&&J++}for(let[M,Y]of a.current)for(let X of Y)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=J}function Q(){var R,K,H;let L=V();L&&(((R=L.parentElement)==null?void 0:R.firstChild)===L&&((H=(K=L.closest(mr))==null?void 0:K.querySelector(xy))==null||H.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function V(){var R;return(R=C.current)==null?void 0:R.querySelector(`${kd}[aria-selected="true"]`)}function Z(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(ac))||[])}function B(R){let K=Z()[R];K&&E.setState("value",K.getAttribute(Tn))}function ae(R){var K;let H=V(),L=Z(),J=L.findIndex(Y=>Y===H),M=L[J+R];(K=i.current)!=null&&K.loop&&(M=J+R<0?L[L.length-1]:J+R===L.length?L[0]:L[J+R]),M&&E.setState("value",M.getAttribute(Tn))}function F(R){let K=V(),H=K==null?void 0:K.closest(mr),L;for(;H&&!L;)H=R>0?Ey(H,mr):Ry(H,mr),L=H==null?void 0:H.querySelector(ac);L?E.setState("value",L.getAttribute(Tn)):ae(R)}let A=()=>B(Z().length-1),ce=R=>{R.preventDefault(),R.metaKey?A():R.altKey?F(1):ae(1)},le=R=>{R.preventDefault(),R.metaKey?B(0):R.altKey?F(-1):ae(-1)};return l.createElement(Rt.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var K;(K=y.onKeyDown)==null||K.call(y,R);let H=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||H))switch(R.key){case"n":case"j":{v&&R.ctrlKey&&ce(R);break}case"ArrowDown":{ce(R);break}case"p":case"k":{v&&R.ctrlKey&&le(R);break}case"ArrowUp":{le(R);break}case"Home":{R.preventDefault(),B(0);break}case"End":{R.preventDefault(),A();break}case"Enter":{R.preventDefault();let L=V();if(L){let J=new Event(no);L.dispatchEvent(J)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:Ty},f),qs(e,R=>l.createElement(Ad.Provider,{value:E},l.createElement(Td.Provider,{value:k},R))))}),vy=l.forwardRef((e,t)=>{var n,s;let a=Ne(),o=l.useRef(null),c=l.useContext(Md),i=Fr(),f=Id(e),u=(s=(n=f.current)==null?void 0:n.forceMount)!=null?s:c==null?void 0:c.forceMount;vn(()=>{if(!u)return i.item(a,c==null?void 0:c.id)},[u]);let d=Od(a,o,[e.value,e.children,o],e.keywords),h=Wo(),m=Qt(S=>S.value&&S.value===d.current),x=Qt(S=>u||i.filter()===!1?!0:S.search?S.filtered.items.get(a)>0:!0);l.useEffect(()=>{let S=o.current;if(!(!S||e.disabled))return S.addEventListener(no,g),()=>S.removeEventListener(no,g)},[x,e.onSelect,e.disabled]);function g(){var S,E;p(),(E=(S=f.current).onSelect)==null||E.call(S,d.current)}function p(){h.setState("value",d.current,!0)}if(!x)return null;let{disabled:v,value:y,onSelect:w,forceMount:N,keywords:j,...C}=e;return l.createElement(Rt.div,{ref:lt(o,t),...C,id:a,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!m,"data-disabled":!!v,"data-selected":!!m,onPointerMove:v||i.getDisablePointerSelection()?void 0:p,onClick:v?void 0:g},e.children)}),yy=l.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,c=Ne(),i=l.useRef(null),f=l.useRef(null),u=Ne(),d=Fr(),h=Qt(x=>a||d.filter()===!1?!0:x.search?x.filtered.groups.has(c):!0);vn(()=>d.group(c),[]),Od(c,i,[e.value,e.heading,f]);let m=l.useMemo(()=>({id:c,forceMount:a}),[a]);return l.createElement(Rt.div,{ref:lt(i,t),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&l.createElement("div",{ref:f,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),qs(e,x=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},l.createElement(Md.Provider,{value:m},x))))}),by=l.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=l.useRef(null),o=Qt(c=>!c.search);return!n&&!o?null:l.createElement(Rt.div,{ref:lt(a,t),...s,"cmdk-separator":"",role:"separator"})}),wy=l.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=Wo(),c=Qt(u=>u.search),i=Qt(u=>u.selectedItemId),f=Fr();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(Rt.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":f.listId,"aria-labelledby":f.labelId,"aria-activedescendant":i,id:f.inputId,type:"text",value:a?e.value:c,onChange:u=>{a||o.setState("search",u.target.value),n==null||n(u.target.value)}})}),jy=l.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=l.useRef(null),c=l.useRef(null),i=Qt(u=>u.selectedItemId),f=Fr();return l.useEffect(()=>{if(c.current&&o.current){let u=c.current,d=o.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let x=u.offsetHeight;d.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(h),m.unobserve(u)}}},[]),l.createElement(Rt.div,{ref:lt(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":s,id:f.listId},qs(e,u=>l.createElement("div",{ref:lt(c,f.listInnerRef),"cmdk-list-sizer":""},u)))}),Ny=l.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:c,...i}=e;return l.createElement(Bo,{open:n,onOpenChange:s},l.createElement(Ko,{container:c},l.createElement(Bs,{"cmdk-overlay":"",className:a}),l.createElement(Ks,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(_d,{ref:t,...i}))))}),Cy=l.forwardRef((e,t)=>Qt(n=>n.filtered.count===0)?l.createElement(Rt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sy=l.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return l.createElement(Rt.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},qs(e,c=>l.createElement("div",{"aria-hidden":!0},c)))}),De=Object.assign(_d,{List:jy,Item:vy,Input:wy,Group:yy,Separator:by,Dialog:Ny,Empty:Cy,Loading:Sy});function Ey(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ry(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Id(e){let t=l.useRef(e);return vn(()=>{t.current=e}),t}var vn=typeof window>"u"?l.useEffect:l.useLayoutEffect;function An(e){let t=l.useRef();return t.current===void 0&&(t.current=e()),t}function Qt(e){let t=Wo(),n=()=>e(t.snapshot());return l.useSyncExternalStore(t.subscribe,n,n)}function Od(e,t,n,s=[]){let a=l.useRef(),o=Fr();return vn(()=>{var c;let i=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():a.current}})(),f=s.map(u=>u.trim());o.value(e,i,f),(c=t.current)==null||c.setAttribute(Tn,i),a.current=i}),a}var Py=()=>{let[e,t]=l.useState(),n=An(()=>new Map);return vn(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function ky(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function qs({asChild:e,children:t},n){return e&&l.isValidElement(t)?l.cloneElement(ky(t),{ref:t.ref},n(t.props.children)):n(t)}var Ty={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Hs=Bo,Ay=Ko,Dd=l.forwardRef(({className:e,...t},n)=>r.jsx(Bs,{ref:n,className:T("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}));Dd.displayName=Bs.displayName;const $r=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ay,{children:[r.jsx(Dd,{}),r.jsxs(Ks,{ref:s,className:T("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,r.jsxs(Rd,{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:[r.jsx(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));$r.displayName=Ks.displayName;const Ws=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-1.5 text-left",e),...t});Ws.displayName="DialogHeader";const Gs=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Gs.displayName="DialogFooter";const Ur=l.forwardRef(({className:e,...t},n)=>r.jsx(qo,{ref:n,className:T("text-lg font-semibold leading-none tracking-tight",e),...t}));Ur.displayName=qo.displayName;const My=l.forwardRef(({className:e,...t},n)=>r.jsx(Ho,{ref:n,className:T("text-sm text-zinc-500",e),...t}));My.displayName=Ho.displayName;const zd=l.forwardRef(({className:e,...t},n)=>r.jsx(De,{ref:n,className:T("flex h-full w-full flex-col overflow-hidden rounded-md bg-white text-zinc-900",e),...t}));zd.displayName=De.displayName;const Ld=l.forwardRef(({className:e,...t},n)=>r.jsxs("div",{className:"flex items-center border-b border-zinc-200 px-3","cmdk-input-wrapper":"",children:[r.jsx(tr,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(De.Input,{ref:n,className:T("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})]}));Ld.displayName=De.Input.displayName;const Fd=l.forwardRef(({className:e,...t},n)=>r.jsx(De.List,{ref:n,className:T("max-h-[400px] overflow-y-auto overflow-x-hidden",e),...t}));Fd.displayName=De.List.displayName;const $d=l.forwardRef((e,t)=>r.jsx(De.Empty,{ref:t,className:"py-6 text-center text-sm text-zinc-500",...e}));$d.displayName=De.Empty.displayName;const us=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Group,{ref:n,className:T("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}));us.displayName=De.Group.displayName;const ro=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Separator,{ref:n,className:T("-mx-1 h-px bg-zinc-100",e),...t}));ro.displayName=De.Separator.displayName;const fs=l.forwardRef(({className:e,...t},n)=>r.jsx(De.Item,{ref:n,className:T("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}));fs.displayName=De.Item.displayName;function Go(e){const t=e+"CollectionProvider",[n,s]=ut(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=p=>{const{scope:v,children:y}=p,w=Xe.useRef(null),N=Xe.useRef(new Map).current;return r.jsx(a,{scope:v,itemMap:N,collectionRef:w,children:y})};c.displayName=t;const i=e+"CollectionSlot",f=pn(i),u=Xe.forwardRef((p,v)=>{const{scope:y,children:w}=p,N=o(i,y),j=de(v,N.collectionRef);return r.jsx(f,{ref:j,children:w})});u.displayName=i;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=pn(d),x=Xe.forwardRef((p,v)=>{const{scope:y,children:w,...N}=p,j=Xe.useRef(null),C=de(v,j),S=o(d,y);return Xe.useEffect(()=>(S.itemMap.set(j,{ref:j,...N}),()=>void S.itemMap.delete(j))),r.jsx(m,{[h]:"",ref:C,children:w})});x.displayName=d;function g(p){const v=o(e+"CollectionConsumer",p);return Xe.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const N=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((S,E)=>N.indexOf(S.ref.current)-N.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:u,ItemSlot:x},g,s]}var _y=l.createContext(void 0);function Qs(e){const t=l.useContext(_y);return e||t||"ltr"}var Ca="rovingFocusGroup.onEntryFocus",Iy={bubbles:!1,cancelable:!0},Vr="RovingFocusGroup",[so,Ud,Oy]=Go(Vr),[Dy,Ys]=ut(Vr,[Oy]),[zy,Ly]=Dy(Vr),Vd=l.forwardRef((e,t)=>r.jsx(so.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(so.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Fy,{...e,ref:t})})}));Vd.displayName=Vr;var Fy=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:o,currentTabStopId:c,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:f,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=e,m=l.useRef(null),x=de(t,m),g=Qs(o),[p,v]=Gt({prop:c,defaultProp:i??null,onChange:f,caller:Vr}),[y,w]=l.useState(!1),N=dt(u),j=Ud(n),C=l.useRef(!1),[S,E]=l.useState(0);return l.useEffect(()=>{const k=m.current;if(k)return k.addEventListener(Ca,N),()=>k.removeEventListener(Ca,N)},[N]),r.jsx(zy,{scope:n,orientation:s,dir:g,loop:a,currentTabStopId:p,onItemFocus:l.useCallback(k=>v(k),[v]),onItemShiftTab:l.useCallback(()=>w(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(k=>k+1),[]),onFocusableItemRemove:l.useCallback(()=>E(k=>k-1),[]),children:r.jsx(G.div,{tabIndex:y||S===0?-1:0,"data-orientation":s,...h,ref:x,style:{outline:"none",...e.style},onMouseDown:D(e.onMouseDown,()=>{C.current=!0}),onFocus:D(e.onFocus,k=>{const z=!C.current;if(k.target===k.currentTarget&&z&&!y){const O=new CustomEvent(Ca,Iy);if(k.currentTarget.dispatchEvent(O),!O.defaultPrevented){const U=j().filter(B=>B.focusable),I=U.find(B=>B.active),Q=U.find(B=>B.id===p),Z=[I,Q,...U].filter(Boolean).map(B=>B.ref.current);qd(Z,d)}}C.current=!1}),onBlur:D(e.onBlur,()=>w(!1))})})}),Bd="RovingFocusGroupItem",Kd=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:o,children:c,...i}=e,f=Ne(),u=o||f,d=Ly(Bd,n),h=d.currentTabStopId===u,m=Ud(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=d;return l.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(so.ItemSlot,{scope:n,id:u,focusable:s,active:a,children:r.jsx(G.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...i,ref:t,onMouseDown:D(e.onMouseDown,v=>{s?d.onItemFocus(u):v.preventDefault()}),onFocus:D(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:D(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Vy(v,d.orientation,d.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let N=m().filter(j=>j.focusable).map(j=>j.ref.current);if(y==="last")N.reverse();else if(y==="prev"||y==="next"){y==="prev"&&N.reverse();const j=N.indexOf(v.currentTarget);N=d.loop?By(N,j+1):N.slice(j+1)}setTimeout(()=>qd(N))}}),children:typeof c=="function"?c({isCurrentTabStop:h,hasTabStop:p!=null}):c})})});Kd.displayName=Bd;var $y={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Uy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Vy(e,t,n){const s=Uy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return $y[s]}function qd(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function By(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Hd=Vd,Wd=Kd,Xs="Tabs",[Ky]=ut(Xs,[Ys]),Gd=Ys(),[qy,Qo]=Ky(Xs),Qd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:o,orientation:c="horizontal",dir:i,activationMode:f="automatic",...u}=e,d=Qs(i),[h,m]=Gt({prop:s,onChange:a,defaultProp:o??"",caller:Xs});return r.jsx(qy,{scope:n,baseId:Ne(),value:h,onValueChange:m,orientation:c,dir:d,activationMode:f,children:r.jsx(G.div,{dir:d,"data-orientation":c,...u,ref:t})})});Qd.displayName=Xs;var Yd="TabsList",Xd=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,o=Qo(Yd,n),c=Gd(n);return r.jsx(Hd,{asChild:!0,...c,orientation:o.orientation,dir:o.dir,loop:s,children:r.jsx(G.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});Xd.displayName=Yd;var Zd="TabsTrigger",Jd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...o}=e,c=Qo(Zd,n),i=Gd(n),f=nu(c.baseId,s),u=ru(c.baseId,s),d=s===c.value;return r.jsx(Wd,{asChild:!0,...i,focusable:!a,active:d,children:r.jsx(G.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:f,...o,ref:t,onMouseDown:D(e.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?c.onValueChange(s):h.preventDefault()}),onKeyDown:D(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&c.onValueChange(s)}),onFocus:D(e.onFocus,()=>{const h=c.activationMode!=="manual";!d&&!a&&h&&c.onValueChange(s)})})})});Jd.displayName=Zd;var eu="TabsContent",tu=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:o,...c}=e,i=Qo(eu,n),f=nu(i.baseId,s),u=ru(i.baseId,s),d=s===i.value,h=l.useRef(d);return l.useEffect(()=>{const m=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(m)},[]),r.jsx(Ge,{present:a||d,children:({present:m})=>r.jsx(G.div,{"data-state":d?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":f,hidden:!m,id:u,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:m&&o})})});tu.displayName=eu;function nu(e,t){return`${e}-trigger-${t}`}function ru(e,t){return`${e}-content-${t}`}var Hy=Qd,su=Xd,au=Jd,ou=tu;const Br=Hy,or=l.forwardRef(({className:e,...t},n)=>r.jsx(su,{ref:n,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-zinc-100 p-1 text-zinc-500",e),...t}));or.displayName=su.displayName;const Te=l.forwardRef(({className:e,...t},n)=>r.jsx(au,{ref:n,className:T("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}));Te.displayName=au.displayName;const Ue=l.forwardRef(({className:e,...t},n)=>r.jsx(ou,{ref:n,className:T("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}));Ue.displayName=ou.displayName;const Wy=/^\/[A-Za-z0-9/_.-]*$/,rs=8e3;function Gy(e,t){var a;const n=[];for(const o of e)if(n.push({role:"user",content:o.question.slice(0,rs)}),o.answer.trim()!==""){const c=o.revealed.filter(i=>i.end<=rs);n.push({role:"assistant",content:o.answer.slice(0,rs),...c.length>0&&{revealed:c}})}n.push({role:"user",content:t.slice(0,rs)});const s=n.slice(-40);for(;((a=s[0])==null?void 0:a.role)!=="user";)s.shift();return s}function ss(e){try{return JSON.parse(e.data)}catch{return}}let kn=null,Qy=1;const Yo=Us((e,t)=>{const n=(o,c)=>e(i=>({exchanges:i.exchanges.map(f=>f.id===o?{...f,...c(f)}:f)})),s=(o,c)=>{kn==null||kn.close(),kn=null,n(o,()=>c),e({busy:!1})},a=(o,c)=>{const i=new EventSource(`/api/admin/assistant/turns/${encodeURIComponent(c.turnId)}/stream?ticket=${encodeURIComponent(c.ticket)}`);kn=i;const f=()=>kn===i;i.addEventListener("text",u=>{const d=ss(u);f()&&d!==void 0&&n(o,h=>({answer:h.answer+d.delta,revealed:[...h.revealed,...(d.revealed??[]).map(m=>({...m,start:m.start+h.answer.length,end:m.end+h.answer.length}))]}))}),i.addEventListener("tool",u=>{const d=ss(u);f()&&d!==void 0&&n(o,h=>({steps:[...h.steps,d]}))}),i.addEventListener("proposal",u=>{const d=ss(u);f()&&d!==void 0&&n(o,h=>({proposals:[...h.proposals,d]}))}),i.addEventListener("done",()=>{f()&&s(o,{state:"done"})}),i.addEventListener("error",u=>{if(!f())return;const d="data"in u?ss(u):void 0;s(o,{state:"error",error:d??{code:"assistant.disconnected",message:"The answer was cut off"}})})};return{exchanges:[],busy:!1,ask(o,c){const i=o.trim();if(i===""||t().busy)return;const f=Qy++,u=Gy(t().exchanges.filter(h=>!h.unavailable),i);e(h=>({busy:!0,exchanges:[...h.exchanges,{id:f,question:i,answer:"",revealed:[],state:"streaming",steps:[],proposals:[]}]}));const d=c.slice(0,200);W.post("/api/admin/assistant/turns",{messages:u,...Wy.test(d)&&{page:d}}).then(h=>{var m;((m=t().exchanges.find(x=>x.id===f))==null?void 0:m.state)==="streaming"&&a(f,h)}).catch(h=>{const m=h instanceof Ae?h.code:"assistant.failed";s(f,{state:"error",...m==="assistant.unavailable"&&{unavailable:!0},error:{code:m,message:h instanceof Ae?h.message:"The question could not be sent"}})})},stop(){const o=t().exchanges.find(c=>c.state==="streaming");o!==void 0&&s(o.id,{state:"stopped"})},updateProposal(o){e(c=>({exchanges:c.exchanges.map(i=>({...i,proposals:i.proposals.map(f=>f.id===o.id?o:f)}))}))}}}),Xo=Us(e=>({isOpen:!1,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1}),toggle:()=>e(t=>({isOpen:!t.isOpen}))}));function me(e,t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:t,minimumFractionDigits:2}).format(e/100)}function Yy(e){const t=e.trim();if(!/^\d+(\.\d{1,2})?$/.test(t))return null;const[n="0",s=""]=t.split(".");return Number(n)*100+Number(s.padEnd(2,"0"))}function Xy(e,t){const n=e/100,s=Zy(t);return n>=1e6?`${s}${(n/1e6).toFixed(1)}M`:n>=1e3?`${s}${(n/1e3).toFixed(1)}k`:me(e,t)}function Zy(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}}const oc=120;function ic(e,t,n){if(e===null)return"none";if(t==="money"&&typeof e=="number")return me(e,n);const s=String(e);return s.length>oc?`${s.slice(0,oc)}…`:s}function Jy(e,t){const{label:n,kind:s,current:a,proposed:o}=e;return s==="collection"?`${n}: ${a??0} → ${o??0} items${e.changed===!0?", changed":""}`:`${n}: ${ic(a,s,t)} → ${ic(o,s,t)}`}const eb=e=>String(e.args[e.command==="inventory.adjust"?"variantId":"id"]??"");function iu({proposal:e,scope:t}){const n=e.status==="pending"&&lp.includes(e.command),{data:s}=ox(e.id,n),a=n?s==null?void 0:s.preview:void 0;if(a===void 0)return null;const{target:o,changes:c,currency:i}=a;return r.jsxs("div",{className:"space-y-1 text-xs",children:[r.jsx("p",{className:"font-medium break-words text-zinc-900","data-testid":P(t,"target",e.id),children:o===null?`Not found: ${eb(e)}`:o.label}),c.length>0&&r.jsx("ul",{className:"space-y-0.5 break-words text-zinc-700",children:c.map((f,u)=>r.jsx("li",{"data-testid":P(t,"change",e.id),children:Jy(f,i)},u))})]})}const cc={pending:{label:"Pending approval",style:"bg-amber-50 text-amber-700"},approved:{label:"Approved",style:"bg-blue-50 text-blue-700"},applied:{label:"Applied",style:"bg-green-50 text-green-700"},rejected:{label:"Rejected",style:"bg-zinc-100 text-zinc-600"},failed:{label:"Failed",style:"bg-red-50 text-red-700"}};function tb({proposal:e}){const t=ll(),n=dl(),s=Yo(m=>m.updateProposal),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,status:d}=e,h=async m=>{if(!a.current){a.current=!0,c(!0),f(null);try{s(await m())}catch(x){f(x instanceof Ae?x.message:"The proposal could not be decided.")}finally{a.current=!1,c(!1)}}};return r.jsxs("article",{className:"space-y-2 rounded-md border border-zinc-200 bg-white p-3","data-testid":P("assistant","proposal",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsx("p",{className:"font-mono text-xs font-semibold break-all text-zinc-900",children:e.command}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",cc[d].style),"data-testid":P("assistant","proposal","status",u),children:cc[d].label})]}),r.jsx(iu,{proposal:e,scope:"assistant"}),r.jsx("pre",{className:"max-h-32 overflow-auto rounded bg-zinc-50 p-2 font-mono text-[11px] whitespace-pre-wrap break-all text-zinc-700",children:JSON.stringify(e.args,null,1)}),d==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>t.mutateAsync(u)),"data-testid":P("assistant","approve",u),children:[o?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",disabled:o,onClick:()=>void h(()=>n.mutateAsync({id:u,reason:""})),"data-testid":P("assistant","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}function nb({exchange:e}){const t=Xo(a=>a.close),{state:n,error:s}=e;return r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"ml-auto w-fit max-w-[85%] rounded-lg bg-blue-600 px-3 py-2 text-sm whitespace-pre-wrap text-white","data-testid":P("assistant","message"),"data-role":"user",children:e.question}),r.jsxs("div",{className:"space-y-2","data-testid":P("assistant","message"),"data-role":"assistant",children:[e.steps.map((a,o)=>r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-zinc-500","data-testid":P("assistant","step"),"data-tool":a.name,"data-ok":String(a.ok),children:[a.ok?r.jsx(St,{className:"h-3 w-3 text-green-600"}):r.jsx(Yt,{className:"h-3 w-3 text-red-500"}),r.jsx("span",{className:"font-mono",children:a.title}),a.code!==void 0&&r.jsx("span",{className:"text-red-500",children:a.code})]},o)),e.proposals.map(a=>r.jsx(tb,{proposal:a},a.id)),e.unavailable===!0?r.jsxs("p",{className:"rounded-md bg-amber-50 p-3 text-sm text-amber-800","data-testid":P("assistant","unavailable"),children:["The assistant needs an AI provider that can call tools."," ",r.jsx(Ze,{to:"/settings",className:"font-medium underline",onClick:t,children:"Set one up in Settings"}),"."]}):r.jsxs("p",{className:"text-sm whitespace-pre-wrap text-zinc-800","data-testid":P("assistant","answer"),"data-state":n,children:[e.answer,n==="stopped"&&r.jsx("span",{className:"ml-1 text-xs text-zinc-400 italic",children:"(Stopped)"})]}),n==="streaming"&&e.answer===""&&r.jsx("p",{className:"text-xs text-zinc-400",children:"Thinking…"}),s!==void 0&&e.unavailable!==!0&&r.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-red-600","data-testid":P("assistant","error"),"data-code":s.code,children:[r.jsx(el,{className:"h-3.5 w-3.5"}),s.message]})]})]})}function rb({draft:e,onDraftChange:t}){const{exchanges:n,busy:s,ask:a}=Yo(),{pathname:o}=fh(),c=l.useRef(null),i=l.useRef(null),f=n.at(-1);l.useEffect(()=>{var d;(d=i.current)==null||d.scrollIntoView({block:"end"})},[n.length,f==null?void 0:f.answer,f==null?void 0:f.steps.length,f==null?void 0:f.proposals.length]),l.useEffect(()=>{var d;s||(d=c.current)==null||d.focus()},[s]);const u=d=>{d.key!=="Enter"||d.nativeEvent.isComposing||(d.preventDefault(),!(s||e.trim()==="")&&(a(e,o),t("")))};return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"max-h-[400px] min-h-24 space-y-4 overflow-y-auto px-4 py-3",children:[n.length===0&&r.jsxs("p",{className:"flex items-center gap-2 py-6 text-sm text-zinc-500",children:[r.jsx(Wa,{className:"h-4 w-4"}),"Ask about your store: orders, products, stock. A change it suggests waits for your approval."]}),n.map(d=>r.jsx(nb,{exchange:d},d.id)),r.jsx("div",{ref:i})]}),r.jsxs("div",{className:"flex items-center border-t border-zinc-200 px-3",children:[r.jsx(Wa,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx("input",{ref:c,className:"flex h-12 w-full bg-transparent py-3 text-sm outline-none placeholder:text-zinc-400 disabled:cursor-not-allowed disabled:opacity-50",placeholder:s?"Answering…":"Ask about your store, then press Enter",value:e,maxLength:8e3,disabled:s,onChange:d=>t(d.target.value),onKeyDown:u,"data-testid":P("assistant","input")})]})]})}function sb(e){return Ce({queryKey:["search",e],queryFn:()=>W.get("/api/admin/search",{q:e}),enabled:e.length>=2,staleTime:1e4})}function ab(e,t){const[n,s]=l.useState(e);return l.useEffect(()=>{const a=setTimeout(()=>s(e),t);return()=>clearTimeout(a)},[e,t]),n}function ob(){const{isOpen:e,close:t}=Xo(),n=Yo(g=>g.stop),s=Ct(),[a,o]=l.useState("search"),[c,i]=l.useState(""),[f,u]=l.useState(""),d=ab(c,300);l.useEffect(()=>{e||(n(),o("search"))},[e,n]);const h=g=>{if(!g.startsWith("?"))return i(g);i(""),u(g.slice(1)),o("ask")},{data:m}=sb(d),x=l.useCallback(g=>{t(),g()},[t]);return r.jsx(Hs,{open:e,onOpenChange:g=>!g&&t(),children:r.jsxs($r,{className:"max-w-2xl gap-0 overflow-hidden p-0 shadow-2xl","aria-describedby":void 0,children:[r.jsx(Ur,{className:"sr-only",children:"Search or ask"}),r.jsxs(Br,{value:a,onValueChange:g=>o(g),children:[r.jsxs(or,{className:"mx-3 mt-3",children:[r.jsx(Te,{value:"search","data-testid":P("search","tab","search"),children:"Search"}),r.jsx(Te,{value:"ask","data-testid":P("search","tab","ask"),children:"Ask"})]}),r.jsx(Ue,{value:"search",className:"mt-0",children:r.jsxs(zd,{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:[r.jsx(Ld,{placeholder:"Search orders, products, customers... (? to ask)",value:c,onValueChange:h,"data-testid":P("search","input")}),r.jsxs(Fd,{"data-testid":P("search"),children:[r.jsx($d,{children:d.length<2?r.jsx("span",{className:"text-zinc-400",children:"Type at least 2 characters to search"}):r.jsxs("span",{children:['No results for "',d,'"']})}),(m==null?void 0:m.orders)&&m.orders.length>0&&r.jsx(us,{heading:"Orders",children:m.orders.slice(0,5).map(g=>r.jsxs(fs,{value:`order-${g.orderNumber}`,onSelect:()=>x(()=>s(`/orders/${g.orderNumber}`)),children:[r.jsx(Gn,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"font-mono text-sm font-medium",children:["#",g.orderNumber]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))}),(m==null?void 0:m.products)&&m.products.length>0&&r.jsxs(r.Fragment,{children:[m.orders&&m.orders.length>0&&r.jsx(ro,{}),r.jsx(us,{heading:"Products",children:m.products.slice(0,5).map(g=>r.jsxs(fs,{value:`product-${g.id}`,onSelect:()=>x(()=>s(`/products/${g.slug}`)),children:[r.jsx(qt,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsx("span",{className:"text-sm font-medium truncate",children:g.name}),r.jsx("span",{className:"text-xs text-zinc-500 capitalize",children:g.status})]})]},g.id))})]}),(m==null?void 0:m.customers)&&m.customers.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(ro,{}),r.jsx(us,{heading:"Customers",children:m.customers.slice(0,5).map(g=>r.jsxs(fs,{value:`customer-${g.id}`,onSelect:()=>x(()=>s(`/customers/${g.id}`)),children:[r.jsx(So,{className:"h-4 w-4 text-zinc-400 shrink-0"}),r.jsxs("div",{className:"flex flex-col min-w-0",children:[r.jsxs("span",{className:"text-sm font-medium",children:[g.firstName," ",g.lastName]}),r.jsx("span",{className:"text-xs text-zinc-500 truncate",children:g.email})]})]},g.id))})]})]})]})}),r.jsx(Ue,{value:"ask",className:"mt-0",children:r.jsx(rb,{draft:f,onDraftChange:u})})]})]})})}function ib(){const{open:e}=Xo();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]),r.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":P("search","trigger"),children:[r.jsx(tr,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:"Search"}),r.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:[r.jsx("span",{children:"⌘"}),"K"]})]})}const Zo=["orders","list"],nn=e=>e===void 0;function cu(e,t){return nn(e.status)||e.status===t.status}function cb(e,t){return cu(e,t)&&nn(e.q)&&nn(e.dateFrom)&&nn(e.dateTo)&&nn(e.customer)&&(nn(e.offset)||e.offset===0)&&(nn(e.sort)||e.sort==="createdAt:desc")}function lb(e,t){for(const n of e.getQueryCache().findAll({queryKey:Zo})){const s=n.queryKey[2]??{};if(!cu(s,t))continue;const a={queryKey:n.queryKey,exact:!0},o=n.state.fetchStatus==="fetching"?e.cancelQueries(a):void 0,c=e.getQueryData(n.queryKey),i=c!==void 0&&cb(s,t);if(i){const f=[t,...c.filter(u=>u.id!==t.id)];e.setQueryData(n.queryKey,f.slice(0,s.limit??f.length))}o?o.then(()=>e.invalidateQueries(a)):i||e.invalidateQueries(a)}}const db=[Zo,["orders","detail"],["dashboard"],["inventory","list"],["proposals"]];async function ub(e){await Promise.all(db.map(async t=>{await e.cancelQueries({queryKey:t}),e.invalidateQueries({queryKey:t})}))}function fb(e){const t=dd.getState().pushNotification;function n(s){switch(s.type){case"order.placed.v1":{const{order:a}=s.payload;lb(e,a),e.invalidateQueries({queryKey:["dashboard"]}),t({type:"info",title:"New Order",message:`Order #${a.orderNumber} placed by ${a.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:Zo}),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:a,currentQty:o,threshold:c}=s.payload;t({type:"warning",title:"Low Stock Alert",message:`Variant ${a} is running low: ${o} left (threshold ${c})`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"inventory.out_of_stock.v1":{t({type:"error",title:"Out of Stock",message:`Variant ${s.payload.variantId} is out of stock`}),e.invalidateQueries({queryKey:["inventory","list"]});break}case"payment.failed.v1":{const{orderId:a,reason:o}=s.payload;t({type:"error",title:"Payment Failed",message:`Payment failed for order ${a}: ${o}`});break}case"proposal.created.v1":{e.invalidateQueries({queryKey:["proposals"]}),t({type:"info",title:"Inbox",message:`Agent proposal: ${s.payload.command}`});break}case"proposal.approved.v1":case"proposal.rejected.v1":case"proposal.applied.v1":case"proposal.failed.v1":{e.invalidateQueries({queryKey:["proposals"]});break}case"adapter.error.v1":{const{adapterType:a,adapterName:o,error:c}=s.payload;t({type:"error",title:"Adapter Error",message:`${a} adapter ${o}: ${c.message}`});break}}}return function(a,o){n({type:a,payload:o})}}const jr=Us(e=>({events:[],connected:!1,setConnected:t=>e({connected:t}),pushEvent:(t,n)=>{const s={id:crypto.randomUUID(),type:t,label:n,at:new Date().toISOString()};e(a=>({events:[s,...a.events].slice(0,20)}))}}));function hb(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 lc(){const e=jr(t=>t.connected);return r.jsxs("span",{className:"flex items-center gap-1.5 shrink-0","data-testid":P("topbar","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-2 w-2 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),r.jsx("span",{className:"font-medium text-[10px] uppercase tracking-wider text-zinc-400",children:e?"Live":"Offline"})]})}function mb(){const e=jr(s=>s.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?r.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx(lc,{}),r.jsx("span",{className:"text-zinc-300",children:"—"}),r.jsx("span",{className:"text-zinc-400",children:"No recent events"})]}):r.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",ref:t,children:[r.jsx(lc,{}),r.jsx("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:n.map(s=>r.jsx("span",{className:T("flex shrink-0 items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium whitespace-nowrap",hb(s.type)),children:s.label},s.id))})]})}function pb({navOpen:e,onToggleNav:t}){return r.jsxs(r.Fragment,{children:[r.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:[r.jsx("button",{type:"button","data-testid":P("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:r.jsx(Vp,{className:"h-5 w-5"})}),r.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:r.jsx(Kx,{})}),r.jsx("div",{className:"mx-8 hidden flex-1 items-center justify-center overflow-hidden md:flex",children:r.jsx(mb,{})}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(ib,{}),r.jsx(U0,{})]})]}),r.jsx(ob,{})]})}const dc=[1e3,2e3,5e3,1e4,3e4];function xb(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&"payload"in t)return t.payload}catch{}}function gb(e,t={}){let n=null,s=0,a=null,o=!1;async function c(){return(await W.post("/api/admin/events/ticket")).ticket}function i(){if(o)return;const u=dc[Math.min(s,dc.length-1)]??3e4;s++,a=setTimeout(()=>{f()},u)}async function f(){var u;if(!o)try{const d=await c();if(o)return;n=new EventSource(`/api/admin/events?ticket=${encodeURIComponent(d)}`),n.onopen=()=>{s=0},n.addEventListener("connected",()=>{var h;(h=t.onConnected)==null||h.call(t)});for(const h of ip)n.addEventListener(h,m=>{const x=xb(m.data);x!==void 0&&e(h,x)});n.onerror=()=>{var h;n==null||n.close(),n=null,!o&&((h=t.onDisconnected)==null||h.call(t),i())}}catch{if(o)return;(u=t.onDisconnected)==null||u.call(t),i()}}return{connect(){o=!1,f()},disconnect(){o=!0,a!==null&&(clearTimeout(a),a=null),n==null||n.close(),n=null}}}function vb(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"order.confirmation_resend_requested.v1":return"Confirmation resend queued";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 yb({children:e}){const t=ye(),n=l.useRef(null),s=jr(o=>o.pushEvent),a=jr(o=>o.setConnected);return l.useEffect(()=>{if(!gs())return;const o=fb(t),c=gb((i,f)=>{o(i,f),s(i,vb({type:i,payload:f}))},{onConnected:()=>{a(!0),ub(t)},onDisconnected:()=>a(!1)});return n.current=c,c.connect(),()=>{c.disconnect(),n.current=null,a(!1)}},[t,s,a]),r.jsx(r.Fragment,{children:e})}function bb(){const[e,t]=l.useState(!1);return r.jsx(yb,{children:r.jsxs("div",{className:"min-h-screen bg-zinc-100",children:[e&&r.jsx("div",{"aria-hidden":"true",className:"fixed inset-0 z-40 bg-zinc-950/50 md:hidden",onClick:()=>t(!1)}),r.jsx(Bx,{open:e,onClose:()=>t(!1)}),r.jsx(pb,{navOpen:e,onToggleNav:()=>t(n=>!n)}),r.jsx("main",{className:"md:ml-60 pt-14 min-h-screen",children:r.jsx("div",{className:"p-6",children:r.jsx(hh,{})})})]})})}const pe=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:T("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:s,...n}));pe.displayName="Input";var wb="Label",lu=l.forwardRef((e,t)=>r.jsx(Rt.label,{...e,ref:t,onMouseDown:n=>{var a;n.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));lu.displayName=wb;var du=lu;const jb=As("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ee=l.forwardRef(({className:e,...t},n)=>r.jsx(du,{ref:n,className:T(jb(),e),...t}));Ee.displayName=du.displayName;function Nb({size:e="md",className:t}){return r.jsx("div",{className:T("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 Cb(){const{login:e}=ol(),[t,n]=l.useState(""),[s,a]=l.useState(""),[o,c]=l.useState(null),[i,f]=l.useState(!1),u=async d=>{d.preventDefault(),c(null),f(!0);try{await e(t,s)}catch(h){c(h instanceof Error?h.message:"Login failed")}finally{f(!1)}};return r.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4",children:[r.jsx("div",{className:"pointer-events-none fixed inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #fff 1px, transparent 1px)",backgroundSize:"24px 24px"}}),r.jsxs("div",{className:"relative w-full max-w-sm",children:[r.jsxs("div",{className:"mb-8 flex flex-col items-center gap-3",children:[r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-blue-600 shadow-lg shadow-blue-500/20",children:r.jsx("span",{className:"text-xl font-bold text-white",children:"N"})}),r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-xl font-bold tracking-widest text-zinc-100 uppercase",children:"Nymbal"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Admin Dashboard"})]})]}),r.jsxs("div",{className:"rounded-xl border border-zinc-800 bg-zinc-900 p-6 shadow-2xl",children:[r.jsx("h2",{className:"mb-1 text-base font-semibold text-zinc-100",children:"Sign in"}),r.jsx("p",{className:"mb-6 text-sm text-zinc-500",children:"Enter your admin credentials"}),r.jsxs("form",{onSubmit:d=>void u(d),"data-testid":P("login","form"),className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-zinc-300 text-xs",children:"Email"}),r.jsx(pe,{type:"email",value:t,onChange:d=>n(d.target.value),placeholder:"admin@yourstore.com",autoComplete:"email",required:!0,disabled:i,"data-testid":P("login","email"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-zinc-300 text-xs",children:"Password"}),r.jsx(pe,{type:"password",value:s,onChange:d=>a(d.target.value),placeholder:"••••••••",autoComplete:"current-password",required:!0,disabled:i,"data-testid":P("login","password"),className:"bg-zinc-800 border-zinc-700 text-zinc-100 placeholder:text-zinc-600 focus:ring-blue-500 focus:border-blue-500"})]}),o&&r.jsx("div",{role:"alert","data-testid":P("login","error"),className:"rounded-md border border-red-800/50 bg-red-900/20 px-3 py-2 text-sm text-red-400",children:o}),r.jsx(se,{type:"submit",className:"w-full",disabled:i||!t||!s,"data-testid":P("login","submit"),children:i?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Nb,{size:"sm",className:"border-blue-200 border-t-white"}),"Signing in..."]}):"Sign in"})]})]}),r.jsx("p",{className:"mt-4 text-center text-xs text-zinc-600",children:"Nymbal Admin · Precision Workspace"})]})]})}function xe({className:e,...t}){return r.jsx("div",{className:T("animate-pulse rounded-md bg-zinc-200",e),...t})}const Sb={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"},Eb={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Part. Refunded"};function Xn({status:e,size:t="md",className:n,"data-testid":s}){return r.jsx("span",{"data-testid":s,className:T("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",Sb[e],n),children:Eb[e]})}function We({icon:e,title:t,description:n,action:s,className:a}){return r.jsxs("div",{className:T("flex flex-col items-center justify-center py-16 px-4 text-center",a),children:[e&&r.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-zinc-100 text-zinc-400",children:e}),r.jsx("h3",{className:"text-sm font-medium text-zinc-900",children:t}),n&&r.jsx("p",{className:"mt-1 text-sm text-zinc-500",children:n}),s&&r.jsx("div",{className:"mt-4",children:s})]})}function Rb(){return Ce({queryKey:["dashboard"],queryFn:()=>W.get("/api/admin/dashboard"),refetchInterval:6e4})}function Pb(){const e=jr(t=>t.connected);return r.jsxs("span",{className:T("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider",e?"bg-green-50 border-green-200 text-green-600":"bg-zinc-50 border-zinc-200 text-zinc-500"),"data-testid":P("dashboard","live"),"data-state":e?"live":"offline",children:[r.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e&&r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),r.jsx("span",{className:T("relative inline-flex h-1.5 w-1.5 rounded-full",e?"bg-green-500":"bg-zinc-300")})]}),e?"Live":"Offline"]})}function Sa({icon:e,label:t,value:n,subtext:s,loading:a,color:o="blue"}){const c={blue:"bg-blue-50 text-blue-600",green:"bg-green-50 text-green-600",violet:"bg-violet-50 text-violet-600"};return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsx("div",{className:T("flex h-9 w-9 items-center justify-center rounded-lg",c[o]),children:e}),r.jsx(Ga,{className:"h-4 w-4 text-zinc-300"})]}),a?r.jsxs(r.Fragment,{children:[r.jsx(xe,{className:"h-7 w-24 mb-1"}),r.jsx(xe,{className:"h-3.5 w-16"})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900",children:n}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:t}),s&&r.jsx("p",{className:"mt-1 text-[11px] text-zinc-400",children:s})]})]})}function kb({search:e,lookup:t,checkout:n}){return[...e?["search"]:[],...t?["lookup"]:[],...n==="none"?[]:[`checkout ${n}`]]}function Tb({agents:e,loading:t}){return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5","data-testid":P("dashboard","agents"),children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-50 text-amber-600",children:r.jsx(Ep,{className:"h-4.5 w-4.5"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Agents"}),r.jsx("p",{className:"text-xs text-zinc-500",children:"Orders shopping agents brought, last 30 days"})]})]}),t||e===void 0?r.jsx(xe,{className:"h-16 w-full"}):r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-semibold font-mono text-zinc-900","data-testid":P("dashboard","agents","orders"),children:e.orders.count}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Agent orders"}),r.jsx("p",{className:"mt-2 font-mono text-sm text-zinc-900","data-testid":P("dashboard","agents","revenue"),"data-minor":e.orders.revenueMinor,children:me(e.orders.revenueMinor,e.currency)}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"Revenue"})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"By agent"}),e.bySource.length===0?r.jsx("p",{className:"text-xs text-zinc-500",children:"No agent orders yet"}):r.jsx("ul",{className:"space-y-1 text-xs",children:e.bySource.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":P("dashboard","agents","source"),"data-source":n.source,"data-count":n.count,"data-minor":n.revenueMinor,children:[r.jsx("span",{className:"truncate text-zinc-700",children:n.source.slice(6)}),r.jsxs("span",{className:"shrink-0 font-mono text-zinc-500",children:[n.count," · ",me(n.revenueMinor,e.currency)]})]},n.source))})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Surfaces"}),r.jsxs("ul",{className:"space-y-1 text-xs text-zinc-700",children:[e.surfaces.map(n=>r.jsxs("li",{"data-testid":P("dashboard","agents","surface",n.name),children:[r.jsx("span",{className:"font-medium uppercase",children:n.name}),":"," ",kb(n.capabilities).join(", ")]},n.name)),r.jsxs("li",{children:[r.jsx("span",{className:"font-medium uppercase",children:"MCP"}),":"," ",e.mcp.enabled?`on, ${e.mcp.writes}`:"off"]})]}),e.profilePath!==null&&r.jsx("a",{href:e.profilePath,className:"mt-2 inline-block text-xs font-medium text-blue-600 hover:text-blue-700",children:"Agent profile →"})]})]})]})}function Ab(){var o,c;const{data:e}=Eo(),{data:t,isLoading:n}=Rb(),s=Ct(),a="GBP";return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:(e==null?void 0:e.storeName)??"Dashboard"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Today's performance at a glance"})]}),r.jsx(Pb,{})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[r.jsx(Sa,{icon:r.jsx(Gn,{className:"h-4.5 w-4.5"}),label:"Orders today",value:String((t==null?void 0:t.today.orderCount)??0),loading:n,color:"blue"}),r.jsx(Sa,{icon:r.jsx(Ip,{className:"h-4.5 w-4.5"}),label:"Revenue today",value:t?Xy(t.today.revenueMinor,a):"—",subtext:t?me(t.today.revenueMinor,a):void 0,loading:n,color:"green"}),r.jsx(Sa,{icon:r.jsx(al,{className:"h-4.5 w-4.5"}),label:"Items shipped",value:String((t==null?void 0:t.today.itemsShipped)??0),loading:n,color:"violet"})]}),r.jsx(Tb,{agents:t==null?void 0:t.agents,loading:n}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Recent Orders"}),r.jsx("button",{onClick:()=>s("/orders"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"View all →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:5}).map((i,f)=>r.jsx(xe,{className:"h-11 w-full"},f))}):(o=t==null?void 0:t.recentOrders)!=null&&o.length?r.jsx("div",{className:"overflow-x-auto",role:"region",tabIndex:0,"aria-label":"Recent orders","data-testid":P("dashboard","recent-orders"),children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"border-b border-zinc-100",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Order"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsx("th",{className:"px-4 py-2.5 text-left text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Total"}),r.jsx("th",{className:"px-4 py-2.5 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-400",children:"Time"})]})}),r.jsx("tbody",{children:t.recentOrders.map(i=>r.jsxs("tr",{className:"cursor-pointer border-b border-zinc-50 last:border-0 hover:bg-zinc-50 transition-colors",onClick:()=>s(`/orders/${i.orderNumber}`),children:[r.jsx("td",{className:"px-4 py-2.5",children:r.jsxs("span",{className:"font-mono text-sm font-medium text-blue-600",children:["#",i.orderNumber]})}),r.jsx("td",{className:"px-4 py-2.5 text-zinc-600 truncate max-w-[160px]",children:i.email}),r.jsx("td",{className:"px-4 py-2.5",children:r.jsx(Xn,{status:i.status,size:"sm"})}),r.jsx("td",{className:"px-4 py-2.5 text-right font-mono text-sm text-zinc-700",children:me(i.totalMinor,i.currency)}),r.jsx("td",{className:"px-4 py-2.5 text-right text-xs text-zinc-400",children:ht(i.createdAt)})]},i.id))})]})}):r.jsx(We,{icon:r.jsx(Gn,{className:"h-5 w-5"}),title:"No orders yet",description:"Orders will appear here as they come in."})]})}),r.jsx("div",{children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Low Stock"}),(t==null?void 0:t.lowStock)&&t.lowStock.length>0&&r.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})]}),r.jsx("button",{onClick:()=>s("/inventory"),className:"text-xs text-blue-600 hover:text-blue-700 font-medium",children:"Manage →"})]}),n?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:4}).map((i,f)=>r.jsx(xe,{className:"h-10 w-full"},f))}):(c=t==null?void 0:t.lowStock)!=null&&c.length?r.jsx("div",{className:"divide-y divide-zinc-50",children:t.lowStock.map(i=>r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-zinc-50 transition-colors",onClick:()=>s("/inventory"),children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-xs font-medium text-zinc-700",children:i.productName}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:i.sku})]}),r.jsxs("div",{className:"ml-3 text-right",children:[r.jsx("span",{className:T("font-mono text-sm font-semibold",i.status==="out_of_stock"?"text-red-600":"text-amber-600"),children:i.stock}),r.jsxs("p",{className:"text-[10px] text-zinc-400",children:["/",i.threshold]})]})]},i.variantId))}):r.jsxs("div",{className:"p-6 text-center",children:[r.jsx("div",{className:"mx-auto mb-2 flex h-8 w-8 items-center justify-center rounded-full bg-green-50",children:r.jsx(vs,{className:"h-4 w-4 text-green-500"})}),r.jsx("p",{className:"text-xs text-zinc-500",children:"All stock levels are healthy"})]})]})})]})]})}const wn=l.forwardRef(({className:e,...t},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:T("w-full caption-bottom text-sm",e),...t})}));wn.displayName="Table";const jn=l.forwardRef(({className:e,...t},n)=>r.jsx("thead",{ref:n,className:T("[&_tr]:border-b [&_tr]:border-zinc-200",e),...t}));jn.displayName="TableHeader";const Nn=l.forwardRef(({className:e,...t},n)=>r.jsx("tbody",{ref:n,className:T("[&_tr:last-child]:border-0",e),...t}));Nn.displayName="TableBody";const Mb=l.forwardRef(({className:e,...t},n)=>r.jsx("tfoot",{ref:n,className:T("border-t border-zinc-200 bg-zinc-50/50 font-medium [&>tr]:last:border-b-0",e),...t}));Mb.displayName="TableFooter";const Be=l.forwardRef(({className:e,...t},n)=>r.jsx("tr",{ref:n,className:T("border-b border-zinc-100 transition-colors hover:bg-zinc-50/60 data-[state=selected]:bg-blue-50",e),...t}));Be.displayName="TableRow";const ne=l.forwardRef(({className:e,...t},n)=>r.jsx("th",{ref:n,className:T("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}));ne.displayName="TableHead";const re=l.forwardRef(({className:e,...t},n)=>r.jsx("td",{ref:n,className:T("h-11 px-4 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t}));re.displayName="TableCell";const _b=l.forwardRef(({className:e,...t},n)=>r.jsx("caption",{ref:n,className:T("mt-4 text-sm text-zinc-500",e),...t}));_b.displayName="TableCaption";function uu(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 Zs="Checkbox",[Ib]=ut(Zs),[Ob,Jo]=Ib(Zs);function Db(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:c,name:i,onCheckedChange:f,required:u,value:d="on",internal_do_not_use_render:h}=e,[m,x]=Gt({prop:n,defaultProp:a??!1,onChange:f,caller:Zs}),[g,p]=l.useState(null),[v,y]=l.useState(null),w=l.useRef(!1),N=g?!!c||!!g.closest("form"):!0,j={checked:m,disabled:o,setChecked:x,control:g,setControl:p,name:i,form:c,value:d,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:Bt(a)?!1:a,isFormControl:N,bubbleInput:v,setBubbleInput:y};return r.jsx(Ob,{scope:t,...j,children:zb(h)?h(j):s})}var fu="CheckboxTrigger",hu=l.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:c,disabled:i,checked:f,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:m,isFormControl:x,bubbleInput:g}=Jo(fu,e),p=de(a,d),v=l.useRef(f);return l.useEffect(()=>{const y=o==null?void 0:o.form;if(y){const w=()=>h(v.current);return y.addEventListener("reset",w),()=>y.removeEventListener("reset",w)}},[o,h]),r.jsx(G.button,{type:"button",role:"checkbox","aria-checked":Bt(f)?"mixed":f,"aria-required":u,"data-state":vu(f),"data-disabled":i?"":void 0,disabled:i,value:c,...s,ref:p,onKeyDown:D(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:D(n,y=>{h(w=>Bt(w)?!0:!w),g&&x&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})})});hu.displayName=fu;var ei=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:c,disabled:i,value:f,onCheckedChange:u,form:d,...h}=e;return r.jsx(Db,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:i,required:c,onCheckedChange:u,name:s,form:d,value:f,internal_do_not_use_render:({isFormControl:m})=>r.jsxs(r.Fragment,{children:[r.jsx(hu,{...h,ref:t,__scopeCheckbox:n}),m&&r.jsx(gu,{__scopeCheckbox:n})]})})});ei.displayName=Zs;var mu="CheckboxIndicator",pu=l.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=Jo(mu,n);return r.jsx(Ge,{present:s||Bt(o.checked)||o.checked===!0,children:r.jsx(G.span,{"data-state":vu(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});pu.displayName=mu;var xu="CheckboxBubbleInput",gu=l.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:c,required:i,disabled:f,name:u,value:d,form:h,bubbleInput:m,setBubbleInput:x}=Jo(xu,e),g=de(n,x),p=uu(o),v=Il(s);l.useEffect(()=>{const w=m;if(!w)return;const N=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(N,"checked").set,S=!a.current;if(p!==o&&C){const E=new Event("click",{bubbles:S});w.indeterminate=Bt(o),C.call(w,Bt(o)?!1:o),w.dispatchEvent(E)}},[m,p,o,a]);const y=l.useRef(Bt(o)?!1:o);return r.jsx(G.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??y.current,required:i,disabled:f,name:u,value:d,form:h,...t,tabIndex:-1,ref:g,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});gu.displayName=xu;function zb(e){return typeof e=="function"}function Bt(e){return e==="indeterminate"}function vu(e){return Bt(e)?"indeterminate":e?"checked":"unchecked"}const ao=l.forwardRef(({className:e,...t},n)=>r.jsx(ei,{ref:n,className:T("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:r.jsx(pu,{className:T("flex items-center justify-center text-current"),children:r.jsx(St,{className:"h-3 w-3",strokeWidth:3})})}));ao.displayName=ei.displayName;var oo=["Enter"," "],Lb=["ArrowDown","PageUp","Home"],yu=["ArrowUp","PageDown","End"],Fb=[...Lb,...yu],$b={ltr:[...oo,"ArrowRight"],rtl:[...oo,"ArrowLeft"]},Ub={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Kr="Menu",[Nr,Vb,Bb]=Go(Kr),[Cn,bu]=ut(Kr,[Bb,ar,Ys]),Js=ar(),wu=Ys(),[Kb,Sn]=Cn(Kr),[qb,qr]=Cn(Kr),ju=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:a,onOpenChange:o,modal:c=!0}=e,i=Js(t),[f,u]=l.useState(null),d=l.useRef(!1),h=dt(o),m=Qs(a);return l.useEffect(()=>{const x=()=>{d.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>d.current=!1;return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),r.jsx(Do,{...i,children:r.jsx(Kb,{scope:t,open:n,onOpenChange:h,content:f,onContentChange:u,children:r.jsx(qb,{scope:t,onClose:l.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:c,children:s})})})};ju.displayName=Kr;var Hb="MenuAnchor",ti=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=Js(n);return r.jsx(zs,{...a,...s,ref:t})});ti.displayName=Hb;var ni="MenuPortal",[Wb,Nu]=Cn(ni,{forceMount:void 0}),Cu=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:a}=e,o=Sn(ni,t);return r.jsx(Wb,{scope:t,forceMount:n,children:r.jsx(Ge,{present:n||o.open,children:r.jsx(Dr,{asChild:!0,container:a,children:s})})})};Cu.displayName=ni;var He="MenuContent",[Gb,ri]=Cn(He),Su=l.forwardRef((e,t)=>{const n=Nu(He,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(He,e.__scopeMenu),c=qr(He,e.__scopeMenu);return r.jsx(Nr.Provider,{scope:e.__scopeMenu,children:r.jsx(Ge,{present:s||o.open,children:r.jsx(Nr.Slot,{scope:e.__scopeMenu,children:c.modal?r.jsx(Qb,{...a,ref:t}):r.jsx(Yb,{...a,ref:t})})})})}),Qb=l.forwardRef((e,t)=>{const n=Sn(He,e.__scopeMenu),s=l.useRef(null),a=de(t,s);return l.useEffect(()=>{const o=s.current;if(o)return Ls(o)},[]),r.jsx(si,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:D(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yb=l.forwardRef((e,t)=>{const n=Sn(He,e.__scopeMenu);return r.jsx(si,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xb=pn("MenuContent.ScrollLock"),si=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:i,onEntryFocus:f,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,disableOutsideScroll:g,...p}=e,v=Sn(He,n),y=qr(He,n),w=Js(n),N=wu(n),j=Vb(n),[C,S]=l.useState(null),E=l.useRef(null),k=de(t,E,v.onContentChange),z=l.useRef(0),O=l.useRef(""),U=l.useRef(0),I=l.useRef(null),Q=l.useRef("right"),V=l.useRef(0),Z=g?zr:l.Fragment,B=g?{as:Xb,allowPinchZoom:!0}:void 0,ae=A=>{var M,Y;const ce=O.current+A,le=j().filter(X=>!X.disabled),R=document.activeElement,K=(M=le.find(X=>X.ref.current===R))==null?void 0:M.textValue,H=le.map(X=>X.textValue),L=lw(H,ce,K),J=(Y=le.find(X=>X.textValue===L))==null?void 0:Y.ref.current;(function X(ie){O.current=ie,window.clearTimeout(z.current),ie!==""&&(z.current=window.setTimeout(()=>X(""),1e3))})(ce),J&&setTimeout(()=>J.focus())};l.useEffect(()=>()=>window.clearTimeout(z.current),[]),Ms();const F=l.useCallback(A=>{var le,R;return Q.current===((le=I.current)==null?void 0:le.side)&&uw(A,(R=I.current)==null?void 0:R.area)},[]);return r.jsx(Gb,{scope:n,searchRef:O,onItemEnter:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),onItemLeave:l.useCallback(A=>{var ce;F(A)||((ce=E.current)==null||ce.focus(),S(null))},[F]),onTriggerLeave:l.useCallback(A=>{F(A)&&A.preventDefault()},[F]),pointerGraceTimerRef:U,onPointerGraceIntentChange:l.useCallback(A=>{I.current=A},[]),children:r.jsx(Z,{...B,children:r.jsx(Ir,{asChild:!0,trapped:a,onMountAutoFocus:D(o,A=>{var ce;A.preventDefault(),(ce=E.current)==null||ce.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:x,children:r.jsx(Hd,{asChild:!0,...N,dir:y.dir,orientation:"vertical",loop:s,currentTabStopId:C,onCurrentTabStopIdChange:S,onEntryFocus:D(f,A=>{y.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(zo,{role:"menu","aria-orientation":"vertical","data-state":Uu(v.open),"data-radix-menu-content":"",dir:y.dir,...w,...p,ref:k,style:{outline:"none",...p.style},onKeyDown:D(p.onKeyDown,A=>{const le=A.target.closest("[data-radix-menu-content]")===A.currentTarget,R=A.ctrlKey||A.altKey||A.metaKey,K=A.key.length===1;le&&(A.key==="Tab"&&A.preventDefault(),!R&&K&&ae(A.key));const H=E.current;if(A.target!==H||!Fb.includes(A.key))return;A.preventDefault();const J=j().filter(M=>!M.disabled).map(M=>M.ref.current);yu.includes(A.key)&&J.reverse(),iw(J)}),onBlur:D(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(z.current),O.current="")}),onPointerMove:D(e.onPointerMove,Cr(A=>{const ce=A.target,le=V.current!==A.clientX;if(A.currentTarget.contains(ce)&&le){const R=A.clientX>V.current?"right":"left";Q.current=R,V.current=A.clientX}}))})})})})})})});Su.displayName=He;var Zb="MenuGroup",ai=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"group",...s,ref:t})});ai.displayName=Zb;var Jb="MenuLabel",Eu=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{...s,ref:t})});Eu.displayName=Jb;var Ss="MenuItem",uc="menu.itemSelect",ea=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...a}=e,o=l.useRef(null),c=qr(Ss,e.__scopeMenu),i=ri(Ss,e.__scopeMenu),f=de(t,o),u=l.useRef(!1),d=()=>{const h=o.current;if(!n&&h){const m=new CustomEvent(uc,{bubbles:!0,cancelable:!0});h.addEventListener(uc,x=>s==null?void 0:s(x),{once:!0}),vl(h,m),m.defaultPrevented?u.current=!1:c.onClose()}};return r.jsx(Ru,{...a,ref:f,disabled:n,onClick:D(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:D(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:D(e.onKeyDown,h=>{const m=i.searchRef.current!=="";n||m&&h.key===" "||oo.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ea.displayName=Ss;var Ru=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:a,...o}=e,c=ri(Ss,n),i=wu(n),f=l.useRef(null),u=de(t,f),[d,h]=l.useState(!1),[m,x]=l.useState("");return l.useEffect(()=>{const g=f.current;g&&x((g.textContent??"").trim())},[o.children]),r.jsx(Nr.ItemSlot,{scope:n,disabled:s,textValue:a??m,children:r.jsx(Wd,{asChild:!0,...i,focusable:!s,children:r.jsx(G.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...o,ref:u,onPointerMove:D(e.onPointerMove,Cr(g=>{s?c.onItemLeave(g):(c.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:D(e.onPointerLeave,Cr(g=>c.onItemLeave(g))),onFocus:D(e.onFocus,()=>h(!0)),onBlur:D(e.onBlur,()=>h(!1))})})})}),ew="MenuCheckboxItem",Pu=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...a}=e;return r.jsx(_u,{scope:e.__scopeMenu,checked:n,children:r.jsx(ea,{role:"menuitemcheckbox","aria-checked":Es(n)?"mixed":n,...a,ref:t,"data-state":ii(n),onSelect:D(a.onSelect,()=>s==null?void 0:s(Es(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Pu.displayName=ew;var ku="MenuRadioGroup",[tw,nw]=Cn(ku,{value:void 0,onValueChange:()=>{}}),Tu=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...a}=e,o=dt(s);return r.jsx(tw,{scope:e.__scopeMenu,value:n,onValueChange:o,children:r.jsx(ai,{...a,ref:t})})});Tu.displayName=ku;var Au="MenuRadioItem",Mu=l.forwardRef((e,t)=>{const{value:n,...s}=e,a=nw(Au,e.__scopeMenu),o=n===a.value;return r.jsx(_u,{scope:e.__scopeMenu,checked:o,children:r.jsx(ea,{role:"menuitemradio","aria-checked":o,...s,ref:t,"data-state":ii(o),onSelect:D(s.onSelect,()=>{var c;return(c=a.onValueChange)==null?void 0:c.call(a,n)},{checkForDefaultPrevented:!1})})})});Mu.displayName=Au;var oi="MenuItemIndicator",[_u,rw]=Cn(oi,{checked:!1}),Iu=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...a}=e,o=rw(oi,n);return r.jsx(Ge,{present:s||Es(o.checked)||o.checked===!0,children:r.jsx(G.span,{...a,ref:t,"data-state":ii(o.checked)})})});Iu.displayName=oi;var sw="MenuSeparator",Ou=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(G.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Ou.displayName=sw;var aw="MenuArrow",Du=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,a=Js(n);return r.jsx(Lo,{...a,...s,ref:t})});Du.displayName=aw;var ow="MenuSub",[R1,zu]=Cn(ow),xr="MenuSubTrigger",Lu=l.forwardRef((e,t)=>{const n=Sn(xr,e.__scopeMenu),s=qr(xr,e.__scopeMenu),a=zu(xr,e.__scopeMenu),o=ri(xr,e.__scopeMenu),c=l.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:f}=o,u={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const h=i.current;return()=>{window.clearTimeout(h),f(null)}},[i,f]),r.jsx(ti,{asChild:!0,...u,children:r.jsx(Ru,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":Uu(n.open),...e,ref:lt(t,a.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:D(e.onPointerMove,Cr(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:D(e.onPointerLeave,Cr(h=>{var x,g;d();const m=(x=n.content)==null?void 0:x.getBoundingClientRect();if(m){const p=(g=n.content)==null?void 0:g.dataset.side,v=p==="right",y=v?-5:5,w=m[v?"left":"right"],N=m[v?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:N,y:m.top},{x:N,y:m.bottom},{x:w,y:m.bottom}],side:p}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:D(e.onKeyDown,h=>{var x;const m=o.searchRef.current!=="";e.disabled||m&&h.key===" "||$b[s.dir].includes(h.key)&&(n.onOpenChange(!0),(x=n.content)==null||x.focus(),h.preventDefault())})})})});Lu.displayName=xr;var Fu="MenuSubContent",$u=l.forwardRef((e,t)=>{const n=Nu(He,e.__scopeMenu),{forceMount:s=n.forceMount,...a}=e,o=Sn(He,e.__scopeMenu),c=qr(He,e.__scopeMenu),i=zu(Fu,e.__scopeMenu),f=l.useRef(null),u=de(t,f);return r.jsx(Nr.Provider,{scope:e.__scopeMenu,children:r.jsx(Ge,{present:s||o.open,children:r.jsx(Nr.Slot,{scope:e.__scopeMenu,children:r.jsx(si,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;c.isUsingKeyboardRef.current&&((h=f.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:D(e.onFocusOutside,d=>{d.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:D(e.onEscapeKeyDown,d=>{c.onClose(),d.preventDefault()}),onKeyDown:D(e.onKeyDown,d=>{var x;const h=d.currentTarget.contains(d.target),m=Ub[c.dir].includes(d.key);h&&m&&(o.onOpenChange(!1),(x=i.trigger)==null||x.focus(),d.preventDefault())})})})})})});$u.displayName=Fu;function Uu(e){return e?"open":"closed"}function Es(e){return e==="indeterminate"}function ii(e){return Es(e)?"indeterminate":e?"checked":"unchecked"}function iw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function cw(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function lw(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=cw(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function dw(e,t){const{x:n,y:s}=e;let a=!1;for(let o=0,c=t.length-1;o<t.length;c=o++){const i=t[o],f=t[c],u=i.x,d=i.y,h=f.x,m=f.y;d>s!=m>s&&n<(h-u)*(s-d)/(m-d)+u&&(a=!a)}return a}function uw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return dw(n,t)}function Cr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var fw=ju,hw=ti,mw=Cu,pw=Su,xw=ai,gw=Eu,vw=ea,yw=Pu,bw=Tu,ww=Mu,jw=Iu,Nw=Ou,Cw=Du,Sw=Lu,Ew=$u,ta="DropdownMenu",[Rw]=ut(ta,[bu]),Me=bu(),[Pw,Vu]=Rw(ta),Bu=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:a,defaultOpen:o,onOpenChange:c,modal:i=!0}=e,f=Me(t),u=l.useRef(null),[d,h]=Gt({prop:a,defaultProp:o??!1,onChange:c,caller:ta});return r.jsx(Pw,{scope:t,triggerId:Ne(),triggerRef:u,contentId:Ne(),open:d,onOpenChange:h,onOpenToggle:l.useCallback(()=>h(m=>!m),[h]),modal:i,children:r.jsx(fw,{...f,open:d,onOpenChange:h,dir:s,modal:i,children:n})})};Bu.displayName=ta;var Ku="DropdownMenuTrigger",qu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...a}=e,o=Vu(Ku,n),c=Me(n);return r.jsx(hw,{asChild:!0,...c,children:r.jsx(G.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...a,ref:lt(t,o.triggerRef),onPointerDown:D(e.onPointerDown,i=>{!s&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:D(e.onKeyDown,i=>{s||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});qu.displayName=Ku;var kw="DropdownMenuPortal",Hu=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Me(t);return r.jsx(mw,{...s,...n})};Hu.displayName=kw;var Wu="DropdownMenuContent",Gu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Vu(Wu,n),o=Me(n),c=l.useRef(!1);return r.jsx(pw,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...s,ref:t,onCloseAutoFocus:D(e.onCloseAutoFocus,i=>{var f;c.current||(f=a.triggerRef.current)==null||f.focus(),c.current=!1,i.preventDefault()}),onInteractOutside:D(e.onInteractOutside,i=>{const f=i.detail.originalEvent,u=f.button===0&&f.ctrlKey===!0,d=f.button===2||u;(!a.modal||d)&&(c.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Gu.displayName=Wu;var Tw="DropdownMenuGroup",Aw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(xw,{...a,...s,ref:t})});Aw.displayName=Tw;var Mw="DropdownMenuLabel",Qu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(gw,{...a,...s,ref:t})});Qu.displayName=Mw;var _w="DropdownMenuItem",Yu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(vw,{...a,...s,ref:t})});Yu.displayName=_w;var Iw="DropdownMenuCheckboxItem",Xu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(yw,{...a,...s,ref:t})});Xu.displayName=Iw;var Ow="DropdownMenuRadioGroup",Dw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(bw,{...a,...s,ref:t})});Dw.displayName=Ow;var zw="DropdownMenuRadioItem",Zu=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(ww,{...a,...s,ref:t})});Zu.displayName=zw;var Lw="DropdownMenuItemIndicator",Ju=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(jw,{...a,...s,ref:t})});Ju.displayName=Lw;var Fw="DropdownMenuSeparator",ef=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Nw,{...a,...s,ref:t})});ef.displayName=Fw;var $w="DropdownMenuArrow",Uw=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Cw,{...a,...s,ref:t})});Uw.displayName=$w;var Vw="DropdownMenuSubTrigger",tf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Sw,{...a,...s,ref:t})});tf.displayName=Vw;var Bw="DropdownMenuSubContent",nf=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,a=Me(n);return r.jsx(Ew,{...a,...s,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)"}})});nf.displayName=Bw;var Kw=Bu,qw=qu,Hw=Hu,rf=Gu,sf=Qu,af=Yu,of=Xu,cf=Zu,lf=Ju,df=ef,uf=tf,ff=nf;const ci=Kw,li=qw,Ww=l.forwardRef(({className:e,inset:t,children:n,...s},a)=>r.jsxs(uf,{ref:a,className:T("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),...s,children:[n,r.jsx(Jc,{className:"ml-auto"})]}));Ww.displayName=uf.displayName;const Gw=l.forwardRef(({className:e,...t},n)=>r.jsx(ff,{ref:n,className:T("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}));Gw.displayName=ff.displayName;const na=l.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(Hw,{children:r.jsx(rf,{ref:s,sideOffset:t,className:T("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})}));na.displayName=rf.displayName;const bt=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(af,{ref:s,className:T("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}));bt.displayName=af.displayName;const Qw=l.forwardRef(({className:e,children:t,checked:n=!1,...s},a)=>r.jsxs(of,{ref:a,className:T("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,...s,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(lf,{children:r.jsx(St,{className:"h-4 w-4"})})}),t]}));Qw.displayName=of.displayName;const Yw=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(cf,{ref:s,className:T("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:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(lf,{children:r.jsx(Ap,{className:"h-2 w-2 fill-current"})})}),t]}));Yw.displayName=cf.displayName;const Xw=l.forwardRef(({className:e,inset:t,...n},s)=>r.jsx(sf,{ref:s,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",t&&"pl-8",e),...n}));Xw.displayName=sf.displayName;const ra=l.forwardRef(({className:e,...t},n)=>r.jsx(df,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));ra.displayName=df.displayName;const Zw=[{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"}],Jw={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"};function ej(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),[o,c]=l.useState(new Set),{data:i,isLoading:f}=il({status:t==="all"?void 0:t,q:s||void 0,sort:"createdAt:desc",limit:100}),u=m=>{c(x=>{const g=new Set(x);return g.has(m)?g.delete(m):g.add(m),g})},d=()=>{i&&(o.size===i.length?c(new Set):c(new Set(i.map(m=>m.id))))},h=i?o.size===i.length&&i.length>0:!1;return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Orders"}),r.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} orders`:"Loading..."})]})}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:Zw.map(m=>r.jsx("button",{onClick:()=>n(m.value),className:T("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))}),r.jsxs("div",{className:"flex flex-1 items-center gap-2 sm:justify-end",children:[r.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search orders...",value:s,onChange:m=>a(m.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsxs(se,{variant:"outline",size:"sm",className:"gap-1.5",children:[r.jsx(Dp,{className:"h-3.5 w-3.5"}),"Filter"]})]})]}),o.size>0&&r.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-blue-200 bg-blue-50 px-4 py-2.5",children:[r.jsxs("span",{className:"text-sm font-medium text-blue-700",children:[o.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[r.jsxs(se,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-blue-200 text-blue-700 hover:bg-blue-100",children:[r.jsx(Pp,{className:"h-3.5 w-3.5"}),"Confirm All"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"h-7 gap-1.5 text-xs border-red-200 text-red-600 hover:bg-red-50",children:[r.jsx(sl,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{className:"w-10 pl-4",children:r.jsx(ao,{checked:h,onCheckedChange:d,"aria-label":"Select all"})}),r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Customer"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Payment"}),r.jsx(ne,{className:"text-center",children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"}),r.jsx(ne,{className:"w-10",children:r.jsx("span",{className:"sr-only",children:"Actions"})})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Be,{"data-testid":P("orders","row",m.orderNumber),"data-state":o.has(m.id)?"selected":void 0,className:T("cursor-pointer",o.has(m.id)&&"bg-blue-50/50"),children:[r.jsx(re,{className:"pl-4",onClick:x=>x.stopPropagation(),children:r.jsx(ao,{checked:o.has(m.id),onCheckedChange:()=>u(m.id),"aria-label":`Select order ${m.orderNumber}`})}),r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:["#",m.orderNumber]}),r.jsx(re,{className:"text-zinc-600 cursor-pointer",onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx("div",{className:"truncate max-w-[180px]",children:m.email})}),r.jsx(re,{onClick:()=>e(`/orders/${m.orderNumber}`),children:r.jsx(Xn,{status:m.status})}),r.jsx(re,{className:"text-sm text-zinc-600",onClick:()=>e(`/orders/${m.orderNumber}`),"data-testid":P("orders","payment",m.orderNumber),children:Jw[am(m)]}),r.jsx(re,{className:"text-center text-zinc-500",onClick:()=>e(`/orders/${m.orderNumber}`),children:m.lineItems.length}),r.jsx(re,{className:"text-right font-mono text-sm",onClick:()=>e(`/orders/${m.orderNumber}`),children:me(m.totalMinor,m.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",onClick:()=>e(`/orders/${m.orderNumber}`),children:ht(m.createdAt)}),r.jsx(re,{onClick:x=>x.stopPropagation(),children:r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon","aria-label":`Actions for order ${m.orderNumber}`,className:"h-8 w-8 text-zinc-400",children:r.jsx(tl,{className:"h-4 w-4"})})}),r.jsxs(na,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/orders/${m.orderNumber}`),children:"View details"}),r.jsx(ra,{}),r.jsx(bt,{className:"text-red-600",children:"Cancel order"})]})]})})]},m.id))})]}):r.jsx(We,{icon:r.jsx(qt,{className:"h-5 w-5"}),title:"No orders found",description:s||t!=="all"?"Try adjusting your filters.":"Orders will appear here as they come in."})})]})}const tj={breadcrumb:()=>"Orders"};function fc(e,[t,n]){return Math.min(n,Math.max(t,e))}var hf=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"}),nj="VisuallyHidden",rj=l.forwardRef((e,t)=>r.jsx(G.span,{...e,ref:t,style:{...hf,...e.style}}));rj.displayName=nj;var sj=[" ","Enter","ArrowUp","ArrowDown"],aj=[" ","Enter"],yn="Select",[sa,aa,oj]=Go(yn),[ir]=ut(yn,[oj,ar]),oa=ar(),[ij,Jt]=ir(yn),[cj,lj]=ir(yn),mf=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:c,defaultValue:i,onValueChange:f,dir:u,name:d,autoComplete:h,disabled:m,required:x,form:g}=e,p=oa(t),[v,y]=l.useState(null),[w,N]=l.useState(null),[j,C]=l.useState(!1),S=Qs(u),[E,k]=Gt({prop:s,defaultProp:a??!1,onChange:o,caller:yn}),[z,O]=Gt({prop:c,defaultProp:i,onChange:f,caller:yn}),U=l.useRef(null),I=v?g||!!v.closest("form"):!0,[Q,V]=l.useState(new Set),Z=Array.from(Q).map(B=>B.props.value).join(";");return r.jsx(Do,{...p,children:r.jsxs(ij,{required:x,scope:t,trigger:v,onTriggerChange:y,valueNode:w,onValueNodeChange:N,valueNodeHasChildren:j,onValueNodeHasChildrenChange:C,contentId:Ne(),value:z,onValueChange:O,open:E,onOpenChange:k,dir:S,triggerPointerDownPosRef:U,disabled:m,children:[r.jsx(sa.Provider,{scope:t,children:r.jsx(cj,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(B=>{V(ae=>new Set(ae).add(B))},[]),onNativeOptionRemove:l.useCallback(B=>{V(ae=>{const F=new Set(ae);return F.delete(B),F})},[]),children:n})}),I?r.jsxs(Lf,{"aria-hidden":!0,required:x,tabIndex:-1,name:d,autoComplete:h,value:z,onChange:B=>O(B.target.value),disabled:m,form:g,children:[z===void 0?r.jsx("option",{value:""}):null,Array.from(Q)]},Z):null]})})};mf.displayName=yn;var pf="SelectTrigger",xf=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=oa(n),c=Jt(pf,n),i=c.disabled||s,f=de(t,c.onTriggerChange),u=aa(n),d=l.useRef("touch"),[h,m,x]=$f(p=>{const v=u().filter(N=>!N.disabled),y=v.find(N=>N.value===c.value),w=Uf(v,p,y);w!==void 0&&c.onValueChange(w.value)}),g=p=>{i||(c.onOpenChange(!0),x()),p&&(c.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(zs,{asChild:!0,...o,children:r.jsx(G.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":Ff(c.value)?"":void 0,...a,ref:f,onClick:D(a.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&g(p)}),onPointerDown:D(a.onPointerDown,p=>{d.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:D(a.onKeyDown,p=>{const v=h.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&m(p.key),!(v&&p.key===" ")&&sj.includes(p.key)&&(g(),p.preventDefault())})})})});xf.displayName=pf;var gf="SelectValue",vf=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:c="",...i}=e,f=Jt(gf,n),{onValueNodeHasChildrenChange:u}=f,d=o!==void 0,h=de(t,f.onValueNodeChange);return Re(()=>{u(d)},[u,d]),r.jsx(G.span,{...i,ref:h,style:{pointerEvents:"none"},children:Ff(f.value)?r.jsx(r.Fragment,{children:c}):o})});vf.displayName=gf;var dj="SelectIcon",yf=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return r.jsx(G.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});yf.displayName=dj;var uj="SelectPortal",bf=e=>r.jsx(Dr,{asChild:!0,...e});bf.displayName=uj;var bn="SelectContent",wf=l.forwardRef((e,t)=>{const n=Jt(bn,e.__scopeSelect),[s,a]=l.useState();if(Re(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?Ps.createPortal(r.jsx(jf,{scope:e.__scopeSelect,children:r.jsx(sa.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),o):null}return r.jsx(Nf,{...e,ref:t})});wf.displayName=bn;var Qe=10,[jf,en]=ir(bn),fj="SelectContentImpl",hj=pn("SelectContent.RemoveScroll"),Nf=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:c,side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v,...y}=e,w=Jt(bn,n),[N,j]=l.useState(null),[C,S]=l.useState(null),E=de(t,M=>j(M)),[k,z]=l.useState(null),[O,U]=l.useState(null),I=aa(n),[Q,V]=l.useState(!1),Z=l.useRef(!1);l.useEffect(()=>{if(N)return Ls(N)},[N]),Ms();const B=l.useCallback(M=>{const[Y,...X]=I().map(he=>he.ref.current),[ie]=X.slice(-1),fe=document.activeElement;for(const he of M)if(he===fe||(he==null||he.scrollIntoView({block:"nearest"}),he===Y&&C&&(C.scrollTop=0),he===ie&&C&&(C.scrollTop=C.scrollHeight),he==null||he.focus(),document.activeElement!==fe))return},[I,C]),ae=l.useCallback(()=>B([k,N]),[B,k,N]);l.useEffect(()=>{Q&&ae()},[Q,ae]);const{onOpenChange:F,triggerPointerDownPosRef:A}=w;l.useEffect(()=>{if(N){let M={x:0,y:0};const Y=ie=>{var fe,he;M={x:Math.abs(Math.round(ie.pageX)-(((fe=A.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(ie.pageY)-(((he=A.current)==null?void 0:he.y)??0))}},X=ie=>{M.x<=10&&M.y<=10?ie.preventDefault():N.contains(ie.target)||F(!1),document.removeEventListener("pointermove",Y),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",X,{capture:!0})}}},[N,F,A]),l.useEffect(()=>{const M=()=>F(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[F]);const[ce,le]=$f(M=>{const Y=I().filter(fe=>!fe.disabled),X=Y.find(fe=>fe.ref.current===document.activeElement),ie=Uf(Y,M,X);ie&&setTimeout(()=>ie.ref.current.focus())}),R=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&(z(M),ie&&(Z.current=!0))},[w.value]),K=l.useCallback(()=>N==null?void 0:N.focus(),[N]),H=l.useCallback((M,Y,X)=>{const ie=!Z.current&&!X;(w.value!==void 0&&w.value===Y||ie)&&U(M)},[w.value]),L=s==="popper"?io:Cf,J=L===io?{side:i,sideOffset:f,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(jf,{scope:n,content:N,viewport:C,onViewportChange:S,itemRefCallback:R,selectedItem:k,onItemLeave:K,itemTextRefCallback:H,focusSelectedItem:ae,selectedItemText:O,position:s,isPositioned:Q,searchRef:ce,children:r.jsx(zr,{as:hj,allowPinchZoom:!0,children:r.jsx(Ir,{asChild:!0,trapped:w.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:D(a,M=>{var Y;(Y=w.trigger)==null||Y.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:r.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:M=>M.preventDefault(),...y,...J,onPlaced:()=>V(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:D(y.onKeyDown,M=>{const Y=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Y&&M.key.length===1&&le(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let ie=I().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(M.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const fe=M.target,he=ie.indexOf(fe);ie=ie.slice(he+1)}setTimeout(()=>B(ie)),M.preventDefault()}})})})})})})});Nf.displayName=fj;var mj="SelectItemAlignedPosition",Cf=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=Jt(bn,n),c=en(bn,n),[i,f]=l.useState(null),[u,d]=l.useState(null),h=de(t,E=>d(E)),m=aa(n),x=l.useRef(!1),g=l.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:y,focusSelectedItem:w}=c,N=l.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&p&&v&&y){const E=o.trigger.getBoundingClientRect(),k=u.getBoundingClientRect(),z=o.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(o.dir!=="rtl"){const fe=O.left-k.left,he=z.left-fe,ze=E.left-he,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Qe,dr=fc(he,[Qe,Math.max(Qe,lr-cr)]);i.style.minWidth=nt+"px",i.style.left=dr+"px"}else{const fe=k.right-O.right,he=window.innerWidth-z.right-fe,ze=window.innerWidth-E.right-he,nt=E.width+ze,cr=Math.max(nt,k.width),lr=window.innerWidth-Qe,dr=fc(he,[Qe,Math.max(Qe,lr-cr)]);i.style.minWidth=nt+"px",i.style.right=dr+"px"}const U=m(),I=window.innerHeight-Qe*2,Q=p.scrollHeight,V=window.getComputedStyle(u),Z=parseInt(V.borderTopWidth,10),B=parseInt(V.paddingTop,10),ae=parseInt(V.borderBottomWidth,10),F=parseInt(V.paddingBottom,10),A=Z+B+Q+F+ae,ce=Math.min(v.offsetHeight*5,A),le=window.getComputedStyle(p),R=parseInt(le.paddingTop,10),K=parseInt(le.paddingBottom,10),H=E.top+E.height/2-Qe,L=I-H,J=v.offsetHeight/2,M=v.offsetTop+J,Y=Z+B+M,X=A-Y;if(Y<=H){const fe=U.length>0&&v===U[U.length-1].ref.current;i.style.bottom="0px";const he=u.clientHeight-p.offsetTop-p.offsetHeight,ze=Math.max(L,J+(fe?K:0)+he+ae),nt=Y+ze;i.style.height=nt+"px"}else{const fe=U.length>0&&v===U[0].ref.current;i.style.top="0px";const ze=Math.max(H,Z+p.offsetTop+(fe?R:0)+J)+X;i.style.height=ze+"px",p.scrollTop=Y-H+p.offsetTop}i.style.margin=`${Qe}px 0`,i.style.minHeight=ce+"px",i.style.maxHeight=I+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[m,o.trigger,o.valueNode,i,u,p,v,y,o.dir,s]);Re(()=>N(),[N]);const[j,C]=l.useState();Re(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const S=l.useCallback(E=>{E&&g.current===!0&&(N(),w==null||w(),g.current=!1)},[N,w]);return r.jsx(xj,{scope:n,contentWrapper:i,shouldExpandOnScrollRef:x,onScrollButtonChange:S,children:r.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(G.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Cf.displayName=mj;var pj="SelectPopperPosition",io=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=Qe,...o}=e,c=oa(n);return r.jsx(zo,{...c,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});io.displayName=pj;var[xj,di]=ir(bn,{}),co="SelectViewport",Sf=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=en(co,n),c=di(co,n),i=de(t,o.onViewportChange),f=l.useRef(0);return r.jsxs(r.Fragment,{children:[r.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:s}),r.jsx(sa.Slot,{scope:n,children:r.jsx(G.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:D(a.onScroll,u=>{const d=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&h){const x=Math.abs(f.current-d.scrollTop);if(x>0){const g=window.innerHeight-Qe*2,p=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),y=Math.max(p,v);if(y<g){const w=y+x,N=Math.min(g,w),j=w-N;h.style.height=N+"px",h.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,h.style.justifyContent="flex-end")}}}f.current=d.scrollTop})})})]})});Sf.displayName=co;var Ef="SelectGroup",[gj,vj]=ir(Ef),yj=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=Ne();return r.jsx(gj,{scope:n,id:a,children:r.jsx(G.div,{role:"group","aria-labelledby":a,...s,ref:t})})});yj.displayName=Ef;var Rf="SelectLabel",Pf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=vj(Rf,n);return r.jsx(G.div,{id:a.id,...s,ref:t})});Pf.displayName=Rf;var Rs="SelectItem",[bj,kf]=ir(Rs),Tf=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...c}=e,i=Jt(Rs,n),f=en(Rs,n),u=i.value===s,[d,h]=l.useState(o??""),[m,x]=l.useState(!1),g=de(t,w=>{var N;return(N=f.itemRefCallback)==null?void 0:N.call(f,w,s,a)}),p=Ne(),v=l.useRef("touch"),y=()=>{a||(i.onValueChange(s),i.onOpenChange(!1))};if(s==="")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 r.jsx(bj,{scope:n,value:s,disabled:a,textId:p,isSelected:u,onItemTextChange:l.useCallback(w=>{h(N=>N||((w==null?void 0:w.textContent)??"").trim())},[]),children:r.jsx(sa.ItemSlot,{scope:n,value:s,disabled:a,textValue:d,children:r.jsx(G.div,{role:"option","aria-labelledby":p,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...c,ref:g,onFocus:D(c.onFocus,()=>x(!0)),onBlur:D(c.onBlur,()=>x(!1)),onClick:D(c.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:D(c.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:D(c.onPointerDown,w=>{v.current=w.pointerType}),onPointerMove:D(c.onPointerMove,w=>{var N;v.current=w.pointerType,a?(N=f.onItemLeave)==null||N.call(f):v.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:D(c.onPointerLeave,w=>{var N;w.currentTarget===document.activeElement&&((N=f.onItemLeave)==null||N.call(f))}),onKeyDown:D(c.onKeyDown,w=>{var j;((j=f.searchRef)==null?void 0:j.current)!==""&&w.key===" "||(aj.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Tf.displayName=Rs;var gr="SelectItemText",Af=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,c=Jt(gr,n),i=en(gr,n),f=kf(gr,n),u=lj(gr,n),[d,h]=l.useState(null),m=de(t,y=>h(y),f.onItemTextChange,y=>{var w;return(w=i.itemTextRefCallback)==null?void 0:w.call(i,y,f.value,f.disabled)}),x=d==null?void 0:d.textContent,g=l.useMemo(()=>r.jsx("option",{value:f.value,disabled:f.disabled,children:x},f.value),[f.disabled,f.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=u;return Re(()=>(p(g),()=>v(g)),[p,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(G.span,{id:f.textId,...o,ref:m}),f.isSelected&&c.valueNode&&!c.valueNodeHasChildren?Ps.createPortal(o.children,c.valueNode):null]})});Af.displayName=gr;var Mf="SelectItemIndicator",_f=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return kf(Mf,n).isSelected?r.jsx(G.span,{"aria-hidden":!0,...s,ref:t}):null});_f.displayName=Mf;var lo="SelectScrollUpButton",If=l.forwardRef((e,t)=>{const n=en(lo,e.__scopeSelect),s=di(lo,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Re(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollTop>0;o(u)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Df,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop-f.offsetHeight)}}):null});If.displayName=lo;var uo="SelectScrollDownButton",Of=l.forwardRef((e,t)=>{const n=en(uo,e.__scopeSelect),s=di(uo,e.__scopeSelect),[a,o]=l.useState(!1),c=de(t,s.onScrollButtonChange);return Re(()=>{if(n.viewport&&n.isPositioned){let i=function(){const u=f.scrollHeight-f.clientHeight,d=Math.ceil(f.scrollTop)<u;o(d)};const f=n.viewport;return i(),f.addEventListener("scroll",i),()=>f.removeEventListener("scroll",i)}},[n.viewport,n.isPositioned]),a?r.jsx(Df,{...e,ref:c,onAutoScroll:()=>{const{viewport:i,selectedItem:f}=n;i&&f&&(i.scrollTop=i.scrollTop+f.offsetHeight)}}):null});Of.displayName=uo;var Df=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=en("SelectScrollButton",n),c=l.useRef(null),i=aa(n),f=l.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return l.useEffect(()=>()=>f(),[f]),Re(()=>{var d;const u=i().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[i]),r.jsx(G.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:D(a.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:D(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:D(a.onPointerLeave,()=>{f()})})}),wj="SelectSeparator",zf=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(G.div,{"aria-hidden":!0,...s,ref:t})});zf.displayName=wj;var fo="SelectArrow",jj=l.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=oa(n),o=Jt(fo,n),c=en(fo,n);return o.open&&c.position==="popper"?r.jsx(Lo,{...a,...s,ref:t}):null});jj.displayName=fo;var Nj="SelectBubbleInput",Lf=l.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=l.useRef(null),o=de(s,a),c=uu(t);return l.useEffect(()=>{const i=a.current;if(!i)return;const f=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(f,"value").set;if(c!==t&&d){const h=new Event("change",{bubbles:!0});d.call(i,t),i.dispatchEvent(h)}},[c,t]),r.jsx(G.select,{...n,style:{...hf,...n.style},ref:o,defaultValue:t})});Lf.displayName=Nj;function Ff(e){return e===""||e===void 0}function $f(e){const t=dt(e),n=l.useRef(""),s=l.useRef(0),a=l.useCallback(c=>{const i=n.current+c;t(i),(function f(u){n.current=u,window.clearTimeout(s.current),u!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(i)},[t]),o=l.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function Uf(e,t,n){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let c=Cj(e,Math.max(o,0));a.length===1&&(c=c.filter(u=>u!==n));const f=c.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function Cj(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Sj=mf,Vf=xf,Ej=vf,Rj=yf,Pj=bf,Bf=wf,kj=Sf,Kf=Pf,qf=Tf,Tj=Af,Aj=_f,Hf=If,Wf=Of,Gf=zf;const Sr=Sj,Er=Ej,Zn=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Vf,{ref:s,className:T("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,r.jsx(Rj,{asChild:!0,children:r.jsx(Zc,{className:"h-4 w-4 opacity-50 shrink-0"})})]}));Zn.displayName=Vf.displayName;const Qf=l.forwardRef(({className:e,...t},n)=>r.jsx(Hf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(kp,{className:"h-4 w-4"})}));Qf.displayName=Hf.displayName;const Yf=l.forwardRef(({className:e,...t},n)=>r.jsx(Wf,{ref:n,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Zc,{className:"h-4 w-4"})}));Yf.displayName=Wf.displayName;const Jn=l.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>r.jsx(Pj,{children:r.jsxs(Bf,{ref:a,className:T("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,...s,children:[r.jsx(Qf,{}),r.jsx(kj,{className:T("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Yf,{})]})}));Jn.displayName=Bf.displayName;const Mj=l.forwardRef(({className:e,...t},n)=>r.jsx(Kf,{ref:n,className:T("px-2 py-1.5 text-xs font-semibold text-zinc-500 uppercase tracking-wider",e),...t}));Mj.displayName=Kf.displayName;const qe=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(qf,{ref:s,className:T("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:[r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Aj,{children:r.jsx(St,{className:"h-4 w-4"})})}),r.jsx(Tj,{children:t})]}));qe.displayName=qf.displayName;const _j=l.forwardRef(({className:e,...t},n)=>r.jsx(Gf,{ref:n,className:T("-mx-1 my-1 h-px bg-zinc-100",e),...t}));_j.displayName=Gf.displayName;function Xf({orderId:e,orderNumber:t,open:n,onOpenChange:s}){const[a,o]=l.useState(""),[c,i]=l.useState(""),[f,u]=l.useState(null),d=l.useRef(!1),[h,m]=l.useState(!1),x=ex();l.useEffect(()=>{n&&u(null)},[n]);const g=a.trim()!==""&&c.trim()!=="",p=()=>{o(""),i(""),u(null),s(!1)},v=async()=>{if(!(!g||d.current)){d.current=!0,m(!0),u(null);try{await x.mutateAsync({orderId:e,carrier:a.trim(),trackingNumber:c.trim()}),p()}catch(y){u(y instanceof Ae?y.message:"The order could not be shipped.")}finally{d.current=!1,m(!1)}}};return r.jsx(Hs,{open:n,onOpenChange:y=>y?s(!0):p(),children:r.jsxs($r,{className:"max-w-md","data-testid":P("order","ship-dialog"),children:[r.jsx(Ws,{children:r.jsxs(Ur,{children:["Ship Order #",t]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-carrier",children:"Carrier"}),r.jsx(pe,{id:"ship-carrier",value:a,onChange:y=>o(y.target.value),"data-testid":P("order","ship-carrier")})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"ship-tracking",children:"Tracking number"}),r.jsx(pe,{id:"ship-tracking",value:c,onChange:y=>i(y.target.value),"data-testid":P("order","ship-tracking")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600","data-testid":P("order","ship-error"),children:f})]}),r.jsxs(Gs,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:p,"data-testid":P("order","ship-cancel"),children:"Cancel"}),r.jsx(se,{type:"button",onClick:()=>void v(),disabled:!g||h,"data-testid":P("order","ship-submit"),children:h?"Shipping...":"Ship order"})]})]})})}const as="record-payment",Ea={pending:"Pending",confirmed:"Confirmed",processing:"Processing",shipped:"Shipped",delivered:"Delivered",cancelled:"Cancelled",refunded:"Refunded",partially_refunded:"Partially Refunded"},Ij={confirmed:"confirm",processing:"process",delivered:"mark-delivered",cancelled:"cancel"};function Oj(e,t){return sm[e].filter(n=>n!=="refunded"&&n!=="partially_refunded"&&n!=="confirmed"&&!(n==="cancelled"&&t>0))}function Dj({orderId:e,currentStatus:t,orderNumber:n,capturedMinor:s}){const a=ye(),{mutateAsync:o,isPending:c}=Xp(),{mutateAsync:i,isPending:f}=cl(),[u,d]=l.useState(null),[h,m]=l.useState(null),[x,g]=l.useState(!1),p=Oj(t,s),v=t==="pending"&&s===0,y=u??t,w=c||f,N=p.length===0&&!v,j=async C=>{if(m(null),C==="shipped"){g(!0);return}const S=C===as?"confirmed":C;d(S);try{C===as?await i({orderId:e}):await o({orderId:e,action:Ij[S]??S})}catch(E){m(E instanceof Ae?E.message:"The status could not be changed."),d(null),a.invalidateQueries({queryKey:["orders","detail",n]})}};return r.jsxs(r.Fragment,{children:[N?r.jsx("span",{className:"text-sm text-zinc-500 font-medium capitalize",children:Ea[t]}):r.jsxs(Sr,{value:y,onValueChange:C=>void j(C),disabled:w,children:[r.jsx(Zn,{className:T("w-44 h-8 text-xs",w&&"opacity-50"),"aria-label":"Order status","data-testid":P("order","status-select"),children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsxs(qe,{value:t,disabled:!0,"data-testid":P("order","status-option",t),children:[Ea[t]," (current)"]}),v&&r.jsx(qe,{value:as,"data-testid":P("order","status-option",as),children:"Record payment"}),p.map(C=>r.jsx(qe,{value:C,"data-testid":P("order","status-option",C),children:Ea[C]},C))]})]}),h&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","status-error"),children:h}),r.jsx(Xf,{orderId:e,orderNumber:n,open:x,onOpenChange:g})]})}function zj({entries:e}){const t=[...e].sort((n,s)=>new Date(s.timestamp).getTime()-new Date(n.timestamp).getTime());return r.jsx("div",{className:"flow-root",children:r.jsx("ul",{className:"-mb-8",children:t.map((n,s)=>r.jsx("li",{"data-testid":P("order","timeline-entry",n.toStatus),children:r.jsxs("div",{className:"relative pb-8",children:[s<t.length-1&&r.jsx("span",{className:"absolute left-4 top-5 -ml-px h-full w-0.5 bg-zinc-200","aria-hidden":"true"}),r.jsxs("div",{className:"relative flex gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border-2 border-zinc-200 bg-white",children:r.jsx("div",{className:"h-2 w-2 rounded-full bg-blue-500"})}),r.jsxs("div",{className:"min-w-0 flex-1 pt-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.fromStatus&&r.jsxs(r.Fragment,{children:[r.jsx(Xn,{status:n.fromStatus,size:"sm"}),r.jsx("span",{className:"text-zinc-400 text-xs",children:"→"})]}),r.jsx(Xn,{status:n.toStatus,size:"sm"})]}),n.note&&r.jsx("p",{className:"mt-1 text-sm text-zinc-600",children:n.note}),r.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{children:n.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:n.timestamp,title:Oe(n.timestamp),children:ht(n.timestamp)})]})]})]})]})},n.id))})})}const Kt=l.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{className:T("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}));Kt.displayName="Textarea";function Lj({orderId:e,notes:t}){const[n,s]=l.useState(""),a=rx(),o=async c=>{c.preventDefault(),n.trim()&&(await a.mutateAsync({orderId:e,body:n.trim()}),s(""))};return r.jsxs("div",{"data-testid":P("order","notes"),children:[r.jsx("div",{className:"space-y-3",children:t.length===0?r.jsx("p",{className:"text-sm text-zinc-400 italic",children:"No notes yet."}):[...t].sort((c,i)=>new Date(i.at).getTime()-new Date(c.at).getTime()).map((c,i)=>r.jsx(Fj,{note:c},i))}),r.jsxs("form",{onSubmit:c=>void o(c),className:"mt-4 flex gap-2",children:[r.jsx(Kt,{placeholder:"Add an internal note...",value:n,onChange:c=>s(c.target.value),rows:2,className:"flex-1 text-sm",onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),o(c))}}),r.jsx(se,{type:"submit",size:"icon","aria-label":"Add note",disabled:!n.trim()||a.isPending,className:"self-end h-9 w-9",children:r.jsx(rl,{className:"h-4 w-4"})})]})]})}function Fj({note:e}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:e.body}),r.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:e.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:e.at,title:Oe(e.at),children:ht(e.at)})]})]})}function $j(e,t){if(!(e instanceof Ae))return"The refund could not be made.";const{amountMinor:n,refundableMinor:s}=e.context??{};return e.code==="refund.exceeds_captured"&&typeof n=="number"&&typeof s=="number"?`A refund of ${me(n,t)} is more than the ${me(s,t)} left to refund.`:e.message}function Uj({order:e,onClose:t}){const{refundableMinor:n,currency:s}=e.payment,[a,o]=l.useState((n/100).toFixed(2)),[c,i]=l.useState(""),[f,u]=l.useState(null),[d,h]=l.useState(()=>crypto.randomUUID()),m=l.useRef(!1),[x,g]=l.useState(!1),p=tx(),v=Yy(a),y=v!==null&&v>0&&v<=n,w=async()=>{if(!(!y||v===null||m.current)){m.current=!0,g(!0),u(null);try{if((await p.mutateAsync({orderId:e.id,amountMinor:v,requestId:d,...c.trim()&&{reason:c.trim()}})).refund.status==="failed"){h(crypto.randomUUID()),u("The payment provider refused the refund.");return}t()}catch(N){u($j(N,s))}finally{m.current=!1,g(!1)}}};return r.jsx(Hs,{open:!0,onOpenChange:N=>!N&&t(),children:r.jsxs($r,{className:"max-w-md","data-testid":P("order","refund-dialog"),children:[r.jsx(Ws,{children:r.jsxs(Ur,{children:["Refund Order #",e.orderNumber]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 p-3 bg-zinc-50",children:r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-zinc-600",children:"Refundable"}),r.jsx("span",{className:"font-mono font-semibold text-zinc-900",children:me(n,s)})]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{htmlFor:"refund-amount",children:["Amount (",s,")"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{id:"refund-amount",inputMode:"decimal",value:a,onChange:N=>o(N.target.value),"aria-invalid":!y,"data-testid":P("order","refund-amount")}),r.jsx(se,{variant:"outline",type:"button",onClick:()=>o((n/100).toFixed(2)),children:"Full refund"})]}),!y&&r.jsxs("p",{className:"text-xs text-red-600",children:["Enter an amount above 0 and up to ",me(n,s),"."]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"refund-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"refund-reason",placeholder:"Enter refund reason...",value:c,onChange:N=>i(N.target.value),rows:3,"data-testid":P("order","refund-reason")})]}),f&&r.jsx("p",{role:"alert",className:"text-sm text-red-600",children:f})]}),r.jsxs(Gs,{children:[r.jsx(se,{variant:"outline",type:"button",onClick:t,children:"Cancel"}),r.jsx(se,{variant:"destructive",type:"button",onClick:()=>void w(),disabled:!y||x,"data-testid":P("order","refund-confirm"),children:x?"Processing...":`Refund ${v!==null?me(v,s):""}`})]})]})})}const Vj=50;function Bj(e,t){return jo({queryKey:["history",e,t],initialPageParam:void 0,queryFn:({pageParam:n})=>W.get(`/api/admin/${e}/${encodeURIComponent(t)}/history`,{limit:Vj,cursor:n}),getNextPageParam:n=>n.nextCursor??void 0,enabled:t!==""})}function Kj(e,t){return Ce({queryKey:["history","as-of",e,t],queryFn:()=>W.get(e,{at:t}),enabled:t!==null,retry:!1})}function ho(e){return e==null?"—":typeof e=="object"?JSON.stringify(e):String(e)}function qj({seq:e,change:t}){return r.jsxs("li",{className:"font-mono text-xs text-zinc-600 break-all","data-testid":`history-change-${e}-${t.path}`,children:[r.jsxs("span",{className:"text-zinc-400",children:[t.path,": "]}),r.jsx("span",{className:"text-red-700",children:ho(t.from)}),r.jsx("span",{className:"text-zinc-400",children:" → "}),r.jsx("span",{className:"text-green-700",children:ho(t.to)})]})}function Hj({entry:e,onAsOf:t}){return r.jsxs("li",{className:"py-3 space-y-1.5","data-testid":`history-row-${e.seq}`,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[r.jsx("time",{dateTime:e.at,className:"text-zinc-500",children:Oe(e.at)}),r.jsx("span",{className:"font-mono text-zinc-800",children:e.type}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-actor`,children:e.actor===null?"system":`${e.actor.kind}:${e.actor.id}`}),r.jsx("span",{className:"font-mono text-zinc-500","data-testid":`history-row-${e.seq}-command`,children:e.command??""}),r.jsx(se,{type:"button",variant:"outline",size:"sm",className:"ml-auto h-6 px-2 text-xs",onClick:()=>t(e.at),"data-testid":`history-as-of-${e.seq}`,children:"View as of"})]}),e.base?r.jsx("p",{className:"text-xs text-zinc-400",children:"The earliest state the event log holds."}):r.jsx("ul",{className:"space-y-0.5",children:e.changes.map(n=>r.jsx(qj,{seq:e.seq,change:n},n.path))})]})}function Wj({detailPath:e,at:t,onClose:n}){const{data:s,error:a,isLoading:o}=Kj(e,t);return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3 space-y-2","data-testid":"history-as-of-panel",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("h4",{className:"text-xs font-semibold text-zinc-700",children:["As of ",Oe(t)]}),r.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:n,children:r.jsx(Yt,{className:"h-3.5 w-3.5"})})]}),o?r.jsx(xe,{className:"h-24 w-full"}):a?r.jsx("p",{className:"text-xs text-red-600",children:a instanceof Ae?a.message:"The record could not be read as of then."}):s?r.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:Object.entries(s.record).map(([c,i])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"text-zinc-400",children:c}),r.jsx("dd",{className:"font-mono text-zinc-700 break-all","data-testid":`history-as-of-field-${c}`,children:ho(i)})]},c))}):null]})}function ui({collection:e,id:t,detailPath:n}){const{data:s,isLoading:a,isError:o,hasNextPage:c,fetchNextPage:i,isFetchingNextPage:f}=Bj(e,t),[u,d]=l.useState(null);if(a)return r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((x,g)=>r.jsx(xe,{className:"h-10 w-full"},g))});if(o||!s)return r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"History could not be loaded"});const h=s.pages[0];if(h.historyStartsAt===null)return r.jsxs("p",{className:"py-4 text-center text-sm text-zinc-500","data-testid":"history-empty",children:["This record predates the event log’s window: the log keeps ",h.retentionDays," days of changes (events.retentionDays), so its earlier history is no longer held."]});const m=s.pages.flatMap(x=>x.entries);return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:["From ",Oe(h.historyStartsAt),": the event log keeps ",h.retentionDays," days of changes."]}),u!==null&&r.jsx(Wj,{detailPath:n,at:u,onClose:()=>d(null)}),r.jsx("ul",{className:"divide-y divide-zinc-100",children:m.map(x=>r.jsx(Hj,{entry:x,onAsOf:d},x.seq))}),c&&r.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void i(),disabled:f,children:f?"Loading…":"Load more"})]})}const Gj=["pending","cancelled"],Qj={unpaid:"Unpaid",paid:"Paid",partially_refunded:"Partially refunded",refunded:"Refunded"},Yj={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"},Xj={provider:"Payment provider",manual:"Recorded manually",import:"Imported"};function Zj(e){return e==="storefront"?"Storefront":e==="import"?"Imported":`Agent · ${e.slice(6)}`}const Jj={pending:"Refund pending",succeeded:"Refunded",failed:"Failed"};function eN({order:e}){const{payment:t}=e;return r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Payment"}),r.jsx("span",{className:T("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",Yj[t.state]),"data-testid":P("order","payment-state"),children:Qj[t.state]})]}),r.jsxs("dl",{className:"space-y-1.5 text-sm",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Captured"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":P("order","captured"),children:me(t.capturedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Refunded"}),r.jsx("dd",{className:"font-mono text-zinc-700","data-testid":P("order","refunded"),children:me(t.refundedMinor,t.currency)})]}),r.jsxs("div",{className:"flex justify-between font-semibold",children:[r.jsx("dt",{className:"text-zinc-700",children:"Net"}),r.jsx("dd",{className:"font-mono text-zinc-900","data-testid":P("order","net"),children:me(t.capturedMinor-t.refundedMinor,t.currency)})]}),e.captureMethod&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Method"}),r.jsx("dd",{className:"text-zinc-700",children:Xj[e.captureMethod]})]}),r.jsxs("div",{className:"flex justify-between gap-3",children:[r.jsx("dt",{className:"text-zinc-500",children:"Source"}),r.jsx("dd",{className:"truncate text-zinc-700","data-testid":P("order","source"),"data-source":e.source,children:Zj(e.source)})]}),e.paymentIntentId&&r.jsxs("div",{className:"flex justify-between",children:[r.jsx("dt",{className:"text-zinc-500",children:"Intent ID"}),r.jsx("dd",{className:"font-mono text-xs text-zinc-600 truncate max-w-[120px]",children:e.paymentIntentId})]})]}),t.refunds.length>0&&r.jsx("ul",{className:"space-y-1 border-t border-zinc-100 pt-2 text-sm",children:t.refunds.map(n=>r.jsxs("li",{className:"flex justify-between gap-2","data-testid":P("order","refund-row",n.id),children:[r.jsxs("span",{className:"text-zinc-500",children:[Jj[n.status]," · ",Oe(n.createdAt)]}),r.jsx("span",{className:"font-mono text-zinc-700",children:me(n.amountMinor,n.currency)})]},n.id))})]})}function hc({address:e,label:t}){return r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-1.5",children:t}),r.jsxs("div",{className:"text-sm text-zinc-600 space-y-0.5",children:[r.jsxs("p",{children:[e.firstName," ",e.lastName]}),e.company&&r.jsx("p",{children:e.company}),r.jsx("p",{children:e.addressLine1}),e.addressLine2&&r.jsx("p",{children:e.addressLine2}),r.jsxs("p",{children:[e.city,", ",e.region," ",e.postalCode]}),r.jsx("p",{children:e.country})]})]})}function tN(){const{orderNumber:e}=xo(),[t,n]=l.useState(!1),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=l.useRef(!1),[f,u]=l.useState(!1),{data:d,isLoading:h}=Qp(e??""),{data:m=[]}=Yp((d==null?void 0:d.id)??""),x=cl(),g=Zp(),p=Jp(),v=nx(),y=async S=>{if(!i.current){i.current=!0,u(!0),c(null);try{await S()}catch(E){c(E instanceof Ae?E.message:"The order could not be updated.")}finally{i.current=!1,u(!1)}}};if(h)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-40"}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-4",children:[r.jsx(xe,{className:"h-48 w-full"}),r.jsx(xe,{className:"h-32 w-full"})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(xe,{className:"h-40 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]})]})]});if(!d)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Order not found"}),r.jsx(Ze,{to:"/orders",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to orders"})]});const N=d.status==="pending"&&d.payment.capturedMinor===0?{label:"Record payment",icon:Si,action:()=>void y(()=>x.mutateAsync({orderId:d.id}))}:d.status==="processing"?{label:"Mark Shipped",icon:al,action:()=>a(!0)}:d.status==="shipped"?{label:"Mark Delivered",icon:Si,action:()=>void y(()=>p.mutateAsync(d.id))}:null,j=Gj.includes(d.status)||v.isPending,C=v.isError?v.error.message:v.data?`Confirmation queued to ${v.data.email}`:null;return r.jsxs("div",{className:"space-y-4","data-testid":P("order","detail"),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(Ze,{to:"/orders",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700 transition-colors",children:[r.jsx(Co,{className:"h-4 w-4"}),"Orders"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsxs("h1",{className:"font-mono text-base font-semibold text-zinc-900",children:["#",d.orderNumber]}),r.jsx(Xn,{status:d.status,"data-testid":P("order","status-badge")})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o!==null&&r.jsx("span",{role:"alert",className:"text-xs text-red-600","data-testid":P("order","action-error"),children:o}),C!==null&&r.jsx("span",{role:"status",className:"text-xs text-zinc-500","data-testid":P("order","resend-result"),children:C}),N&&r.jsxs(se,{size:"sm",onClick:N.action,disabled:f,className:"gap-1.5","data-testid":P("order","primary-action"),children:[r.jsx(N.icon,{className:"h-4 w-4"}),N.label]}),r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"outline",size:"sm","data-testid":P("order","actions"),children:"Actions"})}),r.jsxs(na,{align:"end",className:"w-44",children:[r.jsxs(bt,{onSelect:()=>{j||v.mutate({orderId:d.id})},className:"gap-2",disabled:j,"data-testid":P("order","action","resend-confirmation"),children:[r.jsx(nl,{className:"h-4 w-4"}),"Resend confirmation"]}),r.jsx(ra,{}),d.payment.refundableMinor>0&&r.jsxs(bt,{onClick:()=>n(!0),className:"gap-2","data-testid":P("order","action","refund"),children:[r.jsx(_p,{className:"h-4 w-4"}),"Issue refund"]}),r.jsxs(bt,{onClick:()=>void y(()=>g.mutateAsync({orderId:d.id})),className:"gap-2 text-red-600","data-testid":P("order","action","cancel"),disabled:d.payment.capturedMinor>0||["cancelled","refunded","delivered"].includes(d.status),children:[r.jsx(Tp,{className:"h-4 w-4"}),"Cancel order"]})]})]})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Ei,{className:"h-3.5 w-3.5"}),"Placed ",Oe(d.createdAt)]}),r.jsx("span",{className:"text-zinc-300",children:"·"}),r.jsx(Dj,{orderId:d.id,currentStatus:d.status,orderNumber:d.orderNumber,capturedMinor:d.payment.capturedMinor})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-5",children:[r.jsxs("div",{className:"md:col-span-3 space-y-5",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsxs("h2",{className:"text-sm font-semibold text-zinc-900",children:["Items (",d.lineItems.length,")"]})}),r.jsx("div",{className:"divide-y divide-zinc-50",children:d.lineItems.map(S=>r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[S.imageUrl?r.jsx("img",{src:S.imageUrl,alt:S.productName,className:"h-12 w-12 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(qt,{className:"h-5 w-5 text-zinc-300"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:S.productName}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[S.variantName," · ",S.sku]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("p",{className:"font-mono text-sm text-zinc-700",children:me(S.lineTotalMinor,d.currency)}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[S.qty," × ",me(S.unitPriceMinor,d.currency)]})]})]},S.variantId))}),r.jsxs("div",{className:"border-t border-zinc-100 bg-zinc-50 px-4 py-3 space-y-1",children:[r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Subtotal"}),r.jsx("span",{className:"font-mono",children:me(d.subtotalMinor,d.currency)})]}),d.taxTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Tax"}),r.jsx("span",{className:"font-mono",children:me(d.taxTotalMinor,d.currency)})]}),d.shippingTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-zinc-500",children:[r.jsx("span",{children:"Shipping"}),r.jsx("span",{className:"font-mono",children:me(d.shippingTotalMinor,d.currency)})]}),d.discountTotalMinor>0&&r.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[r.jsx("span",{children:"Discount"}),r.jsxs("span",{className:"font-mono",children:["-",me(d.discountTotalMinor,d.currency)]})]}),r.jsxs("div",{className:"flex justify-between border-t border-zinc-200 pt-2 text-sm font-semibold text-zinc-800",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{className:"font-mono text-base",children:me(d.totalMinor,d.currency)})]})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:r.jsxs(Br,{defaultValue:"notes",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-2",children:r.jsxs(or,{className:"h-8",children:[r.jsxs(Te,{value:"notes",className:"gap-1.5 text-xs",children:[r.jsx(Bp,{className:"h-3.5 w-3.5"}),"Notes",m.length>0&&r.jsx("span",{className:"rounded-full bg-zinc-100 px-1.5 text-[10px]",children:m.length})]}),r.jsxs(Te,{value:"timeline",className:"gap-1.5 text-xs","data-testid":P("order","tab","timeline"),children:[r.jsx(Ei,{className:"h-3.5 w-3.5"}),"Timeline"]}),r.jsxs(Te,{value:"history",className:"gap-1.5 text-xs","data-testid":P("order","tab","history"),children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})]})}),r.jsx(Ue,{value:"notes",className:"p-4",children:r.jsx(Lj,{orderId:d.id,notes:m})}),r.jsx(Ue,{value:"timeline",className:"p-4",children:d.history&&d.history.length>0?r.jsx(zj,{entries:d.history}):r.jsx("p",{className:"text-sm text-zinc-400 text-center py-4",children:"No history yet."})}),r.jsx(Ue,{value:"history",className:"p-4",children:r.jsx(ui,{collection:"orders",id:d.id,detailPath:`/api/admin/orders/${encodeURIComponent(d.orderNumber)}`})})]})})]}),r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Customer"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-zinc-100 text-sm font-semibold text-zinc-600",children:(d.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-800 [overflow-wrap:anywhere]",children:d.email}),d.customerId&&r.jsx(Ze,{to:`/customers/${d.customerId}`,className:"text-xs text-blue-600 hover:underline",children:"View customer →"})]})]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-3",children:"Addresses"}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[r.jsx(hc,{address:d.shippingAddress,label:"Shipping"}),r.jsx(hc,{address:d.billingAddress,label:"Billing"})]})]}),r.jsx(eN,{order:d}),d.notes&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-amber-50 p-4",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-600 mb-1.5",children:"Order Note"}),r.jsx("p",{className:"text-sm text-amber-800",children:d.notes})]})]})]}),t&&r.jsx(Uj,{order:d,onClose:()=>n(!1)}),r.jsx(Xf,{orderId:d.id,orderNumber:d.orderNumber,open:s,onOpenChange:a})]})}const nN={breadcrumb:e=>`#${e.orderNumber??""}`},rN=As("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 Zf({className:e,variant:t,...n}){return r.jsx("div",{className:T(rN({variant:t}),e),...n})}function sN(e={}){return Ce({queryKey:["products","list",e],queryFn:()=>W.get("/api/admin/products",e)})}function aN(e){return Ce({queryKey:["products","detail",e],queryFn:()=>W.get(`/api/admin/products/${e}`),enabled:!!e&&e!=="new"})}function oN(){const e=ye();return we({mutationFn:({product:t,idempotencyKey:n})=>W.post("/api/admin/products",t,n===void 0?void 0:{idempotencyKey:n}),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function iN(){const e=ye();return we({mutationFn:({id:t,data:n,idempotencyKey:s})=>W.patch(`/api/admin/products/${t}`,n,s===void 0?void 0:{idempotencyKey:s}),onSuccess:t=>{e.setQueryData(["products","detail",t.id],t),e.setQueryData(["products","detail",t.slug],t),e.invalidateQueries({queryKey:["products","list"]})}})}function cN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/duplicate`),onSuccess:()=>{e.invalidateQueries({queryKey:["products","list"]})}})}function lN(){const e=ye();return we({mutationFn:t=>W.post(`/api/admin/products/${t}/archive`),onSuccess:()=>{e.invalidateQueries({queryKey:["products"]})}})}function dN(){return we({mutationFn:({id:e,field:t,context:n})=>W.post(`/api/admin/products/${e}/enhance`,{field:t,context:n})})}const uN=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Draft",value:"draft"},{label:"Archived",value:"archived"}],fN={active:"success",draft:"default",archived:"secondary"};function hN(){const e=Ct(),[t,n]=l.useState("all"),[s,a]=l.useState(""),{data:o,isLoading:c}=sN({status:t==="all"?void 0:t,q:s||void 0,limit:100}),i=cN(),f=lN();return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Products"}),r.jsx("p",{className:"text-sm text-zinc-500",children:o?`${o.length} products`:"Loading..."})]}),r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(br,{className:"h-4 w-4"}),"Add Product"]})]}),r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[r.jsx("div",{className:"flex flex-wrap gap-1.5",children:uN.map(u=>r.jsx("button",{onClick:()=>n(u.value),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",t===u.value?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:u.label},u.value))}),r.jsxs("div",{className:"relative flex-1 sm:max-w-xs sm:ml-auto",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search products...",value:s,onChange:u=>a(u.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:c?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:6}).map((u,d)=>r.jsx(xe,{className:"h-11 w-full"},d))}):o!=null&&o.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{className:"w-12",children:"Image"}),r.jsx(ne,{children:"Name"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Type"}),r.jsx(ne,{className:"text-right",children:"Price"}),r.jsx(ne,{children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Updated"}),r.jsx(ne,{className:"w-10"})]})}),r.jsx(Nn,{children:o.map(u=>{const d=u.media[0],h=u.variants[0],m=u.variants.reduce((p,v)=>p+v.stock,0),x=u.variants.some(p=>p.stock<=p.lowStockThreshold),g=u.variants.some(p=>p.stock===0);return r.jsxs(Be,{"data-testid":P("products","row",u.id),className:"cursor-pointer",onClick:()=>e(`/products/${u.slug}`),children:[r.jsx(re,{children:d?r.jsx("img",{src:d.url,alt:d.altText,className:"h-8 w-8 rounded border border-zinc-100 object-cover"}):r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded border border-zinc-100 bg-zinc-50",children:r.jsx(qt,{className:"h-3.5 w-3.5 text-zinc-300"})})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-zinc-800",children:u.name}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-400",children:u.slug})]})}),r.jsx(re,{children:r.jsx(Zf,{variant:fN[u.status],className:"capitalize",children:u.status})}),r.jsx(re,{className:"text-xs text-zinc-500 capitalize",children:u.type}),r.jsx(re,{className:"text-right font-mono text-sm",children:h?me(h.priceMinor,"GBP"):"—"}),r.jsx(re,{children:r.jsx("span",{className:T("text-sm font-mono font-medium",g?"text-red-600":x?"text-amber-600":"text-zinc-700"),children:m})}),r.jsx(re,{className:"text-right text-xs text-zinc-400",children:ht(u.updatedAt)}),r.jsx(re,{onClick:p=>p.stopPropagation(),children:r.jsxs(ci,{children:[r.jsx(li,{asChild:!0,children:r.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-zinc-400 opacity-0 group-hover:opacity-100",children:r.jsx(tl,{className:"h-4 w-4"})})}),r.jsxs(na,{align:"end",children:[r.jsx(bt,{onClick:()=>e(`/products/${u.slug}`),children:"Edit"}),r.jsxs(bt,{onClick:()=>void i.mutateAsync(u.id),className:"gap-2",children:[r.jsx(Mp,{className:"h-3.5 w-3.5"}),"Duplicate"]}),r.jsx(ra,{}),r.jsxs(bt,{onClick:()=>void f.mutateAsync(u.id),className:"gap-2 text-zinc-500",children:[r.jsx(Cp,{className:"h-3.5 w-3.5"}),"Archive"]})]})]})})]},u.id)})})]}):r.jsx(We,{icon:r.jsx(qt,{className:"h-5 w-5"}),title:"No products found",description:s?"Try a different search.":"Create your first product.",action:r.jsxs(se,{onClick:()=>e("/products/new"),className:"gap-1.5",children:[r.jsx(br,{className:"h-4 w-4"}),"Add Product"]})})})]})}const mN={breadcrumb:()=>"Products"};function pN(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 xN({productId:e,variants:t,onChange:n,currency:s,existing:a=!1}){const[o,c]=l.useState(t.map(d=>({...d,_priceDisplay:(d.priceMinor/100).toFixed(2)}))),i=(d,h,m)=>{c(x=>{const g=x.map(p=>{if(p.id!==d)return p;if(h==="_priceDisplay"){const v=parseFloat(m);return{...p,_priceDisplay:m,priceMinor:isNaN(v)?p.priceMinor:Math.round(v*100)}}return{...p,[h]:m}});return n(g.map(({_priceDisplay:p,...v})=>v)),g})},f=()=>{const d=pN(e),h=[...o,{...d,_priceDisplay:"0.00"}];c(h),n(h.map(({_priceDisplay:m,...x})=>x))},u=d=>{const h=o.filter(m=>m.id!==d);c(h),n(h.map(({_priceDisplay:m,...x})=>x))};return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"SKU"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Name"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Price"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Stock"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Status"}),r.jsx("th",{className:"w-10 px-3 py-2"})]})}),r.jsxs("tbody",{children:[o.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:6,className:"px-3 py-6 text-center text-sm text-zinc-400",children:a?"No variants.":"No variants yet. Add one below."})}),o.map(d=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0","data-testid":P("product","variant-row",d.id),children:[r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"font-mono text-xs",children:d.sku}):r.jsx(pe,{value:d.sku,onChange:h=>i(d.id,"sku",h.target.value),placeholder:"SKU-001",className:"h-7 font-mono text-xs w-28"})}),r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"text-xs",children:d.name}):r.jsx(pe,{value:d.name,onChange:h=>i(d.id,"name",h.target.value),placeholder:"Variant name",className:"h-7 text-xs"})}),r.jsx("td",{className:"px-3 py-2",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx("span",{className:"text-xs text-zinc-400",children:s}),r.jsx(pe,{value:d._priceDisplay,onChange:h=>i(d.id,"_priceDisplay",h.target.value),"data-testid":P("product","variant-price",d.id),onBlur:h=>{const m=parseFloat(h.target.value);isNaN(m)||i(d.id,"_priceDisplay",m.toFixed(2))},className:"h-7 w-20 text-right font-mono text-xs"})]})}),r.jsx("td",{className:"px-3 py-2 text-right",children:a?r.jsx(Ze,{to:`/inventory?q=${encodeURIComponent(d.sku)}`,"data-testid":P("product","variant-stock",d.id),title:"Adjust stock in Inventory",className:"font-mono text-xs text-zinc-700 underline underline-offset-2 hover:text-zinc-900",children:d.stock}):r.jsx(pe,{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})}),r.jsx("td",{className:"px-3 py-2",children:a?r.jsx("span",{className:"text-xs capitalize",children:d.status}):r.jsxs(Sr,{value:d.status,onValueChange:h=>i(d.id,"status",h),children:[r.jsx(Zn,{className:"h-7 w-24 text-xs",children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"active",children:"Active"}),r.jsx(qe,{value:"inactive",children:"Inactive"})]})]})}),r.jsx("td",{className:"px-3 py-2",children:!a&&r.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:r.jsx(sl,{className:"h-3.5 w-3.5"})})})]},d.id))]})]})}),r.jsxs("div",{className:"flex items-center justify-between pt-1",children:[r.jsxs("p",{className:"text-xs text-zinc-400",children:[o.length," variant",o.length!==1?"s":"",o.length>0&&r.jsxs(r.Fragment,{children:[" · Total stock: ",o.reduce((d,h)=>d+h.stock,0)]})]}),!a&&r.jsxs(se,{variant:"outline",size:"sm",onClick:f,className:"gap-1.5",children:[r.jsx(br,{className:"h-3.5 w-3.5"}),"Add Variant"]})]})]})}function gN({media:e,onChange:t}){const[n,s]=l.useState(""),[a,o]=l.useState(""),[c,i]=l.useState(!1),[f,u]=l.useState(null),d=()=>{if(!n.trim())return;const g=[...e,{url:n.trim(),altText:a.trim(),position:e.length}];t(g),s(""),o("")},h=g=>{const p=e.filter((v,y)=>y!==g).map((v,y)=>({...v,position:y}));t(p)},m=g=>{const p=e[g];if(!p)return;const v=[p,...e.filter((y,w)=>w!==g)].map((y,w)=>({...y,position:w}));t(v)},x=(g,p)=>{const v=e.map((y,w)=>w===g?{...y,altText:p}:y);t(v)};return r.jsxs("div",{className:"space-y-3",children:[e.length>0&&r.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:e.map((g,p)=>r.jsxs("div",{className:T("group relative rounded-md border bg-zinc-50 overflow-hidden",p===0?"border-blue-300 ring-1 ring-blue-300":"border-zinc-200"),children:[r.jsx("div",{className:"aspect-square flex items-center justify-center",children:g.url?r.jsx("img",{src:g.url,alt:g.altText||"Product image",className:"h-full w-full object-cover",onError:v=>{v.target.style.display="none"}}):r.jsx(zp,{className:"h-6 w-6 text-zinc-300"})}),p===0&&r.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"}),r.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&&r.jsx("button",{onClick:()=>m(p),className:"rounded bg-white/90 p-1 text-zinc-700 hover:bg-white",title:"Set as primary",children:r.jsx(Gp,{className:"h-3 w-3"})}),r.jsx("button",{onClick:()=>h(p),className:"rounded bg-white/90 p-1 text-red-600 hover:bg-white",title:"Remove",children:r.jsx(Yt,{className:"h-3 w-3"})})]}),r.jsx("div",{className:"border-t border-zinc-100 px-1.5 py-1",children:f===p?r.jsx("input",{autoFocus:!0,value:g.altText,onChange:v=>x(p,v.target.value),onBlur:()=>u(null),className:"w-full text-[10px] bg-transparent border-b border-zinc-300 outline-none",placeholder:"Alt text..."}):r.jsx("button",{onClick:()=>u(p),className:"w-full text-left text-[10px] text-zinc-400 hover:text-zinc-600 truncate",children:g.altText||"Add alt text"})})]},p))}),r.jsx("div",{className:T("rounded-md border-2 border-dashed p-4 transition-colors",c?"border-blue-400 bg-blue-50":"border-zinc-200"),onDragOver:g=>{g.preventDefault(),i(!0)},onDragLeave:()=>i(!1),onDrop:g=>{g.preventDefault(),i(!1)},children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs text-zinc-500 text-center",children:"Add image by URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Ee,{className:"text-xs",children:"Image URL"}),r.jsx(pe,{value:n,onChange:g=>s(g.target.value),placeholder:"https://cdn.example.com/image.jpg",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsxs("div",{className:"flex-1 space-y-1.5",children:[r.jsx(Ee,{className:"text-xs",children:"Alt Text"}),r.jsx(pe,{value:a,onChange:g=>o(g.target.value),placeholder:"Describe the image",className:"text-xs h-8",onKeyDown:g=>g.key==="Enter"&&d()})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs(se,{type:"button",size:"sm",onClick:d,disabled:!n.trim(),className:"h-8 gap-1",children:[r.jsx(br,{className:"h-3.5 w-3.5"}),"Add"]})})]})]})}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[e.length," image",e.length!==1?"s":""," · Drag to reorder (coming soon)"]})]})}function vN({title:e,description:t,url:n}){const o=e.length>60,c=t.length>155,i=o?e.slice(0,60)+"...":e,f=c?t.slice(0,155)+"...":t;return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-4",children:r.jsxs("div",{className:"max-w-lg",children:[r.jsx("p",{className:"text-xs text-zinc-400 mb-1 truncate",children:n||"https://yourstore.com/products/..."}),r.jsx("p",{className:T("text-[17px] leading-snug text-blue-700 cursor-pointer hover:underline mb-1",!e&&"text-zinc-300 italic"),children:i||"Page title appears here"}),r.jsx("p",{className:T("text-sm leading-relaxed text-zinc-500",!t&&"text-zinc-300 italic"),children:f||"Meta description appears here..."})]})}),(o||c)&&r.jsxs("div",{className:"space-y-1.5",children:[o&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(vs,{className:"h-3.5 w-3.5 shrink-0"}),"Title is ",e.length," chars — Google shows ~60. Consider shortening."]}),c&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600",children:[r.jsx(vs,{className:"h-3.5 w-3.5 shrink-0"}),"Description is ",t.length," chars — Google shows ~155. Consider shortening."]})]}),r.jsxs("div",{className:"flex gap-4 text-xs text-zinc-400",children:[r.jsxs("span",{className:T(o?"text-amber-500":"text-zinc-400"),children:["Title: ",e.length,"/",60]}),r.jsxs("span",{className:T(c?"text-amber-500":"text-zinc-400"),children:["Description: ",t.length,"/",155]})]})]})}function Ra({productId:e,field:t,context:n,onApply:s,className:a}){const[o,c]=l.useState(null),i=dN(),f=async()=>{c(null);const h={};n.name&&(h.name=n.name),n.current&&(h.current=n.current);const m=await i.mutateAsync({id:e,field:t,context:h});c(m.suggestion)},u=()=>{o&&(s(o),c(null))},d=()=>{c(null)};return r.jsxs("div",{className:T("space-y-2",a),"data-testid":P("product","ai-enrich",t),children:[r.jsxs(se,{type:"button",variant:"outline",size:"sm",onClick:()=>void f(),disabled:i.isPending,className:"gap-1.5 text-xs text-purple-700 border-purple-200 hover:bg-purple-50 hover:border-purple-300",children:[r.jsx(Wa,{className:T("h-3.5 w-3.5",i.isPending&&"animate-spin")}),i.isPending?"Enhancing...":"Enhance with AI"]}),o&&r.jsxs("div",{className:"rounded-md border border-purple-200 bg-purple-50 p-3 space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-purple-800 uppercase tracking-wider",children:"AI Suggestion"}),r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:o}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(se,{type:"button",size:"sm",onClick:u,className:"gap-1.5 bg-purple-600 hover:bg-purple-700 text-white text-xs",children:[r.jsx(St,{className:"h-3.5 w-3.5"}),"Apply"]}),r.jsxs(se,{type:"button",variant:"ghost",size:"sm",onClick:d,className:"gap-1.5 text-zinc-500 text-xs",children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Dismiss"]})]})]})]})}const yN={name:"",slug:"",description:"",shortDescription:"",status:"draft",type:"simple",seoTitle:"",seoDescription:"",media:[],variants:[],categoryIds:[],metadata:{}};function bN(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function mc(){const{slug:e}=xo(),t=Ct(),n=!e||e==="new",{data:s,isLoading:a}=aN(n?"":e??""),o=oN(),c=iN(),[i,f]=l.useState(yN),[u,d]=l.useState(!1),[h,m]=l.useState(!1),[x,g]=Xt();l.useEffect(()=>{s&&f(s)},[s]);const p=(j,C)=>{d(!0),f(S=>{const E={...S,[j]:C};return j==="name"&&!h&&(E.slug=bN(C)),E})},v=async()=>{const j=x;if(g(),n){const C=await o.mutateAsync({product:i,idempotencyKey:j});t(`/products/${C.slug}`)}else if(s){const C=new Set(s.variants.map(k=>k.id)),S=(i.variants??[]).filter(k=>C.has(k.id)).map(({id:k,priceMinor:z,compareAtPriceMinor:O})=>({id:k,priceMinor:z,compareAtPriceMinor:O})),E={...i,variants:S};await c.mutateAsync({id:s.id,data:E,idempotencyKey:j}),d(!1)}},y=o.isPending||c.isPending;if(!n&&a)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-48"}),r.jsx(xe,{className:"h-96 w-full"})]});if(!n&&!s)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx(qt,{className:"mb-3 h-8 w-8 text-zinc-300"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Product not found"}),r.jsx(Ze,{to:"/products",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to products"})]});const w=(s==null?void 0:s.id)??"new";return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(Ze,{to:"/products",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Co,{className:"h-4 w-4"}),"Products"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("h1",{className:"text-base font-semibold text-zinc-900",children:n?"New Product":i.name||"Edit Product"}),u&&r.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:"Unsaved changes"})]}),r.jsx(se,{onClick:()=>void v(),disabled:y||!i.name,className:"gap-1.5","data-testid":P("product","save"),children:y?r.jsxs(r.Fragment,{children:[r.jsx(Mr,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Hp,{className:"h-4 w-4"}),n?"Create Product":"Save Changes"]})})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-3",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs(Br,{defaultValue:"general",children:[r.jsxs(or,{className:"mb-4",children:[r.jsx(Te,{value:"general",children:"General"}),r.jsx(Te,{value:"variants","data-testid":P("product","tab","variants"),children:"Variants"}),r.jsx(Te,{value:"media",children:"Media"}),r.jsx(Te,{value:"seo",children:"SEO"}),s&&r.jsx(Te,{value:"history","data-testid":P("product","tab","history"),children:"History"})]}),r.jsx(Ue,{value:"general",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{children:["Product Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(pe,{value:i.name??"",onChange:j=>p("name",j.target.value),placeholder:"e.g. Classic White T-Shirt","data-testid":P("product","name"),className:"text-base"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Slug"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-zinc-400 shrink-0",children:"/products/"}),r.jsx(pe,{value:i.slug??"",onChange:j=>{m(!0),p("slug",j.target.value)},placeholder:"classic-white-t-shirt",className:"font-mono text-sm"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Description"}),!n&&r.jsx(Ra,{productId:w,field:"description",context:{...i.name?{name:i.name}:{},...i.description?{current:i.description}:{}},onApply:j=>p("description",j)})]}),r.jsx(Kt,{value:i.description??"",onChange:j=>p("description",j.target.value),placeholder:"Describe this product...",rows:5})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Short Description"}),r.jsx(Kt,{value:i.shortDescription??"",onChange:j=>p("shortDescription",j.target.value),placeholder:"Brief one-line description...",rows:2})]})]})}),r.jsx(Ue,{value:"variants",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Variants"}),r.jsx(xN,{productId:w,variants:i.variants??[],onChange:j=>p("variants",j),currency:"GBP",existing:!n})]})}),r.jsx(Ue,{value:"media",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:[r.jsx("h3",{className:"text-sm font-semibold text-zinc-900 mb-3",children:"Media"}),r.jsx(gN,{media:i.media??[],onChange:j=>p("media",j)})]})}),r.jsx(Ue,{value:"seo",className:"space-y-4",children:r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"SEO Title"}),!n&&r.jsx(Ra,{productId:w,field:"title",context:i.name?{name:i.name}:{},onApply:j=>p("seoTitle",j),className:"scale-90 origin-right"})]}),r.jsx(pe,{value:i.seoTitle??"",onChange:j=>p("seoTitle",j.target.value),placeholder:i.name??"SEO title..."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"SEO Description"}),!n&&r.jsx(Ra,{productId:w,field:"seoDescription",context:{...i.name?{name:i.name}:{},...i.seoDescription?{current:i.seoDescription}:{}},onApply:j=>p("seoDescription",j),className:"scale-90 origin-right"})]}),r.jsx(Kt,{value:i.seoDescription??"",onChange:j=>p("seoDescription",j.target.value),placeholder:"Meta description for search engines...",rows:3})]}),r.jsxs("div",{className:"pt-2 border-t border-zinc-100",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-400 mb-3",children:"Preview"}),r.jsx(vN,{title:i.seoTitle||i.name||"",description:i.seoDescription||i.shortDescription||"",url:`https://yourstore.com/products/${i.slug??""}`})]})]})}),s&&r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(ui,{collection:"products",id:s.id,detailPath:`/api/admin/products/${encodeURIComponent(s.id)}`})})})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Status"}),r.jsxs(Sr,{value:i.status??"draft",onValueChange:j=>p("status",j),children:[r.jsx(Zn,{"data-testid":P("product","status"),children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"draft",children:"Draft"}),r.jsx(qe,{value:"active",children:"Active"}),r.jsx(qe,{value:"archived",children:"Archived"})]})]}),r.jsxs("p",{className:"text-xs text-zinc-400",children:[i.status==="draft"&&"Not visible to customers.",i.status==="active"&&"Visible and purchasable.",i.status==="archived"&&"Hidden, not purchasable."]})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-3",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-zinc-400",children:"Product Type"}),r.jsxs(Sr,{value:i.type??"simple",onValueChange:j=>p("type",j),children:[r.jsx(Zn,{children:r.jsx(Er,{})}),r.jsxs(Jn,{children:[r.jsx(qe,{value:"simple",children:"Simple"}),r.jsx(qe,{value:"variable",children:"Variable"})]})]})]}),!n&&s&&r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-4 space-y-2 text-xs text-zinc-500",children:[r.jsx("h3",{className:"font-semibold uppercase tracking-wider text-zinc-400",children:"Summary"}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Variants"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.variants.length})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Total stock"}),r.jsx("span",{className:"font-mono font-medium text-zinc-700",children:s.variants.reduce((j,C)=>j+C.stock,0)})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Media"}),r.jsx("span",{className:"font-medium text-zinc-700",children:s.media.length})]})]})]})]})]})}const wN={breadcrumb:e=>"Edit"},jN={breadcrumb:()=>"New Product"},NN=[{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 CN({row:e,onAdjust:t}){const[n,s]=l.useState(0),[a,o]=l.useState("manual"),[c,i]=l.useState(!1),[f,u]=Xt(),d=()=>{n!==0&&(t(n,a,f),u(),s(0),i(!0),setTimeout(()=>i(!1),1500))};return r.jsxs("div",{className:"flex items-center gap-2","data-testid":P("inventory","adjust",e.variantId),children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>s(h=>h-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:r.jsx(Kp,{className:"h-3 w-3"})}),r.jsx("input",{type:"number",value:n,onChange:h=>s(parseInt(h.target.value)||0),className:T("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")}),r.jsx("button",{onClick:()=>s(h=>h+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:r.jsx(br,{className:"h-3 w-3"})})]}),r.jsxs(Sr,{value:a,onValueChange:h=>o(h),children:[r.jsx(Zn,{className:"h-7 w-28 text-xs",children:r.jsx(Er,{})}),r.jsx(Jn,{children:NN.map(h=>r.jsx(qe,{value:h.value,children:h.label},h.value))})]}),r.jsx(se,{size:"sm",variant:c?"secondary":"default",className:"h-7 px-2 text-xs gap-1",onClick:d,disabled:n===0||c,children:c?r.jsxs(r.Fragment,{children:[r.jsx(St,{className:"h-3 w-3 text-green-600"}),r.jsx("span",{className:"text-green-600",children:"Done"})]}):"Apply"})]})}const SN=Bo,EN=Ko,Jf=l.forwardRef(({className:e,...t},n)=>r.jsx(Bs,{className:T("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 RN=As("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"}}),eh=l.forwardRef(({side:e="right",className:t,children:n,...s},a)=>r.jsxs(EN,{children:[r.jsx(Jf,{}),r.jsxs(Ks,{ref:a,className:T(RN({side:e}),"border-zinc-200",t),...s,children:[n,r.jsxs(Rd,{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:[r.jsx(Yt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));eh.displayName="SheetContent";const th=({className:e,...t})=>r.jsx("div",{className:T("flex flex-col space-y-2 text-left",e),...t});th.displayName="SheetHeader";const nh=l.forwardRef(({className:e,...t},n)=>r.jsx(qo,{ref:n,className:T("text-lg font-semibold text-zinc-900",e),...t}));nh.displayName="SheetTitle";const PN=l.forwardRef(({className:e,...t},n)=>r.jsx(Ho,{ref:n,className:T("text-sm text-zinc-500",e),...t}));PN.displayName="SheetDescription";function kN(e={}){return Ce({queryKey:["inventory","list",e],queryFn:()=>W.get("/api/admin/inventory",e)})}function TN(e){return Ce({queryKey:["inventory","history",e],queryFn:()=>W.get(`/api/admin/inventory/${e}/history`),enabled:!!e})}function AN(){const e=ye();return we({mutationFn:({variantId:t,delta:n,reason:s,idempotencyKey:a})=>W.post(`/api/admin/inventory/${t}/adjust`,{delta:n,reason:s},a===void 0?void 0:{idempotencyKey:a}),onMutate:async({variantId:t,delta:n})=>{await e.cancelQueries({queryKey:["inventory","list"]});const s=e.getQueryData(["inventory","list",{}]);return s&&e.setQueryData(["inventory","list",{}],s.map(a=>a.variantId===t?{...a,stock:Math.max(0,a.stock+n)}:a)),{previousData:s}},onError:(t,n,s)=>{s!=null&&s.previousData&&e.setQueryData(["inventory","list",{}],s.previousData)},onSuccess:()=>{e.invalidateQueries({queryKey:["inventory"]})}})}function MN({variantId:e,productName:t,sku:n,onClose:s}){const{data:a,isLoading:o}=TN(e);return r.jsx(SN,{open:!0,onOpenChange:c=>!c&&s(),children:r.jsxs(eh,{className:"w-[480px] sm:max-w-[480px] overflow-y-auto",children:[r.jsxs(th,{children:[r.jsx(nh,{children:"Stock History"}),r.jsxs("div",{className:"mt-1",children:[r.jsx("p",{className:"text-sm font-medium text-zinc-700",children:t}),r.jsx("p",{className:"font-mono text-xs text-zinc-400",children:n})]})]}),r.jsx("div",{className:"mt-6",children:o?r.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((c,i)=>r.jsx(xe,{className:"h-12 w-full"},i))}):!a||a.length===0?r.jsx("p",{className:"text-sm text-zinc-400 text-center py-8",children:"No adjustment history found."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{className:"bg-zinc-50 border-b border-zinc-200",children:r.jsxs("tr",{children:[r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Date"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Adj"}),r.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium uppercase tracking-wider text-zinc-500",children:"New Qty"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Reason"}),r.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Actor"})]})}),r.jsx("tbody",{children:a.map(c=>r.jsxs("tr",{className:"border-b border-zinc-100 last:border-0",children:[r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 whitespace-nowrap",children:Oe(c.timestamp)}),r.jsxs("td",{className:T("px-3 py-2 text-right font-mono text-sm font-medium",c.adjustment>0?"text-green-600":"text-red-600"),children:[c.adjustment>0?"+":"",c.adjustment]}),r.jsx("td",{className:"px-3 py-2 text-right font-mono text-sm text-zinc-700",children:c.newQty}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500 capitalize",children:c.reason.replace(/-/g," ")}),r.jsx("td",{className:"px-3 py-2 text-xs text-zinc-500",children:c.actor})]},c.id))})]})})})]})})}const _N={in_stock:"success",low_stock:"warning",out_of_stock:"destructive"},pc={in_stock:"In Stock",low_stock:"Low Stock",out_of_stock:"Out of Stock"};function IN(){const[e]=kc(),[t,n]=l.useState(()=>e.get("q")??""),[s,a]=l.useState("all"),[o,c]=l.useState(null),{data:i,isLoading:f}=kN({q:t||void 0,status:s==="all"?void 0:s,sort:"urgency",limit:200}),u=AN(),d=m=>(x,g,p)=>{u.mutateAsync({variantId:m,delta:x,reason:g,idempotencyKey:p})},h=m=>m==="out_of_stock"?"border-l-4 border-l-red-300":m==="low_stock"?"border-l-4 border-l-amber-300":"";return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inventory"}),r.jsx("p",{className:"text-sm text-zinc-500",children:i?`${i.length} variants`:"Loading..."})]})}),r.jsxs("div",{className:"flex gap-3 items-center",children:[r.jsx("div",{className:"flex gap-1.5",children:["all","out_of_stock","low_stock","in_stock"].map(m=>r.jsx("button",{onClick:()=>a(m),className:T("rounded-full px-3 py-1 text-xs font-medium transition-colors",s===m?"bg-zinc-900 text-white":"bg-zinc-100 text-zinc-600 hover:bg-zinc-200"),children:m==="all"?"All":pc[m]},m))}),r.jsxs("div",{className:"relative ml-auto max-w-xs flex-1",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search SKU or product...",value:t,onChange:m=>n(m.target.value),className:"pl-9 h-8 text-sm"})]})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:f?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((m,x)=>r.jsx(xe,{className:"h-11 w-full"},x))}):i!=null&&i.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Product"}),r.jsx(ne,{children:"SKU / Options"}),r.jsx(ne,{className:"text-right",children:"Stock"}),r.jsx(ne,{className:"text-right",children:"Threshold"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Adjust"}),r.jsx(ne,{className:"text-right",children:"History"})]})}),r.jsx(Nn,{children:i.map(m=>r.jsxs(Be,{"data-testid":P("inventory","row",m.variantId),className:T("transition-colors",h(m.status)),children:[r.jsx(re,{children:r.jsx("p",{className:"font-medium text-zinc-800 text-sm",children:m.productName})}),r.jsx(re,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-mono text-xs text-zinc-500",children:m.sku}),m.options.length>0&&r.jsx("p",{className:"text-[10px] text-zinc-400",children:m.options.map(x=>`${x.name}: ${x.value}`).join(" · ")})]})}),r.jsx(re,{className:T("text-right font-mono text-base font-semibold",m.status==="out_of_stock"?"text-red-600":m.status==="low_stock"?"text-amber-600":"text-zinc-800"),children:m.stock}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-400",children:m.threshold}),r.jsx(re,{children:r.jsx(Zf,{variant:_N[m.status],className:"text-[10px]",children:pc[m.status]})}),r.jsx(re,{children:r.jsx(CN,{row:m,onAdjust:d(m.variantId)})}),r.jsx(re,{className:"text-right",children:r.jsxs("button",{onClick:()=>c(m),className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium ml-auto",children:[r.jsx(Wn,{className:"h-3.5 w-3.5"}),"History"]})})]},m.variantId))})]}):r.jsx(We,{icon:r.jsx(Xc,{className:"h-5 w-5"}),title:"No inventory found",description:"No variants match your filters."})}),o&&r.jsx(MN,{variantId:o.variantId,productName:o.productName,sku:o.sku,onClose:()=>c(null)})]})}const ON={breadcrumb:()=>"Inventory"};function DN(e={}){return Ce({queryKey:["customers","list",e],queryFn:async()=>(await W.get("/api/admin/customers",e)).customers})}function zN(e){return Ce({queryKey:["customers","detail",e],queryFn:()=>W.get(`/api/admin/customers/${e}`),enabled:!!e})}function LN(e){return Ce({queryKey:["customers","orders",e],queryFn:()=>W.get(`/api/admin/customers/${e}/orders`),enabled:!!e})}function FN(){const e=ye();return we({mutationFn:({customerId:t,body:n})=>W.post(`/api/admin/customers/${t}/notes`,{body:n}),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:["customers","detail",n.customerId]})}})}function $N(){const e=Ct(),[t,n]=l.useState(""),{data:s,isLoading:a}=DN({q:t||void 0,limit:100});return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Customers"}),r.jsx("p",{className:"text-sm text-zinc-500",children:s?`${s.length} customers`:"Loading..."})]})}),r.jsxs("div",{className:"relative max-w-sm",children:[r.jsx(tr,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-400"}),r.jsx(pe,{placeholder:"Search by name or email...",value:t,onChange:o=>n(o.target.value),className:"pl-9 h-8 text-sm"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:a?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((o,c)=>r.jsx(xe,{className:"h-11 w-full"},c))}):s!=null&&s.length?r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Customer"}),r.jsx(ne,{className:"text-right",children:"Orders"}),r.jsx(ne,{className:"text-right",children:"Total Spent"}),r.jsx(ne,{children:"Since"}),r.jsx(ne,{className:"text-right",children:"Last Order"})]})}),r.jsx(Nn,{children:s.map(o=>{var i;const c=[o.firstName,o.lastName].filter(Boolean).join(" ");return r.jsxs(Be,{"data-testid":P("customers","row",o.id),className:"cursor-pointer",onClick:()=>e(`/customers/${o.id}`),children:[r.jsx(re,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.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:(((i=o.firstName)==null?void 0:i[0])??o.email[0]??"?").toUpperCase()}),r.jsxs("div",{children:[c&&r.jsx("p",{className:"text-sm font-medium text-zinc-800",children:c}),r.jsx("p",{className:"text-xs text-zinc-500",children:o.email})]})]})}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:o.orderCount}),r.jsx(re,{className:"text-right font-mono text-sm text-zinc-700",children:me(o.totalSpentMinor,"GBP")}),r.jsx(re,{className:"text-sm text-zinc-500",children:Oe(o.createdAt)}),r.jsx(re,{className:"text-right text-sm text-zinc-400",children:o.orderCount>0?ht(o.updatedAt):"—"})]},o.id)})})]}):r.jsx(We,{icon:r.jsx(So,{className:"h-5 w-5"}),title:"No customers found",description:t?"Try a different search.":"Customers will appear as orders are placed."})})]})}const UN={breadcrumb:()=>"Customers"};function VN({customer:e,stats:t}){var s;const n=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.email;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-4",children:[r.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:(((s=e.firstName)==null?void 0:s[0])??e.email[0]??"?").toUpperCase()}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h2",{className:"text-base font-semibold text-zinc-900 truncate",children:n}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-3 text-sm text-zinc-500",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(nl,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:e.email})]}),e.phone&&r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(qp,{className:"h-3.5 w-3.5"}),e.phone]})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-zinc-400",children:[r.jsx(Rp,{className:"h-3 w-3"}),"Customer since ",Oe(e.createdAt)]})]}),e.requiresPasswordReset&&r.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"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[r.jsx(Pa,{icon:r.jsx(Gn,{className:"h-4 w-4 text-blue-500"}),label:"Total Orders",value:String(t.orderCount)}),r.jsx(Pa,{icon:r.jsx(Ga,{className:"h-4 w-4 text-green-500"}),label:"Lifetime Value","data-testid":P("customer","stat","lifetime-value"),value:me(t.lifetimeRevenueMinor,"GBP"),mono:!0}),r.jsx(Pa,{icon:r.jsx(Ga,{className:"h-4 w-4 text-indigo-500"}),label:"Avg Order","data-testid":P("customer","stat","avg-order"),value:me(t.avgOrderValueMinor,"GBP"),mono:!0})]}),t.lastOrderAt&&r.jsxs("p",{className:"text-xs text-zinc-400",children:["Last order: ",ht(t.lastOrderAt)]})]})}function Pa({icon:e,label:t,value:n,mono:s,"data-testid":a}){return r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-white p-3","data-testid":a,children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e,r.jsx("span",{className:"text-xs text-zinc-500",children:t})]}),r.jsx("p",{className:`text-base font-semibold text-zinc-900 ${s?"font-mono":""}`,children:n})]})}function BN({orders:e,isLoading:t}){const n=Ct();return t?r.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>r.jsx(xe,{className:"h-11 w-full"},a))}):!e||e.length===0?r.jsx(We,{icon:r.jsx(Gn,{className:"h-5 w-5"}),title:"No orders",description:"This customer hasn't placed any orders yet."}):r.jsx("div",{className:"rounded-md border border-zinc-200 overflow-hidden",children:r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Order #"}),r.jsx(ne,{children:"Status"}),r.jsx(ne,{children:"Items"}),r.jsx(ne,{className:"text-right",children:"Total"}),r.jsx(ne,{className:"text-right",children:"Date"})]})}),r.jsx(Nn,{children:e.map(s=>r.jsxs(Be,{"data-testid":P("customer","orders-row",s.id),className:"cursor-pointer",onClick:()=>n(`/orders/${s.orderNumber}`),children:[r.jsxs(re,{className:"font-mono text-sm font-medium text-blue-600",children:["#",s.orderNumber]}),r.jsx(re,{children:r.jsx(Xn,{status:s.status})}),r.jsxs(re,{className:"text-zinc-500",children:[s.lineItems.length," item",s.lineItems.length!==1?"s":""]}),r.jsx(re,{className:"text-right font-mono text-sm",children:me(s.totalMinor,s.currency)}),r.jsx(re,{className:"text-right text-sm text-zinc-500",children:ht(s.createdAt)})]},s.id))})]})})}function KN({notes:e}){return r.jsx("div",{className:"space-y-2",children:e.length===0?r.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)=>r.jsxs("div",{className:"rounded-md border border-zinc-200 bg-zinc-50 p-3",children:[r.jsx("p",{className:"text-sm text-zinc-700 whitespace-pre-wrap",children:t.body}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-zinc-400",children:[r.jsx("span",{className:"font-medium text-zinc-500",children:t.actor}),r.jsx("span",{children:"·"}),r.jsx("time",{dateTime:t.at,title:Oe(t.at),children:ht(t.at)})]})]},n))})}function qN(){const{id:e}=xo(),[t,n]=l.useState(""),s=l.useRef(!1),[a,o]=l.useState(!1),{data:c,isLoading:i}=zN(e??""),{data:f,isLoading:u}=LN(e??""),d=FN(),h=async v=>{if(v.preventDefault(),!(!t.trim()||!e||s.current)){s.current=!0,o(!0);try{await d.mutateAsync({customerId:e,body:t.trim()}),n("")}finally{s.current=!1,o(!1)}}};if(i)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(xe,{className:"h-8 w-32"}),r.jsx(xe,{className:"h-32 w-full"}),r.jsx(xe,{className:"h-48 w-full"})]});if(!c)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[r.jsx("p",{className:"text-sm text-zinc-500",children:"Customer not found"}),r.jsx(Ze,{to:"/customers",className:"mt-3 text-sm text-blue-600 hover:underline",children:"← Back to customers"})]});const{customer:m,stats:x}=c,g=[m.firstName,m.lastName].filter(Boolean).join(" ")||m.email,p=m.metadata.adminNotes??[];return r.jsxs("div",{className:"space-y-5","data-testid":P("customer","detail"),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ze,{to:"/customers",className:"flex items-center gap-1.5 text-sm text-zinc-500 hover:text-zinc-700",children:[r.jsx(Co,{className:"h-4 w-4"}),"Customers"]}),r.jsx("span",{className:"text-zinc-300",children:"/"}),r.jsx("span",{className:"min-w-0 text-sm font-medium text-zinc-900 [overflow-wrap:anywhere]",children:g})]}),r.jsxs(Br,{defaultValue:"overview",children:[r.jsxs(or,{children:[r.jsx(Te,{value:"overview","data-testid":P("customer","tab","overview"),children:"Overview"}),r.jsx(Te,{value:"history","data-testid":P("customer","tab","history"),children:"History"})]}),r.jsxs(Ue,{value:"overview",className:"space-y-5",children:[r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(VN,{customer:m,stats:x})}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-hidden",children:[r.jsx("div",{className:"border-b border-zinc-100 px-4 py-3",children:r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Order History"})}),r.jsx("div",{className:"p-4",children:r.jsx(BN,{orders:f,isLoading:u})})]}),r.jsxs("div",{className:"rounded-lg border border-zinc-200 bg-white p-5 space-y-3","data-testid":P("customer","notes"),children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:"Notes"}),r.jsx(KN,{notes:p}),r.jsxs("form",{onSubmit:v=>void h(v),className:"flex gap-2 pt-2",children:[r.jsx(Kt,{placeholder:"Add a note about this customer...",value:t,onChange:v=>n(v.target.value),rows:2,className:"flex-1 text-sm"}),r.jsx(se,{type:"submit",size:"icon",disabled:!t.trim()||a,className:"self-end h-9 w-9",children:r.jsx(rl,{className:"h-4 w-4"})})]})]})]}),r.jsx(Ue,{value:"history",children:r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white p-5",children:r.jsx(ui,{collection:"customers",id:m.id,detailPath:`/api/admin/customers/${encodeURIComponent(m.id)}`})})})]})]})}const HN={breadcrumb:e=>"Customer"},rh=(e,t)=>`/api/admin/settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;function WN(){return Ce({queryKey:["settings"],queryFn:()=>W.get("/api/admin/settings")})}function GN(){const e=ye();return we({mutationFn:({slot:t,path:n,value:s})=>W.put(rh(t,n),{value:s}),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}function QN(){const e=ye();return we({mutationFn:({slot:t,path:n})=>W.delete(rh(t,n)),onSuccess:()=>e.invalidateQueries({queryKey:["settings"]})})}const YN={payments:"Payments",email:"Email",reviews:"Reviews",search:"Search",analytics:"Analytics",shipping:"Shipping",tax:"Tax",ai:"AI"},XN=(e,t)=>`${e}-${t}`;function ZN(e){return e.source==="config"||e.source==="env"?"Set by environment":e.secret?e.state==="set"?"Set":"Not set":e.state==="set"?String(e.value??""):"Not set"}function JN({slot:e,field:t,onSaved:n}){const s=l.useRef(null),a=GN(),o=QN(),[c,i]=l.useState(null),f=l.useRef(!1),u=XN(e,t.path),d=t.source==="config"||t.source==="env",h=async()=>{var g;const x=((g=s.current)==null?void 0:g.value)??"";if(!(x===""||f.current)){f.current=!0,i(null);try{await a.mutateAsync({slot:e,path:t.path,value:x}),s.current&&(s.current.value=""),n()}catch(p){i(p instanceof Ae?p.message:"The value was not saved")}finally{f.current=!1}}},m=async()=>{i(null);try{await o.mutateAsync({slot:e,path:t.path}),n()}catch(x){i(x instanceof Ae?x.message:"The value was not cleared")}};return r.jsxs("div",{"data-testid":`settings-field-${u}`,className:"flex flex-col gap-2 border-b border-zinc-100 py-3 last:border-b-0 sm:flex-row sm:items-center",children:[r.jsxs("div",{className:"min-w-0 sm:w-56",children:[r.jsx("label",{htmlFor:`settings-input-${u}`,className:"text-sm font-medium text-zinc-900",children:t.label}),r.jsx("p",{className:"font-mono text-[11px] text-zinc-500",children:t.path})]}),r.jsx("span",{"data-testid":`settings-state-${u}`,className:"min-w-0 truncate text-sm text-zinc-600 sm:w-44",children:ZN(t)}),!d&&r.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pe,{ref:s,id:`settings-input-${u}`,"data-testid":`settings-input-${u}`,type:t.secret?"password":"text",autoComplete:"off",spellCheck:!1,placeholder:t.secret&&t.state==="set"?"Enter a new value":""}),r.jsx(se,{type:"button",size:"sm",className:"h-9","data-testid":`settings-save-${u}`,disabled:a.isPending,onClick:()=>void h(),children:"Save"}),t.source==="settings"&&r.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-9","data-testid":`settings-clear-${u}`,disabled:o.isPending,onClick:()=>void m(),children:"Clear"})]}),c!==null&&r.jsx("p",{role:"alert",className:"text-xs text-red-600",children:c})]})]})}function e1({slot:e,onSaved:t}){return r.jsxs("section",{className:"rounded-lg border border-zinc-200 bg-white px-4",children:[r.jsxs("header",{className:"flex items-baseline gap-2 border-b border-zinc-100 py-3",children:[r.jsx("h2",{className:"text-sm font-semibold text-zinc-900",children:YN[e.slot]??e.slot}),r.jsx("span",{className:"text-xs text-zinc-500",children:e.provider})]}),e.fields.map(n=>r.jsx(JN,{slot:e.slot,field:n,onSaved:t},n.path))]})}function t1(){const{data:e,isLoading:t}=WN(),[n,s]=l.useState(!1);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Settings"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Keys and credentials for the services this store uses. The config and environment always win."})]}),n&&r.jsx("p",{"data-testid":"settings-restart-note",role:"status",className:"rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:"Saved. Restart the store to apply."}),t?r.jsx(xe,{className:"h-40 w-full"}):e===void 0||e.slots.length===0?r.jsx(We,{icon:r.jsx(Fp,{className:"h-5 w-5"}),title:"Nothing to set here",description:"None of this store's providers takes keys from Settings."}):e.slots.map(a=>r.jsx(e1,{slot:a,onSaved:()=>s(!0)},a.slot))]})}const n1={breadcrumb:()=>"Settings"},r1=100;function s1(e){return jo({queryKey:["activity",e],initialPageParam:void 0,queryFn:({pageParam:t})=>W.getPage("/api/admin/activity",{...e,limit:r1,cursor:t}),getNextPageParam:t=>{var s;const n=(s=t.meta)==null?void 0:s.nextCursor;return typeof n=="string"&&n!==""?n:void 0}})}function a1(e){return W.getText("/api/admin/activity/export",e)}const o1={applied:"bg-green-50 text-green-700",refused:"bg-red-50 text-red-700",replayed:"bg-zinc-100 text-zinc-600"};function xc(e){if(e==="")return;const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function i1(e){const t={};for(const a of["actor","command","subject","correlation","outcome"]){const o=e[a].trim();o!==""&&(t[a]=o)}const n=xc(e.since),s=xc(e.until);return n!==void 0&&(t.since=n),s!==void 0&&(t.until=s),t}function c1(e){const t=URL.createObjectURL(new Blob([e],{type:"application/x-ndjson"})),n=document.createElement("a");n.href=t,n.download=`activity-${new Date().toISOString().slice(0,10)}.ndjson`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)}const l1={actor:"",command:"",subject:"",correlation:"",outcome:"",since:"",until:""};function d1(){const[e]=kc(),[t,n]=l.useState(()=>({...l1,correlation:e.get("correlation")??""})),[s,a]=l.useState(!1),[o,c]=l.useState(null),i=i1(t),{data:f,isLoading:u,isError:d,fetchNextPage:h,hasNextPage:m,isFetchingNextPage:x}=s1(i),g=(f==null?void 0:f.pages.flatMap(y=>y.data))??[],p=y=>w=>n(N=>({...N,[y]:w})),v=async()=>{a(!0),c(null);try{const{since:y,until:w,correlation:N}=i;c1(await a1({...y!==void 0&&{since:y},...w!==void 0&&{until:w},...N!==void 0&&{correlation:N}}))}catch(y){c(y instanceof Error?y.message:String(y))}finally{a(!1)}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Activity"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Who changed what, newest first. The export covers the time and correlation filters."})]}),r.jsxs(se,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>void v(),disabled:s,"data-testid":"activity-export",children:[s?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(Op,{className:"h-3.5 w-3.5"}),"Export"]})]}),o&&r.jsxs("p",{className:"text-sm text-red-600",children:["Export failed: ",o]}),r.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[r.jsx(pe,{placeholder:"Actor (admin:<id>, system, …)",value:t.actor,onChange:y=>p("actor")(y.target.value),className:"h-8 text-sm","aria-label":"Actor","data-testid":"activity-filter-actor"}),r.jsx(pe,{placeholder:"Command (inventory.adjust, …)",value:t.command,onChange:y=>p("command")(y.target.value),className:"h-8 text-sm","aria-label":"Command","data-testid":"activity-filter-command"}),r.jsx(pe,{placeholder:"Subject id",value:t.subject,onChange:y=>p("subject")(y.target.value),className:"h-8 text-sm","aria-label":"Subject","data-testid":"activity-filter-subject"}),r.jsx(pe,{placeholder:"Correlation id",value:t.correlation,onChange:y=>p("correlation")(y.target.value),className:"h-8 text-sm","aria-label":"Correlation id","data-testid":"activity-filter-correlation"}),r.jsxs("select",{value:t.outcome,onChange:y=>p("outcome")(y.target.value),className:"h-8 rounded-md border border-zinc-200 bg-white px-2 text-sm","aria-label":"Outcome","data-testid":"activity-filter-outcome",children:[r.jsx("option",{value:"",children:"Any outcome"}),r.jsx("option",{value:"applied",children:"Applied"}),r.jsx("option",{value:"refused",children:"Refused"}),r.jsx("option",{value:"replayed",children:"Replayed"})]}),r.jsx(pe,{type:"datetime-local",value:t.since,onChange:y=>p("since")(y.target.value),className:"h-8 text-sm","aria-label":"From","data-testid":"activity-filter-since"}),r.jsx(pe,{type:"datetime-local",value:t.until,onChange:y=>p("until")(y.target.value),className:"h-8 text-sm","aria-label":"Until","data-testid":"activity-filter-until"})]}),r.jsx("div",{className:"rounded-lg border border-zinc-200 bg-white overflow-x-auto",children:u?r.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:8}).map((y,w)=>r.jsx(xe,{className:"h-11 w-full"},w))}):d?r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"Activity could not be loaded"}):g.length===0?r.jsx(We,{icon:r.jsx(Wn,{className:"h-5 w-5"}),title:"No activity found",description:"Changes to the store appear here as they are made."}):r.jsxs(wn,{children:[r.jsx(jn,{children:r.jsxs(Be,{children:[r.jsx(ne,{children:"Time"}),r.jsx(ne,{children:"Actor"}),r.jsx(ne,{children:"Command"}),r.jsx(ne,{children:"Subjects"}),r.jsx(ne,{children:"Outcome"}),r.jsx(ne,{children:"Correlation id"})]})}),r.jsx(Nn,{children:g.map(y=>r.jsxs(Be,{"data-testid":`activity-row-${y.id}`,children:[r.jsx(re,{className:"whitespace-nowrap text-xs text-zinc-500",children:Oe(y.at)}),r.jsxs(re,{className:"font-mono text-xs",children:[y.actor.kind,":",y.actor.id]}),r.jsx(re,{className:"font-mono text-xs",children:y.command}),r.jsx(re,{className:"font-mono text-xs text-zinc-600",children:y.subjects.map(w=>r.jsxs("div",{children:[w.type,":",w.id]},`${w.type}:${w.id}`))}),r.jsx(re,{children:r.jsxs("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",o1[y.outcome]),children:[y.outcome,y.responseStatus!==null&&` ${y.responseStatus}`]})}),r.jsx(re,{className:"font-mono text-xs text-zinc-500",children:y.correlationId??""})]},y.id))})]})}),m&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void h(),disabled:x,children:x?"Loading…":"Load more"})]})}const u1={breadcrumb:()=>"Activity"},f1={pending:"bg-amber-50 text-amber-700",approved:"bg-blue-50 text-blue-700",applied:"bg-green-50 text-green-700",rejected:"bg-zinc-100 text-zinc-600",failed:"bg-red-50 text-red-700"},h1={pending:"Pending",approved:"Approved",applied:"Applied",rejected:"Rejected",failed:"Failed"};function m1(e){return typeof e=="string"?e:JSON.stringify(e)}function p1(e,t){return e.kind==="policy"?`policy ${e.rule}`:e.id===t?"you":`admin ${e.id}`}function x1({proposal:e,me:t,onReject:n}){const s=ll(),a=l.useRef(!1),[o,c]=l.useState(!1),[i,f]=l.useState(null),{id:u,decision:d,outcome:h}=e,m=e.proposer.agent,x=e.proposer.userId,g=async()=>{if(!a.current){a.current=!0,c(!0),f(null);try{await s.mutateAsync(u)}catch(v){f(v instanceof Ae?v.message:"The proposal could not be approved.")}finally{a.current=!1,c(!1)}}},p=Object.entries(e.args);return r.jsxs("article",{className:"min-w-0 space-y-3 rounded-lg border border-zinc-200 bg-white p-4","data-testid":P("inbox","row",u),children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-mono text-sm font-semibold break-all text-zinc-900",children:e.command}),r.jsx("p",{className:"font-mono text-xs break-all text-zinc-500",children:e.tool})]}),r.jsx("span",{className:T("rounded-full px-2 py-0.5 text-[11px] font-medium",f1[e.status]),"data-testid":P("inbox","status",u),children:h1[e.status]})]}),r.jsxs("p",{className:"text-xs break-words text-zinc-500",children:[m.name,m.version!==void 0&&` ${m.version}`," for"," ",x===null?"a shopper":x===t?"you":`admin ${x}`,","," ",Oe(e.createdAt)]}),r.jsx(iu,{proposal:e,scope:"inbox"}),(p.length>0||e.handles.length>0)&&r.jsxs("dl",{className:"grid min-w-0 grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-3 gap-y-1 rounded-md bg-zinc-50 p-2 text-xs",children:[p.map(([v,y])=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsx("dd",{className:"font-mono whitespace-pre-wrap break-all text-zinc-800",children:m1(y)})]},v)),e.handles.map(v=>r.jsxs("div",{className:"contents",children:[r.jsx("dt",{className:"font-mono text-zinc-500 break-all",children:v}),r.jsxs("dd",{className:"text-zinc-400 italic",children:["the agent’s ",v]})]},v))]}),d!==void 0&&r.jsxs("p",{className:"text-xs break-words text-zinc-600",children:[e.status==="rejected"?"Rejected":"Approved"," by"," ",p1(d.by,t),", ",Oe(d.at),d.reason!==void 0&&`: ${d.reason}`]}),e.status==="failed"&&(h==null?void 0:h.message)!==void 0&&r.jsx("p",{className:"text-xs break-words text-red-600",children:h.message}),e.status==="applied"&&r.jsx(Ze,{to:`/activity?correlation=${encodeURIComponent(e.correlationId)}`,className:"text-xs text-blue-600 hover:underline",children:"See what it changed"}),e.status==="pending"&&r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(se,{size:"sm",className:"gap-1.5",onClick:()=>void g(),disabled:o,"data-testid":P("inbox","approve",u),children:[o?r.jsx(Mr,{className:"h-3.5 w-3.5 animate-spin"}):r.jsx(St,{className:"h-3.5 w-3.5"}),"Approve"]}),r.jsxs(se,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>n(e),disabled:o,"data-testid":P("inbox","reject",u),children:[r.jsx(Yt,{className:"h-3.5 w-3.5"}),"Reject"]}),i!==null&&r.jsx("p",{className:"text-xs text-red-600",children:i})]})]})}const g1=500;function v1({proposal:e,onClose:t}){const[n,s]=l.useState(""),[a,o]=l.useState(null),c=l.useRef(!1),[i,f]=l.useState(!1),u=dl();l.useEffect(()=>{e!==null&&(s(""),o(null))},[e]);const d=async()=>{if(!(e===null||c.current)){c.current=!0,f(!0),o(null);try{await u.mutateAsync({id:e.id,reason:n.trim()}),t()}catch(h){o(h instanceof Ae?h.message:"The proposal could not be rejected.")}finally{c.current=!1,f(!1)}}};return r.jsx(Hs,{open:e!==null,onOpenChange:h=>!h&&t(),children:r.jsxs($r,{className:"max-w-md",children:[r.jsx(Ws,{children:r.jsxs(Ur,{children:["Reject ",e==null?void 0:e.command]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"proposal-reason",children:"Reason (optional)"}),r.jsx(Kt,{id:"proposal-reason",value:n,maxLength:g1,onChange:h=>s(h.target.value),"data-testid":P("inbox","reason")})]}),a!==null&&r.jsx("p",{className:"text-sm text-red-600",children:a}),r.jsxs(Gs,{children:[r.jsx(se,{variant:"outline",onClick:t,disabled:i,children:"Cancel"}),r.jsx(se,{variant:"destructive",onClick:()=>void d(),disabled:i,"data-testid":P("inbox","reject-confirm"),children:"Reject"})]})]})})}function y1(){const[e,t]=l.useState("pending"),[n,s]=l.useState(null),{data:a}=Eo(),{data:o,isLoading:c,isError:i,fetchNextPage:f,hasNextPage:u,isFetchingNextPage:d}=ax(e),h=(o==null?void 0:o.pages.flatMap(m=>m.items))??[];return r.jsxs("div",{className:"min-w-0 space-y-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-zinc-900",children:"Inbox"}),r.jsx("p",{className:"text-sm text-zinc-500",children:"Changes agents asked for. Nothing runs until you approve it, as you."})]}),r.jsx(Br,{value:e,onValueChange:m=>t(m),children:r.jsxs(or,{children:[r.jsx(Te,{value:"pending","data-testid":P("inbox","tab","pending"),children:"Pending"}),r.jsx(Te,{value:"decided","data-testid":P("inbox","tab","decided"),children:"Decided"})]})}),c?r.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((m,x)=>r.jsx(xe,{className:"h-28 w-full"},x))}):i?r.jsx(We,{icon:r.jsx(Ha,{className:"h-5 w-5"}),title:"The inbox could not be loaded"}):h.length===0?r.jsx(We,{icon:r.jsx(Ha,{className:"h-5 w-5"}),title:e==="pending"?"Nothing waiting":"Nothing decided yet",description:"An agent's change to the store appears here until someone decides it."}):r.jsx("div",{className:"space-y-3",children:h.map(m=>r.jsx(x1,{proposal:m,me:a==null?void 0:a.userId,onReject:s},m.id))}),u&&r.jsx(se,{variant:"outline",size:"sm",onClick:()=>void f(),disabled:d,children:d?"Loading…":"Load more"}),r.jsx(v1,{proposal:n,onClose:()=>s(null)})]})}const b1={breadcrumb:()=>"Inbox"};function w1(){const e=Ct();return r.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[r.jsx("p",{className:"font-mono text-5xl font-bold text-zinc-200",children:"404"}),r.jsx("h2",{className:"mt-3 text-base font-semibold text-zinc-700",children:"Page not found"}),r.jsx("p",{className:"mt-1 text-sm text-zinc-400",children:"The page you're looking for doesn't exist."}),r.jsx("div",{className:"mt-6",children:r.jsx(se,{variant:"outline",onClick:()=>e("/"),children:"Go to Dashboard"})})]})}let gc=null;async function j1(){return gs()?null:(gc??(gc=bp()),await gc,gs()?null:ph("/login"))}const sh=mh([{path:"/login",element:r.jsx(Cb,{})},{path:"/",element:r.jsx(bb,{}),loader:j1,handle:{breadcrumb:()=>null},children:[{index:!0,element:r.jsx(Ab,{}),handle:{breadcrumb:()=>"Dashboard"}},{path:"orders",handle:tj,children:[{index:!0,element:r.jsx(ej,{})},{path:":orderNumber",element:r.jsx(tN,{}),handle:nN}]},{path:"products",handle:mN,children:[{index:!0,element:r.jsx(hN,{})},{path:"new",element:r.jsx(mc,{}),handle:jN},{path:":slug",element:r.jsx(mc,{}),handle:wN}]},{path:"inventory",element:r.jsx(IN,{}),handle:ON},{path:"customers",handle:UN,children:[{index:!0,element:r.jsx($N,{})},{path:":id",element:r.jsx(qN,{}),handle:HN}]},{path:"activity",element:r.jsx(d1,{}),handle:u1},{path:"inbox",element:r.jsx(y1,{}),handle:b1},{path:"settings",element:r.jsx(t1,{}),handle:n1},{path:"*",element:r.jsx(w1,{})}]}],{basename:"/admin"});xp(()=>{xs.clear(),sh.navigate("/login")});const ah=document.getElementById("root");if(!ah)throw new Error("Root element not found");bh.createRoot(ah).render(r.jsx(l.StrictMode,{children:r.jsx(Wh,{client:xs,children:r.jsx(xh,{router:sh})})}));