otx-swap 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.inset-2{inset:.5rem}.inset-x-0{left:0;right:0}.-bottom-1{bottom:-.25rem}.-bottom-2{bottom:-.5rem}.-right-1{right:-.25rem}.-top-2{top:-.5rem}.bottom-0{bottom:0}.bottom-full{bottom:100%}.left-0{left:0}.left-1\\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.top-1\\/2{top:50%}.top-full{top:100%}.z-10{z-index:10}.z-50{z-index:50}.-my-4{margin-top:-1rem;margin-bottom:-1rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-auto{margin-left:auto}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.size-10{width:2.5rem;height:2.5rem}.size-12{width:3rem;height:3rem}.size-2{width:.5rem;height:.5rem}.size-20{width:5rem;height:5rem}.size-3{width:.75rem;height:.75rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-8{width:2rem;height:2rem}.h-1\\.5{height:.375rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[2\\.5rem\\]{max-height:2.5rem}.max-h-\\[2rem\\]{max-height:2rem}.max-h-\\[3rem\\]{max-height:3rem}.max-h-\\[5rem\\]{max-height:5rem}.max-h-\\[600px\\]{max-height:600px}.max-h-\\[60vh\\]{max-height:60vh}.max-h-\\[90vh\\]{max-height:90vh}.max-h-\\[96vh\\]{max-height:96vh}.w-1\\/3{width:33.333333%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\\.5{width:.875rem}.w-32{width:8rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-72{width:18rem}.w-8{width:2rem}.w-96{width:24rem}.w-auto{width:auto}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\\[140px\\]{min-width:140px}.max-w-2xl{max-width:42rem}.max-w-\\[280px\\]{max-width:280px}.max-w-md{max-width:28rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-\\[var\\(--optimex-border\\)\\]>:not([hidden])~:not([hidden]){border-color:var(--optimex-border)}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\\[0\\.25rem\\]{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.rounded-t-2xl{border-top-left-radius:1rem;border-top-right-radius:1rem}.rounded-t-sm{border-top-left-radius:.125rem;border-top-right-radius:.125rem}.border{border-width:1px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-none{border-style:none}.border-\\[var\\(--optimex-background\\)\\]{border-color:var(--optimex-background)}.border-\\[var\\(--optimex-border\\)\\]{border-color:var(--optimex-border)}.border-\\[var\\(--optimex-primary\\)\\]{border-color:var(--optimex-primary)}.border-\\[var\\(--optimex-surface\\)\\]{border-color:var(--optimex-surface)}.border-current{border-color:currentColor}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-white\\/10{border-color:#ffffff1a}.border-white\\/5{border-color:#ffffff0d}.border-white\\/\\[0\\.02\\]{border-color:#ffffff05}.border-white\\/\\[0\\.05\\]{border-color:#ffffff0d}.border-t-transparent{border-top-color:transparent}.bg-\\[rgba\\(239\\,68\\,68\\,0\\.15\\)\\]{background-color:#ef444426}.bg-\\[rgba\\(34\\,197\\,94\\,0\\.15\\)\\]{background-color:#22c55e26}.bg-\\[rgba\\(59\\,130\\,246\\,0\\.15\\)\\]{background-color:#3b82f626}.bg-\\[var\\(--optimex-background\\)\\]{background-color:var(--optimex-background)}.bg-\\[var\\(--optimex-border\\)\\]{background-color:var(--optimex-border)}.bg-\\[var\\(--optimex-error\\)\\]{background-color:var(--optimex-error)}.bg-\\[var\\(--optimex-primary\\)\\]{background-color:var(--optimex-primary)}.bg-\\[var\\(--optimex-surface\\)\\]{background-color:var(--optimex-surface)}.bg-\\[var\\(--optimex-surface-hover\\)\\]{background-color:var(--optimex-surface-hover)}.bg-black\\/60{background-color:#0009}.bg-blue-500\\/20{background-color:#3b82f633}.bg-green-500\\/10{background-color:#22c55e1a}.bg-orange-500\\/20{background-color:#f9731633}.bg-purple-500\\/20{background-color:#a855f733}.bg-red-500\\/10{background-color:#ef44441a}.bg-red-500\\/20{background-color:#ef444433}.bg-transparent{background-color:transparent}.bg-white\\/10{background-color:#ffffff1a}.bg-white\\/20{background-color:#fff3}.bg-white\\/5{background-color:#ffffff0d}.bg-white\\/\\[0\\.02\\]{background-color:#ffffff05}.bg-yellow-500\\/10{background-color:#eab3081a}.bg-zinc-800\\/80{background-color:#27272acc}.bg-zinc-900\\/50{background-color:#18181b80}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-\\[var\\(--optimex-primary\\)\\]{--tw-gradient-from: var(--optimex-primary) var(--tw-gradient-from-position);--tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-\\[\\#d45800\\]{--tw-gradient-to: #d45800 var(--tw-gradient-to-position)}.stroke-\\[var\\(--optimex-error\\)\\]{stroke:var(--optimex-error)}.p-0{padding:0}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1\\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.py-\\[6px\\]{padding-top:6px;padding-bottom:6px}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-10{padding-left:2.5rem}.pl-2{padding-left:.5rem}.pr-10{padding-right:2.5rem}.pr-3{padding-right:.75rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\\[10px\\]{font-size:10px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-none{line-height:1}.tracking-tight{letter-spacing:-.025em}.tracking-wider{letter-spacing:.05em}.text-\\[var\\(--optimex-error\\)\\]{color:var(--optimex-error)}.text-\\[var\\(--optimex-primary\\)\\]{color:var(--optimex-primary)}.text-\\[var\\(--optimex-success\\)\\]{color:var(--optimex-success)}.text-\\[var\\(--optimex-text\\)\\]{color:var(--optimex-text)}.text-\\[var\\(--optimex-text-secondary\\)\\]{color:var(--optimex-text-secondary)}.text-\\[var\\(--optimex-warning\\)\\]{color:var(--optimex-warning)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-orange-400{--tw-text-opacity: 1;color:rgb(251 146 60 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/20{color:#fff3}.text-white\\/30{color:#ffffff4d}.text-white\\/40{color:#fff6}.text-white\\/50{color:#ffffff80}.text-white\\/60{color:#fff9}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-zinc-400{--tw-text-opacity: 1;color:rgb(161 161 170 / var(--tw-text-opacity, 1))}.text-zinc-500{--tw-text-opacity: 1;color:rgb(113 113 122 / var(--tw-text-opacity, 1))}.opacity-0{opacity:0}.opacity-50{opacity:.5}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_15px_rgba\\(235\\,98\\,0\\,0\\.1\\)\\]{--tw-shadow: 0 0 15px rgba(235,98,0,.1);--tw-shadow-colored: 0 0 15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_15px_rgba\\(235\\,98\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0 15px rgba(235,98,0,.3);--tw-shadow-colored: 0 0 15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_8px_rgba\\(235\\,98\\,0\\,0\\.8\\)\\]{--tw-shadow: 0 0 8px rgba(235,98,0,.8);--tw-shadow-colored: 0 0 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.optx-widget{isolation:isolate;width:100%;min-width:0;max-width:100%;--optimex-primary: #eb6200;--optimex-primary-rgb: 235, 98, 0;--optimex-primary-hover: #d45800;--optimex-background: #0f1115;--optimex-surface: #1a1e26;--optimex-surface-hover: #252a35;--optimex-card-dark: #141417;--optimex-text: #ffffff;--optimex-text-secondary: #9ca3af;--optimex-border: #23170f;--optimex-success: #22c55e;--optimex-error: #ef4444;--optimex-warning: #f59e0b;font-family:Space Grotesk,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:14px;line-height:1.5;color:var(--optimex-text);text-align:left;-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.optx-widget .glass-container{background:linear-gradient(135deg,#1a1e26e6,#0f1115f2);border:1px solid rgba(255,255,255,.05);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;min-width:0;max-width:100%;box-sizing:border-box}.optx-widget *,.optx-widget *:before,.optx-widget *:after{box-sizing:border-box}.optx-widget button{font-family:inherit;line-height:inherit;margin:0;cursor:pointer}.optx-widget input,.optx-widget select,.optx-widget textarea{font-family:inherit;line-height:inherit;margin:0}.optx-widget a{color:inherit;text-decoration:none}.optx-widget ul,.optx-widget ol{list-style:none;margin:0;padding:0}.optx-widget img{max-width:100%;height:auto}.optx-widget svg{display:inline-block;vertical-align:middle}.glow-orange{box-shadow:inset 0 0 15px #eb620026,0 0 20px #eb62001a}.glow-green{box-shadow:0 0 12px #22c55e33}.glow-red{box-shadow:0 0 12px #ef444433}@keyframes status-pulse{0%,to{opacity:1}50%{opacity:.5}}.status-pulse{animation:status-pulse 2s cubic-bezier(.4,0,.6,1) infinite}.placeholder\\:text-white\\/10::-moz-placeholder{color:#ffffff1a}.placeholder\\:text-white\\/10::placeholder{color:#ffffff1a}.placeholder\\:text-white\\/30::-moz-placeholder{color:#ffffff4d}.placeholder\\:text-white\\/30::placeholder{color:#ffffff4d}.placeholder\\:text-white\\/50::-moz-placeholder{color:#ffffff80}.placeholder\\:text-white\\/50::placeholder{color:#ffffff80}.focus-within\\:border-\\[var\\(--optimex-primary\\)\\]:focus-within{border-color:var(--optimex-primary)}.hover\\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:border-\\[var\\(--optimex-primary\\)\\]:hover{border-color:var(--optimex-primary)}.hover\\:bg-\\[rgba\\(239\\,68\\,68\\,0\\.2\\)\\]:hover{background-color:#ef444433}.hover\\:bg-\\[var\\(--optimex-primary-hover\\)\\]:hover{background-color:var(--optimex-primary-hover)}.hover\\:bg-\\[var\\(--optimex-surface-hover\\)\\]:hover{background-color:var(--optimex-surface-hover)}.hover\\:bg-white\\/10:hover{background-color:#ffffff1a}.hover\\:bg-white\\/5:hover{background-color:#ffffff0d}.hover\\:bg-white\\/\\[0\\.02\\]:hover{background-color:#ffffff05}.hover\\:text-\\[var\\(--optimex-primary\\)\\]:hover{color:var(--optimex-primary)}.hover\\:text-\\[var\\(--optimex-text\\)\\]:hover{color:var(--optimex-text)}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:text-white\\/40:hover{color:#fff6}.hover\\:text-white\\/50:hover{color:#ffffff80}.hover\\:text-white\\/60:hover{color:#fff9}.hover\\:opacity-70:hover{opacity:.7}.hover\\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\\:brightness-110:hover{--tw-brightness: brightness(1.1);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.focus\\:border-\\[var\\(--optimex-primary\\)\\]:focus{border-color:var(--optimex-primary)}.focus\\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-\\[0\\.98\\]:active{--tw-scale-x: .98;--tw-scale-y: .98;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\\:opacity-100{opacity:1}@media(min-width:640px){.sm\\:text-left{text-align:left}}@media(min-width:768px){.md\\:h-\\[70vh\\]{height:70vh}}')),document.head.appendChild(t)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("react"),ke=require("./react-query-DLqM33VH.cjs"),Vn=require("react-dom");function Wn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=Wn(p),To=Wn(Vn),Ct={colors:{primary:"#ed6300",primaryHover:"#EA580C",secondary:"#FB923C",background:"#111112",surface:"#1A1A1A",surfaceHover:"#252525",text:"#FFFFFF",textSecondary:"#9CA3AF",border:"#2A2A2A",success:"#22C55E",error:"#EF4444",warning:"#F59E0B"},borderRadius:"lg"},_o=p.createContext(null);function Ro({children:e,theme:t}){const n=p.useMemo(()=>t?{...Ct,...t,colors:{...Ct.colors,...t.colors}}:Ct,[t]),r=p.useMemo(()=>({"":n.colors.primary,"-hover":n.colors.primaryHover,"--optimex-secondary":n.colors.secondary,"--optimex-background":n.colors.background,"--optimex-surface":n.colors.surface,"--optimex-surface-hover":n.colors.surfaceHover,"--optimex-text":n.colors.text,"--optimex-text-secondary":n.colors.textSecondary,"--optimex-border":n.colors.border,"--optimex-success":n.colors.success,"--optimex-error":n.colors.error,"--optimex-warning":n.colors.warning}),[n]);return o.jsx(_o.Provider,{value:{theme:n},children:o.jsx("div",{style:r,className:"w-full",children:e})})}const Hn=p.createContext(null);function Ao({children:e,externalWalletClient:t,onRequestWallet:n}){const r=p.useMemo(()=>{const s=t?.evm?.address??null,a=t?.evm?.chain?.id??null,l=t?.btc?.address??null,i=t?.btc?.publicKey??null,c=t?.solana?.address??null,d=!!s,u=!!l,f=!!c;return{mode:"external",isExternalWallet:!0,isConnected:d||u||f,evmAddress:s,evmChainId:a,isEvmConnected:d,btcAddress:l,btcPublicKey:i,isBtcConnected:u,solanaAddress:c,isSolanaConnected:f,externalWalletClient:t,onRequestWallet:n,isConnecting:!1}},[t,n]);return o.jsx(Hn.Provider,{value:r,children:e})}class kt extends Error{status;code;constructor(t,n,r){super(n),this.name="ApiError",this.status=t,this.code=r}}class Un{baseUrl;headers;constructor(t){this.baseUrl=t.replace(/\/$/,""),this.headers={"Content-Type":"application/json"}}async request(t,n,r){const s=`${this.baseUrl}${n}`;try{const a=await fetch(s,{method:t,headers:this.headers,body:r?JSON.stringify(r):void 0});if(!a.ok){const i=await a.json().catch(()=>({}));throw new kt(a.status,i.message||`Request failed with status ${a.status}`,i.code)}return(await a.json()).data}catch(a){throw a instanceof kt?a:new kt(0,a instanceof Error?a.message:"Network error","NETWORK_ERROR")}}async getTokens(){return this.request("GET","/v2/tokens")}async createQuote(t){return this.request("POST","/v2/trades/quote",t)}async submitTransaction(t,n){return this.request("POST","/v2/trades/submit-tx",{trade_id:t,tx_id:n})}async getTrade(t){return this.request("GET",`/v2/trades/${t}`)}async getTokenPrice(t){return this.request("GET",`/v2/tokens/${t}`)}async listTrades(t={}){const n=new URLSearchParams;t.limit&&n.set("limit",String(t.limit)),t.page&&n.set("page",String(t.page)),t.state&&n.set("state",t.state),t.from_user_address?.length&&t.from_user_address.forEach(a=>n.append("from_user_address",a)),t.to_user_address?.length&&t.to_user_address.forEach(a=>n.append("to_user_address",a));const r=n.toString(),s=r?`/v2/trades?${r}`:"/v2/trades";return this.request("GET",s)}}let Be=null;function Ve(e){if(!Be&&e&&(Be=new Un(e)),!Be)throw new Error("API not initialized. Please provide baseUrl.");return Be}function Mo(e){return Be=new Un(e),Be}const Lo=["tokens"];function Po(e){return ke.useQuery({queryKey:Lo,queryFn:async()=>Ve(e).getTokens(),staleTime:300*1e3,gcTime:1800*1e3,retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4)})}const Oo=15e3,Io=1e4,Y={EVM:"EVM",BTC:"BTC",SOLANA:"Solana"};function Do(e,t=4){return e?e.length<=t*2+3?e:`${e.slice(0,t+2)}...${e.slice(-t)}`:""}function $o(e,t,n=6){if(!e)return"0";let r;typeof e=="bigint"?r=e:typeof e=="string"?r=BigInt(e):r=BigInt(Math.floor(e));const s=BigInt(10**t),a=r/s,l=r%s;if(l===0n)return a.toString();const c=l.toString().padStart(t,"0").slice(0,n).replace(/0+$/,"");return c?`${a}.${c}`:a.toString()}function qn(e,t){if(!e||e==="0")return 0n;const[n,r=""]=e.split("."),s=r.slice(0,t).padEnd(t,"0"),a=n+s;return BigInt(a)}function je(e,t=18,n=6){if(!e)return"0";const r=String(e);if(r.includes(".")||!Number.isInteger(Number(r))){const s=parseFloat(r);return isNaN(s)?"0":s.toFixed(n).replace(/\.?0+$/,"")}return $o(r,t,n)}function Fo(e){return/^0x[a-fA-F0-9]{40}$/.test(e)}function Bo(e){return/^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[a-z0-9]{39,59}$/.test(e)}function zo(e){return/^[mn2][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(tb1)[a-z0-9]{39,59}$/.test(e)}function Vo(e){return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)}function Kt(e,t,n){const r=e.trim();if(!r)return{isValid:!1,error:"Address is required"};switch(t){case Y.EVM:return Fo(r)?{isValid:!0}:{isValid:!1,error:`Invalid ${n} wallet address`};case Y.BTC:if(n==="bitcoin_testnet"){if(!zo(r))return{isValid:!1,error:`Invalid ${n} wallet address`}}else if(!Bo(r))return{isValid:!1,error:`Invalid ${n} wallet address`};return{isValid:!0};case Y.SOLANA:return Vo(r)?{isValid:!0}:{isValid:!1,error:`Invalid ${n} wallet address`};default:return{isValid:!1,error:`Unsupported network type: ${t}`}}}const Wo=e=>["quote",e];function Ho(e,{from_token:t,to_token:n,amount:r,from_user_address:s,to_user_address:a,user_refund_pubkey:l,slippage:i="100",affiliate_fee_bps:c,affiliate_info:d,trade_timeout:u,script_timeout:f,enabled:x=!0,onQuote:v}){const w=n&&a?Kt(a,n.network_type,n.network_id).isValid:!1,m=t&&n&&r&&parseFloat(r)>0&&s&&a&&l&&w;return ke.useQuery({queryKey:Wo({from_token:t,to_token:n,amount:r,from_user_address:s,to_user_address:a,user_refund_pubkey:l,slippage:i}),queryFn:async()=>{const y=Ve(e),g=qn(r,t.token_decimals).toString(),k=await y.createQuote({from_token_id:t.token_id,to_token_id:n.token_id,amount_in:g,slippage:i,from_user_address:s,to_user_address:a,user_refund_pubkey:l,affiliate_fee_bps:c,affiliate_info:d,trade_timeout:u,script_timeout:f});return v?.({quote:k,from_token:t,to_token:n,amount_in:r}),k},enabled:x&&!!m,staleTime:Io,refetchInterval:Oo,retry:2,retryDelay:1e3})}const Gn=p.createContext(null);function Uo({children:e,value:t}){return o.jsx(Gn.Provider,{value:t,children:e})}function Je(){const e=p.useContext(Gn);if(!e)throw new Error("useWidgetConfig must be used within SwapWidget");return e}function qo({className:e="h-6 w-6"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{width:"24",height:"24",rx:"6",fill:"#D0D0D8"}),o.jsx("rect",{x:"4",y:"4",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#FFD49F"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.98943 6.98062C9.06078 6.50027 8.69769 6.24205 8.20122 6.06979L8.36227 5.4191L7.96906 5.32039L7.81227 5.95393C7.7089 5.92798 7.60273 5.9035 7.49723 5.87925L7.65514 5.24153L7.26216 5.14282L7.101 5.79329C7.01544 5.77366 6.93144 5.75426 6.84991 5.73384L6.85036 5.73181L6.30809 5.59542L6.20348 6.01846C6.20348 6.01846 6.49523 6.08581 6.48907 6.08998C6.64832 6.13003 6.6771 6.23618 6.67229 6.32034L6.48884 7.06162C6.49982 7.06444 6.51404 7.0685 6.52972 7.07482L6.5164 7.07147L6.48817 7.06444L6.23103 8.10286C6.21155 8.1516 6.16216 8.2247 6.05084 8.19695C6.05476 8.2027 5.76503 8.12509 5.76503 8.12509L5.56982 8.57847L6.08152 8.70696C6.13867 8.72139 6.19513 8.73622 6.251 8.7509C6.2882 8.76067 6.32514 8.77037 6.36184 8.77984L6.19912 9.43798L6.59188 9.53669L6.75304 8.88554C6.86033 8.91487 6.96448 8.94195 7.06639 8.96744L6.9058 9.61554L7.299 9.71425L7.46173 9.05735C8.13224 9.18517 8.63643 9.13361 8.84866 8.52274C9.01967 8.03089 8.84015 7.74717 8.48737 7.56216C8.74428 7.50248 8.93781 7.33225 8.98943 6.98062ZM8.09134 8.24968C7.97986 8.70094 7.27864 8.51438 6.9578 8.42902L6.95779 8.42901C6.92893 8.42133 6.90314 8.41447 6.88114 8.40897L7.09706 7.53706C7.12385 7.54379 7.15659 7.55119 7.19367 7.55957C7.52551 7.63458 8.20558 7.78829 8.09134 8.24968ZM7.26037 7.15491C7.52787 7.22682 8.11136 7.38367 8.213 6.97354C8.31679 6.55403 7.74968 6.42757 7.47272 6.36581C7.44156 6.35886 7.41408 6.35273 7.39164 6.3471L7.19587 7.1379C7.21436 7.14254 7.23606 7.14838 7.26037 7.15491Z",fill:"#F7931A"}),o.jsx("rect",{x:"12.8572",y:"4",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"white"}),o.jsx("path",{d:"M14.8567 7.47096L16.2848 8.30034V6.83321V5.14284L14.8567 7.47096Z",fill:"#898989"}),o.jsx("path",{d:"M16.2837 5.14284V6.8332V8.30033L17.7118 7.47096L16.2837 5.14284Z",fill:"#323232"}),o.jsx("path",{d:"M16.2837 6.83343L17.7114 7.47098L16.2837 8.30014V6.83343Z",fill:"#141414"}),o.jsx("path",{d:"M16.2848 6.83322L16.2853 6.83336V8.29993L16.2848 8.30035L14.8567 7.47097L16.2848 6.83322Z",fill:"#373737"}),o.jsx("path",{d:"M14.8567 7.73708L16.2848 9.71431V8.56604L14.8567 7.73708Z",fill:"#898989"}),o.jsx("path",{d:"M16.2837 8.56604V9.71431L17.7127 7.73708L16.2837 8.56604Z",fill:"#323232"}),o.jsx("rect",{x:"4",y:"12.8571",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#DCFFFB"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.68368 15.456C8.66445 15.4645 8.64369 15.469 8.6227 15.469H5.49249C5.47756 15.469 5.46296 15.4645 5.45047 15.4563C5.43798 15.448 5.42815 15.4362 5.42218 15.4223C5.41621 15.4084 5.41436 15.3931 5.41685 15.3782C5.41935 15.3633 5.42608 15.3494 5.43622 15.3383L6.0958 14.6209C6.11009 14.6053 6.12738 14.5929 6.14662 14.5844C6.16585 14.5758 6.18661 14.5714 6.2076 14.5714H9.33781C9.35286 14.5711 9.3677 14.5753 9.3804 14.5835C9.39311 14.5917 9.40317 14.6035 9.40925 14.6175C9.41536 14.6315 9.41722 14.6469 9.41465 14.662C9.41208 14.677 9.40518 14.691 9.39482 14.7021L8.7345 15.4195C8.72021 15.4351 8.70292 15.4475 8.68368 15.456ZM8.73471 15.9844C8.72037 15.9689 8.70306 15.9565 8.68384 15.948C8.66462 15.9395 8.64389 15.9351 8.62291 15.935H5.4927C5.47777 15.935 5.46317 15.9394 5.45068 15.9477C5.43819 15.956 5.42836 15.9678 5.42239 15.9817C5.41642 15.9955 5.41457 16.0108 5.41706 16.0258C5.41955 16.0407 5.42629 16.0545 5.43643 16.0656L6.09601 16.7835C6.11035 16.799 6.12766 16.8114 6.14688 16.8199C6.1661 16.8284 6.18683 16.8328 6.20781 16.8329H9.33802C9.35292 16.8328 9.36746 16.8284 9.3799 16.82C9.39235 16.8117 9.40211 16.7999 9.40804 16.7861C9.41396 16.7722 9.41579 16.7569 9.41326 16.742C9.41076 16.7272 9.40405 16.7133 9.39392 16.7023L8.73471 15.9844ZM9.39503 17.4295L8.73471 18.147C8.72042 18.1626 8.70313 18.175 8.68389 18.1835C8.66466 18.192 8.6439 18.1964 8.62291 18.1965H5.4927C5.47777 18.1964 5.46317 18.192 5.45068 18.1837C5.43819 18.1754 5.42836 18.1636 5.42239 18.1498C5.41642 18.1359 5.41457 18.1206 5.41706 18.1057C5.41955 18.0908 5.42629 18.0769 5.43643 18.0658L6.09601 17.3484C6.1103 17.3328 6.12759 17.3203 6.14683 17.3118C6.16606 17.3033 6.18682 17.2989 6.20781 17.2989H9.33802C9.35307 17.2986 9.3679 17.3028 9.38061 17.311C9.39332 17.3192 9.40338 17.331 9.40945 17.345C9.41557 17.3589 9.41743 17.3744 9.41486 17.3895C9.41229 17.4045 9.40539 17.4185 9.39503 17.4295Z",fill:"url(#paint0_linear_all_networks)"}),o.jsx("rect",{x:"12.8572",y:"12.8571",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#999CB3"}),o.jsx("path",{d:"M16.0979 17.4286V15.1429H16.473V17.4286H16.0979ZM15.1426 16.4692V16.097H17.4283V16.4692H15.1426Z",fill:"#2D3153"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"paint0_linear_all_networks",x1:"7.82209",y1:"19.7701",x2:"10.7176",y2:"15.7425",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0.08",stopColor:"#9945FF"}),o.jsx("stop",{offset:"0.3",stopColor:"#8752F3"}),o.jsx("stop",{offset:"0.5",stopColor:"#5497D5"}),o.jsx("stop",{offset:"0.6",stopColor:"#43B4CA"}),o.jsx("stop",{offset:"0.72",stopColor:"#28E0B9"}),o.jsx("stop",{offset:"0.97",stopColor:"#19FB9B"})]})})]})}function Go(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",...e,children:o.jsx("path",{d:"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"})})}function Yt({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}function Kn({className:e="h-4 w-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}function Yn({className:e="h-5 w-5"}){return o.jsxs("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),o.jsx("path",{strokeLinecap:"round",d:"M12 2a10 10 0 019.17 6"})]})}function Ko({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}function Ae({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function Yo(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),o.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}function Zo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...e,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})}function Qo({className:e="h-3.5 w-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function Xo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 20",fill:"currentColor",...e,children:o.jsx("path",{d:"M18.1123 4.25181C17.9463 3.49057 17.537 2.8272 16.9727 2.31607C15.4792 0.978457 13.189 1.03283 11.7619 2.4357C11.2751 2.91419 10.9321 3.51232 10.7662 4.18656C10.6002 4.84993 10.6555 5.64381 10.4564 6.50293C10.1798 7.75354 9.53813 8.90629 8.6088 9.81978C7.6131 10.7985 6.34081 11.451 4.95788 11.6903C4.19451 11.8208 3.3205 11.7773 2.57925 12.0165C2.00396 12.2014 1.48398 12.5276 1.07463 12.9409C-0.374675 14.3981 -0.352546 16.7254 1.10782 18.1609C2.535 19.5637 4.84725 19.6181 6.32974 18.2696C6.72802 17.9107 7.04886 17.4757 7.25907 16.9755C7.67947 16.0076 7.52459 15.5944 7.65735 14.6483C7.73479 14.0936 7.87862 13.5608 8.08882 13.0388C8.31009 12.4841 8.3986 12.3319 8.70837 11.8643C9.29473 10.9943 10.0692 10.2548 10.9874 9.73278C12.0053 9.14554 13.178 8.81929 14.4392 8.81929C16.32 8.81929 18.0237 9.56966 19.2628 10.7768C20.2586 11.7446 20.9445 13.0061 21.1879 14.4199C21.3096 15.0941 21.2432 15.8227 21.4202 16.4861C21.5972 17.1386 21.9402 17.715 22.4049 18.1826C23.8763 19.629 26.266 19.629 27.7485 18.1826C29.1646 16.7906 29.231 14.5395 27.8923 13.0823C27.4498 12.6038 26.8855 12.234 26.2549 12.0274C25.4252 11.7664 25.0379 11.8643 24.1971 11.7555C22.6593 11.5598 21.2875 10.8638 20.2475 9.84153C19.1854 8.79754 18.4663 7.40554 18.2893 5.8613C18.1897 5.19793 18.2561 4.87168 18.1123 4.25181ZM16.9617 11.0486C15.5013 9.61316 13.1448 9.61316 11.6844 11.0486C10.2241 12.4841 10.2241 14.8005 11.6844 16.236C13.1448 17.6715 15.5013 17.6715 16.9617 16.236C18.422 14.8005 18.422 12.4841 16.9617 11.0486ZM26.0668 3.13169C24.6065 1.6962 22.25 1.6962 20.7896 3.13169C19.3292 4.56719 19.3292 6.88355 20.7896 8.31904C22.25 9.75453 24.6065 9.75453 26.0668 8.31904C27.5272 6.88355 27.5272 4.56719 26.0668 3.13169ZM7.95606 3.17519C6.49569 1.7397 4.13919 1.7397 2.67882 3.17519C1.21845 4.61069 1.21845 6.92705 2.67882 8.36254C4.13919 9.79803 6.49569 9.79803 7.95606 8.36254C9.41643 6.92705 9.41643 4.59981 7.95606 3.17519Z"})})}function Jo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 124 22",...e,children:o.jsx("path",{d:"M41.39 4.241c3.385 0 6.162 2.73 6.162 6.058s-2.777 6.003-6.162 6.003h-.62c-3.385 0-6.162-2.676-6.162-6.003S37.385 4.24 40.77 4.24zm-.3 10.745c2.877 0 4.825-2.317 4.825-4.644.055-2.37-1.903-4.796-4.824-4.796-2.976 0-4.879 2.425-4.824 4.796-.01 2.316 1.892 4.644 4.824 4.644m21.353-4.698c0 3.327-2.268 5.992-5.233 5.992h-.62c-2.422 0-3.905-.805-4.978-2.665V22H50.02V4.241h1.593V6.96c.963-1.925 2.666-2.719 4.979-2.719h.62c2.964 0 5.232 2.719 5.232 6.047m-1.703 0c0-2.317-1.649-4.644-4.559-4.644-2.312 0-4.259 1.925-4.259 4.23v.816c0 2.316 1.936 4.187 4.304 4.187 2.832 0 4.514-2.273 4.514-4.59m8.275 6.003c-.354 0-.72-.055-1.073-.196-.874-.305-1.593-.86-2.058-1.61a5 5 0 0 1-.465-1.109c-.1-.402-.155-.707-.155-1.11V5.765h-1.382v-1.36h1.382V.772h1.649v3.632h3.44v1.36h-3.44v6.144c0 1.762.774 2.828 2.722 2.828h1.438v1.566h-2.058zm6.018-15.28c0 .555-.409 1.012-.973 1.012A1.025 1.025 0 0 1 73.03 1.01C73.031.457 73.496 0 74.06 0s.973.457.973 1.011m-1.792 3.23h1.593v12.06h-1.593zm14.283 2.621c.819-1.718 2.511-2.62 4.47-2.62 3.075 0 4.47 2.729 4.47 5.502v6.558H94.87V9.396c0-5.655-6.881-4.698-6.881.196v6.71h-1.594V9.396c0-5.655-6.826-4.698-6.826.196v6.71h-1.637V4.242h1.593v2.065c1.637-2.925 6.716-2.773 7.999.555m17.436 8.124c1.847 0 3.695-1.164 4.304-2.73h1.593c-.819 2.316-2.877 4.035-5.543 4.035h-.664c-3.385 0-5.897-2.676-5.897-6.003s2.512-6.058 5.897-6.058h.664c3.341 0 5.897 2.73 5.897 6.058 0 .195 0 .402-.056.609H100.38c.121 2.273 2.268 4.089 4.58 4.089m4.624-5.296c-.099-2.273-2.257-4.133-4.613-4.133-2.312 0-4.47 1.86-4.569 4.133zM124 4.24l-5.133 6.058L124 16.302h-2.058l-4.104-4.84-4.105 4.84h-2.002l5.133-6.003-5.133-6.058h2.002l4.105 4.84 4.104-4.84zm-105.888-.49a3.67 3.67 0 0 0-1.14-1.935 3.817 3.817 0 0 0-5.21.12 3.67 3.67 0 0 0-.996 1.75c-.166.664-.11 1.458-.31 2.317A6.7 6.7 0 0 1 8.61 9.32a6.88 6.88 0 0 1-3.651 1.87c-.763.13-1.638.087-2.379.327a3.75 3.75 0 0 0-1.504.924 3.667 3.667 0 0 0 .033 5.22c1.427 1.403 3.74 1.457 5.222.109.398-.36.719-.794.93-1.294.42-.968.265-1.382.397-2.328a6.8 6.8 0 0 1 .432-1.61c.221-.554.31-.706.62-1.174a6.862 6.862 0 0 1 5.73-3.045c1.881 0 3.585.75 4.824 1.958a6.64 6.64 0 0 1 1.925 3.643c.122.674.055 1.403.232 2.066.177.653.52 1.229.985 1.697 1.471 1.446 3.861 1.446 5.343 0a3.666 3.666 0 0 0 .144-5.1 3.9 3.9 0 0 0-1.637-1.056c-.83-.26-1.217-.163-2.058-.271a6.86 6.86 0 0 1-3.95-1.914 6.65 6.65 0 0 1-1.958-3.98c-.1-.664-.033-.99-.177-1.61m-1.15 6.798a3.77 3.77 0 0 0-5.278 0 3.62 3.62 0 0 0 0 5.187 3.77 3.77 0 0 0 5.278 0 3.62 3.62 0 0 0 0-5.187m9.105-7.917a3.77 3.77 0 0 0-5.277 0 3.62 3.62 0 0 0 0 5.187 3.77 3.77 0 0 0 5.277 0 3.62 3.62 0 0 0 0-5.187m-18.11.043a3.77 3.77 0 0 0-5.278 0 3.62 3.62 0 0 0 0 5.188 3.77 3.77 0 0 0 5.277 0 3.62 3.62 0 0 0 0-5.188"})})}function es(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 25",fill:"none",...e,children:[o.jsx("mask",{id:"paste_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"25",children:o.jsx("rect",{y:"0.5",width:"24",height:"24",fill:"#D9D9D9"})}),o.jsx("g",{mask:"url(#paste_mask)",children:o.jsx("path",{d:"M5.30775 20.9999C4.80908 20.9999 4.38308 20.8233 4.02975 20.4701C3.67658 20.1168 3.5 19.6908 3.5 19.1921V5.80762C3.5 5.30895 3.67658 4.88295 4.02975 4.52962C4.38308 4.17645 4.80908 3.99987 5.30775 3.99987H9.7135C9.852 3.5127 10.135 3.10887 10.5625 2.78837C10.99 2.46787 11.4692 2.30762 12 2.30762C12.5513 2.30762 13.0382 2.46787 13.4605 2.78837C13.883 3.10887 14.1635 3.5127 14.302 3.99987H18.6923C19.1909 3.99987 19.6169 4.17645 19.9703 4.52962C20.3234 4.88295 20.5 5.30895 20.5 5.80762V19.1921C20.5 19.6908 20.3234 20.1168 19.9703 20.4701C19.6169 20.8233 19.1909 20.9999 18.6923 20.9999H5.30775ZM5.30775 19.4999H18.6923C18.7692 19.4999 18.8398 19.4678 18.9038 19.4036C18.9679 19.3396 19 19.2691 19 19.1921V5.80762C19 5.73062 18.9679 5.66012 18.9038 5.59612C18.8398 5.53195 18.7692 5.49987 18.6923 5.49987H16.5V8.11512H7.5V5.49987H5.30775C5.23075 5.49987 5.16025 5.53195 5.09625 5.59612C5.03208 5.66012 5 5.73062 5 5.80762V19.1921C5 19.2691 5.03208 19.3396 5.09625 19.4036C5.16025 19.4678 5.23075 19.4999 5.30775 19.4999ZM12 5.61537C12.2577 5.61537 12.4728 5.52912 12.6453 5.35662C12.8176 5.18412 12.9038 4.96903 12.9038 4.71137C12.9038 4.4537 12.8176 4.23862 12.6453 4.06612C12.4728 3.89378 12.2577 3.80762 12 3.80762C11.7423 3.80762 11.5273 3.89378 11.3548 4.06612C11.1824 4.23862 11.0963 4.4537 11.0963 4.71137C11.0963 4.96903 11.1824 5.18412 11.3548 5.35662C11.5273 5.52912 11.7423 5.61537 12 5.61537Z",fill:"currentColor",fillOpacity:.48})})]})}function ts(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M4 12C4 7.58172 7.58172 4 12 4C15.0736 4 17.7555 5.6841 19.2291 8.16667M20 12C20 16.4183 16.4183 20 12 20C8.92638 20 6.24452 18.3159 4.77091 15.8333",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),o.jsx("path",{d:"M19 4V8H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M5 20V16H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ns(e){return o.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("circle",{cx:"32",cy:"32",r:"28",className:"fill-[var(--optimex-error)]/10 stroke-[var(--optimex-error)]",strokeWidth:"2"}),o.jsx("path",{d:"M20 22L26 28M26 22L20 28",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("path",{d:"M38 22L44 28M44 22L38 28",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("path",{d:"M22 44C26 38 38 38 42 44",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"})]})}function rs({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function os({className:e="h-5 w-5"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Zn(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),o.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}function pn({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Qn(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 21",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",d:"m11.299 2.846-.553 2.231q.557.126 1.103.263l.549-2.219 1.375.346-.563 2.277c1.737.603 3.008 1.506 2.759 3.188-.18 1.23-.858 1.827-1.757 2.036 1.234.647 1.862 1.641 1.264 3.362-.743 2.137-2.507 2.318-4.854 1.87l-.57 2.3-1.376-.345.562-2.269a53 53 0 0 1-1.096-.287l-.565 2.28-1.374-.346.57-2.304c-.322-.082-.65-.17-.982-.254L4 14.525l.684-1.587c.009.002 1.013.272 1 .251.389.098.562-.158.63-.33l.9-3.633.145.036a1 1 0 0 0-.142-.047l.64-2.593c.018-.295-.082-.667-.64-.807.02-.014-1-.25-1-.25l.367-1.48 1.898.476-.002.008q.43.106.88.207L9.922 2.5zM8.588 13.93c.933.233 3.81 1.164 4.236-.557.444-1.795-2.547-2.26-3.48-2.495zM9.69 9.483c.778.195 3.172.99 3.56-.575.404-1.634-2.098-1.998-2.875-2.193z"})})}function Xn(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 12",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M2.463 8.78a.44.44 0 0 1 .311-.129H13.5a.22.22 0 0 1 .156.376l-2.119 2.124a.44.44 0 0 1-.311.129H.5a.22.22 0 0 1-.156-.377zm0-7.932A.45.45 0 0 1 2.774.72H13.5a.221.221 0 0 1 .156.376L11.536 3.22a.44.44 0 0 1-.311.13H.5a.22.22 0 0 1-.156-.377zm9.074 3.941a.44.44 0 0 0-.311-.13H.5a.22.22 0 0 0-.156.377l2.12 2.124a.44.44 0 0 0 .31.129H13.5a.221.221 0 0 0 .156-.376z"})})}function Jn(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 22",width:"20",height:"20",...e,children:[o.jsx("path",{fill:"currentColor",d:"M6.998 0 .5 11.204l6.498-3.069zM6.998 8.136.5 11.205l6.498 3.992z"}),o.jsx("path",{fill:"currentColor",d:"M13.496 11.204 6.997 0v8.135z"}),o.jsx("path",{fill:"currentColor",d:"m6.997 15.197 6.499-3.992-6.499-3.07zM.5 12.484 6.998 22v-5.526z"}),o.jsx("path",{fill:"currentColor",d:"M6.997 16.474V22l6.502-9.516z"})]})}function er(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M11.984 21.5c4.98 0 9.016-4.03 9.016-9s-4.036-9-9.016-9C7.26 3.5 3.385 7.127 3 11.743h11.917v1.514H3c.385 4.616 4.26 8.243 8.984 8.243"})})}function tr(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:[o.jsxs("g",{fill:"currentColor",fillOpacity:.48,clipPath:"url(#arb_a)",children:[o.jsx("path",{d:"m12.089 14.49 2.278 3.68 2.105-1.255-2.992-4.852zM18.389 15.439l-.002-1.006-3.27-5.24-1.213 2.119 3.157 5.251 1.14-.68a.53.53 0 0 0 .188-.379zM4.688 16.387l1.611.956 5.363-8.85-.91-.024c-.776-.011-1.611.196-1.994.84l-3.046 4.857-1.024 1.62zM14.758 8.494l-2.4.009-5.426 9.214 1.897 1.123.515-.9z"}),o.jsx("path",{d:"M19.4 8.481a1.58 1.58 0 0 0-.718-1.264L12.72 3.69a1.51 1.51 0 0 0-1.368 0c-.05.026-5.8 3.456-5.8 3.456a1.572 1.572 0 0 0-.863 1.333v7.307l1.024-1.62-.009-5.638.007-.06a.52.52 0 0 1 .204-.332c.027-.02 5.875-3.502 5.893-3.512a.5.5 0 0 1 .45-.002l5.887 3.484c.139.091.226.246.234.415v6.984a.52.52 0 0 1-.176.38l-1.141.68-.589.35-2.105 1.256-2.134 1.272a.5.5 0 0 1-.364-.007L9.345 17.94l-.516.9 2.27 1.344.36.207c.161.08.393.127.602.127q.29 0 .556-.108l6.2-3.693c.355-.284.565-.712.584-1.175z"})]}),o.jsx("defs",{children:o.jsx("clipPath",{id:"arb_a",children:o.jsx("path",{fill:"currentColor",d:"M4 3h16v18H4z"})})})]})}function nr(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M7.245 16.646q-1.431 0-2.343-.672C4.301 15.52 4 14.867 4 14.03c0-.18.02-.39.058-.647q.154-.862.441-2.08Q5.317 8 8.717 8c.614 0 1.171.102 1.657.314q.73.298 1.152.915.423.604.423 1.44 0 .249-.058.633a26 26 0 0 1-.435 2.08c-.282 1.095-.762 1.92-1.453 2.464-.685.538-1.606.8-2.758.8m.173-1.728c.448 0 .825-.134 1.139-.396q.481-.393.685-1.216c.185-.756.326-1.408.422-1.972q.05-.25.051-.518.002-1.094-1.139-1.094-.672.001-1.152.396-.471.393-.672 1.216c-.147.538-.288 1.19-.435 1.972q-.05.238-.051.505c-.007.743.384 1.107 1.152 1.107M12.506 16.531c-.09 0-.154-.025-.205-.083-.038-.064-.051-.134-.038-.218l1.657-7.808a.32.32 0 0 1 .135-.217.35.35 0 0 1 .23-.083h3.194q1.333.001 2.137.55c.544.371.82.902.82 1.6 0 .198-.026.41-.071.627-.198.922-.602 1.6-1.216 2.042q-.902.66-2.477.659h-1.619l-.55 2.63a.34.34 0 0 1-.135.218.35.35 0 0 1-.23.083zm4.25-4.589c.339 0 .627-.09.876-.275q.383-.277.506-.793.038-.203.038-.359c0-.23-.07-.41-.205-.531-.134-.128-.37-.192-.697-.192h-1.44l-.455 2.15z"})})}function rr(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:[o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m4.913 12.5.011 3.868 3.286 1.935v2.264L3 17.511V11.37zm0-3.868v2.254L3 9.754V7.5l1.913-1.133L6.836 7.5zM9.582 7.5l1.913-1.133L13.418 7.5l-1.923 1.132z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M6.297 15.567v-2.265l1.913 1.132v2.254zm3.285 3.547 1.914 1.132 1.923-1.132v2.254L11.496 22.5l-1.914-1.132zM16.163 7.5l1.913-1.133L20 7.5v2.254l-1.923 1.132V8.632zm1.913 8.868.011-3.868L20 11.368v6.142l-5.208 3.056v-2.265z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m16.704 15.567-1.914 1.122v-2.254l1.913-1.133z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m16.704 9.434.01 2.264-3.294 1.934v3.878l-1.913 1.122-1.914-1.122v-3.878l-3.295-1.934V9.434L8.22 8.3l3.275 1.944L14.79 8.3l1.922 1.133zM6.297 5.566 11.496 2.5l5.208 3.066L14.791 6.7l-3.295-1.944L8.21 6.7z"})]})}const hn={bitcoin:Qn,solana:Xn,ethereum:Jn,base:er,arbitrum:tr,optimism:nr,bsc:rr};function ss(e){if(!e)return null;const t=e.toLowerCase().replace(/[\s_-]/g,"");return t in hn?hn[t]:t.includes("bitcoin")||t.includes("btc")?Qn:t.includes("solana")||t.includes("sol")?Xn:t.includes("ethereum")||t.includes("eth")||t.includes("erc20")?Jn:t.includes("base")?er:t.includes("arbitrum")||t.includes("arb")?tr:t.includes("optimism")||t.includes("op")?nr:t.includes("bsc")||t.includes("binance")||t.includes("bnb")?rr:null}function as(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function is({icon:e,label:t,address:n,className:r=""}){const[s,a]=p.useState(!1),l=p.useCallback(async()=>{try{await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)}catch{console.error("Failed to copy")}},[n]);return o.jsxs("div",{className:`flex items-center justify-between px-4 py-3 ${r}`,children:[o.jsxs("div",{className:"flex items-center gap-2 text-[var(--optimex-text-secondary)]",children:[o.jsx(e,{className:"size-4"}),o.jsx("span",{className:"text-sm",children:t})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:as(n)}),o.jsx("button",{onClick:l,className:"p-1 rounded hover:bg-[var(--optimex-surface-hover)] transition-colors",title:s?"Copied!":"Copy",children:s?o.jsx(Yt,{className:"size-4 text-[var(--optimex-success)]"}):o.jsx(Yo,{className:"size-4 text-[var(--optimex-text-secondary)]"})})]})]})}const ls={primary:"bg-gradient-to-r from-[var(--optimex-primary)] to-[#d45800] text-black hover:brightness-110 shadow-lg shadow-[var(--optimex-primary)]/30",secondary:"bg-[var(--optimex-surface)] text-[var(--optimex-text)] hover:bg-[var(--optimex-surface-hover)] border border-[var(--optimex-border)]",ghost:"bg-transparent text-[var(--optimex-text-secondary)] hover:bg-[var(--optimex-surface-hover)] hover:text-[var(--optimex-text)]",danger:"bg-[var(--optimex-error)] text-white hover:bg-[var(--optimex-error)]/90 hover:shadow-lg hover:shadow-[var(--optimex-error)]/25"},cs={sm:"px-3 py-1.5 text-xs rounded-md gap-1.5 max-h-[2rem]",md:"px-4 py-2 text-sm rounded-md gap-2 max-h-[2.5rem]",lg:"px-6 py-3 text-sm rounded-md gap-2 max-h-[3rem]"};function or({variant:e="primary",size:t="md",fullWidth:n=!1,isLoading:r=!1,leftIcon:s,rightIcon:a,children:l,className:i="",disabled:c,...d}){const u=c||r;return o.jsxs("button",{className:`
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.inset-2{inset:.5rem}.inset-x-0{left:0;right:0}.-bottom-1{bottom:-.25rem}.-bottom-2{bottom:-.5rem}.-right-1{right:-.25rem}.-top-2{top:-.5rem}.bottom-0{bottom:0}.bottom-full{bottom:100%}.left-0{left:0}.left-1\\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.top-1\\/2{top:50%}.top-full{top:100%}.z-10{z-index:10}.z-50{z-index:50}.-my-4{margin-top:-1rem;margin-bottom:-1rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-auto{margin-left:auto}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.size-10{width:2.5rem;height:2.5rem}.size-12{width:3rem;height:3rem}.size-2{width:.5rem;height:.5rem}.size-20{width:5rem;height:5rem}.size-3{width:.75rem;height:.75rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-8{width:2rem;height:2rem}.h-1\\.5{height:.375rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[2\\.5rem\\]{max-height:2.5rem}.max-h-\\[2rem\\]{max-height:2rem}.max-h-\\[3rem\\]{max-height:3rem}.max-h-\\[5rem\\]{max-height:5rem}.max-h-\\[600px\\]{max-height:600px}.max-h-\\[60vh\\]{max-height:60vh}.max-h-\\[90vh\\]{max-height:90vh}.max-h-\\[96vh\\]{max-height:96vh}.w-1\\/3{width:33.333333%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\\.5{width:.875rem}.w-32{width:8rem}.w-4{width:1rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-72{width:18rem}.w-8{width:2rem}.w-96{width:24rem}.w-auto{width:auto}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\\[140px\\]{min-width:140px}.max-w-2xl{max-width:42rem}.max-w-\\[280px\\]{max-width:280px}.max-w-md{max-width:28rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize{resize:both}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-\\[var\\(--optimex-border\\)\\]>:not([hidden])~:not([hidden]){border-color:var(--optimex-border)}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\\[0\\.25rem\\]{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.rounded-t-2xl{border-top-left-radius:1rem;border-top-right-radius:1rem}.rounded-t-sm{border-top-left-radius:.125rem;border-top-right-radius:.125rem}.border{border-width:1px}.border-2{border-width:2px}.border-4{border-width:4px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-none{border-style:none}.border-\\[var\\(--optimex-background\\)\\]{border-color:var(--optimex-background)}.border-\\[var\\(--optimex-border\\)\\]{border-color:var(--optimex-border)}.border-\\[var\\(--optimex-primary\\)\\]{border-color:var(--optimex-primary)}.border-\\[var\\(--optimex-surface\\)\\]{border-color:var(--optimex-surface)}.border-current{border-color:currentColor}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-white\\/10{border-color:#ffffff1a}.border-white\\/5{border-color:#ffffff0d}.border-white\\/\\[0\\.02\\]{border-color:#ffffff05}.border-white\\/\\[0\\.05\\]{border-color:#ffffff0d}.border-t-transparent{border-top-color:transparent}.bg-\\[rgba\\(239\\,68\\,68\\,0\\.15\\)\\]{background-color:#ef444426}.bg-\\[rgba\\(34\\,197\\,94\\,0\\.15\\)\\]{background-color:#22c55e26}.bg-\\[rgba\\(59\\,130\\,246\\,0\\.15\\)\\]{background-color:#3b82f626}.bg-\\[var\\(--optimex-background\\)\\]{background-color:var(--optimex-background)}.bg-\\[var\\(--optimex-border\\)\\]{background-color:var(--optimex-border)}.bg-\\[var\\(--optimex-error\\)\\]{background-color:var(--optimex-error)}.bg-\\[var\\(--optimex-primary\\)\\]{background-color:var(--optimex-primary)}.bg-\\[var\\(--optimex-surface\\)\\]{background-color:var(--optimex-surface)}.bg-\\[var\\(--optimex-surface-hover\\)\\]{background-color:var(--optimex-surface-hover)}.bg-black\\/60{background-color:#0009}.bg-blue-500\\/20{background-color:#3b82f633}.bg-green-500\\/10{background-color:#22c55e1a}.bg-orange-500\\/20{background-color:#f9731633}.bg-purple-500\\/20{background-color:#a855f733}.bg-red-500\\/10{background-color:#ef44441a}.bg-red-500\\/20{background-color:#ef444433}.bg-transparent{background-color:transparent}.bg-white\\/10{background-color:#ffffff1a}.bg-white\\/20{background-color:#fff3}.bg-white\\/5{background-color:#ffffff0d}.bg-white\\/\\[0\\.02\\]{background-color:#ffffff05}.bg-yellow-500\\/10{background-color:#eab3081a}.bg-zinc-800\\/80{background-color:#27272acc}.bg-zinc-900\\/50{background-color:#18181b80}.stroke-\\[var\\(--optimex-error\\)\\]{stroke:var(--optimex-error)}.p-0{padding:0}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1\\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.py-\\[6px\\]{padding-top:6px;padding-bottom:6px}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-10{padding-left:2.5rem}.pl-2{padding-left:.5rem}.pr-10{padding-right:2.5rem}.pr-3{padding-right:.75rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\\[10px\\]{font-size:10px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-none{line-height:1}.tracking-tight{letter-spacing:-.025em}.tracking-wider{letter-spacing:.05em}.text-\\[var\\(--optimex-error\\)\\]{color:var(--optimex-error)}.text-\\[var\\(--optimex-primary\\)\\]{color:var(--optimex-primary)}.text-\\[var\\(--optimex-success\\)\\]{color:var(--optimex-success)}.text-\\[var\\(--optimex-text\\)\\]{color:var(--optimex-text)}.text-\\[var\\(--optimex-text-secondary\\)\\]{color:var(--optimex-text-secondary)}.text-\\[var\\(--optimex-warning\\)\\]{color:var(--optimex-warning)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-orange-400{--tw-text-opacity: 1;color:rgb(251 146 60 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/20{color:#fff3}.text-white\\/30{color:#ffffff4d}.text-white\\/40{color:#fff6}.text-white\\/50{color:#ffffff80}.text-white\\/60{color:#fff9}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-zinc-400{--tw-text-opacity: 1;color:rgb(161 161 170 / var(--tw-text-opacity, 1))}.text-zinc-500{--tw-text-opacity: 1;color:rgb(113 113 122 / var(--tw-text-opacity, 1))}.opacity-0{opacity:0}.opacity-50{opacity:.5}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_15px_rgba\\(235\\,98\\,0\\,0\\.1\\)\\]{--tw-shadow: 0 0 15px rgba(235,98,0,.1);--tw-shadow-colored: 0 0 15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_15px_rgba\\(235\\,98\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0 15px rgba(235,98,0,.3);--tw-shadow-colored: 0 0 15px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0_8px_rgba\\(235\\,98\\,0\\,0\\.8\\)\\]{--tw-shadow: 0 0 8px rgba(235,98,0,.8);--tw-shadow-colored: 0 0 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.optx-widget{isolation:isolate;width:100%;min-width:0;max-width:100%;--optimex-primary: #eb6200;--optimex-primary-rgb: 235, 98, 0;--optimex-primary-hover: #d45800;--optimex-background: #0f1115;--optimex-surface: #1a1e26;--optimex-surface-hover: #252a35;--optimex-card-dark: #141417;--optimex-text: #ffffff;--optimex-text-secondary: #9ca3af;--optimex-border: #23170f;--optimex-success: #22c55e;--optimex-error: #ef4444;--optimex-warning: #f59e0b;font-family:Space Grotesk,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:14px;line-height:1.5;color:var(--optimex-text);text-align:left;-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.optx-widget .glass-container{background:linear-gradient(135deg,#1a1e26e6,#0f1115f2);border:1px solid rgba(255,255,255,.05);-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;min-width:0;max-width:100%;box-sizing:border-box}.optx-widget *,.optx-widget *:before,.optx-widget *:after{box-sizing:border-box}.optx-widget button{font-family:inherit;line-height:inherit;margin:0;cursor:pointer}.optx-widget input,.optx-widget select,.optx-widget textarea{font-family:inherit;line-height:inherit;margin:0}.optx-widget a{color:inherit;text-decoration:none}.optx-widget ul,.optx-widget ol{list-style:none;margin:0;padding:0}.optx-widget img{max-width:100%;height:auto}.optx-widget svg{display:inline-block;vertical-align:middle}.glow-orange{box-shadow:inset 0 0 15px #eb620026,0 0 20px #eb62001a}.glow-green{box-shadow:0 0 12px #22c55e33}.glow-red{box-shadow:0 0 12px #ef444433}@keyframes status-pulse{0%,to{opacity:1}50%{opacity:.5}}.status-pulse{animation:status-pulse 2s cubic-bezier(.4,0,.6,1) infinite}.placeholder\\:text-white\\/10::-moz-placeholder{color:#ffffff1a}.placeholder\\:text-white\\/10::placeholder{color:#ffffff1a}.placeholder\\:text-white\\/30::-moz-placeholder{color:#ffffff4d}.placeholder\\:text-white\\/30::placeholder{color:#ffffff4d}.placeholder\\:text-white\\/50::-moz-placeholder{color:#ffffff80}.placeholder\\:text-white\\/50::placeholder{color:#ffffff80}.focus-within\\:border-\\[var\\(--optimex-primary\\)\\]:focus-within{border-color:var(--optimex-primary)}.hover\\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:border-\\[var\\(--optimex-primary\\)\\]:hover{border-color:var(--optimex-primary)}.hover\\:bg-\\[rgba\\(239\\,68\\,68\\,0\\.2\\)\\]:hover{background-color:#ef444433}.hover\\:bg-\\[var\\(--optimex-primary-hover\\)\\]:hover{background-color:var(--optimex-primary-hover)}.hover\\:bg-\\[var\\(--optimex-surface-hover\\)\\]:hover{background-color:var(--optimex-surface-hover)}.hover\\:bg-white\\/10:hover{background-color:#ffffff1a}.hover\\:bg-white\\/5:hover{background-color:#ffffff0d}.hover\\:bg-white\\/\\[0\\.02\\]:hover{background-color:#ffffff05}.hover\\:text-\\[var\\(--optimex-primary\\)\\]:hover{color:var(--optimex-primary)}.hover\\:text-\\[var\\(--optimex-text\\)\\]:hover{color:var(--optimex-text)}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:text-white\\/40:hover{color:#fff6}.hover\\:text-white\\/50:hover{color:#ffffff80}.hover\\:text-white\\/60:hover{color:#fff9}.hover\\:opacity-70:hover{opacity:.7}.hover\\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\\:brightness-110:hover{--tw-brightness: brightness(1.1);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.focus\\:border-\\[var\\(--optimex-primary\\)\\]:focus{border-color:var(--optimex-primary)}.focus\\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-\\[0\\.98\\]:active{--tw-scale-x: .98;--tw-scale-y: .98;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group:hover .group-hover\\:opacity-100{opacity:1}@media(min-width:640px){.sm\\:text-left{text-align:left}}@media(min-width:768px){.md\\:h-\\[70vh\\]{height:70vh}}')),document.head.appendChild(t)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("react"),ke=require("./react-query-DLqM33VH.cjs"),Vn=require("react-dom");function Wn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=Wn(p),To=Wn(Vn),Ct={colors:{primary:"#ed6300",primaryHover:"#EA580C",secondary:"#FB923C",background:"#111112",surface:"#1A1A1A",surfaceHover:"#252525",text:"#FFFFFF",textSecondary:"#9CA3AF",border:"#2A2A2A",success:"#22C55E",error:"#EF4444",warning:"#F59E0B"},borderRadius:"lg"},_o=p.createContext(null);function Ro({children:e,theme:t}){const n=p.useMemo(()=>t?{...Ct,...t,colors:{...Ct.colors,...t.colors}}:Ct,[t]),r=p.useMemo(()=>({"--optimex-primary":n.colors.primary,"--optimex-primary-hover":n.colors.primaryHover,"--optimex-secondary":n.colors.secondary,"--optimex-background":n.colors.background,"--optimex-surface":n.colors.surface,"--optimex-surface-hover":n.colors.surfaceHover,"--optimex-text":n.colors.text,"--optimex-text-secondary":n.colors.textSecondary,"--optimex-border":n.colors.border,"--optimex-success":n.colors.success,"--optimex-error":n.colors.error,"--optimex-warning":n.colors.warning}),[n]);return o.jsx(_o.Provider,{value:{theme:n},children:o.jsx("div",{style:r,className:"w-full",children:e})})}const Hn=p.createContext(null);function Ao({children:e,externalWalletClient:t,onRequestWallet:n}){const r=p.useMemo(()=>{const s=t?.evm?.address??null,a=t?.evm?.chain?.id??null,l=t?.btc?.address??null,i=t?.btc?.publicKey??null,c=t?.solana?.address??null,d=!!s,u=!!l,f=!!c;return{mode:"external",isExternalWallet:!0,isConnected:d||u||f,evmAddress:s,evmChainId:a,isEvmConnected:d,btcAddress:l,btcPublicKey:i,isBtcConnected:u,solanaAddress:c,isSolanaConnected:f,externalWalletClient:t,onRequestWallet:n,isConnecting:!1}},[t,n]);return o.jsx(Hn.Provider,{value:r,children:e})}class kt extends Error{status;code;constructor(t,n,r){super(n),this.name="ApiError",this.status=t,this.code=r}}class Un{baseUrl;headers;constructor(t){this.baseUrl=t.replace(/\/$/,""),this.headers={"Content-Type":"application/json"}}async request(t,n,r){const s=`${this.baseUrl}${n}`;try{const a=await fetch(s,{method:t,headers:this.headers,body:r?JSON.stringify(r):void 0});if(!a.ok){const i=await a.json().catch(()=>({}));throw new kt(a.status,i.message||`Request failed with status ${a.status}`,i.code)}return(await a.json()).data}catch(a){throw a instanceof kt?a:new kt(0,a instanceof Error?a.message:"Network error","NETWORK_ERROR")}}async getTokens(){return this.request("GET","/v2/tokens")}async createQuote(t){return this.request("POST","/v2/trades/quote",t)}async submitTransaction(t,n){return this.request("POST","/v2/trades/submit-tx",{trade_id:t,tx_id:n})}async getTrade(t){return this.request("GET",`/v2/trades/${t}`)}async getTokenPrice(t){return this.request("GET",`/v2/tokens/${t}`)}async listTrades(t={}){const n=new URLSearchParams;t.limit&&n.set("limit",String(t.limit)),t.page&&n.set("page",String(t.page)),t.state&&n.set("state",t.state),t.from_user_address?.length&&t.from_user_address.forEach(a=>n.append("from_user_address",a)),t.to_user_address?.length&&t.to_user_address.forEach(a=>n.append("to_user_address",a));const r=n.toString(),s=r?`/v2/trades?${r}`:"/v2/trades";return this.request("GET",s)}}let Be=null;function Ve(e){if(!Be&&e&&(Be=new Un(e)),!Be)throw new Error("API not initialized. Please provide baseUrl.");return Be}function Mo(e){return Be=new Un(e),Be}const Lo=["tokens"];function Po(e){return ke.useQuery({queryKey:Lo,queryFn:async()=>Ve(e).getTokens(),staleTime:300*1e3,gcTime:1800*1e3,retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4)})}const Oo=15e3,Io=1e4,Y={EVM:"EVM",BTC:"BTC",SOLANA:"Solana"};function Do(e,t=4){return e?e.length<=t*2+3?e:`${e.slice(0,t+2)}...${e.slice(-t)}`:""}function $o(e,t,n=6){if(!e)return"0";let r;typeof e=="bigint"?r=e:typeof e=="string"?r=BigInt(e):r=BigInt(Math.floor(e));const s=BigInt(10**t),a=r/s,l=r%s;if(l===0n)return a.toString();const c=l.toString().padStart(t,"0").slice(0,n).replace(/0+$/,"");return c?`${a}.${c}`:a.toString()}function qn(e,t){if(!e||e==="0")return 0n;const[n,r=""]=e.split("."),s=r.slice(0,t).padEnd(t,"0"),a=n+s;return BigInt(a)}function je(e,t=18,n=6){if(!e)return"0";const r=String(e);if(r.includes(".")||!Number.isInteger(Number(r))){const s=parseFloat(r);return isNaN(s)?"0":s.toFixed(n).replace(/\.?0+$/,"")}return $o(r,t,n)}function Fo(e){return/^0x[a-fA-F0-9]{40}$/.test(e)}function Bo(e){return/^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[a-z0-9]{39,59}$/.test(e)}function zo(e){return/^[mn2][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(tb1)[a-z0-9]{39,59}$/.test(e)}function Vo(e){return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)}function Kt(e,t,n){const r=e.trim();if(!r)return{isValid:!1,error:"Address is required"};switch(t){case Y.EVM:return Fo(r)?{isValid:!0}:{isValid:!1,error:`Invalid ${n} wallet address`};case Y.BTC:if(n==="bitcoin_testnet"){if(!zo(r))return{isValid:!1,error:`Invalid ${n} wallet address`}}else if(!Bo(r))return{isValid:!1,error:`Invalid ${n} wallet address`};return{isValid:!0};case Y.SOLANA:return Vo(r)?{isValid:!0}:{isValid:!1,error:`Invalid ${n} wallet address`};default:return{isValid:!1,error:`Unsupported network type: ${t}`}}}const Wo=e=>["quote",e];function Ho(e,{from_token:t,to_token:n,amount:r,from_user_address:s,to_user_address:a,user_refund_pubkey:l,slippage:i="100",affiliate_fee_bps:c,affiliate_info:d,trade_timeout:u,script_timeout:f,enabled:x=!0,onQuote:v}){const w=n&&a?Kt(a,n.network_type,n.network_id).isValid:!1,m=t&&n&&r&&parseFloat(r)>0&&s&&a&&l&&w;return ke.useQuery({queryKey:Wo({from_token:t,to_token:n,amount:r,from_user_address:s,to_user_address:a,user_refund_pubkey:l,slippage:i}),queryFn:async()=>{const y=Ve(e),g=qn(r,t.token_decimals).toString(),k=await y.createQuote({from_token_id:t.token_id,to_token_id:n.token_id,amount_in:g,slippage:i,from_user_address:s,to_user_address:a,user_refund_pubkey:l,affiliate_fee_bps:c,affiliate_info:d,trade_timeout:u,script_timeout:f});return v?.({quote:k,from_token:t,to_token:n,amount_in:r}),k},enabled:x&&!!m,staleTime:Io,refetchInterval:Oo,retry:2,retryDelay:1e3})}const Gn=p.createContext(null);function Uo({children:e,value:t}){return o.jsx(Gn.Provider,{value:t,children:e})}function Je(){const e=p.useContext(Gn);if(!e)throw new Error("useWidgetConfig must be used within SwapWidget");return e}function qo({className:e="h-6 w-6"}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{width:"24",height:"24",rx:"6",fill:"#D0D0D8"}),o.jsx("rect",{x:"4",y:"4",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#FFD49F"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.98943 6.98062C9.06078 6.50027 8.69769 6.24205 8.20122 6.06979L8.36227 5.4191L7.96906 5.32039L7.81227 5.95393C7.7089 5.92798 7.60273 5.9035 7.49723 5.87925L7.65514 5.24153L7.26216 5.14282L7.101 5.79329C7.01544 5.77366 6.93144 5.75426 6.84991 5.73384L6.85036 5.73181L6.30809 5.59542L6.20348 6.01846C6.20348 6.01846 6.49523 6.08581 6.48907 6.08998C6.64832 6.13003 6.6771 6.23618 6.67229 6.32034L6.48884 7.06162C6.49982 7.06444 6.51404 7.0685 6.52972 7.07482L6.5164 7.07147L6.48817 7.06444L6.23103 8.10286C6.21155 8.1516 6.16216 8.2247 6.05084 8.19695C6.05476 8.2027 5.76503 8.12509 5.76503 8.12509L5.56982 8.57847L6.08152 8.70696C6.13867 8.72139 6.19513 8.73622 6.251 8.7509C6.2882 8.76067 6.32514 8.77037 6.36184 8.77984L6.19912 9.43798L6.59188 9.53669L6.75304 8.88554C6.86033 8.91487 6.96448 8.94195 7.06639 8.96744L6.9058 9.61554L7.299 9.71425L7.46173 9.05735C8.13224 9.18517 8.63643 9.13361 8.84866 8.52274C9.01967 8.03089 8.84015 7.74717 8.48737 7.56216C8.74428 7.50248 8.93781 7.33225 8.98943 6.98062ZM8.09134 8.24968C7.97986 8.70094 7.27864 8.51438 6.9578 8.42902L6.95779 8.42901C6.92893 8.42133 6.90314 8.41447 6.88114 8.40897L7.09706 7.53706C7.12385 7.54379 7.15659 7.55119 7.19367 7.55957C7.52551 7.63458 8.20558 7.78829 8.09134 8.24968ZM7.26037 7.15491C7.52787 7.22682 8.11136 7.38367 8.213 6.97354C8.31679 6.55403 7.74968 6.42757 7.47272 6.36581C7.44156 6.35886 7.41408 6.35273 7.39164 6.3471L7.19587 7.1379C7.21436 7.14254 7.23606 7.14838 7.26037 7.15491Z",fill:"#F7931A"}),o.jsx("rect",{x:"12.8572",y:"4",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"white"}),o.jsx("path",{d:"M14.8567 7.47096L16.2848 8.30034V6.83321V5.14284L14.8567 7.47096Z",fill:"#898989"}),o.jsx("path",{d:"M16.2837 5.14284V6.8332V8.30033L17.7118 7.47096L16.2837 5.14284Z",fill:"#323232"}),o.jsx("path",{d:"M16.2837 6.83343L17.7114 7.47098L16.2837 8.30014V6.83343Z",fill:"#141414"}),o.jsx("path",{d:"M16.2848 6.83322L16.2853 6.83336V8.29993L16.2848 8.30035L14.8567 7.47097L16.2848 6.83322Z",fill:"#373737"}),o.jsx("path",{d:"M14.8567 7.73708L16.2848 9.71431V8.56604L14.8567 7.73708Z",fill:"#898989"}),o.jsx("path",{d:"M16.2837 8.56604V9.71431L17.7127 7.73708L16.2837 8.56604Z",fill:"#323232"}),o.jsx("rect",{x:"4",y:"12.8571",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#DCFFFB"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.68368 15.456C8.66445 15.4645 8.64369 15.469 8.6227 15.469H5.49249C5.47756 15.469 5.46296 15.4645 5.45047 15.4563C5.43798 15.448 5.42815 15.4362 5.42218 15.4223C5.41621 15.4084 5.41436 15.3931 5.41685 15.3782C5.41935 15.3633 5.42608 15.3494 5.43622 15.3383L6.0958 14.6209C6.11009 14.6053 6.12738 14.5929 6.14662 14.5844C6.16585 14.5758 6.18661 14.5714 6.2076 14.5714H9.33781C9.35286 14.5711 9.3677 14.5753 9.3804 14.5835C9.39311 14.5917 9.40317 14.6035 9.40925 14.6175C9.41536 14.6315 9.41722 14.6469 9.41465 14.662C9.41208 14.677 9.40518 14.691 9.39482 14.7021L8.7345 15.4195C8.72021 15.4351 8.70292 15.4475 8.68368 15.456ZM8.73471 15.9844C8.72037 15.9689 8.70306 15.9565 8.68384 15.948C8.66462 15.9395 8.64389 15.9351 8.62291 15.935H5.4927C5.47777 15.935 5.46317 15.9394 5.45068 15.9477C5.43819 15.956 5.42836 15.9678 5.42239 15.9817C5.41642 15.9955 5.41457 16.0108 5.41706 16.0258C5.41955 16.0407 5.42629 16.0545 5.43643 16.0656L6.09601 16.7835C6.11035 16.799 6.12766 16.8114 6.14688 16.8199C6.1661 16.8284 6.18683 16.8328 6.20781 16.8329H9.33802C9.35292 16.8328 9.36746 16.8284 9.3799 16.82C9.39235 16.8117 9.40211 16.7999 9.40804 16.7861C9.41396 16.7722 9.41579 16.7569 9.41326 16.742C9.41076 16.7272 9.40405 16.7133 9.39392 16.7023L8.73471 15.9844ZM9.39503 17.4295L8.73471 18.147C8.72042 18.1626 8.70313 18.175 8.68389 18.1835C8.66466 18.192 8.6439 18.1964 8.62291 18.1965H5.4927C5.47777 18.1964 5.46317 18.192 5.45068 18.1837C5.43819 18.1754 5.42836 18.1636 5.42239 18.1498C5.41642 18.1359 5.41457 18.1206 5.41706 18.1057C5.41955 18.0908 5.42629 18.0769 5.43643 18.0658L6.09601 17.3484C6.1103 17.3328 6.12759 17.3203 6.14683 17.3118C6.16606 17.3033 6.18682 17.2989 6.20781 17.2989H9.33802C9.35307 17.2986 9.3679 17.3028 9.38061 17.311C9.39332 17.3192 9.40338 17.331 9.40945 17.345C9.41557 17.3589 9.41743 17.3744 9.41486 17.3895C9.41229 17.4045 9.40539 17.4185 9.39503 17.4295Z",fill:"url(#paint0_linear_all_networks)"}),o.jsx("rect",{x:"12.8572",y:"12.8571",width:"6.85714",height:"6.85714",rx:"3.42857",fill:"#999CB3"}),o.jsx("path",{d:"M16.0979 17.4286V15.1429H16.473V17.4286H16.0979ZM15.1426 16.4692V16.097H17.4283V16.4692H15.1426Z",fill:"#2D3153"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"paint0_linear_all_networks",x1:"7.82209",y1:"19.7701",x2:"10.7176",y2:"15.7425",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0.08",stopColor:"#9945FF"}),o.jsx("stop",{offset:"0.3",stopColor:"#8752F3"}),o.jsx("stop",{offset:"0.5",stopColor:"#5497D5"}),o.jsx("stop",{offset:"0.6",stopColor:"#43B4CA"}),o.jsx("stop",{offset:"0.72",stopColor:"#28E0B9"}),o.jsx("stop",{offset:"0.97",stopColor:"#19FB9B"})]})})]})}function Go(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",...e,children:o.jsx("path",{d:"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"})})}function Yt({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}function Kn({className:e="h-4 w-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}function Yn({className:e="h-5 w-5"}){return o.jsxs("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[o.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),o.jsx("path",{strokeLinecap:"round",d:"M12 2a10 10 0 019.17 6"})]})}function Ko({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 20 20",children:o.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}function Ae({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}function Yo(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),o.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}function Zo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...e,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})}function Qo({className:e="h-3.5 w-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function Xo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 29 20",fill:"currentColor",...e,children:o.jsx("path",{d:"M18.1123 4.25181C17.9463 3.49057 17.537 2.8272 16.9727 2.31607C15.4792 0.978457 13.189 1.03283 11.7619 2.4357C11.2751 2.91419 10.9321 3.51232 10.7662 4.18656C10.6002 4.84993 10.6555 5.64381 10.4564 6.50293C10.1798 7.75354 9.53813 8.90629 8.6088 9.81978C7.6131 10.7985 6.34081 11.451 4.95788 11.6903C4.19451 11.8208 3.3205 11.7773 2.57925 12.0165C2.00396 12.2014 1.48398 12.5276 1.07463 12.9409C-0.374675 14.3981 -0.352546 16.7254 1.10782 18.1609C2.535 19.5637 4.84725 19.6181 6.32974 18.2696C6.72802 17.9107 7.04886 17.4757 7.25907 16.9755C7.67947 16.0076 7.52459 15.5944 7.65735 14.6483C7.73479 14.0936 7.87862 13.5608 8.08882 13.0388C8.31009 12.4841 8.3986 12.3319 8.70837 11.8643C9.29473 10.9943 10.0692 10.2548 10.9874 9.73278C12.0053 9.14554 13.178 8.81929 14.4392 8.81929C16.32 8.81929 18.0237 9.56966 19.2628 10.7768C20.2586 11.7446 20.9445 13.0061 21.1879 14.4199C21.3096 15.0941 21.2432 15.8227 21.4202 16.4861C21.5972 17.1386 21.9402 17.715 22.4049 18.1826C23.8763 19.629 26.266 19.629 27.7485 18.1826C29.1646 16.7906 29.231 14.5395 27.8923 13.0823C27.4498 12.6038 26.8855 12.234 26.2549 12.0274C25.4252 11.7664 25.0379 11.8643 24.1971 11.7555C22.6593 11.5598 21.2875 10.8638 20.2475 9.84153C19.1854 8.79754 18.4663 7.40554 18.2893 5.8613C18.1897 5.19793 18.2561 4.87168 18.1123 4.25181ZM16.9617 11.0486C15.5013 9.61316 13.1448 9.61316 11.6844 11.0486C10.2241 12.4841 10.2241 14.8005 11.6844 16.236C13.1448 17.6715 15.5013 17.6715 16.9617 16.236C18.422 14.8005 18.422 12.4841 16.9617 11.0486ZM26.0668 3.13169C24.6065 1.6962 22.25 1.6962 20.7896 3.13169C19.3292 4.56719 19.3292 6.88355 20.7896 8.31904C22.25 9.75453 24.6065 9.75453 26.0668 8.31904C27.5272 6.88355 27.5272 4.56719 26.0668 3.13169ZM7.95606 3.17519C6.49569 1.7397 4.13919 1.7397 2.67882 3.17519C1.21845 4.61069 1.21845 6.92705 2.67882 8.36254C4.13919 9.79803 6.49569 9.79803 7.95606 8.36254C9.41643 6.92705 9.41643 4.59981 7.95606 3.17519Z"})})}function Jo(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 124 22",...e,children:o.jsx("path",{d:"M41.39 4.241c3.385 0 6.162 2.73 6.162 6.058s-2.777 6.003-6.162 6.003h-.62c-3.385 0-6.162-2.676-6.162-6.003S37.385 4.24 40.77 4.24zm-.3 10.745c2.877 0 4.825-2.317 4.825-4.644.055-2.37-1.903-4.796-4.824-4.796-2.976 0-4.879 2.425-4.824 4.796-.01 2.316 1.892 4.644 4.824 4.644m21.353-4.698c0 3.327-2.268 5.992-5.233 5.992h-.62c-2.422 0-3.905-.805-4.978-2.665V22H50.02V4.241h1.593V6.96c.963-1.925 2.666-2.719 4.979-2.719h.62c2.964 0 5.232 2.719 5.232 6.047m-1.703 0c0-2.317-1.649-4.644-4.559-4.644-2.312 0-4.259 1.925-4.259 4.23v.816c0 2.316 1.936 4.187 4.304 4.187 2.832 0 4.514-2.273 4.514-4.59m8.275 6.003c-.354 0-.72-.055-1.073-.196-.874-.305-1.593-.86-2.058-1.61a5 5 0 0 1-.465-1.109c-.1-.402-.155-.707-.155-1.11V5.765h-1.382v-1.36h1.382V.772h1.649v3.632h3.44v1.36h-3.44v6.144c0 1.762.774 2.828 2.722 2.828h1.438v1.566h-2.058zm6.018-15.28c0 .555-.409 1.012-.973 1.012A1.025 1.025 0 0 1 73.03 1.01C73.031.457 73.496 0 74.06 0s.973.457.973 1.011m-1.792 3.23h1.593v12.06h-1.593zm14.283 2.621c.819-1.718 2.511-2.62 4.47-2.62 3.075 0 4.47 2.729 4.47 5.502v6.558H94.87V9.396c0-5.655-6.881-4.698-6.881.196v6.71h-1.594V9.396c0-5.655-6.826-4.698-6.826.196v6.71h-1.637V4.242h1.593v2.065c1.637-2.925 6.716-2.773 7.999.555m17.436 8.124c1.847 0 3.695-1.164 4.304-2.73h1.593c-.819 2.316-2.877 4.035-5.543 4.035h-.664c-3.385 0-5.897-2.676-5.897-6.003s2.512-6.058 5.897-6.058h.664c3.341 0 5.897 2.73 5.897 6.058 0 .195 0 .402-.056.609H100.38c.121 2.273 2.268 4.089 4.58 4.089m4.624-5.296c-.099-2.273-2.257-4.133-4.613-4.133-2.312 0-4.47 1.86-4.569 4.133zM124 4.24l-5.133 6.058L124 16.302h-2.058l-4.104-4.84-4.105 4.84h-2.002l5.133-6.003-5.133-6.058h2.002l4.105 4.84 4.104-4.84zm-105.888-.49a3.67 3.67 0 0 0-1.14-1.935 3.817 3.817 0 0 0-5.21.12 3.67 3.67 0 0 0-.996 1.75c-.166.664-.11 1.458-.31 2.317A6.7 6.7 0 0 1 8.61 9.32a6.88 6.88 0 0 1-3.651 1.87c-.763.13-1.638.087-2.379.327a3.75 3.75 0 0 0-1.504.924 3.667 3.667 0 0 0 .033 5.22c1.427 1.403 3.74 1.457 5.222.109.398-.36.719-.794.93-1.294.42-.968.265-1.382.397-2.328a6.8 6.8 0 0 1 .432-1.61c.221-.554.31-.706.62-1.174a6.862 6.862 0 0 1 5.73-3.045c1.881 0 3.585.75 4.824 1.958a6.64 6.64 0 0 1 1.925 3.643c.122.674.055 1.403.232 2.066.177.653.52 1.229.985 1.697 1.471 1.446 3.861 1.446 5.343 0a3.666 3.666 0 0 0 .144-5.1 3.9 3.9 0 0 0-1.637-1.056c-.83-.26-1.217-.163-2.058-.271a6.86 6.86 0 0 1-3.95-1.914 6.65 6.65 0 0 1-1.958-3.98c-.1-.664-.033-.99-.177-1.61m-1.15 6.798a3.77 3.77 0 0 0-5.278 0 3.62 3.62 0 0 0 0 5.187 3.77 3.77 0 0 0 5.278 0 3.62 3.62 0 0 0 0-5.187m9.105-7.917a3.77 3.77 0 0 0-5.277 0 3.62 3.62 0 0 0 0 5.187 3.77 3.77 0 0 0 5.277 0 3.62 3.62 0 0 0 0-5.187m-18.11.043a3.77 3.77 0 0 0-5.278 0 3.62 3.62 0 0 0 0 5.188 3.77 3.77 0 0 0 5.277 0 3.62 3.62 0 0 0 0-5.188"})})}function es(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 25",fill:"none",...e,children:[o.jsx("mask",{id:"paste_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:"0",y:"0",width:"24",height:"25",children:o.jsx("rect",{y:"0.5",width:"24",height:"24",fill:"#D9D9D9"})}),o.jsx("g",{mask:"url(#paste_mask)",children:o.jsx("path",{d:"M5.30775 20.9999C4.80908 20.9999 4.38308 20.8233 4.02975 20.4701C3.67658 20.1168 3.5 19.6908 3.5 19.1921V5.80762C3.5 5.30895 3.67658 4.88295 4.02975 4.52962C4.38308 4.17645 4.80908 3.99987 5.30775 3.99987H9.7135C9.852 3.5127 10.135 3.10887 10.5625 2.78837C10.99 2.46787 11.4692 2.30762 12 2.30762C12.5513 2.30762 13.0382 2.46787 13.4605 2.78837C13.883 3.10887 14.1635 3.5127 14.302 3.99987H18.6923C19.1909 3.99987 19.6169 4.17645 19.9703 4.52962C20.3234 4.88295 20.5 5.30895 20.5 5.80762V19.1921C20.5 19.6908 20.3234 20.1168 19.9703 20.4701C19.6169 20.8233 19.1909 20.9999 18.6923 20.9999H5.30775ZM5.30775 19.4999H18.6923C18.7692 19.4999 18.8398 19.4678 18.9038 19.4036C18.9679 19.3396 19 19.2691 19 19.1921V5.80762C19 5.73062 18.9679 5.66012 18.9038 5.59612C18.8398 5.53195 18.7692 5.49987 18.6923 5.49987H16.5V8.11512H7.5V5.49987H5.30775C5.23075 5.49987 5.16025 5.53195 5.09625 5.59612C5.03208 5.66012 5 5.73062 5 5.80762V19.1921C5 19.2691 5.03208 19.3396 5.09625 19.4036C5.16025 19.4678 5.23075 19.4999 5.30775 19.4999ZM12 5.61537C12.2577 5.61537 12.4728 5.52912 12.6453 5.35662C12.8176 5.18412 12.9038 4.96903 12.9038 4.71137C12.9038 4.4537 12.8176 4.23862 12.6453 4.06612C12.4728 3.89378 12.2577 3.80762 12 3.80762C11.7423 3.80762 11.5273 3.89378 11.3548 4.06612C11.1824 4.23862 11.0963 4.4537 11.0963 4.71137C11.0963 4.96903 11.1824 5.18412 11.3548 5.35662C11.5273 5.52912 11.7423 5.61537 12 5.61537Z",fill:"currentColor",fillOpacity:.48})})]})}function ts(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M4 12C4 7.58172 7.58172 4 12 4C15.0736 4 17.7555 5.6841 19.2291 8.16667M20 12C20 16.4183 16.4183 20 12 20C8.92638 20 6.24452 18.3159 4.77091 15.8333",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),o.jsx("path",{d:"M19 4V8H15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),o.jsx("path",{d:"M5 20V16H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ns(e){return o.jsxs("svg",{viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("circle",{cx:"32",cy:"32",r:"28",className:"fill-[var(--optimex-error)]/10 stroke-[var(--optimex-error)]",strokeWidth:"2"}),o.jsx("path",{d:"M20 22L26 28M26 22L20 28",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("path",{d:"M38 22L44 28M44 22L38 28",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"}),o.jsx("path",{d:"M22 44C26 38 38 38 42 44",className:"stroke-[var(--optimex-error)]",strokeWidth:"2.5",strokeLinecap:"round"})]})}function rs({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function os({className:e="h-5 w-5"}){return o.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function Zn(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),o.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}function pn({className:e="h-5 w-5"}){return o.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Qn(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 21",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",d:"m11.299 2.846-.553 2.231q.557.126 1.103.263l.549-2.219 1.375.346-.563 2.277c1.737.603 3.008 1.506 2.759 3.188-.18 1.23-.858 1.827-1.757 2.036 1.234.647 1.862 1.641 1.264 3.362-.743 2.137-2.507 2.318-4.854 1.87l-.57 2.3-1.376-.345.562-2.269a53 53 0 0 1-1.096-.287l-.565 2.28-1.374-.346.57-2.304c-.322-.082-.65-.17-.982-.254L4 14.525l.684-1.587c.009.002 1.013.272 1 .251.389.098.562-.158.63-.33l.9-3.633.145.036a1 1 0 0 0-.142-.047l.64-2.593c.018-.295-.082-.667-.64-.807.02-.014-1-.25-1-.25l.367-1.48 1.898.476-.002.008q.43.106.88.207L9.922 2.5zM8.588 13.93c.933.233 3.81 1.164 4.236-.557.444-1.795-2.547-2.26-3.48-2.495zM9.69 9.483c.778.195 3.172.99 3.56-.575.404-1.634-2.098-1.998-2.875-2.193z"})})}function Xn(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 12",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M2.463 8.78a.44.44 0 0 1 .311-.129H13.5a.22.22 0 0 1 .156.376l-2.119 2.124a.44.44 0 0 1-.311.129H.5a.22.22 0 0 1-.156-.377zm0-7.932A.45.45 0 0 1 2.774.72H13.5a.221.221 0 0 1 .156.376L11.536 3.22a.44.44 0 0 1-.311.13H.5a.22.22 0 0 1-.156-.377zm9.074 3.941a.44.44 0 0 0-.311-.13H.5a.22.22 0 0 0-.156.377l2.12 2.124a.44.44 0 0 0 .31.129H13.5a.221.221 0 0 0 .156-.376z"})})}function Jn(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 22",width:"20",height:"20",...e,children:[o.jsx("path",{fill:"currentColor",d:"M6.998 0 .5 11.204l6.498-3.069zM6.998 8.136.5 11.205l6.498 3.992z"}),o.jsx("path",{fill:"currentColor",d:"M13.496 11.204 6.997 0v8.135z"}),o.jsx("path",{fill:"currentColor",d:"m6.997 15.197 6.499-3.992-6.499-3.07zM.5 12.484 6.998 22v-5.526z"}),o.jsx("path",{fill:"currentColor",d:"M6.997 16.474V22l6.502-9.516z"})]})}function er(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M11.984 21.5c4.98 0 9.016-4.03 9.016-9s-4.036-9-9.016-9C7.26 3.5 3.385 7.127 3 11.743h11.917v1.514H3c.385 4.616 4.26 8.243 8.984 8.243"})})}function tr(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:[o.jsxs("g",{fill:"currentColor",fillOpacity:.48,clipPath:"url(#arb_a)",children:[o.jsx("path",{d:"m12.089 14.49 2.278 3.68 2.105-1.255-2.992-4.852zM18.389 15.439l-.002-1.006-3.27-5.24-1.213 2.119 3.157 5.251 1.14-.68a.53.53 0 0 0 .188-.379zM4.688 16.387l1.611.956 5.363-8.85-.91-.024c-.776-.011-1.611.196-1.994.84l-3.046 4.857-1.024 1.62zM14.758 8.494l-2.4.009-5.426 9.214 1.897 1.123.515-.9z"}),o.jsx("path",{d:"M19.4 8.481a1.58 1.58 0 0 0-.718-1.264L12.72 3.69a1.51 1.51 0 0 0-1.368 0c-.05.026-5.8 3.456-5.8 3.456a1.572 1.572 0 0 0-.863 1.333v7.307l1.024-1.62-.009-5.638.007-.06a.52.52 0 0 1 .204-.332c.027-.02 5.875-3.502 5.893-3.512a.5.5 0 0 1 .45-.002l5.887 3.484c.139.091.226.246.234.415v6.984a.52.52 0 0 1-.176.38l-1.141.68-.589.35-2.105 1.256-2.134 1.272a.5.5 0 0 1-.364-.007L9.345 17.94l-.516.9 2.27 1.344.36.207c.161.08.393.127.602.127q.29 0 .556-.108l6.2-3.693c.355-.284.565-.712.584-1.175z"})]}),o.jsx("defs",{children:o.jsx("clipPath",{id:"arb_a",children:o.jsx("path",{fill:"currentColor",d:"M4 3h16v18H4z"})})})]})}function nr(e){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M7.245 16.646q-1.431 0-2.343-.672C4.301 15.52 4 14.867 4 14.03c0-.18.02-.39.058-.647q.154-.862.441-2.08Q5.317 8 8.717 8c.614 0 1.171.102 1.657.314q.73.298 1.152.915.423.604.423 1.44 0 .249-.058.633a26 26 0 0 1-.435 2.08c-.282 1.095-.762 1.92-1.453 2.464-.685.538-1.606.8-2.758.8m.173-1.728c.448 0 .825-.134 1.139-.396q.481-.393.685-1.216c.185-.756.326-1.408.422-1.972q.05-.25.051-.518.002-1.094-1.139-1.094-.672.001-1.152.396-.471.393-.672 1.216c-.147.538-.288 1.19-.435 1.972q-.05.238-.051.505c-.007.743.384 1.107 1.152 1.107M12.506 16.531c-.09 0-.154-.025-.205-.083-.038-.064-.051-.134-.038-.218l1.657-7.808a.32.32 0 0 1 .135-.217.35.35 0 0 1 .23-.083h3.194q1.333.001 2.137.55c.544.371.82.902.82 1.6 0 .198-.026.41-.071.627-.198.922-.602 1.6-1.216 2.042q-.902.66-2.477.659h-1.619l-.55 2.63a.34.34 0 0 1-.135.218.35.35 0 0 1-.23.083zm4.25-4.589c.339 0 .627-.09.876-.275q.383-.277.506-.793.038-.203.038-.359c0-.23-.07-.41-.205-.531-.134-.128-.37-.192-.697-.192h-1.44l-.455 2.15z"})})}function rr(e){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 25",width:"20",height:"20",...e,children:[o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m4.913 12.5.011 3.868 3.286 1.935v2.264L3 17.511V11.37zm0-3.868v2.254L3 9.754V7.5l1.913-1.133L6.836 7.5zM9.582 7.5l1.913-1.133L13.418 7.5l-1.923 1.132z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"M6.297 15.567v-2.265l1.913 1.132v2.254zm3.285 3.547 1.914 1.132 1.923-1.132v2.254L11.496 22.5l-1.914-1.132zM16.163 7.5l1.913-1.133L20 7.5v2.254l-1.923 1.132V8.632zm1.913 8.868.011-3.868L20 11.368v6.142l-5.208 3.056v-2.265z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m16.704 15.567-1.914 1.122v-2.254l1.913-1.133z"}),o.jsx("path",{fill:"currentColor",fillOpacity:.48,d:"m16.704 9.434.01 2.264-3.294 1.934v3.878l-1.913 1.122-1.914-1.122v-3.878l-3.295-1.934V9.434L8.22 8.3l3.275 1.944L14.79 8.3l1.922 1.133zM6.297 5.566 11.496 2.5l5.208 3.066L14.791 6.7l-3.295-1.944L8.21 6.7z"})]})}const hn={bitcoin:Qn,solana:Xn,ethereum:Jn,base:er,arbitrum:tr,optimism:nr,bsc:rr};function ss(e){if(!e)return null;const t=e.toLowerCase().replace(/[\s_-]/g,"");return t in hn?hn[t]:t.includes("bitcoin")||t.includes("btc")?Qn:t.includes("solana")||t.includes("sol")?Xn:t.includes("ethereum")||t.includes("eth")||t.includes("erc20")?Jn:t.includes("base")?er:t.includes("arbitrum")||t.includes("arb")?tr:t.includes("optimism")||t.includes("op")?nr:t.includes("bsc")||t.includes("binance")||t.includes("bnb")?rr:null}function as(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function is({icon:e,label:t,address:n,className:r=""}){const[s,a]=p.useState(!1),l=p.useCallback(async()=>{try{await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),2e3)}catch{console.error("Failed to copy")}},[n]);return o.jsxs("div",{className:`flex items-center justify-between px-4 py-3 ${r}`,children:[o.jsxs("div",{className:"flex items-center gap-2 text-[var(--optimex-text-secondary)]",children:[o.jsx(e,{className:"size-4"}),o.jsx("span",{className:"text-sm",children:t})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:as(n)}),o.jsx("button",{onClick:l,className:"p-1 rounded hover:bg-[var(--optimex-surface-hover)] transition-colors",title:s?"Copied!":"Copy",children:s?o.jsx(Yt,{className:"size-4 text-[var(--optimex-success)]"}):o.jsx(Yo,{className:"size-4 text-[var(--optimex-text-secondary)]"})})]})]})}const ls={primary:"bg-[var(--optimex-primary)] text-black hover:bg-[var(--optimex-primary-hover)] hover:brightness-110 shadow-lg shadow-[var(--optimex-primary)]/30",secondary:"bg-[var(--optimex-surface)] text-[var(--optimex-text)] hover:bg-[var(--optimex-surface-hover)] border border-[var(--optimex-border)]",ghost:"bg-transparent text-[var(--optimex-text-secondary)] hover:bg-[var(--optimex-surface-hover)] hover:text-[var(--optimex-text)]",danger:"bg-[var(--optimex-error)] text-white hover:bg-[var(--optimex-error)]/90 hover:shadow-lg hover:shadow-[var(--optimex-error)]/25"},cs={sm:"px-3 py-1.5 text-xs rounded-md gap-1.5 max-h-[2rem]",md:"px-4 py-2 text-sm rounded-md gap-2 max-h-[2.5rem]",lg:"px-6 py-3 text-sm rounded-md gap-2 max-h-[3rem]"};function or({variant:e="primary",size:t="md",fullWidth:n=!1,isLoading:r=!1,leftIcon:s,rightIcon:a,children:l,className:i="",disabled:c,...d}){const u=c||r;return o.jsxs("button",{className:`
3
3
  group flex items-center justify-center font-semibold transition-all active:scale-[0.98]
4
4
  ${ls[e]}
5
5
  ${cs[t]}
@@ -52,4 +52,4 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
52
52
 
53
53
  For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Ai="DialogDescriptionWarning",Mi=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zr(Ai).contentName}}.`;return h.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Li=Dr,Pi=Br,Oi=zr,Ii=Vr,Di=Hr,$i=qr,Fi=Kr;function Bi(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const Qr=p.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),et=()=>{const e=p.useContext(Qr);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};Bi(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
54
54
  [data-state=closed]
55
- ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function zi(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Vi(){return en(/^Mac/)}function Wi(){return en(/^iPhone/)}function Pn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Hi(){return en(/^iPad/)||Vi()&&navigator.maxTouchPoints>1}function Xr(){return Wi()||Hi()}function en(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Ui=24,qi=typeof window<"u"?p.useLayoutEffect:p.useEffect;function On(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const Pt=typeof document<"u"&&window.visualViewport;function In(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Jr(e){for(In(e)&&(e=e.parentElement);e&&!In(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Gi=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let dt=0,Ot;function Ki(e={}){let{isDisabled:t}=e;qi(()=>{if(!t)return dt++,dt===1&&Xr()&&(Ot=Yi()),()=>{dt--,dt===0&&Ot?.()}},[t])}function Yi(){let e,t=0,n=f=>{e=Jr(f.target),!(e===document.documentElement&&e===document.body)&&(t=f.changedTouches[0].pageY)},r=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let x=f.changedTouches[0].pageY,v=e.scrollTop,w=e.scrollHeight-e.clientHeight;w!==0&&((v<=0&&x>t||v>=w&&x<t)&&f.preventDefault(),t=x)},s=f=>{let x=f.target;Ht(x)&&x!==document.activeElement&&(f.preventDefault(),x.style.transform="translateY(-2000px)",x.focus(),requestAnimationFrame(()=>{x.style.transform=""}))},a=f=>{let x=f.target;Ht(x)&&(x.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{x.style.transform="",Pt&&(Pt.height<window.innerHeight?requestAnimationFrame(()=>{Dn(x)}):Pt.addEventListener("resize",()=>Dn(x),{once:!0}))}))},l=()=>{window.scrollTo(0,0)},i=window.pageXOffset,c=window.pageYOffset,d=On(Zi(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let u=On(Ye(document,"touchstart",n,{passive:!1,capture:!0}),Ye(document,"touchmove",r,{passive:!1,capture:!0}),Ye(document,"touchend",s,{passive:!1,capture:!0}),Ye(document,"focus",a,!0),Ye(window,"scroll",l));return()=>{d(),u(),window.scrollTo(i,c)}}function Zi(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function Ye(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Dn(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let n=Jr(e);if(n!==document.documentElement&&n!==document.body&&n!==e){let r=n.getBoundingClientRect().top,s=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom;const l=n.getBoundingClientRect().bottom+Ui;a>l&&(n.scrollTop+=s-r)}e=n.parentElement}}function Ht(e){return e instanceof HTMLInputElement&&!Gi.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Qi(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Xi(...e){return t=>e.forEach(n=>Qi(n,t))}function eo(...e){return h.useCallback(Xi(...e),e)}const to=new WeakMap;function ee(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([s,a])=>{if(s.startsWith("--")){e.style.setProperty(s,a);return}r[s]=e.style[s],e.style[s]=a}),!n&&to.set(e,r)}function Ji(e,t){if(!e||!(e instanceof HTMLElement))return;let n=to.get(e);n&&(e.style[t]=n[t])}const X=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function ut(e,t){if(!e)return null;const n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[X(t)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[X(t)?5:4]):null)}function el(e){return 8*(Math.log(e+1)-2)}function It(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}function tl(...e){return(...t)=>{for(const n of e)typeof n=="function"&&n(...t)}}const K={DURATION:.5,EASE:[.32,.72,0,1]},no=.4,nl=.25,rl=100,ro=8,_e=16,Ut=26,Dt="vaul-dragging";function oo(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current==null?void 0:t.current.call(t,...n),[])}function ol({defaultProp:e,onChange:t}){const n=p.useState(e),[r]=n,s=p.useRef(r),a=oo(t);return p.useEffect(()=>{s.current!==r&&(a(r),s.current=r)},[r,s,a]),n}function so({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,s]=ol({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:r,i=oo(n),c=p.useCallback(d=>{if(a){const f=typeof d=="function"?d(e):d;f!==e&&i(f)}else s(d)},[a,e,s,i]);return[l,c]}function sl({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:s,fadeFromIndex:a,onSnapPointChange:l,direction:i="bottom",container:c,snapToSequentialPoint:d}){const[u,f]=so({prop:e,defaultProp:n?.[0],onChange:t}),[x,v]=p.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);p.useEffect(()=>{function j(){v({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]);const w=p.useMemo(()=>u===n?.[n.length-1]||null,[n,u]),m=p.useMemo(()=>{var j;return(j=n?.findIndex(C=>C===u))!=null?j:null},[n,u]),y=n&&n.length>0&&(a||a===0)&&!Number.isNaN(a)&&n[a]===u||!n,g=p.useMemo(()=>{const j=c?{width:c.getBoundingClientRect().width,height:c.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var C;return(C=n?.map(R=>{const B=typeof R=="string";let L=0;if(B&&(L=parseInt(R,10)),X(i)){const _=B?L:x?R*j.height:0;return x?i==="bottom"?j.height-_:-j.height+_:_}const D=B?L:x?R*j.width:0;return x?i==="right"?j.width-D:-j.width+D:D}))!=null?C:[]},[n,x,c]),k=p.useMemo(()=>m!==null?g?.[m]:null,[g,m]),N=p.useCallback(j=>{var C;const R=(C=g?.findIndex(B=>B===j))!=null?C:null;l(R),ee(r.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(i)?`translate3d(0, ${j}px, 0)`:`translate3d(${j}px, 0, 0)`}),g&&R!==g.length-1&&a!==void 0&&R!==a&&R<a?ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"0"}):ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"1"}),f(n?.[Math.max(R,0)])},[r.current,n,g,a,s,f]);p.useEffect(()=>{if(u||e){var j;const C=(j=n?.findIndex(R=>R===e||R===u))!=null?j:-1;g&&C!==-1&&typeof g[C]=="number"&&N(g[C])}},[u,e,n,g,N]);function b({draggedDistance:j,closeDrawer:C,velocity:R,dismissible:B}){if(a===void 0)return;const L=i==="bottom"||i==="right"?(k??0)-j:(k??0)+j,D=m===a-1,_=m===0,V=j>0;if(D&&ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`}),!d&&R>2&&!V){B?C():N(g[0]);return}if(!d&&R>2&&V&&g&&n){N(g[n.length-1]);return}const W=g?.reduce((H,S)=>typeof H!="number"||typeof S!="number"?H:Math.abs(S-L)<Math.abs(H-L)?S:H),G=X(i)?window.innerHeight:window.innerWidth;if(R>no&&Math.abs(j)<G*.4){const H=V?1:-1;if(H>0&&w&&n){N(g[n.length-1]);return}if(_&&H<0&&B&&C(),m===null)return;N(g[m+H]);return}N(W)}function A({draggedDistance:j}){if(k===null)return;const C=i==="bottom"||i==="right"?k-j:k+j;(i==="bottom"||i==="right")&&C<g[g.length-1]||(i==="top"||i==="left")&&C>g[g.length-1]||ee(r.current,{transform:X(i)?`translate3d(0, ${C}px, 0)`:`translate3d(${C}px, 0, 0)`})}function I(j,C){if(!n||typeof m!="number"||!g||a===void 0)return null;const R=m===a-1;if(m>=a&&C)return 0;if(R&&!C)return 1;if(!y&&!R)return null;const L=R?m+1:m-1,D=R?g[L]-g[L-1]:g[L+1]-g[L],_=j/Math.abs(D);return R?1-_:_}return{isLastSnapPoint:w,activeSnapPoint:u,shouldFade:y,getPercentageDragged:I,setActiveSnapPoint:f,activeSnapPointIndex:m,onRelease:b,onDrag:A,snapPointsOffset:g}}const al=()=>()=>{};function il(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:s}=et(),a=p.useRef(null),l=p.useMemo(()=>document.body.style.backgroundColor,[]);function i(){return(window.innerWidth-Ut)/window.innerWidth}p.useEffect(()=>{if(t&&n){a.current&&clearTimeout(a.current);const c=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!c)return;tl(r&&!s?It(document.body,{background:"black"}):al,It(c,{transformOrigin:X(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${K.DURATION}s`,transitionTimingFunction:`cubic-bezier(${K.EASE.join(",")})`}));const d=It(c,{borderRadius:`${ro}px`,overflow:"hidden",...X(e)?{transform:`scale(${i()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${i()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{d(),a.current=window.setTimeout(()=>{l?document.body.style.background=l:document.body.style.removeProperty("background")},K.DURATION*1e3)}}},[t,n,l])}let Ze=null;function ll({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:a}){const[l,i]=p.useState(()=>typeof window<"u"?window.location.href:""),c=p.useRef(0),d=p.useCallback(()=>{if(Pn()&&Ze===null&&e&&!a){Ze={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:x}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-c.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const v=x-window.innerHeight;v&&c.current>=x&&(document.body.style.top=`${-(c.current+v)}px`)}),300)}},[e]),u=p.useCallback(()=>{if(Pn()&&Ze!==null&&!a){const f=-parseInt(document.body.style.top,10),x=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Ze),window.requestAnimationFrame(()=>{if(s&&l!==window.location.href){i(window.location.href);return}window.scrollTo(x,f)}),Ze=null}},[l]);return p.useEffect(()=>{function f(){c.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),p.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||u()}},[t,u]),p.useEffect(()=>{n||!r||(e?(!window.matchMedia("(display-mode: standalone)").matches&&d(),t||window.setTimeout(()=>{u()},500)):u())},[e,r,l,t,n,d,u]),{restorePositionSetting:u}}function cl({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:s,snapPoints:a,shouldScaleBackground:l=!1,setBackgroundColorOnScale:i=!0,closeThreshold:c=nl,scrollLockTimeout:d=rl,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:x=a&&a.length-1,activeSnapPoint:v,setActiveSnapPoint:w,fixed:m,modal:y=!0,onClose:g,nested:k,noBodyStyles:N=!1,direction:b="bottom",defaultOpen:A=!1,disablePreventScroll:I=!0,snapToSequentialPoint:j=!1,preventScrollRestoration:C=!1,repositionInputs:R=!0,onAnimationEnd:B,container:L,autoFocus:D=!1}){var _,V;const[W=!1,G]=so({defaultProp:A,prop:e,onChange:M=>{t?.(M),!M&&!k&&bo(),setTimeout(()=>{B?.(M)},K.DURATION*1e3),M&&!y&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),M||(document.body.style.pointerEvents="auto")}}),[H,S]=p.useState(!1),[ne,oe]=p.useState(!1),[Ne,ue]=p.useState(!1),U=p.useRef(null),Q=p.useRef(null),ie=p.useRef(null),he=p.useRef(null),$=p.useRef(null),fe=p.useRef(!1),xe=p.useRef(null),ge=p.useRef(0),le=p.useRef(!1),Se=p.useRef(!A),sn=p.useRef(0),P=p.useRef(null),an=p.useRef(((_=P.current)==null?void 0:_.getBoundingClientRect().height)||0),ln=p.useRef(((V=P.current)==null?void 0:V.getBoundingClientRect().width)||0),yt=p.useRef(0),ho=p.useCallback(M=>{a&&M===qe.length-1&&(Q.current=new Date)},[]),{activeSnapPoint:xo,activeSnapPointIndex:Oe,setActiveSnapPoint:cn,onRelease:go,snapPointsOffset:qe,onDrag:vo,shouldFade:dn,getPercentageDragged:wo}=sl({snapPoints:a,activeSnapPointProp:v,setActiveSnapPointProp:w,drawerRef:P,fadeFromIndex:x,overlayRef:U,onSnapPointChange:ho,direction:b,container:L,snapToSequentialPoint:j});Ki({isDisabled:!W||ne||!y||Ne||!H||!R||!I});const{restorePositionSetting:bo}=ll({isOpen:W,modal:y,nested:k??!1,hasBeenOpened:H,preventScrollRestoration:C,noBodyStyles:N});function tt(){return(window.innerWidth-Ut)/window.innerWidth}function yo(M){var z,q;!u&&!a||P.current&&!P.current.contains(M.target)||(an.current=((z=P.current)==null?void 0:z.getBoundingClientRect().height)||0,ln.current=((q=P.current)==null?void 0:q.getBoundingClientRect().width)||0,oe(!0),ie.current=new Date,Xr()&&window.addEventListener("touchend",()=>fe.current=!1,{once:!0}),M.target.setPointerCapture(M.pointerId),ge.current=X(b)?M.pageY:M.pageX)}function un(M,z){var q;let F=M;const Z=(q=window.getSelection())==null?void 0:q.toString(),re=P.current?ut(P.current,b):null,te=new Date;if(F.tagName==="SELECT"||F.hasAttribute("data-vaul-no-drag")||F.closest("[data-vaul-no-drag]"))return!1;if(b==="right"||b==="left")return!0;if(Q.current&&te.getTime()-Q.current.getTime()<500)return!1;if(re!==null&&(b==="bottom"?re>0:re<0))return!0;if(Z&&Z.length>0)return!1;if($.current&&te.getTime()-$.current.getTime()<d&&re===0||z)return $.current=te,!1;for(;F;){if(F.scrollHeight>F.clientHeight){if(F.scrollTop!==0)return $.current=new Date,!1;if(F.getAttribute("role")==="dialog")return!0}F=F.parentNode}return!0}function Co(M){if(P.current&&ne){const z=b==="bottom"||b==="right"?1:-1,q=(ge.current-(X(b)?M.pageY:M.pageX))*z,F=q>0,Z=a&&!u&&!F;if(Z&&Oe===0)return;const re=Math.abs(q),te=document.querySelector("[data-vaul-drawer-wrapper]"),ve=b==="bottom"||b==="top"?an.current:ln.current;let se=re/ve;const Ee=wo(re,F);if(Ee!==null&&(se=Ee),Z&&se>=1||!fe.current&&!un(M.target,F))return;if(P.current.classList.add(Dt),fe.current=!0,ee(P.current,{transition:"none"}),ee(U.current,{transition:"none"}),a&&vo({draggedDistance:q}),F&&!a){const ce=el(q),nt=Math.min(ce*-1,0)*z;ee(P.current,{transform:X(b)?`translate3d(0, ${nt}px, 0)`:`translate3d(${nt}px, 0, 0)`});return}const we=1-se;if((dn||x&&Oe===x-1)&&(r?.(M,se),ee(U.current,{opacity:`${we}`,transition:"none"},!0)),te&&U.current&&l){const ce=Math.min(tt()+se*(1-tt()),1),nt=8-se*8,mn=Math.max(0,14-se*14);ee(te,{borderRadius:`${nt}px`,transform:X(b)?`scale(${ce}) translate3d(0, ${mn}px, 0)`:`scale(${ce}) translate3d(${mn}px, 0, 0)`,transition:"none"},!0)}if(!a){const ce=re*z;ee(P.current,{transform:X(b)?`translate3d(0, ${ce}px, 0)`:`translate3d(${ce}px, 0, 0)`})}}}p.useEffect(()=>{window.requestAnimationFrame(()=>{Se.current=!0})},[]),p.useEffect(()=>{var M;function z(){if(!P.current||!R)return;const q=document.activeElement;if(Ht(q)||le.current){var F;const Z=((F=window.visualViewport)==null?void 0:F.height)||0,re=window.innerHeight;let te=re-Z;const ve=P.current.getBoundingClientRect().height||0,se=ve>re*.8;yt.current||(yt.current=ve);const Ee=P.current.getBoundingClientRect().top;if(Math.abs(sn.current-te)>60&&(le.current=!le.current),a&&a.length>0&&qe&&Oe){const we=qe[Oe]||0;te+=we}if(sn.current=te,ve>Z||le.current){const we=P.current.getBoundingClientRect().height;let ce=we;we>Z&&(ce=Z-(se?Ee:Ut)),m?P.current.style.height=`${we-Math.max(te,0)}px`:P.current.style.height=`${Math.max(ce,Z-Ee)}px`}else zi()||(P.current.style.height=`${yt.current}px`);a&&a.length>0&&!le.current?P.current.style.bottom="0px":P.current.style.bottom=`${Math.max(te,0)}px`}}return(M=window.visualViewport)==null||M.addEventListener("resize",z),()=>{var q;return(q=window.visualViewport)==null?void 0:q.removeEventListener("resize",z)}},[Oe,a,qe]);function Ge(M){ko(),g?.(),M||G(!1),setTimeout(()=>{a&&cn(a[0])},K.DURATION*1e3)}function fn(){if(!P.current)return;const M=document.querySelector("[data-vaul-drawer-wrapper]"),z=ut(P.current,b);ee(P.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`}),ee(U.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"1"}),l&&z&&z>0&&W&&ee(M,{borderRadius:`${ro}px`,overflow:"hidden",...X(b)?{transform:`scale(${tt()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${tt()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${K.DURATION}s`,transitionTimingFunction:`cubic-bezier(${K.EASE.join(",")})`},!0)}function ko(){!ne||!P.current||(P.current.classList.remove(Dt),fe.current=!1,oe(!1),he.current=new Date)}function jo(M){if(!ne||!P.current)return;P.current.classList.remove(Dt),fe.current=!1,oe(!1),he.current=new Date;const z=ut(P.current,b);if(!M||!un(M.target,!1)||!z||Number.isNaN(z)||ie.current===null)return;const q=he.current.getTime()-ie.current.getTime(),F=ge.current-(X(b)?M.pageY:M.pageX),Z=Math.abs(F)/q;if(Z>.05&&(ue(!0),setTimeout(()=>{ue(!1)},200)),a){go({draggedDistance:F*(b==="bottom"||b==="right"?1:-1),closeDrawer:Ge,velocity:Z,dismissible:u}),s?.(M,!0);return}if(b==="bottom"||b==="right"?F>0:F<0){fn(),s?.(M,!0);return}if(Z>no){Ge(),s?.(M,!1);return}var re;const te=Math.min((re=P.current.getBoundingClientRect().height)!=null?re:0,window.innerHeight);var ve;const se=Math.min((ve=P.current.getBoundingClientRect().width)!=null?ve:0,window.innerWidth),Ee=b==="left"||b==="right";if(Math.abs(z)>=(Ee?se:te)*c){Ge(),s?.(M,!1);return}s?.(M,!0),fn()}p.useEffect(()=>(W&&(ee(document.documentElement,{scrollBehavior:"auto"}),Q.current=new Date),()=>{Ji(document.documentElement,"scrollBehavior")}),[W]);function No(M){const z=M?(window.innerWidth-_e)/window.innerWidth:1,q=M?-_e:0;xe.current&&window.clearTimeout(xe.current),ee(P.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(b)?`scale(${z}) translate3d(0, ${q}px, 0)`:`scale(${z}) translate3d(${q}px, 0, 0)`}),!M&&P.current&&(xe.current=setTimeout(()=>{const F=ut(P.current,b);ee(P.current,{transition:"none",transform:X(b)?`translate3d(0, ${F}px, 0)`:`translate3d(${F}px, 0, 0)`})},500))}function So(M,z){if(z<0)return;const q=(window.innerWidth-_e)/window.innerWidth,F=q+z*(1-q),Z=-_e+z*_e;ee(P.current,{transform:X(b)?`scale(${F}) translate3d(0, ${Z}px, 0)`:`scale(${F}) translate3d(${Z}px, 0, 0)`,transition:"none"})}function Eo(M,z){const q=X(b)?window.innerHeight:window.innerWidth,F=z?(q-_e)/q:1,Z=z?-_e:0;z&&ee(P.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(b)?`scale(${F}) translate3d(0, ${Z}px, 0)`:`scale(${F}) translate3d(${Z}px, 0, 0)`})}return p.useEffect(()=>{y||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[y]),p.createElement(Li,{defaultOpen:A,onOpenChange:M=>{!u&&!M||(M?S(!0):Ge(!0),G(M))},open:W},p.createElement(Qr.Provider,{value:{activeSnapPoint:xo,snapPoints:a,setActiveSnapPoint:cn,drawerRef:P,overlayRef:U,onOpenChange:t,onPress:yo,onRelease:jo,onDrag:Co,dismissible:u,shouldAnimate:Se,handleOnly:f,isOpen:W,isDragging:ne,shouldFade:dn,closeDrawer:Ge,onNestedDrag:So,onNestedOpenChange:No,onNestedRelease:Eo,keyboardIsOpen:le,modal:y,snapPointsOffset:qe,activeSnapPointIndex:Oe,direction:b,shouldScaleBackground:l,setBackgroundColorOnScale:i,noBodyStyles:N,container:L,autoFocus:D}},n))}const ao=p.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:r,onRelease:s,shouldFade:a,isOpen:l,modal:i,shouldAnimate:c}=et(),d=eo(t,n),u=r&&r.length>0;if(!i)return null;const f=p.useCallback(x=>s(x),[s]);return p.createElement(Oi,{onMouseUp:f,ref:d,"data-vaul-overlay":"","data-vaul-snap-points":l&&u?"true":"false","data-vaul-snap-points-overlay":l&&a?"true":"false","data-vaul-animate":c?.current?"true":"false",...e})});ao.displayName="Drawer.Overlay";const io=p.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},s){const{drawerRef:a,onPress:l,onRelease:i,onDrag:c,keyboardIsOpen:d,snapPointsOffset:u,activeSnapPointIndex:f,modal:x,isOpen:v,direction:w,snapPoints:m,container:y,handleOnly:g,shouldAnimate:k,autoFocus:N}=et(),[b,A]=p.useState(!1),I=eo(s,a),j=p.useRef(null),C=p.useRef(null),R=p.useRef(!1),B=m&&m.length>0;il();const L=(_,V,W=0)=>{if(R.current)return!0;const G=Math.abs(_.y),H=Math.abs(_.x),S=H>G,ne=["bottom","right"].includes(V)?1:-1;if(V==="left"||V==="right"){if(!(_.x*ne<0)&&H>=0&&H<=W)return S}else if(!(_.y*ne<0)&&G>=0&&G<=W)return!S;return R.current=!0,!0};p.useEffect(()=>{B&&window.requestAnimationFrame(()=>{A(!0)})},[]);function D(_){j.current=null,R.current=!1,i(_)}return p.createElement(Ii,{"data-vaul-drawer-direction":w,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":v&&B?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":k?.current?"true":"false",...r,ref:I,style:u&&u.length>0?{"--snap-point-height":`${u[f??0]}px`,...t}:t,onPointerDown:_=>{g||(r.onPointerDown==null||r.onPointerDown.call(r,_),j.current={x:_.pageX,y:_.pageY},l(_))},onOpenAutoFocus:_=>{n?.(_),N||_.preventDefault()},onPointerDownOutside:_=>{if(e?.(_),!x||_.defaultPrevented){_.preventDefault();return}d.current&&(d.current=!1)},onFocusOutside:_=>{if(!x){_.preventDefault();return}},onPointerMove:_=>{if(C.current=_,g||(r.onPointerMove==null||r.onPointerMove.call(r,_),!j.current))return;const V=_.pageY-j.current.y,W=_.pageX-j.current.x,G=_.pointerType==="touch"?10:2;L({x:W,y:V},w,G)?c(_):(Math.abs(W)>G||Math.abs(V)>G)&&(j.current=null)},onPointerUp:_=>{r.onPointerUp==null||r.onPointerUp.call(r,_),j.current=null,R.current=!1,i(_)},onPointerOut:_=>{r.onPointerOut==null||r.onPointerOut.call(r,_),D(C.current)},onContextMenu:_=>{r.onContextMenu==null||r.onContextMenu.call(r,_),C.current&&D(C.current)}})});io.displayName="Drawer.Content";const dl=250,ul=120,fl=p.forwardRef(function({preventCycle:e=!1,children:t,...n},r){const{closeDrawer:s,isDragging:a,snapPoints:l,activeSnapPoint:i,setActiveSnapPoint:c,dismissible:d,handleOnly:u,isOpen:f,onPress:x,onDrag:v}=et(),w=p.useRef(null),m=p.useRef(!1);function y(){if(m.current){N();return}window.setTimeout(()=>{g()},ul)}function g(){if(a||e||m.current){N();return}if(N(),!l||l.length===0){d||s();return}if(i===l[l.length-1]&&d){s();return}const A=l.findIndex(j=>j===i);if(A===-1)return;const I=l[A+1];c(I)}function k(){w.current=window.setTimeout(()=>{m.current=!0},dl)}function N(){w.current&&window.clearTimeout(w.current),m.current=!1}return p.createElement("div",{onClick:y,onPointerCancel:N,onPointerDown:b=>{u&&x(b),k()},onPointerMove:b=>{u&&v(b)},ref:r,"data-vaul-drawer-visible":f?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},p.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});fl.displayName="Drawer.Handle";function ml(e){const t=et(),{container:n=t.container,...r}=e;return p.createElement(Pi,{container:n,...r})}const Re={Root:cl,Content:io,Overlay:ao,Portal:ml,Close:Fi,Title:Di,Description:$i};function pl(e=768){const[t,n]=p.useState(!1);return p.useEffect(()=>{const r=()=>{n(window.innerWidth<e)};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[e]),t}function tn({open:e,onOpenChange:t,children:n,title:r,description:s,className:a="",showCloseButton:l=!0}){return pl()?o.jsx(Re.Root,{open:e,onOpenChange:t,children:o.jsxs(Re.Portal,{children:[o.jsx(Re.Overlay,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),o.jsxs(Re.Content,{className:`fixed inset-x-0 bottom-0 z-50 mt-24 flex max-h-[96vh] flex-col rounded-t-2xl bg-[var(--optimex-surface)] border-t border-white/[0.05] outline-none ${a}`,children:[o.jsx("div",{className:"mx-auto mt-4 h-1.5 w-12 flex-shrink-0 rounded-full bg-white/20"}),(r||l)&&o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.05] px-4 pb-4 pt-2",children:[o.jsxs("div",{children:[r&&o.jsx(Re.Title,{className:"text-lg font-bold text-white",children:r}),s&&o.jsx(Re.Description,{className:"text-sm text-white/40",children:s})]}),l&&o.jsx(Re.Close,{className:"rounded-lg p-1.5 text-white/40 transition-colors hover:bg-white/10 hover:text-white/60",children:o.jsx(Ae,{})})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:n})]})]})}):e?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>t(!1)}),o.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,"aria-describedby":s?"modal-description":void 0,className:`relative z-10 flex max-h-[90vh] flex-col rounded-2xl bg-[var(--optimex-surface)] border border-white/[0.05] shadow-2xl ${a}`,children:[(r||l)&&o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.05] p-4",children:[o.jsxs("div",{children:[r&&o.jsx("h2",{id:"modal-title",className:"text-lg font-bold text-white",children:r}),s&&o.jsx("p",{id:"modal-description",className:"text-sm text-white/40",children:s})]}),l&&o.jsx("button",{onClick:()=>t(!1),className:"rounded-lg p-1.5 text-white/40 transition-colors hover:bg-white/10 hover:text-white/60",children:o.jsx(Ae,{})})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:n})]})]}):null}const hl=({children:e,className:t=""})=>o.jsx("div",{className:`p-4 ${t}`,children:e}),xl=({children:e,className:t=""})=>o.jsx("div",{className:`flex gap-2 border-t border-white/[0.05] p-4 ${t}`,children:e});function qt({children:e,onClick:t,isActive:n=!1,type:r="button",className:s=""}){return o.jsx("button",{type:r,onClick:t,className:vr(`px-2 py-1 bg-zinc-800/80 rounded-md text-xs transition-colors shadow-sm border ${n?"border-[var(--optimex-primary)]":"border-transparent text-white hover:bg-white/10 hover:text-white"} ${s}`),children:e})}const gl={"bottom-right":"right-0 top-full mt-2","bottom-left":"left-0 top-full mt-2","bottom-center":"left-1/2 -translate-x-1/2 top-full mt-2","top-right":"right-0 bottom-full mb-2","top-left":"left-0 bottom-full mb-2","top-center":"left-1/2 -translate-x-1/2 bottom-full mb-2"},vl={"bottom-right":"-top-2 right-4 rotate-45 border-l border-t","bottom-left":"-top-2 left-4 rotate-45 border-l border-t","bottom-center":"-top-2 left-1/2 -translate-x-1/2 rotate-45 border-l border-t","top-right":"-bottom-2 right-4 rotate-45 border-r border-b","top-left":"-bottom-2 left-4 rotate-45 border-r border-b","top-center":"-bottom-2 left-1/2 -translate-x-1/2 rotate-45 border-r border-b"};function wl({isOpen:e,onClose:t,children:n,anchorRef:r,position:s="bottom-right",width:a="w-72",showArrow:l=!0,className:i="",ariaLabel:c}){const d=p.useRef(null);return p.useEffect(()=>{if(!e)return;const u=v=>{const w=v.target;d.current?.contains(w)||r?.current?.contains(w)||t()},f=v=>{v.key==="Escape"&&t()},x=setTimeout(()=>{document.addEventListener("mousedown",u),document.addEventListener("keydown",f)},0);return()=>{clearTimeout(x),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[e,t,r]),e?o.jsxs("div",{ref:d,className:`absolute z-50 rounded-[0.25rem] border border-[var(--optimex-border)] bg-[var(--optimex-surface)] p-4 shadow-lg ${gl[s]} ${a} ${i}`,role:"dialog","aria-label":c,children:[l&&o.jsx("div",{className:`absolute h-4 w-4 border-[var(--optimex-border)] bg-[var(--optimex-surface)] ${vl[s]}`}),o.jsx("div",{className:"relative",children:n})]}):null}function bl({value:e,onChange:t,placeholder:n,hasError:r=!1,leftIcon:s,rightContent:a,type:l="text",inputMode:i="text",disabled:c=!1,className:d=""}){return o.jsxs("div",{className:`flex rounded-md items-center gap-2 bg-white/5 border py-3 px-3 transition-colors ${r?"border-red-500":"border-white/10 hover:border-[var(--optimex-primary)] focus-within:border-[var(--optimex-primary)]"} ${c?"opacity-50 cursor-not-allowed":""} ${d}`,children:[s&&o.jsx(s,{className:"size-5 text-white/40 shrink-0"}),o.jsx("input",{type:l,inputMode:i,value:e,onChange:u=>t(u.target.value),placeholder:n,disabled:c,className:"flex-1 min-w-0 bg-transparent text-white text-sm placeholder:text-white/10 outline-none disabled:cursor-not-allowed"}),a]})}const yl={sm:{container:"h-6 w-6",icon:"h-6 w-6",badge:"h-3 w-3"},md:{container:"h-8 w-8",icon:"h-8 w-8",badge:"h-4 w-4"},lg:{container:"h-10 w-10",icon:"h-10 w-10",badge:"h-5 w-5"},xl:{container:"h-14 w-14",icon:"h-14 w-14",badge:"h-6 w-6"}};function Le({token:e,size:t="md",showNetworkBadge:n=!0}){const r=yl[t];return o.jsxs("div",{className:`relative shrink-0 ${r.container}`,children:[o.jsx("img",{src:e.token_logo_uri||"/placeholder-token.svg",alt:e.token_symbol,className:`${r.icon} rounded-full bg-[var(--optimex-background)]`,onError:s=>{s.target.src="/placeholder-token.svg"}}),n&&e.network_logo_uri&&o.jsx("img",{src:e.network_logo_uri,alt:e.network_name,className:`absolute -bottom-1 -right-1 ${r.badge} rounded-full border-2 border-[var(--optimex-surface)]`,onError:s=>{s.target.style.display="none"}})]})}const Cl="glass-container rounded-3xl p-4 shadow-2xl relative w-full min-w-0";function nn({children:e,className:t}){return o.jsx("div",{className:t??Cl,children:e})}function kl(){return o.jsxs("div",{className:"relative size-20 mb-4",children:[o.jsx("div",{className:"absolute inset-0 rounded-full bg-red-500/10 animate-pulse"}),o.jsx("div",{className:"absolute inset-2 rounded-full bg-red-500/20"}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx(ns,{className:"size-10 text-red-500"})})]})}function jl({error:e,onRetry:t,className:n}){const r=()=>{const s=e?.message?.toLowerCase()||"";return s.includes("network")||s.includes("fetch")?"Connection issue. Check your internet and try again.":s.includes("timeout")?"Request timed out. The server might be busy.":s.includes("401")||s.includes("403")?"Access denied. Please check your credentials.":s.includes("500")||s.includes("server")?"Server is having issues. Please try again later.":"Something went wrong while loading. Let's give it another shot!"};return o.jsx(nn,{className:n,children:o.jsx("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-6 border border-white/[0.02]",children:o.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[o.jsx(kl,{}),o.jsx("h3",{className:"text-base font-bold text-white mb-1",children:"Oops! Something went wrong"}),o.jsx("p",{className:"text-sm text-white/40 mb-6 max-w-[280px]",children:r()}),o.jsx(or,{onClick:t,size:"md",fullWidth:!0,leftIcon:o.jsx(ts,{className:"size-4 transition-transform group-hover:rotate-180"}),children:"Try Again"}),e?.message&&o.jsxs("details",{className:"mt-4 w-full",children:[o.jsx("summary",{className:"cursor-pointer text-xs text-white/30 hover:text-white/50 transition-colors",children:"Technical details"}),o.jsx("p",{className:"mt-2 bg-white/5 p-3 text-left text-xs text-white/40 break-all border border-white/[0.02]",children:e.message})]})]})})})}function Nl({className:e}){return o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("header",{className:"flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 rounded-lg bg-[var(--optimex-primary)]/30 animate-pulse"}),o.jsx("div",{className:"h-6 w-28 rounded bg-white/10 animate-pulse"})]}),o.jsx("div",{className:"size-10 rounded-lg bg-white/5 animate-pulse"})]}),o.jsxs(nn,{className:e,children:[o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-2",children:[o.jsx("div",{className:"flex justify-between items-center mb-4",children:o.jsx("div",{className:"h-3 w-10 animate-pulse rounded bg-white/10"})}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-white/10 mb-2"}),o.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-white/5"})]}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 p-2 pr-3 rounded-full border border-white/10",children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10 animate-pulse"}),o.jsxs("div",{children:[o.jsx("div",{className:"h-4 w-12 animate-pulse rounded bg-white/10 mb-1"}),o.jsx("div",{className:"h-2 w-16 animate-pulse rounded bg-white/5"})]})]})]})]}),o.jsx("div",{className:"relative z-10 -my-4 flex justify-center",children:o.jsx("div",{className:"size-10 rounded-full bg-[var(--optimex-surface)] border-4 border-[var(--optimex-background)] animate-pulse"})}),o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-4",children:[o.jsx("div",{className:"flex justify-between items-center mb-4",children:o.jsx("div",{className:"h-3 w-6 animate-pulse rounded bg-white/10"})}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-8 w-20 animate-pulse rounded bg-white/10 mb-2"}),o.jsx("div",{className:"h-3 w-14 animate-pulse rounded bg-white/5"})]}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 p-2 pr-3 rounded-full border border-white/10",children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10 animate-pulse"}),o.jsxs("div",{children:[o.jsx("div",{className:"h-4 w-12 animate-pulse rounded bg-white/10 mb-1"}),o.jsx("div",{className:"h-2 w-16 animate-pulse rounded bg-white/5"})]})]})]})]}),o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-4",children:[o.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-white/10 mb-2"}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 border border-white/10 py-3 px-3 rounded-md",children:[o.jsx("div",{className:"size-5 rounded-full bg-white/10 animate-pulse shrink-0"}),o.jsx("div",{className:"h-4 flex-1 animate-pulse rounded bg-white/5"})]}),o.jsx("div",{className:"h-2 w-48 animate-pulse rounded bg-white/5 mt-2"})]}),o.jsx("div",{className:"h-12 w-full animate-pulse rounded-xl bg-[var(--optimex-primary)]/30 bg-white/5 mt-2"}),o.jsx("div",{className:"mt-4 flex items-center justify-center",children:o.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-white/5"})})]})]})}const lo=p.createContext(null);function Sl({children:e}){const t=Je(),{data:n,isLoading:r,error:s,refetch:a}=Po(t.apiBaseUrl),l=t.renderLoading??Nl,i=t.renderError??jl;if(r)return o.jsx(l,{});if(s||!n){const c=s instanceof Error?s:new Error("Failed to load tokens");return o.jsx(i,{error:c,onRetry:()=>a()})}return o.jsx(lo.Provider,{value:{tokensData:n,refetch:a},children:e})}function El(){const e=p.useContext(lo);if(!e)throw new Error("useTokensData must be used within TokensProvider");return e}function Tl({token:e,value:t,onChange:n,placeholder:r,error:s,onClose:a}){const l=p.useCallback(()=>{n("")},[n]),i=p.useCallback(async()=>{try{const f=await navigator.clipboard.readText();f&&n(f.trim())}catch(f){console.error("Failed to read clipboard:",f)}},[n]),c=()=>r||(e?`Enter ${e.network_name} address`:"Enter receiving address"),d=e?.network_name||"destination",u=p.useMemo(()=>ss(e?.network_name)||Zn,[e?.network_name]);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.05] animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("label",{className:"text-white/40 text-xs",children:"Recipient Address"}),a&&o.jsx("button",{type:"button",onClick:l,className:"text-white/20 hover:text-white/40 transition-colors",children:o.jsx(Ae,{className:"size-4"})})]}),o.jsx(bl,{value:t,onChange:n,placeholder:c(),hasError:!!s,leftIcon:u,rightContent:t?o.jsx("button",{type:"button",onClick:l,className:"text-white/40 hover:text-white/60 transition-colors",children:o.jsx(Ae,{className:"size-5"})}):o.jsx("button",{type:"button",onClick:i,className:"text-white/40 hover:text-[var(--optimex-primary)] transition-colors",children:o.jsx(es,{className:"size-5"})})}),s?o.jsxs("p",{className:"text-[10px] text-red-500 mt-2 flex items-center gap-1",children:[o.jsx(pn,{className:"size-3"}),s]}):o.jsxs("p",{className:"text-[10px] text-white/40 mt-2 flex items-center gap-1",children:[o.jsx(pn,{className:"size-3"}),"Ensure the address matches the ",d," network."]})]})}function $n({token:e,value:t,onChange:n,readOnly:r=!1,onSelectToken:s,isLoading:a=!1,loadingText:l="Loading...",balance:i,isOutput:c=!1,isWalletConnected:d=!1,usdValue:u="$0.00"}){const f=m=>{if(r||!n)return;const y=m.target.value;/^[0-9]*\.?[0-9]*$/.test(y)&&n(y)},x=d&&!c&&i!==void 0,v=()=>{if(!i||!n||r)return;const m=(parseFloat(i)/2).toString();n(m)},w=()=>{!i||!n||r||n(i)};return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 flex flex-col gap-2 border border-white/[0.02] focus-within:border-[var(--optimex-primary)]/40 transition-colors",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-white/40 text-xs",children:c?"To":"From"}),o.jsx("div",{className:"flex items-center gap-2",children:x&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-white/40 text-xs",children:["Balance: ",i," ",e?.token_symbol]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(qt,{onClick:v,children:"50%"}),o.jsx(qt,{onClick:w,children:"Max"})]})]})})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0.0",value:t,onChange:f,readOnly:r,className:"w-full bg-transparent border-none p-0 text-white text-2xl font-bold focus:ring-0 placeholder:text-white/10 outline-none"}),o.jsxs("p",{className:"text-white/30 text-xs mt-1",children:["~",u]})]}),o.jsxs("button",{onClick:s,className:"flex items-center gap-2 bg-white/5 hover:bg-white/10 p-2 pr-3 rounded-full transition-all border border-white/10 active:scale-95 shrink-0",children:[e?o.jsxs(o.Fragment,{children:[o.jsx(Le,{token:e,size:"md"}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-white text-sm font-bold leading-none",children:e.token_symbol}),o.jsx("p",{className:"text-white/40 text-[10px] leading-none mt-1",children:e.network_name})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10"}),o.jsx("span",{className:"text-white text-sm font-bold",children:"Select"})]}),o.jsx(Kn,{className:"size-4 text-white/20"})]})]}),a&&o.jsxs("div",{className:"flex items-center justify-end gap-2 text-sm text-white/40",children:[o.jsx("div",{className:"size-3 animate-spin rounded-full border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:l})]})]})}const $t=[.5,.75,1];function _l({value:e,onChange:t}){const[n,r]=p.useState(""),[s,a]=p.useState(!$t.includes(e)),l=p.useCallback(d=>{a(!1),r(""),t(d)},[t]),i=p.useCallback(d=>{const u=d.target.value;if(u===""||/^\d*\.?\d*$/.test(u)){r(u),a(!0);const f=parseFloat(u);!isNaN(f)&&f>0&&f<=50&&t(f)}},[t]),c=p.useCallback(()=>{a(!0),!n&&e&&r($t.includes(e)?"":String(e))},[n,e]);return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:"Slippage Tolerance"}),o.jsxs("span",{className:"text-sm text-[var(--optimex-text-secondary)]",children:[e,"%"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[$t.map(d=>o.jsxs(qt,{onClick:()=>l(d),isActive:e===d&&!s,className:"flex-1",children:[d,"%"]},d)),o.jsxs("div",{className:`flex flex-1 items-center justify-center px-2 rounded-md transition-colors shadow-sm bg-zinc-800/80 border ${s?"border-[var(--optimex-primary)]":"border-transparent hover:bg-white/10"}`,children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Custom",value:n,onChange:i,onFocus:c,className:"w-full min-w-0 py-[6px] bg-transparent text-center text-xs outline-none placeholder:text-white/50 text-white"}),o.jsx("span",{className:"text-xs text-white/50",children:"%"})]})]}),e>5&&o.jsx("p",{className:"text-xs text-[var(--optimex-warning)]",children:"This may result in an unfavorable trade. Try lowering your slippage setting."})]})}function Rl({isOpen:e,onClose:t,value:n,onChange:r,anchorRef:s}){const a=p.useCallback(l=>{r(l)},[r]);return o.jsx(wl,{isOpen:e,onClose:t,anchorRef:s,position:"bottom-right",width:"w-96",ariaLabel:"Slippage settings",children:o.jsx(_l,{value:n,onChange:a})})}function Al({title:e="Swap",slippage:t=.75,onSlippageChange:n,isSettingsOpen:r=!1,onSettingsToggle:s,onHistoryClick:a,hideHistory:l=!1}){const i=p.useRef(null);return o.jsxs("header",{className:"flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 bg-[var(--optimex-primary)] rounded-lg flex items-center justify-center shadow-[0_0_15px_rgba(235,98,0,0.3)]",children:o.jsx(Xo,{className:"w-5 h-auto text-white"})}),o.jsx("h2",{className:"text-xl font-bold tracking-tight text-[var(--optimex-text)]",children:e})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[!l&&o.jsx("button",{onClick:a,className:"size-10 rounded-lg bg-white/5 hover:bg-white/10 text-white/60 hover:text-white transition-colors flex items-center justify-center","aria-label":"Trade History",children:o.jsx(Zo,{className:"size-5"})}),o.jsxs("div",{className:"relative",children:[o.jsx("button",{ref:i,onClick:s,className:"size-10 rounded-lg bg-white/5 hover:bg-white/10 text-white/60 hover:text-white transition-colors flex items-center justify-center","aria-label":"Settings",children:o.jsx(os,{className:"size-5"})}),o.jsx(Rl,{isOpen:r,onClose:()=>s?.(),value:t,onChange:c=>n?.(c),anchorRef:i})]})]})]})}function co({onClick:e,disabled:t}){return o.jsx("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",children:o.jsx("button",{onClick:e,disabled:t,className:"size-10 rounded-full bg-[var(--optimex-surface)] border-4 border-white/5 flex items-center justify-center text-[var(--optimex-primary)] hover:scale-110 transition-all shadow-xl disabled:cursor-not-allowed",children:o.jsx(Go,{className:"size-5"})})})}function Ml({quote:e,fromToken:t,toToken:n,amount:r,slippage:s,isFetching:a}){const[l,i]=p.useState(!1),[c,d]=p.useState(!1),u=p.useCallback(()=>{d(g=>!g)},[]),f=p.useCallback(()=>{i(g=>!g)},[]),x=parseFloat(r)||0,v=parseFloat(e.min_amount_out)/Math.pow(10,n.token_decimals),w=x>0?v/x:0,m=v>0?x/v:0,y=()=>c?`1 ${n.token_symbol} = ${m.toFixed(6)} ${t.token_symbol}`:`1 ${t.token_symbol} = ${w.toFixed(6)} ${n.token_symbol}`;return o.jsxs("div",{className:"bg-white/[0.02] rounded-md border border-white/5 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:f,className:"w-full flex items-center justify-between p-3 text-xs cursor-pointer hover:bg-white/[0.02] transition-colors",children:[o.jsx("div",{className:"flex items-center gap-2 text-white/60 font-medium",children:a?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"size-3 animate-spin rounded-full border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:"Updating..."})]}):o.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),u()},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),u())},className:"hover:text-white transition-colors",children:y()})}),o.jsx(Kn,{className:`size-4 text-white/40 transition-transform ${l?"rotate-180":""}`})]}),l&&o.jsxs("div",{className:"px-3 pb-3 space-y-2 text-xs border-t border-white/5",children:[o.jsxs("div",{className:"flex items-center justify-between pt-3",children:[o.jsx("span",{className:"text-white/40",children:"Min. Received"}),o.jsxs("span",{className:"font-medium text-white",children:[je(e.min_amount_out,n.token_decimals)," ",n.token_symbol]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-white/40",children:"Est. Time"}),o.jsx("span",{className:"font-medium text-[var(--optimex-primary)]",children:"~10 minutes"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-white/40",children:"Slippage Tolerance"}),o.jsxs("span",{className:"font-medium text-white",children:[s,"%"]})]})]})]})}function Ll({text:e,disabled:t,onClick:n}){return o.jsx("button",{disabled:t,onClick:n,className:"w-full font-semibold text-black bg-gradient-to-r from-[var(--optimex-primary)] to-[#d45800] hover:brightness-110 py-4 rounded-md shadow-lg shadow-[var(--optimex-primary)]/30 flex items-center justify-center transition-all active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50",children:e})}function Pl(){return o.jsxs("a",{href:"https://optimex.com",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-1.5 text-[var(--optimex-text-secondary)] text-[10px] opacity-50 hover:opacity-70 transition-opacity",children:[o.jsx("span",{children:"Powered by"}),o.jsx(Jo,{className:"h-3 w-auto"})]})}function Ol({value:e,onChange:t,placeholder:n="Search by name or symbol..."}){return o.jsx("div",{className:"p-4 pb-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",placeholder:n,value:e,onChange:r=>t(r.target.value),className:"w-full rounded-xl bg-white/5 border border-white/10 px-4 py-3 pl-10 pr-10 text-white outline-none placeholder:text-white/30 transition-colors hover:border-[var(--optimex-primary)] focus:border-[var(--optimex-primary)]"}),o.jsx(rs,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-white/40"}),e&&o.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/60 transition-colors",children:o.jsx(Ae,{className:"size-5"})})]})})}function Il({networks:e,selectedNetwork:t,onSelectNetwork:n}){return o.jsxs("div",{className:"w-1/3 min-w-[140px] border-r border-white/[0.05] overflow-y-auto p-2",children:[o.jsx("div",{className:"mb-2 px-2 text-xs font-medium uppercase tracking-wider text-white/40",children:"Networks"}),o.jsxs("div",{className:"space-y-1 px-2",children:[o.jsxs("button",{onClick:()=>n(null),className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t===null?"bg-white/5 text-white":"text-white/60 hover:bg-white/5 hover:text-white"}`,children:[o.jsx(qo,{}),o.jsx("span",{children:"All"})]}),e.map(r=>o.jsx(Dl,{network:r,isSelected:t===r.network_id,onSelect:()=>n(r.network_id)},r.network_id))]})]})}function Dl({network:e,isSelected:t,onSelect:n}){return o.jsxs("button",{onClick:n,className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t?"bg-white/5 text-white":"text-white/60 hover:bg-white/5 hover:text-white"}`,children:[e.logo_uri?o.jsx("img",{src:e.logo_uri,alt:e.name,className:"h-8 w-8 rounded-lg",onError:r=>{r.target.style.display="none"}}):o.jsx("div",{className:"h-6 w-6 rounded-full bg-white/10"}),o.jsx("span",{className:"truncate",children:e.name})]})}function $l({tokens:e,selectedSymbol:t,onSelectSymbol:n,maxVisible:r=12}){return o.jsxs("div",{className:"border-b border-white/[0.05] p-2",children:[o.jsx("div",{className:"mb-2 px-2 text-xs font-medium uppercase tracking-wider text-white/40",children:"Tokens"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5 overflow-hidden max-h-[5rem]",children:[o.jsx("button",{onClick:()=>n(null),className:`border rounded-lg px-2.5 py-1 text-xs font-medium transition-colors ${t===null?"border-[var(--optimex-primary)] text-white":"border-transparent text-white/60 hover:bg-white/10 hover:text-white"}`,children:"All"}),e.slice(0,r).map(s=>o.jsx(Fl,{token:s,isSelected:t===s.token_symbol,onSelect:()=>n(s.token_symbol)},s.token_symbol))]})]})}function Fl({token:e,isSelected:t,onSelect:n}){return o.jsxs("button",{onClick:n,className:vr("flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs font-medium transition-colors outline-none border bg-white/5",t?"border-[var(--optimex-primary)] text-white":"border-transparent text-white/60 hover:bg-white/10 hover:text-white"),children:[e.token_logo_uri&&o.jsx("img",{src:e.token_logo_uri,alt:e.token_symbol,className:"h-4 w-4 rounded-full",onError:r=>{r.target.style.display="none"}}),e.token_symbol]})}function Ue(){const e=p.useContext(Hn);if(!e)throw new Error("useWallet must be used within WalletProvider");return e}function bt(e){return`https://network-api-stg.bitdex.xyz/${e}/rpc/zwD70RMT9DrE8L5SaMnJNMF8m70Gum`}function Bl(e){return e==="bitcoin_testnet"?"https://mempool.space/testnet4/api":"https://mempool.space/api"}function rn(e){return!e.token_address||e.token_address===""||e.token_address==="native"||e.token_address==="0x0000000000000000000000000000000000000000"}function zl(e,t){if(!e||e==="0")return"0";const n=BigInt(e),r=BigInt(10**t),s=n/r,a=n%r;if(a===BigInt(0))return s.toString();let l=a.toString().padStart(t,"0");return l=l.replace(/0+$/,""),l.length>6&&(l=l.slice(0,6)),`${s}.${l}`}function Vl(e){return`0x70a08231000000000000000000000000${e.toLowerCase().replace("0x","")}`}async function uo(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`RPC request failed: ${n.status}`);return n.json()}async function Wl(e,t){const r=await uo(e,{jsonrpc:"2.0",method:"eth_getBalance",params:[t,"latest"],id:1});if(r.error)throw new Error(`RPC error: ${r.error.message}`);const s=r.result||"0x0";return BigInt(s).toString()}async function Hl(e,t,n){const r={jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:Vl(n)},"latest"],id:1},s=await uo(e,r);if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result||"0x0";return BigInt(a).toString()}async function Ul(e,t){const n=bt(e.network_id),r=rn(e);let s;return r?s=await Wl(n,t):s=await Hl(n,e.token_address,t),{rawBalance:s,isNative:r}}async function ql(e,t){const r=`${Bl(e.network_id)}/address/${t}`,s=await fetch(r);if(!s.ok)throw new Error(`Mempool API request failed: ${s.status}`);const a=await s.json(),l=a.chain_stats.funded_txo_sum-a.chain_stats.spent_txo_sum,i=a.mempool_stats.funded_txo_sum-a.mempool_stats.spent_txo_sum;return{rawBalance:(l+i).toString(),isNative:!0}}async function fo(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`RPC request failed: ${n.status}`);return n.json()}async function Gl(e,t){const r=await fo(e,{jsonrpc:"2.0",method:"getBalance",params:[t],id:1});if(r.error)throw new Error(`RPC error: ${r.error.message}`);return(r.result?.value||0).toString()}async function Kl(e,t,n){const s=await fo(e,{jsonrpc:"2.0",method:"getTokenAccountsByOwner",params:[n,{mint:t},{encoding:"jsonParsed"}],id:1});if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result?.value||[];let l=BigInt(0);for(const i of a){const c=i.account.data.parsed.info.tokenAmount.amount;l+=BigInt(c)}return l.toString()}async function Yl(e,t){const n=bt(e.network_id),r=rn(e);let s;return r?s=await Gl(n,t):s=await Kl(n,e.token_address,t),{rawBalance:s,isNative:r}}function Zl(e,t){if(!t)return!1;switch(t){case Y.EVM:return e.isEvmConnected;case Y.BTC:return e.isBtcConnected;case Y.SOLANA:return e.isSolanaConnected;default:return!1}}function Ql(e){if(!e)return"";switch(e){case Y.EVM:return"EVM";case Y.BTC:return"Bitcoin";case Y.SOLANA:return"Solana";default:return e}}function Xl(e,t){if(!t)return null;switch(t){case Y.EVM:return e.evmAddress;case Y.BTC:return e.btcAddress;case Y.SOLANA:return e.solanaAddress;default:return null}}async function Jl(e,t){const n=e.token_address||"native";let r;switch(e.network_type){case Y.BTC:r=await ql(e,t);break;case Y.SOLANA:r=await Yl(e,t);break;case Y.EVM:default:r=await Ul(e,t)}return{tokenId:n,networkId:e.network_id,walletAddress:t,rawBalance:r.rawBalance,formattedBalance:zl(r.rawBalance,e.token_decimals),updatedAt:Date.now()}}const ec=30*1e3,tc=15*1e3;function nc(e,t){return!e||!t?["balance"]:["balance",e.network_id,e.token_address||"native",t]}function mo({token:e,walletAddress:t,enabled:n=!0,polling:r=!1,pollingInterval:s=tc}){const a=n&&!!e&&!!t,{data:l,isLoading:i,isFetching:c,error:d,refetch:u}=ke.useQuery({queryKey:nc(e,t),queryFn:()=>Jl(e,t),enabled:a,staleTime:ec,retry:1,refetchOnWindowFocus:!1,refetchInterval:r?s:!1});return{balance:l,formattedBalance:l?.formattedBalance||"0",isLoading:a&&i,isFetching:a&&c,error:d,refetch:u}}function rc({token:e,isSelected:t,isDisabled:n,onSelect:r}){const s=Ue(),a=Xl(s,e.network_type),{formattedBalance:l,isLoading:i}=mo({token:e,walletAddress:a,enabled:!!a}),c=!!a;return o.jsxs("button",{onClick:r,disabled:n,className:`flex w-full items-center gap-3 rounded-lg p-2 transition-colors ${t?"bg-white/5 text-white":n?"cursor-not-allowed opacity-50":"hover:bg-white/5"}`,children:[o.jsx(Le,{token:e}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"text-sm text-white/40",children:e.token_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[c&&o.jsx("span",{className:"text-sm font-medium text-white",children:i?o.jsx("span",{className:"inline-block h-4 w-12 animate-pulse rounded bg-white/10"}):l}),o.jsx("span",{className:"font-medium text-white",children:e.token_symbol})]})]}),t&&o.jsx(Yt,{className:"h-5 w-5 text-[var(--optimex-primary)]"})]})}function oc({tokens:e,selectedTokenId:t,disabledTokenId:n,disabledTokenIds:r,isLoading:s,emptyMessage:a="No tokens available",onSelect:l}){return s?o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-[var(--optimex-primary)] border-t-transparent"})})}):e.length===0?o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"py-8 text-center text-white/40",children:a})}):o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1",children:e.map(i=>{const c=n===i.token_id||r?.has(i.token_id)===!0;return o.jsx(rc,{token:i,isSelected:t===i.token_id,isDisabled:c,onSelect:()=>l(i)},i.token_id)})})})}function sc({isOpen:e,onClose:t,onSelect:n,tokensData:r,isLoading:s,selectedToken:a,disabledTokenId:l,disabledTokenIds:i,tokens:c,emptyMessage:d,title:u="Select Token",filterNetworkType:f}){const[x,v]=p.useState(""),[w,m]=p.useState(null),[y,g]=p.useState(null),k=p.useMemo(()=>r?.supported_networks?f?r.supported_networks.filter(L=>L.type===f):r.supported_networks:[],[r,f]),N=c??r?.tokens,b=p.useMemo(()=>N?N.filter(L=>{if(f&&L.network_type!==f||w&&L.network_id!==w)return!1;if(x){const D=(V,W)=>V.toLowerCase().includes(W.toLowerCase()),_=x.toLowerCase();return D(L.token_symbol,_)||D(L.token_name,_)||D(L.token_address,_)}return!0}):[],[N,x,w,f]),A=p.useMemo(()=>{if(!N)return[];const L=new Map;return N.forEach(D=>{f&&D.network_type!==f||w&&D.network_id!==w||L.has(D.token_symbol)||L.set(D.token_symbol,D)}),Array.from(L.values())},[N,f,w]),I=p.useMemo(()=>y?b.filter(L=>L.token_symbol===y):b,[b,y]),j=()=>{v(""),m(null),g(null)},C=L=>{n(L),t(),j()},R=L=>{L||(t(),j())},B=L=>{m(L),g(null)};return o.jsx(tn,{open:e,onOpenChange:R,title:u,className:"h-full md:h-[70vh] max-h-[600px] w-full max-w-2xl",children:o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(Ol,{value:x,onChange:v}),o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[o.jsx(Il,{networks:k,selectedNetwork:w,onSelectNetwork:B}),o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden pl-2",children:[o.jsx($l,{tokens:A,selectedSymbol:y,onSelectSymbol:g}),o.jsx(oc,{tokens:I,selectedTokenId:a?.token_id,disabledTokenId:l,disabledTokenIds:i,isLoading:s,emptyMessage:x?"No tokens found":d??"No tokens available",onSelect:C})]})]})]})})}function Fn({token:e,amount:t,label:n,isEstimated:r=!1,highlight:s=!1,usdValue:a="$0.00"}){return o.jsx("div",{className:`p-4 rounded-xl border transition-all duration-200 ${s?"bg-zinc-900/50 border-[var(--optimex-primary)]/20 shadow-[0_0_15px_rgba(235,98,0,0.1)]":"bg-zinc-900/50 border-white/5"}`,children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"size-12 flex items-center justify-center ",children:o.jsx(Le,{token:e,size:"lg"})}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[o.jsxs("p",{className:`text-xs font-medium uppercase tracking-wider ${s?"text-[var(--optimex-primary)]":"text-zinc-500"}`,children:[n," ",r&&"(Est.)"]}),o.jsx("p",{className:"text-white text-sm font-semibold truncate",children:e.token_symbol}),o.jsx("p",{className:"text-zinc-500 text-xs truncate",children:e.network_name})]}),o.jsxs("div",{className:"flex flex-col items-end gap-0.5 ml-auto shrink-0",children:[o.jsx("p",{className:"text-white text-lg font-bold",children:r?`~${t}`:t}),o.jsx("p",{className:"text-zinc-400 text-xs",children:a})]})]})})}function ac({fromToken:e,toToken:t,fromAmount:n,toAmount:r,fromUsdValue:s="$0.00",toUsdValue:a="$0.00"}){return o.jsxs("div",{className:"relative flex flex-col gap-2",children:[o.jsx(Fn,{token:e,amount:n,label:"You Pay",usdValue:s}),o.jsx(co,{onClick:()=>{},disabled:!0}),o.jsx(Fn,{token:t,amount:r,label:"You Receive",usdValue:a})]})}function Ft({label:e,value:t,borderTop:n}){return o.jsxs("div",{className:`flex justify-between items-center text-sm ${n?"pt-2 mt-2 border-t border-white/5":""}`,children:[o.jsx("span",{className:"text-zinc-500",children:e}),o.jsx("div",{className:"flex items-center gap-1 text-white font-medium",children:t})]})}function ic({minReceived:e,estimatedTime:t,slippage:n,networkFee:r="Included"}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-xl p-4 border border-white/5 space-y-3",children:[o.jsx(Ft,{label:"Min. Received",value:e}),o.jsx(Ft,{label:"Estimated Time",value:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"size-2 bg-[var(--optimex-primary)] rounded-full animate-pulse shadow-[0_0_8px_rgba(235,98,0,0.8)]"}),o.jsx("span",{children:t})]})}),o.jsx(Ft,{label:"Slippage Tolerance",value:n})]})}const lc=3e4,cc=6e4;function xt({symbol:e,enabled:t=!0}){const n=Je(),{data:r,isLoading:s,isError:a}=ke.useQuery({queryKey:["tokenPrice",e],queryFn:async()=>{if(!e)throw new Error("Symbol is required");return(await Ve(n.apiBaseUrl).getTokenPrice(e)).current_price},enabled:t&&!!e,staleTime:lc,refetchInterval:cc,retry:2});return{price:r??null,isLoading:s,isError:a,calculateUsdValue:i=>{if(!r||!i||isNaN(parseFloat(i)))return"$0.00";const c=parseFloat(i);if(c===0)return"$0.00";const d=c*r;return d<.01?"<$0.01":d<1?`$${d.toFixed(4)}`:d<1e3?`$${d.toFixed(2)}`:d<1e6?`$${(d/1e3).toFixed(2)}K`:`$${(d/1e6).toFixed(2)}M`}}}function dc({isOpen:e,onClose:t,onConfirm:n,fromToken:r,toToken:s,amountIn:a,quote:l,slippage:i,stage:c,receivingAddress:d=""}){const u=c!=="idle"&&c!=="confirming"&&c!=="error"&&c!=="submitted",f=c==="submitted",x=c==="error",v=je(l.min_amount_out,s.token_decimals),{calculateUsdValue:w}=xt({symbol:r.token_symbol,enabled:e}),{calculateUsdValue:m}=xt({symbol:s.token_symbol,enabled:e}),y=w(a),g=m(v),k=b=>{!b&&!u&&t()},N=f?"Swap Complete":x?"Swap Failed":"Review Swap";return o.jsxs(tn,{open:e,onOpenChange:k,title:N,showCloseButton:!u,className:"w-full max-w-md",children:[o.jsxs(hl,{className:"space-y-3",children:[o.jsx(ac,{fromToken:r,toToken:s,fromAmount:a,toAmount:v,fromUsdValue:y,toUsdValue:g}),o.jsx(ic,{minReceived:`${v} ${s.token_symbol}`,estimatedTime:"~10 minutes",slippage:`${i}%`}),d&&o.jsx("div",{className:"bg-[var(--optimex-surface)] rounded-xl px-2 border border-white/5",children:o.jsx(is,{icon:Zn,label:"Receiving Address",address:d})})]}),o.jsx(xl,{children:o.jsx(ea,{state:u?"processing":f?"success":x?"error":"idle",onConfirm:f?t:n,confirmText:"Confirm Swap"})})]})}function uc({swap:e}){const{tokens:t,modals:n,tokenSelect:r,actions:s,input:a,quote:l,execution:i}=e;return o.jsxs(o.Fragment,{children:[o.jsx(sc,{isOpen:n.tokenSelect.isOpen,onClose:n.tokenSelect.close,onSelect:s.selectToken,tokensData:t.data,isLoading:!1,selectedToken:r.type==="from"?t.from:t.to,disabledTokenId:r.type==="from"?t.to?.token_id:t.from?.token_id,tokens:r.type==="to"?t.availableTo:t.all,emptyMessage:r.type==="to"?"No available pairs for selected source token":void 0,title:r.type==="from"?"Select Source Token":"Select Destination Token"}),l.data&&t.from&&t.to&&o.jsx(dc,{isOpen:n.confirm.isOpen,onClose:s.closeConfirmModal,onConfirm:s.confirmSwap,fromToken:t.from,toToken:t.to,amountIn:a.amount,quote:l.data,slippage:a.slippage,stage:i.stage,txHash:i.txHash,error:i.error,receivingAddress:e.addresses.receiving})]})}function on({status:e}){const t={pending:{icon:Yn,text:"Processing",bgClass:"bg-yellow-500/10",textClass:"text-yellow-500",animate:!0},success:{icon:Yt,text:"Completed",bgClass:"bg-green-500/10",textClass:"text-green-500",animate:!1},failed:{icon:Ko,text:"Failed",bgClass:"bg-red-500/10",textClass:"text-red-500",animate:!1}},{icon:n,text:r,bgClass:s,textClass:a,animate:l}=t[e];return o.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${s}`,children:[o.jsx(n,{className:`w-4 h-4 ${a} ${l?"animate-spin":""}`}),o.jsx("span",{className:`text-xs font-medium ${a}`,children:r})]})}function fc({onClose:e}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-[var(--optimex-border)] rounded-xl p-4 mt-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)] font-medium",children:"Recent Trade"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(on,{status:"pending"}),e&&o.jsx("button",{onClick:e,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ae,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]})]}),o.jsx("div",{className:"flex items-center px-3",children:o.jsx("svg",{className:"w-5 h-5 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"})]})]})]})}function mc({trade:e,status:t,isLoading:n,onClose:r}){if(n||!e)return o.jsx(fc,{onClose:r});const s=e.from_token,a=e.to_token,l=je(e.amount_in,s.token_decimals),i=je(e.min_amount_out,a.token_decimals);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-[var(--optimex-border)] rounded-xl p-4 mt-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)] font-medium",children:"Recent Trade"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(on,{status:t}),r&&o.jsx("button",{onClick:r,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ae,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Le,{token:s,size:"sm",showNetworkBadge:!1}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:l}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:s.token_symbol})]})]}),o.jsx("div",{className:"flex items-center px-3",children:o.jsx("svg",{className:"w-5 h-5 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:i}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:a.token_symbol})]}),o.jsx(Le,{token:a,size:"sm",showNetworkBadge:!1})]})]})]})}const pc=1e4;function hc({apiBaseUrl:e,walletAddresses:t,enabled:n=!0,limit:r=20}){const{data:s,isLoading:a,isError:l,refetch:i}=ke.useQuery({queryKey:["trades",t,r],queryFn:async()=>Ve(e).listTrades({from_user_address:t,limit:r}),enabled:n&&!!t?.length,refetchInterval:pc,retry:2,retryDelay:2e3});return{trades:s??[],isLoading:a,isError:l,refetch:i}}function xc(e){if(!e)return"pending";switch(e.toLowerCase()){case"success":case"completed":return"success";case"failed":case"refunded":case"expired":return"failed";default:return"pending"}}function gc({trade:e}){const t=e.from_token,n=e.to_token,r=xc(e.state),s=je(e.amount_in,t.token_decimals),a=je(e.min_amount_out,n.token_decimals);return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-[var(--optimex-border)]",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Le,{token:t,size:"sm",showNetworkBadge:!1}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:s}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:t.token_symbol})]})]}),o.jsx("div",{className:"flex items-center px-2",children:o.jsx("svg",{className:"w-4 h-4 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:a}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:n.token_symbol})]}),o.jsx(Le,{token:n,size:"sm",showNetworkBadge:!1})]}),o.jsx("div",{className:"ml-3",children:o.jsx(on,{status:r})})]})}function Bt(){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-[var(--optimex-border)]",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-14 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-8 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]})]}),o.jsx("div",{className:"w-4 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsx("div",{className:"w-14 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-8 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"})]}),o.jsx("div",{className:"ml-3 w-20 h-6 bg-[var(--optimex-border)] rounded-full animate-pulse"})]})}function vc(){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx("div",{className:"w-16 h-16 mb-4 rounded-full bg-[var(--optimex-surface)] flex items-center justify-center",children:o.jsx("svg",{className:"w-8 h-8 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})}),o.jsx("p",{className:"text-sm text-[var(--optimex-text-secondary)]",children:"No trade history yet"})]})}function wc({open:e,onOpenChange:t,evmAddress:n,btcAddress:r,solanaAddress:s}){const a=Je(),l=[n,r,s].filter(d=>!!d),{trades:i,isLoading:c}=hc({apiBaseUrl:a.apiBaseUrl,walletAddresses:l.length>0?l:void 0,enabled:e&&l.length>0});return o.jsx(tn,{open:e,onOpenChange:t,title:"Trade History",className:"w-full max-w-md",children:o.jsxs("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[c?o.jsxs(o.Fragment,{children:[o.jsx(Bt,{}),o.jsx(Bt,{}),o.jsx(Bt,{})]}):i.length===0?o.jsx(vc,{}):i.map(d=>o.jsx(gc,{trade:d},d.trade_id)),!c&&i.length>0&&o.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2 text-xs text-[var(--optimex-text-secondary)]",children:[o.jsx(Yn,{className:"w-3 h-3 animate-spin"}),o.jsx("span",{children:"Auto-refreshing"})]})]})})}function bc(e,t){return p.useMemo(()=>{const n=e.trim();if(!t||!n)return{isValid:!n,error:void 0};const r=Kt(n,t.network_type,t.network_id);return{isValid:r.isValid,error:r.isValid?void 0:r.error}},[e,t])}function yc(){const[e,t]=p.useState(null),[n,r]=p.useState(!1),[s,a]=p.useState(!1),l=p.useCallback(()=>t("from"),[]),i=p.useCallback(()=>t("to"),[]),c=p.useCallback(()=>t(null),[]),d=p.useCallback(()=>r(!0),[]),u=p.useCallback(()=>r(!1),[]),f=p.useCallback(()=>a(v=>!v),[]),x=p.useCallback(()=>a(!1),[]);return{tokenSelect:{isOpen:e!==null,type:e,openFrom:l,openTo:i,close:c},confirm:{isOpen:n,open:d,close:u},settings:{isOpen:s,toggle:f,close:x}}}function Cc({fromToken:e,toToken:t,amount:n,fromUserAddress:r,toUserAddress:s,userRefundPubkey:a,slippage:l,config:i}){return p.useMemo(()=>{const c=s.trim(),d=i.affiliateAddress&&i.affiliateFee?[{provider:i.affiliateProvider??"optimex-widget",rate:String(i.affiliateFee),receiver:i.affiliateAddress,network:"ethereum"}]:void 0,u=Math.round(l*100);return{from_token:e,to_token:t,amount:n,from_user_address:r,to_user_address:c||null,user_refund_pubkey:a,slippage:String(u),affiliate_fee_bps:i.affiliateFee?String(i.affiliateFee):void 0,affiliate_info:d,trade_timeout:i.tradeTimeout,script_timeout:i.scriptTimeout}},[e,t,n,r,s,a,l,i.affiliateFee,i.affiliateAddress,i.affiliateProvider,i.tradeTimeout,i.scriptTimeout])}function kc(e,t){return p.useMemo(()=>{if(!e||!t)return{walletAccount:void 0,evmWalletAccount:void 0};switch(e.network_type){case Y.EVM:return{walletAccount:t.evm,evmWalletAccount:t.evm};case Y.BTC:return{walletAccount:t.btc,evmWalletAccount:void 0};case Y.SOLANA:return{walletAccount:t.solana,evmWalletAccount:void 0};default:return{walletAccount:void 0,evmWalletAccount:void 0}}},[e,t])}const Bn={BTC:1,EVM:2,Solana:3};function jc(e){const{tokens:t,pairs:n,selectedFromToken:r}=e,s=p.useMemo(()=>{const v=new Map;if(!n)return v;for(const w of n){if(!w.is_active)continue;const m=v.get(w.from_token_id);m?m.add(w.to_token_id):v.set(w.from_token_id,new Set([w.to_token_id]))}return v},[n]),a=p.useMemo(()=>t??[],[t]),l=p.useMemo(()=>{const v=new Set;for(const w of a){const m=s.get(w.token_id);(!m||m.size===0)&&v.add(w.token_id)}return v},[a,s]),i=p.useMemo(()=>{if(!r)return[];const v=s.get(r.token_id);return!v||v.size===0?[]:a.filter(w=>v.has(w.token_id))},[r,s,a]),c=p.useCallback((v,w)=>s.get(v)?.has(w)??!1,[s]),d=p.useCallback(v=>(s.get(v)?.size??0)>0,[s]),u=p.useCallback(v=>[...v].sort((w,m)=>{const y=Bn[w.network_type]??99,g=Bn[m.network_type]??99;return y-g}),[]),f=p.useCallback(v=>{const w=s.get(v.token_id);if(!w||w.size===0)return null;const m=a.filter(g=>w.has(g.token_id));return m.length===0?null:u(m)[0]??null},[s,a,u]),x=p.useCallback(()=>{if(a.length===0)return null;const v=u(a);for(const w of v){const m=f(w);if(m)return{fromToken:w,toToken:m}}return null},[a,u,f]);return{allTokens:a,tokensWithoutPairs:l,availableToTokens:i,isPairValid:c,findBestToToken:f,hasValidPairs:d,getDefaultPair:x}}function Nc(e){if(!e.chain_id||e.network_type!=="EVM")return;const t=parseInt(e.chain_id,10);return isNaN(t)?void 0:t}async function Sc(e,t){const n=Nc(t);if(!n)throw new Error(`Cannot determine chain ID for token: ${t.token_id}`);return await e.getChainId()===n?!1:(await e.switchChain(n),!0)}const Ec="0xdd62ed3e",Tc="0x095ea7b3",_c="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";function Gt(e){return e.toLowerCase().replace("0x","").padStart(64,"0")}function Rc(e){return e.toString(16).padStart(64,"0")}function Ac(e){const t=e.startsWith("0x")?e.slice(2):e;return!t||t===""?0n:BigInt("0x"+t)}async function Mc(e,t,n,r){const s=bt(e),a=Ec+Gt(n)+Gt(r),i=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_call",params:[{to:t,data:a},"latest"]})})).json();if(i.error)throw new Error(`Failed to check allowance: ${i.error.message}`);return Ac(i.result)}function Lc(e,t){const n=t?Rc(t):_c.slice(2);return`${Tc}${Gt(e)}${n}`}async function Pc(e,t,n,r){const s=Lc(n,r);return await e.sendTransaction({to:t,data:s})}async function Oc(e,t,n=60,r=2e3){const s=bt(e);for(let a=0;a<n;a++){const i=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_getTransactionReceipt",params:[t]})})).json();if(i.error)throw new Error(`RPC error: ${i.error.message}`);if(i.result){const c=i.result;return{status:c.status==="0x1"?"success":"reverted",blockNumber:c.blockNumber,transactionHash:c.transactionHash}}await new Promise(c=>setTimeout(c,r))}throw new Error(`Transaction ${t} not confirmed after ${n} attempts`)}function Ic(e){return e?"getChainId"in e&&"switchChain"in e&&typeof e.getChainId=="function"&&typeof e.switchChain=="function":!1}function Dc({apiBaseUrl:e,onWalletTx:t,onSubmitTx:n,onError:r}){const[s,a]=p.useState({stage:"idle",txHash:null,tradeId:null,error:null}),l=p.useCallback(()=>{a({stage:"idle",txHash:null,tradeId:null,error:null})},[]),i=p.useCallback((u,f,x)=>{a(v=>({...v,stage:"error",error:u})),r?.({error:u,stage:f,trade_id:x})},[r]),c=p.useCallback(async(u,f,x,v)=>{const w=x.deposit_address;if(!w)throw new Error("Missing deposit address for EVM transaction");a(k=>({...k,stage:"switching_chain"})),await Sc(u,f);const m=rn(f);if(!m&&f.token_address&&(a(N=>({...N,stage:"checking_allowance"})),await Mc(f.network_id,f.token_address,u.address,w)<v)){a(A=>({...A,stage:"approving"}));const N=await Pc(u,f.token_address,w,v);if((await Oc(f.network_id,N)).status==="reverted")throw new Error("Token approval transaction reverted")}a(k=>({...k,stage:"broadcasting"}));const y={to:w,value:m?v:0n,data:x.payload?x.payload:void 0};return await u.sendTransaction(y)},[]),d=p.useCallback(async({quote:u,fromToken:f,toToken:x,amountIn:v,walletAccount:w,evmWalletAccount:m})=>{const y=Ve(e);try{a({stage:"confirming",txHash:null,tradeId:u.trade_id,error:null});const g=m||w;if(!g)throw new Error("Wallet not available");a(b=>({...b,stage:"signing"}));let k;const N=qn(v,f.token_decimals);if(f.network_type===Y.EVM){const b=m||(Ic(w)?w:null);if(b)k=await c(b,f,u,N);else{const A=u.deposit_address,I=u.payload?u.payload:void 0;if(!A)throw new Error("Missing deposit address for EVM transaction");a(C=>({...C,stage:"broadcasting"}));const j={to:A,value:N,data:I};k=await g.sendTransaction(j)}}else if(f.network_type===Y.BTC){if(!u.deposit_address)throw new Error("Missing deposit address for BTC transaction");a(b=>({...b,stage:"broadcasting"})),k=await g.sendTransaction({toAddress:u.deposit_address,amount:N})}else if(f.network_type===Y.SOLANA){if(!u.payload)throw new Error("Missing payload for Solana transaction");a(b=>({...b,stage:"broadcasting"})),k=await g.sendTransaction(u.payload)}else throw new Error(`Unsupported network type: ${f.network_type}`);t?.({trade_id:u.trade_id,tx_hash:k,from_token:f,to_token:x,amount_in:v}),a(b=>({...b,txHash:k,stage:"submitting"}));try{await y.submitTransaction(u.trade_id,k),n?.({trade_id:u.trade_id,tx_hash:k,status:"success"})}catch(b){throw n?.({trade_id:u.trade_id,tx_hash:k,status:"error",error:b.message}),b}return a(b=>({...b,stage:"submitted"})),{tradeId:u.trade_id,txHash:k}}catch(g){const k=s.stage==="approving"?"approval":"wallet_tx";throw i(g,k,u.trade_id),g}},[e,t,n,i,c,s.stage]);return{...s,executeSwap:d,resetState:l,isExecuting:s.stage!=="idle"&&s.stage!=="submitted"&&s.stage!=="error"}}function $c({defaultPair:e,isPairValid:t,findBestToToken:n,hasValidPairs:r,defaultSlippage:s=.75,selectingToken:a=null}){const[l,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(""),[x,v]=p.useState(""),[w,m]=p.useState(s),y=l??e?.fromToken??null,g=c??e?.toToken??null,k=p.useCallback(()=>{y&&g&&t(g.token_id,y.token_id)&&(i(g),d(y),f(""))},[y,g,t]),N=p.useCallback(b=>{if(a==="from"){if(!r(b.token_id))return!1;if(b.token_id===g?.token_id)d(y);else if(g&&!t(b.token_id,g.token_id)){const A=n(b);d(A)}return i(b),!0}else if(a==="to")return b.token_id===y?.token_id&&i(g),d(b),!0;return!1},[a,y,g,t,n,r]);return{fromToken:y,toToken:g,handleTokenSelect:N,handleSwapDirection:k,amount:u,setAmount:f,receivingAddress:x,setReceivingAddress:v,slippage:w,setSlippage:m}}function Fc({fromToken:e,toToken:t}){const n=Ue();return p.useMemo(()=>{const r=n.evmAddress,s=n.btcAddress,a=n.btcPublicKey;let l=null,i=null;return e?.network_type===Y.EVM?(l=r,i=r):e?.network_type===Y.BTC&&(l=s,i=a),{fromUserAddress:l,userRefundPubkey:i}},[n.evmAddress,n.btcAddress,n.btcPublicKey,e,t])}function Bc({fromToken:e,toToken:t,amount:n,quote:r,isLoadingQuote:s,isFetchingQuote:a,receivingAddress:l,onConnectWallet:i,onSwap:c}){const d=Ue();return p.useMemo(()=>{if(!Zl(d,e?.network_type)){const x=Ql(e?.network_type);return{text:x?`Connect ${x} Wallet`:"Connect Wallet",disabled:!1,action:i}}return!e||!t?{text:"Select Tokens",disabled:!0,action:void 0}:!n||parseFloat(n)<=0?{text:"Enter Amount",disabled:!0,action:void 0}:l.trim()?Kt(l,t.network_type,t.network_id).isValid?s||a?{text:"Getting Quote...",disabled:!0,action:void 0}:r?{text:"Review",disabled:!1,action:c}:{text:"Unable to Quote",disabled:!0,action:void 0}:{text:"Enter Receiving Address",disabled:!0,action:void 0}:{text:"Enter Receiving Address",disabled:!0,action:void 0}},[d.isEvmConnected,d.isBtcConnected,d.isSolanaConnected,e,t,n,s,a,r,i,c,l])}function zc({tokens:e,defaultFromToken:t,defaultToToken:n,isPairValid:r}){return p.useMemo(()=>{if(!t||!n||!e)return null;const s=e.find(l=>l.token_id===t),a=e.find(l=>l.token_id===n);return!s||!a?null:r(s.token_id,a.token_id)?{fromToken:s,toToken:a}:null},[e,t,n,r])}function Vc(){const e=Ue(),t=Je(),n=yc(),{tokensData:r}=El(),s=r.tokens,a=r.pairs,{allTokens:l,tokensWithoutPairs:i,isPairValid:c,findBestToToken:d,hasValidPairs:u,getDefaultPair:f}=jc({tokens:s,pairs:a,selectedFromToken:null}),v=zc({tokens:s,defaultFromToken:t.defaultFromToken,defaultToToken:t.defaultToToken,isPairValid:c})??f(),{fromToken:w,toToken:m,handleTokenSelect:y,handleSwapDirection:g,amount:k,setAmount:N,receivingAddress:b,setReceivingAddress:A,slippage:I,setSlippage:j}=$c({defaultPair:v,isPairValid:c,findBestToToken:d,hasValidPairs:u,defaultSlippage:t.defaultSlippage,selectingToken:n.tokenSelect.type}),C=p.useMemo(()=>w?l.filter($=>c(w.token_id,$.token_id)):[],[w,l,c]),R=bc(b,m),{fromUserAddress:B,userRefundPubkey:L}=Fc({fromToken:w,toToken:m}),D=Cc({fromToken:w,toToken:m,amount:k,fromUserAddress:B,toUserAddress:b,userRefundPubkey:L,slippage:I,config:{affiliateFee:t.affiliateFee,affiliateAddress:t.affiliateAddress,affiliateProvider:t.affiliateProvider,tradeTimeout:t.tradeTimeout,scriptTimeout:t.scriptTimeout}}),_=!!w&&!!m&&parseFloat(k)>0&&!!b.trim()&&!n.confirm.isOpen,{data:V,isLoading:W,isFetching:G,refetch:H}=Ho(t.apiBaseUrl,{...D,enabled:_,onQuote:t.callbacks?.onQuote}),S=Dc({apiBaseUrl:t.apiBaseUrl,onWalletTx:t.callbacks?.onWalletTx,onSubmitTx:t.callbacks?.onSubmitTx,onError:t.callbacks?.onError}),{walletAccount:ne,evmWalletAccount:oe}=kc(w,e.externalWalletClient??void 0),Ne=p.useCallback(()=>{e.isExternalWallet?e.onRequestWallet?.(w?.network_id??""):e.openConnectModal?.()},[e,w?.network_id]),ue=p.useCallback(()=>{!V||!w||!m||n.confirm.open()},[V,w,m,n.confirm]),U=p.useCallback(($=!1)=>{S.isExecuting||(n.confirm.close(),$||S.resetState())},[S,n.confirm]),Q=p.useCallback(async()=>{if(!(!V||!w||!m))try{await S.executeSwap({quote:V,fromToken:w,toToken:m,amountIn:k,walletAccount:ne,evmWalletAccount:oe}),U(!0),N("")}catch($){console.error("Swap failed:",$)}},[V,w,m,k,ne,oe,S,U,N]),ie=p.useCallback($=>{y($)&&n.tokenSelect.close()},[y,n.tokenSelect]),he=Bc({fromToken:w,toToken:m,amount:k,quote:V,isLoadingQuote:W,isFetchingQuote:G,receivingAddress:b,onConnectWallet:Ne,onSwap:ue});return{tokens:{from:w,to:m,all:l,availableTo:C,withoutPairs:i,data:r},input:{amount:k,setAmount:N,receivingAddress:b,setReceivingAddress:A,slippage:I,setSlippage:j},quote:{data:V,isLoading:W,isFetching:G,refetch:H},validation:{address:R},buttonState:he,modals:n,tokenSelect:{type:n.tokenSelect.type},actions:{selectToken:ie,swapDirection:g,connectWallet:Ne,openSwapConfirm:ue,closeConfirmModal:U,confirmSwap:Q},execution:{stage:S.stage,txHash:S.txHash,tradeId:S.tradeId,error:S.error,isExecuting:S.isExecuting},wallet:e,addresses:{sending:B,receiving:b}}}const Wc=5e3;function zn(e){if(!e)return"pending";switch(e.toLowerCase()){case"success":case"completed":return"success";case"failed":case"refunded":case"expired":return"failed";default:return"pending"}}function Hc({apiBaseUrl:e,tradeId:t}){const{data:n,isLoading:r}=ke.useQuery({queryKey:["trade",t],queryFn:async()=>Ve(e).getTrade(t),enabled:!!t,refetchInterval:s=>{const a=s.state.data;return a&&zn(a.state)==="success"?!1:Wc},retry:!0,retryDelay:2e3});return{trade:n??null,status:zn(n?.state),isLoading:r}}function po(){const e=Vc(),t=Je(),{tokens:n,input:r,quote:s,modals:a,buttonState:l,validation:i,actions:c,addresses:d,wallet:u,execution:f}=e,[x,v]=p.useState(!1),{trade:w,status:m,isLoading:y}=Hc({apiBaseUrl:t.apiBaseUrl,tradeId:f.tradeId}),{formattedBalance:g}=mo({token:n.from,walletAddress:d.sending,enabled:!!n.from&&!!d.sending,polling:!0}),{calculateUsdValue:k}=xt({symbol:n.from?.token_symbol,enabled:!!n.from}),{calculateUsdValue:N}=xt({symbol:n.to?.token_symbol,enabled:!!n.to}),b=u.isConnected,A=k(r.amount),I=s.data?N(je(s.data.min_amount_out,n.to?.token_decimals||18)):"$0.00";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-4 w-full min-w-0",children:[o.jsx(Al,{slippage:r.slippage,onSlippageChange:r.setSlippage,isSettingsOpen:a.settings.isOpen,onSettingsToggle:a.settings.toggle,onHistoryClick:()=>v(!0),hideHistory:t.hideHistory||!u.isConnected}),o.jsxs(nn,{children:[o.jsxs("div",{className:"space-y-2 relative",children:[o.jsx($n,{token:n.from,value:r.amount,onChange:r.setAmount,onSelectToken:a.tokenSelect.openFrom,balance:g,isWalletConnected:b,usdValue:A}),o.jsx(co,{onClick:c.swapDirection}),o.jsx($n,{token:n.to,value:s.data?je(s.data.min_amount_out,n.to?.token_decimals||18):"",readOnly:!0,onSelectToken:a.tokenSelect.openTo,isOutput:!0,usdValue:I})]}),o.jsx("div",{className:"mt-4",children:o.jsx(Tl,{token:n.to,value:r.receivingAddress,onChange:r.setReceivingAddress,error:i.address.error})}),o.jsx("div",{className:"mt-4",children:o.jsx(Ll,{text:l.text,disabled:l.disabled,onClick:l.action})}),s.data&&n.from&&n.to&&o.jsx("div",{className:"mt-4",children:o.jsx(Ml,{quote:s.data,fromToken:n.from,toToken:n.to,amount:r.amount,slippage:r.slippage,isFetching:s.isFetching,onRefresh:s.refetch})}),o.jsx("div",{className:"mt-4",children:o.jsx(Pl,{})}),f.tradeId&&o.jsx("div",{className:"mt-4",children:o.jsx(mc,{trade:w,status:m,isLoading:y})})]})]}),o.jsx(uc,{swap:e}),x&&o.jsx(wc,{open:x,onOpenChange:v,evmAddress:u.evmAddress??void 0,btcAddress:u.btcAddress??void 0,solanaAddress:u.solanaAddress??void 0})]})}function Uc({className:e,connectLabel:t="Connect Wallet",showNetworkBadge:n=!0,onClick:r}){const s=Ue(),a=s.evmAddress||s.btcAddress||s.solanaAddress,l=()=>{if(r){r();return}s.isExternalWallet?s.onRequestWallet?.():s.openConnectModal?.()},i=()=>n?s.isEvmConnected?o.jsx("span",{className:"rounded bg-blue-500/20 px-1.5 py-0.5 text-xs text-blue-400",children:"EVM"}):s.isBtcConnected?o.jsx("span",{className:"rounded bg-orange-500/20 px-1.5 py-0.5 text-xs text-orange-400",children:"BTC"}):s.isSolanaConnected?o.jsx("span",{className:"rounded bg-purple-500/20 px-1.5 py-0.5 text-xs text-purple-400",children:"SOL"}):null:null;return s.isConnected?o.jsxs("div",{className:`flex items-center gap-2 ${e||""}`,children:[i(),o.jsxs("button",{onClick:l,className:"group flex items-center gap-1.5 rounded-[0.25rem] bg-[var(--optimex-surface-hover)] px-3 py-1.5 text-sm text-[var(--optimex-text)] transition-colors hover:bg-[rgba(239,68,68,0.2)]",children:[o.jsx("span",{children:Do(a)}),o.jsx(Qo,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})]}):o.jsx("button",{onClick:l,className:`rounded-[0.25rem] bg-[var(--optimex-primary)] px-4 py-1.5 text-sm font-medium text-white transition-colors hover:bg-[var(--optimex-primary-hover)] ${e||""}`,children:t})}function qc({apiBaseUrl:e,walletClient:t,onRequestWallet:n,theme:r,defaultFromToken:s,defaultToToken:a,affiliateFee:l,affiliateAddress:i,affiliateProvider:c,tradeTimeout:d,scriptTimeout:u,defaultSlippage:f=.75,hideHistory:x=!1,children:v,renderLoading:w,renderError:m,queryClient:y,onQuote:g,onWalletTx:k,onSubmitTx:N,onSwapComplete:b,onError:A}){Mo(e);const I=p.useMemo(()=>y??new ke.QueryClient,[y]),C={apiBaseUrl:e,defaultSlippage:f,affiliateFee:l,affiliateAddress:i,affiliateProvider:c,tradeTimeout:d,scriptTimeout:u,defaultFromToken:s,defaultToToken:a,hideHistory:x,callbacks:{onQuote:g,onWalletTx:k,onSubmitTx:N,onSwapComplete:b,onError:A},renderLoading:w,renderError:m},R=v??o.jsx(po,{});return o.jsx("div",{className:"optx-widget",children:o.jsx(ke.QueryClientProvider,{client:I,children:o.jsx(Uo,{value:C,children:o.jsx(Ro,{theme:r,children:o.jsx(Ao,{externalWalletClient:t,onRequestWallet:n,children:o.jsx(Sl,{children:R})})})})})})}exports.ConnectButton=Uc;exports.SwapCard=po;exports.SwapWidget=qc;exports.useWallet=Ue;
55
+ ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function zi(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Vi(){return en(/^Mac/)}function Wi(){return en(/^iPhone/)}function Pn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Hi(){return en(/^iPad/)||Vi()&&navigator.maxTouchPoints>1}function Xr(){return Wi()||Hi()}function en(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Ui=24,qi=typeof window<"u"?p.useLayoutEffect:p.useEffect;function On(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const Pt=typeof document<"u"&&window.visualViewport;function In(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Jr(e){for(In(e)&&(e=e.parentElement);e&&!In(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Gi=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let dt=0,Ot;function Ki(e={}){let{isDisabled:t}=e;qi(()=>{if(!t)return dt++,dt===1&&Xr()&&(Ot=Yi()),()=>{dt--,dt===0&&Ot?.()}},[t])}function Yi(){let e,t=0,n=f=>{e=Jr(f.target),!(e===document.documentElement&&e===document.body)&&(t=f.changedTouches[0].pageY)},r=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let x=f.changedTouches[0].pageY,v=e.scrollTop,w=e.scrollHeight-e.clientHeight;w!==0&&((v<=0&&x>t||v>=w&&x<t)&&f.preventDefault(),t=x)},s=f=>{let x=f.target;Ht(x)&&x!==document.activeElement&&(f.preventDefault(),x.style.transform="translateY(-2000px)",x.focus(),requestAnimationFrame(()=>{x.style.transform=""}))},a=f=>{let x=f.target;Ht(x)&&(x.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{x.style.transform="",Pt&&(Pt.height<window.innerHeight?requestAnimationFrame(()=>{Dn(x)}):Pt.addEventListener("resize",()=>Dn(x),{once:!0}))}))},l=()=>{window.scrollTo(0,0)},i=window.pageXOffset,c=window.pageYOffset,d=On(Zi(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let u=On(Ye(document,"touchstart",n,{passive:!1,capture:!0}),Ye(document,"touchmove",r,{passive:!1,capture:!0}),Ye(document,"touchend",s,{passive:!1,capture:!0}),Ye(document,"focus",a,!0),Ye(window,"scroll",l));return()=>{d(),u(),window.scrollTo(i,c)}}function Zi(e,t,n){let r=e.style[t];return e.style[t]=n,()=>{e.style[t]=r}}function Ye(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Dn(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let n=Jr(e);if(n!==document.documentElement&&n!==document.body&&n!==e){let r=n.getBoundingClientRect().top,s=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom;const l=n.getBoundingClientRect().bottom+Ui;a>l&&(n.scrollTop+=s-r)}e=n.parentElement}}function Ht(e){return e instanceof HTMLInputElement&&!Gi.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Qi(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Xi(...e){return t=>e.forEach(n=>Qi(n,t))}function eo(...e){return h.useCallback(Xi(...e),e)}const to=new WeakMap;function ee(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let r={};Object.entries(t).forEach(([s,a])=>{if(s.startsWith("--")){e.style.setProperty(s,a);return}r[s]=e.style[s],e.style[s]=a}),!n&&to.set(e,r)}function Ji(e,t){if(!e||!(e instanceof HTMLElement))return;let n=to.get(e);n&&(e.style[t]=n[t])}const X=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function ut(e,t){if(!e)return null;const n=window.getComputedStyle(e),r=n.transform||n.webkitTransform||n.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[X(t)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[X(t)?5:4]):null)}function el(e){return 8*(Math.log(e+1)-2)}function It(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}function tl(...e){return(...t)=>{for(const n of e)typeof n=="function"&&n(...t)}}const K={DURATION:.5,EASE:[.32,.72,0,1]},no=.4,nl=.25,rl=100,ro=8,_e=16,Ut=26,Dt="vaul-dragging";function oo(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>t.current==null?void 0:t.current.call(t,...n),[])}function ol({defaultProp:e,onChange:t}){const n=p.useState(e),[r]=n,s=p.useRef(r),a=oo(t);return p.useEffect(()=>{s.current!==r&&(a(r),s.current=r)},[r,s,a]),n}function so({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,s]=ol({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:r,i=oo(n),c=p.useCallback(d=>{if(a){const f=typeof d=="function"?d(e):d;f!==e&&i(f)}else s(d)},[a,e,s,i]);return[l,c]}function sl({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:r,overlayRef:s,fadeFromIndex:a,onSnapPointChange:l,direction:i="bottom",container:c,snapToSequentialPoint:d}){const[u,f]=so({prop:e,defaultProp:n?.[0],onChange:t}),[x,v]=p.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);p.useEffect(()=>{function j(){v({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]);const w=p.useMemo(()=>u===n?.[n.length-1]||null,[n,u]),m=p.useMemo(()=>{var j;return(j=n?.findIndex(C=>C===u))!=null?j:null},[n,u]),y=n&&n.length>0&&(a||a===0)&&!Number.isNaN(a)&&n[a]===u||!n,g=p.useMemo(()=>{const j=c?{width:c.getBoundingClientRect().width,height:c.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var C;return(C=n?.map(R=>{const B=typeof R=="string";let L=0;if(B&&(L=parseInt(R,10)),X(i)){const _=B?L:x?R*j.height:0;return x?i==="bottom"?j.height-_:-j.height+_:_}const D=B?L:x?R*j.width:0;return x?i==="right"?j.width-D:-j.width+D:D}))!=null?C:[]},[n,x,c]),k=p.useMemo(()=>m!==null?g?.[m]:null,[g,m]),N=p.useCallback(j=>{var C;const R=(C=g?.findIndex(B=>B===j))!=null?C:null;l(R),ee(r.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(i)?`translate3d(0, ${j}px, 0)`:`translate3d(${j}px, 0, 0)`}),g&&R!==g.length-1&&a!==void 0&&R!==a&&R<a?ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"0"}):ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"1"}),f(n?.[Math.max(R,0)])},[r.current,n,g,a,s,f]);p.useEffect(()=>{if(u||e){var j;const C=(j=n?.findIndex(R=>R===e||R===u))!=null?j:-1;g&&C!==-1&&typeof g[C]=="number"&&N(g[C])}},[u,e,n,g,N]);function b({draggedDistance:j,closeDrawer:C,velocity:R,dismissible:B}){if(a===void 0)return;const L=i==="bottom"||i==="right"?(k??0)-j:(k??0)+j,D=m===a-1,_=m===0,V=j>0;if(D&&ee(s.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`}),!d&&R>2&&!V){B?C():N(g[0]);return}if(!d&&R>2&&V&&g&&n){N(g[n.length-1]);return}const W=g?.reduce((H,S)=>typeof H!="number"||typeof S!="number"?H:Math.abs(S-L)<Math.abs(H-L)?S:H),G=X(i)?window.innerHeight:window.innerWidth;if(R>no&&Math.abs(j)<G*.4){const H=V?1:-1;if(H>0&&w&&n){N(g[n.length-1]);return}if(_&&H<0&&B&&C(),m===null)return;N(g[m+H]);return}N(W)}function A({draggedDistance:j}){if(k===null)return;const C=i==="bottom"||i==="right"?k-j:k+j;(i==="bottom"||i==="right")&&C<g[g.length-1]||(i==="top"||i==="left")&&C>g[g.length-1]||ee(r.current,{transform:X(i)?`translate3d(0, ${C}px, 0)`:`translate3d(${C}px, 0, 0)`})}function I(j,C){if(!n||typeof m!="number"||!g||a===void 0)return null;const R=m===a-1;if(m>=a&&C)return 0;if(R&&!C)return 1;if(!y&&!R)return null;const L=R?m+1:m-1,D=R?g[L]-g[L-1]:g[L+1]-g[L],_=j/Math.abs(D);return R?1-_:_}return{isLastSnapPoint:w,activeSnapPoint:u,shouldFade:y,getPercentageDragged:I,setActiveSnapPoint:f,activeSnapPointIndex:m,onRelease:b,onDrag:A,snapPointsOffset:g}}const al=()=>()=>{};function il(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:r,noBodyStyles:s}=et(),a=p.useRef(null),l=p.useMemo(()=>document.body.style.backgroundColor,[]);function i(){return(window.innerWidth-Ut)/window.innerWidth}p.useEffect(()=>{if(t&&n){a.current&&clearTimeout(a.current);const c=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!c)return;tl(r&&!s?It(document.body,{background:"black"}):al,It(c,{transformOrigin:X(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${K.DURATION}s`,transitionTimingFunction:`cubic-bezier(${K.EASE.join(",")})`}));const d=It(c,{borderRadius:`${ro}px`,overflow:"hidden",...X(e)?{transform:`scale(${i()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${i()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{d(),a.current=window.setTimeout(()=>{l?document.body.style.background=l:document.body.style.removeProperty("background")},K.DURATION*1e3)}}},[t,n,l])}let Ze=null;function ll({isOpen:e,modal:t,nested:n,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:a}){const[l,i]=p.useState(()=>typeof window<"u"?window.location.href:""),c=p.useRef(0),d=p.useCallback(()=>{if(Pn()&&Ze===null&&e&&!a){Ze={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:x}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-c.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const v=x-window.innerHeight;v&&c.current>=x&&(document.body.style.top=`${-(c.current+v)}px`)}),300)}},[e]),u=p.useCallback(()=>{if(Pn()&&Ze!==null&&!a){const f=-parseInt(document.body.style.top,10),x=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Ze),window.requestAnimationFrame(()=>{if(s&&l!==window.location.href){i(window.location.href);return}window.scrollTo(x,f)}),Ze=null}},[l]);return p.useEffect(()=>{function f(){c.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),p.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||u()}},[t,u]),p.useEffect(()=>{n||!r||(e?(!window.matchMedia("(display-mode: standalone)").matches&&d(),t||window.setTimeout(()=>{u()},500)):u())},[e,r,l,t,n,d,u]),{restorePositionSetting:u}}function cl({open:e,onOpenChange:t,children:n,onDrag:r,onRelease:s,snapPoints:a,shouldScaleBackground:l=!1,setBackgroundColorOnScale:i=!0,closeThreshold:c=nl,scrollLockTimeout:d=rl,dismissible:u=!0,handleOnly:f=!1,fadeFromIndex:x=a&&a.length-1,activeSnapPoint:v,setActiveSnapPoint:w,fixed:m,modal:y=!0,onClose:g,nested:k,noBodyStyles:N=!1,direction:b="bottom",defaultOpen:A=!1,disablePreventScroll:I=!0,snapToSequentialPoint:j=!1,preventScrollRestoration:C=!1,repositionInputs:R=!0,onAnimationEnd:B,container:L,autoFocus:D=!1}){var _,V;const[W=!1,G]=so({defaultProp:A,prop:e,onChange:M=>{t?.(M),!M&&!k&&bo(),setTimeout(()=>{B?.(M)},K.DURATION*1e3),M&&!y&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),M||(document.body.style.pointerEvents="auto")}}),[H,S]=p.useState(!1),[ne,oe]=p.useState(!1),[Ne,ue]=p.useState(!1),U=p.useRef(null),Q=p.useRef(null),ie=p.useRef(null),he=p.useRef(null),$=p.useRef(null),fe=p.useRef(!1),xe=p.useRef(null),ge=p.useRef(0),le=p.useRef(!1),Se=p.useRef(!A),sn=p.useRef(0),P=p.useRef(null),an=p.useRef(((_=P.current)==null?void 0:_.getBoundingClientRect().height)||0),ln=p.useRef(((V=P.current)==null?void 0:V.getBoundingClientRect().width)||0),yt=p.useRef(0),ho=p.useCallback(M=>{a&&M===qe.length-1&&(Q.current=new Date)},[]),{activeSnapPoint:xo,activeSnapPointIndex:Oe,setActiveSnapPoint:cn,onRelease:go,snapPointsOffset:qe,onDrag:vo,shouldFade:dn,getPercentageDragged:wo}=sl({snapPoints:a,activeSnapPointProp:v,setActiveSnapPointProp:w,drawerRef:P,fadeFromIndex:x,overlayRef:U,onSnapPointChange:ho,direction:b,container:L,snapToSequentialPoint:j});Ki({isDisabled:!W||ne||!y||Ne||!H||!R||!I});const{restorePositionSetting:bo}=ll({isOpen:W,modal:y,nested:k??!1,hasBeenOpened:H,preventScrollRestoration:C,noBodyStyles:N});function tt(){return(window.innerWidth-Ut)/window.innerWidth}function yo(M){var z,q;!u&&!a||P.current&&!P.current.contains(M.target)||(an.current=((z=P.current)==null?void 0:z.getBoundingClientRect().height)||0,ln.current=((q=P.current)==null?void 0:q.getBoundingClientRect().width)||0,oe(!0),ie.current=new Date,Xr()&&window.addEventListener("touchend",()=>fe.current=!1,{once:!0}),M.target.setPointerCapture(M.pointerId),ge.current=X(b)?M.pageY:M.pageX)}function un(M,z){var q;let F=M;const Z=(q=window.getSelection())==null?void 0:q.toString(),re=P.current?ut(P.current,b):null,te=new Date;if(F.tagName==="SELECT"||F.hasAttribute("data-vaul-no-drag")||F.closest("[data-vaul-no-drag]"))return!1;if(b==="right"||b==="left")return!0;if(Q.current&&te.getTime()-Q.current.getTime()<500)return!1;if(re!==null&&(b==="bottom"?re>0:re<0))return!0;if(Z&&Z.length>0)return!1;if($.current&&te.getTime()-$.current.getTime()<d&&re===0||z)return $.current=te,!1;for(;F;){if(F.scrollHeight>F.clientHeight){if(F.scrollTop!==0)return $.current=new Date,!1;if(F.getAttribute("role")==="dialog")return!0}F=F.parentNode}return!0}function Co(M){if(P.current&&ne){const z=b==="bottom"||b==="right"?1:-1,q=(ge.current-(X(b)?M.pageY:M.pageX))*z,F=q>0,Z=a&&!u&&!F;if(Z&&Oe===0)return;const re=Math.abs(q),te=document.querySelector("[data-vaul-drawer-wrapper]"),ve=b==="bottom"||b==="top"?an.current:ln.current;let se=re/ve;const Ee=wo(re,F);if(Ee!==null&&(se=Ee),Z&&se>=1||!fe.current&&!un(M.target,F))return;if(P.current.classList.add(Dt),fe.current=!0,ee(P.current,{transition:"none"}),ee(U.current,{transition:"none"}),a&&vo({draggedDistance:q}),F&&!a){const ce=el(q),nt=Math.min(ce*-1,0)*z;ee(P.current,{transform:X(b)?`translate3d(0, ${nt}px, 0)`:`translate3d(${nt}px, 0, 0)`});return}const we=1-se;if((dn||x&&Oe===x-1)&&(r?.(M,se),ee(U.current,{opacity:`${we}`,transition:"none"},!0)),te&&U.current&&l){const ce=Math.min(tt()+se*(1-tt()),1),nt=8-se*8,mn=Math.max(0,14-se*14);ee(te,{borderRadius:`${nt}px`,transform:X(b)?`scale(${ce}) translate3d(0, ${mn}px, 0)`:`scale(${ce}) translate3d(${mn}px, 0, 0)`,transition:"none"},!0)}if(!a){const ce=re*z;ee(P.current,{transform:X(b)?`translate3d(0, ${ce}px, 0)`:`translate3d(${ce}px, 0, 0)`})}}}p.useEffect(()=>{window.requestAnimationFrame(()=>{Se.current=!0})},[]),p.useEffect(()=>{var M;function z(){if(!P.current||!R)return;const q=document.activeElement;if(Ht(q)||le.current){var F;const Z=((F=window.visualViewport)==null?void 0:F.height)||0,re=window.innerHeight;let te=re-Z;const ve=P.current.getBoundingClientRect().height||0,se=ve>re*.8;yt.current||(yt.current=ve);const Ee=P.current.getBoundingClientRect().top;if(Math.abs(sn.current-te)>60&&(le.current=!le.current),a&&a.length>0&&qe&&Oe){const we=qe[Oe]||0;te+=we}if(sn.current=te,ve>Z||le.current){const we=P.current.getBoundingClientRect().height;let ce=we;we>Z&&(ce=Z-(se?Ee:Ut)),m?P.current.style.height=`${we-Math.max(te,0)}px`:P.current.style.height=`${Math.max(ce,Z-Ee)}px`}else zi()||(P.current.style.height=`${yt.current}px`);a&&a.length>0&&!le.current?P.current.style.bottom="0px":P.current.style.bottom=`${Math.max(te,0)}px`}}return(M=window.visualViewport)==null||M.addEventListener("resize",z),()=>{var q;return(q=window.visualViewport)==null?void 0:q.removeEventListener("resize",z)}},[Oe,a,qe]);function Ge(M){ko(),g?.(),M||G(!1),setTimeout(()=>{a&&cn(a[0])},K.DURATION*1e3)}function fn(){if(!P.current)return;const M=document.querySelector("[data-vaul-drawer-wrapper]"),z=ut(P.current,b);ee(P.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`}),ee(U.current,{transition:`opacity ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,opacity:"1"}),l&&z&&z>0&&W&&ee(M,{borderRadius:`${ro}px`,overflow:"hidden",...X(b)?{transform:`scale(${tt()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${tt()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${K.DURATION}s`,transitionTimingFunction:`cubic-bezier(${K.EASE.join(",")})`},!0)}function ko(){!ne||!P.current||(P.current.classList.remove(Dt),fe.current=!1,oe(!1),he.current=new Date)}function jo(M){if(!ne||!P.current)return;P.current.classList.remove(Dt),fe.current=!1,oe(!1),he.current=new Date;const z=ut(P.current,b);if(!M||!un(M.target,!1)||!z||Number.isNaN(z)||ie.current===null)return;const q=he.current.getTime()-ie.current.getTime(),F=ge.current-(X(b)?M.pageY:M.pageX),Z=Math.abs(F)/q;if(Z>.05&&(ue(!0),setTimeout(()=>{ue(!1)},200)),a){go({draggedDistance:F*(b==="bottom"||b==="right"?1:-1),closeDrawer:Ge,velocity:Z,dismissible:u}),s?.(M,!0);return}if(b==="bottom"||b==="right"?F>0:F<0){fn(),s?.(M,!0);return}if(Z>no){Ge(),s?.(M,!1);return}var re;const te=Math.min((re=P.current.getBoundingClientRect().height)!=null?re:0,window.innerHeight);var ve;const se=Math.min((ve=P.current.getBoundingClientRect().width)!=null?ve:0,window.innerWidth),Ee=b==="left"||b==="right";if(Math.abs(z)>=(Ee?se:te)*c){Ge(),s?.(M,!1);return}s?.(M,!0),fn()}p.useEffect(()=>(W&&(ee(document.documentElement,{scrollBehavior:"auto"}),Q.current=new Date),()=>{Ji(document.documentElement,"scrollBehavior")}),[W]);function No(M){const z=M?(window.innerWidth-_e)/window.innerWidth:1,q=M?-_e:0;xe.current&&window.clearTimeout(xe.current),ee(P.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(b)?`scale(${z}) translate3d(0, ${q}px, 0)`:`scale(${z}) translate3d(${q}px, 0, 0)`}),!M&&P.current&&(xe.current=setTimeout(()=>{const F=ut(P.current,b);ee(P.current,{transition:"none",transform:X(b)?`translate3d(0, ${F}px, 0)`:`translate3d(${F}px, 0, 0)`})},500))}function So(M,z){if(z<0)return;const q=(window.innerWidth-_e)/window.innerWidth,F=q+z*(1-q),Z=-_e+z*_e;ee(P.current,{transform:X(b)?`scale(${F}) translate3d(0, ${Z}px, 0)`:`scale(${F}) translate3d(${Z}px, 0, 0)`,transition:"none"})}function Eo(M,z){const q=X(b)?window.innerHeight:window.innerWidth,F=z?(q-_e)/q:1,Z=z?-_e:0;z&&ee(P.current,{transition:`transform ${K.DURATION}s cubic-bezier(${K.EASE.join(",")})`,transform:X(b)?`scale(${F}) translate3d(0, ${Z}px, 0)`:`scale(${F}) translate3d(${Z}px, 0, 0)`})}return p.useEffect(()=>{y||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[y]),p.createElement(Li,{defaultOpen:A,onOpenChange:M=>{!u&&!M||(M?S(!0):Ge(!0),G(M))},open:W},p.createElement(Qr.Provider,{value:{activeSnapPoint:xo,snapPoints:a,setActiveSnapPoint:cn,drawerRef:P,overlayRef:U,onOpenChange:t,onPress:yo,onRelease:jo,onDrag:Co,dismissible:u,shouldAnimate:Se,handleOnly:f,isOpen:W,isDragging:ne,shouldFade:dn,closeDrawer:Ge,onNestedDrag:So,onNestedOpenChange:No,onNestedRelease:Eo,keyboardIsOpen:le,modal:y,snapPointsOffset:qe,activeSnapPointIndex:Oe,direction:b,shouldScaleBackground:l,setBackgroundColorOnScale:i,noBodyStyles:N,container:L,autoFocus:D}},n))}const ao=p.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:r,onRelease:s,shouldFade:a,isOpen:l,modal:i,shouldAnimate:c}=et(),d=eo(t,n),u=r&&r.length>0;if(!i)return null;const f=p.useCallback(x=>s(x),[s]);return p.createElement(Oi,{onMouseUp:f,ref:d,"data-vaul-overlay":"","data-vaul-snap-points":l&&u?"true":"false","data-vaul-snap-points-overlay":l&&a?"true":"false","data-vaul-animate":c?.current?"true":"false",...e})});ao.displayName="Drawer.Overlay";const io=p.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...r},s){const{drawerRef:a,onPress:l,onRelease:i,onDrag:c,keyboardIsOpen:d,snapPointsOffset:u,activeSnapPointIndex:f,modal:x,isOpen:v,direction:w,snapPoints:m,container:y,handleOnly:g,shouldAnimate:k,autoFocus:N}=et(),[b,A]=p.useState(!1),I=eo(s,a),j=p.useRef(null),C=p.useRef(null),R=p.useRef(!1),B=m&&m.length>0;il();const L=(_,V,W=0)=>{if(R.current)return!0;const G=Math.abs(_.y),H=Math.abs(_.x),S=H>G,ne=["bottom","right"].includes(V)?1:-1;if(V==="left"||V==="right"){if(!(_.x*ne<0)&&H>=0&&H<=W)return S}else if(!(_.y*ne<0)&&G>=0&&G<=W)return!S;return R.current=!0,!0};p.useEffect(()=>{B&&window.requestAnimationFrame(()=>{A(!0)})},[]);function D(_){j.current=null,R.current=!1,i(_)}return p.createElement(Ii,{"data-vaul-drawer-direction":w,"data-vaul-drawer":"","data-vaul-delayed-snap-points":b?"true":"false","data-vaul-snap-points":v&&B?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":k?.current?"true":"false",...r,ref:I,style:u&&u.length>0?{"--snap-point-height":`${u[f??0]}px`,...t}:t,onPointerDown:_=>{g||(r.onPointerDown==null||r.onPointerDown.call(r,_),j.current={x:_.pageX,y:_.pageY},l(_))},onOpenAutoFocus:_=>{n?.(_),N||_.preventDefault()},onPointerDownOutside:_=>{if(e?.(_),!x||_.defaultPrevented){_.preventDefault();return}d.current&&(d.current=!1)},onFocusOutside:_=>{if(!x){_.preventDefault();return}},onPointerMove:_=>{if(C.current=_,g||(r.onPointerMove==null||r.onPointerMove.call(r,_),!j.current))return;const V=_.pageY-j.current.y,W=_.pageX-j.current.x,G=_.pointerType==="touch"?10:2;L({x:W,y:V},w,G)?c(_):(Math.abs(W)>G||Math.abs(V)>G)&&(j.current=null)},onPointerUp:_=>{r.onPointerUp==null||r.onPointerUp.call(r,_),j.current=null,R.current=!1,i(_)},onPointerOut:_=>{r.onPointerOut==null||r.onPointerOut.call(r,_),D(C.current)},onContextMenu:_=>{r.onContextMenu==null||r.onContextMenu.call(r,_),C.current&&D(C.current)}})});io.displayName="Drawer.Content";const dl=250,ul=120,fl=p.forwardRef(function({preventCycle:e=!1,children:t,...n},r){const{closeDrawer:s,isDragging:a,snapPoints:l,activeSnapPoint:i,setActiveSnapPoint:c,dismissible:d,handleOnly:u,isOpen:f,onPress:x,onDrag:v}=et(),w=p.useRef(null),m=p.useRef(!1);function y(){if(m.current){N();return}window.setTimeout(()=>{g()},ul)}function g(){if(a||e||m.current){N();return}if(N(),!l||l.length===0){d||s();return}if(i===l[l.length-1]&&d){s();return}const A=l.findIndex(j=>j===i);if(A===-1)return;const I=l[A+1];c(I)}function k(){w.current=window.setTimeout(()=>{m.current=!0},dl)}function N(){w.current&&window.clearTimeout(w.current),m.current=!1}return p.createElement("div",{onClick:y,onPointerCancel:N,onPointerDown:b=>{u&&x(b),k()},onPointerMove:b=>{u&&v(b)},ref:r,"data-vaul-drawer-visible":f?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},p.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});fl.displayName="Drawer.Handle";function ml(e){const t=et(),{container:n=t.container,...r}=e;return p.createElement(Pi,{container:n,...r})}const Re={Root:cl,Content:io,Overlay:ao,Portal:ml,Close:Fi,Title:Di,Description:$i};function pl(e=768){const[t,n]=p.useState(!1);return p.useEffect(()=>{const r=()=>{n(window.innerWidth<e)};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[e]),t}function tn({open:e,onOpenChange:t,children:n,title:r,description:s,className:a="",showCloseButton:l=!0}){return pl()?o.jsx(Re.Root,{open:e,onOpenChange:t,children:o.jsxs(Re.Portal,{children:[o.jsx(Re.Overlay,{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm"}),o.jsxs(Re.Content,{className:`fixed inset-x-0 bottom-0 z-50 mt-24 flex max-h-[96vh] flex-col rounded-t-2xl bg-[var(--optimex-surface)] border-t border-white/[0.05] outline-none ${a}`,children:[o.jsx("div",{className:"mx-auto mt-4 h-1.5 w-12 flex-shrink-0 rounded-full bg-white/20"}),(r||l)&&o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.05] px-4 pb-4 pt-2",children:[o.jsxs("div",{children:[r&&o.jsx(Re.Title,{className:"text-lg font-bold text-white",children:r}),s&&o.jsx(Re.Description,{className:"text-sm text-white/40",children:s})]}),l&&o.jsx(Re.Close,{className:"rounded-lg p-1.5 text-white/40 transition-colors hover:bg-white/10 hover:text-white/60",children:o.jsx(Ae,{})})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:n})]})]})}):e?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>t(!1)}),o.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":r?"modal-title":void 0,"aria-describedby":s?"modal-description":void 0,className:`relative z-10 flex max-h-[90vh] flex-col rounded-2xl bg-[var(--optimex-surface)] border border-white/[0.05] shadow-2xl ${a}`,children:[(r||l)&&o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.05] p-4",children:[o.jsxs("div",{children:[r&&o.jsx("h2",{id:"modal-title",className:"text-lg font-bold text-white",children:r}),s&&o.jsx("p",{id:"modal-description",className:"text-sm text-white/40",children:s})]}),l&&o.jsx("button",{onClick:()=>t(!1),className:"rounded-lg p-1.5 text-white/40 transition-colors hover:bg-white/10 hover:text-white/60",children:o.jsx(Ae,{})})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:n})]})]}):null}const hl=({children:e,className:t=""})=>o.jsx("div",{className:`p-4 ${t}`,children:e}),xl=({children:e,className:t=""})=>o.jsx("div",{className:`flex gap-2 border-t border-white/[0.05] p-4 ${t}`,children:e});function qt({children:e,onClick:t,isActive:n=!1,type:r="button",className:s=""}){return o.jsx("button",{type:r,onClick:t,className:vr(`px-2 py-1 bg-zinc-800/80 rounded-md text-xs transition-colors shadow-sm border ${n?"border-[var(--optimex-primary)]":"border-transparent text-white hover:bg-white/10 hover:text-white"} ${s}`),children:e})}const gl={"bottom-right":"right-0 top-full mt-2","bottom-left":"left-0 top-full mt-2","bottom-center":"left-1/2 -translate-x-1/2 top-full mt-2","top-right":"right-0 bottom-full mb-2","top-left":"left-0 bottom-full mb-2","top-center":"left-1/2 -translate-x-1/2 bottom-full mb-2"},vl={"bottom-right":"-top-2 right-4 rotate-45 border-l border-t","bottom-left":"-top-2 left-4 rotate-45 border-l border-t","bottom-center":"-top-2 left-1/2 -translate-x-1/2 rotate-45 border-l border-t","top-right":"-bottom-2 right-4 rotate-45 border-r border-b","top-left":"-bottom-2 left-4 rotate-45 border-r border-b","top-center":"-bottom-2 left-1/2 -translate-x-1/2 rotate-45 border-r border-b"};function wl({isOpen:e,onClose:t,children:n,anchorRef:r,position:s="bottom-right",width:a="w-72",showArrow:l=!0,className:i="",ariaLabel:c}){const d=p.useRef(null);return p.useEffect(()=>{if(!e)return;const u=v=>{const w=v.target;d.current?.contains(w)||r?.current?.contains(w)||t()},f=v=>{v.key==="Escape"&&t()},x=setTimeout(()=>{document.addEventListener("mousedown",u),document.addEventListener("keydown",f)},0);return()=>{clearTimeout(x),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[e,t,r]),e?o.jsxs("div",{ref:d,className:`absolute z-50 rounded-[0.25rem] border border-[var(--optimex-border)] bg-[var(--optimex-surface)] p-4 shadow-lg ${gl[s]} ${a} ${i}`,role:"dialog","aria-label":c,children:[l&&o.jsx("div",{className:`absolute h-4 w-4 border-[var(--optimex-border)] bg-[var(--optimex-surface)] ${vl[s]}`}),o.jsx("div",{className:"relative",children:n})]}):null}function bl({value:e,onChange:t,placeholder:n,hasError:r=!1,leftIcon:s,rightContent:a,type:l="text",inputMode:i="text",disabled:c=!1,className:d=""}){return o.jsxs("div",{className:`flex rounded-md items-center gap-2 bg-white/5 border py-3 px-3 transition-colors ${r?"border-red-500":"border-white/10 hover:border-[var(--optimex-primary)] focus-within:border-[var(--optimex-primary)]"} ${c?"opacity-50 cursor-not-allowed":""} ${d}`,children:[s&&o.jsx(s,{className:"size-5 text-white/40 shrink-0"}),o.jsx("input",{type:l,inputMode:i,value:e,onChange:u=>t(u.target.value),placeholder:n,disabled:c,className:"flex-1 min-w-0 bg-transparent text-white text-sm placeholder:text-white/10 outline-none disabled:cursor-not-allowed"}),a]})}const yl={sm:{container:"h-6 w-6",icon:"h-6 w-6",badge:"h-3 w-3"},md:{container:"h-8 w-8",icon:"h-8 w-8",badge:"h-4 w-4"},lg:{container:"h-10 w-10",icon:"h-10 w-10",badge:"h-5 w-5"},xl:{container:"h-14 w-14",icon:"h-14 w-14",badge:"h-6 w-6"}};function Le({token:e,size:t="md",showNetworkBadge:n=!0}){const r=yl[t];return o.jsxs("div",{className:`relative shrink-0 ${r.container}`,children:[o.jsx("img",{src:e.token_logo_uri||"/placeholder-token.svg",alt:e.token_symbol,className:`${r.icon} rounded-full bg-[var(--optimex-background)]`,onError:s=>{s.target.src="/placeholder-token.svg"}}),n&&e.network_logo_uri&&o.jsx("img",{src:e.network_logo_uri,alt:e.network_name,className:`absolute -bottom-1 -right-1 ${r.badge} rounded-full border-2 border-[var(--optimex-surface)]`,onError:s=>{s.target.style.display="none"}})]})}const Cl="glass-container rounded-3xl p-4 shadow-2xl relative w-full min-w-0";function nn({children:e,className:t}){return o.jsx("div",{className:t??Cl,children:e})}function kl(){return o.jsxs("div",{className:"relative size-20 mb-4",children:[o.jsx("div",{className:"absolute inset-0 rounded-full bg-red-500/10 animate-pulse"}),o.jsx("div",{className:"absolute inset-2 rounded-full bg-red-500/20"}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx(ns,{className:"size-10 text-red-500"})})]})}function jl({error:e,onRetry:t,className:n}){const r=()=>{const s=e?.message?.toLowerCase()||"";return s.includes("network")||s.includes("fetch")?"Connection issue. Check your internet and try again.":s.includes("timeout")?"Request timed out. The server might be busy.":s.includes("401")||s.includes("403")?"Access denied. Please check your credentials.":s.includes("500")||s.includes("server")?"Server is having issues. Please try again later.":"Something went wrong while loading. Let's give it another shot!"};return o.jsx(nn,{className:n,children:o.jsx("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-6 border border-white/[0.02]",children:o.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[o.jsx(kl,{}),o.jsx("h3",{className:"text-base font-bold text-white mb-1",children:"Oops! Something went wrong"}),o.jsx("p",{className:"text-sm text-white/40 mb-6 max-w-[280px]",children:r()}),o.jsx(or,{onClick:t,size:"md",fullWidth:!0,leftIcon:o.jsx(ts,{className:"size-4 transition-transform group-hover:rotate-180"}),children:"Try Again"}),e?.message&&o.jsxs("details",{className:"mt-4 w-full",children:[o.jsx("summary",{className:"cursor-pointer text-xs text-white/30 hover:text-white/50 transition-colors",children:"Technical details"}),o.jsx("p",{className:"mt-2 bg-white/5 p-3 text-left text-xs text-white/40 break-all border border-white/[0.02]",children:e.message})]})]})})})}function Nl({className:e}){return o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("header",{className:"flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 rounded-lg bg-[var(--optimex-primary)]/30 animate-pulse"}),o.jsx("div",{className:"h-6 w-28 rounded bg-white/10 animate-pulse"})]}),o.jsx("div",{className:"size-10 rounded-lg bg-white/5 animate-pulse"})]}),o.jsxs(nn,{className:e,children:[o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-2",children:[o.jsx("div",{className:"flex justify-between items-center mb-4",children:o.jsx("div",{className:"h-3 w-10 animate-pulse rounded bg-white/10"})}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-8 w-24 animate-pulse rounded bg-white/10 mb-2"}),o.jsx("div",{className:"h-3 w-16 animate-pulse rounded bg-white/5"})]}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 p-2 pr-3 rounded-full border border-white/10",children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10 animate-pulse"}),o.jsxs("div",{children:[o.jsx("div",{className:"h-4 w-12 animate-pulse rounded bg-white/10 mb-1"}),o.jsx("div",{className:"h-2 w-16 animate-pulse rounded bg-white/5"})]})]})]})]}),o.jsx("div",{className:"relative z-10 -my-4 flex justify-center",children:o.jsx("div",{className:"size-10 rounded-full bg-[var(--optimex-surface)] border-4 border-[var(--optimex-background)] animate-pulse"})}),o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-4",children:[o.jsx("div",{className:"flex justify-between items-center mb-4",children:o.jsx("div",{className:"h-3 w-6 animate-pulse rounded bg-white/10"})}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"h-8 w-20 animate-pulse rounded bg-white/10 mb-2"}),o.jsx("div",{className:"h-3 w-14 animate-pulse rounded bg-white/5"})]}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 p-2 pr-3 rounded-full border border-white/10",children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10 animate-pulse"}),o.jsxs("div",{children:[o.jsx("div",{className:"h-4 w-12 animate-pulse rounded bg-white/10 mb-1"}),o.jsx("div",{className:"h-2 w-16 animate-pulse rounded bg-white/5"})]})]})]})]}),o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.02] mb-4",children:[o.jsx("div",{className:"h-3 w-28 animate-pulse rounded bg-white/10 mb-2"}),o.jsxs("div",{className:"flex items-center gap-2 bg-white/5 border border-white/10 py-3 px-3 rounded-md",children:[o.jsx("div",{className:"size-5 rounded-full bg-white/10 animate-pulse shrink-0"}),o.jsx("div",{className:"h-4 flex-1 animate-pulse rounded bg-white/5"})]}),o.jsx("div",{className:"h-2 w-48 animate-pulse rounded bg-white/5 mt-2"})]}),o.jsx("div",{className:"h-12 w-full animate-pulse rounded-xl bg-[var(--optimex-primary)]/30 bg-white/5 mt-2"}),o.jsx("div",{className:"mt-4 flex items-center justify-center",children:o.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-white/5"})})]})]})}const lo=p.createContext(null);function Sl({children:e}){const t=Je(),{data:n,isLoading:r,error:s,refetch:a}=Po(t.apiBaseUrl),l=t.renderLoading??Nl,i=t.renderError??jl;if(r)return o.jsx(l,{});if(s||!n){const c=s instanceof Error?s:new Error("Failed to load tokens");return o.jsx(i,{error:c,onRetry:()=>a()})}return o.jsx(lo.Provider,{value:{tokensData:n,refetch:a},children:e})}function El(){const e=p.useContext(lo);if(!e)throw new Error("useTokensData must be used within TokensProvider");return e}function Tl({token:e,value:t,onChange:n,placeholder:r,error:s,onClose:a}){const l=p.useCallback(()=>{n("")},[n]),i=p.useCallback(async()=>{try{const f=await navigator.clipboard.readText();f&&n(f.trim())}catch(f){console.error("Failed to read clipboard:",f)}},[n]),c=()=>r||(e?`Enter ${e.network_name} address`:"Enter receiving address"),d=e?.network_name||"destination",u=p.useMemo(()=>ss(e?.network_name)||Zn,[e?.network_name]);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 border border-white/[0.05] animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("label",{className:"text-white/40 text-xs",children:"Recipient Address"}),a&&o.jsx("button",{type:"button",onClick:l,className:"text-white/20 hover:text-white/40 transition-colors",children:o.jsx(Ae,{className:"size-4"})})]}),o.jsx(bl,{value:t,onChange:n,placeholder:c(),hasError:!!s,leftIcon:u,rightContent:t?o.jsx("button",{type:"button",onClick:l,className:"text-white/40 hover:text-white/60 transition-colors",children:o.jsx(Ae,{className:"size-5"})}):o.jsx("button",{type:"button",onClick:i,className:"text-white/40 hover:text-[var(--optimex-primary)] transition-colors",children:o.jsx(es,{className:"size-5"})})}),s?o.jsxs("p",{className:"text-[10px] text-red-500 mt-2 flex items-center gap-1",children:[o.jsx(pn,{className:"size-3"}),s]}):o.jsxs("p",{className:"text-[10px] text-white/40 mt-2 flex items-center gap-1",children:[o.jsx(pn,{className:"size-3"}),"Ensure the address matches the ",d," network."]})]})}function $n({token:e,value:t,onChange:n,readOnly:r=!1,onSelectToken:s,isLoading:a=!1,loadingText:l="Loading...",balance:i,isOutput:c=!1,isWalletConnected:d=!1,usdValue:u="$0.00"}){const f=m=>{if(r||!n)return;const y=m.target.value;/^[0-9]*\.?[0-9]*$/.test(y)&&n(y)},x=d&&!c&&i!==void 0,v=()=>{if(!i||!n||r)return;const m=(parseFloat(i)/2).toString();n(m)},w=()=>{!i||!n||r||n(i)};return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-2xl p-4 flex flex-col gap-2 border border-white/[0.02] focus-within:border-[var(--optimex-primary)]/40 transition-colors",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsx("span",{className:"text-white/40 text-xs",children:c?"To":"From"}),o.jsx("div",{className:"flex items-center gap-2",children:x&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-white/40 text-xs",children:["Balance: ",i," ",e?.token_symbol]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(qt,{onClick:v,children:"50%"}),o.jsx(qt,{onClick:w,children:"Max"})]})]})})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"0.0",value:t,onChange:f,readOnly:r,className:"w-full bg-transparent border-none p-0 text-white text-2xl font-bold focus:ring-0 placeholder:text-white/10 outline-none"}),o.jsxs("p",{className:"text-white/30 text-xs mt-1",children:["~",u]})]}),o.jsxs("button",{onClick:s,className:"flex items-center gap-2 bg-white/5 hover:bg-white/10 p-2 pr-3 rounded-full transition-all border border-white/10 active:scale-95 shrink-0",children:[e?o.jsxs(o.Fragment,{children:[o.jsx(Le,{token:e,size:"md"}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-white text-sm font-bold leading-none",children:e.token_symbol}),o.jsx("p",{className:"text-white/40 text-[10px] leading-none mt-1",children:e.network_name})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"size-8 rounded-full bg-white/10"}),o.jsx("span",{className:"text-white text-sm font-bold",children:"Select"})]}),o.jsx(Kn,{className:"size-4 text-white/20"})]})]}),a&&o.jsxs("div",{className:"flex items-center justify-end gap-2 text-sm text-white/40",children:[o.jsx("div",{className:"size-3 animate-spin rounded-full border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:l})]})]})}const $t=[.5,.75,1];function _l({value:e,onChange:t}){const[n,r]=p.useState(""),[s,a]=p.useState(!$t.includes(e)),l=p.useCallback(d=>{a(!1),r(""),t(d)},[t]),i=p.useCallback(d=>{const u=d.target.value;if(u===""||/^\d*\.?\d*$/.test(u)){r(u),a(!0);const f=parseFloat(u);!isNaN(f)&&f>0&&f<=50&&t(f)}},[t]),c=p.useCallback(()=>{a(!0),!n&&e&&r($t.includes(e)?"":String(e))},[n,e]);return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:"Slippage Tolerance"}),o.jsxs("span",{className:"text-sm text-[var(--optimex-text-secondary)]",children:[e,"%"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[$t.map(d=>o.jsxs(qt,{onClick:()=>l(d),isActive:e===d&&!s,className:"flex-1",children:[d,"%"]},d)),o.jsxs("div",{className:`flex flex-1 items-center justify-center px-2 rounded-md transition-colors shadow-sm bg-zinc-800/80 border ${s?"border-[var(--optimex-primary)]":"border-transparent hover:bg-white/10"}`,children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Custom",value:n,onChange:i,onFocus:c,className:"w-full min-w-0 py-[6px] bg-transparent text-center text-xs outline-none placeholder:text-white/50 text-white"}),o.jsx("span",{className:"text-xs text-white/50",children:"%"})]})]}),e>5&&o.jsx("p",{className:"text-xs text-[var(--optimex-warning)]",children:"This may result in an unfavorable trade. Try lowering your slippage setting."})]})}function Rl({isOpen:e,onClose:t,value:n,onChange:r,anchorRef:s}){const a=p.useCallback(l=>{r(l)},[r]);return o.jsx(wl,{isOpen:e,onClose:t,anchorRef:s,position:"bottom-right",width:"w-96",ariaLabel:"Slippage settings",children:o.jsx(_l,{value:n,onChange:a})})}function Al({title:e="Swap",slippage:t=.75,onSlippageChange:n,isSettingsOpen:r=!1,onSettingsToggle:s,onHistoryClick:a,hideHistory:l=!1}){const i=p.useRef(null);return o.jsxs("header",{className:"flex items-center justify-between px-2",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 bg-[var(--optimex-primary)] rounded-lg flex items-center justify-center shadow-[0_0_15px_rgba(235,98,0,0.3)]",children:o.jsx(Xo,{className:"w-5 h-auto text-white"})}),o.jsx("h2",{className:"text-xl font-bold tracking-tight text-[var(--optimex-text)]",children:e})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[!l&&o.jsx("button",{onClick:a,className:"size-10 rounded-lg bg-white/5 hover:bg-white/10 text-white/60 hover:text-white transition-colors flex items-center justify-center","aria-label":"Trade History",children:o.jsx(Zo,{className:"size-5"})}),o.jsxs("div",{className:"relative",children:[o.jsx("button",{ref:i,onClick:s,className:"size-10 rounded-lg bg-white/5 hover:bg-white/10 text-white/60 hover:text-white transition-colors flex items-center justify-center","aria-label":"Settings",children:o.jsx(os,{className:"size-5"})}),o.jsx(Rl,{isOpen:r,onClose:()=>s?.(),value:t,onChange:c=>n?.(c),anchorRef:i})]})]})]})}function co({onClick:e,disabled:t}){return o.jsx("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",children:o.jsx("button",{onClick:e,disabled:t,className:"size-10 rounded-full bg-[var(--optimex-surface)] border-4 border-white/5 flex items-center justify-center text-[var(--optimex-primary)] hover:scale-110 transition-all shadow-xl disabled:cursor-not-allowed",children:o.jsx(Go,{className:"size-5"})})})}function Ml({quote:e,fromToken:t,toToken:n,amount:r,slippage:s,isFetching:a}){const[l,i]=p.useState(!1),[c,d]=p.useState(!1),u=p.useCallback(()=>{d(g=>!g)},[]),f=p.useCallback(()=>{i(g=>!g)},[]),x=parseFloat(r)||0,v=parseFloat(e.min_amount_out)/Math.pow(10,n.token_decimals),w=x>0?v/x:0,m=v>0?x/v:0,y=()=>c?`1 ${n.token_symbol} = ${m.toFixed(6)} ${t.token_symbol}`:`1 ${t.token_symbol} = ${w.toFixed(6)} ${n.token_symbol}`;return o.jsxs("div",{className:"bg-white/[0.02] rounded-md border border-white/5 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:f,className:"w-full flex items-center justify-between p-3 text-xs cursor-pointer hover:bg-white/[0.02] transition-colors",children:[o.jsx("div",{className:"flex items-center gap-2 text-white/60 font-medium",children:a?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"size-3 animate-spin rounded-full border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:"Updating..."})]}):o.jsx("span",{role:"button",tabIndex:0,onClick:g=>{g.stopPropagation(),u()},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.stopPropagation(),u())},className:"hover:text-white transition-colors",children:y()})}),o.jsx(Kn,{className:`size-4 text-white/40 transition-transform ${l?"rotate-180":""}`})]}),l&&o.jsxs("div",{className:"px-3 pb-3 space-y-2 text-xs border-t border-white/5",children:[o.jsxs("div",{className:"flex items-center justify-between pt-3",children:[o.jsx("span",{className:"text-white/40",children:"Min. Received"}),o.jsxs("span",{className:"font-medium text-white",children:[je(e.min_amount_out,n.token_decimals)," ",n.token_symbol]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-white/40",children:"Est. Time"}),o.jsx("span",{className:"font-medium text-[var(--optimex-primary)]",children:"~10 minutes"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-white/40",children:"Slippage Tolerance"}),o.jsxs("span",{className:"font-medium text-white",children:[s,"%"]})]})]})]})}function Ll({text:e,disabled:t,onClick:n}){return o.jsx("button",{disabled:t,onClick:n,className:"w-full font-semibold text-black bg-[var(--optimex-primary)] hover:bg-[var(--optimex-primary-hover)] hover:brightness-110 py-4 rounded-md shadow-lg shadow-[var(--optimex-primary)]/30 flex items-center justify-center transition-all active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50",children:e})}function Pl(){return o.jsxs("a",{href:"https://optimex.com",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-1.5 text-[var(--optimex-text-secondary)] text-[10px] opacity-50 hover:opacity-70 transition-opacity",children:[o.jsx("span",{children:"Powered by"}),o.jsx(Jo,{className:"h-3 w-auto"})]})}function Ol({value:e,onChange:t,placeholder:n="Search by name or symbol..."}){return o.jsx("div",{className:"p-4 pb-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",placeholder:n,value:e,onChange:r=>t(r.target.value),className:"w-full rounded-xl bg-white/5 border border-white/10 px-4 py-3 pl-10 pr-10 text-white outline-none placeholder:text-white/30 transition-colors hover:border-[var(--optimex-primary)] focus:border-[var(--optimex-primary)]"}),o.jsx(rs,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-white/40"}),e&&o.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/60 transition-colors",children:o.jsx(Ae,{className:"size-5"})})]})})}function Il({networks:e,selectedNetwork:t,onSelectNetwork:n}){return o.jsxs("div",{className:"w-1/3 min-w-[140px] border-r border-white/[0.05] overflow-y-auto p-2",children:[o.jsx("div",{className:"mb-2 px-2 text-xs font-medium uppercase tracking-wider text-white/40",children:"Networks"}),o.jsxs("div",{className:"space-y-1 px-2",children:[o.jsxs("button",{onClick:()=>n(null),className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t===null?"bg-white/5 text-white":"text-white/60 hover:bg-white/5 hover:text-white"}`,children:[o.jsx(qo,{}),o.jsx("span",{children:"All"})]}),e.map(r=>o.jsx(Dl,{network:r,isSelected:t===r.network_id,onSelect:()=>n(r.network_id)},r.network_id))]})]})}function Dl({network:e,isSelected:t,onSelect:n}){return o.jsxs("button",{onClick:n,className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t?"bg-white/5 text-white":"text-white/60 hover:bg-white/5 hover:text-white"}`,children:[e.logo_uri?o.jsx("img",{src:e.logo_uri,alt:e.name,className:"h-8 w-8 rounded-lg",onError:r=>{r.target.style.display="none"}}):o.jsx("div",{className:"h-6 w-6 rounded-full bg-white/10"}),o.jsx("span",{className:"truncate",children:e.name})]})}function $l({tokens:e,selectedSymbol:t,onSelectSymbol:n,maxVisible:r=12}){return o.jsxs("div",{className:"border-b border-white/[0.05] p-2",children:[o.jsx("div",{className:"mb-2 px-2 text-xs font-medium uppercase tracking-wider text-white/40",children:"Tokens"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5 overflow-hidden max-h-[5rem]",children:[o.jsx("button",{onClick:()=>n(null),className:`border rounded-lg px-2.5 py-1 text-xs font-medium transition-colors ${t===null?"border-[var(--optimex-primary)] text-white":"border-transparent text-white/60 hover:bg-white/10 hover:text-white"}`,children:"All"}),e.slice(0,r).map(s=>o.jsx(Fl,{token:s,isSelected:t===s.token_symbol,onSelect:()=>n(s.token_symbol)},s.token_symbol))]})]})}function Fl({token:e,isSelected:t,onSelect:n}){return o.jsxs("button",{onClick:n,className:vr("flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs font-medium transition-colors outline-none border bg-white/5",t?"border-[var(--optimex-primary)] text-white":"border-transparent text-white/60 hover:bg-white/10 hover:text-white"),children:[e.token_logo_uri&&o.jsx("img",{src:e.token_logo_uri,alt:e.token_symbol,className:"h-4 w-4 rounded-full",onError:r=>{r.target.style.display="none"}}),e.token_symbol]})}function Ue(){const e=p.useContext(Hn);if(!e)throw new Error("useWallet must be used within WalletProvider");return e}function bt(e){return`https://network-api-stg.bitdex.xyz/${e}/rpc/zwD70RMT9DrE8L5SaMnJNMF8m70Gum`}function Bl(e){return e==="bitcoin_testnet"?"https://mempool.space/testnet4/api":"https://mempool.space/api"}function rn(e){return!e.token_address||e.token_address===""||e.token_address==="native"||e.token_address==="0x0000000000000000000000000000000000000000"}function zl(e,t){if(!e||e==="0")return"0";const n=BigInt(e),r=BigInt(10**t),s=n/r,a=n%r;if(a===BigInt(0))return s.toString();let l=a.toString().padStart(t,"0");return l=l.replace(/0+$/,""),l.length>6&&(l=l.slice(0,6)),`${s}.${l}`}function Vl(e){return`0x70a08231000000000000000000000000${e.toLowerCase().replace("0x","")}`}async function uo(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`RPC request failed: ${n.status}`);return n.json()}async function Wl(e,t){const r=await uo(e,{jsonrpc:"2.0",method:"eth_getBalance",params:[t,"latest"],id:1});if(r.error)throw new Error(`RPC error: ${r.error.message}`);const s=r.result||"0x0";return BigInt(s).toString()}async function Hl(e,t,n){const r={jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:Vl(n)},"latest"],id:1},s=await uo(e,r);if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result||"0x0";return BigInt(a).toString()}async function Ul(e,t){const n=bt(e.network_id),r=rn(e);let s;return r?s=await Wl(n,t):s=await Hl(n,e.token_address,t),{rawBalance:s,isNative:r}}async function ql(e,t){const r=`${Bl(e.network_id)}/address/${t}`,s=await fetch(r);if(!s.ok)throw new Error(`Mempool API request failed: ${s.status}`);const a=await s.json(),l=a.chain_stats.funded_txo_sum-a.chain_stats.spent_txo_sum,i=a.mempool_stats.funded_txo_sum-a.mempool_stats.spent_txo_sum;return{rawBalance:(l+i).toString(),isNative:!0}}async function fo(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`RPC request failed: ${n.status}`);return n.json()}async function Gl(e,t){const r=await fo(e,{jsonrpc:"2.0",method:"getBalance",params:[t],id:1});if(r.error)throw new Error(`RPC error: ${r.error.message}`);return(r.result?.value||0).toString()}async function Kl(e,t,n){const s=await fo(e,{jsonrpc:"2.0",method:"getTokenAccountsByOwner",params:[n,{mint:t},{encoding:"jsonParsed"}],id:1});if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result?.value||[];let l=BigInt(0);for(const i of a){const c=i.account.data.parsed.info.tokenAmount.amount;l+=BigInt(c)}return l.toString()}async function Yl(e,t){const n=bt(e.network_id),r=rn(e);let s;return r?s=await Gl(n,t):s=await Kl(n,e.token_address,t),{rawBalance:s,isNative:r}}function Zl(e,t){if(!t)return!1;switch(t){case Y.EVM:return e.isEvmConnected;case Y.BTC:return e.isBtcConnected;case Y.SOLANA:return e.isSolanaConnected;default:return!1}}function Ql(e){if(!e)return"";switch(e){case Y.EVM:return"EVM";case Y.BTC:return"Bitcoin";case Y.SOLANA:return"Solana";default:return e}}function Xl(e,t){if(!t)return null;switch(t){case Y.EVM:return e.evmAddress;case Y.BTC:return e.btcAddress;case Y.SOLANA:return e.solanaAddress;default:return null}}async function Jl(e,t){const n=e.token_address||"native";let r;switch(e.network_type){case Y.BTC:r=await ql(e,t);break;case Y.SOLANA:r=await Yl(e,t);break;case Y.EVM:default:r=await Ul(e,t)}return{tokenId:n,networkId:e.network_id,walletAddress:t,rawBalance:r.rawBalance,formattedBalance:zl(r.rawBalance,e.token_decimals),updatedAt:Date.now()}}const ec=30*1e3,tc=15*1e3;function nc(e,t){return!e||!t?["balance"]:["balance",e.network_id,e.token_address||"native",t]}function mo({token:e,walletAddress:t,enabled:n=!0,polling:r=!1,pollingInterval:s=tc}){const a=n&&!!e&&!!t,{data:l,isLoading:i,isFetching:c,error:d,refetch:u}=ke.useQuery({queryKey:nc(e,t),queryFn:()=>Jl(e,t),enabled:a,staleTime:ec,retry:1,refetchOnWindowFocus:!1,refetchInterval:r?s:!1});return{balance:l,formattedBalance:l?.formattedBalance||"0",isLoading:a&&i,isFetching:a&&c,error:d,refetch:u}}function rc({token:e,isSelected:t,isDisabled:n,onSelect:r}){const s=Ue(),a=Xl(s,e.network_type),{formattedBalance:l,isLoading:i}=mo({token:e,walletAddress:a,enabled:!!a}),c=!!a;return o.jsxs("button",{onClick:r,disabled:n,className:`flex w-full items-center gap-3 rounded-lg p-2 transition-colors ${t?"bg-white/5 text-white":n?"cursor-not-allowed opacity-50":"hover:bg-white/5"}`,children:[o.jsx(Le,{token:e}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"text-sm text-white/40",children:e.token_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[c&&o.jsx("span",{className:"text-sm font-medium text-white",children:i?o.jsx("span",{className:"inline-block h-4 w-12 animate-pulse rounded bg-white/10"}):l}),o.jsx("span",{className:"font-medium text-white",children:e.token_symbol})]})]}),t&&o.jsx(Yt,{className:"h-5 w-5 text-[var(--optimex-primary)]"})]})}function oc({tokens:e,selectedTokenId:t,disabledTokenId:n,disabledTokenIds:r,isLoading:s,emptyMessage:a="No tokens available",onSelect:l}){return s?o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-[var(--optimex-primary)] border-t-transparent"})})}):e.length===0?o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"py-8 text-center text-white/40",children:a})}):o.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1",children:e.map(i=>{const c=n===i.token_id||r?.has(i.token_id)===!0;return o.jsx(rc,{token:i,isSelected:t===i.token_id,isDisabled:c,onSelect:()=>l(i)},i.token_id)})})})}function sc({isOpen:e,onClose:t,onSelect:n,tokensData:r,isLoading:s,selectedToken:a,disabledTokenId:l,disabledTokenIds:i,tokens:c,emptyMessage:d,title:u="Select Token",filterNetworkType:f}){const[x,v]=p.useState(""),[w,m]=p.useState(null),[y,g]=p.useState(null),k=p.useMemo(()=>r?.supported_networks?f?r.supported_networks.filter(L=>L.type===f):r.supported_networks:[],[r,f]),N=c??r?.tokens,b=p.useMemo(()=>N?N.filter(L=>{if(f&&L.network_type!==f||w&&L.network_id!==w)return!1;if(x){const D=(V,W)=>V.toLowerCase().includes(W.toLowerCase()),_=x.toLowerCase();return D(L.token_symbol,_)||D(L.token_name,_)||D(L.token_address,_)}return!0}):[],[N,x,w,f]),A=p.useMemo(()=>{if(!N)return[];const L=new Map;return N.forEach(D=>{f&&D.network_type!==f||w&&D.network_id!==w||L.has(D.token_symbol)||L.set(D.token_symbol,D)}),Array.from(L.values())},[N,f,w]),I=p.useMemo(()=>y?b.filter(L=>L.token_symbol===y):b,[b,y]),j=()=>{v(""),m(null),g(null)},C=L=>{n(L),t(),j()},R=L=>{L||(t(),j())},B=L=>{m(L),g(null)};return o.jsx(tn,{open:e,onOpenChange:R,title:u,className:"h-full md:h-[70vh] max-h-[600px] w-full max-w-2xl",children:o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx(Ol,{value:x,onChange:v}),o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[o.jsx(Il,{networks:k,selectedNetwork:w,onSelectNetwork:B}),o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden pl-2",children:[o.jsx($l,{tokens:A,selectedSymbol:y,onSelectSymbol:g}),o.jsx(oc,{tokens:I,selectedTokenId:a?.token_id,disabledTokenId:l,disabledTokenIds:i,isLoading:s,emptyMessage:x?"No tokens found":d??"No tokens available",onSelect:C})]})]})]})})}function Fn({token:e,amount:t,label:n,isEstimated:r=!1,highlight:s=!1,usdValue:a="$0.00"}){return o.jsx("div",{className:`p-4 rounded-xl border transition-all duration-200 ${s?"bg-zinc-900/50 border-[var(--optimex-primary)]/20 shadow-[0_0_15px_rgba(235,98,0,0.1)]":"bg-zinc-900/50 border-white/5"}`,children:o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"size-12 flex items-center justify-center ",children:o.jsx(Le,{token:e,size:"lg"})}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[o.jsxs("p",{className:`text-xs font-medium uppercase tracking-wider ${s?"text-[var(--optimex-primary)]":"text-zinc-500"}`,children:[n," ",r&&"(Est.)"]}),o.jsx("p",{className:"text-white text-sm font-semibold truncate",children:e.token_symbol}),o.jsx("p",{className:"text-zinc-500 text-xs truncate",children:e.network_name})]}),o.jsxs("div",{className:"flex flex-col items-end gap-0.5 ml-auto shrink-0",children:[o.jsx("p",{className:"text-white text-lg font-bold",children:r?`~${t}`:t}),o.jsx("p",{className:"text-zinc-400 text-xs",children:a})]})]})})}function ac({fromToken:e,toToken:t,fromAmount:n,toAmount:r,fromUsdValue:s="$0.00",toUsdValue:a="$0.00"}){return o.jsxs("div",{className:"relative flex flex-col gap-2",children:[o.jsx(Fn,{token:e,amount:n,label:"You Pay",usdValue:s}),o.jsx(co,{onClick:()=>{},disabled:!0}),o.jsx(Fn,{token:t,amount:r,label:"You Receive",usdValue:a})]})}function Ft({label:e,value:t,borderTop:n}){return o.jsxs("div",{className:`flex justify-between items-center text-sm ${n?"pt-2 mt-2 border-t border-white/5":""}`,children:[o.jsx("span",{className:"text-zinc-500",children:e}),o.jsx("div",{className:"flex items-center gap-1 text-white font-medium",children:t})]})}function ic({minReceived:e,estimatedTime:t,slippage:n,networkFee:r="Included"}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-xl p-4 border border-white/5 space-y-3",children:[o.jsx(Ft,{label:"Min. Received",value:e}),o.jsx(Ft,{label:"Estimated Time",value:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"size-2 bg-[var(--optimex-primary)] rounded-full animate-pulse shadow-[0_0_8px_rgba(235,98,0,0.8)]"}),o.jsx("span",{children:t})]})}),o.jsx(Ft,{label:"Slippage Tolerance",value:n})]})}const lc=3e4,cc=6e4;function xt({symbol:e,enabled:t=!0}){const n=Je(),{data:r,isLoading:s,isError:a}=ke.useQuery({queryKey:["tokenPrice",e],queryFn:async()=>{if(!e)throw new Error("Symbol is required");return(await Ve(n.apiBaseUrl).getTokenPrice(e)).current_price},enabled:t&&!!e,staleTime:lc,refetchInterval:cc,retry:2});return{price:r??null,isLoading:s,isError:a,calculateUsdValue:i=>{if(!r||!i||isNaN(parseFloat(i)))return"$0.00";const c=parseFloat(i);if(c===0)return"$0.00";const d=c*r;return d<.01?"<$0.01":d<1?`$${d.toFixed(4)}`:d<1e3?`$${d.toFixed(2)}`:d<1e6?`$${(d/1e3).toFixed(2)}K`:`$${(d/1e6).toFixed(2)}M`}}}function dc({isOpen:e,onClose:t,onConfirm:n,fromToken:r,toToken:s,amountIn:a,quote:l,slippage:i,stage:c,receivingAddress:d=""}){const u=c!=="idle"&&c!=="confirming"&&c!=="error"&&c!=="submitted",f=c==="submitted",x=c==="error",v=je(l.min_amount_out,s.token_decimals),{calculateUsdValue:w}=xt({symbol:r.token_symbol,enabled:e}),{calculateUsdValue:m}=xt({symbol:s.token_symbol,enabled:e}),y=w(a),g=m(v),k=b=>{!b&&!u&&t()},N=f?"Swap Complete":x?"Swap Failed":"Review Swap";return o.jsxs(tn,{open:e,onOpenChange:k,title:N,showCloseButton:!u,className:"w-full max-w-md",children:[o.jsxs(hl,{className:"space-y-3",children:[o.jsx(ac,{fromToken:r,toToken:s,fromAmount:a,toAmount:v,fromUsdValue:y,toUsdValue:g}),o.jsx(ic,{minReceived:`${v} ${s.token_symbol}`,estimatedTime:"~10 minutes",slippage:`${i}%`}),d&&o.jsx("div",{className:"bg-[var(--optimex-surface)] rounded-xl px-2 border border-white/5",children:o.jsx(is,{icon:Zn,label:"Receiving Address",address:d})})]}),o.jsx(xl,{children:o.jsx(ea,{state:u?"processing":f?"success":x?"error":"idle",onConfirm:f?t:n,confirmText:"Confirm Swap"})})]})}function uc({swap:e}){const{tokens:t,modals:n,tokenSelect:r,actions:s,input:a,quote:l,execution:i}=e;return o.jsxs(o.Fragment,{children:[o.jsx(sc,{isOpen:n.tokenSelect.isOpen,onClose:n.tokenSelect.close,onSelect:s.selectToken,tokensData:t.data,isLoading:!1,selectedToken:r.type==="from"?t.from:t.to,disabledTokenId:r.type==="from"?t.to?.token_id:t.from?.token_id,tokens:r.type==="to"?t.availableTo:t.all,emptyMessage:r.type==="to"?"No available pairs for selected source token":void 0,title:r.type==="from"?"Select Source Token":"Select Destination Token"}),l.data&&t.from&&t.to&&o.jsx(dc,{isOpen:n.confirm.isOpen,onClose:s.closeConfirmModal,onConfirm:s.confirmSwap,fromToken:t.from,toToken:t.to,amountIn:a.amount,quote:l.data,slippage:a.slippage,stage:i.stage,txHash:i.txHash,error:i.error,receivingAddress:e.addresses.receiving})]})}function on({status:e}){const t={pending:{icon:Yn,text:"Processing",bgClass:"bg-yellow-500/10",textClass:"text-yellow-500",animate:!0},success:{icon:Yt,text:"Completed",bgClass:"bg-green-500/10",textClass:"text-green-500",animate:!1},failed:{icon:Ko,text:"Failed",bgClass:"bg-red-500/10",textClass:"text-red-500",animate:!1}},{icon:n,text:r,bgClass:s,textClass:a,animate:l}=t[e];return o.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${s}`,children:[o.jsx(n,{className:`w-4 h-4 ${a} ${l?"animate-spin":""}`}),o.jsx("span",{className:`text-xs font-medium ${a}`,children:r})]})}function fc({onClose:e}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-[var(--optimex-border)] rounded-xl p-4 mt-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)] font-medium",children:"Recent Trade"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(on,{status:"pending"}),e&&o.jsx("button",{onClick:e,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ae,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]})]}),o.jsx("div",{className:"flex items-center px-3",children:o.jsx("svg",{className:"w-5 h-5 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"})]})]})]})}function mc({trade:e,status:t,isLoading:n,onClose:r}){if(n||!e)return o.jsx(fc,{onClose:r});const s=e.from_token,a=e.to_token,l=je(e.amount_in,s.token_decimals),i=je(e.min_amount_out,a.token_decimals);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-[var(--optimex-border)] rounded-xl p-4 mt-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)] font-medium",children:"Recent Trade"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(on,{status:t}),r&&o.jsx("button",{onClick:r,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ae,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Le,{token:s,size:"sm",showNetworkBadge:!1}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:l}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:s.token_symbol})]})]}),o.jsx("div",{className:"flex items-center px-3",children:o.jsx("svg",{className:"w-5 h-5 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:i}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:a.token_symbol})]}),o.jsx(Le,{token:a,size:"sm",showNetworkBadge:!1})]})]})]})}const pc=1e4;function hc({apiBaseUrl:e,walletAddresses:t,enabled:n=!0,limit:r=20}){const{data:s,isLoading:a,isError:l,refetch:i}=ke.useQuery({queryKey:["trades",t,r],queryFn:async()=>Ve(e).listTrades({from_user_address:t,limit:r}),enabled:n&&!!t?.length,refetchInterval:pc,retry:2,retryDelay:2e3});return{trades:s??[],isLoading:a,isError:l,refetch:i}}function xc(e){if(!e)return"pending";switch(e.toLowerCase()){case"success":case"completed":return"success";case"failed":case"refunded":case"expired":return"failed";default:return"pending"}}function gc({trade:e}){const t=e.from_token,n=e.to_token,r=xc(e.state),s=je(e.amount_in,t.token_decimals),a=je(e.min_amount_out,n.token_decimals);return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-[var(--optimex-border)]",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Le,{token:t,size:"sm",showNetworkBadge:!1}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:s}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:t.token_symbol})]})]}),o.jsx("div",{className:"flex items-center px-2",children:o.jsx("svg",{className:"w-4 h-4 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end",children:[o.jsx("span",{className:"text-sm font-semibold text-[var(--optimex-text)]",children:a}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",children:n.token_symbol})]}),o.jsx(Le,{token:n,size:"sm",showNetworkBadge:!1})]}),o.jsx("div",{className:"ml-3",children:o.jsx(on,{status:r})})]})}function Bt(){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-[var(--optimex-border)]",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-14 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-8 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]})]}),o.jsx("div",{className:"w-4 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex flex-col items-end gap-1",children:[o.jsx("div",{className:"w-14 h-4 bg-[var(--optimex-border)] rounded animate-pulse"}),o.jsx("div",{className:"w-8 h-3 bg-[var(--optimex-border)] rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--optimex-border)] animate-pulse"})]}),o.jsx("div",{className:"ml-3 w-20 h-6 bg-[var(--optimex-border)] rounded-full animate-pulse"})]})}function vc(){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx("div",{className:"w-16 h-16 mb-4 rounded-full bg-[var(--optimex-surface)] flex items-center justify-center",children:o.jsx("svg",{className:"w-8 h-8 text-[var(--optimex-text-secondary)]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})}),o.jsx("p",{className:"text-sm text-[var(--optimex-text-secondary)]",children:"No trade history yet"})]})}function wc({open:e,onOpenChange:t,evmAddress:n,btcAddress:r,solanaAddress:s}){const a=Je(),l=[n,r,s].filter(d=>!!d),{trades:i,isLoading:c}=hc({apiBaseUrl:a.apiBaseUrl,walletAddresses:l.length>0?l:void 0,enabled:e&&l.length>0});return o.jsx(tn,{open:e,onOpenChange:t,title:"Trade History",className:"w-full max-w-md",children:o.jsxs("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[c?o.jsxs(o.Fragment,{children:[o.jsx(Bt,{}),o.jsx(Bt,{}),o.jsx(Bt,{})]}):i.length===0?o.jsx(vc,{}):i.map(d=>o.jsx(gc,{trade:d},d.trade_id)),!c&&i.length>0&&o.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2 text-xs text-[var(--optimex-text-secondary)]",children:[o.jsx(Yn,{className:"w-3 h-3 animate-spin"}),o.jsx("span",{children:"Auto-refreshing"})]})]})})}function bc(e,t){return p.useMemo(()=>{const n=e.trim();if(!t||!n)return{isValid:!n,error:void 0};const r=Kt(n,t.network_type,t.network_id);return{isValid:r.isValid,error:r.isValid?void 0:r.error}},[e,t])}function yc(){const[e,t]=p.useState(null),[n,r]=p.useState(!1),[s,a]=p.useState(!1),l=p.useCallback(()=>t("from"),[]),i=p.useCallback(()=>t("to"),[]),c=p.useCallback(()=>t(null),[]),d=p.useCallback(()=>r(!0),[]),u=p.useCallback(()=>r(!1),[]),f=p.useCallback(()=>a(v=>!v),[]),x=p.useCallback(()=>a(!1),[]);return{tokenSelect:{isOpen:e!==null,type:e,openFrom:l,openTo:i,close:c},confirm:{isOpen:n,open:d,close:u},settings:{isOpen:s,toggle:f,close:x}}}function Cc({fromToken:e,toToken:t,amount:n,fromUserAddress:r,toUserAddress:s,userRefundPubkey:a,slippage:l,config:i}){return p.useMemo(()=>{const c=s.trim(),d=i.affiliateAddress&&i.affiliateFee?[{provider:i.affiliateProvider??"optimex-widget",rate:String(i.affiliateFee),receiver:i.affiliateAddress,network:"ethereum"}]:void 0,u=Math.round(l*100);return{from_token:e,to_token:t,amount:n,from_user_address:r,to_user_address:c||null,user_refund_pubkey:a,slippage:String(u),affiliate_fee_bps:i.affiliateFee?String(i.affiliateFee):void 0,affiliate_info:d,trade_timeout:i.tradeTimeout,script_timeout:i.scriptTimeout}},[e,t,n,r,s,a,l,i.affiliateFee,i.affiliateAddress,i.affiliateProvider,i.tradeTimeout,i.scriptTimeout])}function kc(e,t){return p.useMemo(()=>{if(!e||!t)return{walletAccount:void 0,evmWalletAccount:void 0};switch(e.network_type){case Y.EVM:return{walletAccount:t.evm,evmWalletAccount:t.evm};case Y.BTC:return{walletAccount:t.btc,evmWalletAccount:void 0};case Y.SOLANA:return{walletAccount:t.solana,evmWalletAccount:void 0};default:return{walletAccount:void 0,evmWalletAccount:void 0}}},[e,t])}const Bn={BTC:1,EVM:2,Solana:3};function jc(e){const{tokens:t,pairs:n,selectedFromToken:r}=e,s=p.useMemo(()=>{const v=new Map;if(!n)return v;for(const w of n){if(!w.is_active)continue;const m=v.get(w.from_token_id);m?m.add(w.to_token_id):v.set(w.from_token_id,new Set([w.to_token_id]))}return v},[n]),a=p.useMemo(()=>t??[],[t]),l=p.useMemo(()=>{const v=new Set;for(const w of a){const m=s.get(w.token_id);(!m||m.size===0)&&v.add(w.token_id)}return v},[a,s]),i=p.useMemo(()=>{if(!r)return[];const v=s.get(r.token_id);return!v||v.size===0?[]:a.filter(w=>v.has(w.token_id))},[r,s,a]),c=p.useCallback((v,w)=>s.get(v)?.has(w)??!1,[s]),d=p.useCallback(v=>(s.get(v)?.size??0)>0,[s]),u=p.useCallback(v=>[...v].sort((w,m)=>{const y=Bn[w.network_type]??99,g=Bn[m.network_type]??99;return y-g}),[]),f=p.useCallback(v=>{const w=s.get(v.token_id);if(!w||w.size===0)return null;const m=a.filter(g=>w.has(g.token_id));return m.length===0?null:u(m)[0]??null},[s,a,u]),x=p.useCallback(()=>{if(a.length===0)return null;const v=u(a);for(const w of v){const m=f(w);if(m)return{fromToken:w,toToken:m}}return null},[a,u,f]);return{allTokens:a,tokensWithoutPairs:l,availableToTokens:i,isPairValid:c,findBestToToken:f,hasValidPairs:d,getDefaultPair:x}}function Nc(e){if(!e.chain_id||e.network_type!=="EVM")return;const t=parseInt(e.chain_id,10);return isNaN(t)?void 0:t}async function Sc(e,t){const n=Nc(t);if(!n)throw new Error(`Cannot determine chain ID for token: ${t.token_id}`);return await e.getChainId()===n?!1:(await e.switchChain(n),!0)}const Ec="0xdd62ed3e",Tc="0x095ea7b3",_c="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";function Gt(e){return e.toLowerCase().replace("0x","").padStart(64,"0")}function Rc(e){return e.toString(16).padStart(64,"0")}function Ac(e){const t=e.startsWith("0x")?e.slice(2):e;return!t||t===""?0n:BigInt("0x"+t)}async function Mc(e,t,n,r){const s=bt(e),a=Ec+Gt(n)+Gt(r),i=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_call",params:[{to:t,data:a},"latest"]})})).json();if(i.error)throw new Error(`Failed to check allowance: ${i.error.message}`);return Ac(i.result)}function Lc(e,t){const n=t?Rc(t):_c.slice(2);return`${Tc}${Gt(e)}${n}`}async function Pc(e,t,n,r){const s=Lc(n,r);return await e.sendTransaction({to:t,data:s})}async function Oc(e,t,n=60,r=2e3){const s=bt(e);for(let a=0;a<n;a++){const i=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_getTransactionReceipt",params:[t]})})).json();if(i.error)throw new Error(`RPC error: ${i.error.message}`);if(i.result){const c=i.result;return{status:c.status==="0x1"?"success":"reverted",blockNumber:c.blockNumber,transactionHash:c.transactionHash}}await new Promise(c=>setTimeout(c,r))}throw new Error(`Transaction ${t} not confirmed after ${n} attempts`)}function Ic(e){return e?"getChainId"in e&&"switchChain"in e&&typeof e.getChainId=="function"&&typeof e.switchChain=="function":!1}function Dc({apiBaseUrl:e,onWalletTx:t,onSubmitTx:n,onError:r}){const[s,a]=p.useState({stage:"idle",txHash:null,tradeId:null,error:null}),l=p.useCallback(()=>{a({stage:"idle",txHash:null,tradeId:null,error:null})},[]),i=p.useCallback((u,f,x)=>{a(v=>({...v,stage:"error",error:u})),r?.({error:u,stage:f,trade_id:x})},[r]),c=p.useCallback(async(u,f,x,v)=>{const w=x.deposit_address;if(!w)throw new Error("Missing deposit address for EVM transaction");a(k=>({...k,stage:"switching_chain"})),await Sc(u,f);const m=rn(f);if(!m&&f.token_address&&(a(N=>({...N,stage:"checking_allowance"})),await Mc(f.network_id,f.token_address,u.address,w)<v)){a(A=>({...A,stage:"approving"}));const N=await Pc(u,f.token_address,w,v);if((await Oc(f.network_id,N)).status==="reverted")throw new Error("Token approval transaction reverted")}a(k=>({...k,stage:"broadcasting"}));const y={to:w,value:m?v:0n,data:x.payload?x.payload:void 0};return await u.sendTransaction(y)},[]),d=p.useCallback(async({quote:u,fromToken:f,toToken:x,amountIn:v,walletAccount:w,evmWalletAccount:m})=>{const y=Ve(e);try{a({stage:"confirming",txHash:null,tradeId:u.trade_id,error:null});const g=m||w;if(!g)throw new Error("Wallet not available");a(b=>({...b,stage:"signing"}));let k;const N=qn(v,f.token_decimals);if(f.network_type===Y.EVM){const b=m||(Ic(w)?w:null);if(b)k=await c(b,f,u,N);else{const A=u.deposit_address,I=u.payload?u.payload:void 0;if(!A)throw new Error("Missing deposit address for EVM transaction");a(C=>({...C,stage:"broadcasting"}));const j={to:A,value:N,data:I};k=await g.sendTransaction(j)}}else if(f.network_type===Y.BTC){if(!u.deposit_address)throw new Error("Missing deposit address for BTC transaction");a(b=>({...b,stage:"broadcasting"})),k=await g.sendTransaction({toAddress:u.deposit_address,amount:N})}else if(f.network_type===Y.SOLANA){if(!u.payload)throw new Error("Missing payload for Solana transaction");a(b=>({...b,stage:"broadcasting"})),k=await g.sendTransaction(u.payload)}else throw new Error(`Unsupported network type: ${f.network_type}`);t?.({trade_id:u.trade_id,tx_hash:k,from_token:f,to_token:x,amount_in:v}),a(b=>({...b,txHash:k,stage:"submitting"}));try{await y.submitTransaction(u.trade_id,k),n?.({trade_id:u.trade_id,tx_hash:k,status:"success"})}catch(b){throw n?.({trade_id:u.trade_id,tx_hash:k,status:"error",error:b.message}),b}return a(b=>({...b,stage:"submitted"})),{tradeId:u.trade_id,txHash:k}}catch(g){const k=s.stage==="approving"?"approval":"wallet_tx";throw i(g,k,u.trade_id),g}},[e,t,n,i,c,s.stage]);return{...s,executeSwap:d,resetState:l,isExecuting:s.stage!=="idle"&&s.stage!=="submitted"&&s.stage!=="error"}}function $c({defaultPair:e,isPairValid:t,findBestToToken:n,hasValidPairs:r,defaultSlippage:s=.75,selectingToken:a=null}){const[l,i]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(""),[x,v]=p.useState(""),[w,m]=p.useState(s),y=l??e?.fromToken??null,g=c??e?.toToken??null,k=p.useCallback(()=>{y&&g&&t(g.token_id,y.token_id)&&(i(g),d(y),f(""))},[y,g,t]),N=p.useCallback(b=>{if(a==="from"){if(!r(b.token_id))return!1;if(b.token_id===g?.token_id)d(y);else if(g&&!t(b.token_id,g.token_id)){const A=n(b);d(A)}return i(b),!0}else if(a==="to")return b.token_id===y?.token_id&&i(g),d(b),!0;return!1},[a,y,g,t,n,r]);return{fromToken:y,toToken:g,handleTokenSelect:N,handleSwapDirection:k,amount:u,setAmount:f,receivingAddress:x,setReceivingAddress:v,slippage:w,setSlippage:m}}function Fc({fromToken:e,toToken:t}){const n=Ue();return p.useMemo(()=>{const r=n.evmAddress,s=n.btcAddress,a=n.btcPublicKey;let l=null,i=null;return e?.network_type===Y.EVM?(l=r,i=r):e?.network_type===Y.BTC&&(l=s,i=a),{fromUserAddress:l,userRefundPubkey:i}},[n.evmAddress,n.btcAddress,n.btcPublicKey,e,t])}function Bc({fromToken:e,toToken:t,amount:n,quote:r,isLoadingQuote:s,isFetchingQuote:a,receivingAddress:l,onConnectWallet:i,onSwap:c}){const d=Ue();return p.useMemo(()=>{if(!Zl(d,e?.network_type)){const x=Ql(e?.network_type);return{text:x?`Connect ${x} Wallet`:"Connect Wallet",disabled:!1,action:i}}return!e||!t?{text:"Select Tokens",disabled:!0,action:void 0}:!n||parseFloat(n)<=0?{text:"Enter Amount",disabled:!0,action:void 0}:l.trim()?Kt(l,t.network_type,t.network_id).isValid?s||a?{text:"Getting Quote...",disabled:!0,action:void 0}:r?{text:"Review",disabled:!1,action:c}:{text:"Unable to Quote",disabled:!0,action:void 0}:{text:"Enter Receiving Address",disabled:!0,action:void 0}:{text:"Enter Receiving Address",disabled:!0,action:void 0}},[d.isEvmConnected,d.isBtcConnected,d.isSolanaConnected,e,t,n,s,a,r,i,c,l])}function zc({tokens:e,defaultFromToken:t,defaultToToken:n,isPairValid:r}){return p.useMemo(()=>{if(!t||!n||!e)return null;const s=e.find(l=>l.token_id===t),a=e.find(l=>l.token_id===n);return!s||!a?null:r(s.token_id,a.token_id)?{fromToken:s,toToken:a}:null},[e,t,n,r])}function Vc(){const e=Ue(),t=Je(),n=yc(),{tokensData:r}=El(),s=r.tokens,a=r.pairs,{allTokens:l,tokensWithoutPairs:i,isPairValid:c,findBestToToken:d,hasValidPairs:u,getDefaultPair:f}=jc({tokens:s,pairs:a,selectedFromToken:null}),v=zc({tokens:s,defaultFromToken:t.defaultFromToken,defaultToToken:t.defaultToToken,isPairValid:c})??f(),{fromToken:w,toToken:m,handleTokenSelect:y,handleSwapDirection:g,amount:k,setAmount:N,receivingAddress:b,setReceivingAddress:A,slippage:I,setSlippage:j}=$c({defaultPair:v,isPairValid:c,findBestToToken:d,hasValidPairs:u,defaultSlippage:t.defaultSlippage,selectingToken:n.tokenSelect.type}),C=p.useMemo(()=>w?l.filter($=>c(w.token_id,$.token_id)):[],[w,l,c]),R=bc(b,m),{fromUserAddress:B,userRefundPubkey:L}=Fc({fromToken:w,toToken:m}),D=Cc({fromToken:w,toToken:m,amount:k,fromUserAddress:B,toUserAddress:b,userRefundPubkey:L,slippage:I,config:{affiliateFee:t.affiliateFee,affiliateAddress:t.affiliateAddress,affiliateProvider:t.affiliateProvider,tradeTimeout:t.tradeTimeout,scriptTimeout:t.scriptTimeout}}),_=!!w&&!!m&&parseFloat(k)>0&&!!b.trim()&&!n.confirm.isOpen,{data:V,isLoading:W,isFetching:G,refetch:H}=Ho(t.apiBaseUrl,{...D,enabled:_,onQuote:t.callbacks?.onQuote}),S=Dc({apiBaseUrl:t.apiBaseUrl,onWalletTx:t.callbacks?.onWalletTx,onSubmitTx:t.callbacks?.onSubmitTx,onError:t.callbacks?.onError}),{walletAccount:ne,evmWalletAccount:oe}=kc(w,e.externalWalletClient??void 0),Ne=p.useCallback(()=>{e.isExternalWallet?e.onRequestWallet?.(w?.network_id??""):e.openConnectModal?.()},[e,w?.network_id]),ue=p.useCallback(()=>{!V||!w||!m||n.confirm.open()},[V,w,m,n.confirm]),U=p.useCallback(($=!1)=>{S.isExecuting||(n.confirm.close(),$||S.resetState())},[S,n.confirm]),Q=p.useCallback(async()=>{if(!(!V||!w||!m))try{await S.executeSwap({quote:V,fromToken:w,toToken:m,amountIn:k,walletAccount:ne,evmWalletAccount:oe}),U(!0),N("")}catch($){console.error("Swap failed:",$)}},[V,w,m,k,ne,oe,S,U,N]),ie=p.useCallback($=>{y($)&&n.tokenSelect.close()},[y,n.tokenSelect]),he=Bc({fromToken:w,toToken:m,amount:k,quote:V,isLoadingQuote:W,isFetchingQuote:G,receivingAddress:b,onConnectWallet:Ne,onSwap:ue});return{tokens:{from:w,to:m,all:l,availableTo:C,withoutPairs:i,data:r},input:{amount:k,setAmount:N,receivingAddress:b,setReceivingAddress:A,slippage:I,setSlippage:j},quote:{data:V,isLoading:W,isFetching:G,refetch:H},validation:{address:R},buttonState:he,modals:n,tokenSelect:{type:n.tokenSelect.type},actions:{selectToken:ie,swapDirection:g,connectWallet:Ne,openSwapConfirm:ue,closeConfirmModal:U,confirmSwap:Q},execution:{stage:S.stage,txHash:S.txHash,tradeId:S.tradeId,error:S.error,isExecuting:S.isExecuting},wallet:e,addresses:{sending:B,receiving:b}}}const Wc=5e3;function zn(e){if(!e)return"pending";switch(e.toLowerCase()){case"success":case"completed":return"success";case"failed":case"refunded":case"expired":return"failed";default:return"pending"}}function Hc({apiBaseUrl:e,tradeId:t}){const{data:n,isLoading:r}=ke.useQuery({queryKey:["trade",t],queryFn:async()=>Ve(e).getTrade(t),enabled:!!t,refetchInterval:s=>{const a=s.state.data;return a&&zn(a.state)==="success"?!1:Wc},retry:!0,retryDelay:2e3});return{trade:n??null,status:zn(n?.state),isLoading:r}}function po(){const e=Vc(),t=Je(),{tokens:n,input:r,quote:s,modals:a,buttonState:l,validation:i,actions:c,addresses:d,wallet:u,execution:f}=e,[x,v]=p.useState(!1),{trade:w,status:m,isLoading:y}=Hc({apiBaseUrl:t.apiBaseUrl,tradeId:f.tradeId}),{formattedBalance:g}=mo({token:n.from,walletAddress:d.sending,enabled:!!n.from&&!!d.sending,polling:!0}),{calculateUsdValue:k}=xt({symbol:n.from?.token_symbol,enabled:!!n.from}),{calculateUsdValue:N}=xt({symbol:n.to?.token_symbol,enabled:!!n.to}),b=u.isConnected,A=k(r.amount),I=s.data?N(je(s.data.min_amount_out,n.to?.token_decimals||18)):"$0.00";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-4 w-full min-w-0",children:[o.jsx(Al,{slippage:r.slippage,onSlippageChange:r.setSlippage,isSettingsOpen:a.settings.isOpen,onSettingsToggle:a.settings.toggle,onHistoryClick:()=>v(!0),hideHistory:t.hideHistory||!u.isConnected}),o.jsxs(nn,{children:[o.jsxs("div",{className:"space-y-2 relative",children:[o.jsx($n,{token:n.from,value:r.amount,onChange:r.setAmount,onSelectToken:a.tokenSelect.openFrom,balance:g,isWalletConnected:b,usdValue:A}),o.jsx(co,{onClick:c.swapDirection}),o.jsx($n,{token:n.to,value:s.data?je(s.data.min_amount_out,n.to?.token_decimals||18):"",readOnly:!0,onSelectToken:a.tokenSelect.openTo,isOutput:!0,usdValue:I})]}),o.jsx("div",{className:"mt-4",children:o.jsx(Tl,{token:n.to,value:r.receivingAddress,onChange:r.setReceivingAddress,error:i.address.error})}),o.jsx("div",{className:"mt-4",children:o.jsx(Ll,{text:l.text,disabled:l.disabled,onClick:l.action})}),s.data&&n.from&&n.to&&o.jsx("div",{className:"mt-4",children:o.jsx(Ml,{quote:s.data,fromToken:n.from,toToken:n.to,amount:r.amount,slippage:r.slippage,isFetching:s.isFetching,onRefresh:s.refetch})}),o.jsx("div",{className:"mt-4",children:o.jsx(Pl,{})}),f.tradeId&&o.jsx("div",{className:"mt-4",children:o.jsx(mc,{trade:w,status:m,isLoading:y})})]})]}),o.jsx(uc,{swap:e}),x&&o.jsx(wc,{open:x,onOpenChange:v,evmAddress:u.evmAddress??void 0,btcAddress:u.btcAddress??void 0,solanaAddress:u.solanaAddress??void 0})]})}function Uc({className:e,connectLabel:t="Connect Wallet",showNetworkBadge:n=!0,onClick:r}){const s=Ue(),a=s.evmAddress||s.btcAddress||s.solanaAddress,l=()=>{if(r){r();return}s.isExternalWallet?s.onRequestWallet?.():s.openConnectModal?.()},i=()=>n?s.isEvmConnected?o.jsx("span",{className:"rounded bg-blue-500/20 px-1.5 py-0.5 text-xs text-blue-400",children:"EVM"}):s.isBtcConnected?o.jsx("span",{className:"rounded bg-orange-500/20 px-1.5 py-0.5 text-xs text-orange-400",children:"BTC"}):s.isSolanaConnected?o.jsx("span",{className:"rounded bg-purple-500/20 px-1.5 py-0.5 text-xs text-purple-400",children:"SOL"}):null:null;return s.isConnected?o.jsxs("div",{className:`flex items-center gap-2 ${e||""}`,children:[i(),o.jsxs("button",{onClick:l,className:"group flex items-center gap-1.5 rounded-[0.25rem] bg-[var(--optimex-surface-hover)] px-3 py-1.5 text-sm text-[var(--optimex-text)] transition-colors hover:bg-[rgba(239,68,68,0.2)]",children:[o.jsx("span",{children:Do(a)}),o.jsx(Qo,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})]}):o.jsx("button",{onClick:l,className:`rounded-[0.25rem] bg-[var(--optimex-primary)] px-4 py-1.5 text-sm font-medium text-white transition-colors hover:bg-[var(--optimex-primary-hover)] ${e||""}`,children:t})}function qc({apiBaseUrl:e,walletClient:t,onRequestWallet:n,theme:r,defaultFromToken:s,defaultToToken:a,affiliateFee:l,affiliateAddress:i,affiliateProvider:c,tradeTimeout:d,scriptTimeout:u,defaultSlippage:f=.75,hideHistory:x=!1,children:v,renderLoading:w,renderError:m,queryClient:y,onQuote:g,onWalletTx:k,onSubmitTx:N,onSwapComplete:b,onError:A}){Mo(e);const I=p.useMemo(()=>y??new ke.QueryClient,[y]),C={apiBaseUrl:e,defaultSlippage:f,affiliateFee:l,affiliateAddress:i,affiliateProvider:c,tradeTimeout:d,scriptTimeout:u,defaultFromToken:s,defaultToToken:a,hideHistory:x,callbacks:{onQuote:g,onWalletTx:k,onSubmitTx:N,onSwapComplete:b,onError:A},renderLoading:w,renderError:m},R=v??o.jsx(po,{});return o.jsx("div",{className:"optx-widget",children:o.jsx(ke.QueryClientProvider,{client:I,children:o.jsx(Uo,{value:C,children:o.jsx(Ro,{theme:r,children:o.jsx(Ao,{externalWalletClient:t,onRequestWallet:n,children:o.jsx(Sl,{children:R})})})})})})}exports.ConnectButton=Uc;exports.SwapCard=po;exports.SwapWidget=qc;exports.useWallet=Ue;