@dodoex/widgets 3.0.2-zetachain.114 → 3.0.2-zetachain.115
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/{helper-tgDSGHwl.js → helper-Bj_ByzR1.js} +1 -1
- package/dist/{helper-Cm_cnIZD.cjs → helper-D694wcPy.cjs} +1 -1
- package/dist/{index-1TGmLYn3.cjs → index-CtA83niL.cjs} +1 -1
- package/dist/{index-btriIW8k.js → index-D-8F683S.js} +1 -1
- package/dist/{index-C1M4iixl.js → index-D3K8vv-j.js} +1 -1
- package/dist/{index-DWGDLKiS.cjs → index-DGIFC0bG.cjs} +1 -1
- package/dist/{index-BaJ7Cs6-.cjs → index-mNarS5h3.cjs} +1 -1
- package/dist/{index-Ced-Vxeu.js → index-y-icueWq.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/widgets/PoolWidget/PoolList/components/FilterGroup.d.ts +2 -0
- package/dist/types/widgets/PoolWidget/PoolList/components/SortButtonGroup.d.ts +11 -0
- package/dist/types/widgets/PoolWidget/PoolList/components/TableSortButton.d.ts +1 -1
- package/package.json +2 -2
|
@@ -31,4 +31,4 @@ var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected
|
|
|
31
31
|
object-assign
|
|
32
32
|
(c) Sindre Sorhus
|
|
33
33
|
@license MIT
|
|
34
|
-
*/function cx(){if(Kg)return Yg;Kg=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Yg=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,o){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in r=Object(arguments[l]))t.call(r,d)&&(s[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(s[a[c]]=r[a[c]])}}return s},Yg}function ux(){if(Jg)return Xg;Jg=1;return Xg="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function px(){return tx?ex:(tx=1,ex=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var hx=dx();$g.exports=function(){if(rx)return ox;rx=1;var e=dx(),t=cx(),n=ux(),i=px(),o=function(){if(ix)return nx;ix=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=ux(),n={},i=px();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,r,a,s,l){if("production"!==process.env.NODE_ENV)for(var d in o)if(i(o,d)){var c;try{if("function"!=typeof o[d]){var u=Error((s||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=o[d](r,d,s,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((s||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in n)){n[c.message]=!0;var p=l?l():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},nx=o}(),r=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(r=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ox=function(s,l){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:x("array"),bigint:x("bigint"),bool:x("boolean"),func:x("function"),number:x("number"),object:x("object"),string:x("string"),symbol:x("symbol"),any:g(a),arrayOf:function(e){return g((function(t,i,o,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[i];if(!Array.isArray(s))return new m("Invalid "+r+" `"+a+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var l=0;l<s.length;l++){var d=e(s,l,o,r,a+"["+l+"]",n);if(d instanceof Error)return d}return null}))},element:g((function(e,t,n,i,o){var r=e[t];return s(r)?null:new m("Invalid "+i+" `"+o+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:g((function(t,n,i,o,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+o+" `"+r+"` of type `"+v(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")})),instanceOf:function(e){return g((function(t,n,i,o,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+o+" `"+r+"` of type `"+((s=t[n]).constructor&&s.constructor.name?s.constructor.name:u)+"` supplied to `"+i+"`, expected instance of `"+a+"`.")}var s;return null}))},node:g((function(e,t,n,i,o){return y(e[t])?null:new m("Invalid "+i+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return g((function(t,o,r,a,s){if("function"!=typeof e)return new m("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[o],d=v(l);if("object"!==d)return new m("Invalid "+a+" `"+s+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,r,a,s+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?g((function(t,n,i,o,r){for(var a=t[n],s=0;s<e.length;s++)if(h(a,e[s]))return null;var l=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+o+" `"+r+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})):("production"!==process.env.NODE_ENV&&r(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+C(o)+" at index "+t+"."),a}return g((function(t,o,r,a,s){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,o,r,a,s,n);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new m("Invalid "+a+" `"+s+"` supplied to `"+r+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")}))},shape:function(e){return g((function(t,i,o,r,a){var s=t[i],l=v(s);if("object"!==l)return new m("Invalid "+r+" `"+a+"` of type `"+l+"` supplied to `"+o+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return f(o,r,a,d,b(c));var u=c(s,d,o,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return g((function(o,r,a,s,l){var d=o[r],c=v(d);if("object"!==c)return new m("Invalid "+s+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},o[r],e);for(var p in u){var h=e[p];if(i(e,p)&&"function"!=typeof h)return f(a,s,l,p,b(h));if(!h)return new m("Invalid "+s+" `"+l+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var g=h(d,p,a,s,l+"."+p,n);if(g)return g}return null}))}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function m(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function g(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function o(o,a,s,d,c,p,h){if(d=d||u,p=p||s,h!==n){if(l){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var x=d+":"+s;!t[x]&&i<3&&(r("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[x]=!0,i++)}}return null==a[s]?o?null===a[s]?new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `null`."):new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,s,d,c,p)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function x(e){return g((function(t,n,i,o,r,a){var s=t[n];return v(s)!==e?new m("Invalid "+o+" `"+r+"` of type `"+b(s)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null}))}function f(e,t,n,i,o){return new m((e||"React class")+": "+t+" type `"+n+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function y(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(y);if(null===e||s(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e[c]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,i=t.call(e);if(t!==e.entries){for(;!(n=i.next()).done;)if(!y(n.value))return!1}else for(;!(n=i.next()).done;){var o=n.value;if(o&&!y(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function C(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return m.prototype=Error.prototype,p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p},ox}()(hx.isElement,!0)}else $g.exports=function(){if(sx)return ax;sx=1;var e=ux();function t(){}function n(){}return n.resetWarningCache=t,ax=function(){function i(t,n,i,o,r,a){if(a!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return i}i.isRequired=i;var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var mx=H($g.exports);function gx(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function xx(e,t,n,i,o){const r=e[t],a=o||t;if(null==r||"undefined"==typeof window)return null;let s;const l=r.type;return"function"!=typeof l||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(l)||(s="Did you accidentally use a plain function component for an element instead?"),void 0!==s?new Error(`Invalid ${i} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${s} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const fx=gx(mx.element,xx);fx.isRequired=gx(mx.element.isRequired,xx);const yx="exact-prop: ";function vx(e){return e&&e.ownerDocument||document}const bx="undefined"!=typeof window?D.useLayoutEffect:D.useEffect;function Cx(e){const t=D.useRef(e);return bx((()=>{t.current=e})),D.useRef(((...e)=>(0,t.current)(...e))).current}function jx(...e){return D.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{!function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(e,t)}))}),e)}const wx={};const kx=[];class Tx{static create(){return new Tx}currentId=null;start(e,t){this.clear(),this.currentId=setTimeout((()=>{this.currentId=null,t()}),e)}clear=()=>{null!==this.currentId&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Bx(){const e=function(e,t){const n=D.useRef(wx);return n.current===wx&&(n.current=e(t)),n}(Tx.create).current;var t;return t=e.disposeEffect,D.useEffect(t,kx),e}const Ix={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Sx(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Sx(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Ax(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Sx(e))&&(i&&(i+=" "),i+=t);return i}function Ex(e,t=[]){if(void 0===e)return{};const n={};return Object.keys(e).filter((n=>n.match(/^on[A-Z]/)&&"function"==typeof e[n]&&!t.includes(n))).forEach((t=>{n[t]=e[t]})),n}function Ox(e){if(void 0===e)return{};const t={};return Object.keys(e).filter((t=>!(t.match(/^on[A-Z]/)&&"function"==typeof e[t]))).forEach((n=>{t[n]=e[n]})),t}function Lx(e){const{elementType:t,externalSlotProps:n,ownerState:i,skipResolvingSlotProps:o=!1,...r}=e,a=o?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,i),{props:s,internalRef:l}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:i,externalForwardedProps:o,className:r}=e;if(!t){const e=Ax(n?.className,r,o?.className,i?.className),t={...n?.style,...o?.style,...i?.style},a={...n,...o,...i};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Ex({...o,...i}),s=Ox(i),l=Ox(o),d=t(a),c=Ax(d?.className,n?.className,r,o?.className,i?.className),u={...d?.style,...n?.style,...o?.style,...i?.style},p={...d,...n,...l,...s};return c.length>0&&(p.className=c),Object.keys(u).length>0&&(p.style=u),{props:p,internalRef:d.ref}}({...r,externalSlotProps:a}),d=function(e,t,n){return void 0===e||"string"==typeof e?t:{...t,ownerState:{...t.ownerState,...n}}}(t,{...s,ref:jx(l,a?.ref,e.additionalProps?.ref)},i);return d}function Rx(e){return e.substring(2).toLowerCase()}function Mx(e){const{children:t,disableReactTree:n=!1,mouseEvent:i="onClick",onClickAway:o,touchEvent:r="onTouchEnd"}=e,a=D.useRef(!1),s=D.useRef(null),l=D.useRef(!1),d=D.useRef(!1);D.useEffect((()=>(setTimeout((()=>{l.current=!0}),0),()=>{l.current=!1})),[]);const c=jx((u=t)&&D.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,s);var u;const p=Cx((e=>{const t=d.current;d.current=!1;const i=vx(s.current);if(!l.current||!s.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,i))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(s.current)>-1:!i.documentElement.contains(e.target)||s.current.contains(e.target),r||!n&&t||o(e)})),h=e=>n=>{d.current=!0;const i=t.props[e];i&&i(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),D.useEffect((()=>{if(!1!==r){const e=Rx(r),t=vx(s.current),n=()=>{a.current=!0};return t.addEventListener(e,p),t.addEventListener("touchmove",n),()=>{t.removeEventListener(e,p),t.removeEventListener("touchmove",n)}}}),[p,r]),!1!==i&&(m[i]=h(i)),D.useEffect((()=>{if(!1!==i){const e=Rx(i),t=vx(s.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,i]),G.jsx(D.Fragment,{children:D.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(Mx.propTypes={children:fx.isRequired,disableReactTree:mx.bool,mouseEvent:mx.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mx.func.isRequired,touchEvent:mx.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(Mx.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[yx]:t=>{const n=Object.keys(t).filter((t=>!e.hasOwnProperty(t)));return n.length>0?new Error(`The following props are not supported: ${n.map((e=>`\`${e}\``)).join(", ")}. Please remove them.`):null}}}(Mx.propTypes));const Px="base";function _x(e,t){const n=Ix[t];return n?`${Px}--${n}`:function(e,t){return`${Px}-${e}-${t}`}(e,t)}const Nx="Snackbar";function Dx(e){return _x(Nx,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=_x(e,t)}))}(Nx,["root"]);const Fx={disableDefaultClasses:!1},Ux=D.createContext(Fx);"production"!==process.env.NODE_ENV&&(Ux.displayName="ClassNameConfiguratorContext");const qx=()=>function(e,t,n){const i={};for(const o in e){const r=e[o];let a="";for(let e=0;e<r.length;e+=1){const i=r[e];i&&(a+=t(i)+" ",n&&n[i]&&(a+=n[i]+" "))}i[o]=a}return i}({root:["root"]},function(e){const{disableDefaultClasses:t}=D.useContext(Ux);return n=>t?"":e(n)}(Dx)),Vx=D.forwardRef((function(e,t){const{autoHideDuration:n=null,children:i,disableWindowBlurListener:o=!1,exited:r=!0,onBlur:a,onClose:s,onFocus:l,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...g}=e,x=qx(),{getRootProps:f,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:i,open:o,resumeHideDuration:r}=e,a=Bx();D.useEffect((()=>{if(o)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&i?.(e,"escapeKeyDown")}}),[o,i]);const s=Cx(((e,t)=>{i?.(e,t)})),l=Cx((e=>{i&&null!=e&&a.start(e,(()=>{s(null,"timeout")}))}));D.useEffect((()=>(o&&l(t),a.clear)),[o,t,l,a]);const d=a.clear,c=D.useCallback((()=>{null!=t&&l(null!=r?r:.5*t)}),[t,r,l]),u=e=>t=>{const n=e.onFocus;n?.(t),d()},p=e=>t=>{const n=e.onMouseEnter;n?.(t),d()},h=e=>t=>{const n=e.onMouseLeave;n?.(t),c()};return D.useEffect((()=>{if(!n&&o)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,o,c,d]),{getRootProps:(t={})=>{const n={...Ex(e),...Ex(t)};return{role:"presentation",...t,...n,onBlur:(i=n,e=>{const t=i.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var i},onClickAway:e=>{i?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:o,onClose:s,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",C=Lx({elementType:b,getSlotProps:f,externalForwardedProps:g,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:x.root}),j=Lx({elementType:Mx,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete j.ownerState,!u&&r?null:G.jsx(Mx,{...j,children:G.jsx(b,{...C,children:i})})}));function Hx({size:e,color:i,time:o,strokeWidth:r=2,sx:a}){const[s,l]=n.useState("0 1069"),d=e/2,c=d-1;return n.useEffect((()=>{l(2*Math.PI*c+" 0")}),[]),G.jsx(t.Box,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${r}`,left:`-${r}`,transform:"rotate(-90deg)"},a),children:G.jsx(t.Box,{component:"circle",cx:d,cy:d,r:c,strokeWidth:r,stroke:i,fill:"none",strokeDasharray:s,sx:{transition:`stroke-dasharray ${o}`}})})}"production"!==process.env.NODE_ENV&&(Vx.propTypes={autoHideDuration:mx.number,children:mx.node,disableWindowBlurListener:mx.bool,exited:mx.bool,onClose:mx.func,open:mx.bool,resumeHideDuration:mx.number,slotProps:mx.shape({clickAwayListener:mx.oneOfType([mx.func,mx.shape({children:mx.element.isRequired,disableReactTree:mx.bool,mouseEvent:mx.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mx.func,touchEvent:mx.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:mx.oneOfType([mx.func,mx.object])}),slots:mx.shape({root:mx.elementType})});var Wx=n.memo(Hx);const $x=c.create((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),zx={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function Zx(){const e=t.useTheme(),{notify:i,close:o}=$x(),[r,a]=n.useState(!0),s=n.useRef(null),l=null==i?void 0:i.timeout,d=!!i;let c=G.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),G.jsx("path",{d:"M25.1384 11.334L14.8873 21.5851L10.8584 17.5718L8.66504 19.7651L14.8873 25.9873L27.3317 13.5429L25.1384 11.334Z",fill:"#2FBA90"})]});switch(null==i?void 0:i.type){case"error":c=G.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),G.jsx("path",{d:"M25.3331 13.0452L19.8782 18.5L25.3331 23.9548L23.5148 25.7731L18.06 20.3183L12.6051 25.7731L10.7869 23.9548L16.2417 18.5L10.7869 13.0452L12.6051 11.2269L18.06 16.6817L23.5148 11.2269L25.3331 13.0452Z",fill:"#FF6187"})]});break;case"warning":c=G.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.4065 3.6189L9.62438 3.59576L3.39812 9.78928L3.37498 18.5714L9.5685 24.7976L18.3506 24.8208L24.5769 18.6273L24.6 9.84516L18.4065 3.6189ZM26.9359 8.88481L19.3791 1.28812L8.66403 1.25988L1.06734 8.81663L1.0391 19.5317L8.59585 27.1284L19.311 27.1567L26.9076 19.5999L26.9359 8.88481Z",fill:"#B15600"}),G.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),G.jsx("path",{d:"M13.9998 21.6395C14.8896 21.6395 15.6109 20.9181 15.6109 20.0283C15.6109 19.1386 14.8896 18.4172 13.9998 18.4172C13.11 18.4172 12.3887 19.1386 12.3887 20.0283C12.3887 20.9181 13.11 21.6395 13.9998 21.6395Z",fill:"#B15600"})]})}return G.jsx(t.Box,{component:Vx,open:d,autoHideDuration:l,onClose:(e,t)=>{"clickaway"!==t&&o()},exited:r,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:G.jsx(I.Transition,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{a(!1)},onExited:()=>{a(!0)},nodeRef:s,children:n=>G.jsxs(t.Box,{ref:s,sx:{display:"flex",justifyContent:"space-between",p:12,borderRadius:8,backgroundColor:"background.paper",color:"text.primary",border:"solid 1px",borderColor:"border.main",boxShadow:"0px 6px 12px 0px rgba(0, 0, 0, 0.10)",transform:zx[n],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:i?c:""}),G.jsxs(t.Box,{sx:{ml:20},children:[G.jsx(t.Box,{sx:{typography:"caption"},children:null==i?void 0:i.message}),(null==i?void 0:i.link)?G.jsxs(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:i.link.outerLink,sx:{display:"inline-flex",alignItems:"center",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},children:[i.link.text,G.jsx(t.Box,{component:"svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{ml:4,width:18,height:18},children:G.jsx("path",{d:"M4.22703 13.2122L10.6811 6.75812L4.75206 6.75812L4.75736 5.25729H13.2426V13.7426H11.7471L11.7418 7.81878L5.28769 14.2729L4.22703 13.2122Z",fill:"currentColor"})})]}):"",(null==i?void 0:i.content)?G.jsx(t.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:i.content}):""]})]}),G.jsxs(t.Box,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:l?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:l?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:o,children:[l?G.jsx(Wx,{size:24,strokeWidth:"2.4px",time:`${l}ms`,color:e.palette.text.disabled}):"",G.jsx(t.Box,{component:"svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:16,height:16,border:"none",color:e.palette.text.disabled},children:G.jsx("g",{children:G.jsx("path",{d:"M12.8897 4.36345L9.25313 8L12.8897 11.6365L11.6775 12.8487L8.04095 9.21218L4.4044 12.8487L3.19221 11.6365L6.82876 8L3.19221 4.36345L4.4044 3.15127L8.04095 6.78782L11.6775 3.15127L12.8897 4.36345Z",fill:"currentColor"})})})]})]})})})}var Qx;function Gx(){return Gx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Gx.apply(null,arguments)}const Yx=e=>D.createElement("svg",Gx({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Qx||(Qx=D.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},D.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},D.createElement("g",{transform:"translate(18.000000, 291.000000)"},D.createElement("g",{transform:"translate(40.000000, 83.000000)"},D.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),Kx=6;function Xx(){var e;const n=t.useTheme();return G.jsx(t.Box,{sx:{mx:"auto",border:`${Kx}px solid ${null===(e=n.palette)||void 0===e?void 0:e.background.input}`,borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:G.jsx(t.Box,{component:Yx,sx:{position:"absolute",top:`-${Kx}px`,right:`-${Kx}px`,color:"primary.main"}})})}function Jx({showingDone:e,errorMessage:n}){return t.useTheme(),n?G.jsx(t.Box,{component:se.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?G.jsx(t.Box,{component:se.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):G.jsx(Xx,{})}function ef({showingDone:e,showing:n}){return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[G.jsx(t.Box,{sx:{mt:60},children:e?(null==n?void 0:n.brief)===Bg?o.i18n._({id:"EcVqOR",message:"{0} Submitted",values:{0:null==n?void 0:n.brief}}):o.i18n._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==n?void 0:n.brief}}):o.i18n._({id:"/nzjSF",message:"{0} pending",values:{0:null==n?void 0:n.brief}})}),(null==n?void 0:n.subtitle)?G.jsx(t.Box,{sx:{mt:20,typography:"body2"},children:null==n?void 0:n.subtitle}):""]})}function tf({isStarted:i,isEnded:o,tx:r,currentRequestChainId:a}){const[s,l]=n.useState(0),{chainId:d}=cp(),c=n.useMemo((()=>np(a||d||1,r,"tx")),[a,d,r]),u=n.useMemo((()=>{const e=Math.floor(s/60),t=s%60;return e?`${e}m ${t}s`:`${t}s`}),[s]),p=n.useRef();return n.useEffect((()=>(i&&(l(0),window.clearInterval(p.current),p.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(p.current)})),[i]),n.useEffect((()=>{o&&window.clearInterval(p.current)}),[o]),G.jsxs(t.Box,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"+Jkdiu",message:"Transaction Time:"}),u]}),G.jsxs(t.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:c,target:"_blank",rel:"noopener noreferrer",children:[G.jsx(e.Trans,{id:"S3piC2",message:"Tx"}),G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function nf(n){var i,r,{children:a,executionStatus:s,showSubmitLoadingDialog:l}=n;const d=_p(U(n,["children","executionStatus","showSubmitLoadingDialog"])),{ctxVal:c,showing:u,closeShowing:p,setShowing:h,showingDone:m,errorMessage:g,transactionTx:x,requests:f}=Object.assign(Object.assign({},d),s),{isMobile:y}=Bp(),{noSubmissionDialog:v,submissionDialogModal:b}=X(),C=()=>{h((e=>{if(!e)return e;const t=Object.assign({},e);return delete t.submitState,t}))},j=m&&(null==u?void 0:u.brief)===Bg&&!g,w=null===(r=null===(i=null==f?void 0:f.get(x))||void 0===i?void 0:i[0].metadata)||void 0===r?void 0:r.chainId;return G.jsxs(Fp.Provider,{value:c,children:[a,l&&G.jsx(Eh,{modal:!0,open:!!(null==u?void 0:u.submitState),onClose:C,children:!!u&&G.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",gap:20,p:20,minHeight:208,width:y?"100%":340,textAlign:"center"},children:[G.jsxs(t.Box,{sx:{textAlign:"center",color:"text.secondary"},children:[u.brief,G.jsx(t.Box,{component:se.Error,sx:{position:"absolute",top:20,right:20,color:"text.secondary",cursor:"pointer"},onClick:C})]}),"submitted"===u.submitState?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.ArrowSubmit,sx:{width:64,height:64}}),G.jsxs("div",{children:[G.jsx("div",{children:o.i18n._({id:"EcVqOR",message:"{0} Submitted",values:{0:u.brief}})}),u.subtitle&&G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]}),G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,onClick:C,sx:{mt:4},children:G.jsx(e.Trans,{id:"zga9sT",message:"OK"})})]}):G.jsxs(G.Fragment,{children:[G.jsx(Xx,{}),G.jsxs("div",{children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"7y/8M6",message:"Please confirm in wallet"})}),u.subtitle&&G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]})]})]})}),G.jsx(Eh,{open:!!u&&"loading"!==u.submitState&&!v,onClose:p,id:"submission",modal:!!y||b,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",px:20,pb:20,flex:1,overflowY:"auto",width:y?void 0:b?340:void 0},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{textAlign:"center",pt:60},children:G.jsx(Jx,{showingDone:m,errorMessage:g})}),g?G.jsxs(t.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(t.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:g})]}):G.jsxs(G.Fragment,{children:[G.jsx(ef,{showingDone:m,showing:u}),G.jsx(tf,{isStarted:!!u,isEnded:m,tx:x,currentRequestChainId:w})]})]}),j&&G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,size:t.Button.Size.big,onClick:()=>{vp(fp.Initial),p(),yp.setState({crossChainSubmittedCounter:1}),setTimeout((()=>{yp.setState({crossChainSubmittedCounter:0})}),300)},sx:{mt:y?20:"auto"},children:"Check in order list"}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:()=>{vp(fp.Initial),p()},sx:{mt:j?12:y?20:"auto"},children:g?G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"}):G.jsx(e.Trans,{id:"yz7wBu",message:"Close"})})]})})]})}const of="dodo-widget-container";function rf(e){return e.noLangProvider?G.jsx(G.Fragment,{children:e.children}):G.jsx(Vg,{locale:e.locale,children:G.jsx(nf,{...e,children:e.children})})}function af(e){return Lh(e),kp(),function(){const{chainId:e,evmProvider:t}=cp();n.useEffect((()=>{const n=n=>{if(n===e){const e=ac.get(n);if(null==e?void 0:e.isEVMChain)return t}return null},i=new B.ContractRequests({multiCallAddressList:u.multiCallAddressList,getProvider:n,rpc:ql()});nd.setGetConfigProvider(n),u.setContractRequests(i),r.setContractRequests(i)}),[e,t])}(),e.noUI?G.jsx(rf,{...e,children:e.children}):null}function sf(e){var t;const i=n.useRef(null);return G.jsx(K,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:i}),children:G.jsx(af,{...e})})}function lf(e){var{sx:i}=e,o=U(e,["sx"]);const{width:r}=X(),a=n.useMemo((()=>{let e="";return"number"==typeof r?e=`${r}px`:r&&(e=r),e?`calc(${e} - 40px)`:"auto"}),[r]);return G.jsx(t.QuestionTooltip,{container:document.querySelector(`.${of}`),maxWidth:a,sx:Object.assign({cursor:"help"},i),...o})}function df({route:i}){const o=t.useTheme();ac.get(i.fromChainId);const r=ac.get(i.toChainId),[a,s]=n.useState(!1),[l,d]=n.useState(!1),c=dh({fees:i.fees});return G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{py:20,borderStyle:"solid",borderWidth:o.spacing(1,0,0),borderColor:o.palette.border.main},children:G.jsx(t.Accordion,{children:G.jsx(t.AccordionItem,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[G.jsx(t.Box,{component:se.DetailBorder,sx:{mr:6,width:18,height:18}}),G.jsx(e.Trans,{id:"rRDi3Y",message:"Detail"})]}),G.jsx(t.Box,{component:se.CaretUp,sx:{width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]}),children:G.jsxs(t.Box,{sx:{mt:16},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary",flexShrink:0},children:G.jsx(e.Trans,{id:"lt8yMa",message:"Send to:"})}),G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[r?G.jsx(t.Box,{component:r.logo,sx:{width:18,height:18}}):null,G.jsx(t.Box,{sx:{display:"inline-block",mx:6,width:"1px",height:12,backgroundColor:"border.main"}}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},children:tp(i.toAddress)}),G.jsx(t.HoverOpacity,{component:"a",href:np(i.toChainId,i.toAddress,"address"),target:"_blank",rel:"noopener noreferrer",sx:{ml:6,width:18,height:18,color:"text.secondary",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})})]})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:G.jsx(e.Trans,{id:"sMMlTX",message:"Total fees"})}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>s(!a),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[G.jsx(t.Box,{sx:{fontWeight:600,color:o.palette.text.primary},children:i.feeUSD?`~$${i.feeUSD}`:"-"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:a?G.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):G.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),a&&c.map((e=>G.jsxs(t.Box,{sx:{mt:8,pl:22,pr:22,display:"flex",alignItems:"center",justifyContent:"space-between",color:"text.secondary",typography:"body2",position:"relative"},children:[G.jsx(t.Box,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:"10",height:"25",viewBox:"0 0 10 25",fill:"none",sx:{width:10,height:25,position:"absolute",left:10,bottom:10},children:G.jsx("path",{d:"M9 24L2 24C1.44772 24 1 23.5523 1 23L1 1",stroke:"currentColor",strokeOpacity:"0.5",strokeLinecap:"round",strokeDasharray:"2 2"})}),G.jsx(t.Box,{sx:{flex:1},children:e.title}),e.isFree?G.jsx(t.Box,{sx:{color:o.palette.primary.main},children:"Free"}):null!==e.value?G.jsxs(t.Box,{sx:{color:o.palette.text.primary},children:["~$",e.value]}):G.jsx(t.Box,{sx:{color:o.palette.text.primary},children:"-"})]},e.title))),G.jsxs(t.Box,{sx:{mt:8,mb:l?8:0,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",fontWeight:600,color:"success.main",flexShrink:0},children:"Fee comparison"}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>d(!l),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:"ZUNO"}),G.jsx(t.Box,{sx:{px:8,borderRadius:12,backgroundColor:o.palette.success.main,typography:"h6",fontWeight:600,color:o.palette.success.contrastText,textTransform:"uppercase"},children:"Cheapest"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:l?G.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):G.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),l&&G.jsx(Bh,{feeUSD:i.feeUSD}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(lf,{onlyHover:!0,title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:6})]}),G.jsxs(t.Box,{sx:{typography:"body2"},children:[100*i.slippage,"%"]})]})]})})})}),G.jsx(t.Box,{sx:{pt:0,pb:0,borderStyle:"solid",borderWidth:o.spacing(1,0,0),borderColor:o.palette.border.main},children:G.jsx(t.Accordion,{children:G.jsx(t.AccordionItem,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:G.jsxs(t.Box,{sx:{py:20,display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[G.jsx(t.Box,{component:se.DetailBorder,sx:{mr:6,width:18,height:18}}),G.jsx(e.Trans,{id:"QNWt8A",message:"Estimated Time"})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:[i.executionDuration?hh({start:Date.now(),end:Date.now()+1e3*i.executionDuration}):"-",G.jsx(t.Box,{component:se.CaretUp,sx:{ml:6,width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]})]}),children:G.jsx(hg,{route:i,isMobile:!0})})})})]})}function cf({open:i,onClose:o,route:r,bridgeOrderTxRequest:a,clearToAmt:s,clearFromAmt:l,isDialogModal:d}){const c=t.useTheme(),{contractStatus:u}=yp(),p=Sg({route:r,bridgeOrderTxRequest:a});return n.useEffect((()=>{u!==fp.Pending&&o(),u===fp.TxSuccess&&(s(),l())}),[u]),G.jsx(Eh,{title:G.jsx(e.Trans,{id:"tKE4Ak",message:"Cross Chain Summary"}),open:i,id:"cross-chain-summary",onClose:()=>{vp(fp.Initial),o()},modal:d,children:G.jsxs(G.Fragment,{children:[r?G.jsxs(t.Box,{sx:{px:16,pb:20,flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"36% 28% 36%",py:20,borderStyle:"solid",borderWidth:c.spacing(1,0,0),borderColor:c.palette.border.main},children:[G.jsx(Og,{token:r.fromToken,chainId:r.fromChainId,amount:r.fromAmount}),G.jsx(Eg,{children:G.jsx(t.Box,{sx:{display:"flex",px:3,py:3,backgroundColor:c.palette.background.paperContrast,border:`1px solid ${c.palette.border.main}`,borderRadius:"50%",alignItems:"center",width:24,height:24,overflow:"hidden"},children:G.jsx(Ag,{size:"medium",toolDetails:r.step.toolDetails,nameMarginLeft:8})})}),G.jsx(Og,{token:r.toToken,chainId:r.toChainId,amount:r.toTokenAmount})]}),G.jsx(df,{route:r})]}):"",G.jsx(t.Box,{sx:{px:16,py:20},children:G.jsx(t.Button,{fullWidth:!0,isLoading:u==fp.Pending,disabled:!r,onClick:()=>{p(),vp(fp.Pending)},children:u==fp.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"PZqJog",message:"Confirm Cross Chain"})})})]})})}function uf({message:n,onClose:i,isDialogModal:o}){return G.jsx(Eh,{open:!!n,onClose:i,id:"error-message",modal:o,children:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{flex:1,textAlign:"center"},children:[G.jsx(t.Box,{component:se.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),n?G.jsxs(t.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(t.Box,{sx:{color:"text.secondary",mt:12,mx:20,typography:"body2",wordBreak:"break-all",overflow:"auto",height:"300px"},children:n})]}):""]}),G.jsx(t.Box,{sx:{px:16,py:20},children:G.jsx(t.Button,{onClick:i,fullWidth:!0,children:G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"})})})]})})}function pf(){const[e,i]=n.useState(!1),o="https://smolrefuel.com/?partner=0x1271CAba4bf23f8Fb31F97448605d65EE302CA51";return G.jsxs(G.Fragment,{children:[G.jsxs(t.ButtonBase,{sx:{mt:16,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:4,typography:"body2",fontWeight:600,color:"text.link","&:hover":{color:"text.primary"}},onClick:()=>{window.open(o,"_blank")},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"19",viewBox:"0 0 19 19",fill:"none",children:G.jsx("path",{d:"M3.5 16.25V4.25C3.5 3.8375 3.64687 3.48438 3.94063 3.19063C4.23438 2.89687 4.5875 2.75 5 2.75H9.5C9.9125 2.75 10.2656 2.89687 10.5594 3.19063C10.8531 3.48438 11 3.8375 11 4.25V9.5H11.75C12.1625 9.5 12.5156 9.64688 12.8094 9.94063C13.1031 10.2344 13.25 10.5875 13.25 11V14.375C13.25 14.5875 13.3219 14.7656 13.4656 14.9094C13.6094 15.0531 13.7875 15.125 14 15.125C14.2125 15.125 14.3906 15.0531 14.5344 14.9094C14.6781 14.7656 14.75 14.5875 14.75 14.375V8.975C14.6375 9.0375 14.5188 9.07813 14.3938 9.09688C14.2688 9.11563 14.1375 9.125 14 9.125C13.475 9.125 13.0312 8.94375 12.6688 8.58125C12.3063 8.21875 12.125 7.775 12.125 7.25C12.125 6.85 12.2344 6.49063 12.4531 6.17188C12.6719 5.85313 12.9625 5.625 13.325 5.4875L11.75 3.9125L12.5375 3.125L15.3125 5.825C15.5 6.0125 15.6406 6.23125 15.7344 6.48125C15.8281 6.73125 15.875 6.9875 15.875 7.25V14.375C15.875 14.9 15.6938 15.3438 15.3313 15.7063C14.9688 16.0688 14.525 16.25 14 16.25C13.475 16.25 13.0312 16.0688 12.6688 15.7063C12.3063 15.3438 12.125 14.9 12.125 14.375V10.625H11V16.25H3.5ZM5 8H9.5V4.25H5V8ZM14 8C14.2125 8 14.3906 7.92813 14.5344 7.78438C14.6781 7.64062 14.75 7.4625 14.75 7.25C14.75 7.0375 14.6781 6.85938 14.5344 6.71563C14.3906 6.57188 14.2125 6.5 14 6.5C13.7875 6.5 13.6094 6.57188 13.4656 6.71563C13.3219 6.85938 13.25 7.0375 13.25 7.25C13.25 7.4625 13.3219 7.64062 13.4656 7.78438C13.6094 7.92813 13.7875 8 14 8Z",fill:"currentColor"})}),"Gas Refuel>"]}),G.jsx(Eh,{open:e,onClose:()=>i(!1),title:"Gas refuel",modal:!0,children:G.jsxs(t.Box,{sx:{maxWidth:540,minHeight:600,px:20,pb:24,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[G.jsx(t.Box,{sx:{pt:20,borderTopWidth:1,borderTopStyle:"solid",borderColor:"border.main",typography:"body2",color:"text.secondary"},children:"A solution for gas refueling that allows you to refill your wallet anonymously and gas-free."}),G.jsx(t.Box,{component:"iframe",src:o,width:"100%",sx:{borderRadius:12,overflow:"hidden",flex:1,border:"none"}})]})})]})}function hf({open:i,execute:o,onClose:r,toToken:s,fromToken:l,fromAmount:d,toAmount:c,priceImpact:u,clearFromAmt:p,clearToAmt:h,baseFeeAmount:m,curToFiatPrice:g,curFromFiatPrice:x,pricePerFromToken:f,additionalFeeAmount:y,loading:v,slippage:b,isDialogModal:C}){var j,w;const k=t.useTheme(),{contractStatus:T}=yp(),B=n.useMemo((()=>new a(u).gt(mc)),[u]),[I,S]=n.useState(!1),[A,E]=n.useState(!1);return n.useEffect((()=>{T!==fp.Pending&&r(),T===fp.TxSuccess&&(h(),p())}),[T]),n.useEffect((()=>{S(!1)}),[g]),G.jsx(Eh,{open:i,onClose:()=>{vp(fp.Initial),r()},id:"swap-summary",title:G.jsx(e.Trans,{id:"QR4/RH",message:"Swap summary"}),modal:C,children:G.jsxs(t.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[G.jsx(Nh,{width:16,height:16,url:null==l?void 0:l.logoURI,address:null!==(j=null==l?void 0:l.address)&&void 0!==j?j:"",marginRight:6}),G.jsx(t.Box,{children:`${Au({input:d,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),G.jsx(t.Box,{sx:{mt:4,typography:"h6",color:k.palette.text.secondary},children:x?`$${Su({input:x,showDecimals:1})}`:"-"})]}),G.jsx(t.Box,{sx:{width:16,mx:16},component:se.DoubleRight}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex"},children:[G.jsx(Nh,{width:16,height:16,marginRight:6,url:null==s?void 0:s.logoURI,address:null!==(w=null==s?void 0:s.address)&&void 0!==w?w:""}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:`${Au({input:c,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:k.palette.text.secondary},children:g?`$${Su({input:g,showDecimals:1})}`:"-"})]})]}),G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1 ",null==l?void 0:l.symbol," = ",G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:Au({input:new a(c).dividedBy(new a(d)),decimals:null==s?void 0:s.decimals})})," ",null==s?void 0:s.symbol]})]}),G.jsxs(t.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:k.palette.text.secondary},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{width:16,mr:7},component:se.DetailBorder}),G.jsx(e.Trans,{id:"XeovX3",message:"Swap Detail"})]}),G.jsx(t.Box,{component:t.ButtonBase,children:G.jsx(t.Box,{onClick:()=>E(!A),sx:{width:10,color:"text.secondary",transform:A?"rotateX(0deg)":"rotateX(180deg)"},component:se.CaretUp})})]}),G.jsxs(t.Box,{sx:{mt:16,display:A?"initial":"none"},children:[G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"93m8jT",message:"Basic Fee"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:m?`${Au({input:m,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"J39pAJ",message:"Additional Fee"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:y?`${Au({input:y,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"T+qgFw",message:"Price Impact"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),G.jsx(t.Box,{children:`${u}%`})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),G.jsxs(t.Box,{children:[b,"%"]})]})]})]}),G.jsx(t.Box,{sx:{flex:1}}),B&&G.jsxs(t.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>S(!I),children:[G.jsx(t.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:I?G.jsx(t.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:G.jsx(t.Box,{component:se.Done,sx:{width:14,color:"secondary.contrastText"}})}):G.jsx(t.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${k.palette.text.secondary}`}})}),G.jsx(t.Box,{children:G.jsx(e.Trans,{components:{0:G.jsx(t.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:u},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),G.jsx(t.Button,{isLoading:T==fp.Pending,disabled:B&&!I,fullWidth:!0,onClick:()=>{o(),vp(fp.Pending)},children:T==fp.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"lQ6r7x",message:"Confirm swap"})})]})})}function mf(e){var{sx:n,maxVal:i,decimals:o=2,onInputChange:r}=e,s=U(e,["sx","maxVal","decimals","onInputChange"]);return G.jsx(t.Input,{...s,onChange:e=>{const t=0===e.target.value.length?null:Lu(e.target.value,o),n=i&&t&&new a.BigNumber(t).gt(i)?i.toString():t;r&&r(n)}})}function gf({open:i,onClose:o,isBridge:r,isDialogModal:a}){const s=t.useTheme(),{slippage:l}=yp(),d=n.useMemo((()=>Number(l)>=xc),[l]),{defaultSlippage:c}=Xp(r);return G.jsx(Eh,{open:i,onClose:o,id:"swap-settings",title:G.jsx(e.Trans,{id:"OSWUSw",message:"Cross chain setting"}),modal:a,children:G.jsx(t.Box,{sx:{mx:20},children:G.jsxs(t.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column"},children:[G.jsx(mf,{fullWidth:!0,maxVal:100,value:null!=l?l:"",placeholder:c.toString(),onInputChange:e=>{!function(e,t){null===t?localStorage.removeItem(e?pc:uc):localStorage.setItem(e?pc:uc,String(t))}(!!r,e),Cp(e)},suffix:G.jsx(t.Box,{sx:{color:"text.disabled"},children:"%"}),height:36,sx:{mt:12}}),d&&G.jsx(t.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:G.jsx(e.Trans,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]})})})}const xf="position-y-dot";function ff(){return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(t.Skeleton,{width:"100%",height:12}),G.jsx(t.Skeleton,{width:"100%",height:12})]})}function yf({data:e,loading:i}){var o,r;const a=t.useTheme(),s=a.palette.primary.main,l=n.useRef(null),d=e.length;return G.jsx(t.Box,{sx:{height:105,flex:1,[`& .${xf}`]:{}},ref:l,children:i?G.jsx(ff,{}):G.jsx(t.Box,{component:S.ResponsiveContainer,sx:{typography:"h6","& .recharts-cartesian-axis text":{fill:a.palette.background.paperContrast}},children:G.jsxs(S.AreaChart,{data:e,margin:{top:0,right:0,left:0,bottom:0},children:[G.jsx(S.XAxis,{dataKey:"forecastSlippage",axisLine:!1,tickLine:!1,interval:"preserveStartEnd",tickFormatter:e=>Vu({input:e}),type:"number",domain:[d&&null!==(o=e[0].forecastSlippage)&&void 0!==o?o:0,d&&null!==(r=e[d-1].forecastSlippage)&&void 0!==r?r:"auto"]}),G.jsx(S.YAxis,{dataKey:"confidenceRatio",axisLine:!1,tickLine:!1,hide:!0}),G.jsx("defs",{children:G.jsxs("linearGradient",{id:"count-linear",x1:"0",y1:"0",x2:"0",y2:"1",children:[G.jsx("stop",{offset:"0",stopColor:s,stopOpacity:.3}),G.jsx("stop",{offset:"100%",stopColor:s,stopOpacity:0})]})}),G.jsx(S.Area,{type:"monotone",dataKey:"confidenceRatio",stroke:s,strokeWidth:2,fill:"url(#count-linear)"}),e.map((e=>G.jsx(S.ReferenceDot,{x:e.forecastSlippage,y:e.confidenceRatio,r:1,fill:a.palette.text.primary,stroke:"none",className:xf},e.confidenceRatio)))]})})})}var vf=n.memo(yf);const bf=t.styled(t.Slider)((({theme:e})=>({height:2,padding:"15px 0",margin:0,"& .base-Slider-valueLabel":{fontSize:12,fontWeight:"normal",top:-6,backgroundColor:"unset",color:e.palette.text.primary,"&:before":{display:"none"},"& *":{background:"transparent",color:e.palette.text.primary}},"& .base-Slider-track":{display:"none"},"& .base-Slider-rail":{backgroundColor:e.palette.text.disabled,height:1,opacity:1},"& .base-Slider-mark":{display:"none",opacity:1,backgroundColor:e.palette.success.main,height:6,width:4,borderRadius:4},"& .base-Slider-markLabel":{display:"none",fontSize:"12px",lineHeight:"17px"}})));function Cf(i){var{hidden:o,sx:r,value:a,color:s,min:l,max:d,formatValue:c,getSliderYPosition:u}=i,p=U(i,["hidden","sx","value","color","min","max","formatValue","getSliderYPosition"]);const{children:h}=p,m=U(p,["children"]),{isMobile:g}=t.useDevices(),x=n.useRef(null),f=u(a),y=g?4:0,v=f?f-39-y:void 0,b=null!=s?s:"text.primary",C=a===l,j=a===d;return G.jsxs(t.Box,{...m,ref:x,sx:Object.assign({position:"absolute","&&&":{display:o?"none":"block",backgroundColor:"transparent",boxShadow:"none",bottom:8+y,width:"auto",height:"auto",top:"auto",marginLeft:0,transform:"none"}},r),children:[h,G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[v?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:b,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),G.jsx(t.Box,{sx:{height:v,width:"0",borderStyle:"dashed",borderWidth:1,borderColor:b}})]}):"",G.jsx(t.Box,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:b,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),G.jsxs(t.Box,{sx:Object.assign(Object.assign({typography:"h6",position:"absolute",bottom:-20,color:b,whiteSpace:"nowrap",backgroundColor:"background.paperContrast"},C?{left:0}:{}),j?{right:0}:{}),children:[j?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:"span",sx:{color:"success.main"},children:G.jsx(e.Trans,{id:"cOvZFM",message:"Dynamic"})}),G.jsx("span",{children:" • "})]}):"",c(a)]})]})]})}function jf(e){var{hoverValue:n,formatValue:i,getSliderYPosition:o}=e,r=U(e,["hoverValue","formatValue","getSliderYPosition"]);const{isMobile:a}=t.useDevices(),s=a?"primary.main":void 0,l=a?void 0:"primary.main";return G.jsx(bf,{slots:{thumb:e=>{const t=r.value&&"number"==typeof r.value&&(r.min&&r.value<r.min||r.max&&r.value>r.max),d={value:r.value,min:r.min,max:r.max,hidden:!!t,color:s,formatValue:i,getSliderYPosition:o},c=Object.assign(Object.assign({},e),d);if(null!==n&&r.max&&r.min&&r.value!==n){const e=r.max-r.min,t=n-r.min,i=t?t/e*100:0;if(a){const e=!!n&&(!!r.min&&n<r.min||!!r.max&&n>r.max);return G.jsxs(G.Fragment,{children:[G.jsx(Cf,{...d,value:n,color:l,hidden:e,sx:{left:i+"%"}}),G.jsx(Cf,{...c})]})}return G.jsxs(G.Fragment,{children:[G.jsx(Cf,{...c}),G.jsx(Cf,{...d,value:n,hidden:!1,color:l,sx:{left:i+"%"}})]})}return G.jsx(Cf,{...c})}},...r})}const wf=(e,{time:t=100,wrapper:n=document,retryCount:i=50}={})=>new Promise((o=>{n.querySelector(e)?o(!0):setTimeout((()=>q(void 0,void 0,void 0,(function*(){if(n.querySelector(e))o(!0);else if(i){const r=yield wf(e,{time:t,wrapper:n,retryCount:i-1});o(r)}else o(!1)}))),t)}));function kf({data:i,activeSlippage:o,loading:r,sx:s,handleChangeCustomSlippage:l}){const d=n.useMemo((()=>{var e;return null!==(e=null==i?void 0:i.length)&&void 0!==e?e:0}),[i]),{isMobile:c}=t.useDevices(),[u,p]=n.useState([]),h=n.useRef(null);n.useEffect((()=>{(()=>{q(this,void 0,void 0,(function*(){var e;if(h.current&&d){const t=`.${xf}`;yield wf(t,{wrapper:h.current});const n=h.current.querySelectorAll(t),{y:i,height:o}=h.current.getBoundingClientRect(),r=null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0,a=[];for(let e=0;e<r;e++){const t=n[e];const r=(t.children[0]?t.children[0].getBoundingClientRect().y:t.getBoundingClientRect().y)-i-.5;a.push(o-r)}p(a)}}))})()}),[d]);const m=(({activeSlippage:e,data:t,yPositions:i})=>{const[o,r]=n.useState(0),s=n.useMemo((()=>1e6),[]),[l,d]=n.useMemo((()=>{var e,n;const i=null==t?void 0:t.length;return i?[new a(null!==(e=t[0].forecastSlippage)&&void 0!==e?e:0).times(null!=s?s:0).dp(0,1).toNumber(),new a(null!==(n=t[i-1].forecastSlippage)&&void 0!==n?n:0).times(null!=s?s:0).dp(0,1).toNumber()]:[0,0]}),[t,s]),c=n.useCallback((e=>{if(void 0===e)return"";const n=new a(e);if((null==t?void 0:t.length)&&s){const e=t.find((e=>{var t;return new a(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(s).dp(0,1).isEqualTo(n)}));if(null==e?void 0:e.forecastSlippage)return Vu({input:e.forecastSlippage,showDecimals:4})}return Vu({input:s?n.div(s):n,showDecimals:4})}),[s,t]),u=n.useCallback((e=>{let n=0;return e&&(null==t?void 0:t.length)&&s?(t.some(((o,r)=>{var l,d;const c=null!==(l=o.forecastSlippage)&&void 0!==l?l:0,u=new a(c).times(s).dp(0,1).toNumber();if(e===u)return n=i[r],!0;if(e<u){if(0===r)return n=0,!0;const o=c-(null!==(d=t[r-1].forecastSlippage)&&void 0!==d?d:0),l=i[r]-i[r-1],u=c-new a(e).div(s).toNumber();return n=i[r]-l/o*u,!0}})),n):n}),[i,t,s]),p=n.useCallback((e=>{r(e);const n=new a(e);let i,o=-1;if((null==t?void 0:t.length)&&s){o=t.findIndex((e=>{var t;return new a(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(s).dp(0,1).isEqualTo(n)}));const e=-1!==o?t[o]:void 0;i=null==e?void 0:e.forecastSlippage}return i||(i=n.div(null!=s?s:0).toNumber()),i}),[t,s]);return n.useEffect((()=>{if(s&&e){const t=new a(e).times(s).dp(0,1);t.isEqualTo(o)||r(t.toNumber())}}),[e]),{min:l,max:d,value:o,decimalConversion:s,formatValue:c,getSliderYPosition:u,handleChangeValue:p}})({data:i,activeSlippage:o,yPositions:u}),{hoverValue:g,setHoverValue:x}=function(e,{slippageSlider:i}){const{isMobile:o}=t.useDevices(),[r,s]=n.useState(null),l=n.useRef(!1);return n.useEffect((()=>{if(e.current&&i.max){const t=e.current;let{width:n,x:d}=t.getBoundingClientRect();const c=e=>{if(l.current)return;const t=e.pageX-d,o=i.max-i.min,c=new a(t/n*o).integerValue().plus(i.min).toNumber();c!==r&&s(c)},u=()=>{s(null)},p=()=>{l.current=!1},h=()=>{l.current=!0};return o||(t.addEventListener("mousemove",c),t.addEventListener("mouseleave",u),t.addEventListener("mouseup",p),t.addEventListener("mousedown",h)),()=>{o&&(t.removeEventListener("mousemove",c),t.removeEventListener("mouseleave",u),t.removeEventListener("mouseUp",p),t.removeEventListener("mouseDown",h))}}}),[e,o]),{hoverValue:r,setHoverValue:s}}(h,{slippageSlider:m}),{successRate:f,hoverSuccessRate:y}=function({data:e,activeSlippage:t,hoverValue:i,decimalConversion:o}){const r=n.useMemo((()=>{var n,i;let o="-";if(t&&(null==e?void 0:e.length)){const r=e.some(((n,i)=>{var r,a,s,l,d,c;const u=null!==(r=n.forecastSlippage)&&void 0!==r?r:0;if(t===u)return o=Vu({input:null!==(a=null==n?void 0:n.confidenceRatio)&&void 0!==a?a:0}),!0;if(t<u){if(0===i)o=`< ${Vu({input:null!==(s=null==n?void 0:n.confidenceRatio)&&void 0!==s?s:0})}`;else{const t=Vu({input:null!==(d=null===(l=e[i-1])||void 0===l?void 0:l.confidenceRatio)&&void 0!==d?d:0}),r=Vu({input:null!==(c=null==n?void 0:n.confidenceRatio)&&void 0!==c?c:0});o=`${t} - ${r}`}return!0}return!1}));r||(o=`> ${Vu({input:null!==(i=null===(n=e[e.length-1])||void 0===n?void 0:n.confidenceRatio)&&void 0!==i?i:0})}`)}return o}),[e,t]),s=n.useMemo((()=>{var t,n;let r="";if(i&&(null==e?void 0:e.length)&&o){const s=e.some(((t,n)=>{var s,l,d,c,u,p;const h=null!==(s=t.forecastSlippage)&&void 0!==s?s:0,m=new a(h).times(o).dp(0,1).toNumber();if(i===m)return r=Vu({input:null!==(l=null==t?void 0:t.confidenceRatio)&&void 0!==l?l:0}),!0;if(i<m){if(0===n)r=`< ${Vu({input:null!==(d=null==t?void 0:t.confidenceRatio)&&void 0!==d?d:0})}`;else{const i=Vu({input:null!==(u=null===(c=e[n-1])||void 0===c?void 0:c.confidenceRatio)&&void 0!==u?u:0}),o=Vu({input:null!==(p=null==t?void 0:t.confidenceRatio)&&void 0!==p?p:0});r=`${i} - ${o}`}return!0}return!1}));s||(r=`> ${Vu({input:null!==(n=null===(t=e[e.length-1])||void 0===t?void 0:t.confidenceRatio)&&void 0!==n?n:0})}`)}return r}),[i,o,e]);return{successRate:r,hoverSuccessRate:s}}({data:i,activeSlippage:o,hoverValue:g,decimalConversion:m.decimalConversion});return i?G.jsxs(t.Box,{sx:Object.assign({p:12,pb:28,borderRadius:12,backgroundColor:"background.paperContrast"},s),children:[G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600,color:"text.secondary"},children:G.jsx(e.Trans,{id:"88dol0",message:"Success Rate"})}),G.jsx(t.LoadingSkeleton,{loading:r,loadingProps:{width:100},sx:{mt:4,typography:"caption",color:y?"primary.main":"text.primary"},children:y||f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"flex-end",pr:4},children:[G.jsx(t.Box,{sx:{pb:8,mr:16,typography:"h6",fontWeight:600},children:G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"})}),G.jsxs(t.Box,{sx:{flex:1},ref:h,children:[G.jsx(vf,{data:i,loading:r}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:!r&&d?G.jsx(jf,{value:c?g||-1:m.value,min:m.min,max:m.max,disabled:!c,marks:[{value:m.max,label:m.max}],formatValue:m.formatValue,getSliderYPosition:m.getSliderYPosition,hoverValue:c?m.value:g,onChange:(e,t)=>{if("number"==typeof t){if(c)return void x(t);const e=m.handleChangeValue(t);l(e)}},onChangeCommitted:()=>{x(null)}}):""})]})]})]}):null}var Tf,Bf=n.memo(kf);function If({title:i,desc:o,doNotChecked:r,onChangeDoNotChecked:a}){const s=t.useTheme();if(n.useMemo((()=>r),[]))return null;const l=s.palette.warning.main;return G.jsxs(t.Box,{sx:{backgroundColor:t.alpha(l,.1),borderRadius:8,padding:12},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,typography:"body2",color:l,fontWeight:700},children:[G.jsx(se.Warn,{}),i]}),G.jsx(t.Box,{sx:{mt:8,typography:"body2",fontWeight:500,color:s.palette.text.secondary,textAlign:"center"},children:o}),!!a&&G.jsxs(t.Box,{sx:{width:"100%",mt:20,color:s.palette.text.secondary,typography:"h6",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer"},component:"label",children:[G.jsx(t.Checkbox,{checked:r,size:16,onChange:e=>{const{checked:t}=e.target;a(t)}}),G.jsx(e.Trans,{id:"3WdxUv",message:"Do not remind again"})]})]})}function Sf({fromToken:i,toToken:r}){var s,l;const d=t.useTheme(),{slippageAdvanced:c,notRemindAgainSlippageHigher:u,notRemindAgainSlippageLower:p}=Gp(),{customSlippage:h,customSlippageNum:m,handleSlippageChange:g,forecastSlippage:x,forecastSlippageQuery:f,recommendSlippage:y}=nh({fromToken:i,toToken:r}),v=!!x,[b,C]=n.useState(!1),[j,w]=n.useState();!j&&i&&r&&w(h?Tf.custom:Tf.recommend);const k=j===Tf.custom,T=n.useRef(null),B=n.useMemo((()=>j===Tf.custom?m?new a(m).div(100).toNumber():void 0:new a(y).div(100).toNumber()),[j,y,m]),I=n.useCallback((e=>{k||w(Tf.custom),g({slippage:new a(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(y)})}),[k,y,g]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:24,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"x6GJ4a",message:"Max Slippage"}),G.jsx(t.QuestionTooltip,{title:G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"qoii6e",message:"The dynamic slippage is provided by ZUNO team through analyzing historical transactions."}),G.jsx("br",{}),G.jsxs(t.Box,{component:"a",href:o.i18n._({id:"zABfk1",message:"https://blog.dodoex.io/introducing-the-dodo-smart-slippage-3d32d13a4fef"}),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[G.jsx(e.Trans,{id:"NgeSlx",message:"Learn More"}),">"]})]}),ml:7})]}),f.isLoading||(null===(s=f.slippageData.slippageList)||void 0===s?void 0:s.length)?G.jsxs(t.LoadingSkeleton,{loading:f.isLoading,loadingProps:{width:100},component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"sxkWRg",message:"Advanced"}),G.jsx(t.Checkbox,{sx:{top:-1},size:16,checked:c,onChange:e=>{const{checked:t}=e.target;Gp.setState({slippageAdvanced:t})}})]}):""]}),!!j&&G.jsxs(t.Tabs,{value:j,onChange:(e,t)=>{w(t),t===Tf.custom&&C(!0)},children:[G.jsxs(t.TabListButton,{variant:"inPaper",sx:{mt:16,'&:not(:hover) [aria-selected="true"] .weak':{color:t.alpha(d.palette.secondary.contrastText,.5)}},children:[G.jsx(t.TabButton,{value:Tf.recommend,variant:"inPaper",sx:{position:"relative"},children:G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:"span",sx:{position:"absolute",top:4,left:4,ml:4,typography:"h6",fontWeight:600,padding:d.spacing(0,8),borderRadius:4,backgroundColor:k?t.alpha(d.palette.purple.main,.1):"#FFF"},children:G.jsx(t.Box,{component:"span",sx:{background:k?`linear-gradient(90deg, ${d.palette.purple.main} -1.33%, ${"dark"===d.palette.mode?"#E6D9FF":"#BFAFF3"} 98.67%)`:`linear-gradient(90deg, ${d.palette.purple.main} -1.33%, #BFAFF3 98.67%)`,backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"New"})}),G.jsxs(t.Box,{sx:{textAlign:"center"},children:[v?G.jsxs(t.Box,{sx:{flexGrow:1,typography:"body2",fontWeight:600},children:[y.toString()||"-","%"]}):G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"wSpNR+",message:"This trading pair does not have enough historical data and has used the default dynamic slippage."}),sx:{ml:0,maxWidth:240},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"body2",fontWeight:600,color:d.palette.warning.main,gap:4},children:[G.jsx(t.Box,{component:se.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),G.jsxs("span",{children:[y.toString()||"-","%"]})]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600},className:"weak",children:G.jsx(e.Trans,{id:"cOvZFM",message:"Dynamic"})})]})]})}),G.jsx(t.TabButton,{value:Tf.custom,variant:"inPaper",sx:{position:"relative",p:0},children:G.jsxs(t.Box,{sx:{px:16,py:12,typography:"body2",fontWeight:600,textAlign:"center"},onClick:()=>{setTimeout((()=>{C(!0)}))},children:[b?G.jsx(t.Input,{ref:T,placeholder:"-",sx:{backgroundColor:"transparent",borderWidth:0,"& input":{textAlign:"center",typography:"body2",p:0,boxSizing:"border-box",height:19,color:k?d.palette.secondary.contrastText:d.palette.text.secondary,"&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",value:h||"",autoFocus:!0,onChange:e=>{const t=e.target.value;g({slippage:t,disabled:!1,recommend:String(y)})},onBlur:()=>{setTimeout((()=>{if(C(!1),!m)return void w(Tf.recommend);const e=!m||m<0;e&&h&&g({slippage:h,disabled:e,deleted:e,recommend:String(y)})}),10)},onKeyDown:e=>{var t;"Enter"===e.code&&(e.preventDefault(),null===(t=T.current)||void 0===t||t.blur())}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,color:h&&k?d.palette.warning.main:void 0},children:[h&&G.jsx(t.Box,{component:se.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),h||"-","%"]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"h6",fontWeight:600},className:"weak",children:G.jsx(e.Trans,{id:"8Tg/JR",message:"Custom"})})]})})]}),G.jsx(t.TabPanel,{value:Tf.recommend,children:(null===(l=f.slippageData.slippageList)||void 0===l?void 0:l.length)&&c?G.jsx(Bf,{data:f.slippageData.slippageList,activeSlippage:B,loading:f.isLoading,handleChangeCustomSlippage:I,sx:{mt:8}}):""}),G.jsxs(t.TabPanel,{value:Tf.custom,children:[G.jsx(t.Box,{sx:{mt:8}}),m>y&&G.jsx(If,{title:o.i18n._({id:"8XNsbx",message:"Higher than dynamic slippage"}),desc:o.i18n._({id:"iLj1a9",message:"Dynamic slippage is {recommendSlippage}%,the current slippage setting is higher than the dynamic slippage, which means you are willing to accept a worse final execution price.",values:{recommendSlippage:y}}),doNotChecked:u,onChangeDoNotChecked:e=>Gp.setState({notRemindAgainSlippageHigher:e})}),!!m&&m<y&&G.jsx(If,{title:o.i18n._({id:"TTlkRL",message:"Lower than dynamic slippage"}),desc:o.i18n._({id:"yq+Q9s",message:"Dynamic slippage is {recommendSlippage}% , the current slippage setting may increase the failure rate of transactions.",values:{recommendSlippage:y}}),doNotChecked:p,onChangeDoNotChecked:e=>Gp.setState({notRemindAgainSlippageLower:e})})]})]})]})}function Af({checked:n,onChange:i,sx:o,disabled:r}){const a=t.useTheme();let s=a.palette.background.tag;return n&&(s=a.palette.secondary.main),G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:a.palette.background.input,opacity:r?.5:1},o),component:t.ButtonBase,disabled:r,onClick:()=>{r||i(!n)},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"az8lvo",message:"Off"})}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:n?a.palette.secondary.contrastText:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"Z5HWHd",message:"On"})}),G.jsx(t.Box,{sx:{borderRadius:6,backgroundColor:s,zIndex:0,position:"absolute",top:2,bottom:2,width:"calc(50% - 2px - 2px)",left:n?"calc(50% + 2px)":"2px",transition:"left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"}})]})}function Ef({show:n,onClick:i}){const o=t.useTheme();return G.jsxs(t.HoverOpacity,{weak:!0,sx:{display:n?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:o.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${o.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${t.alpha("light"===o.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:i,children:[G.jsx(e.Trans,{id:"F8yRdq",message:"More trade settings"}),G.jsx(t.Box,{component:"svg",width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M12.5 19L6.5 13L7.9 11.6L12.5 16.175L17.1 11.6L18.5 13L12.5 19ZM12.5 13L6.5 6.99998L7.9 5.59998L12.5 10.175L17.1 5.59998L18.5 6.99998L12.5 13Z",fill:"currentColor"})})]})}function Of({selected:e,name:n,logo:i,onClick:o}){const r=t.useTheme();return G.jsxs(t.Box,{component:t.ButtonBase,onClick:o,sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,py:19,mt:16,mx:8,width:"calc(33.33% - 8px - 8px)",borderRadius:8,backgroundColor:r.palette.background.paperContrast,borderColor:e?r.palette.secondary.main:r.palette.background.paperContrast,borderWidth:1,borderStyle:"solid","&:hover":{borderColor:r.palette.secondary.main},position:"relative",overflow:"hidden"},children:[G.jsx("img",{src:i,alt:n,style:{height:40,width:40}}),G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:600},children:n}),e&&G.jsx(t.Box,{sx:{right:0,top:0,position:"absolute",width:32,height:24,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r.palette.secondary.main,borderRadius:"0px 0px 0px 8px"},children:G.jsx("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M11.8709 3.16663L5.03682 10.0007L2.35089 7.32514L0.888672 8.78737L5.03682 12.9355L13.3331 4.63922L11.8709 3.16663Z",fill:r.palette.secondary.contrastText})})})]})}function Lf({privacySwapSupplierEndpoints:e,endpointStatusMap:i,refetchEndpointStatus:o,setIsSelectSupplierMode:r}){var a,s;const l=t.useTheme(),[d,c]=n.useState(null!==(s=null===(a=null==e?void 0:e[0])||void 0===a?void 0:a.key)&&void 0!==s?s:null),[u,p]=n.useState(i);u!==i&&(p(i),Array.from(i.entries()).forEach((([e,t])=>{t&&c(e)})));const h=d?null==e?void 0:e.find((e=>e.key===d)):void 0,m=!d||i.get(d),g=n.useCallback((()=>{o(),r(!1)}),[o,r]),{switchTo:x}=function({chainId:e,successCallback:t,selectedSupplier:i}){return{switchTo:n.useCallback((()=>q(this,void 0,void 0,(function*(){if(i)try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[i.addChainParameters]}),t()}catch(e){console.error(e)}}))),[i,t])}}({successCallback:g,selectedSupplier:h});return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"stretch",flexDirection:"column",minHeight:"100%"},children:[G.jsx(t.Box,{sx:{mt:20,pt:12,display:"flex",alignItems:"flex-start",flexWrap:"wrap",mx:-8},children:null==e?void 0:e.map(((e,t)=>{const n=d===e.key;return G.jsx(Of,{selected:n,name:e.name,logo:e.logo,onClick:()=>c(e.key)},t)}))}),G.jsx(t.Box,{sx:{mt:24,width:"100%",height:"1px",flexShrink:0,flexGrow:0,backgroundColor:l.palette.border.main}}),G.jsxs(t.Box,{sx:{mt:24,mb:24,typography:"body2",fontWeight:500,color:l.palette.text.secondary},children:[G.jsx(t.Box,{children:"*Choose your privacy transaction server. Later, a new network will be added to your wallet, and transactions submitted under this network can only be seen by the privacy transaction server. The server will protect you from the impact of MEV. You can also disable the privacy transaction by switching back to the original network."}),h&&G.jsx(t.Box,{sx:{color:l.palette.primary.main},component:"a",href:null==h?void 0:h.docUrl,target:"_blank",rel:"noopener noreferrer",children:"Learn more>"})]}),G.jsx(t.Button,{size:t.Button.Size.big,variant:t.Button.Variant.contained,fullWidth:!0,sx:{marginTop:"auto",flexShrink:0,flexGrow:0},disabled:m,onClick:x,children:"Enable Privacy Swap"}),G.jsx(t.Box,{sx:{height:28,width:"100%"}})]})}function Rf({open:o,onClose:r,fromToken:a,toToken:s,privacySwapEnableAble:l,privacySwapEnable:d,privacySwapSupplierEndpoints:c,endpointStatusMap:u,refetchEndpointStatus:p,isDialogModal:h}){const m=t.useTheme(),{ddl:g,expertMode:x,disableIndirectRouting:f}=Gp(),[y,v]=n.useState(!1),b=n.useRef(null),[C,j]=n.useState(!1);return n.useEffect((()=>{const e=b.current,t=new ResizeObserver((()=>{e&&j(e.scrollHeight!==e.offsetHeight)})),n=i.throttle((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;j(t)}),50);return e&&(j(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==b?void 0:b.current]),G.jsx(Eh,{open:o,onClose:y?()=>v(!1):r,id:"swap-settings",title:y?"Select A Supplier":G.jsx(e.Trans,{id:"384mLX",message:"Same chain setting"}),modal:h,children:G.jsx(t.Box,{sx:{px:20,pb:34,overflowY:"auto"},ref:b,children:y?G.jsx(Lf,{privacySwapSupplierEndpoints:c,endpointStatusMap:u,refetchEndpointStatus:p,setIsSelectSupplierMode:v,privacySwapEnable:d,privacySwapEnableAble:l}):G.jsxs(G.Fragment,{children:[G.jsx(Sf,{fromToken:a,toToken:s}),G.jsxs(t.Box,{sx:{mt:24,pt:14,borderTop:`solid 1px ${m.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"zSMRJ/",message:"Transaction Deadline"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"wmCrk7",message:"You may modify the transaction deadline, the maximum time allowed for a trade to be processed on-chain. However, please note that this may lead to your trade executing at a subpar price, as the market price may change during that time."}),ml:7})]}),G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[G.jsx(t.Input,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(fc),value:g,onChange:e=>{Gp.setState({ddl:e.target.value})}}),G.jsx(e.Trans,{id:"H9HlDe",message:"minutes"})]})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${m.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"MXQodB",message:"Disable Indirect Routing"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"Y0Knz4",message:"Checking this option means that the routing algorithm will only route to liquidity pools between the two tokens in the trading pair and will ignore routes with any intermediary tokens."}),ml:7})]}),G.jsx(Af,{checked:f,onChange:e=>{Gp.setState({disableIndirectRouting:e})}})]}),l&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"U1Bq/+",message:"Privacy Swap"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"fsEEap",message:"Privacy Swap can effectively protect users from sandwich attacks that could come about due to the differences between the slippage settings and the current price in the liquidity pool. This feature is free for a limited time."}),ml:7})]}),G.jsx(Af,{checked:d,disabled:d,onChange:e=>{e&&v(!0)}})]})]}),G.jsx(Ef,{show:C,onClick:()=>{var e,t;null===(e=b.current)||void 0===e||e.scrollTo({top:null===(t=b.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})})}function Mf({onClick:e,disabled:n,plus:i}){const o=t.useTheme(),r=n||i||!e;return G.jsx(t.Box,{sx:{width:"100%",position:"relative"},children:G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({width:44,height:44,borderRadius:"50%",backgroundColor:o.palette.background.paper,border:"4px solid #E4E1D4",display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)",color:"text.secondary"},r?{cursor:"inherit"}:{"&:hover":{color:"text.primary"},"&:focus-visible":{"&::before":{content:'""',position:"absolute",display:"block",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"50%",width:36,height:36,border:"solid 1px",borderColor:"text.secondary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:i?G.jsx(t.Box,{component:se.Plus,sx:{width:24,height:24}}):G.jsx(t.Box,{component:se.ArrowBack,sx:{width:24,height:24}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(Tf||(Tf={}));const Pf=()=>{const{requests:e,updateText:t}=Up(),i=n.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if((n===Ip.Running||n===Ip.Success)&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=n.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if(n===Ip.Success&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),r=n.useCallback(((e,n,i)=>{const o=e[n];if(!o)return!1;return!!(a.isBigNumber(i)?i:new a(i)).isEqualTo(o)||(t((e=>{var t;const i=Object.assign({},e.metadata);return(null===(t=null==i?void 0:i.logBalance)||void 0===t?void 0:t[n])?(delete i.logBalance[n],Object.keys(i.logBalance).length||delete i.logBalance,{brief:e.brief,spec:e.spec,metadata:i}):null})),!1)}),[t]),s=n.useCallback(((e,t)=>r(i,e,t)),[i,r]),l=n.useCallback(((e,t)=>r(o,e,t)),[o,r]);return{balanceData:i,balanceDataDone:o,isTokenLoading:s,isTokenLoadingDone:l}};function _f({onClick:n,balance:i,decimals:o,address:r,showMaxBtn:a,canClickBalance:s,loading:l,balanceText:d}){const{palette:c}=t.useTheme(),u=s&&(null==i?void 0:i.gt(0))&&n;return G.jsxs(t.Box,{sx:Object.assign({typography:"body2",alignItems:"center",color:c.text.secondary,wordBreak:"break-word",textAlign:"right"},u?{"&:hover":{color:c.text.primary,cursor:"pointer"}}:{}),onClick:u?()=>n(i?i.toString():""):void 0,children:[null!=d?d:G.jsx(e.Trans,{id:"0QDjxt",message:"Balance:"})," ",l?G.jsx(t.RotatingIcon,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):G.jsxs(G.Fragment,{children:[r?Au({input:i,decimals:Math.min(o||4,4)}):"-",a&&i&&i.gt(0)&&n&&G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:6,color:(null==i?void 0:i.gt(0))?c.primary.main:c.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>n&&n(i?i.toString():""),children:G.jsx(e.Trans,{id:"CK1KXz",message:"Max"})})]})]})}const Nf=n.forwardRef((function({readOnly:e,sx:i,value:o,decimals:r,onChange:a,suffix:s,suffixGap:l=0,withClear:d,onFocus:c,placeholder:u,readonlyShowSuffix:p,typography:h},m){const g=t.useTheme(),x=n.useMemo((()=>s||(d&&o&&a?G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{a&&a("")},children:G.jsx(t.Box,{component:se.Error,sx:{width:12}})}):void 0)),[a,s,g.palette.text.primary,o,d]);return G.jsx(t.Input,{fullWidth:!0,value:o,readOnly:e,placeholder:u||"0.00",onFocus:c,onChange:e=>{const t=e.target.value,n=0===t.length?"":Lu(t,r);a&&a(n)},"data-testid":"number-input-wrapper",suffix:(!e||p)&&x,suffixGap:l,ref:m,sx:Object.assign({border:"none","& input":{fontSize:24,typography:h,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:h,color:"text.disabled"}}},i)})}));function Df({token:n,onClick:i,showChainLogo:o,readonly:r,showChainName:a}){var s,l;const d=t.useTheme(),c=(null==n?void 0:n.chainId)?ac.get(n.chainId):null,u=a&&!!c;return G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",gap:8,color:d.palette.text.primary,typography:u?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||i&&i(e)},"data-testid":Cc,children:[!!(null==n?void 0:n.address)&&G.jsx(Nh,{url:null==n?void 0:n.logoURI,address:null!==(s=null==n?void 0:n.address)&&void 0!==s?s:"",chainId:null==n?void 0:n.chainId,noShowChain:!o,width:32,height:32,chainSize:16,logoOffset:6,marginRight:0}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==n?void 0:n.address)?G.jsx(G.Fragment,{children:G.jsx(t.Box,{children:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&G.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!u&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[c.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]})}function Ff({chain:e,active:n,onClick:i}){return G.jsx(t.Tooltip,{title:e.name,placement:"top",onlyHover:!0,children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,cursor:"pointer",border:"1px solid"},n?{backgroundColor:"tabActive.main",borderColor:"tabActive.main",color:"primary.main"}:{borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:i,children:[G.jsx(t.Box,{component:e.logo,sx:{width:24,height:24}}),n&&G.jsx(t.Box,{sx:{typography:"body2",color:"primary.main"},children:e.name})]})},e.chainId)}var Uf=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},qf={"text/plain":"Text","text/html":"Url",default:"Text"};var Vf=function(e,t){var n,i,o,r,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=Uf(),r=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(i){if(i.stopPropagation(),t.format)if(i.preventDefault(),void 0===i.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=qf[t.format]||qf.default;window.clipboardData.setData(o,e)}else i.clipboardData.clearData(),i.clipboardData.setData(t.format,e);t.onCopy&&(i.preventDefault(),t.onCopy(i.clipboardData))})),document.body.appendChild(s),r.selectNodeContents(s),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),i=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(i,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l},Hf=H(Vf);function Wf({copyText:e,size:i,sx:r,componentProps:a,onClick:s,children:l}){var d;const[c,u]=n.useState(!1);return G.jsx(t.TooltipToast,{title:o.i18n._({id:"6V3Ea3",message:"Copied"}),open:c,onClose:()=>u(!1),arrow:!1,children:G.jsxs(t.Box,{...a,component:null!==(d=null==a?void 0:a.component)&&void 0!==d?d:t.ButtonBase,onClick:t=>{if(null==a?void 0:a.onClick)return a.onClick(t);t.stopPropagation(),e&&(Hf(e),u(!0)),s&&s()},sx:Object.assign({cursor:"pointer"},null==a?void 0:a.sx),children:[G.jsx(t.Box,{component:se.Copy,sx:Object.assign({width:i||"auto",height:i||"auto"},r)}),l]})})}function $f({truncate:e,address:n,disabledAddress:i,sx:o,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:s}){return i?G.jsx(t.Box,{children:e?tp(n):n}):G.jsx(t.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==o?void 0:o.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:G.jsxs(t.Box,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?tp(n):n,s?G.jsx(t.Box,{component:se.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function zf({address:e,truncate:n,showCopy:i,size:o="medium",iconSize:r,iconSpace:a,sx:s,iconDarkHover:l,disabledAddress:d,addressHoverColor:c,addressHoverShowIcon:u,customChainId:p,handleOpen:h,onAddressClick:m,onShareClick:g}){const x=t.useTheme(),{chainId:f}=cp(),y=null!=p?p:f,v="big"===o,b="medium"===o,C=l?t.HoverAddBackground:t.HoverOpacity,j=e=>{let t=e?12:8;return a&&(t=a),l&&(t-=3),t},w=v?"h5":b?"body1":"body2",k=(t,n)=>{h?h(t,n):y&&(t.stopPropagation(),window.open(np(y,e,"address")))},T=r||(b?16:14);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",typography:w,color:x.palette.text.primary,lineHeight:"normal"},s||{}),children:[G.jsx($f,{truncate:n,address:e,disabledAddress:d,sx:s,typography:w,handleOpen:null!=m?m:k,addressHoverColor:c,addressHoverShowIcon:u}),G.jsx(C,{sx:{display:"inline-flex",ml:j(b),cursor:"pointer"},onClick:e=>{k(e,"icon")},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:T,height:T}})}),i?G.jsx(Wf,{size:T,copyText:e,componentProps:{component:C,sx:{ml:j(b),display:"inline-flex",alignItems:"center",justifyContent:"center"}}}):null,!!g&&G.jsx(C,{sx:{display:"inline-flex",ml:j(b),cursor:"pointer"},onClick:e=>{g(e)},children:G.jsx(t.Box,{component:se.Share,sx:{width:T,height:T,ml:j(b)}})})]})}function Zf({token:e,disabled:i,style:o,balance:r,onSelect:a}){const s=t.useTheme(),l=n.useMemo((()=>r?Au({input:r,decimals:e.decimals}):""),[r,e.decimals]);return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",px:8,py:8,borderRadius:8,cursor:i?"auto":"pointer",opacity:i?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:o,onClick:()=>{i||a(e)},"data-testid":kc,children:[G.jsx(Nh,{token:e,width:32,height:32,noShowChain:!0,noBorder:!0}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[G.jsx(t.Box,{sx:{textAlign:"left",color:"text.primary",typography:"body2",fontWeight:600},children:e.symbol}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:500,maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),G.jsx(zf,{address:e.address,customChainId:e.chainId,showCopy:!0,truncate:!0,iconSpace:2,iconSize:12,size:"small",sx:{typography:"h6",color:"text.disabled"}})]})]}),G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:(null==r?void 0:r.gte(0))?l:G.jsx(t.Box,{component:se.Loading,width:18,sx:{"& path":{fill:s.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})}function Qf(){return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(t.Skeleton,{variant:"circular",width:32,sx:{mt:8}}),G.jsxs(t.Box,{sx:{ml:8,flex:"1 0 auto"},children:[G.jsx(t.Skeleton,{sx:{borderRadius:4},height:24}),G.jsx(t.Skeleton,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Gf({data:e,index:t,style:n}){const i=e.tokenList[t],o=e.getIsDisabled(i),r=e.getBalance(i);return G.jsx(Zf,{token:i,disabled:o,style:n,onSelect:e.onSelectToken,balance:r},i.address+i.chainId)}function Yf({fixedSizeHeight:e,tokenList:t,onSelectToken:i,getIsDisabled:o,getBalance:r}){const a=n.useMemo((()=>({onSelectToken:i,tokenList:t,getIsDisabled:o,getBalance:r})),[i,t,o,r]);return G.jsx(A.FixedSizeList,{height:e,width:"100%",itemSize:56,itemData:a,itemCount:t.length,children:Gf})}function Kf({chainId:e,value:i,onChange:s,occupiedAddrs:l,occupiedChainId:c,hiddenAddrs:u,showAddrs:p,visible:h,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,sx:v,filterBySupportTargetChain:b}){const{chainList:C,selectChainId:j,setSelectChainId:w}=function(e){const{crossChain:t,defaultChainId:i,IS_TEST_ENV:o}=X(),[r,a]=n.useState(e?Array.isArray(e)?e[0]?e[0].chainId:i:e.chainId:i),s=n.useMemo((()=>t?o?Array.from(ac.values()):Array.from(ac.values()).filter((e=>!e.isTestNet)):[]),[o,t]);return{chainList:s,selectChainId:r,setSelectChainId:a}}(i),{showTokenList:k,filter:T,setFilter:B,onSelectToken:I,popularTokenList:S,tokenInfoMap:A}=function({value:e,onChange:t,occupiedAddrs:i,occupiedChainId:o,hiddenAddrs:s,showAddrs:l,side:d,chainId:c,visible:u,defaultLoadBalance:p,multiple:h,filterBySupportTargetChain:m}){const[g,x]=n.useState(""),f=Lp(),y=null!=c?c:f,{tokenList:v,popularTokenList:b}=Tc(),C=n.useMemo((()=>new Set(s?s.map((e=>e.toLowerCase())):void 0)),[s]),j=n.useMemo((()=>l?new Set(l.map((e=>e.toLowerCase()))):void 0),[l]),w=n.useCallback((e=>{const t=new Set;return e.filter((e=>{if(e.chainId!==y)return!1;let n=!0;if(n=j?j.has(e.address.toLowerCase()):!C.has(e.address.toLowerCase()),n)if(d)n=!e.side||e.side===d;else{const i=`${e.chainId}-${e.address}`;n=!t.has(i),t.add(i)}return n}))}),[y,j,C,d]),k=n.useCallback((e=>{var t;if(e.chainId!==y)return!1;if(!m)return!0;if(null==o||o===y)return!0;if(!e.supportTargetChain)return!1;if(o!==r.ChainId.SOLANA)return!0;if(y!==r.ChainId.ZETACHAIN)return!1;const n=null===(t=null==i?void 0:i[0])||void 0===t?void 0:t.toLowerCase(),a=e.address.toLowerCase();if(!n)return!0;const s=r.basicTokenMap[o];switch(n){case s.address.toLowerCase():case s.wrappedTokenAddress.toLowerCase():return a==="0x4bC32034caCcc9B7e02536945eDbC286bACbA073".toLowerCase();case"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".toLowerCase():return a==="0x8344d6f84d26f998fa070BbEA6D2E15E359e2641".toLowerCase();case"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB".toLowerCase():return a==="0xEe9CC614D03e7Dbe994b514079f4914a605B4719".toLowerCase();default:return!0}}),[y,m,i,o]),T=n.useMemo((()=>w(v.filter(k))),[k,w,v]),B=n.useMemo((()=>w(b.filter(k))),[k,w,b]),I=n.useCallback((n=>{const r=n.address.toLowerCase(),a=!(o&&n.chainId!==o||!(null==i?void 0:i.some((e=>e.toLowerCase()===r))));if(Array.isArray(e)||h&&!e){const i=[...e],o=i.findIndex((e=>e.address.toLocaleLowerCase()===r));-1!==o?i.splice(o,1):i.push(n),t(i,a)}else t(n,a)}),[t,i,o]),S=Rh({chainId:y,tokenList:T,popularTokenList:B,value:e,visible:u,defaultLoadBalance:p}),A=n.useCallback((t=>{if(null===t)return null;const n=[];g?t.forEach((e=>{const t=_h(e,g,{matchAddress:!0});t&&n.push({sort:t,token:e})})):t.forEach((e=>{n.push({sort:0,token:e})}));const o=[];return n.sort(((t,n)=>{var o,r;const s=t.token,l=n.token;if(e)if(Array.isArray(e)){const t=e.map((e=>e.address)),n=t.indexOf(s.address),i=t.indexOf(l.address),o=-1!==n,r=-1!==i;if(o||r)return o&&n<i||!r?-1:1}else{if(s.address===e.address)return-1;if(l.address===e.address)return 1}if(null==i?void 0:i.includes(s.address))return-1;if(null==i?void 0:i.includes(l.address))return 1;const d=(null===(o=S.get(`${s.chainId}-${s.address}`))||void 0===o?void 0:o.balance)||new a(0),c=(null===(r=S.get(`${l.chainId}-${l.address}`))||void 0===r?void 0:r.balance)||new a(0),u=B.map((e=>e.address));return(null==u?void 0:u.includes(s.address))?-1:(null==u?void 0:u.includes(l.address))?1:d.eq(c)?t.sort!==n.sort?t.sort>n.sort?1:-1:s.symbol.localeCompare(l.symbol):d.gt(c)?-1:1})).some((e=>!!(g&&o.length>21)||(o.push(e.token),!1))),o}),[g,S,i,e,B]),E=n.useMemo((()=>A(T)||[]),[A,T]);return{filter:g,setFilter:x,showTokenList:E,onSelectToken:I,popularTokenList:B,tokenInfoMap:S}}({value:i,onChange:s,occupiedAddrs:l,occupiedChainId:c,hiddenAddrs:u,showAddrs:p,side:m,chainId:null!=e?e:j,visible:h,defaultLoadBalance:g,multiple:x,filterBySupportTargetChain:b}),E=n.useRef(null),O=n.useRef(null),[L,R]=n.useState(329);n.useEffect((()=>{if(E.current){const e=new ResizeObserver((e=>{for(const t of e)if(t.target===E.current){const e=t.contentRect.height-1;e>0&&R(e)}}));return e.observe(E.current),()=>{e.disconnect()}}}),[]);const M=d.useQuery({queryKey:["token-picker-searchOtherAddress",T],queryFn:()=>y?y(T):null,enabled:ep(T)&&!!y}),P=n.useCallback((e=>!!i&&(Array.isArray(i)?i.some((t=>t.address===e.address&&t.chainId===e.chainId)):i.address===e.address&&i.chainId===e.chainId)),[i]),_=n.useCallback((e=>{var t;return null===(t=A.get(`${e.chainId}-${e.address}`))||void 0===t?void 0:t.balance}),[A]);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",px:16,flexGrow:1,overflow:"hidden"},v),children:[G.jsx(t.SearchInput,{fullWidth:!0,height:48,value:T,onChange:e=>B(e.target.value),clearValue:()=>B(""),placeholder:null!=f?f:o.i18n._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&C.length>0&&G.jsx(t.Box,{ref:O,sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},children:C.map((e=>G.jsx(Ff,{chain:e,active:e.chainId===j,onClick:()=>{w(e.chainId)}},e.chainId)))}),G.jsx(t.Box,{sx:{pb:15,flexGrow:1},ref:E,children:k.length?G.jsx(Yf,{fixedSizeHeight:L,tokenList:k,onSelectToken:I,getIsDisabled:P,getBalance:_}):G.jsx(t.Box,{sx:{height:L,overflowY:"auto"},children:M.isLoading?G.jsx(Qf,{}):M.data?M.data:G.jsx(ee,{hasSearch:!0,sx:{mt:80}})})})]})}function Xf(t){const{height:n,TokenPickerDialog:i}=X(),{isMobile:o}=Bp();if(i)return G.jsx(i,{...t});const{open:r,title:a,value:s,onClose:l,occupiedAddrs:d,hiddenAddrs:c,showAddrs:u,occupiedChainId:p,onTokenChange:h,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,chainId:v,modal:b,filterBySupportTargetChain:C}=t;return G.jsx(Eh,{height:b?"80vh":n,open:r,onClose:l,title:null!=a?a:G.jsx(e.Trans,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:wc,modal:b,children:G.jsx(Kf,{value:s,visible:r,onChange:h,occupiedAddrs:d,occupiedChainId:p,hiddenAddrs:c,showAddrs:u,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,chainId:v,sx:b?{width:o?"100%":420,borderRadius:16}:void 0,filterBySupportTargetChain:C})})}const Jf=/^ST[0-9A-HJ-NP-Z]{39}$/,ey=/^0x[a-fA-F0-9]{64}$/,ty=/^[A-Za-z0-9_-]{48}$/;const ny=({chainId:e,open:i,onClose:o,inputToAddress:a,setInputToAddress:l})=>{const d=t.useTheme(),[c,u]=n.useState(a||""),p=function(e,t){return n.useMemo((()=>{if(!e)return!1;const n=ac.get(t);if(!n)return!1;try{if(n.isEVMChain)return!!su(e);if(n.isSolanaChain)return new s.PublicKey(e),!0;if(n.isBTCChain){if(Jf.test(e))return!0;try{return t===r.ChainId.BTC_SIGNET?F.address.toOutputScript(e,bg):F.address.toOutputScript(e,F.networks.bitcoin),!0}catch(e){return!1}}else{if(n.isSUIChain)return ey.test(e);if(n.isTONChain)return ty.test(e)}return!1}catch(e){return!1}}),[e,t])}(c,e),h=n.useMemo((()=>ac.get(e)),[e]);return G.jsx(Eh,{open:i,onClose:o,title:"Receive address",modal:!0,children:G.jsxs(t.Box,{sx:{minWidth:420,p:20,borderTop:`1px solid ${d.palette.border.main}`,display:"flex",flexDirection:"column",gap:20},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(t.Input,{fullWidth:!0,value:c,placeholder:`Enter ${null==h?void 0:h.name} address`,onChange:e=>{u(e.target.value)},height:48,suffix:c?G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{u("")},children:G.jsx(t.Box,{component:se.Error,sx:{width:12}})}):null}),!p&&c&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main"},children:"Invalid address"})]}),G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.contained,size:t.Button.Size.middle,disabled:!c||!p,onClick:()=>{l(c),o()},children:"Confirm"})]})})},iy=({token:e,enterAddressEnabled:i=!1,inputToAddress:o,setInputToAddress:r,account:a})=>{var s,l,d,c,u,p;const m=e.chainId,{open:g,disconnect:x,suiConnectModalOpen:f,setSuiConnectModalOpen:y}=cp(),[v,b]=n.useState(!1),C=n.useMemo((()=>ac.get(m)),[m]),j=G.jsxs("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("path",{d:"M12.001 6.3667C12.7373 6.3667 13.3339 6.9634 13.334 7.69971V9.03369H10.1338C9.54481 9.03383 9.06738 9.51108 9.06738 10.1001C9.06751 10.689 9.54488 11.1664 10.1338 11.1665H13.334V12.4995C13.334 13.2359 12.7374 13.8335 12.001 13.8335H4.00098C3.2646 13.8335 2.66797 13.2359 2.66797 12.4995V7.69971C2.66806 6.9634 3.26465 6.3667 4.00098 6.3667H12.001Z",fill:"currentColor"}),G.jsx("ellipse",{cx:"10.1349",cy:"10.1002",rx:"0.533334",ry:"0.533333",fill:"currentColor"}),G.jsx("path",{d:"M8.54243 3.63688C9.14948 3.36708 9.86253 3.5853 10.2146 4.14863L10.9341 5.29984H4.80078L8.54243 3.63688Z",fill:"currentColor"})]});return G.jsxs(G.Fragment,{children:[G.jsx(t.Popup,{triggerChildren:(null===(s=null==a?void 0:a.appKitAccount)||void 0===s?void 0:s.isConnected)?G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:[j,tp(null===(l=null==a?void 0:a.appKitAccount)||void 0===l?void 0:l.address),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:G.jsx("path",{d:"M12.667 6.93016L11.5703 5.8335L8.00033 9.39572L4.43033 5.8335L3.33366 6.93016L8.00033 11.5968L12.667 6.93016Z",fill:"currentColor",fillOpacity:"0.5"})})]}):G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:["Wallet address:",tp(null===(d=null==a?void 0:a.appKitAccount)||void 0===d?void 0:d.address),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:G.jsx("path",{d:"M3.33301 10.0698L4.42967 11.1665L7.99967 7.60428L11.5697 11.1665L12.6663 10.0698L7.99967 5.40317L3.33301 10.0698Z",fill:"currentColor",fillOpacity:"0.5"})})]}),titleSx:{display:"flex",flexDirection:"column",gap:8},children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsxs(t.Box,{sx:{typography:"h6",lineHeight:"16px",color:"text.secondary"},children:["Connected(",dp(m),")"]}),(null===(c=null==a?void 0:a.appKitAccount)||void 0===c?void 0:c.isConnected)?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,px:8,py:8,color:"text.primary",borderRadius:8,backgroundColor:"background.paperContrast",typography:"body2",lineHeight:"19px"},children:[o?j:C&&G.jsx(t.Box,{component:C.logo,sx:{width:16,height:16}}),tp(null===(u=null==a?void 0:a.appKitAccount)||void 0===u?void 0:u.address),G.jsx(t.Box,{sx:{ml:"auto",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onClick:()=>{o?r(null):x({namespace:null==a?void 0:a.namespace})},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 2.25H9.75V9.75H8.25V2.25ZM12.3075 4.94244L13.3725 3.87744C14.8275 5.11494 15.75 6.94494 15.75 8.99994C15.75 12.7274 12.7275 15.7499 9 15.7499C5.2725 15.7499 2.25 12.7274 2.25 8.99994C2.25 6.94494 3.1725 5.11494 4.6275 3.87744L5.685 4.93494C4.5075 5.89494 3.75 7.35744 3.75 8.99994C3.75 11.9024 6.0975 14.2499 9 14.2499C11.9025 14.2499 14.25 11.9024 14.25 8.99994C14.25 7.35744 13.4925 5.89494 12.3075 4.94244Z",fill:"#ED4A25"})})})]}):G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),"sui"===(null==a?void 0:a.namespace)?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},children:"Connect a new wallet"}),open:f,onOpenChange:e=>{console.log("walletconnectbtn isOpen",e),y(e)}}):G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{g({namespace:null==a?void 0:a.namespace})},children:"Connect a new wallet"})]}),i&&G.jsxs(G.Fragment,{children:[(null===(p=null==a?void 0:a.appKitAccount)||void 0===p?void 0:p.isConnected)&&G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{b(!0)},children:"Enter receive address"})]})]})}),v&&G.jsx(ny,{open:v,onClose:()=>b(!1),chainId:m,inputToAddress:o,setInputToAddress:r})]})};function oy({sx:i,amt:o,token:r,readOnly:a,showMaxBtn:s,canClickBalance:l,onMaxClick:d,fiatPriceTxt:c,failedReason:u,occupiedAddrs:p,occupiedChainId:h,showAddrs:m,onInputFocus:g,onTokenClick:x,onInputChange:f,onTokenChange:y,side:v,showChainLogo:b,showChainName:C,defaultLoadBalance:j,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:B,inputReadonlyTooltip:I,inputTypography:S,hideToken:A,checkLogBalance:E,notTokenPickerModal:O,enterAddressEnabled:L,inputToAddress:R,setInputToAddress:M,account:P,tokenQuery:_,filterBySupportTargetChain:N}){var D,F;const U=t.useTheme(),[q,V]=n.useState(!1),H=null!==(F=null!=w?w:null===(D=_.data)||void 0===D?void 0:D.balance)&&void 0!==F?F:null,{isTokenLoading:W}=Pf();let $=null!=k?k:_.isLoading;!$&&H&&(E?$=Object.entries(E).some((([e,t])=>W(e,t))):r&&($=W(r.address,H))),wp({tokenList:r?[r]:[]});const[z,Z]=n.useState(0),Q=n.useRef("");n.useEffect((()=>{o!==Q.current&&Z(0)}),[o]);const{gotoBuyToken:Y}=X();let K=Y&&H&&o&&H.lt(o);const J=!!f||!!I,ee={"& input":{typography:"h2",height:"44px",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{typography:"h2",height:"44px",color:"text.disabled"}},backgroundColor:"background.paper"};return G.jsxs(t.Box,{sx:Object.assign({minHeight:J?133:"auto",padding:U.spacing(20,20,24),overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:12,backgroundColor:U.palette.background.paper},i),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[A?G.jsx(t.Box,{}):G.jsx(Df,{token:r,showChainLogo:b,showChainName:C,onClick:()=>V(!0),readonly:!y}),r&&G.jsx(iy,{token:r,enterAddressEnabled:L,inputToAddress:R,setInputToAddress:M,account:P})]}),J&&(a&&I?G.jsx(t.TooltipToast,{title:I,arrow:!1,children:G.jsx(t.Box,{children:G.jsx(Nf,{value:o,readOnly:!0,withClear:!0,sx:Object.assign({mt:16},ee)})})}):G.jsx(Nf,{value:o,onFocus:g,onChange:f?e=>{f(e),Z(0)}:void 0,readOnly:a,withClear:!0,suffix:K?G.jsx(t.Button,{variant:t.Button.Variant.tag,backgroundColor:U.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{var t;e.stopPropagation(),(null===(t=null==P?void 0:P.appKitAccount)||void 0===t?void 0:t.address)&&(null==Y||Y({token:r,account:P.appKitAccount.address}))},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:S,sx:Object.assign({mt:16},ee)})),u&&G.jsx(t.Box,{sx:{mt:4,typography:"h6",lineHeight:"16px",fontWeight:500,color:U.palette.error.main},children:u}),G.jsxs(t.Box,{sx:{mt:B?9:4,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:U.palette.text.secondary},children:c}),G.jsx(_f,{balance:H,balanceText:T,onClick:a||!d&&!f?void 0:e=>{d?d(e):f&&f(e),0!==z&&1!==z&&(Z(1),Q.current=e)},showMaxBtn:s,canClickBalance:l,address:null==r?void 0:r.address,decimals:null==r?void 0:r.decimals,loading:$})]}),G.jsx(Xf,{value:r,open:q,side:v,chainId:void 0,showAddrs:m,occupiedAddrs:p,occupiedChainId:h,defaultLoadBalance:j,onClose:()=>{V(!1),x&&x()},onTokenChange:(e,t)=>{V(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Ih)},modal:!O,filterBySupportTargetChain:N})]})}function ry({rawRouteData:e,chainId:t}){const i=n.useMemo((()=>{if(!e)return[];try{const n=JSON.parse(e);return n.subRoute[0].midPath.map((e=>{const{fromToken:n,toToken:i,oneSplitTotalPart:o}=e,r=new Map;return e.poolDetails.forEach((e=>{var t;const n={poolPart:Vu({input:new a(e.poolPart).div(o)}),poolAddress:e.pool||null};r.has(e.poolName)?null===(t=r.get(e.poolName))||void 0===t||t.push(n):r.set(e.poolName,[n])})),{fromToken:n,toToken:i,chainId:t,poolDetails:r}}))}catch(e){console.error(e)}return[]}),[t,e]);return{routeData:i}}const ay=({routeInfo:i,toToken:o,fromToken:r})=>{const[a,s]=n.useState(!1),l=t.useTheme(),{isMobile:d}=Bp(),c=n.useMemo((()=>{const e=[{key:"from",logo:G.jsx(Nh,{token:r,noShowChain:!0,height:14,width:14,marginRight:0})}];return e.push({key:"to",logo:G.jsx(Nh,{token:o,noShowChain:!0,height:14,width:14,marginRight:0})}),e}),[r,o]),{routeData:u}=ry({rawRouteData:i,chainId:null==r?void 0:r.chainId});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{py:4,pl:8,pr:4,display:"flex",alignItems:"center",gap:4,borderRadius:12,backgroundColor:l.palette.background.tag,cursor:"pointer",typography:"h6",fontWeight:500,color:l.palette.text.secondary,"&:hover":{color:l.palette.text.primary}},onClick:()=>{s(!0)},children:[G.jsx(t.Box,{sx:{color:l.palette.text.primary},children:"Route:"}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:0},children:c.map(((e,t)=>G.jsx(n.Fragment,{children:e.logo},e.key)))}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.jsx("path",{d:"M2.91699 11.0833V7.58332H4.08366V9.91666H6.41699V11.0833H2.91699ZM9.91699 6.41666V4.08332H7.58366V2.91666H11.0837V6.41666H9.91699Z",fill:"currentColor"})})]}),G.jsx(Eh,{open:a,title:G.jsx(e.Trans,{id:"rT8e1f",message:"Route"}),onClose:()=>s(!1),modal:!0,children:G.jsx(t.Box,{sx:{minWidth:d?"100%":800,py:20,px:20,borderTop:`1px solid ${l.palette.border.main}`},children:d?G.jsx($h,{routeData:u,fromTokenRaw:r,toTokenRaw:o}):G.jsx(zh,{routeData:u,fromTokenRaw:r,toTokenRaw:o})})})]})};function sy({toToken:i,fromToken:o,priceStatus:r,pricePerToToken:a,pricePerFromToken:s,routeInfo:l}){const d=t.useTheme(),[c,u]=n.useState("-"),[p,h]=n.useState(null),[m,g]=n.useState("-"),[x,f]=n.useState(null);n.useEffect((()=>{u(null==o?void 0:o.symbol),g(null==i?void 0:i.symbol),h(a),f(s)}),[o,i,a,s]);const y=n.useCallback((()=>{u(m),g(c),h(x),f(p)}),[c,p,m,x]);return G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:{[Yp.Initial]:"-",[Yp.Loading]:G.jsxs(G.Fragment,{children:[G.jsx(t.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Yp.Failed]:G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}),[Yp.Success]:G.jsxs(t.Box,{sx:{width:"100%",mt:16,px:11,py:7,borderRadius:12,border:`solid 1px ${d.palette.border.main}`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"flex-start",gap:6},children:[G.jsxs(t.Box,{sx:{typography:"body2",lineHeight:"18px",color:d.palette.text.primary},children:["1 ",c," ",G.jsx("span",{style:{color:d.palette.text.secondary},children:"="})," ",Su({input:x,showDecimals:4})," ",m]}),G.jsx(t.Box,{component:t.ButtonBase,sx:{width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(t.Box,{sx:{width:16,color:"text.secondary"},onClick:y,component:se.Switch})})]}),o&&i&&G.jsx(ay,{routeInfo:l,fromToken:o,toToken:i})]})}[r]})}const ly=[.25,.5,.75,1];function dy({value:e,onChange:n,sx:i}){const o=t.useTheme(),r="light"===o.palette.mode,{isMobile:a}=Bp();return G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:a?10:14,gridTemplateColumns:`repeat(${ly.length}, 1fr)`},i),children:ly.map((i=>{const a=i===e;return G.jsxs(t.ButtonBase,{disabled:!n,sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:o.palette.text.primary,backgroundColor:t.alpha(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:t.alpha(o.palette.text.primary,.4)}},onClick:()=>{!a&&n&&n(i)},className:a?"selected":void 0,children:[100*i,"%"]},i)}))})}function cy(){return t.useTheme(),G.jsx(t.Box,{sx:{height:4,position:"relative",color:"text.secondary"},children:G.jsx(t.Box,{sx:{width:44,height:44,backgroundColor:"background.input",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",borderWidth:4,borderStyle:"solid",borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",color:"text.secondary"},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",fill:"none",children:G.jsx("path",{d:"M19.0142 13H13.0142V19H11.0142V13H5.01416V11H11.0142V5H13.0142V11H19.0142V13Z",fill:"currentColor"})})})})}function uy(){return G.jsx(t.Box,{sx:{position:"relative",height:4},children:G.jsx(t.Box,{sx:{width:44,height:44,borderRadius:22,backgroundColor:"background.input",borderWidth:4,borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%) rotate(90deg)",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:G.jsx(t.Box,{component:se.Plus})})})}function py({sx:i,inputSx:o,amt:r,token:a,readOnly:s,showMaxBtn:l,canClickBalance:c,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:g,onTokenClick:x,onInputChange:f,onTokenChange:y,side:v,showChainLogo:b,showChainName:C,defaultLoadBalance:j,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:B,inputReadonlyTooltip:I,inputTypography:S,chainId:A,hideToken:E,checkLogBalance:O,notTokenPickerModal:L}){var R,M;const{account:P}=cp(),_=t.useTheme(),[N,D]=n.useState(!1),F=d.useQuery(id.getFetchTokenQuery(null==a?void 0:a.chainId,null==a?void 0:a.address,P)),U=null!==(M=null!=w?w:null===(R=F.data)||void 0===R?void 0:R.balance)&&void 0!==M?M:null,{isTokenLoading:q}=Pf();let V=null!=k?k:F.isLoading;!V&&U&&(O?V=Object.entries(O).some((([e,t])=>q(e,t))):a&&(V=q(a.address,U))),wp({tokenList:a?[a]:[]});const[H,W]=n.useState(0),$=n.useRef("");n.useEffect((()=>{r!==$.current&&W(0)}),[r]);const{gotoBuyToken:z}=X();let Z=z&&U&&r&&U.lt(r);const Q=!!f||!!I;return G.jsxs(t.Box,{sx:Object.assign({minHeight:Q?133:"auto",padding:_.spacing(20,20,24),borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:_.palette.background.input},i),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[E?G.jsx(t.Box,{}):G.jsx(Df,{token:a,showChainLogo:b,showChainName:C,onClick:()=>D(!0),readonly:!y}),G.jsx(_f,{balance:U,balanceText:T,onClick:s||!u&&!f?void 0:e=>{u?u(e):f&&f(e),0!==H&&1!==H&&(W(1),$.current=e)},showMaxBtn:l,canClickBalance:c,address:null==a?void 0:a.address,decimals:null==a?void 0:a.decimals,loading:V})]}),Q&&(s&&I?G.jsx(t.TooltipToast,{title:I,arrow:!1,children:G.jsx(t.Box,{children:G.jsx(Nf,{value:r,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},o)})})}):G.jsx(Nf,{value:r,onFocus:g,onChange:f?e=>{f(e),W(0)}:void 0,readOnly:s,withClear:!0,suffix:Z?G.jsx(t.Button,{variant:t.Button.Variant.tag,backgroundColor:_.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==z||z({token:a,account:P})},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:S,sx:Object.assign({mt:12},o)})),!s&&B?G.jsx(dy,{sx:{mt:16},value:H,onChange:U&&void 0!==(null==a?void 0:a.decimals)?e=>{if(U&&(null==a?void 0:a.decimals))if(W(e),1===e){const e=U.toString();u?u(e):f&&f(e),$.current=e}else if(f){const t=U.multipliedBy(e).dp(a.decimals).toString();f(t),$.current=t}}:void 0}):"",void 0!==p?G.jsx(t.Box,{sx:{mt:B?9:0,typography:"h6",color:_.palette.text.secondary},children:p}):"",G.jsx(Xf,{value:a,open:N,side:v,chainId:A,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:j,onClose:()=>{D(!1),x&&x()},onTokenChange:(e,t)=>{D(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Ih)},modal:!L})]})}var hy;function my(){return my=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},my.apply(null,arguments)}const gy=e=>D.createElement("svg",my({width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),hy||(hy=D.createElement("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"}))),xy=e=>Object.keys(new Array(e+1).join(","));function fy(e){return null!=e&&""!==e}var yy;function vy(){return vy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},vy.apply(null,arguments)}const by=e=>D.createElement("svg",vy({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),yy||(yy=D.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},D.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),D.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),D.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),D.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),D.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),D.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),D.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),D.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),D.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),D.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),D.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),D.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),D.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),D.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),D.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),D.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),D.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),D.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),D.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},D.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),D.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),D.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),D.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),D.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),D.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),D.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),D.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),D.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),D.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),D.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),D.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))));function Cy(e){const{switchNetwork:t}=m.useAppKitNetwork();return n.useMemo((()=>{var n;if(!e)return;const i=null===(n=ac.get(e))||void 0===n?void 0:n.caipNetwork;return i?()=>t(i):void 0}),[e,t])}function jy({token:e,size:r="small",sx:a,children:s}){const[l,d]=n.useState(!1),{evmProvider:c,chainId:u}=cp(),p=Cy(e.chainId);return G.jsxs(t.Box,{sx:i.merge({margin:"0",border:"none",padding:"0",background:"none",cursor:"pointer","&:focus":{outline:"none"},"&:active":{outline:"none"},display:"inline-flex",alignItems:"center",justifyContent:"center"},a),onClick:t=>q(this,void 0,void 0,(function*(){if(t.stopPropagation(),void 0!==e.chainId&&e.chainId!==u&&p)return void(null==p||p());if(l)return;if(!c)return;d(!0);const{result:n,failMsg:i}=yield function(e,t){return q(this,void 0,void 0,(function*(){if(!e)return{result:!1};try{return{result:yield e.send("wallet_watchAsset",{type:"ERC20",options:{address:t.address,symbol:t.symbol,decimals:t.decimals,image:t.logoURI}})}}catch(e){return console.error(e),{result:!1,failMsg:null==e?void 0:e.message}}}))}(c,e);n?$x.getState().toast({message:o.i18n._({id:"DupCvC",message:"Added successful"}),type:"success",timeout:3e3}):$x.getState().toast({message:`${o.i18n._({id:"v4wgrk",message:"Failed to add"})}${i?`: ${i}`:""}`,type:"error"}),d(!1)})),component:"button",children:[G.jsx(t.Box,{component:by,sx:Object.assign({},"medium"===r?{width:16,height:16}:{width:14,height:14})}),s]})}function wy({tokens:e,width:n=24,height:i=24,gap:o=-4,cross:r,mr:a,chainId:s,showChainLogo:l,sx:d}){var c;const u=t.useTheme(),{onlyChainId:p}=X(),h=l&&!p,m=n/2;return!e||e.length<=0?G.jsx(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:G.jsx(t.Box,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:52,height:24,viewBox:"0 0 52 24",fill:"none",sx:{height:n,width:"auto",color:t.alpha(u.palette.text.primary,"light"===u.palette.mode?.11:.13),animation:"pulseKeyframe 2s ease-in-out 0.5s infinite","@keyframes pulseKeyframe":{"0%":{opacity:1},"50%":{opacity:.4},"100%":{opacity:1}}},children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3746 4.50813C19.1755 1.76008 15.7933 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24C15.7933 24 19.1755 22.2399 21.3746 19.4919C19.8788 17.3743 19 14.7898 19 12C19 9.21023 19.8788 6.62571 21.3746 4.50813ZM22 5.36441C24.1498 2.13102 27.8261 0 32 0C38.3911 0 43.6152 4.99623 43.9797 11.296C41.0986 12.163 39 14.8364 39 18C39 19.1371 39.2711 20.2108 39.7523 21.1602C37.6611 22.9317 34.9553 24 32 24C27.8261 24 24.1498 21.869 22 18.6356C20.7363 16.735 20 14.4535 20 12C20 9.54653 20.7363 7.26502 22 5.36441ZM52 18C52 21.3137 49.3137 24 46 24C43.5588 24 41.458 22.542 40.5211 20.4493C40.5042 20.4116 40.4876 20.3736 40.4715 20.3355C40.1679 19.6176 40 18.8284 40 18C40 15.3894 41.6673 13.1682 43.9952 12.3431C44.6221 12.1209 45.2969 12 46 12C49.3137 12 52 14.6863 52 18Z",fill:"currentColor"})})}):G.jsxs(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:[e.map(((e,i)=>G.jsx(t.Box,{sx:{display:"inline-flex",width:n,height:n,ml:i>0?o:0,borderRadius:"50%",backgroundColor:u.palette.background.default},children:"object"==typeof e?G.jsx(Nh,{address:e.address,width:n,height:n,chainId:s,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):G.jsx(t.Box,{component:"img",height:n,src:e})},i))),h&&ac.has(s)?G.jsx(t.Box,{component:null===(c=ac.get(s))||void 0===c?void 0:c.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:m,height:m}}):""]})}function ky({loading:e,empty:n,hasSearch:i,children:o,refetch:r}){return e?G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:xy(4).map(((e,n)=>G.jsx(t.Skeleton,{width:"100%",height:45},n)))}):r?G.jsx(re,{refresh:r,sx:{height:320}}):n?G.jsx(ee,{hasSearch:i,sx:{height:320}}):G.jsx(G.Fragment,{children:o})}function Ty({show:e,onClick:n,sx:i}){return G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({p:3,transform:e?"rotate(180deg)":"none",transition:"all 100ms",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},i),onClick:n,children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.58398 11.376C8.78189 11.6728 9.21811 11.6728 9.41603 11.376L12.4818 6.77735C12.7033 6.44507 12.4651 6 12.0657 6H5.93426C5.53491 6 5.29672 6.44507 5.51823 6.77735L8.58398 11.376Z",fill:"currentColor"})})})}function By({isMobile:e,statusText:n,statusColor:i,time:o,alphaColor:r,sx:a,children:s}){const l=t.useTheme(),d=t.alpha(i,.1),c=r?t.alpha(i,r):i;return G.jsxs(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:e?"center":"flex-start",gap:2,typography:"h6",color:"text.secondary"},a),children:[G.jsxs(t.Box,{sx:{padding:l.spacing(4,16),borderRadius:4,backgroundColor:d,color:c,textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center"},children:[n,s]}),o]})}function Iy({token:e,amount:n,canAddMetamask:i,title:o,linkVisible:r=!0}){var a,s;return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsxs(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:[o,": ",Au({input:n,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),i&&e&&G.jsx(jy,{token:e})]}),G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,typography:"h6",fontWeight:500,color:"text.secondary"},children:[e&&null!==(s=null===(a=ac.get(e.chainId))||void 0===a?void 0:a.name)&&void 0!==s?s:"-",r&&G.jsx(gy,{})]})]})}function Sy({token:e,amount:n,showChain:i,hideLogo:o,canAddMetamask:r,sx:a}){var s,l;let d="";i&&(d=null!==(l=null===(s=ac.get(e.chainId))||void 0===s?void 0:s.name)&&void 0!==l?l:"");const c=Au({input:n,decimals:e.decimals});return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:[!o&&G.jsx(Nh,{address:e.address,chainId:e.chainId,width:20,height:20}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:2},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,wordBreak:"break-word",typography:"body1",fontWeight:600},children:[`${c} ${e.symbol}`,r&&G.jsx(jy,{token:e})]}),!!d&&G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:2,typography:"h6",fontWeight:500,color:"text.secondary"},children:[d,G.jsx(gy,{})]})]})]})}function Ay({height:n=64,sx:i,onClick:o,hasMore:r,loading:a}){return t.useTheme(),r?G.jsx(t.ButtonBase,{sx:Object.assign({display:"flex",justifyContent:"center",alignItems:"center",height:n,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},i),onClick:o,children:a?G.jsx(t.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})}):null}function Ey(e){var{sx:n,children:i,hasMore:o,loadMore:r,loadMoreLoading:a}=e,s=U(e,["sx","children","hasMore","loadMore","loadMoreLoading"]);return G.jsxs(t.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",pt:12,px:20,pb:20},n),...s,children:[G.jsx(t.Box,{component:"table",sx:{width:"100%",borderCollapse:"separate",borderSpacing:"0 4px","& th":{py:12,px:24,typography:"body2",textAlign:"left",color:"text.secondary",backgroundColor:"background.paper"},"& th:first-of-type":{borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"& th:last-of-type":{borderTopRightRadius:"8px",borderBottomRightRadius:"8px"},"& td":{px:24,py:20,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,"&::after":{content:'""',display:"table-row",height:"0"}}},children:i}),!!r&&G.jsx(Ay,{loading:a,hasMore:o,onClick:r})]})}function Oy({fromToken:e,toToken:i,fromTokenPrice:o,toTokenPrice:r,sx:s,children:l}){const d=t.useTheme(),[c,u]=n.useState(!1),p=n.useMemo((()=>new a(o&&r?c?r:o:0)),[o,r,c]);return G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign({display:"flex",alignItems:"center",gap:8,color:"text.primary",typography:"body1",fontWeight:600,"&:hover>svg>path":{fill:d.palette.text.primary}},s),onClick:()=>u((e=>!e)),children:[G.jsxs(t.Box,{children:[l,"1 ",c?i.symbol:e.symbol," = ",p&&p.isFinite()?Au({input:p,decimals:c?e.decimals:i.decimals}):"-"," ",c?e.symbol:i.symbol]}),G.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"9",cy:"9",r:"9",fill:d.palette.border.main}),G.jsx("path",{d:"M9.5 6.5H4.5V8H13.5L9.5 4.25V6.5ZM8.25 13.75V11.5H13.5V10H4.5L8.25 13.75Z",fill:d.palette.text.secondary})]})]})}function Ly({showFold:e,isMobile:i,data:o}){const a=t.useTheme(),s=n.useMemo((()=>{var e,t,n,i,a,s,l,d,c,u,p,h,m,g;const x=[{title:"Total time spent",value:null!==(n=hh({start:null!==(e=o.startTime)&&void 0!==e?e:void 0,end:null!==(t=o.endTime)&&void 0!==t?t:void 0}))&&void 0!==n?n:"-"},{title:"Pay",value:G.jsx(zf,{address:null!==(i=o.fromAddress)&&void 0!==i?i:"",customChainId:null!==(a=o.routeData.fromChainId)&&void 0!==a?a:r.ChainId.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:"Receive",value:G.jsx(zf,{address:null!==(s=o.toAddress)&&void 0!==s?s:"",customChainId:null!==(l=o.routeData.toChainId)&&void 0!==l?l:r.ChainId.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:G.jsxs(G.Fragment,{children:["Fill Gas (Destination gas)",G.jsx(lf,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(u=null===(c=null===(d=o.fees)||void 0===d?void 0:d.find((e=>"destinationFee"===e.type)))||void 0===c?void 0:c.amountUSD)&&void 0!==u?u:"-"}`},{title:G.jsxs(G.Fragment,{children:["Bridge Fee",G.jsx(lf,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(m=null===(h=null===(p=o.fees)||void 0===p?void 0:p.find((e=>"platformFee"===e.type)))||void 0===h?void 0:h.amountUSD)&&void 0!==m?m:"-"}`}],f=null===(g=o.fees)||void 0===g?void 0:g.find((e=>"svmRentFee"===e.type));return f&&x.push({title:G.jsxs(G.Fragment,{children:["Rent",G.jsx(lf,{onlyHover:!0,title:"Rent (only first transaction of SPL token)",ml:0})]}),value:`$${f.amountUSD}`}),x}),[o.endTime,o.fees,o.fromAddress,o.routeData.fromChainId,o.routeData.toChainId,o.startTime,o.toAddress]);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:16,p:e?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${a.palette.background.skeleton} 0%, ${a.palette.background.skeleton} 100%), ${a.palette.background.paper}`,maxHeight:e?"auto":0,transition:"all 300ms",overflow:"hidden",[a.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px",gap:24}},children:[G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8,[a.breakpoints.up("tablet")]:{alignItems:"center",flexDirection:"row",gap:20}},children:s.map(((e,n)=>G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",[a.breakpoints.up("tablet")]:{flexBasis:"20%",flexGrow:1,flexShrink:1,flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:4}},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.secondary",typography:"h6"},children:e.title}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:e.value})]},n)))}),null!=o.routeData.fromChainId&&null!=o.routeData.toChainId&&G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.disabled"}}),G.jsx(hg,{route:{fromChainId:o.routeData.fromChainId,toChainId:o.routeData.toChainId,step:o.routeData.step},isMobile:i})]})]})}function Ry({data:e}){const n=t.useTheme(),i="refund_success"===e.subStatus,{isMobile:o}=Bp();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,[n.breakpoints.up("tablet")]:{gap:8}},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,color:i?n.palette.success.main:n.palette.text.disabled,borderRadius:"50%",backgroundColor:i?t.alpha(n.palette.success.main,.1):n.palette.background.tag,[n.breakpoints.up("tablet")]:{width:24,height:24}},children:i?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o?"12":"16",height:o?"12":"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{d:"M12.7601 3.55554L5.92598 10.3896L3.24005 7.71406L1.77783 9.17628L5.92598 13.3244L14.2223 5.02813L12.7601 3.55554Z",fill:"currentColor"})}):G.jsx(t.RotatingIcon,{sx:{width:12,color:n.palette.text.disabled,[n.breakpoints.up("tablet")]:{width:16}}})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,[n.breakpoints.up("tablet")]:{flexDirection:"column",alignItems:"flex-start"}},children:[e.refundChainId&&e.refundHash?G.jsx(zf,{address:e.refundHash,customChainId:e.refundChainId,showCopy:!1,truncate:!0,iconSpace:o?2:8,sx:{typography:"h6",[n.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},handleOpen:t=>{t.stopPropagation(),window.open(np(e.refundChainId,e.refundHash,"tx"))}}):G.jsx(t.Box,{sx:{typography:"h6",[n.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},children:"-"}),G.jsx(t.Box,{sx:{display:"none",[n.breakpoints.up("tablet")]:{display:"block",typography:"h6",color:n.palette.text.secondary}},children:i?"Refunded to this address.":"Refund in progress."}),i?null:G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.text.secondary,[n.breakpoints.up("tablet")]:{display:"none"}},children:"(Refund in progress.)"})]})]})}function My({data:e,isMobile:i,isErrorRefund:o}){var r,a,s,l,d,c,u,p,h,m;const g=t.useTheme(),{statusText:x,statusColor:f,statusAlphaColor:y}=n.useMemo((()=>{let t="Loading",n=g.palette.text.primary;switch(e.status){case"pending":t="Pending",n=g.palette.text.secondary;break;case"success":t="Succeeded",n=g.palette.success.main;break;case"failure_revert":t="Swap failed",n=g.palette.error.main;break;case"abort":t="Aborted",n=g.palette.error.main}return{statusText:t,statusColor:n,statusAlphaColor:undefined}}),[e.status,g.palette.error.main,g.palette.success.main,g.palette.text.primary,g.palette.text.secondary]),[v,b]=n.useState(!1),C=e.createdAt?gh(new Date(e.createdAt)):"-";return i?G.jsxs(t.Box,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{width:24,height:24,address:null===(r=e.fromToken)||void 0===r?void 0:r.address,chainId:null===(a=e.fromToken)||void 0===a?void 0:a.chainId}),G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),G.jsx(Nh,{width:24,height:24,address:null===(s=e.toToken)||void 0===s?void 0:s.address,chainId:null===(l=e.toToken)||void 0===l?void 0:l.chainId})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:G.jsx(By,{isMobile:!1,statusText:x,statusColor:f,alphaColor:y,children:"success"!==e.status&&G.jsx(lf,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:f}})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:g.palette.text.secondary},children:C})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(Iy,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay",linkVisible:!1}),G.jsx(Iy,{token:e.toToken,amount:e.toAmount,canAddMetamask:e.fromToken&&null!==(c=null===(d=ac.get(e.fromToken.chainId))||void 0===d?void 0:d.isEVMChain)&&void 0!==c&&c,title:"Receive",linkVisible:!1}),o&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:"Refunds TX:"}),G.jsx(Ry,{data:e})]})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${g.palette.border.main}`},children:G.jsx(Ty,{show:v,onClick:()=>b((e=>!e)),sx:{color:"text.secondary"}})})]})]}),G.jsx(Ly,{showFold:v,data:e,isMobile:i})]}):G.jsxs(G.Fragment,{children:[G.jsxs("tr",{children:[G.jsx(t.Box,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:v?0:8},children:e.fromToken&&G.jsx(Sy,{token:e.fromToken,amount:null!==(u=e.fromAmount)&&void 0!==u?u:"",showChain:!0})}),G.jsx("td",{children:e.toToken&&G.jsx(Sy,{token:e.toToken,amount:null!==(p=e.toAmount)&&void 0!==p?p:"",showChain:!0,canAddMetamask:null!==(m=null===(h=ac.get(e.toToken.chainId))||void 0===h?void 0:h.isEVMChain)&&void 0!==m&&m})}),G.jsx("td",{children:G.jsx(By,{isMobile:i,statusText:x,statusColor:f,alphaColor:y,time:C,children:"success"!==e.status&&G.jsx(lf,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:f}})})}),o?G.jsx("td",{children:G.jsx(Ry,{data:e})}):G.jsx("td",{children:e.fromToken&&e.toToken&&G.jsx(Oy,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),G.jsx(t.Box,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:v?0:8},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[!o&&"refund_success"===e.subStatus&&G.jsxs(G.Fragment,{children:[G.jsx(t.Tooltip,{title:"refund TX",placement:"top",onlyHover:!0,children:G.jsx(t.Box,{component:"a",href:e.refundChainId&&e.refundHash?np(e.refundChainId,e.refundHash,"tx"):void 0,target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})})}),G.jsx(t.Box,{sx:{height:16,width:"1px",backgroundColor:"border.main"}})]}),G.jsx(Ty,{show:v,onClick:()=>b((e=>!e))})]})})]}),G.jsx("tr",{children:G.jsx(t.Box,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:G.jsx(Ly,{showFold:v,data:e})})})]})}function Py({account:i,type:o}){const{isMobile:s}=Bp(),l=function({account:e,limit:t=5,type:i}){var o;const{tokenList:s}=Tc(),l=xp().getInfiniteQuery(r.SwapApi.graphql.cross_chain_swap_zetachain_orderList,"page",{where:{user:e,pageSize:t,type:i}}),c=d.useInfiniteQuery(Object.assign(Object.assign({},l),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_orderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),u=n.useMemo((()=>{var e,t,n,i;return null!==(i=null===(n=null===(t=null===(e=c.data)||void 0===e?void 0:e.pages)||void 0===t?void 0:t.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_orderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===n?void 0:n.map((e=>{const t=s.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.fromTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.fromChainId)})),n=s.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.toTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.toChainId)})),i=(null==e?void 0:e.fromAmount)&&t?new a(e.fromAmount).div(10**t.decimals).dp(t.decimals,a.ROUND_DOWN):null,o=(null==e?void 0:e.toAmount)&&n?new a(e.toAmount).div(10**n.decimals).dp(n.decimals,a.ROUND_DOWN):null;return{hash:null==e?void 0:e.fromHash,refundHash:null==e?void 0:e.refundHash,externalId:null==e?void 0:e.externalId,refundCridgeContract:void 0,refundChainId:(null==e?void 0:e.refundChainId)?Number(e.refundChainId):void 0,fromToken:t,toToken:n,fromAmount:i,toAmount:o,startTime:(null==e?void 0:e.startTime)?1e3*e.startTime:void 0,endTime:(null==e?void 0:e.endTime)?1e3*e.endTime:void 0,createdAt:null==e?void 0:e.createdAt,fromAddress:null==e?void 0:e.fromAddress,toAddress:null==e?void 0:e.toAddress,routeData:{fromChainId:null==e?void 0:e.fromChainId,toChainId:null==e?void 0:e.toChainId,step:Ic({omniPlan:null==e?void 0:e.omniPlan,tokenList:s})},fees:null==e?void 0:e.fees,status:null==e?void 0:e.status,subStatus:null==e?void 0:e.subStatus,transactionHash:null==e?void 0:e.fromHash,fromTokenPrice:i&&o&&t?o.div(i).dp(t.decimals,a.ROUND_DOWN).toString():null,toTokenPrice:i&&o&&n?i.div(o).dp(n.decimals,a.ROUND_DOWN).toString():null}})))&&void 0!==i?i:[]}),[null===(o=c.data)||void 0===o?void 0:o.pages,s]);return Object.assign(Object.assign({},c),{orderList:u})}({account:i,limit:s?10:5,type:o}),c="error_refund"===o;return G.jsx(ky,{isMobile:s,empty:!l.orderList.length,loading:l.isLoading,children:s?G.jsxs(t.Box,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[l.orderList.map((e=>G.jsx(My,{data:e,isMobile:s,isErrorRefund:c},e.hash))),G.jsx(Ay,{loading:l.isFetchingNextPage,onClick:l.fetchNextPage,hasMore:l.hasNextPage,height:68})]}):G.jsx(G.Fragment,{children:G.jsxs(Ey,{loadMoreLoading:l.isFetchingNextPage,loadMore:l.fetchNextPage,hasMore:l.hasNextPage,children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(e.Trans,{id:"4fL/V7",message:"Pay"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"uAQUqI",message:"Status"})}),c?G.jsx("th",{children:G.jsx(e.Trans,{id:"VmAUk7",message:"Refunds TX"})}):G.jsx("th",{children:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"})}),G.jsx(t.Box,{component:"th",sx:{width:c?110:140,textAlign:"right !important"},children:G.jsx(e.Trans,{id:"URmyfc",message:"Details"})})]})}),G.jsx("tbody",{children:l.orderList.map((e=>G.jsx(My,{data:e,isMobile:s,isErrorRefund:c},e.hash)))})]})})})}function _y({account:e,limit:t=5}){var n,i,o,a;const s=void 0,l=xp().getInfiniteQuery(r.SwapApi.graphql.cross_chain_swap_zetachain_swapOrderList,"page",{where:{userAddress:null==e?void 0:e.toLowerCase(),pageSize:t}}),c=d.useInfiniteQuery(Object.assign(Object.assign({},l),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_swapOrderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),u=null!==(a=null===(o=null===(i=null===(n=c.data)||void 0===n?void 0:n.pages)||void 0===i?void 0:i.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_swapOrderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===o?void 0:o.map((t=>{var n,i,o,r,a,l,d,c,u,p,h,m,g,x,f,y,v,b,C;let j="";const w=null!==(i=null===(n=null==t?void 0:t.extra)||void 0===n?void 0:n.safeTxHash)&&void 0!==i?i:void 0;return w&&s&&e&&(j=s(w,null==t?void 0:t.chainId,e)),{hash:null!==(o=null==t?void 0:t.hash)&&void 0!==o?o:"",fromToken:sp({address:null!==(r=null==t?void 0:t.fromTokenAddress)&&void 0!==r?r:"",decimals:null==t?void 0:t.fromTokenDecimals,symbol:null!==(a=null==t?void 0:t.fromTokenSymbol)&&void 0!==a?a:"",name:null!==(l=null==t?void 0:t.fromTokenSymbol)&&void 0!==l?l:""},null==t?void 0:t.chainId),toToken:sp({address:null!==(d=null==t?void 0:t.toTokenAddress)&&void 0!==d?d:"",decimals:null==t?void 0:t.toTokenDecimals,symbol:null!==(c=null==t?void 0:t.toTokenSymbol)&&void 0!==c?c:"",name:null!==(u=null==t?void 0:t.toTokenSymbol)&&void 0!==u?u:""},null==t?void 0:t.chainId),fromAmount:null!==(p=null==t?void 0:t.fromAmount)&&void 0!==p?p:"",toAmount:null!==(h=null==t?void 0:t.toAmount)&&void 0!==h?h:"",minAmount:null!==(m=null==t?void 0:t.minAmount)&&void 0!==m?m:"",fromTokenPrice:null!==(g=null==t?void 0:t.fromTokenPrice)&&void 0!==g?g:"",toTokenPrice:null!==(x=null==t?void 0:t.toTokenPrice)&&void 0!==x?x:"",createdAt:null!==(f=null==t?void 0:t.createdAt)&&void 0!==f?f:"",routeData:null!==(v=null===(y=null==t?void 0:t.extra)||void 0===y?void 0:y.routeData)&&void 0!==v?v:"",safeTxHash:w,safeTxUrl:j,status:null!==(b=null==t?void 0:t.status)&&void 0!==b?b:"",transactionHash:null===(C=null==t?void 0:t.extra)||void 0===C?void 0:C.transactionHash}})))&&void 0!==a?a:[];return Object.assign(Object.assign({},c),{orderList:u})}var Ny,Dy;function Fy({showFold:i,isMobile:o,data:r}){const s=t.useTheme(),{routeData:l}=ry({rawRouteData:r.routeData,chainId:r.fromToken.chainId}),d=n.useMemo((()=>r.fromTokenPrice?new a(r.fromTokenPrice):new a(0)),[r.fromTokenPrice]);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:24,p:i?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${s.palette.background.skeleton} 0%, ${s.palette.background.skeleton} 100%), ${s.palette.background.paper}`,maxHeight:i?400:0,transition:"all 300ms",overflow:"hidden",[s.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"h6",color:s.palette.text.secondary},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),o&&G.jsxs(t.Box,{children:["Rate: 1 ",r.fromToken.symbol,"=",d&&d.isFinite()?Au({input:d,decimals:r.toToken.decimals}):"-"," ",r.toToken.symbol]})]}),o?G.jsx($h,{routeData:l,fromTokenRaw:r.fromToken,toTokenRaw:r.toToken}):G.jsx(zh,{routeData:l,fromTokenRaw:r.fromToken,toTokenRaw:r.toToken})]})}function Uy({data:e,isMobile:i}){var r,a,s,l,d,c;const u=t.useTheme(),[p,h]=n.useState(!1),{statusText:m,statusColor:g,statusAlphaColor:x}=function({status:e,stateTextMap:n}){let i=n?n[e]:e;const r=t.useTheme();let a,s=o.i18n._({id:"yQE2r9",message:"Loading"}),l=r.palette.text.primary;switch(e){case Ny.Warning:s=o.i18n._({id:"GGWsTU",message:"Canceled"}),a=.1;break;case Ny.Failed:s=o.i18n._({id:"7Bj3x9",message:"Failed"}),l=r.palette.error.main;break;case Ny.Success:s=o.i18n._({id:"KAbcm2",message:"Succeeded"}),l=r.palette.success.main}return{state:i,statusText:s,statusColor:l,statusAlphaColor:a}}({status:e.status}),f=gh(new Date(e.createdAt));return i?G.jsxs(t.Box,{sx:{backgroundColor:u.palette.background.paper,borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},onClick:()=>window.open(np(e.fromToken.chainId,e.hash,"tx"),"_blank"),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{width:24,height:24,address:e.fromToken.address,chainId:e.fromToken.chainId}),G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),G.jsx(Nh,{width:24,height:24,address:e.toToken.address,chainId:e.toToken.chainId})]}),G.jsx(By,{isMobile:!1,statusText:m,statusColor:g,alphaColor:x})]}),G.jsx(t.Box,{sx:{typography:"h6",color:u.palette.text.secondary},children:f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(Iy,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay"}),G.jsx(Iy,{token:e.toToken,amount:e.toAmount,canAddMetamask:null!==(a=null===(r=ac.get(e.fromToken.chainId))||void 0===r?void 0:r.isEVMChain)&&void 0!==a&&a,title:"Receive"})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${u.palette.border.main}`},children:G.jsx(Ty,{show:p,onClick:()=>h((e=>!e)),sx:{color:"text.secondary"}})})]})]}),G.jsx(Fy,{showFold:p,data:e,isMobile:!0})]}):G.jsxs(G.Fragment,{children:[G.jsxs("tr",{children:[G.jsx(t.Box,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:p?0:8},children:G.jsx(Sy,{token:e.fromToken,amount:null!==(s=e.fromAmount)&&void 0!==s?s:"",showChain:!0})}),G.jsx("td",{children:G.jsx(Sy,{token:e.toToken,amount:null!==(l=e.toAmount)&&void 0!==l?l:"",showChain:!0,canAddMetamask:null!==(c=null===(d=ac.get(e.toToken.chainId))||void 0===d?void 0:d.isEVMChain)&&void 0!==c&&c})}),G.jsx("td",{children:G.jsx(By,{isMobile:i,statusText:m,statusColor:g,alphaColor:x,time:f})}),G.jsx("td",{children:G.jsx(Oy,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),G.jsx(t.Box,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:p?0:8},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{component:"a",href:np(e.fromToken.chainId,e.hash,"tx"),target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})}),G.jsx(t.Box,{sx:{height:16,width:"1px",backgroundColor:"border.main"}}),G.jsx(Ty,{show:p,onClick:()=>h((e=>!e))})]})})]}),G.jsx("tr",{children:G.jsx(t.Box,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:G.jsx(Fy,{showFold:p,data:e})})})]})}function qy({account:n}){const{isMobile:i}=Bp(),o=_y({account:n,limit:i?10:5});return G.jsx(ky,{isMobile:i,empty:!o.orderList.length,loading:o.isLoading,children:i?G.jsxs(t.Box,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[o.orderList.map((e=>G.jsx(Uy,{data:e,isMobile:i},e.hash))),G.jsx(Ay,{loading:o.isFetchingNextPage,onClick:o.fetchNextPage,hasMore:o.hasNextPage,height:68})]}):G.jsx(G.Fragment,{children:G.jsxs(Ey,{loadMoreLoading:o.isFetchingNextPage,loadMore:o.fetchNextPage,hasMore:o.hasNextPage,children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:G.jsx(e.Trans,{id:"4fL/V7",message:"Pay"})})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"uAQUqI",message:"Status"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"})}),G.jsx(t.Box,{component:"th",sx:{width:140},children:G.jsx(e.Trans,{id:"URmyfc",message:"Details"})})]})}),G.jsx("tbody",{children:o.orderList.map((e=>G.jsx(Uy,{data:e,isMobile:i},e.hash)))})]})})})}function Vy(e){var{sx:n}=e,i=U(e,["sx"]);return G.jsx(t.TabPanel,{...i,sx:Object.assign(Object.assign({},n),{display:"flex",flexDirection:"column",overflow:"hidden"})})}!function(e){e.Running="pending",e.Success="success",e.Failed="failed",e.Warning="reset"}(Ny||(Ny={})),function(e){e.sameChain="same-chain",e.crossChain="cross-chain",e.errorRefunds="error-refunds"}(Dy||(Dy={}));const Hy="widget-module-container",Wy=n.forwardRef((function(e,n){var{sx:i}=e,o=U(e,["sx"]);const{isMobile:r}=Bp();return G.jsx(t.Box,{className:Hy,ref:n,sx:Object.assign(Object.assign({flex:1,backgroundColor:"transparent"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:0,height:"auto"}),i),...o})}));var $y;exports.PageType=void 0,($y=exports.PageType||(exports.PageType={})).Pool="pool",$y.PoolDetail="poolDetail",$y.CurvePoolDetail="curvePoolDetail",$y.CreatePool="createPool",$y.ModifyPool="modifyPool",$y.MiningList="miningList",$y.MiningDetail="miningDetail",$y.createPoolAMMV2="createPoolAMMV2",$y.createPoolAMMV3="createPoolAMMV3";const zy=c.create(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const i=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:exports.PageType.Pool}];return{page:t,historyList:i}}))},back:()=>{e((e=>{const t=e.historyList.length;if(!t)return"undefined"!=typeof window&&window.history&&history.back(),e;const n=[...e.historyList];return{page:n.splice(t-1,1)[0],historyList:n}}))}})));function Zy({title:e,descList:n,linkTo:i,sx:o}){const r=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({backgroundColor:r.palette.background.paper,backdropFilter:"blur(4px)",borderRadius:12,padding:24,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24},o),children:[G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body1",fontWeight:500,lineHeight:"24px"},children:e}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"stretch",gap:24},children:n.map(((e,n)=>G.jsxs(t.Box,{sx:{flex:1,padding:16,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:8,borderWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{color:r.palette.primary.contrastText,typography:"h6",fontWeight:600,lineHeight:"20px",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:r.palette.primary.main},children:n+1}),G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:500,lineHeight:"24px"},children:e.title})]}),G.jsx(t.Box,{sx:{color:r.palette.text.secondary,typography:"h6",fontWeight:500,lineHeight:"18px"},children:e.desc})]},n)))}),G.jsx(t.Box,{component:"a",href:i,target:"_blank",rel:"noopener noreferrer",sx:{px:24,py:12,borderRadius:8,backgroundColor:r.palette.background.tag,color:r.palette.text.primary,typography:"body2",fontWeight:700,lineHeight:"21px",textDecoration:"none"},children:"Read Docs"})]})}const Qy=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Gy({disabled:e,value:n,onChange:i,sx:o}){return G.jsxs(t.Box,{sx:Object.assign({p:20,backgroundColor:"background.cardInput",borderRadius:12},o),children:[G.jsx(Nf,{value:String(n),onChange:e=>i(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:G.jsx(t.Box,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,backgroundColor:"background.cardInput","& input":{pl:0,typography:"h1"}}}),G.jsx(t.Box,{sx:{mt:20},children:G.jsx(t.Slider,{marks:Qy,step:1,disabled:e,value:n,onChange:(e,t)=>i(t)})})]})}function Yy({active:n,sx:i,onClick:o}){const r=t.useTheme(),a="light"===r.palette.mode;let s=r.palette.primary.main,l="transparent";return n&&(s=r.palette.primary.contrastText,l=t.alpha(r.palette.primary.main,.8)),G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({typography:"body2",p:n?r.spacing(8,20,9):r.spacing(7,19,8),minWidth:79,border:n?void 0:`1px solid ${s}`,color:s,backgroundColor:l,borderRadius:8,fontWeight:600,"&:hover":{color:n?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:n?r.palette.primary.main:a?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},i),onClick:o,children:G.jsx(e.Trans,{id:"R9Khdg",message:"Auto"})})}const Ky="auto",Xy="0.1",Jy="0.5",ev="0.5",tv=.01,nv=({address:e,type:t})=>{const[i,o]=n.useState(Ky),r=n.useMemo((()=>i===Ky?"AMMV3"===t?new a(ev).div(100).toNumber():"AMMV2"===t?new a(Jy).div(100).toNumber():new a(Xy).div(100).toNumber():i),[i,t]);return{slipper:i,setSlipper:o,slipperValue:r,resetSlipper:()=>{o(Ky)}}};function iv({type:i,disabled:o,value:r,onChange:s,sx:l}){const d=t.useTheme(),c=r===Ky,[u,p]=n.useState(c?"":new a(r).times(100).toNumber()),h="AMMV3"==i?ev:"AMMV2"==i?Jy:Xy;return G.jsx(t.Tooltip,{disabled:o,onlyClick:!0,title:G.jsxs(t.Box,{sx:{backgroundColor:d.palette.background.paper,padding:d.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[c?h:r&&new a(r).times(100).toNumber(),"%"]})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",margin:d.spacing(16,0,0,0)},children:[G.jsx(Yy,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{p(""),s(Ky)},active:c}),G.jsx(t.Input,{placeholder:String(h),value:u,onChange:e=>{const{value:t}=e.target;p(t),s(t?new a(t).div(100).toNumber():Ky)},onBlur:()=>{(!c&&new a(r).gt(.1)||new a(r).lte(0))&&(p(10),s(.1))},suffix:G.jsx(t.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(t.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:d.spacing(0,0,0,"auto"),p:d.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},l),children:G.jsx(t.Box,{component:se.Setting,sx:{width:18,height:18,"& path:last-child":{fill:d.palette.text.primary}}})})})}const ov=50;var rv,av,sv;function lv(i){var r,a,s,{chainId:l,includeButton:d}=i,c=U(i,["chainId","includeButton"]);const{chainId:u,getAppKitAccountByChainId:p,open:h}=cp(),[m,g]=n.useState(!1),x=Cy(l),f=void 0!==u&&void 0!==l&&u!==l,y=p(l);return!(null==y?void 0:y.appKitAccount.address)||m||void 0===u||l&&l!==u?G.jsx(G.Fragment,{children:G.jsx(t.Button,{...c,isLoading:m,onClick:()=>q(this,void 0,void 0,(function*(){if(f)return x?(g(!0),yield x(),void g(!1)):void 0;g(!0),h({namespace:null==y?void 0:y.namespace}),g(!1)})),children:m?G.jsx(e.Trans,{id:"J28zul",message:"Connecting..."}):f&&l?o.i18n._({id:"1+P9RR",message:"Switch to {0}",values:{0:null!==(s=null===(a=ac.get(l))||void 0===a?void 0:a.name)&&void 0!==s?s:"unknown"}}):G.jsx(e.Trans,{id:"r7ScnQ",message:"Connect to a wallet"})})}):d?G.jsx(G.Fragment,{children:null!==(r=c.children)&&void 0!==r?r:null}):G.jsx(t.Button,{...c})}!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(rv||(rv={})),function(e){e.CURRENCY_A="CURRENCY_A",e.CURRENCY_B="CURRENCY_B"}(av||(av={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(sv||(sv={}));const dv={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},cv=({children:e,sx:n})=>(t.useTheme(),G.jsx(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},n),children:e})),uv=({children:e,sx:n})=>{const i=t.useTheme();return G.jsx(cv,{sx:Object.assign(Object.assign({},n),{backgroundColor:i.palette.background.paperContrast}),children:e})},pv=({children:e})=>{const n=t.useTheme();return G.jsxs(t.Box,{sx:{p:8,borderRadius:8,backgroundColor:t.alpha(n.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 16.125L9 1.875L17.25 16.125H0.75ZM14.6475 14.625L8.99998 4.86749L3.35247 14.625H14.6475ZM9.75004 12.375H8.25003V13.875H9.75004V12.375ZM8.25003 7.875H9.75004V10.875H8.25003V7.875Z",fill:n.palette.warning.main})}),G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.warning.main,textAlign:"left"},children:e})]})};function hv({gap:e,flex:n,children:i,style:o}){return G.jsx(t.Box,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&dv[e]||e},n&&{flex:n}),{width:"100%",alignItems:"center"}),o),children:i})}function mv({gap:e,justify:n,grow:i,children:o,style:r}){return G.jsx(t.Box,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&dv[e]||e,justifyItems:n,flexGrow:i&&1},r),children:o})}function gv({gap:e,children:n,sx:i}){return G.jsx(t.Box,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&dv[e]||e},i),children:n})}function xv({children:e,style:t}){return G.jsx(gv,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function fv({gap:e,justify:t,children:n,sx:i}){return G.jsx(gv,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},i),children:n})}function yv({children:e,disabled:t,sx:n}){return G.jsx(gv,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const vv=({chainId:n,approvalA:i,approvalB:r,parsedAmounts:a,isValid:s,depositADisabled:l,depositBDisabled:d,errorMessage:c,setShowConfirm:u})=>{var p,h;const m=i.needApprove&&!!a[av.CURRENCY_A]||i.isApproving,g=r.needApprove&&!!a[av.CURRENCY_B]||r.isApproving;return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:n,children:G.jsxs(mv,{gap:"md",style:{width:"100%"},children:[(m||g)&&s&&G.jsxs(t.Box,{sx:{width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"space-between",gap:8},children:[m&&G.jsx(t.Button,{size:t.Button.Size.big,isLoading:i.isApproving,onClick:i.submitApprove,disabled:i.insufficientBalance,width:g?"50%":"100%",children:i.isApproving?G.jsx(e.Trans,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(p=i.token)||void 0===p?void 0:p.symbol}}):i.approveTitle}),g&&G.jsx(t.Button,{size:t.Button.Size.big,isLoading:r.isApproving,onClick:r.submitApprove,disabled:r.insufficientBalance,width:m?"50%":"100%",children:r.isApproving?G.jsx(e.Trans,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(h=r.token)||void 0===h?void 0:h.symbol}}):r.approveTitle})]}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:()=>{u(!0)},disabled:!s||i.needApprove&&!l||r.needApprove&&!d,danger:!s&&!!a[av.CURRENCY_A]&&!!a[av.CURRENCY_B],children:c||o.i18n._({id:"rdUucN",message:"Preview"})})]})})},bv=({chainId:e,disabled:n,isLoading:i,onConfirm:r})=>G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:r,disabled:n,isLoading:i,children:o.i18n._({id:"h5pjuM",message:"Collect fees"})})});function Cv(e){const t=n.useRef();return n.useEffect((()=>{t.current=e})),t.current}const jv=[.25,.5,.75,1];function wv({currentValue:e,onClick:i,sx:o}){const r=t.useTheme(),a="light"===r.palette.mode,{isMobile:s}=Bp(),[l,d]=n.useState(null),c=n.useRef(0);n.useEffect((()=>{e?(c.current+=1,c.current>=2&&(d(null),c.current=0)):d(null)}),[e]);const u=Cv(e);return n.useEffect((()=>{u===e&&1===l&&(c.current=1)}),[e,u,l]),G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${jv.length}, 1fr)`},o),children:jv.map((e=>{const n=e===l;return G.jsxs(t.ButtonBase,{sx:{typography:"h6",borderRadius:4,padding:r.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:r.palette.text.primary,backgroundColor:t.alpha(r.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:a?r.palette.primary.main:t.alpha(r.palette.text.primary,.4)}},onClick:()=>{n||(c.current=0,d(e),i(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const kv=({value:i,onUserInput:r,maxAmount:a,balance:s,currency:l,locked:d})=>{var c,u;const p=t.useTheme(),h=n.useCallback((e=>{if(!a||!l)return;const t=a.toExact().multipliedBy(e).dp(l.decimals).toString();r(t)}),[l,a,r]),m=n.useMemo((()=>s?Au({input:s.toExact(),decimals:null==l?void 0:l.decimals}):"-"),[null==l?void 0:l.decimals,s]);return G.jsxs(t.Box,{sx:{pt:20,pb:20,px:20,borderRadius:16,backgroundColor:p.palette.background.cardInput},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==l?void 0:l.address)&&G.jsx(Nh,{address:null!==(c=null==l?void 0:l.address)&&void 0!==c?c:"",chainId:null==l?void 0:l.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:(null==l?void 0:l.address)?G.jsx(t.Box,{children:null!==(u=null==l?void 0:l.symbol)&&void 0!==u?u:"-"}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),G.jsxs(t.Box,{component:t.ButtonBase,sx:{color:p.palette.text.secondary,"&:hover":{color:p.palette.text.primary},cursor:"pointer",display:"flex",flexWrap:"wrap",justifyContent:"flex-end",typography:"body2"},onClick:()=>{h(1)},children:[G.jsxs(t.Box,{sx:{wordBreak:"keep-all"},children:[o.i18n._({id:"fsBGk0",message:"Balance"}),": "]}),G.jsx(t.Box,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),G.jsx(Nf,{sx:{mt:4,backgroundColor:p.palette.background.cardInput},suffix:void 0,value:i,onChange:r,readOnly:d,withClear:!d}),d?null:G.jsx(wv,{sx:{mt:20,mb:0},onClick:h,currentValue:i})]})},Tv={},Bv={};var Iv,Sv;Object.values(r.ChainId).filter((e=>"number"==typeof e)).map((e=>{const t=u.getUniswapV3FactoryContractAddressByChainId(e),n=u.getNonfungiblePositionManagerContractAddressByChainId(e);t&&(Tv[e]=t),n&&(Bv[e]=n)})),r.ChainId.MAINNET,r.ChainId.ARBITRUM_ONE,r.ChainId.SEPOLIA,r.ChainId.TAIKO,function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(Iv||(Iv={})),function(e){e[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP"}(Sv||(Sv={}));const Av=E.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ev={[Sv.ROUND_DOWN]:a.ROUND_DOWN,[Sv.ROUND_HALF_UP]:a.ROUND_HALF_UP,[Sv.ROUND_UP]:a.ROUND_UP},Ov={[Sv.ROUND_DOWN]:a.ROUND_DOWN,[Sv.ROUND_HALF_UP]:a.ROUND_HALF_UP,[Sv.ROUND_UP]:a.ROUND_UP};class Lv{constructor(e,t=E.BigInt(1)){this.numerator=E.BigInt(e),this.denominator=E.BigInt(t)}static tryParseFraction(e){if(e instanceof E||"number"==typeof e||"string"==typeof e)return new Lv(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return E.divide(this.numerator,this.denominator)}get remainder(){return new Lv(E.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new Lv(this.denominator,this.numerator)}add(e){const t=Lv.tryParseFraction(e);return E.equal(this.denominator,t.denominator)?new Lv(E.add(this.numerator,t.numerator),this.denominator):new Lv(E.add(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator)),E.multiply(this.denominator,t.denominator))}subtract(e){const t=Lv.tryParseFraction(e);return E.equal(this.denominator,t.denominator)?new Lv(E.subtract(this.numerator,t.numerator),this.denominator):new Lv(E.subtract(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator)),E.multiply(this.denominator,t.denominator))}lessThan(e){const t=Lv.tryParseFraction(e);return E.lessThan(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}equalTo(e){const t=Lv.tryParseFraction(e);return E.equal(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}greaterThan(e){const t=Lv.tryParseFraction(e);return E.greaterThan(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}multiply(e){const t=Lv.tryParseFraction(e);return new Lv(E.multiply(this.numerator,t.numerator),E.multiply(this.denominator,t.denominator))}divide(e){const t=Lv.tryParseFraction(e);return new Lv(E.multiply(this.numerator,t.denominator),E.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=Sv.ROUND_HALF_UP){O(Number.isInteger(e),`${e} is not an integer.`),O(e>0,`${e} is not positive.`);const i=Ev[n],o=new a(this.numerator.toString()).div(this.denominator.toString()).precision(e,i);return o.toFormat(o.decimalPlaces(),i,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=Sv.ROUND_HALF_UP){O(Number.isInteger(e),`${e} is not an integer.`),O(e>=0,`${e} is negative.`);const i=Ov[n];return new a(this.numerator.toString()).decimalPlaces(e,i).div(this.denominator.toString()).toFormat(e,i,t)}get asFraction(){return new Lv(this.numerator,this.denominator)}}class Rv extends Lv{static fromRawAmount(e,t){return new Rv(e,t)}static fromFractionalAmount(e,t,n){return new Rv(e,t,n)}constructor(e,t,n){super(t,n),O(E.lessThanOrEqual(this.quotient,Av),"AMOUNT"),this.currency=e,this.decimalScale=E.exponentiate(E.BigInt(10),E.BigInt(e.decimals))}add(e){O(this.currency.equals(e.currency),"CURRENCY");const t=super.add(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}subtract(e){O(this.currency.equals(e.currency),"CURRENCY");const t=super.subtract(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}multiply(e){const t=super.multiply(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}divide(e){const t=super.divide(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}toSignificant(e=6,t,n=Sv.ROUND_DOWN){return super.divide(this.decimalScale).toSignificant(e,t,n)}toFixed(e=this.currency.decimals,t,n=Sv.ROUND_DOWN){return O(e<=this.currency.decimals,"DECIMALS"),super.divide(this.decimalScale).toFixed(e,t,n)}toExact(){return new a(this.quotient.toString()).div(this.decimalScale.toString())}get wrapped(){return this.currency.isToken?this:Rv.fromFractionalAmount(this.currency.wrapped,this.numerator,this.denominator)}}const Mv=new Lv(E.BigInt(100));function Pv(e){return new _v(e.numerator,e.denominator)}class _v extends Lv{constructor(){super(...arguments),this.isPercent=!0}add(e){return Pv(super.add(e))}subtract(e){return Pv(super.subtract(e))}multiply(e){return Pv(super.multiply(e))}divide(e){return Pv(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(Mv).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(Mv).toFixed(e,t,n)}}class Nv extends Lv{constructor(...e){let t,n,i,o;if(4===e.length)[t,n,i,o]=e;else{const r=e[0].quoteAmount.divide(e[0].baseAmount);[t,n,i,o]=[e[0].baseAmount.currency,e[0].quoteAmount.currency,r.denominator,r.numerator]}super(o,i),this.baseCurrency=t,this.quoteCurrency=n,this.scalar=new Lv(E.exponentiate(E.BigInt(10),E.BigInt(t.decimals)),E.exponentiate(E.BigInt(10),E.BigInt(n.decimals)))}invert(){return new Nv(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)}multiply(e){O(this.quoteCurrency.equals(e.baseCurrency),"TOKEN");const t=super.multiply(e);return new Nv(this.baseCurrency,e.quoteCurrency,t.denominator,t.numerator)}quote(e){O(e.currency.equals(this.baseCurrency),"TOKEN");const t=super.multiply(e);return Rv.fromFractionalAmount(this.quoteCurrency,t.numerator,t.denominator)}get adjustedForDecimals(){return super.multiply(this.scalar)}toSignificant(e=6,t,n){return this.adjustedForDecimals.toSignificant(e,t,n)}toFixed(e=4,t,n){return this.adjustedForDecimals.toFixed(e,t,n)}}class Dv{constructor(e,t,n,i){O(Number.isSafeInteger(e),"CHAIN_ID"),O(t>=0&&t<255&&Number.isInteger(t),"DECIMALS"),this.chainId=e,this.decimals=t,this.symbol=n,this.name=i}}function Fv(e){try{return su(e)}catch(t){throw new Error(`${e} is not a valid address.`)}}const Uv=/^0x[0-9a-fA-F]{40}$/;class qv extends Dv{constructor(e,t,n,i,o,r,a,s){super(e,n,i,o),this.isNative=!1,this.isToken=!0,this.address=r?function(e){if(Uv.test(e))return e;throw new Error(`${e} is not a valid address.`)}(t):Fv(t),a&&O(a.gte(x.BigNumber.from(0)),"NON-NEGATIVE FOT FEES"),s&&O(s.gte(x.BigNumber.from(0)),"NON-NEGATIVE FOT FEES"),this.buyFeeBps=a,this.sellFeeBps=s}equals(e){return e.isToken&&this.chainId===e.chainId&&this.address.toLowerCase()===e.address.toLowerCase()}sortsBefore(e){return O(this.chainId===e.chainId,"CHAIN_IDS"),O(this.address.toLowerCase()!==e.address.toLowerCase(),"ADDRESSES"),this.address.toLowerCase()<e.address.toLowerCase()}get wrapped(){return this}}const Vv=E.BigInt(Number.MAX_SAFE_INTEGER),Hv=E.BigInt(0),Wv=E.BigInt(1),$v=E.BigInt(2);const zv=E.BigInt(0),Zv=1e4;new _v(E.BigInt(1),Zv),new _v(1,100),new _v(3,100),new _v(5,100),new _v(10,100),new _v(15,100);const Qv=new _v(0);new _v(1);const Gv="0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";var Yv;!function(e){e[e.LOWEST=100]="LOWEST",e[e.LOW_200=200]="LOW_200",e[e.LOW_300=300]="LOW_300",e[e.LOW_400=400]="LOW_400",e[e.LOW=500]="LOW",e[e.MEDIUM=3e3]="MEDIUM",e[e.HIGH=1e4]="HIGH"}(Yv||(Yv={}));const Kv={[Yv.LOWEST]:1,[Yv.LOW_200]:4,[Yv.LOW_300]:6,[Yv.LOW_400]:8,[Yv.LOW]:10,[Yv.MEDIUM]:60,[Yv.HIGH]:200},Xv=E.BigInt(-1),Jv=E.BigInt(0),eb=E.BigInt(1),tb=E.exponentiate(E.BigInt(2),E.BigInt(96)),nb=E.exponentiate(tb,E.BigInt(2)),ib=new Dc("properties/5.8.0");function ob(e,t,n){Object.defineProperty(e,t,{enumerable:!0,value:n,writable:!1})}function rb(e,t){for(let n=0;n<32;n++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}const ab={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function sb(e){if(null==e||ab[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const t=Object.keys(e);for(let n=0;n<t.length;n++){let i=null;try{i=e[t[n]]}catch(e){continue}if(!sb(i))return!1}return!0}return ib.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function lb(e){if(sb(e))return e;if(Array.isArray(e))return Object.freeze(e.map((e=>db(e))));if("object"==typeof e){const t={};for(const n in e){const i=e[n];void 0!==i&&ob(t,n,db(i))}return t}return ib.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function db(e){return lb(e)}class cb{constructor(e){for(const t in e)this[t]=db(e[t])}}const ub="abi/5.8.0",pb=new Dc(ub),hb={};let mb={calldata:!0,memory:!0,storage:!0},gb={calldata:!0,memory:!0};function xb(e,t){if("bytes"===e||"string"===e){if(mb[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&gb[t])return!0;return(mb[t]||"payable"===t)&&pb.throwArgumentError("invalid modifier","name",t),!1}function fb(e,t){for(let n in t)ob(e,n,t[n])}const yb=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vb=new RegExp(/^(.*)\[([0-9]*)\]$/);class bb{constructor(e,t){e!==hb&&pb.throwError("use fromString",Dc.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),fb(this,t);let n=this.type.match(vb);fb(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:bb.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==yb.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===yb.full?", ":",")+")"):t+=this.type,e!==yb.sighash&&(!0===this.indexed&&(t+=" indexed"),e===yb.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?bb.fromString(e,t):bb.fromObject(e)}static fromObject(e){return bb.isParamType(e)?e:new bb(hb,{name:e.name||null,type:Ob(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(bb.fromObject):null})}static fromString(e,t){return n=function(e,t){let n=e;function i(t){pb.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function o(e){let n={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(n.indexed=!1),n}e=e.replace(/\s/g," ");let r={type:"",name:"",state:{allowType:!0}},a=r;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(n),a.state.allowType=!1,a.type=Ob(a.type),a.components=[o(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),xb(a.type,a.name)&&(a.name=""),a.type=Ob(a.type);let e=a;a=a.parent,a||i(n),delete e.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),xb(a.type,a.name)&&(a.name=""),a.type=Ob(a.type);let s=o(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Ob(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(t||i(n),a.indexed&&i(n),a.indexed=!0,a.name=""):xb(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(n),a.type+=r,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(n),a.type+=r,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=r,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=r,delete a.state.allowArray):a.state.readArray?a.type+=r:i(n)}}return a.parent&&pb.throwArgumentError("unexpected eof","param",e),delete r.state,"indexed"===a.name?(t||i(n.length-7),a.indexed&&i(n.length-7),a.indexed=!0,a.name=""):xb(a.type,a.name)&&(a.name=""),r.type=Ob(r.type),r}(e,!!t),bb.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components});var n}static isParamType(e){return!(null==e||!e._isParamType)}}function Cb(e,t){return function(e){e=e.trim();let t=[],n="",i=0;for(let o=0;o<e.length;o++){let r=e[o];","===r&&0===i?(t.push(n),n=""):(n+=r,"("===r?i++:")"===r&&(i--,-1===i&&pb.throwArgumentError("unbalanced parenthesis","value",e)))}n&&t.push(n);return t}(e).map((e=>bb.fromString(e,t)))}class jb{constructor(e,t){e!==hb&&pb.throwError("use a static from method",Dc.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),fb(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return jb.isFragment(e)?e:"string"==typeof e?jb.fromString(e):jb.fromObject(e)}static fromObject(e){if(jb.isFragment(e))return e;switch(e.type){case"function":return Sb.fromObject(e);case"event":return wb.fromObject(e);case"constructor":return Ib.fromObject(e);case"error":return Eb.fromObject(e);case"fallback":case"receive":return null}return pb.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?wb.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?Sb.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?Ib.fromString(e.trim()):"error"===e.split(" ")[0]?Eb.fromString(e.substring(5).trim()):pb.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class wb extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",e!==yb.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?wb.fromString(e):wb.fromObject(e)}static fromObject(e){if(wb.isEventFragment(e))return e;"event"!==e.type&&pb.throwArgumentError("invalid event object","value",e);const t={name:Rb(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(bb.fromObject):[],type:"event"};return new wb(hb,t)}static fromString(e){let t=e.match(Mb);t||pb.throwArgumentError("invalid event string","value",e);let n=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":n=!0;break;case"":break;default:pb.warn("unknown modifier: "+e)}})),wb.fromObject({name:t[1].trim(),anonymous:n,inputs:Cb(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function kb(e,t){t.gas=null;let n=e.split("@");return 1!==n.length?(n.length>2&&pb.throwArgumentError("invalid human-readable ABI signature","value",e),n[1].match(/^[0-9]+$/)||pb.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=x.BigNumber.from(n[1]),n[0]):e}function Tb(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function Bb(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&pb.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&pb.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||pb.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&pb.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&pb.throwArgumentError("unable to determine stateMutability","value",e),t}class Ib extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===yb.sighash&&pb.throwError("cannot format a constructor for sighash",Dc.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?Ib.fromString(e):Ib.fromObject(e)}static fromObject(e){if(Ib.isConstructorFragment(e))return e;"constructor"!==e.type&&pb.throwArgumentError("invalid constructor object","value",e);let t=Bb(e);t.constant&&pb.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(bb.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?x.BigNumber.from(e.gas):null};return new Ib(hb,n)}static fromString(e){let t={type:"constructor"},n=(e=kb(e,t)).match(Mb);return n&&"constructor"===n[1].trim()||pb.throwArgumentError("invalid constructor string","value",e),t.inputs=Cb(n[2].trim(),!1),Tb(n[3].trim(),t),Ib.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class Sb extends Ib{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",e!==yb.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?Sb.fromString(e):Sb.fromObject(e)}static fromObject(e){if(Sb.isFunctionFragment(e))return e;"function"!==e.type&&pb.throwArgumentError("invalid function object","value",e);let t=Bb(e);const n={type:e.type,name:Rb(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(bb.fromObject):[],outputs:e.outputs?e.outputs.map(bb.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?x.BigNumber.from(e.gas):null};return new Sb(hb,n)}static fromString(e){let t={type:"function"},n=(e=kb(e,t)).split(" returns ");n.length>2&&pb.throwArgumentError("invalid function string","value",e);let i=n[0].match(Mb);if(i||pb.throwArgumentError("invalid function signature","value",e),t.name=i[1].trim(),t.name&&Rb(t.name),t.inputs=Cb(i[2],!1),Tb(i[3].trim(),t),n.length>1){let i=n[1].match(Mb);""==i[1].trim()&&""==i[3].trim()||pb.throwArgumentError("unexpected tokens","value",e),t.outputs=Cb(i[2],!1)}else t.outputs=[];return Sb.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function Ab(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||pb.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class Eb extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?Eb.fromString(e):Eb.fromObject(e)}static fromObject(e){if(Eb.isErrorFragment(e))return e;"error"!==e.type&&pb.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:Rb(e.name),inputs:e.inputs?e.inputs.map(bb.fromObject):[]};return Ab(new Eb(hb,t))}static fromString(e){let t={type:"error"},n=e.match(Mb);return n||pb.throwArgumentError("invalid error signature","value",e),t.name=n[1].trim(),t.name&&Rb(t.name),t.inputs=Cb(n[2],!1),Ab(Eb.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function Ob(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const Lb=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Rb(e){return e&&e.match(Lb)||pb.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const Mb=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Pb=new Dc(ub);class _b{constructor(e,t,n,i){this.name=e,this.type=t,this.localName=n,this.dynamic=i}_throwError(e,t){Pb.throwArgumentError(e,this.localName,t)}}class Nb{constructor(e){ob(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let t="0x";return e.forEach((e=>{t+=Gc(e).substring(2)})),t}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData($c(e._data))}writeBytes(e){let t=Wc(e);const n=t.length%this.wordSize;return n&&(t=$c([t,this._padding.slice(n)])),this._writeData(t)}_getValue(e){let t=Wc(x.BigNumber.from(e));return t.length>this.wordSize&&Pb.throwError("value out-of-bounds",Dc.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=$c([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class Db{constructor(e,t,n,i){ob(this,"_data",Wc(e)),ob(this,"wordSize",t||32),ob(this,"_coerceFunc",n),ob(this,"allowLoose",i),this._offset=0}get data(){return Gc(this._data)}get consumed(){return this._offset}static coerce(e,t){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):Db.coerce(e,t)}_peekBytes(e,t,n){let i=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+t<=this._data.length?i=t:Pb.throwError("data out-of-bounds",Dc.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new Db(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let n=this._peekBytes(0,e,!!t);return this._offset+=n.length,n.slice(0,e)}readValue(){return x.BigNumber.from(this.readBytes(this.wordSize))}}class Fb extends _b{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=su(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return su(Xc(e.readValue().toHexString(),20))}}class Ub extends _b{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const qb=new Dc(ub);function Vb(e,t,n){let i=null;if(Array.isArray(n))i=n;else if(n&&"object"==typeof n){let e={};i=t.map((t=>{const i=t.localName;return i||qb.throwError("cannot encode object for signature with missing names",Dc.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]&&qb.throwError("cannot encode object for signature with duplicate names",Dc.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]=!0,n[i]}))}else qb.throwArgumentError("invalid tuple value","tuple",n);t.length!==i.length&&qb.throwArgumentError("types/value length mismatch","tuple",n);let o=new Nb(e.wordSize),r=new Nb(e.wordSize),a=[];t.forEach(((e,t)=>{let n=i[t];if(e.dynamic){let t=r.length;e.encode(r,n);let i=o.writeUpdatableValue();a.push((e=>{i(e+t)}))}else e.encode(o,n)})),a.forEach((e=>{e(o.length)}));let s=e.appendWriter(o);return s+=e.appendWriter(r),s}function Hb(e,t){let n=[],i=e.subReader(0);t.forEach((t=>{let o=null;if(t.dynamic){let n=e.readValue(),r=i.subReader(n.toNumber());try{o=t.decode(r)}catch(e){if(e.code===Dc.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}}else try{o=t.decode(e)}catch(e){if(e.code===Dc.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}null!=o&&n.push(o)}));const o=t.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});t.forEach(((e,t)=>{let i=e.localName;if(!i||1!==o[i])return;if("length"===i&&(i="_length"),null!=n[i])return;const r=n[t];r instanceof Error?Object.defineProperty(n,i,{enumerable:!0,get:()=>{throw r}}):n[i]=r}));for(let e=0;e<n.length;e++){const t=n[e];t instanceof Error&&Object.defineProperty(n,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(n)}class Wb extends _b{constructor(e,t,n){super("array",e.type+"["+(t>=0?t:"")+"]",n,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let n=this.length;-1===n&&(n=t.length,e.writeValue(t.length)),qb.checkArgumentCount(t.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let e=0;e<t.length;e++)i.push(this.coder);return Vb(e,i,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&qb.throwError("insufficient data length",Dc.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let n=[];for(let e=0;e<t;e++)n.push(new Ub(this.coder));return e.coerce(this.name,Hb(e,n))}}class $b extends _b{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class zb extends _b{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Wc(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Zb extends zb{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Gc(super.decode(e)))}}class Qb extends _b{constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let n=Wc(t);return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return e.coerce(this.name,Gc(e.readBytes(this.size)))}}class Gb extends _b{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}class Yb extends _b{constructor(e,t,n){const i=(t?"int":"uint")+8*e;super(i,i,n,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let n=x.BigNumber.from(t),i=pu.mask(8*e.wordSize);if(this.signed){let e=i.mask(8*this.size-1);(n.gt(e)||n.lt(e.add(uu).mul(du)))&&this._throwError("value out-of-bounds",t)}else(n.lt(cu)||n.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return n=n.toTwos(8*this.size).mask(8*this.size),this.signed&&(n=n.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(n)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Kb extends zb{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,yu(t))}decode(e){return vu(super.decode(e))}}class Xb extends _b{constructor(e,t){let n=!1;const i=[];e.forEach((e=>{e.dynamic&&(n=!0),i.push(e.type)}));super("tuple","tuple("+i.join(",")+")",t,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});return this.coders.forEach(((n,i)=>{let o=n.localName;o&&1===t[o]&&("length"===o&&(o="_length"),null==e[o]&&(e[o]=e[i]))})),Object.freeze(e)}encode(e,t){return Vb(e,this.coders,t)}decode(e){return e.coerce(this.name,Hb(e,this.coders))}}const Jb=new Dc(ub),eC=new RegExp(/^bytes([0-9]*)$/),tC=new RegExp(/^(u?int)([0-9]*)$/);const nC=new class{constructor(e){ob(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new Fb(e.name);case"bool":return new $b(e.name);case"string":return new Kb(e.name);case"bytes":return new Zb(e.name);case"array":return new Wb(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new Xb((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Gb(e.name)}let t=e.type.match(tC);if(t){let n=parseInt(t[2]||"256");return(0===n||n>256||n%8!=0)&&Jb.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Yb(n/8,"int"===t[1],e.name)}if(t=e.type.match(eC),t){let n=parseInt(t[1]);return(0===n||n>32)&&Jb.throwArgumentError("invalid bytes length","param",e),new Qb(n,e.name)}return Jb.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new Db(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new Nb(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(bb.from(e))));return new Xb(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&Jb.throwError("types/values length mismatch",Dc.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const n=e.map((e=>this._getCoder(bb.from(e)))),i=new Xb(n,"_"),o=this._getWriter();return i.encode(o,t),o.data}decode(e,t,n){const i=e.map((e=>this._getCoder(bb.from(e))));return new Xb(i,"_").decode(this._getReader(Wc(t),n))}};function iC(e){return tu(yu(e))}const oC=new Dc(ub);class rC extends cb{}class aC extends cb{}class sC extends cb{}class lC extends cb{static isIndexed(e){return!(!e||!e._isIndexed)}}const dC={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function cC(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return n.error=t,n}class uC{constructor(e){let t=[];t="string"==typeof e?JSON.parse(e):e,ob(this,"fragments",t.map((e=>jb.from(e))).filter((e=>null!=e))),ob(this,"_abiCoder",rb(new.target,"getAbiCoder")()),ob(this,"functions",{}),ob(this,"errors",{}),ob(this,"events",{}),ob(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void oC.warn("duplicate definition - constructor"):void ob(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let n=e.format();t[n]?oC.warn("duplicate definition - "+n):t[n]=e})),this.deploy||ob(this,"deploy",Ib.from({payable:!1,type:"constructor"})),ob(this,"_isInterface",!0)}format(e){e||(e=yb.full),e===yb.sighash&&oC.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===yb.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return nC}static getAddress(e){return su(e)}static getSighash(e){return Kc(iC(e.format()),0,4)}static getEventTopic(e){return iC(e.format())}getFunction(e){if(Zc(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];oC.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching function","name",t):n.length>1&&oC.throwArgumentError("multiple matching functions","name",t),this.functions[n[0]]}const t=this.functions[Sb.fromString(e).format()];return t||oC.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Zc(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];oC.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching event","name",t):n.length>1&&oC.throwArgumentError("multiple matching events","name",t),this.events[n[0]]}const t=this.events[wb.fromString(e).format()];return t||oC.throwArgumentError("no matching event","signature",e),t}getError(e){if(Zc(e)){const t=rb(this.constructor,"getSighash");for(const n in this.errors){if(e===t(this.errors[n]))return this.errors[n]}oC.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching error","name",t):n.length>1&&oC.throwArgumentError("multiple matching errors","name",t),this.errors[n[0]]}const t=this.errors[Sb.fromString(e).format()];return t||oC.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return rb(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),rb(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const n=Wc(t);return Gc(n.slice(0,4))!==this.getSighash(e)&&oC.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Gc(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Gc($c([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const n=Wc(t);return Gc(n.slice(0,4))!==this.getSighash(e)&&oC.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Gc(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Gc($c([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let n=Wc(t),i=null,o="",r=null,a=null,s=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch(e){}break;case 4:{const e=Gc(n.slice(0,4)),t=dC[e];if(t)r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.signature,t.reason&&(i=r[0]),"Error"===a?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(r[0])}`:"Panic"===a&&(o=`; VM Exception while processing transaction: reverted with panic code ${r[0]}`);else try{const t=this.getError(e);r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.format()}catch(e){}break}}return oC.throwError("call revert exception"+o,Dc.errors.CALL_EXCEPTION,{method:e.format(),data:Gc(t),errorArgs:r,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Gc(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&oC.throwError("too many arguments for "+e.format(),Dc.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(e,t)=>"string"===e.type?iC(t):"bytes"===e.type?tu(Gc(t)):("bool"===e.type&&"boolean"==typeof t&&(t=t?"0x01":"0x00"),e.type.match(/^u?int/)&&(t=x.BigNumber.from(t).toHexString()),"address"===e.type&&this._abiCoder.encode(["address"],[t]),Xc(Gc(t),32));for(t.forEach(((t,o)=>{let r=e.inputs[o];r.indexed?null==t?n.push(null):"array"===r.baseType||"tuple"===r.baseType?oC.throwArgumentError("filtering with tuples or arrays not supported","contract."+r.name,t):Array.isArray(t)?n.push(t.map((e=>i(r,e)))):n.push(i(r,t)):null!=t&&oC.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+r.name,t)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const n=[],i=[],o=[];return e.anonymous||n.push(this.getEventTopic(e)),t.length!==e.inputs.length&&oC.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,r)=>{const a=t[r];if(e.indexed)if("string"===e.type)n.push(iC(a));else if("bytes"===e.type)n.push(tu(a));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");n.push(this._abiCoder.encode([e.type],[a]))}else i.push(e),o.push(a)})),{data:this._abiCoder.encode(i,o),topics:n}}decodeEventLog(e,t,n){if("string"==typeof e&&(e=this.getEvent(e)),null!=n&&!e.anonymous){let t=this.getEventTopic(e);Zc(n[0],32)&&n[0].toLowerCase()===t||oC.throwError("fragment/topic mismatch",Dc.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:n[0]}),n=n.slice(1)}let i=[],o=[],r=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(bb.fromObject({type:"bytes32",name:e.name})),r.push(!0)):(i.push(e),r.push(!1)):(o.push(e),r.push(!1))}));let a=null!=n?this._abiCoder.decode(i,$c(n)):null,s=this._abiCoder.decode(o,t,!0),l=[],d=0,c=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==a)l[t]=new lC({_isIndexed:!0,hash:null});else if(r[t])l[t]=new lC({_isIndexed:!0,hash:a[c++]});else try{l[t]=a[c++]}catch(e){l[t]=e}else try{l[t]=s[d++]}catch(e){l[t]=e}if(e.name&&null==l[e.name]){const n=l[t];n instanceof Error?Object.defineProperty(l,e.name,{enumerable:!0,get:()=>{throw cC(`property ${JSON.stringify(e.name)}`,n)}}):l[e.name]=n}}));for(let e=0;e<l.length;e++){const t=l[e];t instanceof Error&&Object.defineProperty(l,e,{enumerable:!0,get:()=>{throw cC(`index ${e}`,t)}})}return Object.freeze(l)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new aC({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:x.BigNumber.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new rC({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Gc(e);let n=this.getError(t.substring(0,10).toLowerCase());return n?new sC({args:this._abiCoder.decode(n.inputs,"0x"+t.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!(!e||!e._isInterface)}}function pC({factoryAddress:e,tokenA:t,tokenB:n,fee:i,initCodeHashManualOverride:o,chainId:a}){const[s,l]=t.sortsBefore(n)?[t,n]:[n,t],d=Iu(["bytes"],[nC.encode(["address","address","uint24"],[s.address,l.address,i])]),c=null!=o?o:function(e){switch(e){case r.ChainId.TAIKO:case r.ChainId.ZETACHAIN:case r.ChainId.ZETACHAIN_TESTNET:return"0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";case r.ChainId.SEPOLIA:return"0x4509fa1e2d1989ac1632a56fe87c53e8d1e9d05847694e00f62b23e28cec98c4";default:return Gv}}(a);return lu(e,d,c)}const hC=E.BigInt(2),mC=[128,64,32,16,8,4,2,1].map((e=>[e,E.exponentiate(hC,E.BigInt(e))]));function gC(e,t){return E.signedRightShift(E.multiply(e,E.BigInt(t)),E.BigInt(128))}const xC=E.exponentiate(E.BigInt(2),E.BigInt(32));class fC{constructor(){}static getSqrtRatioAtTick(e){O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK&&Number.isInteger(e),"TICK");const t=e<0?-1*e:e;let n=1&t?E.BigInt("0xfffcb933bd6fad37aa2d162d1a594001"):E.BigInt("0x100000000000000000000000000000000");return 2&t&&(n=gC(n,"0xfff97272373d413259a46990580e213a")),4&t&&(n=gC(n,"0xfff2e50f5f656932ef12357cf3c7fdcc")),8&t&&(n=gC(n,"0xffe5caca7e10e4e61c3624eaa0941cd0")),16&t&&(n=gC(n,"0xffcb9843d60f6159c9db58835c926644")),32&t&&(n=gC(n,"0xff973b41fa98c081472e6896dfb254c0")),64&t&&(n=gC(n,"0xff2ea16466c96a3843ec78b326b52861")),128&t&&(n=gC(n,"0xfe5dee046a99a2a811c461f1969c3053")),256&t&&(n=gC(n,"0xfcbe86c7900a88aedcffc83b479aa3a4")),512&t&&(n=gC(n,"0xf987a7253ac413176f2b074cf7815e54")),1024&t&&(n=gC(n,"0xf3392b0822b70005940c7a398e4b70f3")),2048&t&&(n=gC(n,"0xe7159475a2c29b7443b29c7fa6e889d9")),4096&t&&(n=gC(n,"0xd097f3bdfd2022b8845ad8f792aa5825")),8192&t&&(n=gC(n,"0xa9f746462d870fdf8a65dc1f90e061e5")),16384&t&&(n=gC(n,"0x70d869a156d2a1b890bb3df62baf32f7")),32768&t&&(n=gC(n,"0x31be135f97d08fd981231505542fcfa6")),65536&t&&(n=gC(n,"0x9aa508b5b7a84e1c677de54f3e99bc9")),131072&t&&(n=gC(n,"0x5d6af8dedb81196699c329225ee604")),262144&t&&(n=gC(n,"0x2216e584f5fa1ea926041bedfe98")),524288&t&&(n=gC(n,"0x48a170391f7dc42444e8fa2")),e>0&&(n=E.divide(Av,n)),E.greaterThan(E.remainder(n,xC),Jv)?E.add(E.divide(n,xC),eb):E.divide(n,xC)}static getTickAtSqrtRatio(e){O(E.greaterThanOrEqual(e,fC.MIN_SQRT_RATIO)&&E.lessThan(e,fC.MAX_SQRT_RATIO),"SQRT_RATIO");const t=E.leftShift(e,E.BigInt(32)),n=function(e){O(E.greaterThan(e,Jv),"ZERO"),O(E.lessThanOrEqual(e,Av),"MAX");let t=0;for(const[n,i]of mC)E.greaterThanOrEqual(e,i)&&(e=E.signedRightShift(e,E.BigInt(n)),t+=n);return t}(t);let i;i=E.greaterThanOrEqual(E.BigInt(n),E.BigInt(128))?E.signedRightShift(t,E.BigInt(n-127)):E.leftShift(t,E.BigInt(127-n));let o=E.leftShift(E.subtract(E.BigInt(n),E.BigInt(128)),E.BigInt(64));for(let e=0;e<14;e++){i=E.signedRightShift(E.multiply(i,i),E.BigInt(127));const t=E.signedRightShift(i,E.BigInt(128));o=E.bitwiseOr(o,E.leftShift(t,E.BigInt(63-e))),i=E.signedRightShift(i,t)}const r=E.multiply(o,E.BigInt("255738958999603826347141")),a=E.toNumber(E.signedRightShift(E.subtract(r,E.BigInt("3402992956809132418596140100660247210")),E.BigInt(128))),s=E.toNumber(E.signedRightShift(E.add(r,E.BigInt("291339464771989622907027621153398088495")),E.BigInt(128)));return a===s?a:E.lessThanOrEqual(fC.getSqrtRatioAtTick(s),e)?s:a}}fC.MIN_TICK=-887272,fC.MAX_TICK=-fC.MIN_TICK,fC.MIN_SQRT_RATIO=E.BigInt("4295128739"),fC.MAX_SQRT_RATIO=E.BigInt("1461446703485210103287273052203988822378723970342");class yC{constructor(){}static mulDivRoundingUp(e,t,n){const i=E.multiply(e,t);let o=E.divide(i,n);return E.notEqual(E.remainder(i,n),Jv)&&(o=E.add(o,eb)),o}}const vC=E.subtract(E.exponentiate(E.BigInt(2),E.BigInt(160)),eb);function bC(e,t){const n=E.multiply(e,t);return E.bitwiseAnd(n,Av)}class CC{constructor(){}static getAmount0Delta(e,t,n,i){E.greaterThan(e,t)&&([e,t]=[t,e]);const o=E.leftShift(n,E.BigInt(96)),r=E.subtract(t,e);return i?yC.mulDivRoundingUp(yC.mulDivRoundingUp(o,r,t),eb,e):E.divide(E.divide(E.multiply(o,r),t),e)}static getAmount1Delta(e,t,n,i){return E.greaterThan(e,t)&&([e,t]=[t,e]),i?yC.mulDivRoundingUp(n,E.subtract(t,e),tb):E.divide(E.multiply(n,E.subtract(t,e)),tb)}static getNextSqrtPriceFromInput(e,t,n,i){return O(E.greaterThan(e,Jv)),O(E.greaterThan(t,Jv)),i?this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!0)}static getNextSqrtPriceFromOutput(e,t,n,i){return O(E.greaterThan(e,Jv)),O(E.greaterThan(t,Jv)),i?this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!1)}static getNextSqrtPriceFromAmount0RoundingUp(e,t,n,i){if(E.equal(n,Jv))return e;const o=E.leftShift(t,E.BigInt(96));if(i){let t=bC(n,e);if(E.equal(E.divide(t,n),e)){const n=function(e,t){const n=E.add(e,t);return E.bitwiseAnd(n,Av)}(o,t);if(E.greaterThanOrEqual(n,o))return yC.mulDivRoundingUp(o,e,n)}return yC.mulDivRoundingUp(o,eb,E.add(E.divide(o,e),n))}{let t=bC(n,e);O(E.equal(E.divide(t,n),e)),O(E.greaterThan(o,t));const i=E.subtract(o,t);return yC.mulDivRoundingUp(o,e,i)}}static getNextSqrtPriceFromAmount1RoundingDown(e,t,n,i){if(i){const i=E.lessThanOrEqual(n,vC)?E.divide(E.leftShift(n,E.BigInt(96)),t):E.divide(E.multiply(n,tb),t);return E.add(e,i)}{const i=yC.mulDivRoundingUp(n,tb,t);return O(E.greaterThan(e,i)),E.subtract(e,i)}}}const jC=E.exponentiate(E.BigInt(10),E.BigInt(6));class wC{constructor(){}static computeSwapStep(e,t,n,i,o){const r={};o=E.BigInt(o);const a=E.greaterThanOrEqual(e,t),s=E.greaterThanOrEqual(i,Jv);if(s){const s=E.divide(E.multiply(i,E.subtract(jC,o)),jC);r.amountIn=a?CC.getAmount0Delta(t,e,n,!0):CC.getAmount1Delta(e,t,n,!0),E.greaterThanOrEqual(s,r.amountIn)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=CC.getNextSqrtPriceFromInput(e,n,s,a)}else r.amountOut=a?CC.getAmount1Delta(t,e,n,!1):CC.getAmount0Delta(e,t,n,!1),E.greaterThanOrEqual(E.multiply(i,Xv),r.amountOut)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=CC.getNextSqrtPriceFromOutput(e,n,E.multiply(i,Xv),a);const l=E.equal(t,r.sqrtRatioNextX96);return a?(r.amountIn=l&&s?r.amountIn:CC.getAmount0Delta(r.sqrtRatioNextX96,e,n,!0),r.amountOut=l&&!s?r.amountOut:CC.getAmount1Delta(r.sqrtRatioNextX96,e,n,!1)):(r.amountIn=l&&s?r.amountIn:CC.getAmount1Delta(e,r.sqrtRatioNextX96,n,!0),r.amountOut=l&&!s?r.amountOut:CC.getAmount0Delta(e,r.sqrtRatioNextX96,n,!1)),!s&&E.greaterThan(r.amountOut,E.multiply(i,Xv))&&(r.amountOut=E.multiply(i,Xv)),s&&E.notEqual(r.sqrtRatioNextX96,t)?r.feeAmount=E.subtract(i,r.amountIn):r.feeAmount=yC.mulDivRoundingUp(r.amountIn,o,E.subtract(jC,o)),[r.sqrtRatioNextX96,r.amountIn,r.amountOut,r.feeAmount]}}class kC{constructor(){}static addDelta(e,t){return E.lessThan(t,Jv)?E.subtract(e,E.multiply(t,Xv)):E.add(e,t)}}class TC{getTick(e){return q(this,void 0,void 0,(function*(){throw new Error(TC.ERROR_MESSAGE)}))}nextInitializedTickWithinOneWord(e,t,n){return q(this,void 0,void 0,(function*(){throw new Error(TC.ERROR_MESSAGE)}))}}function BC(e,t){return e.index-t.index}TC.ERROR_MESSAGE="No tick data provider was given";class IC{constructor(){}static validateList(e,t){O(t>0,"TICK_SPACING_NONZERO"),O(e.every((({index:e})=>e%t==0)),"TICK_SPACING"),O(E.equal(e.reduce(((e,{liquidityNet:t})=>E.add(e,t)),Jv),Jv),"ZERO_NET"),O(function(e,t){for(let n=0;n<e.length-1;n++)if(t(e[n],e[n+1])>0)return!1;return!0}(e,BC),"SORTED")}static isBelowSmallest(e,t){return O(e.length>0,"LENGTH"),t<e[0].index}static isAtOrAboveLargest(e,t){return O(e.length>0,"LENGTH"),t>=e[e.length-1].index}static getTick(e,t){const n=e[this.binarySearch(e,t)];return O(n.index===t,"NOT_CONTAINED"),n}static binarySearch(e,t){O(!this.isBelowSmallest(e,t),"BELOW_SMALLEST");let n,i=0,o=e.length-1;for(;;){if(n=Math.floor((i+o)/2),e[n].index<=t&&(n===e.length-1||e[n+1].index>t))return n;e[n].index<t?i=n+1:o=n-1}}static nextInitializedTick(e,t,n){if(n){if(O(!IC.isBelowSmallest(e,t),"BELOW_SMALLEST"),IC.isAtOrAboveLargest(e,t))return e[e.length-1];return e[this.binarySearch(e,t)]}if(O(!this.isAtOrAboveLargest(e,t),"AT_OR_ABOVE_LARGEST"),this.isBelowSmallest(e,t))return e[0];return e[this.binarySearch(e,t)+1]}static nextInitializedTickWithinOneWord(e,t,n,i){const o=Math.floor(t/i);if(n){const r=(o>>8<<8)*i;if(IC.isBelowSmallest(e,t))return[r,!1];const a=IC.nextInitializedTick(e,t,n).index,s=Math.max(r,a);return[s,s===a]}{const r=(((o+1>>8)+1<<8)-1)*i;if(this.isAtOrAboveLargest(e,t))return[r,!1];const a=this.nextInitializedTick(e,t,n).index,s=Math.min(r,a);return[s,s===a]}}}function SC(e){let t=E.BigInt(e).toString(16);return t.length%2!=0&&(t=`0${t}`),`0x${t}`}function AC(e,t){const n=E.leftShift(E.BigInt(e),E.BigInt(192)),i=E.BigInt(t);return function(e){if(O(E.greaterThanOrEqual(e,Hv),"NEGATIVE"),E.lessThan(e,Vv))return E.BigInt(Math.floor(Math.sqrt(E.toNumber(e))));let t,n;for(t=e,n=E.add(E.divide(e,$v),Wv);E.lessThan(n,t);)t=n,n=E.divide(E.add(E.divide(e,n),n),$v);return t}(E.divide(n,i))}function EC(e,t,n){E.greaterThan(e,t)&&([e,t]=[t,e]);const i=E.divide(E.multiply(e,t),tb);return E.divide(E.multiply(E.BigInt(n),i),E.subtract(t,e))}function OC(e,t,n){E.greaterThan(e,t)&&([e,t]=[t,e]);const i=E.multiply(E.multiply(E.BigInt(n),e),t),o=E.multiply(tb,E.subtract(t,e));return E.divide(i,o)}function LC(e,t,n){return E.greaterThan(e,t)&&([e,t]=[t,e]),E.divide(E.multiply(E.BigInt(n),tb),E.subtract(t,e))}function RC(e,t,n,i,o,r){E.greaterThan(t,n)&&([t,n]=[n,t]);const a=r?OC:EC;if(E.lessThanOrEqual(e,t))return a(t,n,i);if(E.lessThan(e,n)){const r=a(e,n,i),s=LC(t,e,o);return E.lessThan(r,s)?r:s}return LC(t,n,o)}function MC(e,t){O(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),O(t>0,"TICK_SPACING"),O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<fC.MIN_TICK?n+t:n>fC.MAX_TICK?n-t:n}function PC(e,t,n){const i=fC.getSqrtRatioAtTick(n),o=E.multiply(i,i);return e.sortsBefore(t)?new Nv(e,t,nb,o):new Nv(e,t,o,nb)}function _C(e){const t=e.baseCurrency.sortsBefore(e.quoteCurrency),n=t?AC(e.numerator,e.denominator):AC(e.denominator,e.numerator);let i=fC.getTickAtSqrtRatio(n);const o=PC(e.baseCurrency,e.quoteCurrency,i+1);return t?e.lessThan(o)||i++:e.greaterThan(o)||i++,i}E.exponentiate(E.BigInt(2),E.BigInt(128)),E.exponentiate(E.BigInt(2),E.BigInt(256));class NC{constructor({index:e,liquidityGross:t,liquidityNet:n}){O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK,"TICK"),this.index=e,this.liquidityGross=E.BigInt(t),this.liquidityNet=E.BigInt(n)}}class DC{constructor(e,t){const n=e.map((e=>e instanceof NC?e:new NC(e)));IC.validateList(n,t),this.ticks=n}getTick(e){return q(this,void 0,void 0,(function*(){return IC.getTick(this.ticks,e)}))}nextInitializedTickWithinOneWord(e,t,n){return q(this,void 0,void 0,(function*(){return IC.nextInitializedTickWithinOneWord(this.ticks,e,t,n)}))}}const FC=new TC;let UC=class e{static getAddress(e,t,n,i,o){return pC({factoryAddress:null!=o?o:"0x78172691DD3B8ADa7aEbd9bFfB487FB11D735DB2",fee:n,tokenA:e,tokenB:t,initCodeHashManualOverride:i})}constructor(e,t,n,i,o,r,a=FC){O(Number.isInteger(n)&&n<1e6,"FEE");const s=fC.getSqrtRatioAtTick(r),l=fC.getSqrtRatioAtTick(r+1);O(E.greaterThanOrEqual(E.BigInt(i),s)&&E.lessThanOrEqual(E.BigInt(i),l),"PRICE_BOUNDS"),[this.token0,this.token1]=e.sortsBefore(t)?[e,t]:[t,e],this.fee=n,this.sqrtRatioX96=E.BigInt(i),this.liquidity=E.BigInt(o),this.tickCurrent=r,this.tickDataProvider=Array.isArray(a)?new DC(a,Kv[n]):a}involvesToken(e){return e.equals(this.token0)||e.equals(this.token1)}get token0Price(){var e;return null!==(e=this._token0Price)&&void 0!==e?e:this._token0Price=new Nv(this.token0,this.token1,nb,E.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}get token1Price(){var e;return null!==(e=this._token1Price)&&void 0!==e?e:this._token1Price=new Nv(this.token1,this.token0,E.multiply(this.sqrtRatioX96,this.sqrtRatioX96),nb)}priceOf(e){return O(this.involvesToken(e),"TOKEN"),e.equals(this.token0)?this.token0Price:this.token1Price}get chainId(){return this.token0.chainId}getOutputAmount(t,n){return q(this,void 0,void 0,(function*(){O(this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token0),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,t.quotient,n),l=i?this.token1:this.token0;return[Rv.fromRawAmount(l,E.multiply(o,Xv)),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}getInputAmount(t,n){return q(this,void 0,void 0,(function*(){O(t.currency.isToken&&this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token1),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,E.multiply(t.quotient,Xv),n),l=i?this.token0:this.token1;return[Rv.fromRawAmount(l,o),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}swap(e,t,n){return q(this,void 0,void 0,(function*(){return function(e,t,n,i,o,r,a,s,l){return q(this,void 0,void 0,(function*(){l||(l=a?E.add(fC.MIN_SQRT_RATIO,eb):E.subtract(fC.MAX_SQRT_RATIO,eb)),a?(O(E.greaterThan(l,fC.MIN_SQRT_RATIO),"RATIO_MIN"),O(E.lessThan(l,t),"RATIO_CURRENT")):(O(E.lessThan(l,fC.MAX_SQRT_RATIO),"RATIO_MAX"),O(E.greaterThan(l,t),"RATIO_CURRENT"));const d=E.greaterThanOrEqual(s,Jv),c={amountSpecifiedRemaining:s,amountCalculated:Jv,sqrtPriceX96:t,tick:n,liquidity:i};for(;E.notEqual(c.amountSpecifiedRemaining,Jv)&&c.sqrtPriceX96!==l;){let t={};if(t.sqrtPriceStartX96=c.sqrtPriceX96,[t.tickNext,t.initialized]=yield r.nextInitializedTickWithinOneWord(c.tick,a,o),t.tickNext<fC.MIN_TICK?t.tickNext=fC.MIN_TICK:t.tickNext>fC.MAX_TICK&&(t.tickNext=fC.MAX_TICK),t.sqrtPriceNextX96=fC.getSqrtRatioAtTick(t.tickNext),[c.sqrtPriceX96,t.amountIn,t.amountOut,t.feeAmount]=wC.computeSwapStep(c.sqrtPriceX96,(a?E.lessThan(t.sqrtPriceNextX96,l):E.greaterThan(t.sqrtPriceNextX96,l))?l:t.sqrtPriceNextX96,c.liquidity,c.amountSpecifiedRemaining,e),d?(c.amountSpecifiedRemaining=E.subtract(c.amountSpecifiedRemaining,E.add(t.amountIn,t.feeAmount)),c.amountCalculated=E.subtract(c.amountCalculated,t.amountOut)):(c.amountSpecifiedRemaining=E.add(c.amountSpecifiedRemaining,t.amountOut),c.amountCalculated=E.add(c.amountCalculated,E.add(t.amountIn,t.feeAmount))),E.equal(c.sqrtPriceX96,t.sqrtPriceNextX96)){if(t.initialized){let e=E.BigInt((yield r.getTick(t.tickNext)).liquidityNet);a&&(e=E.multiply(e,Xv)),c.liquidity=kC.addDelta(c.liquidity,e)}c.tick=a?t.tickNext-1:t.tickNext}else E.notEqual(c.sqrtPriceX96,t.sqrtPriceStartX96)&&(c.tick=fC.getTickAtSqrtRatio(c.sqrtPriceX96))}return{amountCalculated:c.amountCalculated,sqrtRatioX96:c.sqrtPriceX96,liquidity:c.liquidity,tickCurrent:c.tick}}))}(E.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,t,n)}))}get tickSpacing(){return Kv[this.fee]}};class qC{constructor({pool:e,liquidity:t,tickLower:n,tickUpper:i}){this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,O(n<i,"TICK_ORDER"),O(n>=fC.MIN_TICK&&n%e.tickSpacing==0,"TICK_LOWER"),O(i<=fC.MAX_TICK&&i%e.tickSpacing==0,"TICK_UPPER"),this.pool=e,this.tickLower=n,this.tickUpper=i,this.liquidity=E.BigInt(t)}get token0PriceLower(){return PC(this.pool.token0,this.pool.token1,this.tickLower)}get token0PriceUpper(){return PC(this.pool.token0,this.pool.token1,this.tickUpper)}get amount0(){return null===this._token0Amount&&(this.pool.tickCurrent<this.tickLower?this._token0Amount=Rv.fromRawAmount(this.pool.token0,CC.getAmount0Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this.pool.tickCurrent<this.tickUpper?this._token0Amount=Rv.fromRawAmount(this.pool.token0,CC.getAmount0Delta(this.pool.sqrtRatioX96,fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this._token0Amount=Rv.fromRawAmount(this.pool.token0,Jv)),this._token0Amount}get amount1(){return null===this._token1Amount&&(this.pool.tickCurrent<this.tickLower?this._token1Amount=Rv.fromRawAmount(this.pool.token1,Jv):this.pool.tickCurrent<this.tickUpper?this._token1Amount=Rv.fromRawAmount(this.pool.token1,CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!1)):this._token1Amount=Rv.fromRawAmount(this.pool.token1,CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}ratiosAfterSlippage(e){const t=this.pool.token0Price.asFraction.multiply(new _v(1).subtract(e)),n=this.pool.token0Price.asFraction.multiply(e.add(1));let i=AC(t.numerator,t.denominator);E.lessThanOrEqual(i,fC.MIN_SQRT_RATIO)&&(i=E.add(fC.MIN_SQRT_RATIO,E.BigInt(1)));let o=AC(n.numerator,n.denominator);return E.greaterThanOrEqual(o,fC.MAX_SQRT_RATIO)&&(o=E.subtract(fC.MAX_SQRT_RATIO,E.BigInt(1))),{sqrtRatioX96Lower:i,sqrtRatioX96Upper:o}}mintAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new UC(this.pool.token0,this.pool.token1,this.pool.fee,n,0,fC.getTickAtSqrtRatio(n)),o=new UC(this.pool.token0,this.pool.token1,this.pool.fee,t,0,fC.getTickAtSqrtRatio(t)),r=qC.fromAmounts(Object.assign(Object.assign({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts),{useFullPrecision:!1})),{amount0:a}=new qC({pool:o,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts,{amount1:s}=new qC({pool:i,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts;return{amount0:a,amount1:s}}burnAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new UC(this.pool.token0,this.pool.token1,this.pool.fee,n,0,fC.getTickAtSqrtRatio(n)),o=new UC(this.pool.token0,this.pool.token1,this.pool.fee,t,0,fC.getTickAtSqrtRatio(t)),r=new qC({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new qC({pool:i,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:r.quotient,amount1:a.quotient}}get mintAmounts(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:CC.getAmount0Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:Jv}:this.pool.tickCurrent<this.tickUpper?{amount0:CC.getAmount0Delta(this.pool.sqrtRatioX96,fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:Jv,amount1:CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}static fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:o,useFullPrecision:r}){const a=fC.getSqrtRatioAtTick(t),s=fC.getSqrtRatioAtTick(n);return new qC({pool:e,tickLower:t,tickUpper:n,liquidity:RC(e.sqrtRatioX96,a,s,i,o,r)})}static fromAmount0({pool:e,tickLower:t,tickUpper:n,amount0:i,useFullPrecision:o}){return qC.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:Av,useFullPrecision:o})}static fromAmount1({pool:e,tickLower:t,tickUpper:n,amount1:i}){return qC.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:Av,amount1:i,useFullPrecision:!0})}}var VC=[{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"}];class HC{constructor(){}static encodeMulticall(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:HC.INTERFACE.encodeFunctionData("multicall",[e])}static decodeMulticall(e){return HC.INTERFACE.decodeFunctionData("multicall",e).data}}HC.INTERFACE=new uC(VC);var WC=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"},{internalType:"address",name:"_tokenDescriptor_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"address",name:"recipient",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Collect",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"DecreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"IncreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint128",name:"amount0Max",type:"uint128"},{internalType:"uint128",name:"amount1Max",type:"uint128"}],internalType:"struct INonfungiblePositionManager.CollectParams",name:"params",type:"tuple"}],name:"collect",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceX96",type:"uint160"}],name:"createAndInitializePoolIfNecessary",outputs:[{internalType:"address",name:"pool",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.DecreaseLiquidityParams",name:"params",type:"tuple"}],name:"decreaseLiquidity",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.IncreaseLiquidityParams",name:"params",type:"tuple"}],name:"increaseLiquidity",outputs:[{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.MintParams",name:"params",type:"tuple"}],name:"mint",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"positions",outputs:[{internalType:"uint96",name:"nonce",type:"uint96"},{internalType:"address",name:"operator",type:"address"},{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"feeGrowthInside0LastX128",type:"uint256"},{internalType:"uint256",name:"feeGrowthInside1LastX128",type:"uint256"},{internalType:"uint128",name:"tokensOwed0",type:"uint128"},{internalType:"uint128",name:"tokensOwed1",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount0Owed",type:"uint256"},{internalType:"uint256",name:"amount1Owed",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"uniswapV3MintCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],$C=[{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"}];class zC{constructor(){}static encodeFeeBips(e){return SC(e.multiply(1e4).quotient)}static encodeUnwrapWETH9(e,t,n){if(t=Fv(t),n){const i=this.encodeFeeBips(n.fee),o=Fv(n.recipient);return zC.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[SC(e),t,i,o])}return zC.INTERFACE.encodeFunctionData("unwrapWETH9",[SC(e),t])}static encodeSweepToken(e,t,n,i){if(n=Fv(n),i){const o=this.encodeFeeBips(i.fee),r=Fv(i.recipient);return zC.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,SC(t),n,o,r])}return zC.INTERFACE.encodeFunctionData("sweepToken",[e.address,SC(t),n])}static encodeRefundETH(){return zC.INTERFACE.encodeFunctionData("refundETH")}}zC.INTERFACE=new uC($C);var ZC=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"}];class QC{constructor(){}static encodePermit(e,t){return"nonce"in t?QC.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,SC(t.nonce),SC(t.expiry),t.v,t.r,t.s]):QC.INTERFACE.encodeFunctionData("selfPermit",[e.address,SC(t.amount),SC(t.deadline),t.v,t.r,t.s])}}QC.INTERFACE=new uC(ZC);const GC=SC(E.subtract(E.exponentiate(E.BigInt(2),E.BigInt(128)),E.BigInt(1)));function YC(e){return Object.keys(e).some((e=>"recipient"===e))}const KC={Permit:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};class XC{constructor(){}static encodeCreate(e){return XC.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,SC(e.sqrtRatioX96)])}static createCallParameters(e){return{calldata:this.encodeCreate(e),value:SC(0)}}static addCallParameters(e,t){O(E.greaterThan(e.liquidity,Jv),"ZERO_LIQUIDITY");const n=[],{amount0:i,amount1:o}=e.mintAmounts,r=e.mintAmountsWithSlippage(t.slippageTolerance),a=SC(r.amount0),s=SC(r.amount1),l=SC(t.deadline);if(YC(t)&&t.createPool&&n.push(this.encodeCreate(e.pool)),t.token0Permit&&n.push(QC.encodePermit(e.pool.token0,t.token0Permit)),t.token1Permit&&n.push(QC.encodePermit(e.pool.token1,t.token1Permit)),YC(t)){const r=Fv(t.recipient);n.push(XC.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:SC(i),amount1Desired:SC(o),amount0Min:a,amount1Min:s,recipient:r,deadline:l}]))}else n.push(XC.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:SC(t.tokenId),amount0Desired:SC(i),amount1Desired:SC(o),amount0Min:a,amount1Min:s,deadline:l}]));let d=SC(0);if(t.useNative){const r=t.useNative.wrapped;O(e.pool.token0.equals(r)||e.pool.token1.equals(r),"NO_WETH");const a=e.pool.token0.equals(r)?i:o;E.greaterThan(a,Jv)&&n.push(zC.encodeRefundETH()),d=SC(a)}return{calldata:HC.encodeMulticall(n),value:d}}static encodeCollect(e){const t=[],n=SC(e.tokenId),i=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,o=Fv(e.recipient);if(t.push(XC.INTERFACE.encodeFunctionData("collect",[{tokenId:n,recipient:i?"0x0000000000000000000000000000000000000000":o,amount0Max:GC,amount1Max:GC}])),i){const n=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,i=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,r=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;t.push(zC.encodeUnwrapWETH9(n,o)),t.push(zC.encodeSweepToken(i,r,o))}return t}static collectCallParameters(e){const t=XC.encodeCollect(e);return{calldata:HC.encodeMulticall(t),value:SC(0)}}static removeCallParameters(e,t){const n=[],i=SC(t.deadline),o=SC(t.tokenId),r=new qC({pool:e.pool,liquidity:t.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});O(E.greaterThan(r.liquidity,Jv),"ZERO_LIQUIDITY");const{amount0:a,amount1:s}=r.burnAmountsWithSlippage(t.slippageTolerance);t.permit&&n.push(XC.INTERFACE.encodeFunctionData("permit",[Fv(t.permit.spender),o,SC(t.permit.deadline),t.permit.v,t.permit.r,t.permit.s])),n.push(XC.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:o,liquidity:SC(r.liquidity),amount0Min:SC(a),amount1Min:SC(s),deadline:i}]));const l=t.collectOptions,{expectedCurrencyOwed0:d,expectedCurrencyOwed1:c}=l,u=U(l,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return n.push(...XC.encodeCollect(Object.assign({tokenId:SC(t.tokenId),expectedCurrencyOwed0:d.add(Rv.fromRawAmount(d.currency,a)),expectedCurrencyOwed1:c.add(Rv.fromRawAmount(c.currency,s))},u))),t.liquidityPercentage.equalTo(eb)?t.burnToken&&n.push(XC.INTERFACE.encodeFunctionData("burn",[o])):O(!0!==t.burnToken,"CANNOT_BURN"),{calldata:HC.encodeMulticall(n),value:SC(0)}}static safeTransferFromParameters(e){const t=Fv(e.recipient),n=Fv(e.sender);let i;return i=e.data?XC.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[n,t,SC(e.tokenId),e.data]):XC.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[n,t,SC(e.tokenId)]),{calldata:i,value:SC(0)}}static getPermitData(e,t,n){return{domain:{name:"Uniswap V3 Positions NFT-V1",chainId:n,version:"1",verifyingContract:t},types:KC,values:e}}}XC.INTERFACE=new uC(WC);var JC=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactInputSingleParams",name:"params",type:"tuple"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactOutputSingleParams",name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}];new uC([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}]),new uC(JC);new uC([{inputs:[{internalType:"contract IUniswapV3Factory",name:"_factory",type:"address"},{internalType:"contract INonfungiblePositionManager",name:"_nonfungiblePositionManager",type:"address"},{internalType:"uint256",name:"_maxIncentiveStartLeadTime",type:"uint256"},{internalType:"uint256",name:"_maxIncentiveDuration",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"DepositTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{indexed:!0,internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"},{indexed:!1,internalType:"address",name:"refundee",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"IncentiveCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"refund",type:"uint256"}],name:"IncentiveEnded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"RewardClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"}],name:"TokenStaked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"TokenUnstaked",type:"event"},{inputs:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountRequested",type:"uint256"}],name:"claimReward",outputs:[{internalType:"uint256",name:"reward",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"reward",type:"uint256"}],name:"createIncentive",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"deposits",outputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint48",name:"numberOfStakes",type:"uint48"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"}],name:"endIncentive",outputs:[{internalType:"uint256",name:"refund",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"contract IUniswapV3Factory",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getRewardInfo",outputs:[{internalType:"uint256",name:"reward",type:"uint256"},{internalType:"uint160",name:"secondsInsideX128",type:"uint160"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"incentives",outputs:[{internalType:"uint256",name:"totalRewardUnclaimed",type:"uint256"},{internalType:"uint160",name:"totalSecondsClaimedX128",type:"uint160"},{internalType:"uint96",name:"numberOfStakes",type:"uint96"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveStartLeadTime",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"nonfungiblePositionManager",outputs:[{internalType:"contract INonfungiblePositionManager",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20Minimal",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"rewards",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"stakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"stakes",outputs:[{internalType:"uint160",name:"secondsPerLiquidityInsideInitialX128",type:"uint160"},{internalType:"uint128",name:"liquidity",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"transferDeposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"unstakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"}]);function ej({removed:e,inRange:n}){const i=t.useTheme(),r={py:4,px:8,color:i.palette.success.main,borderRadius:4,backgroundColor:t.alpha(i.palette.success.main,.1),typography:"h6"};return e?G.jsx(t.Tooltip,{title:o.i18n._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.warning.main,backgroundColor:t.alpha(i.palette.warning.main,.1)}),children:o.i18n._({id:"D87pha",message:"Closed"})})}):n?G.jsx(t.Tooltip,{title:o.i18n._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:r,children:o.i18n._({id:"vOyUlD",message:"In range"})})}):G.jsx(t.Tooltip,{title:o.i18n._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.error.main,backgroundColor:t.alpha(i.palette.error.main,.1)}),children:o.i18n._({id:"i3Z+/Z",message:"Out of range"})})})}new uC([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"}],internalType:"struct ISwapRouter.ExactInputParams",name:"params",type:"tuple"}],name:"exactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactInputSingleParams",name:"params",type:"tuple"}],name:"exactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"}],internalType:"struct ISwapRouter.ExactOutputParams",name:"params",type:"tuple"}],name:"exactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactOutputSingleParams",name:"params",type:"tuple"}],name:"exactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}]);const tj=({token:e,amount:n})=>{var i;const o=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{address:null!==(i=null==e?void 0:e.address)&&void 0!==i?i:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:18,height:18,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body1",color:o.palette.text.primary},children:[Au({input:n.toSignificant(),decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),G.jsx(t.ButtonBase,{sx:{display:"flex",alignItems:"center",color:o.palette.text.secondary,"&:hover":{color:o.palette.text.primary}},onClick:()=>{window.open(np(e.chainId,null==e?void 0:e.address,"address"))},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{opacity:"0.5",fillRule:"evenodd",clipRule:"evenodd",d:"M3.33333 3.33333V12.6667H12.6667V8H14V12.6667C14 13.4 13.4 14 12.6667 14H3.33333C2.59333 14 2 13.4 2 12.6667V3.33333C2 2.6 2.59333 2 3.33333 2H8V3.33333H3.33333ZM9.33333 3.33333V2H14V6.66667H12.6667V4.27333L6.11333 10.8267L5.17333 9.88667L11.7267 3.33333H9.33333Z",fill:"currentColor"})})})]})},nj=({position:i,inRange:r})=>{var a;const s=t.useTheme(),l=i.pool.token0,d=i.pool.token1,c=i.pool.chainId,u=(null==i?void 0:i.liquidity)&&E.equal(null==i?void 0:i.liquidity,E.BigInt(0)),p=n.useMemo((()=>UC.getAddress(i.pool.token0,i.pool.token1,i.pool.fee,void 0,c?Tv[c]:void 0)),[c,i.pool.fee,i.pool.token0,i.pool.token1]);return G.jsxs(t.Box,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:s.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body2",color:s.palette.text.primary},children:[o.i18n._({id:"PVa3KL",message:"Position on"})," ",null==l?void 0:l.symbol,"/",null==d?void 0:d.symbol]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(ej,{removed:u,inRange:r}),G.jsx(t.Box,{sx:{py:4,px:8,color:s.palette.text.secondary,borderRadius:4,backgroundColor:s.palette.background.tag,typography:"h6"},children:Vu({input:(null===(a=null==i?void 0:i.pool)||void 0===a?void 0:a.fee)/1e6})})]})]}),G.jsxs(t.ButtonBase,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:s.palette.text.secondary,"&:hover":{color:s.palette.text.primary}},onClick:()=>{window.open(np(c,p,"address"))},children:[o.i18n._({id:"URmyfc",message:"Details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),G.jsxs(t.Box,{sx:{p:s.spacing(12,20)},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(t.Box,{sx:{mt:12},children:[G.jsx(tj,{token:l,amount:i.amount0}),G.jsx(tj,{token:d,amount:i.amount1})]})]})]})};function ij({price:e,atLimit:t,direction:n}){return t[n]?n===sv.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Au({input:"string"==typeof e?e:null==e?void 0:e.toSignificant(8),decimals:8})}const oj=({baseToken:e,quoteToken:n,handleRateToggle:i,sx:o})=>{const r=t.useTheme(),a=null==e?void 0:e.wrapped,s=null==n?void 0:n.wrapped,l=a&&s&&a.sortsBefore(s);return G.jsx(t.Box,{component:t.ButtonBase,onClick:i,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:r.palette.border.main},o),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:"auto"}},children:[G.jsx(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},l?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:l?e.symbol:null==n?void 0:n.symbol}),G.jsx(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},l?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:l?n.symbol:null==e?void 0:e.symbol})]})})},rj=({position:i,title:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{const s=i.pool.token0,l=i.pool.token1,d=t.useTheme(),[c,u]=n.useState(r?r===s?s:r===l?l:s:s),p=c===s,h=p?l:s,m=p?i.pool.priceOf(i.pool.token0):i.pool.priceOf(i.pool.token1),g=p?i.token0PriceLower:i.token0PriceUpper.invert(),x=p?i.token0PriceUpper:i.token0PriceLower.invert(),f=n.useCallback((()=>{u(h)}),[h]);return G.jsxs(mv,{gap:"md",children:[G.jsxs(xv,{children:[o?G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.secondary},children:o}):G.jsx("div",{}),G.jsx(oj,{baseToken:p?s:l,quoteToken:p?l:s,handleRateToggle:f})]}),G.jsxs(xv,{children:[G.jsxs(uv,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"EQs1sJ",message:"Min price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:ij({price:g,atLimit:a,direction:sv.LOWER})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==c?void 0:c.symbol}})})]}),G.jsxs(uv,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"5etEUX",message:"Max price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:ij({price:x,atLimit:a,direction:sv.UPPER})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==h?void 0:h.symbol}})})]})]}),G.jsxs(uv,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(mv,{gap:"4px",justify:"flex-start",children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"DWd30U",message:"Current price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:`${Au({input:m.toSignificant(8),decimals:8})} `})]})]})},aj=({chainId:e,disabled:n,removed:i,isLoading:r,error:a,onConfirm:s})=>G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:s,disabled:n,isLoading:r,children:i?o.i18n._({id:"D87pha",message:"Closed"}):null!=a?a:o.i18n._({id:"t/YqKh",message:"Remove"})})}),sj={[Yv.LOWEST]:{label:"0.01%"},[Yv.LOW_200]:{label:"0.02%"},[Yv.LOW_300]:{label:"0.03%"},[Yv.LOW_400]:{label:"0.04%"},[Yv.LOW]:{label:"0.05%"},[Yv.MEDIUM]:{label:"0.30%"},[Yv.HIGH]:{label:"1.00%"}},lj=({poolType:e})=>{const n="AMM V2"===e?t.lightPalette.error.main:"AMM V3"===e?t.lightPalette.purple.main:t.lightPalette.success.main;return G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:t.alpha(n,.1),color:n,whiteSpace:"nowrap"},children:e})},dj=({isAMMV2:n,isAMMV3:i,lpFeeRate:o,mtFeeRate:r})=>{var s,l;return G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:i?null!==(l=null===(s=sj[o])||void 0===s?void 0:s.label)&&void 0!==l?l:"-":Vu({input:new a(null!=o?o:0).plus(r?Mu(r,n?4:18):0)})})})},cj=({sx:e})=>G.jsx(lj,{poolType:"AMM V3"}),uj=({position:n,title:i,inRange:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{var s,l,d;const c=n.pool.token0,u=n.pool.token1,p=(null==n?void 0:n.liquidity)&&E.equal(null==n?void 0:n.liquidity,E.BigInt(0));return G.jsxs(mv,{gap:"md",style:{marginTop:"0.5rem"},children:[G.jsxs(xv,{style:{gap:4},children:[G.jsxs(fv,{children:[G.jsx(wy,{tokens:[{address:c.address},{address:u.address}],mr:8,chainId:c.chainId}),G.jsxs(t.Box,{sx:{typography:"h5"},children:[null==c?void 0:c.symbol," / ",null==u?void 0:u.symbol]})]}),G.jsx(cj,{sx:{ml:"auto"}}),G.jsx(ej,{removed:p,inRange:o})]}),G.jsxs(uv,{children:[G.jsxs(mv,{gap:"md",children:[G.jsxs(xv,{children:[G.jsxs(fv,{children:[G.jsx(Nh,{address:null!==(s=null==c?void 0:c.address)&&void 0!==s?s:"",chainId:null==c?void 0:c.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(t.Box,{sx:{ml:8},children:null==c?void 0:c.symbol})]}),G.jsx(fv,{children:G.jsx(t.Box,{sx:{mr:8},children:Au({input:n.amount0.toSignificant(),decimals:null==c?void 0:c.decimals})})})]}),G.jsxs(xv,{children:[G.jsxs(fv,{children:[G.jsx(Nh,{address:null!==(l=null==u?void 0:u.address)&&void 0!==l?l:"",chainId:null==u?void 0:u.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(t.Box,{ml:"8px",children:null==u?void 0:u.symbol})]}),G.jsx(fv,{children:G.jsx(t.Box,{mr:"8px",children:Au({input:n.amount1.toSignificant(),decimals:null==u?void 0:u.decimals})})})]})]}),G.jsxs(xv,{children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"})}),G.jsx(t.Box,{children:Vu({input:(null===(d=null==n?void 0:n.pool)||void 0===d?void 0:d.fee)/1e6})})]})]}),G.jsx(rj,{position:n,title:i,baseCurrencyDefault:r,ticksAtLimit:a})]})},pj=({on:e,onClose:n,position:i,outOfRange:r,ticksAtLimit:a,onConfirm:s,loading:l})=>{const{isMobile:d}=Bp();return G.jsx(Eh,{open:e,onClose:n,modal:!0,title:o.i18n._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:G.jsxs(t.Box,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:d?void 0:420},children:[G.jsx(t.Box,{sx:{pt:0,px:0},children:i?G.jsx(uj,{position:i,inRange:!r,ticksAtLimit:a,title:o.i18n._({id:"3VUfrF",message:"Selected Range"})}):null}),G.jsx(t.Button,{size:t.Button.Size.big,fullWidth:!0,isLoading:l,sx:{mt:20},onClick:s,children:o.i18n._({id:"m16xKo",message:"Add"})})]})})};class hj{static getPoolAddress(e,t,n,i,o){this.addresses.length>this.MAX_ENTRIES&&(this.addresses=this.addresses.slice(0,this.MAX_ENTRIES/2));const{address:r}=t,{address:a}=n,s=`${e}:${r}:${a}:${i.toString()}`,l=this.addresses.find((e=>e.key===s));if(l)return l.address;const d={key:s,address:pC({factoryAddress:e,tokenA:t,tokenB:n,fee:i,chainId:o})};return this.addresses.unshift(d),d.address}static getPool(e,t,n,i,o,r){this.pools.length>this.MAX_ENTRIES&&(this.pools=this.pools.slice(0,this.MAX_ENTRIES/2));const a=this.pools.find((a=>a.token0===e&&a.token1===t&&a.fee===n&&E.EQ(a.sqrtRatioX96,i)&&E.EQ(a.liquidity,o)&&a.tickCurrent===r));if(a)return a;const s=new UC(e,t,n,i,o,r);return this.pools.unshift(s),s}}var mj;function gj(e,t,i){const o=n.useMemo((()=>[[e,t,i]]),[e,t,i]);return function(e,t){const i=n.useMemo((()=>e?t.map((([e,t,n])=>{if(e&&t&&n){const i=e.wrapped,o=t.wrapped;if(i.equals(o))return;return i.sortsBefore(o)?[i,o,n]:[o,i,n]}})):new Array(t.length)),[e,t]),o=n.useMemo((()=>{const t=e&&Tv[e];return t?i.map((n=>n&&hj.getPoolAddress(t,...n,e))):new Array(i.length)}),[e,i]),{data:r}=d.useQueries({queries:o.map((t=>zu.getV3PoolSlot0(e,t))),combine:e=>({data:e.map((e=>e.data))})}),{data:a}=d.useQueries({queries:o.map((t=>zu.getV3PoolLiquidity(e,t))),combine:e=>({data:e.map((e=>e.data))})});return n.useMemo((()=>t.map(((e,t)=>{const n=i[t];if(!n)return[mj.INVALID,null];const[o,s,l]=n;if(!r[t])return[mj.NOT_EXISTS,null];const d=r[t];if(!a[t])return[mj.NOT_EXISTS,null];const c=a[t];if(!d||!c)return[mj.NOT_EXISTS,null];if(!d.sqrtPriceX96||d.sqrtPriceX96.eq(0))return[mj.NOT_EXISTS,null];try{const e=hj.getPool(o,s,l,d.sqrtPriceX96,c[0],d.tick);return[mj.EXISTS,e]}catch(e){return console.error(e,{tags:{file:"usePools",function:"usePools"},extra:{token0:o.address,token1:s.address,chainId:o.chainId,fee:l}}),[mj.NOT_EXISTS,null]}}))),[a,t,r,i])}(null==e?void 0:e.chainId,o)[0]}hj.MAX_ENTRIES=128,hj.pools=[],hj.addresses=[],function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(mj||(mj={}));class xj{constructor(e){const t=r.basicTokenMap[e];this.chainId=e,this.decimals=t.decimals,this.name=t.name,this.symbol=t.symbol,this.isNative=!0,this.isToken=!1,this.address=fj(this.chainId)}equals(e){return e.isNative&&e.chainId===this.chainId}get wrapped(){const e=r.basicTokenMap[this.chainId];return new qv(this.chainId,e.wrappedTokenAddress,e.decimals,e.wrappedTokenSymbol,e.name)}static onChain(e){var t;return null!==(t=this._cachedNativeCurrency[e])&&void 0!==t?t:this._cachedNativeCurrency[e]=new xj(e)}}function fj(e){return r.basicTokenMap[e].address}function yj(e,t){const n=null==e?void 0:e.toLowerCase(),i=null==t?void 0:t.toLowerCase();return null!==n&&null!==i&&n===i}xj._cachedNativeCurrency={};const vj=(e,t)=>!t||yj(t,fj(e));function bj(e){if(!e)return;const{name:t,chainId:n,address:i,decimals:o,symbol:r}=e;return function(e,t){return!vj(e,t)}(n,i)?new qv(n,i,o,null!=r?r:void 0,null!=t?t:void 0):new xj(n)}function Cj(e){var t,n;if(e)return{chainId:e.chainId,address:e.address,decimals:e.decimals,symbol:null!==(t=e.symbol)&&void 0!==t?t:"",name:null!==(n=e.name)&&void 0!==n?n:""}}function jj(e,t,n){if(e&&t&&"number"==typeof n)return PC(e,t,n)}function wj(e,t){if(e&&t&&!isNaN(parseFloat(e)))try{const n=L.parseUnits(function(e,t){const n=e.split(/[.,]/),i=e.includes(".")?".":",";return n.length>1&&n[1].length>t?n[0]+i+n[1].slice(0,t):e}(e,t.decimals),t.decimals).toString();if("0"!==n)return Rv.fromRawAmount(t,E.BigInt(n))}catch(t){console.error("tryParseCurrencyAmount","tryParseCurrencyAmount",`Failed to parse input amount: "${e}"`,t)}}function kj(e,t,n,i){if(!(e&&t&&n&&i))return;const o=function(e,t,n){var i;if(!e||!t||!n)return;if(!n.match(/^\d*\.?\d+$/))return;const[o,r]=n.split("."),a=null!==(i=null==r?void 0:r.length)&&void 0!==i?i:0,s=E.BigInt((null!=o?o:"")+(null!=r?r:""));return new Nv(e,t,E.multiply(E.BigInt(10**a),E.BigInt(10**e.decimals)),E.multiply(s,E.BigInt(10**t.decimals)))}(e,t,i);if(!o)return;let r;const a=AC(o.numerator,o.denominator);return r=E.greaterThanOrEqual(a,fC.MAX_SQRT_RATIO)?fC.MAX_TICK:E.lessThanOrEqual(a,fC.MIN_SQRT_RATIO)?fC.MIN_TICK:_C(o),MC(r,Kv[n])}function Tj({state:e,existingPosition:t,chainId:i}){var r,a,s,l,c,u,p,h,m,g,x,f,y;const{account:v}=cp(),{feeAmount:b,independentField:C,typedValue:j,leftRangeTypedValue:w,rightRangeTypedValue:k,startPriceTypedValue:T}=e,B=null!==(r=e.baseToken)&&void 0!==r?r:void 0,I=null!==(a=e.baseToken)&&void 0!==a?a:void 0,S=null!==(s=e.quoteToken)&&void 0!==s?s:void 0,A=C===av.CURRENCY_A?av.CURRENCY_B:av.CURRENCY_A,O=n.useMemo((()=>({[av.CURRENCY_A]:B,[av.CURRENCY_B]:S})),[B,S]),[L,R,M]=n.useMemo((()=>[null==B?void 0:B.wrapped,null==S?void 0:S.wrapped,null==I?void 0:I.wrapped]),[B,S,I]),[P,_]=n.useMemo((()=>L&&R?L.sortsBefore(R)?[L,R]:[R,L]:[void 0,void 0]),[L,R]),N=d.useQuery(id.getFetchTokenQuery(null===(l=O[av.CURRENCY_A])||void 0===l?void 0:l.chainId,null===(c=O[av.CURRENCY_A])||void 0===c?void 0:c.address,v)),D=d.useQuery(id.getFetchTokenQuery(null===(u=O[av.CURRENCY_B])||void 0===u?void 0:u.chainId,null===(p=O[av.CURRENCY_B])||void 0===p?void 0:p.address,v)),F=n.useMemo((()=>{var e,t,n,i,o,r;return{[av.CURRENCY_A]:O[av.CURRENCY_A]?(null===(e=N.data)||void 0===e?void 0:e.balance)?Rv.fromRawAmount(O[av.CURRENCY_A],E.BigInt(null===(t=N.data)||void 0===t?void 0:t.balance.multipliedBy(Math.pow(10,null!==(n=O[av.CURRENCY_A].decimals)&&void 0!==n?n:18)).toString())):Rv.fromRawAmount(O[av.CURRENCY_A],0):void 0,[av.CURRENCY_B]:O[av.CURRENCY_B]?(null===(i=D.data)||void 0===i?void 0:i.balance)?Rv.fromRawAmount(O[av.CURRENCY_B],E.BigInt(null===(o=D.data)||void 0===o?void 0:o.balance.multipliedBy(Math.pow(10,null!==(r=O[av.CURRENCY_B].decimals)&&void 0!==r?r:18)).toString())):Rv.fromRawAmount(O[av.CURRENCY_B],0):void 0}}),[O,null===(h=N.data)||void 0===h?void 0:h.balance,null===(m=D.data)||void 0===m?void 0:m.balance]),[U,q]=gj(O[av.CURRENCY_A],O[av.CURRENCY_B],b),V=U===mj.NOT_EXISTS,H=Boolean(M&&P&&!M.equals(P)),W=n.useMemo((()=>{var e;if(!V)return q&&P?q.priceOf(P):void 0;{const t=wj(T,H?P:_);if(t&&P&&_){const n=wj("1",H?_:P),i=n&&t?new Nv(n.currency,t.currency,n.quotient,t.quotient):void 0;return null!==(e=H?null==i?void 0:i.invert():i)&&void 0!==e?e:void 0}}}),[V,T,H,_,P,q]),$=n.useMemo((()=>{const e=W?AC(W.numerator,W.denominator):void 0;return W&&e&&!(E.greaterThanOrEqual(e,fC.MIN_SQRT_RATIO)&&E.lessThan(e,fC.MAX_SQRT_RATIO))}),[W]),z=n.useMemo((()=>{if(L&&R&&b&&W&&!$){const e=_C(W),t=fC.getSqrtRatioAtTick(e);return new UC(L,R,b,t,E.BigInt(0),e,[])}}),[b,$,W,L,R]),Z=null!=q?q:z,Q=n.useMemo((()=>({[sv.LOWER]:b?MC(fC.MIN_TICK,Kv[b]):void 0,[sv.UPPER]:b?MC(fC.MAX_TICK,Kv[b]):void 0})),[b]),G=n.useMemo((()=>({[sv.LOWER]:"number"==typeof(null==t?void 0:t.tickLower)?t.tickLower:H&&"boolean"==typeof k||!H&&"boolean"==typeof w?Q[sv.LOWER]:H?kj(_,P,b,k.toString()):kj(P,_,b,w.toString()),[sv.UPPER]:"number"==typeof(null==t?void 0:t.tickUpper)?t.tickUpper:!H&&"boolean"==typeof k||H&&"boolean"==typeof w?Q[sv.UPPER]:H?kj(_,P,b,w.toString()):kj(P,_,b,k.toString())})),[t,b,H,w,k,Q,P,_]),{[sv.LOWER]:Y,[sv.UPPER]:K}=G||{},X=n.useMemo((()=>({[sv.LOWER]:b&&Y===Q.LOWER,[sv.UPPER]:b&&K===Q.UPPER})),[Q,Y,K,b]),J=Boolean("number"==typeof Y&&"number"==typeof K&&Y>=K),ee=n.useMemo((()=>({[sv.LOWER]:jj(P,_,Q.LOWER),[sv.UPPER]:jj(P,_,Q.UPPER)})),[P,_,Q.LOWER,Q.UPPER]),te=n.useMemo((()=>({[sv.LOWER]:jj(P,_,G[sv.LOWER]),[sv.UPPER]:jj(P,_,G[sv.UPPER])})),[P,_,G]),{[sv.LOWER]:ne,[sv.UPPER]:ie}=te,oe=Boolean(!J&&W&&ne&&ie&&(W.lessThan(ne)||W.greaterThan(ie))),re=wj(j,O[C]),ae=n.useMemo((()=>{const e=null==re?void 0:re.wrapped,t=A===av.CURRENCY_B?S:B;if(re&&e&&"number"==typeof Y&&"number"==typeof K&&Z){if(oe||J)return;const n=e.currency.equals(Z.token0)?qC.fromAmount0({pool:Z,tickLower:Y,tickUpper:K,amount0:re.quotient,useFullPrecision:!0}):qC.fromAmount1({pool:Z,tickLower:Y,tickUpper:K,amount1:re.quotient}),i=e.currency.equals(Z.token0)?n.amount1:n.amount0;return t&&Rv.fromRawAmount(t,i.quotient)}}),[re,oe,A,S,B,Y,K,Z,J]),se=n.useMemo((()=>({[av.CURRENCY_A]:C===av.CURRENCY_A?re:ae,[av.CURRENCY_B]:C===av.CURRENCY_A?ae:re})),[ae,re,C]),le=Boolean("number"==typeof K&&Z&&Z.tickCurrent>=K),de=Boolean("number"==typeof Y&&Z&&Z.tickCurrent<=Y),ce=J||Boolean(le&&Z&&L&&Z.token0.equals(L)||de&&Z&&L&&Z.token1.equals(L)),ue=J||Boolean(le&&Z&&R&&Z.token0.equals(R)||de&&Z&&R&&Z.token1.equals(R)),{inputTax:pe,outputTax:he}=function(e,t,i){const[{inputTax:o,outputTax:r},a]=n.useState({inputTax:Qv,outputTax:Qv});return{inputTax:o,outputTax:r}}((null==B?void 0:B.isToken)&&B.address,(null==S?void 0:S.isToken)&&S.address),me=n.useMemo((()=>{var e,t;if(!Z||!L||!R||"number"!=typeof Y||"number"!=typeof K||J)return;const n=le?zv:null===(e=null==se?void 0:se[L.equals(Z.token0)?av.CURRENCY_A:av.CURRENCY_B])||void 0===e?void 0:e.quotient,i=de?zv:null===(t=null==se?void 0:se[L.equals(Z.token0)?av.CURRENCY_B:av.CURRENCY_A])||void 0===t?void 0:t.quotient;return void 0!==n&&void 0!==i?qC.fromAmounts({pool:Z,tickLower:Y,tickUpper:K,amount0:n,amount1:i,useFullPrecision:!0}):void 0}),[se,Z,L,R,le,de,J,Y,K]);let ge;v||(ge=o.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),U===mj.INVALID&&(ge=null!=ge?ge:o.i18n._({id:"R7D79P",message:"Invalid pair"})),$&&(ge=null!=ge?ge:o.i18n._({id:"HXBqgG",message:"Invalid price input"})),(se[av.CURRENCY_A]||ce)&&(se[av.CURRENCY_B]||ue)||(ge=null!=ge?ge:o.i18n._({id:"iPMIoT",message:"Enter an amount"}));const{[av.CURRENCY_A]:xe,[av.CURRENCY_B]:fe}=se;xe&&(null===(g=null==F?void 0:F[av.CURRENCY_A])||void 0===g?void 0:g.lessThan(xe))&&(ge=o.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(x=O[av.CURRENCY_A])||void 0===x?void 0:x.symbol}})),fe&&(null===(f=null==F?void 0:F[av.CURRENCY_B])||void 0===f?void 0:f.lessThan(fe))&&(ge=o.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(y=O[av.CURRENCY_B])||void 0===y?void 0:y.symbol}}));const ye=pe.greaterThan(0)||he.greaterThan(0),ve=U===mj.INVALID||ye;return{dependentField:A,currencies:O,pool:q,poolState:U,currencyBalances:F,parsedAmounts:se,ticks:G,price:W,pricesAtTicks:te,pricesAtLimit:ee,position:me,noLiquidity:V,errorMessage:ge,invalidPool:ve,invalidRange:J,outOfRange:oe,depositADisabled:ce,depositBDisabled:ue,invertPrice:H,ticksAtLimit:X,isTaxed:ye}}var Bj;function Ij(e,t){switch(t.type){case Bj.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:bj(n)})}case Bj.UpdateDefaultBaseToken:{const n=t.payload;return e.baseToken?e:Object.assign(Object.assign({},e),{baseToken:bj(n)})}case Bj.UpdateQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{quoteToken:bj(n)})}case Bj.UpdateDefaultQuoteToken:{const n=t.payload;return e.quoteToken?e:Object.assign(Object.assign({},e),{quoteToken:bj(n)})}case Bj.UpdateBaseTokenAndClearQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:bj(n),quoteToken:null})}case Bj.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case Bj.ToggleRate:{const{baseToken:t,quoteToken:n}=e;return Object.assign(Object.assign({},e),{baseToken:n,quoteToken:t})}case Bj.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case Bj.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case Bj.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case Bj.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case Bj.typeInput:{const{payload:{field:n,typedValue:i,noLiquidity:o}}=t;return o?(e.independentField,Object.assign(Object.assign({},e),{independentField:n,typedValue:i})):Object.assign(Object.assign({},e),{independentField:n,typedValue:i})}default:throw Error("Unknown action: "+t.type)}}function Sj({noLiquidity:e,dispatch:t}){return{onFieldAInput:n.useCallback((n=>{t({type:Bj.typeInput,payload:{field:av.CURRENCY_A,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onFieldBInput:n.useCallback((n=>{t({type:Bj.typeInput,payload:{field:av.CURRENCY_B,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onLeftRangeInput:n.useCallback((e=>{t({type:Bj.typeLeftRangeInput,payload:{typedValue:e}})}),[t]),onRightRangeInput:n.useCallback((e=>{t({type:Bj.typeRightRangeInput,payload:{typedValue:e}})}),[t]),onStartPriceInput:n.useCallback((e=>{t({type:Bj.typeStartPriceInput,payload:{typedValue:e}})}),[t])}}function Aj(e){return e?Bv[e]:void 0}function Ej(e,t){const i=Aj(t),o=n.useMemo((()=>e?e.map((e=>[e])):[]),[e]),r=d.useQuery(zu.getPositions(t,i,o)),a=r.isLoading,s=r.error,l=n.useMemo((()=>{var t;if(!a&&!s&&e)return null===(t=r.data)||void 0===t?void 0:t.map(((t,n)=>({tokenId:e[n],fee:t.fee,feeGrowthInside0LastX128:t.feeGrowthInside0LastX128.toString(),feeGrowthInside1LastX128:t.feeGrowthInside1LastX128.toString(),liquidity:t.liquidity.toString(),nonce:t.nonce.toString(),operator:t.operator,tickLower:t.tickLower,tickUpper:t.tickUpper,token0:t.token0,token1:t.token1,tokensOwed0:t.tokensOwed0.toString(),tokensOwed1:t.tokensOwed1.toString()})))}),[a,s,r,e]);return{loading:a,positions:null==l?void 0:l.map(((e,t)=>Object.assign(Object.assign({},e),{tokenId:o[t][0]})))}}!function(e){e[e.UpdateBaseToken=0]="UpdateBaseToken",e[e.UpdateDefaultBaseToken=1]="UpdateDefaultBaseToken",e[e.UpdateQuoteToken=2]="UpdateQuoteToken",e[e.UpdateDefaultQuoteToken=3]="UpdateDefaultQuoteToken",e[e.UpdateBaseTokenAndClearQuoteToken=4]="UpdateBaseTokenAndClearQuoteToken",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.ToggleRate=6]="ToggleRate",e[e.setFullRange=7]="setFullRange",e[e.typeStartPriceInput=8]="typeStartPriceInput",e[e.typeLeftRangeInput=9]="typeLeftRangeInput",e[e.typeRightRangeInput=10]="typeRightRangeInput",e[e.typeInput=11]="typeInput"}(Bj||(Bj={}));const Oj=E.exponentiate(E.BigInt(10),E.BigInt(16));function Lj(e){if(e)return e.currency.isNative?E.greaterThan(e.quotient,Oj)?Rv.fromRawAmount(e.currency,E.subtract(e.quotient,Oj)):Rv.fromRawAmount(e.currency,E.BigInt(0)):e}const Rj=1e4,Mj=100*Rj;function Pj(e){const t=Math.floor(Number(e)*Rj);return new _v(t,Mj)}const _j=({token:e,amount:n})=>{var i;const o=t.useTheme();return G.jsxs(t.Box,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:o.palette.text.primary},children:[G.jsx(Nh,{address:null!==(i=null==e?void 0:e.address)&&void 0!==i?i:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),G.jsx(t.Box,{children:null==e?void 0:e.symbol}),G.jsx(t.Box,{sx:{ml:"auto"},children:Au({input:null==n?void 0:n.toSignificant(),decimals:null==e?void 0:e.decimals})})]})},Nj=({chainId:e,baseToken:i,quoteToken:s,feeAmount:l,tokenId:c,onClose:u})=>{var p,h;const{isMobile:m}=Bp(),g=t.useTheme(),f=Up(),y=d.useQueryClient(),{account:v}=cp(),{position:b,loading:C}=function(e,t){var n;const i=Ej(e?[e]:void 0,t);return{loading:i.loading,position:null===(n=i.positions)||void 0===n?void 0:n[0]}}(c,e),j=!!b&&!C,{position:w}=function(e,t,i){const o=n.useMemo((()=>t?bj(t):void 0),[t]),r=n.useMemo((()=>i?bj(i):void 0),[i]),[,a]=gj(null!=o?o:void 0,null!=r?r:void 0,null==e?void 0:e.fee);let s;return a&&e&&(s=new qC({pool:a,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})),{position:s,pool:null!=a?a:void 0}}(b,i,s),[k,T]=n.useState("stake"),[B,I]=n.useState(!1),[S,A]=n.useState(ov),[E,O]=n.useReducer(Ij,{baseToken:bj(i),quoteToken:bj(s),feeAmount:l,independentField:av.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""}),{independentField:L,typedValue:R,startPriceTypedValue:M}=E,{pool:P,ticks:_,dependentField:N,price:D,pricesAtTicks:F,pricesAtLimit:U,parsedAmounts:V,currencyBalances:H,position:W,noLiquidity:$,currencies:z,errorMessage:Z,invalidPool:Q,invalidRange:Y,outOfRange:K,depositADisabled:J,depositBDisabled:ee,invertPrice:te,ticksAtLimit:ne,isTaxed:ie}=Tj({state:E,existingPosition:w,chainId:e}),{position:oe,liquidityPercentage:re,liquidityValue0:ae,liquidityValue1:le,feeValue0:de,feeValue1:ce,error:ue}=function({percent:e,position:t,asWETH:i,baseToken:r,quoteToken:a}){const{account:s}=cp(),[l,d]=n.useMemo((()=>[null==r?void 0:r.wrapped,null==a?void 0:a.wrapped]),[r,a]),[c,u]=n.useMemo((()=>l&&d?l.sortsBefore(d)?[l,d]:[d,l]:[void 0,void 0]),[l,d]),[,p]=gj(null!=c?c:void 0,null!=u?u:void 0,null==t?void 0:t.fee),h=n.useMemo((()=>p&&(null==t?void 0:t.liquidity)&&"number"==typeof(null==t?void 0:t.tickLower)&&"number"==typeof(null==t?void 0:t.tickUpper)?new qC({pool:p,liquidity:t.liquidity.toString(),tickLower:t.tickLower,tickUpper:t.tickUpper}):void 0),[p,t]),m=new _v(e,100),g=h?m.multiply(h.amount0.quotient).quotient:void 0,x=h?m.multiply(h.amount1.quotient).quotient:void 0,f=c&&g?Rv.fromRawAmount(c,g):void 0,y=u&&x?Rv.fromRawAmount(u,x):void 0,v=!(!p||!t)&&(p.tickCurrent<t.tickLower||p.tickCurrent>t.tickUpper);let b;return s||(b=o.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),0===e&&(b=null!=b?b:o.i18n._({id:"Sta9CR",message:"Enter a percent"})),{position:h,liquidityPercentage:m,liquidityValue0:f,liquidityValue1:y,feeValue0:void 0,feeValue1:void 0,outOfRange:v,error:b}}({position:b,asWETH:void 0,percent:S,baseToken:E.baseToken,quoteToken:E.quoteToken}),pe="0"===(null==b?void 0:b.liquidity),[he,me]=function({chainId:e,pool:t,tokenId:n,asWETH:i}){var o;const r=Aj(e),a=null===(o=x.BigNumber.from(n))||void 0===o?void 0:o.toHexString(),s=d.useQuery(zu.getOwner(e,r,n)),l=d.useQuery(zu.getCollect(e,r,a,s.data&&Array.isArray(s.data)?s.data[0]:void 0));return t&&l&&l.data&&l.data.amount0&&l.data.amount1?[Rv.fromRawAmount(t.token0,l.data.amount0.toString()),Rv.fromRawAmount(t.token1,l.data.amount1.toString())]:[void 0,void 0]}({pool:null!=P?P:void 0,tokenId:c,asWETH:!1,chainId:e}),ge=me,xe=he;n.useMemo((()=>{var e;return null===(e=te?null==D?void 0:D.invert():D)||void 0===e?void 0:e.toSignificant()}),[te,D]);const{onFieldAInput:fe,onFieldBInput:ye,onLeftRangeInput:ve,onRightRangeInput:be,onStartPriceInput:Ce}=Sj({noLiquidity:$,dispatch:O}),{slipper:je,setSlipper:we,slipperValue:ke,resetSlipper:Te}=nv({address:void 0,type:"AMMV3"}),Be=!Z&&!Y,Ie=n.useMemo((()=>{var e,t;return{[L]:R,[N]:null!==(t=null===(e=V[N])||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""}}),[N,L,V,R]),Se=n.useMemo((()=>[av.CURRENCY_A,av.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:Lj(H[t])})),{})),[H]),Ae=lh(Cj(null===(p=V[av.CURRENCY_A])||void 0===p?void 0:p.currency),{contractAddress:Bv[e],overrideBalance:H[av.CURRENCY_A]?new a(H[av.CURRENCY_A].toSignificant()):void 0,amount:V[av.CURRENCY_A]?new a(V[av.CURRENCY_A].toSignificant()):void 0}),Ee=lh(Cj(null===(h=V[av.CURRENCY_B])||void 0===h?void 0:h.currency),{contractAddress:Bv[e],overrideBalance:H[av.CURRENCY_B]?new a(H[av.CURRENCY_B].toSignificant()):void 0,amount:V[av.CURRENCY_B]?new a(V[av.CURRENCY_B].toSignificant()):void 0}),{[sv.LOWER]:Oe,[sv.UPPER]:Le}=_,{[sv.LOWER]:Re,[sv.UPPER]:Me}=F,{deadLine:Pe}=X(),_e=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(!v||!e||!W)return;if(!E.baseToken||!E.quoteToken)return;const t=Math.ceil(Date.now()/1e3)+(null!=Pe?Pe:600),n=E.baseToken.isNative?E.baseToken:E.quoteToken.isNative?E.quoteToken:void 0;try{const{calldata:i,value:a}=XC.addCallParameters(W,{tokenId:c,slippageTolerance:Pj(100*ke),deadline:t.toString(),useNative:n});let s={to:Bv[e],data:i,value:a};(yield f.execute(o.i18n._({id:"OBdohg",message:"Add Liquidity"}),Object.assign({opcode:Mp.TX},s),{early:!1,metadata:{[exports.MetadataFlag.addAMMV3Pool]:"1"}}))===Ap.Success&&(I(!1),setTimeout((()=>{null==u||u()}),100)),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onAddMutation",e)}}))}),Ne=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(!(v&&e&&oe&&re&&ae&&le))return;const t=Math.ceil(Date.now()/1e3)+(null!=Pe?Pe:600);try{const{calldata:n,value:i}=XC.removeCallParameters(oe,{tokenId:c.toString(),liquidityPercentage:re,slippageTolerance:Pj(100*ke),deadline:t.toString(),collectOptions:{expectedCurrencyOwed0:null!=de?de:Rv.fromRawAmount(ae.currency,0),expectedCurrencyOwed1:null!=ce?ce:Rv.fromRawAmount(le.currency,0),recipient:v}});let a={to:Bv[e],data:n,value:i};(yield f.execute(o.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),Object.assign({opcode:Mp.TX},a),{early:!1,metadata:{[exports.MetadataFlag.removeAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{null==u||u()}),100),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onRemoveMutation",e)}}))}),De=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(v&&e&&P)try{const{calldata:t,value:n}=XC.collectCallParameters({tokenId:c.toString(),expectedCurrencyOwed0:null!=he?he:Rv.fromRawAmount(P.token0,0),expectedCurrencyOwed1:null!=me?me:Rv.fromRawAmount(P.token1,0),recipient:v});let i={to:Bv[e],data:t,value:n};(yield f.execute(o.i18n._({id:"zXCpR0",message:"Claim Rewards"}),Object.assign({opcode:Mp.TX},i),{early:!1,metadata:{[exports.MetadataFlag.claimAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{null==u||u()}),100),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onClaimMutation",e)}}))}),Fe=n.useMemo((()=>{var n,i,r,a;const s=[{key:"stake",value:o.i18n._({id:"m16xKo",message:"Add"})},{key:"unstake",value:o.i18n._({id:"t/YqKh",message:"Remove"})},{key:"claim",value:o.i18n._({id:"hom7qf",message:"Claim"})}];return G.jsxs(t.Box,{sx:{borderRadius:16,backgroundColor:g.palette.background.paper},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:g.palette.background.paper},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:o.i18n._({id:"E6MqGy",message:"Add liquidity"})}),u?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{u()}})}):void 0]}),j&&w&&G.jsx(t.Box,{sx:{mx:20,mb:16},children:G.jsx(nj,{position:w,inRange:!K})}),G.jsxs(t.Tabs,{value:k,onChange:(e,t)=>{T(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:s,variant:"inPaper",tabsListSx:{mx:20}}),G.jsxs(t.TabPanel,{value:"stake",children:[j&&w&&G.jsx(t.Box,{sx:{mt:16,mx:20},children:G.jsx(rj,{position:w,title:o.i18n._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:ne})}),G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.secondary,textAlign:"left"},children:o.i18n._({id:"BRi+RY",message:"Add more liquidity"})}),G.jsxs(t.Box,{children:[G.jsx(kv,{value:Ie[av.CURRENCY_A],onUserInput:fe,maxAmount:Se[av.CURRENCY_A],balance:H[av.CURRENCY_A],currency:null!==(n=z[av.CURRENCY_A])&&void 0!==n?n:null,locked:J}),G.jsx(cy,{}),G.jsx(kv,{value:Ie[av.CURRENCY_B],onUserInput:ye,maxAmount:Se[av.CURRENCY_B],balance:H[av.CURRENCY_B],currency:null!==(i=z[av.CURRENCY_B])&&void 0!==i?i:null,locked:ee})]}),G.jsx(iv,{value:je,onChange:we,disabled:!1,type:"AMMV3"})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(vv,{chainId:e,approvalA:Ae,approvalB:Ee,parsedAmounts:V,isValid:Be,depositADisabled:J,depositBDisabled:ee,errorMessage:Z,setShowConfirm:I})}),G.jsx(pj,{parsedAmounts:V,position:W,existingPosition:void 0,priceLower:Re,priceUpper:Me,outOfRange:K,ticksAtLimit:ne,on:B,onClose:()=>{I(!1)},onConfirm:_e.mutate,loading:_e.isPending})]}),G.jsxs(t.TabPanel,{value:"unstake",children:[G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(Gy,{disabled:!1,value:S,onChange:e=>A(e)}),G.jsx(iv,{value:je,onChange:we,disabled:!1,type:"AMMV3"})]}),G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:g.palette.text.secondary},children:"Receive"}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:[G.jsx(t.Box,{component:"span",sx:{color:g.palette.primary.main},children:ae?Au({input:ae.toExact(),decimals:ae.currency.decimals}):"-"})," ",null===(r=null==ae?void 0:ae.currency)||void 0===r?void 0:r.symbol]}),G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:[G.jsx(t.Box,{component:"span",sx:{color:g.palette.primary.main},children:le?Au({input:le.toExact(),decimals:le.currency.decimals}):"-"})," ",null===(a=null==le?void 0:le.currency)||void 0===a?void 0:a.symbol]})]})]}),G.jsx(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(aj,{chainId:e,disabled:pe||0===S||!ae,removed:pe,error:ue,onConfirm:Ne.mutate,isLoading:Ne.isPending})})]}),G.jsxs(t.TabPanel,{value:"claim",children:[G.jsxs(t.Box,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:g.palette.border.main},children:[G.jsx(t.Box,{sx:{py:12,px:20,typography:"body1",color:g.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:g.palette.border.main},children:o.i18n._({id:"tu/fxg",message:"Claim fees"})}),G.jsxs(t.Box,{sx:{p:20},children:[G.jsx(_j,{token:null==ge?void 0:ge.currency,amount:ge}),G.jsx(_j,{token:null==xe?void 0:xe.currency,amount:xe})]})]}),G.jsx(t.Box,{sx:{mx:20,mt:16,typography:"h6",color:g.palette.text.secondary},children:o.i18n._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),G.jsx(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(bv,{chainId:e,disabled:De.isPending,onConfirm:De.mutate,isLoading:De.isPending})})]})]})]})}),[Ae,Ee,e,z,H,J,ee,ue,Z,w,xe,ge,Ie,j,Be,ae,le,Se,_e.isPending,_e.mutate,De.isPending,De.mutate,u,fe,ye,Ne.isPending,Ne.mutate,k,K,V,W,Re,Me,pe,we,B,S,je,g.palette.background.paper,g.palette.border.main,g.palette.primary.main,g.palette.text.primary,g.palette.text.secondary,ne]);return m?G.jsx(Eh,{open:null!=i&&null!=s,onClose:u,scope:!m,modal:m,id:"pool-operate",children:Fe}):Fe};const Dj=({outOfRange:e})=>{const n=t.useTheme();return G.jsx(t.Tooltip,{title:e?o.i18n._({id:"i3Z+/Z",message:"Out of range"}):o.i18n._({id:"vOyUlD",message:"In range"}),children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.583252 12.5416L6.99992 1.45825L13.4166 12.5416H0.583252ZM11.3924 11.3749L6.9999 3.78575L2.6074 11.3749H11.3924ZM7.58328 9.62492H6.41661V10.7916H7.58328V9.62492ZM6.41661 6.12492H7.58328V8.45825H6.41661V6.12492Z",fill:n.palette.warning.main})}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:G.jsx("circle",{cx:"4",cy:"4",r:"4",fill:n.palette.success.main})})})})},Fj=({p:e,currency0:i,currency1:r,onClickManage:a})=>{const s=t.useTheme(),[,l]=gj(null!=i?i:void 0,null!=r?r:void 0,e.fee),d=n.useMemo((()=>{if(l)return new qC({pool:l,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})}),[e.liquidity,e.tickLower,e.tickUpper,l]),c=(u=e.fee,p=e.tickLower,h=e.tickUpper,n.useMemo((()=>({[sv.LOWER]:u&&p?p===MC(fC.MIN_TICK,Kv[u]):void 0,[sv.UPPER]:u&&h?h===MC(fC.MAX_TICK,Kv[u]):void 0})),[u,p,h]));var u,p,h;const m=null==d?void 0:d.token0PriceLower,g=null==d?void 0:d.token0PriceUpper,x=null==d?void 0:d.amount1.currency,f=null==d?void 0:d.amount0.currency,y=!!l&&(l.tickCurrent<e.tickLower||l.tickCurrent>=e.tickUpper),v=i==i?null==d?void 0:d.pool.priceOf(null==d?void 0:d.pool.token0):null==d?void 0:d.pool.priceOf(null==d?void 0:d.pool.token1);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:s.palette.background.paperContrast},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:s.palette.text.primary},children:[G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:m,atLimit:c,direction:sv.LOWER})," "]}),null==x?void 0:x.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:g,atLimit:c,direction:sv.UPPER})," "]}),null==x?void 0:x.symbol]})})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Dj,{outOfRange:y}),G.jsxs(t.Box,{sx:{typography:"h6",color:s.palette.text.secondary},children:[o.i18n._({id:"DWd30U",message:"Current price"}),": ",`${Au({input:null==v?void 0:v.toSignificant(8),decimals:8})}`," ",null==x?void 0:x.symbol," per ",null==f?void 0:f.symbol]})]})]}),G.jsx(t.Button,{variant:t.Button.Variant.outlined,size:t.Button.Size.small,fullWidth:!0,onClick:a,children:o.i18n._({id:"wckWOP",message:"Manage"})})]})},Uj=({chainId:e,baseToken:i,quoteToken:r,feeAmount:a,onClose:s,handleGoToAddLiquidityV3:l})=>{const{isMobile:c}=Bp(),u=t.useTheme(),{account:p}=cp(),{positions:h,loading:m}=function(e,t){const i=Aj(t),{isLoading:o,data:r}=d.useQuery(zu.getBalanceOf(t,i,null!=e?e:void 0)),a=n.useMemo((()=>{if(e&&r&&r.isFinite()){const t=[];for(let n=0;n<r.toNumber();n++)t.push([e,n]);return t}return[]}),[e,r]),s=d.useQuery(zu.getTokenOfOwnerByIndex(t,i,a)),l=s.isLoading,c=n.useMemo((()=>e&&s.data?s.data.map((e=>{if(Array.isArray(e)&&e.length>0)return e[0].toString()})):[]),[e,s]),{positions:u,loading:p}=Ej(c,t);return{loading:l||o||p,positions:u}}(p,e),g=n.useMemo((()=>i?bj(i):void 0),[i]),x=n.useMemo((()=>r?bj(r):void 0),[r]),[f,y]=n.useMemo((()=>[null==g?void 0:g.wrapped,null==x?void 0:x.wrapped]),[g,x]),[v,b]=n.useMemo((()=>f&&y?f.sortsBefore(y)?[f,y]:[y,f]:[void 0,void 0]),[f,y]),C=n.useMemo((()=>{if(void 0!==h)return h.filter((e=>yj(null==v?void 0:v.address,e.token0)&&yj(null==b?void 0:b.address,e.token1)&&e.fee===a))}),[a,h,null==v?void 0:v.address,null==b?void 0:b.address]),[j,w]=n.useState(null),k=n.useMemo((()=>{var e;return G.jsxs(t.Box,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:u.palette.background.paper,minHeight:480},children:[G.jsxs(t.Box,{sx:{pb:16,borderBottomColor:u.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[o.i18n._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==C?void 0:C.length)&&void 0!==e?e:0,")"]}),s?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{s()}})}):void 0]}),C&&C.length>0?G.jsxs(G.Fragment,{children:[null==C?void 0:C.map((e=>G.jsx(Fj,{p:e,currency0:g,currency1:x,onClickManage:()=>{w(e)}},e.tokenId))),G.jsxs(t.Button,{size:t.Button.Size.big,variant:t.Button.Variant.second,onClick:()=>{l({from:i.address,to:r.address,fee:String(a)})},sx:{gap:8},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:G.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),o.i18n._({id:"FQ4aT9",message:"Add Position"})]})]}):G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[G.jsx(J,{sx:{width:60,height:60,borderRadius:24/105*60}}),G.jsx(t.Box,{sx:{typography:"body1",color:u.palette.text.secondary},children:o.i18n._({id:"/6L4mj",message:"Your position is empty"})})]}),G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:void 0!==C&&0===C.length?G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({from:i.address,to:r.address,fee:String(a)})},children:o.i18n._({id:"FQ4aT9",message:"Add Position"})}):G.jsx(lv,{size:t.Button.Size.small})})]})]})}),[u.palette.background.paper,u.palette.border.main,u.palette.text.primary,u.palette.text.secondary,C,s,g,x,l,i.address,r.address,a]);return null!==j?G.jsx(Nj,{baseToken:i,quoteToken:r,feeAmount:a,tokenId:j.tokenId,chainId:e,onClose:()=>{w(null)}}):c?G.jsx(Eh,{open:null!=i&&null!=r,onClose:s,scope:!c,modal:c,id:"pool-operate",children:k}):k};function qj({children:e,sx:n,gap:i=20,repeatBaseForLargeScreen:o=3}){const{isMobile:r,minDevice:a}=Bp();let s={};if(r)s={display:"flex",flexDirection:"column",gap:i};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=o+n,!0})),s={display:"grid",gap:i,gridTemplateColumns:`repeat(${e}, 1fr)`}}return G.jsx(t.Box,{sx:Object.assign(Object.assign({},s),n),children:e})}function Vj({text:e,onClick:n}){const i=t.useTheme();return G.jsxs(t.Box,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:i.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",color:"primary.main",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:n,children:[e,G.jsx(t.Box,{component:se.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function Hj({tags:e,onDeleteTag:n,sx:i}){return e.length?G.jsx(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center"},i),children:e.map((e=>G.jsxs(t.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[G.jsx(Nh,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n(e)})]},e.address)))}):null}function Wj({chainId:e,address:n,type:i=exports.PageType.PoolDetail}){const{isMobile:o}=Bp();return G.jsx(t.Box,{component:"button",onClick:t=>{t.stopPropagation(),zy.getState().push({type:i,params:{chainId:e,address:n}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,color:"text.primary","&:hover":{opacity:.5}},o?{width:64,height:36,backgroundColor:"background.tag"}:{width:40,height:32,backgroundColor:"transparent",borderWidth:1,borderStyle:"solid",borderColor:"border.main"}),children:G.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.83333 14.1667H7.5V8.33333H5.83333V14.1667ZM9.16667 14.1667H10.8333V5.83333H9.16667V14.1667ZM12.5 14.1667H14.1667V10.8333H12.5V14.1667ZM4.16667 17.5C3.70833 17.5 3.31597 17.3368 2.98958 17.0104C2.66319 16.684 2.5 16.2917 2.5 15.8333V4.16667C2.5 3.70833 2.66319 3.31597 2.98958 2.98958C3.31597 2.66319 3.70833 2.5 4.16667 2.5H15.8333C16.2917 2.5 16.684 2.66319 17.0104 2.98958C17.3368 3.31597 17.5 3.70833 17.5 4.16667V15.8333C17.5 16.2917 17.3368 16.684 17.0104 17.0104C16.684 17.3368 16.2917 17.5 15.8333 17.5H4.16667ZM4.16667 15.8333H15.8333V4.16667H4.16667V15.8333Z",fill:"currentColor"})})})}function $j(n){var{sx:i,children:o,empty:r,loading:a,hasMore:s,loadMore:l,loadMoreLoading:d}=n,c=U(n,["sx","children","empty","loading","hasMore","loadMore","loadMoreLoading"]);const u=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",borderRadius:16},i),...c,children:[G.jsx(t.Box,{component:"table",sx:Object.assign({width:"100%",borderCollapse:"collapse","& th":{px:24,py:12,typography:"h6",lineHeight:"20px",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:12,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.tag"},"& tbody tr":{borderWidth:"1px 0px 1px 0px",borderStyle:"solid",borderColor:"border.main"}},!r&&!a&&{"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${"dark"===u.palette.mode?"#1A1A1B":t.alpha("#1A1A1B",.1)} -2px 0px 4px 0px`}}}),children:o}),s&&G.jsx(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:l,children:d?G.jsx(t.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function zj({sx:n}){const{supportAMMV2:i,supportAMMV3:o}=X(),r=i||o;return G.jsxs(t.Box,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},n),children:[G.jsx(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(wy,{width:24,tokens:[],mr:6,showChainLogo:!0}),G.jsx(t.Skeleton,{variant:"rounded",height:20,width:88})]})}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),r&&G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),G.jsx(t.Skeleton,{variant:"rounded",height:32,sx:{mt:20}})]})}function Zj({sx:i,value:r,onChange:a,searchAddress:s}){const[l,d]=n.useState(!1),{isMobile:c}=Bp();return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign(Object.assign({typography:"body2",display:"flex",alignItems:"center",justifyContent:"flex-start",px:12,height:32,backgroundColor:"background.tag",color:"text.secondary",borderRadius:8,fontWeight:600},c?{width:"100%"}:{minWidth:220}),i),onClick:()=>d(!0),children:[G.jsx(t.Box,{component:se.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),G.jsx(e.Trans,{id:"A1taO8",message:"Search"})]}),G.jsx(Xf,{value:r,open:l,multiple:!0,title:G.jsx(e.Trans,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:o.i18n._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{d(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];a(t)}else a(e);d(!1)}},searchOtherAddress:e=>s(e,(()=>d(!1))),modal:!0})]})}var Qj;function Gj({apy:e,dailyApy:n,weeklyApy:i,sx:o}){const r=t.useTheme();return G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{maxWidth:216,typography:"h6",fontWeight:500,color:"text.secondary"},children:[G.jsx(t.Box,{sx:{fontWeight:700},children:"Base vAPY (annualized)"}),G.jsxs(t.Box,{component:"ul",sx:{pl:16,my:0,listStyleType:"disc"},children:[G.jsxs("li",{children:["Daily: ",Vu({input:n,showDecimals:2})]}),G.jsxs("li",{children:["Weekly: ",Vu({input:i,showDecimals:2})]})]}),G.jsx("br",{}),"*Variable APY based on today’s trading activity"]}),children:G.jsx(t.Box,{component:"span",sx:Object.assign({fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto",typography:"h5",[r.breakpoints.up("tablet")]:{typography:"body2"}},o),children:Vu({input:e,showDecimals:2})})})}!function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(Qj||(Qj={}));const Yj=({pool:e,separate:n,wrap:i})=>{const o=t.useTheme();if(!e)return null;const r=e.coins.slice(0,8),a=r.length,s=n?a>=6&&i?18:24:a>3?24:36,l=(d=a,i?d<=3?{rows:1,cols:d,itemsPerRow:[d]}:4===d?{rows:2,cols:2,itemsPerRow:[2,2]}:5===d?{rows:2,cols:3,itemsPerRow:[3,2]}:6===d?{rows:2,cols:3,itemsPerRow:[3,3]}:7===d?{rows:2,cols:4,itemsPerRow:[4,3]}:8===d?{rows:2,cols:4,itemsPerRow:[4,4]}:{rows:1,cols:d,itemsPerRow:[d]}:{rows:1,cols:d,itemsPerRow:[d]});var d;return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:Array.from({length:l.rows},((i,a)=>G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:n?2:0,[o.breakpoints.up("tablet")]:{gap:n?4:0}},children:r.slice(l.itemsPerRow.slice(0,a).reduce(((e,t)=>e+t),0),l.itemsPerRow.slice(0,a+1).reduce(((e,t)=>e+t),0)).map(((i,o)=>G.jsx(t.Tooltip,{title:i.symbol,placement:"top",onlyHover:!0,leaveDelay:100,sx:{maxWidth:240},children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:o,position:"relative",marginLeft:n?0:o>0?"-8px":0},children:G.jsx(Nh,{address:i.address,width:s,height:s,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0})})},i.address)))},a)))})};function Kj({lqList:e,onDeleteTag:n,sx:i}){if(!(null==e?void 0:e.length))return null;const{name:o}=e[0];return G.jsxs(t.Box,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},i),children:[o,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n()})]})}function Xj({list:e,onClick:n}){return G.jsx(G.Fragment,{children:null==e?void 0:e.map((e=>G.jsxs(t.Box,{onClick:n,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Yj,{pool:e,separate:!1,wrap:!1}),G.jsx(t.Box,{sx:{typography:"h5"},children:e.name})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:["$",e.tvl?qu(new a(e.tvl)):"-"]}),G.jsx(t.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:"TVL"})]})]},e.address)))})}const Jj=new r.CurveApi({contractRequests:nd});function ew(e,t){var n,i,o,r,a,s,l,d,c,u,p,h,m,g;if(!e||!t)return[];const x=[];for(const f of e){if(!(null==f?void 0:f.pool))continue;const e=f.pool,y=((null===(n=e.coins)||void 0===n?void 0:n.map((e=>({chainId:t,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex)),v={chainId:t,name:e.name||"",address:e.address||e.id||"",symbol:e.symbol,decimals:e.decimals,fee:(null===(i=e.fee)||void 0===i?void 0:i.toString())||"0",coins:y,apy:(null===(o=e.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=e.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=e.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=e.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=e.traderCount)||void 0===l?void 0:l.toString())||null,liquidityUtilization:(null===(d=e.liquidityUtilization)||void 0===d?void 0:d.toString())||null,lpTokenBalance:(null===(u=null===(c=f.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.liquidityTokenBalance)||null,daoFee:(null===(p=e.daoFee)||void 0===p?void 0:p.toString())||null,virtualPrice:(null===(h=e.virtualPrice)||void 0===h?void 0:h.toString())||null,poolType:e.poolType||"plain",a:(null===(m=e.a)||void 0===m?void 0:m.toString())||null,offpegFeeMultiplier:(null===(g=e.offpegFeeMultiplier)||void 0===g?void 0:g.toString())||null};x.push(v)}return x}function tw({poolList:n,isMyPool:i,setOperateCurvePool:o}){const r=t.useTheme();return G.jsx(G.Fragment,{children:n.map((n=>G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`,borderRadius:16},className:"gradient-card-border",onClick:()=>{zy.getState().push({type:exports.PageType.CurvePoolDetail,params:{chainId:n.chainId,address:n.address}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600},children:n.name}),G.jsx(t.Box,{sx:{maxWidth:146,wordBreak:"break-word",typography:"body2",color:r.palette.text.secondary},children:n.coins.map(((e,i)=>G.jsxs(t.Box,{component:"span",children:[e.symbol,i!==n.coins.length-1&&"/"]},e.address)))})]}),G.jsx(Yj,{pool:n,separate:!0,wrap:!0})]}),G.jsxs(t.Box,{sx:{mt:40},children:[G.jsx(Gj,{apy:n.apy,dailyApy:n.dailyApy,weeklyApy:n.weeklyApy}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:20},children:[G.jsxs(t.Box,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",n.tvl?Xu({input:n.tvl,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),G.jsx(t.Box,{sx:{flexShrink:0,flexGrow:0,width:"1px",height:24,backgroundColor:r.palette.border.main}}),G.jsxs(t.Box,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[G.jsx(t.Box,{sx:{typography:"h5"},children:i?n.lpTokenBalance?Au({input:n.lpTokenBalance,decimals:n.decimals}):"-":G.jsxs(G.Fragment,{children:["$",n.volume?Xu({input:n.volume,decimals:2}):"-"]})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:i?"My LP tokens":"Volume"})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[i&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({pool:n,type:Qj.Remove})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({pool:n,type:Qj.Add})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),G.jsx(Wj,{chainId:n.chainId,address:n.address,type:exports.PageType.CurvePoolDetail})]})]},`${n.chainId}-${n.address}`)))})}function nw({poolList:e,isMyPool:n,loading:i,operateCurvePool:r,setOperateCurvePool:a,hasMore:s,loadMore:l,loadMoreLoading:d}){const c=t.useTheme();return G.jsxs($j,{hasMore:s,loadMore:l,loadMoreLoading:d,empty:!(null==e?void 0:e.length),loading:i,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:"Pool"}),G.jsx(t.Box,{component:"th",children:"Assets"}),G.jsx(t.Box,{component:"th",children:"APY"}),G.jsx(t.Box,{component:"th",children:"TVL"}),G.jsx(t.Box,{component:"th",children:n?"My LP tokens":"Volume"}),G.jsx(t.Box,{component:"th",sx:{width:n?249:155}})]})}),G.jsx(t.Box,{component:"tbody",children:e.map((e=>{var i;let s="";if((null===(i=null==r?void 0:r.pool)||void 0===i?void 0:i.address.toLowerCase())===e.address.toLowerCase())if(r.type===Qj.Remove)s=o.i18n._({id:"0+31GV",message:"Removing"});else s=o.i18n._({id:"1yHVE+",message:"Adding"});const l=c.palette.hover.default;return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(s?", & td":"")]:{backgroundImage:`linear-gradient(${l}, ${l})`}},children:[G.jsxs(t.Box,{component:"td",children:[G.jsx(t.Box,{sx:{typography:"body2",lineHeight:"19px",fontWeight:600},children:e.name}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsx(t.Box,{component:"td",children:G.jsx(Yj,{pool:e,separate:!0,wrap:!1})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(Gj,{apy:e.apy,dailyApy:e.dailyApy,weeklyApy:e.weeklyApy})})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.tvl,decimals:2})}`,children:["$",e.tvl?Xu({input:e.tvl,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:n?G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.lpTokenBalance,decimals:2})}`,children:e.lpTokenBalance?Au({input:e.lpTokenBalance,decimals:e.decimals}):"-"}):G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.volume,decimals:2})}`,children:["$",e.volume?Xu({input:e.volume,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[G.jsx(Wj,{chainId:e.chainId,address:e.address,type:exports.PageType.CurvePoolDetail}),s?G.jsx(Vj,{text:s,onClick:()=>a(null)}):G.jsxs(G.Fragment,{children:[n&&G.jsx(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:()=>{a({pool:e,type:Qj.Remove})},sx:{py:0,height:32},children:o.i18n._({id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{a({pool:e,type:Qj.Add})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},`${e.chainId}-${e.address}`)}))})]})}const iw=({account:e,scrollParentRef:o,activeChainId:a,operateCurvePool:s,setOperateCurvePool:l,children:c,isMyPool:u=!1})=>{var p,h;const m=t.useTheme(),{isMobile:g}=Bp(),x=xp(),f=d.useQueryClient(),{onlyChainId:y}=X(),{filterTokens:v,filterAddressLqList:b,handleDeleteToken:C,handleChangeFilterTokens:j,handleChangeFilterAddress:w}=function(){const[e,t]=n.useState([]),[i,o]=n.useState([]);return{filterTokens:e,filterAddressLqList:i,handleDeleteToken:e=>{t((t=>{const n=[...t],i=n.indexOf(e);return-1!==i&&n.splice(i,1),n}))},handleChangeFilterTokens:e=>{o([]),e.length>0?t([e[e.length-1]]):t([])},handleChangeFilterAddress:e=>{o(e),t([])}}}(),k=n.useMemo((()=>{var t,n;return{chainId:a,pageSize:g?4:8,order:{orderBy:"tvl",orderDirection:"desc"},user:u?null==e?void 0:e.toLowerCase():null,filterState:{tokenAddress:null!==(n=null===(t=v[0])||void 0===t?void 0:t.address.toLowerCase())&&void 0!==n?n:null}}}),[a,g,u,e,v]),T=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign({},k)}),B=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign({},k)}),I=d.useInfiniteQuery(Object.assign(Object.assign({},T),{enabled:!u,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getAllPools)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getAllPools;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),S=d.useInfiniteQuery(Object.assign(Object.assign({},B),{enabled:u&&null!=e,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getMyLiquidity)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getMyLiquidity;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),A=!!(null==b?void 0:b.length),E=n.useMemo((()=>{var e,t;let n=[];return A?n=[...b]:u?null===(t=S.data)||void 0===t||t.pages.forEach((e=>{var t;const i=ew(null===(t=e.curve_stableswap_ng_getMyLiquidity)||void 0===t?void 0:t.lqList,a);n=[...n,...i]})):null===(e=I.data)||void 0===e||e.pages.forEach((e=>{var t;const i=ew(null===(t=e.curve_stableswap_ng_getAllPools)||void 0===t?void 0:t.lqList,a);n=[...n,...i]})),n}),[A,u,b,null===(p=I.data)||void 0===p?void 0:p.pages,a,null===(h=S.data)||void 0===h?void 0:h.pages]),O=(u?S.hasNextPage:I.hasNextPage)&&!A,L=u?S:I;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:20,display:"flex",flexDirection:"column",gap:12,[m.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[m.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},g?{}:{"& > button":{flex:1}}),children:G.jsx(Zj,{value:v,onChange:j,searchAddress:(e,t)=>q(void 0,void 0,void 0,(function*(){var n,i;const o=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign(Object.assign({},k),{filterState:{poolAddress:e.toLowerCase()}})}),s=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign(Object.assign({},k),{filterState:{poolAddress:e.toLowerCase()}})}),l=ew(u?null===(n=(yield f.fetchQuery(s)).curve_stableswap_ng_getMyLiquidity)||void 0===n?void 0:n.lqList:null===(i=(yield f.fetchQuery(o)).curve_stableswap_ng_getAllPools)||void 0===i?void 0:i.lqList,a);return(null==l?void 0:l.length)?G.jsx(Xj,{list:l,onClick:()=>{w(l),t()}}):null}))})}),(A||!!v.length)&&G.jsxs(t.Box,{sx:{my:0},children:[A?G.jsx(Kj,{lqList:b,onDeleteTag:()=>w([])}):null,G.jsx(Hj,{tags:v,onDeleteTag:C})]})]})]}),g?G.jsx(R,{hasMore:O,threshold:300,loadMore:i.debounce((()=>{L.hasNextPage&&!L.isFetching&&L.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>o.current||null,loader:G.jsx(zj,{sx:{mt:20}},"loader"),children:G.jsxs(qj,{children:[L.isLoading?G.jsx(zj,{}):"",!L.isLoading&&!(null==E?void 0:E.length)&&!L.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!(!a||y)}),!!L.error&&G.jsx(re,{refresh:L.refetch,sx:{mt:40}}),G.jsx(tw,{isMyPool:u,poolList:E,setOperateCurvePool:l})]})}):G.jsxs(G.Fragment,{children:[G.jsx(nw,{isMyPool:u,poolList:E,loading:L.isLoading,operateCurvePool:s,setOperateCurvePool:l,hasMore:O,loadMoreLoading:L.isFetchingNextPage,loadMore:()=>{L.hasNextPage&&!L.isFetching&&L.fetchNextPage()}}),G.jsx(ky,{loading:L.isLoading,refetch:L.error?L.refetch:void 0,empty:!(null==E?void 0:E.length),hasSearch:!(!a||y)})]})]})};function ow({children:e}){const n=t.useTheme();return G.jsx(t.Box,{sx:{px:20,py:16,boxShadow:"0px -1px 0px 0px rgba(55, 55, 57, 0.10)",backgroundColor:"background.paper",borderBottomLeftRadius:16,borderBottomRightRadius:16,position:"fixed",bottom:0,left:0,right:0,[n.breakpoints.up("tablet")]:{position:"static"}},children:e})}const rw=e=>{const n=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,px:12,height:36,borderRadius:8,border:`1px solid ${n.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px",color:n.palette.text.secondary,textTransform:"capitalize"},children:["Slippage Bonus (incl. pricing)",G.jsx(lf,{title:"Bonus comes as an advantage from current coin prices which usually appears for coins which are low in balance"})]}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:n.palette.success.main},children:"-"})]})};function aw({pool:e,account:t}){var i;const o=d.useQuery(Jj.getBalanceOf(null==e?void 0:e.chainId,null==e?void 0:e.address,t)),r=d.useQuery(Jj.getBalances(null==e?void 0:e.chainId,null==e?void 0:e.address,null!==(i=null==e?void 0:e.coins)&&void 0!==i?i:[])),s=d.useQuery(Jj.getTotalSupply(null==e?void 0:e.chainId,null==e?void 0:e.address)),l=n.useMemo((()=>s.data?null==(null==e?void 0:e.decimals)?null:s.data.div(10**e.decimals).dp(e.decimals,a.ROUND_DOWN):null),[s.data,null==e?void 0:e.decimals]),c=n.useMemo((()=>o.data?null==(null==e?void 0:e.decimals)?null:o.data.div(10**e.decimals).dp(e.decimals,a.ROUND_DOWN):null),[o.data,null==e?void 0:e.decimals]),u=n.useMemo((()=>r.data?null==(null==e?void 0:e.coins)?null:r.data.map(((t,n)=>{const i=e.coins[n];return t.div(10**i.decimals).dp(i.decimals,a.ROUND_DOWN)})):null),[r.data,null==e?void 0:e.coins]),p=n.useMemo((()=>u&&c&&l?null==(null==e?void 0:e.coins)?null:u.map(((t,n)=>{const i=e.coins[n];return t.multipliedBy(c).div(l).dp(i.decimals,a.ROUND_DOWN)})):null),[u,c,l,null==e?void 0:e.coins]);return{lpTokenTotalSupply:l,tokenBalances:u,lpTokenBalance:c,userTokenBalances:p,lpTokenBalanceLoading:o.isLoading||r.isLoading||s.isLoading}}const sw=({operateCurvePool:e})=>{const i=t.useTheme(),{account:s,chainId:l}=cp(),c=Up(),u=d.useQueryClient(),[p,h]=n.useState(!1),[m,g]=n.useState({}),x=n.useRef(m);x.current=m;const{slipper:f,setSlipper:y,slipperValue:v,resetSlipper:b}=nv({address:e.pool.address}),{lpTokenTotalSupply:C,tokenBalances:j,lpTokenBalance:w,userTokenBalances:k}=aw({pool:e.pool,account:s}),T=n.useCallback((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),g(t)}),[e.pool.coins]);n.useEffect((()=>{T()}),[T]);const B=(t,n)=>{g((i=>{const o=Object.assign(Object.assign({},i),{[t]:n});if(p&&j){const i=e.pool.coins.findIndex((e=>e.address===t));if(-1!==i){const r=j[i],s=new a(n||"0");s.isZero()||""===n?e.pool.coins.forEach((e=>{e.address!==t&&(o[e.address]="0")})):r&&r.gt(0)&&s.gt(0)&&e.pool.coins.forEach(((e,t)=>{if(t!==i){const n=j[t];if(n&&n.gt(0)){const t=n.div(r),i=s.multipliedBy(t).dp(e.decimals,a.ROUND_DOWN).toString();o[e.address]=i}else o[e.address]="0"}}))}}return o}))},I=d.useQueries({queries:e.pool.coins.map((t=>{const n=id.getFetchTokenQuery(t.chainId,t.address,s,e.pool.address);return{queryKey:n.queryKey,enabled:n.enabled&&null!=t.chainId&&null!=t.address&&null!=s&&null!=e.pool.address,queryFn:n.queryFn}})),combine:e=>({data:e.map((e=>{var t,n,i,o;return{address:null===(t=e.data)||void 0===t?void 0:t.address,symbol:null===(n=e.data)||void 0===n?void 0:n.symbol,balance:null===(i=e.data)||void 0===i?void 0:i.balance,allowance:null===(o=e.data)||void 0===o?void 0:o.allowance}})),loading:e.some((e=>e.isLoading))})}),{getApprovalState:S,getBalanceState:A,getPendingRest:E,submitApprove:O}=(({account:e,chainId:t,offset:i,contractAddress:s})=>{var l,c;const u=Up(),p=d.useQueryClient(),{runningRequests:h}=qp(),{updateBlockNumber:m}=kp(),g=n.useMemo((()=>null!=s?s:r.contractConfig[t].DODO_APPROVE),[t,s]),x=n.useMemo((()=>{var e;return t?null===(e=r.basicTokenMap[t])||void 0===e?void 0:e.address:null}),[t]),f=d.useMutation({mutationFn:n=>q(void 0,[n],void 0,(function*({token:n,isReset:i,submittedBack:r,canceledCallback:s,successBack:l,failedCallback:d}){if(!g||!e||!n)return;const c=rp(n),h=i?new a(0):void 0,x=i?o.i18n._({id:"OfhWJH",message:"Reset"}):o.i18n._({id:"Z7ZXbT",message:"Approve"}),f=yield u.execute(`${x} ${c}`,{opcode:Mp.Approval,token:n,contract:g,amt:h},{submittedBack:r,metadata:{[exports.MetadataFlag.approve]:!0}});if(f===Ap.Canceled&&(null==s||s()),f===Ap.Success&&l&&l(),f===Ap.Failed&&(null==d||d()),f!==Ap.Success)return f;yield m(),p.invalidateQueries({queryKey:id.getFetchTokenQuery(t,null==n?void 0:n.address,e,g).queryKey,refetchType:"all"})}))}),y=n.useCallback(((t,n,o,r)=>{var s,l;if(!t)return oh.Loading;const d=h.some((e=>{var n,i,o;return(null===(n=e.spec)||void 0===n?void 0:n.opcode)===Mp.Approval&&(null===(i=e.spec)||void 0===i?void 0:i.token.address)===(null==t?void 0:t.address)&&(null===(o=e.spec)||void 0===o?void 0:o.contract)===g})),c=(null===(l=null===(s=f.variables)||void 0===s?void 0:s.token)||void 0===l?void 0:l.address)===(null==t?void 0:t.address)&&f.isPending,u=new a(null!=n?n:0);return e?!o||u.minus(null!=i?i:0).gt(o)||u.isZero()?oh.Unchecked:t&&t.address===x?oh.Sufficient:d||c?oh.Approving:r?u.minus(null!=i?i:0).gt(r)?oh.Insufficient:oh.Sufficient:oh.Loading:oh.Unchecked}),[e,x,g,i,h,f.isPending,null===(c=null===(l=f.variables)||void 0===l?void 0:l.token)||void 0===c?void 0:c.address]);return{getApprovalState:y,getPendingRest:n.useCallback(((e,t)=>("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)),[]),getBalanceState:n.useCallback(((t,n,o)=>e?o?t.minus(null!=i?i:0).gt(o)?rh.Insufficient:rh.Sufficient:rh.Loading:rh.Unchecked),[e,i]),submitApprove:n.useCallback(((e,t,n,i,o,r)=>q(void 0,void 0,void 0,(function*(){f.mutate({token:e,isReset:t,submittedBack:n,canceledCallback:i,successBack:o,failedCallback:r})}))),[f]),getMaxBalance:n.useCallback(((e,n)=>{const i=new a(0);return e&&void 0!==t&&n||i}),[t])}})({account:s,chainId:e.pool.chainId,contractAddress:e.pool.address}),L=n.useCallback(((t,n,i)=>{var o;if(!j)return{};const r={},s=n||m,l=i||I.data,d=j.findIndex((e=>e&&e.gt(0)));if(-1!==d){const n=j[d],i=e.pool.coins[d];let c;if(void 0!==t)c=t;else{const e=Object.values(s).find((e=>e&&"0"!==e&&""!==e));if(e)c=e;else{const e=null===(o=null==l?void 0:l.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=i.address)||void 0===n?void 0:n.toLowerCase())})))||void 0===o?void 0:o.balance;c=e&&e.gt(0)?e.dp(i.decimals,a.ROUND_DOWN).toString():"1"}}const u=new a(c);r[i.address]=c,e.pool.coins.forEach(((e,t)=>{if(t!==d){const i=j[t];if(i&&i.gt(0)&&n.gt(0)){const t=i.div(n),o=u.multipliedBy(t).dp(e.decimals,a.ROUND_DOWN).toString();r[e.address]=o}else r[e.address]="0"}}))}return r}),[e.pool.coins,j,m,I.data]),R=d.useQuery(Jj.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=m[e.address]||"0",n=new a(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.ROUND_DOWN).toString():"0"})),!0)),M=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(s&&R.data)try{const t=new uC([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_min_mint_amount",type:"uint256"}],name:"add_liquidity",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=m[e.address]||"0",n=new a(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.ROUND_DOWN).toString():"0"})),i=R.data.multipliedBy(1-v).dp(0,a.ROUND_DOWN).toString(),o=t.encodeFunctionData("add_liquidity",[n,i]),s=()=>{u.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),u.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield c.execute("add_liquidity",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveAddLiquidity]:!0},submittedBack:()=>{s()},successBack:()=>{s(),T()}})}catch(e){console.error("curve add_liquidity",e)}}))}),P=n.useMemo((()=>{var n,i;if(!s||e.pool.chainId!==l)return G.jsx(lv,{chainId:e.pool.chainId,fullWidth:!0});if(I.loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!Object.values(m).some((e=>e&&"0"!==e)))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const o of e.pool.coins){const e=m[o.address];if(!e||"0"===e)continue;const r=new a(e);if(!r.isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});const s=I.data.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())})),l=null!==(n=null==s?void 0:s.balance)&&void 0!==n?n:null,d=null!==(i=null==s?void 0:s.allowance)&&void 0!==i?i:null,c=A(r,o,l),u=E(o,d),p=S(o,r,l,d);if(c===rh.Loading||p===oh.Loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Loading..."});if(c===rh.Insufficient)return G.jsxs(t.Button,{fullWidth:!0,disabled:!0,children:["Insufficient ",o.symbol," balance"]});if(p===oh.Approving)return G.jsxs(t.Button,{fullWidth:!0,disabled:!0,children:[o.symbol," Approval Pending"]});if(p===oh.Insufficient)return G.jsxs(t.Button,{fullWidth:!0,onClick:()=>{O(o,u)},children:["Approve ",o.symbol]})}return R.isLoading||!R.data?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):R.data.lte(0)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"}):G.jsx(t.Button,{fullWidth:!0,disabled:M.isPending,isLoading:M.isPending,onClick:()=>{M.mutate()},children:"Add"})}),[s,l,S,A,E,R.data,R.isLoading,M,e.pool.chainId,e.pool.coins,O,m,I.data,I.loading]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[i.breakpoints.up("tablet")]:{pb:20}},children:[G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:4},children:e.pool.coins.map((e=>{var n;const o=null===(n=I.data.find((t=>{var n,i;return(null===(n=t.address)||void 0===n?void 0:n.toLowerCase())===(null===(i=e.address)||void 0===i?void 0:i.toLowerCase())})))||void 0===n?void 0:n.balance;return G.jsxs(t.Box,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:i.palette.background.cardInput},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:e.symbol})]}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{o&&((e,t,n)=>{if(!t)return;const i=t.dp(n,a.ROUND_DOWN).toString();B(e,i)})(e.address,o,e.decimals)},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},children:["Balance: ",o?Au({input:o,decimals:e.decimals}):"-"]})]}),G.jsx(Nf,{value:m[e.address]||"",onChange:t=>{B(e.address,t)},decimals:e.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]},e.symbol)}))}),G.jsxs(t.Box,{sx:{mt:-8,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{const e=!p;if(h(e),e&&j){const e=L(void 0,x.current,I.data);g(e)}},sx:{px:11,py:3,borderRadius:20,border:`1px solid ${p?i.palette.primary.main:i.palette.border.main}`,typography:"body2",fontWeight:500,lineHeight:"19px",color:p?i.palette.primary.contrastText:i.palette.text.primary,backgroundColor:p?i.palette.primary.main:"transparent","&:hover":{opacity:.8}},children:["Balanced proportion: ",p?"ON":"OFF"]}),G.jsx(iv,{value:f,onChange:y,sx:{width:"auto",display:"inline-flex",ml:0}})]}),G.jsx(rw,{})]}),G.jsx(ow,{children:P})]})};function lw({disabled:e,selected:n,onClick:i,children:o,iconVisible:r}){const a=t.useTheme(),s=n?a.palette.success.main:a.palette.text.secondary;return G.jsxs(t.Box,{component:t.ButtonBase,disabled:e,onClick:i,sx:{flexGrow:1,flexShrink:1,flexBasis:"100%",display:"flex",alignItems:"center",gap:8},children:[r&&G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:n?G.jsxs(G.Fragment,{children:[G.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:s}),G.jsx("rect",{x:"4.5",y:"5",width:"9",height:"9",rx:"4.5",fill:s,stroke:s})]}):G.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:s})}),G.jsx(t.Box,{sx:{flexGrow:1,display:"flex",alignItems:"center",gap:8,typography:"body2",fontWeight:500,lineHeight:"19px",color:a.palette.text.primary},children:o})]})}const dw=({operateCurvePool:e})=>{const i=t.useTheme(),{account:o,chainId:s}=cp(),l=Up(),c=d.useQueryClient(),[u,p]=n.useState(""),[h,m]=n.useState("oneCoin"),[g,x]=n.useState(0),[f,y]=n.useState({}),{slipper:v,setSlipper:b,slipperValue:C,resetSlipper:j}=nv({address:e.pool.address}),{lpTokenBalance:w,userTokenBalances:k,lpTokenBalanceLoading:T}=aw({pool:e.pool,account:o}),B=n.useCallback((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),y(t)}),[e.pool.coins]);n.useEffect((()=>{B()}),[B]);const I=n.useMemo((()=>{const e=new a.BigNumber(u);return e.isFinite()?e:null}),[u]),S=d.useQuery(Jj.calcWithdrawOneCoin(e.pool.chainId,e.pool.address,I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",g)),A=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o&&S.data)try{const t=new uC([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"i",type:"int128"},{name:"_min_received",type:"uint256"}],name:"remove_liquidity_one_coin",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",i=S.data.multipliedBy(1-C).dp(0,a.BigNumber.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_one_coin",[n,g,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity_one_coin",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidityOneCoin]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p("")}})}catch(e){console.error("curve remove_liquidity_one_coin",e)}}))}),E=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o)try{const t=new uC([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"_min_amounts",type:"uint256[]"}],name:"remove_liquidity",outputs:[{name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",i=e.pool.coins.map(((e,t)=>(null==k?void 0:k[t])&&I&&w&&w.gt(0)?k[t].multipliedBy(I).div(w).multipliedBy(10**e.decimals).multipliedBy(1-C).dp(0,a.BigNumber.ROUND_DOWN).toString():"0")),o=t.encodeFunctionData("remove_liquidity",[n,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidity]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p("")}})}catch(e){console.error("curve remove_liquidity",e)}}))}),O=d.useQuery(Object.assign({},Jj.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new a.BigNumber(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0"})),!1)));n.useEffect((()=>{if("custom"===h&&O.isSuccess&&O.data){const t=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,a.BigNumber.ROUND_DOWN);p(t.toString())}}),[O.isSuccess,O.data,h,e.pool.decimals]);const L=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o&&O.data)try{const t=new uC([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_max_burn_amount",type:"uint256"}],name:"remove_liquidity_imbalance",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new a.BigNumber(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0"})),i=O.data.multipliedBy(1+C).dp(0,a.BigNumber.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_imbalance",[n,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity_imbalance",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidityImBalance]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p(""),B()}})}catch(e){console.error("curve remove_liquidity_imbalance",e)}}))}),R=n.useMemo((()=>{if(!o||e.pool.chainId!==s)return G.jsx(lv,{chainId:e.pool.chainId,fullWidth:!0});if(!u||"0"===u)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});const n=new a.BigNumber(u);if(!n.isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});if(T)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!w||w.lte(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"No LP token balance"});if(n.gt(w))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"});if("oneCoin"===h)return S.isLoading||!S.data?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):S.data.lte(0)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"}):G.jsx(t.Button,{fullWidth:!0,disabled:A.isPending,isLoading:A.isPending,onClick:()=>{A.mutate()},children:"Remove"});if("balanced"===h)return G.jsx(t.Button,{fullWidth:!0,disabled:E.isPending,isLoading:E.isPending,onClick:()=>{E.mutate()},children:"Remove"});if("custom"===h){if(!Object.values(f).some((e=>e&&"0"!==e)))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const n of e.pool.coins){const e=f[n.address];if(!e||"0"===e)continue;if(!new a.BigNumber(e).isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"})}if(O.isLoading||!O.data)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."});if(O.data.lte(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});const i=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,a.BigNumber.ROUND_DOWN);return i.gt(n)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient input amount"}):i.gt(w)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"}):G.jsx(t.Button,{fullWidth:!0,disabled:L.isPending,isLoading:L.isPending,onClick:()=>{L.mutate()},children:"Remove"})}return null}),[o,e.pool.chainId,e.pool.decimals,e.pool.coins,s,u,T,w,h,S.isLoading,S.data,A,E,f,O.isLoading,O.data,L]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[i.breakpoints.up("tablet")]:{pb:20}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsxs(t.Box,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:i.palette.background.cardInput},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:"LP Tokens"}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{w&&p(w.dp(e.pool.decimals,a.BigNumber.ROUND_DOWN).toString())},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},children:["Balance: ",w?Au({input:w,decimals:e.pool.decimals}):"-"]})]}),G.jsx(Nf,{value:u,onChange:e=>{p(e)},decimals:e.pool.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]}),G.jsxs(t.Box,{sx:{p:12,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,borderRadius:8,border:`1px solid ${i.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(lw,{iconVisible:!0,disabled:!1,selected:"oneCoin"===h,onClick:()=>{m("oneCoin")},children:"One coin"}),G.jsx(lw,{iconVisible:!0,disabled:!1,selected:"balanced"===h,onClick:()=>{m("balanced")},children:"Balanced"}),G.jsx(lw,{iconVisible:!0,disabled:!1,selected:"custom"===h,onClick:()=>{m("custom")},children:"Custom"})]}),G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12},children:e.pool.coins.map(((e,n)=>{var o;return G.jsxs(lw,{iconVisible:"oneCoin"===h||"balanced"===h,disabled:!1,selected:"oneCoin"!==h||g===n,onClick:()=>{"oneCoin"===h&&x(n)},children:[G.jsx(Nh,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:e.symbol}),"oneCoin"===h&&G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:g===n?Au({input:null===(o=S.data)||void 0===o?void 0:o.div(10**e.decimals),decimals:e.decimals}):"0"}),"balanced"===h&&G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:(null==k?void 0:k[n])&&I&&w&&w.gt(0)?Au({input:k[n].multipliedBy(I).div(w),decimals:e.decimals}):"-"}),"custom"===h&&G.jsx(t.Box,{sx:{ml:"auto"},children:G.jsx(Nf,{value:f[e.address]||"",onChange:t=>{var n,i;n=e.address,i=t,y((e=>Object.assign(Object.assign({},e),{[n]:i})))},decimals:e.decimals,sx:{mt:0,"& input":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,textAlign:"right",border:`1px solid ${i.palette.border.main}`,borderRadius:8,outline:"none",padding:0,color:"text.primary",height:38,width:160,px:12,"&::placeholder":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,color:"text.disabled"}}}})})]},e.address)}))})]}),G.jsx(iv,{value:v,onChange:b,sx:{}})]}),G.jsx(rw,{})]}),G.jsx(ow,{children:R})]})},cw=({onClose:e,poolDetailBtnVisible:i=!0,operateCurvePool:o})=>{const r=t.useTheme(),{account:a}=cp(),[s,l]=n.useState(o.type),[d,c]=n.useState(o.type);d!==o.type&&(c(o.type),l(o.type));const{lpTokenBalance:u,userTokenBalances:p}=aw({pool:o.pool,account:a});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",gap:16,px:20,pt:20},children:[e&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid",borderColor:r.palette.border.main},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",pb:17},children:"Liquidity"}),G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:e,component:t.ButtonBase,children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16}})})]}),G.jsxs(t.Box,{children:[i&&G.jsxs(t.Box,{sx:{px:20,py:12,borderTopLeftRadius:8,borderTopRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,borderBottom:"none",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:"text.primary"},children:o.pool.name}),G.jsx(zf,{address:o.pool.address,customChainId:o.pool.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{zy.getState().push({type:exports.PageType.CurvePoolDetail,params:{address:o.pool.address,chainId:o.pool.chainId}})},sx:{display:"flex",alignItems:"center",color:"text.secondary","&:hover":{color:"text.primary"}},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px"},children:"details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.49988 5L6.44238 6.0575L9.87738 9.5L6.44238 12.9425L7.49988 14L11.9999 9.5L7.49988 5Z",fill:"currentColor"})})]})]}),G.jsxs(t.Box,{sx:{px:20,py:12,borderTopLeftRadius:i?0:8,borderTopRightRadius:i?0:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:12},children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,lineHeight:"16px",color:"text.secondary"},children:"My LP tokens"}),G.jsx(t.Tooltip,{title:G.jsx(t.Box,{sx:{m:8,display:"flex",flexDirection:"column",gap:20,minWidth:216},children:null==p?void 0:p.map(((e,n)=>{const i=o.pool.coins[n];return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600,lineHeight:"14px"},children:[G.jsx(Nh,{width:14,height:14,address:i.address,chainId:i.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{children:i.symbol}),G.jsx(t.Box,{sx:{ml:"auto"},children:Au({input:e,decimals:i.decimals})})]},n)}))}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:500,lineHeight:"22px",color:r.palette.text.primary},children:Au({input:u,decimals:o.pool.decimals})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00016 1.33325C4.32016 1.33325 1.3335 4.31992 1.3335 7.99992C1.3335 11.6799 4.32016 14.6666 8.00016 14.6666C11.6802 14.6666 14.6668 11.6799 14.6668 7.99992C14.6668 4.31992 11.6802 1.33325 8.00016 1.33325ZM7.3335 4.66658V5.99992H8.66683V4.66658H7.3335ZM7.3335 7.33325V11.3333H8.66683V7.33325H7.3335ZM2.66683 7.99992C2.66683 10.9399 5.06016 13.3333 8.00016 13.3333C10.9402 13.3333 13.3335 10.9399 13.3335 7.99992C13.3335 5.05992 10.9402 2.66659 8.00016 2.66659C5.06016 2.66659 2.66683 5.05992 2.66683 7.99992Z",fill:r.palette.text.secondary})})]})})]})]})]}),G.jsxs(t.Tabs,{value:s,onChange:(e,t)=>{l(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:[{key:Qj.Add,value:"Add"},{key:Qj.Remove,value:"Remove"}],variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(t.TabPanel,{value:Qj.Add,children:G.jsx(sw,{operateCurvePool:o})}),G.jsx(t.TabPanel,{value:Qj.Remove,children:G.jsx(dw,{operateCurvePool:o})})]})]})},uw=({poolDetailBtnVisible:e,operateCurvePool:i,setOperateCurvePool:o})=>{const{isMobile:r}=Bp(),a=n.useMemo((()=>{if(o)return()=>{o(null)}}),[o]);return r?G.jsx(Eh,{open:!0,onClose:a,scope:!r,modal:r,id:"curve-pool-operate",children:G.jsx(cw,{onClose:a,operateCurvePool:i,poolDetailBtnVisible:e})}):G.jsx(t.Box,{sx:{borderRadius:16,backgroundColor:"background.paper"},children:G.jsx(cw,{onClose:a,operateCurvePool:i,poolDetailBtnVisible:e})})};function pw(e,t,n,i){return"CLASSICAL"===i&&e&&t&&e.isEqualTo(t)?e.times(`1e${n}`).minus(1).div(`1e${n}`):e}function hw(e,t){return e.lte(0)?new a.BigNumber(0):t.div(e)}function mw(e,t,n,i,o,r,s){const l=o&&function(e){return-1!==["0x9D9793e1E18CDEe6cf63818315D55244f73EC006","0x0D04146B2Fe5d267629a7eb341Fb4388DcdBD22f","0x3D9d765b0fbAf594F90F07bc42889473e6613C7A","0x3854BdcB1a7cBA4b1A5f9a7C8719e247Df4c42c6","0xA46F5eC3219f956d14C6816Ef9cf6CaBf13bdD77","0xB16f2Ff8E8499E31B257d2A02D25e8956Ae6aFe7"].findIndex((t=>t.toLowerCase()===e.toLowerCase()))}(o);let d,c;const u="CLASSICAL"===r?i:n;if(e&&t&&u&&void 0!==s){if(c=hw(t,u),d=e.times(c),"CLASSICAL"===r&&l){if(!i)return[void 0,void 0];d.gt(i)&&n&&(c=hw(t,a.BigNumber.min(i,n)),d=d.times(c))}return[c,d.dp(Number(s),a.BigNumber.ROUND_DOWN)]}return[void 0,void 0]}function gw({account:e,pool:t}){var n,i;const{chainId:o,address:r,type:s,baseTokenDecimals:l,quoteTokenDecimals:c,baseLpTokenDecimals:u,quoteLpTokenDecimals:p}=null!=t?t:{},h=d.useQuery($u.getTotalBaseLpQuery(o,r,s,u)),m=d.useQuery($u.getTotalQuoteLpQuery(o,r,s,p)),g=d.useQuery($u.getUserBaseLpQuery(o,r,s,u,e)),x=d.useQuery($u.getUserQuoteLpQuery(o,r,s,p,e)),f=d.useQuery($u.getReserveLpQuery(o,r,s,l,c)),y=d.useQuery($u.getClassicalTargetQuery(o,r,s,l,c)),v=h.data,b=m.data,{baseReserve:C,quoteReserve:j}=f.data||{},w=null===(n=y.data)||void 0===n?void 0:n.baseTarget,k=null===(i=y.data)||void 0===i?void 0:i.quoteTarget,T="DPP"===s,B=T?C:pw(g.data,v,u,s),I=T?j:pw(x.data,b,p,s),[S,A]=T?[new a.BigNumber(1),C]:mw(B,v,C,w,r,s,l);let E,O;if(j){let e=m.data;e||m.isLoading||m.error||!v||(e=v);const t=x.isFetched&&!x.error&&null===I?B:I;T?(E=new a.BigNumber(1),O=j):x.isLoading||x.error||y.error||t?[E,O]=mw(t,e,j,k,r,s,c):O=new a.BigNumber(0)}const L=g.isLoading||x.isLoading,R=g.isError||x.isError,M=()=>{g.refetch(),x.refetch(),h.refetch(),m.refetch(),f.refetch(),y.refetch()},P=L||h.isLoading||m.isLoading||f.isLoading||y.isLoading,_=R||h.isError||m.isError||f.isError||y.isError,N="DVM"===(null==t?void 0:t.type)&&(!j||j.isZero());return{totalBaseLpBalance:v,totalQuoteLpBalance:b,baseReserve:C,quoteReserve:j,classicalBaseTarget:w,classicalQuoteTarget:k,userBaseLpBalance:B,userQuoteLpBalance:I,userBaseLpToTokenBalance:A,userQuoteLpToTokenBalance:O,baseLpToTokenProportion:S,quoteLpToTokenProportion:E,isSinglePool:N,userLpBalanceLoading:L,userLpToTokenBalanceLoading:P,userLpBalanceError:R,userLpToTokenBalanceError:_,userLpToTokenBalanceRefetch:M,error:_,loading:P,refetch:M}}const xw=new r.MiningApi({contractRequests:nd});function fw({chainId:e,address:n,showName:i,size:o,offset:r,rightContent:a}){const s=G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:r},children:[G.jsx(Nh,{chainId:e,address:n,width:o,height:o,noShowChain:!0,marginRight:0}),i]});return a?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s,a]}):s}function yw({miningItem:e}){var t,n;const{account:i}=cp(),o=null!==(t=null==e?void 0:e.rewardTokenInfos)&&void 0!==t?t:[],r=[],s=[];if(e){const t=e.version,a=null!==(n=e.miningContractAddress)&&void 0!==n?n:"";o.forEach((n=>{var o,l,d,c,u,p,h,m,g;const x={address:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",decimals:null==n?void 0:n.decimals,symbol:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"",usdPrice:null!==(d=null==n?void 0:n.price)&&void 0!==d?d:""};if("3"===t)r.push(x),s.push(xw.getPendingRewardQuery(e.chainId,a,i,x.address,x.decimals,t));else switch(e.type){case"classical":r.push(x),s.push(xw.getPendingRewardQuery(e.chainId,a,i,null!==(u=null===(c=e.baseLpToken)||void 0===c?void 0:c.address)&&void 0!==u?u:"",x.decimals,"2")),r.push(x),s.push(xw.getPendingRewardQuery(e.chainId,a,i,null!==(h=null===(p=e.quoteLpToken)||void 0===p?void 0:p.address)&&void 0!==h?h:"",x.decimals,"2"));break;case"vdodo":case"single":r.push(x),s.push(xw.getPendingRewardQuery(e.chainId,a,i,null!==(g=null===(m=e.baseToken)||void 0===m?void 0:m.address)&&void 0!==g?g:"",x.decimals,"2"));break;default:throw new Error(`type: ${e.type} is not valid.`)}}))}return d.useQueries({queries:s,combine:e=>{let t=new a(0),n=new a(0);return{data:e.map(((e,i)=>{const o=r[i],a=e.data;if(a){t=a.plus(t);const e=null==o?void 0:o.usdPrice;e&&(n=n.plus(a.times(e)))}return Object.assign(Object.assign({},o),{amount:a})})),pending:e.some((e=>e.isPending)),error:e.some((e=>e.isError)),totalReward:t,totalRewardUSD:n,refetch:()=>{e.forEach((e=>e.refetch()))}}}})}function vw({value:e,label:n,tokenList:i,loading:o}){const r=t.useTheme();return G.jsxs(t.Box,{sx:{flexGrow:0,flexShrink:1,width:"30%"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:r.palette.text.secondary},children:n}),G.jsxs(t.Box,{sx:{mt:8,typography:"body1",fontWeight:600,color:r.palette.text.primary,display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.LoadingSkeleton,{loading:o,loadingProps:{width:30},children:e?`$${Au({input:e,decimals:2})}`:"-"}),G.jsx(t.Tooltip,{placement:"top",title:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8,width:190,color:"text.primary",fontWeight:600},children:i.map((e=>{var t;return G.jsx(fw,{chainId:e.chainId,address:e.address,showName:null!==(t=e.symbolEle)&&void 0!==t?t:e.symbol,rightContent:e.amount,size:20,offset:6},e.address+e.chainId)}))}),children:G.jsx(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",color:r.palette.text.secondary,width:16,height:16,"&:hover":{color:"text.primary"}},children:G.jsx(se.DetailBorder,{})})})]})]})}function bw({chainId:n,loading:i,miningItem:r,miningContractAddress:a,stakedTokenUSD:s,stakedTokenUSDLoading:l,miningTitle:d,associatedMineSectionShort:c,stakedTokenList:u,isEnded:p}){var h,m;const g=t.useTheme(),x=yw({miningItem:r});return G.jsxs(t.Box,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8,borderColor:g.palette.border.main,borderStyle:"solid",borderWidth:1,mb:20},children:[c?null:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{py:12,px:20,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.LoadingSkeleton,{loading:i,loadingProps:{width:100},children:G.jsx(wy,{width:24,tokens:u,gap:-6,chainId:n,mr:4,showChainLogo:!1})}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{color:g.palette.text.primary,typography:"body2",fontWeight:600,display:"flex",alignItems:"center"},children:null!=d?d:"-"}),p&&G.jsx(t.Box,{sx:{backgroundColor:g.palette.border.disabled,borderRadius:4,typography:"h6",fontWeight:500,px:8,color:g.palette.text.disabled},children:G.jsx(e.Trans,{id:"237hSL",message:"Ended"})})]}),G.jsx(zf,{size:"small",truncate:!0,address:null!=a?a:"",iconSpace:4,sx:{color:g.palette.text.secondary,typography:"h6"},customChainId:n})]})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,typography:"h6",cursor:"pointer"},onClick:()=>{zy.getState().push({type:exports.PageType.MiningDetail,params:{address:a,chainId:n}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{d:"M7.5 4.5L6.4425 5.5575L9.8775 9L6.4425 12.4425L7.5 13.5L12 9L7.5 4.5Z",fill:"currentColor"})})]})]}),G.jsx(t.Box,{sx:{width:"100%",height:"1px",backgroundColor:g.palette.border.main}})]}),G.jsxs(t.Box,{sx:{py:12,px:20,display:"flex",alignItems:"center",gap:20},children:[G.jsx(vw,{value:s,label:o.i18n._({id:"luOvdJ",message:"My Staked"}),tokenList:u,loading:i||l}),G.jsx(t.Box,{sx:{width:"1px",height:30,backgroundColor:g.palette.border.main,flexGrow:0,flexShrink:0}}),G.jsx(vw,{value:x.totalRewardUSD,label:o.i18n._({id:"4cJ0hF",message:"Rewards"}),tokenList:null!==(m=null===(h=x.data)||void 0===h?void 0:h.map((e=>Object.assign(Object.assign({chainId:n},e),{name:e.symbol,amount:Au({input:e.amount,decimals:e.decimals})}))))&&void 0!==m?m:[],loading:x.pending||i})]})]})}const Cw=({miningItem:e,successBack:t})=>{const{account:n}=cp(),i=Up();return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const a=yield q(void 0,void 0,void 0,(function*(){if(!n||!(null==e?void 0:e.miningContractAddress))return null;let t="";const i=yield r.MiningApi.encode.claimAllMining(e.miningContractAddress);if(i&&i.data)return i.value=0,i;throw t="invalid data",new Error(t)}));if(!a)return;return yield i.execute(o.i18n._({id:"hom7qf",message:"Claim"}),Object.assign({opcode:Mp.TX},a),{metadata:{[exports.MetadataFlag.claimMining]:"1"},successBack:t})}))})};function jw({miningItem:n}){const i=yw({miningItem:n}),o=Cw({miningItem:n,successBack:()=>{i.refetch()}});return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==n?void 0:n.chainId,children:G.jsx(t.Button,{fullWidth:!0,isLoading:o.isPending,disabled:i.totalReward.isZero(),onClick:()=>{o.mutate()},children:o.isPending?G.jsx(e.Trans,{id:"KvG1xW",message:"Claiming"}):G.jsx(e.Trans,{id:"dUdltF",message:"One-Click Claim"})})})}function ww({tokenSymbol:e,goLpLink:n}){const i=t.useTheme();return G.jsxs(t.HoverAddUnderLine,{sx:{color:i.palette.text.secondary,typography:"h6",display:"flex",alignItems:"center"},component:t.ButtonBase,onClick:n,children:[o.i18n._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:e}}),G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.83324 3.88867L5.01074 4.71117L7.68241 7.38867L5.01074 10.0662L5.83324 10.8887L9.33324 7.38867L5.83324 3.88867Z",fill:"currentColor"})})]})}function kw({miningItem:n,loading:i,sx:o}){const r=t.useTheme(),s=yw({miningItem:n});return G.jsxs(t.Box,{sx:Object.assign({borderWidth:1,borderRadius:12},o),children:[G.jsxs(t.Box,{sx:{typography:"body1",color:r.palette.text.secondary,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12},children:[G.jsx(e.Trans,{id:"4cJ0hF",message:"Rewards"}),":",G.jsx(t.LoadingSkeleton,{loading:i||s.pending,loadingProps:{width:100},sx:{color:r.palette.text.primary,fontWeight:600},children:s.pending||s.error?"-":`$${Au({input:s.totalRewardUSD,decimals:2})}`})]}),G.jsxs(t.Box,{sx:{borderTopWidth:1,px:20,pt:4,pb:8},children:[(i||s.pending)&&G.jsx(t.LoadingSkeleton,{loading:i,loadingProps:{width:150}}),!i&&!s.pending&&!!n&&s.data.map((e=>G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.address&&e.symbol&&G.jsx(fw,{chainId:n.chainId,address:e.address,showName:e.symbol,size:24,offset:6}),G.jsxs(t.Box,{sx:{ml:"auto"},children:[G.jsx(t.Box,{sx:{typography:"h5",textAlign:"right"},children:Au({input:e.amount,decimals:e.decimals})}),G.jsx(t.Box,{sx:{mt:2,typography:"body2",color:r.palette.text.secondary,textAlign:"right"},children:e.usdPrice&&e.amount?`≈ $${Au({input:new a(e.amount).multipliedBy(e.usdPrice).dp(4,a.ROUND_DOWN),decimals:4})}`:"-"})]})]},e.address)))]})]})}function Tw({status:n,children:i,buttonProps:o}){return!n.needShowTokenStatusButton&&i?G.jsx(G.Fragment,{children:i}):n.insufficientBalance?G.jsx(t.Button,{fullWidth:!0,disabled:!0,...o,children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(t.Button,{fullWidth:!0,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance,...o,children:n.isApproving?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):n.approveTitle})}function Bw(e){if(!e&&"number"!=typeof e)return e;let t="";return t=a.isBigNumber(e)?e.toString(16):new a(e).toString(16),t.length%2?"0x0"+t:"0x"+t}function Iw(e){return Bw(Ru(e,18))}const Sw=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:s})=>{const{chainId:l,account:c}=cp(),u=Up(),p=r.basicTokenMap[l];return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const l=yield q(void 0,void 0,void 0,(function*(){var n,i;if(!(c&&e&&e.baseToken&&e.miningContractAddress))return null;let o="";const s=new a(t),l=Number(e.baseToken.decimals),d=yield r.MiningApi.encode.depositMining(e.miningContractAddress,s,l);if(!d||!d.data)throw o="invalid data",new Error(o);try{return t&&(null===(i=null===(n=e.baseLpToken)||void 0===n?void 0:n.address)||void 0===i?void 0:i.toLocaleLowerCase())===p.address.toLocaleLowerCase()?d.value=Iw(s):d.value=0,d}catch(e){throw console.error("2.0 sendTransaction error",e),o=`2.0 sendTransaction error; ERROR: ${e}`,new Error(o)}}));if(!l)return;return yield u.execute(o.i18n._({id:"JYKRJS",message:"Stake"}),Object.assign({opcode:Mp.TX},l),{metadata:{[exports.MetadataFlag.stakeMining]:"1",logBalance:s},submittedBack:n,successBack:i})}))})};function Aw({goLpLink:n,amount:i,miningItem:r,balanceInfo:a,submittedBack:s,successBack:l,logBalance:d}){var c,u,p,h;const m=Sw({miningItem:r,amount:i,submittedBack:s,successBack:l,logBalance:d}),g=r?`${null===(c=r.baseToken)||void 0===c?void 0:c.symbol}-${null===(u=r.quoteToken)||void 0===u?void 0:u.symbol} LP`:"",x=lh(r?sp(Object.assign(Object.assign({},r.baseLpToken),{symbol:g}),r.chainId):null,{contractAddress:null!==(p=null==r?void 0:r.miningContractAddress)&&void 0!==p?p:"",overrideBalance:a.userBaseLpBalance,amount:i});return n&&g&&(null===(h=a.userBaseLpBalance)||void 0===h?void 0:h.isZero())?G.jsx(t.Button,{fullWidth:!0,onClick:()=>n(),children:o.i18n._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:g}})}):G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==r?void 0:r.chainId,children:G.jsx(Tw,{status:x,children:G.jsx(t.Button,{fullWidth:!0,isLoading:m.isPending,disabled:!Number(i),onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"KsqhWn",message:"Staking"}):G.jsx(e.Trans,{id:"JYKRJS",message:"Stake"})})})})}const Ew=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:s})=>{const{account:l}=cp(),c=Up();return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const d=yield q(void 0,void 0,void 0,(function*(){if(!(l&&e&&e.baseToken&&e.miningContractAddress))return null;let n="";const i=new a(t),o=Number(e.baseToken.decimals),s=yield r.MiningApi.encode.withdrawMining(e.miningContractAddress,i,o);if(s&&s.data)return s.value=0,s;throw n="invalid data",new Error(n)}));if(!d)return;return yield c.execute(o.i18n._({id:"OFjZGo",message:"Unstake"}),Object.assign({opcode:Mp.TX},d),{metadata:{[exports.MetadataFlag.unstakeMining]:"1",logBalance:s},submittedBack:n,successBack:i})}))})};function Ow({amount:n,miningItem:i,overrideBalance:o,submittedBack:r,successBack:a,logBalance:s}){var l,d;const c=Ew({miningItem:i,amount:n,submittedBack:r,successBack:a,logBalance:s}),u=i?`${null===(l=i.baseToken)||void 0===l?void 0:l.symbol}-${null===(d=i.quoteToken)||void 0===d?void 0:d.symbol} LP`:"",p=lh(i?sp(Object.assign(Object.assign({},i.baseLpToken),{symbol:u}),i.chainId):null,{overrideBalance:o,amount:n,skipQuery:!0});return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==i?void 0:i.chainId,children:G.jsx(Tw,{status:p,children:G.jsx(t.Button,{fullWidth:!0,isLoading:c.isPending,disabled:!Number(n),onClick:()=>{c.mutate()},children:c.isPending?G.jsx(e.Trans,{id:"1gWStS",message:"Unstaking"}):G.jsx(e.Trans,{id:"OFjZGo",message:"Unstake"})})})})}function Lw(e){var{sx:n}=e,i=U(e,["sx"]);const o=t.useTheme();return G.jsx(t.Box,{sx:Object.assign({paddingTop:20,backgroundColor:o.palette.background.paper,position:"sticky",bottom:0},n),...i})}function Rw({chainId:e,poolAddress:i,status:s,loading:l,operateType:c,setOperateType:u,miningItem:p,associatedMineSectionVisible:h,goLpLink:m}){var g,x,f,y,v,b,C,j,w,k,T,B,I,S,A,E,O;const L=t.useTheme(),{account:R}=cp(),{miningContractAddress:M}=null!=p?p:{},P=sp(null==p?void 0:p.baseToken,e),_=sp(null==p?void 0:p.quoteToken,e),[N,D]=n.useState(""),[F,U]=n.useState(""),q=[{key:"stake",value:o.i18n._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:o.i18n._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:o.i18n._({id:"hom7qf",message:"Claim"})}],V=p&&P&&_&&["classical","lptoken"].includes(null!==(g=p.type)&&void 0!==g?g:"")?{chainId:e,address:i,type:"lptoken"===p.type?"DSP":"CLASSICAL",baseToken:P,quoteToken:_}:void 0,H=gw({account:R,pool:p&&P&&_&&p.baseLpToken&&p.quoteLpToken&&["classical","lptoken"].includes(null!==(x=p.type)&&void 0!==x?x:"")?{chainId:e,address:i,type:"lptoken"===p.type?"DSP":"CLASSICAL",baseTokenDecimals:P.decimals,quoteTokenDecimals:_.decimals,baseLpTokenDecimals:null!==(f=p.baseLpToken.decimals)&&void 0!==f?f:18,quoteLpTokenDecimals:null!==(y=p.quoteLpToken.decimals)&&void 0!==y?y:18}:void 0}),W=d.useQuery($u.getPMMStateQuery(null==V?void 0:V.chainId,null==V?void 0:V.address,null==V?void 0:V.type,null===(v=null==V?void 0:V.baseToken)||void 0===v?void 0:v.decimals,null===(b=null==V?void 0:V.quoteToken)||void 0===b?void 0:b.decimals)),$=d.useQuery(xw.getLpStakedBalance(null==p?void 0:p.chainId,(null==p?void 0:p.miningContractAddress)||void 0,R,null!==(j=null===(C=null==p?void 0:p.baseLpToken)||void 0===C?void 0:C.address)&&void 0!==j?j:"",null===(w=null==p?void 0:p.baseToken)||void 0===w?void 0:w.decimals,null==p?void 0:p.version)),z=$.isLoading||W.isLoading;let Z,Q,Y;if($.data&&H.baseLpToTokenProportion&&H.quoteLpToTokenProportion&&!W.isLoading){const e=null===(k=null==p?void 0:p.baseToken)||void 0===k?void 0:k.price,t=null===(T=null==p?void 0:p.quoteToken)||void 0===T?void 0:T.price,n=null===(B=W.data)||void 0===B?void 0:B.midPrice;Q=$.data.times(H.baseLpToTokenProportion),Y=$.data.times(H.quoteLpToTokenProportion),n?t?Z=Q.times(n).plus(Y).times(t):e&&(Z=Y.times(n).plus(Q).times(e)):e&&t&&(Z=Q.times(e).plus(Y.times(t)))}const K=P&&_?[Object.assign(Object.assign({},P),{amount:Au({input:Q,decimals:P.decimals})}),Object.assign(Object.assign({},_),{amount:Au({input:Y,decimals:_.decimals})})]:[],X=P&&_?`${P.symbol}-${_.symbol} LP`:"- LP",J=s===r.MiningStatusE.ended,ee=(null===(I=null==p?void 0:p.baseLpToken)||void 0===I?void 0:I.address)&&H.userBaseLpBalance?{[null===(S=null==p?void 0:p.baseLpToken)||void 0===S?void 0:S.address]:H.userBaseLpBalance.toString()}:{},te=()=>{H.refetch(),W.refetch(),$.refetch()};return G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{paddingTop:20,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:L.palette.background.paper,px:20,paddingBottom:0,borderBottomLeftRadius:0,borderBottomRightRadius:0},children:[h&&G.jsx(bw,{chainId:e,miningContractAddress:null!=M?M:"",loading:l,miningItem:p,stakedTokenUSD:Z,stakedTokenUSDLoading:z,miningTitle:null!==(A=null==p?void 0:p.title)&&void 0!==A?A:"",stakedTokenList:K}),G.jsxs(t.Tabs,{value:c,onChange:(e,t)=>{u(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:q,variant:"inPaper",tabsListSx:{mt:16}}),G.jsxs(t.TabPanel,{value:"stake",children:[G.jsxs(t.Box,{sx:{mt:20,borderColor:L.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:16},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(wy,{width:K.length>1?20:28,tokens:K,chainId:e}),G.jsx(t.Box,{sx:{ml:8,typography:"body1",color:L.palette.text.primary,fontWeight:600},children:X})]}),!!m&&G.jsx(ww,{tokenSymbol:X,goLpLink:m})]}),G.jsx(py,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:o.i18n._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:H.userBaseLpBalance||new a("-"),overrideBalanceLoading:H.loading,amt:N,canClickBalance:!0,onInputChange:e=>{D(e)},readOnly:J||l,token:P,checkLogBalance:ee,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),G.jsx(Lw,{children:G.jsx(Aw,{miningItem:p,balanceInfo:H,amount:N,goLpLink:m,submittedBack:()=>D(""),successBack:te,logBalance:ee})})]}),G.jsxs(t.TabPanel,{value:"unstake",children:[G.jsx(py,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:o.i18n._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:$.data||new a("-"),overrideBalanceLoading:$.isLoading,amt:J?null!==(O=null===(E=$.data)||void 0===E?void 0:E.toString())&&void 0!==O?O:"":F,onInputChange:e=>{U(e)},canClickBalance:!0,readOnly:J||l,token:P,checkLogBalance:ee,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),G.jsx(Lw,{children:G.jsx(Ow,{miningItem:p,overrideBalance:$.data,amount:F,submittedBack:()=>U(""),successBack:te,logBalance:ee})})]}),G.jsxs(t.TabPanel,{value:"claim",children:[G.jsx(kw,{miningItem:p,loading:l,sx:{mt:20}}),G.jsx(Lw,{children:G.jsx(jw,{miningItem:p})})]})]})]})})}function Mw({chainId:e,account:t,poolAddress:i,goLpLink:o}){var a,s,l;const c=xp().getQuery(r.MiningApi.graphql.fetchMiningList,{where:{chainIds:[e],user:t,filterState:{address:i}}}),u=d.useQuery(Object.assign(Object.assign({},c),{enabled:!!i})),p=null===(l=null===(s=null===(a=u.data)||void 0===a?void 0:a.mining_list)||void 0===s?void 0:s.list)||void 0===l?void 0:l[0],{status:h}=function({miningItem:e}){var t,n;let i=r.MiningStatusE.active,o=[];if(null==e?void 0:e.rewardTokenInfos)if("classical"!==e.type){const a=r.MiningApi.utils.getMiningStatusByTimestamp({startTime:null!==(t=e.startTime)&&void 0!==t?t:"",endTime:null!==(n=e.endTime)&&void 0!==n?n:"",rewardTokenInfoList:e.rewardTokenInfos.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))});i=a.status,o.push(a)}else if(e.rewardQuoteTokenInfos){o=[e.rewardTokenInfos,e.rewardQuoteTokenInfos].map((t=>{var n,i;return r.MiningApi.utils.getMiningStatusByTimestamp({startTime:null!==(n=e.startTime)&&void 0!==n?n:"",endTime:null!==(i=e.endTime)&&void 0!==i?i:"",rewardTokenInfoList:t.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))})}));const[{status:t},{status:n}]=o;r.MiningStatusE.active,(t===r.MiningStatusE.upcoming&&n===r.MiningStatusE.upcoming||t===r.MiningStatusE.upcoming&&n===r.MiningStatusE.ended||t===r.MiningStatusE.ended&&n===r.MiningStatusE.upcoming)&&r.MiningStatusE.upcoming,t===r.MiningStatusE.ended&&n===r.MiningStatusE.ended&&r.MiningStatusE.ended}return{status:i,miningStatusList:o}}({miningItem:p}),[m,g]=n.useState(h===r.MiningStatusE.ended?"unstake":"stake");return G.jsx(Rw,{chainId:e,loading:u.isLoading||u.isPending,operateType:m,setOperateType:g,associatedMineSectionVisible:!0,miningItem:p,status:h,goLpLink:o,poolAddress:i})}const Pw=()=>{const n=t.useTheme();return G.jsx(t.Tooltip,{placement:"top-end",leaveDelay:100,title:G.jsx(t.Box,{sx:{maxWidth:240,color:n.palette.warning.main,typography:"h6",fontWeight:500,"&>a":{textDecoration:"underline",color:n.palette.warning.main},"&>a:hover":{color:t.alpha(n.palette.warning.main,.5)}},children:G.jsx(e.Trans,{id:"QtgfjM",message:"The creator of the liquidity pool can adjust the liquidity distribution by modifying the market-making price parameters. <0>Learn more</0>",components:{0:G.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://docs.dodoex.io/en/product/pmm-algorithm"})}})}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,py:4,px:8,borderRadius:8,backgroundColor:t.alpha(n.palette.warning.main,.1),color:n.palette.warning.main,typography:"h6",fontWeight:500,lineHeight:"16px",cursor:"help"},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{d:"M8.00008 10.6666C8.18897 10.6666 8.3473 10.6027 8.47508 10.4749C8.60286 10.3471 8.66675 10.1888 8.66675 9.99992C8.66675 9.81103 8.60286 9.6527 8.47508 9.52492C8.3473 9.39714 8.18897 9.33325 8.00008 9.33325C7.81119 9.33325 7.65286 9.39714 7.52508 9.52492C7.3973 9.6527 7.33341 9.81103 7.33341 9.99992C7.33341 10.1888 7.3973 10.3471 7.52508 10.4749C7.65286 10.6027 7.81119 10.6666 8.00008 10.6666ZM7.33341 7.99992H8.66675V4.66659H7.33341V7.99992ZM8.00008 14.6666C6.45564 14.2777 5.18064 13.3916 4.17508 12.0083C3.16953 10.6249 2.66675 9.08881 2.66675 7.39992V3.33325L8.00008 1.33325L13.3334 3.33325V7.39992C13.3334 9.08881 12.8306 10.6249 11.8251 12.0083C10.8195 13.3916 9.54453 14.2777 8.00008 14.6666ZM8.00008 13.2666C9.15564 12.8999 10.1112 12.1666 10.8667 11.0666C11.6223 9.96659 12.0001 8.74436 12.0001 7.39992V4.24992L8.00008 2.74992L4.00008 4.24992V7.39992C4.00008 8.74436 4.37786 9.96659 5.13341 11.0666C5.88897 12.1666 6.84453 12.8999 8.00008 13.2666Z",fill:"currentColor"})}),G.jsx(e.Trans,{id:"iDGO1l",message:"Disclaimer"})]})})};var _w;function Nw(n){const{ConfirmComponent:i}=X();if(i)return G.jsx(i,{...n});const{open:o,onClose:r,title:a,children:s,singleBtn:l,danger:d,singleBtnText:c,cancelText:u,confirmText:p,disabledConfirm:h,confirmLoading:m,isManualClose:g,onConfirm:x,modal:f}=n;return G.jsx(Eh,{open:o,onClose:r,title:a,modal:f,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1},children:[G.jsx(t.Box,{sx:{typography:"body2",color:a?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:s}),l?G.jsx(t.Box,{sx:{px:20},children:G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,danger:d,sx:{mt:32,mb:20},onClick:()=>{r()},children:c||G.jsx(e.Trans,{id:"DPfwMq",message:"Done"})})}):G.jsxs(t.Box,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{r()},children:u||G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx(t.Button,{sx:{ml:8},variant:t.Button.Variant.outlined,danger:d,disabled:h,isLoading:m,onClick:()=>{x&&x(),g||r()},children:p||G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})]})})}function Dw(e){var{sx:n,label:i,children:o}=e,r=U(e,["sx","label","children"]);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between"},n),...r,children:[G.jsx(t.Box,{children:i}),G.jsx(t.Box,{sx:{textAlign:"right",fontWeight:600},children:o})]})}function Fw({baseToken:e,quoteToken:i,midPrice:o,loading:r,disabled:s}){const l=t.useTheme(),[d,c]=n.useState(!1),u=d?null==i?void 0:i.symbol:null==e?void 0:e.symbol,p=d&&o?new a(1).div(o):o,h=d?null==e?void 0:e.symbol:null==i?void 0:i.symbol;return G.jsxs(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:r,loadingProps:{width:50},children:[e&&i?G.jsx(t.Tooltip,{title:`1 ${u} = ${p?Su({input:p}):""} ${h}`,children:o?G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Su({input:p}):""} ${h}`}):G.jsxs(t.Box,{children:[`1 ${u} = `,G.jsx(t.LoadingSkeleton,{loading:r,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",G.jsx(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!s&&{cursor:"pointer","&:hover":{backgroundColor:t.alpha(l.palette.text.primary,.04)}}),onClick:()=>{s||c((e=>!e))},children:G.jsx(t.Box,{component:se.Switch,sx:{width:18,height:18}})})]})}function Uw({baseToken:n,quoteToken:i,loading:o,midPrice:r,shareOfPool:a,sx:s}){const l=t.useTheme(),d=!n||!i;return G.jsxs(t.Box,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},s),children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsx(Fw,{baseToken:n,quoteToken:i,loading:o,disabled:d,midPrice:r})]}),G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:l.spacing(1,0,0),borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:G.jsx(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:a||"-%"})})]})]})}function qw({open:n,onClose:i,slippage:o,baseToken:r,quoteToken:a,baseAmount:s,quoteAmount:l,lpAmount:d,fee:c,price:u,shareOfPool:p,pairAddress:h,createMutation:m}){const g=t.useTheme(),{isMobile:x}=Bp();return G.jsx(Eh,{modal:!0,open:n,onClose:i,title:d?G.jsx(e.Trans,{id:"AeZIvT",message:"You will receive"}):G.jsx(e.Trans,{id:"aM1tos",message:"You are creating a pool"}),children:G.jsxs(t.Box,{sx:{px:20,py:24,borderTopWidth:1,width:x?"100%":420},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[G.jsx(wy,{width:24,height:24,tokens:r&&a?[r,a]:[],chainId:null==r?void 0:r.chainId}),d?Au({input:d,decimals:18}):""]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,gap:4,fontWeight:600},children:[G.jsx(e.Trans,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==a?void 0:a.symbol}}),G.jsx(lj,{poolType:"AMM V2"})]})]}),G.jsx(t.Box,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:G.jsx(e.Trans,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:Vu({input:o})}})}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:g.palette.background.paperContrast},children:[G.jsx(Dw,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:r}),Au({input:s,decimals:null==r?void 0:r.decimals})]})}),G.jsx(Dw,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==a?void 0:a.symbol}}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:a}),Au({input:l,decimals:null==a?void 0:a.decimals})]})}),G.jsx(Dw,{label:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"}),children:Vu({input:c})}),G.jsx(Dw,{label:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:r}),G.jsx(Fw,{baseToken:r,quoteToken:a,midPrice:u})]})}),G.jsx(Dw,{label:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"}),children:p}),G.jsx(Dw,{label:G.jsx(e.Trans,{id:"ESQO1L",message:"Pool address"}),children:G.jsx(zf,{showCopy:!1,address:null!=h?h:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,sx:{mt:20},isLoading:m.isPending,onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"pwUZo2",message:"Confirming..."}):G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})})}function Vw(e,t,n){const i=new a(e),o=new a(t),r=i.minus(o),s=i.gt(o),l=i.lt(o);return{now:o,target:i,isChange:s||l,change:r,changeText:(l?"":"+")+Su({input:r,showDecimals:n>6?6:4,showPrecisionDecimals:2}),isAdd:s,isRemove:l}}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(_w||(_w={}));const Hw=e=>q(void 0,[e],void 0,(function*({chainId:e,account:t,srcPool:n,baseToken:i,quoteToken:o,baseAmount:s,quoteAmount:l,feeRate:d,initPrice:c,slippageCoefficient:u,ddl:p,SLIPPAGE_PROTECTION:h}){const m=e?r.basicTokenMap[e]:void 0,g=function({srcPool:e,newPool:t}){if(!e)return null;const{baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=t,{baseReserve:s,quoteReserve:l}=e;return{baseAmount:Vw(o,s,n.decimals),quoteAmount:Vw(r,l,i.decimals),feeRate:Vw(new a(t.feeRate).div(100),e.feeRate,6),initPrice:Vw(t.initPrice,e.i,10),slippageCoefficient:Vw(t.slippageCoefficient||"1",e.k,4)}}({srcPool:n,newPool:{baseToken:i,quoteToken:o,baseAmount:s,quoteAmount:l,feeRate:d,initPrice:c,slippageCoefficient:u}});if(!(t&&e&&g&&n))return null;const f=Number(i.decimals),y=Number(o.decimals);let v;const b=g.slippageCoefficient.target;try{const t=i.symbol===(null==m?void 0:m.symbol),s=o.symbol===(null==m?void 0:m.symbol);if(g.baseAmount.isRemove&&g.quoteAmount.isRemove){const t=[yield $u.getDPPOwnerProxyAddressQuery(e,n.address).queryFn(),g.feeRate.target.multipliedBy(1e4).toNumber(),g.initPrice.target.toNumber(),b.toNumber(),x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString(),x.parseFixed(g.baseAmount.now.multipliedBy(1-h).dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.now.multipliedBy(1-h).dp(y,a.ROUND_FLOOR).toString(),y).toString(),f,y];v=yield r.PoolApi.encode.removeDPPPoolABI(...t)}else{const t=[e,n.address,g.feeRate.target.multipliedBy(1e4).toNumber(),g.initPrice.target.toNumber(),b.toNumber(),g.baseAmount.isAdd?x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString():"0",g.quoteAmount.isAdd?x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString():"0",g.baseAmount.isAdd?"0":x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString(),g.quoteAmount.isAdd?"0":x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString(),x.parseFixed(g.baseAmount.now.multipliedBy(1-h).dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.now.multipliedBy(1-h).dp(y,a.ROUND_FLOOR).toString(),y).toString(),0,f,y,Math.ceil(Date.now()/1e3)+(null!=p?p:600)];v=yield r.PoolApi.encode.resetDPPPoolABI(...t)}return t&&g.baseAmount.isAdd&&(v.value=Iw(g.baseAmount.change)),s&&g.quoteAmount.isAdd&&(v.value=Iw(g.quoteAmount.change)),v}catch(e){throw console.error("2.0 resetDPPPool error",e),new Error(`2.0 resetDPPPool error;ERROR:${e}`)}})),Ww=(e,t,n)=>t?e&&"0"!==e?n?t.minus(e).toString():t.plus(e).toString():t.toString():e;function $w({pool:e}){var t,n;const{account:i}=cp(),o=Up(),r=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),s=d.useQuery($u.getLPFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type)),{deadLine:l}=X(),c=d.useMutation({mutationFn:t=>q(this,[t],void 0,(function*({baseAmount:t,quoteAmount:n,isRemove:d=!1,feeRate:c,initPrice:u,slippageCoefficient:p,txTitle:h,submittedBack:m}){var g;if(!e)throw new Error("pool is undefined");const x=s.data;if(!x)throw new Error("lpFeeRate is undefined");if(!r.data)throw new Error("pmmStateQuery.data is undefined");const{pmmParamsBG:f,baseReserve:y,quoteReserve:v}=r.data,b=f.i.toNumber(),C=f.k.toNumber(),j=yield Hw({account:i,chainId:null==e?void 0:e.chainId,SLIPPAGE_PROTECTION:tv,srcPool:Object.assign(Object.assign({},e),{baseReserve:y,quoteReserve:v,i:b,k:C,feeRate:x.times(100).toString()}),baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,baseAmount:Ww(t,y?new a(y):void 0,d),quoteAmount:Ww(n,v?new a(v):void 0,d),feeRate:null!=c?c:x.times(100).toString(),initPrice:null!=u?u:String(b),slippageCoefficient:null!=p?p:String(C),ddl:l});if(!j)throw new Error(`modify pool failed: ${e.address}`);return o.execute(h,Object.assign(Object.assign({opcode:Mp.TX},j),{value:null!==(g=j.value)&&void 0!==g?g:0}),{metadata:{[d?exports.MetadataFlag.removeLiquidity:exports.MetadataFlag.addLiquidity]:!0},submittedBack:m})}))});return{modifyDPPMutation:c}}const zw=e=>{const{account:t,chainId:i}=cp(),o=Up(),s=d.useQueryClient(),{deadLine:l}=X(),{modifyDPPMutation:c}=$w({pool:e}),u=d.useMutation({mutationFn:n=>q(void 0,void 0,void 0,(function*(){var d,c,u,p,h;if(!e||!t||!n.balanceInfo)return;const{isRemove:m,baseAmount:g,quoteAmount:f,slippageProtection:y,balanceInfo:v,SLIPPAGE_PROTECTION:b,submittedBack:C,successBack:j,txTitle:w,withdrawInfo:k}=n,T=!m,{address:B,type:I,baseToken:S,quoteToken:A}=e,E=S.address.toLowerCase(),O=A.address.toLowerCase(),L=r.basicTokenMap[i].address.toLowerCase(),R=L===E,M=L===O,P="DSP"===I||"GSP"===I,_="CLASSICAL"===I,N=B.toLocaleLowerCase(),D=new a(g),F=new a(f),U=D.isNaN(),q=F.isNaN(),V=+S.decimals,H=+A.decimals,W=S.symbol,$=A.symbol,z=y;let Z,Q=U?"0":x.parseFixed(D.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString(),G=q?"0":x.parseFixed(F.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString();try{if(T)if(_){const e=!U&&(null==v?void 0:v.classicalBaseTarget)&&v.classicalBaseTarget.gt(0)&&v.totalBaseLpBalance?x.parseFixed(D.multipliedBy(v.totalBaseLpBalance).multipliedBy(1-b).div(v.classicalBaseTarget).dp(V,a.ROUND_FLOOR).toString(),V).toString():"0",t=!q&&(null==v?void 0:v.classicalBaseTarget)&&v.totalQuoteLpBalance&&v.classicalQuoteTarget&&v.classicalQuoteTarget.gt(0)?x.parseFixed(F.multipliedBy(v.totalQuoteLpBalance).multipliedBy(1-b).div(v.classicalQuoteTarget).dp(H,a.ROUND_FLOOR).toString(),H).toString():"0",n=[i,N,U?"0":x.parseFixed(D.dp(V,a.ROUND_FLOOR).toString(),V).toString(),q?"0":x.parseFixed(F.dp(H,a.ROUND_FLOOR).toString(),H).toString(),e,t,R?1:M?2:0,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=yield r.PoolApi.encode.addClassicalLiquidityABI(...n)}else{const e=[i,N,U?"0":x.parseFixed(D.dp(V,a.ROUND_FLOOR).toString(),V).toString(),q?"0":x.parseFixed(F.dp(H,a.ROUND_FLOOR).toString(),H).toString(),Q,G,R?1:M?2:0,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=P?yield r.PoolApi.encode.addDSPLiquidityABI(...e):yield r.PoolApi.encode.addDVMLiquidityABI(...e)}else if(_){if("base"===(U?"quote":"base")){const e=D.dp(V,a.ROUND_FLOOR).toString(),t=k&&k.receiveAmountBg?x.parseFixed(k.receiveAmountBg.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString():Q,n=[i,N,x.parseFixed(e,V).toString(),t];Z=yield r.PoolApi.encode.removeClassicalBaseABI(...n)}else{const e=F.dp(H,a.ROUND_FLOOR).toString(),t=k&&k.receiveAmountBg?x.parseFixed(k.receiveAmountBg.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString():G,n=[i,N,x.parseFixed(e,H).toString(),t];Z=yield r.PoolApi.encode.removeClassicalQuoteABI(...n)}}else{if(!((null==v?void 0:v.baseReserve)&&v.quoteReserve&&v.totalBaseLpBalance&&v.userBaseLpBalance&&v.userBaseLpToTokenBalance))return;let e=new a(0);if(null===(d=v.totalBaseLpBalance)||void 0===d?void 0:d.lte(0))e=v.userBaseLpBalance||new a(0);else if(v.baseReserve.gt(0)&&v.quoteReserve.eq(0)){let t=D;D.gte(v.userBaseLpToTokenBalance)&&(t=v.userBaseLpToTokenBalance),e=t.multipliedBy(v.totalBaseLpBalance).div(v.baseReserve)}else if(v.baseReserve.gt(0)&&v.quoteReserve.gt(0)){let t=D;D.gte(v.userBaseLpToTokenBalance)&&(t=v.userBaseLpToTokenBalance);let n,i=F;if(v.userQuoteLpToTokenBalance&&F.gte(v.userQuoteLpToTokenBalance)&&(i=v.userQuoteLpToTokenBalance),i.gt(0)&&(null===(c=v.userQuoteLpToTokenBalance)||void 0===c?void 0:c.gt(0))&&(n=i.div(v.userQuoteLpToTokenBalance)),t.gt(0)&&v.userBaseLpToTokenBalance.gt(0)&&(n=t.div(v.userBaseLpToTokenBalance)),(null==n?void 0:n.gte(1))&&(n=new a(1)),!n)return;e=n.multipliedBy(v.userBaseLpBalance);const o=e.dp(V,a.ROUND_FLOOR).div(v.totalBaseLpBalance);t=o.multipliedBy(v.baseReserve).dp(V,a.ROUND_FLOOR),i=o.multipliedBy(v.quoteReserve).dp(H,a.ROUND_FLOOR),Q=x.parseFixed(t.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString(),G=x.parseFixed(i.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString()}const n=R||M,o=[i,N,t,e.isNaN()?"0":x.parseFixed(e.dp(V,a.ROUND_FLOOR).toString(),V).toString(),Q,G,n,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=P?yield r.PoolApi.encode.removeDSPLiquidityABI(...o):yield r.PoolApi.encode.removeDVMLiquidityABI(...o)}}catch(e){throw new Error(`v2 addDVMLiquidity or removeDVMLiquidity or removeDSPLiquidity error: ${e}`)}if(Z&&Z.data){const n={};if(g){const o=null===(u=s.getQueryData(id.getFetchTokenQuery(i,S.address,t).queryKey))||void 0===u?void 0:u.balance;o&&(n[S.address]=o.toString()),e.baseLpToken&&(null==v?void 0:v.userBaseLpBalance)&&(n[e.baseLpToken.id]=v.userBaseLpBalance.toString())}if(f){const o=null===(p=s.getQueryData(id.getFetchTokenQuery(i,A.address,t).queryKey))||void 0===p?void 0:p.balance;o&&(n[A.address]=o.toString()),e.quoteLpToken&&(null==v?void 0:v.userQuoteLpBalance)&&(n[e.quoteLpToken.id]=v.userQuoteLpBalance.toString())}try{let e;T&&R&&(Z.value=Iw(U?"0":D)),T&&M&&(Z.value=Iw(q?"0":F)),U||(e=`${D.toString()}${W}`),q||(e=U?`${F.toString()}${$}`:`${e} & ${F.toString()}${$}`);(yield o.execute(w,Object.assign(Object.assign({opcode:Mp.TX},Z),{value:null!==(h=Z.value)&&void 0!==h?h:0}),{subtitle:e,metadata:{[T?exports.MetadataFlag.addLiquidity:exports.MetadataFlag.removeLiquidity]:!0,logBalance:n},submittedBack:C}))===Ap.Success&&j&&j()}catch(e){throw Error(`v2 sendTransaction error: ${e}`)}}}))}),p="DPP"===(null==e?void 0:e.type)?c:u;return n.useEffect((()=>{p.reset()}),[e]),{operateLiquidityMutation:p}};function Zw({baseToken:t,quoteToken:n,baseAmount:i,quoteAmount:s,slippage:l,fee:c,isExists:p,successBack:h,submittedBack:m}){const g=Up(),{account:x}=cp();e.useLingui();const{deadLine:f}=X();return d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){var e,d;if(!t||!n)throw new Error("token is undefined");if(!x)throw new Error("account is undefined");if(!c)throw new Error("fee is undefined");const y=t.chainId,v=r.basicTokenMap[y].address.toLowerCase(),b=u.getUniswapV2Router02ContractAddressByChainId(y),C=u.getUniswapV2Router02FixedFeeContractAddressByChainId(y),j=!b,w=b||C;if(!w)throw new Error("AMMV2 contract address is not valid.");let k="",T="0x0";const B=t.address.toLowerCase()===v,I=n.address.toLowerCase()===v,S=Ru(i,t.decimals),A=Ru(s,n.decimals),E=S.times(1-l).dp(0,a.ROUND_FLOOR),O=A.times(1-l).dp(0,a.ROUND_FLOOR),L=Ru(c,4).toString(),R=Math.ceil(Date.now()/1e3)+(null!=f?f:600);try{if(B){const t=n.address,i=A.toString(),o=O.toString(),r=E.toString();T=null!==(e=Bw(S))&&void 0!==e?e:"",k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidityETH(t,i,o,r,x,R):u.encodeUniswapV2Router02AddLiquidityETH(t,L,i,o,r,x,R)}else if(I){const e=t.address,n=S.toString(),i=E.toString(),o=O.toString();T=null!==(d=Bw(A))&&void 0!==d?d:"",k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidityETH(e,n,i,o,x,R):u.encodeUniswapV2Router02AddLiquidityETH(e,L,n,i,o,x,R)}else k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidity(t.address,n.address,S.toString(),A.toString(),E.toString(),O.toString(),x,R):u.encodeUniswapV2Router02AddLiquidity(t.address,n.address,L,S.toString(),A.toString(),E.toString(),O.toString(),x,R)}catch(e){throw console.error("encodeUniswapV2Router02AddLiquidity error",e),e}return yield g.execute(p?o.i18n._({id:"E6MqGy",message:"Add liquidity"}):o.i18n._({id:"L37FfW",message:"Create AMM V2 Position"}),{opcode:Mp.TX,to:w,data:k,value:T},{metadata:{[p?exports.MetadataFlag.addLiquidityAMMV2Position:exports.MetadataFlag.createAMMV2Position]:!0},successBack:h,submittedBack:m})}))})}function Qw({lqAndDodoCompareText:n,baseToken:i,quoteToken:r,midPrice:a}){const s=a?Su({input:a}):"";return G.jsxs(t.Box,{sx:{p:10,mb:12,backgroundColor:"background.paperDarkContrast",borderRadius:12},children:[G.jsxs(t.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",justifyContent:"center",color:"error.main",fontWeight:600,mb:10,textAlign:"center"},children:[G.jsx(t.Box,{component:se.Alarm,sx:{mr:4}}),o.i18n._({id:"YUyuNp",message:"{lqAndDodoCompareText} Price Difference",values:{lqAndDodoCompareText:n}})]}),G.jsxs(t.Box,{sx:{typography:"h6",color:"text.secondary",textAlign:"center"},children:[G.jsx(e.Trans,{id:"ZhEBp4",message:"Current liquidity pool token price"}),` 1 ${null==i?void 0:i.symbol} = ${s} ${null==r?void 0:r.symbol} ${o.i18n._({id:"wd1uHY",message:"differs from the price quoted by ZUNO by {lqAndDodoCompareText}",values:{lqAndDodoCompareText:n}})}`]})]})}function Gw({chainId:n,baseTokenStatus:i,quoteTokenStatus:o,children:r}){const{runningRequests:a}=qp(),{account:s,chainId:l}=cp();if(!s||n!==l)return G.jsx(lv,{chainId:n,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[exports.MetadataFlag.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[exports.MetadataFlag.removeLiquidity])})),c=[];i.needShowTokenStatusButton&&c.push(G.jsx(Tw,{status:i})),o.needShowTokenStatusButton&&!i.isApproving&&c.push(G.jsx(Tw,{status:o}));const u=c.length;return 2===u?G.jsx(t.Box,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:c.map((e=>e))}):1===u?c[0]:d?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:G.jsx(e.Trans,{id:"UbRKMZ",message:"Pending"})}):G.jsx(G.Fragment,{children:r})}function Yw({pool:i,addPortion:o,midPrice:s,shareOfPool:l}){var d,c,u,p,h,m;const g=t.useTheme(),[x,f]=n.useState(!1);let y="";if(o&&s){const e=new a(1).div(o.plus(1)),t=new a(o).div(o.plus(1)),n=e.times(s),r=n.plus(t);y=o?`${Vu({input:n.div(r)})} ${null===(d=null==i?void 0:i.baseToken)||void 0===d?void 0:d.symbol} + ${Vu({input:t.div(r)})} ${null===(c=null==i?void 0:i.quoteToken)||void 0===c?void 0:c.symbol}`:""}const v=x?null===(u=null==i?void 0:i.quoteToken)||void 0===u?void 0:u.symbol:null===(p=null==i?void 0:i.baseToken)||void 0===p?void 0:p.symbol,b=x&&s?new a(1).div(s):s,C=x?null===(h=null==i?void 0:i.baseToken)||void 0===h?void 0:h.symbol:null===(m=null==i?void 0:i.quoteToken)||void 0===m?void 0:m.symbol;return G.jsxs(t.Box,{sx:{mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsxs(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,ml:8,overflow:"hidden"},loading:!i,loadingProps:{width:50},children:[G.jsx(t.Tooltip,{title:`1 ${v} = ${b?Su({input:b}):""} ${C}`,children:s?G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${v} = ${b?Su({input:b}):""} ${C}`}):G.jsxs(t.Box,{children:[`1 ${v} = `,G.jsx(t.LoadingSkeleton,{loading:!0,loadingProps:{width:30},component:"span",sx:{display:"inline-block"}}),` ${C}`]})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,cursor:"pointer",backgroundColor:"background.paperDarkContrast",borderRadius:"50%","&:hover":{backgroundColor:t.alpha(g.palette.text.primary,.04)}},onClick:()=>f((e=>!e)),children:G.jsx(t.Box,{component:se.Switch,sx:{width:18,height:18}})})]})]}),"AMMV2"===(null==i?void 0:i.type)?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:g.spacing(1,0,0),borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"NEQTCn",message:"Share Of Pool"})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:l})]}):G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:g.spacing(1,0,0),borderColor:"border.main"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:[G.jsx(e.Trans,{id:"22Xs8M",message:"Deposit Ratio"}),G.jsx(t.QuestionTooltip,{ml:4,title:G.jsx(e.Trans,{id:"I0yi1d",message:"Deposit ratio is determined by the current assets ratio in the pool. The ratio does not represent the exchange price"})})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:i&&r.PoolApi.utils.singleSideLp(i.type)?G.jsx(e.Trans,{id:"Kb3KaW",message:"Any Ratio"}):G.jsx(G.Fragment,{children:G.jsx(t.Tooltip,{title:y,children:G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y})})})})]})]})}function Kw({baseToken:e,quoteToken:t}){const{toFiatPrice:n,fromFiatPrice:i}=Wp({fromToken:null!=e?e:null,toToken:null!=t?t:null});return function({fromToken:e,toToken:t,fromFiatPrice:n,toFiatPrice:i,reverse:o,showDecimals:r=1}){const a={comparePrice:null,comparePriceText:"",loading:!0};return e&&t&&n&&i?(o?(a.loading=!1,a.comparePrice=i.div(n),a.comparePriceText=`1 ${rp(t)} = ${Su({input:a.comparePrice,showDecimals:r})} ${rp(e)}`):(a.loading=!1,a.comparePrice=n.div(i),a.comparePriceText=`1 ${rp(e)} = ${Su({input:a.comparePrice,showDecimals:r})} ${rp(t)}`),a):a}({fromToken:e,toToken:t,fromFiatPrice:i?new a(i):void 0,toFiatPrice:n?new a(n):void 0})}const Xw=(e,t,i)=>{const{comparePrice:o}=Kw({baseToken:e,quoteToken:t}),r=n.useMemo((()=>{if(!(i&&o&&o.toNumber()&&i.toNumber()))return 0;const e=o.minus(i);return Math.abs(e.div(o).toNumber())}),[i,o]),s=n.useMemo((()=>`${Uu(new a(r).times(100))}%`),[r]);return{lqAndDodoCompare:r,lqAndDodoCompareText:s,midPrice:i,isShowCompare:r>.01,isWarnCompare:r>.03}};function Jw({pool:e,baseAmount:t,quoteAmount:i}){const[o,s,l,c,u,p]=n.useMemo((()=>{var t,n;const{baseToken:i,quoteToken:o}=e||{};let a=!1;if(!i||!o)return[void 0,void 0,void 0,void 0,void 0,a];const s=i.chainId,l=r.basicTokenMap[s],d=(null===(t=l.address)||void 0===t?void 0:t.toLowerCase())===i.address.toLowerCase(),c=(null===(n=l.address)||void 0===n?void 0:n.toLowerCase())===o.address.toLowerCase(),u=d?l.wrappedTokenAddress:i.address,p=c?l.wrappedTokenAddress:o.address,h=new M.Token(i.chainId,u,i.decimals,i.symbol,i.name),m=new M.Token(o.chainId,p,o.decimals,o.symbol,o.name);a=!h.sortsBefore(m);const[g,x]=a?[m,h]:[h,m];return[s,null==e?void 0:e.type,null==e?void 0:e.address,g,x,a]}),[e]),h=$u.getReserveLpQuery(o,l,s,null==c?void 0:c.decimals,null==u?void 0:u.decimals),m="AMMV2"===s,g=d.useQuery(Object.assign(Object.assign({},h),{enabled:!!h.enabled&&m})),x=$u.getTotalBaseLpQuery(o,l,s,18),f=d.useQuery(Object.assign(Object.assign({},x),{enabled:!!x.enabled&&m})),{account:y}=cp(),v=$u.getUserBaseLpQuery(o,l,s,18,y),b=d.useQuery(Object.assign(Object.assign({},v),{enabled:!!v.enabled&&m})),C=n.useMemo((()=>g.isFetched&&!!g.data&&f.isFetched&&!!f.data),[g.isFetched,g.data,f.isFetched,f.data]),[j,w]=n.useMemo((()=>{var e;if(!c||!u||!1===C)return[null,null];const{baseReserve:t,quoteReserve:n}=null!==(e=g.data)&&void 0!==e?e:{baseReserve:0,quoteReserve:0},i=M.CurrencyAmount.fromRawAmount(c,Ru(t,c.decimals).toString()),o=M.CurrencyAmount.fromRawAmount(u,Ru(n,u.decimals).toString());let r=i,a=o;p&&(r=o,a=i);const s=new P.Pair(r,a);if(r.equalTo(0)||a.equalTo(0))return[s,null];const l=a.divide(r);return[s,new M.Price(r.currency,a.currency,l.denominator,l.numerator)]}),[c,u,g.data,p]),[k,T]=n.useMemo((()=>C?w?[new a(w.toSignificant()),new a(w.invert().toSignificant())]:[void 0,void 0]:t&&i?[new a(i).div(t),new a(t).div(i)]:[void 0,void 0]),[w,C,t,i]),B=f.data,I=C?f.data&&c?Ru(f.data,18).toString():"":"0";let S,A;const E=p?u:c,O=p?c:u;if((null==j?void 0:j.liquidityToken)&&I&&B&&E&&O){const e=M.CurrencyAmount.fromRawAmount(null==j?void 0:j.liquidityToken,I);if(void 0!==t&&void 0!==i){if(Number(t)&&Number(i)){const n=M.CurrencyAmount.fromRawAmount(E,Ru(t,E.decimals).toString()),o=M.CurrencyAmount.fromRawAmount(O,Ru(i,O.decimals).toString()),r=null==j?void 0:j.getLiquidityMinted(e,n,o);A=Mu(r.quotient.toString(),18),S=A.div(B.plus(A)).times(100)}}else A=b.data||void 0,A&&(S=A.div(B).times(100))}else C||(S=new a(100));let L="-";return(null==e?void 0:e.baseToken)&&e.quoteToken&&(L=S?`${Su({input:S,showDecimals:2,roundingMode:a.ROUND_HALF_UP})}%`:"0%"),{isRearTokenA:p,pair:j,price:k,invertedPrice:T,reserveQuery:g,totalBaseLpQuery:f,liquidityMinted:A,poolTokenPercentage:S,shareOfPool:L,isExists:C}}function ek({pool:e,maxBaseAmount:t,maxQuoteAmount:i,isRemove:o}){var s,l,c;const[u,p]=n.useState(""),[h,m]=n.useState(""),g=!e||"AMMV2"!==e.type&&"AMMV3"!==e.type,x=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals)),f=()=>{p(""),m("")},y=null==e?void 0:e.type,v=Jw({pool:e,baseAmount:u,quoteAmount:h});let b=null===(c=x.data)||void 0===c?void 0:c.midPrice,C=new a(NaN),j=!1,w=!1;const k=x.data;if(e)if(k){const t=k.pmmParamsBG.i,n=k.pmmParamsBG.b,i=k.pmmParamsBG.q;w=("DSP"===e.type||"GSP"===e.type)&&(i.eq(0)||n.eq(0)),j="DVM"===e.type&&new a(i).eq(0),C=w?t:j?a(1):i.div(n)}else"AMMV2"===y&&(b=v.isRearTokenA?v.invertedPrice:v.price,C=b||new a(1));const T=n.useRef(C);if(!e||C.isNaN())return{baseAmount:u,quoteAmount:h,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:f};const B=!j&&!r.PoolApi.utils.singleSideLp(e.type),I=e.baseToken.decimals,S=e.quoteToken.decimals,A=e=>{if(e){let n=C.multipliedBy(e).dp(S).toString();i&&o&&(i.lte(n)||(null==t?void 0:t.lte(0)))&&(n=i.toString()),m(n)}else m(e)};!B||T.current&&C.isEqualTo(T.current)||(T.current=C,A(u));let E=!1;E=!!e&&r.PoolApi.utils.singleSideLp(e.type)?!u&&!h:j?!u:!u||!h;const O=g?x:v.reserveQuery;return{baseAmount:u,quoteAmount:h,handleChangeBaseAmount:e=>{let t=Lu(e,I);null===t&&(t=u),p(t),B&&A(t)},handleChangeQuoteAmount:e=>{let n=Lu(e,S);null===n&&(n=h),m(n),B&&(e=>{if(e){let n=new a(e).div(C).dp(I).toString();t&&o&&(t.lte(n)||(null==i?void 0:i.lte(0)))&&(n=t.toString()),p(n)}else p(e)})(n)},reset:f,addPortion:C,amountLoading:O.isLoading,amountError:O.isError,amountRefetch:O.refetch,amountCheckedDisabled:E,midPrice:b,uniV2Pair:v}}function tk({submittedBack:e,onlyShowSide:i,pool:a,balanceInfo:s}){var l,c,p,h,m,g;const x=t.useTheme(),{isMobile:f}=Bp(),{account:y}=cp(),{baseAmount:v,quoteAmount:b,handleChangeBaseAmount:C,handleChangeQuoteAmount:j,addPortion:w,midPrice:k,amountLoading:T,amountCheckedDisabled:B,uniV2Pair:I,reset:S}=ek({pool:a}),A=d.useQuery($u.getFeeRateQuery(null==a?void 0:a.chainId,null==a?void 0:a.address,null==a?void 0:a.type,y)),E=null===(m=null===(c=null===(l=A.data)||void 0===l?void 0:l.mtFeeRate)||void 0===c?void 0:c.plus(null!==(h=null===(p=A.data)||void 0===p?void 0:p.lpFeeRate)&&void 0!==h?h:0))||void 0===m?void 0:m.toNumber(),O="AMMV2"===(null==a?void 0:a.type),[L,R]=n.useState(!1),{slipper:M,setSlipper:P,slipperValue:_,resetSlipper:N}=nv({address:null==a?void 0:a.address,type:null==a?void 0:a.type}),D=Cv(a);n.useEffect((()=>{(null==a?void 0:a.address)!==(null==D?void 0:D.address)&&(S(),N())}),[a]);const F=r.PoolApi.utils.canOperateLiquidity(null==a?void 0:a.type,void 0,null==a?void 0:a.creator,y),[U,q]=n.useState(!1),{isShowCompare:V,lqAndDodoCompareText:H,isWarnCompare:W}=Xw(null==a?void 0:a.baseToken,null==a?void 0:a.quoteToken,k),$=O&&a.chainId?u.getUniswapV2Router02ContractAddressByChainId(a.chainId)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(a.chainId):void 0,z=lh(null==a?void 0:a.baseToken,{amount:v,contractAddress:$}),Z=lh(null==a?void 0:a.quoteToken,{amount:b,contractAddress:$}),Q=z.insufficientBalance||Z.insufficientBalance,{isSinglePool:Y}=s,K=!a||Q||!k||!!s.loading||!!s.error||B||A.isLoading;let X=O?o.i18n._({id:"bwSQI0",message:"Supply"}):o.i18n._({id:"m16xKo",message:"Add"});Q&&(X=o.i18n._({id:"znqB4T",message:"Insufficient balance"}));const J=()=>{S(),N(),e&&e()},{operateLiquidityMutation:ee}=zw(a),te=()=>{O?R(!0):ee.mutate({txTitle:o.i18n._({id:"OBdohg",message:"Add Liquidity"}),isRemove:!1,baseAmount:v,quoteAmount:b,slippageProtection:_,balanceInfo:s,SLIPPAGE_PROTECTION:tv,submittedBack:J})},ne=Zw({baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,baseAmount:v,quoteAmount:b,fee:E,isExists:!0,slippage:_,submittedBack:()=>{J(),R(!1)}});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:20,pb:18,px:20},children:["quote"===i?"":G.jsx(py,{amt:v,token:null==a?void 0:a.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:C,readOnly:s.loading||!F,sx:{backgroundColor:"background.cardInput",padding:x.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),i?"":G.jsx(cy,{}),"base"===i?"":G.jsx(py,{amt:b,token:null==a?void 0:a.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:j,readOnly:s.loading||!F||Y,sx:{backgroundColor:"background.cardInput",padding:x.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}),G.jsxs(t.LoadingSkeleton,{loading:s.loading||T,sx:{mt:8},children:[G.jsx(iv,{value:M,onChange:P,disabled:!F,type:null==a?void 0:a.type}),G.jsx(Yw,{pool:a,addPortion:w,midPrice:k,shareOfPool:null==I?void 0:I.shareOfPool})]})]}),G.jsxs(t.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[V&&G.jsx(Qw,{baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,lqAndDodoCompareText:H,midPrice:k}),a?G.jsx(Gw,{chainId:a.chainId,baseTokenStatus:z,quoteTokenStatus:Z,children:G.jsx(t.Button,{fullWidth:!0,disabled:K,danger:W,isLoading:ee.isPending||ne.isPending,onClick:()=>{K||(W?q(!0):te())},children:X})}):G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:X})]}),G.jsx(Nw,{open:U,onClose:()=>q(!1),title:o.i18n._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:te,modal:!0,children:G.jsxs(t.Box,{children:[G.jsx(t.Box,{children:o.i18n._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:H}})}),G.jsx(t.Box,{children:o.i18n._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),G.jsx(uf,{message:null===(g=ee.error)||void 0===g?void 0:g.message,onClose:()=>ee.reset(),isDialogModal:f}),O&&!!a&&G.jsx(qw,{open:L,onClose:()=>R(!1),slippage:_,baseToken:a.baseToken,baseAmount:v,quoteToken:a.quoteToken,quoteAmount:b,fee:E,price:null==I?void 0:I.price,lpAmount:null==I?void 0:I.liquidityMinted,shareOfPool:null==I?void 0:I.shareOfPool,pairAddress:a.address,createMutation:ne})]})}function nk({chainId:e,address:n,token:i,quoteToken:o,lpBalance:r,lpBalanceLoading:a,balanceNeedUpdateLoading:s,tokenBalanceList:l}){var d;const c=o?`${null==i?void 0:i.symbol}/${o.symbol}`:null!==(d=null==i?void 0:i.symbol)&&void 0!==d?d:"";return G.jsxs(t.Box,{sx:{display:"flex"},children:[i?G.jsx(t.Box,{sx:{position:"relative",top:2},children:o?G.jsx(wy,{tokens:[i,o],chainId:e,width:18,mr:4}):G.jsx(Nh,{address:i.address,width:18,height:18,chainId:e,url:i.logoURI,marginRight:4,noShowChain:!0})}):G.jsx(t.Skeleton,{width:32,height:32,sx:{mr:4}}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",wordBreak:"break-all"},children:[G.jsx(t.LoadingSkeleton,{loading:a,loadingProps:{width:30},sx:{display:"flex",alignItems:"center",mr:2},children:s?G.jsx(t.RotatingIcon,{}):Su({input:r||"-"})}),`${c} LP`,!!(null==l?void 0:l.length)&&G.jsx(t.Tooltip,{title:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:l.map((e=>G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:e.token.address,chainId:e.token.chainId,width:14,height:14,url:e.token.logoURI,marginRight:4,noShowChain:!0}),e.token.symbol]}),G.jsxs(t.LoadingSkeleton,{loading:e.loading,children:[!e.balance||e.balance.isZero()||e.balance.isNaN()?"":"~",e.balance?Su({input:e.balance}):""]})]},e.token.address)))}),sx:{padding:20,width:256},children:G.jsx(t.HoverOpacity,{component:se.DetailBorder,sx:{ml:4,width:16,height:16}})}),G.jsx(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:e?np(e,n,"address"):"",sx:{display:"inline-flex",height:14},children:G.jsx(t.HoverOpacity,{component:se.ArrowTopRightBorder,sx:{ml:4,width:14,height:14}})})]})]},n)}function ik({loading:n,hidePoolInfo:i,pool:o,balanceInfo:s}){var l,c,u,p,h,m,g;const x=t.useTheme(),f=n||!o,y=!!o&&r.PoolApi.utils.singleSideLp(o.type),{isTokenLoading:v}=Pf(),{account:b}=cp(),C=d.useQuery($u.getFeeRateQuery(null==o?void 0:o.chainId,null==o?void 0:o.address,null==o?void 0:o.type,b)),j=null===(c=null===(l=C.data)||void 0===l?void 0:l.lpFeeRate)||void 0===c?void 0:c.plus(null!==(p=null===(u=C.data)||void 0===u?void 0:u.mtFeeRate)&&void 0!==p?p:0);let w=!1,k=!1;o&&(s.userBaseLpBalance&&o.baseLpToken&&(w=v(o.baseLpToken.id,s.userBaseLpBalance)),s.userQuoteLpBalance&&o.quoteLpToken&&(k=v(o.quoteLpToken.id,s.userQuoteLpBalance)));const T="AMMV2"===(null==o?void 0:o.type);return G.jsxs(t.Box,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[i?"":G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:x.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:x.spacing(0,0,1)},children:[G.jsxs(t.Box,{children:[G.jsxs(t.LoadingSkeleton,{loading:f,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(h=null==o?void 0:o.baseToken)||void 0===h?void 0:h.symbol,"/",null===(m=null==o?void 0:o.quoteToken)||void 0===m?void 0:m.symbol,"AMMV2"===(null==o?void 0:o.type)&&G.jsx(t.LoadingSkeleton,{loading:C.isLoading,loadingProps:{width:30},sx:{typography:"h6"},children:G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vu({input:j})},components:{0:G.jsx("b",{})}})]}),sx:{maxWidth:240},children:G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:x.palette.background.tag,color:"text.secondary",whiteSpace:"nowrap"},children:Vu({input:j})})})})]}),G.jsx(t.LoadingSkeleton,{loading:f,children:G.jsx(zf,{address:null!==(g=null==o?void 0:o.address)&&void 0!==g?g:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==o?void 0:o.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==o?void 0:o.address)&&!T?G.jsxs(t.Box,{component:t.ButtonBase,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:o.chainId,address:o.address}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),G.jsxs(t.Box,{sx:{p:x.spacing(12,20)},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsx(t.Box,{sx:{mt:12},children:G.jsx(t.LoadingSkeleton,{loading:f,loadingSx:{width:100},children:y?G.jsxs(G.Fragment,{children:[G.jsx(nk,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,lpBalance:null==s?void 0:s.userBaseLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:w,tokenBalanceList:o?[{token:o.baseToken,balance:null==s?void 0:s.userBaseLpToTokenBalance,loading:s.userLpToTokenBalanceLoading}]:void 0}),G.jsx(nk,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.quoteToken,lpBalance:null==s?void 0:s.userQuoteLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.quoteToken,balance:null==s?void 0:s.userQuoteLpToTokenBalance,loading:s.userLpToTokenBalanceLoading}]:void 0})]}):G.jsx(nk,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,quoteToken:null==o?void 0:o.quoteToken,lpBalance:s.userBaseLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:w,tokenBalanceList:o?[{token:o.baseToken,balance:s.userBaseLpToTokenBalance||new a(0),loading:s.userLpToTokenBalanceLoading},{token:o.quoteToken,balance:s.userQuoteLpToTokenBalance||new a(0),loading:s.userLpToTokenBalanceLoading}]:void 0})})})]})]})}const ok=({pool:e,isBase:t,baseAmount:n,quoteAmount:i})=>{var o,r;const s="CLASSICAL"===(null==e?void 0:e.type),l=t||void 0===t,c=null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,u=null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals,p=d.useQuery(Object.assign(Object.assign({},$u.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,n&&void 0!==c?x.parseFixed(new a(n).dp(c,a.ROUND_FLOOR).toString(),c).toString():"",c)),{enabled:!!e&&!!n&&s&&l})),h=d.useQuery(Object.assign(Object.assign({},$u.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,i&&void 0!==u?x.parseFixed(new a(i).dp(u,a.ROUND_FLOOR).toString(),u).toString():"",u)),{enabled:!!e&&!!i&&s&&!l}));let m,g="",f="",y="",v="",b="",C=!1,j=null;if(e){const t=ap(e.baseToken.decimals),o=ap(e.quoteToken.decimals);if(y=Su({input:n,showDecimals:t}),v=Su({input:i,showDecimals:o}),s)if(C=l?p.isLoading:h.isLoading,j=l?p.error:h.error,l){if(p.data){g=Su({input:p.data,showDecimals:t}),b=g;const e=new a(n).minus(p.data);y=e.gt(0)?Su({input:e,showDecimals:t}):"-",m=e}}else if(h.data){f=Su({input:h.data,showDecimals:o}),b=f;const e=new a(i).minus(h.data);y=e.gt(0)?Su({input:e,showDecimals:t}):"-",m=e}}let w=[];return e&&(s?t?w.push({amount:y||"0",symbol:e.baseToken.symbol}):w.push({amount:v||"0",symbol:e.quoteToken.symbol}):(w.push({amount:y||"0",symbol:e.baseToken.symbol}),w.push({amount:v||"0",symbol:e.quoteToken.symbol}))),{withdrawFee:b,baseWithdrawFee:g,quoteWithdrawFee:f,receiveBaseAmount:y,receiveQuoteAmount:v,receiveAmountBg:m,receiveList:w,loading:C,error:j}};var rk;!function(e){e[e.base=1]="base",e[e.quote=2]="quote"}(rk||(rk={}));const ak=e=>{const[t,i]=n.useState(rk.base);let o,a;return e&&r.PoolApi.utils.singleSideLp(e.type)&&(o=t===rk.base,a=o?e.baseToken:e.quoteToken),{isBase:o,checkToken:a,checkTokenType:t,setCheckToken:i}};function sk({token:e,pool:n,sx:i,value:o,onChange:r,selectedValue:a,lpBalance:s,balanceMax:l,balanceInfo:d,loading:c}){var u;const p=null==n?void 0:n.chainId;return G.jsxs(t.Box,{sx:i,children:[G.jsxs(t.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:600},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[e?G.jsx(t.Radio,{checked:o===a,onChange:()=>r(o),sx:{mr:16}}):"",G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx(G.Fragment,{children:G.jsx(Nh,{address:e.address,width:24,height:24,chainId:e.chainId||p,url:e.logoURI,noShowChain:!0})}):n&&G.jsx(wy,{tokens:[n.baseToken,n.quoteToken],chainId:(null===(u=n.baseToken)||void 0===u?void 0:u.chainId)||p,width:24,height:24})})]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[e?`${e.symbol} LP `:n&&`${n.baseToken.symbol}\n ${n.quoteToken.symbol}\n LP `,c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{ml:4,position:"relative",top:3}}):s&&Su({input:s})||""]})]}),G.jsx(t.Box,{sx:{typography:"body2",mt:5,color:"text.secondary",textAlign:"right"},children:e?G.jsxs(G.Fragment,{children:[c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{ml:4,position:"relative",top:3}}):`≈ ${l&&Su({input:l})||""}`,` ${e.symbol}`]}):n&&d&&d.userBaseLpToTokenBalance&&d.userQuoteLpToTokenBalance?G.jsxs(G.Fragment,{children:[c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{position:"relative",top:4}}):Su({input:d.userBaseLpToTokenBalance}),` ${null==n?void 0:n.baseToken.symbol} + `,c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{position:"relative",top:4}}):Su({input:d.userQuoteLpToTokenBalance}),` ${null==n?void 0:n.quoteToken.symbol}`]}):""})]})}function lk({pool:e,checkTokenType:t,setCheckToken:n,balanceInfo:i,baseTokenBalanceUpdateLoading:o,quoteBalanceUpdateLoading:a}){if(!e)return null;const s=r.PoolApi.utils.singleSideLp(e.type);return G.jsx(G.Fragment,{children:s?G.jsxs(G.Fragment,{children:[G.jsx(sk,{token:e.baseToken,selectedValue:t,onChange:n,value:rk.base,lpBalance:i&&i.userBaseLpBalance,balanceMax:i&&i.userBaseLpToTokenBalance,loading:o}),G.jsx(sk,{selectedValue:t,onChange:n,sx:{mt:13},token:e.quoteToken,value:rk.quote,lpBalance:i&&i.userQuoteLpBalance,balanceMax:i&&i.userQuoteLpToTokenBalance,loading:a})]}):G.jsx(sk,{pool:e,value:t,onChange:n,lpBalance:i&&i.userBaseLpBalance,balanceInfo:i,loading:o||a})})}function dk({submittedBack:i,onlyShowSide:s,pool:l,balanceInfo:c}){var p,h,m,g,x,f,y,v,b,C;const j=t.useTheme(),{isMobile:w}=Bp(),{account:k}=cp(),T=c.userBaseLpToTokenBalance,B=c.userQuoteLpToTokenBalance,I=c.loading,{slipper:S,setSlipper:A,slipperValue:E,resetSlipper:O}=nv({address:null==l?void 0:l.address}),{isBase:L,checkToken:R,checkTokenType:M,setCheckToken:P}=ak(l),{baseAmount:_,quoteAmount:N,handleChangeBaseAmount:D,handleChangeQuoteAmount:F,addPortion:U,midPrice:V,amountLoading:H,amountCheckedDisabled:W,uniV2Pair:$,reset:z}=ek({pool:l,maxBaseAmount:T,maxQuoteAmount:B}),[Z,Q]=n.useState(""),[Y,K]=n.useState("");n.useEffect((()=>{const e=setTimeout((()=>{Q(_)}),80);return()=>clearTimeout(e)}),[_]),n.useEffect((()=>{const e=setTimeout((()=>{K(N)}),80);return()=>clearTimeout(e)}),[N]);const J=e=>{D(e)},ee=e=>{F(e)},te="AMMV2"===(null==l?void 0:l.type),ne=(null==l?void 0:l.chainId)?r.basicTokenMap[l.chainId]:void 0,ie=null===(p=null==ne?void 0:ne.address)||void 0===p?void 0:p.toLowerCase(),oe=null===(h=null==ne?void 0:ne.wrappedTokenAddress)||void 0===h?void 0:h.toLowerCase(),re=!!l&&[ie,oe].includes(l.baseToken.address.toLowerCase()),ae=!!l&&[ie,oe].includes(l.quoteToken.address.toLowerCase()),se=te&&l&&(re||ae),[le,de]=n.useState(!1),ce=se&&re&&!le&&ne?l?Object.assign(Object.assign({},l.baseToken),{symbol:ne.symbol,address:ne.address}):void 0:null==l?void 0:l.baseToken,ue=se&&ae&&!le&&ne?l?Object.assign(Object.assign({},l.quoteToken),{symbol:ne.symbol,address:ne.address}):void 0:null==l?void 0:l.quoteToken,pe=ok({pool:l?Object.assign(Object.assign({},l),{baseToken:ce,quoteToken:ue}):l,isBase:L,baseAmount:Z,quoteAmount:Y}),{mode:he,modeOptions:me,handleChangeMode:ge,sliderPercentage:xe,handleChangeSliderPercentage:fe,resetPercentage:ye}=function({isBase:e,pool:t,baseOverride:i,quoteOverride:r,resetAmount:a,handleChangeBaseAmount:s,handleChangeQuoteAmount:l}){const[d,c]=n.useState(rv.percentage),[u,p]=n.useState(ov),h=n.useRef(null),m=()=>{h.current&&clearTimeout(h.current)},g=()=>{m(),p(ov)};return n.useEffect((()=>m),[]),{mode:d,modeOptions:[{key:rv.quantity,value:o.i18n._({id:"PIYEqF",message:"Quantity model"})},{key:rv.percentage,value:o.i18n._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{c(e),a(),g()},sliderPercentage:u,handleChangeSliderPercentage:n=>{if(m(),n!==u&&p(n),!t)return;const o=100===n,a=()=>{if(t)if(e||void 0===e){if(i){let e=i.toString();o||(e=Ou(i.times(n/100),t.baseToken.decimals)),s(e)}}else if(r){let e=r.toString();o||(e=Ou(r.times(n/100),t.quoteToken.decimals)),l(e)}};o?a():h.current=setTimeout(a,100)},resetPercentage:g}}({isBase:L,pool:l,baseOverride:T,quoteOverride:B,resetAmount:z,handleChangeBaseAmount:J,handleChangeQuoteAmount:ee});n.useEffect((()=>{z(),ye()}),[M]);const ve=Cv(l);n.useEffect((()=>{(null==l?void 0:l.address)!==(null==ve?void 0:ve.address)&&(z(),O(),ge(rv.percentage),fe(ov))}),[l]),n.useEffect((()=>{he===rv.percentage&&fe(xe)}),[null==T?void 0:T.toString(),null==B?void 0:B.toString()]);const be=r.PoolApi.utils.canOperateLiquidity(null==l?void 0:l.type,void 0,null==l?void 0:l.creator,k),[Ce,je]=n.useState(!1),{isShowCompare:we,lqAndDodoCompareText:ke,isWarnCompare:Te}=Xw(null==l?void 0:l.baseToken,null==l?void 0:l.quoteToken,V),Be=d.useQuery($u.getFeeRateQuery(null==l?void 0:l.chainId,null==l?void 0:l.address,null==l?void 0:l.type,k)),Ie=null===(y=null===(g=null===(m=Be.data)||void 0===m?void 0:m.mtFeeRate)||void 0===g?void 0:g.plus(null!==(f=null===(x=Be.data)||void 0===x?void 0:x.lpFeeRate)&&void 0!==f?f:0))||void 0===y?void 0:y.toNumber(),{baseTokenStatus:Se,quoteTokenStatus:Ae}=function({pool:e,baseAmount:t,quoteAmount:n,balanceInfo:i}){var o,s,l,d,c;const{chainId:p,baseToken:h,quoteToken:m}=null!=e?e:{};let g="";const x="AMMV2"===(null==e?void 0:e.type);p&&(g=null!==(o=r.contractConfig[p].DODO_V1_PAIR_PROXY)&&void 0!==o?o:"",x&&(g=u.getUniswapV2Router02ContractAddressByChainId(p)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(e.chainId)));const f=null!==(l=null===(s=null==e?void 0:e.baseLpToken)||void 0===s?void 0:s.id)&&void 0!==l?l:"",y=null!==(c=null===(d=null==e?void 0:e.quoteLpToken)||void 0===d?void 0:d.id)&&void 0!==c?c:"",v="CLASSICAL"===(null==e?void 0:e.type);return{baseTokenStatus:lh(h?Object.assign(Object.assign({},h),{symbol:v?h.symbol+" LP":`${h.symbol}/${null==m?void 0:m.symbol} LP`,address:f}):void 0,{amount:x&&i.userBaseLpToTokenBalance&&i.userBaseLpBalance?new a(t).div(i.userBaseLpToTokenBalance).times(i.userBaseLpBalance).toString():t,skipQuery:!g||!f||!v&&!x,contractAddress:g,overrideBalance:x?i.userBaseLpBalance:i.userBaseLpToTokenBalance}),quoteTokenStatus:lh(m?Object.assign(Object.assign({},m),{address:y}):void 0,{amount:n,skipQuery:!g||!y||!v,contractAddress:g,overrideBalance:i.userQuoteLpToTokenBalance})}}({pool:l,baseAmount:_,quoteAmount:N,balanceInfo:c}),Ee=Se.insufficientBalance||Ae.insufficientBalance,{isSinglePool:Oe}=c,Le=Ee?o.i18n._({id:"znqB4T",message:"Insufficient balance"}):o.i18n._({id:"t/YqKh",message:"Remove"}),Re=()=>{z(),O(),i&&i()},Me=null===(v=null==$?void 0:$.pair)||void 0===v?void 0:v.liquidityToken.decimals,Pe=null===(b=c.userBaseLpBalance)||void 0===b?void 0:b.times(xe/100),_e=Pe&&void 0!==Me?Ru(Pe,Me).toString():"",{operateLiquidityMutation:Ne}=zw(l),De=function({baseToken:t,quoteToken:n,baseAmount:i,quoteAmount:s,liquidityAmount:l,slippage:c,fee:p,submittedBack:h}){const m=Up(),{account:g}=cp();e.useLingui();const{deadLine:x}=X();return d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){if(!t||!n)throw new Error("token is undefined");if(!g)throw new Error("account is undefined");if(!p)throw new Error("fee is undefined");const e=t.chainId,d=r.basicTokenMap[e].address.toLowerCase(),f=u.getUniswapV2Router02ContractAddressByChainId(e),y=u.getUniswapV2Router02FixedFeeContractAddressByChainId(e),v=!f,b=f||y;if(!b)throw new Error("AMMV2 contract address is not valid.");let C="";const j=t.address.toLowerCase()===d,w=n.address.toLowerCase()===d,k=Ru(new a(i).times(1-c),t.decimals),T=Ru(new a(s).times(1-c),n.decimals),B=Ru(p,4).toString(),I=Math.ceil(Date.now()/1e3)+(null!=x?x:600);try{if(j){const e=n.address,t=T.toString(),i=k.toString();C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidityETH(e,l,t,i,g,I):u.encodeUniswapV2Router02RemoveLiquidityETH(e,B,l,t,i,g,I)}else if(w){const e=t.address,n=k.toString(),i=T.toString();C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidityETH(e,l,n,i,g,I):u.encodeUniswapV2Router02RemoveLiquidityETH(e,B,l,n,i,g,I)}else C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidity(t.address,n.address,l,k.toString(),T.toString(),g,I):u.encodeUniswapV2Router02RemoveLiquidity(t.address,n.address,B,l,k.toString(),T.toString(),g,I)}catch(e){throw console.error("encodeUniswapV2Router02RemoveLiquidity error",e),e}return yield m.execute(o.i18n._({id:"cJtosk",message:"Remove liquidity"}),{opcode:Mp.TX,to:b,data:C,value:"0x0"},{metadata:{[exports.MetadataFlag.removeLiqidityAMMV2Position]:!0},submittedBack:h})}))})}({baseToken:ce,quoteToken:ue,baseAmount:_,quoteAmount:N,liquidityAmount:_e,slippage:E,fee:Ie,submittedBack:Re}),Fe=()=>{if(te)return De.mutate();Ne.mutate({txTitle:o.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),isRemove:!0,baseAmount:_,quoteAmount:N,slippageProtection:E,balanceInfo:c,SLIPPAGE_PROTECTION:tv,submittedBack:Re})},Ue=n.useMemo((()=>{var e;const t=new a(_),n=new a(N);return!l||Ee||!V||!!c.loading||!!c.error||W||!!pe.error||pe.loading||!!(null===(e=pe.receiveAmountBg)||void 0===e?void 0:e.lte(0))||Be.isLoading||(te?null==Pe||Pe.lte(0):!t.isFinite()||!n.isFinite()||t.lte(0)&&n.lte(0))}),[W,c.error,c.loading,_,Be.isLoading,te,Ee,Pe,V,l,N,pe.error,pe.loading,pe.receiveAmountBg]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:18,px:20},children:[!te&&G.jsxs(t.Box,{sx:{mt:20,borderStyle:"solid",borderWidth:1,borderRadius:12,borderColor:"border.main"},children:[G.jsx(t.Select,{value:he,options:me,onChange:(e,t)=>ge(t),popupOffset:0,sx:{px:20,py:12,width:"100%",backgroundColor:"transparent",color:"text.primary",typography:"body2"}}),!!l&&r.PoolApi.utils.singleSideLp(l.type)&&G.jsx(t.Box,{sx:{pt:20,pb:13,px:20,borderStyle:"solid",borderWidth:"1px 0 0"},children:G.jsx(lk,{pool:l,balanceInfo:c,checkTokenType:M,setCheckToken:P,baseTokenBalanceUpdateLoading:!1,quoteBalanceUpdateLoading:!1})})]}),G.jsx(t.Box,{sx:{pt:20},children:he===rv.percentage?G.jsx(Gy,{disabled:c.loading||!be,value:xe,onChange:fe}):R?G.jsx(py,{amt:L?_:N,token:R,canClickBalance:!0,showPercentage:!0,onInputChange:L?J:ee,readOnly:c.loading||!be,overrideBalance:L?T:B,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}):G.jsxs(G.Fragment,{children:[G.jsx(py,{amt:_,token:null==l?void 0:l.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:J,readOnly:c.loading||!be,overrideBalance:T,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),s?"":G.jsx(cy,{}),"base"===s?"":G.jsx(py,{amt:N,token:null==l?void 0:l.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:ee,readOnly:c.loading||!be||Oe,overrideBalance:B,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}})]})}),G.jsxs(t.LoadingSkeleton,{loading:c.loading||H,sx:{mt:8},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:8},children:[te&&se&&G.jsx(t.Box,{sx:{px:12,py:4,borderRadius:20,borderWidth:1,backgroundColor:"transparent",color:"primary.main",cursor:"pointer",typography:"body2","&:hover":{backgroundColor:"hover.default"}},component:"button",onClick:()=>de((e=>!e)),children:G.jsx(e.Trans,{id:"/k7Ttv",message:"Receive {0}",values:{0:le?null==ne?void 0:ne.symbol:null==ne?void 0:ne.wrappedTokenSymbol}})}),G.jsx(iv,{value:S,onChange:A,disabled:!be,type:null==l?void 0:l.type,sx:{margin:0}})]}),G.jsx(Yw,{pool:l,addPortion:U,midPrice:V,shareOfPool:null==$?void 0:$.shareOfPool})]}),!!l&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",mt:20,mb:14},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary",position:"relative",top:2},children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx(t.Box,{sx:{textAlign:"right"},children:pe.receiveList.map(((e,n)=>G.jsxs(t.Box,{sx:{mt:n>0?4:0},children:[G.jsxs(t.LoadingSkeleton,{component:"span",loading:pe.loading,loadingSx:{mr:8,width:100},sx:{display:"inline-block",typography:"h5",fontWeight:600,color:pe.receiveBaseAmount&&"0"!==pe.receiveBaseAmount?"primary.main":"text.primary"},children:[e.amount," "]}),G.jsx(t.Box,{component:"span",sx:{typography:"body2"},children:e.symbol})]},e.symbol)))})]})]}),G.jsxs(t.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[we&&G.jsx(Qw,{baseToken:null==l?void 0:l.baseToken,quoteToken:null==l?void 0:l.quoteToken,lqAndDodoCompareText:ke,midPrice:V}),l?G.jsx(Gw,{chainId:l.chainId,baseTokenStatus:Se,quoteTokenStatus:Ae,children:G.jsx(t.Button,{fullWidth:!0,disabled:Ue,danger:Te,isLoading:Ne.isPending||De.isPending,onClick:()=>{Ue||(Te?je(!0):Fe())},children:Le})}):G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:Le})]}),G.jsx(Nw,{open:Ce,onClose:()=>je(!1),title:o.i18n._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:Fe,modal:!0,children:G.jsxs(t.Box,{children:[G.jsx(t.Box,{children:o.i18n._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:ke}})}),G.jsx(t.Box,{children:o.i18n._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),G.jsx(uf,{message:null===(C=Ne.error)||void 0===C?void 0:C.message,onClose:()=>Ne.reset(),isDialogModal:w})]})}function ck({pool:i,operate:o,hidePoolInfo:r,errorRefetch:a,submittedBack:s}){var l,c,u,p,h,m;const{operateTab:g,operateTabs:x,handleChangeTab:f}=function(t=Qj.Add){const{i18n:i}=e.useLingui(),[o,r]=n.useState(t),a=n.useMemo((()=>[{key:Qj.Add,value:i._({id:"m16xKo",message:"Add"})},{key:Qj.Remove,value:i._({id:"t/YqKh",message:"Remove"})}]),[i._]);return n.useEffect((()=>{r(t)}),[t]),{operateTab:o,operateTabs:a,handleChangeTab:e=>{r(e)}}}(o),{account:y}=cp(),v=gw({account:y,pool:i?{chainId:i.chainId,address:i.address,type:i.type,baseTokenDecimals:i.baseToken.decimals,quoteTokenDecimals:i.quoteToken.decimals,baseLpTokenDecimals:null!==(c=null===(l=i.baseLpToken)||void 0===l?void 0:l.decimals)&&void 0!==c?c:18,quoteLpTokenDecimals:null!==(p=null===(u=i.quoteLpToken)||void 0===u?void 0:u.decimals)&&void 0!==p?p:18}:void 0}),b=d.useQuery($u.getPMMStateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,null===(h=null==i?void 0:i.baseToken)||void 0===h?void 0:h.decimals,null===(m=null==i?void 0:i.quoteToken)||void 0===m?void 0:m.decimals));return v.error||b.error||a?G.jsx(re,{refresh:()=>{v.error&&v.refetch(),b.error&&b.refetch(),a&&a()},sx:{my:40,height:"100%"}}):G.jsxs(G.Fragment,{children:[G.jsx(ik,{pool:i,balanceInfo:v,hidePoolInfo:r}),G.jsxs(t.Tabs,{value:g,onChange:(e,t)=>{f(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:x,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(t.TabPanel,{value:Qj.Add,children:G.jsx(tk,{pool:i,balanceInfo:v,submittedBack:s})}),G.jsx(t.TabPanel,{value:Qj.Remove,children:G.jsx(dk,{pool:i,balanceInfo:v,submittedBack:s})})]})]})}function uk({onClose:i,pool:a,address:s,operate:l,chainId:c,hasMining:u,hidePoolInfo:p,sx:h}){var m,g,x,f,y,v,b,C,j;const{account:w}=cp(),k=c?Hl[c]:"",T=xp(),B=d.useQuery(Object.assign(Object.assign({},T.getQuery(r.PoolApi.graphql.fetchPoolList,{where:{id:null!==(m=null==s?void 0:s.toLocaleLowerCase())&&void 0!==m?m:"",chain:k}})),{enabled:!!s&&!!c})),I=null===(x=null===(g=B.data)||void 0===g?void 0:g.pairs)||void 0===x?void 0:x[0],S=I&&c?function(e,t){var n,i,o,r,a,s;if(e)return{address:e.id,chainId:t,baseToken:Zu(e.baseToken,t),quoteToken:Zu(e.quoteToken,t),type:e.type,creator:e.creator,baseLpToken:{id:null===(n=e.baseLpToken)||void 0===n?void 0:n.id,decimals:Number(null!==(o=null===(i=e.baseLpToken)||void 0===i?void 0:i.decimals)&&void 0!==o?o:18)},quoteLpToken:{id:null===(r=e.quoteLpToken)||void 0===r?void 0:r.id,decimals:Number(null!==(s=null===(a=e.quoteLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18)}}}(I,c):void 0,A=s&&c?S:a,E=B.error?B.refetch:void 0,{poolOrMiningTab:O,poolOrMiningTabs:L,handleChangeTab:R}=function({hasMining:t}){const{i18n:i}=e.useLingui(),[o,r]=n.useState(_w.Liquidity);return{poolOrMiningTab:o,poolOrMiningTabs:n.useMemo((()=>{const e=[{key:_w.Liquidity,value:i._({id:"6y2TB3",message:"Liquidity"})},{key:_w.Mining,value:i._({id:"Sti4vy",message:"Mining"})}];return t?e:e.slice(0,1)}),[i._,t]),handleChangeTab:e=>{r(e)}}}({hasMining:u}),M=gw({account:w,pool:A?{chainId:A.chainId,address:A.address,type:A.type,baseTokenDecimals:A.baseToken.decimals,quoteTokenDecimals:A.quoteToken.decimals,baseLpTokenDecimals:null!==(y=null===(f=A.baseLpToken)||void 0===f?void 0:f.decimals)&&void 0!==y?y:18,quoteLpTokenDecimals:null!==(b=null===(v=A.quoteLpToken)||void 0===v?void 0:v.decimals)&&void 0!==b?b:18}:void 0}),P=!!(null===(C=M.userBaseLpBalance)||void 0===C?void 0:C.gt(0))||!!(null===(j=M.userQuoteLpBalance)||void 0===j?void 0:j.gt(0)),_=null!=c?c:null==A?void 0:A.chainId,N=null!=s?s:null==A?void 0:A.address;return G.jsx(t.Box,{sx:h,children:G.jsxs(t.Tabs,{value:O,onChange:(e,t)=>{R(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[G.jsx(t.TabsGroup,{tabs:L,tabsListSx:Object.assign({mx:20,justifyContent:"space-between"},u&&P?{"& button:last-child":{position:"relative","&::before":{content:`"${o.i18n._({id:"TY5fM3",message:"LP Tokens"})}"`,position:"absolute",top:16,right:20,px:8,py:2,borderRadius:12,transform:"scale(0.66667) translateX(100%)",transformOrigin:"right top",backgroundColor:t.alpha("#DABB1B",.2),color:"#DABB1B"}}}:{}),rightSlot:G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:["GSP"===(null==A?void 0:A.type)&&G.jsx(Pw,{}),i?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"},cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{i()}})}):void 0]})}),G.jsx(t.TabPanel,{value:_w.Liquidity,sx:{flex:1,overflowY:"auto"},children:G.jsx(ck,{pool:A,operate:l,hidePoolInfo:p,errorRefetch:E,submittedBack:()=>{u&&R(_w.Mining)}})}),G.jsx(t.TabPanel,{value:_w.Mining,sx:{flex:1,overflowY:"auto"},children:_&&N?G.jsx(Mw,{chainId:_,account:w,poolAddress:N,goLpLink:()=>{R(_w.Liquidity)}}):""})]})})}function pk(e){var{modal:t}=e,n=U(e,["modal"]);const{isMobile:i}=Bp();return G.jsx(Eh,{open:!!n.pool||!!n.address,onClose:n.onClose,scope:!i,modal:t,id:"pool-operate",children:G.jsx(uk,{...n})})}function hk({address:n,chainId:i,hideName:o,sx:a}){const s=t.useTheme(),l=xp(),{onlyChainId:c}=X(),u=d.useQuery(Object.assign({},l.getQuery(r.SystemApi.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:c||void 0}})));if(!n)return null;const p=[];return("string"==typeof n?[n]:Array.from(new Set(n)).filter((e=>!!e))).forEach((e=>{var t,n,o;e&&(null===(o=null===(n=null===(t=u.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===n?void 0:n.partnerRewards)||void 0===o||o.some((t=>{var n,o,r,a,s,l,d,c,h,m,g,x,f,y;if((null==t?void 0:t.chainId)===i&&(null===(n=null==t?void 0:t.pool)||void 0===n?void 0:n.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=u.data)||void 0===o?void 0:o.liquidity_getLpPartnerRewards)||void 0===r?void 0:r.partnerInfos)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.partner)===t.partner));if(!e)return;p.push({partner:{name:null!==(s=null==e?void 0:e.partner)&&void 0!==s?s:"",logo:null!==(l=null==e?void 0:e.logo)&&void 0!==l?l:"",introduction:null!==(d=null==e?void 0:e.introduction)&&void 0!==d?d:"",link:null!==(c=null==e?void 0:e.link)&&void 0!==c?c:"",extra:null!==(h=null==e?void 0:e.extra)&&void 0!==h?h:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(g=null==e?void 0:e.theme)||void 0===g?void 0:g[1])||void 0},reward:null!==(x=null==t?void 0:t.reward)&&void 0!==x?x:"",type:null!==(f=null==t?void 0:t.type)&&void 0!==f?f:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==p?void 0:p.length)?(p.sort(((e,t)=>e.sort-t.sort)),G.jsx(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:p.map((n=>G.jsx(t.Tooltip,{leaveDelay:100,title:G.jsxs(t.Box,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[n.partner.introduction,!!n.partner.link&&G.jsxs(t.Box,{component:"a",target:"_blank",href:n.partner.link,rel:"noopener noreferrer",sx:{display:"flex",alignItems:"center",gap:4,color:"primary.main","&:hover":{opacity:.5}},children:[G.jsx(e.Trans,{id:"zwWKhA",message:"Learn more"})," ",G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 2.91667V11.0833H11.0833V7H12.25V11.0833C12.25 11.725 11.725 12.25 11.0833 12.25H2.91667C2.26917 12.25 1.75 11.725 1.75 11.0833V2.91667C1.75 2.275 2.26917 1.75 2.91667 1.75H7V2.91667H2.91667ZM8.16667 2.91667V1.75H12.25V5.83333H11.0833V3.73917L5.34917 9.47333L4.52667 8.65083L10.2608 2.91667H8.16667Z",fill:"currentColor"})})]})]}),children:G.jsxs(t.ButtonBase,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:s.spacing(0,4),height:20,borderRadius:4,background:n.partner.background,color:n.partner.color,whiteSpace:"nowrap"},children:[G.jsx(t.Box,{component:"img",src:n.partner.logo,alt:n.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!o&&!!n.reward&&G.jsx(t.Box,{sx:{fontSize:"10px",fontWeight:600},children:n.reward})]})},n.partner.name+n.reward)))})):null}var mk,gk;function xk(){return xk=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},xk.apply(null,arguments)}const fk=e=>D.createElement("svg",xk({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mk||(mk=D.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),gk||(gk=D.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.5 12.25H12.25V8.5H8.5V12.25ZM14.125 23.5H17.875V19.75H14.125V23.5ZM12.25 23.5H8.5V19.75H12.25V23.5ZM8.5 17.875H12.25V14.125H8.5V17.875ZM17.875 17.875H14.125V14.125H17.875V17.875ZM19.75 8.5V12.25H23.5V8.5H19.75ZM17.875 12.25H14.125V8.5H17.875V12.25ZM19.75 17.875H23.5V14.125H19.75V17.875ZM23.5 23.5H19.75V19.75H23.5V23.5Z",fill:"#1A1A1B"}))),yk="_default";function vk({value:e,onChange:n,placeholder:o,options:r,sx:a,readOnly:s,valueOnlyIcon:l}){const d=t.useTheme();return G.jsx(t.Select,{value:null!=e?e:yk,onChange:(t,i)=>{const o="number"==typeof e&&i?Number(i):i;n(o===yk?void 0:o)},disabled:s,sx:i.merge({padding:d.spacing(8,12),"& .MuiSelect-select.MuiSelect-select.MuiSelect-select":{display:"flex",alignItems:"center",gap:8,padding:d.spacing(8,12,8,12),minHeight:"auto",backgroundColor:"transparent",color:"text.primary",borderRadius:8,typography:"body2",fontWeight:600,borderStyle:"solid",borderWidth:1,borderColor:"divider","& svg, & img":{width:24,height:24},'&:hover, &[aria-expanded="true"]':{backgroundColor:"background.paper"},"&.Mui-readOnly":{color:"text.disabled"}},"& .MuiSelect-icon":{color:s?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},a),renderValue:n=>{if(!(null==n?void 0:n.value)||n.value===yk)return G.jsx(t.Box,{sx:{color:"text.secondary"},children:null!=o?o:""});const i=r.find((t=>t.key===e));return i?G.jsxs(G.Fragment,{children:[i.logo,l?"":i.value]}):null},options:[...r]})}function bk({isMobileStyle:e,chain:n,isLastItem:i,logoWidth:o,mobileLogoWidth:r,sx:a}){const s=t.useTheme();return e?G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",py:18,borderTop:`1px solid ${s.palette.border.main}`,borderBottom:i?`1px solid ${s.palette.border.main}`:"none"},a),children:[G.jsx(t.Box,{component:null==n?void 0:n.logo,sx:{width:r,height:r}}),G.jsx(t.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==n?void 0:n.name})]}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{component:null==n?void 0:n.logo,sx:{width:o,height:o}}),G.jsx(t.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==n?void 0:n.name})]})}const Ck=-1;function jk({chainId:i,setChainId:o,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:s=24,mainMobileLogoWidth:l=18,notShowAllChain:d,valueOnlyIcon:c,sx:u}){const p=function(){const{chainId:e}=cp(),t=n.useMemo((()=>{const t=new Map;let n;return ac.forEach(((i,o)=>{if(i.mainnet){if(e!==i.chainId)return;n=i.mainnet}t.set(o,Object.assign({},i))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e]);return t}(),[h,m]=n.useState(!1),{isMobile:g}=Bp(),{i18n:x}=e.useLingui(),f=n.useCallback((()=>{const e=void 0===i?p[0]:p.find((e=>e.chainId===i));if(c){if(void 0===i||!e)return"";const n=g?a:s;return G.jsx(t.Box,{component:null==e?void 0:e.logo,sx:{width:n,height:n}})}return void 0!==i||d?e?G.jsx(bk,{isMobileStyle:g,chain:e,logoWidth:s,mobileLogoWidth:l}):null:G.jsx(bk,{isMobileStyle:g,chain:{chainId:Ck,logo:fk,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:s,mobileLogoWidth:l,sx:{border:"none"}})}),[i,p,d,c,g,x._]),y=n.useMemo((()=>{const e=[];return d||e.push({key:Ck,value:G.jsx(bk,{isMobileStyle:g,chain:{chainId:Ck,logo:fk,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),p.forEach(((t,n)=>{e.push({key:t.chainId,value:G.jsx(bk,{isLastItem:n===p.length-1,isMobileStyle:g,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[g,r,a,p,d]);return g?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>m(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",color:"text.primary",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},u),children:[G.jsx(t.Box,{sx:{pr:5},children:f()}),G.jsx(t.Box,{component:se.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),G.jsx(Eh,{open:h,title:G.jsx(e.Trans,{id:"lJvbHq",message:"Select Network"}),onClose:()=>m(!1),id:"select-chain",modal:!0,children:G.jsx(t.Box,{sx:{mb:20},children:y.map((e=>G.jsxs(t.Box,{onClick:()=>{const t=e.key;o(t===Ck?void 0:Number(t)),m(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(i?e.key===i:e.key===Ck)&&G.jsx(t.Box,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):G.jsx(vk,{value:null!=i?i:Ck,onChange:e=>{y.some((t=>String(t.key)===String(e)))&&o(e===Ck?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:y,valueOnlyIcon:c,sx:Object.assign({px:8,height:32,fontWeight:600,typography:"body2",backgroundColor:"background.tag",color:"text.primary"},u)})}function wk({lqList:e,onDeleteTag:n,sx:i}){var o;if(!(null==e?void 0:e.length))return null;if(!(null===(o=e[0])||void 0===o?void 0:o.pair))return null;const{pair:r}=e[0],a=Zu(r.baseToken,r.chainId),s=Zu(r.quoteToken,r.chainId);return a&&s?G.jsxs(t.Box,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},i),children:[G.jsx(wy,{tokens:[a,s],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",s.symbol,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n()})]}):null}const kk=e=>{const{filterList:n,value:i,onChange:o}=e,r=t.useTheme();return G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:n.map(((e,a)=>G.jsx(t.Box,{sx:Object.assign(Object.assign({borderLeftWidth:1,borderRightWidth:a===n.length-1?1:0,borderTopWidth:1,borderBottomWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",typography:"body2",lineHeight:"30px",color:r.palette.text.secondary,px:20,cursor:"pointer",borderTopLeftRadius:0===a?8:0,borderBottomLeftRadius:0===a?8:0,borderTopRightRadius:a===n.length-1?8:0,borderBottomRightRadius:a===n.length-1?8:0},i===e.value?{backgroundColor:r.palette.border.disabled,color:r.palette.text.primary}:{}),{[r.breakpoints.down("tablet")]:{flexGrow:1,flexBasis:"25%",textAlign:"center"}}),onClick:()=>o(e.value),children:e.label},e.value)))})},Tk=({sx:n,isRightTop:i,isReverseColor:o})=>{const r=t.useTheme();return G.jsx(t.Box,{sx:Object.assign(Object.assign(Object.assign({display:"inline-flex",padding:"2px 4px",alignItems:"center",gap:"4px",borderRadius:4,background:t.alpha(r.palette.warning.main,.1),color:r.palette.warning.main,fontSize:"10px",fontWeight:600,lineHeight:"14px"},i?{position:"absolute",top:-14,right:0,background:`linear-gradient(0deg, ${r.palette.warning.main}1A 0%, ${r.palette.warning.main}1A 100%), ${r.palette.background.paper}`}:void 0),o?{background:"light"===r.palette.mode?"linear-gradient(0deg, var(--label-warning, rgba(177, 86, 0, 0.10)) 0%, var(--label-warning, rgba(177, 86, 0, 0.10)) 100%), #FFF":"linear-gradient(0deg, #FFFFFF, #FFFFFF),linear-gradient(0deg, rgba(235, 141, 39, 0.1), rgba(235, 141, 39, 0.1))",zIndex:1}:void 0),n),children:G.jsx(e.Trans,{id:"y5rS9U",message:"Migrate"})})};function Bk({chainId:n,baseToken:i,quoteToken:o,apy:r,hasQuote:s,hasMining:l,sx:d,children:c}){if(!i)return null;const u=s?[{token:i,transactionApy:null==r?void 0:r.transactionBaseApy,miningApy:null==r?void 0:r.miningBaseApy},{token:o,transactionApy:null==r?void 0:r.transactionQuoteApy,miningApy:null==r?void 0:r.miningQuoteApy}]:[{transactionApy:null==r?void 0:r.transactionBaseApy,miningApy:null==r?void 0:r.miningBaseApy,metromMiningApy:null==r?void 0:r.metromMiningApy}];return G.jsx(t.Tooltip,{children:null!=c?c:G.jsx(t.HoverOpacity,{component:se.QuestionBorder,sx:Object.assign({width:15,height:15},d)}),title:G.jsx(t.Box,{sx:{minWidth:236},children:u.map(((r,s)=>{var d,c,u,p,h;return G.jsxs(t.Box,{sx:{mt:0===s?0:20},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:r.token?G.jsxs(G.Fragment,{children:[G.jsx(Nh,{width:14,height:14,marginRight:4,address:r.token.address,url:r.token.logoURI,chainId:n,noShowChain:!0}),r.token.symbol]}):G.jsxs(G.Fragment,{children:[G.jsx(wy,{tokens:[i,o],width:14,mr:4,chainId:n}),i.symbol,"/",null==o?void 0:o.symbol]})}),G.jsx(t.Box,{children:Hu(new a(null!==(u=r.transactionApy)&&void 0!==u?u:0).plus(null!==(p=r.miningApy)&&void 0!==p?p:0).plus(null!==(h=r.metromMiningApy)&&void 0!==h?h:0))})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"})}),G.jsx("span",{children:r.transactionApy?Hu(new a(r.transactionApy)):"-"})]}),l?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"})}),G.jsx("span",{children:r.miningApy?Hu(new a(r.miningApy)):"-"})]}):"",r.metromMiningApy&&Number(r.metromMiningApy)>0&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})}),G.jsx("span",{children:r.metromMiningApy?Hu(new a(r.metromMiningApy)):"-"})]})]},null!==(c=null===(d=r.token)||void 0===d?void 0:d.address)&&void 0!==c?c:1)}))})})}function Ik({list:n,onClick:i}){return G.jsx(G.Fragment,{children:null==n?void 0:n.map((n=>{var o,s,l,d;if(!(null==n?void 0:n.pair))return null;const c=n.pair,u=Zu(c.baseToken,c.chainId),p=Zu(c.quoteToken,c.chainId),h=c.apy?Hu(new a(null===(o=c.apy)||void 0===o?void 0:o.transactionBaseApy).plus(null!==(l=null===(s=c.apy)||void 0===s?void 0:s.miningBaseApy)&&void 0!==l?l:0)):void 0,m=r.PoolApi.utils.singleSideLp(c.type)&&c.apy?Hu(new a(c.apy.transactionQuoteApy).plus(null!==(d=c.apy.miningQuoteApy)&&void 0!==d?d:0)):void 0;return u&&p?G.jsxs(t.Box,{onClick:i,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(wy,{tokens:[u,p],chainId:c.chainId,width:24,mr:10}),G.jsxs(t.Box,{sx:{typography:"h5"},children:[u.symbol,"/",p.symbol]})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:[h,m?`/${m}`:""]}),G.jsx(t.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]},c.id):null}))})}function Sk(e){var t;const[i,o]=n.useState(null!==(t=null==e?void 0:e.tokens)&&void 0!==t?t:[]),[r,a]=n.useState([]);n.useEffect((()=>{e&&(o(e.tokens),a(e.lqList))}),[e]);const[s,l]=n.useMemo((()=>{const[e,t]=i;return[null==e?void 0:e.symbol,null==t?void 0:t.symbol]}),[i]);return{filterTokens:i,filterASymbol:s,filterBSymbol:l,filterAddressLqList:r,handleDeleteToken:t=>{o((n=>{const i=[...n],o=i.indexOf(t);return-1!==o&&i.splice(o,1),e&&e.onChangeFilterTokens(i),i}))},handleChangeFilterTokens:t=>{a([]),o(t),e&&(e.onChangeFilterTokens(t),e.onChangeFilterAddressLqList([]))},handleChangeFilterAddress:t=>{a(t),o([]),e&&(e.onChangeFilterTokens([]),e.onChangeFilterAddressLqList(t))}}}const Ak=e=>{const{direction:n,children:i,onClick:o}=e,r=t.useTheme();return G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:2,typography:"h6",lineHeight:"20px",color:r.palette.text.secondary,cursor:"pointer","&:hover":{opacity:.8}},onClick:o,children:[i,G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("path",{d:"M5.0625 5.82469L5.98781 6.75L9 3.74438L12.0122 6.75L12.9375 5.82469L9 1.88719L5.0625 5.82469Z",fill:"asc"===n?r.palette.text.primary:r.palette.text.disabled}),G.jsx("path",{d:"M5.0625 12.1753L5.98781 11.25L9 14.2556L12.0122 11.25L12.9375 12.1753L9 16.1128L5.0625 12.1753Z",fill:"desc"===n?r.palette.text.primary:r.palette.text.disabled})]})]})};function Ek({lqList:n,setOperatePool:i,getMigrationPairAndMining:o,supportAMM:s,timeRange:l}){const d=t.useTheme(),{onSharePool:c}=X();return G.jsx(G.Fragment,{children:null==n?void 0:n.map((n=>{var u,p,h,m,g,x,f,y,v;if(!(null==n?void 0:n.pair))return null;const b=n.pair,C=Zu(b.baseToken,b.chainId),j=Zu(b.quoteToken,b.chainId),w=null===(u=b.apyList)||void 0===u?void 0:u.find((e=>(null==e?void 0:e.timeRange)===`${l}D`)),k=w?Hu(new a(null==w?void 0:w.transactionBaseApy).plus(null!==(p=null==w?void 0:w.miningBaseApy)&&void 0!==p?p:0)):void 0,T=r.PoolApi.utils.singleSideLp(b.type)&&w?Hu(new a(w.transactionQuoteApy).plus(null!==(h=w.miningQuoteApy)&&void 0!==h?h:0)):void 0,B=!!(null===(m=b.miningAddress)||void 0===m?void 0:m[0]),I=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,S=b.type,A=Yu(S),E="AMMV2"===S,O="AMMV3"===S,L=null==o?void 0:o({address:b.id,chainId:b.chainId});return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{s||zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:b.chainId,address:b.id}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[C&&j?G.jsx(wy,{tokens:[C,j],width:24,mr:6,chainId:b.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==C?void 0:C.symbol}/${null==j?void 0:j.symbol}`,!!c&&G.jsx(t.Box,{component:se.Share,sx:{ml:2,width:12,height:12},onClick:()=>c({chainId:b.chainId,baseToken:C,quoteToken:j,poolId:b.id,apy:w,isSingle:r.PoolApi.utils.singleSideLp(b.type)})}),G.jsx(hk,{address:b.id,chainId:b.chainId})]}),!!L&&G.jsx(Tk,{})]}),B||I?G.jsxs(t.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${t.alpha(d.palette.secondary.main,.3)} 0%, ${t.alpha(d.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[s&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[A,G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:O?null!==(x=null===(g=sj[b.lpFeeRate])||void 0===g?void 0:g.label)&&void 0!==x?x:"-":Vu({input:new a(null!==(f=b.lpFeeRate)&&void 0!==f?f:0).plus(b.mtFeeRate?Mu(b.mtFeeRate,E?4:18):0)})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5",color:"success.main"},children:[k,T?`/${T}`:""]}),G.jsxs(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[l,"d ",G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(Bk,{chainId:b.chainId,apy:w,baseToken:C,quoteToken:j,hasQuote:!!T,hasMining:B,sx:{width:14,height:14}})]})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",Xu({input:b.tvl,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),s&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:["$",Xu({input:null===(v=null===(y=b.volumeList)||void 0===y?void 0:y.find((e=>(null==e?void 0:e.timeRange)===`${l}D`)))||void 0===v?void 0:v.volume,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"iuFFMB",message:"Volume ({timeRange}d)",values:{timeRange:l}})})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),i({pool:Qu(n),hasMining:B})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),s&&"PMM"===A&&G.jsx(Wj,{chainId:b.chainId,address:b.id})]})]},b.id+b.chainId)}))})}function Ok({lqList:n,loading:i,operatePool:s,setOperatePool:l,getMigrationPairAndMining:d,hasMore:c,loadMore:u,loadMoreLoading:p,supportAMM:h,timeRange:m,setOrderBy:g,setOrderDirection:x,orderBy:f,orderDirection:y}){const v=t.useTheme(),{onSharePool:b}=X();return G.jsxs($j,{hasMore:c,loadMore:u,loadMoreLoading:p,empty:!(null==n?void 0:n.length),loading:i,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),h&&G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),G.jsx(t.Box,{component:"th",children:G.jsx(Ak,{direction:"tvl"===f?y:null,onClick:()=>{"tvl"!==f?(g("tvl"),x("desc")):x("asc"===y?"desc":"asc")},children:"TVL"})}),G.jsx(t.Box,{component:"th",children:G.jsxs(Ak,{direction:"apy"===f?y:null,onClick:()=>{"apy"!==f?(g("apy"),x("desc")):x("asc"===y?"desc":"asc")},children:[m,"d APY"]})}),h&&G.jsx("th",{children:G.jsxs(Ak,{direction:"volume"===f?y:null,onClick:()=>{"volume"!==f?(g("volume"),x("desc")):x("asc"===y?"desc":"asc")},children:[m,"d Volume"]})}),G.jsx(t.Box,{component:"th",sx:{width:80}})]})}),G.jsx(t.Box,{component:"tbody",children:null==n?void 0:n.map((e=>{var n,i,c,u,p,g,x,f;if(!(null==e?void 0:e.pair))return null;const y=e.pair,C=Zu(y.baseToken,y.chainId),j=Zu(y.quoteToken,y.chainId),w=null===(n=y.apyList)||void 0===n?void 0:n.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)),k=w?Hu(new a(null==w?void 0:w.transactionBaseApy).plus(null!==(i=null==w?void 0:w.miningBaseApy)&&void 0!==i?i:0).plus(null!==(c=null==w?void 0:w.metromMiningApy)&&void 0!==c?c:0)):void 0,T=r.PoolApi.utils.singleSideLp(y.type)&&w?Hu(new a(w.transactionQuoteApy).plus(null!==(u=w.miningQuoteApy)&&void 0!==u?u:0)):void 0;let B="";if((null===(p=null==s?void 0:s.pool)||void 0===p?void 0:p.address)===y.id||(null==s?void 0:s.address)===y.id)if(s.operate===Qj.Remove)B=o.i18n._({id:"0+31GV",message:"Removing"});else B=o.i18n._({id:"1yHVE+",message:"Adding"});const I=!!(null===(g=y.miningAddress)||void 0===g?void 0:g[0]),S=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,A=y.type,E=Yu(A),O="AMMV2"===A,L="AMMV3"===A,R=v.palette.hover.default,M=null==d?void 0:d({address:y.id,chainId:y.chainId});return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(B?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[C&&j?G.jsx(wy,{tokens:[C,j],width:24,mr:8,chainId:y.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==C?void 0:C.symbol}/${null==j?void 0:j.symbol}`,G.jsx(hk,{address:y.id,chainId:y.chainId}),!!M&&G.jsx(Tk,{})]}),G.jsx(zf,{address:y.id,customChainId:y.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,onShareClick:b?()=>b({chainId:y.chainId,baseToken:C,quoteToken:j,poolId:y.id,apy:w,isSingle:r.PoolApi.utils.singleSideLp(y.type)}):void 0,sx:{typography:"h6",color:"text.secondary"},disabledAddress:h,onAddressClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:y.chainId,address:y.id}})}})]})]})}),h&&G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(lj,{poolType:E}),G.jsx(dj,{isAMMV2:O,isAMMV3:L,lpFeeRate:y.lpFeeRate,mtFeeRate:y.mtFeeRate})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:y.tvl?`$${Au({input:y.tvl,decimals:2})}`:void 0,children:["$",Xu({input:y.tvl,decimals:2})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[I||S?G.jsx(t.Tooltip,{title:o.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(Bk,{chainId:y.chainId,apy:w,baseToken:C,quoteToken:j,hasQuote:!!T,hasMining:I,children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[k,T?`/${T}`:""]})})]})}),h&&G.jsxs(t.Box,{component:"td",sx:{typography:"body2"},children:["$",Xu({input:null===(f=null===(x=y.volumeList)||void 0===x?void 0:x.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)))||void 0===f?void 0:f.volume,decimals:2})]}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[h&&"PMM"===E&&G.jsx(Wj,{chainId:y.chainId,address:y.id}),B?G.jsx(Vj,{text:B,onClick:()=>l(null)}):G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({pool:Qu(e),hasMining:I})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})})]},y.id+y.chainId)}))})]})}function Lk({scrollParentRef:e,filterChainIds:o,activeChainId:a,handleChangeActiveChainId:s,operatePool:l,setOperatePool:c,tokenAndPoolFilter:u,getMigrationPairAndMining:p,children:h}){var m,g;const x=t.useTheme(),{onlyChainId:f,supportAMMV2:y,supportAMMV3:v,notSupportPMM:b}=X(),{minDevice:C,isMobile:j}=Bp(),w=d.useQueryClient(),[k,T]=n.useState("all"),[B,I]=n.useState("1"),[S,A]=n.useState("desc"),[E,O]=n.useState("tvl"),{filterTokens:L,filterASymbol:M,filterBSymbol:P,filterAddressLqList:_,handleDeleteToken:N,handleChangeFilterTokens:D,handleChangeFilterAddress:F}=Sk(u),U=n.useMemo((()=>{if(v&&"v3"===k)return["AMMV3"];if(y&&"v2"===k)return["AMMV2"];if(!b&&"pmm"===k)return["CLASSICAL","DVM","DSP","GSP"];let e=b?[]:["CLASSICAL","DVM","DSP","GSP"];return y&&e.push("AMMV2"),v&&e.push("AMMV3"),e}),[b,y,v,k]),V=n.useMemo((()=>({chainIds:o,pageSize:j?4:8,filterState:{viewOnlyOwn:!1,filterTypes:U},order:{timeRange:`${B}D`,orderDirection:S,orderBy:E}})),[o,U,j,B,E,S]),H=xp(),W=H.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},V),{filterState:Object.assign({filterASymbol:M,filterBSymbol:P},V.filterState)})}),$=d.useInfiniteQuery(Object.assign(Object.assign({},W),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:i,pageSize:o}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!i||!o)return null;let r=Math.floor(i/o);return i%o&&(r+=1),n>=r?null:n+1}}));let z=[];const Z=!!(null==_?void 0:_.length);Z?z=[..._]:null===(m=$.data)||void 0===m||m.pages.forEach((e=>{var t,n;null===(n=null===(t=e.liquidity_list)||void 0===t?void 0:t.lqList)||void 0===n||n.forEach((e=>{null==z||z.push(e)}))}));const Q=$.hasNextPage&&!Z;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[x.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[x.breakpoints.up("tablet")]:{mr:"auto"}},children:h}),!f&&G.jsx(jk,{chainId:a,setChainId:s}),(y||v)&&G.jsx(kk,{filterList:[{label:"All",value:"all"}].concat(b?[]:[{label:"PMM",value:"pmm"}]).concat(y?[{label:"V2",value:"v2"}]:[]).concat(v?[{label:"V3",value:"v3"}]:[]),value:k,onChange:e=>T(e)}),G.jsx(kk,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:B,onChange:e=>I(e)}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},j?{}:{"& > button":{flex:1}}),children:null!==(g=null==u?void 0:u.element)&&void 0!==g?g:G.jsx(Zj,{value:L,onChange:D,searchAddress:(e,t)=>q(this,void 0,void 0,(function*(){var n;const i=H.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},V),{filterState:Object.assign({address:e},V.filterState)})}),o=null===(n=(yield w.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?G.jsx(Ik,{list:o,onClick:()=>{F(o),t()}}):null}))})}),(Z||!!L.length)&&G.jsxs(t.Box,{sx:{my:0},children:[Z?G.jsx(wk,{lqList:_,onDeleteTag:()=>F([])}):"",G.jsx(Hj,{tags:L,onDeleteTag:N})]})]})]}),j?G.jsx(R,{hasMore:Q,threshold:300,loadMore:i.debounce((()=>{$.hasNextPage&&!$.isFetching&&$.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:G.jsx(zj,{sx:{mt:20}},"loader"),children:G.jsxs(qj,{children:[$.isLoading?G.jsx(zj,{}):"",!$.isLoading&&!(null==z?void 0:z.length)&&!$.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!(a&&!f||M||P)}),!!$.error&&G.jsx(re,{refresh:$.refetch,sx:{mt:40}}),G.jsx(Ek,{lqList:z,setOperatePool:c,supportAMM:y||v,getMigrationPairAndMining:p,timeRange:B})]})}):G.jsxs(G.Fragment,{children:[G.jsx(Ok,{lqList:z,loading:$.isLoading,operatePool:l,setOperatePool:c,hasMore:Q,loadMoreLoading:$.isFetchingNextPage,loadMore:()=>{$.hasNextPage&&!$.isFetching&&$.fetchNextPage()},supportAMM:y||v,timeRange:B,getMigrationPairAndMining:p,orderBy:E,orderDirection:S,setOrderBy:O,setOrderDirection:A}),G.jsx(ky,{loading:$.isLoading,refetch:$.error?$.refetch:void 0,empty:!(null==z?void 0:z.length),hasSearch:!!(a&&!f||M||P)})]})]})}function Rk({onClick:e,title:n,desc:i}){const o=t.useTheme();return G.jsx(t.Box,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${o.palette.border.main}`,[o.breakpoints.up("tablet")]:{maxWidth:236,borderTop:"none",mx:0,px:16,py:8}},children:G.jsxs(t.ButtonBase,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,p:0,borderRadius:8,textAlign:"left","&:hover":{backgroundColor:o.palette.background.tag},[o.breakpoints.up("tablet")]:{p:8}},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:o.palette.text.primary},children:n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary},children:i})]})})}const Mk=i=>{const o=t.useTheme(),{isMobile:r}=Bp(),{supportAMMV2:a,supportAMMV3:s,notSupportPMM:l}=X(),[d,c]=n.useState(!1),u={[exports.PageType.CreatePool]:!l,[exports.PageType.createPoolAMMV2]:!!a,[exports.PageType.createPoolAMMV3]:!!s},p=Object.entries(u).filter((([e,t])=>!0===t)),h=1===p.length?p[0][0]:void 0;if(!h){const n=G.jsxs(G.Fragment,{children:[!l&&G.jsx(Rk,{onClick:()=>{zy.getState().push({type:exports.PageType.CreatePool})},title:G.jsx(e.Trans,{id:"Eif7f6",message:"PMM Pool"}),desc:G.jsx(e.Trans,{id:"LQ0J1B",message:"Flexible customization, take full control of liquidity"})}),a&&G.jsx(Rk,{onClick:()=>{zy.getState().push({type:exports.PageType.createPoolAMMV2})},title:G.jsx(e.Trans,{id:"lNYomJ",message:"AMM V2 Position"}),desc:G.jsx(e.Trans,{id:"lLbR0m",message:"Simple, full-range liquidity"})}),s&&G.jsx(Rk,{onClick:()=>{zy.getState().push({type:exports.PageType.createPoolAMMV3})},title:G.jsx(e.Trans,{id:"sVlqoo",message:"AMM V3 Position"}),desc:G.jsx(e.Trans,{id:"EkAv3P",message:"Concentrated liquidity, higher efficiency"})})]});return r?G.jsxs(G.Fragment,{children:[G.jsxs(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{c(!0)},sx:{height:36},children:[G.jsx(t.Box,{component:se.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]}),G.jsx(Eh,{open:d,title:G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{c(!1)},modal:!0,children:G.jsx(t.Box,{sx:{mb:0},children:n})})]}):G.jsx(t.Tooltip,{arrow:!1,leaveDelay:300,placement:r?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:G.jsx(t.Box,{children:n}),children:G.jsxs(t.Box,{sx:{width:r?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,pl:8,pr:16,py:6,borderRadius:40,backgroundColor:o.palette.background.tag,typography:"body2",fontWeight:600,color:o.palette.text.link,cursor:"pointer","&:hover":{backgroundColor:t.alpha(o.palette.primary.main,.1)}},children:[G.jsx(t.Box,{component:se.Plus}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})})}return G.jsxs(t.Button,{variant:t.Button.Variant.outlined,fullWidth:r,onClick:()=>{zy.getState().push({type:h})},sx:{height:40},children:[G.jsx(t.Box,{component:se.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})},Pk="DODO_WIDGET_POOL_LIST_TOP_TAB",_k="DODO_WIDGET_POOL_LIST_TAB",Nk="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var Dk,Fk,Uk,qk;!function(e){e.ALM="ALM",e.NORMAL="NORMAL",e.MULTI_TOKEN="MULTI_TOKEN"}(Dk||(Dk={})),function(e){e.ALL="ALL",e.MY="MY"}(Fk||(Fk={})),function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(Uk||(Uk={})),function(e){e.ALL="ALL",e.MY="MY"}(qk||(qk={}));const Vk=(e,n,i)=>{let r=o.i18n._({id:"TJBHlP",message:"Standard"}),a=i.palette.purple.main;switch(e){case"DSP":r=o.i18n._({id:"J7M/DA",message:"Pegged"}),a=i.palette.success.main;break;case"DPP":r=o.i18n._({id:"zwBp5t",message:"Private"}),a=i.palette.error.main}"DVM"===e&&(!n||n.isZero())&&(r=o.i18n._({id:"S8G1qk",message:"Single"}),a=i.palette.warning.main);return{typeLabel:r,typeColor:a,typeBgColor:t.alpha(a,.1)}};function Hk({account:n,list:i,setOperatePool:o}){const r=t.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var s,l,d,c,u;if(!i)return null;const p=null!==(s=i.pairAddress)&&void 0!==s?s:"",h=i.chainId,m=i.poolType,g={chainId:h,address:null!==(l=i.baseAddress)&&void 0!==l?l:"",symbol:null!==(d=i.baseSymbol)&&void 0!==d?d:""},x={chainId:h,address:null!==(c=i.quoteAddress)&&void 0!==c?c:"",symbol:null!==(u=i.quoteSymbol)&&void 0!==u?u:""},{typeLabel:f,typeColor:y,typeBgColor:v}=Vk(m,i.quoteReserve?new a(i.quoteReserve):null,r);return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:h,address:p}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[g&&x?G.jsx(wy,{tokens:[g,x],width:24,mr:8,chainId:h,showChainLogo:!0}):"",G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},children:tp(p)}),"DPP"===m&&G.jsx(t.HoverAddBackground,{sx:{ml:2},component:t.ButtonBase,onClick:e=>{e.stopPropagation(),zy.getState().push({type:exports.PageType.ModifyPool,params:{chainId:h,address:p}})},children:G.jsx(t.Box,{component:se.Edit,sx:{width:12,height:12,cursor:"pointer"}})})]}),G.jsx(t.Box,{sx:{typography:"h6",width:"max-content",p:8,borderRadius:8,backgroundColor:v,color:y},children:f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",mt:44},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",i.tvl?Xu({input:i.tvl,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),G.jsx(t.Box,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",i.totalFee?Xu({input:i.totalFee,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"hCBYHP",message:"Total Fee Revenue"})})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[!!n&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({address:p,operate:Qj.Remove,chainId:h})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({address:p,operate:Qj.Add,chainId:h})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})]},p+h)}))})}function Wk({account:n,list:i,loading:r,operatePool:s,setOperatePool:l}){const d=t.useTheme(),c=zy();return G.jsxs($j,{empty:!(null==i?void 0:i.length),loading:r,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"hCBYHP",message:"Total Fee Revenue"})}),G.jsx(t.Box,{component:"th",sx:{width:160}})]})}),G.jsx(t.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var r,u,p,h,m,g;if(!i)return null;const x="DPP"===i.poolType,f=null!==(r=i.pairAddress)&&void 0!==r?r:"",y=i.chainId,v=i.poolType,b={chainId:y,address:null!==(u=i.baseAddress)&&void 0!==u?u:"",symbol:null!==(p=i.baseSymbol)&&void 0!==p?p:""},C={chainId:y,address:null!==(h=i.quoteAddress)&&void 0!==h?h:"",symbol:null!==(m=i.quoteSymbol)&&void 0!==m?m:""},{typeLabel:j,typeColor:w,typeBgColor:k}=Vk(v,i.quoteReserve?new a(i.quoteReserve):null,d);let T="";if((null===(g=null==s?void 0:s.pool)||void 0===g?void 0:g.address)===f||(null==s?void 0:s.address)===f)if((null==s?void 0:s.operate)===Qj.Remove)T=o.i18n._({id:"0+31GV",message:"Removing"});else T=o.i18n._({id:"1yHVE+",message:"Adding"});const B=d.palette.hover.default;return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(T?", & td":"")]:{backgroundImage:`linear-gradient(${B}, ${B})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[b&&C?G.jsx(wy,{tokens:[b,C],width:24,mr:10,chainId:y,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(t.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:"primary.main",hoverSx:{color:"primary.main","& svg":{display:"inline-block"}},className:"truncate-address-link",sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},onClick:()=>{c.push({type:exports.PageType.PoolDetail,params:{chainId:y,address:f}})},children:tp(f)}),G.jsx(t.Box,{component:se.ArrowRight,sx:{display:"none",width:14,height:14}})]}),x?G.jsx(t.Box,{sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderColor:"text.primary",borderRadius:4,whiteSpace:"nowrap",cursor:"pointer","&:hover":{backgroundColor:t.alpha(d.palette.text.primary,.1)}},onClick:()=>{c.push({type:exports.PageType.ModifyPool,params:{chainId:y,address:f}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):""]}),G.jsx(t.Box,{sx:{typography:"h6",width:"max-content",mt:2,px:8,py:2,borderRadius:12,backgroundColor:k,color:w},children:j})]})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:i.tvl?`$${Su({input:i.tvl})}`:void 0,children:["$",i.tvl?Xu({input:i.tvl,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{title:i.totalFee?`$${Su({input:i.totalFee})}`:"",sx:{typography:"body2",fontWeight:600},children:["$",i.totalFee?Xu({input:i.totalFee,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:T?G.jsx(Vj,{text:T,onClick:()=>l(null)}):G.jsxs(G.Fragment,{children:[!!n&&G.jsx(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),l({operate:Qj.Remove,chainId:y,address:f})},sx:{py:0,height:32},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({chainId:y,address:f})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})})})]},f+y)}))})]})}function $k({account:i,filterChainIds:o,activeChainId:a,handleChangeActiveChainId:s,operatePool:l,setOperatePool:c,children:u}){var p,h,m,g,x,f;const{isMobile:y}=Bp(),v=t.useTheme(),{onlyChainId:b}=X(),C={limit:1e3,page:1,owner:i},j=xp().getQuery(r.PoolApi.graphql.fetchDashboardPairList,{where:C}),w=d.useQuery(Object.assign({},j)),k=null!==(f=o?null===(m=null===(h=null===(p=w.data)||void 0===p?void 0:p.dashboard_pairs_list)||void 0===h?void 0:h.list)||void 0===m?void 0:m.filter((e=>{var t;return o.includes(null!==(t=null==e?void 0:e.chainId)&&void 0!==t?t:0)})):null===(x=null===(g=w.data)||void 0===g?void 0:g.dashboard_pairs_list)||void 0===x?void 0:x.list)&&void 0!==f?f:[],[T,B]=n.useState(!1),I=T?k.filter((e=>!!Number(null==e?void 0:e.tvl))):k;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[v.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[v.breakpoints.up("tablet")]:{mr:"auto"}},children:u}),!b&&G.jsx(jk,{chainId:a,setChainId:s}),G.jsxs(t.Box,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[G.jsx(t.Checkbox,{sx:{top:-1},size:16,checked:T,onChange:e=>{const{checked:t}=e.target;B(t)}}),G.jsx(e.Trans,{id:"eVZ7bY",message:"Hide TVL=0 pools"})]})]}),y?G.jsxs(qj,{children:[w.isLoading?G.jsx(zj,{}):"",!w.isLoading&&!(null==I?void 0:I.length)&&!w.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!a&&!b}),!!w.error&&G.jsx(re,{refresh:w.refetch,sx:{mt:40}}),G.jsx(Hk,{account:i,list:I,setOperatePool:c})]}):G.jsxs(G.Fragment,{children:[G.jsx(Wk,{account:i,list:I,loading:w.isLoading,operatePool:l,setOperatePool:c}),G.jsx(ky,{loading:w.isLoading,refetch:w.error?w.refetch:void 0,empty:!(null==I?void 0:I.length),hasSearch:!!a&&!b})]})]})}function zk({account:n,lqList:i,setOperatePool:o,getMigrationPairAndMining:s,supportAMM:l,timeRange:d}){const c=t.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var u,p,h,m,g,x,f,y,v,b,C,j,w,k,T;if(!(null==i?void 0:i.pair))return null;const B=i.pair,I=Zu(B.baseToken,B.chainId),S=Zu(B.quoteToken,B.chainId),A=null===(u=B.apyList)||void 0===u?void 0:u.find((e=>(null==e?void 0:e.timeRange)===`${d}D`)),E=r.PoolApi.utils.singleSideLp(B.type),O=A?Hu(new a(null==A?void 0:A.transactionBaseApy).plus(null!==(p=null==A?void 0:A.miningBaseApy)&&void 0!==p?p:0).plus(null!==(h=null==A?void 0:A.metromMiningApy)&&void 0!==h?h:0)):void 0,L=E&&A?Hu(new a(A.transactionQuoteApy).plus(null!==(m=A.miningQuoteApy)&&void 0!==m?m:0)):void 0;let R,M;(null===(g=i.liquidityPositions)||void 0===g?void 0:g.length)&&i.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const s=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==s?void 0:s.length)){const t=s[1].toLocaleLowerCase();if((null===(i=null===(n=null==B?void 0:B.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(R=new a(e.liquidityTokenBalance));(null===(r=null===(o=null==B?void 0:B.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(M=new a(e.liquidityTokenBalance))}}}));const P=!!(null===(x=B.miningAddress)||void 0===x?void 0:x[0]),_=!!(null==A?void 0:A.metromMiningApy)&&Number(null==A?void 0:A.metromMiningApy)>0,N=null===(f=i.liquidityPositions)||void 0===f?void 0:f[0],D=B.type,F=Yu(D),U="AMMV2"===D,q="AMMV3"===D,V=null==s?void 0:s({address:B.id,chainId:B.chainId});return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{l||zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:B.chainId,address:B.id}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[I&&S?G.jsx(wy,{tokens:[I,S],width:24,mr:6,chainId:B.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==I?void 0:I.symbol}/${null==S?void 0:S.symbol}`,G.jsx(hk,{address:B.id,chainId:B.chainId})]}),!!V&&G.jsx(Tk,{})]}),P||_?G.jsxs(t.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${t.alpha(c.palette.secondary.main,.3)} 0%, ${t.alpha(c.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[l&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[F,G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:q?null!==(v=null===(y=sj[B.lpFeeRate])||void 0===y?void 0:y.label)&&void 0!==v?v:"-":Vu({input:new a(null!==(b=B.lpFeeRate)&&void 0!==b?b:0).plus(B.mtFeeRate?Mu(B.mtFeeRate,U?4:18):0)})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5",color:"success.main"},children:[O||"-%",L?`/${L}`:""]}),G.jsxs(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[d,"d ",G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(Bk,{chainId:B.chainId,apy:A,baseToken:I,quoteToken:S,hasQuote:!!L,hasMining:P,sx:{width:14,height:14}})]})]}),q?null:G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",Xu({input:B.tvl,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),"AMMV2"===D&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h5"},children:Vu({input:null===(j=null===(C=i.liquidityPositions)||void 0===C?void 0:C[0])||void 0===j?void 0:j.poolShare})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"h3PbRN",message:"My Pool Share"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:q?(null==N?void 0:N.liquidityUSD)?`$${Au({input:N.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[E?G.jsx(Nh,{address:null==I?void 0:I.address,chainId:B.chainId,url:null==I?void 0:I.logoURI,width:18,height:18,sx:{mr:4}}):G.jsx(wy,{tokens:I&&S?[I,S]:[],width:18,mr:4,showChainLogo:!1,chainId:B.chainId}),R?Su({input:R}):"",E&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Nh,{address:null==S?void 0:S.address,chainId:B.chainId,url:null==S?void 0:S.logoURI,width:18,height:18,sx:{mx:4}}),M?Su({input:M}):"0"]})]})}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})})]})]}),q&&G.jsxs(t.Box,{sx:{mt:20},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Dj,{outOfRange:null!==(w=null==N?void 0:N.outOfRange)&&void 0!==w&&w}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(k=null==N?void 0:N.priceRange)||void 0===k?void 0:k.token0LowerPrice,atLimit:{},direction:sv.LOWER})," "]}),null==I?void 0:I.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(T=null==N?void 0:N.priceRange)||void 0===T?void 0:T.token1LowerPrice,atLimit:{},direction:sv.UPPER})," "]}),null==I?void 0:I.symbol]})})]}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[q?null:!!n&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({operate:Qj.Remove,pool:Gu(i),hasMining:P})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({operate:Qj.Add,pool:Gu(i),hasMining:P})},children:G.jsx(e.Trans,{id:"J/hVSQ",message:"{0}",values:{0:q?"Manage":"Add"}})}),l&&"PMM"===F&&G.jsx(Wj,{chainId:B.chainId,address:B.id})]})]},q?null==N?void 0:N.id:B.id+B.chainId)}))})}function Zk({account:n,lqList:i,loading:s,operatePool:l,setOperatePool:d,supportAMM:c,onlyV3:u,getMigrationPairAndMining:p,timeRange:h}){const m=t.useTheme();return G.jsxs($j,{empty:!(null==i?void 0:i.length),loading:s,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),c&&G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),u?null:G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),G.jsxs(t.Box,{component:"th",children:[h,"d ",G.jsx(e.Trans,{id:"rSayea",message:"APY"})]}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),u?G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})}):null,G.jsx(t.Box,{component:"th",sx:{width:210}})]})}),G.jsx(t.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var s,g,x,f,y,v,b,C,j,w,k,T,B,I,S;if(!(null==i?void 0:i.pair))return null;const A=i.pair,E=Zu(A.baseToken,A.chainId),O=Zu(A.quoteToken,A.chainId),L=r.PoolApi.utils.singleSideLp(A.type),R=null===(s=A.apyList)||void 0===s?void 0:s.find((e=>(null==e?void 0:e.timeRange)===`${h}D`)),M=R?Hu(new a(null==R?void 0:R.transactionBaseApy).plus(null!==(g=null==R?void 0:R.miningBaseApy)&&void 0!==g?g:0)):void 0,P=L&&R?Hu(new a(R.transactionQuoteApy).plus(null!==(x=R.miningQuoteApy)&&void 0!==x?x:0)):void 0;let _,N;(null===(f=i.liquidityPositions)||void 0===f?void 0:f.length)&&i.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const s=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==s?void 0:s.length)){const t=s[1].toLocaleLowerCase();if((null===(i=null===(n=null==A?void 0:A.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(_=new a(e.liquidityTokenBalance));(null===(r=null===(o=null==A?void 0:A.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(N=new a(e.liquidityTokenBalance))}}}));const D=null===(y=i.liquidityPositions)||void 0===y?void 0:y[0],F=A.type,U=Yu(F),q="AMMV2"===F,V="AMMV3"===F;let H="";if(V)(null===(C=null===(b=null===(v=null==l?void 0:l.pool)||void 0===v?void 0:v.liquidityPositions)||void 0===b?void 0:b[0])||void 0===C?void 0:C.id)===(null==D?void 0:D.id)&&(H=o.i18n._({id:"p3607o",message:"Managing"}));else if((null===(j=null==l?void 0:l.pool)||void 0===j?void 0:j.address)===A.id||(null==l?void 0:l.address)===A.id)if(l.operate===Qj.Remove)H=o.i18n._({id:"0+31GV",message:"Removing"});else H=o.i18n._({id:"1yHVE+",message:"Adding"});const W=!!(null===(w=A.miningAddress)||void 0===w?void 0:w[0]),$=!!(null==R?void 0:R.metromMiningApy)&&Number(null==R?void 0:R.metromMiningApy)>0,z=m.palette.hover.default,Z=null==p?void 0:p({address:A.id,chainId:A.chainId});return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(H?", & td":"")]:{backgroundImage:`linear-gradient(${z}, ${z})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[E&&O?G.jsx(wy,{tokens:[E,O],width:24,mr:8,chainId:A.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==O?void 0:O.symbol}`,G.jsx(hk,{address:A.id,chainId:A.chainId}),!!Z&&G.jsx(Tk,{})]}),G.jsx(zf,{address:A.id,customChainId:A.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:c,onAddressClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:A.chainId,address:A.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),c&&G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(lj,{poolType:U}),G.jsx(dj,{isAMMV2:q,isAMMV3:V,lpFeeRate:A.lpFeeRate,mtFeeRate:A.mtFeeRate})]})}),V?null:G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:A.tvl?`$${Su({input:A.tvl||0})}`:void 0,children:["$",Xu({input:A.tvl||0,decimals:2})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[W||$?G.jsx(t.Tooltip,{title:o.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(Bk,{chainId:A.chainId,apy:R,baseToken:E,quoteToken:O,hasQuote:!!P,hasMining:W,children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[M||"-%",P?`/${P}`:""]})})]})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2"},children:V?(null==D?void 0:D.liquidityUSD)?`$${Au({input:D.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[L?G.jsx(Nh,{address:null==E?void 0:E.address,chainId:A.chainId,url:null==E?void 0:E.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):G.jsx(wy,{tokens:E&&O?[E,O]:[],width:24,mr:4,showChainLogo:!1,chainId:A.chainId}),_?Su({input:_}):"-",L&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Nh,{address:null==O?void 0:O.address,chainId:A.chainId,url:null==O?void 0:O.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),N?Su({input:N}):"0"]}),q&&G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"NXZdrO",message:"My pool share"}),children:G.jsx(t.Box,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Vu({input:null===(T=null===(k=i.liquidityPositions)||void 0===k?void 0:k[0])||void 0===T?void 0:T.poolShare})})})]})})}),u?G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Dj,{outOfRange:null!==(B=null==D?void 0:D.outOfRange)&&void 0!==B&&B}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(I=null==D?void 0:D.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:sv.LOWER})," "]}),null==E?void 0:E.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(S=null==D?void 0:D.priceRange)||void 0===S?void 0:S.token0UpperPrice,atLimit:{},direction:sv.UPPER})," "]}),null==E?void 0:E.symbol]})})]})}):null,G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c&&"PMM"===U&&G.jsx(Wj,{chainId:A.chainId,address:A.id}),H?G.jsx(Vj,{text:H,onClick:()=>d(null)}):G.jsxs(G.Fragment,{children:[V?null:!!n&&G.jsxs(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),d({operate:Qj.Remove,pool:Gu(i),hasMining:W})},sx:{py:0,height:32},children:[G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"}),!!Z&&G.jsx(Tk,{isRightTop:!0})]}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{d({pool:Gu(i),hasMining:W})},sx:{py:0,height:32},children:V?o.i18n._({id:"wckWOP",message:"Manage"}):o.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},V?null==D?void 0:D.id:A.id+A.chainId)}))})]})}function Qk({account:e,filterChainIds:i,activeChainId:o,handleChangeActiveChainId:a,operatePool:s,setOperatePool:l,getMigrationPairAndMining:c,tokenAndPoolFilter:u,children:p}){var h,m,g,x,f,y,v,b;const C=t.useTheme(),{minDevice:j,isMobile:w}=Bp(),k=d.useQueryClient(),{onlyChainId:T,supportAMMV2:B,supportAMMV3:I,notSupportPMM:S}=X(),[A,E]=n.useState("pmm&v2"),[O,L]=n.useState("1"),{filterTokens:R,filterASymbol:M,filterBSymbol:P,filterAddressLqList:_,handleDeleteToken:N,handleChangeFilterTokens:D,handleChangeFilterAddress:F}=Sk(u);let U=S?[]:["CLASSICAL","DVM","DSP","GSP","DPP"];B&&U.push("AMMV2"),I&&"v3"===A&&(U=["AMMV3"]);const V={currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:U}},H=xp(),W=H.getQuery(r.PoolApi.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},V),{filterState:Object.assign({filterASymbol:M,filterBSymbol:P},V.filterState)})}),$=d.useQuery(Object.assign({},W));let z=null!==(g=null===(m=null===(h=$.data)||void 0===h?void 0:h.liquidity_list)||void 0===m?void 0:m.lqList)&&void 0!==g?g:[];const Z=!!(null==_?void 0:_.length);return Z?z=[..._]:i&&(z=null!==(v=null===(y=null===(f=null===(x=$.data)||void 0===x?void 0:x.liquidity_list)||void 0===f?void 0:f.lqList)||void 0===y?void 0:y.filter((e=>{var t,n;return i.includes(null!==(n=null===(t=null==e?void 0:e.pair)||void 0===t?void 0:t.chainId)&&void 0!==n?n:0)})))&&void 0!==v?v:[]),G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[C.breakpoints.up("tablet")]:{py:16,flexDirection:"row",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[C.breakpoints.up("tablet")]:{mr:"auto"}},children:p}),!T&&G.jsx(jk,{chainId:o,setChainId:a}),I&&G.jsx(kk,{filterList:[{label:"V3",value:"v3"},{label:"V2 & PMM",value:"pmm&v2"}],value:A,onChange:e=>E(e)}),G.jsx(kk,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:O,onChange:e=>L(e)}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},w?{}:{"& > button":{flex:1}}),children:null!==(b=null==u?void 0:u.element)&&void 0!==b?b:G.jsx(Zj,{value:R,onChange:D,searchAddress:(e,t)=>q(this,void 0,void 0,(function*(){var n;const i=H.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},V),{filterState:Object.assign({address:e},V.filterState)})}),o=null===(n=(yield k.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?G.jsx(Ik,{list:o,onClick:()=>{F(o),t()}}):null}))})}),(Z||!!R.length)&&G.jsxs(t.Box,{sx:{my:0},children:[Z?G.jsx(wk,{lqList:_,onDeleteTag:()=>F([])}):"",G.jsx(Hj,{tags:R,onDeleteTag:N})]})]})]}),w?G.jsxs(qj,{children:[$.isLoading?G.jsx(zj,{}):"",!$.isLoading&&!(null==z?void 0:z.length)&&!$.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!(o&&!T||M||P)}),!!$.error&&G.jsx(re,{refresh:$.refetch,sx:{mt:40}}),G.jsx(zk,{account:e,lqList:z,setOperatePool:l,supportAMM:B||I,getMigrationPairAndMining:c,timeRange:O})]}):G.jsxs(G.Fragment,{children:[G.jsx(Zk,{account:e,lqList:z,loading:$.isLoading,operatePool:s,setOperatePool:l,supportAMM:B||I,onlyV3:"v3"===A,getMigrationPairAndMining:c,timeRange:O}),G.jsx(ky,{loading:$.isLoading,refetch:$.error?$.refetch:void 0,empty:!(null==z?void 0:z.length),hasSearch:!!(o&&!T||M||P)})]})]})}function Gk(e){var{sx:n}=e,i=U(e,["sx"]);return G.jsx(t.TabPanel,{...i,sx:Object.assign(Object.assign({},n),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Yk({params:e,scrollRef:i,tokenAndPoolFilter:o,operatePool:a,onOperatePool:s,getMigrationPairAndMining:l}){var d,c,u;const{isMobile:p}=Bp();t.useTheme();const h=X((e=>e.noDocumentLink)),m=n.useRef(null),{account:g}=cp(),{poolTopTab:x,normalPoolTab:f,almPoolTab:y,multiTokenPoolTab:v,normalTabs:b,almTabs:C,topTabs:j,multiTokenTabs:w,handleChangePoolTab:k}=function(){const[e,t]=n.useState(Dk.NORMAL),[i,o]=n.useState(Fk.ALL),[r,a]=n.useState(Uk.addLiquidity),[s,l]=n.useState(qk.ALL),{supportAMMV2:d,supportAMMV3:c,notSupportPMM:u,supportCurve:p}=X(),h=n.useMemo((()=>{const e=[{key:Dk.NORMAL,value:"Normal"}];return p&&e.push({key:Dk.MULTI_TOKEN,value:"Multi-token"}),e}),[p]),m=n.useMemo((()=>[{key:Fk.ALL,value:"All vauls"},{key:Fk.MY,value:"My liquidity"}]),[]),g=n.useMemo((()=>{const e=[{key:Uk.addLiquidity,value:"Add Liquidity"},{key:Uk.myLiquidity,value:"My Liquidity"}];return u||e.push({key:Uk.myCreated,value:d||c?"My Pools (PMM)":"My Pools"}),e}),[d,c,u]),x=n.useMemo((()=>[{key:qk.ALL,value:"All pools"},{key:qk.MY,value:"My liquidity"}]),[]),f=n.useRef(!1);return n.useEffect((()=>{const e=sessionStorage.getItem(Pk),n=sessionStorage.getItem(_k);e&&n&&!f.current&&(f.current=!0,t(e),e===Dk.NORMAL?a(n):e===Dk.ALM?o(n):e===Dk.MULTI_TOKEN&&l(n))}),[]),{poolTopTab:e,normalPoolTab:r,almPoolTab:i,multiTokenPoolTab:s,topTabs:h,normalTabs:g,almTabs:m,multiTokenTabs:x,handleChangePoolTab:({topTab:e,poolTab:n})=>{t(e),e===Dk.NORMAL?a(n):e===Dk.ALM?o(n):e===Dk.MULTI_TOKEN&&l(n),sessionStorage.setItem(Pk,e),sessionStorage.setItem(_k,n)}}}(),{activeChainId:T,filterChainIds:B,handleChangeActiveChainId:I}=function(){const{chainId:e}=cp(),{onlyChainId:t,defaultChainId:i}=X(),[o,a]=n.useState(t),s=n.useMemo((()=>void 0!==o?[o]:sc(e)?void 0:Object.values(r.ChainId).filter((e=>!!Number(e)))),[e,o]);return n.useEffect((()=>{const e=Number(sessionStorage.getItem(Nk));e&&a(e)}),[]),n.useEffect((()=>{!sessionStorage.getItem(Nk)&&i&&a(i)}),[i]),{activeChainId:o,filterChainIds:s,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(Nk):sessionStorage.setItem(Nk,String(e)),a(e)}}}(),[S,A]=n.useState(null),[E,O]=n.useState(a||null),L=e=>{if(s){if(s(e))return}O(e)};return n.useEffect((()=>{O(a||null)}),[a]),G.jsxs(Wy,{sx:Object.assign({},p?{p:0}:{display:"flex",gap:12,flex:1}),ref:m,children:[G.jsxs(t.Tabs,{value:x,onChange:(e,t)=>{t===Dk.NORMAL?k({topTab:t,poolTab:f}):t===Dk.ALM?k({topTab:t,poolTab:y}):t===Dk.MULTI_TOKEN&&k({topTab:t,poolTab:v})},sx:p?{}:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:[G.jsxs(t.Box,{sx:Object.assign({},p?void 0:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",pb:16,borderBottomWidth:1,borderBottomColor:"border.main",borderBottomStyle:"solid"}),children:[G.jsx(t.TabsGroup,{tabs:j,variant:"default",tabsListSx:Object.assign({justifyContent:"space-between"},p?{mb:12,gap:32}:{borderBottomWidth:0}),tabSx:p?{mr:0,padding:"0px 0px 16px 0px",flexGrow:1,flexShrink:1,flexBasis:"93px",gap:32}:{mr:48,typography:"h5",lineHeight:"25px",minHeight:41,padding:"8px 0px 8px 0px"}}),x===Dk.NORMAL&&G.jsx(Mk,{})]}),G.jsx(Gk,{value:Dk.ALM,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:"ALM"}),G.jsx(Gk,{value:Dk.NORMAL,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsxs(t.Tabs,{value:f,onChange:(e,t)=>{k({topTab:Dk.NORMAL,poolTab:t})},children:[G.jsx(t.TabPanel,{value:Uk.addLiquidity,children:G.jsx(Lk,{account:g,filterChainIds:B,scrollParentRef:null!=i?i:m,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,tokenAndPoolFilter:o,getMigrationPairAndMining:l,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:Uk.myLiquidity,children:G.jsx(Qk,{account:g,filterChainIds:B,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,tokenAndPoolFilter:o,getMigrationPairAndMining:l,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:Uk.myCreated,children:G.jsx($k,{account:g,filterChainIds:B,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),!h&&G.jsx(Zy,{title:"How does Liquidity Pools work?",descList:[{title:"Deposit Liquidity",desc:"Select a liquidity pool that suits your preferences and supply a pair of assets in our AMM pools or any supported assets in StableSwap pools. In return, you'll receive LP tokens, representing your share of the liquidity provided."},{title:"Earn Fees",desc:"As transactions occur within the pool, fees are collected and added to your LP tokens' value. This accrues daily, giving you real-time APY as your token holdings grow."},{title:"Delegate & Change Pool Fees",desc:"Boosted pool rewards are distributed every Sunday. If you've contributed liquidity to these pools, simply visit the rewards page, select the relevant week, and claim your earnings with ease."}],linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",sx:Object.assign({mt:16},p&&{mt:20})})]})}),G.jsx(Gk,{value:Dk.MULTI_TOKEN,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsxs(t.Tabs,{value:v,onChange:(e,t)=>{k({topTab:Dk.MULTI_TOKEN,poolTab:t})},children:[G.jsx(t.TabPanel,{value:qk.ALL,children:G.jsx(iw,{scrollParentRef:null!=i?i:m,activeChainId:T,operateCurvePool:S,setOperateCurvePool:A,account:g,children:G.jsx(t.TabsButtonGroup,{tabs:w,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:qk.MY,children:G.jsx(iw,{scrollParentRef:null!=i?i:m,activeChainId:T,operateCurvePool:S,setOperateCurvePool:A,account:g,isMyPool:!0,children:G.jsx(t.TabsButtonGroup,{tabs:w,variant:"inPaperContrast"})})})]})})]}),x===Dk.NORMAL&&E&&G.jsx(t.Box,{sx:{position:"relative",width:p?"100%":375},children:"AMMV3"===(null===(d=null==E?void 0:E.pool)||void 0===d?void 0:d.type)&&E.pool.chainId?f===Uk.myLiquidity&&(null===(u=null===(c=E.pool.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.tokenId)?G.jsx(Nj,{baseToken:E.pool.baseToken,quoteToken:E.pool.quoteToken,feeAmount:Number(E.pool.lpFeeRate),tokenId:E.pool.liquidityPositions[0].tokenId,chainId:E.pool.chainId,onClose:()=>L(null)}):G.jsx(Uj,{chainId:E.pool.chainId,baseToken:E.pool.baseToken,quoteToken:E.pool.quoteToken,feeAmount:Number(E.pool.lpFeeRate),onClose:()=>L(null),handleGoToAddLiquidityV3:e=>{zy.getState().push({type:exports.PageType.createPoolAMMV3,params:e})}}):G.jsx(G.Fragment,{children:p?G.jsx(pk,{account:g,onClose:()=>L(null),modal:p,...E}):G.jsx(uk,{account:g,onClose:()=>L(null),...E,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})})}),x===Dk.MULTI_TOKEN&&S&&G.jsx(t.Box,{sx:{position:"relative",width:p?"100%":375},children:G.jsx(uw,{operateCurvePool:S,setOperateCurvePool:A})})]})}function Kk({sx:e,onClick:n}){const o=t.useTheme();return G.jsx(t.HoverOpacity,{onClick:()=>{n?n():zy.getState().back()},sx:i.merge({display:"inline-flex",alignItems:"center",cursor:"pointer"},e),children:G.jsx(t.Box,{sx:{color:o.palette.text.secondary,width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",borderColor:o.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:8,backgroundColor:o.palette.background.paper},children:G.jsx(se.ArrowBack,{})})})}var Xk,Jk,eT,tT,nT,iT,oT,rT,aT,sT,lT,dT,cT;function uT(){return uT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uT.apply(null,arguments)}const pT=e=>D.createElement("svg",uT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Xk||(Xk=D.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_5229_28889)"})),Jk||(Jk=D.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_5229_28889)"})),eT||(eT=D.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_5229_28889)"})),tT||(tT=D.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_5229_28889)"})),nT||(nT=D.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_5229_28889)"})),iT||(iT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28889)"})),oT||(oT=D.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_5229_28889)"})),rT||(rT=D.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_5229_28889)"})),aT||(aT=D.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_5229_28889)"})),sT||(sT=D.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_5229_28889)"})),lT||(lT=D.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_5229_28889)"})),dT||(dT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28889)"})),cT||(cT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28889",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28889",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28889",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28889",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28889",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28889",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_5229_28889",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_5229_28889",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_5229_28889",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_5229_28889",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_5229_28889",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5229_28889",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var hT,mT,gT,xT,fT,yT,vT,bT,CT,jT,wT,kT,TT;function BT(){return BT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},BT.apply(null,arguments)}const IT=e=>D.createElement("svg",BT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),hT||(hT=D.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_3900_354238)"})),mT||(mT=D.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_3900_354238)"})),gT||(gT=D.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_3900_354238)"})),xT||(xT=D.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_3900_354238)"})),fT||(fT=D.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_3900_354238)"})),yT||(yT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_3900_354238)"})),vT||(vT=D.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_3900_354238)"})),bT||(bT=D.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_3900_354238)"})),CT||(CT=D.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_3900_354238)"})),jT||(jT=D.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_3900_354238)"})),wT||(wT=D.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_3900_354238)"})),kT||(kT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_3900_354238)"})),TT||(TT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_3900_354238",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_3900_354238",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_3900_354238",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_3900_354238",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_3900_354238",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_3900_354238",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_3900_354238",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_3900_354238",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_3900_354238",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_3900_354238",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_3900_354238",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_3900_354238",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var ST,AT,ET,OT,LT,RT,MT,PT,_T,NT,DT,FT,UT,qT;function VT(){return VT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},VT.apply(null,arguments)}const HT=e=>D.createElement("svg",VT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),ST||(ST=D.createElement("g",{clipPath:"url(#clip0_5057_344879)"},D.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344879)"}),D.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344879)"}),D.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344879)"}),D.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344879)"}),D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344879)"}),D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344879)"}),D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344879)"}),D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344879)"}),D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344879)"}),D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344879)"}))),AT||(AT=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344879)"})),ET||(ET=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344879)"})),OT||(OT=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344879)"})),LT||(LT=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344879)"})),RT||(RT=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344879)"})),MT||(MT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344879)"})),PT||(PT=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344879)"})),_T||(_T=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344879)"})),NT||(NT=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344879)"})),DT||(DT=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344879)"})),FT||(FT=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344879)"})),UT||(UT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344879)"})),qT||(qT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5057_344879",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5057_344879",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint2_linear_5057_344879",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint3_linear_5057_344879",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint4_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint5_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint6_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint7_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint8_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint9_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint10_linear_5057_344879",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5057_344879",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint12_linear_5057_344879",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint13_linear_5057_344879",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint14_linear_5057_344879",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint15_linear_5057_344879",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint16_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint17_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint18_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint19_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint20_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint21_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("clipPath",{id:"clip0_5057_344879"},D.createElement("rect",{width:737,height:220,fill:"white"})))));var WT,$T,zT,ZT,QT,GT,YT,KT,XT,JT,eB,tB,nB,iB;function oB(){return oB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},oB.apply(null,arguments)}const rB=e=>D.createElement("svg",oB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),WT||(WT=D.createElement("g",{clipPath:"url(#clip0_5057_344817)"},D.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344817)"}),D.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344817)"}),D.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344817)"}),D.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344817)"}),D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344817)"}),D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344817)"}),D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344817)"}),D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344817)"}),D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344817)"}),D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344817)"}))),$T||($T=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344817)"})),zT||(zT=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344817)"})),ZT||(ZT=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344817)"})),QT||(QT=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344817)"})),GT||(GT=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344817)"})),YT||(YT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344817)"})),KT||(KT=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344817)"})),XT||(XT=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344817)"})),JT||(JT=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344817)"})),eB||(eB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344817)"})),tB||(tB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344817)"})),nB||(nB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344817)"})),iB||(iB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5057_344817",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5057_344817",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint2_linear_5057_344817",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint3_linear_5057_344817",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint4_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint5_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint6_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint7_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint8_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint9_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint10_linear_5057_344817",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5057_344817",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint12_linear_5057_344817",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint13_linear_5057_344817",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint14_linear_5057_344817",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint15_linear_5057_344817",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint16_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint17_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint18_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint19_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint20_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint21_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("clipPath",{id:"clip0_5057_344817"},D.createElement("rect",{width:737,height:220,fill:"white"})))));var aB,sB,lB,dB,cB,uB,pB,hB,mB,gB,xB,fB,yB;function vB(){return vB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},vB.apply(null,arguments)}const bB=e=>D.createElement("svg",vB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),aB||(aB=D.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),sB||(sB=D.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),lB||(lB=D.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),dB||(dB=D.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),cB||(cB=D.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),uB||(uB=D.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),pB||(pB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_5229_28865)"})),hB||(hB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_5229_28865)"})),mB||(mB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_5229_28865)"})),gB||(gB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_5229_28865)"})),xB||(xB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_5229_28865)"})),fB||(fB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_5229_28865)"})),yB||(yB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28865",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28865",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28865",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28865",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28865",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28865",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var CB,jB,wB,kB,TB,BB,IB,SB,AB,EB,OB,LB,RB;function MB(){return MB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MB.apply(null,arguments)}const PB=e=>D.createElement("svg",MB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),CB||(CB=D.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),jB||(jB=D.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),wB||(wB=D.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),kB||(kB=D.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),TB||(TB=D.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),BB||(BB=D.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),IB||(IB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_3900_354262)"})),SB||(SB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_3900_354262)"})),AB||(AB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_3900_354262)"})),EB||(EB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_3900_354262)"})),OB||(OB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_3900_354262)"})),LB||(LB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_3900_354262)"})),RB||(RB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_3900_354262",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_3900_354262",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_3900_354262",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_3900_354262",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_3900_354262",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_3900_354262",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var _B,NB,DB,FB,UB,qB,VB,HB,WB,$B,zB,ZB,QB;function GB(){return GB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},GB.apply(null,arguments)}const YB=e=>D.createElement("svg",GB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),_B||(_B=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_5229_28987)"})),NB||(NB=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_5229_28987)"})),DB||(DB=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_5229_28987)"})),FB||(FB=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_5229_28987)"})),UB||(UB=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_5229_28987)"})),qB||(qB=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28987)"})),VB||(VB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_5229_28987)"})),HB||(HB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_5229_28987)"})),WB||(WB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_5229_28987)"})),$B||($B=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_5229_28987)"})),zB||(zB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_5229_28987)"})),ZB||(ZB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28987)"})),QB||(QB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28987",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28987",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28987",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28987",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28987",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28987",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_5229_28987",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_5229_28987",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_5229_28987",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_5229_28987",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_5229_28987",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5229_28987",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var KB,XB,JB,eI,tI,nI,iI,oI,rI,aI,sI,lI,dI;function cI(){return cI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},cI.apply(null,arguments)}const uI=e=>D.createElement("svg",cI({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),KB||(KB=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_4437_25449)"})),XB||(XB=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_4437_25449)"})),JB||(JB=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_4437_25449)"})),eI||(eI=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_4437_25449)"})),tI||(tI=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_4437_25449)"})),nI||(nI=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_4437_25449)"})),iI||(iI=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_4437_25449)"})),oI||(oI=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_4437_25449)"})),rI||(rI=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_4437_25449)"})),aI||(aI=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_4437_25449)"})),sI||(sI=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_4437_25449)"})),lI||(lI=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_4437_25449)"})),dI||(dI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_4437_25449",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_4437_25449",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_4437_25449",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_4437_25449",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_4437_25449",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_4437_25449",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_4437_25449",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_4437_25449",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_4437_25449",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_4437_25449",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_4437_25449",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_4437_25449",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var pI,hI;function mI(){const e="https://docs.dodoex.io/product/tutorial/how-to-create-pools#learn-more-about-the-characteristics-of-different-pool-models",t=[{version:hI.standard,title:o.i18n._({id:"TJBHlP",message:"Standard"}),description:o.i18n._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),exampleImgUrl:uI,exampleDarkImgUrl:YB,docUrl:e,initPriceLabel:o.i18n._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:o.i18n._({id:"5OKrbq",message:"Since this pool uses the PMM algorithm, which is different from the normal AMM pool mechanism, the initial price calculation is also different from AMM."}),initPriceTipsLink:"https://docs.dodoex.io/en/product/dodo-v2-pools/dodo-vending-machine/dvm-initial-price-formula-explanation"},{version:hI.pegged,title:o.i18n._({id:"J7M/DA",message:"Pegged"}),description:o.i18n._({id:"RvYEUJ",message:"Suitable for synthetic assets. The liquidity is super concentrated at some price like Curve Finance."}),exampleImgUrl:IT,exampleDarkImgUrl:pT,docUrl:e,initPriceLabel:o.i18n._({id:"4ogEAw",message:"Pegged Exchange Rate"}),initPriceTips:o.i18n._({id:"M9dIDb",message:"The pegged exchange rate refers to the exchange rate between two token assets where one's value is pegged/fixed by the other. For example, the pegged exchange rate between the US Dollar and USDT is 1."})},{version:hI.singleToken,title:o.i18n._({id:"34w3mT",message:"Single-Token"}),description:o.i18n._({id:"a1AzKr",message:"For those who are looking to sell tokens and only need ask-side liquidity."}),exampleImgUrl:PB,exampleDarkImgUrl:bB,docUrl:e,initPriceLabel:o.i18n._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:o.i18n._({id:"HGf8fG",message:"You can set the minimum selling price for single-token pools."})},{version:hI.marketMakerPool,title:o.i18n._({id:"4vKwIV",message:"Private Pool"}),description:o.i18n._({id:"pKjCsP",message:"100% use your own funds and enjoy the maximum degree of flexibility."}),exampleImgUrl:rB,exampleDarkImgUrl:HT,docUrl:e,initPriceLabel:o.i18n._({id:"CeLrge",message:"Mid Price"}),initPriceTips:o.i18n._({id:"GGPOuT",message:"set current mid price"})}],n=t.reduce(((e,t)=>(e[t.version]=t,e)),{});return{versionList:t,versionMap:n,subPeggedVersionList:gI()}}function gI(){return[{version:pI.DSP,title:o.i18n._({id:"D1bhHv",message:"The pool’s market-making price is fixed"}),description:o.i18n._({id:"lgE483",message:"Once created, the price cannot be changed. This option applies to assets like ETH-WETH."})},{version:pI.GSP,title:o.i18n._({id:"LVzIav",message:"The pool’s market-making price can be adjusted"}),description:o.i18n._({id:"KkjUUb",message:"Once created, you can adjust the pool’s market-making price at any time. This option is suitable for assets with fluctuating pegged prices. Adjusting the pool’s market-making price allows for more competitive quotes."})}]}function xI(){return gI().reduce(((e,t)=>(e[t.version]=t,e)),{})}!function(e){e.DSP="dsp",e.GSP="gsp"}(pI||(pI={})),function(e){e.standard="standard",e.singleToken="single-token",e.pegged="pagged",e.marketMakerPool="market-maker-pool"}(hI||(hI={}));const fI="0.3",yI=0,vI=10,bI="1",CI="0.0000000000001",jI=1e8,wI="1",kI="0.0001",TI="0.1",BI=8;function II({selectedVersion:e,quoteToken:t,initPrice:n,midPrice:i}){return e===hI.standard?!i||i.isZero()?null:Au({input:i,decimals:t.decimals}):Au({input:n,decimals:t.decimals})}function SI({initPrice:e}){const t=new a(e);if(!t.isFinite()||t.lte(0))return{base:null,quote:null};const n=new a(1),i=n.dividedBy(n.plus(t)).dp(BI,a.ROUND_DOWN);return{base:i,quote:n.minus(i).dp(BI,a.ROUND_DOWN)}}function AI({chainId:e,baseToken:t,quoteToken:n}){const i=r.basicTokenMap[e];return!(!t||!n)&&(!(!Ju(t.address,i.address)||!Ju(n.address,i.wrappedTokenAddress))||!(!Ju(t.address,i.wrappedTokenAddress)||!Ju(n.address,i.address)))}function EI({title:e,children:n,isWaiting:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:i?"-":n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function OI({status:n,selectedVersion:i,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,midPrice:l,sx:d}){var c;const{versionMap:u}=mI(),p="waiting"===n,{initPriceLabel:h}=u[i];return o&&r?G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:Object.assign({mt:0,display:"flex",alignItems:"stretch",gap:12,opacity:p?.5:1},d),children:[G.jsxs(EI,{title:G.jsx(e.Trans,{id:"fSFt4a",message:"Token Pair"}),isWaiting:p,children:[G.jsx(wy,{width:24,height:24,tokens:[o,r]}),o.symbol,"-",r.symbol]}),G.jsx(EI,{title:G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:p,children:s}),G.jsxs(EI,{title:h,isWaiting:p,children:["1 ",o.symbol," = ",null!==(c=II({midPrice:l,quoteToken:r,selectedVersion:i,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]})]})}):null}var LI,RI;function MI(){return MI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MI.apply(null,arguments)}const PI=e=>D.createElement("svg",MI({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),LI||(LI=D.createElement("g",{clipPath:"url(#clip0_5251_29079)"},D.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_29079)"}),D.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#EC5A7D",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),D.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_29079)"}),D.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#2FBA90",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),RI||(RI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5251_29079",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EC5A7D",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#EC5A7D",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5251_29079",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#2FBA90",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#2FBA90",stopOpacity:0})),D.createElement("clipPath",{id:"clip0_5251_29079"},D.createElement("rect",{width:54,height:32,fill:"white"})))));var _I,NI;function DI(){return DI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},DI.apply(null,arguments)}const FI=e=>D.createElement("svg",DI({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),_I||(_I=D.createElement("g",{clipPath:"url(#clip0_5251_28999)"},D.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_28999)"}),D.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#FF6187",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),D.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_28999)"}),D.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#55F9C7",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),NI||(NI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5251_28999",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FF6187",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#FF6187",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5251_28999",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#55F9C7",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#55F9C7",stopOpacity:0})),D.createElement("clipPath",{id:"clip0_5251_28999"},D.createElement("rect",{width:54,height:32,fill:"white"})))));function UI({height:e,text:t}){return G.jsx(ee,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:e||261},emptyText:t||o.i18n._({id:"uiuMDr",message:"Enter parameters to view the yield curve"})})}const qI=n.lazy((()=>Promise.resolve().then((function(){return require("./index-1TGmLYn3.cjs")})))),VI=n.lazy((()=>Promise.resolve().then((function(){return require("./index-DWGDLKiS.cjs")}))));var HI,WI;function $I({baseToken:i,quoteToken:r,pmmParams:a,pmmModel:s,midPrice:l}){var d,c;const u=t.useTheme(),{isMobile:p}=Bp(),[h,m]=n.useState(HI.depth),g=n.useRef(null),[x,f]=n.useState(0),y=null!==(d=null==i?void 0:i.symbol)&&void 0!==d?d:"",v=null!==(c=null==r?void 0:r.symbol)&&void 0!==c?c:"";n.useEffect((()=>{const e=()=>{g&&g.current&&f(g.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[g,l]);const b=h===HI.depth;if(!l||l.isNaN())return G.jsx(UI,{height:p?261:b?665:494});const C=u.palette.success.main,j=u.palette.error.main,w=[{key:HI.liquidity,value:o.i18n._({id:"6y2TB3",message:"Liquidity"})},{key:HI.depth,value:o.i18n._({id:"n25Lml",message:"Depth"})}];return G.jsxs(t.Box,{ref:g,sx:{mt:2,"& input":{backgroundColor:"background.cardInput",borderStyle:"solid",borderWidth:"1px",borderColor:"border.main",borderRadius:8,color:"text.primary",overflow:"hidden"},"& .operate-btn-wrapper button":{backgroundColor:"background.paperContrast",color:"text.primary"}},children:[G.jsxs(t.Tabs,{value:h,onChange:(e,t)=>{m(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:w,variant:"tag",tabsListSx:{ml:"auto"}}),G.jsx(t.Box,{sx:Object.assign({typography:"h6",mt:8,mb:14,color:"text.secondary"},p?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:G.jsx(e.Trans,{id:"tyGEMJ",message:"Amounts"})}),G.jsx(t.TabPanel,{value:HI.depth,children:x&&G.jsx(n.Suspense,{children:G.jsx(qI,{width:x,height:p?261:364,chartId:"create-pool-depth-chart",baseTokenSymbol:y,quoteTokenSymbol:v,pmmModel:s,pmmParams:a,midPrice:l,colorMap:{grid:"light"===u.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===u.palette.mode?"#E4E4E4":void 0,leftBg:[0,t.alpha(C,.04),1,t.alpha(C,.3)],leftLine:C,rightBg:[0,t.alpha(j,.04),1,t.alpha(j,.3)],rightLine:j,tooltipBg:u.palette.background.paperContrast,tooltipColor:u.palette.text.primary},notShowAmountInput:p})})}),G.jsx(t.TabPanel,{value:HI.liquidity,children:G.jsx(n.Suspense,{children:G.jsx(VI,{width:x,height:p?261:364,baseTokenSymbol:y,quoteTokenSymbol:v,pmmModel:s,pmmParams:a,midPrice:l,notShowTipText:!0,colorMap:{grid:"light"===u.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===u.palette.mode?"#E4E4E4":void 0,leftBg:[0,t.alpha(C,.04),1,t.alpha(C,.3)],leftLine:C,rightBg:[0,t.alpha(j,.04),1,t.alpha(j,.3)],rightLine:j,tooltipBg:u.palette.background.paperContrast,tooltipColor:u.palette.text.primary,textColor:u.palette.text.secondary}})})})]}),G.jsx(t.Box,{sx:Object.assign({typography:"h6",mt:6,color:"text.secondary"},p?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:G.jsx(e.Trans,{id:"DZULmp",message:"Swap Rate"})}),b?"":G.jsxs(t.Box,{sx:{typography:"h6",mt:24,color:"text.secondary",textAlign:"center"},children:["* ",o.i18n._({id:"DuVAxN",message:"The area of the chart indicates the buy/sell volume of {baseSymbol} that can be carried by the market when the current price changes to the hover price.",values:{baseSymbol:y}})]})]})}!function(e){e[e.liquidity=1]="liquidity",e[e.depth=2]="depth"}(HI||(HI={})),function(e){e[e.standard=1]="standard",e[e.singleToken=2]="singleToken",e[e.pagged=3]="pagged",e[e.marketMaker=4]="marketMaker"}(WI||(WI={}));const zI=({selectedVersion:e,baseAmount:t,quoteAmount:i,initPrice:o,slippageCoefficient:a})=>{const s=n.useMemo((()=>{const n=[hI.standard,hI.singleToken].includes(e),r=e===hI.singleToken;if(!t||!r&&!i)return;const s=Number(o),l=Number(t),d=Number(i),c=Number(a);return{i:s,k:c,b:l,b0:l,q:d,q0:0!==c&&n?0:d,R:0!==c&&n?1:0}}),[t,o,i,e,a]),l=n.useMemo((()=>{if(s)return r.getPmmModel(s)}),[s]),d=n.useMemo((()=>{if(l)return l.getMidPrice()}),[l]);return{pmmParams:s,pmmModel:l,midPrice:d}};function ZI({selectedVersion:e,baseToken:i,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d}){const c=t.useTheme(),{isMobile:u}=Bp(),[p,h]=n.useState(!1),{pmmParams:m,pmmModel:g,midPrice:x}=zI({selectedVersion:e,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s});if(!u)return null;const f=o.i18n._({id:"FQfStS",message:"Emulator"}),y=o.i18n._({id:"ihn3o9",message:"The liquidity of ZUNO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{mx:20,mb:8},children:G.jsxs(t.Box,{sx:{width:"100%",px:20,py:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:c.palette.border.main,display:"flex",alignItems:"center",justifyContent:"space-between"},component:t.ButtonBase,onClick:()=>h(!0),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:c.palette.text.secondary,typography:"body1",fontWeight:600},children:[f,G.jsx(t.QuestionTooltip,{title:y,ml:4,sx:{width:14,height:14}})]}),!x||x.isNaN()?G.jsx(t.Box,{sx:{py:5,typography:"body1"},children:"-"}):"light"===c.palette.mode?G.jsx(PI,{width:"52",height:"32"}):G.jsx(FI,{width:"52",height:"32"})]})}),G.jsx(Eh,{open:p,onClose:()=>h(!1),modal:!0,title:G.jsxs(t.Box,{children:[f,G.jsx(t.QuestionTooltip,{title:y,ml:4})]}),children:G.jsx(t.Box,{sx:{px:28,pb:20,maxHeight:"calc(80vh - 134px)",overflowY:"auto",overflowX:"hidden"},children:G.jsx($I,{baseToken:i,quoteToken:r,pmmParams:m,pmmModel:g,midPrice:x})})})]})}function QI({color:e,backgroundColor:n,tagKey:i}){return G.jsx(t.Box,{sx:{ml:8,px:8,py:2,borderRadius:4,backgroundColor:n,color:e,typography:"h6",fontWeight:500},children:i})}function GI({isWaiting:n,feeRate:i}){const r=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:r.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":G.jsxs(G.Fragment,{children:[i||"-","%",i===fI&&G.jsx(QI,{tagKey:o.i18n._({id:"/+c6tU",message:"99% Default"}),color:r.palette.purple.main,backgroundColor:t.alpha(r.palette.purple.main,.1)})]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:r.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"})})]})}function YI({isWaiting:n,selectedVersion:i,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d,peggedBaseTokenRatio:c,peggedQuoteTokenRatio:u}){const p=t.useTheme(),{pmmParams:h,pmmModel:m,midPrice:g}=zI({selectedVersion:i,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s});return G.jsxs(G.Fragment,{children:[!n&&G.jsx($I,{baseToken:o,quoteToken:r,pmmParams:h,pmmModel:m,midPrice:g}),G.jsxs(t.Box,{sx:{mt:n?0:20,padding:16,borderRadius:8,backgroundColor:p.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":G.jsxs(G.Fragment,{children:[c,"% ",null==o?void 0:o.symbol," : ",u,"% ",null==r?void 0:r.symbol]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:p.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"eK0eiF",message:"Initial asset ratio"})})]})]})}function KI({title:e,children:n,isWaiting:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:i?"-":n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function XI({status:e,selectedVersion:n,baseToken:i,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d}){var c;const{pmmParams:u,pmmModel:p,midPrice:h}=zI({selectedVersion:n,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s}),{versionMap:m}=mI(),g="waiting"===e,{initPriceLabel:x}=m[n];return G.jsxs(G.Fragment,{children:["running"===e&&G.jsx($I,{baseToken:i,quoteToken:r,pmmParams:u,pmmModel:p,midPrice:h}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"stretch",gap:12,opacity:g?.5:1},children:[G.jsx(KI,{title:o.i18n._({id:"fSFt4a",message:"Token Pair"}),isWaiting:g,children:i&&r?G.jsxs(G.Fragment,{children:[G.jsx(wy,{width:24,tokens:[i,r],chainId:i.chainId}),i.symbol,"-",r.symbol]}):""}),G.jsx(KI,{title:x,isWaiting:g,children:i&&r?G.jsxs(G.Fragment,{children:["1 ",i.symbol,"=",null!==(c=II({midPrice:h,quoteToken:r,selectedVersion:n,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]}):""}),G.jsx(KI,{title:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:g,children:s})]})]})}function JI({isWaiting:n,selectedSubPeggedVersion:i}){var o,r;const a=t.useTheme(),s=xI();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:a.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":i&&null!==(r=null===(o=s[i])||void 0===o?void 0:o.title)&&void 0!==r?r:"-"}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:a.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"XPiFIY",message:"Can the pool price be adjusted?"})})]})}function eS({index:e,titleKey:n,status:i}){const o=t.useTheme(),{isMobile:r}=Bp();return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:Object.assign({mt:28,mb:28,borderTopColor:"border.main",borderTopStyle:"solid",borderTopWidth:1},r?{mt:12,mb:12,display:1===e?"none":"block"}:{})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",mb:20},children:[G.jsx(t.Box,{sx:{display:"flex",width:"20px",height:"20px",justifyContent:"center",alignItems:"center",flexShrink:0,borderRadius:"50%",backgroundColor:"waiting"===i?o.palette.background.paperDarkContrast:o.palette.secondary.main,typography:"h6",fontWeight:600,textAlign:"center",color:"waiting"===i?o.palette.text.disabled:o.palette.secondary.contrastText},children:"completed"===i?G.jsx(G.Fragment,{children:G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M12.7596 3.55566L5.92549 10.3897L3.23957 7.71418L1.77734 9.17641L5.92549 13.3246L14.2218 5.02826L12.7596 3.55566Z",fill:"currentColor"})})}):e}),G.jsx(t.Box,{sx:{ml:8,typography:"body1",fontWeight:600,color:"waiting"===i?o.palette.text.disabled:o.palette.text.primary},children:n})]})]})}function tS({currentStep:e,isPeggedVersion:n}){const i=t.useTheme(),{isMobile:r}=Bp();let a="",s="",l="";switch(e){case 0:a=o.i18n._({id:"hdIg7i",message:"Select Pool Version"}),l=o.i18n._({id:"fw3eYd",message:"ZUNO provides a variety of pool versions to suit your needs."});break;case 1:a=o.i18n._({id:"lsg9Mi",message:"Parameter Settings"});break;case 2:n?a=o.i18n._({id:"6lss/t",message:"Pricing Model"}):(a=o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),s=o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}));break;case 3:if(!n)throw new Error("type is error");a=o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),s=o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."});break;case 4:if(!n)throw new Error("type is error");a=o.i18n._({id:"3ggd2j",message:"Asset ratio within the pool"});break;default:throw new Error(`Invalid Step ${e}`)}return G.jsxs(t.Box,{sx:Object.assign({position:"sticky",top:0,py:20,px:20,backgroundColor:i.palette.background.paper,zIndex:1},r?{}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"h5",color:i.palette.text.primary,fontWeight:600},children:a}),s&&G.jsx(t.QuestionTooltip,{title:s,sx:{width:16,height:16}}),G.jsx(t.Box,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:(n?[0,1,2,3,4]:[0,1,2]).map((n=>G.jsx(t.Box,{sx:{width:12,height:12,borderRadius:12,background:e>=n?i.palette.secondary.main:t.alpha(i.palette.primary.main,.1)}},n)))})]}),l&&G.jsx(t.Box,{sx:{mt:8,typography:"body2",color:i.palette.text.secondary},children:l})]})}function nS({versionItem:n,status:i}){const o=t.useTheme(),{noDocumentLink:r}=X(),a="light"===o.palette.mode;return"completed"===i?G.jsxs(t.Box,{sx:{backgroundColor:o.palette.background.paper,borderRadius:8,width:"50%",padding:16},children:[G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,color:o.palette.text.primary},children:n.title}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,mt:8,color:o.palette.text.secondary},children:n.description})]}):G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"h4",fontWeight:600},children:n.title}),!r&&G.jsxs(t.Box,{sx:{ml:8,display:"flex",padding:"2px 8px",justifyContent:"center",alignItems:"center",gap:"2px",color:o.palette.text.disabled,backgroundColor:o.palette.background.paperDarkContrast,borderRadius:4,typography:"h6"},component:"a",href:n.docUrl,target:"_blank",rel:"noreferrer",children:[G.jsx(e.Trans,{id:"TGi+jm",message:"Doc"}),G.jsx("svg",{width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 3.41667V11.5833H11.0833V7.5H12.25V11.5833C12.25 12.225 11.725 12.75 11.0833 12.75H2.91667C2.26917 12.75 1.75 12.225 1.75 11.5833V3.41667C1.75 2.775 2.26917 2.25 2.91667 2.25H7V3.41667H2.91667ZM8.16667 3.41667V2.25H12.25V6.33333H11.0833V4.23917L5.34917 9.97333L4.52667 9.15083L10.2608 3.41667H8.16667Z",fill:"currentColor"})})]})]}),G.jsx(t.Box,{sx:{position:"relative",width:"100%",minHeight:220},children:G.jsx(t.Box,{component:a?n.exampleImgUrl:n.exampleDarkImgUrl,sx:{marginTop:20,width:"100%"}})})]})}function iS({side:e,tokenList:t,occupyToken:n,needFindToken:i,chainId:o}){var r,a;let s=null,l=null;const d=t.filter((t=>!(t.side&&t.side!==e||o&&t.chainId!==o)));return d.length&&(i&&(s=null!==(r=d.find((e=>e.address===(null==i?void 0:i.address)&&e.chainId===i.chainId)))&&void 0!==r?r:null,l=s),l||(n?l=null!==(a=d.find((e=>e.address!==n.address)))&&void 0!==a?a:null:[l]=d)),{findToken:s,defaultToken:l}}function oS(){const{account:e,chainId:t}=cp(),n=zy((e=>{var t;return null===(t=e.page)||void 0===t?void 0:t.params}));return function({chainId:e,account:t,defaultBaseToken:n,defaultQuoteToken:i,tokenListInclude:o}={}){const{tokenList:r}=Tc(),a=iS({side:"from",needFindToken:n,tokenList:r,chainId:e}),s=d.useQuery(Object.assign({},id.getFetchTokenQuery(o?void 0:e,null==n?void 0:n.address,t))),l=d.useQuery(Object.assign({},id.getFetchTokenQuery(o?void 0:e,null==i?void 0:i.address,t)));let c=null,u=!1;c=a.defaultToken,s.data&&(c=s.data,u=s.isLoading);let p=null,h=!1;return p=iS({side:"to",needFindToken:i,occupyToken:c,tokenList:r,chainId:e}).defaultToken,l.data&&(p=l.data,h=l.isLoading),{defaultBaseToken:c,defaultQuoteToken:p,defaultBaseTokenLoading:u,defaultQuoteTokenLoading:h}}({chainId:t,account:e,defaultBaseToken:(null==n?void 0:n.fromAddress)?{address:null==n?void 0:n.fromAddress,chainId:t}:void 0,defaultQuoteToken:(null==n?void 0:n.toAddress)?{address:null==n?void 0:n.toAddress,chainId:t}:void 0})}function rS({tokens:e}){const{apikey:t}=X(),n=Hp(Zl.fiatPrice);return d.useQuery({enabled:!!e.length,queryKey:["fetch","fetchFiatPrice",e],queryFn:()=>q(this,void 0,void 0,(function*(){const i=yield f.post(n,{networks:e.map((e=>op(e.chainId))),addresses:e.map((e=>e.address)),symbols:e.map((e=>e.symbol)),isCache:!0},t?{headers:{apikey:t}}:void 0),o=new Map;return i.data.data&&i.data.data.forEach((e=>{const t=Number(e.price);!Number.isNaN(t)&&t>0&&o.set(e.address,t)})),o}))})}const aS=({selectedVersion:e})=>e===hI.pegged?["0.0001","0.0005","0.002"]:["0.5","0.01","1"];var sS;function lS(e,t){return!e||null==t||e.isNaN()?"":e.dp(t,a.ROUND_DOWN).toString()}function dS({state:e,fixedRatioPrice:t}){const{selectedVersion:n,baseToken:i,quoteToken:o,baseAmount:r,isFixedRatio:s,leftTokenAddress:l}=e;if(!i||!o)throw new Error("token is required");const d=l===(null==i?void 0:i.address),c=n===hI.standard,u=n===hI.pegged,p=new a(t);let h=c?CI:d?t:!p.isNaN()&&p.gt(0)?new a(1).div(p).dp(d?o.decimals:i.decimals).toString():bI;if(c){const e=18-i.decimals+o.decimals;e<String(CI).split(".")[1].length&&(h=new a(1).div(10**e).toString())}if(u){const n=SI({initPrice:h}),i=n.base?n.base.multipliedBy(100).toString():"",o=n.quote?n.quote.multipliedBy(100).toString():"";return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t,peggedBaseTokenRatio:i,peggedQuoteTokenRatio:o})}if(c&&s){const n=new a(r);if(!n.isNaN()&&!p.isNaN()&&p.gt(0)){const r=d?n.multipliedBy(p):n.div(p);return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t,baseAmount:lS(n,i.decimals),quoteAmount:lS(r,o.decimals)})}}return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t})}function cS(e,t){var n;switch(t.type){case sS.SetCurrentStep:{const{payload:n}=t;return e.selectedVersion===hI.pegged?Object.assign(Object.assign({},e),{currentStep:n>=4?4:n<=0?0:n}):Object.assign(Object.assign({},e),{currentStep:n>=2?2:n<=0?0:n})}case sS.SelectNewVersion:{const{payload:i}=t;if(i===e.selectedVersion)return e;let o,r=wI;i===hI.pegged&&(r=kI,o=pI.DSP);let a=CI;i===hI.singleToken?a="":i!==hI.standard&&(a=bI);let s=!0;return i===hI.singleToken&&(s=!1),Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:"",isFixedRatio:s,initPrice:a,fixedRatioPrice:i===hI.singleToken?"":bI,slippageCoefficient:r,isSlippageCoefficientCustomized:!aS({selectedVersion:t.payload}).includes(r),selectedVersion:t.payload,selectedSubPeggedVersion:o,leftTokenAddress:null===(n=e.baseToken)||void 0===n?void 0:n.address})}case sS.SelectNewSubPeggedVersion:return Object.assign(Object.assign({},e),{selectedSubPeggedVersion:t.payload});case sS.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:n,baseAmount:"",leftTokenAddress:null==n?void 0:n.address})}case sS.UpdateQuoteToken:{const{baseToken:n}=e;return Object.assign(Object.assign({},e),{quoteToken:t.payload,quoteAmount:"",leftTokenAddress:null==n?void 0:n.address})}case sS.SwitchTokens:{const{selectedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=e;return t===hI.singleToken?Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,leftTokenAddress:null==i?void 0:i.address}):Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,baseAmount:r,quoteAmount:o,leftTokenAddress:null==i?void 0:i.address})}case sS.UpdateBaseAmount:{const n=t.payload,{selectedVersion:i,quoteToken:o,fixedRatioPrice:s,isFixedRatio:l,peggedBaseTokenRatio:d}=e;if(!o)throw new Error("token is required");const c=new a(n);if(i===hI.pegged){const t=new a(d).div(100).dp(BI,a.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:""});const i=c.div(t).minus(c);return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:lS(i,o.decimals)})}if(i===hI.standard&&l&&s){if(!n)return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:n});const t=function(e,t){const n=new r.PMMModel;return n.B=new a(e.baseAmount),n.i=new a(e.initPrice),n.k=new a(e.slippageCoefficient),n.RStatus=1,n.getQuoteByMidPrice(t)}(Object.assign(Object.assign({},e),{baseAmount:n}),new a(s));return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:lS(t,o.decimals)})}return Object.assign(Object.assign({},e),{baseAmount:n})}case sS.UpdateQuoteAmount:{const n=t.payload,{selectedVersion:i,baseToken:o,fixedRatioPrice:r,isFixedRatio:s,leftTokenAddress:l,peggedQuoteTokenRatio:d}=e;if(!o)throw new Error("token is required");const c=l===(null==o?void 0:o.address),u=new a(n);if(i===hI.pegged){const t=new a(d).div(100).dp(BI,a.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:n});const i=u.div(t).minus(u);return Object.assign(Object.assign({},e),{baseAmount:lS(i,o.decimals),quoteAmount:n})}if(i===hI.standard&&s){const t=new a(r),i=t.gt(0)?c?u.div(t):u.multipliedBy(t):void 0;return Object.assign(Object.assign({},e),{baseAmount:lS(i,o.decimals),quoteAmount:n})}return Object.assign(Object.assign({},e),{quoteAmount:n})}case sS.UpdateIsFixedRatio:return Object.assign(Object.assign({},e),{isFixedRatio:t.payload});case sS.InitFixedRatioPrice:{const{leftTokenAddress:n,baseToken:i,quoteToken:o}=e;if(!i||!o)throw new Error("token is required");const r=n===(null==i?void 0:i.address),{baseTokenFiatPrice:s,quoteTokenFiatPrice:l}=t.payload,d=s&&l?new a(s).div(l):void 0,c=s&&l?new a(l).div(s):void 0,u=r?d:c,p=r?o.decimals:i.decimals;return u&&!u.isNaN()?dS({state:e,fixedRatioPrice:u.dp(p,a.ROUND_DOWN).toString()}):e}case sS.UpdateFixedRatioPrice:return dS({state:e,fixedRatioPrice:t.payload});case sS.ToggleLeftToken:{const{baseToken:t,quoteToken:n,fixedRatioPrice:i}=e;if(!t||!n)throw new Error("token is required");const o=e.leftTokenAddress===(null==t?void 0:t.address),r=o?null==n?void 0:n.address:null==t?void 0:t.address,s=new a(i);if(!s.isNaN()&&s.gt(0)){const i=new a(1).div(s).dp(o?t.decimals:n.decimals);return dS({state:Object.assign(Object.assign({},e),{leftTokenAddress:r}),fixedRatioPrice:i.toString()})}return Object.assign(Object.assign({},e),{leftTokenAddress:r})}case sS.UpdateSlippageCoefficient:return Object.assign(Object.assign({},e),{slippageCoefficient:t.payload});case sS.UpdateIsSlippageCoefficientCustomized:return Object.assign(Object.assign({},e),{isSlippageCoefficientCustomized:t.payload});case sS.UpdateFeeRate:return Object.assign(Object.assign({},e),{feeRate:t.payload});case sS.UpdateIsFeeRateCustomized:return Object.assign(Object.assign({},e),{isFeeRateCustomized:t.payload});case sS.InitEditParameters:return function(e,t){const{baseToken:n,quoteToken:i}=t;return n&&i?Object.assign(Object.assign({},e),{baseToken:n,quoteToken:i,leftTokenAddress:null==n?void 0:n.address,slippageCoefficient:"",initPrice:"",fixedRatioPrice:"",feeRate:"",isFixedRatio:!1}):e}(e,t.payload);case sS.UpdatePeggedBaseTokenRatio:{if(!e.quoteToken)throw new Error("token is required");const n=t.payload,i=new a(n).dp(BI-2,a.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:"",baseAmount:"",quoteAmount:""});const o=new a(100).minus(i).dp(BI-2,a.ROUND_DOWN),r=i.lte(0)?"0":e.baseAmount,s=new a(r),l=s.div(i.div(100)).minus(s);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:n,peggedQuoteTokenRatio:o.lt(0)?"0":o.toString(),baseAmount:r,quoteAmount:lS(l,e.quoteToken.decimals)})}case sS.UpdatePeggedQuoteTokenRatio:{if(!e.baseToken)throw new Error("token is required");const n=t.payload,i=new a(n).dp(BI-2,a.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:n,baseAmount:"",quoteAmount:""});const o=new a(100).minus(i).dp(BI-2,a.ROUND_DOWN),r=i.lte(0)?"0":e.quoteAmount,s=new a(r),l=s.div(i.div(100)).minus(s);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:o.lt(0)?"0":o.toString(),peggedQuoteTokenRatio:n,baseAmount:lS(l,e.baseToken.decimals),quoteAmount:r})}default:throw Error("Unknown action: "+t.type)}}function uS({isSingleTokenVersion:e,leftTokenAddress:t,baseToken:i,quoteToken:o,dispatch:r}){var s,l;const d=rS({tokens:n.useMemo((()=>i&&o?[i,o]:[]),[i,o])}),c=t===(null==i?void 0:i.address),u=i?null===(s=d.data)||void 0===s?void 0:s.get(i.address):void 0,p=o?null===(l=d.data)||void 0===l?void 0:l.get(o.address):void 0,h=n.useMemo((()=>{const e=u&&p?new a(u).div(p):void 0,t=u&&p?new a(p).div(u):void 0;return c?e:t}),[u,c,p]),m=!h||h.isNaN(),g=!d.isLoading&&!d.isPending&&m;return n.useLayoutEffect((()=>{g&&r({type:sS.UpdateIsFixedRatio,payload:!1})}),[r,g]),n.useLayoutEffect((()=>{e||u&&r({type:sS.InitFixedRatioPrice,payload:{baseTokenFiatPrice:u,quoteTokenFiatPrice:p}})}),[u,r,e,p]),{fiatPriceLoading:d.isLoading||d.isPending,currentPrice:h,isErrorPrice:g,isNullPrice:m}}function pS({label:e,value:n}){return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",mb:16},children:[G.jsx(t.Box,{sx:{color:"text.secondary",mr:8},children:e}),G.jsx(t.Box,{sx:{textAlign:"right",wordBreak:"break-all"},children:n})]})}function hS({on:e,onClose:n,state:i,onConfirm:r,isModify:a,loading:s}){var l,d,c,u,p,h,m;const{chainId:g}=cp(),{versionMap:x}=mI(),{isMobile:f}=Bp(),{title:y,initPriceLabel:v}=x[i.selectedVersion],{midPrice:b}=zI({selectedVersion:i.selectedVersion,baseAmount:i.baseAmount,quoteAmount:i.quoteAmount,initPrice:i.initPrice,slippageCoefficient:i.slippageCoefficient}),C=xI(),j=i.selectedVersion===hI.pegged;return G.jsx(Eh,{open:e,onClose:n,modal:!0,title:a?o.i18n._({id:"dzV+zO",message:"Modify Confirmation"}):o.i18n._({id:"tnRI9r",message:"Pool Creation Confirmation"}),children:G.jsxs(t.Box,{sx:{flex:1,px:20,pb:20,display:"flex",flexDirection:"column",justifyContent:"space-between",width:f?void 0:420},children:[G.jsxs(t.Box,{sx:{pt:40,px:8},children:[G.jsx(pS,{label:o.i18n._({id:"eE0JZ4",message:"Version"}),value:y}),G.jsx(pS,{label:o.i18n._({id:"7m5+6j",message:"Initial Tokens"}),value:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[G.jsx(Nh,{address:null===(l=i.baseToken)||void 0===l?void 0:l.address,chainId:g,marginRight:8,width:18,height:18}),i.baseAmount||"-"," ",null===(d=i.baseToken)||void 0===d?void 0:d.symbol]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",mt:4},children:[G.jsx(Nh,{address:null===(c=i.quoteToken)||void 0===c?void 0:c.address,chainId:g,marginRight:8,width:18,height:18}),i.quoteAmount||"-"," ",null===(u=i.quoteToken)||void 0===u?void 0:u.symbol]})]})}),G.jsx(pS,{label:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),value:i.slippageCoefficient}),G.jsx(pS,{label:v,value:i.baseToken&&i.quoteToken?`1 ${i.baseToken.symbol} = ${II({midPrice:b,quoteToken:i.quoteToken,selectedVersion:i.selectedVersion,initPrice:i.initPrice})} ${i.quoteToken.symbol}`:""}),j&&G.jsx(pS,{label:o.i18n._({id:"6lss/t",message:"Pricing Model"}),value:i.selectedSubPeggedVersion?null===(p=C[i.selectedSubPeggedVersion])||void 0===p?void 0:p.title:"-"}),G.jsx(pS,{label:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),value:`${i.feeRate}%`}),j&&G.jsx(pS,{label:o.i18n._({id:"eK0eiF",message:"Initial asset ratio"}),value:G.jsxs(G.Fragment,{children:[i.peggedBaseTokenRatio,"% ",null===(h=i.baseToken)||void 0===h?void 0:h.symbol," : ",i.peggedQuoteTokenRatio,"% ",null===(m=i.quoteToken)||void 0===m?void 0:m.symbol]})})]}),G.jsx(t.Button,{fullWidth:!0,isLoading:s,sx:{mt:30},onClick:r,children:a?o.i18n._({id:"7VpPHA",message:"Confirm"}):o.i18n._({id:"hYgDIe",message:"Create"})})]})})}!function(e){e[e.SetCurrentStep=1]="SetCurrentStep",e[e.SelectNewVersion=2]="SelectNewVersion",e[e.SelectNewSubPeggedVersion=3]="SelectNewSubPeggedVersion",e[e.UpdateBaseToken=4]="UpdateBaseToken",e[e.UpdateQuoteToken=5]="UpdateQuoteToken",e[e.SwitchTokens=6]="SwitchTokens",e[e.UpdateBaseAmount=7]="UpdateBaseAmount",e[e.UpdateQuoteAmount=8]="UpdateQuoteAmount",e[e.UpdateIsFixedRatio=9]="UpdateIsFixedRatio",e[e.UpdateFixedRatioPrice=10]="UpdateFixedRatioPrice",e[e.InitFixedRatioPrice=11]="InitFixedRatioPrice",e[e.ToggleLeftToken=12]="ToggleLeftToken",e[e.UpdateSlippageCoefficient=13]="UpdateSlippageCoefficient",e[e.UpdateIsSlippageCoefficientCustomized=14]="UpdateIsSlippageCoefficientCustomized",e[e.UpdateFeeRate=15]="UpdateFeeRate",e[e.UpdateIsFeeRateCustomized=16]="UpdateIsFeeRateCustomized",e[e.InitEditParameters=17]="InitEditParameters",e[e.UpdatePeggedBaseTokenRatio=18]="UpdatePeggedBaseTokenRatio",e[e.UpdatePeggedQuoteTokenRatio=19]="UpdatePeggedQuoteTokenRatio"}(sS||(sS={}));const mS=({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:s,feeRate:l,initPrice:d,slippageCoefficient:c})=>{const{chainId:u,account:p}=cp(),{deadLine:h}=X(),m=r.basicTokenMap[u];return{getCreateParams:()=>q(void 0,void 0,void 0,(function*(){if(!p||!n||!i)return null;let g="";const f=Number(n.decimals),y=Number(i.decimals),v=new a(l),b=e===hI.marketMakerPool,C=e===hI.standard,j=e===hI.pegged,w=e===hI.pegged&&t===pI.GSP,k={decimals:f,address:n.address},T={decimals:y,address:i.address},B=x.parseFixed(o,f).toString(),I=x.parseFixed(s||"0",y).toString(),S=b?v.times(100).toNumber():v.times(80).toNumber();let A=b&&C?new a(s).div(o).dp(y,a.ROUND_DOWN).toString():new a(d).toString();if(C){const e=18-n.decimals+i.decimals;e<String(CI).split(".")[1].length&&(A=new a(1).div(10**e).toString())}const E=Number(c||(j?"0.1":"1")),O=Math.ceil(Date.now()/1e3)+(null!=h?h:3600);let L;const R=[u,k,T,B,I,S,A,E,O];try{e===hI.standard||e===hI.singleToken?L=yield r.PoolApi.encode.createDVMPoolABI(...R):b?L=yield r.PoolApi.encode.createDPPPoolABI(...R):j?L=yield r.PoolApi.encode.createDSPPoolABI(...R):w&&(L=yield r.PoolApi.encode.createGSPPoolABI(u,p,k,T,B,I,S,A,E,O))}catch(e){throw console.error("2.0 CreatePool createPrams error",R,e),g=`2.0 CreatePool createPrams error; ERROR: ${e}`,new Error(g)}if(!L||!L.data)throw g="invalid data",new Error(g);try{const e=m.address.toLowerCase();return o&&n.address.toLowerCase()===e?L.value=Iw(o):s&&i.address.toLowerCase()===e?L.value=Iw(s):L.value=0,L}catch(e){throw console.error("2.0 sendTransaction error",e),g=`2.0 sendTransaction error; ERROR: ${e}`,new Error(g)}}))}},gS=({chainId:n,baseToken:i,quoteToken:o})=>{const r=t.useTheme();return AI({chainId:n,baseToken:i,quoteToken:o})?G.jsx(t.Box,{sx:{mb:12,py:8,px:12,borderRadius:8,backgroundColor:t.alpha(r.palette.error.main,.1),color:r.palette.error.main,textAlign:"center",typography:"h6",fontWeight:500},children:G.jsx(e.Trans,{id:"peTryP",message:"{0}-{1} is not supported. Please select another pair.",values:{0:null==i?void 0:i.symbol,1:null==o?void 0:o.symbol}})}):null};function xS({state:n,dispatch:i,openConfirm:r,isPeggedVersion:s,isStandardVersion:l,isSingleTokenVersion:d,fiatPriceLoading:c}){var u,p;const{currentStep:h,selectedVersion:m,baseToken:g,quoteToken:x,baseAmount:f,quoteAmount:y,initPrice:v,slippageCoefficient:b,feeRate:C}=n,j=new a(f||0),w=new a(y||0),k=lh(g,{amount:f}),T=lh(x,{amount:y}),B={variant:t.Button.Variant.contained},I=AI({chainId:null!==(p=null===(u=n.baseToken)||void 0===u?void 0:u.chainId)&&void 0!==p?p:1,baseToken:g,quoteToken:x}),S=o.i18n._({id:"hXzOVo",message:"Next"}),A=G.jsx(t.Button,{fullWidth:!0,disabled:!0,...B,children:S}),E=G.jsx(t.Button,{variant:t.Button.Variant.contained,fullWidth:!0,onClick:r,children:G.jsx(e.Trans,{id:"hYgDIe",message:"Create"})});if(0===h)return G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:sS.SetCurrentStep,payload:1})},children:S});const O=!g||j.isNaN()||j.lte(0),L=!x||w.isNaN()||w.lte(0);if(1===h){if(I)return A;if(s){if(!g||!x)return A}else{if(O)return A;if(k.needShowTokenStatusButton||k.insufficientBalance)return G.jsx(Tw,{status:k,buttonProps:B});if(!d){if(L)return A;if(T.needShowTokenStatusButton||T.insufficientBalance)return G.jsx(Tw,{status:T,buttonProps:B})}if(!l){if(!x)return A;const e=new a(v),t=Math.min(x.decimals,16);if(!v||e.isNaN()||e.lt(`1e-${t}`)||e.gt(jI))return A;const n=new a(b);if(!b||n.isNaN()||n.lt(0)||n.gt(m===hI.pegged?TI:wI))return A}if(c)return A;if(AI({chainId:g.chainId,baseToken:g,quoteToken:x}))return A}return G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:sS.SetCurrentStep,payload:2})},children:S})}const R=new a(C),M=!C||R.isNaN()||R.lt(yI)||R.gt(vI);return 2===h?s?G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:sS.SetCurrentStep,payload:3})},children:S}):M?A:E:3===h?M?A:G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:sS.SetCurrentStep,payload:4})},children:S}):4===h?O||L?A:k.needShowTokenStatusButton||k.insufficientBalance?G.jsx(Tw,{status:k,buttonProps:B}):T.needShowTokenStatusButton||T.insufficientBalance?G.jsx(Tw,{status:T,buttonProps:B}):E:null}function fS({state:i,dispatch:r,isPeggedVersion:a,isStandardVersion:s,isSingleTokenVersion:l,fiatPriceLoading:c}){const{currentStep:u}=i,p=t.useTheme(),{isMobile:h}=Bp(),m=Up(),{onlyChainId:g,chainId:x}=cp(),[f,y]=n.useState(!1),{getCreateParams:v}=mS(i),b=d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){const e=yield v();if(!e)return;(yield m.execute(o.i18n._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Mp.TX,desc:"Create pool"},e),{early:!0,metadata:{[i.selectedVersion===hI.marketMakerPool?exports.MetadataFlag.createDPPPool:i.selectedVersion===hI.pegged?i.selectedSubPeggedVersion===pI.DSP?exports.MetadataFlag.createDSPPool:exports.MetadataFlag.createGSPPool:exports.MetadataFlag.createDVMPool]:"1"}}))===Ap.Submitted&&setTimeout((()=>{zy.getState().push({type:exports.PageType.Pool,params:{tab:Uk.myCreated}})}),100)}))});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:p.palette.background.paperContrast,px:20,py:20},h?{}:{position:"static",backgroundColor:"transparent",py:0}),children:[1==u&&G.jsx(gS,{chainId:x,baseToken:i.baseToken,quoteToken:i.quoteToken}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[0===u&&h&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{zy.getState().back()},children:G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),u>0&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{r({type:sS.SetCurrentStep,payload:u-1})},children:G.jsx(e.Trans,{id:"iH8pgl",message:"Back"})}),G.jsx(lv,{chainId:g,variant:t.Button.Variant.contained,fullWidth:!0,includeButton:!0,children:G.jsx(xS,{state:i,dispatch:r,openConfirm:()=>{y(!0)},isPeggedVersion:a,isStandardVersion:s,isSingleTokenVersion:l,fiatPriceLoading:c})})]})]}),G.jsx(hS,{on:f,onClose:()=>y(!1),state:i,isModify:!1,onConfirm:b.mutate,loading:b.isPending})]})}function yS({selected:e}){const n=t.useTheme();return G.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginLeft:"auto",flexShrink:0},children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:e?n.palette.success.main:n.palette.text.secondary}),e&&G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:n.palette.success.main,stroke:n.palette.success.main})]})}function vS({title:e,subTitle:n,description:i,selected:o,onClick:r,children:a,sx:s,titleSx:l}){const d=t.useTheme();d.palette.mode;return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",p:20,backgroundColor:d.palette.background.tag,borderWidth:1,borderColor:o?d.palette.primary.main:"transparent",borderStyle:"solid",borderRadius:12,flexWrap:"wrap",justifyContent:"flex-start",textAlign:"left","&:hover":{borderColor:d.palette.primary.main}},s),component:t.ButtonBase,onClick:r,children:[G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",typography:"caption",pr:2,color:d.palette.text.primary},l),children:[e,n,G.jsx(yS,{selected:o})]}),G.jsx(t.Box,{sx:{mt:8,typography:"body2",width:"100%",textAlign:"left",color:o?d.palette.text.primary:d.palette.text.secondary},children:i}),a]})}function bS({errorMsg:e,isCustomized:i,onClick:r,value:a,onChange:s}){const l=t.useTheme(),d=n.useMemo((()=>!(!a||"0"===a||Number(a))),[a]);return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{py:12,px:20,backgroundColor:l.palette.background.paper,borderColor:i&&e||d?l.palette.error.main:i?l.palette.primary.main:l.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center"},onClick:r,children:G.jsx(Nf,{value:i?a:"",onChange:s,suffix:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:16},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,ml:8},children:"%"}),G.jsx(yS,{selected:i})]}),placeholder:o.i18n._({id:"8Tg/JR",message:"Custom"}),sx:{backgroundColor:"transparent","& input":{typography:"body1",height:36,lineHeight:"36px",p:l.spacing(0),color:l.palette.text.primary,"&::placeholder":{color:l.palette.text.disabled,fontWeight:600,typography:"body1",lineHeight:1,position:"relative"}}}})}),e&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main",mt:6},children:e})]})}const CS=()=>[{title:"0.01%",description:o.i18n._({id:"yzjPpo",message:"Fees will be the same as in most other pools."}),value:"0.01"},{title:"0.3%",description:o.i18n._({id:"OJOe+K",message:"Set the fee to the same as most other pools"}),value:fI,tag:"99% Default"},{title:"1%",description:"Most suitable for swapping exotic assets.",value:"1"}];function jS(){const e=t.useTheme();return n.useMemo((()=>CS().map((n=>n.value===fI?Object.assign(Object.assign({},n),{tagBackgroundColor:t.alpha(e.palette.purple.main,.1),tagColor:e.palette.purple.main}):n))),[e.palette.purple.main])}const wS=e=>{if(!e)return"";const t=new a(e);return t.isNaN()||!t.lt(yI)&&!t.gt(vI)?"":o.i18n._({id:"vWT429",message:"The fee rate must be between 0% to 10%"})},kS=(e,t)=>{if(!e)return"";const n=new a(e);if(!n.isNaN()&&(n.lt(0)||n.gt(t===hI.pegged?TI:wI)))switch(t){case hI.standard:case hI.singleToken:case hI.marketMakerPool:return o.i18n._({id:"3U+Oti",message:"he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."});case hI.pegged:return o.i18n._({id:"LDprZB",message:"The slippage coefficient needs to be greater than 0, and less than 0.1."})}return""};function TS({dispatch:i,feeRate:o,isFeeRateCustomized:r}){const a=t.useTheme(),s=jS(),l=n.useMemo((()=>wS(o)||""),[o]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:[s.map((e=>{const t=!r&&o===e.value;return G.jsx(vS,{title:e.title,description:e.description,onClick:()=>{i({type:sS.UpdateIsFeeRateCustomized,payload:!1}),i({type:sS.UpdateFeeRate,payload:e.value})},selected:t,subTitle:e.tag?G.jsx(QI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:a.palette.background.paper,borderColor:t?a.palette.primary.main:a.palette.border.main}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(bS,{errorMsg:l,isCustomized:r,onClick:()=>{i({type:sS.UpdateFeeRate,payload:""}),i({type:sS.UpdateIsFeeRateCustomized,payload:!0})},value:o,onChange:e=>{i({type:sS.UpdateFeeRate,payload:e})}})})]}),G.jsx(t.Box,{sx:{typography:"body2",mt:20,color:"text.secondary",px:20},children:G.jsx(e.Trans,{id:"0b0AkA",message:"* Please note that the Fee Rate cannot be modified after the pool is created"})})]})}function BS({on:t,onClose:n,onConfirm:i}){return G.jsx(Nw,{open:t,onClose:n,onConfirm:i,title:o.i18n._({id:"t+LmjM",message:"Initial Price Alert"}),modal:!0,children:G.jsx(e.Trans,{id:"yXm1vH",message:"The initial price is different from the current market price, which may cause your pool to be arbitraged"})})}const IS=({title:e,children:n,sx:i})=>{const o=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},i),children:[G.jsx(t.Box,{sx:{typography:"body2",color:o.palette.text.primary,fontWeight:500,display:"flex",alignItems:"center"},children:e}),n]})};function SS({selectedVersion:i,isStandardVersion:r,isSingleTokenVersion:s,isFixedRatio:l,leftTokenAddress:d,baseToken:c,quoteToken:u,fixedRatioPrice:p,dispatch:h,priceInfo:m}){const g=t.useTheme(),[x,f]=n.useState(!1),{versionMap:y}=mI(),{initPriceLabel:v,initPriceTips:b,initPriceTipsLink:C}=y[i],j=d===(null==c?void 0:c.address),w=j?null==c?void 0:c.symbol:null==u?void 0:u.symbol,k=j?null==u?void 0:u.symbol:null==c?void 0:c.symbol,{currentPrice:T,isErrorPrice:B,isNullPrice:I,fiatPriceLoading:S}=m,A=j?null==u?void 0:u.decimals:null==c?void 0:c.decimals,E=n.useMemo((()=>{if(!u)return"";const e=function(e,t,n){if(!t)return"";const i=new a(t),r=Math.min(n,16),s=Number(`1e-${r}`);if(e!==hI.standard&&!i.isNaN()&&(i.lt(s)||i.gt(jI))){const t=s.toFixed(r);switch(e){case hI.pegged:case hI.singleToken:return o.i18n._({id:"P4iKEj",message:"The initial price needs to be greater than {min} and less than 100,000,000",values:{min:t}});case hI.marketMakerPool:return o.i18n._({id:"kdzjmC",message:"The mid price needs to be greater than {min} and less than 100,000,000",values:{min:t}})}}return""}(i,p,u.decimals);return e||""}),[p,u,i]),O=n.useMemo((()=>!(!p||"0"===p||Number(p))),[p]);return G.jsxs(G.Fragment,{children:[G.jsx(IS,{title:G.jsxs(G.Fragment,{children:[v,b&&G.jsx(t.QuestionTooltip,{title:G.jsxs(G.Fragment,{children:[b,C?G.jsxs(G.Fragment,{children:["\n",G.jsxs(t.Box,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[G.jsx(e.Trans,{id:"NgeSlx",message:"Learn More"}),">"]})]}):""]}),ml:4,sx:{width:14,height:14,alignItems:"center"}})]}),sx:{mt:20},children:G.jsxs(t.Box,{sx:{pt:r?11:19,px:19,pb:11,borderWidth:1,borderStyle:"solid",borderColor:E||O?"error.main":g.palette.background.cardInput,borderRadius:8,backgroundColor:g.palette.background.cardInput,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20},children:[r?null:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{typography:"body2",color:g.palette.text.primary,display:"flex",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{fontWeight:600,color:g.palette.text.disabled,flexShrink:0},children:["1 ",null!=w?w:"-"," ="]}),G.jsx(Nf,{value:p,onChange:e=>{h({type:sS.UpdateFixedRatioPrice,payload:e})},readOnly:l,sx:{backgroundColor:"background.cardInput",pl:0,pr:0,mt:0,flex:"1 1 auto","& input":{textAlign:"right",typography:"h5",height:25,py:0,px:8,color:g.palette.text.primary,"&::placeholder":{color:g.palette.text.disabled}}}}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:g.palette.text.disabled,flexShrink:0},children:null!=k?k:"-"}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},component:t.ButtonBase,onClick:()=>{h({type:sS.ToggleLeftToken})},children:G.jsx(t.HoverOpacity,{weak:!0,component:se.Switch,sx:{marginLeft:8,p:g.spacing(2),color:g.palette.text.primary,backgroundColor:t.alpha(g.palette.primary.main,.1),borderRadius:"50%"}})})]}),E&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main",mt:-14},children:E})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r?"flex-start":"flex-end",typography:"h6",color:g.palette.text.primary,fontWeight:500},children:["=",G.jsx(e.Trans,{id:"pdZiL7",message:"Current Market Price:"})," ",S?G.jsx(t.Skeleton,{sx:{borderRadius:4},width:50,height:17}):I?G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"mObS+5",message:"Failed to get price of the token"}),children:G.jsx(t.Box,{component:se.Warn,sx:{width:14,height:14,color:g.palette.error.main,typography:"h6"}})}):Au({input:T,decimals:A})," ",k,B||s?null:G.jsx(t.Checkbox,{checked:l,onChange:e=>{if(e.target.checked){if(h({type:sS.UpdateIsFixedRatio,payload:!0}),!A)throw new Error("currentTokenDecimals is undefined");T&&!T.isNaN()&&h({type:sS.UpdateFixedRatioPrice,payload:T.dp(A,a.ROUND_DOWN).toString()})}else f(!0)},sx:{ml:8}})]})]})}),G.jsx(BS,{on:x,onClose:()=>f(!1),onConfirm:()=>{h({type:sS.UpdateIsFixedRatio,payload:!1})}})]})}function AS({selectedVersion:e,selectedSubPeggedVersion:n,baseToken:i,quoteToken:o,initPrice:r,dispatch:a}){var s;const l=t.useTheme(),{versionMap:d,subPeggedVersionList:c}=mI(),{initPriceLabel:u}=d[e];return i&&o?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:8,display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",color:l.palette.text.secondary,fontWeight:500},children:u}),G.jsxs(t.Box,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600},children:["1 ",null==i?void 0:i.symbol,"=",null!==(s=II({midPrice:void 0,quoteToken:o,selectedVersion:e,initPrice:r}))&&void 0!==s?s:"-"," ",o.symbol]})]}),G.jsx(t.Box,{sx:{mt:20,display:"flex",flexDirection:"column",gap:12,px:20},children:c.map((e=>{const t=n===e.version;return G.jsx(vS,{title:e.title,description:e.description,onClick:()=>{a({type:sS.SelectNewSubPeggedVersion,payload:e.version})},selected:t,subTitle:void 0,sx:{backgroundColor:l.palette.background.paper,borderColor:t?l.palette.primary.main:l.palette.border.main},titleSx:{typography:"body1",fontWeight:600}},e.version)}))})]}):null}function ES({title:e,value:n,onChange:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{flexGrow:1,flexShrink:1,flexBasis:"50%",display:"flex",alignItems:"center",px:15,py:7,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:8,backgroundColor:o.palette.background.cardInput},children:[G.jsx(t.Box,{sx:{color:o.palette.text.primary,typography:"body1",fontWeight:500,flexShrink:0},children:e}),G.jsx(Nf,{value:n,onChange:i,suffix:"%",placeholder:"0",sx:{backgroundColor:"background.cardInput",mt:0,display:"flex",alignItems:"center",width:"100%",typography:"h5",lineHeight:"32px",color:o.palette.text.disabled,"& input":{textAlign:"right",py:0,px:8,color:o.palette.text.primary,"&::placeholder":{opacity:1,color:o.palette.text.disabled,fontWeight:600,typography:"h5",lineHeight:1,position:"relative"}}}})]})}const OS=({baseToken:i,quoteToken:o,initPrice:r,peggedBaseTokenRatio:s,peggedQuoteTokenRatio:l,baseAmount:d,quoteAmount:c,dispatch:u})=>{var p,h;const m=t.useTheme(),[g,x]=n.useMemo((()=>{const{base:e,quote:t}=SI({initPrice:r});return[e?e.multipliedBy(100).toString():null,t?t.multipliedBy(100).toString():null]}),[r]),f=""===s&&""===l,[y,v]=n.useMemo((()=>{var e,t;const n=null!==(e=null==i?void 0:i.decimals)&&void 0!==e?e:0,s=null!==(t=null==o?void 0:o.decimals)&&void 0!==t?t:0,l=new a(d).dp(n,a.ROUND_DOWN).multipliedBy(`1e${n}`),u=new a(c).dp(s,a.ROUND_DOWN).multipliedBy(`1e${s}`),p=new a(r).multipliedBy(`1e${18-n+s}`).dp(0,a.ROUND_DOWN),h=u.lt(l.multipliedBy(p).div(1e18))?u.multipliedBy(1e18).div(p):l,m=new a(1001);if(m.gt(h))return[new a(1),"100%"];const g=m.dividedBy(h);return[g,Vu({input:g})]}),[d,null==i?void 0:i.decimals,r,c,null==o?void 0:o.decimals]),b=n.useMemo((()=>!!y.lte("0.0000000001")||null!=g&&s===g&&null!=x&&l===x),[y,s,l,g,x]),C=`${null==i?void 0:i.symbol}:${null==o?void 0:o.symbol}=${g}%:${x}%`;return G.jsxs(IS,{title:G.jsx(e.Trans,{id:"OuSseo",message:"Ratio Settings"}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(ES,{title:null!==(p=null==i?void 0:i.symbol)&&void 0!==p?p:"",value:s,onChange:e=>{u({type:sS.UpdatePeggedBaseTokenRatio,payload:e})}}),G.jsx(t.Box,{sx:{color:m.palette.text.primary,typography:"body2",fontWeight:500,width:14,flexShrink:0,flexGrow:0,textAlign:"center"},children:":"}),G.jsx(ES,{title:null!==(h=null==o?void 0:o.symbol)&&void 0!==h?h:"",value:l,onChange:e=>{u({type:sS.UpdatePeggedQuoteTokenRatio,payload:e})}})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,px:19,pt:19,pb:11,borderRadius:16,borderWidth:1,borderColor:b||f?m.palette.border.main:"transparent",borderStyle:"solid",backgroundColor:b||f?m.palette.background.paper:t.alpha(m.palette.warning.main,.1)},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[f?null:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,color:b?m.palette.text.primary:m.palette.warning.main,typography:"body1",fontWeight:600},children:[b?null:G.jsx(se.Warn,{}),G.jsx(e.Trans,{id:"x3muNy",message:"Liquidity Burn Ratio"}),": ",v]}),G.jsx(t.Box,{sx:{color:m.palette.text.secondary,typography:"h6",textAlign:"center","&>strong":{color:b?m.palette.text.primary:m.palette.warning.main}},children:f?G.jsx(e.Trans,{id:"pQJBKk",message:"The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{recommendRatioText:C}}):G.jsx(e.Trans,{id:"ZlQ83E",message:"<0>{lostRatio}</0> of the initial liquidity you provide will be burned. <1/>The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{lostRatio:v,recommendRatioText:C},components:{0:G.jsx("strong",{}),1:G.jsx("br",{})}})})]}),f||!b?G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,size:t.Button.Size.small,onClick:()=>{u({type:sS.UpdatePeggedBaseTokenRatio,payload:null!=g?g:""})},sx:{border:`solid 1px ${m.palette.text.primary}`,color:m.palette.text.primary,"&:hover":{background:t.alpha(m.palette.text.primary,.1)}},children:G.jsx(e.Trans,{id:"NjdGps",message:"Use the recommended ratio"})}):null]})]})};function LS({open:e,onClose:n,afterClose:i,title:o,titleCenter:r,rightSlot:a,canBack:s=!0,children:l,width:d=420,height:c,testId:u}){const p=t.useTheme(),{isMobile:h}=Bp();return G.jsx(t.WidgetModal,{open:e,onClose:n,container:h?document.querySelector(`.${of}`):void 0,disableEnforceFocus:!0,children:G.jsxs(t.Box,{sx:Object.assign({backgroundColor:"background.paper",display:"flex",height:c,flexDirection:"column",justifyContent:"center",alignItems:"center",outline:0,overflow:"hidden","& > div":{width:"100%"}},h?{width:"100%",borderRadius:p.spacing(16,16,0,0)}:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:d,maxWidth:"95%",minHeight:200,maxHeight:"80%",borderRadius:16}),"data-testid":u,children:[o?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r?"center":"space-between",p:20,width:"100%",boxSizing:"border-box"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:o}),a,!a&&s&&G.jsx(t.Box,{component:se.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{n&&n(),null==i||i()}})]}):"",l]})})}var RS;function MS(){return MS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MS.apply(null,arguments)}const PS=e=>D.createElement("svg",MS({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),RS||(RS=D.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},D.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function _S({dispatch:i,slippageCoefficient:r,selectedVersion:a,isCustomized:s,isStandardVersion:l}){const d=t.useTheme(),[c,u]=n.useState(!1),[p,h]=n.useState(r),m=function({selectedVersion:e}){const i=t.useTheme();return n.useMemo((()=>{const n=i.palette.background.paperDarkContrast,r=i.palette.text.disabled,a=i.palette.purple.main,s=t.alpha(a,.1);return e===hI.pegged?[{tag:"",description:o.i18n._({id:"PPqGw9",message:"Applicable to pegged assets with a fixed price and no fluctuation"}),value:"0",title:"K=0",tagBackgroundColor:"transparent",tagColor:"transparent"},{tag:o.i18n._({id:"nTWWCZ",message:"Low"}),description:o.i18n._({id:"L4nQwl",message:"Suitable for stablecoins with price fluctuations within 0.5%"}),value:"0.0001",title:"K=0.0001",tagBackgroundColor:s,tagColor:a},{tag:o.i18n._({id:"agPptk",message:"Medium"}),description:o.i18n._({id:"FrP5tr",message:"Suitable for stablecoins with price fluctuations within 2%"}),value:"0.0005",title:"K=0.0005",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"yx/fMc",message:"High"}),description:o.i18n._({id:"bC0iyq",message:"Suitable for stablecoins with price fluctuations within 10%"}),value:"0.002",title:"K=0.002",tagBackgroundColor:n,tagColor:r}]:[{tag:o.i18n._({id:"agPptk",message:"Medium"}),description:o.i18n._({id:"VXTSOE",message:"Suitable for most situations."}),value:"0.5",title:"K=0.5",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"nTWWCZ",message:"Low"}),description:o.i18n._({id:"DPi/hO",message:"Results in a relatively fixed price."}),value:"0.01",title:"K=0.01",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"yx/fMc",message:"High"}),description:o.i18n._({id:"fKYdE9",message:"Results in a more volatile price."}),value:"1",title:"K=1",tagBackgroundColor:s,tagColor:a}]}),[e,i.palette])}({selectedVersion:a}),[g,x]=n.useState(r);g!==r&&(x(r),h(r));const f=n.useMemo((()=>{const e=kS(p,a);return null!=e?e:""}),[a,p]),y=n.useMemo((()=>!(!p||"0"===p||Number(p))),[p]),v=Boolean(f)||y||s&&!p;return G.jsxs(G.Fragment,{children:[G.jsx(IS,{title:G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:4,sx:{width:14,height:14}})]}),sx:{mt:20},children:G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:8,color:d.palette.text.primary,borderRadius:8,backgroundColor:d.palette.background.cardInput,"&:hover":{backgroundColor:d.palette.hover.default},"&[disabled]>svg":{color:d.palette.text.disabled}},disabled:l,onClick:l?void 0:()=>{u(!0)},children:[G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px"},children:r}),G.jsx(t.Box,{component:PS,sx:{flexShrink:0,width:18,height:18}})]})}),G.jsx(LS,{open:c,onClose:()=>u(!1),title:G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:8})]}),children:G.jsxs(t.Box,{sx:{flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,p:d.spacing(8,28,28)},children:[m.map((e=>{const t=!s&&p===e.value;return G.jsx(vS,{title:e.title,description:e.description,onClick:()=>{i({type:sS.UpdateIsSlippageCoefficientCustomized,payload:!1}),h(e.value)},selected:t,subTitle:e.tag?G.jsx(QI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:d.palette.background.paper,borderColor:t?d.palette.primary.main:d.palette.border.main},titleSx:{typography:"body1"}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(bS,{errorMsg:f,isCustomized:s,onClick:()=>{s||h(""),i({type:sS.UpdateIsSlippageCoefficientCustomized,payload:!0})},value:p,onChange:e=>{h(e)}})})]}),G.jsx(t.Box,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:G.jsx(t.Button,{fullWidth:!0,disabled:v,onClick:()=>{i({type:sS.UpdateSlippageCoefficient,payload:p}),u(!1)},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function NS({token:i,oppositeTokenAddress:o,dispatch:r,tokenSelectOnChange:a}){var s;const l=t.useTheme(),{chainId:c,account:u}=cp(),[p,h]=n.useState(!1),m=d.useQuery(Object.assign({},id.getFetchTokenQuery(c,null==i?void 0:i.address,u)));return i?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",px:20,py:8,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default}},onClick:()=>{h(!0)},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:i.address,marginRight:0,width:24,height:24,chainId:i.chainId||c,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(t.Box,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600,lineHeight:"32px",flexShrink:0},children:i.symbol}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",fontWeight:500,color:l.palette.text.secondary,wordBreak:"break-all"},children:["(",G.jsx(e.Trans,{id:"fsBGk0",message:"Balance"}),": ",!i.address||m.isLoading?G.jsx(t.RotatingIcon,{}):Au({input:null===(s=m.data)||void 0===s?void 0:s.balance,decimals:i.decimals}),")"]})]}),G.jsx(t.Box,{component:PS,sx:{flexShrink:0,ml:"auto",width:18,height:18,color:l.palette.text.secondary}})]}),G.jsx(Xf,{value:i,open:p,chainId:c,occupiedAddrs:[o],occupiedChainId:i.chainId,onClose:()=>{h(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return r({type:sS.SwitchTokens}),void h(!1);a(e),h(!1)}},modal:!0})]}):null}const DS=({baseToken:t,quoteToken:n,dispatch:i})=>{var o,r;return G.jsxs(IS,{title:G.jsx(e.Trans,{id:"dmiCGN",message:"Select Token Pair"}),children:[G.jsx(NS,{token:t,oppositeTokenAddress:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",dispatch:i,tokenSelectOnChange:e=>{i({type:sS.UpdateBaseToken,payload:e})}}),G.jsx(NS,{token:n,oppositeTokenAddress:null!==(r=null==t?void 0:t.address)&&void 0!==r?r:"",dispatch:i,tokenSelectOnChange:e=>{i({type:sS.UpdateQuoteToken,payload:e})}})]})};function FS({selectedVersion:e,dispatch:n}){const i=t.useTheme(),{isMobile:o}=Bp(),{versionList:r}=mI(),a="light"===i.palette.mode;return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:r.map((i=>{const r=e===i.version;return G.jsx(vS,{title:i.title,description:i.description,onClick:()=>{n({type:sS.SelectNewVersion,payload:i.version})},selected:r,children:o&&r&&G.jsx(t.Box,{component:a?i.exampleImgUrl:i.exampleDarkImgUrl,sx:{mt:28,width:"100%",height:88.1}})},i.version)}))})}function US(){const i=t.useTheme(),{defaultBaseToken:r,defaultQuoteToken:s}=oS(),{chainId:l}=cp(),[d,c]=n.useReducer(cS,{currentStep:0,selectedVersion:hI.standard,baseToken:r,quoteToken:s,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:CI,fixedRatioPrice:bI,leftTokenAddress:null==r?void 0:r.address,feeRate:fI,isFeeRateCustomized:!1,slippageCoefficient:wI,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});!r||d.baseToken&&d.baseToken.chainId===l||c({type:sS.UpdateBaseToken,payload:r}),!s||d.quoteToken&&d.quoteToken.chainId===l||c({type:sS.UpdateQuoteToken,payload:s});const{isMobile:u}=Bp(),{versionMap:p}=mI(),h=p[d.selectedVersion],m=d.selectedVersion===hI.singleToken,g=d.selectedVersion===hI.standard,x=d.selectedVersion===hI.pegged,f=m?d.quoteToken:d.baseToken,y=m?d.baseToken:d.quoteToken,v=uS({isSingleTokenVersion:m,leftTokenAddress:d.leftTokenAddress,baseToken:d.baseToken,quoteToken:d.quoteToken,dispatch:c}),b=new a(d.peggedBaseTokenRatio).div(100).dp(BI,a.ROUND_DOWN),C=new a(d.peggedQuoteTokenRatio).div(100).dp(BI,a.ROUND_DOWN),j=x&&b.lte(0),w=x&&C.lte(0),k=G.jsxs(t.Box,{sx:{px:20},children:[G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:m?d.quoteAmount:d.baseAmount,onInputChange:m?void 0:e=>{c({type:m?sS.UpdateQuoteAmount:sS.UpdateBaseAmount,payload:e})},readOnly:m||j,sx:{backgroundColor:"background.cardInput",padding:i.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:j?o.i18n._({id:"t3d3/V",message:"ratio is 0"}):void 0,token:f,occupiedAddrs:y?[y.address]:void 0,occupiedChainId:l,chainId:l,onTokenChange:x?void 0:(e,t)=>{c(t?{type:sS.SwitchTokens}:{type:m?sS.UpdateQuoteToken:sS.UpdateBaseToken,payload:e})}}),G.jsx(cy,{}),G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:m?d.baseAmount:d.quoteAmount,onInputChange:e=>{c({type:m?sS.UpdateBaseAmount:sS.UpdateQuoteAmount,payload:e})},readOnly:g&&d.isFixedRatio&&!!d.fixedRatioPrice||w,sx:{backgroundColor:"background.cardInput",padding:i.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:w?o.i18n._({id:"t3d3/V",message:"ratio is 0"}):o.i18n._({id:"5QDjef",message:"The token amount is calculated by initial price."}),token:y,occupiedAddrs:f?[f.address]:void 0,occupiedChainId:l,chainId:l,onTokenChange:(e,t)=>{c(t?{type:sS.SwitchTokens}:{type:m?sS.UpdateBaseToken:sS.UpdateQuoteToken,payload:e})}})]});return G.jsx(Wy,{children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"flex-start",height:"100%"},u?{}:{height:"auto",overflowX:"auto"}),children:[u?null:G.jsxs(t.Box,{sx:{mr:12,flexGrow:1,display:"block",overflow:"hidden"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20},children:[G.jsx(Kk,{}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"pHQq+U",message:"Pool Setup"})}),G.jsx(lj,{poolType:"PMM"})]}),G.jsx(eS,{titleKey:o.i18n._({id:"hdIg7i",message:"Select Pool Version"}),index:1,status:0===d.currentStep?"running":"completed"}),G.jsx(nS,{versionItem:h,status:0===d.currentStep?"running":"completed"},h.version),G.jsx(eS,{titleKey:o.i18n._({id:"lsg9Mi",message:"Parameter Settings"}),index:2,status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed"}),x?G.jsx(OI,{status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed",baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,midPrice:void 0}):G.jsx(XI,{status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed",baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),x&&G.jsxs(G.Fragment,{children:[G.jsx(eS,{titleKey:o.i18n._({id:"6lss/t",message:"Pricing Model"}),index:3,status:d.currentStep>2?"completed":2===d.currentStep?"running":"waiting"}),G.jsx(JI,{isWaiting:d.currentStep<2,selectedSubPeggedVersion:d.selectedSubPeggedVersion})]}),x?G.jsxs(G.Fragment,{children:[G.jsx(eS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),index:4,status:d.currentStep>3?"completed":3===d.currentStep?"running":"waiting"}),G.jsx(GI,{isWaiting:d.currentStep<3,feeRate:d.feeRate})]}):G.jsxs(G.Fragment,{children:[G.jsx(eS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),index:3,status:2===d.currentStep?"running":"waiting"}),G.jsx(GI,{isWaiting:d.currentStep<2,feeRate:d.feeRate})]}),x&&G.jsxs(G.Fragment,{children:[G.jsx(eS,{titleKey:o.i18n._({id:"3ggd2j",message:"Asset ratio within the pool"}),index:5,status:d.currentStep>4?"completed":4===d.currentStep?"running":"waiting"}),G.jsx(YI,{isWaiting:d.currentStep<4,baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount,peggedBaseTokenRatio:d.peggedBaseTokenRatio,peggedQuoteTokenRatio:d.peggedQuoteTokenRatio})]})]}),G.jsxs(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,borderRadius:0,backgroundColor:"background.paper",minHeight:"100%"},u?{}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto",height:"100%",position:"sticky",top:"0px",overflowY:"hidden"}),children:[G.jsx(tS,{currentStep:d.currentStep,isPeggedVersion:x}),0===d.currentStep&&G.jsx(FS,{selectedVersion:d.selectedVersion,dispatch:c}),1===d.currentStep&&G.jsxs(G.Fragment,{children:[x?G.jsx(G.Fragment,{children:G.jsx(DS,{baseToken:d.baseToken,quoteToken:d.quoteToken,dispatch:c})}):G.jsxs(G.Fragment,{children:[G.jsx(ZI,{baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),k]}),G.jsx(_S,{dispatch:c,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,isCustomized:d.isSlippageCoefficientCustomized,isStandardVersion:g}),G.jsx(SS,{selectedVersion:d.selectedVersion,isFixedRatio:d.isFixedRatio,leftTokenAddress:d.leftTokenAddress,baseToken:d.baseToken,quoteToken:d.quoteToken,fixedRatioPrice:d.fixedRatioPrice,dispatch:c,isStandardVersion:g,isSingleTokenVersion:m,priceInfo:v})]}),x&&2===d.currentStep&&G.jsx(AS,{selectedVersion:d.selectedVersion,selectedSubPeggedVersion:d.selectedSubPeggedVersion,baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,dispatch:c}),d.currentStep===(x?3:2)&&G.jsx(TS,{dispatch:c,feeRate:d.feeRate,isFeeRateCustomized:d.isFeeRateCustomized}),x&&4===d.currentStep&&G.jsxs(G.Fragment,{children:[G.jsx(ZI,{baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),G.jsx(OS,{dispatch:c,baseToken:d.baseToken,quoteToken:d.quoteToken,peggedBaseTokenRatio:d.peggedBaseTokenRatio,peggedQuoteTokenRatio:d.peggedQuoteTokenRatio,initPrice:d.initPrice,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),G.jsx(IS,{title:G.jsx(e.Trans,{id:"E4LM3N",message:"Add Initial Liquidity"}),sx:{mt:20},children:G.jsx(t.Box,{sx:{mx:-20},children:k})})]}),G.jsx(t.Box,{sx:Object.assign({pb:160},u?{}:{pb:28})}),G.jsx(fS,{state:d,dispatch:c,isPeggedVersion:x,isStandardVersion:g,isSingleTokenVersion:m,fiatPriceLoading:v.fiatPriceLoading})]})]})})}function qS({open:n,onClose:i,title:o,children:r,singleBtn:a,danger:s,singleBtnText:l,cancelText:d,confirmText:c,disabledConfirm:u,confirmLoading:p,isManualClose:h,onConfirm:m}){const g=LS;return G.jsx(g,{open:n,onClose:i,title:G.jsx(t.Box,{sx:{textAlign:"center"},children:o}),canBack:!1,titleCenter:!0,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1,width:"100%"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:o?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:r}),a?G.jsx(t.Box,{sx:{px:20},children:G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,danger:s,sx:{mt:32,mb:20},onClick:()=>{i()},children:l||G.jsx(e.Trans,{id:"DPfwMq",message:"Done"})})}):G.jsxs(t.Box,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{i()},children:d||G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx(t.Button,{sx:{ml:8},variant:t.Button.Variant.outlined,danger:s,disabled:u,isLoading:p,onClick:()=>{m&&m(),h||i()},children:c||G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})]})})}function VS({sx:n,onClick:o}){const r=t.useTheme();return G.jsxs(t.HoverOpacity,{onClick:()=>{o?o():zy.getState().back()},sx:i.merge({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},n),children:[G.jsx(t.Box,{sx:{color:r.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:r.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:r.palette.background.paper,mr:6},children:G.jsx(se.ArrowBack,{})}),G.jsx(e.Trans,{id:"CKyk7Q",message:"Go back"})]})}function HS({open:i,onClose:r,alertContent:a,onConfirm:s}){const l=t.useTheme(),[d,c]=n.useState(!1),u=o.i18n._({id:"LQU+Dm",message:"Risk Disclaimer"});return G.jsx(LS,{open:i,onClose:r,title:u,canBack:!1,titleCenter:!0,children:G.jsxs(t.Box,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{mb:20,mx:20,maxHeight:275,overflowY:"auto",borderWidth:1,borderRadius:10,borderStyle:"solid",borderColor:"border.main",p:l.spacing(20),typography:"body2",backgroundColor:l.palette.background.input,color:l.palette.text.primary,textAlign:"left"},children:a}),G.jsxs(t.Box,{sx:{padding:20,pt:12,backgroundColor:l.palette.background.paperContrast},children:[G.jsxs(t.Box,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary",textAlign:"left","& a":{fontWeight:600,color:"primary.main","&:hover":{textDecoration:"underline"}}},children:[G.jsx(t.Checkbox,{sx:{top:-1},checked:d,onChange:e=>{const{checked:t}=e.target;c(t)}}),G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"dqWPbT",message:"I have read, understand, and agree to the <0>Terms of Service</0>.",components:{0:G.jsx("a",{href:"https://docs.dodoex.io/home/terms-of-service",target:"_blank",rel:"noopener noreferrer"})}})})]}),G.jsx(t.Box,{sx:{mt:12,display:"flex",alignItems:"center"},children:G.jsx(t.Button,{sx:{},disabled:!d,fullWidth:!0,onClick:()=>{c(!1),null==s||s()},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})]})})}function WS({id:e,chainId:t}){var n,i,o,s,l,c,u,p,h,m,g,x,f;const y=t?Hl[t]:"",v=xp().getQuery(r.PoolApi.graphql.fetchPool,{id:e||"",where:{refreshNow:!1,chain:y},liquidityWhere:{chain:y,refreshNow:!1,filterState:{address:e}}}),b=d.useQuery(Object.assign(Object.assign({},v),{enabled:!!e})),{pair:C,liquidity_list:j}=null!==(n=b.data)&&void 0!==n?n:{},w=null===(o=null===(i=null==j?void 0:j.lqList)||void 0===i?void 0:i[0])||void 0===o?void 0:o.pair;return Object.assign(Object.assign({},b),{poolDetail:C&&t?Object.assign(Object.assign({},C),{address:C.id,type:C.type,chainId:t,baseToken:Zu(C.baseToken,t),quoteToken:Zu(C.quoteToken,t),miningAddress:null!==(l=null===(s=null==w?void 0:w.miningAddress)||void 0===s?void 0:s[0])&&void 0!==l?l:"",apy:null==w?void 0:w.apy,baseApy:(null==w?void 0:w.apy)?Hu(new a(null!==(c=w.apy.transactionBaseApy)&&void 0!==c?c:0).plus(null!==(u=w.apy.miningBaseApy)&&void 0!==u?u:0)):void 0,quoteApy:Number(null===(p=null==w?void 0:w.apy)||void 0===p?void 0:p.transactionQuoteApy)||Number(null===(h=null==w?void 0:w.apy)||void 0===h?void 0:h.miningQuoteApy)?Hu(new a(null!==(g=null===(m=null==w?void 0:w.apy)||void 0===m?void 0:m.transactionQuoteApy)&&void 0!==g?g:0).plus(null!==(f=null===(x=null==w?void 0:w.apy)||void 0===x?void 0:x.miningQuoteApy)&&void 0!==f?f:0)):void 0,isCpPool:!1,cpAddress:void 0,cpLiquidator:void 0,cpCreator:void 0,cpCreatedAtTimestamp:void 0}):null})}function $S({disabled:n,chainId:i,baseStatus:o,quoteStatus:r,onClick:a}){const{account:s}=cp();return s?o.needShowTokenStatusButton||r.needShowTokenStatusButton?G.jsx(Tw,{status:o.needShowTokenStatusButton?o:r,buttonProps:{variant:t.Button.Variant.contained,fullWidth:!0}}):G.jsx(t.Button,{variant:t.Button.Variant.contained,fullWidth:!0,disabled:n,onClick:()=>a(),children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})}):G.jsx(lv,{chainId:i,variant:t.Button.Variant.contained,fullWidth:!0,includeButton:!0})}function zS({state:i,pool:r,loading:s}){var l,c;const{baseToken:u,quoteToken:p,baseAmount:h,quoteAmount:m,initPrice:g,slippageCoefficient:x,feeRate:f}=i,y=d.useQuery($u.getPMMStateQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,null==r?void 0:r.type,null===(l=null==r?void 0:r.baseToken)||void 0===l?void 0:l.decimals,null===(c=null==r?void 0:r.quoteToken)||void 0===c?void 0:c.decimals)),v=t.useTheme(),{isMobile:b}=Bp(),{account:C}=cp(),j=zy(),[w,k]=n.useState(!1),T=y.data&&h?new a(h).minus(y.data.baseReserve):void 0,B=y.data&&m?new a(m).minus(y.data.quoteReserve):void 0,I=null==T?void 0:T.lt(0),S=lh(u,{amount:T}),A=lh(p,{amount:B});let E=!r||s||!h||Number(h)<0||!m||Number(m)<0;if(!E&&p){const e=new a(g),t=Math.min(p.decimals,16);(!g||e.isNaN()||e.lt(`1e-${t}`)||e.gt(jI))&&(E=!0);const n=new a(x);(!x||n.isNaN()||n.lt(0)||n.gt(wI))&&(E=!0);const i=new a(f);(!f||i.isNaN()||i.lt(0)||i.gt(vI))&&(E=!0)}const{modifyDPPMutation:O}=$w({pool:r||void 0});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign(Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:v.palette.background.paperContrast,px:20,py:20},b?{}:{position:"static",backgroundColor:"transparent",py:0}),{display:"flex",alignItems:"center",gap:8}),children:[b&&!!C&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{j.back()},children:G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx($S,{disabled:E,chainId:null==r?void 0:r.chainId,baseStatus:S,quoteStatus:A,onClick:()=>k(!0)})]}),G.jsx(hS,{on:w,onClose:()=>k(!1),state:i,isModify:!0,loading:O.isPending,onConfirm:()=>{var e,t;O.mutate({txTitle:o.i18n._({id:"KRnA5J",message:"Set pool parameters"}),baseAmount:null!==(e=null==T?void 0:T.toString())&&void 0!==e?e:"",quoteAmount:null!==(t=null==B?void 0:B.toString())&&void 0!==t?t:"",isRemove:I,feeRate:i.feeRate,initPrice:i.initPrice,slippageCoefficient:i.slippageCoefficient,submittedBack:()=>{k(!1),j.push({type:exports.PageType.Pool,params:{tab:Uk.myCreated}})}})}})]})}function ZS({dispatch:i,feeRate:r,isCustomized:a}){const s=t.useTheme(),[l,d]=n.useState(!1),[c,u]=n.useState(r),p=jS();!c&&r&&u(r);const h=wS(c),m=!(!c||"0"===c||Number(c)),g=Boolean(h)||m||a&&!c;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:20,px:20},children:[G.jsxs(t.Box,{sx:{fontWeight:500,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8,size:16})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",ml:12},children:[r,"%",G.jsx(t.Button,{variant:t.Button.Variant.tag,sx:{ml:12,fontSize:12},onClick:()=>d(!0),children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]})]}),G.jsx(LS,{open:l,onClose:()=>d(!1),title:G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8})]}),children:G.jsxs(t.Box,{sx:{flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,p:s.spacing(8,28,28)},children:[p.map((e=>{const t=!a&&c===e.value;return G.jsx(vS,{title:e.title,description:e.description,onClick:()=>{i({type:sS.UpdateIsFeeRateCustomized,payload:!1}),u(e.value)},selected:t,subTitle:e.tag?G.jsx(QI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:s.palette.background.paper,borderColor:t?s.palette.primary.main:s.palette.border.main}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(bS,{errorMsg:h,isCustomized:a,onClick:()=>{a||u(""),i({type:sS.UpdateIsFeeRateCustomized,payload:!0})},value:c,onChange:e=>{u(e)}})})]}),G.jsx(t.Box,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:G.jsx(t.Button,{fullWidth:!0,disabled:g,onClick:()=>{i({type:sS.UpdateFeeRate,payload:c}),d(!1)},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function QS({titleKey:e}){const n=t.useTheme();return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{mt:28,mb:28,borderTopColor:"divider",borderTopStyle:"solid",borderTopWidth:1}}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",mb:20},children:G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:n.palette.text.primary},children:e})})]})}function GS({params:i}){var r,a,s,l;const c=t.useTheme(),{isMobile:u}=Bp(),{chainId:p}=cp(),[h,m]=n.useState(!1),[g,x]=n.useReducer(cS,{currentStep:0,selectedVersion:hI.marketMakerPool,baseToken:null,quoteToken:null,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:bI,fixedRatioPrice:bI,leftTokenAddress:void 0,feeRate:fI,isFeeRateCustomized:!1,slippageCoefficient:wI,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});n.useEffect((()=>{m(!window.localStorage.getItem(hc.PoolEditPage))}),[]);const[f,y]=n.useState("inital"),v=WS({id:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{poolDetail:b}=v,C=U(v,["poolDetail"]);C.isPending||C.error||b||"inital"!==f||y("open"),!g.baseToken&&(null==b?void 0:b.baseToken)&&x({type:sS.InitEditParameters,payload:b});const j=d.useQuery($u.getPMMStateQuery(null==b?void 0:b.chainId,null==b?void 0:b.address,null==b?void 0:b.type,null===(r=null==b?void 0:b.baseToken)||void 0===r?void 0:r.decimals,null===(a=null==b?void 0:b.quoteToken)||void 0===a?void 0:a.decimals));if(!g.slippageCoefficient&&(null===(l=null===(s=j.data)||void 0===s?void 0:s.pmmParamsBG)||void 0===l?void 0:l.k)){const e=j.data.pmmParamsBG.k.toString(),t=!aS({selectedVersion:g.selectedVersion}).includes(e);x({type:sS.UpdateSlippageCoefficient,payload:e}),x({type:sS.UpdateIsSlippageCoefficientCustomized,payload:t})}!g.baseAmount&&j.data&&(x({type:sS.UpdateBaseAmount,payload:j.data.baseReserve.toString()}),x({type:sS.UpdateQuoteAmount,payload:j.data.quoteReserve.toString()})),!g.fixedRatioPrice&&j.data&&x({type:sS.UpdateFixedRatioPrice,payload:j.data.pmmParamsBG.i.toString()});const w=d.useQuery($u.getLPFeeRateQuery(null==b?void 0:b.chainId,null==b?void 0:b.address,null==b?void 0:b.type));if(!g.feeRate&&w.data){const e=w.data.times(100).toString(),t=-1===CS().findIndex((t=>t.value===e));x({type:sS.UpdateFeeRate,payload:e}),x({type:sS.UpdateIsFeeRateCustomized,payload:t})}const k=g.selectedVersion===hI.singleToken,T=g.selectedVersion===hI.standard,B=uS({isSingleTokenVersion:k,leftTokenAddress:g.leftTokenAddress,baseToken:g.baseToken,quoteToken:g.quoteToken,dispatch:x}),{versionMap:I}=mI(),S=I[g.selectedVersion],A=!(null==b?void 0:b.baseToken),E=G.jsx(t.Skeleton,{variant:"rounded",width:210,height:60,sx:{padding:16,borderRadius:8}}),O=G.jsx(t.Skeleton,{variant:"rounded",height:167,sx:{mx:20,borderRadius:16}});return G.jsxs(G.Fragment,{children:[G.jsx(Wy,{children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"flex-start"},u?{height:"100%"}:{height:"auto"}),children:[u?null:G.jsxs(t.Box,{sx:{mr:12,flexGrow:1,display:"block"},children:[G.jsx(VS,{}),G.jsx(t.Box,{sx:{mt:28,typography:"h5",fontWeight:600,color:"text.primary"},children:G.jsx(e.Trans,{id:"pHQq+U",message:"Pool Setup"})}),G.jsx(QS,{titleKey:o.i18n._({id:"hdIg7i",message:"Select Pool Version"})}),G.jsx(nS,{versionItem:S,status:"completed"},S.version),G.jsx(QS,{titleKey:o.i18n._({id:"lsg9Mi",message:"Parameter Settings"})}),A?E:G.jsx(XI,{status:"running",baseToken:g.baseToken,quoteToken:g.quoteToken,initPrice:g.initPrice,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,baseAmount:g.baseAmount,quoteAmount:g.quoteAmount}),G.jsx(QS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"})}),A?E:G.jsx(GI,{isWaiting:!1,feeRate:g.feeRate})]}),G.jsxs(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,backgroundColor:"background.paper"},u?{width:"100%",borderRadius:0,minHeight:"100%"}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto"}),children:[G.jsx(t.Box,{sx:Object.assign({top:0,py:20,px:20,backgroundColor:c.palette.background.paper,zIndex:1},u?{position:"sticky"}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(t.Box,{sx:{typography:"h5",color:c.palette.text.primary,fontWeight:600},children:G.jsx(e.Trans,{id:"6XYkjc",message:"Edit Parameter Settings"})})})}),A?null:G.jsx(ZI,{baseToken:g.baseToken,quoteToken:g.quoteToken,initPrice:g.initPrice,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,baseAmount:g.baseAmount,quoteAmount:g.quoteAmount}),A?O:G.jsxs(t.Box,{sx:{px:20},children:[G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:g.baseAmount,onInputChange:e=>{x({type:sS.UpdateBaseAmount,payload:e})},readOnly:k,token:g.baseToken,occupiedAddrs:g.quoteToken?[g.quoteToken.address]:void 0,occupiedChainId:p,chainId:p}),G.jsx(uy,{}),G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:g.quoteAmount,onInputChange:e=>{x({type:sS.UpdateQuoteAmount,payload:e})},token:g.quoteToken,occupiedAddrs:g.baseToken?[g.baseToken.address]:void 0,occupiedChainId:p,chainId:p})]}),A?null:G.jsxs(G.Fragment,{children:[g.selectedVersion!==hI.standard&&G.jsx(_S,{dispatch:x,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,isCustomized:g.isSlippageCoefficientCustomized,isStandardVersion:T}),G.jsx(SS,{selectedVersion:g.selectedVersion,isFixedRatio:g.isFixedRatio,leftTokenAddress:g.leftTokenAddress,baseToken:g.baseToken,quoteToken:g.quoteToken,fixedRatioPrice:g.fixedRatioPrice,dispatch:x,isStandardVersion:T,isSingleTokenVersion:k,priceInfo:B}),G.jsx(ZS,{dispatch:x,feeRate:g.feeRate,isCustomized:g.isFeeRateCustomized})]}),G.jsx(t.Box,{sx:{pb:160,[c.breakpoints.up("tablet")]:{pb:28}}}),G.jsx(zS,{state:g,pool:b,loading:A})]})]})}),G.jsx(qS,{singleBtn:!0,open:"open"===f,onClose:()=>y("close"),onConfirm:()=>y("close"),title:o.i18n._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),G.jsx(HS,{open:h,onClose:()=>{m(!1)},onConfirm:()=>{window.localStorage.setItem(hc.PoolEditPage,"1"),m(!1)},alertContent:G.jsx(e.Trans,{id:"Y9QDtD",message:"You are making changes to the liquidity of a private pool. This is a highly discretionary operation that may cause substantial inflows/outflows of funds and changes in market prices. Please make sure you are fully aware of the implications of each parameter modification."})})]})}function YS(e){return null==e?0:new a(e).dp(4,a.ROUND_DOWN).toNumber()}function KS({unit:i,data:o,masterKey:r,sumKey:s}){const l=t.useTheme(),d=n.useRef(null),[c,u]=n.useState(null),[p,h]=n.useState(0);n.useEffect((()=>{const e=()=>{d&&d.current&&h(d.current.offsetWidth)};return setTimeout(e,100),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[d]);const m="light"===l.palette.mode?t.alpha(l.palette.success.main,.6):l.palette.primary.main,g="#ff9553",x=o[o.length-2],f="date";let y=[];if(null==o?void 0:o.length){let e=o[0][r];o.forEach((t=>{t[r]>e&&(e=t[r])})),y=e?[0,Math.ceil(e/3),Math.ceil(e/3*2),e]:[0]}let v=0;y.forEach((e=>{const t=Uu(new a(e));let n=t.replace(".","").length;t.indexOf(".")>-1&&(n+=.11),n>v&&(v=n)}));const b=10*v+2;return G.jsxs(t.Box,{ref:d,sx:{position:"relative"},children:[G.jsxs(t.Box,{sx:{minHeight:62,mb:10},children:[G.jsxs(t.Box,{sx:{typography:"caption",mb:8},children:[i||G.jsx("span",{children:" "}),Su({input:null==x?void 0:x[s]})]}),G.jsx(t.Box,{sx:{color:"text.secondary"},children:T(null==x?void 0:x[f]).format("LL")})]}),G.jsxs(S.BarChart,{width:p,height:364,data:o,margin:{top:5,right:10,left:0,bottom:5},children:[G.jsx("defs",{children:o.map(((e,n)=>G.jsxs("linearGradient",{id:`colorBar${e.date}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[G.jsx("stop",{offset:"0%",stopColor:n===o.length-1?g:m}),G.jsx("stop",{offset:"100%",stopColor:t.alpha(n===o.length-1?g:m,.04)})]},e.date)))}),G.jsx(S.XAxis,{hide:!0,dataKey:f,axisLine:!1,tickFormatter:e=>T(e).format("MM-DD")}),G.jsx(S.YAxis,{orientation:"right",axisLine:!1,ticks:y,width:b,tickFormatter:e=>Uu(new a(e))}),G.jsx(S.Tooltip,{isAnimationActive:!1,content:({active:n,payload:i,label:o})=>{if(!(n&&i&&i.length))return null;const r=T(o).format("YYYY-MM-DD")===T().format("YYYY-MM-DD");return G.jsxs(t.Box,{sx:{px:10,py:12,maxWidth:240,borderRadius:8,backgroundColor:"background.paperContrast",typography:"h6",color:"text.secondary"},children:[G.jsx(t.Box,{sx:{mr:8},children:T(o).format("MM-DD HH:mm")}),G.jsx(t.Box,{children:i[0].value}),r?G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"ubzjDN",message:"Real Time"})}):""]})},cursor:!1,coordinate:{x:0,y:0}}),G.jsx(S.Bar,{dataKey:r,onMouseMove:e=>{u(e[f])},onMouseLeave:()=>{u(null)},children:o.map((e=>G.jsx(S.Cell,{fill:`url(#colorBar${e.date})`},e.date)))}),c&&G.jsx(S.ReferenceLine,{x:c,stroke:m,strokeDasharray:"3 3"})]})]})}var XS,JS;function eA({poolDetail:e,chart24hDataFirst:i}){var s,l,c,u,p,h,m,g;const x=t.useTheme(),[f,y]=n.useState(i?XS.volume:XS.depth),v={key:XS.depth,value:o.i18n._({id:"n25Lml",message:"Depth"})},b=[{key:XS.volume,value:o.i18n._({id:"/cF7Rs",message:"Volume"})},{key:XS.feeRevenue,value:o.i18n._({id:"9QjAGB",message:"FeeRevenue"})},{key:XS.traders,value:o.i18n._({id:"qDhDFK",message:"Traders"})}];i?b.push(v):b.splice(0,0,v);const C=function({address:e,chainId:t,day:n}){var i,o,s;const l=t?Hl[t]:"",c=xp().getQuery(r.PoolApi.graphql.fetchPoolDayData,{where:{pair_address:null!=e?e:"",chain:l,day:n}}),u=d.useQuery(Object.assign(Object.assign({},c),{enabled:!!e&&!!t})),p=null!==(s=null===(o=null===(i=u.data)||void 0===i?void 0:i.dashboard_pairs_day_data)||void 0===o?void 0:o.map((e=>{var t,n;return{volume:YS(null==e?void 0:e.volumeUsd),fee:YS(new a(null!==(t=null==e?void 0:e.feeUsd)&&void 0!==t?t:0).plus(null!==(n=null==e?void 0:e.mtFeeUsd)&&void 0!==n?n:0).toString()),traders:(null==e?void 0:e.addresses)?Number(e.addresses):0,date:(null==e?void 0:e.timestamp)?1e3*(null==e?void 0:e.timestamp):0,tvl:YS(null==e?void 0:e.tvlUsd)}})))&&void 0!==s?s:[];return Object.assign(Object.assign({},u),{dayDataList:p})}({chainId:null==e?void 0:e.chainId,address:null==e?void 0:e.address,day:30}),j=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals)),{pmmParamsBG:w}=null!==(c=j.data)&&void 0!==c?c:{},k=w?{i:w.i.toNumber(),k:w.k.toNumber(),b:w.b.toNumber(),b0:w.b0.toNumber(),q:w.q.toNumber(),q0:w.k.isEqualTo(0)?w.q.toNumber():w.q0.toNumber(),R:w.k.isEqualTo(0)?0:w.R}:void 0,T=k?r.getPmmModel(k):void 0,[B,I]=n.useState(!1),S=B&&(null===(u=j.data)||void 0===u?void 0:u.midPrice)?new a(1).div(null===(p=j.data)||void 0===p?void 0:p.midPrice):null===(h=j.data)||void 0===h?void 0:h.midPrice;return G.jsx(t.Box,{sx:{mt:24,[x.breakpoints.up("tablet")]:{mt:20,pt:28,borderTop:`1px solid ${x.palette.border.main}`}},children:G.jsxs(t.Tabs,{value:f,onChange:(e,t)=>y(t),children:[G.jsx(t.TabsGroup,{tabs:b,variant:"rounded",tabsListSx:{borderWidth:0,gap:4,mb:24}}),f===XS.depth&&(null==e?void 0:e.baseToken)&&(null==e?void 0:e.quoteToken)?G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:G.jsx(tA,{baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,midPrice:S,isSwitchMidPrice:B,setIsSwitchMidPrice:I,showMidPrice:f===XS.depth})}):"",G.jsx(t.TabPanel,{value:XS.depth,children:G.jsx($I,{baseToken:null!==(m=null==e?void 0:e.baseToken)&&void 0!==m?m:null,quoteToken:null!==(g=null==e?void 0:e.quoteToken)&&void 0!==g?g:null,pmmParams:k,pmmModel:T,midPrice:S})}),G.jsx(t.TabPanel,{value:XS.volume,children:G.jsx(KS,{data:C.dayDataList,masterKey:"volume",sumKey:"volume",unit:"$"})}),G.jsx(t.TabPanel,{value:XS.feeRevenue,children:G.jsx(KS,{data:C.dayDataList,masterKey:"fee",sumKey:"fee",unit:"$"})}),G.jsx(t.TabPanel,{value:XS.traders,children:G.jsx(KS,{data:C.dayDataList,masterKey:"traders",sumKey:"traders",unit:""})})]})})}function tA({baseToken:e,quoteToken:n,midPrice:i,isSwitchMidPrice:o,setIsSwitchMidPrice:r,showMidPrice:a}){const s=null==e?void 0:e.symbol,l=null==n?void 0:n.symbol,d=o?l:s,c=o?s:l;return G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:a?G.jsxs(t.Box,{sx:{mt:4,typography:"body2",color:"text.secondary",wordBreak:"break-all",display:"flex"},children:[`1 ${d} = ${i?Su({input:i,showDecimals:16}):"-"} ${c}`,G.jsx(t.HoverOpacity,{weak:!0,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,position:"relative",top:1.5,ml:9,cursor:"pointer",borderRadius:"50%",backgroundColor:"background.paperDarkContrast",p:0},onClick:()=>r((e=>!e)),children:G.jsx(t.Box,{component:se.Switch})})]}):""})}function nA({poolDetail:i}){var o,s,l;const{isMobile:c}=Bp(),u=t.useTheme(),p=null==i?void 0:i.chainId;null===(l=d.useQuery($u.getPMMStateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,null===(o=null==i?void 0:i.baseToken)||void 0===o?void 0:o.decimals,null===(s=null==i?void 0:i.quoteToken)||void 0===s?void 0:s.decimals)).data)||void 0===l||l.midPrice;const h=function({pool:e}){var t,n,i,o,s,l,c;const{chainId:u,address:p,type:h,baseToken:m,quoteToken:g}=e||{},x=null!=p?p:"",f=u?Hl[u]:"",y=null==m?void 0:m.decimals,v=null==g?void 0:g.decimals,b=d.useQuery($u.getPMMStateQuery(u,p,h,null==m?void 0:m.decimals,null==g?void 0:g.decimals)),C=null===(t=b.data)||void 0===t?void 0:t.midPrice,j=d.useQuery($u.getTotalBaseLpQuery(u,p,h,y)),w=d.useQuery($u.getTotalQuoteLpQuery(u,p,h,v)),k=d.useQuery($u.getReserveLpQuery(u,p,h,y,v)),T=d.useQuery($u.getClassicalTargetQuery(u,p,h,y,v)),B=j.data;let I=w.data;I||w.isLoading||w.error||!B||(I=B);const{baseReserve:S,quoteReserve:A}=k.data||{},E=null===(n=T.data)||void 0===n?void 0:n.baseTarget,O=null===(i=T.data)||void 0===i?void 0:i.quoteTarget,L=rS({tokens:g?[g]:[]}),R=xp(),M=d.useQuery(Object.assign(Object.assign({},R.getQuery(r.PoolApi.graphql.fetchLiquidityPositions,{id:x,where:{pair:x,liquidityTokenBalance_not:"0",chain:f,refreshNow:!0},miningWhere:{pair:x,liquidityTokenInMining_not:"0",chain:f},first:1e3,orderBy:"liquidityTokenBalance",orderDirection:"desc"})),{enabled:!!p})),{balance:P,mining:_,pair:N}=null!==(o=M.data)&&void 0!==o?o:{};let D=[];const F=g?null===(s=L.data)||void 0===s?void 0:s.get(g.address):void 0;if(P&&_&&N){const{baseLpToken:e,quoteLpToken:t}=N,n=new Map,i=(null==e?void 0:e.id)===(null==t?void 0:t.id);for(const o of P){const{id:r,liquidityTokenBalance:s}=o,l=new a(null!=s?s:0),[d,c]=r.split("-");let u={id:d,baseSupplied:new a(0),quoteSupplied:new a(0)};n.has(u.id)?u=n.get(u.id):n.set(u.id,u);const[,m]=mw(l,B,S,E,p,h,y);m&&(i||c===(null==e?void 0:e.id))&&(u.baseSupplied=m);const[,g]=mw(l,I,A,O,p,h,v);g&&(i||c===(null==t?void 0:t.id))&&(u.quoteSupplied=g)}for(const o of _){const{id:r,liquidityTokenInMining:s}=o,l=new a(null!=s?s:0),[d,c]=r.split("-"),[,u]=mw(l,B,S,E,p,h,y),[,m]=mw(l,I,A,O,p,h,v);if(n.has(d)){const o=n.get(d);u&&(i||c===(null==e?void 0:e.id))&&(o.baseSupplied=u.plus(o.baseSupplied)),m&&(i||c===(null==t?void 0:t.id))&&(o.quoteSupplied=m.plus(o.quoteSupplied))}else{const o={id:d,baseSupplied:new a(0),quoteSupplied:new a(0)};u&&(i||c===(null==e?void 0:e.id))&&(o.baseSupplied=u),m&&(i||c===(null==t?void 0:t.id))&&(o.quoteSupplied=m),n.set(o.id,o)}}const o=(null!==(l=null==m?void 0:m.decimals)&&void 0!==l?l:0)>6?6:4,r=(null!==(c=null==g?void 0:g.decimals)&&void 0!==c?c:0)>6?6:4,s=F;n.forEach((e=>{var t,n;D.push({userId:e.id,baseSupplied:e.baseSupplied?Su({input:e.baseSupplied,showDecimals:o}):"0",quoteSupplied:e.quoteSupplied?Su({input:e.quoteSupplied,showDecimals:r}):"0",baseTokenAddress:null!==(t=null==m?void 0:m.address)&&void 0!==t?t:"",quoteTokenAddress:null!==(n=null==g?void 0:g.address)&&void 0!==n?n:"",baseTokenSymbol:Wu(m),quoteTokenSymbol:Wu(g),sharePercentage:C&&S?Su({input:C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).div(C.multipliedBy(S).plus(null!=A?A:0)).multipliedBy(100),showDecimals:2}):"",dollarValue:null!=s&&C?`$${Su({input:C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).multipliedBy(s),showDecimals:2})}`:"-",dollarValueBN:C?C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0):a(0)})})),D.sort(((e,t)=>t.dollarValueBN.gt(e.dollarValueBN)?1:-1))}const U=[b,j,w,T,k,L,M],q=function(e){const t=[];if(e.forEach((e=>{e.error&&t.push(e.refetch)})),t.length)return()=>{t.forEach((e=>e()))}}(U),V=U.some((e=>e.isLoading));return Object.assign(Object.assign({},M),{isLoading:V,errorRefetch:q,list:D})}({pool:i}),[m,g]=n.useState(1),x=m*(c?4:8),f=h.list,y=x<f.length,v=f.slice(0,x);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:h.error?h.refetch:void 0,loading:h.isLoading&&!(null==v?void 0:v.length),empty:!(null==v?void 0:v.length),children:!!(null==v?void 0:v.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"JlIjZf",message:"Liquidity Provider"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"C1qIFl",message:"Liquidity Supplied"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"me2dmq",message:"Value (USD)"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"Z8lGw6",message:"Share"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==v?void 0:v.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(zf,{address:e.userId,customChainId:p,truncate:!0})})}),G.jsxs("td",{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.baseTokenAddress,chainId:p,width:18,height:18}),`${e.baseSupplied} ${e.baseTokenSymbol}`]}),G.jsxs(t.Box,{sx:{mt:4,display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.quoteTokenAddress,chainId:p,width:18,height:18}),`${e.quoteSupplied} ${e.quoteTokenSymbol}`]})]}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:e.dollarValue}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:`${e.sharePercentage}%`})]},e.userId)))})]})}),y&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:u.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>g((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function iA({address:e,chainId:t}){var n;const i=xp(),o=t?Hl[t]:"",a=i.getQuery(r.PoolApi.graphql.fetchPoolDashboard,{where:{pair_address:null!=e?e:"",chain:o}}),s=d.useQuery(Object.assign(Object.assign({},a),{enabled:!!e&&!!t})),l=null===(n=s.data)||void 0===n?void 0:n.dashboard_pairs_detail;return Object.assign(Object.assign({},s),{dashboard:l})}function oA(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function rA({chainId:e,address:n,symbol:o,amount:r,sx:a}){return G.jsxs(t.Box,{sx:i.merge({display:"flex",justifyContent:"flex-end",alignItems:"center"},a),children:[n&&G.jsx(t.Box,{sx:{height:16,flexBasis:16,flexGrow:0,flexShrink:0,mr:4},children:G.jsx(Nh,{width:16,height:16,address:n,chainId:e})}),G.jsxs(t.Box,{sx:{textAlign:"right",display:"flex",alignItems:"center"},children:[r," ",G.jsx(t.Box,{sx:{display:"inline-block",maxWidth:"6em",minWidth:"auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"},title:o,children:o})]})]})}function aA({chainId:e,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r,vertical:a}){const{isMobile:s}=Bp();return G.jsxs(t.Box,{sx:{mt:4,display:"flex",justifyContent:"flex-end",flexDirection:a?"column":"row",alignItems:a?"flex-end":"center",flexWrap:"wrap",typography:s?"h6":"body1"},children:[n?G.jsx(rA,{chainId:e,address:null==n?void 0:n.address,amount:o,symbol:null==n?void 0:n.symbol}):"-",a?"":G.jsx(t.Box,{sx:{mx:10},children:"/"}),i?G.jsx(rA,{chainId:e,address:null==i?void 0:i.address,amount:r,symbol:null==i?void 0:i.symbol,sx:{mt:a?4:0}}):"-"]})}function sA({label:e,children:n,pairsStatLoading:o,poolDetailLoading:r}){const{isMobile:a}=Bp();return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",minWidth:"5em",typography:a?"h6":"body1"},children:e}),G.jsx(t.Box,{sx:i.merge({textAlign:"right",overflow:"hidden","& .title":{typography:a?"body1":"caption",width:"100%"}},o&&!r||!o&&r?{ml:8,flex:1,display:"flex",flexDirection:"column",alignItems:"flex-end","& .title":{display:"flex",justifyContent:"flex-end"}}:{}),children:n})]})}function lA({sx:e}){return G.jsx(t.Skeleton,{sx:Object.assign({width:"100%",maxWidth:237,height:22},e)})}function dA({detail:e,lpFeeRate:n,mtFeeRate:i}){const{isMobile:r}=Bp();return"DPP"===(null==e?void 0:e.type)?null:e&&n&&i?G.jsxs(t.Box,{sx:{color:"text.secondary",typography:r?"h6":"body1"},children:[G.jsx("span",{children:"LP "}),G.jsx("span",{children:Vu({input:n,showDecimals:6})}),G.jsxs("span",{children:[" / ",o.i18n._({id:"7C/BwI",message:"Community Treasury"})," "]}),G.jsx("span",{children:Vu({input:new a(null!=i?i:0).toNumber(),showDecimals:6})})]}):G.jsx(lA,{sx:{mt:4}})}function cA({detail:e}){var n,i,r,s,l,c,u,p,h,m,g,x,f,y,v,b,C,j,w,k,T,B,I,S,A,E,O;const L=t.useTheme(),{isMobile:R}=Bp(),{baseToken:M,quoteToken:P}=null!=e?e:{},_="DPP"===(null==e?void 0:e.type),N="DSP"===(null==e?void 0:e.type)||"GSP"===(null==e?void 0:e.type),D="CLASSICAL"===(null==e?void 0:e.type),F=iA({address:null==e?void 0:e.address,chainId:null==e?void 0:e.chainId}),U=F.dashboard,q=F.isLoading,V=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(n=null==e?void 0:e.baseToken)||void 0===n?void 0:n.decimals,null===(i=null==e?void 0:e.quoteToken)||void 0===i?void 0:i.decimals)),H=q?G.jsx(lA,{}):null===(null==U?void 0:U.totalVolume)||void 0===(null==U?void 0:U.totalVolume)?"-":`$${Su({input:new a(null==U?void 0:U.totalVolume),showDecimals:2})}`,W=q?G.jsx(lA,{}):U&&(fy(U.totalFee)||fy(U.totalMtFee))?`$${Su({input:new a(U.totalFee||0).plus(U.totalMtFee||0),showDecimals:2})}`:"-",{account:$}=cp(),z=d.useQuery($u.getFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,$)),Z=null===(r=z.data)||void 0===r?void 0:r.mtFeeRate,Q=null===(s=z.data)||void 0===s?void 0:s.lpFeeRate,Y=null==Z?void 0:Z.plus(null!=Q?Q:0),K=!e,X=d.useQuery($u.getClassicalTargetQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(l=null==e?void 0:e.baseToken)||void 0===l?void 0:l.decimals,null===(c=null==e?void 0:e.quoteToken)||void 0===c?void 0:c.decimals));return G.jsxs(t.Box,{sx:Object.assign({pb:30,position:"relative",overflow:"hidden"},R?{backgroundColor:"background.paper",p:20}:{mt:32}),children:[G.jsxs(t.Box,{sx:{flex:"1 0 50%","& > div + div":{mt:10},"&::after":{content:'""',display:"block",my:20,width:"100%",height:"1px",backgroundColor:"border.main"}},children:[G.jsx(sA,{label:o.i18n._({id:"l4Za6X",message:"Total Swap Volume"}),pairsStatLoading:q,children:G.jsx("div",{className:"title",children:H})}),q||!e?G.jsx(lA,{sx:{mt:4}}):G.jsx(aA,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:null!==(u=null==U?void 0:U.baseVolumeCumulative)&&void 0!==u?u:0,showDecimals:2}),quoteAmount:Su({input:null!==(p=null==U?void 0:U.quoteVolumeCumulative)&&void 0!==p?p:0,showDecimals:2})}),G.jsx(sA,{label:o.i18n._({id:"Z033WN",message:"Total Swap Fee"}),pairsStatLoading:q,children:G.jsx("div",{className:"title",children:W})}),q||!e?G.jsx(lA,{sx:{mt:4}}):G.jsx(aA,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:new a(null!==(h=null==U?void 0:U.baseFee)&&void 0!==h?h:0).plus(null!==(m=null==U?void 0:U.baseMtFee)&&void 0!==m?m:0),showDecimals:2}),quoteAmount:Su({input:new a(null!==(g=null==U?void 0:U.quoteFee)&&void 0!==g?g:0).plus(null!==(x=null==U?void 0:U.quoteMtFee)&&void 0!==x?x:0),showDecimals:2})}),G.jsx(sA,{label:o.i18n._({id:"/BbUJ6",message:"Total Number of Traders"}),pairsStatLoading:q,children:q?G.jsx(lA,{sx:{mt:4}}):Su({input:null!==(f=null==U?void 0:U.txUsers)&&void 0!==f?f:0,showDecimals:0})})]}),G.jsxs(t.Box,{sx:{flex:"1 0 50%",overflow:"hidden","& > div + div":{mt:10}},children:[G.jsx(sA,{label:o.i18n._({id:"UE2beD",message:"Creator"}),poolDetailLoading:!e,children:e?e.isCpPool?G.jsx(zf,{address:null!==(y=e.cpCreator)&&void 0!==y?y:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(zf,{address:null!==(v=e.creator)&&void 0!==v?v:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(lA,{})}),(null==e?void 0:e.isCpPool)||(null==e?void 0:e.owner)?G.jsx(sA,{label:o.i18n._({id:"LtI9AS",message:"Owner"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):(null==e?void 0:e.isCpPool)?G.jsx(zf,{address:null==e?void 0:e.cpCreator,truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(zf,{address:null!==(b=e.owner)&&void 0!==b?b:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})}):"",G.jsx(sA,{label:o.i18n._({id:"52uNwk",message:"Creation Time"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):oA(1e3*Number((null==e?void 0:e.isCpPool)?e.cpCreatedAtTimestamp||0:e.createdAtTimestamp||0))||"-"}),(null==e?void 0:e.isCpPool)?G.jsxs(G.Fragment,{children:[G.jsx(sA,{label:o.i18n._({id:"cDWXuq",message:"Settler"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):G.jsx(zf,{address:(null==e?void 0:e.cpLiquidator)||"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})}),G.jsx(sA,{label:o.i18n._({id:"JuzN3b",message:"Related CrowdPooling"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):G.jsx(zf,{address:null==e?void 0:e.cpAddress,truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})})]}):void 0,G.jsxs(sA,{label:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),poolDetailLoading:K,children:[G.jsx("div",{className:"detail-title",style:{textAlign:"right"},children:Vu({input:null==Y?void 0:Y.toNumber(),showDecimals:6})}),G.jsx(dA,{detail:e,lpFeeRate:Q,mtFeeRate:Z})]}),G.jsx(sA,{label:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):null===(j=null===(C=V.data)||void 0===C?void 0:C.pmmParamsBG)||void 0===j?void 0:j.k.toString()}),G.jsx(sA,{poolDetailLoading:K,label:D?o.i18n._({id:"d8YnVj",message:"Guide Price"}):_?o.i18n._({id:"CeLrge",message:"Mid Price"}):N?o.i18n._({id:"4ogEAw",message:"Pegged Exchange Rate"}):o.i18n._({id:"jjuKOj",message:"Min Price"}),children:K?G.jsx(lA,{}):null!==M&&(N?`1 ${null==M?void 0:M.symbol} = ${null===(T=null===(k=null===(w=V.data)||void 0===w?void 0:w.pmmParamsBG)||void 0===k?void 0:k.i)||void 0===T?void 0:T.toString()} ${null==P?void 0:P.symbol}`:null===(S=null===(I=null===(B=V.data)||void 0===B?void 0:B.pmmParamsBG)||void 0===I?void 0:I.i)||void 0===S?void 0:S.toString())||"-"}),D&&G.jsxs(G.Fragment,{children:[G.jsx(sA,{label:o.i18n._({id:"JR7wWw",message:"Equilibrium target"}),poolDetailLoading:K,children:K?G.jsx(lA,{}):G.jsx(G.Fragment,{children:null===(O=null===(E=null===(A=V.data)||void 0===A?void 0:A.pmmParamsBG)||void 0===E?void 0:E.k)||void 0===O?void 0:O.toString()})}),X.data?G.jsx(aA,{vertical:!0,chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:X.data.baseTarget,showDecimals:2}),quoteAmount:Su({input:X.data.quoteTarget,showDecimals:2})}):""]})]})]})}function uA(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function pA({amountOut:e,amountIn:i,fromTokenSymbol:o,toTokenSymbol:r}){const[a,s]=n.useState(!1),l=Su({input:i/e,showDecimals:2}),d=Su({input:e/i,showDecimals:2});return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:["1 ",a?r:o," = ",a?l:d," ",a?o:r,G.jsx(t.Box,{sx:{ml:10,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backgroundColor:"background.paperContrast",borderRadius:"50%"},onClick:()=>s((e=>!e)),children:G.jsx(t.Box,{component:se.Switch})})]})}function hA({poolDetail:i}){var o,s,l;const{isMobile:c}=Bp(),u=t.useTheme(),{account:p,chainId:h}=cp(),m=d.useQuery($u.getFeeRateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,p)),g=null===(o=m.data)||void 0===o?void 0:o.mtFeeRate,x=null===(s=m.data)||void 0===s?void 0:s.lpFeeRate,f=null==g?void 0:g.plus(null!=x?x:0),y=function({chainId:e,address:t,first:n=50}){var i;const o=e?Hl[e]:"",a=xp().getQuery(r.PoolApi.graphql.fetchPoolSwapList,{first:n,orderBy:"timestamp",orderDirection:"desc",where:{pair:t,chain:o}}),s=d.useQuery(Object.assign(Object.assign({},a),{enabled:!!t})),l=null===(i=s.data)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},s),{swapList:l})}({address:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),[v,b]=n.useState(1),C=v*(c?4:8),j=null!==(l=y.swapList)&&void 0!==l?l:[],w=C<j.length,k=j.slice(0,C);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:y.error?y.refetch:void 0,loading:y.isLoading,empty:!(null==k?void 0:k.length),children:!!(null==k?void 0:k.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"UPXmW+",message:"Trader"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"v4nCHK",message:"Paid"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"fZ5Vnu",message:"Received"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"a7u1N9",message:"Price"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"PLUB/s",message:"Fee"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==k?void 0:k.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:uA(1e3*e.timestamp)}),G.jsx("td",{children:G.jsx(zf,{address:e.from,truncate:!0})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.fromToken.id,chainId:h,width:18,height:18}),`${Su({input:e.amountIn,showDecimals:2})} ${e.fromToken.symbol}`]})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.toToken.id,chainId:h,width:18,height:18}),`${Su({input:e.amountOut,showDecimals:2})} ${e.toToken.symbol}`]})}),G.jsx("td",{children:G.jsx(pA,{amountOut:e.amountOut,amountIn:e.amountIn,fromTokenSymbol:e.fromToken.symbol,toTokenSymbol:e.toToken.symbol})}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:Vu({input:f})}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:`${Su({input:new a(e.amountOut).times(null!=f?f:0)})} ${e.toToken.symbol}`})]},e.id)))})]})}),w&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:u.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>b((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function mA({poolDetail:e}){const{isMobile:i}=Bp(),[r,a]=n.useState(JS.parameters),s=[{key:JS.parameters,value:o.i18n._({id:"F18WP3",message:"Parameters"})},{key:JS.swaps,value:o.i18n._({id:"EatqP4",message:"Swaps"})}];return e&&"DPP"!==(null==e?void 0:e.type)&&s.push({key:JS.liquidityProviders,value:o.i18n._({id:"juypHV",message:"Liquidity Providers"})}),G.jsx(t.Box,{sx:Object.assign({mt:24,backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},i?{}:{mt:32,px:20}),children:G.jsxs(t.Tabs,{value:r,onChange:(e,t)=>a(t),children:[G.jsx(t.TabsGroup,{tabs:s}),G.jsx(t.TabPanel,{value:JS.parameters,children:G.jsx(cA,{detail:e})}),G.jsx(t.TabPanel,{value:JS.swaps,children:G.jsx(hA,{poolDetail:e})}),G.jsx(t.TabPanel,{value:JS.liquidityProviders,children:G.jsx(nA,{poolDetail:e})})]})})}function gA(){return G.jsx(t.Skeleton,{variant:"rounded",sx:{width:90}})}function xA({poolDetail:n}){var i,r;const s=t.useTheme(),{isMobile:l}=Bp(),d=iA({address:null==n?void 0:n.address,chainId:null==n?void 0:n.chainId}),c=d.dashboard,u=[{description:o.i18n._({id:"Gr2anW",message:"Traders (24H)"}),text:d.isLoading?G.jsx(gA,{}):null===(null==c?void 0:c.txUserNear24h)||void 0===(null==c?void 0:c.txUserNear24h)?"-":Uu(new a(null==c?void 0:c.txUserNear24h))},{description:o.i18n._({id:"sTnImq",message:"Total Liquidity"}),text:d.isLoading?G.jsx(gA,{}):null===(null==c?void 0:c.tvl)||void 0===(null==c?void 0:c.tvl)?"-":`$${Uu(new a(null==c?void 0:c.tvl))}`},{description:o.i18n._({id:"p7/w10",message:"Volume (24H)"}),text:d.isLoading?G.jsx(gA,{}):null===(null==c?void 0:c.volume)||void 0===(null==c?void 0:c.volume)?"-":`$${Uu(new a(null==c?void 0:c.volume))}`},{description:o.i18n._({id:"7X40pG",message:"Fees (24H)"}),text:d.isLoading?G.jsx(gA,{}):null!==!(null==c?void 0:c.feeNear24h)||(null==c?void 0:c.mtFeeNear24h)?`$${Uu(new a(null!==(i=null==c?void 0:c.feeNear24h)&&void 0!==i?i:0).plus(null!==(r=null==c?void 0:c.mtFeeNear24h)&&void 0!==r?r:0))}`:"-",question:d.isLoading?void 0:G.jsxs(t.Box,{sx:{width:198},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"}),G.jsx(t.Box,{children:(null==c?void 0:c.feeNear24h)?`$${Uu(new a(null==c?void 0:c.feeNear24h))}`:"-"})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"}),G.jsx(t.Box,{children:(null==c?void 0:c.mtFeeNear24h)?`$${Uu(new a(null==c?void 0:c.mtFeeNear24h))}`:"-"})]})]})}];return G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:12},l?{mt:24,gridTemplateColumns:"repeat(2, 1fr)"}:{mt:32,gridTemplateColumns:"repeat(4, 1fr)"}),children:u.map((e=>G.jsxs(t.Box,{sx:{borderRadius:8,p:16,backgroundColor:"background.paper",border:`1px solid ${s.palette.border.main}`},children:[G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,lineHeight:"27px"},children:e.text}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary",gap:4},children:[e.description,e.question?G.jsx(lf,{title:e.question}):""]})]},e.description)))})}function fA({poolDetail:n,loading:i}){var a,s,l,d;const{address:c}=null!=n?n:{},u=t.useTheme(),p=zy(),{account:h}=cp(),{isMobile:m}=Bp(),g=h&&"DPP"===(null==n?void 0:n.type)&&(null===(a=null==n?void 0:n.owner)||void 0===a?void 0:a.toLocaleLowerCase())===h.toLocaleLowerCase(),{supportAMMV2:x,onSharePool:f}=X();return G.jsxs(t.Box,{sx:Object.assign({},m?{pt:24}:{pt:20,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==n?void 0:n.baseToken)?G.jsx(wy,{tokens:[n.baseToken,n.quoteToken],chainId:n.chainId,width:36,mr:8}):G.jsx(t.Skeleton,{variant:"circular",sx:{width:36,height:36,mr:8}}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h4"},children:[(null==n?void 0:n.baseToken)?`${null===(s=n.baseToken)||void 0===s?void 0:s.symbol} / ${null===(l=n.quoteToken)||void 0===l?void 0:l.symbol}`:"-",x&&G.jsx(t.Box,{component:"span",sx:{position:"relative",top:-4,ml:4,px:4,py:2,borderRadius:4,fontSize:10,lineHeight:1,fontWeight:600,backgroundColor:t.alpha(u.palette.purple.main,.1),color:u.palette.purple.main},children:"PMM"}),G.jsx(hk,{address:c,chainId:null==n?void 0:n.chainId,hideName:m,sx:{display:"inline-flex",ml:8}}),g&&!m?G.jsx(t.Box,{component:t.ButtonBase,sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderRadius:4,borderColor:"primary.main",color:"primary.main",whiteSpace:"nowrap","&:hover":{backgroundColor:"primary.main",color:"primary.contrastText"}},onClick:()=>{p.push({type:exports.PageType.ModifyPool,params:{address:null==n?void 0:n.address,chainId:null==n?void 0:n.chainId}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):""]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",mr:12},children:G.jsx(zf,{address:null!=c?c:"",truncate:!0,showCopy:!0,iconDarkHover:!0,"data-key":"link",sx:{typography:"body2",color:"text.secondary"},iconSize:14,iconSpace:6,customChainId:null==n?void 0:n.chainId,onShareClick:f&&n?()=>f({chainId:n.chainId,baseToken:n.baseToken,quoteToken:n.quoteToken,poolId:c,apy:n.apy,isSingle:r.PoolApi.utils.singleSideLp(n.type)}):void 0})})]})]}),G.jsxs(t.Box,{sx:m?{display:"flex",alignItems:"center",mt:24}:{textAlign:"right"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"success.main",typography:"h4"},children:[(null==n?void 0:n.miningAddress)?G.jsx(t.Tooltip,{title:o.i18n._({id:"B3mhDR",message:"Add liquidity to obtain LP tokens for mining"}),children:G.jsx("span",{children:"✨ "})}):"",G.jsx(t.LoadingSkeleton,{loading:i,loadingSx:{width:100},children:null!==(d=null==n?void 0:n.baseApy)&&void 0!==d?d:"0%"}),(null==n?void 0:n.quoteApy)?`/${null==n?void 0:n.quoteApy}`:""]}),G.jsx(t.Box,{sx:Object.assign({typography:"body2"},m?{ml:4}:{}),children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]})}function yA({chainId:e,shortNumber:n,pieSize:i="default",baseReserve:o=new a(1),baseAmount:r=new a(1),quoteAmount:s=new a(0),baseTokenSymbol:l="-",quoteTokenSymbol:d="-",quoteTokenDecimals:c=18,baseTokenDecimals:u=18,baseTokenAddress:p,quoteTokenAddress:h,baseTvlRate:m,quoteTvlRate:g,disabledAmount:x,disabledRate:f,disabledPercentage:y,loading:v,sx:b,pieRadius:C}){const j=t.useTheme(),w="small"===i,k=w?6:16,T=C||(w?23:30),B=u>6?6:u>4?4:2,I=c>6?6:c>4?4:2,A=n?Uu(new a(o)):Su({input:o,showDecimals:B}),E=n?Uu(new a(s)):Su({input:s,showDecimals:I});let O=r.plus(s);O=O.lte(0)?new a(1):O;const L=m||r.div(O).multipliedBy(100).toFixed(2),R=g||s.div(O).multipliedBy(100).toFixed(2),M=r.lte(0)&&s.lte(0),P=j.palette.success.main,_=j.palette.error.main,N=[{name:"base",value:M?1:r.toNumber(),color:P},{name:"quote",value:M?1:s.toNumber(),color:_}];return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",flexDirection:"column"},b||{}),children:[G.jsx("div",{children:y?"":v?G.jsx(t.Skeleton,{width:46,height:46,variant:"circular"}):G.jsx(S.PieChart,{width:2*T,height:2*T,children:G.jsx(S.Pie,{isAnimationActive:!1,dataKey:"value",data:N,labelLine:!1,label:!1,outerRadius:T,fill:_,children:N.map(((e,t)=>G.jsx(S.Cell,{fill:e.color,strokeWidth:0},`cell-${t}`)))})})}),G.jsxs(t.Box,{className:"symbol-wrapper",sx:{display:"flex",flexDirection:"column",justifyContent:"center",ml:0,mt:16,width:"100%","& > div":{paddingLeft:"12px",position:"relative","&::before":{content:'""',width:"8px",height:"8px",position:"absolute",left:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:j.palette.purple.main,borderRadius:"50%"},"&:last-child::before":{backgroundColor:_},"&> span.symbol":{display:"inline-block",maxWidth:"6em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"}}},children:[v?G.jsx(t.Skeleton,{width:237,sx:{borderRadius:4}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{className:"symbol",title:l,sx:{typography:"h6"},children:l}),p?G.jsx(zf,{address:p,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[x?"":`${A} `,y||f?"":G.jsxs(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${L}%)`]})]})]}),v?G.jsx(t.Skeleton,{width:237,sx:{borderRadius:4,marginTop:`${k}px`}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:`${k}px`},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{className:"symbol",title:d,sx:{typography:"h6"},children:d}),h?G.jsx(zf,{address:h,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[x?"":`${E} `,y||f?"":G.jsxs(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${R}%)`]})]})]})]})]})}function vA({poolDetail:n}){var i,o,r,s,l,c,u,p,h;const m=t.useTheme(),{isMobile:g}=Bp(),x=d.useQuery($u.getPMMStateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(i=null==n?void 0:n.baseToken)||void 0===i?void 0:i.decimals,null===(o=null==n?void 0:n.quoteToken)||void 0===o?void 0:o.decimals)),f=null===(r=x.data)||void 0===r?void 0:r.midPrice,y=d.useQuery($u.getReserveLpQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(s=null==n?void 0:n.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==n?void 0:n.quoteToken)||void 0===l?void 0:l.decimals)),{baseReserve:v,quoteReserve:b}=y.data||{},C=v&&f?null==f?void 0:f.multipliedBy(v):void 0,j=b&&f?new a(b):void 0;let w=C&&j?null==C?void 0:C.plus(j):void 0;w=!w||w.lte(0)?new a(1):w;const k=C&&C.div(w).multipliedBy(100).toFixed(2),T=j&&j.div(w).multipliedBy(100).toFixed(2);return G.jsxs(t.Box,{sx:{mt:g?24:28},children:[G.jsx(t.Box,{sx:{fontWeight:600},children:G.jsx(e.Trans,{id:"sTnImq",message:"Total Liquidity"})}),G.jsxs(t.Box,{sx:{display:"flex",mt:16,backgroundColor:"background.paper",borderRadius:16,overflowX:"auto",border:`1px solid ${m.palette.border.main}`},children:[G.jsx(t.Box,{sx:{flex:g?1:void 0,padding:g?m.spacing(20,30,20,20):m.spacing(20,30,16)},children:G.jsx(yA,{pieRadius:44,baseReserve:v,baseAmount:C,baseTokenDecimals:null===(c=null==n?void 0:n.baseToken)||void 0===c?void 0:c.decimals,quoteAmount:j,baseTvlRate:k,quoteTvlRate:T,chainId:null==n?void 0:n.chainId,quoteTokenDecimals:(null===(u=null==n?void 0:n.quoteToken)||void 0===u?void 0:u.decimals)||void 0,baseTokenSymbol:Wu(null==n?void 0:n.baseToken),quoteTokenSymbol:Wu(null==n?void 0:n.quoteToken),baseTokenAddress:g?null===(p=null==n?void 0:n.baseToken)||void 0===p?void 0:p.address:"",quoteTokenAddress:g?null===(h=null==n?void 0:n.quoteToken)||void 0===h?void 0:h.address:"",shortNumber:!0,disabledRate:!g,disabledAmount:!g,loading:x.isLoading||y.isLoading,sx:g?{typography:"body2",fontWeight:600}:{"& .symbol-wrapper":{display:"flex",alignItems:"center",flexDirection:"row","& > div, & > span":{mt:0,"&:last-child":{ml:16}},"& .MuiSkeleton-root":{width:"40px !important"}}}})}),g?"":G.jsxs(t.Box,{component:"table",sx:{flex:1,fontWeight:600,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 0 1px","& thead":{typography:"h6",color:"text.secondary","& th":{textAlign:"right",px:20,py:16,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 1px","&:first-child":{textAlign:"left"}}},"& tbody":{typography:"body2",textAlign:"right","& td":{px:20,py:0,"&:first-child":{textAlign:"left"}}}},children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(e.Trans,{id:"bUUVED",message:"Asset"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"hcNa1G",message:"Token Amount"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"iaocTt",message:"Ratio"})})]})}),G.jsxs("tbody",{children:[G.jsxs("tr",{children:[G.jsx("td",{children:n?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:n.baseToken.address,width:24,height:24,marginRight:4,chainId:n.chainId}),G.jsxs(t.Box,{children:[n.baseToken.symbol,G.jsx(zf,{address:n.baseToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:n.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):G.jsx(t.Skeleton,{width:100,height:24})}),G.jsx("td",{children:n?Uu(new a(n.baseReserve)):G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}})}),G.jsx("td",{children:x.isLoading?G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=k?k:"-"}%`})]}),G.jsxs("tr",{children:[G.jsx("td",{children:n?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:n.quoteToken.address,width:24,height:24,marginRight:4,chainId:n.chainId}),G.jsxs(t.Box,{children:[n.quoteToken.symbol,G.jsx(zf,{address:n.quoteToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:n.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):G.jsx(t.Skeleton,{width:100,height:24})}),G.jsx("td",{children:n?Uu(new a(n.quoteReserve)):G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}})}),G.jsx("td",{children:x.isLoading?G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=T?T:"-"}%`})]})]})]})]})]})}function bA({params:i}){var r,a,s,l,d,c,u;const p=zy(),{isMobile:h}=Bp(),{account:m}=cp(),g=t.useTheme(),x=WS({id:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{poolDetail:f}=x,y=U(x,["poolDetail"]),[v,b]=n.useState("inital");y.isPending||y.error||f||"inital"!==v||b("open");const C=f&&"DPP"===f.type&&m&&(null===(r=f.owner)||void 0===r?void 0:r.toLocaleLowerCase())===m.toLocaleLowerCase(),j=f&&"DPP"!==f.type||m&&(null==f?void 0:f.owner)&&f.owner.toLocaleLowerCase()===m.toLocaleLowerCase(),[w,k]=n.useState();f&&void 0===w&&!h&&k(Qj.Add);const T=w&&f?Object.assign(Object.assign({},f),{baseLpToken:{id:null===(a=f.baseLpToken)||void 0===a?void 0:a.id,decimals:Number(null!==(l=null===(s=f.baseLpToken)||void 0===s?void 0:s.decimals)&&void 0!==l?l:18)},quoteLpToken:{id:null===(d=f.quoteLpToken)||void 0===d?void 0:d.id,decimals:Number(null!==(u=null===(c=f.quoteLpToken)||void 0===c?void 0:c.decimals)&&void 0!==u?u:18)}}):void 0,B=!!(null==f?void 0:f.miningAddress);return G.jsxs(Wy,{sx:h?{p:g.spacing(28,0,j?108:0)}:{p:g.spacing(28,0,40)},children:[G.jsx(VS,{onClick:()=>{p.push({type:exports.PageType.Pool})}}),G.jsxs(t.Box,{sx:h?{}:{display:"flex",gap:12,overflow:"hidden"},children:[G.jsxs(t.Box,{sx:{flex:1,overflow:"hidden"},children:[G.jsx(fA,{poolDetail:f,loading:y.isPending}),G.jsx(eA,{poolDetail:f,chart24hDataFirst:!0}),G.jsx(xA,{poolDetail:f}),G.jsx(vA,{poolDetail:f}),G.jsx(mA,{poolDetail:f})]}),h?G.jsx(pk,{account:m,pool:T,operate:w,hasMining:B,modal:!0,onClose:()=>{k(void 0)}}):G.jsx(uk,{account:m,operate:w,hasMining:B,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},pool:T,hidePoolInfo:!0})]}),G.jsx(qS,{singleBtn:!0,open:"open"===v,onClose:()=>b("close"),onConfirm:()=>b("close"),title:o.i18n._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),h&&j&&G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:C?"repeat(3, 1fr)":"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[C?G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{zy.getState().push({type:exports.PageType.ModifyPool,params:{chainId:f.chainId,address:f.address}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):"",G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{k(Qj.Remove)},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{onClick:()=>{k(Qj.Add)},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})})]})}function CA({statuses:n,children:i,buttonProps:o}){var r;if(!n.find((e=>e.needShowTokenStatusButton))&&i)return G.jsx(G.Fragment,{children:i});const a=n.find((e=>e.insufficientBalance));if(a)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,...o,children:G.jsx(e.Trans,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const s=n.some((e=>e.isApproving));return G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:n.map(((n,i)=>{var r,a;let l="";return n.isApproving?l=G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):(n.needReset||n.needApprove)&&(l=n.approveTitle),l?G.jsx(t.Button,{fullWidth:!0,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance||s,...o,children:l},null!==(a=null===(r=n.token)||void 0===r?void 0:r.symbol)&&void 0!==a?a:i):null}))})}function jA({token:i,chainId:o,showChainLogo:r,readonly:a,showChainName:s,logoSize:l=24,chainLogoSize:d=12,side:c,occupiedToken:u,defaultLoadBalance:p,notTokenPickerModal:h,border:m,px:g=20,py:x=8,highlightDefault:f,onTokenClick:y,onTokenChange:v}){var b,C;const{onlyChainId:j}=X(),w=o||j,k=t.useTheme(),[T,B]=n.useState(!1),I=(null==i?void 0:i.chainId)?ac.get(i.chainId):null,S=s&&!!I;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:k.palette.text.primary,typography:S?"body2":"body1",fontWeight:600,px:g,py:x,"&:focus-visible":{opacity:.5}},!!m&&{border:`solid 1px ${k.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:k.palette.hover.default}}),!(!f||i)&&{backgroundColor:k.palette.primary.main,color:k.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{a||B(!0)},"data-testid":jc,children:[!!(null==i?void 0:i.address)&&G.jsx(Nh,{url:null==i?void 0:i.logoURI,address:null!==(b=null==i?void 0:i.address)&&void 0!==b?b:"",chainId:null==i?void 0:i.chainId,noShowChain:!r,width:l,height:l,chainSize:d,logoOffset:10,marginRight:0}),G.jsxs(t.Box,{sx:{flex:1},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==i?void 0:i.address)?G.jsx(G.Fragment,{children:G.jsx(t.Box,{children:null!==(C=null==i?void 0:i.symbol)&&void 0!==C?C:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!a&&G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"})})]}),!!S&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[I.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]}),G.jsx(Xf,{value:i,open:T,side:c,chainId:w,occupiedAddrs:u?[u.address]:void 0,occupiedChainId:null==u?void 0:u.chainId,defaultLoadBalance:p,onClose:()=>{B(!1),y&&y()},onTokenChange:(e,t)=>{B(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),Ih)},modal:!h})]})}function wA({title:e,disabled:n,children:i}){return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:n?.3:void 0},children:[G.jsx(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),i]})}!function(e){e[e.depth=1]="depth",e[e.volume=2]="volume",e[e.feeRevenue=3]="feeRevenue",e[e.traders=4]="traders"}(XS||(XS={})),function(e){e[e.parameters=1]="parameters",e[e.swaps=2]="swaps",e[e.liquidityProviders=3]="liquidityProviders"}(JS||(JS={}));const kA=1e-4;function TA({disabled:i,fee:o,onChange:r,feeList:s,hasCustom:l}){const d=t.useTheme(),[c,u]=n.useState(!1),[p,h]=n.useState(!1),[m,g]=n.useState(""),{isMobile:x}=Bp(),f=!s.includes(o),y=f||p,v=!p&&f&&!!m&&new a(m).div(100).lt(kA),b=i||v;return G.jsxs(t.Box,{sx:{opacity:i?.3:void 0,fontWeight:600},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main"},children:[G.jsx(e.Trans,{id:"tMMG40",message:"{0}% fee tier",values:{0:o?new a(o).times(100).toString():"-"}}),G.jsx(t.ButtonBase,{sx:{px:16,py:7,border:`solid 1px ${d.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:b?"default":"pointer",opacity:v?.3:1},disabled:b,onClick:()=>{b||u((e=>!e))},children:c?G.jsx(e.Trans,{id:"vLyv1R",message:"Hide"}):G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]}),c&&G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({mt:12},x?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:[s.map((e=>{const n=o===e&&!y;return G.jsxs(t.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer"},n&&{color:d.palette.primary.main,borderColor:d.palette.primary.main}),children:[100*e,"%",G.jsx(t.Radio,{size:18,checked:n,onChange:(t,n)=>{n&&r(e)}})]},e)})),l&&G.jsxs(t.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer",color:v?d.palette.error.main:"text.primary"},y&&{color:d.palette.primary.main,borderColor:d.palette.primary.main}),onClick:()=>{h(!0),g("")},children:[p?G.jsx(t.Input,{value:m,autoFocus:!0,onChange:e=>{const t=e.target.value;isNaN(Number(t))||g(t)},onBlur:()=>{const e=Number(m),t=e?new a(e).div(100).toNumber():e;t&&t<kA?r(0):m&&(e||0===e)&&r(t),h(!1)},sx:{p:0,flex:1,height:"100%",border:"none",backgroundColor:"none"},inputSx:{p:0}}):G.jsx(G.Fragment,{children:f?(new a(o).times(100).toNumber()||m)+"%":G.jsx(e.Trans,{id:"8Tg/JR",message:"Custom"})}),G.jsx(t.Radio,{size:18,checked:y,sx:{flexShrink:0}})]})]}),v&&G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,typography:"h6",backgroundColor:t.alpha(d.palette.error.main,.1),color:d.palette.error.main},children:[G.jsx(t.Box,{component:se.ErrorBorder,sx:{width:18,height:18}}),G.jsx(e.Trans,{id:"LHxwaD",message:"The fee tier should greater than {0}%",values:{0:100*kA}})]})]})]})}function BA({isExists:i,pair:o,pairAddress:r}){var s,l,c;const{isBalanceLoading:p,isDepositedLoading:h,balance:m,token0Deposited:g,token1Deposited:x,poolTokenPercentage:f}=function({pairAddress:e,pair:t}){var i;const{account:o}=cp(),r=null===(i=null==t?void 0:t.liquidityToken)||void 0===i?void 0:i.chainId,s=d.useQuery(Object.assign(Object.assign({},u.getFetchUniswapV2PairBalanceOfQueryOptions(r,e,o)),{retry:!1})),l=d.useQuery(Object.assign(Object.assign({},u.getFetchUniswapV2PairTotalSupplyQueryOptions(r,e)),{retry:!1})),[c,p,h]=n.useMemo((()=>{if(!t||!s.data||!l.data||l.data<s.data)return[void 0,void 0,void 0];const e=M.CurrencyAmount.fromRawAmount(t.liquidityToken,l.data.toString()),n=M.CurrencyAmount.fromRawAmount(t.liquidityToken,s.data.toString());return[new M.Percent(s.data.toString(),l.data.toString()),t.getLiquidityValue(t.token0,e,n,!1),t.getLiquidityValue(t.token1,e,n,!1)]}),[s.data,l.data,t]);return{isBalanceLoading:s.isLoading,isDepositedLoading:s.isLoading||l.isLoading,balance:s.data&&t?Mu(s.data.toString(),t.liquidityToken.decimals):void 0,poolTokenPercentage:c?new a(c.toSignificant(6)):void 0,token0Deposited:p?new a(p.toSignificant()):void 0,token1Deposited:h?new a(h.toSignificant()):void 0}}({pairAddress:r,pair:o}),y=f?`${Su({input:f,showDecimals:2,roundingMode:a.ROUND_HALF_UP})}%`:void 0;return i&&o?G.jsxs(t.Box,{sx:{px:20,py:12,borderWidth:1,borderRadius:8,borderStyle:"solid",borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center"},children:[G.jsx(wy,{width:18,height:18,tokens:[o.token0,o.token1],mr:4}),G.jsx(t.LoadingSkeleton,{loading:p,loadingProps:{width:50},sx:{mr:4},children:Au({input:m,decimals:null===(s=o.liquidityToken)||void 0===s?void 0:s.decimals})}),`${o.token0.symbol}/${o.token1.symbol} LP`,G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[G.jsx(fw,{address:o.token0.address,chainId:o.token0.chainId,showName:null!==(l=o.token0.symbol)&&void 0!==l?l:"",size:14,offset:4,rightContent:G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:Au({input:g,decimals:o.token0.decimals})})}),G.jsx(fw,{address:o.token1.address,chainId:o.token1.chainId,showName:null!==(c=o.token1.symbol)&&void 0!==c?c:"",size:14,offset:4,rightContent:G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:Au({input:x,decimals:o.token1.decimals})})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"c4miqE",message:"Pool share"}),G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:y})]})]}),sx:{padding:20,width:256},children:G.jsx(t.HoverOpacity,{component:se.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),G.jsx(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:np(o.liquidityToken.chainId,o.liquidityToken.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:G.jsx(t.HoverOpacity,{component:se.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function IA({sx:i,disabled:o,slippage:r,onChangeSlippage:s}){const l=t.useTheme(),d=r===Ky,[c,u]=n.useState(d?"":new a(r).times(100).toNumber());return G.jsx(t.Tooltip,{disabled:o,onlyClick:!0,title:G.jsxs(t.Box,{sx:{backgroundColor:l.palette.background.paper,padding:l.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[d?Jy:r&&new a(r).times(100).toNumber(),"%"]})]}),G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"center",margin:l.spacing(16,0,0,0)},children:[G.jsx(Yy,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),s(Ky)},active:d}),G.jsx(t.Input,{placeholder:String(Jy),value:c,onChange:e=>{const{value:t}=e.target;u(t),s(t?new a(t).div(100).toNumber():Ky)},onBlur:()=>{(!d&&new a(r).gt(.1)||new a(r).lte(0))&&(u(10),s(.1))},suffix:G.jsx(t.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(t.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:l.spacing(0,0,0,"auto"),p:l.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast",cursor:"pointer"},i),children:G.jsx(t.Box,{component:se.Setting,sx:{width:18,height:18,"& path:last-child":{fill:l.palette.text.primary}}})})})}function SA(){var i,o,s;const l=t.useTheme(),[d,c]=n.useState(.003),[p,h]=n.useState(),[m,g]=n.useState(),[x,f]=n.useState(""),[y,v]=n.useState(""),[b,C]=n.useState(Ky),j=b===Ky?new a(Jy).div(100).toNumber():b,{isMobile:w}=Bp(),{onlyChainId:k}=X(),T=n.useMemo((()=>k||(null==p?void 0:p.chainId)||(null==m?void 0:m.chainId)),[k,p,m]),{pairAddress:B,pair:I,price:S,isInvalidPair:A,invertedPrice:E,priceLoading:O,liquidityMinted:L,shareOfPool:R,isExists:P}=function({baseToken:e,quoteToken:t,baseAmount:i,quoteAmount:o,fee:a}){const[s,l,d]=n.useMemo((()=>{var n,i;if(!e||!t)return[null,null,!1];const o=r.basicTokenMap[e.chainId],a=(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())===e.address.toLowerCase(),s=(null===(i=o.address)||void 0===i?void 0:i.toLowerCase())===t.address.toLowerCase(),l=a?o.wrappedTokenAddress:e.address,d=s?o.wrappedTokenAddress:t.address,c=l.toLowerCase()===d.toLowerCase();return c?[null,null,!0]:[new M.Token(e.chainId,l,e.decimals,e.symbol,e.name),new M.Token(t.chainId,d,t.decimals,t.symbol,t.name),c]}),[e,t]),c=n.useMemo((()=>{if(!s||!l||void 0===a)return;const e=s.chainId,t=e?u.getUniswapV2FactoryContractAddressByChainId(e)||u.getUniswapV2FactoryFixedFeeContractAddressByChainId(e):void 0;return t?ip({factoryAddress:t,tokenA:s,tokenB:l,fee:a}):void 0}),[s,l,a]),{pair:p,price:h,invertedPrice:m,reserveQuery:g,liquidityMinted:x,shareOfPool:f,isExists:y}=Jw({pool:e&&t&&c?{baseToken:e,quoteToken:t,type:"AMMV2",address:c}:void 0,baseAmount:i,quoteAmount:o});return{pairAddress:c,pair:p,isInvalidPair:d,price:h,invertedPrice:m,priceLoading:g.isLoading,liquidityMinted:x,shareOfPool:f,isExists:y}}({baseToken:p,quoteToken:m,baseAmount:x,quoteAmount:y,fee:d}),_=Cv(S);if(S&&x&&!S.isEqualTo(null!=_?_:0)&&P){const e=S.times(x).dp(null!==(i=null==m?void 0:m.decimals)&&void 0!==i?i:18);e.isEqualTo(y)||v(e.toString())}const N=T?u.getUniswapV2Router02ContractAddressByChainId(T)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(T):void 0,D=lh(p,{amount:x,contractAddress:N}),F=lh(m,{amount:y,contractAddress:N}),[U,q]=n.useState(!1),V=!p||!m,H=Zw({baseToken:p,quoteToken:m,baseAmount:x,quoteAmount:y,fee:d,isExists:P,slippage:j,successBack:()=>{zy.getState().push({type:exports.PageType.Pool,params:{tab:Uk.myLiquidity}})}});return n.useEffect((()=>{console.error("createMutation.error",H.error)}),[H.error]),G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[l.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[G.jsx(Kk,{onClick:()=>{zy.getState().push({type:exports.PageType.Pool})}}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})}),G.jsx(lj,{poolType:"AMM V2"})]}),G.jsxs(t.Box,{sx:{pt:20,px:16,position:"relative",overflow:"hidden",backgroundColor:l.palette.background.paper,borderRadius:16,[l.breakpoints.up("tablet")]:{borderWidth:1,borderStyle:"solid",borderColor:"border.main",px:0,mx:"auto",width:600}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:20,[l.breakpoints.up("tablet")]:{pt:20,px:20,pb:20}},children:[G.jsx(BA,{pair:I,pairAddress:B,isExists:P}),G.jsxs(wA,{title:G.jsx(e.Trans,{id:"nxRg31",message:"Select pair"}),children:[G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:w?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[G.jsx(jA,{border:!0,highlightDefault:!0,chainId:T,token:p,onTokenChange:(e,t)=>{t?(h(m),g(p),f(""),v("")):(h(e),f(""))},occupiedToken:m}),G.jsx(jA,{border:!0,highlightDefault:!0,chainId:T,token:m,onTokenChange:(e,t)=>{t?(h(m),g(p)):(g(e),v(""))},occupiedToken:p})]}),(!T||Ku(T))&&G.jsx(TA,{fee:d,onChange:c,feeList:[1e-4,5e-4,.003],hasCustom:!0,disabled:V})]}),G.jsx(wA,{title:G.jsx(e.Trans,{id:"MU9s7M",message:"Deposit amounts"}),disabled:V,children:G.jsxs(t.Box,{children:[G.jsx(py,{sx:{mb:4,pb:28,minHeight:"auto",backgroundColor:"background.cardInput",padding:l.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},token:p,amt:x,defaultLoadBalance:!0,onInputChange:e=>{var t;f(e);const n=Number(e);P&&S&&n&&v(S.times(e).dp(null!==(t=null==m?void 0:m.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(o=null==m?void 0:m.address)&&void 0!==o?o:""],occupiedChainId:null==m?void 0:m.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:V}),G.jsx(cy,{}),G.jsx(py,{sx:{pb:20,minHeight:"auto",backgroundColor:"background.cardInput",padding:l.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},token:m,amt:y,defaultLoadBalance:!0,onInputChange:e=>{var t;v(e);const n=Number(e);P&&E&&n&&f(E.times(e).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(s=null==p?void 0:p.address)&&void 0!==s?s:""],occupiedChainId:null==p?void 0:p.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:V}),G.jsx(IA,{slippage:b,onChangeSlippage:C,disabled:V,sx:{mt:8}}),G.jsx(Uw,{baseToken:p,quoteToken:m,loading:O,midPrice:S,shareOfPool:R}),!!P&&G.jsxs(t.Box,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vu({input:d})},components:{0:G.jsx("b",{})}})]})]})})]}),G.jsx(t.Box,{sx:{mt:20,py:16,[l.breakpoints.up("tablet")]:{px:20}},children:G.jsx(lv,{fullWidth:!0,includeButton:!0,size:t.Button.Size.big,disabled:V,chainId:T,children:G.jsx(CA,{statuses:[D,F],buttonProps:{size:t.Button.Size.big},children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,disabled:!(p&&m&&x&&y&&!A&&d),onClick:()=>q(!0),children:A?G.jsx(e.Trans,{id:"R7D79P",message:"Invalid pair"}):G.jsx(e.Trans,{id:"bwSQI0",message:"Supply"})})})})}),G.jsx(qw,{open:U,onClose:()=>q(!1),slippage:j,baseToken:p,baseAmount:x,quoteToken:m,quoteAmount:y,fee:d,price:S,lpAmount:L,shareOfPool:R,pairAddress:B,createMutation:H})]})]})}const AA=({disabled:e,feeAmount:i,dispatch:r})=>{const a=t.useTheme(),{isMobile:s}=Bp(),[l,d]=n.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:a.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[G.jsx(t.Box,{sx:{typography:"h5",color:a.palette.text.primary},children:i?`${sj[i].label} ${o.i18n._({id:"fxRyGG",message:"fee tier"})}`:o.i18n._({id:"EU3wU4",message:"Fee tier"})}),G.jsx(t.Button,{size:t.Button.Size.small,variant:t.Button.Variant.outlined,disabled:e,onClick:()=>d((e=>!e)),sx:{color:a.palette.text.primary,border:`solid 1px ${a.palette.text.primary}`},children:l?o.i18n._({id:"vLyv1R",message:"Hide"}):o.i18n._({id:"ePK91l",message:"Edit"})})]}),l&&G.jsx(t.Box,{sx:Object.assign({},s?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[Yv.LOWEST,Yv.LOW,Yv.MEDIUM,Yv.HIGH].map((n=>{const o=i===n;return G.jsxs(t.Button,{size:t.Button.Size.middle,variant:t.Button.Variant.outlined,disabled:e,onClick:()=>{r({type:Bj.UpdateFeeAmount,payload:n})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:o?a.palette.primary.main:a.palette.text.primary,borderRadius:12,borderColor:o?a.palette.primary.main:a.palette.border.main,[a.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[sj[n].label,o?G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.primary.main}),G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:a.palette.primary.main,stroke:a.palette.primary.main})]}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.text.secondary})})]},n)}))})]})},EA={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},OA=({series:e,xScale:i,yScale:o,xValue:r,yValue:a,fill:s})=>n.useMemo((()=>{var n;return G.jsx(t.Box,{component:"path",opacity:.5,stroke:null!=s?s:EA.accent1,fill:null!=s?s:EA.accent1,d:null!==(n=_.area().curve(_.curveStepAfter).x((e=>i(r(e)))).y1((e=>o(a(e)))).y0(o(0))(e.filter((e=>{const t=i(r(e));return t>0&&t<=window.innerWidth}))))&&void 0!==n?n:void 0})}),[s,e,i,r,o,a]),LA=({axisGenerator:e})=>G.jsx("g",{ref:t=>{t&&_.select(t).call(e).call((e=>e.select(".domain").remove()))}}),RA=({xScale:e,innerHeight:i,offset:o=0})=>n.useMemo((()=>G.jsx(t.Box,{component:"g",transform:`translate(0, ${i+o})`,sx:{"& line":{display:"none"},"& text":{color:EA.neutral2,transform:"translateY(5px)"}},children:G.jsx(LA,{axisGenerator:_.axisBottom(e).ticks(6)})})),[i,o,e]),MA=e=>["M 0 0",`v ${e}`,"m 1 0","V 0","M 0 1","h 12","q 2 0, 2 2","v 22","q 0 2 -2 2","h -12","z"].join(" "),PA=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),_A=({color:e,size:t=10,margin:n=10})=>G.jsx("polygon",{points:`0 0, ${t} ${t}, 0 ${t}`,transform:` translate(${t+n}, ${n}) rotate(45) `,fill:e,stroke:e,strokeWidth:"4",strokeLinejoin:"round"});const NA=({color:e,d:n})=>G.jsx(t.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:n}),DA=({d:e})=>G.jsx(t.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:EA.white,opacity:EA.opacity.hover,d:e}),FA=({visible:e,transform:n,children:i})=>G.jsx(t.Box,{component:"g",opacity:e?"1":"0",transform:n,sx:{transition:"opacity 300ms"},children:i}),UA=({y:e,x:n,height:i,width:o,rx:r})=>G.jsx(t.Box,{component:"rect",fill:EA.surface3,y:e,x:n,height:i,width:o,rx:r}),qA=({y:e,transform:n,dominantBaseline:i,children:o})=>G.jsx(t.Box,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:EA.neutral1,transform:n,dominantBaseline:i,children:o}),VA=(e,t,n)=>{const i=e.map((e=>n(e).toFixed(1))),o=t.map((e=>n(e).toFixed(1)));return i.every(((e,t)=>e===o[t]))},HA=({id:e,xScale:t,interactive:i,brushLabelValue:o,brushExtent:r,setBrushExtent:a,innerWidth:s,innerHeight:l,westHandleColor:d,eastHandleColor:c})=>{const u=n.useRef(null),p=n.useRef(null),[h,m]=n.useState(r),[g,x]=n.useState(!1),[f,y]=n.useState(!1),v=function(e){const t=n.useRef();return n.useEffect((()=>{t.current=e}),[e]),t.current}(r),b=n.useCallback((e=>{const{type:n,selection:i,mode:o}=e;if(!i)return void m(null);const s=i.map(t.invert);"end"!==n||VA(r,s,t)||a(s,o),m(s)}),[t,r,a]);n.useEffect((()=>{m(r)}),[r]),n.useEffect((()=>{u.current&&(p.current=_.brushX().extent([[Math.max(2,t(0)),0],[s-2,l]]).handleSize(30).filter((()=>i)).on("brush end",b),p.current(_.select(u.current)),v&&VA(r,v,t)&&_.select(u.current).transition().call(p.current.move,r.map(t)),_.select(u.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[r,b,e,l,s,i,v,t]),n.useEffect((()=>{u.current&&p.current&&p.current.move(_.select(u.current),r.map(t))}),[r,t]),n.useEffect((()=>{x(!0);const e=setTimeout((()=>x(!1)),1500);return()=>clearTimeout(e)}),[h]);const C=h&&t(h[0])>20,j=h&&t(h[1])>s-20,w=h&&(t(h[0])<0||t(h[1])<0),k=h&&(t(h[0])>s||t(h[1])>s),T=h&&t(h[0])>=0&&t(h[0])<=s,B=h&&t(h[1])>=0&&t(h[1])<=s;return n.useMemo((()=>G.jsxs(G.Fragment,{children:[G.jsxs("defs",{children:[G.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[G.jsx("stop",{stopColor:d}),G.jsx("stop",{stopColor:c,offset:"1"})]}),G.jsx("clipPath",{id:`${e}-brush-clip`,children:G.jsx("rect",{x:"0",y:"0",width:s,height:l})})]}),G.jsx("g",{ref:u,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)}),h&&G.jsxs(G.Fragment,{children:[T?G.jsxs("g",{transform:`translate(${Math.max(0,t(h[0]))}, 0), scale(${C?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(NA,{color:d,d:MA(l)}),G.jsx(DA,{d:PA()})]}),G.jsxs(FA,{transform:`translate(50,0), scale(${C?"1":"-1"}, 1)`,visible:g||f,children:[G.jsx(UA,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(qA,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:o("w",h[0])})]})]}):null,B?G.jsxs("g",{transform:`translate(${t(h[1])}, 0), scale(${j?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(NA,{color:c,d:MA(l)}),G.jsx(DA,{d:PA()})]}),G.jsxs(FA,{transform:`translate(50,0), scale(${j?"-1":"1"}, 1)`,visible:g||f,children:[G.jsx(UA,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(qA,{y:"15",dominantBaseline:"middle",children:o("e",h[1])})]})]}):null,w&&G.jsx(_A,{color:d}),k&&G.jsx("g",{transform:`translate(${s}, 0) scale(-1, 1)`,children:G.jsx(_A,{color:c})})]})]})),[o,c,B,j,C,f,e,l,s,h,k,g,w,d,T,t])},WA=({value:e,xScale:i,innerHeight:o})=>n.useMemo((()=>G.jsx(t.Box,{component:"line",x1:i(e),y1:"0",x2:i(e),y2:o,sx:{opacity:.5,strokeWidth:2,stroke:EA.neutral1,fill:"none"}})),[e,i,o]);function $A({svg:e,xScale:i,setZoom:o,width:r,height:a,resetBrush:s,showResetButton:l,zoomLevels:d}){const c=n.useRef(),[u,p,h,m]=n.useMemo((()=>[()=>e&&c.current&&_.select(e).transition().call(c.current.scaleBy,2),()=>e&&c.current&&_.select(e).transition().call(c.current.scaleBy,.5),()=>e&&c.current&&_.select(e).transition().call(c.current.scaleTo,.5),()=>e&&c.current&&_.select(e).call(c.current.transform,_.zoomIdentity.translate(0,0).scale(1)).transition().call(c.current.scaleTo,.5)]),[e]);return n.useEffect((()=>{e&&(c.current=_.zoom().scaleExtent([d.min,d.max]).extent([[0,0],[r,a]]).on("zoom",(({transform:e})=>o(e))),_.select(e).call(c.current))}),[a,r,o,e,i,c,d,d.max,d.min]),n.useEffect((()=>{h()}),[h,d]),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${l?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[l&&G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:()=>{s(),m()},disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"1 4 1 10 7 10"}),G.jsx("polyline",{points:"23 20 23 14 17 14"}),G.jsx("path",{d:"M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"})]})}),G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const zA=e=>e.price0,ZA=e=>e.activeLiquidity;function QA({id:e="liquidityChartRangeInput",data:{series:i,current:o},ticksAtLimit:r,styles:a,dimensions:{width:s,height:l},margins:d,interactive:c=!0,brushDomain:u,brushLabels:p,onBrushDomainChange:h,zoomLevels:m}){const g=n.useRef(null),[x,f]=n.useState(null),[y,v]=n.useMemo((()=>[l-d.top-d.bottom,s-d.left-d.right]),[s,l,d]),{xScale:b,yScale:C}=n.useMemo((()=>{const e={xScale:_.scaleLinear().domain([o*m.initialMin,o*m.initialMax]).range([0,v]),yScale:_.scaleLinear().domain([0,_.max(i,ZA)]).range([y,0])};if(x){const t=x.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[o,m.initialMin,m.initialMax,v,i,y,x]);return n.useEffect((()=>{f(null)}),[m]),n.useEffect((()=>{u||h(b.domain(),void 0)}),[u,h,b]),G.jsxs(G.Fragment,{children:[G.jsx($A,{svg:g.current,xScale:b,setZoom:f,width:v,height:l,resetBrush:()=>{h([o*m.initialMin,o*m.initialMax],"reset")},showResetButton:Boolean(r[sv.LOWER]||r[sv.UPPER]),zoomLevels:m}),G.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${s} ${l}`,style:{overflow:"visible"},children:[G.jsxs("defs",{children:[G.jsx("clipPath",{id:`${e}-chart-clip`,children:G.jsx("rect",{x:"0",y:"0",width:v,height:l})}),u&&G.jsx("mask",{id:`${e}-chart-area-mask`,children:G.jsx("rect",{fill:"white",x:b(u[0]),y:"0",width:b(u[1])-b(u[0]),height:y})})]}),G.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[G.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[G.jsx(OA,{series:i,xScale:b,yScale:C,xValue:zA,yValue:ZA}),u&&G.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:G.jsx(OA,{series:i,xScale:b,yScale:C,xValue:zA,yValue:ZA,fill:a.area.selection})}),G.jsx(WA,{value:o,xScale:b,innerHeight:y}),G.jsx(RA,{xScale:b,innerHeight:y})]}),G.jsx(t.Box,{component:"rect",width:v,height:l,ref:g,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),G.jsx(HA,{id:e,xScale:b,interactive:c,brushLabelValue:p,brushExtent:null!=u?u:b.domain(),innerWidth:v,innerHeight:y,setBrushExtent:h,westHandleColor:a.brush.handle.west,eastHandleColor:a.brush.handle.east})]})]})]})}const GA=8;function YA(e,t,n,i,o,r){var a,s,l,d,c;let u=Object.assign({},n),p=[];for(let n=o+(r?1:-1);r?n<i.length:n>=0;r?n++:n--){const o=Number(null===(a=i[n])||void 0===a?void 0:a.tickIdx),h=PC(e,t,o),m={liquidityActive:u.liquidityActive,tick:o,liquidityNet:E.BigInt(null!==(l=null===(s=i[n])||void 0===s?void 0:s.liquidityNet)&&void 0!==l?l:""),price0:h.toFixed(GA),sdkPrice:h};r?m.liquidityActive=E.add(u.liquidityActive,E.BigInt(null!==(c=null===(d=i[n])||void 0===d?void 0:d.liquidityNet)&&void 0!==c?c:0)):!r&&E.notEqual(u.liquidityNet,E.BigInt(0))&&(m.liquidityActive=E.subtract(u.liquidityActive,u.liquidityNet)),p.push(m),u=m}return r||(p=p.reverse()),p}const KA=8,XA=(e,t)=>e&&t?Math.floor(e/Kv[t])*Kv[t]:void 0,JA=1e3;function eE(e,t,i,o){const[a,s]=n.useState(0),[l,c]=n.useState([]),{data:u,error:p,isLoading:h}=function(e,t,n,i=0,o){var a;const s=xp(),l=e&&t&&n?UC.getAddress(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped,n,void 0,o?Tv[o]:void 0):void 0,c=s.getQuery(r.AMMV3Api.graphql.AllV3TicksDocument,{skip:i,first:JA,where:{chain:o?Hl[o]:void 0,poolAddress:null!==(a=null==l?void 0:l.toLowerCase())&&void 0!==a?a:void 0,refreshNow:!0,schemaName:"ammv3"}});return d.useQuery(Object.assign(Object.assign({},c),{enabled:!0}))}(e,t,i,a,o),m=null==u?void 0:u.ticks;return n.useEffect((()=>{(null==m?void 0:m.length)&&(c((e=>[...e,...m])),(null==m?void 0:m.length)===JA&&s((e=>e+JA)))}),[m]),{isLoading:h||(null==m?void 0:m.length)===JA,error:p,ticks:l}}function tE({currencyA:e,currencyB:t,feeAmount:i,chainId:o}){const{isLoading:r,error:a,data:s}=function(e,t,i,o){var r,a,s;const l=gj(e,t,i),d=null===(r=l[1])||void 0===r?void 0:r.liquidity,c=null===(a=l[1])||void 0===a?void 0:a.sqrtRatioX96,u=null===(s=l[1])||void 0===s?void 0:s.tickCurrent,p=n.useMemo((()=>XA(u,i)),[u,i]),{isLoading:h,error:m,ticks:g}=eE(e,t,i,o);return n.useMemo((()=>{var n,i,o,r,a;if(!e||!t||void 0===p||l[0]!==mj.EXISTS||!g||0===g.length||h)return{isLoading:h||l[0]===mj.LOADING,error:m,activeTick:p,data:void 0};const s=null==e?void 0:e.wrapped,x=null==t?void 0:t.wrapped,f=g.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>p))-1;if(f<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{token0:s.address,token1:x.address,chainId:s.chainId}),{isLoading:h,error:m,activeTick:p,data:void 0};const y=PC(s,x,p),v={liquidityActive:E.BigInt(null!==(i=null===(n=l[1])||void 0===n?void 0:n.liquidity)&&void 0!==i?i:0),tick:p,liquidityNet:Number(null===(o=g[f])||void 0===o?void 0:o.tickIdx)===p?E.BigInt(null!==(a=null===(r=g[f])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):E.BigInt(0),price0:y.toFixed(KA),sdkPrice:y},b=YA(s,x,v,g,f,!0),C=YA(s,x,v,g,f,!1).concat(v).concat(b);return{isLoading:h,error:m,currentTick:u,activeTick:p,liquidity:d,sqrtPriceX96:c,data:C}}),[e,t,p,l,g,h,m,u,d,c])}(e,t,i,o),l=n.useCallback((()=>{if(!(null==s?void 0:s.length))return;const e=[];for(let t=0;t<s.length;t++){const n=s[t],i={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};i.activeLiquidity>0&&e.push(i)}return e}),[s]);return n.useMemo((()=>({isLoading:r,error:a,formattedData:r?void 0:l()})),[r,a,l])}const nE={initialMin:.999,initialMax:1.001,min:1e-5,max:1.5},iE={[Yv.LOWEST]:nE,[Yv.LOW_200]:nE,[Yv.LOW_300]:nE,[Yv.LOW_400]:nE,[Yv.LOW]:nE,[Yv.MEDIUM]:{initialMin:.5,initialMax:2,min:1e-5,max:20},[Yv.HIGH]:{initialMin:.5,initialMax:2,min:1e-5,max:20}};function oE({message:e,icon:n}){return G.jsxs(hv,{style:{height:"100%",justifyContent:"center"},children:[n,e&&G.jsx(t.Box,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function rE(){return G.jsx(t.LoadingSkeleton,{})}function aE({chainId:i,currencyA:o,currencyB:r,feeAmount:a,ticksAtLimit:s,price:l,priceLower:d,priceUpper:c,onLeftRangeInput:u,onRightRangeInput:p,interactive:h}){const m=o&&r&&(null==o?void 0:o.wrapped.sortsBefore(null==r?void 0:r.wrapped)),{isLoading:g,error:x,formattedData:f}=tE({currencyA:o,currencyB:r,feeAmount:a,chainId:i}),y=n.useCallback(((e,t)=>{let n=Number(e[0]);const i=Number(e[1]);n<=0&&(n=1/10**6),(!s[m?sv.LOWER:sv.UPPER]||"handle"===t||"reset"===t)&&n>0&&u(n.toFixed(6)),(!s[m?sv.UPPER:sv.LOWER]||"reset"===t)&&i>0&&i<1e35&&p(i.toFixed(6))}),[m,u,p,s]);h=h&&Boolean(null==f?void 0:f.length);const v=n.useMemo((()=>{const e=m?d:null==c?void 0:c.invert(),t=m?c:null==d?void 0:d.invert();return e&&t?[parseFloat(null==e?void 0:e.toSignificant(6)),parseFloat(null==t?void 0:t.toSignificant(6))]:void 0}),[m,d,c]),b=n.useCallback(((e,t)=>{if(!l)return"";if("w"===e&&s[m?sv.LOWER:sv.UPPER])return"0";if("e"===e&&s[m?sv.UPPER:sv.LOWER])return"∞";const n=(t<l?-1:1)*((Math.max(t,l)-Math.min(t,l))/l)*100;return l?`${Au({input:n,decimals:2})}%`:""}),[m,l,s]),C=!o||!r||void 0===f&&!g&&!x;return G.jsx(mv,{gap:"md",style:{minHeight:"200px"},children:C?G.jsx(oE,{message:G.jsx(e.Trans,{id:"OZUH85",message:"Your position will appear here."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:EA.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),G.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]})}):g?G.jsx(rE,{}):x?G.jsx(oE,{message:G.jsx(e.Trans,{id:"79D0qY",message:"Liquidity data not available."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:EA.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("path",{d:"M22.61 16.95A5 5 0 0 0 18 10h-1.26a8 8 0 0 0-7.05-6M5 5a8 8 0 0 0 4 15h9a5 5 0 0 0 1.7-.3"}),G.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):f&&0!==f.length&&l?G.jsx(t.Box,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:G.jsx(QA,{data:{series:f,current:l},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:EA.accent1},brush:{handle:{west:EA.critical,east:EA.accent1}}},interactive:h,brushLabels:b,brushDomain:v,onBrushDomainChange:y,zoomLevels:iE[null!=a?a:Yv.MEDIUM],ticksAtLimit:s})}):G.jsx(oE,{message:G.jsx(e.Trans,{id:"rH6vg9",message:"There is no liquidity data."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:EA.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),G.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),G.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const sE=({value:i,decrement:o,increment:r,decrementDisabled:a=!1,incrementDisabled:s=!1,locked:l,onUserInput:d,title:c,tokenA:u,tokenB:p})=>{const h=t.useTheme(),[m,g]=n.useState(!1),[x,f]=n.useState(""),[y,v]=n.useState(!1),[b,C]=n.useState(!1),j=n.useCallback((()=>{v(!1),g(!1),d(x)}),[x,d]),w=n.useCallback((()=>{v(!1),d(o())}),[o,d]),k=n.useCallback((()=>{v(!1),d(r())}),[r,d]);return n.useEffect((()=>{x===i||y||setTimeout((()=>{f(i),C(!0),setTimeout((function(){C(!1)}),1800)}),0)}),[x,y,i]),G.jsx(t.Box,{onFocus:()=>{v(!0),g(!0)},onBlur:j,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:h.palette.background.cardInput},children:G.jsxs(t.Box,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:h.palette.text.primary},children:c}),G.jsx(t.Box,{sx:{mt:4,typography:"h6",fontWeight:500,color:h.palette.text.secondary},children:G.jsx(e.Trans,{id:"1/LP4K",message:"{tokenB} per {tokenA}",values:{tokenB:p,tokenA:u}})}),G.jsx(Nf,{sx:{mt:12,backgroundColor:h.palette.background.cardInput},value:x,onChange:e=>{f(e)},readOnly:l})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&G.jsx(t.Button,{size:t.Button.Size.small,onClick:k,disabled:s,sx:{px:4,backgroundColor:h.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:a?h.palette.text.disabled:h.palette.text.primary})})}),!l&&G.jsx(t.Button,{size:t.Button.Size.small,onClick:w,disabled:a,sx:{px:4,backgroundColor:h.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:a?h.palette.text.disabled:h.palette.text.primary})})})]})]})})},lE=({priceLower:n,priceUpper:i,onLeftRangeInput:o,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:s,getDecrementUpper:l,getIncrementUpper:d,currencyA:c,currencyB:u,feeAmount:p,ticksAtLimit:h})=>{var m,g,x,f;const y=null===(m=null!=c?c:void 0)||void 0===m?void 0:m.wrapped,v=null===(g=null!=u?u:void 0)||void 0===g?void 0:g.wrapped,b=y&&v&&y.sortsBefore(v),C=b?n:null==i?void 0:i.invert(),j=b?i:null==n?void 0:n.invert();return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsx(sE,{value:h[b?sv.LOWER:sv.UPPER]?"0":null!==(x=null==C?void 0:C.toSignificant(8))&&void 0!==x?x:"",onUserInput:o,decrement:b?a:d,increment:b?s:l,decrementDisabled:void 0===C||h[b?sv.LOWER:sv.UPPER],incrementDisabled:void 0===C||h[b?sv.LOWER:sv.UPPER],feeAmount:p,label:C?`${null==u?void 0:u.symbol}`:"-",title:G.jsx(e.Trans,{id:"uEoBVI",message:"Low price"}),tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol}),G.jsx(sE,{value:h[b?sv.UPPER:sv.LOWER]?"∞":null!==(f=null==j?void 0:j.toSignificant(8))&&void 0!==f?f:"",onUserInput:r,decrement:b?l:s,increment:b?d:a,incrementDisabled:void 0===j||h[b?sv.UPPER:sv.LOWER],decrementDisabled:void 0===j||h[b?sv.UPPER:sv.LOWER],feeAmount:p,label:j?`${null==u?void 0:u.symbol}`:"-",tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol,title:G.jsx(e.Trans,{id:"kAC8rT",message:"High price"})})]})};var dE;function cE(){return cE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},cE.apply(null,arguments)}const uE=e=>D.createElement("svg",cE({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),dE||(dE=D.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},D.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function pE({chainId:e,token:i,oppositeTokenAddress:r,dispatch:a,tokenSelectOnChange:s}){const l=t.useTheme(),[d,c]=n.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:i?l.palette.border.main:l.palette.primary.main,color:i?l.palette.text.primary:l.palette.primary.contrastText,backgroundColor:i?"transparent":l.palette.primary.main,"&:hover":{borderColor:i?l.palette.border.main:l.palette.primary.main,opacity:.8},[l.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[i?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:i.address,marginRight:0,width:24,height:24,chainId:i.chainId||e,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:i.symbol})]}):G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:o.i18n._({id:"0RrIzN",message:"Select token"})}),G.jsx(t.Box,{component:uE,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),G.jsx(Xf,{value:Cj(i),open:d,chainId:e,occupiedAddrs:[r],occupiedChainId:null==i?void 0:i.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return a({type:Bj.UpdateBaseTokenAndClearQuoteToken,payload:e}),void c(!1);s(e),c(!1)}},modal:!0})]})}const hE=({chainId:e,baseToken:n,quoteToken:i,dispatch:o})=>{var r,a;const s=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[s.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[G.jsx(pE,{chainId:e,token:n,oppositeTokenAddress:null!==(r=null==i?void 0:i.address)&&void 0!==r?r:"",dispatch:o,tokenSelectOnChange:e=>{o({type:Bj.UpdateBaseToken,payload:e})}}),G.jsx(pE,{chainId:e,token:i,oppositeTokenAddress:null!==(a=null==n?void 0:n.address)&&void 0!==a?a:"",dispatch:o,tokenSelectOnChange:e=>{o({type:Bj.UpdateQuoteToken,payload:e})}})]})};const mE=[{value:.03,title:"Narrow"},{value:.08,title:"Standard"},{value:.15,title:"Wide"},{value:1,title:"Full"}],gE=e=>{const i=t.useTheme(),[o,r]=n.useState(null);return G.jsx(t.Box,{sx:{borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:i.palette.border.main,overflow:"hidden",display:"flex",alignItems:"center",flexWrap:"wrap",alignSelf:"stretch"},children:mE.map(((n,a)=>G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{r(n.value),e.onSelect(n.value)},sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",px:20,py:12,gap:8,flexBasis:"50%",flexGrow:1,borderRight:a%2==0?`1px solid ${i.palette.border.main}`:"none",borderBottom:a<=1?`1px solid ${i.palette.border.main}`:"none",[i.breakpoints.up("tablet")]:{flexBasis:"25%",borderRight:a===mE.length-1?"none":`1px solid ${i.palette.border.main}`,borderBottom:"none"},backgroundColor:o===n.value?t.alpha("#7BF179",.1):"transparent","&:hover":{backgroundColor:t.alpha("#7BF179",.1)}},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:i.palette.text.primary},children:n.title}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600,color:i.palette.text.primary},children:1===n.value?"∞":`+-${100*n.value}%`})]},n.value)))})};function xE({params:i,handleGoBack:r,handleGoToPoolList:s}){var l,c,u,p,h,m,g,x,f,y;const{account:v,onlyChainId:b,defaultChainId:C}=cp(),j=null!=b?b:C,w=t.useTheme(),k=Up(),{isMobile:T}=Bp(),B=d.useQuery(Object.assign({},id.getFetchTokenQuery(j,null==i?void 0:i.from,v))),I=d.useQuery(Object.assign({},id.getFetchTokenQuery(j,null==i?void 0:i.to,v))),[S,A]=n.useReducer(Ij,{baseToken:null,quoteToken:null,feeAmount:(null==i?void 0:i.fee)?Number(null==i?void 0:i.fee):void 0,independentField:av.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});n.useEffect((()=>{B.data&&A({type:Bj.UpdateDefaultBaseToken,payload:B.data})}),[B]),n.useEffect((()=>{I.data&&A({type:Bj.UpdateDefaultQuoteToken,payload:I.data})}),[I]);const{independentField:E,typedValue:O,startPriceTypedValue:L}=S,{pool:R,ticks:M,dependentField:P,price:_,pricesAtTicks:N,pricesAtLimit:D,parsedAmounts:F,currencyBalances:U,position:V,noLiquidity:H,currencies:W,errorMessage:$,invalidPool:z,invalidRange:Z,outOfRange:Q,depositADisabled:Y,depositBDisabled:K,invertPrice:J,ticksAtLimit:ee,isTaxed:te}=Tj({state:S,chainId:j}),ne=n.useMemo((()=>{var e;return null===(e=J?null==_?void 0:_.invert():_)||void 0===e?void 0:e.toSignificant()}),[J,_]),{onFieldAInput:ie,onFieldBInput:oe,onLeftRangeInput:re,onRightRangeInput:ae,onStartPriceInput:se}=Sj({noLiquidity:H,dispatch:A}),{slipper:le,setSlipper:de,slipperValue:ce,resetSlipper:ue}=nv({address:void 0,type:"AMMV3"}),pe=!$&&!Z,[he,me]=n.useState(!1),ge={[E]:O,[P]:null!==(c=null===(l=F[P])||void 0===l?void 0:l.toSignificant(6))&&void 0!==c?c:""},xe=[av.CURRENCY_A,av.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:Lj(U[t])})),{}),fe=lh(Cj(null===(u=F[av.CURRENCY_A])||void 0===u?void 0:u.currency),{contractAddress:Bv[j],overrideBalance:U[av.CURRENCY_A]?new a(U[av.CURRENCY_A].toSignificant()):void 0,amount:F[av.CURRENCY_A]?new a(F[av.CURRENCY_A].toSignificant()):void 0}),ye=lh(Cj(null===(p=F[av.CURRENCY_B])||void 0===p?void 0:p.currency),{contractAddress:Bv[j],overrideBalance:U[av.CURRENCY_B]?new a(U[av.CURRENCY_B].toSignificant()):void 0,amount:F[av.CURRENCY_B]?new a(F[av.CURRENCY_B].toSignificant()):void 0}),{[sv.LOWER]:ve,[sv.UPPER]:be}=M,{[sv.LOWER]:Ce,[sv.UPPER]:je}=N,{getDecrementLower:we,getIncrementLower:ke,getDecrementUpper:Te,getIncrementUpper:Be,getSetFullRange:Ie}=function({tickLower:e,tickUpper:t,pool:i,state:o,dispatch:r}){const{baseToken:a,quoteToken:s,feeAmount:l}=o,d=n.useMemo((()=>null==a?void 0:a.wrapped),[a]),c=n.useMemo((()=>null==s?void 0:s.wrapped),[s]);return{getDecrementLower:n.useCallback((()=>d&&c&&"number"==typeof e&&l?PC(d,c,e-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof e&&d&&c&&l&&i?PC(d,c,i.tickCurrent-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,e,l,i]),getIncrementLower:n.useCallback((()=>d&&c&&"number"==typeof e&&l?PC(d,c,e+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof e&&d&&c&&l&&i?PC(d,c,i.tickCurrent+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,e,l,i]),getDecrementUpper:n.useCallback((()=>d&&c&&"number"==typeof t&&l?PC(d,c,t-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof t&&d&&c&&l&&i?PC(d,c,i.tickCurrent-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,t,l,i]),getIncrementUpper:n.useCallback((()=>d&&c&&"number"==typeof t&&l?PC(d,c,t+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof t&&d&&c&&l&&i?PC(d,c,i.tickCurrent+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,t,l,i]),getSetFullRange:n.useCallback((()=>{r({type:Bj.setFullRange,payload:void 0})}),[r])}}({tickLower:ve,tickUpper:be,pool:R,state:S,dispatch:A}),Se=n.useCallback((e=>{if(1===e)Ie();else if(ne){const t=new a(ne),n=t.multipliedBy(1-e),i=t.multipliedBy(1+e);re(n.dp(5,a.ROUND_DOWN).toString()),ae(i.dp(5,a.ROUND_DOWN).toString())}}),[ne,Ie,re,ae]),{deadLine:Ae}=X(),Ee=d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){if(!v||!j||!V)return;if(!S.baseToken||!S.quoteToken)return;const e=Math.ceil(Date.now()/1e3)+(null!=Ae?Ae:600),t=S.baseToken.isNative?S.baseToken:S.quoteToken.isNative?S.quoteToken:void 0;try{const{calldata:n,value:i}=XC.addCallParameters(V,{slippageTolerance:Pj(100*ce),recipient:v,deadline:e.toString(),useNative:t,createPool:H});let r={to:Bv[j],data:n,value:i};(yield k.execute(o.i18n._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Mp.TX},r),{early:!1,metadata:{[exports.MetadataFlag.createAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{s()}),100)}catch(e){console.error("onAddMutation",e)}}))});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[w.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[G.jsx(Kk,{}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})}),G.jsx(lj,{poolType:"AMM V3"})]}),G.jsxs(t.Box,{sx:{px:16,display:"flex",flexDirection:"column",alignItems:"stretch",backgroundColor:w.palette.background.paper,borderRadius:16,[w.breakpoints.up("tablet")]:{borderColor:w.palette.border.main,borderWidth:1,borderStyle:"solid",px:0,mx:"auto",width:600}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,py:20,[w.breakpoints.up("tablet")]:{px:20}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"nxRg31",message:"Select pair"})}),G.jsx(hE,{chainId:j,baseToken:S.baseToken,quoteToken:S.quoteToken,dispatch:A}),G.jsx(AA,{disabled:!S.baseToken||!S.quoteToken,feeAmount:S.feeAmount,dispatch:A})]}),G.jsxs(yv,{disabled:!S.feeAmount||z,children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"5CZbyC",message:"Set price range"})}),Boolean(S.baseToken&&S.quoteToken)&&G.jsx(oj,{baseToken:S.baseToken,quoteToken:S.quoteToken,handleRateToggle:()=>{var e,t,n,i,o;ee[sv.LOWER]||ee[sv.UPPER]||(re(null!==(t=null===(e=J?Ce:null==je?void 0:je.invert())||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""),ae(null!==(i=null===(n=J?je:null==Ce?void 0:Ce.invert())||void 0===n?void 0:n.toSignificant(6))&&void 0!==i?i:""),ie(null!==(o=ge[av.CURRENCY_B])&&void 0!==o?o:"")),A({type:Bj.ToggleRate,payload:void 0})},sx:T?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]}),G.jsx(gE,{onSelect:Se}),G.jsx(lE,{priceLower:Ce,priceUpper:je,getDecrementLower:we,getIncrementLower:ke,getDecrementUpper:Te,getIncrementUpper:Be,onLeftRangeInput:re,onRightRangeInput:ae,currencyA:S.baseToken,currencyB:S.quoteToken,feeAmount:S.feeAmount,ticksAtLimit:ee}),Q&&G.jsx(pv,{children:o.i18n._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),Z&&G.jsx(pv,{children:o.i18n._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),H?G.jsxs(yv,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"zeSosD",message:"Starting price"})}),G.jsx(t.Box,{sx:{p:8,borderRadius:8,backgroundColor:t.alpha(w.palette.primary.main,.1),typography:"h6",color:w.palette.primary.main},children:o.i18n._({id:"X6T02b",message:"This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."})}),G.jsx(t.Box,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:w.palette.border.main,borderStyle:"solid"},children:G.jsx(Nf,{sx:{backgroundColor:"transparent"},value:L,onChange:se})})]}):G.jsxs(yv,{disabled:!S.feeAmount||z,children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:[o.i18n._({id:"DWd30U",message:"Current price"}),G.jsxs(t.Box,{children:[ne," ",o.i18n._({id:"b2jAb+",message:"per"})," ",null!==(m=null===(h=S.baseToken)||void 0===h?void 0:h.symbol)&&void 0!==m?m:""]})]}),G.jsx(aE,{chainId:j,currencyA:null!==(g=S.baseToken)&&void 0!==g?g:void 0,currencyB:null!==(x=S.quoteToken)&&void 0!==x?x:void 0,feeAmount:S.feeAmount,ticksAtLimit:ee,price:_?parseFloat((J?_.invert():_).toSignificant(8)):void 0,priceLower:Ce,priceUpper:je,onLeftRangeInput:re,onRightRangeInput:ae,interactive:!0})]}),G.jsxs(yv,{disabled:z||Z||H&&!L,children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"MU9s7M",message:"Deposit amounts"})}),G.jsxs(t.Box,{children:[G.jsx(kv,{value:ge[av.CURRENCY_A],onUserInput:ie,maxAmount:xe[av.CURRENCY_A],balance:U[av.CURRENCY_A],currency:null!==(f=W[av.CURRENCY_A])&&void 0!==f?f:null,locked:Y}),G.jsx(cy,{}),G.jsx(kv,{value:ge[av.CURRENCY_B],onUserInput:oe,maxAmount:xe[av.CURRENCY_B],balance:U[av.CURRENCY_B],currency:null!==(y=W[av.CURRENCY_B])&&void 0!==y?y:null,locked:K})]}),G.jsx(iv,{value:le,onChange:de,disabled:!1,type:"AMMV3"})]})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",py:16,[w.breakpoints.up("tablet")]:{px:20,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:w.palette.background.paper}},children:G.jsx(vv,{chainId:j,approvalA:fe,approvalB:ye,parsedAmounts:F,isValid:pe,depositADisabled:Y,depositBDisabled:K,errorMessage:$,setShowConfirm:me})}),G.jsx(pj,{parsedAmounts:F,position:V,existingPosition:void 0,priceLower:Ce,priceUpper:je,outOfRange:Q,ticksAtLimit:ee,on:he,onClose:()=>{me(!1)},onConfirm:Ee.mutate,loading:Ee.isPending})]})]})}const fE=["#154618","#ED4A25","#0E794D","#F7A33E","#582969","#DFCC28","#294369","#1D1D1D"],yE=({poolDetail:e,tokenBalances:i})=>{const o=t.useTheme(),r=n.useMemo((()=>{if(!e)return[];if(!i)return[];const t=i.reduce(((e,t)=>e.plus(t)),new a.BigNumber(0));return e.coins.map(((e,n)=>({name:e.name,symbol:e.symbol,address:e.address,chainId:e.chainId,decimals:e.decimals,value:i[n].toNumber(),percentage:i[n].div(t).toNumber(),color:fE[n]})))}),[e,i]);return G.jsxs(t.Box,{sx:{mt:16,display:"flex",flexDirection:"column",alignItems:"stretch",gap:28,p:20,backgroundColor:o.palette.background.paper,borderRadius:16,[o.breakpoints.up("tablet")]:{flexDirection:"row",alignItems:"center",border:`1px solid ${o.palette.border.main}`,p:0,gap:0}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",[o.breakpoints.up("tablet")]:{minWidth:364,flexDirection:"column",gap:16}},children:[G.jsx(S.PieChart,{width:88,height:88,children:G.jsx(S.Pie,{isAnimationActive:!1,dataKey:"value",data:r,labelLine:!1,label:!1,outerRadius:44,children:r.map(((e,t)=>G.jsx(S.Cell,{fill:e.color,strokeWidth:0},`cell-${t}`)))})}),G.jsx(t.Box,{sx:{display:"none",[o.breakpoints.up("tablet")]:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:16,maxWidth:172}},children:r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),G.jsx(t.Box,{sx:{typography:"h6",color:o.palette.text.primary},children:e.symbol})]},e.address)))})]}),G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:16,[o.breakpoints.up("tablet")]:{display:"none"}},children:r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:e.symbol}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsxs(t.Box,{sx:{ml:"auto",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right"},children:Au({input:e.value,decimals:e.decimals})}),G.jsxs(t.Box,{sx:{typography:"h6",color:o.palette.text.secondary,textAlign:"right"},children:["(",Vu({input:new a.BigNumber(e.percentage),showDecimals:2}),")"]})]})]},e.address)))}),G.jsxs(t.Box,{sx:{display:"none",[o.breakpoints.up("tablet")]:{flexGrow:1,display:"block",borderLeft:`1px solid ${o.palette.border.main}`}},children:[G.jsxs(t.Box,{sx:{borderBottom:`1px solid ${o.palette.border.main}`,typography:"h6",fontWeight:600,color:o.palette.text.secondary,height:48,display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:"Asset"}),G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"Token Amount"}),G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"ratio"})]}),r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",height:56},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:[G.jsx(Nh,{address:e.address,width:24,height:24,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:e.symbol}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]})]}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Au({input:e.value,decimals:e.decimals})}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Vu({input:new a.BigNumber(e.percentage),showDecimals:2})})]},e.address)))]})]})};function vE(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function bE({chainId:i,address:o}){var a;const{isMobile:s}=Bp(),l=t.useTheme(),c=function({chainId:e,address:t}){var n,i;const o=xp().getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolSwapInfo,{where:{chainId:null!=e?e:r.ChainId.ZETACHAIN,poolAddress:null!=t?t:""}}),a=d.useQuery(Object.assign(Object.assign({},o),{enabled:!!t&&!!e})),s=null===(i=null===(n=a.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolSwapInfo)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},a),{swapList:s})}({address:o,chainId:i}),[u,p]=n.useState(1),h=u*(s?4:8),m=null!==(a=c.swapList)&&void 0!==a?a:[],g=h<m.length,x=m.slice(0,h);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:c.error?c.refetch:void 0,loading:c.isLoading,empty:!(null==x?void 0:x.length),children:!!(null==x?void 0:x.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"UPXmW+",message:"Trader"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"v4nCHK",message:"Paid"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"fZ5Vnu",message:"Received"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==x?void 0:x.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:vE(1e3*e.time)}),G.jsx("td",{children:G.jsx(zf,{address:e.user,truncate:!0})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.paidToken.id,chainId:i,width:24,height:24,noBorder:!0,noShowChain:!0}),`${Au({input:e.paidAmount,decimals:e.paidToken.decimals})} ${e.paidToken.symbol}`]})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.receivedToken.id,chainId:i,width:18,height:18,noBorder:!0,noShowChain:!0}),`${Au({input:e.receivedAmount,decimals:e.receivedToken.decimals})} ${e.receivedToken.symbol}`]})})]},e.id)))})]})}),g&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>p((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}const CE=({chainId:i,address:o})=>{var a,s;const{isMobile:l}=Bp(),c=t.useTheme(),u=function({chainId:e,address:t}){var n,i;const o=xp(),a=d.useQuery(Object.assign(Object.assign({},o.getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolLiquidityHistory,{where:{chainId:null!=e?e:r.ChainId.ZETACHAIN,poolAddress:null!=t?t:""}})),{enabled:!!t&&!!e}));return Object.assign(Object.assign({},a),{list:null===(i=null===(n=a.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolLiquidityHistory)||void 0===i?void 0:i.liquidityHistories})}({address:o,chainId:i}),[p,h]=n.useState(1),m=p*(l?4:8),g=u.list,x=m<(null!==(a=null==g?void 0:g.length)&&void 0!==a?a:0),f=null!==(s=null==g?void 0:g.slice(0,m))&&void 0!==s?s:[];return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:u.error?u.refetch:void 0,loading:u.isLoading&&!(null==f?void 0:f.length),empty:!(null==f?void 0:f.length),children:!!(null==f?void 0:f.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"bwRvnp",message:"Action"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"GX8GKD",message:"Assets"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==f?void 0:f.map((e=>{var o;return G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:vE(1e3*e.time)}),G.jsx("td",{children:e.action}),G.jsx("td",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:null===(o=e.assets)||void 0===o?void 0:o.map(((e,o)=>G.jsxs(n.Fragment,{children:[o>0&&G.jsx(t.Box,{sx:{width:"1px",height:"16px",backgroundColor:c.palette.border.main,margin:"0 8px"}}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsx(Nh,{address:e.token.address,chainId:i,width:24,height:24,noBorder:!0,noShowChain:!0,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body2"},children:[Au({input:e.amount,decimals:e.token.decimals})," ",e.token.symbol]})]})]},e.token.address)))})})]},e.id)}))})]})}),x&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:c.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>h((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})},jE=({title:e,children:n,tip:i,sx:o})=>G.jsxs(t.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,py:8},o),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary"},children:e}),i&&G.jsx(lf,{title:i})]}),G.jsx(t.Box,{sx:{typography:"body1",color:"text.primary"},children:n})]}),wE=({poolDetail:e})=>{var n;return G.jsxs(t.Box,{sx:{mt:10,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(jE,{title:"Daily USD volume",children:(null==e?void 0:e.dailyVolumeUsd)?`$${qu(new a((null==e?void 0:e.dailyVolumeUsd)||"0"))}`:"-"}),G.jsx(jE,{title:"Liquidity utilization",tip:"24h Volume/Liquidity ratio",children:(null==e?void 0:e.liquidityUtilization)?`${Vu({input:new a((null==e?void 0:e.liquidityUtilization)||"0"),showDecimals:2})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(jE,{title:"Fee",children:(null==e?void 0:e.fee)?`${Vu({input:new a((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}`:"-"}),G.jsx(jE,{title:"DAO fee",children:(null==e?void 0:e.daoFee)?`${Vu({input:new a((null==e?void 0:e.daoFee)||"0"),showDecimals:2})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(jE,{title:"Virtual price",tip:"Measures pool growth; this is not a dollar value",children:(null==e?void 0:e.virtualPrice)?`${Au({input:new a((null==e?void 0:e.virtualPrice)||"0").div(1e18),decimals:18})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(jE,{title:"Pool/Token",children:(null==e?void 0:e.address)?G.jsx(zf,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body1",color:"text.primary"}}):"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(jE,{title:"Pool Type",children:"plain"===(null==e?void 0:e.poolType)?"Stableswap-NG":"meta"===(null==e?void 0:e.poolType)?"Plain pool":"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(jE,{title:"Coins",sx:{alignItems:"flex-start"},children:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:e?e.coins.map((n=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{address:n.address,width:16,height:16,chainId:null==e?void 0:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:500,color:"text.primary"},children:[n.symbol,"(Standard)"]})]},n.address))):"-"})}),G.jsx(jE,{title:"Pool Parameters:",sx:{alignItems:"flex-start"},children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body1",color:"text.primary"},children:["A:",null!==(n=null==e?void 0:e.a)&&void 0!==n?n:"-"]}),G.jsx(lf,{title:"Amplification coefficient chosen from fluctuation of prices around 1."})]}),G.jsxs(t.Box,{sx:{typography:"body1",color:"text.primary"},children:["Off Peg Multiplier:",(null==e?void 0:e.offpegFeeMultiplier)?new a(null==e?void 0:e.offpegFeeMultiplier).div(1e10).toString():"-"]})]})})]})},kE=({poolDetail:e})=>{var n;const i=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,[i.breakpoints.up("tablet")]:{py:20,flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:`1px solid ${i.palette.border.main}`}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[e?G.jsx(Yj,{pool:e,separate:!1,wrap:!0}):G.jsx(t.Skeleton,{width:72,height:52,sx:{borderRadius:8}}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h4",fontWeight:600},children:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:"-"}),(null==e?void 0:e.address)&&G.jsx(zf,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body2",color:"text.secondary"}})]})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"row",alignItems:"flex-end",gap:4,[i.breakpoints.up("tablet")]:{flexDirection:"column",gap:0}},children:[G.jsx(Gj,{apy:null==e?void 0:e.apy,dailyApy:null==e?void 0:e.dailyApy,weeklyApy:null==e?void 0:e.weeklyApy,sx:{typography:"h4",[i.breakpoints.up("tablet")]:{typography:"h4"}}}),G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary"},children:"APY"})]})]})},TE=({poolDetail:e})=>{const n=t.useTheme(),i=[{title:"Trader",value:qu(new a((null==e?void 0:e.traderCount)||"0"))},{title:"Total Liquidity",value:`$${qu(new a((null==e?void 0:e.tvl)||"0"))}`},{title:"Volume",value:`$${qu(new a((null==e?void 0:e.volume)||"0"))}`},{title:"Fees",value:Vu({input:new a((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}];return G.jsx(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gridTemplateRows:"repeat(2, 1fr)",gap:12,[n.breakpoints.up("tablet")]:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(1, 1fr)"}},children:i.map(((i,o)=>e?G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,borderRadius:8,backgroundColor:n.palette.background.paper,[n.breakpoints.up("tablet")]:{border:`1px solid ${n.palette.border.main}`}},children:[G.jsx(t.Box,{sx:{typography:"caption",color:n.palette.text.primary},children:i.value}),G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.text.secondary},children:i.title})]},o):G.jsx(t.Skeleton,{width:"100%",height:77,sx:{borderRadius:8}},o)))})};const BE=({params:i})=>{const o=zy(),{isMobile:a}=Bp(),{account:s}=cp(),l=t.useTheme(),{poolDetail:c,isLoading:u,error:p}=function({address:e,chainId:t}){const i=xp(),o=n.useCallback((e=>{var n,i,o,a,s,l,d,c,u,p,h,m;const g=null==e?void 0:e.curve_stableswap_ng_getPoolInfo;if(!g)return;const x=((null===(n=g.coins)||void 0===n?void 0:n.map((e=>({chainId:null!=t?t:r.ChainId.ZETACHAIN,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex));return{chainId:null!=t?t:r.ChainId.ZETACHAIN,name:g.name||"",address:g.address||g.id||"",symbol:g.symbol,decimals:g.decimals,fee:(null===(i=g.fee)||void 0===i?void 0:i.toString())||"0",coins:x,apy:(null===(o=g.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(a=g.tvl)||void 0===a?void 0:a.toString())||null,volume:(null===(s=g.volume)||void 0===s?void 0:s.toString())||null,dailyVolumeUsd:(null===(l=g.dailyVolumeUsd)||void 0===l?void 0:l.toString())||null,traderCount:(null===(d=g.traderCount)||void 0===d?void 0:d.toString())||null,lpTokenBalance:null,liquidityUtilization:(null===(c=g.liquidityUtilization)||void 0===c?void 0:c.toString())||null,daoFee:(null===(u=g.daoFee)||void 0===u?void 0:u.toString())||null,virtualPrice:(null===(p=g.virtualPrice)||void 0===p?void 0:p.toString())||null,poolType:g.poolType||"plain",a:(null===(h=g.a)||void 0===h?void 0:h.toString())||null,offpegFeeMultiplier:(null===(m=g.offpegFeeMultiplier)||void 0===m?void 0:m.toString())||null}}),[t]),{data:a,isLoading:s,error:l}=d.useQuery(Object.assign(Object.assign({},i.getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolInfo,{where:{chainId:null!=t?t:r.ChainId.ZETACHAIN,poolAddress:null!=e?e:""}})),{enabled:!!e&&!!t,select:o}));return{poolDetail:a,isLoading:s,error:l}}({address:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{tokenBalances:h}=aw({pool:c,account:s}),[m,g]=n.useState(null),[x,f]=n.useState("parameters");n.useEffect((()=>{a||c&&g({pool:c,type:Qj.Add})}),[c,a]);const y=n.useMemo((()=>[{key:"parameters",value:"Parameters"},{key:"swaps",value:"Swaps"},{key:"liquidity",value:"Liquidity"}]),[]);return G.jsxs(Wy,{sx:a?{p:l.spacing(28,0,108)}:{p:l.spacing(28,0,40)},children:[G.jsxs(t.Box,{sx:{[l.breakpoints.up("tablet")]:{display:"flex",gap:12,overflow:"hidden"}},children:[G.jsxs(t.Box,{sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",gap:24,[l.breakpoints.up("tablet")]:{gap:28}},children:[G.jsx(VS,{onClick:()=>{o.push({type:exports.PageType.Pool})}}),G.jsx(kE,{poolDetail:c}),G.jsx(TE,{poolDetail:c}),c&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",color:l.palette.text.primary},children:"Currency reserves"}),G.jsx(yE,{poolDetail:c,tokenBalances:h})]}),G.jsx(t.Box,{sx:{backgroundColor:l.palette.background.paper,borderRadius:16,overflow:"hidden",px:16,pb:16,[l.breakpoints.up("tablet")]:{px:20,pb:20}},children:G.jsxs(t.Tabs,{value:x,onChange:(e,t)=>f(t),children:[G.jsx(t.TabsGroup,{tabs:y}),G.jsx(t.TabPanel,{value:"parameters",children:G.jsx(wE,{poolDetail:c})}),G.jsx(t.TabPanel,{value:"swaps",children:G.jsx(bE,{chainId:null==i?void 0:i.chainId,address:null==i?void 0:i.address})}),G.jsx(t.TabPanel,{value:"liquidity",children:G.jsx(CE,{chainId:null==i?void 0:i.chainId,address:null==i?void 0:i.address})})]})})]}),G.jsx(t.Box,{sx:{position:"relative",width:a?"100%":375},children:m?G.jsx(uw,{poolDetailBtnVisible:!1,operateCurvePool:m,setOperateCurvePool:a?g:void 0}):a?null:G.jsx(t.Skeleton,{width:375,height:403,sx:{borderRadius:16}})})]}),a&&G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,disabled:!c,onClick:()=>{c&&g({pool:c,type:Qj.Remove})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{disabled:!c,onClick:()=>{c&&g({pool:c,type:Qj.Add})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})})]})};exports.AMMV2Create=SA,exports.AMMV3PositionManage=Nj,exports.AMMV3PositionsView=Uj,exports.AddLiquidityV3=xE,exports.CurvePoolDetail=BE,exports.EmptyList=ee,exports.FailedList=re,exports.Message=Zx,exports.Pool=function(){const{routerPage:e}=X(),t=zy((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case exports.PageType.Pool:return G.jsx(Yk,{params:n.params});case exports.PageType.CreatePool:return G.jsx(US,{});case exports.PageType.ModifyPool:return G.jsx(GS,{params:n.params});case exports.PageType.PoolDetail:return G.jsx(bA,{params:n.params});case exports.PageType.CurvePoolDetail:return G.jsx(BE,{params:n.params});case exports.PageType.createPoolAMMV2:return G.jsx(SA,{});case exports.PageType.createPoolAMMV3:return G.jsx(xE,{params:n.params,handleGoBack:()=>{zy.getState().push({type:exports.PageType.Pool})},handleGoToPoolList:()=>{zy.getState().push({type:exports.PageType.Pool})}});default:return G.jsx(Yk,{params:null==n?void 0:n.params})}},exports.PoolCreate=US,exports.PoolDetail=bA,exports.PoolList=Yk,exports.PoolModify=GS,exports.PoolOperate=uk,exports.PoolOperateDialog=pk,exports.Swap=function({getAutoSlippage:s,onPayTokenChange:l,onReceiveTokenChange:c}={}){var u,p,m,g,x,f;const y=t.useTheme(),{isInflight:v}=qp(),{noPowerBy:b,onlyChainId:C}=X(),{isMobile:j}=Bp(),{open:w,disconnect:k,suiConnectModalOpen:T,setSuiConnectModalOpen:B,getAppKitAccountByChainId:I,chainId:S,appKitActiveNetwork:A}=cp(),[E,O]=n.useState(!1),[L,R]=n.useState(""),[M,P]=n.useState(""),[_,N]=n.useState(""),[D,F]=n.useState(""),[U,V]=n.useState(null),[H,W]=n.useState(null),[$,z]=n.useState(!1),[Z,Q]=n.useState(!1),[Y,K]=n.useState(!1),[J,ee]=n.useState(null),te=n.useMemo((()=>I(null==U?void 0:U.chainId)),[null==U?void 0:U.chainId,I]),ne=n.useMemo((()=>{const e=I(null==H?void 0:H.chainId);if(e)return J?Object.assign(Object.assign({},e),{appKitAccount:Object.assign(Object.assign({},e.appKitAccount),{isConnected:!0,address:J})}):e}),[I,null==H?void 0:H.chainId,J]),ie=n.useMemo((()=>i.debounce((e=>N(e)),300)),[]),oe=n.useMemo((()=>i.debounce((e=>F(e)),300)),[]),re=n.useMemo((()=>{if(U&&H)return!(!(null==U?void 0:U.chainId)||!(null==H?void 0:H.chainId)||U.chainId===H.chainId)}),[U,H]),{toFiatPrice:ae,fromFiatPrice:le}=Wp({toToken:H,fromToken:U}),{marginAmount:de}=function({token:e,fiatPrice:t}){return{marginAmount:n.useMemo((()=>{var n;const i=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,o=null!=t?new a(500).div(t):new a(0),r=Ru(o,i);return(r.lt(new a(1).times(new a(10).pow(i-3)))?new a(0):r).toString(10)}),[null==e?void 0:e.decimals,t])}}({token:E?H:U,fiatPrice:E?ae:le});Tp({fromToken:U,toToken:H,getAutoSlippage:s});const{slippage:ce,slippageLoading:ue}=nh({fromToken:U,toToken:H}),{slippage:pe}=function(){const{defaultSlippage:e}=Xp(!0);return{slippage:yp((t=>t.slippage||e))}}(),{privacySwapSupplierEndpoints:he,privacySwapEnable:me,privacySwapEnableAble:ge,endpointStatusMap:xe,refetchEndpointStatus:fe}=th({chainId:null==U?void 0:U.chainId,account:null==te?void 0:te.appKitAccount.address}),ye=function(e){var t,n;const{getAppKitAccountByChainId:i}=cp(),{latestBlockNumber:o}=yp(),a=id.getFetchTokenQuery(e&&(null===(t=ac.get(e))||void 0===t?void 0:t.isEVMChain)?e:void 0,e?r.basicTokenMap[e].address:void 0,null===(n=i(e))||void 0===n?void 0:n.appKitAccount.address);return d.useQuery(Object.assign(Object.assign({},a),{queryKey:[...a.queryKey,o]}))}(null==U?void 0:U.chainId),{sendRouteLoading:ve,sendRouteError:be,setSendRouteError:Ce,bridgeOrderTxRequest:je,handleClickSend:we}=function(){const e=xp(),{evmProvider:t}=cp(),[i,a]=n.useState(),[s,l]=n.useState(!1),[d,c]=n.useState(""),u=n.useCallback((n=>q(this,[n],void 0,(function*({selectedRoute:n,fromEtherTokenBalance:i,goNext:s}){var d,u;if(!n)return;const{encodeParams:p}=n;if(p&&p.interfaceParams){c(""),l(!0);try{const h=yield e.getData(r.SwapApi.graphql.cross_chain_swap_zetachain_transactionEncode.toString(),{data:{interfaceParams:p.interfaceParams}});if(!h||!h.cross_chain_swap_zetachain_transactionEncode)throw new Error("cross_chain_swap_transactionEncode is null");const{data:m,to:g,value:x,from:f,chainId:y}=h.cross_chain_swap_zetachain_transactionEncode;if(!(m&&g&&x&&f&&y))throw new Error("cross_chain_swap_transactionEncode is null");const v=ac.get(y);if(null==v?void 0:v.isEVMChain){if(!i)throw new Error("fromEtherTokenBalance is null");const{fromToken:e,fromAmount:a}=n,s=r.basicTokenMap[y],p=Mu(x,18),h=s&&e.address.toLowerCase()===s.address.toLowerCase(),v=p.minus(h?a:0);if(!p.isNaN()&&p.gt(0)&&i.lt(p))return c(o.i18n._({id:"F9xwHA",message:"Insufficient cross-chain fees, need at least {0} {1}",values:{0:Au({input:v,decimals:null!==(d=null==s?void 0:s.decimals)&&void 0!==d?d:18}),1:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}})),void l(!1);if(!t||!(yield pp({from:f,to:g,value:x,data:m},t)))throw new Error("failed to estimate gas")}a({data:m,to:g,value:x,from:f,chainId:y}),s()}catch(e){console.error("[failed to construct transaction request]: ",e);const{message:t}=e;c(t)}l(!1)}}))),[e,t]);return{sendRouteLoading:s,sendRouteError:d,setSendRouteError:c,bridgeOrderTxRequest:i,handleClickSend:u}}(),{bridgeRouteList:ke,status:Te,failedReason:Be}=function({fromAccount:e,toAccount:t,fromToken:i,toToken:o,fromAmount:r,enabled:s,slippage:l}){var c,u,p,h;const{tokenList:m}=Tc(),{GRAPHQL_URL:g}=X(),x=n.useMemo((()=>i&&r?new a(r).multipliedBy(new a(10).pow(i.decimals)).dp(0,a.ROUND_DOWN):null),[r,i]),f=null!==(u=null===(c=null==e?void 0:e.appKitAccount)||void 0===c?void 0:c.address)&&void 0!==u?u:rc(null==i?void 0:i.chainId),y=null!==(h=null===(p=null==t?void 0:t.appKitAccount)||void 0===p?void 0:p.address)&&void 0!==h?h:rc(null==o?void 0:o.chainId),{data:v,error:b,isLoading:C,refetch:j}=d.useQuery({retry:!1,queryKey:["graphql","cross_chain_swap_zetachain_routes",null==i?void 0:i.chainId,null==i?void 0:i.address,null==o?void 0:o.chainId,null==o?void 0:o.address,f,y,null==x?void 0:x.toString(),l],queryFn:()=>q(this,void 0,void 0,(function*(){const e=yield fetch(`${g}?opname=Cross_chain_swap_zetachain_routes`,{headers:{"content-type":"application/json"},body:`{"query":"\\n query Cross_chain_swap_zetachain_routes($where: Cross_chain_swap_zetachainrouteParams) {\\n cross_chain_swap_zetachain_routes(where: $where) {\\n routeId\\n fromChainId\\n fromTokenAddress\\n fromAmount\\n fromAmountWithOutDecimals\\n fromAmountUSD\\n toChainId\\n toTokenAddress\\n toAmount\\n toAmountWithOutDecimals\\n toAmountUSD\\n fromAddress\\n toAddress\\n slippage\\n approveTarget\\n fees\\n omniPlan\\n encodeParams\\n }\\n}\\n ","variables":{"where":{"fromChainId":${null==i?void 0:i.chainId},"fromTokenAddress":"${null==i?void 0:i.address}","toChainId":${null==o?void 0:o.chainId},"toTokenAddress":"${null==o?void 0:o.address}","fromAddress":"${f}","toAddress":"${y}","fromAmount":"${null==x?void 0:x.toString()}","slippage":${l?Number(l)/100:null}}},"operationName":"Cross_chain_swap_zetachain_routes"}`,method:"POST"}),t=yield e.json();if(t.errors)throw new Error(t.errors[0].message);return t.data})),refetchInterval:15e3,enabled:!!i&&!!o&&!!x&&x.isFinite()&&x.gt(0)&&i.chainId!==o.chainId&&s}),{status:w,failedReason:k,bridgeRouteList:T}=n.useMemo((()=>{if(C)return{status:Sc.Loading,bridgeRouteList:[]};if(b){let e;if(console.error("error:",b),b.message.includes("NOT_ROUTE_MIN_AMOUNT:min-")){const t=b.message.split("min-")[1];t&&(e=`(Enter min amount: ${t})`)}return{status:Sc.Failed,failedReason:e,bridgeRouteList:[]}}if(v&&v.cross_chain_swap_zetachain_routes){const e=[],{routeId:t,fromChainId:n,fromTokenAddress:i,fromAmount:o,fromAmountWithOutDecimals:r,fromAmountUSD:s,toChainId:l,toTokenAddress:d,toAmount:c,fromAddress:u,toAddress:p,slippage:h,approveTarget:g,fees:x,omniPlan:f,encodeParams:y}=v.cross_chain_swap_zetachain_routes,b=ac.get(n);if(t&&n&&i&&r&&l&&d&&c&&u&&p&&h&&(!(null==b?void 0:b.isEVMChain)||g)&&x&&f&&f.length>0&&y){const o=m.find((e=>e.address.toLowerCase()===i.toLowerCase()&&e.chainId===n)),s=m.find((e=>e.address.toLowerCase()===d.toLowerCase()&&e.chainId===l)),b=new a(c);if(o&&s&&b.isFinite()&&b.gt(0)){const i=Ic({omniPlan:f,tokenList:m});if(i.includedSteps.length>0){const d=x.reduce(((e,t)=>{var n;return e.plus(null!==(n=t.amountUSD)&&void 0!==n?n:0)}),new a(0)).dp(4,a.ROUND_DOWN).toString(),c={key:t,id:t,fromChainId:n,toChainId:l,fromToken:o,toToken:s,fromAmount:r,toTokenAmount:b.div(`1e${s.decimals}`),fromAddress:u,toAddress:p,product:"zetachain",slippage:h,roundedRouteCostTime:0,spenderContractAddress:null!=g?g:null,feeUSD:d,fees:x,executionDuration:null,step:i,encodeParams:y,productParams:null,sourceRoute:v.cross_chain_swap_zetachain_routes};e.push(c)}}}return e.length>0?{status:Sc.Success,bridgeRouteList:e}:{status:Sc.Failed,bridgeRouteList:[]}}return{status:Sc.Initial,bridgeRouteList:[]}}),[C,b,v,m]);return{status:w,failedReason:k,refetch:j,bridgeRouteList:T}}({toToken:H,fromToken:U,fromAmount:_,fromAccount:te,toAccount:ne,enabled:!Y&&!ve,slippage:pe}),Ie=n.useMemo((()=>{if(ke&&ke.length>0)return ke[0]}),[ke]),{isApproving:Se,isGetApproveLoading:Ae,needApprove:Ee,insufficientBalance:Oe,submitApprove:Le,getMaxBalance:Re,tokenQuery:Me}=lh(U,{amount:_,contractAddress:null!==(u=null==Ie?void 0:Ie.spenderContractAddress)&&void 0!==u?u:void 0,account:null==te?void 0:te.appKitAccount.address}),{tokenQuery:Pe}=lh(H,{account:null==ne?void 0:ne.appKitAccount.address}),_e=n.useCallback((()=>{Ge(Re())}),[Re]),Ne=n.useMemo((()=>!(!(null==te?void 0:te.appKitAccount.address)||Oe||Se||Ae||Ee)),[null==te?void 0:te.appKitAccount.address,Oe,Se,Ae,Ee]),{status:De,rawBrief:Fe,executeSwap:Ue}=Kp({toToken:H,fromToken:U,marginAmount:de,fromAmount:_,toAmount:D,estimateGas:Ne,isReverseRouting:E,slippage:ce,slippageLoading:ue}),{resAmount:qe,priceImpact:Ve,baseFeeAmount:He,additionalFeeAmount:We,resPricePerToToken:$e,resPricePerFromToken:ze,routeInfo:Ze}=n.useMemo((()=>Fe||{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null,routeInfo:null}),[Fe]),Qe=jp(re),Ge=n.useCallback((e=>{const t=e.toString();R(t),ie(t)}),[R,ie]),Ye=n.useCallback((e=>{const t=e.toString();P(t),oe(t)}),[P,oe]),Ke=n.useCallback((e=>V((t=>{var n;const i="function"==typeof e?e(t):e;return S||yp.setState({fromTokenChainId:null!==(n=null==i?void 0:i.chainId)&&void 0!==n?n:void 0}),l&&i&&i!==t&&l(i),i}))),[l,S]),Xe=n.useCallback((e=>W((t=>{const n="function"==typeof e?e(t):e;return c&&n&&n!==t&&c(n),n}))),[c]);!function({fromToken:e,toToken:t,setFromToken:i,setToToken:o,updateFromAmt:r,updateToAmt:a,setIsReverseRouting:s}){const{tokenList:l}=Tc(),{crossChain:d,defaultFromToken:c,defaultToToken:u,onlyChainId:p}=X(),{chainId:h}=cp(),m=n.useCallback((()=>{let n,m=null;const g=d?void 0:null!=p?p:h;if(!e){const e=Jp({side:"from",defaultToken:c,tokenList:l,chainId:g});m=e.findToken,n=e.setDefaultAmount,m&&(i(m),void 0!==n&&(s(!1),r(n)))}if(!t){const{findToken:e,setDefaultAmount:t}=Jp({side:"to",defaultToken:u,tokenList:l,occupyToken:m,chainId:g});e&&(o(e),void 0===n&&void 0!==t&&(s(!0),a(t)))}}),[h,d,c,u,e,p,i,s,o,t,l,r,a]);n.useEffect((()=>{const e=setTimeout((()=>{m()}),10);return()=>clearTimeout(e)}),[m])}({fromToken:U,toToken:H,setFromToken:Ke,setToToken:Xe,updateFromAmt:Ge,updateToAmt:Ye,setIsReverseRouting:O});const Je=n.useCallback((()=>{Ge(""),Ye(""),Ke(H),Xe(U),cc("from",H),cc("to",U)}),[Ke,H,Xe,U,Ge,Ye]),et=n.useCallback(((e,t)=>{if(t)return Je();Ge(""),Ye(""),Ke(e),cc("from",e)}),[Je,Ge,Ye,Ke,cc]),tt=n.useCallback(((e,t)=>{if(t)return Je();Ge(""),Ye(""),Xe(e),cc("to",e)}),[Je,Ge,Ye,Ke,cc]),nt=n.useCallback((()=>{E&&Ge(""),O(!1)}),[E,Ge]),it=n.useCallback((()=>{E||Ye(""),O(!0)}),[E,Ye]),ot=(e=>{const{defaultSlippage:t}=Xp(void 0===e),i=yp((e=>e.slippage||t));return n.useMemo((()=>(void 0===e?Number(i):e)>5),[i,e])})(re?void 0:ce),rt=n.useMemo((()=>(100*Number(Ve)).toFixed(2)),[Ve]),at=n.useMemo((()=>{const e=E?qe:_;return e&&le?new a(le).multipliedBy(e):null}),[le,_,E,qe]),st=n.useMemo((()=>{var e;if(!ae||void 0===re)return null;if(re)return(null===(e=null==Ie?void 0:Ie.toTokenAmount)||void 0===e?void 0:e.gt(0))?Ie.toTokenAmount.multipliedBy(ae):null;const t=E?D:qe;return t?new a(ae).multipliedBy(t):null}),[ae,D,E,qe,Ie,re]),lt=n.useMemo((()=>G.jsxs(t.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[G.jsx(lf,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),G.jsxs(t.Box,{sx:{display:"flex"},children:[G.jsx(e.Trans,{id:"6+mYrD",message:"Current price impact"}),G.jsxs(t.Box,{sx:{color:y.palette.error.main,ml:4},children:[rt,"%"]})]})]})),[rt,y.palette.error.main]),dt=n.useMemo((()=>G.jsx(sy,{toToken:H,fromToken:U,priceStatus:De,pricePerToToken:$e,pricePerFromToken:ze,routeInfo:Ze})),[H,U,De,$e,ze,Ze]),ct=n.useMemo((()=>!r.ChainId[(null==U?void 0:U.chainId)||1]),[null==U?void 0:U.chainId]),ut=n.useMemo((()=>{if(!U)return!1;const e=I(U.chainId);return!!e&&(!!e.chain.isEVMChain&&(!!S&&!!(null==U?void 0:U.chainId)&&(null==U?void 0:U.chainId)!==S))}),[S,U,I]),pt=function({fromToken:e,toToken:t}){const i=Tc(Bc);return n.useMemo((()=>!(!e||i.some((t=>t.chainId===e.chainId&&t.address===e.address&&(!t.side||"to"===t.side))))||!(!t||i.some((e=>e.chainId===t.chainId&&e.address===t.address&&(!e.side||"from"===e.side))))),[e,t,i])}({fromToken:U,toToken:H}),ht=n.useMemo((()=>G.jsx(t.Tooltip,{open:Qe.showSwitchSlippage,title:re?G.jsx(e.Trans,{id:"qLkska",message:"The setting has been switched to cross chain mode"}):G.jsx(e.Trans,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",onClose:()=>Qe.setShowSwitchSlippage(!1),onlyClick:!0,children:G.jsx(t.Box,{component:t.ButtonBase,onClick:()=>Q(!0),sx:{p:4,backgroundColor:y.palette.background.paper,borderRadius:4,height:28,width:28,display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.Setting,sx:{width:20,height:20,color:"text.primary",cursor:"pointer"}})})})),[re,Qe,y.palette.background.paper]),mt=n.useMemo((()=>ot&&new a(E?D:_).gt(0)&&!Oe&&(re?Te===Yp.Success:De===Yp.Success)?G.jsxs(t.Box,{sx:{textAlign:"center",mb:8},children:[G.jsx(t.Box,{component:se.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),o.i18n._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[ot,E,D,_,Oe,re,Te,De]),gt=n.useMemo((()=>ut?G.jsxs(t.Box,{sx:{textAlign:"center"},children:[G.jsx(t.Box,{component:se.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):re&&Te===Yp.Initial?"-":De===Yp.Loading||re&&Te===Yp.Loading?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsxs(G.Fragment,{children:[G.jsx(t.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]})}):ct?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{mr:6,width:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):re&&ke.length?G.jsxs(G.Fragment,{children:[mt,G.jsx(gg,{route:Ie})]}):re&&(Te===Yp.Success&&!ke.length||Te===Yp.Failed)&&L?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}):G.jsxs(G.Fragment,{children:[!re&&L&&new a(rt).gt(mc)&<,mt,dt]})),[De,dt,L,lt,rt,ct,re,Te,ke,Ie,ut,mt]),xt=n.useMemo((()=>E?new a(M).gt(0)?Au({input:qe,decimals:null==U?void 0:U.decimals}):"-":L),[L,M,qe,U,E]),ft=n.useMemo((()=>{var e;return E?M:re?(null===(e=null==Ie?void 0:Ie.toTokenAmount)||void 0===e?void 0:e.gt(0))&&Te!==Yp.Loading?Au({input:Ie.toTokenAmount,decimals:null==H?void 0:H.decimals}):"-":new a(L).gt(0)?Au({input:qe,decimals:null==H?void 0:H.decimals}):"-"}),[L,M,qe,H,E,Ie,re,Te]),yt=n.useMemo((()=>{var n,i,o,r;if(!(null===(n=null==te?void 0:te.appKitAccount)||void 0===n?void 0:n.isConnected)){const e=`Connect to ${dp(null==U?void 0:U.chainId)} wallet`,n=G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:e});if(!(null==U?void 0:U.chainId))return n;const o=null===(i=ac.get(U.chainId))||void 0===i?void 0:i.caipNetwork;if(!o)return n;const r=lp.getChainNamespace(o);return"sui"===r?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Button,{fullWidth:!0,children:e}),open:T,onOpenChange:e=>{console.log("swap from button isOpen",e),B(e)}}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>{w({namespace:r})},children:e})}if(te.chain.isEVMChain&&te.chain.chainId!==S)return G.jsx(t.Button,{fullWidth:!0,onClick:()=>{A.switchNetwork(te.chain.caipNetwork)},children:G.jsx(e.Trans,{id:"1+P9RR",message:"Switch to {0}",values:{0:te.chain.name}})});if(te.chain.isSolanaChain&&te.chain.chainId!==S)return G.jsx(t.Button,{fullWidth:!0,onClick:()=>{A.switchNetwork(te.chain.caipNetwork)},children:G.jsx(e.Trans,{id:"1+P9RR",message:"Switch to {0}",values:{0:te.chain.name}})});if(!(null===(o=null==ne?void 0:ne.appKitAccount)||void 0===o?void 0:o.isConnected)){const e=`Connect to ${dp(null==H?void 0:H.chainId)} wallet`,n=G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:e});if(!(null==H?void 0:H.chainId))return n;const i=null===(r=ac.get(H.chainId))||void 0===r?void 0:r.caipNetwork;if(!i)return n;const o=lp.getChainNamespace(i);return"sui"===o?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Button,{fullWidth:!0,children:e}),open:T,onOpenChange:e=>{console.log("swap to button isOpen",e),B(e)}}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>{w({namespace:o})},children:e})}if(v)return G.jsx(t.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:G.jsx(e.Trans,{id:"FRBvjQ",message:"Transaction Pending"})});if(!U||!H)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:G.jsx(e.Trans,{id:"KlvBGJ",message:"Select Tokens"})});if(!new a(E?D:_).gt(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:G.jsx(e.Trans,{id:"iPMIoT",message:"Enter an amount"})});if(re?Te===Yp.Loading||Ae:De===Yp.Loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:G.jsx(e.Trans,{id:"OauUE6",message:"Fetching Price..."})});let s=!1;return s=re?!ke.length||Te===Yp.Failed:!qe||De===Yp.Failed,s?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})}):Oe?G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):Ee?G.jsx(t.Button,{fullWidth:!0,disabled:Se,onClick:()=>Le(),children:Se?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):G.jsx(e.Trans,{id:"Z7ZXbT",message:"Approve"})}):re?G.jsx(t.Button,{fullWidth:!0,onClick:()=>{var e,t;return we({selectedRoute:Ie,fromEtherTokenBalance:null!==(t=null===(e=ye.data)||void 0===e?void 0:e.balance)&&void 0!==t?t:null,goNext:()=>K(!0)})},"data-testid":bc,disabled:!Ie,isLoading:ve,children:G.jsx(e.Trans,{id:"SXnevP",message:"Review Cross Chain"})}):me?G.jsxs(t.Button,{fullWidth:!0,onClick:()=>z(!0),"data-testid":bc,children:[G.jsx(t.Tooltip,{placement:"top",onlyHover:!0,maxWidth:240,title:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:500,color:"text.primary"},children:"Privacy Swap is Enabled"}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.secondary"},children:"Your transactions on the Ethereum network will be protected from sandwich attacks."})]}),children:G.jsx(t.Box,{sx:{mr:8},children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"30",viewBox:"0 0 25 30",fill:"none",children:[G.jsx("path",{d:"M12.5 4L3.5 8V14C3.5 19.55 7.34 24.74 12.5 26C17.66 24.74 21.5 19.55 21.5 14V8L12.5 4Z",fill:"white"}),G.jsx("path",{d:"M23 14C23 20.1791 18.7457 26.0187 12.8555 27.457L12.5 27.5439L12.1445 27.457C6.25427 26.0187 2 20.1791 2 14V7.02539L2.89062 6.62891L11.8906 2.62891L12.5 2.3584L13.1094 2.62891L22.1094 6.62891L23 7.02539V14Z",stroke:"white",strokeOpacity:"0.5",strokeWidth:"3"}),G.jsx("path",{d:"M16.3937 11.3638L10.8021 16.9553L8.60457 14.7662L7.4082 15.9626L10.8021 19.3565L17.59 12.5686L16.3937 11.3638Z",fill:"#154618"})]})})}),G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})]}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>z(!0),"data-testid":bc,children:G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})})}),[null===(p=null==te?void 0:te.appKitAccount)||void 0===p?void 0:p.isConnected,null==te?void 0:te.chain.isEVMChain,null==te?void 0:te.chain.chainId,null==te?void 0:te.chain.isSolanaChain,null==te?void 0:te.chain.name,null==te?void 0:te.chain.caipNetwork,S,null===(m=null==ne?void 0:ne.appKitAccount)||void 0===m?void 0:m.isConnected,v,U,H,E,D,_,re,Te,Ae,De,Oe,Ee,me,T,B,w,A,ke.length,qe,Se,Le,Ie,ve,we,null===(g=ye.data)||void 0===g?void 0:g.balance]),vt=n.useMemo((()=>U&&H?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{token:U,width:16,height:16,marginRight:6,chainId:U.chainId,noShowChain:!!C}),`${Au({input:E?qe:_,decimals:null==U?void 0:U.decimals})} ${null==U?void 0:U.symbol}`,G.jsx(t.Box,{component:se.DoubleRight,sx:{width:12,height:12,mx:16}}),G.jsx(Nh,{token:H,width:16,height:16,marginRight:6,chainId:H.chainId,noShowChain:!!C}),`${Au({input:E?D:qe,decimals:null==H?void 0:H.decimals})} ${null==H?void 0:H.symbol}`]}):G.jsx(t.Box,{})),[U,H,_,D,qe,E,C]);return G.jsxs(t.Box,{sx:{width:"100%",overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",borderRadius:16,backgroundColor:y.palette.background.skeleton,[y.breakpoints.up("laptop")]:{width:450,backgroundColor:y.palette.background.skeleton,backdropFilter:"blur(4px)"}},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",px:16,py:20},children:[G.jsx(t.Box,{sx:{typography:"caption",color:y.palette.text.primary},children:"Universal Swap"}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",borderRadius:4,p:1,backgroundColor:y.palette.background.tag},children:[G.jsxs(t.Box,{sx:{color:y.palette.text.secondary,typography:"h6",px:6,py:4},children:[re?(null==Ie?void 0:Ie.slippage)?100*Ie.slippage:null!=pe?pe:"-":ce,"%"]}),ht]})]}),G.jsxs(t.Box,{sx:{flex:1,px:16,pb:20,overflowY:"auto"},children:[G.jsxs(t.Box,{children:[G.jsx(oy,{sx:{mb:4},token:U,side:"from",amt:xt,defaultLoadBalance:!0,onMaxClick:_e,onInputChange:Ge,onInputFocus:re?void 0:nt,showMaxBtn:!E&&!L,occupiedAddrs:[null!==(x=null==H?void 0:H.address)&&void 0!==x?x:""],occupiedChainId:null==H?void 0:H.chainId,fiatPriceTxt:at?`$${Au({input:at,decimals:2})}`:"$-",onTokenChange:et,readOnly:E,showChainLogo:!C,showChainName:!C,notTokenPickerModal:!j,enterAddressEnabled:!1,inputToAddress:J,setInputToAddress:ee,account:te,failedReason:Be,tokenQuery:Me}),G.jsx(Mf,{onClick:Je,disabled:pt}),G.jsx(oy,{token:H,side:"to",amt:ft,onInputChange:Ye,onInputFocus:re?void 0:it,occupiedAddrs:[null!==(f=null==U?void 0:U.address)&&void 0!==f?f:""],occupiedChainId:null==U?void 0:U.chainId,fiatPriceTxt:st?G.jsxs(G.Fragment,{children:["$",Au({input:st,decimals:2})]}):"$-",onTokenChange:tt,readOnly:re||!E,showChainLogo:!C,showChainName:!C,notTokenPickerModal:!j,enterAddressEnabled:re,inputToAddress:J,setInputToAddress:ee,account:ne,sx:{padding:y.spacing(24,20,20)},tokenQuery:Pe,filterBySupportTargetChain:!1}),G.jsx(t.Box,{sx:{py:16,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:gt})]}),yt,G.jsx(pf,{}),b?"":G.jsxs(t.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:y.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[G.jsx(t.Box,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:y.palette.text.disabled}},component:se.Dodo}),G.jsx(e.Trans,{id:"QIsI8+",message:"Powered by ZUNO protocol"})]})]}),G.jsx(hf,{toToken:H,fromToken:U,fromAmount:E?qe:_,toAmount:E?D:qe,open:$,baseFeeAmount:He,priceImpact:rt,additionalFeeAmount:We,curToFiatPrice:st,execute:()=>Ue(vt),clearFromAmt:()=>Ge(""),clearToAmt:()=>Ye(""),curFromFiatPrice:at,pricePerFromToken:ze,onClose:()=>z(!1),loading:De===Yp.Loading,slippage:ce,isDialogModal:j}),re?G.jsx(gf,{open:Z,onClose:()=>Q(!1),isBridge:!0,isDialogModal:j}):G.jsx(Rf,{open:Z,onClose:()=>Q(!1),fromToken:U,toToken:H,privacySwapEnableAble:ge,privacySwapEnable:me,privacySwapSupplierEndpoints:he,endpointStatusMap:xe,refetchEndpointStatus:fe,isDialogModal:j}),G.jsx(cf,{open:Y,onClose:()=>K(!1),route:Ie,bridgeOrderTxRequest:je,clearFromAmt:()=>Ge(""),clearToAmt:()=>Ye(""),isDialogModal:j}),G.jsx(uf,{message:be,onClose:()=>Ce(""),isDialogModal:j})]})},exports.SwapOrderHistory=function(){const e=t.useTheme(),{isMobile:i}=Bp(),o=n.useRef(null),a=n.useRef(null),{crossChainSubmittedCounter:s}=yp(),l=d.useQueryClient(),c=n.useRef(),u=n.useRef(l),{evmAccount:p,solanaAccount:h,bitcoinAccount:m,suiAccount:g,tonAccount:x,currentAccount:f}=cp(),[y,v]=n.useState(Dy.sameChain),[b,C]=n.useState(),j=n.useMemo((()=>[{key:Dy.sameChain,value:"Same chain Swaps"},{key:Dy.crossChain,value:"Cross Chain Swaps"},{key:Dy.errorRefunds,value:"Error Refunds"}]),[]),w=n.useMemo((()=>{var e,t,n,i,o;const r=[];if(p.isConnected&&p.address){const t=null===(e=ac.entries().find((([e,t])=>t.isEVMChain)))||void 0===e?void 0:e[1];t&&r.push({account:su(p.address),firstChain:t})}if(h.isConnected&&h.address){const e=null===(t=ac.entries().find((([e,t])=>t.isSolanaChain)))||void 0===t?void 0:t[1];e&&r.push({account:h.address,firstChain:e})}if(m.isConnected&&m.address){const e=null===(n=ac.entries().find((([e,t])=>t.isBTCChain)))||void 0===n?void 0:n[1];e&&r.push({account:m.address,firstChain:e})}if(g.isConnected&&g.address){const e=null===(i=ac.entries().find((([e,t])=>t.isSUIChain)))||void 0===i?void 0:i[1];e&&r.push({account:g.address,firstChain:e})}if(x.isConnected&&x.address){const e=null===(o=ac.entries().find((([e,t])=>t.isTONChain)))||void 0===o?void 0:o[1];e&&r.push({account:x.address,firstChain:e})}return r}),[m.address,m.isConnected,p.address,p.isConnected,h.address,h.isConnected,g.address,g.isConnected,x.address,x.isConnected]);n.useEffect((()=>{C((()=>{if(w.length>0)return w[0].account}))}),[w]);const k=n.useCallback(((e,t,n)=>{C(e),o.current&&(t?o.current.scrollTo({left:o.current.scrollWidth,behavior:"smooth"}):n&&o.current.scrollTo({left:0,behavior:"smooth"}))}),[]);return n.useEffect((()=>{const e=null==f?void 0:f.address;if(!e)return;const t=w.find((t=>t.account.toLowerCase()===e.toLowerCase()));t&&(c.current=t.account)}),[w,null==f?void 0:f.address]),n.useEffect((()=>{u.current=l}),[l]),n.useEffect((()=>{0!==s&&setTimeout((()=>{var e;null===(e=a.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"}),v(Dy.crossChain),c.current&&(C(c.current),u.current.invalidateQueries({queryKey:["graphql","getInfiniteQuery","page",r.SwapApi.graphql.cross_chain_swap_zetachain_orderList]}))}),300)}),[s]),G.jsxs(t.Tabs,{value:y,onChange:(e,t)=>{v(t)},sx:{width:"100%",display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%",borderRadius:16,backgroundColor:"background.skeleton",backdropFilter:"blur(4px)",[e.breakpoints.up("laptop")]:{}},className:i?void 0:"gradient-card-border",children:[G.jsx(t.Box,{ref:a,sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",px:16,pt:20,[e.breakpoints.up("laptop")]:{px:24}},children:G.jsx(t.TabsGroup,{tabs:j,variant:"default",tabsListSx:{justifyContent:"space-between",borderBottomWidth:0},tabSx:{mr:28,typography:"body2",lineHeight:"19px",minHeight:39,padding:"0px 0px 20px 0px",[e.breakpoints.up("laptop")]:{typography:"body1",lineHeight:"22px",minHeight:42}}})}),G.jsx(t.Box,{ref:o,sx:{px:16,py:12,display:"flex",alignItems:"center",gap:12,overflowX:"auto",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",[e.breakpoints.up("laptop")]:{px:24},"&::-webkit-scrollbar":{display:"none"},msOverflowStyle:"none",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",userSelect:"none"},children:w.map(((n,i)=>{const o=b===n.account,r=i===w.length-1,a=0===i;return G.jsxs(t.Box,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:4,pl:8,py:8,pr:10,borderRadius:4,backgroundColor:"transparent",cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.secondary",flexShrink:0},o&&{backgroundColor:t.alpha(e.palette.success.main,.1),color:"success.main"}),{"&:hover":{backgroundColor:o?t.alpha(e.palette.success.main,.1):e.palette.background.paperDarkContrast}}),onClick:()=>k(n.account,r,a),children:[n.firstChain&&G.jsx(t.Box,{component:n.firstChain.logo,sx:{width:16,height:16}}),"(",dp(n.firstChain.chainId),")",tp(n.account)]},n.account)}))}),b?G.jsxs(G.Fragment,{children:[G.jsx(Vy,{value:Dy.sameChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(qy,{account:b})}),G.jsx(Vy,{value:Dy.crossChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Py,{account:b})}),G.jsx(Vy,{value:Dy.errorRefunds,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Py,{account:b,type:"error_refund"})})]}):G.jsx(ky,{isMobile:i,empty:!0,loading:!1})]})},exports.TokenCard=py,exports.TokenLogo=Nh,exports.UnstyleWidget=sf,exports.WIDGET_CLASS_NAME=of,exports.WIDGET_MODULE_CLASS_NAME=Hy,exports.Widget=function(e){const n=t.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||Lg});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),G.jsxs(t.ThemeProvider,{theme:n,children:[G.jsx(t.CssBaseline,{container:`.${of}, .${t.WIDGET_MODAL_CLASS}, .${t.WIDGET_MODAL_FIXED_CLASS}`}),G.jsx(d.QueryClientProvider,{client:Hg,children:G.jsxs(sf,{...e,children:[e.children,G.jsx(Zx,{})]})})]})},exports.chainListMap=ac,exports.fixedInputStringToFormattedNumber=Lu,exports.formatPercentageNumber=Vu,exports.formatReadableNumber=Su,exports.formatShortNumber=Uu,exports.formatTokenAmountNumber=Au,exports.getEtherscanPage=np,exports.jsxRuntimeExports=G,exports.rpcServerMap=Ul,exports.scanUrlDomainMap=Vl,exports.useMessageState=$x,exports.usePoolBalanceInfo=gw,exports.useRouterStore=zy,exports.useTradeSwapOrderList=_y;
|
|
34
|
+
*/function cx(){if(Kg)return Yg;Kg=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Yg=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,o){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in r=Object(arguments[l]))t.call(r,d)&&(s[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(s[a[c]]=r[a[c]])}}return s},Yg}function ux(){if(Jg)return Xg;Jg=1;return Xg="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function px(){return tx?ex:(tx=1,ex=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var hx=dx();$g.exports=function(){if(rx)return ox;rx=1;var e=dx(),t=cx(),n=ux(),i=px(),o=function(){if(ix)return nx;ix=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=ux(),n={},i=px();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,r,a,s,l){if("production"!==process.env.NODE_ENV)for(var d in o)if(i(o,d)){var c;try{if("function"!=typeof o[d]){var u=Error((s||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=o[d](r,d,s,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((s||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in n)){n[c.message]=!0;var p=l?l():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},nx=o}(),r=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(r=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ox=function(s,l){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:x("array"),bigint:x("bigint"),bool:x("boolean"),func:x("function"),number:x("number"),object:x("object"),string:x("string"),symbol:x("symbol"),any:g(a),arrayOf:function(e){return g((function(t,i,o,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[i];if(!Array.isArray(s))return new m("Invalid "+r+" `"+a+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var l=0;l<s.length;l++){var d=e(s,l,o,r,a+"["+l+"]",n);if(d instanceof Error)return d}return null}))},element:g((function(e,t,n,i,o){var r=e[t];return s(r)?null:new m("Invalid "+i+" `"+o+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:g((function(t,n,i,o,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+o+" `"+r+"` of type `"+v(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")})),instanceOf:function(e){return g((function(t,n,i,o,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+o+" `"+r+"` of type `"+((s=t[n]).constructor&&s.constructor.name?s.constructor.name:u)+"` supplied to `"+i+"`, expected instance of `"+a+"`.")}var s;return null}))},node:g((function(e,t,n,i,o){return y(e[t])?null:new m("Invalid "+i+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return g((function(t,o,r,a,s){if("function"!=typeof e)return new m("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[o],d=v(l);if("object"!==d)return new m("Invalid "+a+" `"+s+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,r,a,s+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?g((function(t,n,i,o,r){for(var a=t[n],s=0;s<e.length;s++)if(h(a,e[s]))return null;var l=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+o+" `"+r+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})):("production"!==process.env.NODE_ENV&&r(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+C(o)+" at index "+t+"."),a}return g((function(t,o,r,a,s){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,o,r,a,s,n);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new m("Invalid "+a+" `"+s+"` supplied to `"+r+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")}))},shape:function(e){return g((function(t,i,o,r,a){var s=t[i],l=v(s);if("object"!==l)return new m("Invalid "+r+" `"+a+"` of type `"+l+"` supplied to `"+o+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return f(o,r,a,d,b(c));var u=c(s,d,o,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return g((function(o,r,a,s,l){var d=o[r],c=v(d);if("object"!==c)return new m("Invalid "+s+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},o[r],e);for(var p in u){var h=e[p];if(i(e,p)&&"function"!=typeof h)return f(a,s,l,p,b(h));if(!h)return new m("Invalid "+s+" `"+l+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var g=h(d,p,a,s,l+"."+p,n);if(g)return g}return null}))}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function m(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function g(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function o(o,a,s,d,c,p,h){if(d=d||u,p=p||s,h!==n){if(l){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var x=d+":"+s;!t[x]&&i<3&&(r("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[x]=!0,i++)}}return null==a[s]?o?null===a[s]?new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `null`."):new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,s,d,c,p)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function x(e){return g((function(t,n,i,o,r,a){var s=t[n];return v(s)!==e?new m("Invalid "+o+" `"+r+"` of type `"+b(s)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null}))}function f(e,t,n,i,o){return new m((e||"React class")+": "+t+" type `"+n+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function y(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(y);if(null===e||s(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e[c]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,i=t.call(e);if(t!==e.entries){for(;!(n=i.next()).done;)if(!y(n.value))return!1}else for(;!(n=i.next()).done;){var o=n.value;if(o&&!y(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function C(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return m.prototype=Error.prototype,p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p},ox}()(hx.isElement,!0)}else $g.exports=function(){if(sx)return ax;sx=1;var e=ux();function t(){}function n(){}return n.resetWarningCache=t,ax=function(){function i(t,n,i,o,r,a){if(a!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return i}i.isRequired=i;var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var mx=H($g.exports);function gx(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function xx(e,t,n,i,o){const r=e[t],a=o||t;if(null==r||"undefined"==typeof window)return null;let s;const l=r.type;return"function"!=typeof l||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(l)||(s="Did you accidentally use a plain function component for an element instead?"),void 0!==s?new Error(`Invalid ${i} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${s} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const fx=gx(mx.element,xx);fx.isRequired=gx(mx.element.isRequired,xx);const yx="exact-prop: ";function vx(e){return e&&e.ownerDocument||document}const bx="undefined"!=typeof window?D.useLayoutEffect:D.useEffect;function Cx(e){const t=D.useRef(e);return bx((()=>{t.current=e})),D.useRef(((...e)=>(0,t.current)(...e))).current}function jx(...e){return D.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{!function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(e,t)}))}),e)}const wx={};const kx=[];class Tx{static create(){return new Tx}currentId=null;start(e,t){this.clear(),this.currentId=setTimeout((()=>{this.currentId=null,t()}),e)}clear=()=>{null!==this.currentId&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Bx(){const e=function(e,t){const n=D.useRef(wx);return n.current===wx&&(n.current=e(t)),n}(Tx.create).current;var t;return t=e.disposeEffect,D.useEffect(t,kx),e}const Ix={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Sx(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Sx(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Ax(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Sx(e))&&(i&&(i+=" "),i+=t);return i}function Ex(e,t=[]){if(void 0===e)return{};const n={};return Object.keys(e).filter((n=>n.match(/^on[A-Z]/)&&"function"==typeof e[n]&&!t.includes(n))).forEach((t=>{n[t]=e[t]})),n}function Ox(e){if(void 0===e)return{};const t={};return Object.keys(e).filter((t=>!(t.match(/^on[A-Z]/)&&"function"==typeof e[t]))).forEach((n=>{t[n]=e[n]})),t}function Lx(e){const{elementType:t,externalSlotProps:n,ownerState:i,skipResolvingSlotProps:o=!1,...r}=e,a=o?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,i),{props:s,internalRef:l}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:i,externalForwardedProps:o,className:r}=e;if(!t){const e=Ax(n?.className,r,o?.className,i?.className),t={...n?.style,...o?.style,...i?.style},a={...n,...o,...i};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Ex({...o,...i}),s=Ox(i),l=Ox(o),d=t(a),c=Ax(d?.className,n?.className,r,o?.className,i?.className),u={...d?.style,...n?.style,...o?.style,...i?.style},p={...d,...n,...l,...s};return c.length>0&&(p.className=c),Object.keys(u).length>0&&(p.style=u),{props:p,internalRef:d.ref}}({...r,externalSlotProps:a}),d=function(e,t,n){return void 0===e||"string"==typeof e?t:{...t,ownerState:{...t.ownerState,...n}}}(t,{...s,ref:jx(l,a?.ref,e.additionalProps?.ref)},i);return d}function Rx(e){return e.substring(2).toLowerCase()}function Mx(e){const{children:t,disableReactTree:n=!1,mouseEvent:i="onClick",onClickAway:o,touchEvent:r="onTouchEnd"}=e,a=D.useRef(!1),s=D.useRef(null),l=D.useRef(!1),d=D.useRef(!1);D.useEffect((()=>(setTimeout((()=>{l.current=!0}),0),()=>{l.current=!1})),[]);const c=jx((u=t)&&D.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,s);var u;const p=Cx((e=>{const t=d.current;d.current=!1;const i=vx(s.current);if(!l.current||!s.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,i))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(s.current)>-1:!i.documentElement.contains(e.target)||s.current.contains(e.target),r||!n&&t||o(e)})),h=e=>n=>{d.current=!0;const i=t.props[e];i&&i(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),D.useEffect((()=>{if(!1!==r){const e=Rx(r),t=vx(s.current),n=()=>{a.current=!0};return t.addEventListener(e,p),t.addEventListener("touchmove",n),()=>{t.removeEventListener(e,p),t.removeEventListener("touchmove",n)}}}),[p,r]),!1!==i&&(m[i]=h(i)),D.useEffect((()=>{if(!1!==i){const e=Rx(i),t=vx(s.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,i]),G.jsx(D.Fragment,{children:D.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(Mx.propTypes={children:fx.isRequired,disableReactTree:mx.bool,mouseEvent:mx.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mx.func.isRequired,touchEvent:mx.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(Mx.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[yx]:t=>{const n=Object.keys(t).filter((t=>!e.hasOwnProperty(t)));return n.length>0?new Error(`The following props are not supported: ${n.map((e=>`\`${e}\``)).join(", ")}. Please remove them.`):null}}}(Mx.propTypes));const Px="base";function _x(e,t){const n=Ix[t];return n?`${Px}--${n}`:function(e,t){return`${Px}-${e}-${t}`}(e,t)}const Nx="Snackbar";function Dx(e){return _x(Nx,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=_x(e,t)}))}(Nx,["root"]);const Fx={disableDefaultClasses:!1},Ux=D.createContext(Fx);"production"!==process.env.NODE_ENV&&(Ux.displayName="ClassNameConfiguratorContext");const qx=()=>function(e,t,n){const i={};for(const o in e){const r=e[o];let a="";for(let e=0;e<r.length;e+=1){const i=r[e];i&&(a+=t(i)+" ",n&&n[i]&&(a+=n[i]+" "))}i[o]=a}return i}({root:["root"]},function(e){const{disableDefaultClasses:t}=D.useContext(Ux);return n=>t?"":e(n)}(Dx)),Vx=D.forwardRef((function(e,t){const{autoHideDuration:n=null,children:i,disableWindowBlurListener:o=!1,exited:r=!0,onBlur:a,onClose:s,onFocus:l,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...g}=e,x=qx(),{getRootProps:f,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:i,open:o,resumeHideDuration:r}=e,a=Bx();D.useEffect((()=>{if(o)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&i?.(e,"escapeKeyDown")}}),[o,i]);const s=Cx(((e,t)=>{i?.(e,t)})),l=Cx((e=>{i&&null!=e&&a.start(e,(()=>{s(null,"timeout")}))}));D.useEffect((()=>(o&&l(t),a.clear)),[o,t,l,a]);const d=a.clear,c=D.useCallback((()=>{null!=t&&l(null!=r?r:.5*t)}),[t,r,l]),u=e=>t=>{const n=e.onFocus;n?.(t),d()},p=e=>t=>{const n=e.onMouseEnter;n?.(t),d()},h=e=>t=>{const n=e.onMouseLeave;n?.(t),c()};return D.useEffect((()=>{if(!n&&o)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,o,c,d]),{getRootProps:(t={})=>{const n={...Ex(e),...Ex(t)};return{role:"presentation",...t,...n,onBlur:(i=n,e=>{const t=i.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var i},onClickAway:e=>{i?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:o,onClose:s,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",C=Lx({elementType:b,getSlotProps:f,externalForwardedProps:g,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:x.root}),j=Lx({elementType:Mx,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete j.ownerState,!u&&r?null:G.jsx(Mx,{...j,children:G.jsx(b,{...C,children:i})})}));function Hx({size:e,color:i,time:o,strokeWidth:r=2,sx:a}){const[s,l]=n.useState("0 1069"),d=e/2,c=d-1;return n.useEffect((()=>{l(2*Math.PI*c+" 0")}),[]),G.jsx(t.Box,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${r}`,left:`-${r}`,transform:"rotate(-90deg)"},a),children:G.jsx(t.Box,{component:"circle",cx:d,cy:d,r:c,strokeWidth:r,stroke:i,fill:"none",strokeDasharray:s,sx:{transition:`stroke-dasharray ${o}`}})})}"production"!==process.env.NODE_ENV&&(Vx.propTypes={autoHideDuration:mx.number,children:mx.node,disableWindowBlurListener:mx.bool,exited:mx.bool,onClose:mx.func,open:mx.bool,resumeHideDuration:mx.number,slotProps:mx.shape({clickAwayListener:mx.oneOfType([mx.func,mx.shape({children:mx.element.isRequired,disableReactTree:mx.bool,mouseEvent:mx.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mx.func,touchEvent:mx.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:mx.oneOfType([mx.func,mx.object])}),slots:mx.shape({root:mx.elementType})});var Wx=n.memo(Hx);const $x=c.create((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),zx={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function Zx(){const e=t.useTheme(),{notify:i,close:o}=$x(),[r,a]=n.useState(!0),s=n.useRef(null),l=null==i?void 0:i.timeout,d=!!i;let c=G.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),G.jsx("path",{d:"M25.1384 11.334L14.8873 21.5851L10.8584 17.5718L8.66504 19.7651L14.8873 25.9873L27.3317 13.5429L25.1384 11.334Z",fill:"#2FBA90"})]});switch(null==i?void 0:i.type){case"error":c=G.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),G.jsx("path",{d:"M25.3331 13.0452L19.8782 18.5L25.3331 23.9548L23.5148 25.7731L18.06 20.3183L12.6051 25.7731L10.7869 23.9548L16.2417 18.5L10.7869 13.0452L12.6051 11.2269L18.06 16.6817L23.5148 11.2269L25.3331 13.0452Z",fill:"#FF6187"})]});break;case"warning":c=G.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.4065 3.6189L9.62438 3.59576L3.39812 9.78928L3.37498 18.5714L9.5685 24.7976L18.3506 24.8208L24.5769 18.6273L24.6 9.84516L18.4065 3.6189ZM26.9359 8.88481L19.3791 1.28812L8.66403 1.25988L1.06734 8.81663L1.0391 19.5317L8.59585 27.1284L19.311 27.1567L26.9076 19.5999L26.9359 8.88481Z",fill:"#B15600"}),G.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),G.jsx("path",{d:"M13.9998 21.6395C14.8896 21.6395 15.6109 20.9181 15.6109 20.0283C15.6109 19.1386 14.8896 18.4172 13.9998 18.4172C13.11 18.4172 12.3887 19.1386 12.3887 20.0283C12.3887 20.9181 13.11 21.6395 13.9998 21.6395Z",fill:"#B15600"})]})}return G.jsx(t.Box,{component:Vx,open:d,autoHideDuration:l,onClose:(e,t)=>{"clickaway"!==t&&o()},exited:r,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:G.jsx(I.Transition,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{a(!1)},onExited:()=>{a(!0)},nodeRef:s,children:n=>G.jsxs(t.Box,{ref:s,sx:{display:"flex",justifyContent:"space-between",p:12,borderRadius:8,backgroundColor:"background.paper",color:"text.primary",border:"solid 1px",borderColor:"border.main",boxShadow:"0px 6px 12px 0px rgba(0, 0, 0, 0.10)",transform:zx[n],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:i?c:""}),G.jsxs(t.Box,{sx:{ml:20},children:[G.jsx(t.Box,{sx:{typography:"caption"},children:null==i?void 0:i.message}),(null==i?void 0:i.link)?G.jsxs(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:i.link.outerLink,sx:{display:"inline-flex",alignItems:"center",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},children:[i.link.text,G.jsx(t.Box,{component:"svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{ml:4,width:18,height:18},children:G.jsx("path",{d:"M4.22703 13.2122L10.6811 6.75812L4.75206 6.75812L4.75736 5.25729H13.2426V13.7426H11.7471L11.7418 7.81878L5.28769 14.2729L4.22703 13.2122Z",fill:"currentColor"})})]}):"",(null==i?void 0:i.content)?G.jsx(t.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:i.content}):""]})]}),G.jsxs(t.Box,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:l?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:l?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:o,children:[l?G.jsx(Wx,{size:24,strokeWidth:"2.4px",time:`${l}ms`,color:e.palette.text.disabled}):"",G.jsx(t.Box,{component:"svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:16,height:16,border:"none",color:e.palette.text.disabled},children:G.jsx("g",{children:G.jsx("path",{d:"M12.8897 4.36345L9.25313 8L12.8897 11.6365L11.6775 12.8487L8.04095 9.21218L4.4044 12.8487L3.19221 11.6365L6.82876 8L3.19221 4.36345L4.4044 3.15127L8.04095 6.78782L11.6775 3.15127L12.8897 4.36345Z",fill:"currentColor"})})})]})]})})})}var Qx;function Gx(){return Gx=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Gx.apply(null,arguments)}const Yx=e=>D.createElement("svg",Gx({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Qx||(Qx=D.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},D.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},D.createElement("g",{transform:"translate(18.000000, 291.000000)"},D.createElement("g",{transform:"translate(40.000000, 83.000000)"},D.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),Kx=6;function Xx(){var e;const n=t.useTheme();return G.jsx(t.Box,{sx:{mx:"auto",border:`${Kx}px solid ${null===(e=n.palette)||void 0===e?void 0:e.background.input}`,borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:G.jsx(t.Box,{component:Yx,sx:{position:"absolute",top:`-${Kx}px`,right:`-${Kx}px`,color:"primary.main"}})})}function Jx({showingDone:e,errorMessage:n}){return t.useTheme(),n?G.jsx(t.Box,{component:se.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?G.jsx(t.Box,{component:se.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):G.jsx(Xx,{})}function ef({showingDone:e,showing:n}){return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[G.jsx(t.Box,{sx:{mt:60},children:e?(null==n?void 0:n.brief)===Bg?o.i18n._({id:"EcVqOR",message:"{0} Submitted",values:{0:null==n?void 0:n.brief}}):o.i18n._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==n?void 0:n.brief}}):o.i18n._({id:"/nzjSF",message:"{0} pending",values:{0:null==n?void 0:n.brief}})}),(null==n?void 0:n.subtitle)?G.jsx(t.Box,{sx:{mt:20,typography:"body2"},children:null==n?void 0:n.subtitle}):""]})}function tf({isStarted:i,isEnded:o,tx:r,currentRequestChainId:a}){const[s,l]=n.useState(0),{chainId:d}=cp(),c=n.useMemo((()=>np(a||d||1,r,"tx")),[a,d,r]),u=n.useMemo((()=>{const e=Math.floor(s/60),t=s%60;return e?`${e}m ${t}s`:`${t}s`}),[s]),p=n.useRef();return n.useEffect((()=>(i&&(l(0),window.clearInterval(p.current),p.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(p.current)})),[i]),n.useEffect((()=>{o&&window.clearInterval(p.current)}),[o]),G.jsxs(t.Box,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"+Jkdiu",message:"Transaction Time:"}),u]}),G.jsxs(t.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:c,target:"_blank",rel:"noopener noreferrer",children:[G.jsx(e.Trans,{id:"S3piC2",message:"Tx"}),G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function nf(n){var i,r,{children:a,executionStatus:s,showSubmitLoadingDialog:l}=n;const d=_p(U(n,["children","executionStatus","showSubmitLoadingDialog"])),{ctxVal:c,showing:u,closeShowing:p,setShowing:h,showingDone:m,errorMessage:g,transactionTx:x,requests:f}=Object.assign(Object.assign({},d),s),{isMobile:y}=Bp(),{noSubmissionDialog:v,submissionDialogModal:b}=X(),C=()=>{h((e=>{if(!e)return e;const t=Object.assign({},e);return delete t.submitState,t}))},j=m&&(null==u?void 0:u.brief)===Bg&&!g,w=null===(r=null===(i=null==f?void 0:f.get(x))||void 0===i?void 0:i[0].metadata)||void 0===r?void 0:r.chainId;return G.jsxs(Fp.Provider,{value:c,children:[a,l&&G.jsx(Eh,{modal:!0,open:!!(null==u?void 0:u.submitState),onClose:C,children:!!u&&G.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",gap:20,p:20,minHeight:208,width:y?"100%":340,textAlign:"center"},children:[G.jsxs(t.Box,{sx:{textAlign:"center",color:"text.secondary"},children:[u.brief,G.jsx(t.Box,{component:se.Error,sx:{position:"absolute",top:20,right:20,color:"text.secondary",cursor:"pointer"},onClick:C})]}),"submitted"===u.submitState?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.ArrowSubmit,sx:{width:64,height:64}}),G.jsxs("div",{children:[G.jsx("div",{children:o.i18n._({id:"EcVqOR",message:"{0} Submitted",values:{0:u.brief}})}),u.subtitle&&G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]}),G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,onClick:C,sx:{mt:4},children:G.jsx(e.Trans,{id:"zga9sT",message:"OK"})})]}):G.jsxs(G.Fragment,{children:[G.jsx(Xx,{}),G.jsxs("div",{children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"7y/8M6",message:"Please confirm in wallet"})}),u.subtitle&&G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]})]})]})}),G.jsx(Eh,{open:!!u&&"loading"!==u.submitState&&!v,onClose:p,id:"submission",modal:!!y||b,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",px:20,pb:20,flex:1,overflowY:"auto",width:y?void 0:b?340:void 0},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{textAlign:"center",pt:60},children:G.jsx(Jx,{showingDone:m,errorMessage:g})}),g?G.jsxs(t.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(t.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:g})]}):G.jsxs(G.Fragment,{children:[G.jsx(ef,{showingDone:m,showing:u}),G.jsx(tf,{isStarted:!!u,isEnded:m,tx:x,currentRequestChainId:w})]})]}),j&&G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,size:t.Button.Size.big,onClick:()=>{vp(fp.Initial),p(),yp.setState({crossChainSubmittedCounter:1}),setTimeout((()=>{yp.setState({crossChainSubmittedCounter:0})}),300)},sx:{mt:y?20:"auto"},children:"Check in order list"}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:()=>{vp(fp.Initial),p()},sx:{mt:j?12:y?20:"auto"},children:g?G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"}):G.jsx(e.Trans,{id:"yz7wBu",message:"Close"})})]})})]})}const of="dodo-widget-container";function rf(e){return e.noLangProvider?G.jsx(G.Fragment,{children:e.children}):G.jsx(Vg,{locale:e.locale,children:G.jsx(nf,{...e,children:e.children})})}function af(e){return Lh(e),kp(),function(){const{chainId:e,evmProvider:t}=cp();n.useEffect((()=>{const n=n=>{if(n===e){const e=ac.get(n);if(null==e?void 0:e.isEVMChain)return t}return null},i=new B.ContractRequests({multiCallAddressList:u.multiCallAddressList,getProvider:n,rpc:ql()});nd.setGetConfigProvider(n),u.setContractRequests(i),r.setContractRequests(i)}),[e,t])}(),e.noUI?G.jsx(rf,{...e,children:e.children}):null}function sf(e){var t;const i=n.useRef(null);return G.jsx(K,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:i}),children:G.jsx(af,{...e})})}function lf(e){var{sx:i}=e,o=U(e,["sx"]);const{width:r}=X(),a=n.useMemo((()=>{let e="";return"number"==typeof r?e=`${r}px`:r&&(e=r),e?`calc(${e} - 40px)`:"auto"}),[r]);return G.jsx(t.QuestionTooltip,{container:document.querySelector(`.${of}`),maxWidth:a,sx:Object.assign({cursor:"help"},i),...o})}function df({route:i}){const o=t.useTheme();ac.get(i.fromChainId);const r=ac.get(i.toChainId),[a,s]=n.useState(!1),[l,d]=n.useState(!1),c=dh({fees:i.fees});return G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{py:20,borderStyle:"solid",borderWidth:o.spacing(1,0,0),borderColor:o.palette.border.main},children:G.jsx(t.Accordion,{children:G.jsx(t.AccordionItem,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[G.jsx(t.Box,{component:se.DetailBorder,sx:{mr:6,width:18,height:18}}),G.jsx(e.Trans,{id:"rRDi3Y",message:"Detail"})]}),G.jsx(t.Box,{component:se.CaretUp,sx:{width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]}),children:G.jsxs(t.Box,{sx:{mt:16},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary",flexShrink:0},children:G.jsx(e.Trans,{id:"lt8yMa",message:"Send to:"})}),G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[r?G.jsx(t.Box,{component:r.logo,sx:{width:18,height:18}}):null,G.jsx(t.Box,{sx:{display:"inline-block",mx:6,width:"1px",height:12,backgroundColor:"border.main"}}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},children:tp(i.toAddress)}),G.jsx(t.HoverOpacity,{component:"a",href:np(i.toChainId,i.toAddress,"address"),target:"_blank",rel:"noopener noreferrer",sx:{ml:6,width:18,height:18,color:"text.secondary",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})})]})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:G.jsx(e.Trans,{id:"sMMlTX",message:"Total fees"})}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>s(!a),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[G.jsx(t.Box,{sx:{fontWeight:600,color:o.palette.text.primary},children:i.feeUSD?`~$${i.feeUSD}`:"-"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:a?G.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):G.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),a&&c.map((e=>G.jsxs(t.Box,{sx:{mt:8,pl:22,pr:22,display:"flex",alignItems:"center",justifyContent:"space-between",color:"text.secondary",typography:"body2",position:"relative"},children:[G.jsx(t.Box,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:"10",height:"25",viewBox:"0 0 10 25",fill:"none",sx:{width:10,height:25,position:"absolute",left:10,bottom:10},children:G.jsx("path",{d:"M9 24L2 24C1.44772 24 1 23.5523 1 23L1 1",stroke:"currentColor",strokeOpacity:"0.5",strokeLinecap:"round",strokeDasharray:"2 2"})}),G.jsx(t.Box,{sx:{flex:1},children:e.title}),e.isFree?G.jsx(t.Box,{sx:{color:o.palette.primary.main},children:"Free"}):null!==e.value?G.jsxs(t.Box,{sx:{color:o.palette.text.primary},children:["~$",e.value]}):G.jsx(t.Box,{sx:{color:o.palette.text.primary},children:"-"})]},e.title))),G.jsxs(t.Box,{sx:{mt:8,mb:l?8:0,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",fontWeight:600,color:"success.main",flexShrink:0},children:"Fee comparison"}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>d(!l),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:"ZUNO"}),G.jsx(t.Box,{sx:{px:8,borderRadius:12,backgroundColor:o.palette.success.main,typography:"h6",fontWeight:600,color:o.palette.success.contrastText,textTransform:"uppercase"},children:"Cheapest"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:l?G.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):G.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),l&&G.jsx(Bh,{feeUSD:i.feeUSD}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(lf,{onlyHover:!0,title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:6})]}),G.jsxs(t.Box,{sx:{typography:"body2"},children:[100*i.slippage,"%"]})]})]})})})}),G.jsx(t.Box,{sx:{pt:0,pb:0,borderStyle:"solid",borderWidth:o.spacing(1,0,0),borderColor:o.palette.border.main},children:G.jsx(t.Accordion,{children:G.jsx(t.AccordionItem,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:G.jsxs(t.Box,{sx:{py:20,display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[G.jsx(t.Box,{component:se.DetailBorder,sx:{mr:6,width:18,height:18}}),G.jsx(e.Trans,{id:"QNWt8A",message:"Estimated Time"})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:[i.executionDuration?hh({start:Date.now(),end:Date.now()+1e3*i.executionDuration}):"-",G.jsx(t.Box,{component:se.CaretUp,sx:{ml:6,width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]})]}),children:G.jsx(hg,{route:i,isMobile:!0})})})})]})}function cf({open:i,onClose:o,route:r,bridgeOrderTxRequest:a,clearToAmt:s,clearFromAmt:l,isDialogModal:d}){const c=t.useTheme(),{contractStatus:u}=yp(),p=Sg({route:r,bridgeOrderTxRequest:a});return n.useEffect((()=>{u!==fp.Pending&&o(),u===fp.TxSuccess&&(s(),l())}),[u]),G.jsx(Eh,{title:G.jsx(e.Trans,{id:"tKE4Ak",message:"Cross Chain Summary"}),open:i,id:"cross-chain-summary",onClose:()=>{vp(fp.Initial),o()},modal:d,children:G.jsxs(G.Fragment,{children:[r?G.jsxs(t.Box,{sx:{px:16,pb:20,flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"36% 28% 36%",py:20,borderStyle:"solid",borderWidth:c.spacing(1,0,0),borderColor:c.palette.border.main},children:[G.jsx(Og,{token:r.fromToken,chainId:r.fromChainId,amount:r.fromAmount}),G.jsx(Eg,{children:G.jsx(t.Box,{sx:{display:"flex",px:3,py:3,backgroundColor:c.palette.background.paperContrast,border:`1px solid ${c.palette.border.main}`,borderRadius:"50%",alignItems:"center",width:24,height:24,overflow:"hidden"},children:G.jsx(Ag,{size:"medium",toolDetails:r.step.toolDetails,nameMarginLeft:8})})}),G.jsx(Og,{token:r.toToken,chainId:r.toChainId,amount:r.toTokenAmount})]}),G.jsx(df,{route:r})]}):"",G.jsx(t.Box,{sx:{px:16,py:20},children:G.jsx(t.Button,{fullWidth:!0,isLoading:u==fp.Pending,disabled:!r,onClick:()=>{p(),vp(fp.Pending)},children:u==fp.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"PZqJog",message:"Confirm Cross Chain"})})})]})})}function uf({message:n,onClose:i,isDialogModal:o}){return G.jsx(Eh,{open:!!n,onClose:i,id:"error-message",modal:o,children:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{flex:1,textAlign:"center"},children:[G.jsx(t.Box,{component:se.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),n?G.jsxs(t.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(t.Box,{sx:{color:"text.secondary",mt:12,mx:20,typography:"body2",wordBreak:"break-all",overflow:"auto",height:"300px"},children:n})]}):""]}),G.jsx(t.Box,{sx:{px:16,py:20},children:G.jsx(t.Button,{onClick:i,fullWidth:!0,children:G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"})})})]})})}function pf(){const[e,i]=n.useState(!1),o="https://smolrefuel.com/?partner=0x1271CAba4bf23f8Fb31F97448605d65EE302CA51";return G.jsxs(G.Fragment,{children:[G.jsxs(t.ButtonBase,{sx:{mt:16,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:4,typography:"body2",fontWeight:600,color:"text.link","&:hover":{color:"text.primary"}},onClick:()=>{window.open(o,"_blank")},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"19",viewBox:"0 0 19 19",fill:"none",children:G.jsx("path",{d:"M3.5 16.25V4.25C3.5 3.8375 3.64687 3.48438 3.94063 3.19063C4.23438 2.89687 4.5875 2.75 5 2.75H9.5C9.9125 2.75 10.2656 2.89687 10.5594 3.19063C10.8531 3.48438 11 3.8375 11 4.25V9.5H11.75C12.1625 9.5 12.5156 9.64688 12.8094 9.94063C13.1031 10.2344 13.25 10.5875 13.25 11V14.375C13.25 14.5875 13.3219 14.7656 13.4656 14.9094C13.6094 15.0531 13.7875 15.125 14 15.125C14.2125 15.125 14.3906 15.0531 14.5344 14.9094C14.6781 14.7656 14.75 14.5875 14.75 14.375V8.975C14.6375 9.0375 14.5188 9.07813 14.3938 9.09688C14.2688 9.11563 14.1375 9.125 14 9.125C13.475 9.125 13.0312 8.94375 12.6688 8.58125C12.3063 8.21875 12.125 7.775 12.125 7.25C12.125 6.85 12.2344 6.49063 12.4531 6.17188C12.6719 5.85313 12.9625 5.625 13.325 5.4875L11.75 3.9125L12.5375 3.125L15.3125 5.825C15.5 6.0125 15.6406 6.23125 15.7344 6.48125C15.8281 6.73125 15.875 6.9875 15.875 7.25V14.375C15.875 14.9 15.6938 15.3438 15.3313 15.7063C14.9688 16.0688 14.525 16.25 14 16.25C13.475 16.25 13.0312 16.0688 12.6688 15.7063C12.3063 15.3438 12.125 14.9 12.125 14.375V10.625H11V16.25H3.5ZM5 8H9.5V4.25H5V8ZM14 8C14.2125 8 14.3906 7.92813 14.5344 7.78438C14.6781 7.64062 14.75 7.4625 14.75 7.25C14.75 7.0375 14.6781 6.85938 14.5344 6.71563C14.3906 6.57188 14.2125 6.5 14 6.5C13.7875 6.5 13.6094 6.57188 13.4656 6.71563C13.3219 6.85938 13.25 7.0375 13.25 7.25C13.25 7.4625 13.3219 7.64062 13.4656 7.78438C13.6094 7.92813 13.7875 8 14 8Z",fill:"currentColor"})}),"Gas Refuel>"]}),G.jsx(Eh,{open:e,onClose:()=>i(!1),title:"Gas refuel",modal:!0,children:G.jsxs(t.Box,{sx:{maxWidth:540,minHeight:600,px:20,pb:24,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[G.jsx(t.Box,{sx:{pt:20,borderTopWidth:1,borderTopStyle:"solid",borderColor:"border.main",typography:"body2",color:"text.secondary"},children:"A solution for gas refueling that allows you to refill your wallet anonymously and gas-free."}),G.jsx(t.Box,{component:"iframe",src:o,width:"100%",sx:{borderRadius:12,overflow:"hidden",flex:1,border:"none"}})]})})]})}function hf({open:i,execute:o,onClose:r,toToken:s,fromToken:l,fromAmount:d,toAmount:c,priceImpact:u,clearFromAmt:p,clearToAmt:h,baseFeeAmount:m,curToFiatPrice:g,curFromFiatPrice:x,pricePerFromToken:f,additionalFeeAmount:y,loading:v,slippage:b,isDialogModal:C}){var j,w;const k=t.useTheme(),{contractStatus:T}=yp(),B=n.useMemo((()=>new a(u).gt(mc)),[u]),[I,S]=n.useState(!1),[A,E]=n.useState(!1);return n.useEffect((()=>{T!==fp.Pending&&r(),T===fp.TxSuccess&&(h(),p())}),[T]),n.useEffect((()=>{S(!1)}),[g]),G.jsx(Eh,{open:i,onClose:()=>{vp(fp.Initial),r()},id:"swap-summary",title:G.jsx(e.Trans,{id:"QR4/RH",message:"Swap summary"}),modal:C,children:G.jsxs(t.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[G.jsx(Nh,{width:16,height:16,url:null==l?void 0:l.logoURI,address:null!==(j=null==l?void 0:l.address)&&void 0!==j?j:"",marginRight:6}),G.jsx(t.Box,{children:`${Au({input:d,decimals:null==l?void 0:l.decimals})} ${null==l?void 0:l.symbol}`})]}),G.jsx(t.Box,{sx:{mt:4,typography:"h6",color:k.palette.text.secondary},children:x?`$${Su({input:x,showDecimals:1})}`:"-"})]}),G.jsx(t.Box,{sx:{width:16,mx:16},component:se.DoubleRight}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex"},children:[G.jsx(Nh,{width:16,height:16,marginRight:6,url:null==s?void 0:s.logoURI,address:null!==(w=null==s?void 0:s.address)&&void 0!==w?w:""}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:`${Au({input:c,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:k.palette.text.secondary},children:g?`$${Su({input:g,showDecimals:1})}`:"-"})]})]}),G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1 ",null==l?void 0:l.symbol," = ",G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:Au({input:new a(c).dividedBy(new a(d)),decimals:null==s?void 0:s.decimals})})," ",null==s?void 0:s.symbol]})]}),G.jsxs(t.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${k.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:k.palette.text.secondary},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{width:16,mr:7},component:se.DetailBorder}),G.jsx(e.Trans,{id:"XeovX3",message:"Swap Detail"})]}),G.jsx(t.Box,{component:t.ButtonBase,children:G.jsx(t.Box,{onClick:()=>E(!A),sx:{width:10,color:"text.secondary",transform:A?"rotateX(0deg)":"rotateX(180deg)"},component:se.CaretUp})})]}),G.jsxs(t.Box,{sx:{mt:16,display:A?"initial":"none"},children:[G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"93m8jT",message:"Basic Fee"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:m?`${Au({input:m,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"J39pAJ",message:"Additional Fee"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),G.jsx(t.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:y?`${Au({input:y,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"T+qgFw",message:"Price Impact"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),G.jsx(t.Box,{children:`${u}%`})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),G.jsxs(t.Box,{children:[b,"%"]})]})]})]}),G.jsx(t.Box,{sx:{flex:1}}),B&&G.jsxs(t.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>S(!I),children:[G.jsx(t.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:I?G.jsx(t.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:G.jsx(t.Box,{component:se.Done,sx:{width:14,color:"secondary.contrastText"}})}):G.jsx(t.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${k.palette.text.secondary}`}})}),G.jsx(t.Box,{children:G.jsx(e.Trans,{components:{0:G.jsx(t.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:u},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),G.jsx(t.Button,{isLoading:T==fp.Pending,disabled:B&&!I,fullWidth:!0,onClick:()=>{o(),vp(fp.Pending)},children:T==fp.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"lQ6r7x",message:"Confirm swap"})})]})})}function mf(e){var{sx:n,maxVal:i,decimals:o=2,onInputChange:r}=e,s=U(e,["sx","maxVal","decimals","onInputChange"]);return G.jsx(t.Input,{...s,onChange:e=>{const t=0===e.target.value.length?null:Lu(e.target.value,o),n=i&&t&&new a.BigNumber(t).gt(i)?i.toString():t;r&&r(n)}})}function gf({open:i,onClose:o,isBridge:r,isDialogModal:a}){const s=t.useTheme(),{slippage:l}=yp(),d=n.useMemo((()=>Number(l)>=xc),[l]),{defaultSlippage:c}=Xp(r);return G.jsx(Eh,{open:i,onClose:o,id:"swap-settings",title:G.jsx(e.Trans,{id:"OSWUSw",message:"Cross chain setting"}),modal:a,children:G.jsx(t.Box,{sx:{mx:20},children:G.jsxs(t.Box,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column"},children:[G.jsx(mf,{fullWidth:!0,maxVal:100,value:null!=l?l:"",placeholder:c.toString(),onInputChange:e=>{!function(e,t){null===t?localStorage.removeItem(e?pc:uc):localStorage.setItem(e?pc:uc,String(t))}(!!r,e),Cp(e)},suffix:G.jsx(t.Box,{sx:{color:"text.disabled"},children:"%"}),height:36,sx:{mt:12}}),d&&G.jsx(t.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:G.jsx(e.Trans,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]})})})}const xf="position-y-dot";function ff(){return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(t.Skeleton,{width:"100%",height:12}),G.jsx(t.Skeleton,{width:"100%",height:12})]})}function yf({data:e,loading:i}){var o,r;const a=t.useTheme(),s=a.palette.primary.main,l=n.useRef(null),d=e.length;return G.jsx(t.Box,{sx:{height:105,flex:1,[`& .${xf}`]:{}},ref:l,children:i?G.jsx(ff,{}):G.jsx(t.Box,{component:S.ResponsiveContainer,sx:{typography:"h6","& .recharts-cartesian-axis text":{fill:a.palette.background.paperContrast}},children:G.jsxs(S.AreaChart,{data:e,margin:{top:0,right:0,left:0,bottom:0},children:[G.jsx(S.XAxis,{dataKey:"forecastSlippage",axisLine:!1,tickLine:!1,interval:"preserveStartEnd",tickFormatter:e=>Vu({input:e}),type:"number",domain:[d&&null!==(o=e[0].forecastSlippage)&&void 0!==o?o:0,d&&null!==(r=e[d-1].forecastSlippage)&&void 0!==r?r:"auto"]}),G.jsx(S.YAxis,{dataKey:"confidenceRatio",axisLine:!1,tickLine:!1,hide:!0}),G.jsx("defs",{children:G.jsxs("linearGradient",{id:"count-linear",x1:"0",y1:"0",x2:"0",y2:"1",children:[G.jsx("stop",{offset:"0",stopColor:s,stopOpacity:.3}),G.jsx("stop",{offset:"100%",stopColor:s,stopOpacity:0})]})}),G.jsx(S.Area,{type:"monotone",dataKey:"confidenceRatio",stroke:s,strokeWidth:2,fill:"url(#count-linear)"}),e.map((e=>G.jsx(S.ReferenceDot,{x:e.forecastSlippage,y:e.confidenceRatio,r:1,fill:a.palette.text.primary,stroke:"none",className:xf},e.confidenceRatio)))]})})})}var vf=n.memo(yf);const bf=t.styled(t.Slider)((({theme:e})=>({height:2,padding:"15px 0",margin:0,"& .base-Slider-valueLabel":{fontSize:12,fontWeight:"normal",top:-6,backgroundColor:"unset",color:e.palette.text.primary,"&:before":{display:"none"},"& *":{background:"transparent",color:e.palette.text.primary}},"& .base-Slider-track":{display:"none"},"& .base-Slider-rail":{backgroundColor:e.palette.text.disabled,height:1,opacity:1},"& .base-Slider-mark":{display:"none",opacity:1,backgroundColor:e.palette.success.main,height:6,width:4,borderRadius:4},"& .base-Slider-markLabel":{display:"none",fontSize:"12px",lineHeight:"17px"}})));function Cf(i){var{hidden:o,sx:r,value:a,color:s,min:l,max:d,formatValue:c,getSliderYPosition:u}=i,p=U(i,["hidden","sx","value","color","min","max","formatValue","getSliderYPosition"]);const{children:h}=p,m=U(p,["children"]),{isMobile:g}=t.useDevices(),x=n.useRef(null),f=u(a),y=g?4:0,v=f?f-39-y:void 0,b=null!=s?s:"text.primary",C=a===l,j=a===d;return G.jsxs(t.Box,{...m,ref:x,sx:Object.assign({position:"absolute","&&&":{display:o?"none":"block",backgroundColor:"transparent",boxShadow:"none",bottom:8+y,width:"auto",height:"auto",top:"auto",marginLeft:0,transform:"none"}},r),children:[h,G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[v?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:b,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),G.jsx(t.Box,{sx:{height:v,width:"0",borderStyle:"dashed",borderWidth:1,borderColor:b}})]}):"",G.jsx(t.Box,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:b,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),G.jsxs(t.Box,{sx:Object.assign(Object.assign({typography:"h6",position:"absolute",bottom:-20,color:b,whiteSpace:"nowrap",backgroundColor:"background.paperContrast"},C?{left:0}:{}),j?{right:0}:{}),children:[j?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:"span",sx:{color:"success.main"},children:G.jsx(e.Trans,{id:"cOvZFM",message:"Dynamic"})}),G.jsx("span",{children:" • "})]}):"",c(a)]})]})]})}function jf(e){var{hoverValue:n,formatValue:i,getSliderYPosition:o}=e,r=U(e,["hoverValue","formatValue","getSliderYPosition"]);const{isMobile:a}=t.useDevices(),s=a?"primary.main":void 0,l=a?void 0:"primary.main";return G.jsx(bf,{slots:{thumb:e=>{const t=r.value&&"number"==typeof r.value&&(r.min&&r.value<r.min||r.max&&r.value>r.max),d={value:r.value,min:r.min,max:r.max,hidden:!!t,color:s,formatValue:i,getSliderYPosition:o},c=Object.assign(Object.assign({},e),d);if(null!==n&&r.max&&r.min&&r.value!==n){const e=r.max-r.min,t=n-r.min,i=t?t/e*100:0;if(a){const e=!!n&&(!!r.min&&n<r.min||!!r.max&&n>r.max);return G.jsxs(G.Fragment,{children:[G.jsx(Cf,{...d,value:n,color:l,hidden:e,sx:{left:i+"%"}}),G.jsx(Cf,{...c})]})}return G.jsxs(G.Fragment,{children:[G.jsx(Cf,{...c}),G.jsx(Cf,{...d,value:n,hidden:!1,color:l,sx:{left:i+"%"}})]})}return G.jsx(Cf,{...c})}},...r})}const wf=(e,{time:t=100,wrapper:n=document,retryCount:i=50}={})=>new Promise((o=>{n.querySelector(e)?o(!0):setTimeout((()=>q(void 0,void 0,void 0,(function*(){if(n.querySelector(e))o(!0);else if(i){const r=yield wf(e,{time:t,wrapper:n,retryCount:i-1});o(r)}else o(!1)}))),t)}));function kf({data:i,activeSlippage:o,loading:r,sx:s,handleChangeCustomSlippage:l}){const d=n.useMemo((()=>{var e;return null!==(e=null==i?void 0:i.length)&&void 0!==e?e:0}),[i]),{isMobile:c}=t.useDevices(),[u,p]=n.useState([]),h=n.useRef(null);n.useEffect((()=>{(()=>{q(this,void 0,void 0,(function*(){var e;if(h.current&&d){const t=`.${xf}`;yield wf(t,{wrapper:h.current});const n=h.current.querySelectorAll(t),{y:i,height:o}=h.current.getBoundingClientRect(),r=null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0,a=[];for(let e=0;e<r;e++){const t=n[e];const r=(t.children[0]?t.children[0].getBoundingClientRect().y:t.getBoundingClientRect().y)-i-.5;a.push(o-r)}p(a)}}))})()}),[d]);const m=(({activeSlippage:e,data:t,yPositions:i})=>{const[o,r]=n.useState(0),s=n.useMemo((()=>1e6),[]),[l,d]=n.useMemo((()=>{var e,n;const i=null==t?void 0:t.length;return i?[new a(null!==(e=t[0].forecastSlippage)&&void 0!==e?e:0).times(null!=s?s:0).dp(0,1).toNumber(),new a(null!==(n=t[i-1].forecastSlippage)&&void 0!==n?n:0).times(null!=s?s:0).dp(0,1).toNumber()]:[0,0]}),[t,s]),c=n.useCallback((e=>{if(void 0===e)return"";const n=new a(e);if((null==t?void 0:t.length)&&s){const e=t.find((e=>{var t;return new a(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(s).dp(0,1).isEqualTo(n)}));if(null==e?void 0:e.forecastSlippage)return Vu({input:e.forecastSlippage,showDecimals:4})}return Vu({input:s?n.div(s):n,showDecimals:4})}),[s,t]),u=n.useCallback((e=>{let n=0;return e&&(null==t?void 0:t.length)&&s?(t.some(((o,r)=>{var l,d;const c=null!==(l=o.forecastSlippage)&&void 0!==l?l:0,u=new a(c).times(s).dp(0,1).toNumber();if(e===u)return n=i[r],!0;if(e<u){if(0===r)return n=0,!0;const o=c-(null!==(d=t[r-1].forecastSlippage)&&void 0!==d?d:0),l=i[r]-i[r-1],u=c-new a(e).div(s).toNumber();return n=i[r]-l/o*u,!0}})),n):n}),[i,t,s]),p=n.useCallback((e=>{r(e);const n=new a(e);let i,o=-1;if((null==t?void 0:t.length)&&s){o=t.findIndex((e=>{var t;return new a(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(s).dp(0,1).isEqualTo(n)}));const e=-1!==o?t[o]:void 0;i=null==e?void 0:e.forecastSlippage}return i||(i=n.div(null!=s?s:0).toNumber()),i}),[t,s]);return n.useEffect((()=>{if(s&&e){const t=new a(e).times(s).dp(0,1);t.isEqualTo(o)||r(t.toNumber())}}),[e]),{min:l,max:d,value:o,decimalConversion:s,formatValue:c,getSliderYPosition:u,handleChangeValue:p}})({data:i,activeSlippage:o,yPositions:u}),{hoverValue:g,setHoverValue:x}=function(e,{slippageSlider:i}){const{isMobile:o}=t.useDevices(),[r,s]=n.useState(null),l=n.useRef(!1);return n.useEffect((()=>{if(e.current&&i.max){const t=e.current;let{width:n,x:d}=t.getBoundingClientRect();const c=e=>{if(l.current)return;const t=e.pageX-d,o=i.max-i.min,c=new a(t/n*o).integerValue().plus(i.min).toNumber();c!==r&&s(c)},u=()=>{s(null)},p=()=>{l.current=!1},h=()=>{l.current=!0};return o||(t.addEventListener("mousemove",c),t.addEventListener("mouseleave",u),t.addEventListener("mouseup",p),t.addEventListener("mousedown",h)),()=>{o&&(t.removeEventListener("mousemove",c),t.removeEventListener("mouseleave",u),t.removeEventListener("mouseUp",p),t.removeEventListener("mouseDown",h))}}}),[e,o]),{hoverValue:r,setHoverValue:s}}(h,{slippageSlider:m}),{successRate:f,hoverSuccessRate:y}=function({data:e,activeSlippage:t,hoverValue:i,decimalConversion:o}){const r=n.useMemo((()=>{var n,i;let o="-";if(t&&(null==e?void 0:e.length)){const r=e.some(((n,i)=>{var r,a,s,l,d,c;const u=null!==(r=n.forecastSlippage)&&void 0!==r?r:0;if(t===u)return o=Vu({input:null!==(a=null==n?void 0:n.confidenceRatio)&&void 0!==a?a:0}),!0;if(t<u){if(0===i)o=`< ${Vu({input:null!==(s=null==n?void 0:n.confidenceRatio)&&void 0!==s?s:0})}`;else{const t=Vu({input:null!==(d=null===(l=e[i-1])||void 0===l?void 0:l.confidenceRatio)&&void 0!==d?d:0}),r=Vu({input:null!==(c=null==n?void 0:n.confidenceRatio)&&void 0!==c?c:0});o=`${t} - ${r}`}return!0}return!1}));r||(o=`> ${Vu({input:null!==(i=null===(n=e[e.length-1])||void 0===n?void 0:n.confidenceRatio)&&void 0!==i?i:0})}`)}return o}),[e,t]),s=n.useMemo((()=>{var t,n;let r="";if(i&&(null==e?void 0:e.length)&&o){const s=e.some(((t,n)=>{var s,l,d,c,u,p;const h=null!==(s=t.forecastSlippage)&&void 0!==s?s:0,m=new a(h).times(o).dp(0,1).toNumber();if(i===m)return r=Vu({input:null!==(l=null==t?void 0:t.confidenceRatio)&&void 0!==l?l:0}),!0;if(i<m){if(0===n)r=`< ${Vu({input:null!==(d=null==t?void 0:t.confidenceRatio)&&void 0!==d?d:0})}`;else{const i=Vu({input:null!==(u=null===(c=e[n-1])||void 0===c?void 0:c.confidenceRatio)&&void 0!==u?u:0}),o=Vu({input:null!==(p=null==t?void 0:t.confidenceRatio)&&void 0!==p?p:0});r=`${i} - ${o}`}return!0}return!1}));s||(r=`> ${Vu({input:null!==(n=null===(t=e[e.length-1])||void 0===t?void 0:t.confidenceRatio)&&void 0!==n?n:0})}`)}return r}),[i,o,e]);return{successRate:r,hoverSuccessRate:s}}({data:i,activeSlippage:o,hoverValue:g,decimalConversion:m.decimalConversion});return i?G.jsxs(t.Box,{sx:Object.assign({p:12,pb:28,borderRadius:12,backgroundColor:"background.paperContrast"},s),children:[G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600,color:"text.secondary"},children:G.jsx(e.Trans,{id:"88dol0",message:"Success Rate"})}),G.jsx(t.LoadingSkeleton,{loading:r,loadingProps:{width:100},sx:{mt:4,typography:"caption",color:y?"primary.main":"text.primary"},children:y||f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"flex-end",pr:4},children:[G.jsx(t.Box,{sx:{pb:8,mr:16,typography:"h6",fontWeight:600},children:G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"})}),G.jsxs(t.Box,{sx:{flex:1},ref:h,children:[G.jsx(vf,{data:i,loading:r}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:!r&&d?G.jsx(jf,{value:c?g||-1:m.value,min:m.min,max:m.max,disabled:!c,marks:[{value:m.max,label:m.max}],formatValue:m.formatValue,getSliderYPosition:m.getSliderYPosition,hoverValue:c?m.value:g,onChange:(e,t)=>{if("number"==typeof t){if(c)return void x(t);const e=m.handleChangeValue(t);l(e)}},onChangeCommitted:()=>{x(null)}}):""})]})]})]}):null}var Tf,Bf=n.memo(kf);function If({title:i,desc:o,doNotChecked:r,onChangeDoNotChecked:a}){const s=t.useTheme();if(n.useMemo((()=>r),[]))return null;const l=s.palette.warning.main;return G.jsxs(t.Box,{sx:{backgroundColor:t.alpha(l,.1),borderRadius:8,padding:12},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,typography:"body2",color:l,fontWeight:700},children:[G.jsx(se.Warn,{}),i]}),G.jsx(t.Box,{sx:{mt:8,typography:"body2",fontWeight:500,color:s.palette.text.secondary,textAlign:"center"},children:o}),!!a&&G.jsxs(t.Box,{sx:{width:"100%",mt:20,color:s.palette.text.secondary,typography:"h6",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer"},component:"label",children:[G.jsx(t.Checkbox,{checked:r,size:16,onChange:e=>{const{checked:t}=e.target;a(t)}}),G.jsx(e.Trans,{id:"3WdxUv",message:"Do not remind again"})]})]})}function Sf({fromToken:i,toToken:r}){var s,l;const d=t.useTheme(),{slippageAdvanced:c,notRemindAgainSlippageHigher:u,notRemindAgainSlippageLower:p}=Gp(),{customSlippage:h,customSlippageNum:m,handleSlippageChange:g,forecastSlippage:x,forecastSlippageQuery:f,recommendSlippage:y}=nh({fromToken:i,toToken:r}),v=!!x,[b,C]=n.useState(!1),[j,w]=n.useState();!j&&i&&r&&w(h?Tf.custom:Tf.recommend);const k=j===Tf.custom,T=n.useRef(null),B=n.useMemo((()=>j===Tf.custom?m?new a(m).div(100).toNumber():void 0:new a(y).div(100).toNumber()),[j,y,m]),I=n.useCallback((e=>{k||w(Tf.custom),g({slippage:new a(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(y)})}),[k,y,g]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:24,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"x6GJ4a",message:"Max Slippage"}),G.jsx(t.QuestionTooltip,{title:G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"qoii6e",message:"The dynamic slippage is provided by ZUNO team through analyzing historical transactions."}),G.jsx("br",{}),G.jsxs(t.Box,{component:"a",href:o.i18n._({id:"zABfk1",message:"https://blog.dodoex.io/introducing-the-dodo-smart-slippage-3d32d13a4fef"}),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[G.jsx(e.Trans,{id:"NgeSlx",message:"Learn More"}),">"]})]}),ml:7})]}),f.isLoading||(null===(s=f.slippageData.slippageList)||void 0===s?void 0:s.length)?G.jsxs(t.LoadingSkeleton,{loading:f.isLoading,loadingProps:{width:100},component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"sxkWRg",message:"Advanced"}),G.jsx(t.Checkbox,{sx:{top:-1},size:16,checked:c,onChange:e=>{const{checked:t}=e.target;Gp.setState({slippageAdvanced:t})}})]}):""]}),!!j&&G.jsxs(t.Tabs,{value:j,onChange:(e,t)=>{w(t),t===Tf.custom&&C(!0)},children:[G.jsxs(t.TabListButton,{variant:"inPaper",sx:{mt:16,'&:not(:hover) [aria-selected="true"] .weak':{color:t.alpha(d.palette.secondary.contrastText,.5)}},children:[G.jsx(t.TabButton,{value:Tf.recommend,variant:"inPaper",sx:{position:"relative"},children:G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:"span",sx:{position:"absolute",top:4,left:4,ml:4,typography:"h6",fontWeight:600,padding:d.spacing(0,8),borderRadius:4,backgroundColor:k?t.alpha(d.palette.purple.main,.1):"#FFF"},children:G.jsx(t.Box,{component:"span",sx:{background:k?`linear-gradient(90deg, ${d.palette.purple.main} -1.33%, ${"dark"===d.palette.mode?"#E6D9FF":"#BFAFF3"} 98.67%)`:`linear-gradient(90deg, ${d.palette.purple.main} -1.33%, #BFAFF3 98.67%)`,backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"New"})}),G.jsxs(t.Box,{sx:{textAlign:"center"},children:[v?G.jsxs(t.Box,{sx:{flexGrow:1,typography:"body2",fontWeight:600},children:[y.toString()||"-","%"]}):G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"wSpNR+",message:"This trading pair does not have enough historical data and has used the default dynamic slippage."}),sx:{ml:0,maxWidth:240},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"body2",fontWeight:600,color:d.palette.warning.main,gap:4},children:[G.jsx(t.Box,{component:se.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),G.jsxs("span",{children:[y.toString()||"-","%"]})]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600},className:"weak",children:G.jsx(e.Trans,{id:"cOvZFM",message:"Dynamic"})})]})]})}),G.jsx(t.TabButton,{value:Tf.custom,variant:"inPaper",sx:{position:"relative",p:0},children:G.jsxs(t.Box,{sx:{px:16,py:12,typography:"body2",fontWeight:600,textAlign:"center"},onClick:()=>{setTimeout((()=>{C(!0)}))},children:[b?G.jsx(t.Input,{ref:T,placeholder:"-",sx:{backgroundColor:"transparent",borderWidth:0,"& input":{textAlign:"center",typography:"body2",p:0,boxSizing:"border-box",height:19,color:k?d.palette.secondary.contrastText:d.palette.text.secondary,"&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",value:h||"",autoFocus:!0,onChange:e=>{const t=e.target.value;g({slippage:t,disabled:!1,recommend:String(y)})},onBlur:()=>{setTimeout((()=>{if(C(!1),!m)return void w(Tf.recommend);const e=!m||m<0;e&&h&&g({slippage:h,disabled:e,deleted:e,recommend:String(y)})}),10)},onKeyDown:e=>{var t;"Enter"===e.code&&(e.preventDefault(),null===(t=T.current)||void 0===t||t.blur())}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,color:h&&k?d.palette.warning.main:void 0},children:[h&&G.jsx(t.Box,{component:se.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),h||"-","%"]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"h6",fontWeight:600},className:"weak",children:G.jsx(e.Trans,{id:"8Tg/JR",message:"Custom"})})]})})]}),G.jsx(t.TabPanel,{value:Tf.recommend,children:(null===(l=f.slippageData.slippageList)||void 0===l?void 0:l.length)&&c?G.jsx(Bf,{data:f.slippageData.slippageList,activeSlippage:B,loading:f.isLoading,handleChangeCustomSlippage:I,sx:{mt:8}}):""}),G.jsxs(t.TabPanel,{value:Tf.custom,children:[G.jsx(t.Box,{sx:{mt:8}}),m>y&&G.jsx(If,{title:o.i18n._({id:"8XNsbx",message:"Higher than dynamic slippage"}),desc:o.i18n._({id:"iLj1a9",message:"Dynamic slippage is {recommendSlippage}%,the current slippage setting is higher than the dynamic slippage, which means you are willing to accept a worse final execution price.",values:{recommendSlippage:y}}),doNotChecked:u,onChangeDoNotChecked:e=>Gp.setState({notRemindAgainSlippageHigher:e})}),!!m&&m<y&&G.jsx(If,{title:o.i18n._({id:"TTlkRL",message:"Lower than dynamic slippage"}),desc:o.i18n._({id:"yq+Q9s",message:"Dynamic slippage is {recommendSlippage}% , the current slippage setting may increase the failure rate of transactions.",values:{recommendSlippage:y}}),doNotChecked:p,onChangeDoNotChecked:e=>Gp.setState({notRemindAgainSlippageLower:e})})]})]})]})}function Af({checked:n,onChange:i,sx:o,disabled:r}){const a=t.useTheme();let s=a.palette.background.tag;return n&&(s=a.palette.secondary.main),G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:a.palette.background.input,opacity:r?.5:1},o),component:t.ButtonBase,disabled:r,onClick:()=>{r||i(!n)},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"az8lvo",message:"Off"})}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:n?a.palette.secondary.contrastText:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"Z5HWHd",message:"On"})}),G.jsx(t.Box,{sx:{borderRadius:6,backgroundColor:s,zIndex:0,position:"absolute",top:2,bottom:2,width:"calc(50% - 2px - 2px)",left:n?"calc(50% + 2px)":"2px",transition:"left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"}})]})}function Ef({show:n,onClick:i}){const o=t.useTheme();return G.jsxs(t.HoverOpacity,{weak:!0,sx:{display:n?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:o.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${o.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${t.alpha("light"===o.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:i,children:[G.jsx(e.Trans,{id:"F8yRdq",message:"More trade settings"}),G.jsx(t.Box,{component:"svg",width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M12.5 19L6.5 13L7.9 11.6L12.5 16.175L17.1 11.6L18.5 13L12.5 19ZM12.5 13L6.5 6.99998L7.9 5.59998L12.5 10.175L17.1 5.59998L18.5 6.99998L12.5 13Z",fill:"currentColor"})})]})}function Of({selected:e,name:n,logo:i,onClick:o}){const r=t.useTheme();return G.jsxs(t.Box,{component:t.ButtonBase,onClick:o,sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,py:19,mt:16,mx:8,width:"calc(33.33% - 8px - 8px)",borderRadius:8,backgroundColor:r.palette.background.paperContrast,borderColor:e?r.palette.secondary.main:r.palette.background.paperContrast,borderWidth:1,borderStyle:"solid","&:hover":{borderColor:r.palette.secondary.main},position:"relative",overflow:"hidden"},children:[G.jsx("img",{src:i,alt:n,style:{height:40,width:40}}),G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:600},children:n}),e&&G.jsx(t.Box,{sx:{right:0,top:0,position:"absolute",width:32,height:24,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r.palette.secondary.main,borderRadius:"0px 0px 0px 8px"},children:G.jsx("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M11.8709 3.16663L5.03682 10.0007L2.35089 7.32514L0.888672 8.78737L5.03682 12.9355L13.3331 4.63922L11.8709 3.16663Z",fill:r.palette.secondary.contrastText})})})]})}function Lf({privacySwapSupplierEndpoints:e,endpointStatusMap:i,refetchEndpointStatus:o,setIsSelectSupplierMode:r}){var a,s;const l=t.useTheme(),[d,c]=n.useState(null!==(s=null===(a=null==e?void 0:e[0])||void 0===a?void 0:a.key)&&void 0!==s?s:null),[u,p]=n.useState(i);u!==i&&(p(i),Array.from(i.entries()).forEach((([e,t])=>{t&&c(e)})));const h=d?null==e?void 0:e.find((e=>e.key===d)):void 0,m=!d||i.get(d),g=n.useCallback((()=>{o(),r(!1)}),[o,r]),{switchTo:x}=function({chainId:e,successCallback:t,selectedSupplier:i}){return{switchTo:n.useCallback((()=>q(this,void 0,void 0,(function*(){if(i)try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[i.addChainParameters]}),t()}catch(e){console.error(e)}}))),[i,t])}}({successCallback:g,selectedSupplier:h});return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"stretch",flexDirection:"column",minHeight:"100%"},children:[G.jsx(t.Box,{sx:{mt:20,pt:12,display:"flex",alignItems:"flex-start",flexWrap:"wrap",mx:-8},children:null==e?void 0:e.map(((e,t)=>{const n=d===e.key;return G.jsx(Of,{selected:n,name:e.name,logo:e.logo,onClick:()=>c(e.key)},t)}))}),G.jsx(t.Box,{sx:{mt:24,width:"100%",height:"1px",flexShrink:0,flexGrow:0,backgroundColor:l.palette.border.main}}),G.jsxs(t.Box,{sx:{mt:24,mb:24,typography:"body2",fontWeight:500,color:l.palette.text.secondary},children:[G.jsx(t.Box,{children:"*Choose your privacy transaction server. Later, a new network will be added to your wallet, and transactions submitted under this network can only be seen by the privacy transaction server. The server will protect you from the impact of MEV. You can also disable the privacy transaction by switching back to the original network."}),h&&G.jsx(t.Box,{sx:{color:l.palette.primary.main},component:"a",href:null==h?void 0:h.docUrl,target:"_blank",rel:"noopener noreferrer",children:"Learn more>"})]}),G.jsx(t.Button,{size:t.Button.Size.big,variant:t.Button.Variant.contained,fullWidth:!0,sx:{marginTop:"auto",flexShrink:0,flexGrow:0},disabled:m,onClick:x,children:"Enable Privacy Swap"}),G.jsx(t.Box,{sx:{height:28,width:"100%"}})]})}function Rf({open:o,onClose:r,fromToken:a,toToken:s,privacySwapEnableAble:l,privacySwapEnable:d,privacySwapSupplierEndpoints:c,endpointStatusMap:u,refetchEndpointStatus:p,isDialogModal:h}){const m=t.useTheme(),{ddl:g,expertMode:x,disableIndirectRouting:f}=Gp(),[y,v]=n.useState(!1),b=n.useRef(null),[C,j]=n.useState(!1);return n.useEffect((()=>{const e=b.current,t=new ResizeObserver((()=>{e&&j(e.scrollHeight!==e.offsetHeight)})),n=i.throttle((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;j(t)}),50);return e&&(j(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==b?void 0:b.current]),G.jsx(Eh,{open:o,onClose:y?()=>v(!1):r,id:"swap-settings",title:y?"Select A Supplier":G.jsx(e.Trans,{id:"384mLX",message:"Same chain setting"}),modal:h,children:G.jsx(t.Box,{sx:{px:20,pb:34,overflowY:"auto"},ref:b,children:y?G.jsx(Lf,{privacySwapSupplierEndpoints:c,endpointStatusMap:u,refetchEndpointStatus:p,setIsSelectSupplierMode:v,privacySwapEnable:d,privacySwapEnableAble:l}):G.jsxs(G.Fragment,{children:[G.jsx(Sf,{fromToken:a,toToken:s}),G.jsxs(t.Box,{sx:{mt:24,pt:14,borderTop:`solid 1px ${m.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"zSMRJ/",message:"Transaction Deadline"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"wmCrk7",message:"You may modify the transaction deadline, the maximum time allowed for a trade to be processed on-chain. However, please note that this may lead to your trade executing at a subpar price, as the market price may change during that time."}),ml:7})]}),G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[G.jsx(t.Input,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(fc),value:g,onChange:e=>{Gp.setState({ddl:e.target.value})}}),G.jsx(e.Trans,{id:"H9HlDe",message:"minutes"})]})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${m.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"MXQodB",message:"Disable Indirect Routing"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"Y0Knz4",message:"Checking this option means that the routing algorithm will only route to liquidity pools between the two tokens in the trading pair and will ignore routes with any intermediary tokens."}),ml:7})]}),G.jsx(Af,{checked:f,onChange:e=>{Gp.setState({disableIndirectRouting:e})}})]}),l&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"U1Bq/+",message:"Privacy Swap"}),G.jsx(lf,{title:G.jsx(e.Trans,{id:"fsEEap",message:"Privacy Swap can effectively protect users from sandwich attacks that could come about due to the differences between the slippage settings and the current price in the liquidity pool. This feature is free for a limited time."}),ml:7})]}),G.jsx(Af,{checked:d,disabled:d,onChange:e=>{e&&v(!0)}})]})]}),G.jsx(Ef,{show:C,onClick:()=>{var e,t;null===(e=b.current)||void 0===e||e.scrollTo({top:null===(t=b.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})})}function Mf({onClick:e,disabled:n,plus:i}){const o=t.useTheme(),r=n||i||!e;return G.jsx(t.Box,{sx:{width:"100%",position:"relative"},children:G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({width:44,height:44,borderRadius:"50%",backgroundColor:o.palette.background.paper,border:"4px solid #E4E1D4",display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)",color:"text.secondary"},r?{cursor:"inherit"}:{"&:hover":{color:"text.primary"},"&:focus-visible":{"&::before":{content:'""',position:"absolute",display:"block",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"50%",width:36,height:36,border:"solid 1px",borderColor:"text.secondary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:i?G.jsx(t.Box,{component:se.Plus,sx:{width:24,height:24}}):G.jsx(t.Box,{component:se.ArrowBack,sx:{width:24,height:24}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(Tf||(Tf={}));const Pf=()=>{const{requests:e,updateText:t}=Up(),i=n.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if((n===Ip.Running||n===Ip.Success)&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=n.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if(n===Ip.Success&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),r=n.useCallback(((e,n,i)=>{const o=e[n];if(!o)return!1;return!!(a.isBigNumber(i)?i:new a(i)).isEqualTo(o)||(t((e=>{var t;const i=Object.assign({},e.metadata);return(null===(t=null==i?void 0:i.logBalance)||void 0===t?void 0:t[n])?(delete i.logBalance[n],Object.keys(i.logBalance).length||delete i.logBalance,{brief:e.brief,spec:e.spec,metadata:i}):null})),!1)}),[t]),s=n.useCallback(((e,t)=>r(i,e,t)),[i,r]),l=n.useCallback(((e,t)=>r(o,e,t)),[o,r]);return{balanceData:i,balanceDataDone:o,isTokenLoading:s,isTokenLoadingDone:l}};function _f({onClick:n,balance:i,decimals:o,address:r,showMaxBtn:a,canClickBalance:s,loading:l,balanceText:d}){const{palette:c}=t.useTheme(),u=s&&(null==i?void 0:i.gt(0))&&n;return G.jsxs(t.Box,{sx:Object.assign({typography:"body2",alignItems:"center",color:c.text.secondary,wordBreak:"break-word",textAlign:"right"},u?{"&:hover":{color:c.text.primary,cursor:"pointer"}}:{}),onClick:u?()=>n(i?i.toString():""):void 0,children:[null!=d?d:G.jsx(e.Trans,{id:"0QDjxt",message:"Balance:"})," ",l?G.jsx(t.RotatingIcon,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):G.jsxs(G.Fragment,{children:[r?Au({input:i,decimals:Math.min(o||4,4)}):"-",a&&i&&i.gt(0)&&n&&G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:6,color:(null==i?void 0:i.gt(0))?c.primary.main:c.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>n&&n(i?i.toString():""),children:G.jsx(e.Trans,{id:"CK1KXz",message:"Max"})})]})]})}const Nf=n.forwardRef((function({readOnly:e,sx:i,value:o,decimals:r,onChange:a,suffix:s,suffixGap:l=0,withClear:d,onFocus:c,placeholder:u,readonlyShowSuffix:p,typography:h},m){const g=t.useTheme(),x=n.useMemo((()=>s||(d&&o&&a?G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{a&&a("")},children:G.jsx(t.Box,{component:se.Error,sx:{width:12}})}):void 0)),[a,s,g.palette.text.primary,o,d]);return G.jsx(t.Input,{fullWidth:!0,value:o,readOnly:e,placeholder:u||"0.00",onFocus:c,onChange:e=>{const t=e.target.value,n=0===t.length?"":Lu(t,r);a&&a(n)},"data-testid":"number-input-wrapper",suffix:(!e||p)&&x,suffixGap:l,ref:m,sx:Object.assign({border:"none","& input":{fontSize:24,typography:h,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:h,color:"text.disabled"}}},i)})}));function Df({token:n,onClick:i,showChainLogo:o,readonly:r,showChainName:a}){var s,l;const d=t.useTheme(),c=(null==n?void 0:n.chainId)?ac.get(n.chainId):null,u=a&&!!c;return G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",gap:8,color:d.palette.text.primary,typography:u?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||i&&i(e)},"data-testid":Cc,children:[!!(null==n?void 0:n.address)&&G.jsx(Nh,{url:null==n?void 0:n.logoURI,address:null!==(s=null==n?void 0:n.address)&&void 0!==s?s:"",chainId:null==n?void 0:n.chainId,noShowChain:!o,width:32,height:32,chainSize:16,logoOffset:6,marginRight:0}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==n?void 0:n.address)?G.jsx(G.Fragment,{children:G.jsx(t.Box,{children:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&G.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!u&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[c.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]})}function Ff({chain:e,active:n,onClick:i}){return G.jsx(t.Tooltip,{title:e.name,placement:"top",onlyHover:!0,children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,cursor:"pointer",border:"1px solid"},n?{backgroundColor:"tabActive.main",borderColor:"tabActive.main",color:"primary.main"}:{borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:i,children:[G.jsx(t.Box,{component:e.logo,sx:{width:24,height:24}}),n&&G.jsx(t.Box,{sx:{typography:"body2",color:"primary.main"},children:e.name})]})},e.chainId)}var Uf=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},qf={"text/plain":"Text","text/html":"Url",default:"Text"};var Vf=function(e,t){var n,i,o,r,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=Uf(),r=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(i){if(i.stopPropagation(),t.format)if(i.preventDefault(),void 0===i.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=qf[t.format]||qf.default;window.clipboardData.setData(o,e)}else i.clipboardData.clearData(),i.clipboardData.setData(t.format,e);t.onCopy&&(i.preventDefault(),t.onCopy(i.clipboardData))})),document.body.appendChild(s),r.selectNodeContents(s),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),i=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(i,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l},Hf=H(Vf);function Wf({copyText:e,size:i,sx:r,componentProps:a,onClick:s,children:l}){var d;const[c,u]=n.useState(!1);return G.jsx(t.TooltipToast,{title:o.i18n._({id:"6V3Ea3",message:"Copied"}),open:c,onClose:()=>u(!1),arrow:!1,children:G.jsxs(t.Box,{...a,component:null!==(d=null==a?void 0:a.component)&&void 0!==d?d:t.ButtonBase,onClick:t=>{if(null==a?void 0:a.onClick)return a.onClick(t);t.stopPropagation(),e&&(Hf(e),u(!0)),s&&s()},sx:Object.assign({cursor:"pointer"},null==a?void 0:a.sx),children:[G.jsx(t.Box,{component:se.Copy,sx:Object.assign({width:i||"auto",height:i||"auto"},r)}),l]})})}function $f({truncate:e,address:n,disabledAddress:i,sx:o,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:s}){return i?G.jsx(t.Box,{children:e?tp(n):n}):G.jsx(t.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==o?void 0:o.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:G.jsxs(t.Box,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?tp(n):n,s?G.jsx(t.Box,{component:se.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function zf({address:e,truncate:n,showCopy:i,size:o="medium",iconSize:r,iconSpace:a,sx:s,iconDarkHover:l,disabledAddress:d,addressHoverColor:c,addressHoverShowIcon:u,customChainId:p,handleOpen:h,onAddressClick:m,onShareClick:g}){const x=t.useTheme(),{chainId:f}=cp(),y=null!=p?p:f,v="big"===o,b="medium"===o,C=l?t.HoverAddBackground:t.HoverOpacity,j=e=>{let t=e?12:8;return a&&(t=a),l&&(t-=3),t},w=v?"h5":b?"body1":"body2",k=(t,n)=>{h?h(t,n):y&&(t.stopPropagation(),window.open(np(y,e,"address")))},T=r||(b?16:14);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",typography:w,color:x.palette.text.primary,lineHeight:"normal"},s||{}),children:[G.jsx($f,{truncate:n,address:e,disabledAddress:d,sx:s,typography:w,handleOpen:null!=m?m:k,addressHoverColor:c,addressHoverShowIcon:u}),G.jsx(C,{sx:{display:"inline-flex",ml:j(b),cursor:"pointer"},onClick:e=>{k(e,"icon")},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:T,height:T}})}),i?G.jsx(Wf,{size:T,copyText:e,componentProps:{component:C,sx:{ml:j(b),display:"inline-flex",alignItems:"center",justifyContent:"center"}}}):null,!!g&&G.jsx(C,{sx:{display:"inline-flex",ml:j(b),cursor:"pointer"},onClick:e=>{g(e)},children:G.jsx(t.Box,{component:se.Share,sx:{width:T,height:T,ml:j(b)}})})]})}function Zf({token:e,disabled:i,style:o,balance:r,onSelect:a}){const s=t.useTheme(),l=n.useMemo((()=>r?Au({input:r,decimals:e.decimals}):""),[r,e.decimals]);return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",px:8,py:8,borderRadius:8,cursor:i?"auto":"pointer",opacity:i?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:o,onClick:()=>{i||a(e)},"data-testid":kc,children:[G.jsx(Nh,{token:e,width:32,height:32,noShowChain:!0,noBorder:!0}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[G.jsx(t.Box,{sx:{textAlign:"left",color:"text.primary",typography:"body2",fontWeight:600},children:e.symbol}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:500,maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),G.jsx(zf,{address:e.address,customChainId:e.chainId,showCopy:!0,truncate:!0,iconSpace:2,iconSize:12,size:"small",sx:{typography:"h6",color:"text.disabled"}})]})]}),G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:(null==r?void 0:r.gte(0))?l:G.jsx(t.Box,{component:se.Loading,width:18,sx:{"& path":{fill:s.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})}function Qf(){return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(t.Skeleton,{variant:"circular",width:32,sx:{mt:8}}),G.jsxs(t.Box,{sx:{ml:8,flex:"1 0 auto"},children:[G.jsx(t.Skeleton,{sx:{borderRadius:4},height:24}),G.jsx(t.Skeleton,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Gf({data:e,index:t,style:n}){const i=e.tokenList[t],o=e.getIsDisabled(i),r=e.getBalance(i);return G.jsx(Zf,{token:i,disabled:o,style:n,onSelect:e.onSelectToken,balance:r},i.address+i.chainId)}function Yf({fixedSizeHeight:e,tokenList:t,onSelectToken:i,getIsDisabled:o,getBalance:r}){const a=n.useMemo((()=>({onSelectToken:i,tokenList:t,getIsDisabled:o,getBalance:r})),[i,t,o,r]);return G.jsx(A.FixedSizeList,{height:e,width:"100%",itemSize:56,itemData:a,itemCount:t.length,children:Gf})}function Kf({chainId:e,value:i,onChange:s,occupiedAddrs:l,occupiedChainId:c,hiddenAddrs:u,showAddrs:p,visible:h,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,sx:v,filterBySupportTargetChain:b}){const{chainList:C,selectChainId:j,setSelectChainId:w}=function(e){const{crossChain:t,defaultChainId:i,IS_TEST_ENV:o}=X(),[r,a]=n.useState(e?Array.isArray(e)?e[0]?e[0].chainId:i:e.chainId:i),s=n.useMemo((()=>t?o?Array.from(ac.values()):Array.from(ac.values()).filter((e=>!e.isTestNet)):[]),[o,t]);return{chainList:s,selectChainId:r,setSelectChainId:a}}(i),{showTokenList:k,filter:T,setFilter:B,onSelectToken:I,popularTokenList:S,tokenInfoMap:A}=function({value:e,onChange:t,occupiedAddrs:i,occupiedChainId:o,hiddenAddrs:s,showAddrs:l,side:d,chainId:c,visible:u,defaultLoadBalance:p,multiple:h,filterBySupportTargetChain:m}){const[g,x]=n.useState(""),f=Lp(),y=null!=c?c:f,{tokenList:v,popularTokenList:b}=Tc(),C=n.useMemo((()=>new Set(s?s.map((e=>e.toLowerCase())):void 0)),[s]),j=n.useMemo((()=>l?new Set(l.map((e=>e.toLowerCase()))):void 0),[l]),w=n.useCallback((e=>{const t=new Set;return e.filter((e=>{if(e.chainId!==y)return!1;let n=!0;if(n=j?j.has(e.address.toLowerCase()):!C.has(e.address.toLowerCase()),n)if(d)n=!e.side||e.side===d;else{const i=`${e.chainId}-${e.address}`;n=!t.has(i),t.add(i)}return n}))}),[y,j,C,d]),k=n.useCallback((e=>{var t;if(e.chainId!==y)return!1;if(!m)return!0;if(null==o||o===y)return!0;if(!e.supportTargetChain)return!1;if(o!==r.ChainId.SOLANA)return!0;if(y!==r.ChainId.ZETACHAIN)return!1;const n=null===(t=null==i?void 0:i[0])||void 0===t?void 0:t.toLowerCase(),a=e.address.toLowerCase();if(!n)return!0;const s=r.basicTokenMap[o];switch(n){case s.address.toLowerCase():case s.wrappedTokenAddress.toLowerCase():return a==="0x4bC32034caCcc9B7e02536945eDbC286bACbA073".toLowerCase();case"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".toLowerCase():return a==="0x8344d6f84d26f998fa070BbEA6D2E15E359e2641".toLowerCase();case"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB".toLowerCase():return a==="0xEe9CC614D03e7Dbe994b514079f4914a605B4719".toLowerCase();default:return!0}}),[y,m,i,o]),T=n.useMemo((()=>w(v.filter(k))),[k,w,v]),B=n.useMemo((()=>w(b.filter(k))),[k,w,b]),I=n.useCallback((n=>{const r=n.address.toLowerCase(),a=!(o&&n.chainId!==o||!(null==i?void 0:i.some((e=>e.toLowerCase()===r))));if(Array.isArray(e)||h&&!e){const i=[...e],o=i.findIndex((e=>e.address.toLocaleLowerCase()===r));-1!==o?i.splice(o,1):i.push(n),t(i,a)}else t(n,a)}),[t,i,o]),S=Rh({chainId:y,tokenList:T,popularTokenList:B,value:e,visible:u,defaultLoadBalance:p}),A=n.useCallback((t=>{if(null===t)return null;const n=[];g?t.forEach((e=>{const t=_h(e,g,{matchAddress:!0});t&&n.push({sort:t,token:e})})):t.forEach((e=>{n.push({sort:0,token:e})}));const o=[];return n.sort(((t,n)=>{var o,r;const s=t.token,l=n.token;if(e)if(Array.isArray(e)){const t=e.map((e=>e.address)),n=t.indexOf(s.address),i=t.indexOf(l.address),o=-1!==n,r=-1!==i;if(o||r)return o&&n<i||!r?-1:1}else{if(s.address===e.address)return-1;if(l.address===e.address)return 1}if(null==i?void 0:i.includes(s.address))return-1;if(null==i?void 0:i.includes(l.address))return 1;const d=(null===(o=S.get(`${s.chainId}-${s.address}`))||void 0===o?void 0:o.balance)||new a(0),c=(null===(r=S.get(`${l.chainId}-${l.address}`))||void 0===r?void 0:r.balance)||new a(0),u=B.map((e=>e.address));return(null==u?void 0:u.includes(s.address))?-1:(null==u?void 0:u.includes(l.address))?1:d.eq(c)?t.sort!==n.sort?t.sort>n.sort?1:-1:s.symbol.localeCompare(l.symbol):d.gt(c)?-1:1})).some((e=>!!(g&&o.length>21)||(o.push(e.token),!1))),o}),[g,S,i,e,B]),E=n.useMemo((()=>A(T)||[]),[A,T]);return{filter:g,setFilter:x,showTokenList:E,onSelectToken:I,popularTokenList:B,tokenInfoMap:S}}({value:i,onChange:s,occupiedAddrs:l,occupiedChainId:c,hiddenAddrs:u,showAddrs:p,side:m,chainId:null!=e?e:j,visible:h,defaultLoadBalance:g,multiple:x,filterBySupportTargetChain:b}),E=n.useRef(null),O=n.useRef(null),[L,R]=n.useState(329);n.useEffect((()=>{if(E.current){const e=new ResizeObserver((e=>{for(const t of e)if(t.target===E.current){const e=t.contentRect.height-1;e>0&&R(e)}}));return e.observe(E.current),()=>{e.disconnect()}}}),[]);const M=d.useQuery({queryKey:["token-picker-searchOtherAddress",T],queryFn:()=>y?y(T):null,enabled:ep(T)&&!!y}),P=n.useCallback((e=>!!i&&(Array.isArray(i)?i.some((t=>t.address===e.address&&t.chainId===e.chainId)):i.address===e.address&&i.chainId===e.chainId)),[i]),_=n.useCallback((e=>{var t;return null===(t=A.get(`${e.chainId}-${e.address}`))||void 0===t?void 0:t.balance}),[A]);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",px:16,flexGrow:1,overflow:"hidden"},v),children:[G.jsx(t.SearchInput,{fullWidth:!0,height:48,value:T,onChange:e=>B(e.target.value),clearValue:()=>B(""),placeholder:null!=f?f:o.i18n._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&C.length>0&&G.jsx(t.Box,{ref:O,sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},children:C.map((e=>G.jsx(Ff,{chain:e,active:e.chainId===j,onClick:()=>{w(e.chainId)}},e.chainId)))}),G.jsx(t.Box,{sx:{pb:15,flexGrow:1},ref:E,children:k.length?G.jsx(Yf,{fixedSizeHeight:L,tokenList:k,onSelectToken:I,getIsDisabled:P,getBalance:_}):G.jsx(t.Box,{sx:{height:L,overflowY:"auto"},children:M.isLoading?G.jsx(Qf,{}):M.data?M.data:G.jsx(ee,{hasSearch:!0,sx:{mt:80}})})})]})}function Xf(t){const{height:n,TokenPickerDialog:i}=X(),{isMobile:o}=Bp();if(i)return G.jsx(i,{...t});const{open:r,title:a,value:s,onClose:l,occupiedAddrs:d,hiddenAddrs:c,showAddrs:u,occupiedChainId:p,onTokenChange:h,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,chainId:v,modal:b,filterBySupportTargetChain:C}=t;return G.jsx(Eh,{height:b?"80vh":n,open:r,onClose:l,title:null!=a?a:G.jsx(e.Trans,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:wc,modal:b,children:G.jsx(Kf,{value:s,visible:r,onChange:h,occupiedAddrs:d,occupiedChainId:p,hiddenAddrs:c,showAddrs:u,side:m,defaultLoadBalance:g,multiple:x,searchPlaceholder:f,searchOtherAddress:y,chainId:v,sx:b?{width:o?"100%":420,borderRadius:16}:void 0,filterBySupportTargetChain:C})})}const Jf=/^ST[0-9A-HJ-NP-Z]{39}$/,ey=/^0x[a-fA-F0-9]{64}$/,ty=/^[A-Za-z0-9_-]{48}$/;const ny=({chainId:e,open:i,onClose:o,inputToAddress:a,setInputToAddress:l})=>{const d=t.useTheme(),[c,u]=n.useState(a||""),p=function(e,t){return n.useMemo((()=>{if(!e)return!1;const n=ac.get(t);if(!n)return!1;try{if(n.isEVMChain)return!!su(e);if(n.isSolanaChain)return new s.PublicKey(e),!0;if(n.isBTCChain){if(Jf.test(e))return!0;try{return t===r.ChainId.BTC_SIGNET?F.address.toOutputScript(e,bg):F.address.toOutputScript(e,F.networks.bitcoin),!0}catch(e){return!1}}else{if(n.isSUIChain)return ey.test(e);if(n.isTONChain)return ty.test(e)}return!1}catch(e){return!1}}),[e,t])}(c,e),h=n.useMemo((()=>ac.get(e)),[e]);return G.jsx(Eh,{open:i,onClose:o,title:"Receive address",modal:!0,children:G.jsxs(t.Box,{sx:{minWidth:420,p:20,borderTop:`1px solid ${d.palette.border.main}`,display:"flex",flexDirection:"column",gap:20},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(t.Input,{fullWidth:!0,value:c,placeholder:`Enter ${null==h?void 0:h.name} address`,onChange:e=>{u(e.target.value)},height:48,suffix:c?G.jsx(t.Box,{component:t.ButtonBase,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{u("")},children:G.jsx(t.Box,{component:se.Error,sx:{width:12}})}):null}),!p&&c&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main"},children:"Invalid address"})]}),G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.contained,size:t.Button.Size.middle,disabled:!c||!p,onClick:()=>{l(c),o()},children:"Confirm"})]})})},iy=({token:e,enterAddressEnabled:i=!1,inputToAddress:o,setInputToAddress:r,account:a})=>{var s,l,d,c,u,p;const m=e.chainId,{open:g,disconnect:x,suiConnectModalOpen:f,setSuiConnectModalOpen:y}=cp(),[v,b]=n.useState(!1),C=n.useMemo((()=>ac.get(m)),[m]),j=G.jsxs("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("path",{d:"M12.001 6.3667C12.7373 6.3667 13.3339 6.9634 13.334 7.69971V9.03369H10.1338C9.54481 9.03383 9.06738 9.51108 9.06738 10.1001C9.06751 10.689 9.54488 11.1664 10.1338 11.1665H13.334V12.4995C13.334 13.2359 12.7374 13.8335 12.001 13.8335H4.00098C3.2646 13.8335 2.66797 13.2359 2.66797 12.4995V7.69971C2.66806 6.9634 3.26465 6.3667 4.00098 6.3667H12.001Z",fill:"currentColor"}),G.jsx("ellipse",{cx:"10.1349",cy:"10.1002",rx:"0.533334",ry:"0.533333",fill:"currentColor"}),G.jsx("path",{d:"M8.54243 3.63688C9.14948 3.36708 9.86253 3.5853 10.2146 4.14863L10.9341 5.29984H4.80078L8.54243 3.63688Z",fill:"currentColor"})]});return G.jsxs(G.Fragment,{children:[G.jsx(t.Popup,{triggerChildren:(null===(s=null==a?void 0:a.appKitAccount)||void 0===s?void 0:s.isConnected)?G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:[j,tp(null===(l=null==a?void 0:a.appKitAccount)||void 0===l?void 0:l.address),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:G.jsx("path",{d:"M12.667 6.93016L11.5703 5.8335L8.00033 9.39572L4.43033 5.8335L3.33366 6.93016L8.00033 11.5968L12.667 6.93016Z",fill:"currentColor",fillOpacity:"0.5"})})]}):G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:["Wallet address:",tp(null===(d=null==a?void 0:a.appKitAccount)||void 0===d?void 0:d.address),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:G.jsx("path",{d:"M3.33301 10.0698L4.42967 11.1665L7.99967 7.60428L11.5697 11.1665L12.6663 10.0698L7.99967 5.40317L3.33301 10.0698Z",fill:"currentColor",fillOpacity:"0.5"})})]}),titleSx:{display:"flex",flexDirection:"column",gap:8},children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsxs(t.Box,{sx:{typography:"h6",lineHeight:"16px",color:"text.secondary"},children:["Connected(",dp(m),")"]}),(null===(c=null==a?void 0:a.appKitAccount)||void 0===c?void 0:c.isConnected)?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,px:8,py:8,color:"text.primary",borderRadius:8,backgroundColor:"background.paperContrast",typography:"body2",lineHeight:"19px"},children:[o?j:C&&G.jsx(t.Box,{component:C.logo,sx:{width:16,height:16}}),tp(null===(u=null==a?void 0:a.appKitAccount)||void 0===u?void 0:u.address),G.jsx(t.Box,{sx:{ml:"auto",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onClick:()=>{o?r(null):x({namespace:null==a?void 0:a.namespace})},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 2.25H9.75V9.75H8.25V2.25ZM12.3075 4.94244L13.3725 3.87744C14.8275 5.11494 15.75 6.94494 15.75 8.99994C15.75 12.7274 12.7275 15.7499 9 15.7499C5.2725 15.7499 2.25 12.7274 2.25 8.99994C2.25 6.94494 3.1725 5.11494 4.6275 3.87744L5.685 4.93494C4.5075 5.89494 3.75 7.35744 3.75 8.99994C3.75 11.9024 6.0975 14.2499 9 14.2499C11.9025 14.2499 14.25 11.9024 14.25 8.99994C14.25 7.35744 13.4925 5.89494 12.3075 4.94244Z",fill:"#ED4A25"})})})]}):G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),"sui"===(null==a?void 0:a.namespace)?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},children:"Connect a new wallet"}),open:f,onOpenChange:e=>{console.log("walletconnectbtn isOpen",e),y(e)}}):G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{g({namespace:null==a?void 0:a.namespace})},children:"Connect a new wallet"})]}),i&&G.jsxs(G.Fragment,{children:[(null===(p=null==a?void 0:a.appKitAccount)||void 0===p?void 0:p.isConnected)&&G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),G.jsx(t.Box,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{b(!0)},children:"Enter receive address"})]})]})}),v&&G.jsx(ny,{open:v,onClose:()=>b(!1),chainId:m,inputToAddress:o,setInputToAddress:r})]})};function oy({sx:i,amt:o,token:r,readOnly:a,showMaxBtn:s,canClickBalance:l,onMaxClick:d,fiatPriceTxt:c,failedReason:u,occupiedAddrs:p,occupiedChainId:h,showAddrs:m,onInputFocus:g,onTokenClick:x,onInputChange:f,onTokenChange:y,side:v,showChainLogo:b,showChainName:C,defaultLoadBalance:j,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:B,inputReadonlyTooltip:I,inputTypography:S,hideToken:A,checkLogBalance:E,notTokenPickerModal:O,enterAddressEnabled:L,inputToAddress:R,setInputToAddress:M,account:P,tokenQuery:_,filterBySupportTargetChain:N}){var D,F;const U=t.useTheme(),[q,V]=n.useState(!1),H=null!==(F=null!=w?w:null===(D=_.data)||void 0===D?void 0:D.balance)&&void 0!==F?F:null,{isTokenLoading:W}=Pf();let $=null!=k?k:_.isLoading;!$&&H&&(E?$=Object.entries(E).some((([e,t])=>W(e,t))):r&&($=W(r.address,H))),wp({tokenList:r?[r]:[]});const[z,Z]=n.useState(0),Q=n.useRef("");n.useEffect((()=>{o!==Q.current&&Z(0)}),[o]);const{gotoBuyToken:Y}=X();let K=Y&&H&&o&&H.lt(o);const J=!!f||!!I,ee={"& input":{typography:"h2",height:"44px",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{typography:"h2",height:"44px",color:"text.disabled"}},backgroundColor:"background.paper"};return G.jsxs(t.Box,{sx:Object.assign({minHeight:J?133:"auto",padding:U.spacing(20,20,24),overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:12,backgroundColor:U.palette.background.paper},i),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[A?G.jsx(t.Box,{}):G.jsx(Df,{token:r,showChainLogo:b,showChainName:C,onClick:()=>V(!0),readonly:!y}),r&&G.jsx(iy,{token:r,enterAddressEnabled:L,inputToAddress:R,setInputToAddress:M,account:P})]}),J&&(a&&I?G.jsx(t.TooltipToast,{title:I,arrow:!1,children:G.jsx(t.Box,{children:G.jsx(Nf,{value:o,readOnly:!0,withClear:!0,sx:Object.assign({mt:16},ee)})})}):G.jsx(Nf,{value:o,onFocus:g,onChange:f?e=>{f(e),Z(0)}:void 0,readOnly:a,withClear:!0,suffix:K?G.jsx(t.Button,{variant:t.Button.Variant.tag,backgroundColor:U.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{var t;e.stopPropagation(),(null===(t=null==P?void 0:P.appKitAccount)||void 0===t?void 0:t.address)&&(null==Y||Y({token:r,account:P.appKitAccount.address}))},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:S,sx:Object.assign({mt:16},ee)})),u&&G.jsx(t.Box,{sx:{mt:4,typography:"h6",lineHeight:"16px",fontWeight:500,color:U.palette.error.main},children:u}),G.jsxs(t.Box,{sx:{mt:B?9:4,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:U.palette.text.secondary},children:c}),G.jsx(_f,{balance:H,balanceText:T,onClick:a||!d&&!f?void 0:e=>{d?d(e):f&&f(e),0!==z&&1!==z&&(Z(1),Q.current=e)},showMaxBtn:s,canClickBalance:l,address:null==r?void 0:r.address,decimals:null==r?void 0:r.decimals,loading:$})]}),G.jsx(Xf,{value:r,open:q,side:v,chainId:void 0,showAddrs:m,occupiedAddrs:p,occupiedChainId:h,defaultLoadBalance:j,onClose:()=>{V(!1),x&&x()},onTokenChange:(e,t)=>{V(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Ih)},modal:!O,filterBySupportTargetChain:N})]})}function ry({rawRouteData:e,chainId:t}){const i=n.useMemo((()=>{if(!e)return[];try{const n=JSON.parse(e);return n.subRoute[0].midPath.map((e=>{const{fromToken:n,toToken:i,oneSplitTotalPart:o}=e,r=new Map;return e.poolDetails.forEach((e=>{var t;const n={poolPart:Vu({input:new a(e.poolPart).div(o)}),poolAddress:e.pool||null};r.has(e.poolName)?null===(t=r.get(e.poolName))||void 0===t||t.push(n):r.set(e.poolName,[n])})),{fromToken:n,toToken:i,chainId:t,poolDetails:r}}))}catch(e){console.error(e)}return[]}),[t,e]);return{routeData:i}}const ay=({routeInfo:i,toToken:o,fromToken:r})=>{const[a,s]=n.useState(!1),l=t.useTheme(),{isMobile:d}=Bp(),c=n.useMemo((()=>{const e=[{key:"from",logo:G.jsx(Nh,{token:r,noShowChain:!0,height:14,width:14,marginRight:0})}];return e.push({key:"to",logo:G.jsx(Nh,{token:o,noShowChain:!0,height:14,width:14,marginRight:0})}),e}),[r,o]),{routeData:u}=ry({rawRouteData:i,chainId:null==r?void 0:r.chainId});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{py:4,pl:8,pr:4,display:"flex",alignItems:"center",gap:4,borderRadius:12,backgroundColor:l.palette.background.tag,cursor:"pointer",typography:"h6",fontWeight:500,color:l.palette.text.secondary,"&:hover":{color:l.palette.text.primary}},onClick:()=>{s(!0)},children:[G.jsx(t.Box,{sx:{color:l.palette.text.primary},children:"Route:"}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:0},children:c.map(((e,t)=>G.jsx(n.Fragment,{children:e.logo},e.key)))}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.jsx("path",{d:"M2.91699 11.0833V7.58332H4.08366V9.91666H6.41699V11.0833H2.91699ZM9.91699 6.41666V4.08332H7.58366V2.91666H11.0837V6.41666H9.91699Z",fill:"currentColor"})})]}),G.jsx(Eh,{open:a,title:G.jsx(e.Trans,{id:"rT8e1f",message:"Route"}),onClose:()=>s(!1),modal:!0,children:G.jsx(t.Box,{sx:{minWidth:d?"100%":800,py:20,px:20,borderTop:`1px solid ${l.palette.border.main}`},children:d?G.jsx($h,{routeData:u,fromTokenRaw:r,toTokenRaw:o}):G.jsx(zh,{routeData:u,fromTokenRaw:r,toTokenRaw:o})})})]})};function sy({toToken:i,fromToken:o,priceStatus:r,pricePerToToken:a,pricePerFromToken:s,routeInfo:l}){const d=t.useTheme(),[c,u]=n.useState("-"),[p,h]=n.useState(null),[m,g]=n.useState("-"),[x,f]=n.useState(null);n.useEffect((()=>{u(null==o?void 0:o.symbol),g(null==i?void 0:i.symbol),h(a),f(s)}),[o,i,a,s]);const y=n.useCallback((()=>{u(m),g(c),h(x),f(p)}),[c,p,m,x]);return G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:{[Yp.Initial]:"-",[Yp.Loading]:G.jsxs(G.Fragment,{children:[G.jsx(t.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Yp.Failed]:G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}),[Yp.Success]:G.jsxs(t.Box,{sx:{width:"100%",mt:16,px:11,py:7,borderRadius:12,border:`solid 1px ${d.palette.border.main}`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"flex-start",gap:6},children:[G.jsxs(t.Box,{sx:{typography:"body2",lineHeight:"18px",color:d.palette.text.primary},children:["1 ",c," ",G.jsx("span",{style:{color:d.palette.text.secondary},children:"="})," ",Su({input:x,showDecimals:4})," ",m]}),G.jsx(t.Box,{component:t.ButtonBase,sx:{width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(t.Box,{sx:{width:16,color:"text.secondary"},onClick:y,component:se.Switch})})]}),o&&i&&G.jsx(ay,{routeInfo:l,fromToken:o,toToken:i})]})}[r]})}const ly=[.25,.5,.75,1];function dy({value:e,onChange:n,sx:i}){const o=t.useTheme(),r="light"===o.palette.mode,{isMobile:a}=Bp();return G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:a?10:14,gridTemplateColumns:`repeat(${ly.length}, 1fr)`},i),children:ly.map((i=>{const a=i===e;return G.jsxs(t.ButtonBase,{disabled:!n,sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:o.palette.text.primary,backgroundColor:t.alpha(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:t.alpha(o.palette.text.primary,.4)}},onClick:()=>{!a&&n&&n(i)},className:a?"selected":void 0,children:[100*i,"%"]},i)}))})}function cy(){return t.useTheme(),G.jsx(t.Box,{sx:{height:4,position:"relative",color:"text.secondary"},children:G.jsx(t.Box,{sx:{width:44,height:44,backgroundColor:"background.input",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",borderWidth:4,borderStyle:"solid",borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",color:"text.secondary"},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",fill:"none",children:G.jsx("path",{d:"M19.0142 13H13.0142V19H11.0142V13H5.01416V11H11.0142V5H13.0142V11H19.0142V13Z",fill:"currentColor"})})})})}function uy(){return G.jsx(t.Box,{sx:{position:"relative",height:4},children:G.jsx(t.Box,{sx:{width:44,height:44,borderRadius:22,backgroundColor:"background.input",borderWidth:4,borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%) rotate(90deg)",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:G.jsx(t.Box,{component:se.Plus})})})}function py({sx:i,inputSx:o,amt:r,token:a,readOnly:s,showMaxBtn:l,canClickBalance:c,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:g,onTokenClick:x,onInputChange:f,onTokenChange:y,side:v,showChainLogo:b,showChainName:C,defaultLoadBalance:j,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:B,inputReadonlyTooltip:I,inputTypography:S,chainId:A,hideToken:E,checkLogBalance:O,notTokenPickerModal:L}){var R,M;const{account:P}=cp(),_=t.useTheme(),[N,D]=n.useState(!1),F=d.useQuery(id.getFetchTokenQuery(null==a?void 0:a.chainId,null==a?void 0:a.address,P)),U=null!==(M=null!=w?w:null===(R=F.data)||void 0===R?void 0:R.balance)&&void 0!==M?M:null,{isTokenLoading:q}=Pf();let V=null!=k?k:F.isLoading;!V&&U&&(O?V=Object.entries(O).some((([e,t])=>q(e,t))):a&&(V=q(a.address,U))),wp({tokenList:a?[a]:[]});const[H,W]=n.useState(0),$=n.useRef("");n.useEffect((()=>{r!==$.current&&W(0)}),[r]);const{gotoBuyToken:z}=X();let Z=z&&U&&r&&U.lt(r);const Q=!!f||!!I;return G.jsxs(t.Box,{sx:Object.assign({minHeight:Q?133:"auto",padding:_.spacing(20,20,24),borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:_.palette.background.input},i),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[E?G.jsx(t.Box,{}):G.jsx(Df,{token:a,showChainLogo:b,showChainName:C,onClick:()=>D(!0),readonly:!y}),G.jsx(_f,{balance:U,balanceText:T,onClick:s||!u&&!f?void 0:e=>{u?u(e):f&&f(e),0!==H&&1!==H&&(W(1),$.current=e)},showMaxBtn:l,canClickBalance:c,address:null==a?void 0:a.address,decimals:null==a?void 0:a.decimals,loading:V})]}),Q&&(s&&I?G.jsx(t.TooltipToast,{title:I,arrow:!1,children:G.jsx(t.Box,{children:G.jsx(Nf,{value:r,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},o)})})}):G.jsx(Nf,{value:r,onFocus:g,onChange:f?e=>{f(e),W(0)}:void 0,readOnly:s,withClear:!0,suffix:Z?G.jsx(t.Button,{variant:t.Button.Variant.tag,backgroundColor:_.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==z||z({token:a,account:P})},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:S,sx:Object.assign({mt:12},o)})),!s&&B?G.jsx(dy,{sx:{mt:16},value:H,onChange:U&&void 0!==(null==a?void 0:a.decimals)?e=>{if(U&&(null==a?void 0:a.decimals))if(W(e),1===e){const e=U.toString();u?u(e):f&&f(e),$.current=e}else if(f){const t=U.multipliedBy(e).dp(a.decimals).toString();f(t),$.current=t}}:void 0}):"",void 0!==p?G.jsx(t.Box,{sx:{mt:B?9:0,typography:"h6",color:_.palette.text.secondary},children:p}):"",G.jsx(Xf,{value:a,open:N,side:v,chainId:A,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:j,onClose:()=>{D(!1),x&&x()},onTokenChange:(e,t)=>{D(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Ih)},modal:!L})]})}var hy;function my(){return my=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},my.apply(null,arguments)}const gy=e=>D.createElement("svg",my({width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),hy||(hy=D.createElement("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"}))),xy=e=>Object.keys(new Array(e+1).join(","));function fy(e){return null!=e&&""!==e}var yy;function vy(){return vy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},vy.apply(null,arguments)}const by=e=>D.createElement("svg",vy({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),yy||(yy=D.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},D.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),D.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),D.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),D.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),D.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),D.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),D.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),D.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),D.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),D.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),D.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),D.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),D.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),D.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),D.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),D.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),D.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),D.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),D.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},D.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),D.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),D.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),D.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),D.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),D.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),D.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),D.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),D.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),D.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),D.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),D.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))));function Cy(e){const{switchNetwork:t}=m.useAppKitNetwork();return n.useMemo((()=>{var n;if(!e)return;const i=null===(n=ac.get(e))||void 0===n?void 0:n.caipNetwork;return i?()=>t(i):void 0}),[e,t])}function jy({token:e,size:r="small",sx:a,children:s}){const[l,d]=n.useState(!1),{evmProvider:c,chainId:u}=cp(),p=Cy(e.chainId);return G.jsxs(t.Box,{sx:i.merge({margin:"0",border:"none",padding:"0",background:"none",cursor:"pointer","&:focus":{outline:"none"},"&:active":{outline:"none"},display:"inline-flex",alignItems:"center",justifyContent:"center"},a),onClick:t=>q(this,void 0,void 0,(function*(){if(t.stopPropagation(),void 0!==e.chainId&&e.chainId!==u&&p)return void(null==p||p());if(l)return;if(!c)return;d(!0);const{result:n,failMsg:i}=yield function(e,t){return q(this,void 0,void 0,(function*(){if(!e)return{result:!1};try{return{result:yield e.send("wallet_watchAsset",{type:"ERC20",options:{address:t.address,symbol:t.symbol,decimals:t.decimals,image:t.logoURI}})}}catch(e){return console.error(e),{result:!1,failMsg:null==e?void 0:e.message}}}))}(c,e);n?$x.getState().toast({message:o.i18n._({id:"DupCvC",message:"Added successful"}),type:"success",timeout:3e3}):$x.getState().toast({message:`${o.i18n._({id:"v4wgrk",message:"Failed to add"})}${i?`: ${i}`:""}`,type:"error"}),d(!1)})),component:"button",children:[G.jsx(t.Box,{component:by,sx:Object.assign({},"medium"===r?{width:16,height:16}:{width:14,height:14})}),s]})}function wy({tokens:e,width:n=24,height:i=24,gap:o=-4,cross:r,mr:a,chainId:s,showChainLogo:l,sx:d}){var c;const u=t.useTheme(),{onlyChainId:p}=X(),h=l&&!p,m=n/2;return!e||e.length<=0?G.jsx(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:G.jsx(t.Box,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:52,height:24,viewBox:"0 0 52 24",fill:"none",sx:{height:n,width:"auto",color:t.alpha(u.palette.text.primary,"light"===u.palette.mode?.11:.13),animation:"pulseKeyframe 2s ease-in-out 0.5s infinite","@keyframes pulseKeyframe":{"0%":{opacity:1},"50%":{opacity:.4},"100%":{opacity:1}}},children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3746 4.50813C19.1755 1.76008 15.7933 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24C15.7933 24 19.1755 22.2399 21.3746 19.4919C19.8788 17.3743 19 14.7898 19 12C19 9.21023 19.8788 6.62571 21.3746 4.50813ZM22 5.36441C24.1498 2.13102 27.8261 0 32 0C38.3911 0 43.6152 4.99623 43.9797 11.296C41.0986 12.163 39 14.8364 39 18C39 19.1371 39.2711 20.2108 39.7523 21.1602C37.6611 22.9317 34.9553 24 32 24C27.8261 24 24.1498 21.869 22 18.6356C20.7363 16.735 20 14.4535 20 12C20 9.54653 20.7363 7.26502 22 5.36441ZM52 18C52 21.3137 49.3137 24 46 24C43.5588 24 41.458 22.542 40.5211 20.4493C40.5042 20.4116 40.4876 20.3736 40.4715 20.3355C40.1679 19.6176 40 18.8284 40 18C40 15.3894 41.6673 13.1682 43.9952 12.3431C44.6221 12.1209 45.2969 12 46 12C49.3137 12 52 14.6863 52 18Z",fill:"currentColor"})})}):G.jsxs(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:[e.map(((e,i)=>G.jsx(t.Box,{sx:{display:"inline-flex",width:n,height:n,ml:i>0?o:0,borderRadius:"50%",backgroundColor:u.palette.background.default},children:"object"==typeof e?G.jsx(Nh,{address:e.address,width:n,height:n,chainId:s,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):G.jsx(t.Box,{component:"img",height:n,src:e})},i))),h&&ac.has(s)?G.jsx(t.Box,{component:null===(c=ac.get(s))||void 0===c?void 0:c.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:m,height:m}}):""]})}function ky({loading:e,empty:n,hasSearch:i,children:o,refetch:r}){return e?G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:xy(4).map(((e,n)=>G.jsx(t.Skeleton,{width:"100%",height:45},n)))}):r?G.jsx(re,{refresh:r,sx:{height:320}}):n?G.jsx(ee,{hasSearch:i,sx:{height:320}}):G.jsx(G.Fragment,{children:o})}function Ty({show:e,onClick:n,sx:i}){return G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({p:3,transform:e?"rotate(180deg)":"none",transition:"all 100ms",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},i),onClick:n,children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.58398 11.376C8.78189 11.6728 9.21811 11.6728 9.41603 11.376L12.4818 6.77735C12.7033 6.44507 12.4651 6 12.0657 6H5.93426C5.53491 6 5.29672 6.44507 5.51823 6.77735L8.58398 11.376Z",fill:"currentColor"})})})}function By({isMobile:e,statusText:n,statusColor:i,time:o,alphaColor:r,sx:a,children:s}){const l=t.useTheme(),d=t.alpha(i,.1),c=r?t.alpha(i,r):i;return G.jsxs(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:e?"center":"flex-start",gap:2,typography:"h6",color:"text.secondary"},a),children:[G.jsxs(t.Box,{sx:{padding:l.spacing(4,16),borderRadius:4,backgroundColor:d,color:c,textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center"},children:[n,s]}),o]})}function Iy({token:e,amount:n,canAddMetamask:i,title:o,linkVisible:r=!0}){var a,s;return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsxs(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:[o,": ",Au({input:n,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),i&&e&&G.jsx(jy,{token:e})]}),G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:4,typography:"h6",fontWeight:500,color:"text.secondary"},children:[e&&null!==(s=null===(a=ac.get(e.chainId))||void 0===a?void 0:a.name)&&void 0!==s?s:"-",r&&G.jsx(gy,{})]})]})}function Sy({token:e,amount:n,showChain:i,hideLogo:o,canAddMetamask:r,sx:a}){var s,l;let d="";i&&(d=null!==(l=null===(s=ac.get(e.chainId))||void 0===s?void 0:s.name)&&void 0!==l?l:"");const c=Au({input:n,decimals:e.decimals});return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:[!o&&G.jsx(Nh,{address:e.address,chainId:e.chainId,width:20,height:20}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:2},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,wordBreak:"break-word",typography:"body1",fontWeight:600},children:[`${c} ${e.symbol}`,r&&G.jsx(jy,{token:e})]}),!!d&&G.jsxs(t.Box,{sx:{display:"inline-flex",alignItems:"center",gap:2,typography:"h6",fontWeight:500,color:"text.secondary"},children:[d,G.jsx(gy,{})]})]})]})}function Ay({height:n=64,sx:i,onClick:o,hasMore:r,loading:a}){return t.useTheme(),r?G.jsx(t.ButtonBase,{sx:Object.assign({display:"flex",justifyContent:"center",alignItems:"center",height:n,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},i),onClick:o,children:a?G.jsx(t.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})}):null}function Ey(e){var{sx:n,children:i,hasMore:o,loadMore:r,loadMoreLoading:a}=e,s=U(e,["sx","children","hasMore","loadMore","loadMoreLoading"]);return G.jsxs(t.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",pt:12,px:20,pb:20},n),...s,children:[G.jsx(t.Box,{component:"table",sx:{width:"100%",borderCollapse:"separate",borderSpacing:"0 4px","& th":{py:12,px:24,typography:"body2",textAlign:"left",color:"text.secondary",backgroundColor:"background.paper"},"& th:first-of-type":{borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"& th:last-of-type":{borderTopRightRadius:"8px",borderBottomRightRadius:"8px"},"& td":{px:24,py:20,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,"&::after":{content:'""',display:"table-row",height:"0"}}},children:i}),!!r&&G.jsx(Ay,{loading:a,hasMore:o,onClick:r})]})}function Oy({fromToken:e,toToken:i,fromTokenPrice:o,toTokenPrice:r,sx:s,children:l}){const d=t.useTheme(),[c,u]=n.useState(!1),p=n.useMemo((()=>new a(o&&r?c?r:o:0)),[o,r,c]);return G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign({display:"flex",alignItems:"center",gap:8,color:"text.primary",typography:"body1",fontWeight:600,"&:hover>svg>path":{fill:d.palette.text.primary}},s),onClick:()=>u((e=>!e)),children:[G.jsxs(t.Box,{children:[l,"1 ",c?i.symbol:e.symbol," = ",p&&p.isFinite()?Au({input:p,decimals:c?e.decimals:i.decimals}):"-"," ",c?e.symbol:i.symbol]}),G.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"9",cy:"9",r:"9",fill:d.palette.border.main}),G.jsx("path",{d:"M9.5 6.5H4.5V8H13.5L9.5 4.25V6.5ZM8.25 13.75V11.5H13.5V10H4.5L8.25 13.75Z",fill:d.palette.text.secondary})]})]})}function Ly({showFold:e,isMobile:i,data:o}){const a=t.useTheme(),s=n.useMemo((()=>{var e,t,n,i,a,s,l,d,c,u,p,h,m,g;const x=[{title:"Total time spent",value:null!==(n=hh({start:null!==(e=o.startTime)&&void 0!==e?e:void 0,end:null!==(t=o.endTime)&&void 0!==t?t:void 0}))&&void 0!==n?n:"-"},{title:"Pay",value:G.jsx(zf,{address:null!==(i=o.fromAddress)&&void 0!==i?i:"",customChainId:null!==(a=o.routeData.fromChainId)&&void 0!==a?a:r.ChainId.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:"Receive",value:G.jsx(zf,{address:null!==(s=o.toAddress)&&void 0!==s?s:"",customChainId:null!==(l=o.routeData.toChainId)&&void 0!==l?l:r.ChainId.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:G.jsxs(G.Fragment,{children:["Fill Gas (Destination gas)",G.jsx(lf,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(u=null===(c=null===(d=o.fees)||void 0===d?void 0:d.find((e=>"destinationFee"===e.type)))||void 0===c?void 0:c.amountUSD)&&void 0!==u?u:"-"}`},{title:G.jsxs(G.Fragment,{children:["Bridge Fee",G.jsx(lf,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(m=null===(h=null===(p=o.fees)||void 0===p?void 0:p.find((e=>"platformFee"===e.type)))||void 0===h?void 0:h.amountUSD)&&void 0!==m?m:"-"}`}],f=null===(g=o.fees)||void 0===g?void 0:g.find((e=>"svmRentFee"===e.type));return f&&x.push({title:G.jsxs(G.Fragment,{children:["Rent",G.jsx(lf,{onlyHover:!0,title:"Rent (only first transaction of SPL token)",ml:0})]}),value:`$${f.amountUSD}`}),x}),[o.endTime,o.fees,o.fromAddress,o.routeData.fromChainId,o.routeData.toChainId,o.startTime,o.toAddress]);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:16,p:e?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${a.palette.background.skeleton} 0%, ${a.palette.background.skeleton} 100%), ${a.palette.background.paper}`,maxHeight:e?"auto":0,transition:"all 300ms",overflow:"hidden",[a.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px",gap:24}},children:[G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8,[a.breakpoints.up("tablet")]:{alignItems:"center",flexDirection:"row",gap:20}},children:s.map(((e,n)=>G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",[a.breakpoints.up("tablet")]:{flexBasis:"20%",flexGrow:1,flexShrink:1,flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:4}},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.secondary",typography:"h6"},children:e.title}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:e.value})]},n)))}),null!=o.routeData.fromChainId&&null!=o.routeData.toChainId&&G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{height:"1px",width:"100%",backgroundColor:"border.disabled"}}),G.jsx(hg,{route:{fromChainId:o.routeData.fromChainId,toChainId:o.routeData.toChainId,step:o.routeData.step},isMobile:i})]})]})}function Ry({data:e}){const n=t.useTheme(),i="refund_success"===e.subStatus,{isMobile:o}=Bp();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,[n.breakpoints.up("tablet")]:{gap:8}},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,color:i?n.palette.success.main:n.palette.text.disabled,borderRadius:"50%",backgroundColor:i?t.alpha(n.palette.success.main,.1):n.palette.background.tag,[n.breakpoints.up("tablet")]:{width:24,height:24}},children:i?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o?"12":"16",height:o?"12":"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{d:"M12.7601 3.55554L5.92598 10.3896L3.24005 7.71406L1.77783 9.17628L5.92598 13.3244L14.2223 5.02813L12.7601 3.55554Z",fill:"currentColor"})}):G.jsx(t.RotatingIcon,{sx:{width:12,color:n.palette.text.disabled,[n.breakpoints.up("tablet")]:{width:16}}})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,[n.breakpoints.up("tablet")]:{flexDirection:"column",alignItems:"flex-start"}},children:[e.refundChainId&&e.refundHash?G.jsx(zf,{address:e.refundHash,customChainId:e.refundChainId,showCopy:!1,truncate:!0,iconSpace:o?2:8,sx:{typography:"h6",[n.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},handleOpen:t=>{t.stopPropagation(),window.open(np(e.refundChainId,e.refundHash,"tx"))}}):G.jsx(t.Box,{sx:{typography:"h6",[n.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},children:"-"}),G.jsx(t.Box,{sx:{display:"none",[n.breakpoints.up("tablet")]:{display:"block",typography:"h6",color:n.palette.text.secondary}},children:i?"Refunded to this address.":"Refund in progress."}),i?null:G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.text.secondary,[n.breakpoints.up("tablet")]:{display:"none"}},children:"(Refund in progress.)"})]})]})}function My({data:e,isMobile:i,isErrorRefund:o}){var r,a,s,l,d,c,u,p,h,m;const g=t.useTheme(),{statusText:x,statusColor:f,statusAlphaColor:y}=n.useMemo((()=>{let t="Loading",n=g.palette.text.primary;switch(e.status){case"pending":t="Pending",n=g.palette.text.secondary;break;case"success":t="Succeeded",n=g.palette.success.main;break;case"failure_revert":t="Swap failed",n=g.palette.error.main;break;case"abort":t="Aborted",n=g.palette.error.main}return{statusText:t,statusColor:n,statusAlphaColor:undefined}}),[e.status,g.palette.error.main,g.palette.success.main,g.palette.text.primary,g.palette.text.secondary]),[v,b]=n.useState(!1),C=e.createdAt?gh(new Date(e.createdAt)):"-";return i?G.jsxs(t.Box,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{width:24,height:24,address:null===(r=e.fromToken)||void 0===r?void 0:r.address,chainId:null===(a=e.fromToken)||void 0===a?void 0:a.chainId}),G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),G.jsx(Nh,{width:24,height:24,address:null===(s=e.toToken)||void 0===s?void 0:s.address,chainId:null===(l=e.toToken)||void 0===l?void 0:l.chainId})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:G.jsx(By,{isMobile:!1,statusText:x,statusColor:f,alphaColor:y,children:"success"!==e.status&&G.jsx(lf,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:f}})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:g.palette.text.secondary},children:C})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(Iy,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay",linkVisible:!1}),G.jsx(Iy,{token:e.toToken,amount:e.toAmount,canAddMetamask:e.fromToken&&null!==(c=null===(d=ac.get(e.fromToken.chainId))||void 0===d?void 0:d.isEVMChain)&&void 0!==c&&c,title:"Receive",linkVisible:!1}),o&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:"Refunds TX:"}),G.jsx(Ry,{data:e})]})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${g.palette.border.main}`},children:G.jsx(Ty,{show:v,onClick:()=>b((e=>!e)),sx:{color:"text.secondary"}})})]})]}),G.jsx(Ly,{showFold:v,data:e,isMobile:i})]}):G.jsxs(G.Fragment,{children:[G.jsxs("tr",{children:[G.jsx(t.Box,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:v?0:8},children:e.fromToken&&G.jsx(Sy,{token:e.fromToken,amount:null!==(u=e.fromAmount)&&void 0!==u?u:"",showChain:!0})}),G.jsx("td",{children:e.toToken&&G.jsx(Sy,{token:e.toToken,amount:null!==(p=e.toAmount)&&void 0!==p?p:"",showChain:!0,canAddMetamask:null!==(m=null===(h=ac.get(e.toToken.chainId))||void 0===h?void 0:h.isEVMChain)&&void 0!==m&&m})}),G.jsx("td",{children:G.jsx(By,{isMobile:i,statusText:x,statusColor:f,alphaColor:y,time:C,children:"success"!==e.status&&G.jsx(lf,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:f}})})}),o?G.jsx("td",{children:G.jsx(Ry,{data:e})}):G.jsx("td",{children:e.fromToken&&e.toToken&&G.jsx(Oy,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),G.jsx(t.Box,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:v?0:8},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[!o&&"refund_success"===e.subStatus&&G.jsxs(G.Fragment,{children:[G.jsx(t.Tooltip,{title:"refund TX",placement:"top",onlyHover:!0,children:G.jsx(t.Box,{component:"a",href:e.refundChainId&&e.refundHash?np(e.refundChainId,e.refundHash,"tx"):void 0,target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})})}),G.jsx(t.Box,{sx:{height:16,width:"1px",backgroundColor:"border.main"}})]}),G.jsx(Ty,{show:v,onClick:()=>b((e=>!e))})]})})]}),G.jsx("tr",{children:G.jsx(t.Box,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:G.jsx(Ly,{showFold:v,data:e})})})]})}function Py({account:i,type:o}){const{isMobile:s}=Bp(),l=function({account:e,limit:t=5,type:i}){var o;const{tokenList:s}=Tc(),l=xp().getInfiniteQuery(r.SwapApi.graphql.cross_chain_swap_zetachain_orderList,"page",{where:{user:e,pageSize:t,type:i}}),c=d.useInfiniteQuery(Object.assign(Object.assign({},l),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_orderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),u=n.useMemo((()=>{var e,t,n,i;return null!==(i=null===(n=null===(t=null===(e=c.data)||void 0===e?void 0:e.pages)||void 0===t?void 0:t.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_orderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===n?void 0:n.map((e=>{const t=s.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.fromTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.fromChainId)})),n=s.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.toTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.toChainId)})),i=(null==e?void 0:e.fromAmount)&&t?new a(e.fromAmount).div(10**t.decimals).dp(t.decimals,a.ROUND_DOWN):null,o=(null==e?void 0:e.toAmount)&&n?new a(e.toAmount).div(10**n.decimals).dp(n.decimals,a.ROUND_DOWN):null;return{hash:null==e?void 0:e.fromHash,refundHash:null==e?void 0:e.refundHash,externalId:null==e?void 0:e.externalId,refundCridgeContract:void 0,refundChainId:(null==e?void 0:e.refundChainId)?Number(e.refundChainId):void 0,fromToken:t,toToken:n,fromAmount:i,toAmount:o,startTime:(null==e?void 0:e.startTime)?1e3*e.startTime:void 0,endTime:(null==e?void 0:e.endTime)?1e3*e.endTime:void 0,createdAt:null==e?void 0:e.createdAt,fromAddress:null==e?void 0:e.fromAddress,toAddress:null==e?void 0:e.toAddress,routeData:{fromChainId:null==e?void 0:e.fromChainId,toChainId:null==e?void 0:e.toChainId,step:Ic({omniPlan:null==e?void 0:e.omniPlan,tokenList:s})},fees:null==e?void 0:e.fees,status:null==e?void 0:e.status,subStatus:null==e?void 0:e.subStatus,transactionHash:null==e?void 0:e.fromHash,fromTokenPrice:i&&o&&t?o.div(i).dp(t.decimals,a.ROUND_DOWN).toString():null,toTokenPrice:i&&o&&n?i.div(o).dp(n.decimals,a.ROUND_DOWN).toString():null}})))&&void 0!==i?i:[]}),[null===(o=c.data)||void 0===o?void 0:o.pages,s]);return Object.assign(Object.assign({},c),{orderList:u})}({account:i,limit:s?10:5,type:o}),c="error_refund"===o;return G.jsx(ky,{isMobile:s,empty:!l.orderList.length,loading:l.isLoading,children:s?G.jsxs(t.Box,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[l.orderList.map((e=>G.jsx(My,{data:e,isMobile:s,isErrorRefund:c},e.hash))),G.jsx(Ay,{loading:l.isFetchingNextPage,onClick:l.fetchNextPage,hasMore:l.hasNextPage,height:68})]}):G.jsx(G.Fragment,{children:G.jsxs(Ey,{loadMoreLoading:l.isFetchingNextPage,loadMore:l.fetchNextPage,hasMore:l.hasNextPage,children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(e.Trans,{id:"4fL/V7",message:"Pay"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"uAQUqI",message:"Status"})}),c?G.jsx("th",{children:G.jsx(e.Trans,{id:"VmAUk7",message:"Refunds TX"})}):G.jsx("th",{children:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"})}),G.jsx(t.Box,{component:"th",sx:{width:c?110:140,textAlign:"right !important"},children:G.jsx(e.Trans,{id:"URmyfc",message:"Details"})})]})}),G.jsx("tbody",{children:l.orderList.map((e=>G.jsx(My,{data:e,isMobile:s,isErrorRefund:c},e.hash)))})]})})})}function _y({account:e,limit:t=5}){var n,i,o,a;const s=void 0,l=xp().getInfiniteQuery(r.SwapApi.graphql.cross_chain_swap_zetachain_swapOrderList,"page",{where:{userAddress:null==e?void 0:e.toLowerCase(),pageSize:t}}),c=d.useInfiniteQuery(Object.assign(Object.assign({},l),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_swapOrderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),u=null!==(a=null===(o=null===(i=null===(n=c.data)||void 0===n?void 0:n.pages)||void 0===i?void 0:i.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_swapOrderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===o?void 0:o.map((t=>{var n,i,o,r,a,l,d,c,u,p,h,m,g,x,f,y,v,b,C;let j="";const w=null!==(i=null===(n=null==t?void 0:t.extra)||void 0===n?void 0:n.safeTxHash)&&void 0!==i?i:void 0;return w&&s&&e&&(j=s(w,null==t?void 0:t.chainId,e)),{hash:null!==(o=null==t?void 0:t.hash)&&void 0!==o?o:"",fromToken:sp({address:null!==(r=null==t?void 0:t.fromTokenAddress)&&void 0!==r?r:"",decimals:null==t?void 0:t.fromTokenDecimals,symbol:null!==(a=null==t?void 0:t.fromTokenSymbol)&&void 0!==a?a:"",name:null!==(l=null==t?void 0:t.fromTokenSymbol)&&void 0!==l?l:""},null==t?void 0:t.chainId),toToken:sp({address:null!==(d=null==t?void 0:t.toTokenAddress)&&void 0!==d?d:"",decimals:null==t?void 0:t.toTokenDecimals,symbol:null!==(c=null==t?void 0:t.toTokenSymbol)&&void 0!==c?c:"",name:null!==(u=null==t?void 0:t.toTokenSymbol)&&void 0!==u?u:""},null==t?void 0:t.chainId),fromAmount:null!==(p=null==t?void 0:t.fromAmount)&&void 0!==p?p:"",toAmount:null!==(h=null==t?void 0:t.toAmount)&&void 0!==h?h:"",minAmount:null!==(m=null==t?void 0:t.minAmount)&&void 0!==m?m:"",fromTokenPrice:null!==(g=null==t?void 0:t.fromTokenPrice)&&void 0!==g?g:"",toTokenPrice:null!==(x=null==t?void 0:t.toTokenPrice)&&void 0!==x?x:"",createdAt:null!==(f=null==t?void 0:t.createdAt)&&void 0!==f?f:"",routeData:null!==(v=null===(y=null==t?void 0:t.extra)||void 0===y?void 0:y.routeData)&&void 0!==v?v:"",safeTxHash:w,safeTxUrl:j,status:null!==(b=null==t?void 0:t.status)&&void 0!==b?b:"",transactionHash:null===(C=null==t?void 0:t.extra)||void 0===C?void 0:C.transactionHash}})))&&void 0!==a?a:[];return Object.assign(Object.assign({},c),{orderList:u})}var Ny,Dy;function Fy({showFold:i,isMobile:o,data:r}){const s=t.useTheme(),{routeData:l}=ry({rawRouteData:r.routeData,chainId:r.fromToken.chainId}),d=n.useMemo((()=>r.fromTokenPrice?new a(r.fromTokenPrice):new a(0)),[r.fromTokenPrice]);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:24,p:i?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${s.palette.background.skeleton} 0%, ${s.palette.background.skeleton} 100%), ${s.palette.background.paper}`,maxHeight:i?400:0,transition:"all 300ms",overflow:"hidden",[s.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"h6",color:s.palette.text.secondary},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),o&&G.jsxs(t.Box,{children:["Rate: 1 ",r.fromToken.symbol,"=",d&&d.isFinite()?Au({input:d,decimals:r.toToken.decimals}):"-"," ",r.toToken.symbol]})]}),o?G.jsx($h,{routeData:l,fromTokenRaw:r.fromToken,toTokenRaw:r.toToken}):G.jsx(zh,{routeData:l,fromTokenRaw:r.fromToken,toTokenRaw:r.toToken})]})}function Uy({data:e,isMobile:i}){var r,a,s,l,d,c;const u=t.useTheme(),[p,h]=n.useState(!1),{statusText:m,statusColor:g,statusAlphaColor:x}=function({status:e,stateTextMap:n}){let i=n?n[e]:e;const r=t.useTheme();let a,s=o.i18n._({id:"yQE2r9",message:"Loading"}),l=r.palette.text.primary;switch(e){case Ny.Warning:s=o.i18n._({id:"GGWsTU",message:"Canceled"}),a=.1;break;case Ny.Failed:s=o.i18n._({id:"7Bj3x9",message:"Failed"}),l=r.palette.error.main;break;case Ny.Success:s=o.i18n._({id:"KAbcm2",message:"Succeeded"}),l=r.palette.success.main}return{state:i,statusText:s,statusColor:l,statusAlphaColor:a}}({status:e.status}),f=gh(new Date(e.createdAt));return i?G.jsxs(t.Box,{sx:{backgroundColor:u.palette.background.paper,borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},onClick:()=>window.open(np(e.fromToken.chainId,e.hash,"tx"),"_blank"),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{width:24,height:24,address:e.fromToken.address,chainId:e.fromToken.chainId}),G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:G.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),G.jsx(Nh,{width:24,height:24,address:e.toToken.address,chainId:e.toToken.chainId})]}),G.jsx(By,{isMobile:!1,statusText:m,statusColor:g,alphaColor:x})]}),G.jsx(t.Box,{sx:{typography:"h6",color:u.palette.text.secondary},children:f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[G.jsx(Iy,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay"}),G.jsx(Iy,{token:e.toToken,amount:e.toAmount,canAddMetamask:null!==(a=null===(r=ac.get(e.fromToken.chainId))||void 0===r?void 0:r.isEVMChain)&&void 0!==a&&a,title:"Receive"})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${u.palette.border.main}`},children:G.jsx(Ty,{show:p,onClick:()=>h((e=>!e)),sx:{color:"text.secondary"}})})]})]}),G.jsx(Fy,{showFold:p,data:e,isMobile:!0})]}):G.jsxs(G.Fragment,{children:[G.jsxs("tr",{children:[G.jsx(t.Box,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:p?0:8},children:G.jsx(Sy,{token:e.fromToken,amount:null!==(s=e.fromAmount)&&void 0!==s?s:"",showChain:!0})}),G.jsx("td",{children:G.jsx(Sy,{token:e.toToken,amount:null!==(l=e.toAmount)&&void 0!==l?l:"",showChain:!0,canAddMetamask:null!==(c=null===(d=ac.get(e.toToken.chainId))||void 0===d?void 0:d.isEVMChain)&&void 0!==c&&c})}),G.jsx("td",{children:G.jsx(By,{isMobile:i,statusText:m,statusColor:g,alphaColor:x,time:f})}),G.jsx("td",{children:G.jsx(Oy,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),G.jsx(t.Box,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:p?0:8},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{component:"a",href:np(e.fromToken.chainId,e.hash,"tx"),target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.ArrowTopRightBorder,sx:{width:18,height:18}})}),G.jsx(t.Box,{sx:{height:16,width:"1px",backgroundColor:"border.main"}}),G.jsx(Ty,{show:p,onClick:()=>h((e=>!e))})]})})]}),G.jsx("tr",{children:G.jsx(t.Box,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:G.jsx(Fy,{showFold:p,data:e})})})]})}function qy({account:n}){const{isMobile:i}=Bp(),o=_y({account:n,limit:i?10:5});return G.jsx(ky,{isMobile:i,empty:!o.orderList.length,loading:o.isLoading,children:i?G.jsxs(t.Box,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[o.orderList.map((e=>G.jsx(Uy,{data:e,isMobile:i},e.hash))),G.jsx(Ay,{loading:o.isFetchingNextPage,onClick:o.fetchNextPage,hasMore:o.hasNextPage,height:68})]}):G.jsx(G.Fragment,{children:G.jsxs(Ey,{loadMoreLoading:o.isFetchingNextPage,loadMore:o.fetchNextPage,hasMore:o.hasNextPage,children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:G.jsx(e.Trans,{id:"4fL/V7",message:"Pay"})})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"uAQUqI",message:"Status"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"})}),G.jsx(t.Box,{component:"th",sx:{width:140},children:G.jsx(e.Trans,{id:"URmyfc",message:"Details"})})]})}),G.jsx("tbody",{children:o.orderList.map((e=>G.jsx(Uy,{data:e,isMobile:i},e.hash)))})]})})})}function Vy(e){var{sx:n}=e,i=U(e,["sx"]);return G.jsx(t.TabPanel,{...i,sx:Object.assign(Object.assign({},n),{display:"flex",flexDirection:"column",overflow:"hidden"})})}!function(e){e.Running="pending",e.Success="success",e.Failed="failed",e.Warning="reset"}(Ny||(Ny={})),function(e){e.sameChain="same-chain",e.crossChain="cross-chain",e.errorRefunds="error-refunds"}(Dy||(Dy={}));const Hy="widget-module-container",Wy=n.forwardRef((function(e,n){var{sx:i}=e,o=U(e,["sx"]);const{isMobile:r}=Bp();return G.jsx(t.Box,{className:Hy,ref:n,sx:Object.assign(Object.assign({flex:1,backgroundColor:"transparent"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:0,height:"auto"}),i),...o})}));var $y;exports.PageType=void 0,($y=exports.PageType||(exports.PageType={})).Pool="pool",$y.PoolDetail="poolDetail",$y.CurvePoolDetail="curvePoolDetail",$y.CreatePool="createPool",$y.ModifyPool="modifyPool",$y.MiningList="miningList",$y.MiningDetail="miningDetail",$y.createPoolAMMV2="createPoolAMMV2",$y.createPoolAMMV3="createPoolAMMV3";const zy=c.create(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const i=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:exports.PageType.Pool}];return{page:t,historyList:i}}))},back:()=>{e((e=>{const t=e.historyList.length;if(!t)return"undefined"!=typeof window&&window.history&&history.back(),e;const n=[...e.historyList];return{page:n.splice(t-1,1)[0],historyList:n}}))}})));function Zy({title:e,descList:n,linkTo:i,sx:o}){const r=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({backgroundColor:r.palette.background.paper,backdropFilter:"blur(4px)",borderRadius:12,padding:24,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24},o),children:[G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body1",fontWeight:500,lineHeight:"24px"},children:e}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"stretch",gap:24},children:n.map(((e,n)=>G.jsxs(t.Box,{sx:{flex:1,padding:16,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:8,borderWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{color:r.palette.primary.contrastText,typography:"h6",fontWeight:600,lineHeight:"20px",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:r.palette.primary.main},children:n+1}),G.jsx(t.Box,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:500,lineHeight:"24px"},children:e.title})]}),G.jsx(t.Box,{sx:{color:r.palette.text.secondary,typography:"h6",fontWeight:500,lineHeight:"18px"},children:e.desc})]},n)))}),G.jsx(t.Box,{component:"a",href:i,target:"_blank",rel:"noopener noreferrer",sx:{px:24,py:12,borderRadius:8,backgroundColor:r.palette.background.tag,color:r.palette.text.primary,typography:"body2",fontWeight:700,lineHeight:"21px",textDecoration:"none"},children:"Read Docs"})]})}const Qy=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Gy({disabled:e,value:n,onChange:i,sx:o}){return G.jsxs(t.Box,{sx:Object.assign({p:20,backgroundColor:"background.cardInput",borderRadius:12},o),children:[G.jsx(Nf,{value:String(n),onChange:e=>i(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:G.jsx(t.Box,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,backgroundColor:"background.cardInput","& input":{pl:0,typography:"h1"}}}),G.jsx(t.Box,{sx:{mt:20},children:G.jsx(t.Slider,{marks:Qy,step:1,disabled:e,value:n,onChange:(e,t)=>i(t)})})]})}function Yy({active:n,sx:i,onClick:o}){const r=t.useTheme(),a="light"===r.palette.mode;let s=r.palette.primary.main,l="transparent";return n&&(s=r.palette.primary.contrastText,l=t.alpha(r.palette.primary.main,.8)),G.jsx(t.Box,{component:t.ButtonBase,sx:Object.assign({typography:"body2",p:n?r.spacing(8,20,9):r.spacing(7,19,8),minWidth:79,border:n?void 0:`1px solid ${s}`,color:s,backgroundColor:l,borderRadius:8,fontWeight:600,"&:hover":{color:n?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:n?r.palette.primary.main:a?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},i),onClick:o,children:G.jsx(e.Trans,{id:"R9Khdg",message:"Auto"})})}const Ky="auto",Xy="0.1",Jy="0.5",ev="0.5",tv=.01,nv=({address:e,type:t})=>{const[i,o]=n.useState(Ky),r=n.useMemo((()=>i===Ky?"AMMV3"===t?new a(ev).div(100).toNumber():"AMMV2"===t?new a(Jy).div(100).toNumber():new a(Xy).div(100).toNumber():i),[i,t]);return{slipper:i,setSlipper:o,slipperValue:r,resetSlipper:()=>{o(Ky)}}};function iv({type:i,disabled:o,value:r,onChange:s,sx:l}){const d=t.useTheme(),c=r===Ky,[u,p]=n.useState(c?"":new a(r).times(100).toNumber()),h="AMMV3"==i?ev:"AMMV2"==i?Jy:Xy;return G.jsx(t.Tooltip,{disabled:o,onlyClick:!0,title:G.jsxs(t.Box,{sx:{backgroundColor:d.palette.background.paper,padding:d.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[c?h:r&&new a(r).times(100).toNumber(),"%"]})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",margin:d.spacing(16,0,0,0)},children:[G.jsx(Yy,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{p(""),s(Ky)},active:c}),G.jsx(t.Input,{placeholder:String(h),value:u,onChange:e=>{const{value:t}=e.target;p(t),s(t?new a(t).div(100).toNumber():Ky)},onBlur:()=>{(!c&&new a(r).gt(.1)||new a(r).lte(0))&&(p(10),s(.1))},suffix:G.jsx(t.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(t.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:d.spacing(0,0,0,"auto"),p:d.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},l),children:G.jsx(t.Box,{component:se.Setting,sx:{width:18,height:18,"& path:last-child":{fill:d.palette.text.primary}}})})})}const ov=50;var rv,av,sv;function lv(i){var r,a,s,{chainId:l,includeButton:d}=i,c=U(i,["chainId","includeButton"]);const{chainId:u,getAppKitAccountByChainId:p,open:h}=cp(),[m,g]=n.useState(!1),x=Cy(l),f=void 0!==u&&void 0!==l&&u!==l,y=p(l);return!(null==y?void 0:y.appKitAccount.address)||m||void 0===u||l&&l!==u?G.jsx(G.Fragment,{children:G.jsx(t.Button,{...c,isLoading:m,onClick:()=>q(this,void 0,void 0,(function*(){if(f)return x?(g(!0),yield x(),void g(!1)):void 0;g(!0),h({namespace:null==y?void 0:y.namespace}),g(!1)})),children:m?G.jsx(e.Trans,{id:"J28zul",message:"Connecting..."}):f&&l?o.i18n._({id:"1+P9RR",message:"Switch to {0}",values:{0:null!==(s=null===(a=ac.get(l))||void 0===a?void 0:a.name)&&void 0!==s?s:"unknown"}}):G.jsx(e.Trans,{id:"r7ScnQ",message:"Connect to a wallet"})})}):d?G.jsx(G.Fragment,{children:null!==(r=c.children)&&void 0!==r?r:null}):G.jsx(t.Button,{...c})}!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(rv||(rv={})),function(e){e.CURRENCY_A="CURRENCY_A",e.CURRENCY_B="CURRENCY_B"}(av||(av={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(sv||(sv={}));const dv={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},cv=({children:e,sx:n})=>(t.useTheme(),G.jsx(t.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},n),children:e})),uv=({children:e,sx:n})=>{const i=t.useTheme();return G.jsx(cv,{sx:Object.assign(Object.assign({},n),{backgroundColor:i.palette.background.paperContrast}),children:e})},pv=({children:e})=>{const n=t.useTheme();return G.jsxs(t.Box,{sx:{p:8,borderRadius:8,backgroundColor:t.alpha(n.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 16.125L9 1.875L17.25 16.125H0.75ZM14.6475 14.625L8.99998 4.86749L3.35247 14.625H14.6475ZM9.75004 12.375H8.25003V13.875H9.75004V12.375ZM8.25003 7.875H9.75004V10.875H8.25003V7.875Z",fill:n.palette.warning.main})}),G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.warning.main,textAlign:"left"},children:e})]})};function hv({gap:e,flex:n,children:i,style:o}){return G.jsx(t.Box,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&dv[e]||e},n&&{flex:n}),{width:"100%",alignItems:"center"}),o),children:i})}function mv({gap:e,justify:n,grow:i,children:o,style:r}){return G.jsx(t.Box,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&dv[e]||e,justifyItems:n,flexGrow:i&&1},r),children:o})}function gv({gap:e,children:n,sx:i}){return G.jsx(t.Box,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&dv[e]||e},i),children:n})}function xv({children:e,style:t}){return G.jsx(gv,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function fv({gap:e,justify:t,children:n,sx:i}){return G.jsx(gv,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},i),children:n})}function yv({children:e,disabled:t,sx:n}){return G.jsx(gv,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const vv=({chainId:n,approvalA:i,approvalB:r,parsedAmounts:a,isValid:s,depositADisabled:l,depositBDisabled:d,errorMessage:c,setShowConfirm:u})=>{var p,h;const m=i.needApprove&&!!a[av.CURRENCY_A]||i.isApproving,g=r.needApprove&&!!a[av.CURRENCY_B]||r.isApproving;return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:n,children:G.jsxs(mv,{gap:"md",style:{width:"100%"},children:[(m||g)&&s&&G.jsxs(t.Box,{sx:{width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"space-between",gap:8},children:[m&&G.jsx(t.Button,{size:t.Button.Size.big,isLoading:i.isApproving,onClick:i.submitApprove,disabled:i.insufficientBalance,width:g?"50%":"100%",children:i.isApproving?G.jsx(e.Trans,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(p=i.token)||void 0===p?void 0:p.symbol}}):i.approveTitle}),g&&G.jsx(t.Button,{size:t.Button.Size.big,isLoading:r.isApproving,onClick:r.submitApprove,disabled:r.insufficientBalance,width:m?"50%":"100%",children:r.isApproving?G.jsx(e.Trans,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(h=r.token)||void 0===h?void 0:h.symbol}}):r.approveTitle})]}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:()=>{u(!0)},disabled:!s||i.needApprove&&!l||r.needApprove&&!d,danger:!s&&!!a[av.CURRENCY_A]&&!!a[av.CURRENCY_B],children:c||o.i18n._({id:"rdUucN",message:"Preview"})})]})})},bv=({chainId:e,disabled:n,isLoading:i,onConfirm:r})=>G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:r,disabled:n,isLoading:i,children:o.i18n._({id:"h5pjuM",message:"Collect fees"})})});function Cv(e){const t=n.useRef();return n.useEffect((()=>{t.current=e})),t.current}const jv=[.25,.5,.75,1];function wv({currentValue:e,onClick:i,sx:o}){const r=t.useTheme(),a="light"===r.palette.mode,{isMobile:s}=Bp(),[l,d]=n.useState(null),c=n.useRef(0);n.useEffect((()=>{e?(c.current+=1,c.current>=2&&(d(null),c.current=0)):d(null)}),[e]);const u=Cv(e);return n.useEffect((()=>{u===e&&1===l&&(c.current=1)}),[e,u,l]),G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${jv.length}, 1fr)`},o),children:jv.map((e=>{const n=e===l;return G.jsxs(t.ButtonBase,{sx:{typography:"h6",borderRadius:4,padding:r.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:r.palette.text.primary,backgroundColor:t.alpha(r.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:a?r.palette.primary.main:t.alpha(r.palette.text.primary,.4)}},onClick:()=>{n||(c.current=0,d(e),i(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const kv=({value:i,onUserInput:r,maxAmount:a,balance:s,currency:l,locked:d})=>{var c,u;const p=t.useTheme(),h=n.useCallback((e=>{if(!a||!l)return;const t=a.toExact().multipliedBy(e).dp(l.decimals).toString();r(t)}),[l,a,r]),m=n.useMemo((()=>s?Au({input:s.toExact(),decimals:null==l?void 0:l.decimals}):"-"),[null==l?void 0:l.decimals,s]);return G.jsxs(t.Box,{sx:{pt:20,pb:20,px:20,borderRadius:16,backgroundColor:p.palette.background.cardInput},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==l?void 0:l.address)&&G.jsx(Nh,{address:null!==(c=null==l?void 0:l.address)&&void 0!==c?c:"",chainId:null==l?void 0:l.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:(null==l?void 0:l.address)?G.jsx(t.Box,{children:null!==(u=null==l?void 0:l.symbol)&&void 0!==u?u:"-"}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),G.jsxs(t.Box,{component:t.ButtonBase,sx:{color:p.palette.text.secondary,"&:hover":{color:p.palette.text.primary},cursor:"pointer",display:"flex",flexWrap:"wrap",justifyContent:"flex-end",typography:"body2"},onClick:()=>{h(1)},children:[G.jsxs(t.Box,{sx:{wordBreak:"keep-all"},children:[o.i18n._({id:"fsBGk0",message:"Balance"}),": "]}),G.jsx(t.Box,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),G.jsx(Nf,{sx:{mt:4,backgroundColor:p.palette.background.cardInput},suffix:void 0,value:i,onChange:r,readOnly:d,withClear:!d}),d?null:G.jsx(wv,{sx:{mt:20,mb:0},onClick:h,currentValue:i})]})},Tv={},Bv={};var Iv,Sv;Object.values(r.ChainId).filter((e=>"number"==typeof e)).map((e=>{const t=u.getUniswapV3FactoryContractAddressByChainId(e),n=u.getNonfungiblePositionManagerContractAddressByChainId(e);t&&(Tv[e]=t),n&&(Bv[e]=n)})),r.ChainId.MAINNET,r.ChainId.ARBITRUM_ONE,r.ChainId.SEPOLIA,r.ChainId.TAIKO,function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(Iv||(Iv={})),function(e){e[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP"}(Sv||(Sv={}));const Av=E.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ev={[Sv.ROUND_DOWN]:a.ROUND_DOWN,[Sv.ROUND_HALF_UP]:a.ROUND_HALF_UP,[Sv.ROUND_UP]:a.ROUND_UP},Ov={[Sv.ROUND_DOWN]:a.ROUND_DOWN,[Sv.ROUND_HALF_UP]:a.ROUND_HALF_UP,[Sv.ROUND_UP]:a.ROUND_UP};class Lv{constructor(e,t=E.BigInt(1)){this.numerator=E.BigInt(e),this.denominator=E.BigInt(t)}static tryParseFraction(e){if(e instanceof E||"number"==typeof e||"string"==typeof e)return new Lv(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return E.divide(this.numerator,this.denominator)}get remainder(){return new Lv(E.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new Lv(this.denominator,this.numerator)}add(e){const t=Lv.tryParseFraction(e);return E.equal(this.denominator,t.denominator)?new Lv(E.add(this.numerator,t.numerator),this.denominator):new Lv(E.add(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator)),E.multiply(this.denominator,t.denominator))}subtract(e){const t=Lv.tryParseFraction(e);return E.equal(this.denominator,t.denominator)?new Lv(E.subtract(this.numerator,t.numerator),this.denominator):new Lv(E.subtract(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator)),E.multiply(this.denominator,t.denominator))}lessThan(e){const t=Lv.tryParseFraction(e);return E.lessThan(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}equalTo(e){const t=Lv.tryParseFraction(e);return E.equal(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}greaterThan(e){const t=Lv.tryParseFraction(e);return E.greaterThan(E.multiply(this.numerator,t.denominator),E.multiply(t.numerator,this.denominator))}multiply(e){const t=Lv.tryParseFraction(e);return new Lv(E.multiply(this.numerator,t.numerator),E.multiply(this.denominator,t.denominator))}divide(e){const t=Lv.tryParseFraction(e);return new Lv(E.multiply(this.numerator,t.denominator),E.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=Sv.ROUND_HALF_UP){O(Number.isInteger(e),`${e} is not an integer.`),O(e>0,`${e} is not positive.`);const i=Ev[n],o=new a(this.numerator.toString()).div(this.denominator.toString()).precision(e,i);return o.toFormat(o.decimalPlaces(),i,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=Sv.ROUND_HALF_UP){O(Number.isInteger(e),`${e} is not an integer.`),O(e>=0,`${e} is negative.`);const i=Ov[n];return new a(this.numerator.toString()).decimalPlaces(e,i).div(this.denominator.toString()).toFormat(e,i,t)}get asFraction(){return new Lv(this.numerator,this.denominator)}}class Rv extends Lv{static fromRawAmount(e,t){return new Rv(e,t)}static fromFractionalAmount(e,t,n){return new Rv(e,t,n)}constructor(e,t,n){super(t,n),O(E.lessThanOrEqual(this.quotient,Av),"AMOUNT"),this.currency=e,this.decimalScale=E.exponentiate(E.BigInt(10),E.BigInt(e.decimals))}add(e){O(this.currency.equals(e.currency),"CURRENCY");const t=super.add(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}subtract(e){O(this.currency.equals(e.currency),"CURRENCY");const t=super.subtract(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}multiply(e){const t=super.multiply(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}divide(e){const t=super.divide(e);return Rv.fromFractionalAmount(this.currency,t.numerator,t.denominator)}toSignificant(e=6,t,n=Sv.ROUND_DOWN){return super.divide(this.decimalScale).toSignificant(e,t,n)}toFixed(e=this.currency.decimals,t,n=Sv.ROUND_DOWN){return O(e<=this.currency.decimals,"DECIMALS"),super.divide(this.decimalScale).toFixed(e,t,n)}toExact(){return new a(this.quotient.toString()).div(this.decimalScale.toString())}get wrapped(){return this.currency.isToken?this:Rv.fromFractionalAmount(this.currency.wrapped,this.numerator,this.denominator)}}const Mv=new Lv(E.BigInt(100));function Pv(e){return new _v(e.numerator,e.denominator)}class _v extends Lv{constructor(){super(...arguments),this.isPercent=!0}add(e){return Pv(super.add(e))}subtract(e){return Pv(super.subtract(e))}multiply(e){return Pv(super.multiply(e))}divide(e){return Pv(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(Mv).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(Mv).toFixed(e,t,n)}}class Nv extends Lv{constructor(...e){let t,n,i,o;if(4===e.length)[t,n,i,o]=e;else{const r=e[0].quoteAmount.divide(e[0].baseAmount);[t,n,i,o]=[e[0].baseAmount.currency,e[0].quoteAmount.currency,r.denominator,r.numerator]}super(o,i),this.baseCurrency=t,this.quoteCurrency=n,this.scalar=new Lv(E.exponentiate(E.BigInt(10),E.BigInt(t.decimals)),E.exponentiate(E.BigInt(10),E.BigInt(n.decimals)))}invert(){return new Nv(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)}multiply(e){O(this.quoteCurrency.equals(e.baseCurrency),"TOKEN");const t=super.multiply(e);return new Nv(this.baseCurrency,e.quoteCurrency,t.denominator,t.numerator)}quote(e){O(e.currency.equals(this.baseCurrency),"TOKEN");const t=super.multiply(e);return Rv.fromFractionalAmount(this.quoteCurrency,t.numerator,t.denominator)}get adjustedForDecimals(){return super.multiply(this.scalar)}toSignificant(e=6,t,n){return this.adjustedForDecimals.toSignificant(e,t,n)}toFixed(e=4,t,n){return this.adjustedForDecimals.toFixed(e,t,n)}}class Dv{constructor(e,t,n,i){O(Number.isSafeInteger(e),"CHAIN_ID"),O(t>=0&&t<255&&Number.isInteger(t),"DECIMALS"),this.chainId=e,this.decimals=t,this.symbol=n,this.name=i}}function Fv(e){try{return su(e)}catch(t){throw new Error(`${e} is not a valid address.`)}}const Uv=/^0x[0-9a-fA-F]{40}$/;class qv extends Dv{constructor(e,t,n,i,o,r,a,s){super(e,n,i,o),this.isNative=!1,this.isToken=!0,this.address=r?function(e){if(Uv.test(e))return e;throw new Error(`${e} is not a valid address.`)}(t):Fv(t),a&&O(a.gte(x.BigNumber.from(0)),"NON-NEGATIVE FOT FEES"),s&&O(s.gte(x.BigNumber.from(0)),"NON-NEGATIVE FOT FEES"),this.buyFeeBps=a,this.sellFeeBps=s}equals(e){return e.isToken&&this.chainId===e.chainId&&this.address.toLowerCase()===e.address.toLowerCase()}sortsBefore(e){return O(this.chainId===e.chainId,"CHAIN_IDS"),O(this.address.toLowerCase()!==e.address.toLowerCase(),"ADDRESSES"),this.address.toLowerCase()<e.address.toLowerCase()}get wrapped(){return this}}const Vv=E.BigInt(Number.MAX_SAFE_INTEGER),Hv=E.BigInt(0),Wv=E.BigInt(1),$v=E.BigInt(2);const zv=E.BigInt(0),Zv=1e4;new _v(E.BigInt(1),Zv),new _v(1,100),new _v(3,100),new _v(5,100),new _v(10,100),new _v(15,100);const Qv=new _v(0);new _v(1);const Gv="0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";var Yv;!function(e){e[e.LOWEST=100]="LOWEST",e[e.LOW_200=200]="LOW_200",e[e.LOW_300=300]="LOW_300",e[e.LOW_400=400]="LOW_400",e[e.LOW=500]="LOW",e[e.MEDIUM=3e3]="MEDIUM",e[e.HIGH=1e4]="HIGH"}(Yv||(Yv={}));const Kv={[Yv.LOWEST]:1,[Yv.LOW_200]:4,[Yv.LOW_300]:6,[Yv.LOW_400]:8,[Yv.LOW]:10,[Yv.MEDIUM]:60,[Yv.HIGH]:200},Xv=E.BigInt(-1),Jv=E.BigInt(0),eb=E.BigInt(1),tb=E.exponentiate(E.BigInt(2),E.BigInt(96)),nb=E.exponentiate(tb,E.BigInt(2)),ib=new Dc("properties/5.8.0");function ob(e,t,n){Object.defineProperty(e,t,{enumerable:!0,value:n,writable:!1})}function rb(e,t){for(let n=0;n<32;n++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}const ab={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function sb(e){if(null==e||ab[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const t=Object.keys(e);for(let n=0;n<t.length;n++){let i=null;try{i=e[t[n]]}catch(e){continue}if(!sb(i))return!1}return!0}return ib.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function lb(e){if(sb(e))return e;if(Array.isArray(e))return Object.freeze(e.map((e=>db(e))));if("object"==typeof e){const t={};for(const n in e){const i=e[n];void 0!==i&&ob(t,n,db(i))}return t}return ib.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function db(e){return lb(e)}class cb{constructor(e){for(const t in e)this[t]=db(e[t])}}const ub="abi/5.8.0",pb=new Dc(ub),hb={};let mb={calldata:!0,memory:!0,storage:!0},gb={calldata:!0,memory:!0};function xb(e,t){if("bytes"===e||"string"===e){if(mb[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&gb[t])return!0;return(mb[t]||"payable"===t)&&pb.throwArgumentError("invalid modifier","name",t),!1}function fb(e,t){for(let n in t)ob(e,n,t[n])}const yb=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vb=new RegExp(/^(.*)\[([0-9]*)\]$/);class bb{constructor(e,t){e!==hb&&pb.throwError("use fromString",Dc.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),fb(this,t);let n=this.type.match(vb);fb(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:bb.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==yb.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===yb.full?", ":",")+")"):t+=this.type,e!==yb.sighash&&(!0===this.indexed&&(t+=" indexed"),e===yb.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?bb.fromString(e,t):bb.fromObject(e)}static fromObject(e){return bb.isParamType(e)?e:new bb(hb,{name:e.name||null,type:Ob(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(bb.fromObject):null})}static fromString(e,t){return n=function(e,t){let n=e;function i(t){pb.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function o(e){let n={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(n.indexed=!1),n}e=e.replace(/\s/g," ");let r={type:"",name:"",state:{allowType:!0}},a=r;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(n),a.state.allowType=!1,a.type=Ob(a.type),a.components=[o(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),xb(a.type,a.name)&&(a.name=""),a.type=Ob(a.type);let e=a;a=a.parent,a||i(n),delete e.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),xb(a.type,a.name)&&(a.name=""),a.type=Ob(a.type);let s=o(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Ob(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(t||i(n),a.indexed&&i(n),a.indexed=!0,a.name=""):xb(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(n),a.type+=r,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(n),a.type+=r,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=r,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=r,delete a.state.allowArray):a.state.readArray?a.type+=r:i(n)}}return a.parent&&pb.throwArgumentError("unexpected eof","param",e),delete r.state,"indexed"===a.name?(t||i(n.length-7),a.indexed&&i(n.length-7),a.indexed=!0,a.name=""):xb(a.type,a.name)&&(a.name=""),r.type=Ob(r.type),r}(e,!!t),bb.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components});var n}static isParamType(e){return!(null==e||!e._isParamType)}}function Cb(e,t){return function(e){e=e.trim();let t=[],n="",i=0;for(let o=0;o<e.length;o++){let r=e[o];","===r&&0===i?(t.push(n),n=""):(n+=r,"("===r?i++:")"===r&&(i--,-1===i&&pb.throwArgumentError("unbalanced parenthesis","value",e)))}n&&t.push(n);return t}(e).map((e=>bb.fromString(e,t)))}class jb{constructor(e,t){e!==hb&&pb.throwError("use a static from method",Dc.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),fb(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return jb.isFragment(e)?e:"string"==typeof e?jb.fromString(e):jb.fromObject(e)}static fromObject(e){if(jb.isFragment(e))return e;switch(e.type){case"function":return Sb.fromObject(e);case"event":return wb.fromObject(e);case"constructor":return Ib.fromObject(e);case"error":return Eb.fromObject(e);case"fallback":case"receive":return null}return pb.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?wb.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?Sb.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?Ib.fromString(e.trim()):"error"===e.split(" ")[0]?Eb.fromString(e.substring(5).trim()):pb.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class wb extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",e!==yb.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?wb.fromString(e):wb.fromObject(e)}static fromObject(e){if(wb.isEventFragment(e))return e;"event"!==e.type&&pb.throwArgumentError("invalid event object","value",e);const t={name:Rb(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(bb.fromObject):[],type:"event"};return new wb(hb,t)}static fromString(e){let t=e.match(Mb);t||pb.throwArgumentError("invalid event string","value",e);let n=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":n=!0;break;case"":break;default:pb.warn("unknown modifier: "+e)}})),wb.fromObject({name:t[1].trim(),anonymous:n,inputs:Cb(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function kb(e,t){t.gas=null;let n=e.split("@");return 1!==n.length?(n.length>2&&pb.throwArgumentError("invalid human-readable ABI signature","value",e),n[1].match(/^[0-9]+$/)||pb.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=x.BigNumber.from(n[1]),n[0]):e}function Tb(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function Bb(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&pb.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&pb.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||pb.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&pb.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&pb.throwArgumentError("unable to determine stateMutability","value",e),t}class Ib extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===yb.sighash&&pb.throwError("cannot format a constructor for sighash",Dc.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?Ib.fromString(e):Ib.fromObject(e)}static fromObject(e){if(Ib.isConstructorFragment(e))return e;"constructor"!==e.type&&pb.throwArgumentError("invalid constructor object","value",e);let t=Bb(e);t.constant&&pb.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(bb.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?x.BigNumber.from(e.gas):null};return new Ib(hb,n)}static fromString(e){let t={type:"constructor"},n=(e=kb(e,t)).match(Mb);return n&&"constructor"===n[1].trim()||pb.throwArgumentError("invalid constructor string","value",e),t.inputs=Cb(n[2].trim(),!1),Tb(n[3].trim(),t),Ib.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class Sb extends Ib{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",e!==yb.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?Sb.fromString(e):Sb.fromObject(e)}static fromObject(e){if(Sb.isFunctionFragment(e))return e;"function"!==e.type&&pb.throwArgumentError("invalid function object","value",e);let t=Bb(e);const n={type:e.type,name:Rb(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(bb.fromObject):[],outputs:e.outputs?e.outputs.map(bb.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?x.BigNumber.from(e.gas):null};return new Sb(hb,n)}static fromString(e){let t={type:"function"},n=(e=kb(e,t)).split(" returns ");n.length>2&&pb.throwArgumentError("invalid function string","value",e);let i=n[0].match(Mb);if(i||pb.throwArgumentError("invalid function signature","value",e),t.name=i[1].trim(),t.name&&Rb(t.name),t.inputs=Cb(i[2],!1),Tb(i[3].trim(),t),n.length>1){let i=n[1].match(Mb);""==i[1].trim()&&""==i[3].trim()||pb.throwArgumentError("unexpected tokens","value",e),t.outputs=Cb(i[2],!1)}else t.outputs=[];return Sb.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function Ab(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||pb.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class Eb extends jb{format(e){if(e||(e=yb.sighash),yb[e]||pb.throwArgumentError("invalid format type","format",e),e===yb.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==yb.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===yb.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?Eb.fromString(e):Eb.fromObject(e)}static fromObject(e){if(Eb.isErrorFragment(e))return e;"error"!==e.type&&pb.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:Rb(e.name),inputs:e.inputs?e.inputs.map(bb.fromObject):[]};return Ab(new Eb(hb,t))}static fromString(e){let t={type:"error"},n=e.match(Mb);return n||pb.throwArgumentError("invalid error signature","value",e),t.name=n[1].trim(),t.name&&Rb(t.name),t.inputs=Cb(n[2],!1),Ab(Eb.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function Ob(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const Lb=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Rb(e){return e&&e.match(Lb)||pb.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const Mb=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Pb=new Dc(ub);class _b{constructor(e,t,n,i){this.name=e,this.type=t,this.localName=n,this.dynamic=i}_throwError(e,t){Pb.throwArgumentError(e,this.localName,t)}}class Nb{constructor(e){ob(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let t="0x";return e.forEach((e=>{t+=Gc(e).substring(2)})),t}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData($c(e._data))}writeBytes(e){let t=Wc(e);const n=t.length%this.wordSize;return n&&(t=$c([t,this._padding.slice(n)])),this._writeData(t)}_getValue(e){let t=Wc(x.BigNumber.from(e));return t.length>this.wordSize&&Pb.throwError("value out-of-bounds",Dc.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=$c([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class Db{constructor(e,t,n,i){ob(this,"_data",Wc(e)),ob(this,"wordSize",t||32),ob(this,"_coerceFunc",n),ob(this,"allowLoose",i),this._offset=0}get data(){return Gc(this._data)}get consumed(){return this._offset}static coerce(e,t){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):Db.coerce(e,t)}_peekBytes(e,t,n){let i=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+t<=this._data.length?i=t:Pb.throwError("data out-of-bounds",Dc.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new Db(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let n=this._peekBytes(0,e,!!t);return this._offset+=n.length,n.slice(0,e)}readValue(){return x.BigNumber.from(this.readBytes(this.wordSize))}}class Fb extends _b{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=su(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return su(Xc(e.readValue().toHexString(),20))}}class Ub extends _b{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const qb=new Dc(ub);function Vb(e,t,n){let i=null;if(Array.isArray(n))i=n;else if(n&&"object"==typeof n){let e={};i=t.map((t=>{const i=t.localName;return i||qb.throwError("cannot encode object for signature with missing names",Dc.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]&&qb.throwError("cannot encode object for signature with duplicate names",Dc.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]=!0,n[i]}))}else qb.throwArgumentError("invalid tuple value","tuple",n);t.length!==i.length&&qb.throwArgumentError("types/value length mismatch","tuple",n);let o=new Nb(e.wordSize),r=new Nb(e.wordSize),a=[];t.forEach(((e,t)=>{let n=i[t];if(e.dynamic){let t=r.length;e.encode(r,n);let i=o.writeUpdatableValue();a.push((e=>{i(e+t)}))}else e.encode(o,n)})),a.forEach((e=>{e(o.length)}));let s=e.appendWriter(o);return s+=e.appendWriter(r),s}function Hb(e,t){let n=[],i=e.subReader(0);t.forEach((t=>{let o=null;if(t.dynamic){let n=e.readValue(),r=i.subReader(n.toNumber());try{o=t.decode(r)}catch(e){if(e.code===Dc.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}}else try{o=t.decode(e)}catch(e){if(e.code===Dc.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}null!=o&&n.push(o)}));const o=t.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});t.forEach(((e,t)=>{let i=e.localName;if(!i||1!==o[i])return;if("length"===i&&(i="_length"),null!=n[i])return;const r=n[t];r instanceof Error?Object.defineProperty(n,i,{enumerable:!0,get:()=>{throw r}}):n[i]=r}));for(let e=0;e<n.length;e++){const t=n[e];t instanceof Error&&Object.defineProperty(n,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(n)}class Wb extends _b{constructor(e,t,n){super("array",e.type+"["+(t>=0?t:"")+"]",n,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let n=this.length;-1===n&&(n=t.length,e.writeValue(t.length)),qb.checkArgumentCount(t.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let e=0;e<t.length;e++)i.push(this.coder);return Vb(e,i,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&qb.throwError("insufficient data length",Dc.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let n=[];for(let e=0;e<t;e++)n.push(new Ub(this.coder));return e.coerce(this.name,Hb(e,n))}}class $b extends _b{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class zb extends _b{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Wc(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Zb extends zb{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Gc(super.decode(e)))}}class Qb extends _b{constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let n=Wc(t);return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return e.coerce(this.name,Gc(e.readBytes(this.size)))}}class Gb extends _b{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}class Yb extends _b{constructor(e,t,n){const i=(t?"int":"uint")+8*e;super(i,i,n,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let n=x.BigNumber.from(t),i=pu.mask(8*e.wordSize);if(this.signed){let e=i.mask(8*this.size-1);(n.gt(e)||n.lt(e.add(uu).mul(du)))&&this._throwError("value out-of-bounds",t)}else(n.lt(cu)||n.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return n=n.toTwos(8*this.size).mask(8*this.size),this.signed&&(n=n.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(n)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Kb extends zb{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,yu(t))}decode(e){return vu(super.decode(e))}}class Xb extends _b{constructor(e,t){let n=!1;const i=[];e.forEach((e=>{e.dynamic&&(n=!0),i.push(e.type)}));super("tuple","tuple("+i.join(",")+")",t,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});return this.coders.forEach(((n,i)=>{let o=n.localName;o&&1===t[o]&&("length"===o&&(o="_length"),null==e[o]&&(e[o]=e[i]))})),Object.freeze(e)}encode(e,t){return Vb(e,this.coders,t)}decode(e){return e.coerce(this.name,Hb(e,this.coders))}}const Jb=new Dc(ub),eC=new RegExp(/^bytes([0-9]*)$/),tC=new RegExp(/^(u?int)([0-9]*)$/);const nC=new class{constructor(e){ob(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new Fb(e.name);case"bool":return new $b(e.name);case"string":return new Kb(e.name);case"bytes":return new Zb(e.name);case"array":return new Wb(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new Xb((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Gb(e.name)}let t=e.type.match(tC);if(t){let n=parseInt(t[2]||"256");return(0===n||n>256||n%8!=0)&&Jb.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Yb(n/8,"int"===t[1],e.name)}if(t=e.type.match(eC),t){let n=parseInt(t[1]);return(0===n||n>32)&&Jb.throwArgumentError("invalid bytes length","param",e),new Qb(n,e.name)}return Jb.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new Db(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new Nb(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(bb.from(e))));return new Xb(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&Jb.throwError("types/values length mismatch",Dc.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const n=e.map((e=>this._getCoder(bb.from(e)))),i=new Xb(n,"_"),o=this._getWriter();return i.encode(o,t),o.data}decode(e,t,n){const i=e.map((e=>this._getCoder(bb.from(e))));return new Xb(i,"_").decode(this._getReader(Wc(t),n))}};function iC(e){return tu(yu(e))}const oC=new Dc(ub);class rC extends cb{}class aC extends cb{}class sC extends cb{}class lC extends cb{static isIndexed(e){return!(!e||!e._isIndexed)}}const dC={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function cC(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return n.error=t,n}class uC{constructor(e){let t=[];t="string"==typeof e?JSON.parse(e):e,ob(this,"fragments",t.map((e=>jb.from(e))).filter((e=>null!=e))),ob(this,"_abiCoder",rb(new.target,"getAbiCoder")()),ob(this,"functions",{}),ob(this,"errors",{}),ob(this,"events",{}),ob(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void oC.warn("duplicate definition - constructor"):void ob(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let n=e.format();t[n]?oC.warn("duplicate definition - "+n):t[n]=e})),this.deploy||ob(this,"deploy",Ib.from({payable:!1,type:"constructor"})),ob(this,"_isInterface",!0)}format(e){e||(e=yb.full),e===yb.sighash&&oC.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===yb.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return nC}static getAddress(e){return su(e)}static getSighash(e){return Kc(iC(e.format()),0,4)}static getEventTopic(e){return iC(e.format())}getFunction(e){if(Zc(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];oC.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching function","name",t):n.length>1&&oC.throwArgumentError("multiple matching functions","name",t),this.functions[n[0]]}const t=this.functions[Sb.fromString(e).format()];return t||oC.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Zc(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];oC.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching event","name",t):n.length>1&&oC.throwArgumentError("multiple matching events","name",t),this.events[n[0]]}const t=this.events[wb.fromString(e).format()];return t||oC.throwArgumentError("no matching event","signature",e),t}getError(e){if(Zc(e)){const t=rb(this.constructor,"getSighash");for(const n in this.errors){if(e===t(this.errors[n]))return this.errors[n]}oC.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===n.length?oC.throwArgumentError("no matching error","name",t):n.length>1&&oC.throwArgumentError("multiple matching errors","name",t),this.errors[n[0]]}const t=this.errors[Sb.fromString(e).format()];return t||oC.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return rb(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),rb(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const n=Wc(t);return Gc(n.slice(0,4))!==this.getSighash(e)&&oC.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Gc(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Gc($c([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const n=Wc(t);return Gc(n.slice(0,4))!==this.getSighash(e)&&oC.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Gc(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Gc($c([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let n=Wc(t),i=null,o="",r=null,a=null,s=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch(e){}break;case 4:{const e=Gc(n.slice(0,4)),t=dC[e];if(t)r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.signature,t.reason&&(i=r[0]),"Error"===a?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(r[0])}`:"Panic"===a&&(o=`; VM Exception while processing transaction: reverted with panic code ${r[0]}`);else try{const t=this.getError(e);r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.format()}catch(e){}break}}return oC.throwError("call revert exception"+o,Dc.errors.CALL_EXCEPTION,{method:e.format(),data:Gc(t),errorArgs:r,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Gc(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&oC.throwError("too many arguments for "+e.format(),Dc.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(e,t)=>"string"===e.type?iC(t):"bytes"===e.type?tu(Gc(t)):("bool"===e.type&&"boolean"==typeof t&&(t=t?"0x01":"0x00"),e.type.match(/^u?int/)&&(t=x.BigNumber.from(t).toHexString()),"address"===e.type&&this._abiCoder.encode(["address"],[t]),Xc(Gc(t),32));for(t.forEach(((t,o)=>{let r=e.inputs[o];r.indexed?null==t?n.push(null):"array"===r.baseType||"tuple"===r.baseType?oC.throwArgumentError("filtering with tuples or arrays not supported","contract."+r.name,t):Array.isArray(t)?n.push(t.map((e=>i(r,e)))):n.push(i(r,t)):null!=t&&oC.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+r.name,t)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const n=[],i=[],o=[];return e.anonymous||n.push(this.getEventTopic(e)),t.length!==e.inputs.length&&oC.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,r)=>{const a=t[r];if(e.indexed)if("string"===e.type)n.push(iC(a));else if("bytes"===e.type)n.push(tu(a));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");n.push(this._abiCoder.encode([e.type],[a]))}else i.push(e),o.push(a)})),{data:this._abiCoder.encode(i,o),topics:n}}decodeEventLog(e,t,n){if("string"==typeof e&&(e=this.getEvent(e)),null!=n&&!e.anonymous){let t=this.getEventTopic(e);Zc(n[0],32)&&n[0].toLowerCase()===t||oC.throwError("fragment/topic mismatch",Dc.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:n[0]}),n=n.slice(1)}let i=[],o=[],r=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(bb.fromObject({type:"bytes32",name:e.name})),r.push(!0)):(i.push(e),r.push(!1)):(o.push(e),r.push(!1))}));let a=null!=n?this._abiCoder.decode(i,$c(n)):null,s=this._abiCoder.decode(o,t,!0),l=[],d=0,c=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==a)l[t]=new lC({_isIndexed:!0,hash:null});else if(r[t])l[t]=new lC({_isIndexed:!0,hash:a[c++]});else try{l[t]=a[c++]}catch(e){l[t]=e}else try{l[t]=s[d++]}catch(e){l[t]=e}if(e.name&&null==l[e.name]){const n=l[t];n instanceof Error?Object.defineProperty(l,e.name,{enumerable:!0,get:()=>{throw cC(`property ${JSON.stringify(e.name)}`,n)}}):l[e.name]=n}}));for(let e=0;e<l.length;e++){const t=l[e];t instanceof Error&&Object.defineProperty(l,e,{enumerable:!0,get:()=>{throw cC(`index ${e}`,t)}})}return Object.freeze(l)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new aC({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:x.BigNumber.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new rC({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Gc(e);let n=this.getError(t.substring(0,10).toLowerCase());return n?new sC({args:this._abiCoder.decode(n.inputs,"0x"+t.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!(!e||!e._isInterface)}}function pC({factoryAddress:e,tokenA:t,tokenB:n,fee:i,initCodeHashManualOverride:o,chainId:a}){const[s,l]=t.sortsBefore(n)?[t,n]:[n,t],d=Iu(["bytes"],[nC.encode(["address","address","uint24"],[s.address,l.address,i])]),c=null!=o?o:function(e){switch(e){case r.ChainId.TAIKO:case r.ChainId.ZETACHAIN:case r.ChainId.ZETACHAIN_TESTNET:return"0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";case r.ChainId.SEPOLIA:return"0x4509fa1e2d1989ac1632a56fe87c53e8d1e9d05847694e00f62b23e28cec98c4";default:return Gv}}(a);return lu(e,d,c)}const hC=E.BigInt(2),mC=[128,64,32,16,8,4,2,1].map((e=>[e,E.exponentiate(hC,E.BigInt(e))]));function gC(e,t){return E.signedRightShift(E.multiply(e,E.BigInt(t)),E.BigInt(128))}const xC=E.exponentiate(E.BigInt(2),E.BigInt(32));class fC{constructor(){}static getSqrtRatioAtTick(e){O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK&&Number.isInteger(e),"TICK");const t=e<0?-1*e:e;let n=1&t?E.BigInt("0xfffcb933bd6fad37aa2d162d1a594001"):E.BigInt("0x100000000000000000000000000000000");return 2&t&&(n=gC(n,"0xfff97272373d413259a46990580e213a")),4&t&&(n=gC(n,"0xfff2e50f5f656932ef12357cf3c7fdcc")),8&t&&(n=gC(n,"0xffe5caca7e10e4e61c3624eaa0941cd0")),16&t&&(n=gC(n,"0xffcb9843d60f6159c9db58835c926644")),32&t&&(n=gC(n,"0xff973b41fa98c081472e6896dfb254c0")),64&t&&(n=gC(n,"0xff2ea16466c96a3843ec78b326b52861")),128&t&&(n=gC(n,"0xfe5dee046a99a2a811c461f1969c3053")),256&t&&(n=gC(n,"0xfcbe86c7900a88aedcffc83b479aa3a4")),512&t&&(n=gC(n,"0xf987a7253ac413176f2b074cf7815e54")),1024&t&&(n=gC(n,"0xf3392b0822b70005940c7a398e4b70f3")),2048&t&&(n=gC(n,"0xe7159475a2c29b7443b29c7fa6e889d9")),4096&t&&(n=gC(n,"0xd097f3bdfd2022b8845ad8f792aa5825")),8192&t&&(n=gC(n,"0xa9f746462d870fdf8a65dc1f90e061e5")),16384&t&&(n=gC(n,"0x70d869a156d2a1b890bb3df62baf32f7")),32768&t&&(n=gC(n,"0x31be135f97d08fd981231505542fcfa6")),65536&t&&(n=gC(n,"0x9aa508b5b7a84e1c677de54f3e99bc9")),131072&t&&(n=gC(n,"0x5d6af8dedb81196699c329225ee604")),262144&t&&(n=gC(n,"0x2216e584f5fa1ea926041bedfe98")),524288&t&&(n=gC(n,"0x48a170391f7dc42444e8fa2")),e>0&&(n=E.divide(Av,n)),E.greaterThan(E.remainder(n,xC),Jv)?E.add(E.divide(n,xC),eb):E.divide(n,xC)}static getTickAtSqrtRatio(e){O(E.greaterThanOrEqual(e,fC.MIN_SQRT_RATIO)&&E.lessThan(e,fC.MAX_SQRT_RATIO),"SQRT_RATIO");const t=E.leftShift(e,E.BigInt(32)),n=function(e){O(E.greaterThan(e,Jv),"ZERO"),O(E.lessThanOrEqual(e,Av),"MAX");let t=0;for(const[n,i]of mC)E.greaterThanOrEqual(e,i)&&(e=E.signedRightShift(e,E.BigInt(n)),t+=n);return t}(t);let i;i=E.greaterThanOrEqual(E.BigInt(n),E.BigInt(128))?E.signedRightShift(t,E.BigInt(n-127)):E.leftShift(t,E.BigInt(127-n));let o=E.leftShift(E.subtract(E.BigInt(n),E.BigInt(128)),E.BigInt(64));for(let e=0;e<14;e++){i=E.signedRightShift(E.multiply(i,i),E.BigInt(127));const t=E.signedRightShift(i,E.BigInt(128));o=E.bitwiseOr(o,E.leftShift(t,E.BigInt(63-e))),i=E.signedRightShift(i,t)}const r=E.multiply(o,E.BigInt("255738958999603826347141")),a=E.toNumber(E.signedRightShift(E.subtract(r,E.BigInt("3402992956809132418596140100660247210")),E.BigInt(128))),s=E.toNumber(E.signedRightShift(E.add(r,E.BigInt("291339464771989622907027621153398088495")),E.BigInt(128)));return a===s?a:E.lessThanOrEqual(fC.getSqrtRatioAtTick(s),e)?s:a}}fC.MIN_TICK=-887272,fC.MAX_TICK=-fC.MIN_TICK,fC.MIN_SQRT_RATIO=E.BigInt("4295128739"),fC.MAX_SQRT_RATIO=E.BigInt("1461446703485210103287273052203988822378723970342");class yC{constructor(){}static mulDivRoundingUp(e,t,n){const i=E.multiply(e,t);let o=E.divide(i,n);return E.notEqual(E.remainder(i,n),Jv)&&(o=E.add(o,eb)),o}}const vC=E.subtract(E.exponentiate(E.BigInt(2),E.BigInt(160)),eb);function bC(e,t){const n=E.multiply(e,t);return E.bitwiseAnd(n,Av)}class CC{constructor(){}static getAmount0Delta(e,t,n,i){E.greaterThan(e,t)&&([e,t]=[t,e]);const o=E.leftShift(n,E.BigInt(96)),r=E.subtract(t,e);return i?yC.mulDivRoundingUp(yC.mulDivRoundingUp(o,r,t),eb,e):E.divide(E.divide(E.multiply(o,r),t),e)}static getAmount1Delta(e,t,n,i){return E.greaterThan(e,t)&&([e,t]=[t,e]),i?yC.mulDivRoundingUp(n,E.subtract(t,e),tb):E.divide(E.multiply(n,E.subtract(t,e)),tb)}static getNextSqrtPriceFromInput(e,t,n,i){return O(E.greaterThan(e,Jv)),O(E.greaterThan(t,Jv)),i?this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!0)}static getNextSqrtPriceFromOutput(e,t,n,i){return O(E.greaterThan(e,Jv)),O(E.greaterThan(t,Jv)),i?this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!1)}static getNextSqrtPriceFromAmount0RoundingUp(e,t,n,i){if(E.equal(n,Jv))return e;const o=E.leftShift(t,E.BigInt(96));if(i){let t=bC(n,e);if(E.equal(E.divide(t,n),e)){const n=function(e,t){const n=E.add(e,t);return E.bitwiseAnd(n,Av)}(o,t);if(E.greaterThanOrEqual(n,o))return yC.mulDivRoundingUp(o,e,n)}return yC.mulDivRoundingUp(o,eb,E.add(E.divide(o,e),n))}{let t=bC(n,e);O(E.equal(E.divide(t,n),e)),O(E.greaterThan(o,t));const i=E.subtract(o,t);return yC.mulDivRoundingUp(o,e,i)}}static getNextSqrtPriceFromAmount1RoundingDown(e,t,n,i){if(i){const i=E.lessThanOrEqual(n,vC)?E.divide(E.leftShift(n,E.BigInt(96)),t):E.divide(E.multiply(n,tb),t);return E.add(e,i)}{const i=yC.mulDivRoundingUp(n,tb,t);return O(E.greaterThan(e,i)),E.subtract(e,i)}}}const jC=E.exponentiate(E.BigInt(10),E.BigInt(6));class wC{constructor(){}static computeSwapStep(e,t,n,i,o){const r={};o=E.BigInt(o);const a=E.greaterThanOrEqual(e,t),s=E.greaterThanOrEqual(i,Jv);if(s){const s=E.divide(E.multiply(i,E.subtract(jC,o)),jC);r.amountIn=a?CC.getAmount0Delta(t,e,n,!0):CC.getAmount1Delta(e,t,n,!0),E.greaterThanOrEqual(s,r.amountIn)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=CC.getNextSqrtPriceFromInput(e,n,s,a)}else r.amountOut=a?CC.getAmount1Delta(t,e,n,!1):CC.getAmount0Delta(e,t,n,!1),E.greaterThanOrEqual(E.multiply(i,Xv),r.amountOut)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=CC.getNextSqrtPriceFromOutput(e,n,E.multiply(i,Xv),a);const l=E.equal(t,r.sqrtRatioNextX96);return a?(r.amountIn=l&&s?r.amountIn:CC.getAmount0Delta(r.sqrtRatioNextX96,e,n,!0),r.amountOut=l&&!s?r.amountOut:CC.getAmount1Delta(r.sqrtRatioNextX96,e,n,!1)):(r.amountIn=l&&s?r.amountIn:CC.getAmount1Delta(e,r.sqrtRatioNextX96,n,!0),r.amountOut=l&&!s?r.amountOut:CC.getAmount0Delta(e,r.sqrtRatioNextX96,n,!1)),!s&&E.greaterThan(r.amountOut,E.multiply(i,Xv))&&(r.amountOut=E.multiply(i,Xv)),s&&E.notEqual(r.sqrtRatioNextX96,t)?r.feeAmount=E.subtract(i,r.amountIn):r.feeAmount=yC.mulDivRoundingUp(r.amountIn,o,E.subtract(jC,o)),[r.sqrtRatioNextX96,r.amountIn,r.amountOut,r.feeAmount]}}class kC{constructor(){}static addDelta(e,t){return E.lessThan(t,Jv)?E.subtract(e,E.multiply(t,Xv)):E.add(e,t)}}class TC{getTick(e){return q(this,void 0,void 0,(function*(){throw new Error(TC.ERROR_MESSAGE)}))}nextInitializedTickWithinOneWord(e,t,n){return q(this,void 0,void 0,(function*(){throw new Error(TC.ERROR_MESSAGE)}))}}function BC(e,t){return e.index-t.index}TC.ERROR_MESSAGE="No tick data provider was given";class IC{constructor(){}static validateList(e,t){O(t>0,"TICK_SPACING_NONZERO"),O(e.every((({index:e})=>e%t==0)),"TICK_SPACING"),O(E.equal(e.reduce(((e,{liquidityNet:t})=>E.add(e,t)),Jv),Jv),"ZERO_NET"),O(function(e,t){for(let n=0;n<e.length-1;n++)if(t(e[n],e[n+1])>0)return!1;return!0}(e,BC),"SORTED")}static isBelowSmallest(e,t){return O(e.length>0,"LENGTH"),t<e[0].index}static isAtOrAboveLargest(e,t){return O(e.length>0,"LENGTH"),t>=e[e.length-1].index}static getTick(e,t){const n=e[this.binarySearch(e,t)];return O(n.index===t,"NOT_CONTAINED"),n}static binarySearch(e,t){O(!this.isBelowSmallest(e,t),"BELOW_SMALLEST");let n,i=0,o=e.length-1;for(;;){if(n=Math.floor((i+o)/2),e[n].index<=t&&(n===e.length-1||e[n+1].index>t))return n;e[n].index<t?i=n+1:o=n-1}}static nextInitializedTick(e,t,n){if(n){if(O(!IC.isBelowSmallest(e,t),"BELOW_SMALLEST"),IC.isAtOrAboveLargest(e,t))return e[e.length-1];return e[this.binarySearch(e,t)]}if(O(!this.isAtOrAboveLargest(e,t),"AT_OR_ABOVE_LARGEST"),this.isBelowSmallest(e,t))return e[0];return e[this.binarySearch(e,t)+1]}static nextInitializedTickWithinOneWord(e,t,n,i){const o=Math.floor(t/i);if(n){const r=(o>>8<<8)*i;if(IC.isBelowSmallest(e,t))return[r,!1];const a=IC.nextInitializedTick(e,t,n).index,s=Math.max(r,a);return[s,s===a]}{const r=(((o+1>>8)+1<<8)-1)*i;if(this.isAtOrAboveLargest(e,t))return[r,!1];const a=this.nextInitializedTick(e,t,n).index,s=Math.min(r,a);return[s,s===a]}}}function SC(e){let t=E.BigInt(e).toString(16);return t.length%2!=0&&(t=`0${t}`),`0x${t}`}function AC(e,t){const n=E.leftShift(E.BigInt(e),E.BigInt(192)),i=E.BigInt(t);return function(e){if(O(E.greaterThanOrEqual(e,Hv),"NEGATIVE"),E.lessThan(e,Vv))return E.BigInt(Math.floor(Math.sqrt(E.toNumber(e))));let t,n;for(t=e,n=E.add(E.divide(e,$v),Wv);E.lessThan(n,t);)t=n,n=E.divide(E.add(E.divide(e,n),n),$v);return t}(E.divide(n,i))}function EC(e,t,n){E.greaterThan(e,t)&&([e,t]=[t,e]);const i=E.divide(E.multiply(e,t),tb);return E.divide(E.multiply(E.BigInt(n),i),E.subtract(t,e))}function OC(e,t,n){E.greaterThan(e,t)&&([e,t]=[t,e]);const i=E.multiply(E.multiply(E.BigInt(n),e),t),o=E.multiply(tb,E.subtract(t,e));return E.divide(i,o)}function LC(e,t,n){return E.greaterThan(e,t)&&([e,t]=[t,e]),E.divide(E.multiply(E.BigInt(n),tb),E.subtract(t,e))}function RC(e,t,n,i,o,r){E.greaterThan(t,n)&&([t,n]=[n,t]);const a=r?OC:EC;if(E.lessThanOrEqual(e,t))return a(t,n,i);if(E.lessThan(e,n)){const r=a(e,n,i),s=LC(t,e,o);return E.lessThan(r,s)?r:s}return LC(t,n,o)}function MC(e,t){O(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),O(t>0,"TICK_SPACING"),O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<fC.MIN_TICK?n+t:n>fC.MAX_TICK?n-t:n}function PC(e,t,n){const i=fC.getSqrtRatioAtTick(n),o=E.multiply(i,i);return e.sortsBefore(t)?new Nv(e,t,nb,o):new Nv(e,t,o,nb)}function _C(e){const t=e.baseCurrency.sortsBefore(e.quoteCurrency),n=t?AC(e.numerator,e.denominator):AC(e.denominator,e.numerator);let i=fC.getTickAtSqrtRatio(n);const o=PC(e.baseCurrency,e.quoteCurrency,i+1);return t?e.lessThan(o)||i++:e.greaterThan(o)||i++,i}E.exponentiate(E.BigInt(2),E.BigInt(128)),E.exponentiate(E.BigInt(2),E.BigInt(256));class NC{constructor({index:e,liquidityGross:t,liquidityNet:n}){O(e>=fC.MIN_TICK&&e<=fC.MAX_TICK,"TICK"),this.index=e,this.liquidityGross=E.BigInt(t),this.liquidityNet=E.BigInt(n)}}class DC{constructor(e,t){const n=e.map((e=>e instanceof NC?e:new NC(e)));IC.validateList(n,t),this.ticks=n}getTick(e){return q(this,void 0,void 0,(function*(){return IC.getTick(this.ticks,e)}))}nextInitializedTickWithinOneWord(e,t,n){return q(this,void 0,void 0,(function*(){return IC.nextInitializedTickWithinOneWord(this.ticks,e,t,n)}))}}const FC=new TC;let UC=class e{static getAddress(e,t,n,i,o){return pC({factoryAddress:null!=o?o:"0x78172691DD3B8ADa7aEbd9bFfB487FB11D735DB2",fee:n,tokenA:e,tokenB:t,initCodeHashManualOverride:i})}constructor(e,t,n,i,o,r,a=FC){O(Number.isInteger(n)&&n<1e6,"FEE");const s=fC.getSqrtRatioAtTick(r),l=fC.getSqrtRatioAtTick(r+1);O(E.greaterThanOrEqual(E.BigInt(i),s)&&E.lessThanOrEqual(E.BigInt(i),l),"PRICE_BOUNDS"),[this.token0,this.token1]=e.sortsBefore(t)?[e,t]:[t,e],this.fee=n,this.sqrtRatioX96=E.BigInt(i),this.liquidity=E.BigInt(o),this.tickCurrent=r,this.tickDataProvider=Array.isArray(a)?new DC(a,Kv[n]):a}involvesToken(e){return e.equals(this.token0)||e.equals(this.token1)}get token0Price(){var e;return null!==(e=this._token0Price)&&void 0!==e?e:this._token0Price=new Nv(this.token0,this.token1,nb,E.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}get token1Price(){var e;return null!==(e=this._token1Price)&&void 0!==e?e:this._token1Price=new Nv(this.token1,this.token0,E.multiply(this.sqrtRatioX96,this.sqrtRatioX96),nb)}priceOf(e){return O(this.involvesToken(e),"TOKEN"),e.equals(this.token0)?this.token0Price:this.token1Price}get chainId(){return this.token0.chainId}getOutputAmount(t,n){return q(this,void 0,void 0,(function*(){O(this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token0),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,t.quotient,n),l=i?this.token1:this.token0;return[Rv.fromRawAmount(l,E.multiply(o,Xv)),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}getInputAmount(t,n){return q(this,void 0,void 0,(function*(){O(t.currency.isToken&&this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token1),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,E.multiply(t.quotient,Xv),n),l=i?this.token0:this.token1;return[Rv.fromRawAmount(l,o),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}swap(e,t,n){return q(this,void 0,void 0,(function*(){return function(e,t,n,i,o,r,a,s,l){return q(this,void 0,void 0,(function*(){l||(l=a?E.add(fC.MIN_SQRT_RATIO,eb):E.subtract(fC.MAX_SQRT_RATIO,eb)),a?(O(E.greaterThan(l,fC.MIN_SQRT_RATIO),"RATIO_MIN"),O(E.lessThan(l,t),"RATIO_CURRENT")):(O(E.lessThan(l,fC.MAX_SQRT_RATIO),"RATIO_MAX"),O(E.greaterThan(l,t),"RATIO_CURRENT"));const d=E.greaterThanOrEqual(s,Jv),c={amountSpecifiedRemaining:s,amountCalculated:Jv,sqrtPriceX96:t,tick:n,liquidity:i};for(;E.notEqual(c.amountSpecifiedRemaining,Jv)&&c.sqrtPriceX96!==l;){let t={};if(t.sqrtPriceStartX96=c.sqrtPriceX96,[t.tickNext,t.initialized]=yield r.nextInitializedTickWithinOneWord(c.tick,a,o),t.tickNext<fC.MIN_TICK?t.tickNext=fC.MIN_TICK:t.tickNext>fC.MAX_TICK&&(t.tickNext=fC.MAX_TICK),t.sqrtPriceNextX96=fC.getSqrtRatioAtTick(t.tickNext),[c.sqrtPriceX96,t.amountIn,t.amountOut,t.feeAmount]=wC.computeSwapStep(c.sqrtPriceX96,(a?E.lessThan(t.sqrtPriceNextX96,l):E.greaterThan(t.sqrtPriceNextX96,l))?l:t.sqrtPriceNextX96,c.liquidity,c.amountSpecifiedRemaining,e),d?(c.amountSpecifiedRemaining=E.subtract(c.amountSpecifiedRemaining,E.add(t.amountIn,t.feeAmount)),c.amountCalculated=E.subtract(c.amountCalculated,t.amountOut)):(c.amountSpecifiedRemaining=E.add(c.amountSpecifiedRemaining,t.amountOut),c.amountCalculated=E.add(c.amountCalculated,E.add(t.amountIn,t.feeAmount))),E.equal(c.sqrtPriceX96,t.sqrtPriceNextX96)){if(t.initialized){let e=E.BigInt((yield r.getTick(t.tickNext)).liquidityNet);a&&(e=E.multiply(e,Xv)),c.liquidity=kC.addDelta(c.liquidity,e)}c.tick=a?t.tickNext-1:t.tickNext}else E.notEqual(c.sqrtPriceX96,t.sqrtPriceStartX96)&&(c.tick=fC.getTickAtSqrtRatio(c.sqrtPriceX96))}return{amountCalculated:c.amountCalculated,sqrtRatioX96:c.sqrtPriceX96,liquidity:c.liquidity,tickCurrent:c.tick}}))}(E.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,t,n)}))}get tickSpacing(){return Kv[this.fee]}};class qC{constructor({pool:e,liquidity:t,tickLower:n,tickUpper:i}){this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,O(n<i,"TICK_ORDER"),O(n>=fC.MIN_TICK&&n%e.tickSpacing==0,"TICK_LOWER"),O(i<=fC.MAX_TICK&&i%e.tickSpacing==0,"TICK_UPPER"),this.pool=e,this.tickLower=n,this.tickUpper=i,this.liquidity=E.BigInt(t)}get token0PriceLower(){return PC(this.pool.token0,this.pool.token1,this.tickLower)}get token0PriceUpper(){return PC(this.pool.token0,this.pool.token1,this.tickUpper)}get amount0(){return null===this._token0Amount&&(this.pool.tickCurrent<this.tickLower?this._token0Amount=Rv.fromRawAmount(this.pool.token0,CC.getAmount0Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this.pool.tickCurrent<this.tickUpper?this._token0Amount=Rv.fromRawAmount(this.pool.token0,CC.getAmount0Delta(this.pool.sqrtRatioX96,fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this._token0Amount=Rv.fromRawAmount(this.pool.token0,Jv)),this._token0Amount}get amount1(){return null===this._token1Amount&&(this.pool.tickCurrent<this.tickLower?this._token1Amount=Rv.fromRawAmount(this.pool.token1,Jv):this.pool.tickCurrent<this.tickUpper?this._token1Amount=Rv.fromRawAmount(this.pool.token1,CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!1)):this._token1Amount=Rv.fromRawAmount(this.pool.token1,CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}ratiosAfterSlippage(e){const t=this.pool.token0Price.asFraction.multiply(new _v(1).subtract(e)),n=this.pool.token0Price.asFraction.multiply(e.add(1));let i=AC(t.numerator,t.denominator);E.lessThanOrEqual(i,fC.MIN_SQRT_RATIO)&&(i=E.add(fC.MIN_SQRT_RATIO,E.BigInt(1)));let o=AC(n.numerator,n.denominator);return E.greaterThanOrEqual(o,fC.MAX_SQRT_RATIO)&&(o=E.subtract(fC.MAX_SQRT_RATIO,E.BigInt(1))),{sqrtRatioX96Lower:i,sqrtRatioX96Upper:o}}mintAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new UC(this.pool.token0,this.pool.token1,this.pool.fee,n,0,fC.getTickAtSqrtRatio(n)),o=new UC(this.pool.token0,this.pool.token1,this.pool.fee,t,0,fC.getTickAtSqrtRatio(t)),r=qC.fromAmounts(Object.assign(Object.assign({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts),{useFullPrecision:!1})),{amount0:a}=new qC({pool:o,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts,{amount1:s}=new qC({pool:i,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts;return{amount0:a,amount1:s}}burnAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new UC(this.pool.token0,this.pool.token1,this.pool.fee,n,0,fC.getTickAtSqrtRatio(n)),o=new UC(this.pool.token0,this.pool.token1,this.pool.fee,t,0,fC.getTickAtSqrtRatio(t)),r=new qC({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new qC({pool:i,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:r.quotient,amount1:a.quotient}}get mintAmounts(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:CC.getAmount0Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:Jv}:this.pool.tickCurrent<this.tickUpper?{amount0:CC.getAmount0Delta(this.pool.sqrtRatioX96,fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:Jv,amount1:CC.getAmount1Delta(fC.getSqrtRatioAtTick(this.tickLower),fC.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}static fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:o,useFullPrecision:r}){const a=fC.getSqrtRatioAtTick(t),s=fC.getSqrtRatioAtTick(n);return new qC({pool:e,tickLower:t,tickUpper:n,liquidity:RC(e.sqrtRatioX96,a,s,i,o,r)})}static fromAmount0({pool:e,tickLower:t,tickUpper:n,amount0:i,useFullPrecision:o}){return qC.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:Av,useFullPrecision:o})}static fromAmount1({pool:e,tickLower:t,tickUpper:n,amount1:i}){return qC.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:Av,amount1:i,useFullPrecision:!0})}}var VC=[{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"}];class HC{constructor(){}static encodeMulticall(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:HC.INTERFACE.encodeFunctionData("multicall",[e])}static decodeMulticall(e){return HC.INTERFACE.decodeFunctionData("multicall",e).data}}HC.INTERFACE=new uC(VC);var WC=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"},{internalType:"address",name:"_tokenDescriptor_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"address",name:"recipient",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Collect",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"DecreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"IncreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint128",name:"amount0Max",type:"uint128"},{internalType:"uint128",name:"amount1Max",type:"uint128"}],internalType:"struct INonfungiblePositionManager.CollectParams",name:"params",type:"tuple"}],name:"collect",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceX96",type:"uint160"}],name:"createAndInitializePoolIfNecessary",outputs:[{internalType:"address",name:"pool",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.DecreaseLiquidityParams",name:"params",type:"tuple"}],name:"decreaseLiquidity",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.IncreaseLiquidityParams",name:"params",type:"tuple"}],name:"increaseLiquidity",outputs:[{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.MintParams",name:"params",type:"tuple"}],name:"mint",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"positions",outputs:[{internalType:"uint96",name:"nonce",type:"uint96"},{internalType:"address",name:"operator",type:"address"},{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"feeGrowthInside0LastX128",type:"uint256"},{internalType:"uint256",name:"feeGrowthInside1LastX128",type:"uint256"},{internalType:"uint128",name:"tokensOwed0",type:"uint128"},{internalType:"uint128",name:"tokensOwed1",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount0Owed",type:"uint256"},{internalType:"uint256",name:"amount1Owed",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"uniswapV3MintCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],$C=[{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"}];class zC{constructor(){}static encodeFeeBips(e){return SC(e.multiply(1e4).quotient)}static encodeUnwrapWETH9(e,t,n){if(t=Fv(t),n){const i=this.encodeFeeBips(n.fee),o=Fv(n.recipient);return zC.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[SC(e),t,i,o])}return zC.INTERFACE.encodeFunctionData("unwrapWETH9",[SC(e),t])}static encodeSweepToken(e,t,n,i){if(n=Fv(n),i){const o=this.encodeFeeBips(i.fee),r=Fv(i.recipient);return zC.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,SC(t),n,o,r])}return zC.INTERFACE.encodeFunctionData("sweepToken",[e.address,SC(t),n])}static encodeRefundETH(){return zC.INTERFACE.encodeFunctionData("refundETH")}}zC.INTERFACE=new uC($C);var ZC=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"}];class QC{constructor(){}static encodePermit(e,t){return"nonce"in t?QC.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,SC(t.nonce),SC(t.expiry),t.v,t.r,t.s]):QC.INTERFACE.encodeFunctionData("selfPermit",[e.address,SC(t.amount),SC(t.deadline),t.v,t.r,t.s])}}QC.INTERFACE=new uC(ZC);const GC=SC(E.subtract(E.exponentiate(E.BigInt(2),E.BigInt(128)),E.BigInt(1)));function YC(e){return Object.keys(e).some((e=>"recipient"===e))}const KC={Permit:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};class XC{constructor(){}static encodeCreate(e){return XC.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,SC(e.sqrtRatioX96)])}static createCallParameters(e){return{calldata:this.encodeCreate(e),value:SC(0)}}static addCallParameters(e,t){O(E.greaterThan(e.liquidity,Jv),"ZERO_LIQUIDITY");const n=[],{amount0:i,amount1:o}=e.mintAmounts,r=e.mintAmountsWithSlippage(t.slippageTolerance),a=SC(r.amount0),s=SC(r.amount1),l=SC(t.deadline);if(YC(t)&&t.createPool&&n.push(this.encodeCreate(e.pool)),t.token0Permit&&n.push(QC.encodePermit(e.pool.token0,t.token0Permit)),t.token1Permit&&n.push(QC.encodePermit(e.pool.token1,t.token1Permit)),YC(t)){const r=Fv(t.recipient);n.push(XC.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:SC(i),amount1Desired:SC(o),amount0Min:a,amount1Min:s,recipient:r,deadline:l}]))}else n.push(XC.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:SC(t.tokenId),amount0Desired:SC(i),amount1Desired:SC(o),amount0Min:a,amount1Min:s,deadline:l}]));let d=SC(0);if(t.useNative){const r=t.useNative.wrapped;O(e.pool.token0.equals(r)||e.pool.token1.equals(r),"NO_WETH");const a=e.pool.token0.equals(r)?i:o;E.greaterThan(a,Jv)&&n.push(zC.encodeRefundETH()),d=SC(a)}return{calldata:HC.encodeMulticall(n),value:d}}static encodeCollect(e){const t=[],n=SC(e.tokenId),i=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,o=Fv(e.recipient);if(t.push(XC.INTERFACE.encodeFunctionData("collect",[{tokenId:n,recipient:i?"0x0000000000000000000000000000000000000000":o,amount0Max:GC,amount1Max:GC}])),i){const n=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,i=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,r=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;t.push(zC.encodeUnwrapWETH9(n,o)),t.push(zC.encodeSweepToken(i,r,o))}return t}static collectCallParameters(e){const t=XC.encodeCollect(e);return{calldata:HC.encodeMulticall(t),value:SC(0)}}static removeCallParameters(e,t){const n=[],i=SC(t.deadline),o=SC(t.tokenId),r=new qC({pool:e.pool,liquidity:t.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});O(E.greaterThan(r.liquidity,Jv),"ZERO_LIQUIDITY");const{amount0:a,amount1:s}=r.burnAmountsWithSlippage(t.slippageTolerance);t.permit&&n.push(XC.INTERFACE.encodeFunctionData("permit",[Fv(t.permit.spender),o,SC(t.permit.deadline),t.permit.v,t.permit.r,t.permit.s])),n.push(XC.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:o,liquidity:SC(r.liquidity),amount0Min:SC(a),amount1Min:SC(s),deadline:i}]));const l=t.collectOptions,{expectedCurrencyOwed0:d,expectedCurrencyOwed1:c}=l,u=U(l,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return n.push(...XC.encodeCollect(Object.assign({tokenId:SC(t.tokenId),expectedCurrencyOwed0:d.add(Rv.fromRawAmount(d.currency,a)),expectedCurrencyOwed1:c.add(Rv.fromRawAmount(c.currency,s))},u))),t.liquidityPercentage.equalTo(eb)?t.burnToken&&n.push(XC.INTERFACE.encodeFunctionData("burn",[o])):O(!0!==t.burnToken,"CANNOT_BURN"),{calldata:HC.encodeMulticall(n),value:SC(0)}}static safeTransferFromParameters(e){const t=Fv(e.recipient),n=Fv(e.sender);let i;return i=e.data?XC.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[n,t,SC(e.tokenId),e.data]):XC.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[n,t,SC(e.tokenId)]),{calldata:i,value:SC(0)}}static getPermitData(e,t,n){return{domain:{name:"Uniswap V3 Positions NFT-V1",chainId:n,version:"1",verifyingContract:t},types:KC,values:e}}}XC.INTERFACE=new uC(WC);var JC=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactInputSingleParams",name:"params",type:"tuple"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactOutputSingleParams",name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}];new uC([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}]),new uC(JC);new uC([{inputs:[{internalType:"contract IUniswapV3Factory",name:"_factory",type:"address"},{internalType:"contract INonfungiblePositionManager",name:"_nonfungiblePositionManager",type:"address"},{internalType:"uint256",name:"_maxIncentiveStartLeadTime",type:"uint256"},{internalType:"uint256",name:"_maxIncentiveDuration",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"DepositTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{indexed:!0,internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"},{indexed:!1,internalType:"address",name:"refundee",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"IncentiveCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"refund",type:"uint256"}],name:"IncentiveEnded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"RewardClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"}],name:"TokenStaked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"TokenUnstaked",type:"event"},{inputs:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountRequested",type:"uint256"}],name:"claimReward",outputs:[{internalType:"uint256",name:"reward",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"reward",type:"uint256"}],name:"createIncentive",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"deposits",outputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint48",name:"numberOfStakes",type:"uint48"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"}],name:"endIncentive",outputs:[{internalType:"uint256",name:"refund",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"contract IUniswapV3Factory",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getRewardInfo",outputs:[{internalType:"uint256",name:"reward",type:"uint256"},{internalType:"uint160",name:"secondsInsideX128",type:"uint160"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"incentives",outputs:[{internalType:"uint256",name:"totalRewardUnclaimed",type:"uint256"},{internalType:"uint160",name:"totalSecondsClaimedX128",type:"uint160"},{internalType:"uint96",name:"numberOfStakes",type:"uint96"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveStartLeadTime",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"nonfungiblePositionManager",outputs:[{internalType:"contract INonfungiblePositionManager",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20Minimal",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"rewards",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"stakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"stakes",outputs:[{internalType:"uint160",name:"secondsPerLiquidityInsideInitialX128",type:"uint160"},{internalType:"uint128",name:"liquidity",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"transferDeposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"unstakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"}]);function ej({removed:e,inRange:n}){const i=t.useTheme(),r={py:4,px:8,color:i.palette.success.main,borderRadius:4,backgroundColor:t.alpha(i.palette.success.main,.1),typography:"h6"};return e?G.jsx(t.Tooltip,{title:o.i18n._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.warning.main,backgroundColor:t.alpha(i.palette.warning.main,.1)}),children:o.i18n._({id:"D87pha",message:"Closed"})})}):n?G.jsx(t.Tooltip,{title:o.i18n._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:r,children:o.i18n._({id:"vOyUlD",message:"In range"})})}):G.jsx(t.Tooltip,{title:o.i18n._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),maxWidth:240,children:G.jsx(t.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.error.main,backgroundColor:t.alpha(i.palette.error.main,.1)}),children:o.i18n._({id:"i3Z+/Z",message:"Out of range"})})})}new uC([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"}],internalType:"struct ISwapRouter.ExactInputParams",name:"params",type:"tuple"}],name:"exactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactInputSingleParams",name:"params",type:"tuple"}],name:"exactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"}],internalType:"struct ISwapRouter.ExactOutputParams",name:"params",type:"tuple"}],name:"exactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactOutputSingleParams",name:"params",type:"tuple"}],name:"exactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}]);const tj=({token:e,amount:n})=>{var i;const o=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{address:null!==(i=null==e?void 0:e.address)&&void 0!==i?i:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:18,height:18,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body1",color:o.palette.text.primary},children:[Au({input:n.toSignificant(),decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),G.jsx(t.ButtonBase,{sx:{display:"flex",alignItems:"center",color:o.palette.text.secondary,"&:hover":{color:o.palette.text.primary}},onClick:()=>{window.open(np(e.chainId,null==e?void 0:e.address,"address"))},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{opacity:"0.5",fillRule:"evenodd",clipRule:"evenodd",d:"M3.33333 3.33333V12.6667H12.6667V8H14V12.6667C14 13.4 13.4 14 12.6667 14H3.33333C2.59333 14 2 13.4 2 12.6667V3.33333C2 2.6 2.59333 2 3.33333 2H8V3.33333H3.33333ZM9.33333 3.33333V2H14V6.66667H12.6667V4.27333L6.11333 10.8267L5.17333 9.88667L11.7267 3.33333H9.33333Z",fill:"currentColor"})})})]})},nj=({position:i,inRange:r})=>{var a;const s=t.useTheme(),l=i.pool.token0,d=i.pool.token1,c=i.pool.chainId,u=(null==i?void 0:i.liquidity)&&E.equal(null==i?void 0:i.liquidity,E.BigInt(0)),p=n.useMemo((()=>UC.getAddress(i.pool.token0,i.pool.token1,i.pool.fee,void 0,c?Tv[c]:void 0)),[c,i.pool.fee,i.pool.token0,i.pool.token1]);return G.jsxs(t.Box,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:s.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body2",color:s.palette.text.primary},children:[o.i18n._({id:"PVa3KL",message:"Position on"})," ",null==l?void 0:l.symbol,"/",null==d?void 0:d.symbol]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(ej,{removed:u,inRange:r}),G.jsx(t.Box,{sx:{py:4,px:8,color:s.palette.text.secondary,borderRadius:4,backgroundColor:s.palette.background.tag,typography:"h6"},children:Vu({input:(null===(a=null==i?void 0:i.pool)||void 0===a?void 0:a.fee)/1e6})})]})]}),G.jsxs(t.ButtonBase,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:s.palette.text.secondary,"&:hover":{color:s.palette.text.primary}},onClick:()=>{window.open(np(c,p,"address"))},children:[o.i18n._({id:"URmyfc",message:"Details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),G.jsxs(t.Box,{sx:{p:s.spacing(12,20)},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(t.Box,{sx:{mt:12},children:[G.jsx(tj,{token:l,amount:i.amount0}),G.jsx(tj,{token:d,amount:i.amount1})]})]})]})};function ij({price:e,atLimit:t,direction:n}){return t[n]?n===sv.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Au({input:"string"==typeof e?e:null==e?void 0:e.toSignificant(8),decimals:8})}const oj=({baseToken:e,quoteToken:n,handleRateToggle:i,sx:o})=>{const r=t.useTheme(),a=null==e?void 0:e.wrapped,s=null==n?void 0:n.wrapped,l=a&&s&&a.sortsBefore(s);return G.jsx(t.Box,{component:t.ButtonBase,onClick:i,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:r.palette.border.main},o),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:"auto"}},children:[G.jsx(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},l?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:l?e.symbol:null==n?void 0:n.symbol}),G.jsx(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},l?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:l?n.symbol:null==e?void 0:e.symbol})]})})},rj=({position:i,title:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{const s=i.pool.token0,l=i.pool.token1,d=t.useTheme(),[c,u]=n.useState(r?r===s?s:r===l?l:s:s),p=c===s,h=p?l:s,m=p?i.pool.priceOf(i.pool.token0):i.pool.priceOf(i.pool.token1),g=p?i.token0PriceLower:i.token0PriceUpper.invert(),x=p?i.token0PriceUpper:i.token0PriceLower.invert(),f=n.useCallback((()=>{u(h)}),[h]);return G.jsxs(mv,{gap:"md",children:[G.jsxs(xv,{children:[o?G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.secondary},children:o}):G.jsx("div",{}),G.jsx(oj,{baseToken:p?s:l,quoteToken:p?l:s,handleRateToggle:f})]}),G.jsxs(xv,{children:[G.jsxs(uv,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"EQs1sJ",message:"Min price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:ij({price:g,atLimit:a,direction:sv.LOWER})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==c?void 0:c.symbol}})})]}),G.jsxs(uv,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"5etEUX",message:"Max price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:ij({price:x,atLimit:a,direction:sv.UPPER})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==h?void 0:h.symbol}})})]})]}),G.jsxs(uv,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(mv,{gap:"4px",justify:"flex-start",children:[G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"DWd30U",message:"Current price"})}),G.jsx(t.Box,{sx:{color:d.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),G.jsx(t.Box,{sx:{color:d.palette.text.primary,typography:"caption"},children:`${Au({input:m.toSignificant(8),decimals:8})} `})]})]})},aj=({chainId:e,disabled:n,removed:i,isLoading:r,error:a,onConfirm:s})=>G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,onClick:s,disabled:n,isLoading:r,children:i?o.i18n._({id:"D87pha",message:"Closed"}):null!=a?a:o.i18n._({id:"t/YqKh",message:"Remove"})})}),sj={[Yv.LOWEST]:{label:"0.01%"},[Yv.LOW_200]:{label:"0.02%"},[Yv.LOW_300]:{label:"0.03%"},[Yv.LOW_400]:{label:"0.04%"},[Yv.LOW]:{label:"0.05%"},[Yv.MEDIUM]:{label:"0.30%"},[Yv.HIGH]:{label:"1.00%"}},lj=({poolType:e})=>{const n="AMM V2"===e?t.lightPalette.error.main:"AMM V3"===e?t.lightPalette.purple.main:t.lightPalette.success.main;return G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:t.alpha(n,.1),color:n,whiteSpace:"nowrap"},children:e})},dj=({isAMMV2:n,isAMMV3:i,lpFeeRate:o,mtFeeRate:r})=>{var s,l;return G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:i?null!==(l=null===(s=sj[o])||void 0===s?void 0:s.label)&&void 0!==l?l:"-":Vu({input:new a(null!=o?o:0).plus(r?Mu(r,n?4:18):0)})})})},cj=({sx:e})=>G.jsx(lj,{poolType:"AMM V3"}),uj=({position:n,title:i,inRange:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{var s,l,d;const c=n.pool.token0,u=n.pool.token1,p=(null==n?void 0:n.liquidity)&&E.equal(null==n?void 0:n.liquidity,E.BigInt(0));return G.jsxs(mv,{gap:"md",style:{marginTop:"0.5rem"},children:[G.jsxs(xv,{style:{gap:4},children:[G.jsxs(fv,{children:[G.jsx(wy,{tokens:[{address:c.address},{address:u.address}],mr:8,chainId:c.chainId}),G.jsxs(t.Box,{sx:{typography:"h5"},children:[null==c?void 0:c.symbol," / ",null==u?void 0:u.symbol]})]}),G.jsx(cj,{sx:{ml:"auto"}}),G.jsx(ej,{removed:p,inRange:o})]}),G.jsxs(uv,{children:[G.jsxs(mv,{gap:"md",children:[G.jsxs(xv,{children:[G.jsxs(fv,{children:[G.jsx(Nh,{address:null!==(s=null==c?void 0:c.address)&&void 0!==s?s:"",chainId:null==c?void 0:c.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(t.Box,{sx:{ml:8},children:null==c?void 0:c.symbol})]}),G.jsx(fv,{children:G.jsx(t.Box,{sx:{mr:8},children:Au({input:n.amount0.toSignificant(),decimals:null==c?void 0:c.decimals})})})]}),G.jsxs(xv,{children:[G.jsxs(fv,{children:[G.jsx(Nh,{address:null!==(l=null==u?void 0:u.address)&&void 0!==l?l:"",chainId:null==u?void 0:u.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(t.Box,{ml:"8px",children:null==u?void 0:u.symbol})]}),G.jsx(fv,{children:G.jsx(t.Box,{mr:"8px",children:Au({input:n.amount1.toSignificant(),decimals:null==u?void 0:u.decimals})})})]})]}),G.jsxs(xv,{children:[G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"})}),G.jsx(t.Box,{children:Vu({input:(null===(d=null==n?void 0:n.pool)||void 0===d?void 0:d.fee)/1e6})})]})]}),G.jsx(rj,{position:n,title:i,baseCurrencyDefault:r,ticksAtLimit:a})]})},pj=({on:e,onClose:n,position:i,outOfRange:r,ticksAtLimit:a,onConfirm:s,loading:l})=>{const{isMobile:d}=Bp();return G.jsx(Eh,{open:e,onClose:n,modal:!0,title:o.i18n._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:G.jsxs(t.Box,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:d?void 0:420},children:[G.jsx(t.Box,{sx:{pt:0,px:0},children:i?G.jsx(uj,{position:i,inRange:!r,ticksAtLimit:a,title:o.i18n._({id:"3VUfrF",message:"Selected Range"})}):null}),G.jsx(t.Button,{size:t.Button.Size.big,fullWidth:!0,isLoading:l,sx:{mt:20},onClick:s,children:o.i18n._({id:"m16xKo",message:"Add"})})]})})};class hj{static getPoolAddress(e,t,n,i,o){this.addresses.length>this.MAX_ENTRIES&&(this.addresses=this.addresses.slice(0,this.MAX_ENTRIES/2));const{address:r}=t,{address:a}=n,s=`${e}:${r}:${a}:${i.toString()}`,l=this.addresses.find((e=>e.key===s));if(l)return l.address;const d={key:s,address:pC({factoryAddress:e,tokenA:t,tokenB:n,fee:i,chainId:o})};return this.addresses.unshift(d),d.address}static getPool(e,t,n,i,o,r){this.pools.length>this.MAX_ENTRIES&&(this.pools=this.pools.slice(0,this.MAX_ENTRIES/2));const a=this.pools.find((a=>a.token0===e&&a.token1===t&&a.fee===n&&E.EQ(a.sqrtRatioX96,i)&&E.EQ(a.liquidity,o)&&a.tickCurrent===r));if(a)return a;const s=new UC(e,t,n,i,o,r);return this.pools.unshift(s),s}}var mj;function gj(e,t,i){const o=n.useMemo((()=>[[e,t,i]]),[e,t,i]);return function(e,t){const i=n.useMemo((()=>e?t.map((([e,t,n])=>{if(e&&t&&n){const i=e.wrapped,o=t.wrapped;if(i.equals(o))return;return i.sortsBefore(o)?[i,o,n]:[o,i,n]}})):new Array(t.length)),[e,t]),o=n.useMemo((()=>{const t=e&&Tv[e];return t?i.map((n=>n&&hj.getPoolAddress(t,...n,e))):new Array(i.length)}),[e,i]),{data:r}=d.useQueries({queries:o.map((t=>zu.getV3PoolSlot0(e,t))),combine:e=>({data:e.map((e=>e.data))})}),{data:a}=d.useQueries({queries:o.map((t=>zu.getV3PoolLiquidity(e,t))),combine:e=>({data:e.map((e=>e.data))})});return n.useMemo((()=>t.map(((e,t)=>{const n=i[t];if(!n)return[mj.INVALID,null];const[o,s,l]=n;if(!r[t])return[mj.NOT_EXISTS,null];const d=r[t];if(!a[t])return[mj.NOT_EXISTS,null];const c=a[t];if(!d||!c)return[mj.NOT_EXISTS,null];if(!d.sqrtPriceX96||d.sqrtPriceX96.eq(0))return[mj.NOT_EXISTS,null];try{const e=hj.getPool(o,s,l,d.sqrtPriceX96,c[0],d.tick);return[mj.EXISTS,e]}catch(e){return console.error(e,{tags:{file:"usePools",function:"usePools"},extra:{token0:o.address,token1:s.address,chainId:o.chainId,fee:l}}),[mj.NOT_EXISTS,null]}}))),[a,t,r,i])}(null==e?void 0:e.chainId,o)[0]}hj.MAX_ENTRIES=128,hj.pools=[],hj.addresses=[],function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(mj||(mj={}));class xj{constructor(e){const t=r.basicTokenMap[e];this.chainId=e,this.decimals=t.decimals,this.name=t.name,this.symbol=t.symbol,this.isNative=!0,this.isToken=!1,this.address=fj(this.chainId)}equals(e){return e.isNative&&e.chainId===this.chainId}get wrapped(){const e=r.basicTokenMap[this.chainId];return new qv(this.chainId,e.wrappedTokenAddress,e.decimals,e.wrappedTokenSymbol,e.name)}static onChain(e){var t;return null!==(t=this._cachedNativeCurrency[e])&&void 0!==t?t:this._cachedNativeCurrency[e]=new xj(e)}}function fj(e){return r.basicTokenMap[e].address}function yj(e,t){const n=null==e?void 0:e.toLowerCase(),i=null==t?void 0:t.toLowerCase();return null!==n&&null!==i&&n===i}xj._cachedNativeCurrency={};const vj=(e,t)=>!t||yj(t,fj(e));function bj(e){if(!e)return;const{name:t,chainId:n,address:i,decimals:o,symbol:r}=e;return function(e,t){return!vj(e,t)}(n,i)?new qv(n,i,o,null!=r?r:void 0,null!=t?t:void 0):new xj(n)}function Cj(e){var t,n;if(e)return{chainId:e.chainId,address:e.address,decimals:e.decimals,symbol:null!==(t=e.symbol)&&void 0!==t?t:"",name:null!==(n=e.name)&&void 0!==n?n:""}}function jj(e,t,n){if(e&&t&&"number"==typeof n)return PC(e,t,n)}function wj(e,t){if(e&&t&&!isNaN(parseFloat(e)))try{const n=L.parseUnits(function(e,t){const n=e.split(/[.,]/),i=e.includes(".")?".":",";return n.length>1&&n[1].length>t?n[0]+i+n[1].slice(0,t):e}(e,t.decimals),t.decimals).toString();if("0"!==n)return Rv.fromRawAmount(t,E.BigInt(n))}catch(t){console.error("tryParseCurrencyAmount","tryParseCurrencyAmount",`Failed to parse input amount: "${e}"`,t)}}function kj(e,t,n,i){if(!(e&&t&&n&&i))return;const o=function(e,t,n){var i;if(!e||!t||!n)return;if(!n.match(/^\d*\.?\d+$/))return;const[o,r]=n.split("."),a=null!==(i=null==r?void 0:r.length)&&void 0!==i?i:0,s=E.BigInt((null!=o?o:"")+(null!=r?r:""));return new Nv(e,t,E.multiply(E.BigInt(10**a),E.BigInt(10**e.decimals)),E.multiply(s,E.BigInt(10**t.decimals)))}(e,t,i);if(!o)return;let r;const a=AC(o.numerator,o.denominator);return r=E.greaterThanOrEqual(a,fC.MAX_SQRT_RATIO)?fC.MAX_TICK:E.lessThanOrEqual(a,fC.MIN_SQRT_RATIO)?fC.MIN_TICK:_C(o),MC(r,Kv[n])}function Tj({state:e,existingPosition:t,chainId:i}){var r,a,s,l,c,u,p,h,m,g,x,f,y;const{account:v}=cp(),{feeAmount:b,independentField:C,typedValue:j,leftRangeTypedValue:w,rightRangeTypedValue:k,startPriceTypedValue:T}=e,B=null!==(r=e.baseToken)&&void 0!==r?r:void 0,I=null!==(a=e.baseToken)&&void 0!==a?a:void 0,S=null!==(s=e.quoteToken)&&void 0!==s?s:void 0,A=C===av.CURRENCY_A?av.CURRENCY_B:av.CURRENCY_A,O=n.useMemo((()=>({[av.CURRENCY_A]:B,[av.CURRENCY_B]:S})),[B,S]),[L,R,M]=n.useMemo((()=>[null==B?void 0:B.wrapped,null==S?void 0:S.wrapped,null==I?void 0:I.wrapped]),[B,S,I]),[P,_]=n.useMemo((()=>L&&R?L.sortsBefore(R)?[L,R]:[R,L]:[void 0,void 0]),[L,R]),N=d.useQuery(id.getFetchTokenQuery(null===(l=O[av.CURRENCY_A])||void 0===l?void 0:l.chainId,null===(c=O[av.CURRENCY_A])||void 0===c?void 0:c.address,v)),D=d.useQuery(id.getFetchTokenQuery(null===(u=O[av.CURRENCY_B])||void 0===u?void 0:u.chainId,null===(p=O[av.CURRENCY_B])||void 0===p?void 0:p.address,v)),F=n.useMemo((()=>{var e,t,n,i,o,r;return{[av.CURRENCY_A]:O[av.CURRENCY_A]?(null===(e=N.data)||void 0===e?void 0:e.balance)?Rv.fromRawAmount(O[av.CURRENCY_A],E.BigInt(null===(t=N.data)||void 0===t?void 0:t.balance.multipliedBy(Math.pow(10,null!==(n=O[av.CURRENCY_A].decimals)&&void 0!==n?n:18)).toString())):Rv.fromRawAmount(O[av.CURRENCY_A],0):void 0,[av.CURRENCY_B]:O[av.CURRENCY_B]?(null===(i=D.data)||void 0===i?void 0:i.balance)?Rv.fromRawAmount(O[av.CURRENCY_B],E.BigInt(null===(o=D.data)||void 0===o?void 0:o.balance.multipliedBy(Math.pow(10,null!==(r=O[av.CURRENCY_B].decimals)&&void 0!==r?r:18)).toString())):Rv.fromRawAmount(O[av.CURRENCY_B],0):void 0}}),[O,null===(h=N.data)||void 0===h?void 0:h.balance,null===(m=D.data)||void 0===m?void 0:m.balance]),[U,q]=gj(O[av.CURRENCY_A],O[av.CURRENCY_B],b),V=U===mj.NOT_EXISTS,H=Boolean(M&&P&&!M.equals(P)),W=n.useMemo((()=>{var e;if(!V)return q&&P?q.priceOf(P):void 0;{const t=wj(T,H?P:_);if(t&&P&&_){const n=wj("1",H?_:P),i=n&&t?new Nv(n.currency,t.currency,n.quotient,t.quotient):void 0;return null!==(e=H?null==i?void 0:i.invert():i)&&void 0!==e?e:void 0}}}),[V,T,H,_,P,q]),$=n.useMemo((()=>{const e=W?AC(W.numerator,W.denominator):void 0;return W&&e&&!(E.greaterThanOrEqual(e,fC.MIN_SQRT_RATIO)&&E.lessThan(e,fC.MAX_SQRT_RATIO))}),[W]),z=n.useMemo((()=>{if(L&&R&&b&&W&&!$){const e=_C(W),t=fC.getSqrtRatioAtTick(e);return new UC(L,R,b,t,E.BigInt(0),e,[])}}),[b,$,W,L,R]),Z=null!=q?q:z,Q=n.useMemo((()=>({[sv.LOWER]:b?MC(fC.MIN_TICK,Kv[b]):void 0,[sv.UPPER]:b?MC(fC.MAX_TICK,Kv[b]):void 0})),[b]),G=n.useMemo((()=>({[sv.LOWER]:"number"==typeof(null==t?void 0:t.tickLower)?t.tickLower:H&&"boolean"==typeof k||!H&&"boolean"==typeof w?Q[sv.LOWER]:H?kj(_,P,b,k.toString()):kj(P,_,b,w.toString()),[sv.UPPER]:"number"==typeof(null==t?void 0:t.tickUpper)?t.tickUpper:!H&&"boolean"==typeof k||H&&"boolean"==typeof w?Q[sv.UPPER]:H?kj(_,P,b,w.toString()):kj(P,_,b,k.toString())})),[t,b,H,w,k,Q,P,_]),{[sv.LOWER]:Y,[sv.UPPER]:K}=G||{},X=n.useMemo((()=>({[sv.LOWER]:b&&Y===Q.LOWER,[sv.UPPER]:b&&K===Q.UPPER})),[Q,Y,K,b]),J=Boolean("number"==typeof Y&&"number"==typeof K&&Y>=K),ee=n.useMemo((()=>({[sv.LOWER]:jj(P,_,Q.LOWER),[sv.UPPER]:jj(P,_,Q.UPPER)})),[P,_,Q.LOWER,Q.UPPER]),te=n.useMemo((()=>({[sv.LOWER]:jj(P,_,G[sv.LOWER]),[sv.UPPER]:jj(P,_,G[sv.UPPER])})),[P,_,G]),{[sv.LOWER]:ne,[sv.UPPER]:ie}=te,oe=Boolean(!J&&W&&ne&&ie&&(W.lessThan(ne)||W.greaterThan(ie))),re=wj(j,O[C]),ae=n.useMemo((()=>{const e=null==re?void 0:re.wrapped,t=A===av.CURRENCY_B?S:B;if(re&&e&&"number"==typeof Y&&"number"==typeof K&&Z){if(oe||J)return;const n=e.currency.equals(Z.token0)?qC.fromAmount0({pool:Z,tickLower:Y,tickUpper:K,amount0:re.quotient,useFullPrecision:!0}):qC.fromAmount1({pool:Z,tickLower:Y,tickUpper:K,amount1:re.quotient}),i=e.currency.equals(Z.token0)?n.amount1:n.amount0;return t&&Rv.fromRawAmount(t,i.quotient)}}),[re,oe,A,S,B,Y,K,Z,J]),se=n.useMemo((()=>({[av.CURRENCY_A]:C===av.CURRENCY_A?re:ae,[av.CURRENCY_B]:C===av.CURRENCY_A?ae:re})),[ae,re,C]),le=Boolean("number"==typeof K&&Z&&Z.tickCurrent>=K),de=Boolean("number"==typeof Y&&Z&&Z.tickCurrent<=Y),ce=J||Boolean(le&&Z&&L&&Z.token0.equals(L)||de&&Z&&L&&Z.token1.equals(L)),ue=J||Boolean(le&&Z&&R&&Z.token0.equals(R)||de&&Z&&R&&Z.token1.equals(R)),{inputTax:pe,outputTax:he}=function(e,t,i){const[{inputTax:o,outputTax:r},a]=n.useState({inputTax:Qv,outputTax:Qv});return{inputTax:o,outputTax:r}}((null==B?void 0:B.isToken)&&B.address,(null==S?void 0:S.isToken)&&S.address),me=n.useMemo((()=>{var e,t;if(!Z||!L||!R||"number"!=typeof Y||"number"!=typeof K||J)return;const n=le?zv:null===(e=null==se?void 0:se[L.equals(Z.token0)?av.CURRENCY_A:av.CURRENCY_B])||void 0===e?void 0:e.quotient,i=de?zv:null===(t=null==se?void 0:se[L.equals(Z.token0)?av.CURRENCY_B:av.CURRENCY_A])||void 0===t?void 0:t.quotient;return void 0!==n&&void 0!==i?qC.fromAmounts({pool:Z,tickLower:Y,tickUpper:K,amount0:n,amount1:i,useFullPrecision:!0}):void 0}),[se,Z,L,R,le,de,J,Y,K]);let ge;v||(ge=o.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),U===mj.INVALID&&(ge=null!=ge?ge:o.i18n._({id:"R7D79P",message:"Invalid pair"})),$&&(ge=null!=ge?ge:o.i18n._({id:"HXBqgG",message:"Invalid price input"})),(se[av.CURRENCY_A]||ce)&&(se[av.CURRENCY_B]||ue)||(ge=null!=ge?ge:o.i18n._({id:"iPMIoT",message:"Enter an amount"}));const{[av.CURRENCY_A]:xe,[av.CURRENCY_B]:fe}=se;xe&&(null===(g=null==F?void 0:F[av.CURRENCY_A])||void 0===g?void 0:g.lessThan(xe))&&(ge=o.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(x=O[av.CURRENCY_A])||void 0===x?void 0:x.symbol}})),fe&&(null===(f=null==F?void 0:F[av.CURRENCY_B])||void 0===f?void 0:f.lessThan(fe))&&(ge=o.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(y=O[av.CURRENCY_B])||void 0===y?void 0:y.symbol}}));const ye=pe.greaterThan(0)||he.greaterThan(0),ve=U===mj.INVALID||ye;return{dependentField:A,currencies:O,pool:q,poolState:U,currencyBalances:F,parsedAmounts:se,ticks:G,price:W,pricesAtTicks:te,pricesAtLimit:ee,position:me,noLiquidity:V,errorMessage:ge,invalidPool:ve,invalidRange:J,outOfRange:oe,depositADisabled:ce,depositBDisabled:ue,invertPrice:H,ticksAtLimit:X,isTaxed:ye}}var Bj;function Ij(e,t){switch(t.type){case Bj.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:bj(n)})}case Bj.UpdateDefaultBaseToken:{const n=t.payload;return e.baseToken?e:Object.assign(Object.assign({},e),{baseToken:bj(n)})}case Bj.UpdateQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{quoteToken:bj(n)})}case Bj.UpdateDefaultQuoteToken:{const n=t.payload;return e.quoteToken?e:Object.assign(Object.assign({},e),{quoteToken:bj(n)})}case Bj.UpdateBaseTokenAndClearQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:bj(n),quoteToken:null})}case Bj.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case Bj.ToggleRate:{const{baseToken:t,quoteToken:n}=e;return Object.assign(Object.assign({},e),{baseToken:n,quoteToken:t})}case Bj.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case Bj.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case Bj.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case Bj.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case Bj.typeInput:{const{payload:{field:n,typedValue:i,noLiquidity:o}}=t;return o?(e.independentField,Object.assign(Object.assign({},e),{independentField:n,typedValue:i})):Object.assign(Object.assign({},e),{independentField:n,typedValue:i})}default:throw Error("Unknown action: "+t.type)}}function Sj({noLiquidity:e,dispatch:t}){return{onFieldAInput:n.useCallback((n=>{t({type:Bj.typeInput,payload:{field:av.CURRENCY_A,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onFieldBInput:n.useCallback((n=>{t({type:Bj.typeInput,payload:{field:av.CURRENCY_B,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onLeftRangeInput:n.useCallback((e=>{t({type:Bj.typeLeftRangeInput,payload:{typedValue:e}})}),[t]),onRightRangeInput:n.useCallback((e=>{t({type:Bj.typeRightRangeInput,payload:{typedValue:e}})}),[t]),onStartPriceInput:n.useCallback((e=>{t({type:Bj.typeStartPriceInput,payload:{typedValue:e}})}),[t])}}function Aj(e){return e?Bv[e]:void 0}function Ej(e,t){const i=Aj(t),o=n.useMemo((()=>e?e.map((e=>[e])):[]),[e]),r=d.useQuery(zu.getPositions(t,i,o)),a=r.isLoading,s=r.error,l=n.useMemo((()=>{var t;if(!a&&!s&&e)return null===(t=r.data)||void 0===t?void 0:t.map(((t,n)=>({tokenId:e[n],fee:t.fee,feeGrowthInside0LastX128:t.feeGrowthInside0LastX128.toString(),feeGrowthInside1LastX128:t.feeGrowthInside1LastX128.toString(),liquidity:t.liquidity.toString(),nonce:t.nonce.toString(),operator:t.operator,tickLower:t.tickLower,tickUpper:t.tickUpper,token0:t.token0,token1:t.token1,tokensOwed0:t.tokensOwed0.toString(),tokensOwed1:t.tokensOwed1.toString()})))}),[a,s,r,e]);return{loading:a,positions:null==l?void 0:l.map(((e,t)=>Object.assign(Object.assign({},e),{tokenId:o[t][0]})))}}!function(e){e[e.UpdateBaseToken=0]="UpdateBaseToken",e[e.UpdateDefaultBaseToken=1]="UpdateDefaultBaseToken",e[e.UpdateQuoteToken=2]="UpdateQuoteToken",e[e.UpdateDefaultQuoteToken=3]="UpdateDefaultQuoteToken",e[e.UpdateBaseTokenAndClearQuoteToken=4]="UpdateBaseTokenAndClearQuoteToken",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.ToggleRate=6]="ToggleRate",e[e.setFullRange=7]="setFullRange",e[e.typeStartPriceInput=8]="typeStartPriceInput",e[e.typeLeftRangeInput=9]="typeLeftRangeInput",e[e.typeRightRangeInput=10]="typeRightRangeInput",e[e.typeInput=11]="typeInput"}(Bj||(Bj={}));const Oj=E.exponentiate(E.BigInt(10),E.BigInt(16));function Lj(e){if(e)return e.currency.isNative?E.greaterThan(e.quotient,Oj)?Rv.fromRawAmount(e.currency,E.subtract(e.quotient,Oj)):Rv.fromRawAmount(e.currency,E.BigInt(0)):e}const Rj=1e4,Mj=100*Rj;function Pj(e){const t=Math.floor(Number(e)*Rj);return new _v(t,Mj)}const _j=({token:e,amount:n})=>{var i;const o=t.useTheme();return G.jsxs(t.Box,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:o.palette.text.primary},children:[G.jsx(Nh,{address:null!==(i=null==e?void 0:e.address)&&void 0!==i?i:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),G.jsx(t.Box,{children:null==e?void 0:e.symbol}),G.jsx(t.Box,{sx:{ml:"auto"},children:Au({input:null==n?void 0:n.toSignificant(),decimals:null==e?void 0:e.decimals})})]})},Nj=({chainId:e,baseToken:i,quoteToken:s,feeAmount:l,tokenId:c,onClose:u})=>{var p,h;const{isMobile:m}=Bp(),g=t.useTheme(),f=Up(),y=d.useQueryClient(),{account:v}=cp(),{position:b,loading:C}=function(e,t){var n;const i=Ej(e?[e]:void 0,t);return{loading:i.loading,position:null===(n=i.positions)||void 0===n?void 0:n[0]}}(c,e),j=!!b&&!C,{position:w}=function(e,t,i){const o=n.useMemo((()=>t?bj(t):void 0),[t]),r=n.useMemo((()=>i?bj(i):void 0),[i]),[,a]=gj(null!=o?o:void 0,null!=r?r:void 0,null==e?void 0:e.fee);let s;return a&&e&&(s=new qC({pool:a,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})),{position:s,pool:null!=a?a:void 0}}(b,i,s),[k,T]=n.useState("stake"),[B,I]=n.useState(!1),[S,A]=n.useState(ov),[E,O]=n.useReducer(Ij,{baseToken:bj(i),quoteToken:bj(s),feeAmount:l,independentField:av.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""}),{independentField:L,typedValue:R,startPriceTypedValue:M}=E,{pool:P,ticks:_,dependentField:N,price:D,pricesAtTicks:F,pricesAtLimit:U,parsedAmounts:V,currencyBalances:H,position:W,noLiquidity:$,currencies:z,errorMessage:Z,invalidPool:Q,invalidRange:Y,outOfRange:K,depositADisabled:J,depositBDisabled:ee,invertPrice:te,ticksAtLimit:ne,isTaxed:ie}=Tj({state:E,existingPosition:w,chainId:e}),{position:oe,liquidityPercentage:re,liquidityValue0:ae,liquidityValue1:le,feeValue0:de,feeValue1:ce,error:ue}=function({percent:e,position:t,asWETH:i,baseToken:r,quoteToken:a}){const{account:s}=cp(),[l,d]=n.useMemo((()=>[null==r?void 0:r.wrapped,null==a?void 0:a.wrapped]),[r,a]),[c,u]=n.useMemo((()=>l&&d?l.sortsBefore(d)?[l,d]:[d,l]:[void 0,void 0]),[l,d]),[,p]=gj(null!=c?c:void 0,null!=u?u:void 0,null==t?void 0:t.fee),h=n.useMemo((()=>p&&(null==t?void 0:t.liquidity)&&"number"==typeof(null==t?void 0:t.tickLower)&&"number"==typeof(null==t?void 0:t.tickUpper)?new qC({pool:p,liquidity:t.liquidity.toString(),tickLower:t.tickLower,tickUpper:t.tickUpper}):void 0),[p,t]),m=new _v(e,100),g=h?m.multiply(h.amount0.quotient).quotient:void 0,x=h?m.multiply(h.amount1.quotient).quotient:void 0,f=c&&g?Rv.fromRawAmount(c,g):void 0,y=u&&x?Rv.fromRawAmount(u,x):void 0,v=!(!p||!t)&&(p.tickCurrent<t.tickLower||p.tickCurrent>t.tickUpper);let b;return s||(b=o.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),0===e&&(b=null!=b?b:o.i18n._({id:"Sta9CR",message:"Enter a percent"})),{position:h,liquidityPercentage:m,liquidityValue0:f,liquidityValue1:y,feeValue0:void 0,feeValue1:void 0,outOfRange:v,error:b}}({position:b,asWETH:void 0,percent:S,baseToken:E.baseToken,quoteToken:E.quoteToken}),pe="0"===(null==b?void 0:b.liquidity),[he,me]=function({chainId:e,pool:t,tokenId:n,asWETH:i}){var o;const r=Aj(e),a=null===(o=x.BigNumber.from(n))||void 0===o?void 0:o.toHexString(),s=d.useQuery(zu.getOwner(e,r,n)),l=d.useQuery(zu.getCollect(e,r,a,s.data&&Array.isArray(s.data)?s.data[0]:void 0));return t&&l&&l.data&&l.data.amount0&&l.data.amount1?[Rv.fromRawAmount(t.token0,l.data.amount0.toString()),Rv.fromRawAmount(t.token1,l.data.amount1.toString())]:[void 0,void 0]}({pool:null!=P?P:void 0,tokenId:c,asWETH:!1,chainId:e}),ge=me,xe=he;n.useMemo((()=>{var e;return null===(e=te?null==D?void 0:D.invert():D)||void 0===e?void 0:e.toSignificant()}),[te,D]);const{onFieldAInput:fe,onFieldBInput:ye,onLeftRangeInput:ve,onRightRangeInput:be,onStartPriceInput:Ce}=Sj({noLiquidity:$,dispatch:O}),{slipper:je,setSlipper:we,slipperValue:ke,resetSlipper:Te}=nv({address:void 0,type:"AMMV3"}),Be=!Z&&!Y,Ie=n.useMemo((()=>{var e,t;return{[L]:R,[N]:null!==(t=null===(e=V[N])||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""}}),[N,L,V,R]),Se=n.useMemo((()=>[av.CURRENCY_A,av.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:Lj(H[t])})),{})),[H]),Ae=lh(Cj(null===(p=V[av.CURRENCY_A])||void 0===p?void 0:p.currency),{contractAddress:Bv[e],overrideBalance:H[av.CURRENCY_A]?new a(H[av.CURRENCY_A].toSignificant()):void 0,amount:V[av.CURRENCY_A]?new a(V[av.CURRENCY_A].toSignificant()):void 0}),Ee=lh(Cj(null===(h=V[av.CURRENCY_B])||void 0===h?void 0:h.currency),{contractAddress:Bv[e],overrideBalance:H[av.CURRENCY_B]?new a(H[av.CURRENCY_B].toSignificant()):void 0,amount:V[av.CURRENCY_B]?new a(V[av.CURRENCY_B].toSignificant()):void 0}),{[sv.LOWER]:Oe,[sv.UPPER]:Le}=_,{[sv.LOWER]:Re,[sv.UPPER]:Me}=F,{deadLine:Pe}=X(),_e=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(!v||!e||!W)return;if(!E.baseToken||!E.quoteToken)return;const t=Math.ceil(Date.now()/1e3)+(null!=Pe?Pe:600),n=E.baseToken.isNative?E.baseToken:E.quoteToken.isNative?E.quoteToken:void 0;try{const{calldata:i,value:a}=XC.addCallParameters(W,{tokenId:c,slippageTolerance:Pj(100*ke),deadline:t.toString(),useNative:n});let s={to:Bv[e],data:i,value:a};(yield f.execute(o.i18n._({id:"OBdohg",message:"Add Liquidity"}),Object.assign({opcode:Mp.TX},s),{early:!1,metadata:{[exports.MetadataFlag.addAMMV3Pool]:"1"}}))===Ap.Success&&(I(!1),setTimeout((()=>{null==u||u()}),100)),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onAddMutation",e)}}))}),Ne=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(!(v&&e&&oe&&re&&ae&&le))return;const t=Math.ceil(Date.now()/1e3)+(null!=Pe?Pe:600);try{const{calldata:n,value:i}=XC.removeCallParameters(oe,{tokenId:c.toString(),liquidityPercentage:re,slippageTolerance:Pj(100*ke),deadline:t.toString(),collectOptions:{expectedCurrencyOwed0:null!=de?de:Rv.fromRawAmount(ae.currency,0),expectedCurrencyOwed1:null!=ce?ce:Rv.fromRawAmount(le.currency,0),recipient:v}});let a={to:Bv[e],data:n,value:i};(yield f.execute(o.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),Object.assign({opcode:Mp.TX},a),{early:!1,metadata:{[exports.MetadataFlag.removeAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{null==u||u()}),100),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onRemoveMutation",e)}}))}),De=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(v&&e&&P)try{const{calldata:t,value:n}=XC.collectCallParameters({tokenId:c.toString(),expectedCurrencyOwed0:null!=he?he:Rv.fromRawAmount(P.token0,0),expectedCurrencyOwed1:null!=me?me:Rv.fromRawAmount(P.token1,0),recipient:v});let i={to:Bv[e],data:t,value:n};(yield f.execute(o.i18n._({id:"zXCpR0",message:"Claim Rewards"}),Object.assign({opcode:Mp.TX},i),{early:!1,metadata:{[exports.MetadataFlag.claimAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{null==u||u()}),100),y.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"ammv3"],refetchType:"all"})}catch(e){console.error("onClaimMutation",e)}}))}),Fe=n.useMemo((()=>{var n,i,r,a;const s=[{key:"stake",value:o.i18n._({id:"m16xKo",message:"Add"})},{key:"unstake",value:o.i18n._({id:"t/YqKh",message:"Remove"})},{key:"claim",value:o.i18n._({id:"hom7qf",message:"Claim"})}];return G.jsxs(t.Box,{sx:{borderRadius:16,backgroundColor:g.palette.background.paper},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:g.palette.background.paper},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:o.i18n._({id:"E6MqGy",message:"Add liquidity"})}),u?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{u()}})}):void 0]}),j&&w&&G.jsx(t.Box,{sx:{mx:20,mb:16},children:G.jsx(nj,{position:w,inRange:!K})}),G.jsxs(t.Tabs,{value:k,onChange:(e,t)=>{T(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:s,variant:"inPaper",tabsListSx:{mx:20}}),G.jsxs(t.TabPanel,{value:"stake",children:[j&&w&&G.jsx(t.Box,{sx:{mt:16,mx:20},children:G.jsx(rj,{position:w,title:o.i18n._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:ne})}),G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.secondary,textAlign:"left"},children:o.i18n._({id:"BRi+RY",message:"Add more liquidity"})}),G.jsxs(t.Box,{children:[G.jsx(kv,{value:Ie[av.CURRENCY_A],onUserInput:fe,maxAmount:Se[av.CURRENCY_A],balance:H[av.CURRENCY_A],currency:null!==(n=z[av.CURRENCY_A])&&void 0!==n?n:null,locked:J}),G.jsx(cy,{}),G.jsx(kv,{value:Ie[av.CURRENCY_B],onUserInput:ye,maxAmount:Se[av.CURRENCY_B],balance:H[av.CURRENCY_B],currency:null!==(i=z[av.CURRENCY_B])&&void 0!==i?i:null,locked:ee})]}),G.jsx(iv,{value:je,onChange:we,disabled:!1,type:"AMMV3"})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(vv,{chainId:e,approvalA:Ae,approvalB:Ee,parsedAmounts:V,isValid:Be,depositADisabled:J,depositBDisabled:ee,errorMessage:Z,setShowConfirm:I})}),G.jsx(pj,{parsedAmounts:V,position:W,existingPosition:void 0,priceLower:Re,priceUpper:Me,outOfRange:K,ticksAtLimit:ne,on:B,onClose:()=>{I(!1)},onConfirm:_e.mutate,loading:_e.isPending})]}),G.jsxs(t.TabPanel,{value:"unstake",children:[G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(Gy,{disabled:!1,value:S,onChange:e=>A(e)}),G.jsx(iv,{value:je,onChange:we,disabled:!1,type:"AMMV3"})]}),G.jsxs(t.Box,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:g.palette.text.secondary},children:"Receive"}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:[G.jsx(t.Box,{component:"span",sx:{color:g.palette.primary.main},children:ae?Au({input:ae.toExact(),decimals:ae.currency.decimals}):"-"})," ",null===(r=null==ae?void 0:ae.currency)||void 0===r?void 0:r.symbol]}),G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:g.palette.text.primary},children:[G.jsx(t.Box,{component:"span",sx:{color:g.palette.primary.main},children:le?Au({input:le.toExact(),decimals:le.currency.decimals}):"-"})," ",null===(a=null==le?void 0:le.currency)||void 0===a?void 0:a.symbol]})]})]}),G.jsx(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(aj,{chainId:e,disabled:pe||0===S||!ae,removed:pe,error:ue,onConfirm:Ne.mutate,isLoading:Ne.isPending})})]}),G.jsxs(t.TabPanel,{value:"claim",children:[G.jsxs(t.Box,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:g.palette.border.main},children:[G.jsx(t.Box,{sx:{py:12,px:20,typography:"body1",color:g.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:g.palette.border.main},children:o.i18n._({id:"tu/fxg",message:"Claim fees"})}),G.jsxs(t.Box,{sx:{p:20},children:[G.jsx(_j,{token:null==ge?void 0:ge.currency,amount:ge}),G.jsx(_j,{token:null==xe?void 0:xe.currency,amount:xe})]})]}),G.jsx(t.Box,{sx:{mx:20,mt:16,typography:"h6",color:g.palette.text.secondary},children:o.i18n._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),G.jsx(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:g.palette.background.paper},children:G.jsx(bv,{chainId:e,disabled:De.isPending,onConfirm:De.mutate,isLoading:De.isPending})})]})]})]})}),[Ae,Ee,e,z,H,J,ee,ue,Z,w,xe,ge,Ie,j,Be,ae,le,Se,_e.isPending,_e.mutate,De.isPending,De.mutate,u,fe,ye,Ne.isPending,Ne.mutate,k,K,V,W,Re,Me,pe,we,B,S,je,g.palette.background.paper,g.palette.border.main,g.palette.primary.main,g.palette.text.primary,g.palette.text.secondary,ne]);return m?G.jsx(Eh,{open:null!=i&&null!=s,onClose:u,scope:!m,modal:m,id:"pool-operate",children:Fe}):Fe};const Dj=({outOfRange:e})=>{const n=t.useTheme();return G.jsx(t.Tooltip,{title:e?o.i18n._({id:"i3Z+/Z",message:"Out of range"}):o.i18n._({id:"vOyUlD",message:"In range"}),children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.583252 12.5416L6.99992 1.45825L13.4166 12.5416H0.583252ZM11.3924 11.3749L6.9999 3.78575L2.6074 11.3749H11.3924ZM7.58328 9.62492H6.41661V10.7916H7.58328V9.62492ZM6.41661 6.12492H7.58328V8.45825H6.41661V6.12492Z",fill:n.palette.warning.main})}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:G.jsx("circle",{cx:"4",cy:"4",r:"4",fill:n.palette.success.main})})})})},Fj=({p:e,currency0:i,currency1:r,onClickManage:a})=>{const s=t.useTheme(),[,l]=gj(null!=i?i:void 0,null!=r?r:void 0,e.fee),d=n.useMemo((()=>{if(l)return new qC({pool:l,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})}),[e.liquidity,e.tickLower,e.tickUpper,l]),c=(u=e.fee,p=e.tickLower,h=e.tickUpper,n.useMemo((()=>({[sv.LOWER]:u&&p?p===MC(fC.MIN_TICK,Kv[u]):void 0,[sv.UPPER]:u&&h?h===MC(fC.MAX_TICK,Kv[u]):void 0})),[u,p,h]));var u,p,h;const m=null==d?void 0:d.token0PriceLower,g=null==d?void 0:d.token0PriceUpper,x=null==d?void 0:d.amount1.currency,f=null==d?void 0:d.amount0.currency,y=!!l&&(l.tickCurrent<e.tickLower||l.tickCurrent>=e.tickUpper),v=i==i?null==d?void 0:d.pool.priceOf(null==d?void 0:d.pool.token0):null==d?void 0:d.pool.priceOf(null==d?void 0:d.pool.token1);return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:s.palette.background.paperContrast},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:s.palette.text.primary},children:[G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:m,atLimit:c,direction:sv.LOWER})," "]}),null==x?void 0:x.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:g,atLimit:c,direction:sv.UPPER})," "]}),null==x?void 0:x.symbol]})})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Dj,{outOfRange:y}),G.jsxs(t.Box,{sx:{typography:"h6",color:s.palette.text.secondary},children:[o.i18n._({id:"DWd30U",message:"Current price"}),": ",`${Au({input:null==v?void 0:v.toSignificant(8),decimals:8})}`," ",null==x?void 0:x.symbol," per ",null==f?void 0:f.symbol]})]})]}),G.jsx(t.Button,{variant:t.Button.Variant.outlined,size:t.Button.Size.small,fullWidth:!0,onClick:a,children:o.i18n._({id:"wckWOP",message:"Manage"})})]})},Uj=({chainId:e,baseToken:i,quoteToken:r,feeAmount:a,onClose:s,handleGoToAddLiquidityV3:l})=>{const{isMobile:c}=Bp(),u=t.useTheme(),{account:p}=cp(),{positions:h,loading:m}=function(e,t){const i=Aj(t),{isLoading:o,data:r}=d.useQuery(zu.getBalanceOf(t,i,null!=e?e:void 0)),a=n.useMemo((()=>{if(e&&r&&r.isFinite()){const t=[];for(let n=0;n<r.toNumber();n++)t.push([e,n]);return t}return[]}),[e,r]),s=d.useQuery(zu.getTokenOfOwnerByIndex(t,i,a)),l=s.isLoading,c=n.useMemo((()=>e&&s.data?s.data.map((e=>{if(Array.isArray(e)&&e.length>0)return e[0].toString()})):[]),[e,s]),{positions:u,loading:p}=Ej(c,t);return{loading:l||o||p,positions:u}}(p,e),g=n.useMemo((()=>i?bj(i):void 0),[i]),x=n.useMemo((()=>r?bj(r):void 0),[r]),[f,y]=n.useMemo((()=>[null==g?void 0:g.wrapped,null==x?void 0:x.wrapped]),[g,x]),[v,b]=n.useMemo((()=>f&&y?f.sortsBefore(y)?[f,y]:[y,f]:[void 0,void 0]),[f,y]),C=n.useMemo((()=>{if(void 0!==h)return h.filter((e=>yj(null==v?void 0:v.address,e.token0)&&yj(null==b?void 0:b.address,e.token1)&&e.fee===a))}),[a,h,null==v?void 0:v.address,null==b?void 0:b.address]),[j,w]=n.useState(null),k=n.useMemo((()=>{var e;return G.jsxs(t.Box,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:u.palette.background.paper,minHeight:480},children:[G.jsxs(t.Box,{sx:{pb:16,borderBottomColor:u.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[o.i18n._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==C?void 0:C.length)&&void 0!==e?e:0,")"]}),s?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{s()}})}):void 0]}),C&&C.length>0?G.jsxs(G.Fragment,{children:[null==C?void 0:C.map((e=>G.jsx(Fj,{p:e,currency0:g,currency1:x,onClickManage:()=>{w(e)}},e.tokenId))),G.jsxs(t.Button,{size:t.Button.Size.big,variant:t.Button.Variant.second,onClick:()=>{l({from:i.address,to:r.address,fee:String(a)})},sx:{gap:8},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:G.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),o.i18n._({id:"FQ4aT9",message:"Add Position"})]})]}):G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[G.jsx(J,{sx:{width:60,height:60,borderRadius:24/105*60}}),G.jsx(t.Box,{sx:{typography:"body1",color:u.palette.text.secondary},children:o.i18n._({id:"/6L4mj",message:"Your position is empty"})})]}),G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:void 0!==C&&0===C.length?G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({from:i.address,to:r.address,fee:String(a)})},children:o.i18n._({id:"FQ4aT9",message:"Add Position"})}):G.jsx(lv,{size:t.Button.Size.small})})]})]})}),[u.palette.background.paper,u.palette.border.main,u.palette.text.primary,u.palette.text.secondary,C,s,g,x,l,i.address,r.address,a]);return null!==j?G.jsx(Nj,{baseToken:i,quoteToken:r,feeAmount:a,tokenId:j.tokenId,chainId:e,onClose:()=>{w(null)}}):c?G.jsx(Eh,{open:null!=i&&null!=r,onClose:s,scope:!c,modal:c,id:"pool-operate",children:k}):k};function qj({children:e,sx:n,gap:i=20,repeatBaseForLargeScreen:o=3}){const{isMobile:r,minDevice:a}=Bp();let s={};if(r)s={display:"flex",flexDirection:"column",gap:i};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=o+n,!0})),s={display:"grid",gap:i,gridTemplateColumns:`repeat(${e}, 1fr)`}}return G.jsx(t.Box,{sx:Object.assign(Object.assign({},s),n),children:e})}function Vj({text:e,onClick:n}){const i=t.useTheme();return G.jsxs(t.Box,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:i.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",color:"primary.main",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:n,children:[e,G.jsx(t.Box,{component:se.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function Hj({tags:e,onDeleteTag:n,sx:i}){return e.length?G.jsx(t.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center"},i),children:e.map((e=>G.jsxs(t.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[G.jsx(Nh,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n(e)})]},e.address)))}):null}function Wj({chainId:e,address:n,type:i=exports.PageType.PoolDetail}){const{isMobile:o}=Bp();return G.jsx(t.Box,{component:"button",onClick:t=>{t.stopPropagation(),zy.getState().push({type:i,params:{chainId:e,address:n}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,color:"text.primary","&:hover":{opacity:.5}},o?{width:64,height:36,backgroundColor:"background.tag"}:{width:40,height:32,backgroundColor:"transparent",borderWidth:1,borderStyle:"solid",borderColor:"border.main"}),children:G.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.83333 14.1667H7.5V8.33333H5.83333V14.1667ZM9.16667 14.1667H10.8333V5.83333H9.16667V14.1667ZM12.5 14.1667H14.1667V10.8333H12.5V14.1667ZM4.16667 17.5C3.70833 17.5 3.31597 17.3368 2.98958 17.0104C2.66319 16.684 2.5 16.2917 2.5 15.8333V4.16667C2.5 3.70833 2.66319 3.31597 2.98958 2.98958C3.31597 2.66319 3.70833 2.5 4.16667 2.5H15.8333C16.2917 2.5 16.684 2.66319 17.0104 2.98958C17.3368 3.31597 17.5 3.70833 17.5 4.16667V15.8333C17.5 16.2917 17.3368 16.684 17.0104 17.0104C16.684 17.3368 16.2917 17.5 15.8333 17.5H4.16667ZM4.16667 15.8333H15.8333V4.16667H4.16667V15.8333Z",fill:"currentColor"})})})}function $j(n){var{sx:i,children:o,empty:r,loading:a,hasMore:s,loadMore:l,loadMoreLoading:d}=n,c=U(n,["sx","children","empty","loading","hasMore","loadMore","loadMoreLoading"]);const u=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",borderRadius:16},i),...c,children:[G.jsx(t.Box,{component:"table",sx:Object.assign({width:"100%",borderCollapse:"collapse","& th":{px:24,py:12,typography:"h6",lineHeight:"20px",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:12,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.tag"},"& tbody tr":{borderWidth:"1px 0px 1px 0px",borderStyle:"solid",borderColor:"border.main"}},!r&&!a&&{"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${"dark"===u.palette.mode?"#1A1A1B":t.alpha("#1A1A1B",.1)} -2px 0px 4px 0px`}}}),children:o}),s&&G.jsx(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:l,children:d?G.jsx(t.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function zj({sx:n}){const{supportAMMV2:i,supportAMMV3:o}=X(),r=i||o;return G.jsxs(t.Box,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},n),children:[G.jsx(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(wy,{width:24,tokens:[],mr:6,showChainLogo:!0}),G.jsx(t.Skeleton,{variant:"rounded",height:20,width:88})]})}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),r&&G.jsxs(t.Box,{children:[G.jsx(t.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),G.jsx(t.Skeleton,{variant:"rounded",height:32,sx:{mt:20}})]})}function Zj({sx:i,value:r,onChange:a,searchAddress:s}){const[l,d]=n.useState(!1),{isMobile:c}=Bp();return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign(Object.assign({typography:"body2",display:"flex",alignItems:"center",justifyContent:"flex-start",px:12,height:32,backgroundColor:"background.tag",color:"text.secondary",borderRadius:8,fontWeight:600},c?{width:"100%"}:{minWidth:220}),i),onClick:()=>d(!0),children:[G.jsx(t.Box,{component:se.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),G.jsx(e.Trans,{id:"A1taO8",message:"Search"})]}),G.jsx(Xf,{value:r,open:l,multiple:!0,title:G.jsx(e.Trans,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:o.i18n._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{d(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];a(t)}else a(e);d(!1)}},searchOtherAddress:e=>s(e,(()=>d(!1))),modal:!0})]})}var Qj;function Gj({apy:e,dailyApy:n,weeklyApy:i,sx:o}){const r=t.useTheme();return G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{maxWidth:216,typography:"h6",fontWeight:500,color:"text.secondary"},children:[G.jsx(t.Box,{sx:{fontWeight:700},children:"Base vAPY (annualized)"}),G.jsxs(t.Box,{component:"ul",sx:{pl:16,my:0,listStyleType:"disc"},children:[G.jsxs("li",{children:["Daily: ",Vu({input:n,showDecimals:2})]}),G.jsxs("li",{children:["Weekly: ",Vu({input:i,showDecimals:2})]})]}),G.jsx("br",{}),"*Variable APY based on today’s trading activity"]}),children:G.jsx(t.Box,{component:"span",sx:Object.assign({fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto",typography:"h5",[r.breakpoints.up("tablet")]:{typography:"body2"}},o),children:Vu({input:e,showDecimals:2})})})}!function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(Qj||(Qj={}));const Yj=({pool:e,separate:n,wrap:i})=>{const o=t.useTheme();if(!e)return null;const r=e.coins.slice(0,8),a=r.length,s=n?a>=6&&i?18:24:a>3?24:36,l=(d=a,i?d<=3?{rows:1,cols:d,itemsPerRow:[d]}:4===d?{rows:2,cols:2,itemsPerRow:[2,2]}:5===d?{rows:2,cols:3,itemsPerRow:[3,2]}:6===d?{rows:2,cols:3,itemsPerRow:[3,3]}:7===d?{rows:2,cols:4,itemsPerRow:[4,3]}:8===d?{rows:2,cols:4,itemsPerRow:[4,4]}:{rows:1,cols:d,itemsPerRow:[d]}:{rows:1,cols:d,itemsPerRow:[d]});var d;return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:Array.from({length:l.rows},((i,a)=>G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:n?2:0,[o.breakpoints.up("tablet")]:{gap:n?4:0}},children:r.slice(l.itemsPerRow.slice(0,a).reduce(((e,t)=>e+t),0),l.itemsPerRow.slice(0,a+1).reduce(((e,t)=>e+t),0)).map(((i,o)=>G.jsx(t.Tooltip,{title:i.symbol,placement:"top",onlyHover:!0,leaveDelay:100,sx:{maxWidth:240},children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:o,position:"relative",marginLeft:n?0:o>0?"-8px":0},children:G.jsx(Nh,{address:i.address,width:s,height:s,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0})})},i.address)))},a)))})};function Kj({lqList:e,onDeleteTag:n,sx:i}){if(!(null==e?void 0:e.length))return null;const{name:o}=e[0];return G.jsxs(t.Box,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},i),children:[o,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n()})]})}function Xj({list:e,onClick:n}){return G.jsx(G.Fragment,{children:null==e?void 0:e.map((e=>G.jsxs(t.Box,{onClick:n,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Yj,{pool:e,separate:!1,wrap:!1}),G.jsx(t.Box,{sx:{typography:"h5"},children:e.name})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:["$",e.tvl?qu(new a(e.tvl)):"-"]}),G.jsx(t.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:"TVL"})]})]},e.address)))})}const Jj=new r.CurveApi({contractRequests:nd});function ew(e,t){var n,i,o,r,a,s,l,d,c,u,p,h,m,g;if(!e||!t)return[];const x=[];for(const f of e){if(!(null==f?void 0:f.pool))continue;const e=f.pool,y=((null===(n=e.coins)||void 0===n?void 0:n.map((e=>({chainId:t,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex)),v={chainId:t,name:e.name||"",address:e.address||e.id||"",symbol:e.symbol,decimals:e.decimals,fee:(null===(i=e.fee)||void 0===i?void 0:i.toString())||"0",coins:y,apy:(null===(o=e.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=e.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=e.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=e.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=e.traderCount)||void 0===l?void 0:l.toString())||null,liquidityUtilization:(null===(d=e.liquidityUtilization)||void 0===d?void 0:d.toString())||null,lpTokenBalance:(null===(u=null===(c=f.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.liquidityTokenBalance)||null,daoFee:(null===(p=e.daoFee)||void 0===p?void 0:p.toString())||null,virtualPrice:(null===(h=e.virtualPrice)||void 0===h?void 0:h.toString())||null,poolType:e.poolType||"plain",a:(null===(m=e.a)||void 0===m?void 0:m.toString())||null,offpegFeeMultiplier:(null===(g=e.offpegFeeMultiplier)||void 0===g?void 0:g.toString())||null};x.push(v)}return x}const tw=({children:e,sortList:i,sx:o})=>{const r=t.useTheme(),[a,s]=n.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:8},o),children:[e,G.jsx(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,borderWidth:1,borderStyle:"solid",borderColor:r.palette.border.main,backgroundColor:a?r.palette.background.tag:"transparent",color:a?r.palette.text.primary:r.palette.text.secondary,[r.breakpoints.up("tablet")]:{display:"none"}},onClick:()=>s(!a),children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:G.jsx("path",{d:"M9.16662 16.836C8.88731 16.836 8.65037 16.7387 8.45578 16.5441C8.2612 16.3496 8.16391 16.1126 8.16391 15.8333V10.8931L3.37037 4.76623C3.11551 4.43207 3.07682 4.08144 3.25432 3.71436C3.43169 3.34741 3.73578 3.16394 4.16662 3.16394H15.8333C16.2641 3.16394 16.5682 3.34741 16.7456 3.71436C16.9231 4.08144 16.8844 4.43207 16.6295 4.76623L11.836 10.8931V15.8881C11.836 16.1574 11.7454 16.3828 11.5641 16.5641C11.3827 16.7454 11.1574 16.836 10.8881 16.836H9.16662ZM9.99995 10.1504L13.9954 5.05977H6.00453L9.99995 10.1504Z",fill:"currentColor"})})})]}),a&&G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",[r.breakpoints.up("tablet")]:{display:"none"}},children:i.map(((e,n)=>G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"center",gap:2,borderLeftWidth:1,borderRightWidth:n===i.length-1?1:0,borderTopWidth:1,borderBottomWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",typography:"h6",lineHeight:"30px",color:r.palette.text.secondary,px:20,borderTopLeftRadius:0===n?8:0,borderBottomLeftRadius:0===n?8:0,borderTopRightRadius:n===i.length-1?8:0,borderBottomRightRadius:n===i.length-1?8:0},void 0!==e.direction?{backgroundColor:r.palette.border.disabled,color:r.palette.text.primary}:{}),{[r.breakpoints.down("tablet")]:{flexGrow:1,flexBasis:"25%",textAlign:"center"}}),onClick:e.onClick,children:[e.label,G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("path",{d:"M5.0625 5.82469L5.98781 6.75L9 3.74438L12.0122 6.75L12.9375 5.82469L9 1.88719L5.0625 5.82469Z",fill:"asc"===e.direction?r.palette.text.primary:r.palette.text.disabled}),G.jsx("path",{d:"M5.0625 12.1753L5.98781 11.25L9 14.2556L12.0122 11.25L12.9375 12.1753L9 16.1128L5.0625 12.1753Z",fill:"desc"===e.direction?r.palette.text.primary:r.palette.text.disabled})]})]},e.label)))})]})},nw=e=>{const{direction:n,children:i,onClick:o}=e,r=t.useTheme();return G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:2,typography:"h6",lineHeight:"20px",color:r.palette.text.secondary,cursor:"pointer","&:hover":{opacity:.8}},onClick:o,children:[i,G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("path",{d:"M5.0625 5.82469L5.98781 6.75L9 3.74438L12.0122 6.75L12.9375 5.82469L9 1.88719L5.0625 5.82469Z",fill:"asc"===n?r.palette.text.primary:r.palette.text.disabled}),G.jsx("path",{d:"M5.0625 12.1753L5.98781 11.25L9 14.2556L12.0122 11.25L12.9375 12.1753L9 16.1128L5.0625 12.1753Z",fill:"desc"===n?r.palette.text.primary:r.palette.text.disabled})]})]})};function iw({poolList:n,isMyPool:i,setOperateCurvePool:o}){const r=t.useTheme();return G.jsx(G.Fragment,{children:n.map((n=>G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`,borderRadius:16},className:"gradient-card-border",onClick:()=>{zy.getState().push({type:exports.PageType.CurvePoolDetail,params:{chainId:n.chainId,address:n.address}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600},children:n.name}),G.jsx(t.Box,{sx:{maxWidth:146,wordBreak:"break-word",typography:"body2",color:r.palette.text.secondary},children:n.coins.map(((e,i)=>G.jsxs(t.Box,{component:"span",children:[e.symbol,i!==n.coins.length-1&&"/"]},e.address)))})]}),G.jsx(Yj,{pool:n,separate:!0,wrap:!0})]}),G.jsxs(t.Box,{sx:{mt:40},children:[G.jsx(Gj,{apy:n.apy,dailyApy:n.dailyApy,weeklyApy:n.weeklyApy}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:20},children:[G.jsxs(t.Box,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",n.tvl?Xu({input:n.tvl,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),G.jsx(t.Box,{sx:{flexShrink:0,flexGrow:0,width:"1px",height:24,backgroundColor:r.palette.border.main}}),G.jsxs(t.Box,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[G.jsx(t.Box,{sx:{typography:"h5"},children:i?n.lpTokenBalance?Au({input:n.lpTokenBalance,decimals:n.decimals}):"-":G.jsxs(G.Fragment,{children:["$",n.volume?Xu({input:n.volume,decimals:2}):"-"]})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:i?"My LP tokens":"Volume"})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[i&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({pool:n,type:Qj.Remove})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({pool:n,type:Qj.Add})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),G.jsx(Wj,{chainId:n.chainId,address:n.address,type:exports.PageType.CurvePoolDetail})]})]},`${n.chainId}-${n.address}`)))})}function ow({poolList:e,isMyPool:n,loading:i,operateCurvePool:r,setOperateCurvePool:a,hasMore:s,loadMore:l,loadMoreLoading:d,orderBy:c,orderDirection:u,setOrderBy:p,setOrderDirection:h}){const m=t.useTheme();return G.jsxs($j,{hasMore:s,loadMore:l,loadMoreLoading:d,empty:!(null==e?void 0:e.length),loading:i,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:"Pool"}),G.jsx(t.Box,{component:"th",children:"Assets"}),G.jsx(t.Box,{component:"th",children:G.jsx(nw,{direction:"apy"===c?u:void 0,onClick:()=>{if("apy"===c)return"desc"===u?void h("asc"):(p(void 0),void h(void 0));p("apy"),h("desc")},children:"APY"})}),G.jsx(t.Box,{component:"th",children:G.jsx(nw,{direction:"tvl"===c?u:void 0,onClick:()=>{if("tvl"===c)return"desc"===u?void h("asc"):(p(void 0),void h(void 0));p("tvl"),h("desc")},children:"TVL"})}),G.jsx(t.Box,{component:"th",children:n?G.jsx(G.Fragment,{children:"My LP tokens"}):G.jsx(nw,{direction:"volume"===c?u:void 0,onClick:()=>{if("volume"===c)return"desc"===u?void h("asc"):(p(void 0),void h(void 0));p("volume"),h("desc")},children:"Volume"})}),G.jsx(t.Box,{component:"th",sx:{width:n?249:155}})]})}),G.jsx(t.Box,{component:"tbody",children:e.map((e=>{var i;let s="";if((null===(i=null==r?void 0:r.pool)||void 0===i?void 0:i.address.toLowerCase())===e.address.toLowerCase())if(r.type===Qj.Remove)s=o.i18n._({id:"0+31GV",message:"Removing"});else s=o.i18n._({id:"1yHVE+",message:"Adding"});const l=m.palette.hover.default;return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(s?", & td":"")]:{backgroundImage:`linear-gradient(${l}, ${l})`}},children:[G.jsxs(t.Box,{component:"td",children:[G.jsx(t.Box,{sx:{typography:"body2",lineHeight:"19px",fontWeight:600},children:e.name}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsx(t.Box,{component:"td",children:G.jsx(Yj,{pool:e,separate:!0,wrap:!1})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(Gj,{apy:e.apy,dailyApy:e.dailyApy,weeklyApy:e.weeklyApy})})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.tvl,decimals:2})}`,children:["$",e.tvl?Xu({input:e.tvl,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:n?G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.lpTokenBalance,decimals:2})}`,children:e.lpTokenBalance?Au({input:e.lpTokenBalance,decimals:e.decimals}):"-"}):G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},title:`$${Au({input:e.volume,decimals:2})}`,children:["$",e.volume?Xu({input:e.volume,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[G.jsx(Wj,{chainId:e.chainId,address:e.address,type:exports.PageType.CurvePoolDetail}),s?G.jsx(Vj,{text:s,onClick:()=>a(null)}):G.jsxs(G.Fragment,{children:[n&&G.jsx(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:()=>{a({pool:e,type:Qj.Remove})},sx:{py:0,height:32},children:o.i18n._({id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{a({pool:e,type:Qj.Add})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},`${e.chainId}-${e.address}`)}))})]})}const rw=({account:e,scrollParentRef:o,activeChainId:a,operateCurvePool:s,setOperateCurvePool:l,children:c,isMyPool:u=!1})=>{var p,h;const m=t.useTheme(),{isMobile:g}=Bp(),x=xp(),f=d.useQueryClient(),{onlyChainId:y}=X(),{filterTokens:v,filterAddressLqList:b,handleDeleteToken:C,handleChangeFilterTokens:j,handleChangeFilterAddress:w}=function(){const[e,t]=n.useState([]),[i,o]=n.useState([]);return{filterTokens:e,filterAddressLqList:i,handleDeleteToken:e=>{t((t=>{const n=[...t],i=n.indexOf(e);return-1!==i&&n.splice(i,1),n}))},handleChangeFilterTokens:e=>{o([]),e.length>0?t([e[e.length-1]]):t([])},handleChangeFilterAddress:e=>{o(e),t([])}}}(),[k,T]=n.useState(),[B,I]=n.useState(),S=n.useMemo((()=>{var t,n;return{chainId:a,pageSize:g?4:8,order:{orderBy:B,orderDirection:k},user:u?null==e?void 0:e.toLowerCase():null,filterState:{tokenAddress:null!==(n=null===(t=v[0])||void 0===t?void 0:t.address.toLowerCase())&&void 0!==n?n:null}}}),[a,g,B,k,u,e,v]),A=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign({},S)}),E=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign({},S)}),O=d.useInfiniteQuery(Object.assign(Object.assign({},A),{enabled:!u,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getAllPools)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getAllPools;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),L=d.useInfiniteQuery(Object.assign(Object.assign({},E),{enabled:u&&null!=e,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getMyLiquidity)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getMyLiquidity;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),M=!!(null==b?void 0:b.length),P=n.useMemo((()=>{var e,t;let n=[];return M?n=[...b]:u?null===(t=L.data)||void 0===t||t.pages.forEach((e=>{var t;const i=ew(null===(t=e.curve_stableswap_ng_getMyLiquidity)||void 0===t?void 0:t.lqList,a);n=[...n,...i]})):null===(e=O.data)||void 0===e||e.pages.forEach((e=>{var t;const i=ew(null===(t=e.curve_stableswap_ng_getAllPools)||void 0===t?void 0:t.lqList,a);n=[...n,...i]})),n}),[M,u,b,null===(p=O.data)||void 0===p?void 0:p.pages,a,null===(h=L.data)||void 0===h?void 0:h.pages]),_=(u?L.hasNextPage:O.hasNextPage)&&!M,N=u?L:O;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:20,display:"flex",flexDirection:"column",gap:12,[m.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[m.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),G.jsx(tw,{sortList:[{label:"TVL",direction:"tvl"===B?k:void 0,onClick:()=>{if("tvl"===B)return"desc"===k?void T("asc"):(I(void 0),void T(void 0));I("tvl"),T("desc")}},{label:"APY",direction:"apy"===B?k:void 0,onClick:()=>{if("apy"===B)return"desc"===k?void T("asc"):(I(void 0),void T(void 0));I("apy"),T("desc")}}].concat(u?[]:[{label:"Volume",direction:"volume"===B?k:void 0,onClick:()=>{if("volume"===B)return"desc"===k?void T("asc"):(I(void 0),void T(void 0));I("volume"),T("desc")}}]),children:G.jsxs(t.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},g?{}:{"& > button":{flex:1}}),children:G.jsx(Zj,{value:v,onChange:j,searchAddress:(e,t)=>q(void 0,void 0,void 0,(function*(){var n,i;const o=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign(Object.assign({},S),{filterState:{poolAddress:e.toLowerCase()}})}),s=x.getInfiniteQuery(r.CurveApi.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign(Object.assign({},S),{filterState:{poolAddress:e.toLowerCase()}})}),l=ew(u?null===(n=(yield f.fetchQuery(s)).curve_stableswap_ng_getMyLiquidity)||void 0===n?void 0:n.lqList:null===(i=(yield f.fetchQuery(o)).curve_stableswap_ng_getAllPools)||void 0===i?void 0:i.lqList,a);return(null==l?void 0:l.length)?G.jsx(Xj,{list:l,onClick:()=>{w(l),t()}}):null}))})}),(M||!!v.length)&&G.jsxs(t.Box,{sx:{my:0},children:[M?G.jsx(Kj,{lqList:b,onDeleteTag:()=>w([])}):null,G.jsx(Hj,{tags:v,onDeleteTag:C})]})]})})]}),g?G.jsx(R,{hasMore:_,threshold:300,loadMore:i.debounce((()=>{N.hasNextPage&&!N.isFetching&&N.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>o.current||null,loader:G.jsx(zj,{sx:{mt:20}},"loader"),children:G.jsxs(qj,{children:[N.isLoading?G.jsx(zj,{}):"",!N.isLoading&&!(null==P?void 0:P.length)&&!N.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!(!a||y)}),!!N.error&&G.jsx(re,{refresh:N.refetch,sx:{mt:40}}),G.jsx(iw,{isMyPool:u,poolList:P,setOperateCurvePool:l})]})}):G.jsxs(G.Fragment,{children:[G.jsx(ow,{isMyPool:u,poolList:P,loading:N.isLoading,operateCurvePool:s,setOperateCurvePool:l,hasMore:_,loadMoreLoading:N.isFetchingNextPage,loadMore:()=>{N.hasNextPage&&!N.isFetching&&N.fetchNextPage()},orderBy:B,orderDirection:k,setOrderBy:I,setOrderDirection:T}),G.jsx(ky,{loading:N.isLoading,refetch:N.error?N.refetch:void 0,empty:!(null==P?void 0:P.length),hasSearch:!(!a||y)})]})]})};function aw({children:e}){const n=t.useTheme();return G.jsx(t.Box,{sx:{px:20,py:16,boxShadow:"0px -1px 0px 0px rgba(55, 55, 57, 0.10)",backgroundColor:"background.paper",borderBottomLeftRadius:16,borderBottomRightRadius:16,position:"fixed",bottom:0,left:0,right:0,[n.breakpoints.up("tablet")]:{position:"static"}},children:e})}const sw=e=>{const n=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,px:12,height:36,borderRadius:8,border:`1px solid ${n.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px",color:n.palette.text.secondary,textTransform:"capitalize"},children:["Slippage Bonus (incl. pricing)",G.jsx(lf,{title:"Bonus comes as an advantage from current coin prices which usually appears for coins which are low in balance"})]}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:n.palette.success.main},children:"-"})]})};function lw({pool:e,account:t}){var i;const o=d.useQuery(Jj.getBalanceOf(null==e?void 0:e.chainId,null==e?void 0:e.address,t)),r=d.useQuery(Jj.getBalances(null==e?void 0:e.chainId,null==e?void 0:e.address,null!==(i=null==e?void 0:e.coins)&&void 0!==i?i:[])),s=d.useQuery(Jj.getTotalSupply(null==e?void 0:e.chainId,null==e?void 0:e.address)),l=n.useMemo((()=>s.data?null==(null==e?void 0:e.decimals)?null:s.data.div(10**e.decimals).dp(e.decimals,a.ROUND_DOWN):null),[s.data,null==e?void 0:e.decimals]),c=n.useMemo((()=>o.data?null==(null==e?void 0:e.decimals)?null:o.data.div(10**e.decimals).dp(e.decimals,a.ROUND_DOWN):null),[o.data,null==e?void 0:e.decimals]),u=n.useMemo((()=>r.data?null==(null==e?void 0:e.coins)?null:r.data.map(((t,n)=>{const i=e.coins[n];return t.div(10**i.decimals).dp(i.decimals,a.ROUND_DOWN)})):null),[r.data,null==e?void 0:e.coins]),p=n.useMemo((()=>u&&c&&l?null==(null==e?void 0:e.coins)?null:u.map(((t,n)=>{const i=e.coins[n];return t.multipliedBy(c).div(l).dp(i.decimals,a.ROUND_DOWN)})):null),[u,c,l,null==e?void 0:e.coins]);return{lpTokenTotalSupply:l,tokenBalances:u,lpTokenBalance:c,userTokenBalances:p,lpTokenBalanceLoading:o.isLoading||r.isLoading||s.isLoading}}const dw=({operateCurvePool:e})=>{const i=t.useTheme(),{account:s,chainId:l}=cp(),c=Up(),u=d.useQueryClient(),[p,h]=n.useState(!1),[m,g]=n.useState({}),x=n.useRef(m);x.current=m;const{slipper:f,setSlipper:y,slipperValue:v,resetSlipper:b}=nv({address:e.pool.address}),{lpTokenTotalSupply:C,tokenBalances:j,lpTokenBalance:w,userTokenBalances:k}=lw({pool:e.pool,account:s}),T=n.useCallback((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),g(t)}),[e.pool.coins]);n.useEffect((()=>{T()}),[T]);const B=(t,n)=>{g((i=>{const o=Object.assign(Object.assign({},i),{[t]:n});if(p&&j){const i=e.pool.coins.findIndex((e=>e.address===t));if(-1!==i){const r=j[i],s=new a(n||"0");s.isZero()||""===n?e.pool.coins.forEach((e=>{e.address!==t&&(o[e.address]="0")})):r&&r.gt(0)&&s.gt(0)&&e.pool.coins.forEach(((e,t)=>{if(t!==i){const n=j[t];if(n&&n.gt(0)){const t=n.div(r),i=s.multipliedBy(t).dp(e.decimals,a.ROUND_DOWN).toString();o[e.address]=i}else o[e.address]="0"}}))}}return o}))},I=d.useQueries({queries:e.pool.coins.map((t=>{const n=id.getFetchTokenQuery(t.chainId,t.address,s,e.pool.address);return{queryKey:n.queryKey,enabled:n.enabled&&null!=t.chainId&&null!=t.address&&null!=s&&null!=e.pool.address,queryFn:n.queryFn}})),combine:e=>({data:e.map((e=>{var t,n,i,o;return{address:null===(t=e.data)||void 0===t?void 0:t.address,symbol:null===(n=e.data)||void 0===n?void 0:n.symbol,balance:null===(i=e.data)||void 0===i?void 0:i.balance,allowance:null===(o=e.data)||void 0===o?void 0:o.allowance}})),loading:e.some((e=>e.isLoading))})}),{getApprovalState:S,getBalanceState:A,getPendingRest:E,submitApprove:O}=(({account:e,chainId:t,offset:i,contractAddress:s})=>{var l,c;const u=Up(),p=d.useQueryClient(),{runningRequests:h}=qp(),{updateBlockNumber:m}=kp(),g=n.useMemo((()=>null!=s?s:r.contractConfig[t].DODO_APPROVE),[t,s]),x=n.useMemo((()=>{var e;return t?null===(e=r.basicTokenMap[t])||void 0===e?void 0:e.address:null}),[t]),f=d.useMutation({mutationFn:n=>q(void 0,[n],void 0,(function*({token:n,isReset:i,submittedBack:r,canceledCallback:s,successBack:l,failedCallback:d}){if(!g||!e||!n)return;const c=rp(n),h=i?new a(0):void 0,x=i?o.i18n._({id:"OfhWJH",message:"Reset"}):o.i18n._({id:"Z7ZXbT",message:"Approve"}),f=yield u.execute(`${x} ${c}`,{opcode:Mp.Approval,token:n,contract:g,amt:h},{submittedBack:r,metadata:{[exports.MetadataFlag.approve]:!0}});if(f===Ap.Canceled&&(null==s||s()),f===Ap.Success&&l&&l(),f===Ap.Failed&&(null==d||d()),f!==Ap.Success)return f;yield m(),p.invalidateQueries({queryKey:id.getFetchTokenQuery(t,null==n?void 0:n.address,e,g).queryKey,refetchType:"all"})}))}),y=n.useCallback(((t,n,o,r)=>{var s,l;if(!t)return oh.Loading;const d=h.some((e=>{var n,i,o;return(null===(n=e.spec)||void 0===n?void 0:n.opcode)===Mp.Approval&&(null===(i=e.spec)||void 0===i?void 0:i.token.address)===(null==t?void 0:t.address)&&(null===(o=e.spec)||void 0===o?void 0:o.contract)===g})),c=(null===(l=null===(s=f.variables)||void 0===s?void 0:s.token)||void 0===l?void 0:l.address)===(null==t?void 0:t.address)&&f.isPending,u=new a(null!=n?n:0);return e?!o||u.minus(null!=i?i:0).gt(o)||u.isZero()?oh.Unchecked:t&&t.address===x?oh.Sufficient:d||c?oh.Approving:r?u.minus(null!=i?i:0).gt(r)?oh.Insufficient:oh.Sufficient:oh.Loading:oh.Unchecked}),[e,x,g,i,h,f.isPending,null===(c=null===(l=f.variables)||void 0===l?void 0:l.token)||void 0===c?void 0:c.address]);return{getApprovalState:y,getPendingRest:n.useCallback(((e,t)=>("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)),[]),getBalanceState:n.useCallback(((t,n,o)=>e?o?t.minus(null!=i?i:0).gt(o)?rh.Insufficient:rh.Sufficient:rh.Loading:rh.Unchecked),[e,i]),submitApprove:n.useCallback(((e,t,n,i,o,r)=>q(void 0,void 0,void 0,(function*(){f.mutate({token:e,isReset:t,submittedBack:n,canceledCallback:i,successBack:o,failedCallback:r})}))),[f]),getMaxBalance:n.useCallback(((e,n)=>{const i=new a(0);return e&&void 0!==t&&n||i}),[t])}})({account:s,chainId:e.pool.chainId,contractAddress:e.pool.address}),L=n.useCallback(((t,n,i)=>{var o;if(!j)return{};const r={},s=n||m,l=i||I.data,d=j.findIndex((e=>e&&e.gt(0)));if(-1!==d){const n=j[d],i=e.pool.coins[d];let c;if(void 0!==t)c=t;else{const e=Object.values(s).find((e=>e&&"0"!==e&&""!==e));if(e)c=e;else{const e=null===(o=null==l?void 0:l.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=i.address)||void 0===n?void 0:n.toLowerCase())})))||void 0===o?void 0:o.balance;c=e&&e.gt(0)?e.dp(i.decimals,a.ROUND_DOWN).toString():"1"}}const u=new a(c);r[i.address]=c,e.pool.coins.forEach(((e,t)=>{if(t!==d){const i=j[t];if(i&&i.gt(0)&&n.gt(0)){const t=i.div(n),o=u.multipliedBy(t).dp(e.decimals,a.ROUND_DOWN).toString();r[e.address]=o}else r[e.address]="0"}}))}return r}),[e.pool.coins,j,m,I.data]),R=d.useQuery(Jj.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=m[e.address]||"0",n=new a(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.ROUND_DOWN).toString():"0"})),!0)),M=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(s&&R.data)try{const t=new uC([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_min_mint_amount",type:"uint256"}],name:"add_liquidity",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=m[e.address]||"0",n=new a(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.ROUND_DOWN).toString():"0"})),i=R.data.multipliedBy(1-v).dp(0,a.ROUND_DOWN).toString(),o=t.encodeFunctionData("add_liquidity",[n,i]),s=()=>{u.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),u.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield c.execute("add_liquidity",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveAddLiquidity]:!0},submittedBack:()=>{s()},successBack:()=>{s(),T()}})}catch(e){console.error("curve add_liquidity",e)}}))}),P=n.useMemo((()=>{var n,i;if(!s||e.pool.chainId!==l)return G.jsx(lv,{chainId:e.pool.chainId,fullWidth:!0});if(I.loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!Object.values(m).some((e=>e&&"0"!==e)))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const o of e.pool.coins){const e=m[o.address];if(!e||"0"===e)continue;const r=new a(e);if(!r.isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});const s=I.data.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())})),l=null!==(n=null==s?void 0:s.balance)&&void 0!==n?n:null,d=null!==(i=null==s?void 0:s.allowance)&&void 0!==i?i:null,c=A(r,o,l),u=E(o,d),p=S(o,r,l,d);if(c===rh.Loading||p===oh.Loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Loading..."});if(c===rh.Insufficient)return G.jsxs(t.Button,{fullWidth:!0,disabled:!0,children:["Insufficient ",o.symbol," balance"]});if(p===oh.Approving)return G.jsxs(t.Button,{fullWidth:!0,disabled:!0,children:[o.symbol," Approval Pending"]});if(p===oh.Insufficient)return G.jsxs(t.Button,{fullWidth:!0,onClick:()=>{O(o,u)},children:["Approve ",o.symbol]})}return R.isLoading||!R.data?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):R.data.lte(0)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"}):G.jsx(t.Button,{fullWidth:!0,disabled:M.isPending,isLoading:M.isPending,onClick:()=>{M.mutate()},children:"Add"})}),[s,l,S,A,E,R.data,R.isLoading,M,e.pool.chainId,e.pool.coins,O,m,I.data,I.loading]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[i.breakpoints.up("tablet")]:{pb:20}},children:[G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:4},children:e.pool.coins.map((e=>{var n;const o=null===(n=I.data.find((t=>{var n,i;return(null===(n=t.address)||void 0===n?void 0:n.toLowerCase())===(null===(i=e.address)||void 0===i?void 0:i.toLowerCase())})))||void 0===n?void 0:n.balance;return G.jsxs(t.Box,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:i.palette.background.cardInput},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:e.symbol})]}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{o&&((e,t,n)=>{if(!t)return;const i=t.dp(n,a.ROUND_DOWN).toString();B(e,i)})(e.address,o,e.decimals)},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},children:["Balance: ",o?Au({input:o,decimals:e.decimals}):"-"]})]}),G.jsx(Nf,{value:m[e.address]||"",onChange:t=>{B(e.address,t)},decimals:e.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]},e.symbol)}))}),G.jsxs(t.Box,{sx:{mt:-8,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{const e=!p;if(h(e),e&&j){const e=L(void 0,x.current,I.data);g(e)}},sx:{px:11,py:3,borderRadius:20,border:`1px solid ${p?i.palette.primary.main:i.palette.border.main}`,typography:"body2",fontWeight:500,lineHeight:"19px",color:p?i.palette.primary.contrastText:i.palette.text.primary,backgroundColor:p?i.palette.primary.main:"transparent","&:hover":{opacity:.8}},children:["Balanced proportion: ",p?"ON":"OFF"]}),G.jsx(iv,{value:f,onChange:y,sx:{width:"auto",display:"inline-flex",ml:0}})]}),G.jsx(sw,{})]}),G.jsx(aw,{children:P})]})};function cw({disabled:e,selected:n,onClick:i,children:o,iconVisible:r}){const a=t.useTheme(),s=n?a.palette.success.main:a.palette.text.secondary;return G.jsxs(t.Box,{component:t.ButtonBase,disabled:e,onClick:i,sx:{flexGrow:1,flexShrink:1,flexBasis:"100%",display:"flex",alignItems:"center",gap:8},children:[r&&G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:n?G.jsxs(G.Fragment,{children:[G.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:s}),G.jsx("rect",{x:"4.5",y:"5",width:"9",height:"9",rx:"4.5",fill:s,stroke:s})]}):G.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:s})}),G.jsx(t.Box,{sx:{flexGrow:1,display:"flex",alignItems:"center",gap:8,typography:"body2",fontWeight:500,lineHeight:"19px",color:a.palette.text.primary},children:o})]})}const uw=({operateCurvePool:e})=>{const i=t.useTheme(),{account:o,chainId:s}=cp(),l=Up(),c=d.useQueryClient(),[u,p]=n.useState(""),[h,m]=n.useState("oneCoin"),[g,x]=n.useState(0),[f,y]=n.useState({}),{slipper:v,setSlipper:b,slipperValue:C,resetSlipper:j}=nv({address:e.pool.address}),{lpTokenBalance:w,userTokenBalances:k,lpTokenBalanceLoading:T}=lw({pool:e.pool,account:o}),B=n.useCallback((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),y(t)}),[e.pool.coins]);n.useEffect((()=>{B()}),[B]);const I=n.useMemo((()=>{const e=new a.BigNumber(u);return e.isFinite()?e:null}),[u]),S=d.useQuery(Jj.calcWithdrawOneCoin(e.pool.chainId,e.pool.address,I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",g)),A=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o&&S.data)try{const t=new uC([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"i",type:"int128"},{name:"_min_received",type:"uint256"}],name:"remove_liquidity_one_coin",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",i=S.data.multipliedBy(1-C).dp(0,a.BigNumber.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_one_coin",[n,g,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity_one_coin",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidityOneCoin]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p("")}})}catch(e){console.error("curve remove_liquidity_one_coin",e)}}))}),E=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o)try{const t=new uC([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"_min_amounts",type:"uint256[]"}],name:"remove_liquidity",outputs:[{name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0",i=e.pool.coins.map(((e,t)=>(null==k?void 0:k[t])&&I&&w&&w.gt(0)?k[t].multipliedBy(I).div(w).multipliedBy(10**e.decimals).multipliedBy(1-C).dp(0,a.BigNumber.ROUND_DOWN).toString():"0")),o=t.encodeFunctionData("remove_liquidity",[n,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidity]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p("")}})}catch(e){console.error("curve remove_liquidity",e)}}))}),O=d.useQuery(Object.assign({},Jj.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new a.BigNumber(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0"})),!1)));n.useEffect((()=>{if("custom"===h&&O.isSuccess&&O.data){const t=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,a.BigNumber.ROUND_DOWN);p(t.toString())}}),[O.isSuccess,O.data,h,e.pool.decimals]);const L=d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){if(o&&O.data)try{const t=new uC([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_max_burn_amount",type:"uint256"}],name:"remove_liquidity_imbalance",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new a.BigNumber(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,a.BigNumber.ROUND_DOWN).toString():"0"})),i=O.data.multipliedBy(1+C).dp(0,a.BigNumber.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_imbalance",[n,i]),s=()=>{c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"curve"],refetchType:"all"}),c.invalidateQueries({queryKey:[r.CONTRACT_QUERY_KEY,"token","getFetchTokenQuery"],refetchType:"all"})};return yield l.execute("remove_liquidity_imbalance",{opcode:Mp.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[exports.MetadataFlag.curveRemoveLiquidityImBalance]:!0},submittedBack:()=>{s()},successBack:()=>{s(),p(""),B()}})}catch(e){console.error("curve remove_liquidity_imbalance",e)}}))}),R=n.useMemo((()=>{if(!o||e.pool.chainId!==s)return G.jsx(lv,{chainId:e.pool.chainId,fullWidth:!0});if(!u||"0"===u)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});const n=new a.BigNumber(u);if(!n.isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});if(T)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!w||w.lte(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"No LP token balance"});if(n.gt(w))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"});if("oneCoin"===h)return S.isLoading||!S.data?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):S.data.lte(0)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"}):G.jsx(t.Button,{fullWidth:!0,disabled:A.isPending,isLoading:A.isPending,onClick:()=>{A.mutate()},children:"Remove"});if("balanced"===h)return G.jsx(t.Button,{fullWidth:!0,disabled:E.isPending,isLoading:E.isPending,onClick:()=>{E.mutate()},children:"Remove"});if("custom"===h){if(!Object.values(f).some((e=>e&&"0"!==e)))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const n of e.pool.coins){const e=f[n.address];if(!e||"0"===e)continue;if(!new a.BigNumber(e).isFinite())return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"})}if(O.isLoading||!O.data)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."});if(O.data.lte(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Invalid input"});const i=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,a.BigNumber.ROUND_DOWN);return i.gt(n)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient input amount"}):i.gt(w)?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"}):G.jsx(t.Button,{fullWidth:!0,disabled:L.isPending,isLoading:L.isPending,onClick:()=>{L.mutate()},children:"Remove"})}return null}),[o,e.pool.chainId,e.pool.decimals,e.pool.coins,s,u,T,w,h,S.isLoading,S.data,A,E,f,O.isLoading,O.data,L]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[i.breakpoints.up("tablet")]:{pb:20}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsxs(t.Box,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:i.palette.background.cardInput},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:"LP Tokens"}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{w&&p(w.dp(e.pool.decimals,a.BigNumber.ROUND_DOWN).toString())},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},children:["Balance: ",w?Au({input:w,decimals:e.pool.decimals}):"-"]})]}),G.jsx(Nf,{value:u,onChange:e=>{p(e)},decimals:e.pool.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]}),G.jsxs(t.Box,{sx:{p:12,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,borderRadius:8,border:`1px solid ${i.palette.border.main}`},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(cw,{iconVisible:!0,disabled:!1,selected:"oneCoin"===h,onClick:()=>{m("oneCoin")},children:"One coin"}),G.jsx(cw,{iconVisible:!0,disabled:!1,selected:"balanced"===h,onClick:()=>{m("balanced")},children:"Balanced"}),G.jsx(cw,{iconVisible:!0,disabled:!1,selected:"custom"===h,onClick:()=>{m("custom")},children:"Custom"})]}),G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12},children:e.pool.coins.map(((e,n)=>{var o;return G.jsxs(cw,{iconVisible:"oneCoin"===h||"balanced"===h,disabled:!1,selected:"oneCoin"!==h||g===n,onClick:()=>{"oneCoin"===h&&x(n)},children:[G.jsx(Nh,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:e.symbol}),"oneCoin"===h&&G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:g===n?Au({input:null===(o=S.data)||void 0===o?void 0:o.div(10**e.decimals),decimals:e.decimals}):"0"}),"balanced"===h&&G.jsx(t.Box,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:i.palette.text.primary},children:(null==k?void 0:k[n])&&I&&w&&w.gt(0)?Au({input:k[n].multipliedBy(I).div(w),decimals:e.decimals}):"-"}),"custom"===h&&G.jsx(t.Box,{sx:{ml:"auto"},children:G.jsx(Nf,{value:f[e.address]||"",onChange:t=>{var n,i;n=e.address,i=t,y((e=>Object.assign(Object.assign({},e),{[n]:i})))},decimals:e.decimals,sx:{mt:0,"& input":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,textAlign:"right",border:`1px solid ${i.palette.border.main}`,borderRadius:8,outline:"none",padding:0,color:"text.primary",height:38,width:160,px:12,"&::placeholder":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,color:"text.disabled"}}}})})]},e.address)}))})]}),G.jsx(iv,{value:v,onChange:b,sx:{}})]}),G.jsx(sw,{})]}),G.jsx(aw,{children:R})]})},pw=({onClose:e,poolDetailBtnVisible:i=!0,operateCurvePool:o})=>{const r=t.useTheme(),{account:a}=cp(),[s,l]=n.useState(o.type),[d,c]=n.useState(o.type);d!==o.type&&(c(o.type),l(o.type));const{lpTokenBalance:u,userTokenBalances:p}=lw({pool:o.pool,account:a});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",gap:16,px:20,pt:20},children:[e&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid",borderColor:r.palette.border.main},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",pb:17},children:"Liquidity"}),G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:e,component:t.ButtonBase,children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16}})})]}),G.jsxs(t.Box,{children:[i&&G.jsxs(t.Box,{sx:{px:20,py:12,borderTopLeftRadius:8,borderTopRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,borderBottom:"none",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:"text.primary"},children:o.pool.name}),G.jsx(zf,{address:o.pool.address,customChainId:o.pool.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{zy.getState().push({type:exports.PageType.CurvePoolDetail,params:{address:o.pool.address,chainId:o.pool.chainId}})},sx:{display:"flex",alignItems:"center",color:"text.secondary","&:hover":{color:"text.primary"}},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px"},children:"details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.49988 5L6.44238 6.0575L9.87738 9.5L6.44238 12.9425L7.49988 14L11.9999 9.5L7.49988 5Z",fill:"currentColor"})})]})]}),G.jsxs(t.Box,{sx:{px:20,py:12,borderTopLeftRadius:i?0:8,borderTopRightRadius:i?0:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:12},children:[G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,lineHeight:"16px",color:"text.secondary"},children:"My LP tokens"}),G.jsx(t.Tooltip,{title:G.jsx(t.Box,{sx:{m:8,display:"flex",flexDirection:"column",gap:20,minWidth:216},children:null==p?void 0:p.map(((e,n)=>{const i=o.pool.coins[n];return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600,lineHeight:"14px"},children:[G.jsx(Nh,{width:14,height:14,address:i.address,chainId:i.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsx(t.Box,{children:i.symbol}),G.jsx(t.Box,{sx:{ml:"auto"},children:Au({input:e,decimals:i.decimals})})]},n)}))}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:500,lineHeight:"22px",color:r.palette.text.primary},children:Au({input:u,decimals:o.pool.decimals})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00016 1.33325C4.32016 1.33325 1.3335 4.31992 1.3335 7.99992C1.3335 11.6799 4.32016 14.6666 8.00016 14.6666C11.6802 14.6666 14.6668 11.6799 14.6668 7.99992C14.6668 4.31992 11.6802 1.33325 8.00016 1.33325ZM7.3335 4.66658V5.99992H8.66683V4.66658H7.3335ZM7.3335 7.33325V11.3333H8.66683V7.33325H7.3335ZM2.66683 7.99992C2.66683 10.9399 5.06016 13.3333 8.00016 13.3333C10.9402 13.3333 13.3335 10.9399 13.3335 7.99992C13.3335 5.05992 10.9402 2.66659 8.00016 2.66659C5.06016 2.66659 2.66683 5.05992 2.66683 7.99992Z",fill:r.palette.text.secondary})})]})})]})]})]}),G.jsxs(t.Tabs,{value:s,onChange:(e,t)=>{l(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:[{key:Qj.Add,value:"Add"},{key:Qj.Remove,value:"Remove"}],variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(t.TabPanel,{value:Qj.Add,children:G.jsx(dw,{operateCurvePool:o})}),G.jsx(t.TabPanel,{value:Qj.Remove,children:G.jsx(uw,{operateCurvePool:o})})]})]})},hw=({poolDetailBtnVisible:e,operateCurvePool:i,setOperateCurvePool:o})=>{const{isMobile:r}=Bp(),a=n.useMemo((()=>{if(o)return()=>{o(null)}}),[o]);return r?G.jsx(Eh,{open:!0,onClose:a,scope:!r,modal:r,id:"curve-pool-operate",children:G.jsx(pw,{onClose:a,operateCurvePool:i,poolDetailBtnVisible:e})}):G.jsx(t.Box,{sx:{borderRadius:16,backgroundColor:"background.paper"},children:G.jsx(pw,{onClose:a,operateCurvePool:i,poolDetailBtnVisible:e})})};function mw(e,t,n,i){return"CLASSICAL"===i&&e&&t&&e.isEqualTo(t)?e.times(`1e${n}`).minus(1).div(`1e${n}`):e}function gw(e,t){return e.lte(0)?new a.BigNumber(0):t.div(e)}function xw(e,t,n,i,o,r,s){const l=o&&function(e){return-1!==["0x9D9793e1E18CDEe6cf63818315D55244f73EC006","0x0D04146B2Fe5d267629a7eb341Fb4388DcdBD22f","0x3D9d765b0fbAf594F90F07bc42889473e6613C7A","0x3854BdcB1a7cBA4b1A5f9a7C8719e247Df4c42c6","0xA46F5eC3219f956d14C6816Ef9cf6CaBf13bdD77","0xB16f2Ff8E8499E31B257d2A02D25e8956Ae6aFe7"].findIndex((t=>t.toLowerCase()===e.toLowerCase()))}(o);let d,c;const u="CLASSICAL"===r?i:n;if(e&&t&&u&&void 0!==s){if(c=gw(t,u),d=e.times(c),"CLASSICAL"===r&&l){if(!i)return[void 0,void 0];d.gt(i)&&n&&(c=gw(t,a.BigNumber.min(i,n)),d=d.times(c))}return[c,d.dp(Number(s),a.BigNumber.ROUND_DOWN)]}return[void 0,void 0]}function fw({account:e,pool:t}){var n,i;const{chainId:o,address:r,type:s,baseTokenDecimals:l,quoteTokenDecimals:c,baseLpTokenDecimals:u,quoteLpTokenDecimals:p}=null!=t?t:{},h=d.useQuery($u.getTotalBaseLpQuery(o,r,s,u)),m=d.useQuery($u.getTotalQuoteLpQuery(o,r,s,p)),g=d.useQuery($u.getUserBaseLpQuery(o,r,s,u,e)),x=d.useQuery($u.getUserQuoteLpQuery(o,r,s,p,e)),f=d.useQuery($u.getReserveLpQuery(o,r,s,l,c)),y=d.useQuery($u.getClassicalTargetQuery(o,r,s,l,c)),v=h.data,b=m.data,{baseReserve:C,quoteReserve:j}=f.data||{},w=null===(n=y.data)||void 0===n?void 0:n.baseTarget,k=null===(i=y.data)||void 0===i?void 0:i.quoteTarget,T="DPP"===s,B=T?C:mw(g.data,v,u,s),I=T?j:mw(x.data,b,p,s),[S,A]=T?[new a.BigNumber(1),C]:xw(B,v,C,w,r,s,l);let E,O;if(j){let e=m.data;e||m.isLoading||m.error||!v||(e=v);const t=x.isFetched&&!x.error&&null===I?B:I;T?(E=new a.BigNumber(1),O=j):x.isLoading||x.error||y.error||t?[E,O]=xw(t,e,j,k,r,s,c):O=new a.BigNumber(0)}const L=g.isLoading||x.isLoading,R=g.isError||x.isError,M=()=>{g.refetch(),x.refetch(),h.refetch(),m.refetch(),f.refetch(),y.refetch()},P=L||h.isLoading||m.isLoading||f.isLoading||y.isLoading,_=R||h.isError||m.isError||f.isError||y.isError,N="DVM"===(null==t?void 0:t.type)&&(!j||j.isZero());return{totalBaseLpBalance:v,totalQuoteLpBalance:b,baseReserve:C,quoteReserve:j,classicalBaseTarget:w,classicalQuoteTarget:k,userBaseLpBalance:B,userQuoteLpBalance:I,userBaseLpToTokenBalance:A,userQuoteLpToTokenBalance:O,baseLpToTokenProportion:S,quoteLpToTokenProportion:E,isSinglePool:N,userLpBalanceLoading:L,userLpToTokenBalanceLoading:P,userLpBalanceError:R,userLpToTokenBalanceError:_,userLpToTokenBalanceRefetch:M,error:_,loading:P,refetch:M}}const yw=new r.MiningApi({contractRequests:nd});function vw({chainId:e,address:n,showName:i,size:o,offset:r,rightContent:a}){const s=G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:r},children:[G.jsx(Nh,{chainId:e,address:n,width:o,height:o,noShowChain:!0,marginRight:0}),i]});return a?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s,a]}):s}function bw({miningItem:e}){var t,n;const{account:i}=cp(),o=null!==(t=null==e?void 0:e.rewardTokenInfos)&&void 0!==t?t:[],r=[],s=[];if(e){const t=e.version,a=null!==(n=e.miningContractAddress)&&void 0!==n?n:"";o.forEach((n=>{var o,l,d,c,u,p,h,m,g;const x={address:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",decimals:null==n?void 0:n.decimals,symbol:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"",usdPrice:null!==(d=null==n?void 0:n.price)&&void 0!==d?d:""};if("3"===t)r.push(x),s.push(yw.getPendingRewardQuery(e.chainId,a,i,x.address,x.decimals,t));else switch(e.type){case"classical":r.push(x),s.push(yw.getPendingRewardQuery(e.chainId,a,i,null!==(u=null===(c=e.baseLpToken)||void 0===c?void 0:c.address)&&void 0!==u?u:"",x.decimals,"2")),r.push(x),s.push(yw.getPendingRewardQuery(e.chainId,a,i,null!==(h=null===(p=e.quoteLpToken)||void 0===p?void 0:p.address)&&void 0!==h?h:"",x.decimals,"2"));break;case"vdodo":case"single":r.push(x),s.push(yw.getPendingRewardQuery(e.chainId,a,i,null!==(g=null===(m=e.baseToken)||void 0===m?void 0:m.address)&&void 0!==g?g:"",x.decimals,"2"));break;default:throw new Error(`type: ${e.type} is not valid.`)}}))}return d.useQueries({queries:s,combine:e=>{let t=new a(0),n=new a(0);return{data:e.map(((e,i)=>{const o=r[i],a=e.data;if(a){t=a.plus(t);const e=null==o?void 0:o.usdPrice;e&&(n=n.plus(a.times(e)))}return Object.assign(Object.assign({},o),{amount:a})})),pending:e.some((e=>e.isPending)),error:e.some((e=>e.isError)),totalReward:t,totalRewardUSD:n,refetch:()=>{e.forEach((e=>e.refetch()))}}}})}function Cw({value:e,label:n,tokenList:i,loading:o}){const r=t.useTheme();return G.jsxs(t.Box,{sx:{flexGrow:0,flexShrink:1,width:"30%"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:r.palette.text.secondary},children:n}),G.jsxs(t.Box,{sx:{mt:8,typography:"body1",fontWeight:600,color:r.palette.text.primary,display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.LoadingSkeleton,{loading:o,loadingProps:{width:30},children:e?`$${Au({input:e,decimals:2})}`:"-"}),G.jsx(t.Tooltip,{placement:"top",title:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8,width:190,color:"text.primary",fontWeight:600},children:i.map((e=>{var t;return G.jsx(vw,{chainId:e.chainId,address:e.address,showName:null!==(t=e.symbolEle)&&void 0!==t?t:e.symbol,rightContent:e.amount,size:20,offset:6},e.address+e.chainId)}))}),children:G.jsx(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",color:r.palette.text.secondary,width:16,height:16,"&:hover":{color:"text.primary"}},children:G.jsx(se.DetailBorder,{})})})]})]})}function jw({chainId:n,loading:i,miningItem:r,miningContractAddress:a,stakedTokenUSD:s,stakedTokenUSDLoading:l,miningTitle:d,associatedMineSectionShort:c,stakedTokenList:u,isEnded:p}){var h,m;const g=t.useTheme(),x=bw({miningItem:r});return G.jsxs(t.Box,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8,borderColor:g.palette.border.main,borderStyle:"solid",borderWidth:1,mb:20},children:[c?null:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{py:12,px:20,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.LoadingSkeleton,{loading:i,loadingProps:{width:100},children:G.jsx(wy,{width:24,tokens:u,gap:-6,chainId:n,mr:4,showChainLogo:!1})}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{color:g.palette.text.primary,typography:"body2",fontWeight:600,display:"flex",alignItems:"center"},children:null!=d?d:"-"}),p&&G.jsx(t.Box,{sx:{backgroundColor:g.palette.border.disabled,borderRadius:4,typography:"h6",fontWeight:500,px:8,color:g.palette.text.disabled},children:G.jsx(e.Trans,{id:"237hSL",message:"Ended"})})]}),G.jsx(zf,{size:"small",truncate:!0,address:null!=a?a:"",iconSpace:4,sx:{color:g.palette.text.secondary,typography:"h6"},customChainId:n})]})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,typography:"h6",cursor:"pointer"},onClick:()=>{zy.getState().push({type:exports.PageType.MiningDetail,params:{address:a,chainId:n}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{d:"M7.5 4.5L6.4425 5.5575L9.8775 9L6.4425 12.4425L7.5 13.5L12 9L7.5 4.5Z",fill:"currentColor"})})]})]}),G.jsx(t.Box,{sx:{width:"100%",height:"1px",backgroundColor:g.palette.border.main}})]}),G.jsxs(t.Box,{sx:{py:12,px:20,display:"flex",alignItems:"center",gap:20},children:[G.jsx(Cw,{value:s,label:o.i18n._({id:"luOvdJ",message:"My Staked"}),tokenList:u,loading:i||l}),G.jsx(t.Box,{sx:{width:"1px",height:30,backgroundColor:g.palette.border.main,flexGrow:0,flexShrink:0}}),G.jsx(Cw,{value:x.totalRewardUSD,label:o.i18n._({id:"4cJ0hF",message:"Rewards"}),tokenList:null!==(m=null===(h=x.data)||void 0===h?void 0:h.map((e=>Object.assign(Object.assign({chainId:n},e),{name:e.symbol,amount:Au({input:e.amount,decimals:e.decimals})}))))&&void 0!==m?m:[],loading:x.pending||i})]})]})}const ww=({miningItem:e,successBack:t})=>{const{account:n}=cp(),i=Up();return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const a=yield q(void 0,void 0,void 0,(function*(){if(!n||!(null==e?void 0:e.miningContractAddress))return null;let t="";const i=yield r.MiningApi.encode.claimAllMining(e.miningContractAddress);if(i&&i.data)return i.value=0,i;throw t="invalid data",new Error(t)}));if(!a)return;return yield i.execute(o.i18n._({id:"hom7qf",message:"Claim"}),Object.assign({opcode:Mp.TX},a),{metadata:{[exports.MetadataFlag.claimMining]:"1"},successBack:t})}))})};function kw({miningItem:n}){const i=bw({miningItem:n}),o=ww({miningItem:n,successBack:()=>{i.refetch()}});return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==n?void 0:n.chainId,children:G.jsx(t.Button,{fullWidth:!0,isLoading:o.isPending,disabled:i.totalReward.isZero(),onClick:()=>{o.mutate()},children:o.isPending?G.jsx(e.Trans,{id:"KvG1xW",message:"Claiming"}):G.jsx(e.Trans,{id:"dUdltF",message:"One-Click Claim"})})})}function Tw({tokenSymbol:e,goLpLink:n}){const i=t.useTheme();return G.jsxs(t.HoverAddUnderLine,{sx:{color:i.palette.text.secondary,typography:"h6",display:"flex",alignItems:"center"},component:t.ButtonBase,onClick:n,children:[o.i18n._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:e}}),G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.83324 3.88867L5.01074 4.71117L7.68241 7.38867L5.01074 10.0662L5.83324 10.8887L9.33324 7.38867L5.83324 3.88867Z",fill:"currentColor"})})]})}function Bw({miningItem:n,loading:i,sx:o}){const r=t.useTheme(),s=bw({miningItem:n});return G.jsxs(t.Box,{sx:Object.assign({borderWidth:1,borderRadius:12},o),children:[G.jsxs(t.Box,{sx:{typography:"body1",color:r.palette.text.secondary,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12},children:[G.jsx(e.Trans,{id:"4cJ0hF",message:"Rewards"}),":",G.jsx(t.LoadingSkeleton,{loading:i||s.pending,loadingProps:{width:100},sx:{color:r.palette.text.primary,fontWeight:600},children:s.pending||s.error?"-":`$${Au({input:s.totalRewardUSD,decimals:2})}`})]}),G.jsxs(t.Box,{sx:{borderTopWidth:1,px:20,pt:4,pb:8},children:[(i||s.pending)&&G.jsx(t.LoadingSkeleton,{loading:i,loadingProps:{width:150}}),!i&&!s.pending&&!!n&&s.data.map((e=>G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.address&&e.symbol&&G.jsx(vw,{chainId:n.chainId,address:e.address,showName:e.symbol,size:24,offset:6}),G.jsxs(t.Box,{sx:{ml:"auto"},children:[G.jsx(t.Box,{sx:{typography:"h5",textAlign:"right"},children:Au({input:e.amount,decimals:e.decimals})}),G.jsx(t.Box,{sx:{mt:2,typography:"body2",color:r.palette.text.secondary,textAlign:"right"},children:e.usdPrice&&e.amount?`≈ $${Au({input:new a(e.amount).multipliedBy(e.usdPrice).dp(4,a.ROUND_DOWN),decimals:4})}`:"-"})]})]},e.address)))]})]})}function Iw({status:n,children:i,buttonProps:o}){return!n.needShowTokenStatusButton&&i?G.jsx(G.Fragment,{children:i}):n.insufficientBalance?G.jsx(t.Button,{fullWidth:!0,disabled:!0,...o,children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(t.Button,{fullWidth:!0,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance,...o,children:n.isApproving?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):n.approveTitle})}function Sw(e){if(!e&&"number"!=typeof e)return e;let t="";return t=a.isBigNumber(e)?e.toString(16):new a(e).toString(16),t.length%2?"0x0"+t:"0x"+t}function Aw(e){return Sw(Ru(e,18))}const Ew=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:s})=>{const{chainId:l,account:c}=cp(),u=Up(),p=r.basicTokenMap[l];return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const l=yield q(void 0,void 0,void 0,(function*(){var n,i;if(!(c&&e&&e.baseToken&&e.miningContractAddress))return null;let o="";const s=new a(t),l=Number(e.baseToken.decimals),d=yield r.MiningApi.encode.depositMining(e.miningContractAddress,s,l);if(!d||!d.data)throw o="invalid data",new Error(o);try{return t&&(null===(i=null===(n=e.baseLpToken)||void 0===n?void 0:n.address)||void 0===i?void 0:i.toLocaleLowerCase())===p.address.toLocaleLowerCase()?d.value=Aw(s):d.value=0,d}catch(e){throw console.error("2.0 sendTransaction error",e),o=`2.0 sendTransaction error; ERROR: ${e}`,new Error(o)}}));if(!l)return;return yield u.execute(o.i18n._({id:"JYKRJS",message:"Stake"}),Object.assign({opcode:Mp.TX},l),{metadata:{[exports.MetadataFlag.stakeMining]:"1",logBalance:s},submittedBack:n,successBack:i})}))})};function Ow({goLpLink:n,amount:i,miningItem:r,balanceInfo:a,submittedBack:s,successBack:l,logBalance:d}){var c,u,p,h;const m=Ew({miningItem:r,amount:i,submittedBack:s,successBack:l,logBalance:d}),g=r?`${null===(c=r.baseToken)||void 0===c?void 0:c.symbol}-${null===(u=r.quoteToken)||void 0===u?void 0:u.symbol} LP`:"",x=lh(r?sp(Object.assign(Object.assign({},r.baseLpToken),{symbol:g}),r.chainId):null,{contractAddress:null!==(p=null==r?void 0:r.miningContractAddress)&&void 0!==p?p:"",overrideBalance:a.userBaseLpBalance,amount:i});return n&&g&&(null===(h=a.userBaseLpBalance)||void 0===h?void 0:h.isZero())?G.jsx(t.Button,{fullWidth:!0,onClick:()=>n(),children:o.i18n._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:g}})}):G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==r?void 0:r.chainId,children:G.jsx(Iw,{status:x,children:G.jsx(t.Button,{fullWidth:!0,isLoading:m.isPending,disabled:!Number(i),onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"KsqhWn",message:"Staking"}):G.jsx(e.Trans,{id:"JYKRJS",message:"Stake"})})})})}const Lw=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:s})=>{const{account:l}=cp(),c=Up();return d.useMutation({mutationFn:()=>q(void 0,void 0,void 0,(function*(){const d=yield q(void 0,void 0,void 0,(function*(){if(!(l&&e&&e.baseToken&&e.miningContractAddress))return null;let n="";const i=new a(t),o=Number(e.baseToken.decimals),s=yield r.MiningApi.encode.withdrawMining(e.miningContractAddress,i,o);if(s&&s.data)return s.value=0,s;throw n="invalid data",new Error(n)}));if(!d)return;return yield c.execute(o.i18n._({id:"OFjZGo",message:"Unstake"}),Object.assign({opcode:Mp.TX},d),{metadata:{[exports.MetadataFlag.unstakeMining]:"1",logBalance:s},submittedBack:n,successBack:i})}))})};function Rw({amount:n,miningItem:i,overrideBalance:o,submittedBack:r,successBack:a,logBalance:s}){var l,d;const c=Lw({miningItem:i,amount:n,submittedBack:r,successBack:a,logBalance:s}),u=i?`${null===(l=i.baseToken)||void 0===l?void 0:l.symbol}-${null===(d=i.quoteToken)||void 0===d?void 0:d.symbol} LP`:"",p=lh(i?sp(Object.assign(Object.assign({},i.baseLpToken),{symbol:u}),i.chainId):null,{overrideBalance:o,amount:n,skipQuery:!0});return G.jsx(lv,{includeButton:!0,fullWidth:!0,chainId:null==i?void 0:i.chainId,children:G.jsx(Iw,{status:p,children:G.jsx(t.Button,{fullWidth:!0,isLoading:c.isPending,disabled:!Number(n),onClick:()=>{c.mutate()},children:c.isPending?G.jsx(e.Trans,{id:"1gWStS",message:"Unstaking"}):G.jsx(e.Trans,{id:"OFjZGo",message:"Unstake"})})})})}function Mw(e){var{sx:n}=e,i=U(e,["sx"]);const o=t.useTheme();return G.jsx(t.Box,{sx:Object.assign({paddingTop:20,backgroundColor:o.palette.background.paper,position:"sticky",bottom:0},n),...i})}function Pw({chainId:e,poolAddress:i,status:s,loading:l,operateType:c,setOperateType:u,miningItem:p,associatedMineSectionVisible:h,goLpLink:m}){var g,x,f,y,v,b,C,j,w,k,T,B,I,S,A,E,O;const L=t.useTheme(),{account:R}=cp(),{miningContractAddress:M}=null!=p?p:{},P=sp(null==p?void 0:p.baseToken,e),_=sp(null==p?void 0:p.quoteToken,e),[N,D]=n.useState(""),[F,U]=n.useState(""),q=[{key:"stake",value:o.i18n._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:o.i18n._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:o.i18n._({id:"hom7qf",message:"Claim"})}],V=p&&P&&_&&["classical","lptoken"].includes(null!==(g=p.type)&&void 0!==g?g:"")?{chainId:e,address:i,type:"lptoken"===p.type?"DSP":"CLASSICAL",baseToken:P,quoteToken:_}:void 0,H=fw({account:R,pool:p&&P&&_&&p.baseLpToken&&p.quoteLpToken&&["classical","lptoken"].includes(null!==(x=p.type)&&void 0!==x?x:"")?{chainId:e,address:i,type:"lptoken"===p.type?"DSP":"CLASSICAL",baseTokenDecimals:P.decimals,quoteTokenDecimals:_.decimals,baseLpTokenDecimals:null!==(f=p.baseLpToken.decimals)&&void 0!==f?f:18,quoteLpTokenDecimals:null!==(y=p.quoteLpToken.decimals)&&void 0!==y?y:18}:void 0}),W=d.useQuery($u.getPMMStateQuery(null==V?void 0:V.chainId,null==V?void 0:V.address,null==V?void 0:V.type,null===(v=null==V?void 0:V.baseToken)||void 0===v?void 0:v.decimals,null===(b=null==V?void 0:V.quoteToken)||void 0===b?void 0:b.decimals)),$=d.useQuery(yw.getLpStakedBalance(null==p?void 0:p.chainId,(null==p?void 0:p.miningContractAddress)||void 0,R,null!==(j=null===(C=null==p?void 0:p.baseLpToken)||void 0===C?void 0:C.address)&&void 0!==j?j:"",null===(w=null==p?void 0:p.baseToken)||void 0===w?void 0:w.decimals,null==p?void 0:p.version)),z=$.isLoading||W.isLoading;let Z,Q,Y;if($.data&&H.baseLpToTokenProportion&&H.quoteLpToTokenProportion&&!W.isLoading){const e=null===(k=null==p?void 0:p.baseToken)||void 0===k?void 0:k.price,t=null===(T=null==p?void 0:p.quoteToken)||void 0===T?void 0:T.price,n=null===(B=W.data)||void 0===B?void 0:B.midPrice;Q=$.data.times(H.baseLpToTokenProportion),Y=$.data.times(H.quoteLpToTokenProportion),n?t?Z=Q.times(n).plus(Y).times(t):e&&(Z=Y.times(n).plus(Q).times(e)):e&&t&&(Z=Q.times(e).plus(Y.times(t)))}const K=P&&_?[Object.assign(Object.assign({},P),{amount:Au({input:Q,decimals:P.decimals})}),Object.assign(Object.assign({},_),{amount:Au({input:Y,decimals:_.decimals})})]:[],X=P&&_?`${P.symbol}-${_.symbol} LP`:"- LP",J=s===r.MiningStatusE.ended,ee=(null===(I=null==p?void 0:p.baseLpToken)||void 0===I?void 0:I.address)&&H.userBaseLpBalance?{[null===(S=null==p?void 0:p.baseLpToken)||void 0===S?void 0:S.address]:H.userBaseLpBalance.toString()}:{},te=()=>{H.refetch(),W.refetch(),$.refetch()};return G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{paddingTop:20,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:L.palette.background.paper,px:20,paddingBottom:0,borderBottomLeftRadius:0,borderBottomRightRadius:0},children:[h&&G.jsx(jw,{chainId:e,miningContractAddress:null!=M?M:"",loading:l,miningItem:p,stakedTokenUSD:Z,stakedTokenUSDLoading:z,miningTitle:null!==(A=null==p?void 0:p.title)&&void 0!==A?A:"",stakedTokenList:K}),G.jsxs(t.Tabs,{value:c,onChange:(e,t)=>{u(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:q,variant:"inPaper",tabsListSx:{mt:16}}),G.jsxs(t.TabPanel,{value:"stake",children:[G.jsxs(t.Box,{sx:{mt:20,borderColor:L.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:16},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(wy,{width:K.length>1?20:28,tokens:K,chainId:e}),G.jsx(t.Box,{sx:{ml:8,typography:"body1",color:L.palette.text.primary,fontWeight:600},children:X})]}),!!m&&G.jsx(Tw,{tokenSymbol:X,goLpLink:m})]}),G.jsx(py,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:o.i18n._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:H.userBaseLpBalance||new a("-"),overrideBalanceLoading:H.loading,amt:N,canClickBalance:!0,onInputChange:e=>{D(e)},readOnly:J||l,token:P,checkLogBalance:ee,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),G.jsx(Mw,{children:G.jsx(Ow,{miningItem:p,balanceInfo:H,amount:N,goLpLink:m,submittedBack:()=>D(""),successBack:te,logBalance:ee})})]}),G.jsxs(t.TabPanel,{value:"unstake",children:[G.jsx(py,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:o.i18n._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:$.data||new a("-"),overrideBalanceLoading:$.isLoading,amt:J?null!==(O=null===(E=$.data)||void 0===E?void 0:E.toString())&&void 0!==O?O:"":F,onInputChange:e=>{U(e)},canClickBalance:!0,readOnly:J||l,token:P,checkLogBalance:ee,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),G.jsx(Mw,{children:G.jsx(Rw,{miningItem:p,overrideBalance:$.data,amount:F,submittedBack:()=>U(""),successBack:te,logBalance:ee})})]}),G.jsxs(t.TabPanel,{value:"claim",children:[G.jsx(Bw,{miningItem:p,loading:l,sx:{mt:20}}),G.jsx(Mw,{children:G.jsx(kw,{miningItem:p})})]})]})]})})}function _w({chainId:e,account:t,poolAddress:i,goLpLink:o}){var a,s,l;const c=xp().getQuery(r.MiningApi.graphql.fetchMiningList,{where:{chainIds:[e],user:t,filterState:{address:i}}}),u=d.useQuery(Object.assign(Object.assign({},c),{enabled:!!i})),p=null===(l=null===(s=null===(a=u.data)||void 0===a?void 0:a.mining_list)||void 0===s?void 0:s.list)||void 0===l?void 0:l[0],{status:h}=function({miningItem:e}){var t,n;let i=r.MiningStatusE.active,o=[];if(null==e?void 0:e.rewardTokenInfos)if("classical"!==e.type){const a=r.MiningApi.utils.getMiningStatusByTimestamp({startTime:null!==(t=e.startTime)&&void 0!==t?t:"",endTime:null!==(n=e.endTime)&&void 0!==n?n:"",rewardTokenInfoList:e.rewardTokenInfos.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))});i=a.status,o.push(a)}else if(e.rewardQuoteTokenInfos){o=[e.rewardTokenInfos,e.rewardQuoteTokenInfos].map((t=>{var n,i;return r.MiningApi.utils.getMiningStatusByTimestamp({startTime:null!==(n=e.startTime)&&void 0!==n?n:"",endTime:null!==(i=e.endTime)&&void 0!==i?i:"",rewardTokenInfoList:t.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))})}));const[{status:t},{status:n}]=o;r.MiningStatusE.active,(t===r.MiningStatusE.upcoming&&n===r.MiningStatusE.upcoming||t===r.MiningStatusE.upcoming&&n===r.MiningStatusE.ended||t===r.MiningStatusE.ended&&n===r.MiningStatusE.upcoming)&&r.MiningStatusE.upcoming,t===r.MiningStatusE.ended&&n===r.MiningStatusE.ended&&r.MiningStatusE.ended}return{status:i,miningStatusList:o}}({miningItem:p}),[m,g]=n.useState(h===r.MiningStatusE.ended?"unstake":"stake");return G.jsx(Pw,{chainId:e,loading:u.isLoading||u.isPending,operateType:m,setOperateType:g,associatedMineSectionVisible:!0,miningItem:p,status:h,goLpLink:o,poolAddress:i})}const Nw=()=>{const n=t.useTheme();return G.jsx(t.Tooltip,{placement:"top-end",leaveDelay:100,title:G.jsx(t.Box,{sx:{maxWidth:240,color:n.palette.warning.main,typography:"h6",fontWeight:500,"&>a":{textDecoration:"underline",color:n.palette.warning.main},"&>a:hover":{color:t.alpha(n.palette.warning.main,.5)}},children:G.jsx(e.Trans,{id:"QtgfjM",message:"The creator of the liquidity pool can adjust the liquidity distribution by modifying the market-making price parameters. <0>Learn more</0>",components:{0:G.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://docs.dodoex.io/en/product/pmm-algorithm"})}})}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2,py:4,px:8,borderRadius:8,backgroundColor:t.alpha(n.palette.warning.main,.1),color:n.palette.warning.main,typography:"h6",fontWeight:500,lineHeight:"16px",cursor:"help"},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.jsx("path",{d:"M8.00008 10.6666C8.18897 10.6666 8.3473 10.6027 8.47508 10.4749C8.60286 10.3471 8.66675 10.1888 8.66675 9.99992C8.66675 9.81103 8.60286 9.6527 8.47508 9.52492C8.3473 9.39714 8.18897 9.33325 8.00008 9.33325C7.81119 9.33325 7.65286 9.39714 7.52508 9.52492C7.3973 9.6527 7.33341 9.81103 7.33341 9.99992C7.33341 10.1888 7.3973 10.3471 7.52508 10.4749C7.65286 10.6027 7.81119 10.6666 8.00008 10.6666ZM7.33341 7.99992H8.66675V4.66659H7.33341V7.99992ZM8.00008 14.6666C6.45564 14.2777 5.18064 13.3916 4.17508 12.0083C3.16953 10.6249 2.66675 9.08881 2.66675 7.39992V3.33325L8.00008 1.33325L13.3334 3.33325V7.39992C13.3334 9.08881 12.8306 10.6249 11.8251 12.0083C10.8195 13.3916 9.54453 14.2777 8.00008 14.6666ZM8.00008 13.2666C9.15564 12.8999 10.1112 12.1666 10.8667 11.0666C11.6223 9.96659 12.0001 8.74436 12.0001 7.39992V4.24992L8.00008 2.74992L4.00008 4.24992V7.39992C4.00008 8.74436 4.37786 9.96659 5.13341 11.0666C5.88897 12.1666 6.84453 12.8999 8.00008 13.2666Z",fill:"currentColor"})}),G.jsx(e.Trans,{id:"iDGO1l",message:"Disclaimer"})]})})};var Dw;function Fw(n){const{ConfirmComponent:i}=X();if(i)return G.jsx(i,{...n});const{open:o,onClose:r,title:a,children:s,singleBtn:l,danger:d,singleBtnText:c,cancelText:u,confirmText:p,disabledConfirm:h,confirmLoading:m,isManualClose:g,onConfirm:x,modal:f}=n;return G.jsx(Eh,{open:o,onClose:r,title:a,modal:f,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1},children:[G.jsx(t.Box,{sx:{typography:"body2",color:a?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:s}),l?G.jsx(t.Box,{sx:{px:20},children:G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,danger:d,sx:{mt:32,mb:20},onClick:()=>{r()},children:c||G.jsx(e.Trans,{id:"DPfwMq",message:"Done"})})}):G.jsxs(t.Box,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{r()},children:u||G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx(t.Button,{sx:{ml:8},variant:t.Button.Variant.outlined,danger:d,disabled:h,isLoading:m,onClick:()=>{x&&x(),g||r()},children:p||G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})]})})}function Uw(e){var{sx:n,label:i,children:o}=e,r=U(e,["sx","label","children"]);return G.jsxs(t.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between"},n),...r,children:[G.jsx(t.Box,{children:i}),G.jsx(t.Box,{sx:{textAlign:"right",fontWeight:600},children:o})]})}function qw({baseToken:e,quoteToken:i,midPrice:o,loading:r,disabled:s}){const l=t.useTheme(),[d,c]=n.useState(!1),u=d?null==i?void 0:i.symbol:null==e?void 0:e.symbol,p=d&&o?new a(1).div(o):o,h=d?null==e?void 0:e.symbol:null==i?void 0:i.symbol;return G.jsxs(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:r,loadingProps:{width:50},children:[e&&i?G.jsx(t.Tooltip,{title:`1 ${u} = ${p?Su({input:p}):""} ${h}`,children:o?G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Su({input:p}):""} ${h}`}):G.jsxs(t.Box,{children:[`1 ${u} = `,G.jsx(t.LoadingSkeleton,{loading:r,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",G.jsx(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!s&&{cursor:"pointer","&:hover":{backgroundColor:t.alpha(l.palette.text.primary,.04)}}),onClick:()=>{s||c((e=>!e))},children:G.jsx(t.Box,{component:se.Switch,sx:{width:18,height:18}})})]})}function Vw({baseToken:n,quoteToken:i,loading:o,midPrice:r,shareOfPool:a,sx:s}){const l=t.useTheme(),d=!n||!i;return G.jsxs(t.Box,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},s),children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsx(qw,{baseToken:n,quoteToken:i,loading:o,disabled:d,midPrice:r})]}),G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:l.spacing(1,0,0),borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:G.jsx(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:a||"-%"})})]})]})}function Hw({open:n,onClose:i,slippage:o,baseToken:r,quoteToken:a,baseAmount:s,quoteAmount:l,lpAmount:d,fee:c,price:u,shareOfPool:p,pairAddress:h,createMutation:m}){const g=t.useTheme(),{isMobile:x}=Bp();return G.jsx(Eh,{modal:!0,open:n,onClose:i,title:d?G.jsx(e.Trans,{id:"AeZIvT",message:"You will receive"}):G.jsx(e.Trans,{id:"aM1tos",message:"You are creating a pool"}),children:G.jsxs(t.Box,{sx:{px:20,py:24,borderTopWidth:1,width:x?"100%":420},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[G.jsx(wy,{width:24,height:24,tokens:r&&a?[r,a]:[],chainId:null==r?void 0:r.chainId}),d?Au({input:d,decimals:18}):""]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,gap:4,fontWeight:600},children:[G.jsx(e.Trans,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==a?void 0:a.symbol}}),G.jsx(lj,{poolType:"AMM V2"})]})]}),G.jsx(t.Box,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:G.jsx(e.Trans,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:Vu({input:o})}})}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:g.palette.background.paperContrast},children:[G.jsx(Uw,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:r}),Au({input:s,decimals:null==r?void 0:r.decimals})]})}),G.jsx(Uw,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==a?void 0:a.symbol}}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:a}),Au({input:l,decimals:null==a?void 0:a.decimals})]})}),G.jsx(Uw,{label:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"}),children:Vu({input:c})}),G.jsx(Uw,{label:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"}),children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{width:18,height:18,marginRight:4,token:r}),G.jsx(qw,{baseToken:r,quoteToken:a,midPrice:u})]})}),G.jsx(Uw,{label:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"}),children:p}),G.jsx(Uw,{label:G.jsx(e.Trans,{id:"ESQO1L",message:"Pool address"}),children:G.jsx(zf,{showCopy:!1,address:null!=h?h:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,sx:{mt:20},isLoading:m.isPending,onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"pwUZo2",message:"Confirming..."}):G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})})}function Ww(e,t,n){const i=new a(e),o=new a(t),r=i.minus(o),s=i.gt(o),l=i.lt(o);return{now:o,target:i,isChange:s||l,change:r,changeText:(l?"":"+")+Su({input:r,showDecimals:n>6?6:4,showPrecisionDecimals:2}),isAdd:s,isRemove:l}}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(Dw||(Dw={}));const $w=e=>q(void 0,[e],void 0,(function*({chainId:e,account:t,srcPool:n,baseToken:i,quoteToken:o,baseAmount:s,quoteAmount:l,feeRate:d,initPrice:c,slippageCoefficient:u,ddl:p,SLIPPAGE_PROTECTION:h}){const m=e?r.basicTokenMap[e]:void 0,g=function({srcPool:e,newPool:t}){if(!e)return null;const{baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=t,{baseReserve:s,quoteReserve:l}=e;return{baseAmount:Ww(o,s,n.decimals),quoteAmount:Ww(r,l,i.decimals),feeRate:Ww(new a(t.feeRate).div(100),e.feeRate,6),initPrice:Ww(t.initPrice,e.i,10),slippageCoefficient:Ww(t.slippageCoefficient||"1",e.k,4)}}({srcPool:n,newPool:{baseToken:i,quoteToken:o,baseAmount:s,quoteAmount:l,feeRate:d,initPrice:c,slippageCoefficient:u}});if(!(t&&e&&g&&n))return null;const f=Number(i.decimals),y=Number(o.decimals);let v;const b=g.slippageCoefficient.target;try{const t=i.symbol===(null==m?void 0:m.symbol),s=o.symbol===(null==m?void 0:m.symbol);if(g.baseAmount.isRemove&&g.quoteAmount.isRemove){const t=[yield $u.getDPPOwnerProxyAddressQuery(e,n.address).queryFn(),g.feeRate.target.multipliedBy(1e4).toNumber(),g.initPrice.target.toNumber(),b.toNumber(),x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString(),x.parseFixed(g.baseAmount.now.multipliedBy(1-h).dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.now.multipliedBy(1-h).dp(y,a.ROUND_FLOOR).toString(),y).toString(),f,y];v=yield r.PoolApi.encode.removeDPPPoolABI(...t)}else{const t=[e,n.address,g.feeRate.target.multipliedBy(1e4).toNumber(),g.initPrice.target.toNumber(),b.toNumber(),g.baseAmount.isAdd?x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString():"0",g.quoteAmount.isAdd?x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString():"0",g.baseAmount.isAdd?"0":x.parseFixed(g.baseAmount.change.abs().dp(f,a.ROUND_FLOOR).toString(),f).toString(),g.quoteAmount.isAdd?"0":x.parseFixed(g.quoteAmount.change.abs().dp(y,a.ROUND_FLOOR).toString(),y).toString(),x.parseFixed(g.baseAmount.now.multipliedBy(1-h).dp(f,a.ROUND_FLOOR).toString(),f).toString(),x.parseFixed(g.quoteAmount.now.multipliedBy(1-h).dp(y,a.ROUND_FLOOR).toString(),y).toString(),0,f,y,Math.ceil(Date.now()/1e3)+(null!=p?p:600)];v=yield r.PoolApi.encode.resetDPPPoolABI(...t)}return t&&g.baseAmount.isAdd&&(v.value=Aw(g.baseAmount.change)),s&&g.quoteAmount.isAdd&&(v.value=Aw(g.quoteAmount.change)),v}catch(e){throw console.error("2.0 resetDPPPool error",e),new Error(`2.0 resetDPPPool error;ERROR:${e}`)}})),zw=(e,t,n)=>t?e&&"0"!==e?n?t.minus(e).toString():t.plus(e).toString():t.toString():e;function Zw({pool:e}){var t,n;const{account:i}=cp(),o=Up(),r=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),s=d.useQuery($u.getLPFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type)),{deadLine:l}=X(),c=d.useMutation({mutationFn:t=>q(this,[t],void 0,(function*({baseAmount:t,quoteAmount:n,isRemove:d=!1,feeRate:c,initPrice:u,slippageCoefficient:p,txTitle:h,submittedBack:m}){var g;if(!e)throw new Error("pool is undefined");const x=s.data;if(!x)throw new Error("lpFeeRate is undefined");if(!r.data)throw new Error("pmmStateQuery.data is undefined");const{pmmParamsBG:f,baseReserve:y,quoteReserve:v}=r.data,b=f.i.toNumber(),C=f.k.toNumber(),j=yield $w({account:i,chainId:null==e?void 0:e.chainId,SLIPPAGE_PROTECTION:tv,srcPool:Object.assign(Object.assign({},e),{baseReserve:y,quoteReserve:v,i:b,k:C,feeRate:x.times(100).toString()}),baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,baseAmount:zw(t,y?new a(y):void 0,d),quoteAmount:zw(n,v?new a(v):void 0,d),feeRate:null!=c?c:x.times(100).toString(),initPrice:null!=u?u:String(b),slippageCoefficient:null!=p?p:String(C),ddl:l});if(!j)throw new Error(`modify pool failed: ${e.address}`);return o.execute(h,Object.assign(Object.assign({opcode:Mp.TX},j),{value:null!==(g=j.value)&&void 0!==g?g:0}),{metadata:{[d?exports.MetadataFlag.removeLiquidity:exports.MetadataFlag.addLiquidity]:!0},submittedBack:m})}))});return{modifyDPPMutation:c}}const Qw=e=>{const{account:t,chainId:i}=cp(),o=Up(),s=d.useQueryClient(),{deadLine:l}=X(),{modifyDPPMutation:c}=Zw({pool:e}),u=d.useMutation({mutationFn:n=>q(void 0,void 0,void 0,(function*(){var d,c,u,p,h;if(!e||!t||!n.balanceInfo)return;const{isRemove:m,baseAmount:g,quoteAmount:f,slippageProtection:y,balanceInfo:v,SLIPPAGE_PROTECTION:b,submittedBack:C,successBack:j,txTitle:w,withdrawInfo:k}=n,T=!m,{address:B,type:I,baseToken:S,quoteToken:A}=e,E=S.address.toLowerCase(),O=A.address.toLowerCase(),L=r.basicTokenMap[i].address.toLowerCase(),R=L===E,M=L===O,P="DSP"===I||"GSP"===I,_="CLASSICAL"===I,N=B.toLocaleLowerCase(),D=new a(g),F=new a(f),U=D.isNaN(),q=F.isNaN(),V=+S.decimals,H=+A.decimals,W=S.symbol,$=A.symbol,z=y;let Z,Q=U?"0":x.parseFixed(D.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString(),G=q?"0":x.parseFixed(F.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString();try{if(T)if(_){const e=!U&&(null==v?void 0:v.classicalBaseTarget)&&v.classicalBaseTarget.gt(0)&&v.totalBaseLpBalance?x.parseFixed(D.multipliedBy(v.totalBaseLpBalance).multipliedBy(1-b).div(v.classicalBaseTarget).dp(V,a.ROUND_FLOOR).toString(),V).toString():"0",t=!q&&(null==v?void 0:v.classicalBaseTarget)&&v.totalQuoteLpBalance&&v.classicalQuoteTarget&&v.classicalQuoteTarget.gt(0)?x.parseFixed(F.multipliedBy(v.totalQuoteLpBalance).multipliedBy(1-b).div(v.classicalQuoteTarget).dp(H,a.ROUND_FLOOR).toString(),H).toString():"0",n=[i,N,U?"0":x.parseFixed(D.dp(V,a.ROUND_FLOOR).toString(),V).toString(),q?"0":x.parseFixed(F.dp(H,a.ROUND_FLOOR).toString(),H).toString(),e,t,R?1:M?2:0,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=yield r.PoolApi.encode.addClassicalLiquidityABI(...n)}else{const e=[i,N,U?"0":x.parseFixed(D.dp(V,a.ROUND_FLOOR).toString(),V).toString(),q?"0":x.parseFixed(F.dp(H,a.ROUND_FLOOR).toString(),H).toString(),Q,G,R?1:M?2:0,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=P?yield r.PoolApi.encode.addDSPLiquidityABI(...e):yield r.PoolApi.encode.addDVMLiquidityABI(...e)}else if(_){if("base"===(U?"quote":"base")){const e=D.dp(V,a.ROUND_FLOOR).toString(),t=k&&k.receiveAmountBg?x.parseFixed(k.receiveAmountBg.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString():Q,n=[i,N,x.parseFixed(e,V).toString(),t];Z=yield r.PoolApi.encode.removeClassicalBaseABI(...n)}else{const e=F.dp(H,a.ROUND_FLOOR).toString(),t=k&&k.receiveAmountBg?x.parseFixed(k.receiveAmountBg.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString():G,n=[i,N,x.parseFixed(e,H).toString(),t];Z=yield r.PoolApi.encode.removeClassicalQuoteABI(...n)}}else{if(!((null==v?void 0:v.baseReserve)&&v.quoteReserve&&v.totalBaseLpBalance&&v.userBaseLpBalance&&v.userBaseLpToTokenBalance))return;let e=new a(0);if(null===(d=v.totalBaseLpBalance)||void 0===d?void 0:d.lte(0))e=v.userBaseLpBalance||new a(0);else if(v.baseReserve.gt(0)&&v.quoteReserve.eq(0)){let t=D;D.gte(v.userBaseLpToTokenBalance)&&(t=v.userBaseLpToTokenBalance),e=t.multipliedBy(v.totalBaseLpBalance).div(v.baseReserve)}else if(v.baseReserve.gt(0)&&v.quoteReserve.gt(0)){let t=D;D.gte(v.userBaseLpToTokenBalance)&&(t=v.userBaseLpToTokenBalance);let n,i=F;if(v.userQuoteLpToTokenBalance&&F.gte(v.userQuoteLpToTokenBalance)&&(i=v.userQuoteLpToTokenBalance),i.gt(0)&&(null===(c=v.userQuoteLpToTokenBalance)||void 0===c?void 0:c.gt(0))&&(n=i.div(v.userQuoteLpToTokenBalance)),t.gt(0)&&v.userBaseLpToTokenBalance.gt(0)&&(n=t.div(v.userBaseLpToTokenBalance)),(null==n?void 0:n.gte(1))&&(n=new a(1)),!n)return;e=n.multipliedBy(v.userBaseLpBalance);const o=e.dp(V,a.ROUND_FLOOR).div(v.totalBaseLpBalance);t=o.multipliedBy(v.baseReserve).dp(V,a.ROUND_FLOOR),i=o.multipliedBy(v.quoteReserve).dp(H,a.ROUND_FLOOR),Q=x.parseFixed(t.multipliedBy(1-z).dp(V,a.ROUND_FLOOR).toString(),V).toString(),G=x.parseFixed(i.multipliedBy(1-z).dp(H,a.ROUND_FLOOR).toString(),H).toString()}const n=R||M,o=[i,N,t,e.isNaN()?"0":x.parseFixed(e.dp(V,a.ROUND_FLOOR).toString(),V).toString(),Q,G,n,Math.ceil(Date.now()/1e3)+(null!=l?l:600)];Z=P?yield r.PoolApi.encode.removeDSPLiquidityABI(...o):yield r.PoolApi.encode.removeDVMLiquidityABI(...o)}}catch(e){throw new Error(`v2 addDVMLiquidity or removeDVMLiquidity or removeDSPLiquidity error: ${e}`)}if(Z&&Z.data){const n={};if(g){const o=null===(u=s.getQueryData(id.getFetchTokenQuery(i,S.address,t).queryKey))||void 0===u?void 0:u.balance;o&&(n[S.address]=o.toString()),e.baseLpToken&&(null==v?void 0:v.userBaseLpBalance)&&(n[e.baseLpToken.id]=v.userBaseLpBalance.toString())}if(f){const o=null===(p=s.getQueryData(id.getFetchTokenQuery(i,A.address,t).queryKey))||void 0===p?void 0:p.balance;o&&(n[A.address]=o.toString()),e.quoteLpToken&&(null==v?void 0:v.userQuoteLpBalance)&&(n[e.quoteLpToken.id]=v.userQuoteLpBalance.toString())}try{let e;T&&R&&(Z.value=Aw(U?"0":D)),T&&M&&(Z.value=Aw(q?"0":F)),U||(e=`${D.toString()}${W}`),q||(e=U?`${F.toString()}${$}`:`${e} & ${F.toString()}${$}`);(yield o.execute(w,Object.assign(Object.assign({opcode:Mp.TX},Z),{value:null!==(h=Z.value)&&void 0!==h?h:0}),{subtitle:e,metadata:{[T?exports.MetadataFlag.addLiquidity:exports.MetadataFlag.removeLiquidity]:!0,logBalance:n},submittedBack:C}))===Ap.Success&&j&&j()}catch(e){throw Error(`v2 sendTransaction error: ${e}`)}}}))}),p="DPP"===(null==e?void 0:e.type)?c:u;return n.useEffect((()=>{p.reset()}),[e]),{operateLiquidityMutation:p}};function Gw({baseToken:t,quoteToken:n,baseAmount:i,quoteAmount:s,slippage:l,fee:c,isExists:p,successBack:h,submittedBack:m}){const g=Up(),{account:x}=cp();e.useLingui();const{deadLine:f}=X();return d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){var e,d;if(!t||!n)throw new Error("token is undefined");if(!x)throw new Error("account is undefined");if(!c)throw new Error("fee is undefined");const y=t.chainId,v=r.basicTokenMap[y].address.toLowerCase(),b=u.getUniswapV2Router02ContractAddressByChainId(y),C=u.getUniswapV2Router02FixedFeeContractAddressByChainId(y),j=!b,w=b||C;if(!w)throw new Error("AMMV2 contract address is not valid.");let k="",T="0x0";const B=t.address.toLowerCase()===v,I=n.address.toLowerCase()===v,S=Ru(i,t.decimals),A=Ru(s,n.decimals),E=S.times(1-l).dp(0,a.ROUND_FLOOR),O=A.times(1-l).dp(0,a.ROUND_FLOOR),L=Ru(c,4).toString(),R=Math.ceil(Date.now()/1e3)+(null!=f?f:600);try{if(B){const t=n.address,i=A.toString(),o=O.toString(),r=E.toString();T=null!==(e=Sw(S))&&void 0!==e?e:"",k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidityETH(t,i,o,r,x,R):u.encodeUniswapV2Router02AddLiquidityETH(t,L,i,o,r,x,R)}else if(I){const e=t.address,n=S.toString(),i=E.toString(),o=O.toString();T=null!==(d=Sw(A))&&void 0!==d?d:"",k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidityETH(e,n,i,o,x,R):u.encodeUniswapV2Router02AddLiquidityETH(e,L,n,i,o,x,R)}else k=j?u.encodeUniswapV2Router02FixedFeeAddLiquidity(t.address,n.address,S.toString(),A.toString(),E.toString(),O.toString(),x,R):u.encodeUniswapV2Router02AddLiquidity(t.address,n.address,L,S.toString(),A.toString(),E.toString(),O.toString(),x,R)}catch(e){throw console.error("encodeUniswapV2Router02AddLiquidity error",e),e}return yield g.execute(p?o.i18n._({id:"E6MqGy",message:"Add liquidity"}):o.i18n._({id:"L37FfW",message:"Create AMM V2 Position"}),{opcode:Mp.TX,to:w,data:k,value:T},{metadata:{[p?exports.MetadataFlag.addLiquidityAMMV2Position:exports.MetadataFlag.createAMMV2Position]:!0},successBack:h,submittedBack:m})}))})}function Yw({lqAndDodoCompareText:n,baseToken:i,quoteToken:r,midPrice:a}){const s=a?Su({input:a}):"";return G.jsxs(t.Box,{sx:{p:10,mb:12,backgroundColor:"background.paperDarkContrast",borderRadius:12},children:[G.jsxs(t.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",justifyContent:"center",color:"error.main",fontWeight:600,mb:10,textAlign:"center"},children:[G.jsx(t.Box,{component:se.Alarm,sx:{mr:4}}),o.i18n._({id:"YUyuNp",message:"{lqAndDodoCompareText} Price Difference",values:{lqAndDodoCompareText:n}})]}),G.jsxs(t.Box,{sx:{typography:"h6",color:"text.secondary",textAlign:"center"},children:[G.jsx(e.Trans,{id:"ZhEBp4",message:"Current liquidity pool token price"}),` 1 ${null==i?void 0:i.symbol} = ${s} ${null==r?void 0:r.symbol} ${o.i18n._({id:"wd1uHY",message:"differs from the price quoted by ZUNO by {lqAndDodoCompareText}",values:{lqAndDodoCompareText:n}})}`]})]})}function Kw({chainId:n,baseTokenStatus:i,quoteTokenStatus:o,children:r}){const{runningRequests:a}=qp(),{account:s,chainId:l}=cp();if(!s||n!==l)return G.jsx(lv,{chainId:n,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[exports.MetadataFlag.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[exports.MetadataFlag.removeLiquidity])})),c=[];i.needShowTokenStatusButton&&c.push(G.jsx(Iw,{status:i})),o.needShowTokenStatusButton&&!i.isApproving&&c.push(G.jsx(Iw,{status:o}));const u=c.length;return 2===u?G.jsx(t.Box,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:c.map((e=>e))}):1===u?c[0]:d?G.jsx(t.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:G.jsx(e.Trans,{id:"UbRKMZ",message:"Pending"})}):G.jsx(G.Fragment,{children:r})}function Xw({pool:i,addPortion:o,midPrice:s,shareOfPool:l}){var d,c,u,p,h,m;const g=t.useTheme(),[x,f]=n.useState(!1);let y="";if(o&&s){const e=new a(1).div(o.plus(1)),t=new a(o).div(o.plus(1)),n=e.times(s),r=n.plus(t);y=o?`${Vu({input:n.div(r)})} ${null===(d=null==i?void 0:i.baseToken)||void 0===d?void 0:d.symbol} + ${Vu({input:t.div(r)})} ${null===(c=null==i?void 0:i.quoteToken)||void 0===c?void 0:c.symbol}`:""}const v=x?null===(u=null==i?void 0:i.quoteToken)||void 0===u?void 0:u.symbol:null===(p=null==i?void 0:i.baseToken)||void 0===p?void 0:p.symbol,b=x&&s?new a(1).div(s):s,C=x?null===(h=null==i?void 0:i.baseToken)||void 0===h?void 0:h.symbol:null===(m=null==i?void 0:i.quoteToken)||void 0===m?void 0:m.symbol;return G.jsxs(t.Box,{sx:{mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsxs(t.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,ml:8,overflow:"hidden"},loading:!i,loadingProps:{width:50},children:[G.jsx(t.Tooltip,{title:`1 ${v} = ${b?Su({input:b}):""} ${C}`,children:s?G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${v} = ${b?Su({input:b}):""} ${C}`}):G.jsxs(t.Box,{children:[`1 ${v} = `,G.jsx(t.LoadingSkeleton,{loading:!0,loadingProps:{width:30},component:"span",sx:{display:"inline-block"}}),` ${C}`]})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,cursor:"pointer",backgroundColor:"background.paperDarkContrast",borderRadius:"50%","&:hover":{backgroundColor:t.alpha(g.palette.text.primary,.04)}},onClick:()=>f((e=>!e)),children:G.jsx(t.Box,{component:se.Switch,sx:{width:18,height:18}})})]})]}),"AMMV2"===(null==i?void 0:i.type)?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:g.spacing(1,0,0),borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"NEQTCn",message:"Share Of Pool"})}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:l})]}):G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:g.spacing(1,0,0),borderColor:"border.main"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:[G.jsx(e.Trans,{id:"22Xs8M",message:"Deposit Ratio"}),G.jsx(t.QuestionTooltip,{ml:4,title:G.jsx(e.Trans,{id:"I0yi1d",message:"Deposit ratio is determined by the current assets ratio in the pool. The ratio does not represent the exchange price"})})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:i&&r.PoolApi.utils.singleSideLp(i.type)?G.jsx(e.Trans,{id:"Kb3KaW",message:"Any Ratio"}):G.jsx(G.Fragment,{children:G.jsx(t.Tooltip,{title:y,children:G.jsx(t.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y})})})})]})]})}function Jw({baseToken:e,quoteToken:t}){const{toFiatPrice:n,fromFiatPrice:i}=Wp({fromToken:null!=e?e:null,toToken:null!=t?t:null});return function({fromToken:e,toToken:t,fromFiatPrice:n,toFiatPrice:i,reverse:o,showDecimals:r=1}){const a={comparePrice:null,comparePriceText:"",loading:!0};return e&&t&&n&&i?(o?(a.loading=!1,a.comparePrice=i.div(n),a.comparePriceText=`1 ${rp(t)} = ${Su({input:a.comparePrice,showDecimals:r})} ${rp(e)}`):(a.loading=!1,a.comparePrice=n.div(i),a.comparePriceText=`1 ${rp(e)} = ${Su({input:a.comparePrice,showDecimals:r})} ${rp(t)}`),a):a}({fromToken:e,toToken:t,fromFiatPrice:i?new a(i):void 0,toFiatPrice:n?new a(n):void 0})}const ek=(e,t,i)=>{const{comparePrice:o}=Jw({baseToken:e,quoteToken:t}),r=n.useMemo((()=>{if(!(i&&o&&o.toNumber()&&i.toNumber()))return 0;const e=o.minus(i);return Math.abs(e.div(o).toNumber())}),[i,o]),s=n.useMemo((()=>`${Uu(new a(r).times(100))}%`),[r]);return{lqAndDodoCompare:r,lqAndDodoCompareText:s,midPrice:i,isShowCompare:r>.01,isWarnCompare:r>.03}};function tk({pool:e,baseAmount:t,quoteAmount:i}){const[o,s,l,c,u,p]=n.useMemo((()=>{var t,n;const{baseToken:i,quoteToken:o}=e||{};let a=!1;if(!i||!o)return[void 0,void 0,void 0,void 0,void 0,a];const s=i.chainId,l=r.basicTokenMap[s],d=(null===(t=l.address)||void 0===t?void 0:t.toLowerCase())===i.address.toLowerCase(),c=(null===(n=l.address)||void 0===n?void 0:n.toLowerCase())===o.address.toLowerCase(),u=d?l.wrappedTokenAddress:i.address,p=c?l.wrappedTokenAddress:o.address,h=new M.Token(i.chainId,u,i.decimals,i.symbol,i.name),m=new M.Token(o.chainId,p,o.decimals,o.symbol,o.name);a=!h.sortsBefore(m);const[g,x]=a?[m,h]:[h,m];return[s,null==e?void 0:e.type,null==e?void 0:e.address,g,x,a]}),[e]),h=$u.getReserveLpQuery(o,l,s,null==c?void 0:c.decimals,null==u?void 0:u.decimals),m="AMMV2"===s,g=d.useQuery(Object.assign(Object.assign({},h),{enabled:!!h.enabled&&m})),x=$u.getTotalBaseLpQuery(o,l,s,18),f=d.useQuery(Object.assign(Object.assign({},x),{enabled:!!x.enabled&&m})),{account:y}=cp(),v=$u.getUserBaseLpQuery(o,l,s,18,y),b=d.useQuery(Object.assign(Object.assign({},v),{enabled:!!v.enabled&&m})),C=n.useMemo((()=>g.isFetched&&!!g.data&&f.isFetched&&!!f.data),[g.isFetched,g.data,f.isFetched,f.data]),[j,w]=n.useMemo((()=>{var e;if(!c||!u||!1===C)return[null,null];const{baseReserve:t,quoteReserve:n}=null!==(e=g.data)&&void 0!==e?e:{baseReserve:0,quoteReserve:0},i=M.CurrencyAmount.fromRawAmount(c,Ru(t,c.decimals).toString()),o=M.CurrencyAmount.fromRawAmount(u,Ru(n,u.decimals).toString());let r=i,a=o;p&&(r=o,a=i);const s=new P.Pair(r,a);if(r.equalTo(0)||a.equalTo(0))return[s,null];const l=a.divide(r);return[s,new M.Price(r.currency,a.currency,l.denominator,l.numerator)]}),[c,u,g.data,p]),[k,T]=n.useMemo((()=>C?w?[new a(w.toSignificant()),new a(w.invert().toSignificant())]:[void 0,void 0]:t&&i?[new a(i).div(t),new a(t).div(i)]:[void 0,void 0]),[w,C,t,i]),B=f.data,I=C?f.data&&c?Ru(f.data,18).toString():"":"0";let S,A;const E=p?u:c,O=p?c:u;if((null==j?void 0:j.liquidityToken)&&I&&B&&E&&O){const e=M.CurrencyAmount.fromRawAmount(null==j?void 0:j.liquidityToken,I);if(void 0!==t&&void 0!==i){if(Number(t)&&Number(i)){const n=M.CurrencyAmount.fromRawAmount(E,Ru(t,E.decimals).toString()),o=M.CurrencyAmount.fromRawAmount(O,Ru(i,O.decimals).toString()),r=null==j?void 0:j.getLiquidityMinted(e,n,o);A=Mu(r.quotient.toString(),18),S=A.div(B.plus(A)).times(100)}}else A=b.data||void 0,A&&(S=A.div(B).times(100))}else C||(S=new a(100));let L="-";return(null==e?void 0:e.baseToken)&&e.quoteToken&&(L=S?`${Su({input:S,showDecimals:2,roundingMode:a.ROUND_HALF_UP})}%`:"0%"),{isRearTokenA:p,pair:j,price:k,invertedPrice:T,reserveQuery:g,totalBaseLpQuery:f,liquidityMinted:A,poolTokenPercentage:S,shareOfPool:L,isExists:C}}function nk({pool:e,maxBaseAmount:t,maxQuoteAmount:i,isRemove:o}){var s,l,c;const[u,p]=n.useState(""),[h,m]=n.useState(""),g=!e||"AMMV2"!==e.type&&"AMMV3"!==e.type,x=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals)),f=()=>{p(""),m("")},y=null==e?void 0:e.type,v=tk({pool:e,baseAmount:u,quoteAmount:h});let b=null===(c=x.data)||void 0===c?void 0:c.midPrice,C=new a(NaN),j=!1,w=!1;const k=x.data;if(e)if(k){const t=k.pmmParamsBG.i,n=k.pmmParamsBG.b,i=k.pmmParamsBG.q;w=("DSP"===e.type||"GSP"===e.type)&&(i.eq(0)||n.eq(0)),j="DVM"===e.type&&new a(i).eq(0),C=w?t:j?a(1):i.div(n)}else"AMMV2"===y&&(b=v.isRearTokenA?v.invertedPrice:v.price,C=b||new a(1));const T=n.useRef(C);if(!e||C.isNaN())return{baseAmount:u,quoteAmount:h,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:f};const B=!j&&!r.PoolApi.utils.singleSideLp(e.type),I=e.baseToken.decimals,S=e.quoteToken.decimals,A=e=>{if(e){let n=C.multipliedBy(e).dp(S).toString();i&&o&&(i.lte(n)||(null==t?void 0:t.lte(0)))&&(n=i.toString()),m(n)}else m(e)};!B||T.current&&C.isEqualTo(T.current)||(T.current=C,A(u));let E=!1;E=!!e&&r.PoolApi.utils.singleSideLp(e.type)?!u&&!h:j?!u:!u||!h;const O=g?x:v.reserveQuery;return{baseAmount:u,quoteAmount:h,handleChangeBaseAmount:e=>{let t=Lu(e,I);null===t&&(t=u),p(t),B&&A(t)},handleChangeQuoteAmount:e=>{let n=Lu(e,S);null===n&&(n=h),m(n),B&&(e=>{if(e){let n=new a(e).div(C).dp(I).toString();t&&o&&(t.lte(n)||(null==i?void 0:i.lte(0)))&&(n=t.toString()),p(n)}else p(e)})(n)},reset:f,addPortion:C,amountLoading:O.isLoading,amountError:O.isError,amountRefetch:O.refetch,amountCheckedDisabled:E,midPrice:b,uniV2Pair:v}}function ik({submittedBack:e,onlyShowSide:i,pool:a,balanceInfo:s}){var l,c,p,h,m,g;const x=t.useTheme(),{isMobile:f}=Bp(),{account:y}=cp(),{baseAmount:v,quoteAmount:b,handleChangeBaseAmount:C,handleChangeQuoteAmount:j,addPortion:w,midPrice:k,amountLoading:T,amountCheckedDisabled:B,uniV2Pair:I,reset:S}=nk({pool:a}),A=d.useQuery($u.getFeeRateQuery(null==a?void 0:a.chainId,null==a?void 0:a.address,null==a?void 0:a.type,y)),E=null===(m=null===(c=null===(l=A.data)||void 0===l?void 0:l.mtFeeRate)||void 0===c?void 0:c.plus(null!==(h=null===(p=A.data)||void 0===p?void 0:p.lpFeeRate)&&void 0!==h?h:0))||void 0===m?void 0:m.toNumber(),O="AMMV2"===(null==a?void 0:a.type),[L,R]=n.useState(!1),{slipper:M,setSlipper:P,slipperValue:_,resetSlipper:N}=nv({address:null==a?void 0:a.address,type:null==a?void 0:a.type}),D=Cv(a);n.useEffect((()=>{(null==a?void 0:a.address)!==(null==D?void 0:D.address)&&(S(),N())}),[a]);const F=r.PoolApi.utils.canOperateLiquidity(null==a?void 0:a.type,void 0,null==a?void 0:a.creator,y),[U,q]=n.useState(!1),{isShowCompare:V,lqAndDodoCompareText:H,isWarnCompare:W}=ek(null==a?void 0:a.baseToken,null==a?void 0:a.quoteToken,k),$=O&&a.chainId?u.getUniswapV2Router02ContractAddressByChainId(a.chainId)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(a.chainId):void 0,z=lh(null==a?void 0:a.baseToken,{amount:v,contractAddress:$}),Z=lh(null==a?void 0:a.quoteToken,{amount:b,contractAddress:$}),Q=z.insufficientBalance||Z.insufficientBalance,{isSinglePool:Y}=s,K=!a||Q||!k||!!s.loading||!!s.error||B||A.isLoading;let X=O?o.i18n._({id:"bwSQI0",message:"Supply"}):o.i18n._({id:"m16xKo",message:"Add"});Q&&(X=o.i18n._({id:"znqB4T",message:"Insufficient balance"}));const J=()=>{S(),N(),e&&e()},{operateLiquidityMutation:ee}=Qw(a),te=()=>{O?R(!0):ee.mutate({txTitle:o.i18n._({id:"OBdohg",message:"Add Liquidity"}),isRemove:!1,baseAmount:v,quoteAmount:b,slippageProtection:_,balanceInfo:s,SLIPPAGE_PROTECTION:tv,submittedBack:J})},ne=Gw({baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,baseAmount:v,quoteAmount:b,fee:E,isExists:!0,slippage:_,submittedBack:()=>{J(),R(!1)}});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:20,pb:18,px:20},children:["quote"===i?"":G.jsx(py,{amt:v,token:null==a?void 0:a.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:C,readOnly:s.loading||!F,sx:{backgroundColor:"background.cardInput",padding:x.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),i?"":G.jsx(cy,{}),"base"===i?"":G.jsx(py,{amt:b,token:null==a?void 0:a.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:j,readOnly:s.loading||!F||Y,sx:{backgroundColor:"background.cardInput",padding:x.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}),G.jsxs(t.LoadingSkeleton,{loading:s.loading||T,sx:{mt:8},children:[G.jsx(iv,{value:M,onChange:P,disabled:!F,type:null==a?void 0:a.type}),G.jsx(Xw,{pool:a,addPortion:w,midPrice:k,shareOfPool:null==I?void 0:I.shareOfPool})]})]}),G.jsxs(t.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[V&&G.jsx(Yw,{baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,lqAndDodoCompareText:H,midPrice:k}),a?G.jsx(Kw,{chainId:a.chainId,baseTokenStatus:z,quoteTokenStatus:Z,children:G.jsx(t.Button,{fullWidth:!0,disabled:K,danger:W,isLoading:ee.isPending||ne.isPending,onClick:()=>{K||(W?q(!0):te())},children:X})}):G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:X})]}),G.jsx(Fw,{open:U,onClose:()=>q(!1),title:o.i18n._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:te,modal:!0,children:G.jsxs(t.Box,{children:[G.jsx(t.Box,{children:o.i18n._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:H}})}),G.jsx(t.Box,{children:o.i18n._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),G.jsx(uf,{message:null===(g=ee.error)||void 0===g?void 0:g.message,onClose:()=>ee.reset(),isDialogModal:f}),O&&!!a&&G.jsx(Hw,{open:L,onClose:()=>R(!1),slippage:_,baseToken:a.baseToken,baseAmount:v,quoteToken:a.quoteToken,quoteAmount:b,fee:E,price:null==I?void 0:I.price,lpAmount:null==I?void 0:I.liquidityMinted,shareOfPool:null==I?void 0:I.shareOfPool,pairAddress:a.address,createMutation:ne})]})}function ok({chainId:e,address:n,token:i,quoteToken:o,lpBalance:r,lpBalanceLoading:a,balanceNeedUpdateLoading:s,tokenBalanceList:l}){var d;const c=o?`${null==i?void 0:i.symbol}/${o.symbol}`:null!==(d=null==i?void 0:i.symbol)&&void 0!==d?d:"";return G.jsxs(t.Box,{sx:{display:"flex"},children:[i?G.jsx(t.Box,{sx:{position:"relative",top:2},children:o?G.jsx(wy,{tokens:[i,o],chainId:e,width:18,mr:4}):G.jsx(Nh,{address:i.address,width:18,height:18,chainId:e,url:i.logoURI,marginRight:4,noShowChain:!0})}):G.jsx(t.Skeleton,{width:32,height:32,sx:{mr:4}}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",wordBreak:"break-all"},children:[G.jsx(t.LoadingSkeleton,{loading:a,loadingProps:{width:30},sx:{display:"flex",alignItems:"center",mr:2},children:s?G.jsx(t.RotatingIcon,{}):Su({input:r||"-"})}),`${c} LP`,!!(null==l?void 0:l.length)&&G.jsx(t.Tooltip,{title:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:l.map((e=>G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:e.token.address,chainId:e.token.chainId,width:14,height:14,url:e.token.logoURI,marginRight:4,noShowChain:!0}),e.token.symbol]}),G.jsxs(t.LoadingSkeleton,{loading:e.loading,children:[!e.balance||e.balance.isZero()||e.balance.isNaN()?"":"~",e.balance?Su({input:e.balance}):""]})]},e.token.address)))}),sx:{padding:20,width:256},children:G.jsx(t.HoverOpacity,{component:se.DetailBorder,sx:{ml:4,width:16,height:16}})}),G.jsx(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:e?np(e,n,"address"):"",sx:{display:"inline-flex",height:14},children:G.jsx(t.HoverOpacity,{component:se.ArrowTopRightBorder,sx:{ml:4,width:14,height:14}})})]})]},n)}function rk({loading:n,hidePoolInfo:i,pool:o,balanceInfo:s}){var l,c,u,p,h,m,g;const x=t.useTheme(),f=n||!o,y=!!o&&r.PoolApi.utils.singleSideLp(o.type),{isTokenLoading:v}=Pf(),{account:b}=cp(),C=d.useQuery($u.getFeeRateQuery(null==o?void 0:o.chainId,null==o?void 0:o.address,null==o?void 0:o.type,b)),j=null===(c=null===(l=C.data)||void 0===l?void 0:l.lpFeeRate)||void 0===c?void 0:c.plus(null!==(p=null===(u=C.data)||void 0===u?void 0:u.mtFeeRate)&&void 0!==p?p:0);let w=!1,k=!1;o&&(s.userBaseLpBalance&&o.baseLpToken&&(w=v(o.baseLpToken.id,s.userBaseLpBalance)),s.userQuoteLpBalance&&o.quoteLpToken&&(k=v(o.quoteLpToken.id,s.userQuoteLpBalance)));const T="AMMV2"===(null==o?void 0:o.type);return G.jsxs(t.Box,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[i?"":G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:x.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:x.spacing(0,0,1)},children:[G.jsxs(t.Box,{children:[G.jsxs(t.LoadingSkeleton,{loading:f,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(h=null==o?void 0:o.baseToken)||void 0===h?void 0:h.symbol,"/",null===(m=null==o?void 0:o.quoteToken)||void 0===m?void 0:m.symbol,"AMMV2"===(null==o?void 0:o.type)&&G.jsx(t.LoadingSkeleton,{loading:C.isLoading,loadingProps:{width:30},sx:{typography:"h6"},children:G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vu({input:j})},components:{0:G.jsx("b",{})}})]}),sx:{maxWidth:240},children:G.jsx(t.Box,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:x.palette.background.tag,color:"text.secondary",whiteSpace:"nowrap"},children:Vu({input:j})})})})]}),G.jsx(t.LoadingSkeleton,{loading:f,children:G.jsx(zf,{address:null!==(g=null==o?void 0:o.address)&&void 0!==g?g:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==o?void 0:o.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==o?void 0:o.address)&&!T?G.jsxs(t.Box,{component:t.ButtonBase,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:o.chainId,address:o.address}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),G.jsxs(t.Box,{sx:{p:x.spacing(12,20)},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsx(t.Box,{sx:{mt:12},children:G.jsx(t.LoadingSkeleton,{loading:f,loadingSx:{width:100},children:y?G.jsxs(G.Fragment,{children:[G.jsx(ok,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,lpBalance:null==s?void 0:s.userBaseLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:w,tokenBalanceList:o?[{token:o.baseToken,balance:null==s?void 0:s.userBaseLpToTokenBalance,loading:s.userLpToTokenBalanceLoading}]:void 0}),G.jsx(ok,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.quoteToken,lpBalance:null==s?void 0:s.userQuoteLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.quoteToken,balance:null==s?void 0:s.userQuoteLpToTokenBalance,loading:s.userLpToTokenBalanceLoading}]:void 0})]}):G.jsx(ok,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,quoteToken:null==o?void 0:o.quoteToken,lpBalance:s.userBaseLpBalance,lpBalanceLoading:s.userLpBalanceLoading,balanceNeedUpdateLoading:w,tokenBalanceList:o?[{token:o.baseToken,balance:s.userBaseLpToTokenBalance||new a(0),loading:s.userLpToTokenBalanceLoading},{token:o.quoteToken,balance:s.userQuoteLpToTokenBalance||new a(0),loading:s.userLpToTokenBalanceLoading}]:void 0})})})]})]})}const ak=({pool:e,isBase:t,baseAmount:n,quoteAmount:i})=>{var o,r;const s="CLASSICAL"===(null==e?void 0:e.type),l=t||void 0===t,c=null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,u=null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals,p=d.useQuery(Object.assign(Object.assign({},$u.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,n&&void 0!==c?x.parseFixed(new a(n).dp(c,a.ROUND_FLOOR).toString(),c).toString():"",c)),{enabled:!!e&&!!n&&s&&l})),h=d.useQuery(Object.assign(Object.assign({},$u.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,i&&void 0!==u?x.parseFixed(new a(i).dp(u,a.ROUND_FLOOR).toString(),u).toString():"",u)),{enabled:!!e&&!!i&&s&&!l}));let m,g="",f="",y="",v="",b="",C=!1,j=null;if(e){const t=ap(e.baseToken.decimals),o=ap(e.quoteToken.decimals);if(y=Su({input:n,showDecimals:t}),v=Su({input:i,showDecimals:o}),s)if(C=l?p.isLoading:h.isLoading,j=l?p.error:h.error,l){if(p.data){g=Su({input:p.data,showDecimals:t}),b=g;const e=new a(n).minus(p.data);y=e.gt(0)?Su({input:e,showDecimals:t}):"-",m=e}}else if(h.data){f=Su({input:h.data,showDecimals:o}),b=f;const e=new a(i).minus(h.data);y=e.gt(0)?Su({input:e,showDecimals:t}):"-",m=e}}let w=[];return e&&(s?t?w.push({amount:y||"0",symbol:e.baseToken.symbol}):w.push({amount:v||"0",symbol:e.quoteToken.symbol}):(w.push({amount:y||"0",symbol:e.baseToken.symbol}),w.push({amount:v||"0",symbol:e.quoteToken.symbol}))),{withdrawFee:b,baseWithdrawFee:g,quoteWithdrawFee:f,receiveBaseAmount:y,receiveQuoteAmount:v,receiveAmountBg:m,receiveList:w,loading:C,error:j}};var sk;!function(e){e[e.base=1]="base",e[e.quote=2]="quote"}(sk||(sk={}));const lk=e=>{const[t,i]=n.useState(sk.base);let o,a;return e&&r.PoolApi.utils.singleSideLp(e.type)&&(o=t===sk.base,a=o?e.baseToken:e.quoteToken),{isBase:o,checkToken:a,checkTokenType:t,setCheckToken:i}};function dk({token:e,pool:n,sx:i,value:o,onChange:r,selectedValue:a,lpBalance:s,balanceMax:l,balanceInfo:d,loading:c}){var u;const p=null==n?void 0:n.chainId;return G.jsxs(t.Box,{sx:i,children:[G.jsxs(t.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:600},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[e?G.jsx(t.Radio,{checked:o===a,onChange:()=>r(o),sx:{mr:16}}):"",G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx(G.Fragment,{children:G.jsx(Nh,{address:e.address,width:24,height:24,chainId:e.chainId||p,url:e.logoURI,noShowChain:!0})}):n&&G.jsx(wy,{tokens:[n.baseToken,n.quoteToken],chainId:(null===(u=n.baseToken)||void 0===u?void 0:u.chainId)||p,width:24,height:24})})]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[e?`${e.symbol} LP `:n&&`${n.baseToken.symbol}\n ${n.quoteToken.symbol}\n LP `,c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{ml:4,position:"relative",top:3}}):s&&Su({input:s})||""]})]}),G.jsx(t.Box,{sx:{typography:"body2",mt:5,color:"text.secondary",textAlign:"right"},children:e?G.jsxs(G.Fragment,{children:[c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{ml:4,position:"relative",top:3}}):`≈ ${l&&Su({input:l})||""}`,` ${e.symbol}`]}):n&&d&&d.userBaseLpToTokenBalance&&d.userQuoteLpToTokenBalance?G.jsxs(G.Fragment,{children:[c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{position:"relative",top:4}}):Su({input:d.userBaseLpToTokenBalance}),` ${null==n?void 0:n.baseToken.symbol} + `,c?G.jsx(t.Box,{component:t.RotatingIcon,sx:{position:"relative",top:4}}):Su({input:d.userQuoteLpToTokenBalance}),` ${null==n?void 0:n.quoteToken.symbol}`]}):""})]})}function ck({pool:e,checkTokenType:t,setCheckToken:n,balanceInfo:i,baseTokenBalanceUpdateLoading:o,quoteBalanceUpdateLoading:a}){if(!e)return null;const s=r.PoolApi.utils.singleSideLp(e.type);return G.jsx(G.Fragment,{children:s?G.jsxs(G.Fragment,{children:[G.jsx(dk,{token:e.baseToken,selectedValue:t,onChange:n,value:sk.base,lpBalance:i&&i.userBaseLpBalance,balanceMax:i&&i.userBaseLpToTokenBalance,loading:o}),G.jsx(dk,{selectedValue:t,onChange:n,sx:{mt:13},token:e.quoteToken,value:sk.quote,lpBalance:i&&i.userQuoteLpBalance,balanceMax:i&&i.userQuoteLpToTokenBalance,loading:a})]}):G.jsx(dk,{pool:e,value:t,onChange:n,lpBalance:i&&i.userBaseLpBalance,balanceInfo:i,loading:o||a})})}function uk({submittedBack:i,onlyShowSide:s,pool:l,balanceInfo:c}){var p,h,m,g,x,f,y,v,b,C;const j=t.useTheme(),{isMobile:w}=Bp(),{account:k}=cp(),T=c.userBaseLpToTokenBalance,B=c.userQuoteLpToTokenBalance,I=c.loading,{slipper:S,setSlipper:A,slipperValue:E,resetSlipper:O}=nv({address:null==l?void 0:l.address}),{isBase:L,checkToken:R,checkTokenType:M,setCheckToken:P}=lk(l),{baseAmount:_,quoteAmount:N,handleChangeBaseAmount:D,handleChangeQuoteAmount:F,addPortion:U,midPrice:V,amountLoading:H,amountCheckedDisabled:W,uniV2Pair:$,reset:z}=nk({pool:l,maxBaseAmount:T,maxQuoteAmount:B}),[Z,Q]=n.useState(""),[Y,K]=n.useState("");n.useEffect((()=>{const e=setTimeout((()=>{Q(_)}),80);return()=>clearTimeout(e)}),[_]),n.useEffect((()=>{const e=setTimeout((()=>{K(N)}),80);return()=>clearTimeout(e)}),[N]);const J=e=>{D(e)},ee=e=>{F(e)},te="AMMV2"===(null==l?void 0:l.type),ne=(null==l?void 0:l.chainId)?r.basicTokenMap[l.chainId]:void 0,ie=null===(p=null==ne?void 0:ne.address)||void 0===p?void 0:p.toLowerCase(),oe=null===(h=null==ne?void 0:ne.wrappedTokenAddress)||void 0===h?void 0:h.toLowerCase(),re=!!l&&[ie,oe].includes(l.baseToken.address.toLowerCase()),ae=!!l&&[ie,oe].includes(l.quoteToken.address.toLowerCase()),se=te&&l&&(re||ae),[le,de]=n.useState(!1),ce=se&&re&&!le&&ne?l?Object.assign(Object.assign({},l.baseToken),{symbol:ne.symbol,address:ne.address}):void 0:null==l?void 0:l.baseToken,ue=se&&ae&&!le&&ne?l?Object.assign(Object.assign({},l.quoteToken),{symbol:ne.symbol,address:ne.address}):void 0:null==l?void 0:l.quoteToken,pe=ak({pool:l?Object.assign(Object.assign({},l),{baseToken:ce,quoteToken:ue}):l,isBase:L,baseAmount:Z,quoteAmount:Y}),{mode:he,modeOptions:me,handleChangeMode:ge,sliderPercentage:xe,handleChangeSliderPercentage:fe,resetPercentage:ye}=function({isBase:e,pool:t,baseOverride:i,quoteOverride:r,resetAmount:a,handleChangeBaseAmount:s,handleChangeQuoteAmount:l}){const[d,c]=n.useState(rv.percentage),[u,p]=n.useState(ov),h=n.useRef(null),m=()=>{h.current&&clearTimeout(h.current)},g=()=>{m(),p(ov)};return n.useEffect((()=>m),[]),{mode:d,modeOptions:[{key:rv.quantity,value:o.i18n._({id:"PIYEqF",message:"Quantity model"})},{key:rv.percentage,value:o.i18n._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{c(e),a(),g()},sliderPercentage:u,handleChangeSliderPercentage:n=>{if(m(),n!==u&&p(n),!t)return;const o=100===n,a=()=>{if(t)if(e||void 0===e){if(i){let e=i.toString();o||(e=Ou(i.times(n/100),t.baseToken.decimals)),s(e)}}else if(r){let e=r.toString();o||(e=Ou(r.times(n/100),t.quoteToken.decimals)),l(e)}};o?a():h.current=setTimeout(a,100)},resetPercentage:g}}({isBase:L,pool:l,baseOverride:T,quoteOverride:B,resetAmount:z,handleChangeBaseAmount:J,handleChangeQuoteAmount:ee});n.useEffect((()=>{z(),ye()}),[M]);const ve=Cv(l);n.useEffect((()=>{(null==l?void 0:l.address)!==(null==ve?void 0:ve.address)&&(z(),O(),ge(rv.percentage),fe(ov))}),[l]),n.useEffect((()=>{he===rv.percentage&&fe(xe)}),[null==T?void 0:T.toString(),null==B?void 0:B.toString()]);const be=r.PoolApi.utils.canOperateLiquidity(null==l?void 0:l.type,void 0,null==l?void 0:l.creator,k),[Ce,je]=n.useState(!1),{isShowCompare:we,lqAndDodoCompareText:ke,isWarnCompare:Te}=ek(null==l?void 0:l.baseToken,null==l?void 0:l.quoteToken,V),Be=d.useQuery($u.getFeeRateQuery(null==l?void 0:l.chainId,null==l?void 0:l.address,null==l?void 0:l.type,k)),Ie=null===(y=null===(g=null===(m=Be.data)||void 0===m?void 0:m.mtFeeRate)||void 0===g?void 0:g.plus(null!==(f=null===(x=Be.data)||void 0===x?void 0:x.lpFeeRate)&&void 0!==f?f:0))||void 0===y?void 0:y.toNumber(),{baseTokenStatus:Se,quoteTokenStatus:Ae}=function({pool:e,baseAmount:t,quoteAmount:n,balanceInfo:i}){var o,s,l,d,c;const{chainId:p,baseToken:h,quoteToken:m}=null!=e?e:{};let g="";const x="AMMV2"===(null==e?void 0:e.type);p&&(g=null!==(o=r.contractConfig[p].DODO_V1_PAIR_PROXY)&&void 0!==o?o:"",x&&(g=u.getUniswapV2Router02ContractAddressByChainId(p)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(e.chainId)));const f=null!==(l=null===(s=null==e?void 0:e.baseLpToken)||void 0===s?void 0:s.id)&&void 0!==l?l:"",y=null!==(c=null===(d=null==e?void 0:e.quoteLpToken)||void 0===d?void 0:d.id)&&void 0!==c?c:"",v="CLASSICAL"===(null==e?void 0:e.type);return{baseTokenStatus:lh(h?Object.assign(Object.assign({},h),{symbol:v?h.symbol+" LP":`${h.symbol}/${null==m?void 0:m.symbol} LP`,address:f}):void 0,{amount:x&&i.userBaseLpToTokenBalance&&i.userBaseLpBalance?new a(t).div(i.userBaseLpToTokenBalance).times(i.userBaseLpBalance).toString():t,skipQuery:!g||!f||!v&&!x,contractAddress:g,overrideBalance:x?i.userBaseLpBalance:i.userBaseLpToTokenBalance}),quoteTokenStatus:lh(m?Object.assign(Object.assign({},m),{address:y}):void 0,{amount:n,skipQuery:!g||!y||!v,contractAddress:g,overrideBalance:i.userQuoteLpToTokenBalance})}}({pool:l,baseAmount:_,quoteAmount:N,balanceInfo:c}),Ee=Se.insufficientBalance||Ae.insufficientBalance,{isSinglePool:Oe}=c,Le=Ee?o.i18n._({id:"znqB4T",message:"Insufficient balance"}):o.i18n._({id:"t/YqKh",message:"Remove"}),Re=()=>{z(),O(),i&&i()},Me=null===(v=null==$?void 0:$.pair)||void 0===v?void 0:v.liquidityToken.decimals,Pe=null===(b=c.userBaseLpBalance)||void 0===b?void 0:b.times(xe/100),_e=Pe&&void 0!==Me?Ru(Pe,Me).toString():"",{operateLiquidityMutation:Ne}=Qw(l),De=function({baseToken:t,quoteToken:n,baseAmount:i,quoteAmount:s,liquidityAmount:l,slippage:c,fee:p,submittedBack:h}){const m=Up(),{account:g}=cp();e.useLingui();const{deadLine:x}=X();return d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){if(!t||!n)throw new Error("token is undefined");if(!g)throw new Error("account is undefined");if(!p)throw new Error("fee is undefined");const e=t.chainId,d=r.basicTokenMap[e].address.toLowerCase(),f=u.getUniswapV2Router02ContractAddressByChainId(e),y=u.getUniswapV2Router02FixedFeeContractAddressByChainId(e),v=!f,b=f||y;if(!b)throw new Error("AMMV2 contract address is not valid.");let C="";const j=t.address.toLowerCase()===d,w=n.address.toLowerCase()===d,k=Ru(new a(i).times(1-c),t.decimals),T=Ru(new a(s).times(1-c),n.decimals),B=Ru(p,4).toString(),I=Math.ceil(Date.now()/1e3)+(null!=x?x:600);try{if(j){const e=n.address,t=T.toString(),i=k.toString();C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidityETH(e,l,t,i,g,I):u.encodeUniswapV2Router02RemoveLiquidityETH(e,B,l,t,i,g,I)}else if(w){const e=t.address,n=k.toString(),i=T.toString();C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidityETH(e,l,n,i,g,I):u.encodeUniswapV2Router02RemoveLiquidityETH(e,B,l,n,i,g,I)}else C=v?u.encodeUniswapV2Router02FixedFeeRemoveLiquidity(t.address,n.address,l,k.toString(),T.toString(),g,I):u.encodeUniswapV2Router02RemoveLiquidity(t.address,n.address,B,l,k.toString(),T.toString(),g,I)}catch(e){throw console.error("encodeUniswapV2Router02RemoveLiquidity error",e),e}return yield m.execute(o.i18n._({id:"cJtosk",message:"Remove liquidity"}),{opcode:Mp.TX,to:b,data:C,value:"0x0"},{metadata:{[exports.MetadataFlag.removeLiqidityAMMV2Position]:!0},submittedBack:h})}))})}({baseToken:ce,quoteToken:ue,baseAmount:_,quoteAmount:N,liquidityAmount:_e,slippage:E,fee:Ie,submittedBack:Re}),Fe=()=>{if(te)return De.mutate();Ne.mutate({txTitle:o.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),isRemove:!0,baseAmount:_,quoteAmount:N,slippageProtection:E,balanceInfo:c,SLIPPAGE_PROTECTION:tv,submittedBack:Re})},Ue=n.useMemo((()=>{var e;const t=new a(_),n=new a(N);return!l||Ee||!V||!!c.loading||!!c.error||W||!!pe.error||pe.loading||!!(null===(e=pe.receiveAmountBg)||void 0===e?void 0:e.lte(0))||Be.isLoading||(te?null==Pe||Pe.lte(0):!t.isFinite()||!n.isFinite()||t.lte(0)&&n.lte(0))}),[W,c.error,c.loading,_,Be.isLoading,te,Ee,Pe,V,l,N,pe.error,pe.loading,pe.receiveAmountBg]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pb:18,px:20},children:[!te&&G.jsxs(t.Box,{sx:{mt:20,borderStyle:"solid",borderWidth:1,borderRadius:12,borderColor:"border.main"},children:[G.jsx(t.Select,{value:he,options:me,onChange:(e,t)=>ge(t),popupOffset:0,sx:{px:20,py:12,width:"100%",backgroundColor:"transparent",color:"text.primary",typography:"body2"}}),!!l&&r.PoolApi.utils.singleSideLp(l.type)&&G.jsx(t.Box,{sx:{pt:20,pb:13,px:20,borderStyle:"solid",borderWidth:"1px 0 0"},children:G.jsx(ck,{pool:l,balanceInfo:c,checkTokenType:M,setCheckToken:P,baseTokenBalanceUpdateLoading:!1,quoteBalanceUpdateLoading:!1})})]}),G.jsx(t.Box,{sx:{pt:20},children:he===rv.percentage?G.jsx(Gy,{disabled:c.loading||!be,value:xe,onChange:fe}):R?G.jsx(py,{amt:L?_:N,token:R,canClickBalance:!0,showPercentage:!0,onInputChange:L?J:ee,readOnly:c.loading||!be,overrideBalance:L?T:B,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}):G.jsxs(G.Fragment,{children:[G.jsx(py,{amt:_,token:null==l?void 0:l.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:J,readOnly:c.loading||!be,overrideBalance:T,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),s?"":G.jsx(cy,{}),"base"===s?"":G.jsx(py,{amt:N,token:null==l?void 0:l.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:ee,readOnly:c.loading||!be||Oe,overrideBalance:B,overrideBalanceLoading:I,sx:{backgroundColor:"background.cardInput",padding:j.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}})]})}),G.jsxs(t.LoadingSkeleton,{loading:c.loading||H,sx:{mt:8},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:8},children:[te&&se&&G.jsx(t.Box,{sx:{px:12,py:4,borderRadius:20,borderWidth:1,backgroundColor:"transparent",color:"primary.main",cursor:"pointer",typography:"body2","&:hover":{backgroundColor:"hover.default"}},component:"button",onClick:()=>de((e=>!e)),children:G.jsx(e.Trans,{id:"/k7Ttv",message:"Receive {0}",values:{0:le?null==ne?void 0:ne.symbol:null==ne?void 0:ne.wrappedTokenSymbol}})}),G.jsx(iv,{value:S,onChange:A,disabled:!be,type:null==l?void 0:l.type,sx:{margin:0}})]}),G.jsx(Xw,{pool:l,addPortion:U,midPrice:V,shareOfPool:null==$?void 0:$.shareOfPool})]}),!!l&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",mt:20,mb:14},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary",position:"relative",top:2},children:G.jsx(e.Trans,{id:"lDgVWA",message:"Receive"})}),G.jsx(t.Box,{sx:{textAlign:"right"},children:pe.receiveList.map(((e,n)=>G.jsxs(t.Box,{sx:{mt:n>0?4:0},children:[G.jsxs(t.LoadingSkeleton,{component:"span",loading:pe.loading,loadingSx:{mr:8,width:100},sx:{display:"inline-block",typography:"h5",fontWeight:600,color:pe.receiveBaseAmount&&"0"!==pe.receiveBaseAmount?"primary.main":"text.primary"},children:[e.amount," "]}),G.jsx(t.Box,{component:"span",sx:{typography:"body2"},children:e.symbol})]},e.symbol)))})]})]}),G.jsxs(t.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[we&&G.jsx(Yw,{baseToken:null==l?void 0:l.baseToken,quoteToken:null==l?void 0:l.quoteToken,lqAndDodoCompareText:ke,midPrice:V}),l?G.jsx(Kw,{chainId:l.chainId,baseTokenStatus:Se,quoteTokenStatus:Ae,children:G.jsx(t.Button,{fullWidth:!0,disabled:Ue,danger:Te,isLoading:Ne.isPending||De.isPending,onClick:()=>{Ue||(Te?je(!0):Fe())},children:Le})}):G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:Le})]}),G.jsx(Fw,{open:Ce,onClose:()=>je(!1),title:o.i18n._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:Fe,modal:!0,children:G.jsxs(t.Box,{children:[G.jsx(t.Box,{children:o.i18n._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:ke}})}),G.jsx(t.Box,{children:o.i18n._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),G.jsx(uf,{message:null===(C=Ne.error)||void 0===C?void 0:C.message,onClose:()=>Ne.reset(),isDialogModal:w})]})}function pk({pool:i,operate:o,hidePoolInfo:r,errorRefetch:a,submittedBack:s}){var l,c,u,p,h,m;const{operateTab:g,operateTabs:x,handleChangeTab:f}=function(t=Qj.Add){const{i18n:i}=e.useLingui(),[o,r]=n.useState(t),a=n.useMemo((()=>[{key:Qj.Add,value:i._({id:"m16xKo",message:"Add"})},{key:Qj.Remove,value:i._({id:"t/YqKh",message:"Remove"})}]),[i._]);return n.useEffect((()=>{r(t)}),[t]),{operateTab:o,operateTabs:a,handleChangeTab:e=>{r(e)}}}(o),{account:y}=cp(),v=fw({account:y,pool:i?{chainId:i.chainId,address:i.address,type:i.type,baseTokenDecimals:i.baseToken.decimals,quoteTokenDecimals:i.quoteToken.decimals,baseLpTokenDecimals:null!==(c=null===(l=i.baseLpToken)||void 0===l?void 0:l.decimals)&&void 0!==c?c:18,quoteLpTokenDecimals:null!==(p=null===(u=i.quoteLpToken)||void 0===u?void 0:u.decimals)&&void 0!==p?p:18}:void 0}),b=d.useQuery($u.getPMMStateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,null===(h=null==i?void 0:i.baseToken)||void 0===h?void 0:h.decimals,null===(m=null==i?void 0:i.quoteToken)||void 0===m?void 0:m.decimals));return v.error||b.error||a?G.jsx(re,{refresh:()=>{v.error&&v.refetch(),b.error&&b.refetch(),a&&a()},sx:{my:40,height:"100%"}}):G.jsxs(G.Fragment,{children:[G.jsx(rk,{pool:i,balanceInfo:v,hidePoolInfo:r}),G.jsxs(t.Tabs,{value:g,onChange:(e,t)=>{f(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:x,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(t.TabPanel,{value:Qj.Add,children:G.jsx(ik,{pool:i,balanceInfo:v,submittedBack:s})}),G.jsx(t.TabPanel,{value:Qj.Remove,children:G.jsx(uk,{pool:i,balanceInfo:v,submittedBack:s})})]})]})}function hk({onClose:i,pool:a,address:s,operate:l,chainId:c,hasMining:u,hidePoolInfo:p,sx:h}){var m,g,x,f,y,v,b,C,j;const{account:w}=cp(),k=c?Hl[c]:"",T=xp(),B=d.useQuery(Object.assign(Object.assign({},T.getQuery(r.PoolApi.graphql.fetchPoolList,{where:{id:null!==(m=null==s?void 0:s.toLocaleLowerCase())&&void 0!==m?m:"",chain:k}})),{enabled:!!s&&!!c})),I=null===(x=null===(g=B.data)||void 0===g?void 0:g.pairs)||void 0===x?void 0:x[0],S=I&&c?function(e,t){var n,i,o,r,a,s;if(e)return{address:e.id,chainId:t,baseToken:Zu(e.baseToken,t),quoteToken:Zu(e.quoteToken,t),type:e.type,creator:e.creator,baseLpToken:{id:null===(n=e.baseLpToken)||void 0===n?void 0:n.id,decimals:Number(null!==(o=null===(i=e.baseLpToken)||void 0===i?void 0:i.decimals)&&void 0!==o?o:18)},quoteLpToken:{id:null===(r=e.quoteLpToken)||void 0===r?void 0:r.id,decimals:Number(null!==(s=null===(a=e.quoteLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18)}}}(I,c):void 0,A=s&&c?S:a,E=B.error?B.refetch:void 0,{poolOrMiningTab:O,poolOrMiningTabs:L,handleChangeTab:R}=function({hasMining:t}){const{i18n:i}=e.useLingui(),[o,r]=n.useState(Dw.Liquidity);return{poolOrMiningTab:o,poolOrMiningTabs:n.useMemo((()=>{const e=[{key:Dw.Liquidity,value:i._({id:"6y2TB3",message:"Liquidity"})},{key:Dw.Mining,value:i._({id:"Sti4vy",message:"Mining"})}];return t?e:e.slice(0,1)}),[i._,t]),handleChangeTab:e=>{r(e)}}}({hasMining:u}),M=fw({account:w,pool:A?{chainId:A.chainId,address:A.address,type:A.type,baseTokenDecimals:A.baseToken.decimals,quoteTokenDecimals:A.quoteToken.decimals,baseLpTokenDecimals:null!==(y=null===(f=A.baseLpToken)||void 0===f?void 0:f.decimals)&&void 0!==y?y:18,quoteLpTokenDecimals:null!==(b=null===(v=A.quoteLpToken)||void 0===v?void 0:v.decimals)&&void 0!==b?b:18}:void 0}),P=!!(null===(C=M.userBaseLpBalance)||void 0===C?void 0:C.gt(0))||!!(null===(j=M.userQuoteLpBalance)||void 0===j?void 0:j.gt(0)),_=null!=c?c:null==A?void 0:A.chainId,N=null!=s?s:null==A?void 0:A.address;return G.jsx(t.Box,{sx:h,children:G.jsxs(t.Tabs,{value:O,onChange:(e,t)=>{R(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[G.jsx(t.TabsGroup,{tabs:L,tabsListSx:Object.assign({mx:20,justifyContent:"space-between"},u&&P?{"& button:last-child":{position:"relative","&::before":{content:`"${o.i18n._({id:"TY5fM3",message:"LP Tokens"})}"`,position:"absolute",top:16,right:20,px:8,py:2,borderRadius:12,transform:"scale(0.66667) translateX(100%)",transformOrigin:"right top",backgroundColor:t.alpha("#DABB1B",.2),color:"#DABB1B"}}}:{}),rightSlot:G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:["GSP"===(null==A?void 0:A.type)&&G.jsx(Nw,{}),i?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"},cursor:"pointer"},children:G.jsx(t.Box,{component:se.Error,sx:{width:16,height:16},onClick:()=>{i()}})}):void 0]})}),G.jsx(t.TabPanel,{value:Dw.Liquidity,sx:{flex:1,overflowY:"auto"},children:G.jsx(pk,{pool:A,operate:l,hidePoolInfo:p,errorRefetch:E,submittedBack:()=>{u&&R(Dw.Mining)}})}),G.jsx(t.TabPanel,{value:Dw.Mining,sx:{flex:1,overflowY:"auto"},children:_&&N?G.jsx(_w,{chainId:_,account:w,poolAddress:N,goLpLink:()=>{R(Dw.Liquidity)}}):""})]})})}function mk(e){var{modal:t}=e,n=U(e,["modal"]);const{isMobile:i}=Bp();return G.jsx(Eh,{open:!!n.pool||!!n.address,onClose:n.onClose,scope:!i,modal:t,id:"pool-operate",children:G.jsx(hk,{...n})})}function gk({address:n,chainId:i,hideName:o,sx:a}){const s=t.useTheme(),l=xp(),{onlyChainId:c}=X(),u=d.useQuery(Object.assign({},l.getQuery(r.SystemApi.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:c||void 0}})));if(!n)return null;const p=[];return("string"==typeof n?[n]:Array.from(new Set(n)).filter((e=>!!e))).forEach((e=>{var t,n,o;e&&(null===(o=null===(n=null===(t=u.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===n?void 0:n.partnerRewards)||void 0===o||o.some((t=>{var n,o,r,a,s,l,d,c,h,m,g,x,f,y;if((null==t?void 0:t.chainId)===i&&(null===(n=null==t?void 0:t.pool)||void 0===n?void 0:n.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=u.data)||void 0===o?void 0:o.liquidity_getLpPartnerRewards)||void 0===r?void 0:r.partnerInfos)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.partner)===t.partner));if(!e)return;p.push({partner:{name:null!==(s=null==e?void 0:e.partner)&&void 0!==s?s:"",logo:null!==(l=null==e?void 0:e.logo)&&void 0!==l?l:"",introduction:null!==(d=null==e?void 0:e.introduction)&&void 0!==d?d:"",link:null!==(c=null==e?void 0:e.link)&&void 0!==c?c:"",extra:null!==(h=null==e?void 0:e.extra)&&void 0!==h?h:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(g=null==e?void 0:e.theme)||void 0===g?void 0:g[1])||void 0},reward:null!==(x=null==t?void 0:t.reward)&&void 0!==x?x:"",type:null!==(f=null==t?void 0:t.type)&&void 0!==f?f:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==p?void 0:p.length)?(p.sort(((e,t)=>e.sort-t.sort)),G.jsx(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:p.map((n=>G.jsx(t.Tooltip,{leaveDelay:100,title:G.jsxs(t.Box,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[n.partner.introduction,!!n.partner.link&&G.jsxs(t.Box,{component:"a",target:"_blank",href:n.partner.link,rel:"noopener noreferrer",sx:{display:"flex",alignItems:"center",gap:4,color:"primary.main","&:hover":{opacity:.5}},children:[G.jsx(e.Trans,{id:"zwWKhA",message:"Learn more"})," ",G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 2.91667V11.0833H11.0833V7H12.25V11.0833C12.25 11.725 11.725 12.25 11.0833 12.25H2.91667C2.26917 12.25 1.75 11.725 1.75 11.0833V2.91667C1.75 2.275 2.26917 1.75 2.91667 1.75H7V2.91667H2.91667ZM8.16667 2.91667V1.75H12.25V5.83333H11.0833V3.73917L5.34917 9.47333L4.52667 8.65083L10.2608 2.91667H8.16667Z",fill:"currentColor"})})]})]}),children:G.jsxs(t.ButtonBase,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:s.spacing(0,4),height:20,borderRadius:4,background:n.partner.background,color:n.partner.color,whiteSpace:"nowrap"},children:[G.jsx(t.Box,{component:"img",src:n.partner.logo,alt:n.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!o&&!!n.reward&&G.jsx(t.Box,{sx:{fontSize:"10px",fontWeight:600},children:n.reward})]})},n.partner.name+n.reward)))})):null}var xk,fk;function yk(){return yk=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},yk.apply(null,arguments)}const vk=e=>D.createElement("svg",yk({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),xk||(xk=D.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),fk||(fk=D.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.5 12.25H12.25V8.5H8.5V12.25ZM14.125 23.5H17.875V19.75H14.125V23.5ZM12.25 23.5H8.5V19.75H12.25V23.5ZM8.5 17.875H12.25V14.125H8.5V17.875ZM17.875 17.875H14.125V14.125H17.875V17.875ZM19.75 8.5V12.25H23.5V8.5H19.75ZM17.875 12.25H14.125V8.5H17.875V12.25ZM19.75 17.875H23.5V14.125H19.75V17.875ZM23.5 23.5H19.75V19.75H23.5V23.5Z",fill:"#1A1A1B"}))),bk="_default";function Ck({value:e,onChange:n,placeholder:o,options:r,sx:a,readOnly:s,valueOnlyIcon:l}){const d=t.useTheme();return G.jsx(t.Select,{value:null!=e?e:bk,onChange:(t,i)=>{const o="number"==typeof e&&i?Number(i):i;n(o===bk?void 0:o)},disabled:s,sx:i.merge({padding:d.spacing(8,12),"& .MuiSelect-select.MuiSelect-select.MuiSelect-select":{display:"flex",alignItems:"center",gap:8,padding:d.spacing(8,12,8,12),minHeight:"auto",backgroundColor:"transparent",color:"text.primary",borderRadius:8,typography:"body2",fontWeight:600,borderStyle:"solid",borderWidth:1,borderColor:"divider","& svg, & img":{width:24,height:24},'&:hover, &[aria-expanded="true"]':{backgroundColor:"background.paper"},"&.Mui-readOnly":{color:"text.disabled"}},"& .MuiSelect-icon":{color:s?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},a),renderValue:n=>{if(!(null==n?void 0:n.value)||n.value===bk)return G.jsx(t.Box,{sx:{color:"text.secondary"},children:null!=o?o:""});const i=r.find((t=>t.key===e));return i?G.jsxs(G.Fragment,{children:[i.logo,l?"":i.value]}):null},options:[...r]})}function jk({isMobileStyle:e,chain:n,isLastItem:i,logoWidth:o,mobileLogoWidth:r,sx:a}){const s=t.useTheme();return e?G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",py:18,borderTop:`1px solid ${s.palette.border.main}`,borderBottom:i?`1px solid ${s.palette.border.main}`:"none"},a),children:[G.jsx(t.Box,{component:null==n?void 0:n.logo,sx:{width:r,height:r}}),G.jsx(t.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==n?void 0:n.name})]}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{component:null==n?void 0:n.logo,sx:{width:o,height:o}}),G.jsx(t.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==n?void 0:n.name})]})}const wk=-1;function kk({chainId:i,setChainId:o,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:s=24,mainMobileLogoWidth:l=18,notShowAllChain:d,valueOnlyIcon:c,sx:u}){const p=function(){const{chainId:e}=cp(),t=n.useMemo((()=>{const t=new Map;let n;return ac.forEach(((i,o)=>{if(i.mainnet){if(e!==i.chainId)return;n=i.mainnet}t.set(o,Object.assign({},i))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e]);return t}(),[h,m]=n.useState(!1),{isMobile:g}=Bp(),{i18n:x}=e.useLingui(),f=n.useCallback((()=>{const e=void 0===i?p[0]:p.find((e=>e.chainId===i));if(c){if(void 0===i||!e)return"";const n=g?a:s;return G.jsx(t.Box,{component:null==e?void 0:e.logo,sx:{width:n,height:n}})}return void 0!==i||d?e?G.jsx(jk,{isMobileStyle:g,chain:e,logoWidth:s,mobileLogoWidth:l}):null:G.jsx(jk,{isMobileStyle:g,chain:{chainId:wk,logo:vk,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:s,mobileLogoWidth:l,sx:{border:"none"}})}),[i,p,d,c,g,x._]),y=n.useMemo((()=>{const e=[];return d||e.push({key:wk,value:G.jsx(jk,{isMobileStyle:g,chain:{chainId:wk,logo:vk,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),p.forEach(((t,n)=>{e.push({key:t.chainId,value:G.jsx(jk,{isLastItem:n===p.length-1,isMobileStyle:g,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[g,r,a,p,d]);return g?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>m(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",color:"text.primary",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},u),children:[G.jsx(t.Box,{sx:{pr:5},children:f()}),G.jsx(t.Box,{component:se.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),G.jsx(Eh,{open:h,title:G.jsx(e.Trans,{id:"lJvbHq",message:"Select Network"}),onClose:()=>m(!1),id:"select-chain",modal:!0,children:G.jsx(t.Box,{sx:{mb:20},children:y.map((e=>G.jsxs(t.Box,{onClick:()=>{const t=e.key;o(t===wk?void 0:Number(t)),m(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(i?e.key===i:e.key===wk)&&G.jsx(t.Box,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):G.jsx(Ck,{value:null!=i?i:wk,onChange:e=>{y.some((t=>String(t.key)===String(e)))&&o(e===wk?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:y,valueOnlyIcon:c,sx:Object.assign({px:8,height:32,fontWeight:600,typography:"body2",backgroundColor:"background.tag",color:"text.primary"},u)})}function Tk({lqList:e,onDeleteTag:n,sx:i}){var o;if(!(null==e?void 0:e.length))return null;if(!(null===(o=e[0])||void 0===o?void 0:o.pair))return null;const{pair:r}=e[0],a=Zu(r.baseToken,r.chainId),s=Zu(r.quoteToken,r.chainId);return a&&s?G.jsxs(t.Box,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},i),children:[G.jsx(wy,{tokens:[a,s],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",s.symbol,G.jsx(t.Box,{component:se.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>n()})]}):null}const Bk=e=>{const{filterList:n,value:i,onChange:o,sx:r}=e,a=t.useTheme();return G.jsx(t.Box,{sx:Object.assign({display:"flex",alignItems:"center"},r),children:n.map(((e,r)=>G.jsx(t.Box,{sx:Object.assign(Object.assign({borderLeftWidth:1,borderRightWidth:r===n.length-1?1:0,borderTopWidth:1,borderBottomWidth:1,borderColor:a.palette.border.main,borderStyle:"solid",typography:"body2",lineHeight:"30px",color:a.palette.text.secondary,px:20,cursor:"pointer",borderTopLeftRadius:0===r?8:0,borderBottomLeftRadius:0===r?8:0,borderTopRightRadius:r===n.length-1?8:0,borderBottomRightRadius:r===n.length-1?8:0},i===e.value?{backgroundColor:a.palette.border.disabled,color:a.palette.text.primary}:{}),{[a.breakpoints.down("tablet")]:{flexGrow:1,flexBasis:"25%",textAlign:"center"}}),onClick:()=>o(e.value),children:e.label},e.value)))})},Ik=({sx:n,isRightTop:i,isReverseColor:o})=>{const r=t.useTheme();return G.jsx(t.Box,{sx:Object.assign(Object.assign(Object.assign({display:"inline-flex",padding:"2px 4px",alignItems:"center",gap:"4px",borderRadius:4,background:t.alpha(r.palette.warning.main,.1),color:r.palette.warning.main,fontSize:"10px",fontWeight:600,lineHeight:"14px"},i?{position:"absolute",top:-14,right:0,background:`linear-gradient(0deg, ${r.palette.warning.main}1A 0%, ${r.palette.warning.main}1A 100%), ${r.palette.background.paper}`}:void 0),o?{background:"light"===r.palette.mode?"linear-gradient(0deg, var(--label-warning, rgba(177, 86, 0, 0.10)) 0%, var(--label-warning, rgba(177, 86, 0, 0.10)) 100%), #FFF":"linear-gradient(0deg, #FFFFFF, #FFFFFF),linear-gradient(0deg, rgba(235, 141, 39, 0.1), rgba(235, 141, 39, 0.1))",zIndex:1}:void 0),n),children:G.jsx(e.Trans,{id:"y5rS9U",message:"Migrate"})})};function Sk({chainId:n,baseToken:i,quoteToken:o,apy:r,hasQuote:s,hasMining:l,sx:d,children:c}){if(!i)return null;const u=s?[{token:i,transactionApy:null==r?void 0:r.transactionBaseApy,miningApy:null==r?void 0:r.miningBaseApy},{token:o,transactionApy:null==r?void 0:r.transactionQuoteApy,miningApy:null==r?void 0:r.miningQuoteApy}]:[{transactionApy:null==r?void 0:r.transactionBaseApy,miningApy:null==r?void 0:r.miningBaseApy,metromMiningApy:null==r?void 0:r.metromMiningApy}];return G.jsx(t.Tooltip,{children:null!=c?c:G.jsx(t.HoverOpacity,{component:se.QuestionBorder,sx:Object.assign({width:15,height:15},d)}),title:G.jsx(t.Box,{sx:{minWidth:236},children:u.map(((r,s)=>{var d,c,u,p,h;return G.jsxs(t.Box,{sx:{mt:0===s?0:20},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:r.token?G.jsxs(G.Fragment,{children:[G.jsx(Nh,{width:14,height:14,marginRight:4,address:r.token.address,url:r.token.logoURI,chainId:n,noShowChain:!0}),r.token.symbol]}):G.jsxs(G.Fragment,{children:[G.jsx(wy,{tokens:[i,o],width:14,mr:4,chainId:n}),i.symbol,"/",null==o?void 0:o.symbol]})}),G.jsx(t.Box,{children:Hu(new a(null!==(u=r.transactionApy)&&void 0!==u?u:0).plus(null!==(p=r.miningApy)&&void 0!==p?p:0).plus(null!==(h=r.metromMiningApy)&&void 0!==h?h:0))})]}),G.jsxs(t.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"})}),G.jsx("span",{children:r.transactionApy?Hu(new a(r.transactionApy)):"-"})]}),l?G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"})}),G.jsx("span",{children:r.miningApy?Hu(new a(r.miningApy)):"-"})]}):"",r.metromMiningApy&&Number(r.metromMiningApy)>0&&G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})}),G.jsx("span",{children:r.metromMiningApy?Hu(new a(r.metromMiningApy)):"-"})]})]},null!==(c=null===(d=r.token)||void 0===d?void 0:d.address)&&void 0!==c?c:1)}))})})}function Ak({list:n,onClick:i}){return G.jsx(G.Fragment,{children:null==n?void 0:n.map((n=>{var o,s,l,d;if(!(null==n?void 0:n.pair))return null;const c=n.pair,u=Zu(c.baseToken,c.chainId),p=Zu(c.quoteToken,c.chainId),h=c.apy?Hu(new a(null===(o=c.apy)||void 0===o?void 0:o.transactionBaseApy).plus(null!==(l=null===(s=c.apy)||void 0===s?void 0:s.miningBaseApy)&&void 0!==l?l:0)):void 0,m=r.PoolApi.utils.singleSideLp(c.type)&&c.apy?Hu(new a(c.apy.transactionQuoteApy).plus(null!==(d=c.apy.miningQuoteApy)&&void 0!==d?d:0)):void 0;return u&&p?G.jsxs(t.Box,{onClick:i,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(wy,{tokens:[u,p],chainId:c.chainId,width:24,mr:10}),G.jsxs(t.Box,{sx:{typography:"h5"},children:[u.symbol,"/",p.symbol]})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:[h,m?`/${m}`:""]}),G.jsx(t.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]},c.id):null}))})}function Ek(e){var t;const[i,o]=n.useState(null!==(t=null==e?void 0:e.tokens)&&void 0!==t?t:[]),[r,a]=n.useState([]);n.useEffect((()=>{e&&(o(e.tokens),a(e.lqList))}),[e]);const[s,l]=n.useMemo((()=>{const[e,t]=i;return[null==e?void 0:e.symbol,null==t?void 0:t.symbol]}),[i]);return{filterTokens:i,filterASymbol:s,filterBSymbol:l,filterAddressLqList:r,handleDeleteToken:t=>{o((n=>{const i=[...n],o=i.indexOf(t);return-1!==o&&i.splice(o,1),e&&e.onChangeFilterTokens(i),i}))},handleChangeFilterTokens:t=>{a([]),o(t),e&&(e.onChangeFilterTokens(t),e.onChangeFilterAddressLqList([]))},handleChangeFilterAddress:t=>{a(t),o([]),e&&(e.onChangeFilterTokens([]),e.onChangeFilterAddressLqList(t))}}}function Ok({lqList:n,setOperatePool:i,getMigrationPairAndMining:o,supportAMM:s,timeRange:l}){const d=t.useTheme(),{onSharePool:c}=X();return G.jsx(G.Fragment,{children:null==n?void 0:n.map((n=>{var u,p,h,m,g,x,f,y,v;if(!(null==n?void 0:n.pair))return null;const b=n.pair,C=Zu(b.baseToken,b.chainId),j=Zu(b.quoteToken,b.chainId),w=null===(u=b.apyList)||void 0===u?void 0:u.find((e=>(null==e?void 0:e.timeRange)===`${l}D`)),k=w?Hu(new a(null==w?void 0:w.transactionBaseApy).plus(null!==(p=null==w?void 0:w.miningBaseApy)&&void 0!==p?p:0)):void 0,T=r.PoolApi.utils.singleSideLp(b.type)&&w?Hu(new a(w.transactionQuoteApy).plus(null!==(h=w.miningQuoteApy)&&void 0!==h?h:0)):void 0,B=!!(null===(m=b.miningAddress)||void 0===m?void 0:m[0]),I=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,S=b.type,A=Yu(S),E="AMMV2"===S,O="AMMV3"===S,L=null==o?void 0:o({address:b.id,chainId:b.chainId});return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{s||zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:b.chainId,address:b.id}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[C&&j?G.jsx(wy,{tokens:[C,j],width:24,mr:6,chainId:b.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==C?void 0:C.symbol}/${null==j?void 0:j.symbol}`,!!c&&G.jsx(t.Box,{component:se.Share,sx:{ml:2,width:12,height:12},onClick:()=>c({chainId:b.chainId,baseToken:C,quoteToken:j,poolId:b.id,apy:w,isSingle:r.PoolApi.utils.singleSideLp(b.type)})}),G.jsx(gk,{address:b.id,chainId:b.chainId})]}),!!L&&G.jsx(Ik,{})]}),B||I?G.jsxs(t.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${t.alpha(d.palette.secondary.main,.3)} 0%, ${t.alpha(d.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[s&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[A,G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:O?null!==(x=null===(g=sj[b.lpFeeRate])||void 0===g?void 0:g.label)&&void 0!==x?x:"-":Vu({input:new a(null!==(f=b.lpFeeRate)&&void 0!==f?f:0).plus(b.mtFeeRate?Mu(b.mtFeeRate,E?4:18):0)})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5",color:"success.main"},children:[k,T?`/${T}`:""]}),G.jsxs(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[l,"d ",G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(Sk,{chainId:b.chainId,apy:w,baseToken:C,quoteToken:j,hasQuote:!!T,hasMining:B,sx:{width:14,height:14}})]})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",Xu({input:b.tvl,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),s&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:["$",Xu({input:null===(v=null===(y=b.volumeList)||void 0===y?void 0:y.find((e=>(null==e?void 0:e.timeRange)===`${l}D`)))||void 0===v?void 0:v.volume,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"iuFFMB",message:"Volume ({timeRange}d)",values:{timeRange:l}})})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),i({pool:Qu(n),hasMining:B})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),s&&"PMM"===A&&G.jsx(Wj,{chainId:b.chainId,address:b.id})]})]},b.id+b.chainId)}))})}function Lk({lqList:n,loading:i,operatePool:s,setOperatePool:l,getMigrationPairAndMining:d,hasMore:c,loadMore:u,loadMoreLoading:p,supportAMM:h,timeRange:m,setOrderBy:g,setOrderDirection:x,orderBy:f,orderDirection:y}){const v=t.useTheme(),{onSharePool:b}=X();return G.jsxs($j,{hasMore:c,loadMore:u,loadMoreLoading:p,empty:!(null==n?void 0:n.length),loading:i,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),h&&G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),G.jsx(t.Box,{component:"th",children:G.jsx(nw,{direction:"tvl"===f?y:void 0,onClick:()=>{if("tvl"===f)return"desc"===y?void x("asc"):(g(void 0),void x(void 0));g("tvl"),x("desc")},children:"TVL"})}),G.jsx(t.Box,{component:"th",children:G.jsxs(nw,{direction:"apy"===f?y:void 0,onClick:()=>{if("apy"===f)return"desc"===y?void x("asc"):(g(void 0),void x(void 0));g("apy"),x("desc")},children:[m,"d APY"]})}),h&&G.jsx("th",{children:G.jsxs(nw,{direction:"volume"===f?y:void 0,onClick:()=>{if("volume"===f)return"desc"===y?void x("asc"):(g(void 0),void x(void 0));g("volume"),x("desc")},children:[m,"d Volume"]})}),G.jsx(t.Box,{component:"th",sx:{width:80}})]})}),G.jsx(t.Box,{component:"tbody",children:null==n?void 0:n.map((e=>{var n,i,c,u,p,g,x,f;if(!(null==e?void 0:e.pair))return null;const y=e.pair,C=Zu(y.baseToken,y.chainId),j=Zu(y.quoteToken,y.chainId),w=null===(n=y.apyList)||void 0===n?void 0:n.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)),k=w?Hu(new a(null==w?void 0:w.transactionBaseApy).plus(null!==(i=null==w?void 0:w.miningBaseApy)&&void 0!==i?i:0).plus(null!==(c=null==w?void 0:w.metromMiningApy)&&void 0!==c?c:0)):void 0,T=r.PoolApi.utils.singleSideLp(y.type)&&w?Hu(new a(w.transactionQuoteApy).plus(null!==(u=w.miningQuoteApy)&&void 0!==u?u:0)):void 0;let B="";if((null===(p=null==s?void 0:s.pool)||void 0===p?void 0:p.address)===y.id||(null==s?void 0:s.address)===y.id)if(s.operate===Qj.Remove)B=o.i18n._({id:"0+31GV",message:"Removing"});else B=o.i18n._({id:"1yHVE+",message:"Adding"});const I=!!(null===(g=y.miningAddress)||void 0===g?void 0:g[0]),S=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,A=y.type,E=Yu(A),O="AMMV2"===A,L="AMMV3"===A,R=v.palette.hover.default,M=null==d?void 0:d({address:y.id,chainId:y.chainId});return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(B?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[C&&j?G.jsx(wy,{tokens:[C,j],width:24,mr:8,chainId:y.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==C?void 0:C.symbol}/${null==j?void 0:j.symbol}`,G.jsx(gk,{address:y.id,chainId:y.chainId}),!!M&&G.jsx(Ik,{})]}),G.jsx(zf,{address:y.id,customChainId:y.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,onShareClick:b?()=>b({chainId:y.chainId,baseToken:C,quoteToken:j,poolId:y.id,apy:w,isSingle:r.PoolApi.utils.singleSideLp(y.type)}):void 0,sx:{typography:"h6",color:"text.secondary"},disabledAddress:h,onAddressClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:y.chainId,address:y.id}})}})]})]})}),h&&G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(lj,{poolType:E}),G.jsx(dj,{isAMMV2:O,isAMMV3:L,lpFeeRate:y.lpFeeRate,mtFeeRate:y.mtFeeRate})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:y.tvl?`$${Au({input:y.tvl,decimals:2})}`:void 0,children:["$",Xu({input:y.tvl,decimals:2})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[I||S?G.jsx(t.Tooltip,{title:o.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(Sk,{chainId:y.chainId,apy:w,baseToken:C,quoteToken:j,hasQuote:!!T,hasMining:I,children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[k,T?`/${T}`:""]})})]})}),h&&G.jsxs(t.Box,{component:"td",sx:{typography:"body2"},children:["$",Xu({input:null===(f=null===(x=y.volumeList)||void 0===x?void 0:x.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)))||void 0===f?void 0:f.volume,decimals:2})]}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[h&&"PMM"===E&&G.jsx(Wj,{chainId:y.chainId,address:y.id}),B?G.jsx(Vj,{text:B,onClick:()=>l(null)}):G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({pool:Qu(e),hasMining:I})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})})]},y.id+y.chainId)}))})]})}function Rk({scrollParentRef:e,filterChainIds:o,activeChainId:a,handleChangeActiveChainId:s,operatePool:l,setOperatePool:c,tokenAndPoolFilter:u,getMigrationPairAndMining:p,children:h}){var m,g;const x=t.useTheme(),{onlyChainId:f,supportAMMV2:y,supportAMMV3:v,notSupportPMM:b}=X(),{minDevice:C,isMobile:j}=Bp(),w=d.useQueryClient(),[k,T]=n.useState("all"),[B,I]=n.useState("1"),[S,A]=n.useState(),[E,O]=n.useState(),{filterTokens:L,filterASymbol:M,filterBSymbol:P,filterAddressLqList:_,handleDeleteToken:N,handleChangeFilterTokens:D,handleChangeFilterAddress:F}=Ek(u),U=n.useMemo((()=>{if(v&&"v3"===k)return["AMMV3"];if(y&&"v2"===k)return["AMMV2"];if(!b&&"pmm"===k)return["CLASSICAL","DVM","DSP","GSP"];let e=b?[]:["CLASSICAL","DVM","DSP","GSP"];return y&&e.push("AMMV2"),v&&e.push("AMMV3"),e}),[b,y,v,k]),V=n.useMemo((()=>({chainIds:o,pageSize:j?4:8,filterState:{viewOnlyOwn:!1,filterTypes:U},order:{timeRange:`${B}D`,orderDirection:S,orderBy:E}})),[o,U,j,B,E,S]),H=xp(),W=H.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},V),{filterState:Object.assign({filterASymbol:M,filterBSymbol:P},V.filterState)})}),$=d.useInfiniteQuery(Object.assign(Object.assign({},W),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:i,pageSize:o}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!i||!o)return null;let r=Math.floor(i/o);return i%o&&(r+=1),n>=r?null:n+1}}));let z=[];const Z=!!(null==_?void 0:_.length);Z?z=[..._]:null===(m=$.data)||void 0===m||m.pages.forEach((e=>{var t,n;null===(n=null===(t=e.liquidity_list)||void 0===t?void 0:t.lqList)||void 0===n||n.forEach((e=>{null==z||z.push(e)}))}));const Q=$.hasNextPage&&!Z;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[x.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[x.breakpoints.up("tablet")]:{mr:"auto"}},children:h}),!f&&G.jsx(kk,{chainId:a,setChainId:s}),(y||v)&&G.jsx(Bk,{filterList:[{label:"All",value:"all"}].concat(b?[]:[{label:"PMM",value:"pmm"}]).concat(y?[{label:"V2",value:"v2"}]:[]).concat(v?[{label:"V3",value:"v3"}]:[]),value:k,onChange:e=>T(e)}),G.jsx(tw,{sortList:[{label:"TVL",direction:"tvl"===E?S:void 0,onClick:()=>{if("tvl"===E)return"desc"===S?void A("asc"):(O(void 0),void A(void 0));O("tvl"),A("desc")}},{label:`${B}d APY`,direction:"apy"===E?S:void 0,onClick:()=>{if("apy"===E)return"desc"===S?void A("asc"):(O(void 0),void A(void 0));O("apy"),A("desc")}},{label:`${B}d Volume`,direction:"volume"===E?S:void 0,onClick:()=>{if("volume"===E)return"desc"===S?void A("asc"):(O(void 0),void A(void 0));O("volume"),A("desc")}}],children:G.jsx(Bk,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:B,onChange:e=>I(e),sx:{flex:1}})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},j?{}:{"& > button":{flex:1}}),children:null!==(g=null==u?void 0:u.element)&&void 0!==g?g:G.jsx(Zj,{value:L,onChange:D,searchAddress:(e,t)=>q(this,void 0,void 0,(function*(){var n;const i=H.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},V),{filterState:Object.assign({address:e},V.filterState)})}),o=null===(n=(yield w.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?G.jsx(Ak,{list:o,onClick:()=>{F(o),t()}}):null}))})}),(Z||!!L.length)&&G.jsxs(t.Box,{sx:{my:0},children:[Z?G.jsx(Tk,{lqList:_,onDeleteTag:()=>F([])}):"",G.jsx(Hj,{tags:L,onDeleteTag:N})]})]})]}),j?G.jsx(R,{hasMore:Q,threshold:300,loadMore:i.debounce((()=>{$.hasNextPage&&!$.isFetching&&$.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:G.jsx(zj,{sx:{mt:20}},"loader"),children:G.jsxs(qj,{children:[$.isLoading?G.jsx(zj,{}):"",!$.isLoading&&!(null==z?void 0:z.length)&&!$.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!(a&&!f||M||P)}),!!$.error&&G.jsx(re,{refresh:$.refetch,sx:{mt:40}}),G.jsx(Ok,{lqList:z,setOperatePool:c,supportAMM:y||v,getMigrationPairAndMining:p,timeRange:B})]})}):G.jsxs(G.Fragment,{children:[G.jsx(Lk,{lqList:z,loading:$.isLoading,operatePool:l,setOperatePool:c,hasMore:Q,loadMoreLoading:$.isFetchingNextPage,loadMore:()=>{$.hasNextPage&&!$.isFetching&&$.fetchNextPage()},supportAMM:y||v,timeRange:B,getMigrationPairAndMining:p,orderBy:E,orderDirection:S,setOrderBy:O,setOrderDirection:A}),G.jsx(ky,{loading:$.isLoading,refetch:$.error?$.refetch:void 0,empty:!(null==z?void 0:z.length),hasSearch:!!(a&&!f||M||P)})]})]})}function Mk({onClick:e,title:n,desc:i}){const o=t.useTheme();return G.jsx(t.Box,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${o.palette.border.main}`,[o.breakpoints.up("tablet")]:{maxWidth:236,borderTop:"none",mx:0,px:16,py:8}},children:G.jsxs(t.ButtonBase,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,p:0,borderRadius:8,textAlign:"left","&:hover":{backgroundColor:o.palette.background.tag},[o.breakpoints.up("tablet")]:{p:8}},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:o.palette.text.primary},children:n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary},children:i})]})})}const Pk=i=>{const o=t.useTheme(),{isMobile:r}=Bp(),{supportAMMV2:a,supportAMMV3:s,notSupportPMM:l}=X(),[d,c]=n.useState(!1),u={[exports.PageType.CreatePool]:!l,[exports.PageType.createPoolAMMV2]:!!a,[exports.PageType.createPoolAMMV3]:!!s},p=Object.entries(u).filter((([e,t])=>!0===t)),h=1===p.length?p[0][0]:void 0;if(!h){const n=G.jsxs(G.Fragment,{children:[!l&&G.jsx(Mk,{onClick:()=>{zy.getState().push({type:exports.PageType.CreatePool})},title:G.jsx(e.Trans,{id:"Eif7f6",message:"PMM Pool"}),desc:G.jsx(e.Trans,{id:"LQ0J1B",message:"Flexible customization, take full control of liquidity"})}),a&&G.jsx(Mk,{onClick:()=>{zy.getState().push({type:exports.PageType.createPoolAMMV2})},title:G.jsx(e.Trans,{id:"lNYomJ",message:"AMM V2 Position"}),desc:G.jsx(e.Trans,{id:"lLbR0m",message:"Simple, full-range liquidity"})}),s&&G.jsx(Mk,{onClick:()=>{zy.getState().push({type:exports.PageType.createPoolAMMV3})},title:G.jsx(e.Trans,{id:"sVlqoo",message:"AMM V3 Position"}),desc:G.jsx(e.Trans,{id:"EkAv3P",message:"Concentrated liquidity, higher efficiency"})})]});return r?G.jsxs(G.Fragment,{children:[G.jsxs(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{c(!0)},sx:{height:36},children:[G.jsx(t.Box,{component:se.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]}),G.jsx(Eh,{open:d,title:G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{c(!1)},modal:!0,children:G.jsx(t.Box,{sx:{mb:0},children:n})})]}):G.jsx(t.Tooltip,{arrow:!1,leaveDelay:300,placement:r?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:G.jsx(t.Box,{children:n}),children:G.jsxs(t.Box,{sx:{width:r?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,pl:8,pr:16,py:6,borderRadius:40,backgroundColor:o.palette.background.tag,typography:"body2",fontWeight:600,color:o.palette.text.link,cursor:"pointer","&:hover":{backgroundColor:t.alpha(o.palette.primary.main,.1)}},children:[G.jsx(t.Box,{component:se.Plus}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})})}return G.jsxs(t.Button,{variant:t.Button.Variant.outlined,fullWidth:r,onClick:()=>{zy.getState().push({type:h})},sx:{height:40},children:[G.jsx(t.Box,{component:se.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})},_k="DODO_WIDGET_POOL_LIST_TOP_TAB",Nk="DODO_WIDGET_POOL_LIST_TAB",Dk="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var Fk,Uk,qk,Vk;!function(e){e.ALM="ALM",e.NORMAL="NORMAL",e.MULTI_TOKEN="MULTI_TOKEN"}(Fk||(Fk={})),function(e){e.ALL="ALL",e.MY="MY"}(Uk||(Uk={})),function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(qk||(qk={})),function(e){e.ALL="ALL",e.MY="MY"}(Vk||(Vk={}));const Hk=(e,n,i)=>{let r=o.i18n._({id:"TJBHlP",message:"Standard"}),a=i.palette.purple.main;switch(e){case"DSP":r=o.i18n._({id:"J7M/DA",message:"Pegged"}),a=i.palette.success.main;break;case"DPP":r=o.i18n._({id:"zwBp5t",message:"Private"}),a=i.palette.error.main}"DVM"===e&&(!n||n.isZero())&&(r=o.i18n._({id:"S8G1qk",message:"Single"}),a=i.palette.warning.main);return{typeLabel:r,typeColor:a,typeBgColor:t.alpha(a,.1)}};function Wk({account:n,list:i,setOperatePool:o}){const r=t.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var s,l,d,c,u;if(!i)return null;const p=null!==(s=i.pairAddress)&&void 0!==s?s:"",h=i.chainId,m=i.poolType,g={chainId:h,address:null!==(l=i.baseAddress)&&void 0!==l?l:"",symbol:null!==(d=i.baseSymbol)&&void 0!==d?d:""},x={chainId:h,address:null!==(c=i.quoteAddress)&&void 0!==c?c:"",symbol:null!==(u=i.quoteSymbol)&&void 0!==u?u:""},{typeLabel:f,typeColor:y,typeBgColor:v}=Hk(m,i.quoteReserve?new a(i.quoteReserve):null,r);return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:h,address:p}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[g&&x?G.jsx(wy,{tokens:[g,x],width:24,mr:8,chainId:h,showChainLogo:!0}):"",G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},children:tp(p)}),"DPP"===m&&G.jsx(t.HoverAddBackground,{sx:{ml:2},component:t.ButtonBase,onClick:e=>{e.stopPropagation(),zy.getState().push({type:exports.PageType.ModifyPool,params:{chainId:h,address:p}})},children:G.jsx(t.Box,{component:se.Edit,sx:{width:12,height:12,cursor:"pointer"}})})]}),G.jsx(t.Box,{sx:{typography:"h6",width:"max-content",p:8,borderRadius:8,backgroundColor:v,color:y},children:f})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",mt:44},children:[G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",i.tvl?Xu({input:i.tvl,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),G.jsx(t.Box,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",i.totalFee?Xu({input:i.totalFee,decimals:2}):"-"]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"hCBYHP",message:"Total Fee Revenue"})})]})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[!!n&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({address:p,operate:Qj.Remove,chainId:h})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({address:p,operate:Qj.Add,chainId:h})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})]},p+h)}))})}function $k({account:n,list:i,loading:r,operatePool:s,setOperatePool:l,setOrderBy:d,setOrderDirection:c,orderBy:u,orderDirection:p}){const h=t.useTheme(),m=zy();return G.jsxs($j,{empty:!(null==i?void 0:i.length),loading:r,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),G.jsx(t.Box,{component:"th",children:G.jsx(nw,{direction:"tvl"===u?p:void 0,onClick:()=>{if("tvl"===u)return"desc"===p?void c("asc"):(d(void 0),void c(void 0));d("tvl"),c("desc")},children:"TVL"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"hCBYHP",message:"Total Fee Revenue"})}),G.jsx(t.Box,{component:"th",sx:{width:160}})]})}),G.jsx(t.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var r,d,c,u,p,g;if(!i)return null;const x="DPP"===i.poolType,f=null!==(r=i.pairAddress)&&void 0!==r?r:"",y=i.chainId,v=i.poolType,b={chainId:y,address:null!==(d=i.baseAddress)&&void 0!==d?d:"",symbol:null!==(c=i.baseSymbol)&&void 0!==c?c:""},C={chainId:y,address:null!==(u=i.quoteAddress)&&void 0!==u?u:"",symbol:null!==(p=i.quoteSymbol)&&void 0!==p?p:""},{typeLabel:j,typeColor:w,typeBgColor:k}=Hk(v,i.quoteReserve?new a(i.quoteReserve):null,h);let T="";if((null===(g=null==s?void 0:s.pool)||void 0===g?void 0:g.address)===f||(null==s?void 0:s.address)===f)if((null==s?void 0:s.operate)===Qj.Remove)T=o.i18n._({id:"0+31GV",message:"Removing"});else T=o.i18n._({id:"1yHVE+",message:"Adding"});const B=h.palette.hover.default;return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(T?", & td":"")]:{backgroundImage:`linear-gradient(${B}, ${B})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[b&&C?G.jsx(wy,{tokens:[b,C],width:24,mr:10,chainId:y,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(t.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:"primary.main",hoverSx:{color:"primary.main","& svg":{display:"inline-block"}},className:"truncate-address-link",sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600},onClick:()=>{m.push({type:exports.PageType.PoolDetail,params:{chainId:y,address:f}})},children:tp(f)}),G.jsx(t.Box,{component:se.ArrowRight,sx:{display:"none",width:14,height:14}})]}),x?G.jsx(t.Box,{sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderColor:"text.primary",borderRadius:4,whiteSpace:"nowrap",cursor:"pointer","&:hover":{backgroundColor:t.alpha(h.palette.text.primary,.1)}},onClick:()=>{m.push({type:exports.PageType.ModifyPool,params:{chainId:y,address:f}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):""]}),G.jsx(t.Box,{sx:{typography:"h6",width:"max-content",mt:2,px:8,py:2,borderRadius:12,backgroundColor:k,color:w},children:j})]})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:i.tvl?`$${Su({input:i.tvl})}`:void 0,children:["$",i.tvl?Xu({input:i.tvl,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{title:i.totalFee?`$${Su({input:i.totalFee})}`:"",sx:{typography:"body2",fontWeight:600},children:["$",i.totalFee?Xu({input:i.totalFee,decimals:2}):"-"]})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:T?G.jsx(Vj,{text:T,onClick:()=>l(null)}):G.jsxs(G.Fragment,{children:[!!n&&G.jsx(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),l({operate:Qj.Remove,chainId:y,address:f})},sx:{py:0,height:32},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{l({chainId:y,address:f})},sx:{py:0,height:32},children:o.i18n._({id:"m16xKo",message:"Add"})})]})})})]},f+y)}))})]})}function zk({account:i,filterChainIds:o,activeChainId:a,handleChangeActiveChainId:s,operatePool:l,setOperatePool:c,children:u}){var p,h,m,g,x,f;const{isMobile:y}=Bp(),v=t.useTheme(),{onlyChainId:b}=X(),[C,j]=n.useState(),[w,k]=n.useState(),T={limit:i?1e3:0,page:1,owner:i,order:{orderDirection:C,orderBy:w}},B=xp().getQuery(r.PoolApi.graphql.fetchDashboardPairList,{where:T}),I=d.useQuery(Object.assign({},B)),S=null!==(f=o?null===(m=null===(h=null===(p=I.data)||void 0===p?void 0:p.dashboard_pairs_list)||void 0===h?void 0:h.list)||void 0===m?void 0:m.filter((e=>{var t;return o.includes(null!==(t=null==e?void 0:e.chainId)&&void 0!==t?t:0)})):null===(x=null===(g=I.data)||void 0===g?void 0:g.dashboard_pairs_list)||void 0===x?void 0:x.list)&&void 0!==f?f:[],[A,E]=n.useState(!1),O=A?S.filter((e=>!!Number(null==e?void 0:e.tvl))):S;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[v.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[v.breakpoints.up("tablet")]:{mr:"auto"}},children:u}),!b&&G.jsx(kk,{chainId:a,setChainId:s}),G.jsx(tw,{sortList:[{label:"TVL",direction:"tvl"===w?C:void 0,onClick:()=>{if("tvl"===w)return"desc"===C?void j("asc"):(k(void 0),void j(void 0));k("tvl"),j("desc")}}],sx:{justifyContent:"space-between"},children:G.jsxs(t.Box,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[G.jsx(t.Checkbox,{sx:{top:-1},size:16,checked:A,onChange:e=>{const{checked:t}=e.target;E(t)}}),G.jsx(e.Trans,{id:"eVZ7bY",message:"Hide TVL=0 pools"})]})})]}),y?G.jsxs(qj,{children:[I.isLoading?G.jsx(zj,{}):"",!I.isLoading&&!(null==O?void 0:O.length)&&!I.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!a&&!b}),!!I.error&&G.jsx(re,{refresh:I.refetch,sx:{mt:40}}),G.jsx(Wk,{account:i,list:O,setOperatePool:c})]}):G.jsxs(G.Fragment,{children:[G.jsx($k,{account:i,list:O,loading:I.isLoading,operatePool:l,setOperatePool:c,orderBy:w,orderDirection:C,setOrderBy:k,setOrderDirection:j}),G.jsx(ky,{loading:I.isLoading,refetch:I.error?I.refetch:void 0,empty:!(null==O?void 0:O.length),hasSearch:!!a&&!b})]})]})}function Zk({account:n,lqList:i,setOperatePool:o,getMigrationPairAndMining:s,supportAMM:l,timeRange:d}){const c=t.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var u,p,h,m,g,x,f,y,v,b,C,j,w,k,T;if(!(null==i?void 0:i.pair))return null;const B=i.pair,I=Zu(B.baseToken,B.chainId),S=Zu(B.quoteToken,B.chainId),A=null===(u=B.apyList)||void 0===u?void 0:u.find((e=>(null==e?void 0:e.timeRange)===`${d}D`)),E=r.PoolApi.utils.singleSideLp(B.type),O=A?Hu(new a(null==A?void 0:A.transactionBaseApy).plus(null!==(p=null==A?void 0:A.miningBaseApy)&&void 0!==p?p:0).plus(null!==(h=null==A?void 0:A.metromMiningApy)&&void 0!==h?h:0)):void 0,L=E&&A?Hu(new a(A.transactionQuoteApy).plus(null!==(m=A.miningQuoteApy)&&void 0!==m?m:0)):void 0;let R,M;(null===(g=i.liquidityPositions)||void 0===g?void 0:g.length)&&i.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const s=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==s?void 0:s.length)){const t=s[1].toLocaleLowerCase();if((null===(i=null===(n=null==B?void 0:B.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(R=new a(e.liquidityTokenBalance));(null===(r=null===(o=null==B?void 0:B.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(M=new a(e.liquidityTokenBalance))}}}));const P=!!(null===(x=B.miningAddress)||void 0===x?void 0:x[0]),_=!!(null==A?void 0:A.metromMiningApy)&&Number(null==A?void 0:A.metromMiningApy)>0,N=null===(f=i.liquidityPositions)||void 0===f?void 0:f[0],D=B.type,F=Yu(D),U="AMMV2"===D,q="AMMV3"===D,V=null==s?void 0:s({address:B.id,chainId:B.chainId});return G.jsxs(t.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{l||zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:B.chainId,address:B.id}})},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[I&&S?G.jsx(wy,{tokens:[I,S],width:24,mr:6,chainId:B.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==I?void 0:I.symbol}/${null==S?void 0:S.symbol}`,G.jsx(gk,{address:B.id,chainId:B.chainId})]}),!!V&&G.jsx(Ik,{})]}),P||_?G.jsxs(t.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${t.alpha(c.palette.secondary.main,.3)} 0%, ${t.alpha(c.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[l&&G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[F,G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(t.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:q?null!==(v=null===(y=sj[B.lpFeeRate])||void 0===y?void 0:y.label)&&void 0!==v?v:"-":Vu({input:new a(null!==(b=B.lpFeeRate)&&void 0!==b?b:0).plus(B.mtFeeRate?Mu(B.mtFeeRate,U?4:18):0)})})})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5",color:"success.main"},children:[O||"-%",L?`/${L}`:""]}),G.jsxs(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[d,"d ",G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(Sk,{chainId:B.chainId,apy:A,baseToken:I,quoteToken:S,hasQuote:!!L,hasMining:P,sx:{width:14,height:14}})]})]}),q?null:G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h5"},children:["$",Xu({input:B.tvl,decimals:2})]}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),"AMMV2"===D&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h5"},children:Vu({input:null===(j=null===(C=i.liquidityPositions)||void 0===C?void 0:C[0])||void 0===j?void 0:j.poolShare})}),G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"h3PbRN",message:"My Pool Share"})})]}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:q?(null==N?void 0:N.liquidityUSD)?`$${Au({input:N.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[E?G.jsx(Nh,{address:null==I?void 0:I.address,chainId:B.chainId,url:null==I?void 0:I.logoURI,width:18,height:18,sx:{mr:4}}):G.jsx(wy,{tokens:I&&S?[I,S]:[],width:18,mr:4,showChainLogo:!1,chainId:B.chainId}),R?Su({input:R}):"",E&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Nh,{address:null==S?void 0:S.address,chainId:B.chainId,url:null==S?void 0:S.logoURI,width:18,height:18,sx:{mx:4}}),M?Su({input:M}):"0"]})]})}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})})]})]}),q&&G.jsxs(t.Box,{sx:{mt:20},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Dj,{outOfRange:null!==(w=null==N?void 0:N.outOfRange)&&void 0!==w&&w}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(k=null==N?void 0:N.priceRange)||void 0===k?void 0:k.token0LowerPrice,atLimit:{},direction:sv.LOWER})," "]}),null==I?void 0:I.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(T=null==N?void 0:N.priceRange)||void 0===T?void 0:T.token1LowerPrice,atLimit:{},direction:sv.UPPER})," "]}),null==I?void 0:I.symbol]})})]}),G.jsx(t.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})})]}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[q?null:!!n&&G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({operate:Qj.Remove,pool:Gu(i),hasMining:P})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),o({operate:Qj.Add,pool:Gu(i),hasMining:P})},children:G.jsx(e.Trans,{id:"J/hVSQ",message:"{0}",values:{0:q?"Manage":"Add"}})}),l&&"PMM"===F&&G.jsx(Wj,{chainId:B.chainId,address:B.id})]})]},q?null==N?void 0:N.id:B.id+B.chainId)}))})}function Qk({account:n,lqList:i,loading:s,operatePool:l,setOperatePool:d,supportAMM:c,onlyV3:u,getMigrationPairAndMining:p,timeRange:h,setOrderBy:m,setOrderDirection:g,orderBy:x,orderDirection:f}){const y=t.useTheme();return G.jsxs($j,{empty:!(null==i?void 0:i.length),loading:s,children:[G.jsx(t.Box,{component:"thead",children:G.jsxs(t.Box,{component:"tr",children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),c&&G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),u?null:G.jsx(t.Box,{component:"th",children:G.jsx(nw,{direction:"tvl"===x?f:void 0,onClick:()=>{if("tvl"===x)return"desc"===f?void g("asc"):(m(void 0),void g(void 0));m("tvl"),g("desc")},children:"TVL"})}),G.jsx(t.Box,{component:"th",children:G.jsxs(nw,{direction:"apy"===x?f:void 0,onClick:()=>{if("apy"===x)return"desc"===f?void g("asc"):(m(void 0),void g(void 0));m("apy"),g("desc")},children:[h,"d APY"]})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),u?G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})}):null,G.jsx(t.Box,{component:"th",sx:{width:210}})]})}),G.jsx(t.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var s,m,g,x,f,v,b,C,j,w,k,T,B,I,S;if(!(null==i?void 0:i.pair))return null;const A=i.pair,E=Zu(A.baseToken,A.chainId),O=Zu(A.quoteToken,A.chainId),L=r.PoolApi.utils.singleSideLp(A.type),R=null===(s=A.apyList)||void 0===s?void 0:s.find((e=>(null==e?void 0:e.timeRange)===`${h}D`)),M=R?Hu(new a(null==R?void 0:R.transactionBaseApy).plus(null!==(m=null==R?void 0:R.miningBaseApy)&&void 0!==m?m:0)):void 0,P=L&&R?Hu(new a(R.transactionQuoteApy).plus(null!==(g=R.miningQuoteApy)&&void 0!==g?g:0)):void 0;let _,N;(null===(x=i.liquidityPositions)||void 0===x?void 0:x.length)&&i.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const s=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==s?void 0:s.length)){const t=s[1].toLocaleLowerCase();if((null===(i=null===(n=null==A?void 0:A.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(_=new a(e.liquidityTokenBalance));(null===(r=null===(o=null==A?void 0:A.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(N=new a(e.liquidityTokenBalance))}}}));const D=null===(f=i.liquidityPositions)||void 0===f?void 0:f[0],F=A.type,U=Yu(F),q="AMMV2"===F,V="AMMV3"===F;let H="";if(V)(null===(C=null===(b=null===(v=null==l?void 0:l.pool)||void 0===v?void 0:v.liquidityPositions)||void 0===b?void 0:b[0])||void 0===C?void 0:C.id)===(null==D?void 0:D.id)&&(H=o.i18n._({id:"p3607o",message:"Managing"}));else if((null===(j=null==l?void 0:l.pool)||void 0===j?void 0:j.address)===A.id||(null==l?void 0:l.address)===A.id)if(l.operate===Qj.Remove)H=o.i18n._({id:"0+31GV",message:"Removing"});else H=o.i18n._({id:"1yHVE+",message:"Adding"});const W=!!(null===(w=A.miningAddress)||void 0===w?void 0:w[0]),$=!!(null==R?void 0:R.metromMiningApy)&&Number(null==R?void 0:R.metromMiningApy)>0,z=y.palette.hover.default,Z=null==p?void 0:p({address:A.id,chainId:A.chainId});return G.jsxs(t.Box,{component:"tr",sx:{["&:hover td"+(H?", & td":"")]:{backgroundImage:`linear-gradient(${z}, ${z})`}},children:[G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[E&&O?G.jsx(wy,{tokens:[E,O],width:24,mr:8,chainId:A.chainId,showChainLogo:!0}):"",G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==O?void 0:O.symbol}`,G.jsx(gk,{address:A.id,chainId:A.chainId}),!!Z&&G.jsx(Ik,{})]}),G.jsx(zf,{address:A.id,customChainId:A.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:c,onAddressClick:()=>{zy.getState().push({type:exports.PageType.PoolDetail,params:{chainId:A.chainId,address:A.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),c&&G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(lj,{poolType:U}),G.jsx(dj,{isAMMV2:q,isAMMV3:V,lpFeeRate:A.lpFeeRate,mtFeeRate:A.mtFeeRate})]})}),V?null:G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{typography:"body2"},title:A.tvl?`$${Su({input:A.tvl||0})}`:void 0,children:["$",Xu({input:A.tvl||0,decimals:2})]})}),G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[W||$?G.jsx(t.Tooltip,{title:o.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(Sk,{chainId:A.chainId,apy:R,baseToken:E,quoteToken:O,hasQuote:!!P,hasMining:W,children:G.jsxs(t.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[M||"-%",P?`/${P}`:""]})})]})}),G.jsx(t.Box,{component:"td",children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"body2"},children:V?(null==D?void 0:D.liquidityUSD)?`$${Au({input:D.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[L?G.jsx(Nh,{address:null==E?void 0:E.address,chainId:A.chainId,url:null==E?void 0:E.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):G.jsx(wy,{tokens:E&&O?[E,O]:[],width:24,mr:4,showChainLogo:!1,chainId:A.chainId}),_?Su({input:_}):"-",L&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Nh,{address:null==O?void 0:O.address,chainId:A.chainId,url:null==O?void 0:O.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),N?Su({input:N}):"0"]}),q&&G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"NXZdrO",message:"My pool share"}),children:G.jsx(t.Box,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Vu({input:null===(T=null===(k=i.liquidityPositions)||void 0===k?void 0:k[0])||void 0===T?void 0:T.poolShare})})})]})})}),u?G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Dj,{outOfRange:null!==(B=null==D?void 0:D.outOfRange)&&void 0!==B&&B}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(I=null==D?void 0:D.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:sv.LOWER})," "]}),null==E?void 0:E.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),G.jsx(t.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[ij({price:null===(S=null==D?void 0:D.priceRange)||void 0===S?void 0:S.token0UpperPrice,atLimit:{},direction:sv.UPPER})," "]}),null==E?void 0:E.symbol]})})]})}):null,G.jsx(t.Box,{component:"td",children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c&&"PMM"===U&&G.jsx(Wj,{chainId:A.chainId,address:A.id}),H?G.jsx(Vj,{text:H,onClick:()=>d(null)}):G.jsxs(G.Fragment,{children:[V?null:!!n&&G.jsxs(t.Button,{variant:t.Button.Variant.second,size:t.Button.Size.small,onClick:e=>{e.stopPropagation(),d({operate:Qj.Remove,pool:Gu(i),hasMining:W})},sx:{py:0,height:32},children:[G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"}),!!Z&&G.jsx(Ik,{isRightTop:!0})]}),G.jsx(t.Button,{size:t.Button.Size.small,onClick:()=>{d({pool:Gu(i),hasMining:W})},sx:{py:0,height:32},children:V?o.i18n._({id:"wckWOP",message:"Manage"}):o.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},V?null==D?void 0:D.id:A.id+A.chainId)}))})]})}function Gk({account:e,filterChainIds:i,activeChainId:o,handleChangeActiveChainId:a,operatePool:s,setOperatePool:l,getMigrationPairAndMining:c,tokenAndPoolFilter:u,children:p}){var h,m,g,x,f,y,v,b;const C=t.useTheme(),{minDevice:j,isMobile:w}=Bp(),k=d.useQueryClient(),{onlyChainId:T,supportAMMV2:B,supportAMMV3:I,notSupportPMM:S}=X(),[A,E]=n.useState("pmm&v2"),[O,L]=n.useState("1"),[R,M]=n.useState(),[P,_]=n.useState(),{filterTokens:N,filterASymbol:D,filterBSymbol:F,filterAddressLqList:U,handleDeleteToken:V,handleChangeFilterTokens:H,handleChangeFilterAddress:W}=Ek(u);let $=S?[]:["CLASSICAL","DVM","DSP","GSP","DPP"];B&&$.push("AMMV2"),I&&"v3"===A&&($=["AMMV3"]);const z={chainIds:i,currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:$},order:{timeRange:`${O}D`,orderDirection:R,orderBy:P}},Z=xp(),Q=Z.getQuery(r.PoolApi.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},z),{filterState:Object.assign({filterASymbol:D,filterBSymbol:F},z.filterState)})}),Y=d.useQuery(Object.assign({},Q));let K=null!==(g=null===(m=null===(h=Y.data)||void 0===h?void 0:h.liquidity_list)||void 0===m?void 0:m.lqList)&&void 0!==g?g:[];const J=!!(null==U?void 0:U.length);return J?K=[...U]:i&&(K=null!==(v=null===(y=null===(f=null===(x=Y.data)||void 0===x?void 0:x.liquidity_list)||void 0===f?void 0:f.lqList)||void 0===y?void 0:y.filter((e=>{var t,n;return i.includes(null!==(n=null===(t=null==e?void 0:e.pair)||void 0===t?void 0:t.chainId)&&void 0!==n?n:0)})))&&void 0!==v?v:[]),G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[C.breakpoints.up("tablet")]:{py:16,flexDirection:"row",gap:8,px:0,justifyContent:"space-between"}},children:[G.jsx(t.Box,{sx:{[C.breakpoints.up("tablet")]:{mr:"auto"}},children:p}),!T&&G.jsx(kk,{chainId:o,setChainId:a}),I&&G.jsx(Bk,{filterList:[{label:"V3",value:"v3"},{label:"V2 & PMM",value:"pmm&v2"}],value:A,onChange:e=>{E(e),_(void 0),M(void 0)}}),G.jsx(tw,{sortList:("v3"===A?[]:[{label:"TVL",direction:"tvl"===P?R:void 0,onClick:()=>{if("tvl"===P)return"desc"===R?void M("asc"):(_(void 0),void M(void 0));_("tvl"),M("desc")}}]).concat([{label:`${O}d APY`,direction:"apy"===P?R:void 0,onClick:()=>{if("apy"===P)return"desc"===R?void M("asc"):(_(void 0),void M(void 0));_("apy"),M("desc")}}]),children:G.jsx(Bk,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:O,onChange:e=>L(e),sx:{flex:1}})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},w?{}:{"& > button":{flex:1}}),children:null!==(b=null==u?void 0:u.element)&&void 0!==b?b:G.jsx(Zj,{value:N,onChange:H,searchAddress:(e,t)=>q(this,void 0,void 0,(function*(){var n;const i=Z.getInfiniteQuery(r.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},z),{filterState:Object.assign({address:e},z.filterState)})}),o=null===(n=(yield k.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?G.jsx(Ak,{list:o,onClick:()=>{W(o),t()}}):null}))})}),(J||!!N.length)&&G.jsxs(t.Box,{sx:{my:0},children:[J?G.jsx(Tk,{lqList:U,onDeleteTag:()=>W([])}):"",G.jsx(Hj,{tags:N,onDeleteTag:V})]})]})]}),w?G.jsxs(qj,{children:[Y.isLoading?G.jsx(zj,{}):"",!Y.isLoading&&!(null==K?void 0:K.length)&&!Y.error&&G.jsx(ee,{sx:{mt:40},hasSearch:!!(o&&!T||D||F)}),!!Y.error&&G.jsx(re,{refresh:Y.refetch,sx:{mt:40}}),G.jsx(Zk,{account:e,lqList:K,setOperatePool:l,supportAMM:B||I,getMigrationPairAndMining:c,timeRange:O})]}):G.jsxs(G.Fragment,{children:[G.jsx(Qk,{account:e,lqList:K,loading:Y.isLoading,operatePool:s,setOperatePool:l,supportAMM:B||I,onlyV3:"v3"===A,orderBy:P,orderDirection:R,setOrderBy:_,setOrderDirection:M,getMigrationPairAndMining:c,timeRange:O}),G.jsx(ky,{loading:Y.isLoading,refetch:Y.error?Y.refetch:void 0,empty:!(null==K?void 0:K.length),hasSearch:!!(o&&!T||D||F)})]})]})}function Yk(e){var{sx:n}=e,i=U(e,["sx"]);return G.jsx(t.TabPanel,{...i,sx:Object.assign(Object.assign({},n),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Kk({params:e,scrollRef:i,tokenAndPoolFilter:o,operatePool:a,onOperatePool:s,getMigrationPairAndMining:l}){var d,c,u;const{isMobile:p}=Bp();t.useTheme();const h=X((e=>e.noDocumentLink)),m=n.useRef(null),{account:g}=cp(),{poolTopTab:x,normalPoolTab:f,almPoolTab:y,multiTokenPoolTab:v,normalTabs:b,almTabs:C,topTabs:j,multiTokenTabs:w,handleChangePoolTab:k}=function(){const[e,t]=n.useState(Fk.NORMAL),[i,o]=n.useState(Uk.ALL),[r,a]=n.useState(qk.addLiquidity),[s,l]=n.useState(Vk.ALL),{supportAMMV2:d,supportAMMV3:c,notSupportPMM:u,supportCurve:p}=X(),h=n.useMemo((()=>{const e=[{key:Fk.NORMAL,value:"Normal"}];return p&&e.push({key:Fk.MULTI_TOKEN,value:"Multi-token"}),e}),[p]),m=n.useMemo((()=>[{key:Uk.ALL,value:"All vauls"},{key:Uk.MY,value:"My liquidity"}]),[]),g=n.useMemo((()=>{const e=[{key:qk.addLiquidity,value:"Add Liquidity"},{key:qk.myLiquidity,value:"My Liquidity"}];return u||e.push({key:qk.myCreated,value:d||c?"My Pools (PMM)":"My Pools"}),e}),[d,c,u]),x=n.useMemo((()=>[{key:Vk.ALL,value:"All pools"},{key:Vk.MY,value:"My liquidity"}]),[]),f=n.useRef(!1);return n.useEffect((()=>{const e=sessionStorage.getItem(_k),n=sessionStorage.getItem(Nk);e&&n&&!f.current&&(f.current=!0,t(e),e===Fk.NORMAL?a(n):e===Fk.ALM?o(n):e===Fk.MULTI_TOKEN&&l(n))}),[]),{poolTopTab:e,normalPoolTab:r,almPoolTab:i,multiTokenPoolTab:s,topTabs:h,normalTabs:g,almTabs:m,multiTokenTabs:x,handleChangePoolTab:({topTab:e,poolTab:n})=>{t(e),e===Fk.NORMAL?a(n):e===Fk.ALM?o(n):e===Fk.MULTI_TOKEN&&l(n),sessionStorage.setItem(_k,e),sessionStorage.setItem(Nk,n)}}}(),{activeChainId:T,filterChainIds:B,handleChangeActiveChainId:I}=function(){const{chainId:e}=cp(),{onlyChainId:t,defaultChainId:i}=X(),[o,a]=n.useState(t),s=n.useMemo((()=>void 0!==o?[o]:sc(e)?void 0:Object.values(r.ChainId).filter((e=>!!Number(e)))),[e,o]);return n.useEffect((()=>{const e=Number(sessionStorage.getItem(Dk));e&&a(e)}),[]),n.useEffect((()=>{!sessionStorage.getItem(Dk)&&i&&a(i)}),[i]),{activeChainId:o,filterChainIds:s,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(Dk):sessionStorage.setItem(Dk,String(e)),a(e)}}}(),[S,A]=n.useState(null),[E,O]=n.useState(a||null),L=e=>{if(s){if(s(e))return}O(e)};return n.useEffect((()=>{O(a||null)}),[a]),G.jsxs(Wy,{sx:Object.assign({},p?{p:0}:{display:"flex",gap:12,flex:1}),ref:m,children:[G.jsxs(t.Tabs,{value:x,onChange:(e,t)=>{t===Fk.NORMAL?k({topTab:t,poolTab:f}):t===Fk.ALM?k({topTab:t,poolTab:y}):t===Fk.MULTI_TOKEN&&k({topTab:t,poolTab:v})},sx:p?{}:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:[G.jsxs(t.Box,{sx:Object.assign({},p?void 0:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",pb:16,borderBottomWidth:1,borderBottomColor:"border.main",borderBottomStyle:"solid"}),children:[G.jsx(t.TabsGroup,{tabs:j,variant:"default",tabsListSx:Object.assign({justifyContent:"space-between"},p?{mb:12,gap:32}:{borderBottomWidth:0}),tabSx:p?{mr:0,padding:"0px 0px 16px 0px",flexGrow:1,flexShrink:1,flexBasis:"93px",gap:32}:{mr:48,typography:"h5",lineHeight:"25px",minHeight:41,padding:"8px 0px 8px 0px"}}),x===Fk.NORMAL&&G.jsx(Pk,{})]}),G.jsx(Yk,{value:Fk.ALM,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:"ALM"}),G.jsx(Yk,{value:Fk.NORMAL,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsxs(t.Tabs,{value:f,onChange:(e,t)=>{k({topTab:Fk.NORMAL,poolTab:t})},children:[G.jsx(t.TabPanel,{value:qk.addLiquidity,children:G.jsx(Rk,{account:g,filterChainIds:B,scrollParentRef:null!=i?i:m,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,tokenAndPoolFilter:o,getMigrationPairAndMining:l,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:qk.myLiquidity,children:G.jsx(Gk,{account:g,filterChainIds:B,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,tokenAndPoolFilter:o,getMigrationPairAndMining:l,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:qk.myCreated,children:G.jsx(zk,{account:g,filterChainIds:B,activeChainId:T,handleChangeActiveChainId:I,operatePool:E,setOperatePool:L,children:G.jsx(t.TabsButtonGroup,{tabs:b,variant:"inPaperContrast"})})}),!h&&G.jsx(Zy,{title:"How does Liquidity Pools work?",descList:[{title:"Deposit Liquidity",desc:"Select a liquidity pool that suits your preferences and supply a pair of assets in our AMM pools or any supported assets in StableSwap pools. In return, you'll receive LP tokens, representing your share of the liquidity provided."},{title:"Earn Fees",desc:"As transactions occur within the pool, fees are collected and added to your LP tokens' value. This accrues daily, giving you real-time APY as your token holdings grow."},{title:"Delegate & Change Pool Fees",desc:"Boosted pool rewards are distributed every Sunday. If you've contributed liquidity to these pools, simply visit the rewards page, select the relevant week, and claim your earnings with ease."}],linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",sx:Object.assign({mt:16},p&&{mt:20})})]})}),G.jsx(Yk,{value:Fk.MULTI_TOKEN,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsxs(t.Tabs,{value:v,onChange:(e,t)=>{k({topTab:Fk.MULTI_TOKEN,poolTab:t})},children:[G.jsx(t.TabPanel,{value:Vk.ALL,children:G.jsx(rw,{scrollParentRef:null!=i?i:m,activeChainId:T,operateCurvePool:S,setOperateCurvePool:A,account:g,children:G.jsx(t.TabsButtonGroup,{tabs:w,variant:"inPaperContrast"})})}),G.jsx(t.TabPanel,{value:Vk.MY,children:G.jsx(rw,{scrollParentRef:null!=i?i:m,activeChainId:T,operateCurvePool:S,setOperateCurvePool:A,account:g,isMyPool:!0,children:G.jsx(t.TabsButtonGroup,{tabs:w,variant:"inPaperContrast"})})})]})})]}),x===Fk.NORMAL&&E&&G.jsx(t.Box,{sx:{position:"relative",width:p?"100%":375},children:"AMMV3"===(null===(d=null==E?void 0:E.pool)||void 0===d?void 0:d.type)&&E.pool.chainId?f===qk.myLiquidity&&(null===(u=null===(c=E.pool.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.tokenId)?G.jsx(Nj,{baseToken:E.pool.baseToken,quoteToken:E.pool.quoteToken,feeAmount:Number(E.pool.lpFeeRate),tokenId:E.pool.liquidityPositions[0].tokenId,chainId:E.pool.chainId,onClose:()=>L(null)}):G.jsx(Uj,{chainId:E.pool.chainId,baseToken:E.pool.baseToken,quoteToken:E.pool.quoteToken,feeAmount:Number(E.pool.lpFeeRate),onClose:()=>L(null),handleGoToAddLiquidityV3:e=>{zy.getState().push({type:exports.PageType.createPoolAMMV3,params:e})}}):G.jsx(G.Fragment,{children:p?G.jsx(mk,{account:g,onClose:()=>L(null),modal:p,...E}):G.jsx(hk,{account:g,onClose:()=>L(null),...E,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})})}),x===Fk.MULTI_TOKEN&&S&&G.jsx(t.Box,{sx:{position:"relative",width:p?"100%":375},children:G.jsx(hw,{operateCurvePool:S,setOperateCurvePool:A})})]})}function Xk({sx:e,onClick:n}){const o=t.useTheme();return G.jsx(t.HoverOpacity,{onClick:()=>{n?n():zy.getState().back()},sx:i.merge({display:"inline-flex",alignItems:"center",cursor:"pointer"},e),children:G.jsx(t.Box,{sx:{color:o.palette.text.secondary,width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",borderColor:o.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:8,backgroundColor:o.palette.background.paper},children:G.jsx(se.ArrowBack,{})})})}var Jk,eT,tT,nT,iT,oT,rT,aT,sT,lT,dT,cT,uT;function pT(){return pT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},pT.apply(null,arguments)}const hT=e=>D.createElement("svg",pT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),Jk||(Jk=D.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_5229_28889)"})),eT||(eT=D.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_5229_28889)"})),tT||(tT=D.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_5229_28889)"})),nT||(nT=D.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_5229_28889)"})),iT||(iT=D.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_5229_28889)"})),oT||(oT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28889)"})),rT||(rT=D.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_5229_28889)"})),aT||(aT=D.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_5229_28889)"})),sT||(sT=D.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_5229_28889)"})),lT||(lT=D.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_5229_28889)"})),dT||(dT=D.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_5229_28889)"})),cT||(cT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28889)"})),uT||(uT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28889",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28889",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28889",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28889",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28889",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28889",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_5229_28889",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_5229_28889",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_5229_28889",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_5229_28889",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_5229_28889",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5229_28889",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var mT,gT,xT,fT,yT,vT,bT,CT,jT,wT,kT,TT,BT;function IT(){return IT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},IT.apply(null,arguments)}const ST=e=>D.createElement("svg",IT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mT||(mT=D.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_3900_354238)"})),gT||(gT=D.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_3900_354238)"})),xT||(xT=D.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_3900_354238)"})),fT||(fT=D.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_3900_354238)"})),yT||(yT=D.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_3900_354238)"})),vT||(vT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_3900_354238)"})),bT||(bT=D.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_3900_354238)"})),CT||(CT=D.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_3900_354238)"})),jT||(jT=D.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_3900_354238)"})),wT||(wT=D.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_3900_354238)"})),kT||(kT=D.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_3900_354238)"})),TT||(TT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_3900_354238)"})),BT||(BT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_3900_354238",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_3900_354238",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_3900_354238",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_3900_354238",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_3900_354238",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_3900_354238",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_3900_354238",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_3900_354238",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_3900_354238",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_3900_354238",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_3900_354238",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_3900_354238",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var AT,ET,OT,LT,RT,MT,PT,_T,NT,DT,FT,UT,qT,VT;function HT(){return HT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},HT.apply(null,arguments)}const WT=e=>D.createElement("svg",HT({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),AT||(AT=D.createElement("g",{clipPath:"url(#clip0_5057_344879)"},D.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344879)"}),D.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344879)"}),D.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344879)"}),D.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344879)"}),D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344879)"}),D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344879)"}),D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344879)"}),D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344879)"}),D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344879)"}),D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344879)"}))),ET||(ET=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344879)"})),OT||(OT=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344879)"})),LT||(LT=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344879)"})),RT||(RT=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344879)"})),MT||(MT=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344879)"})),PT||(PT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344879)"})),_T||(_T=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344879)"})),NT||(NT=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344879)"})),DT||(DT=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344879)"})),FT||(FT=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344879)"})),UT||(UT=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344879)"})),qT||(qT=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344879)"})),VT||(VT=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5057_344879",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5057_344879",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint2_linear_5057_344879",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint3_linear_5057_344879",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint4_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint5_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint6_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint7_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint8_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint9_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"white",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),D.createElement("linearGradient",{id:"paint10_linear_5057_344879",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5057_344879",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint12_linear_5057_344879",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint13_linear_5057_344879",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint14_linear_5057_344879",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint15_linear_5057_344879",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint16_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint17_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint18_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint19_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint20_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint21_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("clipPath",{id:"clip0_5057_344879"},D.createElement("rect",{width:737,height:220,fill:"white"})))));var $T,zT,ZT,QT,GT,YT,KT,XT,JT,eB,tB,nB,iB,oB;function rB(){return rB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},rB.apply(null,arguments)}const aB=e=>D.createElement("svg",rB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),$T||($T=D.createElement("g",{clipPath:"url(#clip0_5057_344817)"},D.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344817)"}),D.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344817)"}),D.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344817)"}),D.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344817)"}),D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344817)"}),D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344817)"}),D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344817)"}),D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344817)"}),D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344817)"}),D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344817)"}))),zT||(zT=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344817)"})),ZT||(ZT=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344817)"})),QT||(QT=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344817)"})),GT||(GT=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344817)"})),YT||(YT=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344817)"})),KT||(KT=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344817)"})),XT||(XT=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344817)"})),JT||(JT=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344817)"})),eB||(eB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344817)"})),tB||(tB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344817)"})),nB||(nB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344817)"})),iB||(iB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344817)"})),oB||(oB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5057_344817",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5057_344817",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint2_linear_5057_344817",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint3_linear_5057_344817",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint4_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint5_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint6_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint7_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint8_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint9_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),D.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),D.createElement("linearGradient",{id:"paint10_linear_5057_344817",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5057_344817",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint12_linear_5057_344817",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint13_linear_5057_344817",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint14_linear_5057_344817",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint15_linear_5057_344817",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint16_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint17_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint18_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint19_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint20_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint21_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("clipPath",{id:"clip0_5057_344817"},D.createElement("rect",{width:737,height:220,fill:"white"})))));var sB,lB,dB,cB,uB,pB,hB,mB,gB,xB,fB,yB,vB;function bB(){return bB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bB.apply(null,arguments)}const CB=e=>D.createElement("svg",bB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),sB||(sB=D.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),lB||(lB=D.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),dB||(dB=D.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),cB||(cB=D.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),uB||(uB=D.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),pB||(pB=D.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),hB||(hB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_5229_28865)"})),mB||(mB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_5229_28865)"})),gB||(gB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_5229_28865)"})),xB||(xB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_5229_28865)"})),fB||(fB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_5229_28865)"})),yB||(yB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_5229_28865)"})),vB||(vB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28865",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28865",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28865",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28865",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28865",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28865",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var jB,wB,kB,TB,BB,IB,SB,AB,EB,OB,LB,RB,MB;function PB(){return PB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},PB.apply(null,arguments)}const _B=e=>D.createElement("svg",PB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),jB||(jB=D.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),wB||(wB=D.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),kB||(kB=D.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),TB||(TB=D.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),BB||(BB=D.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),IB||(IB=D.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),SB||(SB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_3900_354262)"})),AB||(AB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_3900_354262)"})),EB||(EB=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_3900_354262)"})),OB||(OB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_3900_354262)"})),LB||(LB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_3900_354262)"})),RB||(RB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_3900_354262)"})),MB||(MB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_3900_354262",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_3900_354262",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_3900_354262",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_3900_354262",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_3900_354262",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_3900_354262",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var NB,DB,FB,UB,qB,VB,HB,WB,$B,zB,ZB,QB,GB;function YB(){return YB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},YB.apply(null,arguments)}const KB=e=>D.createElement("svg",YB({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),NB||(NB=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_5229_28987)"})),DB||(DB=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_5229_28987)"})),FB||(FB=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_5229_28987)"})),UB||(UB=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_5229_28987)"})),qB||(qB=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_5229_28987)"})),VB||(VB=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28987)"})),HB||(HB=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_5229_28987)"})),WB||(WB=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_5229_28987)"})),$B||($B=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_5229_28987)"})),zB||(zB=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_5229_28987)"})),ZB||(ZB=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_5229_28987)"})),QB||(QB=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28987)"})),GB||(GB=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5229_28987",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_5229_28987",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_5229_28987",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_5229_28987",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_5229_28987",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_5229_28987",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_5229_28987",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_5229_28987",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_5229_28987",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_5229_28987",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_5229_28987",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_5229_28987",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var XB,JB,eI,tI,nI,iI,oI,rI,aI,sI,lI,dI,cI;function uI(){return uI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uI.apply(null,arguments)}const pI=e=>D.createElement("svg",uI({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),XB||(XB=D.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_4437_25449)"})),JB||(JB=D.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_4437_25449)"})),eI||(eI=D.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_4437_25449)"})),tI||(tI=D.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_4437_25449)"})),nI||(nI=D.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_4437_25449)"})),iI||(iI=D.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_4437_25449)"})),oI||(oI=D.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_4437_25449)"})),rI||(rI=D.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_4437_25449)"})),aI||(aI=D.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_4437_25449)"})),sI||(sI=D.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_4437_25449)"})),lI||(lI=D.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_4437_25449)"})),dI||(dI=D.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_4437_25449)"})),cI||(cI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_4437_25449",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint1_linear_4437_25449",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint2_linear_4437_25449",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint3_linear_4437_25449",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint4_linear_4437_25449",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint5_linear_4437_25449",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint6_linear_4437_25449",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint7_linear_4437_25449",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint8_linear_4437_25449",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint9_linear_4437_25449",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint10_linear_4437_25449",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),D.createElement("linearGradient",{id:"paint11_linear_4437_25449",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),D.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var hI,mI;function gI(){const e="https://docs.dodoex.io/product/tutorial/how-to-create-pools#learn-more-about-the-characteristics-of-different-pool-models",t=[{version:mI.standard,title:o.i18n._({id:"TJBHlP",message:"Standard"}),description:o.i18n._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),exampleImgUrl:pI,exampleDarkImgUrl:KB,docUrl:e,initPriceLabel:o.i18n._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:o.i18n._({id:"5OKrbq",message:"Since this pool uses the PMM algorithm, which is different from the normal AMM pool mechanism, the initial price calculation is also different from AMM."}),initPriceTipsLink:"https://docs.dodoex.io/en/product/dodo-v2-pools/dodo-vending-machine/dvm-initial-price-formula-explanation"},{version:mI.pegged,title:o.i18n._({id:"J7M/DA",message:"Pegged"}),description:o.i18n._({id:"RvYEUJ",message:"Suitable for synthetic assets. The liquidity is super concentrated at some price like Curve Finance."}),exampleImgUrl:ST,exampleDarkImgUrl:hT,docUrl:e,initPriceLabel:o.i18n._({id:"4ogEAw",message:"Pegged Exchange Rate"}),initPriceTips:o.i18n._({id:"M9dIDb",message:"The pegged exchange rate refers to the exchange rate between two token assets where one's value is pegged/fixed by the other. For example, the pegged exchange rate between the US Dollar and USDT is 1."})},{version:mI.singleToken,title:o.i18n._({id:"34w3mT",message:"Single-Token"}),description:o.i18n._({id:"a1AzKr",message:"For those who are looking to sell tokens and only need ask-side liquidity."}),exampleImgUrl:_B,exampleDarkImgUrl:CB,docUrl:e,initPriceLabel:o.i18n._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:o.i18n._({id:"HGf8fG",message:"You can set the minimum selling price for single-token pools."})},{version:mI.marketMakerPool,title:o.i18n._({id:"4vKwIV",message:"Private Pool"}),description:o.i18n._({id:"pKjCsP",message:"100% use your own funds and enjoy the maximum degree of flexibility."}),exampleImgUrl:aB,exampleDarkImgUrl:WT,docUrl:e,initPriceLabel:o.i18n._({id:"CeLrge",message:"Mid Price"}),initPriceTips:o.i18n._({id:"GGPOuT",message:"set current mid price"})}],n=t.reduce(((e,t)=>(e[t.version]=t,e)),{});return{versionList:t,versionMap:n,subPeggedVersionList:xI()}}function xI(){return[{version:hI.DSP,title:o.i18n._({id:"D1bhHv",message:"The pool’s market-making price is fixed"}),description:o.i18n._({id:"lgE483",message:"Once created, the price cannot be changed. This option applies to assets like ETH-WETH."})},{version:hI.GSP,title:o.i18n._({id:"LVzIav",message:"The pool’s market-making price can be adjusted"}),description:o.i18n._({id:"KkjUUb",message:"Once created, you can adjust the pool’s market-making price at any time. This option is suitable for assets with fluctuating pegged prices. Adjusting the pool’s market-making price allows for more competitive quotes."})}]}function fI(){return xI().reduce(((e,t)=>(e[t.version]=t,e)),{})}!function(e){e.DSP="dsp",e.GSP="gsp"}(hI||(hI={})),function(e){e.standard="standard",e.singleToken="single-token",e.pegged="pagged",e.marketMakerPool="market-maker-pool"}(mI||(mI={}));const yI="0.3",vI=0,bI=10,CI="1",jI="0.0000000000001",wI=1e8,kI="1",TI="0.0001",BI="0.1",II=8;function SI({selectedVersion:e,quoteToken:t,initPrice:n,midPrice:i}){return e===mI.standard?!i||i.isZero()?null:Au({input:i,decimals:t.decimals}):Au({input:n,decimals:t.decimals})}function AI({initPrice:e}){const t=new a(e);if(!t.isFinite()||t.lte(0))return{base:null,quote:null};const n=new a(1),i=n.dividedBy(n.plus(t)).dp(II,a.ROUND_DOWN);return{base:i,quote:n.minus(i).dp(II,a.ROUND_DOWN)}}function EI({chainId:e,baseToken:t,quoteToken:n}){const i=r.basicTokenMap[e];return!(!t||!n)&&(!(!Ju(t.address,i.address)||!Ju(n.address,i.wrappedTokenAddress))||!(!Ju(t.address,i.wrappedTokenAddress)||!Ju(n.address,i.address)))}function OI({title:e,children:n,isWaiting:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:i?"-":n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function LI({status:n,selectedVersion:i,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,midPrice:l,sx:d}){var c;const{versionMap:u}=gI(),p="waiting"===n,{initPriceLabel:h}=u[i];return o&&r?G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:Object.assign({mt:0,display:"flex",alignItems:"stretch",gap:12,opacity:p?.5:1},d),children:[G.jsxs(OI,{title:G.jsx(e.Trans,{id:"fSFt4a",message:"Token Pair"}),isWaiting:p,children:[G.jsx(wy,{width:24,height:24,tokens:[o,r]}),o.symbol,"-",r.symbol]}),G.jsx(OI,{title:G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:p,children:s}),G.jsxs(OI,{title:h,isWaiting:p,children:["1 ",o.symbol," = ",null!==(c=SI({midPrice:l,quoteToken:r,selectedVersion:i,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]})]})}):null}var RI,MI;function PI(){return PI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},PI.apply(null,arguments)}const _I=e=>D.createElement("svg",PI({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),RI||(RI=D.createElement("g",{clipPath:"url(#clip0_5251_29079)"},D.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_29079)"}),D.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#EC5A7D",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),D.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_29079)"}),D.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#2FBA90",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),MI||(MI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5251_29079",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#EC5A7D",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#EC5A7D",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5251_29079",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#2FBA90",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#2FBA90",stopOpacity:0})),D.createElement("clipPath",{id:"clip0_5251_29079"},D.createElement("rect",{width:54,height:32,fill:"white"})))));var NI,DI;function FI(){return FI=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},FI.apply(null,arguments)}const UI=e=>D.createElement("svg",FI({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),NI||(NI=D.createElement("g",{clipPath:"url(#clip0_5251_28999)"},D.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_28999)"}),D.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#FF6187",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),D.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_28999)"}),D.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#55F9C7",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),DI||(DI=D.createElement("defs",null,D.createElement("linearGradient",{id:"paint0_linear_5251_28999",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#FF6187",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#FF6187",stopOpacity:0})),D.createElement("linearGradient",{id:"paint1_linear_5251_28999",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},D.createElement("stop",{stopColor:"#55F9C7",stopOpacity:.3}),D.createElement("stop",{offset:1,stopColor:"#55F9C7",stopOpacity:0})),D.createElement("clipPath",{id:"clip0_5251_28999"},D.createElement("rect",{width:54,height:32,fill:"white"})))));function qI({height:e,text:t}){return G.jsx(ee,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:e||261},emptyText:t||o.i18n._({id:"uiuMDr",message:"Enter parameters to view the yield curve"})})}const VI=n.lazy((()=>Promise.resolve().then((function(){return require("./index-CtA83niL.cjs")})))),HI=n.lazy((()=>Promise.resolve().then((function(){return require("./index-DGIFC0bG.cjs")}))));var WI,$I;function zI({baseToken:i,quoteToken:r,pmmParams:a,pmmModel:s,midPrice:l}){var d,c;const u=t.useTheme(),{isMobile:p}=Bp(),[h,m]=n.useState(WI.depth),g=n.useRef(null),[x,f]=n.useState(0),y=null!==(d=null==i?void 0:i.symbol)&&void 0!==d?d:"",v=null!==(c=null==r?void 0:r.symbol)&&void 0!==c?c:"";n.useEffect((()=>{const e=()=>{g&&g.current&&f(g.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[g,l]);const b=h===WI.depth;if(!l||l.isNaN())return G.jsx(qI,{height:p?261:b?665:494});const C=u.palette.success.main,j=u.palette.error.main,w=[{key:WI.liquidity,value:o.i18n._({id:"6y2TB3",message:"Liquidity"})},{key:WI.depth,value:o.i18n._({id:"n25Lml",message:"Depth"})}];return G.jsxs(t.Box,{ref:g,sx:{mt:2,"& input":{backgroundColor:"background.cardInput",borderStyle:"solid",borderWidth:"1px",borderColor:"border.main",borderRadius:8,color:"text.primary",overflow:"hidden"},"& .operate-btn-wrapper button":{backgroundColor:"background.paperContrast",color:"text.primary"}},children:[G.jsxs(t.Tabs,{value:h,onChange:(e,t)=>{m(t)},children:[G.jsx(t.TabsButtonGroup,{tabs:w,variant:"tag",tabsListSx:{ml:"auto"}}),G.jsx(t.Box,{sx:Object.assign({typography:"h6",mt:8,mb:14,color:"text.secondary"},p?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:G.jsx(e.Trans,{id:"tyGEMJ",message:"Amounts"})}),G.jsx(t.TabPanel,{value:WI.depth,children:x&&G.jsx(n.Suspense,{children:G.jsx(VI,{width:x,height:p?261:364,chartId:"create-pool-depth-chart",baseTokenSymbol:y,quoteTokenSymbol:v,pmmModel:s,pmmParams:a,midPrice:l,colorMap:{grid:"light"===u.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===u.palette.mode?"#E4E4E4":void 0,leftBg:[0,t.alpha(C,.04),1,t.alpha(C,.3)],leftLine:C,rightBg:[0,t.alpha(j,.04),1,t.alpha(j,.3)],rightLine:j,tooltipBg:u.palette.background.paperContrast,tooltipColor:u.palette.text.primary},notShowAmountInput:p})})}),G.jsx(t.TabPanel,{value:WI.liquidity,children:G.jsx(n.Suspense,{children:G.jsx(HI,{width:x,height:p?261:364,baseTokenSymbol:y,quoteTokenSymbol:v,pmmModel:s,pmmParams:a,midPrice:l,notShowTipText:!0,colorMap:{grid:"light"===u.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===u.palette.mode?"#E4E4E4":void 0,leftBg:[0,t.alpha(C,.04),1,t.alpha(C,.3)],leftLine:C,rightBg:[0,t.alpha(j,.04),1,t.alpha(j,.3)],rightLine:j,tooltipBg:u.palette.background.paperContrast,tooltipColor:u.palette.text.primary,textColor:u.palette.text.secondary}})})})]}),G.jsx(t.Box,{sx:Object.assign({typography:"h6",mt:6,color:"text.secondary"},p?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:G.jsx(e.Trans,{id:"DZULmp",message:"Swap Rate"})}),b?"":G.jsxs(t.Box,{sx:{typography:"h6",mt:24,color:"text.secondary",textAlign:"center"},children:["* ",o.i18n._({id:"DuVAxN",message:"The area of the chart indicates the buy/sell volume of {baseSymbol} that can be carried by the market when the current price changes to the hover price.",values:{baseSymbol:y}})]})]})}!function(e){e[e.liquidity=1]="liquidity",e[e.depth=2]="depth"}(WI||(WI={})),function(e){e[e.standard=1]="standard",e[e.singleToken=2]="singleToken",e[e.pagged=3]="pagged",e[e.marketMaker=4]="marketMaker"}($I||($I={}));const ZI=({selectedVersion:e,baseAmount:t,quoteAmount:i,initPrice:o,slippageCoefficient:a})=>{const s=n.useMemo((()=>{const n=[mI.standard,mI.singleToken].includes(e),r=e===mI.singleToken;if(!t||!r&&!i)return;const s=Number(o),l=Number(t),d=Number(i),c=Number(a);return{i:s,k:c,b:l,b0:l,q:d,q0:0!==c&&n?0:d,R:0!==c&&n?1:0}}),[t,o,i,e,a]),l=n.useMemo((()=>{if(s)return r.getPmmModel(s)}),[s]),d=n.useMemo((()=>{if(l)return l.getMidPrice()}),[l]);return{pmmParams:s,pmmModel:l,midPrice:d}};function QI({selectedVersion:e,baseToken:i,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d}){const c=t.useTheme(),{isMobile:u}=Bp(),[p,h]=n.useState(!1),{pmmParams:m,pmmModel:g,midPrice:x}=ZI({selectedVersion:e,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s});if(!u)return null;const f=o.i18n._({id:"FQfStS",message:"Emulator"}),y=o.i18n._({id:"ihn3o9",message:"The liquidity of ZUNO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{mx:20,mb:8},children:G.jsxs(t.Box,{sx:{width:"100%",px:20,py:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:c.palette.border.main,display:"flex",alignItems:"center",justifyContent:"space-between"},component:t.ButtonBase,onClick:()=>h(!0),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:c.palette.text.secondary,typography:"body1",fontWeight:600},children:[f,G.jsx(t.QuestionTooltip,{title:y,ml:4,sx:{width:14,height:14}})]}),!x||x.isNaN()?G.jsx(t.Box,{sx:{py:5,typography:"body1"},children:"-"}):"light"===c.palette.mode?G.jsx(_I,{width:"52",height:"32"}):G.jsx(UI,{width:"52",height:"32"})]})}),G.jsx(Eh,{open:p,onClose:()=>h(!1),modal:!0,title:G.jsxs(t.Box,{children:[f,G.jsx(t.QuestionTooltip,{title:y,ml:4})]}),children:G.jsx(t.Box,{sx:{px:28,pb:20,maxHeight:"calc(80vh - 134px)",overflowY:"auto",overflowX:"hidden"},children:G.jsx(zI,{baseToken:i,quoteToken:r,pmmParams:m,pmmModel:g,midPrice:x})})})]})}function GI({color:e,backgroundColor:n,tagKey:i}){return G.jsx(t.Box,{sx:{ml:8,px:8,py:2,borderRadius:4,backgroundColor:n,color:e,typography:"h6",fontWeight:500},children:i})}function YI({isWaiting:n,feeRate:i}){const r=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:r.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":G.jsxs(G.Fragment,{children:[i||"-","%",i===yI&&G.jsx(GI,{tagKey:o.i18n._({id:"/+c6tU",message:"99% Default"}),color:r.palette.purple.main,backgroundColor:t.alpha(r.palette.purple.main,.1)})]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:r.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"})})]})}function KI({isWaiting:n,selectedVersion:i,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d,peggedBaseTokenRatio:c,peggedQuoteTokenRatio:u}){const p=t.useTheme(),{pmmParams:h,pmmModel:m,midPrice:g}=ZI({selectedVersion:i,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s});return G.jsxs(G.Fragment,{children:[!n&&G.jsx(zI,{baseToken:o,quoteToken:r,pmmParams:h,pmmModel:m,midPrice:g}),G.jsxs(t.Box,{sx:{mt:n?0:20,padding:16,borderRadius:8,backgroundColor:p.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":G.jsxs(G.Fragment,{children:[c,"% ",null==o?void 0:o.symbol," : ",u,"% ",null==r?void 0:r.symbol]})}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:p.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"eK0eiF",message:"Initial asset ratio"})})]})]})}function XI({title:e,children:n,isWaiting:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:i?"-":n}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function JI({status:e,selectedVersion:n,baseToken:i,quoteToken:r,initPrice:a,slippageCoefficient:s,baseAmount:l,quoteAmount:d}){var c;const{pmmParams:u,pmmModel:p,midPrice:h}=ZI({selectedVersion:n,baseAmount:l,quoteAmount:d,initPrice:a,slippageCoefficient:s}),{versionMap:m}=gI(),g="waiting"===e,{initPriceLabel:x}=m[n];return G.jsxs(G.Fragment,{children:["running"===e&&G.jsx(zI,{baseToken:i,quoteToken:r,pmmParams:u,pmmModel:p,midPrice:h}),G.jsxs(t.Box,{sx:{mt:20,display:"flex",alignItems:"stretch",gap:12,opacity:g?.5:1},children:[G.jsx(XI,{title:o.i18n._({id:"fSFt4a",message:"Token Pair"}),isWaiting:g,children:i&&r?G.jsxs(G.Fragment,{children:[G.jsx(wy,{width:24,tokens:[i,r],chainId:i.chainId}),i.symbol,"-",r.symbol]}):""}),G.jsx(XI,{title:x,isWaiting:g,children:i&&r?G.jsxs(G.Fragment,{children:["1 ",i.symbol,"=",null!==(c=SI({midPrice:h,quoteToken:r,selectedVersion:n,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]}):""}),G.jsx(XI,{title:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:g,children:s})]})]})}function eS({isWaiting:n,selectedSubPeggedVersion:i}){var o,r;const a=t.useTheme(),s=fI();return G.jsxs(t.Box,{sx:{padding:16,borderRadius:8,backgroundColor:a.palette.background.paper,width:"50%",opacity:n?.5:1},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:n?"-":i&&null!==(r=null===(o=s[i])||void 0===o?void 0:o.title)&&void 0!==r?r:"-"}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:a.palette.text.secondary,mt:8},children:G.jsx(e.Trans,{id:"XPiFIY",message:"Can the pool price be adjusted?"})})]})}function tS({index:e,titleKey:n,status:i}){const o=t.useTheme(),{isMobile:r}=Bp();return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:Object.assign({mt:28,mb:28,borderTopColor:"border.main",borderTopStyle:"solid",borderTopWidth:1},r?{mt:12,mb:12,display:1===e?"none":"block"}:{})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",mb:20},children:[G.jsx(t.Box,{sx:{display:"flex",width:"20px",height:"20px",justifyContent:"center",alignItems:"center",flexShrink:0,borderRadius:"50%",backgroundColor:"waiting"===i?o.palette.background.paperDarkContrast:o.palette.secondary.main,typography:"h6",fontWeight:600,textAlign:"center",color:"waiting"===i?o.palette.text.disabled:o.palette.secondary.contrastText},children:"completed"===i?G.jsx(G.Fragment,{children:G.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M12.7596 3.55566L5.92549 10.3897L3.23957 7.71418L1.77734 9.17641L5.92549 13.3246L14.2218 5.02826L12.7596 3.55566Z",fill:"currentColor"})})}):e}),G.jsx(t.Box,{sx:{ml:8,typography:"body1",fontWeight:600,color:"waiting"===i?o.palette.text.disabled:o.palette.text.primary},children:n})]})]})}function nS({currentStep:e,isPeggedVersion:n}){const i=t.useTheme(),{isMobile:r}=Bp();let a="",s="",l="";switch(e){case 0:a=o.i18n._({id:"hdIg7i",message:"Select Pool Version"}),l=o.i18n._({id:"fw3eYd",message:"ZUNO provides a variety of pool versions to suit your needs."});break;case 1:a=o.i18n._({id:"lsg9Mi",message:"Parameter Settings"});break;case 2:n?a=o.i18n._({id:"6lss/t",message:"Pricing Model"}):(a=o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),s=o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}));break;case 3:if(!n)throw new Error("type is error");a=o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),s=o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."});break;case 4:if(!n)throw new Error("type is error");a=o.i18n._({id:"3ggd2j",message:"Asset ratio within the pool"});break;default:throw new Error(`Invalid Step ${e}`)}return G.jsxs(t.Box,{sx:Object.assign({position:"sticky",top:0,py:20,px:20,backgroundColor:i.palette.background.paper,zIndex:1},r?{}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"h5",color:i.palette.text.primary,fontWeight:600},children:a}),s&&G.jsx(t.QuestionTooltip,{title:s,sx:{width:16,height:16}}),G.jsx(t.Box,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:(n?[0,1,2,3,4]:[0,1,2]).map((n=>G.jsx(t.Box,{sx:{width:12,height:12,borderRadius:12,background:e>=n?i.palette.secondary.main:t.alpha(i.palette.primary.main,.1)}},n)))})]}),l&&G.jsx(t.Box,{sx:{mt:8,typography:"body2",color:i.palette.text.secondary},children:l})]})}function iS({versionItem:n,status:i}){const o=t.useTheme(),{noDocumentLink:r}=X(),a="light"===o.palette.mode;return"completed"===i?G.jsxs(t.Box,{sx:{backgroundColor:o.palette.background.paper,borderRadius:8,width:"50%",padding:16},children:[G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,color:o.palette.text.primary},children:n.title}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,mt:8,color:o.palette.text.secondary},children:n.description})]}):G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{typography:"h4",fontWeight:600},children:n.title}),!r&&G.jsxs(t.Box,{sx:{ml:8,display:"flex",padding:"2px 8px",justifyContent:"center",alignItems:"center",gap:"2px",color:o.palette.text.disabled,backgroundColor:o.palette.background.paperDarkContrast,borderRadius:4,typography:"h6"},component:"a",href:n.docUrl,target:"_blank",rel:"noreferrer",children:[G.jsx(e.Trans,{id:"TGi+jm",message:"Doc"}),G.jsx("svg",{width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 3.41667V11.5833H11.0833V7.5H12.25V11.5833C12.25 12.225 11.725 12.75 11.0833 12.75H2.91667C2.26917 12.75 1.75 12.225 1.75 11.5833V3.41667C1.75 2.775 2.26917 2.25 2.91667 2.25H7V3.41667H2.91667ZM8.16667 3.41667V2.25H12.25V6.33333H11.0833V4.23917L5.34917 9.97333L4.52667 9.15083L10.2608 3.41667H8.16667Z",fill:"currentColor"})})]})]}),G.jsx(t.Box,{sx:{position:"relative",width:"100%",minHeight:220},children:G.jsx(t.Box,{component:a?n.exampleImgUrl:n.exampleDarkImgUrl,sx:{marginTop:20,width:"100%"}})})]})}function oS({side:e,tokenList:t,occupyToken:n,needFindToken:i,chainId:o}){var r,a;let s=null,l=null;const d=t.filter((t=>!(t.side&&t.side!==e||o&&t.chainId!==o)));return d.length&&(i&&(s=null!==(r=d.find((e=>e.address===(null==i?void 0:i.address)&&e.chainId===i.chainId)))&&void 0!==r?r:null,l=s),l||(n?l=null!==(a=d.find((e=>e.address!==n.address)))&&void 0!==a?a:null:[l]=d)),{findToken:s,defaultToken:l}}function rS(){const{account:e,chainId:t}=cp(),n=zy((e=>{var t;return null===(t=e.page)||void 0===t?void 0:t.params}));return function({chainId:e,account:t,defaultBaseToken:n,defaultQuoteToken:i,tokenListInclude:o}={}){const{tokenList:r}=Tc(),a=oS({side:"from",needFindToken:n,tokenList:r,chainId:e}),s=d.useQuery(Object.assign({},id.getFetchTokenQuery(o?void 0:e,null==n?void 0:n.address,t))),l=d.useQuery(Object.assign({},id.getFetchTokenQuery(o?void 0:e,null==i?void 0:i.address,t)));let c=null,u=!1;c=a.defaultToken,s.data&&(c=s.data,u=s.isLoading);let p=null,h=!1;return p=oS({side:"to",needFindToken:i,occupyToken:c,tokenList:r,chainId:e}).defaultToken,l.data&&(p=l.data,h=l.isLoading),{defaultBaseToken:c,defaultQuoteToken:p,defaultBaseTokenLoading:u,defaultQuoteTokenLoading:h}}({chainId:t,account:e,defaultBaseToken:(null==n?void 0:n.fromAddress)?{address:null==n?void 0:n.fromAddress,chainId:t}:void 0,defaultQuoteToken:(null==n?void 0:n.toAddress)?{address:null==n?void 0:n.toAddress,chainId:t}:void 0})}function aS({tokens:e}){const{apikey:t}=X(),n=Hp(Zl.fiatPrice);return d.useQuery({enabled:!!e.length,queryKey:["fetch","fetchFiatPrice",e],queryFn:()=>q(this,void 0,void 0,(function*(){const i=yield f.post(n,{networks:e.map((e=>op(e.chainId))),addresses:e.map((e=>e.address)),symbols:e.map((e=>e.symbol)),isCache:!0},t?{headers:{apikey:t}}:void 0),o=new Map;return i.data.data&&i.data.data.forEach((e=>{const t=Number(e.price);!Number.isNaN(t)&&t>0&&o.set(e.address,t)})),o}))})}const sS=({selectedVersion:e})=>e===mI.pegged?["0.0001","0.0005","0.002"]:["0.5","0.01","1"];var lS;function dS(e,t){return!e||null==t||e.isNaN()?"":e.dp(t,a.ROUND_DOWN).toString()}function cS({state:e,fixedRatioPrice:t}){const{selectedVersion:n,baseToken:i,quoteToken:o,baseAmount:r,isFixedRatio:s,leftTokenAddress:l}=e;if(!i||!o)throw new Error("token is required");const d=l===(null==i?void 0:i.address),c=n===mI.standard,u=n===mI.pegged,p=new a(t);let h=c?jI:d?t:!p.isNaN()&&p.gt(0)?new a(1).div(p).dp(d?o.decimals:i.decimals).toString():CI;if(c){const e=18-i.decimals+o.decimals;e<String(jI).split(".")[1].length&&(h=new a(1).div(10**e).toString())}if(u){const n=AI({initPrice:h}),i=n.base?n.base.multipliedBy(100).toString():"",o=n.quote?n.quote.multipliedBy(100).toString():"";return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t,peggedBaseTokenRatio:i,peggedQuoteTokenRatio:o})}if(c&&s){const n=new a(r);if(!n.isNaN()&&!p.isNaN()&&p.gt(0)){const r=d?n.multipliedBy(p):n.div(p);return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t,baseAmount:dS(n,i.decimals),quoteAmount:dS(r,o.decimals)})}}return Object.assign(Object.assign({},e),{initPrice:h,fixedRatioPrice:t})}function uS(e,t){var n;switch(t.type){case lS.SetCurrentStep:{const{payload:n}=t;return e.selectedVersion===mI.pegged?Object.assign(Object.assign({},e),{currentStep:n>=4?4:n<=0?0:n}):Object.assign(Object.assign({},e),{currentStep:n>=2?2:n<=0?0:n})}case lS.SelectNewVersion:{const{payload:i}=t;if(i===e.selectedVersion)return e;let o,r=kI;i===mI.pegged&&(r=TI,o=hI.DSP);let a=jI;i===mI.singleToken?a="":i!==mI.standard&&(a=CI);let s=!0;return i===mI.singleToken&&(s=!1),Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:"",isFixedRatio:s,initPrice:a,fixedRatioPrice:i===mI.singleToken?"":CI,slippageCoefficient:r,isSlippageCoefficientCustomized:!sS({selectedVersion:t.payload}).includes(r),selectedVersion:t.payload,selectedSubPeggedVersion:o,leftTokenAddress:null===(n=e.baseToken)||void 0===n?void 0:n.address})}case lS.SelectNewSubPeggedVersion:return Object.assign(Object.assign({},e),{selectedSubPeggedVersion:t.payload});case lS.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:n,baseAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lS.UpdateQuoteToken:{const{baseToken:n}=e;return Object.assign(Object.assign({},e),{quoteToken:t.payload,quoteAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lS.SwitchTokens:{const{selectedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=e;return t===mI.singleToken?Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,leftTokenAddress:null==i?void 0:i.address}):Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,baseAmount:r,quoteAmount:o,leftTokenAddress:null==i?void 0:i.address})}case lS.UpdateBaseAmount:{const n=t.payload,{selectedVersion:i,quoteToken:o,fixedRatioPrice:s,isFixedRatio:l,peggedBaseTokenRatio:d}=e;if(!o)throw new Error("token is required");const c=new a(n);if(i===mI.pegged){const t=new a(d).div(100).dp(II,a.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:""});const i=c.div(t).minus(c);return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dS(i,o.decimals)})}if(i===mI.standard&&l&&s){if(!n)return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:n});const t=function(e,t){const n=new r.PMMModel;return n.B=new a(e.baseAmount),n.i=new a(e.initPrice),n.k=new a(e.slippageCoefficient),n.RStatus=1,n.getQuoteByMidPrice(t)}(Object.assign(Object.assign({},e),{baseAmount:n}),new a(s));return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dS(t,o.decimals)})}return Object.assign(Object.assign({},e),{baseAmount:n})}case lS.UpdateQuoteAmount:{const n=t.payload,{selectedVersion:i,baseToken:o,fixedRatioPrice:r,isFixedRatio:s,leftTokenAddress:l,peggedQuoteTokenRatio:d}=e;if(!o)throw new Error("token is required");const c=l===(null==o?void 0:o.address),u=new a(n);if(i===mI.pegged){const t=new a(d).div(100).dp(II,a.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:n});const i=u.div(t).minus(u);return Object.assign(Object.assign({},e),{baseAmount:dS(i,o.decimals),quoteAmount:n})}if(i===mI.standard&&s){const t=new a(r),i=t.gt(0)?c?u.div(t):u.multipliedBy(t):void 0;return Object.assign(Object.assign({},e),{baseAmount:dS(i,o.decimals),quoteAmount:n})}return Object.assign(Object.assign({},e),{quoteAmount:n})}case lS.UpdateIsFixedRatio:return Object.assign(Object.assign({},e),{isFixedRatio:t.payload});case lS.InitFixedRatioPrice:{const{leftTokenAddress:n,baseToken:i,quoteToken:o}=e;if(!i||!o)throw new Error("token is required");const r=n===(null==i?void 0:i.address),{baseTokenFiatPrice:s,quoteTokenFiatPrice:l}=t.payload,d=s&&l?new a(s).div(l):void 0,c=s&&l?new a(l).div(s):void 0,u=r?d:c,p=r?o.decimals:i.decimals;return u&&!u.isNaN()?cS({state:e,fixedRatioPrice:u.dp(p,a.ROUND_DOWN).toString()}):e}case lS.UpdateFixedRatioPrice:return cS({state:e,fixedRatioPrice:t.payload});case lS.ToggleLeftToken:{const{baseToken:t,quoteToken:n,fixedRatioPrice:i}=e;if(!t||!n)throw new Error("token is required");const o=e.leftTokenAddress===(null==t?void 0:t.address),r=o?null==n?void 0:n.address:null==t?void 0:t.address,s=new a(i);if(!s.isNaN()&&s.gt(0)){const i=new a(1).div(s).dp(o?t.decimals:n.decimals);return cS({state:Object.assign(Object.assign({},e),{leftTokenAddress:r}),fixedRatioPrice:i.toString()})}return Object.assign(Object.assign({},e),{leftTokenAddress:r})}case lS.UpdateSlippageCoefficient:return Object.assign(Object.assign({},e),{slippageCoefficient:t.payload});case lS.UpdateIsSlippageCoefficientCustomized:return Object.assign(Object.assign({},e),{isSlippageCoefficientCustomized:t.payload});case lS.UpdateFeeRate:return Object.assign(Object.assign({},e),{feeRate:t.payload});case lS.UpdateIsFeeRateCustomized:return Object.assign(Object.assign({},e),{isFeeRateCustomized:t.payload});case lS.InitEditParameters:return function(e,t){const{baseToken:n,quoteToken:i}=t;return n&&i?Object.assign(Object.assign({},e),{baseToken:n,quoteToken:i,leftTokenAddress:null==n?void 0:n.address,slippageCoefficient:"",initPrice:"",fixedRatioPrice:"",feeRate:"",isFixedRatio:!1}):e}(e,t.payload);case lS.UpdatePeggedBaseTokenRatio:{if(!e.quoteToken)throw new Error("token is required");const n=t.payload,i=new a(n).dp(II-2,a.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:"",baseAmount:"",quoteAmount:""});const o=new a(100).minus(i).dp(II-2,a.ROUND_DOWN),r=i.lte(0)?"0":e.baseAmount,s=new a(r),l=s.div(i.div(100)).minus(s);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:n,peggedQuoteTokenRatio:o.lt(0)?"0":o.toString(),baseAmount:r,quoteAmount:dS(l,e.quoteToken.decimals)})}case lS.UpdatePeggedQuoteTokenRatio:{if(!e.baseToken)throw new Error("token is required");const n=t.payload,i=new a(n).dp(II-2,a.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:n,baseAmount:"",quoteAmount:""});const o=new a(100).minus(i).dp(II-2,a.ROUND_DOWN),r=i.lte(0)?"0":e.quoteAmount,s=new a(r),l=s.div(i.div(100)).minus(s);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:o.lt(0)?"0":o.toString(),peggedQuoteTokenRatio:n,baseAmount:dS(l,e.baseToken.decimals),quoteAmount:r})}default:throw Error("Unknown action: "+t.type)}}function pS({isSingleTokenVersion:e,leftTokenAddress:t,baseToken:i,quoteToken:o,dispatch:r}){var s,l;const d=aS({tokens:n.useMemo((()=>i&&o?[i,o]:[]),[i,o])}),c=t===(null==i?void 0:i.address),u=i?null===(s=d.data)||void 0===s?void 0:s.get(i.address):void 0,p=o?null===(l=d.data)||void 0===l?void 0:l.get(o.address):void 0,h=n.useMemo((()=>{const e=u&&p?new a(u).div(p):void 0,t=u&&p?new a(p).div(u):void 0;return c?e:t}),[u,c,p]),m=!h||h.isNaN(),g=!d.isLoading&&!d.isPending&&m;return n.useLayoutEffect((()=>{g&&r({type:lS.UpdateIsFixedRatio,payload:!1})}),[r,g]),n.useLayoutEffect((()=>{e||u&&r({type:lS.InitFixedRatioPrice,payload:{baseTokenFiatPrice:u,quoteTokenFiatPrice:p}})}),[u,r,e,p]),{fiatPriceLoading:d.isLoading||d.isPending,currentPrice:h,isErrorPrice:g,isNullPrice:m}}function hS({label:e,value:n}){return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",mb:16},children:[G.jsx(t.Box,{sx:{color:"text.secondary",mr:8},children:e}),G.jsx(t.Box,{sx:{textAlign:"right",wordBreak:"break-all"},children:n})]})}function mS({on:e,onClose:n,state:i,onConfirm:r,isModify:a,loading:s}){var l,d,c,u,p,h,m;const{chainId:g}=cp(),{versionMap:x}=gI(),{isMobile:f}=Bp(),{title:y,initPriceLabel:v}=x[i.selectedVersion],{midPrice:b}=ZI({selectedVersion:i.selectedVersion,baseAmount:i.baseAmount,quoteAmount:i.quoteAmount,initPrice:i.initPrice,slippageCoefficient:i.slippageCoefficient}),C=fI(),j=i.selectedVersion===mI.pegged;return G.jsx(Eh,{open:e,onClose:n,modal:!0,title:a?o.i18n._({id:"dzV+zO",message:"Modify Confirmation"}):o.i18n._({id:"tnRI9r",message:"Pool Creation Confirmation"}),children:G.jsxs(t.Box,{sx:{flex:1,px:20,pb:20,display:"flex",flexDirection:"column",justifyContent:"space-between",width:f?void 0:420},children:[G.jsxs(t.Box,{sx:{pt:40,px:8},children:[G.jsx(hS,{label:o.i18n._({id:"eE0JZ4",message:"Version"}),value:y}),G.jsx(hS,{label:o.i18n._({id:"7m5+6j",message:"Initial Tokens"}),value:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[G.jsx(Nh,{address:null===(l=i.baseToken)||void 0===l?void 0:l.address,chainId:g,marginRight:8,width:18,height:18}),i.baseAmount||"-"," ",null===(d=i.baseToken)||void 0===d?void 0:d.symbol]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",mt:4},children:[G.jsx(Nh,{address:null===(c=i.quoteToken)||void 0===c?void 0:c.address,chainId:g,marginRight:8,width:18,height:18}),i.quoteAmount||"-"," ",null===(u=i.quoteToken)||void 0===u?void 0:u.symbol]})]})}),G.jsx(hS,{label:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),value:i.slippageCoefficient}),G.jsx(hS,{label:v,value:i.baseToken&&i.quoteToken?`1 ${i.baseToken.symbol} = ${SI({midPrice:b,quoteToken:i.quoteToken,selectedVersion:i.selectedVersion,initPrice:i.initPrice})} ${i.quoteToken.symbol}`:""}),j&&G.jsx(hS,{label:o.i18n._({id:"6lss/t",message:"Pricing Model"}),value:i.selectedSubPeggedVersion?null===(p=C[i.selectedSubPeggedVersion])||void 0===p?void 0:p.title:"-"}),G.jsx(hS,{label:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),value:`${i.feeRate}%`}),j&&G.jsx(hS,{label:o.i18n._({id:"eK0eiF",message:"Initial asset ratio"}),value:G.jsxs(G.Fragment,{children:[i.peggedBaseTokenRatio,"% ",null===(h=i.baseToken)||void 0===h?void 0:h.symbol," : ",i.peggedQuoteTokenRatio,"% ",null===(m=i.quoteToken)||void 0===m?void 0:m.symbol]})})]}),G.jsx(t.Button,{fullWidth:!0,isLoading:s,sx:{mt:30},onClick:r,children:a?o.i18n._({id:"7VpPHA",message:"Confirm"}):o.i18n._({id:"hYgDIe",message:"Create"})})]})})}!function(e){e[e.SetCurrentStep=1]="SetCurrentStep",e[e.SelectNewVersion=2]="SelectNewVersion",e[e.SelectNewSubPeggedVersion=3]="SelectNewSubPeggedVersion",e[e.UpdateBaseToken=4]="UpdateBaseToken",e[e.UpdateQuoteToken=5]="UpdateQuoteToken",e[e.SwitchTokens=6]="SwitchTokens",e[e.UpdateBaseAmount=7]="UpdateBaseAmount",e[e.UpdateQuoteAmount=8]="UpdateQuoteAmount",e[e.UpdateIsFixedRatio=9]="UpdateIsFixedRatio",e[e.UpdateFixedRatioPrice=10]="UpdateFixedRatioPrice",e[e.InitFixedRatioPrice=11]="InitFixedRatioPrice",e[e.ToggleLeftToken=12]="ToggleLeftToken",e[e.UpdateSlippageCoefficient=13]="UpdateSlippageCoefficient",e[e.UpdateIsSlippageCoefficientCustomized=14]="UpdateIsSlippageCoefficientCustomized",e[e.UpdateFeeRate=15]="UpdateFeeRate",e[e.UpdateIsFeeRateCustomized=16]="UpdateIsFeeRateCustomized",e[e.InitEditParameters=17]="InitEditParameters",e[e.UpdatePeggedBaseTokenRatio=18]="UpdatePeggedBaseTokenRatio",e[e.UpdatePeggedQuoteTokenRatio=19]="UpdatePeggedQuoteTokenRatio"}(lS||(lS={}));const gS=({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:s,feeRate:l,initPrice:d,slippageCoefficient:c})=>{const{chainId:u,account:p}=cp(),{deadLine:h}=X(),m=r.basicTokenMap[u];return{getCreateParams:()=>q(void 0,void 0,void 0,(function*(){if(!p||!n||!i)return null;let g="";const f=Number(n.decimals),y=Number(i.decimals),v=new a(l),b=e===mI.marketMakerPool,C=e===mI.standard,j=e===mI.pegged,w=e===mI.pegged&&t===hI.GSP,k={decimals:f,address:n.address},T={decimals:y,address:i.address},B=x.parseFixed(o,f).toString(),I=x.parseFixed(s||"0",y).toString(),S=b?v.times(100).toNumber():v.times(80).toNumber();let A=b&&C?new a(s).div(o).dp(y,a.ROUND_DOWN).toString():new a(d).toString();if(C){const e=18-n.decimals+i.decimals;e<String(jI).split(".")[1].length&&(A=new a(1).div(10**e).toString())}const E=Number(c||(j?"0.1":"1")),O=Math.ceil(Date.now()/1e3)+(null!=h?h:3600);let L;const R=[u,k,T,B,I,S,A,E,O];try{e===mI.standard||e===mI.singleToken?L=yield r.PoolApi.encode.createDVMPoolABI(...R):b?L=yield r.PoolApi.encode.createDPPPoolABI(...R):j?L=yield r.PoolApi.encode.createDSPPoolABI(...R):w&&(L=yield r.PoolApi.encode.createGSPPoolABI(u,p,k,T,B,I,S,A,E,O))}catch(e){throw console.error("2.0 CreatePool createPrams error",R,e),g=`2.0 CreatePool createPrams error; ERROR: ${e}`,new Error(g)}if(!L||!L.data)throw g="invalid data",new Error(g);try{const e=m.address.toLowerCase();return o&&n.address.toLowerCase()===e?L.value=Aw(o):s&&i.address.toLowerCase()===e?L.value=Aw(s):L.value=0,L}catch(e){throw console.error("2.0 sendTransaction error",e),g=`2.0 sendTransaction error; ERROR: ${e}`,new Error(g)}}))}},xS=({chainId:n,baseToken:i,quoteToken:o})=>{const r=t.useTheme();return EI({chainId:n,baseToken:i,quoteToken:o})?G.jsx(t.Box,{sx:{mb:12,py:8,px:12,borderRadius:8,backgroundColor:t.alpha(r.palette.error.main,.1),color:r.palette.error.main,textAlign:"center",typography:"h6",fontWeight:500},children:G.jsx(e.Trans,{id:"peTryP",message:"{0}-{1} is not supported. Please select another pair.",values:{0:null==i?void 0:i.symbol,1:null==o?void 0:o.symbol}})}):null};function fS({state:n,dispatch:i,openConfirm:r,isPeggedVersion:s,isStandardVersion:l,isSingleTokenVersion:d,fiatPriceLoading:c}){var u,p;const{currentStep:h,selectedVersion:m,baseToken:g,quoteToken:x,baseAmount:f,quoteAmount:y,initPrice:v,slippageCoefficient:b,feeRate:C}=n,j=new a(f||0),w=new a(y||0),k=lh(g,{amount:f}),T=lh(x,{amount:y}),B={variant:t.Button.Variant.contained},I=EI({chainId:null!==(p=null===(u=n.baseToken)||void 0===u?void 0:u.chainId)&&void 0!==p?p:1,baseToken:g,quoteToken:x}),S=o.i18n._({id:"hXzOVo",message:"Next"}),A=G.jsx(t.Button,{fullWidth:!0,disabled:!0,...B,children:S}),E=G.jsx(t.Button,{variant:t.Button.Variant.contained,fullWidth:!0,onClick:r,children:G.jsx(e.Trans,{id:"hYgDIe",message:"Create"})});if(0===h)return G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:lS.SetCurrentStep,payload:1})},children:S});const O=!g||j.isNaN()||j.lte(0),L=!x||w.isNaN()||w.lte(0);if(1===h){if(I)return A;if(s){if(!g||!x)return A}else{if(O)return A;if(k.needShowTokenStatusButton||k.insufficientBalance)return G.jsx(Iw,{status:k,buttonProps:B});if(!d){if(L)return A;if(T.needShowTokenStatusButton||T.insufficientBalance)return G.jsx(Iw,{status:T,buttonProps:B})}if(!l){if(!x)return A;const e=new a(v),t=Math.min(x.decimals,16);if(!v||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wI))return A;const n=new a(b);if(!b||n.isNaN()||n.lt(0)||n.gt(m===mI.pegged?BI:kI))return A}if(c)return A;if(EI({chainId:g.chainId,baseToken:g,quoteToken:x}))return A}return G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:lS.SetCurrentStep,payload:2})},children:S})}const R=new a(C),M=!C||R.isNaN()||R.lt(vI)||R.gt(bI);return 2===h?s?G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:lS.SetCurrentStep,payload:3})},children:S}):M?A:E:3===h?M?A:G.jsx(t.Button,{fullWidth:!0,...B,onClick:()=>{i({type:lS.SetCurrentStep,payload:4})},children:S}):4===h?O||L?A:k.needShowTokenStatusButton||k.insufficientBalance?G.jsx(Iw,{status:k,buttonProps:B}):T.needShowTokenStatusButton||T.insufficientBalance?G.jsx(Iw,{status:T,buttonProps:B}):E:null}function yS({state:i,dispatch:r,isPeggedVersion:a,isStandardVersion:s,isSingleTokenVersion:l,fiatPriceLoading:c}){const{currentStep:u}=i,p=t.useTheme(),{isMobile:h}=Bp(),m=Up(),{onlyChainId:g,chainId:x}=cp(),[f,y]=n.useState(!1),{getCreateParams:v}=gS(i),b=d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){const e=yield v();if(!e)return;(yield m.execute(o.i18n._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Mp.TX,desc:"Create pool"},e),{early:!0,metadata:{[i.selectedVersion===mI.marketMakerPool?exports.MetadataFlag.createDPPPool:i.selectedVersion===mI.pegged?i.selectedSubPeggedVersion===hI.DSP?exports.MetadataFlag.createDSPPool:exports.MetadataFlag.createGSPPool:exports.MetadataFlag.createDVMPool]:"1"}}))===Ap.Submitted&&setTimeout((()=>{zy.getState().push({type:exports.PageType.Pool,params:{tab:qk.myCreated}})}),100)}))});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:p.palette.background.paperContrast,px:20,py:20},h?{}:{position:"static",backgroundColor:"transparent",py:0}),children:[1==u&&G.jsx(xS,{chainId:x,baseToken:i.baseToken,quoteToken:i.quoteToken}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[0===u&&h&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{zy.getState().back()},children:G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),u>0&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{r({type:lS.SetCurrentStep,payload:u-1})},children:G.jsx(e.Trans,{id:"iH8pgl",message:"Back"})}),G.jsx(lv,{chainId:g,variant:t.Button.Variant.contained,fullWidth:!0,includeButton:!0,children:G.jsx(fS,{state:i,dispatch:r,openConfirm:()=>{y(!0)},isPeggedVersion:a,isStandardVersion:s,isSingleTokenVersion:l,fiatPriceLoading:c})})]})]}),G.jsx(mS,{on:f,onClose:()=>y(!1),state:i,isModify:!1,onConfirm:b.mutate,loading:b.isPending})]})}function vS({selected:e}){const n=t.useTheme();return G.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginLeft:"auto",flexShrink:0},children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:e?n.palette.success.main:n.palette.text.secondary}),e&&G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:n.palette.success.main,stroke:n.palette.success.main})]})}function bS({title:e,subTitle:n,description:i,selected:o,onClick:r,children:a,sx:s,titleSx:l}){const d=t.useTheme();d.palette.mode;return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",p:20,backgroundColor:d.palette.background.tag,borderWidth:1,borderColor:o?d.palette.primary.main:"transparent",borderStyle:"solid",borderRadius:12,flexWrap:"wrap",justifyContent:"flex-start",textAlign:"left","&:hover":{borderColor:d.palette.primary.main}},s),component:t.ButtonBase,onClick:r,children:[G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",typography:"caption",pr:2,color:d.palette.text.primary},l),children:[e,n,G.jsx(vS,{selected:o})]}),G.jsx(t.Box,{sx:{mt:8,typography:"body2",width:"100%",textAlign:"left",color:o?d.palette.text.primary:d.palette.text.secondary},children:i}),a]})}function CS({errorMsg:e,isCustomized:i,onClick:r,value:a,onChange:s}){const l=t.useTheme(),d=n.useMemo((()=>!(!a||"0"===a||Number(a))),[a]);return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{py:12,px:20,backgroundColor:l.palette.background.paper,borderColor:i&&e||d?l.palette.error.main:i?l.palette.primary.main:l.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center"},onClick:r,children:G.jsx(Nf,{value:i?a:"",onChange:s,suffix:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:16},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,ml:8},children:"%"}),G.jsx(vS,{selected:i})]}),placeholder:o.i18n._({id:"8Tg/JR",message:"Custom"}),sx:{backgroundColor:"transparent","& input":{typography:"body1",height:36,lineHeight:"36px",p:l.spacing(0),color:l.palette.text.primary,"&::placeholder":{color:l.palette.text.disabled,fontWeight:600,typography:"body1",lineHeight:1,position:"relative"}}}})}),e&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main",mt:6},children:e})]})}const jS=()=>[{title:"0.01%",description:o.i18n._({id:"yzjPpo",message:"Fees will be the same as in most other pools."}),value:"0.01"},{title:"0.3%",description:o.i18n._({id:"OJOe+K",message:"Set the fee to the same as most other pools"}),value:yI,tag:"99% Default"},{title:"1%",description:"Most suitable for swapping exotic assets.",value:"1"}];function wS(){const e=t.useTheme();return n.useMemo((()=>jS().map((n=>n.value===yI?Object.assign(Object.assign({},n),{tagBackgroundColor:t.alpha(e.palette.purple.main,.1),tagColor:e.palette.purple.main}):n))),[e.palette.purple.main])}const kS=e=>{if(!e)return"";const t=new a(e);return t.isNaN()||!t.lt(vI)&&!t.gt(bI)?"":o.i18n._({id:"vWT429",message:"The fee rate must be between 0% to 10%"})},TS=(e,t)=>{if(!e)return"";const n=new a(e);if(!n.isNaN()&&(n.lt(0)||n.gt(t===mI.pegged?BI:kI)))switch(t){case mI.standard:case mI.singleToken:case mI.marketMakerPool:return o.i18n._({id:"3U+Oti",message:"he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."});case mI.pegged:return o.i18n._({id:"LDprZB",message:"The slippage coefficient needs to be greater than 0, and less than 0.1."})}return""};function BS({dispatch:i,feeRate:o,isFeeRateCustomized:r}){const a=t.useTheme(),s=wS(),l=n.useMemo((()=>kS(o)||""),[o]);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:[s.map((e=>{const t=!r&&o===e.value;return G.jsx(bS,{title:e.title,description:e.description,onClick:()=>{i({type:lS.UpdateIsFeeRateCustomized,payload:!1}),i({type:lS.UpdateFeeRate,payload:e.value})},selected:t,subTitle:e.tag?G.jsx(GI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:a.palette.background.paper,borderColor:t?a.palette.primary.main:a.palette.border.main}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(CS,{errorMsg:l,isCustomized:r,onClick:()=>{i({type:lS.UpdateFeeRate,payload:""}),i({type:lS.UpdateIsFeeRateCustomized,payload:!0})},value:o,onChange:e=>{i({type:lS.UpdateFeeRate,payload:e})}})})]}),G.jsx(t.Box,{sx:{typography:"body2",mt:20,color:"text.secondary",px:20},children:G.jsx(e.Trans,{id:"0b0AkA",message:"* Please note that the Fee Rate cannot be modified after the pool is created"})})]})}function IS({on:t,onClose:n,onConfirm:i}){return G.jsx(Fw,{open:t,onClose:n,onConfirm:i,title:o.i18n._({id:"t+LmjM",message:"Initial Price Alert"}),modal:!0,children:G.jsx(e.Trans,{id:"yXm1vH",message:"The initial price is different from the current market price, which may cause your pool to be arbitraged"})})}const SS=({title:e,children:n,sx:i})=>{const o=t.useTheme();return G.jsxs(t.Box,{sx:Object.assign({mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},i),children:[G.jsx(t.Box,{sx:{typography:"body2",color:o.palette.text.primary,fontWeight:500,display:"flex",alignItems:"center"},children:e}),n]})};function AS({selectedVersion:i,isStandardVersion:r,isSingleTokenVersion:s,isFixedRatio:l,leftTokenAddress:d,baseToken:c,quoteToken:u,fixedRatioPrice:p,dispatch:h,priceInfo:m}){const g=t.useTheme(),[x,f]=n.useState(!1),{versionMap:y}=gI(),{initPriceLabel:v,initPriceTips:b,initPriceTipsLink:C}=y[i],j=d===(null==c?void 0:c.address),w=j?null==c?void 0:c.symbol:null==u?void 0:u.symbol,k=j?null==u?void 0:u.symbol:null==c?void 0:c.symbol,{currentPrice:T,isErrorPrice:B,isNullPrice:I,fiatPriceLoading:S}=m,A=j?null==u?void 0:u.decimals:null==c?void 0:c.decimals,E=n.useMemo((()=>{if(!u)return"";const e=function(e,t,n){if(!t)return"";const i=new a(t),r=Math.min(n,16),s=Number(`1e-${r}`);if(e!==mI.standard&&!i.isNaN()&&(i.lt(s)||i.gt(wI))){const t=s.toFixed(r);switch(e){case mI.pegged:case mI.singleToken:return o.i18n._({id:"P4iKEj",message:"The initial price needs to be greater than {min} and less than 100,000,000",values:{min:t}});case mI.marketMakerPool:return o.i18n._({id:"kdzjmC",message:"The mid price needs to be greater than {min} and less than 100,000,000",values:{min:t}})}}return""}(i,p,u.decimals);return e||""}),[p,u,i]),O=n.useMemo((()=>!(!p||"0"===p||Number(p))),[p]);return G.jsxs(G.Fragment,{children:[G.jsx(SS,{title:G.jsxs(G.Fragment,{children:[v,b&&G.jsx(t.QuestionTooltip,{title:G.jsxs(G.Fragment,{children:[b,C?G.jsxs(G.Fragment,{children:["\n",G.jsxs(t.Box,{component:"a",href:C,target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[G.jsx(e.Trans,{id:"NgeSlx",message:"Learn More"}),">"]})]}):""]}),ml:4,sx:{width:14,height:14,alignItems:"center"}})]}),sx:{mt:20},children:G.jsxs(t.Box,{sx:{pt:r?11:19,px:19,pb:11,borderWidth:1,borderStyle:"solid",borderColor:E||O?"error.main":g.palette.background.cardInput,borderRadius:8,backgroundColor:g.palette.background.cardInput,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20},children:[r?null:G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{typography:"body2",color:g.palette.text.primary,display:"flex",alignItems:"center"},children:[G.jsxs(t.Box,{sx:{fontWeight:600,color:g.palette.text.disabled,flexShrink:0},children:["1 ",null!=w?w:"-"," ="]}),G.jsx(Nf,{value:p,onChange:e=>{h({type:lS.UpdateFixedRatioPrice,payload:e})},readOnly:l,sx:{backgroundColor:"background.cardInput",pl:0,pr:0,mt:0,flex:"1 1 auto","& input":{textAlign:"right",typography:"h5",height:25,py:0,px:8,color:g.palette.text.primary,"&::placeholder":{color:g.palette.text.disabled}}}}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:g.palette.text.disabled,flexShrink:0},children:null!=k?k:"-"}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},component:t.ButtonBase,onClick:()=>{h({type:lS.ToggleLeftToken})},children:G.jsx(t.HoverOpacity,{weak:!0,component:se.Switch,sx:{marginLeft:8,p:g.spacing(2),color:g.palette.text.primary,backgroundColor:t.alpha(g.palette.primary.main,.1),borderRadius:"50%"}})})]}),E&&G.jsx(t.Box,{sx:{typography:"h6",color:"error.main",mt:-14},children:E})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r?"flex-start":"flex-end",typography:"h6",color:g.palette.text.primary,fontWeight:500},children:["=",G.jsx(e.Trans,{id:"pdZiL7",message:"Current Market Price:"})," ",S?G.jsx(t.Skeleton,{sx:{borderRadius:4},width:50,height:17}):I?G.jsx(t.Tooltip,{title:G.jsx(e.Trans,{id:"mObS+5",message:"Failed to get price of the token"}),children:G.jsx(t.Box,{component:se.Warn,sx:{width:14,height:14,color:g.palette.error.main,typography:"h6"}})}):Au({input:T,decimals:A})," ",k,B||s?null:G.jsx(t.Checkbox,{checked:l,onChange:e=>{if(e.target.checked){if(h({type:lS.UpdateIsFixedRatio,payload:!0}),!A)throw new Error("currentTokenDecimals is undefined");T&&!T.isNaN()&&h({type:lS.UpdateFixedRatioPrice,payload:T.dp(A,a.ROUND_DOWN).toString()})}else f(!0)},sx:{ml:8}})]})]})}),G.jsx(IS,{on:x,onClose:()=>f(!1),onConfirm:()=>{h({type:lS.UpdateIsFixedRatio,payload:!1})}})]})}function ES({selectedVersion:e,selectedSubPeggedVersion:n,baseToken:i,quoteToken:o,initPrice:r,dispatch:a}){var s;const l=t.useTheme(),{versionMap:d,subPeggedVersionList:c}=gI(),{initPriceLabel:u}=d[e];return i&&o?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{mt:8,display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",color:l.palette.text.secondary,fontWeight:500},children:u}),G.jsxs(t.Box,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600},children:["1 ",null==i?void 0:i.symbol,"=",null!==(s=SI({midPrice:void 0,quoteToken:o,selectedVersion:e,initPrice:r}))&&void 0!==s?s:"-"," ",o.symbol]})]}),G.jsx(t.Box,{sx:{mt:20,display:"flex",flexDirection:"column",gap:12,px:20},children:c.map((e=>{const t=n===e.version;return G.jsx(bS,{title:e.title,description:e.description,onClick:()=>{a({type:lS.SelectNewSubPeggedVersion,payload:e.version})},selected:t,subTitle:void 0,sx:{backgroundColor:l.palette.background.paper,borderColor:t?l.palette.primary.main:l.palette.border.main},titleSx:{typography:"body1",fontWeight:600}},e.version)}))})]}):null}function OS({title:e,value:n,onChange:i}){const o=t.useTheme();return G.jsxs(t.Box,{sx:{flexGrow:1,flexShrink:1,flexBasis:"50%",display:"flex",alignItems:"center",px:15,py:7,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:8,backgroundColor:o.palette.background.cardInput},children:[G.jsx(t.Box,{sx:{color:o.palette.text.primary,typography:"body1",fontWeight:500,flexShrink:0},children:e}),G.jsx(Nf,{value:n,onChange:i,suffix:"%",placeholder:"0",sx:{backgroundColor:"background.cardInput",mt:0,display:"flex",alignItems:"center",width:"100%",typography:"h5",lineHeight:"32px",color:o.palette.text.disabled,"& input":{textAlign:"right",py:0,px:8,color:o.palette.text.primary,"&::placeholder":{opacity:1,color:o.palette.text.disabled,fontWeight:600,typography:"h5",lineHeight:1,position:"relative"}}}})]})}const LS=({baseToken:i,quoteToken:o,initPrice:r,peggedBaseTokenRatio:s,peggedQuoteTokenRatio:l,baseAmount:d,quoteAmount:c,dispatch:u})=>{var p,h;const m=t.useTheme(),[g,x]=n.useMemo((()=>{const{base:e,quote:t}=AI({initPrice:r});return[e?e.multipliedBy(100).toString():null,t?t.multipliedBy(100).toString():null]}),[r]),f=""===s&&""===l,[y,v]=n.useMemo((()=>{var e,t;const n=null!==(e=null==i?void 0:i.decimals)&&void 0!==e?e:0,s=null!==(t=null==o?void 0:o.decimals)&&void 0!==t?t:0,l=new a(d).dp(n,a.ROUND_DOWN).multipliedBy(`1e${n}`),u=new a(c).dp(s,a.ROUND_DOWN).multipliedBy(`1e${s}`),p=new a(r).multipliedBy(`1e${18-n+s}`).dp(0,a.ROUND_DOWN),h=u.lt(l.multipliedBy(p).div(1e18))?u.multipliedBy(1e18).div(p):l,m=new a(1001);if(m.gt(h))return[new a(1),"100%"];const g=m.dividedBy(h);return[g,Vu({input:g})]}),[d,null==i?void 0:i.decimals,r,c,null==o?void 0:o.decimals]),b=n.useMemo((()=>!!y.lte("0.0000000001")||null!=g&&s===g&&null!=x&&l===x),[y,s,l,g,x]),C=`${null==i?void 0:i.symbol}:${null==o?void 0:o.symbol}=${g}%:${x}%`;return G.jsxs(SS,{title:G.jsx(e.Trans,{id:"OuSseo",message:"Ratio Settings"}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(OS,{title:null!==(p=null==i?void 0:i.symbol)&&void 0!==p?p:"",value:s,onChange:e=>{u({type:lS.UpdatePeggedBaseTokenRatio,payload:e})}}),G.jsx(t.Box,{sx:{color:m.palette.text.primary,typography:"body2",fontWeight:500,width:14,flexShrink:0,flexGrow:0,textAlign:"center"},children:":"}),G.jsx(OS,{title:null!==(h=null==o?void 0:o.symbol)&&void 0!==h?h:"",value:l,onChange:e=>{u({type:lS.UpdatePeggedQuoteTokenRatio,payload:e})}})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,px:19,pt:19,pb:11,borderRadius:16,borderWidth:1,borderColor:b||f?m.palette.border.main:"transparent",borderStyle:"solid",backgroundColor:b||f?m.palette.background.paper:t.alpha(m.palette.warning.main,.1)},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[f?null:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,color:b?m.palette.text.primary:m.palette.warning.main,typography:"body1",fontWeight:600},children:[b?null:G.jsx(se.Warn,{}),G.jsx(e.Trans,{id:"x3muNy",message:"Liquidity Burn Ratio"}),": ",v]}),G.jsx(t.Box,{sx:{color:m.palette.text.secondary,typography:"h6",textAlign:"center","&>strong":{color:b?m.palette.text.primary:m.palette.warning.main}},children:f?G.jsx(e.Trans,{id:"pQJBKk",message:"The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{recommendRatioText:C}}):G.jsx(e.Trans,{id:"ZlQ83E",message:"<0>{lostRatio}</0> of the initial liquidity you provide will be burned. <1/>The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{lostRatio:v,recommendRatioText:C},components:{0:G.jsx("strong",{}),1:G.jsx("br",{})}})})]}),f||!b?G.jsx(t.Button,{variant:t.Button.Variant.outlined,fullWidth:!0,size:t.Button.Size.small,onClick:()=>{u({type:lS.UpdatePeggedBaseTokenRatio,payload:null!=g?g:""})},sx:{border:`solid 1px ${m.palette.text.primary}`,color:m.palette.text.primary,"&:hover":{background:t.alpha(m.palette.text.primary,.1)}},children:G.jsx(e.Trans,{id:"NjdGps",message:"Use the recommended ratio"})}):null]})]})};function RS({open:e,onClose:n,afterClose:i,title:o,titleCenter:r,rightSlot:a,canBack:s=!0,children:l,width:d=420,height:c,testId:u}){const p=t.useTheme(),{isMobile:h}=Bp();return G.jsx(t.WidgetModal,{open:e,onClose:n,container:h?document.querySelector(`.${of}`):void 0,disableEnforceFocus:!0,children:G.jsxs(t.Box,{sx:Object.assign({backgroundColor:"background.paper",display:"flex",height:c,flexDirection:"column",justifyContent:"center",alignItems:"center",outline:0,overflow:"hidden","& > div":{width:"100%"}},h?{width:"100%",borderRadius:p.spacing(16,16,0,0)}:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:d,maxWidth:"95%",minHeight:200,maxHeight:"80%",borderRadius:16}),"data-testid":u,children:[o?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:r?"center":"space-between",p:20,width:"100%",boxSizing:"border-box"},children:[G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:o}),a,!a&&s&&G.jsx(t.Box,{component:se.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{n&&n(),null==i||i()}})]}):"",l]})})}var MS;function PS(){return PS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},PS.apply(null,arguments)}const _S=e=>D.createElement("svg",PS({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),MS||(MS=D.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},D.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function NS({dispatch:i,slippageCoefficient:r,selectedVersion:a,isCustomized:s,isStandardVersion:l}){const d=t.useTheme(),[c,u]=n.useState(!1),[p,h]=n.useState(r),m=function({selectedVersion:e}){const i=t.useTheme();return n.useMemo((()=>{const n=i.palette.background.paperDarkContrast,r=i.palette.text.disabled,a=i.palette.purple.main,s=t.alpha(a,.1);return e===mI.pegged?[{tag:"",description:o.i18n._({id:"PPqGw9",message:"Applicable to pegged assets with a fixed price and no fluctuation"}),value:"0",title:"K=0",tagBackgroundColor:"transparent",tagColor:"transparent"},{tag:o.i18n._({id:"nTWWCZ",message:"Low"}),description:o.i18n._({id:"L4nQwl",message:"Suitable for stablecoins with price fluctuations within 0.5%"}),value:"0.0001",title:"K=0.0001",tagBackgroundColor:s,tagColor:a},{tag:o.i18n._({id:"agPptk",message:"Medium"}),description:o.i18n._({id:"FrP5tr",message:"Suitable for stablecoins with price fluctuations within 2%"}),value:"0.0005",title:"K=0.0005",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"yx/fMc",message:"High"}),description:o.i18n._({id:"bC0iyq",message:"Suitable for stablecoins with price fluctuations within 10%"}),value:"0.002",title:"K=0.002",tagBackgroundColor:n,tagColor:r}]:[{tag:o.i18n._({id:"agPptk",message:"Medium"}),description:o.i18n._({id:"VXTSOE",message:"Suitable for most situations."}),value:"0.5",title:"K=0.5",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"nTWWCZ",message:"Low"}),description:o.i18n._({id:"DPi/hO",message:"Results in a relatively fixed price."}),value:"0.01",title:"K=0.01",tagBackgroundColor:n,tagColor:r},{tag:o.i18n._({id:"yx/fMc",message:"High"}),description:o.i18n._({id:"fKYdE9",message:"Results in a more volatile price."}),value:"1",title:"K=1",tagBackgroundColor:s,tagColor:a}]}),[e,i.palette])}({selectedVersion:a}),[g,x]=n.useState(r);g!==r&&(x(r),h(r));const f=n.useMemo((()=>{const e=TS(p,a);return null!=e?e:""}),[a,p]),y=n.useMemo((()=>!(!p||"0"===p||Number(p))),[p]),v=Boolean(f)||y||s&&!p;return G.jsxs(G.Fragment,{children:[G.jsx(SS,{title:G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:4,sx:{width:14,height:14}})]}),sx:{mt:20},children:G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:8,color:d.palette.text.primary,borderRadius:8,backgroundColor:d.palette.background.cardInput,"&:hover":{backgroundColor:d.palette.hover.default},"&[disabled]>svg":{color:d.palette.text.disabled}},disabled:l,onClick:l?void 0:()=>{u(!0)},children:[G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px"},children:r}),G.jsx(t.Box,{component:_S,sx:{flexShrink:0,width:18,height:18}})]})}),G.jsx(RS,{open:c,onClose:()=>u(!1),title:G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"sjn3tj",message:"Slippage Coefficient"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:8})]}),children:G.jsxs(t.Box,{sx:{flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,p:d.spacing(8,28,28)},children:[m.map((e=>{const t=!s&&p===e.value;return G.jsx(bS,{title:e.title,description:e.description,onClick:()=>{i({type:lS.UpdateIsSlippageCoefficientCustomized,payload:!1}),h(e.value)},selected:t,subTitle:e.tag?G.jsx(GI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:d.palette.background.paper,borderColor:t?d.palette.primary.main:d.palette.border.main},titleSx:{typography:"body1"}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(CS,{errorMsg:f,isCustomized:s,onClick:()=>{s||h(""),i({type:lS.UpdateIsSlippageCoefficientCustomized,payload:!0})},value:p,onChange:e=>{h(e)}})})]}),G.jsx(t.Box,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:G.jsx(t.Button,{fullWidth:!0,disabled:v,onClick:()=>{i({type:lS.UpdateSlippageCoefficient,payload:p}),u(!1)},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function DS({token:i,oppositeTokenAddress:o,dispatch:r,tokenSelectOnChange:a}){var s;const l=t.useTheme(),{chainId:c,account:u}=cp(),[p,h]=n.useState(!1),m=d.useQuery(Object.assign({},id.getFetchTokenQuery(c,null==i?void 0:i.address,u)));return i?G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:{display:"flex",alignItems:"center",px:20,py:8,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default}},onClick:()=>{h(!0)},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:i.address,marginRight:0,width:24,height:24,chainId:i.chainId||c,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(t.Box,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600,lineHeight:"32px",flexShrink:0},children:i.symbol}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",fontWeight:500,color:l.palette.text.secondary,wordBreak:"break-all"},children:["(",G.jsx(e.Trans,{id:"fsBGk0",message:"Balance"}),": ",!i.address||m.isLoading?G.jsx(t.RotatingIcon,{}):Au({input:null===(s=m.data)||void 0===s?void 0:s.balance,decimals:i.decimals}),")"]})]}),G.jsx(t.Box,{component:_S,sx:{flexShrink:0,ml:"auto",width:18,height:18,color:l.palette.text.secondary}})]}),G.jsx(Xf,{value:i,open:p,chainId:c,occupiedAddrs:[o],occupiedChainId:i.chainId,onClose:()=>{h(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return r({type:lS.SwitchTokens}),void h(!1);a(e),h(!1)}},modal:!0})]}):null}const FS=({baseToken:t,quoteToken:n,dispatch:i})=>{var o,r;return G.jsxs(SS,{title:G.jsx(e.Trans,{id:"dmiCGN",message:"Select Token Pair"}),children:[G.jsx(DS,{token:t,oppositeTokenAddress:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lS.UpdateBaseToken,payload:e})}}),G.jsx(DS,{token:n,oppositeTokenAddress:null!==(r=null==t?void 0:t.address)&&void 0!==r?r:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lS.UpdateQuoteToken,payload:e})}})]})};function US({selectedVersion:e,dispatch:n}){const i=t.useTheme(),{isMobile:o}=Bp(),{versionList:r}=gI(),a="light"===i.palette.mode;return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:r.map((i=>{const r=e===i.version;return G.jsx(bS,{title:i.title,description:i.description,onClick:()=>{n({type:lS.SelectNewVersion,payload:i.version})},selected:r,children:o&&r&&G.jsx(t.Box,{component:a?i.exampleImgUrl:i.exampleDarkImgUrl,sx:{mt:28,width:"100%",height:88.1}})},i.version)}))})}function qS(){const i=t.useTheme(),{defaultBaseToken:r,defaultQuoteToken:s}=rS(),{chainId:l}=cp(),[d,c]=n.useReducer(uS,{currentStep:0,selectedVersion:mI.standard,baseToken:r,quoteToken:s,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:jI,fixedRatioPrice:CI,leftTokenAddress:null==r?void 0:r.address,feeRate:yI,isFeeRateCustomized:!1,slippageCoefficient:kI,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});!r||d.baseToken&&d.baseToken.chainId===l||c({type:lS.UpdateBaseToken,payload:r}),!s||d.quoteToken&&d.quoteToken.chainId===l||c({type:lS.UpdateQuoteToken,payload:s});const{isMobile:u}=Bp(),{versionMap:p}=gI(),h=p[d.selectedVersion],m=d.selectedVersion===mI.singleToken,g=d.selectedVersion===mI.standard,x=d.selectedVersion===mI.pegged,f=m?d.quoteToken:d.baseToken,y=m?d.baseToken:d.quoteToken,v=pS({isSingleTokenVersion:m,leftTokenAddress:d.leftTokenAddress,baseToken:d.baseToken,quoteToken:d.quoteToken,dispatch:c}),b=new a(d.peggedBaseTokenRatio).div(100).dp(II,a.ROUND_DOWN),C=new a(d.peggedQuoteTokenRatio).div(100).dp(II,a.ROUND_DOWN),j=x&&b.lte(0),w=x&&C.lte(0),k=G.jsxs(t.Box,{sx:{px:20},children:[G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:m?d.quoteAmount:d.baseAmount,onInputChange:m?void 0:e=>{c({type:m?lS.UpdateQuoteAmount:lS.UpdateBaseAmount,payload:e})},readOnly:m||j,sx:{backgroundColor:"background.cardInput",padding:i.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:j?o.i18n._({id:"t3d3/V",message:"ratio is 0"}):void 0,token:f,occupiedAddrs:y?[y.address]:void 0,occupiedChainId:l,chainId:l,onTokenChange:x?void 0:(e,t)=>{c(t?{type:lS.SwitchTokens}:{type:m?lS.UpdateQuoteToken:lS.UpdateBaseToken,payload:e})}}),G.jsx(cy,{}),G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:m?d.baseAmount:d.quoteAmount,onInputChange:e=>{c({type:m?lS.UpdateBaseAmount:lS.UpdateQuoteAmount,payload:e})},readOnly:g&&d.isFixedRatio&&!!d.fixedRatioPrice||w,sx:{backgroundColor:"background.cardInput",padding:i.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:w?o.i18n._({id:"t3d3/V",message:"ratio is 0"}):o.i18n._({id:"5QDjef",message:"The token amount is calculated by initial price."}),token:y,occupiedAddrs:f?[f.address]:void 0,occupiedChainId:l,chainId:l,onTokenChange:(e,t)=>{c(t?{type:lS.SwitchTokens}:{type:m?lS.UpdateBaseToken:lS.UpdateQuoteToken,payload:e})}})]});return G.jsx(Wy,{children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"flex-start",height:"100%"},u?{}:{height:"auto",overflowX:"auto"}),children:[u?null:G.jsxs(t.Box,{sx:{mr:12,flexGrow:1,display:"block",overflow:"hidden"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20},children:[G.jsx(Xk,{}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"pHQq+U",message:"Pool Setup"})}),G.jsx(lj,{poolType:"PMM"})]}),G.jsx(tS,{titleKey:o.i18n._({id:"hdIg7i",message:"Select Pool Version"}),index:1,status:0===d.currentStep?"running":"completed"}),G.jsx(iS,{versionItem:h,status:0===d.currentStep?"running":"completed"},h.version),G.jsx(tS,{titleKey:o.i18n._({id:"lsg9Mi",message:"Parameter Settings"}),index:2,status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed"}),x?G.jsx(LI,{status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed",baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,midPrice:void 0}):G.jsx(JI,{status:0===d.currentStep?"waiting":1===d.currentStep?"running":"completed",baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),x&&G.jsxs(G.Fragment,{children:[G.jsx(tS,{titleKey:o.i18n._({id:"6lss/t",message:"Pricing Model"}),index:3,status:d.currentStep>2?"completed":2===d.currentStep?"running":"waiting"}),G.jsx(eS,{isWaiting:d.currentStep<2,selectedSubPeggedVersion:d.selectedSubPeggedVersion})]}),x?G.jsxs(G.Fragment,{children:[G.jsx(tS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),index:4,status:d.currentStep>3?"completed":3===d.currentStep?"running":"waiting"}),G.jsx(YI,{isWaiting:d.currentStep<3,feeRate:d.feeRate})]}):G.jsxs(G.Fragment,{children:[G.jsx(tS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),index:3,status:2===d.currentStep?"running":"waiting"}),G.jsx(YI,{isWaiting:d.currentStep<2,feeRate:d.feeRate})]}),x&&G.jsxs(G.Fragment,{children:[G.jsx(tS,{titleKey:o.i18n._({id:"3ggd2j",message:"Asset ratio within the pool"}),index:5,status:d.currentStep>4?"completed":4===d.currentStep?"running":"waiting"}),G.jsx(KI,{isWaiting:d.currentStep<4,baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount,peggedBaseTokenRatio:d.peggedBaseTokenRatio,peggedQuoteTokenRatio:d.peggedQuoteTokenRatio})]})]}),G.jsxs(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,borderRadius:0,backgroundColor:"background.paper",minHeight:"100%"},u?{}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto",height:"100%",position:"sticky",top:"0px",overflowY:"hidden"}),children:[G.jsx(nS,{currentStep:d.currentStep,isPeggedVersion:x}),0===d.currentStep&&G.jsx(US,{selectedVersion:d.selectedVersion,dispatch:c}),1===d.currentStep&&G.jsxs(G.Fragment,{children:[x?G.jsx(G.Fragment,{children:G.jsx(FS,{baseToken:d.baseToken,quoteToken:d.quoteToken,dispatch:c})}):G.jsxs(G.Fragment,{children:[G.jsx(QI,{baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),k]}),G.jsx(NS,{dispatch:c,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,isCustomized:d.isSlippageCoefficientCustomized,isStandardVersion:g}),G.jsx(AS,{selectedVersion:d.selectedVersion,isFixedRatio:d.isFixedRatio,leftTokenAddress:d.leftTokenAddress,baseToken:d.baseToken,quoteToken:d.quoteToken,fixedRatioPrice:d.fixedRatioPrice,dispatch:c,isStandardVersion:g,isSingleTokenVersion:m,priceInfo:v})]}),x&&2===d.currentStep&&G.jsx(ES,{selectedVersion:d.selectedVersion,selectedSubPeggedVersion:d.selectedSubPeggedVersion,baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,dispatch:c}),d.currentStep===(x?3:2)&&G.jsx(BS,{dispatch:c,feeRate:d.feeRate,isFeeRateCustomized:d.isFeeRateCustomized}),x&&4===d.currentStep&&G.jsxs(G.Fragment,{children:[G.jsx(QI,{baseToken:d.baseToken,quoteToken:d.quoteToken,initPrice:d.initPrice,slippageCoefficient:d.slippageCoefficient,selectedVersion:d.selectedVersion,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),G.jsx(LS,{dispatch:c,baseToken:d.baseToken,quoteToken:d.quoteToken,peggedBaseTokenRatio:d.peggedBaseTokenRatio,peggedQuoteTokenRatio:d.peggedQuoteTokenRatio,initPrice:d.initPrice,baseAmount:d.baseAmount,quoteAmount:d.quoteAmount}),G.jsx(SS,{title:G.jsx(e.Trans,{id:"E4LM3N",message:"Add Initial Liquidity"}),sx:{mt:20},children:G.jsx(t.Box,{sx:{mx:-20},children:k})})]}),G.jsx(t.Box,{sx:Object.assign({pb:160},u?{}:{pb:28})}),G.jsx(yS,{state:d,dispatch:c,isPeggedVersion:x,isStandardVersion:g,isSingleTokenVersion:m,fiatPriceLoading:v.fiatPriceLoading})]})]})})}function VS({open:n,onClose:i,title:o,children:r,singleBtn:a,danger:s,singleBtnText:l,cancelText:d,confirmText:c,disabledConfirm:u,confirmLoading:p,isManualClose:h,onConfirm:m}){const g=RS;return G.jsx(g,{open:n,onClose:i,title:G.jsx(t.Box,{sx:{textAlign:"center"},children:o}),canBack:!1,titleCenter:!0,children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1,width:"100%"},children:[G.jsx(t.Box,{sx:{typography:"body2",color:o?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:r}),a?G.jsx(t.Box,{sx:{px:20},children:G.jsx(t.Button,{fullWidth:!0,variant:t.Button.Variant.outlined,danger:s,sx:{mt:32,mb:20},onClick:()=>{i()},children:l||G.jsx(e.Trans,{id:"DPfwMq",message:"Done"})})}):G.jsxs(t.Box,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{i()},children:d||G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx(t.Button,{sx:{ml:8},variant:t.Button.Variant.outlined,danger:s,disabled:u,isLoading:p,onClick:()=>{m&&m(),h||i()},children:c||G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})]})})}function HS({sx:n,onClick:o}){const r=t.useTheme();return G.jsxs(t.HoverOpacity,{onClick:()=>{o?o():zy.getState().back()},sx:i.merge({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},n),children:[G.jsx(t.Box,{sx:{color:r.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:r.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:r.palette.background.paper,mr:6},children:G.jsx(se.ArrowBack,{})}),G.jsx(e.Trans,{id:"CKyk7Q",message:"Go back"})]})}function WS({open:i,onClose:r,alertContent:a,onConfirm:s}){const l=t.useTheme(),[d,c]=n.useState(!1),u=o.i18n._({id:"LQU+Dm",message:"Risk Disclaimer"});return G.jsx(RS,{open:i,onClose:r,title:u,canBack:!1,titleCenter:!0,children:G.jsxs(t.Box,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{mb:20,mx:20,maxHeight:275,overflowY:"auto",borderWidth:1,borderRadius:10,borderStyle:"solid",borderColor:"border.main",p:l.spacing(20),typography:"body2",backgroundColor:l.palette.background.input,color:l.palette.text.primary,textAlign:"left"},children:a}),G.jsxs(t.Box,{sx:{padding:20,pt:12,backgroundColor:l.palette.background.paperContrast},children:[G.jsxs(t.Box,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary",textAlign:"left","& a":{fontWeight:600,color:"primary.main","&:hover":{textDecoration:"underline"}}},children:[G.jsx(t.Checkbox,{sx:{top:-1},checked:d,onChange:e=>{const{checked:t}=e.target;c(t)}}),G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"dqWPbT",message:"I have read, understand, and agree to the <0>Terms of Service</0>.",components:{0:G.jsx("a",{href:"https://docs.dodoex.io/home/terms-of-service",target:"_blank",rel:"noopener noreferrer"})}})})]}),G.jsx(t.Box,{sx:{mt:12,display:"flex",alignItems:"center"},children:G.jsx(t.Button,{sx:{},disabled:!d,fullWidth:!0,onClick:()=>{c(!1),null==s||s()},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})]})})}function $S({id:e,chainId:t}){var n,i,o,s,l,c,u,p,h,m,g,x,f;const y=t?Hl[t]:"",v=xp().getQuery(r.PoolApi.graphql.fetchPool,{id:e||"",where:{refreshNow:!1,chain:y},liquidityWhere:{chain:y,refreshNow:!1,filterState:{address:e}}}),b=d.useQuery(Object.assign(Object.assign({},v),{enabled:!!e})),{pair:C,liquidity_list:j}=null!==(n=b.data)&&void 0!==n?n:{},w=null===(o=null===(i=null==j?void 0:j.lqList)||void 0===i?void 0:i[0])||void 0===o?void 0:o.pair;return Object.assign(Object.assign({},b),{poolDetail:C&&t?Object.assign(Object.assign({},C),{address:C.id,type:C.type,chainId:t,baseToken:Zu(C.baseToken,t),quoteToken:Zu(C.quoteToken,t),miningAddress:null!==(l=null===(s=null==w?void 0:w.miningAddress)||void 0===s?void 0:s[0])&&void 0!==l?l:"",apy:null==w?void 0:w.apy,baseApy:(null==w?void 0:w.apy)?Hu(new a(null!==(c=w.apy.transactionBaseApy)&&void 0!==c?c:0).plus(null!==(u=w.apy.miningBaseApy)&&void 0!==u?u:0)):void 0,quoteApy:Number(null===(p=null==w?void 0:w.apy)||void 0===p?void 0:p.transactionQuoteApy)||Number(null===(h=null==w?void 0:w.apy)||void 0===h?void 0:h.miningQuoteApy)?Hu(new a(null!==(g=null===(m=null==w?void 0:w.apy)||void 0===m?void 0:m.transactionQuoteApy)&&void 0!==g?g:0).plus(null!==(f=null===(x=null==w?void 0:w.apy)||void 0===x?void 0:x.miningQuoteApy)&&void 0!==f?f:0)):void 0,isCpPool:!1,cpAddress:void 0,cpLiquidator:void 0,cpCreator:void 0,cpCreatedAtTimestamp:void 0}):null})}function zS({disabled:n,chainId:i,baseStatus:o,quoteStatus:r,onClick:a}){const{account:s}=cp();return s?o.needShowTokenStatusButton||r.needShowTokenStatusButton?G.jsx(Iw,{status:o.needShowTokenStatusButton?o:r,buttonProps:{variant:t.Button.Variant.contained,fullWidth:!0}}):G.jsx(t.Button,{variant:t.Button.Variant.contained,fullWidth:!0,disabled:n,onClick:()=>a(),children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})}):G.jsx(lv,{chainId:i,variant:t.Button.Variant.contained,fullWidth:!0,includeButton:!0})}function ZS({state:i,pool:r,loading:s}){var l,c;const{baseToken:u,quoteToken:p,baseAmount:h,quoteAmount:m,initPrice:g,slippageCoefficient:x,feeRate:f}=i,y=d.useQuery($u.getPMMStateQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,null==r?void 0:r.type,null===(l=null==r?void 0:r.baseToken)||void 0===l?void 0:l.decimals,null===(c=null==r?void 0:r.quoteToken)||void 0===c?void 0:c.decimals)),v=t.useTheme(),{isMobile:b}=Bp(),{account:C}=cp(),j=zy(),[w,k]=n.useState(!1),T=y.data&&h?new a(h).minus(y.data.baseReserve):void 0,B=y.data&&m?new a(m).minus(y.data.quoteReserve):void 0,I=null==T?void 0:T.lt(0),S=lh(u,{amount:T}),A=lh(p,{amount:B});let E=!r||s||!h||Number(h)<0||!m||Number(m)<0;if(!E&&p){const e=new a(g),t=Math.min(p.decimals,16);(!g||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wI))&&(E=!0);const n=new a(x);(!x||n.isNaN()||n.lt(0)||n.gt(kI))&&(E=!0);const i=new a(f);(!f||i.isNaN()||i.lt(0)||i.gt(bI))&&(E=!0)}const{modifyDPPMutation:O}=Zw({pool:r||void 0});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign(Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:v.palette.background.paperContrast,px:20,py:20},b?{}:{position:"static",backgroundColor:"transparent",py:0}),{display:"flex",alignItems:"center",gap:8}),children:[b&&!!C&&G.jsx(t.Button,{variant:t.Button.Variant.second,fullWidth:!0,onClick:()=>{j.back()},children:G.jsx(e.Trans,{id:"dEgA5A",message:"Cancel"})}),G.jsx(zS,{disabled:E,chainId:null==r?void 0:r.chainId,baseStatus:S,quoteStatus:A,onClick:()=>k(!0)})]}),G.jsx(mS,{on:w,onClose:()=>k(!1),state:i,isModify:!0,loading:O.isPending,onConfirm:()=>{var e,t;O.mutate({txTitle:o.i18n._({id:"KRnA5J",message:"Set pool parameters"}),baseAmount:null!==(e=null==T?void 0:T.toString())&&void 0!==e?e:"",quoteAmount:null!==(t=null==B?void 0:B.toString())&&void 0!==t?t:"",isRemove:I,feeRate:i.feeRate,initPrice:i.initPrice,slippageCoefficient:i.slippageCoefficient,submittedBack:()=>{k(!1),j.push({type:exports.PageType.Pool,params:{tab:qk.myCreated}})}})}})]})}function QS({dispatch:i,feeRate:r,isCustomized:a}){const s=t.useTheme(),[l,d]=n.useState(!1),[c,u]=n.useState(r),p=wS();!c&&r&&u(r);const h=kS(c),m=!(!c||"0"===c||Number(c)),g=Boolean(h)||m||a&&!c;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:20,px:20},children:[G.jsxs(t.Box,{sx:{fontWeight:500,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8,size:16})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",ml:12},children:[r,"%",G.jsx(t.Button,{variant:t.Button.Variant.tag,sx:{ml:12,fontSize:12},onClick:()=>d(!0),children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]})]}),G.jsx(RS,{open:l,onClose:()=>d(!1),title:G.jsxs(t.Box,{children:[G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"}),G.jsx(t.QuestionTooltip,{title:o.i18n._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8})]}),children:G.jsxs(t.Box,{sx:{flex:1,overflowY:"auto"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,p:s.spacing(8,28,28)},children:[p.map((e=>{const t=!a&&c===e.value;return G.jsx(bS,{title:e.title,description:e.description,onClick:()=>{i({type:lS.UpdateIsFeeRateCustomized,payload:!1}),u(e.value)},selected:t,subTitle:e.tag?G.jsx(GI,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:s.palette.background.paper,borderColor:t?s.palette.primary.main:s.palette.border.main}},e.value)})),G.jsx(t.Box,{sx:{mt:8},children:G.jsx(CS,{errorMsg:h,isCustomized:a,onClick:()=>{a||u(""),i({type:lS.UpdateIsFeeRateCustomized,payload:!0})},value:c,onChange:e=>{u(e)}})})]}),G.jsx(t.Box,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:G.jsx(t.Button,{fullWidth:!0,disabled:g,onClick:()=>{i({type:lS.UpdateFeeRate,payload:c}),d(!1)},children:G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function GS({titleKey:e}){const n=t.useTheme();return G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{sx:{mt:28,mb:28,borderTopColor:"divider",borderTopStyle:"solid",borderTopWidth:1}}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",mb:20},children:G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:n.palette.text.primary},children:e})})]})}function YS({params:i}){var r,a,s,l;const c=t.useTheme(),{isMobile:u}=Bp(),{chainId:p}=cp(),[h,m]=n.useState(!1),[g,x]=n.useReducer(uS,{currentStep:0,selectedVersion:mI.marketMakerPool,baseToken:null,quoteToken:null,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:CI,fixedRatioPrice:CI,leftTokenAddress:void 0,feeRate:yI,isFeeRateCustomized:!1,slippageCoefficient:kI,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});n.useEffect((()=>{m(!window.localStorage.getItem(hc.PoolEditPage))}),[]);const[f,y]=n.useState("inital"),v=$S({id:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{poolDetail:b}=v,C=U(v,["poolDetail"]);C.isPending||C.error||b||"inital"!==f||y("open"),!g.baseToken&&(null==b?void 0:b.baseToken)&&x({type:lS.InitEditParameters,payload:b});const j=d.useQuery($u.getPMMStateQuery(null==b?void 0:b.chainId,null==b?void 0:b.address,null==b?void 0:b.type,null===(r=null==b?void 0:b.baseToken)||void 0===r?void 0:r.decimals,null===(a=null==b?void 0:b.quoteToken)||void 0===a?void 0:a.decimals));if(!g.slippageCoefficient&&(null===(l=null===(s=j.data)||void 0===s?void 0:s.pmmParamsBG)||void 0===l?void 0:l.k)){const e=j.data.pmmParamsBG.k.toString(),t=!sS({selectedVersion:g.selectedVersion}).includes(e);x({type:lS.UpdateSlippageCoefficient,payload:e}),x({type:lS.UpdateIsSlippageCoefficientCustomized,payload:t})}!g.baseAmount&&j.data&&(x({type:lS.UpdateBaseAmount,payload:j.data.baseReserve.toString()}),x({type:lS.UpdateQuoteAmount,payload:j.data.quoteReserve.toString()})),!g.fixedRatioPrice&&j.data&&x({type:lS.UpdateFixedRatioPrice,payload:j.data.pmmParamsBG.i.toString()});const w=d.useQuery($u.getLPFeeRateQuery(null==b?void 0:b.chainId,null==b?void 0:b.address,null==b?void 0:b.type));if(!g.feeRate&&w.data){const e=w.data.times(100).toString(),t=-1===jS().findIndex((t=>t.value===e));x({type:lS.UpdateFeeRate,payload:e}),x({type:lS.UpdateIsFeeRateCustomized,payload:t})}const k=g.selectedVersion===mI.singleToken,T=g.selectedVersion===mI.standard,B=pS({isSingleTokenVersion:k,leftTokenAddress:g.leftTokenAddress,baseToken:g.baseToken,quoteToken:g.quoteToken,dispatch:x}),{versionMap:I}=gI(),S=I[g.selectedVersion],A=!(null==b?void 0:b.baseToken),E=G.jsx(t.Skeleton,{variant:"rounded",width:210,height:60,sx:{padding:16,borderRadius:8}}),O=G.jsx(t.Skeleton,{variant:"rounded",height:167,sx:{mx:20,borderRadius:16}});return G.jsxs(G.Fragment,{children:[G.jsx(Wy,{children:G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"flex-start"},u?{height:"100%"}:{height:"auto"}),children:[u?null:G.jsxs(t.Box,{sx:{mr:12,flexGrow:1,display:"block"},children:[G.jsx(HS,{}),G.jsx(t.Box,{sx:{mt:28,typography:"h5",fontWeight:600,color:"text.primary"},children:G.jsx(e.Trans,{id:"pHQq+U",message:"Pool Setup"})}),G.jsx(GS,{titleKey:o.i18n._({id:"hdIg7i",message:"Select Pool Version"})}),G.jsx(iS,{versionItem:S,status:"completed"},S.version),G.jsx(GS,{titleKey:o.i18n._({id:"lsg9Mi",message:"Parameter Settings"})}),A?E:G.jsx(JI,{status:"running",baseToken:g.baseToken,quoteToken:g.quoteToken,initPrice:g.initPrice,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,baseAmount:g.baseAmount,quoteAmount:g.quoteAmount}),G.jsx(GS,{titleKey:o.i18n._({id:"Y7rVy0",message:"Fee Rate"})}),A?E:G.jsx(YI,{isWaiting:!1,feeRate:g.feeRate})]}),G.jsxs(t.Box,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,backgroundColor:"background.paper"},u?{width:"100%",borderRadius:0,minHeight:"100%"}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto"}),children:[G.jsx(t.Box,{sx:Object.assign({top:0,py:20,px:20,backgroundColor:c.palette.background.paper,zIndex:1},u?{position:"sticky"}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(t.Box,{sx:{typography:"h5",color:c.palette.text.primary,fontWeight:600},children:G.jsx(e.Trans,{id:"6XYkjc",message:"Edit Parameter Settings"})})})}),A?null:G.jsx(QI,{baseToken:g.baseToken,quoteToken:g.quoteToken,initPrice:g.initPrice,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,baseAmount:g.baseAmount,quoteAmount:g.quoteAmount}),A?O:G.jsxs(t.Box,{sx:{px:20},children:[G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:g.baseAmount,onInputChange:e=>{x({type:lS.UpdateBaseAmount,payload:e})},readOnly:k,token:g.baseToken,occupiedAddrs:g.quoteToken?[g.quoteToken.address]:void 0,occupiedChainId:p,chainId:p}),G.jsx(uy,{}),G.jsx(py,{canClickBalance:!0,showPercentage:!0,amt:g.quoteAmount,onInputChange:e=>{x({type:lS.UpdateQuoteAmount,payload:e})},token:g.quoteToken,occupiedAddrs:g.baseToken?[g.baseToken.address]:void 0,occupiedChainId:p,chainId:p})]}),A?null:G.jsxs(G.Fragment,{children:[g.selectedVersion!==mI.standard&&G.jsx(NS,{dispatch:x,slippageCoefficient:g.slippageCoefficient,selectedVersion:g.selectedVersion,isCustomized:g.isSlippageCoefficientCustomized,isStandardVersion:T}),G.jsx(AS,{selectedVersion:g.selectedVersion,isFixedRatio:g.isFixedRatio,leftTokenAddress:g.leftTokenAddress,baseToken:g.baseToken,quoteToken:g.quoteToken,fixedRatioPrice:g.fixedRatioPrice,dispatch:x,isStandardVersion:T,isSingleTokenVersion:k,priceInfo:B}),G.jsx(QS,{dispatch:x,feeRate:g.feeRate,isCustomized:g.isFeeRateCustomized})]}),G.jsx(t.Box,{sx:{pb:160,[c.breakpoints.up("tablet")]:{pb:28}}}),G.jsx(ZS,{state:g,pool:b,loading:A})]})]})}),G.jsx(VS,{singleBtn:!0,open:"open"===f,onClose:()=>y("close"),onConfirm:()=>y("close"),title:o.i18n._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),G.jsx(WS,{open:h,onClose:()=>{m(!1)},onConfirm:()=>{window.localStorage.setItem(hc.PoolEditPage,"1"),m(!1)},alertContent:G.jsx(e.Trans,{id:"Y9QDtD",message:"You are making changes to the liquidity of a private pool. This is a highly discretionary operation that may cause substantial inflows/outflows of funds and changes in market prices. Please make sure you are fully aware of the implications of each parameter modification."})})]})}function KS(e){return null==e?0:new a(e).dp(4,a.ROUND_DOWN).toNumber()}function XS({unit:i,data:o,masterKey:r,sumKey:s}){const l=t.useTheme(),d=n.useRef(null),[c,u]=n.useState(null),[p,h]=n.useState(0);n.useEffect((()=>{const e=()=>{d&&d.current&&h(d.current.offsetWidth)};return setTimeout(e,100),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[d]);const m="light"===l.palette.mode?t.alpha(l.palette.success.main,.6):l.palette.primary.main,g="#ff9553",x=o[o.length-2],f="date";let y=[];if(null==o?void 0:o.length){let e=o[0][r];o.forEach((t=>{t[r]>e&&(e=t[r])})),y=e?[0,Math.ceil(e/3),Math.ceil(e/3*2),e]:[0]}let v=0;y.forEach((e=>{const t=Uu(new a(e));let n=t.replace(".","").length;t.indexOf(".")>-1&&(n+=.11),n>v&&(v=n)}));const b=10*v+2;return G.jsxs(t.Box,{ref:d,sx:{position:"relative"},children:[G.jsxs(t.Box,{sx:{minHeight:62,mb:10},children:[G.jsxs(t.Box,{sx:{typography:"caption",mb:8},children:[i||G.jsx("span",{children:" "}),Su({input:null==x?void 0:x[s]})]}),G.jsx(t.Box,{sx:{color:"text.secondary"},children:T(null==x?void 0:x[f]).format("LL")})]}),G.jsxs(S.BarChart,{width:p,height:364,data:o,margin:{top:5,right:10,left:0,bottom:5},children:[G.jsx("defs",{children:o.map(((e,n)=>G.jsxs("linearGradient",{id:`colorBar${e.date}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[G.jsx("stop",{offset:"0%",stopColor:n===o.length-1?g:m}),G.jsx("stop",{offset:"100%",stopColor:t.alpha(n===o.length-1?g:m,.04)})]},e.date)))}),G.jsx(S.XAxis,{hide:!0,dataKey:f,axisLine:!1,tickFormatter:e=>T(e).format("MM-DD")}),G.jsx(S.YAxis,{orientation:"right",axisLine:!1,ticks:y,width:b,tickFormatter:e=>Uu(new a(e))}),G.jsx(S.Tooltip,{isAnimationActive:!1,content:({active:n,payload:i,label:o})=>{if(!(n&&i&&i.length))return null;const r=T(o).format("YYYY-MM-DD")===T().format("YYYY-MM-DD");return G.jsxs(t.Box,{sx:{px:10,py:12,maxWidth:240,borderRadius:8,backgroundColor:"background.paperContrast",typography:"h6",color:"text.secondary"},children:[G.jsx(t.Box,{sx:{mr:8},children:T(o).format("MM-DD HH:mm")}),G.jsx(t.Box,{children:i[0].value}),r?G.jsx(t.Box,{children:G.jsx(e.Trans,{id:"ubzjDN",message:"Real Time"})}):""]})},cursor:!1,coordinate:{x:0,y:0}}),G.jsx(S.Bar,{dataKey:r,onMouseMove:e=>{u(e[f])},onMouseLeave:()=>{u(null)},children:o.map((e=>G.jsx(S.Cell,{fill:`url(#colorBar${e.date})`},e.date)))}),c&&G.jsx(S.ReferenceLine,{x:c,stroke:m,strokeDasharray:"3 3"})]})]})}var JS,eA;function tA({poolDetail:e,chart24hDataFirst:i}){var s,l,c,u,p,h,m,g;const x=t.useTheme(),[f,y]=n.useState(i?JS.volume:JS.depth),v={key:JS.depth,value:o.i18n._({id:"n25Lml",message:"Depth"})},b=[{key:JS.volume,value:o.i18n._({id:"/cF7Rs",message:"Volume"})},{key:JS.feeRevenue,value:o.i18n._({id:"9QjAGB",message:"FeeRevenue"})},{key:JS.traders,value:o.i18n._({id:"qDhDFK",message:"Traders"})}];i?b.push(v):b.splice(0,0,v);const C=function({address:e,chainId:t,day:n}){var i,o,s;const l=t?Hl[t]:"",c=xp().getQuery(r.PoolApi.graphql.fetchPoolDayData,{where:{pair_address:null!=e?e:"",chain:l,day:n}}),u=d.useQuery(Object.assign(Object.assign({},c),{enabled:!!e&&!!t})),p=null!==(s=null===(o=null===(i=u.data)||void 0===i?void 0:i.dashboard_pairs_day_data)||void 0===o?void 0:o.map((e=>{var t,n;return{volume:KS(null==e?void 0:e.volumeUsd),fee:KS(new a(null!==(t=null==e?void 0:e.feeUsd)&&void 0!==t?t:0).plus(null!==(n=null==e?void 0:e.mtFeeUsd)&&void 0!==n?n:0).toString()),traders:(null==e?void 0:e.addresses)?Number(e.addresses):0,date:(null==e?void 0:e.timestamp)?1e3*(null==e?void 0:e.timestamp):0,tvl:KS(null==e?void 0:e.tvlUsd)}})))&&void 0!==s?s:[];return Object.assign(Object.assign({},u),{dayDataList:p})}({chainId:null==e?void 0:e.chainId,address:null==e?void 0:e.address,day:30}),j=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals)),{pmmParamsBG:w}=null!==(c=j.data)&&void 0!==c?c:{},k=w?{i:w.i.toNumber(),k:w.k.toNumber(),b:w.b.toNumber(),b0:w.b0.toNumber(),q:w.q.toNumber(),q0:w.k.isEqualTo(0)?w.q.toNumber():w.q0.toNumber(),R:w.k.isEqualTo(0)?0:w.R}:void 0,T=k?r.getPmmModel(k):void 0,[B,I]=n.useState(!1),S=B&&(null===(u=j.data)||void 0===u?void 0:u.midPrice)?new a(1).div(null===(p=j.data)||void 0===p?void 0:p.midPrice):null===(h=j.data)||void 0===h?void 0:h.midPrice;return G.jsx(t.Box,{sx:{mt:24,[x.breakpoints.up("tablet")]:{mt:20,pt:28,borderTop:`1px solid ${x.palette.border.main}`}},children:G.jsxs(t.Tabs,{value:f,onChange:(e,t)=>y(t),children:[G.jsx(t.TabsGroup,{tabs:b,variant:"rounded",tabsListSx:{borderWidth:0,gap:4,mb:24}}),f===JS.depth&&(null==e?void 0:e.baseToken)&&(null==e?void 0:e.quoteToken)?G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:G.jsx(nA,{baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,midPrice:S,isSwitchMidPrice:B,setIsSwitchMidPrice:I,showMidPrice:f===JS.depth})}):"",G.jsx(t.TabPanel,{value:JS.depth,children:G.jsx(zI,{baseToken:null!==(m=null==e?void 0:e.baseToken)&&void 0!==m?m:null,quoteToken:null!==(g=null==e?void 0:e.quoteToken)&&void 0!==g?g:null,pmmParams:k,pmmModel:T,midPrice:S})}),G.jsx(t.TabPanel,{value:JS.volume,children:G.jsx(XS,{data:C.dayDataList,masterKey:"volume",sumKey:"volume",unit:"$"})}),G.jsx(t.TabPanel,{value:JS.feeRevenue,children:G.jsx(XS,{data:C.dayDataList,masterKey:"fee",sumKey:"fee",unit:"$"})}),G.jsx(t.TabPanel,{value:JS.traders,children:G.jsx(XS,{data:C.dayDataList,masterKey:"traders",sumKey:"traders",unit:""})})]})})}function nA({baseToken:e,quoteToken:n,midPrice:i,isSwitchMidPrice:o,setIsSwitchMidPrice:r,showMidPrice:a}){const s=null==e?void 0:e.symbol,l=null==n?void 0:n.symbol,d=o?l:s,c=o?s:l;return G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:a?G.jsxs(t.Box,{sx:{mt:4,typography:"body2",color:"text.secondary",wordBreak:"break-all",display:"flex"},children:[`1 ${d} = ${i?Su({input:i,showDecimals:16}):"-"} ${c}`,G.jsx(t.HoverOpacity,{weak:!0,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,position:"relative",top:1.5,ml:9,cursor:"pointer",borderRadius:"50%",backgroundColor:"background.paperDarkContrast",p:0},onClick:()=>r((e=>!e)),children:G.jsx(t.Box,{component:se.Switch})})]}):""})}function iA({poolDetail:i}){var o,s,l;const{isMobile:c}=Bp(),u=t.useTheme(),p=null==i?void 0:i.chainId;null===(l=d.useQuery($u.getPMMStateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,null===(o=null==i?void 0:i.baseToken)||void 0===o?void 0:o.decimals,null===(s=null==i?void 0:i.quoteToken)||void 0===s?void 0:s.decimals)).data)||void 0===l||l.midPrice;const h=function({pool:e}){var t,n,i,o,s,l,c;const{chainId:u,address:p,type:h,baseToken:m,quoteToken:g}=e||{},x=null!=p?p:"",f=u?Hl[u]:"",y=null==m?void 0:m.decimals,v=null==g?void 0:g.decimals,b=d.useQuery($u.getPMMStateQuery(u,p,h,null==m?void 0:m.decimals,null==g?void 0:g.decimals)),C=null===(t=b.data)||void 0===t?void 0:t.midPrice,j=d.useQuery($u.getTotalBaseLpQuery(u,p,h,y)),w=d.useQuery($u.getTotalQuoteLpQuery(u,p,h,v)),k=d.useQuery($u.getReserveLpQuery(u,p,h,y,v)),T=d.useQuery($u.getClassicalTargetQuery(u,p,h,y,v)),B=j.data;let I=w.data;I||w.isLoading||w.error||!B||(I=B);const{baseReserve:S,quoteReserve:A}=k.data||{},E=null===(n=T.data)||void 0===n?void 0:n.baseTarget,O=null===(i=T.data)||void 0===i?void 0:i.quoteTarget,L=aS({tokens:g?[g]:[]}),R=xp(),M=d.useQuery(Object.assign(Object.assign({},R.getQuery(r.PoolApi.graphql.fetchLiquidityPositions,{id:x,where:{pair:x,liquidityTokenBalance_not:"0",chain:f,refreshNow:!0},miningWhere:{pair:x,liquidityTokenInMining_not:"0",chain:f},first:1e3,orderBy:"liquidityTokenBalance",orderDirection:"desc"})),{enabled:!!p})),{balance:P,mining:_,pair:N}=null!==(o=M.data)&&void 0!==o?o:{};let D=[];const F=g?null===(s=L.data)||void 0===s?void 0:s.get(g.address):void 0;if(P&&_&&N){const{baseLpToken:e,quoteLpToken:t}=N,n=new Map,i=(null==e?void 0:e.id)===(null==t?void 0:t.id);for(const o of P){const{id:r,liquidityTokenBalance:s}=o,l=new a(null!=s?s:0),[d,c]=r.split("-");let u={id:d,baseSupplied:new a(0),quoteSupplied:new a(0)};n.has(u.id)?u=n.get(u.id):n.set(u.id,u);const[,m]=xw(l,B,S,E,p,h,y);m&&(i||c===(null==e?void 0:e.id))&&(u.baseSupplied=m);const[,g]=xw(l,I,A,O,p,h,v);g&&(i||c===(null==t?void 0:t.id))&&(u.quoteSupplied=g)}for(const o of _){const{id:r,liquidityTokenInMining:s}=o,l=new a(null!=s?s:0),[d,c]=r.split("-"),[,u]=xw(l,B,S,E,p,h,y),[,m]=xw(l,I,A,O,p,h,v);if(n.has(d)){const o=n.get(d);u&&(i||c===(null==e?void 0:e.id))&&(o.baseSupplied=u.plus(o.baseSupplied)),m&&(i||c===(null==t?void 0:t.id))&&(o.quoteSupplied=m.plus(o.quoteSupplied))}else{const o={id:d,baseSupplied:new a(0),quoteSupplied:new a(0)};u&&(i||c===(null==e?void 0:e.id))&&(o.baseSupplied=u),m&&(i||c===(null==t?void 0:t.id))&&(o.quoteSupplied=m),n.set(o.id,o)}}const o=(null!==(l=null==m?void 0:m.decimals)&&void 0!==l?l:0)>6?6:4,r=(null!==(c=null==g?void 0:g.decimals)&&void 0!==c?c:0)>6?6:4,s=F;n.forEach((e=>{var t,n;D.push({userId:e.id,baseSupplied:e.baseSupplied?Su({input:e.baseSupplied,showDecimals:o}):"0",quoteSupplied:e.quoteSupplied?Su({input:e.quoteSupplied,showDecimals:r}):"0",baseTokenAddress:null!==(t=null==m?void 0:m.address)&&void 0!==t?t:"",quoteTokenAddress:null!==(n=null==g?void 0:g.address)&&void 0!==n?n:"",baseTokenSymbol:Wu(m),quoteTokenSymbol:Wu(g),sharePercentage:C&&S?Su({input:C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).div(C.multipliedBy(S).plus(null!=A?A:0)).multipliedBy(100),showDecimals:2}):"",dollarValue:null!=s&&C?`$${Su({input:C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).multipliedBy(s),showDecimals:2})}`:"-",dollarValueBN:C?C.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0):a(0)})})),D.sort(((e,t)=>t.dollarValueBN.gt(e.dollarValueBN)?1:-1))}const U=[b,j,w,T,k,L,M],q=function(e){const t=[];if(e.forEach((e=>{e.error&&t.push(e.refetch)})),t.length)return()=>{t.forEach((e=>e()))}}(U),V=U.some((e=>e.isLoading));return Object.assign(Object.assign({},M),{isLoading:V,errorRefetch:q,list:D})}({pool:i}),[m,g]=n.useState(1),x=m*(c?4:8),f=h.list,y=x<f.length,v=f.slice(0,x);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:h.error?h.refetch:void 0,loading:h.isLoading&&!(null==v?void 0:v.length),empty:!(null==v?void 0:v.length),children:!!(null==v?void 0:v.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"JlIjZf",message:"Liquidity Provider"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"C1qIFl",message:"Liquidity Supplied"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"me2dmq",message:"Value (USD)"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"Z8lGw6",message:"Share"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==v?void 0:v.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center"},children:G.jsx(zf,{address:e.userId,customChainId:p,truncate:!0})})}),G.jsxs("td",{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.baseTokenAddress,chainId:p,width:18,height:18}),`${e.baseSupplied} ${e.baseTokenSymbol}`]}),G.jsxs(t.Box,{sx:{mt:4,display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.quoteTokenAddress,chainId:p,width:18,height:18}),`${e.quoteSupplied} ${e.quoteTokenSymbol}`]})]}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:e.dollarValue}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:`${e.sharePercentage}%`})]},e.userId)))})]})}),y&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:u.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>g((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function oA({address:e,chainId:t}){var n;const i=xp(),o=t?Hl[t]:"",a=i.getQuery(r.PoolApi.graphql.fetchPoolDashboard,{where:{pair_address:null!=e?e:"",chain:o}}),s=d.useQuery(Object.assign(Object.assign({},a),{enabled:!!e&&!!t})),l=null===(n=s.data)||void 0===n?void 0:n.dashboard_pairs_detail;return Object.assign(Object.assign({},s),{dashboard:l})}function rA(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function aA({chainId:e,address:n,symbol:o,amount:r,sx:a}){return G.jsxs(t.Box,{sx:i.merge({display:"flex",justifyContent:"flex-end",alignItems:"center"},a),children:[n&&G.jsx(t.Box,{sx:{height:16,flexBasis:16,flexGrow:0,flexShrink:0,mr:4},children:G.jsx(Nh,{width:16,height:16,address:n,chainId:e})}),G.jsxs(t.Box,{sx:{textAlign:"right",display:"flex",alignItems:"center"},children:[r," ",G.jsx(t.Box,{sx:{display:"inline-block",maxWidth:"6em",minWidth:"auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"},title:o,children:o})]})]})}function sA({chainId:e,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r,vertical:a}){const{isMobile:s}=Bp();return G.jsxs(t.Box,{sx:{mt:4,display:"flex",justifyContent:"flex-end",flexDirection:a?"column":"row",alignItems:a?"flex-end":"center",flexWrap:"wrap",typography:s?"h6":"body1"},children:[n?G.jsx(aA,{chainId:e,address:null==n?void 0:n.address,amount:o,symbol:null==n?void 0:n.symbol}):"-",a?"":G.jsx(t.Box,{sx:{mx:10},children:"/"}),i?G.jsx(aA,{chainId:e,address:null==i?void 0:i.address,amount:r,symbol:null==i?void 0:i.symbol,sx:{mt:a?4:0}}):"-"]})}function lA({label:e,children:n,pairsStatLoading:o,poolDetailLoading:r}){const{isMobile:a}=Bp();return G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(t.Box,{sx:{color:"text.secondary",minWidth:"5em",typography:a?"h6":"body1"},children:e}),G.jsx(t.Box,{sx:i.merge({textAlign:"right",overflow:"hidden","& .title":{typography:a?"body1":"caption",width:"100%"}},o&&!r||!o&&r?{ml:8,flex:1,display:"flex",flexDirection:"column",alignItems:"flex-end","& .title":{display:"flex",justifyContent:"flex-end"}}:{}),children:n})]})}function dA({sx:e}){return G.jsx(t.Skeleton,{sx:Object.assign({width:"100%",maxWidth:237,height:22},e)})}function cA({detail:e,lpFeeRate:n,mtFeeRate:i}){const{isMobile:r}=Bp();return"DPP"===(null==e?void 0:e.type)?null:e&&n&&i?G.jsxs(t.Box,{sx:{color:"text.secondary",typography:r?"h6":"body1"},children:[G.jsx("span",{children:"LP "}),G.jsx("span",{children:Vu({input:n,showDecimals:6})}),G.jsxs("span",{children:[" / ",o.i18n._({id:"7C/BwI",message:"Community Treasury"})," "]}),G.jsx("span",{children:Vu({input:new a(null!=i?i:0).toNumber(),showDecimals:6})})]}):G.jsx(dA,{sx:{mt:4}})}function uA({detail:e}){var n,i,r,s,l,c,u,p,h,m,g,x,f,y,v,b,C,j,w,k,T,B,I,S,A,E,O;const L=t.useTheme(),{isMobile:R}=Bp(),{baseToken:M,quoteToken:P}=null!=e?e:{},_="DPP"===(null==e?void 0:e.type),N="DSP"===(null==e?void 0:e.type)||"GSP"===(null==e?void 0:e.type),D="CLASSICAL"===(null==e?void 0:e.type),F=oA({address:null==e?void 0:e.address,chainId:null==e?void 0:e.chainId}),U=F.dashboard,q=F.isLoading,V=d.useQuery($u.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(n=null==e?void 0:e.baseToken)||void 0===n?void 0:n.decimals,null===(i=null==e?void 0:e.quoteToken)||void 0===i?void 0:i.decimals)),H=q?G.jsx(dA,{}):null===(null==U?void 0:U.totalVolume)||void 0===(null==U?void 0:U.totalVolume)?"-":`$${Su({input:new a(null==U?void 0:U.totalVolume),showDecimals:2})}`,W=q?G.jsx(dA,{}):U&&(fy(U.totalFee)||fy(U.totalMtFee))?`$${Su({input:new a(U.totalFee||0).plus(U.totalMtFee||0),showDecimals:2})}`:"-",{account:$}=cp(),z=d.useQuery($u.getFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,$)),Z=null===(r=z.data)||void 0===r?void 0:r.mtFeeRate,Q=null===(s=z.data)||void 0===s?void 0:s.lpFeeRate,Y=null==Z?void 0:Z.plus(null!=Q?Q:0),K=!e,X=d.useQuery($u.getClassicalTargetQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(l=null==e?void 0:e.baseToken)||void 0===l?void 0:l.decimals,null===(c=null==e?void 0:e.quoteToken)||void 0===c?void 0:c.decimals));return G.jsxs(t.Box,{sx:Object.assign({pb:30,position:"relative",overflow:"hidden"},R?{backgroundColor:"background.paper",p:20}:{mt:32}),children:[G.jsxs(t.Box,{sx:{flex:"1 0 50%","& > div + div":{mt:10},"&::after":{content:'""',display:"block",my:20,width:"100%",height:"1px",backgroundColor:"border.main"}},children:[G.jsx(lA,{label:o.i18n._({id:"l4Za6X",message:"Total Swap Volume"}),pairsStatLoading:q,children:G.jsx("div",{className:"title",children:H})}),q||!e?G.jsx(dA,{sx:{mt:4}}):G.jsx(sA,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:null!==(u=null==U?void 0:U.baseVolumeCumulative)&&void 0!==u?u:0,showDecimals:2}),quoteAmount:Su({input:null!==(p=null==U?void 0:U.quoteVolumeCumulative)&&void 0!==p?p:0,showDecimals:2})}),G.jsx(lA,{label:o.i18n._({id:"Z033WN",message:"Total Swap Fee"}),pairsStatLoading:q,children:G.jsx("div",{className:"title",children:W})}),q||!e?G.jsx(dA,{sx:{mt:4}}):G.jsx(sA,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:new a(null!==(h=null==U?void 0:U.baseFee)&&void 0!==h?h:0).plus(null!==(m=null==U?void 0:U.baseMtFee)&&void 0!==m?m:0),showDecimals:2}),quoteAmount:Su({input:new a(null!==(g=null==U?void 0:U.quoteFee)&&void 0!==g?g:0).plus(null!==(x=null==U?void 0:U.quoteMtFee)&&void 0!==x?x:0),showDecimals:2})}),G.jsx(lA,{label:o.i18n._({id:"/BbUJ6",message:"Total Number of Traders"}),pairsStatLoading:q,children:q?G.jsx(dA,{sx:{mt:4}}):Su({input:null!==(f=null==U?void 0:U.txUsers)&&void 0!==f?f:0,showDecimals:0})})]}),G.jsxs(t.Box,{sx:{flex:"1 0 50%",overflow:"hidden","& > div + div":{mt:10}},children:[G.jsx(lA,{label:o.i18n._({id:"UE2beD",message:"Creator"}),poolDetailLoading:!e,children:e?e.isCpPool?G.jsx(zf,{address:null!==(y=e.cpCreator)&&void 0!==y?y:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(zf,{address:null!==(v=e.creator)&&void 0!==v?v:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(dA,{})}),(null==e?void 0:e.isCpPool)||(null==e?void 0:e.owner)?G.jsx(lA,{label:o.i18n._({id:"LtI9AS",message:"Owner"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):(null==e?void 0:e.isCpPool)?G.jsx(zf,{address:null==e?void 0:e.cpCreator,truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}}):G.jsx(zf,{address:null!==(b=e.owner)&&void 0!==b?b:"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})}):"",G.jsx(lA,{label:o.i18n._({id:"52uNwk",message:"Creation Time"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):rA(1e3*Number((null==e?void 0:e.isCpPool)?e.cpCreatedAtTimestamp||0:e.createdAtTimestamp||0))||"-"}),(null==e?void 0:e.isCpPool)?G.jsxs(G.Fragment,{children:[G.jsx(lA,{label:o.i18n._({id:"cDWXuq",message:"Settler"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):G.jsx(zf,{address:(null==e?void 0:e.cpLiquidator)||"",truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})}),G.jsx(lA,{label:o.i18n._({id:"JuzN3b",message:"Related CrowdPooling"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):G.jsx(zf,{address:null==e?void 0:e.cpAddress,truncate:!0,"data-key":"link",sx:{color:L.palette.text.primary}})})]}):void 0,G.jsxs(lA,{label:o.i18n._({id:"Y7rVy0",message:"Fee Rate"}),poolDetailLoading:K,children:[G.jsx("div",{className:"detail-title",style:{textAlign:"right"},children:Vu({input:null==Y?void 0:Y.toNumber(),showDecimals:6})}),G.jsx(cA,{detail:e,lpFeeRate:Q,mtFeeRate:Z})]}),G.jsx(lA,{label:o.i18n._({id:"sjn3tj",message:"Slippage Coefficient"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):null===(j=null===(C=V.data)||void 0===C?void 0:C.pmmParamsBG)||void 0===j?void 0:j.k.toString()}),G.jsx(lA,{poolDetailLoading:K,label:D?o.i18n._({id:"d8YnVj",message:"Guide Price"}):_?o.i18n._({id:"CeLrge",message:"Mid Price"}):N?o.i18n._({id:"4ogEAw",message:"Pegged Exchange Rate"}):o.i18n._({id:"jjuKOj",message:"Min Price"}),children:K?G.jsx(dA,{}):null!==M&&(N?`1 ${null==M?void 0:M.symbol} = ${null===(T=null===(k=null===(w=V.data)||void 0===w?void 0:w.pmmParamsBG)||void 0===k?void 0:k.i)||void 0===T?void 0:T.toString()} ${null==P?void 0:P.symbol}`:null===(S=null===(I=null===(B=V.data)||void 0===B?void 0:B.pmmParamsBG)||void 0===I?void 0:I.i)||void 0===S?void 0:S.toString())||"-"}),D&&G.jsxs(G.Fragment,{children:[G.jsx(lA,{label:o.i18n._({id:"JR7wWw",message:"Equilibrium target"}),poolDetailLoading:K,children:K?G.jsx(dA,{}):G.jsx(G.Fragment,{children:null===(O=null===(E=null===(A=V.data)||void 0===A?void 0:A.pmmParamsBG)||void 0===E?void 0:E.k)||void 0===O?void 0:O.toString()})}),X.data?G.jsx(sA,{vertical:!0,chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Su({input:X.data.baseTarget,showDecimals:2}),quoteAmount:Su({input:X.data.quoteTarget,showDecimals:2})}):""]})]})]})}function pA(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function hA({amountOut:e,amountIn:i,fromTokenSymbol:o,toTokenSymbol:r}){const[a,s]=n.useState(!1),l=Su({input:i/e,showDecimals:2}),d=Su({input:e/i,showDecimals:2});return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:["1 ",a?r:o," = ",a?l:d," ",a?o:r,G.jsx(t.Box,{sx:{ml:10,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backgroundColor:"background.paperContrast",borderRadius:"50%"},onClick:()=>s((e=>!e)),children:G.jsx(t.Box,{component:se.Switch})})]})}function mA({poolDetail:i}){var o,s,l;const{isMobile:c}=Bp(),u=t.useTheme(),{account:p,chainId:h}=cp(),m=d.useQuery($u.getFeeRateQuery(null==i?void 0:i.chainId,null==i?void 0:i.address,null==i?void 0:i.type,p)),g=null===(o=m.data)||void 0===o?void 0:o.mtFeeRate,x=null===(s=m.data)||void 0===s?void 0:s.lpFeeRate,f=null==g?void 0:g.plus(null!=x?x:0),y=function({chainId:e,address:t,first:n=50}){var i;const o=e?Hl[e]:"",a=xp().getQuery(r.PoolApi.graphql.fetchPoolSwapList,{first:n,orderBy:"timestamp",orderDirection:"desc",where:{pair:t,chain:o}}),s=d.useQuery(Object.assign(Object.assign({},a),{enabled:!!t})),l=null===(i=s.data)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},s),{swapList:l})}({address:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),[v,b]=n.useState(1),C=v*(c?4:8),j=null!==(l=y.swapList)&&void 0!==l?l:[],w=C<j.length,k=j.slice(0,C);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:y.error?y.refetch:void 0,loading:y.isLoading,empty:!(null==k?void 0:k.length),children:!!(null==k?void 0:k.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"UPXmW+",message:"Trader"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"v4nCHK",message:"Paid"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"fZ5Vnu",message:"Received"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"a7u1N9",message:"Price"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"Y7rVy0",message:"Fee Rate"})}),G.jsx(t.Box,{component:"th",sx:{"&&":{textAlign:"right"}},children:G.jsx(e.Trans,{id:"PLUB/s",message:"Fee"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==k?void 0:k.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:pA(1e3*e.timestamp)}),G.jsx("td",{children:G.jsx(zf,{address:e.from,truncate:!0})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.fromToken.id,chainId:h,width:18,height:18}),`${Su({input:e.amountIn,showDecimals:2})} ${e.fromToken.symbol}`]})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.toToken.id,chainId:h,width:18,height:18}),`${Su({input:e.amountOut,showDecimals:2})} ${e.toToken.symbol}`]})}),G.jsx("td",{children:G.jsx(hA,{amountOut:e.amountOut,amountIn:e.amountIn,fromTokenSymbol:e.fromToken.symbol,toTokenSymbol:e.toToken.symbol})}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:Vu({input:f})}),G.jsx(t.Box,{component:"td",sx:{textAlign:"right"},children:`${Su({input:new a(e.amountOut).times(null!=f?f:0)})} ${e.toToken.symbol}`})]},e.id)))})]})}),w&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:u.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>b((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function gA({poolDetail:e}){const{isMobile:i}=Bp(),[r,a]=n.useState(eA.parameters),s=[{key:eA.parameters,value:o.i18n._({id:"F18WP3",message:"Parameters"})},{key:eA.swaps,value:o.i18n._({id:"EatqP4",message:"Swaps"})}];return e&&"DPP"!==(null==e?void 0:e.type)&&s.push({key:eA.liquidityProviders,value:o.i18n._({id:"juypHV",message:"Liquidity Providers"})}),G.jsx(t.Box,{sx:Object.assign({mt:24,backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},i?{}:{mt:32,px:20}),children:G.jsxs(t.Tabs,{value:r,onChange:(e,t)=>a(t),children:[G.jsx(t.TabsGroup,{tabs:s}),G.jsx(t.TabPanel,{value:eA.parameters,children:G.jsx(uA,{detail:e})}),G.jsx(t.TabPanel,{value:eA.swaps,children:G.jsx(mA,{poolDetail:e})}),G.jsx(t.TabPanel,{value:eA.liquidityProviders,children:G.jsx(iA,{poolDetail:e})})]})})}function xA(){return G.jsx(t.Skeleton,{variant:"rounded",sx:{width:90}})}function fA({poolDetail:n}){var i,r;const s=t.useTheme(),{isMobile:l}=Bp(),d=oA({address:null==n?void 0:n.address,chainId:null==n?void 0:n.chainId}),c=d.dashboard,u=[{description:o.i18n._({id:"Gr2anW",message:"Traders (24H)"}),text:d.isLoading?G.jsx(xA,{}):null===(null==c?void 0:c.txUserNear24h)||void 0===(null==c?void 0:c.txUserNear24h)?"-":Uu(new a(null==c?void 0:c.txUserNear24h))},{description:o.i18n._({id:"sTnImq",message:"Total Liquidity"}),text:d.isLoading?G.jsx(xA,{}):null===(null==c?void 0:c.tvl)||void 0===(null==c?void 0:c.tvl)?"-":`$${Uu(new a(null==c?void 0:c.tvl))}`},{description:o.i18n._({id:"p7/w10",message:"Volume (24H)"}),text:d.isLoading?G.jsx(xA,{}):null===(null==c?void 0:c.volume)||void 0===(null==c?void 0:c.volume)?"-":`$${Uu(new a(null==c?void 0:c.volume))}`},{description:o.i18n._({id:"7X40pG",message:"Fees (24H)"}),text:d.isLoading?G.jsx(xA,{}):null!==!(null==c?void 0:c.feeNear24h)||(null==c?void 0:c.mtFeeNear24h)?`$${Uu(new a(null!==(i=null==c?void 0:c.feeNear24h)&&void 0!==i?i:0).plus(null!==(r=null==c?void 0:c.mtFeeNear24h)&&void 0!==r?r:0))}`:"-",question:d.isLoading?void 0:G.jsxs(t.Box,{sx:{width:198},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"}),G.jsx(t.Box,{children:(null==c?void 0:c.feeNear24h)?`$${Uu(new a(null==c?void 0:c.feeNear24h))}`:"-"})]}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"}),G.jsx(t.Box,{children:(null==c?void 0:c.mtFeeNear24h)?`$${Uu(new a(null==c?void 0:c.mtFeeNear24h))}`:"-"})]})]})}];return G.jsx(t.Box,{sx:Object.assign({display:"grid",gap:12},l?{mt:24,gridTemplateColumns:"repeat(2, 1fr)"}:{mt:32,gridTemplateColumns:"repeat(4, 1fr)"}),children:u.map((e=>G.jsxs(t.Box,{sx:{borderRadius:8,p:16,backgroundColor:"background.paper",border:`1px solid ${s.palette.border.main}`},children:[G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,lineHeight:"27px"},children:e.text}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary",gap:4},children:[e.description,e.question?G.jsx(lf,{title:e.question}):""]})]},e.description)))})}function yA({poolDetail:n,loading:i}){var a,s,l,d;const{address:c}=null!=n?n:{},u=t.useTheme(),p=zy(),{account:h}=cp(),{isMobile:m}=Bp(),g=h&&"DPP"===(null==n?void 0:n.type)&&(null===(a=null==n?void 0:n.owner)||void 0===a?void 0:a.toLocaleLowerCase())===h.toLocaleLowerCase(),{supportAMMV2:x,onSharePool:f}=X();return G.jsxs(t.Box,{sx:Object.assign({},m?{pt:24}:{pt:20,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==n?void 0:n.baseToken)?G.jsx(wy,{tokens:[n.baseToken,n.quoteToken],chainId:n.chainId,width:36,mr:8}):G.jsx(t.Skeleton,{variant:"circular",sx:{width:36,height:36,mr:8}}),G.jsxs(t.Box,{children:[G.jsxs(t.Box,{sx:{typography:"h4"},children:[(null==n?void 0:n.baseToken)?`${null===(s=n.baseToken)||void 0===s?void 0:s.symbol} / ${null===(l=n.quoteToken)||void 0===l?void 0:l.symbol}`:"-",x&&G.jsx(t.Box,{component:"span",sx:{position:"relative",top:-4,ml:4,px:4,py:2,borderRadius:4,fontSize:10,lineHeight:1,fontWeight:600,backgroundColor:t.alpha(u.palette.purple.main,.1),color:u.palette.purple.main},children:"PMM"}),G.jsx(gk,{address:c,chainId:null==n?void 0:n.chainId,hideName:m,sx:{display:"inline-flex",ml:8}}),g&&!m?G.jsx(t.Box,{component:t.ButtonBase,sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderRadius:4,borderColor:"primary.main",color:"primary.main",whiteSpace:"nowrap","&:hover":{backgroundColor:"primary.main",color:"primary.contrastText"}},onClick:()=>{p.push({type:exports.PageType.ModifyPool,params:{address:null==n?void 0:n.address,chainId:null==n?void 0:n.chainId}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):""]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",mr:12},children:G.jsx(zf,{address:null!=c?c:"",truncate:!0,showCopy:!0,iconDarkHover:!0,"data-key":"link",sx:{typography:"body2",color:"text.secondary"},iconSize:14,iconSpace:6,customChainId:null==n?void 0:n.chainId,onShareClick:f&&n?()=>f({chainId:n.chainId,baseToken:n.baseToken,quoteToken:n.quoteToken,poolId:c,apy:n.apy,isSingle:r.PoolApi.utils.singleSideLp(n.type)}):void 0})})]})]}),G.jsxs(t.Box,{sx:m?{display:"flex",alignItems:"center",mt:24}:{textAlign:"right"},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",color:"success.main",typography:"h4"},children:[(null==n?void 0:n.miningAddress)?G.jsx(t.Tooltip,{title:o.i18n._({id:"B3mhDR",message:"Add liquidity to obtain LP tokens for mining"}),children:G.jsx("span",{children:"✨ "})}):"",G.jsx(t.LoadingSkeleton,{loading:i,loadingSx:{width:100},children:null!==(d=null==n?void 0:n.baseApy)&&void 0!==d?d:"0%"}),(null==n?void 0:n.quoteApy)?`/${null==n?void 0:n.quoteApy}`:""]}),G.jsx(t.Box,{sx:Object.assign({typography:"body2"},m?{ml:4}:{}),children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]})}function vA({chainId:e,shortNumber:n,pieSize:i="default",baseReserve:o=new a(1),baseAmount:r=new a(1),quoteAmount:s=new a(0),baseTokenSymbol:l="-",quoteTokenSymbol:d="-",quoteTokenDecimals:c=18,baseTokenDecimals:u=18,baseTokenAddress:p,quoteTokenAddress:h,baseTvlRate:m,quoteTvlRate:g,disabledAmount:x,disabledRate:f,disabledPercentage:y,loading:v,sx:b,pieRadius:C}){const j=t.useTheme(),w="small"===i,k=w?6:16,T=C||(w?23:30),B=u>6?6:u>4?4:2,I=c>6?6:c>4?4:2,A=n?Uu(new a(o)):Su({input:o,showDecimals:B}),E=n?Uu(new a(s)):Su({input:s,showDecimals:I});let O=r.plus(s);O=O.lte(0)?new a(1):O;const L=m||r.div(O).multipliedBy(100).toFixed(2),R=g||s.div(O).multipliedBy(100).toFixed(2),M=r.lte(0)&&s.lte(0),P=j.palette.success.main,_=j.palette.error.main,N=[{name:"base",value:M?1:r.toNumber(),color:P},{name:"quote",value:M?1:s.toNumber(),color:_}];return G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",flexDirection:"column"},b||{}),children:[G.jsx("div",{children:y?"":v?G.jsx(t.Skeleton,{width:46,height:46,variant:"circular"}):G.jsx(S.PieChart,{width:2*T,height:2*T,children:G.jsx(S.Pie,{isAnimationActive:!1,dataKey:"value",data:N,labelLine:!1,label:!1,outerRadius:T,fill:_,children:N.map(((e,t)=>G.jsx(S.Cell,{fill:e.color,strokeWidth:0},`cell-${t}`)))})})}),G.jsxs(t.Box,{className:"symbol-wrapper",sx:{display:"flex",flexDirection:"column",justifyContent:"center",ml:0,mt:16,width:"100%","& > div":{paddingLeft:"12px",position:"relative","&::before":{content:'""',width:"8px",height:"8px",position:"absolute",left:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:j.palette.purple.main,borderRadius:"50%"},"&:last-child::before":{backgroundColor:_},"&> span.symbol":{display:"inline-block",maxWidth:"6em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"}}},children:[v?G.jsx(t.Skeleton,{width:237,sx:{borderRadius:4}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{className:"symbol",title:l,sx:{typography:"h6"},children:l}),p?G.jsx(zf,{address:p,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[x?"":`${A} `,y||f?"":G.jsxs(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${L}%)`]})]})]}),v?G.jsx(t.Skeleton,{width:237,sx:{borderRadius:4,marginTop:`${k}px`}}):G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:`${k}px`},children:[G.jsxs(t.Box,{children:[G.jsx(t.Box,{className:"symbol",title:d,sx:{typography:"h6"},children:d}),h?G.jsx(zf,{address:h,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),G.jsxs(t.Box,{sx:{textAlign:"right"},children:[x?"":`${E} `,y||f?"":G.jsxs(t.Box,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${R}%)`]})]})]})]})]})}function bA({poolDetail:n}){var i,o,r,s,l,c,u,p,h;const m=t.useTheme(),{isMobile:g}=Bp(),x=d.useQuery($u.getPMMStateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(i=null==n?void 0:n.baseToken)||void 0===i?void 0:i.decimals,null===(o=null==n?void 0:n.quoteToken)||void 0===o?void 0:o.decimals)),f=null===(r=x.data)||void 0===r?void 0:r.midPrice,y=d.useQuery($u.getReserveLpQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(s=null==n?void 0:n.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==n?void 0:n.quoteToken)||void 0===l?void 0:l.decimals)),{baseReserve:v,quoteReserve:b}=y.data||{},C=v&&f?null==f?void 0:f.multipliedBy(v):void 0,j=b&&f?new a(b):void 0;let w=C&&j?null==C?void 0:C.plus(j):void 0;w=!w||w.lte(0)?new a(1):w;const k=C&&C.div(w).multipliedBy(100).toFixed(2),T=j&&j.div(w).multipliedBy(100).toFixed(2);return G.jsxs(t.Box,{sx:{mt:g?24:28},children:[G.jsx(t.Box,{sx:{fontWeight:600},children:G.jsx(e.Trans,{id:"sTnImq",message:"Total Liquidity"})}),G.jsxs(t.Box,{sx:{display:"flex",mt:16,backgroundColor:"background.paper",borderRadius:16,overflowX:"auto",border:`1px solid ${m.palette.border.main}`},children:[G.jsx(t.Box,{sx:{flex:g?1:void 0,padding:g?m.spacing(20,30,20,20):m.spacing(20,30,16)},children:G.jsx(vA,{pieRadius:44,baseReserve:v,baseAmount:C,baseTokenDecimals:null===(c=null==n?void 0:n.baseToken)||void 0===c?void 0:c.decimals,quoteAmount:j,baseTvlRate:k,quoteTvlRate:T,chainId:null==n?void 0:n.chainId,quoteTokenDecimals:(null===(u=null==n?void 0:n.quoteToken)||void 0===u?void 0:u.decimals)||void 0,baseTokenSymbol:Wu(null==n?void 0:n.baseToken),quoteTokenSymbol:Wu(null==n?void 0:n.quoteToken),baseTokenAddress:g?null===(p=null==n?void 0:n.baseToken)||void 0===p?void 0:p.address:"",quoteTokenAddress:g?null===(h=null==n?void 0:n.quoteToken)||void 0===h?void 0:h.address:"",shortNumber:!0,disabledRate:!g,disabledAmount:!g,loading:x.isLoading||y.isLoading,sx:g?{typography:"body2",fontWeight:600}:{"& .symbol-wrapper":{display:"flex",alignItems:"center",flexDirection:"row","& > div, & > span":{mt:0,"&:last-child":{ml:16}},"& .MuiSkeleton-root":{width:"40px !important"}}}})}),g?"":G.jsxs(t.Box,{component:"table",sx:{flex:1,fontWeight:600,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 0 1px","& thead":{typography:"h6",color:"text.secondary","& th":{textAlign:"right",px:20,py:16,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 1px","&:first-child":{textAlign:"left"}}},"& tbody":{typography:"body2",textAlign:"right","& td":{px:20,py:0,"&:first-child":{textAlign:"left"}}}},children:[G.jsx("thead",{children:G.jsxs("tr",{children:[G.jsx("th",{children:G.jsx(e.Trans,{id:"bUUVED",message:"Asset"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"hcNa1G",message:"Token Amount"})}),G.jsx("th",{children:G.jsx(e.Trans,{id:"iaocTt",message:"Ratio"})})]})}),G.jsxs("tbody",{children:[G.jsxs("tr",{children:[G.jsx("td",{children:n?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:n.baseToken.address,width:24,height:24,marginRight:4,chainId:n.chainId}),G.jsxs(t.Box,{children:[n.baseToken.symbol,G.jsx(zf,{address:n.baseToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:n.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):G.jsx(t.Skeleton,{width:100,height:24})}),G.jsx("td",{children:n?Uu(new a(n.baseReserve)):G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}})}),G.jsx("td",{children:x.isLoading?G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=k?k:"-"}%`})]}),G.jsxs("tr",{children:[G.jsx("td",{children:n?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{address:n.quoteToken.address,width:24,height:24,marginRight:4,chainId:n.chainId}),G.jsxs(t.Box,{children:[n.quoteToken.symbol,G.jsx(zf,{address:n.quoteToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:n.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):G.jsx(t.Skeleton,{width:100,height:24})}),G.jsx("td",{children:n?Uu(new a(n.quoteReserve)):G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}})}),G.jsx("td",{children:x.isLoading?G.jsx(t.Skeleton,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=T?T:"-"}%`})]})]})]})]})]})}function CA({params:i}){var r,a,s,l,d,c,u;const p=zy(),{isMobile:h}=Bp(),{account:m}=cp(),g=t.useTheme(),x=$S({id:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{poolDetail:f}=x,y=U(x,["poolDetail"]),[v,b]=n.useState("inital");y.isPending||y.error||f||"inital"!==v||b("open");const C=f&&"DPP"===f.type&&m&&(null===(r=f.owner)||void 0===r?void 0:r.toLocaleLowerCase())===m.toLocaleLowerCase(),j=f&&"DPP"!==f.type||m&&(null==f?void 0:f.owner)&&f.owner.toLocaleLowerCase()===m.toLocaleLowerCase(),[w,k]=n.useState();f&&void 0===w&&!h&&k(Qj.Add);const T=w&&f?Object.assign(Object.assign({},f),{baseLpToken:{id:null===(a=f.baseLpToken)||void 0===a?void 0:a.id,decimals:Number(null!==(l=null===(s=f.baseLpToken)||void 0===s?void 0:s.decimals)&&void 0!==l?l:18)},quoteLpToken:{id:null===(d=f.quoteLpToken)||void 0===d?void 0:d.id,decimals:Number(null!==(u=null===(c=f.quoteLpToken)||void 0===c?void 0:c.decimals)&&void 0!==u?u:18)}}):void 0,B=!!(null==f?void 0:f.miningAddress);return G.jsxs(Wy,{sx:h?{p:g.spacing(28,0,j?108:0)}:{p:g.spacing(28,0,40)},children:[G.jsx(HS,{onClick:()=>{p.push({type:exports.PageType.Pool})}}),G.jsxs(t.Box,{sx:h?{}:{display:"flex",gap:12,overflow:"hidden"},children:[G.jsxs(t.Box,{sx:{flex:1,overflow:"hidden"},children:[G.jsx(yA,{poolDetail:f,loading:y.isPending}),G.jsx(tA,{poolDetail:f,chart24hDataFirst:!0}),G.jsx(fA,{poolDetail:f}),G.jsx(bA,{poolDetail:f}),G.jsx(gA,{poolDetail:f})]}),h?G.jsx(mk,{account:m,pool:T,operate:w,hasMining:B,modal:!0,onClose:()=>{k(void 0)}}):G.jsx(hk,{account:m,operate:w,hasMining:B,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},pool:T,hidePoolInfo:!0})]}),G.jsx(VS,{singleBtn:!0,open:"open"===v,onClose:()=>b("close"),onConfirm:()=>b("close"),title:o.i18n._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),h&&j&&G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:C?"repeat(3, 1fr)":"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[C?G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{zy.getState().push({type:exports.PageType.ModifyPool,params:{chainId:f.chainId,address:f.address}})},children:G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})}):"",G.jsx(t.Button,{variant:t.Button.Variant.second,onClick:()=>{k(Qj.Remove)},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{onClick:()=>{k(Qj.Add)},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})})]})}function jA({statuses:n,children:i,buttonProps:o}){var r;if(!n.find((e=>e.needShowTokenStatusButton))&&i)return G.jsx(G.Fragment,{children:i});const a=n.find((e=>e.insufficientBalance));if(a)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,...o,children:G.jsx(e.Trans,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const s=n.some((e=>e.isApproving));return G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:n.map(((n,i)=>{var r,a;let l="";return n.isApproving?l=G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):(n.needReset||n.needApprove)&&(l=n.approveTitle),l?G.jsx(t.Button,{fullWidth:!0,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance||s,...o,children:l},null!==(a=null===(r=n.token)||void 0===r?void 0:r.symbol)&&void 0!==a?a:i):null}))})}function wA({token:i,chainId:o,showChainLogo:r,readonly:a,showChainName:s,logoSize:l=24,chainLogoSize:d=12,side:c,occupiedToken:u,defaultLoadBalance:p,notTokenPickerModal:h,border:m,px:g=20,py:x=8,highlightDefault:f,onTokenClick:y,onTokenChange:v}){var b,C;const{onlyChainId:j}=X(),w=o||j,k=t.useTheme(),[T,B]=n.useState(!1),I=(null==i?void 0:i.chainId)?ac.get(i.chainId):null,S=s&&!!I;return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:k.palette.text.primary,typography:S?"body2":"body1",fontWeight:600,px:g,py:x,"&:focus-visible":{opacity:.5}},!!m&&{border:`solid 1px ${k.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:k.palette.hover.default}}),!(!f||i)&&{backgroundColor:k.palette.primary.main,color:k.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{a||B(!0)},"data-testid":jc,children:[!!(null==i?void 0:i.address)&&G.jsx(Nh,{url:null==i?void 0:i.logoURI,address:null!==(b=null==i?void 0:i.address)&&void 0!==b?b:"",chainId:null==i?void 0:i.chainId,noShowChain:!r,width:l,height:l,chainSize:d,logoOffset:10,marginRight:0}),G.jsxs(t.Box,{sx:{flex:1},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==i?void 0:i.address)?G.jsx(G.Fragment,{children:G.jsx(t.Box,{children:null!==(C=null==i?void 0:i.symbol)&&void 0!==C?C:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!a&&G.jsx(t.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"})})]}),!!S&&G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[I.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]}),G.jsx(Xf,{value:i,open:T,side:c,chainId:w,occupiedAddrs:u?[u.address]:void 0,occupiedChainId:null==u?void 0:u.chainId,defaultLoadBalance:p,onClose:()=>{B(!1),y&&y()},onTokenChange:(e,t)=>{B(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),Ih)},modal:!h})]})}function kA({title:e,disabled:n,children:i}){return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:n?.3:void 0},children:[G.jsx(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),i]})}!function(e){e[e.depth=1]="depth",e[e.volume=2]="volume",e[e.feeRevenue=3]="feeRevenue",e[e.traders=4]="traders"}(JS||(JS={})),function(e){e[e.parameters=1]="parameters",e[e.swaps=2]="swaps",e[e.liquidityProviders=3]="liquidityProviders"}(eA||(eA={}));const TA=1e-4;function BA({disabled:i,fee:o,onChange:r,feeList:s,hasCustom:l}){const d=t.useTheme(),[c,u]=n.useState(!1),[p,h]=n.useState(!1),[m,g]=n.useState(""),{isMobile:x}=Bp(),f=!s.includes(o),y=f||p,v=!p&&f&&!!m&&new a(m).div(100).lt(TA),b=i||v;return G.jsxs(t.Box,{sx:{opacity:i?.3:void 0,fontWeight:600},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main"},children:[G.jsx(e.Trans,{id:"tMMG40",message:"{0}% fee tier",values:{0:o?new a(o).times(100).toString():"-"}}),G.jsx(t.ButtonBase,{sx:{px:16,py:7,border:`solid 1px ${d.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:b?"default":"pointer",opacity:v?.3:1},disabled:b,onClick:()=>{b||u((e=>!e))},children:c?G.jsx(e.Trans,{id:"vLyv1R",message:"Hide"}):G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]}),c&&G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({mt:12},x?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:[s.map((e=>{const n=o===e&&!y;return G.jsxs(t.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer"},n&&{color:d.palette.primary.main,borderColor:d.palette.primary.main}),children:[100*e,"%",G.jsx(t.Radio,{size:18,checked:n,onChange:(t,n)=>{n&&r(e)}})]},e)})),l&&G.jsxs(t.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer",color:v?d.palette.error.main:"text.primary"},y&&{color:d.palette.primary.main,borderColor:d.palette.primary.main}),onClick:()=>{h(!0),g("")},children:[p?G.jsx(t.Input,{value:m,autoFocus:!0,onChange:e=>{const t=e.target.value;isNaN(Number(t))||g(t)},onBlur:()=>{const e=Number(m),t=e?new a(e).div(100).toNumber():e;t&&t<TA?r(0):m&&(e||0===e)&&r(t),h(!1)},sx:{p:0,flex:1,height:"100%",border:"none",backgroundColor:"none"},inputSx:{p:0}}):G.jsx(G.Fragment,{children:f?(new a(o).times(100).toNumber()||m)+"%":G.jsx(e.Trans,{id:"8Tg/JR",message:"Custom"})}),G.jsx(t.Radio,{size:18,checked:y,sx:{flexShrink:0}})]})]}),v&&G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,typography:"h6",backgroundColor:t.alpha(d.palette.error.main,.1),color:d.palette.error.main},children:[G.jsx(t.Box,{component:se.ErrorBorder,sx:{width:18,height:18}}),G.jsx(e.Trans,{id:"LHxwaD",message:"The fee tier should greater than {0}%",values:{0:100*TA}})]})]})]})}function IA({isExists:i,pair:o,pairAddress:r}){var s,l,c;const{isBalanceLoading:p,isDepositedLoading:h,balance:m,token0Deposited:g,token1Deposited:x,poolTokenPercentage:f}=function({pairAddress:e,pair:t}){var i;const{account:o}=cp(),r=null===(i=null==t?void 0:t.liquidityToken)||void 0===i?void 0:i.chainId,s=d.useQuery(Object.assign(Object.assign({},u.getFetchUniswapV2PairBalanceOfQueryOptions(r,e,o)),{retry:!1})),l=d.useQuery(Object.assign(Object.assign({},u.getFetchUniswapV2PairTotalSupplyQueryOptions(r,e)),{retry:!1})),[c,p,h]=n.useMemo((()=>{if(!t||!s.data||!l.data||l.data<s.data)return[void 0,void 0,void 0];const e=M.CurrencyAmount.fromRawAmount(t.liquidityToken,l.data.toString()),n=M.CurrencyAmount.fromRawAmount(t.liquidityToken,s.data.toString());return[new M.Percent(s.data.toString(),l.data.toString()),t.getLiquidityValue(t.token0,e,n,!1),t.getLiquidityValue(t.token1,e,n,!1)]}),[s.data,l.data,t]);return{isBalanceLoading:s.isLoading,isDepositedLoading:s.isLoading||l.isLoading,balance:s.data&&t?Mu(s.data.toString(),t.liquidityToken.decimals):void 0,poolTokenPercentage:c?new a(c.toSignificant(6)):void 0,token0Deposited:p?new a(p.toSignificant()):void 0,token1Deposited:h?new a(h.toSignificant()):void 0}}({pairAddress:r,pair:o}),y=f?`${Su({input:f,showDecimals:2,roundingMode:a.ROUND_HALF_UP})}%`:void 0;return i&&o?G.jsxs(t.Box,{sx:{px:20,py:12,borderWidth:1,borderRadius:8,borderStyle:"solid",borderColor:"border.main"},children:[G.jsx(t.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(t.Box,{sx:{mt:12,display:"flex",alignItems:"center"},children:[G.jsx(wy,{width:18,height:18,tokens:[o.token0,o.token1],mr:4}),G.jsx(t.LoadingSkeleton,{loading:p,loadingProps:{width:50},sx:{mr:4},children:Au({input:m,decimals:null===(s=o.liquidityToken)||void 0===s?void 0:s.decimals})}),`${o.token0.symbol}/${o.token1.symbol} LP`,G.jsx(t.Tooltip,{title:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[G.jsx(vw,{address:o.token0.address,chainId:o.token0.chainId,showName:null!==(l=o.token0.symbol)&&void 0!==l?l:"",size:14,offset:4,rightContent:G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:Au({input:g,decimals:o.token0.decimals})})}),G.jsx(vw,{address:o.token1.address,chainId:o.token1.chainId,showName:null!==(c=o.token1.symbol)&&void 0!==c?c:"",size:14,offset:4,rightContent:G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:Au({input:x,decimals:o.token1.decimals})})}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"c4miqE",message:"Pool share"}),G.jsx(t.LoadingSkeleton,{loading:h,loadingProps:{width:50},children:y})]})]}),sx:{padding:20,width:256},children:G.jsx(t.HoverOpacity,{component:se.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),G.jsx(t.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:np(o.liquidityToken.chainId,o.liquidityToken.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:G.jsx(t.HoverOpacity,{component:se.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function SA({sx:i,disabled:o,slippage:r,onChangeSlippage:s}){const l=t.useTheme(),d=r===Ky,[c,u]=n.useState(d?"":new a(r).times(100).toNumber());return G.jsx(t.Tooltip,{disabled:o,onlyClick:!0,title:G.jsxs(t.Box,{sx:{backgroundColor:l.palette.background.paper,padding:l.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[d?Jy:r&&new a(r).times(100).toNumber(),"%"]})]}),G.jsxs(t.Box,{sx:{mt:16,display:"flex",alignItems:"center",margin:l.spacing(16,0,0,0)},children:[G.jsx(Yy,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),s(Ky)},active:d}),G.jsx(t.Input,{placeholder:String(Jy),value:c,onChange:e=>{const{value:t}=e.target;u(t),s(t?new a(t).div(100).toNumber():Ky)},onBlur:()=>{(!d&&new a(r).gt(.1)||new a(r).lte(0))&&(u(10),s(.1))},suffix:G.jsx(t.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(t.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:l.spacing(0,0,0,"auto"),p:l.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast",cursor:"pointer"},i),children:G.jsx(t.Box,{component:se.Setting,sx:{width:18,height:18,"& path:last-child":{fill:l.palette.text.primary}}})})})}function AA(){var i,o,s;const l=t.useTheme(),[d,c]=n.useState(.003),[p,h]=n.useState(),[m,g]=n.useState(),[x,f]=n.useState(""),[y,v]=n.useState(""),[b,C]=n.useState(Ky),j=b===Ky?new a(Jy).div(100).toNumber():b,{isMobile:w}=Bp(),{onlyChainId:k}=X(),T=n.useMemo((()=>k||(null==p?void 0:p.chainId)||(null==m?void 0:m.chainId)),[k,p,m]),{pairAddress:B,pair:I,price:S,isInvalidPair:A,invertedPrice:E,priceLoading:O,liquidityMinted:L,shareOfPool:R,isExists:P}=function({baseToken:e,quoteToken:t,baseAmount:i,quoteAmount:o,fee:a}){const[s,l,d]=n.useMemo((()=>{var n,i;if(!e||!t)return[null,null,!1];const o=r.basicTokenMap[e.chainId],a=(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())===e.address.toLowerCase(),s=(null===(i=o.address)||void 0===i?void 0:i.toLowerCase())===t.address.toLowerCase(),l=a?o.wrappedTokenAddress:e.address,d=s?o.wrappedTokenAddress:t.address,c=l.toLowerCase()===d.toLowerCase();return c?[null,null,!0]:[new M.Token(e.chainId,l,e.decimals,e.symbol,e.name),new M.Token(t.chainId,d,t.decimals,t.symbol,t.name),c]}),[e,t]),c=n.useMemo((()=>{if(!s||!l||void 0===a)return;const e=s.chainId,t=e?u.getUniswapV2FactoryContractAddressByChainId(e)||u.getUniswapV2FactoryFixedFeeContractAddressByChainId(e):void 0;return t?ip({factoryAddress:t,tokenA:s,tokenB:l,fee:a}):void 0}),[s,l,a]),{pair:p,price:h,invertedPrice:m,reserveQuery:g,liquidityMinted:x,shareOfPool:f,isExists:y}=tk({pool:e&&t&&c?{baseToken:e,quoteToken:t,type:"AMMV2",address:c}:void 0,baseAmount:i,quoteAmount:o});return{pairAddress:c,pair:p,isInvalidPair:d,price:h,invertedPrice:m,priceLoading:g.isLoading,liquidityMinted:x,shareOfPool:f,isExists:y}}({baseToken:p,quoteToken:m,baseAmount:x,quoteAmount:y,fee:d}),_=Cv(S);if(S&&x&&!S.isEqualTo(null!=_?_:0)&&P){const e=S.times(x).dp(null!==(i=null==m?void 0:m.decimals)&&void 0!==i?i:18);e.isEqualTo(y)||v(e.toString())}const N=T?u.getUniswapV2Router02ContractAddressByChainId(T)||u.getUniswapV2Router02FixedFeeContractAddressByChainId(T):void 0,D=lh(p,{amount:x,contractAddress:N}),F=lh(m,{amount:y,contractAddress:N}),[U,q]=n.useState(!1),V=!p||!m,H=Gw({baseToken:p,quoteToken:m,baseAmount:x,quoteAmount:y,fee:d,isExists:P,slippage:j,successBack:()=>{zy.getState().push({type:exports.PageType.Pool,params:{tab:qk.myLiquidity}})}});return n.useEffect((()=>{console.error("createMutation.error",H.error)}),[H.error]),G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[l.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[G.jsx(Xk,{onClick:()=>{zy.getState().push({type:exports.PageType.Pool})}}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})}),G.jsx(lj,{poolType:"AMM V2"})]}),G.jsxs(t.Box,{sx:{pt:20,px:16,position:"relative",overflow:"hidden",backgroundColor:l.palette.background.paper,borderRadius:16,[l.breakpoints.up("tablet")]:{borderWidth:1,borderStyle:"solid",borderColor:"border.main",px:0,mx:"auto",width:600}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:20,[l.breakpoints.up("tablet")]:{pt:20,px:20,pb:20}},children:[G.jsx(IA,{pair:I,pairAddress:B,isExists:P}),G.jsxs(kA,{title:G.jsx(e.Trans,{id:"nxRg31",message:"Select pair"}),children:[G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:w?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[G.jsx(wA,{border:!0,highlightDefault:!0,chainId:T,token:p,onTokenChange:(e,t)=>{t?(h(m),g(p),f(""),v("")):(h(e),f(""))},occupiedToken:m}),G.jsx(wA,{border:!0,highlightDefault:!0,chainId:T,token:m,onTokenChange:(e,t)=>{t?(h(m),g(p)):(g(e),v(""))},occupiedToken:p})]}),(!T||Ku(T))&&G.jsx(BA,{fee:d,onChange:c,feeList:[1e-4,5e-4,.003],hasCustom:!0,disabled:V})]}),G.jsx(kA,{title:G.jsx(e.Trans,{id:"MU9s7M",message:"Deposit amounts"}),disabled:V,children:G.jsxs(t.Box,{children:[G.jsx(py,{sx:{mb:4,pb:28,minHeight:"auto",backgroundColor:"background.cardInput",padding:l.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},token:p,amt:x,defaultLoadBalance:!0,onInputChange:e=>{var t;f(e);const n=Number(e);P&&S&&n&&v(S.times(e).dp(null!==(t=null==m?void 0:m.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(o=null==m?void 0:m.address)&&void 0!==o?o:""],occupiedChainId:null==m?void 0:m.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:V}),G.jsx(cy,{}),G.jsx(py,{sx:{pb:20,minHeight:"auto",backgroundColor:"background.cardInput",padding:l.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},token:m,amt:y,defaultLoadBalance:!0,onInputChange:e=>{var t;v(e);const n=Number(e);P&&E&&n&&f(E.times(e).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(s=null==p?void 0:p.address)&&void 0!==s?s:""],occupiedChainId:null==p?void 0:p.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:V}),G.jsx(SA,{slippage:b,onChangeSlippage:C,disabled:V,sx:{mt:8}}),G.jsx(Vw,{baseToken:p,quoteToken:m,loading:O,midPrice:S,shareOfPool:R}),!!P&&G.jsxs(t.Box,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vu({input:d})},components:{0:G.jsx("b",{})}})]})]})})]}),G.jsx(t.Box,{sx:{mt:20,py:16,[l.breakpoints.up("tablet")]:{px:20}},children:G.jsx(lv,{fullWidth:!0,includeButton:!0,size:t.Button.Size.big,disabled:V,chainId:T,children:G.jsx(jA,{statuses:[D,F],buttonProps:{size:t.Button.Size.big},children:G.jsx(t.Button,{fullWidth:!0,size:t.Button.Size.big,disabled:!(p&&m&&x&&y&&!A&&d),onClick:()=>q(!0),children:A?G.jsx(e.Trans,{id:"R7D79P",message:"Invalid pair"}):G.jsx(e.Trans,{id:"bwSQI0",message:"Supply"})})})})}),G.jsx(Hw,{open:U,onClose:()=>q(!1),slippage:j,baseToken:p,baseAmount:x,quoteToken:m,quoteAmount:y,fee:d,price:S,lpAmount:L,shareOfPool:R,pairAddress:B,createMutation:H})]})]})}const EA=({disabled:e,feeAmount:i,dispatch:r})=>{const a=t.useTheme(),{isMobile:s}=Bp(),[l,d]=n.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:a.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[G.jsx(t.Box,{sx:{typography:"h5",color:a.palette.text.primary},children:i?`${sj[i].label} ${o.i18n._({id:"fxRyGG",message:"fee tier"})}`:o.i18n._({id:"EU3wU4",message:"Fee tier"})}),G.jsx(t.Button,{size:t.Button.Size.small,variant:t.Button.Variant.outlined,disabled:e,onClick:()=>d((e=>!e)),sx:{color:a.palette.text.primary,border:`solid 1px ${a.palette.text.primary}`},children:l?o.i18n._({id:"vLyv1R",message:"Hide"}):o.i18n._({id:"ePK91l",message:"Edit"})})]}),l&&G.jsx(t.Box,{sx:Object.assign({},s?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[Yv.LOWEST,Yv.LOW,Yv.MEDIUM,Yv.HIGH].map((n=>{const o=i===n;return G.jsxs(t.Button,{size:t.Button.Size.middle,variant:t.Button.Variant.outlined,disabled:e,onClick:()=>{r({type:Bj.UpdateFeeAmount,payload:n})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:o?a.palette.primary.main:a.palette.text.primary,borderRadius:12,borderColor:o?a.palette.primary.main:a.palette.border.main,[a.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[sj[n].label,o?G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.primary.main}),G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:a.palette.primary.main,stroke:a.palette.primary.main})]}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.text.secondary})})]},n)}))})]})},OA={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},LA=({series:e,xScale:i,yScale:o,xValue:r,yValue:a,fill:s})=>n.useMemo((()=>{var n;return G.jsx(t.Box,{component:"path",opacity:.5,stroke:null!=s?s:OA.accent1,fill:null!=s?s:OA.accent1,d:null!==(n=_.area().curve(_.curveStepAfter).x((e=>i(r(e)))).y1((e=>o(a(e)))).y0(o(0))(e.filter((e=>{const t=i(r(e));return t>0&&t<=window.innerWidth}))))&&void 0!==n?n:void 0})}),[s,e,i,r,o,a]),RA=({axisGenerator:e})=>G.jsx("g",{ref:t=>{t&&_.select(t).call(e).call((e=>e.select(".domain").remove()))}}),MA=({xScale:e,innerHeight:i,offset:o=0})=>n.useMemo((()=>G.jsx(t.Box,{component:"g",transform:`translate(0, ${i+o})`,sx:{"& line":{display:"none"},"& text":{color:OA.neutral2,transform:"translateY(5px)"}},children:G.jsx(RA,{axisGenerator:_.axisBottom(e).ticks(6)})})),[i,o,e]),PA=e=>["M 0 0",`v ${e}`,"m 1 0","V 0","M 0 1","h 12","q 2 0, 2 2","v 22","q 0 2 -2 2","h -12","z"].join(" "),_A=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),NA=({color:e,size:t=10,margin:n=10})=>G.jsx("polygon",{points:`0 0, ${t} ${t}, 0 ${t}`,transform:` translate(${t+n}, ${n}) rotate(45) `,fill:e,stroke:e,strokeWidth:"4",strokeLinejoin:"round"});const DA=({color:e,d:n})=>G.jsx(t.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:n}),FA=({d:e})=>G.jsx(t.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:OA.white,opacity:OA.opacity.hover,d:e}),UA=({visible:e,transform:n,children:i})=>G.jsx(t.Box,{component:"g",opacity:e?"1":"0",transform:n,sx:{transition:"opacity 300ms"},children:i}),qA=({y:e,x:n,height:i,width:o,rx:r})=>G.jsx(t.Box,{component:"rect",fill:OA.surface3,y:e,x:n,height:i,width:o,rx:r}),VA=({y:e,transform:n,dominantBaseline:i,children:o})=>G.jsx(t.Box,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:OA.neutral1,transform:n,dominantBaseline:i,children:o}),HA=(e,t,n)=>{const i=e.map((e=>n(e).toFixed(1))),o=t.map((e=>n(e).toFixed(1)));return i.every(((e,t)=>e===o[t]))},WA=({id:e,xScale:t,interactive:i,brushLabelValue:o,brushExtent:r,setBrushExtent:a,innerWidth:s,innerHeight:l,westHandleColor:d,eastHandleColor:c})=>{const u=n.useRef(null),p=n.useRef(null),[h,m]=n.useState(r),[g,x]=n.useState(!1),[f,y]=n.useState(!1),v=function(e){const t=n.useRef();return n.useEffect((()=>{t.current=e}),[e]),t.current}(r),b=n.useCallback((e=>{const{type:n,selection:i,mode:o}=e;if(!i)return void m(null);const s=i.map(t.invert);"end"!==n||HA(r,s,t)||a(s,o),m(s)}),[t,r,a]);n.useEffect((()=>{m(r)}),[r]),n.useEffect((()=>{u.current&&(p.current=_.brushX().extent([[Math.max(2,t(0)),0],[s-2,l]]).handleSize(30).filter((()=>i)).on("brush end",b),p.current(_.select(u.current)),v&&HA(r,v,t)&&_.select(u.current).transition().call(p.current.move,r.map(t)),_.select(u.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[r,b,e,l,s,i,v,t]),n.useEffect((()=>{u.current&&p.current&&p.current.move(_.select(u.current),r.map(t))}),[r,t]),n.useEffect((()=>{x(!0);const e=setTimeout((()=>x(!1)),1500);return()=>clearTimeout(e)}),[h]);const C=h&&t(h[0])>20,j=h&&t(h[1])>s-20,w=h&&(t(h[0])<0||t(h[1])<0),k=h&&(t(h[0])>s||t(h[1])>s),T=h&&t(h[0])>=0&&t(h[0])<=s,B=h&&t(h[1])>=0&&t(h[1])<=s;return n.useMemo((()=>G.jsxs(G.Fragment,{children:[G.jsxs("defs",{children:[G.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[G.jsx("stop",{stopColor:d}),G.jsx("stop",{stopColor:c,offset:"1"})]}),G.jsx("clipPath",{id:`${e}-brush-clip`,children:G.jsx("rect",{x:"0",y:"0",width:s,height:l})})]}),G.jsx("g",{ref:u,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)}),h&&G.jsxs(G.Fragment,{children:[T?G.jsxs("g",{transform:`translate(${Math.max(0,t(h[0]))}, 0), scale(${C?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(DA,{color:d,d:PA(l)}),G.jsx(FA,{d:_A()})]}),G.jsxs(UA,{transform:`translate(50,0), scale(${C?"1":"-1"}, 1)`,visible:g||f,children:[G.jsx(qA,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(VA,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:o("w",h[0])})]})]}):null,B?G.jsxs("g",{transform:`translate(${t(h[1])}, 0), scale(${j?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(DA,{color:c,d:PA(l)}),G.jsx(FA,{d:_A()})]}),G.jsxs(UA,{transform:`translate(50,0), scale(${j?"-1":"1"}, 1)`,visible:g||f,children:[G.jsx(qA,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(VA,{y:"15",dominantBaseline:"middle",children:o("e",h[1])})]})]}):null,w&&G.jsx(NA,{color:d}),k&&G.jsx("g",{transform:`translate(${s}, 0) scale(-1, 1)`,children:G.jsx(NA,{color:c})})]})]})),[o,c,B,j,C,f,e,l,s,h,k,g,w,d,T,t])},$A=({value:e,xScale:i,innerHeight:o})=>n.useMemo((()=>G.jsx(t.Box,{component:"line",x1:i(e),y1:"0",x2:i(e),y2:o,sx:{opacity:.5,strokeWidth:2,stroke:OA.neutral1,fill:"none"}})),[e,i,o]);function zA({svg:e,xScale:i,setZoom:o,width:r,height:a,resetBrush:s,showResetButton:l,zoomLevels:d}){const c=n.useRef(),[u,p,h,m]=n.useMemo((()=>[()=>e&&c.current&&_.select(e).transition().call(c.current.scaleBy,2),()=>e&&c.current&&_.select(e).transition().call(c.current.scaleBy,.5),()=>e&&c.current&&_.select(e).transition().call(c.current.scaleTo,.5),()=>e&&c.current&&_.select(e).call(c.current.transform,_.zoomIdentity.translate(0,0).scale(1)).transition().call(c.current.scaleTo,.5)]),[e]);return n.useEffect((()=>{e&&(c.current=_.zoom().scaleExtent([d.min,d.max]).extent([[0,0],[r,a]]).on("zoom",(({transform:e})=>o(e))),_.select(e).call(c.current))}),[a,r,o,e,i,c,d,d.max,d.min]),n.useEffect((()=>{h()}),[h,d]),G.jsxs(t.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${l?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[l&&G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:()=>{s(),m()},disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"1 4 1 10 7 10"}),G.jsx("polyline",{points:"23 20 23 14 17 14"}),G.jsx("path",{d:"M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"})]})}),G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),G.jsx(t.Button,{size:t.Button.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const ZA=e=>e.price0,QA=e=>e.activeLiquidity;function GA({id:e="liquidityChartRangeInput",data:{series:i,current:o},ticksAtLimit:r,styles:a,dimensions:{width:s,height:l},margins:d,interactive:c=!0,brushDomain:u,brushLabels:p,onBrushDomainChange:h,zoomLevels:m}){const g=n.useRef(null),[x,f]=n.useState(null),[y,v]=n.useMemo((()=>[l-d.top-d.bottom,s-d.left-d.right]),[s,l,d]),{xScale:b,yScale:C}=n.useMemo((()=>{const e={xScale:_.scaleLinear().domain([o*m.initialMin,o*m.initialMax]).range([0,v]),yScale:_.scaleLinear().domain([0,_.max(i,QA)]).range([y,0])};if(x){const t=x.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[o,m.initialMin,m.initialMax,v,i,y,x]);return n.useEffect((()=>{f(null)}),[m]),n.useEffect((()=>{u||h(b.domain(),void 0)}),[u,h,b]),G.jsxs(G.Fragment,{children:[G.jsx(zA,{svg:g.current,xScale:b,setZoom:f,width:v,height:l,resetBrush:()=>{h([o*m.initialMin,o*m.initialMax],"reset")},showResetButton:Boolean(r[sv.LOWER]||r[sv.UPPER]),zoomLevels:m}),G.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${s} ${l}`,style:{overflow:"visible"},children:[G.jsxs("defs",{children:[G.jsx("clipPath",{id:`${e}-chart-clip`,children:G.jsx("rect",{x:"0",y:"0",width:v,height:l})}),u&&G.jsx("mask",{id:`${e}-chart-area-mask`,children:G.jsx("rect",{fill:"white",x:b(u[0]),y:"0",width:b(u[1])-b(u[0]),height:y})})]}),G.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[G.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[G.jsx(LA,{series:i,xScale:b,yScale:C,xValue:ZA,yValue:QA}),u&&G.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:G.jsx(LA,{series:i,xScale:b,yScale:C,xValue:ZA,yValue:QA,fill:a.area.selection})}),G.jsx($A,{value:o,xScale:b,innerHeight:y}),G.jsx(MA,{xScale:b,innerHeight:y})]}),G.jsx(t.Box,{component:"rect",width:v,height:l,ref:g,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),G.jsx(WA,{id:e,xScale:b,interactive:c,brushLabelValue:p,brushExtent:null!=u?u:b.domain(),innerWidth:v,innerHeight:y,setBrushExtent:h,westHandleColor:a.brush.handle.west,eastHandleColor:a.brush.handle.east})]})]})]})}const YA=8;function KA(e,t,n,i,o,r){var a,s,l,d,c;let u=Object.assign({},n),p=[];for(let n=o+(r?1:-1);r?n<i.length:n>=0;r?n++:n--){const o=Number(null===(a=i[n])||void 0===a?void 0:a.tickIdx),h=PC(e,t,o),m={liquidityActive:u.liquidityActive,tick:o,liquidityNet:E.BigInt(null!==(l=null===(s=i[n])||void 0===s?void 0:s.liquidityNet)&&void 0!==l?l:""),price0:h.toFixed(YA),sdkPrice:h};r?m.liquidityActive=E.add(u.liquidityActive,E.BigInt(null!==(c=null===(d=i[n])||void 0===d?void 0:d.liquidityNet)&&void 0!==c?c:0)):!r&&E.notEqual(u.liquidityNet,E.BigInt(0))&&(m.liquidityActive=E.subtract(u.liquidityActive,u.liquidityNet)),p.push(m),u=m}return r||(p=p.reverse()),p}const XA=8,JA=(e,t)=>e&&t?Math.floor(e/Kv[t])*Kv[t]:void 0,eE=1e3;function tE(e,t,i,o){const[a,s]=n.useState(0),[l,c]=n.useState([]),{data:u,error:p,isLoading:h}=function(e,t,n,i=0,o){var a;const s=xp(),l=e&&t&&n?UC.getAddress(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped,n,void 0,o?Tv[o]:void 0):void 0,c=s.getQuery(r.AMMV3Api.graphql.AllV3TicksDocument,{skip:i,first:eE,where:{chain:o?Hl[o]:void 0,poolAddress:null!==(a=null==l?void 0:l.toLowerCase())&&void 0!==a?a:void 0,refreshNow:!0,schemaName:"ammv3"}});return d.useQuery(Object.assign(Object.assign({},c),{enabled:!0}))}(e,t,i,a,o),m=null==u?void 0:u.ticks;return n.useEffect((()=>{(null==m?void 0:m.length)&&(c((e=>[...e,...m])),(null==m?void 0:m.length)===eE&&s((e=>e+eE)))}),[m]),{isLoading:h||(null==m?void 0:m.length)===eE,error:p,ticks:l}}function nE({currencyA:e,currencyB:t,feeAmount:i,chainId:o}){const{isLoading:r,error:a,data:s}=function(e,t,i,o){var r,a,s;const l=gj(e,t,i),d=null===(r=l[1])||void 0===r?void 0:r.liquidity,c=null===(a=l[1])||void 0===a?void 0:a.sqrtRatioX96,u=null===(s=l[1])||void 0===s?void 0:s.tickCurrent,p=n.useMemo((()=>JA(u,i)),[u,i]),{isLoading:h,error:m,ticks:g}=tE(e,t,i,o);return n.useMemo((()=>{var n,i,o,r,a;if(!e||!t||void 0===p||l[0]!==mj.EXISTS||!g||0===g.length||h)return{isLoading:h||l[0]===mj.LOADING,error:m,activeTick:p,data:void 0};const s=null==e?void 0:e.wrapped,x=null==t?void 0:t.wrapped,f=g.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>p))-1;if(f<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{token0:s.address,token1:x.address,chainId:s.chainId}),{isLoading:h,error:m,activeTick:p,data:void 0};const y=PC(s,x,p),v={liquidityActive:E.BigInt(null!==(i=null===(n=l[1])||void 0===n?void 0:n.liquidity)&&void 0!==i?i:0),tick:p,liquidityNet:Number(null===(o=g[f])||void 0===o?void 0:o.tickIdx)===p?E.BigInt(null!==(a=null===(r=g[f])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):E.BigInt(0),price0:y.toFixed(XA),sdkPrice:y},b=KA(s,x,v,g,f,!0),C=KA(s,x,v,g,f,!1).concat(v).concat(b);return{isLoading:h,error:m,currentTick:u,activeTick:p,liquidity:d,sqrtPriceX96:c,data:C}}),[e,t,p,l,g,h,m,u,d,c])}(e,t,i,o),l=n.useCallback((()=>{if(!(null==s?void 0:s.length))return;const e=[];for(let t=0;t<s.length;t++){const n=s[t],i={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};i.activeLiquidity>0&&e.push(i)}return e}),[s]);return n.useMemo((()=>({isLoading:r,error:a,formattedData:r?void 0:l()})),[r,a,l])}const iE={initialMin:.999,initialMax:1.001,min:1e-5,max:1.5},oE={[Yv.LOWEST]:iE,[Yv.LOW_200]:iE,[Yv.LOW_300]:iE,[Yv.LOW_400]:iE,[Yv.LOW]:iE,[Yv.MEDIUM]:{initialMin:.5,initialMax:2,min:1e-5,max:20},[Yv.HIGH]:{initialMin:.5,initialMax:2,min:1e-5,max:20}};function rE({message:e,icon:n}){return G.jsxs(hv,{style:{height:"100%",justifyContent:"center"},children:[n,e&&G.jsx(t.Box,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function aE(){return G.jsx(t.LoadingSkeleton,{})}function sE({chainId:i,currencyA:o,currencyB:r,feeAmount:a,ticksAtLimit:s,price:l,priceLower:d,priceUpper:c,onLeftRangeInput:u,onRightRangeInput:p,interactive:h}){const m=o&&r&&(null==o?void 0:o.wrapped.sortsBefore(null==r?void 0:r.wrapped)),{isLoading:g,error:x,formattedData:f}=nE({currencyA:o,currencyB:r,feeAmount:a,chainId:i}),y=n.useCallback(((e,t)=>{let n=Number(e[0]);const i=Number(e[1]);n<=0&&(n=1/10**6),(!s[m?sv.LOWER:sv.UPPER]||"handle"===t||"reset"===t)&&n>0&&u(n.toFixed(6)),(!s[m?sv.UPPER:sv.LOWER]||"reset"===t)&&i>0&&i<1e35&&p(i.toFixed(6))}),[m,u,p,s]);h=h&&Boolean(null==f?void 0:f.length);const v=n.useMemo((()=>{const e=m?d:null==c?void 0:c.invert(),t=m?c:null==d?void 0:d.invert();return e&&t?[parseFloat(null==e?void 0:e.toSignificant(6)),parseFloat(null==t?void 0:t.toSignificant(6))]:void 0}),[m,d,c]),b=n.useCallback(((e,t)=>{if(!l)return"";if("w"===e&&s[m?sv.LOWER:sv.UPPER])return"0";if("e"===e&&s[m?sv.UPPER:sv.LOWER])return"∞";const n=(t<l?-1:1)*((Math.max(t,l)-Math.min(t,l))/l)*100;return l?`${Au({input:n,decimals:2})}%`:""}),[m,l,s]),C=!o||!r||void 0===f&&!g&&!x;return G.jsx(mv,{gap:"md",style:{minHeight:"200px"},children:C?G.jsx(rE,{message:G.jsx(e.Trans,{id:"OZUH85",message:"Your position will appear here."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:OA.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),G.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]})}):g?G.jsx(aE,{}):x?G.jsx(rE,{message:G.jsx(e.Trans,{id:"79D0qY",message:"Liquidity data not available."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:OA.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("path",{d:"M22.61 16.95A5 5 0 0 0 18 10h-1.26a8 8 0 0 0-7.05-6M5 5a8 8 0 0 0 4 15h9a5 5 0 0 0 1.7-.3"}),G.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):f&&0!==f.length&&l?G.jsx(t.Box,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:G.jsx(GA,{data:{series:f,current:l},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:OA.accent1},brush:{handle:{west:OA.critical,east:OA.accent1}}},interactive:h,brushLabels:b,brushDomain:v,onBrushDomainChange:y,zoomLevels:oE[null!=a?a:Yv.MEDIUM],ticksAtLimit:s})}):G.jsx(rE,{message:G.jsx(e.Trans,{id:"rH6vg9",message:"There is no liquidity data."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:OA.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),G.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),G.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const lE=({value:i,decrement:o,increment:r,decrementDisabled:a=!1,incrementDisabled:s=!1,locked:l,onUserInput:d,title:c,tokenA:u,tokenB:p})=>{const h=t.useTheme(),[m,g]=n.useState(!1),[x,f]=n.useState(""),[y,v]=n.useState(!1),[b,C]=n.useState(!1),j=n.useCallback((()=>{v(!1),g(!1),d(x)}),[x,d]),w=n.useCallback((()=>{v(!1),d(o())}),[o,d]),k=n.useCallback((()=>{v(!1),d(r())}),[r,d]);return n.useEffect((()=>{x===i||y||setTimeout((()=>{f(i),C(!0),setTimeout((function(){C(!1)}),1800)}),0)}),[x,y,i]),G.jsx(t.Box,{onFocus:()=>{v(!0),g(!0)},onBlur:j,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:h.palette.background.cardInput},children:G.jsxs(t.Box,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:h.palette.text.primary},children:c}),G.jsx(t.Box,{sx:{mt:4,typography:"h6",fontWeight:500,color:h.palette.text.secondary},children:G.jsx(e.Trans,{id:"1/LP4K",message:"{tokenB} per {tokenA}",values:{tokenB:p,tokenA:u}})}),G.jsx(Nf,{sx:{mt:12,backgroundColor:h.palette.background.cardInput},value:x,onChange:e=>{f(e)},readOnly:l})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&G.jsx(t.Button,{size:t.Button.Size.small,onClick:k,disabled:s,sx:{px:4,backgroundColor:h.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:a?h.palette.text.disabled:h.palette.text.primary})})}),!l&&G.jsx(t.Button,{size:t.Button.Size.small,onClick:w,disabled:a,sx:{px:4,backgroundColor:h.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:a?h.palette.text.disabled:h.palette.text.primary})})})]})]})})},dE=({priceLower:n,priceUpper:i,onLeftRangeInput:o,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:s,getDecrementUpper:l,getIncrementUpper:d,currencyA:c,currencyB:u,feeAmount:p,ticksAtLimit:h})=>{var m,g,x,f;const y=null===(m=null!=c?c:void 0)||void 0===m?void 0:m.wrapped,v=null===(g=null!=u?u:void 0)||void 0===g?void 0:g.wrapped,b=y&&v&&y.sortsBefore(v),C=b?n:null==i?void 0:i.invert(),j=b?i:null==n?void 0:n.invert();return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsx(lE,{value:h[b?sv.LOWER:sv.UPPER]?"0":null!==(x=null==C?void 0:C.toSignificant(8))&&void 0!==x?x:"",onUserInput:o,decrement:b?a:d,increment:b?s:l,decrementDisabled:void 0===C||h[b?sv.LOWER:sv.UPPER],incrementDisabled:void 0===C||h[b?sv.LOWER:sv.UPPER],feeAmount:p,label:C?`${null==u?void 0:u.symbol}`:"-",title:G.jsx(e.Trans,{id:"uEoBVI",message:"Low price"}),tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol}),G.jsx(lE,{value:h[b?sv.UPPER:sv.LOWER]?"∞":null!==(f=null==j?void 0:j.toSignificant(8))&&void 0!==f?f:"",onUserInput:r,decrement:b?l:s,increment:b?d:a,incrementDisabled:void 0===j||h[b?sv.UPPER:sv.LOWER],decrementDisabled:void 0===j||h[b?sv.UPPER:sv.LOWER],feeAmount:p,label:j?`${null==u?void 0:u.symbol}`:"-",tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol,title:G.jsx(e.Trans,{id:"kAC8rT",message:"High price"})})]})};var cE;function uE(){return uE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uE.apply(null,arguments)}const pE=e=>D.createElement("svg",uE({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),cE||(cE=D.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},D.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function hE({chainId:e,token:i,oppositeTokenAddress:r,dispatch:a,tokenSelectOnChange:s}){const l=t.useTheme(),[d,c]=n.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{component:t.ButtonBase,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:i?l.palette.border.main:l.palette.primary.main,color:i?l.palette.text.primary:l.palette.primary.contrastText,backgroundColor:i?"transparent":l.palette.primary.main,"&:hover":{borderColor:i?l.palette.border.main:l.palette.primary.main,opacity:.8},[l.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[i?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:i.address,marginRight:0,width:24,height:24,chainId:i.chainId||e,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:i.symbol})]}):G.jsx(t.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:o.i18n._({id:"0RrIzN",message:"Select token"})}),G.jsx(t.Box,{component:pE,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),G.jsx(Xf,{value:Cj(i),open:d,chainId:e,occupiedAddrs:[r],occupiedChainId:null==i?void 0:i.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return a({type:Bj.UpdateBaseTokenAndClearQuoteToken,payload:e}),void c(!1);s(e),c(!1)}},modal:!0})]})}const mE=({chainId:e,baseToken:n,quoteToken:i,dispatch:o})=>{var r,a;const s=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[s.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[G.jsx(hE,{chainId:e,token:n,oppositeTokenAddress:null!==(r=null==i?void 0:i.address)&&void 0!==r?r:"",dispatch:o,tokenSelectOnChange:e=>{o({type:Bj.UpdateBaseToken,payload:e})}}),G.jsx(hE,{chainId:e,token:i,oppositeTokenAddress:null!==(a=null==n?void 0:n.address)&&void 0!==a?a:"",dispatch:o,tokenSelectOnChange:e=>{o({type:Bj.UpdateQuoteToken,payload:e})}})]})};const gE=[{value:.03,title:"Narrow"},{value:.08,title:"Standard"},{value:.15,title:"Wide"},{value:1,title:"Full"}],xE=e=>{const i=t.useTheme(),[o,r]=n.useState(null);return G.jsx(t.Box,{sx:{borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:i.palette.border.main,overflow:"hidden",display:"flex",alignItems:"center",flexWrap:"wrap",alignSelf:"stretch"},children:gE.map(((n,a)=>G.jsxs(t.Box,{component:t.ButtonBase,onClick:()=>{r(n.value),e.onSelect(n.value)},sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",px:20,py:12,gap:8,flexBasis:"50%",flexGrow:1,borderRight:a%2==0?`1px solid ${i.palette.border.main}`:"none",borderBottom:a<=1?`1px solid ${i.palette.border.main}`:"none",[i.breakpoints.up("tablet")]:{flexBasis:"25%",borderRight:a===gE.length-1?"none":`1px solid ${i.palette.border.main}`,borderBottom:"none"},backgroundColor:o===n.value?t.alpha("#7BF179",.1):"transparent","&:hover":{backgroundColor:t.alpha("#7BF179",.1)}},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:i.palette.text.primary},children:n.title}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:600,color:i.palette.text.primary},children:1===n.value?"∞":`+-${100*n.value}%`})]},n.value)))})};function fE({params:i,handleGoBack:r,handleGoToPoolList:s}){var l,c,u,p,h,m,g,x,f,y;const{account:v,onlyChainId:b,defaultChainId:C}=cp(),j=null!=b?b:C,w=t.useTheme(),k=Up(),{isMobile:T}=Bp(),B=d.useQuery(Object.assign({},id.getFetchTokenQuery(j,null==i?void 0:i.from,v))),I=d.useQuery(Object.assign({},id.getFetchTokenQuery(j,null==i?void 0:i.to,v))),[S,A]=n.useReducer(Ij,{baseToken:null,quoteToken:null,feeAmount:(null==i?void 0:i.fee)?Number(null==i?void 0:i.fee):void 0,independentField:av.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});n.useEffect((()=>{B.data&&A({type:Bj.UpdateDefaultBaseToken,payload:B.data})}),[B]),n.useEffect((()=>{I.data&&A({type:Bj.UpdateDefaultQuoteToken,payload:I.data})}),[I]);const{independentField:E,typedValue:O,startPriceTypedValue:L}=S,{pool:R,ticks:M,dependentField:P,price:_,pricesAtTicks:N,pricesAtLimit:D,parsedAmounts:F,currencyBalances:U,position:V,noLiquidity:H,currencies:W,errorMessage:$,invalidPool:z,invalidRange:Z,outOfRange:Q,depositADisabled:Y,depositBDisabled:K,invertPrice:J,ticksAtLimit:ee,isTaxed:te}=Tj({state:S,chainId:j}),ne=n.useMemo((()=>{var e;return null===(e=J?null==_?void 0:_.invert():_)||void 0===e?void 0:e.toSignificant()}),[J,_]),{onFieldAInput:ie,onFieldBInput:oe,onLeftRangeInput:re,onRightRangeInput:ae,onStartPriceInput:se}=Sj({noLiquidity:H,dispatch:A}),{slipper:le,setSlipper:de,slipperValue:ce,resetSlipper:ue}=nv({address:void 0,type:"AMMV3"}),pe=!$&&!Z,[he,me]=n.useState(!1),ge={[E]:O,[P]:null!==(c=null===(l=F[P])||void 0===l?void 0:l.toSignificant(6))&&void 0!==c?c:""},xe=[av.CURRENCY_A,av.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:Lj(U[t])})),{}),fe=lh(Cj(null===(u=F[av.CURRENCY_A])||void 0===u?void 0:u.currency),{contractAddress:Bv[j],overrideBalance:U[av.CURRENCY_A]?new a(U[av.CURRENCY_A].toSignificant()):void 0,amount:F[av.CURRENCY_A]?new a(F[av.CURRENCY_A].toSignificant()):void 0}),ye=lh(Cj(null===(p=F[av.CURRENCY_B])||void 0===p?void 0:p.currency),{contractAddress:Bv[j],overrideBalance:U[av.CURRENCY_B]?new a(U[av.CURRENCY_B].toSignificant()):void 0,amount:F[av.CURRENCY_B]?new a(F[av.CURRENCY_B].toSignificant()):void 0}),{[sv.LOWER]:ve,[sv.UPPER]:be}=M,{[sv.LOWER]:Ce,[sv.UPPER]:je}=N,{getDecrementLower:we,getIncrementLower:ke,getDecrementUpper:Te,getIncrementUpper:Be,getSetFullRange:Ie}=function({tickLower:e,tickUpper:t,pool:i,state:o,dispatch:r}){const{baseToken:a,quoteToken:s,feeAmount:l}=o,d=n.useMemo((()=>null==a?void 0:a.wrapped),[a]),c=n.useMemo((()=>null==s?void 0:s.wrapped),[s]);return{getDecrementLower:n.useCallback((()=>d&&c&&"number"==typeof e&&l?PC(d,c,e-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof e&&d&&c&&l&&i?PC(d,c,i.tickCurrent-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,e,l,i]),getIncrementLower:n.useCallback((()=>d&&c&&"number"==typeof e&&l?PC(d,c,e+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof e&&d&&c&&l&&i?PC(d,c,i.tickCurrent+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,e,l,i]),getDecrementUpper:n.useCallback((()=>d&&c&&"number"==typeof t&&l?PC(d,c,t-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof t&&d&&c&&l&&i?PC(d,c,i.tickCurrent-Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,t,l,i]),getIncrementUpper:n.useCallback((()=>d&&c&&"number"==typeof t&&l?PC(d,c,t+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):"number"!=typeof t&&d&&c&&l&&i?PC(d,c,i.tickCurrent+Kv[l]).toSignificant(5,void 0,Sv.ROUND_UP):""),[d,c,t,l,i]),getSetFullRange:n.useCallback((()=>{r({type:Bj.setFullRange,payload:void 0})}),[r])}}({tickLower:ve,tickUpper:be,pool:R,state:S,dispatch:A}),Se=n.useCallback((e=>{if(1===e)Ie();else if(ne){const t=new a(ne),n=t.multipliedBy(1-e),i=t.multipliedBy(1+e);re(n.dp(5,a.ROUND_DOWN).toString()),ae(i.dp(5,a.ROUND_DOWN).toString())}}),[ne,Ie,re,ae]),{deadLine:Ae}=X(),Ee=d.useMutation({mutationFn:()=>q(this,void 0,void 0,(function*(){if(!v||!j||!V)return;if(!S.baseToken||!S.quoteToken)return;const e=Math.ceil(Date.now()/1e3)+(null!=Ae?Ae:600),t=S.baseToken.isNative?S.baseToken:S.quoteToken.isNative?S.quoteToken:void 0;try{const{calldata:n,value:i}=XC.addCallParameters(V,{slippageTolerance:Pj(100*ce),recipient:v,deadline:e.toString(),useNative:t,createPool:H});let r={to:Bv[j],data:n,value:i};(yield k.execute(o.i18n._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Mp.TX},r),{early:!1,metadata:{[exports.MetadataFlag.createAMMV3Pool]:"1"}}))===Ap.Success&&setTimeout((()=>{s()}),100)}catch(e){console.error("onAddMutation",e)}}))});return G.jsxs(G.Fragment,{children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[w.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[G.jsx(Xk,{}),G.jsx(t.Box,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})}),G.jsx(lj,{poolType:"AMM V3"})]}),G.jsxs(t.Box,{sx:{px:16,display:"flex",flexDirection:"column",alignItems:"stretch",backgroundColor:w.palette.background.paper,borderRadius:16,[w.breakpoints.up("tablet")]:{borderColor:w.palette.border.main,borderWidth:1,borderStyle:"solid",px:0,mx:"auto",width:600}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,py:20,[w.breakpoints.up("tablet")]:{px:20}},children:[G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"nxRg31",message:"Select pair"})}),G.jsx(mE,{chainId:j,baseToken:S.baseToken,quoteToken:S.quoteToken,dispatch:A}),G.jsx(EA,{disabled:!S.baseToken||!S.quoteToken,feeAmount:S.feeAmount,dispatch:A})]}),G.jsxs(yv,{disabled:!S.feeAmount||z,children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"5CZbyC",message:"Set price range"})}),Boolean(S.baseToken&&S.quoteToken)&&G.jsx(oj,{baseToken:S.baseToken,quoteToken:S.quoteToken,handleRateToggle:()=>{var e,t,n,i,o;ee[sv.LOWER]||ee[sv.UPPER]||(re(null!==(t=null===(e=J?Ce:null==je?void 0:je.invert())||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""),ae(null!==(i=null===(n=J?je:null==Ce?void 0:Ce.invert())||void 0===n?void 0:n.toSignificant(6))&&void 0!==i?i:""),ie(null!==(o=ge[av.CURRENCY_B])&&void 0!==o?o:"")),A({type:Bj.ToggleRate,payload:void 0})},sx:T?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]}),G.jsx(xE,{onSelect:Se}),G.jsx(dE,{priceLower:Ce,priceUpper:je,getDecrementLower:we,getIncrementLower:ke,getDecrementUpper:Te,getIncrementUpper:Be,onLeftRangeInput:re,onRightRangeInput:ae,currencyA:S.baseToken,currencyB:S.quoteToken,feeAmount:S.feeAmount,ticksAtLimit:ee}),Q&&G.jsx(pv,{children:o.i18n._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),Z&&G.jsx(pv,{children:o.i18n._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),H?G.jsxs(yv,{children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"zeSosD",message:"Starting price"})}),G.jsx(t.Box,{sx:{p:8,borderRadius:8,backgroundColor:t.alpha(w.palette.primary.main,.1),typography:"h6",color:w.palette.primary.main},children:o.i18n._({id:"X6T02b",message:"This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."})}),G.jsx(t.Box,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:w.palette.border.main,borderStyle:"solid"},children:G.jsx(Nf,{sx:{backgroundColor:"transparent"},value:L,onChange:se})})]}):G.jsxs(yv,{disabled:!S.feeAmount||z,children:[G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:[o.i18n._({id:"DWd30U",message:"Current price"}),G.jsxs(t.Box,{children:[ne," ",o.i18n._({id:"b2jAb+",message:"per"})," ",null!==(m=null===(h=S.baseToken)||void 0===h?void 0:h.symbol)&&void 0!==m?m:""]})]}),G.jsx(sE,{chainId:j,currencyA:null!==(g=S.baseToken)&&void 0!==g?g:void 0,currencyB:null!==(x=S.quoteToken)&&void 0!==x?x:void 0,feeAmount:S.feeAmount,ticksAtLimit:ee,price:_?parseFloat((J?_.invert():_).toSignificant(8)):void 0,priceLower:Ce,priceUpper:je,onLeftRangeInput:re,onRightRangeInput:ae,interactive:!0})]}),G.jsxs(yv,{disabled:z||Z||H&&!L,children:[G.jsx(t.Box,{sx:{typography:"body1",fontWeight:600,color:w.palette.text.primary,textAlign:"left"},children:o.i18n._({id:"MU9s7M",message:"Deposit amounts"})}),G.jsxs(t.Box,{children:[G.jsx(kv,{value:ge[av.CURRENCY_A],onUserInput:ie,maxAmount:xe[av.CURRENCY_A],balance:U[av.CURRENCY_A],currency:null!==(f=W[av.CURRENCY_A])&&void 0!==f?f:null,locked:Y}),G.jsx(cy,{}),G.jsx(kv,{value:ge[av.CURRENCY_B],onUserInput:oe,maxAmount:xe[av.CURRENCY_B],balance:U[av.CURRENCY_B],currency:null!==(y=W[av.CURRENCY_B])&&void 0!==y?y:null,locked:K})]}),G.jsx(iv,{value:le,onChange:de,disabled:!1,type:"AMMV3"})]})]}),G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",py:16,[w.breakpoints.up("tablet")]:{px:20,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:w.palette.background.paper}},children:G.jsx(vv,{chainId:j,approvalA:fe,approvalB:ye,parsedAmounts:F,isValid:pe,depositADisabled:Y,depositBDisabled:K,errorMessage:$,setShowConfirm:me})}),G.jsx(pj,{parsedAmounts:F,position:V,existingPosition:void 0,priceLower:Ce,priceUpper:je,outOfRange:Q,ticksAtLimit:ee,on:he,onClose:()=>{me(!1)},onConfirm:Ee.mutate,loading:Ee.isPending})]})]})}const yE=["#154618","#ED4A25","#0E794D","#F7A33E","#582969","#DFCC28","#294369","#1D1D1D"],vE=({poolDetail:e,tokenBalances:i})=>{const o=t.useTheme(),r=n.useMemo((()=>{if(!e)return[];if(!i)return[];const t=i.reduce(((e,t)=>e.plus(t)),new a.BigNumber(0));return e.coins.map(((e,n)=>({name:e.name,symbol:e.symbol,address:e.address,chainId:e.chainId,decimals:e.decimals,value:i[n].toNumber(),percentage:i[n].div(t).toNumber(),color:yE[n]})))}),[e,i]);return G.jsxs(t.Box,{sx:{mt:16,display:"flex",flexDirection:"column",alignItems:"stretch",gap:28,p:20,backgroundColor:o.palette.background.paper,borderRadius:16,[o.breakpoints.up("tablet")]:{flexDirection:"row",alignItems:"center",border:`1px solid ${o.palette.border.main}`,p:0,gap:0}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",[o.breakpoints.up("tablet")]:{minWidth:364,flexDirection:"column",gap:16}},children:[G.jsx(S.PieChart,{width:88,height:88,children:G.jsx(S.Pie,{isAnimationActive:!1,dataKey:"value",data:r,labelLine:!1,label:!1,outerRadius:44,children:r.map(((e,t)=>G.jsx(S.Cell,{fill:e.color,strokeWidth:0},`cell-${t}`)))})}),G.jsx(t.Box,{sx:{display:"none",[o.breakpoints.up("tablet")]:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:16,maxWidth:172}},children:r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),G.jsx(t.Box,{sx:{typography:"h6",color:o.palette.text.primary},children:e.symbol})]},e.address)))})]}),G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",gap:16,[o.breakpoints.up("tablet")]:{display:"none"}},children:r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(t.Box,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:e.symbol}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),G.jsxs(t.Box,{sx:{ml:"auto",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right"},children:Au({input:e.value,decimals:e.decimals})}),G.jsxs(t.Box,{sx:{typography:"h6",color:o.palette.text.secondary,textAlign:"right"},children:["(",Vu({input:new a.BigNumber(e.percentage),showDecimals:2}),")"]})]})]},e.address)))}),G.jsxs(t.Box,{sx:{display:"none",[o.breakpoints.up("tablet")]:{flexGrow:1,display:"block",borderLeft:`1px solid ${o.palette.border.main}`}},children:[G.jsxs(t.Box,{sx:{borderBottom:`1px solid ${o.palette.border.main}`,typography:"h6",fontWeight:600,color:o.palette.text.secondary,height:48,display:"flex",alignItems:"center"},children:[G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:"Asset"}),G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"Token Amount"}),G.jsx(t.Box,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"ratio"})]}),r.map((e=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",height:56},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8,flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:[G.jsx(Nh,{address:e.address,width:24,height:24,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary},children:e.symbol}),G.jsx(zf,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]})]}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Au({input:e.value,decimals:e.decimals})}),G.jsx(t.Box,{sx:{typography:"body2",fontWeight:600,color:o.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Vu({input:new a.BigNumber(e.percentage),showDecimals:2})})]},e.address)))]})]})};function bE(e,t){if(!e)return"";const n=T(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function CE({chainId:i,address:o}){var a;const{isMobile:s}=Bp(),l=t.useTheme(),c=function({chainId:e,address:t}){var n,i;const o=xp().getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolSwapInfo,{where:{chainId:null!=e?e:r.ChainId.ZETACHAIN,poolAddress:null!=t?t:""}}),a=d.useQuery(Object.assign(Object.assign({},o),{enabled:!!t&&!!e})),s=null===(i=null===(n=a.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolSwapInfo)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},a),{swapList:s})}({address:o,chainId:i}),[u,p]=n.useState(1),h=u*(s?4:8),m=null!==(a=c.swapList)&&void 0!==a?a:[],g=h<m.length,x=m.slice(0,h);return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:c.error?c.refetch:void 0,loading:c.isLoading,empty:!(null==x?void 0:x.length),children:!!(null==x?void 0:x.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"UPXmW+",message:"Trader"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"v4nCHK",message:"Paid"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"fZ5Vnu",message:"Received"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==x?void 0:x.map((e=>G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:bE(1e3*e.time)}),G.jsx("td",{children:G.jsx(zf,{address:e.user,truncate:!0})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.paidToken.id,chainId:i,width:24,height:24,noBorder:!0,noShowChain:!0}),`${Au({input:e.paidAmount,decimals:e.paidToken.decimals})} ${e.paidToken.symbol}`]})}),G.jsx("td",{children:G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Nh,{address:e.receivedToken.id,chainId:i,width:18,height:18,noBorder:!0,noShowChain:!0}),`${Au({input:e.receivedAmount,decimals:e.receivedToken.decimals})} ${e.receivedToken.symbol}`]})})]},e.id)))})]})}),g&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>p((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}const jE=({chainId:i,address:o})=>{var a,s;const{isMobile:l}=Bp(),c=t.useTheme(),u=function({chainId:e,address:t}){var n,i;const o=xp(),a=d.useQuery(Object.assign(Object.assign({},o.getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolLiquidityHistory,{where:{chainId:null!=e?e:r.ChainId.ZETACHAIN,poolAddress:null!=t?t:""}})),{enabled:!!t&&!!e}));return Object.assign(Object.assign({},a),{list:null===(i=null===(n=a.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolLiquidityHistory)||void 0===i?void 0:i.liquidityHistories})}({address:o,chainId:i}),[p,h]=n.useState(1),m=p*(l?4:8),g=u.list,x=m<(null!==(a=null==g?void 0:g.length)&&void 0!==a?a:0),f=null!==(s=null==g?void 0:g.slice(0,m))&&void 0!==s?s:[];return G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column"},children:G.jsx(ky,{refetch:u.error?u.refetch:void 0,loading:u.isLoading&&!(null==f?void 0:f.length),empty:!(null==f?void 0:f.length),children:!!(null==f?void 0:f.length)&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{overflowX:"auto",minHeight:244},children:G.jsxs(t.Box,{component:"table",sx:{minWidth:"100%"},children:[G.jsx(t.Box,{component:"thead",sx:{position:"sticky",top:0},children:G.jsxs(t.Box,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"LhMjLm",message:"Time"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"bwRvnp",message:"Action"})}),G.jsx(t.Box,{component:"th",children:G.jsx(e.Trans,{id:"GX8GKD",message:"Assets"})})]})}),G.jsx(t.Box,{component:"tbody",children:null==f?void 0:f.map((e=>{var o;return G.jsxs(t.Box,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[G.jsx("td",{children:bE(1e3*e.time)}),G.jsx("td",{children:e.action}),G.jsx("td",{children:G.jsx(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:null===(o=e.assets)||void 0===o?void 0:o.map(((e,o)=>G.jsxs(n.Fragment,{children:[o>0&&G.jsx(t.Box,{sx:{width:"1px",height:"16px",backgroundColor:c.palette.border.main,margin:"0 8px"}}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[G.jsx(Nh,{address:e.token.address,chainId:i,width:24,height:24,noBorder:!0,noShowChain:!0,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body2"},children:[Au({input:e.amount,decimals:e.token.decimals})," ",e.token.symbol]})]})]},e.token.address)))})})]},e.id)}))})]})}),x&&G.jsxs(t.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:c.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>h((e=>e+1)),children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(t.Box,{component:se.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})},wE=({title:e,children:n,tip:i,sx:o})=>G.jsxs(t.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,py:8},o),children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary"},children:e}),i&&G.jsx(lf,{title:i})]}),G.jsx(t.Box,{sx:{typography:"body1",color:"text.primary"},children:n})]}),kE=({poolDetail:e})=>{var n;return G.jsxs(t.Box,{sx:{mt:10,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(wE,{title:"Daily USD volume",children:(null==e?void 0:e.dailyVolumeUsd)?`$${qu(new a((null==e?void 0:e.dailyVolumeUsd)||"0"))}`:"-"}),G.jsx(wE,{title:"Liquidity utilization",tip:"24h Volume/Liquidity ratio",children:(null==e?void 0:e.liquidityUtilization)?`${Vu({input:new a((null==e?void 0:e.liquidityUtilization)||"0"),showDecimals:2})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(wE,{title:"Fee",children:(null==e?void 0:e.fee)?`${Vu({input:new a((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}`:"-"}),G.jsx(wE,{title:"DAO fee",children:(null==e?void 0:e.daoFee)?`${Vu({input:new a((null==e?void 0:e.daoFee)||"0"),showDecimals:2})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(wE,{title:"Virtual price",tip:"Measures pool growth; this is not a dollar value",children:(null==e?void 0:e.virtualPrice)?`${Au({input:new a((null==e?void 0:e.virtualPrice)||"0").div(1e18),decimals:18})}`:"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(wE,{title:"Pool/Token",children:(null==e?void 0:e.address)?G.jsx(zf,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body1",color:"text.primary"}}):"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(wE,{title:"Pool Type",children:"plain"===(null==e?void 0:e.poolType)?"Stableswap-NG":"meta"===(null==e?void 0:e.poolType)?"Plain pool":"-"}),G.jsx(t.Box,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),G.jsx(wE,{title:"Coins",sx:{alignItems:"flex-start"},children:G.jsx(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:e?e.coins.map((n=>G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nh,{address:n.address,width:16,height:16,chainId:null==e?void 0:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),G.jsxs(t.Box,{sx:{typography:"body1",fontWeight:500,color:"text.primary"},children:[n.symbol,"(Standard)"]})]},n.address))):"-"})}),G.jsx(wE,{title:"Pool Parameters:",sx:{alignItems:"flex-start"},children:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsxs(t.Box,{sx:{typography:"body1",color:"text.primary"},children:["A:",null!==(n=null==e?void 0:e.a)&&void 0!==n?n:"-"]}),G.jsx(lf,{title:"Amplification coefficient chosen from fluctuation of prices around 1."})]}),G.jsxs(t.Box,{sx:{typography:"body1",color:"text.primary"},children:["Off Peg Multiplier:",(null==e?void 0:e.offpegFeeMultiplier)?new a(null==e?void 0:e.offpegFeeMultiplier).div(1e10).toString():"-"]})]})})]})},TE=({poolDetail:e})=>{var n;const i=t.useTheme();return G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,[i.breakpoints.up("tablet")]:{py:20,flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:`1px solid ${i.palette.border.main}`}},children:[G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[e?G.jsx(Yj,{pool:e,separate:!1,wrap:!0}):G.jsx(t.Skeleton,{width:72,height:52,sx:{borderRadius:8}}),G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"h4",fontWeight:600},children:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:"-"}),(null==e?void 0:e.address)&&G.jsx(zf,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body2",color:"text.secondary"}})]})]}),G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"row",alignItems:"flex-end",gap:4,[i.breakpoints.up("tablet")]:{flexDirection:"column",gap:0}},children:[G.jsx(Gj,{apy:null==e?void 0:e.apy,dailyApy:null==e?void 0:e.dailyApy,weeklyApy:null==e?void 0:e.weeklyApy,sx:{typography:"h4",[i.breakpoints.up("tablet")]:{typography:"h4"}}}),G.jsx(t.Box,{sx:{typography:"body2",color:"text.secondary"},children:"APY"})]})]})},BE=({poolDetail:e})=>{const n=t.useTheme(),i=[{title:"Trader",value:qu(new a((null==e?void 0:e.traderCount)||"0"))},{title:"Total Liquidity",value:`$${qu(new a((null==e?void 0:e.tvl)||"0"))}`},{title:"Volume",value:`$${qu(new a((null==e?void 0:e.volume)||"0"))}`},{title:"Fees",value:Vu({input:new a((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}];return G.jsx(t.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gridTemplateRows:"repeat(2, 1fr)",gap:12,[n.breakpoints.up("tablet")]:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(1, 1fr)"}},children:i.map(((i,o)=>e?G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",p:16,borderRadius:8,backgroundColor:n.palette.background.paper,[n.breakpoints.up("tablet")]:{border:`1px solid ${n.palette.border.main}`}},children:[G.jsx(t.Box,{sx:{typography:"caption",color:n.palette.text.primary},children:i.value}),G.jsx(t.Box,{sx:{typography:"h6",color:n.palette.text.secondary},children:i.title})]},o):G.jsx(t.Skeleton,{width:"100%",height:77,sx:{borderRadius:8}},o)))})};const IE=({params:i})=>{const o=zy(),{isMobile:a}=Bp(),{account:s}=cp(),l=t.useTheme(),{poolDetail:c,isLoading:u,error:p}=function({address:e,chainId:t}){const i=xp(),o=n.useCallback((e=>{var n,i,o,a,s,l,d,c,u,p,h,m;const g=null==e?void 0:e.curve_stableswap_ng_getPoolInfo;if(!g)return;const x=((null===(n=g.coins)||void 0===n?void 0:n.map((e=>({chainId:null!=t?t:r.ChainId.ZETACHAIN,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex));return{chainId:null!=t?t:r.ChainId.ZETACHAIN,name:g.name||"",address:g.address||g.id||"",symbol:g.symbol,decimals:g.decimals,fee:(null===(i=g.fee)||void 0===i?void 0:i.toString())||"0",coins:x,apy:(null===(o=g.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(a=g.tvl)||void 0===a?void 0:a.toString())||null,volume:(null===(s=g.volume)||void 0===s?void 0:s.toString())||null,dailyVolumeUsd:(null===(l=g.dailyVolumeUsd)||void 0===l?void 0:l.toString())||null,traderCount:(null===(d=g.traderCount)||void 0===d?void 0:d.toString())||null,lpTokenBalance:null,liquidityUtilization:(null===(c=g.liquidityUtilization)||void 0===c?void 0:c.toString())||null,daoFee:(null===(u=g.daoFee)||void 0===u?void 0:u.toString())||null,virtualPrice:(null===(p=g.virtualPrice)||void 0===p?void 0:p.toString())||null,poolType:g.poolType||"plain",a:(null===(h=g.a)||void 0===h?void 0:h.toString())||null,offpegFeeMultiplier:(null===(m=g.offpegFeeMultiplier)||void 0===m?void 0:m.toString())||null}}),[t]),{data:a,isLoading:s,error:l}=d.useQuery(Object.assign(Object.assign({},i.getQuery(r.CurveApi.graphql.curve_stableswap_ng_getPoolInfo,{where:{chainId:null!=t?t:r.ChainId.ZETACHAIN,poolAddress:null!=e?e:""}})),{enabled:!!e&&!!t,select:o}));return{poolDetail:a,isLoading:s,error:l}}({address:null==i?void 0:i.address,chainId:null==i?void 0:i.chainId}),{tokenBalances:h}=lw({pool:c,account:s}),[m,g]=n.useState(null),[x,f]=n.useState("parameters");n.useEffect((()=>{a||c&&g({pool:c,type:Qj.Add})}),[c,a]);const y=n.useMemo((()=>[{key:"parameters",value:"Parameters"},{key:"swaps",value:"Swaps"},{key:"liquidity",value:"Liquidity"}]),[]);return G.jsxs(Wy,{sx:a?{p:l.spacing(28,0,108)}:{p:l.spacing(28,0,40)},children:[G.jsxs(t.Box,{sx:{[l.breakpoints.up("tablet")]:{display:"flex",gap:12,overflow:"hidden"}},children:[G.jsxs(t.Box,{sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",gap:24,[l.breakpoints.up("tablet")]:{gap:28}},children:[G.jsx(HS,{onClick:()=>{o.push({type:exports.PageType.Pool})}}),G.jsx(TE,{poolDetail:c}),G.jsx(BE,{poolDetail:c}),c&&G.jsxs(t.Box,{children:[G.jsx(t.Box,{sx:{typography:"body1",color:l.palette.text.primary},children:"Currency reserves"}),G.jsx(vE,{poolDetail:c,tokenBalances:h})]}),G.jsx(t.Box,{sx:{backgroundColor:l.palette.background.paper,borderRadius:16,overflow:"hidden",px:16,pb:16,[l.breakpoints.up("tablet")]:{px:20,pb:20}},children:G.jsxs(t.Tabs,{value:x,onChange:(e,t)=>f(t),children:[G.jsx(t.TabsGroup,{tabs:y}),G.jsx(t.TabPanel,{value:"parameters",children:G.jsx(kE,{poolDetail:c})}),G.jsx(t.TabPanel,{value:"swaps",children:G.jsx(CE,{chainId:null==i?void 0:i.chainId,address:null==i?void 0:i.address})}),G.jsx(t.TabPanel,{value:"liquidity",children:G.jsx(jE,{chainId:null==i?void 0:i.chainId,address:null==i?void 0:i.address})})]})})]}),G.jsx(t.Box,{sx:{position:"relative",width:a?"100%":375},children:m?G.jsx(hw,{poolDetailBtnVisible:!1,operateCurvePool:m,setOperateCurvePool:a?g:void 0}):a?null:G.jsx(t.Skeleton,{width:375,height:403,sx:{borderRadius:16}})})]}),a&&G.jsx(G.Fragment,{children:G.jsxs(t.Box,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[G.jsx(t.Button,{variant:t.Button.Variant.second,disabled:!c,onClick:()=>{c&&g({pool:c,type:Qj.Remove})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(t.Button,{disabled:!c,onClick:()=>{c&&g({pool:c,type:Qj.Add})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})})]})})]})};exports.AMMV2Create=AA,exports.AMMV3PositionManage=Nj,exports.AMMV3PositionsView=Uj,exports.AddLiquidityV3=fE,exports.CurvePoolDetail=IE,exports.EmptyList=ee,exports.FailedList=re,exports.Message=Zx,exports.Pool=function(){const{routerPage:e}=X(),t=zy((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case exports.PageType.Pool:return G.jsx(Kk,{params:n.params});case exports.PageType.CreatePool:return G.jsx(qS,{});case exports.PageType.ModifyPool:return G.jsx(YS,{params:n.params});case exports.PageType.PoolDetail:return G.jsx(CA,{params:n.params});case exports.PageType.CurvePoolDetail:return G.jsx(IE,{params:n.params});case exports.PageType.createPoolAMMV2:return G.jsx(AA,{});case exports.PageType.createPoolAMMV3:return G.jsx(fE,{params:n.params,handleGoBack:()=>{zy.getState().push({type:exports.PageType.Pool})},handleGoToPoolList:()=>{zy.getState().push({type:exports.PageType.Pool})}});default:return G.jsx(Kk,{params:null==n?void 0:n.params})}},exports.PoolCreate=qS,exports.PoolDetail=CA,exports.PoolList=Kk,exports.PoolModify=YS,exports.PoolOperate=hk,exports.PoolOperateDialog=mk,exports.Swap=function({getAutoSlippage:s,onPayTokenChange:l,onReceiveTokenChange:c}={}){var u,p,m,g,x,f;const y=t.useTheme(),{isInflight:v}=qp(),{noPowerBy:b,onlyChainId:C}=X(),{isMobile:j}=Bp(),{open:w,disconnect:k,suiConnectModalOpen:T,setSuiConnectModalOpen:B,getAppKitAccountByChainId:I,chainId:S,appKitActiveNetwork:A}=cp(),[E,O]=n.useState(!1),[L,R]=n.useState(""),[M,P]=n.useState(""),[_,N]=n.useState(""),[D,F]=n.useState(""),[U,V]=n.useState(null),[H,W]=n.useState(null),[$,z]=n.useState(!1),[Z,Q]=n.useState(!1),[Y,K]=n.useState(!1),[J,ee]=n.useState(null),te=n.useMemo((()=>I(null==U?void 0:U.chainId)),[null==U?void 0:U.chainId,I]),ne=n.useMemo((()=>{const e=I(null==H?void 0:H.chainId);if(e)return J?Object.assign(Object.assign({},e),{appKitAccount:Object.assign(Object.assign({},e.appKitAccount),{isConnected:!0,address:J})}):e}),[I,null==H?void 0:H.chainId,J]),ie=n.useMemo((()=>i.debounce((e=>N(e)),300)),[]),oe=n.useMemo((()=>i.debounce((e=>F(e)),300)),[]),re=n.useMemo((()=>{if(U&&H)return!(!(null==U?void 0:U.chainId)||!(null==H?void 0:H.chainId)||U.chainId===H.chainId)}),[U,H]),{toFiatPrice:ae,fromFiatPrice:le}=Wp({toToken:H,fromToken:U}),{marginAmount:de}=function({token:e,fiatPrice:t}){return{marginAmount:n.useMemo((()=>{var n;const i=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,o=null!=t?new a(500).div(t):new a(0),r=Ru(o,i);return(r.lt(new a(1).times(new a(10).pow(i-3)))?new a(0):r).toString(10)}),[null==e?void 0:e.decimals,t])}}({token:E?H:U,fiatPrice:E?ae:le});Tp({fromToken:U,toToken:H,getAutoSlippage:s});const{slippage:ce,slippageLoading:ue}=nh({fromToken:U,toToken:H}),{slippage:pe}=function(){const{defaultSlippage:e}=Xp(!0);return{slippage:yp((t=>t.slippage||e))}}(),{privacySwapSupplierEndpoints:he,privacySwapEnable:me,privacySwapEnableAble:ge,endpointStatusMap:xe,refetchEndpointStatus:fe}=th({chainId:null==U?void 0:U.chainId,account:null==te?void 0:te.appKitAccount.address}),ye=function(e){var t,n;const{getAppKitAccountByChainId:i}=cp(),{latestBlockNumber:o}=yp(),a=id.getFetchTokenQuery(e&&(null===(t=ac.get(e))||void 0===t?void 0:t.isEVMChain)?e:void 0,e?r.basicTokenMap[e].address:void 0,null===(n=i(e))||void 0===n?void 0:n.appKitAccount.address);return d.useQuery(Object.assign(Object.assign({},a),{queryKey:[...a.queryKey,o]}))}(null==U?void 0:U.chainId),{sendRouteLoading:ve,sendRouteError:be,setSendRouteError:Ce,bridgeOrderTxRequest:je,handleClickSend:we}=function(){const e=xp(),{evmProvider:t}=cp(),[i,a]=n.useState(),[s,l]=n.useState(!1),[d,c]=n.useState(""),u=n.useCallback((n=>q(this,[n],void 0,(function*({selectedRoute:n,fromEtherTokenBalance:i,goNext:s}){var d,u;if(!n)return;const{encodeParams:p}=n;if(p&&p.interfaceParams){c(""),l(!0);try{const h=yield e.getData(r.SwapApi.graphql.cross_chain_swap_zetachain_transactionEncode.toString(),{data:{interfaceParams:p.interfaceParams}});if(!h||!h.cross_chain_swap_zetachain_transactionEncode)throw new Error("cross_chain_swap_transactionEncode is null");const{data:m,to:g,value:x,from:f,chainId:y}=h.cross_chain_swap_zetachain_transactionEncode;if(!(m&&g&&x&&f&&y))throw new Error("cross_chain_swap_transactionEncode is null");const v=ac.get(y);if(null==v?void 0:v.isEVMChain){if(!i)throw new Error("fromEtherTokenBalance is null");const{fromToken:e,fromAmount:a}=n,s=r.basicTokenMap[y],p=Mu(x,18),h=s&&e.address.toLowerCase()===s.address.toLowerCase(),v=p.minus(h?a:0);if(!p.isNaN()&&p.gt(0)&&i.lt(p))return c(o.i18n._({id:"F9xwHA",message:"Insufficient cross-chain fees, need at least {0} {1}",values:{0:Au({input:v,decimals:null!==(d=null==s?void 0:s.decimals)&&void 0!==d?d:18}),1:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}})),void l(!1);if(!t||!(yield pp({from:f,to:g,value:x,data:m},t)))throw new Error("failed to estimate gas")}a({data:m,to:g,value:x,from:f,chainId:y}),s()}catch(e){console.error("[failed to construct transaction request]: ",e);const{message:t}=e;c(t)}l(!1)}}))),[e,t]);return{sendRouteLoading:s,sendRouteError:d,setSendRouteError:c,bridgeOrderTxRequest:i,handleClickSend:u}}(),{bridgeRouteList:ke,status:Te,failedReason:Be}=function({fromAccount:e,toAccount:t,fromToken:i,toToken:o,fromAmount:r,enabled:s,slippage:l}){var c,u,p,h;const{tokenList:m}=Tc(),{GRAPHQL_URL:g}=X(),x=n.useMemo((()=>i&&r?new a(r).multipliedBy(new a(10).pow(i.decimals)).dp(0,a.ROUND_DOWN):null),[r,i]),f=null!==(u=null===(c=null==e?void 0:e.appKitAccount)||void 0===c?void 0:c.address)&&void 0!==u?u:rc(null==i?void 0:i.chainId),y=null!==(h=null===(p=null==t?void 0:t.appKitAccount)||void 0===p?void 0:p.address)&&void 0!==h?h:rc(null==o?void 0:o.chainId),{data:v,error:b,isLoading:C,refetch:j}=d.useQuery({retry:!1,queryKey:["graphql","cross_chain_swap_zetachain_routes",null==i?void 0:i.chainId,null==i?void 0:i.address,null==o?void 0:o.chainId,null==o?void 0:o.address,f,y,null==x?void 0:x.toString(),l],queryFn:()=>q(this,void 0,void 0,(function*(){const e=yield fetch(`${g}?opname=Cross_chain_swap_zetachain_routes`,{headers:{"content-type":"application/json"},body:`{"query":"\\n query Cross_chain_swap_zetachain_routes($where: Cross_chain_swap_zetachainrouteParams) {\\n cross_chain_swap_zetachain_routes(where: $where) {\\n routeId\\n fromChainId\\n fromTokenAddress\\n fromAmount\\n fromAmountWithOutDecimals\\n fromAmountUSD\\n toChainId\\n toTokenAddress\\n toAmount\\n toAmountWithOutDecimals\\n toAmountUSD\\n fromAddress\\n toAddress\\n slippage\\n approveTarget\\n fees\\n omniPlan\\n encodeParams\\n }\\n}\\n ","variables":{"where":{"fromChainId":${null==i?void 0:i.chainId},"fromTokenAddress":"${null==i?void 0:i.address}","toChainId":${null==o?void 0:o.chainId},"toTokenAddress":"${null==o?void 0:o.address}","fromAddress":"${f}","toAddress":"${y}","fromAmount":"${null==x?void 0:x.toString()}","slippage":${l?Number(l)/100:null}}},"operationName":"Cross_chain_swap_zetachain_routes"}`,method:"POST"}),t=yield e.json();if(t.errors)throw new Error(t.errors[0].message);return t.data})),refetchInterval:15e3,enabled:!!i&&!!o&&!!x&&x.isFinite()&&x.gt(0)&&i.chainId!==o.chainId&&s}),{status:w,failedReason:k,bridgeRouteList:T}=n.useMemo((()=>{if(C)return{status:Sc.Loading,bridgeRouteList:[]};if(b){let e;if(console.error("error:",b),b.message.includes("NOT_ROUTE_MIN_AMOUNT:min-")){const t=b.message.split("min-")[1];t&&(e=`(Enter min amount: ${t})`)}return{status:Sc.Failed,failedReason:e,bridgeRouteList:[]}}if(v&&v.cross_chain_swap_zetachain_routes){const e=[],{routeId:t,fromChainId:n,fromTokenAddress:i,fromAmount:o,fromAmountWithOutDecimals:r,fromAmountUSD:s,toChainId:l,toTokenAddress:d,toAmount:c,fromAddress:u,toAddress:p,slippage:h,approveTarget:g,fees:x,omniPlan:f,encodeParams:y}=v.cross_chain_swap_zetachain_routes,b=ac.get(n);if(t&&n&&i&&r&&l&&d&&c&&u&&p&&h&&(!(null==b?void 0:b.isEVMChain)||g)&&x&&f&&f.length>0&&y){const o=m.find((e=>e.address.toLowerCase()===i.toLowerCase()&&e.chainId===n)),s=m.find((e=>e.address.toLowerCase()===d.toLowerCase()&&e.chainId===l)),b=new a(c);if(o&&s&&b.isFinite()&&b.gt(0)){const i=Ic({omniPlan:f,tokenList:m});if(i.includedSteps.length>0){const d=x.reduce(((e,t)=>{var n;return e.plus(null!==(n=t.amountUSD)&&void 0!==n?n:0)}),new a(0)).dp(4,a.ROUND_DOWN).toString(),c={key:t,id:t,fromChainId:n,toChainId:l,fromToken:o,toToken:s,fromAmount:r,toTokenAmount:b.div(`1e${s.decimals}`),fromAddress:u,toAddress:p,product:"zetachain",slippage:h,roundedRouteCostTime:0,spenderContractAddress:null!=g?g:null,feeUSD:d,fees:x,executionDuration:null,step:i,encodeParams:y,productParams:null,sourceRoute:v.cross_chain_swap_zetachain_routes};e.push(c)}}}return e.length>0?{status:Sc.Success,bridgeRouteList:e}:{status:Sc.Failed,bridgeRouteList:[]}}return{status:Sc.Initial,bridgeRouteList:[]}}),[C,b,v,m]);return{status:w,failedReason:k,refetch:j,bridgeRouteList:T}}({toToken:H,fromToken:U,fromAmount:_,fromAccount:te,toAccount:ne,enabled:!Y&&!ve,slippage:pe}),Ie=n.useMemo((()=>{if(ke&&ke.length>0)return ke[0]}),[ke]),{isApproving:Se,isGetApproveLoading:Ae,needApprove:Ee,insufficientBalance:Oe,submitApprove:Le,getMaxBalance:Re,tokenQuery:Me}=lh(U,{amount:_,contractAddress:null!==(u=null==Ie?void 0:Ie.spenderContractAddress)&&void 0!==u?u:void 0,account:null==te?void 0:te.appKitAccount.address}),{tokenQuery:Pe}=lh(H,{account:null==ne?void 0:ne.appKitAccount.address}),_e=n.useCallback((()=>{Ge(Re())}),[Re]),Ne=n.useMemo((()=>!(!(null==te?void 0:te.appKitAccount.address)||Oe||Se||Ae||Ee)),[null==te?void 0:te.appKitAccount.address,Oe,Se,Ae,Ee]),{status:De,rawBrief:Fe,executeSwap:Ue}=Kp({toToken:H,fromToken:U,marginAmount:de,fromAmount:_,toAmount:D,estimateGas:Ne,isReverseRouting:E,slippage:ce,slippageLoading:ue}),{resAmount:qe,priceImpact:Ve,baseFeeAmount:He,additionalFeeAmount:We,resPricePerToToken:$e,resPricePerFromToken:ze,routeInfo:Ze}=n.useMemo((()=>Fe||{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null,routeInfo:null}),[Fe]),Qe=jp(re),Ge=n.useCallback((e=>{const t=e.toString();R(t),ie(t)}),[R,ie]),Ye=n.useCallback((e=>{const t=e.toString();P(t),oe(t)}),[P,oe]),Ke=n.useCallback((e=>V((t=>{var n;const i="function"==typeof e?e(t):e;return S||yp.setState({fromTokenChainId:null!==(n=null==i?void 0:i.chainId)&&void 0!==n?n:void 0}),l&&i&&i!==t&&l(i),i}))),[l,S]),Xe=n.useCallback((e=>W((t=>{const n="function"==typeof e?e(t):e;return c&&n&&n!==t&&c(n),n}))),[c]);!function({fromToken:e,toToken:t,setFromToken:i,setToToken:o,updateFromAmt:r,updateToAmt:a,setIsReverseRouting:s}){const{tokenList:l}=Tc(),{crossChain:d,defaultFromToken:c,defaultToToken:u,onlyChainId:p}=X(),{chainId:h}=cp(),m=n.useCallback((()=>{let n,m=null;const g=d?void 0:null!=p?p:h;if(!e){const e=Jp({side:"from",defaultToken:c,tokenList:l,chainId:g});m=e.findToken,n=e.setDefaultAmount,m&&(i(m),void 0!==n&&(s(!1),r(n)))}if(!t){const{findToken:e,setDefaultAmount:t}=Jp({side:"to",defaultToken:u,tokenList:l,occupyToken:m,chainId:g});e&&(o(e),void 0===n&&void 0!==t&&(s(!0),a(t)))}}),[h,d,c,u,e,p,i,s,o,t,l,r,a]);n.useEffect((()=>{const e=setTimeout((()=>{m()}),10);return()=>clearTimeout(e)}),[m])}({fromToken:U,toToken:H,setFromToken:Ke,setToToken:Xe,updateFromAmt:Ge,updateToAmt:Ye,setIsReverseRouting:O});const Je=n.useCallback((()=>{Ge(""),Ye(""),Ke(H),Xe(U),cc("from",H),cc("to",U)}),[Ke,H,Xe,U,Ge,Ye]),et=n.useCallback(((e,t)=>{if(t)return Je();Ge(""),Ye(""),Ke(e),cc("from",e)}),[Je,Ge,Ye,Ke,cc]),tt=n.useCallback(((e,t)=>{if(t)return Je();Ge(""),Ye(""),Xe(e),cc("to",e)}),[Je,Ge,Ye,Ke,cc]),nt=n.useCallback((()=>{E&&Ge(""),O(!1)}),[E,Ge]),it=n.useCallback((()=>{E||Ye(""),O(!0)}),[E,Ye]),ot=(e=>{const{defaultSlippage:t}=Xp(void 0===e),i=yp((e=>e.slippage||t));return n.useMemo((()=>(void 0===e?Number(i):e)>5),[i,e])})(re?void 0:ce),rt=n.useMemo((()=>(100*Number(Ve)).toFixed(2)),[Ve]),at=n.useMemo((()=>{const e=E?qe:_;return e&&le?new a(le).multipliedBy(e):null}),[le,_,E,qe]),st=n.useMemo((()=>{var e;if(!ae||void 0===re)return null;if(re)return(null===(e=null==Ie?void 0:Ie.toTokenAmount)||void 0===e?void 0:e.gt(0))?Ie.toTokenAmount.multipliedBy(ae):null;const t=E?D:qe;return t?new a(ae).multipliedBy(t):null}),[ae,D,E,qe,Ie,re]),lt=n.useMemo((()=>G.jsxs(t.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[G.jsx(lf,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),G.jsxs(t.Box,{sx:{display:"flex"},children:[G.jsx(e.Trans,{id:"6+mYrD",message:"Current price impact"}),G.jsxs(t.Box,{sx:{color:y.palette.error.main,ml:4},children:[rt,"%"]})]})]})),[rt,y.palette.error.main]),dt=n.useMemo((()=>G.jsx(sy,{toToken:H,fromToken:U,priceStatus:De,pricePerToToken:$e,pricePerFromToken:ze,routeInfo:Ze})),[H,U,De,$e,ze,Ze]),ct=n.useMemo((()=>!r.ChainId[(null==U?void 0:U.chainId)||1]),[null==U?void 0:U.chainId]),ut=n.useMemo((()=>{if(!U)return!1;const e=I(U.chainId);return!!e&&(!!e.chain.isEVMChain&&(!!S&&!!(null==U?void 0:U.chainId)&&(null==U?void 0:U.chainId)!==S))}),[S,U,I]),pt=function({fromToken:e,toToken:t}){const i=Tc(Bc);return n.useMemo((()=>!(!e||i.some((t=>t.chainId===e.chainId&&t.address===e.address&&(!t.side||"to"===t.side))))||!(!t||i.some((e=>e.chainId===t.chainId&&e.address===t.address&&(!e.side||"from"===e.side))))),[e,t,i])}({fromToken:U,toToken:H}),ht=n.useMemo((()=>G.jsx(t.Tooltip,{open:Qe.showSwitchSlippage,title:re?G.jsx(e.Trans,{id:"qLkska",message:"The setting has been switched to cross chain mode"}):G.jsx(e.Trans,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",onClose:()=>Qe.setShowSwitchSlippage(!1),onlyClick:!0,children:G.jsx(t.Box,{component:t.ButtonBase,onClick:()=>Q(!0),sx:{p:4,backgroundColor:y.palette.background.paper,borderRadius:4,height:28,width:28,display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx(t.Box,{component:se.Setting,sx:{width:20,height:20,color:"text.primary",cursor:"pointer"}})})})),[re,Qe,y.palette.background.paper]),mt=n.useMemo((()=>ot&&new a(E?D:_).gt(0)&&!Oe&&(re?Te===Yp.Success:De===Yp.Success)?G.jsxs(t.Box,{sx:{textAlign:"center",mb:8},children:[G.jsx(t.Box,{component:se.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),o.i18n._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[ot,E,D,_,Oe,re,Te,De]),gt=n.useMemo((()=>ut?G.jsxs(t.Box,{sx:{textAlign:"center"},children:[G.jsx(t.Box,{component:se.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):re&&Te===Yp.Initial?"-":De===Yp.Loading||re&&Te===Yp.Loading?G.jsx(t.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsxs(G.Fragment,{children:[G.jsx(t.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]})}):ct?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{mr:6,width:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):re&&ke.length?G.jsxs(G.Fragment,{children:[mt,G.jsx(gg,{route:Ie})]}):re&&(Te===Yp.Success&&!ke.length||Te===Yp.Failed)&&L?G.jsxs(G.Fragment,{children:[G.jsx(t.Box,{component:se.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}):G.jsxs(G.Fragment,{children:[!re&&L&&new a(rt).gt(mc)&<,mt,dt]})),[De,dt,L,lt,rt,ct,re,Te,ke,Ie,ut,mt]),xt=n.useMemo((()=>E?new a(M).gt(0)?Au({input:qe,decimals:null==U?void 0:U.decimals}):"-":L),[L,M,qe,U,E]),ft=n.useMemo((()=>{var e;return E?M:re?(null===(e=null==Ie?void 0:Ie.toTokenAmount)||void 0===e?void 0:e.gt(0))&&Te!==Yp.Loading?Au({input:Ie.toTokenAmount,decimals:null==H?void 0:H.decimals}):"-":new a(L).gt(0)?Au({input:qe,decimals:null==H?void 0:H.decimals}):"-"}),[L,M,qe,H,E,Ie,re,Te]),yt=n.useMemo((()=>{var n,i,o,r;if(!(null===(n=null==te?void 0:te.appKitAccount)||void 0===n?void 0:n.isConnected)){const e=`Connect to ${dp(null==U?void 0:U.chainId)} wallet`,n=G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:e});if(!(null==U?void 0:U.chainId))return n;const o=null===(i=ac.get(U.chainId))||void 0===i?void 0:i.caipNetwork;if(!o)return n;const r=lp.getChainNamespace(o);return"sui"===r?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Button,{fullWidth:!0,children:e}),open:T,onOpenChange:e=>{console.log("swap from button isOpen",e),B(e)}}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>{w({namespace:r})},children:e})}if(te.chain.isEVMChain&&te.chain.chainId!==S)return G.jsx(t.Button,{fullWidth:!0,onClick:()=>{A.switchNetwork(te.chain.caipNetwork)},children:G.jsx(e.Trans,{id:"1+P9RR",message:"Switch to {0}",values:{0:te.chain.name}})});if(te.chain.isSolanaChain&&te.chain.chainId!==S)return G.jsx(t.Button,{fullWidth:!0,onClick:()=>{A.switchNetwork(te.chain.caipNetwork)},children:G.jsx(e.Trans,{id:"1+P9RR",message:"Switch to {0}",values:{0:te.chain.name}})});if(!(null===(o=null==ne?void 0:ne.appKitAccount)||void 0===o?void 0:o.isConnected)){const e=`Connect to ${dp(null==H?void 0:H.chainId)} wallet`,n=G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:e});if(!(null==H?void 0:H.chainId))return n;const i=null===(r=ac.get(H.chainId))||void 0===r?void 0:r.caipNetwork;if(!i)return n;const o=lp.getChainNamespace(i);return"sui"===o?G.jsx(h.ConnectModal,{trigger:G.jsx(t.Button,{fullWidth:!0,children:e}),open:T,onOpenChange:e=>{console.log("swap to button isOpen",e),B(e)}}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>{w({namespace:o})},children:e})}if(v)return G.jsx(t.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:G.jsx(e.Trans,{id:"FRBvjQ",message:"Transaction Pending"})});if(!U||!H)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:G.jsx(e.Trans,{id:"KlvBGJ",message:"Select Tokens"})});if(!new a(E?D:_).gt(0))return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:G.jsx(e.Trans,{id:"iPMIoT",message:"Enter an amount"})});if(re?Te===Yp.Loading||Ae:De===Yp.Loading)return G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:G.jsx(e.Trans,{id:"OauUE6",message:"Fetching Price..."})});let s=!1;return s=re?!ke.length||Te===Yp.Failed:!qe||De===Yp.Failed,s?G.jsx(t.Button,{fullWidth:!0,disabled:!0,children:G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})}):Oe?G.jsx(t.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):Ee?G.jsx(t.Button,{fullWidth:!0,disabled:Se,onClick:()=>Le(),children:Se?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):G.jsx(e.Trans,{id:"Z7ZXbT",message:"Approve"})}):re?G.jsx(t.Button,{fullWidth:!0,onClick:()=>{var e,t;return we({selectedRoute:Ie,fromEtherTokenBalance:null!==(t=null===(e=ye.data)||void 0===e?void 0:e.balance)&&void 0!==t?t:null,goNext:()=>K(!0)})},"data-testid":bc,disabled:!Ie,isLoading:ve,children:G.jsx(e.Trans,{id:"SXnevP",message:"Review Cross Chain"})}):me?G.jsxs(t.Button,{fullWidth:!0,onClick:()=>z(!0),"data-testid":bc,children:[G.jsx(t.Tooltip,{placement:"top",onlyHover:!0,maxWidth:240,title:G.jsxs(t.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(t.Box,{sx:{typography:"body2",fontWeight:500,color:"text.primary"},children:"Privacy Swap is Enabled"}),G.jsx(t.Box,{sx:{typography:"h6",fontWeight:500,color:"text.secondary"},children:"Your transactions on the Ethereum network will be protected from sandwich attacks."})]}),children:G.jsx(t.Box,{sx:{mr:8},children:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"30",viewBox:"0 0 25 30",fill:"none",children:[G.jsx("path",{d:"M12.5 4L3.5 8V14C3.5 19.55 7.34 24.74 12.5 26C17.66 24.74 21.5 19.55 21.5 14V8L12.5 4Z",fill:"white"}),G.jsx("path",{d:"M23 14C23 20.1791 18.7457 26.0187 12.8555 27.457L12.5 27.5439L12.1445 27.457C6.25427 26.0187 2 20.1791 2 14V7.02539L2.89062 6.62891L11.8906 2.62891L12.5 2.3584L13.1094 2.62891L22.1094 6.62891L23 7.02539V14Z",stroke:"white",strokeOpacity:"0.5",strokeWidth:"3"}),G.jsx("path",{d:"M16.3937 11.3638L10.8021 16.9553L8.60457 14.7662L7.4082 15.9626L10.8021 19.3565L17.59 12.5686L16.3937 11.3638Z",fill:"#154618"})]})})}),G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})]}):G.jsx(t.Button,{fullWidth:!0,onClick:()=>z(!0),"data-testid":bc,children:G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})})}),[null===(p=null==te?void 0:te.appKitAccount)||void 0===p?void 0:p.isConnected,null==te?void 0:te.chain.isEVMChain,null==te?void 0:te.chain.chainId,null==te?void 0:te.chain.isSolanaChain,null==te?void 0:te.chain.name,null==te?void 0:te.chain.caipNetwork,S,null===(m=null==ne?void 0:ne.appKitAccount)||void 0===m?void 0:m.isConnected,v,U,H,E,D,_,re,Te,Ae,De,Oe,Ee,me,T,B,w,A,ke.length,qe,Se,Le,Ie,ve,we,null===(g=ye.data)||void 0===g?void 0:g.balance]),vt=n.useMemo((()=>U&&H?G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Nh,{token:U,width:16,height:16,marginRight:6,chainId:U.chainId,noShowChain:!!C}),`${Au({input:E?qe:_,decimals:null==U?void 0:U.decimals})} ${null==U?void 0:U.symbol}`,G.jsx(t.Box,{component:se.DoubleRight,sx:{width:12,height:12,mx:16}}),G.jsx(Nh,{token:H,width:16,height:16,marginRight:6,chainId:H.chainId,noShowChain:!!C}),`${Au({input:E?D:qe,decimals:null==H?void 0:H.decimals})} ${null==H?void 0:H.symbol}`]}):G.jsx(t.Box,{})),[U,H,_,D,qe,E,C]);return G.jsxs(t.Box,{sx:{width:"100%",overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",borderRadius:16,backgroundColor:y.palette.background.skeleton,[y.breakpoints.up("laptop")]:{width:450,backgroundColor:y.palette.background.skeleton,backdropFilter:"blur(4px)"}},children:[G.jsxs(t.Box,{sx:{display:"flex",justifyContent:"space-between",px:16,py:20},children:[G.jsx(t.Box,{sx:{typography:"caption",color:y.palette.text.primary},children:"Universal Swap"}),G.jsxs(t.Box,{sx:{display:"flex",alignItems:"center",borderRadius:4,p:1,backgroundColor:y.palette.background.tag},children:[G.jsxs(t.Box,{sx:{color:y.palette.text.secondary,typography:"h6",px:6,py:4},children:[re?(null==Ie?void 0:Ie.slippage)?100*Ie.slippage:null!=pe?pe:"-":ce,"%"]}),ht]})]}),G.jsxs(t.Box,{sx:{flex:1,px:16,pb:20,overflowY:"auto"},children:[G.jsxs(t.Box,{children:[G.jsx(oy,{sx:{mb:4},token:U,side:"from",amt:xt,defaultLoadBalance:!0,onMaxClick:_e,onInputChange:Ge,onInputFocus:re?void 0:nt,showMaxBtn:!E&&!L,occupiedAddrs:[null!==(x=null==H?void 0:H.address)&&void 0!==x?x:""],occupiedChainId:null==H?void 0:H.chainId,fiatPriceTxt:at?`$${Au({input:at,decimals:2})}`:"$-",onTokenChange:et,readOnly:E,showChainLogo:!C,showChainName:!C,notTokenPickerModal:!j,enterAddressEnabled:!1,inputToAddress:J,setInputToAddress:ee,account:te,failedReason:Be,tokenQuery:Me}),G.jsx(Mf,{onClick:Je,disabled:pt}),G.jsx(oy,{token:H,side:"to",amt:ft,onInputChange:Ye,onInputFocus:re?void 0:it,occupiedAddrs:[null!==(f=null==U?void 0:U.address)&&void 0!==f?f:""],occupiedChainId:null==U?void 0:U.chainId,fiatPriceTxt:st?G.jsxs(G.Fragment,{children:["$",Au({input:st,decimals:2})]}):"$-",onTokenChange:tt,readOnly:re||!E,showChainLogo:!C,showChainName:!C,notTokenPickerModal:!j,enterAddressEnabled:re,inputToAddress:J,setInputToAddress:ee,account:ne,sx:{padding:y.spacing(24,20,20)},tokenQuery:Pe,filterBySupportTargetChain:!1}),G.jsx(t.Box,{sx:{py:16,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:gt})]}),yt,G.jsx(pf,{}),b?"":G.jsxs(t.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:y.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[G.jsx(t.Box,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:y.palette.text.disabled}},component:se.Dodo}),G.jsx(e.Trans,{id:"QIsI8+",message:"Powered by ZUNO protocol"})]})]}),G.jsx(hf,{toToken:H,fromToken:U,fromAmount:E?qe:_,toAmount:E?D:qe,open:$,baseFeeAmount:He,priceImpact:rt,additionalFeeAmount:We,curToFiatPrice:st,execute:()=>Ue(vt),clearFromAmt:()=>Ge(""),clearToAmt:()=>Ye(""),curFromFiatPrice:at,pricePerFromToken:ze,onClose:()=>z(!1),loading:De===Yp.Loading,slippage:ce,isDialogModal:j}),re?G.jsx(gf,{open:Z,onClose:()=>Q(!1),isBridge:!0,isDialogModal:j}):G.jsx(Rf,{open:Z,onClose:()=>Q(!1),fromToken:U,toToken:H,privacySwapEnableAble:ge,privacySwapEnable:me,privacySwapSupplierEndpoints:he,endpointStatusMap:xe,refetchEndpointStatus:fe,isDialogModal:j}),G.jsx(cf,{open:Y,onClose:()=>K(!1),route:Ie,bridgeOrderTxRequest:je,clearFromAmt:()=>Ge(""),clearToAmt:()=>Ye(""),isDialogModal:j}),G.jsx(uf,{message:be,onClose:()=>Ce(""),isDialogModal:j})]})},exports.SwapOrderHistory=function(){const e=t.useTheme(),{isMobile:i}=Bp(),o=n.useRef(null),a=n.useRef(null),{crossChainSubmittedCounter:s}=yp(),l=d.useQueryClient(),c=n.useRef(),u=n.useRef(l),{evmAccount:p,solanaAccount:h,bitcoinAccount:m,suiAccount:g,tonAccount:x,currentAccount:f}=cp(),[y,v]=n.useState(Dy.sameChain),[b,C]=n.useState(),j=n.useMemo((()=>[{key:Dy.sameChain,value:"Same chain Swaps"},{key:Dy.crossChain,value:"Cross Chain Swaps"},{key:Dy.errorRefunds,value:"Error Refunds"}]),[]),w=n.useMemo((()=>{var e,t,n,i,o;const r=[];if(p.isConnected&&p.address){const t=null===(e=ac.entries().find((([e,t])=>t.isEVMChain)))||void 0===e?void 0:e[1];t&&r.push({account:su(p.address),firstChain:t})}if(h.isConnected&&h.address){const e=null===(t=ac.entries().find((([e,t])=>t.isSolanaChain)))||void 0===t?void 0:t[1];e&&r.push({account:h.address,firstChain:e})}if(m.isConnected&&m.address){const e=null===(n=ac.entries().find((([e,t])=>t.isBTCChain)))||void 0===n?void 0:n[1];e&&r.push({account:m.address,firstChain:e})}if(g.isConnected&&g.address){const e=null===(i=ac.entries().find((([e,t])=>t.isSUIChain)))||void 0===i?void 0:i[1];e&&r.push({account:g.address,firstChain:e})}if(x.isConnected&&x.address){const e=null===(o=ac.entries().find((([e,t])=>t.isTONChain)))||void 0===o?void 0:o[1];e&&r.push({account:x.address,firstChain:e})}return r}),[m.address,m.isConnected,p.address,p.isConnected,h.address,h.isConnected,g.address,g.isConnected,x.address,x.isConnected]);n.useEffect((()=>{C((()=>{if(w.length>0)return w[0].account}))}),[w]);const k=n.useCallback(((e,t,n)=>{C(e),o.current&&(t?o.current.scrollTo({left:o.current.scrollWidth,behavior:"smooth"}):n&&o.current.scrollTo({left:0,behavior:"smooth"}))}),[]);return n.useEffect((()=>{const e=null==f?void 0:f.address;if(!e)return;const t=w.find((t=>t.account.toLowerCase()===e.toLowerCase()));t&&(c.current=t.account)}),[w,null==f?void 0:f.address]),n.useEffect((()=>{u.current=l}),[l]),n.useEffect((()=>{0!==s&&setTimeout((()=>{var e;null===(e=a.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"}),v(Dy.crossChain),c.current&&(C(c.current),u.current.invalidateQueries({queryKey:["graphql","getInfiniteQuery","page",r.SwapApi.graphql.cross_chain_swap_zetachain_orderList]}))}),300)}),[s]),G.jsxs(t.Tabs,{value:y,onChange:(e,t)=>{v(t)},sx:{width:"100%",display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%",borderRadius:16,backgroundColor:"background.skeleton",backdropFilter:"blur(4px)",[e.breakpoints.up("laptop")]:{}},className:i?void 0:"gradient-card-border",children:[G.jsx(t.Box,{ref:a,sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",px:16,pt:20,[e.breakpoints.up("laptop")]:{px:24}},children:G.jsx(t.TabsGroup,{tabs:j,variant:"default",tabsListSx:{justifyContent:"space-between",borderBottomWidth:0},tabSx:{mr:28,typography:"body2",lineHeight:"19px",minHeight:39,padding:"0px 0px 20px 0px",[e.breakpoints.up("laptop")]:{typography:"body1",lineHeight:"22px",minHeight:42}}})}),G.jsx(t.Box,{ref:o,sx:{px:16,py:12,display:"flex",alignItems:"center",gap:12,overflowX:"auto",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",[e.breakpoints.up("laptop")]:{px:24},"&::-webkit-scrollbar":{display:"none"},msOverflowStyle:"none",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",userSelect:"none"},children:w.map(((n,i)=>{const o=b===n.account,r=i===w.length-1,a=0===i;return G.jsxs(t.Box,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:4,pl:8,py:8,pr:10,borderRadius:4,backgroundColor:"transparent",cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.secondary",flexShrink:0},o&&{backgroundColor:t.alpha(e.palette.success.main,.1),color:"success.main"}),{"&:hover":{backgroundColor:o?t.alpha(e.palette.success.main,.1):e.palette.background.paperDarkContrast}}),onClick:()=>k(n.account,r,a),children:[n.firstChain&&G.jsx(t.Box,{component:n.firstChain.logo,sx:{width:16,height:16}}),"(",dp(n.firstChain.chainId),")",tp(n.account)]},n.account)}))}),b?G.jsxs(G.Fragment,{children:[G.jsx(Vy,{value:Dy.sameChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(qy,{account:b})}),G.jsx(Vy,{value:Dy.crossChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Py,{account:b})}),G.jsx(Vy,{value:Dy.errorRefunds,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Py,{account:b,type:"error_refund"})})]}):G.jsx(ky,{isMobile:i,empty:!0,loading:!1})]})},exports.TokenCard=py,exports.TokenLogo=Nh,exports.UnstyleWidget=sf,exports.WIDGET_CLASS_NAME=of,exports.WIDGET_MODULE_CLASS_NAME=Hy,exports.Widget=function(e){const n=t.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||Lg});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),G.jsxs(t.ThemeProvider,{theme:n,children:[G.jsx(t.CssBaseline,{container:`.${of}, .${t.WIDGET_MODAL_CLASS}, .${t.WIDGET_MODAL_FIXED_CLASS}`}),G.jsx(d.QueryClientProvider,{client:Hg,children:G.jsxs(sf,{...e,children:[e.children,G.jsx(Zx,{})]})})]})},exports.chainListMap=ac,exports.fixedInputStringToFormattedNumber=Lu,exports.formatPercentageNumber=Vu,exports.formatReadableNumber=Su,exports.formatShortNumber=Uu,exports.formatTokenAmountNumber=Au,exports.getEtherscanPage=np,exports.jsxRuntimeExports=G,exports.rpcServerMap=Ul,exports.scanUrlDomainMap=Vl,exports.useMessageState=$x,exports.usePoolBalanceInfo=fw,exports.useRouterStore=zy,exports.useTradeSwapOrderList=_y;
|