@kodiak-finance/orderly-ui-order-entry 2.8.9 → 2.8.10-rc.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
@@ -69,6 +69,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
69
69
  setSoundAlert: (value: boolean) => void;
70
70
  currentFocusInput: react.MutableRefObject<InputType>;
71
71
  symbolLeverage: number | undefined;
72
+ effectiveLeverageResult: _kodiak_finance_orderly_hooks.EffectiveLeverageResult;
72
73
  submit: (options?: {
73
74
  resetOnSuccess?: boolean;
74
75
  }) => Promise<{
package/dist/index.d.ts CHANGED
@@ -69,6 +69,7 @@ declare const useOrderEntryScript: (inputs: OrderEntryScriptInputs) => {
69
69
  setSoundAlert: (value: boolean) => void;
70
70
  currentFocusInput: react.MutableRefObject<InputType>;
71
71
  symbolLeverage: number | undefined;
72
+ effectiveLeverageResult: _kodiak_finance_orderly_hooks.EffectiveLeverageResult;
72
73
  submit: (options?: {
73
74
  resetOnSuccess?: boolean;
74
75
  }) => Promise<{
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ki = require('react');
3
+ var Ai = require('react');
4
4
  var orderlyHooks = require('@kodiak-finance/orderly-hooks');
5
5
  var orderlyI18n = require('@kodiak-finance/orderly-i18n');
6
6
  var orderlyReactApp = require('@kodiak-finance/orderly-react-app');
@@ -16,16 +16,16 @@ var orderlyUiLeverage = require('@kodiak-finance/orderly-ui-leverage');
16
16
 
17
17
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
18
 
19
- var ki__default = /*#__PURE__*/_interopDefault(ki);
19
+ var Ai__default = /*#__PURE__*/_interopDefault(Ai);
20
20
 
21
- var De=e=>{let{pinned:t,orderTypeExtra:r}=e,{t:o}=orderlyI18n.useTranslation(),i=n=>s=>{e.onValueChange&&e.onValueChange("order_type_ext",s?n:"");};return ki.useEffect(()=>{e.onValueChange?.("visible_quantity",e.hidden?0:1);},[e.hidden]),jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-54",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:t?"start":"between",mb:3,width:t?"unset":"100%",className:"oui-gap-x-2 md:oui-gap-x-3",wrap:"wrap",gapY:1,children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-postOnly-checkBox",id:"toggle_order_post_only",className:"oui-peer",color:"white",variant:"radio",disabled:!e.showExtra,checked:r===orderlyTypes.OrderType.POST_ONLY,onCheckedChange:i(orderlyTypes.OrderType.POST_ONLY)}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_post_only",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.postOnly")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-ioc-checkBox",id:"toggle_order_iov",color:"white",className:"oui-peer",variant:"radio",checked:r===orderlyTypes.OrderType.IOC,onCheckedChange:i(orderlyTypes.OrderType.IOC),disabled:!e.showExtra}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_iov",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.ioc")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-fox-checkBox",id:"toggle_order_fok",color:"white",variant:"radio",className:"oui-peer",checked:r===orderlyTypes.OrderType.FOK,onCheckedChange:i(orderlyTypes.OrderType.FOK),disabled:!e.showExtra}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_fok",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.fok")})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{gapX:6,children:[jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-orderConfirm-checkBox",id:"toggle_order_confirm",color:"white",checked:e.needConfirm,onCheckedChange:n=>{e.setNeedConfirm(!!n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_confirm",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.orderConfirm")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-hidden-checkBox",id:"toggle_order_hidden",color:"white",checked:e.hidden,onCheckedChange:n=>{e.setHidden(n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_hidden",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.hidden")})]})]}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-3"}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Switch,{"data-testid":"oui-testid-orderEntry-additional-keepVisible-switch",id:"toggle_order_keep_visible",onCheckedChange:n=>{e.setPinned(n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_keep_visible",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.keepVisible")})]})]})]})};function Yr(e){let[t,r]=ki.useState(false);return jsxRuntime.jsxs(orderlyUi.PopoverRoot,{open:t,onOpenChange:r,children:[jsxRuntime.jsx(orderlyUi.PopoverTrigger,{asChild:true,children:jsxRuntime.jsx("button",{"data-testid":"oui-testid-orderEntry-additional-button",onClick:()=>{r(true);},children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-white/[.36] hover:oui-fill-white/80",children:jsxRuntime.jsx("path",{d:"M3.332 2.665a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm-8 4a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm-8 4a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667z"})})})}),jsxRuntime.jsx(orderlyUi.PopoverContent,{side:"top",align:"end",className:"oui-w-[230px]",children:jsxRuntime.jsx(De,{...e})})]})}var $r="M10.007 1.302a.74.74 0 0 0-.486.214c-1.033.989-1.349 1.815-.972 2.948-.88.675-1.437.84-2.536.84-1.503 0-2.484.182-3.152.85v.02a1.583 1.583 0 0 0 0 2.248l1.867 1.882-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.194 1.87 1.861a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.523.854-3.144 0-1.03.212-1.758.852-2.523 1.233.361 1.95.015 2.961-.995a.68.68 0 0 0 .188-.48c0-.234-.06-.593-.209-1.04a5.34 5.34 0 0 0-1.312-2.103 5.35 5.35 0 0 0-2.104-1.312c-.448-.15-.808-.208-1.042-.208",Zr=e=>{let[t,r]=ki.useState($r);return jsxRuntime.jsx("button",{...e,children:jsxRuntime.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",focusable:false,onMouseEnter:()=>{r('M10.008 1.302a.74.74 0 0 0-.486.214c-1.033.989-1.349 1.815-.972 2.948-.88.675-1.437.84-2.536.84-1.503 0-2.484.182-3.152.85v.02a1.583 1.583 0 0 0 0 2.248l1.867 1.882-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.194 1.87 1.861a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.523.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.48c0-.234-.06-.593-.209-1.04a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.15-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.107.507.508.94 1.13 1.119 1.945-.636.61-1.026.658-1.662.323a.67.67 0 0 0-.779.117c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.292-.076 1.773-.48 2.206-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.515 2.226-.514 1.742.001 2.668-.448 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.686-.29-1.047.321-1.67"');},onMouseLeave:()=>{r($r);},className:"oui-text-primary-darken",children:jsxRuntime.jsx("path",{d:t})})})};function Xr(e){let{order:t,symbolInfo:r,onEdit:o,onDelete:i,errors:n}=e,{getErrorMsg:s}=orderlyReactApp.useOrderEntryFormErrorMsg(n),{t:a}=orderlyI18n.useTranslation(),l=()=>{let p=s("tp_trigger_price");return t.tp_trigger_price||t.tp_order_price?jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",gapY:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.tpTriggerPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.tp_trigger_price??""})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.tpOrderPrice")}),t.tp_order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.tp_order_price??""}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:"Market"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.totalEstTpPnl")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),coloring:true,dp:2,children:Number(t.tp_pnl)})]})]}),p&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"start",gap:2,className:"oui-w-full",children:[jsxRuntime.jsx("div",{className:"oui-relative oui-top-[7px] oui-size-1 oui-rounded-full oui-bg-danger"}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-danger",children:p})]})]}):null},c=()=>{if(t.sl_trigger_price||t.sl_order_price){let p=s("sl_trigger_price");return jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full",gap:4,children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",gapY:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.slTriggerPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.sl_trigger_price??""})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.slOrderPrice")}),t.sl_order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.sl_order_price??""}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:"Market"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.totalEstSlPnl")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{coloring:true,suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),dp:2,children:Number(t.sl_pnl)})]}),p&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"start",gap:2,className:"oui-w-full",children:[jsxRuntime.jsx("div",{className:"oui-relative oui-top-[7px] oui-size-1 oui-rounded-full oui-bg-danger"}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-danger",children:p})]})]})})}return null};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full oui-text-2xs",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"start",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.advanced.title")}),jsxRuntime.jsxs(orderlyUi.Flex,{gap:2,children:[jsxRuntime.jsx(dn,{size:12,className:"oui-cursor-pointer oui-text-base-contrast-54 hover:oui-text-base-contrast",opacity:1,onClick:i}),jsxRuntime.jsx(cn,{size:12,className:"oui-cursor-pointer oui-text-base-contrast-54 hover:oui-text-base-contrast",onClick:o})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"start",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.mode")}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:t.position_type===orderlyTypes.PositionType.FULL?a("tpsl.fullPosition"):a("tpsl.partialPosition")})]}),l(),c(),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mb-2 oui-w-full"})]})}var dn=e=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.size,height:e.size,viewBox:"0 0 12 12",fill:"currentColor",...e,children:jsxRuntime.jsx("path",{d:"M5.99903 0.976562C5.44653 0.976562 4.99903 1.42406 4.99903 1.97656H2.49902C2.22302 1.97656 1.99902 2.20056 1.99902 2.47656C1.99902 2.75256 2.22302 2.97656 2.49902 2.97656H9.49903C9.77503 2.97656 9.99903 2.75256 9.99903 2.47656C9.99903 2.20056 9.77503 1.97656 9.49903 1.97656H6.99903C6.99903 1.42406 6.55153 0.976562 5.99903 0.976562ZM2.49902 3.97655V8.97654C2.49902 10.0715 3.40152 10.961 4.49903 10.961L7.51453 10.9765C8.61203 10.9765 9.49903 10.074 9.49903 8.97654V3.97655H2.49902ZM4.99903 5.47655C5.27503 5.47655 5.49903 5.70055 5.49903 5.97655V8.97654C5.49903 9.25254 5.27503 9.47654 4.99903 9.47654C4.72303 9.47654 4.49903 9.25254 4.49903 8.97654V5.97655C4.49903 5.70055 4.72303 5.47655 4.99903 5.47655ZM6.99903 5.47655C7.27503 5.47655 7.49903 5.70055 7.49903 5.97655V8.97654C7.49903 9.25254 7.27503 9.47654 6.99903 9.47654C6.72303 9.47654 6.49903 9.25254 6.49903 8.97654V5.97655C6.49903 5.70055 6.72303 5.47655 6.99903 5.47655Z"})}),cn=e=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",width:e.size,height:e.size,fill:"currentColor",...e,children:jsxRuntime.jsx("path",{d:"M8.49779 0.976562C8.36529 0.976562 8.23229 1.02357 8.13829 1.11707C7.86029 1.39507 6.85979 2.39558 6.63779 2.61808L2.13529 7.12059L1.63479 7.62059C1.56529 7.69059 1.52929 7.78958 1.50979 7.88658L1.00979 10.3881C0.939788 10.7381 1.23779 11.0361 1.58779 10.9666C1.90079 10.9036 3.77679 10.5286 4.08929 10.4661C4.18629 10.4466 4.28529 10.4106 4.35529 10.3411L4.85529 9.84059L9.35779 5.33808C9.58029 5.11608 10.5808 4.11506 10.8588 3.83756C10.9523 3.74356 10.9993 3.61056 10.9993 3.47806C10.9993 2.65956 10.7908 2.07456 10.3583 1.63306C9.92179 1.18756 9.33879 0.976562 8.49779 0.976562ZM8.69479 1.98606C9.14629 2.01256 9.43879 2.11608 9.63929 2.32108C9.84429 2.53008 9.97379 2.82008 10.0018 3.26258C9.72779 3.53608 9.32679 3.93106 8.99829 4.25956C8.60179 3.86306 8.11279 3.37407 7.71629 2.97757C8.04529 2.64907 8.42129 2.25956 8.69479 1.98606ZM6.99729 3.69657L8.27929 4.97858L4.49579 8.76207L3.21379 7.48009L6.99729 3.69657ZM2.49479 8.19908L3.77679 9.48107L3.72979 9.52809C3.39979 9.59409 2.73329 9.73359 2.11929 9.85659L2.44779 8.24608L2.49479 8.19908Z"})});var Je=ki__default.default.forwardRef((e,t)=>{let r=ki.useId();return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:14,height:14,viewBox:"0 0 14 14",fill:"currentColor",ref:t,focusable:false,...e,children:[jsxRuntime.jsx("path",{d:"M6.16411 1.53106C6.61974 1.07566 7.35888 1.07551 7.81442 1.53106L8.48833 2.20496C8.6797 2.39624 8.93064 2.51452 9.19755 2.54106L9.3132 2.54676H10.2662C10.9104 2.54691 11.4328 3.06926 11.4329 3.71343V4.66647C11.4329 4.97589 11.5559 5.27312 11.7747 5.49191L12.4492 6.16582C12.9047 6.62142 12.9047 7.36054 12.4492 7.81613L11.7753 8.49004L11.6972 8.57549C11.5272 8.78302 11.433 9.04426 11.4329 9.31491V10.2685L11.4272 10.3876C11.3715 10.9366 10.9348 11.373 10.3859 11.4289L10.2662 11.4352H9.3132L9.19755 11.4409C8.93066 11.4674 8.67969 11.5857 8.48833 11.777L7.81442 12.4509L7.72555 12.5306C7.29789 12.8795 6.68066 12.8794 6.25297 12.5306L6.16411 12.4509L5.4902 11.777C5.29887 11.5857 5.04786 11.4675 4.78097 11.4409L4.66533 11.4352H3.71171L3.59265 11.4289C3.04358 11.3731 2.60705 10.9367 2.55131 10.3876L2.54505 10.2685V9.31491C2.54499 9.04416 2.45089 8.78306 2.28072 8.57549L2.20325 8.49004L1.52934 7.81613C1.10213 7.38905 1.07534 6.71297 1.44902 6.25469L1.52934 6.16582L2.20382 5.49191C2.42248 5.27314 2.54505 4.97579 2.54505 4.66647V3.71343C2.54513 3.10945 3.00442 2.61221 3.59265 2.55246L3.71171 2.54676H4.66533L4.78097 2.54106C5.00968 2.51826 5.22694 2.4281 5.40475 2.28244L5.4902 2.20496L6.16411 1.53106ZM6.31507 3.02983C5.87756 3.46727 5.28401 3.71336 4.66533 3.71343H3.71171V4.66647C3.71171 5.28521 3.46614 5.87922 3.02869 6.31678L2.35421 6.99069L3.02812 7.6646C3.46577 8.10214 3.71164 8.69607 3.71171 9.31491V10.2685H4.66533C5.28396 10.2686 5.87757 10.5142 6.31507 10.9515L6.98898 11.6255L7.66289 10.9515C8.10045 10.5141 8.69446 10.2685 9.3132 10.2685H10.2662V9.31491C10.2663 8.69604 10.5127 8.10214 10.9504 7.6646L11.6243 6.99069L10.9498 6.31678C10.5122 5.8792 10.2662 5.28531 10.2662 4.66647V3.71343H9.3132C8.69438 3.71343 8.10047 3.46739 7.66289 3.02983L6.98898 2.35592L6.31507 3.02983ZM8.52934 4.64255C8.7571 4.41479 9.12639 4.41489 9.35421 4.64255C9.58202 4.87035 9.58202 5.23961 9.35421 5.46742L5.4657 9.35593C5.2379 9.58372 4.86863 9.58373 4.64083 9.35593C4.41318 9.12811 4.41308 8.75881 4.64083 8.53106L8.52934 4.64255ZM8.66435 7.83265C9.1245 7.83272 9.49777 8.2059 9.49777 8.66607C9.49769 9.12616 9.12445 9.49941 8.66435 9.49948C8.20419 9.49948 7.83101 9.12621 7.83094 8.66607C7.83094 8.20586 8.20415 7.83265 8.66435 7.83265ZM5.33126 4.49956C5.79141 4.49963 6.16468 4.87282 6.16468 5.33298C6.1646 5.79307 5.79136 6.16575 5.33126 6.16582C4.87111 6.16582 4.49793 5.79311 4.49785 5.33298C4.49785 4.87277 4.87106 4.49956 5.33126 4.49956Z",fill:`url(#${r})`}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:r,x1:"12.7908",y1:"6.99084",x2:"1.1875",y2:"6.99084",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-end))"}),jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-start))",offset:1})]})})]})});process.env.NODE_ENV!=="production"&&(Je.displayName="EffectiveFee");var xn=e=>{let{content:t}=e,{isMobile:r}=orderlyUi.useScreen(),{t:o}=orderlyI18n.useTranslation();return r?jsxRuntime.jsx(Je,{onClick:()=>{orderlyUi.modal.dialog({title:o("common.tips"),content:t});}}):jsxRuntime.jsx(orderlyUi.Tooltip,{content:t,className:"oui-p-1.5 oui-text-base-contrast-54",children:jsxRuntime.jsx(Je,{className:"oui-cursor-pointer"})})},Dt=e=>{let{t}=orderlyI18n.useTranslation(),{effectiveTakerFee:r,effectiveMakerFee:o}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:t("common.fees")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),": --% /"," ",t("portfolio.feeTier.column.maker"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:r}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:"/"}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.maker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:o})]})})]}),jsxRuntime.jsx(xn,{content:t("portfolio.feeTier.effectiveFee.tooltip")})]})};var zt=e=>jsxRuntime.jsx(Dt,{...e});var Qt=e=>{let{t}=orderlyI18n.useTranslation(),{takerFee:r,makerFee:o}=e;return jsxRuntime.jsx(orderlyUi.Flex,{itemAlign:"center",justify:"between",width:"100%",gap:1,children:jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:t("common.fees")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),": --% /"," ",t("portfolio.feeTier.column.maker"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:r}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:"/"}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.maker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:o})]})})]})})};var Gt=e=>jsxRuntime.jsx(Qt,{...e});var Pn=e=>typeof e<"u"&&e!==null,Wt=()=>{let{refereeRebate:e,...t}=orderlyHooks.useFeeState();return Pn(e)?jsxRuntime.jsx(zt,{...ramda.pick(["effectiveTakerFee","effectiveMakerFee"],t)}):jsxRuntime.jsx(Gt,{...ramda.pick(["takerFee","makerFee"],t)})};var so=[.01,.05,.1],lo=ki.forwardRef((e,t)=>{let{t:r}=orderlyI18n.useTranslation(),[o,i]=ki.useState(),[n,s]=ki.useState(""),[a,l]=ki.useState(void 0);ki.useImperativeHandle(t,()=>({getValue:()=>n?new orderlyUtils.Decimal(n)?.toNumber():o})),ki.useEffect(()=>{e.initialValue&&!so.includes(e.initialValue)?s(e.initialValue.toString()):i(e.initialValue);},[e.initialValue,open]);let c=m=>{i(m),s(""),l(void 0);},p=m=>{if(!m){s(m);return}let d=new orderlyUtils.Decimal(m);i(void 0),d.gt(3)?(s("3"),l(r("orderEntry.slippage.error.exceed"))):(s(m),l(void 0));},u=e.isMobile?jsxRuntime.jsx("button",{onClick:()=>{orderlyUi.modal.alert({title:r("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:r("orderEntry.slippage.tips")})});},children:jsxRuntime.jsx(orderlyUi.ExclamationFillIcon,{className:"oui-text-base-contrast-54",size:16})}):jsxRuntime.jsx(orderlyUi.Tooltip,{content:jsxRuntime.jsx(orderlyUi.Text,{intensity:80,size:"2xs",children:r("orderEntry.slippage.tips")}),className:"oui-w-[260px] oui-bg-base-6",arrow:{className:"oui-fill-base-6"},children:jsxRuntime.jsx(orderlyUi.TooltipTrigger,{children:jsxRuntime.jsx(orderlyUi.ExclamationFillIcon,{className:"oui-text-base-contrast-54",size:16})})});return jsxRuntime.jsxs("div",{className:"oui-text-2xs",children:[jsxRuntime.jsxs(orderlyUi.Flex,{mb:2,gapX:1,children:[jsxRuntime.jsx(orderlyUi.Text,{size:"xs",children:r("orderEntry.slippage")}),u]}),jsxRuntime.jsxs(orderlyUi.Flex,{gapX:2,children:[so.map(m=>jsxRuntime.jsx(Rn,{value:m,isActive:o===m,onClick:()=>{c(m);}},m)),jsxRuntime.jsx(orderlyUi.Input,{suffix:"%",formatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(2)],value:n,onValueChange:p,classNames:{root:orderlyUi.cn("oui-rounded-md oui-bg-base-6","oui-h-[40px] oui-w-[74px]"),input:"oui-text-base-contrast",additional:"oui-pl-1"}})]}),!!a&&jsxRuntime.jsx(orderlyUi.Box,{mt:5,className:"-oui-mb-5",children:jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",color:"danger",children:a})})]})}),Rn=({value:e,isActive:t,onClick:r})=>jsxRuntime.jsx(orderlyUi.Flex,{intensity:600,justify:"center",itemAlign:"center",r:"md",width:74,height:40,className:orderlyUi.cn("oui-cursor-pointer oui-select-none",t&&"oui-bg-primary-light"),onClick:r,children:jsxRuntime.jsxs(orderlyUi.Text,{size:"sm",intensity:80,children:[e,"%"]})});var uo=e=>{let{t}=orderlyI18n.useTranslation(),[r,{setTrue:o,setFalse:i,toggle:n}]=orderlyHooks.useBoolean(false),{isMobile:s}=orderlyUi.useScreen(),a=ki.useRef(null),l=()=>{let c=a.current?.getValue();return e.setSlippage(c?c.toString():"1"),i(),Promise.resolve(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.SimpleDialog,{open:r,onOpenChange:n,title:t("common.settings"),contentProps:{size:s?"xs":"sm"},actions:{primary:{disabled:false,label:t("common.save"),onClick:l},secondary:{label:t("common.cancel"),onClick:()=>i()}},children:jsxRuntime.jsx(lo,{ref:a,isMobile:s,initialValue:e.slippage?Number(e.slippage):void 0})}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:t("orderEntry.slippage")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{size:"2xs",children:[t("orderEntry.slippage.est"),": -% / ",t("common.max"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{size:"2xs",rule:"percentages",prefix:`${t("orderEntry.slippage.est")}: `,suffix:` / ${t("common.max")}: `,children:e.estSlippage??0}),jsxRuntime.jsx("button",{className:"oui-text-2xs",onClick:()=>o(),children:jsxRuntime.jsxs(orderlyUi.Flex,{className:"oui-gap-0.5",as:"span",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-primary",children:`${e.slippage||"-"}%`}),jsxRuntime.jsx(orderlyUi.EditIcon,{className:"oui-text-primary oui-hidden md:oui-block",size:12,opacity:1})]})})]})})]})]})};var co=e=>jsxRuntime.jsx(uo,{...e});function fo(e){let{canTrade:t,disableFeatures:r,orderType:o}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-space-y-[2px] xl:oui-space-y-1",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:i("orderEntry.estLiqPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:e.quote,size:"2xs",dp:e.dp,className:"oui-text-base-contrast-80",unitClassName:"oui-ml-1 oui-text-base-contrast-36",children:t?e.estLiqPrice??"--":"--"})]}),o===orderlyTypes.OrderType.MARKET&&!r?.includes("slippageSetting")&&jsxRuntime.jsx(co,{slippage:e.slippage,setSlippage:e.setSlippage,estSlippage:e.estSlippage}),!r?.includes("feesInfo")&&jsxRuntime.jsx(Wt,{})]})}var jn=e=>e>=0&&e<50?"oui-text-success":e>=50&&e<80?"oui-text-warning":e>=80?"oui-text-danger":"",$t=e=>{let{t}=orderlyI18n.useTranslation(),{ltv_threshold:r,negative_usdc_threshold:o,isThresholdLoading:i,holdingData:n=[],currentLtv:s,onConvert:a}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,className:"oui-w-72 oui-max-w-72",direction:"column",children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("common.assets")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("transfer.deposit.collateralContribution")})]}),n.map((l,c)=>jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:80,size:"xs",children:l.token}),jsxRuntime.jsx(orderlyUi.Text,{size:"xs",intensity:80,className:orderlyUi.cn(Number(l.collateralContribution)<0&&"oui-text-warning"),children:orderlyUtils.removeTrailingZeros(l.collateralContribution)})]},`item-${c}`)),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full"}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("transfer.LTV.currentLTV")}),jsxRuntime.jsxs(orderlyUi.Text,{size:"xs",intensity:36,className:orderlyUi.cn("oui-select-none",jn(s)),children:[s,"%"]})]}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-py-2",intensity:54,size:"2xs",children:t("transfer.LTV.tooltip",{threshold:i?"-":r,usdcThreshold:i?"-":o})}),jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,size:"md",variant:"outlined",color:"secondary",onClick:a,children:t("transfer.convert.convertAssets")})]})};var as=()=>{let{data:e,error:t,isLoading:r}=orderlyHooks.useQuery("/v1/public/auto_convert_threshold",{errorRetryCount:3});return {ltv_threshold:new orderlyUtils.Decimal(e?.ltv_threshold??0).mul(100).toNumber(),negative_usdc_threshold:e?.negative_usdc_threshold,isLoading:r,error:t}},Zt=()=>{let{data:e=[],isLoading:t}=orderlyHooks.useHoldingStream(),{ltv_threshold:r,negative_usdc_threshold:o,isLoading:i}=as(),n=orderlyHooks.useTokensInfo(),{getIndexPrice:s}=orderlyHooks.useIndexPricesStream(),a=e.map(p=>{let u=n?.find(({token:T})=>T===p.token),m=s(p.token),d=u?orderlyPerp.account.collateralRatio({baseWeight:u.base_weight??0,discountFactor:u.discount_factor??0,collateralQty:p.holding,collateralCap:u?.user_max_qty??p.holding,indexPrice:m}):orderlyUtils.zero,C=orderlyPerp.account.collateralContribution({collateralQty:p.holding,collateralCap:u?.user_max_qty??p.holding,collateralRatio:d.toNumber(),indexPrice:m});return {...p,collateralContribution:C}}),l=orderlyHooks.useComputedLTV(),c=ki.useCallback(async()=>orderlyUi.modal.show("ConvertDialogId"),[]);return {holdingData:a,isHoldingLoading:t,ltv_threshold:r,negative_usdc_threshold:o,isThresholdLoading:i,currentLtv:l,onConvert:c}};var it=()=>{let e=Zt();return jsxRuntime.jsx($t,{...e})};var _o=e=>{let{canTrade:t,currentLtv:r,quote:o,freeCollateral:i}=e,{t:n}=orderlyI18n.useTranslation(),s=ki.useMemo(()=>typeof r=="number"&&!Number.isNaN(r)&&r>0,[r]);return jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:n("common.available")}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"center",gap:1,children:[s&&jsxRuntime.jsx(orderlyUi.Tooltip,{className:"oui-bg-base-6 oui-p-2",content:jsxRuntime.jsx(it,{}),children:jsxRuntime.jsx(orderlyUi.InfoCircleIcon,{className:"oui-cursor-pointer oui-text-warning oui-opacity-80"})}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:o,size:"2xs",className:"oui-text-base-contrast-80",unitClassName:"oui-ml-1 oui-text-base-contrast-54",dp:2,padding:false,children:t?i:0})]})]})};function Fe(e){let{order_type:t,order_type_ext:r}=e,o=[orderlyTypes.OrderType.ASK,orderlyTypes.OrderType.BID].includes(r);return t?t===orderlyTypes.OrderType.LIMIT&&o:o}function Oo(e,t){if([orderlyTypes.BBOOrderType.COUNTERPARTY1,orderlyTypes.BBOOrderType.COUNTERPARTY5].includes(e))return t===orderlyTypes.OrderSide.BUY?orderlyTypes.OrderType.ASK:orderlyTypes.OrderType.BID;if([orderlyTypes.BBOOrderType.QUEUE1,orderlyTypes.BBOOrderType.QUEUE5].includes(e))return t===orderlyTypes.OrderSide.BUY?orderlyTypes.OrderType.BID:orderlyTypes.OrderType.ASK}function Po(e){if([orderlyTypes.BBOOrderType.COUNTERPARTY1,orderlyTypes.BBOOrderType.QUEUE1].includes(e))return orderlyTypes.OrderLevel.ONE;if([orderlyTypes.BBOOrderType.COUNTERPARTY5,orderlyTypes.BBOOrderType.QUEUE5].includes(e))return orderlyTypes.OrderLevel.FIVE}function ho(e){let t=e?.data?.rows||[];if(t.length>0){let r=t.length,o=t.filter(i=>i.success).length;return o===r?orderlyI18n.i18n.t("orderEntry.scaledOrder.fullySuccessful",{total:r}):o===0?orderlyI18n.i18n.t("orderEntry.scaledOrder.allFailed"):orderlyI18n.i18n.t("orderEntry.scaledOrder.partiallySuccessful",{successCount:o,total:r})}}var Xt=e=>Number.isNaN(Number(e))?0:Number(e);var rr=e=>{let{symbolInfo:t,order:r,onConfirm:o,onCancel:i}=e,{quote:n,quote_dp:s,base_dp:a}=t,{side:l,order_type:c,order_type_ext:p,level:u,symbol:m}=r,{t:d}=orderlyI18n.useTranslation(),[{rows:C}]=orderlyHooks.usePositionStream(m),O=C?.[0]?.position_qty,[h,L]=orderlyHooks.useLocalStorage("orderly_order_confirm",true),E=()=>r.position_type===orderlyTypes.PositionType.FULL?jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.positionType.full")}):jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.positionType.partial")}),Z=()=>{if(c===orderlyTypes.OrderType.MARKET||c===orderlyTypes.OrderType.STOP_MARKET)return jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:d("common.marketPrice")});if(Fe({order_type:c,order_type_ext:p})){let B=orderlyUtils.getBBOType({type:p,side:l,level:u}),j={[orderlyTypes.BBOOrderType.COUNTERPARTY1]:d("orderEntry.bbo.counterparty1"),[orderlyTypes.BBOOrderType.COUNTERPARTY5]:d("orderEntry.bbo.counterparty5"),[orderlyTypes.BBOOrderType.QUEUE1]:d("orderEntry.bbo.queue1"),[orderlyTypes.BBOOrderType.QUEUE5]:d("orderEntry.bbo.queue5")}[B];return jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:j})}return jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:n,rule:"price",className:"oui-text-base-contrast",unitClassName:"oui-text-base-contrast-36 oui-ml-1",dp:s,padding:false,children:r.order_price})},F=({price:B,isOrderPrice:j,isEnable:ie,colorType:xe})=>ie?!B&&j?jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36",children:d("common.marketPrice")}):jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:"USDC",rule:"price",className:orderlyUi.cn("oui-text-base-contrast",xe==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),unitClassName:"oui-text-base-contrast-36 oui-ml-1",dp:s,padding:false,children:B}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36",children:"-- USDC"}),ue=()=>{if(!O||!r.order_quantity)return null;let B=new orderlyUtils.Decimal(r.order_quantity);return r.position_type===orderlyTypes.PositionType.FULL&&(B=B.plus(new orderlyUtils.Decimal(O??0))),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:r.position_type===orderlyTypes.PositionType.FULL?d("common.positionQty"):d("common.orderQty")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:a,padding:false,className:"oui-text-base-contrast",children:B.toNumber()})]})},ye=()=>{if(c===orderlyTypes.OrderType.TRAILING_STOP){let{activated_price:B,callback_value:j,callback_rate:ie}=r,xe=ie?jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("orderEntry.trailingRate")}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-base-contrast",children:[ie,"%"]})]}):jsxRuntime.jsx(st,{title:d("orderEntry.trailingValue"),value:j,unit:n,dp:s});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[B&&jsxRuntime.jsx(st,{title:d("common.triggerPrice"),value:B,unit:n,dp:s}),xe]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("common.price")}),Z()]}),jsxRuntime.jsx(st,{title:d("common.estTotal"),value:r.total,unit:n,dp:s})]})},U=jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"symbol",showIcon:true,children:r.symbol}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"end",gapX:1,children:[jsxRuntime.jsx(Os,{type:c}),l===orderlyTypes.OrderSide.BUY?jsxRuntime.jsx(orderlyUi.Badge,{color:"buy",size:"sm",children:d("common.buy")}):jsxRuntime.jsx(orderlyUi.Badge,{color:"sell",size:"sm",children:d("common.sell")})]})]}),K=jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("common.orderQty")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:a,padding:false,className:"oui-text-base-contrast",children:r.order_quantity})]}),f=(c===orderlyTypes.OrderType.STOP_LIMIT||c===orderlyTypes.OrderType.STOP_MARKET&&r.trigger_price)&&jsxRuntime.jsx(st,{title:d("common.trigger"),value:r.trigger_price,unit:n,dp:s}),Y=(r.tp_trigger_price||r.sl_trigger_price)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-4"}),jsxRuntime.jsxs("div",{className:orderlyUi.textVariants({size:"sm",intensity:54,className:"oui-space-y-1 oui-w-full oui-flex oui-flex-col oui-gap-3"}),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:E()}),ue(),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",itemAlign:"start",gap:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.tpTriggerPrice")}),F({price:r.tp_trigger_price??"",isOrderPrice:false,isEnable:!!r.tp_trigger_price,colorType:"TP"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.tpOrderPrice")}),F({price:r.tp_order_price??"",isOrderPrice:true,isEnable:!!r.tp_trigger_price,colorType:"TP"})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",itemAlign:"start",gap:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.slTriggerPrice")}),F({price:r.sl_trigger_price??"",isOrderPrice:false,isEnable:!!r.sl_trigger_price,colorType:"SL"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.slOrderPrice")}),F({price:r.sl_order_price??"",isOrderPrice:true,isEnable:!!r.sl_trigger_price,colorType:"SL"})]})]})]})]}),de=jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,pt:4,pb:5,children:[jsxRuntime.jsx(orderlyUi.Checkbox,{id:"orderConfirm",color:"white",onCheckedChange:B=>{L(!B);}}),jsxRuntime.jsx("label",{htmlFor:"orderConfirm",className:orderlyUi.textVariants({size:"xs",intensity:54}),children:d("orderEntry.disableOrderConfirm")})]}),be=jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:3,children:[jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"md",onClick:()=>i(),children:d("common.cancel")}),jsxRuntime.jsx(orderlyUi.Button,{size:"md",onClick:()=>o(),children:d("common.confirm")})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[U,jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-4"}),jsxRuntime.jsxs("div",{className:orderlyUi.textVariants({size:"sm",intensity:54,className:"oui-space-y-1"}),children:[K,f,ye()]}),Y,de,be]})},st=e=>{let{title:t,value:r,unit:o,dp:i}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:t}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:o,rule:"price",dp:i,padding:false,className:"oui-text-base-contrast",unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:r})]})};rr.displayName="OrderConfirmDialog";var Os=e=>{let{t}=orderlyI18n.useTranslation(),r=ki.useMemo(()=>{switch(e.type){case orderlyTypes.OrderType.LIMIT:return t("orderEntry.orderType.limit");case orderlyTypes.OrderType.MARKET:return t("common.marketPrice");case orderlyTypes.OrderType.STOP_LIMIT:return t("orderEntry.orderType.stopLimit");case orderlyTypes.OrderType.STOP_MARKET:return t("orderEntry.orderType.stopMarket");case orderlyTypes.OrderType.TRAILING_STOP:return t("orderEntry.orderType.trailingStop");default:return ""}},[e.type]);return jsxRuntime.jsx(orderlyUi.Badge,{color:"neutral",size:"sm",children:r})},Ps=e=>{let{close:t,resolve:r,reject:o,...i}=e;return jsxRuntime.jsx(rr,{...i,onCancel:()=>{o(),t();},onConfirm:()=>{r(),t();}})},or="orderConfirm";orderlyUi.registerSimpleDialog(or,Ps,{size:"sm",title:()=>orderlyI18n.i18n.t("orderEntry.orderConfirm")});var sr=e=>{let{order:t,symbolInfo:r,dataSource:o,national:i,askAndBid:n,totalQuantity:s}=e,{base:a,quote:l,base_dp:c,quote_dp:p}=r,{t:u}=orderlyI18n.useTranslation(),m=()=>{e.reject(),e.close?.();},d=()=>{e.resolve(),e.close?.();},C=ki.useMemo(()=>[{title:u("common.symbol"),dataIndex:"symbol",width:125,render:(T,O)=>jsxRuntime.jsxs(orderlyUi.Flex,{gap:2,children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-h-[38px] oui-w-1 oui-shrink-0 oui-rounded-[1px]",O.side===orderlyTypes.OrderSide.BUY?"oui-bg-trade-profit":"oui-bg-trade-loss")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",children:[jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,children:[jsxRuntime.jsx(orderlyUi.TokenIcon,{symbol:T,className:"oui-size-3"}),jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"symbol",size:"xs",formatString:"base-type",children:T})]}),jsxRuntime.jsx(orderlyUi.Badge,{color:"neutral",size:"xs",children:u("orderEntry.orderType.limit")})]})]})},{title:u("common.quantity"),dataIndex:"order_quantity",width:100,render:(T,O)=>jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:c,padding:false,color:O.side===orderlyTypes.OrderSide.BUY?"buy":"sell",children:T})},{title:u("common.orderPrice"),dataIndex:"order_price",width:100,render:(T,O)=>{let h=!!(O.side===orderlyTypes.OrderSide.BUY?n?.[0]&&Number(T)>=n?.[0]:n?.[1]&&Number(T)<=n?.[1]);return jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:p,children:T}),h&&jsxRuntime.jsx(orderlyUi.Tooltip,{content:u("orderEntry.confirmScaledOrder.orderPrice.warning"),className:"oui-w-[240px] oui-text-2xs oui-font-semibold oui-text-base-contrast-80",children:jsxRuntime.jsx(ws,{className:"oui-text-warning-darken"})})]})}}],[u,r,n,c,p]);return jsxRuntime.jsxs("div",{className:"oui-font-semibold",children:[jsxRuntime.jsx(orderlyUi.DataTable,{classNames:{root:orderlyUi.cn("oui-bg-base-7","oui-rounded-lg","oui-overflow-hidden",t.orders?.length>=6&&"oui-h-[320px]"),scroll:"!oui-min-h-[130px]"},dataSource:o,columns:C,bordered:true,onRow:()=>({className:orderlyUi.cn("oui-h-[50px]")})}),jsxRuntime.jsxs("div",{className:"oui-mb-5 oui-mt-4 oui-text-2xs",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("orderEntry.totalOrders")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:t.orders?.length})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",mt:2,children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("orderEntry.totalQuantity")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",unit:a,dp:c,padding:false,intensity:80,unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:s})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",mt:2,children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("common.notional")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",unit:l,dp:p,padding:false,intensity:80,unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:i})]})]}),jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:3,children:[jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"md",onClick:m,children:u("common.cancel")}),jsxRuntime.jsx(orderlyUi.Button,{size:"md",onClick:d,children:u("common.confirm")})]})]})},ws=ki.forwardRef((e,t)=>jsxRuntime.jsx("svg",{width:"12",height:"13",viewBox:"0 0 12 13",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",ref:t,...e,children:jsxRuntime.jsx("path",{d:"M5.99951 1.50708C3.23811 1.50708 0.999512 3.74558 0.999512 6.50708C0.999512 9.26858 3.23811 11.5071 5.99951 11.5071C8.76091 11.5071 10.9995 9.26858 10.9995 6.50708C10.9995 3.74558 8.76091 1.50708 5.99951 1.50708ZM5.99951 4.00708C6.27566 4.00708 6.49951 4.23108 6.49951 4.50708C6.49951 4.78308 6.27566 5.00708 5.99951 5.00708C5.72336 5.00708 5.49951 4.78308 5.49951 4.50708C5.49951 4.23108 5.72336 4.00708 5.99951 4.00708ZM5.99951 5.50708C6.27566 5.50708 6.49951 5.73108 6.49951 6.00708V8.50708C6.49951 8.78308 6.27566 9.00708 5.99951 9.00708C5.72336 9.00708 5.49951 8.78308 5.49951 8.50708V6.00708C5.49951 5.73108 5.72336 5.50708 5.99951 5.50708Z"})}));function lt(){let e=orderlyHooks.useEventEmitter(),[t,r]=ki.useState([0,0]),o=orderlyHooks.useDebouncedCallback(i=>{let n=i.asks?.[i.asks.length-1]?.[0],s=i.bids?.[0]?.[0];r([n,s]);},200);return ki.useEffect(()=>(e.on("orderbook:update",o),()=>{e.off("orderbook:update",o),o.cancel();}),[o]),t}function ar(e){let{order:t,symbolInfo:r}=e,o=t.orders,i=lt(),n=ki.useMemo(()=>o.reduce((l,c)=>l.add(new orderlyUtils.Decimal(c.order_price).mul(c.order_quantity)),orderlyUtils.zero).toNumber(),[o]),s=ki.useMemo(()=>o.reduce((l,c)=>l.add(new orderlyUtils.Decimal(c.order_quantity)),orderlyUtils.zero).toString(),[o,r.base_dp]);return {dataSource:o,national:n,askAndBid:i,totalQuantity:s}}var Ro=e=>{let t=ar(e);return jsxRuntime.jsx(sr,{...e,...t})},ut="scaledOrderConfirm";orderlyUi.registerSimpleDialog(ut,Ro,{size:"md",title:()=>orderlyI18n.i18n.t("orderEntry.confirmScaledOrder"),contentProps:{}});var Mo=e=>{let{t}=orderlyI18n.useTranslation(),r=ki.useMemo(()=>[{label:t("orderEntry.orderType.limitOrder"),value:orderlyTypes.OrderType.LIMIT},{label:t("orderEntry.orderType.marketOrder"),value:orderlyTypes.OrderType.MARKET},{label:t("orderEntry.orderType.stopLimit"),value:orderlyTypes.OrderType.STOP_LIMIT},{label:t("orderEntry.orderType.stopMarket"),value:orderlyTypes.OrderType.STOP_MARKET},{label:t("orderEntry.orderType.scaledOrder"),value:orderlyTypes.OrderType.SCALED},{label:t("orderEntry.orderType.trailingStop"),value:orderlyTypes.OrderType.TRAILING_STOP}],[t]),o=ki.useMemo(()=>({[orderlyTypes.OrderType.LIMIT]:t("orderEntry.orderType.limit"),[orderlyTypes.OrderType.MARKET]:t("common.marketPrice"),[orderlyTypes.OrderType.STOP_LIMIT]:t("orderEntry.orderType.stopLimit"),[orderlyTypes.OrderType.STOP_MARKET]:t("orderEntry.orderType.stopMarket"),[orderlyTypes.OrderType.SCALED]:t("orderEntry.orderType.scaledOrder"),[orderlyTypes.OrderType.TRAILING_STOP]:t("orderEntry.orderType.trailingStop")}),[t]);return jsxRuntime.jsx(orderlyUi.Select.options,{testid:"oui-testid-orderEntry-orderType-button",currentValue:e.type,value:e.type,options:r,onValueChange:e.onChange,contentProps:{className:"oui-bg-base-8"},classNames:{trigger:"oui-bg-base-6 oui-border-line"},valueFormatter:(i,n)=>{if(!r.find(l=>l.value===i))return jsxRuntime.jsx(orderlyUi.Text,{size:"xs",children:n.placeholder});let a=o[i];return jsxRuntime.jsx(orderlyUi.Text,{size:"xs",color:e.canTrade?e.side===orderlyTypes.OrderSide.BUY?"buy":"sell":void 0,children:a})},size:"md"})};var Do=e=>{let{symbol:t,side:r,symbolLeverage:o}=e,{isMobile:i}=orderlyUi.useScreen(),{maxLeverage:n}=orderlyHooks.useSymbolLeverage(t),s=o||n,a=()=>{let l=i?orderlyUiLeverage.SymbolLeverageSheetId:orderlyUiLeverage.SymbolLeverageDialogId;orderlyUi.modal.show(l,{symbol:t,side:r,curLeverage:s});};return jsxRuntime.jsxs(orderlyUi.Flex,{justify:"center",itemAlign:"center",gapX:1,className:orderlyUi.cn("oui-h-8","oui-rounded oui-border oui-border-line oui-bg-base-6","oui-cursor-pointer oui-select-none oui-text-xs oui-font-semibold oui-text-base-contrast-54"),onClick:a,children:[jsxRuntime.jsx(orderlyUi.Text,{children:"Cross"}),jsxRuntime.jsx(orderlyUi.Text.numeral,{dp:0,rm:orderlyUtils.Decimal.ROUND_DOWN,unit:"X",children:s})]})};function Uo(e){let{canTrade:t,side:r,order_type:o,setOrderValue:i}=e,{t:n}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-grid oui-w-full oui-flex-1 oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]","oui-grid-cols-2"),children:[jsxRuntime.jsx(orderlyUi.Button,{onClick:()=>{e.setOrderValue("side",orderlyTypes.OrderSide.BUY);},size:"md",fullWidth:true,"data-type":orderlyTypes.OrderSide.BUY,className:orderlyUi.cn(r===orderlyTypes.OrderSide.BUY&&t?"oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80":"oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"),"data-testid":"oui-testid-orderEntry-side-buy-button",children:n("common.buy")}),jsxRuntime.jsx(orderlyUi.Button,{onClick:()=>{e.setOrderValue("side",orderlyTypes.OrderSide.SELL);},"data-type":orderlyTypes.OrderSide.SELL,fullWidth:true,size:"md",className:orderlyUi.cn(r===orderlyTypes.OrderSide.SELL&&e.canTrade?"oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80":"oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"),"data-testid":"oui-testid-orderEntry-side-sell-button",children:n("common.sell")})]}),jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-grid oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]","oui-grid-cols-2"),children:[jsxRuntime.jsx("div",{className:"oui-w-full",children:jsxRuntime.jsx(Mo,{type:o,side:r,canTrade:t,onChange:s=>{i("order_type",s);}})}),jsxRuntime.jsx("div",{className:"oui-w-full",children:jsxRuntime.jsx(Do,{symbol:e.symbol,side:e.side,symbolLeverage:e.symbolLeverage})})]})]})}var dr=ki.createContext({}),v=()=>ki.useContext(dr);var Qo=e=>{let{errorMsgVisible:t,symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,setOrderValues:a,currentFocusInput:l,errors:c,priceInputRef:p,priceInputContainerRef:u,triggerPriceInputRef:m,activatedPriceInputRef:d}=e,C=ki.useMemo(()=>({errorMsgVisible:t,symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,setOrderValues:a,currentFocusInput:l,errors:c,priceInputRef:p,priceInputContainerRef:u,triggerPriceInputRef:m,activatedPriceInputRef:d}),[t,r,o,i,n,s,a,l,c,p,u,m,d]);return jsxRuntime.jsx(dr.Provider,{value:C,children:e.children})};var I=ki.forwardRef((e,t)=>{let{placeholder:r="0",inputMode:o}=e,{errorMsgVisible:i}=v();return jsxRuntime.jsx(orderlyUi.Input.tooltip,{ref:t,tooltip:i?e.error:void 0,autoComplete:"off",autoFocus:e.autoFocus,size:"lg",placeholder:e.readonly?"":r,id:e.id,name:e.name,color:e.error?"danger":void 0,prefix:jsxRuntime.jsx(la,{id:e.id,className:e.classNames?.prefix,children:e.label}),suffix:e.suffix,value:e.readonly?"":e.value||"",onValueChange:e.onChange,onFocus:n=>{e.onFocus?.(n);},onBlur:n=>{e.onBlur?.(n);},inputMode:o,formatters:e.overrideFormatters||[...e.formatters??orderlyTypes.EMPTY_LIST,orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.currencyFormatter,orderlyUi.inputFormatter.decimalPointFormatter],classNames:{root:orderlyUi.cn("orderly-order-entry oui-relative oui-h-[54px] oui-rounded oui-border oui-border-solid oui-border-line oui-px-2 oui-py-1 group-first:oui-rounded-t-xl group-last:oui-rounded-b-xl",e.className,e.classNames?.root),input:orderlyUi.cn("oui-mb-1 oui-mt-5 oui-h-5",e?.classNames?.input),suffix:orderlyUi.cn("oui-absolute oui-right-0 oui-top-0 oui-justify-start oui-py-2 oui-text-2xs oui-text-base-contrast-36",e.classNames?.suffix)},readOnly:e.readonly})});I.displayName="CustomInput";var la=e=>jsxRuntime.jsx("label",{htmlFor:e.id,className:orderlyUi.cn("oui-absolute oui-left-2 oui-top-[7px] oui-text-2xs oui-text-base-contrast-36",e.className),children:e.children});var Go=e=>{let{t}=orderlyI18n.useTranslation(),r=ki.useMemo(()=>[{label:t("orderEntry.bbo.counterparty1"),value:orderlyTypes.BBOOrderType.COUNTERPARTY1},{label:t("orderEntry.bbo.counterparty5"),value:orderlyTypes.BBOOrderType.COUNTERPARTY5},{label:t("orderEntry.bbo.queue1"),value:orderlyTypes.BBOOrderType.QUEUE1},{label:t("orderEntry.bbo.queue5"),value:orderlyTypes.BBOOrderType.QUEUE5}],[]);return jsxRuntime.jsx(orderlyUi.Select.options,{testid:"oui-testid-orderEntry-bbo-orderType-button",currentValue:e.value,value:e.value,options:r,onValueChange:e.onChange,contentProps:{className:"oui-bg-base-8 oui-w-full",style:e.contentStyle},size:"sm",classNames:{trigger:"oui-border-none oui-bg-transparent"},valueFormatter:(o,i)=>{let n=r.find(s=>s.value===o);return jsxRuntime.jsx(orderlyUi.Box,{children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",children:n?.label})})}})};var Ho=e=>{let{quote:t,bbo:r,fillMiddleValue:o}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"end",className:orderlyUi.cn("oui-order-entry-limit-price-input-suffix","oui-text-2xs"),children:[t,jsxRuntime.jsxs(orderlyUi.Flex,{justify:"end",itemAlign:"center",gap:2,children:[jsxRuntime.jsx(orderlyUi.Flex,{px:3,height:20,justify:"center",itemAlign:"center",r:"base",className:orderlyUi.cn("oui-mt-[2px] oui-cursor-pointer oui-select-none oui-border",r.bboStatus==="on"?"oui-border-primary":"oui-border-line-12",r.bboStatus==="disabled"&&"oui-cursor-not-allowed"),onClick:()=>{r.bboStatus==="disabled"?orderlyUi.modal.dialog({title:i("common.tips"),size:"xs",content:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:i("orderEntry.bbo.disabled.tips")})}):r.toggleBBO();},children:jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn(r.bboStatus==="on"&&"oui-text-primary",r.bboStatus==="off"&&"oui-text-base-contrast-54",r.bboStatus==="disabled"&&"oui-text-base-contrast-20"),children:i("orderEntry.bbo")})}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-select-none","oui-cursor-pointer oui-text-primary"),onClick:o,children:"Mid"})]})]})};var Ko=e=>{let{bbo:t}=e,{t:r}=orderlyI18n.useTranslation(),{symbolInfo:o,onFocus:i,onBlur:n,getErrorMsg:s,setOrderValue:a,priceInputRef:l,priceInputContainerRef:c}=v(),{quote:p,quote_dp:u}=o,m=t.bboStatus==="on",d=e.order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx(Ho,{quote:p,bbo:t,fillMiddleValue:e.fillMiddleValue}):p;return jsxRuntime.jsxs("div",{ref:c,className:"oui-group oui-relative oui-w-full",children:[jsxRuntime.jsx(I,{id:"order_price_input",name:"order_price_input",label:r("common.price"),suffix:d,value:e.order_price,onChange:C=>{a("order_price",C);},error:s("order_price"),formatters:[orderlyUi.inputFormatter.dpFormatter(u)],onFocus:i(1),onBlur:n(1),readonly:m,inputMode:"decimal",ref:l,classNames:{root:orderlyUi.cn(m&&"focus-within:oui-outline-transparent "),input:orderlyUi.cn(m&&"oui-cursor-auto")}}),t.bboStatus==="on"&&jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-absolute oui-bottom-1 oui-left-0"),children:jsxRuntime.jsx(Go,{value:t.bboType,onChange:t.onBBOChange,contentStyle:{width:e.priceInputContainerWidth}})})]})};var He=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s}=v(),{base:a,quote:l,base_dp:c,quote_dp:p}=r;return jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,className:"oui-group oui-space-x-1",children:[jsxRuntime.jsx(I,{id:"order_quantity_input",name:"order_quantity_input",label:t("common.qty"),suffix:a,error:n("order_quantity"),value:e.order_quantity,onChange:u=>{s("order_quantity",u);},formatters:[orderlyUi.inputFormatter.dpFormatter(c)],onFocus:o(3),onBlur:i(3),inputMode:"decimal",className:"!oui-rounded-r oui-rounded-bl-xl"}),jsxRuntime.jsx(I,{id:"order_total_input",name:"order_total_input",label:`${t("common.total")}\u2248`,suffix:l,error:n("total"),value:e.total,onChange:u=>{s("total",u);},formatters:[orderlyUi.inputFormatter.dpFormatter(p)],onFocus:o(4),onBlur:i(4),inputMode:"decimal",className:"!oui-rounded-bl oui-rounded-br-xl"})]})});He.displayName="QtyAndTotalInput";var Zo=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{setOrderValue:r}=v(),o=()=>{orderlyUi.modal.dialog({title:t("common.tips"),size:"sm",content:jsxRuntime.jsx(Fa,{value:e.distribution_type})});};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"center",p:2,r:"base",width:"100%",intensity:600,className:orderlyUi.cn("oui-t-rounded oui-text-base-contrast-36","oui-border oui-border-solid oui-border-line",e.className),children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-cursor-pointer oui-border-b oui-border-dashed oui-border-line-12",onClick:o,children:t("orderEntry.quantityDistribution")}),jsxRuntime.jsx(Na,{value:e.distribution_type,onValueChange:i=>{r("distribution_type",i);}})]})}),Fa=e=>{let{t}=orderlyI18n.useTranslation(),[r,o]=ki.useState(orderlyTypes.DistributionType.FLAT);ki.useEffect(()=>{o([orderlyTypes.DistributionType.FLAT,orderlyTypes.DistributionType.ASCENDING,orderlyTypes.DistributionType.DESCENDING].includes(e.value)?e.value:orderlyTypes.DistributionType.FLAT);},[e.value]);let i=ki.useMemo(()=>[{type:orderlyTypes.DistributionType.FLAT,title:t("orderEntry.distributionType.flat"),description:t("orderEntry.distributionType.flat.description"),formula:`${t("orderEntry.skew")} = 1`,quantity:jsxRuntime.jsx(ka,{})},{type:orderlyTypes.DistributionType.ASCENDING,title:t("orderEntry.distributionType.ascending"),description:t("orderEntry.distributionType.ascending.description"),formula:`${t("orderEntry.skew")} > 1`,quantity:jsxRuntime.jsx(wa,{})},{type:orderlyTypes.DistributionType.DESCENDING,title:t("orderEntry.distributionType.descending"),description:t("orderEntry.distributionType.descending.description"),formula:`0 < ${t("orderEntry.skew")} < 1`,quantity:jsxRuntime.jsx(Ra,{})}],[]),n=ki.useMemo(()=>i.find(s=>s.type===r),[i,r]);return jsxRuntime.jsxs("div",{className:"oui-text-2xs oui-font-semibold oui-text-base-contrast-54",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gapY:1,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:t("orderEntry.quantityDistribution.description")}),jsxRuntime.jsx(orderlyUi.Text,{children:t("orderEntry.quantityDistribution.formula")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{intensity:600,p:1,r:"base",mt:3,itemAlign:"start",children:[jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",itemAlign:"start",children:i.map(s=>jsxRuntime.jsx(orderlyUi.Box,{intensity:r===s.type?500:600,width:78,p:2,className:"oui-cursor-pointer oui-rounded-l",onClick:()=>{o(s.type);},children:jsxRuntime.jsx(orderlyUi.Text,{children:s.title})},s.title))}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gapY:1,p:2,intensity:500,width:"100%",className:orderlyUi.cn("oui-rounded-r",r===orderlyTypes.DistributionType.FLAT&&"oui-rounded-bl",r===orderlyTypes.DistributionType.ASCENDING&&"oui-rounded-l",r===orderlyTypes.DistributionType.DESCENDING&&"oui-rounded-tl"),children:[jsxRuntime.jsx("div",{children:n?.formula}),jsxRuntime.jsx(orderlyUi.Text,{children:n?.description}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",justify:"center",children:n?.quantity}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gapX:1,justify:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-1",children:t("common.price")}),jsxRuntime.jsx(Aa,{})]})]})]})]})},Na=e=>{let{value:t,onValueChange:r}=e,{t:o}=orderlyI18n.useTranslation(),i=s=>a=>{r(s);},n=ki.useMemo(()=>({[orderlyTypes.DistributionType.FLAT]:o("orderEntry.distributionType.flat"),[orderlyTypes.DistributionType.ASCENDING]:o("orderEntry.distributionType.ascending.abbr"),[orderlyTypes.DistributionType.DESCENDING]:o("orderEntry.distributionType.descending.abbr"),[orderlyTypes.DistributionType.CUSTOM]:o("orderEntry.distributionType.custom")}),[o]);return jsxRuntime.jsx(orderlyUi.Flex,{className:orderlyUi.cn("oui-gap-x-[6px] lg:oui-gap-x-2"),wrap:"wrap",children:Object.values(orderlyTypes.DistributionType).map(s=>jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{id:`distribution-type-${s}`,color:"white",variant:"radio",checked:t===s,onCheckedChange:i(s)}),jsxRuntime.jsx("label",{htmlFor:`distribution-type-${s}`,className:orderlyUi.cn("oui-text-2xs","oui-ml-1","oui-whitespace-nowrap oui-break-normal"),children:n[s]})]},s))})},ka=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"18",y:"18",width:"181",height:"4",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"15",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"62",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"109",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"156",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"203",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"})]}),wa=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"18",y:"18",width:"181",height:"4",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"15",cy:"20",r:"4.28571",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.42857"}),jsxRuntime.jsx("circle",{cx:"62",cy:"20",r:"5.14286",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.71429"}),jsxRuntime.jsx("circle",{cx:"109",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"156",cy:"20",r:"6.85714",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.28571"}),jsxRuntime.jsx("circle",{cx:"203",cy:"20",r:"7.71429",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.57143"})]}),Ra=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"181",height:"4",transform:"matrix(-1 0 0 1 200 18)",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"5",cy:"5",r:"4.28571",transform:"matrix(-1 0 0 1 208 15)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.42857"}),jsxRuntime.jsx("circle",{cx:"6",cy:"6",r:"5.14286",transform:"matrix(-1 0 0 1 162 14)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.71429"}),jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"6",transform:"matrix(-1 0 0 1 116 13)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6.85714",transform:"matrix(-1 0 0 1 70 12)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.28571"}),jsxRuntime.jsx("circle",{cx:"9",cy:"9",r:"7.71429",transform:"matrix(-1 0 0 1 24 11)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.57143"})]}),Aa=()=>jsxRuntime.jsx("svg",{width:"176",height:"8",viewBox:"0 0 176 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M175.354 4.35355C175.549 4.15829 175.549 3.84171 175.354 3.64645L172.172 0.464466C171.976 0.269204 171.66 0.269204 171.464 0.464466C171.269 0.659728 171.269 0.976311 171.464 1.17157L174.293 4L171.464 6.82843C171.269 7.02369 171.269 7.34027 171.464 7.53553C171.66 7.7308 171.976 7.7308 172.172 7.53553L175.354 4.35355ZM0 4V4.5H175V4V3.5H0V4Z",fill:"rgb(var(--oui-color-base-1))"})});var _r=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s}=v(),{quote:a,quote_dp:l}=r;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(I,{label:t("orderEntry.startPrice"),suffix:a,id:"order_start_price_input",value:e.start_price,error:n("start_price"),onChange:c=>{s("start_price",c);},formatters:[orderlyUi.inputFormatter.dpFormatter(l)],onFocus:o(5),onBlur:i(5),inputMode:"decimal",classNames:{root:"oui-rounded-t-xl"}}),jsxRuntime.jsx(I,{label:t("orderEntry.endPrice"),suffix:a,id:"order_end_price_input",value:e.end_price,error:n("end_price"),onChange:c=>{s("end_price",c);},formatters:[orderlyUi.inputFormatter.dpFormatter(l)],onFocus:o(6),onBlur:i(6),inputMode:"decimal"})]})});_r.displayName="ScaledPriceInput";var Ga=e=>jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",intensity:36,children:e}),Jo=e=>{let{base:t,quote:r}=e,o=ki.useMemo(()=>[{name:r},{name:t}],[t,r]);return jsxRuntime.jsx(orderlyUi.Select.tokens,{variant:"text",size:"xs",iconSize:"2xs",tokens:o,classNames:{trigger:orderlyUi.cn("oui-absolute oui-right-0 oui-top-1","oui-w-full oui-justify-end")},value:e.value,onValueChange:e.onValueChange,valueFormatter:Ga,contentProps:{align:"end",alignOffset:-1,sideOffset:-4,className:"oui-border oui-border-line-6"}})};var ri=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{errors:r,symbolInfo:o,onFocus:i,onBlur:n,getErrorMsg:s,setOrderValue:a}=v(),[l,c]=orderlyHooks.useLocalStorage("orderly_order_quantity_unit","quote"),{base:p,quote:u,base_dp:m,quote_dp:d}=o,C=l==="base",O=jsxRuntime.jsx(Jo,{base:p,quote:u,value:C?p:u,onValueChange:h=>{c(h===p?"base":"quote");}});return C?jsxRuntime.jsx(I,{label:t("common.qty"),suffix:O,id:"order_quantity_input",name:"order_quantity_input",className:"!oui-rounded-r",value:e.order_quantity,error:s("order_quantity",`${r?.order_quantity?.value} ${p}`),onChange:h=>{a("order_quantity",h);},formatters:[orderlyUi.inputFormatter.dpFormatter(m)],onFocus:i(3),onBlur:n(3),inputMode:"decimal"}):jsxRuntime.jsx(I,{label:t("common.qty"),suffix:O,id:"order_total_input",name:"order_total_input",className:"!oui-rounded-r",value:e.total,error:s("order_quantity",`${r?.total?.value} ${u}`),onChange:h=>{a("total",h);},formatters:[orderlyUi.inputFormatter.dpFormatter(d)],onFocus:i(4),onBlur:n(4),inputMode:"decimal"})});var ii=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{onFocus:r,onBlur:o,getErrorMsg:i,setOrderValue:n}=v();return jsxRuntime.jsx(I,{id:"order_skew_input",label:t("orderEntry.skew"),value:e.skew,error:i("skew"),onChange:s=>{n("skew",s);},onFocus:r(8),onBlur:o(8),inputMode:"decimal",overrideFormatters:[orderlyUi.inputFormatter.rangeFormatter({min:0,max:100,dp:2}),orderlyUi.inputFormatter.dpFormatter(2)],classNames:{root:"oui-rounded-b-xl"}})});var si=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{onFocus:r,onBlur:o,getErrorMsg:i,setOrderValue:n}=v();return jsxRuntime.jsx(I,{label:t("orderEntry.totalOrders"),placeholder:"2-20",id:"order_total_orders_input",className:"!oui-rounded-l",value:e.total_orders,error:i("total_orders"),onChange:s=>{n("total_orders",s);},overrideFormatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(0)],onFocus:r(7),onBlur:o(7),inputMode:"numeric"})});var li=e=>{let{values:t}=e,r=t.distribution_type===orderlyTypes.DistributionType.CUSTOM;return jsxRuntime.jsxs("div",{className:"oui-space-y-1",children:[jsxRuntime.jsx(_r,{start_price:t.start_price,end_price:t.end_price}),jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,className:"oui-group oui-space-x-1",children:[jsxRuntime.jsx(ri,{order_quantity:t.order_quantity,total:t.total}),jsxRuntime.jsx(si,{total_orders:t.total_orders})]}),jsxRuntime.jsx(Zo,{distribution_type:t.distribution_type,className:orderlyUi.cn(!r&&"oui-rounded-b-xl")}),r&&jsxRuntime.jsx(ii,{skew:t.skew})]})};var Or=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,triggerPriceInputRef:a}=v();return jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx(I,{ref:a,id:"order_trigger_price_input",name:"order_trigger_price_input",label:t("common.trigger"),suffix:r.quote,value:e.trigger_price,onChange:l=>{s("trigger_price",l);},error:n("trigger_price"),formatters:[orderlyUi.inputFormatter.dpFormatter(r.quote_dp)],onFocus:o(2),onBlur:i(2),inputMode:"decimal"})})})});Or.displayName="TriggerPriceInput";var Pr=ki.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,activatedPriceInputRef:a}=v();return jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx(I,{ref:a,id:"order_activated_price_input",name:"order_activated_price_input",label:t("common.triggerPrice"),placeholder:`0 (${t("common.optional")})`,suffix:r.quote,error:n("activated_price"),value:e.activated_price,onChange:l=>{s("activated_price",l);},formatters:[orderlyUi.inputFormatter.dpFormatter(r.quote_dp)],onFocus:o(9),onBlur:i(9),inputMode:"decimal"})})});Pr.displayName="ActivePriceInput";var pl=[1,2,3,5],hr=ki.memo(e=>{let{setOrderValue:t}=v();return jsxRuntime.jsx(orderlyUi.Flex,{gapX:2,className:e.className,children:pl.map(r=>{let o=r.toString(),i=e.callback_rate===o;return jsxRuntime.jsx(orderlyUi.Flex,{justify:"center",itemAlign:"center",width:46,height:18,className:orderlyUi.cn("oui-cursor-pointer oui-select-none","oui-rounded oui-border",i?"oui-border-base-contrast-36":"oui-border-line-12"),onClick:()=>{t("callback_rate",o),e.onClick?.(o);},children:jsxRuntime.jsxs(orderlyUi.Text,{size:"2xs",intensity:i?80:36,weight:"semibold",children:[r,"%"]})},r)})})});hr.displayName="CallbackRatePercentages";var Er=ki.memo(e=>{let{quote:t}=e,r=ki.useMemo(()=>[{label:t,value:orderlyTypes.TrailingCallbackType.VALUE},{label:"%",value:orderlyTypes.TrailingCallbackType.RATE}],[t]);return jsxRuntime.jsx(orderlyUi.Select.options,{variant:"text",size:"xs",options:r,classNames:{trigger:orderlyUi.cn("oui-absolute oui-right-0 oui-top-1","oui-w-[124px] oui-justify-end","oui-text-base-contrast-36")},value:e.value,onValueChange:e.onValueChange,contentProps:{align:"end",alignOffset:-1,sideOffset:-4,className:"oui-border oui-border-line-6"}})});Er.displayName="trailingCallbackSelect";var Ir=ki.memo(e=>{let{callback_value:t,callback_rate:r}=e,{t:o}=orderlyI18n.useTranslation(),{symbolInfo:i,onFocus:n,onBlur:s,getErrorMsg:a,setOrderValue:l,setOrderValues:c}=v(),{quote:p,quote_dp:u}=i,m=ki.useRef(),d=ki.useRef(),[C,T]=orderlyHooks.useLocalStorage("orderly_order_trailing_callback_type",orderlyTypes.TrailingCallbackType.VALUE),O=ki.useCallback(L=>{T(L),L===orderlyTypes.TrailingCallbackType.RATE?(m.current=t,c({callback_value:"",callback_rate:d.current})):(d.current=r,c({callback_value:m.current,callback_rate:""}));},[t,r]),h=jsxRuntime.jsx(Er,{quote:p,value:C,onValueChange:O});return C===orderlyTypes.TrailingCallbackType.RATE?jsxRuntime.jsxs("div",{className:"oui-relative",children:[jsxRuntime.jsx(I,{id:"order_callback_rate_input",name:"order_callback_rate_input",label:o("orderEntry.trailingRate"),suffix:h,error:a("callback_rate"),value:r,onChange:L=>{l("callback_rate",L);},formatters:[orderlyUi.inputFormatter.dpFormatter(1)],onFocus:L=>{n(11)(L);},onBlur:L=>{s(11)(L);},inputMode:"decimal",classNames:{root:"oui-h-[68px]",input:"oui-mb-5",prefix:"!oui-top-1"}}),jsxRuntime.jsx(hr,{className:"oui-absolute oui-bottom-1 oui-left-2",callback_rate:r})]}):jsxRuntime.jsx(I,{id:"order_callback_value_input",name:"order_callback_value_input",label:o("orderEntry.trailingValue"),suffix:h,error:a("callback_value"),value:t,onChange:L=>{l("callback_value",L);},formatters:[orderlyUi.inputFormatter.dpFormatter(u)],onFocus:n(10),onBlur:s(10),inputMode:"decimal",classNames:{input:"!oui-mb-[6px]",prefix:"!oui-top-1"}})});Ir.displayName="TrailingCallbackInput";var gi=e=>{let{values:t}=e;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Pr,{activated_price:t.activated_price}),jsxRuntime.jsx(Ir,{callback_value:t.callback_value,callback_rate:t.callback_rate}),jsxRuntime.jsx(He,{order_quantity:t.order_quantity,total:t.total})]})};function yi(e){let{values:t}=e,r=t.order_type;if(r===orderlyTypes.OrderType.SCALED)return jsxRuntime.jsx(li,{values:t});if(r===orderlyTypes.OrderType.TRAILING_STOP)return jsxRuntime.jsx(gi,{values:t});let o=r===orderlyTypes.OrderType.STOP_LIMIT||r===orderlyTypes.OrderType.STOP_MARKET,i=r===orderlyTypes.OrderType.LIMIT||r===orderlyTypes.OrderType.STOP_LIMIT,n=o&&jsxRuntime.jsx(Or,{trigger_price:t.trigger_price}),s=i&&jsxRuntime.jsx(Ko,{order_type:t.order_type,order_price:t.order_price,bbo:e.bbo,fillMiddleValue:e.fillMiddleValue,priceInputContainerWidth:e.priceInputContainerWidth});return jsxRuntime.jsxs("div",{className:"oui-space-y-1",children:[n,s,jsxRuntime.jsx(He,{order_quantity:t.order_quantity,total:t.total})]})}var _i=e=>{let{canTrade:t,order_quantity:r,maxQty:o}=e,{t:i}=orderlyI18n.useTranslation(),n=ki.useMemo(()=>t?e.side===orderlyTypes.OrderSide.BUY?"buy":"sell":void 0,[e.side,t]),s=ki.useMemo(()=>e.side===orderlyTypes.OrderSide.BUY?i("orderEntry.maxBuy"):i("orderEntry.maxSell"),[e.side,i]),a=ki.useMemo(()=>r?Number(r):0,[r]),l=ki.useMemo(()=>r?Number(r)>=Number(o)?1:orderlyUi.convertValueToPercentage(Number(r??0),0,o)/100:0,[r,o]);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(orderlyUi.Slider.single,{disabled:o===0||!t,value:a,color:n,markCount:4,showTip:true,max:o,step:e.tick,onValueChange:e.onValueChange}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-pt-1 xl:oui-pt-2",children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"percentages",size:"2xs",color:n,dp:2,padding:false,children:t?l:0}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx("button",{className:orderlyUi.textVariants({size:"2xs",className:"oui-mr-1"}),onClick:()=>e.setMaxQty(),"data-testid":"oui-testid-orderEntry-maxQty-value-button",children:s}),jsxRuntime.jsx(orderlyUi.Text.numeral,{size:"2xs",color:n,dp:e.dp,padding:false,"data-testid":"oui-testid-orderEntry-maxQty-value",children:t?o:0})]})]})]})};var Nr=ki.createContext({}),_t=()=>ki.useContext(Nr);var vi=e=>{let{type:t,values:r,quote_dp:o}=e,{t:i}=orderlyI18n.useTranslation(),[n,s]=ki.useState(true),{mode:a,setMode:l,tipsEle:c}=_t(),[p,u]=ki.useState(false),[m,d]=ki.useState(false),C=ki.useMemo(()=>{switch(a){case "Offset":return `${t.toLowerCase()}_offset`;case "Offset%":return `${t.toLowerCase()}_offset_percentage`;default:return `${t.toLowerCase()}_pnl`}},[a]),[T,O]=ki.useState(r[a]);ki.useEffect(()=>{m||O(r[a]);},[r,a,m]);let h=ki.useMemo(()=>[{label:i("tpsl.pnl"),value:"PnL",testId:"PnL_menu_item"},{label:i("tpsl.offset"),value:"Offset",testId:"Offset_mneu_item"},{label:`${i("tpsl.offset")}%`,value:"Offset%",testId:"Offset%_menu_item"}],[i]),L=ki.useMemo(()=>({PnL:i("tpsl.pnl"),Offset:i("tpsl.offset"),"Offset%":`${i("tpsl.offset")}%`}),[i]),E=ki.useRef("");return {mode:a,modes:h,modeLabelMap:L,formatter:U=>{let{dp:K=2}=U;return {onRenderBefore:(f,Y)=>(f=`${f}`,n&&t==="SL"&&a==="PnL"&&(f=f.startsWith("-")?f:"-"+f),f===""||f==="-"?"":a==="Offset%"?`${new orderlyUtils.Decimal(f.replace(new RegExp(E.current.replace(".","\\.")+"$"),"")).mul(100).todp(2,4).toString()}${E.current}`:(a==="Offset"&&(f=orderlyUtils.todpIfNeed(f,K)),`${f}`)),onSendBefore:f=>{if(/^\-?0{2,}$/.test(f))return "0";if(a==="Offset%"){if(f!==""){f=orderlyUtils.todpIfNeed(f,2);let Y=f.match(/\.0{0,2}$/);Y?E.current=Y[0]:E.current="",f=new orderlyUtils.Decimal(f).div(100).toString(),f=`${f}${E.current}`;}}else a==="PnL"&&t==="SL"&&n?f=f.startsWith("-")?f:"-"+f:f=orderlyUtils.todpIfNeed(f,K);return f===""||f==="-"?"":f}}},onModeChange:U=>{l(U);},onFocus:()=>{u(true),d(true);},onBlur:()=>{u(false),d(false),e.onChange(C,T);},value:T,onValueChange:U=>{O(U),e.onChange(C,U);},quote_dp:o,tips:p?c:void 0,setFocus:s}};var hi=e=>{let{mode:t,modes:r,modeLabelMap:o,onModeChange:i,onValueChange:n,quote:s,quote_dp:a,value:l,type:c,tips:p,onFocus:u,onBlur:m,setFocus:d}=e,[C,T]=ki.useState(t),[O,h]=ki.useState(t==="Offset%"?"%":s);ki.useEffect(()=>{T(t),h(t==="Offset%"?"%":s);},[t]),ki.useEffect(()=>{T(l?"":t);},[l]);let L=ki.useMemo(()=>`${c.toLowerCase()}_${t.toLowerCase()}`,[]);return jsxRuntime.jsx(orderlyUi.Input.tooltip,{prefix:o[C]||C,size:"md",placeholder:O,id:L,align:"right",value:l,tooltip:p,tooltipProps:{content:{side:e.type==="TP"?"top":"bottom"}},"data-testid":e.testIds?.input,autoComplete:"off",inputMode:"decimal",onValueChange:n,formatters:[e.formatter({dp:a,mode:t,type:c}),orderlyUi.inputFormatter.currencyFormatter],classNames:{root:c==="TP"?"oui-text-trade-profit":"oui-text-trade-loss",additional:"oui-text-base-contrast-54",input:"oui-text-inherit"},onFocus:()=>{T(""),h(""),d(true),u();},onBlur:()=>{T(l?"":t),h(t==="Offset%"?"%":s),m();},suffix:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t==="Offset%"&&!!l&&jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",color:"inherit",className:"oui-ml-[2px]",children:"%"}),jsxRuntime.jsx(Ql,{mode:t,modes:r,onModeChange:E=>i(E.value),testId:e.testIds?.dropDown})]})})},Ql=e=>jsxRuntime.jsx(orderlyUi.SimpleDropdownMenu,{currentValue:e.mode,menu:e.modes,align:"end",size:"xs",className:"oui-min-w-[80px]",onCloseAutoFocus:t=>t.preventDefault(),onSelect:t=>e.onModeChange(t),children:jsxRuntime.jsx("button",{className:"oui-p-2","data-testid":e.testId,children:jsxRuntime.jsx(orderlyUi.CaretDownIcon,{size:12,color:"white"})})});var Ei=e=>{let{testIds:t,quote:r,...o}=e,i=vi(o);return jsxRuntime.jsx(hi,{...i,testIds:t,quote:r,type:e.type})};var Rr=e=>{let{type:t,values:r,children:o}=e,[i,n]=orderlyHooks.useLocalStorage("TP/SL_Mode","Offset%"),{t:s}=orderlyI18n.useTranslation(),a=ki.useMemo(()=>!r.PnL||!r.trigger_price?null:jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx("span",{className:"oui-text-xs oui-text-base-contrast-54",children:i==="PnL"?s("orderEntry.estRoi"):s("orderEntry.estPnL")}),i==="PnL"?jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"percentages",className:orderlyUi.cn("oui-ml-1 oui-text-xs",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),children:r.ROI}):jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",className:orderlyUi.cn("oui-ml-1 oui-text-xs",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),children:r.PnL})]}),[i,r.ROI,r.PnL,r.trigger_price]),l=ki.useMemo(()=>({mode:i,setMode:n,tipsEle:a}),[i,n,a]);return jsxRuntime.jsx(Nr.Provider,{value:l,children:o})};var Ri=e=>{let t=ki__default.default.useRef(null),{t:r}=orderlyI18n.useTranslation();return ki.useEffect(()=>{e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET&&e.onSwitchChanged(false);},[e.orderType]),e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET||e.isReduceOnly?null:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{id:"order_entry_tpsl",className:"oui-h-[14px]",checked:e.switchState,disabled:e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET||e.isReduceOnly,onCheckedChange:o=>{e.onSwitchChanged(o);}}),jsxRuntime.jsx("label",{htmlFor:"order_entry_tpsl",className:"oui-text-xs",children:r("common.tpsl")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,onClick:e.showTPSLAdvanced,className:orderlyUi.cn("oui-group oui-invisible",e.switchState&&"oui-visible"),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm oui-cursor-pointer group-hover:oui-text-base-contrast",children:r("tpsl.advanced")}),jsxRuntime.jsx(orderlyUi.SettingFillIcon,{size:12,className:"oui-text-base-contrast-54 group-hover:oui-text-base-contrast oui-cursor-pointer",opacity:1,onClick:e.showTPSLAdvanced})]})]}),jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-h-0 oui-overflow-hidden oui-transition-all",e.switchState&&"oui-max-h-[120px]"),onTransitionEnd:()=>{t.current?.style.setProperty("opacity",e.switchState?"1":"0");},children:jsxRuntime.jsx(Ai,{ref:t,setOrderValue:e.setOrderValue,onChange:e.onChange,values:e.values,errors:e.errors,quote_dp:e.quote_dp})})]})},Ai=ki__default.default.forwardRef((e,t)=>{let{getErrorMsg:r}=orderlyReactApp.useOrderEntryFormErrorMsg(e.errors);return jsxRuntime.jsxs("div",{ref:t,className:"oui-space-y-1 oui-px-px oui-py-2 oui-transition-all",children:[jsxRuntime.jsx(orderlyUiTpsl.TPSLPositionTypeWidget,{value:e.values.position_type,onChange:e.onChange}),jsxRuntime.jsx(Rr,{values:e.values.tp,type:"TP",children:jsxRuntime.jsx(Ni,{type:"TP",error:r("tp_trigger_price"),onChange:e.onChange,values:e.values.tp,quote_dp:e.quote_dp,testIds:{first:"oui-testid-orderEntry-tpsl-tpPrice-input",second:"oui-testid-orderEntry-tpsl-tpPnl-input",dropDown:"oui-testid-orderEntry-tpsl-tp-dropDown-trigger-button"}})}),jsxRuntime.jsx(Rr,{values:e.values.sl,type:"SL",children:jsxRuntime.jsx(Ni,{type:"SL",error:r("sl_trigger_price"),onChange:e.onChange,values:e.values.sl,quote_dp:e.quote_dp,testIds:{first:"oui-testid-orderEntry-tpsl-slPrice-input",second:"oui-testid-orderEntry-tpsl-slPnl-input",dropDown:"oui-testid-orderEntry-tpsl-sl-dropDown-trigger-button"}})})]})});Ai.displayName="TPSLInputForm";var nu=e=>{let{t}=orderlyI18n.useTranslation(),{errorMsgVisible:r}=v(),{tipsEle:o}=_t(),[i,n]=ki.useState(`${e.type} Price`),[s,a]=ki.useState("USDC"),[l,c]=ki.useState(false),[p,u]=ki.useState(false),[m,d]=ki.useState(e.values.trigger_price??"");ki.useEffect(()=>{p||d(e.values.trigger_price??"");},[e.values.trigger_price,p]);let C=ki.useMemo(()=>e.error&&r?e.error:l?o:null,[e.error,r,l,o]),T=E=>{let Z=e.type==="TP"?t("tpsl.tpPrice"):t("tpsl.slPrice");return E&&(Z=e.type==="TP"?t("tpsl.tp"):t("tpsl.sl")),Z},O=E=>{d(E),e.onChange(E);};ki.useEffect(()=>{n(T(e.values.trigger_price)),p||d(e.values.trigger_price??"");},[e.type,e.values.trigger_price]);let h=()=>{n(e.type==="TP"?t("tpsl.tp"):t("tpsl.sl")),a(""),c(true),u(true);},L=()=>{n(T(e.values.trigger_price)),a("USDC"),c(false),u(false),e.onChange(m);};return jsxRuntime.jsx(orderlyUi.Input.tooltip,{"data-testid":e.testId,prefix:i,size:"md",placeholder:s,align:"right",onFocus:h,onBlur:L,tooltip:C,tooltipProps:{content:{side:e.type==="TP"?"top":"bottom"}},color:e.error?"danger":void 0,autoComplete:"off",inputMode:"decimal",value:m,classNames:{additional:"oui-text-base-contrast-54",root:"oui-pr-2 md:oui-pr-3",prefix:"oui-pr-1 md:oui-pr-2"},onValueChange:O,formatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(e.quote_dp??2),orderlyUi.inputFormatter.currencyFormatter]})},Ni=e=>jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:1,children:[jsxRuntime.jsx(nu,{testId:e.testIds?.first,type:e.type,error:e.error,values:e.values??"",onChange:t=>{e.onChange(e.type==="SL"?"sl_trigger_price":"tp_trigger_price",t);},quote_dp:e.quote_dp}),jsxRuntime.jsx(Ei,{testIds:{input:e.testIds?.second,dropDown:e.testIds?.dropDown},onChange:e.onChange,quote:"USDC",quote_dp:2,type:e.type,values:{PnL:e.values.PnL,Offset:e.values.Offset,"Offset%":e.values["Offset%"],ROI:e.values.ROI}})]});var zr=e=>{let{side:t,formattedOrder:r,setOrderValue:o,setOrderValues:i,symbolInfo:n,maxQty:s,freeCollateral:a,helper:l,submit:c,metaState:p,bboStatus:u,bboType:m,onBBOChange:d,toggleBBO:C,disableFeatures:T,currentLtv:O,fillMiddleValue:h,soundAlert:L,setSoundAlert:E,currentFocusInput:Z}=e,{t:F}=orderlyI18n.useTranslation(),{isMobile:ue}=orderlyUi.useScreen(),[ye,U]=ki.useState(false),{errors:K,validated:f}=p,[Y,de]=ki.useState(false),[be,B]=orderlyHooks.useLocalStorage("orderly_order_confirm",true),[j,ie]=orderlyHooks.useLocalStorage("orderly-order-additional-pinned",true),[xe,ce]=ki.useState(false),[Nt,kt]=orderlyHooks.useLocalStorage("orderly-order-hidden",false),[he,wt]=orderlyHooks.useLocalStorage("orderly-slippage","1",{parseJSON:y=>!y||y==='""'?"1":JSON.parse(y)}),{notification:Rt}=orderlyHooks.useOrderlyContext(),Ze=ki.useId(),{getErrorMsg:At}=orderlyReactApp.useOrderEntryFormErrorMsg(f?K:null),_=ki.useMemo(()=>t===orderlyTypes.OrderSide.BUY?F("orderEntry.buyLong"):F("orderEntry.sellShort"),[t,F]);ki.useEffect(()=>{f&&de(true);},[f]),ki.useEffect(()=>{T?.includes("slippageSetting")||(he?o("slippage",Number(he)):o("slippage",void 0));},[he,T]),ki.useEffect(()=>{let y=R=>{R.target.closest("#order-entry-submit-button")||de(Kr=>Kr&&false);};return Y?document.addEventListener("click",y):document.removeEventListener("click",y),()=>{document.removeEventListener("click",y);}},[Y]);let k=orderlyHooks.useMemoizedFn(async()=>{let y=r.order_type===orderlyTypes.OrderType.SCALED;l.validate().then(R=>y?orderlyUi.modal.show(ut,{order:R,symbolInfo:n,size:ue?"sm":"md"}):be?orderlyUi.modal.show(or,{order:r,symbolInfo:n}):true,R=>(R.slippage&&orderlyUi.toast.error(F("orderEntry.slippage.error.max")),de(true),Promise.reject())).then(()=>c({resetOnSuccess:false}).then(R=>{if(!R.success&&R.message)orderlyUi.toast.error(R.message);else if(R.success&&y){let Ve=ho(R);Ve&&orderlyUi.toast.success(Ve);}})).catch(R=>{R?.message&&orderlyUi.toast.error(R.message);});}),ne=async()=>{if(r.reduce_only&&s===0)return orderlyUi.modal.confirm({title:F("orderEntry.reduceOnly.reminder"),content:F("orderEntry.reduceOnly.reminder.content"),okLabel:F("orderEntry.placeOrderNow"),onOk:async()=>(o("reduce_only",false),requestAnimationFrame(()=>{e.resetMetaState(),k();}),Promise.resolve(true)),onCancel:async()=>Promise.resolve(false)});k();},D=()=>{l.validate().then(()=>{ce(true);},y=>{let R=new Set(["tp_trigger_price","sl_trigger_price"]);Object.keys(y).every(Ve=>R.has(Ve))&&ce(true);});},X=y=>{y.side!==r.side&&o("side",y.side),i({position_type:y.position_type,tp_order_type:y.tp_order_type,tp_pnl:y.tp_pnl,tp_offset:y.tp_offset,tp_offset_percentage:y.tp_offset_percentage,tp_ROI:y.tp_ROI,tp_trigger_price:y.tp_trigger_price,tp_order_price:y.tp_order_price,sl_order_type:y.sl_order_type,sl_trigger_price:y.sl_trigger_price,sl_order_price:y.sl_order_price,sl_pnl:y.sl_pnl,sl_offset:y.sl_offset,sl_offset_percentage:y.sl_offset_percentage,sl_ROI:y.sl_ROI}),ce(false),U(true);},Bt=()=>{U(false),i({tp_trigger_price:void 0,tp_order_price:void 0,tp_order_type:orderlyTypes.OrderType.MARKET,sl_trigger_price:void 0,sl_order_price:void 0,sl_order_type:orderlyTypes.OrderType.MARKET,tp_pnl:void 0,sl_pnl:void 0,position_type:orderlyTypes.PositionType.FULL});};ki.useEffect(()=>{U(false);},[e.symbol]);let je=!!Rt?.orderFilled?.media,Wr={pinned:j,setPinned:ie,needConfirm:be,setNeedConfirm:B,hidden:Nt,setHidden:kt,onValueChange:o,orderTypeExtra:r.order_type_ext,showExtra:r.order_type===orderlyTypes.OrderType.LIMIT&&!e.tpslSwitch},Hr=!j&&jsxRuntime.jsx(Yr,{...Wr});return jsxRuntime.jsxs(Qo,{errors:K,errorMsgVisible:Y,symbolInfo:n,onFocus:e.onFocus,onBlur:e.onBlur,getErrorMsg:At,setOrderValue:o,setOrderValues:i,currentFocusInput:Z.current,priceInputRef:e.priceInputRef,priceInputContainerRef:e.priceInputContainerRef,triggerPriceInputRef:e.triggerPriceInputRef,activatedPriceInputRef:e.activatedPriceInputRef,children:[jsxRuntime.jsxs("div",{className:"oui-space-y-2 oui-text-base-contrast-54 xl:oui-space-y-3",ref:e.containerRef,children:[jsxRuntime.jsx(Uo,{symbol:e.symbol,canTrade:e.canTrade,side:t,order_type:r.order_type,setOrderValue:o,symbolLeverage:e.symbolLeverage}),jsxRuntime.jsx(_o,{currentLtv:O,canTrade:e.canTrade,quote:n?.quote,freeCollateral:a}),jsxRuntime.jsx(yi,{values:r,priceInputContainerWidth:e.priceInputContainerWidth,fillMiddleValue:h,bbo:{bboStatus:u,bboType:m,onBBOChange:d,toggleBBO:C}}),jsxRuntime.jsx(_i,{canTrade:e.canTrade,maxQty:s,order_quantity:r.order_quantity,tick:n.base_tick,dp:n.base_dp,setMaxQty:e.setMaxQty,onValueChange:y=>{o("order_quantity",y);},side:e.side}),jsxRuntime.jsx(orderlyUi.ThrottledButton,{fullWidth:true,id:"order-entry-submit-button","data-type":orderlyTypes.OrderSide.BUY,className:orderlyUi.cn(t===orderlyTypes.OrderSide.BUY?"orderly-order-entry-submit-button-buy oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80":"orderly-order-entry-submit-button-sell oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80"),onClick:ne,loading:e.isMutating,disabled:!e.canTrade,children:_}),jsxRuntime.jsx(fo,{canTrade:e.canTrade,quote:n.quote,estLiqPrice:e.estLiqPrice,estLeverage:e.estLeverage,currentLeverage:e.currentLeverage,slippage:he,dp:n.quote_dp,setSlippage:wt,estSlippage:e.estSlippage,orderType:r.order_type,disableFeatures:T}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full"}),ye?jsxRuntime.jsx(Xr,{order:r,symbolInfo:e.symbolInfo,errors:f?K:null,onEdit:()=>{ce(true);},onDelete:()=>{Bt();}}):jsxRuntime.jsx(Ri,{quote_dp:e.symbolInfo.quote_dp,switchState:e.tpslSwitch,onSwitchChanged:e.setTpslSwitch,orderType:r.order_type,errors:f?K:null,isReduceOnly:r.reduce_only,setOrderValue:o,values:{position_type:r.position_type??orderlyTypes.PositionType.PARTIAL,tp:{trigger_price:r.tp_trigger_price??"",PnL:r.tp_pnl??"",Offset:r.tp_offset??"","Offset%":r.tp_offset_percentage??"",ROI:r.tp_ROI??""},sl:{trigger_price:r.sl_trigger_price??"",PnL:r.sl_pnl??"",Offset:r.sl_offset??"","Offset%":r.sl_offset_percentage??"",ROI:r.sl_ROI??""}},showTPSLAdvanced:D,onChange:(y,R)=>{o(y,R);}}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",className:"!oui-mt-0 xl:!oui-mt-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{"data-testid":"oui-testid-orderEntry-reduceOnly-switch",className:"oui-h-[14px]",id:"reduceOnly",checked:r.reduce_only,onCheckedChange:y=>{o("reduce_only",y);}}),jsxRuntime.jsx("label",{htmlFor:"reduceOnly",className:"oui-text-xs",children:F("orderEntry.reduceOnly")})]}),!je&&Hr]}),je&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",className:"!oui-mt-0 xl:!oui-mt-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{className:"oui-h-[14px]",id:Ze,checked:L,onCheckedChange:y=>E(y)}),jsxRuntime.jsx("label",{htmlFor:Ze,className:"oui-text-xs",children:F("orderEntry.soundAlerts")})]}),Hr]}),j&&jsxRuntime.jsxs(orderlyUi.Box,{p:2,r:"md",intensity:700,position:"relative",children:[jsxRuntime.jsx(De,{...Wr}),jsxRuntime.jsx(Zr,{onClick:()=>{ie(false);},className:"oui-group oui-absolute oui-right-2 oui-top-2","data-testid":"oui-testid-orderEntry-pinned-button"})]})]}),jsxRuntime.jsx(orderlyUi.SimpleSheet,{open:xe,onOpenChange:ce,classNames:{body:"oui-h-full oui-pb-0 oui-border-none",overlay:"!oui-bg-base-10/60",content:orderlyUi.cn("oui-rounded-[16px] oui-border-none !oui-p-0",ue?"oui-inset-y-0 oui-right-0 oui-w-[280px]":"!oui-bottom-[40px] oui-right-3 oui-top-[44px] !oui-h-auto oui-w-[360px]")},contentProps:{side:"right",closeable:false},children:jsxRuntime.jsx(orderlyUiTpsl.TPSLAdvancedWidget,{setOrderValue:o,order:r,onSubmit:X,onClose:()=>{ce(false);},symbolLeverage:e.symbolLeverage})})]})};function Di({tpslSwitch:e,order_type:t,order_type_ext:r,side:o,setOrderValues:i}){let[n,s]=orderlyHooks.useLocalStorage("orderly_order_bbo_type",void 0),a=ki.useRef(n),{track:l}=orderlyHooks.useTrack(),c=ki.useMemo(()=>e||[orderlyTypes.OrderType.POST_ONLY,orderlyTypes.OrderType.IOC,orderlyTypes.OrderType.FOK].includes(r)?"disabled":n&&t===orderlyTypes.OrderType.LIMIT?"on":"off",[e,r,t,n]),p=()=>{l(orderlyTypes.TrackerEventName.clickBBOButton),n?(s(void 0),i({order_type_ext:void 0,level:void 0})):s(a.current||orderlyTypes.BBOOrderType.COUNTERPARTY1);},u=m=>{s(m),a.current=m;};return ki.useEffect(()=>{c==="disabled"&&i({order_type_ext:Fe({order_type_ext:r})?void 0:r,level:void 0});},[c,r]),ki.useEffect(()=>{if(c==="on"){let m=Oo(n,o),d=Po(n);i({order_type_ext:m,level:d});}},[n,c,o]),{bboStatus:c,bboType:n,setBBOType:s,onBBOChange:u,toggleBBO:p}}function Ui(){let{state:e}=orderlyHooks.useAccount(),{wrongNetwork:t,disabledConnect:r}=orderlyReactApp.useAppContext();return ki.useMemo(()=>!t&&!r&&(e.status===orderlyTypes.AccountStatusEnum.EnableTrading||e.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),[e.status,t,r])}function Wi(e){let{base_tick:t,order_type:r,order_quantity:o,setValue:i}=e,n=ki.useRef(0),s=ki.useRef(6),a=()=>{if(t<1||r===orderlyTypes.OrderType.SCALED||!o)return;let p=orderlyHooks.utils.formatNumber(o,new orderlyUtils.Decimal(t||"0").toNumber());i("order_quantity",p,{shouldUpdateLastChangedField:false});},l=p=>u=>{n.current=p,[5,6].includes(n.current)&&(s.current=p);},c=p=>u=>{setTimeout(()=>{n.current===p&&(n.current=0);},300),p===3&&a();};return {currentFocusInput:n,lastScaledOrderPriceInput:s,onFocus:orderlyHooks.useMemoizedFn(l),onBlur:orderlyHooks.useMemoizedFn(c)}}function Hi({order_type_ext:e}){let[t,r]=ki.useState(0),o=ki.useRef(null);return ki.useEffect(()=>{let i=o.current;if(!i)return;let n=new ResizeObserver(s=>{for(let a of s){let l=a.contentRect.width;l&&r(l);}});return n.observe(i),()=>{n.unobserve(i);}},[o,e]),{priceInputContainerRef:o,priceInputContainerWidth:t}}var Qu="orderly_order_sound_alert",Gr=e=>{let{symbol:t}=e,[r,o]=orderlyHooks.useLocalStorage("orderly-order-entry-order-type",orderlyTypes.OrderType.LIMIT),[i,n]=orderlyHooks.useLocalStorage("orderly-order-entry-order-side",orderlyTypes.OrderSide.BUY),s=orderlyHooks.useLeverageBySymbol(t),{notification:a}=orderlyHooks.useOrderlyContext(),[l,c]=orderlyHooks.useLocalStorage(Qu,a?.orderFilled?.defaultOpen??false),p=Ui(),{formattedOrder:u,setValue:m,setValues:d,symbolInfo:C,...T}=orderlyHooks.useOrderEntry(t,{initialOrder:{symbol:t,order_type:r,position_type:orderlyTypes.PositionType.PARTIAL,side:i}}),[O,h]=orderlyHooks.useLocalStorage("orderly-order-entry-tp_sl-switch",false),{currentLeverage:L}=orderlyHooks.useMarginRatio(),E=orderlyHooks.useEventEmitter(),Z=ki.useRef(null),F=ki.useRef(null),ue=ki.useRef(null),{bboStatus:ye,bboType:U,setBBOType:K,onBBOChange:f,toggleBBO:Y}=Di({tpslSwitch:O,order_type:u.order_type,order_type_ext:u.order_type_ext,side:u.side,setOrderValues:d}),{currentFocusInput:de,lastScaledOrderPriceInput:be,onFocus:B,onBlur:j}=Wi({base_tick:C?.base_tick,order_type:u.order_type,order_quantity:u.order_quantity,setValue:m}),ie=()=>{d({tp_trigger_price:"",sl_trigger_price:"",position_type:orderlyTypes.PositionType.FULL});},xe=()=>{d({order_type_ext:void 0,position_type:orderlyTypes.PositionType.FULL});},ce=()=>{m("order_quantity",T.maxQty);},Nt=orderlyHooks.useMemoizedFn((_,k,ne)=>{if(_==="order_type"&&o(k),_==="side"&&n(k),_==="reduce_only"&&k||_==="order_type"&&(k===orderlyTypes.OrderType.STOP_LIMIT||k===orderlyTypes.OrderType.STOP_MARKET)){let D={tp_trigger_price:"",sl_trigger_price:"",[_]:k};_==="order_type"&&(D.order_type_ext=""),d(D);return}if(_==="order_type"&&k!==orderlyTypes.OrderType.LIMIT){let D={level:void 0,order_type_ext:void 0,[_]:k};d(D);return}if(_==="order_type"&&k===orderlyTypes.OrderType.SCALED){d({distribution_type:orderlyTypes.DistributionType.FLAT,[_]:k});return}m(_,k,ne);}),kt=_=>{h(_),_?xe():ie();};ki.useEffect(()=>{let _=k=>{m("order_price",k);};return E.on("update:orderPrice",_),()=>{E.off("update:orderPrice",_);}},[]),ki.useEffect(()=>{let _=ne=>{requestAnimationFrame(()=>{ne?.focus();});},k=ne=>{let D=orderlyUtils.removeTrailingZeros(ne[0]),{order_type:X,order_type_ext:Bt}=u;if(de.current===2&&(X===orderlyTypes.OrderType.STOP_LIMIT||X===orderlyTypes.OrderType.STOP_MARKET)){m("trigger_price",D),_(Z.current);return}if(Fe({order_type:X,order_type_ext:Bt})){K(void 0),d({order_type_ext:void 0,level:void 0}),requestAnimationFrame(()=>{E.emit("update:orderPrice",D);}),_(F.current);return}if(X===orderlyTypes.OrderType.STOP_LIMIT||X===orderlyTypes.OrderType.LIMIT){m("order_price",D),_(F.current);return}if(X===orderlyTypes.OrderType.STOP_MARKET){m("trigger_price",D),_(Z.current);return}if(X===orderlyTypes.OrderType.MARKET){K(void 0),d({order_type:orderlyTypes.OrderType.LIMIT,order_price:D}),_(F.current);return}if(X===orderlyTypes.OrderType.SCALED&&be.current){let je=be.current===5?"start_price":"end_price";m(je,D),_(F.current);return}if(X===orderlyTypes.OrderType.TRAILING_STOP){m("activated_price",D),_(ue.current);return}m("order_price",D),_(F.current);};return E.on("orderbook:item:click",k),()=>{E.off("orderbook:item:click",k);}},[u,C]),ki.useEffect(()=>{T.reset(),T.resetMetaState();},[t]),ki.useEffect(()=>{u.order_type===orderlyTypes.OrderType.SCALED&&!u.distribution_type&&m("distribution_type",orderlyTypes.DistributionType.FLAT);},[u.order_type,u.distribution_type]);let he=orderlyHooks.useComputedLTV(),wt=lt(),Rt=()=>{if(ye==="on"&&Y(),u.order_type===orderlyTypes.OrderType.LIMIT){let[_=0,k=0]=wt,ne=new orderlyUtils.Decimal(Xt(_)).add(Xt(k)).div(2).toNumber();requestAnimationFrame(()=>{E.emit("update:orderPrice",ne);});}},{priceInputContainerRef:Ze,priceInputContainerWidth:At}=Hi({order_type_ext:u.order_type_ext});return {...T,side:u.side,type:u.order_type,level:u.level,formattedOrder:u,setOrderValue:Nt,setOrderValues:d,currentLeverage:L,tpslSwitch:O,setTpslSwitch:kt,setMaxQty:ce,symbolInfo:C,onFocus:B,onBlur:j,priceInputRef:F,priceInputContainerRef:Ze,priceInputContainerWidth:At,triggerPriceInputRef:Z,activatedPriceInputRef:ue,canTrade:p,bboStatus:ye,bboType:U,onBBOChange:f,toggleBBO:Y,currentLtv:he,fillMiddleValue:Rt,symbol:t,soundAlert:l,setSoundAlert:c,currentFocusInput:de,symbolLeverage:s}};var Gu=e=>{let t=Gr(e);return jsxRuntime.jsx(zr,{...t,containerRef:e.containerRef,disableFeatures:e.disableFeatures})};
21
+ var De=e=>{let{pinned:t,orderTypeExtra:r}=e,{t:o}=orderlyI18n.useTranslation(),i=n=>s=>{e.onValueChange&&e.onValueChange("order_type_ext",s?n:"");};return Ai.useEffect(()=>{e.onValueChange?.("visible_quantity",e.hidden?0:1);},[e.hidden]),jsxRuntime.jsxs("div",{className:"oui-text-base-contrast-54",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:t?"start":"between",mb:3,width:t?"unset":"100%",className:"oui-gap-x-2 md:oui-gap-x-3",wrap:"wrap",gapY:1,children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-postOnly-checkBox",id:"toggle_order_post_only",className:"oui-peer",color:"white",variant:"radio",disabled:!e.showExtra,checked:r===orderlyTypes.OrderType.POST_ONLY,onCheckedChange:i(orderlyTypes.OrderType.POST_ONLY)}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_post_only",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.postOnly")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-ioc-checkBox",id:"toggle_order_iov",color:"white",className:"oui-peer",variant:"radio",checked:r===orderlyTypes.OrderType.IOC,onCheckedChange:i(orderlyTypes.OrderType.IOC),disabled:!e.showExtra}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_iov",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.ioc")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-fox-checkBox",id:"toggle_order_fok",color:"white",variant:"radio",className:"oui-peer",checked:r===orderlyTypes.OrderType.FOK,onCheckedChange:i(orderlyTypes.OrderType.FOK),disabled:!e.showExtra}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_fok",className:orderlyUi.cn("oui-ml-1 oui-text-2xs peer-data-[disabled]:oui-text-base-contrast-20","oui-whitespace-nowrap oui-break-normal"),children:o("orderEntry.orderType.fok")})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{gapX:6,children:[jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-orderConfirm-checkBox",id:"toggle_order_confirm",color:"white",checked:e.needConfirm,onCheckedChange:n=>{e.setNeedConfirm(!!n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_confirm",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.orderConfirm")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Checkbox,{"data-testid":"oui-testid-orderEntry-hidden-checkBox",id:"toggle_order_hidden",color:"white",checked:e.hidden,onCheckedChange:n=>{e.setHidden(n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_hidden",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.hidden")})]})]}),!t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-3"}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx(orderlyUi.Switch,{"data-testid":"oui-testid-orderEntry-additional-keepVisible-switch",id:"toggle_order_keep_visible",onCheckedChange:n=>{e.setPinned(n);}}),jsxRuntime.jsx("label",{htmlFor:"toggle_order_keep_visible",className:"oui-ml-1 oui-text-2xs",children:o("orderEntry.keepVisible")})]})]})]})};function Zr(e){let[t,r]=Ai.useState(false);return jsxRuntime.jsxs(orderlyUi.PopoverRoot,{open:t,onOpenChange:r,children:[jsxRuntime.jsx(orderlyUi.PopoverTrigger,{asChild:true,children:jsxRuntime.jsx("button",{"data-testid":"oui-testid-orderEntry-additional-button",onClick:()=>{r(true);},children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-white/[.36] hover:oui-fill-white/80",children:jsxRuntime.jsx("path",{d:"M3.332 2.665a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V3.332a.667.667 0 0 0-.667-.667zm-8 4a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667V7.332a.667.667 0 0 0-.667-.667zm-8 4a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667zm4 0a.667.667 0 0 0-.667.667v1.333c0 .368.299.667.667.667h1.333a.667.667 0 0 0 .667-.667v-1.333a.667.667 0 0 0-.667-.667z"})})})}),jsxRuntime.jsx(orderlyUi.PopoverContent,{side:"top",align:"end",className:"oui-w-[230px]",children:jsxRuntime.jsx(De,{...e})})]})}var Xr="M10.007 1.302a.74.74 0 0 0-.486.214c-1.033.989-1.349 1.815-.972 2.948-.88.675-1.437.84-2.536.84-1.503 0-2.484.182-3.152.85v.02a1.583 1.583 0 0 0 0 2.248l1.867 1.882-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.194 1.87 1.861a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.523.854-3.144 0-1.03.212-1.758.852-2.523 1.233.361 1.95.015 2.961-.995a.68.68 0 0 0 .188-.48c0-.234-.06-.593-.209-1.04a5.34 5.34 0 0 0-1.312-2.103 5.35 5.35 0 0 0-2.104-1.312c-.448-.15-.808-.208-1.042-.208",jr=e=>{let[t,r]=Ai.useState(Xr);return jsxRuntime.jsx("button",{...e,children:jsxRuntime.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",focusable:false,onMouseEnter:()=>{r('M10.008 1.302a.74.74 0 0 0-.486.214c-1.033.989-1.349 1.815-.972 2.948-.88.675-1.437.84-2.536.84-1.503 0-2.484.182-3.152.85v.02a1.583 1.583 0 0 0 0 2.248l1.867 1.882-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.194 1.87 1.861a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.523.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.48c0-.234-.06-.593-.209-1.04a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.15-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.107.507.508.94 1.13 1.119 1.945-.636.61-1.026.658-1.662.323a.67.67 0 0 0-.779.117c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.292-.076 1.773-.48 2.206-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.515 2.226-.514 1.742.001 2.668-.448 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.686-.29-1.047.321-1.67"');},onMouseLeave:()=>{r(Xr);},className:"oui-text-primary-darken",children:jsxRuntime.jsx("path",{d:t})})})};function eo(e){let{order:t,symbolInfo:r,onEdit:o,onDelete:i,errors:n}=e,{getErrorMsg:s}=orderlyReactApp.useOrderEntryFormErrorMsg(n),{t:a}=orderlyI18n.useTranslation(),l=()=>{let p=s("tp_trigger_price");return t.tp_trigger_price||t.tp_order_price?jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",gapY:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.tpTriggerPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.tp_trigger_price??""})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.tpOrderPrice")}),t.tp_order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.tp_order_price??""}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:"Market"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.totalEstTpPnl")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),coloring:true,dp:2,children:Number(t.tp_pnl)})]})]}),p&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"start",gap:2,className:"oui-w-full",children:[jsxRuntime.jsx("div",{className:"oui-relative oui-top-[7px] oui-size-1 oui-rounded-full oui-bg-danger"}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-danger",children:p})]})]}):null},c=()=>{if(t.sl_trigger_price||t.sl_order_price){let p=s("sl_trigger_price");return jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full",gap:4,children:jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"between",gapY:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.slTriggerPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.sl_trigger_price??""})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.slOrderPrice")}),t.sl_order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx(orderlyUi.Text.numeral,{suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),className:"oui-text-base-contrast",dp:r.quote_dp,children:t.sl_order_price??""}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:"Market"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.totalEstSlPnl")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{coloring:true,suffix:jsxRuntime.jsx(orderlyUi.Text,{className:"oui-ml-1 oui-text-base-contrast-36",children:r.quote}),dp:2,children:Number(t.sl_pnl)})]}),p&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"start",itemAlign:"start",gap:2,className:"oui-w-full",children:[jsxRuntime.jsx("div",{className:"oui-relative oui-top-[7px] oui-size-1 oui-rounded-full oui-bg-danger"}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-danger",children:p})]})]})})}return null};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",className:"oui-w-full oui-text-2xs",gap:4,children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"start",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.advanced.title")}),jsxRuntime.jsxs(orderlyUi.Flex,{gap:2,children:[jsxRuntime.jsx(mn,{size:12,className:"oui-cursor-pointer oui-text-base-contrast-54 hover:oui-text-base-contrast",opacity:1,onClick:i}),jsxRuntime.jsx(fn,{size:12,className:"oui-cursor-pointer oui-text-base-contrast-54 hover:oui-text-base-contrast",onClick:o})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"start",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:a("tpsl.mode")}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:t.position_type===orderlyTypes.PositionType.FULL?a("tpsl.fullPosition"):a("tpsl.partialPosition")})]}),l(),c(),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-mb-2 oui-w-full"})]})}var mn=e=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e.size,height:e.size,viewBox:"0 0 12 12",fill:"currentColor",...e,children:jsxRuntime.jsx("path",{d:"M5.99903 0.976562C5.44653 0.976562 4.99903 1.42406 4.99903 1.97656H2.49902C2.22302 1.97656 1.99902 2.20056 1.99902 2.47656C1.99902 2.75256 2.22302 2.97656 2.49902 2.97656H9.49903C9.77503 2.97656 9.99903 2.75256 9.99903 2.47656C9.99903 2.20056 9.77503 1.97656 9.49903 1.97656H6.99903C6.99903 1.42406 6.55153 0.976562 5.99903 0.976562ZM2.49902 3.97655V8.97654C2.49902 10.0715 3.40152 10.961 4.49903 10.961L7.51453 10.9765C8.61203 10.9765 9.49903 10.074 9.49903 8.97654V3.97655H2.49902ZM4.99903 5.47655C5.27503 5.47655 5.49903 5.70055 5.49903 5.97655V8.97654C5.49903 9.25254 5.27503 9.47654 4.99903 9.47654C4.72303 9.47654 4.49903 9.25254 4.49903 8.97654V5.97655C4.49903 5.70055 4.72303 5.47655 4.99903 5.47655ZM6.99903 5.47655C7.27503 5.47655 7.49903 5.70055 7.49903 5.97655V8.97654C7.49903 9.25254 7.27503 9.47654 6.99903 9.47654C6.72303 9.47654 6.49903 9.25254 6.49903 8.97654V5.97655C6.49903 5.70055 6.72303 5.47655 6.99903 5.47655Z"})}),fn=e=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12",width:e.size,height:e.size,fill:"currentColor",...e,children:jsxRuntime.jsx("path",{d:"M8.49779 0.976562C8.36529 0.976562 8.23229 1.02357 8.13829 1.11707C7.86029 1.39507 6.85979 2.39558 6.63779 2.61808L2.13529 7.12059L1.63479 7.62059C1.56529 7.69059 1.52929 7.78958 1.50979 7.88658L1.00979 10.3881C0.939788 10.7381 1.23779 11.0361 1.58779 10.9666C1.90079 10.9036 3.77679 10.5286 4.08929 10.4661C4.18629 10.4466 4.28529 10.4106 4.35529 10.3411L4.85529 9.84059L9.35779 5.33808C9.58029 5.11608 10.5808 4.11506 10.8588 3.83756C10.9523 3.74356 10.9993 3.61056 10.9993 3.47806C10.9993 2.65956 10.7908 2.07456 10.3583 1.63306C9.92179 1.18756 9.33879 0.976562 8.49779 0.976562ZM8.69479 1.98606C9.14629 2.01256 9.43879 2.11608 9.63929 2.32108C9.84429 2.53008 9.97379 2.82008 10.0018 3.26258C9.72779 3.53608 9.32679 3.93106 8.99829 4.25956C8.60179 3.86306 8.11279 3.37407 7.71629 2.97757C8.04529 2.64907 8.42129 2.25956 8.69479 1.98606ZM6.99729 3.69657L8.27929 4.97858L4.49579 8.76207L3.21379 7.48009L6.99729 3.69657ZM2.49479 8.19908L3.77679 9.48107L3.72979 9.52809C3.39979 9.59409 2.73329 9.73359 2.11929 9.85659L2.44779 8.24608L2.49479 8.19908Z"})});var Je=Ai__default.default.forwardRef((e,t)=>{let r=Ai.useId();return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:14,height:14,viewBox:"0 0 14 14",fill:"currentColor",ref:t,focusable:false,...e,children:[jsxRuntime.jsx("path",{d:"M6.16411 1.53106C6.61974 1.07566 7.35888 1.07551 7.81442 1.53106L8.48833 2.20496C8.6797 2.39624 8.93064 2.51452 9.19755 2.54106L9.3132 2.54676H10.2662C10.9104 2.54691 11.4328 3.06926 11.4329 3.71343V4.66647C11.4329 4.97589 11.5559 5.27312 11.7747 5.49191L12.4492 6.16582C12.9047 6.62142 12.9047 7.36054 12.4492 7.81613L11.7753 8.49004L11.6972 8.57549C11.5272 8.78302 11.433 9.04426 11.4329 9.31491V10.2685L11.4272 10.3876C11.3715 10.9366 10.9348 11.373 10.3859 11.4289L10.2662 11.4352H9.3132L9.19755 11.4409C8.93066 11.4674 8.67969 11.5857 8.48833 11.777L7.81442 12.4509L7.72555 12.5306C7.29789 12.8795 6.68066 12.8794 6.25297 12.5306L6.16411 12.4509L5.4902 11.777C5.29887 11.5857 5.04786 11.4675 4.78097 11.4409L4.66533 11.4352H3.71171L3.59265 11.4289C3.04358 11.3731 2.60705 10.9367 2.55131 10.3876L2.54505 10.2685V9.31491C2.54499 9.04416 2.45089 8.78306 2.28072 8.57549L2.20325 8.49004L1.52934 7.81613C1.10213 7.38905 1.07534 6.71297 1.44902 6.25469L1.52934 6.16582L2.20382 5.49191C2.42248 5.27314 2.54505 4.97579 2.54505 4.66647V3.71343C2.54513 3.10945 3.00442 2.61221 3.59265 2.55246L3.71171 2.54676H4.66533L4.78097 2.54106C5.00968 2.51826 5.22694 2.4281 5.40475 2.28244L5.4902 2.20496L6.16411 1.53106ZM6.31507 3.02983C5.87756 3.46727 5.28401 3.71336 4.66533 3.71343H3.71171V4.66647C3.71171 5.28521 3.46614 5.87922 3.02869 6.31678L2.35421 6.99069L3.02812 7.6646C3.46577 8.10214 3.71164 8.69607 3.71171 9.31491V10.2685H4.66533C5.28396 10.2686 5.87757 10.5142 6.31507 10.9515L6.98898 11.6255L7.66289 10.9515C8.10045 10.5141 8.69446 10.2685 9.3132 10.2685H10.2662V9.31491C10.2663 8.69604 10.5127 8.10214 10.9504 7.6646L11.6243 6.99069L10.9498 6.31678C10.5122 5.8792 10.2662 5.28531 10.2662 4.66647V3.71343H9.3132C8.69438 3.71343 8.10047 3.46739 7.66289 3.02983L6.98898 2.35592L6.31507 3.02983ZM8.52934 4.64255C8.7571 4.41479 9.12639 4.41489 9.35421 4.64255C9.58202 4.87035 9.58202 5.23961 9.35421 5.46742L5.4657 9.35593C5.2379 9.58372 4.86863 9.58373 4.64083 9.35593C4.41318 9.12811 4.41308 8.75881 4.64083 8.53106L8.52934 4.64255ZM8.66435 7.83265C9.1245 7.83272 9.49777 8.2059 9.49777 8.66607C9.49769 9.12616 9.12445 9.49941 8.66435 9.49948C8.20419 9.49948 7.83101 9.12621 7.83094 8.66607C7.83094 8.20586 8.20415 7.83265 8.66435 7.83265ZM5.33126 4.49956C5.79141 4.49963 6.16468 4.87282 6.16468 5.33298C6.1646 5.79307 5.79136 6.16575 5.33126 6.16582C4.87111 6.16582 4.49793 5.79311 4.49785 5.33298C4.49785 4.87277 4.87106 4.49956 5.33126 4.49956Z",fill:`url(#${r})`}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:r,x1:"12.7908",y1:"6.99084",x2:"1.1875",y2:"6.99084",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-end))"}),jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-start))",offset:1})]})})]})});process.env.NODE_ENV!=="production"&&(Je.displayName="EffectiveFee");var Cn=e=>{let{content:t}=e,{isMobile:r}=orderlyUi.useScreen(),{t:o}=orderlyI18n.useTranslation();return r?jsxRuntime.jsx(Je,{onClick:()=>{orderlyUi.modal.dialog({title:o("common.tips"),content:t});}}):jsxRuntime.jsx(orderlyUi.Tooltip,{content:t,className:"oui-p-1.5 oui-text-base-contrast-54",children:jsxRuntime.jsx(Je,{className:"oui-cursor-pointer"})})},Qt=e=>{let{t}=orderlyI18n.useTranslation(),{effectiveTakerFee:r,effectiveMakerFee:o}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",width:"100%",gap:1,children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:t("common.fees")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),": --% /"," ",t("portfolio.feeTier.column.maker"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:r}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:"/"}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.maker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:o})]})})]}),jsxRuntime.jsx(Cn,{content:t("portfolio.feeTier.effectiveFee.tooltip")})]})};var Gt=e=>jsxRuntime.jsx(Qt,{...e});var Ht=e=>{let{t}=orderlyI18n.useTranslation(),{takerFee:r,makerFee:o}=e;return jsxRuntime.jsx(orderlyUi.Flex,{itemAlign:"center",justify:"between",width:"100%",gap:1,children:jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:t("common.fees")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),": --% /"," ",t("portfolio.feeTier.column.maker"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.taker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:r}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:"/"}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-truncate",size:"2xs",children:[t("portfolio.feeTier.column.maker"),":"]}),jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-base-contrast-80",children:o})]})})]})})};var Kt=e=>jsxRuntime.jsx(Ht,{...e});var Sn=e=>typeof e<"u"&&e!==null,Yt=()=>{let{refereeRebate:e,...t}=orderlyHooks.useFeeState();return Sn(e)?jsxRuntime.jsx(Gt,{...ramda.pick(["effectiveTakerFee","effectiveMakerFee"],t)}):jsxRuntime.jsx(Kt,{...ramda.pick(["takerFee","makerFee"],t)})};var lo=[.01,.05,.1],co=Ai.forwardRef((e,t)=>{let{t:r}=orderlyI18n.useTranslation(),[o,i]=Ai.useState(),[n,s]=Ai.useState(""),[a,l]=Ai.useState(void 0);Ai.useImperativeHandle(t,()=>({getValue:()=>n?new orderlyUtils.Decimal(n)?.toNumber():o})),Ai.useEffect(()=>{e.initialValue&&!lo.includes(e.initialValue)?s(e.initialValue.toString()):i(e.initialValue);},[e.initialValue,open]);let c=m=>{i(m),s(""),l(void 0);},p=m=>{if(!m){s(m);return}let d=new orderlyUtils.Decimal(m);i(void 0),d.gt(3)?(s("3"),l(r("orderEntry.slippage.error.exceed"))):(s(m),l(void 0));},u=e.isMobile?jsxRuntime.jsx("button",{onClick:()=>{orderlyUi.modal.alert({title:r("common.tips"),message:jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:r("orderEntry.slippage.tips")})});},children:jsxRuntime.jsx(orderlyUi.ExclamationFillIcon,{className:"oui-text-base-contrast-54",size:16})}):jsxRuntime.jsx(orderlyUi.Tooltip,{content:jsxRuntime.jsx(orderlyUi.Text,{intensity:80,size:"2xs",children:r("orderEntry.slippage.tips")}),className:"oui-w-[260px] oui-bg-base-6",arrow:{className:"oui-fill-base-6"},children:jsxRuntime.jsx(orderlyUi.TooltipTrigger,{children:jsxRuntime.jsx(orderlyUi.ExclamationFillIcon,{className:"oui-text-base-contrast-54",size:16})})});return jsxRuntime.jsxs("div",{className:"oui-text-2xs",children:[jsxRuntime.jsxs(orderlyUi.Flex,{mb:2,gapX:1,children:[jsxRuntime.jsx(orderlyUi.Text,{size:"xs",children:r("orderEntry.slippage")}),u]}),jsxRuntime.jsxs(orderlyUi.Flex,{gapX:2,children:[lo.map(m=>jsxRuntime.jsx(Mn,{value:m,isActive:o===m,onClick:()=>{c(m);}},m)),jsxRuntime.jsx(orderlyUi.Input,{suffix:"%",formatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(2)],value:n,onValueChange:p,classNames:{root:orderlyUi.cn("oui-rounded-md oui-bg-base-6","oui-h-[40px] oui-w-[74px]"),input:"oui-text-base-contrast",additional:"oui-pl-1"}})]}),!!a&&jsxRuntime.jsx(orderlyUi.Box,{mt:5,className:"-oui-mb-5",children:jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",color:"danger",children:a})})]})}),Mn=({value:e,isActive:t,onClick:r})=>jsxRuntime.jsx(orderlyUi.Flex,{intensity:600,justify:"center",itemAlign:"center",r:"md",width:74,height:40,className:orderlyUi.cn("oui-cursor-pointer oui-select-none",t&&"oui-bg-primary-light"),onClick:r,children:jsxRuntime.jsxs(orderlyUi.Text,{size:"sm",intensity:80,children:[e,"%"]})});var po=e=>{let{t}=orderlyI18n.useTranslation(),[r,{setTrue:o,setFalse:i,toggle:n}]=orderlyHooks.useBoolean(false),{isMobile:s}=orderlyUi.useScreen(),a=Ai.useRef(null),l=()=>{let c=a.current?.getValue();return e.setSlippage(c?c.toString():"1"),i(),Promise.resolve(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.SimpleDialog,{open:r,onOpenChange:n,title:t("common.settings"),contentProps:{size:s?"xs":"sm"},actions:{primary:{disabled:false,label:t("common.save"),onClick:l},secondary:{label:t("common.cancel"),onClick:()=>i()}},children:jsxRuntime.jsx(co,{ref:a,isMobile:s,initialValue:e.slippage?Number(e.slippage):void 0})}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:t("orderEntry.slippage")}),jsxRuntime.jsx(orderlyUiConnector.AuthGuard,{fallback:()=>jsxRuntime.jsxs(orderlyUi.Text,{size:"2xs",children:[t("orderEntry.slippage.est"),": -% / ",t("common.max"),": --%"]}),children:jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{size:"2xs",rule:"percentages",prefix:`${t("orderEntry.slippage.est")}: `,suffix:` / ${t("common.max")}: `,children:e.estSlippage??0}),jsxRuntime.jsx("button",{className:"oui-text-2xs",onClick:()=>o(),children:jsxRuntime.jsxs(orderlyUi.Flex,{className:"oui-gap-0.5",as:"span",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-text-primary",children:`${e.slippage||"-"}%`}),jsxRuntime.jsx(orderlyUi.EditIcon,{className:"oui-text-primary oui-hidden md:oui-block",size:12,opacity:1})]})})]})})]})]})};var mo=e=>jsxRuntime.jsx(po,{...e});function yo(e){let{canTrade:t,disableFeatures:r,orderType:o}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs("div",{className:"oui-space-y-[2px] xl:oui-space-y-1",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:i("orderEntry.estLiqPrice")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:e.quote,size:"2xs",dp:e.dp,className:"oui-text-base-contrast-80",unitClassName:"oui-ml-1 oui-text-base-contrast-36",children:t?e.estLiqPrice??"--":"--"})]}),o===orderlyTypes.OrderType.MARKET&&!r?.includes("slippageSetting")&&jsxRuntime.jsx(mo,{slippage:e.slippage,setSlippage:e.setSlippage,estSlippage:e.estSlippage}),!r?.includes("feesInfo")&&jsxRuntime.jsx(Yt,{})]})}var es=e=>e>=0&&e<50?"oui-text-success":e>=50&&e<80?"oui-text-warning":e>=80?"oui-text-danger":"",jt=e=>{let{t}=orderlyI18n.useTranslation(),{ltv_threshold:r,negative_usdc_threshold:o,isThresholdLoading:i,holdingData:n=[],currentLtv:s,onConvert:a}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{gap:1,className:"oui-w-72 oui-max-w-72",direction:"column",children:[jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("common.assets")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("transfer.deposit.collateralContribution")})]}),n.map((l,c)=>jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:80,size:"xs",children:l.token}),jsxRuntime.jsx(orderlyUi.Text,{size:"xs",intensity:80,className:orderlyUi.cn(Number(l.collateralContribution)<0&&"oui-text-warning"),children:orderlyUtils.removeTrailingZeros(l.collateralContribution)})]},`item-${c}`)),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full"}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",justify:"between",itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:36,size:"xs",children:t("transfer.LTV.currentLTV")}),jsxRuntime.jsxs(orderlyUi.Text,{size:"xs",intensity:36,className:orderlyUi.cn("oui-select-none",es(s)),children:[s,"%"]})]}),jsxRuntime.jsx(orderlyUi.Text,{className:"oui-py-2",intensity:54,size:"2xs",children:t("transfer.LTV.tooltip",{threshold:i?"-":r,usdcThreshold:i?"-":o})}),jsxRuntime.jsx(orderlyUi.Button,{fullWidth:true,size:"md",variant:"outlined",color:"secondary",onClick:a,children:t("transfer.convert.convertAssets")})]})};var ds=()=>{let{data:e,error:t,isLoading:r}=orderlyHooks.useQuery("/v1/public/auto_convert_threshold",{errorRetryCount:3});return {ltv_threshold:new orderlyUtils.Decimal(e?.ltv_threshold??0).mul(100).toNumber(),negative_usdc_threshold:e?.negative_usdc_threshold,isLoading:r,error:t}},Jt=()=>{let{data:e=[],isLoading:t}=orderlyHooks.useHoldingStream(),{ltv_threshold:r,negative_usdc_threshold:o,isLoading:i}=ds(),n=orderlyHooks.useTokensInfo(),{getIndexPrice:s}=orderlyHooks.useIndexPricesStream(),a=e.map(p=>{let u=n?.find(({token:T})=>T===p.token),m=s(p.token),d=u?orderlyPerp.account.collateralRatio({baseWeight:u.base_weight??0,discountFactor:u.discount_factor??0,collateralQty:p.holding,collateralCap:u?.user_max_qty??p.holding,indexPrice:m}):orderlyUtils.zero,C=orderlyPerp.account.collateralContribution({collateralQty:p.holding,collateralCap:u?.user_max_qty??p.holding,collateralRatio:d.toNumber(),indexPrice:m});return {...p,collateralContribution:C}}),l=orderlyHooks.useComputedLTV(),c=Ai.useCallback(async()=>orderlyUi.modal.show("ConvertDialogId"),[]);return {holdingData:a,isHoldingLoading:t,ltv_threshold:r,negative_usdc_threshold:o,isThresholdLoading:i,currentLtv:l,onConvert:c}};var it=()=>{let e=Jt();return jsxRuntime.jsx(jt,{...e})};var vo=e=>{let{canTrade:t,currentLtv:r,quote:o,freeCollateral:i}=e,{t:n}=orderlyI18n.useTranslation(),s=Ai.useMemo(()=>typeof r=="number"&&!Number.isNaN(r)&&r>0,[r]);return jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",children:n("common.available")}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"center",gap:1,children:[s&&jsxRuntime.jsx(orderlyUi.Tooltip,{className:"oui-bg-base-6 oui-p-2",content:jsxRuntime.jsx(it,{}),children:jsxRuntime.jsx(orderlyUi.InfoCircleIcon,{className:"oui-cursor-pointer oui-text-warning oui-opacity-80"})}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:o,size:"2xs",className:"oui-text-base-contrast-80",unitClassName:"oui-ml-1 oui-text-base-contrast-54",dp:2,padding:false,children:t?i:0})]})]})};function Fe(e){let{order_type:t,order_type_ext:r}=e,o=[orderlyTypes.OrderType.ASK,orderlyTypes.OrderType.BID].includes(r);return t?t===orderlyTypes.OrderType.LIMIT&&o:o}function ho(e,t){if([orderlyTypes.BBOOrderType.COUNTERPARTY1,orderlyTypes.BBOOrderType.COUNTERPARTY5].includes(e))return t===orderlyTypes.OrderSide.BUY?orderlyTypes.OrderType.ASK:orderlyTypes.OrderType.BID;if([orderlyTypes.BBOOrderType.QUEUE1,orderlyTypes.BBOOrderType.QUEUE5].includes(e))return t===orderlyTypes.OrderSide.BUY?orderlyTypes.OrderType.BID:orderlyTypes.OrderType.ASK}function Eo(e){if([orderlyTypes.BBOOrderType.COUNTERPARTY1,orderlyTypes.BBOOrderType.QUEUE1].includes(e))return orderlyTypes.OrderLevel.ONE;if([orderlyTypes.BBOOrderType.COUNTERPARTY5,orderlyTypes.BBOOrderType.QUEUE5].includes(e))return orderlyTypes.OrderLevel.FIVE}function So(e){let t=e?.data?.rows||[];if(t.length>0){let r=t.length,o=t.filter(i=>i.success).length;return o===r?orderlyI18n.i18n.t("orderEntry.scaledOrder.fullySuccessful",{total:r}):o===0?orderlyI18n.i18n.t("orderEntry.scaledOrder.allFailed"):orderlyI18n.i18n.t("orderEntry.scaledOrder.partiallySuccessful",{successCount:o,total:r})}}var tr=e=>Number.isNaN(Number(e))?0:Number(e);var nr=e=>{let{symbolInfo:t,order:r,onConfirm:o,onCancel:i}=e,{quote:n,quote_dp:s,base_dp:a}=t,{side:l,order_type:c,order_type_ext:p,level:u,symbol:m}=r,{t:d}=orderlyI18n.useTranslation(),[{rows:C}]=orderlyHooks.usePositionStream(m),h=C?.[0]?.position_qty,[v,I]=orderlyHooks.useLocalStorage("orderly_order_confirm",true),R=()=>r.position_type===orderlyTypes.PositionType.FULL?jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.positionType.full")}):jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.positionType.partial")}),J=()=>{if(c===orderlyTypes.OrderType.MARKET||c===orderlyTypes.OrderType.STOP_MARKET)return jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:d("common.marketPrice")});if(Fe({order_type:c,order_type_ext:p})){let B=orderlyUtils.getBBOType({type:p,side:l,level:u}),$={[orderlyTypes.BBOOrderType.COUNTERPARTY1]:d("orderEntry.bbo.counterparty1"),[orderlyTypes.BBOOrderType.COUNTERPARTY5]:d("orderEntry.bbo.counterparty5"),[orderlyTypes.BBOOrderType.QUEUE1]:d("orderEntry.bbo.queue1"),[orderlyTypes.BBOOrderType.QUEUE5]:d("orderEntry.bbo.queue5")}[B];return jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:$})}return jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:n,rule:"price",className:"oui-text-base-contrast",unitClassName:"oui-text-base-contrast-36 oui-ml-1",dp:s,padding:false,children:r.order_price})},A=({price:B,isOrderPrice:$,isEnable:ee,colorType:de})=>ee?!B&&$?jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36",children:d("common.marketPrice")}):jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:"USDC",rule:"price",className:orderlyUi.cn("oui-text-base-contrast",de==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),unitClassName:"oui-text-base-contrast-36 oui-ml-1",dp:s,padding:false,children:B}):jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast-36",children:"-- USDC"}),ye=()=>{if(!h||!r.order_quantity)return null;let B=new orderlyUtils.Decimal(r.order_quantity);return r.position_type===orderlyTypes.PositionType.FULL&&(B=B.plus(new orderlyUtils.Decimal(h??0))),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:r.position_type===orderlyTypes.PositionType.FULL?d("common.positionQty"):d("common.orderQty")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:a,padding:false,className:"oui-text-base-contrast",children:B.toNumber()})]})},j=()=>{if(c===orderlyTypes.OrderType.TRAILING_STOP){let{activated_price:B,callback_value:$,callback_rate:ee}=r,de=ee?jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("orderEntry.trailingRate")}),jsxRuntime.jsxs(orderlyUi.Text,{className:"oui-text-base-contrast",children:[ee,"%"]})]}):jsxRuntime.jsx(st,{title:d("orderEntry.trailingValue"),value:$,unit:n,dp:s});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[B&&jsxRuntime.jsx(st,{title:d("common.triggerPrice"),value:B,unit:n,dp:s}),de]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("common.price")}),J()]}),jsxRuntime.jsx(st,{title:d("common.estTotal"),value:r.total,unit:n,dp:s})]})},M=jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"symbol",showIcon:true,children:r.symbol}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"end",gapX:1,children:[jsxRuntime.jsx(Es,{type:c}),l===orderlyTypes.OrderSide.BUY?jsxRuntime.jsx(orderlyUi.Badge,{color:"buy",size:"sm",children:d("common.buy")}):jsxRuntime.jsx(orderlyUi.Badge,{color:"sell",size:"sm",children:d("common.sell")})]})]}),V=jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("common.orderQty")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:a,padding:false,className:"oui-text-base-contrast",children:r.order_quantity})]}),f=(c===orderlyTypes.OrderType.STOP_LIMIT||c===orderlyTypes.OrderType.STOP_MARKET&&r.trigger_price)&&jsxRuntime.jsx(st,{title:d("common.trigger"),value:r.trigger_price,unit:n,dp:s}),Y=(r.tp_trigger_price||r.sl_trigger_price)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-4"}),jsxRuntime.jsxs("div",{className:orderlyUi.textVariants({size:"sm",intensity:54,className:"oui-space-y-1 oui-w-full oui-flex oui-flex-col oui-gap-3"}),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-contrast",children:R()}),ye(),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",itemAlign:"start",gap:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.tpTriggerPrice")}),A({price:r.tp_trigger_price??"",isOrderPrice:false,isEnable:!!r.tp_trigger_price,colorType:"TP"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.tpOrderPrice")}),A({price:r.tp_order_price??"",isOrderPrice:true,isEnable:!!r.tp_trigger_price,colorType:"TP"})]})]}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",justify:"between",itemAlign:"start",gap:1,className:"oui-w-full",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.slTriggerPrice")}),A({price:r.sl_trigger_price??"",isOrderPrice:false,isEnable:!!r.sl_trigger_price,colorType:"SL"})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-w-full",children:[jsxRuntime.jsx(orderlyUi.Text,{children:d("tpsl.slOrderPrice")}),A({price:r.sl_order_price??"",isOrderPrice:true,isEnable:!!r.sl_trigger_price,colorType:"SL"})]})]})]})]}),be=jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,pt:4,pb:5,children:[jsxRuntime.jsx(orderlyUi.Checkbox,{id:"orderConfirm",color:"white",onCheckedChange:B=>{I(!B);}}),jsxRuntime.jsx("label",{htmlFor:"orderConfirm",className:orderlyUi.textVariants({size:"xs",intensity:54}),children:d("orderEntry.disableOrderConfirm")})]}),xe=jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:3,children:[jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"md",onClick:()=>i(),children:d("common.cancel")}),jsxRuntime.jsx(orderlyUi.Button,{size:"md",onClick:()=>o(),children:d("common.confirm")})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[M,jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-my-4"}),jsxRuntime.jsxs("div",{className:orderlyUi.textVariants({size:"sm",intensity:54,className:"oui-space-y-1"}),children:[V,f,j()]}),Y,be,xe]})},st=e=>{let{title:t,value:r,unit:o,dp:i}=e;return jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:t}),jsxRuntime.jsx(orderlyUi.Text.numeral,{unit:o,rule:"price",dp:i,padding:false,className:"oui-text-base-contrast",unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:r})]})};nr.displayName="OrderConfirmDialog";var Es=e=>{let{t}=orderlyI18n.useTranslation(),r=Ai.useMemo(()=>{switch(e.type){case orderlyTypes.OrderType.LIMIT:return t("orderEntry.orderType.limit");case orderlyTypes.OrderType.MARKET:return t("common.marketPrice");case orderlyTypes.OrderType.STOP_LIMIT:return t("orderEntry.orderType.stopLimit");case orderlyTypes.OrderType.STOP_MARKET:return t("orderEntry.orderType.stopMarket");case orderlyTypes.OrderType.TRAILING_STOP:return t("orderEntry.orderType.trailingStop");default:return ""}},[e.type]);return jsxRuntime.jsx(orderlyUi.Badge,{color:"neutral",size:"sm",children:r})},Ss=e=>{let{close:t,resolve:r,reject:o,...i}=e;return jsxRuntime.jsx(nr,{...i,onCancel:()=>{o(),t();},onConfirm:()=>{r(),t();}})},sr="orderConfirm";orderlyUi.registerSimpleDialog(sr,Ss,{size:"sm",title:()=>orderlyI18n.i18n.t("orderEntry.orderConfirm")});var ur=e=>{let{order:t,symbolInfo:r,dataSource:o,national:i,askAndBid:n,totalQuantity:s}=e,{base:a,quote:l,base_dp:c,quote_dp:p}=r,{t:u}=orderlyI18n.useTranslation(),m=()=>{e.reject(),e.close?.();},d=()=>{e.resolve(),e.close?.();},C=Ai.useMemo(()=>[{title:u("common.symbol"),dataIndex:"symbol",width:125,render:(T,h)=>jsxRuntime.jsxs(orderlyUi.Flex,{gap:2,children:[jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-h-[38px] oui-w-1 oui-shrink-0 oui-rounded-[1px]",h.side===orderlyTypes.OrderSide.BUY?"oui-bg-trade-profit":"oui-bg-trade-loss")}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",children:[jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,children:[jsxRuntime.jsx(orderlyUi.TokenIcon,{symbol:T,className:"oui-size-3"}),jsxRuntime.jsx(orderlyUi.Text.formatted,{rule:"symbol",size:"xs",formatString:"base-type",children:T})]}),jsxRuntime.jsx(orderlyUi.Badge,{color:"neutral",size:"xs",children:u("orderEntry.orderType.limit")})]})]})},{title:u("common.quantity"),dataIndex:"order_quantity",width:100,render:(T,h)=>jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:c,padding:false,color:h.side===orderlyTypes.OrderSide.BUY?"buy":"sell",children:T})},{title:u("common.orderPrice"),dataIndex:"order_price",width:100,render:(T,h)=>{let v=!!(h.side===orderlyTypes.OrderSide.BUY?n?.[0]&&Number(T)>=n?.[0]:n?.[1]&&Number(T)<=n?.[1]);return jsxRuntime.jsxs(orderlyUi.Flex,{gapX:1,children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",dp:p,children:T}),v&&jsxRuntime.jsx(orderlyUi.Tooltip,{content:u("orderEntry.confirmScaledOrder.orderPrice.warning"),className:"oui-w-[240px] oui-text-2xs oui-font-semibold oui-text-base-contrast-80",children:jsxRuntime.jsx(Bs,{className:"oui-text-warning-darken"})})]})}}],[u,r,n,c,p]);return jsxRuntime.jsxs("div",{className:"oui-font-semibold",children:[jsxRuntime.jsx(orderlyUi.DataTable,{classNames:{root:orderlyUi.cn("oui-bg-base-7","oui-rounded-lg","oui-overflow-hidden",t.orders?.length>=6&&"oui-h-[320px]"),scroll:"!oui-min-h-[130px]"},dataSource:o,columns:C,bordered:true,onRow:()=>({className:orderlyUi.cn("oui-h-[50px]")})}),jsxRuntime.jsxs("div",{className:"oui-mb-5 oui-mt-4 oui-text-2xs",children:[jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("orderEntry.totalOrders")}),jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:t.orders?.length})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",mt:2,children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("orderEntry.totalQuantity")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",unit:a,dp:c,padding:false,intensity:80,unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:s})]}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",mt:2,children:[jsxRuntime.jsx(orderlyUi.Text,{children:u("common.notional")}),jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",unit:l,dp:p,padding:false,intensity:80,unitClassName:"oui-text-base-contrast-36 oui-ml-1",children:i})]})]}),jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:3,children:[jsxRuntime.jsx(orderlyUi.Button,{color:"secondary",size:"md",onClick:m,children:u("common.cancel")}),jsxRuntime.jsx(orderlyUi.Button,{size:"md",onClick:d,children:u("common.confirm")})]})]})},Bs=Ai.forwardRef((e,t)=>jsxRuntime.jsx("svg",{width:"12",height:"13",viewBox:"0 0 12 13",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",ref:t,...e,children:jsxRuntime.jsx("path",{d:"M5.99951 1.50708C3.23811 1.50708 0.999512 3.74558 0.999512 6.50708C0.999512 9.26858 3.23811 11.5071 5.99951 11.5071C8.76091 11.5071 10.9995 9.26858 10.9995 6.50708C10.9995 3.74558 8.76091 1.50708 5.99951 1.50708ZM5.99951 4.00708C6.27566 4.00708 6.49951 4.23108 6.49951 4.50708C6.49951 4.78308 6.27566 5.00708 5.99951 5.00708C5.72336 5.00708 5.49951 4.78308 5.49951 4.50708C5.49951 4.23108 5.72336 4.00708 5.99951 4.00708ZM5.99951 5.50708C6.27566 5.50708 6.49951 5.73108 6.49951 6.00708V8.50708C6.49951 8.78308 6.27566 9.00708 5.99951 9.00708C5.72336 9.00708 5.49951 8.78308 5.49951 8.50708V6.00708C5.49951 5.73108 5.72336 5.50708 5.99951 5.50708Z"})}));function lt(){let e=orderlyHooks.useEventEmitter(),[t,r]=Ai.useState([0,0]),o=orderlyHooks.useDebouncedCallback(i=>{let n=i.asks?.[i.asks.length-1]?.[0],s=i.bids?.[0]?.[0];r([n,s]);},200);return Ai.useEffect(()=>(e.on("orderbook:update",o),()=>{e.off("orderbook:update",o),o.cancel();}),[o]),t}function dr(e){let{order:t,symbolInfo:r}=e,o=t.orders,i=lt(),n=Ai.useMemo(()=>o.reduce((l,c)=>l.add(new orderlyUtils.Decimal(c.order_price).mul(c.order_quantity)),orderlyUtils.zero).toNumber(),[o]),s=Ai.useMemo(()=>o.reduce((l,c)=>l.add(new orderlyUtils.Decimal(c.order_quantity)),orderlyUtils.zero).toString(),[o,r.base_dp]);return {dataSource:o,national:n,askAndBid:i,totalQuantity:s}}var Bo=e=>{let t=dr(e);return jsxRuntime.jsx(ur,{...e,...t})},ut="scaledOrderConfirm";orderlyUi.registerSimpleDialog(ut,Bo,{size:"md",title:()=>orderlyI18n.i18n.t("orderEntry.confirmScaledOrder"),contentProps:{}});var Mo=({result:e,hasOrderQty:t,className:r})=>{if(!e||!e.isConstrained||!t)return null;let{selectedLeverage:o,effectiveLeverage:i,constraintMessage:n}=e,s=a=>Math.floor(new orderlyUtils.Decimal(a).toNumber());return jsxRuntime.jsx(orderlyUi.Tooltip,{title:n||"Effective leverage is constrained by position size",side:"top",children:jsxRuntime.jsxs(orderlyUi.Flex,{className:orderlyUi.cn("oui-rounded oui-border oui-border-orange-500/50 oui-bg-orange-500/10","oui-px-3 oui-py-2","oui-gap-x-2",r),itemAlign:"center",children:[jsxRuntime.jsx("span",{className:"oui-text-orange-400 oui-text-sm",children:"\u26A0\uFE0F"}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsxs(orderlyUi.Text,{size:"xs",intensity:80,children:["Selected:"," ",jsxRuntime.jsxs("span",{className:"oui-font-semibold oui-line-through",children:[s(o),"x"]})," \u2192 ","Effective:"," ",jsxRuntime.jsxs("span",{className:"oui-font-semibold oui-text-orange-400",children:[s(i),"x"]})]})})]})})};var Do=e=>{let{t}=orderlyI18n.useTranslation(),r=Ai.useMemo(()=>[{label:t("orderEntry.orderType.limitOrder"),value:orderlyTypes.OrderType.LIMIT},{label:t("orderEntry.orderType.marketOrder"),value:orderlyTypes.OrderType.MARKET},{label:t("orderEntry.orderType.stopLimit"),value:orderlyTypes.OrderType.STOP_LIMIT},{label:t("orderEntry.orderType.stopMarket"),value:orderlyTypes.OrderType.STOP_MARKET},{label:t("orderEntry.orderType.scaledOrder"),value:orderlyTypes.OrderType.SCALED},{label:t("orderEntry.orderType.trailingStop"),value:orderlyTypes.OrderType.TRAILING_STOP}],[t]),o=Ai.useMemo(()=>({[orderlyTypes.OrderType.LIMIT]:t("orderEntry.orderType.limit"),[orderlyTypes.OrderType.MARKET]:t("common.marketPrice"),[orderlyTypes.OrderType.STOP_LIMIT]:t("orderEntry.orderType.stopLimit"),[orderlyTypes.OrderType.STOP_MARKET]:t("orderEntry.orderType.stopMarket"),[orderlyTypes.OrderType.SCALED]:t("orderEntry.orderType.scaledOrder"),[orderlyTypes.OrderType.TRAILING_STOP]:t("orderEntry.orderType.trailingStop")}),[t]);return jsxRuntime.jsx(orderlyUi.Select.options,{testid:"oui-testid-orderEntry-orderType-button",currentValue:e.type,value:e.type,options:r,onValueChange:e.onChange,contentProps:{className:"oui-bg-base-8"},classNames:{trigger:"oui-bg-base-6 oui-border-line"},valueFormatter:(i,n)=>{if(!r.find(l=>l.value===i))return jsxRuntime.jsx(orderlyUi.Text,{size:"xs",children:n.placeholder});let a=o[i];return jsxRuntime.jsx(orderlyUi.Text,{size:"xs",color:e.canTrade?e.side===orderlyTypes.OrderSide.BUY?"buy":"sell":void 0,children:a})},size:"md"})};var Qo=e=>{let{symbol:t,side:r,symbolLeverage:o}=e,{isMobile:i}=orderlyUi.useScreen(),{maxLeverage:n}=orderlyHooks.useSymbolLeverage(t),s=o||n,a=()=>{let l=i?orderlyUiLeverage.SymbolLeverageSheetId:orderlyUiLeverage.SymbolLeverageDialogId;orderlyUi.modal.show(l,{symbol:t,side:r,curLeverage:s});};return jsxRuntime.jsxs(orderlyUi.Flex,{justify:"center",itemAlign:"center",gapX:1,className:orderlyUi.cn("oui-h-8","oui-rounded oui-border oui-border-line oui-bg-base-6","oui-cursor-pointer oui-select-none oui-text-xs oui-font-semibold oui-text-base-contrast-54"),onClick:a,children:[jsxRuntime.jsx(orderlyUi.Text,{children:"Cross"}),jsxRuntime.jsx(orderlyUi.Text.numeral,{dp:0,rm:orderlyUtils.Decimal.ROUND_DOWN,unit:"X",children:s})]})};function Wo(e){let{canTrade:t,side:r,order_type:o,setOrderValue:i}=e,{t:n}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-grid oui-w-full oui-flex-1 oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]","oui-grid-cols-2"),children:[jsxRuntime.jsx(orderlyUi.Button,{onClick:()=>{e.setOrderValue("side",orderlyTypes.OrderSide.BUY);},size:"md",fullWidth:true,"data-type":orderlyTypes.OrderSide.BUY,className:orderlyUi.cn(r===orderlyTypes.OrderSide.BUY&&t?"oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80":"oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"),"data-testid":"oui-testid-orderEntry-side-buy-button",children:n("common.buy")}),jsxRuntime.jsx(orderlyUi.Button,{onClick:()=>{e.setOrderValue("side",orderlyTypes.OrderSide.SELL);},"data-type":orderlyTypes.OrderSide.SELL,fullWidth:true,size:"md",className:orderlyUi.cn(r===orderlyTypes.OrderSide.SELL&&e.canTrade?"oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80":"oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"),"data-testid":"oui-testid-orderEntry-side-sell-button",children:n("common.sell")})]}),jsxRuntime.jsxs("div",{className:orderlyUi.cn("oui-grid oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]","oui-grid-cols-2"),children:[jsxRuntime.jsx("div",{className:"oui-w-full",children:jsxRuntime.jsx(Do,{type:o,side:r,canTrade:t,onChange:s=>{i("order_type",s);}})}),jsxRuntime.jsx("div",{className:"oui-w-full",children:jsxRuntime.jsx(Qo,{symbol:e.symbol,side:e.side,symbolLeverage:e.symbolLeverage})})]})]})}var fr=Ai.createContext({}),O=()=>Ai.useContext(fr);var Ho=e=>{let{errorMsgVisible:t,symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,setOrderValues:a,currentFocusInput:l,errors:c,priceInputRef:p,priceInputContainerRef:u,triggerPriceInputRef:m,activatedPriceInputRef:d}=e,C=Ai.useMemo(()=>({errorMsgVisible:t,symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,setOrderValues:a,currentFocusInput:l,errors:c,priceInputRef:p,priceInputContainerRef:u,triggerPriceInputRef:m,activatedPriceInputRef:d}),[t,r,o,i,n,s,a,l,c,p,u,m,d]);return jsxRuntime.jsx(fr.Provider,{value:C,children:e.children})};var S=Ai.forwardRef((e,t)=>{let{placeholder:r="0",inputMode:o}=e,{errorMsgVisible:i}=O();return jsxRuntime.jsx(orderlyUi.Input.tooltip,{ref:t,tooltip:i?e.error:void 0,autoComplete:"off",autoFocus:e.autoFocus,size:"lg",placeholder:e.readonly?"":r,id:e.id,name:e.name,color:e.error?"danger":void 0,prefix:jsxRuntime.jsx(ya,{id:e.id,className:e.classNames?.prefix,children:e.label}),suffix:e.suffix,value:e.readonly?"":e.value||"",onValueChange:e.onChange,onFocus:n=>{e.onFocus?.(n);},onBlur:n=>{e.onBlur?.(n);},inputMode:o,formatters:e.overrideFormatters||[...e.formatters??orderlyTypes.EMPTY_LIST,orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.currencyFormatter,orderlyUi.inputFormatter.decimalPointFormatter],classNames:{root:orderlyUi.cn("orderly-order-entry oui-relative oui-h-[54px] oui-rounded oui-border oui-border-solid oui-border-line oui-px-2 oui-py-1 group-first:oui-rounded-t-xl group-last:oui-rounded-b-xl",e.className,e.classNames?.root),input:orderlyUi.cn("oui-mb-1 oui-mt-5 oui-h-5",e?.classNames?.input),suffix:orderlyUi.cn("oui-absolute oui-right-0 oui-top-0 oui-justify-start oui-py-2 oui-text-2xs oui-text-base-contrast-36",e.classNames?.suffix)},readOnly:e.readonly})});S.displayName="CustomInput";var ya=e=>jsxRuntime.jsx("label",{htmlFor:e.id,className:orderlyUi.cn("oui-absolute oui-left-2 oui-top-[7px] oui-text-2xs oui-text-base-contrast-36",e.className),children:e.children});var Ko=e=>{let{t}=orderlyI18n.useTranslation(),r=Ai.useMemo(()=>[{label:t("orderEntry.bbo.counterparty1"),value:orderlyTypes.BBOOrderType.COUNTERPARTY1},{label:t("orderEntry.bbo.counterparty5"),value:orderlyTypes.BBOOrderType.COUNTERPARTY5},{label:t("orderEntry.bbo.queue1"),value:orderlyTypes.BBOOrderType.QUEUE1},{label:t("orderEntry.bbo.queue5"),value:orderlyTypes.BBOOrderType.QUEUE5}],[]);return jsxRuntime.jsx(orderlyUi.Select.options,{testid:"oui-testid-orderEntry-bbo-orderType-button",currentValue:e.value,value:e.value,options:r,onValueChange:e.onChange,contentProps:{className:"oui-bg-base-8 oui-w-full",style:e.contentStyle},size:"sm",classNames:{trigger:"oui-border-none oui-bg-transparent"},valueFormatter:(o,i)=>{let n=r.find(s=>s.value===o);return jsxRuntime.jsx(orderlyUi.Box,{children:jsxRuntime.jsx(orderlyUi.Text,{size:"sm",children:n?.label})})}})};var $o=e=>{let{quote:t,bbo:r,fillMiddleValue:o}=e,{t:i}=orderlyI18n.useTranslation();return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"end",className:orderlyUi.cn("oui-order-entry-limit-price-input-suffix","oui-text-2xs"),children:[t,jsxRuntime.jsxs(orderlyUi.Flex,{justify:"end",itemAlign:"center",gap:2,children:[jsxRuntime.jsx(orderlyUi.Flex,{px:3,height:20,justify:"center",itemAlign:"center",r:"base",className:orderlyUi.cn("oui-mt-[2px] oui-cursor-pointer oui-select-none oui-border",r.bboStatus==="on"?"oui-border-primary":"oui-border-line-12",r.bboStatus==="disabled"&&"oui-cursor-not-allowed"),onClick:()=>{r.bboStatus==="disabled"?orderlyUi.modal.dialog({title:i("common.tips"),size:"xs",content:jsxRuntime.jsx(orderlyUi.Text,{intensity:54,children:i("orderEntry.bbo.disabled.tips")})}):r.toggleBBO();},children:jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn(r.bboStatus==="on"&&"oui-text-primary",r.bboStatus==="off"&&"oui-text-base-contrast-54",r.bboStatus==="disabled"&&"oui-text-base-contrast-20"),children:i("orderEntry.bbo")})}),jsxRuntime.jsx(orderlyUi.Text,{className:orderlyUi.cn("oui-select-none","oui-cursor-pointer oui-text-primary"),onClick:o,children:"Mid"})]})]})};var Zo=e=>{let{bbo:t}=e,{t:r}=orderlyI18n.useTranslation(),{symbolInfo:o,onFocus:i,onBlur:n,getErrorMsg:s,setOrderValue:a,priceInputRef:l,priceInputContainerRef:c}=O(),{quote:p,quote_dp:u}=o,m=t.bboStatus==="on",d=e.order_type===orderlyTypes.OrderType.LIMIT?jsxRuntime.jsx($o,{quote:p,bbo:t,fillMiddleValue:e.fillMiddleValue}):p;return jsxRuntime.jsxs("div",{ref:c,className:"oui-group oui-relative oui-w-full",children:[jsxRuntime.jsx(S,{id:"order_price_input",name:"order_price_input",label:r("common.price"),suffix:d,value:e.order_price,onChange:C=>{a("order_price",C);},error:s("order_price"),formatters:[orderlyUi.inputFormatter.dpFormatter(u)],onFocus:i(1),onBlur:n(1),readonly:m,inputMode:"decimal",ref:l,classNames:{root:orderlyUi.cn(m&&"focus-within:oui-outline-transparent "),input:orderlyUi.cn(m&&"oui-cursor-auto")}}),t.bboStatus==="on"&&jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-absolute oui-bottom-1 oui-left-0"),children:jsxRuntime.jsx(Ko,{value:t.bboType,onChange:t.onBBOChange,contentStyle:{width:e.priceInputContainerWidth}})})]})};var He=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s}=O(),{base:a,quote:l,base_dp:c,quote_dp:p}=r;return jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,className:"oui-group oui-space-x-1",children:[jsxRuntime.jsx(S,{id:"order_quantity_input",name:"order_quantity_input",label:t("common.qty"),suffix:a,error:n("order_quantity"),value:e.order_quantity,onChange:u=>{s("order_quantity",u);},formatters:[orderlyUi.inputFormatter.dpFormatter(c)],onFocus:o(3),onBlur:i(3),inputMode:"decimal",className:"!oui-rounded-r oui-rounded-bl-xl"}),jsxRuntime.jsx(S,{id:"order_total_input",name:"order_total_input",label:`${t("common.total")}\u2248`,suffix:l,error:n("total"),value:e.total,onChange:u=>{s("total",u);},formatters:[orderlyUi.inputFormatter.dpFormatter(p)],onFocus:o(4),onBlur:i(4),inputMode:"decimal",className:"!oui-rounded-bl oui-rounded-br-xl"})]})});He.displayName="QtyAndTotalInput";var Jo=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{setOrderValue:r}=O(),o=()=>{orderlyUi.modal.dialog({title:t("common.tips"),size:"sm",content:jsxRuntime.jsx(Va,{value:e.distribution_type})});};return jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",justify:"center",p:2,r:"base",width:"100%",intensity:600,className:orderlyUi.cn("oui-t-rounded oui-text-base-contrast-36","oui-border oui-border-solid oui-border-line",e.className),children:[jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",className:"oui-cursor-pointer oui-border-b oui-border-dashed oui-border-line-12",onClick:o,children:t("orderEntry.quantityDistribution")}),jsxRuntime.jsx(qa,{value:e.distribution_type,onValueChange:i=>{r("distribution_type",i);}})]})}),Va=e=>{let{t}=orderlyI18n.useTranslation(),[r,o]=Ai.useState(orderlyTypes.DistributionType.FLAT);Ai.useEffect(()=>{o([orderlyTypes.DistributionType.FLAT,orderlyTypes.DistributionType.ASCENDING,orderlyTypes.DistributionType.DESCENDING].includes(e.value)?e.value:orderlyTypes.DistributionType.FLAT);},[e.value]);let i=Ai.useMemo(()=>[{type:orderlyTypes.DistributionType.FLAT,title:t("orderEntry.distributionType.flat"),description:t("orderEntry.distributionType.flat.description"),formula:`${t("orderEntry.skew")} = 1`,quantity:jsxRuntime.jsx(Da,{})},{type:orderlyTypes.DistributionType.ASCENDING,title:t("orderEntry.distributionType.ascending"),description:t("orderEntry.distributionType.ascending.description"),formula:`${t("orderEntry.skew")} > 1`,quantity:jsxRuntime.jsx(za,{})},{type:orderlyTypes.DistributionType.DESCENDING,title:t("orderEntry.distributionType.descending"),description:t("orderEntry.distributionType.descending.description"),formula:`0 < ${t("orderEntry.skew")} < 1`,quantity:jsxRuntime.jsx(Ua,{})}],[]),n=Ai.useMemo(()=>i.find(s=>s.type===r),[i,r]);return jsxRuntime.jsxs("div",{className:"oui-text-2xs oui-font-semibold oui-text-base-contrast-54",children:[jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gapY:1,children:[jsxRuntime.jsx(orderlyUi.Text,{intensity:80,children:t("orderEntry.quantityDistribution.description")}),jsxRuntime.jsx(orderlyUi.Text,{children:t("orderEntry.quantityDistribution.formula")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{intensity:600,p:1,r:"base",mt:3,itemAlign:"start",children:[jsxRuntime.jsx(orderlyUi.Flex,{direction:"column",itemAlign:"start",children:i.map(s=>jsxRuntime.jsx(orderlyUi.Box,{intensity:r===s.type?500:600,width:78,p:2,className:"oui-cursor-pointer oui-rounded-l",onClick:()=>{o(s.type);},children:jsxRuntime.jsx(orderlyUi.Text,{children:s.title})},s.title))}),jsxRuntime.jsxs(orderlyUi.Flex,{direction:"column",itemAlign:"start",gapY:1,p:2,intensity:500,width:"100%",className:orderlyUi.cn("oui-rounded-r",r===orderlyTypes.DistributionType.FLAT&&"oui-rounded-bl",r===orderlyTypes.DistributionType.ASCENDING&&"oui-rounded-l",r===orderlyTypes.DistributionType.DESCENDING&&"oui-rounded-tl"),children:[jsxRuntime.jsx("div",{children:n?.formula}),jsxRuntime.jsx(orderlyUi.Text,{children:n?.description}),jsxRuntime.jsx(orderlyUi.Flex,{width:"100%",justify:"center",children:n?.quantity}),jsxRuntime.jsxs(orderlyUi.Flex,{width:"100%",gapX:1,justify:"center",children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-base-1",children:t("common.price")}),jsxRuntime.jsx(Qa,{})]})]})]})]})},qa=e=>{let{value:t,onValueChange:r}=e,{t:o}=orderlyI18n.useTranslation(),i=s=>a=>{r(s);},n=Ai.useMemo(()=>({[orderlyTypes.DistributionType.FLAT]:o("orderEntry.distributionType.flat"),[orderlyTypes.DistributionType.ASCENDING]:o("orderEntry.distributionType.ascending.abbr"),[orderlyTypes.DistributionType.DESCENDING]:o("orderEntry.distributionType.descending.abbr"),[orderlyTypes.DistributionType.CUSTOM]:o("orderEntry.distributionType.custom")}),[o]);return jsxRuntime.jsx(orderlyUi.Flex,{className:orderlyUi.cn("oui-gap-x-[6px] lg:oui-gap-x-2"),wrap:"wrap",children:Object.values(orderlyTypes.DistributionType).map(s=>jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",children:[jsxRuntime.jsx(orderlyUi.Checkbox,{id:`distribution-type-${s}`,color:"white",variant:"radio",checked:t===s,onCheckedChange:i(s)}),jsxRuntime.jsx("label",{htmlFor:`distribution-type-${s}`,className:orderlyUi.cn("oui-text-2xs","oui-ml-1","oui-whitespace-nowrap oui-break-normal"),children:n[s]})]},s))})},Da=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"18",y:"18",width:"181",height:"4",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"15",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"62",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"109",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"156",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"203",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"})]}),za=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{x:"18",y:"18",width:"181",height:"4",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"15",cy:"20",r:"4.28571",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.42857"}),jsxRuntime.jsx("circle",{cx:"62",cy:"20",r:"5.14286",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.71429"}),jsxRuntime.jsx("circle",{cx:"109",cy:"20",r:"6",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"156",cy:"20",r:"6.85714",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.28571"}),jsxRuntime.jsx("circle",{cx:"203",cy:"20",r:"7.71429",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.57143"})]}),Ua=()=>jsxRuntime.jsxs("svg",{width:"218",height:"40",viewBox:"0 0 218 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"181",height:"4",transform:"matrix(-1 0 0 1 200 18)",fill:"rgb(var(--oui-color-base-2))"}),jsxRuntime.jsx("circle",{cx:"5",cy:"5",r:"4.28571",transform:"matrix(-1 0 0 1 208 15)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.42857"}),jsxRuntime.jsx("circle",{cx:"6",cy:"6",r:"5.14286",transform:"matrix(-1 0 0 1 162 14)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"1.71429"}),jsxRuntime.jsx("circle",{cx:"7",cy:"7",r:"6",transform:"matrix(-1 0 0 1 116 13)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"6.85714",transform:"matrix(-1 0 0 1 70 12)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.28571"}),jsxRuntime.jsx("circle",{cx:"9",cy:"9",r:"7.71429",transform:"matrix(-1 0 0 1 24 11)",fill:"rgb(var(--oui-color-base-2))",stroke:"rgb(var(--oui-color-base-5))",strokeWidth:"2.57143"})]}),Qa=()=>jsxRuntime.jsx("svg",{width:"176",height:"8",viewBox:"0 0 176 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M175.354 4.35355C175.549 4.15829 175.549 3.84171 175.354 3.64645L172.172 0.464466C171.976 0.269204 171.66 0.269204 171.464 0.464466C171.269 0.659728 171.269 0.976311 171.464 1.17157L174.293 4L171.464 6.82843C171.269 7.02369 171.269 7.34027 171.464 7.53553C171.66 7.7308 171.976 7.7308 172.172 7.53553L175.354 4.35355ZM0 4V4.5H175V4V3.5H0V4Z",fill:"rgb(var(--oui-color-base-1))"})});var Pr=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s}=O(),{quote:a,quote_dp:l}=r;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(S,{label:t("orderEntry.startPrice"),suffix:a,id:"order_start_price_input",value:e.start_price,error:n("start_price"),onChange:c=>{s("start_price",c);},formatters:[orderlyUi.inputFormatter.dpFormatter(l)],onFocus:o(5),onBlur:i(5),inputMode:"decimal",classNames:{root:"oui-rounded-t-xl"}}),jsxRuntime.jsx(S,{label:t("orderEntry.endPrice"),suffix:a,id:"order_end_price_input",value:e.end_price,error:n("end_price"),onChange:c=>{s("end_price",c);},formatters:[orderlyUi.inputFormatter.dpFormatter(l)],onFocus:o(6),onBlur:i(6),inputMode:"decimal"})]})});Pr.displayName="ScaledPriceInput";var ja=e=>jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",intensity:36,children:e}),ri=e=>{let{base:t,quote:r}=e,o=Ai.useMemo(()=>[{name:r},{name:t}],[t,r]);return jsxRuntime.jsx(orderlyUi.Select.tokens,{variant:"text",size:"xs",iconSize:"2xs",tokens:o,classNames:{trigger:orderlyUi.cn("oui-absolute oui-right-0 oui-top-1","oui-w-full oui-justify-end")},value:e.value,onValueChange:e.onValueChange,valueFormatter:ja,contentProps:{align:"end",alignOffset:-1,sideOffset:-4,className:"oui-border oui-border-line-6"}})};var ni=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{errors:r,symbolInfo:o,onFocus:i,onBlur:n,getErrorMsg:s,setOrderValue:a}=O(),[l,c]=orderlyHooks.useLocalStorage("orderly_order_quantity_unit","quote"),{base:p,quote:u,base_dp:m,quote_dp:d}=o,C=l==="base",h=jsxRuntime.jsx(ri,{base:p,quote:u,value:C?p:u,onValueChange:v=>{c(v===p?"base":"quote");}});return C?jsxRuntime.jsx(S,{label:t("common.qty"),suffix:h,id:"order_quantity_input",name:"order_quantity_input",className:"!oui-rounded-r",value:e.order_quantity,error:s("order_quantity",`${r?.order_quantity?.value} ${p}`),onChange:v=>{a("order_quantity",v);},formatters:[orderlyUi.inputFormatter.dpFormatter(m)],onFocus:i(3),onBlur:n(3),inputMode:"decimal"}):jsxRuntime.jsx(S,{label:t("common.qty"),suffix:h,id:"order_total_input",name:"order_total_input",className:"!oui-rounded-r",value:e.total,error:s("order_quantity",`${r?.total?.value} ${u}`),onChange:v=>{a("total",v);},formatters:[orderlyUi.inputFormatter.dpFormatter(d)],onFocus:i(4),onBlur:n(4),inputMode:"decimal"})});var ai=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{onFocus:r,onBlur:o,getErrorMsg:i,setOrderValue:n}=O();return jsxRuntime.jsx(S,{id:"order_skew_input",label:t("orderEntry.skew"),value:e.skew,error:i("skew"),onChange:s=>{n("skew",s);},onFocus:r(8),onBlur:o(8),inputMode:"decimal",overrideFormatters:[orderlyUi.inputFormatter.rangeFormatter({min:0,max:100,dp:2}),orderlyUi.inputFormatter.dpFormatter(2)],classNames:{root:"oui-rounded-b-xl"}})});var ui=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{onFocus:r,onBlur:o,getErrorMsg:i,setOrderValue:n}=O();return jsxRuntime.jsx(S,{label:t("orderEntry.totalOrders"),placeholder:"2-20",id:"order_total_orders_input",className:"!oui-rounded-l",value:e.total_orders,error:i("total_orders"),onChange:s=>{n("total_orders",s);},overrideFormatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(0)],onFocus:r(7),onBlur:o(7),inputMode:"numeric"})});var ci=e=>{let{values:t}=e,r=t.distribution_type===orderlyTypes.DistributionType.CUSTOM;return jsxRuntime.jsxs("div",{className:"oui-space-y-1",children:[jsxRuntime.jsx(Pr,{start_price:t.start_price,end_price:t.end_price}),jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,className:"oui-group oui-space-x-1",children:[jsxRuntime.jsx(ni,{order_quantity:t.order_quantity,total:t.total}),jsxRuntime.jsx(ui,{total_orders:t.total_orders})]}),jsxRuntime.jsx(Jo,{distribution_type:t.distribution_type,className:orderlyUi.cn(!r&&"oui-rounded-b-xl")}),r&&jsxRuntime.jsx(ai,{skew:t.skew})]})};var Sr=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,triggerPriceInputRef:a}=O();return jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx(S,{ref:a,id:"order_trigger_price_input",name:"order_trigger_price_input",label:t("common.trigger"),suffix:r.quote,value:e.trigger_price,onChange:l=>{s("trigger_price",l);},error:n("trigger_price"),formatters:[orderlyUi.inputFormatter.dpFormatter(r.quote_dp)],onFocus:o(2),onBlur:i(2),inputMode:"decimal"})})})});Sr.displayName="TriggerPriceInput";var Ir=Ai.memo(e=>{let{t}=orderlyI18n.useTranslation(),{symbolInfo:r,onFocus:o,onBlur:i,getErrorMsg:n,setOrderValue:s,activatedPriceInputRef:a}=O();return jsxRuntime.jsx("div",{className:"oui-group",children:jsxRuntime.jsx(S,{ref:a,id:"order_activated_price_input",name:"order_activated_price_input",label:t("common.triggerPrice"),placeholder:`0 (${t("common.optional")})`,suffix:r.quote,error:n("activated_price"),value:e.activated_price,onChange:l=>{s("activated_price",l);},formatters:[orderlyUi.inputFormatter.dpFormatter(r.quote_dp)],onFocus:o(9),onBlur:i(9),inputMode:"decimal"})})});Ir.displayName="ActivePriceInput";var _l=[1,2,3,5],Lr=Ai.memo(e=>{let{setOrderValue:t}=O();return jsxRuntime.jsx(orderlyUi.Flex,{gapX:2,className:e.className,children:_l.map(r=>{let o=r.toString(),i=e.callback_rate===o;return jsxRuntime.jsx(orderlyUi.Flex,{justify:"center",itemAlign:"center",width:46,height:18,className:orderlyUi.cn("oui-cursor-pointer oui-select-none","oui-rounded oui-border",i?"oui-border-base-contrast-36":"oui-border-line-12"),onClick:()=>{t("callback_rate",o),e.onClick?.(o);},children:jsxRuntime.jsxs(orderlyUi.Text,{size:"2xs",intensity:i?80:36,weight:"semibold",children:[r,"%"]})},r)})})});Lr.displayName="CallbackRatePercentages";var Fr=Ai.memo(e=>{let{quote:t}=e,r=Ai.useMemo(()=>[{label:t,value:orderlyTypes.TrailingCallbackType.VALUE},{label:"%",value:orderlyTypes.TrailingCallbackType.RATE}],[t]);return jsxRuntime.jsx(orderlyUi.Select.options,{variant:"text",size:"xs",options:r,classNames:{trigger:orderlyUi.cn("oui-absolute oui-right-0 oui-top-1","oui-w-[124px] oui-justify-end","oui-text-base-contrast-36")},value:e.value,onValueChange:e.onValueChange,contentProps:{align:"end",alignOffset:-1,sideOffset:-4,className:"oui-border oui-border-line-6"}})});Fr.displayName="trailingCallbackSelect";var kr=Ai.memo(e=>{let{callback_value:t,callback_rate:r}=e,{t:o}=orderlyI18n.useTranslation(),{symbolInfo:i,onFocus:n,onBlur:s,getErrorMsg:a,setOrderValue:l,setOrderValues:c}=O(),{quote:p,quote_dp:u}=i,m=Ai.useRef(),d=Ai.useRef(),[C,T]=orderlyHooks.useLocalStorage("orderly_order_trailing_callback_type",orderlyTypes.TrailingCallbackType.VALUE),h=Ai.useCallback(I=>{T(I),I===orderlyTypes.TrailingCallbackType.RATE?(m.current=t,c({callback_value:"",callback_rate:d.current})):(d.current=r,c({callback_value:m.current,callback_rate:""}));},[t,r]),v=jsxRuntime.jsx(Fr,{quote:p,value:C,onValueChange:h});return C===orderlyTypes.TrailingCallbackType.RATE?jsxRuntime.jsxs("div",{className:"oui-relative",children:[jsxRuntime.jsx(S,{id:"order_callback_rate_input",name:"order_callback_rate_input",label:o("orderEntry.trailingRate"),suffix:v,error:a("callback_rate"),value:r,onChange:I=>{l("callback_rate",I);},formatters:[orderlyUi.inputFormatter.dpFormatter(1)],onFocus:I=>{n(11)(I);},onBlur:I=>{s(11)(I);},inputMode:"decimal",classNames:{root:"oui-h-[68px]",input:"oui-mb-5",prefix:"!oui-top-1"}}),jsxRuntime.jsx(Lr,{className:"oui-absolute oui-bottom-1 oui-left-2",callback_rate:r})]}):jsxRuntime.jsx(S,{id:"order_callback_value_input",name:"order_callback_value_input",label:o("orderEntry.trailingValue"),suffix:v,error:a("callback_value"),value:t,onChange:I=>{l("callback_value",I);},formatters:[orderlyUi.inputFormatter.dpFormatter(u)],onFocus:n(10),onBlur:s(10),inputMode:"decimal",classNames:{input:"!oui-mb-[6px]",prefix:"!oui-top-1"}})});kr.displayName="TrailingCallbackInput";var xi=e=>{let{values:t}=e;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ir,{activated_price:t.activated_price}),jsxRuntime.jsx(kr,{callback_value:t.callback_value,callback_rate:t.callback_rate}),jsxRuntime.jsx(He,{order_quantity:t.order_quantity,total:t.total})]})};function Ti(e){let{values:t}=e,r=t.order_type;if(r===orderlyTypes.OrderType.SCALED)return jsxRuntime.jsx(ci,{values:t});if(r===orderlyTypes.OrderType.TRAILING_STOP)return jsxRuntime.jsx(xi,{values:t});let o=r===orderlyTypes.OrderType.STOP_LIMIT||r===orderlyTypes.OrderType.STOP_MARKET,i=r===orderlyTypes.OrderType.LIMIT||r===orderlyTypes.OrderType.STOP_LIMIT,n=o&&jsxRuntime.jsx(Sr,{trigger_price:t.trigger_price}),s=i&&jsxRuntime.jsx(Zo,{order_type:t.order_type,order_price:t.order_price,bbo:e.bbo,fillMiddleValue:e.fillMiddleValue,priceInputContainerWidth:e.priceInputContainerWidth});return jsxRuntime.jsxs("div",{className:"oui-space-y-1",children:[n,s,jsxRuntime.jsx(He,{order_quantity:t.order_quantity,total:t.total})]})}var Oi=e=>{let{canTrade:t,order_quantity:r,maxQty:o}=e,{t:i}=orderlyI18n.useTranslation(),n=Ai.useMemo(()=>t?e.side===orderlyTypes.OrderSide.BUY?"buy":"sell":void 0,[e.side,t]),s=Ai.useMemo(()=>e.side===orderlyTypes.OrderSide.BUY?i("orderEntry.maxBuy"):i("orderEntry.maxSell"),[e.side,i]),a=Ai.useMemo(()=>r?Number(r):0,[r]),l=Ai.useMemo(()=>r?Number(r)>=Number(o)?1:orderlyUi.convertValueToPercentage(Number(r??0),0,o)/100:0,[r,o]);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(orderlyUi.Slider.single,{disabled:o===0||!t,value:a,color:n,markCount:4,showTip:true,max:o,step:e.tick,onValueChange:e.onValueChange}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",className:"oui-pt-1 xl:oui-pt-2",children:[jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"percentages",size:"2xs",color:n,dp:2,padding:false,children:t?l:0}),jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx("button",{className:orderlyUi.textVariants({size:"2xs",className:"oui-mr-1"}),onClick:()=>e.setMaxQty(),"data-testid":"oui-testid-orderEntry-maxQty-value-button",children:s}),jsxRuntime.jsx(orderlyUi.Text.numeral,{size:"2xs",color:n,dp:e.dp,padding:false,"data-testid":"oui-testid-orderEntry-maxQty-value",children:t?o:0})]})]})]})};var Ar=Ai.createContext({}),Ct=()=>Ai.useContext(Ar);var hi=e=>{let{type:t,values:r,quote_dp:o}=e,{t:i}=orderlyI18n.useTranslation(),[n,s]=Ai.useState(true),{mode:a,setMode:l,tipsEle:c}=Ct(),[p,u]=Ai.useState(false),[m,d]=Ai.useState(false),C=Ai.useMemo(()=>{switch(a){case "Offset":return `${t.toLowerCase()}_offset`;case "Offset%":return `${t.toLowerCase()}_offset_percentage`;default:return `${t.toLowerCase()}_pnl`}},[a]),[T,h]=Ai.useState(r[a]);Ai.useEffect(()=>{m||h(r[a]);},[r,a,m]);let v=Ai.useMemo(()=>[{label:i("tpsl.pnl"),value:"PnL",testId:"PnL_menu_item"},{label:i("tpsl.offset"),value:"Offset",testId:"Offset_mneu_item"},{label:`${i("tpsl.offset")}%`,value:"Offset%",testId:"Offset%_menu_item"}],[i]),I=Ai.useMemo(()=>({PnL:i("tpsl.pnl"),Offset:i("tpsl.offset"),"Offset%":`${i("tpsl.offset")}%`}),[i]),R=Ai.useRef("");return {mode:a,modes:v,modeLabelMap:I,formatter:M=>{let{dp:V=2}=M;return {onRenderBefore:(f,Y)=>(f=`${f}`,n&&t==="SL"&&a==="PnL"&&(f=f.startsWith("-")?f:"-"+f),f===""||f==="-"?"":a==="Offset%"?`${new orderlyUtils.Decimal(f.replace(new RegExp(R.current.replace(".","\\.")+"$"),"")).mul(100).todp(2,4).toString()}${R.current}`:(a==="Offset"&&(f=orderlyUtils.todpIfNeed(f,V)),`${f}`)),onSendBefore:f=>{if(/^\-?0{2,}$/.test(f))return "0";if(a==="Offset%"){if(f!==""){f=orderlyUtils.todpIfNeed(f,2);let Y=f.match(/\.0{0,2}$/);Y?R.current=Y[0]:R.current="",f=new orderlyUtils.Decimal(f).div(100).toString(),f=`${f}${R.current}`;}}else a==="PnL"&&t==="SL"&&n?f=f.startsWith("-")?f:"-"+f:f=orderlyUtils.todpIfNeed(f,V);return f===""||f==="-"?"":f}}},onModeChange:M=>{l(M);},onFocus:()=>{u(true),d(true);},onBlur:()=>{u(false),d(false),e.onChange(C,T);},value:T,onValueChange:M=>{h(M),e.onChange(C,M);},quote_dp:o,tips:p?c:void 0,setFocus:s}};var Ii=e=>{let{mode:t,modes:r,modeLabelMap:o,onModeChange:i,onValueChange:n,quote:s,quote_dp:a,value:l,type:c,tips:p,onFocus:u,onBlur:m,setFocus:d}=e,[C,T]=Ai.useState(t),[h,v]=Ai.useState(t==="Offset%"?"%":s);Ai.useEffect(()=>{T(t),v(t==="Offset%"?"%":s);},[t]),Ai.useEffect(()=>{T(l?"":t);},[l]);let I=Ai.useMemo(()=>`${c.toLowerCase()}_${t.toLowerCase()}`,[]);return jsxRuntime.jsx(orderlyUi.Input.tooltip,{prefix:o[C]||C,size:"md",placeholder:h,id:I,align:"right",value:l,tooltip:p,tooltipProps:{content:{side:e.type==="TP"?"top":"bottom"}},"data-testid":e.testIds?.input,autoComplete:"off",inputMode:"decimal",onValueChange:n,formatters:[e.formatter({dp:a,mode:t,type:c}),orderlyUi.inputFormatter.currencyFormatter],classNames:{root:c==="TP"?"oui-text-trade-profit":"oui-text-trade-loss",additional:"oui-text-base-contrast-54",input:"oui-text-inherit"},onFocus:()=>{T(""),v(""),d(true),u();},onBlur:()=>{T(l?"":t),v(t==="Offset%"?"%":s),m();},suffix:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t==="Offset%"&&!!l&&jsxRuntime.jsx(orderlyUi.Text,{size:"2xs",color:"inherit",className:"oui-ml-[2px]",children:"%"}),jsxRuntime.jsx(Xl,{mode:t,modes:r,onModeChange:R=>i(R.value),testId:e.testIds?.dropDown})]})})},Xl=e=>jsxRuntime.jsx(orderlyUi.SimpleDropdownMenu,{currentValue:e.mode,menu:e.modes,align:"end",size:"xs",className:"oui-min-w-[80px]",onCloseAutoFocus:t=>t.preventDefault(),onSelect:t=>e.onModeChange(t),children:jsxRuntime.jsx("button",{className:"oui-p-2","data-testid":e.testId,children:jsxRuntime.jsx(orderlyUi.CaretDownIcon,{size:12,color:"white"})})});var Li=e=>{let{testIds:t,quote:r,...o}=e,i=hi(o);return jsxRuntime.jsx(Ii,{...i,testIds:t,quote:r,type:e.type})};var Vr=e=>{let{type:t,values:r,children:o}=e,[i,n]=orderlyHooks.useLocalStorage("TP/SL_Mode","Offset%"),{t:s}=orderlyI18n.useTranslation(),a=Ai.useMemo(()=>!r.PnL||!r.trigger_price?null:jsxRuntime.jsxs(orderlyUi.Flex,{children:[jsxRuntime.jsx("span",{className:"oui-text-xs oui-text-base-contrast-54",children:i==="PnL"?s("orderEntry.estRoi"):s("orderEntry.estPnL")}),i==="PnL"?jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"percentages",className:orderlyUi.cn("oui-ml-1 oui-text-xs",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),children:r.ROI}):jsxRuntime.jsx(orderlyUi.Text.numeral,{rule:"price",className:orderlyUi.cn("oui-ml-1 oui-text-xs",t==="TP"?"oui-text-trade-profit":"oui-text-trade-loss"),children:r.PnL})]}),[i,r.ROI,r.PnL,r.trigger_price]),l=Ai.useMemo(()=>({mode:i,setMode:n,tipsEle:a}),[i,n,a]);return jsxRuntime.jsx(Ar.Provider,{value:l,children:o})};var Mi=e=>{let t=Ai__default.default.useRef(null),{t:r}=orderlyI18n.useTranslation();return Ai.useEffect(()=>{e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET&&e.onSwitchChanged(false);},[e.orderType]),e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET||e.isReduceOnly?null:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",justify:"between",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{id:"order_entry_tpsl",className:"oui-h-[14px]",checked:e.switchState,disabled:e.orderType!==orderlyTypes.OrderType.LIMIT&&e.orderType!==orderlyTypes.OrderType.MARKET||e.isReduceOnly,onCheckedChange:o=>{e.onSwitchChanged(o);}}),jsxRuntime.jsx("label",{htmlFor:"order_entry_tpsl",className:"oui-text-xs",children:r("common.tpsl")})]}),jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,onClick:e.showTPSLAdvanced,className:orderlyUi.cn("oui-group oui-invisible",e.switchState&&"oui-visible"),children:[jsxRuntime.jsx(orderlyUi.Text,{className:"oui-text-sm oui-cursor-pointer group-hover:oui-text-base-contrast",children:r("tpsl.advanced")}),jsxRuntime.jsx(orderlyUi.SettingFillIcon,{size:12,className:"oui-text-base-contrast-54 group-hover:oui-text-base-contrast oui-cursor-pointer",opacity:1,onClick:e.showTPSLAdvanced})]})]}),jsxRuntime.jsx("div",{className:orderlyUi.cn("oui-max-h-0 oui-overflow-hidden oui-transition-all",e.switchState&&"oui-max-h-[120px]"),onTransitionEnd:()=>{t.current?.style.setProperty("opacity",e.switchState?"1":"0");},children:jsxRuntime.jsx(Vi,{ref:t,setOrderValue:e.setOrderValue,onChange:e.onChange,values:e.values,errors:e.errors,quote_dp:e.quote_dp})})]})},Vi=Ai__default.default.forwardRef((e,t)=>{let{getErrorMsg:r}=orderlyReactApp.useOrderEntryFormErrorMsg(e.errors);return jsxRuntime.jsxs("div",{ref:t,className:"oui-space-y-1 oui-px-px oui-py-2 oui-transition-all",children:[jsxRuntime.jsx(orderlyUiTpsl.TPSLPositionTypeWidget,{value:e.values.position_type,onChange:e.onChange}),jsxRuntime.jsx(Vr,{values:e.values.tp,type:"TP",children:jsxRuntime.jsx(Ri,{type:"TP",error:r("tp_trigger_price"),onChange:e.onChange,values:e.values.tp,quote_dp:e.quote_dp,testIds:{first:"oui-testid-orderEntry-tpsl-tpPrice-input",second:"oui-testid-orderEntry-tpsl-tpPnl-input",dropDown:"oui-testid-orderEntry-tpsl-tp-dropDown-trigger-button"}})}),jsxRuntime.jsx(Vr,{values:e.values.sl,type:"SL",children:jsxRuntime.jsx(Ri,{type:"SL",error:r("sl_trigger_price"),onChange:e.onChange,values:e.values.sl,quote_dp:e.quote_dp,testIds:{first:"oui-testid-orderEntry-tpsl-slPrice-input",second:"oui-testid-orderEntry-tpsl-slPnl-input",dropDown:"oui-testid-orderEntry-tpsl-sl-dropDown-trigger-button"}})})]})});Vi.displayName="TPSLInputForm";var mu=e=>{let{t}=orderlyI18n.useTranslation(),{errorMsgVisible:r}=O(),{tipsEle:o}=Ct(),[i,n]=Ai.useState(`${e.type} Price`),[s,a]=Ai.useState("USDC"),[l,c]=Ai.useState(false),[p,u]=Ai.useState(false),[m,d]=Ai.useState(e.values.trigger_price??"");Ai.useEffect(()=>{p||d(e.values.trigger_price??"");},[e.values.trigger_price,p]);let C=Ai.useMemo(()=>e.error&&r?e.error:l?o:null,[e.error,r,l,o]),T=R=>{let J=e.type==="TP"?t("tpsl.tpPrice"):t("tpsl.slPrice");return R&&(J=e.type==="TP"?t("tpsl.tp"):t("tpsl.sl")),J},h=R=>{d(R),e.onChange(R);};Ai.useEffect(()=>{n(T(e.values.trigger_price)),p||d(e.values.trigger_price??"");},[e.type,e.values.trigger_price]);let v=()=>{n(e.type==="TP"?t("tpsl.tp"):t("tpsl.sl")),a(""),c(true),u(true);},I=()=>{n(T(e.values.trigger_price)),a("USDC"),c(false),u(false),e.onChange(m);};return jsxRuntime.jsx(orderlyUi.Input.tooltip,{"data-testid":e.testId,prefix:i,size:"md",placeholder:s,align:"right",onFocus:v,onBlur:I,tooltip:C,tooltipProps:{content:{side:e.type==="TP"?"top":"bottom"}},color:e.error?"danger":void 0,autoComplete:"off",inputMode:"decimal",value:m,classNames:{additional:"oui-text-base-contrast-54",root:"oui-pr-2 md:oui-pr-3",prefix:"oui-pr-1 md:oui-pr-2"},onValueChange:h,formatters:[orderlyUi.inputFormatter.numberFormatter,orderlyUi.inputFormatter.dpFormatter(e.quote_dp??2),orderlyUi.inputFormatter.currencyFormatter]})},Ri=e=>jsxRuntime.jsxs(orderlyUi.Grid,{cols:2,gapX:1,children:[jsxRuntime.jsx(mu,{testId:e.testIds?.first,type:e.type,error:e.error,values:e.values??"",onChange:t=>{e.onChange(e.type==="SL"?"sl_trigger_price":"tp_trigger_price",t);},quote_dp:e.quote_dp}),jsxRuntime.jsx(Li,{testIds:{input:e.testIds?.second,dropDown:e.testIds?.dropDown},onChange:e.onChange,quote:"USDC",quote_dp:2,type:e.type,values:{PnL:e.values.PnL,Offset:e.values.Offset,"Offset%":e.values["Offset%"],ROI:e.values.ROI}})]});var Wr=e=>{let{side:t,formattedOrder:r,setOrderValue:o,setOrderValues:i,symbolInfo:n,maxQty:s,freeCollateral:a,helper:l,submit:c,metaState:p,bboStatus:u,bboType:m,onBBOChange:d,toggleBBO:C,disableFeatures:T,currentLtv:h,fillMiddleValue:v,soundAlert:I,setSoundAlert:R,currentFocusInput:J}=e,{t:A}=orderlyI18n.useTranslation(),{isMobile:ye}=orderlyUi.useScreen(),[j,M]=Ai.useState(false),{errors:V,validated:f}=p,[Y,be]=Ai.useState(false),[xe,B]=orderlyHooks.useLocalStorage("orderly_order_confirm",true),[$,ee]=orderlyHooks.useLocalStorage("orderly-order-additional-pinned",true),[de,ce]=Ai.useState(false),[kt,wt]=orderlyHooks.useLocalStorage("orderly-order-hidden",false),[he,Rt]=orderlyHooks.useLocalStorage("orderly-slippage","1",{parseJSON:g=>!g||g==='""'?"1":JSON.parse(g)}),{notification:At}=orderlyHooks.useOrderlyContext(),Ze=Ai.useId(),{getErrorMsg:Bt}=orderlyReactApp.useOrderEntryFormErrorMsg(f?V:null),Mt=Ai.useMemo(()=>t===orderlyTypes.OrderSide.BUY?A("orderEntry.buyLong"):A("orderEntry.sellShort"),[t,A]);Ai.useEffect(()=>{f&&be(true);},[f]),Ai.useEffect(()=>{T?.includes("slippageSetting")||(he?o("slippage",Number(he)):o("slippage",void 0));},[he,T]),Ai.useEffect(()=>{let g=N=>{N.target.closest("#order-entry-submit-button")||be($r=>$r&&false);};return Y?document.addEventListener("click",g):document.removeEventListener("click",g),()=>{document.removeEventListener("click",g);}},[Y]);let Xe=orderlyHooks.useMemoizedFn(async()=>{let g=r.order_type===orderlyTypes.OrderType.SCALED;l.validate().then(N=>g?orderlyUi.modal.show(ut,{order:N,symbolInfo:n,size:ye?"sm":"md"}):xe?orderlyUi.modal.show(sr,{order:r,symbolInfo:n}):true,N=>(N.slippage&&orderlyUi.toast.error(A("orderEntry.slippage.error.max")),be(true),Promise.reject())).then(()=>c({resetOnSuccess:false}).then(N=>{if(!N.success&&N.message)orderlyUi.toast.error(N.message);else if(N.success&&g){let Ve=So(N);Ve&&orderlyUi.toast.success(Ve);}})).catch(N=>{N?.message&&orderlyUi.toast.error(N.message);});}),Vt=async()=>{if(r.reduce_only&&s===0)return orderlyUi.modal.confirm({title:A("orderEntry.reduceOnly.reminder"),content:A("orderEntry.reduceOnly.reminder.content"),okLabel:A("orderEntry.placeOrderNow"),onOk:async()=>(o("reduce_only",false),requestAnimationFrame(()=>{e.resetMetaState(),Xe();}),Promise.resolve(true)),onCancel:async()=>Promise.resolve(false)});Xe();},qt=()=>{l.validate().then(()=>{ce(true);},g=>{let N=new Set(["tp_trigger_price","sl_trigger_price"]);Object.keys(g).every(Ve=>N.has(Ve))&&ce(true);});},_=g=>{g.side!==r.side&&o("side",g.side),i({position_type:g.position_type,tp_order_type:g.tp_order_type,tp_pnl:g.tp_pnl,tp_offset:g.tp_offset,tp_offset_percentage:g.tp_offset_percentage,tp_ROI:g.tp_ROI,tp_trigger_price:g.tp_trigger_price,tp_order_price:g.tp_order_price,sl_order_type:g.sl_order_type,sl_trigger_price:g.sl_trigger_price,sl_order_price:g.sl_order_price,sl_pnl:g.sl_pnl,sl_offset:g.sl_offset,sl_offset_percentage:g.sl_offset_percentage,sl_ROI:g.sl_ROI}),ce(false),M(true);},F=()=>{M(false),i({tp_trigger_price:void 0,tp_order_price:void 0,tp_order_type:orderlyTypes.OrderType.MARKET,sl_trigger_price:void 0,sl_order_price:void 0,sl_order_type:orderlyTypes.OrderType.MARKET,tp_pnl:void 0,sl_pnl:void 0,position_type:orderlyTypes.PositionType.FULL});};Ai.useEffect(()=>{M(false);},[e.symbol]);let te=!!At?.orderFilled?.media,q={pinned:$,setPinned:ee,needConfirm:xe,setNeedConfirm:B,hidden:kt,setHidden:wt,onValueChange:o,orderTypeExtra:r.order_type_ext,showExtra:r.order_type===orderlyTypes.OrderType.LIMIT&&!e.tpslSwitch},Z=!$&&jsxRuntime.jsx(Zr,{...q});return jsxRuntime.jsxs(Ho,{errors:V,errorMsgVisible:Y,symbolInfo:n,onFocus:e.onFocus,onBlur:e.onBlur,getErrorMsg:Bt,setOrderValue:o,setOrderValues:i,currentFocusInput:J.current,priceInputRef:e.priceInputRef,priceInputContainerRef:e.priceInputContainerRef,triggerPriceInputRef:e.triggerPriceInputRef,activatedPriceInputRef:e.activatedPriceInputRef,children:[jsxRuntime.jsxs("div",{className:"oui-space-y-2 oui-text-base-contrast-54 xl:oui-space-y-3",ref:e.containerRef,children:[jsxRuntime.jsx(Wo,{symbol:e.symbol,canTrade:e.canTrade,side:t,order_type:r.order_type,setOrderValue:o,symbolLeverage:e.symbolLeverage}),jsxRuntime.jsx(Mo,{result:e.effectiveLeverageResult,hasOrderQty:!!r.order_quantity}),jsxRuntime.jsx(vo,{currentLtv:h,canTrade:e.canTrade,quote:n?.quote,freeCollateral:a}),jsxRuntime.jsx(Ti,{values:r,priceInputContainerWidth:e.priceInputContainerWidth,fillMiddleValue:v,bbo:{bboStatus:u,bboType:m,onBBOChange:d,toggleBBO:C}}),jsxRuntime.jsx(Oi,{canTrade:e.canTrade,maxQty:s,order_quantity:r.order_quantity,tick:n.base_tick,dp:n.base_dp,setMaxQty:e.setMaxQty,onValueChange:g=>{o("order_quantity",g);},side:e.side}),jsxRuntime.jsx(orderlyUi.ThrottledButton,{fullWidth:true,id:"order-entry-submit-button","data-type":orderlyTypes.OrderSide.BUY,className:orderlyUi.cn(t===orderlyTypes.OrderSide.BUY?"orderly-order-entry-submit-button-buy oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80":"orderly-order-entry-submit-button-sell oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80"),onClick:Vt,loading:e.isMutating,disabled:!e.canTrade,children:Mt}),jsxRuntime.jsx(yo,{canTrade:e.canTrade,quote:n.quote,estLiqPrice:e.estLiqPrice,estLeverage:e.estLeverage,currentLeverage:e.currentLeverage,slippage:he,dp:n.quote_dp,setSlippage:Rt,estSlippage:e.estSlippage,orderType:r.order_type,disableFeatures:T}),jsxRuntime.jsx(orderlyUi.Divider,{className:"oui-w-full"}),j?jsxRuntime.jsx(eo,{order:r,symbolInfo:e.symbolInfo,errors:f?V:null,onEdit:()=>{ce(true);},onDelete:()=>{F();}}):jsxRuntime.jsx(Mi,{quote_dp:e.symbolInfo.quote_dp,switchState:e.tpslSwitch,onSwitchChanged:e.setTpslSwitch,orderType:r.order_type,errors:f?V:null,isReduceOnly:r.reduce_only,setOrderValue:o,values:{position_type:r.position_type??orderlyTypes.PositionType.PARTIAL,tp:{trigger_price:r.tp_trigger_price??"",PnL:r.tp_pnl??"",Offset:r.tp_offset??"","Offset%":r.tp_offset_percentage??"",ROI:r.tp_ROI??""},sl:{trigger_price:r.sl_trigger_price??"",PnL:r.sl_pnl??"",Offset:r.sl_offset??"","Offset%":r.sl_offset_percentage??"",ROI:r.sl_ROI??""}},showTPSLAdvanced:qt,onChange:(g,N)=>{o(g,N);}}),jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",className:"!oui-mt-0 xl:!oui-mt-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{"data-testid":"oui-testid-orderEntry-reduceOnly-switch",className:"oui-h-[14px]",id:"reduceOnly",checked:r.reduce_only,onCheckedChange:g=>{o("reduce_only",g);}}),jsxRuntime.jsx("label",{htmlFor:"reduceOnly",className:"oui-text-xs",children:A("orderEntry.reduceOnly")})]}),!te&&Z]}),te&&jsxRuntime.jsxs(orderlyUi.Flex,{justify:"between",itemAlign:"center",className:"!oui-mt-0 xl:!oui-mt-3",children:[jsxRuntime.jsxs(orderlyUi.Flex,{itemAlign:"center",gapX:1,children:[jsxRuntime.jsx(orderlyUi.Switch,{className:"oui-h-[14px]",id:Ze,checked:I,onCheckedChange:g=>R(g)}),jsxRuntime.jsx("label",{htmlFor:Ze,className:"oui-text-xs",children:A("orderEntry.soundAlerts")})]}),Z]}),$&&jsxRuntime.jsxs(orderlyUi.Box,{p:2,r:"md",intensity:700,position:"relative",children:[jsxRuntime.jsx(De,{...q}),jsxRuntime.jsx(jr,{onClick:()=>{ee(false);},className:"oui-group oui-absolute oui-right-2 oui-top-2","data-testid":"oui-testid-orderEntry-pinned-button"})]})]}),jsxRuntime.jsx(orderlyUi.SimpleSheet,{open:de,onOpenChange:ce,classNames:{body:"oui-h-full oui-pb-0 oui-border-none",overlay:"!oui-bg-base-10/60",content:orderlyUi.cn("oui-rounded-[16px] oui-border-none !oui-p-0",ye?"oui-inset-y-0 oui-right-0 oui-w-[280px]":"!oui-bottom-[40px] oui-right-3 oui-top-[44px] !oui-h-auto oui-w-[360px]")},contentProps:{side:"right",closeable:false},children:jsxRuntime.jsx(orderlyUiTpsl.TPSLAdvancedWidget,{setOrderValue:o,order:r,onSubmit:_,onClose:()=>{ce(false);},symbolLeverage:e.symbolLeverage})})]})};function Qi({tpslSwitch:e,order_type:t,order_type_ext:r,side:o,setOrderValues:i}){let[n,s]=orderlyHooks.useLocalStorage("orderly_order_bbo_type",void 0),a=Ai.useRef(n),{track:l}=orderlyHooks.useTrack(),c=Ai.useMemo(()=>e||[orderlyTypes.OrderType.POST_ONLY,orderlyTypes.OrderType.IOC,orderlyTypes.OrderType.FOK].includes(r)?"disabled":n&&t===orderlyTypes.OrderType.LIMIT?"on":"off",[e,r,t,n]),p=()=>{l(orderlyTypes.TrackerEventName.clickBBOButton),n?(s(void 0),i({order_type_ext:void 0,level:void 0})):s(a.current||orderlyTypes.BBOOrderType.COUNTERPARTY1);},u=m=>{s(m),a.current=m;};return Ai.useEffect(()=>{c==="disabled"&&i({order_type_ext:Fe({order_type_ext:r})?void 0:r,level:void 0});},[c,r]),Ai.useEffect(()=>{if(c==="on"){let m=ho(n,o),d=Eo(n);i({order_type_ext:m,level:d});}},[n,c,o]),{bboStatus:c,bboType:n,setBBOType:s,onBBOChange:u,toggleBBO:p}}function Wi(){let{state:e}=orderlyHooks.useAccount(),{wrongNetwork:t,disabledConnect:r}=orderlyReactApp.useAppContext();return Ai.useMemo(()=>!t&&!r&&(e.status===orderlyTypes.AccountStatusEnum.EnableTrading||e.status===orderlyTypes.AccountStatusEnum.EnableTradingWithoutConnected),[e.status,t,r])}function Yi(e){let{base_tick:t,order_type:r,order_quantity:o,setValue:i}=e,n=Ai.useRef(0),s=Ai.useRef(6),a=()=>{if(t<1||r===orderlyTypes.OrderType.SCALED||!o)return;let p=orderlyHooks.utils.formatNumber(o,new orderlyUtils.Decimal(t||"0").toNumber());i("order_quantity",p,{shouldUpdateLastChangedField:false});},l=p=>u=>{n.current=p,[5,6].includes(n.current)&&(s.current=p);},c=p=>u=>{setTimeout(()=>{n.current===p&&(n.current=0);},300),p===3&&a();};return {currentFocusInput:n,lastScaledOrderPriceInput:s,onFocus:orderlyHooks.useMemoizedFn(l),onBlur:orderlyHooks.useMemoizedFn(c)}}function $i({order_type_ext:e}){let[t,r]=Ai.useState(0),o=Ai.useRef(null);return Ai.useEffect(()=>{let i=o.current;if(!i)return;let n=new ResizeObserver(s=>{for(let a of s){let l=a.contentRect.width;l&&r(l);}});return n.observe(i),()=>{n.unobserve(i);}},[o,e]),{priceInputContainerRef:o,priceInputContainerWidth:t}}var Ju="orderly_order_sound_alert",Yr=e=>{let{symbol:t}=e,[r,o]=orderlyHooks.useLocalStorage("orderly-order-entry-order-type",orderlyTypes.OrderType.LIMIT),[i,n]=orderlyHooks.useLocalStorage("orderly-order-entry-order-side",orderlyTypes.OrderSide.BUY),s=orderlyHooks.useLeverageBySymbol(t),{notification:a}=orderlyHooks.useOrderlyContext(),[l,c]=orderlyHooks.useLocalStorage(Ju,a?.orderFilled?.defaultOpen??false),p=Wi(),{formattedOrder:u,setValue:m,setValues:d,symbolInfo:C,...T}=orderlyHooks.useOrderEntry(t,{initialOrder:{symbol:t,order_type:r,position_type:orderlyTypes.PositionType.PARTIAL,side:i}}),[h]=orderlyHooks.usePositionStream(t),v=h?.rows?.[0],I=v?.position_qty?Number(v.position_qty):0,R=orderlyHooks.useEffectiveLeverage({symbol:t,positionQty:I,positionPrice:v?.mark_price?Number(v.mark_price):void 0,orderQty:u?.order_quantity?Number(u.order_quantity):void 0,orderPrice:u?.order_price?Number(u.order_price):void 0,selectedLeverage:s}),[J,A]=orderlyHooks.useLocalStorage("orderly-order-entry-tp_sl-switch",false),{currentLeverage:ye}=orderlyHooks.useMarginRatio(),j=orderlyHooks.useEventEmitter(),M=Ai.useRef(null),V=Ai.useRef(null),f=Ai.useRef(null),{bboStatus:Y,bboType:be,setBBOType:xe,onBBOChange:B,toggleBBO:$}=Qi({tpslSwitch:J,order_type:u.order_type,order_type_ext:u.order_type_ext,side:u.side,setOrderValues:d}),{currentFocusInput:ee,lastScaledOrderPriceInput:de,onFocus:ce,onBlur:kt}=Yi({base_tick:C?.base_tick,order_type:u.order_type,order_quantity:u.order_quantity,setValue:m}),wt=()=>{d({tp_trigger_price:"",sl_trigger_price:"",position_type:orderlyTypes.PositionType.FULL});},he=()=>{d({order_type_ext:void 0,position_type:orderlyTypes.PositionType.FULL});},Rt=()=>{m("order_quantity",T.maxQty);},At=orderlyHooks.useMemoizedFn((_,F,te)=>{if(_==="order_type"&&o(F),_==="side"&&n(F),_==="reduce_only"&&F||_==="order_type"&&(F===orderlyTypes.OrderType.STOP_LIMIT||F===orderlyTypes.OrderType.STOP_MARKET)){let q={tp_trigger_price:"",sl_trigger_price:"",[_]:F};_==="order_type"&&(q.order_type_ext=""),d(q);return}if(_==="order_type"&&F!==orderlyTypes.OrderType.LIMIT){let q={level:void 0,order_type_ext:void 0,[_]:F};d(q);return}if(_==="order_type"&&F===orderlyTypes.OrderType.SCALED){d({distribution_type:orderlyTypes.DistributionType.FLAT,[_]:F});return}m(_,F,te);}),Ze=_=>{A(_),_?he():wt();};Ai.useEffect(()=>{let _=F=>{m("order_price",F);};return j.on("update:orderPrice",_),()=>{j.off("update:orderPrice",_);}},[]),Ai.useEffect(()=>{let _=te=>{requestAnimationFrame(()=>{te?.focus();});},F=te=>{let q=orderlyUtils.removeTrailingZeros(te[0]),{order_type:Z,order_type_ext:g}=u;if(ee.current===2&&(Z===orderlyTypes.OrderType.STOP_LIMIT||Z===orderlyTypes.OrderType.STOP_MARKET)){m("trigger_price",q),_(M.current);return}if(Fe({order_type:Z,order_type_ext:g})){xe(void 0),d({order_type_ext:void 0,level:void 0}),requestAnimationFrame(()=>{j.emit("update:orderPrice",q);}),_(V.current);return}if(Z===orderlyTypes.OrderType.STOP_LIMIT||Z===orderlyTypes.OrderType.LIMIT){m("order_price",q),_(V.current);return}if(Z===orderlyTypes.OrderType.STOP_MARKET){m("trigger_price",q),_(M.current);return}if(Z===orderlyTypes.OrderType.MARKET){xe(void 0),d({order_type:orderlyTypes.OrderType.LIMIT,order_price:q}),_(V.current);return}if(Z===orderlyTypes.OrderType.SCALED&&de.current){let N=de.current===5?"start_price":"end_price";m(N,q),_(V.current);return}if(Z===orderlyTypes.OrderType.TRAILING_STOP){m("activated_price",q),_(f.current);return}m("order_price",q),_(V.current);};return j.on("orderbook:item:click",F),()=>{j.off("orderbook:item:click",F);}},[u,C]),Ai.useEffect(()=>{T.reset(),T.resetMetaState();},[t]),Ai.useEffect(()=>{u.order_type===orderlyTypes.OrderType.SCALED&&!u.distribution_type&&m("distribution_type",orderlyTypes.DistributionType.FLAT);},[u.order_type,u.distribution_type]);let Bt=orderlyHooks.useComputedLTV(),Mt=lt(),Xe=()=>{if(Y==="on"&&$(),u.order_type===orderlyTypes.OrderType.LIMIT){let[_=0,F=0]=Mt,te=new orderlyUtils.Decimal(tr(_)).add(tr(F)).div(2).toNumber();requestAnimationFrame(()=>{j.emit("update:orderPrice",te);});}},{priceInputContainerRef:Vt,priceInputContainerWidth:qt}=$i({order_type_ext:u.order_type_ext});return {...T,side:u.side,type:u.order_type,level:u.level,formattedOrder:u,setOrderValue:At,setOrderValues:d,currentLeverage:ye,tpslSwitch:J,setTpslSwitch:Ze,setMaxQty:Rt,symbolInfo:C,onFocus:ce,onBlur:kt,priceInputRef:V,priceInputContainerRef:Vt,priceInputContainerWidth:qt,triggerPriceInputRef:M,activatedPriceInputRef:f,canTrade:p,bboStatus:Y,bboType:be,onBBOChange:B,toggleBBO:$,currentLtv:Bt,fillMiddleValue:Xe,symbol:t,soundAlert:l,setSoundAlert:c,currentFocusInput:ee,symbolLeverage:s,effectiveLeverageResult:R}};var ed=e=>{let t=Yr(e);return jsxRuntime.jsx(Wr,{...t,containerRef:e.containerRef,disableFeatures:e.disableFeatures})};
22
22
 
23
23
  exports.AdditionalInfo = De;
24
- exports.FeesWidget = Wt;
24
+ exports.FeesWidget = Yt;
25
25
  exports.LTVRiskTooltipWidget = it;
26
- exports.OrderConfirmDialog = rr;
27
- exports.OrderEntry = zr;
28
- exports.OrderEntryWidget = Gu;
29
- exports.useOrderEntryScript = Gr;
26
+ exports.OrderConfirmDialog = nr;
27
+ exports.OrderEntry = Wr;
28
+ exports.OrderEntryWidget = ed;
29
+ exports.useOrderEntryScript = Yr;
30
30
  //# sourceMappingURL=out.js.map
31
31
  //# sourceMappingURL=index.js.map