2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
|
|
import{r as a,j as s,P as S,i as y,p as Sn,z as we,e as xe,ay as Dn,az as Ce,aA as _e,g as In,aB as Nn,aC as Pn,at as X,aD as Tn,H as F,d as w,aE as An,aF as jn,aG as On,aH as kn,aI as Ln,aJ as Fn,aK as Gn,aL as Kn,aM as $n,aN as Re,c as Un,as as Me}from"./index-oAPVDf-r.js";import{c as ye,I as Bn,R as zn}from"./index-DGH-oZ97.js";import{C as Vn}from"./chevron-right-B9rMgght.js";import{C as Yn}from"./check-CG8zylH4.js";import{C as Wn}from"./circle-030W8joh.js";var Xn="Separator",he="horizontal",Hn=["horizontal","vertical"],Ee=a.forwardRef((e,t)=>{const{decorative:n,orientation:o=he,...r}=e,c=qn(o)?o:he,l=n?{role:"none"}:{"aria-orientation":c==="vertical"?c:void 0,role:"separator"};return s.jsx(S.div,{"data-orientation":c,...l,...r,ref:t})});Ee.displayName=Xn;function qn(e){return Hn.includes(e)}var be=Ee;const Jn=a.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...o},r)=>s.jsx(be,{ref:r,decorative:n,orientation:t,className:y("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));Jn.displayName=be.displayName;function Ro(){const{user:e}=Sn(),[t,n]=a.useState(null),[o,r]=a.useState([]),[c,u]=a.useState(!0),[l,m]=a.useState(null);return a.useEffect(()=>{if(!e){u(!1);return}async function v(){u(!0),m(null);try{const{data:d,error:i}=await we.from("wallets").select("*").eq("user_id",e.id).maybeSingle();if(i)throw i;if(!d){n(null),r([]),u(!1);return}n(d);const{data:p,error:M}=await we.from("transactions").select("*").eq("wallet_id",d.id).order("created_at",{ascending:!1});if(M)throw M;r(p||[])}catch(d){m(d instanceof Error?d.message:"Kunde inte hämta wallet-data")}finally{u(!1)}}v()},[e]),{wallet:t,transactions:o,isLoading:c,error:l}}const Zn=.15,Qn=1,yo=100;function Eo(e){return Math.floor(e*Qn*(1-Zn)*100)/100}function bo(e){return`${e.toLocaleString("sv-SE")} kr`}function So(e){return e.toLocaleString("sv-SE",{minimumFractionDigits:2,maximumFractionDigits:2})+" kr"}function Do(e){return e!=null&&e.toLowerCase().includes("utbetalning")||e!=null&&e.toLowerCase().includes("payout")?"cash":e!=null&&e.toLowerCase().includes("kupong")||e!=null&&e.toLowerCase().includes("voucher")?"voucher":"credits"}var te=["Enter"," "],et=["ArrowDown","PageUp","Home"],Se=["ArrowUp","PageDown","End"],nt=[...et,...Se],tt={ltr:[...te,"ArrowRight"],rtl:[...te,"ArrowLeft"]},ot={ltr:["ArrowLeft"],rtl:["ArrowRight"]},G="Menu",[k,rt,at]=Dn(G),[D,De]=xe(G,[at,Ce,ye]),H=Ce(),Ie=ye(),[st,I]=D(G),[ct,K]=D(G),Ne=e=>{const{__scopeMenu:t,open:n=!1,children:o,dir:r,onOpenChange:c,modal:u=!0}=e,l=H(t),[m,v]=a.useState(null),d=a.useRef(!1),i=_e(c),p=In(r);return a.useEffect(()=>{const M=()=>{d.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},h=()=>d.current=!1;return document.addEventListener("keydown",M,{capture:!0}),()=>{document.removeEventListener("keydown",M,{capture:!0}),document.removeEventListener("pointerdown",h,{capture:!0}),document.removeEventListener("pointermove",h,{capture:!0})}},[]),s.jsx(Nn,{...l,children:s.jsx(st,{scope:t,open:n,onOpenChange:i,content:m,onContentChange:v,children:s.jsx(ct,{scope:t,onClose:a.useCallback(()=>i(!1),[i]),isUsingKeyboardRef:d,dir:p,modal:u,children:o})})})};Ne.displayName=G;var it="MenuAnchor",oe=a.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,r=H(n);return s.jsx(Pn,{...r,...o,ref:t})});oe.displayName=it;var re="MenuPortal",[ut,Pe]=D(re,{forceMount:void 0}),Te=e=>{const{__scopeMenu:t,forceMount:n,children:o,container:r}=e,c=I(re,t);return s.jsx(ut,{scope:t,forceMount:n,children:s.jsx(X,{present:n||c.open,children:s.jsx(Tn,{asChild:!0,container:r,children:o})})})};Te.displayName=re;var C="MenuContent",[dt,ae]=D(C),Ae=a.forwardRef((e,t)=>{const n=Pe(C,e.__scopeMenu),{forceMount:o=n.forceMount,...r}=e,c=I(C,e.__scopeMenu),u=K(C,e.__scopeMenu);return s.jsx(k.Provider,{scope:e.__scopeMenu,children:s.jsx(X,{present:o||c.open,children:s.jsx(k.Slot,{scope:e.__scopeMenu,children:u.modal?s.jsx(lt,{...r,ref:t}):s.jsx(ft,{...r,ref:t})})})})}),lt=a.forwardRef((e,t)=>{const n=I(C,e.__scopeMen
|