1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WeeklyManagerBonusAudit-bxHO-G3Y.js","assets/index-DdU35jPJ.js","assets/index-ziLDO-qt.css","assets/weeklyManagerBonusFormatters-sk-boEuf.js","assets/index-CpcvuyT9.js","assets/format-C-2FZrE-.js","assets/index-CGPMVT10.js","assets/gift-iZbsnbdF.js","assets/createLucideIcon-DMxicyrC.js","assets/target-BtQDcMxu.js","assets/trophy-CQa1VtdB.js","assets/triangle-alert-l3tEQyle.js","assets/dollar-sign-Ca60MLZ3.js","assets/rotate-ccw-DX9Sab2l.js","assets/ChallengeHero-Ba_dbTZs.js","assets/confetti.module-CGx9Uca3.js","assets/index-CtlYlah8.js","assets/proxy-C7hkWtXH.js","assets/layers-w7JW3XkB.js","assets/arrow-right-BdTovHrw.js","assets/zap-R8goDiXI.js","assets/lock-Brnc1X-D.js","assets/chevron-up-w1zviHLx.js","assets/chevron-down-DcLGbHop.js","assets/clock-D8ofwCOI.js","assets/calendar-WJIH9OsN.js","assets/trending-up-D6tLkDJM.js","assets/chevron-right-PZEH6lk6.js","assets/refresh-cw-2pM8p9DH.js","assets/wallet-6HLGA_Th.js","assets/sparkles-BfFbpu9e.js","assets/circle-dot-CjT2MoiD.js","assets/circle-check-DIcqODlT.js","assets/arrow-down-Bpaao2tB.js","assets/circle-x-QpU72J1I.js","assets/package-DYJogmeO.js","assets/chevron-left-BcAcL8kJ.js","assets/SalesPageOpeningState-DkarD1ei.js","assets/uiAsync-Br22hwGx.js","assets/circle-play-DNmcT_o3.js","assets/HowItWorksModal-Dtohef03.js","assets/index-BhZ8ej-y.js","assets/index-12QbP6l0.js","assets/index-gN4drEn4.js","assets/index-BsvT06Lq.js","assets/index-9bdZCgcr.js","assets/index-BvvUEucZ.js","assets/index-Bwgqm7vL.js","assets/utils-DCmAa5as.js","assets/clsx-B-dksMZM.js","assets/bundle-mjs-BTmSotT-.js","assets/dialog-gVN6KGjC.js","assets/x-DAruoHhn.js","assets/dialog-BvzTRZmc.css","assets/use-mobile-B0EOQ6wr.js","assets/shopping-cart-vZlzvnWl.js","assets/lightbulb-Dn4qBCOd.js","assets/info-DXmh_8J-.js","assets/CommissionsLifetime-Dxyh0-3o.js","assets/shopping-bag-CrDvW2T1.js","assets/award-BXY6iOl3.js","assets/trending-down-4SJR8Ei-.js","assets/minus-Cyk10VU5.js","assets/generateCategoricalChart-CuyUVvyI.js","assets/tiny-invariant-BaFNuDhB.js","assets/BarChart-BkW8XfJv.js","assets/TeamChallengeProgress-BJGZtp8p.js","assets/crown-BUMK61KA.js","assets/users-ecdZz2CG.js","assets/TeamChallengeCelebration-BC-fii3H.js","assets/party-popper-JZfNkSql.js","assets/loader-circle-B5Ydjp3O.js"])))=>i.map(i=>d[i]); 2import{j as e,R as L,r as l,c as ie,D as ne,b as oe,t as me,_ as S}from"./index-DdU35jPJ.js";import{W as de}from"./wallet-6HLGA_Th.js";import{S as ee}from"./sparkles-BfFbpu9e.js";import{T as ce}from"./trending-up-D6tLkDJM.js";import{D as xe}from"./dollar-sign-Ca60MLZ3.js";import{C as Y}from"./circle-dot-CjT2MoiD.js";import{L as ue}from"./layers-w7JW3XkB.js";import{C as se}from"./circle-check-DIcqODlT.js";import{T as v}from"./trophy-CQa1VtdB.js";import{A as q}from"./arrow-down-Bpaao2tB.js";import{C as be}from"./circle-x-QpU72J1I.js";import{P as he}from"./package-DYJogmeO.js";import{C as pe}from"./chevron-up-w1zviHLx.js";import{C as ge}from"./chevron-down-DcLGbHop.js";import{C as fe}from"./chevron-left-BcAcL8kJ.js";import{C as je}from"./chevron-right-PZEH6lk6.js";import{S as Ne}from"./SalesPageOpeningState-DkarD1ei.js";import{w as ve}from"./uiAsync-Br22hwGx.js";import{L as Ce}from"./lock-Brnc1X-D.js";import{T as ye}from"./triangle-alert-l3tEQyle.js";import{R as K}from"./refresh-cw-2pM8p9DH.js";import{C as we}from"./circle-play-DNmcT_o3.js";const f=s=>s==null||isNaN(s)?"$0.00":"$"+Number(s).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),b=s=>s==null||isNaN(s)?"$0":"$"+Number(s).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0}),R=s=>s==null||isNaN(s)?"0":Number(s).toLocaleString("en-US"),is=(s,a)=>!a||a<=0?s>0?100:0:(s-a)/a*100;function ke({summary:s,refreshing:a,canViewGP:r=!1}){const n=Number.isFinite(Number(s.avgGrossProfitPerTire))?Number(s.avgGrossProfitPerTire):Number(s.tiresSold)>0?(Number(s.revenue||0)-Number(s.salesRepCost||0))/Number(s.tiresSold):0,o=[{label:"Earned Commission",value:s.earnedCommission,sub:"Accrued on completion",icon:de,gradient:"from-emerald-500 to-teal-600",ring:"ring-emerald-200",glow:"shadow-emerald-500/20",big:!0},{label:"Estimated Commission",value:s.estimatedCommission,sub:"Projected from open orders",icon:ee,gradient:"from-
2amber-400 to-orange-500",ring:"ring-amber-200",glow:"shadow-amber-500/20",big:!1},{label:"Avg Gross Profit / Tire",value:n,sub:`Commissionable GP across ${s.tiresSold||0} completed tires`,icon:ce,gradient:"from-blue-500 to-indigo-600",ring:"ring-blue-200",glow:"shadow-blue-500/20",big:!1}];return e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:o.map(i=>{const h=i.icon;return e.jsxs("div",{className:`relative overflow-hidden rounded-2xl bg-gradient-to-br ${i.gradient} p-5 sm:p-6 text-white shadow-lg ${i.glow} ring-1 ${i.ring} ${i.big?"lg:row-span-1":""}`,children:[e.jsx("div",{className:"absolute -right-6 -top-6 opacity-20",children:e.jsx(h,{className:"w-28 h-28"})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-white/20 flex items-center justify-center backdrop-blur-sm",children:e.jsx(h,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-white/90",children:i.label})]}),e.jsx("p",{className:`font-black tabular-nums tracking-tight ${i.big?"text-4xl sm:text-5xl":"text-3xl sm:text-4xl"}`,children:f(i.value)}),e.jsx("p",{className:"text-xs sm:text-sm text-white/80 mt-1.5",children:i.sub})]})]},i.label)})})}function Se({summary:s,canViewGP:a=!1}){const r=Number(s.tiresSold)>0?Number(s.revenue||0)/Number(s.tiresSold):0,n=[{label:"Revenue",value:b(s.revenue),sub:"Seller revenue",icon:xe,tint:"text-blue-600 bg-blue-50"},a?{label:"Avg GP / Order",value:b(s.avgGpPerOrder),sub:"Quality per sale",icon:Y,tint:"text-indigo-600 bg-indigo-50"}:{label:"Avg Revenue / Tire",value:b(r),sub:"Completed tire sales",icon:Y,tint:"text-indigo-600 bg-indigo-50"},{label:"Tires Sold",value:R(s.tiresSold),sub:"This period",icon:ue,tint:"text-emerald-600 bg-emerald-50"},{label:"Completed Orders",value:R(s.completedOrders),sub:"Earned",icon:se,tint:"text-amber-600 bg-amber-50"}];return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:n.map(o=>{const i=o.icon;return e.jsxs("div",{className:"rounded-2xl bg-white border border-slate-200/80 p-4 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:o.label}),e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${o.tint}`,children:e.jsx(i,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-2xl font-black text-slate-900 tabular-nums",children:o.value}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:o.sub})]},o.label)})})}function Q({row:s,canViewGP:a=!1}){const r=s.status==="earned",n=s.status==="estimated",o=s.earnedCommission||s.estimatedCommission||0,i=r?se:n?ee:be,h=r?"text-emerald-600":n?"text-amber-600":"text-slate-400",y=r?"Earned":n?"Estimated":"Cancelled";if(s.isChallengeReward){const m=s.challengeStatus==="reserved",N=m?s.estimatedCommission:s.earnedCommission,C=[{label:"Revenue",value:f(s.revenue)},{label:a?"Gross Profit":"Cost",value:f(a?s.salesGrossProfit:s.salesRepCost),strong:!0},{label:"Normal Commission (10%)",value:f(s.normalCommission||0)},{label:m?"Estimated 100% Commission":"100% Challenge Commission",value:f(s.challengeCommission||N||0),accent:!0},{label:m?"Reserved Estimate":"Commission Earned",value:f(N),final:!0}];return e.jsxs("div",{className:"bg-amber-50/60 border-t border-amber-200 px-4 py-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(v,{className:"w-4 h-4 text-amber-600"}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-amber-700",children:m?"100% Commission Reserved":"100% Commission Challenge"}),s.challengeNumber&&e.jsxs("span",{className:"text-[11px] text-amber-600/80",children:["· Reward #",s.challengeNumber]})]}),e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-1 flex-wrap",children:C.map((u,w)=>e.jsxs(L.Fragment,{children:[e.jsxs("div",{className:`flex-1 min-w-[140px] rounded-xl border px-4 py-3 ${u.final?"bg-amber-100 border-amber-300":u.accent?"bg-amber-50 border-amber-200":"bg-white border-slate-200"}`,children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 uppercase tracking-wider",children:u.label}),e.jsx("p",{className:`text-lg font-black tabular-nums ${u.final?"text-amber-700":u.accent?"text-amber-600":"text-slate-900"}`,children:u.value})]}),w<C.length-1&&e.jsx("div",{className:"flex justify-center sm:px-1 text-amber-300",children:e.jsx(q,{className:"w-4 h-4 rotate-0 sm:-rotate-90"})})]},u.label))}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-amber-700/90",children:[s.capApplied&&e.jsx("span",{className:"font-semibold",children:"Challenge payout cap applied: up to $1,000."}),e.jsxs("span",{children:[m?"Estimated bonus after completion":"Bonus paid by Challenge",": ",e.jsx("b",{className:"tabular-nums",children:f(s.bonusDifference||0)})]}),m&&e.jsx("span",{className:"font-semibold",children:"Finalizes only when Operations completes the order."})]})]})}const t=[{label:"Revenue",value:f(s.revenue)},{label:a?"Gross Profit":"Cost",value:f(a?s.salesGrossProfit:s.salesRepCost),strong:!0},{label:"Commission %",value:s.commissionRule},{label:r?"Commission Earned":n?"Estimated Commission":"Commission",value:f(o),final:!0}];return e.jsxs("div",{className:"bg-slate-50 border-t border-slate-200 px-4 py-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(i,{className:`w-4 h-4 ${h}`}),e.jsx("span",{className:`text-xs font-bold uppercase tracking-wider ${h}`,children:y}),n&&e.jsx("span",{className:"text-[11px] text-slate-400",children:"· estimate may change before completion"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-1",children:t.map((m,N)=>e.jsxs(L.Fragment,{children:[e.jsxs("div",{className:`flex-1 rounded-xl border px-4 py-3 ${m.final?"bg-emerald-50 border-emerald-200":(m.strong,"bg-white border-slate-200")}`,children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-500 uppercase tracking-wider",children:m.label}),e.jsx("p",{className:`text-lg font-black tabular-nums ${m.final?"text-emerald-600":"text-slate-900"}`,children:m.value})]}),N<t.length-1&&e.jsx("div",{className:"flex justify-center sm:px-1 text-slate-300",children:e.jsx(q,{className:"w-4 h-4 rotate-0 sm:-rotate-90"})})]},m.label))})]})}const J={earned:{dot:"bg-emerald-500",text:"text-emerald-700",bg:"bg-emerald-50",label:"Earned"}
2,estimated:{dot:"bg-amber-500",text:"text-amber-700",bg:"bg-amber-50",label:"Estimated"},cancelled:{dot:"bg-slate-400",text:"text-slate-500",bg:"bg-slate-100",label:"Cancelled"}};function X({status:s}){const a=J[s]||J.cancelled;return e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-semibold ${a.bg} ${a.text}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.dot}`}),a.label]})}function Z({row:s}){return s.status==="earned"?s.isChallengeReward?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 font-bold tabular-nums",children:[e.jsx(v,{className:"w-3.5 h-3.5"}),b(s.earnedCommission)]}):e.jsx("span",{className:"text-emerald-600 tabular-nums",children:b(s.earnedCommission)}):s.status==="estimated"?s.isChallengeReward?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-700 font-bold tabular-nums",children:[e.jsx(v,{className:"w-3.5 h-3.5"}),b(s.estimatedCommission)]}):e.jsx("span",{className:"text-amber-600 tabular-nums",children:b(s.estimatedCommission)}):e.jsx("span",{className:"text-slate-400",children:"$0"})}function Re({row:s}){return s.isChallengeReward?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-100 text-amber-700 px-2 py-0.5 text-xs font-bold",children:[e.jsx(v,{className:"w-3 h-3"}),s.challengeStatus==="reserved"?"100% Reserved":"100%"]}):e.jsx("span",{className:"text-slate-500",children:"10%"})}function _e({orders:s,pagination:a,onPageChange:r,canViewGP:n=!1}){const[o,i]=l.useState(null),h=t=>i(m=>m===t?null:t),y=s&&s.length>0;return e.jsxs("div",{className:"rounded-2xl bg-white border border-slate-200/80 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-5 py-4 border-b border-slate-200",children:e.jsx("h3",{className:"text-xs font-bold uppercase tracking-widest text-slate-400",children:"Order History"})}),y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-slate-50/70",children:["Customer","Order #","Date","Tires","Revenue",n?"Gross Profit":"Cost","Rule","Commission","Status"].map(t=>e.jsx("th",{className:"px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:t},t))})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:s.map(t=>e.jsxs(L.Fragment,{children:[e.jsxs("tr",{onClick:()=>h(t.id),className:`cursor-pointer hover:bg-slate-50 transition-colors ${t.isChallengeReward?"bg-amber-50/40":""}`,children:[e.jsxs("td",{className:"px-4 py-3 text-sm font-semibold text-slate-900 max-w-[200px] truncate",children:[t.isChallengeReward&&e.jsx(v,{className:"inline w-3.5 h-3.5 text-amber-500 mr-1.5 -mt-0.5"}),t.customerName]}),e.jsxs("td",{className:"px-4 py-3 text-sm font-mono text-slate-600",children:["#",t.orderNumber]}),e.jsx("td",{className:"px-4 py-3 text-sm text-slate-600 tabular-nums",children:t.dateCT||"â"}),e.jsx("td",{className:"px-4 py-3 text-sm text-slate-600 tabular-nums",children:R(t.tireQty)}),e.jsx("td",{className:"px-4 py-3 text-sm text-slate-900 tabular-nums",children:b(t.revenue)}),e.jsx("td",{className:"px-4 py-3 text-sm text-slate-900 tabular-nums",children:b(n?t.salesGrossProfit:t.salesRepCost)}),e.jsx("td",{className:"px-4 py-3 text-sm",children:e.jsx(Re,{row:t})}),e.jsx("td",{className:"px-4 py-3 text-sm font-bold tabular-nums",children:e.jsx(Z,{row:t})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(X,{status:t.status})})]}),o===t.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"p-0",children:e.jsx(Q,{row:t,canViewGP:n})})})]},t.id))})]})}),e.jsx("div",{className:"md:hidden divide-y divide-slate-100",children:s.map(t=>e.jsxs("div",{className:t.isChallengeReward?"bg-amber-50/40":"",children:[e.jsxs("div",{onClick:()=>h(t.id),className:"p-4 active:bg-slate-50",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"font-semibold text-slate-900 truncate flex items-center gap-1.5",children:[t.isChallengeReward&&e.jsx(v,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),t.customerName]}),e.jsxs("p",{className:"text-xs text-slate-500 mt-0.5",children:["#",t.orderNumber," · ",t.dateCT||"â"," · ",R(t.t
2ireQty)," tires"]}),t.isChallengeReward&&e.jsxs("span",{className:"inline-flex items-center gap-1 mt-1 rounded-full bg-amber-100 text-amber-700 px-2 py-0.5 text-[10px] font-bold",children:[e.jsx(v,{className:"w-2.5 h-2.5"}),t.challengeStatus==="reserved"?"100% Commission Reserved":"100% Commission Order"]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-lg font-black tabular-nums",children:e.jsx(Z,{row:t})}),e.jsx(X,{status:t.status})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-slate-100",children:[e.jsxs("div",{className:"flex gap-4 text-xs",children:[e.jsxs("span",{className:"text-slate-500",children:["Rev ",e.jsx("b",{className:"text-slate-900 tabular-nums",children:b(t.revenue)})]}),e.jsxs("span",{className:"text-slate-500",children:[n?"GP":"Cost"," ",e.jsx("b",{className:"text-slate-900 tabular-nums",children:b(n?t.salesGrossProfit:t.salesRepCost)})]})]}),o===t.id?e.jsx(pe,{className:"w-4 h-4 text-slate-400"}):e.jsx(ge,{className:"w-4 h-4 text-slate-400"})]})]}),o===t.id&&e.jsx(Q,{row:t,canViewGP:n})]},t.id))}),a&&a.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-t border-slate-200 bg-slate-50/50",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Page ",a.page," of ",a.totalPages," · ",R(a.total)," orders"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>r(a.page-1),disabled:a.page<=1,className:"inline-flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-white",children:[e.jsx(fe,{className:"w-3.5 h-3.5"})," Prev"]}),e.jsxs("button",{onClick:()=>r(a.page+1),disabled:a.page>=a.totalPages,className:"inline-flex items-center gap-1 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 disabled:opacity-40 disabled:cursor-not-allowed hover:bg-white",children:["Next ",e.jsx(je,{className:"w-3.5 h-3.5"})]})]})]})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx(he,{className:"w-10 h-10 mx-auto mb-3 text-slate-300"}),e.jsx("p",{className:"text-sm text-slate-500",children:"No orders in this period."})]})]})}const Pe=l.lazy(()=>S(()=>import("./WeeklyManagerBonusAudit-bxHO-G3Y.js").then(s=>s.a),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),Ee=l.lazy(()=>S(()=>import("./ChallengeHero-Ba_dbTZs.js"),__vite__mapDeps([14,1,2,15,16,17,10,8,18,19,20,21,22,23,7,24,25,26,27,11,28,29,30,12,31,32,33,34,35,36,37,38,39]))),Te=l.lazy(()=>S(()=>import("./HowItWorksModal-Dtohef03.js"),__vite__mapDeps([40,1,2,41,42,43,44,45,46,47,48,49,50,51,52,8,53,54,55,9,26,10,56,57]))),Fe=l.lazy(()=>S(()=>import("./CommissionsLifetime-Dxyh0-3o.js"),__vite__mapDeps([58,1,2,59,8,26,60,18,10,61,62,63,49,64,65,29,30,12,31,32,33,34,35,22,23,36,27,37,28,38,21,11,39]))),Le=l.lazy(()=>S(()=>import("./TeamChallengeProgress-BJGZtp8p.js"),__vite__mapDeps([66,1,2,67,8,10,30,11,28,68]))),$e=l.lazy(()=>S(()=>import("./TeamChallengeCelebration-BC-fii3H.js"),__vite__mapDeps([69,1,2,15,10,8,20,67,30,60,70,71]))),Ae=[{value:"thisWeek",label:"This Week"},{value:"thisMonth",label:"This Month"},{value:"last30Days",label:"Last 30 Days"},{value:"all",label:"Lifetime"}],F={summary:{earnedCommission:0,estimatedCommission:0,salesGrossProfit:0,revenue:0,tiresSold:0,completedOrders:0,avgGpPerOrder:0},lifetime:{revenue:0,salesGrossProfit:0,tiresSold:0,orders:0,earnedCommission:0,avgGpPerOrder:0},weeklyTrend:[],currentWeek:{gp:0,commission:0,tires:0,orders:0},previousWeek:{gp:0,commission:0,tires:0,orders:0},orders:[],pagination:{page:1,pageSize:10,total:0,totalPages:1}};function De(){var W,G,z,M,U,H;const[s,a]=l.useState(null),{user:r,isAuthenticated:n,isLoadingAuth:o,isLoadingPublicSettings:i,authError:h}=ie(),[y,t]=l.useState(!1),[m,N]=l.useState(!1),[C,u]=l.useState(!1),[w,te]=l.useState("thisMonth"),[$,A]=l.useState(1),[ae,le]=l.useState(0),[D,O]=l.useState(!1),k=l.useRef(0),E=l.useRef(null),T=l.useRef(!1),re=ne(),_=(()=>{try{return new URLSearchParams(re.search).get("sellerId")||void 0}catch{return}})(),c=n&&!o&&!i&&!h&&(r!=null&&r.id||r!=null&&r.email)?JSON.stringify([r.id||"",r.email||"",r.role||"",w,_||""]):null,P=l.useRef(c);P.current=c;const j=c&&(s==null?void 0:s.scope)===c?s.data:null;E.current=j;const I=l.useCallback(async()=>{var V;if(!c)return;const p=++k.current;u(!0);try{const g=await ve(oe.functions.invoke("loadSellerCommissionsV3",{dateRange:w,page:$,pageSize:10,fresh:T.current,..._?{sellerId:_}:{}}),"Your commissions took too long to load. Please retry.");if(p!==k.current||P.current!==c)return;const x=g==null?void 0:g.data;if(x&&x.status==="rate_limited"){me.error("Refreshing shortly â showing your latest data.");return}if(x&&x.error==="No selling capability"){t(!0);return}if(x&&x.error)throw new Error(x.error);t(!1),N(!1),E.current=x||F,a({scope:c,data:x||F})}catch(g){if(p!==k.current||P.current!==c)return;const x=((V=g==null?void 0:g.response)==null?void 0:V.status)||(g==null?void 0:g.status);a(null),E.current=null,x===401||x===403?t(!0):N(!0)}finally{p===k.current&&P.current===c&&(T.current=!1,u(!1))}},[w,$,ae,_,c]);l.useEffect(()=>(k.current+=1,t(!1),N(!1),c?I():(a(null),u(!1),!o&&!i&&t(!0)),()=>{k.current+=1}),[I,c,o,i]);const B=()=>{T.current=!0,le(p=>p+1)};if(!j&&!y&&!m)return e.jsx(Ne,{title:"100% Commission Challenge",subt
2itle:"Your commissions, challenge progress, and completed-order earnings.",label:"Loading your commissionsâ¦"});if(y)return e.jsx("div",{className:"min-h-screen bg-[#FAFBFC] flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center rounded-2xl bg-white border border-slate-200 p-8 max-w-md shadow-sm",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(Ce,{className:"w-7 h-7 text-slate-400"})}),e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"My Commissions"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Selling capability is required to view commissions. Your account is not enabled for selling."})]})});if(m)return e.jsx("div",{className:"min-h-screen bg-[#FAFBFC] flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center rounded-2xl bg-white border border-slate-200 p-8 max-w-md shadow-sm",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-amber-50 flex items-center justify-center mx-auto mb-4",children:e.jsx(ye,{className:"w-7 h-7 text-amber-500"})}),e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Couldn't load commissions"}),e.jsxs("button",{onClick:B,className:"mt-2 inline-flex items-center gap-2 rounded-lg bg-[#0073ea] text-white px-4 py-2 text-sm font-semibold hover:bg-[#0060b9]",children:[e.jsx(K,{className:"w-4 h-4"})," Try again"]})]})});const d=j||F;return e.jsxs("div",{className:"min-h-screen bg-[#FAFBFC]",children:[e.jsx(l.Suspense,{fallback:null,children:e.jsx($e,{sellerId:(W=d.seller)==null?void 0:W.id})}),C&&e.jsx("div",{className:"fixed top-0 left-0 right-0 h-1 z-50 bg-[#0073ea]/10 overflow-hidden",children:e.jsx("div",{className:"h-full w-1/3 bg-[#0073ea] animate-pulse"})}),e.jsxs("div",{className:"max-w-6xl mx-auto px-3 pb-24 pt-4 sm:px-4 sm:py-6 lg:px-8 lg:py-10",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 mb-5 sm:mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-gradient-to-br from-[#FDB813] to-[#F68B1E] flex items-center justify-center shadow-sm",children:e.jsx(v,{className:"w-5 h-5 text-[#111111]"})}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-[#F68B1E]",children:"Reward Program"})]}),e.jsx("h1",{className:"text-2xl leading-tight sm:text-4xl font-black tracking-tight text-slate-900",children:"100% Commission Challenge"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"Win. Unlock. Earn 100% commission up to $1,000 on one eligible order."}),e.jsxs("button",{onClick:()=>O(!0),className:"mt-3 inline-flex min-h-11 w-full sm:w-auto items-center justify-center gap-2 rounded-xl sm:rounded-full bg-[#FDB813]/12 border border-[#F68B1E]/45 px-4 py-2 text-sm font-semibold text-[#0F172A] shadow-sm transition-all hover:-translate-y-0.5 hover:bg-[#FDB813]/20 hover:shadow-[0_10px_28px_-8px_rgba(246,139,30,0.55)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#F68B1E]/40",children:[e.jsx(we,{className:"w-4 h-4 text-[#F68B1E]"}),"See How to Unlock 100%"]})]}),e.jsxs("div",{className:"flex w-full sm:w-auto items-center gap-2",children:[e.jsx("div",{className:"flex min-w-0 flex-1 sm:flex-none items-center gap-1 overflow-x-auto rounded-xl bg-white border border-slate-200 p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:Ae.map(p=>e.jsx("button",{onClick:()=>{A(1),te(p.value)},className:`min-h-10 shrink-0 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${w===p.value?"bg-[#0073ea] text-white shadow-sm":"text-slate-600 hover:bg-slate-50"}`,children:p.label},p.value))}),e.jsx("button",{onClick:B,disabled:C,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-white border border-slate-200 text-sm font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",title:"Refresh",children:e.jsx(K,{className:`w-4 h-4 ${C?"th-inline-spinner":""}`})})]})]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"th-loading-skeleton h-36 rounded-2xl"}),children:e.jsx(Ee,{sellerId:(G=j==null?void 0:j.seller)==null?void 0:G.id,sellerEmail:(z=j==null?void 0:j.seller)==null?void 0:z.email})}),e.jsx(ke,{summary:d.summary,refreshing:C,canViewGP:!!d.can_view_gp}),e.jsx(Se,{summary:d.summary,canViewGP:!!d.can_view_gp}),((M=d.weeklyManagerBonusAudit)==null?void 0:M.readState)==="unavailable"&&e.jsx("div",{role:"status",className:"rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-950",children:"Weekly bonus records are unavailable. Order commissions are shown separately."}),!!((U=d.weeklyManagerBonusWeeks)!=null&&U.length)&&e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"th-loading-skeleton h-36 rounded-xl"}),children:e.jsx(Pe,{weeks:d.weeklyManagerBonusWeeks,managerId:(H=d.seller)==null?void 0:H.id})}),e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"th-loading-skeleton h-64 roun
2ded-2xl"}),children:e.jsx(Fe,{lifetime:d.lifetime,weeklyTrend:d.weeklyTrend,currentWeek:d.currentWeek,previousWeek:d.previousWeek,canViewGP:!!d.can_view_gp})}),e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"th-loading-skeleton h-32 rounded-2xl"}),children:e.jsx(Le,{})}),e.jsx(_e,{orders:d.orders,pagination:d.pagination,onPageChange:A,canViewGP:!!d.can_view_gp})]}),e.jsx("p",{className:"px-2 text-center text-xs leading-relaxed text-slate-400 mt-6 sm:mt-8",children:"Commission is calculated from the authoritative sales margin · Earned when the order reaches Completed"})]}),D&&e.jsx(l.Suspense,{fallback:null,children:e.jsx(Te,{open:D,onClose:()=>O(!1)})})]})}const ns=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"}));export{ns as S,f as a,is as d,b as m,R as n};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.