@kodiak-finance/orderly-affiliate 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,96 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, FC, PropsWithChildren } from 'react';
4
+ import { RefferalAPI } from '@kodiak-finance/orderly-hooks';
5
+
6
+ declare const DashboardPage: (props: {
7
+ classNames?: {
8
+ root?: string;
9
+ loadding?: string;
10
+ home?: string;
11
+ dashboard?: string;
12
+ };
13
+ }) => react_jsx_runtime.JSX.Element;
14
+
15
+ declare const HomePage: () => react_jsx_runtime.JSX.Element;
16
+
17
+ declare const AffiliatePage: () => react_jsx_runtime.JSX.Element;
18
+
19
+ declare const TraderPage: () => react_jsx_runtime.JSX.Element;
20
+
21
+ declare const index_AffiliatePage: typeof AffiliatePage;
22
+ declare const index_DashboardPage: typeof DashboardPage;
23
+ declare const index_HomePage: typeof HomePage;
24
+ declare const index_TraderPage: typeof TraderPage;
25
+ declare namespace index {
26
+ export { index_AffiliatePage as AffiliatePage, index_DashboardPage as DashboardPage, index_HomePage as HomePage, index_TraderPage as TraderPage };
27
+ }
28
+
29
+ declare enum TabTypes {
30
+ affiliate = "affiliate",
31
+ trader = "trader"
32
+ }
33
+ type UserVolumeType = {
34
+ "1d_volume"?: number;
35
+ "7d_volume"?: number;
36
+ "30d_volume"?: number;
37
+ all_volume?: number;
38
+ };
39
+ type Overwrite = {
40
+ shortBrokerName?: string;
41
+ brokerName?: string;
42
+ ref?: {
43
+ top?: BuildNode;
44
+ card?: BuildNode;
45
+ step?: BuildNode;
46
+ };
47
+ };
48
+ type ChartConfig = {
49
+ affiliate: {
50
+ bar?: any;
51
+ yAxis?: any;
52
+ xAxis?: any;
53
+ };
54
+ trader: {
55
+ bar?: any;
56
+ yAxis?: any;
57
+ xAxis?: any;
58
+ };
59
+ };
60
+ type ReferralContextProps = {
61
+ onBecomeAnAffiliate?: () => void;
62
+ becomeAnAffiliateUrl?: string;
63
+ bindReferralCodeState?: (success: boolean, error: any, hide: any, queryParams: any) => void;
64
+ onLearnAffiliate?: () => void;
65
+ learnAffiliateUrl?: string;
66
+ referralLinkUrl: string;
67
+ showReferralPage?: () => void;
68
+ showDashboard?: () => void;
69
+ chartConfig?: ChartConfig;
70
+ overwrite?: Overwrite;
71
+ splashPage?: () => ReactNode;
72
+ };
73
+ type ReferralContextReturns = {
74
+ referralInfo?: RefferalAPI.ReferralInfo;
75
+ isAffiliate: boolean;
76
+ isTrader: boolean;
77
+ mutate: any;
78
+ userVolume?: UserVolumeType;
79
+ dailyVolume?: RefferalAPI.DayliVolume[];
80
+ isLoading: boolean;
81
+ showHome: boolean;
82
+ setShowHome: (value: boolean) => void;
83
+ tab: TabTypes;
84
+ setTab: React.Dispatch<React.SetStateAction<TabTypes>>;
85
+ wrongNetwork: boolean;
86
+ disabledConnect: boolean;
87
+ generateCode: RefferalAPI.AutoGenerateCode | undefined;
88
+ } & ReferralContextProps;
89
+ declare const ReferralContext: react.Context<ReferralContextReturns>;
90
+ type BuildNode = (state: ReferralContextReturns) => ReactNode;
91
+ declare const ReferralProvider: FC<PropsWithChildren<ReferralContextProps>>;
92
+ declare const useReferralContext: () => ReferralContextReturns;
93
+
94
+ declare const AffiliateLayoutWidget: (props: PropsWithChildren) => react_jsx_runtime.JSX.Element;
95
+
96
+ export { AffiliateLayoutWidget, type BuildNode, type ChartConfig, index as Dashboard, type Overwrite, ReferralContext, type ReferralContextProps, type ReferralContextReturns, ReferralProvider, TabTypes, type UserVolumeType, useReferralContext };
@@ -0,0 +1,96 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, FC, PropsWithChildren } from 'react';
4
+ import { RefferalAPI } from '@kodiak-finance/orderly-hooks';
5
+
6
+ declare const DashboardPage: (props: {
7
+ classNames?: {
8
+ root?: string;
9
+ loadding?: string;
10
+ home?: string;
11
+ dashboard?: string;
12
+ };
13
+ }) => react_jsx_runtime.JSX.Element;
14
+
15
+ declare const HomePage: () => react_jsx_runtime.JSX.Element;
16
+
17
+ declare const AffiliatePage: () => react_jsx_runtime.JSX.Element;
18
+
19
+ declare const TraderPage: () => react_jsx_runtime.JSX.Element;
20
+
21
+ declare const index_AffiliatePage: typeof AffiliatePage;
22
+ declare const index_DashboardPage: typeof DashboardPage;
23
+ declare const index_HomePage: typeof HomePage;
24
+ declare const index_TraderPage: typeof TraderPage;
25
+ declare namespace index {
26
+ export { index_AffiliatePage as AffiliatePage, index_DashboardPage as DashboardPage, index_HomePage as HomePage, index_TraderPage as TraderPage };
27
+ }
28
+
29
+ declare enum TabTypes {
30
+ affiliate = "affiliate",
31
+ trader = "trader"
32
+ }
33
+ type UserVolumeType = {
34
+ "1d_volume"?: number;
35
+ "7d_volume"?: number;
36
+ "30d_volume"?: number;
37
+ all_volume?: number;
38
+ };
39
+ type Overwrite = {
40
+ shortBrokerName?: string;
41
+ brokerName?: string;
42
+ ref?: {
43
+ top?: BuildNode;
44
+ card?: BuildNode;
45
+ step?: BuildNode;
46
+ };
47
+ };
48
+ type ChartConfig = {
49
+ affiliate: {
50
+ bar?: any;
51
+ yAxis?: any;
52
+ xAxis?: any;
53
+ };
54
+ trader: {
55
+ bar?: any;
56
+ yAxis?: any;
57
+ xAxis?: any;
58
+ };
59
+ };
60
+ type ReferralContextProps = {
61
+ onBecomeAnAffiliate?: () => void;
62
+ becomeAnAffiliateUrl?: string;
63
+ bindReferralCodeState?: (success: boolean, error: any, hide: any, queryParams: any) => void;
64
+ onLearnAffiliate?: () => void;
65
+ learnAffiliateUrl?: string;
66
+ referralLinkUrl: string;
67
+ showReferralPage?: () => void;
68
+ showDashboard?: () => void;
69
+ chartConfig?: ChartConfig;
70
+ overwrite?: Overwrite;
71
+ splashPage?: () => ReactNode;
72
+ };
73
+ type ReferralContextReturns = {
74
+ referralInfo?: RefferalAPI.ReferralInfo;
75
+ isAffiliate: boolean;
76
+ isTrader: boolean;
77
+ mutate: any;
78
+ userVolume?: UserVolumeType;
79
+ dailyVolume?: RefferalAPI.DayliVolume[];
80
+ isLoading: boolean;
81
+ showHome: boolean;
82
+ setShowHome: (value: boolean) => void;
83
+ tab: TabTypes;
84
+ setTab: React.Dispatch<React.SetStateAction<TabTypes>>;
85
+ wrongNetwork: boolean;
86
+ disabledConnect: boolean;
87
+ generateCode: RefferalAPI.AutoGenerateCode | undefined;
88
+ } & ReferralContextProps;
89
+ declare const ReferralContext: react.Context<ReferralContextReturns>;
90
+ type BuildNode = (state: ReferralContextReturns) => ReactNode;
91
+ declare const ReferralProvider: FC<PropsWithChildren<ReferralContextProps>>;
92
+ declare const useReferralContext: () => ReferralContextReturns;
93
+
94
+ declare const AffiliateLayoutWidget: (props: PropsWithChildren) => react_jsx_runtime.JSX.Element;
95
+
96
+ export { AffiliateLayoutWidget, type BuildNode, type ChartConfig, index as Dashboard, type Overwrite, ReferralContext, type ReferralContextProps, type ReferralContextReturns, ReferralProvider, TabTypes, type UserVolumeType, useReferralContext };
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var orderlyUi = require('@kodiak-finance/orderly-ui');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var orderlyUtils = require('@kodiak-finance/orderly-utils');
6
+ var orderlyI18n = require('@kodiak-finance/orderly-i18n');
7
+ var react = require('react');
8
+ var dateFns = require('date-fns');
9
+ var orderlyHooks = require('@kodiak-finance/orderly-hooks');
10
+ var orderlyReactApp = require('@kodiak-finance/orderly-react-app');
11
+ var orderlyTypes = require('@kodiak-finance/orderly-types');
12
+ var orderlyChart = require('@kodiak-finance/orderly-chart');
13
+ var orderlyUiConnector = require('@kodiak-finance/orderly-ui-connector');
14
+ var orderlyUiScaffold = require('@kodiak-finance/orderly-ui-scaffold');
15
+
16
+ var gi=Object.defineProperty;var hi=(e,t)=>{for(var r in t)gi(e,r,{get:t[r],enumerable:true});};var si={};hi(si,{AffiliatePage:()=>_e,DashboardPage:()=>li,HomePage:()=>ve,TraderPage:()=>Le});var mt=e=>{let{size:t=16,className:r,...a}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".98",xmlns:"http://www.w3.org/2000/svg",className:e.className,...a,children:[jsxRuntime.jsx("path",{d:"M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97"}),jsxRuntime.jsx("path",{d:"M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386"})]})};var dt=e=>{let{size:t=16,className:r,...a}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.36",xmlns:"http://www.w3.org/2000/svg",className:e.className,...a,children:[jsxRuntime.jsx("path",{d:"M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z"}),jsxRuntime.jsx("path",{d:"M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",fill:"white",fillOpacity:"0.98"})]})};var J=e=>jsxRuntime.jsxs("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:[jsxRuntime.jsxs("g",{clipPath:"url(#a)",children:[jsxRuntime.jsx("path",{d:"M10.5 20c5.542 0 10-4.458 10-10s-4.458-10-10-10S.5 4.458.5 10s4.458 10 10 10",fill:"#2775CA"}),jsxRuntime.jsx("path",{d:"M13.5 11.473c0-1.452-.94-1.95-2.82-2.158-1.344-.166-1.613-.498-1.613-1.078s.448-.955 1.343-.955c.806 0 1.254.25 1.478.872.045.124.18.207.313.207h.717c.179 0 .313-.125.313-.29v-.042c-.179-.913-.985-1.618-2.015-1.701v-.996c0-.166-.134-.29-.358-.332h-.671c-.18 0-.314.124-.359.332v.954c-1.343.166-2.194.996-2.194 2.034 0 1.369.896 1.908 2.776 2.116 1.254.207 1.657.456 1.657 1.12s-.627 1.12-1.477 1.12c-1.165 0-1.568-.456-1.702-1.078a.32.32 0 0 0-.313-.25h-.762c-.179 0-.313.125-.313.291v.042c.179 1.037.895 1.784 2.373 1.991v.996c0 .166.134.29.358.332h.672c.18 0 .313-.124.358-.332v-.996c1.344-.207 2.239-1.079 2.239-2.199",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{d:"M8.24 16.57c-3.458-1.215-5.23-4.986-3.945-8.324.665-1.821 2.127-3.208 3.944-3.859.178-.086.266-.216.266-.433v-.607c0-.174-.088-.304-.266-.347-.044 0-.133 0-.177.043-4.21 1.3-6.516 5.68-5.186 9.798.798 2.428 2.704 4.292 5.186 5.072.177.087.355 0 .4-.173.043-.043.043-.087.043-.173v-.608c0-.13-.133-.303-.266-.39m4.698-13.527c-.178-.086-.355 0-.4.174-.043.043-.043.086-.043.173v.607c0 .174.133.347.266.434 3.457 1.213 5.23 4.985 3.944 8.323-.664 1.821-2.127 3.209-3.944 3.859-.178.086-.266.216-.266.433v.607c0 .174.088.304.266.347.044 0 .133 0 .177-.043 4.21-1.3 6.515-5.68 5.186-9.798-.798-2.471-2.748-4.335-5.186-5.116",fill:"#fff",fillOpacity:".98"})]}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:"a",children:jsxRuntime.jsx("path",{fill:"#fff",d:"M.5 0h20v20H.5z"})})})]});var gt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(yi,{...e}),jsxRuntime.jsx(vi,{...e}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",gap:2,children:[jsxRuntime.jsx(xt,{title:`${t("affiliate.referralVol")} (USDC)`,value:e.referralVol,dp:2,...e}),jsxRuntime.jsx(xt,{title:t("affiliate.referees"),value:e.referees,dp:0,...e}),jsxRuntime.jsx(xt,{title:t("affiliate.summary.refereesTraded"),value:e.refereesTades,dp:0,...e})]})]})},yi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{className:"oui-min-w-14",children:jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},vi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gradient:"primary",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,height:"100%",className:"oui-max-h-[104px]",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.commission")} (USDC)`}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(J,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(e.commission,{fix:2,fallback:"0"})})]})]})},xt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:orderlyUtils.commifyOptional(e.value,{fix:e.dp,fallback:"0"})})]});var Ne=(r=>(r.affiliate="affiliate",r.trader="trader",r))(Ne||{}),Vr=react.createContext({}),Ss=e=>{let{becomeAnAffiliateUrl:t="https://orderly.network/",learnAffiliateUrl:r="https://orderly.network/",referralLinkUrl:a="https://orderly.network/",chartConfig:o,overwrite:n,children:i,splashPage:f,onBecomeAnAffiliate:s,bindReferralCodeState:x,onLearnAffiliate:m,showReferralPage:u}=e,{state:l}=orderlyHooks.useAccount(),{data:d,mutate:p,isLoading:c}=orderlyHooks.usePrivateQuery("/v1/referral/info",{revalidateOnFocus:true,errorRetryCount:3,...orderlyHooks.noCacheConfig}),{data:C,mutate:k}=orderlyHooks.usePrivateQuery("/v1/referral/auto_referral/progress",{revalidateOnFocus:true,errorRetryCount:2,formatter:O=>({code:O.auto_referral_code,requireVolume:O.required_volume,completedVolume:O.completed_volume})}),[ne,U]=react.useState(c);react.useEffect(()=>{U(true);},[c]);let{data:I,mutate:_}=orderlyHooks.useDaily({startDate:dateFns.subDays(new Date,1),endDate:dateFns.subDays(new Date,90)}),{data:A,mutate:B}=orderlyHooks.usePrivateQuery("/v1/volume/user/stats",{revalidateOnFocus:true}),ce=react.useMemo(()=>(d?.referrer_info?.referral_codes?.length||0)>0,[d?.referrer_info]),H=react.useMemo(()=>(d?.referee_info?.referer_code?.length||0)>0,[d?.referee_info]),K=react.useMemo(()=>{let O={};if(I&&I.length>0){let Be=dateFns.format(new Date,"yyyy-MM-dd"),_r=I.findIndex(pi=>pi.date===Be),Mr=0;_r!==-1&&(Mr=I[_r].perp_volume),O["1d_volume"]=Mr;}return A&&(O["7d_volume"]=A.perp_volume_last_7_days,O["30d_volume"]=A.perp_volume_last_30_days,O.all_volume=A.perp_volume_ltd),O},[I,A]);react.useEffect(()=>{(ce||H)&&U(false);},[ce,H]);let Ie=orderlyHooks.useMemoizedFn(()=>{B(),_(),p(),k();});react.useEffect(()=>{let Be=new URLSearchParams(window.location.search).get("ref");Be&&localStorage.setItem("referral_code",Be);},[]);let[Nr,di]=react.useState("affiliate"),{wrongNetwork:Ar,disabledConnect:Dr}=orderlyReactApp.useAppContext(),Fr=react.useRef(orderlyTypes.AccountStatusEnum.NotConnected),ft=react.useRef(null);react.useEffect(()=>(Fr.current!==l.status&&(Fr.current=l.status,ft.current=setTimeout(()=>{Ie();},1e3)),()=>{ft.current&&clearTimeout(ft.current);}),[Ie,l.status]);let xi=react.useMemo(()=>({generateCode:C,showHome:ne,referralInfo:d,isAffiliate:ce,isTrader:H,tab:Nr,becomeAnAffiliateUrl:t,learnAffiliateUrl:r,referralLinkUrl:a,userVolume:K,dailyVolume:I,chartConfig:o,overwrite:n,isLoading:c,wrongNetwork:Ar,disabledConnect:Dr,setShowHome:U,setTab:di,mutate:Ie,onBecomeAnAffiliate:s,bindReferralCodeState:x,onLearnAffiliate:m,showReferralPage:u,splashPage:f}),[t,o,I,d,Dr,C,ce,c,H,r,n,a,ne,Nr,K,Ar,s,x,m,u,f,Ie]);return jsxRuntime.jsx(Vr.Provider,{value:xi,children:i})},y=()=>react.useContext(Vr);var bt=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("All"),a=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o}=y(),n=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referrer_rebate;case "1D":return o.referrer_info["1d_referrer_rebate"];case "7D":return o.referrer_info["7d_referrer_rebate"];case "30D":return o.referrer_info["30d_referrer_rebate"]}},[o,t]),i=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referee_volume;case "1D":return o.referrer_info["1d_referee_volume"];case "7D":return o.referrer_info["7d_referee_volume"];case "30D":return o.referrer_info["30d_referee_volume"]}},[o,t]),f=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_invites;case "1D":return o.referrer_info["1d_invites"];case "7D":return o.referrer_info["7d_invites"];case "30D":return o.referrer_info["30d_invites"]}},[o,t]),s=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_traded;case "1D":return o.referrer_info["1d_traded"];case "7D":return o.referrer_info["7d_traded"];case "30D":return o.referrer_info["30d_traded"]}},[o,t]);return {period:t,periodTypes:a,onPeriodChange:m=>{r(m);},commission:n,referralVol:i,referees:f,refereesTades:s}};var Ee=()=>{let e=bt();return jsxRuntime.jsx(gt,{...e})};var Or=e=>{let{text:t,visibleCount:r}=e,a=react.useRef(null),o=react.useRef(null),n=react.useRef(void 0);function i(m,u){let d=document.createElement("canvas").getContext("2d"),p=m;if(d&&p){let c=getComputedStyle(p).font;return c.length===0&&(c=[getComputedStyle(p).fontWeight,getComputedStyle(p).fontSize,getComputedStyle(p).fontFamily].join(" ")),d.font=c,d.letterSpacing=getComputedStyle(p).letterSpacing,d.measureText(u).width}}let[f,s]=react.useState(0);react.useEffect(()=>{let m=()=>{if(e.visibleCount===void 0&&a.current&&o.current){let u=a.current.clientWidth;if(u==n.current)return;n.current=u;let l=o.current,d=t,p=Math.ceil(i(l,"...")||0),c=u-p,C=0;for(;C<t.length&&!((i(l,Oi(t,C++))||c)<=c););s(d.length-C);}};return n.current=void 0,m(),window.addEventListener("resize",m),()=>{n.current=void 0,window.removeEventListener("resize",m);}},[t,o]);let x=react.useMemo(()=>{if(f+1>=t.length)return t;let m=r||f,u=t.slice(0,Math.ceil(m/2)),l=t.slice(t.length-Math.floor(m/2),t.length);return `${u}...${l}`},[t,r,f]);return jsxRuntime.jsxs("div",{ref:a,className:orderlyUi.cn("oui-relative oui-w-full oui-text-end",e.className),children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-hidden oui-whitespace-nowrap oui-absolute oui-top-0 oui-bottom-0 oui-right-0 oui-left-0"),children:jsxRuntime.jsx("span",{ref:o,children:t})}),jsxRuntime.jsx("span",{children:x})]})},Oi=(e,t)=>{let r=Math.floor(e.length/2-(t>0?t/2:1)),a=e.slice(0,r),o=e.slice(r+t);return a+o};var vt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-referralLink",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(qi,{...e}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",className:"oui-flex oui-flex-col 3xl:oui-flex-row",gap:4,children:[jsxRuntime.jsx("div",{className:"oui-w-full 3xl:oui-w-1/3",children:jsxRuntime.jsx(Zi,{...e})}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",className:"3xl:oui-w-2/3 3xl:oui-gap-2",children:[jsxRuntime.jsx(Er,{title:t("affiliate.referralCode"),value:e.refCode,...e}),jsxRuntime.jsx(Er,{title:t("affiliate.referralLink"),value:e.refLink,...e})]})]})]})},qi=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.referralLink")})})},Zi=e=>{let{t}=orderlyI18n.useTranslation(),r=(a,o,n,i,f)=>{let s="oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl";return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:i,children:[jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",gap:2,children:jsxRuntime.jsx(Qi,{title:a,tooltip:f})}),n?jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",className:s,children:o}):jsxRuntime.jsx(orderlyUi.Text,{className:s,children:o})]})};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[r(t("affiliate.referralLink.earn"),e.earn||"-",true,"oui-flex-1",jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",children:e.earn||"-"})," ",t("affiliate.referralLink.earn.tooltip",{brokerName:e.brokerName})]})),r(t("affiliate.referralLink.share"),e.share||"-",false,"oui-flex-1",jsxRuntime.jsx(orderlyI18n.Trans,{i18nKey:"affiliate.referralLink.share.tooltip",values:{value:e.share||"-",brokerName:e.brokerName},components:[jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand"})]}))]})},Er=e=>{let{title:t,value:r="-"}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{r:"xl",p:3,gap:4,direction:"row",width:"100%",className:"oui-bg-base-8",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-54 oui-flex-shrink oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:t}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"end",gap:2,className:"oui-flex-1 oui-text-xs md:oui-text-sm xl:oui-text-base",children:[jsxRuntime.jsx(Or,{text:r}),jsxRuntime.jsx("button",{className:"oui-cursor-pointer oui-text-sm oui-flex-shrink",onClick:()=>{navigator.clipboard.writeText(r),e.onCopy?.(r);},children:jsxRuntime.jsx(orderlyUi.CopyIcon,{size:12,color:"white",className:"oui-w-[13px] oui-h-[13px] md:oui-w-[14px] md:oui-h-[14px] xl:oui-w-4 xl:oui-h-4"})})]})]})},Qi=e=>jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.tooltip,className:"oui-max-w-[200px]",children:jsxRuntime.jsx("div",{onClick:()=>{orderlyUi.modal.alert({title:e.title,message:jsxRuntime.jsx("div",{className:"oui-text-base-contrast/30 oui-space-y-3 oui-text-xs desktop:oui-text-xs",children:e.tooltip})});},children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full",lineStyle:"dotted",intensity:16})]})})});function ze(e,t,r){try{let a=new URL(e),o=new URLSearchParams(a.search);return o.set(t,r),a.search=o.toString(),a.toString()}catch{return e}}async function Rt(e){try{await navigator.clipboard.writeText(e),orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.copied"));}catch{orderlyUi.toast.success(orderlyI18n.i18n.t("common.copy.failed"));}}function Gr(e){if(e===void 0)return "";let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd HH:mm:ss 'UTC'")}function qr(e){if(e===void 0)return;let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd")}function Zr(e,t){return e&&t&&e.toISOString().substring(0,10)===t.toISOString().substring(0,10)}function Qr(e){return new Date(e.toUTCString())}var Tt=()=>{let{t:e}=orderlyI18n.useTranslation(),t=d=>{orderlyUi.toast.success(e("common.copy.copied"));},{referralInfo:r,referralLinkUrl:a,overwrite:o}=y(),[n,i]=orderlyHooks.useLocalStorage("orderly_referral_codes",[]),f=react.useMemo(()=>{if(!r?.referrer_info?.referral_codes)return [];let d=[...r?.referrer_info?.referral_codes],p=[];for(let c=0;c<n.length;c++){let C=n[c],k=d.findIndex(ne=>ne.code===C);k!==-1&&(p.push({...d[k]}),d.splice(k,1));}return [...p,...d]},[r?.referrer_info?.referral_codes,n]),s=react.useMemo(()=>{if(f.length!==0)return f[0]},[f]),x=react.useMemo(()=>s?.code,[s]),m=react.useMemo(()=>s?ze(a,"ref",s.code):"",[s]),u=react.useMemo(()=>`${new orderlyUtils.Decimal(s?.referrer_rebate_rate||"0").mul(100).toDecimalPlaces(0,orderlyUtils.Decimal.ROUND_DOWN).toString()}%`,[s?.referrer_rebate_rate]),l=react.useMemo(()=>`${new orderlyUtils.Decimal(s?.referee_rebate_rate||"0").mul(100).toDecimalPlaces(0,orderlyUtils.Decimal.ROUND_DOWN).toString()}%`,[s?.referee_rebate_rate]);return {onCopy:t,refLink:m,refCode:x,share:l,earn:u,brokerName:o?.brokerName??o?.shortBrokerName}};var He=()=>{let e=Tt();return jsxRuntime.jsx(vt,{...e})};var Nt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(ia,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{className:"oui-h-[170px] 2xl:oui-h-[196px] oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(orderlyChart.VolBarChart,{data:e.dataSource||orderlyTypes.EMPTY_LIST,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:orderlyUtils.Decimal.ROUND_DOWN,dp:e.volType==="Commission"?6:2}})})]}),ia=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};function Ge(e,t){let r=Date(),a=new Array(e).fill(0).map((n,i)=>({date:dateFns.format(dateFns.subDays(r,i+1),"yyyy-MM-dd"),volume:0,opacity:0})).reverse(),o=t?.reduce((n,i)=>(n[i.date]=i,n),{});for(let n=0;n<a.length;n++){let i=a[n],f=o?.[i.date];f&&(a[n]={...f,opacity:f.volume>0?1:0});}return a}var At=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("7"),a=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=l=>{r(l);},[n,i]=react.useState("Commission"),f=[{label:e("affiliate.commission"),value:"Commission"},{label:e("affiliate.referralVol"),value:"ref"}],s=l=>{i(l);},x=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),[m]=orderlyHooks.useReferralRebateSummary({startDate:dateFns.format(x.startDate,"yyyy-MM-dd"),endDate:dateFns.format(x.endDate,"yyyy-MM-dd"),size:Number(t)}),u=react.useMemo(()=>(m?.map(l=>({date:l.date,volume:n==="Commission"?l.referral_rebate:l.volume}))||[]).reverse(),[m,n]);return {period:t,periodTypes:a,onPeriodChange:o,volType:n,volTypes:f,onVolTypeChange:s,dataSource:Ge(Number(t),u)}};var qe=()=>{let e=At();return jsxRuntime.jsx(Nt,{...e})};var Ae=e=>{let{className:t,...r}=e;return jsxRuntime.jsx("svg",{width:"12",height:"13",viewBox:"0 0 12 13",xmlns:"http://www.w3.org/2000/svg",fill:"white",fillOpacity:"0.36",className:t,...r,children:jsxRuntime.jsx("path",{d:"M8.49773 1.47656C8.36523 1.47656 8.23223 1.52357 8.13823 1.61707C7.86023 1.89507 6.85973 2.89558 6.63773 3.11808L2.13523 7.62059L1.63473 8.12059C1.56523 8.19059 1.52923 8.28958 1.50973 8.38658L1.00973 10.8881C0.939727 11.2381 1.23773 11.5361 1.58773 11.4666C1.90073 11.4036 3.77673 11.0286 4.08923 10.9661C4.18623 10.9466 4.28523 10.9106 4.35523 10.8411L4.85523 10.3406L9.35773 5.83808C9.58023 5.61608 10.5807 4.61506 10.8587 4.33756C10.9522 4.24356 10.9992 4.11056 10.9992 3.97806C10.9992 3.15956 10.7907 2.57456 10.3582 2.13306C9.92173 1.68756 9.33873 1.47656 8.49773 1.47656ZM8.69473 2.48606C9.14623 2.51256 9.43873 2.61608 9.63923 2.82108C9.84423 3.03008 9.97373 3.32008 10.0017 3.76258C9.72773 4.03608 9.32673 4.43106 8.99823 4.75956C8.60173 4.36306 8.11273 3.87407 7.71623 3.47757C8.04523 3.14907 8.42123 2.75956 8.69473 2.48606ZM6.99723 4.19657L8.27923 5.47858L4.49573 9.26207L3.21373 7.98009L6.99723 4.19657ZM2.49473 8.69908L3.77673 9.98107L3.72973 10.0281C3.39973 10.0941 2.73323 10.2336 2.11923 10.3566L2.44773 8.74608L2.49473 8.69908Z"})})};var to=e=>jsxRuntime.jsx("button",{children:jsxRuntime.jsx(Ae,{className:" oui-mt-px oui-cursor-pointer oui-fill-base-contrast-36 hover:oui-fill-base-contrast-80",fillOpacity:1,fill:"currentColor",onClick:e.onClick})});var Dt=e=>jsxRuntime.jsx("button",{onClick:t=>{e?.onClick?.(!e.pinned);},children:e.pinned===false?jsxRuntime.jsx(ma,{size:e.size,fillOpacity:1,className:"orderly-fill-primary-darken hover:orderly-fill-primary-darken/80"}):jsxRuntime.jsx(ua,{size:e.size,fillOpacity:1,className:"orderly-fill-base-contrast-36 hover:orderly-fill-base-contrast"})}),ua=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#608CFF",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208"})})},ma=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".36",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.108.507.507.94 1.13 1.119 1.944-.636.61-1.026.659-1.662.324a.67.67 0 0 0-.779.116c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.293-.076 1.774-.48 2.207-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.514 2.226-.514 1.742.001 2.668-.447 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.685-.29-1.046.321-1.67"})})};var _t=e=>{let t=orderlyHooks.useMediaQuery("(max-width: 767px)");return jsxRuntime.jsxs(orderlyUi.Flex,{r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-h-full oui-bg-base-9 oui-p-6 oui-tabular-nums",children:[jsxRuntime.jsx(ba,{...e}),jsxRuntime.jsxs("div",{className:"oui-flex oui-w-full oui-flex-col 2xl:oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Divider,{}),t?jsxRuntime.jsx(Ca,{...e}):jsxRuntime.jsx(ya,{...e})]})]})},ba=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.referralCodes")}),jsxRuntime.jsxs("div",{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-54",children:`${t("affiliate.referralCodes.remaining")}: `}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-primary-light",children:e.codes?.length||"--"})]})]})},Ca=e=>jsxRuntime.jsx(orderlyUi.ListView,{dataSource:e.codes,className:"oui-max-h-[240px] oui-w-full",renderItem:(t,r)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",children:[jsxRuntime.jsx(wa,{data:t,editRate:e.editRate,copyLink:e.copyLink,copyCode:e.copyCode,setPinCode:e.setPinCode,editCode:e.editCode},r),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mt-3 oui-w-full"})]})}),De=e=>{let{title:t,copyable:r,value:a,align:o,className:n,editRate:i,onCopy:f}=e;return jsxRuntime.jsx(orderlyUi.Statistic,{id:"oui-affiliate-affiliate-referralCodes",className:orderlyUi.cn("oui-flex-1",n),label:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-36",children:t}),align:o,children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(orderlyUi.Text.formatted,{copyable:r,onCopy:()=>{f?.();},className:"oui-mt-[6px] oui-text-sm oui-text-base-contrast-80",children:a}),i&&jsxRuntime.jsx(Ae,{className:"oui-mt-px oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:()=>i()})]})})},wa=e=>{let{data:t,setPinCode:r,copyLink:a,editRate:o,editCode:n}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gap:3,direction:"column",className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(De,{title:i("affiliate.referralCode"),value:t.code,copyable:true,onCopy:()=>{e.copyCode?.(t.code);},editRate:()=>{n(t);}}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.you&Referee"),value:ao(t),align:"end",editRate:()=>{o(t);}}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.referees&Traders"),value:Ce(t),align:"end",className:"oui-hidden md:oui-flex"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",className:"md:oui-hidden",children:[jsxRuntime.jsx(De,{title:i("affiliate.referees"),value:Ce(t).split("/")?.[0],align:"start"}),jsxRuntime.jsx(De,{title:i("affiliate.referralCodes.column.traders"),value:Ce(t).split("/")?.[1],align:"end"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(Dt,{pinned:t.isPined||false,onClick:f=>{r(t.code,!f);}}),jsxRuntime.jsx(orderlyUi.Button,{variant:"outlined",size:"xs",className:"oui-px-[20px]",onClick:f=>{a(t.code);},children:i("affiliate.referralCodes.copyLink")})]})]},t.code)},ya=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(min-width: 1024px)"),a=react.useMemo(()=>{let o=[{title:t("affiliate.referralCode"),dataIndex:"code",width:r?115:120,className:"!oui-px-0",render:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"center",gap:1,children:[jsxRuntime.jsx(Dt,{size:12,pinned:i.isPined||false,onClick:f=>{e.setPinCode(i.code,!f);}}),jsxRuntime.jsx(orderlyUi.Text.formatted,{suffix:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i.isAutoGenerated&&i.total_invites<1&&jsxRuntime.jsx(to,{onClick:()=>e.editCode?.(i)}),jsxRuntime.jsx(orderlyUi.CopyIcon,{className:"oui-cursor-pointer",size:12,color:"white",onClick:()=>e.copyCode?.(i.code)})]}),copyable:true,onCopy:()=>{e.copyCode?.(i.code);},children:n})]})},{title:t("affiliate.referralCodes.column.you&Referee"),dataIndex:"dffd",width:120,className:"oui-pr-0",render:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"center",gap:1,children:[ao(i),jsxRuntime.jsx(Ae,{className:"oui-mt-[6px] oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:f=>e.editRate?.(i)})]})}];return r?(o.push({title:t("affiliate.referees"),dataIndex:"referee_rebate_rate",width:65,className:"oui-pr-0",render:(n,i)=>Ce(i).split("/")[0]}),o.push({title:t("affiliate.referralCodes.column.traders"),dataIndex:"referrer_rebate_rate",width:65,className:"oui-pr-0",render:(n,i)=>Ce(i).split("/")[1]})):o.push({title:t("affiliate.referralCodes.column.referees&Traders"),dataIndex:"total_invites/total_traded",width:120,fixed:"left",render:(n,i)=>Ce(i)}),o.push({dataIndex:"link",align:"right",width:74,className:"!oui-px-0",render:(n,i)=>jsxRuntime.jsx(orderlyUi.Button,{variant:"outlined",size:"sm",className:"oui-px-5",onClick:f=>{e?.copyLink?.(i.code);},children:t("affiliate.referralCodes.copyLink")})}),o},[r,t]);return jsxRuntime.jsx(orderlyUi.DataTable,{bordered:true,columns:a,dataSource:e.codes,classNames:{header:"oui-px-0",root:"2xl:oui-flex-1 2xl:oui-max-h-[230px] 3xl:oui-max-h-[300px]"},onRow:o=>({className:"oui-h-[45px]"})})},ao=e=>{let t=new orderlyUtils.Decimal(e.referee_rebate_rate).mul(100).toFixed(1,orderlyUtils.Decimal.ROUND_DOWN).toString();return `${new orderlyUtils.Decimal(e.referrer_rebate_rate).mul(100).toFixed(1,orderlyUtils.Decimal.ROUND_DOWN).toString()}% / ${t}%`},Ce=e=>`${e.total_invites} / ${e.total_traded}`;var xo=orderlyUi.modal.create(e=>{let{t}=orderlyI18n.useTranslation(),{visible:r,onOpenChange:a}=orderlyUi.useModal(),[o,n]=react.useState(""),[i,f]=react.useState({length:false,format:false}),[s,{error:x,isMutating:m}]=orderlyHooks.useMutation("/v1/referral/edit_referral_code","POST");return react.useEffect(()=>{n(e.code.code);},[e.code]),react.useEffect(()=>{let u=o.toUpperCase(),l={length:false,format:false};(u.length<4||u.length>10)&&(l.length=true),/^[A-Z0-9]+$/.test(u)||(l.format=true),f(l);},[o]),jsxRuntime.jsxs(orderlyUi.SimpleDialog,{classNames:{content:"oui-max-w-[360px]"},title:jsxRuntime.jsx("div",{children:t("affiliate.referralCode.editCodeModal.title")}),open:r,onOpenChange:a,actions:{primary:{loading:m,disabled:i.length||i.format,label:t("common.confirm"),onClick:async()=>{try{let u=await s({current_referral_code:e.code.code,new_referral_code:o.toUpperCase()});if(u.success){orderlyUi.toast.success(t("affiliate.referralCode.editCodeModal.success")),e.successCallback(),a(!1);return}orderlyUi.toast.error(u.message);}catch{}}}},children:[jsxRuntime.jsx("div",{className:"oui-mb-6 oui-text-xs oui-text-base-contrast-54",children:t("affiliate.referralCode.editCodeModal.description")}),jsxRuntime.jsx(orderlyUi.TextField,{placeholder:"",fullWidth:true,label:t("affiliate.referralCode.editCodeModal.label"),onClean:()=>{n("");},value:o,onChange:u=>{let l=u.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");n(l);},formatters:[orderlyUi.inputFormatter.createRegexInputFormatter(u=>String(u).replace(/[a-z]/g,l=>l.toUpperCase())),orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],classNames:{label:"oui-text-base-contrast-54 oui-text-xs",input:"placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"},maxLength:10,minLength:4,autoComplete:"off",helpText:""}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"center",itemAlign:"start",gap:1,className:"oui-mt-3",children:[jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",i.length?"oui-text-danger":"oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.length")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs","oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.format")})]})]})});var wo=orderlyUi.modal.create(e=>{let{code:t,mutate:r}=e,{visible:a,hide:o,resolve:n,reject:i,onOpenChange:f}=orderlyUi.useModal(),s=new orderlyUtils.Decimal(t.max_rebate_rate).mul(100),[x,m]=react.useState(`${new orderlyUtils.Decimal(t.referee_rebate_rate).mul(100)}`),[u,l]=react.useState(`${new orderlyUtils.Decimal(t.referrer_rebate_rate).mul(100)}`),[d,p]=react.useState(false),c=react.useRef(null),{t:C}=orderlyI18n.useTranslation();react.useEffect(()=>{c?.current&&(c.current.focus(),c.current.setSelectionRange(c.current.value.length,c.current.value.length));},[c]),react.useEffect(()=>{m(`${new orderlyUtils.Decimal(t.referee_rebate_rate).mul(100)}`),l(`${new orderlyUtils.Decimal(t.referrer_rebate_rate).mul(100)}`);},[t]);let[k,{error:ne,isMutating:U}]=orderlyHooks.useMutation("/v1/referral/edit_split","POST"),I=async()=>{try{let _=Number.parseFloat(x),A=Number.parseFloat(u);await k({referral_code:t.code,referee_rebate_rate:_/100,referrer_rebate_rate:A/100}),orderlyUi.toast.success(C("affiliate.referralRate.editRateModal.success")),r(),o();}catch(_){orderlyUi.toast.error(_?.message||_||"");}};return jsxRuntime.jsx(orderlyUi.Dialog,{open:a,onOpenChange:f,children:jsxRuntime.jsxs(orderlyUi.DialogContent,{className:"oui-px-6 oui-max-w-[320px] oui-bg-base-8 oui-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)]",closable:true,children:[jsxRuntime.jsxs(orderlyUi.DialogTitle,{children:[jsxRuntime.jsx("div",{className:"oui-my-3",children:C("affiliate.referralRate.editRateModal.title")}),jsxRuntime.jsx(orderlyUi.Divider,{})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-h-full oui-flex oui-flex-col oui-justify-end",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54",children:C("affiliate.referralRate.editRateModal.description")}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-text-base-contrast-80 oui-mt-2 oui-flex",children:[C("affiliate.referralRate.editRateModal.label"),jsxRuntime.jsx("div",{className:"oui-text-warning-darken oui-pl-1",children:`${new orderlyUtils.Decimal(t.max_rebate_rate).mul(100).toFixed(0,orderlyUtils.Decimal.ROUND_DOWN)}%`})]}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:C("affiliate.referralRate.editRateModal.label.you")}),jsxRuntime.jsx(orderlyUi.Input,{ref:c,containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",value:u,onChange:_=>{let A=orderlyHooks.cleanStringStyle(_.target.value),B=Number.parseFloat(A);l(A),Number.isNaN(B)?(m(""),l("")):(m(`${Co(new orderlyUtils.Decimal(0),s.sub(B))}`),p(s.sub(B)<new orderlyUtils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:d?"danger":void 0}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:C("affiliate.referralRate.editRateModal.label.referee")}),jsxRuntime.jsx(orderlyUi.Input,{containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",autoFocus:false,value:x,onChange:_=>{let A=orderlyHooks.cleanStringStyle(_.target.value),B=Number.parseFloat(A);m(A),Number.isNaN(B)?(m(""),l("")):(l(`${Co(new orderlyUtils.Decimal(0),s.sub(B))}`),p(s.sub(B)<new orderlyUtils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:d?"danger":void 0}),d&&jsxRuntime.jsx("div",{className:"oui-text-danger oui-text-xs oui-mt-8 oui-text-center oui-px-4",children:C("affiliate.referralRate.editRateModal.helpText.max")}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",justify:"center",children:jsxRuntime.jsx(orderlyUi.Button,{id:"referral_bind_referral_code_btn",disabled:x.length===0||u.length===0||d,loading:U,className:orderlyUi.cn("oui-mt-8 oui-mb-4 oui-w-[154px]",d&&"oui-mt-3"),onClick:_=>{_.stopPropagation(),I();},children:C("common.confirm")})})]})]})})});function Co(e,t){return e>t?e:t}var Pt=()=>{let{referralInfo:e,referralLinkUrl:t,mutate:r,generateCode:a}=y(),o=l=>{Rt(ze(t,"ref",l));},n=l=>{Rt(l);},i=l=>{orderlyUi.modal.show(wo,{code:{...l},mutate:r});},f=l=>{orderlyUi.modal.show(xo,{code:{...l},successCallback:()=>{r();}});},[s,x]=orderlyHooks.useLocalStorage("orderly_referral_codes",[]),m=(l,d)=>{if(d){let p=s.findIndex(c=>c===l);p!==-1&&s.splice(p,1);}else s.splice(0,0,l);s.length>6&&s.splice(s.length-1,1),x([...s]);},u=react.useMemo(()=>{if(!e?.referrer_info?.referral_codes)return;let l=e?.referrer_info?.referral_codes?.map(p=>(a&&a.code===p.code&&(p.isAutoGenerated=true),p)),d=[];for(let p=0;p<s.length;p++){let c=s[p],C=l.findIndex(k=>k.code===c);C!==-1&&(d.push({...l[C],isPined:true}),l.splice(C,1));}return [...d,...l]},[e?.referrer_info?.referral_codes,s,a]);return {copyCode:n,copyLink:o,editRate:i,editCode:f,setPinCode:m,codes:u}};var Ye=()=>{let e=Pt();return jsxRuntime.jsx(_t,{...e})};var kt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{id:"oui-affiliate-affiliate-commissionAndReferees",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:jsxRuntime.jsxs(orderlyUi.Tabs,{defaultValue:"account",className:"oui-w-full",variant:"contained",children:[jsxRuntime.jsx(orderlyUi.TabPanel,{value:"account",title:t("affiliate.commission"),children:jsxRuntime.jsx(Xa,{...e})}),jsxRuntime.jsx(orderlyUi.TabPanel,{value:"password",title:t("affiliate.myReferees"),children:jsxRuntime.jsx(Ka,{...e})})]})})},G=e=>{let{title:t,value:r,align:a,className:o,rule:n,formatString:i,prefix:f}=e;return jsxRuntime.jsx(orderlyUi.Statistic,{className:orderlyUi.cn("oui-flex-1",o),label:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36 oui-text-2xs",children:t}),align:a,children:jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:n||"",formatString:i,prefix:f,className:"oui-text-base-contrast-80 oui-text-sm oui-mt-[6px]",children:r})})},Xa=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=react.useMemo(()=>[{title:`${t("affiliate.commission")} (USDC)`,dataIndex:"referral_rebate",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:`${t("affiliate.referralVol")} (USDC)`,dataIndex:"volume",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:2,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:t("affiliate.commission.column.activeUsers"),dataIndex:"daily_traded_referral",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:i}),width:216},{title:t("common.date"),dataIndex:"date",render:i=>qr(i),width:216}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(orderlyUi.ListView,{className:"oui-max-h-[200px] oui-w-full",dataSource:e.commission.data,loadMore:e.commission.loadMore,isLoading:e.commission.isLoading,renderItem:n=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.commission"),value:orderlyUtils.commifyOptional(n.referral_rebate,{fix:6,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(G,{title:t("affiliate.referralVol"),value:orderlyUtils.commifyOptional(n.volume,{fix:2,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(G,{title:t("affiliate.commission.column.activeUsers"),value:n.daily_traded_referral}),jsxRuntime.jsx(G,{title:t("common.date"),value:n.date,rule:"date",formatString:"yyyy-MM-dd",align:"end"})]}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mt-3 oui-w-full"})]})}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,columns:a,loading:e.commission.isLoading,ignoreLoadingCheck:true,dataSource:e.commission.data,pagination:e.commission.pagination,onRow:n=>({className:"oui-h-[41px]"})}),[r,e.commission]);return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(Ja,{value:e.commission.dateRange,setValue:e.commission.setDateRange}),o]})},Ka=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=react.useMemo(()=>[{title:t("affiliate.referees.column.refereeAddress"),dataIndex:"user_address",render:i=>jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"address",children:i}),className:"oui-w-1/5"},{title:t("affiliate.referralCode"),dataIndex:"referral_code",className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,dataIndex:"referral_rebate",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:6,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalVol")} (USDC)`,dataIndex:"volume",render:i=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(i,{fix:2,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:t("affiliate.referees.column.invitationTime"),dataIndex:"code_binding_time",render:i=>jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"date",formatString:"yyyy-MM-dd",children:i}),className:"oui-w-1/5"}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(orderlyUi.ListView,{className:"oui-w-full oui-max-h-[200px]",dataSource:e.referees.data,loadMore:e.referees.loadMore,isLoading:e.referees.isLoading,renderItem:(n,i)=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:3,className:"oui-border-b-2 oui-border-line-6 oui-pb-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.referralCode"),value:n.referral_code}),jsxRuntime.jsx(G,{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,value:orderlyUtils.commifyOptional(n.referral_rebate,{fix:6,prefix:"$",padEnd:true}),className:"oui-min-w-[102px]"}),jsxRuntime.jsx(G,{title:t("affiliate.referees.column.totalVol"),value:orderlyUtils.commifyOptional(n.volume,{fix:2,prefix:"$",padEnd:true}),align:"end"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",pt:3,gap:3,width:"100%",children:[jsxRuntime.jsx(G,{title:t("affiliate.referees.column.refereeAddress"),value:n.user_address,rule:"address"}),jsxRuntime.jsx(G,{title:t("affiliate.referees.column.invitationTime"),value:n.code_binding_time,align:"end",rule:"date",formatString:"yyyy-MM-dd"})]})]},i)}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,loading:e.referees.isLoading,ignoreLoadingCheck:true,columns:a,dataSource:e.referees.data,pagination:e.referees.pagination,onRow:n=>({className:"oui-h-[41px]"})}),[r,e.referees]);return jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:o})},Ja=e=>jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",height:49,className:"oui-border-b oui-border-line-6",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.DatePicker.range,{size:"xs",value:e.value,onChange:t=>{e.setValue(t);},max:90,disabled:{after:new Date}})})});var It=()=>{let e=tn(),t=rn();return {commission:e,referees:t}},tn=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),{page:a,pageSize:o,setPage:n,parsePagination:i}=orderlyUi.usePagination(),[f,{refresh:s,isLoading:x,loadMore:m,meta:u}]=orderlyHooks.useReferralRebateSummary({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:a});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>i(u),[i,u]);return react.useEffect(()=>{n(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:x,loadMore:m}},rn=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),{page:a,pageSize:o,setPage:n,parsePagination:i}=orderlyUi.usePagination(),[f,{refresh:s,isLoading:x,loadMore:m,meta:u}]=orderlyHooks.useRefereeInfo({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:a,sort:"descending_code_binding_time"});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>i(u),[i,u]);return react.useEffect(()=>{n(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:x,loadMore:m}};var Bt=()=>{let e=It();return jsxRuntime.jsx(kt,{...e})};var _e=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-affiliate-page",className:orderlyUi.cn("oui-h-lvw","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(ln,{}),jsxRuntime.jsx(Bt,{})]}),ln=()=>orderlyHooks.useMediaQuery("(max-width: 1279px)")?jsxRuntime.jsx(sn,{}):jsxRuntime.jsx(fn,{}),sn=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx(He,{})]}),jsxRuntime.jsx(qe,{}),jsxRuntime.jsx(Ye,{})]}),fn=()=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",itemAlign:"stretch",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:4,className:"oui-flex-1 oui-w-1/2",children:[jsxRuntime.jsx("div",{className:"oui-flex-1 oui-h-full oui-w-full",children:jsxRuntime.jsx(Ee,{})}),jsxRuntime.jsx(qe,{})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:4,className:"oui-w-1/2",children:[jsxRuntime.jsx(He,{}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsx(Ye,{})})]})]});var Vt=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(dn,{...e}),jsxRuntime.jsx(Mo,{className:"md:oui-hidden",...e}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",gap:3,width:"100%",className:"md:oui-mt-3",children:[jsxRuntime.jsx(xn,{...e}),jsxRuntime.jsx(pn,{...e})]}),jsxRuntime.jsx(gn,{title:`${t("affiliate.trader.tradingVol")} (USDC)`,...e})]})},dn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",gap:3,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-flex-1",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.trader.yourReferrer")}),jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"sm",className:"oui-text-primary-light oui-text-2xs md:oui-text-xs 2xl:oui-text-sm oui-bg-base-6",children:e.code})]}),jsxRuntime.jsx(Mo,{className:"oui-hidden md:oui-flex md:oui-flex-shrink md:oui-w-fit",...e})]})},Mo=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",gap:2,className:e.className,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebate")}:`}),jsxRuntime.jsx(orderlyUi.Text.gradient,{color:"brand",className:"oui-text-lg md:oui-text-xl 2xl:oui-text-2xl",children:e.rebateText})]})},xn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",width:"100%",justify:"between",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},pn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{gradient:"success",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebates")} (USDC)`}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(J,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(e.rebates,{fix:2,fallback:"0"})})]})]})},gn=e=>jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:orderlyUtils.commifyOptional(e.vol,{fix:2,fallback:"0"})})]});var Ot=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("All"),a=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o,userVolume:n}=y(),i=react.useMemo(()=>{if(!o)return 0;switch(t){case "All":return o.referee_info.total_referee_rebate;case "1D":return o.referee_info["1d_referee_rebate"];case "7D":return o.referee_info["7d_referee_rebate"];case "30D":return o.referee_info["30d_referee_rebate"]}},[o,t]),f=react.useMemo(()=>{if(n)switch(t){case "All":return n.all_volume;case "1D":return n["1d_volume"];case "7D":return n["7d_volume"];case "30D":return n["30d_volume"]}},[n,t]),s=o?.referee_info?.referer_code,x=o?.referee_info?.referee_rebate_rate,m=react.useMemo(()=>x?new orderlyUtils.Decimal(x).mul(100).toDecimalPlaces(2,orderlyUtils.Decimal.ROUND_DOWN).toString()+"%":"-",[x]);return {period:t,periodTypes:a,onPeriodChange:l=>{r(l);},rebates:i,vol:f,rebateText:m,code:s}};var Et=()=>{let e=Ot();return jsxRuntime.jsx(Vt,{...e})};var Ut=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(Tn,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{className:"oui-min-h-[170px] oui-h-full oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(orderlyChart.VolBarChart,{data:e.dataSource,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:orderlyUtils.Decimal.ROUND_DOWN,dp:e.volType==="volume"?2:6}})})]}),Tn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(orderlyUi.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};var Ht=()=>{let{t:e}=orderlyI18n.useTranslation(),[t,r]=react.useState("7"),a=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=c=>{r(c);},[n,i]=react.useState("rebate"),f=[{label:e("affiliate.trader.rebate"),value:"rebate"},{label:e("common.volume"),value:"volume"}],s=c=>{i(c);},x=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),{data:m,mutate:u}=orderlyHooks.useRefereeRebateSummary(x),{dailyVolume:l,chartConfig:d}=y(),p=react.useMemo(()=>n==="rebate"?(m||[]).map(C=>({date:C.date,volume:C.referee_rebate})).reverse():n==="volume"?l?.filter(c=>c.date>dateFns.format(dateFns.subDays(Date(),Number(t)+1),"yyyy-MM-dd")).map(c=>({date:c.date,volume:c.perp_volume}))||[]:[],[m,l,n]);return {period:t,periodTypes:a,onPeriodChange:o,volType:n,volTypes:f,onVolTypeChange:s,dataSource:Ge(Number(t),p)}};var $t=()=>{let e=Ht();return jsxRuntime.jsx(Ut,{...e})};var Zt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-rebates",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:[jsxRuntime.jsx(kn,{...e}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",className:"oui-border-y-2 oui-border-line-6",height:49,direction:"row",itemAlign:"center",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(orderlyUi.DatePicker.range,{size:"xs",value:e.dateRange,onChange:t=>{e.setDateRange(t);},max:90,disabled:{after:new Date}})})}),jsxRuntime.jsx(In,{...e})]}),kn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg",children:t("affiliate.trader.myRebates")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:36,className:"oui-text-2xs",children:e.displayDate})]})},In=e=>{let{t}=orderlyI18n.useTranslation(),r=orderlyHooks.useMediaQuery("(max-width: 767px)"),a=[{title:`${t("affiliate.trader.rebates")} (USDC)`,dataIndex:"referee_rebate",render:o=>jsxRuntime.jsx(orderlyUi.Text,{children:orderlyUtils.commifyOptional(o,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:127},{title:`${t("affiliate.trader.tradingVol")} (USDC)`,dataIndex:"vol",render:o=>orderlyUtils.commifyOptional(o,{fix:2,fallback:"0",padEnd:true,prefix:"$"}),width:127},{title:t("common.date"),dataIndex:"date",render:o=>jsxRuntime.jsx(orderlyUi.Text.formatted,{formatString:"yyyy-MM-dd",children:o}),width:127}];return r?jsxRuntime.jsx(orderlyUi.ListView,{dataSource:e.dataSource,className:"oui-h-[197px] oui-w-full",renderItem:(o,n)=>jsxRuntime.jsx(Bn,{item:o})}):jsxRuntime.jsx(orderlyUiConnector.AuthGuardDataTable,{bordered:true,loading:e.isLoading,columns:a,dataSource:e.dataSource,ignoreLoadingCheck:true,onRow:o=>({className:"oui-h-[41px]"}),pagination:e.pagination,manualPagination:false})},Bn=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",width:"100%",children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gap:1,children:[jsxRuntime.jsx(orderlyUi.Statistic,{label:`${t("affiliate.trader.rebates")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1 oui-min-w-[105px]",children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:orderlyUtils.commifyOptional(e.item.referee_rebate,{fix:6,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(orderlyUi.Statistic,{label:`${t("affiliate.trader.tradingVol")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-shrink",children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:orderlyUtils.commifyOptional(e.item.vol,{fix:2,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(orderlyUi.Statistic,{label:t("common.date"),className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1",align:"end",children:jsxRuntime.jsx(orderlyUi.Text.formatted,{size:"sm",intensity:80,formatString:"yyyy-MM-dd",children:e.item.date})})]}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full oui-mt-3"})]})};var Qt=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),{data:r,mutate:a,isLoading:o}=orderlyHooks.useRefereeRebateSummary({startDate:e?.from,endDate:e?.to}),{data:n,mutate:i}=orderlyHooks.useDaily({startDate:e?.to,endDate:e?.from}),f=react.useMemo(()=>typeof r>"u"?[]:r.map(u=>{let l=u.date,d=n?.filter(p=>Zr(dateFns.toDate(l),dateFns.toDate(p.date)))?.[0];return d?{...u,vol:d.perp_volume}:u}),[r,n]),s;(f?.length||0)>0&&(s=Gr(f?.[0].date));let{pagination:x,setPage:m}=orderlyUi.usePagination();return react.useEffect(()=>{m(1);},[e]),{dateRange:e,setDateRange:t,displayDate:s,dataSource:f,pagination:x,isLoading:o}};var Yt=()=>{let e=Qt();return jsxRuntime.jsx(Zt,{...e})};var Le=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-trader-page",className:orderlyUi.cn("oui-h-lvw oui-w-full","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gap:4,className:"oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",children:[jsxRuntime.jsx(Et,{}),jsxRuntime.jsx($t,{})]}),jsxRuntime.jsx(Yt,{})]});var jt=e=>{let{t}=orderlyI18n.useTranslation(),{generateCode:r}=y(),a=react.useMemo(()=>r?r.requireVolume>0?{title:t("affiliate.process.step1.volumeGt0.title",{requireVolume:r.requireVolume}),desc:t("affiliate.process.step1.volumeGt0.description",{volume:orderlyUtils.commify(r.completedVolume??0,2),requireVolume:orderlyUtils.commify(r.requireVolume)})}:{title:t("affiliate.process.step1.volumeEq0.title"),desc:t("affiliate.process.step1.volumeEq0.description")}:{title:t("affiliate.process.step1.title"),desc:t("affiliate.process.step1.description")},[r,t]);return typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-becomeAffiliate",direction:"column",gap:6,p:6,itemAlign:"center",r:"2xl",className:"oui-bg-base-9",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.process.title")}),jsxRuntime.jsxs(orderlyUi.Flex,{className:"oui-flex oui-flex-col oui-gap-3 lg:oui-w-full lg:oui-flex-row lg:oui-items-stretch",children:[jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Zn,{}),title:a.title,content:a.desc}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Uo,{})}),jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Qn,{}),title:t("affiliate.process.step2.title"),content:t("affiliate.process.step2.description")}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Uo,{})}),jsxRuntime.jsx(Kt,{icon:jsxRuntime.jsx(Yn,{}),title:t("affiliate.process.step3.title"),content:t("affiliate.process.step3.description")})]})]})},Kt=e=>jsxRuntime.jsxs(orderlyUi.Flex,{className:orderlyUi.cn("oui-flex oui-flex-row oui-gap-3","lg:oui-flex-1 lg:oui-flex-col lg:oui-gap-[6px]"),width:"100%",children:[jsxRuntime.jsx("div",{className:"oui-shrink-0",children:e.icon}),jsxRuntime.jsxs(orderlyUi.Flex,{className:orderlyUi.cn("oui-flex oui-flex-col oui-items-start oui-h-full oui-justify-between","lg:oui-items-center lg:oui-justify-start"),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg lg:oui-text-center",children:e.title}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-36 lg:oui-text-center",children:e.content})]})]}),Zn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.941 5.4h-6.682a.6.6 0 0 0-.593.509l-.462 3a.6.6 0 0 0 .593.691h7.606a.6.6 0 0 0 .593-.691l-.462-3a.6.6 0 0 0-.593-.509m-6.682-1.8a2.4 2.4 0 0 0-2.372 2.035l-.462 3a2.4 2.4 0 0 0 2.372 2.765h7.606a2.4 2.4 0 0 0 2.372-2.765l-.462-3A2.4 2.4 0 0 0 24.941 3.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M32.721 28.2c.924-1.6 3.233-1.6 4.157 0l7.275 12.6c.924 1.6-.231 3.6-2.079 3.6H27.525c-1.848 0-3.002-2-2.078-3.6z",fill:"#335FFC"}),jsxRuntime.jsx("path",{d:"M33.492 38.12H31.56c-.252 0-.426-.276-.336-.535l1.92-5.53a.4.4 0 0 1 .132-.185.34.34 0 0 1 .204-.07h3.24c.255 0 .43.284.333.544l-1.118 3.011h2.104c.31 0 .475.4.27.656l-5.158 6.453c-.251.313-.716.041-.619-.362z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.4 16.8v2.4h2.4v-2.4zM13.2 15a.6.6 0 0 0-.6.6v4.8a.6.6 0 0 0 .6.6H18a.6.6 0 0 0 .6-.6v-4.8a.6.6 0 0 0-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M20.4 16.2a.6.6 0 0 1 .6-.6h2.4a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H21a.6.6 0 0 1-.6-.6zm0 3a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6zm-7.8 5.4a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.739 6.6H10.2A2.4 2.4 0 0 0 7.8 9v30a2.4 2.4 0 0 0 2.4 2.4h13.84l1.014-1.8H10.2a.6.6 0 0 1-.6-.6V9a.6.6 0 0 1 .6-.6h5.262zm12 1.8H33a.6.6 0 0 1 .6.6v16.47a2.8 2.8 0 0 1 1.8-.205V9A2.4 2.4 0 0 0 33 6.6h-5.538z",fill:"#fff",fillOpacity:".36"})]}),Qn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{d:"M24 33a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15 32.4a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0 1.8a3.6 3.6 0 1 0 0-7.2 3.6 3.6 0 0 0 0 7.2m-6.578 4.942A4.8 4.8 0 0 1 13.2 34.8h3.6a4.8 4.8 0 0 1 4.778 4.342 9 9 0 0 1-1.778 1.473V39.6a3 3 0 0 0-3-3h-3.6a3 3 0 0 0-3 3v1.015a9 9 0 0 1-1.778-1.473",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.2 12a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0m1.8 0c0 1.37-.459 2.632-1.231 3.642l2.308 2.308a7.76 7.76 0 0 1 4.023-1.7v-.764A3.602 3.602 0 0 1 24 8.4a3.6 3.6 0 0 1 .9 7.087v.764c1.48.17 2.833.754 3.942 1.633l2.326-2.326a6 6 0 1 1 1.273 1.273l-2.326 2.326a7.76 7.76 0 0 1 1.634 3.943h.764a3.602 3.602 0 0 1 7.087.9 3.6 3.6 0 0 1-7.087.9h-.764a7.76 7.76 0 0 1-1.699 4.023l2.308 2.308a6 6 0 1 1-1.25 1.295l-2.347-2.347a7.8 7.8 0 0 1-3.05 1.433 11 11 0 0 0-.377-1.76 6 6 0 1 0-7.185-7.185q-.855-.261-1.76-.379a7.8 7.8 0 0 1 1.432-3.049l-2.347-2.347A6 6 0 1 1 18 12m7.8 0a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0M36 25.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0-9.6a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4M40.2 36a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0",fill:"#fff",fillOpacity:".36"})]}),Yn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 24a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8m0 1.8a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M45 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M35.1 6.6a.9.9 0 1 1 1.8 0v.437A3 3 0 0 1 39 9.9h-1.8a1.2 1.2 0 1 0-1.2 1.2 3 3 0 0 1 .9 5.863v.437a.9.9 0 0 1-1.8 0v-.437A3 3 0 0 1 33 14.1h1.8a1.2 1.2 0 1 0 1.2-1.2 3 3 0 0 1-.9-5.863z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.2 23.7a.9.9 0 0 1 1.8 0v.6q0 .045-.004.086c-.197 9.351-7.525 16.948-16.765 17.573l1.205 1.205a.9.9 0 1 1-1.272 1.272l-2.7-2.7a.9.9 0 0 1 0-1.272l2.7-2.7a.9.9 0 1 1 1.272 1.272l-1.11 1.11c8.325-.674 14.87-7.642 14.874-16.14zM21.564 4.836a.9.9 0 1 1 1.272-1.272l2.7 2.7a.9.9 0 0 1 0 1.272l-2.7 2.7a.9.9 0 1 1-1.272-1.272l1.11-1.11C14.347 8.528 7.8 15.5 7.8 24v.3a.9.9 0 1 1-1.8 0v-.6l.004-.086C6.201 14.263 13.53 6.666 22.77 6.042z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 11.4q.615 0 1.213.058a11 11 0 0 0 .061 1.816Q24.647 13.2 24 13.2c-5.965 0-10.8 4.835-10.8 10.8 0 2.898 1.142 5.53 3 7.47a4.8 4.8 0 0 1 4.8-4.79h6a4.8 4.8 0 0 1 4.8 4.789c1.858-1.94 3-4.572 3-7.47q0-.647-.074-1.274a11 11 0 0 0 1.816.06q.057.6.058 1.214c0 6.959-5.641 12.6-12.6 12.6S11.4 30.959 11.4 24 17.041 11.4 24 11.4m6 21.581v-1.5a3 3 0 0 0-3-3h-6a3 3 0 0 0-3 3v1.5a10.75 10.75 0 0 0 6 1.819c2.22 0 4.284-.67 6-1.819",fill:"#fff",fillOpacity:".36"})]}),Uo=()=>jsxRuntime.jsx("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.5048 4.00806C8.8728 4.00806 9.1708 4.30626 9.1708 4.67406C9.1708 4.99259 9.1708 8.71739 9.1708 9.71072L11.1688 7.73339L12.1055 8.67005L8.98346 11.8127C8.85346 11.9434 8.6788 12.0081 8.50413 12.0081C8.33013 12.0081 8.15612 11.9427 8.02612 11.8127L4.90413 8.67005L5.8408 7.73339L7.83881 9.71072C7.83881 8.71739 7.83881 4.99259 7.83881 4.67406C7.83881 4.30626 8.1368 4.00806 8.5048 4.00806Z",fill:"#608CFF"})});var er=()=>{let e=y();return {overwrite:e.overwrite?.ref?.step,state:e}};var tr=()=>{let e=er();return jsxRuntime.jsx(jt,{...e})};var rr=()=>{let{t:e}=orderlyI18n.useTranslation();return jsxRuntime.jsx("div",{id:"oui-affiliate-home-title",className:"oui-text-center oui-text-3xl oui-font-bold md:oui-text-3xl lg:oui-text-4xl xl:oui-text-5xl",children:e("affiliate.page.title")})};var or=()=>jsxRuntime.jsx(rr,{});var ir=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-subtitle",direction:"column",className:"oui-text-sm md:oui-text-base xl:oui-text-lg oui-text-base-contrast-80 oui-text-center",gap:3,children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.page.subTitle")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,className:"oui-text-primary-light oui-fill-primary-light hover:oui-text-primary-darken oui-cursor-pointer oui-text-2xs md:oui-text-xs xl:oui-text-sm",onClick:r=>{e.onLearnAffiliate?e.onLearnAffiliate?.():e.learnAffiliateUrl&&window.open(e.learnAffiliateUrl,"_blank");},children:[jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.page.learnMore")}),jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.008 7.995c0-.368.298-.666.666-.666H9.71L7.733 5.331l.937-.936 3.143 3.122c.13.13.195.304.195.479a.67.67 0 0 1-.195.478L8.67 11.596l-.937-.937 1.978-1.998H4.674a.666.666 0 0 1-.666-.666"})})]})]})};var ar=()=>{let e=y(),{onLearnAffiliate:t,learnAffiliateUrl:r}=e;return {onLearnAffiliate:t,learnAffiliateUrl:r}};var nr=()=>{let e=ar();return jsxRuntime.jsx(ir,{...e})};var lr=e=>e.overwriteTop!==void 0?e.overwriteTop?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-top",direction:"column",gap:6,children:[jsxRuntime.jsx(or,{}),jsxRuntime.jsx(nr,{})]});var sr=()=>{let e=y();return {overwriteTop:e.overwrite?.ref?.top,state:e}};var fr=()=>{let e=sr();return jsxRuntime.jsx(lr,{...e})};var nt=e=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.98",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:jsxRuntime.jsx("path",{d:"M4.00806 7.9952C4.00806 7.6272 4.30626 7.3292 4.67406 7.3292C4.99259 7.3292 8.71739 7.3292 9.71072 7.3292L7.73339 5.3312L8.67005 4.39453L11.8127 7.51654C11.9434 7.64654 12.0081 7.8212 12.0081 7.99587C12.0081 8.16987 11.9427 8.34388 11.8127 8.47388L8.67005 11.5959L7.73339 10.6592L9.71072 8.66119C8.71739 8.66119 4.99259 8.66119 4.67406 8.66119C4.30626 8.66119 4.00806 8.3632 4.00806 7.9952Z"})});var cr=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-asTrader",gradient:"success",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{height:80,direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isTrader?t("affiliate.trader"):t("affiliate.asTrader.title")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-text-xs md:oui-text-sm 2xl:oui-text-base oui-text-base-contrast-54",e.isTrader&&"oui-hidden"),children:t("affiliate.asTrader.description")})]}),jsxRuntime.jsx("div",{className:"oui-flex-shrink-0",children:jsxRuntime.jsx(hl,{})})]}),jsxRuntime.jsx(bl,{...e})]})},hl=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-w-[90px] xl:oui-h-[90px] ",children:[jsxRuntime.jsx("path",{d:"M44.996 7.324c-20.71 0-37.43 16.79-37.5 37.5-.07 20.682 16.806 37.575 37.5 37.617 20.694.04 37.537-17.082 37.5-37.617-.037-20.71-16.79-37.5-37.5-37.5m0 7.5c16.569 0 30 13.433 30 30 0 8.438-3.514 16.043-9.12 21.495-2.762-5.973-8.694-10.245-15.49-10.245h-10.78c-6.791 0-12.706 4.22-15.47 10.197-5.606-5.453-9.14-13.01-9.14-21.447 0-16.567 13.431-30 30-30m0 7.5c-8.284 0-15 6.717-15 15s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M90 71.25C90 81.605 81.605 90 71.25 90S52.5 81.605 52.5 71.25 60.895 52.5 71.25 52.5 90 60.895 90 71.25",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M80.62 75.007c0-.24-.08-.49-.263-.675l-3.487-3.456-1.318 1.318 1.845 1.875H63.745a.938.938 0 0 0 0 1.875h13.652l-1.845 1.875 1.318 1.318 3.487-3.456a.95.95 0 0 0 .263-.674m-.937-7.5a.94.94 0 0 0-.938-.938H65.093l1.846-1.875-1.319-1.318-3.486 3.456a.966.966 0 0 0 0 1.349l3.486 3.456 1.319-1.318-1.846-1.875h13.652c.518 0 .938-.42.938-.937",fill:"#fff",fillOpacity:".98"})]}),bl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isTrader&&!e.wrongNetwork){let a=e.referralInfo?.referee_info?.total_referee_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(orderlyUi.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(J,{}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:orderlyUtils.commifyOptional(a,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:e?.onEnterTraderPage,children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(nt,{className:"md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]"})]})]})}return jsxRuntime.jsx(Cl,{...e})})()})},Cl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Dialog,{open:e.open,onOpenChange:e.setOpen,children:[jsxRuntime.jsx(orderlyUi.DialogTrigger,{children:jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip"),children:e.isMobile?jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:r=>{(!e.isSignIn||e.wrongNetwork)&&(r.stopPropagation(),r.preventDefault(),orderlyUi.modal.alert({title:t("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip")})}));},className:!e.isSignIn||e.wrongNetwork?"oui-bg-white/[.54] oui-text-black/[.36] hover:oui-bg-white/[.54]":void 0,children:t("affiliate.asTrader.button")}):jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",disabled:!e.isSignIn||e.wrongNetwork,children:t("affiliate.asTrader.button")})})}),jsxRuntime.jsxs(orderlyUi.DialogContent,{className:"oui-w-[320px] oui-font-semibold",children:[jsxRuntime.jsx(orderlyUi.DialogHeader,{children:jsxRuntime.jsx(orderlyUi.DialogTitle,{children:t("affiliate.referralCode.dialog.title")})}),jsxRuntime.jsx(orderlyUi.Divider,{}),jsxRuntime.jsxs(orderlyUi.DialogBody,{children:[jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:54,children:t("affiliate.referralCode.dialog.description")}),jsxRuntime.jsx(orderlyUi.TextField,{className:"oui-mt-4 oui-w-full",placeholder:t("affiliate.referralCode"),value:e.code,onChange:r=>{let a=r.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");e.setCode(a);},formatters:[orderlyUi.inputFormatter.createRegexInputFormatter(r=>String(r).replace(/[a-z]/g,a=>a.toUpperCase())),orderlyUi.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],onClean:()=>{e.setCode("");},label:t("affiliate.referralCode.label"),classNames:{label:"oui-text-2xs oui-text-base-contrast-54"},helpText:!e.isExist&&!e.isLoading&&e.code.length>0?t("affiliate.referralCode.notExist"):void 0,color:!e.isExist&&!e.isLoading&&e.code.length>0?"danger":void 0}),jsxRuntime.jsx(orderlyUi.Flex,{itemAlign:"center",width:"100%",direction:"row",justify:"center",mt:6,children:jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"primary",size:"md",className:"oui-px-[40px]",disabled:e.code.length<4||!e.isExist,onClick:r=>{r.stopPropagation(),e.onClickConfirm();},children:t("common.confirm")})})]})]})]})};var xr=()=>{let{t:e}=orderlyI18n.useTranslation(),{isTrader:t,referralInfo:r,setShowHome:a,bindReferralCodeState:o,setTab:n,mutate:i,wrongNetwork:f,disabledConnect:s}=y(),{state:x}=orderlyHooks.useAccount(),m=!s&&(x.status===orderlyTypes.AccountStatusEnum.EnableTrading||x.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),u=()=>{n("trader"),a(false);},[l,d]=react.useState(""),[p,c]=react.useState(false),{isExist:C,error:k,isLoading:ne}=orderlyHooks.useCheckReferralCode(l),U=()=>{c(false);},[I,{error:_,isMutating:A}]=orderlyHooks.useMutation("/v1/referral/bind","POST"),B=async()=>{try{await I({referral_code:l}),orderlyUi.toast.success(e("affiliate.referralCode.bound")),i(),o?o(!0,null,U,{tab:1}):U();}catch(H){let K=`${H}`;"message"in H&&(K=H.message),K==="referral code not exist"&&(K=e("affiliate.referralCode.notExist")),o?(orderlyUi.toast.error(K),o(false,H,U,{})):orderlyUi.toast.error(K);}},{isMobile:ce}=orderlyUi.useScreen();return {isSignIn:m,isTrader:t,isLoading:ne,referralInfo:r,onEnterTraderPage:u,code:l,setCode:d,open:p,setOpen:c,onClickConfirm:B,isExist:C,wrongNetwork:f,isMobile:ce}};var pr=()=>{let e=xr();return jsxRuntime.jsx(cr,{...e})};var gr=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-asAnAffiliate",gradient:"primary",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isAffiliate?t("common.affiliate"):t("affiliate.asAffiliate.title")}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",e.isAffiliate&&"oui-hidden"),children:t("affiliate.asAffiliate.description")})]}),jsxRuntime.jsx("div",{className:"oui-shrink-0",children:jsxRuntime.jsx(Ml,{})})]}),jsxRuntime.jsx(Pl,{...e})]})},Ml=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 72 72",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-w-[90px] xl:oui-h-[90px]",children:[jsxRuntime.jsx("path",{d:"M35.997 5.86c-16.569 0-29.944 13.43-30 30-.056 16.545 13.445 30.06 30 30.093s30.03-13.665 30-30.093c-.03-16.57-13.432-30-30-30m0 6c13.255 0 24 10.746 24 24 0 6.75-2.812 12.834-7.297 17.196-2.209-4.78-6.955-8.196-12.39-8.196h-8.626c-5.432 0-10.164 3.375-12.375 8.157-4.485-4.362-7.312-10.407-7.312-17.157 0-13.254 10.745-24 24-24m0 6c-6.628 0-12 5.373-12 12s5.372 12 12 12c6.627 0 12-5.373 12-12s-5.373-12-12-12",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M72 57c0 8.284-6.716 15-15 15s-15-6.716-15-15 6.716-15 15-15 15 6.716 15 15",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M53.624 51.45a4.125 4.125 0 0 0-4.125 4.125c0 2.388 1.36 4.641 3.61 6.703a21 21 0 0 0 2.414 1.875c.287.194.556.37.797.516.147.089.243.154.304.187a.79.79 0 0 0 .75 0c.061-.033.158-.098.305-.187.24-.147.51-.322.797-.516a21 21 0 0 0 2.414-1.875c2.25-2.062 3.61-4.315 3.61-6.703a4.125 4.125 0 0 0-4.126-4.125c-1.294 0-2.557.705-3.351 1.734-.775-1.047-2.034-1.734-3.399-1.734",fill:"#fff",fillOpacity:".98"})]}),Pl=e=>{let{t}=orderlyI18n.useTranslation();return jsxRuntime.jsx(orderlyUi.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isAffiliate&&!e.wrongNetwork){let a=e.referralInfo?.referrer_info?.total_referrer_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(orderlyUi.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(J,{}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:orderlyUtils.commifyOptional(a,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:o=>{e.onEnterAffiliatePage?.(e.referralInfo);},children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(nt,{className:"md:oui-w-[18px] md:oui-h-[18px] lg:oui-w-[20px] lg:oui-h-[20px] xl:oui-w-[24px] xl:oui-h-[24px]"})]})]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Tooltip,{content:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip"),children:e.isMobile?jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:a=>{!e.isSignIn||e.wrongNetwork?(a.stopPropagation(),a.preventDefault(),orderlyUi.modal.alert({title:t("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:e.wrongNetwork?t("connector.wrongNetwork.tooltip"):t("affiliate.connectWallet.tooltip")})})):e.becomeAnAffiliate?.();},className:!e.isSignIn||e.wrongNetwork?"oui-bg-white/[.54] oui-text-black/[.36] hover:oui-bg-white/[.54]":void 0,children:t("affiliate.asAffiliate.button")}):jsxRuntime.jsx(orderlyUi.Button,{variant:"contained",color:"light",onClick:e.becomeAnAffiliate,disabled:!e.isSignIn||e.wrongNetwork,children:t("affiliate.asAffiliate.button")})}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",className:"oui-h-full",itemAlign:"end",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl 2xl:oui-text-2xl",children:t("affiliate.upTo")}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-2xs oui-text-base-contrast-54 md:oui-text-xs 2xl:oui-text-sm",children:t("affiliate.commission")})]})]})})()})};var hr=()=>{let{isAffiliate:e,isLoading:t,referralInfo:r,becomeAnAffiliateUrl:a,setShowHome:o,setTab:n,wrongNetwork:i,disabledConnect:f}=y(),{state:s}=orderlyHooks.useAccount(),x=!f&&(s.status===orderlyTypes.AccountStatusEnum.EnableTrading||s.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),m=()=>{window.open(a,"_blank");},u=()=>{n("affiliate"),o(false);},{isMobile:l}=orderlyUi.useScreen();return {isSignIn:x,isAffiliate:e,isLoading:t,referralInfo:r,onEnterAffiliatePage:u,becomeAnAffiliate:m,wrongNetwork:i,isMobile:l}};var br=()=>{let e=hr();return jsxRuntime.jsx(gr,{...e})};var Cr=e=>typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-card",className:"oui-flex oui-w-full oui-flex-col oui-items-stretch oui-gap-6 xl:oui-flex-row xl:oui-gap-[36px]",children:[jsxRuntime.jsx(br,{}),jsxRuntime.jsx(pr,{})]});var wr=()=>{let e=y();return {overwrite:e.overwrite?.ref?.card,state:e}};var yr=()=>{let e=wr();return jsxRuntime.jsx(Cr,{...e})};var ve=()=>jsxRuntime.jsxs(orderlyUi.Flex,{id:"oui-affiliate-home-page",className:orderlyUi.cn("oui-h-lvw ","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(fr,{}),jsxRuntime.jsx(yr,{}),jsxRuntime.jsx(tr,{})]});var Rr=e=>{let{t}=orderlyI18n.useTranslation(),r=()=>{if(e.isAffiliate&&!e.isTrader)return jsxRuntime.jsxs(orderlyUi.Button,{variant:"contained",color:"success",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:a=>{e.anATrader();},children:[jsxRuntime.jsx(dt,{}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.asTrader.title")})]});if(!e.isAffiliate&&e.isTrader)return jsxRuntime.jsxs(orderlyUi.Button,{variant:"contained",color:"primary",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:a=>{e.anAnAffiliate();},children:[jsxRuntime.jsx(mt,{}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.asAffiliate.title")})]})};return e.isLoading?jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-w-[960px]",e.classNames?.loadding),children:e.splashPage?.()||jsxRuntime.jsx(ve,{})}):!e.isAffiliate&&!e.isTrader||e.showHome?jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-w-[960px]",e?.classNames?.home),children:jsxRuntime.jsx(ve,{})}):jsxRuntime.jsxs(orderlyUi.TabsBase,{id:"oui-affiliate-dashboard-tab",value:e.tab,onValueChange:a=>{e.setTab(a);},className:orderlyUi.cn("oui-w-full",e.classNames?.dashboard),children:[jsxRuntime.jsxs(orderlyUi.TabsList,{className:orderlyUi.cn("oui-px-6 oui-flex oui-flex-row oui-justify-start oui-h-[44px] oui-relative oui-items-end","oui-text-base md:oui-text-lg","oui-rounded-xl oui-bg-base-9","oui-border oui-border-line-6",e.isAffiliate&&e.isTrader&&"oui-justify-center"),children:[e.isAffiliate&&jsxRuntime.jsx(orderlyUi.TabsTrigger,{id:"oui-affiliate-dashboard-tab-affiliate",value:"affiliate",children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(mt,{fillOpacity:1,fill:"currentColor",className:e.tab==="affiliate"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(orderlyUi.Text,{children:t("common.affiliate")})]})}),e.isTrader&&jsxRuntime.jsx(orderlyUi.TabsTrigger,{id:"oui-affiliate-dashboard-tab-trader",value:"trader",children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(dt,{fillOpacity:1,fill:"currentColor",className:e.tab==="trader"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(orderlyUi.Text,{children:t("affiliate.trader")})]})}),r()]}),e.isAffiliate&&jsxRuntime.jsx(orderlyUi.TabsContent,{value:"affiliate",className:"oui-mt-4",children:jsxRuntime.jsx(_e,{})}),e.isTrader&&jsxRuntime.jsx(orderlyUi.TabsContent,{value:"trader",className:"oui-mt-4",children:jsxRuntime.jsx(Le,{})})]})};var Tr=()=>{let{isAffiliate:e,isTrader:t,isLoading:r,becomeAnAffiliateUrl:a,onBecomeAnAffiliate:o,showReferralPage:n,splashPage:i,showHome:f,setShowHome:s,tab:x,setTab:m}=y(),u=react.useMemo(()=>e&&t?x:e&&!t?"affiliate":!e&&t?"trader":"affiliate",[x,e,t]);return react.useEffect(()=>{let c=new URLSearchParams(window.location.search).get("tab");c&&m(c);},[window.location.search]),{setTab:m,tab:u,isAffiliate:e,isTrader:t,isLoading:r,anAnAffiliate:()=>{s(true);},anATrader:()=>{s(true);},splashPage:i,showHome:f,setShowHome:s}};var Sr=e=>{let t=Tr();return jsxRuntime.jsx(Rr,{classNames:e.classNames,...t})};var li=e=>{let{classNames:t={}}=e,{root:r,...a}=t;return jsxRuntime.jsx("div",{id:"oui-affiliate-dashboard-page",className:orderlyUi.cn("oui-w-full oui-tracking-tight",r),children:jsxRuntime.jsx(Sr,{classNames:a})})};var ui=e=>{let{...t}=e;return jsxRuntime.jsx(orderlyUiScaffold.Scaffold,{leftSidebar:jsxRuntime.jsx(Kl,{...t}),children:jsxRuntime.jsx(orderlyUi.Box,{mx:3,my:6,children:e.children})})},Kl=e=>jsxRuntime.jsx(orderlyUi.Box,{p:4,m:3,border:true,borderColor:8,r:"xl",children:jsxRuntime.jsx(orderlyUiScaffold.SideBar,{...e})});var ci=()=>{let[e,t]=react.useState("/"),{t:r}=orderlyI18n.useTranslation();return {items:react.useMemo(()=>[{name:r("common.trading"),href:"/",icon:jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M4.883 1.5c-.166.01-.393.076-.515.173a2 2 0 0 0-.18.173L.918 6.553a.86.86 0 0 0-.168.475c0 .339.232.543.232.543l7.374 8.633c.005.006.269.301.644.296s.64-.29.644-.296l7.402-8.663s.204-.269.204-.513-.196-.517-.196-.517L13.82 1.848c-.023-.032-.076-.021-.103-.049-.033-.038-.037-.091-.077-.124-.123-.097-.267-.106-.413-.123-.04-.005-.063-.049-.103-.049h-.078zm1.745 1.582h4.744L9 5.795zm-1.675.542 2.294 2.615H3.122zm8.094 0 1.831 2.615h-4.125zM3.328 7.818h4.847v5.672zm6.497 0h4.847c-1.151 1.345-3.422 4.007-4.847 5.672z",fill:"url(#a)"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"a",x1:"17.25",y1:"9",x2:".75",y2:"9",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-end))"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"rgb(var(--oui-gradient-brand-start))"})]})})]})},{name:r("common.affiliate"),href:"/affiliate",icon:jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 4.95c0-.746.604-1.35 1.35-1.35h4.05c.746 0 1.35.604 1.35 1.35v4.62L9 12.195 5.625 9.57zm8.624 3.163-.524.407v-.96l.074.05c.193.128.346.302.45.502m-4.42 5.148L14.4 9.705v3.345a1.35 1.35 0 0 1-1.35 1.35h-8.1a1.35 1.35 0 0 1-1.35-1.35V9.705l4.571 3.556c.488.379 1.17.379 1.658 0M4.275 8.52l-.524-.407c.104-.2.257-.374.45-.503l.074-.049zm0-2.581V4.95a2.7 2.7 0 0 1 2.7-2.7h4.05a2.7 2.7 0 0 1 2.7 2.7v.989l.823.548a2.7 2.7 0 0 1 1.202 2.247v4.316a2.7 2.7 0 0 1-2.7 2.7h-8.1a2.7 2.7 0 0 1-2.7-2.7V8.734a2.7 2.7 0 0 1 1.202-2.247zM9 6.089l.111-.118.005-.005a1.08 1.08 0 0 1 1.58.004 1.223 1.223 0 0 1 0 1.668l-1.515 1.62-.004.004c-.1.102-.26.1-.358-.004l-1.516-1.62a1.223 1.223 0 0 1 0-1.668l.004-.004a1.08 1.08 0 0 1 1.58.004z",fill:"#fff",fillOpacity:".54"})})}],[r]),current:e,onItemSelect:o=>{t(o.href);}}};var ts=e=>{let t=ci();return jsxRuntime.jsx(ui,{...t,children:e.children})};
17
+
18
+ exports.AffiliateLayoutWidget = ts;
19
+ exports.Dashboard = si;
20
+ exports.ReferralContext = Vr;
21
+ exports.ReferralProvider = Ss;
22
+ exports.TabTypes = Ne;
23
+ exports.useReferralContext = y;
24
+ //# sourceMappingURL=out.js.map
25
+ //# sourceMappingURL=index.js.map