48ea61cdcc
- Product documentation in docs/products/ - Updated MEMORY.md with product info - quiXzoom Auth Core as AAMOS Identity product
55 lines
78 KiB
JavaScript
55 lines
78 KiB
JavaScript
import{x as H,o as de,r as v,a9 as Ie,w as M,ao as X,j as e,y as I,z as P,v as L,ap as ue,aq as me,ar as fe,as as ge,a as he,M as mt,G as ft,L as gt,p as De,c as Xt,P as ze,at as Qt,d as Yt,au as Wt,O as Zt,av as en,g as tn,aw as nn,q as ht,I as pt,ax as z,C as rn,A as sn,a2 as an,b as Ne,B as ve,ay as on}from"./index-CZD3_4lD.js";import{S as q,D as ln,a as cn,b as dn,c as Ze,u as un,f as J,d as ke,e as mn,M as ne,g as et,P as tt,h as fn}from"./dropdown-menu-CFWQzY9-.js";import{B as Q}from"./badge-D3Mn__J4.js";import{d as gn,T as nt}from"./differenceInDays-BjWVl97D.js";import{G as xt}from"./gift-C8Ri1JSk.js";import{C as hn}from"./circle-check-60AjePHB.js";import{C as ae}from"./clock-CHYQgZWG.js";import{S as rt,F as pn,C as xn,H as yn}from"./star-DINAYY6y.js";import{Q as bn}from"./qr-code-J7tfaoiH.js";import{f as T,s as Y,e as yt,d as bt}from"./sv-KqUX0hpM.js";import{A as wt}from"./index-DXB3_sFe.js";import{C as wn}from"./check-CCL32zXH.js";import{H as jt}from"./heart-Bn8C2h_q.js";import{L as jn}from"./leaf-BV-5O-4e.js";import{G as Nn}from"./graduation-cap-TNnu1wlO.js";import{C as Pe}from"./chevron-down-DA--jGG2.js";import{E as vn}from"./external-link-DZgJPdR9.js";import{S as kn}from"./scroll-area-DdYSSeiY.js";import{I as Cn}from"./info-DLVcQf5T.js";import{F as st}from"./file-text-I90VDyBK.js";import{D as Sn}from"./download-JAaLZNwh.js";import{S as En}from"./send-DWELcW4W.js";import{C as An}from"./calendar-3jVgdv6R.js";import{B as Mn}from"./building-2-BpMHggJ8.js";import{T as Tn}from"./trending-up-CVyK6WFK.js";import{C as _n}from"./circle-alert-DFiBooaQ.js";import"./index-C6sfL5Wv.js";import"./chevron-right-Dvw0FPw3.js";import"./circle-CNf9xg3I.js";/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const at=H("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Bn=H("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const In=H("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Dn=H("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Pn=H("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const ot=H("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Nt=H("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Rn=H("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
|
||
* @license lucide-react v0.462.0 - ISC
|
||
*
|
||
* This source code is licensed under the ISC license.
|
||
* See the LICENSE file in the root directory of this source tree.
|
||
*/const Ln=H("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]),Ce="https://api.quixzoom.com/api/qz",it=.15;function Fn(){const{user:t}=de(),[n,a]=v.useState([]),[r,o]=v.useState([]),[s,i]=v.useState(!0);return v.useEffect(()=>{if(!t){i(!1);return}async function u(){i(!0);const x=Ie.getToken();if(!x){i(!1);return}try{const h=await fetch(`${Ce}/payouts/history`,{headers:{Authorization:`Bearer ${x}`}});if(h.ok){const b=await h.json();a(Array.isArray(b.payouts)?b.payouts:[])}}catch(h){console.error("[usePayouts] fetchPayouts error:",h)}i(!1)}async function p(){try{const x=await fetch(`${Ce}/payouts/currencies`);if(x.ok){const h=await x.json();o(Array.isArray(h.currencies)?h.currencies:[])}}catch(x){console.error("[usePayouts] fetchCurrencies error:",x)}}u(),p()},[t]),{payouts:n,isLoading:s,calculatePayout:u=>{const p=Math.round(u*it),x=u-p;return{taxAmount:p,netAmount:x}},requestPayout:async(u,p="SEK")=>{var h;if(!t)return M.error("Du måste vara inloggad"),!1;const x=Ie.getToken();if(!x)return M.error("Ingen giltig session — logga in igen"),!1;if(u<100)return M.error("Minsta utbetalning är 100 credits"),!1;try{const b=await fetch(`${Ce}/payouts/request`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({amount_credits:u,currency:p})}),w=await b.json();if(!b.ok)return b.status===400&&((h=w.error)!=null&&h.includes("Stripe Connect"))?(M.error("Utbetalningar kräver ett verifierat konto",{description:"Slutför onboarding via Inställningar → Utbetalningar för att aktivera Stripe Connect.",duration:6e3}),!1):(M.error(w.error||"Kunde inte skapa utbetalningsförfrågan"),!1);const g={id:w.payout_id||`tmp-${Date.now()}`,amount:u*100,tax_amount:(w.fee_credits||0)*100,net_amount:(w.net_credits||0)*100,status:w.status||"pending",reference:void 0,processed_at:null,created_at:new Date().toISOString()};a(d=>[g,...d]);const y=w.mode==="mock"?" (sandbox-läge)":"";return M.success(`Utbetalning initierad${y}`,{description:`${w.net_credits||0} credits → ${w.amount||""} ${w.currency||p} skickas till ditt konto.`}),!0}catch(b){return console.error("[usePayouts] requestPayout error:",b),M.error("Nätverksfel — försök igen"),!1}},TAX_RATE:it,currencies:r}}var ee={},Hn=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},vt={},D={};let Ke;const Un=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];D.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17};D.getSymbolTotalCodewords=function(n){return Un[n]};D.getBCHDigit=function(t){let n=0;for(;t!==0;)n++,t>>>=1;return n};D.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');Ke=n};D.isKanjiModeEnabled=function(){return typeof Ke<"u"};D.toSJIS=function(n){return Ke(n)};var pe={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+a)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,o){if(t.isValid(r))return r;try{return n(r)}catch{return o}}})(pe);function kt(){this.buffer=[],this.length=0}kt.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let a=0;a<n;a++)this.putBit((t>>>n-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}};var $n=kt;function te(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}te.prototype.set=function(t,n,a,r){const o=t*this.size+n;this.data[o]=a,r&&(this.reservedBit[o]=!0)};te.prototype.get=function(t,n){return this.data[t*this.size+n]};te.prototype.xor=function(t,n,a){this.data[t*this.size+n]^=a};te.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]};var zn=te,Ct={};(function(t){const n=D.getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,s=n(r),i=s===145?26:Math.ceil((s-13)/(2*o-2))*2,l=[s-7];for(let c=1;c<o-1;c++)l[c]=l[c-1]-i;return l.push(6),l.reverse()},t.getPositions=function(r){const o=[],s=t.getRowColCoords(r),i=s.length;for(let l=0;l<i;l++)for(let c=0;c<i;c++)l===0&&c===0||l===0&&c===i-1||l===i-1&&c===0||o.push([s[l],s[c]]);return o}})(Ct);var St={};const Kn=D.getSymbolSize,lt=7;St.getPositions=function(n){const a=Kn(n);return[[0,0],[a-lt,0],[0,a-lt]]};var Et={};(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const s=o.size;let i=0,l=0,c=0,f=null,u=null;for(let p=0;p<s;p++){l=c=0,f=u=null;for(let x=0;x<s;x++){let h=o.get(p,x);h===f?l++:(l>=5&&(i+=n.N1+(l-5)),f=h,l=1),h=o.get(x,p),h===u?c++:(c>=5&&(i+=n.N1+(c-5)),u=h,c=1)}l>=5&&(i+=n.N1+(l-5)),c>=5&&(i+=n.N1+(c-5))}return i},t.getPenaltyN2=function(o){const s=o.size;let i=0;for(let l=0;l<s-1;l++)for(let c=0;c<s-1;c++){const f=o.get(l,c)+o.get(l,c+1)+o.get(l+1,c)+o.get(l+1,c+1);(f===4||f===0)&&i++}return i*n.N2},t.getPenaltyN3=function(o){const s=o.size;let i=0,l=0,c=0;for(let f=0;f<s;f++){l=c=0;for(let u=0;u<s;u++)l=l<<1&2047|o.get(f,u),u>=10&&(l===1488||l===93)&&i++,c=c<<1&2047|o.get(u,f),u>=10&&(c===1488||c===93)&&i++}return i*n.N3},t.getPenaltyN4=function(o){let s=0;const i=o.data.length;for(let c=0;c<i;c++)s+=o.data[c];return Math.abs(Math.ceil(s*100/i/5)-10)*n.N4};function a(r,o,s){switch(r){case t.Patterns.PATTERN000:return(o+s)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return s%3===0;case t.Patterns.PATTERN011:return(o+s)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(s/3))%2===0;case t.Patterns.PATTERN101:return o*s%2+o*s%3===0;case t.Patterns.PATTERN110:return(o*s%2+o*s%3)%2===0;case t.Patterns.PATTERN111:return(o*s%3+(o+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(o,s){const i=s.size;for(let l=0;l<i;l++)for(let c=0;c<i;c++)s.isReserved(c,l)||s.xor(c,l,a(o,c,l))},t.getBestMask=function(o,s){const i=Object.keys(t.Patterns).length;let l=0,c=1/0;for(let f=0;f<i;f++){s(f),t.applyMask(f,o);const u=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(f,o),u<c&&(c=u,l=f)}return l}})(Et);var xe={};const U=pe,re=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],se=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];xe.getBlocksCount=function(n,a){switch(a){case U.L:return re[(n-1)*4+0];case U.M:return re[(n-1)*4+1];case U.Q:return re[(n-1)*4+2];case U.H:return re[(n-1)*4+3];default:return}};xe.getTotalCodewordsCount=function(n,a){switch(a){case U.L:return se[(n-1)*4+0];case U.M:return se[(n-1)*4+1];case U.Q:return se[(n-1)*4+2];case U.H:return se[(n-1)*4+3];default:return}};var At={},ye={};const W=new Uint8Array(512),le=new Uint8Array(256);(function(){let n=1;for(let a=0;a<255;a++)W[a]=n,le[n]=a,n<<=1,n&256&&(n^=285);for(let a=255;a<512;a++)W[a]=W[a-255]})();ye.log=function(n){if(n<1)throw new Error("log("+n+")");return le[n]};ye.exp=function(n){return W[n]};ye.mul=function(n,a){return n===0||a===0?0:W[le[n]+le[a]]};(function(t){const n=ye;t.mul=function(r,o){const s=new Uint8Array(r.length+o.length-1);for(let i=0;i<r.length;i++)for(let l=0;l<o.length;l++)s[i+l]^=n.mul(r[i],o[l]);return s},t.mod=function(r,o){let s=new Uint8Array(r);for(;s.length-o.length>=0;){const i=s[0];for(let c=0;c<o.length;c++)s[c]^=n.mul(o[c],i);let l=0;for(;l<s.length&&s[l]===0;)l++;s=s.slice(l)}return s},t.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let s=0;s<r;s++)o=t.mul(o,new Uint8Array([1,n.exp(s)]));return o}})(At);const Mt=At;function Ve(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}Ve.prototype.initialize=function(n){this.degree=n,this.genPoly=Mt.generateECPolynomial(this.degree)};Ve.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(n.length+this.degree);a.set(n);const r=Mt.mod(a,this.genPoly),o=this.degree-r.length;if(o>0){const s=new Uint8Array(this.degree);return s.set(r,o),s}return r};var Vn=Ve,Tt={},$={},Oe={};Oe.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40};var F={};const _t="[0-9]+",On="[A-Z $%*+\\-./:]+";let Z="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Z=Z.replace(/u/g,"\\u");const Gn="(?:(?![A-Z0-9 $%*+\\-./:]|"+Z+`)(?:.|[\r
|
||
]))+`;F.KANJI=new RegExp(Z,"g");F.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");F.BYTE=new RegExp(Gn,"g");F.NUMERIC=new RegExp(_t,"g");F.ALPHANUMERIC=new RegExp(On,"g");const qn=new RegExp("^"+Z+"$"),Jn=new RegExp("^"+_t+"$"),Xn=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");F.testKanji=function(n){return qn.test(n)};F.testNumeric=function(n){return Jn.test(n)};F.testAlphanumeric=function(n){return Xn.test(n)};(function(t){const n=Oe,a=F;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(s,i){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!n.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?s.ccBits[0]:i<27?s.ccBits[1]:s.ccBits[2]},t.getBestModeForData=function(s){return a.testNumeric(s)?t.NUMERIC:a.testAlphanumeric(s)?t.ALPHANUMERIC:a.testKanji(s)?t.KANJI:t.BYTE},t.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},t.isValid=function(s){return s&&s.bit&&s.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+o)}}t.from=function(s,i){if(t.isValid(s))return s;try{return r(s)}catch{return i}}})($);(function(t){const n=D,a=xe,r=pe,o=$,s=Oe,i=7973,l=n.getBCHDigit(i);function c(x,h,b){for(let w=1;w<=40;w++)if(h<=t.getCapacity(w,b,x))return w}function f(x,h){return o.getCharCountIndicator(x,h)+4}function u(x,h){let b=0;return x.forEach(function(w){const g=f(w.mode,h);b+=g+w.getBitsLength()}),b}function p(x,h){for(let b=1;b<=40;b++)if(u(x,b)<=t.getCapacity(b,h,o.MIXED))return b}t.from=function(h,b){return s.isValid(h)?parseInt(h,10):b},t.getCapacity=function(h,b,w){if(!s.isValid(h))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=o.BYTE);const g=n.getSymbolTotalCodewords(h),y=a.getTotalCodewordsCount(h,b),d=(g-y)*8;if(w===o.MIXED)return d;const m=d-f(w,h);switch(w){case o.NUMERIC:return Math.floor(m/10*3);case o.ALPHANUMERIC:return Math.floor(m/11*2);case o.KANJI:return Math.floor(m/13);case o.BYTE:default:return Math.floor(m/8)}},t.getBestVersionForData=function(h,b){let w;const g=r.from(b,r.M);if(Array.isArray(h)){if(h.length>1)return p(h,g);if(h.length===0)return 1;w=h[0]}else w=h;return c(w.mode,w.getLength(),g)},t.getEncodedBits=function(h){if(!s.isValid(h)||h<7)throw new Error("Invalid QR Code version");let b=h<<12;for(;n.getBCHDigit(b)-l>=0;)b^=i<<n.getBCHDigit(b)-l;return h<<12|b}})(Tt);var Bt={};const Re=D,It=1335,Qn=21522,ct=Re.getBCHDigit(It);Bt.getEncodedBits=function(n,a){const r=n.bit<<3|a;let o=r<<10;for(;Re.getBCHDigit(o)-ct>=0;)o^=It<<Re.getBCHDigit(o)-ct;return(r<<10|o)^Qn};var Dt={};const Yn=$;function K(t){this.mode=Yn.NUMERIC,this.data=t.toString()}K.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)};K.prototype.getLength=function(){return this.data.length};K.prototype.getBitsLength=function(){return K.getBitsLength(this.data.length)};K.prototype.write=function(n){let a,r,o;for(a=0;a+3<=this.data.length;a+=3)r=this.data.substr(a,3),o=parseInt(r,10),n.put(o,10);const s=this.data.length-a;s>0&&(r=this.data.substr(a),o=parseInt(r,10),n.put(o,s*3+1))};var Wn=K;const Zn=$,Se=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function V(t){this.mode=Zn.ALPHANUMERIC,this.data=t}V.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)};V.prototype.getLength=function(){return this.data.length};V.prototype.getBitsLength=function(){return V.getBitsLength(this.data.length)};V.prototype.write=function(n){let a;for(a=0;a+2<=this.data.length;a+=2){let r=Se.indexOf(this.data[a])*45;r+=Se.indexOf(this.data[a+1]),n.put(r,11)}this.data.length%2&&n.put(Se.indexOf(this.data[a]),6)};var er=V;const tr=$;function O(t){this.mode=tr.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}O.getBitsLength=function(n){return n*8};O.prototype.getLength=function(){return this.data.length};O.prototype.getBitsLength=function(){return O.getBitsLength(this.data.length)};O.prototype.write=function(t){for(let n=0,a=this.data.length;n<a;n++)t.put(this.data[n],8)};var nr=O;const rr=$,sr=D;function G(t){this.mode=rr.KANJI,this.data=t}G.getBitsLength=function(n){return n*13};G.prototype.getLength=function(){return this.data.length};G.prototype.getBitsLength=function(){return G.getBitsLength(this.data.length)};G.prototype.write=function(t){let n;for(n=0;n<this.data.length;n++){let a=sr.toSJIS(this.data[n]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
||
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),t.put(a,13)}};var ar=G,Pt={exports:{}};(function(t){var n={single_source_shortest_paths:function(a,r,o){var s={},i={};i[r]=0;var l=n.PriorityQueue.make();l.push(r,0);for(var c,f,u,p,x,h,b,w,g;!l.empty();){c=l.pop(),f=c.value,p=c.cost,x=a[f]||{};for(u in x)x.hasOwnProperty(u)&&(h=x[u],b=p+h,w=i[u],g=typeof i[u]>"u",(g||w>b)&&(i[u]=b,l.push(u,b),s[u]=f))}if(typeof o<"u"&&typeof i[o]>"u"){var y=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(y)}return s},extract_shortest_path_from_predecessor_list:function(a,r){for(var o=[],s=r;s;)o.push(s),a[s],s=a[s];return o.reverse(),o},find_path:function(a,r,o){var s=n.single_source_shortest_paths(a,r,o);return n.extract_shortest_path_from_predecessor_list(s,o)},PriorityQueue:{make:function(a){var r=n.PriorityQueue,o={},s;a=a||{};for(s in r)r.hasOwnProperty(s)&&(o[s]=r[s]);return o.queue=[],o.sorter=a.sorter||r.default_sorter,o},default_sorter:function(a,r){return a.cost-r.cost},push:function(a,r){var o={value:a,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=n})(Pt);var or=Pt.exports;(function(t){const n=$,a=Wn,r=er,o=nr,s=ar,i=F,l=D,c=or;function f(y){return unescape(encodeURIComponent(y)).length}function u(y,d,m){const j=[];let C;for(;(C=y.exec(m))!==null;)j.push({data:C[0],index:C.index,mode:d,length:C[0].length});return j}function p(y){const d=u(i.NUMERIC,n.NUMERIC,y),m=u(i.ALPHANUMERIC,n.ALPHANUMERIC,y);let j,C;return l.isKanjiModeEnabled()?(j=u(i.BYTE,n.BYTE,y),C=u(i.KANJI,n.KANJI,y)):(j=u(i.BYTE_KANJI,n.BYTE,y),C=[]),d.concat(m,j,C).sort(function(E,_){return E.index-_.index}).map(function(E){return{data:E.data,mode:E.mode,length:E.length}})}function x(y,d){switch(d){case n.NUMERIC:return a.getBitsLength(y);case n.ALPHANUMERIC:return r.getBitsLength(y);case n.KANJI:return s.getBitsLength(y);case n.BYTE:return o.getBitsLength(y)}}function h(y){return y.reduce(function(d,m){const j=d.length-1>=0?d[d.length-1]:null;return j&&j.mode===m.mode?(d[d.length-1].data+=m.data,d):(d.push(m),d)},[])}function b(y){const d=[];for(let m=0;m<y.length;m++){const j=y[m];switch(j.mode){case n.NUMERIC:d.push([j,{data:j.data,mode:n.ALPHANUMERIC,length:j.length},{data:j.data,mode:n.BYTE,length:j.length}]);break;case n.ALPHANUMERIC:d.push([j,{data:j.data,mode:n.BYTE,length:j.length}]);break;case n.KANJI:d.push([j,{data:j.data,mode:n.BYTE,length:f(j.data)}]);break;case n.BYTE:d.push([{data:j.data,mode:n.BYTE,length:f(j.data)}])}}return d}function w(y,d){const m={},j={start:{}};let C=["start"];for(let N=0;N<y.length;N++){const E=y[N],_=[];for(let k=0;k<E.length;k++){const A=E[k],S=""+N+k;_.push(S),m[S]={node:A,lastCount:0},j[S]={};for(let R=0;R<C.length;R++){const B=C[R];m[B]&&m[B].node.mode===A.mode?(j[B][S]=x(m[B].lastCount+A.length,A.mode)-x(m[B].lastCount,A.mode),m[B].lastCount+=A.length):(m[B]&&(m[B].lastCount=A.length),j[B][S]=x(A.length,A.mode)+4+n.getCharCountIndicator(A.mode,d))}}C=_}for(let N=0;N<C.length;N++)j[C[N]].end=0;return{map:j,table:m}}function g(y,d){let m;const j=n.getBestModeForData(y);if(m=n.from(d,j),m!==n.BYTE&&m.bit<j.bit)throw new Error('"'+y+'" cannot be encoded with mode '+n.toString(m)+`.
|
||
Suggested mode is: `+n.toString(j));switch(m===n.KANJI&&!l.isKanjiModeEnabled()&&(m=n.BYTE),m){case n.NUMERIC:return new a(y);case n.ALPHANUMERIC:return new r(y);case n.KANJI:return new s(y);case n.BYTE:return new o(y)}}t.fromArray=function(d){return d.reduce(function(m,j){return typeof j=="string"?m.push(g(j,null)):j.data&&m.push(g(j.data,j.mode)),m},[])},t.fromString=function(d,m){const j=p(d,l.isKanjiModeEnabled()),C=b(j),N=w(C,m),E=c.find_path(N.map,"start","end"),_=[];for(let k=1;k<E.length-1;k++)_.push(N.table[E[k]].node);return t.fromArray(h(_))},t.rawSplit=function(d){return t.fromArray(p(d,l.isKanjiModeEnabled()))}})(Dt);const be=D,Ee=pe,ir=$n,lr=zn,cr=Ct,dr=St,Le=Et,Fe=xe,ur=Vn,ce=Tt,mr=Bt,fr=$,Ae=Dt;function gr(t,n){const a=t.size,r=dr.getPositions(n);for(let o=0;o<r.length;o++){const s=r[o][0],i=r[o][1];for(let l=-1;l<=7;l++)if(!(s+l<=-1||a<=s+l))for(let c=-1;c<=7;c++)i+c<=-1||a<=i+c||(l>=0&&l<=6&&(c===0||c===6)||c>=0&&c<=6&&(l===0||l===6)||l>=2&&l<=4&&c>=2&&c<=4?t.set(s+l,i+c,!0,!0):t.set(s+l,i+c,!1,!0))}}function hr(t){const n=t.size;for(let a=8;a<n-8;a++){const r=a%2===0;t.set(a,6,r,!0),t.set(6,a,r,!0)}}function pr(t,n){const a=cr.getPositions(n);for(let r=0;r<a.length;r++){const o=a[r][0],s=a[r][1];for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)i===-2||i===2||l===-2||l===2||i===0&&l===0?t.set(o+i,s+l,!0,!0):t.set(o+i,s+l,!1,!0)}}function xr(t,n){const a=t.size,r=ce.getEncodedBits(n);let o,s,i;for(let l=0;l<18;l++)o=Math.floor(l/3),s=l%3+a-8-3,i=(r>>l&1)===1,t.set(o,s,i,!0),t.set(s,o,i,!0)}function Me(t,n,a){const r=t.size,o=mr.getEncodedBits(n,a);let s,i;for(s=0;s<15;s++)i=(o>>s&1)===1,s<6?t.set(s,8,i,!0):s<8?t.set(s+1,8,i,!0):t.set(r-15+s,8,i,!0),s<8?t.set(8,r-s-1,i,!0):s<9?t.set(8,15-s-1+1,i,!0):t.set(8,15-s-1,i,!0);t.set(r-8,8,1,!0)}function yr(t,n){const a=t.size;let r=-1,o=a-1,s=7,i=0;for(let l=a-1;l>0;l-=2)for(l===6&&l--;;){for(let c=0;c<2;c++)if(!t.isReserved(o,l-c)){let f=!1;i<n.length&&(f=(n[i]>>>s&1)===1),t.set(o,l-c,f),s--,s===-1&&(i++,s=7)}if(o+=r,o<0||a<=o){o-=r,r=-r;break}}}function br(t,n,a){const r=new ir;a.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),fr.getCharCountIndicator(c.mode,t)),c.write(r)});const o=be.getSymbolTotalCodewords(t),s=Fe.getTotalCodewordsCount(t,n),i=(o-s)*8;for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const l=(i-r.getLengthInBits())/8;for(let c=0;c<l;c++)r.put(c%2?17:236,8);return wr(r,t,n)}function wr(t,n,a){const r=be.getSymbolTotalCodewords(n),o=Fe.getTotalCodewordsCount(n,a),s=r-o,i=Fe.getBlocksCount(n,a),l=r%i,c=i-l,f=Math.floor(r/i),u=Math.floor(s/i),p=u+1,x=f-u,h=new ur(x);let b=0;const w=new Array(i),g=new Array(i);let y=0;const d=new Uint8Array(t.buffer);for(let E=0;E<i;E++){const _=E<c?u:p;w[E]=d.slice(b,b+_),g[E]=h.encode(w[E]),b+=_,y=Math.max(y,_)}const m=new Uint8Array(r);let j=0,C,N;for(C=0;C<y;C++)for(N=0;N<i;N++)C<w[N].length&&(m[j++]=w[N][C]);for(C=0;C<x;C++)for(N=0;N<i;N++)m[j++]=g[N][C];return m}function jr(t,n,a,r){let o;if(Array.isArray(t))o=Ae.fromArray(t);else if(typeof t=="string"){let f=n;if(!f){const u=Ae.rawSplit(t);f=ce.getBestVersionForData(u,a)}o=Ae.fromString(t,f||40)}else throw new Error("Invalid data");const s=ce.getBestVersionForData(o,a);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!n)n=s;else if(n<s)throw new Error(`
|
||
The chosen QR Code version cannot contain this amount of data.
|
||
Minimum version required to store current data is: `+s+`.
|
||
`);const i=br(n,a,o),l=be.getSymbolSize(n),c=new lr(l);return gr(c,n),hr(c),pr(c,n),Me(c,a,0),n>=7&&xr(c,n),yr(c,i),isNaN(r)&&(r=Le.getBestMask(c,Me.bind(null,c,a))),Le.applyMask(r,c),Me(c,a,r),{modules:c,version:n,errorCorrectionLevel:a,maskPattern:r,segments:o}}vt.create=function(n,a){if(typeof n>"u"||n==="")throw new Error("No input text");let r=Ee.M,o,s;return typeof a<"u"&&(r=Ee.from(a.errorCorrectionLevel,Ee.M),o=ce.from(a.version),s=Le.from(a.maskPattern),a.toSJISFunc&&be.setToSJISFunction(a.toSJISFunc)),jr(n,o,r,s)};var Rt={},Ge={};(function(t){function n(a){if(typeof a=="number"&&(a=a.toString()),typeof a!="string")throw new Error("Color should be defined as hex string");let r=a.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+a);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,i=r.scale||4;return{width:s,scale:s?4:i,margin:o,color:{dark:n(r.color.dark||"#000000ff"),light:n(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const s=t.getScale(r,o);return Math.floor((r+o.margin*2)*s)},t.qrToImageData=function(r,o,s){const i=o.modules.size,l=o.modules.data,c=t.getScale(i,s),f=Math.floor((i+s.margin*2)*c),u=s.margin*c,p=[s.color.light,s.color.dark];for(let x=0;x<f;x++)for(let h=0;h<f;h++){let b=(x*f+h)*4,w=s.color.light;if(x>=u&&h>=u&&x<f-u&&h<f-u){const g=Math.floor((x-u)/c),y=Math.floor((h-u)/c);w=p[l[g*i+y]?1:0]}r[b++]=w.r,r[b++]=w.g,r[b++]=w.b,r[b]=w.a}}})(Ge);(function(t){const n=Ge;function a(o,s,i){o.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=i,s.width=i,s.style.height=i+"px",s.style.width=i+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(s,i,l){let c=l,f=i;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),i||(f=r()),c=n.getOptions(c);const u=n.getImageWidth(s.modules.size,c),p=f.getContext("2d"),x=p.createImageData(u,u);return n.qrToImageData(x.data,s,c),a(p,f,u),p.putImageData(x,0,0),f},t.renderToDataURL=function(s,i,l){let c=l;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),c||(c={});const f=t.render(s,i,c),u=c.type||"image/png",p=c.rendererOpts||{};return f.toDataURL(u,p.quality)}})(Rt);var Lt={};const Nr=Ge;function dt(t,n){const a=t.a/255,r=n+'="'+t.hex+'"';return a<1?r+" "+n+'-opacity="'+a.toFixed(2).slice(1)+'"':r}function Te(t,n,a){let r=t+n;return typeof a<"u"&&(r+=" "+a),r}function vr(t,n,a){let r="",o=0,s=!1,i=0;for(let l=0;l<t.length;l++){const c=Math.floor(l%n),f=Math.floor(l/n);!c&&!s&&(s=!0),t[l]?(i++,l>0&&c>0&&t[l-1]||(r+=s?Te("M",c+a,.5+f+a):Te("m",o,0),o=0,s=!1),c+1<n&&t[l+1]||(r+=Te("h",i),i=0)):o++}return r}Lt.render=function(n,a,r){const o=Nr.getOptions(a),s=n.modules.size,i=n.modules.data,l=s+o.margin*2,c=o.color.light.a?"<path "+dt(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",f="<path "+dt(o.color.dark,"stroke")+' d="'+vr(i,s,o.margin)+'"/>',u='viewBox="0 0 '+l+" "+l+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+u+' shape-rendering="crispEdges">'+c+f+`</svg>
|
||
`;return typeof r=="function"&&r(null,x),x};const kr=Hn,He=vt,Ft=Rt,Cr=Lt;function qe(t,n,a,r,o){const s=[].slice.call(arguments,1),i=s.length,l=typeof s[i-1]=="function";if(!l&&!kr())throw new Error("Callback required as last argument");if(l){if(i<2)throw new Error("Too few arguments provided");i===2?(o=a,a=n,n=r=void 0):i===3&&(n.getContext&&typeof o>"u"?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(a=n,n=r=void 0):i===2&&!n.getContext&&(r=a,a=n,n=void 0),new Promise(function(c,f){try{const u=He.create(a,r);c(t(u,n,r))}catch(u){f(u)}})}try{const c=He.create(a,r);o(null,t(c,n,r))}catch(c){o(c)}}ee.create=He.create;ee.toCanvas=qe.bind(null,Ft.render);ee.toDataURL=qe.bind(null,Ft.renderToDataURL);ee.toString=qe.bind(null,function(t,n,a){return Cr.render(t,a)});function Ht(){const{user:t}=de(),[n,a]=v.useState([]),[r,o]=v.useState(!0),s=v.useCallback(async()=>{if(!t){o(!1);return}o(!0);try{const u=await X(`/vouchers?user_id=${t.id}&order=issued_at.desc`);a(Array.isArray(u)?u:[])}catch(u){console.error("[useVouchers]",u)}finally{o(!1)}},[t]);v.useEffect(()=>{s()},[s]);const i=v.useCallback(async u=>{const p=JSON.stringify({id:u.id,code:u.code,title:u.title,brand:u.orderer_brand,expires:u.expires_at});return ee.toDataURL(p,{width:256,margin:2})},[]),l=n.filter(u=>u.status==="active"&&new Date(u.expires_at)>new Date),c=n.filter(u=>u.status==="redeemed"||u.status==="expired"),f=l.filter(u=>(new Date(u.expires_at).getTime()-Date.now())/864e5<=7);return{vouchers:n,activeVouchers:l,usedVouchers:c,expiresWithin7Days:f,isLoading:r,fetchVouchers:s,getQRDataUrl:i}}function ut({voucher:t}){const[n,a]=v.useState(!1),[r,o]=v.useState(null),[s,i]=v.useState(!1),{getQRDataUrl:l}=Ht(),c=gn(new Date(t.expires_at),new Date),f=c<=7&&t.status==="active",u=t.status==="expired"||new Date(t.expires_at)<new Date,p=t.status==="redeemed",x=async()=>{i(!0);const b=await l(t);o(b),i(!1),a(!0)},h=p||u?"bg-muted":f?"border-amber-500/50 bg-amber-500/5":"border-primary/30 bg-primary/5";return e.jsxs(e.Fragment,{children:[e.jsx(I,{className:`overflow-hidden ${h}`,children:e.jsxs(P,{className:"p-0",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.orderer_logo_url?e.jsx("img",{src:t.orderer_logo_url,alt:t.orderer_brand||"",className:"w-10 h-10 rounded-lg object-contain bg-white p-1"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(xt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:t.orderer_brand||"QuiXzoom Reward"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.reward_type==="points"?"Poäng":"Värdekupong"})]})]}),p&&e.jsxs(Q,{variant:"secondary",children:[e.jsx(hn,{className:"w-3 h-3 mr-1"}),"Inlöst"]}),u&&!p&&e.jsx(Q,{variant:"secondary",children:"Utgången"}),!p&&!u&&f&&e.jsxs(Q,{className:"bg-amber-500 text-white",children:[e.jsx(ae,{className:"w-3 h-3 mr-1"}),c,"d kvar"]}),!p&&!u&&!f&&e.jsxs(Q,{variant:"outline",className:"border-green-500 text-green-600",children:[c,"d kvar"]})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:`font-semibold ${p||u?"text-muted-foreground":""}`,children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description})]}),t.value_nominal&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"w-4 h-4 text-amber-500"}),e.jsxs("span",{className:"font-bold text-lg",children:[t.value_nominal," krediter"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"nominellt värde"})]}),t.points&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"w-4 h-4 text-primary"}),e.jsxs("span",{className:"font-bold text-lg",children:[t.points," poäng"]})]}),t.redemption_instructions&&e.jsxs("p",{className:"text-xs text-muted-foreground bg-muted/50 rounded-lg p-2",children:["💡 ",t.redemption_instructions]}),!p&&!u&&e.jsxs(L,{onClick:x,disabled:s,className:"w-full",size:"sm",children:[e.jsx(bn,{className:"w-4 h-4 mr-2"}),s?"Genererar QR...":"Visa QR-kod för inlösning"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:p?`Inlöst ${T(new Date(t.redeemed_at),"d MMM yyyy",{locale:Y})}`:`Utgår ${T(new Date(t.expires_at),"d MMM yyyy",{locale:Y})}`})]})]})}),e.jsx(ue,{open:n,onOpenChange:a,children:e.jsxs(me,{className:"max-w-sm",children:[e.jsx(fe,{children:e.jsx(ge,{children:"Visa för kassan"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[r&&e.jsx("img",{src:r,alt:"QR-kod",className:"w-64 h-64 rounded-xl"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-semibold",children:t.title}),t.orderer_brand&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.orderer_brand})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:["Kod: ",e.jsx("span",{className:"font-mono",children:t.code}),e.jsx("br",{}),"Giltigt t.o.m. ",T(new Date(t.expires_at),"d MMMM yyyy",{locale:Y})]})]})]})})]})}const Sr="https://api.quixzoom.com/api/qz";async function Er(t="month",n="world",a=15){try{const r=new URLSearchParams({period:t,scope:n,limit:String(a)}),o=await fetch(`${Sr}/missions/leaderboard?${r.toString()}`);return o.ok?(await o.json()).leaderboard??[]:(console.warn("[leaderboard-api] fetch failed:",o.status),[])}catch(r){return console.error("[leaderboard-api] error:",r),[]}}function Ar(t){const n=typeof t=="number"?t:0;return n>=1e6?`${(n/1e6).toFixed(1)}M krediter`:n>=1e3?`${Math.round(n/1e3)}k krediter`:`${n.toLocaleString("sv-SE")} krediter`}function _e({className:t="",userCity:n}){var d;const{t:a}=he(),[r,o]=v.useState("month"),[s,i]=v.useState("world"),[l,c]=v.useState([]),[f,u]=v.useState(!0),[p,x]=v.useState(!0);v.useEffect(()=>{let m=!1;return u(!0),Er(r,s,15).then(j=>{m||(c(j),x(j.length>0),u(!1))}),()=>{m=!0}},[r,s]);const h=[{value:"all",label:a("leaderboard.total","Totalt")},{value:"year",label:a("time.year","Senaste året")},{value:"month",label:a("leaderboard.thisMonth","Denna månad")},{value:"today",label:a("common.today","Idag")}],b=[{value:"nearby",label:a("map.nearYou","Nära dig"),icon:mt},{value:"country",label:a("location.sweden","Sverige"),icon:pn},{value:"world",label:a("location.world","Världen"),icon:ft}],w=m=>m===1?e.jsx(xn,{className:"w-5 h-5 text-yellow-500"}):m===2?e.jsx(ot,{className:"w-5 h-5 text-gray-400"}):m===3?e.jsx(ot,{className:"w-5 h-5 text-amber-600"}):e.jsxs("span",{className:"w-5 h-5 flex items-center justify-center text-sm font-bold text-muted-foreground",children:["#",m]}),g=m=>m===1?"bg-gradient-to-r from-yellow-500/20 via-amber-500/10 to-transparent border-yellow-500/40":m===2?"bg-gradient-to-r from-gray-400/20 via-gray-300/10 to-transparent border-gray-400/40":m===3?"bg-gradient-to-r from-amber-600/20 via-orange-500/10 to-transparent border-amber-600/40":"bg-card/50 border-border/50",y=((d=b.find(m=>m.value===s))==null?void 0:d.label)??a("location.world","Världen");return e.jsxs("div",{className:t,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(nt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:a("leaderboard.title","Topplista")}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Top 15 – ",y]})]})]}),e.jsx("div",{className:"flex gap-1 mb-3 p-1 bg-muted/50 rounded-lg",children:b.map(m=>{const j=m.icon;return e.jsxs(L,{variant:s===m.value?"default":"ghost",size:"sm",onClick:()=>i(m.value),className:"flex-1 text-xs gap-1",children:[e.jsx(j,{className:"w-3 h-3"}),m.label]},m.value)})}),e.jsx("div",{className:"flex gap-2 mb-4 overflow-x-auto pb-1 -mx-4 px-4 scrollbar-hide",children:h.map(m=>e.jsx(L,{variant:r===m.value?"secondary":"ghost",size:"sm",onClick:()=>o(m.value),className:"text-xs px-3 flex-shrink-0",children:m.label},m.value))}),f?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(gt,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):p?e.jsx("div",{className:"space-y-2 max-h-[500px] overflow-y-auto pr-1",children:e.jsx(wt,{mode:"popLayout",children:l.map((m,j)=>e.jsx(De.div,{initial:{opacity:0,x:-20,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:20,scale:.95},transition:{delay:j*.015,type:"spring",stiffness:400,damping:30},layout:!0,children:e.jsx(I,{className:`p-3 border ${g(m.rank)} backdrop-blur-sm`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center ${m.rank<=3?"bg-background/80":"bg-muted/50"}`,children:w(m.rank)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-foreground truncate",children:m.nickname}),e.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:e.jsx("span",{children:[m.gender==="male"?a("gender.male","Man"):m.gender==="female"?a("gender.female","Kvinna"):null,m.age?String(m.age):null,m.city].filter(Boolean).join(", ")})})]}),e.jsx("div",{className:"text-right flex-shrink-0",children:e.jsx("p",{className:`font-bold text-sm ${m.rank===1?"text-yellow-500":m.rank===2?"text-gray-400":m.rank===3?"text-amber-600":"text-primary"}`,children:Ar(m.total_earned)})})]})})},`${s}-${r}-${m.user_id}-${m.rank}`))})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(nt,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"Inga data ännu"}),e.jsx("p",{className:"text-xs mt-1",children:"Bli först på topplistan — slutför ditt första uppdrag!"})]})]})}var we="Collapsible",[Mr]=tn(we),[Tr,Je]=Mr(we),Ut=v.forwardRef((t,n)=>{const{__scopeCollapsible:a,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...l}=t,[c,f]=Xt({prop:r,defaultProp:o??!1,onChange:i,caller:we});return e.jsx(Tr,{scope:a,disabled:s,contentId:Qt(),open:c,onOpenToggle:v.useCallback(()=>f(u=>!u),[f]),children:e.jsx(ze.div,{"data-state":Qe(c),"data-disabled":s?"":void 0,...l,ref:n})})});Ut.displayName=we;var $t="CollapsibleTrigger",zt=v.forwardRef((t,n)=>{const{__scopeCollapsible:a,...r}=t,o=Je($t,a);return e.jsx(ze.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Qe(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:n,onClick:Yt(t.onClick,o.onOpenToggle)})});zt.displayName=$t;var Xe="CollapsibleContent",Kt=v.forwardRef((t,n)=>{const{forceMount:a,...r}=t,o=Je(Xe,t.__scopeCollapsible);return e.jsx(Wt,{present:a||o.open,children:({present:s})=>e.jsx(_r,{...r,ref:n,present:s})})});Kt.displayName=Xe;var _r=v.forwardRef((t,n)=>{const{__scopeCollapsible:a,present:r,children:o,...s}=t,i=Je(Xe,a),[l,c]=v.useState(r),f=v.useRef(null),u=Zt(n,f),p=v.useRef(0),x=p.current,h=v.useRef(0),b=h.current,w=i.open||l,g=v.useRef(w),y=v.useRef(void 0);return v.useEffect(()=>{const d=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(d)},[]),en(()=>{const d=f.current;if(d){y.current=y.current||{transitionDuration:d.style.transitionDuration,animationName:d.style.animationName},d.style.transitionDuration="0s",d.style.animationName="none";const m=d.getBoundingClientRect();p.current=m.height,h.current=m.width,g.current||(d.style.transitionDuration=y.current.transitionDuration,d.style.animationName=y.current.animationName),c(r)}},[i.open,r]),e.jsx(ze.div,{"data-state":Qe(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!w,...s,ref:u,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:w&&o})});function Qe(t){return t?"open":"closed"}var Br=Ut;const Vt=Br,Ot=zt,Gt=Kt,Ir=[{id:"unicef",name:"UNICEF",description:"Räddar barn världen över",mission:"Arbetar för barns rättigheter i över 190 länder. Varje krona hjälper barn få tillgång till utbildning, rent vatten och sjukvård.",icon:jt,color:"#00AEEF",gradient:"from-cyan-500 to-blue-500",impact:"100 krediter = vaccin till 10 barn",website:"https://unicef.se"},{id:"doctors-without-borders",name:"Läkare Utan Gränser",description:"Medicinsk hjälp i kriszoner",mission:"Ger livräddande medicinsk vård till människor i nöd, oavsett var de befinner sig eller vilka de är.",icon:Rn,color:"#ED1C24",gradient:"from-red-500 to-rose-600",impact:"250 krediter = medicin för en familj",website:"https://lakareutangranser.se"},{id:"wwf",name:"WWF",description:"Skyddar naturen och djurlivet",mission:"Kämpar för att bevara biologisk mångfald och skydda utrotningshotade arter runt om i världen.",icon:jn,color:"#000000",gradient:"from-green-600 to-emerald-500",impact:"150 krediter = skyddar 1 hektar regnskog",website:"https://wwf.se"},{id:"wateraid",name:"WaterAid",description:"Rent vatten till alla",mission:"Arbetar för att alla människor ska ha tillgång till rent vatten, sanitet och hygien. Vatten är grunden för allt.",icon:Dn,color:"#0099CC",gradient:"from-blue-500 to-cyan-400",impact:"200 krediter = rent vatten i en månad",website:"https://wateraid.org"},{id:"plan",name:"Plan International",description:"Utbildning för flickor",mission:"Kämpar för barns rättigheter och flickors lika möjligheter till utbildning och framtid.",icon:Nn,color:"#009FE3",gradient:"from-blue-400 to-indigo-500",impact:"300 krediter = skolmaterial för ett barn",website:"https://plansverige.org"},{id:"stadsmission",name:"Stadsmissionen",description:"Hjälper utsatta i Sverige",mission:"Ger stöd till människor i hemlöshet och utsatthet. Ingen ska behöva vara hungrig eller frysa.",icon:yn,color:"#E31937",gradient:"from-red-500 to-orange-500",impact:"100 krediter = en varm måltid",website:"https://stadsmissionen.se"},{id:"wfp",name:"World Food Programme",description:"Bekämpar hunger globalt",mission:"FN:s livsmedelsprogram räddar liv genom att leverera mat till de mest utsatta i världen.",icon:Ln,color:"#2A93FC",gradient:"from-blue-500 to-sky-400",impact:"50 krediter = mat till en familj i en dag",website:"https://wfp.org"},{id:"hand-in-hand",name:"Hand in Hand",description:"Skapar jobb för att utrota fattigdom",mission:"Hjälper människor i fattigdom att starta egna företag och försörja sig själva och sina familjer.",icon:ft,color:"#F7941D",gradient:"from-orange-500 to-amber-500",impact:"500 krediter = en mikroentreprenör får stöd",website:"https://handinhand.se"}];function Dr({availableBalance:t,onDonate:n}){const{t:a}=he(),[r,o]=v.useState(null),[s,i]=v.useState({}),[l,c]=v.useState(!1),[f,u]=v.useState(!1),[p,x]=v.useState(null),h=()=>{if(!p)return;const g=`Jag har just donerat ${p.amount} krediter till ${p.charity.name} via Roxvault! 💚 Tillsammans kan vi göra skillnad.`,y=p.charity.website||"https://roxvault.app",d=`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(y)}"e=${encodeURIComponent(g)}`;window.open(d,"_blank","width=600,height=400"),M.success(a("charity.thanksForSharing")),u(!1)},b=async g=>{const y=parseInt(s[g.id])||0;if(y<10){M.error(a("charity.minDonation"));return}if(y>t){M.error(a("charity.notEnoughCredits"));return}c(!0),n?await n(g.id,y)&&(M.success(a("charity.thanksDonation",{amount:y,name:g.name})),x({charity:g,amount:y}),u(!0),o(null),i(m=>({...m,[g.id]:""}))):(await new Promise(d=>setTimeout(d,1e3)),M.success(a("charity.thanksDonation",{amount:y,name:g.name})),x({charity:g,amount:y}),u(!0),o(null),i(d=>({...d,[g.id]:""}))),c(!1)},w=[50,100,250,500];return e.jsxs(e.Fragment,{children:[e.jsx(ue,{open:f,onOpenChange:u,children:e.jsxs(me,{className:"sm:max-w-md",children:[e.jsxs(fe,{children:[e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"w-5 h-5 text-green-500"}),a("charity.donationComplete")]}),e.jsx(nn,{children:a("charity.donatedTo",{amount:p==null?void 0:p.amount,name:p==null?void 0:p.charity.name})})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[p&&e.jsxs("div",{className:"p-4 rounded-xl text-center",style:{background:p.charity.color+"15"},children:[e.jsx("div",{className:`w-12 h-12 rounded-xl bg-gradient-to-br ${p.charity.gradient} flex items-center justify-center mx-auto mb-3`,children:e.jsx(p.charity.icon,{className:"w-6 h-6 text-white"})}),e.jsxs("p",{className:"font-semibold",children:[p.amount," krediter ",a("charity.to")," ",p.charity.name]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[a("charity.thankYou")," 💚"]})]}),e.jsxs(L,{onClick:h,className:"w-full bg-[#1877F2] hover:bg-[#166FE5] text-white",children:[e.jsx(Pn,{className:"w-5 h-5 mr-2"}),a("charity.shareOnFacebook")]}),e.jsx(L,{variant:"outline",onClick:()=>u(!1),className:"w-full",children:a("charity.maybeLater")})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(jt,{className:"w-5 h-5 text-rose-500"}),e.jsx("h2",{className:"text-lg font-semibold",children:a("charity.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground -mt-2 mb-4",children:a("charity.description")}),e.jsx("div",{className:"space-y-2",children:Ir.map((g,y)=>e.jsx(De.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:y*.03},children:e.jsxs(Vt,{open:r===g.id,onOpenChange:d=>o(d?g.id:null),children:[e.jsx(Ot,{asChild:!0,children:e.jsxs("div",{className:"w-full p-3 rounded-xl border-2 cursor-pointer transition-all hover:shadow-md flex items-center gap-3",style:{borderColor:r===g.id?g.color:g.color+"30"},children:[e.jsx("div",{className:`w-10 h-10 rounded-xl bg-gradient-to-br ${g.gradient} flex items-center justify-center flex-shrink-0`,children:e.jsx(g.icon,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("h3",{className:"font-semibold text-sm",children:g.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g.description})]}),e.jsx(Pe,{className:`w-5 h-5 text-muted-foreground transition-transform ${r===g.id?"rotate-180":""}`})]})}),e.jsx(Gt,{children:e.jsx(wt,{children:e.jsxs(De.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"px-3 pb-4 pt-3 space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:g.mission}),e.jsx("div",{className:"p-3 rounded-xl text-sm",style:{background:g.color+"15"},children:e.jsxs("span",{className:"font-medium",style:{color:g.color},children:["💡 ",g.impact]})}),e.jsxs("div",{children:[e.jsx(ht,{htmlFor:`donation-${g.id}`,children:a("charity.amount")}),e.jsx(pt,{id:`donation-${g.id}`,type:"number",placeholder:a("charity.enterAmount"),value:s[g.id]||"",onChange:d=>i(m=>({...m,[g.id]:d.target.value})),max:t,className:"text-lg"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a("charity.available"),": ",t," krediter"]})]}),e.jsx("div",{className:"flex gap-2",children:w.map(d=>e.jsxs(L,{variant:s[g.id]===String(d)?"default":"outline",size:"sm",className:"flex-1",onClick:()=>i(m=>({...m,[g.id]:String(d)})),disabled:d>t,children:[d," krediter"]},d))}),e.jsx(L,{className:"w-full",style:{background:g.color},onClick:()=>b(g),disabled:!s[g.id]||parseInt(s[g.id])<10||l,children:l?a("charity.donating"):`${a("charity.donate")} ${s[g.id]||0} krediter`}),g.website&&e.jsxs("a",{href:g.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[a("charity.readMoreAt")," ",g.name,e.jsx(vn,{className:"w-3 h-3"})]})]})})})]})},g.id))})]})]})}const oe=.25,qt=.35;function ie(t,n){const a=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0");return`RXv-${a}${r}-${String(t+1).padStart(5,"0")}`}function Pr(t){const n="0123456789ABCDEF";let a="";for(let r=0;r<6;r++)a+=n[Math.floor(Math.random()*n.length)];return`${t}-${a}`}function Jt(t){const n=t/(1-qt),a=n-t,r=n*(1+oe),o=r-n;return{grossAmount:Math.round(r*100)/100,vatAmount:Math.round(o*100)/100,taxDeducted:Math.round(a*100)/100,netAmount:t}}function Ue(t){return t?{companyName:t.organization_name,organizationNumber:t.organization_number,companyType:t.organization_type==="authority"?"Myndighet":"Aktiebolag",registeredCountry:t.country||"Sverige",address:{streetAddress:t.street_address,postalCode:t.postal_code,city:t.city,country:t.country||"Sverige"},orderer:{name:t.contact_person,title:"Beställare",department:"Uppdragsansvarig"}}:{companyName:"Rewault AB",organizationNumber:"559XXX-XXXX",companyType:"Aktiebolag",registeredCountry:"Sverige",address:{streetAddress:"Uppgift ej tillgänglig",postalCode:"",city:"Stockholm",country:"Sverige"},orderer:{name:"Systemgenererad",title:"Automatisk",department:"Plattformstjänster"}}}function $e(t){var a;const n=t.includes(",")&&((a=t.split(",")[1])==null?void 0:a.trim())||"Stockholm";return{streetAddress:t||"Uppgift ej specificerad",postalCode:"",city:n,municipality:`${n}s kommun`,county:`${n}s län`,country:"Sverige",latitude:59.3293+(Math.random()-.5)*.1,longitude:18.0686+(Math.random()-.5)*.1,coordinateSystem:"WGS 84",accuracy:"±5 meter (GPS)"}}const Rr={"McDonald's Sverige AB":{organization_name:"McDonald's Sverige AB",organization_number:"556038-8434",organization_type:"company",contact_person:"Maria Lindqvist",street_address:"Frösundaviks allé 1",postal_code:"169 70",city:"Solna",country:"Sverige"},"Tesla Sweden AB":{organization_name:"Tesla Sweden AB",organization_number:"556959-2021",organization_type:"company",contact_person:"Johan Eriksson",street_address:"Karlavägen 60",postal_code:"114 49",city:"Stockholm",country:"Sverige"},"Spotify AB":{organization_name:"Spotify AB",organization_number:"556703-7485",organization_type:"company",contact_person:"Emma Andersson",street_address:"Regeringsgatan 19",postal_code:"111 53",city:"Stockholm",country:"Sverige"}};function Be(t){const n=[{title:"McDonald's Stureplan",area:"Kungsgatan 4, Stockholm",amount:150,payer:"McDonald's Sverige AB"},{title:"Tesla Supercharger Dokumentation",area:"Täby Centrum, Täby",amount:200,payer:"Tesla Sweden AB"},{title:"IKEA Entré-foto",area:"Modulvägen 1, Kungens Kurva",amount:120,payer:"McDonald's Sverige AB"},{title:"Spotify HQ Fasad",area:"Regeringsgatan 19, Stockholm",amount:180,payer:"Spotify AB"},{title:"SL Tunnelbana Station",area:"T-Centralen, Stockholm",amount:100,payer:"Tesla Sweden AB"},{title:"H&M Flagship Store",area:"Drottninggatan 56, Stockholm",amount:140,payer:"McDonald's Sverige AB"},{title:"Coop Matbutik",area:"Götgatan 31, Södermalm",amount:90,payer:"Spotify AB"},{title:"Circle K Bensinstation",area:"E4 Norrtull, Stockholm",amount:110,payer:"Tesla Sweden AB"},{title:"Systembolaget Skyltning",area:"Odengatan 43, Stockholm",amount:130,payer:"McDonald's Sverige AB"},{title:"Pressbyrån Kiosk",area:"Centralen, Stockholm",amount:75,payer:"Spotify AB"},{title:"MAX Hamburgare",area:"Fridhemsplan 1, Stockholm",amount:160,payer:"Tesla Sweden AB"},{title:"Volvo Showroom",area:"Fleminggatan 14, Kungsholmen",amount:220,payer:"McDonald's Sverige AB"},{title:"Nordic Choice Hotel",area:"Sky City, Arlanda",amount:190,payer:"Spotify AB"},{title:"Stadium Sportbutik",area:"Mall of Scandinavia, Solna",amount:145,payer:"Tesla Sweden AB"},{title:"Apotek Hjärtat",area:"Sveavägen 42, Vasastan",amount:95,payer:"McDonald's Sverige AB"}],a=[];let r=t,o=0;const s=new Date;for(;r>0&&o<n.length*3;){const i=n[o%n.length],l=Math.min(i.amount,r),c=Math.floor(o*2.5)+Math.floor(Math.random()*3),f=new Date(s);f.setDate(f.getDate()-c),f.setHours(8+Math.floor(Math.random()*12),Math.floor(Math.random()*60));const u=Jt(l),p=Rr[i.payer]||null;a.push({id:`mock-${o}`,receiptId:ie(o,f),grossAmount:u.grossAmount,vatAmount:u.vatAmount,taxDeducted:u.taxDeducted,netAmount:u.netAmount,created_at:f.toISOString(),description:null,mission_title:i.title,mission_area:i.area,completed_at:f.toISOString(),payer:Ue(p),serviceType:"Fotograferingstjänst – Professionell teknisk dokumentation",serviceContent:"Fotografering utförd i samband med teknisk inventering. Dokumentationen avser teknisk verifiering av objektets existens, placering och status.",servicePurpose:["intern kontroll","säkerhetsdokumentation","fastighetsrelaterad uppföljning"],location:$e(i.area)}),r-=l,o++}return a}function Lr({open:t,onOpenChange:n,totalEarned:a}){const{t:r,i18n:o}=he(),{user:s}=de(),[i,l]=v.useState([]),[c,f]=v.useState(!0),[u,p]=v.useState(null),[x,h]=v.useState(!1),w=(()=>{switch(o.language){case"de":return bt;case"en":return yt;default:return Y}})(),g=i.reduce((d,m)=>({gross:d.gross+m.grossAmount,vat:d.vat+m.vatAmount,tax:d.tax+m.taxDeducted,net:d.net+m.netAmount}),{gross:0,vat:0,tax:0,net:0});v.useEffect(()=>{if(!t||!s)return;async function d(){f(!0);try{const m=await X(`/wallets?user_id=${s.id}`);if(!m){a>0&&l(Be(a)),f(!1);return}const j=await X(`/transactions?wallet_id=${m.id}&type=credit&order=created_at.desc`);if(!j||j.length===0){a>0?l(Be(a)):l([]),f(!1);return}const C=await Promise.all(j.map(async(N,E)=>{const _=Jt(N.amount),k=new Date(N.created_at);if(N.claim_id){const A=await X(`/claims/${N.claim_id}`),S=A==null?void 0:A.missions,R=(S==null?void 0:S.title)||null,B=(S==null?void 0:S.area_name)||null,Ye=(S==null?void 0:S.created_by)||null;let We=null;Ye&&(We=await X(`/orderer-profiles?user_id=${Ye}`));const je=$e(B||"Stockholm");return S!=null&&S.latitude&&(S!=null&&S.longitude)&&(je.latitude=S.latitude,je.longitude=S.longitude),{id:N.id,receiptId:ie(E,k),..._,created_at:N.created_at,description:N.description,mission_title:R,mission_area:B,completed_at:(A==null?void 0:A.completed_at)||null,payer:Ue(We),serviceType:"Fotograferingstjänst – Professionell teknisk dokumentation",serviceContent:"Fotografering utförd i samband med teknisk inventering.",servicePurpose:["intern kontroll","säkerhetsdokumentation"],location:je}}return{id:N.id,receiptId:ie(E,k),..._,created_at:N.created_at,description:N.description,mission_title:null,mission_area:null,completed_at:null,payer:Ue(null),serviceType:"Fotograferingstjänst – Professionell teknisk dokumentation",serviceContent:"Fotografering utförd i samband med teknisk inventering.",servicePurpose:["intern kontroll","säkerhetsdokumentation"],location:$e("Stockholm")}}));l(C)}catch(m){console.error("Error fetching earnings history:",m),a>0&&l(Be(a))}finally{f(!1)}}d()},[t,s,a]);const y=async()=>{if(!s){M.error(r("earningsHistory.mustBeLoggedIn"));return}if(i.length===0){M.error(r("earningsHistory.noTransactionsToExport"));return}h(!0);try{const d=new Date,m=ie(0,d),j={documentType:"Kontoutdrag",documentStatus:"Slutfört / Finalized",documentId:m,referenceNumber:m,documentDate:T(d,"yyyy-MM-dd"),documentTime:T(d,"HH:mm"),timezone:"CET",payer:i[0].payer,issuer:{companyName:"Rewault AB",organizationNumber:"559XXX-XXXX",vatRegistrationNumber:"SE559XXXXXX01",country:"Sverige",address:"Stockholm, Sverige",email:"faktura@rewault.com"},services:i.map(N=>({description:N.mission_title||N.description||"Fotograferingsuppdrag",serviceType:N.serviceType,serviceContent:N.serviceContent,servicePurpose:N.servicePurpose,quantity:1,unitPrice:N.grossAmount/(1+oe),vatRate:oe,vatAmount:N.vatAmount,totalAmount:N.grossAmount,location:N.location})),timeline:{orderReceived:{date:T(new Date(i[0].created_at),"yyyy-MM-dd"),time:T(new Date(i[0].created_at),"HH:mm"),timezone:"CET"},serviceExecuted:{date:T(new Date(i[0].completed_at||i[0].created_at),"yyyy-MM-dd"),time:T(new Date(i[0].completed_at||i[0].created_at),"HH:mm"),timezone:"CET"},paymentReceived:{date:T(d,"yyyy-MM-dd"),time:T(d,"HH:mm"),timezone:"CET"},transactionCompleted:{date:T(d,"yyyy-MM-dd"),time:T(d,"HH:mm"),timezone:"CET"}},financials:{grossAmount:g.gross,vatAmount:g.vat,vatRate:oe,preliminaryTax:g.tax,taxRate:qt,netAmount:g.net,currency:"SEK"},taxCompliance:{taxNote:"Preliminärskatt om 35% har dragits för att säkerställa efterlevnad av kommunal beskattning oavsett hemkommun.",controlStatementNote:"Kontrolluppgift lämnas årligen i enlighet med svensk skattelagstiftning.",taxAuthority:"Skatteverket"},documentHash:Pr(m),recipient:{name:s.email||"Användare",email:s.email||"",userId:s.id}},C=await sn("/generate-invoice-pdf",{receiptData:j});if(C!=null&&C.downloadUrl)window.open(C.downloadUrl,"_blank"),M.success(r("earningsHistory.pdfGenerated"));else if((C==null?void 0:C.status)==="processing")M.info(r("earningsHistory.pdfProcessing"));else throw new Error("No download URL received")}catch(d){console.error("Error generating PDF:",d),M.error(r("earningsHistory.pdfError"))}finally{h(!1)}};return e.jsx(ue,{open:t,onOpenChange:n,children:e.jsxs(me,{className:"max-w-lg max-h-[85vh]",children:[e.jsx(fe,{children:e.jsxs(ge,{className:"flex items-center gap-2",children:[e.jsx(Nt,{className:"h-5 w-5 text-primary"}),r("earningsHistory.title")]})}),e.jsx("div",{className:"bg-muted/50 border border-border rounded-lg p-3 mb-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsx("p",{className:"font-medium",children:r("earningsHistory.auditCompliant")}),e.jsx("p",{children:r("earningsHistory.auditDescription")})]})]})}),e.jsx(I,{className:"bg-muted/30 border-border",children:e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:r("earningsHistory.grossAmount")}),e.jsxs("p",{className:"text-lg font-mono font-semibold",children:[g.gross.toFixed(2)," SEK"]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:[r("earningsHistory.vat")," (25%)"]}),e.jsxs("p",{className:"text-lg font-mono font-semibold text-muted-foreground",children:["−",g.vat.toFixed(2)," SEK"]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:[r("earningsHistory.preliminaryTax")," (35%)"]}),e.jsxs("p",{className:"text-lg font-mono font-semibold text-muted-foreground",children:["−",g.tax.toFixed(2)," SEK"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:r("earningsHistory.netPaid")}),e.jsxs("p",{className:"text-2xl font-mono font-bold",children:[g.net.toFixed(2)," SEK"]})]})]}),e.jsx(q,{className:"my-3"}),e.jsxs("div",{className:"flex justify-between items-center text-xs text-muted-foreground",children:[e.jsxs("span",{className:"font-mono",children:[r("earningsHistory.transactions"),": ",i.length]}),e.jsxs(ln,{children:[e.jsx(cn,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5 font-medium",disabled:x||i.length===0,children:[x?e.jsx(gt,{className:"h-3 w-3 animate-spin"}):e.jsx(st,{className:"h-3 w-3"}),r(x?"earningsHistory.generating":"earningsHistory.pdf"),e.jsx(Pe,{className:"h-3 w-3 ml-0.5"})]})}),e.jsxs(dn,{align:"end",className:"w-40",children:[e.jsxs(Ze,{onClick:y,className:"gap-2 cursor-pointer",children:[e.jsx(Sn,{className:"h-4 w-4"}),r("earningsHistory.download")]}),e.jsxs(Ze,{onClick:()=>M.info(r("earningsHistory.sendEmailSoon")),className:"gap-2 cursor-pointer",children:[e.jsx(En,{className:"h-4 w-4"}),r("earningsHistory.send")]})]})]})]})]})}),e.jsx(kn,{className:"max-h-[350px] pr-4",children:c?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx(z,{className:"h-24 w-full"},d))}):i.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(rn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:r("earningsHistory.noServicesRecorded")}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:r("earningsHistory.completeMissionsForReceipts")})]}):e.jsx("div",{className:"space-y-2",children:i.map(d=>e.jsx(Vt,{open:u===d.id,onOpenChange:m=>p(m?d.id:null),children:e.jsxs(I,{className:"border-border",children:[e.jsx(Ot,{asChild:!0,children:e.jsx(P,{className:"p-3 cursor-pointer hover:bg-muted/30 transition-colors",children:e.jsxs("div",{className:"flex justify-between items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"font-medium text-sm truncate max-w-[140px] sm:max-w-none",children:d.mission_title||d.description||r("earningsHistory.serviceExecution")}),e.jsx(Pe,{className:`h-4 w-4 text-muted-foreground transition-transform flex-shrink-0 ${u===d.id?"rotate-180":""}`})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 mt-1 text-xs text-muted-foreground font-mono overflow-hidden",children:[e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(st,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:d.receiptId})]}),e.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(An,{className:"h-3 w-3"}),T(new Date(d.completed_at||d.created_at),"yyyy-MM-dd",{locale:w})]})]})]}),e.jsxs(Q,{variant:"outline",className:"bg-muted text-foreground border-border font-mono flex-shrink-0 text-xs",children:["+",d.netAmount.toFixed(0)," SEK"]})]})})}),e.jsx(Gt,{children:e.jsxs("div",{className:"px-3 pb-3 pt-0",children:[e.jsx(q,{className:"mb-3"}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 space-y-3 text-xs",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground uppercase tracking-wide text-[10px]",children:r("earningsHistory.documentId")}),e.jsx("p",{className:"font-mono",children:d.receiptId})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground uppercase tracking-wide text-[10px]",children:r("earningsHistory.executed")}),e.jsxs("p",{className:"font-mono",children:[T(new Date(d.completed_at||d.created_at),"yyyy-MM-dd HH:mm",{locale:w})," CET"]})]})]}),e.jsx(q,{}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-muted-foreground uppercase tracking-wide text-[10px] flex items-center gap-1 mb-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),r("earningsHistory.payingOrganization")]}),e.jsx("p",{className:"font-medium",children:d.payer.companyName}),e.jsxs("p",{className:"text-muted-foreground",children:[r("earningsHistory.orgNumber"),": ",d.payer.organizationNumber]}),e.jsxs("p",{className:"text-muted-foreground",children:[d.payer.companyType," · ",d.payer.registeredCountry]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-muted-foreground uppercase tracking-wide text-[10px] flex items-center gap-1 mb-1",children:[e.jsx(mt,{className:"h-3 w-3"}),r("earningsHistory.serviceLocation")]}),e.jsx("p",{children:d.location.streetAddress}),e.jsxs("p",{className:"text-muted-foreground",children:[d.location.city,", ",d.location.country]}),e.jsxs("p",{className:"text-muted-foreground font-mono text-[10px]",children:[d.location.latitude.toFixed(4),"° N, ",d.location.longitude.toFixed(4),"° E (WGS84, ±5m)"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground uppercase tracking-wide text-[10px]",children:r("earningsHistory.serviceType")}),e.jsx("p",{children:d.serviceType})]}),e.jsx(q,{}),e.jsxs("div",{className:"space-y-1 font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:r("earningsHistory.grossAmount")}),e.jsxs("span",{children:[d.grossAmount.toFixed(2)," SEK"]})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsxs("span",{children:[r("earningsHistory.vat")," (25%)"]}),e.jsxs("span",{children:["−",d.vatAmount.toFixed(2)," SEK"]})]}),e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsxs("span",{children:[r("earningsHistory.preliminaryTax")," (35%)"]}),e.jsxs("span",{children:["−",d.taxDeducted.toFixed(2)," SEK"]})]}),e.jsx(q,{}),e.jsxs("div",{className:"flex justify-between font-semibold",children:[e.jsx("span",{children:r("earningsHistory.netPaid")}),e.jsxs("span",{children:[d.netAmount.toFixed(2)," SEK"]})]})]})]})]})})]})},d.id))})}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/60 text-center pt-2 border-t border-border font-mono space-y-0.5",children:[e.jsx("p",{children:r("earningsHistory.footer1")}),e.jsx("p",{children:r("earningsHistory.footer2")}),e.jsx("p",{children:r("earningsHistory.footer3")})]})]})})}const Fr=t=>{switch(t){case"de":return bt;case"en":return yt;default:return Y}};function gs(){const{t,i18n:n}=he(),{user:a,isLoading:r}=de(),{isLoading:o}=an(),{wallet:s,transactions:i,isLoading:l,error:c}=un(),{payouts:f,requestPayout:u}=Fn(),{activeVouchers:p,usedVouchers:x,expiresWithin7Days:h}=Ht(),[b,w]=v.useState(""),[g,y]=v.useState(!1),[d,m]=v.useState(!1),[j,C]=v.useState(!1),N=Fr(n.language);if(r||o)return e.jsxs("div",{className:"min-h-screen bg-background p-4",children:[e.jsx(z,{className:"h-40 w-full mb-4"}),e.jsx(z,{className:"h-20 w-full mb-2"}),e.jsx(z,{className:"h-20 w-full"})]});if(!a)return e.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[e.jsxs("div",{className:"bg-gradient-to-br from-primary to-primary/80 text-primary-foreground p-6 pt-[calc(env(safe-area-inset-top)+1.5rem)]",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:t("wallet.title")}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(I,{className:"bg-primary-foreground/10 border-primary-foreground/20",children:e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary-foreground/80 mb-1",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:t("wallet.balance")})]}),e.jsx("p",{className:"text-3xl font-bold text-primary-foreground",children:"0"}),e.jsx("p",{className:"text-xs text-primary-foreground/60",children:t("common.credits")})]})}),e.jsx(I,{className:"bg-primary-foreground/10 border-primary-foreground/20",children:e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary-foreground/80 mb-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:t("wallet.totalEarned")})]}),e.jsx("p",{className:"text-3xl font-bold text-primary-foreground",children:"0"}),e.jsx("p",{className:"text-xs text-primary-foreground/60",children:t("common.credits")})]})})]}),e.jsx(L,{className:"w-full mt-4 bg-primary-foreground text-primary hover:bg-primary-foreground/90",onClick:()=>window.location.href="/auth",children:t("wallet.loginToEarn")})]}),e.jsx("div",{className:"p-4 border-t border-border",children:e.jsx(_e,{})}),e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:t("wallet.transactionHistory")}),e.jsx(I,{children:e.jsxs(P,{className:"p-8 text-center",children:[e.jsx(ae,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:t("wallet.loginToSeeTransactions")})]})})]}),e.jsx(ve,{})]});if(c)return e.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[e.jsxs("div",{className:"bg-gradient-to-br from-primary to-primary/80 text-primary-foreground p-6 pt-[calc(env(safe-area-inset-top)+1.5rem)]",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:t("wallet.title")}),e.jsx(I,{className:"bg-primary-foreground/10 border-primary-foreground/20",children:e.jsxs(P,{className:"p-6 text-center",children:[e.jsx(Ne,{className:"h-12 w-12 mx-auto text-primary-foreground/40 mb-3"}),e.jsxs("p",{className:"text-primary-foreground font-medium mb-1",children:[t("wallet.balance"),": 0"]}),e.jsx("p",{className:"text-sm text-primary-foreground/60",children:t("common.credits")})]})})]}),e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(ae,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("wallet.noTransactions")}),e.jsx("p",{className:"text-xs text-muted-foreground/60",children:t("wallet.completeMissionsToEarn")})]}),e.jsx("div",{className:"p-4 border-t border-border",children:e.jsx(_e,{})}),e.jsx(ve,{})]});const E=parseInt(b)||0,_=async()=>{if(E<100){M.error(t("wallet.minWithdrawError"));return}m(!0);const k=await u(E,"stripe");m(!1),k&&(y(!1),w(""))};return e.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[e.jsxs("div",{className:"bg-gradient-to-br from-primary to-primary/80 text-primary-foreground p-6 pt-[calc(env(safe-area-inset-top)+1.5rem)]",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:t("wallet.title")}),l?e.jsx(z,{className:"h-24 w-full bg-primary-foreground/20"}):e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(I,{className:"bg-primary-foreground/10 border-primary-foreground/20",children:e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary-foreground/80 mb-1",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Krediter"})]}),e.jsx("p",{className:"text-3xl font-bold text-primary-foreground",children:s&&typeof s.balance=="number"?J(s.balance):"0 krediter"}),e.jsx("p",{className:"text-xs text-primary-foreground/60",children:s&&typeof s.balance=="number"?`≈ ${ke(mn(s.balance))}`:"1 kredit = 1 €"})]})}),e.jsx(I,{className:"bg-primary-foreground/10 border-primary-foreground/20",children:e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary-foreground/80 mb-1",children:[e.jsx(at,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Utbetalningsbart"})]}),e.jsx("p",{className:"text-3xl font-bold text-primary-foreground",children:s&&typeof s.balance=="number"&&s.balance>=ne?ke(et(s.balance)):"—"}),e.jsx("p",{className:"text-xs text-primary-foreground/60",children:s&&typeof s.balance=="number"&&s.balance<ne?`Min ${J(ne)} för uttag`:`${Math.round(tt*100)}% plattformsavgift`})]})})]}),e.jsxs(ue,{open:g,onOpenChange:y,children:[e.jsx(on,{asChild:!0,children:e.jsxs(L,{className:"w-full mt-4 bg-primary-foreground text-primary hover:bg-primary-foreground/90",disabled:!s||typeof s.balance!="number"||s.balance<100,children:[e.jsx(at,{className:"h-4 w-4 mr-2"}),"Begär utbetalning via Stripe"]})}),e.jsxs(me,{children:[e.jsx(fe,{children:e.jsx(ge,{children:t("wallet.withdraw")})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx(ht,{htmlFor:"amount",children:t("wallet.amount")}),e.jsx(pt,{id:"amount",type:"number",placeholder:t("wallet.minAmount"),value:b,onChange:k=>w(k.target.value),max:(s==null?void 0:s.balance)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t("wallet.available"),": ",(s==null?void 0:s.balance)||0," ",t("common.sek")]})]}),E>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Krediter att ta ut:"}),e.jsx("span",{className:"font-medium",children:J(Number(b)||0)})]}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"Plattformsavgift (15%):"}),e.jsxs("span",{children:["- ",J(Math.round((Number(b)||0)*tt))]})]}),e.jsxs("div",{className:"flex justify-between font-semibold border-t pt-1 mt-1",children:[e.jsx("span",{children:"Du får (€):"}),e.jsx("span",{className:"text-green-600",children:ke(et(Number(b)||0))})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1",children:"💡 Vouchers och produktbelöningar tas INTE ut som pengar — de löses in direkt hos företaget."})]}),e.jsx(L,{className:"w-full",onClick:_,disabled:E<100||d,children:t(d?"wallet.processing":"wallet.confirmWithdraw")})]})]})]})]}),f.filter(k=>k.status==="pending").length>0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Nt,{className:"h-5 w-5"}),t("wallet.pendingPayouts")]}),e.jsx("div",{className:"space-y-3",children:f.filter(k=>k.status==="pending").map(k=>e.jsx(I,{className:"border-orange-500/30 bg-orange-500/5",children:e.jsx(P,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[(k.net_amount??0).toLocaleString("sv-SE")," kr via Stripe Connect"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Connect"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T(new Date(k.created_at),"PPp",{locale:N})})]}),e.jsx("span",{className:"text-sm text-orange-500 font-medium",children:t("wallet.pending")})]})})},k.id))})]}),e.jsx("div",{className:"p-4 border-t border-border",children:e.jsx(Dr,{availableBalance:(s==null?void 0:s.balance)||0,onDonate:async(k,A)=>{const S=Ie.getToken();if(!S)return M.error("Ingen giltig session — logga in igen"),!1;try{const R=await fetch("${import.meta.env.VITE_QZ_API_BASE}/auth/donate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${S}`},body:JSON.stringify({charity_id:k,amount:A})}),B=await R.json();return R.ok?!0:(M.error(B.error||"Donation misslyckades"),!1)}catch{return M.error("Nätverksfel — donation misslyckades"),!1}}})}),e.jsx("div",{className:"p-4 border-t border-border",children:e.jsx(_e,{})}),s&&e.jsxs("div",{className:"mx-4 mb-4 p-3 bg-blue-500/10 border border-blue-500/20 rounded-lg text-xs text-blue-700 dark:text-blue-300 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"🪙 Krediter"})," = in-app valuta du tjänar via uppdrag"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"💸 Pengar"})," = konverteras från krediter vid uttag (min ",J(ne),", 15% avgift)"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"🎟️ Vouchers"})," = kuponger från företag, löses in i butik — visas nedan"]})]}),e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:t("wallet.transactionHistory")}),l?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(k=>e.jsx(z,{className:"h-16 w-full"},k))}):i.length===0?e.jsx(I,{children:e.jsxs(P,{className:"p-8 text-center",children:[e.jsx(ae,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:t("wallet.noTransactions")}),e.jsx("p",{className:"text-sm text-muted-foreground/60 mt-1",children:t("wallet.completeMissionsToEarn")})]})}):e.jsx("div",{className:"space-y-3",children:i.map(k=>{const A=fn(k.description||""),S=A==="cash"?"💸":A==="voucher"?"🎟️":"🪙",R=A==="cash"?"Utbetalning":A==="voucher"?"Kupong":"Krediter";return e.jsx(I,{children:e.jsxs(P,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(k.amount??0)>0?e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(In,{className:"h-5 w-5 text-green-500"})}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx(Bn,{className:"h-5 w-5 text-red-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[e.jsx("span",{className:"mr-1",children:S}),k.description||k.type]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"text-xs text-muted-foreground/60 mr-2",children:R}),T(new Date(k.created_at),"PPp",{locale:N})]})]})]}),e.jsxs("p",{className:`text-lg font-semibold ${(k.amount??0)>0?"text-green-500":"text-red-500"}`,children:[(k.amount??0)>0?"+":"",k.amount??0]})]})},k.id)})})]}),(p.length>0||x.length>0)&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"Mina kuponger & belöningar"})]}),h.length>0&&e.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/10 border border-amber-500/30 rounded-lg p-3",children:[e.jsx(_n,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm text-amber-700 dark:text-amber-400",children:[h.length," kupong",h.length>1?"er":""," går ut inom 7 dagar"]})]}),p.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Aktiva"}),p.map(k=>e.jsx(ut,{voucher:k},k.id))]}),x.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Använda / Utgångna"}),x.slice(0,3).map(k=>e.jsx(ut,{voucher:k},k.id))]})]}),e.jsx(Lr,{open:j,onOpenChange:C,totalEarned:(s==null?void 0:s.total_earned)||0}),e.jsx(ve,{})]})}export{gs as default};
|
||
//# sourceMappingURL=Wallet-DhBioTUc.js.map
|