@meteraprotocol/sdk
Version:
SDK to interact with Metera's API & a UI component that will create orders into the Metera Protocol
119 lines • 69.3 kB
JavaScript
'use strict';var react=require('@chakra-ui/react'),X=require('bignumber.js'),react$1=require('react'),core=require('@meteraprotocol/core');require('@nufi/dapp-client-cardano'),require('@nufi/dapp-client-core');var xe=require('axios'),bigRationalTs=require('big-rational-ts'),Lr=require('json-bigint'),lucidTxpipe=require('lucid-txpipe'),zod=require('zod'),cbor2=require('cbor2'),lucid=require('@lucid-evolution/lucid'),react$2=require('@emotion/react'),jsxRuntime=require('react/jsx-runtime'),reactNumberFormat=require('react-number-format'),icons=require('@chakra-ui/icons'),index_js=require('react-icons/md/index.js'),mr=require('@emotion/styled');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var X__default=/*#__PURE__*/_interopDefault(X);var xe__default=/*#__PURE__*/_interopDefault(xe);var Lr__default=/*#__PURE__*/_interopDefault(Lr);var mr__default=/*#__PURE__*/_interopDefault(mr);var mt=(g=>(g.BAD_REQUEST="Bad request",g.UNKNOWN="There was a problem when building your transaction. Please try again",g.NOT_ENOUGH_MONEY="You don't have enough tokens for this.",g.INVALID_IMAGE="Image format is not valid",g.INVALID_ORDER="Invalid order",g.CANT_CANCEL_IN_PROGRESS="Order being processed. Can't cancel right now",g.ORDER_NOT_FOUND="Order not found",g.ALREADY_CANCELLING="Order already in cancelling process",g.ALREADY_CANCELLED="Order already cancelled",g.ORDER_CBOR_INVALID="The provided order is not valid",g.SERVER_DOWN="Our servers are currently down. Please try again later",g.UNAUTHORIZED="Unauthorized",g.ORDER_EXPIRED="This order expired",g.ORDER_MIGHT_HAVE_BEEN_CANCELLED="Can't cancel this order",g.PORTFOLIO_NOT_FOUND="The portfolio you requested doesn't exist",g.PORTFOLIO_CBOR_INVALID="The provided transaction is not valid",g.RUN_OUT_OF_FUNDS="Your request might have clashed with someone else's. Try again",g.OVER_BUDGET="You requested too much for today. Try with other tokens or tomorrow.",g))(mt||{});function Ee(e){if(e.eq(0))return new bigRationalTs.BigRational(0n,1n);let[t,r]=e.toFraction().map(o=>BigInt(o.toFixed(0)));return new bigRationalTs.BigRational(t,r).reduce()}function N(e){let t=X__default.default(e.getNumerator().toString()),r=X__default.default(e.getDenominator().toString());return t.div(r)}function Et(e){return Ee(_r(e))}function _r(e){return X__default.default(e)}Lr__default.default({alwaysParseAsBig:!0,useNativeBigInt:!0,strict:!0});async function Ne(e){let t=lucidTxpipe.getAddressDetails(await e.getChangeAddress()).address.bech32,r=await e.getUtxos();if(!r)return {};let o=r.map(lucidTxpipe.fromHex).map(lucidTxpipe.C.TransactionUnspentOutput.from_bytes).filter(n=>JSON.parse(n.output().address().to_json())===t),i={lovelace:0n};for(let n of o){let a=n.output(),l=a.amount().coin();i.lovelace+=BigInt(l.to_str());let f=a.amount().multiasset()?.to_js_value()||{};for(let[b,p]of Object.entries(f))for(let[d,m]of Object.entries(p)){let u=`${b}${d}`;i[u]||(i[u]=BigInt(0)),i[u]+=BigInt(m);}}return i}function Nt(e){return e.assets.reduce((r,{price:o,amount:i,asset:{decimals:n}})=>Ee(X__default.default(o)).mul(new bigRationalTs.BigRational(i,1n)).mul(new bigRationalTs.BigRational(1n,BigInt(10**n))).add(r),new bigRationalTs.BigRational(0n,1n)).div(new bigRationalTs.BigRational(e.supply,1n)).reduce()}function Xe(e,t){let r={floor:X__default.default.ROUND_FLOOR,ceil:X__default.default.ROUND_CEIL};return BigInt(e.toFixed(0,r[t]))}function Gr(e,t){return Object.entries(t).every(([r,o])=>(e[r]||BigInt(0))>=o)}function z(e){return e.currencySymbol===""?"lovelace":`${e.currencySymbol}${e.name}`}var qe=e=>{if(e instanceof xe__default.default.AxiosError&&e.response?.data&&Object.values(mt).includes(e.response?.data)){let t=e.response.data;switch(t){case"Invalid order":return {error:"The data in your order is probably outdated. Refresh the page and try again"};case"This order expired":return {error:"This order expired, try again."};case"Order already cancelled":return {error:"This order was cancelled already"};case"You don't have enough tokens for this.":return {error:"You ran out of tokens. Refresh your wallet and try again if you recharged"};case"Bad request":return {error:"Some of your input is wrong"};case"Order already in cancelling process":return {error:"In process of cancelling"};default:return {error:t}}}else if(e.message.includes("ECONNREFUSED"))return {error:"Our servers are currently down. Please try again later"};return {error:"Unknown error. Try again"}};function qt(e,t,r,o,i){let n=Object.fromEntries(Object.entries(t).map(([a,l])=>{let c=i.assets.find(f=>f.asset.id===a);return [z(c.asset),l]}));return r==="mint"?Gr(e,n):X__default.default((e[i.portfolio.mtkUnit]||0n).toString()).div(10**core.MTK_DECIMALS).gte(o)}var _e=e=>Object(e).hasOwnProperty("error");var ae="http://localhost:3003".replace(/\/+$/,"");var Ze=class extends Error{constructor(r,o){super(o);this.field=r;this.name="RequiredError";}},se={};var le="https://example.com",Te=function(e,t,r){if(r==null)throw new Ze(t,`Required parameter ${t} was null or undefined when calling ${e}.`)};function gt(e,t,r=""){t!=null&&(typeof t=="object"?Array.isArray(t)?t.forEach(o=>gt(e,o,r)):Object.keys(t).forEach(o=>gt(e,t[o],`${r}${r!==""?".":""}${o}`)):e.has(r)?e.append(r,t):e.set(r,t));}var ce=function(e,...t){let r=new URLSearchParams(e.search);gt(r,t),e.search=r.toString();},Be=function(e,t,r){let o=typeof e!="string";return (o&&r&&r.isJsonMime?r.isJsonMime(t.headers["Content-Type"]):o)?JSON.stringify(e!==void 0?e:{}):e||""},de=function(e){return e.pathname+e.search+e.hash},pe=function(e,t,r,o){return (i=t,n=r)=>{let a={...e.options,url:(i.defaults.baseURL?"":o?.basePath??n)+e.url};return i.request(a)}};var $r=function(e){return {ordersCreatePost:async(t,r={})=>{let o="/orders/create",i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"POST",...n,...r},l={},c={};l["Content-Type"]="application/json",ce(i,c);let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},a.data=Be(t,a,e),{url:de(i),options:a}},ordersSubmitPost:async(t,r={})=>{Te("ordersSubmitPost","ordersSubmitPostRequest",t);let o="/orders/submit",i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"POST",...n,...r},l={},c={};l["Content-Type"]="application/json",ce(i,c);let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},a.data=Be(t,a,e),{url:de(i),options:a}},portfoliosGet:async(t={})=>{let r="/portfolios",o=new URL(r,le),i;e&&(i=e.baseOptions);let n={method:"GET",...i,...t},a={};ce(o,{});let c=i&&i.headers?i.headers:{};return n.headers={...a,...c,...t.headers},{url:de(o),options:n}},portfoliosPricePost:async(t,r={})=>{Te("portfoliosPricePost","portfoliosPricePostRequest",t);let o="/portfolios/price",i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"POST",...n,...r},l={},c={};l["Content-Type"]="application/json",ce(i,c);let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},a.data=Be(t,a,e),{url:de(i),options:a}},portfoliosStateIdGet:async(t,r={})=>{Te("portfoliosStateIdGet","id",t);let o="/portfolios/state/{id}".replace("{id}",encodeURIComponent(String(t))),i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"GET",...n,...r},l={};ce(i,{});let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},{url:de(i),options:a}},swapCreatePost:async(t,r={})=>{Te("swapCreatePost","swapCreatePostRequest",t);let o="/swap/create",i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"POST",...n,...r},l={},c={};l["Content-Type"]="application/json",ce(i,c);let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},a.data=Be(t,a,e),{url:de(i),options:a}},swapSubmitPost:async(t,r={})=>{Te("swapSubmitPost","swapSubmitPostRequest",t);let o="/swap/submit",i=new URL(o,le),n;e&&(n=e.baseOptions);let a={method:"POST",...n,...r},l={},c={};l["Content-Type"]="application/json",ce(i,c);let f=n&&n.headers?n.headers:{};return a.headers={...l,...f,...r.headers},a.data=Be(t,a,e),{url:de(i),options:a}}}},Kr=function(e){let t=$r(e);return {async ordersCreatePost(r,o){let i=await t.ordersCreatePost(r,o),n=e?.serverIndex??0,a=se["SDKApi.ordersCreatePost"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)},async ordersSubmitPost(r,o){let i=await t.ordersSubmitPost(r,o),n=e?.serverIndex??0,a=se["SDKApi.ordersSubmitPost"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)},async portfoliosGet(r){let o=await t.portfoliosGet(r),i=e?.serverIndex??0,n=se["SDKApi.portfoliosGet"]?.[i]?.url;return (a,l)=>pe(o,xe__default.default,ae,e)(a,n||l)},async portfoliosPricePost(r,o){let i=await t.portfoliosPricePost(r,o),n=e?.serverIndex??0,a=se["SDKApi.portfoliosPricePost"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)},async portfoliosStateIdGet(r,o){let i=await t.portfoliosStateIdGet(r,o),n=e?.serverIndex??0,a=se["SDKApi.portfoliosStateIdGet"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)},async swapCreatePost(r,o){let i=await t.swapCreatePost(r,o),n=e?.serverIndex??0,a=se["SDKApi.swapCreatePost"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)},async swapSubmitPost(r,o){let i=await t.swapSubmitPost(r,o),n=e?.serverIndex??0,a=se["SDKApi.swapSubmitPost"]?.[n]?.url;return (l,c)=>pe(i,xe__default.default,ae,e)(l,a||c)}}},ft=function(e,t,r){let o=Kr(e);return {ordersCreatePost(i,n){return o.ordersCreatePost(i,n).then(a=>a(r,t))},ordersSubmitPost(i,n){return o.ordersSubmitPost(i,n).then(a=>a(r,t))},portfoliosGet(i){return o.portfoliosGet(i).then(n=>n(r,t))},portfoliosPricePost(i,n){return o.portfoliosPricePost(i,n).then(a=>a(r,t))},portfoliosStateIdGet(i,n){return o.portfoliosStateIdGet(i,n).then(a=>a(r,t))},swapCreatePost(i,n){return o.swapCreatePost(i,n).then(a=>a(r,t))},swapSubmitPost(i,n){return o.swapSubmitPost(i,n).then(a=>a(r,t))}}};var Ve=class{apiKey;username;password;accessToken;basePath;serverIndex;baseOptions;formDataCtor;constructor(t={}){this.apiKey=t.apiKey,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.serverIndex=t.serverIndex,this.baseOptions=t.baseOptions,this.formDataCtor=t.formDataCtor;}isJsonMime(t){let r=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return t!==null&&(r.test(t)||t.toLowerCase()==="application/json-patch+json")}};zod.z.string();zod.z.string();zod.z.object({address:zod.z.string(),tokens:zod.z.record(zod.z.bigint().positive())}).strict();var _t=zod.z.object({cbor:zod.z.string({description:"Unsigned transaction cbor"}),txId:zod.z.string({description:"Transaction hash"})}),Vt=zod.z.object({cbor:zod.z.string(),id:zod.z.string()}).strict();zod.z.object({cbor:zod.z.string()});react$1.createContext(void 0);function Lt(e){e.length%2!==0&&(e="0"+e);let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.slice(r,r+2),16);return t}async function bt(e,t,r=!1,o="legacy"){return o==="conway"?Qr(e,t,r):Zr(e,t,r)}async function Zr(e,t,r=!1){let o=lucidTxpipe.C.Transaction.from_bytes(Lt(t)),i=await e.signTx(t,r),n=cbor2.decode(i,{encoding:"hex"});if(n.size===0)throw new Error("Empty witness set after signTx");if(!n.has(0))throw new Error("Incorrect vkey witness CBOR format");let a=n.get(0),[l,c]=Array.from(a)[0],f=lucidTxpipe.C.PublicKey.from_bytes(l),b=lucidTxpipe.C.Vkey.new(f),p=lucidTxpipe.C.Ed25519Signature.from_bytes(c),d=lucidTxpipe.C.Vkeywitnesses.new();d.add(lucidTxpipe.C.Vkeywitness.new(b,p));let m=o.witness_set();m.set_vkeys(d);let u=lucidTxpipe.C.Transaction.new(o.body(),m,o.auxiliary_data());return lucidTxpipe.toHex(u.to_bytes())}async function Qr(e,t,r=!1){let o=lucid.CML.Transaction.from_cbor_bytes(Lt(t)),i=await e.signTx(t,r),n=cbor2.decode(i,{encoding:"hex"});if(n.size===0)throw new Error("Empty witness set after signTx");if(!n.has(0))throw new Error("Incorrect vkey witness CBOR format");let a=n.get(0),[l,c]=Array.from(a)[0],f=lucid.CML.PublicKey.from_bytes(l),b=lucid.CML.Ed25519Signature.from_raw_bytes(c),p=lucid.CML.VkeywitnessList.new();p.add(lucid.CML.Vkeywitness.new(f,b));let d=o.witness_set();return d.set_vkeywitnesses(p),lucid.CML.Transaction.new(o.body(),d,!0,o.auxiliary_data()).to_cbor_hex()}function Ht(e){let t={},r={},o={};for(let i of e.assets)r[i.asset.id]=Et(i.price).mul(new bigRationalTs.BigRational(1n,BigInt(10**i.asset.decimals))),t[i.asset.id]=new bigRationalTs.BigRational(i.weightNum,i.weightDenom),o[i.asset.id]=BigInt(i.amount);return {prices:r,weights:t,state:{assets:o,mtkSupply:e.supply}}}function Gt(e,t){if(e.eq(new bigRationalTs.BigRational(0n,1n))){let a={};for(let[l]of Object.entries(t.state.assets))a[l]=0n;return {assets:a,mtkSupply:0n}}let r=core.computeInteraction(t.prices,t.weights,t.state,e),o=e.gte(new bigRationalTs.BigRational(0n,1n))?"ceil":"floor",i={};for(let[a,l]of Object.entries(t.state.assets)){let c=r.assets[a].subtract(new bigRationalTs.BigRational(l,1n));i[a]=Xe(N(c),o);}let n=Xe(N(r.mtkSupply),o)-t.state.mtkSupply;return {assets:i,mtkSupply:n}}async function $t(e,t,r,o,i,n,{onError:a,onSuccess:l}){let c=new Ve({basePath:i}),f=ft(c);try{if((await Ne(e.wallet)).lovelace<10000000n)return a("You need more tADA in your wallet to do this");let p,d=Object.entries(r.assets).map(([M,I])=>({id:M,amount:I.toString()}));o.gt(0)?p={address:lucidTxpipe.getAddressDetails(await e.wallet.getChangeAddress()).address.bech32,portfolioId:t.portfolio.id,maxBatcherFee:t.batcherFee.toString(),minMtkAcceptable:"1",tokens:d}:p={address:lucidTxpipe.getAddressDetails(await e.wallet.getChangeAddress()).address.bech32,portfolioId:t.portfolio.id,amount:Xe(o.times(10**core.MTK_DECIMALS).abs(),"floor").toString(),tokens:d,maxBatcherFee:t.batcherFee.toString(),minWorthAcceptable:"1"};let m=await f.ordersCreatePost(p).catch(qe);if(_e(m))return a(m.error);let{cbor:u,id:y}=Vt.parse(m.data),k=await bt(e.wallet,u,!1),C={id:y,cbor:k},g=await f.ordersSubmitPost(C).catch(qe);return _e(g)?a(g.error):(l(y),y)}catch(b){console.error(b),a("Unknown error. Try again later");}}function Ut(e,t){let r={...e};for(let[o,i]of Object.entries(t))e[o]&&(r[o]=e[o]-i);return r}function jt(e){for(let[t,r]of Object.entries(e))r<=0&&delete e[t];}async function Kt(e,t,r,o,i,n,a,{onError:l,onSuccess:c}){let f=new Ve({basePath:a}),b=ft(f);try{if((await Ne(e.wallet)).lovelace<10000000n)return l("You need more ADA in your wallet to do this");let d={...o},m={};n&&(d=Ut(o,r),m=Ut(o,d),jt(m)),jt(d);let u={address:lucidTxpipe.getAddressDetails(await e.wallet.getChangeAddress()).address.bech32,maxBatcherFee:t.batcherFee.toString(),totalAmount:i.toString(),userAssets:Object.entries(m).map(([V,S])=>({id:V,amount:S.toString()})),swap:Object.entries(d).map(([V,S])=>({id:V,amount:S.toString()})),portfolioId:t.portfolio.id},y=await b.swapCreatePost(u).catch(qe);if(_e(y))return l(y.error);let{cbor:k,txId:C}=_t.parse(y.data),M={cbor:await bt(e.wallet,k,!1,"conway")},I=await b.swapSubmitPost(M).catch(qe);return _e(I)?l(I.error):(c(C),C)}catch(p){console.error(p),l("Unknown error. Try again later");}}var s={background:{purple100:`linear-gradient(
180deg,
rgba(139, 92, 246, 0.01) 0%,
rgba(255, 255, 255, 0) 100%
),
rgba(27, 27, 30, 0.1)`,purple200:`linear-gradient(
180deg,
rgba(139, 92, 246, 0.03) 0%,
rgba(255, 255, 255, 0) 100%
),
rgba(27, 27, 30, 1)`,solid:"rgba(27, 27, 30, 0.9)",modal:"#08040f",homeCards:`radial-gradient(
50% 50% at 20% 20%,
rgba(125, 70, 250, 0.18) 0%,
rgba(69, 44, 126, 0) 100%
),
linear-gradient(
180deg,
rgba(139, 92, 246, 0.03),
rgba(255, 255, 255, 0)
),
rgba(27, 27, 30, 0.9)`,topPortfolios:`radial-gradient(
50% 50% at 50% 50%,
rgba(125, 70, 250, 0.12) 0%,
rgba(69, 44, 126, 0) 100%
),
linear-gradient(
180deg,
rgba(139, 92, 246, 0.03),
rgba(255, 255, 255, 0)
),
rgba(27, 27, 30, 0.9)`,join:`radial-gradient(
50% 50% at 50% 50%,
rgba(125, 70, 250, 0.15) 47%,
rgba(69, 44, 126, 0) 100%
),
linear-gradient(
180deg,
rgba(139, 92, 246, 0.03),
rgba(255, 255, 255, 0)
),
rgba(27, 27, 30, 0.9)`,middleBlub:`radial-gradient(
50% 50% at 50% 50%,
rgba(125, 70, 250, 0.12) 63.5%,
rgba(69, 44, 126, 0) 100%
),
linear-gradient(
180deg,
rgba(139, 92, 246, 0.03),
rgba(255, 255, 255, 0)
),
rgba(27, 27, 30, 0.9)`,card:`linear-gradient(
180deg,
rgba(139, 92, 246, 0.03),
rgba(255, 255, 255, 0)
),
rgba(27, 27, 30, 0.9)`,tableModals:`linear-gradient(
180deg,
rgba(139, 92, 246, 0.03) 0%,
rgba(255, 255, 255, 0) 100%
),
rgba(27, 27, 30, 0.9)`},gradient:{start:"rgba(139, 92, 246, 0.03)",end:"rgba(255, 255, 255, 0)",angle:"180deg",button:`linear-gradient(
87deg,
rgba(76, 29, 149, 0.2) 0%,
rgba(124, 58, 237, 0.2) 100%
)`,button100:`linear-gradient(
87deg,
rgba(77, 29, 149, 0.794) 0%,
rgba(124, 58, 237, 0.2) 100%
)`,table:`linear-gradient(
87deg,
rgba(76, 29, 149, 0.05) 0%,
rgba(124, 58, 237, 0.05) 100%
)`},purple:{divider:"#3a2e5c",subtext:"#a78bfa",button100:"#8b5cf6",button200:"#8a5cf6c7",metera:"#8b5cf6",metera100:"#c4b5fd",metera200:"#8b5cf669",metera300:"rgba(76, 29, 149, 0.4)"},distribution:{one:"#4c1d95",two:"#6d28d9",three:"#8b5cf6",four:"#a78bfa",five:"#c4b5fd"},neutral:{1e3:"rgba(23, 23, 23, 1)",900:"rgba(23, 23, 23, 1)",800:"#262626",600:"#525252",500:"#737373",400:"#a3a3a3",300:"#d4d4d4",200:"#e5e5e5"},cards:{stroke:"rgba(192, 166, 253, 0.25)",stroke2:"rgba(192, 166, 253, 0.2)",background:"#ef4444"},error:{error500:"#ef4444"},success:{success500:"#22c55e"},offWhite:{offWhite400:"#fafaf4"},primary:{primary50:"#f5f3ff"},header:{table:"#2c2658"},circle:{fill:"#83d2ff"},backgrounds:{one:"#3b2b67",two:"#270e45"},animatedBorder:{initialValue:"0turn",animationTo:"1turn",bgSpin:react$2.keyframes`
to {
--animated-border: 1turn;
}
`},blinkAnimation:react$2.keyframes`
{
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(0.7);
}
}
`,opacityAnimation:react$2.keyframes`
{
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.6;
}
}
`};var Yt=react$1.forwardRef(({color:e="#FAFAFA"},t)=>jsxRuntime.jsxs("svg",{ref:t,width:"15",height:"15",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("g",{clipPath:"url(#clip0_785_532)",children:jsxRuntime.jsx("path",{d:"M7.57499 7.49984C7.77091 6.94289 8.15762 6.47326 8.66662 6.17411C9.17562 5.87497 9.77407 5.76562 10.356 5.86543C10.9379 5.96524 11.4657 6.26777 11.8459 6.71944C12.2261 7.17111 12.4342 7.74277 12.4333 8.33317C12.4333 9.99984 9.93332 10.8332 9.93332 10.8332M9.99999 14.1665H10.0083M18.3333 9.99984C18.3333 14.6022 14.6024 18.3332 9.99999 18.3332C5.39762 18.3332 1.66666 14.6022 1.66666 9.99984C1.66666 5.39746 5.39762 1.6665 9.99999 1.6665C14.6024 1.6665 18.3333 5.39746 18.3333 9.99984Z",stroke:"#A3A3A3",strokeWidth:"1.66667",strokeLinecap:"round",strokeLinejoin:"round"})}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:"clip0_785_532",children:jsxRuntime.jsx("rect",{width:"20",height:"20",fill:"white"})})})]}));Yt.displayName="InfoSVG";var Ue=Yt;var F=(e,t=2,r=void 0,o=void 0)=>Number(e).toLocaleString("en-US",{useGrouping:!0,minimumFractionDigits:r!==void 0?r:t,maximumFractionDigits:o!==void 0?o:t});function no(e){e.batcherFee.plus(e.managerFee).plus(e.platformFee).abs();let r=F(e.managerFee.abs().div(10**6).toFixed(6),6,0),o=F(e.batcherFee.abs().div(10**6).toFixed(6),6,0),i=F(e.platformFee.abs().div(10**6).toFixed(6),6,0),n=F(e.expectedAmount.abs().div(10**6).toFixed(6),6,0),a=F(e.withdrawLovelace.abs().div(10**6).toFixed(6),6,0),l=F(X__default.default(2e6).div(10**6).toFixed(6),6,0),c=F(X__default.default(2e6).div(10**6).toFixed(6),6,0),f=`- ${r} $${e.mtkTicker}`,b=`- ${o} \u20B3`,p=`- ${i} \u20B3`,d=`${n} $${e.mtkTicker}`,m=`${a} \u20B3`,u=e.type==="mint"?`$${e.mtkTicker} expected to go to your wallet`:"Expected worth of tokens you will receive",y=`${l} \u20B3`,k=`${c} \u20B3`;return jsxRuntime.jsx(react.Flex,{width:"100%",height:"fit-content",gap:"12px",justifyContent:"space-between",flexDirection:"column",children:e.hasInsuficientToken&&e.type==="mint"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(me,{label:"Zapping via",info:"You are submitting a bulk order via Minswap. Fees are calculated based on Minswap fees",imageSrc:"https://sqvzfgobtlzbovqbkaax.supabase.co/storage/v1/object/public/sdk-assets//minswap_horizontal.svg"}),jsxRuntime.jsx(me,{label:"Batching Fees",info:"Batching fees might be lower if you hold MIN in your wallet",value:y}),jsxRuntime.jsx(me,{label:"Minimum UTxO deposit",info:"This amount of ADA will be held as minimum UTxO ADA and will be returned when your orders are processed or cancelled",value:k})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(me,{label:"Manager Fee",info:`$${e.mtkTicker} paid to the Manager`,value:f}),jsxRuntime.jsx(me,{label:"Batcher Fee",info:"ADA paid for processing",value:b}),jsxRuntime.jsx(me,{label:"Platform Fee",info:"ADA paid for placing orders",value:p}),e.type==="mint"?jsxRuntime.jsx(me,{label:"Expected Amount",info:u,value:d}):jsxRuntime.jsx(me,{label:"Expected worth of tokens",info:u,value:m})]})})}function me({label:e,value:t,info:r,imageSrc:o}){return jsxRuntime.jsxs(react.Flex,{justifyContent:"space-between",width:"100%",fontSize:"14px",fontWeight:"400",lineHeight:"20px",children:[jsxRuntime.jsxs(react.Flex,{gap:2,alignItems:"center",children:[jsxRuntime.jsx(react.Text,{color:"#A3A3A3",children:e}),jsxRuntime.jsx(react.Tooltip,{placement:"top",sx:{background:"var(--bg-200)",border:"0.5px solid var(--cards-stroke)",borderRadius:"0.75rem",color:"var(--off-white-400)",fontWeight:"600",padding:"1rem",backdropFilter:"blur(30px)"},label:r||e,children:jsxRuntime.jsx(react.Flex,{display:"flex",align:"center",cursor:"ponter",children:jsxRuntime.jsx(Ue,{})})})]}),o?jsxRuntime.jsx("img",{src:o,alt:e,style:{width:"6rem"}}):jsxRuntime.jsxs(react.Text,{color:"#FAFAFA",children:[t," "]})]})}var Jt=no;var io=({color:e="#FAFAFA"})=>jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M12 6.00024V3.37573C12 2.75192 12 2.44002 11.8686 2.24834C11.7538 2.08087 11.576 1.96711 11.3758 1.93305C11.1467 1.89406 10.8635 2.02477 10.2971 2.28618L3.64426 5.35673C3.13913 5.58987 2.88656 5.70644 2.70158 5.88723C2.53804 6.04705 2.41321 6.24215 2.33663 6.45761C2.25 6.70133 2.25 6.9795 2.25 7.53583V11.2502M12.375 10.8752H12.3825M2.25 8.40024L2.25 13.3502C2.25 14.1903 2.25 14.6104 2.41349 14.9312C2.5573 15.2135 2.78677 15.4429 3.06901 15.5867C3.38988 15.7502 3.80992 15.7502 4.65 15.7502H13.35C14.1901 15.7502 14.6101 15.7502 14.931 15.5867C15.2132 15.4429 15.4427 15.2135 15.5865 14.9312C15.75 14.6104 15.75 14.1903 15.75 13.3502V8.40024C15.75 7.56016 15.75 7.14012 15.5865 6.81925C15.4427 6.53701 15.2132 6.30754 14.931 6.16373C14.6101 6.00024 14.1901 6.00024 13.35 6.00024L4.65 6.00024C3.80992 6.00024 3.38988 6.00024 3.06901 6.16373C2.78677 6.30754 2.5573 6.53701 2.41349 6.81925C2.25 7.14012 2.25 7.56016 2.25 8.40024ZM12.75 10.8752C12.75 11.0823 12.5821 11.2502 12.375 11.2502C12.1679 11.2502 12 11.0823 12 10.8752C12 10.6681 12.1679 10.5002 12.375 10.5002C12.5821 10.5002 12.75 10.6681 12.75 10.8752Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),wt=io;var so=({status:e,showStatus:t})=>{let r={Confirmed:"#22C55E",Failed:"#EF4444",Invalid:"#EF4444",Cancelled:"#EF4444",Pending:"#FCD34D",Confirming:"#FCD34D",Processing:"#FCD34D",Cancelling:"#EF4444",Insufficient:"#FBBF24"},o=e==="Pending"||e==="Cancelling"||e==="Processing";return jsxRuntime.jsxs(react.Flex,{align:"center",gap:2,children:[jsxRuntime.jsx(react.Box,{style:o?{animation:`${s.blinkAnimation} 1s infinite`}:{},children:jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"6",height:"6",viewBox:"0 0 6 6",fill:"none",children:jsxRuntime.jsx("circle",{cx:"3",cy:"3",r:"3",fill:r[e]})})}),t&&jsxRuntime.jsx(react.Box,{style:o?{animation:`${s.opacityAnimation} 1s infinite`}:{},children:e})]})},L=so;var mo=({step:e,hasBorder:t=!1,circlePadding:r="0.6rem"})=>{let o=parseInt(e,10);return jsxRuntime.jsxs(react.Flex,{justify:"space-between",position:"relative",alignItems:"center",width:"100%",padding:t?"1rem":"",borderRadius:"0.75rem",border:t?`1px solid ${s.cards.stroke}`:"",sx:{fontSize:{lg:"0.875rem",sm:"10px"}},fontWeight:500,children:[jsxRuntime.jsx(react.Circle,{padding:r,bg:o>=1?s.purple.metera:"#E2E8F0",color:o>=1?"white":"#262626",zIndex:1,children:"1. Zap-in"}),jsxRuntime.jsx(react.Circle,{padding:r,bg:o>=2?s.purple.metera:"#E2E8F0",color:o>=2?"white":"#262626",zIndex:1,children:"2. Track & Receive"}),jsxRuntime.jsx(react.Circle,{padding:r,bg:o>=3?s.purple.metera:"#E2E8F0",color:o>=3?"white":"#262626",fontWeight:500,zIndex:1,children:"3. Mint MTKs"}),jsxRuntime.jsx(react.Box,{position:"absolute",width:t?"80%":"100%",top:"50%",h:"2px",bg:o>=1?s.purple.metera:"#E2E8F0",zIndex:0})]})},rr=mo;var ir="https://sqvzfgobtlzbovqbkaax.supabase.co/storage/v1/object/public/sdk-assets//cardanoimage.png",go="https://sqvzfgobtlzbovqbkaax.supabase.co/storage/v1/object/public/sdk-assets//swap-arrow.svg";function fo({type:e,portfolioTicker:t,portfolioImageUrl:r,balance:o,inputValue:i,setInputValue:n,mtkUnit:a,expectedAmount:l,withdrawLovelace:c,switchType:f,showBreakdown:b,hasInsufficientToken:p,portfolioAssets:d,background:m}){let u=()=>{},y=S=>{S.target.value===""&&n(new X__default.default(0));},k=()=>{o&&n(X__default.default(o[a]?.toString()||0).div(10**core.MTK_DECIMALS));},I=()=>jsxRuntime.jsx(react.Flex,{border:`1px solid ${s.cards.stroke}`,_hover:{border:`1px solid ${s.purple.metera}`},_focusWithin:{border:`1px solid ${s.purple.metera}`},height:"105px",borderRadius:"1rem",padding:"1.5rem",width:"full",align:"center",children:jsxRuntime.jsxs(react.Flex,{justifyContent:"space-between",alignItems:"center",width:"100%",gap:"8px",children:[jsxRuntime.jsx(react.Flex,{position:"relative",width:"full",flex:1,alignItems:"flex-start",children:jsxRuntime.jsxs(react.Flex,{flexDir:"column",gap:1,children:[jsxRuntime.jsx(react.Box,{fontSize:"0.875rem",color:"#A3A3A3",children:"Send"}),jsxRuntime.jsx(reactNumberFormat.NumericFormat,{className:"mint-input",value:i.gt(0)?i.toString():"",placeholder:e==="mint"?p?"0.0":"ADA":"0.0",valueIsNumericString:!0,onFocus:u,onBlur:y,thousandSeparator:!0,isAllowed:({floatValue:S})=>(S||0)<=1e7,max:1e7,decimalScale:core.MTK_DECIMALS,style:{width:"100%",color:s.offWhite.offWhite400,fontSize:"32px",fontWeight:"500",lineHeight:"32px",letterSpacing:"-0.02em",textAlign:"left",backgroundColor:"transparent",border:"none",borderRadius:0,outline:"none"},onValueChange:S=>{n(new X__default.default(Number(S.floatValue?S.value:0)));}})]})}),jsxRuntime.jsxs(react.Flex,{flexDirection:"column",color:"#A3A3A3",children:[jsxRuntime.jsx(react.Flex,{justify:"right",cursor:"pointer",children:e==="burn"&&jsxRuntime.jsxs(react.Flex,{justify:"right",fontSize:"0.75rem",color:s.neutral[400],fontWeight:400,cursor:"pointer",onClick:k,display:"flex",flexDirection:"row",gap:2,alignItems:"flex-end",children:[jsxRuntime.jsx(wt,{color:"#A3A3A3"}),jsxRuntime.jsx("span",{children:X__default.default(o?.[a]?.toString()||0).div(10**core.MTK_DECIMALS).toFixed(2)})]})}),jsxRuntime.jsxs(react.Flex,{flexDirection:"row",color:"#A3A3A3",align:"center",gap:1,children:[e==="burn"?jsxRuntime.jsx(react.Box,{width:"1.25rem",children:jsxRuntime.jsx(react.Image,{objectFit:"cover",src:r})}):p&&jsxRuntime.jsx(react.Box,{width:"1.25rem",children:jsxRuntime.jsx(react.Image,{objectFit:"cover",src:ir})}),e==="mint"&&!p&&jsxRuntime.jsxs(react.Flex,{justify:"right",fontSize:"0.65rem",color:"#a3a3a3",fontWeight:400,display:"flex",flexDirection:"row",align:"center",flexDir:"column",children:[!i.eq(0,10)&&jsxRuntime.jsx(react.Box,{children:"ADA worth of"}),jsxRuntime.jsxs(react.Flex,{align:"center",children:[d.sort((S,v)=>S.asset.ticker.localeCompare(v.asset.ticker)).slice(0,2).map((S,v)=>jsxRuntime.jsx(react.Box,{width:"2rem",height:"2rem",overflow:"hidden",borderRadius:"50%",ml:"-0.5rem",zIndex:3+v,position:"relative",children:jsxRuntime.jsx(react.Image,{src:S.asset.imageUrl,alt:S.asset.ticker},S.asset.id+v)},S.asset.id+v)),d.length>2&&jsxRuntime.jsx(react.Box,{fontSize:"0.725rem",alignItems:"center",justifyContent:"center",color:"white",background:s.purple.metera,width:"28px",height:"28px",borderRadius:"full",padding:"0.3rem",marginLeft:"-1rem",zIndex:4,children:jsxRuntime.jsxs(react.Flex,{align:"center",height:"full",justify:"center",fontWeight:700,children:["+",d.length-2]})})]})]}),jsxRuntime.jsxs(react.Text,{fontSize:"1.5rem",fontWeight:"500",lineHeight:"32px",letterSpacing:"-0.02em",textAlign:"right",paddingY:"4px",children:[e==="mint"?"":t,e==="mint"&&p&&"ADA"]})]})]})]})}),V=()=>{let S=e==="mint"?l:c;return jsxRuntime.jsx(react.Flex,{border:`1px solid ${s.cards.stroke}`,bg:`${s.cards.background}, linear-gradient(180deg, rgba(139, 92, 246, 0.03) 0%, rgba(255, 255, 255, 0.00) 100%), rgba(27, 27, 30, 0.90)`,_hover:{border:`1px solid ${s.purple.metera}`},_focusWithin:{border:`1px solid ${s.purple.metera}`},height:"105px",borderRadius:"1rem",padding:"1.5rem",width:"full",align:"center",children:jsxRuntime.jsxs(react.Flex,{justifyContent:"space-between",alignItems:"center",width:"100%",gap:"8px",children:[jsxRuntime.jsx(react.Flex,{position:"relative",width:"full",flex:1,alignItems:"flex-start",children:jsxRuntime.jsxs(react.Flex,{flexDir:"column",gap:1,children:[jsxRuntime.jsx(react.Box,{color:"#A3A3A3",children:"Receive"}),jsxRuntime.jsx(reactNumberFormat.NumericFormat,{className:"mint-input",value:S.gt(0)?S.abs().div(10**core.MTK_DECIMALS).toString():"",valueIsNumericString:!0,placeholder:e==="mint"?"0.0":"ADA",thousandSeparator:!0,readOnly:!0,decimalScale:core.MTK_DECIMALS,style:{width:"100%",color:s.offWhite.offWhite400,fontSize:"32px",fontWeight:"500",lineHeight:"32px",letterSpacing:"-0.02em",textAlign:"left",backgroundColor:"transparent",border:"none",borderRadius:0,outline:"none"}})]})}),jsxRuntime.jsxs(react.Flex,{flexDirection:"column",height:"full",justify:"center",color:"#A3A3A3",children:[jsxRuntime.jsxs(react.Flex,{flexDirection:"row",color:"#A3A3A3",gap:1,align:"center",children:[e==="burn"?jsxRuntime.jsxs(react.Flex,{justify:"right",fontSize:"0.65rem",color:"#a3a3a3",fontWeight:400,display:"flex",flexDirection:"row",align:"center",flexDir:"column",children:[!i.eq(0,10)&&jsxRuntime.jsx(react.Box,{children:"ADA worth of"}),jsxRuntime.jsxs(react.Flex,{align:"center",children:[d.sort((v,q)=>v.asset.ticker.localeCompare(q.asset.ticker)).slice(0,2).map((v,q)=>jsxRuntime.jsx(react.Box,{width:"2rem",height:"2rem",overflow:"hidden",borderRadius:"50%",ml:"-0.5rem",zIndex:3+q,position:"relative",children:jsxRuntime.jsx(react.Image,{src:v.asset.imageUrl,alt:v.asset.ticker},v.asset.id+q)},v.asset.id+q)),d.length>2&&jsxRuntime.jsx(react.Box,{fontSize:"0.725rem",alignItems:"center",justifyContent:"center",color:"white",background:s.purple.metera,width:"28px",height:"28px",borderRadius:"full",padding:"0.3rem",marginLeft:"-1rem",zIndex:4,children:jsxRuntime.jsxs(react.Flex,{align:"center",height:"full",justify:"center",fontWeight:700,children:["+",d.length-2]})})]})]}):jsxRuntime.jsx(react.Box,{width:"1.25rem",children:jsxRuntime.jsx(react.Image,{objectFit:"cover",src:e==="mint"?r:ir})}),jsxRuntime.jsx(react.Text,{fontSize:"1.5rem",fontWeight:"500",lineHeight:"32px",letterSpacing:"-0.02em",textAlign:"right",paddingY:"4px",children:e==="mint"?t:""})]}),jsxRuntime.jsx(react.Flex,{justify:"right",children:e==="mint"&&jsxRuntime.jsxs(react.Flex,{justify:"right",fontSize:"0.65rem",color:"#a3a3a3",fontWeight:400,display:"flex",flexDirection:"row",gap:2,align:"center",children:[jsxRuntime.jsx(wt,{color:"#A3A3A3"}),jsxRuntime.jsx("span",{children:X__default.default(o?.[a]?.toString()||0).div(10**core.MTK_DECIMALS).toFixed(2)})]})})]})]})})};return jsxRuntime.jsxs(react.Flex,{flexDirection:"column",alignItems:"center",children:[jsxRuntime.jsxs(react.Flex,{position:"relative",width:"full",alignItems:"center",flexDirection:"column",gap:"0.3rem",children:[I(),jsxRuntime.jsx(react.Flex,{position:"absolute",background:m||"#08040f",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"2rem",height:"2rem",borderRadius:"50%",border:`1px solid ${s.cards.stroke}`,justify:"center",align:"center",cursor:"pointer",_hover:{border:`1px solid ${s.purple.metera}`},onClick:S=>{f(e==="mint"?"burn":"mint"),n(new X__default.default(0));},children:jsxRuntime.jsx(react.Image,{src:go,objectFit:"cover"})}),V()]}),jsxRuntime.jsx(react.Flex,{alignItems:"center",width:"full",gap:"0.5rem",onClick:b,cursor:"pointer",paddingY:"0.5rem",height:"100%",align:"center",children:!i.eq(0,10)&&jsxRuntime.jsxs(react.Flex,{flexDir:"column",gap:"0.5rem",width:"full",children:[jsxRuntime.jsxs(react.Box,{height:"auto",width:"auto",padding:"0rem",border:`1px solid ${s.cards.stroke}`,sx:{cursor:"pointer",border:"2px solid transparent",transition:"border 0.2s, transform 0.2s",position:"relative",borderRadius:"0.75rem"},children:[" ",jsxRuntime.jsx(react.Flex,{align:"center",gap:2,border:`1px solid ${s.cards.stroke}`,borderRadius:"0.75rem",padding:"1rem",fontSize:"0.875rem",width:"100%",justify:"center",bg:"var(--bg-100)",children:p?jsxRuntime.jsx(react.Box,{color:"#39b75a",fontSize:"1rem",fontWeight:500,children:"Mint MTKs by providing ADA. Click for details."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" ",jsxRuntime.jsx(L,{showStatus:!1,status:"confirmed"}),jsxRuntime.jsx(react.Box,{fontSize:"1rem",color:"#39b75a",children:"Assets found in wallet. View breakdown."})]})})]}),e==="mint"&&p?jsxRuntime.jsx(rr,{step:"1",hasBorder:!0}):""]})})]})}var ar=fo;var wo=react$1.forwardRef(({primaryButtonColor:e=s.purple.button100,hoverButtonColor:t=s.purple.button200,...r},o)=>jsxRuntime.jsx(react.Button,{textColor:s.primary.primary50,background:e,fontSize:".875rem",borderRadius:"0.75rem",isDisabled:r.disabled,_hover:{background:t},_active:{bg:"#414a60"},_disabled:{filter:"grayscale(100%)"},ref:o,...r})),sr=wo;var Ro=react$1.forwardRef((e,t)=>jsxRuntime.jsx(react.Button,{ref:t,textColor:s.primary.primary50,fontSize:".875rem",borderRadius:"22px",background:s.gradient.button,border:`1px solid ${s.cards.stroke}, rgba(139, 93, 247, 0.35)`,_hover:{background:s.gradient.button100},_active:{bg:"#414a60"},...e})),lr=Ro;var To="https://bjlavcngusgdszvtjwdr.supabase.co/storage/v1/object/public/Images//powered_white_stacked.png";function Bo(e){let{leftOnclick:t,leftText:r,rightOnclick:o,rightText:i,pb:n="1rem",pt:a="1rem",disableLeft:l=!1,disableRight:c=!1,rightBtnProps:f={},leftBtnProps:b={},poweredBy:p,primaryButtonColor:d,hoverButtonColor:m}=e;return jsxRuntime.jsxs(react.Flex,{gap:"8px",pb:n,pt:a,height:"full",mt:"auto",justify:"space-between",align:"center",children:[jsxRuntime.jsx(react.Flex,{children:r&&jsxRuntime.jsx(lr,{onClick:t,disabled:l,width:"100%",borderRadius:"60rem",border:`1.5px solid ${s.purple.metera}`,fontSize:"0.875rem",color:s.primary.primary50,fontWeight:"700",cursor:l?"not-allowed":"pointer",...b,children:r})}),i&&jsxRuntime.jsx(sr,{flex:"2",width:"100%",onClick:o,disabled:c,cursor:c?"not-allowed":"pointer",...f,primaryButtonColor:d,hoverButtonColor:m,children:i}),p&&jsxRuntime.jsx(react.Flex,{flex:1,children:jsxRuntime.jsx("a",{href:"https://test.meteraprotocol.io/",target:"blank",children:jsxRuntime.jsx("img",{height:"80%",src:To,alt:"Powered by Metera"})})})]})}var Oe=Bo;var G=({children:e,...t})=>jsxRuntime.jsx(react.Td,{overflow:"hidden",fontSize:"1rem",color:"white",cursor:"pointer",borderRadius:"2rem",...t,children:e});var Mo=e=>e<0n?-e:e;function Do(e){let t=new bigRationalTs.BigRational(0n,1n),{fontSize:r="12px"}=e,o=Object.entries(e.formattedState.state.assets).reduce((C,[g,M])=>{let I=new bigRationalTs.BigRational(M,1n).mul(e.formattedState.prices[g]);return C.add(I).reduce()},new bigRationalTs.BigRational(0n,1n)),i=e.formattedState.prices[e.item.asset.id].mul(new bigRationalTs.BigRational(e.formattedState.state.assets[e.item.asset.id],1n)).reduce();e.formattedState.state.assets[e.item.asset.id];i.div(o).mul(new bigRationalTs.BigRational(100n,1n).reduce());let l=Object.entries(e.amountsToModify).reduce((C,[g,M])=>{let I=new bigRationalTs.BigRational(M,1n).mul(e.formattedState.prices[g]);return C.add(I).reduce()},new bigRationalTs.BigRational(0n,1n)),c=e.formattedState.prices[e.item.asset.id].mul(new bigRationalTs.BigRational(e.amountsToModify[e.item.asset.id],1n)).reduce();l.eq(t)?t:c.div(l).mul(new bigRationalTs.BigRational(100n,1n)).reduce();e.amountsToModify[e.item.asset.id];let p=l.add(o).reduce(),d=i.add(c).reduce();p.eq(t)?t:d.div(p).mul(new bigRationalTs.BigRational(100n,1n)).reduce();let y=Mo(e.amountsToModify[e.item.asset.id]||0n).toString(),k=X__default.default((e.amountsToModify[e.item.asset.id]||0n).toString()).lte(X__default.default((e.balance?.[z(e.item.asset)]||0n).toString()));return jsxRuntime.jsxs(react.Tr,{verticalAlign:"middle",fontSize:r,children:[jsxRuntime.jsx(react.Td,{textAlign:"left",align:"center",flexDir:"row",paddingX:"6px",paddingY:"12px",paddingLeft:"10px",width:"fit-content",children:jsxRuntime.jsx(react.Flex,{justify:"left",children:jsxRuntime.jsx(react.Flex,{justify:"left",children:jsxRuntime.jsxs(react.Flex,{flexDir:"row",gap:2,align:"center",children:[jsxRuntime.jsxs(react.Box,{width:"1.75rem",height:"1.75rem",overflow:"hidden",borderRadius:"full",background:s.purple.metera200,children:[jsxRuntime.jsx(react.Image,{boxSize:"100%",objectFit:"cover",src:e.item.asset.imageUrl,alt:e.item.asset.ticker}),"-"]}),jsxRuntime.jsx(react.Box,{fontSize:"0.785rem",color:s.primary.primary50,fontWeight:"600",children:e.item.asset.ticker})]})})})}),jsxRuntime.jsx(react.Td,{align:"center",fontSize:r==="12px"?"1rem":r,paddingX:"6px",paddingY:"12px",children:jsxRuntime.jsx(react.Flex,{gap:2,justify:"flex-end",children:jsxRuntime.jsx(Pt,{color:s.primary.primary50,value:X__default.default(y.toString()),decimals:e.item.asset.decimals})})}),jsxRuntime.jsx(react.Td,{align:"center",fontSize:r==="12px"?"1rem":r,paddingX:"6px",paddingY:"12px",children:jsxRuntime.jsxs(react.Flex,{gap:1,justify:"right",children:[jsxRuntime.jsx(react.Box,{children:"\u20B3"}),jsxRuntime.jsx(Pt,{color:s.primary.primary50,value:N(c).abs(),decimals:0})]})}),e.type==="mint"&&jsxRuntime.jsx(react.Td,{align:"center",fontSize:r==="12px"?"1rem":r,paddingX:"6px",paddingY:"12px",children:jsxRuntime.jsxs(react.Flex,{align:"center",justifyContent:"flex-end",gap:2,children:[k?jsxRuntime.jsx(L,{showStatus:!1,status:"Confirmed"}):jsxRuntime.jsx(react.Tooltip,{sx:{background:s.cards.background,border:"0.5px solid ",borderRadius:"1rem",color:s.offWhite.offWhite400,fontWeight:"600",padding:"1rem",backdropFilter:"blur(30px)"},label:`You don't have enough ${e.item.asset.name}. Click the dot to visit our faucet.`,children:jsxRuntime.jsx("button",{children:jsxRuntime.jsx("a",{href:"/faucet",style:{color:"var(--link-color)"},children:jsxRuntime.jsx(L,{showStatus:!1,status:"Cancelled"})})})}),jsxRuntime.jsx(Pt,{value:X__default.default((e.balance?.[z(e.item.asset)]||0n).toString()),decimals:e.item.asset.decimals,color:s.primary.primary50})]})})]})}var Pt=e=>jsxRuntime.jsx(react.Flex,{flexDir:"column",whiteSpace:"nowrap",children:jsxRuntime.jsx(react.Box,{color:e.color,children:F(e.value.div(10**e.decimals).toString())})}),cr=Do;var Lo=({type:e,portfolioAssets:t,balance:r,amountsToModify:o,formattedState:i,hideBreakdown:n,from:a,to:l,portfolioTicker:c,hasInsufficientToken:f,isModal:b=!0,background:p})=>jsxRuntime.jsxs(react.Flex,{width:"full",height:"full",flexDirection:"column",padding:"1rem",background:p||s.background.modal,children:[jsxRuntime.jsxs(react.Flex,{alignItems:"flex-end",width:"100%",flexDirection:"column",gap:1,padding:"8px",children:[jsxRuntime.jsx(react.IconButton,{"aria-label":"Close",borderRadius:"100%",fill:"#a78bfa",color:"#a78bfa;",size:"sm",onClick:n,background:"transparent",icon:jsxRuntime.jsx(icons.CloseIcon,{}),alignSelf:"flex-end"}),jsxRuntime.jsxs(react.Flex,{width:"100%",justifyContent:"center",gap:"1rem",children:[jsxRuntime.jsxs(react.Flex,{fontSize:"24px",lineHeight:"24px",gap:"4px",children:[jsxRuntime.jsx(react.Text,{fontWeight:"500",letterSpacing:"-0.02em",color:"#A3A3A3",children:e==="mint"?"ADA":c}),F(a.abs().toString())]}),jsxRuntime.jsx(index_js.MdSwapHoriz,{}),jsxRuntime.jsxs(react.Flex,{fontSize:"24px",lineHeight:"24px",gap:"4px",children:[jsxRuntime.jsx(react.Text,{fontWeight:"500",letterSpacing:"-0.02em",color:"#A3A3A3",children:e==="mint"?c:"ADA"}),F(l.abs().div(10**6).toFixed(6),4)]})]}),jsxRuntime.jsxs(react.Flex,{paddingX:"0.5rem",gap:2,width:"100%",height:"2.5rem",justifyContent:"center",alignItems:"center",children:[jsxRuntime.jsx(L,{showStatus:!1,status:f?"Insufficient":"Confirmed"}),jsxRuntime.jsx(react.Text,{fontSize:"14px",fontWeight:"400",lineHeight:"20px",textAlign:"left",children:"Tokens breakdown"})]})]}),jsxRuntime.jsx(react.Box,{overflowY:"auto",borderRadius:"0.75rem",width:"full",paddingTop:"0.15rem",children:jsxRuntime.jsx(react.Flex,{gap:3,overflow:"auto",children:jsxRuntime.jsx(react.TableContainer,{overflowY:"auto",sx:{"&::-webkit-scrollbar":{width:"0px"},"&::-webkit-scrollbar-track":{background:"none"},"&::-webkit-scrollbar-thumb":{background:"none"},"&::-webkit-scrollbar-thumb:hover":{background:"none"}},children:jsxRuntime.jsxs(react.Table,{variant:"unstyled",sx:{tableLayout:"fixed"},children:[jsxRuntime.jsx(react.Thead,{position:"sticky",top:0,left:0,zIndex:1,borderBottom:"none",children:jsxRuntime.jsxs(react.Tr,{children:[jsxRuntime.jsx(G,{textAlign:"left",paddingX:"8px",paddingY:"1rem",paddingLeft:"10px",fontSize:"0.875rem",color:s.neutral[400],borderTopLeftRadius:"full",children:"Name"}),jsxRuntime.jsx(G,{textAlign:"right",paddingX:0,paddingY:"1rem",fontSize:"0.875rem",color:s.neutral[400],children:jsxRuntime.jsxs(react.Flex,{gap:2,children:[jsxRuntime.jsx(react.Box,{children:"Amount"}),jsxRuntime.jsx(react.Tooltip,{sx:{background:s.cards.background,border:`0.5px solid ${s.cards.stroke}`,borderRadius:"1rem",color:s.offWhite.offWhite400,fontWeight:"600",padding:"1rem",backdropFilter:"blur(30px)"},label:`This is the amount of tokens you${e==="mint"?" need to deposit into":"'ll receive from"} the instrument. `,children:jsxRuntime.jsx("button",{children:jsxRuntime.jsx(Ue,{})})})]})}),jsxRuntime.jsx(G,{textAlign:"right",paddingX:0,paddingY:"1rem",fontSize:"0.875rem",color:s.neutral[400],children:jsxRuntime.jsxs(react.Flex,{width:"full",justify:"center",gap:2,children:[jsxRuntime.jsx(react.Box,{children:"Worth"}),jsxRuntime.jsx(react.Tooltip,{sx:{background:s.cards.background,border:`0.5px solid ${s.cards.stroke}`,borderRadius:"1rem",color:s.offWhite.offWhite400,fontWeight:"600",padding:"1rem",backdropFilter:"blur(30px)"},label:"Value in ADA of each asset",children:jsxRuntime.jsx("button",{children:jsxRuntime.jsx(Ue,{})})})]})}),e==="mint"&&jsxRuntime.jsx(G,{textAlign:"right",paddingX:0,paddingY:"1rem",fontSize:"0.875rem",color:s.neutral[400],paddingRight:"6px",children:"Balance"})]})}),jsxRuntime.jsx("tbody",{style:{maxHeight:"286px"},children:t.sort((d,m)=>d.asset.ticker.localeCompare(m.asset.ticker)).map((d,m)=>jsxRuntime.jsx(cr,{item:d,type:e,balance:r,amountsToModify:o,formattedState:i,...b?{}:{fontSize:"12.5px"}},d.asset.id+m))})]})})})})]});var pr=Lo;var $o=mr__default.default.default||mr__default.default,Ko=$o(react.ModalContent)`
@property --animated-border {
syntax: '<angle>';
inherits: true;
initial-value: 0turn;
}
`,ur=({children:e,minHeight:t="15rem",minWidth:r="50%",...o})=>jsxRuntime.jsxs(react.Modal,{isCentered:!0,...o,children:[jsxRuntime.jsx(react.ModalOverlay,{bg:"#171717B3"}),jsxRuntime.jsx(Ko,{background:s.cards.background,minHeight:t,minWidth:r,padding:"0rem",borderRadius:"1.25rem",border:`1px solid ${s.cards.stroke}`,sx:{cursor:"pointer",border:"2px solid transparent",transition:"border 0.2s, transform 0.2s",borderRadius:"10px !important","--animated-border":s.animatedBorder.initialValue,background:`
conic-gradient(
from var(--animated-border),
#171717a3,
#171717a3 5%,
#171717a3 60%,
#171717a3 95%
)
padding-box,
conic-gradient(
from var(--animated-border),
transparent 25%,
#6d28d9,
#a78bfa 99%,
transparent
)
border-box`,animation:`${s.animatedBorder.bgSpin} 3s linear infinite`},children:jsxRuntime.jsx(react.ModalBody,{padding:0,children:e})})]});var kt=({title:e="Metera Order in Progress",description:t="Confirm the transaction in your wallet",isSwap:r,background:o})=>jsxRuntime.jsxs(react.Flex,{flexDir:"column",gap:"2rem",minHeight:"264px",align:"center",justify:"center",padding:"24px",background:o||s.background.modal,borderRadius:"10px",width:"100%",color:s.offWhite.offWhite400,children:[jsxRuntime.jsxs(react.Flex,{flexDir:"column",gap:"1rem",align:"center",justify:"center",padding:"24px",borderRadius:"0.75rem",width:"100%",cursor:"default",children:[jsxRuntime.jsx(react.Text,{fontSize:"18px",fontWeight:"500",lineHeight:"28px",textAlign:"center",children:e}),jsxRuntime.jsx(react.Flex,{children:r?jsxRuntime.jsx(react.Flex,{flexDir:"column",width:"25rem",gap:"1rem",children:jsxRuntime.jsx(react.Flex,{justify:"center",color:s.neutral[400],fontSize:"16px",fontWeight:400,lineHeight:"24px",textAlign:"center",children:t})}):jsxRuntime.jsx(react.Flex,{justify:"center",color:s.neutral[400],fontSize:"16px",fontWeight:400,lineHeight:"24px",textAlign:"center",children:t})})]}),jsxRuntime.jsxs(react.Flex,{fontSize:"12px",fontWeight:400,lineHeight:"20px",textAlign:"left",gap:1,children:[jsxRuntime.jsx(react.Text,{as:"span",children:"Do you need help?"}),jsxRuntime.jsx(react.Link,{href:"https://discord.com/invite/Ws5Z5ZACme",color:s.purple.button100,target:"blank",children:"Contact support"})]})]});function Zo(e){return jsxRuntime.jsx(ur,{...e.disc,minWidth:"376px",minHeight:"274px",children:jsxRuntime.jsx(kt,{title:e.title,description:e.description,isSwap:e.isSwap})})}var fr=Zo;var br=({children:e,minHeight:t,maxWidth:r,p:o="",...i})=>jsxRuntime.jsxs(react.Modal,{isCentered:!0,...i,children:[jsxRuntime.jsx(react.ModalOverlay,{bg:"#171717B3"}),jsxRuntime.jsx(react.ModalContent,{background:s.background.purple200,minHeight:t||"23rem",maxWidth:r||"40%",borderRadius:"1.25rem",border:`1px solid ${s.cards.stroke}`,sx:{backdropFilter:"blur(60px)"},children:jsxRuntime.jsx(react.ModalBody,{p:o||0,children:e})})]});var an="https://bjlavcngusgdszvtjwdr.supabase.co/storage/v1/object/public/Images//powered_white_stacked.png",vt=({onClose:e,title:t="Transaction Submitted",description:r="Please allow some minutes for your transaction to process on-chain",route:o="orders",routeText:i="Order",background:n})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs(react.Flex,{background:n||s.background.modal,flexDir:"column",width:"full",height:"full",maxWidth:"376px",minHeight:"274px",gap:"1.5rem",padding:"1rem 2.5rem",alignItems:"center",mx:"auto",children:[jsxRuntime.jsx(react.Box,{children:jsxRuntime.jsx(react.Image,{src:an})}),jsxRuntime.jsxs(react.Flex,{flexDirection:"column",gap:"5px",width:"100%",alignItems:"center",children:[jsxRuntime.jsx(react.Text,{fontSize:"18px",fontWeight:"500",lineHeight:"28px",textAlign:"center",color:s.offWhite.offWhite400,children:t}),jsxRuntime.jsx(react.Text,{color:s.neutral[400],fontSize:"16px",fontWeight:400,lineHeight:"24px",textAlign:"center",children:r})]}),jsxRuntime.jsx(Oe,{poweredBy:!1,rightText:`View ${i}`,rightOnclick:()=>{window.open(`https://preprod.meteraprotocol.io/me/${o}`,"_blank");},leftText:"Close",leftOnclick:e})]})});function sn({disc:e,onClose:t,title:r,description:o,route:i,routeText:n}){return jsxRuntime.jsx(br,{...e,isOpen:e.isOpen,maxWidth:"376px",minHeight:"274px",children:jsxRuntime.jsx(vt,{onClose:t})})}var Sr=sn;function pn({inputValue:e,portfolio:t,type:r}){let o=react$1.useMemo(()=>Ht(t),[t]),{amountsPerAsset:i,mintedMicroMTK:n,userReceiveMTK:a,fees:l,withdrawLovelace:c,withdrawUserLvc:f}=react$1.useMemo(()=>{let b=Ee(e),p=Nt(t),d=r==="mint"?b:b.negate().mul(new bigRationalTs.BigRational(BigInt(10**core.MTK_DECIMALS),1n)).mul(p).reduce(),m=Gt(d,o),u=core.computeFees({portfolioState:{batcherFee:X__default.default(t.batcherFee.toString()),entryFee:X__default.default(t.entryFee.toString()),exitFee:X__default.default(t.exitFee.toString()),platformFee:X__default.default(t.platformFee.toString()),microMtkPrice:N(p).multipliedBy(10**6)},amount:N(d.mul(new bigRationalTs.BigRational(BigInt(10**6),1n)).reduce()),type:r}),y=N(d).multipliedBy(10**6).negated(),k=e.div(N(p));return {amountsPerAsset:m,mintedMicroMTK:k,userReceiveMTK:k.minus(u.userFee),withdrawLovelace:y,withdrawUserLvc:y.minus(u.userFee.multipliedBy(N(p)).multipliedBy(10**6)),fees:u}},[e,t,r]);return {amountsPerAsset:i,fees:l,formattedState:o,mintedMicroMTK:n,userReceiveMTK:a,withdrawLovelace:c,withdrawUserLvc:f}}var Rr=pn;function un({children:e,background:t=s.background.modal,width:r="530px",color:o=s.offWhite.offWhite400}){return jsxRuntime.jsx(react.Box,{minWidth:"530px",background:t,transition:"0.25s",borderRadius:"1.25rem",border:`1px solid ${s.cards.stroke}`,sx:{backdropFilter:"blur(60px)"},width:r,padding:"1rem",height:"fit-content",color:o,children:e})}var Ar=un;var xn=e=>e<0n?-e:e;function hn(e){let t=new bigRationalTs.BigRational(0n,1n),o=Object.entries(e.formattedState.state.assets).reduce((U,[te,Ae])=>{let j=new bigRationalTs.BigRational(Ae,1n).mul(e.formattedState.prices[te]);return U.add(j).reduce()},new bigRationalTs.BigRational(0n,1n)),i=e.formattedState.prices[e.item.asset.id].mul(new bigRationalTs.BigRational(e.formattedState.state.assets[e.item.asset.i