@orderly.network/ui-share 2.0.0 → 2.0.1-alpha.0

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.
package/dist/index.d.mts CHANGED
@@ -79,7 +79,7 @@ declare const useSharePnLScript: (props: {
79
79
  baseDp: any;
80
80
  quoteDp: any;
81
81
  referralInfo: ReferralType | undefined;
82
- shareOptions: SharePnLConfig;
82
+ shareOptions: SharePnLConfig | undefined;
83
83
  hide: (() => void) | undefined;
84
84
  };
85
85
 
package/dist/index.d.ts CHANGED
@@ -79,7 +79,7 @@ declare const useSharePnLScript: (props: {
79
79
  baseDp: any;
80
80
  quoteDp: any;
81
81
  referralInfo: ReferralType | undefined;
82
- shareOptions: SharePnLConfig;
82
+ shareOptions: SharePnLConfig | undefined;
83
83
  hide: (() => void) | undefined;
84
84
  };
85
85
 
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var hooks = require('@orderly.network/hooks');
5
5
  var p = require('react');
6
6
  var utils = require('@orderly.network/utils');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
- var Xe = require('embla-carousel-react');
8
+ var je = require('embla-carousel-react');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
@@ -28,14 +28,14 @@ function _interopNamespace(e) {
28
28
  }
29
29
 
30
30
  var p__namespace = /*#__PURE__*/_interopNamespace(p);
31
- var Xe__default = /*#__PURE__*/_interopDefault(Xe);
31
+ var je__default = /*#__PURE__*/_interopDefault(je);
32
32
 
33
- var Y=e=>{let{pnl:t,hide:o}=e,a=t?.position,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),l=n[a?.symbol]("base_dp"),i=n[a?.symbol]("quote_dp"),c=p.useMemo(()=>{let s=r()?.code;return {code:t?.refCode??s,slogan:t?.refSlogan,link:t?.refLink}},[r,t]);return {position:a,leverage:t?.leverage,baseDp:l,quoteDp:i,referralInfo:c,shareOptions:t,hide:o}};function Z(e,t,o,a,n,r,l,i,c){let{symbol:s,currency:u}=Ve(e.symbol),h={symbol:s,currency:u,side:e.position_qty>0?"LONG":"SHORT"};switch(n){case"pnl":{"unrealized_pnl"in e&&(h.pnl=new utils.Decimal(e.unrealized_pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi":{"unrealized_pnl_ROI"in e&&(h.ROI=new utils.Decimal(e.unrealized_pnl_ROI*100).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi_pnl":{"unrealized_pnl"in e&&(h.pnl=new utils.Decimal(e.unrealized_pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),"unrealized_pnl_ROI"in e&&(h.ROI=new utils.Decimal(e.unrealized_pnl_ROI*100).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let v=[];r.has("leverage")&&(h.leverage=t),["openPrice","openTime","markPrice","quantity"].forEach(b=>{if(r.has(b))switch(b){case"leverage":break;case"openPrice":{v.push({title:"Open price",value:te(e.average_open_price,i||2)});break}case"openTime":{v.push({title:"Opened at",value:Qe(e.timestamp)});break}case"markPrice":{v.push({title:"Mark price",value:te(e.mark_price,i||2)});break}case"quantity":v.push({title:"Quantity",value:te(e.position_qty,l||2)});}}),h.informations=v;let S={position:h,updateTime:Ke(new Date),domain:a};return o.length>0&&(S.message=o),typeof c<"u"&&c.code!==void 0&&(S.referral=c),S}function Ve(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[o,a,n]=t;return {symbol:`${a}-${o}`,currency:n||"USDC"}}function Ke(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h24"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(u=>u.type==="year"?u.value:"")?.value,l=n.find(u=>u.type==="month"?u.value:"")?.value,i=n.find(u=>u.type==="day"?u.value:"")?.value,c=n.find(u=>u.type==="hour"?u.value:"")?.value,s=n.find(u=>u.type==="minute"?u.value:"")?.value;return `${r}-${l}-${i} ${c}:${s}`}function Qe(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(s=>s.type==="month"?s.value:"")?.value,l=n.find(s=>s.type==="day"?s.value:"")?.value,i=n.find(s=>s.type==="hour"?s.value:"")?.value,c=n.find(s=>s.type==="minute"?s.value:"")?.value;return `${r}-${l} ${i}:${c}`}function te(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function G(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function X(){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","openTime","markPrice","quantity","leverage"],message:""}}var W=p.forwardRef((e,t)=>{let{width:o,height:a,className:n,data:r,style:l}=e,{ref:i,download:c,toDataURL:s,copy:u,toBlob:h}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:c,toDataURL:s,toBlob:h,copy:u})),jsxRuntime.jsx("canvas",{ref:i,width:o,height:a,className:n,style:l})});var ge=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,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"})]})})},ye=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,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 xe=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=Xe__default.default({containScroll:"keepSnaps",dragFree:!0}),l=p.useCallback(()=>{r&&r.scrollPrev();},[r]),i=p.useCallback(()=>{r&&r.scrollNext();},[r]),c=p.useCallback(s=>{a(s.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(c(r),r.on("reInit",c),r.on("select",c),r?.scrollTo(o));},[r,c]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(ge,{onClick:l}),jsxRuntime.jsx("div",{ref:n,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsxRuntime.jsx(ui.Flex,{children:t.map((s,u)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(u);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===u&&"oui-outline oui-outline-1 oui-outline-primary"),children:jsxRuntime.jsx("img",{src:s,className:"oui-rounded-sm"})},s))})}),jsxRuntime.jsx(ye,{onClick:i})]})};var Se=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]),r=t===o,l="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return r?l+=" oui-text-base-contrast":l+="",jsxRuntime.jsxs("div",{className:l,onClick:()=>{a(t);},children:[jsxRuntime.jsx(st,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},st=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===!0?jsxRuntime.jsx(it,{}):jsxRuntime.jsx(lt,{})}),it=()=>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",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 j=e=>{let{size:t=16,className:o}=e;return jsxRuntime.jsx("button",{type:"button",onClick:a=>{e.onCheckedChange(!e.checked);},className:o,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 we=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs(ui.Flex,{itemAlign:"center",gap:1,className:ui.cn("hover:oui-cursor-pointer"),onClick:()=>{a(l=>{let i=new Set(l);return r?i.delete(t):i.add(t),i});},children:[jsxRuntime.jsx(j,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:l=>{a(i=>{let c=new Set(i);return r?c.delete(t):c.add(t),c});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var Ne=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,l]=p.useState(!1),i=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(j,{className:"oui-mt-[2px]",checked:a,onCheckedChange:c=>{n(c);}}),jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{n(!e.check);},children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsxRuntime.jsx(ui.Input,{ref:i,placeholder:"Max 25 characters",classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:!1,suffix:r&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:c=>{o(""),setTimeout(()=>{i.current?.focus();},50),c.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:c=>{if(c.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(c.target.value.length>0),o(c.target.value);}})})]})};var De=e=>{let{onClickDownload:t,onClickCopy:o}=e;return jsxRuntime.jsxs(ui.Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxRuntime.jsxs(ui.Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(St,{})}),"Download"]}),jsxRuntime.jsxs(ui.Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:o,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(bt,{})}),"Copy"]})]})},St=()=>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"})}),bt=()=>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 Oe=e=>{let{shareOptions:t}=e,o=X(),[a,n]=p.useState(o.pnlFormat),[r,l]=p.useState(new Set(o.options)),[i,c]=p.useState(o.bgIndex),[s,u]=p.useState(o.message),[h,v]=p.useState(!1),{backgroundImages:M,...S}=t??{backgroundImages:[]},[b,I]=p.useState(""),C=p.useRef(null);p.useEffect(()=>{let w=window.location.hostname;I(w);},[]);let P=p.useMemo(()=>t?.backgroundImages[i],[t?.backgroundImages,i]),O=Z(e.position,e.leverage,h?s:"",b,a,r,e.baseDp,e.quoteDp,e.referral),R=()=>{C.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(w=>{ui.toast.error(()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{children:"Copy failed"}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54",children:"Browser version outdated, please update in order to copy image to clipboard."})]}));});},z=()=>{C.current?.download("Poster.png"),e.hide?.();},g=["roi_pnl","roi","pnl"],ee=["openPrice","markPrice","openTime","leverage","quantity"];return G(a,r,i,s),jsxRuntime.jsxs("div",{className:"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full",children:[jsxRuntime.jsxs("div",{className:"oui-flex-1 oui-h-full oui-overflow-y-auto",children:[jsxRuntime.jsxs(ui.Box,{mt:9,height:422,children:[jsxRuntime.jsx(ui.Flex,{itemAlign:"center",justify:"center",children:jsxRuntime.jsx(W,{width:552,height:310,data:{backgroundImg:P,...S,data:O},ratio:3,ref:C})}),jsxRuntime.jsx(xe,{backgroundImages:t?.backgroundImages??[],selectedSnap:i,setSelectedSnap:c})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"PnL display format"}),jsxRuntime.jsx(ui.Flex,{pt:3,gap:3,itemAlign:"center",children:g.map(w=>jsxRuntime.jsx(Se,{setPnlFormat:n,type:w,curType:a}))}),jsxRuntime.jsx(ui.Divider,{className:"oui-w-full oui-pt-6 oui-border-white/10"}),jsxRuntime.jsxs(ui.Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"Optional information to share"}),jsxRuntime.jsx(ui.Flex,{mt:3,gap:4,children:ee.map(w=>jsxRuntime.jsx(we,{setShareOption:l,type:w,curType:r}))})]}),jsxRuntime.jsx(Ne,{message:s,setMessage:u,check:h,setCheck:v})]})]}),jsxRuntime.jsx(De,{onClickCopy:R,onClickDownload:z}),jsxRuntime.jsx("button",{onClick:()=>{e.hide();},className:"oui-absolute oui-top-0 oui-right-0 oui-w-[40px] oui-h-[40px] oui-flex oui-justify-center oui-items-center",children:jsxRuntime.jsx(ui.CloseIcon,{size:12,className:"oui-fill-base-contrast-54"})})]})};var Fe=p__namespace.createContext(null);function T(){let e=p__namespace.useContext(Fe);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var ne=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...l},i)=>{let[c,s]=Xe__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[u,h]=p__namespace.useState(!1),[v,M]=p__namespace.useState(!1),[S,b]=p__namespace.useState(l.initIndex||0),[I,C]=p__namespace.useState([]),P=p__namespace.useCallback(g=>{g&&(I.length===0&&C(g.scrollSnapList()),b(g.selectedScrollSnap()),h(g.canScrollPrev()),M(g.canScrollNext()));},[I]),O=p__namespace.useCallback(()=>{s?.scrollPrev();},[s]),R=p__namespace.useCallback(()=>{s?.scrollNext();},[s]),z=p__namespace.useCallback(g=>{g.key==="ArrowLeft"?(g.preventDefault(),O()):g.key==="ArrowRight"&&(g.preventDefault(),R());},[O,R]);return p__namespace.useEffect(()=>{!s||!o||o(s);},[s,o]),p__namespace.useEffect(()=>{if(s)return P(s),s.on("reInit",P),s.on("select",P),l.initIndex&&s.scrollTo(l.initIndex),()=>{s?.off("select",P);}},[s,P]),jsxRuntime.jsx(Fe.Provider,{value:{carouselRef:c,api:s,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:O,scrollNext:R,canScrollPrev:u,canScrollNext:v,selectedIndex:S,scrollSnaps:I},children:jsxRuntime.jsx("div",{ref:i,onKeyDownCapture:z,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...l,children:r})})});ne.displayName="Carousel";var K=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=T();return jsxRuntime.jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsxRuntime.jsx("div",{ref:o,className:ui.cn("oui-flex",n==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",e),...t})})});K.displayName="CarouselContent";var Q=p__namespace.forwardRef(({className:e,...t},o)=>{let{orientation:a}=T();return jsxRuntime.jsx("div",{ref:o,role:"group","aria-roledescription":"slide",className:ui.cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",e),...t})});Q.displayName="CarouselItem";var ae=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:l,canScrollPrev:i}=T();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="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",e),disabled:!i,onClick:l,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ae.displayName="CarouselPrevious";var se=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:l,canScrollNext:i}=T();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="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",e),disabled:!i,onClick:l,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});se.displayName="CarouselNext";var ie=e=>{let{scrollSnaps:t,selectedIndex:o}=T();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(le,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};ie.displayName="CarouselIdentifier";var le=({index:e,active:t,onClick:o,className:a,activeClassName:n})=>jsxRuntime.jsx("button",{onClick:()=>o?.(e),className:ui.cn("oui-w-2 oui-h-2 oui-rounded-full oui-bg-white/30",a,t&&`active ${n||"oui-bg-primary"}`)});var B=ne;B.Content=K;B.Item=Q;B.Next=se;B.Previous=ae;B.indentify=ie;var Me=e=>{let{shareOptions:t}=e,o=X(),[a,n]=p.useState(o.pnlFormat),[r,l]=p.useState(new Set(o.options)),[i,c]=p.useState(o.message),[s,u]=p.useState(o.bgIndex),{backgroundImages:h,...v}=t??{backgroundImages:[]},[M,S]=p.useState(""),b=t?.backgroundImages.map(()=>p.useRef(null));p.useEffect(()=>{let d=window.location.hostname;S(d);},[]);let I=Z(e.position,e.leverage,i,M,a,r,e.baseDp,e.quoteDp,e.referral),C=p.useRef(),P=552/310,[O,R]=p.useState(1),[z,g]=p.useState(0),[ee,w]=p.useState(!1),he=p.useRef(null);p.useEffect(()=>{if(C.current){let d=C.current.offsetWidth,_=d/P;g(_),R(d/552);}},[C,M]);let He=async d=>{if(!d.current)return;let _=d.current?.toDataURL(),qe=Mt(_);try{navigator.share&&await navigator.share({text:i,files:[new File([qe],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return G(a,r,s,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:C,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${z+20}px`},children:jsxRuntime.jsxs(B,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:s,children:[jsxRuntime.jsx(K,{style:{height:`${z}px`},children:t?.backgroundImages.map((d,_)=>jsxRuntime.jsx(Q,{children:jsxRuntime.jsx(W,{className:"oui-transform oui-origin-top-left",style:{scale:`${O}`},width:552,height:310,data:{backgroundImg:d,...v,data:I},ratio:3,ref:b?.[_]})},_))}),jsxRuntime.jsx("div",{className:"oui-mt-2 oui-mb-1 oui-flex oui-justify-center",children:jsxRuntime.jsx(zt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary oui-w-[20px]",setSelectIndex:u})})]})}),jsxRuntime.jsxs(ui.ScrollArea,{className:"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:"PnL display format"}),jsxRuntime.jsxs("div",{className:"oui-pt-3 oui-px-1 oui-flex oui-justify-between oui-gap-3",children:[jsxRuntime.jsx(ue,{setPnlFormat:n,type:"roi_pnl",curType:a}),jsxRuntime.jsx(ue,{setPnlFormat:n,type:"roi",curType:a}),jsxRuntime.jsx(ue,{setPnlFormat:n,type:"pnl",curType:a})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Optional information to share"}),jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3",children:[jsxRuntime.jsx(J,{setShareOption:l,type:"openPrice",curType:r}),jsxRuntime.jsx(J,{setShareOption:l,type:"openTime",curType:r}),jsxRuntime.jsx(J,{setShareOption:l,type:"leverage",curType:r}),jsxRuntime.jsx(J,{setShareOption:l,type:"markPrice",curType:r}),jsxRuntime.jsx(J,{setShareOption:l,type:"quantity",curType:r})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-8",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1",children:jsxRuntime.jsx(ui.Input,{placeholder:"Max 25 characters",containerClassName:"oui-bg-transparent oui-h-[48px]",value:i,autoFocus:!1,onChange:d=>{if(d.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}c(d.target.value);},ref:he,onFocus:()=>w(!0),onBlur:()=>w(!1),suffix:ee&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:d=>{c(""),setTimeout(()=>{he.current?.focus();},50),d.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsxRuntime.jsx("div",{className:"oui-pt-2",children:jsxRuntime.jsx(ui.Button,{fullWidth:!0,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let d=b?.[s];d&&He(d);},children:"Share"})})]})},ue=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]);return jsxRuntime.jsx("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-flex-1 oui-bg-base-4 hover:oui-cursor-pointer oui-flex oui-items-center oui-px-3 oui-referral-shadow",t===o&&"oui-bg-primary oui-dot-sel"),onClick:()=>{a(t);},children:jsxRuntime.jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:n})})},J=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-mt-0 oui-w-[calc(50%-6px)] oui-bg-base-4 hover:oui-cursor-pointer oui-items-center oui-flex oui-p-3 oui-referral-shadow"),onClick:()=>{a(l=>{let i=new Set(l);return r?i.delete(t):i.add(t),i});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(_t,{})]})};function Mt(e){let t=atob(e.split(",")[1]),o=e.split(",")[0].split(":")[1].split(";")[0],a=new ArrayBuffer(t.length),n=new Uint8Array(a);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Blob([a],{type:o})}var zt=e=>{let{scrollSnaps:t,selectedIndex:o}=T();return p.useEffect(()=>{e.setSelectIndex(o);},[o]),jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1"),children:t.map((a,n)=>jsxRuntime.jsx(le,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},_t=()=>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","fill-opacity":"1"})});var ze=e=>{let{leverage:t,position:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:i}=e,[c,s]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let u=()=>{s(window.innerHeight<900?660:807);};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u);}},[]),jsxRuntime.jsx(Oe,{position:o,leverage:`${t}`,hide:i,baseDp:a,quoteDp:n,referral:r,shareOptions:l})},_e=e=>{let{leverage:t,position:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:i}=e;return jsxRuntime.jsx(Me,{position:o,leverage:t,hide:i,baseDp:a,quoteDp:n,referral:r,shareOptions:l})};var de=e=>{let t=Y({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})},fe=e=>{let t=Y({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(ze,{...t})};var Ut="sharePnLDialog",Wt="sharePnLBottomSheet";ui.registerSimpleDialog(Ut,fe,{contentClassName:"!oui-max-w-[624px] oui-p-0"});ui.registerSimpleSheet(Wt,de,{title:"Share PnL"});
33
+ var Z=e=>{let{pnl:t,hide:o}=e,a=t?.position,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),i=n[a?.symbol]("base_dp"),l=n[a?.symbol]("quote_dp"),c=p.useMemo(()=>{let s=r()?.code;return {code:t?.refCode??s,slogan:t?.refSlogan,link:t?.refLink}},[r,t]);return {position:a,leverage:t?.leverage,baseDp:i,quoteDp:l,referralInfo:c,shareOptions:t,hide:o}};function G(e,t,o,a,n,r,i,l,c){let{symbol:s,currency:u}=Ke(e.symbol),f={symbol:s,currency:u,side:e.position_qty>0?"LONG":"SHORT"};switch(n){case"pnl":{"unrealized_pnl"in e&&(f.pnl=new utils.Decimal(e.unrealized_pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi":{"unrealized_pnl_ROI"in e&&(f.ROI=new utils.Decimal(e.unrealized_pnl_ROI*100).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi_pnl":{"unrealized_pnl"in e&&(f.pnl=new utils.Decimal(e.unrealized_pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),"unrealized_pnl_ROI"in e&&(f.ROI=new utils.Decimal(e.unrealized_pnl_ROI*100).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let v=[];r.has("leverage")&&(f.leverage=t),["openPrice","openTime","markPrice","quantity"].forEach(b=>{if(r.has(b))switch(b){case"leverage":break;case"openPrice":{v.push({title:"Open price",value:re(e.average_open_price,l||2)});break}case"openTime":{v.push({title:"Opened at",value:Je(e.timestamp)});break}case"markPrice":{v.push({title:"Mark price",value:re(e.mark_price,l||2)});break}case"quantity":v.push({title:"Quantity",value:re(e.position_qty,i||2)});}}),f.informations=v;let S={position:f,updateTime:Qe(new Date),domain:a};return o.length>0&&(S.message=o),typeof c<"u"&&c.code!==void 0&&(S.referral=c),S}function Ke(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[o,a,n]=t;return {symbol:`${a}-${o}`,currency:n||"USDC"}}function Qe(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h24"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(u=>u.type==="year"?u.value:"")?.value,i=n.find(u=>u.type==="month"?u.value:"")?.value,l=n.find(u=>u.type==="day"?u.value:"")?.value,c=n.find(u=>u.type==="hour"?u.value:"")?.value,s=n.find(u=>u.type==="minute"?u.value:"")?.value;return `${r}-${i}-${l} ${c}:${s}`}function Je(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(s=>s.type==="month"?s.value:"")?.value,i=n.find(s=>s.type==="day"?s.value:"")?.value,l=n.find(s=>s.type==="hour"?s.value:"")?.value,c=n.find(s=>s.type==="minute"?s.value:"")?.value;return `${r}-${i} ${l}:${c}`}function re(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function X(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function j(){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","openTime","markPrice","quantity","leverage"],message:""}}var $=p.forwardRef((e,t)=>{let{width:o,height:a,className:n,data:r,style:i}=e,{ref:l,download:c,toDataURL:s,copy:u,toBlob:f}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:c,toDataURL:s,toBlob:f,copy:u})),jsxRuntime.jsx("canvas",{ref:l,width:o,height:a,className:n,style:i})});var ye=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,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"})]})})},ve=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,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 Se=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=je__default.default({containScroll:"keepSnaps",dragFree:!0}),i=p.useCallback(()=>{r&&r.scrollPrev();},[r]),l=p.useCallback(()=>{r&&r.scrollNext();},[r]),c=p.useCallback(s=>{a(s.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(c(r),r.on("reInit",c),r.on("select",c),r?.scrollTo(o));},[r,c]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(ye,{onClick:i}),jsxRuntime.jsx("div",{ref:n,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsxRuntime.jsx(ui.Flex,{children:t.map((s,u)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(u);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===u&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:s,className:"oui-rounded-sm"})},s))})}),jsxRuntime.jsx(ve,{onClick:l})]})};var be=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]),r=t===o,i="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return r?i+=" oui-text-base-contrast":i+="",jsxRuntime.jsxs("div",{className:i,onClick:()=>{a(t);},children:[jsxRuntime.jsx(it,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},it=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===!0?jsxRuntime.jsx(lt,{}):jsxRuntime.jsx(ct,{})}),lt=()=>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"})]}),ct=()=>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 ee=e=>{let{size:t=16,className:o}=e;return jsxRuntime.jsx("button",{type:"button",onClick:a=>{e.onCheckedChange(!e.checked);},className:o,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 Ne=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs(ui.Flex,{itemAlign:"center",gap:1,className:ui.cn("hover:oui-cursor-pointer"),onClick:()=>{a(i=>{let l=new Set(i);return r?l.delete(t):l.add(t),l});},children:[jsxRuntime.jsx(ee,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:i=>{a(l=>{let c=new Set(l);return r?c.delete(t):c.add(t),c});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var ke=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,i]=p.useState(!1),l=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(ee,{className:"oui-mt-[2px]",checked:a,onCheckedChange:c=>{n(c);}}),jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{n(!e.check);},children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsxRuntime.jsx(ui.Input,{ref:l,placeholder:"Max 25 characters",classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:!1,suffix:r&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:c=>{o(""),setTimeout(()=>{l.current?.focus();},50),c.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>i(!0),onBlur:()=>i(!1),onChange:c=>{if(c.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(c.target.value.length>0),o(c.target.value);}})})]})};var De=e=>{let{onClickDownload:t,onClickCopy:o}=e;return jsxRuntime.jsxs(ui.Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxRuntime.jsxs(ui.Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(bt,{})}),"Download"]}),jsxRuntime.jsxs(ui.Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:o,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(Pt,{})}),"Copy"]})]})},bt=()=>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"})}),Pt=()=>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 Re=e=>{let{shareOptions:t}=e,o=j(),[a,n]=p.useState(o.pnlFormat),[r,i]=p.useState(new Set(o.options)),[l,c]=p.useState(o.bgIndex),[s,u]=p.useState(o.message),[f,v]=p.useState(!1),{backgroundImages:M,...S}=t??{backgroundImages:[]},[b,I]=p.useState(""),C=p.useRef(null);p.useEffect(()=>{let w=window.location.hostname;I(w);},[]);let P=p.useMemo(()=>t?.backgroundImages?.[l],[t?.backgroundImages,l]),O=G(e.position,e.leverage,f?s:"",b,a,r,e.baseDp,e.quoteDp,e.referral),R=()=>{C.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(w=>{ui.toast.error(()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{children:"Copy failed"}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54",children:"Browser version outdated, please update in order to copy image to clipboard."})]}));});},z=()=>{C.current?.download("Poster.png"),e.hide?.();},h=["roi_pnl","roi","pnl"],oe=["openPrice","markPrice","openTime","leverage","quantity"];return X(a,r,l,s),jsxRuntime.jsxs("div",{className:"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full",children:[jsxRuntime.jsxs("div",{className:"oui-flex-1 oui-h-full oui-overflow-y-auto",children:[jsxRuntime.jsxs(ui.Box,{mt:9,height:422,children:[jsxRuntime.jsx(ui.Flex,{itemAlign:"center",justify:"center",children:jsxRuntime.jsx($,{width:552,height:310,data:{backgroundImg:P,...S,data:O},ratio:3,ref:C})}),jsxRuntime.jsx(Se,{backgroundImages:t?.backgroundImages??[],selectedSnap:l,setSelectedSnap:c})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"PnL display format"}),jsxRuntime.jsx(ui.Flex,{pt:3,gap:3,itemAlign:"center",children:h.map((w,_)=>jsxRuntime.jsx(be,{setPnlFormat:n,type:w,curType:a},_))}),jsxRuntime.jsx(ui.Divider,{className:"oui-w-full oui-pt-6 oui-border-white/10"}),jsxRuntime.jsxs(ui.Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"Optional information to share"}),jsxRuntime.jsx(ui.Flex,{mt:3,gap:4,children:oe.map((w,_)=>jsxRuntime.jsx(Ne,{setShareOption:i,type:w,curType:r},_))})]}),jsxRuntime.jsx(ke,{message:s,setMessage:u,check:f,setCheck:v})]})]}),jsxRuntime.jsx(De,{onClickCopy:R,onClickDownload:z})]})};var Te=p__namespace.createContext(null);function T(){let e=p__namespace.useContext(Te);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var se=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...i},l)=>{let[c,s]=je__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[u,f]=p__namespace.useState(!1),[v,M]=p__namespace.useState(!1),[S,b]=p__namespace.useState(i.initIndex||0),[I,C]=p__namespace.useState([]),P=p__namespace.useCallback(h=>{h&&(I.length===0&&C(h.scrollSnapList()),b(h.selectedScrollSnap()),f(h.canScrollPrev()),M(h.canScrollNext()));},[I]),O=p__namespace.useCallback(()=>{s?.scrollPrev();},[s]),R=p__namespace.useCallback(()=>{s?.scrollNext();},[s]),z=p__namespace.useCallback(h=>{h.key==="ArrowLeft"?(h.preventDefault(),O()):h.key==="ArrowRight"&&(h.preventDefault(),R());},[O,R]);return p__namespace.useEffect(()=>{!s||!o||o(s);},[s,o]),p__namespace.useEffect(()=>{if(s)return P(s),s.on("reInit",P),s.on("select",P),i.initIndex&&s.scrollTo(i.initIndex),()=>{s?.off("select",P);}},[s,P]),jsxRuntime.jsx(Te.Provider,{value:{carouselRef:c,api:s,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:O,scrollNext:R,canScrollPrev:u,canScrollNext:v,selectedIndex:S,scrollSnaps:I},children:jsxRuntime.jsx("div",{ref:l,onKeyDownCapture:z,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...i,children:r})})});se.displayName="Carousel";var Q=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=T();return jsxRuntime.jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsxRuntime.jsx("div",{ref:o,className:ui.cn("oui-flex",n==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",e),...t})})});Q.displayName="CarouselContent";var J=p__namespace.forwardRef(({className:e,...t},o)=>{let{orientation:a}=T();return jsxRuntime.jsx("div",{ref:o,role:"group","aria-roledescription":"slide",className:ui.cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",e),...t})});J.displayName="CarouselItem";var ie=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:i,canScrollPrev:l}=T();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="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",e),disabled:!l,onClick:i,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ie.displayName="CarouselPrevious";var le=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:i,canScrollNext:l}=T();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="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",e),disabled:!l,onClick:i,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});le.displayName="CarouselNext";var ce=e=>{let{scrollSnaps:t,selectedIndex:o}=T();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(ue,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};ce.displayName="CarouselIdentifier";var ue=({index:e,active:t,onClick:o,className:a,activeClassName:n})=>jsxRuntime.jsx("button",{onClick:()=>o?.(e),className:ui.cn("oui-w-2 oui-h-2 oui-rounded-full oui-bg-white/30",a,t&&`active ${n||"oui-bg-primary-darken"}`)});var B=se;B.Content=Q;B.Item=J;B.Next=le;B.Previous=ie;B.indentify=ce;var ze=e=>{let{shareOptions:t}=e,o=j(),[a,n]=p.useState(o.pnlFormat),[r,i]=p.useState(new Set(o.options)),[l,c]=p.useState(o.message),[s,u]=p.useState(o.bgIndex),{backgroundImages:f,...v}=t??{backgroundImages:[]},[M,S]=p.useState(""),b=t?.backgroundImages?.map(()=>p.useRef(null));p.useEffect(()=>{let d=window.location.hostname;S(d);},[]);let I=G(e.position,e.leverage,l,M,a,r,e.baseDp,e.quoteDp,e.referral),C=p.useRef(),P=552/310,[O,R]=p.useState(1),[z,h]=p.useState(0),[oe,w]=p.useState(!1),_=p.useRef(null);p.useEffect(()=>{if(C.current){let d=C.current.offsetWidth,A=d/P;h(A),R(d/552);}},[C,M]);let qe=async d=>{if(!d.current)return;let A=d.current?.toDataURL(),Ue=Mt(A);try{navigator.share&&await navigator.share({text:l,files:[new File([Ue],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return X(a,r,s,l),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:C,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${z+20}px`},children:jsxRuntime.jsxs(B,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:s,children:[jsxRuntime.jsx(Q,{style:{height:`${z}px`},children:t?.backgroundImages?.map((d,A)=>jsxRuntime.jsx(J,{children:jsxRuntime.jsx($,{className:"oui-transform oui-origin-top-left",style:{scale:`${O}`},width:552,height:310,data:{backgroundImg:d,...v,data:I},ratio:3,ref:b?.[A]})},A))}),jsxRuntime.jsx("div",{className:"oui-mt-2 oui-mb-1 oui-flex oui-justify-center",children:jsxRuntime.jsx(zt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary-darken oui-w-[20px]",setSelectIndex:u})})]})}),jsxRuntime.jsxs(ui.ScrollArea,{className:"oui-max-h-[200px] oui-overflow-y-auto oui-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"oui-mt-4",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54",children:"PnL display format"}),jsxRuntime.jsxs("div",{className:"oui-pt-3 oui-px-1 oui-flex oui-justify-between oui-gap-3",children:[jsxRuntime.jsx(pe,{setPnlFormat:n,type:"roi_pnl",curType:a}),jsxRuntime.jsx(pe,{setPnlFormat:n,type:"roi",curType:a}),jsxRuntime.jsx(pe,{setPnlFormat:n,type:"pnl",curType:a})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Optional information to share"}),jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3",children:[jsxRuntime.jsx(Y,{setShareOption:i,type:"openPrice",curType:r}),jsxRuntime.jsx(Y,{setShareOption:i,type:"openTime",curType:r}),jsxRuntime.jsx(Y,{setShareOption:i,type:"leverage",curType:r}),jsxRuntime.jsx(Y,{setShareOption:i,type:"markPrice",curType:r}),jsxRuntime.jsx(Y,{setShareOption:i,type:"quantity",curType:r})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-8",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1",children:jsxRuntime.jsx(ui.Input,{placeholder:"Max 25 characters",containerClassName:"oui-bg-transparent oui-h-[48px]",value:l,autoFocus:!1,onChange:d=>{if(d.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}c(d.target.value);},ref:_,onFocus:()=>w(!0),onBlur:()=>w(!1),suffix:oe&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:d=>{c(""),setTimeout(()=>{_.current?.focus();},50),d.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsxRuntime.jsx("div",{className:"oui-pt-2",children:jsxRuntime.jsx(ui.Button,{fullWidth:!0,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let d=b?.[s];d&&qe(d);},children:"Share"})})]})},pe=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]);return jsxRuntime.jsx("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-flex-1 oui-bg-base-4 hover:oui-cursor-pointer oui-flex oui-items-center oui-px-3 oui-referral-shadow",t===o&&"oui-bg-primary-darken oui-dot-sel"),onClick:()=>{a(t);},children:jsxRuntime.jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:n})})},Y=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-mt-0 oui-w-[calc(50%-6px)] oui-bg-base-4 hover:oui-cursor-pointer oui-items-center oui-flex oui-p-3 oui-referral-shadow"),onClick:()=>{a(i=>{let l=new Set(i);return r?l.delete(t):l.add(t),l});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(_t,{})]})};function Mt(e){let t=atob(e.split(",")[1]),o=e.split(",")[0].split(":")[1].split(";")[0],a=new ArrayBuffer(t.length),n=new Uint8Array(a);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Blob([a],{type:o})}var zt=e=>{let{scrollSnaps:t,selectedIndex:o}=T();return p.useEffect(()=>{e.setSelectIndex(o);},[o]),jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1"),children:t.map((a,n)=>jsxRuntime.jsx(ue,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},_t=()=>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 _e=e=>{let{leverage:t,position:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:i,hide:l}=e,[c,s]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let u=()=>{s(window.innerHeight<900?660:807);};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u);}},[]),i==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(Re,{position:o,leverage:`${t}`,hide:l,baseDp:a,quoteDp:n,referral:r,shareOptions:i})},Ae=e=>{let{leverage:t,position:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:i,hide:l}=e;return i==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(ze,{position:o,leverage:t,hide:l,baseDp:a,quoteDp:n,referral:r,shareOptions:i})};var he=e=>{let t=Z({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(Ae,{...t})},ge=e=>{let t=Z({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})};var Ut="sharePnLDialog",Wt="sharePnLBottomSheet";ui.registerSimpleDialog(Ut,ge,{contentClassName:"!oui-max-w-[624px] oui-p-0"});ui.registerSimpleSheet(Wt,he,{title:"Share PnL",classNames:{body:"oui-pb-4 oui-pt-0"}});
34
34
 
35
35
  exports.SharePnLBottomSheetId = Wt;
36
- exports.SharePnLBottomSheetWidget = de;
36
+ exports.SharePnLBottomSheetWidget = he;
37
37
  exports.SharePnLDialogId = Ut;
38
- exports.SharePnLDialogWidget = fe;
39
- exports.useSharePnLScript = Y;
38
+ exports.SharePnLDialogWidget = ge;
39
+ exports.useSharePnLScript = Z;
40
40
  //# sourceMappingURL=out.js.map
41
41
  //# sourceMappingURL=index.js.map