"use strict";var e=require("bignumber.js"),t=require("lodash"),i=require("react"),r=require("@emotion/styled"),o=require("@emotion/react"),n=require("react-konva"),s=require("./helper-Cg-Jcf0P.cjs"),l=require("./index-DB-NT_Ie.cjs"),a=require("@dodoex/api");require("@lingui/core"),require("@lingui/react"),require("@dodoex/components"),require("@dodoex/dodo-contract-request"),require("identicon.js"),require("zustand"),require("@web3-react/core"),require("@web3-react/eip1193"),require("@web3-react/walletconnect-v2"),require("@web3-react/metamask"),require("@web3-react/types"),require("@tanstack/react-query"),require("@ethersproject/bignumber"),require("react-dom"),require("react-window"),require("dayjs"),require("react-transition-group"),require("@dodoex/contract-request"),require("axios"),require("recharts"),require("jsbi"),require("tiny-invariant"),require("@uniswap/sdk-core"),require("@uniswap/v2-sdk"),require("react-infinite-scroller"),require("d3"),require("rmc-date-picker");var u={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},c=i.createContext&&i.createContext(u),d=["attr","size","title"];function p(e,t){if(null==e)return{};var i,r,o=function(e,t){if(null==e)return{};var i,r,o={},n=Object.keys(e);for(r=0;r<n.length;r++)i=n[r],t.indexOf(i)>=0||(o[i]=e[i]);return o}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)i=n[r],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i])}return o}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},m.apply(this,arguments)}function g(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function x(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?g(Object(i),!0).forEach((function(t){h(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):g(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function h(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function f(e){return e&&e.map(((e,t)=>i.createElement(e.tag,x({key:t},e.attr),f(e.child))))}function b(e){return t=>i.createElement(M,m({attr:x({},e.attr)},t),f(e.child))}function M(e){var t=t=>{var r,{attr:o,size:n,title:s}=e,l=p(e,d),a=n||t.size||"1em";return t.className&&(r=t.className),e.className&&(r=(r?r+" ":"")+e.className),i.createElement("svg",m({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,o,l,{className:r,style:x(x({color:e.color||t.color},t.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&i.createElement("title",null,s),e.children)};return void 0!==c?i.createElement(c.Consumer,null,(e=>t(e))):t(u)}function v(e){return b({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13.293 6.293 7.586 12l5.707 5.707 1.414-1.414L10.414 12l4.293-4.293z"},child:[]}]})(e)}function j(e){return b({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10.707 17.707 16.414 12l-5.707-5.707-1.414 1.414L13.586 12l-4.293 4.293z"},child:[]}]})(e)}function y(e){return b({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5 11h14v2H5z"},child:[]}]})(e)}function P(e){return b({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z"},child:[]}]})(e)}const L=r.input`
  margin: 4px 10px 4px 6px;
  border-radius: 10px;
  border: 1px solid #373739;
  padding: 4px 9px;
  background-color: #1a1a1b;
  color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  outline: none;
  width: 96px;
  &:focus {
    border-color: #fff;

    ${({error:e})=>e&&o.css`
        border-color: red;
      `}
  }
`;const w="rgba(38, 39, 41, 0.3)";function E({width:r,height:o,midPrice:a,pmmModel:u,params:c,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,colorMap:g,setBaseMinAndZoomMultiples:x}){const h=t.merge({grid:"#2A2A2D",midPriceLine:"#313335",leftBg:[0,w,1,"#31645d"],leftLine:"#55f6db",leftColor:"",rightBg:[0,w,1,"#67303d"],rightLine:"#ff4f73",rightColor:"",tooltipBg:"#121212",tooltipColor:void 0},g),f=r,b=o-18,M=f/7,{buyBaseVert:v,sellBaseVert:j}=s.computeBaseVert({midPrice:a,q:c.q,q0:c.q0,pmmModel:u}),y=v.div(b),P=j.div(b),L=i.useRef(null),E=i.useRef(null),{current:z}=L,B=i.useRef(0),q=i.useRef(),{horizontalGridLines:k,verticalGridLines:T}=function({chartHeight:e,chartWidth:t,horizontalLineCount:r,verticalLineCount:o}){return i.useMemo((()=>{const i=[],n=e/(r+1),s=[],l=t/o;for(let e=0;e<r;e++){const r=n*(e+1);i.push([0,r,t,r])}for(let t=0;t<o;t++){const i=l*t+l/2;s.push([i,0,i,e])}return{horizontalGridLines:i,verticalGridLines:s}}),[e,t,r,o])}({chartHeight:b,chartWidth:f,horizontalLineCount:9,verticalLineCount:7}),{horizontalLabelTickPoints:R,horizontalLabelTextPoints:C}=function({chartHeight:e,chartWidth:t,xAxisPoints:r,oneXPx:o,baseMinAndZoomMultiples:n}){return i.useMemo((()=>{const i=s.computeXPortion(t,n.zoomMultiples),a=[],u=[];for(let t=0;t<r;t++){a.push([t*o+o/2,e,t*o+o/2,e+4]);const r=i.multipliedBy(t).multipliedBy(o).plus(i.multipliedBy(o/2)).toNumber(),s=n.baseMin.multipliedBy(10**r),c=t*o,d=e+2+4,p=l.formatShortNumber(s);u.push({x:c,y:d,text:p})}return{horizontalLabelTickPoints:a,horizontalLabelTextPoints:u}}),[n.baseMin,n.zoomMultiples,e,t,o,r])}({chartHeight:b,chartWidth:f,xAxisPoints:7,oneXPx:M,baseMinAndZoomMultiples:m}),{quoteLinePoints:S,quoteLineAreaPoints:N,quoteLineAreaLinearGradientEndPointY:O,baseLinePoints:A,baseLineAreaPoints:X,baseLineAreaLinearGradientEndPointY:Z,midPriceLinePoints:W}=function({chartHeight:t,chartWidth:r,midPrice:o,xPoints:n,pmmModel:l,baseMinAndZoomMultiples:a,buyYPortion:u,sellYPortion:c}){return i.useMemo((()=>{const i=[],d=[],p=[],{baseMin:m,zoomMultiples:g}=a,x=s.computeXPortion(r,g),h=2*g,f=new e(h).div(n);let b=new e(Math.log(o.div(m).toNumber())/Math.log(10));b=e.minimum(h,b),b=e.maximum(0,b);for(let r=new e(0);r.lte(b);){const e=m.multipliedBy(10**r.toNumber()),n=s.evalPoint({val:e,model:l,midPrice:o});if(!n.vert.isNaN()){const e=r.div(x).toNumber(),o=t-n.vert.div(u).toNumber();i.push(e,o)}r=r.plus(f)}for(let e=b;e.lte(h);){const i=m.multipliedBy(10**e.toNumber()),r=s.evalPoint({val:i,model:l,midPrice:o});if(!r.vert.isNaN()){const i=e.div(x).toNumber(),o=t-r.vert.div(c).toNumber();d.push(i,o)}e=e.plus(f)}const M=b.div(x).toNumber(),[,v]=i,j=l.k.eq(0);j&&i.push(M,v||t),i.push(M,t),p.push(M,t,M,0);const y=s.evalPoint({val:m.multipliedBy(10**h),model:l,midPrice:o});let P=t;const L=new e(h).div(x).toNumber();return y.vert.isNaN()||(P=t-y.vert.div(c).toNumber()),j&&d.length>=2&&(d.unshift(M,P),d.unshift(M,t)),d.push(L,P),b.lte(0)&&d.unshift(0,t),{quoteLinePoints:i,quoteLineAreaPoints:[0,t,0,v,...i],quoteLineAreaLinearGradientEndPointY:v,baseLinePoints:d,baseLineAreaPoints:[...d,L,t],baseLineAreaLinearGradientEndPointY:P,midPriceLinePoints:p}}),[a,r,n,o,l,t,u,c])}({chartHeight:b,chartWidth:f,midPrice:a,xPoints:50,pmmModel:u,baseMinAndZoomMultiples:m,buyYPortion:y,sellYPortion:P}),F=e=>{var t;const i=e.target;if(i&&z){const e=null===(t=i.getStage())||void 0===t?void 0:t.getPointerPosition();if(e){const{x:t}=e;if(t>f)return void z.hide();s.updateTooltip({x:t,tooltip:z,buyBaseVert:v,sellBaseVert:j,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,isHover:!0,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine})}}},H=i.useMemo((()=>t.throttle((e=>{const{target:t}=e,i=t.getStage();if(i){i.container().style.cursor="grabbing";const e=null==i?void 0:i.getPointerPosition();if(e){const t=e.x-B.current;B.current=e.x,q.current=e.x,x((e=>void 0===e.baseMin?e:{baseMin:s.computeBaseMinByDistance({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:f,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:0}))}}}),100)),[f,x]),D=i.useMemo((()=>t.throttle((e=>{e.cancelBubble=!0,e.evt.preventDefault();const t=e.evt.deltaY<0;x((e=>{const i=s.computeZoomMultiplesWhenZoom({zoomIn:t,prevZoomMultiples:e.zoomMultiples});return{baseMin:s.computeBaseAfterZoom({midPrice:a,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:e.targetMarginPriceX}}))}),100)),[a,x]);return i.useEffect((()=>{m.targetMarginPriceX>0&&null!==z?s.updateTooltip({x:m.targetMarginPriceX,tooltip:z,buyBaseVert:v,sellBaseVert:j,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine}):void 0!==q.current&&null!==z&&s.updateTooltip({x:q.current,tooltip:z,buyBaseVert:v,sellBaseVert:j,chartWidth:f,chartHeight:b,midPrice:a,pmmModel:u,baseTokenSymbol:d,quoteTokenSymbol:p,baseMinAndZoomMultiples:m,t:s.chartT,isHover:!0,color:h.tooltipColor,leftColor:h.leftLine,rightColor:h.rightLine})}),[m,d,v,b,f,h.leftLine,h.rightLine,h.tooltipColor,a,u,p,j,z]),l.jsxRuntimeExports.jsxs(n.Stage,{ref:E,width:r,offsetY:-s.chartOffsetYBCToolTip,height:o+s.chartOffsetYBCToolTip,draggable:!0,dragBoundFunc:function(){return{x:this.absolutePosition().x,y:this.absolutePosition().y}},onMouseMove:F,onMouseOver:F,onMouseOut:()=>{z&&z.hide()},onDragStart:function(e){const{target:t}=e,i=t.getStage();if(i){const e=i.getPointerPosition();e&&(B.current=e.x)}},onDragMove:H,onDragEnd:e=>{const{target:t}=e,i=t.getStage();i&&(i.container().style.cursor="pointer")},onWheel:D,children:[l.jsxRuntimeExports.jsxs(n.Layer,{children:[l.jsxRuntimeExports.jsx(n.Rect,{x:0,y:0,width:r,height:b,stroke:h.grid,strokeWidth:1}),k.map(((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:h.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),T.map(((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:h.grid,strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),R.map(((e,t)=>l.jsxRuntimeExports.jsx(n.Line,{points:e,stroke:"#9d9d9d",strokeWidth:1,lineCap:"round",lineJoin:"round",listening:!1},t))),C.map(((e,t)=>l.jsxRuntimeExports.jsx(n.Text,{x:e.x,y:e.y,text:e.text,fontFamily:"Manrope",fontSize:12,fill:"#9d9d9d",width:M,padding:0,align:"center",verticalAlign:"bottom",listening:!1},t))),l.jsxRuntimeExports.jsx(n.Line,{points:N,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:0,y:b},fillLinearGradientEndPoint:{x:0,y:O},fillLinearGradientColorStops:h.leftBg}),l.jsxRuntimeExports.jsx(n.Line,{points:S,stroke:h.leftLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),l.jsxRuntimeExports.jsx(n.Line,{points:X,closed:!0,listening:!1,lineCap:"round",lineJoin:"round",fillLinearGradientStartPoint:{x:f,y:b},fillLinearGradientEndPoint:{x:f,y:Z},fillLinearGradientColorStops:h.rightBg}),l.jsxRuntimeExports.jsx(n.Line,{points:A,stroke:h.rightLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1}),l.jsxRuntimeExports.jsx(n.Line,{points:W,stroke:h.midPriceLine,strokeWidth:2,lineCap:"round",lineJoin:"round",listening:!1})]}),l.jsxRuntimeExports.jsxs(n.Layer,{ref:L,visible:!1,listening:!1,children:[l.jsxRuntimeExports.jsx(n.Line,{points:[],stroke:"#ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipVertLine"}),l.jsxRuntimeExports.jsx(n.Line,{points:[],stroke:"ff4f73",strokeWidth:1,lineCap:"round",lineJoin:"round",dash:[4,6],id:"toolTipHoriLine"}),l.jsxRuntimeExports.jsx(n.Circle,{x:0,y:0,radius:5,fill:"#FF5072",stroke:"rgba(255, 80, 114, 0.3)",strokeWidth:12,id:"joinCircle"}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"priceTextLabel",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,id:"priceTextLabel-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"priceTextLabel-text"})]}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"slippageTextLabel",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,id:"slippageTextLabel-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"",fontSize:12,fontFamily:"Manrope",padding:4,fill:"#FF5072",id:"slippageTextLabel-text"})]}),l.jsxRuntimeExports.jsxs(n.Label,{x:0,y:0,id:"toolTip",children:[l.jsxRuntimeExports.jsx(n.Tag,{fill:h.tooltipBg,pointerDirection:"down",pointerWidth:15,pointerHeight:8,cornerRadius:8,lineJoin:"round",id:"toolTip-tag"}),l.jsxRuntimeExports.jsx(n.Text,{text:"-",fontSize:12,lineHeight:17/12,padding:s.labelPadding,fontFamily:"Manrope",fill:"#FFFFFF",id:"toolTip-text"})]})]})]})}const z=r.button`
  margin: 0;
  border: none;
  padding: 0;
  background: none;

  &:focus {
    outline: none;
  }
  &:active {
    outline: none;
  }
`,B=r.div`
  height: 100%;
`,q=r.div`
  display: flex;
  align-items: center;
`,k=r.div`
  border: 1px solid ${({borderColor:e})=>e||"#2a2a2d"};
  flex: 1 0 50%;

  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 400;
  line-height: 17px;
  color: #606066;

  & + & {
    border-left: none;
  }
`,T=r.span`
  color: #85858d;
`,R=r.div`
  margin-top: 20px;
  display: flex;
  justify-content: center;
  margin-bottom: 9px;
`,C=r(z)`
  border-radius: 13px;
  background-color: #373739;
  width: 24px;
  height: 24px;
  font-size: 18px;
  color: #85858d;
  line-height: 0;
  & + & {
    margin-left: 10px;
  }
  &:first-child,
  &:last-child {
    font-size: 20px;
  }

  &:hover {
    color: #fff;
  }
`;function S({params:t,target:i,isBuy:r=!0}){const o=new e(t.b),n=new e(t.q);let s=new e(t.b0);const l=new e(t.q0),u=new e(t.i),c=new e(t.k),{R:d}=t;1===d&&s.eq(o)&&(s=a.solveQuadraticFunctionForTarget(o,n.minus(l),new e(1).div(u),c));const p=r?o.plus(i):o.minus(i);if(p.lt(s)||o.eq(s)){let t=s.multipliedBy(s).div(p).div(p);return t=new e(1).minus(c).plus(c.multipliedBy(t)),u.multipliedBy(t)}const m=new a.PMMModel;m.RStatus=d,m.B=o,m.B0=s,m.Q=n,m.Q0=l,m.i=u,m.k=c,m.mtFeeRate=new e(0),m.lpFeeRate=new e(0);let g=new e(0);g=r?m.querySellBase(i):m.queryBuyBase(i);const x=r?n.minus(g):n.plus(g);let h=l.multipliedBy(l).div(x).div(x);return h=new e(1).minus(c).plus(c.multipliedBy(h)),u.div(h)}exports.default=({chartId:r,width:o=834,height:n=460,baseTokenSymbol:a,quoteTokenSymbol:u,pmmModel:c,pmmParams:d,midPrice:p=new e(0),colorMap:m,notShowAmountInput:g})=>{(({id:e})=>{i.useEffect((()=>{function t(e){e.preventDefault()}let i=!1;try{const e={get passive(){return i=!0,!1}};window.addEventListener("test",(()=>{}),e),window.removeEventListener("test",(()=>{}))}catch(e){i=!1}const r=document.getElementById(e),o=!!i&&{passive:!1};return null==r||r.addEventListener("wheel",t,o),()=>{null==r||r.removeEventListener("wheel",t)}}),[e])})({id:r});const[x,h]=i.useState(""),[f,b]=i.useState(""),[M,w]=i.useState("-"),[z,N]=i.useState("-"),[O,A]=i.useState({baseMin:new e(0),zoomMultiples:s.baseZoomMultiples,targetMarginPriceX:0});i.useEffect((()=>{void 0!==p&&A((e=>({baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX})))}),[p]);const X=i.useMemo((()=>t.debounce((({type:t,amount:i})=>{""===i&&p&&(A({baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:s.baseZoomMultiples}),zoomMultiples:s.baseZoomMultiples,targetMarginPriceX:0}),"buy"===t?w("-"):N("-"));const r=new e(i);if(!r.lte(0)&&!r.isNaN()&&(null==d?void 0:d.b)&&!r.gte(d.b)&&p)if("buy"===t){const e=S({params:d,target:r});A((i=>{const r=s.beforePriceImpactEffect({currentBaseMinAndZoomMultiples:i,targetPrice:e,midPrice:p,width:o});if(r.isSkip)return{baseMin:i.baseMin,zoomMultiples:i.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=s.computeTargetXByTargetPrice({midPrice:p,width:o,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),w(`${l.formatPercentageNumber({input:e.minus(p).div(p)})}`)}else{const e=function({params:e,target:t}){return S({params:e,target:t,isBuy:!1})}({params:d,target:r});A((i=>{const r=s.beforePriceImpactEffect({currentBaseMinAndZoomMultiples:i,targetPrice:e,midPrice:p,width:o});if(r.isSkip)return{baseMin:i.baseMin,zoomMultiples:i.zoomMultiples,targetMarginPriceX:r.targetX};if(r.targetX>0)return{baseMin:r.baseMin,zoomMultiples:r.zoomMultiples,targetMarginPriceX:r.targetX};const n=s.computeTargetXByTargetPrice({midPrice:p,width:o,type:t,targetPrice:e}),l=n.zoomMultiples.dp(6).toNumber();return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:l}),zoomMultiples:l,targetMarginPriceX:n.targetX}})),N(`+${l.formatPercentageNumber({input:e.minus(p).div(p)})}`)}}),300)),[d,p,o]);i.useEffect((()=>{void 0!==x&&X({type:"buy",amount:x})}),[X,x]),i.useEffect((()=>{void 0!==f&&X({type:"sell",amount:f})}),[X,f]);const Z=e=>{let t=0;t=e?-.1*o:.1*o,A((e=>void 0===e.baseMin?e:{baseMin:s.computeBaseMinByDistance({dragDistance:t,prevBaseMin:e.baseMin,chartWidth:o,zoomMultiples:e.zoomMultiples}),zoomMultiples:e.zoomMultiples,targetMarginPriceX:e.targetMarginPriceX}))},W=e=>{A((t=>{const i=s.computeZoomMultiplesWhenZoom({zoomIn:null!=e&&e,prevZoomMultiples:t.zoomMultiples});return{baseMin:s.computeBaseAfterZoom({midPrice:p,zoomMultiples:i}),zoomMultiples:i,targetMarginPriceX:t.targetMarginPriceX}}))},F=i.useMemo((()=>{if(""===x)return!1;const t=new e(x);return!(!t.lte(0)&&!t.isNaN()&&(null==d?void 0:d.b)&&!t.gte(d.b))}),[x,d]),H=i.useMemo((()=>{if(""===f)return!1;const t=new e(f);return!(!t.lte(0)&&!t.isNaN()&&(null==d?void 0:d.b)&&!t.gte(d.b))}),[f,d]);return l.jsxRuntimeExports.jsxs(B,{id:r,children:[g?"":l.jsxRuntimeExports.jsxs(q,{children:[l.jsxRuntimeExports.jsxs(k,{borderColor:m&&m.grid,children:[s.chartT("pool.chart.buy-amount",{symbol:a}),l.jsxRuntimeExports.jsx(L,{value:x,error:F,onChange:e=>{const t=l.fixedInputStringToFormattedNumber(e.target.value,2);null!==t&&h(t)}}),l.jsxRuntimeExports.jsx(T,{children:s.chartT("pool.chart.price-impact",{amount:M})})]}),l.jsxRuntimeExports.jsxs(k,{borderColor:m&&m.grid,children:[s.chartT("pool.chart.sell-amount",{symbol:a}),l.jsxRuntimeExports.jsx(L,{value:f,error:H,onChange:e=>{const t=l.fixedInputStringToFormattedNumber(e.target.value,2);null!==t&&b(t)}}),l.jsxRuntimeExports.jsx(T,{children:s.chartT("pool.chart.price-impact",{amount:z})})]})]}),void 0!==d&&void 0!==p&&void 0!==c&&void 0!==O.baseMin&&void 0!==p&&l.jsxRuntimeExports.jsx(E,{width:o,height:n,params:d,midPrice:p,pmmModel:c,baseTokenSymbol:a,quoteTokenSymbol:u,baseMinAndZoomMultiples:O,colorMap:m,setBaseMinAndZoomMultiples:A}),l.jsxRuntimeExports.jsxs(R,{className:"operate-btn-wrapper",children:[l.jsxRuntimeExports.jsx(C,{onClick:()=>Z(!0),children:l.jsxRuntimeExports.jsx(v,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>W(!1),children:l.jsxRuntimeExports.jsx(y,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>W(!0),children:l.jsxRuntimeExports.jsx(P,{})}),l.jsxRuntimeExports.jsx(C,{onClick:()=>Z(!1),children:l.jsxRuntimeExports.jsx(j,{})})]})]})};
