PageSourceSearch

https://trade.zipmex.com/_next/static/chunks/181-f9c8ce6f1ab77df3.js

js zipmex.com collected 2026-09-28 06:42:23 UTC 28,587 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[181],{181:(e,t,r)=>{r.r(t),r.d(t,{default:()=>X});var a=r(42073),s=r(77672),n=r(75387),l=r(22441),i=r(24270),o=r(48120),c=r(26653),d=r(41831),u=r(29334),m=r(82633),x=r(39868),f=r(90991),h=r(28120),p=r(25045),g=r(13741),v=r(17797),b=r(95431),w=r(14790),y=r(16556),j=r.n(y),N=r(99047),S=r(48386),k=r(27429),C=r(32995),A=r(38395),T=r(84492),E=r(36387),F=r(89900),I=r(47328),M=r(99462),D=r(4323),R=r(44466),U=r(84652),O=r(91386),q=r(81988);let B=e=>Number.isFinite(e)?e>0&&e<1e-4?e.toLocaleString("en-US",{maximumSignificantDigits:4}):e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00",z=e=>{var t,r,s,n;let{slippage:l,defaultInputMint:y,defaultOutputMint:z}=e,{connection:P}=(0,d.w)(),{publicKey:J,connected:$,signTransaction:K,signMessage:L,wallet:W}=(0,u.v)(),_=!!(null==W||null==(r=W.adapter)||null==(t=r.supportedTransactionVersions)?void 0:t.has(0)),H=!!$&&!!W&&!_,V=(0,U.um)(),{tokenMap:X}=(0,T.Ew)(),Q=(0,I.A)(),{toast:Y}=(0,E.dj)(),{getTokenPrice:Z,authenticateTriggerOnce:G,requestTriggerAuthChallenge:ee,verifyTriggerAuth:et,ensureTriggerVault:er,craftTriggerDeposit:ea,createTriggerDcaOrder:es}=(0,F.X)(),en=(0,g.useCallback)(async()=>{if(!J)throw Error("Wallet not connected");let e=J.toBase58();return G(e,async()=>{if(!L)throw Error("This wallet does not support message signing required for recurring orders.");let t=await ee({walletPubkey:e,type:"message"});if(!t.challenge)throw Error("Trigger challenge was missing challenge text.");V.signing("Approve the signature request in your wallet");let r=await L(new TextEncoder().encode(t.challenge)),a=await et({type:"message",walletPubkey:e,signature:j().encode(r)});if(!(null==a?void 0:a.token))throw Error("Failed to authenticate with the order service.");return a.token})},[J,G,L,ee,et,V]),el=(0,g.useCallback)(async(e,t)=>{try{return await t()}catch(r){let t=r instanceof Error?r.message:String(null!=r?r:"");throw Error("".concat(e,": ").concat(t||"request failed"))}},[]),ei=(0,g.useMemo)(()=>Array.from(X.values()),[X]),{data:eo}=(0,i.CJ)(P,J),{holdings:ec,nativeBalance:ed}=(0,R.H)(J),[eu,em]=(0,g.useState)(null),[ex,ef]=(0,g.useState)(null),[eh,ep]=(0,g.useState)("110"),[eg,ev]=(0,g.useState)(""),eb=(0,g.useMemo)(()=>(0,v.DW)(null==eu?void 0:eu.address,{nativeSol:ed,tokens:ec}),[null==eu?void 0:eu.address,ed,ec]),ew=!!J&&(0,v.UX)(eh,null==eu?void 0:eu.decimals,eb),[ey,ej]=(0,g.useState)(1),[eN,eS]=(0,g.useState)("hour"),[ek,eC]=(0,g.useState)(2),[eA,eT]=(0,g.useState)(!1),[eE,eF]=(0,g.useState)(!1),[eI,eM]=(0,g.useState)(null),[eD,eR]=(0,g.useState)(null);(0,g.useEffect)(()=>{(async()=>{try{if(eu){let e=await Z(eu.address);eM(e)}else eM(null);if(ex){let e=await Z(ex.address);eR(e)}else eR(null)}catch(e){console.error("Failed to fetch token price",e)}})()},[eu,ex,Z]),(0,g.useCallback)(e=>{var t,r,a,s;if(!(null==e?void 0:e.address))return"0";if(e.address===c.FX.toBase58())return(null!=(s=null==eo?void 0:eo.uiAmount)?s:0).toString();let n=null==Q||null==(a=Q.find(t=>{var r;return(null==(r=t.token)?void 0:r.symbol)===e.symbol}))||null==(r=a.account)||null==(t=r.account)?void 0:t.amount;return n?(Number(n)/Math.pow(10,e.decimals)).toString():"0"},[eo,Q]),(0,g.useCallback)(e=>"0.00",[Q]);let{inputPriceInUSD:eU,outputPriceInUSD:eO,perOrderSellAmount:eq,perOrderUsdValue:eB,estimatedReceivePerOrder:ez,totalEstimatedReceive:eP,isBelowMinimum:eJ}=(0,g.useMemo)(()=>{var e,t;let r=parseFloat(eh)||0,a=null!=(e=null!=eI?eI:0)?e:0,s=null!=(t=null!=eD?eD:0)?t:0,n=ek>0?r/ek:0,l=n*a,i=0;a&&s&&s>0&&(i=l/s);let o=i*ek;return{inputPriceInUSD:a*r,outputPriceInUSD:o*s,perOrderSellAmount:n,perOrderUsdValue:l,estimatedReceivePerOrder:i,totalEstimatedReceive:o,isBelowMinimum:a>0&&l<10&&r>0}},[eh,eI,eD,ek]);return(0,g.useEffect)(()=>{if(ei.length>0&&(!eu||!ex)){let e=y?ei.find(e=>e.address===y):ei.find(e=>"USDC"===e.symbol),t=z?ei.find(e=>e.address===z):ei.find(e=>"SOL"===e.symbol);e&&!eu&&em(e),t&&!ex&&ef(t)}},[ei,eu,ex,y,z]),(0,a.jsxs)("div",{className:"w-full flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"w-full bg-[var(--c-surface-1)] rounded-md border border-[var(--c-border)] p-4",children:[(0,a.jsxs)("div",{className:"mb-1",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,a.jsx)(C.J,{className:"text-xs text-muted-foreground font-normal",children:"You pay"}),(0,a.jsx)(q.T,{jupiterHoldings:ec,token:eu,setInput:ep,nativeBalance:ed,isSend:!0})]}),(0,a.jsxs)("div",{className:"flex justify-between items-start gap-3",children:[(0,a.jsx)(N.I,{tokenInfo:eu,setCoin:em,isInput:!0,showWalletSection:!0}
1),(0,a.jsxs)("div",{className:"flex flex-col items-end flex-1",children:[(0,a.jsx)(k.p,{type:"number",placeholder:"0.00",value:eh,onChange:e=>{let t=e.target.value;(""===t||parseFloat(t)>=0)&&ep(t)},className:"border-0 bg-transparent ".concat(eh&&eh.length>8?eh.length>12?"text-title sm:text-lg":"text-lg sm:text-title":"text-display sm:text-display"," font-semibold text-text text-right placeholder:text-text/30 p-0 h-auto w-full font-inter leading-tight [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none")}),eU>0&&(0,a.jsxs)("div",{className:"text-sm text-[var(--c-text-2)] mt-1",children:["$",eU.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})]}),(0,a.jsxs)("div",{className:"relative my-2",children:[(0,a.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,a.jsx)("div",{className:"w-full border-t border-border"})}),(0,a.jsx)("div",{className:"relative flex justify-center",children:(0,a.jsx)(S.$,{onClick:()=>{em(ex),ef(eu),ep(eg),ev(eh)},disabled:!eu||!ex,size:"icon",className:"h-8 w-8 rounded-full bg-[var(--c-surface-2)] hover:bg-[var(--c-surface-3)] border border-borderStrong disabled:opacity-50",children:(0,a.jsx)(m.A,{className:"h-4 w-4 text-primary"})})})]}),(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,a.jsx)(C.J,{className:"text-xs text-muted-foreground font-normal",children:"You receive"}),(0,a.jsx)(q.T,{jupiterHoldings:ec,token:ex,setInput:ev,nativeBalance:ed,isSend:!1})]}),(0,a.jsxs)("div",{className:"flex justify-between items-start gap-3",children:[(0,a.jsx)(N.I,{tokenInfo:ex,setCoin:ef,isInput:!1,showWalletSection:!0}),(0,a.jsxs)("div",{className:"flex flex-col items-end flex-1",children:[(0,a.jsx)("span",{className:"".concat((()=>{let e=B(eP);return e.length>8?e.length>12?"text-title sm:text-lg":"text-lg sm:text-title":"text-display sm:text-display"})()," font-semibold text-text text-right w-full font-inter leading-tight truncate"),children:B(eP)}),eO>0&&(0,a.jsxs)("div",{className:"text-sm text-[var(--c-text-2)] mt-1",children:["$",eO.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})]})]}),(0,a.jsx)("div",{className:"w-full bg-[var(--c-surface-1)] rounded-md border border-[var(--c-border)] p-4",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)(C.J,{className:"text-xs text-muted-foreground font-normal mb-2 block text-left",children:"Frequency"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(k.p,{type:"number",value:ey,onChange:e=>ej(parseInt(e.target.value)||1),className:"w-20 h-10 bg-background border-none p-2 text-text text-base font-semibold rounded-lg [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),(0,a.jsxs)(A.l6,{value:eN,onValueChange:eS,children:[(0,a.jsx)(A.bq,{className:"h-10 flex-1 text-text text-base font-medium border-none bg-inner",children:(0,a.jsx)(A.yv,{})}),(0,a.jsxs)(A.gC,{children:[(0,a.jsx)(A.eb,{value:"minute",children:"Minute"}),(0,a.jsx)(A.eb,{value:"hour",children:"Hour"}),(0,a.jsx)(A.eb,{value:"day",children:"Day"})]})]})]})]}),(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)(C.J,{className:"text-xs text-muted-foreground font-normal mb-2 block text-left",children:"Number of orders"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(k.p,{type:"number",min:2,value:ek,onChange:e=>eC(Math.max(2,parseInt(e.target.value)||2)),className:"w-20 h-10 bg-background border-none p-2 text-text text-base font-semibold rounded-lg [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),(0,a.jsx)("span",{className:"text-muted-foreground text-base font-medium",children:"orders"})]})]})]})}),H&&(0,a.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 rounded-xl bg-[var(--c-warn-4)] border border-[var(--c-warn-3)]",children:[(0,a.jsx)(x.A,{className:"w-4 h-4 text-[var(--c-warn)] flex-shrink-0 mt-0.5"}),(0,a.jsxs)("p",{className:"text-xs text-[var(--c-warn)]",children:[(null==W||null==(s=W.adapter)?void 0:s.name)||"This wallet"," cannot sign the transaction type recurring orders use. Connect Phantom, Solflare or Ledger to place one — swaps still work here."]})]}),eJ&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-[var(--c-warn-4)] border border-[var(--c-warn-3)]",children:[(0,a.jsx)(x.A,{className:"w-4 h-4 text-[var(--c-warn)] flex-shrink-0"}),(0,a.jsxs)("p",{className:"text-xs text-[var(--c-warn)]",children:["Minimum $",10," per order required. Current: $",eB.toFixed(2),"/order"]})]}),$&&J?(0,a.jsx)(S.$,{onClick:async()=>{var e,t,r;let a=!1;try{if(!eu||!ex||!J)return void Y({variant:"destructive",title:"Missing data",description:"Please select tokens and ensure your wallet is connected."});if(!eh||0>=parseFloat(eh))return void Y({variant:"destructive",title:"Invalid amount",description:"Enter a valid amount to pay."});eT(!0);let r=Math.round(parseFloat(eh)*Math.pow(10,eu.decimals)),s=ey*(null!=(e=({minute:60,hour:3600,day:86400})[eN])?e:60);if(s<60||s>31536e3)throw Error("The interval between buys must be between 1 minute and 1 year.");let n=J.toBase58(),l=await el("Order service sign-in failed",()=>en());await el("Could not open your order account",()=>er(l));let i=await el("Could not prepare the deposit",()=>ea({inputMint:eu.address,outputMint:ex.address,userAddress:n,amount:String(r),orderType:"dca"},l));if(!(null==i?void 0:i.transaction))throw Error((null==i?void 0:i.error)||"Jupiter did not return a transaction for this order. Try a different amount or token pair.");if(!K)throw Error("This wallet does not support transaction signing required for recurring orders.");if(!_)throw Error("".concat((null==W||null==(t=W.adapter)?void 0:t.name)||"This wallet"," cannot sign versioned transactions, which Jupiter requires for recurring orders. Connect Phantom, Solflare or Ledger."));let c=new Uint8Array(w.Buffer.from(i.transaction,"base64")),d=b.VersionedTransaction.deserialize(c);V.signing();let u=await (0,o.Q5)(K(d)),m=w.Buffer.from(u.serialize()).toString("base64");V.submitting("Setting up ".concat(ek," buys of ").concat(ex.symbol," with ").concat(eu.
1symbol,"…"));let x=await P.sendRawTransaction(u.serialize(),{skipPreflight:!1,maxRetries:3});a=!0;let f=await el("Could not create the order",()=>es({depositRequestId:i.requestId,depositSignedTx:m,userPubkey:n,inputMint:eu.address,outputMint:ex.address,inputAmount:String(r),orderCount:ek,intervalSeconds:s},l)),h=(null==f?void 0:f.txSignature)||(null==f?void 0:f.signature)||x,p=null==f?void 0:f.status;if(!h||p&&"Success"!==p)throw Error((null==f?void 0:f.error)||"Jupiter did not confirm the order. Check the Orders tab before retrying.");V.success("Recurring Order Placed","".concat(ek," buys of ").concat(ex.symbol," scheduled, ").concat(eh," ").concat(eu.symbol," total"),h),ep(""),ev("")}catch(e){console.error("Failed to create recurring order",e),(0,O.reportTxFailure)("swap","dca_order",e,{wallet:null==J?void 0:J.toBase58()}),a?V.failure(Error("We lost contact after sending your order to Jupiter, so we cannot confirm it. Check the Orders tab before trying again — creating it twice would schedule two sets of buys. ".concat(null!=(r=null==e?void 0:e.message)?r:"").trim()),null,"Order status unknown"):V.failure(e)}finally{eT(!1)}},disabled:eA||!eu||!ex||!eh||0>=parseFloat(eh)||!J||eJ||H||ew,className:"w-full h-14 text-base font-semibold rounded-xl mt-2",children:"signing"===V.phase?(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)(f.A,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Approve in Wallet…"]}):"submitting"===V.phase||eA?(0,a.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)(f.A,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Submitting…"]}):ew?"Insufficient ".concat(null!=(n=null==eu?void 0:eu.symbol)?n:"balance"):"Place Recurring Order"}):(0,a.jsxs)("div",{className:"flex justify-center items-center w-full mt-2",children:[(0,a.jsx)("div",{className:"block sm:hidden w-full",children:(0,a.jsx)(M.A,{label:"Connect Wallet",buttonClassName:"w-full h-14 rounded-xl text-base font-semibold bg-primary text-black hover:bg-primary/90 transition-all duration-200 border-none"})}),(0,a.jsx)("div",{className:"hidden sm:block w-full",children:(0,a.jsx)(D.A,{buttonClassName:"w-full h-14 rounded-xl text-base font-semibold bg-primary text-black hover:bg-primary/90 transition-all duration-200 border-none"})})]}),(0,a.jsxs)("div",{className:"w-full bg-[var(--c-surface-1)] rounded-md border border-[var(--c-border)] pt-0 pb-3",children:[(0,a.jsxs)("button",{onClick:()=>eF(!eE),className:"w-full min-h-touch flex justify-between items-center text-xs hover:opacity-80 transition-opacity px-4",children:[(0,a.jsx)("span",{className:"text-text font-medium",children:eu&&ex&&eP>0?"Total Estimated: ".concat(B(eP)," ").concat(ex.symbol):"Order Summary"}),eE?(0,a.jsx)(h.A,{className:"h-4 w-4 text-muted-foreground"}):(0,a.jsx)(p.A,{className:"h-4 w-4 text-muted-foreground"})]}),eE&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-muted-foreground/20 space-y-2 px-4",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Total to sell"}),(0,a.jsxs)("span",{className:"text-text font-medium",children:[eh||0," ",null==eu?void 0:eu.symbol]})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Per order"}),(0,a.jsxs)("span",{className:"text-text font-medium",children:[B(eq)," ",null==eu?void 0:eu.symbol]})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Estimated per order"}),(0,a.jsxs)("span",{className:"text-text font-medium",children:[B(ez)," ",null==ex?void 0:ex.symbol]})]}),eh&&parseFloat(eh)>0&&(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Estimated completion"}),(0,a.jsx)("span",{className:"text-text font-medium",children:(e=>e.toLocaleDateString("en-US",{day:"2-digit",month:"short",year:"numeric"})+" at "+e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}))(new Date(Date.now()+ek*ey*("minute"===eN?60:"hour"===eN?3600:86400)*1e3))})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Slippage"}),(0,a.jsx)("span",{className:"text-text font-medium",children:"Auto (set by the router)"})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"ZIPMEX fee"}),(0,a.jsx)("span",{className:"text-text font-medium",children:"0%"})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground leading-snug",children:"The router charges its own fee on each executed order at its standard rate."})]})]})]})};var P=r(10429),J=r(67911),$=r(27481),K=r(70665),L=r(88829),W=r(36582),_=r(79954);let H=()=>{let{getRecurringOrders:e,cancelRecurringOrder:t,withdrawFromPriceOrder:r,executeRecurringOrder:s,getTriggerJwt:n,getTriggerDcaOrders:i,initCancelTriggerDca:c,confirmCancelTriggerDca:d,authenticateTriggerOnce:m,requestTriggerAuthChallenge:x,verifyTriggerAuth:f}=(0,F.X)(),[h,p]=(0,g.useState)(!1),{toast:v}=(0,E.dj)(),[y,N]=(0,g.useState)([]),[k,C]=(0,g.useState)(!1),[A,I]=(0,g.useState)(null),[M,D]=(0,g.useState)(null),{publicKey:R,connected:q,signTransaction:B,signMessage:z}=(0,u.v)(),H=(0,U.um)(),V=(0,g.useRef)(H);V.current=H;let X=(0,g.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Approve signature request in your wallet";if(!R)throw Error("Wallet not connected");let t=R.toBase58();return m(t,async()=>
1{if(!z)throw Error("This wallet does not support message signing.");let r=await x({walletPubkey:t,type:"message"});if(!r.challenge)throw Error("Trigger challenge was missing challenge text.");V.current.signing(e);try{let e=await z(new TextEncoder().encode(r.challenge)),a=await f({type:"message",walletPubkey:t,signature:j().encode(e)});if(!(null==a?void 0:a.token))throw Error("Failed to authenticate with the order service.");return a.token}finally{V.current.reset()}})},[R,m,z,x,f]),Q=(0,g.useCallback)(async()=>{try{await X("Approve signature request in your wallet to view recent orders"),await ee()}catch(t){var e;console.warn("Trigger v2 authorisation declined",t),(0,O.reportFriction)("trigger_auth_declined",String(null!=(e=null==t?void 0:t.message)?e:t).slice(0,120),{severity:"info"})}},[X]),{tokenList:Y}=(0,T.Ew)(),[Z,G]=(0,g.useState)(!1),ee=async()=>{var t,r,a;if(!R)return;let s=R.toBase58(),l=(0,J.Nh)("dca",s);l&&l.length?(N(l),C(!1)):C(!0),I(null);try{let a=n(s);p(!a);let[l,o,c,d]=await Promise.all([e(s,{orderStatus:"active",recurringType:"time",includeFailedTx:!0}),e(s,{orderStatus:"history",recurringType:"time",includeFailedTx:!0}),a?i({state:"active",limit:100,sort:"updated_at",dir:"desc"},a).catch(e=>{var t;return console.warn("Trigger v2 active DCA unavailable",e),(0,O.reportApiFailure)("/api/jupiter/trigger/dca/active",0,{meta:{error:String(null!=(t=null==e?void 0:e.message)?t:e).slice(0,160)}}),null}):Promise.resolve(null),a?i({state:"past",limit:100,sort:"updated_at",dir:"desc"},a).catch(e=>{var t;return console.warn("Trigger v2 past DCA unavailable",e),(0,O.reportApiFailure)("/api/jupiter/trigger/dca/past",0,{meta:{error:String(null!=(t=null==e?void 0:e.message)?t:e).slice(0,160)}}),null}):Promise.resolve(null)]),u=Array.isArray(l)?l:(null==l?void 0:l.time)||[],m=Array.isArray(o)?o:(null==o?void 0:o.time)||[],x=[...null!=(t=null==c?void 0:c.orders)?t:[],...null!=(r=null==d?void 0:d.orders)?r:[],...u,...m];N(x),(0,J.UY)("dca",s,x)}catch(e){I((null==e?void 0:e.message)||"Failed to fetch DCA orders"),(0,O.reportDeadEnd)("dca_orders","list_failed",{meta:{error:String(null!=(a=null==e?void 0:e.message)?a:e).slice(0,160)}})}finally{C(!1)}};(0,g.useEffect)(()=>{R&&ee()},[R]);let et=e=>{var t;let r=null==Y?void 0:Y.find(t=>t.address===e);return null!=(t=null==r?void 0:r.symbol)?t:"".concat(e.slice(0,4),"…").concat(e.slice(-4))},er=e=>{let t=null==Y?void 0:Y.find(t=>t.address===e);return"number"==typeof(null==t?void 0:t.decimals)?t.decimals:void 0},ea=(e,t)=>{if(null==t)return null;let r=parseFloat(String(null!=e?e:"0"));return Number.isFinite(r)?r/10**t:null},es=async e=>{if(!R)return;D(e.key);let t=!1;try{if(!B)throw Error("This wallet does not support transaction signing.");let r=await X(),a=await c(e.key,r);if(t=!0,!(null==a?void 0:a.transaction))throw Error((null==a?void 0:a.error)||"Jupiter did not return a withdrawal transaction.");let s=new Uint8Array(w.Buffer.from(a.transaction,"base64")),n=b.VersionedTransaction.deserialize(s);V.current.signing("Approve the withdrawal in your wallet to cancel");let l=await (0,o.Q5)(B(n));V.current.submitting("Cancelling and returning your remaining funds…");let i=await d(e.key,{signedTransaction:w.Buffer.from(l.serialize()).toString("base64"),cancelRequestId:a.cancelRequestId},r);V.current.success("Order Cancelled","The remaining balance has been returned to your wallet.",(null==i?void 0:i.txSignature)||(null==i?void 0:i.signature)||null),await ee()}catch(e){if((0,O.reportTxFailure)("swap","dca_cancel",e,{wallet:null==R?void 0:R.toBase58()}),t){var r;V.current.failure(Error("The order was stopped but the refund was not completed. Open this tab again and retry the cancel to claim it. ".concat(null!=(r=null==e?void 0:e.message)?r:"").trim()),null,"Refund not completed")}else V.current.failure(e,null,"Could not cancel the order")}finally{D(null)}},en=async e=>{if(R){D(e.orderKey);try{if(!B)throw Error("This wallet does not support transaction signing required for recurring orders.");let r=await t({user:R.toBase58(),order:e.orderKey});if(null==r?void 0:r.transaction)try{let e=new Uint8Array(w.Buffer.from(r.transaction,"base64")),t=b.VersionedTransaction.deserialize(e),a=await (0,o.Q5)(B(t)),n=w.Buffer.from(a.serialize()).toString("base64");await s({requestId:r.requestId,signedTransaction:n}),v({title:"Order Cancelled",description:"Order cancelled successfully."}),await ee()}catch(e){throw console.error("Transaction failed:",e),e}}catch(e){v({variant:"destructive",title:"Cancel Failed",description:(null==e?void 0:e.message)||"Unable to cancel order"})}finally{D(null)}}},el=async e=>{if(R){D(e.orderKey);try{if(!B)throw Error("This wallet does not support transaction signing required for recurring orders.");let t=await r({orderId:e.orderKey,amount:0});if(null==t?void 0:t.transaction)try{let e=new Uint8Array(w.Buffer.from(t.transaction,"base64")),r=b.VersionedTransaction.deserialize(e),a=await (0,o.Q5)(B(r)),n=w.Buffer.from(a.serialize()).toString("base64");await s({requestId:t.requestId,signedTransaction:n}),v({title:"Withdrawn",description:"Funds withdrawn successfully."}),await ee()}catch(e){throw console.error("Transaction failed:",e),e}}catch(e){v({variant:"destructive",title:"Withdraw Failed",description:(null==e?void 0:e.message)||"Unable to withdraw funds"})}finally{D(null)}}},ei=async()=>{G(!0);
1try{await ee(),v({title:"Refreshed",description:"All data has been refreshed successfully."})}catch(e){console.error("Failed to refresh data",e),v({variant:"destructive",title:"Refresh Failed",description:"Unable to refresh data. Please try again."})}finally{G(!1)}};return(0,a.jsxs)("div",{className:"w-full flex flex-col",children:[h&&q&&(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2 mb-1 rounded-xl bg-surfaceHover border border-borderStrong",children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground",children:"Recently placed orders need a wallet signature to display."}),(0,a.jsx)(S.$,{variant:"outline",size:"sm",onClick:Q,className:"flex-shrink-0",children:"Show them"})]}),(0,a.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto w-full max-h-[400px]",children:k?(0,a.jsxs)("div",{className:"flex flex-col gap-3 py-4 px-3",children:[[0,1,2].map(e=>(0,a.jsxs)("div",{className:"flex items-start gap-3 animate-pulse",children:[(0,a.jsx)("div",{className:"h-8 w-8 rounded-full bg-surfaceHover flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[(0,a.jsx)("div",{className:"h-3 w-24 rounded bg-surfaceHover"}),(0,a.jsx)("div",{className:"h-3 w-40 rounded bg-surfaceHover"})]}),(0,a.jsx)("div",{className:"h-3 w-16 rounded bg-surfaceHover"})]},e)),(0,a.jsx)("p",{className:"text-caption text-[var(--c-text-3)] text-center mt-1",children:"Loading your orders…"})]}):A?(0,a.jsxs)("div",{className:"w-full flex flex-col items-center justify-center py-12 h-full",children:[(0,a.jsx)(l.A,{size:48,className:"text-[#E74C3C] opacity-30 mb-4"}),(0,a.jsx)("h3",{className:"text-text text-lg font-semibold mb-2",children:"Error"}),(0,a.jsx)("p",{className:"text-text opacity-70 text-sm text-center",children:A})]}):0===y.length?(0,a.jsxs)("div",{className:"w-full flex flex-col items-center justify-center py-12 h-full",children:[(0,a.jsx)(l.A,{size:48,className:"text-text opacity-30 mb-4"}),(0,a.jsx)("h3",{className:"text-text text-lg font-semibold mb-2",children:"No DCA Orders Yet"})]}):y.map(e=>{let t=(0,P.nT)(e),r=(e=>{switch(e){case"cancelled":return{color:"text-[var(--c-warn)]",label:"Cancelled",Icon:$.A};case"completed":return{color:"text-primary",label:"Completed",Icon:K.A};case"active":return{color:"text-[#FF1493]",label:"Active",Icon:L.A};case"failed":return{color:"text-loss",label:"Failed",Icon:$.A};default:return{color:"text-text",label:"Unknown",Icon:L.A}}})(t.status),s=er(t.inputMint),n=er(t.outputMint);ea(t.depositedRaw,s);let l=ea(t.receivedRaw,n),i=ea(t.usedRaw,s),o=t.depositedRaw,c=t.usedRaw,d=!t.closed&&c<o,u=o>0?Math.min(1,Math.max(0,c/o)):0,m=null!=l&&null!=i&&i>0&&l>0?l/i:null;return(0,a.jsx)("div",{className:"relative border-t border-borderStrong",children:(0,a.jsx)("div",{className:"flex items-start gap-4 py-4 px-[12px]",children:(0,a.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start mb-1",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 text-caption ".concat(r.color),children:[r.Icon&&(0,a.jsx)(r.Icon,{className:"w-3 h-3 ".concat(r.color)}),r.label]}),(0,a.jsx)("span",{className:"text-muted-foreground text-caption",children:(e=>{if(!e)return"-";let t=new Date(e);return t.toLocaleDateString("en-US",{day:"2-digit",month:"short",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})})(t.createdAt)})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center mb-1",children:[(0,a.jsxs)("h3",{className:"text-text text-lead font-semibold",children:[et(e.inputMint)," →"," ",et(e.outputMint)]}),(0,a.jsx)("div",{className:"text-right",children:null!=l&&l>0?(0,a.jsxs)("span",{className:"text-primary text-lead font-semibold",children:["+",(0,W.NJ)(l,{stable:(0,_.$K)(e.outputMint)})," ",et(e.outputMint)]}):d?(0,a.jsxs)("span",{className:"text-muted-foreground text-lead font-semibold",children:[Math.round(100*u),"% filled"]}):(0,a.jsx)("span",{className:"text-text text-lead font-semibold",children:"-"})})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-muted-foreground text-caption",children:null!=m?"1 ".concat(et(e.inputMint)," ≈ ").concat((0,W.NJ)(m,{stable:(0,_.$K)(e.outputMint)})," ").concat(et(e.outputMint)," avg"):"No buys yet"}),(0,a.jsx)("span",{className:"text-muted-foreground text-caption",children:null!=i&&i>0?"-".concat((0,W.NJ)(i,{stable:(0,_.$K)(e.inputMint)})," ").concat(et(e.inputMint)):"-"})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center",children:[(0,a.jsx)("span",{className:"text-muted-foreground text-caption",children:(0,P.vy)(t.cycleSeconds)?"Cycle: Every ".concat((0,P.vy)(t.cycleSeconds)):"Cycle: —"}),(0,a.jsx)("span",{className:"text-muted-foreground text-caption",children:null!=t.roundsFilled&&null!=t.totalRounds?"".concat(t.roundsFilled,"/").concat(t.totalRounds," trades"):null!=t.roundsFilled?"".concat(t.roundsFilled," trades"):"— trades"})]}),(0,a.jsxs)("div",{className:"flex gap-2 mt-2",children:[d&&(0,a.jsx)(S.$,{size:"sm",variant:"outline",disabled:M===t.key,onClick:()=>t.isV2?es(t):en(e),children:M===t.key?"Cancelling…":"Cancel"}),d&&e.orderKey&&"price"===e.recurringType&&(0,a.jsx)(S.$,{size:"sm",variant:"outline",disabled:M===e.orderKey,onClick:()=>el(e),children:M===e.orderKey?"Withdrawing...":"Withdraw"})]})]})})},t.key)})}),(0,a.jsx)("div",{className:"flex p-4 mb-[20px]",children:(0,a.jsx)(S.$,{variant:"secondary",size:"sm",onClick:ei,disabled:Z,className:"flex w-full h-[40px] items-center justify-center rounded-md bg-[var(--c-surface-2)] border border-[var(--c-border)] text-[var(--c-text-2)] hover:text-primary",children:"Refresh"})})]})};var V=r(7285);let X=e=>{let{slippage:t,defaultInputMint:r,defaultOutputMint:i}=e,[o,c]=(0,V.A)("dcaActiveTab","newOrder"),d=[{value:"newOrder",label:"New Order",icon:(0,a.jsx)(n.A,{className:"w-4 h-4"})},{value:"history",label:"History",icon:(0,a.jsx)(l.A,{className:"w-4 h-4"})}];return(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-full  relative",children:[(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(s.I,{items:d,defaultValue:o,onChange:c})}),"newOrder"===o?(0,a.jsx)(z,{slippage:t,defaultInputMint:r,defaultOutputMint:i}):(0,a.jsx)(H,{})]})})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.