@orderly.network/ui-orders 2.2.0 → 2.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -36,12 +36,7 @@ declare const useOrderListScript: (props: useOrderListScriptOptions) => {
36
36
  updateOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
37
37
  cancelAlgoOrder: (orderId: number, symbol?: string) => Promise<any>;
38
38
  updateAlgoOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
39
- pagination: _orderly_network_ui.PaginationMeta | {
40
- page: number;
41
- pageSize: number;
42
- onPageChange: react.Dispatch<react.SetStateAction<number>>;
43
- onPageSizeChange: (size: number) => void;
44
- };
39
+ pagination: _orderly_network_ui.PaginationMeta;
45
40
  manualPagination: boolean;
46
41
  pnlNotionalDecimalPrecision: number | undefined;
47
42
  onFilter: (filter: {
@@ -53,9 +48,7 @@ declare const useOrderListScript: (props: useOrderListScriptOptions) => {
53
48
  onSymbolChange: ((symbol: API.Symbol) => void) | undefined;
54
49
  sharePnLConfig: SharePnLConfig | undefined;
55
50
  tableInstance: react.MutableRefObject<Table<any> | undefined>;
56
- symbolsInfo: {
57
- [x: string]: (key?: keyof API.SymbolExt | undefined, defaultValue?: (string | number) | undefined) => any;
58
- } & {
51
+ symbolsInfo: Record<string, <Key extends keyof API.SymbolExt>(key: Key, defaultValue?: API.SymbolExt[Key] | undefined) => API.SymbolExt[Key]> & Record<string, () => API.SymbolExt> & {
59
52
  isNil: boolean;
60
53
  };
61
54
  filterDays: 1 | 30 | 7 | 90 | null;
package/dist/index.d.ts CHANGED
@@ -36,12 +36,7 @@ declare const useOrderListScript: (props: useOrderListScriptOptions) => {
36
36
  updateOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
37
37
  cancelAlgoOrder: (orderId: number, symbol?: string) => Promise<any>;
38
38
  updateAlgoOrder: (orderId: string, order: _orderly_network_types.OrderEntity) => Promise<any>;
39
- pagination: _orderly_network_ui.PaginationMeta | {
40
- page: number;
41
- pageSize: number;
42
- onPageChange: react.Dispatch<react.SetStateAction<number>>;
43
- onPageSizeChange: (size: number) => void;
44
- };
39
+ pagination: _orderly_network_ui.PaginationMeta;
45
40
  manualPagination: boolean;
46
41
  pnlNotionalDecimalPrecision: number | undefined;
47
42
  onFilter: (filter: {
@@ -53,9 +48,7 @@ declare const useOrderListScript: (props: useOrderListScriptOptions) => {
53
48
  onSymbolChange: ((symbol: API.Symbol) => void) | undefined;
54
49
  sharePnLConfig: SharePnLConfig | undefined;
55
50
  tableInstance: react.MutableRefObject<Table<any> | undefined>;
56
- symbolsInfo: {
57
- [x: string]: (key?: keyof API.SymbolExt | undefined, defaultValue?: (string | number) | undefined) => any;
58
- } & {
51
+ symbolsInfo: Record<string, <Key extends keyof API.SymbolExt>(key: Key, defaultValue?: API.SymbolExt[Key] | undefined) => API.SymbolExt[Key]> & Record<string, () => API.SymbolExt> & {
59
52
  isNil: boolean;
60
53
  };
61
54
  filterDays: 1 | 30 | 7 | 90 | null;
package/dist/index.js CHANGED
@@ -6,24 +6,24 @@ var types = require('@orderly.network/types');
6
6
  var i18n = require('@orderly.network/i18n');
7
7
  var uiConnector = require('@orderly.network/ui-connector');
8
8
  var hooks = require('@orderly.network/hooks');
9
+ var dateFns = require('date-fns');
10
+ var uiShare = require('@orderly.network/ui-share');
9
11
  var utils = require('@orderly.network/utils');
10
12
  var jsxRuntime = require('react/jsx-runtime');
11
13
  var uiTpsl = require('@orderly.network/ui-tpsl');
12
- var uiShare = require('@orderly.network/ui-share');
13
- var dateFns = require('date-fns');
14
14
  var reactApp = require('@orderly.network/react-app');
15
15
 
16
- var wt=e=>{let{current:t,pnlNotionalDecimalPrecision:r,sharePnLConfig:o}=e,n=react.useRef(null);return react.useImperativeHandle(e.ref,()=>({download:()=>{n.current?.download?.();}})),{current:t,pnlNotionalDecimalPrecision:r,orderListRef:n,sharePnLConfig:o}};var Le=e=>e===void 0||e.length===0?e:e.length===1?e.charAt(0).toUpperCase():e.charAt(0).toUpperCase()+e.toLowerCase().slice(1);function ue(e){let t=e.type,r=e.algo_type;if(typeof t<"u"){let o=[];if(e.parent_algo_type){if(r===types.AlgoOrderType.STOP_LOSS){let i=t===types.OrderType.CLOSE_POSITION?[i18n.i18n.t("common.position"),i18n.i18n.t("tpsl.sl")]:[i18n.i18n.t("tpsl.sl")];o.push(...i);}if(r===types.AlgoOrderType.TAKE_PROFIT){let i=t===types.OrderType.CLOSE_POSITION?[i18n.i18n.t("common.position"),i18n.i18n.t("tpsl.tp")]:[i18n.i18n.t("tpsl.tp")];o.push(...i);}return o}let n=typeof t=="string"?t.replace("_ORDER",""):"";if([types.OrderType.ASK,types.OrderType.BID].includes(t))return [i18n.i18n.t("orderEntry.orderType.limit")];if(e.algo_order_id===void 0||e.algo_order_id&&r==="BRACKET")return [{[types.OrderType.LIMIT]:i18n.i18n.t("orderEntry.orderType.limit"),[types.OrderType.MARKET]:i18n.i18n.t("orderEntry.orderType.market"),[types.OrderType.POST_ONLY]:i18n.i18n.t("orderEntry.orderType.postOnly"),[types.OrderType.IOC]:i18n.i18n.t("orderEntry.orderType.ioc"),[types.OrderType.FOK]:i18n.i18n.t("orderEntry.orderType.fok")}[n]||Le(n)];if(n)return [{[types.OrderType.LIMIT]:i18n.i18n.t("orderEntry.orderType.stopLimit"),[types.OrderType.MARKET]:i18n.i18n.t("orderEntry.orderType.stopMarket")}[n]||n]}if(typeof r<"u"){let o=[];r===types.AlgoOrderRootType.POSITIONAL_TP_SL&&o.push(i18n.i18n.t("common.position"));let n=e?.child_orders?.find(a=>a.algo_type===types.AlgoOrderType.TAKE_PROFIT&&!!a.trigger_price),i=e?.child_orders?.find(a=>a.algo_type===types.AlgoOrderType.STOP_LOSS&&!!a.trigger_price);return (n||i)&&o.push(n&&i?i18n.i18n.t("common.tpsl"):n?i18n.i18n.t("tpsl.tp"):i18n.i18n.t("tpsl.sl")),o}}function ne(e){return e.status===types.OrderStatus.CANCELLED||e.algo_status===types.OrderStatus.CANCELLED}function pn(e){if(e.algo_type!==types.AlgoOrderRootType.BRACKET)return {tpOrder:void 0,slOrder:void 0};let t=e.child_orders?.[0];if(!t)return {tpOrder:void 0,slOrder:void 0};let r=t?.child_orders?.find(n=>n.algo_type===types.AlgoOrderType.TAKE_PROFIT),o=t?.child_orders?.find(n=>n.algo_type===types.AlgoOrderType.STOP_LOSS);return {tpOrder:r,slOrder:o}}function ct(e){let t={pnl:{tpPnL:void 0,slPnL:void 0},roi:{tpRoi:void 0,slRoi:void 0}},{tpOrder:r,slOrder:o}=pn(e);if(!r&&!o||typeof e.price===void 0||!e.price)return t;let n=e.side===types.OrderSide.BUY?e.quantity:e.quantity*-1,i=r?.trigger_price&&hooks.utils.priceToPnl({qty:n,price:r?.trigger_price,entryPrice:e.price,orderSide:e.side,orderType:r.algo_type}),a=o?.trigger_price&&hooks.utils.priceToPnl({qty:n,price:o?.trigger_price,entryPrice:e.price,orderSide:e.side,orderType:o.algo_type}),s=i?hooks.utils.calcTPSL_ROI({pnl:i,qty:e.quantity,price:e.price}):void 0,d=a?hooks.utils.calcTPSL_ROI({pnl:a,qty:e.quantity,price:e.price}):void 0;return {pnl:{tpPnL:i,slPnL:a},roi:{tpRoi:s,slRoi:d}}}function It(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}var qe=e=>{let{type:t,base:r,value:o,cancelPopover:n,isSubmitting:i,onConfirm:a}=e,{t:s}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-pt-5 oui-relative",children:[jsxRuntime.jsx("div",{className:"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm",children:(()=>{let u={values:{base:r,value:utils.commify(o)},components:[jsxRuntime.jsx("span",{className:"oui-text-warning-darken"})]};switch(t){case 0:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.quantity",...u});case 1:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.price",...u});case 2:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.triggerPrice",...u})}})()}),jsxRuntime.jsxs("div",{className:"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5",children:[jsxRuntime.jsx(ui.Button,{color:"secondary",size:"md",onClick:n,disabled:i,children:s("common.cancel")}),jsxRuntime.jsx(ui.ThrottledButton,{size:"md",loading:i,onClick:a,children:s("common.confirm")})]}),jsxRuntime.jsx("button",{className:"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54",onClick:n,children:jsxRuntime.jsx(ui.CloseIcon,{size:16,color:"white",opacity:1})})]})};var Re=e=>{let{inputRef:t,dp:r,value:o,setValue:n,setEditing:i,error:a,handleKeyDown:s,onClick:d,onClose:u,onFocus:l,onBlur:f,hintInfo:x}=e;react.useEffect(()=>{let h=t.current;if(h){let p=h.value.length;h.setSelectionRange(p,p);}i(true);},[]);let C=(x?.length||0)>0;return jsxRuntime.jsx(ui.Tooltip,{content:x,open:C,children:jsxRuntime.jsx(ui.Input,{ref:t,type:"text",size:"sm",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(r),ui.inputFormatter.currencyFormatter],value:o,onValueChange:h=>n(h),helpText:a,onClick:h=>{h.stopPropagation(),h.preventDefault();},autoComplete:"off",onFocus:l,onBlur:f,onKeyDown:s,autoFocus:true,color:C?"danger":void 0,classNames:{root:"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded",input:"oui-pr-2"},suffix:jsxRuntime.jsx("button",{onClick:d,children:jsxRuntime.jsx(ui.CheckIcon,{size:18,color:"white",opacity:1,className:"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100"})})})})};var vr=react.createContext({}),Z=()=>react.useContext(vr),Dt=e=>{let{cancelOrder:t,editOrder:r,cancelAlgoOrder:o,editAlgoOrder:n}=e,{t:i}=i18n.useTranslation(),a=hooks.useSymbolsInfo(),s=react.useCallback(async l=>l.algo_order_id!==void 0?"root_algo_order_id"in l&&l.root_algo_order_id!==l.algo_order_id?o(l.root_algo_order_id,l.symbol):o(l.algo_order_id,l.symbol).then(()=>{}):t(l.order_id,l.symbol).then(()=>{}),[]),d=react.useCallback(async(l,f)=>{l.visible_quantity!==void 0?l.visible_quantity===0:l.visible!==void 0?l.visible===0:false;await ui.modal.sheet({title:i("orders.editOrder"),classNames:{content:"oui-edit-order-sheet-content"},content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Content"})});},[i]),u=react.useCallback((l,f,x)=>{let{min_notional:C}=a[l](),h=hooks.getMinNotional({price:f,qty:x,min_notional:C});if(h!==void 0)return i("orderEntry.total.error.min",{value:h})},[a,i]);return jsxRuntime.jsx(vr.Provider,{value:{onCancelOrder:s,onEditOrder:d,editOrder:r,editAlgoOrder:n,checkMinNotional:u},children:e.children})};var Ar=react.createContext({}),z=()=>react.useContext(Ar),Ft=e=>{let t=hooks.useSymbolsInfo()[e.symbol];return jsxRuntime.jsx(Ar.Provider,{value:{base_dp:t("base_dp"),quote_dp:t("quote_dp"),base_tick:t("base_tick"),quote_tick:t("quote_tick"),base:t("base"),quote:t("quote"),symbol:e.symbol,origin:t(),quote_max:t("quote_max"),quote_min:t("quote_min")},children:e.children})};var kr=react.createContext({}),G=()=>react.useContext(kr),qt=e=>{let{quote_dp:t}=z(),[r,o]=react.useState(),[n]=hooks.useMutation("/v1/algo/order","DELETE"),[i]=hooks.useMutation("/v1/algo/order","PUT"),a=hooks.useSWRConfig(),{state:s}=hooks.useAccount(),d=react.useMemo(()=>hooks.unstable_serialize(()=>["/v1/positions",s.accountId]),[s.accountId]),u=async P=>n(null,{order_id:P.algo_order_id,symbol:P.symbol}),l=async(P,N)=>i({order_id:P.algo_order_id,child_orders:P.child_orders.map(T=>({order_id:T.algo_order_id,quantity:N.order_quantity}))}),f=P=>a.cache.get(d)?.data.rows.find(T=>T.symbol===P),{sl_trigger_price:x,tp_trigger_price:C,tpPnL:h,slPnL:p}=$n({order:e.order,position:r,quote_dp:t});return react.useEffect(()=>{if("algo_type"in e.order||(e.order?.reduce_only??false)){let P=f(e.order.symbol);P&&o(P);}},[e.order.symbol]),jsxRuntime.jsx(kr.Provider,{value:{order:e.order,sl_trigger_price:x,tp_trigger_price:C,tpPnL:h,slPnL:p,onCancelOrder:u,onUpdateOrder:l,getRelatedPosition:f,position:r},children:e.children})};function $n(e){let{order:t,position:r,quote_dp:o}=e;if(!r)return {sl_trigger_price:void 0,tp_trigger_price:void 0,slPnL:void 0,tpPnL:void 0};let{sl_trigger_price:n,tp_trigger_price:i}=!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(t),a=t.quantity;a===0&&t.child_orders?.[0].type==="CLOSE_POSITION"&&(a=r.position_qty);let s=r.average_open_price,d=typeof a=="number"&&typeof i=="number"&&typeof s=="number"?hooks.utils.priceToPnl({qty:a,price:i,entryPrice:r.average_open_price,orderSide:t.side,orderType:types.AlgoOrderType.TAKE_PROFIT},{symbol:{quote_dp:o}}):void 0,u=typeof a=="number"&&typeof n=="number"&&typeof s=="number"?hooks.utils.priceToPnl({qty:a,price:n,entryPrice:r.average_open_price,orderSide:t.side,orderType:types.AlgoOrderType.STOP_LOSS},{symbol:{quote_dp:o}}):void 0;return {sl_trigger_price:n,tp_trigger_price:i,slPnL:u,tpPnL:d}}var Mt=e=>{let{order:t,otherOrderQuantity:r}=e,{reduce_only:o}=t,[n,i]=react.useState(t.quantity.toString()),[a,s]=react.useState(false),{t:d}=i18n.useTranslation();react.useEffect(()=>{E(t.quantity.toString());},[e.order.quantity]);let[u,l]=react.useState(false),[f,x]=react.useState(),{editOrder:C,editAlgoOrder:h,checkMinNotional:p}=Z(),{onUpdateOrder:P,position:N}=G(),{base_dp:T,base:q,base_tick:g}=z(),E=async(y,b)=>{i(y);let B=Math.abs(N?.position_qty||0);if(N&&o&&Number(y)>B)x(d("orders.quantity.lessThanPosition",{quantity:B}));else {let Ce=Number(y);b&&Ce>b?x(d("orders.quantity.lessThan",{quantity:utils.commifyOptional(b,{fix:T})})):x(void 0);}return Promise.resolve()},W=()=>{l(false),s(false);},R=()=>{l(false),E(t.quantity.toString()),s(false);},[O,L]=react.useState(false),F=react.useRef(null),X=()=>{if(f)return;if(Number(n)===Number(t.quantity)){s(false);return}let y=t.algo_order_id!==void 0?t.trigger_price:t.price;if(y!==null&&t.reduce_only!==true){let b=p(t.symbol,y,n);if(b){ui.toast.error(b),L(false),R();return}}l(true);},v=y=>{y?.stopPropagation(),y?.preventDefault(),X();},Y=y=>{y.key==="Enter"&&(y?.stopPropagation(),y?.preventDefault(),X());},A=react.useCallback(()=>{L(true);let y={symbol:t.symbol,order_type:t.type,side:t.side,order_price:t.price,order_quantity:n,algo_order_id:t.algo_order_id};if(typeof y.algo_order_id<"u"&&y.order_type==="MARKET"){let{order_price:B,...Ce}=y;y=Ce;}typeof t.reduce_only<"u"&&(y.reduce_only=t.reduce_only),t.order_tag!==void 0&&(y={...y,order_tag:t.order_tag}),t?.visible_quantity===0&&(y.visible_quantity=0),t?.tag!==void 0&&(y.order_tag=t.tag);let b;"algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?b=P(t,y):t.algo_order_id!==void 0?b=h(t.algo_order_id.toString(),y):b=C(t.order_id.toString(),y),b.then(B=>{W(),E(n.toString());},B=>{ui.toast.error(B.message),E(t.quantity.toString()),R();}).finally(()=>L(false));},[n]),D=react.useRef(null),re=react.useRef(null),de=y=>{D.current&&re.current&&!D.current.contains(y.target)&&!re.current.contains(y.target)&&!u&&R();};react.useEffect(()=>(document.addEventListener("mousedown",de),()=>{document.removeEventListener("mousedown",de);}),[u,t.quantity]);let Ge=()=>!a||e.disableEdit?jsxRuntime.jsx(ei,{order:t,quantity:n,setEditing:s,disableEdit:e.disableEdit}):jsxRuntime.jsx(ti,{inputRef:F,quantitySliderRef:re,base_dp:T,base_tick:g,quantity:n,setQuantity:E,editing:a,setEditing:s,handleKeyDown:Y,onClick:v,onClose:R,symbol:t.symbol,reduce_only:o,positionQty:N?.position_qty,error:f,confirmOpen:u,side:t.side,order:t,setError:x});return jsxRuntime.jsx(ui.Popover,{open:u,onOpenChange:l,content:jsxRuntime.jsx(qe,{type:0,base:q,value:n,cancelPopover:R,isSubmitting:O,onConfirm:A}),contentProps:{onOpenAutoFocus:y=>{}},children:jsxRuntime.jsx("div",{onClick:y=>{y.stopPropagation(),y.preventDefault();},ref:D,children:Ge()})})},ei=e=>{let{order:t,quantity:r}=e,o=t.total_executed_quantity;return jsxRuntime.jsxs(ui.Flex,{direction:"row",justify:"start",gap:1,className:ui.cn("oui-max-w-[110px] oui-relative",t.side===types.OrderSide.BUY&&"oui-text-trade-profit",t.side===types.OrderSide.SELL&&"oui-text-trade-loss",ne(t)&&"oui-text-base-contrast-20"),onClick:n=>{n.stopPropagation(),n.preventDefault(),e.setEditing(true);},children:["algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),jsxRuntime.jsx("span",{children:"/"})]}),jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})]})},ti=e=>{let{inputRef:t,quantitySliderRef:r,base_dp:o,base_tick:n,quantity:i,setQuantity:a,editing:s,setEditing:d,handleKeyDown:u,onClick:l,onClose:f,error:x,symbol:C,reduce_only:h,positionQty:p,confirmOpen:P,side:N,order:T}=e,q=hooks.useMaxQty(C,T.side,T.reduce_only),g=react.useMemo(()=>h?Math.abs(p??0):T.quantity+Math.abs(q),[T.quantity,q,h,p]),[E,W]=react.useState(void 0);react.useEffect(()=>{if(E===void 0){let O=new utils.Decimal(i).div(g).abs().mul(100).toNumber();W(O);}},[E,g,i]);let R=async O=>(n>0&&(O=hooks.utils.formatNumber(O,n)??O),a(`${O}`,g));return jsxRuntime.jsxs(ui.PopoverRoot,{open:!P,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(Re,{inputRef:t,dp:o,value:i,setValue:O=>{let L=Math.abs(Math.min(Number(O),g)).toString();if(a(O,g),O.endsWith("."))return;if(Number(L)===0){W(0);return}let F=new utils.Decimal(O).div(g).mul(100).toDecimalPlaces(2,utils.Decimal.ROUND_DOWN).toNumber();W(Math.min(100,F));},setEditing:d,handleKeyDown:u,onClick:l,onClose:f,onBlur:O=>{R(O.target.value);},hintInfo:x})}),jsxRuntime.jsx(ui.PopoverContent,{className:"oui-w-[360px] oui-rounded-xl",align:"start",side:"bottom",onOpenAutoFocus:O=>{O.preventDefault();},children:jsxRuntime.jsxs(ui.Flex,{p:1,gap:2,width:"100%",itemAlign:"start",ref:r,children:[jsxRuntime.jsx(ui.Text.numeral,{size:"xs",intensity:98,className:"oui-min-w-[30px] ",dp:2,padding:false,unit:"%",rm:utils.Decimal.ROUND_DOWN,children:`${E}`}),jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",gap:2,className:"oui-mt-[6px]",children:[jsxRuntime.jsx(ui.Slider,{markCount:4,value:[E??0],onValueChange:O=>{let L=Array.from(O.values());W(L[0]);let F=new utils.Decimal(L[0]).div(100).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);a(F,g);},onValueCommit:O=>{let L=new utils.Decimal(O[0]).div(100).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);R(L).finally(()=>{t.current.focus();});}}),jsxRuntime.jsx(ri,{onClick:O=>{W(O*100);let L=new utils.Decimal(O).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);L=hooks.utils.formatNumber(L,n)??L,a(L,g),setTimeout(()=>{t.current.focus(),t.current.setSelectionRange(L.length,L.length);},100);}})]})]})})]})},ri=e=>{let{t}=i18n.useTranslation(),r=[{label:"0%",value:0},{label:"25%",value:.25},{label:"50%",value:.5},{label:"75%",value:.75},{label:t("common.max"),value:1}];return jsxRuntime.jsx(ui.Flex,{gap:2,width:"100%",children:r.map((o,n)=>jsxRuntime.jsx(ui.Button,{variant:"outlined",color:"secondary",size:"xs",onClick:i=>{i.stopPropagation(),i.preventDefault(),e.onClick(o.value);},className:"oui-w-1/5",children:o.label},n))})};var Yr=e=>{let{order:t}=e,{t:r}=i18n.useTranslation(),[o,n]=react.useState(()=>t.type===types.OrderType.MARKET&&!t.price?"Market":t.price?.toString()??"Market"),[i,a]=react.useState(false),[s,d]=react.useState(false),u=t?.algo_order_id!==void 0,l=t?.type==="MARKET"&&u,[f,x]=react.useState(false),{editOrder:C,editAlgoOrder:h,checkMinNotional:p}=Z(),{base:P,quote_dp:N}=z(),T=hooks.useSymbolPriceRange(t.symbol,t.side,u?t.trigger_price:void 0),q=()=>{a(false),d(false);},g=()=>{a(false),n(t.price?.toString()??"Market"),d(false);},E=react.useMemo(()=>!T||l||!s?"":Number(o)>T.max?r("orders.price.greaterThan",{max:T.max}):Number(o)<T.min?r("orders.price.lessThan",{min:T.min}):"",[l,s,T,o,r]),W=A=>{if(A?.stopPropagation(),A?.preventDefault(),!(E.length>0)){if(o===`${t.price}`){d(false);return}if(t.reduce_only!==true){let D=p(t.symbol,o,t.quantity);if(D){ui.toast.error(D),x(false),g();return}}a(true);}},R=A=>{A.key==="Enter"&&W(A);},O=()=>{x(true);let A=t.order_id,D={order_price:o,order_quantity:t.quantity,symbol:t.symbol,order_type:t.type,side:t.side};typeof t.reduce_only<"u"&&(D.reduce_only=t.reduce_only),t.order_tag!==void 0&&(D={...D,order_tag:t.order_tag}),u&&(A=t.algo_order_id,D={...D,order_id:A,price:o,algo_order_id:A}),t?.visible_quantity===0&&(D.visible_quantity=0),t.tag!==void 0&&(D.order_tag=t.tag);let re;t.algo_order_id!==void 0?re=h(t.algo_order_id.toString(),D):re=C(t.order_id.toString(),D),re.then(de=>{q(),n(o);},de=>{ui.toast.error(de.message),g();}).finally(()=>x(false));},L=react.useRef(null);react.useEffect(()=>{e.order.price&&n(`${e.order.price}`);},[e.order.price]);let F=react.useRef(null),X=A=>{F.current&&!F.current.contains(A.target)&&!i&&g();};if(react.useEffect(()=>(document.addEventListener("mousedown",X),()=>{document.removeEventListener("mousedown",X);}),[i,t.price]),t.algo_order_id&&t.type=="MARKET"||o==="Market")return jsxRuntime.jsx("span",{children:r("common.marketPrice")});let Y=()=>!s||e.disableEdit?jsxRuntime.jsx(mi,{order:t,price:o,setEditing:d,disableEdit:e.disableEdit}):jsxRuntime.jsx(Re,{inputRef:L,dp:N,value:o,setValue:n,setEditing:d,handleKeyDown:R,onClick:W,onClose:g,hintInfo:E});return jsxRuntime.jsx(ui.Popover,{open:i,onOpenChange:a,content:jsxRuntime.jsx(qe,{type:1,base:P,value:o,cancelPopover:g,isSubmitting:f,onConfirm:O}),children:jsxRuntime.jsx("div",{onClick:A=>{A.stopPropagation(),A.preventDefault();},ref:F,children:Y()})})},mi=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",ne(t)&&"oui-text-base-contrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(true);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:utils.commifyOptional(r)})})})};var eo=e=>{let{order:t}=e,[r,o]=react.useState("");react.useEffect(()=>{o(t.trigger_price?.toString()??"0");},[t.trigger_price]);let n=t?.algo_order_id!==void 0,i=t?.algo_type==="BRACKET",[a,s]=react.useState(false),[d,u]=react.useState(false),[l,f]=react.useState(false),{editAlgoOrder:x,checkMinNotional:C}=Z(),{base:h,quote_dp:p,quote_max:P,quote_min:N}=z(),T=react.useMemo(()=>{if(!((!n||i)&&!d)){if(Number(r)>P)return `Trigger price must be less than ${P}`;if(Number(r)<N)return `Trigger price must be greater than ${N}`}},[d,r,n,i]),q=()=>{s(false),u(false);},g=()=>{o(t.trigger_price?.toString()??"0"),s(false),u(false);},E=react.useRef(null),W=v=>{E.current&&!E.current.contains(v.target)&&!a&&g();};react.useEffect(()=>(document.addEventListener("mousedown",W),()=>{document.removeEventListener("mousedown",W);}),[a,t.trigger_price]);let R=v=>{if(v?.stopPropagation(),v?.preventDefault(),u(false),Number(r)!==Number(t.trigger_price)){if(t.price&&t.reduce_only!==true){let Y=C(t.symbol,t.price,t.quantity);if(Y){ui.toast.error(Y),f(false),g();return}}s(true);}},O=v=>{v.key==="Enter"&&R(v);},L=()=>{if((T??"").length>0)return;f(true);let v={quantity:t.quantity,trigger_price:r,symbol:t.symbol,algo_order_id:t.algo_order_id};t.order_tag!==void 0&&(v={...v,order_tag:t.order_tag}),x(`${t.algo_order_id}`,v).then(Y=>{q(),o(r);},Y=>{ui.toast.error(Y.message),o(t.trigger_price?.toString()??"--"),g();}).finally(()=>f(false));},F=react.useRef(null);if(!n||i)return jsxRuntime.jsx(ui.Text,{children:"--"});let X=()=>!d||e.disableEdit?jsxRuntime.jsx(yi,{order:t,price:r,setEditing:u,disableEdit:e.disableEdit}):jsxRuntime.jsx(Re,{inputRef:F,dp:p,value:r,setValue:o,setEditing:u,handleKeyDown:O,onClick:R,onClose:g,hintInfo:T});return jsxRuntime.jsx(ui.Popover,{open:a,onOpenChange:s,content:jsxRuntime.jsx(qe,{type:2,base:h,value:r,cancelPopover:g,isSubmitting:l,onConfirm:L}),children:jsxRuntime.jsx("div",{onClick:v=>{v.stopPropagation(),v.preventDefault();},ref:E,children:X()})})},yi=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",ne(t)&&"oui-text-base-contrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(true);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})})};var gt=e=>{let{order:t}=e,{t:r}=i18n.useTranslation(),{onCancelOrder:o}=Z(),[n,i]=react.useState(false);return jsxRuntime.jsx(ui.ThrottledButton,{size:"sm",variant:"outlined",color:"secondary",onClick:a=>{o&&(a.preventDefault(),a.stopPropagation(),i(true),o(t).then(s=>s,s=>{ui.toast.error(s.message);}).finally(()=>{i(false);}));},loading:n,children:r("common.cancel")})};var to=e=>{let{record:t}=e,[r,o]=react.useState(false),[n,{data:i,error:a,reset:s,isMutating:d}]=hooks.useMutation("/v1/order"),{t:u}=i18n.useTranslation(),l=hooks.useConfig("brokerId"),f=react.useCallback(()=>{o(false);let x={symbol:t.symbol,order_type:t.type,order_price:t.price,order_quantity:t.quantity,order_amount:t.amount,side:t.side,broker_id:l};Number(t.visible_quantity)<Number(t.quantity)&&(x.visible_quantity=0),typeof t.reduce_only<"u"&&(x.reduce_only=t.reduce_only),n(x);},[]);return jsxRuntime.jsx(ui.Button,{size:"sm",variant:"outlined",color:"secondary",loading:d,disabled:d,onClick:x=>{d||(x.preventDefault(),x.stopPropagation(),f());},children:u("orders.history.renew")})};var io=()=>{let{sl_trigger_price:e,tp_trigger_price:t,order:r,position:o}=G();return jsxRuntime.jsx(Ai,{stopLossPrice:e,takeProfitPrice:t,direction:"column",order:r,position:o,tooltip:true})},Ai=e=>{let{direction:t="row",order:r,position:o}=e,n=hooks.useSymbolsInfo(),{t:i}=i18n.useTranslation(),a=react.useMemo(()=>{let u=[];if(!e.tooltip||!r||!o)return;let l=r.quantity;return l===0&&r.child_orders?.[0].type==="CLOSE_POSITION"&&(l=o.position_qty),e.takeProfitPrice&&u.push(jsxRuntime.jsx(oo,{qty:l,price:e.takeProfitPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.TAKE_PROFIT,symbolInfo:n[r.symbol]()},"tp")),e.stopLossPrice&&u.push(jsxRuntime.jsx(oo,{qty:l,price:e.stopLossPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.STOP_LOSS,symbolInfo:n[r.symbol]()},"sl")),jsxRuntime.jsx("div",{children:u})},[e.takeProfitPrice,e.stopLossPrice,o?.average_open_price,r?.side,r?.quantity,r?.algo_type]),s=react.useMemo(()=>{let u=[];return r?.symbol?(e.takeProfitPrice&&u.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-profit oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12"),rule:"price",dp:n[r.symbol]("quote_dp",2),children:e.takeProfitPrice,prefix:!e.stopLossPrice||t==="column"?jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${i("tpsl.tp")} -`,"\xA0"]}):""},"tp")),e.stopLossPrice&&u.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12"),rule:"price",dp:n[r.symbol]("quote_dp",2),children:e.stopLossPrice,prefix:!e.takeProfitPrice||t==="column"?jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${i("tpsl.sl")} -`,"\xA0"]}):""},"sl")),u.length===0?jsxRuntime.jsx("span",{children:"-"}):(u.length===2&&t==="row"&&u.splice(1,0,jsxRuntime.jsx("span",{children:"/"},"split")),u)):jsxRuntime.jsx("span",{children:"-"})},[e.takeProfitPrice,e.stopLossPrice,r?.symbol,i]),d=jsxRuntime.jsx("div",{className:ui.cn("oui-inline-flex oui-text-base-contrast-36",e.direction==="column"?"oui-flex-col":"oui-flex-row oui-gap-1",e.className),children:s});return e.tooltip?jsxRuntime.jsx(ui.Tooltip,{content:a,className:"oui-bg-base-5",arrow:{className:"oui-fill-base-5"},children:d}):d},oo=e=>{let{qty:t,price:r,entryPrice:o,orderSide:n,orderType:i,symbolInfo:a}=e,{t:s}=i18n.useTranslation(),d=hooks.utils.priceToPnl({qty:t,price:r,entryPrice:o,orderSide:n,orderType:i},{symbol:a}),l=(i===types.AlgoOrderType.TAKE_PROFIT?"TP":"SL")==="TP"?`${s("tpsl.tpPnl")}:`:`${s("tpsl.slPnl")}:`;return jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54 oui-mr-1",children:l}),jsxRuntime.jsx(ui.Text.numeral,{rule:"price",dp:a.quote_dp,padding:false,className:d===0?"oui-text-base-contrast-36":d>0?"oui-text-trade-profit oui-gap-0":"oui-text-trade-loss oui-gap-0",prefix:jsxRuntime.jsx("span",{children:d===0?"":d>0?"+":"-"}),suffix:jsxRuntime.jsx("span",{className:"oui-text-base-contrast-36 oui-ml-1",children:"USDC"}),children:`${Math.abs(d)}`})]})};var uo=e=>{let{order:t}=e,{quote_dp:r,base_dp:o}=z(),{t:n}=i18n.useTranslation(),{sl_trigger_price:i,tp_trigger_price:a}=react.useMemo(()=>!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(e.order.child_orders[0]),[e.order]),{pnl:s,roi:d}=ct(t);return !a&&!i?"--":jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",gap:1,children:[typeof s.tpPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${n("tpsl.tpPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:r,color:"buy",showIdentifier:true,children:s.tpPnL}),typeof s.slPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${n("tpsl.slPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:r,color:"sell",children:s.slPnL})]}),className:"oui-bg-base-6",children:jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(so,{type:"TP",value:a,quote_dp:r}),jsxRuntime.jsx(so,{type:"SL",value:i,quote_dp:r})]})})},so=e=>{let{type:t,value:r,quote_dp:o}=e,{t:n}=i18n.useTranslation();return r?jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),rule:"price",dp:o,prefix:jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[t==="TP"?`${n("tpsl.tp")} -`:`${n("tpsl.sl")} -`,"\xA0"]}),children:r},"tp"):jsxRuntime.jsx(jsxRuntime.Fragment,{})};var co=e=>{let{position:t,order:r}=G(),{quote_dp:o,base_dp:n}=z(),{t:i}=i18n.useTranslation();return jsxRuntime.jsx(uiTpsl.PositionTPSLPopover,{quoteDP:o,baseDP:n,position:t,order:r,label:i("common.edit"),isEditing:true})};var po=()=>{let{sl_trigger_price:e,tp_trigger_price:t}=G(),{t:r}=i18n.useTranslation();return jsxRuntime.jsxs("div",{children:[t?jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-80 oui-td-bg-transparent",children:[jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${r("tpsl.tp")} -`,"\xA0"]}),jsxRuntime.jsx("span",{children:r("common.marketPrice")})]}):null,e?jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-80 oui-td-bg-transparent",children:[jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${r("tpsl.sl")} -`,"\xA0"]}),jsxRuntime.jsx("span",{children:r("common.marketPrice")})]}):null]})};function fo(e){let{sl_trigger_price:t,tp_trigger_price:r}=!("algo_type"in e)||!Array.isArray(e.child_orders)?{}:hooks.utils.findTPSLFromOrder(e),o=r?`${i18n.i18n.t("tpsl.tp")} - ${i18n.i18n.t("common.marketPrice")}`:void 0,n=t?`${i18n.i18n.t("tpsl.sl")} - ${i18n.i18n.t("common.marketPrice")}`:void 0;return {tpTriggerPrice:o,slTriggerPrice:n}}var Qt=e=>{let{t}=i18n.useTranslation();return e.sharePnLConfig==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),ui.modal.show(e.modalId,{pnl:{entity:{symbol:e.order.symbol,pnl:e.order.realized_pnl,side:e.order.side=="BUY"?t("share.pnl.share.long"):t("share.pnl.share.short"),openPrice:e.order.average_executed_price,openTime:e.order.updated_time,quantity:e.order.quantity},refCode:e.refCode,leverage:e.leverage,...e.sharePnLConfig}});},children:jsxRuntime.jsx(ui.ShareIcon,{color:"white",opacity:.54,size:e.iconSize??16})})};var go=e=>{let{sharePnLConfig:t,order:r,modalId:o,iconSize:n}=e,{getFirstRefCode:i}=hooks.useReferralInfo(),a=react.useMemo(()=>i()?.code,[i]),s=hooks.useSymbolLeverage(e.order.symbol);return {iconSize:n,order:r,refCode:a,leverage:s,sharePnLConfig:t,modalId:o}};var et=e=>{let t=go(e);return jsxRuntime.jsx(Qt,{...t})};var xo=e=>{let{_type:t,onSymbolChange:r,pnlNotionalDecimalPrecision:o,sharePnLConfig:n}=e,{t:i}=i18n.useTranslation();return react.useMemo(()=>{switch(t){case "all":return [we({width:130,showType:true,onSymbolChange:r,enableSort:false}),Me({width:130,disableEdit:true,className:"oui-pl-0 oui-pr-0",enableSort:false}),We({width:130,title:i("orders.column.orderPrice"),disableEdit:true,enableSort:false}),bt({width:130,enableSort:false}),yo({width:130,symbolsInfo:e.symbolsInfo}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo}),ze({width:130,enableSort:false}),rt({width:130}),ot({width:130}),Ie({width:130}),$e({width:130}),bo({width:130}),Ue({width:160,enableSort:false})];case "pending":return [we({width:172,showType:true,onSymbolChange:r,enableSort:false}),Me({width:162,className:"oui-pr-0",enableSort:false}),We({width:162,className:"oui-pr-0",enableSort:false}),tt({width:162,className:"oui-pr-0"}),la({width:130}),ze({width:162,isPending:true}),Ie({width:162}),$e({width:162}),Ue({width:162,enableSort:false}),ua({width:162})];case "tp_sl":return [we({width:176,showType:true,onSymbolChange:r,enableSort:false}),ia({width:176}),yo({width:176,symbolsInfo:e.symbolsInfo}),aa({width:176}),da({width:176}),Ie({width:176}),Ue({width:176,enableSort:false}),ca({width:176})];case "filled":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0"}),We({width:124,title:i("orders.column.orderPrice"),disableEdit:true}),sa({width:124}),tt({width:124,disableEdit:true}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo,hideShare:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:176})];case "cancelled":return [we({showType:true,width:154,onSymbolChange:r,enableSort:false}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0",enableSort:false}),We({width:124,disableEdit:true,enableSort:false}),bt({width:124,enableSort:false}),tt({width:124,disableEdit:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124})];case "rejected":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0"}),We({width:124,disableEdit:true}),bt({width:124}),tt({width:124,disableEdit:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:176})];case "orderHistory":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:150,disableEdit:true,className:"oui-pl-6 oui-pr-0"}),We({width:124,disableEdit:true}),bt({width:124}),tt({width:124,disableEdit:true}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:150}),bo({width:80})]}},[t,o,n,i])};function we(e){return {title:i18n.i18n.t("common.symbol"),dataIndex:"symbol",fixed:"left",width:e?.width,onSort:e?.enableSort?(t,r)=>t.symbol.localeCompare(r.symbol):void 0,renderPlantText:(t,r)=>{let o=ue(r)?.join(","),n=o?.length?` (${o})`:"";return `${t.split("_")[1]}-PERP${n}`},render:(t,r)=>{let o=ne(r);return jsxRuntime.jsxs(ui.Flex,{gap:2,children:[jsxRuntime.jsx("div",{className:ui.cn("oui-rounded-[1px] oui-w-1 oui-h-7 oui-shrink-0",r.side===types.OrderSide.BUY?"oui-bg-trade-profit":"oui-bg-trade-loss")}),jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text.formatted,{size:"xs",className:"oui-cursor-pointer oui-text-xs",onClick:n=>{e?.onSymbolChange?.({symbol:t}),n.stopPropagation(),n.preventDefault();},children:`${t.split("_")[1]}-PERP`}),e?.showType&&jsxRuntime.jsx(ui.Flex,{direction:"row",gap:1,children:ue(r)?.map((n,i)=>jsxRuntime.jsx(ui.Badge,{color:n.toLocaleLowerCase()==="position"?o?"neutral":"primary":"neutral",size:"xs",className:"oui-break-normal oui-whitespace-nowrap",children:n},i))})]})]})}}}function Me(e){return {title:i18n.i18n.t("orders.column.fill&Quantity"),dataIndex:"fill_quantity",className:e?.className,width:e?.width,onSort:e?.enableSort??false?(t,r)=>{let o=(t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:t.quantity)??0,n=(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:r.quantity)??0;return it(o,n)}:void 0,renderPlantText:(t,r)=>{if(r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED)return i18n.i18n.t("tpsl.entirePosition");let o=r.total_executed_quantity;return ("algo_type"in r&&r.algo_type===types.AlgoOrderRootType.TP_SL?"":`${o} / `)+`${r.quantity}`},render:(t,r)=>r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(Mt,{order:r,disableEdit:e?.disableEdit})}}function ia(e){return {title:i18n.i18n.t("common.quantity"),className:e?.className,dataIndex:"quantity",width:e?.width,onSort:e?.enableSort??false?(t,r)=>{let o=(t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:t.quantity)??0,n=(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:r.quantity)??0;return it(o,n)}:void 0,renderPlantText:(t,r)=>{if(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL)return i18n.i18n.t("tpsl.entirePosition");let o=r.total_executed_quantity;return ("algo_type"in r&&r.algo_type===types.AlgoOrderRootType.TP_SL?"":`${o}/`)+`${r.quantity}`},render:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(Mt,{order:r})}}function We(e){return {title:e?.title??i18n.i18n.t("common.price"),dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort??false?(t,r,o)=>it(t.price??0,r.price??0):void 0,renderPlantText:(t,r)=>utils.commifyOptional(r.price?.toString(),{fallback:i18n.i18n.t("common.marketPrice")}),render:(t,r)=>jsxRuntime.jsx(Yr,{order:r,disableEdit:e?.disableEdit})}}function aa(e){return {title:e?.title??i18n.i18n.t("common.price"),dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let{tpTriggerPrice:o,slTriggerPrice:n}=fo(r),i=`${o||""}${n?`${o?`
17
- `:""}${n}`:""}`;return i.length>0?i:"--"},render:(t,r)=>jsxRuntime.jsx(po,{})}}function sa(e){return {title:i18n.i18n.t("common.avgPrice"),dataIndex:"average_executed_price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>utils.commifyOptional(t)}}function tt(e){return {title:i18n.i18n.t("common.trigger"),className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=r?.algo_order_id!==void 0,n=r?.algo_type==="BRACKET";return !o||n?"--":utils.commifyOptional(t)},render:(t,r)=>jsxRuntime.jsx(eo,{order:r,disableEdit:e?.disableEdit})}}function yo(e){return {title:e?.title??i18n.i18n.t("common.trigger"),className:e?.className,dataIndex:"tpsl_trigger_price",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=e?.symbolsInfo?.[r.symbol],n=o?.("quote_dp"),{sl_trigger_price:i,tp_trigger_price:a}=!("algo_type"in r)||!Array.isArray(r.child_orders)?{}:hooks.utils.findTPSLFromOrder(r),s=(a!=null?`${i18n.i18n.t("tpsl.tp")}: ${utils.commifyOptional(a,{fix:n,padEnd:true})}`:"")+(i!=null?`${a?`
18
- `:""}${i18n.i18n.t("tpsl.sl")}: ${utils.commifyOptional(i,{fix:n,padEnd:true})}`:"");return s.length>0?s:"--"},render:(t,r)=>jsxRuntime.jsx(io,{})}}function la(e){return {title:i18n.i18n.t("common.tpsl"),className:e?.className,dataIndex:"bracketOrderPrice",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=()=>!("algo_type"in r)||!Array.isArray(r.child_orders)?{}:hooks.utils.findTPSLFromOrder(r.child_orders[0]),{sl_trigger_price:n,tp_trigger_price:i}=o(),a=(i!=null?`${i18n.i18n.t("tpsl.tp")}: ${i}`:"")+(n!=null?`${i?`
19
- `:""}${i18n.i18n.t("tpsl.sl")}: ${n}`:"");return a.length>0?a:"--"},render:(t,r)=>jsxRuntime.jsx(uo,{order:r})}}function ze(e){return {title:i18n.i18n.t("common.notional"),dataIndex:"executed",width:e?.width,className:e?.className,onSort:e?.enableSort??false?(t,r,o)=>{let n=t.type===types.OrderType.CLOSE_POSITION&&t.status!==types.OrderStatus.FILLED||t.total_executed_quantity===0||Number.isNaN(t.average_executed_price)||t.average_executed_price===null?0:t.total_executed_quantity*t.average_executed_price,i=r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED||r.total_executed_quantity===0||Number.isNaN(r.average_executed_price)||r.average_executed_price===null?0:r.total_executed_quantity*r.average_executed_price;return it(n,i)}:void 0,renderPlantText:(t,r)=>Vt(r,e?.isPending??false)==="Entire position"?i18n.i18n.t("tpsl.entirePosition"):utils.commifyOptional(Vt(r,e?.isPending??false),{fix:2}),render:(t,r)=>{let o=Vt(r,e?.isPending??false);return o==="Entire position"?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(ui.Text.numeral,{rm:utils.Decimal.ROUND_DOWN,dp:2,children:o})}}}function Ht(e){return {title:i18n.i18n.t("common.realizedPnl"),dataIndex:"realized_pnl",width:e?.width,className:e?.className,renderPlantText:(t,r)=>{let o=e?.symbolsInfo?.[r.symbol],n=o?.("quote_dp"),i=e?.pnlNotionalDecimalPrecision??n,a=new utils.Decimal(t??0).toDecimalPlaces(i,utils.Decimal.ROUND_DOWN).toNumber(),s=utils.commifyOptional(a);return a>0?`+${s}`:s},render:(t,r)=>{let{quote_dp:o}=z(),n=e?.pnlNotionalDecimalPrecision??o,i=new utils.Decimal(t??0).toDecimalPlaces(n,utils.Decimal.ROUND_DOWN).toNumber();return jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text.numeral,{dp:n,rm:utils.Decimal.ROUND_DOWN,padding:false,intensity:(i??0)==0?80:void 0,showIdentifier:(i??0)>0,coloring:(i??0)!=0,children:i??"--"}),!e?.hideShare&&jsxRuntime.jsx(et,{order:r,sharePnLConfig:e?.sharePnLConfig,modalId:uiShare.SharePnLDialogId})]})}}}function Ie(e){return {title:i18n.i18n.t("orderEntry.reduceOnly"),dataIndex:"reduce_only",width:e?.width,className:e?.className,renderPlantText:(t,r)=>t?i18n.i18n.t("common.yes"):i18n.i18n.t("common.no"),render:t=>jsxRuntime.jsx(ui.Text,{children:t?i18n.i18n.t("common.yes"):i18n.i18n.t("common.no")})}}function $e(e){return {title:i18n.i18n.t("orders.column.hidden"),dataIndex:"visible",width:e?.width,className:e?.className,renderPlantText:(t,r)=>t!==0?i18n.i18n.t("common.no"):i18n.i18n.t("common.yes"),render:(t,r)=>jsxRuntime.jsx(ui.Text,{children:r.visible_quantity!==0?i18n.i18n.t("common.no"):i18n.i18n.t("common.yes")})}}function Ue(e){return {title:i18n.i18n.t("orders.column.orderTime"),dataIndex:"created_time",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(t,r)=>{let o=new Date(t);return dateFns.format(o,"yyyy-MM-dd HH:mm:ss")},render:t=>jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:e?.formatString||"yyyy-MM-dd HH:mm:ss",className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function rt(e){return {title:i18n.i18n.t("common.fee"),dataIndex:"total_fee",width:e?.width,onSort:e?.enableSort,className:e?.className}}function da(e){return {title:i18n.i18n.t("common.notional"),dataIndex:"executed",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):utils.commifyOptional(r.quantity===0?"--":`${new utils.Decimal(r.mark_price).mul(r.quantity).todp(2).toNumber()}`),render:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(ui.Text.numeral,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:r.quantity===0?"--":`${new utils.Decimal(r.mark_price).mul(r.quantity).todp(2).toNumber()}`})}}function ot(e){let t={[types.OrderStatus.NEW]:i18n.i18n.t("orders.status.pending"),[types.OrderStatus.FILLED]:i18n.i18n.t("orders.status.filled"),[types.OrderStatus.PARTIAL_FILLED]:i18n.i18n.t("orders.status.partialFilled"),[types.OrderStatus.CANCELLED]:i18n.i18n.t("orders.status.canceled"),[types.OrderStatus.REJECTED]:i18n.i18n.t("orders.status.rejected"),[types.OrderStatus.INCOMPLETE]:i18n.i18n.t("orders.status.incomplete"),[types.OrderStatus.COMPLETED]:i18n.i18n.t("orders.status.completed")};return {title:i18n.i18n.t("common.status"),dataIndex:"status",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(r,o)=>{let n=r||o.algo_status;return t[n]||Le(n)},render:(r,o)=>{let n=r||o.algo_status;return t[n]||Le(n)}}}function bt(e){return {title:i18n.i18n.t("common.avgPrice"),dataIndex:"average_executed_price",width:e?.width,onSort:e?.enableSort??false?(t,r)=>it(t.average_executed_price??0,r.average_executed_price??0):void 0,className:e?.className,render:(t,r)=>r.type===types.OrderType.MARKET&&!t?"--":jsxRuntime.jsx(ui.Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t}),renderPlantText:(t,r)=>utils.commifyOptional(t,{fix:2})}}function bo(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>r.status===types.OrderStatus.CANCELLED?jsxRuntime.jsx(to,{record:r}):r.status===types.OrderStatus.NEW||r.algo_status===types.OrderStatus.NEW?jsxRuntime.jsx(gt,{order:r}):null}}function ua(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxRuntime.jsx(gt,{order:r})}}function ca(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxRuntime.jsxs(ui.Flex,{gap:3,children:[jsxRuntime.jsx(co,{order:r}),jsxRuntime.jsx(gt,{order:r})]})}}function it(e,t){return e>t?1:e<t?-1:0}function Vt(e,t){return t?e.price&&e.quantity?new utils.Decimal(e.price).mul(e.quantity).toFixed(2,utils.Decimal.ROUND_DOWN):"--":e.type===types.OrderType.CLOSE_POSITION&&e.status!==types.OrderStatus.FILLED?i18n.i18n.t("tpsl.entirePosition"):e.total_executed_quantity===0||Number.isNaN(e.average_executed_price)||e.average_executed_price===null?"--":`${e.total_executed_quantity*e.average_executed_price}`}var ho=e=>{let{item:t}=e,r=t.side===types.OrderSide.BUY,{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Text.formatted,{intensity:80,rule:"symbol",formatString:"base-type",size:"sm",prefix:jsxRuntime.jsx(ui.Badge,{color:r?"success":"danger",size:"xs",children:o(r?"common.buy":"common.sell")}),onClick:()=>{e.onSymbolChange?.({symbol:t.symbol});},children:t.symbol})},Co=e=>{let {item:t}=e;react.useCallback(()=>{let o=typeof t.type=="string"?t.type.replace("_ORDER","").toLowerCase():t.type;return t.algo_order_id&&t.algo_type!==types.AlgoOrderRootType.BRACKET?`Stop ${o}`:Le(t.type)},[t]);return jsxRuntime.jsx(ui.Flex,{direction:"row",gap:1,children:ue(e.item)?.map((o,n)=>jsxRuntime.jsx(ui.Badge,{color:o.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:o},n))})},To=e=>{let{item:t}=e;return jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:"yyyy-MM-dd hh:mm:ss",intensity:36,size:"2xs",children:t.updated_time})},Lo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t.status||t.algo_status,n=react.useMemo(()=>({[types.OrderStatus.NEW]:r("orders.status.pending"),[types.OrderStatus.FILLED]:r("orders.status.filled"),[types.OrderStatus.PARTIAL_FILLED]:r("orders.status.partialFilled"),[types.OrderStatus.CANCELLED]:r("orders.status.canceled"),[types.OrderStatus.REJECTED]:r("orders.status.rejected"),[types.OrderStatus.INCOMPLETE]:r("orders.status.incomplete"),[types.OrderStatus.COMPLETED]:r("orders.status.completed")}),[r]);return jsxRuntime.jsx(ui.Text.formatted,{intensity:80,size:"2xs",children:n[o]||Le(o)})},Gt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t.type===types.OrderType.CLOSE_POSITION&&t?.status!==types.OrderStatus.FILLED;return jsxRuntime.jsx(ui.Statistic,{label:r("common.qty"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.base_dp,padding:false,coloring:true,placeholder:r("tpsl.entirePosition"),intensity:80,children:o?r("tpsl.entirePosition"):t.quantity})})},Jt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsx(ui.Text,{children:r("orders.status.filled")}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.base_dp,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:t.total_executed_quantity})})};var No=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=react.useMemo(()=>t.price&&t.quantity?new utils.Decimal(t.price).mul(t.quantity).toFixed(e.quote_dp,utils.Decimal.ROUND_DOWN):"--",[t.price,t.quantity]);return jsxRuntime.jsx(ui.Statistic,{align:"end",label:jsxRuntime.jsxs(ui.Text,{children:[r("common.notional"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,coloring:true,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:o})})},Xt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:r("orders.column.triggerPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:e.align,children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:t.trigger_price??"--"})})},wo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:r("common.markPrice"),align:"end",classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.mark_price})})},Io=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t?.algo_order_id!==void 0,n=t?.type==="MARKET"&&o;return jsxRuntime.jsx(ui.Statistic,{label:r("common.limitPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:n?jsxRuntime.jsx(ui.Text,{children:r("common.marketPrice")}):jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.price??"--"})})},Eo=e=>{let{tp_trigger_price:t,tpPnL:r}=G(),{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:o("tpsl.tpTrigger"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(xt,{content:r&&jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",showIdentifier:true,prefix:jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${o("tpsl.tpPnl")}:`,"\xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:"\xA0USDC"}),coloring:true,children:r}),classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,color:"buy",padding:false,className:t?"oui-border-b oui-border-dashed oui-border-base-contrast-12":void 0,children:t??"--"})})})},vo=e=>{let{sl_trigger_price:t,slPnL:r}=G(),{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:o("tpsl.slTrigger"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(xt,{content:r&&jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",prefix:jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${o("tpsl.slPnl")}:`,"\xA0\xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:"\xA0USDC"}),coloring:true,children:r}),classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,color:"sell",padding:false,className:t?"oui-border-b oui-border-dashed oui-border-base-contrast-12":void 0,children:t??"--"})})})},Ao=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:t("tpsl.tpPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text,{intensity:80,children:t("common.marketPrice")})})},Do=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:t("tpsl.slPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text,{intensity:80,children:t("common.marketPrice")})})},Fo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=react.useMemo(()=>t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?jsxRuntime.jsx("span",{className:"oui-text-base-contrast-80",children:r("tpsl.entirePosition")}):jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.quantity}),[t,r]);return jsxRuntime.jsx(ui.Statistic,{label:r("common.quantity"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:"end",children:o})},ko=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[t("common.avgPrice"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:e.item?.average_executed_price??"--"})})},qo=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[t("orders.column.orderPrice"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,placeholder:t("common.marketPrice"),children:e.item?.price??"--"})})},Ro=e=>{let t=e?.item?.realized_pnl,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[r("common.realizedPnl"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:"end",children:jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,padding:false,intensity:(t??0)==0?80:void 0,showIdentifier:(t??0)>0,coloring:(t??0)!=0,children:t??"--"}),jsxRuntime.jsx(et,{order:e.item,sharePnLConfig:e.sharePnLConfig,modalId:uiShare.SharePnLBottomSheetId,iconSize:12})]})})},xt=e=>{let{classNames:t,content:r}=e,[o,n]=react.useState(false);return typeof r>"u"?e.children:jsxRuntime.jsx(ui.Tooltip,{content:r,className:t?.content,open:o,onOpenChange:n,arrow:{className:t?.arrow},children:jsxRuntime.jsx("div",{onClick:()=>n(i=>!i),children:e.children})})};var Zt=e=>{let {t}=i18n.useTranslation(),{item:r}=e;r.quantity>0;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(ui.Button,{variant:"outlined",fullWidth:true,color:"secondary",size:"sm",className:"oui-border-base-contrast-36",onClick:()=>{e.onShowEditSheet();},children:t("common.edit")})})};var Wo=e=>{let{side:t}=e.item,{price:r,quantity:o,triggerPrice:n,isAlgoOrder:i}=e,a=t===types.OrderSide.BUY,{t:s}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-pt-2",children:[jsxRuntime.jsx(ui.Text,{intensity:80,children:`You agree to edit your ${e.base}-PERP order.`}),jsxRuntime.jsxs(ui.Flex,{gap:2,mb:3,mt:2,justify:"between",children:[jsxRuntime.jsx(ui.Text.formatted,{rule:"symbol",formatString:"base-type",size:"base",showIcon:true,children:e.item.symbol}),jsxRuntime.jsxs(ui.Flex,{direction:"row",gap:1,children:[ue(e.item)?.map((d,u)=>jsxRuntime.jsx(ui.Badge,{color:d.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:d},u)),a&&jsxRuntime.jsx(ui.Badge,{color:"success",size:"xs",children:s("common.buy")}),!a&&jsxRuntime.jsx(ui.Badge,{color:"danger",size:"xs",children:s("common.sell")})]})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,width:"100%",className:"oui-text-sm oui-text-base-contrast-54",py:3,children:[i&&jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("orders.column.triggerPrice")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:80,dp:e.quote_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,suffix:jsxRuntime.jsx(ui.Text,{intensity:54,children:" USDC"}),children:n??"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("common.price")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:80,dp:e.quote_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,suffix:jsxRuntime.jsx(ui.Text,{intensity:54,children:" USDC"}),placeholder:e.isStopMarket?s("common.marketPrice"):"--",children:e.isStopMarket?s("common.marketPrice"):r??"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("common.qty")}),jsxRuntime.jsx(ui.Text.numeral,{color:t===types.OrderSide.BUY?"buy":"sell",dp:e.base_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,children:o??"--"})]})]}),jsxRuntime.jsxs(ui.Flex,{className:"oui-gap-[2px]",children:[jsxRuntime.jsx(ui.Checkbox,{color:"white",id:"oui-checkbox-disableOrderConfirmation",checked:!e.orderConfirm,onCheckedChange:d=>{e.setOrderConfirm(!d);}}),jsxRuntime.jsx("label",{className:"oui-text-2xs oui-text-base-contrast-54",htmlFor:"oui-checkbox-disableOrderConfirmation",children:s("orderEntry.disableOrderConfirm")})]})]})};var nr=e=>{let{item:t}=e,r=t.side===types.OrderSide.BUY,{t:o}=i18n.useTranslation(),{parseErrorMsg:n}=reactApp.useOrderEntryFormErrorMsg(e.errors),i=n("order_quantity"),a=n("order_price"),s=n("trigger_price"),d=e.quantity&&e.maxQty?Math.min(Number(e.quantity)/e.maxQty,1):void 0,u=l=>{let f=e.baseTick;if(f&&f>0){let x=hooks.utils.formatNumber(l,f)??l;e.setQuantity(x);}};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:3,width:"100%",itemAlign:"start",className:"oui-text-sm",children:[jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text.formatted,{rule:"symbol",showIcon:true,intensity:80,children:t.symbol}),jsxRuntime.jsxs(ui.Flex,{direction:"row",gap:1,children:[ue(e.item)?.map((l,f)=>jsxRuntime.jsx(ui.Badge,{color:l.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:l},f)),r&&jsxRuntime.jsx(ui.Badge,{color:"success",size:"xs",children:o("common.buy")}),!r&&jsxRuntime.jsx(ui.Badge,{color:"danger",size:"xs",children:o("common.sell")})]})]}),jsxRuntime.jsx(ui.Divider,{intensity:8,className:"oui-w-full"}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text,{children:o("common.lastPrice")}),jsxRuntime.jsx(ui.Text.numeral,{dp:e.item?.symbolInfo?.duote_dp,children:e.curMarkPrice??"--"})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",direction:"column",itemAlign:"stretch",gap:2,children:[e.isAlgoOrder&&jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("orders.column.triggerPrice")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.quote}),color:s?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.quote_dp)],value:e.triggerPrice,onValueChange:l=>e.setTriggerPrice(l),tooltip:s,tooltipProps:{content:{className:"oui-bg-base-6 oui-text-base-contrast-80"},arrow:{className:"oui-fill-base-6"}},classNames:{input:"oui-text-base-contrast oui-w-full",root:ui.cn("oui-outline-line-12",s&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("common.price")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.quote}),color:a?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.quote_dp)],disabled:!e.priceEdit,value:e.isStopMarket?o("orderEntry.orderType.market"):e.price,onValueChange:l=>e.setPrice(l),tooltip:a,tooltipProps:{content:{className:"oui-bg-base-5"},arrow:{className:"oui-fill-base-5"}},classNames:{input:"oui-text-base-contrast",root:ui.cn("oui-outline-line-12",a&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("common.quantity")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.base}),color:i?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.base_dp)],value:e.quantity,onValueChange:l=>{e.setQuantity(l);},onBlur:l=>u(l.target.value),tooltip:i,tooltipProps:{content:{className:"oui-bg-base-6"},arrow:{className:"oui-fill-base-6"}},classNames:{input:"oui-text-base-contrast",root:ui.cn("oui-outline-line-12",i&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Slider,{markCount:4,value:[e.sliderValue??0],onValueChange:l=>{e.setSliderValue(l[0]);},color:"primary"}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text.numeral,{color:"primary",size:"2xs",dp:2,padding:false,rule:"percentages",children:`${d??0}`}),jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text,{size:"2xs",color:"primary",children:o("common.max")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:54,size:"2xs",dp:e.base_dp,children:e.maxQty})]})]})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",gap:3,mt:2,children:[jsxRuntime.jsx(ui.Button,{fullWidth:true,color:"secondary",onClick:l=>{e.onClose();},children:o("common.cancel")}),jsxRuntime.jsx(ui.ThrottledButton,{fullWidth:true,onClick:l=>{l.stopPropagation(),l.preventDefault(),e.onSheetConfirm();},loading:e.submitting,disabled:!e.isChanged,children:o("common.confirm")})]})]}),jsxRuntime.jsx(ui.SimpleDialog,{open:e.dialogOpen,onOpenChange:e.setDialogOpen,title:o("orders.editOrder"),size:"xs",actions:{primary:{label:o("common.confirm"),onClick:e.onDialogConfirm,loading:e.submitting,fullWidth:true},secondary:{label:o("common.cancel"),onClick:e.onCloseDialog,fullWidth:true}},classNames:{content:"oui-pb-4",body:"oui-p-0",footer:"oui-pt-3 oui-pb-0"},children:jsxRuntime.jsx(Wo,{...e})})]})};var lr=e=>{let {state:t,editAlgoOrder:r,editOrder:o,autoCheckInput:n=true,position:i}=e,{item:a}=t,{hide:s}=ui.useModal(),[d,u]=react.useState(false),l=a?.algo_order_id!==void 0&&a.algo_type!==types.AlgoOrderRootType.BRACKET,f=a?.type==="MARKET"&&l;f||a?.type==="MARKET";let [C,h]=react.useState(false),p=react.useMemo(()=>l&&a.algo_type!==types.AlgoOrderRootType.BRACKET?`STOP_${a.type}`:a.type,[a,l]),[P,N]=hooks.useLocalStorage("orderly_order_confirm",true),{base_dp:T,base_tick:q}=e.state,{formattedOrder:g,setValue:E,markPrice:R,errors:O,validate:L,maxQty:F}=Wa({order:a,orderType:p,position:i}),X=()=>{L().then(b=>{P?u(true):D(g);},b=>{b?.total?.message&&ui.toast.error(b?.total.message);}).catch(b=>{});},v=react.useCallback(()=>{u(false);},[]),Y=()=>g?D(g):Promise.reject(),A=react.useCallback(()=>{s();},[]),D=react.useCallback(async b=>{let B,Ce=a.visible_quantity!==void 0?a.visible_quantity===0:a.visible!==void 0?a.visible===0:false;if(a.algo_order_id!==void 0){if(f&&"order_price"in b){let{order_price:Te,...Lt}=b;b=Lt;}B=r(a.algo_order_id.toString(),{...b});}else B=o(a.order_id.toString(),{...b,...Ce?{visible_quantity:0}:{}});try{h(!0);let Te=await B;A();}catch(Te){ui.toast.error(Te?.message??`${Te}`);}finally{h(false);}},[r,o]),re=react.useMemo(()=>{let b=g.order_quantity;return b&&Number(b)!==0&&F!==0?new utils.Decimal(b).div(F).mul(100).toDecimalPlaces(2,utils.Decimal.ROUND_DOWN).toNumber():0},[g.order_quantity,F]),de=a.price!=g.order_price||a.quantity!=g.order_quantity||a.trigger_price!=g.trigger_price,Ge=hooks.useThrottledCallback(b=>{let B=new utils.Decimal(b).div(100).mul(F).toDecimalPlaces(T,utils.Decimal.ROUND_DOWN).toNumber();E("order_quantity",hooks.utils.formatNumber(B,q));},50,{}),y=(b,B)=>{E(b,B);};return {...t,curMarkPrice:R,isAlgoOrder:l,isStopMarket:f,price:g.order_price,setPrice:b=>y("order_price",b),priceEdit:!f,triggerPrice:g.trigger_price,setTriggerPrice:b=>y("trigger_price",b),quantity:g.order_quantity,setQuantity:b=>{y("order_quantity",b);},maxQty:F,sliderValue:re,setSliderValue:Ge,onClose:A,onSheetConfirm:X,errors:O,orderType:p,isChanged:de,baseTick:q,dialogOpen:d,setDialogOpen:u,onDialogConfirm:Y,onCloseDialog:v,submitting:C,orderConfirm:P,setOrderConfirm:N}},Wa=e=>{let{order:t,orderType:r,position:o}=e,[n,i]=react.useState({side:t.side,order_type:r,order_price:t.price,order_quantity:t.quantity,trigger_price:t.trigger_price,reduce_only:t.reduce_only,symbol:t.symbol}),{reduce_only:a}=t,s=o?.position_qty,d=hooks.useMaxQty(t.symbol,t.side,t.reduce_only),u=react.useMemo(()=>a?Math.abs(s??0):t.quantity+Math.abs(d),[t.quantity,d,a,s]),{symbolInfo:l,markPrice:f,errors:x,validate:C}=hooks.useOrderEntity({...n,symbol:t.symbol},{maxQty:u});return {symbolInfo:l,markPrice:f,errors:x,validate:C,setValue:(p,P)=>{i(N=>({...N,[p]:P}));},formattedOrder:n,maxQty:u}};var dr=e=>{let t=lr(e);return jsxRuntime.jsx(nr,{...t})};var ur=e=>{let{state:t}=e,{t:r}=i18n.useTranslation(),{editAlgoOrder:o,editOrder:n}=Z(),{order:i,position:a}=G(),s=react.useCallback(()=>{e.state.type==="tp_sl"?ui.modal.sheet({title:r("common.tpsl"),content:jsxRuntime.jsx(uiTpsl.PositionTPSLSheet,{isEditing:true,order:e.state.item,position:a,symbolInfo:e.state.origin})}).catch(d=>{}):ui.modal.sheet({title:r("orders.editOrder"),classNames:{content:"oui-bg-base-8"},content:jsxRuntime.jsx(dr,{position:a,state:t,editAlgoOrder:o,editOrder:n})}).catch(d=>{});},[t]);return {...t,onShowEditSheet:s}};var cr=e=>{let t=ur(e);return jsxRuntime.jsx(Zt,{...t})};var pr=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Button,{variant:"outlined",fullWidth:true,color:"secondary",size:"sm",className:"oui-border-base-contrast-36",onClick:r=>e.setOpen(true),children:t("common.cancel")}),e.open&&jsxRuntime.jsx(ui.SimpleDialog,{size:"xs",open:e.open,onOpenChange:e.setOpen,title:t("orders.cancelOrder"),actions:{primary:{label:t("common.confirm"),loading:e.isLoading,fullWidth:true,size:"md",onClick:r=>{e.onCancel(r);}},secondary:{label:t("common.cancel"),fullWidth:true,size:"md",onClick:()=>{e.onClose();}}},children:jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:54,children:t("orders.cancelOrder.description")})})]})};var fr=e=>{let{state:t}=e,[r,o]=react.useState(false),{onCancelOrder:n}=Z(),[i,a]=react.useState(false);return {...t,open:r,setOpen:o,onCancel:u=>n?(u?.preventDefault(),u?.stopPropagation(),a(true),n(t.item).then(l=>{o(false);},l=>{ui.toast.error(l.message);}).finally(()=>{a(false);})):Promise.resolve(),onClose:()=>{o(false);},isLoading:i}};var gr=e=>{let t=fr(e);return jsxRuntime.jsx(pr,{...t})};var br=e=>{let{t}=i18n.useTranslation();return !e.sl_trigger_price&&!e.tp_trigger_price?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(xt,{classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},content:jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",gap:1,children:[typeof e.pnl?.tpPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${t("tpsl.tpPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:e.quote_dp,color:"buy",showIdentifier:true,children:e.pnl?.tpPnL}),typeof e.pnl?.slPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${t("tpsl.slPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:e.quote_dp,color:"sell",children:e.pnl?.slPnL})]}),children:jsxRuntime.jsx("button",{onClick:()=>{e.setOpen(!e.open);},children:jsxRuntime.jsxs(ui.Flex,{gap:1,width:"1",children:[e.tp_trigger_price&&jsxRuntime.jsx(Vo,{type:"TP",value:e.tp_trigger_price,quote_dp:e.quote_dp}),e.sl_trigger_price&&jsxRuntime.jsx(Vo,{type:"SL",value:e.sl_trigger_price,quote_dp:e.quote_dp})]})})})})},Vo=e=>{let{type:t,value:r,quote_dp:o}=e;return r?jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",className:ui.cn("oui-border-b oui-border-dashed oui-border-base-contrast-12",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),rule:"price",dp:o,padding:false,rm:utils.Decimal.ROUND_DOWN,prefix:jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-36",children:[`${t} `,":\xA0\xA0"]}),children:r},"tp"):jsxRuntime.jsx(jsxRuntime.Fragment,{})};var Pr=e=>{let{item:t,quote_dp:r,base_dp:o}=e,[n,i]=react.useState(false),{sl_trigger_price:a,tp_trigger_price:s}=react.useMemo(()=>!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(t.child_orders[0]),[t]),{pnl:d,roi:u}=ct(t);return {sl_trigger_price:a,tp_trigger_price:s,pnl:d,roi:u,quote_dp:r,open:n,setOpen:i}};var xr=e=>{let t=Pr(e);return jsxRuntime.jsx(br,{...t})};var Sr=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",gap:2,itemAlign:"start",className:e.className,children:[jsxRuntime.jsx(ls,{...e}),jsxRuntime.jsx(ui.Divider,{intensity:6,className:"oui-w-full"}),jsxRuntime.jsx(ds,{...e}),e.type==="pending"&&jsxRuntime.jsx(xr,{...e}),e.type!=="orderHistory"&&jsxRuntime.jsx(us,{...e})]}),ls=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,width:"100%",children:[jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",children:[jsxRuntime.jsx(ho,{...e}),jsxRuntime.jsx(To,{...e})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(Co,{...e}),e.type==="orderHistory"&&jsxRuntime.jsx(Lo,{...e})]})]}),ds=e=>jsxRuntime.jsx(ui.Grid,{cols:3,rows:2,width:"100%",gap:1,children:cs(e)}),us=e=>jsxRuntime.jsxs(ui.Grid,{cols:3,rows:1,width:"100%",gap:2,children:[jsxRuntime.jsx("div",{}),jsxRuntime.jsx(cr,{state:e}),jsxRuntime.jsx(gr,{state:e})]});function cs(e){switch(e.type){case "all":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "pending":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{...e}),jsxRuntime.jsx(Jt,{...e}),jsxRuntime.jsx(No,{...e}),jsxRuntime.jsx(Xt,{...e}),jsxRuntime.jsx(Io,{...e}),jsxRuntime.jsx(wo,{...e})]});case "tp_sl":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Eo,{...e}),jsxRuntime.jsx(Ao,{...e}),jsxRuntime.jsx(Fo,{...e}),jsxRuntime.jsx(vo,{...e}),jsxRuntime.jsx(Do,{...e})]});case "filled":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "cancelled":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "rejected":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "orderHistory":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{...e}),jsxRuntime.jsx(Jt,{...e}),jsxRuntime.jsx(Xt,{...e,align:"end"}),jsxRuntime.jsx(ko,{...e}),jsxRuntime.jsx(qo,{...e}),jsxRuntime.jsx(Ro,{...e})]})}}var _r=e=>{let t=z();return {...e,...t}};var Or=e=>{let{className:t,...r}=e,o=_r(r);return jsxRuntime.jsx(Sr,{...o,className:t})};var hr=e=>{let{sharePnLConfig:t,...r}=e,o=xo({_type:e.type,onSymbolChange:e.onSymbolChange,pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:t,symbolsInfo:e.symbolsInfo});return jsxRuntime.jsx(Dt,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",height:"100%",itemAlign:"start",children:[e.filterItems.length>0&&jsxRuntime.jsx(ui.DataFilter,{items:e.filterItems,onFilter:n=>{e.onFilter(n);},trailing:["pending","tp_sl"].includes(e.type)&&jsxRuntime.jsx(_s,{...e})}),jsxRuntime.jsx(uiConnector.AuthGuardDataTable,{columns:o,loading:e.isLoading,dataSource:e.dataSource,bordered:true,ignoreLoadingCheck:true,testIds:{body:e.testIds?.tableBody},classNames:{header:"oui-h-[38px]",root:"oui-items-start !oui-h-[calc(100%_-_49px)]"},onRow:(n,i)=>({className:ui.cn("oui-h-[48px]",ne(n)?"oui-text-base-contrast-20":"oui-text-base-contrast-80")}),generatedRowKey:(n,i)=>`${e.type}${i}${n.order_id||n.algo_order_id}_index${i}`,renderRowContainer:(n,i,a)=>((e.type==="tp_sl"||e.type==="pending")&&(a=jsxRuntime.jsx(qt,{order:n,children:a})),jsxRuntime.jsx(Ft,{symbol:n.symbol,children:a})),pagination:e.pagination,manualPagination:e.manualPagination,features:[ui.TableFeatures.DownloadFeature],getTableInstance:n=>{e.tableInstance.current=n;}})]})})},Cr=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(Dt,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsxRuntime.jsxs(ui.Grid,{cols:1,rows:2,className:"oui-w-full oui-grid-rows-[auto,1fr]",gap:2,children:[e.showFilter?jsxRuntime.jsx(ui.Flex,{gap:2,p:2,className:"oui-rounded-b-xl oui-bg-base-9",children:e.filterItems.map(r=>r.type!=="select"?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(ui.Picker,{options:r.options,size:"sm",value:r.value,className:"oui-text-2xs oui-text-base-contrast-54 ",placeholder:r.name==="side"?t("common.side.all"):r.name==="status"?t("common.status.all"):"",onValueChange:o=>{e.onFilter?.({name:r.name,value:o});}},r.name))}):jsxRuntime.jsx("div",{}),jsxRuntime.jsx(ui.ListView,{className:e.classNames?.root,contentClassName:e.classNames?.content,dataSource:e.dataSource,loadMore:e.loadMore,isLoading:e.isLoading,renderItem:(r,o)=>{let n=jsxRuntime.jsx(Or,{item:r,index:o,className:e.classNames?.cell,type:e.type,onSymbolChange:e.onSymbolChange,sharePnLConfig:e.sharePnLConfig});return ["tp_sl","pending"].includes(e.type)&&(n=jsxRuntime.jsx(qt,{order:r,children:n})),jsxRuntime.jsx(Ft,{symbol:r.symbol,children:n})}})]})})},_s=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Button,{variant:"outlined",color:"secondary",size:"xs",disabled:(e.dataSource?.length??0)==0,className:"disabled:oui-bg-transport",onClick:r=>e.onCancelAll(),"data-testid":`oui-testid-dataList-${e.type.toLowerCase()}-cancelAll-button`,children:t("orders.cancelAll")})};var jo=e=>react.useMemo(()=>{let r=[];for(let o=0;o<e.length;o++){let n=e[o];if(n.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL||n.algo_type===types.AlgoOrderRootType.TP_SL)if(n.algo_status!==types.OrderStatus.FILLED&&n.algo_status!==types.OrderStatus.PARTIAL_FILLED)for(let i=0;i<n.child_orders.length;i++){let a=n.child_orders[i];!a.is_activated||!a.trigger_price||(a.parent_algo_type=n.algo_type,r.push(a));}else for(let i=0;i<n.child_orders.length;i++){let a=n.child_orders[i];a&&(a.algo_status===types.OrderStatus.FILLED||a.algo_status===types.OrderStatus.PARTIAL_FILLED)&&(a.parent_algo_type=n.algo_type,r.push(a));}else r.push(n);}return r},[e]);var Tt=e=>{let{ordersStatus:t,type:r,enableLoadMore:o=false,onSymbolChange:n,filterConfig:i,pnlNotionalDecimalPrecision:a,sharePnLConfig:s}=e,{t:d}=i18n.useTranslation(),u=hooks.useSymbolsInfo(),l=react.useMemo(()=>t!==types.OrderStatus.INCOMPLETE,[t]),f=50,{page:x,pageSize:C,setPage:h,pagination:p,parsePagination:P}=ui.usePagination({pageSize:f});react.useEffect(()=>{h(1);},[e.symbol]);let{orderStatus:N,ordersSide:T,dateRange:q,filterItems:g,onFilter:E,filterDays:W,updateFilterDays:R}=qs(r,{ordersStatus:t,setPage:h,filterConfig:i}),O=react.useMemo(()=>{if(r==="tp_sl")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),L=react.useMemo(()=>{if(r==="pending")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),F=react.useRef();react.useImperativeHandle(e.ref,()=>({download:()=>{let Nt=`orders_${dateFns.format(new Date,"yyyyMMdd_HHmmss")}`;F.current?.download(Nt);}}));let[X,{isLoading:v,loadMore:Y,cancelOrder:A,updateOrder:D,cancelAlgoOrder:re,updateAlgoOrder:de,cancelAllOrders:Ge,cancelAllTPSLOrders:y,meta:b,refresh:B}]=hooks.useOrderStream({symbol:e.symbol,status:N,side:T,page:o||!l?void 0:x,size:l?C:500,dateRange:q,includes:O,excludes:L}),Ce=`orderly_${r}_pageSize`,[Te,Lt]=hooks.useLocalStorage(Ce,f);react.useEffect(()=>{Te!==C&&Lt(C);},[C,Te]);let nn=react.useCallback(()=>{let Nt=e.type==="pending"?d("orders.pending.cancelAll"):e.type==="tp_sl"?d("orders.tpsl.cancelAll"):"",dn=d("orders.pending.cancelAll.description");ui.modal.confirm({title:Nt,content:jsxRuntime.jsx(ui.Text,{size:"sm",children:dn}),onCancel:async()=>{},onOk:async()=>{try{return r==="tp_sl"?await y():await Ge(),B(),Promise.resolve(!0)}catch(Lr){return Lr?.message!==void 0&&toast.error(Lr.message),Promise.resolve(false)}finally{Promise.resolve();}}});},[r,d]),an=jo(X??[]),sn=reactApp.useDataTap(r!=="tp_sl"?an:X,{fallbackData:[]})??void 0,ln=react.useMemo(()=>l?P(b):p,[b,l,P,p]);return {type:r,dataSource:sn,isLoading:v,loadMore:Y,cancelOrder:A,updateOrder:D,cancelAlgoOrder:re,updateAlgoOrder:de,pagination:ln,manualPagination:l,pnlNotionalDecimalPrecision:a,onFilter:E,filterItems:g,onCancelAll:nn,onSymbolChange:n,sharePnLConfig:s,tableInstance:F,symbolsInfo:u,filterDays:W,updateFilterDays:R}},qs=(e,t)=>{let{t:r}=i18n.useTranslation(),[o,n]=react.useState(t.ordersStatus??"all"),[i,a]=react.useState(t.filterConfig?.side??"all"),[s,d]=react.useState(90),u=t.filterConfig?.range??(e==="all"||e==="orderHistory"?Tr({to:new Date,from:Fe(dateFns.subDays(new Date,89))}):{}),[l,f]=react.useState(u),x=p=>{d(p),f({from:Ve(dateFns.subDays(new Date,p-1)),to:Fe(new Date)}),t.setPage(1);},C=p=>{if(p.name==="side"&&(a(p.value),t.setPage(1)),p.name==="status"&&(n(p.value),t.setPage(1)),p.name==="dateRange"){f(Tr(p.value)),t.setPage(1);let P=Tr(p.value);if(P.from&&P.to){let N=Math.abs(dateFns.differenceInDays(P.from,P.to))+1,q={1:{from:Ve(new Date),to:Fe(new Date)},7:{from:Ve(dateFns.subDays(new Date,6)),to:Fe(new Date)},30:{from:Ve(dateFns.subDays(new Date,29)),to:Fe(new Date)},90:{from:Ve(dateFns.subDays(new Date,89)),to:Fe(new Date)}}[N];q&&It(q.from,P.from)&&It(q.to,P.to)?d(N):d(null);}}};return {filterItems:react.useMemo(()=>{let p={type:"select",name:"side",options:[{label:r("common.side.all"),value:"all"},{label:r("common.buy"),value:"BUY"},{label:r("common.sell"),value:"SELL"}],value:i},P={type:"range",name:"dateRange",value:l},N={type:"select",name:"status",options:[{label:r("common.status.all"),value:"all"},{label:r("orders.status.pending"),value:types.OrderStatus.INCOMPLETE},{label:r("orders.status.filled"),value:types.OrderStatus.FILLED},{label:r("orders.status.partialFilled"),value:types.OrderStatus.PARTIAL_FILLED},{label:r("orders.status.canceled"),value:types.OrderStatus.CANCELLED},{label:r("orders.status.rejected"),value:types.OrderStatus.REJECTED}],value:o};switch(e){case "all":return [p,N,P];case "pending":return [p];case "tp_sl":return [p];case "filled":return [p];case "cancelled":return [p];case "rejected":return [p];case "orderHistory":return [p,N,P]}},[e,i,o,l,r]),onFilter:C,ordersSide:i==="all"?void 0:i,dateRange:l,orderStatus:o==="all"?void 0:o,filterDays:s,updateFilterDays:x}};function Ve(e){if(e==null)return e;let t=new Date(e);return t.setHours(0,0,0,0),t}function Fe(e){if(e==null)return e;let t=new Date(e);return t.setHours(23,59,59,999),t}var Tr=e=>({from:Ve(e.from),to:Fe(e.to??e.from)});var he=react.forwardRef((e,t)=>{let{testIds:r,...o}=e,n=Tt({...o,ref:t});return jsxRuntime.jsx(hr,{...n,testIds:r})}),Ms=e=>{let t=Tt({...e,enableLoadMore:true});return jsxRuntime.jsx(Cr,{...t,classNames:e.classNames,showFilter:e.showFilter})};var on=e=>{let{t}=i18n.useTranslation(),r={pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision};return jsxRuntime.jsxs(ui.Tabs,{defaultValue:e.current||"all",variant:"contained",className:"oui-h-full",classNames:{tabsContent:"oui-h-[calc(100%_-_28px)]"},children:[jsxRuntime.jsx(ui.TabPanel,{value:"all",title:t("common.all"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"all",pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:e.sharePnLConfig,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"pending",title:t("orders.status.pending"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"pending",ordersStatus:types.OrderStatus.INCOMPLETE,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"tp_sl",title:t("common.tpsl"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"tp_sl",ordersStatus:types.OrderStatus.INCOMPLETE,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"filled",title:t("orders.status.filled"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"filled",ordersStatus:types.OrderStatus.FILLED,pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:e.sharePnLConfig,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"cancelled",title:t("orders.status.canceled"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"cancelled",ordersStatus:types.OrderStatus.CANCELLED,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"rejected",title:t("orders.status.rejected"),children:jsxRuntime.jsx(he,{ref:e.orderListRef,type:"rejected",ordersStatus:types.OrderStatus.REJECTED,...r})})]})};var Pe=(s=>(s.all="all",s.pending="pending",s.tp_sl="tp_sl",s.filled="filled",s.cancelled="cancelled",s.rejected="rejected",s.orderHistory="orderHistory",s))(Pe||{}),Ks=react.forwardRef((e,t)=>{let r=wt({...e,ref:t});return jsxRuntime.jsx(on,{...r})});
16
+ var wt=e=>{let{current:t,pnlNotionalDecimalPrecision:r,sharePnLConfig:o}=e,n=react.useRef(null);return react.useImperativeHandle(e.ref,()=>({download:()=>{n.current?.download?.();}})),{current:t,pnlNotionalDecimalPrecision:r,orderListRef:n,sharePnLConfig:o}};var ue=e=>e===void 0||e.length===0?e:e.length===1?e.charAt(0).toUpperCase():e.charAt(0).toUpperCase()+e.toLowerCase().slice(1);function ce(e){let t=e.type,r=e.algo_type;if(typeof t<"u"){let o=[];if(e.parent_algo_type){if(r===types.AlgoOrderType.STOP_LOSS){let i=t===types.OrderType.CLOSE_POSITION?[i18n.i18n.t("common.position"),i18n.i18n.t("tpsl.sl")]:[i18n.i18n.t("tpsl.sl")];o.push(...i);}if(r===types.AlgoOrderType.TAKE_PROFIT){let i=t===types.OrderType.CLOSE_POSITION?[i18n.i18n.t("common.position"),i18n.i18n.t("tpsl.tp")]:[i18n.i18n.t("tpsl.tp")];o.push(...i);}return o}let n=typeof t=="string"?t.replace("_ORDER",""):"";if([types.OrderType.ASK,types.OrderType.BID].includes(t))return [i18n.i18n.t("orderEntry.orderType.limit")];if(e.algo_order_id===void 0||e.algo_order_id&&r==="BRACKET")return [{[types.OrderType.LIMIT]:i18n.i18n.t("orderEntry.orderType.limit"),[types.OrderType.MARKET]:i18n.i18n.t("orderEntry.orderType.market"),[types.OrderType.POST_ONLY]:i18n.i18n.t("orderEntry.orderType.postOnly"),[types.OrderType.IOC]:i18n.i18n.t("orderEntry.orderType.ioc"),[types.OrderType.FOK]:i18n.i18n.t("orderEntry.orderType.fok")}[n]||ue(n)];if(n)return [{[types.OrderType.LIMIT]:i18n.i18n.t("orderEntry.orderType.stopLimit"),[types.OrderType.MARKET]:i18n.i18n.t("orderEntry.orderType.stopMarket")}[n]||n]}if(typeof r<"u"){let o=[];r===types.AlgoOrderRootType.POSITIONAL_TP_SL&&o.push(i18n.i18n.t("common.position"));let n=e?.child_orders?.find(a=>a.algo_type===types.AlgoOrderType.TAKE_PROFIT&&!!a.trigger_price),i=e?.child_orders?.find(a=>a.algo_type===types.AlgoOrderType.STOP_LOSS&&!!a.trigger_price);return (n||i)&&o.push(n&&i?i18n.i18n.t("common.tpsl"):n?i18n.i18n.t("tpsl.tp"):i18n.i18n.t("tpsl.sl")),o}}function ne(e){return e.status===types.OrderStatus.CANCELLED||e.algo_status===types.OrderStatus.CANCELLED}function gn(e){if(e.algo_type!==types.AlgoOrderRootType.BRACKET)return {tpOrder:void 0,slOrder:void 0};let t=e.child_orders?.[0];if(!t)return {tpOrder:void 0,slOrder:void 0};let r=t?.child_orders?.find(n=>n.algo_type===types.AlgoOrderType.TAKE_PROFIT),o=t?.child_orders?.find(n=>n.algo_type===types.AlgoOrderType.STOP_LOSS);return {tpOrder:r,slOrder:o}}function ct(e){let t={pnl:{tpPnL:void 0,slPnL:void 0},roi:{tpRoi:void 0,slRoi:void 0}},{tpOrder:r,slOrder:o}=gn(e);if(!r&&!o||typeof e.price===void 0||!e.price)return t;let n=e.side===types.OrderSide.BUY?e.quantity:e.quantity*-1,i=r?.trigger_price&&hooks.utils.priceToPnl({qty:n,price:r?.trigger_price,entryPrice:e.price,orderSide:e.side,orderType:r.algo_type}),a=o?.trigger_price&&hooks.utils.priceToPnl({qty:n,price:o?.trigger_price,entryPrice:e.price,orderSide:e.side,orderType:o.algo_type}),s=i?hooks.utils.calcTPSL_ROI({pnl:i,qty:e.quantity,price:e.price}):void 0,d=a?hooks.utils.calcTPSL_ROI({pnl:a,qty:e.quantity,price:e.price}):void 0;return {pnl:{tpPnL:i,slPnL:a},roi:{tpRoi:s,slRoi:d}}}function It(e,t){return !e||!t?false:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}var vt=e=>{let{t}=i18n.useTranslation();return e.sharePnLConfig==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),ui.modal.show(e.modalId,{pnl:{entity:{symbol:e.order.symbol,pnl:e.order.realized_pnl,side:e.order.side=="BUY"?t("share.pnl.share.long"):t("share.pnl.share.short"),openPrice:e.order.average_executed_price,openTime:e.order.updated_time,quantity:e.order.quantity},refCode:e.refCode,leverage:e.leverage,...e.sharePnLConfig}});},children:jsxRuntime.jsx(ui.ShareIcon,{color:"white",opacity:.54,size:e.iconSize??16})})};var Ir=e=>{let{sharePnLConfig:t,order:r,modalId:o,iconSize:n}=e,{getFirstRefCode:i}=hooks.useReferralInfo(),a=react.useMemo(()=>i()?.code,[i]),s=hooks.useSymbolLeverage(e.order.symbol);return {iconSize:n,order:r,refCode:a,leverage:s,sharePnLConfig:t,modalId:o}};var Je=e=>{let t=Ir(e);return jsxRuntime.jsx(vt,{...t})};var Er=react.createContext({}),z=()=>react.useContext(Er),At=e=>{let t=hooks.useSymbolsInfo()[e.symbol];return jsxRuntime.jsx(Er.Provider,{value:{base_dp:t("base_dp"),quote_dp:t("quote_dp"),base_tick:t("base_tick"),quote_tick:t("quote_tick"),base:t("base"),quote:t("quote"),symbol:e.symbol,origin:t(),quote_max:t("quote_max"),quote_min:t("quote_min")},children:e.children})};var Fr=e=>{let{order:t}=e,{quote_dp:r,base_dp:o}=z(),{t:n}=i18n.useTranslation(),{sl_trigger_price:i,tp_trigger_price:a}=react.useMemo(()=>!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(e.order.child_orders[0]),[e.order]),{pnl:s,roi:d}=ct(t);return !a&&!i?"--":jsxRuntime.jsx(ui.Tooltip,{content:jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",gap:1,children:[typeof s.tpPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${n("tpsl.tpPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:r,color:"buy",showIdentifier:true,children:s.tpPnL}),typeof s.slPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${n("tpsl.slPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:r,color:"sell",children:s.slPnL})]}),className:"oui-bg-base-6",children:jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(Ar,{type:"TP",value:a,quote_dp:r}),jsxRuntime.jsx(Ar,{type:"SL",value:i,quote_dp:r})]})})},Ar=e=>{let{type:t,value:r,quote_dp:o}=e,{t:n}=i18n.useTranslation();return r?jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),rule:"price",dp:o,prefix:jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[t==="TP"?`${n("tpsl.tp")} -`:`${n("tpsl.sl")} -`,"\xA0"]}),children:r},"tp"):jsxRuntime.jsx(jsxRuntime.Fragment,{})};var qr=react.createContext({}),Z=()=>react.useContext(qr),Ft=e=>{let{cancelOrder:t,editOrder:r,cancelAlgoOrder:o,editAlgoOrder:n}=e,{t:i}=i18n.useTranslation(),a=hooks.useSymbolsInfo(),s=react.useCallback(async l=>l.algo_order_id!==void 0?"root_algo_order_id"in l&&l.root_algo_order_id!==l.algo_order_id?o(l.root_algo_order_id,l.symbol):o(l.algo_order_id,l.symbol).then(()=>{}):t(l.order_id,l.symbol).then(()=>{}),[]),d=react.useCallback(async(l,f)=>{l.visible_quantity!==void 0?l.visible_quantity===0:l.visible!==void 0?l.visible===0:false;await ui.modal.sheet({title:i("orders.editOrder"),classNames:{content:"oui-edit-order-sheet-content"},content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Content"})});},[i]),u=react.useCallback((l,f,x)=>{let{min_notional:C}=a[l](),h=hooks.getMinNotional({price:f,qty:x,min_notional:C});if(h!==void 0)return i("orderEntry.total.error.min",{value:h})},[a,i]);return jsxRuntime.jsx(qr.Provider,{value:{onCancelOrder:s,onEditOrder:d,editOrder:r,editAlgoOrder:n,checkMinNotional:u},children:e.children})};var mt=e=>{let{order:t}=e,{t:r}=i18n.useTranslation(),{onCancelOrder:o}=Z(),[n,i]=react.useState(false);return jsxRuntime.jsx(ui.ThrottledButton,{size:"sm",variant:"outlined",color:"secondary",onClick:a=>{o&&(a.preventDefault(),a.stopPropagation(),i(true),o(t).then(s=>s,s=>{ui.toast.error(s.message);}).finally(()=>{i(false);}));},loading:n,children:r("common.cancel")})};var qe=e=>{let{type:t,base:r,value:o,cancelPopover:n,isSubmitting:i,onConfirm:a}=e,{t:s}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-pt-5 oui-relative",children:[jsxRuntime.jsx("div",{className:"oui-text-base-contrast-54 oui-text-2xs desktop:oui-text-sm",children:(()=>{let u={values:{base:r,value:utils.commify(o)},components:[jsxRuntime.jsx("span",{className:"oui-text-warning-darken"})]};switch(t){case 0:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.quantity",...u});case 1:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.price",...u});case 2:return jsxRuntime.jsx(i18n.Trans,{i18nKey:"order.edit.confirm.triggerPrice",...u})}})()}),jsxRuntime.jsxs("div",{className:"oui-grid oui-grid-cols-2 oui-gap-2 oui-mt-5",children:[jsxRuntime.jsx(ui.Button,{color:"secondary",size:"md",onClick:n,disabled:i,children:s("common.cancel")}),jsxRuntime.jsx(ui.ThrottledButton,{size:"md",loading:i,onClick:a,children:s("common.confirm")})]}),jsxRuntime.jsx("button",{className:"oui-absolute oui-right-0 oui-top-0 oui-text-base-contrast-54",onClick:n,children:jsxRuntime.jsx(ui.CloseIcon,{size:16,color:"white",opacity:1})})]})};var Re=e=>{let{inputRef:t,dp:r,value:o,setValue:n,setEditing:i,error:a,handleKeyDown:s,onClick:d,onClose:u,onFocus:l,onBlur:f,hintInfo:x}=e;react.useEffect(()=>{let h=t.current;if(h){let p=h.value.length;h.setSelectionRange(p,p);}i(true);},[]);let C=(x?.length||0)>0;return jsxRuntime.jsx(ui.Tooltip,{content:x,open:C,children:jsxRuntime.jsx(ui.Input,{ref:t,type:"text",size:"sm",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(r),ui.inputFormatter.currencyFormatter],value:o,onValueChange:h=>n(h),helpText:a,onClick:h=>{h.stopPropagation(),h.preventDefault();},autoComplete:"off",onFocus:l,onBlur:f,onKeyDown:s,autoFocus:true,color:C?"danger":void 0,classNames:{root:"oui-bg-base-700 oui-px-2 oui-py-1 oui-rounded",input:"oui-pr-2"},suffix:jsxRuntime.jsx("button",{onClick:d,children:jsxRuntime.jsx(ui.CheckIcon,{size:18,color:"white",opacity:1,className:"oui-cursor-pointer oui-opacity-50 hover:oui-opacity-100"})})})})};var Ur=e=>{let{order:t}=e,{t:r}=i18n.useTranslation(),[o,n]=react.useState(()=>t.type===types.OrderType.MARKET&&!t.price?"Market":t.price?.toString()??"Market"),[i,a]=react.useState(false),[s,d]=react.useState(false),u=t?.algo_order_id!==void 0,l=t?.type==="MARKET"&&u,[f,x]=react.useState(false),{editOrder:C,editAlgoOrder:h,checkMinNotional:p}=Z(),{base:P,quote_dp:w}=z(),T=hooks.useSymbolPriceRange(t.symbol,t.side,u?t.trigger_price:void 0),q=()=>{a(false),d(false);},g=()=>{a(false),n(t.price?.toString()??"Market"),d(false);},E=react.useMemo(()=>!T||l||!s?"":Number(o)>T.max?r("orders.price.greaterThan",{max:T.max}):Number(o)<T.min?r("orders.price.lessThan",{min:T.min}):"",[l,s,T,o,r]),W=A=>{if(A?.stopPropagation(),A?.preventDefault(),!(E.length>0)){if(o===`${t.price}`){d(false);return}if(t.reduce_only!==true){let D=p(t.symbol,o,t.quantity);if(D){ui.toast.error(D),x(false),g();return}}a(true);}},R=A=>{A.key==="Enter"&&W(A);},O=()=>{x(true);let A=t.order_id,D={order_price:o,order_quantity:t.quantity,symbol:t.symbol,order_type:t.type,side:t.side};typeof t.reduce_only<"u"&&(D.reduce_only=t.reduce_only),t.order_tag!==void 0&&(D={...D,order_tag:t.order_tag}),u&&(A=t.algo_order_id,D={...D,order_id:A,price:o,algo_order_id:A}),t?.visible_quantity===0&&(D.visible_quantity=0),t.tag!==void 0&&(D.order_tag=t.tag);let re;t.algo_order_id!==void 0?re=h(t.algo_order_id.toString(),D):re=C(t.order_id.toString(),D),re.then(de=>{q(),n(o);},de=>{ui.toast.error(de.message),g();}).finally(()=>x(false));},L=react.useRef(null);react.useEffect(()=>{e.order.price&&n(`${e.order.price}`);},[e.order.price]);let F=react.useRef(null),X=A=>{F.current&&!F.current.contains(A.target)&&!i&&g();};if(react.useEffect(()=>(document.addEventListener("mousedown",X),()=>{document.removeEventListener("mousedown",X);}),[i,t.price]),t.algo_order_id&&t.type=="MARKET"||o==="Market")return jsxRuntime.jsx("span",{children:r("common.marketPrice")});let Y=()=>!s||e.disableEdit?jsxRuntime.jsx(li,{order:t,price:o,setEditing:d,disableEdit:e.disableEdit}):jsxRuntime.jsx(Re,{inputRef:L,dp:w,value:o,setValue:n,setEditing:d,handleKeyDown:R,onClick:W,onClose:g,hintInfo:E});return jsxRuntime.jsx(ui.Popover,{open:i,onOpenChange:a,content:jsxRuntime.jsx(qe,{type:1,base:P,value:o,cancelPopover:g,isSubmitting:f,onConfirm:O}),children:jsxRuntime.jsx("div",{onClick:A=>{A.stopPropagation(),A.preventDefault();},ref:F,children:Y()})})},li=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",ne(t)&&"oui-text-base-contrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(true);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:utils.commifyOptional(r)})})})};var Hr=react.createContext({}),G=()=>react.useContext(Hr),Bt=e=>{let{quote_dp:t}=z(),[r,o]=react.useState(),[n]=hooks.useMutation("/v1/algo/order","DELETE"),[i]=hooks.useMutation("/v1/algo/order","PUT"),a=hooks.useSWRConfig(),{state:s}=hooks.useAccount(),d=react.useMemo(()=>hooks.unstable_serialize(()=>["/v1/positions",s.accountId]),[s.accountId]),u=async P=>n(null,{order_id:P.algo_order_id,symbol:P.symbol}),l=async(P,w)=>i({order_id:P.algo_order_id,child_orders:P.child_orders.map(T=>({order_id:T.algo_order_id,quantity:w.order_quantity}))}),f=P=>a.cache.get(d)?.data.rows.find(T=>T.symbol===P),{sl_trigger_price:x,tp_trigger_price:C,tpPnL:h,slPnL:p}=bi({order:e.order,position:r,quote_dp:t});return react.useEffect(()=>{if("algo_type"in e.order||(e.order?.reduce_only??false)){let P=f(e.order.symbol);P&&o(P);}},[e.order.symbol]),jsxRuntime.jsx(Hr.Provider,{value:{order:e.order,sl_trigger_price:x,tp_trigger_price:C,tpPnL:h,slPnL:p,onCancelOrder:u,onUpdateOrder:l,getRelatedPosition:f,position:r},children:e.children})};function bi(e){let{order:t,position:r,quote_dp:o}=e;if(!r)return {sl_trigger_price:void 0,tp_trigger_price:void 0,slPnL:void 0,tpPnL:void 0};let{sl_trigger_price:n,tp_trigger_price:i}=!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(t),a=t.quantity;a===0&&t.child_orders?.[0].type==="CLOSE_POSITION"&&(a=r.position_qty);let s=r.average_open_price,d=typeof a=="number"&&typeof i=="number"&&typeof s=="number"?hooks.utils.priceToPnl({qty:a,price:i,entryPrice:r.average_open_price,orderSide:t.side,orderType:types.AlgoOrderType.TAKE_PROFIT},{symbol:{quote_dp:o}}):void 0,u=typeof a=="number"&&typeof n=="number"&&typeof s=="number"?hooks.utils.priceToPnl({qty:a,price:n,entryPrice:r.average_open_price,orderSide:t.side,orderType:types.AlgoOrderType.STOP_LOSS},{symbol:{quote_dp:o}}):void 0;return {sl_trigger_price:n,tp_trigger_price:i,slPnL:u,tpPnL:d}}var zt=e=>{let{order:t,otherOrderQuantity:r}=e,{reduce_only:o}=t,[n,i]=react.useState(t.quantity.toString()),[a,s]=react.useState(false),{t:d}=i18n.useTranslation();react.useEffect(()=>{E(t.quantity.toString());},[e.order.quantity]);let[u,l]=react.useState(false),[f,x]=react.useState(),{editOrder:C,editAlgoOrder:h,checkMinNotional:p}=Z(),{onUpdateOrder:P,position:w}=G(),{base_dp:T,base:q,base_tick:g}=z(),E=async(y,b)=>{i(y);let B=Math.abs(w?.position_qty||0);if(w&&o&&Number(y)>B)x(d("orders.quantity.lessThanPosition",{quantity:B}));else {let Te=Number(y);b&&Te>b?x(d("orders.quantity.lessThan",{quantity:utils.commifyOptional(b,{fix:T})})):x(void 0);}return Promise.resolve()},W=()=>{l(false),s(false);},R=()=>{l(false),E(t.quantity.toString()),s(false);},[O,L]=react.useState(false),F=react.useRef(null),X=()=>{if(f)return;if(Number(n)===Number(t.quantity)){s(false);return}let y=t.algo_order_id!==void 0?t.trigger_price:t.price;if(y!==null&&t.reduce_only!==true){let b=p(t.symbol,y,n);if(b){ui.toast.error(b),L(false),R();return}}l(true);},v=y=>{y?.stopPropagation(),y?.preventDefault(),X();},Y=y=>{y.key==="Enter"&&(y?.stopPropagation(),y?.preventDefault(),X());},A=react.useCallback(()=>{L(true);let y={symbol:t.symbol,order_type:t.type,side:t.side,order_price:t.price,order_quantity:n,algo_order_id:t.algo_order_id};if(typeof y.algo_order_id<"u"&&y.order_type==="MARKET"){let{order_price:B,...Te}=y;y=Te;}typeof t.reduce_only<"u"&&(y.reduce_only=t.reduce_only),t.order_tag!==void 0&&(y={...y,order_tag:t.order_tag}),t?.visible_quantity===0&&(y.visible_quantity=0),t?.tag!==void 0&&(y.order_tag=t.tag);let b;"algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?b=P(t,y):t.algo_order_id!==void 0?b=h(t.algo_order_id.toString(),y):b=C(t.order_id.toString(),y),b.then(B=>{W(),E(n.toString());},B=>{ui.toast.error(B.message),E(t.quantity.toString()),R();}).finally(()=>L(false));},[n]),D=react.useRef(null),re=react.useRef(null),de=y=>{D.current&&re.current&&!D.current.contains(y.target)&&!re.current.contains(y.target)&&!u&&R();};react.useEffect(()=>(document.addEventListener("mousedown",de),()=>{document.removeEventListener("mousedown",de);}),[u,t.quantity]);let Ge=()=>!a||e.disableEdit?jsxRuntime.jsx(Ii,{order:t,quantity:n,setEditing:s,disableEdit:e.disableEdit}):jsxRuntime.jsx(Ei,{inputRef:F,quantitySliderRef:re,base_dp:T,base_tick:g,quantity:n,setQuantity:E,editing:a,setEditing:s,handleKeyDown:Y,onClick:v,onClose:R,symbol:t.symbol,reduce_only:o,positionQty:w?.position_qty,error:f,confirmOpen:u,side:t.side,order:t,setError:x});return jsxRuntime.jsx(ui.Popover,{open:u,onOpenChange:l,content:jsxRuntime.jsx(qe,{type:0,base:q,value:n,cancelPopover:R,isSubmitting:O,onConfirm:A}),contentProps:{onOpenAutoFocus:y=>{}},children:jsxRuntime.jsx("div",{onClick:y=>{y.stopPropagation(),y.preventDefault();},ref:D,children:Ge()})})},Ii=e=>{let{order:t,quantity:r}=e,o=t.total_executed_quantity;return jsxRuntime.jsxs(ui.Flex,{direction:"row",justify:"start",gap:1,className:ui.cn("oui-max-w-[110px] oui-relative",t.side===types.OrderSide.BUY&&"oui-text-trade-profit",t.side===types.OrderSide.SELL&&"oui-text-trade-loss",ne(t)&&"oui-text-base-contrast-20"),onClick:n=>{n.stopPropagation(),n.preventDefault(),e.setEditing(true);},children:["algo_type"in t&&t.algo_type===types.AlgoOrderRootType.TP_SL?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:o}),jsxRuntime.jsx("span",{children:"/"})]}),jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})]})},Ei=e=>{let{inputRef:t,quantitySliderRef:r,base_dp:o,base_tick:n,quantity:i,setQuantity:a,editing:s,setEditing:d,handleKeyDown:u,onClick:l,onClose:f,error:x,symbol:C,reduce_only:h,positionQty:p,confirmOpen:P,side:w,order:T}=e,q=hooks.useMaxQty(C,T.side,T.reduce_only),g=react.useMemo(()=>h?Math.abs(p??0):T.quantity+Math.abs(q),[T.quantity,q,h,p]),[E,W]=react.useState(void 0);react.useEffect(()=>{if(E===void 0){let O=new utils.Decimal(i).div(g).abs().mul(100).toNumber();W(O);}},[E,g,i]);let R=async O=>(n>0&&(O=hooks.utils.formatNumber(O,n)??O),a(`${O}`,g));return jsxRuntime.jsxs(ui.PopoverRoot,{open:!P,children:[jsxRuntime.jsx(ui.PopoverTrigger,{children:jsxRuntime.jsx(Re,{inputRef:t,dp:o,value:i,setValue:O=>{let L=Math.abs(Math.min(Number(O),g)).toString();if(a(O,g),O.endsWith("."))return;if(Number(L)===0){W(0);return}let F=new utils.Decimal(O).div(g).mul(100).toDecimalPlaces(2,utils.Decimal.ROUND_DOWN).toNumber();W(Math.min(100,F));},setEditing:d,handleKeyDown:u,onClick:l,onClose:f,onBlur:O=>{R(O.target.value);},hintInfo:x})}),jsxRuntime.jsx(ui.PopoverContent,{className:"oui-w-[360px] oui-rounded-xl",align:"start",side:"bottom",onOpenAutoFocus:O=>{O.preventDefault();},children:jsxRuntime.jsxs(ui.Flex,{p:1,gap:2,width:"100%",itemAlign:"start",ref:r,children:[jsxRuntime.jsx(ui.Text.numeral,{size:"xs",intensity:98,className:"oui-min-w-[30px] ",dp:2,padding:false,unit:"%",rm:utils.Decimal.ROUND_DOWN,children:`${E}`}),jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",gap:2,className:"oui-mt-[6px]",children:[jsxRuntime.jsx(ui.Slider,{markCount:4,value:[E??0],onValueChange:O=>{let L=Array.from(O.values());W(L[0]);let F=new utils.Decimal(L[0]).div(100).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);a(F,g);},onValueCommit:O=>{let L=new utils.Decimal(O[0]).div(100).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);R(L).finally(()=>{t.current.focus();});}}),jsxRuntime.jsx(vi,{onClick:O=>{W(O*100);let L=new utils.Decimal(O).mul(g).abs().toFixed(o,utils.Decimal.ROUND_DOWN);L=hooks.utils.formatNumber(L,n)??L,a(L,g),setTimeout(()=>{t.current.focus(),t.current.setSelectionRange(L.length,L.length);},100);}})]})]})})]})},vi=e=>{let{t}=i18n.useTranslation(),r=[{label:"0%",value:0},{label:"25%",value:.25},{label:"50%",value:.5},{label:"75%",value:.75},{label:t("common.max"),value:1}];return jsxRuntime.jsx(ui.Flex,{gap:2,width:"100%",children:r.map((o,n)=>jsxRuntime.jsx(ui.Button,{variant:"outlined",color:"secondary",size:"xs",onClick:i=>{i.stopPropagation(),i.preventDefault(),e.onClick(o.value);},className:"oui-w-1/5",children:o.label},n))})};var eo=e=>{let{record:t}=e,[r,o]=react.useState(false),[n,{data:i,error:a,reset:s,isMutating:d}]=hooks.useMutation("/v1/order"),{t:u}=i18n.useTranslation(),l=hooks.useConfig("brokerId"),f=react.useCallback(()=>{o(false);let x={symbol:t.symbol,order_type:t.type,order_price:t.price,order_quantity:t.quantity,order_amount:t.amount,side:t.side,broker_id:l};Number(t.visible_quantity)<Number(t.quantity)&&(x.visible_quantity=0),typeof t.reduce_only<"u"&&(x.reduce_only=t.reduce_only),n(x);},[]);return jsxRuntime.jsx(ui.Button,{size:"sm",variant:"outlined",color:"secondary",loading:d,disabled:d,onClick:x=>{d||(x.preventDefault(),x.stopPropagation(),f());},children:u("orders.history.renew")})};var to=e=>{let{position:t,order:r}=G(),{quote_dp:o,base_dp:n}=z(),{t:i}=i18n.useTranslation();return jsxRuntime.jsx(uiTpsl.PositionTPSLPopover,{quoteDP:o,baseDP:n,position:t,order:r,label:i("common.edit"),isEditing:true})};var oo=()=>{let{sl_trigger_price:e,tp_trigger_price:t}=G(),{t:r}=i18n.useTranslation();return jsxRuntime.jsxs("div",{children:[t?jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-80 oui-td-bg-transparent",children:[jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${r("tpsl.tp")} -`,"\xA0"]}),jsxRuntime.jsx("span",{children:r("common.marketPrice")})]}):null,e?jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-80 oui-td-bg-transparent",children:[jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${r("tpsl.sl")} -`,"\xA0"]}),jsxRuntime.jsx("span",{children:r("common.marketPrice")})]}):null]})};function no(e){let{sl_trigger_price:t,tp_trigger_price:r}=!("algo_type"in e)||!Array.isArray(e.child_orders)?{}:hooks.utils.findTPSLFromOrder(e),o=r?`${i18n.i18n.t("tpsl.tp")} - ${i18n.i18n.t("common.marketPrice")}`:void 0,n=t?`${i18n.i18n.t("tpsl.sl")} - ${i18n.i18n.t("common.marketPrice")}`:void 0;return {tpTriggerPrice:o,slTriggerPrice:n}}var lo=()=>{let{sl_trigger_price:e,tp_trigger_price:t,order:r,position:o}=G();return jsxRuntime.jsx(Gi,{stopLossPrice:e,takeProfitPrice:t,direction:"column",order:r,position:o,tooltip:true})},Gi=e=>{let{direction:t="row",order:r,position:o}=e,n=hooks.useSymbolsInfo(),{t:i}=i18n.useTranslation(),a=react.useMemo(()=>{let u=[];if(!e.tooltip||!r||!o)return;let l=r.quantity;return l===0&&r.child_orders?.[0].type==="CLOSE_POSITION"&&(l=o.position_qty),e.takeProfitPrice&&u.push(jsxRuntime.jsx(ao,{qty:l,price:e.takeProfitPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.TAKE_PROFIT,symbolInfo:n[r.symbol]()},"tp")),e.stopLossPrice&&u.push(jsxRuntime.jsx(ao,{qty:l,price:e.stopLossPrice,entryPrice:o.average_open_price,orderSide:r.side,orderType:types.AlgoOrderType.STOP_LOSS,symbolInfo:n[r.symbol]()},"sl")),jsxRuntime.jsx("div",{children:u})},[e.takeProfitPrice,e.stopLossPrice,o?.average_open_price,r?.side,r?.quantity,r?.algo_type]),s=react.useMemo(()=>{let u=[];return r?.symbol?(e.takeProfitPrice&&u.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-profit oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12"),rule:"price",dp:n[r.symbol]("quote_dp",2),children:e.takeProfitPrice,prefix:!e.stopLossPrice||t==="column"?jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${i("tpsl.tp")} -`,"\xA0"]}):""},"tp")),e.stopLossPrice&&u.push(jsxRuntime.jsx(ui.Text.numeral,{className:ui.cn("oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12"),rule:"price",dp:n[r.symbol]("quote_dp",2),children:e.stopLossPrice,prefix:!e.takeProfitPrice||t==="column"?jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-54",children:[`${i("tpsl.sl")} -`,"\xA0"]}):""},"sl")),u.length===0?jsxRuntime.jsx("span",{children:"-"}):(u.length===2&&t==="row"&&u.splice(1,0,jsxRuntime.jsx("span",{children:"/"},"split")),u)):jsxRuntime.jsx("span",{children:"-"})},[e.takeProfitPrice,e.stopLossPrice,r?.symbol,i]),d=jsxRuntime.jsx("div",{className:ui.cn("oui-inline-flex oui-text-base-contrast-36",e.direction==="column"?"oui-flex-col":"oui-flex-row oui-gap-1",e.className),children:s});return e.tooltip?jsxRuntime.jsx(ui.Tooltip,{content:a,className:"oui-bg-base-5",arrow:{className:"oui-fill-base-5"},children:d}):d},ao=e=>{let{qty:t,price:r,entryPrice:o,orderSide:n,orderType:i,symbolInfo:a}=e,{t:s}=i18n.useTranslation(),d=hooks.utils.priceToPnl({qty:t,price:r,entryPrice:o,orderSide:n,orderType:i},{symbol:a}),l=(i===types.AlgoOrderType.TAKE_PROFIT?"TP":"SL")==="TP"?`${s("tpsl.tpPnl")}:`:`${s("tpsl.slPnl")}:`;return jsxRuntime.jsxs("div",{className:"oui-flex oui-items-center",children:[jsxRuntime.jsx("span",{className:"oui-text-base-contrast-54 oui-mr-1",children:l}),jsxRuntime.jsx(ui.Text.numeral,{rule:"price",dp:a.quote_dp,padding:false,className:d===0?"oui-text-base-contrast-36":d>0?"oui-text-trade-profit oui-gap-0":"oui-text-trade-loss oui-gap-0",prefix:jsxRuntime.jsx("span",{children:d===0?"":d>0?"+":"-"}),suffix:jsxRuntime.jsx("span",{className:"oui-text-base-contrast-36 oui-ml-1",children:"USDC"}),children:`${Math.abs(d)}`})]})};var go=e=>{let{order:t}=e,[r,o]=react.useState("");react.useEffect(()=>{o(t.trigger_price?.toString()??"0");},[t.trigger_price]);let n=t?.algo_order_id!==void 0,i=t?.algo_type==="BRACKET",[a,s]=react.useState(false),[d,u]=react.useState(false),[l,f]=react.useState(false),{editAlgoOrder:x,checkMinNotional:C}=Z(),{base:h,quote_dp:p,quote_max:P,quote_min:w}=z(),T=react.useMemo(()=>{if(!((!n||i)&&!d)){if(Number(r)>P)return `Trigger price must be less than ${P}`;if(Number(r)<w)return `Trigger price must be greater than ${w}`}},[d,r,n,i]),q=()=>{s(false),u(false);},g=()=>{o(t.trigger_price?.toString()??"0"),s(false),u(false);},E=react.useRef(null),W=v=>{E.current&&!E.current.contains(v.target)&&!a&&g();};react.useEffect(()=>(document.addEventListener("mousedown",W),()=>{document.removeEventListener("mousedown",W);}),[a,t.trigger_price]);let R=v=>{if(v?.stopPropagation(),v?.preventDefault(),u(false),Number(r)!==Number(t.trigger_price)){if(t.price&&t.reduce_only!==true){let Y=C(t.symbol,t.price,t.quantity);if(Y){ui.toast.error(Y),f(false),g();return}}s(true);}},O=v=>{v.key==="Enter"&&R(v);},L=()=>{if((T??"").length>0)return;f(true);let v={quantity:t.quantity,trigger_price:r,symbol:t.symbol,algo_order_id:t.algo_order_id};t.order_tag!==void 0&&(v={...v,order_tag:t.order_tag}),x(`${t.algo_order_id}`,v).then(Y=>{q(),o(r);},Y=>{ui.toast.error(Y.message),o(t.trigger_price?.toString()??"--"),g();}).finally(()=>f(false));},F=react.useRef(null);if(!n||i)return jsxRuntime.jsx(ui.Text,{children:"--"});let X=()=>!d||e.disableEdit?jsxRuntime.jsx(ji,{order:t,price:r,setEditing:u,disableEdit:e.disableEdit}):jsxRuntime.jsx(Re,{inputRef:F,dp:p,value:r,setValue:o,setEditing:u,handleKeyDown:O,onClick:R,onClose:g,hintInfo:T});return jsxRuntime.jsx(ui.Popover,{open:a,onOpenChange:s,content:jsxRuntime.jsx(qe,{type:2,base:h,value:r,cancelPopover:g,isSubmitting:l,onConfirm:L}),children:jsxRuntime.jsx("div",{onClick:v=>{v.stopPropagation(),v.preventDefault();},ref:E,children:X()})})},ji=e=>{let{order:t,price:r}=e;return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-max-w-[110px] oui-justify-start oui-items-center oui-gap-1 oui-relative oui-font-semibold",ne(t)&&"oui-text-base-contrast-20"),onClick:o=>{o.stopPropagation(),o.preventDefault(),e.setEditing(true);},children:jsxRuntime.jsx(ui.Flex,{r:"base",className:ui.cn("oui-min-w-[70px] oui-h-[28px]",!e.disableEdit&&"oui-bg-base-7 oui-px-2 oui-border oui-border-line-12"),children:jsxRuntime.jsx(ui.Text,{size:"2xs",children:r})})})};var _o=e=>{let{_type:t,onSymbolChange:r,pnlNotionalDecimalPrecision:o,sharePnLConfig:n}=e,{t:i}=i18n.useTranslation();return react.useMemo(()=>{switch(t){case "all":return [we({width:130,showType:true,onSymbolChange:r,enableSort:false}),ia({width:130}),Me({width:130,disableEdit:true,className:"oui-pl-0 oui-pr-0",enableSort:false}),We({width:130,title:i("orders.column.orderPrice"),disableEdit:true,enableSort:false}),bt({width:130,enableSort:false}),yo({width:130,symbolsInfo:e.symbolsInfo}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo}),ze({width:130,enableSort:false}),rt({width:130}),ot({width:130}),Ie({width:130}),$e({width:130}),bo({width:130}),Ue({width:160,enableSort:false})];case "pending":return [we({width:172,showType:true,onSymbolChange:r,enableSort:false}),Me({width:162,className:"oui-pr-0",enableSort:false}),We({width:162,className:"oui-pr-0",enableSort:false}),tt({width:162,className:"oui-pr-0"}),da({width:130}),ze({width:162,isPending:true}),Ie({width:162}),$e({width:162}),Ue({width:162,enableSort:false}),ca({width:162})];case "tp_sl":return [we({width:176,showType:true,onSymbolChange:r,enableSort:false}),aa({width:176}),yo({width:176,symbolsInfo:e.symbolsInfo}),sa({width:176}),ua({width:176}),Ie({width:176}),Ue({width:176,enableSort:false}),ma({width:176})];case "filled":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0"}),We({width:124,title:i("orders.column.orderPrice"),disableEdit:true}),la({width:124}),tt({width:124,disableEdit:true}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo,hideShare:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:176})];case "cancelled":return [we({showType:true,width:154,onSymbolChange:r,enableSort:false}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0",enableSort:false}),We({width:124,disableEdit:true,enableSort:false}),bt({width:124,enableSort:false}),tt({width:124,disableEdit:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124})];case "rejected":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:124,disableEdit:true,className:"oui-pl-0 oui-pr-0"}),We({width:124,disableEdit:true}),bt({width:124}),tt({width:124,disableEdit:true}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:176})];case "orderHistory":return [we({showType:true,width:154,onSymbolChange:r}),Me({width:150,disableEdit:true,className:"oui-pl-6 oui-pr-0"}),We({width:124,disableEdit:true}),bt({width:124}),tt({width:124,disableEdit:true}),Ht({width:124,pnlNotionalDecimalPrecision:o,sharePnLConfig:n,symbolsInfo:e.symbolsInfo}),ze({width:124}),rt({width:124}),ot({width:124}),Ie({width:124}),$e({width:124}),Ue({width:150}),bo({width:80})]}},[t,o,n,i])};function we(e){return {title:i18n.i18n.t("common.symbol"),dataIndex:"symbol",fixed:"left",width:e?.width,onSort:e?.enableSort?(t,r)=>t.symbol.localeCompare(r.symbol):void 0,renderPlantText:(t,r)=>{let o=ce(r)?.join(","),n=o?.length?` (${o})`:"";return `${t.split("_")[1]}-PERP${n}`},render:(t,r)=>{let o=ne(r);return jsxRuntime.jsxs(ui.Flex,{gap:2,children:[jsxRuntime.jsx("div",{className:ui.cn("oui-rounded-[1px] oui-w-1 oui-h-7 oui-shrink-0",r.side===types.OrderSide.BUY?"oui-bg-trade-profit":"oui-bg-trade-loss")}),jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text.formatted,{size:"xs",className:"oui-cursor-pointer oui-text-xs",onClick:n=>{e?.onSymbolChange?.({symbol:t}),n.stopPropagation(),n.preventDefault();},children:`${t.split("_")[1]}-PERP`}),e?.showType&&jsxRuntime.jsx(ui.Flex,{direction:"row",gap:1,children:ce(r)?.map((n,i)=>jsxRuntime.jsx(ui.Badge,{color:n.toLocaleLowerCase()==="position"?o?"neutral":"primary":"neutral",size:"xs",className:"oui-break-normal oui-whitespace-nowrap",children:n},i))})]})]})}}}function ia(e){return {title:i18n.i18n.t("common.side"),dataIndex:"side",width:e?.width,onSort:e?.enableSort?(t,r,o)=>r.side.localeCompare(t.side):void 0,renderPlantText:(t,r)=>ue(t),render:(t,r)=>{let o=ne(r)?"oui-text-base-contrast-20":t===types.OrderSide.BUY?"oui-text-trade-profit":"oui-text-trade-loss";return jsxRuntime.jsx("span",{className:ui.cn("oui-font-semibold",o),children:ue(t)})}}}function Me(e){return {title:i18n.i18n.t("orders.column.fill&Quantity"),dataIndex:"fill_quantity",className:e?.className,width:e?.width,onSort:e?.enableSort??false?(t,r)=>{let o=(t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:t.quantity)??0,n=(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:r.quantity)??0;return it(o,n)}:void 0,renderPlantText:(t,r)=>{if(r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED)return i18n.i18n.t("tpsl.entirePosition");let o=r.total_executed_quantity;return ("algo_type"in r&&r.algo_type===types.AlgoOrderRootType.TP_SL?"":`${o} / `)+`${r.quantity}`},render:(t,r)=>r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(zt,{order:r,disableEdit:e?.disableEdit})}}function aa(e){return {title:i18n.i18n.t("common.quantity"),className:e?.className,dataIndex:"quantity",width:e?.width,onSort:e?.enableSort??false?(t,r)=>{let o=(t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:t.quantity)??0,n=(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?0:r.quantity)??0;return it(o,n)}:void 0,renderPlantText:(t,r)=>{if(r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL)return i18n.i18n.t("tpsl.entirePosition");let o=r.total_executed_quantity;return ("algo_type"in r&&r.algo_type===types.AlgoOrderRootType.TP_SL?"":`${o}/`)+`${r.quantity}`},render:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(zt,{order:r})}}function We(e){return {title:e?.title??i18n.i18n.t("common.price"),dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort??false?(t,r,o)=>it(t.price??0,r.price??0):void 0,renderPlantText:(t,r)=>utils.commifyOptional(r.price?.toString(),{fallback:i18n.i18n.t("common.marketPrice")}),render:(t,r)=>jsxRuntime.jsx(Ur,{order:r,disableEdit:e?.disableEdit})}}function sa(e){return {title:e?.title??i18n.i18n.t("common.price"),dataIndex:"price",className:e?.className,width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let{tpTriggerPrice:o,slTriggerPrice:n}=no(r),i=`${o||""}${n?`${o?`
17
+ `:""}${n}`:""}`;return i.length>0?i:"--"},render:(t,r)=>jsxRuntime.jsx(oo,{})}}function la(e){return {title:i18n.i18n.t("common.avgPrice"),dataIndex:"average_executed_price",className:e?.className,width:e?.width,onSort:e?.enableSort,render:(t,r)=>utils.commifyOptional(t)}}function tt(e){return {title:i18n.i18n.t("common.trigger"),className:e?.className,dataIndex:"trigger_price",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=r?.algo_order_id!==void 0,n=r?.algo_type==="BRACKET";return !o||n?"--":utils.commifyOptional(t)},render:(t,r)=>jsxRuntime.jsx(go,{order:r,disableEdit:e?.disableEdit})}}function yo(e){return {title:e?.title??i18n.i18n.t("common.trigger"),className:e?.className,dataIndex:"tpsl_trigger_price",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=e?.symbolsInfo?.[r.symbol],n=o?.("quote_dp"),{sl_trigger_price:i,tp_trigger_price:a}=!("algo_type"in r)||!Array.isArray(r.child_orders)?{}:hooks.utils.findTPSLFromOrder(r),s=(a!=null?`${i18n.i18n.t("tpsl.tp")}: ${utils.commifyOptional(a,{fix:n,padEnd:true})}`:"")+(i!=null?`${a?`
18
+ `:""}${i18n.i18n.t("tpsl.sl")}: ${utils.commifyOptional(i,{fix:n,padEnd:true})}`:"");return s.length>0?s:"--"},render:(t,r)=>jsxRuntime.jsx(lo,{})}}function da(e){return {title:i18n.i18n.t("common.tpsl"),className:e?.className,dataIndex:"bracketOrderPrice",width:e?.width,onSort:e?.enableSort,renderPlantText:(t,r)=>{let o=()=>!("algo_type"in r)||!Array.isArray(r.child_orders)?{}:hooks.utils.findTPSLFromOrder(r.child_orders[0]),{sl_trigger_price:n,tp_trigger_price:i}=o(),a=(i!=null?`${i18n.i18n.t("tpsl.tp")}: ${i}`:"")+(n!=null?`${i?`
19
+ `:""}${i18n.i18n.t("tpsl.sl")}: ${n}`:"");return a.length>0?a:"--"},render:(t,r)=>jsxRuntime.jsx(Fr,{order:r})}}function ze(e){return {title:i18n.i18n.t("common.notional"),dataIndex:"executed",width:e?.width,className:e?.className,onSort:e?.enableSort??false?(t,r,o)=>{let n=t.type===types.OrderType.CLOSE_POSITION&&t.status!==types.OrderStatus.FILLED||t.total_executed_quantity===0||Number.isNaN(t.average_executed_price)||t.average_executed_price===null?0:t.total_executed_quantity*t.average_executed_price,i=r.type===types.OrderType.CLOSE_POSITION&&r.status!==types.OrderStatus.FILLED||r.total_executed_quantity===0||Number.isNaN(r.average_executed_price)||r.average_executed_price===null?0:r.total_executed_quantity*r.average_executed_price;return it(n,i)}:void 0,renderPlantText:(t,r)=>Vt(r,e?.isPending??false)==="Entire position"?i18n.i18n.t("tpsl.entirePosition"):utils.commifyOptional(Vt(r,e?.isPending??false),{fix:2}),render:(t,r)=>{let o=Vt(r,e?.isPending??false);return o==="Entire position"?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(ui.Text.numeral,{rm:utils.Decimal.ROUND_DOWN,dp:2,children:o})}}}function Ht(e){return {title:i18n.i18n.t("common.realizedPnl"),dataIndex:"realized_pnl",width:e?.width,className:e?.className,renderPlantText:(t,r)=>{let o=e?.symbolsInfo?.[r.symbol],n=o?.("quote_dp"),i=e?.pnlNotionalDecimalPrecision??n,a=new utils.Decimal(t??0).toDecimalPlaces(i,utils.Decimal.ROUND_DOWN).toNumber(),s=utils.commifyOptional(a);return a>0?`+${s}`:s},render:(t,r)=>{let{quote_dp:o}=z(),n=e?.pnlNotionalDecimalPrecision??o,i=new utils.Decimal(t??0).toDecimalPlaces(n,utils.Decimal.ROUND_DOWN).toNumber();return jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text.numeral,{dp:n,rm:utils.Decimal.ROUND_DOWN,padding:false,intensity:(i??0)==0?80:void 0,showIdentifier:(i??0)>0,coloring:(i??0)!=0,children:i??"--"}),!e?.hideShare&&jsxRuntime.jsx(Je,{order:r,sharePnLConfig:e?.sharePnLConfig,modalId:uiShare.SharePnLDialogId})]})}}}function Ie(e){return {title:i18n.i18n.t("orderEntry.reduceOnly"),dataIndex:"reduce_only",width:e?.width,className:e?.className,renderPlantText:(t,r)=>t?i18n.i18n.t("common.yes"):i18n.i18n.t("common.no"),render:t=>jsxRuntime.jsx(ui.Text,{children:t?i18n.i18n.t("common.yes"):i18n.i18n.t("common.no")})}}function $e(e){return {title:i18n.i18n.t("orders.column.hidden"),dataIndex:"visible",width:e?.width,className:e?.className,renderPlantText:(t,r)=>t!==0?i18n.i18n.t("common.no"):i18n.i18n.t("common.yes"),render:(t,r)=>jsxRuntime.jsx(ui.Text,{children:r.visible_quantity!==0?i18n.i18n.t("common.no"):i18n.i18n.t("common.yes")})}}function Ue(e){return {title:i18n.i18n.t("orders.column.orderTime"),dataIndex:"created_time",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(t,r)=>{let o=new Date(t);return dateFns.format(o,"yyyy-MM-dd HH:mm:ss")},render:t=>jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:e?.formatString||"yyyy-MM-dd HH:mm:ss",className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t})}}function rt(e){return {title:i18n.i18n.t("common.fee"),dataIndex:"total_fee",width:e?.width,onSort:e?.enableSort,className:e?.className}}function ua(e){return {title:i18n.i18n.t("common.notional"),dataIndex:"executed",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):utils.commifyOptional(r.quantity===0?"--":`${new utils.Decimal(r.mark_price).mul(r.quantity).todp(2).toNumber()}`),render:(t,r)=>r.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?i18n.i18n.t("tpsl.entirePosition"):jsxRuntime.jsx(ui.Text.numeral,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:r.quantity===0?"--":`${new utils.Decimal(r.mark_price).mul(r.quantity).todp(2).toNumber()}`})}}function ot(e){let t={[types.OrderStatus.NEW]:i18n.i18n.t("orders.status.pending"),[types.OrderStatus.FILLED]:i18n.i18n.t("orders.status.filled"),[types.OrderStatus.PARTIAL_FILLED]:i18n.i18n.t("orders.status.partialFilled"),[types.OrderStatus.CANCELLED]:i18n.i18n.t("orders.status.canceled"),[types.OrderStatus.REJECTED]:i18n.i18n.t("orders.status.rejected"),[types.OrderStatus.INCOMPLETE]:i18n.i18n.t("orders.status.incomplete"),[types.OrderStatus.COMPLETED]:i18n.i18n.t("orders.status.completed")};return {title:i18n.i18n.t("common.status"),dataIndex:"status",width:e?.width,onSort:e?.enableSort,className:e?.className,renderPlantText:(r,o)=>{let n=r||o.algo_status;return t[n]||ue(n)},render:(r,o)=>{let n=r||o.algo_status;return t[n]||ue(n)}}}function bt(e){return {title:i18n.i18n.t("common.avgPrice"),dataIndex:"average_executed_price",width:e?.width,onSort:e?.enableSort??false?(t,r)=>it(t.average_executed_price??0,r.average_executed_price??0):void 0,className:e?.className,render:(t,r)=>r.type===types.OrderType.MARKET&&!t?"--":jsxRuntime.jsx(ui.Text,{className:"oui-break-normal oui-whitespace-nowrap oui-font-semibold",children:t}),renderPlantText:(t,r)=>utils.commifyOptional(t,{fix:2})}}function bo(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>r.status===types.OrderStatus.CANCELLED?jsxRuntime.jsx(eo,{record:r}):r.status===types.OrderStatus.NEW||r.algo_status===types.OrderStatus.NEW?jsxRuntime.jsx(mt,{order:r}):null}}function ca(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxRuntime.jsx(mt,{order:r})}}function ma(e){return {title:"",type:"action",dataIndex:"action",width:e?.width,className:e?.className,align:"right",fixed:"right",render:(t,r)=>jsxRuntime.jsxs(ui.Flex,{gap:3,children:[jsxRuntime.jsx(to,{order:r}),jsxRuntime.jsx(mt,{order:r})]})}}function it(e,t){return e>t?1:e<t?-1:0}function Vt(e,t){return t?e.price&&e.quantity?new utils.Decimal(e.price).mul(e.quantity).toFixed(2,utils.Decimal.ROUND_DOWN):"--":e.type===types.OrderType.CLOSE_POSITION&&e.status!==types.OrderStatus.FILLED?i18n.i18n.t("tpsl.entirePosition"):e.total_executed_quantity===0||Number.isNaN(e.average_executed_price)||e.average_executed_price===null?"--":`${e.total_executed_quantity*e.average_executed_price}`}var To=e=>{let{item:t}=e,r=t.side===types.OrderSide.BUY,{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Text.formatted,{intensity:80,rule:"symbol",formatString:"base-type",size:"sm",prefix:jsxRuntime.jsx(ui.Badge,{color:r?"success":"danger",size:"xs",children:o(r?"common.buy":"common.sell")}),onClick:()=>{e.onSymbolChange?.({symbol:t.symbol});},children:t.symbol})},Lo=e=>{let {item:t}=e;react.useCallback(()=>{let o=typeof t.type=="string"?t.type.replace("_ORDER","").toLowerCase():t.type;return t.algo_order_id&&t.algo_type!==types.AlgoOrderRootType.BRACKET?`Stop ${o}`:ue(t.type)},[t]);return jsxRuntime.jsx(ui.Flex,{direction:"row",gap:1,children:ce(e.item)?.map((o,n)=>jsxRuntime.jsx(ui.Badge,{color:o.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:o},n))})},No=e=>{let{item:t}=e;return jsxRuntime.jsx(ui.Text.formatted,{rule:"date",formatString:"yyyy-MM-dd hh:mm:ss",intensity:36,size:"2xs",children:t.updated_time})},wo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t.status||t.algo_status,n=react.useMemo(()=>({[types.OrderStatus.NEW]:r("orders.status.pending"),[types.OrderStatus.FILLED]:r("orders.status.filled"),[types.OrderStatus.PARTIAL_FILLED]:r("orders.status.partialFilled"),[types.OrderStatus.CANCELLED]:r("orders.status.canceled"),[types.OrderStatus.REJECTED]:r("orders.status.rejected"),[types.OrderStatus.INCOMPLETE]:r("orders.status.incomplete"),[types.OrderStatus.COMPLETED]:r("orders.status.completed")}),[r]);return jsxRuntime.jsx(ui.Text.formatted,{intensity:80,size:"2xs",children:n[o]||ue(o)})},Gt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t.type===types.OrderType.CLOSE_POSITION&&t?.status!==types.OrderStatus.FILLED;return jsxRuntime.jsx(ui.Statistic,{label:r("common.qty"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.base_dp,padding:false,coloring:true,placeholder:r("tpsl.entirePosition"),intensity:80,children:o?r("tpsl.entirePosition"):t.quantity})})},Jt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsx(ui.Text,{children:r("orders.status.filled")}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.base_dp,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:t.total_executed_quantity})})};var Io=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=react.useMemo(()=>t.price&&t.quantity?new utils.Decimal(t.price).mul(t.quantity).toFixed(e.quote_dp,utils.Decimal.ROUND_DOWN):"--",[t.price,t.quantity]);return jsxRuntime.jsx(ui.Statistic,{align:"end",label:jsxRuntime.jsxs(ui.Text,{children:[r("common.notional"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,coloring:true,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:o})})},Xt=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:r("orders.column.triggerPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:e.align,children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,intensity:80,padding:false,rm:utils.Decimal.ROUND_DOWN,children:t.trigger_price??"--"})})},Eo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:r("common.markPrice"),align:"end",classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.mark_price})})},vo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=t?.algo_order_id!==void 0,n=t?.type==="MARKET"&&o;return jsxRuntime.jsx(ui.Statistic,{label:r("common.limitPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:n?jsxRuntime.jsx(ui.Text,{children:r("common.marketPrice")}):jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.price??"--"})})},Ao=e=>{let{tp_trigger_price:t,tpPnL:r}=G(),{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:o("tpsl.tpTrigger"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(xt,{content:r&&jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",showIdentifier:true,prefix:jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${o("tpsl.tpPnl")}:`,"\xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:"\xA0USDC"}),coloring:true,children:r}),classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,color:"buy",padding:false,className:t?"oui-border-b oui-border-dashed oui-border-base-contrast-12":void 0,children:t??"--"})})})},Do=e=>{let{sl_trigger_price:t,slPnL:r}=G(),{t:o}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:o("tpsl.slTrigger"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(xt,{content:r&&jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",prefix:jsxRuntime.jsxs(ui.Text,{intensity:54,children:[`${o("tpsl.slPnl")}:`,"\xA0\xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:"\xA0USDC"}),coloring:true,children:r}),classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,color:"sell",padding:false,className:t?"oui-border-b oui-border-dashed oui-border-base-contrast-12":void 0,children:t??"--"})})})},Fo=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:t("tpsl.tpPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text,{intensity:80,children:t("common.marketPrice")})})},ko=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:t("tpsl.slPrice"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text,{intensity:80,children:t("common.marketPrice")})})},qo=e=>{let{item:t}=e,{t:r}=i18n.useTranslation(),o=react.useMemo(()=>t.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL?jsxRuntime.jsx("span",{className:"oui-text-base-contrast-80",children:r("tpsl.entirePosition")}):jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:t.quantity}),[t,r]);return jsxRuntime.jsx(ui.Statistic,{label:r("common.quantity"),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:"end",children:o})},Ro=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[t("common.avgPrice"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,children:e.item?.average_executed_price??"--"})})},Bo=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[t("orders.column.orderPrice"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},children:jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,intensity:80,padding:false,placeholder:t("common.marketPrice"),children:e.item?.price??"--"})})},Mo=e=>{let t=e?.item?.realized_pnl,{t:r}=i18n.useTranslation();return jsxRuntime.jsx(ui.Statistic,{label:jsxRuntime.jsxs(ui.Text,{children:[r("common.realizedPnl"),jsxRuntime.jsx(ui.Text,{intensity:20,children:"(USDC)"})]}),classNames:{root:"oui-text-xs",label:"oui-text-2xs"},align:"end",children:jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text.numeral,{dp:e.quote_dp,rm:utils.Decimal.ROUND_DOWN,padding:false,intensity:(t??0)==0?80:void 0,showIdentifier:(t??0)>0,coloring:(t??0)!=0,children:t??"--"}),jsxRuntime.jsx(Je,{order:e.item,sharePnLConfig:e.sharePnLConfig,modalId:uiShare.SharePnLBottomSheetId,iconSize:12})]})})},xt=e=>{let{classNames:t,content:r}=e,[o,n]=react.useState(false);return typeof r>"u"?e.children:jsxRuntime.jsx(ui.Tooltip,{content:r,className:t?.content,open:o,onOpenChange:n,arrow:{className:t?.arrow},children:jsxRuntime.jsx("div",{onClick:()=>n(i=>!i),children:e.children})})};var Zt=e=>{let {t}=i18n.useTranslation(),{item:r}=e;r.quantity>0;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(ui.Button,{variant:"outlined",fullWidth:true,color:"secondary",size:"sm",className:"oui-border-base-contrast-36",onClick:()=>{e.onShowEditSheet();},children:t("common.edit")})})};var $o=e=>{let{side:t}=e.item,{price:r,quantity:o,triggerPrice:n,isAlgoOrder:i}=e,a=t===types.OrderSide.BUY,{t:s}=i18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-pt-2",children:[jsxRuntime.jsx(ui.Text,{intensity:80,children:`You agree to edit your ${e.base}-PERP order.`}),jsxRuntime.jsxs(ui.Flex,{gap:2,mb:3,mt:2,justify:"between",children:[jsxRuntime.jsx(ui.Text.formatted,{rule:"symbol",formatString:"base-type",size:"base",showIcon:true,children:e.item.symbol}),jsxRuntime.jsxs(ui.Flex,{direction:"row",gap:1,children:[ce(e.item)?.map((d,u)=>jsxRuntime.jsx(ui.Badge,{color:d.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:d},u)),a&&jsxRuntime.jsx(ui.Badge,{color:"success",size:"xs",children:s("common.buy")}),!a&&jsxRuntime.jsx(ui.Badge,{color:"danger",size:"xs",children:s("common.sell")})]})]}),jsxRuntime.jsx(ui.Divider,{}),jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,width:"100%",className:"oui-text-sm oui-text-base-contrast-54",py:3,children:[i&&jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("orders.column.triggerPrice")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:80,dp:e.quote_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,suffix:jsxRuntime.jsx(ui.Text,{intensity:54,children:" USDC"}),children:n??"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("common.price")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:80,dp:e.quote_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,suffix:jsxRuntime.jsx(ui.Text,{intensity:54,children:" USDC"}),placeholder:e.isStopMarket?s("common.marketPrice"):"--",children:e.isStopMarket?s("common.marketPrice"):r??"--"})]}),jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsx(ui.Text,{children:s("common.qty")}),jsxRuntime.jsx(ui.Text.numeral,{color:t===types.OrderSide.BUY?"buy":"sell",dp:e.base_dp,padding:false,rm:utils.Decimal.ROUND_DOWN,children:o??"--"})]})]}),jsxRuntime.jsxs(ui.Flex,{className:"oui-gap-[2px]",children:[jsxRuntime.jsx(ui.Checkbox,{color:"white",id:"oui-checkbox-disableOrderConfirmation",checked:!e.orderConfirm,onCheckedChange:d=>{e.setOrderConfirm(!d);}}),jsxRuntime.jsx("label",{className:"oui-text-2xs oui-text-base-contrast-54",htmlFor:"oui-checkbox-disableOrderConfirmation",children:s("orderEntry.disableOrderConfirm")})]})]})};var nr=e=>{let{item:t}=e,r=t.side===types.OrderSide.BUY,{t:o}=i18n.useTranslation(),{parseErrorMsg:n}=reactApp.useOrderEntryFormErrorMsg(e.errors),i=n("order_quantity"),a=n("order_price"),s=n("trigger_price"),d=e.quantity&&e.maxQty?Math.min(Number(e.quantity)/e.maxQty,1):void 0,u=l=>{let f=e.baseTick;if(f&&f>0){let x=hooks.utils.formatNumber(l,f)??l;e.setQuantity(x);}};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:3,width:"100%",itemAlign:"start",className:"oui-text-sm",children:[jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text.formatted,{rule:"symbol",showIcon:true,intensity:80,children:t.symbol}),jsxRuntime.jsxs(ui.Flex,{direction:"row",gap:1,children:[ce(e.item)?.map((l,f)=>jsxRuntime.jsx(ui.Badge,{color:l.toLocaleLowerCase()==="position"?"primary":"neutral",size:"xs",children:l},f)),r&&jsxRuntime.jsx(ui.Badge,{color:"success",size:"xs",children:o("common.buy")}),!r&&jsxRuntime.jsx(ui.Badge,{color:"danger",size:"xs",children:o("common.sell")})]})]}),jsxRuntime.jsx(ui.Divider,{intensity:8,className:"oui-w-full"}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text,{children:o("common.lastPrice")}),jsxRuntime.jsx(ui.Text.numeral,{dp:e.item?.symbolInfo?.duote_dp,children:e.curMarkPrice??"--"})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",direction:"column",itemAlign:"stretch",gap:2,children:[e.isAlgoOrder&&jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("orders.column.triggerPrice")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.quote}),color:s?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.quote_dp)],value:e.triggerPrice,onValueChange:l=>e.setTriggerPrice(l),tooltip:s,tooltipProps:{content:{className:"oui-bg-base-6 oui-text-base-contrast-80"},arrow:{className:"oui-fill-base-6"}},classNames:{input:"oui-text-base-contrast oui-w-full",root:ui.cn("oui-outline-line-12",s&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("common.price")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.quote}),color:a?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.quote_dp)],disabled:!e.priceEdit,value:e.isStopMarket?o("orderEntry.orderType.market"):e.price,onValueChange:l=>e.setPrice(l),tooltip:a,tooltipProps:{content:{className:"oui-bg-base-5"},arrow:{className:"oui-fill-base-5"}},classNames:{input:"oui-text-base-contrast",root:ui.cn("oui-outline-line-12",a&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Input.tooltip,{prefix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:o("common.quantity")}),suffix:jsxRuntime.jsx(ui.Text,{intensity:54,className:"oui-px-3",children:e.base}),color:i?"danger":void 0,align:"right",fullWidth:true,autoComplete:"off",formatters:[ui.inputFormatter.numberFormatter,ui.inputFormatter.dpFormatter(e.base_dp)],value:e.quantity,onValueChange:l=>{e.setQuantity(l);},onBlur:l=>u(l.target.value),tooltip:i,tooltipProps:{content:{className:"oui-bg-base-6"},arrow:{className:"oui-fill-base-6"}},classNames:{input:"oui-text-base-contrast",root:ui.cn("oui-outline-line-12",i&&"oui-outline-danger")}}),jsxRuntime.jsx(ui.Slider,{markCount:4,value:[e.sliderValue??0],onValueChange:l=>{e.setSliderValue(l[0]);},color:"primary"}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(ui.Text.numeral,{color:"primary",size:"2xs",dp:2,padding:false,rule:"percentages",children:`${d??0}`}),jsxRuntime.jsxs(ui.Flex,{gap:1,children:[jsxRuntime.jsx(ui.Text,{size:"2xs",color:"primary",children:o("common.max")}),jsxRuntime.jsx(ui.Text.numeral,{intensity:54,size:"2xs",dp:e.base_dp,children:e.maxQty})]})]})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",gap:3,mt:2,children:[jsxRuntime.jsx(ui.Button,{fullWidth:true,color:"secondary",onClick:l=>{e.onClose();},children:o("common.cancel")}),jsxRuntime.jsx(ui.ThrottledButton,{fullWidth:true,onClick:l=>{l.stopPropagation(),l.preventDefault(),e.onSheetConfirm();},loading:e.submitting,disabled:!e.isChanged,children:o("common.confirm")})]})]}),jsxRuntime.jsx(ui.SimpleDialog,{open:e.dialogOpen,onOpenChange:e.setDialogOpen,title:o("orders.editOrder"),size:"xs",actions:{primary:{label:o("common.confirm"),onClick:e.onDialogConfirm,loading:e.submitting,fullWidth:true},secondary:{label:o("common.cancel"),onClick:e.onCloseDialog,fullWidth:true}},classNames:{content:"oui-pb-4",body:"oui-p-0",footer:"oui-pt-3 oui-pb-0"},children:jsxRuntime.jsx($o,{...e})})]})};var lr=e=>{let {state:t,editAlgoOrder:r,editOrder:o,autoCheckInput:n=true,position:i}=e,{item:a}=t,{hide:s}=ui.useModal(),[d,u]=react.useState(false),l=a?.algo_order_id!==void 0&&a.algo_type!==types.AlgoOrderRootType.BRACKET,f=a?.type==="MARKET"&&l;f||a?.type==="MARKET";let [C,h]=react.useState(false),p=react.useMemo(()=>l&&a.algo_type!==types.AlgoOrderRootType.BRACKET?`STOP_${a.type}`:a.type,[a,l]),[P,w]=hooks.useLocalStorage("orderly_order_confirm",true),{base_dp:T,base_tick:q}=e.state,{formattedOrder:g,setValue:E,markPrice:R,errors:O,validate:L,maxQty:F}=za({order:a,orderType:p,position:i}),X=()=>{L().then(b=>{P?u(true):D(g);},b=>{b?.total?.message&&ui.toast.error(b?.total.message);}).catch(b=>{});},v=react.useCallback(()=>{u(false);},[]),Y=()=>g?D(g):Promise.reject(),A=react.useCallback(()=>{s();},[]),D=react.useCallback(async b=>{let B,Te=a.visible_quantity!==void 0?a.visible_quantity===0:a.visible!==void 0?a.visible===0:false;if(a.algo_order_id!==void 0){if(f&&"order_price"in b){let{order_price:Le,...Lt}=b;b=Lt;}B=r(a.algo_order_id.toString(),{...b});}else B=o(a.order_id.toString(),{...b,...Te?{visible_quantity:0}:{}});try{h(!0);let Le=await B;A();}catch(Le){ui.toast.error(Le?.message??`${Le}`);}finally{h(false);}},[r,o]),re=react.useMemo(()=>{let b=g.order_quantity;return b&&Number(b)!==0&&F!==0?new utils.Decimal(b).div(F).mul(100).toDecimalPlaces(2,utils.Decimal.ROUND_DOWN).toNumber():0},[g.order_quantity,F]),de=a.price!=g.order_price||a.quantity!=g.order_quantity||a.trigger_price!=g.trigger_price,Ge=hooks.useThrottledCallback(b=>{let B=new utils.Decimal(b).div(100).mul(F).toDecimalPlaces(T,utils.Decimal.ROUND_DOWN).toNumber();E("order_quantity",hooks.utils.formatNumber(B,q));},50,{}),y=(b,B)=>{E(b,B);};return {...t,curMarkPrice:R,isAlgoOrder:l,isStopMarket:f,price:g.order_price,setPrice:b=>y("order_price",b),priceEdit:!f,triggerPrice:g.trigger_price,setTriggerPrice:b=>y("trigger_price",b),quantity:g.order_quantity,setQuantity:b=>{y("order_quantity",b);},maxQty:F,sliderValue:re,setSliderValue:Ge,onClose:A,onSheetConfirm:X,errors:O,orderType:p,isChanged:de,baseTick:q,dialogOpen:d,setDialogOpen:u,onDialogConfirm:Y,onCloseDialog:v,submitting:C,orderConfirm:P,setOrderConfirm:w}},za=e=>{let{order:t,orderType:r,position:o}=e,[n,i]=react.useState({side:t.side,order_type:r,order_price:t.price,order_quantity:t.quantity,trigger_price:t.trigger_price,reduce_only:t.reduce_only,symbol:t.symbol}),{reduce_only:a}=t,s=o?.position_qty,d=hooks.useMaxQty(t.symbol,t.side,t.reduce_only),u=react.useMemo(()=>a?Math.abs(s??0):t.quantity+Math.abs(d),[t.quantity,d,a,s]),{symbolInfo:l,markPrice:f,errors:x,validate:C}=hooks.useOrderEntity({...n,symbol:t.symbol},{maxQty:u});return {symbolInfo:l,markPrice:f,errors:x,validate:C,setValue:(p,P)=>{i(w=>({...w,[p]:P}));},formattedOrder:n,maxQty:u}};var dr=e=>{let t=lr(e);return jsxRuntime.jsx(nr,{...t})};var ur=e=>{let{state:t}=e,{t:r}=i18n.useTranslation(),{editAlgoOrder:o,editOrder:n}=Z(),{order:i,position:a}=G(),s=react.useCallback(()=>{e.state.type==="tp_sl"?ui.modal.sheet({title:r("common.tpsl"),content:jsxRuntime.jsx(uiTpsl.PositionTPSLSheet,{isEditing:true,order:e.state.item,position:a,symbolInfo:e.state.origin})}).catch(d=>{}):ui.modal.sheet({title:r("orders.editOrder"),classNames:{content:"oui-bg-base-8"},content:jsxRuntime.jsx(dr,{position:a,state:t,editAlgoOrder:o,editOrder:n})}).catch(d=>{});},[t]);return {...t,onShowEditSheet:s}};var cr=e=>{let t=ur(e);return jsxRuntime.jsx(Zt,{...t})};var pr=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui.Button,{variant:"outlined",fullWidth:true,color:"secondary",size:"sm",className:"oui-border-base-contrast-36",onClick:r=>e.setOpen(true),children:t("common.cancel")}),e.open&&jsxRuntime.jsx(ui.SimpleDialog,{size:"xs",open:e.open,onOpenChange:e.setOpen,title:t("orders.cancelOrder"),actions:{primary:{label:t("common.confirm"),loading:e.isLoading,fullWidth:true,size:"md",onClick:r=>{e.onCancel(r);}},secondary:{label:t("common.cancel"),fullWidth:true,size:"md",onClick:()=>{e.onClose();}}},children:jsxRuntime.jsx(ui.Text,{size:"2xs",intensity:54,children:t("orders.cancelOrder.description")})})]})};var fr=e=>{let{state:t}=e,[r,o]=react.useState(false),{onCancelOrder:n}=Z(),[i,a]=react.useState(false);return {...t,open:r,setOpen:o,onCancel:u=>n?(u?.preventDefault(),u?.stopPropagation(),a(true),n(t.item).then(l=>{o(false);},l=>{ui.toast.error(l.message);}).finally(()=>{a(false);})):Promise.resolve(),onClose:()=>{o(false);},isLoading:i}};var gr=e=>{let t=fr(e);return jsxRuntime.jsx(pr,{...t})};var br=e=>{let{t}=i18n.useTranslation();return !e.sl_trigger_price&&!e.tp_trigger_price?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(xt,{classNames:{content:"oui-bg-base-6 oui-ml-2",arrow:"oui-fill-base-6"},content:jsxRuntime.jsxs(ui.Flex,{direction:"column",itemAlign:"start",gap:1,children:[typeof e.pnl?.tpPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${t("tpsl.tpPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:e.quote_dp,color:"buy",showIdentifier:true,children:e.pnl?.tpPnL}),typeof e.pnl?.slPnL<"u"&&jsxRuntime.jsx(ui.Text.numeral,{prefix:jsxRuntime.jsxs(ui.Text,{intensity:80,children:[`${t("tpsl.slPnl")}:`," \xA0"]}),suffix:jsxRuntime.jsx(ui.Text,{intensity:20,children:" USDC"}),dp:e.quote_dp,color:"sell",children:e.pnl?.slPnL})]}),children:jsxRuntime.jsx("button",{onClick:()=>{e.setOpen(!e.open);},children:jsxRuntime.jsxs(ui.Flex,{gap:1,width:"1",children:[e.tp_trigger_price&&jsxRuntime.jsx(Go,{type:"TP",value:e.tp_trigger_price,quote_dp:e.quote_dp}),e.sl_trigger_price&&jsxRuntime.jsx(Go,{type:"SL",value:e.sl_trigger_price,quote_dp:e.quote_dp})]})})})})},Go=e=>{let{type:t,value:r,quote_dp:o}=e;return r?jsxRuntime.jsx(ui.Text.numeral,{size:"2xs",className:ui.cn("oui-border-b oui-border-dashed oui-border-base-contrast-12",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),rule:"price",dp:o,padding:false,rm:utils.Decimal.ROUND_DOWN,prefix:jsxRuntime.jsxs("span",{className:"oui-text-base-contrast-36",children:[`${t} `,":\xA0\xA0"]}),children:r},"tp"):jsxRuntime.jsx(jsxRuntime.Fragment,{})};var Pr=e=>{let{item:t,quote_dp:r,base_dp:o}=e,[n,i]=react.useState(false),{sl_trigger_price:a,tp_trigger_price:s}=react.useMemo(()=>!("algo_type"in t)||!Array.isArray(t.child_orders)?{}:hooks.utils.findTPSLFromOrder(t.child_orders[0]),[t]),{pnl:d,roi:u}=ct(t);return {sl_trigger_price:a,tp_trigger_price:s,pnl:d,roi:u,quote_dp:r,open:n,setOpen:i}};var xr=e=>{let t=Pr(e);return jsxRuntime.jsx(br,{...t})};var Sr=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",gap:2,itemAlign:"start",className:e.className,children:[jsxRuntime.jsx(ds,{...e}),jsxRuntime.jsx(ui.Divider,{intensity:6,className:"oui-w-full"}),jsxRuntime.jsx(us,{...e}),e.type==="pending"&&jsxRuntime.jsx(xr,{...e}),e.type!=="orderHistory"&&jsxRuntime.jsx(cs,{...e})]}),ds=e=>jsxRuntime.jsxs(ui.Flex,{direction:"column",gap:1,width:"100%",children:[jsxRuntime.jsxs(ui.Flex,{justify:"between",width:"100%",children:[jsxRuntime.jsx(To,{...e}),jsxRuntime.jsx(No,{...e})]}),jsxRuntime.jsxs(ui.Flex,{width:"100%",justify:"between",children:[jsxRuntime.jsx(Lo,{...e}),e.type==="orderHistory"&&jsxRuntime.jsx(wo,{...e})]})]}),us=e=>jsxRuntime.jsx(ui.Grid,{cols:3,rows:2,width:"100%",gap:1,children:ms(e)}),cs=e=>jsxRuntime.jsxs(ui.Grid,{cols:3,rows:1,width:"100%",gap:2,children:[jsxRuntime.jsx("div",{}),jsxRuntime.jsx(cr,{state:e}),jsxRuntime.jsx(gr,{state:e})]});function ms(e){switch(e.type){case "all":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "pending":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{...e}),jsxRuntime.jsx(Jt,{...e}),jsxRuntime.jsx(Io,{...e}),jsxRuntime.jsx(Xt,{...e}),jsxRuntime.jsx(vo,{...e}),jsxRuntime.jsx(Eo,{...e})]});case "tp_sl":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ao,{...e}),jsxRuntime.jsx(Fo,{...e}),jsxRuntime.jsx(qo,{...e}),jsxRuntime.jsx(Do,{...e}),jsxRuntime.jsx(ko,{...e})]});case "filled":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "cancelled":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "rejected":return jsxRuntime.jsx(jsxRuntime.Fragment,{});case "orderHistory":return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Gt,{...e}),jsxRuntime.jsx(Jt,{...e}),jsxRuntime.jsx(Xt,{...e,align:"end"}),jsxRuntime.jsx(Ro,{...e}),jsxRuntime.jsx(Bo,{...e}),jsxRuntime.jsx(Mo,{...e})]})}}var _r=e=>{let t=z();return {...e,...t}};var Or=e=>{let{className:t,...r}=e,o=_r(r);return jsxRuntime.jsx(Sr,{...o,className:t})};var hr=e=>{let{sharePnLConfig:t,...r}=e,o=_o({_type:e.type,onSymbolChange:e.onSymbolChange,pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:t,symbolsInfo:e.symbolsInfo});return jsxRuntime.jsx(Ft,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsxRuntime.jsxs(ui.Flex,{direction:"column",width:"100%",height:"100%",itemAlign:"start",children:[e.filterItems.length>0&&jsxRuntime.jsx(ui.DataFilter,{items:e.filterItems,onFilter:n=>{e.onFilter(n);},trailing:["pending","tp_sl"].includes(e.type)&&jsxRuntime.jsx(Os,{...e})}),jsxRuntime.jsx(uiConnector.AuthGuardDataTable,{columns:o,loading:e.isLoading,dataSource:e.dataSource,bordered:true,ignoreLoadingCheck:true,testIds:{body:e.testIds?.tableBody},classNames:{header:"oui-h-[38px]",root:"oui-items-start !oui-h-[calc(100%_-_49px)]"},onRow:(n,i)=>({className:ui.cn("oui-h-[48px]",ne(n)?"oui-text-base-contrast-20":"oui-text-base-contrast-80")}),generatedRowKey:(n,i)=>`${e.type}${i}${n.order_id||n.algo_order_id}_index${i}`,renderRowContainer:(n,i,a)=>((e.type==="tp_sl"||e.type==="pending")&&(a=jsxRuntime.jsx(Bt,{order:n,children:a})),jsxRuntime.jsx(At,{symbol:n.symbol,children:a})),pagination:e.pagination,manualPagination:e.manualPagination,features:[ui.TableFeatures.DownloadFeature],getTableInstance:n=>{e.tableInstance.current=n;}})]})})},Cr=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(Ft,{cancelOrder:e.cancelOrder,editOrder:e.updateOrder,cancelAlgoOrder:e.cancelAlgoOrder,editAlgoOrder:e.updateAlgoOrder,children:jsxRuntime.jsxs(ui.Grid,{cols:1,rows:2,className:"oui-w-full oui-grid-rows-[auto,1fr]",gap:2,children:[e.showFilter?jsxRuntime.jsx(ui.Flex,{gap:2,p:2,className:"oui-rounded-b-xl oui-bg-base-9",children:e.filterItems.map(r=>r.type!=="select"?null:jsxRuntime.jsx(ui.Picker,{options:r.options,size:"sm",value:r.value,className:"oui-text-2xs oui-text-base-contrast-54 ",placeholder:r.name==="side"?t("common.side.all"):r.name==="status"?t("common.status.all"):"",onValueChange:o=>{e.onFilter?.({name:r.name,value:o});}},`item-${r.name}`))}):jsxRuntime.jsx("div",{}),jsxRuntime.jsx(ui.ListView,{className:e.classNames?.root,contentClassName:e.classNames?.content,dataSource:e.dataSource,loadMore:e.loadMore,isLoading:e.isLoading,renderItem:(r,o)=>{let n=jsxRuntime.jsx(Or,{item:r,index:o,className:e.classNames?.cell,type:e.type,onSymbolChange:e.onSymbolChange,sharePnLConfig:e.sharePnLConfig});return ["tp_sl","pending"].includes(e.type)&&(n=jsxRuntime.jsx(Bt,{order:r,children:n})),jsxRuntime.jsx(At,{symbol:r.symbol,children:n})}})]})})},Os=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui.Button,{variant:"outlined",color:"secondary",size:"xs",disabled:(e.dataSource?.length??0)==0,className:"disabled:oui-bg-transport",onClick:r=>e.onCancelAll(),"data-testid":`oui-testid-dataList-${e.type.toLowerCase()}-cancelAll-button`,children:t("orders.cancelAll")})};var tn=e=>react.useMemo(()=>{let r=[];for(let o=0;o<e.length;o++){let n=e[o];if(n.algo_type===types.AlgoOrderRootType.POSITIONAL_TP_SL||n.algo_type===types.AlgoOrderRootType.TP_SL)if(n.algo_status!==types.OrderStatus.FILLED&&n.algo_status!==types.OrderStatus.PARTIAL_FILLED)for(let i=0;i<n.child_orders.length;i++){let a=n.child_orders[i];!a.is_activated||!a.trigger_price||(a.parent_algo_type=n.algo_type,r.push(a));}else for(let i=0;i<n.child_orders.length;i++){let a=n.child_orders[i];a&&(a.algo_status===types.OrderStatus.FILLED||a.algo_status===types.OrderStatus.PARTIAL_FILLED)&&(a.parent_algo_type=n.algo_type,r.push(a));}else r.push(n);}return r},[e]);var Tt=e=>{let{ordersStatus:t,type:r,enableLoadMore:o=false,onSymbolChange:n,filterConfig:i,pnlNotionalDecimalPrecision:a,sharePnLConfig:s}=e,{t:d}=i18n.useTranslation(),u=hooks.useSymbolsInfo(),l=react.useMemo(()=>t!==types.OrderStatus.INCOMPLETE,[t]),f=50,{page:x,pageSize:C,setPage:h,pagination:p,parsePagination:P}=ui.usePagination({pageSize:f});react.useEffect(()=>{h(1);},[e.symbol]);let{orderStatus:w,ordersSide:T,dateRange:q,filterItems:g,onFilter:E,filterDays:W,updateFilterDays:R}=qs(r,{ordersStatus:t,setPage:h,filterConfig:i}),O=react.useMemo(()=>{if(r==="tp_sl")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),L=react.useMemo(()=>{if(r==="pending")return [types.AlgoOrderRootType.POSITIONAL_TP_SL,types.AlgoOrderRootType.TP_SL]},[r]),F=react.useRef();react.useImperativeHandle(e.ref,()=>({download:()=>{let Nt=`orders_${dateFns.format(new Date,"yyyyMMdd_HHmmss")}`;F.current?.download(Nt);}}));let[X,{isLoading:v,loadMore:Y,cancelOrder:A,updateOrder:D,cancelAlgoOrder:re,updateAlgoOrder:de,cancelAllOrders:Ge,cancelAllTPSLOrders:y,meta:b,refresh:B}]=hooks.useOrderStream({symbol:e.symbol,status:w,side:T,page:o||!l?void 0:x,size:l?C:500,sourceTypeAll:r==="orderHistory",dateRange:q,includes:O,excludes:L}),Te=`orderly_${r}_pageSize`,[Le,Lt]=hooks.useLocalStorage(Te,f);react.useEffect(()=>{Le!==C&&Lt(C);},[C,Le]);let sn=react.useCallback(()=>{let Nt=e.type==="pending"?d("orders.pending.cancelAll"):e.type==="tp_sl"?d("orders.tpsl.cancelAll"):"",cn=d("orders.pending.cancelAll.description");ui.modal.confirm({title:Nt,content:jsxRuntime.jsx(ui.Text,{size:"sm",children:cn}),onCancel:async()=>{},onOk:async()=>{try{return r==="tp_sl"?await y():await Ge(),B(),Promise.resolve(!0)}catch(Lr){return Lr?.message!==void 0&&toast.error(Lr.message),Promise.resolve(false)}finally{Promise.resolve();}}});},[r,d]),ln=tn(X??[]),dn=reactApp.useDataTap(r!=="tp_sl"?ln:X,{fallbackData:[]})??void 0,un=react.useMemo(()=>l?P(b):p,[b,l,P,p]);return {type:r,dataSource:dn,isLoading:v,loadMore:Y,cancelOrder:A,updateOrder:D,cancelAlgoOrder:re,updateAlgoOrder:de,pagination:un,manualPagination:l,pnlNotionalDecimalPrecision:a,onFilter:E,filterItems:g,onCancelAll:sn,onSymbolChange:n,sharePnLConfig:s,tableInstance:F,symbolsInfo:u,filterDays:W,updateFilterDays:R}},qs=(e,t)=>{let{t:r}=i18n.useTranslation(),[o,n]=react.useState(t.ordersStatus??"all"),[i,a]=react.useState(t.filterConfig?.side??"all"),[s,d]=react.useState(90),u=t.filterConfig?.range??(e==="all"||e==="orderHistory"?Tr({to:new Date,from:Fe(dateFns.subDays(new Date,89))}):{}),[l,f]=react.useState(u),x=p=>{d(p),f({from:Ve(dateFns.subDays(new Date,p-1)),to:Fe(new Date)}),t.setPage(1);},C=p=>{if(p.name==="side"&&(a(p.value),t.setPage(1)),p.name==="status"&&(n(p.value),t.setPage(1)),p.name==="dateRange"){f(Tr(p.value)),t.setPage(1);let P=Tr(p.value);if(P.from&&P.to){let w=Math.abs(dateFns.differenceInDays(P.from,P.to))+1,q={1:{from:Ve(new Date),to:Fe(new Date)},7:{from:Ve(dateFns.subDays(new Date,6)),to:Fe(new Date)},30:{from:Ve(dateFns.subDays(new Date,29)),to:Fe(new Date)},90:{from:Ve(dateFns.subDays(new Date,89)),to:Fe(new Date)}}[w];q&&It(q.from,P.from)&&It(q.to,P.to)?d(w):d(null);}}};return {filterItems:react.useMemo(()=>{let p={type:"select",name:"side",options:[{label:r("common.side.all"),value:"all"},{label:r("common.buy"),value:"BUY"},{label:r("common.sell"),value:"SELL"}],value:i},P={type:"range",name:"dateRange",value:l},w={type:"select",name:"status",options:[{label:r("common.status.all"),value:"all"},{label:r("orders.status.pending"),value:types.OrderStatus.INCOMPLETE},{label:r("orders.status.filled"),value:types.OrderStatus.FILLED},{label:r("orders.status.partialFilled"),value:types.OrderStatus.PARTIAL_FILLED},{label:r("orders.status.canceled"),value:types.OrderStatus.CANCELLED},{label:r("orders.status.rejected"),value:types.OrderStatus.REJECTED}],value:o};switch(e){case "all":return [p,w,P];case "pending":return [p];case "tp_sl":return [p];case "filled":return [p];case "cancelled":return [p];case "rejected":return [p];case "orderHistory":return [p,w,P]}},[e,i,o,l,r]),onFilter:C,ordersSide:i==="all"?void 0:i,dateRange:l,orderStatus:o==="all"?void 0:o,filterDays:s,updateFilterDays:x}};function Ve(e){if(e==null)return e;let t=new Date(e);return t.setHours(0,0,0,0),t}function Fe(e){if(e==null)return e;let t=new Date(e);return t.setHours(23,59,59,999),t}var Tr=e=>({from:Ve(e.from),to:Fe(e.to??e.from)});var Ce=react.forwardRef((e,t)=>{let{testIds:r,...o}=e,n=Tt({...o,ref:t});return jsxRuntime.jsx(hr,{...n,testIds:r})}),Ms=e=>{let t=Tt({...e,enableLoadMore:true});return jsxRuntime.jsx(Cr,{...t,classNames:e.classNames,showFilter:e.showFilter})};var an=e=>{let{t}=i18n.useTranslation(),r={pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision};return jsxRuntime.jsxs(ui.Tabs,{defaultValue:e.current||"all",variant:"contained",className:"oui-h-full",classNames:{tabsContent:"oui-h-[calc(100%_-_28px)]"},children:[jsxRuntime.jsx(ui.TabPanel,{value:"all",title:t("common.all"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"all",pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:e.sharePnLConfig,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"pending",title:t("orders.status.pending"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"pending",ordersStatus:types.OrderStatus.INCOMPLETE,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"tp_sl",title:t("common.tpsl"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"tp_sl",ordersStatus:types.OrderStatus.INCOMPLETE,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"filled",title:t("orders.status.filled"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"filled",ordersStatus:types.OrderStatus.FILLED,pnlNotionalDecimalPrecision:e.pnlNotionalDecimalPrecision,sharePnLConfig:e.sharePnLConfig,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"cancelled",title:t("orders.status.canceled"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"cancelled",ordersStatus:types.OrderStatus.CANCELLED,...r})}),jsxRuntime.jsx(ui.TabPanel,{value:"rejected",title:t("orders.status.rejected"),children:jsxRuntime.jsx(Ce,{ref:e.orderListRef,type:"rejected",ordersStatus:types.OrderStatus.REJECTED,...r})})]})};var xe=(s=>(s.all="all",s.pending="pending",s.tp_sl="tp_sl",s.filled="filled",s.cancelled="cancelled",s.rejected="rejected",s.orderHistory="orderHistory",s))(xe||{}),Ks=react.forwardRef((e,t)=>{let r=wt({...e,ref:t});return jsxRuntime.jsx(an,{...r})});
20
20
 
21
21
  exports.DesktopOrderList = hr;
22
- exports.DesktopOrderListWidget = he;
22
+ exports.DesktopOrderListWidget = Ce;
23
23
  exports.MobileOrderList = Cr;
24
24
  exports.MobileOrderListWidget = Ms;
25
25
  exports.OrdersWidget = Ks;
26
- exports.TabType = Pe;
26
+ exports.TabType = xe;
27
27
  exports.useOrderListScript = Tt;
28
28
  exports.useOrdersScript = wt;
29
29
  //# sourceMappingURL=out.js.map