@kodiak-finance/orderly-ui-share 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,110 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type layoutInfo = {
4
+ width?: number;
5
+ height?: number;
6
+ fontSize?: number;
7
+ color?: string;
8
+ textAlign?: CanvasTextAlign;
9
+ textBaseline?: CanvasTextBaseline;
10
+ position: Partial<{
11
+ left: number;
12
+ right: number;
13
+ top: number;
14
+ bottom: number;
15
+ }>;
16
+ };
17
+ type PosterLayoutConfig = {
18
+ message?: layoutInfo;
19
+ domain?: layoutInfo;
20
+ position?: layoutInfo;
21
+ unrealizedPnl?: layoutInfo & {
22
+ secondaryColor: string;
23
+ secondaryFontSize: number;
24
+ };
25
+ informations?: layoutInfo & {
26
+ labelColor?: string;
27
+ };
28
+ updateTime?: layoutInfo;
29
+ };
30
+ type SharePnLConfig = SharePnLOptions & Partial<Omit<SharePnLParams, "refCode">>;
31
+ type SharePnLParams = {
32
+ entity: ShareEntity;
33
+ refCode?: string;
34
+ refSlogan?: string;
35
+ refLink?: string;
36
+ };
37
+ type SharePnLOptions = {
38
+ /**
39
+ * default is Manrope
40
+ */
41
+ fontFamily?: string;
42
+ /**
43
+ * can not empty
44
+ */
45
+ backgroundImages?: string[];
46
+ /**
47
+ * posterLayoutConfig
48
+ */
49
+ layout?: PosterLayoutConfig;
50
+ /**
51
+ * norma text color, default is "rgba(255, 255, 255, 0.98)"
52
+ */
53
+ color?: string;
54
+ /**
55
+ * profit text color, default is "rgb(0,181,159)"
56
+ */
57
+ profitColor?: string;
58
+ /**
59
+ * loss text color, default is "rgb(255,103,194)"
60
+ */
61
+ lossColor?: string;
62
+ /**
63
+ * brand color, default is "rgb(0,181,159)"
64
+ */
65
+ brandColor?: string;
66
+ };
67
+ type ReferralType = {
68
+ code?: string;
69
+ link?: string;
70
+ slogan?: string;
71
+ };
72
+ type ShareEntity = {
73
+ symbol: string;
74
+ side: "LONG" | "SHORT";
75
+ pnl?: number;
76
+ roi?: number;
77
+ openPrice?: number;
78
+ closePrice?: number;
79
+ openTime?: number;
80
+ closeTime?: number;
81
+ markPrice?: number;
82
+ quantity?: number;
83
+ leverage?: number;
84
+ };
85
+
86
+ declare const useSharePnLScript: (props: {
87
+ pnl?: SharePnLOptions & SharePnLParams;
88
+ hide?: () => void;
89
+ }) => {
90
+ entity: ShareEntity | undefined;
91
+ baseDp: number | undefined;
92
+ quoteDp: number | undefined;
93
+ referralInfo: ReferralType | undefined;
94
+ shareOptions: SharePnLOptions;
95
+ hide: (() => void) | undefined;
96
+ };
97
+
98
+ declare const SharePnLBottomSheetWidget: (props: {
99
+ hide?: () => void;
100
+ pnl?: SharePnLOptions & SharePnLParams;
101
+ }) => react_jsx_runtime.JSX.Element;
102
+ declare const SharePnLDialogWidget: (props: {
103
+ hide?: () => void;
104
+ pnl?: SharePnLOptions & SharePnLParams;
105
+ }) => react_jsx_runtime.JSX.Element;
106
+
107
+ declare const SharePnLDialogId = "sharePnLDialog";
108
+ declare const SharePnLBottomSheetId = "sharePnLBottomSheet";
109
+
110
+ export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLOptions, type SharePnLParams, useSharePnLScript };
@@ -0,0 +1,110 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type layoutInfo = {
4
+ width?: number;
5
+ height?: number;
6
+ fontSize?: number;
7
+ color?: string;
8
+ textAlign?: CanvasTextAlign;
9
+ textBaseline?: CanvasTextBaseline;
10
+ position: Partial<{
11
+ left: number;
12
+ right: number;
13
+ top: number;
14
+ bottom: number;
15
+ }>;
16
+ };
17
+ type PosterLayoutConfig = {
18
+ message?: layoutInfo;
19
+ domain?: layoutInfo;
20
+ position?: layoutInfo;
21
+ unrealizedPnl?: layoutInfo & {
22
+ secondaryColor: string;
23
+ secondaryFontSize: number;
24
+ };
25
+ informations?: layoutInfo & {
26
+ labelColor?: string;
27
+ };
28
+ updateTime?: layoutInfo;
29
+ };
30
+ type SharePnLConfig = SharePnLOptions & Partial<Omit<SharePnLParams, "refCode">>;
31
+ type SharePnLParams = {
32
+ entity: ShareEntity;
33
+ refCode?: string;
34
+ refSlogan?: string;
35
+ refLink?: string;
36
+ };
37
+ type SharePnLOptions = {
38
+ /**
39
+ * default is Manrope
40
+ */
41
+ fontFamily?: string;
42
+ /**
43
+ * can not empty
44
+ */
45
+ backgroundImages?: string[];
46
+ /**
47
+ * posterLayoutConfig
48
+ */
49
+ layout?: PosterLayoutConfig;
50
+ /**
51
+ * norma text color, default is "rgba(255, 255, 255, 0.98)"
52
+ */
53
+ color?: string;
54
+ /**
55
+ * profit text color, default is "rgb(0,181,159)"
56
+ */
57
+ profitColor?: string;
58
+ /**
59
+ * loss text color, default is "rgb(255,103,194)"
60
+ */
61
+ lossColor?: string;
62
+ /**
63
+ * brand color, default is "rgb(0,181,159)"
64
+ */
65
+ brandColor?: string;
66
+ };
67
+ type ReferralType = {
68
+ code?: string;
69
+ link?: string;
70
+ slogan?: string;
71
+ };
72
+ type ShareEntity = {
73
+ symbol: string;
74
+ side: "LONG" | "SHORT";
75
+ pnl?: number;
76
+ roi?: number;
77
+ openPrice?: number;
78
+ closePrice?: number;
79
+ openTime?: number;
80
+ closeTime?: number;
81
+ markPrice?: number;
82
+ quantity?: number;
83
+ leverage?: number;
84
+ };
85
+
86
+ declare const useSharePnLScript: (props: {
87
+ pnl?: SharePnLOptions & SharePnLParams;
88
+ hide?: () => void;
89
+ }) => {
90
+ entity: ShareEntity | undefined;
91
+ baseDp: number | undefined;
92
+ quoteDp: number | undefined;
93
+ referralInfo: ReferralType | undefined;
94
+ shareOptions: SharePnLOptions;
95
+ hide: (() => void) | undefined;
96
+ };
97
+
98
+ declare const SharePnLBottomSheetWidget: (props: {
99
+ hide?: () => void;
100
+ pnl?: SharePnLOptions & SharePnLParams;
101
+ }) => react_jsx_runtime.JSX.Element;
102
+ declare const SharePnLDialogWidget: (props: {
103
+ hide?: () => void;
104
+ pnl?: SharePnLOptions & SharePnLParams;
105
+ }) => react_jsx_runtime.JSX.Element;
106
+
107
+ declare const SharePnLDialogId = "sharePnLDialog";
108
+ declare const SharePnLBottomSheetId = "sharePnLBottomSheet";
109
+
110
+ export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLOptions, type SharePnLParams, useSharePnLScript };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var orderlyUi = require('@kodiak-finance/orderly-ui');
4
+ var f = require('react');
5
+ var orderlyHooks = require('@kodiak-finance/orderly-hooks');
6
+ var orderlyI18n = require('@kodiak-finance/orderly-i18n');
7
+ var orderlyTypes = require('@kodiak-finance/orderly-types');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var orderlyUtils = require('@kodiak-finance/orderly-utils');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var f__default = /*#__PURE__*/_interopDefault(f);
14
+
15
+ var Q=e=>{let{pnl:t,hide:n}=e,r=t?.entity,o=orderlyHooks.useSymbolsInfo(),{getFirstRefCode:a}=orderlyHooks.useReferralInfo(),l=f.useMemo(()=>{let c=a()?.code;return {code:t?.refCode??c,slogan:t?.refSlogan,link:t?.refLink}},[a,t]),u=f.useMemo(()=>{if(r)return o[r?.symbol]("base_dp")},[r,o]),s=f.useMemo(()=>{if(r)return o[r?.symbol]("quote_dp")},[r,o]);return {entity:r,baseDp:u,quoteDp:s,referralInfo:l,shareOptions:t,hide:n}};var K=f.forwardRef((e,t)=>{let{width:n,height:r,className:o,data:a,style:l}=e,{ref:u,download:s,toDataURL:c,copy:i,toBlob:d}=orderlyHooks.usePoster(a,{ratio:e.ratio});return f.useImperativeHandle(t,()=>({download:s,toDataURL:c,toBlob:d,copy:i})),jsxRuntime.jsx("canvas",{ref:u,width:n,height:r,className:o,style:l})});function j(e,t,n,r,o,a,l,u){let{t:s}=orderlyI18n.useTranslation(),{symbol:c,currency:i}=tt(e.symbol),d={symbol:c,currency:i,side:e.side};switch(r){case "pnl":{e.pnl!=null&&(d.pnl=new orderlyUtils.Decimal(e.pnl).toFixed(2,orderlyUtils.Decimal.ROUND_DOWN));break}case "roi":{e.roi!=null&&(d.ROI=new orderlyUtils.Decimal(e.roi).toFixed(2,orderlyUtils.Decimal.ROUND_DOWN));break}case "roi_pnl":{e.pnl!=null&&(d.pnl=new orderlyUtils.Decimal(e.pnl).toFixed(2,orderlyUtils.Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new orderlyUtils.Decimal(e.roi).toFixed(2,orderlyUtils.Decimal.ROUND_DOWN));break}}let h=[];o.has("leverage")&&(d.leverage=e.leverage),["openPrice","closePrice","openTime","closeTime","markPrice","quantity"].forEach(b=>{if(o.has(b))switch(b){case "leverage":break;case "openPrice":{e.openPrice!=null&&h.push({title:s("share.pnl.optionalInfo.openPrice"),value:X(e.openPrice,l||2)});break}case "closePrice":{e.closePrice!=null&&h.push({title:s("share.pnl.optionalInfo.closePrice"),value:X(e.closePrice,l||2)});break}case "openTime":{e.openTime!=null&&h.push({title:s("share.pnl.optionalInfo.openTime"),value:xe(e.openTime)});break}case "closeTime":{e.closeTime!=null&&h.push({title:s("share.pnl.optionalInfo.closeTime"),value:xe(e.closeTime)});break}case "markPrice":{e.markPrice!=null&&h.push({title:s("common.markPrice"),value:X(e.markPrice,l||2)});break}case "quantity":e.quantity!=null&&h.push({title:s("common.quantity"),value:X(e.quantity,a||2)});}}),d.informations=h;let S={position:d,updateTime:ot(new Date),domain:n};return t.length>0&&(S.message=t),typeof u<"u"&&u.code!==void 0&&(S.referral=u),S}function tt(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[n,r,o]=t;return {symbol:`${r}-${n}`,currency:o||"USDC"}}function ot(e){let t=e instanceof Date?e:new Date(e),n={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},o=new Intl.DateTimeFormat("en-US",n).formatToParts(t),a=o.find(i=>i.type==="year"?i.value:"")?.value,l=o.find(i=>i.type==="month"?i.value:"")?.value,u=o.find(i=>i.type==="day"?i.value:"")?.value,s=o.find(i=>i.type==="hour"?i.value:"")?.value,c=o.find(i=>i.type==="minute"?i.value:"")?.value;return `${a}-${l}-${u} ${s}:${c}`}function xe(e){let t=e instanceof Date?e:new Date(e),n={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},o=new Intl.DateTimeFormat("en-US",n).formatToParts(t),a=o.find(c=>c.type==="month"?c.value:"")?.value,l=o.find(c=>c.type==="day"?c.value:"")?.value,u=o.find(c=>c.type==="hour"?c.value:"")?.value,s=o.find(c=>c.type==="minute"?c.value:"")?.value;return `${a}-${l} ${u}:${s}`}function X(e,t){return new orderlyUtils.Decimal(e).toFixed(t,orderlyUtils.Decimal.ROUND_DOWN)}function ee(e,t,n,r){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:n,pnlFormat:e,options:Array.from(t),message:r}));}function te(){let e=localStorage.getItem("pnl_config_key");if(e&&e.length>0)try{return JSON.parse(e)}catch{}return {bgIndex:0,pnlFormat:"roi_pnl",options:["openPrice","closePrice","openTime","closeTime","markPrice","quantity","leverage"],message:""}}var Se=e=>{let{onClickDownload:t,onClickCopy:n}=e,{t:r}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxRuntime.jsxs(orderlyUi.Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(at,{})}),r("common.download")]}),jsxRuntime.jsxs(orderlyUi.Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:n,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(st,{})}),r("common.copy")]})]})},at=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667",fill:"#fff",fillOpacity:".98"})}),st=()=>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:"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",fill:"#fff",fillOpacity:".98"})});var be=e=>{let{children:t,...n}=e;return jsxRuntime.jsx("button",{...n,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083",fill:"#fff",fillOpacity:".54"})]})})},we=e=>{let{children:t,...n}=e;return jsxRuntime.jsx("button",{...n,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271",fill:"#fff",fillOpacity:".54"})]})})};var Ie=e=>{let{backgroundImages:t,selectedSnap:n,setSelectedSnap:r}=e,[o,a]=orderlyUi.useEmblaCarousel({containScroll:"keepSnaps",dragFree:true}),l=f.useCallback(()=>{a&&(a?.canScrollPrev()?a.scrollPrev():n-1>=0&&r(n-1));},[a,n]),u=f.useCallback(()=>{a&&(a?.canScrollNext()?a.scrollNext():n+1<t.length&&r(n+1));},[a,n]),s=f.useCallback(c=>{r(c.selectedScrollSnap());},[]);return f.useEffect(()=>{if(a)return s(a),a.on("reInit",s),a.on("select",s),a?.scrollTo(n),()=>{a.off("reInit",s),a.off("select",s);}},[a,s]),jsxRuntime.jsxs(orderlyUi.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(be,{onClick:l}),jsxRuntime.jsx("div",{ref:o,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsxRuntime.jsx(orderlyUi.Flex,{children:t.map((c,i)=>jsxRuntime.jsx(orderlyUi.Box,{onClick:()=>{a?.canScrollPrev()||a?.canScrollNext()?a?.scrollTo(i):r(i);},mx:2,my:1,mr:6,r:"base",className:orderlyUi.cn("oui-shrink-0 oui-w-[162px]",n===i&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:c,className:"oui-rounded-sm"})},c))})}),jsxRuntime.jsx(we,{onClick:u})]})};var oe=e=>{let{size:t=16,className:n}=e;return jsxRuntime.jsx("button",{type:"button",onClick:r=>{e.onCheckedChange(!e.checked);},className:n,children:e.checked?jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z",fill:"#fff",fillOpacity:".8"})}):jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333",fill:"#fff",fillOpacity:".8"})})})};var De=e=>{let{message:t,setMessage:n,check:r,setCheck:o}=e,[a,l]=f.useState(false),u=f.useRef(null),{t:s}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(oe,{className:"oui-mt-[2px]",checked:r,onCheckedChange:c=>{o(c);}}),jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{o(!e.check);},children:s("share.pnl.optionalInfo.message")}),jsxRuntime.jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsxRuntime.jsx(orderlyUi.Input,{ref:u,placeholder:s("share.pnl.optionalInfo.message.placeholder"),classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:false,suffix:a&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:c=>{n(""),setTimeout(()=>{u.current?.focus();},50),c.stopPropagation();},children:jsxRuntime.jsx(orderlyUi.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(true),onBlur:()=>l(false),onChange:c=>{if(c.target.value.length>25){orderlyUi.toast.error(s("share.pnl.optionalInfo.message.maxLength"));return}o(c.target.value.length>0),n(c.target.value);}})})]})};var Fe=e=>{let{type:t,curType:n,setShareOption:r}=e,{t:o}=orderlyI18n.useTranslation(),a=f.useMemo(()=>{switch(t){case "openPrice":return o("share.pnl.optionalInfo.openPrice");case "closePrice":return o("share.pnl.optionalInfo.closePrice");case "openTime":return o("share.pnl.optionalInfo.openTime");case "closeTime":return o("share.pnl.optionalInfo.closeTime");case "markPrice":return o("common.markPrice");case "quantity":return o("common.quantity");case "leverage":return o("common.leverage")}},[t,o]),l=n.has(t);return jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gap:1,className:orderlyUi.cn("hover:oui-cursor-pointer"),onClick:()=>{r(u=>{let s=new Set(u);return l?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx(oe,{size:16,checked:l,className:"oui-pt-[2px]",onCheckedChange:u=>{r(s=>{let c=new Set(s);return l?c.delete(t):c.add(t),c});}}),jsxRuntime.jsx(orderlyUi.Text,{size:"xs",intensity:54,children:a})]})};var Le=e=>{let{type:t,curType:n,setPnlFormat:r}=e,{t:o}=orderlyI18n.useTranslation(),a=f.useMemo(()=>{switch(t){case "roi_pnl":return o("share.pnl.displayFormat.roi&Pnl");case "roi":return o("share.pnl.displayFormat.roi");case "pnl":return o("share.pnl.displayFormat.pnl")}},[t,o]),l=t===n,u="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return l?u+=" oui-text-base-contrast":u+="",jsxRuntime.jsxs("div",{className:u,onClick:()=>{r(t);},children:[jsxRuntime.jsx(Tt,{sel:l}),jsxRuntime.jsx(orderlyUi.Text,{size:"xs",intensity:54,className:orderlyUi.cn("oui-ml-2 "),children:a})]})},Tt=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===true?jsxRuntime.jsx(Ft,{}):jsxRuntime.jsx(Lt,{})}),Ft=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-primary-darken",children:[jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.333"})]}),Lt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".54"})});var Ae=e=>{let{shareOptions:t}=e,{t:n}=orderlyI18n.useTranslation(),r=te(),a=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[l,u]=f.useState(a.length==1?a[0]:r.pnlFormat),[s,c]=f.useState(new Set(r.options)),[i,d]=f.useState(r.bgIndex),[h,O]=f.useState(r.message),[S,b]=f.useState(false),{backgroundImages:W,...I}=t??{backgroundImages:[]},[z,w]=f.useState(""),v=f.useRef(null);f.useEffect(()=>{let N=window.location.hostname;w(N);},[]);let D=f.useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),$=j(e.entity,S?h:"",z,l,s,e.baseDp,e.quoteDp,e.referral),V=()=>{v.current?.copy().then(()=>{e.hide?.(),orderlyUi.toast.success(n("share.pnl.image.copied"));}).catch(N=>{orderlyUi.toast.error(()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{children:n("common.copy.failed")}),jsxRuntime.jsx("div",{className:"oui-mt-2 oui-max-w-[396px] oui-text-2xs oui-text-base-contrast-54",children:n("share.pnl.copy.failed.description")})]}));});},g=()=>{v.current?.download("Poster.png"),e.hide?.();},ne=f.useMemo(()=>["openPrice","closePrice","markPrice","openTime","closeTime","leverage","quantity"].filter(T=>!!e.entity[T]),[e.entity]);return ee(l,s,i,h),jsxRuntime.jsxs("div",{className:"oui-relative oui-flex oui-size-full oui-flex-col",children:[jsxRuntime.jsxs("div",{className:"oui-h-full oui-flex-1 oui-overflow-y-auto",children:[jsxRuntime.jsxs(orderlyUi.Box,{mt:9,height:422,children:[jsxRuntime.jsx(orderlyUi.Flex,{itemAlign:"center",justify:"center",children:jsxRuntime.jsx(K,{width:552,height:310,data:{backgroundImg:D,...I,data:$},ratio:3,ref:v})}),jsxRuntime.jsx(Ie,{backgroundImages:t?.backgroundImages??orderlyTypes.EMPTY_LIST,selectedSnap:i,setSelectedSnap:d})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:n("share.pnl.displayFormat")}),jsxRuntime.jsx(orderlyUi.Flex,{pt:3,gap:3,itemAlign:"center",children:a.map((N,T)=>jsxRuntime.jsx(Le,{setPnlFormat:u,type:N,curType:l},T))}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full oui-border-white/10 oui-pt-6"}),jsxRuntime.jsxs(orderlyUi.Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"sm",intensity:80,children:n("share.pnl.optionalInfo")}),jsxRuntime.jsx(orderlyUi.Flex,{mt:3,gap:4,className:"oui-flex-wrap",children:ne.map((N,T)=>jsxRuntime.jsx(Fe,{setShareOption:c,type:N,curType:s},T))})]}),jsxRuntime.jsx(De,{message:h,setMessage:O,check:S,setCheck:b})]})]}),jsxRuntime.jsx(Se,{onClickCopy:V,onClickDownload:g})]})};var Ee=f__default.default.createContext(null);function B(){let e=f__default.default.useContext(Ee);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var ie=f__default.default.forwardRef((e,t)=>{let{orientation:n="horizontal",opts:r,setApi:o,plugins:a,className:l,children:u,...s}=e,[c,i]=orderlyUi.useEmblaCarousel({...r,axis:n==="horizontal"?"x":"y"},a),[d,h]=f__default.default.useState(false),[O,S]=f__default.default.useState(false),[b,W]=f__default.default.useState(s.initIndex||0),[I,z]=f__default.default.useState([]),w=f__default.default.useCallback(g=>{g&&(I.length===0&&z(g.scrollSnapList()),W(g.selectedScrollSnap()),h(g.canScrollPrev()),S(g.canScrollNext()));},[I]),v=f__default.default.useCallback(()=>{i?.scrollPrev();},[i]),D=f__default.default.useCallback(()=>{i?.scrollNext();},[i]),$=f__default.default.useCallback(g=>{g.key==="ArrowLeft"?(g.preventDefault(),v()):g.key==="ArrowRight"&&(g.preventDefault(),D());},[v,D]);f__default.default.useEffect(()=>{!i||!o||o(i);},[i,o]),f__default.default.useEffect(()=>{if(i)return w(i),i.on("reInit",w),i.on("select",w),s.initIndex&&i.scrollTo(s.initIndex),()=>{i?.off("select",w);}},[i,w]);let V=f__default.default.useMemo(()=>({carouselRef:c,api:i,opts:r,orientation:n||(r?.axis==="y"?"vertical":"horizontal"),scrollPrev:v,scrollNext:D,canScrollPrev:d,canScrollNext:O,selectedIndex:b,scrollSnaps:I}),[c,i,r,n,v,D,d,O,b,I]);return jsxRuntime.jsx(Ee.Provider,{value:V,children:jsxRuntime.jsx("div",{ref:t,onKeyDownCapture:$,className:orderlyUi.cn("oui-relative",l),role:"region","aria-roledescription":"carousel",...s,children:u})})});ie.displayName="Carousel";var Y=f__default.default.forwardRef((e,t)=>{let{className:n,children:r,...o}=e,{carouselRef:a,orientation:l}=B();return jsxRuntime.jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsxRuntime.jsx("div",{ref:t,className:orderlyUi.cn("oui-flex",l==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",n),...o,children:r})})});Y.displayName="CarouselContent";var G=f__default.default.forwardRef((e,t)=>{let{className:n,children:r,...o}=e,{orientation:a}=B();return jsxRuntime.jsx("div",{ref:t,role:"group","aria-roledescription":"slide",className:orderlyUi.cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",n),...o,children:r})});G.displayName="CarouselItem";var le=f__default.default.forwardRef((e,t)=>{let{className:n,variant:r="contained",size:o="icon",...a}=e,{orientation:l,scrollPrev:u,canScrollPrev:s}=B();return jsxRuntime.jsxs(orderlyUi.Button,{ref:t,variant:r,className:orderlyUi.cn("oui-absolute oui-size-8 oui-rounded-full",l==="horizontal"?"oui--left-12 oui-top-1/2 oui--translate-y-1/2":"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",n),disabled:!s,onClick:u,...a,children:[jsxRuntime.jsx(orderlyUi.ChevronLeftIcon,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});le.displayName="CarouselPrevious";var ce=f__default.default.forwardRef((e,t)=>{let{className:n,variant:r="contained",size:o="icon",...a}=e,{orientation:l,scrollNext:u,canScrollNext:s}=B();return jsxRuntime.jsxs(orderlyUi.Button,{ref:t,variant:r,className:orderlyUi.cn("oui-absolute oui-size-8 oui-rounded-full",l==="horizontal"?"oui--right-12 oui-top-1/2 oui--translate-y-1/2":"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",n),disabled:!s,onClick:u,...a,children:[jsxRuntime.jsx(orderlyUi.ChevronRightIcon,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ce.displayName="CarouselNext";var ue=e=>{let{scrollSnaps:t,selectedIndex:n}=B();return jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-flex oui-gap-1",e.className),children:t.map((r,o)=>jsxRuntime.jsx(me,{index:o,active:o===n,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},o))})};ue.displayName="CarouselIdentifier";var me=({index:e,active:t,onClick:n,className:r,activeClassName:o})=>jsxRuntime.jsx("button",{onClick:()=>n?.(e),className:orderlyUi.cn("oui-size-2 oui-rounded-full oui-bg-white/30",r,t&&`active ${o||"oui-bg-primary-darken"}`)});var M=ie;M.Content=Y;M.Item=G;M.Next=ce;M.Previous=le;M.indentify=ue;var _e=e=>{let{shareOptions:t}=e,{t:n}=orderlyI18n.useTranslation(),r=te(),a=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[l,u]=f.useState(a.length==1?a[0]:r.pnlFormat),[s,c]=f.useState(new Set(r.options)),[i,d]=f.useState(r.message),[h,O]=f.useState(r.bgIndex),{backgroundImages:S,...b}=t??{backgroundImages:[]},[W,I]=f.useState(""),z=t?.backgroundImages?.map(()=>f.useRef(null));f.useEffect(()=>{let p=window.location.hostname;I(p);},[]);let w=j(e.entity,i,W,l,s,e.baseDp,e.quoteDp,e.referral),v=f.useRef(),D=552/310,[$,V]=f.useState(1),[g,ne]=f.useState(0),[N,T]=f.useState(false),Ce=f.useRef(null);f.useEffect(()=>{if(v.current){let p=v.current.offsetWidth,C=p/D;ne(C),V(p/552);}},[v,W]);let Ve=async p=>{if(!p.current)return;let C=p.current?.toDataURL(),Je=Zt(C);try{navigator.share&&await navigator.share({text:i,files:[new File([Je],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}},Ke=f.useMemo(()=>["openPrice","closePrice","openTime","closeTime","leverage","markPrice","quantity"].filter(C=>!!e.entity[C]),[e.entity]);return ee(l,s,h,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:v,className:"oui-mt-4 oui-w-full oui-overflow-hidden",style:{height:`${g+20}px`},children:jsxRuntime.jsxs(M,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:h,children:[jsxRuntime.jsx(Y,{style:{height:`${g}px`},children:t?.backgroundImages?.map((p,C)=>jsxRuntime.jsx(G,{children:jsxRuntime.jsx(K,{className:"oui-origin-top-left oui-transform",style:{scale:`${$}`},width:552,height:310,data:{backgroundImg:p,...b,data:w},ratio:3,ref:z?.[C]})},C))}),jsxRuntime.jsx("div",{className:"oui-mb-1 oui-mt-2 oui-flex oui-justify-center",children:jsxRuntime.jsx(Yt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary-darken oui-w-[20px]",setSelectIndex:O})})]})}),jsxRuntime.jsxs(orderlyUi.ScrollArea,{className:"oui-custom-scrollbar oui-max-h-[200px] oui-overflow-y-auto",children:[jsxRuntime.jsxs("div",{className:"oui-mt-4",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.displayFormat")}),jsxRuntime.jsx("div",{className:"oui-row-span-1 oui-grid oui-grid-cols-3 oui-justify-between oui-gap-3 oui-px-1 oui-pt-3",children:a.map((p,C)=>jsxRuntime.jsx(Kt,{setPnlFormat:u,type:p,curType:l},C))})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.optionalInfo")}),jsxRuntime.jsx("div",{className:"oui-mt-3 oui-flex oui-flex-wrap oui-gap-3",children:Ke.map((p,C)=>jsxRuntime.jsx(Jt,{setShareOption:c,type:p,curType:s},C))})]}),jsxRuntime.jsxs("div",{className:"oui-mb-8 oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.optionalInfo.message")}),jsxRuntime.jsx("div",{className:"oui-bg-base-600 oui-mx-1 oui-mt-3 oui-h-[48px]",children:jsxRuntime.jsx(orderlyUi.Input,{placeholder:n("share.pnl.optionalInfo.message.placeholder"),containerClassName:"oui-bg-transparent oui-h-[48px]",value:i,autoFocus:false,onChange:p=>{if(p.target.value.length>25){orderlyUi.toast.error(n("share.pnl.optionalInfo.message.maxLength"));return}d(p.target.value);},ref:Ce,onFocus:()=>T(true),onBlur:()=>T(false),suffix:N&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:p=>{d(""),setTimeout(()=>{Ce.current?.focus();},50),p.stopPropagation();},children:jsxRuntime.jsx(orderlyUi.CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsxRuntime.jsx("div",{className:"oui-pt-2",children:jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let p=z?.[h];p&&Ve(p);},children:n("common.share")})})]})},Kt=e=>{let{type:t,curType:n,setPnlFormat:r}=e,{t:o}=orderlyI18n.useTranslation(),a=f.useMemo(()=>{switch(t){case "roi_pnl":return o("share.pnl.displayFormat.roi&Pnl");case "roi":return o("share.pnl.displayFormat.roi");case "pnl":return o("share.pnl.displayFormat.pnl")}},[t]);return jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-referral-shadow oui-flex oui-h-[46px] oui-flex-1 oui-items-center oui-rounded-lg oui-bg-base-4 oui-px-3 oui-shadow-lg hover:oui-cursor-pointer",t===n&&"oui-dot-sel oui-bg-primary-darken"),onClick:()=>{r(t);},children:jsxRuntime.jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:a})})},Jt=e=>{let{type:t,curType:n,setShareOption:r}=e,{t:o}=orderlyI18n.useTranslation(),a=f.useMemo(()=>{switch(t){case "openPrice":return o("share.pnl.optionalInfo.openPrice");case "closePrice":return o("share.pnl.optionalInfo.closePrice");case "openTime":return o("share.pnl.optionalInfo.openTime");case "closeTime":return o("share.pnl.optionalInfo.closeTime");case "markPrice":return o("common.markPrice");case "quantity":return o("common.quantity");case "leverage":return o("common.leverage")}},[t,o]),l=n.has(t);return jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-referral-shadow oui-mt-0 oui-flex oui-h-[46px] oui-w-[calc(50%-6px)] oui-items-center oui-rounded-lg oui-bg-base-4 oui-p-3 oui-shadow-lg hover:oui-cursor-pointer"),onClick:()=>{r(u=>{let s=new Set(u);return l?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx("div",{className:"oui-flex-1 oui-text-sm oui-text-base-contrast",children:a}),l&&jsxRuntime.jsx(Gt,{})]})};function Zt(e){let t=atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(t.length),o=new Uint8Array(r);for(let a=0;a<t.length;a++)o[a]=t.charCodeAt(a);return new Blob([r],{type:n})}var Yt=e=>{let{scrollSnaps:t,selectedIndex:n}=B();return f.useEffect(()=>{e.setSelectIndex(n);},[n]),jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-flex oui-gap-1"),children:t.map((r,o)=>jsxRuntime.jsx(me,{index:o,active:o===n,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},o))})},Gt=()=>jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z",fill:"white",fillOpacity:"1"})});var qe=e=>{let{entity:t,baseDp:n,quoteDp:r,referralInfo:o,shareOptions:a,hide:l}=e;return !a||!t?null:jsxRuntime.jsx(Ae,{entity:t,hide:l,baseDp:n,quoteDp:r,referral:o,shareOptions:a})},Ue=e=>{let{entity:t,baseDp:n,quoteDp:r,referralInfo:o,shareOptions:a,hide:l}=e;return !a||!t?null:jsxRuntime.jsx(_e,{entity:t,hide:l,baseDp:n,quoteDp:r,referral:o,shareOptions:a})};var ye=e=>{let t=Q({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(Ue,{...t})},ve=e=>{let t=Q({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(qe,{...t})};var eo="sharePnLDialog",to="sharePnLBottomSheet";orderlyUi.registerSimpleDialog(eo,ve,{classNames:{content:"!oui-max-w-[624px] oui-p-0"}});orderlyUi.registerSimpleSheet(to,ye,{title:orderlyI18n.i18n.t("share.pnl.sharePnl"),classNames:{body:"oui-pb-4 oui-pt-0"}});
16
+
17
+ exports.SharePnLBottomSheetId = to;
18
+ exports.SharePnLBottomSheetWidget = ye;
19
+ exports.SharePnLDialogId = eo;
20
+ exports.SharePnLDialogWidget = ve;
21
+ exports.useSharePnLScript = Q;
22
+ //# sourceMappingURL=out.js.map
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/sharePnL/sharePnL.script.tsx","../src/sharePnL/desktop/content.tsx","../src/sharePnL/poster/poster.tsx","../src/sharePnL/utils/utils.tsx","../src/sharePnL/desktop/bottomBtns.tsx","../src/sharePnL/desktop/carousel.tsx","../src/sharePnL/desktop/buttons.tsx","../src/sharePnL/desktop/message.tsx","../src/sharePnL/desktop/checkbox.tsx","../src/sharePnL/desktop/options.tsx","../src/sharePnL/desktop/pnlFormat.tsx","../src/sharePnL/mobile/content.tsx","../src/sharePnL/carousel/carousel.tsx","../src/sharePnL/carousel/index.tsx","../src/sharePnL/sharePnL.ui.tsx","../src/sharePnL/sharePnL.widget.tsx"],"names":["registerSimpleDialog","registerSimpleSheet","useMemo","useReferralInfo","useSymbolsInfo","useSharePnLScript","props","pnl","hide","entity","symbolInfo","getFirstRefCode","referralInfo","code","base_dp","quote_dp","useEffect","useRef","useState","useTranslation","EMPTY_LIST","Divider","Flex","toast","Text","Box","forwardRef","useImperativeHandle","usePoster","jsx","Poster","parentRef","width","height","className","data","style","ref","download","toDataURL","copy","toBlob","Decimal","getPnLPosterData","position","message","domain","pnlType","options","baseDp","quoteDp","referral","t","symbol","currency","processSymbol","positionData","informations","key","formatFixed","formatOpenTime","formatShareTime","tokens","symbol1","symbol2","symbol3","input","date","formattedParts","year","part","month","day","hour","minute","value","dp","savePnlInfo","format","bgIndex","getPnlInfo","str","Button","jsxs","BottomButtons","onClickDownload","onClickCopy","DownloadIcon","CopyIcon","useCallback","cn","useEmblaCarousel","PrevButton","children","restProps","NextButton","CarouselBackgroundImage","backgroundImages","selectedSnap","setSelectedSnap","emblaRef","emblaApi","onPrevButtonClick","onNextButtonClick","onSelect","e","index","CloseCircleFillIcon","Input","Checkbox","size","Message","setMessage","check","setCheck","focus","setFocus","inputRef","ShareOption","type","curType","setShareOption","text","isSelected","updateSet","checked","PnlFormatView","setPnlFormat","clsName","RadioButton","SelIcon","UnselIcon","DesktopSharePnLContent","shareOptions","localPnlConfig","formats","pnlFormat","shareOption","resetOptions","setDomain","posterRef","currentDomain","curBgImg","posterData","onCopy","onDownload","item","ScrollArea","React","ChevronLeftIcon","ChevronRightIcon","CarouselContext","useCarousel","context","Carousel","originalProps","orientation","opts","setApi","plugins","carouselRef","api","canScrollPrev","setCanScrollPrev","canScrollNext","setCanScrollNext","selectedIndex","setSelectedIndex","scrollSnaps","setScrollSnaps","scrollPrev","scrollNext","handleKeyDown","event","memoizedValue","CarouselContent","CarouselItem","CarouselPrevious","variant","CarouselNext","CarouselIdentifier","_","Dot","active","onClick","activeClassName","MobileSharePnLContent","selectIndex","setSelectIndex","posterRefs","aspectRatio","scale","setScale","carouselHeight","setCarouselHeight","divWidth","divHeight","onSharePnL","blob","dataURItoBlob","MyIdentifier","ChoicesFillIcon","dataURI","byteString","mimeString","ab","ia","i","DesktopSharePnL","MobileSharePnL","SharePnLBottomSheetWidget","state","SharePnLDialogWidget","i18n","SharePnLDialogId","SharePnLBottomSheetId"],"mappings":"AAAA,OAAS,wBAAAA,GAAsB,uBAAAC,OAA2B,6BCA1D,OAAS,WAAAC,OAAe,QACxB,OAAS,mBAAAC,GAAiB,kBAAAC,OAAsB,gCAGzC,IAAMC,EAAqBC,GAG5B,CACJ,GAAM,CAAE,IAAAC,EAAK,KAAAC,CAAK,EAAIF,EAChBG,EAASF,GAAK,OACdG,EAAaN,GAAe,EAC5B,CAAE,gBAAAO,CAAgB,EAAIR,GAAgB,EACtCS,EAAeV,GAAQ,IAAgC,CAC3D,IAAMW,EAAOF,EAAgB,GAAG,KAMhC,MALa,CACX,KAAMJ,GAAK,SAAWM,EACtB,OAAQN,GAAK,UACb,KAAMA,GAAK,OACb,CAEF,EAAG,CAACI,EAAiBJ,CAAG,CAAC,EAQnBO,EAAUZ,GAAQ,IAAM,CAC5B,GAAKO,EACL,OAAOC,EAAWD,GAAQ,MAAM,EAAE,SAAS,CAC7C,EAAG,CAACA,EAAQC,CAAU,CAAC,EACjBK,EAAWb,GAAQ,IAAM,CAC7B,GAAKO,EACL,OAAOC,EAAWD,GAAQ,MAAM,EAAE,UAAU,CAC9C,EAAG,CAACA,EAAQC,CAAU,CAAC,EAEvB,MAAO,CACL,OAAAD,EACA,OAAQK,EACR,QAASC,EACT,aAAAH,EACA,aAAcL,EACd,KAAA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BAErB,IAAMC,GAAmB,iBACnBC,GAAwB,sBAE9BvN,GAAqBsN,GAAkBF,GAAsB,CAC3D,WAAY,CACV,QAAS,4BACX,CACF,CAAC,EAEDnN,GAAoBsN,GAAuBL,GAA2B,CACpE,MAAOG,GAAK,EAAE,oBAAoB,EAClC,WAAY,CACV,KAAM,mBACR,CACF,CAAC","sourcesContent":["import { registerSimpleDialog, registerSimpleSheet } from \"@kodiak-finance/orderly-ui\";\nimport {\n SharePnLDialogWidget,\n SharePnLBottomSheetWidget,\n} from \"./sharePnL/sharePnL.widget\";\nimport { i18n } from \"@kodiak-finance/orderly-i18n\";\n\nconst SharePnLDialogId = \"sharePnLDialog\";\nconst SharePnLBottomSheetId = \"sharePnLBottomSheet\";\n\nregisterSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {\n classNames: {\n content: \"!oui-max-w-[624px] oui-p-0\",\n },\n});\n\nregisterSimpleSheet(SharePnLBottomSheetId, SharePnLBottomSheetWidget, {\n title: i18n.t(\"share.pnl.sharePnl\"),\n classNames: {\n body: \"oui-pb-4 oui-pt-0\",\n },\n});\n\nexport * from \"./sharePnL\";\nexport { SharePnLDialogId, SharePnLBottomSheetId };\nexport type {\n SharePnLConfig,\n SharePnLOptions,\n SharePnLParams,\n} from \"./types/types\";\n","import { useMemo } from \"react\";\nimport { useReferralInfo, useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { ReferralType, SharePnLOptions, SharePnLParams } from \"../types/types\";\n\nexport const useSharePnLScript = (props: {\n pnl?: SharePnLOptions & SharePnLParams;\n hide?: () => void;\n}) => {\n const { pnl, hide } = props;\n const entity = pnl?.entity;\n const symbolInfo = useSymbolsInfo();\n const { getFirstRefCode } = useReferralInfo();\n const referralInfo = useMemo((): ReferralType | undefined => {\n const code = getFirstRefCode()?.code;\n const info = {\n code: pnl?.refCode ?? code,\n slogan: pnl?.refSlogan,\n link: pnl?.refLink,\n };\n return info;\n }, [getFirstRefCode, pnl]);\n\n // print warning if entity is null\n if (!entity) {\n console.warn(\"Entity is null, the share pnl will not be displayed\");\n }\n\n // convert base_dp and quote_dp useMemo\n const base_dp = useMemo(() => {\n if (!entity) return undefined;\n return symbolInfo[entity?.symbol](\"base_dp\");\n }, [entity, symbolInfo]);\n const quote_dp = useMemo(() => {\n if (!entity) return undefined;\n return symbolInfo[entity?.symbol](\"quote_dp\");\n }, [entity, symbolInfo]);\n\n return {\n entity,\n baseDp: base_dp,\n quoteDp: quote_dp,\n referralInfo,\n shareOptions: pnl as SharePnLOptions,\n hide,\n };\n};\n\nexport type SharePnLState = ReturnType<typeof useSharePnLScript>;\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { EMPTY_LIST } from \"@kodiak-finance/orderly-types\";\nimport { Divider, Flex, toast, Text, Box } from \"@kodiak-finance/orderly-ui\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLOptions,\n} from \"../../types/types\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport { BottomButtons } from \"./bottomBtns\";\nimport { CarouselBackgroundImage } from \"./carousel\";\nimport { Message } from \"./message\";\nimport { ShareOption } from \"./options\";\nimport { PnlFormatView } from \"./pnlFormat\";\n\nexport const DesktopSharePnLContent: FC<{\n entity: ShareEntity;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLOptions;\n}> = (props) => {\n const { shareOptions } = props;\n const { t } = useTranslation();\n\n const localPnlConfig = getPnlInfo();\n const hasRoiAndPnl = props.entity.roi != null && props.entity.pnl != null;\n const formats: PnLDisplayFormat[] = hasRoiAndPnl\n ? [\"roi_pnl\", \"roi\", \"pnl\"]\n : props.entity.roi != null\n ? [\"roi\"]\n : props.entity.pnl != null\n ? [\"pnl\"]\n : [];\n\n const [pnlFormat, setPnlFormat] = useState<PnLDisplayFormat>(\n formats.length == 1 ? formats[0] : localPnlConfig.pnlFormat,\n );\n const [shareOption, setShareOption] = useState<Set<ShareOptions>>(\n new Set(localPnlConfig.options),\n );\n const [selectedSnap, setSelectedSnap] = useState(localPnlConfig.bgIndex);\n const [message, setMessage] = useState(localPnlConfig.message);\n const [check, setCheck] = useState(false);\n const { backgroundImages, ...resetOptions } = shareOptions ?? {\n backgroundImages: [],\n };\n\n const [domain, setDomain] = useState(\"\");\n\n const posterRef = useRef<PosterRef | null>(null);\n\n useEffect(() => {\n const currentDomain = window.location.hostname;\n setDomain(currentDomain);\n }, []);\n\n const curBgImg = useMemo(() => {\n return shareOptions?.backgroundImages?.[selectedSnap];\n }, [shareOptions?.backgroundImages, selectedSnap]);\n\n const posterData = getPnLPosterData(\n props.entity,\n check ? message : \"\",\n domain,\n pnlFormat,\n shareOption,\n props.baseDp,\n props.quoteDp,\n props.referral,\n );\n\n const onCopy = () => {\n posterRef.current\n ?.copy()\n .then(() => {\n props.hide?.();\n toast.success(t(\"share.pnl.image.copied\"));\n })\n .catch((e: any) => {\n toast.error(() => {\n return (\n <div>\n <div>{t(\"common.copy.failed\")}</div>\n <div className=\"oui-mt-2 oui-max-w-[396px] oui-text-2xs oui-text-base-contrast-54\">\n {t(\"share.pnl.copy.failed.description\")}\n </div>\n </div>\n );\n });\n });\n };\n const onDownload = () => {\n posterRef.current?.download(\"Poster.png\");\n props.hide?.();\n };\n\n // check if the entity has the option, like formats\n const options: ShareOptions[] = useMemo(() => {\n const mapping: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"markPrice\",\n \"openTime\",\n \"closeTime\",\n \"leverage\",\n \"quantity\",\n ];\n\n return mapping.filter((key) => !!props.entity[key]);\n }, [props.entity]);\n\n savePnlInfo(pnlFormat, shareOption, selectedSnap, message);\n\n return (\n <div className=\"oui-relative oui-flex oui-size-full oui-flex-col\">\n <div className=\"oui-h-full oui-flex-1 oui-overflow-y-auto\">\n <Box mt={9} height={422}>\n <Flex itemAlign={\"center\"} justify={\"center\"}>\n <Poster\n // className=\"oui-mx-11\"\n width={552}\n height={310}\n data={{\n backgroundImg: curBgImg,\n ...resetOptions,\n data: posterData,\n }}\n ratio={3}\n ref={posterRef}\n />\n </Flex>\n <CarouselBackgroundImage\n backgroundImages={shareOptions?.backgroundImages ?? EMPTY_LIST}\n selectedSnap={selectedSnap}\n setSelectedSnap={setSelectedSnap}\n />\n </Box>\n\n <Flex\n direction={\"column\"}\n px={10}\n mt={6}\n justify={\"start\"}\n itemAlign={\"start\"}\n width={\"100%\"}\n >\n <Text size=\"sm\" intensity={80}>\n {t(\"share.pnl.displayFormat\")}\n </Text>\n <Flex pt={3} gap={3} itemAlign={\"center\"}>\n {formats.map((e, index) => (\n <PnlFormatView\n key={index}\n setPnlFormat={setPnlFormat}\n type={e}\n curType={pnlFormat}\n />\n ))}\n </Flex>\n\n <Divider className=\"oui-w-full oui-border-white/10 oui-pt-6\" />\n\n <Flex\n mt={6}\n direction={\"column\"}\n justify={\"start\"}\n itemAlign={\"start\"}\n >\n <Text size=\"sm\" intensity={80}>\n {t(\"share.pnl.optionalInfo\")}\n </Text>\n <Flex mt={3} gap={4} className=\"oui-flex-wrap\">\n {options.map((item, index) => (\n <ShareOption\n key={index}\n setShareOption={setShareOption}\n type={item}\n curType={shareOption}\n />\n ))}\n </Flex>\n </Flex>\n\n <Message\n message={message}\n setMessage={setMessage}\n check={check}\n setCheck={setCheck}\n />\n </Flex>\n </div>\n\n <BottomButtons onClickCopy={onCopy} onClickDownload={onDownload} />\n </div>\n );\n};\n","import { forwardRef, useImperativeHandle } from \"react\";\nimport { type DrawOptions, usePoster } from \"@kodiak-finance/orderly-hooks\";\n\nexport type PosterProps = {\n width: number;\n height: number;\n className?: string;\n ratio?: number;\n data: DrawOptions;\n style?: React.CSSProperties;\n};\n\nexport type PosterRef = {\n download: (filename: string, type?: string, encoderOptions?: number) => void;\n toDataURL: (type?: string, encoderOptions?: number) => string;\n toBlob: (type?: string, encoderOptions?: number) => Promise<Blob | null>;\n copy: () => Promise<void>;\n};\n\nexport const Poster = forwardRef<PosterRef, PosterProps>((props, parentRef) => {\n const { width, height, className, data, style } = props;\n\n const { ref, download, toDataURL, copy, toBlob } = usePoster(data, {\n ratio: props.ratio,\n });\n\n useImperativeHandle(parentRef, () => ({\n download,\n toDataURL,\n toBlob,\n copy,\n }));\n\n return (\n <canvas\n ref={ref}\n width={width}\n height={height}\n className={className}\n style={style}\n />\n );\n});\n","/*\n{\n message: \"I am the Orderly KING.\",\n domain: \"ordely.network\",\n updateTime: \"2022-JAN-01 23:23\",\n position: {\n symbol: \"BTC-PERP\",\n currency: \"USDC\",\n side: \"LONG\",\n leverage: 20,\n pnl: 10432.23,\n ROI: 20.25,\n informations: [\n { title: \"Open Price\", value: 0.12313 },\n { title: \"Opened at\", value: \"Jan-01 23:23\" },\n { title: \"Mark price\", value: \"0.12341\" },\n { title: \"Quantity\", value: \"0.123\" },\n ],\n },\n referral: {\n code: \"WRECKED\",\n link: \"https://orderly.network\",\n slogan: \"Try Orderly now with:\",\n }\n }\n*/\n// import { PnLDisplayFormat, ShareOptions } from \"./type\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { PnLDisplayFormat, ShareEntity, ShareOptions } from \"../../types/types\";\n\nexport type ReferralType = {\n code?: string;\n link?: string;\n slogan?: string;\n};\n\nexport function getPnLPosterData(\n position: ShareEntity,\n message: string,\n domain: string,\n pnlType: PnLDisplayFormat,\n options: Set<ShareOptions>,\n baseDp?: number,\n quoteDp?: number,\n referral?: ReferralType,\n) {\n const { t } = useTranslation();\n const { symbol, currency } = processSymbol(position.symbol);\n const positionData: any = {\n symbol,\n currency,\n side: position.side,\n };\n\n switch (pnlType) {\n case \"pnl\": {\n if (position.pnl != null) {\n positionData[\"pnl\"] = new Decimal(position.pnl).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n case \"roi\": {\n if (position.roi != null) {\n positionData[\"ROI\"] = new Decimal(position.roi).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n case \"roi_pnl\": {\n if (position.pnl != null) {\n positionData[\"pnl\"] = new Decimal(position.pnl).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n if (position.roi != null) {\n positionData[\"ROI\"] = new Decimal(position.roi).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n }\n\n const informations: { title: string; value: any }[] = [];\n\n if (options.has(\"leverage\")) {\n positionData[\"leverage\"] = position.leverage;\n }\n const array: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"markPrice\",\n \"quantity\",\n ];\n array.forEach((key) => {\n if (options.has(key)) {\n switch (key) {\n case \"leverage\": {\n break;\n }\n case \"openPrice\": {\n if (position.openPrice != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.openPrice\"),\n value: formatFixed(position.openPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"closePrice\": {\n if (position.closePrice != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.closePrice\"),\n value: formatFixed(position.closePrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"openTime\": {\n if (position.openTime != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.openTime\"),\n value: formatOpenTime(position.openTime),\n });\n }\n break;\n }\n case \"closeTime\": {\n if (position.closeTime != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.closeTime\"),\n value: formatOpenTime(position.closeTime),\n });\n }\n break;\n }\n case \"markPrice\": {\n if (position.markPrice != null) {\n informations.push({\n title: t(\"common.markPrice\"),\n value: formatFixed(position.markPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"quantity\": {\n if (position.quantity != null) {\n informations.push({\n title: t(\"common.quantity\"),\n value: formatFixed(position.quantity, baseDp || 2),\n });\n }\n }\n default:\n break;\n }\n }\n });\n\n positionData[\"informations\"] = informations;\n\n const data: any = {\n position: positionData,\n updateTime: formatShareTime(new Date()),\n domain,\n };\n if (message.length > 0) {\n data[\"message\"] = message;\n }\n\n if (typeof referral !== \"undefined\" && referral[\"code\"] !== undefined) {\n data[\"referral\"] = referral;\n }\n\n return data;\n}\n\ninterface SymbolResult {\n symbol: string;\n currency: string;\n}\n\nfunction processSymbol(symbol: string): SymbolResult {\n const tokens = symbol.split(\"_\");\n if (tokens.length !== 3) {\n return {\n symbol: symbol,\n currency: \"USDC\",\n };\n }\n\n const [symbol1, symbol2, symbol3] = tokens;\n const formattedString = `${symbol2}-${symbol1}`;\n\n return {\n symbol: formattedString,\n currency: symbol3 || \"USDC\",\n };\n}\n\nfunction formatShareTime(input: number): string;\nfunction formatShareTime(input: Date): string;\nfunction formatShareTime(input: number | Date): string {\n const date = input instanceof Date ? input : new Date(input);\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n };\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", options);\n const formattedParts = formatter.formatToParts(date);\n\n // console.log(\"formattedParts\", formattedParts);\n\n const year = formattedParts.find((part) =>\n part.type === \"year\" ? part.value : \"\",\n )?.value;\n const month = formattedParts.find((part) =>\n part.type === \"month\" ? part.value : \"\",\n )?.value;\n const day = formattedParts.find((part) =>\n part.type === \"day\" ? part.value : \"\",\n )?.value;\n const hour = formattedParts.find((part) =>\n part.type === \"hour\" ? part.value : \"\",\n )?.value;\n const minute = formattedParts.find((part) =>\n part.type === \"minute\" ? part.value : \"\",\n )?.value;\n\n return `${year}-${month}-${day} ${hour}:${minute}`;\n}\n\nfunction formatOpenTime(input: number | Date): string {\n const date = input instanceof Date ? input : new Date(input);\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"short\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n };\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", options);\n const formattedParts = formatter.formatToParts(date);\n\n // console.log(\"formattedParts\", formattedParts);\n\n const month = formattedParts.find((part) =>\n part.type === \"month\" ? part.value : \"\",\n )?.value;\n const day = formattedParts.find((part) =>\n part.type === \"day\" ? part.value : \"\",\n )?.value;\n const hour = formattedParts.find((part) =>\n part.type === \"hour\" ? part.value : \"\",\n )?.value;\n const minute = formattedParts.find((part) =>\n part.type === \"minute\" ? part.value : \"\",\n )?.value;\n\n return `${month}-${day} ${hour}:${minute}`;\n}\n\nfunction formatFixed(value: number, dp: number) {\n return new Decimal(value).toFixed(dp, Decimal.ROUND_DOWN);\n}\n\nexport function savePnlInfo(\n format: PnLDisplayFormat,\n options: Set<ShareOptions>,\n bgIndex: number,\n message: string,\n) {\n localStorage.setItem(\n \"pnl_config_key\",\n JSON.stringify({\n bgIndex: bgIndex,\n pnlFormat: format,\n options: Array.from(options),\n message: message,\n }),\n );\n}\n\nexport function getPnlInfo(): {\n bgIndex: number;\n pnlFormat: PnLDisplayFormat;\n options: ShareOptions[];\n message: \"\";\n} {\n const str = localStorage.getItem(\"pnl_config_key\");\n\n if (str && str.length > 0) {\n try {\n const json = JSON.parse(str);\n\n return json;\n } catch (e) {}\n }\n return {\n bgIndex: 0,\n pnlFormat: \"roi_pnl\",\n options: [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"markPrice\",\n \"quantity\",\n \"leverage\",\n ],\n message: \"\",\n };\n}\n","import { FC } from \"react\";\nimport { Button, Flex } from \"@kodiak-finance/orderly-ui\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nexport const BottomButtons: FC<{\n onClickDownload: any;\n onClickCopy: any;\n}> = (props) => {\n const { onClickDownload, onClickCopy } = props;\n const { t } = useTranslation();\n\n return (\n <Flex px={8} gap={3} mt={3} itemAlign={\"center\"}>\n <Button\n color={\"secondary\"}\n className=\"oui-flex-1 oui-flex oui-gap-1\"\n onClick={onClickDownload}\n >\n <span>\n <DownloadIcon />\n </span>\n {t(\"common.download\")}\n </Button>\n\n <Button className=\"oui-flex-1 oui-flex oui-gap-1\" onClick={onClickCopy}>\n <span>\n <CopyIcon />\n </span>\n {t(\"common.copy\")}\n </Button>\n </Flex>\n );\n};\n\nconst DownloadIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667\"\n fill=\"#fff\"\n fillOpacity=\".98\"\n />\n </svg>\n );\n};\n\nconst CopyIcon = () => {\n return (\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z\"\n fill=\"#fff\"\n fillOpacity=\".98\"\n />\n </svg>\n );\n};\n","import { FC, useCallback, useEffect } from \"react\";\nimport { Box, cn, Flex, useEmblaCarousel } from \"@kodiak-finance/orderly-ui\";\nimport { NextButton, PrevButton } from \"./buttons\";\n\nexport const CarouselBackgroundImage: FC<{\n backgroundImages: ReadonlyArray<string> | string[];\n selectedSnap: number;\n setSelectedSnap: any;\n}> = (props) => {\n const { backgroundImages, selectedSnap, setSelectedSnap } = props;\n\n const [emblaRef, emblaApi] = useEmblaCarousel({\n // loop: true,\n containScroll: \"keepSnaps\",\n dragFree: true,\n });\n\n const onPrevButtonClick = useCallback(() => {\n if (!emblaApi) {\n return;\n }\n if (emblaApi?.canScrollPrev()) {\n emblaApi.scrollPrev();\n } else if (selectedSnap - 1 >= 0) {\n setSelectedSnap(selectedSnap - 1);\n }\n }, [emblaApi, selectedSnap]);\n\n const onNextButtonClick = useCallback(() => {\n if (!emblaApi) {\n return;\n }\n if (emblaApi?.canScrollNext()) {\n emblaApi.scrollNext();\n } else if (selectedSnap + 1 < backgroundImages.length) {\n setSelectedSnap(selectedSnap + 1);\n }\n }, [emblaApi, selectedSnap]);\n\n const onSelect = useCallback((emblaApi: any) => {\n // setPrevBtnDisabled(!emblaApi.canScrollPrev());\n // setNextBtnDisabled(!emblaApi.canScrollNext());\n setSelectedSnap(emblaApi.selectedScrollSnap());\n }, []);\n\n useEffect(() => {\n if (!emblaApi) {\n return;\n }\n onSelect(emblaApi);\n emblaApi.on(\"reInit\", onSelect);\n emblaApi.on(\"select\", onSelect);\n emblaApi?.scrollTo(selectedSnap);\n return () => {\n emblaApi.off(\"reInit\", onSelect);\n emblaApi.off(\"select\", onSelect);\n };\n }, [emblaApi, onSelect]);\n\n return (\n <Flex mt={4} px={2}>\n <PrevButton onClick={onPrevButtonClick} />\n <div\n ref={emblaRef}\n className=\"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0\"\n >\n <Flex>\n {backgroundImages.map((e, index) => (\n <Box\n key={e}\n onClick={() => {\n if (emblaApi?.canScrollPrev() || emblaApi?.canScrollNext()) {\n emblaApi?.scrollTo(index);\n } else {\n setSelectedSnap(index);\n }\n }}\n mx={2}\n my={1}\n mr={6}\n r=\"base\"\n className={cn(\n \"oui-shrink-0 oui-w-[162px]\",\n selectedSnap === index &&\n \"oui-outline oui-outline-1 oui-outline-primary-darken\",\n )}\n >\n <img src={e} className=\"oui-rounded-sm\" />\n </Box>\n ))}\n </Flex>\n </div>\n <NextButton onClick={onNextButtonClick} />\n </Flex>\n );\n};\n","import { FC, PropsWithChildren } from \"react\";\n\ntype PropType = PropsWithChildren<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >\n>;\n\nexport const PrevButton: FC<PropType> = (props) => {\n const { children, ...restProps } = props;\n\n return (\n <button {...restProps}>\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"20\" height=\"20\" rx=\"10\" fill=\"#333948\" />\n <path\n d=\"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n </button>\n );\n};\n\nexport const NextButton: FC<PropType> = (props) => {\n const { children, ...restProps } = props;\n\n return (\n <button {...restProps}>\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"20\" height=\"20\" rx=\"10\" fill=\"#333948\" />\n <path\n d=\"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n </button>\n );\n};\n","import { FC, useRef, useState } from \"react\";\nimport { CloseCircleFillIcon, Input, toast } from \"@kodiak-finance/orderly-ui\";\nimport { Checkbox } from \"./checkbox\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const Message: FC<{\n message: string;\n setMessage: any;\n check: boolean;\n setCheck: any;\n}> = (props) => {\n const { message, setMessage, check, setCheck } = props;\n const [focus, setFocus] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const { t } = useTranslation();\n\n return (\n <div className=\"oui-mt-3 oui-mb-6 oui-flex oui-items-center\">\n <Checkbox\n className=\"oui-mt-[2px]\"\n checked={check}\n onCheckedChange={(e: boolean) => {\n setCheck(e);\n }}\n />\n <div\n className=\"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer\"\n onClick={() => {\n setCheck(!props.check);\n }}\n >\n {t(\"share.pnl.optionalInfo.message\")}\n </div>\n <div className=\"oui-bg-base-900 oui-mx-2 oui-rounded-sm\">\n <Input\n ref={inputRef}\n placeholder={t(\"share.pnl.optionalInfo.message.placeholder\")}\n classNames={{\n root: \"oui-w-[320px]\",\n }}\n size=\"sm\"\n value={message}\n autoFocus={false}\n suffix={\n focus && (\n <button\n className=\"oui-mr-3 oui-cursor-pointer\"\n onMouseDown={(e) => {\n console.log(\"set message to empty\");\n\n setMessage(\"\");\n setTimeout(() => {\n inputRef.current?.focus();\n }, 50);\n e.stopPropagation();\n }}\n >\n <CloseCircleFillIcon size={18} color=\"white\" />\n </button>\n )\n }\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n onChange={(e) => {\n if (e.target.value.length > 25) {\n toast.error(t(\"share.pnl.optionalInfo.message.maxLength\"));\n return;\n }\n setCheck(e.target.value.length > 0);\n setMessage(e.target.value);\n }}\n />\n </div>\n </div>\n );\n};\n","export const Checkbox = (props: {\n size?: number;\n className?: string;\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n}) => {\n const { size = 16, className } = props;\n return (\n <button\n type=\"button\"\n onClick={(e) => {\n props.onCheckedChange(!props.checked);\n }}\n className={className}\n >\n {props.checked ? (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z\"\n fill=\"#fff\"\n fillOpacity=\".8\"\n />\n </svg>\n ) : (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333\"\n fill=\"#fff\"\n fillOpacity=\".8\"\n />\n </svg>\n )}\n </button>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { ShareOptions } from \"../../types/types\";\nimport { Flex, Text, cn } from \"@kodiak-finance/orderly-ui\";\nimport { Checkbox } from \"./checkbox\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return t(\"share.pnl.optionalInfo.openPrice\");\n case \"closePrice\":\n return t(\"share.pnl.optionalInfo.closePrice\");\n case \"openTime\":\n return t(\"share.pnl.optionalInfo.openTime\");\n case \"closeTime\":\n return t(\"share.pnl.optionalInfo.closeTime\");\n case \"markPrice\":\n return t(\"common.markPrice\");\n case \"quantity\":\n return t(\"common.quantity\");\n case \"leverage\":\n return t(\"common.leverage\");\n }\n }, [type, t]);\n\n const isSelected = curType.has(type);\n\n return (\n <Flex\n itemAlign={\"center\"}\n gap={1}\n className={cn(\"hover:oui-cursor-pointer\")}\n onClick={() => {\n // setPnlFormat(type);\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n >\n <Checkbox\n size={16}\n checked={isSelected}\n className=\"oui-pt-[2px]\"\n onCheckedChange={(checked: boolean) => {\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n />\n\n <Text size=\"xs\" intensity={54}>\n {text}\n </Text>\n </Flex>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { PnLDisplayFormat } from \"../../types/types\";\nimport { Text, cn } from \"@kodiak-finance/orderly-ui\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nexport const PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return t(\"share.pnl.displayFormat.roi&Pnl\");\n case \"roi\":\n return t(\"share.pnl.displayFormat.roi\");\n case \"pnl\":\n return t(\"share.pnl.displayFormat.pnl\");\n }\n }, [type, t]);\n\n const isSelected = type === curType;\n\n let clsName = \"oui-flex oui-items-center oui-gap-1 oui-cursor-pointer\";\n if (isSelected) {\n clsName += \" oui-text-base-contrast\";\n } else {\n clsName += \"\";\n }\n\n return (\n <div\n className={clsName}\n onClick={() => {\n setPnlFormat(type);\n }}\n >\n <RadioButton sel={isSelected} />\n <Text\n size=\"xs\"\n intensity={54}\n className={cn(\n \"oui-ml-2 \"\n // isSelected && \"oui-text-base-contrast\"\n )}\n >\n {text}\n </Text>\n </div>\n );\n};\n\nconst RadioButton = (props: {\n sel?: boolean;\n // onChange?: (sel: boolean) => void;\n}) => {\n return (\n <button\n type=\"button\"\n // onClick={(e) => {\n // e.stopPropagation();\n // }}\n >\n {props.sel === true ? <SelIcon /> : <UnselIcon />}\n </button>\n );\n};\n\nconst SelIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"oui-fill-primary-darken\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".36\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"3.333\" />\n </svg>\n );\n};\n\nconst UnselIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n );\n};\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n Button,\n CloseCircleFillIcon,\n cn,\n Input,\n ScrollArea,\n toast,\n} from \"@kodiak-finance/orderly-ui\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLOptions,\n} from \"../../types/types\";\nimport { Carousel } from \"../carousel\";\nimport {\n CarouselContent,\n CarouselItem,\n Dot,\n useCarousel,\n} from \"../carousel/carousel\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\n\nexport const MobileSharePnLContent: FC<{\n entity: ShareEntity;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLOptions;\n}> = (props) => {\n const { shareOptions } = props;\n const { t } = useTranslation();\n const localPnlConfig = getPnlInfo();\n\n const hasRoiAndPnl = props.entity.roi != null && props.entity.pnl != null;\n const formats: PnLDisplayFormat[] = hasRoiAndPnl\n ? [\"roi_pnl\", \"roi\", \"pnl\"]\n : props.entity.roi != null\n ? [\"roi\"]\n : props.entity.pnl != null\n ? [\"pnl\"]\n : [];\n\n const [pnlFormat, setPnlFormat] = useState<PnLDisplayFormat>(\n formats.length == 1 ? formats[0] : localPnlConfig.pnlFormat,\n );\n const [shareOption, setShareOption] = useState<Set<ShareOptions>>(\n new Set(localPnlConfig.options),\n );\n const [message, setMessage] = useState<string>(localPnlConfig.message);\n const [selectIndex, setSelectIndex] = useState(localPnlConfig.bgIndex);\n // const { shareOptions } = useTradingPageContext();\n const { backgroundImages, ...resetOptions } = shareOptions ?? {\n backgroundImages: [],\n };\n\n const [domain, setDomain] = useState(\"\");\n\n const posterRefs = shareOptions?.backgroundImages?.map(() =>\n useRef<PosterRef | null>(null),\n );\n\n useEffect(() => {\n const currentDomain = window.location.hostname;\n setDomain(currentDomain);\n }, []);\n\n const posterData = getPnLPosterData(\n props.entity,\n message,\n domain,\n pnlFormat,\n shareOption,\n props.baseDp,\n props.quoteDp,\n props.referral,\n );\n // console.log(\"pster data\", posterData, props.entity);\n\n const carouselRef = useRef<any>();\n const aspectRatio = 552 / 310;\n const [scale, setScale] = useState(1);\n const [carouselHeight, setCarouselHeight] = useState(0);\n\n const [focus, setFocus] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n useEffect(() => {\n if (carouselRef.current) {\n const divWidth = carouselRef.current.offsetWidth;\n const divHeight = divWidth / aspectRatio;\n setCarouselHeight(divHeight);\n setScale(divWidth / 552);\n }\n }, [carouselRef, domain]);\n\n const onSharePnL = async (\n posterRef: React.MutableRefObject<PosterRef | null>,\n ) => {\n if (!posterRef.current) return;\n const data = posterRef.current?.toDataURL();\n const blob = dataURItoBlob(data);\n try {\n // Check if the browser supports the share feature\n if (navigator.share) {\n await navigator.share({\n // title: \"Share PnL\",\n text: message,\n // url: imageUrl,\n files: [new File([blob], \"image.png\", { type: \"image/png\" })],\n });\n console.log(\"Image shared successfully!\");\n } else {\n console.log(\"Share API is not supported in this browser.\");\n }\n props.hide?.();\n } catch (error) {\n console.error(\"Error sharing image:\", error);\n }\n };\n\n // check if the entity has the option, like formats\n const options: ShareOptions[] = useMemo(() => {\n const mapping: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"leverage\",\n \"markPrice\",\n \"quantity\",\n ];\n\n return mapping.filter((key) => !!props.entity[key]);\n }, [props.entity]);\n\n savePnlInfo(pnlFormat, shareOption, selectIndex, message);\n\n return (\n <div className=\"oui-w-full\">\n <div\n ref={carouselRef}\n className=\"oui-mt-4 oui-w-full oui-overflow-hidden\"\n style={{ height: `${carouselHeight + 20}px` }}\n >\n <Carousel\n className=\"oui-w-full oui-overflow-hidden\"\n opts={{ align: \"start\" }}\n initIndex={selectIndex}\n >\n <CarouselContent style={{ height: `${carouselHeight}px` }}>\n {shareOptions?.backgroundImages?.map((item, index) => (\n <CarouselItem key={index}>\n <Poster\n className=\"oui-origin-top-left oui-transform\"\n style={{ scale: `${scale}` }}\n width={552}\n height={310}\n data={{\n backgroundImg: item,\n ...resetOptions,\n data: posterData,\n }}\n ratio={3}\n ref={posterRefs?.[index]}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <div className=\"oui-mb-1 oui-mt-2 oui-flex oui-justify-center\">\n <MyIdentifier\n dotClassName=\"oui-w-[16px] oui-h-[4px] oui-bg-base-300\"\n dotActiveClassName=\"!oui-bg-primary-darken oui-w-[20px]\"\n setSelectIndex={setSelectIndex}\n />\n </div>\n </Carousel>\n </div>\n\n {/* @ts-ignore */}\n <ScrollArea className=\"oui-custom-scrollbar oui-max-h-[200px] oui-overflow-y-auto\">\n <div className=\"oui-mt-4\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.displayFormat\")}\n </div>\n <div className=\"oui-row-span-1 oui-grid oui-grid-cols-3 oui-justify-between oui-gap-3 oui-px-1 oui-pt-3\">\n {formats.map((item, index) => (\n <PnlFormatView\n key={index}\n setPnlFormat={setPnlFormat}\n type={item}\n curType={pnlFormat}\n />\n ))}\n </div>\n </div>\n\n <div className=\"oui-mt-3\">\n <div className=\"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.optionalInfo\")}\n </div>\n <div className=\"oui-mt-3 oui-flex oui-flex-wrap oui-gap-3\">\n {options.map((item, index) => (\n <ShareOption\n key={index}\n setShareOption={setShareOption}\n type={item}\n curType={shareOption}\n />\n ))}\n </div>\n </div>\n\n <div className=\"oui-mb-8 oui-mt-3\">\n <div className=\"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.optionalInfo.message\")}\n </div>\n <div className=\"oui-bg-base-600 oui-mx-1 oui-mt-3 oui-h-[48px]\">\n <Input\n placeholder={t(\"share.pnl.optionalInfo.message.placeholder\")}\n containerClassName=\"oui-bg-transparent oui-h-[48px]\"\n value={message}\n autoFocus={false}\n onChange={(e) => {\n if (e.target.value.length > 25) {\n toast.error(t(\"share.pnl.optionalInfo.message.maxLength\"));\n return;\n }\n setMessage(e.target.value);\n }}\n ref={inputRef}\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n suffix={\n focus && (\n <button\n className=\"oui-mr-3 oui-cursor-pointer\"\n onMouseDown={(e) => {\n console.log(\"set message to empty\");\n\n setMessage(\"\");\n setTimeout(() => {\n inputRef.current?.focus();\n }, 50);\n e.stopPropagation();\n }}\n >\n <CloseCircleFillIcon size={18} color=\"white\" />\n </button>\n )\n }\n />\n </div>\n </div>\n </ScrollArea>\n\n <div className=\"oui-pt-2\">\n <Button\n fullWidth\n className=\"oui-h-[40px] oui-text-[16px]\"\n onClick={() => {\n const ref = posterRefs?.[selectIndex];\n if (ref) {\n onSharePnL(ref);\n }\n }}\n >\n {t(\"common.share\")}\n </Button>\n </div>\n </div>\n );\n};\n\nconst PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return t(\"share.pnl.displayFormat.roi&Pnl\");\n case \"roi\":\n return t(\"share.pnl.displayFormat.roi\");\n case \"pnl\":\n return t(\"share.pnl.displayFormat.pnl\");\n }\n }, [type]);\n\n const isSelected = type === curType;\n\n return (\n <div\n className={cn(\n \"oui-referral-shadow oui-flex oui-h-[46px] oui-flex-1 oui-items-center oui-rounded-lg oui-bg-base-4 oui-px-3 oui-shadow-lg hover:oui-cursor-pointer\",\n isSelected && \"oui-dot-sel oui-bg-primary-darken\",\n )}\n onClick={() => {\n setPnlFormat(type);\n }}\n >\n <div className=\"oui-text-sm oui-text-base-contrast\">{text}</div>\n {/* {isSelected && <RadioIcon size={20} />} */}\n </div>\n );\n};\n\nconst ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return t(\"share.pnl.optionalInfo.openPrice\");\n case \"closePrice\":\n return t(\"share.pnl.optionalInfo.closePrice\");\n case \"openTime\":\n return t(\"share.pnl.optionalInfo.openTime\");\n case \"closeTime\":\n return t(\"share.pnl.optionalInfo.closeTime\");\n case \"markPrice\":\n return t(\"common.markPrice\");\n case \"quantity\":\n return t(\"common.quantity\");\n case \"leverage\":\n return t(\"common.leverage\");\n }\n }, [type, t]);\n\n const isSelected = curType.has(type);\n\n return (\n <div\n className={cn(\n \"oui-referral-shadow oui-mt-0 oui-flex oui-h-[46px] oui-w-[calc(50%-6px)] oui-items-center oui-rounded-lg oui-bg-base-4 oui-p-3 oui-shadow-lg hover:oui-cursor-pointer\",\n )}\n onClick={() => {\n // setPnlFormat(type);\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n >\n <div className=\"oui-flex-1 oui-text-sm oui-text-base-contrast\">\n {text}\n </div>\n {isSelected && <ChoicesFillIcon />}\n </div>\n );\n};\nfunction dataURItoBlob(dataURI: string) {\n const byteString = atob(dataURI.split(\",\")[1]);\n const mimeString = dataURI.split(\",\")[0].split(\":\")[1].split(\";\")[0];\n const ab = new ArrayBuffer(byteString.length);\n const ia = new Uint8Array(ab);\n for (let i = 0; i < byteString.length; i++) {\n ia[i] = byteString.charCodeAt(i);\n }\n return new Blob([ab], { type: mimeString });\n}\n\nconst MyIdentifier: FC<{\n setSelectIndex: any;\n className?: string;\n dotClassName?: string;\n dotActiveClassName?: string;\n onClick?: (index: number) => void;\n}> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n useEffect(() => {\n props.setSelectIndex(selectedIndex);\n }, [selectedIndex]);\n\n return (\n <div className={cn(\"oui-flex oui-gap-1\")}>\n {scrollSnaps.map((_: any, index: number) => {\n return (\n <Dot\n key={index}\n index={index}\n active={index === selectedIndex}\n onClick={props.onClick}\n className={props.dotClassName}\n activeClassName={props.dotActiveClassName}\n />\n );\n })}\n </div>\n );\n};\n\nconst ChoicesFillIcon = () => {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z\"\n fill=\"white\"\n fillOpacity=\"1\"\n />\n </svg>\n );\n};\n","\"use client\";\n\nimport React from \"react\";\nimport {\n Button,\n ChevronLeftIcon,\n ChevronRightIcon,\n cn,\n useEmblaCarousel,\n type UseEmblaCarouselType,\n} from \"@kodiak-finance/orderly-ui\";\n\ntype CarouselApi = UseEmblaCarouselType[1];\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\ntype CarouselOptions = UseCarouselParameters[0];\ntype CarouselPlugin = UseCarouselParameters[1];\n\ntype CarouselProps = {\n opts?: CarouselOptions;\n plugins?: CarouselPlugin;\n orientation?: \"horizontal\" | \"vertical\";\n setApi?: (api: CarouselApi) => void;\n initIndex?: number;\n};\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0];\n api: ReturnType<typeof useEmblaCarousel>[1];\n scrollPrev: () => void;\n scrollNext: () => void;\n canScrollPrev: boolean;\n canScrollNext: boolean;\n selectedIndex: number;\n scrollSnaps: number[];\n} & CarouselProps;\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null);\n\nexport function useCarousel() {\n const context = React.useContext(CarouselContext);\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\");\n }\n\n return context;\n}\n\nconst Carousel = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & CarouselProps\n>((originalProps, ref) => {\n const {\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n } = originalProps;\n const [carouselRef, api] = useEmblaCarousel(\n { ...opts, axis: orientation === \"horizontal\" ? \"x\" : \"y\" },\n plugins,\n );\n const [canScrollPrev, setCanScrollPrev] = React.useState(false);\n const [canScrollNext, setCanScrollNext] = React.useState(false);\n const [selectedIndex, setSelectedIndex] = React.useState(\n props.initIndex || 0,\n );\n const [scrollSnaps, setScrollSnaps] = React.useState<number[]>([]);\n\n const onSelect = React.useCallback(\n (api: CarouselApi) => {\n if (!api) {\n return;\n }\n\n // console.log(\"selected\", api.scrollSnapList());\n\n if (scrollSnaps.length === 0) {\n setScrollSnaps(api.scrollSnapList());\n }\n\n setSelectedIndex(api.selectedScrollSnap());\n\n setCanScrollPrev(api.canScrollPrev());\n setCanScrollNext(api.canScrollNext());\n },\n [scrollSnaps],\n );\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev();\n }, [api]);\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext();\n }, [api]);\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n scrollPrev();\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n scrollNext();\n }\n },\n [scrollPrev, scrollNext],\n );\n\n React.useEffect(() => {\n if (!api || !setApi) {\n return;\n }\n\n setApi(api);\n }, [api, setApi]);\n\n React.useEffect(() => {\n if (!api) {\n return;\n }\n\n onSelect(api);\n api.on(\"reInit\", onSelect);\n api.on(\"select\", onSelect);\n\n if (props.initIndex) {\n api.scrollTo(props.initIndex);\n }\n return () => {\n api?.off(\"select\", onSelect);\n };\n }, [api, onSelect]);\n\n const memoizedValue = React.useMemo<CarouselContextProps>(() => {\n return {\n carouselRef,\n api: api,\n opts,\n orientation:\n orientation || (opts?.axis === \"y\" ? \"vertical\" : \"horizontal\"),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n selectedIndex,\n scrollSnaps,\n };\n }, [\n carouselRef,\n api,\n opts,\n orientation,\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n selectedIndex,\n scrollSnaps,\n ]);\n\n return (\n <CarouselContext.Provider value={memoizedValue}>\n <div\n ref={ref}\n onKeyDownCapture={handleKeyDown}\n className={cn(\"oui-relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n );\n});\n\nCarousel.displayName = \"Carousel\";\n\nconst CarouselContent = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>((originalProps, ref) => {\n const { className, children, ...props } = originalProps;\n const { carouselRef, orientation } = useCarousel();\n return (\n <div ref={carouselRef} className=\"oui-overflow-hidden\">\n <div\n ref={ref}\n className={cn(\n \"oui-flex\",\n orientation === \"horizontal\" ? \"oui--ml-4\" : \"oui--mt-4 oui-flex-col\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </div>\n );\n});\n\nCarouselContent.displayName = \"CarouselContent\";\n\nconst CarouselItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>((originalProps, ref) => {\n const { className, children, ...props } = originalProps;\n const { orientation } = useCarousel();\n return (\n <div\n ref={ref}\n role=\"group\"\n aria-roledescription=\"slide\"\n className={cn(\n \"oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full\",\n orientation === \"horizontal\" ? \"oui-pl-4\" : \"oui-pt-4\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n});\n\nCarouselItem.displayName = \"CarouselItem\";\n\nconst CarouselPrevious = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>((originalProps, ref) => {\n const {\n className,\n variant = \"contained\",\n size = \"icon\",\n ...props\n } = originalProps;\n const { orientation, scrollPrev, canScrollPrev } = useCarousel();\n return (\n <Button\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-size-8 oui-rounded-full\",\n orientation === \"horizontal\"\n ? \"oui--left-12 oui-top-1/2 oui--translate-y-1/2\"\n : \"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90\",\n className,\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n {...props}\n >\n <ChevronLeftIcon size={20} />\n <span className=\"oui-sr-only\">Previous slide</span>\n </Button>\n );\n});\n\nCarouselPrevious.displayName = \"CarouselPrevious\";\n\nconst CarouselNext = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>((originalProps, ref) => {\n const {\n className,\n variant = \"contained\",\n size = \"icon\",\n ...props\n } = originalProps;\n const { orientation, scrollNext, canScrollNext } = useCarousel();\n return (\n <Button\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-size-8 oui-rounded-full\",\n orientation === \"horizontal\"\n ? \"oui--right-12 oui-top-1/2 oui--translate-y-1/2\"\n : \"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90\",\n className,\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n {...props}\n >\n <ChevronRightIcon size={20} />\n <span className=\"oui-sr-only\">Next slide</span>\n </Button>\n );\n});\n\nCarouselNext.displayName = \"CarouselNext\";\n\nexport type CarouselIdentifierProps = {\n className?: string;\n dotClassName?: string;\n dotActiveClassName?: string;\n onClick?: (index: number) => void;\n // asChild?: boolean;\n};\n\nconst CarouselIdentifier: React.FC<CarouselIdentifierProps> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n return (\n <div className={cn(\"oui-flex oui-gap-1\", props.className)}>\n {scrollSnaps.map((_, index) => {\n return (\n <Dot\n key={index}\n index={index}\n active={index === selectedIndex}\n onClick={props.onClick}\n className={props.dotClassName}\n activeClassName={props.dotActiveClassName}\n />\n );\n })}\n </div>\n );\n};\n\nCarouselIdentifier.displayName = \"CarouselIdentifier\";\n\nexport const Dot: React.FC<{\n index: number;\n active: boolean;\n onClick?: (index: number) => void;\n className?: string;\n activeClassName?: string;\n}> = ({ index, active, onClick, className, activeClassName }) => {\n const activedClassName = activeClassName || \"oui-bg-primary-darken\";\n return (\n <button\n onClick={() => onClick?.(index)}\n className={cn(\n \"oui-size-2 oui-rounded-full oui-bg-white/30\",\n className,\n active && `active ${activedClassName}`,\n )}\n />\n );\n};\n\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n CarouselIdentifier,\n};\n","import {\n Carousel as OriginCarousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n CarouselIdentifier,\n} from \"./carousel\";\n\nexport type Carousel = typeof OriginCarousel & {\n Content: typeof CarouselContent;\n Item: typeof CarouselItem;\n Next: typeof CarouselNext;\n Previous: typeof CarouselPrevious;\n indentify: typeof CarouselIdentifier;\n};\n\nconst Carousel = OriginCarousel as Carousel;\n\nCarousel.Content = CarouselContent;\nCarousel.Item = CarouselItem;\nCarousel.Next = CarouselNext;\nCarousel.Previous = CarouselPrevious;\nCarousel.indentify = CarouselIdentifier;\n\nexport { Carousel };\n","import { FC } from \"react\";\nimport { DesktopSharePnLContent } from \"./desktop/content\";\nimport { MobileSharePnLContent } from \"./mobile/content\";\nimport { SharePnLState } from \"./sharePnL.script\";\n\nexport const DesktopSharePnL: FC<SharePnLState> = (props) => {\n const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;\n\n if (!shareOptions || !entity) {\n return null;\n }\n return (\n <DesktopSharePnLContent\n entity={entity}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n\nexport const MobileSharePnL: FC<SharePnLState> = (props) => {\n const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;\n if (!shareOptions || !entity) {\n return null;\n }\n return (\n <MobileSharePnLContent\n entity={entity}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n","import { SharePnLOptions, SharePnLParams } from \"../types/types\";\nimport { useSharePnLScript } from \"./sharePnL.script\";\nimport { DesktopSharePnL, MobileSharePnL } from \"./sharePnL.ui\";\n\nexport const SharePnLBottomSheetWidget = (props: {\n hide?: () => void;\n pnl?: SharePnLOptions & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <MobileSharePnL {...state} />;\n};\n\nexport const SharePnLDialogWidget = (props: {\n hide?: () => void;\n pnl?: SharePnLOptions & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <DesktopSharePnL {...state} />;\n};\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import { useEmblaCarousel, cn, Button, ChevronLeftIcon, ChevronRightIcon, registerSimpleDialog, registerSimpleSheet, Box, Flex, Text, Divider, ScrollArea, Input, CloseCircleFillIcon, toast } from '@kodiak-finance/orderly-ui';
2
+ import f, { forwardRef, useImperativeHandle, useMemo, useState, useRef, useEffect, useCallback } from 'react';
3
+ import { usePoster, useSymbolsInfo, useReferralInfo } from '@kodiak-finance/orderly-hooks';
4
+ import { i18n, useTranslation } from '@kodiak-finance/orderly-i18n';
5
+ import { EMPTY_LIST } from '@kodiak-finance/orderly-types';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+ import { Decimal } from '@kodiak-finance/orderly-utils';
8
+
9
+ var Q=e=>{let{pnl:t,hide:n}=e,r=t?.entity,o=useSymbolsInfo(),{getFirstRefCode:a}=useReferralInfo(),l=useMemo(()=>{let c=a()?.code;return {code:t?.refCode??c,slogan:t?.refSlogan,link:t?.refLink}},[a,t]),u=useMemo(()=>{if(r)return o[r?.symbol]("base_dp")},[r,o]),s=useMemo(()=>{if(r)return o[r?.symbol]("quote_dp")},[r,o]);return {entity:r,baseDp:u,quoteDp:s,referralInfo:l,shareOptions:t,hide:n}};var K=forwardRef((e,t)=>{let{width:n,height:r,className:o,data:a,style:l}=e,{ref:u,download:s,toDataURL:c,copy:i,toBlob:d}=usePoster(a,{ratio:e.ratio});return useImperativeHandle(t,()=>({download:s,toDataURL:c,toBlob:d,copy:i})),jsx("canvas",{ref:u,width:n,height:r,className:o,style:l})});function j(e,t,n,r,o,a,l,u){let{t:s}=useTranslation(),{symbol:c,currency:i}=tt(e.symbol),d={symbol:c,currency:i,side:e.side};switch(r){case "pnl":{e.pnl!=null&&(d.pnl=new Decimal(e.pnl).toFixed(2,Decimal.ROUND_DOWN));break}case "roi":{e.roi!=null&&(d.ROI=new Decimal(e.roi).toFixed(2,Decimal.ROUND_DOWN));break}case "roi_pnl":{e.pnl!=null&&(d.pnl=new Decimal(e.pnl).toFixed(2,Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new Decimal(e.roi).toFixed(2,Decimal.ROUND_DOWN));break}}let h=[];o.has("leverage")&&(d.leverage=e.leverage),["openPrice","closePrice","openTime","closeTime","markPrice","quantity"].forEach(b=>{if(o.has(b))switch(b){case "leverage":break;case "openPrice":{e.openPrice!=null&&h.push({title:s("share.pnl.optionalInfo.openPrice"),value:X(e.openPrice,l||2)});break}case "closePrice":{e.closePrice!=null&&h.push({title:s("share.pnl.optionalInfo.closePrice"),value:X(e.closePrice,l||2)});break}case "openTime":{e.openTime!=null&&h.push({title:s("share.pnl.optionalInfo.openTime"),value:xe(e.openTime)});break}case "closeTime":{e.closeTime!=null&&h.push({title:s("share.pnl.optionalInfo.closeTime"),value:xe(e.closeTime)});break}case "markPrice":{e.markPrice!=null&&h.push({title:s("common.markPrice"),value:X(e.markPrice,l||2)});break}case "quantity":e.quantity!=null&&h.push({title:s("common.quantity"),value:X(e.quantity,a||2)});}}),d.informations=h;let S={position:d,updateTime:ot(new Date),domain:n};return t.length>0&&(S.message=t),typeof u<"u"&&u.code!==void 0&&(S.referral=u),S}function tt(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[n,r,o]=t;return {symbol:`${r}-${n}`,currency:o||"USDC"}}function ot(e){let t=e instanceof Date?e:new Date(e),n={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},o=new Intl.DateTimeFormat("en-US",n).formatToParts(t),a=o.find(i=>i.type==="year"?i.value:"")?.value,l=o.find(i=>i.type==="month"?i.value:"")?.value,u=o.find(i=>i.type==="day"?i.value:"")?.value,s=o.find(i=>i.type==="hour"?i.value:"")?.value,c=o.find(i=>i.type==="minute"?i.value:"")?.value;return `${a}-${l}-${u} ${s}:${c}`}function xe(e){let t=e instanceof Date?e:new Date(e),n={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},o=new Intl.DateTimeFormat("en-US",n).formatToParts(t),a=o.find(c=>c.type==="month"?c.value:"")?.value,l=o.find(c=>c.type==="day"?c.value:"")?.value,u=o.find(c=>c.type==="hour"?c.value:"")?.value,s=o.find(c=>c.type==="minute"?c.value:"")?.value;return `${a}-${l} ${u}:${s}`}function X(e,t){return new Decimal(e).toFixed(t,Decimal.ROUND_DOWN)}function ee(e,t,n,r){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:n,pnlFormat:e,options:Array.from(t),message:r}));}function te(){let e=localStorage.getItem("pnl_config_key");if(e&&e.length>0)try{return JSON.parse(e)}catch{}return {bgIndex:0,pnlFormat:"roi_pnl",options:["openPrice","closePrice","openTime","closeTime","markPrice","quantity","leverage"],message:""}}var Se=e=>{let{onClickDownload:t,onClickCopy:n}=e,{t:r}=useTranslation();return jsxs(Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxs(Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsx("span",{children:jsx(at,{})}),r("common.download")]}),jsxs(Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:n,children:[jsx("span",{children:jsx(st,{})}),r("common.copy")]})]})},at=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667",fill:"#fff",fillOpacity:".98"})}),st=()=>jsx("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",fill:"#fff",fillOpacity:".98"})});var be=e=>{let{children:t,...n}=e;return jsx("button",{...n,children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsx("path",{d:"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083",fill:"#fff",fillOpacity:".54"})]})})},we=e=>{let{children:t,...n}=e;return jsx("button",{...n,children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsx("path",{d:"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271",fill:"#fff",fillOpacity:".54"})]})})};var Ie=e=>{let{backgroundImages:t,selectedSnap:n,setSelectedSnap:r}=e,[o,a]=useEmblaCarousel({containScroll:"keepSnaps",dragFree:true}),l=useCallback(()=>{a&&(a?.canScrollPrev()?a.scrollPrev():n-1>=0&&r(n-1));},[a,n]),u=useCallback(()=>{a&&(a?.canScrollNext()?a.scrollNext():n+1<t.length&&r(n+1));},[a,n]),s=useCallback(c=>{r(c.selectedScrollSnap());},[]);return useEffect(()=>{if(a)return s(a),a.on("reInit",s),a.on("select",s),a?.scrollTo(n),()=>{a.off("reInit",s),a.off("select",s);}},[a,s]),jsxs(Flex,{mt:4,px:2,children:[jsx(be,{onClick:l}),jsx("div",{ref:o,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsx(Flex,{children:t.map((c,i)=>jsx(Box,{onClick:()=>{a?.canScrollPrev()||a?.canScrollNext()?a?.scrollTo(i):r(i);},mx:2,my:1,mr:6,r:"base",className:cn("oui-shrink-0 oui-w-[162px]",n===i&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsx("img",{src:c,className:"oui-rounded-sm"})},c))})}),jsx(we,{onClick:u})]})};var oe=e=>{let{size:t=16,className:n}=e;return jsx("button",{type:"button",onClick:r=>{e.onCheckedChange(!e.checked);},className:n,children:e.checked?jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z",fill:"#fff",fillOpacity:".8"})}):jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333",fill:"#fff",fillOpacity:".8"})})})};var De=e=>{let{message:t,setMessage:n,check:r,setCheck:o}=e,[a,l]=useState(false),u=useRef(null),{t:s}=useTranslation();return jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsx(oe,{className:"oui-mt-[2px]",checked:r,onCheckedChange:c=>{o(c);}}),jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{o(!e.check);},children:s("share.pnl.optionalInfo.message")}),jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsx(Input,{ref:u,placeholder:s("share.pnl.optionalInfo.message.placeholder"),classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:false,suffix:a&&jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:c=>{n(""),setTimeout(()=>{u.current?.focus();},50),c.stopPropagation();},children:jsx(CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(true),onBlur:()=>l(false),onChange:c=>{if(c.target.value.length>25){toast.error(s("share.pnl.optionalInfo.message.maxLength"));return}o(c.target.value.length>0),n(c.target.value);}})})]})};var Fe=e=>{let{type:t,curType:n,setShareOption:r}=e,{t:o}=useTranslation(),a=useMemo(()=>{switch(t){case "openPrice":return o("share.pnl.optionalInfo.openPrice");case "closePrice":return o("share.pnl.optionalInfo.closePrice");case "openTime":return o("share.pnl.optionalInfo.openTime");case "closeTime":return o("share.pnl.optionalInfo.closeTime");case "markPrice":return o("common.markPrice");case "quantity":return o("common.quantity");case "leverage":return o("common.leverage")}},[t,o]),l=n.has(t);return jsxs(Flex,{itemAlign:"center",gap:1,className:cn("hover:oui-cursor-pointer"),onClick:()=>{r(u=>{let s=new Set(u);return l?s.delete(t):s.add(t),s});},children:[jsx(oe,{size:16,checked:l,className:"oui-pt-[2px]",onCheckedChange:u=>{r(s=>{let c=new Set(s);return l?c.delete(t):c.add(t),c});}}),jsx(Text,{size:"xs",intensity:54,children:a})]})};var Le=e=>{let{type:t,curType:n,setPnlFormat:r}=e,{t:o}=useTranslation(),a=useMemo(()=>{switch(t){case "roi_pnl":return o("share.pnl.displayFormat.roi&Pnl");case "roi":return o("share.pnl.displayFormat.roi");case "pnl":return o("share.pnl.displayFormat.pnl")}},[t,o]),l=t===n,u="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return l?u+=" oui-text-base-contrast":u+="",jsxs("div",{className:u,onClick:()=>{r(t);},children:[jsx(Tt,{sel:l}),jsx(Text,{size:"xs",intensity:54,className:cn("oui-ml-2 "),children:a})]})},Tt=e=>jsx("button",{type:"button",children:e.sel===true?jsx(Ft,{}):jsx(Lt,{})}),Ft=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-primary-darken",children:[jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".36"}),jsx("circle",{cx:"8",cy:"8",r:"3.333"})]}),Lt=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".54"})});var Ae=e=>{let{shareOptions:t}=e,{t:n}=useTranslation(),r=te(),a=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[l,u]=useState(a.length==1?a[0]:r.pnlFormat),[s,c]=useState(new Set(r.options)),[i,d]=useState(r.bgIndex),[h,O]=useState(r.message),[S,b]=useState(false),{backgroundImages:W,...I}=t??{backgroundImages:[]},[z,w]=useState(""),v=useRef(null);useEffect(()=>{let N=window.location.hostname;w(N);},[]);let D=useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),$=j(e.entity,S?h:"",z,l,s,e.baseDp,e.quoteDp,e.referral),V=()=>{v.current?.copy().then(()=>{e.hide?.(),toast.success(n("share.pnl.image.copied"));}).catch(N=>{toast.error(()=>jsxs("div",{children:[jsx("div",{children:n("common.copy.failed")}),jsx("div",{className:"oui-mt-2 oui-max-w-[396px] oui-text-2xs oui-text-base-contrast-54",children:n("share.pnl.copy.failed.description")})]}));});},g=()=>{v.current?.download("Poster.png"),e.hide?.();},ne=useMemo(()=>["openPrice","closePrice","markPrice","openTime","closeTime","leverage","quantity"].filter(T=>!!e.entity[T]),[e.entity]);return ee(l,s,i,h),jsxs("div",{className:"oui-relative oui-flex oui-size-full oui-flex-col",children:[jsxs("div",{className:"oui-h-full oui-flex-1 oui-overflow-y-auto",children:[jsxs(Box,{mt:9,height:422,children:[jsx(Flex,{itemAlign:"center",justify:"center",children:jsx(K,{width:552,height:310,data:{backgroundImg:D,...I,data:$},ratio:3,ref:v})}),jsx(Ie,{backgroundImages:t?.backgroundImages??EMPTY_LIST,selectedSnap:i,setSelectedSnap:d})]}),jsxs(Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsx(Text,{size:"sm",intensity:80,children:n("share.pnl.displayFormat")}),jsx(Flex,{pt:3,gap:3,itemAlign:"center",children:a.map((N,T)=>jsx(Le,{setPnlFormat:u,type:N,curType:l},T))}),jsx(Divider,{className:"oui-w-full oui-border-white/10 oui-pt-6"}),jsxs(Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsx(Text,{size:"sm",intensity:80,children:n("share.pnl.optionalInfo")}),jsx(Flex,{mt:3,gap:4,className:"oui-flex-wrap",children:ne.map((N,T)=>jsx(Fe,{setShareOption:c,type:N,curType:s},T))})]}),jsx(De,{message:h,setMessage:O,check:S,setCheck:b})]})]}),jsx(Se,{onClickCopy:V,onClickDownload:g})]})};var Ee=f.createContext(null);function B(){let e=f.useContext(Ee);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var ie=f.forwardRef((e,t)=>{let{orientation:n="horizontal",opts:r,setApi:o,plugins:a,className:l,children:u,...s}=e,[c,i]=useEmblaCarousel({...r,axis:n==="horizontal"?"x":"y"},a),[d,h]=f.useState(false),[O,S]=f.useState(false),[b,W]=f.useState(s.initIndex||0),[I,z]=f.useState([]),w=f.useCallback(g=>{g&&(I.length===0&&z(g.scrollSnapList()),W(g.selectedScrollSnap()),h(g.canScrollPrev()),S(g.canScrollNext()));},[I]),v=f.useCallback(()=>{i?.scrollPrev();},[i]),D=f.useCallback(()=>{i?.scrollNext();},[i]),$=f.useCallback(g=>{g.key==="ArrowLeft"?(g.preventDefault(),v()):g.key==="ArrowRight"&&(g.preventDefault(),D());},[v,D]);f.useEffect(()=>{!i||!o||o(i);},[i,o]),f.useEffect(()=>{if(i)return w(i),i.on("reInit",w),i.on("select",w),s.initIndex&&i.scrollTo(s.initIndex),()=>{i?.off("select",w);}},[i,w]);let V=f.useMemo(()=>({carouselRef:c,api:i,opts:r,orientation:n||(r?.axis==="y"?"vertical":"horizontal"),scrollPrev:v,scrollNext:D,canScrollPrev:d,canScrollNext:O,selectedIndex:b,scrollSnaps:I}),[c,i,r,n,v,D,d,O,b,I]);return jsx(Ee.Provider,{value:V,children:jsx("div",{ref:t,onKeyDownCapture:$,className:cn("oui-relative",l),role:"region","aria-roledescription":"carousel",...s,children:u})})});ie.displayName="Carousel";var Y=f.forwardRef((e,t)=>{let{className:n,children:r,...o}=e,{carouselRef:a,orientation:l}=B();return jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsx("div",{ref:t,className:cn("oui-flex",l==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",n),...o,children:r})})});Y.displayName="CarouselContent";var G=f.forwardRef((e,t)=>{let{className:n,children:r,...o}=e,{orientation:a}=B();return jsx("div",{ref:t,role:"group","aria-roledescription":"slide",className:cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",n),...o,children:r})});G.displayName="CarouselItem";var le=f.forwardRef((e,t)=>{let{className:n,variant:r="contained",size:o="icon",...a}=e,{orientation:l,scrollPrev:u,canScrollPrev:s}=B();return jsxs(Button,{ref:t,variant:r,className:cn("oui-absolute oui-size-8 oui-rounded-full",l==="horizontal"?"oui--left-12 oui-top-1/2 oui--translate-y-1/2":"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",n),disabled:!s,onClick:u,...a,children:[jsx(ChevronLeftIcon,{size:20}),jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});le.displayName="CarouselPrevious";var ce=f.forwardRef((e,t)=>{let{className:n,variant:r="contained",size:o="icon",...a}=e,{orientation:l,scrollNext:u,canScrollNext:s}=B();return jsxs(Button,{ref:t,variant:r,className:cn("oui-absolute oui-size-8 oui-rounded-full",l==="horizontal"?"oui--right-12 oui-top-1/2 oui--translate-y-1/2":"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",n),disabled:!s,onClick:u,...a,children:[jsx(ChevronRightIcon,{size:20}),jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ce.displayName="CarouselNext";var ue=e=>{let{scrollSnaps:t,selectedIndex:n}=B();return jsx("div",{className:cn("oui-flex oui-gap-1",e.className),children:t.map((r,o)=>jsx(me,{index:o,active:o===n,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},o))})};ue.displayName="CarouselIdentifier";var me=({index:e,active:t,onClick:n,className:r,activeClassName:o})=>jsx("button",{onClick:()=>n?.(e),className:cn("oui-size-2 oui-rounded-full oui-bg-white/30",r,t&&`active ${o||"oui-bg-primary-darken"}`)});var M=ie;M.Content=Y;M.Item=G;M.Next=ce;M.Previous=le;M.indentify=ue;var _e=e=>{let{shareOptions:t}=e,{t:n}=useTranslation(),r=te(),a=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[l,u]=useState(a.length==1?a[0]:r.pnlFormat),[s,c]=useState(new Set(r.options)),[i,d]=useState(r.message),[h,O]=useState(r.bgIndex),{backgroundImages:S,...b}=t??{backgroundImages:[]},[W,I]=useState(""),z=t?.backgroundImages?.map(()=>useRef(null));useEffect(()=>{let p=window.location.hostname;I(p);},[]);let w=j(e.entity,i,W,l,s,e.baseDp,e.quoteDp,e.referral),v=useRef(),D=552/310,[$,V]=useState(1),[g,ne]=useState(0),[N,T]=useState(false),Ce=useRef(null);useEffect(()=>{if(v.current){let p=v.current.offsetWidth,C=p/D;ne(C),V(p/552);}},[v,W]);let Ve=async p=>{if(!p.current)return;let C=p.current?.toDataURL(),Je=Zt(C);try{navigator.share&&await navigator.share({text:i,files:[new File([Je],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}},Ke=useMemo(()=>["openPrice","closePrice","openTime","closeTime","leverage","markPrice","quantity"].filter(C=>!!e.entity[C]),[e.entity]);return ee(l,s,h,i),jsxs("div",{className:"oui-w-full",children:[jsx("div",{ref:v,className:"oui-mt-4 oui-w-full oui-overflow-hidden",style:{height:`${g+20}px`},children:jsxs(M,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:h,children:[jsx(Y,{style:{height:`${g}px`},children:t?.backgroundImages?.map((p,C)=>jsx(G,{children:jsx(K,{className:"oui-origin-top-left oui-transform",style:{scale:`${$}`},width:552,height:310,data:{backgroundImg:p,...b,data:w},ratio:3,ref:z?.[C]})},C))}),jsx("div",{className:"oui-mb-1 oui-mt-2 oui-flex oui-justify-center",children:jsx(Yt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary-darken oui-w-[20px]",setSelectIndex:O})})]})}),jsxs(ScrollArea,{className:"oui-custom-scrollbar oui-max-h-[200px] oui-overflow-y-auto",children:[jsxs("div",{className:"oui-mt-4",children:[jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.displayFormat")}),jsx("div",{className:"oui-row-span-1 oui-grid oui-grid-cols-3 oui-justify-between oui-gap-3 oui-px-1 oui-pt-3",children:a.map((p,C)=>jsx(Kt,{setPnlFormat:u,type:p,curType:l},C))})]}),jsxs("div",{className:"oui-mt-3",children:[jsx("div",{className:"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.optionalInfo")}),jsx("div",{className:"oui-mt-3 oui-flex oui-flex-wrap oui-gap-3",children:Ke.map((p,C)=>jsx(Jt,{setShareOption:c,type:p,curType:s},C))})]}),jsxs("div",{className:"oui-mb-8 oui-mt-3",children:[jsx("div",{className:"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54",children:n("share.pnl.optionalInfo.message")}),jsx("div",{className:"oui-bg-base-600 oui-mx-1 oui-mt-3 oui-h-[48px]",children:jsx(Input,{placeholder:n("share.pnl.optionalInfo.message.placeholder"),containerClassName:"oui-bg-transparent oui-h-[48px]",value:i,autoFocus:false,onChange:p=>{if(p.target.value.length>25){toast.error(n("share.pnl.optionalInfo.message.maxLength"));return}d(p.target.value);},ref:Ce,onFocus:()=>T(true),onBlur:()=>T(false),suffix:N&&jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:p=>{d(""),setTimeout(()=>{Ce.current?.focus();},50),p.stopPropagation();},children:jsx(CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsx("div",{className:"oui-pt-2",children:jsx(Button,{fullWidth:true,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let p=z?.[h];p&&Ve(p);},children:n("common.share")})})]})},Kt=e=>{let{type:t,curType:n,setPnlFormat:r}=e,{t:o}=useTranslation(),a=useMemo(()=>{switch(t){case "roi_pnl":return o("share.pnl.displayFormat.roi&Pnl");case "roi":return o("share.pnl.displayFormat.roi");case "pnl":return o("share.pnl.displayFormat.pnl")}},[t]);return jsx("div",{className:cn("oui-referral-shadow oui-flex oui-h-[46px] oui-flex-1 oui-items-center oui-rounded-lg oui-bg-base-4 oui-px-3 oui-shadow-lg hover:oui-cursor-pointer",t===n&&"oui-dot-sel oui-bg-primary-darken"),onClick:()=>{r(t);},children:jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:a})})},Jt=e=>{let{type:t,curType:n,setShareOption:r}=e,{t:o}=useTranslation(),a=useMemo(()=>{switch(t){case "openPrice":return o("share.pnl.optionalInfo.openPrice");case "closePrice":return o("share.pnl.optionalInfo.closePrice");case "openTime":return o("share.pnl.optionalInfo.openTime");case "closeTime":return o("share.pnl.optionalInfo.closeTime");case "markPrice":return o("common.markPrice");case "quantity":return o("common.quantity");case "leverage":return o("common.leverage")}},[t,o]),l=n.has(t);return jsxs("div",{className:cn("oui-referral-shadow oui-mt-0 oui-flex oui-h-[46px] oui-w-[calc(50%-6px)] oui-items-center oui-rounded-lg oui-bg-base-4 oui-p-3 oui-shadow-lg hover:oui-cursor-pointer"),onClick:()=>{r(u=>{let s=new Set(u);return l?s.delete(t):s.add(t),s});},children:[jsx("div",{className:"oui-flex-1 oui-text-sm oui-text-base-contrast",children:a}),l&&jsx(Gt,{})]})};function Zt(e){let t=atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(t.length),o=new Uint8Array(r);for(let a=0;a<t.length;a++)o[a]=t.charCodeAt(a);return new Blob([r],{type:n})}var Yt=e=>{let{scrollSnaps:t,selectedIndex:n}=B();return useEffect(()=>{e.setSelectIndex(n);},[n]),jsx("div",{className:cn("oui-flex oui-gap-1"),children:t.map((r,o)=>jsx(me,{index:o,active:o===n,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},o))})},Gt=()=>jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z",fill:"white",fillOpacity:"1"})});var qe=e=>{let{entity:t,baseDp:n,quoteDp:r,referralInfo:o,shareOptions:a,hide:l}=e;return !a||!t?null:jsx(Ae,{entity:t,hide:l,baseDp:n,quoteDp:r,referral:o,shareOptions:a})},Ue=e=>{let{entity:t,baseDp:n,quoteDp:r,referralInfo:o,shareOptions:a,hide:l}=e;return !a||!t?null:jsx(_e,{entity:t,hide:l,baseDp:n,quoteDp:r,referral:o,shareOptions:a})};var ye=e=>{let t=Q({hide:e.hide,pnl:e.pnl});return jsx(Ue,{...t})},ve=e=>{let t=Q({hide:e.hide,pnl:e.pnl});return jsx(qe,{...t})};var eo="sharePnLDialog",to="sharePnLBottomSheet";registerSimpleDialog(eo,ve,{classNames:{content:"!oui-max-w-[624px] oui-p-0"}});registerSimpleSheet(to,ye,{title:i18n.t("share.pnl.sharePnl"),classNames:{body:"oui-pb-4 oui-pt-0"}});
10
+
11
+ export { to as SharePnLBottomSheetId, ye as SharePnLBottomSheetWidget, eo as SharePnLDialogId, ve as SharePnLDialogWidget, Q as useSharePnLScript };
12
+ //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/sharePnL/sharePnL.script.tsx","../src/sharePnL/desktop/content.tsx","../src/sharePnL/poster/poster.tsx","../src/sharePnL/utils/utils.tsx","../src/sharePnL/desktop/bottomBtns.tsx","../src/sharePnL/desktop/carousel.tsx","../src/sharePnL/desktop/buttons.tsx","../src/sharePnL/desktop/message.tsx","../src/sharePnL/desktop/checkbox.tsx","../src/sharePnL/desktop/options.tsx","../src/sharePnL/desktop/pnlFormat.tsx","../src/sharePnL/mobile/content.tsx","../src/sharePnL/carousel/carousel.tsx","../src/sharePnL/carousel/index.tsx","../src/sharePnL/sharePnL.ui.tsx","../src/sharePnL/sharePnL.widget.tsx"],"names":["registerSimpleDialog","registerSimpleSheet","useMemo","useReferralInfo","useSymbolsInfo","useSharePnLScript","props","pnl","hide","entity","symbolInfo","getFirstRefCode","referralInfo","code","base_dp","quote_dp","useEffect","useRef","useState","useTranslation","EMPTY_LIST","Divider","Flex","toast","Text","Box","forwardRef","useImperativeHandle","usePoster","jsx","Poster","parentRef","width","height","className","data","style","ref","download","toDataURL","copy","toBlob","Decimal","getPnLPosterData","position","message","domain","pnlType","options","baseDp","quoteDp","referral","t","symbol","currency","processSymbol","positionData","informations","key","formatFixed","formatOpenTime","formatShareTime","tokens","symbol1","symbol2","symbol3","input","date","formattedParts","year","part","month","day","hour","minute","value","dp","savePnlInfo","format","bgIndex","getPnlInfo","str","Button","jsxs","BottomButtons","onClickDownload","onClickCopy","DownloadIcon","CopyIcon","useCallback","cn","useEmblaCarousel","PrevButton","children","restProps","NextButton","CarouselBackgroundImage","backgroundImages","selectedSnap","setSelectedSnap","emblaRef","emblaApi","onPrevButtonClick","onNextButtonClick","onSelect","e","index","CloseCircleFillIcon","Input","Checkbox","size","Message","setMessage","check","setCheck","focus","setFocus","inputRef","ShareOption","type","curType","setShareOption","text","isSelected","updateSet","checked","PnlFormatView","setPnlFormat","clsName","RadioButton","SelIcon","UnselIcon","DesktopSharePnLContent","shareOptions","localPnlConfig","formats","pnlFormat","shareOption","resetOptions","setDomain","posterRef","currentDomain","curBgImg","posterData","onCopy","onDownload","item","ScrollArea","React","ChevronLeftIcon","ChevronRightIcon","CarouselContext","useCarousel","context","Carousel","originalProps","orientation","opts","setApi","plugins","carouselRef","api","canScrollPrev","setCanScrollPrev","canScrollNext","setCanScrollNext","selectedIndex","setSelectedIndex","scrollSnaps","setScrollSnaps","scrollPrev","scrollNext","handleKeyDown","event","memoizedValue","CarouselContent","CarouselItem","CarouselPrevious","variant","CarouselNext","CarouselIdentifier","_","Dot","active","onClick","activeClassName","MobileSharePnLContent","selectIndex","setSelectIndex","posterRefs","aspectRatio","scale","setScale","carouselHeight","setCarouselHeight","divWidth","divHeight","onSharePnL","blob","dataURItoBlob","MyIdentifier","ChoicesFillIcon","dataURI","byteString","mimeString","ab","ia","i","DesktopSharePnL","MobileSharePnL","SharePnLBottomSheetWidget","state","SharePnLDialogWidget","i18n","SharePnLDialogId","SharePnLBottomS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AAI,CAAC+H,GAAgB,CAAC5H,EACb,KAGPoB,GAACuG,GAAA,CACC,OAAQ3H,EACR,KAAMD,EACN,OAAQyC,EACR,QAASC,EACT,SAAUtC,EACV,aAAcyH,EAChB,CAEJ,EAEa4E,GAAqC3M,GAAU,CAC1D,GAAM,CAAE,OAAAG,EAAQ,OAAAwC,EAAQ,QAAAC,EAAS,aAAAtC,EAAc,aAAAyH,EAAc,KAAA7H,CAAK,EAAIF,EACtE,MAAI,CAAC+H,GAAgB,CAAC5H,EACb,KAGPoB,GAAC6J,GAAA,CACC,OAAQjL,EACR,KAAMD,EACN,OAAQyC,EACR,QAASC,EACT,SAAUtC,EACV,aAAcyH,EAChB,CAEJ,EC1BS,cAAAxG,OAAA,oBARF,IAAMqL,GAA6B5M,GAGpC,CACJ,IAAM6M,EAAQ9M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAOuB,GAACoL,GAAA,CAAgB,GAAGE,EAAO,CACpC,EAEaC,GAAwB9M,GAG/B,CACJ,IAAM6M,EAAQ9M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAOuB,GAACmL,GAAA,CAAiB,GAAGG,EAAO,CACrC,EhBnBA,OAAS,QAAAE,OAAY,+BAErB,IAAMC,GAAmB,iBACnBC,GAAwB,sBAE9BvN,GAAqBsN,GAAkBF,GAAsB,CAC3D,WAAY,CACV,QAAS,4BACX,CACF,CAAC,EAEDnN,GAAoBsN,GAAuBL,GAA2B,CACpE,MAAOG,GAAK,EAAE,oBAAoB,EAClC,WAAY,CACV,KAAM,mBACR,CACF,CAAC","sourcesContent":["import { registerSimpleDialog, registerSimpleSheet } from \"@kodiak-finance/orderly-ui\";\nimport {\n SharePnLDialogWidget,\n SharePnLBottomSheetWidget,\n} from \"./sharePnL/sharePnL.widget\";\nimport { i18n } from \"@kodiak-finance/orderly-i18n\";\n\nconst SharePnLDialogId = \"sharePnLDialog\";\nconst SharePnLBottomSheetId = \"sharePnLBottomSheet\";\n\nregisterSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {\n classNames: {\n content: \"!oui-max-w-[624px] oui-p-0\",\n },\n});\n\nregisterSimpleSheet(SharePnLBottomSheetId, SharePnLBottomSheetWidget, {\n title: i18n.t(\"share.pnl.sharePnl\"),\n classNames: {\n body: \"oui-pb-4 oui-pt-0\",\n },\n});\n\nexport * from \"./sharePnL\";\nexport { SharePnLDialogId, SharePnLBottomSheetId };\nexport type {\n SharePnLConfig,\n SharePnLOptions,\n SharePnLParams,\n} from \"./types/types\";\n","import { useMemo } from \"react\";\nimport { useReferralInfo, useSymbolsInfo } from \"@kodiak-finance/orderly-hooks\";\nimport { ReferralType, SharePnLOptions, SharePnLParams } from \"../types/types\";\n\nexport const useSharePnLScript = (props: {\n pnl?: SharePnLOptions & SharePnLParams;\n hide?: () => void;\n}) => {\n const { pnl, hide } = props;\n const entity = pnl?.entity;\n const symbolInfo = useSymbolsInfo();\n const { getFirstRefCode } = useReferralInfo();\n const referralInfo = useMemo((): ReferralType | undefined => {\n const code = getFirstRefCode()?.code;\n const info = {\n code: pnl?.refCode ?? code,\n slogan: pnl?.refSlogan,\n link: pnl?.refLink,\n };\n return info;\n }, [getFirstRefCode, pnl]);\n\n // print warning if entity is null\n if (!entity) {\n console.warn(\"Entity is null, the share pnl will not be displayed\");\n }\n\n // convert base_dp and quote_dp useMemo\n const base_dp = useMemo(() => {\n if (!entity) return undefined;\n return symbolInfo[entity?.symbol](\"base_dp\");\n }, [entity, symbolInfo]);\n const quote_dp = useMemo(() => {\n if (!entity) return undefined;\n return symbolInfo[entity?.symbol](\"quote_dp\");\n }, [entity, symbolInfo]);\n\n return {\n entity,\n baseDp: base_dp,\n quoteDp: quote_dp,\n referralInfo,\n shareOptions: pnl as SharePnLOptions,\n hide,\n };\n};\n\nexport type SharePnLState = ReturnType<typeof useSharePnLScript>;\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { EMPTY_LIST } from \"@kodiak-finance/orderly-types\";\nimport { Divider, Flex, toast, Text, Box } from \"@kodiak-finance/orderly-ui\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLOptions,\n} from \"../../types/types\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport { BottomButtons } from \"./bottomBtns\";\nimport { CarouselBackgroundImage } from \"./carousel\";\nimport { Message } from \"./message\";\nimport { ShareOption } from \"./options\";\nimport { PnlFormatView } from \"./pnlFormat\";\n\nexport const DesktopSharePnLContent: FC<{\n entity: ShareEntity;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLOptions;\n}> = (props) => {\n const { shareOptions } = props;\n const { t } = useTranslation();\n\n const localPnlConfig = getPnlInfo();\n const hasRoiAndPnl = props.entity.roi != null && props.entity.pnl != null;\n const formats: PnLDisplayFormat[] = hasRoiAndPnl\n ? [\"roi_pnl\", \"roi\", \"pnl\"]\n : props.entity.roi != null\n ? [\"roi\"]\n : props.entity.pnl != null\n ? [\"pnl\"]\n : [];\n\n const [pnlFormat, setPnlFormat] = useState<PnLDisplayFormat>(\n formats.length == 1 ? formats[0] : localPnlConfig.pnlFormat,\n );\n const [shareOption, setShareOption] = useState<Set<ShareOptions>>(\n new Set(localPnlConfig.options),\n );\n const [selectedSnap, setSelectedSnap] = useState(localPnlConfig.bgIndex);\n const [message, setMessage] = useState(localPnlConfig.message);\n const [check, setCheck] = useState(false);\n const { backgroundImages, ...resetOptions } = shareOptions ?? {\n backgroundImages: [],\n };\n\n const [domain, setDomain] = useState(\"\");\n\n const posterRef = useRef<PosterRef | null>(null);\n\n useEffect(() => {\n const currentDomain = window.location.hostname;\n setDomain(currentDomain);\n }, []);\n\n const curBgImg = useMemo(() => {\n return shareOptions?.backgroundImages?.[selectedSnap];\n }, [shareOptions?.backgroundImages, selectedSnap]);\n\n const posterData = getPnLPosterData(\n props.entity,\n check ? message : \"\",\n domain,\n pnlFormat,\n shareOption,\n props.baseDp,\n props.quoteDp,\n props.referral,\n );\n\n const onCopy = () => {\n posterRef.current\n ?.copy()\n .then(() => {\n props.hide?.();\n toast.success(t(\"share.pnl.image.copied\"));\n })\n .catch((e: any) => {\n toast.error(() => {\n return (\n <div>\n <div>{t(\"common.copy.failed\")}</div>\n <div className=\"oui-mt-2 oui-max-w-[396px] oui-text-2xs oui-text-base-contrast-54\">\n {t(\"share.pnl.copy.failed.description\")}\n </div>\n </div>\n );\n });\n });\n };\n const onDownload = () => {\n posterRef.current?.download(\"Poster.png\");\n props.hide?.();\n };\n\n // check if the entity has the option, like formats\n const options: ShareOptions[] = useMemo(() => {\n const mapping: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"markPrice\",\n \"openTime\",\n \"closeTime\",\n \"leverage\",\n \"quantity\",\n ];\n\n return mapping.filter((key) => !!props.entity[key]);\n }, [props.entity]);\n\n savePnlInfo(pnlFormat, shareOption, selectedSnap, message);\n\n return (\n <div className=\"oui-relative oui-flex oui-size-full oui-flex-col\">\n <div className=\"oui-h-full oui-flex-1 oui-overflow-y-auto\">\n <Box mt={9} height={422}>\n <Flex itemAlign={\"center\"} justify={\"center\"}>\n <Poster\n // className=\"oui-mx-11\"\n width={552}\n height={310}\n data={{\n backgroundImg: curBgImg,\n ...resetOptions,\n data: posterData,\n }}\n ratio={3}\n ref={posterRef}\n />\n </Flex>\n <CarouselBackgroundImage\n backgroundImages={shareOptions?.backgroundImages ?? EMPTY_LIST}\n selectedSnap={selectedSnap}\n setSelectedSnap={setSelectedSnap}\n />\n </Box>\n\n <Flex\n direction={\"column\"}\n px={10}\n mt={6}\n justify={\"start\"}\n itemAlign={\"start\"}\n width={\"100%\"}\n >\n <Text size=\"sm\" intensity={80}>\n {t(\"share.pnl.displayFormat\")}\n </Text>\n <Flex pt={3} gap={3} itemAlign={\"center\"}>\n {formats.map((e, index) => (\n <PnlFormatView\n key={index}\n setPnlFormat={setPnlFormat}\n type={e}\n curType={pnlFormat}\n />\n ))}\n </Flex>\n\n <Divider className=\"oui-w-full oui-border-white/10 oui-pt-6\" />\n\n <Flex\n mt={6}\n direction={\"column\"}\n justify={\"start\"}\n itemAlign={\"start\"}\n >\n <Text size=\"sm\" intensity={80}>\n {t(\"share.pnl.optionalInfo\")}\n </Text>\n <Flex mt={3} gap={4} className=\"oui-flex-wrap\">\n {options.map((item, index) => (\n <ShareOption\n key={index}\n setShareOption={setShareOption}\n type={item}\n curType={shareOption}\n />\n ))}\n </Flex>\n </Flex>\n\n <Message\n message={message}\n setMessage={setMessage}\n check={check}\n setCheck={setCheck}\n />\n </Flex>\n </div>\n\n <BottomButtons onClickCopy={onCopy} onClickDownload={onDownload} />\n </div>\n );\n};\n","import { forwardRef, useImperativeHandle } from \"react\";\nimport { type DrawOptions, usePoster } from \"@kodiak-finance/orderly-hooks\";\n\nexport type PosterProps = {\n width: number;\n height: number;\n className?: string;\n ratio?: number;\n data: DrawOptions;\n style?: React.CSSProperties;\n};\n\nexport type PosterRef = {\n download: (filename: string, type?: string, encoderOptions?: number) => void;\n toDataURL: (type?: string, encoderOptions?: number) => string;\n toBlob: (type?: string, encoderOptions?: number) => Promise<Blob | null>;\n copy: () => Promise<void>;\n};\n\nexport const Poster = forwardRef<PosterRef, PosterProps>((props, parentRef) => {\n const { width, height, className, data, style } = props;\n\n const { ref, download, toDataURL, copy, toBlob } = usePoster(data, {\n ratio: props.ratio,\n });\n\n useImperativeHandle(parentRef, () => ({\n download,\n toDataURL,\n toBlob,\n copy,\n }));\n\n return (\n <canvas\n ref={ref}\n width={width}\n height={height}\n className={className}\n style={style}\n />\n );\n});\n","/*\n{\n message: \"I am the Orderly KING.\",\n domain: \"ordely.network\",\n updateTime: \"2022-JAN-01 23:23\",\n position: {\n symbol: \"BTC-PERP\",\n currency: \"USDC\",\n side: \"LONG\",\n leverage: 20,\n pnl: 10432.23,\n ROI: 20.25,\n informations: [\n { title: \"Open Price\", value: 0.12313 },\n { title: \"Opened at\", value: \"Jan-01 23:23\" },\n { title: \"Mark price\", value: \"0.12341\" },\n { title: \"Quantity\", value: \"0.123\" },\n ],\n },\n referral: {\n code: \"WRECKED\",\n link: \"https://orderly.network\",\n slogan: \"Try Orderly now with:\",\n }\n }\n*/\n// import { PnLDisplayFormat, ShareOptions } from \"./type\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport { Decimal } from \"@kodiak-finance/orderly-utils\";\nimport { PnLDisplayFormat, ShareEntity, ShareOptions } from \"../../types/types\";\n\nexport type ReferralType = {\n code?: string;\n link?: string;\n slogan?: string;\n};\n\nexport function getPnLPosterData(\n position: ShareEntity,\n message: string,\n domain: string,\n pnlType: PnLDisplayFormat,\n options: Set<ShareOptions>,\n baseDp?: number,\n quoteDp?: number,\n referral?: ReferralType,\n) {\n const { t } = useTranslation();\n const { symbol, currency } = processSymbol(position.symbol);\n const positionData: any = {\n symbol,\n currency,\n side: position.side,\n };\n\n switch (pnlType) {\n case \"pnl\": {\n if (position.pnl != null) {\n positionData[\"pnl\"] = new Decimal(position.pnl).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n case \"roi\": {\n if (position.roi != null) {\n positionData[\"ROI\"] = new Decimal(position.roi).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n case \"roi_pnl\": {\n if (position.pnl != null) {\n positionData[\"pnl\"] = new Decimal(position.pnl).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n if (position.roi != null) {\n positionData[\"ROI\"] = new Decimal(position.roi).toFixed(\n 2,\n Decimal.ROUND_DOWN,\n );\n }\n break;\n }\n }\n\n const informations: { title: string; value: any }[] = [];\n\n if (options.has(\"leverage\")) {\n positionData[\"leverage\"] = position.leverage;\n }\n const array: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"markPrice\",\n \"quantity\",\n ];\n array.forEach((key) => {\n if (options.has(key)) {\n switch (key) {\n case \"leverage\": {\n break;\n }\n case \"openPrice\": {\n if (position.openPrice != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.openPrice\"),\n value: formatFixed(position.openPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"closePrice\": {\n if (position.closePrice != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.closePrice\"),\n value: formatFixed(position.closePrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"openTime\": {\n if (position.openTime != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.openTime\"),\n value: formatOpenTime(position.openTime),\n });\n }\n break;\n }\n case \"closeTime\": {\n if (position.closeTime != null) {\n informations.push({\n title: t(\"share.pnl.optionalInfo.closeTime\"),\n value: formatOpenTime(position.closeTime),\n });\n }\n break;\n }\n case \"markPrice\": {\n if (position.markPrice != null) {\n informations.push({\n title: t(\"common.markPrice\"),\n value: formatFixed(position.markPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"quantity\": {\n if (position.quantity != null) {\n informations.push({\n title: t(\"common.quantity\"),\n value: formatFixed(position.quantity, baseDp || 2),\n });\n }\n }\n default:\n break;\n }\n }\n });\n\n positionData[\"informations\"] = informations;\n\n const data: any = {\n position: positionData,\n updateTime: formatShareTime(new Date()),\n domain,\n };\n if (message.length > 0) {\n data[\"message\"] = message;\n }\n\n if (typeof referral !== \"undefined\" && referral[\"code\"] !== undefined) {\n data[\"referral\"] = referral;\n }\n\n return data;\n}\n\ninterface SymbolResult {\n symbol: string;\n currency: string;\n}\n\nfunction processSymbol(symbol: string): SymbolResult {\n const tokens = symbol.split(\"_\");\n if (tokens.length !== 3) {\n return {\n symbol: symbol,\n currency: \"USDC\",\n };\n }\n\n const [symbol1, symbol2, symbol3] = tokens;\n const formattedString = `${symbol2}-${symbol1}`;\n\n return {\n symbol: formattedString,\n currency: symbol3 || \"USDC\",\n };\n}\n\nfunction formatShareTime(input: number): string;\nfunction formatShareTime(input: Date): string;\nfunction formatShareTime(input: number | Date): string {\n const date = input instanceof Date ? input : new Date(input);\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n };\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", options);\n const formattedParts = formatter.formatToParts(date);\n\n // console.log(\"formattedParts\", formattedParts);\n\n const year = formattedParts.find((part) =>\n part.type === \"year\" ? part.value : \"\",\n )?.value;\n const month = formattedParts.find((part) =>\n part.type === \"month\" ? part.value : \"\",\n )?.value;\n const day = formattedParts.find((part) =>\n part.type === \"day\" ? part.value : \"\",\n )?.value;\n const hour = formattedParts.find((part) =>\n part.type === \"hour\" ? part.value : \"\",\n )?.value;\n const minute = formattedParts.find((part) =>\n part.type === \"minute\" ? part.value : \"\",\n )?.value;\n\n return `${year}-${month}-${day} ${hour}:${minute}`;\n}\n\nfunction formatOpenTime(input: number | Date): string {\n const date = input instanceof Date ? input : new Date(input);\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"short\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n };\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", options);\n const formattedParts = formatter.formatToParts(date);\n\n // console.log(\"formattedParts\", formattedParts);\n\n const month = formattedParts.find((part) =>\n part.type === \"month\" ? part.value : \"\",\n )?.value;\n const day = formattedParts.find((part) =>\n part.type === \"day\" ? part.value : \"\",\n )?.value;\n const hour = formattedParts.find((part) =>\n part.type === \"hour\" ? part.value : \"\",\n )?.value;\n const minute = formattedParts.find((part) =>\n part.type === \"minute\" ? part.value : \"\",\n )?.value;\n\n return `${month}-${day} ${hour}:${minute}`;\n}\n\nfunction formatFixed(value: number, dp: number) {\n return new Decimal(value).toFixed(dp, Decimal.ROUND_DOWN);\n}\n\nexport function savePnlInfo(\n format: PnLDisplayFormat,\n options: Set<ShareOptions>,\n bgIndex: number,\n message: string,\n) {\n localStorage.setItem(\n \"pnl_config_key\",\n JSON.stringify({\n bgIndex: bgIndex,\n pnlFormat: format,\n options: Array.from(options),\n message: message,\n }),\n );\n}\n\nexport function getPnlInfo(): {\n bgIndex: number;\n pnlFormat: PnLDisplayFormat;\n options: ShareOptions[];\n message: \"\";\n} {\n const str = localStorage.getItem(\"pnl_config_key\");\n\n if (str && str.length > 0) {\n try {\n const json = JSON.parse(str);\n\n return json;\n } catch (e) {}\n }\n return {\n bgIndex: 0,\n pnlFormat: \"roi_pnl\",\n options: [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"markPrice\",\n \"quantity\",\n \"leverage\",\n ],\n message: \"\",\n };\n}\n","import { FC } from \"react\";\nimport { Button, Flex } from \"@kodiak-finance/orderly-ui\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nexport const BottomButtons: FC<{\n onClickDownload: any;\n onClickCopy: any;\n}> = (props) => {\n const { onClickDownload, onClickCopy } = props;\n const { t } = useTranslation();\n\n return (\n <Flex px={8} gap={3} mt={3} itemAlign={\"center\"}>\n <Button\n color={\"secondary\"}\n className=\"oui-flex-1 oui-flex oui-gap-1\"\n onClick={onClickDownload}\n >\n <span>\n <DownloadIcon />\n </span>\n {t(\"common.download\")}\n </Button>\n\n <Button className=\"oui-flex-1 oui-flex oui-gap-1\" onClick={onClickCopy}>\n <span>\n <CopyIcon />\n </span>\n {t(\"common.copy\")}\n </Button>\n </Flex>\n );\n};\n\nconst DownloadIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667\"\n fill=\"#fff\"\n fillOpacity=\".98\"\n />\n </svg>\n );\n};\n\nconst CopyIcon = () => {\n return (\n <svg\n width=\"17\"\n height=\"16\"\n viewBox=\"0 0 17 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z\"\n fill=\"#fff\"\n fillOpacity=\".98\"\n />\n </svg>\n );\n};\n","import { FC, useCallback, useEffect } from \"react\";\nimport { Box, cn, Flex, useEmblaCarousel } from \"@kodiak-finance/orderly-ui\";\nimport { NextButton, PrevButton } from \"./buttons\";\n\nexport const CarouselBackgroundImage: FC<{\n backgroundImages: ReadonlyArray<string> | string[];\n selectedSnap: number;\n setSelectedSnap: any;\n}> = (props) => {\n const { backgroundImages, selectedSnap, setSelectedSnap } = props;\n\n const [emblaRef, emblaApi] = useEmblaCarousel({\n // loop: true,\n containScroll: \"keepSnaps\",\n dragFree: true,\n });\n\n const onPrevButtonClick = useCallback(() => {\n if (!emblaApi) {\n return;\n }\n if (emblaApi?.canScrollPrev()) {\n emblaApi.scrollPrev();\n } else if (selectedSnap - 1 >= 0) {\n setSelectedSnap(selectedSnap - 1);\n }\n }, [emblaApi, selectedSnap]);\n\n const onNextButtonClick = useCallback(() => {\n if (!emblaApi) {\n return;\n }\n if (emblaApi?.canScrollNext()) {\n emblaApi.scrollNext();\n } else if (selectedSnap + 1 < backgroundImages.length) {\n setSelectedSnap(selectedSnap + 1);\n }\n }, [emblaApi, selectedSnap]);\n\n const onSelect = useCallback((emblaApi: any) => {\n // setPrevBtnDisabled(!emblaApi.canScrollPrev());\n // setNextBtnDisabled(!emblaApi.canScrollNext());\n setSelectedSnap(emblaApi.selectedScrollSnap());\n }, []);\n\n useEffect(() => {\n if (!emblaApi) {\n return;\n }\n onSelect(emblaApi);\n emblaApi.on(\"reInit\", onSelect);\n emblaApi.on(\"select\", onSelect);\n emblaApi?.scrollTo(selectedSnap);\n return () => {\n emblaApi.off(\"reInit\", onSelect);\n emblaApi.off(\"select\", onSelect);\n };\n }, [emblaApi, onSelect]);\n\n return (\n <Flex mt={4} px={2}>\n <PrevButton onClick={onPrevButtonClick} />\n <div\n ref={emblaRef}\n className=\"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0\"\n >\n <Flex>\n {backgroundImages.map((e, index) => (\n <Box\n key={e}\n onClick={() => {\n if (emblaApi?.canScrollPrev() || emblaApi?.canScrollNext()) {\n emblaApi?.scrollTo(index);\n } else {\n setSelectedSnap(index);\n }\n }}\n mx={2}\n my={1}\n mr={6}\n r=\"base\"\n className={cn(\n \"oui-shrink-0 oui-w-[162px]\",\n selectedSnap === index &&\n \"oui-outline oui-outline-1 oui-outline-primary-darken\",\n )}\n >\n <img src={e} className=\"oui-rounded-sm\" />\n </Box>\n ))}\n </Flex>\n </div>\n <NextButton onClick={onNextButtonClick} />\n </Flex>\n );\n};\n","import { FC, PropsWithChildren } from \"react\";\n\ntype PropType = PropsWithChildren<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >\n>;\n\nexport const PrevButton: FC<PropType> = (props) => {\n const { children, ...restProps } = props;\n\n return (\n <button {...restProps}>\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"20\" height=\"20\" rx=\"10\" fill=\"#333948\" />\n <path\n d=\"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n </button>\n );\n};\n\nexport const NextButton: FC<PropType> = (props) => {\n const { children, ...restProps } = props;\n\n return (\n <button {...restProps}>\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect width=\"20\" height=\"20\" rx=\"10\" fill=\"#333948\" />\n <path\n d=\"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n </button>\n );\n};\n","import { FC, useRef, useState } from \"react\";\nimport { CloseCircleFillIcon, Input, toast } from \"@kodiak-finance/orderly-ui\";\nimport { Checkbox } from \"./checkbox\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const Message: FC<{\n message: string;\n setMessage: any;\n check: boolean;\n setCheck: any;\n}> = (props) => {\n const { message, setMessage, check, setCheck } = props;\n const [focus, setFocus] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const { t } = useTranslation();\n\n return (\n <div className=\"oui-mt-3 oui-mb-6 oui-flex oui-items-center\">\n <Checkbox\n className=\"oui-mt-[2px]\"\n checked={check}\n onCheckedChange={(e: boolean) => {\n setCheck(e);\n }}\n />\n <div\n className=\"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer\"\n onClick={() => {\n setCheck(!props.check);\n }}\n >\n {t(\"share.pnl.optionalInfo.message\")}\n </div>\n <div className=\"oui-bg-base-900 oui-mx-2 oui-rounded-sm\">\n <Input\n ref={inputRef}\n placeholder={t(\"share.pnl.optionalInfo.message.placeholder\")}\n classNames={{\n root: \"oui-w-[320px]\",\n }}\n size=\"sm\"\n value={message}\n autoFocus={false}\n suffix={\n focus && (\n <button\n className=\"oui-mr-3 oui-cursor-pointer\"\n onMouseDown={(e) => {\n console.log(\"set message to empty\");\n\n setMessage(\"\");\n setTimeout(() => {\n inputRef.current?.focus();\n }, 50);\n e.stopPropagation();\n }}\n >\n <CloseCircleFillIcon size={18} color=\"white\" />\n </button>\n )\n }\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n onChange={(e) => {\n if (e.target.value.length > 25) {\n toast.error(t(\"share.pnl.optionalInfo.message.maxLength\"));\n return;\n }\n setCheck(e.target.value.length > 0);\n setMessage(e.target.value);\n }}\n />\n </div>\n </div>\n );\n};\n","export const Checkbox = (props: {\n size?: number;\n className?: string;\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n}) => {\n const { size = 16, className } = props;\n return (\n <button\n type=\"button\"\n onClick={(e) => {\n props.onCheckedChange(!props.checked);\n }}\n className={className}\n >\n {props.checked ? (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z\"\n fill=\"#fff\"\n fillOpacity=\".8\"\n />\n </svg>\n ) : (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333\"\n fill=\"#fff\"\n fillOpacity=\".8\"\n />\n </svg>\n )}\n </button>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { ShareOptions } from \"../../types/types\";\nimport { Flex, Text, cn } from \"@kodiak-finance/orderly-ui\";\nimport { Checkbox } from \"./checkbox\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\n\nexport const ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return t(\"share.pnl.optionalInfo.openPrice\");\n case \"closePrice\":\n return t(\"share.pnl.optionalInfo.closePrice\");\n case \"openTime\":\n return t(\"share.pnl.optionalInfo.openTime\");\n case \"closeTime\":\n return t(\"share.pnl.optionalInfo.closeTime\");\n case \"markPrice\":\n return t(\"common.markPrice\");\n case \"quantity\":\n return t(\"common.quantity\");\n case \"leverage\":\n return t(\"common.leverage\");\n }\n }, [type, t]);\n\n const isSelected = curType.has(type);\n\n return (\n <Flex\n itemAlign={\"center\"}\n gap={1}\n className={cn(\"hover:oui-cursor-pointer\")}\n onClick={() => {\n // setPnlFormat(type);\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n >\n <Checkbox\n size={16}\n checked={isSelected}\n className=\"oui-pt-[2px]\"\n onCheckedChange={(checked: boolean) => {\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n />\n\n <Text size=\"xs\" intensity={54}>\n {text}\n </Text>\n </Flex>\n );\n};\n","import { FC, useMemo } from \"react\";\nimport { PnLDisplayFormat } from \"../../types/types\";\nimport { Text, cn } from \"@kodiak-finance/orderly-ui\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nexport const PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return t(\"share.pnl.displayFormat.roi&Pnl\");\n case \"roi\":\n return t(\"share.pnl.displayFormat.roi\");\n case \"pnl\":\n return t(\"share.pnl.displayFormat.pnl\");\n }\n }, [type, t]);\n\n const isSelected = type === curType;\n\n let clsName = \"oui-flex oui-items-center oui-gap-1 oui-cursor-pointer\";\n if (isSelected) {\n clsName += \" oui-text-base-contrast\";\n } else {\n clsName += \"\";\n }\n\n return (\n <div\n className={clsName}\n onClick={() => {\n setPnlFormat(type);\n }}\n >\n <RadioButton sel={isSelected} />\n <Text\n size=\"xs\"\n intensity={54}\n className={cn(\n \"oui-ml-2 \"\n // isSelected && \"oui-text-base-contrast\"\n )}\n >\n {text}\n </Text>\n </div>\n );\n};\n\nconst RadioButton = (props: {\n sel?: boolean;\n // onChange?: (sel: boolean) => void;\n}) => {\n return (\n <button\n type=\"button\"\n // onClick={(e) => {\n // e.stopPropagation();\n // }}\n >\n {props.sel === true ? <SelIcon /> : <UnselIcon />}\n </button>\n );\n};\n\nconst SelIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"oui-fill-primary-darken\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".36\"\n />\n <circle cx=\"8\" cy=\"8\" r=\"3.333\" />\n </svg>\n );\n};\n\nconst UnselIcon = () => {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667\"\n fill=\"#fff\"\n fillOpacity=\".54\"\n />\n </svg>\n );\n};\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"@kodiak-finance/orderly-i18n\";\nimport {\n Button,\n CloseCircleFillIcon,\n cn,\n Input,\n ScrollArea,\n toast,\n} from \"@kodiak-finance/orderly-ui\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLOptions,\n} from \"../../types/types\";\nimport { Carousel } from \"../carousel\";\nimport {\n CarouselContent,\n CarouselItem,\n Dot,\n useCarousel,\n} from \"../carousel/carousel\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\n\nexport const MobileSharePnLContent: FC<{\n entity: ShareEntity;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLOptions;\n}> = (props) => {\n const { shareOptions } = props;\n const { t } = useTranslation();\n const localPnlConfig = getPnlInfo();\n\n const hasRoiAndPnl = props.entity.roi != null && props.entity.pnl != null;\n const formats: PnLDisplayFormat[] = hasRoiAndPnl\n ? [\"roi_pnl\", \"roi\", \"pnl\"]\n : props.entity.roi != null\n ? [\"roi\"]\n : props.entity.pnl != null\n ? [\"pnl\"]\n : [];\n\n const [pnlFormat, setPnlFormat] = useState<PnLDisplayFormat>(\n formats.length == 1 ? formats[0] : localPnlConfig.pnlFormat,\n );\n const [shareOption, setShareOption] = useState<Set<ShareOptions>>(\n new Set(localPnlConfig.options),\n );\n const [message, setMessage] = useState<string>(localPnlConfig.message);\n const [selectIndex, setSelectIndex] = useState(localPnlConfig.bgIndex);\n // const { shareOptions } = useTradingPageContext();\n const { backgroundImages, ...resetOptions } = shareOptions ?? {\n backgroundImages: [],\n };\n\n const [domain, setDomain] = useState(\"\");\n\n const posterRefs = shareOptions?.backgroundImages?.map(() =>\n useRef<PosterRef | null>(null),\n );\n\n useEffect(() => {\n const currentDomain = window.location.hostname;\n setDomain(currentDomain);\n }, []);\n\n const posterData = getPnLPosterData(\n props.entity,\n message,\n domain,\n pnlFormat,\n shareOption,\n props.baseDp,\n props.quoteDp,\n props.referral,\n );\n // console.log(\"pster data\", posterData, props.entity);\n\n const carouselRef = useRef<any>();\n const aspectRatio = 552 / 310;\n const [scale, setScale] = useState(1);\n const [carouselHeight, setCarouselHeight] = useState(0);\n\n const [focus, setFocus] = useState(false);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n useEffect(() => {\n if (carouselRef.current) {\n const divWidth = carouselRef.current.offsetWidth;\n const divHeight = divWidth / aspectRatio;\n setCarouselHeight(divHeight);\n setScale(divWidth / 552);\n }\n }, [carouselRef, domain]);\n\n const onSharePnL = async (\n posterRef: React.MutableRefObject<PosterRef | null>,\n ) => {\n if (!posterRef.current) return;\n const data = posterRef.current?.toDataURL();\n const blob = dataURItoBlob(data);\n try {\n // Check if the browser supports the share feature\n if (navigator.share) {\n await navigator.share({\n // title: \"Share PnL\",\n text: message,\n // url: imageUrl,\n files: [new File([blob], \"image.png\", { type: \"image/png\" })],\n });\n console.log(\"Image shared successfully!\");\n } else {\n console.log(\"Share API is not supported in this browser.\");\n }\n props.hide?.();\n } catch (error) {\n console.error(\"Error sharing image:\", error);\n }\n };\n\n // check if the entity has the option, like formats\n const options: ShareOptions[] = useMemo(() => {\n const mapping: ShareOptions[] = [\n \"openPrice\",\n \"closePrice\",\n \"openTime\",\n \"closeTime\",\n \"leverage\",\n \"markPrice\",\n \"quantity\",\n ];\n\n return mapping.filter((key) => !!props.entity[key]);\n }, [props.entity]);\n\n savePnlInfo(pnlFormat, shareOption, selectIndex, message);\n\n return (\n <div className=\"oui-w-full\">\n <div\n ref={carouselRef}\n className=\"oui-mt-4 oui-w-full oui-overflow-hidden\"\n style={{ height: `${carouselHeight + 20}px` }}\n >\n <Carousel\n className=\"oui-w-full oui-overflow-hidden\"\n opts={{ align: \"start\" }}\n initIndex={selectIndex}\n >\n <CarouselContent style={{ height: `${carouselHeight}px` }}>\n {shareOptions?.backgroundImages?.map((item, index) => (\n <CarouselItem key={index}>\n <Poster\n className=\"oui-origin-top-left oui-transform\"\n style={{ scale: `${scale}` }}\n width={552}\n height={310}\n data={{\n backgroundImg: item,\n ...resetOptions,\n data: posterData,\n }}\n ratio={3}\n ref={posterRefs?.[index]}\n />\n </CarouselItem>\n ))}\n </CarouselContent>\n <div className=\"oui-mb-1 oui-mt-2 oui-flex oui-justify-center\">\n <MyIdentifier\n dotClassName=\"oui-w-[16px] oui-h-[4px] oui-bg-base-300\"\n dotActiveClassName=\"!oui-bg-primary-darken oui-w-[20px]\"\n setSelectIndex={setSelectIndex}\n />\n </div>\n </Carousel>\n </div>\n\n {/* @ts-ignore */}\n <ScrollArea className=\"oui-custom-scrollbar oui-max-h-[200px] oui-overflow-y-auto\">\n <div className=\"oui-mt-4\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.displayFormat\")}\n </div>\n <div className=\"oui-row-span-1 oui-grid oui-grid-cols-3 oui-justify-between oui-gap-3 oui-px-1 oui-pt-3\">\n {formats.map((item, index) => (\n <PnlFormatView\n key={index}\n setPnlFormat={setPnlFormat}\n type={item}\n curType={pnlFormat}\n />\n ))}\n </div>\n </div>\n\n <div className=\"oui-mt-3\">\n <div className=\"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.optionalInfo\")}\n </div>\n <div className=\"oui-mt-3 oui-flex oui-flex-wrap oui-gap-3\">\n {options.map((item, index) => (\n <ShareOption\n key={index}\n setShareOption={setShareOption}\n type={item}\n curType={shareOption}\n />\n ))}\n </div>\n </div>\n\n <div className=\"oui-mb-8 oui-mt-3\">\n <div className=\"oui-h-[18px] oui-text-3xs oui-text-base-contrast-54\">\n {t(\"share.pnl.optionalInfo.message\")}\n </div>\n <div className=\"oui-bg-base-600 oui-mx-1 oui-mt-3 oui-h-[48px]\">\n <Input\n placeholder={t(\"share.pnl.optionalInfo.message.placeholder\")}\n containerClassName=\"oui-bg-transparent oui-h-[48px]\"\n value={message}\n autoFocus={false}\n onChange={(e) => {\n if (e.target.value.length > 25) {\n toast.error(t(\"share.pnl.optionalInfo.message.maxLength\"));\n return;\n }\n setMessage(e.target.value);\n }}\n ref={inputRef}\n onFocus={() => setFocus(true)}\n onBlur={() => setFocus(false)}\n suffix={\n focus && (\n <button\n className=\"oui-mr-3 oui-cursor-pointer\"\n onMouseDown={(e) => {\n console.log(\"set message to empty\");\n\n setMessage(\"\");\n setTimeout(() => {\n inputRef.current?.focus();\n }, 50);\n e.stopPropagation();\n }}\n >\n <CloseCircleFillIcon size={18} color=\"white\" />\n </button>\n )\n }\n />\n </div>\n </div>\n </ScrollArea>\n\n <div className=\"oui-pt-2\">\n <Button\n fullWidth\n className=\"oui-h-[40px] oui-text-[16px]\"\n onClick={() => {\n const ref = posterRefs?.[selectIndex];\n if (ref) {\n onSharePnL(ref);\n }\n }}\n >\n {t(\"common.share\")}\n </Button>\n </div>\n </div>\n );\n};\n\nconst PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return t(\"share.pnl.displayFormat.roi&Pnl\");\n case \"roi\":\n return t(\"share.pnl.displayFormat.roi\");\n case \"pnl\":\n return t(\"share.pnl.displayFormat.pnl\");\n }\n }, [type]);\n\n const isSelected = type === curType;\n\n return (\n <div\n className={cn(\n \"oui-referral-shadow oui-flex oui-h-[46px] oui-flex-1 oui-items-center oui-rounded-lg oui-bg-base-4 oui-px-3 oui-shadow-lg hover:oui-cursor-pointer\",\n isSelected && \"oui-dot-sel oui-bg-primary-darken\",\n )}\n onClick={() => {\n setPnlFormat(type);\n }}\n >\n <div className=\"oui-text-sm oui-text-base-contrast\">{text}</div>\n {/* {isSelected && <RadioIcon size={20} />} */}\n </div>\n );\n};\n\nconst ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n const { t } = useTranslation();\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return t(\"share.pnl.optionalInfo.openPrice\");\n case \"closePrice\":\n return t(\"share.pnl.optionalInfo.closePrice\");\n case \"openTime\":\n return t(\"share.pnl.optionalInfo.openTime\");\n case \"closeTime\":\n return t(\"share.pnl.optionalInfo.closeTime\");\n case \"markPrice\":\n return t(\"common.markPrice\");\n case \"quantity\":\n return t(\"common.quantity\");\n case \"leverage\":\n return t(\"common.leverage\");\n }\n }, [type, t]);\n\n const isSelected = curType.has(type);\n\n return (\n <div\n className={cn(\n \"oui-referral-shadow oui-mt-0 oui-flex oui-h-[46px] oui-w-[calc(50%-6px)] oui-items-center oui-rounded-lg oui-bg-base-4 oui-p-3 oui-shadow-lg hover:oui-cursor-pointer\",\n )}\n onClick={() => {\n // setPnlFormat(type);\n setShareOption((value: Set<ShareOptions>) => {\n const updateSet = new Set(value);\n if (isSelected) {\n updateSet.delete(type);\n } else {\n updateSet.add(type);\n }\n return updateSet;\n });\n }}\n >\n <div className=\"oui-flex-1 oui-text-sm oui-text-base-contrast\">\n {text}\n </div>\n {isSelected && <ChoicesFillIcon />}\n </div>\n );\n};\nfunction dataURItoBlob(dataURI: string) {\n const byteString = atob(dataURI.split(\",\")[1]);\n const mimeString = dataURI.split(\",\")[0].split(\":\")[1].split(\";\")[0];\n const ab = new ArrayBuffer(byteString.length);\n const ia = new Uint8Array(ab);\n for (let i = 0; i < byteString.length; i++) {\n ia[i] = byteString.charCodeAt(i);\n }\n return new Blob([ab], { type: mimeString });\n}\n\nconst MyIdentifier: FC<{\n setSelectIndex: any;\n className?: string;\n dotClassName?: string;\n dotActiveClassName?: string;\n onClick?: (index: number) => void;\n}> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n useEffect(() => {\n props.setSelectIndex(selectedIndex);\n }, [selectedIndex]);\n\n return (\n <div className={cn(\"oui-flex oui-gap-1\")}>\n {scrollSnaps.map((_: any, index: number) => {\n return (\n <Dot\n key={index}\n index={index}\n active={index === selectedIndex}\n onClick={props.onClick}\n className={props.dotClassName}\n activeClassName={props.dotActiveClassName}\n />\n );\n })}\n </div>\n );\n};\n\nconst ChoicesFillIcon = () => {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z\"\n fill=\"white\"\n fillOpacity=\"1\"\n />\n </svg>\n );\n};\n","\"use client\";\n\nimport React from \"react\";\nimport {\n Button,\n ChevronLeftIcon,\n ChevronRightIcon,\n cn,\n useEmblaCarousel,\n type UseEmblaCarouselType,\n} from \"@kodiak-finance/orderly-ui\";\n\ntype CarouselApi = UseEmblaCarouselType[1];\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>;\ntype CarouselOptions = UseCarouselParameters[0];\ntype CarouselPlugin = UseCarouselParameters[1];\n\ntype CarouselProps = {\n opts?: CarouselOptions;\n plugins?: CarouselPlugin;\n orientation?: \"horizontal\" | \"vertical\";\n setApi?: (api: CarouselApi) => void;\n initIndex?: number;\n};\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0];\n api: ReturnType<typeof useEmblaCarousel>[1];\n scrollPrev: () => void;\n scrollNext: () => void;\n canScrollPrev: boolean;\n canScrollNext: boolean;\n selectedIndex: number;\n scrollSnaps: number[];\n} & CarouselProps;\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null);\n\nexport function useCarousel() {\n const context = React.useContext(CarouselContext);\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\");\n }\n\n return context;\n}\n\nconst Carousel = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & CarouselProps\n>((originalProps, ref) => {\n const {\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n } = originalProps;\n const [carouselRef, api] = useEmblaCarousel(\n { ...opts, axis: orientation === \"horizontal\" ? \"x\" : \"y\" },\n plugins,\n );\n const [canScrollPrev, setCanScrollPrev] = React.useState(false);\n const [canScrollNext, setCanScrollNext] = React.useState(false);\n const [selectedIndex, setSelectedIndex] = React.useState(\n props.initIndex || 0,\n );\n const [scrollSnaps, setScrollSnaps] = React.useState<number[]>([]);\n\n const onSelect = React.useCallback(\n (api: CarouselApi) => {\n if (!api) {\n return;\n }\n\n // console.log(\"selected\", api.scrollSnapList());\n\n if (scrollSnaps.length === 0) {\n setScrollSnaps(api.scrollSnapList());\n }\n\n setSelectedIndex(api.selectedScrollSnap());\n\n setCanScrollPrev(api.canScrollPrev());\n setCanScrollNext(api.canScrollNext());\n },\n [scrollSnaps],\n );\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev();\n }, [api]);\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext();\n }, [api]);\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n scrollPrev();\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n scrollNext();\n }\n },\n [scrollPrev, scrollNext],\n );\n\n React.useEffect(() => {\n if (!api || !setApi) {\n return;\n }\n\n setApi(api);\n }, [api, setApi]);\n\n React.useEffect(() => {\n if (!api) {\n return;\n }\n\n onSelect(api);\n api.on(\"reInit\", onSelect);\n api.on(\"select\", onSelect);\n\n if (props.initIndex) {\n api.scrollTo(props.initIndex);\n }\n return () => {\n api?.off(\"select\", onSelect);\n };\n }, [api, onSelect]);\n\n const memoizedValue = React.useMemo<CarouselContextProps>(() => {\n return {\n carouselRef,\n api: api,\n opts,\n orientation:\n orientation || (opts?.axis === \"y\" ? \"vertical\" : \"horizontal\"),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n selectedIndex,\n scrollSnaps,\n };\n }, [\n carouselRef,\n api,\n opts,\n orientation,\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n selectedIndex,\n scrollSnaps,\n ]);\n\n return (\n <CarouselContext.Provider value={memoizedValue}>\n <div\n ref={ref}\n onKeyDownCapture={handleKeyDown}\n className={cn(\"oui-relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n );\n});\n\nCarousel.displayName = \"Carousel\";\n\nconst CarouselContent = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>((originalProps, ref) => {\n const { className, children, ...props } = originalProps;\n const { carouselRef, orientation } = useCarousel();\n return (\n <div ref={carouselRef} className=\"oui-overflow-hidden\">\n <div\n ref={ref}\n className={cn(\n \"oui-flex\",\n orientation === \"horizontal\" ? \"oui--ml-4\" : \"oui--mt-4 oui-flex-col\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </div>\n );\n});\n\nCarouselContent.displayName = \"CarouselContent\";\n\nconst CarouselItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>((originalProps, ref) => {\n const { className, children, ...props } = originalProps;\n const { orientation } = useCarousel();\n return (\n <div\n ref={ref}\n role=\"group\"\n aria-roledescription=\"slide\"\n className={cn(\n \"oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full\",\n orientation === \"horizontal\" ? \"oui-pl-4\" : \"oui-pt-4\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n});\n\nCarouselItem.displayName = \"CarouselItem\";\n\nconst CarouselPrevious = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>((originalProps, ref) => {\n const {\n className,\n variant = \"contained\",\n size = \"icon\",\n ...props\n } = originalProps;\n const { orientation, scrollPrev, canScrollPrev } = useCarousel();\n return (\n <Button\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-size-8 oui-rounded-full\",\n orientation === \"horizontal\"\n ? \"oui--left-12 oui-top-1/2 oui--translate-y-1/2\"\n : \"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90\",\n className,\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n {...props}\n >\n <ChevronLeftIcon size={20} />\n <span className=\"oui-sr-only\">Previous slide</span>\n </Button>\n );\n});\n\nCarouselPrevious.displayName = \"CarouselPrevious\";\n\nconst CarouselNext = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>((originalProps, ref) => {\n const {\n className,\n variant = \"contained\",\n size = \"icon\",\n ...props\n } = originalProps;\n const { orientation, scrollNext, canScrollNext } = useCarousel();\n return (\n <Button\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-size-8 oui-rounded-full\",\n orientation === \"horizontal\"\n ? \"oui--right-12 oui-top-1/2 oui--translate-y-1/2\"\n : \"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90\",\n className,\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n {...props}\n >\n <ChevronRightIcon size={20} />\n <span className=\"oui-sr-only\">Next slide</span>\n </Button>\n );\n});\n\nCarouselNext.displayName = \"CarouselNext\";\n\nexport type CarouselIdentifierProps = {\n className?: string;\n dotClassName?: string;\n dotActiveClassName?: string;\n onClick?: (index: number) => void;\n // asChild?: boolean;\n};\n\nconst CarouselIdentifier: React.FC<CarouselIdentifierProps> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n return (\n <div className={cn(\"oui-flex oui-gap-1\", props.className)}>\n {scrollSnaps.map((_, index) => {\n return (\n <Dot\n key={index}\n index={index}\n active={index === selectedIndex}\n onClick={props.onClick}\n className={props.dotClassName}\n activeClassName={props.dotActiveClassName}\n />\n );\n })}\n </div>\n );\n};\n\nCarouselIdentifier.displayName = \"CarouselIdentifier\";\n\nexport const Dot: React.FC<{\n index: number;\n active: boolean;\n onClick?: (index: number) => void;\n className?: string;\n activeClassName?: string;\n}> = ({ index, active, onClick, className, activeClassName }) => {\n const activedClassName = activeClassName || \"oui-bg-primary-darken\";\n return (\n <button\n onClick={() => onClick?.(index)}\n className={cn(\n \"oui-size-2 oui-rounded-full oui-bg-white/30\",\n className,\n active && `active ${activedClassName}`,\n )}\n />\n );\n};\n\nexport {\n type CarouselApi,\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselPrevious,\n CarouselNext,\n CarouselIdentifier,\n};\n","import {\n Carousel as OriginCarousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n CarouselIdentifier,\n} from \"./carousel\";\n\nexport type Carousel = typeof OriginCarousel & {\n Content: typeof CarouselContent;\n Item: typeof CarouselItem;\n Next: typeof CarouselNext;\n Previous: typeof CarouselPrevious;\n indentify: typeof CarouselIdentifier;\n};\n\nconst Carousel = OriginCarousel as Carousel;\n\nCarousel.Content = CarouselContent;\nCarousel.Item = CarouselItem;\nCarousel.Next = CarouselNext;\nCarousel.Previous = CarouselPrevious;\nCarousel.indentify = CarouselIdentifier;\n\nexport { Carousel };\n","import { FC } from \"react\";\nimport { DesktopSharePnLContent } from \"./desktop/content\";\nimport { MobileSharePnLContent } from \"./mobile/content\";\nimport { SharePnLState } from \"./sharePnL.script\";\n\nexport const DesktopSharePnL: FC<SharePnLState> = (props) => {\n const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;\n\n if (!shareOptions || !entity) {\n return null;\n }\n return (\n <DesktopSharePnLContent\n entity={entity}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n\nexport const MobileSharePnL: FC<SharePnLState> = (props) => {\n const { entity, baseDp, quoteDp, referralInfo, shareOptions, hide } = props;\n if (!shareOptions || !entity) {\n return null;\n }\n return (\n <MobileSharePnLContent\n entity={entity}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n","import { SharePnLOptions, SharePnLParams } from \"../types/types\";\nimport { useSharePnLScript } from \"./sharePnL.script\";\nimport { DesktopSharePnL, MobileSharePnL } from \"./sharePnL.ui\";\n\nexport const SharePnLBottomSheetWidget = (props: {\n hide?: () => void;\n pnl?: SharePnLOptions & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <MobileSharePnL {...state} />;\n};\n\nexport const SharePnLDialogWidget = (props: {\n hide?: () => void;\n pnl?: SharePnLOptions & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <DesktopSharePnL {...state} />;\n};\n"]}
@@ -0,0 +1 @@
1
+ .oui-custom-scrollbar::-webkit-scrollbar{width:6px;height:6px}.oui-custom-scrollbar::-webkit-scrollbar-track{background-color:transparent;border-radius:4px;padding-top:20px}.oui-custom-scrollbar::-webkit-scrollbar-thumb{border-radius:3px;border:1px dashed transparent;background-color:rgb(var(--oui-color-base-7));background-clip:padding-box}.oui-custom-scrollbar::-webkit-scrollbar-thumb:hover{background:rgb(var(--oui-color-base-5));border-radius:3px}.oui-custom-scrollbar::-webkit-scrollbar-corner{background-color:transparent}.oui-hide-scrollbar::-webkit-scrollbar,.oui-hide-scrollbar::-webkit-scrollbar-thumb{display:none}.oui-sr-only{width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.oui-absolute,.oui-sr-only{position:absolute}.oui-relative{position:relative}.oui--bottom-12{bottom:-3rem}.oui--left-12{left:-3rem}.oui--right-12{right:-3rem}.oui--top-12{top:-3rem}.oui-left-1\/2{left:50%}.oui-top-1\/2{top:50%}.oui-row-span-1{grid-row:span 1/span 1}.oui-mx-0{margin-left:0;margin-right:0}.oui-mx-1{margin-left:.25rem;margin-right:.25rem}.oui-mx-11{margin-left:2.75rem;margin-right:2.75rem}.oui-mx-2{margin-left:.5rem;margin-right:.5rem}.oui--ml-4{margin-left:-1rem}.oui--mt-4{margin-top:-1rem}.oui-mb-1{margin-bottom:.25rem}.oui-mb-6{margin-bottom:1.5rem}.oui-mb-8{margin-bottom:2rem}.oui-ml-1{margin-left:.25rem}.oui-ml-2{margin-left:.5rem}.oui-mr-3{margin-right:.75rem}.oui-mt-0{margin-top:0}.oui-mt-2{margin-top:.5rem}.oui-mt-3{margin-top:.75rem}.oui-mt-4{margin-top:1rem}.oui-mt-\[2px\]{margin-top:2px}.oui-flex{display:flex}.oui-grid{display:grid}.oui-size-2{width:.5rem;height:.5rem}.oui-size-8{width:2rem;height:2rem}.oui-size-full{width:100%;height:100%}.oui-h-\[18px\]{height:18px}.oui-h-\[40px\]{height:40px}.oui-h-\[46px\]{height:46px}.oui-h-\[48px\]{height:48px}.oui-h-\[4px\]{height:4px}.oui-h-full{height:100%}.oui-max-h-\[200px\]{max-height:200px}.oui-w-\[162px\]{width:162px}.oui-w-\[16px\]{width:16px}.oui-w-\[20px\]{width:20px}.oui-w-\[320px\]{width:320px}.oui-w-\[calc\(50\%-6px\)\]{width:calc(50% - 6px)}.oui-w-full{width:100%}.oui-min-w-0{min-width:0}.\!oui-max-w-\[624px\]{max-width:624px!important}.oui-max-w-\[396px\]{max-width:396px}.oui-flex-1{flex:1 1 0%}.oui-shrink-0{flex-shrink:0}.oui-grow-0{flex-grow:0}.oui-basis-full{flex-basis:100%}.oui-origin-top-left{transform-origin:top left}.oui--translate-x-1\/2{--tw-translate-x:-50%}.oui--translate-x-1\/2,.oui--translate-y-1\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.oui--translate-y-1\/2{--tw-translate-y:-50%}.oui-rotate-90{--tw-rotate:90deg}.oui-rotate-90,.oui-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.oui-cursor-pointer{cursor:pointer}.oui-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.oui-flex-col{flex-direction:column}.oui-flex-wrap{flex-wrap:wrap}.oui-items-center{align-items:center}.oui-justify-center{justify-content:center}.oui-justify-between{justify-content:space-between}.oui-gap-1{gap:.25rem}.oui-gap-3{gap:.75rem}.oui-overflow-hidden{overflow:hidden}.oui-overflow-x-auto{overflow-x:auto}.oui-overflow-y-auto{overflow-y:auto}.oui-rounded-full{border-radius:var(--oui-rounded-full,9999px)}.oui-rounded-lg{border-radius:var(--oui-rounded-lg,.5rem)}.oui-rounded-sm{border-radius:var(--oui-rounded-sm,.125rem)}.oui-border-white\/10{border-color:hsla(0,0%,100%,.1)}.\!oui-bg-primary-darken{--tw-bg-opacity:1!important;background-color:rgb(var(--oui-color-primary-darken)/var(--tw-bg-opacity,1))!important}.oui-bg-base-4{--tw-bg-opacity:1;background-color:rgb(var(--oui-color-base-4)/var(--tw-bg-opacity,1))}.oui-bg-primary-darken{--tw-bg-opacity:1;background-color:rgb(var(--oui-color-primary-darken)/var(--tw-bg-opacity,1))}.oui-bg-transparent{background-color:transparent}.oui-bg-white\/30{background-color:hsla(0,0%,100%,.3)}.oui-fill-primary-darken{fill:rgb(var(--oui-color-primary-darken)/1)}.oui-p-0{padding:0}.oui-p-3{padding:.75rem}.oui-px-1{padding-left:.25rem;padding-right:.25rem}.oui-px-3{padding-left:.75rem;padding-right:.75rem}.oui-pb-4{padding-bottom:1rem}.oui-pl-4{padding-left:1rem}.oui-pt-0{padding-top:0}.oui-pt-2{padding-top:.5rem}.oui-pt-3{padding-top:.75rem}.oui-pt-4{padding-top:1rem}.oui-pt-6{padding-top:1.5rem}.oui-pt-\[2px\]{padding-top:2px}.oui-text-2xs{font-size:var(--oui-font-size-2xs,.75rem);line-height:1.125rem}.oui-text-3xs{font-size:var(--oui-font-size-3xs,.625rem);line-height:.625rem}.oui-text-\[16px\]{font-size:16px}.oui-text-sm{font-size:var(--oui-font-size-sm,.875rem);line-height:1.25rem}.oui-text-xs{font-size:var(--oui-font-size-xs,calc(.875rem - 1px));line-height:1.25rem}.oui-text-base-contrast{color:rgb(var(--oui-color-base-foreground)/.98)}.oui-text-base-contrast-54{color:rgb(var(--oui-color-base-foreground)/.54)}.oui-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.oui-outline{outline-style:solid}.oui-outline-1{outline-width:1px}.oui-outline-primary-darken{outline-color:rgb(var(--oui-color-primary-darken)/1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.hover\:oui-cursor-pointer:hover{cursor:pointer}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@kodiak-finance/orderly-ui-share",
3
+ "version": "2.7.4",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "keywords": [
8
+ "Orderly",
9
+ "Share"
10
+ ],
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "dependencies": {
18
+ "@kodiak-finance/orderly-i18n": "2.7.4",
19
+ "@kodiak-finance/orderly-ui": "2.7.4",
20
+ "@kodiak-finance/orderly-hooks": "2.7.4",
21
+ "@kodiak-finance/orderly-utils": "2.7.4",
22
+ "@kodiak-finance/orderly-types": "2.7.4"
23
+ },
24
+ "devDependencies": {
25
+ "@swc/cli": "^0.3.12",
26
+ "@swc/core": "^1.4.12",
27
+ "@types/react": "^18.3.2",
28
+ "@types/react-dom": "^18.3.0",
29
+ "react": "^18.2.0",
30
+ "react-dom": "^18.2.0",
31
+ "tailwindcss": "^3.4.4",
32
+ "tsup": "^7.1.0",
33
+ "tsconfig": "0.10.4"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=18",
37
+ "react-dom": ">=18"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup && pnpm run build:css",
41
+ "build:css": "tailwindcss build -i src/tailwind.css -o dist/styles.css --minify",
42
+ "test": "echo \"Error: no test specified\" && exit 1"
43
+ }
44
+ }