@orderly.network/ui-share 2.0.2 → 2.0.3-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.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
|
|
|
30
30
|
var p__namespace = /*#__PURE__*/_interopNamespace(p);
|
|
31
31
|
var et__default = /*#__PURE__*/_interopDefault(et);
|
|
32
32
|
|
|
33
|
-
var G=e=>{let{pnl:t,hide:o}=e,a=t?.entity,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),l=p.useMemo(()=>{let i=r()?.code;return {code:t?.refCode??i,slogan:t?.refSlogan,link:t?.refLink}},[r,t]),s=p.useMemo(()=>{if(a)return n[a?.symbol]("base_dp")},[a,n]),u=p.useMemo(()=>{if(a)return n[a?.symbol]("quote_dp")},[a,n]);return {entity:a,leverage:t?.leverage,baseDp:s,quoteDp:u,referralInfo:l,shareOptions:t,hide:o}};function X(e,t,o,a,n,r,l,s,u){let{symbol:i,currency:c}=Qe(e.symbol),d={symbol:i,currency:c,side:e.side};switch(n){case"pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi":{e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi_pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let C=[];r.has("leverage")&&(d.leverage=t),["openPrice","openTime","markPrice","quantity"].forEach(w=>{if(r.has(w))switch(w){case"leverage":break;case"openPrice":{e.openPrice!=null&&C.push({title:"Open price",value:ae(e.openPrice,s||2)});break}case"openTime":{e.openTime!=null&&C.push({title:"Opened at",value:Ye(e.openTime)});break}case"markPrice":{e.markPrice!=null&&C.push({title:"Mark price",value:ae(e.markPrice,s||2)});break}case"quantity":e.quantity!=null&&C.push({title:"Quantity",value:ae(e.quantity,l||2)});}}),d.informations=C;let S={position:d,updateTime:Je(new Date),domain:a};return o.length>0&&(S.message=o),typeof u<"u"&&u.code!==void 0&&(S.referral=u),S}function Qe(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 Je(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(c=>c.type==="year"?c.value:"")?.value,l=n.find(c=>c.type==="month"?c.value:"")?.value,s=n.find(c=>c.type==="day"?c.value:"")?.value,u=n.find(c=>c.type==="hour"?c.value:"")?.value,i=n.find(c=>c.type==="minute"?c.value:"")?.value;return `${r}-${l}-${s} ${u}:${i}`}function Ye(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(i=>i.type==="month"?i.value:"")?.value,l=n.find(i=>i.type==="day"?i.value:"")?.value,s=n.find(i=>i.type==="hour"?i.value:"")?.value,u=n.find(i=>i.type==="minute"?i.value:"")?.value;return `${r}-${l} ${s}:${u}`}function ae(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function j(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function ee(){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:l}=e,{ref:s,download:u,toDataURL:i,copy:c,toBlob:d}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:u,toDataURL:i,toBlob:d,copy:c})),jsxRuntime.jsx("canvas",{ref:s,width:o,height:a,className:n,style:l})});var Ce=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"})]})})},xe=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 be=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=et__default.default({containScroll:"keepSnaps",dragFree:!0}),l=p.useCallback(()=>{r&&r.scrollPrev();},[r]),s=p.useCallback(()=>{r&&r.scrollNext();},[r]),u=p.useCallback(i=>{a(i.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(u(r),r.on("reInit",u),r.on("select",u),r?.scrollTo(o));},[r,u]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(Ce,{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((i,c)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(c);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===c&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:i,className:"oui-rounded-sm"})},i))})}),jsxRuntime.jsx(xe,{onClick:s})]})};var we=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(lt,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},lt=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===!0?jsxRuntime.jsx(ut,{}):jsxRuntime.jsx(ct,{})}),ut=()=>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 te=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 De=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 s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx(te,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:l=>{a(s=>{let u=new Set(s);return r?u.delete(t):u.add(t),u});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var Le=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,l]=p.useState(!1),s=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(te,{className:"oui-mt-[2px]",checked:a,onCheckedChange:u=>{n(u);}}),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:s,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:u=>{o(""),setTimeout(()=>{s.current?.focus();},50),u.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:u=>{if(u.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(u.target.value.length>0),o(u.target.value);}})})]})};var Ie=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(wt,{})}),"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"})}),wt=()=>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 Te=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.bgIndex),[d,C]=p.useState(o.message),[B,S]=p.useState(!1),{backgroundImages:w,...O}=t??{backgroundImages:[]},[M,P]=p.useState(""),y=p.useRef(null);p.useEffect(()=>{let N=window.location.hostname;P(N);},[]);let I=p.useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),W=X(e.entity,e.leverage,B?d:"",M,r,s,e.baseDp,e.quoteDp,e.referral),h=()=>{y.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(N=>{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=()=>{y.current?.download("Poster.png"),e.hide?.();},ne=[...e.entity.openPrice?["openPrice"]:[],...e.entity.markPrice?["markPrice"]:[],...e.entity.openTime?["openTime"]:[],...e.leverage?["leverage"]:[],...e.entity.quantity?["quantity"]:[]];return j(r,s,i,d),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:I,...O,data:W},ratio:3,ref:y})}),jsxRuntime.jsx(be,{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:n.map((N,E)=>jsxRuntime.jsx(we,{setPnlFormat:l,type:N,curType:r},E))}),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:ne.map((N,E)=>jsxRuntime.jsx(De,{setShareOption:u,type:N,curType:s},E))})]}),jsxRuntime.jsx(Le,{message:d,setMessage:C,check:B,setCheck:S})]})]}),jsxRuntime.jsx(Ie,{onClickCopy:h,onClickDownload:Z})]})};var Me=p__namespace.createContext(null);function F(){let e=p__namespace.useContext(Me);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var le=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...l},s)=>{let[u,i]=et__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[c,d]=p__namespace.useState(!1),[C,B]=p__namespace.useState(!1),[S,w]=p__namespace.useState(l.initIndex||0),[O,M]=p__namespace.useState([]),P=p__namespace.useCallback(h=>{h&&(O.length===0&&M(h.scrollSnapList()),w(h.selectedScrollSnap()),d(h.canScrollPrev()),B(h.canScrollNext()));},[O]),y=p__namespace.useCallback(()=>{i?.scrollPrev();},[i]),I=p__namespace.useCallback(()=>{i?.scrollNext();},[i]),W=p__namespace.useCallback(h=>{h.key==="ArrowLeft"?(h.preventDefault(),y()):h.key==="ArrowRight"&&(h.preventDefault(),I());},[y,I]);return p__namespace.useEffect(()=>{!i||!o||o(i);},[i,o]),p__namespace.useEffect(()=>{if(i)return P(i),i.on("reInit",P),i.on("select",P),l.initIndex&&i.scrollTo(l.initIndex),()=>{i?.off("select",P);}},[i,P]),jsxRuntime.jsx(Me.Provider,{value:{carouselRef:u,api:i,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:y,scrollNext:I,canScrollPrev:c,canScrollNext:C,selectedIndex:S,scrollSnaps:O},children:jsxRuntime.jsx("div",{ref:s,onKeyDownCapture:W,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...l,children:r})})});le.displayName="Carousel";var Q=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=F();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}=F();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 ue=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:l,canScrollPrev:s}=F();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:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ue.displayName="CarouselPrevious";var ce=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:l,canScrollNext:s}=F();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:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ce.displayName="CarouselNext";var me=e=>{let{scrollSnaps:t,selectedIndex:o}=F();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};me.displayName="CarouselIdentifier";var pe=({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 T=le;T.Content=Q;T.Item=J;T.Next=ce;T.Previous=ue;T.indentify=me;var ze=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.message),[d,C]=p.useState(o.bgIndex),{backgroundImages:B,...S}=t??{backgroundImages:[]},[w,O]=p.useState(""),M=t?.backgroundImages?.map(()=>p.useRef(null));p.useEffect(()=>{let f=window.location.hostname;O(f);},[]);let P=X(e.entity,e.leverage,i,w,r,s,e.baseDp,e.quoteDp,e.referral),y=p.useRef(),I=552/310,[W,h]=p.useState(1),[Z,ne]=p.useState(0),[N,E]=p.useState(!1),ve=p.useRef(null);p.useEffect(()=>{if(y.current){let f=y.current.offsetWidth,A=f/I;ne(A),h(f/552);}},[y,w]);let We=async f=>{if(!f.current)return;let A=f.current?.toDataURL(),$e=At(A);try{navigator.share&&await navigator.share({text:i,files:[new File([$e],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return j(r,s,d,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:y,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${Z+20}px`},children:jsxRuntime.jsxs(T,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:d,children:[jsxRuntime.jsx(Q,{style:{height:`${Z}px`},children:t?.backgroundImages?.map((f,A)=>jsxRuntime.jsx(J,{children:jsxRuntime.jsx($,{className:"oui-transform oui-origin-top-left",style:{scale:`${W}`},width:552,height:310,data:{backgroundImg:f,...S,data:P},ratio:3,ref:M?.[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:C})})]})}),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.jsx("div",{className:"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1",children:n.map(f=>jsxRuntime.jsx(Et,{setPnlFormat:l,type:f,curType:r}))})]}),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:[e.entity.openPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openPrice",curType:s}),e.entity.openTime&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openTime",curType:s}),e.leverage&&jsxRuntime.jsx(Y,{setShareOption:u,type:"leverage",curType:s}),e.entity.markPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"markPrice",curType:s}),e.entity.quantity&&jsxRuntime.jsx(Y,{setShareOption:u,type:"quantity",curType:s})]})]}),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:f=>{if(f.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}c(f.target.value);},ref:ve,onFocus:()=>E(!0),onBlur:()=>E(!1),suffix:N&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:f=>{c(""),setTimeout(()=>{ve.current?.focus();},50),f.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 f=M?.[d];f&&We(f);},children:"Share"})})]})},Et=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(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(Ht,{})]})};function At(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}=F();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(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},Ht=()=>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 He=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e,[u,i]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let c=()=>{i(window.innerHeight<900?660:807);};return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c);}},[]),l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(Te,{entity:o,leverage:`${t}`,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})},_e=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e;return l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(ze,{entity:o,leverage:t,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})};var ge=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})},ye=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(He,{...t})};var $t="sharePnLDialog",Vt="sharePnLBottomSheet";ui.registerSimpleDialog($t,ye,{contentClassName:"!oui-max-w-[624px] oui-p-0"});ui.registerSimpleSheet(Vt,ge,{title:"Share PnL",classNames:{body:"oui-pb-4 oui-pt-0"}});
|
|
33
|
+
var G=e=>{let{pnl:t,hide:o}=e,a=t?.entity,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),l=p.useMemo(()=>{let i=r()?.code;return {code:t?.refCode??i,slogan:t?.refSlogan,link:t?.refLink}},[r,t]),s=p.useMemo(()=>{if(a)return n[a?.symbol]("base_dp")},[a,n]),u=p.useMemo(()=>{if(a)return n[a?.symbol]("quote_dp")},[a,n]);return {entity:a,leverage:t?.leverage,baseDp:s,quoteDp:u,referralInfo:l,shareOptions:t,hide:o}};function X(e,t,o,a,n,r,l,s,u){let{symbol:i,currency:c}=Qe(e.symbol),d={symbol:i,currency:c,side:e.side};switch(n){case"pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi":{e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi_pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let C=[];r.has("leverage")&&(d.leverage=t),["openPrice","openTime","markPrice","quantity"].forEach(w=>{if(r.has(w))switch(w){case"leverage":break;case"openPrice":{e.openPrice!=null&&C.push({title:"Open price",value:ae(e.openPrice,s||2)});break}case"openTime":{e.openTime!=null&&C.push({title:"Opened at",value:Ye(e.openTime)});break}case"markPrice":{e.markPrice!=null&&C.push({title:"Mark price",value:ae(e.markPrice,s||2)});break}case"quantity":e.quantity!=null&&C.push({title:"Quantity",value:ae(e.quantity,l||2)});}}),d.informations=C;let S={position:d,updateTime:Je(new Date),domain:a};return o.length>0&&(S.message=o),typeof u<"u"&&u.code!==void 0&&(S.referral=u),S}function Qe(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 Je(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(c=>c.type==="year"?c.value:"")?.value,l=n.find(c=>c.type==="month"?c.value:"")?.value,s=n.find(c=>c.type==="day"?c.value:"")?.value,u=n.find(c=>c.type==="hour"?c.value:"")?.value,i=n.find(c=>c.type==="minute"?c.value:"")?.value;return `${r}-${l}-${s} ${u}:${i}`}function Ye(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(i=>i.type==="month"?i.value:"")?.value,l=n.find(i=>i.type==="day"?i.value:"")?.value,s=n.find(i=>i.type==="hour"?i.value:"")?.value,u=n.find(i=>i.type==="minute"?i.value:"")?.value;return `${r}-${l} ${s}:${u}`}function ae(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function j(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function ee(){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:l}=e,{ref:s,download:u,toDataURL:i,copy:c,toBlob:d}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:u,toDataURL:i,toBlob:d,copy:c})),jsxRuntime.jsx("canvas",{ref:s,width:o,height:a,className:n,style:l})});var Ce=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"})]})})},xe=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 be=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=et__default.default({containScroll:"keepSnaps",dragFree:!0}),l=p.useCallback(()=>{r&&r.scrollPrev();},[r]),s=p.useCallback(()=>{r&&r.scrollNext();},[r]),u=p.useCallback(i=>{a(i.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(u(r),r.on("reInit",u),r.on("select",u),r?.scrollTo(o));},[r,u]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(Ce,{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((i,c)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(c);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===c&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:i,className:"oui-rounded-sm"})},i))})}),jsxRuntime.jsx(xe,{onClick:s})]})};var we=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(lt,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},lt=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===!0?jsxRuntime.jsx(ut,{}):jsxRuntime.jsx(ct,{})}),ut=()=>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 te=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 De=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 s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx(te,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:l=>{a(s=>{let u=new Set(s);return r?u.delete(t):u.add(t),u});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var Le=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,l]=p.useState(!1),s=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(te,{className:"oui-mt-[2px]",checked:a,onCheckedChange:u=>{n(u);}}),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:s,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:u=>{o(""),setTimeout(()=>{s.current?.focus();},50),u.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:u=>{if(u.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(u.target.value.length>0),o(u.target.value);}})})]})};var Ie=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(wt,{})}),"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"})}),wt=()=>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 Te=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.bgIndex),[d,C]=p.useState(o.message),[B,S]=p.useState(!1),{backgroundImages:w,...O}=t??{backgroundImages:[]},[M,P]=p.useState(""),y=p.useRef(null);p.useEffect(()=>{let N=window.location.hostname;P(N);},[]);let I=p.useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),W=X(e.entity,e.leverage,B?d:"",M,r,s,e.baseDp,e.quoteDp,e.referral),h=()=>{y.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(N=>{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=()=>{y.current?.download("Poster.png"),e.hide?.();},ne=[...e.entity.openPrice?["openPrice"]:[],...e.entity.markPrice?["markPrice"]:[],...e.entity.openTime?["openTime"]:[],...e.leverage?["leverage"]:[],...e.entity.quantity?["quantity"]:[]];return j(r,s,i,d),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:I,...O,data:W},ratio:3,ref:y})}),jsxRuntime.jsx(be,{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:n.map((N,E)=>jsxRuntime.jsx(we,{setPnlFormat:l,type:N,curType:r},E))}),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:ne.map((N,E)=>jsxRuntime.jsx(De,{setShareOption:u,type:N,curType:s},E))})]}),jsxRuntime.jsx(Le,{message:d,setMessage:C,check:B,setCheck:S})]})]}),jsxRuntime.jsx(Ie,{onClickCopy:h,onClickDownload:Z})]})};var Me=p__namespace.createContext(null);function F(){let e=p__namespace.useContext(Me);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var le=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...l},s)=>{let[u,i]=et__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[c,d]=p__namespace.useState(!1),[C,B]=p__namespace.useState(!1),[S,w]=p__namespace.useState(l.initIndex||0),[O,M]=p__namespace.useState([]),P=p__namespace.useCallback(h=>{h&&(O.length===0&&M(h.scrollSnapList()),w(h.selectedScrollSnap()),d(h.canScrollPrev()),B(h.canScrollNext()));},[O]),y=p__namespace.useCallback(()=>{i?.scrollPrev();},[i]),I=p__namespace.useCallback(()=>{i?.scrollNext();},[i]),W=p__namespace.useCallback(h=>{h.key==="ArrowLeft"?(h.preventDefault(),y()):h.key==="ArrowRight"&&(h.preventDefault(),I());},[y,I]);return p__namespace.useEffect(()=>{!i||!o||o(i);},[i,o]),p__namespace.useEffect(()=>{if(i)return P(i),i.on("reInit",P),i.on("select",P),l.initIndex&&i.scrollTo(l.initIndex),()=>{i?.off("select",P);}},[i,P]),jsxRuntime.jsx(Me.Provider,{value:{carouselRef:u,api:i,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:y,scrollNext:I,canScrollPrev:c,canScrollNext:C,selectedIndex:S,scrollSnaps:O},children:jsxRuntime.jsx("div",{ref:s,onKeyDownCapture:W,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...l,children:r})})});le.displayName="Carousel";var Q=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=F();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}=F();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 ue=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:l,canScrollPrev:s}=F();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:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ue.displayName="CarouselPrevious";var ce=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:l,canScrollNext:s}=F();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:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ce.displayName="CarouselNext";var me=e=>{let{scrollSnaps:t,selectedIndex:o}=F();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};me.displayName="CarouselIdentifier";var pe=({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 T=le;T.Content=Q;T.Item=J;T.Next=ce;T.Previous=ue;T.indentify=me;var ze=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.message),[d,C]=p.useState(o.bgIndex),{backgroundImages:B,...S}=t??{backgroundImages:[]},[w,O]=p.useState(""),M=t?.backgroundImages?.map(()=>p.useRef(null));p.useEffect(()=>{let f=window.location.hostname;O(f);},[]);let P=X(e.entity,e.leverage,i,w,r,s,e.baseDp,e.quoteDp,e.referral),y=p.useRef(),I=552/310,[W,h]=p.useState(1),[Z,ne]=p.useState(0),[N,E]=p.useState(!1),ve=p.useRef(null);p.useEffect(()=>{if(y.current){let f=y.current.offsetWidth,A=f/I;ne(A),h(f/552);}},[y,w]);let We=async f=>{if(!f.current)return;let A=f.current?.toDataURL(),$e=At(A);try{navigator.share&&await navigator.share({text:i,files:[new File([$e],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return j(r,s,d,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:y,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${Z+20}px`},children:jsxRuntime.jsxs(T,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:d,children:[jsxRuntime.jsx(Q,{style:{height:`${Z}px`},children:t?.backgroundImages?.map((f,A)=>jsxRuntime.jsx(J,{children:jsxRuntime.jsx($,{className:"oui-transform oui-origin-top-left",style:{scale:`${W}`},width:552,height:310,data:{backgroundImg:f,...S,data:P},ratio:3,ref:M?.[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:C})})]})}),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.jsx("div",{className:"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1",children:n.map(f=>jsxRuntime.jsx(Et,{setPnlFormat:l,type:f,curType:r}))})]}),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:[e.entity.openPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openPrice",curType:s}),e.entity.openTime&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openTime",curType:s}),e.leverage&&jsxRuntime.jsx(Y,{setShareOption:u,type:"leverage",curType:s}),e.entity.markPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"markPrice",curType:s}),e.entity.quantity&&jsxRuntime.jsx(Y,{setShareOption:u,type:"quantity",curType:s})]})]}),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:f=>{if(f.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}c(f.target.value);},ref:ve,onFocus:()=>E(!0),onBlur:()=>E(!1),suffix:N&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:f=>{c(""),setTimeout(()=>{ve.current?.focus();},50),f.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 f=M?.[d];f&&We(f);},children:"Share"})})]})},Et=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(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(Ht,{})]})};function At(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}=F();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(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},Ht=()=>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 He=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e,[u,i]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let c=()=>{i(window.innerHeight<900?660:807);};return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c);}},[]),l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(Te,{entity:o,leverage:`${t}`,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})},_e=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e;return l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(ze,{entity:o,leverage:t,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})};var ge=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})},ye=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(He,{...t})};var $t="sharePnLDialog",Vt="sharePnLBottomSheet";ui.registerSimpleDialog($t,ye,{classNames:{content:"!oui-max-w-[624px] oui-p-0"}});ui.registerSimpleSheet(Vt,ge,{title:"Share PnL",classNames:{body:"oui-pb-4 oui-pt-0"}});
|
|
34
34
|
|
|
35
35
|
exports.SharePnLBottomSheetId = Vt;
|
|
36
36
|
exports.SharePnLBottomSheetWidget = ge;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sharePnL/sharePnL.script.tsx","../src/sharePnL/sharePnL.ui.tsx","../src/sharePnL/desktop/content.tsx","../src/sharePnL/utils/utils.tsx","../src/sharePnL/poster/poster.tsx","../src/sharePnL/desktop/carousel.tsx","../src/sharePnL/desktop/buttons.tsx","../src/sharePnL/desktop/pnlFormat.tsx","../src/sharePnL/desktop/options.tsx","../src/sharePnL/desktop/checkbox.tsx","../src/sharePnL/desktop/message.tsx","../src/sharePnL/desktop/bottomBtns.tsx","../src/sharePnL/mobile/content.tsx","../src/sharePnL/carousel/carousel.tsx","../src/sharePnL/carousel/index.tsx","../src/sharePnL/sharePnL.widget.tsx"],"names":["registerSimpleDialog","registerSimpleSheet","useReferralInfo","useSymbolsInfo","useMemo","useSharePnLScript","props","pnl","hide","entity","symbolInfo","getFirstRefCode","referralInfo","code","base_dp","quote_dp","useEffect","useState","useRef","Decimal","getPnLPosterData","position","leverage","message","domain","pnlType","options","baseDp","quoteDp","referral","symbol","currency","processSymbol","positionData","informations","key","formatFixed","formatOpenTime","data","formatShareTime","tokens","symbol1","symbol2","symbol3","input","date","formattedParts","year","part","month","day","hour","minute","value","dp","savePnlInfo","format","bgIndex","getPnlInfo","str","Divider","Flex","toast","Text","Box","usePoster","forwardRef","useImperativeHandle","jsx","Poster","parentRef","width","height","className","style","ref","download","toDataURL","copy","toBlob","useEmblaCarousel","useCallback","jsxs","PrevButton","children","restProps","NextButton","cn","CarouselBackgroundImage","backgroundImages","selectedSnap","setSelectedSnap","emblaRef","emblaApi","onPrevButtonClick","onNextButtonClick","onSelect","e","index","PnlFormatView","type","curType","setPnlFormat","text","isSelected","clsName","RadioButton","SelIcon","UnselIcon","Checkbox","size","ShareOption","setShareOption","updateSet","checked","CloseCircleFillIcon","Input","Message","setMessage","check","setCheck","focus","setFocus","inputRef","Button","BottomButtons","onClickDownload","onClickCopy","DownloadIcon","CopyIcon","DesktopSharePnLContent","shareOptions","localPnlConfig","formats","pnlFormat","shareOption","resetOptions","setDomain","posterRef","currentDomain","curBgImg","posterData","onCopy","onDownload","item","ScrollArea","React","CarouselContext","useCarousel","context","Carousel","orientation","opts","setApi","plugins","carouselRef","api","canScrollPrev","setCanScrollPrev","canScrollNext","setCanScrollNext","selectedIndex","setSelectedIndex","scrollSnaps","setScrollSnaps","scrollPrev","scrollNext","handleKeyDown","event","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","Fragment","DesktopSharePnL","viewportHeight","setViewportHeight","handleResize","MobileSharePnL","SharePnLBottomSheetWidget","state","SharePnLDialogWidget","SharePnLDialogId","SharePnLBottomSheetId"],"mappings":"AAAA,OAAS,wBAAAA,GAAsB,uBAAAC,OAA2B,sBCA1D,OAAS,mBAAAC,GAAiB,kBAAAC,OAAsB,yBAChD,OAAS,WAAAC,OAAe,QAGjB,IAAMC,EAAqBC,GAG5B,CACJ,GAAM,CAAE,IAAAC,EAAK,KAAAC,CAAK,EAAIF,EAChBG,EAASF,GAAK,OACdG,EAAaP,GAAe,EAC5B,CAAE,gBAAAQ,CAAgB,EAAIT,GAAgB,EACtCU,EAAeR,GAAQ,IAAgC,CAC3D,IAAMS,EAAOF,EAAgB,GAAG,KAMhC,MALa,CACX,KAAMJ,GAAK,SAAWM,EACtB,OAAQN,GAAK,UACb,KAAMA,GAAK,OACb,CAEF,EAAG,CAACI,EAAiBJ,CAAG,CAAC,EAQnBO,EAAUV,GAAQ,IAAM,CAC5B,GAAKK,EACL,OAAOC,EAAWD,GAAQ,MAAM,EAAE,SAAS,CAC7C,EAAG,CAACA,EAAQC,CAAU,CAAC,EACjBK,EAAWX,GAAQ,IAAM,CAC7B,GAAKK,EACL,OAAOC,EAAWD,GAAQ,MAAM,EAAE,UAAU,CAC9C,EAAG,CAACA,EAAQC,CAAU,CAAC,EAGvB,MAAO,CACL,OAAAD,EACA,SAAUF,GAAK,SACf,OAAQO,EACR,QAASC,EACT,aAAAH,EACA,aAAcL,EACd,KAAAC,CACF,CAC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,CACF,EAAIF,EACJ,OAAI6H,GAAgB,MAAQ1H,GAAU,KAAa2D,GAAAsI,GAAA,EAAE,EAEnDtI,GAACgH,GAAA,CACC,OAAQ3K,EACR,SAAUa,EACV,KAAMd,EACN,OAAQmB,EACR,QAASC,EACT,SAAUhB,EACV,aAAcuH,EAChB,CAEJ,EcxDS,cAAA/D,OAAA,oBARF,IAAM4I,GAA6B1M,GAGpC,CACJ,IAAM2M,EAAQ5M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAO8D,GAAC2I,GAAA,CAAgB,GAAGE,EAAO,CACpC,EAEaC,GAAwB5M,GAG/B,CACJ,IAAM2M,EAAQ5M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAO8D,GAACuI,GAAA,CAAiB,GAAGM,EAAO,CACrC,EhBnBA,IAAME,GAAmB,iBACnBC,GAAwB,sBAE9BpN,GAAqBmN,GAAkBD,GAAsB,CAG3D,iBAAkB,4BACpB,CAAC,EAEDjN,GAAoBmN,GAAuBJ,GAA2B,CACpE,MAAO,YACP,WAAY,CACV,KAAM,mBACR,CACF,CAAC","sourcesContent":["import { registerSimpleDialog, registerSimpleSheet } from \"@orderly.network/ui\";\nimport {\n SharePnLDialogWidget,\n SharePnLBottomSheetWidget,\n} from \"./sharePnL/sharePnL.widget\";\n\nconst SharePnLDialogId = \"sharePnLDialog\";\nconst SharePnLBottomSheetId = \"sharePnLBottomSheet\";\n\nregisterSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {\n // title: \"Max account leverage\",\n // size: \"2xl\",\n contentClassName: \"!oui-max-w-[624px] oui-p-0\",\n});\n\nregisterSimpleSheet(SharePnLBottomSheetId, SharePnLBottomSheetWidget, {\n title: \"Share PnL\",\n classNames: {\n body: \"oui-pb-4 oui-pt-0\"\n }\n});\n\nexport * from \"./sharePnL\";\nexport { SharePnLDialogId, SharePnLBottomSheetId };\nexport type { SharePnLConfig, SharePnLParams } from \"./types/types\";\n","import { useReferralInfo, useSymbolsInfo } from \"@orderly.network/hooks\";\nimport { useMemo } from \"react\";\nimport { ReferralType, SharePnLConfig, SharePnLParams } from \"../types/types\";\n\nexport const useSharePnLScript = (props: {\n pnl?: (SharePnLConfig & SharePnLParams) | undefined;\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\n return {\n entity,\n leverage: pnl?.leverage,\n baseDp: base_dp,\n quoteDp: quote_dp,\n referralInfo,\n shareOptions: pnl as SharePnLConfig | undefined,\n hide,\n };\n};\n\nexport type SharePnLState = ReturnType<typeof useSharePnLScript>;\n","import { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { Box } from \"@orderly.network/ui\";\nimport { SharePnLState } from \"./sharePnL.script\";\nimport { DesktopSharePnLContent } from \"./desktop/content\";\nimport { MobileSharePnLContent } from \"./mobile/content\";\n\nexport const DesktopSharePnL: FC<SharePnLState> = (props) => {\n const {\n leverage,\n entity,\n baseDp,\n quoteDp,\n referralInfo,\n shareOptions,\n hide,\n } = props;\n\n const [viewportHeight, setViewportHeight] = useState(\n window.innerHeight < 900 ? 660 : 807\n );\n\n useEffect(() => {\n const handleResize = () => {\n setViewportHeight(window.innerHeight < 900 ? 660 : 807);\n };\n\n window.addEventListener(\"resize\", handleResize);\n\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, []);\n\n if (shareOptions == null || entity == null) return <></>;\n return (\n <DesktopSharePnLContent\n entity={entity}\n leverage={`${leverage}`}\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 {\n leverage,\n entity,\n baseDp,\n quoteDp,\n referralInfo,\n shareOptions,\n hide,\n } = props;\n if (shareOptions == null || entity == null) return <></>;\n return (\n <MobileSharePnLContent\n entity={entity}\n leverage={leverage}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLConfig,\n} from \"../../types/types\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport {\n CloseIcon,\n Divider,\n Flex,\n toast,\n Text,\n Box,\n} from \"@orderly.network/ui\";\nimport { Poster } from \"../poster\";\nimport { CarouselBackgroundImage } from \"./carousel\";\nimport { PnlFormatView } from \"./pnlFormat\";\nimport { ShareOption } from \"./options\";\nimport { Message } from \"./message\";\nimport { BottomButtons } from \"./bottomBtns\";\nimport { PosterRef } from \"../poster/poster\";\n\nexport const DesktopSharePnLContent: FC<{\n entity: ShareEntity;\n leverage: number | string;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLConfig;\n}> = (props) => {\n const { shareOptions } = props;\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 [selectedSnap, setSelectedSnap] = useState(localPnlConfig.bgIndex);\n const [message, setMessage] = useState(localPnlConfig.message);\n const [check, setCheck] = useState(false);\n // const { shareOptions } = useTradingPageContext();\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 props.leverage,\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(\"Image copied\");\n })\n .catch((e: any) => {\n toast.error(() => {\n return (\n <div>\n <div>Copy failed</div>\n <div className=\"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54\">\n Browser version outdated, please update in order to copy image\n to clipboard.\n </div>\n </div>\n );\n });\n });\n };\n const onDownload = () => {\n posterRef.current?.download(\"Poster.png\");\n props.hide?.();\n };\n\n \n // check if the entity has the option, like formats\n const options: ShareOptions[] = [\n ...(props.entity.openPrice ? [\"openPrice\"] as ShareOptions[] : []),\n ...(props.entity.markPrice ? [\"markPrice\"] as ShareOptions[] : []),\n ...(props.entity.openTime ? [\"openTime\"] as ShareOptions[] : []),\n ...(props.leverage ? [\"leverage\"] as ShareOptions[] : []),\n ...(props.entity.quantity ? [\"quantity\"] as ShareOptions[] : []),\n ];\n\n savePnlInfo(pnlFormat, shareOption, selectedSnap, message);\n\n return (\n <div className=\"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full\">\n <div className=\"oui-flex-1 oui-h-full 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 ?? []}\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 PnL display format\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-pt-6 oui-border-white/10\" />\n\n <Flex\n mt={6}\n direction={\"column\"}\n justify={\"start\"}\n itemAlign={\"start\"}\n >\n <Text size=\"sm\" intensity={80}>\n Optional information to share\n </Text>\n <Flex mt={3} gap={4}>\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\n {/* <button\n onClick={() => {\n props.hide();\n }}\n className=\"oui-absolute oui-top-0 oui-right-0 oui-w-[40px] oui-h-[40px] oui-flex oui-justify-center oui-items-center\"\n >\n <CloseIcon size={12} className=\"oui-fill-base-contrast-54\" />\n </button> */}\n </div>\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\nimport { Decimal } from \"@orderly.network/utils\";\nimport { PnLDisplayFormat, ShareEntity, ShareOptions } from \"../../types/types\";\n// import { PnLDisplayFormat, ShareOptions } from \"./type\";\n\nexport type ReferralType = {\n code?: string;\n link?: string;\n slogan?: string;\n};\n\nexport function getPnLPosterData(\n position: ShareEntity,\n leverage: number | string,\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 { 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\"] = leverage;\n }\n const array: ShareOptions[] = [\n \"openPrice\",\n \"openTime\",\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: \"Open price\",\n value: formatFixed(position.openPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"openTime\": {\n if (position.openTime != null) {\n informations.push({\n title: \"Opened at\",\n value: formatOpenTime(position.openTime),\n });\n }\n break;\n }\n case \"markPrice\": {\n if (position.markPrice != null) {\n informations.push({\n title: \"Mark price\",\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: \"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: \"h24\",\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 };\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: [\"openPrice\", \"openTime\", \"markPrice\", \"quantity\", \"leverage\"],\n message: \"\",\n };\n}\n","import { type DrawOptions, usePoster } from \"@orderly.network/hooks\";\nimport { FC, forwardRef, useImperativeHandle } from \"react\";\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","import useEmblaCarousel from \"embla-carousel-react\";\nimport { FC, useCallback, useEffect } from \"react\";\nimport { NextButton, PrevButton } from \"./buttons\";\nimport { Box, cn, Flex } from \"@orderly.network/ui\";\n\nexport const CarouselBackgroundImage: FC<{\n backgroundImages: 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) return;\n emblaApi.scrollPrev();\n }, [emblaApi]);\n\n const onNextButtonClick = useCallback(() => {\n if (!emblaApi) return;\n emblaApi.scrollNext();\n }, [emblaApi]);\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) return;\n\n onSelect(emblaApi);\n emblaApi.on(\"reInit\", onSelect);\n emblaApi.on(\"select\", onSelect);\n emblaApi?.scrollTo(selectedSnap);\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\n emblaApi?.scrollTo(index);\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, useMemo } from \"react\";\nimport { PnLDisplayFormat } from \"../../types/types\";\nimport { Text, cn } from \"@orderly.network/ui\";\n\nexport const PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return \"ROI & PnL\";\n case \"roi\":\n return \"ROI\";\n case \"pnl\":\n return \"PnL\";\n }\n }, [type]);\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, useMemo } from \"react\";\nimport { ShareOptions } from \"../../types/types\";\nimport { Flex, Text, cn } from \"@orderly.network/ui\";\nimport { Checkbox } from \"./checkbox\";\n\nexport const ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return \"Open price\";\n case \"openTime\":\n return \"Opened at\";\n case \"markPrice\":\n return \"Mark price\";\n case \"quantity\":\n return \"Quantity\";\n case \"leverage\":\n return \"Leverage\";\n }\n }, [type]);\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","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 {\n CloseCircleFillIcon,\n Input,\n toast,\n} from \"@orderly.network/ui\";\nimport { FC, useRef, useState } from \"react\";\nimport { Checkbox } from \"./checkbox\";\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 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 Your message\n </div>\n <div className=\"oui-bg-base-900 oui-mx-2 oui-rounded-sm\">\n <Input\n ref={inputRef}\n placeholder=\"Max 25 characters\"\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(\"Maximum support of 25 characters\");\n return;\n }\n setCheck(e.target.value.length > 0);\n setMessage(e.target.value);\n }}\n />\n </div>\n </div>\n );\n};\n","import { FC } from \"react\";\nimport { Button, Flex } from \"@orderly.network/ui\";\n\nexport const BottomButtons: FC<{\n onClickDownload: any;\n onClickCopy: any;\n}> = (props) => {\n const { onClickDownload, onClickCopy } = props;\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 Download\n </Button>\n\n <Button\n className=\"oui-flex-1 oui-flex oui-gap-1\"\n onClick={onClickCopy}\n >\n <span>\n <CopyIcon />\n </span>\n 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, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLConfig,\n} from \"../../types/types\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport {\n Box,\n Button,\n CloseCircleFillIcon,\n cn,\n Input,\n ScrollArea,\n toast,\n} from \"@orderly.network/ui\";\nimport { Carousel } from \"../carousel\";\nimport {\n CarouselContent,\n CarouselItem,\n Dot,\n useCarousel,\n} from \"../carousel/carousel\";\n\nexport const MobileSharePnLContent: FC<{\n entity: ShareEntity;\n leverage: any;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLConfig;\n}> = (props) => {\n const { shareOptions } = props;\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 props.leverage,\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 savePnlInfo(pnlFormat, shareOption, selectIndex, message);\n\n return (\n <div className=\"oui-w-full\">\n {/* <div>{`leverage: ${props.leverage}x`}</div> */}\n <div\n ref={carouselRef}\n className=\"oui-w-full oui-mt-4 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-transform oui-origin-top-left\"\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-mt-2 oui-mb-1 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-max-h-[200px] oui-overflow-y-auto oui-custom-scrollbar\">\n <div className=\"oui-mt-4\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54\">\n PnL display format\n </div>\n <div className=\"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1\">\n {formats.map((item) => (\n <PnlFormatView\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-text-3xs oui-text-base-contrast-54 oui-h-[18px]\">\n Optional information to share\n </div>\n <div className=\"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3\">\n {props.entity.openPrice && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"openPrice\"\n curType={shareOption}\n />\n )}\n {props.entity.openTime && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"openTime\"\n curType={shareOption}\n />\n )}\n {props.leverage && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"leverage\"\n curType={shareOption}\n />\n )}\n {props.entity.markPrice && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"markPrice\"\n curType={shareOption}\n />\n )}\n {props.entity.quantity && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"quantity\"\n curType={shareOption}\n />\n )}\n </div>\n </div>\n\n <div className=\"oui-mt-3 oui-mb-8\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]\">\n Your message\n </div>\n <div className=\"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1\">\n <Input\n placeholder=\"Max 25 characters\"\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(\"Maximum support of 25 characters\");\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 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\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return \"ROI & PnL\";\n case \"roi\":\n return \"ROI\";\n case \"pnl\":\n return \"PnL\";\n }\n }, [type]);\n\n console.log(\"pnl format\", type, curType);\n\n const isSelected = type === curType;\n\n return (\n <div\n className={cn(\n \"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\",\n isSelected && \"oui-bg-primary-darken oui-dot-sel\"\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\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return \"Open price\";\n case \"openTime\":\n return \"Opened at\";\n case \"markPrice\":\n return \"Mark price\";\n case \"quantity\":\n return \"Quantity\";\n case \"leverage\":\n return \"Leverage\";\n }\n }, [type]);\n\n const isSelected = curType.has(type);\n\n return (\n <div\n className={cn(\n \"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\"\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-text-sm oui-flex-1 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 console.log(\"setSelectIndex is\", 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 * as React from \"react\";\nimport useEmblaCarousel, {\n type UseEmblaCarouselType,\n} from \"embla-carousel-react\";\nimport { Button, cn } from \"@orderly.network/ui\";\n\n\n\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>(\n (\n {\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n },\n ref\n ) => {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins\n );\n const [canScrollPrev, setCanScrollPrev] = React.useState(false);\n const [canScrollNext, setCanScrollNext] = React.useState(false);\n const [selectedIndex, setSelectedIndex] = React.useState(props.initIndex ||0);\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 return (\n <CarouselContext.Provider\n value={{\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 <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>(({ className, ...props }, ref) => {\n const { carouselRef, orientation } = useCarousel();\n\n \n\n return (\n <div ref={carouselRef} className=\"oui-overflow-hidden\">\n <div\n ref={ref}\n className={cn(\n \"oui-flex\",\n orientation === \"horizontal\"\n ? \"oui--ml-4\"\n : \"oui--mt-4 oui-flex-col\",\n className\n )}\n {...props}\n />\n </div>\n );\n});\nCarouselContent.displayName = \"CarouselContent\";\n\nconst CarouselItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { orientation } = useCarousel();\n\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 );\n});\nCarouselItem.displayName = \"CarouselItem\";\n\nconst CarouselPrevious = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>(({ className, variant = \"contained\", size = \"icon\", ...props }, ref) => {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel();\n\n return (\n <Button\n // @ts-ignore\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-h-8 oui-w-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 {/* @ts-ignore */}\n <ChevronLeft size={20} />\n <span className=\"oui-sr-only\">Previous slide</span>\n </Button>\n );\n});\nCarouselPrevious.displayName = \"CarouselPrevious\";\n\nconst CarouselNext = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>(({ className, variant = \"contained\", size = \"icon\", ...props }, ref) => {\n const { orientation, scrollNext, canScrollNext } = useCarousel();\n\n return (\n <Button\n // @ts-ignore\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-h-8 oui-w-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 {/* @ts-ignore */}\n <ChevronRight size={20} />\n <span className=\"oui-sr-only\">Next slide</span>\n </Button>\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};\nconst CarouselIdentifier: React.FC<CarouselIdentifierProps> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n\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 console.log(\"activedClassName is\", activedClassName);\n \n return (\n <button\n onClick={() => onClick?.(index)}\n className={cn(\n \"oui-w-2 oui-h-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","\nimport { SharePnLConfig, 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?: SharePnLConfig & 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?: SharePnLConfig & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <DesktopSharePnL {...state} />;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sharePnL/sharePnL.script.tsx","../src/sharePnL/sharePnL.ui.tsx","../src/sharePnL/desktop/content.tsx","../src/sharePnL/utils/utils.tsx","../src/sharePnL/poster/poster.tsx","../src/sharePnL/desktop/carousel.tsx","../src/sharePnL/desktop/buttons.tsx","../src/sharePnL/desktop/pnlFormat.tsx","../src/sharePnL/desktop/options.tsx","../src/sharePnL/desktop/checkbox.tsx","../src/sharePnL/desktop/message.tsx","../src/sharePnL/desktop/bottomBtns.tsx","../src/sharePnL/mobile/content.tsx","../src/sharePnL/carousel/carousel.tsx","../src/sharePnL/carousel/index.tsx","../src/sharePnL/sharePnL.widget.tsx"],"names":["registerSimpleDialog","registerSimpleSheet","useReferralInfo","useSymbolsInfo","useMemo","useSharePnLScript","props","pnl","hide","entity","symbolInfo","getFirstRefCode","referralInfo","code","base_dp","quote_dp","useEffect","useState","useRef","Decimal","getPnLPosterData","position","leverage","message","domain","pnlType","options","baseDp","quoteDp","referral","symbol","currency","processSymbol","positionData","informations","key","formatFixed","formatOpenTime","data","formatShareTime","tokens","symbol1","symbol2","symbol3","input","date","formattedParts","year","part","month","day","hour","minute","value","dp","savePnlInfo","format","bgIndex","getPnlInfo","str","Divider","Flex","toast","Text","Box","usePoster","forwardRef","useImperativeHandle","jsx","Poster","parentRef","width","height","className","style","ref","download","toDataURL","copy","toBlob","useEmblaCarousel","useCallback","jsxs","PrevButton","children","restProps","NextButton","cn","CarouselBackgroundImage","backgroundImages","selectedSnap","setSelectedSnap","emblaRef","emblaApi","onPrevButtonClick","onNextButtonClick","onSelect","e","index","PnlFormatView","type","curType","setPnlFormat","text","isSelected","clsName","RadioButton","SelIcon","UnselIcon","Checkbox","size","ShareOption","setShareOption","updateSet","checked","CloseCircleFillIcon","Input","Message","setMessage","check","setCheck","focus","setFocus","inputRef","Button","BottomButtons","onClickDownload","onClickCopy","DownloadIcon","CopyIcon","DesktopSharePnLContent","shareOptions","localPnlConfig","formats","pnlFormat","shareOption","resetOptions","setDomain","posterRef","currentDomain","curBgImg","posterData","onCopy","onDownload","item","ScrollArea","React","CarouselContext","useCarousel","context","Carousel","orientation","opts","setApi","plugins","carouselRef","api","canScrollPrev","setCanScrollPrev","canScrollNext","setCanScrollNext","selectedIndex","setSelectedIndex","scrollSnaps","setScrollSnaps","scrollPrev","scrollNext","handleKeyDown","event","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","Fragment","DesktopSharePnL","viewportHeight","setViewportHeight","handleResize","MobileSharePnL","SharePnLBottomSheetWidget","state","SharePnLDialogWidget","SharePnLDialogId","SharePnLBottomSheetId"],"mappings":"AAAA,OAAS,wBAAAA,GAAsB,uBAAAC,OAA2B,sBCA1D,OAAS,mBAAAC,GAAiB,kBAAAC,OAAsB,yBAChD,OAAS,WAAAC,OAAe,QAGjB,IAAMC,EAAqBC,GAG5B,CACJ,GAAM,CAAE,IAAAC,EAAK,KAAAC,CAAK,EAAIF,EAChBG,EAASF,GAAK,OACdG,EAAaP,GAAe,EAC5B,CAAE,gBAAAQ,CAAgB,EAAIT,GAAgB,EACtCU,EAAeR,GAAQ,IAAgC,CAC3D,IAAMS,EAAOF,EAAgB,GAAG,KAMhC,MALa,CACX,KAAMJ,GAAK,SAAWM,EACtB,OAAQN,GAAK,UACb,KAAMA,GAAK,OACb,CAEF,EAAG,CAACI,EAAiBJ,CAAG,CAAC,EAQnBO,EAAUV,GAAQ,IAAM,CAC5B,GAAKK,EACL,OAAOC,EAAWD,GAAQ,MAAM,EAAE,SAAS,CAC7C,EAAG,CAACA,EAAQC,CAAU,CAAC,EACjBK,EAAWX,GAAQ,IAA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AQ,GACrB,KAAMd,EACN,OAAQmB,EACR,QAASC,EACT,SAAUhB,EACV,aAAcuH,EAChB,CAEJ,EAEa4E,GAAqCzM,GAAU,CAC1D,GAAM,CACJ,SAAAgB,EACA,OAAAb,EACA,OAAAkB,EACA,QAAAC,EACA,aAAAhB,EACA,aAAAuH,EACA,KAAA3H,CACF,EAAIF,EACJ,OAAI6H,GAAgB,MAAQ1H,GAAU,KAAa2D,GAAAsI,GAAA,EAAE,EAEnDtI,GAACgH,GAAA,CACC,OAAQ3K,EACR,SAAUa,EACV,KAAMd,EACN,OAAQmB,EACR,QAASC,EACT,SAAUhB,EACV,aAAcuH,EAChB,CAEJ,EcxDS,cAAA/D,OAAA,oBARF,IAAM4I,GAA6B1M,GAGpC,CACJ,IAAM2M,EAAQ5M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAO8D,GAAC2I,GAAA,CAAgB,GAAGE,EAAO,CACpC,EAEaC,GAAwB5M,GAG/B,CACJ,IAAM2M,EAAQ5M,EAAkB,CAC9B,KAAMC,EAAM,KACZ,IAAKA,EAAM,GACb,CAAC,EACD,OAAO8D,GAACuI,GAAA,CAAiB,GAAGM,EAAO,CACrC,EhBnBA,IAAME,GAAmB,iBACnBC,GAAwB,sBAE9BpN,GAAqBmN,GAAkBD,GAAsB,CAG3D,WAAY,CACV,QAAS,4BACX,CACF,CAAC,EAEDjN,GAAoBmN,GAAuBJ,GAA2B,CACpE,MAAO,YACP,WAAY,CACV,KAAM,mBACR,CACF,CAAC","sourcesContent":["import { registerSimpleDialog, registerSimpleSheet } from \"@orderly.network/ui\";\nimport {\n SharePnLDialogWidget,\n SharePnLBottomSheetWidget,\n} from \"./sharePnL/sharePnL.widget\";\n\nconst SharePnLDialogId = \"sharePnLDialog\";\nconst SharePnLBottomSheetId = \"sharePnLBottomSheet\";\n\nregisterSimpleDialog(SharePnLDialogId, SharePnLDialogWidget, {\n // title: \"Max account leverage\",\n // size: \"2xl\",\n classNames: {\n content: \"!oui-max-w-[624px] oui-p-0\",\n },\n});\n\nregisterSimpleSheet(SharePnLBottomSheetId, SharePnLBottomSheetWidget, {\n title: \"Share PnL\",\n classNames: {\n body: \"oui-pb-4 oui-pt-0\",\n },\n});\n\nexport * from \"./sharePnL\";\nexport { SharePnLDialogId, SharePnLBottomSheetId };\nexport type { SharePnLConfig, SharePnLParams } from \"./types/types\";\n","import { useReferralInfo, useSymbolsInfo } from \"@orderly.network/hooks\";\nimport { useMemo } from \"react\";\nimport { ReferralType, SharePnLConfig, SharePnLParams } from \"../types/types\";\n\nexport const useSharePnLScript = (props: {\n pnl?: (SharePnLConfig & SharePnLParams) | undefined;\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\n return {\n entity,\n leverage: pnl?.leverage,\n baseDp: base_dp,\n quoteDp: quote_dp,\n referralInfo,\n shareOptions: pnl as SharePnLConfig | undefined,\n hide,\n };\n};\n\nexport type SharePnLState = ReturnType<typeof useSharePnLScript>;\n","import { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { Box } from \"@orderly.network/ui\";\nimport { SharePnLState } from \"./sharePnL.script\";\nimport { DesktopSharePnLContent } from \"./desktop/content\";\nimport { MobileSharePnLContent } from \"./mobile/content\";\n\nexport const DesktopSharePnL: FC<SharePnLState> = (props) => {\n const {\n leverage,\n entity,\n baseDp,\n quoteDp,\n referralInfo,\n shareOptions,\n hide,\n } = props;\n\n const [viewportHeight, setViewportHeight] = useState(\n window.innerHeight < 900 ? 660 : 807\n );\n\n useEffect(() => {\n const handleResize = () => {\n setViewportHeight(window.innerHeight < 900 ? 660 : 807);\n };\n\n window.addEventListener(\"resize\", handleResize);\n\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, []);\n\n if (shareOptions == null || entity == null) return <></>;\n return (\n <DesktopSharePnLContent\n entity={entity}\n leverage={`${leverage}`}\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 {\n leverage,\n entity,\n baseDp,\n quoteDp,\n referralInfo,\n shareOptions,\n hide,\n } = props;\n if (shareOptions == null || entity == null) return <></>;\n return (\n <MobileSharePnLContent\n entity={entity}\n leverage={leverage}\n hide={hide}\n baseDp={baseDp}\n quoteDp={quoteDp}\n referral={referralInfo}\n shareOptions={shareOptions}\n />\n );\n};\n","import { FC, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLConfig,\n} from \"../../types/types\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport {\n CloseIcon,\n Divider,\n Flex,\n toast,\n Text,\n Box,\n} from \"@orderly.network/ui\";\nimport { Poster } from \"../poster\";\nimport { CarouselBackgroundImage } from \"./carousel\";\nimport { PnlFormatView } from \"./pnlFormat\";\nimport { ShareOption } from \"./options\";\nimport { Message } from \"./message\";\nimport { BottomButtons } from \"./bottomBtns\";\nimport { PosterRef } from \"../poster/poster\";\n\nexport const DesktopSharePnLContent: FC<{\n entity: ShareEntity;\n leverage: number | string;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLConfig;\n}> = (props) => {\n const { shareOptions } = props;\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 [selectedSnap, setSelectedSnap] = useState(localPnlConfig.bgIndex);\n const [message, setMessage] = useState(localPnlConfig.message);\n const [check, setCheck] = useState(false);\n // const { shareOptions } = useTradingPageContext();\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 props.leverage,\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(\"Image copied\");\n })\n .catch((e: any) => {\n toast.error(() => {\n return (\n <div>\n <div>Copy failed</div>\n <div className=\"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54\">\n Browser version outdated, please update in order to copy image\n to clipboard.\n </div>\n </div>\n );\n });\n });\n };\n const onDownload = () => {\n posterRef.current?.download(\"Poster.png\");\n props.hide?.();\n };\n\n \n // check if the entity has the option, like formats\n const options: ShareOptions[] = [\n ...(props.entity.openPrice ? [\"openPrice\"] as ShareOptions[] : []),\n ...(props.entity.markPrice ? [\"markPrice\"] as ShareOptions[] : []),\n ...(props.entity.openTime ? [\"openTime\"] as ShareOptions[] : []),\n ...(props.leverage ? [\"leverage\"] as ShareOptions[] : []),\n ...(props.entity.quantity ? [\"quantity\"] as ShareOptions[] : []),\n ];\n\n savePnlInfo(pnlFormat, shareOption, selectedSnap, message);\n\n return (\n <div className=\"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full\">\n <div className=\"oui-flex-1 oui-h-full 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 ?? []}\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 PnL display format\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-pt-6 oui-border-white/10\" />\n\n <Flex\n mt={6}\n direction={\"column\"}\n justify={\"start\"}\n itemAlign={\"start\"}\n >\n <Text size=\"sm\" intensity={80}>\n Optional information to share\n </Text>\n <Flex mt={3} gap={4}>\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\n {/* <button\n onClick={() => {\n props.hide();\n }}\n className=\"oui-absolute oui-top-0 oui-right-0 oui-w-[40px] oui-h-[40px] oui-flex oui-justify-center oui-items-center\"\n >\n <CloseIcon size={12} className=\"oui-fill-base-contrast-54\" />\n </button> */}\n </div>\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\nimport { Decimal } from \"@orderly.network/utils\";\nimport { PnLDisplayFormat, ShareEntity, ShareOptions } from \"../../types/types\";\n// import { PnLDisplayFormat, ShareOptions } from \"./type\";\n\nexport type ReferralType = {\n code?: string;\n link?: string;\n slogan?: string;\n};\n\nexport function getPnLPosterData(\n position: ShareEntity,\n leverage: number | string,\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 { 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\"] = leverage;\n }\n const array: ShareOptions[] = [\n \"openPrice\",\n \"openTime\",\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: \"Open price\",\n value: formatFixed(position.openPrice, quoteDp || 2),\n });\n }\n break;\n }\n case \"openTime\": {\n if (position.openTime != null) {\n informations.push({\n title: \"Opened at\",\n value: formatOpenTime(position.openTime),\n });\n }\n break;\n }\n case \"markPrice\": {\n if (position.markPrice != null) {\n informations.push({\n title: \"Mark price\",\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: \"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: \"h24\",\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 };\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: [\"openPrice\", \"openTime\", \"markPrice\", \"quantity\", \"leverage\"],\n message: \"\",\n };\n}\n","import { type DrawOptions, usePoster } from \"@orderly.network/hooks\";\nimport { FC, forwardRef, useImperativeHandle } from \"react\";\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","import useEmblaCarousel from \"embla-carousel-react\";\nimport { FC, useCallback, useEffect } from \"react\";\nimport { NextButton, PrevButton } from \"./buttons\";\nimport { Box, cn, Flex } from \"@orderly.network/ui\";\n\nexport const CarouselBackgroundImage: FC<{\n backgroundImages: 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) return;\n emblaApi.scrollPrev();\n }, [emblaApi]);\n\n const onNextButtonClick = useCallback(() => {\n if (!emblaApi) return;\n emblaApi.scrollNext();\n }, [emblaApi]);\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) return;\n\n onSelect(emblaApi);\n emblaApi.on(\"reInit\", onSelect);\n emblaApi.on(\"select\", onSelect);\n emblaApi?.scrollTo(selectedSnap);\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\n emblaApi?.scrollTo(index);\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, useMemo } from \"react\";\nimport { PnLDisplayFormat } from \"../../types/types\";\nimport { Text, cn } from \"@orderly.network/ui\";\n\nexport const PnlFormatView: FC<{\n type: PnLDisplayFormat;\n curType?: PnLDisplayFormat;\n setPnlFormat: any;\n}> = (props) => {\n const { type, curType, setPnlFormat } = props;\n\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return \"ROI & PnL\";\n case \"roi\":\n return \"ROI\";\n case \"pnl\":\n return \"PnL\";\n }\n }, [type]);\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, useMemo } from \"react\";\nimport { ShareOptions } from \"../../types/types\";\nimport { Flex, Text, cn } from \"@orderly.network/ui\";\nimport { Checkbox } from \"./checkbox\";\n\nexport const ShareOption: FC<{\n type: ShareOptions;\n curType: Set<ShareOptions>;\n setShareOption: any;\n}> = (props) => {\n const { type, curType, setShareOption } = props;\n\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return \"Open price\";\n case \"openTime\":\n return \"Opened at\";\n case \"markPrice\":\n return \"Mark price\";\n case \"quantity\":\n return \"Quantity\";\n case \"leverage\":\n return \"Leverage\";\n }\n }, [type]);\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","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 {\n CloseCircleFillIcon,\n Input,\n toast,\n} from \"@orderly.network/ui\";\nimport { FC, useRef, useState } from \"react\";\nimport { Checkbox } from \"./checkbox\";\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 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 Your message\n </div>\n <div className=\"oui-bg-base-900 oui-mx-2 oui-rounded-sm\">\n <Input\n ref={inputRef}\n placeholder=\"Max 25 characters\"\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(\"Maximum support of 25 characters\");\n return;\n }\n setCheck(e.target.value.length > 0);\n setMessage(e.target.value);\n }}\n />\n </div>\n </div>\n );\n};\n","import { FC } from \"react\";\nimport { Button, Flex } from \"@orderly.network/ui\";\n\nexport const BottomButtons: FC<{\n onClickDownload: any;\n onClickCopy: any;\n}> = (props) => {\n const { onClickDownload, onClickCopy } = props;\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 Download\n </Button>\n\n <Button\n className=\"oui-flex-1 oui-flex oui-gap-1\"\n onClick={onClickCopy}\n >\n <span>\n <CopyIcon />\n </span>\n 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, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Poster } from \"../poster\";\nimport { PosterRef } from \"../poster/poster\";\nimport {\n PnLDisplayFormat,\n ReferralType,\n ShareEntity,\n ShareOptions,\n SharePnLConfig,\n} from \"../../types/types\";\nimport { getPnlInfo, getPnLPosterData, savePnlInfo } from \"../utils/utils\";\nimport {\n Box,\n Button,\n CloseCircleFillIcon,\n cn,\n Input,\n ScrollArea,\n toast,\n} from \"@orderly.network/ui\";\nimport { Carousel } from \"../carousel\";\nimport {\n CarouselContent,\n CarouselItem,\n Dot,\n useCarousel,\n} from \"../carousel/carousel\";\n\nexport const MobileSharePnLContent: FC<{\n entity: ShareEntity;\n leverage: any;\n hide: any;\n baseDp?: number;\n quoteDp?: number;\n referral?: ReferralType;\n shareOptions: SharePnLConfig;\n}> = (props) => {\n const { shareOptions } = props;\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 props.leverage,\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 savePnlInfo(pnlFormat, shareOption, selectIndex, message);\n\n return (\n <div className=\"oui-w-full\">\n {/* <div>{`leverage: ${props.leverage}x`}</div> */}\n <div\n ref={carouselRef}\n className=\"oui-w-full oui-mt-4 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-transform oui-origin-top-left\"\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-mt-2 oui-mb-1 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-max-h-[200px] oui-overflow-y-auto oui-custom-scrollbar\">\n <div className=\"oui-mt-4\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54\">\n PnL display format\n </div>\n <div className=\"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1\">\n {formats.map((item) => (\n <PnlFormatView\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-text-3xs oui-text-base-contrast-54 oui-h-[18px]\">\n Optional information to share\n </div>\n <div className=\"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3\">\n {props.entity.openPrice && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"openPrice\"\n curType={shareOption}\n />\n )}\n {props.entity.openTime && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"openTime\"\n curType={shareOption}\n />\n )}\n {props.leverage && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"leverage\"\n curType={shareOption}\n />\n )}\n {props.entity.markPrice && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"markPrice\"\n curType={shareOption}\n />\n )}\n {props.entity.quantity && (\n <ShareOption\n setShareOption={setShareOption}\n type=\"quantity\"\n curType={shareOption}\n />\n )}\n </div>\n </div>\n\n <div className=\"oui-mt-3 oui-mb-8\">\n <div className=\"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]\">\n Your message\n </div>\n <div className=\"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1\">\n <Input\n placeholder=\"Max 25 characters\"\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(\"Maximum support of 25 characters\");\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 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\n const text = useMemo(() => {\n switch (type) {\n case \"roi_pnl\":\n return \"ROI & PnL\";\n case \"roi\":\n return \"ROI\";\n case \"pnl\":\n return \"PnL\";\n }\n }, [type]);\n\n console.log(\"pnl format\", type, curType);\n\n const isSelected = type === curType;\n\n return (\n <div\n className={cn(\n \"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\",\n isSelected && \"oui-bg-primary-darken oui-dot-sel\"\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\n const text = useMemo(() => {\n switch (type) {\n case \"openPrice\":\n return \"Open price\";\n case \"openTime\":\n return \"Opened at\";\n case \"markPrice\":\n return \"Mark price\";\n case \"quantity\":\n return \"Quantity\";\n case \"leverage\":\n return \"Leverage\";\n }\n }, [type]);\n\n const isSelected = curType.has(type);\n\n return (\n <div\n className={cn(\n \"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\"\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-text-sm oui-flex-1 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 console.log(\"setSelectIndex is\", 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 * as React from \"react\";\nimport useEmblaCarousel, {\n type UseEmblaCarouselType,\n} from \"embla-carousel-react\";\nimport { Button, cn } from \"@orderly.network/ui\";\n\n\n\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>(\n (\n {\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n },\n ref\n ) => {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins\n );\n const [canScrollPrev, setCanScrollPrev] = React.useState(false);\n const [canScrollNext, setCanScrollNext] = React.useState(false);\n const [selectedIndex, setSelectedIndex] = React.useState(props.initIndex ||0);\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 return (\n <CarouselContext.Provider\n value={{\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 <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>(({ className, ...props }, ref) => {\n const { carouselRef, orientation } = useCarousel();\n\n \n\n return (\n <div ref={carouselRef} className=\"oui-overflow-hidden\">\n <div\n ref={ref}\n className={cn(\n \"oui-flex\",\n orientation === \"horizontal\"\n ? \"oui--ml-4\"\n : \"oui--mt-4 oui-flex-col\",\n className\n )}\n {...props}\n />\n </div>\n );\n});\nCarouselContent.displayName = \"CarouselContent\";\n\nconst CarouselItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const { orientation } = useCarousel();\n\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 );\n});\nCarouselItem.displayName = \"CarouselItem\";\n\nconst CarouselPrevious = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>(({ className, variant = \"contained\", size = \"icon\", ...props }, ref) => {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel();\n\n return (\n <Button\n // @ts-ignore\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-h-8 oui-w-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 {/* @ts-ignore */}\n <ChevronLeft size={20} />\n <span className=\"oui-sr-only\">Previous slide</span>\n </Button>\n );\n});\nCarouselPrevious.displayName = \"CarouselPrevious\";\n\nconst CarouselNext = React.forwardRef<\n HTMLButtonElement,\n React.ComponentProps<typeof Button>\n>(({ className, variant = \"contained\", size = \"icon\", ...props }, ref) => {\n const { orientation, scrollNext, canScrollNext } = useCarousel();\n\n return (\n <Button\n // @ts-ignore\n ref={ref}\n variant={variant}\n // size={size}\n className={cn(\n \"oui-absolute oui-h-8 oui-w-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 {/* @ts-ignore */}\n <ChevronRight size={20} />\n <span className=\"oui-sr-only\">Next slide</span>\n </Button>\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};\nconst CarouselIdentifier: React.FC<CarouselIdentifierProps> = (props) => {\n const { scrollSnaps, selectedIndex } = useCarousel();\n\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 console.log(\"activedClassName is\", activedClassName);\n \n return (\n <button\n onClick={() => onClick?.(index)}\n className={cn(\n \"oui-w-2 oui-h-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","\nimport { SharePnLConfig, 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?: SharePnLConfig & 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?: SharePnLConfig & SharePnLParams;\n}) => {\n const state = useSharePnLScript({\n hide: props.hide,\n pnl: props.pnl,\n });\n return <DesktopSharePnL {...state} />;\n};\n"]}
|