otx-swap 1.2.36 → 1.2.37
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 +3 -3
- package/dist/index.mjs +294 -294
- package/package.json +1 -1
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('.optx-widget .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.optx-widget .fixed{position:fixed}.optx-widget .absolute{position:absolute}.optx-widget .relative{position:relative}.optx-widget .inset-0{inset:0}.optx-widget .inset-2{inset:.5rem}.optx-widget .inset-x-0{left:0;right:0}.optx-widget .-bottom-1{bottom:-.25rem}.optx-widget .-bottom-2{bottom:-.5rem}.optx-widget .-right-1{right:-.25rem}.optx-widget .-top-2{top:-.5rem}.optx-widget .bottom-0{bottom:0}.optx-widget .bottom-full{bottom:100%}.optx-widget .left-0{left:0}.optx-widget .left-1\\/2{left:50%}.optx-widget .left-3{left:.75rem}.optx-widget .left-4{left:1rem}.optx-widget .right-0{right:0}.optx-widget .right-3{right:.75rem}.optx-widget .right-4{right:1rem}.optx-widget .top-1\\/2{top:50%}.optx-widget .top-full{top:100%}.optx-widget .z-10{z-index:10}.optx-widget .z-50{z-index:50}.optx-widget .\\!m-0{margin:0!important}.optx-widget .-my-4{margin-top:-1rem;margin-bottom:-1rem}.optx-widget .mx-auto{margin-left:auto;margin-right:auto}.optx-widget .mb-1{margin-bottom:.25rem}.optx-widget .mb-2{margin-bottom:.5rem}.optx-widget .mb-3{margin-bottom:.75rem}.optx-widget .mb-4{margin-bottom:1rem}.optx-widget .mb-6{margin-bottom:1.5rem}.optx-widget .ml-2{margin-left:.5rem}.optx-widget .ml-3{margin-left:.75rem}.optx-widget .ml-auto{margin-left:auto}.optx-widget .mt-1{margin-top:.25rem}.optx-widget .mt-2{margin-top:.5rem}.optx-widget .mt-24{margin-top:6rem}.optx-widget .mt-3{margin-top:.75rem}.optx-widget .mt-4{margin-top:1rem}.optx-widget .mt-auto{margin-top:auto}.optx-widget .block{display:block}.optx-widget .inline-block{display:inline-block}.optx-widget .inline{display:inline}.optx-widget .flex{display:flex}.optx-widget .size-10{width:2.5rem;height:2.5rem}.optx-widget .size-12{width:3rem;height:3rem}.optx-widget .size-2{width:.5rem;height:.5rem}.optx-widget .size-20{width:5rem;height:5rem}.optx-widget .size-3{width:.75rem;height:.75rem}.optx-widget .size-4{width:1rem;height:1rem}.optx-widget .size-5{width:1.25rem;height:1.25rem}.optx-widget .size-8{width:2rem;height:2rem}.optx-widget .h-1\\.5{height:.375rem}.optx-widget .h-10{height:2.5rem}.optx-widget .h-12{height:3rem}.optx-widget .h-14{height:3.5rem}.optx-widget .h-16{height:4rem}.optx-widget .h-2{height:.5rem}.optx-widget .h-3{height:.75rem}.optx-widget .h-3\\.5{height:.875rem}.optx-widget .h-4{height:1rem}.optx-widget .h-5{height:1.25rem}.optx-widget .h-6{height:1.5rem}.optx-widget .h-8{height:2rem}.optx-widget .h-auto{height:auto}.optx-widget .h-full{height:100%}.optx-widget .max-h-\\[2\\.5rem\\]{max-height:2.5rem}.optx-widget .max-h-\\[2rem\\]{max-height:2rem}.optx-widget .max-h-\\[3rem\\]{max-height:3rem}.optx-widget .max-h-\\[5rem\\]{max-height:5rem}.optx-widget .max-h-\\[60vh\\]{max-height:60vh}.optx-widget .max-h-\\[96vh\\]{max-height:96vh}.optx-widget .min-h-0{min-height:0px}.optx-widget .w-1\\/3{width:33.333333%}.optx-widget .w-10{width:2.5rem}.optx-widget .w-12{width:3rem}.optx-widget .w-14{width:3.5rem}.optx-widget .w-16{width:4rem}.optx-widget .w-20{width:5rem}.optx-widget .w-24{width:6rem}.optx-widget .w-28{width:7rem}.optx-widget .w-3{width:.75rem}.optx-widget .w-3\\.5{width:.875rem}.optx-widget .w-32{width:8rem}.optx-widget .w-4{width:1rem}.optx-widget .w-48{width:12rem}.optx-widget .w-5{width:1.25rem}.optx-widget .w-6{width:1.5rem}.optx-widget .w-72{width:18rem}.optx-widget .w-8{width:2rem}.optx-widget .w-96{width:24rem}.optx-widget .w-\\[32rem\\]{width:32rem}.optx-widget .w-auto{width:auto}.optx-widget .w-full{width:100%}.optx-widget .min-w-0{min-width:0px}.optx-widget .min-w-\\[140px\\]{min-width:140px}.optx-widget .max-w-\\[280px\\]{max-width:280px}.optx-widget .flex-1{flex:1 1 0%}.optx-widget .flex-shrink-0,.optx-widget .shrink-0{flex-shrink:0}.optx-widget .-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))}.optx-widget .-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))}.optx-widget .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))}.optx-widget .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))}.optx-widget .transform{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}}.optx-widget .animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.optx-widget .animate-spin{animation:spin 1s linear infinite}.optx-widget .cursor-not-allowed{cursor:not-allowed}.optx-widget .cursor-pointer{cursor:pointer}.optx-widget .resize{resize:both}.optx-widget .flex-col{flex-direction:column}.optx-widget .flex-wrap{flex-wrap:wrap}.optx-widget .items-end{align-items:flex-end}.optx-widget .items-center{align-items:center}.optx-widget .justify-end{justify-content:flex-end}.optx-widget .justify-center{justify-content:center}.optx-widget .justify-between{justify-content:space-between}.optx-widget .gap-0\\.5{gap:.125rem}.optx-widget .gap-1{gap:.25rem}.optx-widget .gap-1\\.5{gap:.375rem}.optx-widget .gap-2{gap:.5rem}.optx-widget .gap-3{gap:.75rem}.optx-widget .gap-4{gap:1rem}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.divide-\\[var\\(--optimex-border\\)\\]>:not([hidden])~:not([hidden])){border-color:var(--optimex-border)}.optx-widget .overflow-auto{overflow:auto}.optx-widget .overflow-hidden{overflow:hidden}.optx-widget .overflow-y-auto{overflow-y:auto}.optx-widget .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.optx-widget .break-all{word-break:break-all}.optx-widget .rounded{border-radius:.25rem}.optx-widget .rounded-2xl{border-radius:1rem}.optx-widget .rounded-\\[0\\.25rem\\]{border-radius:.25rem}.optx-widget .rounded-\\[9999px\\]{border-radius:9999px}.optx-widget .rounded-\\[var\\(--optimex-overlay-radius\\)\\]{border-radius:var(--optimex-overlay-radius)}.optx-widget .rounded-\\[var\\(--optimex-radius-button\\)\\]{border-radius:var(--optimex-radius-button)}.optx-widget .rounded-\\[var\\(--optimex-radius-input\\)\\]{border-radius:var(--optimex-radius-input)}.optx-widget .rounded-\\[var\\(--optimex-radius-widget\\)\\]{border-radius:var(--optimex-radius-widget)}.optx-widget .rounded-full{border-radius:9999px}.optx-widget .rounded-lg{border-radius:.5rem}.optx-widget .rounded-md{border-radius:.375rem}.optx-widget .rounded-xl{border-radius:.75rem}.optx-widget .rounded-t-sm{border-top-left-radius:.125rem;border-top-right-radius:.125rem}.optx-widget .border{border-width:1px}.optx-widget .border-2{border-width:2px}.optx-widget .border-4{border-width:4px}.optx-widget .border-b{border-bottom-width:1px}.optx-widget .border-l{border-left-width:1px}.optx-widget .border-r{border-right-width:1px}.optx-widget .border-t{border-top-width:1px}.optx-widget .border-none{border-style:none}.optx-widget .border-\\[var\\(--optimex-background\\)\\]{border-color:var(--optimex-background)}.optx-widget .border-\\[var\\(--optimex-error\\)\\]{border-color:var(--optimex-error)}.optx-widget .border-\\[var\\(--optimex-primary\\)\\]{border-color:var(--optimex-primary)}.optx-widget .border-\\[var\\(--optimex-surface\\)\\]{border-color:var(--optimex-surface)}.optx-widget .border-current{border-color:currentColor}.optx-widget .border-transparent{border-color:transparent}.optx-widget .border-white\\/10{border-color:#ffffff1a}.optx-widget .border-white\\/5{border-color:#ffffff0d}.optx-widget .border-white\\/\\[0\\.02\\]{border-color:#ffffff05}.optx-widget .border-white\\/\\[0\\.05\\]{border-color:#ffffff0d}.optx-widget .border-t-transparent{border-top-color:transparent}.optx-widget .bg-\\[rgba\\(239\\,68\\,68\\,0\\.15\\)\\]{background-color:#ef444426}.optx-widget .bg-\\[rgba\\(34\\,197\\,94\\,0\\.15\\)\\]{background-color:#22c55e26}.optx-widget .bg-\\[rgba\\(59\\,130\\,246\\,0\\.15\\)\\]{background-color:#3b82f626}.optx-widget .bg-\\[var\\(--optimex-background\\)\\]{background-color:var(--optimex-background)}.optx-widget .bg-\\[var\\(--optimex-border\\)\\]{background-color:var(--optimex-border)}.optx-widget .bg-\\[var\\(--optimex-error\\)\\]{background-color:var(--optimex-error)}.optx-widget .bg-\\[var\\(--optimex-overlay-background\\)\\]{background-color:var(--optimex-overlay-background)}.optx-widget .bg-\\[var\\(--optimex-primary\\)\\]{background-color:var(--optimex-primary)}.optx-widget .bg-\\[var\\(--optimex-surface\\)\\]{background-color:var(--optimex-surface)}.optx-widget .bg-\\[var\\(--optimex-surface-hover\\)\\]{background-color:var(--optimex-surface-hover)}.optx-widget .bg-black\\/60{background-color:#0009}.optx-widget .bg-blue-500\\/20{background-color:#3b82f633}.optx-widget .bg-green-500\\/10{background-color:#22c55e1a}.optx-widget .bg-orange-500\\/20{background-color:#f9731633}.optx-widget .bg-purple-500\\/20{background-color:#a855f733}.optx-widget .bg-red-500\\/10{background-color:#ef44441a}.optx-widget .bg-transparent{background-color:transparent}.optx-widget .bg-white\\/10{background-color:#ffffff1a}.optx-widget .bg-white\\/20{background-color:#fff3}.optx-widget .bg-white\\/5{background-color:#ffffff0d}.optx-widget .bg-white\\/\\[0\\.02\\]{background-color:#ffffff05}.optx-widget .bg-yellow-500\\/10{background-color:#eab3081a}.optx-widget .bg-zinc-900\\/50{background-color:#18181b80}.optx-widget .stroke-\\[var\\(--optimex-error\\)\\]{stroke:var(--optimex-error)}.optx-widget .p-0{padding:0}.optx-widget .p-1{padding:.25rem}.optx-widget .p-1\\.5{padding:.375rem}.optx-widget .p-2{padding:.5rem}.optx-widget .p-3{padding:.75rem}.optx-widget .p-4{padding:1rem}.optx-widget .p-6{padding:1.5rem}.optx-widget .px-1\\.5{padding-left:.375rem;padding-right:.375rem}.optx-widget .px-2{padding-left:.5rem;padding-right:.5rem}.optx-widget .px-2\\.5{padding-left:.625rem;padding-right:.625rem}.optx-widget .px-3{padding-left:.75rem;padding-right:.75rem}.optx-widget .px-4{padding-left:1rem;padding-right:1rem}.optx-widget .px-6{padding-left:1.5rem;padding-right:1.5rem}.optx-widget .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.optx-widget .py-1{padding-top:.25rem;padding-bottom:.25rem}.optx-widget .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.optx-widget .py-12{padding-top:3rem;padding-bottom:3rem}.optx-widget .py-2{padding-top:.5rem;padding-bottom:.5rem}.optx-widget .py-3{padding-top:.75rem;padding-bottom:.75rem}.optx-widget .py-4{padding-top:1rem;padding-bottom:1rem}.optx-widget .py-8{padding-top:2rem;padding-bottom:2rem}.optx-widget .py-\\[6px\\]{padding-top:6px;padding-bottom:6px}.optx-widget .pb-3{padding-bottom:.75rem}.optx-widget .pb-4{padding-bottom:1rem}.optx-widget .pl-10{padding-left:2.5rem}.optx-widget .pr-10{padding-right:2.5rem}.optx-widget .pr-3{padding-right:.75rem}.optx-widget .pt-2{padding-top:.5rem}.optx-widget .pt-3{padding-top:.75rem}.optx-widget .text-left{text-align:left}.optx-widget .text-center{text-align:center}.optx-widget .text-2xl{font-size:1.5rem;line-height:2rem}.optx-widget .text-\\[10px\\]{font-size:10px}.optx-widget .text-base{font-size:1rem;line-height:1.5rem}.optx-widget .text-lg{font-size:1.125rem;line-height:1.75rem}.optx-widget .text-sm{font-size:.875rem;line-height:1.25rem}.optx-widget .text-xl{font-size:1.25rem;line-height:1.75rem}.optx-widget .text-xs{font-size:.75rem;line-height:1rem}.optx-widget .font-bold{font-weight:700}.optx-widget .font-medium{font-weight:500}.optx-widget .font-semibold{font-weight:600}.optx-widget .uppercase{text-transform:uppercase}.optx-widget .lowercase{text-transform:lowercase}.optx-widget .leading-none{line-height:1}.optx-widget .tracking-tight{letter-spacing:-.025em}.optx-widget .tracking-wider{letter-spacing:.05em}.optx-widget .text-\\[var\\(--optimex-error\\)\\]{color:var(--optimex-error)}.optx-widget .text-\\[var\\(--optimex-primary\\)\\]{color:var(--optimex-primary)}.optx-widget .text-\\[var\\(--optimex-success\\)\\]{color:var(--optimex-success)}.optx-widget .text-\\[var\\(--optimex-text\\)\\]{color:var(--optimex-text)}.optx-widget .text-\\[var\\(--optimex-text-secondary\\)\\]{color:var(--optimex-text-secondary)}.optx-widget .text-\\[var\\(--optimex-warning\\)\\]{color:var(--optimex-warning)}.optx-widget .text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.optx-widget .text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.optx-widget .text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.optx-widget .text-orange-400{--tw-text-opacity: 1;color:rgb(251 146 60 / var(--tw-text-opacity, 1))}.optx-widget .text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.optx-widget .text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.optx-widget .text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.optx-widget .text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.optx-widget .text-zinc-400{--tw-text-opacity: 1;color:rgb(161 161 170 / var(--tw-text-opacity, 1))}.optx-widget .text-zinc-500{--tw-text-opacity: 1;color:rgb(113 113 122 / var(--tw-text-opacity, 1))}.optx-widget .opacity-0{opacity:0}.optx-widget .opacity-50{opacity:.5}.optx-widget .opacity-70{opacity:.7}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .outline-none{outline:2px solid transparent;outline-offset:2px}.optx-widget .blur{--tw-blur: blur(8px);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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .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}.optx-widget .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .duration-200{transition-duration:.2s}.optx-widget .duration-300{transition-duration:.3s}.optx-widget{--optimex-primary: #ed6300;--optimex-background: hsla(0, 0%, 100%, .04);--optimex-surface: hsla(0, 0%, 0%, .2);--optimex-text: #ffffff;--optimex-text-secondary: hsla(0, 0%, 100%, .48);--optimex-error: #ff4d4f;--optimex-success: #52c41a;--optimex-overlay-background: #343b47;--optimex-overlay-radius: .75rem;--optimex-radius-widget: 1rem;--optimex-radius-input: .75rem;--optimex-radius-button: .5rem;--optimex-font-family: "Inter", sans-serif;isolation:isolate;width:100%;min-width:0;max-width:100%;--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: ;font-family:var(--optimex-font-family);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 .widget-container{background:var(--optimex-background);border:1px solid rgba(255,255,255,.05);border-radius:var(--optimex-radius-widget);-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;-webkit-appearance:none;-moz-appearance:none;appearance:none}.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}.optx-widget .glow-orange{box-shadow:inset 0 0 15px #eb620026,0 0 20px #eb62001a}.optx-widget .glow-green{box-shadow:0 0 12px #22c55e33}.optx-widget .glow-red{box-shadow:0 0 12px #ef444433}@keyframes optx-status-pulse{0%,to{opacity:1}50%{opacity:.5}}.optx-widget .status-pulse{animation:optx-status-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes modal-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes modal-overlay-out{0%{opacity:1}to{opacity:0}}@keyframes modal-content-in{0%{opacity:0;transform:translate(-50%,-46%)}to{opacity:1;transform:translate(-50%,-50%)}}@keyframes modal-content-out{0%{opacity:1;transform:translate(-50%,-50%)}to{opacity:0;transform:translate(-50%,-46%)}}.animate-modal-overlay-in{animation:modal-overlay-in .25s cubic-bezier(.16,1,.3,1)}.animate-modal-overlay-out{animation:modal-overlay-out .2s cubic-bezier(.16,1,.3,1)}.animate-modal-in{animation:modal-content-in .3s cubic-bezier(.16,1,.3,1)}.animate-modal-out{animation:modal-content-out .2s cubic-bezier(.16,1,.3,1)}@keyframes optx-shiny-text{0%{background-position:-200% center}to{background-position:200% center}}.optx-widget .shiny-text{background:linear-gradient(90deg,var(--optimex-text-secondary) 0%,var(--optimex-text-secondary) 40%,var(--optimex-text) 50%,var(--optimex-text-secondary) 60%,var(--optimex-text-secondary) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:optx-shiny-text 2s linear infinite}.optx-widget .collapsible-grid{display:grid;transition:grid-template-rows .2s ease-out}.optx-widget .collapsible-grid[data-state=closed]{grid-template-rows:0fr}.optx-widget .collapsible-grid[data-state=open]{grid-template-rows:1fr}.optx-widget .collapsible-content{overflow:hidden}.optx-widget .placeholder\\:text-\\[var\\(--optimex-text-secondary\\)\\]::-moz-placeholder{color:var(--optimex-text-secondary)}.optx-widget .placeholder\\:text-\\[var\\(--optimex-text-secondary\\)\\]::placeholder{color:var(--optimex-text-secondary)}.optx-widget .focus-within\\:border-\\[var\\(--optimex-primary\\)\\]:focus-within{border-color:var(--optimex-primary)}.optx-widget .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))}.optx-widget .hover\\:border-\\[var\\(--optimex-primary\\)\\]:hover{border-color:var(--optimex-primary)}.optx-widget .hover\\:bg-\\[rgba\\(239\\,68\\,68\\,0\\.2\\)\\]:hover{background-color:#ef444433}.optx-widget .hover\\:bg-\\[var\\(--optimex-primary-hover\\)\\]:hover{background-color:var(--optimex-primary-hover)}.optx-widget .hover\\:bg-\\[var\\(--optimex-surface-hover\\)\\]:hover{background-color:var(--optimex-surface-hover)}.optx-widget .hover\\:bg-white\\/10:hover{background-color:#ffffff1a}.optx-widget .hover\\:bg-white\\/5:hover{background-color:#ffffff0d}.optx-widget .hover\\:bg-white\\/\\[0\\.02\\]:hover{background-color:#ffffff05}.optx-widget .hover\\:text-\\[var\\(--optimex-primary\\)\\]:hover{color:var(--optimex-primary)}.optx-widget .hover\\:text-\\[var\\(--optimex-text\\)\\]:hover{color:var(--optimex-text)}.optx-widget .hover\\:text-\\[var\\(--optimex-text-secondary\\)\\]:hover{color:var(--optimex-text-secondary)}.optx-widget .hover\\:opacity-100:hover{opacity:1}.optx-widget .hover\\:opacity-70:hover{opacity:.7}.optx-widget .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)}.optx-widget .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)}.optx-widget .focus\\:border-\\[var\\(--optimex-primary\\)\\]:focus{border-color:var(--optimex-primary)}.optx-widget .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.optx-widget .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)}.optx-widget .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))}.optx-widget .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))}.optx-widget .disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.optx-widget :is(.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))}.optx-widget :is(.group:hover .group-hover\\:opacity-100){opacity:1}@media(min-width:640px){.optx-widget .sm\\:text-left{text-align:left}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),ss=require("react-dom");function os(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const g=os(x),Zo=os(ss);var At=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ye=typeof window>"u"||"Deno"in globalThis;function Ne(){}function Xo(e,t){return typeof e=="function"?e(t):e}function Hr(e){return typeof e=="number"&&e>=0&&e!==1/0}function as(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vt(e,t){return typeof e=="function"?e(t):e}function Re(e,t){return typeof e=="function"?e(t):e}function bn(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:c,stale:i}=e;if(c){if(n){if(t.queryHash!==nn(c,t.options))return!1}else if(!Rt(t.queryKey,c))return!1}if(r!=="all"){const u=t.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function yn(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Tt(t.options.mutationKey)!==Tt(a))return!1}else if(!Rt(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function nn(e,t){return(t?.queryKeyHashFn||Tt)(e)}function Tt(e){return JSON.stringify(e,(t,r)=>qr(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Rt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!Rt(e[r],t[r])):!1}function Vr(e,t){if(e===t)return e;const r=wn(e)&&wn(t);if(r||qr(e)&&qr(t)){const n=r?e:Object.keys(e),s=n.length,a=r?t:Object.keys(t),c=a.length,i=r?[]:{};let u=0;for(let d=0;d<c;d++){const f=r?d:a[d];(!r&&n.includes(f)||r)&&e[f]===void 0&&t[f]===void 0?(i[f]=void 0,u++):(i[f]=Vr(e[f],t[f]),i[f]===e[f]&&e[f]!==void 0&&u++)}return s===c&&u===s?e:i}return t}function Ur(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function wn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qr(e){if(!Cn(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Cn(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Cn(e){return Object.prototype.toString.call(e)==="[object Object]"}function Jo(e){return new Promise(t=>{setTimeout(t,e)})}function Qr(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Vr(e,t)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Vr(e,t)}return t}function ea(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function ta(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var mr=Symbol();function is(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===mr&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===mr?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ra=class extends At{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!Ye&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},sn=new ra,na=class extends At{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!Ye&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#t}},pr=new na;function Kr(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}function sa(e){return Math.min(1e3*2**e,3e4)}function ls(e){return(e??"online")==="online"?pr.isOnline():!0}var cs=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function kr(e){return e instanceof cs}function us(e){let t=!1,r=0,n=!1,s;const a=Kr(),c=m=>{n||(p(new cs(m)),e.abort?.())},i=()=>{t=!0},u=()=>{t=!1},d=()=>sn.isFocused()&&(e.networkMode==="always"||pr.isOnline())&&e.canRun(),f=()=>ls(e.networkMode)&&e.canRun(),h=m=>{n||(n=!0,e.onSuccess?.(m),s?.(),a.resolve(m))},p=m=>{n||(n=!0,e.onError?.(m),s?.(),a.reject(m))},y=()=>new Promise(m=>{s=w=>{(n||d())&&m(w)},e.onPause?.()}).then(()=>{s=void 0,n||e.onContinue?.()}),v=()=>{if(n)return;let m;const w=r===0?e.initialPromise:void 0;try{m=w??e.fn()}catch(b){m=Promise.reject(b)}Promise.resolve(m).then(h).catch(b=>{if(n)return;const R=e.retry??(Ye?0:3),T=e.retryDelay??sa,k=typeof T=="function"?T(r,b):T,A=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,b);if(t||!A){p(b);return}r++,e.onFail?.(r,b),Jo(k).then(()=>d()?void 0:y()).then(()=>{t?p(b):v()})})};return{promise:a,cancel:c,continue:()=>(s?.(),a),cancelRetry:i,continueRetry:u,canStart:f,start:()=>(f()?v():y().then(v),a)}}function oa(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=i=>setTimeout(i,0);const a=i=>{t?e.push(i):s(()=>{r(i)})},c=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(u=>{r(u)})})})};return{batch:i=>{let u;t++;try{u=i()}finally{t--,t||c()}return u},batchCalls:i=>(...u)=>{a(()=>{i(...u)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var pe=oa(),ds=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Hr(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ye?1/0:300*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},aa=class extends ds{#t;#e;#n;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#n=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=ia(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const r=Qr(this.state.data,e,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#s({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(Ne).catch(Ne):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Re(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===mr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!as(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const i=this.observers.find(u=>u.options.queryFn);i&&this.setOptions(i.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,n=i=>{Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},s=()=>{const i=is(this.options,t),u={queryKey:this.queryKey,meta:this.meta};return n(u),this.#o=!1,this.options.persister?this.options.persister(i,u,this):i(u)},a={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};n(a),this.options.behavior?.onFetch(a,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:"fetch",meta:a.fetchOptions?.meta});const c=i=>{kr(i)&&i.silent||this.#s({type:"error",error:i}),kr(i)||(this.#n.config.onError?.(i,this),this.#n.config.onSettled?.(this.state.data,i,this)),this.scheduleGc()};return this.#r=us({initialPromise:t?.initialPromise,fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:i=>{if(i===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(i)}catch(u){c(u);return}this.#n.config.onSuccess?.(i,this),this.#n.config.onSettled?.(i,this.state.error,this),this.scheduleGc()},onError:c,onFail:(i,u)=>{this.#s({type:"failed",failureCount:i,error:u})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}),this.#r.start()}#s(e){const t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...fs(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return kr(n)&&n.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),pe.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function fs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ls(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ia(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var la=class extends At{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,r){const n=t.queryKey,s=t.queryHash??nn(n,t);let a=this.get(s);return a||(a=new aa({cache:this,queryKey:n,queryHash:s,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){pe.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(r=>bn(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>bn(e,r)):t}notify(e){pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){pe.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){pe.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ca=class extends ds{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||ua(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=us({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,s)=>{this.#r({type:"failed",failureCount:n,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",r=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:r}),await this.#e.config.onMutate?.(e,this);const s=await this.options.onMutate?.(e);s!==this.state.context&&this.#r({type:"pending",context:s,variables:e,isPaused:r})}const n=await this.#n.start();return await this.#e.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#e.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#r({type:"success",data:n}),n}catch(n){try{throw await this.#e.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#e.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#r({type:"error",error:n})}}finally{this.#e.runNext(this)}}#r(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),pe.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function ua(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var da=class extends At{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,r){const n=new ca({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#t.add(e);const t=rr(e);if(typeof t=="string"){const r=this.#e.get(t);r?r.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=rr(e);if(typeof t=="string"){const r=this.#e.get(t);if(r)if(r.length>1){const n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=rr(e);if(typeof t=="string"){const n=this.#e.get(t)?.find(s=>s.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=rr(e);return typeof t=="string"?this.#e.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){pe.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(r=>yn(t,r))}findAll(e={}){return this.getAll().filter(t=>yn(e,t))}notify(e){pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return pe.batch(()=>Promise.all(e.map(t=>t.continue().catch(Ne))))}};function rr(e){return e.options.scope?.id}function kn(e){return{onFetch:(t,r)=>{const n=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],c=t.state.data?.pageParams||[];let i={pages:[],pageParams:[]},u=0;const d=async()=>{let f=!1;const h=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?f=!0:t.signal.addEventListener("abort",()=>{f=!0}),t.signal)})},p=is(t.options,t.fetchOptions),y=async(v,m,w)=>{if(f)return Promise.reject();if(m==null&&v.pages.length)return Promise.resolve(v);const b={queryKey:t.queryKey,pageParam:m,direction:w?"backward":"forward",meta:t.options.meta};h(b);const R=await p(b),{maxPages:T}=t.options,k=w?ta:ea;return{pages:k(v.pages,R,T),pageParams:k(v.pageParams,m,T)}};if(s&&a.length){const v=s==="backward",m=v?fa:jn,w={pages:a,pageParams:c},b=m(n,w);i=await y(w,b,v)}else{const v=e??a.length;do{const m=u===0?c[0]??n.initialPageParam:jn(n,i);if(u>0&&m==null)break;i=await y(i,m),u++}while(u<v)}return i};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=d}}}function jn(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function fa(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ha=class{#t;#e;#n;#r;#a;#o;#s;#i;constructor(e={}){this.#t=e.queryCache||new la,this.#e=e.mutationCache||new da,this.#n=e.defaultOptions||{},this.#r=new Map,this.#a=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#s=sn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=pr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#s?.(),this.#s=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=this.#t.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(vt(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=this.#t.get(n.queryHash)?.state.data,c=Xo(t,a);if(c!==void 0)return this.#t.build(this,n).setData(c,{...r,manual:!0})}setQueriesData(e,t,r){return pe.batch(()=>this.#t.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;pe.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#t,n={type:"active",...e};return pe.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=pe.batch(()=>this.#t.findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(Ne).catch(Ne)}invalidateQueries(e,t={}){return pe.batch(()=>{if(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();const r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=pe.batch(()=>this.#t.findAll(e).filter(s=>!s.isDisabled()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(Ne)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(Ne)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=this.#t.build(this,t);return r.isStaleByTime(vt(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ne).catch(Ne)}fetchInfiniteQuery(e){return e.behavior=kn(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ne).catch(Ne)}ensureInfiniteQueryData(e){return e.behavior=kn(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pr.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Tt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],r={};return t.forEach(n=>{Rt(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#a.set(Tt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#a.values()];let r={};return t.forEach(n=>{Rt(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=nn(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===mr&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},ma=class extends At{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#s=Kr(),this.options.experimental_prefetchInRender||this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#a;#o;#s;#i;#p;#f;#h;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Sn(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Gr(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Gr(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e,t){const r=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Re(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),r._defaulted&&!Ur(this.options,r)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const s=this.hasListeners();s&&En(this.#e,n,this.options,r)&&this.#d(),this.updateResult(t),s&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(r.enabled,this.#e)||vt(this.options.staleTime,this.#e)!==vt(r.staleTime,this.#e))&&this.#x();const a=this.#v();s&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(r.enabled,this.#e)||a!==this.#l)&&this.#g(a)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),r=this.createResult(t,e);return xa(this,r)&&(this.#r=r,this.#o=this.options,this.#a=this.#e.state),r}getCurrentResult(){return this.#r}trackResult(e,t){const r={};return Object.keys(e).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),t?.(n),e[n])})}),r}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),r=this.#t.getQueryCache().build(this.#t,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Ne)),t}#x(){this.#y();const e=vt(this.options.staleTime,this.#e);if(Ye||this.#r.isStale||!Hr(e))return;const r=as(this.#r.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#r.isStale||this.updateResult()},r)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(e){this.#w(),this.#l=e,!(Ye||Re(this.options.enabled,this.#e)===!1||!Hr(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||sn.isFocused())&&this.#d()},this.#l))}#b(){this.#x(),this.#g(this.#v())}#y(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const r=this.#e,n=this.options,s=this.#r,a=this.#a,c=this.#o,u=e!==r?e.state:this.#n,{state:d}=e;let f={...d},h=!1,p;if(t._optimisticResults){const j=this.hasListeners(),N=!j&&Sn(e,t),M=j&&En(e,r,t,n);(N||M)&&(f={...f,...fs(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:m}=f;if(t.select&&f.data!==void 0)if(s&&f.data===a?.data&&t.select===this.#p)p=this.#f;else try{this.#p=t.select,p=t.select(f.data),p=Qr(s?.data,p,t),this.#f=p,this.#i=null}catch(j){this.#i=j}else p=f.data;if(t.placeholderData!==void 0&&p===void 0&&m==="pending"){let j;if(s?.isPlaceholderData&&t.placeholderData===c?.placeholderData)j=s.data;else if(j=typeof t.placeholderData=="function"?t.placeholderData(this.#h?.state.data,this.#h):t.placeholderData,t.select&&j!==void 0)try{j=t.select(j),this.#i=null}catch(N){this.#i=N}j!==void 0&&(m="success",p=Qr(s?.data,j,t),h=!0)}this.#i&&(y=this.#i,p=this.#f,v=Date.now(),m="error");const w=f.fetchStatus==="fetching",b=m==="pending",R=m==="error",T=b&&w,k=p!==void 0,L={status:m,fetchStatus:f.fetchStatus,isPending:b,isSuccess:m==="success",isError:R,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:f.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!b,isLoadingError:R&&!k,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:R&&k,isStale:on(e,t),refetch:this.refetch,promise:this.#s};if(this.options.experimental_prefetchInRender){const j=U=>{L.status==="error"?U.reject(L.error):L.data!==void 0&&U.resolve(L.data)},N=()=>{const U=this.#s=L.promise=Kr();j(U)},M=this.#s;switch(M.status){case"pending":e.queryHash===r.queryHash&&j(M);break;case"fulfilled":(L.status==="error"||L.data!==M.value)&&N();break;case"rejected":(L.status!=="error"||L.error!==M.reason)&&N();break}}return L}updateResult(e){const t=this.#r,r=this.createResult(this.#e,this.options);if(this.#a=this.#e.state,this.#o=this.options,this.#a.data!==void 0&&(this.#h=this.#e),Ur(r,t))return;this.#r=r;const n={},s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,c=typeof a=="function"?a():a;if(c==="all"||!c&&!this.#m.size)return!0;const i=new Set(c??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(u=>{const d=u;return this.#r[d]!==t[d]&&i.has(d)})};e?.listeners!==!1&&s()&&(n.listeners=!0),this.#k({...n,...e})}#C(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#k(e){pe.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function pa(e,t){return Re(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Sn(e,t){return pa(e,t)||e.state.data!==void 0&&Gr(e,t,t.refetchOnMount)}function Gr(e,t,r){if(Re(t.enabled,e)!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&on(e,t)}return!1}function En(e,t,r,n){return(e!==t||Re(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&on(e,r)}function on(e,t){return Re(t.enabled,e)!==!1&&e.isStaleByTime(vt(t.staleTime,e))}function xa(e,t){return!Ur(e.getCurrentResult(),t)}var hs=g.createContext(void 0),va=e=>{const t=g.useContext(hs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ga=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),o.jsx(hs.Provider,{value:e,children:t})),ms=g.createContext(!1),ba=()=>g.useContext(ms);ms.Provider;function ya(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var wa=g.createContext(ya()),Ca=()=>g.useContext(wa);function ka(e,t){return typeof e=="function"?e(...t):!!e}function Nn(){}var ja=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Sa=e=>{g.useEffect(()=>{e.clearReset()},[e])},Ea=({result:e,errorResetBoundary:t,throwOnError:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&ka(r,[e.error,n]),Na=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...r)=>Math.max(t(...r),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Ta=(e,t)=>e.isLoading&&e.isFetching&&!t,Ra=(e,t)=>e?.suspense&&t.isPending,Tn=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function Oa(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=va(),s=ba(),a=Ca(),c=n.defaultQueryOptions(e);n.getDefaultOptions().queries?._experimental_beforeQuery?.(c),c._optimisticResults=s?"isRestoring":"optimistic",Na(c),ja(c,a),Sa(a);const i=!n.getQueryCache().get(c.queryHash),[u]=g.useState(()=>new t(n,c)),d=u.getOptimisticResult(c),f=!s&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(h=>{const p=f?u.subscribe(pe.batchCalls(h)):Nn;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(c,{listeners:!1})},[c,u]),Ra(c,d))throw Tn(c,u,a);if(Ea({result:d,errorResetBoundary:a,throwOnError:c.throwOnError,query:n.getQueryCache().get(c.queryHash)}))throw d.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(c,d),c.experimental_prefetchInRender&&!Ye&&Ta(d,s)&&(i?Tn(c,u,a):n.getQueryCache().get(c.queryHash)?.promise)?.catch(Nn).finally(()=>{u.updateResult()}),c.notifyOnChangeProps?d:u.trackResult(d)}function bt(e,t){return Oa(e,ma)}const _a={widget:"1rem",input:"0.75rem",button:"0.5rem"},Aa={primary:"#ffffff",secondary:"hsla(0, 0%, 100%, 0.48)"},Ma={background:"#343b47",radius:"0.75rem"},Ce={colors:{primary:"#ed6300",background:"hsla(0, 0%, 100%, 0.04)",surface:"hsla(0, 0%, 0%, 0.2)",text:Aa,error:"#ff4d4f",success:"#52c41a"},radius:_a,overlay:Ma,fontFamily:"'Inter', sans-serif"},ps=x.createContext(null);function Pa({children:e,theme:t}){const r=x.useMemo(()=>t?{colors:{primary:t.colors?.primary??Ce.colors.primary,background:t.colors?.background??Ce.colors.background,surface:t.colors?.surface??Ce.colors.surface,text:{primary:t.colors?.text?.primary??Ce.colors.text.primary,secondary:t.colors?.text?.secondary??Ce.colors.text.secondary},error:t.colors?.error??Ce.colors.error,success:t.colors?.success??Ce.colors.success},radius:{widget:t.radius?.widget??Ce.radius.widget,input:t.radius?.input??Ce.radius.input,button:t.radius?.button??Ce.radius.button},overlay:{background:t.overlay?.background??Ce.overlay.background,radius:t.overlay?.radius??Ce.overlay.radius},fontFamily:t.fontFamily??Ce.fontFamily}:Ce,[t]),n=x.useMemo(()=>({"--optimex-primary":r.colors.primary,"--optimex-background":r.colors.background,"--optimex-surface":r.colors.surface,"--optimex-text":r.colors.text.primary,"--optimex-text-secondary":r.colors.text.secondary,"--optimex-error":r.colors.error,"--optimex-success":r.colors.success,"--optimex-radius-widget":r.radius.widget,"--optimex-radius-input":r.radius.input,"--optimex-radius-button":r.radius.button,"--optimex-overlay-background":r.overlay.background,"--optimex-overlay-radius":r.overlay.radius,"--optimex-font-family":r.fontFamily}),[r]);return o.jsx(ps.Provider,{value:{theme:r},children:o.jsx("div",{style:n,className:"w-full",children:e})})}function Ia(){const e=x.useContext(ps);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const xs=x.createContext(null);function Da({children:e,externalWalletClient:t,onRequestWallet:r}){const n=x.useMemo(()=>{const s=t?.evm?.address??null,a=t?.evm?.chain?.id??null,c=t?.btc?.address??null,i=t?.btc?.publicKey??null,u=t?.solana?.address??null,d=!!s,f=!!c,h=!!u;return{mode:"external",isExternalWallet:!0,isConnected:d||f||h,evmAddress:s,evmChainId:a,isEvmConnected:d,btcAddress:c,btcPublicKey:i,isBtcConnected:f,solanaAddress:u,isSolanaConnected:h,externalWalletClient:t,onRequestWallet:r,isConnecting:!1}},[t,r]);return o.jsx(xs.Provider,{value:n,children:e})}class jr extends Error{status;code;constructor(t,r,n){super(r),this.name="ApiError",this.status=t,this.code=n}}class vs{baseUrl;headers;constructor(t){this.baseUrl=t.replace(/\/$/,""),this.headers={"Content-Type":"application/json"}}async request(t,r,n){const s=`${this.baseUrl}${r}`;try{const a=await fetch(s,{method:t,headers:this.headers,body:n?JSON.stringify(n):void 0});if(!a.ok){const i=await a.json().catch(()=>({}));throw new jr(a.status,i.message||`Request failed with status ${a.status}`,i.code)}return(await a.json()).data}catch(a){throw a instanceof jr?a:new jr(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,r){return this.request("POST","/v2/trades/submit-tx",{trade_id:t,tx_id:r})}async getTrade(t){return this.request("GET",`/v2/trades/${t}`)}async getTokenPrice(t){return this.request("GET",`/v2/tokens/${t}`)}async listTrades(t={}){const r=new URLSearchParams;t.limit&&r.set("limit",String(t.limit)),t.page&&r.set("page",String(t.page)),t.state&&r.set("state",t.state),t.from_user_address?.length&&t.from_user_address.forEach(a=>r.append("from_user_address",a)),t.to_user_address?.length&&t.to_user_address.forEach(a=>r.append("to_user_address",a));const n=r.toString(),s=n?`/v2/trades?${n}`:"/v2/trades";return this.request("GET",s)}}let xt=null;function yt(e){if(!xt&&e&&(xt=new vs(e)),!xt)throw new Error("API not initialized. Please provide baseUrl.");return xt}function La(e){return xt=new vs(e),xt}const Fa=["tokens"];function Ba(e){return bt({queryKey:Fa,queryFn:async()=>yt(e).getTokens(),staleTime:300*1e3,gcTime:1800*1e3,retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4)})}const $a=2e4,za=1e4,ie={EVM:"EVM",BTC:"BTC",SOLANA:"Solana"};function Wa(e,t=4){return e?e.length<=t*2+3?e:`${e.slice(0,t+2)}...${e.slice(-t)}`:""}function Ha(e,t,r=6){if(!e)return"0";let n;typeof e=="bigint"?n=e:typeof e=="string"?n=BigInt(e):n=BigInt(Math.floor(e));const s=BigInt(10**t),a=n/s,c=n%s;if(c===0n)return a.toString();const u=c.toString().padStart(t,"0").slice(0,r).replace(/0+$/,"");return u?`${a}.${u}`:a.toString()}function gs(e,t){if(!e||e==="0")return 0n;const[r,n=""]=e.split("."),s=n.slice(0,t).padEnd(t,"0"),a=r+s;return BigInt(a)}function ze(e,t=18,r=6){if(!e)return"0";const n=String(e);if(n.includes(".")||!Number.isInteger(Number(n))){const s=parseFloat(n);return isNaN(s)?"0":s.toFixed(r).replace(/\.?0+$/,"")}return Ha(n,t,r)}function Va(e,t){if(!t||!e||isNaN(parseFloat(e)))return"$0.00";const r=parseFloat(e);if(r===0)return"$0.00";const n=r*t;return n<.01?"<$0.01":n<1?`$${n.toFixed(4)}`:n<1e3?`$${n.toFixed(2)}`:n<1e6?`$${(n/1e3).toFixed(2)}K`:`$${(n/1e6).toFixed(2)}M`}var Ua=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sr={exports:{}};var Rn;function qa(){return Rn||(Rn=1,(function(e){(function(){var t="input is invalid type",r="finalize already called",n=typeof window=="object",s=n?window:{};s.JS_SHA3_NO_WINDOW&&(n=!1);var a=!n&&typeof self=="object",c=!s.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;c?s=Ua:a&&(s=self);for(var i=!s.JS_SHA3_NO_COMMON_JS&&!0&&e.exports,u=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),f=[31,7936,2031616,520093696],h=[4,1024,262144,67108864],p=[1,256,65536,16777216],y=[6,1536,393216,100663296],v=[0,8,16,24],m=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],w=[224,256,384,512],b=[128,256],R=["hex","buffer","arrayBuffer","array","digest"],T={128:168,256:136},k=s.JS_SHA3_NO_NODE_JS||!Array.isArray?function(l){return Object.prototype.toString.call(l)==="[object Array]"}:Array.isArray,A=u&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(l){return typeof l=="object"&&l.buffer&&l.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,L=function(l){var C=typeof l;if(C==="string")return[l,!0];if(C!=="object"||l===null)throw new Error(t);if(u&&l.constructor===ArrayBuffer)return[new Uint8Array(l),!1];if(!k(l)&&!A(l))throw new Error(t);return[l,!1]},j=function(l){return L(l)[0].length===0},N=function(l){for(var C=[],S=0;S<l.length;++S)C[S]=l[S];return C},M=function(l,C,S){return function(O){return new F(l,C,l).update(O)[S]()}},U=function(l,C,S){return function(O,E){return new F(l,C,E).update(O)[S]()}},W=function(l,C,S){return function(O,E,$,H){return oe["cshake"+l].update(O,E,$,H)[S]()}},K=function(l,C,S){return function(O,E,$,H){return oe["kmac"+l].update(O,E,$,H)[S]()}},D=function(l,C,S,O){for(var E=0;E<R.length;++E){var $=R[E];l[$]=C(S,O,$)}return l},X=function(l,C){var S=M(l,C,"hex");return S.create=function(){return new F(l,C,l)},S.update=function(O){return S.create().update(O)},D(S,M,l,C)},J=function(l,C){var S=U(l,C,"hex");return S.create=function(O){return new F(l,C,O)},S.update=function(O,E){return S.create(E).update(O)},D(S,U,l,C)},re=function(l,C){var S=T[l],O=W(l,C,"hex");return O.create=function(E,$,H){return j($)&&j(H)?oe["shake"+l].create(E):new F(l,C,E).bytepad([$,H],S)},O.update=function(E,$,H,B){return O.create($,H,B).update(E)},D(O,W,l,C)},te=function(l,C){var S=T[l],O=K(l,C,"hex");return O.create=function(E,$,H){return new ke(l,C,$).bytepad(["KMAC",H],S).bytepad([E],S)},O.update=function(E,$,H,B){return O.create(E,H,B).update($)},D(O,K,l,C)},_=[{name:"keccak",padding:p,bits:w,createMethod:X},{name:"sha3",padding:y,bits:w,createMethod:X},{name:"shake",padding:f,bits:b,createMethod:J},{name:"cshake",padding:h,bits:b,createMethod:re},{name:"kmac",padding:h,bits:b,createMethod:te}],oe={},me=[],xe=0;xe<_.length;++xe)for(var ve=_[xe],Y=ve.bits,ne=0;ne<Y.length;++ne){var ye=ve.name+"_"+Y[ne];if(me.push(ye),oe[ye]=ve.createMethod(Y[ne],ve.padding),ve.name!=="sha3"){var Te=ve.name+Y[ne];me.push(Te),oe[Te]=oe[ye]}}function F(l,C,S){this.blocks=[],this.s=[],this.padding=C,this.outputBits=S,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(l<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=S>>5,this.extraBytes=(S&31)>>3;for(var O=0;O<50;++O)this.s[O]=0}F.prototype.update=function(l){if(this.finalized)throw new Error(r);var C=L(l);l=C[0];for(var S=C[1],O=this.blocks,E=this.byteCount,$=l.length,H=this.blockCount,B=0,le=this.s,V,ee;B<$;){if(this.reset)for(this.reset=!1,O[0]=this.block,V=1;V<H+1;++V)O[V]=0;if(S)for(V=this.start;B<$&&V<E;++B)ee=l.charCodeAt(B),ee<128?O[V>>2]|=ee<<v[V++&3]:ee<2048?(O[V>>2]|=(192|ee>>6)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]):ee<55296||ee>=57344?(O[V>>2]|=(224|ee>>12)<<v[V++&3],O[V>>2]|=(128|ee>>6&63)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]):(ee=65536+((ee&1023)<<10|l.charCodeAt(++B)&1023),O[V>>2]|=(240|ee>>18)<<v[V++&3],O[V>>2]|=(128|ee>>12&63)<<v[V++&3],O[V>>2]|=(128|ee>>6&63)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]);else for(V=this.start;B<$&&V<E;++B)O[V>>2]|=l[B]<<v[V++&3];if(this.lastByteIndex=V,V>=E){for(this.start=V-E,this.block=O[H],V=0;V<H;++V)le[V]^=O[V];we(le),this.reset=!0}else this.start=V}return this},F.prototype.encode=function(l,C){var S=l&255,O=1,E=[S];for(l=l>>8,S=l&255;S>0;)E.unshift(S),l=l>>8,S=l&255,++O;return C?E.push(O):E.unshift(O),this.update(E),E.length},F.prototype.encodeString=function(l){var C=L(l);l=C[0];var S=C[1],O=0,E=l.length;if(S)for(var $=0;$<l.length;++$){var H=l.charCodeAt($);H<128?O+=1:H<2048?O+=2:H<55296||H>=57344?O+=3:(H=65536+((H&1023)<<10|l.charCodeAt(++$)&1023),O+=4)}else O=E;return O+=this.encode(O*8),this.update(l),O},F.prototype.bytepad=function(l,C){for(var S=this.encode(C),O=0;O<l.length;++O)S+=this.encodeString(l[O]);var E=(C-S%C)%C,$=[];return $.length=E,this.update($),this},F.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var l=this.blocks,C=this.lastByteIndex,S=this.blockCount,O=this.s;if(l[C>>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(l[0]=l[S],C=1;C<S+1;++C)l[C]=0;for(l[S-1]|=2147483648,C=0;C<S;++C)O[C]^=l[C];we(O)}},F.prototype.toString=F.prototype.hex=function(){this.finalize();for(var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H="",B;$<S;){for(E=0;E<l&&$<S;++E,++$)B=C[E],H+=d[B>>4&15]+d[B&15]+d[B>>12&15]+d[B>>8&15]+d[B>>20&15]+d[B>>16&15]+d[B>>28&15]+d[B>>24&15];$%l===0&&(C=N(C),we(C),E=0)}return O&&(B=C[E],H+=d[B>>4&15]+d[B&15],O>1&&(H+=d[B>>12&15]+d[B>>8&15]),O>2&&(H+=d[B>>20&15]+d[B>>16&15])),H},F.prototype.arrayBuffer=function(){this.finalize();var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H=this.outputBits>>3,B;O?B=new ArrayBuffer(S+1<<2):B=new ArrayBuffer(H);for(var le=new Uint32Array(B);$<S;){for(E=0;E<l&&$<S;++E,++$)le[$]=C[E];$%l===0&&(C=N(C),we(C))}return O&&(le[$]=C[E],B=B.slice(0,H)),B},F.prototype.buffer=F.prototype.arrayBuffer,F.prototype.digest=F.prototype.array=function(){this.finalize();for(var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H=[],B,le;$<S;){for(E=0;E<l&&$<S;++E,++$)B=$<<2,le=C[E],H[B]=le&255,H[B+1]=le>>8&255,H[B+2]=le>>16&255,H[B+3]=le>>24&255;$%l===0&&(C=N(C),we(C))}return O&&(B=$<<2,le=C[E],H[B]=le&255,O>1&&(H[B+1]=le>>8&255),O>2&&(H[B+2]=le>>16&255)),H};function ke(l,C,S){F.call(this,l,C,S)}ke.prototype=new F,ke.prototype.finalize=function(){return this.encode(this.outputBits,!0),F.prototype.finalize.call(this)};var we=function(l){var C,S,O,E,$,H,B,le,V,ee,We,tt,_e,rt,He,nt,st,Pe,ot,Ve,at,Ae,Ue,it,lt,ct,ut,dt,z,G,Z,Q,se,de,ce,je,ge,Ee,Se,be,Ie,qe,It,Dt,Lt,Ft,Bt,$t,zt,Wt,Ht,Vt,Ut,qt,Qt,Kt,Gt,Yt,Zt,Xt,Jt,er,tr;for(O=0;O<48;O+=2)E=l[0]^l[10]^l[20]^l[30]^l[40],$=l[1]^l[11]^l[21]^l[31]^l[41],H=l[2]^l[12]^l[22]^l[32]^l[42],B=l[3]^l[13]^l[23]^l[33]^l[43],le=l[4]^l[14]^l[24]^l[34]^l[44],V=l[5]^l[15]^l[25]^l[35]^l[45],ee=l[6]^l[16]^l[26]^l[36]^l[46],We=l[7]^l[17]^l[27]^l[37]^l[47],tt=l[8]^l[18]^l[28]^l[38]^l[48],_e=l[9]^l[19]^l[29]^l[39]^l[49],C=tt^(H<<1|B>>>31),S=_e^(B<<1|H>>>31),l[0]^=C,l[1]^=S,l[10]^=C,l[11]^=S,l[20]^=C,l[21]^=S,l[30]^=C,l[31]^=S,l[40]^=C,l[41]^=S,C=E^(le<<1|V>>>31),S=$^(V<<1|le>>>31),l[2]^=C,l[3]^=S,l[12]^=C,l[13]^=S,l[22]^=C,l[23]^=S,l[32]^=C,l[33]^=S,l[42]^=C,l[43]^=S,C=H^(ee<<1|We>>>31),S=B^(We<<1|ee>>>31),l[4]^=C,l[5]^=S,l[14]^=C,l[15]^=S,l[24]^=C,l[25]^=S,l[34]^=C,l[35]^=S,l[44]^=C,l[45]^=S,C=le^(tt<<1|_e>>>31),S=V^(_e<<1|tt>>>31),l[6]^=C,l[7]^=S,l[16]^=C,l[17]^=S,l[26]^=C,l[27]^=S,l[36]^=C,l[37]^=S,l[46]^=C,l[47]^=S,C=ee^(E<<1|$>>>31),S=We^($<<1|E>>>31),l[8]^=C,l[9]^=S,l[18]^=C,l[19]^=S,l[28]^=C,l[29]^=S,l[38]^=C,l[39]^=S,l[48]^=C,l[49]^=S,rt=l[0],He=l[1],Ft=l[11]<<4|l[10]>>>28,Bt=l[10]<<4|l[11]>>>28,dt=l[20]<<3|l[21]>>>29,z=l[21]<<3|l[20]>>>29,Xt=l[31]<<9|l[30]>>>23,Jt=l[30]<<9|l[31]>>>23,qe=l[40]<<18|l[41]>>>14,It=l[41]<<18|l[40]>>>14,de=l[2]<<1|l[3]>>>31,ce=l[3]<<1|l[2]>>>31,nt=l[13]<<12|l[12]>>>20,st=l[12]<<12|l[13]>>>20,$t=l[22]<<10|l[23]>>>22,zt=l[23]<<10|l[22]>>>22,G=l[33]<<13|l[32]>>>19,Z=l[32]<<13|l[33]>>>19,er=l[42]<<2|l[43]>>>30,tr=l[43]<<2|l[42]>>>30,qt=l[5]<<30|l[4]>>>2,Qt=l[4]<<30|l[5]>>>2,je=l[14]<<6|l[15]>>>26,ge=l[15]<<6|l[14]>>>26,Pe=l[25]<<11|l[24]>>>21,ot=l[24]<<11|l[25]>>>21,Wt=l[34]<<15|l[35]>>>17,Ht=l[35]<<15|l[34]>>>17,Q=l[45]<<29|l[44]>>>3,se=l[44]<<29|l[45]>>>3,it=l[6]<<28|l[7]>>>4,lt=l[7]<<28|l[6]>>>4,Kt=l[17]<<23|l[16]>>>9,Gt=l[16]<<23|l[17]>>>9,Ee=l[26]<<25|l[27]>>>7,Se=l[27]<<25|l[26]>>>7,Ve=l[36]<<21|l[37]>>>11,at=l[37]<<21|l[36]>>>11,Vt=l[47]<<24|l[46]>>>8,Ut=l[46]<<24|l[47]>>>8,Dt=l[8]<<27|l[9]>>>5,Lt=l[9]<<27|l[8]>>>5,ct=l[18]<<20|l[19]>>>12,ut=l[19]<<20|l[18]>>>12,Yt=l[29]<<7|l[28]>>>25,Zt=l[28]<<7|l[29]>>>25,be=l[38]<<8|l[39]>>>24,Ie=l[39]<<8|l[38]>>>24,Ae=l[48]<<14|l[49]>>>18,Ue=l[49]<<14|l[48]>>>18,l[0]=rt^~nt&Pe,l[1]=He^~st&ot,l[10]=it^~ct&dt,l[11]=lt^~ut&z,l[20]=de^~je&Ee,l[21]=ce^~ge&Se,l[30]=Dt^~Ft&$t,l[31]=Lt^~Bt&zt,l[40]=qt^~Kt&Yt,l[41]=Qt^~Gt&Zt,l[2]=nt^~Pe&Ve,l[3]=st^~ot&at,l[12]=ct^~dt&G,l[13]=ut^~z&Z,l[22]=je^~Ee&be,l[23]=ge^~Se&Ie,l[32]=Ft^~$t&Wt,l[33]=Bt^~zt&Ht,l[42]=Kt^~Yt&Xt,l[43]=Gt^~Zt&Jt,l[4]=Pe^~Ve&Ae,l[5]=ot^~at&Ue,l[14]=dt^~G&Q,l[15]=z^~Z&se,l[24]=Ee^~be&qe,l[25]=Se^~Ie&It,l[34]=$t^~Wt&Vt,l[35]=zt^~Ht&Ut,l[44]=Yt^~Xt&er,l[45]=Zt^~Jt&tr,l[6]=Ve^~Ae&rt,l[7]=at^~Ue&He,l[16]=G^~Q&it,l[17]=Z^~se<,l[26]=be^~qe&de,l[27]=Ie^~It&ce,l[36]=Wt^~Vt&Dt,l[37]=Ht^~Ut&Lt,l[46]=Xt^~er&qt,l[47]=Jt^~tr&Qt,l[8]=Ae^~rt&nt,l[9]=Ue^~He&st,l[18]=Q^~it&ct,l[19]=se^~lt&ut,l[28]=qe^~de&je,l[29]=It^~ce&ge,l[38]=Vt^~Dt&Ft,l[39]=Ut^~Lt&Bt,l[48]=er^~qt&Kt,l[49]=tr^~Qt&Gt,l[0]^=m[O],l[1]^=m[O+1]};if(i)e.exports=oe;else for(xe=0;xe<me.length;++xe)s[me[xe]]=oe[me[xe]]})()})(Sr)),Sr.exports}var Qa=qa();function Ka(e){const t=e.slice(2).toLowerCase(),r=Qa.keccak256(t);for(let n=0;n<40;n++){const s=parseInt(r[n],16),a=t[n];if(s>=8){if(e[n+2]!==a.toUpperCase())return!1}else if(e[n+2]!==a.toLowerCase())return!1}return!0}function Ga(e){return/^0x[a-fA-F0-9]{40}$/.test(e)?/^0x[0-9a-f]{40}$/.test(e)||/^0x[0-9A-F]{40}$/.test(e)?!0:Ka(e):!1}function Ya(e){return/^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[a-z0-9]{39,59}$/.test(e)}function Za(e){return/^[mn2][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(tb1)[a-z0-9]{39,59}$/.test(e)}function Xa(e){return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)}function an(e,t,r){const n=e.trim();if(!n)return{isValid:!1,error:"Address is required"};switch(t){case ie.EVM:return Ga(n)?{isValid:!0}:{isValid:!1,error:`Invalid ${r} wallet address`};case ie.BTC:if(r==="bitcoin_testnet"){if(!Za(n))return{isValid:!1,error:`Invalid ${r} wallet address`}}else if(!Ya(n))return{isValid:!1,error:`Invalid ${r} wallet address`};return{isValid:!0};case ie.SOLANA:return Xa(n)?{isValid:!0}:{isValid:!1,error:`Invalid ${r} wallet address`};default:return{isValid:!1,error:`Unsupported network type: ${t}`}}}const Ja=e=>["quote",e];function ei(e,{from_token:t,to_token:r,amount:n,from_user_address:s,to_user_address:a,user_refund_pubkey:c,slippage:i="100",affiliate_fee_bps:u,affiliate_info:d,trade_timeout:f,script_timeout:h,enabled:p=!0,onQuote:y}){const v=r&&a?an(a,r.network_type,r.network_id).isValid:!1,m=t&&r&&n&&parseFloat(n)>0&&s&&a&&c&&v;return bt({queryKey:Ja({from_token:t,to_token:r,amount:n,from_user_address:s,to_user_address:a,user_refund_pubkey:c,slippage:i}),queryFn:async()=>{const w=yt(e),b=gs(n,t.token_decimals).toString(),R=await w.createQuote({from_token_id:t.token_id,to_token_id:r.token_id,amount_in:b,slippage:i,from_user_address:s,to_user_address:a,user_refund_pubkey:c,affiliate_fee_bps:u,affiliate_info:d,trade_timeout:f,script_timeout:h});return y?.({quote:R,from_token:t,to_token:r,amount_in:n}),R},enabled:p&&!!m,staleTime:za,refetchInterval:$a,retry:2,retryDelay:1e3})}const bs=x.createContext(null);function ti({children:e,value:t}){return o.jsx(bs.Provider,{value:t,children:e})}function Mt(){const e=x.useContext(bs);if(!e)throw new Error("useWidgetConfig must be used within SwapWidget");return e}function ri({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 ni(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 ln({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 ys({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 ws({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 si({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 Ze({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 oi(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 ai(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 ii({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 li(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 ci(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 ui(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 di(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 fi(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 hi({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 mi({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 Cs(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 On({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 ks(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 js(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 Ss(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 Es(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 Ns(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 Ts(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 Rs(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 _n={bitcoin:ks,solana:js,ethereum:Ss,base:Es,arbitrum:Ns,optimism:Ts,bsc:Rs};function pi(e){if(!e)return null;const t=e.toLowerCase().replace(/[\s_-]/g,"");return t in _n?_n[t]:t.includes("bitcoin")||t.includes("btc")?ks:t.includes("solana")||t.includes("sol")?js:t.includes("ethereum")||t.includes("eth")||t.includes("erc20")?Ss:t.includes("base")?Es:t.includes("arbitrum")||t.includes("arb")?Ns:t.includes("optimism")||t.includes("op")?Ts:t.includes("bsc")||t.includes("binance")||t.includes("bnb")?Rs:null}function xi(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function vi({icon:e,label:t,address:r,className:n=""}){const[s,a]=x.useState(!1),c=x.useCallback(async()=>{try{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)}catch{console.error("Failed to copy")}},[r]);return o.jsxs("div",{className:`flex items-center justify-between px-4 py-3 ${n}`,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:xi(r)}),o.jsx("button",{onClick:c,className:"p-1 rounded hover:bg-[var(--optimex-surface-hover)] transition-colors",title:s?"Copied!":"Copy",children:s?o.jsx(ln,{className:"size-4 text-[var(--optimex-success)]"}):o.jsx(oi,{className:"size-4 text-[var(--optimex-text-secondary)]"})})]})]})}const gi={primary:"bg-[var(--optimex-primary)] text-black hover:brightness-110 shadow-lg shadow-[var(--optimex-primary)]/30",secondary:"bg-[var(--optimex-surface)] text-[var(--optimex-text)] hover:bg-white/10 border border-white/10",ghost:"bg-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 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"},bi={sm:"px-3 py-1.5 text-xs rounded-[var(--optimex-radius-button)] gap-1.5 max-h-[2rem]",md:"px-4 py-2 text-sm rounded-[var(--optimex-radius-button)] gap-2 max-h-[2.5rem]",lg:"px-6 py-3 text-sm rounded-[var(--optimex-radius-button)] gap-2 max-h-[3rem]",xl:"px-6 py-4 text-sm rounded-[var(--optimex-radius-button)] gap-2"};function cn({variant:e="primary",size:t="md",fullWidth:r=!1,isLoading:n=!1,leftIcon:s,rightIcon:a,children:c,className:i="",disabled:u,...d}){const f=u||n;return o.jsxs("button",{className:`
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.optx-widget .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.optx-widget .fixed{position:fixed}.optx-widget .absolute{position:absolute}.optx-widget .relative{position:relative}.optx-widget .inset-0{inset:0}.optx-widget .inset-2{inset:.5rem}.optx-widget .inset-x-0{left:0;right:0}.optx-widget .-bottom-1{bottom:-.25rem}.optx-widget .-bottom-2{bottom:-.5rem}.optx-widget .-right-1{right:-.25rem}.optx-widget .-top-2{top:-.5rem}.optx-widget .bottom-0{bottom:0}.optx-widget .bottom-full{bottom:100%}.optx-widget .left-0{left:0}.optx-widget .left-1\\/2{left:50%}.optx-widget .left-3{left:.75rem}.optx-widget .left-4{left:1rem}.optx-widget .right-0{right:0}.optx-widget .right-3{right:.75rem}.optx-widget .right-4{right:1rem}.optx-widget .top-1\\/2{top:50%}.optx-widget .top-full{top:100%}.optx-widget .z-10{z-index:10}.optx-widget .z-50{z-index:50}.optx-widget .\\!m-0{margin:0!important}.optx-widget .-my-4{margin-top:-1rem;margin-bottom:-1rem}.optx-widget .mx-auto{margin-left:auto;margin-right:auto}.optx-widget .mb-1{margin-bottom:.25rem}.optx-widget .mb-2{margin-bottom:.5rem}.optx-widget .mb-3{margin-bottom:.75rem}.optx-widget .mb-4{margin-bottom:1rem}.optx-widget .mb-6{margin-bottom:1.5rem}.optx-widget .ml-2{margin-left:.5rem}.optx-widget .ml-3{margin-left:.75rem}.optx-widget .ml-auto{margin-left:auto}.optx-widget .mt-1{margin-top:.25rem}.optx-widget .mt-2{margin-top:.5rem}.optx-widget .mt-24{margin-top:6rem}.optx-widget .mt-3{margin-top:.75rem}.optx-widget .mt-4{margin-top:1rem}.optx-widget .mt-auto{margin-top:auto}.optx-widget .block{display:block}.optx-widget .inline-block{display:inline-block}.optx-widget .inline{display:inline}.optx-widget .flex{display:flex}.optx-widget .size-10{width:2.5rem;height:2.5rem}.optx-widget .size-12{width:3rem;height:3rem}.optx-widget .size-2{width:.5rem;height:.5rem}.optx-widget .size-20{width:5rem;height:5rem}.optx-widget .size-3{width:.75rem;height:.75rem}.optx-widget .size-4{width:1rem;height:1rem}.optx-widget .size-5{width:1.25rem;height:1.25rem}.optx-widget .size-8{width:2rem;height:2rem}.optx-widget .h-1\\.5{height:.375rem}.optx-widget .h-10{height:2.5rem}.optx-widget .h-12{height:3rem}.optx-widget .h-14{height:3.5rem}.optx-widget .h-16{height:4rem}.optx-widget .h-2{height:.5rem}.optx-widget .h-3{height:.75rem}.optx-widget .h-3\\.5{height:.875rem}.optx-widget .h-4{height:1rem}.optx-widget .h-5{height:1.25rem}.optx-widget .h-6{height:1.5rem}.optx-widget .h-8{height:2rem}.optx-widget .h-auto{height:auto}.optx-widget .h-full{height:100%}.optx-widget .max-h-\\[2\\.5rem\\]{max-height:2.5rem}.optx-widget .max-h-\\[2rem\\]{max-height:2rem}.optx-widget .max-h-\\[3rem\\]{max-height:3rem}.optx-widget .max-h-\\[5rem\\]{max-height:5rem}.optx-widget .max-h-\\[60vh\\]{max-height:60vh}.optx-widget .max-h-\\[96vh\\]{max-height:96vh}.optx-widget .min-h-0{min-height:0px}.optx-widget .w-1\\/3{width:33.333333%}.optx-widget .w-10{width:2.5rem}.optx-widget .w-12{width:3rem}.optx-widget .w-14{width:3.5rem}.optx-widget .w-16{width:4rem}.optx-widget .w-20{width:5rem}.optx-widget .w-24{width:6rem}.optx-widget .w-28{width:7rem}.optx-widget .w-3{width:.75rem}.optx-widget .w-3\\.5{width:.875rem}.optx-widget .w-32{width:8rem}.optx-widget .w-4{width:1rem}.optx-widget .w-48{width:12rem}.optx-widget .w-5{width:1.25rem}.optx-widget .w-6{width:1.5rem}.optx-widget .w-72{width:18rem}.optx-widget .w-8{width:2rem}.optx-widget .w-96{width:24rem}.optx-widget .w-\\[32rem\\]{width:32rem}.optx-widget .w-auto{width:auto}.optx-widget .w-full{width:100%}.optx-widget .min-w-0{min-width:0px}.optx-widget .min-w-\\[140px\\]{min-width:140px}.optx-widget .max-w-\\[280px\\]{max-width:280px}.optx-widget .flex-1{flex:1 1 0%}.optx-widget .flex-shrink-0,.optx-widget .shrink-0{flex-shrink:0}.optx-widget .-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))}.optx-widget .-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))}.optx-widget .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))}.optx-widget .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))}.optx-widget .transform{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}}.optx-widget .animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.optx-widget .animate-spin{animation:spin 1s linear infinite}.optx-widget .cursor-not-allowed{cursor:not-allowed}.optx-widget .cursor-pointer{cursor:pointer}.optx-widget .resize{resize:both}.optx-widget .flex-col{flex-direction:column}.optx-widget .flex-wrap{flex-wrap:wrap}.optx-widget .items-end{align-items:flex-end}.optx-widget .items-center{align-items:center}.optx-widget .justify-end{justify-content:flex-end}.optx-widget .justify-center{justify-content:center}.optx-widget .justify-between{justify-content:space-between}.optx-widget .gap-0\\.5{gap:.125rem}.optx-widget .gap-1{gap:.25rem}.optx-widget .gap-1\\.5{gap:.375rem}.optx-widget .gap-2{gap:.5rem}.optx-widget .gap-3{gap:.75rem}.optx-widget .gap-4{gap:1rem}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.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))}.optx-widget :is(.divide-white\\/10>:not([hidden])~:not([hidden])){border-color:#ffffff1a}.optx-widget .overflow-auto{overflow:auto}.optx-widget .overflow-hidden{overflow:hidden}.optx-widget .overflow-y-auto{overflow-y:auto}.optx-widget .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.optx-widget .break-all{word-break:break-all}.optx-widget .rounded{border-radius:.25rem}.optx-widget .rounded-2xl{border-radius:1rem}.optx-widget .rounded-\\[0\\.25rem\\]{border-radius:.25rem}.optx-widget .rounded-\\[9999px\\]{border-radius:9999px}.optx-widget .rounded-\\[var\\(--optimex-overlay-radius\\)\\]{border-radius:var(--optimex-overlay-radius)}.optx-widget .rounded-\\[var\\(--optimex-radius-button\\)\\]{border-radius:var(--optimex-radius-button)}.optx-widget .rounded-\\[var\\(--optimex-radius-input\\)\\]{border-radius:var(--optimex-radius-input)}.optx-widget .rounded-\\[var\\(--optimex-radius-widget\\)\\]{border-radius:var(--optimex-radius-widget)}.optx-widget .rounded-full{border-radius:9999px}.optx-widget .rounded-lg{border-radius:.5rem}.optx-widget .rounded-md{border-radius:.375rem}.optx-widget .rounded-xl{border-radius:.75rem}.optx-widget .rounded-t-sm{border-top-left-radius:.125rem;border-top-right-radius:.125rem}.optx-widget .border{border-width:1px}.optx-widget .border-2{border-width:2px}.optx-widget .border-4{border-width:4px}.optx-widget .border-b{border-bottom-width:1px}.optx-widget .border-l{border-left-width:1px}.optx-widget .border-r{border-right-width:1px}.optx-widget .border-t{border-top-width:1px}.optx-widget .border-none{border-style:none}.optx-widget .border-\\[var\\(--optimex-background\\)\\]{border-color:var(--optimex-background)}.optx-widget .border-\\[var\\(--optimex-error\\)\\]{border-color:var(--optimex-error)}.optx-widget .border-\\[var\\(--optimex-primary\\)\\]{border-color:var(--optimex-primary)}.optx-widget .border-\\[var\\(--optimex-surface\\)\\]{border-color:var(--optimex-surface)}.optx-widget .border-current{border-color:currentColor}.optx-widget .border-transparent{border-color:transparent}.optx-widget .border-white\\/10{border-color:#ffffff1a}.optx-widget .border-white\\/5{border-color:#ffffff0d}.optx-widget .border-white\\/\\[0\\.02\\]{border-color:#ffffff05}.optx-widget .border-white\\/\\[0\\.05\\]{border-color:#ffffff0d}.optx-widget .border-t-transparent{border-top-color:transparent}.optx-widget .bg-\\[rgba\\(239\\,68\\,68\\,0\\.15\\)\\]{background-color:#ef444426}.optx-widget .bg-\\[rgba\\(34\\,197\\,94\\,0\\.15\\)\\]{background-color:#22c55e26}.optx-widget .bg-\\[rgba\\(59\\,130\\,246\\,0\\.15\\)\\]{background-color:#3b82f626}.optx-widget .bg-\\[var\\(--optimex-background\\)\\]{background-color:var(--optimex-background)}.optx-widget .bg-\\[var\\(--optimex-border\\)\\]{background-color:var(--optimex-border)}.optx-widget .bg-\\[var\\(--optimex-error\\)\\]{background-color:var(--optimex-error)}.optx-widget .bg-\\[var\\(--optimex-overlay-background\\)\\]{background-color:var(--optimex-overlay-background)}.optx-widget .bg-\\[var\\(--optimex-primary\\)\\]{background-color:var(--optimex-primary)}.optx-widget .bg-\\[var\\(--optimex-surface\\)\\]{background-color:var(--optimex-surface)}.optx-widget .bg-\\[var\\(--optimex-surface-hover\\)\\]{background-color:var(--optimex-surface-hover)}.optx-widget .bg-black\\/60{background-color:#0009}.optx-widget .bg-blue-500\\/20{background-color:#3b82f633}.optx-widget .bg-green-500\\/10{background-color:#22c55e1a}.optx-widget .bg-orange-500\\/20{background-color:#f9731633}.optx-widget .bg-purple-500\\/20{background-color:#a855f733}.optx-widget .bg-red-500\\/10{background-color:#ef44441a}.optx-widget .bg-transparent{background-color:transparent}.optx-widget .bg-white\\/10{background-color:#ffffff1a}.optx-widget .bg-white\\/20{background-color:#fff3}.optx-widget .bg-white\\/5{background-color:#ffffff0d}.optx-widget .bg-white\\/\\[0\\.02\\]{background-color:#ffffff05}.optx-widget .bg-yellow-500\\/10{background-color:#eab3081a}.optx-widget .stroke-\\[var\\(--optimex-error\\)\\]{stroke:var(--optimex-error)}.optx-widget .p-0{padding:0}.optx-widget .p-1{padding:.25rem}.optx-widget .p-1\\.5{padding:.375rem}.optx-widget .p-2{padding:.5rem}.optx-widget .p-3{padding:.75rem}.optx-widget .p-4{padding:1rem}.optx-widget .p-6{padding:1.5rem}.optx-widget .px-1\\.5{padding-left:.375rem;padding-right:.375rem}.optx-widget .px-2{padding-left:.5rem;padding-right:.5rem}.optx-widget .px-2\\.5{padding-left:.625rem;padding-right:.625rem}.optx-widget .px-3{padding-left:.75rem;padding-right:.75rem}.optx-widget .px-4{padding-left:1rem;padding-right:1rem}.optx-widget .px-6{padding-left:1.5rem;padding-right:1.5rem}.optx-widget .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.optx-widget .py-1{padding-top:.25rem;padding-bottom:.25rem}.optx-widget .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.optx-widget .py-12{padding-top:3rem;padding-bottom:3rem}.optx-widget .py-2{padding-top:.5rem;padding-bottom:.5rem}.optx-widget .py-3{padding-top:.75rem;padding-bottom:.75rem}.optx-widget .py-4{padding-top:1rem;padding-bottom:1rem}.optx-widget .py-8{padding-top:2rem;padding-bottom:2rem}.optx-widget .py-\\[6px\\]{padding-top:6px;padding-bottom:6px}.optx-widget .pb-3{padding-bottom:.75rem}.optx-widget .pb-4{padding-bottom:1rem}.optx-widget .pl-10{padding-left:2.5rem}.optx-widget .pr-10{padding-right:2.5rem}.optx-widget .pr-3{padding-right:.75rem}.optx-widget .pt-2{padding-top:.5rem}.optx-widget .pt-3{padding-top:.75rem}.optx-widget .text-left{text-align:left}.optx-widget .text-center{text-align:center}.optx-widget .text-2xl{font-size:1.5rem;line-height:2rem}.optx-widget .text-\\[10px\\]{font-size:10px}.optx-widget .text-base{font-size:1rem;line-height:1.5rem}.optx-widget .text-lg{font-size:1.125rem;line-height:1.75rem}.optx-widget .text-sm{font-size:.875rem;line-height:1.25rem}.optx-widget .text-xl{font-size:1.25rem;line-height:1.75rem}.optx-widget .text-xs{font-size:.75rem;line-height:1rem}.optx-widget .font-bold{font-weight:700}.optx-widget .font-medium{font-weight:500}.optx-widget .font-semibold{font-weight:600}.optx-widget .uppercase{text-transform:uppercase}.optx-widget .lowercase{text-transform:lowercase}.optx-widget .leading-none{line-height:1}.optx-widget .tracking-tight{letter-spacing:-.025em}.optx-widget .tracking-wider{letter-spacing:.05em}.optx-widget .text-\\[var\\(--optimex-error\\)\\]{color:var(--optimex-error)}.optx-widget .text-\\[var\\(--optimex-primary\\)\\]{color:var(--optimex-primary)}.optx-widget .text-\\[var\\(--optimex-success\\)\\]{color:var(--optimex-success)}.optx-widget .text-\\[var\\(--optimex-text\\)\\]{color:var(--optimex-text)}.optx-widget .text-\\[var\\(--optimex-text-secondary\\)\\]{color:var(--optimex-text-secondary)}.optx-widget .text-\\[var\\(--optimex-warning\\)\\]{color:var(--optimex-warning)}.optx-widget .text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.optx-widget .text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.optx-widget .text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.optx-widget .text-orange-400{--tw-text-opacity: 1;color:rgb(251 146 60 / var(--tw-text-opacity, 1))}.optx-widget .text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.optx-widget .text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.optx-widget .text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.optx-widget .text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.optx-widget .opacity-0{opacity:0}.optx-widget .opacity-50{opacity:.5}.optx-widget .opacity-70{opacity:.7}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .outline-none{outline:2px solid transparent;outline-offset:2px}.optx-widget .blur{--tw-blur: blur(8px);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)}.optx-widget .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)}.optx-widget .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)}.optx-widget .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .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}.optx-widget .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.optx-widget .duration-200{transition-duration:.2s}.optx-widget .duration-300{transition-duration:.3s}.optx-widget{--optimex-primary: #ed6300;--optimex-background: hsla(0, 0%, 100%, .04);--optimex-surface: hsla(0, 0%, 0%, .2);--optimex-text: #ffffff;--optimex-text-secondary: hsla(0, 0%, 100%, .48);--optimex-error: #ff4d4f;--optimex-success: #52c41a;--optimex-overlay-background: #343b47;--optimex-overlay-radius: .75rem;--optimex-radius-widget: 1rem;--optimex-radius-input: .75rem;--optimex-radius-button: .5rem;--optimex-font-family: "Inter", sans-serif;isolation:isolate;width:100%;min-width:0;max-width:100%;--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: ;font-family:var(--optimex-font-family);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 .widget-container{background:var(--optimex-background);border:1px solid rgba(255,255,255,.05);border-radius:var(--optimex-radius-widget);-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;-webkit-appearance:none;-moz-appearance:none;appearance:none}.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}.optx-widget .glow-orange{box-shadow:inset 0 0 15px #eb620026,0 0 20px #eb62001a}.optx-widget .glow-green{box-shadow:0 0 12px #22c55e33}.optx-widget .glow-red{box-shadow:0 0 12px #ef444433}@keyframes optx-status-pulse{0%,to{opacity:1}50%{opacity:.5}}.optx-widget .status-pulse{animation:optx-status-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes modal-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes modal-overlay-out{0%{opacity:1}to{opacity:0}}@keyframes modal-content-in{0%{opacity:0;transform:translate(-50%,-46%)}to{opacity:1;transform:translate(-50%,-50%)}}@keyframes modal-content-out{0%{opacity:1;transform:translate(-50%,-50%)}to{opacity:0;transform:translate(-50%,-46%)}}.animate-modal-overlay-in{animation:modal-overlay-in .25s cubic-bezier(.16,1,.3,1)}.animate-modal-overlay-out{animation:modal-overlay-out .2s cubic-bezier(.16,1,.3,1)}.animate-modal-in{animation:modal-content-in .3s cubic-bezier(.16,1,.3,1)}.animate-modal-out{animation:modal-content-out .2s cubic-bezier(.16,1,.3,1)}@keyframes optx-shiny-text{0%{background-position:-200% center}to{background-position:200% center}}.optx-widget .shiny-text{background:linear-gradient(90deg,var(--optimex-text-secondary) 0%,var(--optimex-text-secondary) 40%,var(--optimex-text) 50%,var(--optimex-text-secondary) 60%,var(--optimex-text-secondary) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:optx-shiny-text 2s linear infinite}.optx-widget .collapsible-grid{display:grid;transition:grid-template-rows .2s ease-out}.optx-widget .collapsible-grid[data-state=closed]{grid-template-rows:0fr}.optx-widget .collapsible-grid[data-state=open]{grid-template-rows:1fr}.optx-widget .collapsible-content{overflow:hidden}.optx-widget .placeholder\\:text-\\[var\\(--optimex-text-secondary\\)\\]::-moz-placeholder{color:var(--optimex-text-secondary)}.optx-widget .placeholder\\:text-\\[var\\(--optimex-text-secondary\\)\\]::placeholder{color:var(--optimex-text-secondary)}.optx-widget .focus-within\\:border-\\[var\\(--optimex-primary\\)\\]:focus-within{border-color:var(--optimex-primary)}.optx-widget .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))}.optx-widget .hover\\:border-\\[var\\(--optimex-primary\\)\\]:hover{border-color:var(--optimex-primary)}.optx-widget .hover\\:bg-\\[rgba\\(239\\,68\\,68\\,0\\.2\\)\\]:hover{background-color:#ef444433}.optx-widget .hover\\:bg-\\[var\\(--optimex-primary-hover\\)\\]:hover{background-color:var(--optimex-primary-hover)}.optx-widget .hover\\:bg-\\[var\\(--optimex-surface-hover\\)\\]:hover{background-color:var(--optimex-surface-hover)}.optx-widget .hover\\:bg-white\\/10:hover{background-color:#ffffff1a}.optx-widget .hover\\:bg-white\\/5:hover{background-color:#ffffff0d}.optx-widget .hover\\:bg-white\\/\\[0\\.02\\]:hover{background-color:#ffffff05}.optx-widget .hover\\:text-\\[var\\(--optimex-primary\\)\\]:hover{color:var(--optimex-primary)}.optx-widget .hover\\:text-\\[var\\(--optimex-text\\)\\]:hover{color:var(--optimex-text)}.optx-widget .hover\\:text-\\[var\\(--optimex-text-secondary\\)\\]:hover{color:var(--optimex-text-secondary)}.optx-widget .hover\\:opacity-100:hover{opacity:1}.optx-widget .hover\\:opacity-70:hover{opacity:.7}.optx-widget .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)}.optx-widget .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)}.optx-widget .focus\\:border-\\[var\\(--optimex-primary\\)\\]:focus{border-color:var(--optimex-primary)}.optx-widget .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.optx-widget .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)}.optx-widget .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))}.optx-widget .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))}.optx-widget .disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.optx-widget :is(.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))}.optx-widget :is(.group:hover .group-hover\\:opacity-100){opacity:1}@media(min-width:640px){.optx-widget .sm\\:text-left{text-align:left}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),x=require("react"),ss=require("react-dom");function os(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const g=os(x),Zo=os(ss);var At=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ye=typeof window>"u"||"Deno"in globalThis;function Ne(){}function Xo(e,t){return typeof e=="function"?e(t):e}function Hr(e){return typeof e=="number"&&e>=0&&e!==1/0}function as(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vt(e,t){return typeof e=="function"?e(t):e}function Re(e,t){return typeof e=="function"?e(t):e}function bn(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:c,stale:i}=e;if(c){if(n){if(t.queryHash!==nn(c,t.options))return!1}else if(!Rt(t.queryKey,c))return!1}if(r!=="all"){const u=t.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function yn(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Tt(t.options.mutationKey)!==Tt(a))return!1}else if(!Rt(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function nn(e,t){return(t?.queryKeyHashFn||Tt)(e)}function Tt(e){return JSON.stringify(e,(t,r)=>qr(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Rt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(r=>!Rt(e[r],t[r])):!1}function Vr(e,t){if(e===t)return e;const r=wn(e)&&wn(t);if(r||qr(e)&&qr(t)){const n=r?e:Object.keys(e),s=n.length,a=r?t:Object.keys(t),c=a.length,i=r?[]:{};let u=0;for(let d=0;d<c;d++){const f=r?d:a[d];(!r&&n.includes(f)||r)&&e[f]===void 0&&t[f]===void 0?(i[f]=void 0,u++):(i[f]=Vr(e[f],t[f]),i[f]===e[f]&&e[f]!==void 0&&u++)}return s===c&&u===s?e:i}return t}function Ur(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function wn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qr(e){if(!Cn(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Cn(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Cn(e){return Object.prototype.toString.call(e)==="[object Object]"}function Jo(e){return new Promise(t=>{setTimeout(t,e)})}function Qr(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Vr(e,t)}catch(n){console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`)}return Vr(e,t)}return t}function ea(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function ta(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var mr=Symbol();function is(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===mr&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===mr?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ra=class extends At{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!Ye&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},sn=new ra,na=class extends At{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!Ye&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#t}},pr=new na;function Kr(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}function sa(e){return Math.min(1e3*2**e,3e4)}function ls(e){return(e??"online")==="online"?pr.isOnline():!0}var cs=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function kr(e){return e instanceof cs}function us(e){let t=!1,r=0,n=!1,s;const a=Kr(),c=m=>{n||(p(new cs(m)),e.abort?.())},i=()=>{t=!0},u=()=>{t=!1},d=()=>sn.isFocused()&&(e.networkMode==="always"||pr.isOnline())&&e.canRun(),f=()=>ls(e.networkMode)&&e.canRun(),h=m=>{n||(n=!0,e.onSuccess?.(m),s?.(),a.resolve(m))},p=m=>{n||(n=!0,e.onError?.(m),s?.(),a.reject(m))},y=()=>new Promise(m=>{s=w=>{(n||d())&&m(w)},e.onPause?.()}).then(()=>{s=void 0,n||e.onContinue?.()}),v=()=>{if(n)return;let m;const w=r===0?e.initialPromise:void 0;try{m=w??e.fn()}catch(b){m=Promise.reject(b)}Promise.resolve(m).then(h).catch(b=>{if(n)return;const R=e.retry??(Ye?0:3),T=e.retryDelay??sa,k=typeof T=="function"?T(r,b):T,A=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,b);if(t||!A){p(b);return}r++,e.onFail?.(r,b),Jo(k).then(()=>d()?void 0:y()).then(()=>{t?p(b):v()})})};return{promise:a,cancel:c,continue:()=>(s?.(),a),cancelRetry:i,continueRetry:u,canStart:f,start:()=>(f()?v():y().then(v),a)}}function oa(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=i=>setTimeout(i,0);const a=i=>{t?e.push(i):s(()=>{r(i)})},c=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(u=>{r(u)})})})};return{batch:i=>{let u;t++;try{u=i()}finally{t--,t||c()}return u},batchCalls:i=>(...u)=>{a(()=>{i(...u)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var pe=oa(),ds=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Hr(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ye?1/0:300*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},aa=class extends ds{#t;#e;#n;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#n=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=ia(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const r=Qr(this.state.data,e,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#s({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(Ne).catch(Ne):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Re(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===mr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!as(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const i=this.observers.find(u=>u.options.queryFn);i&&this.setOptions(i.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,n=i=>{Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(this.#o=!0,r.signal)})},s=()=>{const i=is(this.options,t),u={queryKey:this.queryKey,meta:this.meta};return n(u),this.#o=!1,this.options.persister?this.options.persister(i,u,this):i(u)},a={fetchOptions:t,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};n(a),this.options.behavior?.onFetch(a,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:"fetch",meta:a.fetchOptions?.meta});const c=i=>{kr(i)&&i.silent||this.#s({type:"error",error:i}),kr(i)||(this.#n.config.onError?.(i,this),this.#n.config.onSettled?.(this.state.data,i,this)),this.scheduleGc()};return this.#r=us({initialPromise:t?.initialPromise,fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:i=>{if(i===void 0){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(i)}catch(u){c(u);return}this.#n.config.onSuccess?.(i,this),this.#n.config.onSettled?.(i,this.state.error,this),this.scheduleGc()},onError:c,onFail:(i,u)=>{this.#s({type:"failed",failureCount:i,error:u})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}),this.#r.start()}#s(e){const t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...fs(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return kr(n)&&n.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),pe.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function fs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ls(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ia(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var la=class extends At{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,r){const n=t.queryKey,s=t.queryHash??nn(n,t);let a=this.get(s);return a||(a=new aa({cache:this,queryKey:n,queryHash:s,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){pe.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(r=>bn(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>bn(e,r)):t}notify(e){pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){pe.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){pe.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ca=class extends ds{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||ua(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=us({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,s)=>{this.#r({type:"failed",failureCount:n,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",r=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:r}),await this.#e.config.onMutate?.(e,this);const s=await this.options.onMutate?.(e);s!==this.state.context&&this.#r({type:"pending",context:s,variables:e,isPaused:r})}const n=await this.#n.start();return await this.#e.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#e.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#r({type:"success",data:n}),n}catch(n){try{throw await this.#e.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#e.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#r({type:"error",error:n})}}finally{this.#e.runNext(this)}}#r(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),pe.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function ua(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var da=class extends At{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,r){const n=new ca({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#t.add(e);const t=rr(e);if(typeof t=="string"){const r=this.#e.get(t);r?r.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=rr(e);if(typeof t=="string"){const r=this.#e.get(t);if(r)if(r.length>1){const n=r.indexOf(e);n!==-1&&r.splice(n,1)}else r[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=rr(e);if(typeof t=="string"){const n=this.#e.get(t)?.find(s=>s.state.status==="pending");return!n||n===e}else return!0}runNext(e){const t=rr(e);return typeof t=="string"?this.#e.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){pe.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(r=>yn(t,r))}findAll(e={}){return this.getAll().filter(t=>yn(e,t))}notify(e){pe.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return pe.batch(()=>Promise.all(e.map(t=>t.continue().catch(Ne))))}};function rr(e){return e.options.scope?.id}function kn(e){return{onFetch:(t,r)=>{const n=t.options,s=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],c=t.state.data?.pageParams||[];let i={pages:[],pageParams:[]},u=0;const d=async()=>{let f=!1;const h=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(t.signal.aborted?f=!0:t.signal.addEventListener("abort",()=>{f=!0}),t.signal)})},p=is(t.options,t.fetchOptions),y=async(v,m,w)=>{if(f)return Promise.reject();if(m==null&&v.pages.length)return Promise.resolve(v);const b={queryKey:t.queryKey,pageParam:m,direction:w?"backward":"forward",meta:t.options.meta};h(b);const R=await p(b),{maxPages:T}=t.options,k=w?ta:ea;return{pages:k(v.pages,R,T),pageParams:k(v.pageParams,m,T)}};if(s&&a.length){const v=s==="backward",m=v?fa:jn,w={pages:a,pageParams:c},b=m(n,w);i=await y(w,b,v)}else{const v=e??a.length;do{const m=u===0?c[0]??n.initialPageParam:jn(n,i);if(u>0&&m==null)break;i=await y(i,m),u++}while(u<v)}return i};t.options.persister?t.fetchFn=()=>t.options.persister?.(d,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=d}}}function jn(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function fa(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ha=class{#t;#e;#n;#r;#a;#o;#s;#i;constructor(e={}){this.#t=e.queryCache||new la,this.#e=e.mutationCache||new da,this.#n=e.defaultOptions||{},this.#r=new Map,this.#a=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#s=sn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#i=pr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#s?.(),this.#s=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=this.#t.build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(vt(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),a=this.#t.get(n.queryHash)?.state.data,c=Xo(t,a);if(c!==void 0)return this.#t.build(this,n).setData(c,{...r,manual:!0})}setQueriesData(e,t,r){return pe.batch(()=>this.#t.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;pe.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#t,n={type:"active",...e};return pe.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries(n,t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=pe.batch(()=>this.#t.findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(Ne).catch(Ne)}invalidateQueries(e,t={}){return pe.batch(()=>{if(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none")return Promise.resolve();const r={...e,type:e?.refetchType??e?.type??"active"};return this.refetchQueries(r,t)})}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=pe.batch(()=>this.#t.findAll(e).filter(s=>!s.isDisabled()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(Ne)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(Ne)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=this.#t.build(this,t);return r.isStaleByTime(vt(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ne).catch(Ne)}fetchInfiniteQuery(e){return e.behavior=kn(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ne).catch(Ne)}ensureInfiniteQueryData(e){return e.behavior=kn(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return pr.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Tt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],r={};return t.forEach(n=>{Rt(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){this.#a.set(Tt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#a.values()];let r={};return t.forEach(n=>{Rt(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=nn(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===mr&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},ma=class extends At{constructor(e,t){super(),this.options=t,this.#t=e,this.#i=null,this.#s=Kr(),this.options.experimental_prefetchInRender||this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#a;#o;#s;#i;#p;#f;#h;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Sn(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Gr(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Gr(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e,t){const r=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Re(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),r._defaulted&&!Ur(this.options,r)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const s=this.hasListeners();s&&En(this.#e,n,this.options,r)&&this.#d(),this.updateResult(t),s&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(r.enabled,this.#e)||vt(this.options.staleTime,this.#e)!==vt(r.staleTime,this.#e))&&this.#x();const a=this.#v();s&&(this.#e!==n||Re(this.options.enabled,this.#e)!==Re(r.enabled,this.#e)||a!==this.#l)&&this.#g(a)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),r=this.createResult(t,e);return xa(this,r)&&(this.#r=r,this.#o=this.options,this.#a=this.#e.state),r}getCurrentResult(){return this.#r}trackResult(e,t){const r={};return Object.keys(e).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),t?.(n),e[n])})}),r}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),r=this.#t.getQueryCache().build(this.#t,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Ne)),t}#x(){this.#y();const e=vt(this.options.staleTime,this.#e);if(Ye||this.#r.isStale||!Hr(e))return;const r=as(this.#r.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#r.isStale||this.updateResult()},r)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(e){this.#w(),this.#l=e,!(Ye||Re(this.options.enabled,this.#e)===!1||!Hr(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||sn.isFocused())&&this.#d()},this.#l))}#b(){this.#x(),this.#g(this.#v())}#y(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const r=this.#e,n=this.options,s=this.#r,a=this.#a,c=this.#o,u=e!==r?e.state:this.#n,{state:d}=e;let f={...d},h=!1,p;if(t._optimisticResults){const j=this.hasListeners(),N=!j&&Sn(e,t),M=j&&En(e,r,t,n);(N||M)&&(f={...f,...fs(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:m}=f;if(t.select&&f.data!==void 0)if(s&&f.data===a?.data&&t.select===this.#p)p=this.#f;else try{this.#p=t.select,p=t.select(f.data),p=Qr(s?.data,p,t),this.#f=p,this.#i=null}catch(j){this.#i=j}else p=f.data;if(t.placeholderData!==void 0&&p===void 0&&m==="pending"){let j;if(s?.isPlaceholderData&&t.placeholderData===c?.placeholderData)j=s.data;else if(j=typeof t.placeholderData=="function"?t.placeholderData(this.#h?.state.data,this.#h):t.placeholderData,t.select&&j!==void 0)try{j=t.select(j),this.#i=null}catch(N){this.#i=N}j!==void 0&&(m="success",p=Qr(s?.data,j,t),h=!0)}this.#i&&(y=this.#i,p=this.#f,v=Date.now(),m="error");const w=f.fetchStatus==="fetching",b=m==="pending",R=m==="error",T=b&&w,k=p!==void 0,L={status:m,fetchStatus:f.fetchStatus,isPending:b,isSuccess:m==="success",isError:R,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:f.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!b,isLoadingError:R&&!k,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:R&&k,isStale:on(e,t),refetch:this.refetch,promise:this.#s};if(this.options.experimental_prefetchInRender){const j=U=>{L.status==="error"?U.reject(L.error):L.data!==void 0&&U.resolve(L.data)},N=()=>{const U=this.#s=L.promise=Kr();j(U)},M=this.#s;switch(M.status){case"pending":e.queryHash===r.queryHash&&j(M);break;case"fulfilled":(L.status==="error"||L.data!==M.value)&&N();break;case"rejected":(L.status!=="error"||L.error!==M.reason)&&N();break}}return L}updateResult(e){const t=this.#r,r=this.createResult(this.#e,this.options);if(this.#a=this.#e.state,this.#o=this.options,this.#a.data!==void 0&&(this.#h=this.#e),Ur(r,t))return;this.#r=r;const n={},s=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,c=typeof a=="function"?a():a;if(c==="all"||!c&&!this.#m.size)return!0;const i=new Set(c??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#r).some(u=>{const d=u;return this.#r[d]!==t[d]&&i.has(d)})};e?.listeners!==!1&&s()&&(n.listeners=!0),this.#k({...n,...e})}#C(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#k(e){pe.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function pa(e,t){return Re(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Sn(e,t){return pa(e,t)||e.state.data!==void 0&&Gr(e,t,t.refetchOnMount)}function Gr(e,t,r){if(Re(t.enabled,e)!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&on(e,t)}return!1}function En(e,t,r,n){return(e!==t||Re(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&on(e,r)}function on(e,t){return Re(t.enabled,e)!==!1&&e.isStaleByTime(vt(t.staleTime,e))}function xa(e,t){return!Ur(e.getCurrentResult(),t)}var hs=g.createContext(void 0),va=e=>{const t=g.useContext(hs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ga=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),o.jsx(hs.Provider,{value:e,children:t})),ms=g.createContext(!1),ba=()=>g.useContext(ms);ms.Provider;function ya(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var wa=g.createContext(ya()),Ca=()=>g.useContext(wa);function ka(e,t){return typeof e=="function"?e(...t):!!e}function Nn(){}var ja=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Sa=e=>{g.useEffect(()=>{e.clearReset()},[e])},Ea=({result:e,errorResetBoundary:t,throwOnError:r,query:n})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&ka(r,[e.error,n]),Na=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...r)=>Math.max(t(...r),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},Ta=(e,t)=>e.isLoading&&e.isFetching&&!t,Ra=(e,t)=>e?.suspense&&t.isPending,Tn=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function Oa(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=va(),s=ba(),a=Ca(),c=n.defaultQueryOptions(e);n.getDefaultOptions().queries?._experimental_beforeQuery?.(c),c._optimisticResults=s?"isRestoring":"optimistic",Na(c),ja(c,a),Sa(a);const i=!n.getQueryCache().get(c.queryHash),[u]=g.useState(()=>new t(n,c)),d=u.getOptimisticResult(c),f=!s&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(h=>{const p=f?u.subscribe(pe.batchCalls(h)):Nn;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(c,{listeners:!1})},[c,u]),Ra(c,d))throw Tn(c,u,a);if(Ea({result:d,errorResetBoundary:a,throwOnError:c.throwOnError,query:n.getQueryCache().get(c.queryHash)}))throw d.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(c,d),c.experimental_prefetchInRender&&!Ye&&Ta(d,s)&&(i?Tn(c,u,a):n.getQueryCache().get(c.queryHash)?.promise)?.catch(Nn).finally(()=>{u.updateResult()}),c.notifyOnChangeProps?d:u.trackResult(d)}function bt(e,t){return Oa(e,ma)}const _a={widget:"1rem",input:"0.75rem",button:"0.5rem"},Aa={primary:"#ffffff",secondary:"hsla(0, 0%, 100%, 0.48)"},Ma={background:"#343b47",radius:"0.75rem"},Ce={colors:{primary:"#ed6300",background:"hsla(0, 0%, 100%, 0.04)",surface:"hsla(0, 0%, 0%, 0.2)",text:Aa,error:"#ff4d4f",success:"#52c41a"},radius:_a,overlay:Ma,fontFamily:"'Inter', sans-serif"},ps=x.createContext(null);function Pa({children:e,theme:t}){const r=x.useMemo(()=>t?{colors:{primary:t.colors?.primary??Ce.colors.primary,background:t.colors?.background??Ce.colors.background,surface:t.colors?.surface??Ce.colors.surface,text:{primary:t.colors?.text?.primary??Ce.colors.text.primary,secondary:t.colors?.text?.secondary??Ce.colors.text.secondary},error:t.colors?.error??Ce.colors.error,success:t.colors?.success??Ce.colors.success},radius:{widget:t.radius?.widget??Ce.radius.widget,input:t.radius?.input??Ce.radius.input,button:t.radius?.button??Ce.radius.button},overlay:{background:t.overlay?.background??Ce.overlay.background,radius:t.overlay?.radius??Ce.overlay.radius},fontFamily:t.fontFamily??Ce.fontFamily}:Ce,[t]),n=x.useMemo(()=>({"--optimex-primary":r.colors.primary,"--optimex-background":r.colors.background,"--optimex-surface":r.colors.surface,"--optimex-text":r.colors.text.primary,"--optimex-text-secondary":r.colors.text.secondary,"--optimex-error":r.colors.error,"--optimex-success":r.colors.success,"--optimex-radius-widget":r.radius.widget,"--optimex-radius-input":r.radius.input,"--optimex-radius-button":r.radius.button,"--optimex-overlay-background":r.overlay.background,"--optimex-overlay-radius":r.overlay.radius,"--optimex-font-family":r.fontFamily}),[r]);return o.jsx(ps.Provider,{value:{theme:r},children:o.jsx("div",{style:n,className:"w-full",children:e})})}function Ia(){const e=x.useContext(ps);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const xs=x.createContext(null);function Da({children:e,externalWalletClient:t,onRequestWallet:r}){const n=x.useMemo(()=>{const s=t?.evm?.address??null,a=t?.evm?.chain?.id??null,c=t?.btc?.address??null,i=t?.btc?.publicKey??null,u=t?.solana?.address??null,d=!!s,f=!!c,h=!!u;return{mode:"external",isExternalWallet:!0,isConnected:d||f||h,evmAddress:s,evmChainId:a,isEvmConnected:d,btcAddress:c,btcPublicKey:i,isBtcConnected:f,solanaAddress:u,isSolanaConnected:h,externalWalletClient:t,onRequestWallet:r,isConnecting:!1}},[t,r]);return o.jsx(xs.Provider,{value:n,children:e})}class jr extends Error{status;code;constructor(t,r,n){super(r),this.name="ApiError",this.status=t,this.code=n}}class vs{baseUrl;headers;constructor(t){this.baseUrl=t.replace(/\/$/,""),this.headers={"Content-Type":"application/json"}}async request(t,r,n){const s=`${this.baseUrl}${r}`;try{const a=await fetch(s,{method:t,headers:this.headers,body:n?JSON.stringify(n):void 0});if(!a.ok){const i=await a.json().catch(()=>({}));throw new jr(a.status,i.message||`Request failed with status ${a.status}`,i.code)}return(await a.json()).data}catch(a){throw a instanceof jr?a:new jr(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,r){return this.request("POST","/v2/trades/submit-tx",{trade_id:t,tx_id:r})}async getTrade(t){return this.request("GET",`/v2/trades/${t}`)}async getTokenPrice(t){return this.request("GET",`/v2/tokens/${t}`)}async listTrades(t={}){const r=new URLSearchParams;t.limit&&r.set("limit",String(t.limit)),t.page&&r.set("page",String(t.page)),t.state&&r.set("state",t.state),t.from_user_address?.length&&t.from_user_address.forEach(a=>r.append("from_user_address",a)),t.to_user_address?.length&&t.to_user_address.forEach(a=>r.append("to_user_address",a));const n=r.toString(),s=n?`/v2/trades?${n}`:"/v2/trades";return this.request("GET",s)}}let xt=null;function yt(e){if(!xt&&e&&(xt=new vs(e)),!xt)throw new Error("API not initialized. Please provide baseUrl.");return xt}function La(e){return xt=new vs(e),xt}const Fa=["tokens"];function Ba(e){return bt({queryKey:Fa,queryFn:async()=>yt(e).getTokens(),staleTime:300*1e3,gcTime:1800*1e3,retry:3,retryDelay:t=>Math.min(1e3*2**t,3e4)})}const $a=2e4,za=1e4,ie={EVM:"EVM",BTC:"BTC",SOLANA:"Solana"};function Wa(e,t=4){return e?e.length<=t*2+3?e:`${e.slice(0,t+2)}...${e.slice(-t)}`:""}function Ha(e,t,r=6){if(!e)return"0";let n;typeof e=="bigint"?n=e:typeof e=="string"?n=BigInt(e):n=BigInt(Math.floor(e));const s=BigInt(10**t),a=n/s,c=n%s;if(c===0n)return a.toString();const u=c.toString().padStart(t,"0").slice(0,r).replace(/0+$/,"");return u?`${a}.${u}`:a.toString()}function gs(e,t){if(!e||e==="0")return 0n;const[r,n=""]=e.split("."),s=n.slice(0,t).padEnd(t,"0"),a=r+s;return BigInt(a)}function ze(e,t=18,r=6){if(!e)return"0";const n=String(e);if(n.includes(".")||!Number.isInteger(Number(n))){const s=parseFloat(n);return isNaN(s)?"0":s.toFixed(r).replace(/\.?0+$/,"")}return Ha(n,t,r)}function Va(e,t){if(!t||!e||isNaN(parseFloat(e)))return"$0.00";const r=parseFloat(e);if(r===0)return"$0.00";const n=r*t;return n<.01?"<$0.01":n<1?`$${n.toFixed(4)}`:n<1e3?`$${n.toFixed(2)}`:n<1e6?`$${(n/1e3).toFixed(2)}K`:`$${(n/1e6).toFixed(2)}M`}var Ua=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sr={exports:{}};var Rn;function qa(){return Rn||(Rn=1,(function(e){(function(){var t="input is invalid type",r="finalize already called",n=typeof window=="object",s=n?window:{};s.JS_SHA3_NO_WINDOW&&(n=!1);var a=!n&&typeof self=="object",c=!s.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;c?s=Ua:a&&(s=self);for(var i=!s.JS_SHA3_NO_COMMON_JS&&!0&&e.exports,u=!s.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),f=[31,7936,2031616,520093696],h=[4,1024,262144,67108864],p=[1,256,65536,16777216],y=[6,1536,393216,100663296],v=[0,8,16,24],m=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],w=[224,256,384,512],b=[128,256],R=["hex","buffer","arrayBuffer","array","digest"],T={128:168,256:136},k=s.JS_SHA3_NO_NODE_JS||!Array.isArray?function(l){return Object.prototype.toString.call(l)==="[object Array]"}:Array.isArray,A=u&&(s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(l){return typeof l=="object"&&l.buffer&&l.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,L=function(l){var C=typeof l;if(C==="string")return[l,!0];if(C!=="object"||l===null)throw new Error(t);if(u&&l.constructor===ArrayBuffer)return[new Uint8Array(l),!1];if(!k(l)&&!A(l))throw new Error(t);return[l,!1]},j=function(l){return L(l)[0].length===0},N=function(l){for(var C=[],S=0;S<l.length;++S)C[S]=l[S];return C},M=function(l,C,S){return function(O){return new F(l,C,l).update(O)[S]()}},U=function(l,C,S){return function(O,E){return new F(l,C,E).update(O)[S]()}},W=function(l,C,S){return function(O,E,$,H){return oe["cshake"+l].update(O,E,$,H)[S]()}},K=function(l,C,S){return function(O,E,$,H){return oe["kmac"+l].update(O,E,$,H)[S]()}},D=function(l,C,S,O){for(var E=0;E<R.length;++E){var $=R[E];l[$]=C(S,O,$)}return l},X=function(l,C){var S=M(l,C,"hex");return S.create=function(){return new F(l,C,l)},S.update=function(O){return S.create().update(O)},D(S,M,l,C)},J=function(l,C){var S=U(l,C,"hex");return S.create=function(O){return new F(l,C,O)},S.update=function(O,E){return S.create(E).update(O)},D(S,U,l,C)},re=function(l,C){var S=T[l],O=W(l,C,"hex");return O.create=function(E,$,H){return j($)&&j(H)?oe["shake"+l].create(E):new F(l,C,E).bytepad([$,H],S)},O.update=function(E,$,H,B){return O.create($,H,B).update(E)},D(O,W,l,C)},te=function(l,C){var S=T[l],O=K(l,C,"hex");return O.create=function(E,$,H){return new ke(l,C,$).bytepad(["KMAC",H],S).bytepad([E],S)},O.update=function(E,$,H,B){return O.create(E,H,B).update($)},D(O,K,l,C)},_=[{name:"keccak",padding:p,bits:w,createMethod:X},{name:"sha3",padding:y,bits:w,createMethod:X},{name:"shake",padding:f,bits:b,createMethod:J},{name:"cshake",padding:h,bits:b,createMethod:re},{name:"kmac",padding:h,bits:b,createMethod:te}],oe={},me=[],xe=0;xe<_.length;++xe)for(var ve=_[xe],Y=ve.bits,ne=0;ne<Y.length;++ne){var ye=ve.name+"_"+Y[ne];if(me.push(ye),oe[ye]=ve.createMethod(Y[ne],ve.padding),ve.name!=="sha3"){var Te=ve.name+Y[ne];me.push(Te),oe[Te]=oe[ye]}}function F(l,C,S){this.blocks=[],this.s=[],this.padding=C,this.outputBits=S,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(l<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=S>>5,this.extraBytes=(S&31)>>3;for(var O=0;O<50;++O)this.s[O]=0}F.prototype.update=function(l){if(this.finalized)throw new Error(r);var C=L(l);l=C[0];for(var S=C[1],O=this.blocks,E=this.byteCount,$=l.length,H=this.blockCount,B=0,le=this.s,V,ee;B<$;){if(this.reset)for(this.reset=!1,O[0]=this.block,V=1;V<H+1;++V)O[V]=0;if(S)for(V=this.start;B<$&&V<E;++B)ee=l.charCodeAt(B),ee<128?O[V>>2]|=ee<<v[V++&3]:ee<2048?(O[V>>2]|=(192|ee>>6)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]):ee<55296||ee>=57344?(O[V>>2]|=(224|ee>>12)<<v[V++&3],O[V>>2]|=(128|ee>>6&63)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]):(ee=65536+((ee&1023)<<10|l.charCodeAt(++B)&1023),O[V>>2]|=(240|ee>>18)<<v[V++&3],O[V>>2]|=(128|ee>>12&63)<<v[V++&3],O[V>>2]|=(128|ee>>6&63)<<v[V++&3],O[V>>2]|=(128|ee&63)<<v[V++&3]);else for(V=this.start;B<$&&V<E;++B)O[V>>2]|=l[B]<<v[V++&3];if(this.lastByteIndex=V,V>=E){for(this.start=V-E,this.block=O[H],V=0;V<H;++V)le[V]^=O[V];we(le),this.reset=!0}else this.start=V}return this},F.prototype.encode=function(l,C){var S=l&255,O=1,E=[S];for(l=l>>8,S=l&255;S>0;)E.unshift(S),l=l>>8,S=l&255,++O;return C?E.push(O):E.unshift(O),this.update(E),E.length},F.prototype.encodeString=function(l){var C=L(l);l=C[0];var S=C[1],O=0,E=l.length;if(S)for(var $=0;$<l.length;++$){var H=l.charCodeAt($);H<128?O+=1:H<2048?O+=2:H<55296||H>=57344?O+=3:(H=65536+((H&1023)<<10|l.charCodeAt(++$)&1023),O+=4)}else O=E;return O+=this.encode(O*8),this.update(l),O},F.prototype.bytepad=function(l,C){for(var S=this.encode(C),O=0;O<l.length;++O)S+=this.encodeString(l[O]);var E=(C-S%C)%C,$=[];return $.length=E,this.update($),this},F.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var l=this.blocks,C=this.lastByteIndex,S=this.blockCount,O=this.s;if(l[C>>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(l[0]=l[S],C=1;C<S+1;++C)l[C]=0;for(l[S-1]|=2147483648,C=0;C<S;++C)O[C]^=l[C];we(O)}},F.prototype.toString=F.prototype.hex=function(){this.finalize();for(var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H="",B;$<S;){for(E=0;E<l&&$<S;++E,++$)B=C[E],H+=d[B>>4&15]+d[B&15]+d[B>>12&15]+d[B>>8&15]+d[B>>20&15]+d[B>>16&15]+d[B>>28&15]+d[B>>24&15];$%l===0&&(C=N(C),we(C),E=0)}return O&&(B=C[E],H+=d[B>>4&15]+d[B&15],O>1&&(H+=d[B>>12&15]+d[B>>8&15]),O>2&&(H+=d[B>>20&15]+d[B>>16&15])),H},F.prototype.arrayBuffer=function(){this.finalize();var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H=this.outputBits>>3,B;O?B=new ArrayBuffer(S+1<<2):B=new ArrayBuffer(H);for(var le=new Uint32Array(B);$<S;){for(E=0;E<l&&$<S;++E,++$)le[$]=C[E];$%l===0&&(C=N(C),we(C))}return O&&(le[$]=C[E],B=B.slice(0,H)),B},F.prototype.buffer=F.prototype.arrayBuffer,F.prototype.digest=F.prototype.array=function(){this.finalize();for(var l=this.blockCount,C=this.s,S=this.outputBlocks,O=this.extraBytes,E=0,$=0,H=[],B,le;$<S;){for(E=0;E<l&&$<S;++E,++$)B=$<<2,le=C[E],H[B]=le&255,H[B+1]=le>>8&255,H[B+2]=le>>16&255,H[B+3]=le>>24&255;$%l===0&&(C=N(C),we(C))}return O&&(B=$<<2,le=C[E],H[B]=le&255,O>1&&(H[B+1]=le>>8&255),O>2&&(H[B+2]=le>>16&255)),H};function ke(l,C,S){F.call(this,l,C,S)}ke.prototype=new F,ke.prototype.finalize=function(){return this.encode(this.outputBits,!0),F.prototype.finalize.call(this)};var we=function(l){var C,S,O,E,$,H,B,le,V,ee,We,tt,_e,rt,He,nt,st,Pe,ot,Ve,at,Ae,Ue,it,lt,ct,ut,dt,z,G,Z,Q,se,de,ce,je,ge,Ee,Se,be,Ie,qe,It,Dt,Lt,Ft,Bt,$t,zt,Wt,Ht,Vt,Ut,qt,Qt,Kt,Gt,Yt,Zt,Xt,Jt,er,tr;for(O=0;O<48;O+=2)E=l[0]^l[10]^l[20]^l[30]^l[40],$=l[1]^l[11]^l[21]^l[31]^l[41],H=l[2]^l[12]^l[22]^l[32]^l[42],B=l[3]^l[13]^l[23]^l[33]^l[43],le=l[4]^l[14]^l[24]^l[34]^l[44],V=l[5]^l[15]^l[25]^l[35]^l[45],ee=l[6]^l[16]^l[26]^l[36]^l[46],We=l[7]^l[17]^l[27]^l[37]^l[47],tt=l[8]^l[18]^l[28]^l[38]^l[48],_e=l[9]^l[19]^l[29]^l[39]^l[49],C=tt^(H<<1|B>>>31),S=_e^(B<<1|H>>>31),l[0]^=C,l[1]^=S,l[10]^=C,l[11]^=S,l[20]^=C,l[21]^=S,l[30]^=C,l[31]^=S,l[40]^=C,l[41]^=S,C=E^(le<<1|V>>>31),S=$^(V<<1|le>>>31),l[2]^=C,l[3]^=S,l[12]^=C,l[13]^=S,l[22]^=C,l[23]^=S,l[32]^=C,l[33]^=S,l[42]^=C,l[43]^=S,C=H^(ee<<1|We>>>31),S=B^(We<<1|ee>>>31),l[4]^=C,l[5]^=S,l[14]^=C,l[15]^=S,l[24]^=C,l[25]^=S,l[34]^=C,l[35]^=S,l[44]^=C,l[45]^=S,C=le^(tt<<1|_e>>>31),S=V^(_e<<1|tt>>>31),l[6]^=C,l[7]^=S,l[16]^=C,l[17]^=S,l[26]^=C,l[27]^=S,l[36]^=C,l[37]^=S,l[46]^=C,l[47]^=S,C=ee^(E<<1|$>>>31),S=We^($<<1|E>>>31),l[8]^=C,l[9]^=S,l[18]^=C,l[19]^=S,l[28]^=C,l[29]^=S,l[38]^=C,l[39]^=S,l[48]^=C,l[49]^=S,rt=l[0],He=l[1],Ft=l[11]<<4|l[10]>>>28,Bt=l[10]<<4|l[11]>>>28,dt=l[20]<<3|l[21]>>>29,z=l[21]<<3|l[20]>>>29,Xt=l[31]<<9|l[30]>>>23,Jt=l[30]<<9|l[31]>>>23,qe=l[40]<<18|l[41]>>>14,It=l[41]<<18|l[40]>>>14,de=l[2]<<1|l[3]>>>31,ce=l[3]<<1|l[2]>>>31,nt=l[13]<<12|l[12]>>>20,st=l[12]<<12|l[13]>>>20,$t=l[22]<<10|l[23]>>>22,zt=l[23]<<10|l[22]>>>22,G=l[33]<<13|l[32]>>>19,Z=l[32]<<13|l[33]>>>19,er=l[42]<<2|l[43]>>>30,tr=l[43]<<2|l[42]>>>30,qt=l[5]<<30|l[4]>>>2,Qt=l[4]<<30|l[5]>>>2,je=l[14]<<6|l[15]>>>26,ge=l[15]<<6|l[14]>>>26,Pe=l[25]<<11|l[24]>>>21,ot=l[24]<<11|l[25]>>>21,Wt=l[34]<<15|l[35]>>>17,Ht=l[35]<<15|l[34]>>>17,Q=l[45]<<29|l[44]>>>3,se=l[44]<<29|l[45]>>>3,it=l[6]<<28|l[7]>>>4,lt=l[7]<<28|l[6]>>>4,Kt=l[17]<<23|l[16]>>>9,Gt=l[16]<<23|l[17]>>>9,Ee=l[26]<<25|l[27]>>>7,Se=l[27]<<25|l[26]>>>7,Ve=l[36]<<21|l[37]>>>11,at=l[37]<<21|l[36]>>>11,Vt=l[47]<<24|l[46]>>>8,Ut=l[46]<<24|l[47]>>>8,Dt=l[8]<<27|l[9]>>>5,Lt=l[9]<<27|l[8]>>>5,ct=l[18]<<20|l[19]>>>12,ut=l[19]<<20|l[18]>>>12,Yt=l[29]<<7|l[28]>>>25,Zt=l[28]<<7|l[29]>>>25,be=l[38]<<8|l[39]>>>24,Ie=l[39]<<8|l[38]>>>24,Ae=l[48]<<14|l[49]>>>18,Ue=l[49]<<14|l[48]>>>18,l[0]=rt^~nt&Pe,l[1]=He^~st&ot,l[10]=it^~ct&dt,l[11]=lt^~ut&z,l[20]=de^~je&Ee,l[21]=ce^~ge&Se,l[30]=Dt^~Ft&$t,l[31]=Lt^~Bt&zt,l[40]=qt^~Kt&Yt,l[41]=Qt^~Gt&Zt,l[2]=nt^~Pe&Ve,l[3]=st^~ot&at,l[12]=ct^~dt&G,l[13]=ut^~z&Z,l[22]=je^~Ee&be,l[23]=ge^~Se&Ie,l[32]=Ft^~$t&Wt,l[33]=Bt^~zt&Ht,l[42]=Kt^~Yt&Xt,l[43]=Gt^~Zt&Jt,l[4]=Pe^~Ve&Ae,l[5]=ot^~at&Ue,l[14]=dt^~G&Q,l[15]=z^~Z&se,l[24]=Ee^~be&qe,l[25]=Se^~Ie&It,l[34]=$t^~Wt&Vt,l[35]=zt^~Ht&Ut,l[44]=Yt^~Xt&er,l[45]=Zt^~Jt&tr,l[6]=Ve^~Ae&rt,l[7]=at^~Ue&He,l[16]=G^~Q&it,l[17]=Z^~se<,l[26]=be^~qe&de,l[27]=Ie^~It&ce,l[36]=Wt^~Vt&Dt,l[37]=Ht^~Ut&Lt,l[46]=Xt^~er&qt,l[47]=Jt^~tr&Qt,l[8]=Ae^~rt&nt,l[9]=Ue^~He&st,l[18]=Q^~it&ct,l[19]=se^~lt&ut,l[28]=qe^~de&je,l[29]=It^~ce&ge,l[38]=Vt^~Dt&Ft,l[39]=Ut^~Lt&Bt,l[48]=er^~qt&Kt,l[49]=tr^~Qt&Gt,l[0]^=m[O],l[1]^=m[O+1]};if(i)e.exports=oe;else for(xe=0;xe<me.length;++xe)s[me[xe]]=oe[me[xe]]})()})(Sr)),Sr.exports}var Qa=qa();function Ka(e){const t=e.slice(2).toLowerCase(),r=Qa.keccak256(t);for(let n=0;n<40;n++){const s=parseInt(r[n],16),a=t[n];if(s>=8){if(e[n+2]!==a.toUpperCase())return!1}else if(e[n+2]!==a.toLowerCase())return!1}return!0}function Ga(e){return/^0x[a-fA-F0-9]{40}$/.test(e)?/^0x[0-9a-f]{40}$/.test(e)||/^0x[0-9A-F]{40}$/.test(e)?!0:Ka(e):!1}function Ya(e){return/^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[a-z0-9]{39,59}$/.test(e)}function Za(e){return/^[mn2][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(tb1)[a-z0-9]{39,59}$/.test(e)}function Xa(e){return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e)}function an(e,t,r){const n=e.trim();if(!n)return{isValid:!1,error:"Address is required"};switch(t){case ie.EVM:return Ga(n)?{isValid:!0}:{isValid:!1,error:`Invalid ${r} wallet address`};case ie.BTC:if(r==="bitcoin_testnet"){if(!Za(n))return{isValid:!1,error:`Invalid ${r} wallet address`}}else if(!Ya(n))return{isValid:!1,error:`Invalid ${r} wallet address`};return{isValid:!0};case ie.SOLANA:return Xa(n)?{isValid:!0}:{isValid:!1,error:`Invalid ${r} wallet address`};default:return{isValid:!1,error:`Unsupported network type: ${t}`}}}const Ja=e=>["quote",e];function ei(e,{from_token:t,to_token:r,amount:n,from_user_address:s,to_user_address:a,user_refund_pubkey:c,slippage:i="100",affiliate_fee_bps:u,affiliate_info:d,trade_timeout:f,script_timeout:h,enabled:p=!0,onQuote:y}){const v=r&&a?an(a,r.network_type,r.network_id).isValid:!1,m=t&&r&&n&&parseFloat(n)>0&&s&&a&&c&&v;return bt({queryKey:Ja({from_token:t,to_token:r,amount:n,from_user_address:s,to_user_address:a,user_refund_pubkey:c,slippage:i}),queryFn:async()=>{const w=yt(e),b=gs(n,t.token_decimals).toString(),R=await w.createQuote({from_token_id:t.token_id,to_token_id:r.token_id,amount_in:b,slippage:i,from_user_address:s,to_user_address:a,user_refund_pubkey:c,affiliate_fee_bps:u,affiliate_info:d,trade_timeout:f,script_timeout:h});return y?.({quote:R,from_token:t,to_token:r,amount_in:n}),R},enabled:p&&!!m,staleTime:za,refetchInterval:$a,retry:2,retryDelay:1e3})}const bs=x.createContext(null);function ti({children:e,value:t}){return o.jsx(bs.Provider,{value:t,children:e})}function Mt(){const e=x.useContext(bs);if(!e)throw new Error("useWidgetConfig must be used within SwapWidget");return e}function ri({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 ni(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 ln({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 ys({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 ws({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 si({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 Ze({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 oi(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 ai(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 ii({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 li(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 ci(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 ui(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 di(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 fi(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 hi({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 mi({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 Cs(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 On({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 ks(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 js(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 Ss(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 Es(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 Ns(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 Ts(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 Rs(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 _n={bitcoin:ks,solana:js,ethereum:Ss,base:Es,arbitrum:Ns,optimism:Ts,bsc:Rs};function pi(e){if(!e)return null;const t=e.toLowerCase().replace(/[\s_-]/g,"");return t in _n?_n[t]:t.includes("bitcoin")||t.includes("btc")?ks:t.includes("solana")||t.includes("sol")?js:t.includes("ethereum")||t.includes("eth")||t.includes("erc20")?Ss:t.includes("base")?Es:t.includes("arbitrum")||t.includes("arb")?Ns:t.includes("optimism")||t.includes("op")?Ts:t.includes("bsc")||t.includes("binance")||t.includes("bnb")?Rs:null}function xi(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function vi({icon:e,label:t,address:r,className:n=""}){const[s,a]=x.useState(!1),c=x.useCallback(async()=>{try{await navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3)}catch{console.error("Failed to copy")}},[r]);return o.jsxs("div",{className:`flex items-center justify-between px-4 py-3 ${n}`,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:xi(r)}),o.jsx("button",{onClick:c,className:"p-1 rounded hover:bg-white/10 transition-colors",title:s?"Copied!":"Copy",children:s?o.jsx(ln,{className:"size-4 text-[var(--optimex-success)]"}):o.jsx(oi,{className:"size-4 text-[var(--optimex-text-secondary)]"})})]})]})}const gi={primary:"bg-[var(--optimex-primary)] text-black hover:brightness-110 shadow-lg shadow-[var(--optimex-primary)]/30",secondary:"bg-[var(--optimex-surface)] text-[var(--optimex-text)] hover:bg-white/10 border border-white/10",ghost:"bg-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 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"},bi={sm:"px-3 py-1.5 text-xs rounded-[var(--optimex-radius-button)] gap-1.5 max-h-[2rem]",md:"px-4 py-2 text-sm rounded-[var(--optimex-radius-button)] gap-2 max-h-[2.5rem]",lg:"px-6 py-3 text-sm rounded-[var(--optimex-radius-button)] gap-2 max-h-[3rem]",xl:"px-6 py-4 text-sm rounded-[var(--optimex-radius-button)] gap-2"};function cn({variant:e="primary",size:t="md",fullWidth:r=!1,isLoading:n=!1,leftIcon:s,rightIcon:a,children:c,className:i="",disabled:u,...d}){const f=u||n;return o.jsxs("button",{className:`
|
|
3
3
|
group flex items-center justify-center font-semibold transition-all active:scale-[0.98]
|
|
4
4
|
${gi[e]}
|
|
5
5
|
${bi[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 g.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},$c="DialogDescriptionWarning",zc=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jo($c).contentName}}.`;return g.useEffect(()=>{const s=e.current?.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},So=uo,Eo=mo,No=po,To=xo,Ro=go,Oo=yo,_o=Co;function Wc(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}const Ao=x.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}),Pt=()=>{const e=x.useContext(Ao);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};Wc(`[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 Hc(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Vc(){return mn(/^Mac/)}function Uc(){return mn(/^iPhone/)}function Yn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function qc(){return mn(/^iPad/)||Vc()&&navigator.maxTouchPoints>1}function Mo(){return Uc()||qc()}function mn(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Qc=24,Kc=typeof window<"u"?x.useLayoutEffect:x.useEffect;function Zn(...e){return(...t)=>{for(let r of e)typeof r=="function"&&r(...t)}}const Dr=typeof document<"u"&&window.visualViewport;function Xn(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Po(e){for(Xn(e)&&(e=e.parentElement);e&&!Xn(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Gc=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let ur=0,Lr;function Yc(e={}){let{isDisabled:t}=e;Kc(()=>{if(!t)return ur++,ur===1&&Mo()&&(Lr=Zc()),()=>{ur--,ur===0&&Lr?.()}},[t])}function Zc(){let e,t=0,r=h=>{e=Po(h.target),!(e===document.documentElement&&e===document.body)&&(t=h.changedTouches[0].pageY)},n=h=>{if(!e||e===document.documentElement||e===document.body){h.preventDefault();return}let p=h.changedTouches[0].pageY,y=e.scrollTop,v=e.scrollHeight-e.clientHeight;v!==0&&((y<=0&&p>t||y>=v&&p<t)&&h.preventDefault(),t=p)},s=h=>{let p=h.target;Jr(p)&&p!==document.activeElement&&(h.preventDefault(),p.style.transform="translateY(-2000px)",p.focus(),requestAnimationFrame(()=>{p.style.transform=""}))},a=h=>{let p=h.target;Jr(p)&&(p.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{p.style.transform="",Dr&&(Dr.height<window.innerHeight?requestAnimationFrame(()=>{Jn(p)}):Dr.addEventListener("resize",()=>Jn(p),{once:!0}))}))},c=()=>{window.scrollTo(0,0)},i=window.pageXOffset,u=window.pageYOffset,d=Zn(Xc(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let f=Zn(St(document,"touchstart",r,{passive:!1,capture:!0}),St(document,"touchmove",n,{passive:!1,capture:!0}),St(document,"touchend",s,{passive:!1,capture:!0}),St(document,"focus",a,!0),St(window,"scroll",c));return()=>{d(),f(),window.scrollTo(i,u)}}function Xc(e,t,r){let n=e.style[t];return e.style[t]=r,()=>{e.style[t]=n}}function St(e,t,r,n){return e.addEventListener(t,r,n),()=>{e.removeEventListener(t,r,n)}}function Jn(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let r=Po(e);if(r!==document.documentElement&&r!==document.body&&r!==e){let n=r.getBoundingClientRect().top,s=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom;const c=r.getBoundingClientRect().bottom+Qc;a>c&&(r.scrollTop+=s-n)}e=r.parentElement}}function Jr(e){return e instanceof HTMLInputElement&&!Gc.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Jc(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function eu(...e){return t=>e.forEach(r=>Jc(r,t))}function Io(...e){return g.useCallback(eu(...e),e)}const Do=new WeakMap;function he(e,t,r=!1){if(!e||!(e instanceof HTMLElement))return;let n={};Object.entries(t).forEach(([s,a])=>{if(s.startsWith("--")){e.style.setProperty(s,a);return}n[s]=e.style[s],e.style[s]=a}),!r&&Do.set(e,n)}function tu(e,t){if(!e||!(e instanceof HTMLElement))return;let r=Do.get(e);r&&(e.style[t]=r[t])}const ue=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function dr(e,t){if(!e)return null;const r=window.getComputedStyle(e),n=r.transform||r.webkitTransform||r.mozTransform;let s=n.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[ue(t)?13:12]):(s=n.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[ue(t)?5:4]):null)}function ru(e){return 8*(Math.log(e+1)-2)}function Fr(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}function nu(...e){return(...t)=>{for(const r of e)typeof r=="function"&&r(...t)}}const ae={DURATION:.5,EASE:[.32,.72,0,1]},Lo=.4,su=.25,ou=100,Fo=8,Ke=16,en=26,Br="vaul-dragging";function Bo(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...r)=>t.current==null?void 0:t.current.call(t,...r),[])}function au({defaultProp:e,onChange:t}){const r=x.useState(e),[n]=r,s=x.useRef(n),a=Bo(t);return x.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),r}function $o({prop:e,defaultProp:t,onChange:r=()=>{}}){const[n,s]=au({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:n,i=Bo(r),u=x.useCallback(d=>{if(a){const h=typeof d=="function"?d(e):d;h!==e&&i(h)}else s(d)},[a,e,s,i]);return[c,u]}function iu({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:r,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:c,direction:i="bottom",container:u,snapToSequentialPoint:d}){const[f,h]=$o({prop:e,defaultProp:r?.[0],onChange:t}),[p,y]=x.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);x.useEffect(()=>{function j(){y({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]);const v=x.useMemo(()=>f===r?.[r.length-1]||null,[r,f]),m=x.useMemo(()=>{var j;return(j=r?.findIndex(N=>N===f))!=null?j:null},[r,f]),w=r&&r.length>0&&(a||a===0)&&!Number.isNaN(a)&&r[a]===f||!r,b=x.useMemo(()=>{const j=u?{width:u.getBoundingClientRect().width,height:u.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var N;return(N=r?.map(M=>{const U=typeof M=="string";let W=0;if(U&&(W=parseInt(M,10)),ue(i)){const D=U?W:p?M*j.height:0;return p?i==="bottom"?j.height-D:-j.height+D:D}const K=U?W:p?M*j.width:0;return p?i==="right"?j.width-K:-j.width+K:K}))!=null?N:[]},[r,p,u]),R=x.useMemo(()=>m!==null?b?.[m]:null,[b,m]),T=x.useCallback(j=>{var N;const M=(N=b?.findIndex(U=>U===j))!=null?N:null;c(M),he(n.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(i)?`translate3d(0, ${j}px, 0)`:`translate3d(${j}px, 0, 0)`}),b&&M!==b.length-1&&a!==void 0&&M!==a&&M<a?he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"0"}):he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),h(r?.[Math.max(M,0)])},[n.current,r,b,a,s,h]);x.useEffect(()=>{if(f||e){var j;const N=(j=r?.findIndex(M=>M===e||M===f))!=null?j:-1;b&&N!==-1&&typeof b[N]=="number"&&T(b[N])}},[f,e,r,b,T]);function k({draggedDistance:j,closeDrawer:N,velocity:M,dismissible:U}){if(a===void 0)return;const W=i==="bottom"||i==="right"?(R??0)-j:(R??0)+j,K=m===a-1,D=m===0,X=j>0;if(K&&he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),!d&&M>2&&!X){U?N():T(b[0]);return}if(!d&&M>2&&X&&b&&r){T(b[r.length-1]);return}const J=b?.reduce((te,_)=>typeof te!="number"||typeof _!="number"?te:Math.abs(_-W)<Math.abs(te-W)?_:te),re=ue(i)?window.innerHeight:window.innerWidth;if(M>Lo&&Math.abs(j)<re*.4){const te=X?1:-1;if(te>0&&v&&r){T(b[r.length-1]);return}if(D&&te<0&&U&&N(),m===null)return;T(b[m+te]);return}T(J)}function A({draggedDistance:j}){if(R===null)return;const N=i==="bottom"||i==="right"?R-j:R+j;(i==="bottom"||i==="right")&&N<b[b.length-1]||(i==="top"||i==="left")&&N>b[b.length-1]||he(n.current,{transform:ue(i)?`translate3d(0, ${N}px, 0)`:`translate3d(${N}px, 0, 0)`})}function L(j,N){if(!r||typeof m!="number"||!b||a===void 0)return null;const M=m===a-1;if(m>=a&&N)return 0;if(M&&!N)return 1;if(!w&&!M)return null;const W=M?m+1:m-1,K=M?b[W]-b[W-1]:b[W+1]-b[W],D=j/Math.abs(K);return M?1-D:D}return{isLastSnapPoint:v,activeSnapPoint:f,shouldFade:w,getPercentageDragged:L,setActiveSnapPoint:h,activeSnapPointIndex:m,onRelease:k,onDrag:A,snapPointsOffset:b}}const lu=()=>()=>{};function cu(){const{direction:e,isOpen:t,shouldScaleBackground:r,setBackgroundColorOnScale:n,noBodyStyles:s}=Pt(),a=x.useRef(null),c=x.useMemo(()=>document.body.style.backgroundColor,[]);function i(){return(window.innerWidth-en)/window.innerWidth}x.useEffect(()=>{if(t&&r){a.current&&clearTimeout(a.current);const u=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!u)return;nu(n&&!s?Fr(document.body,{background:"black"}):lu,Fr(u,{transformOrigin:ue(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`}));const d=Fr(u,{borderRadius:`${Fo}px`,overflow:"hidden",...ue(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(()=>{c?document.body.style.background=c:document.body.style.removeProperty("background")},ae.DURATION*1e3)}}},[t,r,c])}let Et=null;function uu({isOpen:e,modal:t,nested:r,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[c,i]=x.useState(()=>typeof window<"u"?window.location.href:""),u=x.useRef(0),d=x.useCallback(()=>{if(Yn()&&Et===null&&e&&!a){Et={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:h,innerHeight:p}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-u.current}px`,left:`${-h}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const y=p-window.innerHeight;y&&u.current>=p&&(document.body.style.top=`${-(u.current+y)}px`)}),300)}},[e]),f=x.useCallback(()=>{if(Yn()&&Et!==null&&!a){const h=-parseInt(document.body.style.top,10),p=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Et),window.requestAnimationFrame(()=>{if(s&&c!==window.location.href){i(window.location.href);return}window.scrollTo(p,h)}),Et=null}},[c]);return x.useEffect(()=>{function h(){u.current=window.scrollY}return h(),window.addEventListener("scroll",h),()=>{window.removeEventListener("scroll",h)}},[]),x.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||f()}},[t,f]),x.useEffect(()=>{r||!n||(e?(!window.matchMedia("(display-mode: standalone)").matches&&d(),t||window.setTimeout(()=>{f()},500)):f())},[e,n,c,t,r,d,f]),{restorePositionSetting:f}}function du({open:e,onOpenChange:t,children:r,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:c=!1,setBackgroundColorOnScale:i=!0,closeThreshold:u=su,scrollLockTimeout:d=ou,dismissible:f=!0,handleOnly:h=!1,fadeFromIndex:p=a&&a.length-1,activeSnapPoint:y,setActiveSnapPoint:v,fixed:m,modal:w=!0,onClose:b,nested:R,noBodyStyles:T=!1,direction:k="bottom",defaultOpen:A=!1,disablePreventScroll:L=!0,snapToSequentialPoint:j=!1,preventScrollRestoration:N=!1,repositionInputs:M=!0,onAnimationEnd:U,container:W,autoFocus:K=!1}){var D,X;const[J=!1,re]=$o({defaultProp:A,prop:e,onChange:z=>{t?.(z),!z&&!R&&st(),setTimeout(()=>{U?.(z)},ae.DURATION*1e3),z&&!w&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),z||(document.body.style.pointerEvents="auto")}}),[te,_]=x.useState(!1),[oe,me]=x.useState(!1),[xe,ve]=x.useState(!1),Y=x.useRef(null),ne=x.useRef(null),ye=x.useRef(null),Te=x.useRef(null),F=x.useRef(null),ke=x.useRef(!1),we=x.useRef(null),l=x.useRef(0),C=x.useRef(!1),S=x.useRef(!A),O=x.useRef(0),E=x.useRef(null),$=x.useRef(((D=E.current)==null?void 0:D.getBoundingClientRect().height)||0),H=x.useRef(((X=E.current)==null?void 0:X.getBoundingClientRect().width)||0),B=x.useRef(0),le=x.useCallback(z=>{a&&z===_e.length-1&&(ne.current=new Date)},[]),{activeSnapPoint:V,activeSnapPointIndex:ee,setActiveSnapPoint:We,onRelease:tt,snapPointsOffset:_e,onDrag:rt,shouldFade:He,getPercentageDragged:nt}=iu({snapPoints:a,activeSnapPointProp:y,setActiveSnapPointProp:v,drawerRef:E,fadeFromIndex:p,overlayRef:Y,onSnapPointChange:le,direction:k,container:W,snapToSequentialPoint:j});Yc({isDisabled:!J||oe||!w||xe||!te||!M||!L});const{restorePositionSetting:st}=uu({isOpen:J,modal:w,nested:R??!1,hasBeenOpened:te,preventScrollRestoration:N,noBodyStyles:T});function Pe(){return(window.innerWidth-en)/window.innerWidth}function ot(z){var G,Z;!f&&!a||E.current&&!E.current.contains(z.target)||($.current=((G=E.current)==null?void 0:G.getBoundingClientRect().height)||0,H.current=((Z=E.current)==null?void 0:Z.getBoundingClientRect().width)||0,me(!0),ye.current=new Date,Mo()&&window.addEventListener("touchend",()=>ke.current=!1,{once:!0}),z.target.setPointerCapture(z.pointerId),l.current=ue(k)?z.pageY:z.pageX)}function Ve(z,G){var Z;let Q=z;const se=(Z=window.getSelection())==null?void 0:Z.toString(),de=E.current?dr(E.current,k):null,ce=new Date;if(Q.tagName==="SELECT"||Q.hasAttribute("data-vaul-no-drag")||Q.closest("[data-vaul-no-drag]"))return!1;if(k==="right"||k==="left")return!0;if(ne.current&&ce.getTime()-ne.current.getTime()<500)return!1;if(de!==null&&(k==="bottom"?de>0:de<0))return!0;if(se&&se.length>0)return!1;if(F.current&&ce.getTime()-F.current.getTime()<d&&de===0||G)return F.current=ce,!1;for(;Q;){if(Q.scrollHeight>Q.clientHeight){if(Q.scrollTop!==0)return F.current=new Date,!1;if(Q.getAttribute("role")==="dialog")return!0}Q=Q.parentNode}return!0}function at(z){if(E.current&&oe){const G=k==="bottom"||k==="right"?1:-1,Z=(l.current-(ue(k)?z.pageY:z.pageX))*G,Q=Z>0,se=a&&!f&&!Q;if(se&&ee===0)return;const de=Math.abs(Z),ce=document.querySelector("[data-vaul-drawer-wrapper]"),je=k==="bottom"||k==="top"?$.current:H.current;let ge=de/je;const Ee=nt(de,Q);if(Ee!==null&&(ge=Ee),se&&ge>=1||!ke.current&&!Ve(z.target,Q))return;if(E.current.classList.add(Br),ke.current=!0,he(E.current,{transition:"none"}),he(Y.current,{transition:"none"}),a&&rt({draggedDistance:Z}),Q&&!a){const be=ru(Z),Ie=Math.min(be*-1,0)*G;he(E.current,{transform:ue(k)?`translate3d(0, ${Ie}px, 0)`:`translate3d(${Ie}px, 0, 0)`});return}const Se=1-ge;if((He||p&&ee===p-1)&&(n?.(z,ge),he(Y.current,{opacity:`${Se}`,transition:"none"},!0)),ce&&Y.current&&c){const be=Math.min(Pe()+ge*(1-Pe()),1),Ie=8-ge*8,qe=Math.max(0,14-ge*14);he(ce,{borderRadius:`${Ie}px`,transform:ue(k)?`scale(${be}) translate3d(0, ${qe}px, 0)`:`scale(${be}) translate3d(${qe}px, 0, 0)`,transition:"none"},!0)}if(!a){const be=de*G;he(E.current,{transform:ue(k)?`translate3d(0, ${be}px, 0)`:`translate3d(${be}px, 0, 0)`})}}}x.useEffect(()=>{window.requestAnimationFrame(()=>{S.current=!0})},[]),x.useEffect(()=>{var z;function G(){if(!E.current||!M)return;const Z=document.activeElement;if(Jr(Z)||C.current){var Q;const se=((Q=window.visualViewport)==null?void 0:Q.height)||0,de=window.innerHeight;let ce=de-se;const je=E.current.getBoundingClientRect().height||0,ge=je>de*.8;B.current||(B.current=je);const Ee=E.current.getBoundingClientRect().top;if(Math.abs(O.current-ce)>60&&(C.current=!C.current),a&&a.length>0&&_e&&ee){const Se=_e[ee]||0;ce+=Se}if(O.current=ce,je>se||C.current){const Se=E.current.getBoundingClientRect().height;let be=Se;Se>se&&(be=se-(ge?Ee:en)),m?E.current.style.height=`${Se-Math.max(ce,0)}px`:E.current.style.height=`${Math.max(be,se-Ee)}px`}else Hc()||(E.current.style.height=`${B.current}px`);a&&a.length>0&&!C.current?E.current.style.bottom="0px":E.current.style.bottom=`${Math.max(ce,0)}px`}}return(z=window.visualViewport)==null||z.addEventListener("resize",G),()=>{var Z;return(Z=window.visualViewport)==null?void 0:Z.removeEventListener("resize",G)}},[ee,a,_e]);function Ae(z){it(),b?.(),z||re(!1),setTimeout(()=>{a&&We(a[0])},ae.DURATION*1e3)}function Ue(){if(!E.current)return;const z=document.querySelector("[data-vaul-drawer-wrapper]"),G=dr(E.current,k);he(E.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),he(Y.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),c&&G&&G>0&&J&&he(z,{borderRadius:`${Fo}px`,overflow:"hidden",...ue(k)?{transform:`scale(${Pe()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${Pe()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`},!0)}function it(){!oe||!E.current||(E.current.classList.remove(Br),ke.current=!1,me(!1),Te.current=new Date)}function lt(z){if(!oe||!E.current)return;E.current.classList.remove(Br),ke.current=!1,me(!1),Te.current=new Date;const G=dr(E.current,k);if(!z||!Ve(z.target,!1)||!G||Number.isNaN(G)||ye.current===null)return;const Z=Te.current.getTime()-ye.current.getTime(),Q=l.current-(ue(k)?z.pageY:z.pageX),se=Math.abs(Q)/Z;if(se>.05&&(ve(!0),setTimeout(()=>{ve(!1)},200)),a){tt({draggedDistance:Q*(k==="bottom"||k==="right"?1:-1),closeDrawer:Ae,velocity:se,dismissible:f}),s?.(z,!0);return}if(k==="bottom"||k==="right"?Q>0:Q<0){Ue(),s?.(z,!0);return}if(se>Lo){Ae(),s?.(z,!1);return}var de;const ce=Math.min((de=E.current.getBoundingClientRect().height)!=null?de:0,window.innerHeight);var je;const ge=Math.min((je=E.current.getBoundingClientRect().width)!=null?je:0,window.innerWidth),Ee=k==="left"||k==="right";if(Math.abs(G)>=(Ee?ge:ce)*u){Ae(),s?.(z,!1);return}s?.(z,!0),Ue()}x.useEffect(()=>(J&&(he(document.documentElement,{scrollBehavior:"auto"}),ne.current=new Date),()=>{tu(document.documentElement,"scrollBehavior")}),[J]);function ct(z){const G=z?(window.innerWidth-Ke)/window.innerWidth:1,Z=z?-Ke:0;we.current&&window.clearTimeout(we.current),he(E.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(k)?`scale(${G}) translate3d(0, ${Z}px, 0)`:`scale(${G}) translate3d(${Z}px, 0, 0)`}),!z&&E.current&&(we.current=setTimeout(()=>{const Q=dr(E.current,k);he(E.current,{transition:"none",transform:ue(k)?`translate3d(0, ${Q}px, 0)`:`translate3d(${Q}px, 0, 0)`})},500))}function ut(z,G){if(G<0)return;const Z=(window.innerWidth-Ke)/window.innerWidth,Q=Z+G*(1-Z),se=-Ke+G*Ke;he(E.current,{transform:ue(k)?`scale(${Q}) translate3d(0, ${se}px, 0)`:`scale(${Q}) translate3d(${se}px, 0, 0)`,transition:"none"})}function dt(z,G){const Z=ue(k)?window.innerHeight:window.innerWidth,Q=G?(Z-Ke)/Z:1,se=G?-Ke:0;G&&he(E.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(k)?`scale(${Q}) translate3d(0, ${se}px, 0)`:`scale(${Q}) translate3d(${se}px, 0, 0)`})}return x.useEffect(()=>{w||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[w]),x.createElement(So,{defaultOpen:A,onOpenChange:z=>{!f&&!z||(z?_(!0):Ae(!0),re(z))},open:J},x.createElement(Ao.Provider,{value:{activeSnapPoint:V,snapPoints:a,setActiveSnapPoint:We,drawerRef:E,overlayRef:Y,onOpenChange:t,onPress:ot,onRelease:lt,onDrag:at,dismissible:f,shouldAnimate:S,handleOnly:h,isOpen:J,isDragging:oe,shouldFade:He,closeDrawer:Ae,onNestedDrag:ut,onNestedOpenChange:ct,onNestedRelease:dt,keyboardIsOpen:C,modal:w,snapPointsOffset:_e,activeSnapPointIndex:ee,direction:k,shouldScaleBackground:c,setBackgroundColorOnScale:i,noBodyStyles:T,container:W,autoFocus:K}},r))}const zo=x.forwardRef(function({...e},t){const{overlayRef:r,snapPoints:n,onRelease:s,shouldFade:a,isOpen:c,modal:i,shouldAnimate:u}=Pt(),d=Io(t,r),f=n&&n.length>0;if(!i)return null;const h=x.useCallback(p=>s(p),[s]);return x.createElement(No,{onMouseUp:h,ref:d,"data-vaul-overlay":"","data-vaul-snap-points":c&&f?"true":"false","data-vaul-snap-points-overlay":c&&a?"true":"false","data-vaul-animate":u?.current?"true":"false",...e})});zo.displayName="Drawer.Overlay";const Wo=x.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:r,...n},s){const{drawerRef:a,onPress:c,onRelease:i,onDrag:u,keyboardIsOpen:d,snapPointsOffset:f,activeSnapPointIndex:h,modal:p,isOpen:y,direction:v,snapPoints:m,container:w,handleOnly:b,shouldAnimate:R,autoFocus:T}=Pt(),[k,A]=x.useState(!1),L=Io(s,a),j=x.useRef(null),N=x.useRef(null),M=x.useRef(!1),U=m&&m.length>0;cu();const W=(D,X,J=0)=>{if(M.current)return!0;const re=Math.abs(D.y),te=Math.abs(D.x),_=te>re,oe=["bottom","right"].includes(X)?1:-1;if(X==="left"||X==="right"){if(!(D.x*oe<0)&&te>=0&&te<=J)return _}else if(!(D.y*oe<0)&&re>=0&&re<=J)return!_;return M.current=!0,!0};x.useEffect(()=>{U&&window.requestAnimationFrame(()=>{A(!0)})},[]);function K(D){j.current=null,M.current=!1,i(D)}return x.createElement(To,{"data-vaul-drawer-direction":v,"data-vaul-drawer":"","data-vaul-delayed-snap-points":k?"true":"false","data-vaul-snap-points":y&&U?"true":"false","data-vaul-custom-container":w?"true":"false","data-vaul-animate":R?.current?"true":"false",...n,ref:L,style:f&&f.length>0?{"--snap-point-height":`${f[h??0]}px`,...t}:t,onPointerDown:D=>{b||(n.onPointerDown==null||n.onPointerDown.call(n,D),j.current={x:D.pageX,y:D.pageY},c(D))},onOpenAutoFocus:D=>{r?.(D),T||D.preventDefault()},onPointerDownOutside:D=>{if(e?.(D),!p||D.defaultPrevented){D.preventDefault();return}d.current&&(d.current=!1)},onFocusOutside:D=>{if(!p){D.preventDefault();return}},onPointerMove:D=>{if(N.current=D,b||(n.onPointerMove==null||n.onPointerMove.call(n,D),!j.current))return;const X=D.pageY-j.current.y,J=D.pageX-j.current.x,re=D.pointerType==="touch"?10:2;W({x:J,y:X},v,re)?u(D):(Math.abs(J)>re||Math.abs(X)>re)&&(j.current=null)},onPointerUp:D=>{n.onPointerUp==null||n.onPointerUp.call(n,D),j.current=null,M.current=!1,i(D)},onPointerOut:D=>{n.onPointerOut==null||n.onPointerOut.call(n,D),K(N.current)},onContextMenu:D=>{n.onContextMenu==null||n.onContextMenu.call(n,D),N.current&&K(N.current)}})});Wo.displayName="Drawer.Content";const fu=250,hu=120,mu=x.forwardRef(function({preventCycle:e=!1,children:t,...r},n){const{closeDrawer:s,isDragging:a,snapPoints:c,activeSnapPoint:i,setActiveSnapPoint:u,dismissible:d,handleOnly:f,isOpen:h,onPress:p,onDrag:y}=Pt(),v=x.useRef(null),m=x.useRef(!1);function w(){if(m.current){T();return}window.setTimeout(()=>{b()},hu)}function b(){if(a||e||m.current){T();return}if(T(),!c||c.length===0){d||s();return}if(i===c[c.length-1]&&d){s();return}const A=c.findIndex(j=>j===i);if(A===-1)return;const L=c[A+1];u(L)}function R(){v.current=window.setTimeout(()=>{m.current=!0},fu)}function T(){v.current&&window.clearTimeout(v.current),m.current=!1}return x.createElement("div",{onClick:w,onPointerCancel:T,onPointerDown:k=>{f&&p(k),R()},onPointerMove:k=>{f&&y(k)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...r},x.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});mu.displayName="Drawer.Handle";function pu(e){const t=Pt(),{container:r=t.container,...n}=e;return x.createElement(Eo,{container:r,...n})}const Ge={Root:du,Content:Wo,Overlay:zo,Portal:pu,Close:_o,Title:Ro,Description:Oo};function xu(e=768){const[t,r]=x.useState(!1);return x.useEffect(()=>{const n=()=>{r(window.innerWidth<e)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]),t}function Nt(...e){return Vs(_s(e))}const vu={position:"fixed",inset:0,zIndex:9999,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"},gu={position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:9999,display:"flex",flexDirection:"column"},bu={position:"fixed",inset:0,zIndex:9999,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"},yu={position:"fixed",left:0,right:0,bottom:0,zIndex:9999,maxHeight:"96vh"};function pn({open:e,onOpenChange:t,children:r,title:n,description:s,className:a="",showCloseButton:c=!0,height:i}){const u=xu(),{theme:d}=Ia(),f={"--optimex-primary":d.colors.primary,"--optimex-background":d.colors.background,"--optimex-surface":d.colors.surface,"--optimex-text":d.colors.text.primary,"--optimex-text-secondary":d.colors.text.secondary,"--optimex-error":d.colors.error,"--optimex-success":d.colors.success,"--optimex-radius-widget":d.radius.widget,"--optimex-radius-input":d.radius.input,"--optimex-radius-button":d.radius.button,"--optimex-overlay-background":d.overlay.background,"--optimex-overlay-radius":d.overlay.radius,"--optimex-font-family":d.fontFamily};return u?o.jsx(Ge.Root,{open:e,onOpenChange:t,children:o.jsxs(Ge.Portal,{children:[o.jsx(Ge.Overlay,{style:bu}),o.jsx(Ge.Content,{style:yu,children:o.jsxs("div",{className:Nt("optx-widget flex flex-col bg-[var(--optimex-overlay-background)] outline-none",a),style:{...f,height:i,maxHeight:"96vh",borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.1)",backgroundColor:d.overlay.background,borderRadius:`${d.overlay.radius} ${d.overlay.radius} 0 0`},children:[o.jsx("div",{className:"mx-auto mt-4 h-1.5 w-12 flex-shrink-0 rounded-full bg-white/20"}),(n||c)&&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:[n&&o.jsx(Ge.Title,{className:"text-lg font-bold text-[var(--optimex-text)]",children:n}),s&&o.jsx(Ge.Description,{className:"text-sm text-[var(--optimex-text-secondary)]",children:s})]}),c&&o.jsx(Ge.Close,{className:"rounded-[var(--optimex-radius-button)] p-1.5 text-[var(--optimex-text-secondary)] transition-colors hover:bg-white/10 hover:text-[var(--optimex-text)]",children:o.jsx(Ze,{})})]}),o.jsx("div",{className:"flex flex-1 flex-col overflow-auto",children:r})]})})]})}):o.jsx(So,{open:e,onOpenChange:t,children:o.jsxs(Eo,{children:[o.jsx(No,{style:vu,className:"animate-modal-overlay-in data-[state=closed]:animate-modal-overlay-out"}),o.jsx(To,{style:{...gu,height:i,maxHeight:i||"85vh"},className:Nt("animate-modal-in data-[state=closed]:animate-modal-out",a),children:o.jsxs("div",{className:Nt("optx-widget flex flex-col rounded-[var(--optimex-overlay-radius)] border border-white/10 bg-[var(--optimex-overlay-background)] shadow-2xl outline-none"),style:{...f,flex:1,minHeight:0,height:"100%",borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.1)",backgroundColor:d.overlay.background,borderRadius:d.overlay.radius},children:[(n||s||c)&&o.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-white/[0.05] p-4",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[n&&o.jsx(Ro,{className:"text-lg font-bold leading-none text-[var(--optimex-text)]",children:n}),s&&o.jsx(Oo,{className:"text-sm text-[var(--optimex-text-secondary)]",children:s})]}),c&&o.jsxs(_o,{className:"rounded-[var(--optimex-radius-button)] p-1.5 text-[var(--optimex-text-secondary)] opacity-70 transition-opacity hover:opacity-100 hover:bg-white/10 focus:outline-none",children:[o.jsx(Ze,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]}),o.jsx("div",{className:"flex flex-1 flex-col overflow-hidden min-h-0",children:r})]})})]})})}const wu=({children:e,className:t=""})=>o.jsx("div",{className:Nt("p-4",t),children:e}),Cu=({children:e,className:t=""})=>o.jsx("div",{className:Nt("flex gap-2 border-t border-white/[0.05] p-4",t),children:e});function tn({children:e,onClick:t,isActive:r=!1,type:n="button",className:s=""}){return o.jsx("button",{type:n,onClick:t,className:Us(`px-2 py-1 bg-white/5 rounded-md text-xs transition-colors shadow-sm border ${r?"border-[var(--optimex-primary)] text-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-[var(--optimex-surface-hover)] hover:text-[var(--optimex-text)]"} ${s}`),children:e})}const ku={"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"},ju={"bottom-right":"-top-2 right-4 rotate-45 border-l border-t border-white/10","bottom-left":"-top-2 left-4 rotate-45 border-l border-t border-white/10","bottom-center":"-top-2 left-1/2 -translate-x-1/2 rotate-45 border-l border-t border-white/10","top-right":"-bottom-2 right-4 rotate-45 border-r border-b border-white/10","top-left":"-bottom-2 left-4 rotate-45 border-r border-b border-white/10","top-center":"-bottom-2 left-1/2 -translate-x-1/2 rotate-45 border-r border-b border-white/10"};function Su({isOpen:e,onClose:t,children:r,anchorRef:n,position:s="bottom-right",width:a="w-72",showArrow:c=!1,className:i="",ariaLabel:u}){const d=x.useRef(null);return x.useEffect(()=>{if(!e)return;const f=y=>{const v=y.target;d.current?.contains(v)||n?.current?.contains(v)||t()},h=y=>{y.key==="Escape"&&t()},p=setTimeout(()=>{document.addEventListener("mousedown",f),document.addEventListener("keydown",h)},0);return()=>{clearTimeout(p),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",h)}},[e,t,n]),e?o.jsxs("div",{ref:d,className:`absolute z-50 rounded-[var(--optimex-overlay-radius)] border border-white/10 bg-[var(--optimex-overlay-background)] p-4 shadow-xl ${ku[s]} ${a} ${i}`,role:"dialog","aria-label":u,children:[c&&o.jsx("div",{className:`absolute h-4 w-4 bg-[var(--optimex-overlay-background)] ${ju[s]}`}),o.jsx("div",{className:"relative",children:r})]}):null}function Eu({value:e,onChange:t,placeholder:r,hasError:n=!1,leftIcon:s,rightContent:a,type:c="text",inputMode:i="text",disabled:u=!1,className:d=""}){return o.jsxs("div",{className:`flex rounded-[var(--optimex-radius-button)] items-center gap-2 bg-white/5 border py-3 px-3 transition-colors ${n?"border-[var(--optimex-error)]":"border-white/10 hover:border-[var(--optimex-primary)] focus-within:border-[var(--optimex-primary)]"} ${u?"opacity-50 cursor-not-allowed":""} ${d}`,children:[s&&o.jsx(s,{className:"size-5 text-[var(--optimex-text-secondary)] shrink-0"}),o.jsx("input",{type:c,inputMode:i,value:e,onChange:f=>t(f.target.value),placeholder:r,disabled:u,className:"flex-1 min-w-0 bg-transparent text-[var(--optimex-text)] text-sm placeholder:text-[var(--optimex-text-secondary)]/30 outline-none disabled:cursor-not-allowed"}),a]})}const Nu={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 Je({token:e,size:t="md",showNetworkBadge:r=!0}){const n=Nu[t];return o.jsxs("div",{className:`relative shrink-0 ${n.container}`,children:[o.jsx("img",{src:e.token_logo_uri||"/placeholder-token.svg",alt:e.token_symbol,className:`${n.icon} rounded-[9999px] bg-[var(--optimex-background)]`,onError:s=>{s.target.src="/placeholder-token.svg"}}),r&&e.network_logo_uri&&o.jsx("img",{src:e.network_logo_uri,alt:e.network_name,className:`absolute -bottom-1 -right-1 ${n.badge} rounded-[9999px] border-2 border-[var(--optimex-surface)]`,onError:s=>{s.target.style.display="none"}})]})}const Tu="widget-container rounded-[var(--optimex-radius-widget)] p-4 shadow-2xl relative w-full min-w-0";function xn({children:e,className:t}){return o.jsx("div",{className:t??Tu,children:e})}function Ru(){return o.jsxs("div",{className:"relative size-20 mb-4",children:[o.jsx("div",{className:"absolute inset-0 rounded-full bg-[var(--optimex-error)]/10 animate-pulse"}),o.jsx("div",{className:"absolute inset-2 rounded-full bg-[var(--optimex-error)]/20"}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx(fi,{className:"size-10 text-[var(--optimex-error)]"})})]})}function Ou({error:e,onRetry:t,className:r}){const n=()=>{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(xn,{className:r,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(Ru,{}),o.jsx("h3",{className:"text-base font-bold text-[var(--optimex-text)] mb-1",children:"Oops! Something went wrong"}),o.jsx("p",{className:"text-sm text-[var(--optimex-text-secondary)] mb-6 max-w-[280px]",children:n()}),o.jsx(cn,{onClick:t,size:"md",fullWidth:!0,leftIcon:o.jsx(di,{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-[var(--optimex-text-secondary)]/60 hover:text-[var(--optimex-text-secondary)] transition-colors",children:"Technical details"}),o.jsx("p",{className:"mt-2 bg-white/5 p-3 text-left text-xs text-[var(--optimex-text-secondary)] break-all border border-white/[0.02]",children:e.message})]})]})})})}function _u({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(xn,{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 Ho=x.createContext(null);function Au({children:e}){const t=Mt(),{data:r,isLoading:n,error:s,refetch:a}=Ba(t.apiBaseUrl),c=t.renderLoading??_u,i=t.renderError??Ou;if(n)return o.jsx(c,{});if(s||!r){const u=s instanceof Error?s:new Error("Failed to load tokens");return o.jsx(i,{error:u,onRetry:()=>a()})}return o.jsx(Ho.Provider,{value:{tokensData:r,refetch:a},children:e})}function Mu(){const e=x.useContext(Ho);if(!e)throw new Error("useTokensData must be used within TokensProvider");return e}function Pu({token:e,value:t,onChange:r,placeholder:n,error:s,onClose:a}){const c=x.useCallback(()=>{r("")},[r]),i=x.useCallback(async()=>{try{const h=await navigator.clipboard.readText();h&&r(h.trim())}catch(h){console.error("Failed to read clipboard:",h)}},[r]),u=()=>n||(e?`Enter ${e.network_name} address`:"Enter receiving address"),d=e?.network_name||"destination",f=x.useMemo(()=>pi(e?.network_name)||Cs,[e?.network_name]);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-[var(--optimex-radius-input)] 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-[var(--optimex-text-secondary)] text-xs",children:"Recipient Address"}),a&&o.jsx("button",{type:"button",onClick:c,className:"text-[var(--optimex-text-secondary)]/50 hover:text-[var(--optimex-text-secondary)] transition-colors",children:o.jsx(Ze,{className:"size-4"})})]}),o.jsx(Eu,{value:t,onChange:r,placeholder:u(),hasError:!!s,leftIcon:f,rightContent:t?o.jsx("button",{type:"button",onClick:c,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors",children:o.jsx(Ze,{className:"size-5"})}):o.jsx("button",{type:"button",onClick:i,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-primary)] transition-colors",children:o.jsx(ui,{className:"size-5"})})}),s?o.jsxs("p",{className:"text-[10px] text-[var(--optimex-error)] mt-2 flex items-center gap-1",children:[o.jsx(On,{className:"size-3"}),s]}):o.jsxs("p",{className:"text-[10px] text-[var(--optimex-text-secondary)] mt-2 flex items-center gap-1",children:[o.jsx(On,{className:"size-3"}),"Ensure the address matches the ",d," network."]})]})}function es({token:e,value:t,onChange:r,readOnly:n=!1,onSelectToken:s,isLoading:a=!1,loadingText:c="Loading...",balance:i,isOutput:u=!1,isWalletConnected:d=!1,usdValue:f="$0.00"}){const h=m=>{if(n||!r)return;const w=m.target.value;/^[0-9]*\.?[0-9]*$/.test(w)&&r(w)},p=d&&!u&&i!==void 0,y=()=>{if(!i||!r||n)return;const m=(parseFloat(i)/2).toString();r(m)},v=()=>{!i||!r||n||r(i)};return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-[var(--optimex-radius-input)] 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-[var(--optimex-text-secondary)] text-xs",children:u?"To":"From"}),o.jsx("div",{className:"flex items-center gap-2",children:p&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-[var(--optimex-text-secondary)] text-xs",children:["Balance: ",i," ",e?.token_symbol]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(tn,{onClick:y,children:"50%"}),o.jsx(tn,{onClick:v,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:h,readOnly:n,className:"w-full bg-transparent border-none p-0 text-[var(--optimex-text)] text-2xl font-bold focus:ring-0 placeholder:text-[var(--optimex-text-secondary)]/30 outline-none"}),o.jsxs("p",{className:"text-[var(--optimex-text-secondary)] text-xs mt-1",children:["~",f]})]}),o.jsxs("button",{onClick:s,className:"flex items-center gap-2 bg-white/5 hover:bg-white/10 p-2 pr-3 rounded-[9999px] transition-all border border-white/10 active:scale-95 shrink-0",children:[e?o.jsxs(o.Fragment,{children:[o.jsx(Je,{token:e,size:"md"}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-[var(--optimex-text)] text-sm font-bold leading-none",children:e.token_symbol}),o.jsx("p",{className:"text-[var(--optimex-text-secondary)] text-[10px] leading-none mt-1",children:e.network_name})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"size-8 rounded-[9999px] bg-white/10"}),o.jsx("span",{className:"text-[var(--optimex-text)] text-sm font-bold",children:"Select"})]}),o.jsx(ys,{className:"size-4 text-[var(--optimex-text-secondary)]"})]})]}),a&&o.jsxs("div",{className:"flex items-center justify-end gap-2 text-sm text-[var(--optimex-text-secondary)]",children:[o.jsx("div",{className:"size-3 animate-spin rounded-[9999px] border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:c})]})]})}const $r=[.5,.75,1];function Iu({value:e,onChange:t}){const[r,n]=x.useState(""),[s,a]=x.useState(!$r.includes(e)),c=x.useCallback(d=>{a(!1),n(""),t(d)},[t]),i=x.useCallback(d=>{const f=d.target.value;if(f===""||/^\d*\.?\d*$/.test(f)){n(f),a(!0);const h=parseFloat(f);!isNaN(h)&&h>0&&h<=50&&t(h)}},[t]),u=x.useCallback(()=>{a(!0),!r&&e&&n($r.includes(e)?"":String(e))},[r,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:[$r.map(d=>o.jsxs(tn,{onClick:()=>c(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-white/5 border ${s?"border-[var(--optimex-primary)]":"border-transparent hover:bg-white/10"}`,children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Custom",value:r,onChange:i,onFocus:u,className:"w-full min-w-0 py-[6px] bg-transparent text-center text-xs outline-none placeholder:text-[var(--optimex-text-secondary)] text-[var(--optimex-text)]"}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",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 Du({isOpen:e,onClose:t,value:r,onChange:n,anchorRef:s}){const a=x.useCallback(c=>{n(c)},[n]);return o.jsx(Su,{isOpen:e,onClose:t,anchorRef:s,position:"bottom-right",width:"w-96",ariaLabel:"Slippage settings",children:o.jsx(Iu,{value:r,onChange:a})})}const Lu=({title:e})=>o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 bg-[var(--optimex-primary)] rounded-[var(--optimex-radius-button)] flex items-center justify-center shadow-[0_0_15px_rgba(235,98,0,0.3)]",children:o.jsx(li,{className:"w-5 h-auto text-white"})}),o.jsx("h2",{className:"text-xl font-bold tracking-tight text-[var(--optimex-text)]",children:e})]});function Fu({title:e="Swap",headerLeft:t,slippage:r=.75,onSlippageChange:n,isSettingsOpen:s=!1,onSettingsToggle:a,onHistoryClick:c,hideHistory:i=!1}){const u=x.useRef(null);return o.jsxs("header",{className:"flex items-center justify-between px-2",children:[t??o.jsx(Lu,{title:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[!i&&o.jsx("button",{onClick:c,className:"size-10 rounded-[var(--optimex-radius-button)] bg-white/5 hover:bg-white/10 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors flex items-center justify-center","aria-label":"Trade History",children:o.jsx(ai,{className:"size-5"})}),o.jsxs("div",{className:"relative",children:[o.jsx("button",{ref:u,onClick:a,className:"size-10 rounded-[var(--optimex-radius-button)] bg-white/5 hover:bg-white/10 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors flex items-center justify-center","aria-label":"Settings",children:o.jsx(mi,{className:"size-5"})}),o.jsx(Du,{isOpen:s,onClose:()=>a?.(),value:r,onChange:d=>n?.(d),anchorRef:u})]})]})]})}function Vo({onClick:e,disabled:t}){return o.jsx("div",{className:"!m-0 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-[9999px] 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(ni,{className:"size-5"})})})}function Bu({quote:e,fromToken:t,toToken:r,amount:n,slippage:s,isFetching:a}){const[c,i]=x.useState(!1),[u,d]=x.useState(!1),f=x.useCallback(()=>{d(b=>!b)},[]),h=x.useCallback(()=>{i(b=>!b)},[]),p=parseFloat(n)||0,y=parseFloat(e.min_amount_out)/Math.pow(10,r.token_decimals),v=p>0?y/p:0,m=y>0?p/y:0,w=()=>u?`1 ${r.token_symbol} ≈ ${m.toFixed(6)} ${t.token_symbol}`:`1 ${t.token_symbol} ≈ ${v.toFixed(6)} ${r.token_symbol}`;return o.jsxs("div",{className:"bg-white/[0.02] rounded-[var(--optimex-radius-button)] border border-white/5 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:h,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-[var(--optimex-text-secondary)] ",children:o.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),f()},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),f())},className:`text-[var(--optimex-text)] text-sm transition-colors ${a?"shiny-text":""}`,children:w()})}),o.jsx(ys,{className:`size-4 text-[var(--optimex-text-secondary)] transition-transform duration-200 ${c?"rotate-180":""}`})]}),o.jsx(ll,{isOpen:c,children: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-[var(--optimex-text-secondary)]",children:"Min. Received"}),o.jsxs("span",{className:`font-medium text-[var(--optimex-text)] ${a?"shiny-text":""}`,children:[ze(e.min_amount_out,r.token_decimals)," ",r.token_symbol]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[var(--optimex-text-secondary)]",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-[var(--optimex-text-secondary)]",children:"Slippage Tolerance"}),o.jsxs("span",{className:"font-medium text-[var(--optimex-text)]",children:[s,"%"]})]})]})})]})}function $u({text:e,disabled:t,isLoading:r,onClick:n}){return o.jsx(cn,{variant:"primary",size:"xl",fullWidth:!0,disabled:t,isLoading:r,onClick:n,children:e})}function zu(){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(ci,{className:"h-3 w-auto"})]})}function Wu({value:e,onChange:t,placeholder:r="Search by name or symbol..."}){return o.jsx("div",{className:"flex-shrink-0 p-4 pb-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",placeholder:r,value:e,onChange:n=>t(n.target.value),className:"w-full rounded-xl bg-white/5 border border-white/10 px-4 py-3 pl-10 pr-10 text-[var(--optimex-text)] outline-none placeholder:text-[var(--optimex-text-secondary)]/60 transition-colors hover:border-[var(--optimex-primary)] focus:border-[var(--optimex-primary)]"}),o.jsx(hi,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--optimex-text-secondary)]"}),e&&o.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors",children:o.jsx(Ze,{className:"size-5"})})]})})}function Hu({networks:e,selectedNetwork:t,onSelectNetwork:r}){return o.jsxs("div",{className:"w-1/3 min-w-[140px] min-h-0 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-[var(--optimex-text-secondary)]",children:"Networks"}),o.jsxs("div",{className:"space-y-1 px-2",children:[o.jsxs("button",{onClick:()=>r(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-[var(--optimex-text)]":"text-[var(--optimex-text-secondary)] hover:bg-white/5 hover:text-[var(--optimex-text)]"}`,children:[o.jsx(ri,{}),o.jsx("span",{children:"All"})]}),e.map(n=>o.jsx(Vu,{network:n,isSelected:t===n.network_id,onSelect:()=>r(n.network_id)},n.network_id))]})]})}function Vu({network:e,isSelected:t,onSelect:r}){return o.jsxs("button",{onClick:r,className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t?"bg-white/5 text-[var(--optimex-text)]":"text-[var(--optimex-text-secondary)] hover:bg-white/5 hover:text-[var(--optimex-text)]"}`,children:[e.logo_uri?o.jsx("img",{src:e.logo_uri,alt:e.name,className:"h-8 w-8 rounded-lg",onError:n=>{n.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 Uu({tokens:e,selectedSymbol:t,onSelectSymbol:r,maxVisible:n=12}){return o.jsxs("div",{className:"flex-shrink-0 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-[var(--optimex-text-secondary)]",children:"Tokens"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5 overflow-hidden max-h-[5rem]",children:[o.jsx("button",{onClick:()=>r(null),className:`border rounded-lg px-2.5 py-1 text-xs font-medium transition-colors ${t===null?"border-[var(--optimex-primary)] text-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 hover:text-[var(--optimex-text)]"}`,children:"All"}),e.slice(0,n).map(s=>o.jsx(qu,{token:s,isSelected:t===s.token_symbol,onSelect:()=>r(s.token_symbol)},s.token_symbol))]})]})}function qu({token:e,isSelected:t,onSelect:r}){return o.jsxs("button",{onClick:r,className:Us("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-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 hover:text-[var(--optimex-text)]"),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:n=>{n.target.style.display="none"}}),e.token_symbol]})}function kt(){const e=x.useContext(xs);if(!e)throw new Error("useWallet must be used within WalletProvider");return e}function Cr(e){return`https://network-api-stg.bitdex.xyz/${e}/rpc/zwD70RMT9DrE8L5SaMnJNMF8m70Gum`}function Qu(e){return e==="bitcoin_testnet"?"https://mempool.space/testnet4/api":"https://mempool.space/api"}function vn(e){return!e.token_address||e.token_address===""||e.token_address==="native"||e.token_address==="0x0000000000000000000000000000000000000000"}function Ku(e,t){if(!e||e==="0")return"0";const r=BigInt(e),n=BigInt(10**t),s=r/n,a=r%n;if(a===BigInt(0))return s.toString();let c=a.toString().padStart(t,"0");return c=c.replace(/0+$/,""),c.length>6&&(c=c.slice(0,6)),`${s}.${c}`}function Gu(e){return`0x70a08231000000000000000000000000${e.toLowerCase().replace("0x","")}`}async function Uo(e,t){const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`RPC request failed: ${r.status}`);return r.json()}async function Yu(e,t){const n=await Uo(e,{jsonrpc:"2.0",method:"eth_getBalance",params:[t,"latest"],id:1});if(n.error)throw new Error(`RPC error: ${n.error.message}`);const s=n.result||"0x0";return BigInt(s).toString()}async function Zu(e,t,r){const n={jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:Gu(r)},"latest"],id:1},s=await Uo(e,n);if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result||"0x0";return BigInt(a).toString()}async function Xu(e,t){const r=Cr(e.network_id),n=vn(e);let s;return n?s=await Yu(r,t):s=await Zu(r,e.token_address,t),{rawBalance:s,isNative:n}}async function Ju(e,t){const n=`${Qu(e.network_id)}/address/${t}`,s=await fetch(n);if(!s.ok)throw new Error(`Mempool API request failed: ${s.status}`);const a=await s.json(),c=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:(c+i).toString(),isNative:!0}}async function qo(e,t){const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`RPC request failed: ${r.status}`);return r.json()}async function ed(e,t){const n=await qo(e,{jsonrpc:"2.0",method:"getBalance",params:[t],id:1});if(n.error)throw new Error(`RPC error: ${n.error.message}`);return(n.result?.value||0).toString()}async function td(e,t,r){const s=await qo(e,{jsonrpc:"2.0",method:"getTokenAccountsByOwner",params:[r,{mint:t},{encoding:"jsonParsed"}],id:1});if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result?.value||[];let c=BigInt(0);for(const i of a){const u=i.account.data.parsed.info.tokenAmount.amount;c+=BigInt(u)}return c.toString()}async function rd(e,t){const r=Cr(e.network_id),n=vn(e);let s;return n?s=await ed(r,t):s=await td(r,e.token_address,t),{rawBalance:s,isNative:n}}function nd(e,t){if(!t)return!1;switch(t){case ie.EVM:return e.isEvmConnected;case ie.BTC:return e.isBtcConnected;case ie.SOLANA:return e.isSolanaConnected;default:return!1}}function sd(e){if(!e)return"";switch(e){case ie.EVM:return"EVM";case ie.BTC:return"Bitcoin";case ie.SOLANA:return"Solana";default:return e}}function od(e,t){if(!t)return null;switch(t){case ie.EVM:return e.evmAddress;case ie.BTC:return e.btcAddress;case ie.SOLANA:return e.solanaAddress;default:return null}}async function Qo({provider:e,address:t,chainId:r,chainName:n="Unknown"}){let s=t;if(!s){const c=await e.request({method:"eth_accounts"});if(!c||c.length===0)throw new Error("No accounts found. Please connect your wallet first.");s=c[0]}let a=r;if(a===void 0){const c=await e.request({method:"eth_chainId"});a=parseInt(c,16)}return Ko({provider:e,address:s,chainId:a,chainName:n})}function Ko({provider:e,address:t,chainId:r,chainName:n="Unknown"}){return{address:t,publicKey:t,chain:{id:r,name:n,type:"EVM"},sendTransaction:async i=>{const u=i;return await e.request({method:"eth_sendTransaction",params:[{from:t,to:u.to,value:u.value?`0x${u.value.toString(16)}`:void 0,data:u.data}]})},getChainId:async()=>{const i=await e.request({method:"eth_chainId"});return parseInt(i,16)},switchChain:async i=>{try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${i.toString(16)}`}]})}catch(u){throw u.code===4902?new Error(`Chain ${i} not found in wallet. Please add it first.`):u}}}}const ad=Qo;async function id(e,t){const r=e.token_address||"native";let n;switch(e.network_type){case ie.BTC:n=await Ju(e,t);break;case ie.SOLANA:n=await rd(e,t);break;case ie.EVM:default:n=await Xu(e,t)}return{tokenId:r,networkId:e.network_id,walletAddress:t,rawBalance:n.rawBalance,formattedBalance:Ku(n.rawBalance,e.token_decimals),updatedAt:Date.now()}}const ld=30*1e3,cd=15*1e3;function ud(e,t){return!e||!t?["balance"]:["balance",e.network_id,e.token_address||"native",t]}function Go({token:e,walletAddress:t,enabled:r=!0,polling:n=!1,pollingInterval:s=cd}){const a=r&&!!e&&!!t,{data:c,isLoading:i,isFetching:u,error:d,refetch:f}=bt({queryKey:ud(e,t),queryFn:()=>id(e,t),enabled:a,staleTime:ld,retry:1,refetchOnWindowFocus:!1,refetchInterval:n?s:!1});return{balance:c,formattedBalance:c?.formattedBalance||"0",isLoading:a&&i,isFetching:a&&u,error:d,refetch:f}}function dd({token:e,isSelected:t,isDisabled:r,onSelect:n}){const s=kt(),a=od(s,e.network_type),{formattedBalance:c,isLoading:i}=Go({token:e,walletAddress:a,enabled:!!a}),u=!!a;return o.jsxs("button",{onClick:n,disabled:r,className:`flex w-full items-center gap-3 rounded-lg p-2 transition-colors ${t?"bg-white/5 text-[var(--optimex-text)]":r?"cursor-not-allowed opacity-50":"hover:bg-white/5"}`,children:[o.jsx(Je,{token:e}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"text-sm text-[var(--optimex-text-secondary)]",children:e.token_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[u&&o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:i?o.jsx("span",{className:"inline-block h-4 w-12 animate-pulse rounded bg-white/10"}):c}),o.jsx("span",{className:"font-medium text-[var(--optimex-text)]",children:e.token_symbol})]})]}),t&&o.jsx(ln,{className:"h-5 w-5 text-[var(--optimex-primary)]"})]})}function fd({tokens:e,selectedTokenId:t,disabledTokenId:r,disabledTokenIds:n,isLoading:s,emptyMessage:a="No tokens available",onSelect:c}){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-[var(--optimex-text-secondary)]",children:a})}):o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1",children:e.map(i=>{const u=r===i.token_id||n?.has(i.token_id)===!0;return o.jsx(dd,{token:i,isSelected:t===i.token_id,isDisabled:u,onSelect:()=>c(i)},i.token_id)})})})}function hd({isOpen:e,onClose:t,onSelect:r,tokensData:n,isLoading:s,selectedToken:a,disabledTokenId:c,disabledTokenIds:i,tokens:u,emptyMessage:d,title:f="Select Token",filterNetworkType:h}){const[p,y]=x.useState(""),[v,m]=x.useState(null),[w,b]=x.useState(null),R=x.useMemo(()=>n?.supported_networks?h?n.supported_networks.filter(W=>W.type===h):n.supported_networks:[],[n,h]),T=u??n?.tokens,k=x.useMemo(()=>T?T.filter(W=>{if(h&&W.network_type!==h||v&&W.network_id!==v)return!1;if(p){const K=(X,J)=>X.toLowerCase().includes(J.toLowerCase()),D=p.toLowerCase();return K(W.token_symbol,D)||K(W.token_name,D)||K(W.token_address,D)}return!0}):[],[T,p,v,h]),A=x.useMemo(()=>{if(!T)return[];const W=new Map;return T.forEach(K=>{h&&K.network_type!==h||v&&K.network_id!==v||W.has(K.token_symbol)||W.set(K.token_symbol,K)}),Array.from(W.values())},[T,h,v]),L=x.useMemo(()=>w?k.filter(W=>W.token_symbol===w):k,[k,w]),j=()=>{y(""),m(null),b(null)},N=W=>{r(W),t(),j()},M=W=>{W||(t(),j())},U=W=>{m(W),b(null)};return o.jsx(pn,{open:e,onOpenChange:M,title:f,height:"70vh",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o.jsx(Wu,{value:p,onChange:y}),o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(Hu,{networks:R,selectedNetwork:v,onSelectNetwork:U}),o.jsxs("div",{className:"flex flex-1 min-h-0 flex-col overflow-hidden",children:[o.jsx(Uu,{tokens:A,selectedSymbol:w,onSelectSymbol:b}),o.jsx(fd,{tokens:L,selectedTokenId:a?.token_id,disabledTokenId:c,disabledTokenIds:i,isLoading:s,emptyMessage:p?"No tokens found":d??"No tokens available",onSelect:N})]})]})]})})}function ts({token:e,amount:t,label:r,isEstimated:n=!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(Je,{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:[r," ",n&&"(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:n?`~${t}`:t}),o.jsx("p",{className:"text-zinc-400 text-xs",children:a})]})]})})}function md({fromToken:e,toToken:t,fromAmount:r,toAmount:n,fromUsdValue:s="$0.00",toUsdValue:a="$0.00"}){return o.jsxs("div",{className:"relative flex flex-col gap-2",children:[o.jsx(ts,{token:e,amount:r,label:"You Pay",usdValue:s}),o.jsx(Vo,{onClick:()=>{},disabled:!0}),o.jsx(ts,{token:t,amount:n,label:"You Receive",usdValue:a})]})}function zr({label:e,value:t,borderTop:r}){return o.jsxs("div",{className:`flex justify-between items-center text-sm ${r?"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 pd({minReceived:e,estimatedTime:t,slippage:r,networkFee:n="Included"}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-xl p-4 border border-white/5 space-y-3",children:[o.jsx(zr,{label:"Min. Received",value:e}),o.jsx(zr,{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(zr,{label:"Slippage Tolerance",value:r})]})}const xd=3e4,vd=6e4;function gr({symbol:e,enabled:t=!0}){const r=Mt(),{data:n,isLoading:s,isError:a}=bt({queryKey:["tokenPrice",e],queryFn:async()=>{if(!e)throw new Error("Symbol is required");return(await yt(r.apiBaseUrl).getTokenPrice(e)).current_price},enabled:t&&!!e,staleTime:xd,refetchInterval:vd,retry:2});return{price:n??null,isLoading:s,isError:a,calculateUsdValue:c=>Va(c,n??null)}}function gd({isOpen:e,onClose:t,onConfirm:r,fromToken:n,toToken:s,amountIn:a,quote:c,slippage:i,stage:u,receivingAddress:d=""}){const f=u!=="idle"&&u!=="confirming"&&u!=="error"&&u!=="submitted",h=u==="submitted",p=u==="error",y=ze(c.min_amount_out,s.token_decimals),{calculateUsdValue:v}=gr({symbol:n.token_symbol,enabled:e}),{calculateUsdValue:m}=gr({symbol:s.token_symbol,enabled:e}),w=v(a),b=m(y),R=k=>{!k&&!f&&t()},T=h?"Swap Complete":p?"Swap Failed":"Review Swap";return o.jsxs(pn,{open:e,onOpenChange:R,title:T,showCloseButton:!f,className:"w-[32rem]",children:[o.jsxs(wu,{className:"space-y-3",children:[o.jsx(md,{fromToken:n,toToken:s,fromAmount:a,toAmount:y,fromUsdValue:w,toUsdValue:b}),o.jsx(pd,{minReceived:`${y} ${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(vi,{icon:Cs,label:"Receiving Address",address:d})})]}),o.jsx(Cu,{children:o.jsx(cl,{state:f?"processing":h?"success":p?"error":"idle",onConfirm:h?t:r,confirmText:"Confirm Swap"})})]})}function bd({swap:e}){const{tokens:t,modals:r,tokenSelect:n,actions:s,input:a,quote:c,execution:i}=e;return o.jsxs(o.Fragment,{children:[r.tokenSelect.isOpen&&o.jsx(hd,{isOpen:r.tokenSelect.isOpen,onClose:r.tokenSelect.close,onSelect:s.selectToken,tokensData:t.data,isLoading:!1,selectedToken:n.type==="from"?t.from:t.to,disabledTokenId:n.type==="from"?t.to?.token_id:t.from?.token_id,tokens:n.type==="to"?t.availableTo:t.all,emptyMessage:n.type==="to"?"No available pairs for selected source token":void 0,title:n.type==="from"?"Select Source Token":"Select Destination Token"}),c.data&&t.from&&t.to&&r.confirm.isOpen&&o.jsx(gd,{isOpen:r.confirm.isOpen,onClose:s.closeConfirmModal,onConfirm:s.confirmSwap,fromToken:t.from,toToken:t.to,amountIn:a.amount,quote:c.data,slippage:a.slippage,stage:i.stage,txHash:i.txHash,error:i.error,receivingAddress:e.addresses.receiving})]})}function gn({status:e}){const t={pending:{icon:ws,text:"Processing",bgClass:"bg-yellow-500/10",textClass:"text-yellow-500",animate:!0},success:{icon:ln,text:"Completed",bgClass:"bg-green-500/10",textClass:"text-green-500",animate:!1},failed:{icon:si,text:"Failed",bgClass:"bg-red-500/10",textClass:"text-red-500",animate:!1}},{icon:r,text:n,bgClass:s,textClass:a,animate:c}=t[e];return o.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${s}`,children:[o.jsx(r,{className:`w-4 h-4 ${a} ${c?"animate-spin":""}`}),o.jsx("span",{className:`text-xs font-medium ${a}`,children:n})]})}function yd({onClose:e}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-white/10 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(gn,{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(Ze,{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-white/10 animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-white/10 rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-white/10 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-white/10 rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-white/10 rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-white/10 animate-pulse"})]})]})]})}function wd({trade:e,status:t,isLoading:r,onClose:n}){if(r||!e)return o.jsx(yd,{onClose:n});const s=e.from_token,a=e.to_token,c=ze(e.amount_in,s.token_decimals),i=ze(e.min_amount_out,a.token_decimals);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-white/10 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(gn,{status:t}),n&&o.jsx("button",{onClick:n,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ze,{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(Je,{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:c}),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(Je,{token:a,size:"sm",showNetworkBadge:!1})]})]})]})}const Cd=1e4;function kd({apiBaseUrl:e,walletAddresses:t,enabled:r=!0,limit:n=20}){const{data:s,isLoading:a,isError:c,refetch:i}=bt({queryKey:["trades",t,n],queryFn:async()=>yt(e).listTrades({from_user_address:t,limit:n}),enabled:r&&!!t?.length,refetchInterval:Cd,retry:2,retryDelay:2e3});return{trades:s??[],isLoading:a,isError:c,refetch:i}}function jd(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 Sd({trade:e}){const t=e.from_token,r=e.to_token,n=jd(e.state),s=ze(e.amount_in,t.token_decimals),a=ze(e.min_amount_out,r.token_decimals);return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-white/10",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Je,{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:r.token_symbol})]}),o.jsx(Je,{token:r,size:"sm",showNetworkBadge:!1})]}),o.jsx("div",{className:"ml-3",children:o.jsx(gn,{status:n})})]})}function Wr(){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-white/10",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 Ed(){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 Nd({open:e,onOpenChange:t,evmAddress:r,btcAddress:n,solanaAddress:s}){const a=Mt(),c=[r,n,s].filter(d=>!!d),{trades:i,isLoading:u}=kd({apiBaseUrl:a.apiBaseUrl,walletAddresses:c.length>0?c:void 0,enabled:e&&c.length>0});return o.jsx(pn,{open:e,onOpenChange:t,title:"Trade History",className:"w-[32rem]",children:o.jsxs("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u?o.jsxs(o.Fragment,{children:[o.jsx(Wr,{}),o.jsx(Wr,{}),o.jsx(Wr,{})]}):i.length===0?o.jsx(Ed,{}):i.map(d=>o.jsx(Sd,{trade:d},d.trade_id)),!u&&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(ws,{className:"w-3 h-3 animate-spin"}),o.jsx("span",{children:"Auto-refreshing"})]})]})})}function Td(e,t){return x.useMemo(()=>{const r=e.trim();if(!t||!r)return{isValid:!r,error:void 0};const n=an(r,t.network_type,t.network_id);return{isValid:n.isValid,error:n.isValid?void 0:n.error}},[e,t])}function Rd(){const[e,t]=x.useState(null),[r,n]=x.useState(!1),[s,a]=x.useState(!1),c=x.useCallback(()=>t("from"),[]),i=x.useCallback(()=>t("to"),[]),u=x.useCallback(()=>t(null),[]),d=x.useCallback(()=>n(!0),[]),f=x.useCallback(()=>n(!1),[]),h=x.useCallback(()=>a(y=>!y),[]),p=x.useCallback(()=>a(!1),[]);return{tokenSelect:{isOpen:e!==null,type:e,openFrom:c,openTo:i,close:u},confirm:{isOpen:r,open:d,close:f},settings:{isOpen:s,toggle:h,close:p}}}function Od({fromToken:e,toToken:t,amount:r,fromUserAddress:n,toUserAddress:s,userRefundPubkey:a,slippage:c,config:i}){return x.useMemo(()=>{const u=s.trim(),d=i.affiliateAddress&&i.affiliateFee?[{provider:i.affiliateProvider??"optimex-widget",rate:String(i.affiliateFee),receiver:i.affiliateAddress,network:"ethereum"}]:void 0,f=Math.round(c*100);return{from_token:e,to_token:t,amount:r,from_user_address:n,to_user_address:u||null,user_refund_pubkey:a,slippage:String(f),affiliate_fee_bps:i.affiliateFee?String(i.affiliateFee):void 0,affiliate_info:d,trade_timeout:i.tradeTimeout,script_timeout:i.scriptTimeout}},[e,t,r,n,s,a,c,i.affiliateFee,i.affiliateAddress,i.affiliateProvider,i.tradeTimeout,i.scriptTimeout])}function _d(e,t){return x.useMemo(()=>{if(!e||!t)return{walletAccount:void 0,evmWalletAccount:void 0};switch(e.network_type){case ie.EVM:return{walletAccount:t.evm,evmWalletAccount:t.evm};case ie.BTC:return{walletAccount:t.btc,evmWalletAccount:void 0};case ie.SOLANA:return{walletAccount:t.solana,evmWalletAccount:void 0};default:return{walletAccount:void 0,evmWalletAccount:void 0}}},[e,t])}const rs={BTC:1,EVM:2,Solana:3};function Ad(e){const{tokens:t,pairs:r,selectedFromToken:n}=e,s=x.useMemo(()=>{const y=new Map;if(!r)return y;for(const v of r){if(!v.is_active)continue;const m=y.get(v.from_token_id);m?m.add(v.to_token_id):y.set(v.from_token_id,new Set([v.to_token_id]))}return y},[r]),a=x.useMemo(()=>t??[],[t]),c=x.useMemo(()=>{const y=new Set;for(const v of a){const m=s.get(v.token_id);(!m||m.size===0)&&y.add(v.token_id)}return y},[a,s]),i=x.useMemo(()=>{if(!n)return[];const y=s.get(n.token_id);return!y||y.size===0?[]:a.filter(v=>y.has(v.token_id))},[n,s,a]),u=x.useCallback((y,v)=>s.get(y)?.has(v)??!1,[s]),d=x.useCallback(y=>(s.get(y)?.size??0)>0,[s]),f=x.useCallback(y=>[...y].sort((v,m)=>{const w=rs[v.network_type]??99,b=rs[m.network_type]??99;return w-b}),[]),h=x.useCallback(y=>{const v=s.get(y.token_id);if(!v||v.size===0)return null;const m=a.filter(b=>v.has(b.token_id));return m.length===0?null:f(m)[0]??null},[s,a,f]),p=x.useCallback(()=>{if(a.length===0)return null;const y=f(a);for(const v of y){const m=h(v);if(m)return{fromToken:v,toToken:m}}return null},[a,f,h]);return{allTokens:a,tokensWithoutPairs:c,availableToTokens:i,isPairValid:u,findBestToToken:h,hasValidPairs:d,getDefaultPair:p}}function Md(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 Pd(e,t){const r=Md(t);if(!r)throw new Error(`Cannot determine chain ID for token: ${t.token_id}`);return await e.getChainId()===r?!1:(await e.switchChain(r),!0)}const Id="0xdd62ed3e",Dd="0x095ea7b3",Ld="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";function rn(e){return e.toLowerCase().replace("0x","").padStart(64,"0")}function Fd(e){return e.toString(16).padStart(64,"0")}function Bd(e){const t=e.startsWith("0x")?e.slice(2):e;return!t||t===""?0n:BigInt("0x"+t)}async function $d(e,t,r,n){const s=Cr(e),a=Id+rn(r)+rn(n),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 Bd(i.result)}function zd(e,t){const r=t?Fd(t):Ld.slice(2);return`${Dd}${rn(e)}${r}`}async function Wd(e,t,r,n){const s=zd(r,n);return await e.sendTransaction({to:t,data:s})}async function Hd(e,t,r=60,n=2e3){const s=Cr(e);for(let a=0;a<r;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 u=i.result;return{status:u.status==="0x1"?"success":"reverted",blockNumber:u.blockNumber,transactionHash:u.transactionHash}}await new Promise(u=>setTimeout(u,n))}throw new Error(`Transaction ${t} not confirmed after ${r} attempts`)}function Vd(e){return e?"getChainId"in e&&"switchChain"in e&&typeof e.getChainId=="function"&&typeof e.switchChain=="function":!1}function Ud({apiBaseUrl:e,onWalletTx:t,onSubmitTx:r,onError:n}){const[s,a]=x.useState({stage:"idle",txHash:null,tradeId:null,error:null}),c=x.useCallback(()=>{a({stage:"idle",txHash:null,tradeId:null,error:null})},[]),i=x.useCallback(()=>{a(h=>({stage:"idle",txHash:h.txHash,tradeId:h.tradeId,error:null}))},[]),u=x.useCallback((h,p,y)=>{a(v=>({...v,stage:"error",error:h})),n?.({error:h,stage:p,trade_id:y})},[n]),d=x.useCallback(async(h,p,y,v)=>{const m=y.deposit_address;if(!m)throw new Error("Missing deposit address for EVM transaction");a(T=>({...T,stage:"switching_chain"})),await Pd(h,p);const w=vn(p);if(!w&&p.token_address&&(a(k=>({...k,stage:"checking_allowance"})),await $d(p.network_id,p.token_address,h.address,m)<v)){a(L=>({...L,stage:"approving"}));const k=await Wd(h,p.token_address,m,v);if((await Hd(p.network_id,k)).status==="reverted")throw new Error("Token approval transaction reverted")}a(T=>({...T,stage:"broadcasting"}));const b={to:m,value:w?v:0n,data:y.payload?y.payload:void 0};return await h.sendTransaction(b)},[]),f=x.useCallback(async({quote:h,fromToken:p,toToken:y,amountIn:v,walletAccount:m,evmWalletAccount:w})=>{const b=yt(e);try{a({stage:"confirming",txHash:null,tradeId:h.trade_id,error:null});const R=w||m;if(!R)throw new Error("Wallet not available");a(A=>({...A,stage:"signing"}));let T;const k=gs(v,p.token_decimals);if(p.network_type===ie.EVM){const A=w||(Vd(m)?m:null);if(A)T=await d(A,p,h,k);else{const L=h.deposit_address,j=h.payload?h.payload:void 0;if(!L)throw new Error("Missing deposit address for EVM transaction");a(M=>({...M,stage:"broadcasting"}));const N={to:L,value:k,data:j};T=await R.sendTransaction(N)}}else if(p.network_type===ie.BTC){if(!h.deposit_address)throw new Error("Missing deposit address for BTC transaction");a(A=>({...A,stage:"broadcasting"})),T=await R.sendTransaction({toAddress:h.deposit_address,amount:k})}else if(p.network_type===ie.SOLANA){if(!h.payload)throw new Error("Missing payload for Solana transaction");a(A=>({...A,stage:"broadcasting"})),T=await R.sendTransaction(h.payload)}else throw new Error(`Unsupported network type: ${p.network_type}`);t?.({trade_id:h.trade_id,tx_hash:T,from_token:p,to_token:y,amount_in:v}),a(A=>({...A,txHash:T,stage:"submitting"}));try{await b.submitTransaction(h.trade_id,T),r?.({trade_id:h.trade_id,tx_hash:T,status:"success"})}catch(A){throw r?.({trade_id:h.trade_id,tx_hash:T,status:"error",error:A.message}),A}return a(A=>({...A,stage:"submitted"})),{tradeId:h.trade_id,txHash:T}}catch(R){const T=s.stage==="approving"?"approval":"wallet_tx";throw u(R,T,h.trade_id),R}},[e,t,r,u,d,s.stage]);return{...s,executeSwap:f,resetState:c,resetStateKeepTradeId:i,isExecuting:s.stage!=="idle"&&s.stage!=="submitted"&&s.stage!=="error"}}function qd({defaultPair:e,isPairValid:t,findBestToToken:r,hasValidPairs:n,defaultSlippage:s=.75,selectingToken:a=null}){const[c,i]=x.useState(null),[u,d]=x.useState(null),[f,h]=x.useState(""),[p,y]=x.useState(""),[v,m]=x.useState(s),w=c??e?.fromToken??null,b=u??e?.toToken??null,R=x.useCallback(()=>{w&&b&&t(b.token_id,w.token_id)&&(i(b),d(w),h(""))},[w,b,t]),T=x.useCallback(k=>{if(a==="from"){if(!n(k.token_id))return!1;if(k.token_id===b?.token_id)d(w);else if(b&&!t(k.token_id,b.token_id)){const A=r(k);d(A)}return i(k),!0}else if(a==="to")return k.token_id===w?.token_id&&i(b),d(k),!0;return!1},[a,w,b,t,r,n]);return{fromToken:w,toToken:b,handleTokenSelect:T,handleSwapDirection:R,amount:f,setAmount:h,receivingAddress:p,setReceivingAddress:y,slippage:v,setSlippage:m}}function Qd({fromToken:e,toToken:t}){const r=kt();return x.useMemo(()=>{const n=r.evmAddress,s=r.btcAddress,a=r.btcPublicKey;let c=null,i=null;return e?.network_type===ie.EVM?(c=n,i=n):e?.network_type===ie.BTC&&(c=s,i=a),{fromUserAddress:c,userRefundPubkey:i}},[r.evmAddress,r.btcAddress,r.btcPublicKey,e,t])}function Kd({fromToken:e,toToken:t,amount:r,quote:n,isLoadingQuote:s,isFetchingQuote:a,receivingAddress:c,onConnectWallet:i,onSwap:u}){const d=kt();return x.useMemo(()=>{if(!nd(d,e?.network_type)){const p=sd(e?.network_type);return{text:p?`Connect ${p} Wallet`:"Connect Wallet",disabled:!1,action:i}}return!e||!t?{text:"Select Tokens",disabled:!0,action:void 0}:!r||parseFloat(r)<=0?{text:"Enter Amount",disabled:!0,action:void 0}:c.trim()?an(c,t.network_type,t.network_id).isValid?s||a?{text:"Getting Quote...",disabled:!0,action:void 0}:n?{text:"Review",disabled:!1,action:u}:{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,r,s,a,n,i,u,c])}function Gd({tokens:e,defaultFromToken:t,defaultToToken:r,isPairValid:n}){return x.useMemo(()=>{if(!t||!r||!e)return null;const s=e.find(c=>c.token_id===t),a=e.find(c=>c.token_id===r);return!s||!a?null:n(s.token_id,a.token_id)?{fromToken:s,toToken:a}:null},[e,t,r,n])}function Yd(){const e=kt(),t=Mt(),r=Rd(),{tokensData:n}=Mu(),s=n.tokens,a=n.pairs,{allTokens:c,tokensWithoutPairs:i,isPairValid:u,findBestToToken:d,hasValidPairs:f,getDefaultPair:h}=Ad({tokens:s,pairs:a,selectedFromToken:null}),y=Gd({tokens:s,defaultFromToken:t.defaultFromToken,defaultToToken:t.defaultToToken,isPairValid:u})??h(),{fromToken:v,toToken:m,handleTokenSelect:w,handleSwapDirection:b,amount:R,setAmount:T,receivingAddress:k,setReceivingAddress:A,slippage:L,setSlippage:j}=qd({defaultPair:y,isPairValid:u,findBestToToken:d,hasValidPairs:f,defaultSlippage:t.defaultSlippage,selectingToken:r.tokenSelect.type}),N=x.useMemo(()=>v?c.filter(F=>u(v.token_id,F.token_id)):[],[v,c,u]),M=Td(k,m),{fromUserAddress:U,userRefundPubkey:W}=Qd({fromToken:v,toToken:m}),K=Od({fromToken:v,toToken:m,amount:R,fromUserAddress:U,toUserAddress:k,userRefundPubkey:W,slippage:L,config:{affiliateFee:t.affiliateFee,affiliateAddress:t.affiliateAddress,affiliateProvider:t.affiliateProvider,tradeTimeout:t.tradeTimeout,scriptTimeout:t.scriptTimeout}}),D=!!v&&!!m&&parseFloat(R)>0&&!!k.trim()&&!r.confirm.isOpen,{data:X,isLoading:J,isFetching:re,refetch:te}=ei(t.apiBaseUrl,{...K,enabled:D,onQuote:t.callbacks?.onQuote}),_=Ud({apiBaseUrl:t.apiBaseUrl,onWalletTx:t.callbacks?.onWalletTx,onSubmitTx:t.callbacks?.onSubmitTx,onError:t.callbacks?.onError}),{walletAccount:oe,evmWalletAccount:me}=_d(v,e.externalWalletClient??void 0),xe=x.useCallback(()=>{e.isExternalWallet?e.onRequestWallet?.(v?.network_id??""):e.openConnectModal?.()},[e,v?.network_id]),ve=x.useCallback(()=>{!X||!v||!m||(_.resetState(),r.confirm.open())},[X,v,m,r.confirm,_]),Y=x.useCallback((F=!1)=>{_.isExecuting||(r.confirm.close(),F&&_.resetStateKeepTradeId())},[_,r.confirm]),ne=x.useCallback(async()=>{if(!(!X||!v||!m))try{const{txHash:F}=await _.executeSwap({quote:X,fromToken:v,toToken:m,amountIn:R,walletAccount:oe,evmWalletAccount:me});Y(!!F),T(""),A("")}catch(F){console.error("Swap failed:",F)}},[X,v,m,R,oe,me,_,Y,T,A]),ye=x.useCallback(F=>{w(F)&&r.tokenSelect.close()},[w,r.tokenSelect]),Te=Kd({fromToken:v,toToken:m,amount:R,quote:X,isLoadingQuote:J,isFetchingQuote:re,receivingAddress:k,onConnectWallet:xe,onSwap:ve});return{tokens:{from:v,to:m,all:c,availableTo:N,withoutPairs:i,data:n},input:{amount:R,setAmount:T,receivingAddress:k,setReceivingAddress:A,slippage:L,setSlippage:j},quote:{data:X,isLoading:J,isFetching:re,refetch:te},validation:{address:M},buttonState:Te,modals:r,tokenSelect:{type:r.tokenSelect.type},actions:{selectToken:ye,swapDirection:b,connectWallet:xe,openSwapConfirm:ve,closeConfirmModal:Y,confirmSwap:ne},execution:{stage:_.stage,txHash:_.txHash,tradeId:_.tradeId,error:_.error,isExecuting:_.isExecuting},wallet:e,addresses:{sending:U,receiving:k}}}const Zd=5e3;function ns(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 Xd({apiBaseUrl:e,tradeId:t}){const{data:r,isLoading:n}=bt({queryKey:["trade",t],queryFn:async()=>yt(e).getTrade(t),enabled:!!t,refetchInterval:s=>{const a=s.state.data;return a&&ns(a.state)==="success"?!1:Zd},retry:!0,retryDelay:2e3});return{trade:r??null,status:ns(r?.state),isLoading:n}}function Yo(){const e=Yd(),t=Mt(),{tokens:r,input:n,quote:s,modals:a,buttonState:c,validation:i,actions:u,addresses:d,wallet:f,execution:h}=e,[p,y]=x.useState(!1),{trade:v,status:m,isLoading:w}=Xd({apiBaseUrl:t.apiBaseUrl,tradeId:h.tradeId}),{formattedBalance:b}=Go({token:r.from,walletAddress:d.sending,enabled:!!r.from&&!!d.sending,polling:!0}),{calculateUsdValue:R}=gr({symbol:r.from?.token_symbol,enabled:!!r.from}),{calculateUsdValue:T}=gr({symbol:r.to?.token_symbol,enabled:!!r.to}),k=f.isConnected,A=R(n.amount),L=s.data?T(ze(s.data.min_amount_out,r.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(Fu,{headerLeft:t.headerLeft,slippage:n.slippage,onSlippageChange:n.setSlippage,isSettingsOpen:a.settings.isOpen,onSettingsToggle:a.settings.toggle,onHistoryClick:()=>y(!0),hideHistory:t.hideHistory||!f.isConnected}),o.jsxs(xn,{children:[o.jsxs("div",{className:"space-y-2 relative",children:[o.jsx(es,{token:r.from,value:n.amount,onChange:n.setAmount,onSelectToken:a.tokenSelect.openFrom,balance:b,isWalletConnected:k,usdValue:A}),o.jsx(Vo,{onClick:u.swapDirection}),o.jsx(es,{token:r.to,value:s.data?ze(s.data.min_amount_out,r.to?.token_decimals||18):"",readOnly:!0,onSelectToken:a.tokenSelect.openTo,isOutput:!0,usdValue:L})]}),o.jsx("div",{className:"mt-4",children:o.jsx(Pu,{token:r.to,value:n.receivingAddress,onChange:n.setReceivingAddress,error:i.address.error})}),o.jsx("div",{className:"mt-4",children:o.jsx($u,{text:c.text,disabled:c.disabled,onClick:c.action})}),s.data&&r.from&&r.to&&o.jsx("div",{className:"mt-4",children:o.jsx(Bu,{quote:s.data,fromToken:r.from,toToken:r.to,amount:n.amount,slippage:n.slippage,isFetching:s.isFetching,onRefresh:s.refetch})}),o.jsx("div",{className:"mt-4",children:o.jsx(zu,{})}),h.tradeId&&h.txHash&&o.jsx("div",{className:"mt-4",children:o.jsx(wd,{trade:v,status:m,isLoading:w})})]})]}),o.jsx(bd,{swap:e}),p&&o.jsx(Nd,{open:p,onOpenChange:y,evmAddress:f.evmAddress??void 0,btcAddress:f.btcAddress??void 0,solanaAddress:f.solanaAddress??void 0})]})}function Jd({className:e,connectLabel:t="Connect Wallet",showNetworkBadge:r=!0,onClick:n}){const s=kt(),a=s.evmAddress||s.btcAddress||s.solanaAddress,c=()=>{if(n){n();return}s.isExternalWallet?s.onRequestWallet?.():s.openConnectModal?.()},i=()=>r?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:c,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:Wa(a)}),o.jsx(ii,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})]}):o.jsx("button",{onClick:c,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 ef({apiBaseUrl:e,walletClient:t,onRequestWallet:r,theme:n,defaultFromToken:s,defaultToToken:a,headerLeft:c,affiliateFee:i,affiliateAddress:u,affiliateProvider:d,tradeTimeout:f,scriptTimeout:h,defaultSlippage:p=.75,hideHistory:y=!1,children:v,renderLoading:m,renderError:w,queryClient:b,onQuote:R,onWalletTx:T,onSubmitTx:k,onSwapComplete:A,onError:L}){La(e);const j=x.useMemo(()=>b??new ha,[b]),M={apiBaseUrl:e,defaultSlippage:p,affiliateFee:i,affiliateAddress:u,affiliateProvider:d,tradeTimeout:f,scriptTimeout:h,defaultFromToken:s,defaultToToken:a,hideHistory:y,headerLeft:c,callbacks:{onQuote:R,onWalletTx:T,onSubmitTx:k,onSwapComplete:A,onError:L},renderLoading:m,renderError:w},U=v??o.jsx(Yo,{});return o.jsx("div",{className:"optx-widget",children:o.jsx(ga,{client:j,children:o.jsx(ti,{value:M,children:o.jsx(Pa,{theme:n,children:o.jsx(Da,{externalWalletClient:t,onRequestWallet:r,children:o.jsx(Au,{children:U})})})})})})}exports.ConnectButton=Jd;exports.SwapCard=Yo;exports.SwapWidget=ef;exports.createEvmWalletClient=Qo;exports.createEvmWalletClientAsync=ad;exports.createEvmWalletClientSync=Ko;exports.useWallet=kt;
|
|
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 Hc(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function Vc(){return mn(/^Mac/)}function Uc(){return mn(/^iPhone/)}function Yn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function qc(){return mn(/^iPad/)||Vc()&&navigator.maxTouchPoints>1}function Mo(){return Uc()||qc()}function mn(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const Qc=24,Kc=typeof window<"u"?x.useLayoutEffect:x.useEffect;function Zn(...e){return(...t)=>{for(let r of e)typeof r=="function"&&r(...t)}}const Dr=typeof document<"u"&&window.visualViewport;function Xn(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Po(e){for(Xn(e)&&(e=e.parentElement);e&&!Xn(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Gc=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let ur=0,Lr;function Yc(e={}){let{isDisabled:t}=e;Kc(()=>{if(!t)return ur++,ur===1&&Mo()&&(Lr=Zc()),()=>{ur--,ur===0&&Lr?.()}},[t])}function Zc(){let e,t=0,r=h=>{e=Po(h.target),!(e===document.documentElement&&e===document.body)&&(t=h.changedTouches[0].pageY)},n=h=>{if(!e||e===document.documentElement||e===document.body){h.preventDefault();return}let p=h.changedTouches[0].pageY,y=e.scrollTop,v=e.scrollHeight-e.clientHeight;v!==0&&((y<=0&&p>t||y>=v&&p<t)&&h.preventDefault(),t=p)},s=h=>{let p=h.target;Jr(p)&&p!==document.activeElement&&(h.preventDefault(),p.style.transform="translateY(-2000px)",p.focus(),requestAnimationFrame(()=>{p.style.transform=""}))},a=h=>{let p=h.target;Jr(p)&&(p.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{p.style.transform="",Dr&&(Dr.height<window.innerHeight?requestAnimationFrame(()=>{Jn(p)}):Dr.addEventListener("resize",()=>Jn(p),{once:!0}))}))},c=()=>{window.scrollTo(0,0)},i=window.pageXOffset,u=window.pageYOffset,d=Zn(Xc(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let f=Zn(St(document,"touchstart",r,{passive:!1,capture:!0}),St(document,"touchmove",n,{passive:!1,capture:!0}),St(document,"touchend",s,{passive:!1,capture:!0}),St(document,"focus",a,!0),St(window,"scroll",c));return()=>{d(),f(),window.scrollTo(i,u)}}function Xc(e,t,r){let n=e.style[t];return e.style[t]=r,()=>{e.style[t]=n}}function St(e,t,r,n){return e.addEventListener(t,r,n),()=>{e.removeEventListener(t,r,n)}}function Jn(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let r=Po(e);if(r!==document.documentElement&&r!==document.body&&r!==e){let n=r.getBoundingClientRect().top,s=e.getBoundingClientRect().top,a=e.getBoundingClientRect().bottom;const c=r.getBoundingClientRect().bottom+Qc;a>c&&(r.scrollTop+=s-n)}e=r.parentElement}}function Jr(e){return e instanceof HTMLInputElement&&!Gc.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Jc(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function eu(...e){return t=>e.forEach(r=>Jc(r,t))}function Io(...e){return g.useCallback(eu(...e),e)}const Do=new WeakMap;function he(e,t,r=!1){if(!e||!(e instanceof HTMLElement))return;let n={};Object.entries(t).forEach(([s,a])=>{if(s.startsWith("--")){e.style.setProperty(s,a);return}n[s]=e.style[s],e.style[s]=a}),!r&&Do.set(e,n)}function tu(e,t){if(!e||!(e instanceof HTMLElement))return;let r=Do.get(e);r&&(e.style[t]=r[t])}const ue=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function dr(e,t){if(!e)return null;const r=window.getComputedStyle(e),n=r.transform||r.webkitTransform||r.mozTransform;let s=n.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[ue(t)?13:12]):(s=n.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[ue(t)?5:4]):null)}function ru(e){return 8*(Math.log(e+1)-2)}function Fr(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}function nu(...e){return(...t)=>{for(const r of e)typeof r=="function"&&r(...t)}}const ae={DURATION:.5,EASE:[.32,.72,0,1]},Lo=.4,su=.25,ou=100,Fo=8,Ke=16,en=26,Br="vaul-dragging";function Bo(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...r)=>t.current==null?void 0:t.current.call(t,...r),[])}function au({defaultProp:e,onChange:t}){const r=x.useState(e),[n]=r,s=x.useRef(n),a=Bo(t);return x.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),r}function $o({prop:e,defaultProp:t,onChange:r=()=>{}}){const[n,s]=au({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:n,i=Bo(r),u=x.useCallback(d=>{if(a){const h=typeof d=="function"?d(e):d;h!==e&&i(h)}else s(d)},[a,e,s,i]);return[c,u]}function iu({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:r,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:c,direction:i="bottom",container:u,snapToSequentialPoint:d}){const[f,h]=$o({prop:e,defaultProp:r?.[0],onChange:t}),[p,y]=x.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);x.useEffect(()=>{function j(){y({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]);const v=x.useMemo(()=>f===r?.[r.length-1]||null,[r,f]),m=x.useMemo(()=>{var j;return(j=r?.findIndex(N=>N===f))!=null?j:null},[r,f]),w=r&&r.length>0&&(a||a===0)&&!Number.isNaN(a)&&r[a]===f||!r,b=x.useMemo(()=>{const j=u?{width:u.getBoundingClientRect().width,height:u.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var N;return(N=r?.map(M=>{const U=typeof M=="string";let W=0;if(U&&(W=parseInt(M,10)),ue(i)){const D=U?W:p?M*j.height:0;return p?i==="bottom"?j.height-D:-j.height+D:D}const K=U?W:p?M*j.width:0;return p?i==="right"?j.width-K:-j.width+K:K}))!=null?N:[]},[r,p,u]),R=x.useMemo(()=>m!==null?b?.[m]:null,[b,m]),T=x.useCallback(j=>{var N;const M=(N=b?.findIndex(U=>U===j))!=null?N:null;c(M),he(n.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(i)?`translate3d(0, ${j}px, 0)`:`translate3d(${j}px, 0, 0)`}),b&&M!==b.length-1&&a!==void 0&&M!==a&&M<a?he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"0"}):he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),h(r?.[Math.max(M,0)])},[n.current,r,b,a,s,h]);x.useEffect(()=>{if(f||e){var j;const N=(j=r?.findIndex(M=>M===e||M===f))!=null?j:-1;b&&N!==-1&&typeof b[N]=="number"&&T(b[N])}},[f,e,r,b,T]);function k({draggedDistance:j,closeDrawer:N,velocity:M,dismissible:U}){if(a===void 0)return;const W=i==="bottom"||i==="right"?(R??0)-j:(R??0)+j,K=m===a-1,D=m===0,X=j>0;if(K&&he(s.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),!d&&M>2&&!X){U?N():T(b[0]);return}if(!d&&M>2&&X&&b&&r){T(b[r.length-1]);return}const J=b?.reduce((te,_)=>typeof te!="number"||typeof _!="number"?te:Math.abs(_-W)<Math.abs(te-W)?_:te),re=ue(i)?window.innerHeight:window.innerWidth;if(M>Lo&&Math.abs(j)<re*.4){const te=X?1:-1;if(te>0&&v&&r){T(b[r.length-1]);return}if(D&&te<0&&U&&N(),m===null)return;T(b[m+te]);return}T(J)}function A({draggedDistance:j}){if(R===null)return;const N=i==="bottom"||i==="right"?R-j:R+j;(i==="bottom"||i==="right")&&N<b[b.length-1]||(i==="top"||i==="left")&&N>b[b.length-1]||he(n.current,{transform:ue(i)?`translate3d(0, ${N}px, 0)`:`translate3d(${N}px, 0, 0)`})}function L(j,N){if(!r||typeof m!="number"||!b||a===void 0)return null;const M=m===a-1;if(m>=a&&N)return 0;if(M&&!N)return 1;if(!w&&!M)return null;const W=M?m+1:m-1,K=M?b[W]-b[W-1]:b[W+1]-b[W],D=j/Math.abs(K);return M?1-D:D}return{isLastSnapPoint:v,activeSnapPoint:f,shouldFade:w,getPercentageDragged:L,setActiveSnapPoint:h,activeSnapPointIndex:m,onRelease:k,onDrag:A,snapPointsOffset:b}}const lu=()=>()=>{};function cu(){const{direction:e,isOpen:t,shouldScaleBackground:r,setBackgroundColorOnScale:n,noBodyStyles:s}=Pt(),a=x.useRef(null),c=x.useMemo(()=>document.body.style.backgroundColor,[]);function i(){return(window.innerWidth-en)/window.innerWidth}x.useEffect(()=>{if(t&&r){a.current&&clearTimeout(a.current);const u=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!u)return;nu(n&&!s?Fr(document.body,{background:"black"}):lu,Fr(u,{transformOrigin:ue(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`}));const d=Fr(u,{borderRadius:`${Fo}px`,overflow:"hidden",...ue(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(()=>{c?document.body.style.background=c:document.body.style.removeProperty("background")},ae.DURATION*1e3)}}},[t,r,c])}let Et=null;function uu({isOpen:e,modal:t,nested:r,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[c,i]=x.useState(()=>typeof window<"u"?window.location.href:""),u=x.useRef(0),d=x.useCallback(()=>{if(Yn()&&Et===null&&e&&!a){Et={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:h,innerHeight:p}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-u.current}px`,left:`${-h}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const y=p-window.innerHeight;y&&u.current>=p&&(document.body.style.top=`${-(u.current+y)}px`)}),300)}},[e]),f=x.useCallback(()=>{if(Yn()&&Et!==null&&!a){const h=-parseInt(document.body.style.top,10),p=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Et),window.requestAnimationFrame(()=>{if(s&&c!==window.location.href){i(window.location.href);return}window.scrollTo(p,h)}),Et=null}},[c]);return x.useEffect(()=>{function h(){u.current=window.scrollY}return h(),window.addEventListener("scroll",h),()=>{window.removeEventListener("scroll",h)}},[]),x.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||f()}},[t,f]),x.useEffect(()=>{r||!n||(e?(!window.matchMedia("(display-mode: standalone)").matches&&d(),t||window.setTimeout(()=>{f()},500)):f())},[e,n,c,t,r,d,f]),{restorePositionSetting:f}}function du({open:e,onOpenChange:t,children:r,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:c=!1,setBackgroundColorOnScale:i=!0,closeThreshold:u=su,scrollLockTimeout:d=ou,dismissible:f=!0,handleOnly:h=!1,fadeFromIndex:p=a&&a.length-1,activeSnapPoint:y,setActiveSnapPoint:v,fixed:m,modal:w=!0,onClose:b,nested:R,noBodyStyles:T=!1,direction:k="bottom",defaultOpen:A=!1,disablePreventScroll:L=!0,snapToSequentialPoint:j=!1,preventScrollRestoration:N=!1,repositionInputs:M=!0,onAnimationEnd:U,container:W,autoFocus:K=!1}){var D,X;const[J=!1,re]=$o({defaultProp:A,prop:e,onChange:z=>{t?.(z),!z&&!R&&st(),setTimeout(()=>{U?.(z)},ae.DURATION*1e3),z&&!w&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),z||(document.body.style.pointerEvents="auto")}}),[te,_]=x.useState(!1),[oe,me]=x.useState(!1),[xe,ve]=x.useState(!1),Y=x.useRef(null),ne=x.useRef(null),ye=x.useRef(null),Te=x.useRef(null),F=x.useRef(null),ke=x.useRef(!1),we=x.useRef(null),l=x.useRef(0),C=x.useRef(!1),S=x.useRef(!A),O=x.useRef(0),E=x.useRef(null),$=x.useRef(((D=E.current)==null?void 0:D.getBoundingClientRect().height)||0),H=x.useRef(((X=E.current)==null?void 0:X.getBoundingClientRect().width)||0),B=x.useRef(0),le=x.useCallback(z=>{a&&z===_e.length-1&&(ne.current=new Date)},[]),{activeSnapPoint:V,activeSnapPointIndex:ee,setActiveSnapPoint:We,onRelease:tt,snapPointsOffset:_e,onDrag:rt,shouldFade:He,getPercentageDragged:nt}=iu({snapPoints:a,activeSnapPointProp:y,setActiveSnapPointProp:v,drawerRef:E,fadeFromIndex:p,overlayRef:Y,onSnapPointChange:le,direction:k,container:W,snapToSequentialPoint:j});Yc({isDisabled:!J||oe||!w||xe||!te||!M||!L});const{restorePositionSetting:st}=uu({isOpen:J,modal:w,nested:R??!1,hasBeenOpened:te,preventScrollRestoration:N,noBodyStyles:T});function Pe(){return(window.innerWidth-en)/window.innerWidth}function ot(z){var G,Z;!f&&!a||E.current&&!E.current.contains(z.target)||($.current=((G=E.current)==null?void 0:G.getBoundingClientRect().height)||0,H.current=((Z=E.current)==null?void 0:Z.getBoundingClientRect().width)||0,me(!0),ye.current=new Date,Mo()&&window.addEventListener("touchend",()=>ke.current=!1,{once:!0}),z.target.setPointerCapture(z.pointerId),l.current=ue(k)?z.pageY:z.pageX)}function Ve(z,G){var Z;let Q=z;const se=(Z=window.getSelection())==null?void 0:Z.toString(),de=E.current?dr(E.current,k):null,ce=new Date;if(Q.tagName==="SELECT"||Q.hasAttribute("data-vaul-no-drag")||Q.closest("[data-vaul-no-drag]"))return!1;if(k==="right"||k==="left")return!0;if(ne.current&&ce.getTime()-ne.current.getTime()<500)return!1;if(de!==null&&(k==="bottom"?de>0:de<0))return!0;if(se&&se.length>0)return!1;if(F.current&&ce.getTime()-F.current.getTime()<d&&de===0||G)return F.current=ce,!1;for(;Q;){if(Q.scrollHeight>Q.clientHeight){if(Q.scrollTop!==0)return F.current=new Date,!1;if(Q.getAttribute("role")==="dialog")return!0}Q=Q.parentNode}return!0}function at(z){if(E.current&&oe){const G=k==="bottom"||k==="right"?1:-1,Z=(l.current-(ue(k)?z.pageY:z.pageX))*G,Q=Z>0,se=a&&!f&&!Q;if(se&&ee===0)return;const de=Math.abs(Z),ce=document.querySelector("[data-vaul-drawer-wrapper]"),je=k==="bottom"||k==="top"?$.current:H.current;let ge=de/je;const Ee=nt(de,Q);if(Ee!==null&&(ge=Ee),se&&ge>=1||!ke.current&&!Ve(z.target,Q))return;if(E.current.classList.add(Br),ke.current=!0,he(E.current,{transition:"none"}),he(Y.current,{transition:"none"}),a&&rt({draggedDistance:Z}),Q&&!a){const be=ru(Z),Ie=Math.min(be*-1,0)*G;he(E.current,{transform:ue(k)?`translate3d(0, ${Ie}px, 0)`:`translate3d(${Ie}px, 0, 0)`});return}const Se=1-ge;if((He||p&&ee===p-1)&&(n?.(z,ge),he(Y.current,{opacity:`${Se}`,transition:"none"},!0)),ce&&Y.current&&c){const be=Math.min(Pe()+ge*(1-Pe()),1),Ie=8-ge*8,qe=Math.max(0,14-ge*14);he(ce,{borderRadius:`${Ie}px`,transform:ue(k)?`scale(${be}) translate3d(0, ${qe}px, 0)`:`scale(${be}) translate3d(${qe}px, 0, 0)`,transition:"none"},!0)}if(!a){const be=de*G;he(E.current,{transform:ue(k)?`translate3d(0, ${be}px, 0)`:`translate3d(${be}px, 0, 0)`})}}}x.useEffect(()=>{window.requestAnimationFrame(()=>{S.current=!0})},[]),x.useEffect(()=>{var z;function G(){if(!E.current||!M)return;const Z=document.activeElement;if(Jr(Z)||C.current){var Q;const se=((Q=window.visualViewport)==null?void 0:Q.height)||0,de=window.innerHeight;let ce=de-se;const je=E.current.getBoundingClientRect().height||0,ge=je>de*.8;B.current||(B.current=je);const Ee=E.current.getBoundingClientRect().top;if(Math.abs(O.current-ce)>60&&(C.current=!C.current),a&&a.length>0&&_e&&ee){const Se=_e[ee]||0;ce+=Se}if(O.current=ce,je>se||C.current){const Se=E.current.getBoundingClientRect().height;let be=Se;Se>se&&(be=se-(ge?Ee:en)),m?E.current.style.height=`${Se-Math.max(ce,0)}px`:E.current.style.height=`${Math.max(be,se-Ee)}px`}else Hc()||(E.current.style.height=`${B.current}px`);a&&a.length>0&&!C.current?E.current.style.bottom="0px":E.current.style.bottom=`${Math.max(ce,0)}px`}}return(z=window.visualViewport)==null||z.addEventListener("resize",G),()=>{var Z;return(Z=window.visualViewport)==null?void 0:Z.removeEventListener("resize",G)}},[ee,a,_e]);function Ae(z){it(),b?.(),z||re(!1),setTimeout(()=>{a&&We(a[0])},ae.DURATION*1e3)}function Ue(){if(!E.current)return;const z=document.querySelector("[data-vaul-drawer-wrapper]"),G=dr(E.current,k);he(E.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),he(Y.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),c&&G&&G>0&&J&&he(z,{borderRadius:`${Fo}px`,overflow:"hidden",...ue(k)?{transform:`scale(${Pe()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${Pe()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`},!0)}function it(){!oe||!E.current||(E.current.classList.remove(Br),ke.current=!1,me(!1),Te.current=new Date)}function lt(z){if(!oe||!E.current)return;E.current.classList.remove(Br),ke.current=!1,me(!1),Te.current=new Date;const G=dr(E.current,k);if(!z||!Ve(z.target,!1)||!G||Number.isNaN(G)||ye.current===null)return;const Z=Te.current.getTime()-ye.current.getTime(),Q=l.current-(ue(k)?z.pageY:z.pageX),se=Math.abs(Q)/Z;if(se>.05&&(ve(!0),setTimeout(()=>{ve(!1)},200)),a){tt({draggedDistance:Q*(k==="bottom"||k==="right"?1:-1),closeDrawer:Ae,velocity:se,dismissible:f}),s?.(z,!0);return}if(k==="bottom"||k==="right"?Q>0:Q<0){Ue(),s?.(z,!0);return}if(se>Lo){Ae(),s?.(z,!1);return}var de;const ce=Math.min((de=E.current.getBoundingClientRect().height)!=null?de:0,window.innerHeight);var je;const ge=Math.min((je=E.current.getBoundingClientRect().width)!=null?je:0,window.innerWidth),Ee=k==="left"||k==="right";if(Math.abs(G)>=(Ee?ge:ce)*u){Ae(),s?.(z,!1);return}s?.(z,!0),Ue()}x.useEffect(()=>(J&&(he(document.documentElement,{scrollBehavior:"auto"}),ne.current=new Date),()=>{tu(document.documentElement,"scrollBehavior")}),[J]);function ct(z){const G=z?(window.innerWidth-Ke)/window.innerWidth:1,Z=z?-Ke:0;we.current&&window.clearTimeout(we.current),he(E.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(k)?`scale(${G}) translate3d(0, ${Z}px, 0)`:`scale(${G}) translate3d(${Z}px, 0, 0)`}),!z&&E.current&&(we.current=setTimeout(()=>{const Q=dr(E.current,k);he(E.current,{transition:"none",transform:ue(k)?`translate3d(0, ${Q}px, 0)`:`translate3d(${Q}px, 0, 0)`})},500))}function ut(z,G){if(G<0)return;const Z=(window.innerWidth-Ke)/window.innerWidth,Q=Z+G*(1-Z),se=-Ke+G*Ke;he(E.current,{transform:ue(k)?`scale(${Q}) translate3d(0, ${se}px, 0)`:`scale(${Q}) translate3d(${se}px, 0, 0)`,transition:"none"})}function dt(z,G){const Z=ue(k)?window.innerHeight:window.innerWidth,Q=G?(Z-Ke)/Z:1,se=G?-Ke:0;G&&he(E.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(k)?`scale(${Q}) translate3d(0, ${se}px, 0)`:`scale(${Q}) translate3d(${se}px, 0, 0)`})}return x.useEffect(()=>{w||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[w]),x.createElement(So,{defaultOpen:A,onOpenChange:z=>{!f&&!z||(z?_(!0):Ae(!0),re(z))},open:J},x.createElement(Ao.Provider,{value:{activeSnapPoint:V,snapPoints:a,setActiveSnapPoint:We,drawerRef:E,overlayRef:Y,onOpenChange:t,onPress:ot,onRelease:lt,onDrag:at,dismissible:f,shouldAnimate:S,handleOnly:h,isOpen:J,isDragging:oe,shouldFade:He,closeDrawer:Ae,onNestedDrag:ut,onNestedOpenChange:ct,onNestedRelease:dt,keyboardIsOpen:C,modal:w,snapPointsOffset:_e,activeSnapPointIndex:ee,direction:k,shouldScaleBackground:c,setBackgroundColorOnScale:i,noBodyStyles:T,container:W,autoFocus:K}},r))}const zo=x.forwardRef(function({...e},t){const{overlayRef:r,snapPoints:n,onRelease:s,shouldFade:a,isOpen:c,modal:i,shouldAnimate:u}=Pt(),d=Io(t,r),f=n&&n.length>0;if(!i)return null;const h=x.useCallback(p=>s(p),[s]);return x.createElement(No,{onMouseUp:h,ref:d,"data-vaul-overlay":"","data-vaul-snap-points":c&&f?"true":"false","data-vaul-snap-points-overlay":c&&a?"true":"false","data-vaul-animate":u?.current?"true":"false",...e})});zo.displayName="Drawer.Overlay";const Wo=x.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:r,...n},s){const{drawerRef:a,onPress:c,onRelease:i,onDrag:u,keyboardIsOpen:d,snapPointsOffset:f,activeSnapPointIndex:h,modal:p,isOpen:y,direction:v,snapPoints:m,container:w,handleOnly:b,shouldAnimate:R,autoFocus:T}=Pt(),[k,A]=x.useState(!1),L=Io(s,a),j=x.useRef(null),N=x.useRef(null),M=x.useRef(!1),U=m&&m.length>0;cu();const W=(D,X,J=0)=>{if(M.current)return!0;const re=Math.abs(D.y),te=Math.abs(D.x),_=te>re,oe=["bottom","right"].includes(X)?1:-1;if(X==="left"||X==="right"){if(!(D.x*oe<0)&&te>=0&&te<=J)return _}else if(!(D.y*oe<0)&&re>=0&&re<=J)return!_;return M.current=!0,!0};x.useEffect(()=>{U&&window.requestAnimationFrame(()=>{A(!0)})},[]);function K(D){j.current=null,M.current=!1,i(D)}return x.createElement(To,{"data-vaul-drawer-direction":v,"data-vaul-drawer":"","data-vaul-delayed-snap-points":k?"true":"false","data-vaul-snap-points":y&&U?"true":"false","data-vaul-custom-container":w?"true":"false","data-vaul-animate":R?.current?"true":"false",...n,ref:L,style:f&&f.length>0?{"--snap-point-height":`${f[h??0]}px`,...t}:t,onPointerDown:D=>{b||(n.onPointerDown==null||n.onPointerDown.call(n,D),j.current={x:D.pageX,y:D.pageY},c(D))},onOpenAutoFocus:D=>{r?.(D),T||D.preventDefault()},onPointerDownOutside:D=>{if(e?.(D),!p||D.defaultPrevented){D.preventDefault();return}d.current&&(d.current=!1)},onFocusOutside:D=>{if(!p){D.preventDefault();return}},onPointerMove:D=>{if(N.current=D,b||(n.onPointerMove==null||n.onPointerMove.call(n,D),!j.current))return;const X=D.pageY-j.current.y,J=D.pageX-j.current.x,re=D.pointerType==="touch"?10:2;W({x:J,y:X},v,re)?u(D):(Math.abs(J)>re||Math.abs(X)>re)&&(j.current=null)},onPointerUp:D=>{n.onPointerUp==null||n.onPointerUp.call(n,D),j.current=null,M.current=!1,i(D)},onPointerOut:D=>{n.onPointerOut==null||n.onPointerOut.call(n,D),K(N.current)},onContextMenu:D=>{n.onContextMenu==null||n.onContextMenu.call(n,D),N.current&&K(N.current)}})});Wo.displayName="Drawer.Content";const fu=250,hu=120,mu=x.forwardRef(function({preventCycle:e=!1,children:t,...r},n){const{closeDrawer:s,isDragging:a,snapPoints:c,activeSnapPoint:i,setActiveSnapPoint:u,dismissible:d,handleOnly:f,isOpen:h,onPress:p,onDrag:y}=Pt(),v=x.useRef(null),m=x.useRef(!1);function w(){if(m.current){T();return}window.setTimeout(()=>{b()},hu)}function b(){if(a||e||m.current){T();return}if(T(),!c||c.length===0){d||s();return}if(i===c[c.length-1]&&d){s();return}const A=c.findIndex(j=>j===i);if(A===-1)return;const L=c[A+1];u(L)}function R(){v.current=window.setTimeout(()=>{m.current=!0},fu)}function T(){v.current&&window.clearTimeout(v.current),m.current=!1}return x.createElement("div",{onClick:w,onPointerCancel:T,onPointerDown:k=>{f&&p(k),R()},onPointerMove:k=>{f&&y(k)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...r},x.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});mu.displayName="Drawer.Handle";function pu(e){const t=Pt(),{container:r=t.container,...n}=e;return x.createElement(Eo,{container:r,...n})}const Ge={Root:du,Content:Wo,Overlay:zo,Portal:pu,Close:_o,Title:Ro,Description:Oo};function xu(e=768){const[t,r]=x.useState(!1);return x.useEffect(()=>{const n=()=>{r(window.innerWidth<e)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]),t}function Nt(...e){return Vs(_s(e))}const vu={position:"fixed",inset:0,zIndex:9999,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"},gu={position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:9999,display:"flex",flexDirection:"column"},bu={position:"fixed",inset:0,zIndex:9999,backgroundColor:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(4px)"},yu={position:"fixed",left:0,right:0,bottom:0,zIndex:9999,maxHeight:"96vh"};function pn({open:e,onOpenChange:t,children:r,title:n,description:s,className:a="",showCloseButton:c=!0,height:i}){const u=xu(),{theme:d}=Ia(),f={"--optimex-primary":d.colors.primary,"--optimex-background":d.colors.background,"--optimex-surface":d.colors.surface,"--optimex-text":d.colors.text.primary,"--optimex-text-secondary":d.colors.text.secondary,"--optimex-error":d.colors.error,"--optimex-success":d.colors.success,"--optimex-radius-widget":d.radius.widget,"--optimex-radius-input":d.radius.input,"--optimex-radius-button":d.radius.button,"--optimex-overlay-background":d.overlay.background,"--optimex-overlay-radius":d.overlay.radius,"--optimex-font-family":d.fontFamily};return u?o.jsx(Ge.Root,{open:e,onOpenChange:t,children:o.jsxs(Ge.Portal,{children:[o.jsx(Ge.Overlay,{style:bu}),o.jsx(Ge.Content,{style:yu,children:o.jsxs("div",{className:Nt("optx-widget flex flex-col bg-[var(--optimex-overlay-background)] outline-none",a),style:{...f,height:i,maxHeight:"96vh",borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.1)",backgroundColor:d.overlay.background,borderRadius:`${d.overlay.radius} ${d.overlay.radius} 0 0`},children:[o.jsx("div",{className:"mx-auto mt-4 h-1.5 w-12 flex-shrink-0 rounded-full bg-white/20"}),(n||c)&&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:[n&&o.jsx(Ge.Title,{className:"text-lg font-bold text-[var(--optimex-text)]",children:n}),s&&o.jsx(Ge.Description,{className:"text-sm text-[var(--optimex-text-secondary)]",children:s})]}),c&&o.jsx(Ge.Close,{className:"rounded-[var(--optimex-radius-button)] p-1.5 text-[var(--optimex-text-secondary)] transition-colors hover:bg-white/10 hover:text-[var(--optimex-text)]",children:o.jsx(Ze,{})})]}),o.jsx("div",{className:"flex flex-1 flex-col overflow-auto",children:r})]})})]})}):o.jsx(So,{open:e,onOpenChange:t,children:o.jsxs(Eo,{children:[o.jsx(No,{style:vu,className:"animate-modal-overlay-in data-[state=closed]:animate-modal-overlay-out"}),o.jsx(To,{style:{...gu,height:i,maxHeight:i||"85vh"},className:Nt("animate-modal-in data-[state=closed]:animate-modal-out",a),children:o.jsxs("div",{className:Nt("optx-widget flex flex-col rounded-[var(--optimex-overlay-radius)] border border-white/10 bg-[var(--optimex-overlay-background)] shadow-2xl outline-none"),style:{...f,flex:1,minHeight:0,height:"100%",borderStyle:"solid",borderColor:"rgba(255, 255, 255, 0.1)",backgroundColor:d.overlay.background,borderRadius:d.overlay.radius},children:[(n||s||c)&&o.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-b border-white/[0.05] p-4",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[n&&o.jsx(Ro,{className:"text-lg font-bold leading-none text-[var(--optimex-text)]",children:n}),s&&o.jsx(Oo,{className:"text-sm text-[var(--optimex-text-secondary)]",children:s})]}),c&&o.jsxs(_o,{className:"rounded-[var(--optimex-radius-button)] p-1.5 text-[var(--optimex-text-secondary)] opacity-70 transition-opacity hover:opacity-100 hover:bg-white/10 focus:outline-none",children:[o.jsx(Ze,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]}),o.jsx("div",{className:"flex flex-1 flex-col overflow-hidden min-h-0",children:r})]})})]})})}const wu=({children:e,className:t=""})=>o.jsx("div",{className:Nt("p-4",t),children:e}),Cu=({children:e,className:t=""})=>o.jsx("div",{className:Nt("flex gap-2 border-t border-white/[0.05] p-4",t),children:e});function tn({children:e,onClick:t,isActive:r=!1,type:n="button",className:s=""}){return o.jsx("button",{type:n,onClick:t,className:Us(`px-2 py-1 bg-white/5 rounded-md text-xs transition-colors shadow-sm border ${r?"border-[var(--optimex-primary)] text-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-[var(--optimex-surface-hover)] hover:text-[var(--optimex-text)]"} ${s}`),children:e})}const ku={"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"},ju={"bottom-right":"-top-2 right-4 rotate-45 border-l border-t border-white/10","bottom-left":"-top-2 left-4 rotate-45 border-l border-t border-white/10","bottom-center":"-top-2 left-1/2 -translate-x-1/2 rotate-45 border-l border-t border-white/10","top-right":"-bottom-2 right-4 rotate-45 border-r border-b border-white/10","top-left":"-bottom-2 left-4 rotate-45 border-r border-b border-white/10","top-center":"-bottom-2 left-1/2 -translate-x-1/2 rotate-45 border-r border-b border-white/10"};function Su({isOpen:e,onClose:t,children:r,anchorRef:n,position:s="bottom-right",width:a="w-72",showArrow:c=!1,className:i="",ariaLabel:u}){const d=x.useRef(null);return x.useEffect(()=>{if(!e)return;const f=y=>{const v=y.target;d.current?.contains(v)||n?.current?.contains(v)||t()},h=y=>{y.key==="Escape"&&t()},p=setTimeout(()=>{document.addEventListener("mousedown",f),document.addEventListener("keydown",h)},0);return()=>{clearTimeout(p),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",h)}},[e,t,n]),e?o.jsxs("div",{ref:d,className:`absolute z-50 rounded-[var(--optimex-overlay-radius)] border border-white/10 bg-[var(--optimex-overlay-background)] p-4 shadow-xl ${ku[s]} ${a} ${i}`,role:"dialog","aria-label":u,children:[c&&o.jsx("div",{className:`absolute h-4 w-4 bg-[var(--optimex-overlay-background)] ${ju[s]}`}),o.jsx("div",{className:"relative",children:r})]}):null}function Eu({value:e,onChange:t,placeholder:r,hasError:n=!1,leftIcon:s,rightContent:a,type:c="text",inputMode:i="text",disabled:u=!1,className:d=""}){return o.jsxs("div",{className:`flex rounded-[var(--optimex-radius-button)] items-center gap-2 bg-white/5 border py-3 px-3 transition-colors ${n?"border-[var(--optimex-error)]":"border-white/10 hover:border-[var(--optimex-primary)] focus-within:border-[var(--optimex-primary)]"} ${u?"opacity-50 cursor-not-allowed":""} ${d}`,children:[s&&o.jsx(s,{className:"size-5 text-[var(--optimex-text-secondary)] shrink-0"}),o.jsx("input",{type:c,inputMode:i,value:e,onChange:f=>t(f.target.value),placeholder:r,disabled:u,className:"flex-1 min-w-0 bg-transparent text-[var(--optimex-text)] text-sm placeholder:text-[var(--optimex-text-secondary)]/30 outline-none disabled:cursor-not-allowed"}),a]})}const Nu={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 Je({token:e,size:t="md",showNetworkBadge:r=!0}){const n=Nu[t];return o.jsxs("div",{className:`relative shrink-0 ${n.container}`,children:[o.jsx("img",{src:e.token_logo_uri||"/placeholder-token.svg",alt:e.token_symbol,className:`${n.icon} rounded-[9999px] bg-[var(--optimex-background)]`,onError:s=>{s.target.src="/placeholder-token.svg"}}),r&&e.network_logo_uri&&o.jsx("img",{src:e.network_logo_uri,alt:e.network_name,className:`absolute -bottom-1 -right-1 ${n.badge} rounded-[9999px] border-2 border-[var(--optimex-surface)]`,onError:s=>{s.target.style.display="none"}})]})}const Tu="widget-container rounded-[var(--optimex-radius-widget)] p-4 shadow-2xl relative w-full min-w-0";function xn({children:e,className:t}){return o.jsx("div",{className:t??Tu,children:e})}function Ru(){return o.jsxs("div",{className:"relative size-20 mb-4",children:[o.jsx("div",{className:"absolute inset-0 rounded-full bg-[var(--optimex-error)]/10 animate-pulse"}),o.jsx("div",{className:"absolute inset-2 rounded-full bg-[var(--optimex-error)]/20"}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsx(fi,{className:"size-10 text-[var(--optimex-error)]"})})]})}function Ou({error:e,onRetry:t,className:r}){const n=()=>{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(xn,{className:r,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(Ru,{}),o.jsx("h3",{className:"text-base font-bold text-[var(--optimex-text)] mb-1",children:"Oops! Something went wrong"}),o.jsx("p",{className:"text-sm text-[var(--optimex-text-secondary)] mb-6 max-w-[280px]",children:n()}),o.jsx(cn,{onClick:t,size:"md",fullWidth:!0,leftIcon:o.jsx(di,{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-[var(--optimex-text-secondary)]/60 hover:text-[var(--optimex-text-secondary)] transition-colors",children:"Technical details"}),o.jsx("p",{className:"mt-2 bg-white/5 p-3 text-left text-xs text-[var(--optimex-text-secondary)] break-all border border-white/[0.02]",children:e.message})]})]})})})}function _u({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(xn,{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 Ho=x.createContext(null);function Au({children:e}){const t=Mt(),{data:r,isLoading:n,error:s,refetch:a}=Ba(t.apiBaseUrl),c=t.renderLoading??_u,i=t.renderError??Ou;if(n)return o.jsx(c,{});if(s||!r){const u=s instanceof Error?s:new Error("Failed to load tokens");return o.jsx(i,{error:u,onRetry:()=>a()})}return o.jsx(Ho.Provider,{value:{tokensData:r,refetch:a},children:e})}function Mu(){const e=x.useContext(Ho);if(!e)throw new Error("useTokensData must be used within TokensProvider");return e}function Pu({token:e,value:t,onChange:r,placeholder:n,error:s,onClose:a}){const c=x.useCallback(()=>{r("")},[r]),i=x.useCallback(async()=>{try{const h=await navigator.clipboard.readText();h&&r(h.trim())}catch(h){console.error("Failed to read clipboard:",h)}},[r]),u=()=>n||(e?`Enter ${e.network_name} address`:"Enter receiving address"),d=e?.network_name||"destination",f=x.useMemo(()=>pi(e?.network_name)||Cs,[e?.network_name]);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-[var(--optimex-radius-input)] 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-[var(--optimex-text-secondary)] text-xs",children:"Recipient Address"}),a&&o.jsx("button",{type:"button",onClick:c,className:"text-[var(--optimex-text-secondary)]/50 hover:text-[var(--optimex-text-secondary)] transition-colors",children:o.jsx(Ze,{className:"size-4"})})]}),o.jsx(Eu,{value:t,onChange:r,placeholder:u(),hasError:!!s,leftIcon:f,rightContent:t?o.jsx("button",{type:"button",onClick:c,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors",children:o.jsx(Ze,{className:"size-5"})}):o.jsx("button",{type:"button",onClick:i,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-primary)] transition-colors",children:o.jsx(ui,{className:"size-5"})})}),s?o.jsxs("p",{className:"text-[10px] text-[var(--optimex-error)] mt-2 flex items-center gap-1",children:[o.jsx(On,{className:"size-3"}),s]}):o.jsxs("p",{className:"text-[10px] text-[var(--optimex-text-secondary)] mt-2 flex items-center gap-1",children:[o.jsx(On,{className:"size-3"}),"Ensure the address matches the ",d," network."]})]})}function es({token:e,value:t,onChange:r,readOnly:n=!1,onSelectToken:s,isLoading:a=!1,loadingText:c="Loading...",balance:i,isOutput:u=!1,isWalletConnected:d=!1,usdValue:f="$0.00"}){const h=m=>{if(n||!r)return;const w=m.target.value;/^[0-9]*\.?[0-9]*$/.test(w)&&r(w)},p=d&&!u&&i!==void 0,y=()=>{if(!i||!r||n)return;const m=(parseFloat(i)/2).toString();r(m)},v=()=>{!i||!r||n||r(i)};return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-[var(--optimex-radius-input)] 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-[var(--optimex-text-secondary)] text-xs",children:u?"To":"From"}),o.jsx("div",{className:"flex items-center gap-2",children:p&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-[var(--optimex-text-secondary)] text-xs",children:["Balance: ",i," ",e?.token_symbol]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(tn,{onClick:y,children:"50%"}),o.jsx(tn,{onClick:v,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:h,readOnly:n,className:"w-full bg-transparent border-none p-0 text-[var(--optimex-text)] text-2xl font-bold focus:ring-0 placeholder:text-[var(--optimex-text-secondary)]/30 outline-none"}),o.jsxs("p",{className:"text-[var(--optimex-text-secondary)] text-xs mt-1",children:["~",f]})]}),o.jsxs("button",{onClick:s,className:"flex items-center gap-2 bg-white/5 hover:bg-white/10 p-2 pr-3 rounded-[9999px] transition-all border border-white/10 active:scale-95 shrink-0",children:[e?o.jsxs(o.Fragment,{children:[o.jsx(Je,{token:e,size:"md"}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-[var(--optimex-text)] text-sm font-bold leading-none",children:e.token_symbol}),o.jsx("p",{className:"text-[var(--optimex-text-secondary)] text-[10px] leading-none mt-1",children:e.network_name})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"size-8 rounded-[9999px] bg-white/10"}),o.jsx("span",{className:"text-[var(--optimex-text)] text-sm font-bold",children:"Select"})]}),o.jsx(ys,{className:"size-4 text-[var(--optimex-text-secondary)]"})]})]}),a&&o.jsxs("div",{className:"flex items-center justify-end gap-2 text-sm text-[var(--optimex-text-secondary)]",children:[o.jsx("div",{className:"size-3 animate-spin rounded-[9999px] border border-[var(--optimex-primary)] border-t-transparent"}),o.jsx("span",{children:c})]})]})}const $r=[.5,.75,1];function Iu({value:e,onChange:t}){const[r,n]=x.useState(""),[s,a]=x.useState(!$r.includes(e)),c=x.useCallback(d=>{a(!1),n(""),t(d)},[t]),i=x.useCallback(d=>{const f=d.target.value;if(f===""||/^\d*\.?\d*$/.test(f)){n(f),a(!0);const h=parseFloat(f);!isNaN(h)&&h>0&&h<=50&&t(h)}},[t]),u=x.useCallback(()=>{a(!0),!r&&e&&n($r.includes(e)?"":String(e))},[r,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:[$r.map(d=>o.jsxs(tn,{onClick:()=>c(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-white/5 border ${s?"border-[var(--optimex-primary)]":"border-transparent hover:bg-white/10"}`,children:[o.jsx("input",{type:"text",inputMode:"decimal",placeholder:"Custom",value:r,onChange:i,onFocus:u,className:"w-full min-w-0 py-[6px] bg-transparent text-center text-xs outline-none placeholder:text-[var(--optimex-text-secondary)] text-[var(--optimex-text)]"}),o.jsx("span",{className:"text-xs text-[var(--optimex-text-secondary)]",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 Du({isOpen:e,onClose:t,value:r,onChange:n,anchorRef:s}){const a=x.useCallback(c=>{n(c)},[n]);return o.jsx(Su,{isOpen:e,onClose:t,anchorRef:s,position:"bottom-right",width:"w-96",ariaLabel:"Slippage settings",children:o.jsx(Iu,{value:r,onChange:a})})}const Lu=({title:e})=>o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"size-8 bg-[var(--optimex-primary)] rounded-[var(--optimex-radius-button)] flex items-center justify-center shadow-[0_0_15px_rgba(235,98,0,0.3)]",children:o.jsx(li,{className:"w-5 h-auto text-white"})}),o.jsx("h2",{className:"text-xl font-bold tracking-tight text-[var(--optimex-text)]",children:e})]});function Fu({title:e="Swap",headerLeft:t,slippage:r=.75,onSlippageChange:n,isSettingsOpen:s=!1,onSettingsToggle:a,onHistoryClick:c,hideHistory:i=!1}){const u=x.useRef(null);return o.jsxs("header",{className:"flex items-center justify-between px-2",children:[t??o.jsx(Lu,{title:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[!i&&o.jsx("button",{onClick:c,className:"size-10 rounded-[var(--optimex-radius-button)] bg-white/5 hover:bg-white/10 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors flex items-center justify-center","aria-label":"Trade History",children:o.jsx(ai,{className:"size-5"})}),o.jsxs("div",{className:"relative",children:[o.jsx("button",{ref:u,onClick:a,className:"size-10 rounded-[var(--optimex-radius-button)] bg-white/5 hover:bg-white/10 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors flex items-center justify-center","aria-label":"Settings",children:o.jsx(mi,{className:"size-5"})}),o.jsx(Du,{isOpen:s,onClose:()=>a?.(),value:r,onChange:d=>n?.(d),anchorRef:u})]})]})]})}function Vo({onClick:e,disabled:t}){return o.jsx("div",{className:"!m-0 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-[9999px] 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(ni,{className:"size-5"})})})}function Bu({quote:e,fromToken:t,toToken:r,amount:n,slippage:s,isFetching:a}){const[c,i]=x.useState(!1),[u,d]=x.useState(!1),f=x.useCallback(()=>{d(b=>!b)},[]),h=x.useCallback(()=>{i(b=>!b)},[]),p=parseFloat(n)||0,y=parseFloat(e.min_amount_out)/Math.pow(10,r.token_decimals),v=p>0?y/p:0,m=y>0?p/y:0,w=()=>u?`1 ${r.token_symbol} ≈ ${m.toFixed(6)} ${t.token_symbol}`:`1 ${t.token_symbol} ≈ ${v.toFixed(6)} ${r.token_symbol}`;return o.jsxs("div",{className:"bg-white/[0.02] rounded-[var(--optimex-radius-button)] border border-white/5 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:h,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-[var(--optimex-text-secondary)] ",children:o.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),f()},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),f())},className:`text-[var(--optimex-text)] text-sm transition-colors ${a?"shiny-text":""}`,children:w()})}),o.jsx(ys,{className:`size-4 text-[var(--optimex-text-secondary)] transition-transform duration-200 ${c?"rotate-180":""}`})]}),o.jsx(ll,{isOpen:c,children: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-[var(--optimex-text-secondary)]",children:"Min. Received"}),o.jsxs("span",{className:`font-medium text-[var(--optimex-text)] ${a?"shiny-text":""}`,children:[ze(e.min_amount_out,r.token_decimals)," ",r.token_symbol]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[var(--optimex-text-secondary)]",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-[var(--optimex-text-secondary)]",children:"Slippage Tolerance"}),o.jsxs("span",{className:"font-medium text-[var(--optimex-text)]",children:[s,"%"]})]})]})})]})}function $u({text:e,disabled:t,isLoading:r,onClick:n}){return o.jsx(cn,{variant:"primary",size:"xl",fullWidth:!0,disabled:t,isLoading:r,onClick:n,children:e})}function zu(){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(ci,{className:"h-3 w-auto"})]})}function Wu({value:e,onChange:t,placeholder:r="Search by name or symbol..."}){return o.jsx("div",{className:"flex-shrink-0 p-4 pb-3",children:o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:"text",placeholder:r,value:e,onChange:n=>t(n.target.value),className:"w-full rounded-xl bg-white/5 border border-white/10 px-4 py-3 pl-10 pr-10 text-[var(--optimex-text)] outline-none placeholder:text-[var(--optimex-text-secondary)]/60 transition-colors hover:border-[var(--optimex-primary)] focus:border-[var(--optimex-primary)]"}),o.jsx(hi,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-[var(--optimex-text-secondary)]"}),e&&o.jsx("button",{type:"button",onClick:()=>t(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors",children:o.jsx(Ze,{className:"size-5"})})]})})}function Hu({networks:e,selectedNetwork:t,onSelectNetwork:r}){return o.jsxs("div",{className:"w-1/3 min-w-[140px] min-h-0 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-[var(--optimex-text-secondary)]",children:"Networks"}),o.jsxs("div",{className:"space-y-1 px-2",children:[o.jsxs("button",{onClick:()=>r(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-[var(--optimex-text)]":"text-[var(--optimex-text-secondary)] hover:bg-white/5 hover:text-[var(--optimex-text)]"}`,children:[o.jsx(ri,{}),o.jsx("span",{children:"All"})]}),e.map(n=>o.jsx(Vu,{network:n,isSelected:t===n.network_id,onSelect:()=>r(n.network_id)},n.network_id))]})]})}function Vu({network:e,isSelected:t,onSelect:r}){return o.jsxs("button",{onClick:r,className:`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors ${t?"bg-white/5 text-[var(--optimex-text)]":"text-[var(--optimex-text-secondary)] hover:bg-white/5 hover:text-[var(--optimex-text)]"}`,children:[e.logo_uri?o.jsx("img",{src:e.logo_uri,alt:e.name,className:"h-8 w-8 rounded-lg",onError:n=>{n.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 Uu({tokens:e,selectedSymbol:t,onSelectSymbol:r,maxVisible:n=12}){return o.jsxs("div",{className:"flex-shrink-0 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-[var(--optimex-text-secondary)]",children:"Tokens"}),o.jsxs("div",{className:"flex flex-wrap gap-1.5 overflow-hidden max-h-[5rem]",children:[o.jsx("button",{onClick:()=>r(null),className:`border rounded-lg px-2.5 py-1 text-xs font-medium transition-colors ${t===null?"border-[var(--optimex-primary)] text-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 hover:text-[var(--optimex-text)]"}`,children:"All"}),e.slice(0,n).map(s=>o.jsx(qu,{token:s,isSelected:t===s.token_symbol,onSelect:()=>r(s.token_symbol)},s.token_symbol))]})]})}function qu({token:e,isSelected:t,onSelect:r}){return o.jsxs("button",{onClick:r,className:Us("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-[var(--optimex-text)]":"border-transparent text-[var(--optimex-text-secondary)] hover:bg-white/10 hover:text-[var(--optimex-text)]"),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:n=>{n.target.style.display="none"}}),e.token_symbol]})}function kt(){const e=x.useContext(xs);if(!e)throw new Error("useWallet must be used within WalletProvider");return e}function Cr(e){return`https://network-api-stg.bitdex.xyz/${e}/rpc/zwD70RMT9DrE8L5SaMnJNMF8m70Gum`}function Qu(e){return e==="bitcoin_testnet"?"https://mempool.space/testnet4/api":"https://mempool.space/api"}function vn(e){return!e.token_address||e.token_address===""||e.token_address==="native"||e.token_address==="0x0000000000000000000000000000000000000000"}function Ku(e,t){if(!e||e==="0")return"0";const r=BigInt(e),n=BigInt(10**t),s=r/n,a=r%n;if(a===BigInt(0))return s.toString();let c=a.toString().padStart(t,"0");return c=c.replace(/0+$/,""),c.length>6&&(c=c.slice(0,6)),`${s}.${c}`}function Gu(e){return`0x70a08231000000000000000000000000${e.toLowerCase().replace("0x","")}`}async function Uo(e,t){const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`RPC request failed: ${r.status}`);return r.json()}async function Yu(e,t){const n=await Uo(e,{jsonrpc:"2.0",method:"eth_getBalance",params:[t,"latest"],id:1});if(n.error)throw new Error(`RPC error: ${n.error.message}`);const s=n.result||"0x0";return BigInt(s).toString()}async function Zu(e,t,r){const n={jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:Gu(r)},"latest"],id:1},s=await Uo(e,n);if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result||"0x0";return BigInt(a).toString()}async function Xu(e,t){const r=Cr(e.network_id),n=vn(e);let s;return n?s=await Yu(r,t):s=await Zu(r,e.token_address,t),{rawBalance:s,isNative:n}}async function Ju(e,t){const n=`${Qu(e.network_id)}/address/${t}`,s=await fetch(n);if(!s.ok)throw new Error(`Mempool API request failed: ${s.status}`);const a=await s.json(),c=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:(c+i).toString(),isNative:!0}}async function qo(e,t){const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`RPC request failed: ${r.status}`);return r.json()}async function ed(e,t){const n=await qo(e,{jsonrpc:"2.0",method:"getBalance",params:[t],id:1});if(n.error)throw new Error(`RPC error: ${n.error.message}`);return(n.result?.value||0).toString()}async function td(e,t,r){const s=await qo(e,{jsonrpc:"2.0",method:"getTokenAccountsByOwner",params:[r,{mint:t},{encoding:"jsonParsed"}],id:1});if(s.error)throw new Error(`RPC error: ${s.error.message}`);const a=s.result?.value||[];let c=BigInt(0);for(const i of a){const u=i.account.data.parsed.info.tokenAmount.amount;c+=BigInt(u)}return c.toString()}async function rd(e,t){const r=Cr(e.network_id),n=vn(e);let s;return n?s=await ed(r,t):s=await td(r,e.token_address,t),{rawBalance:s,isNative:n}}function nd(e,t){if(!t)return!1;switch(t){case ie.EVM:return e.isEvmConnected;case ie.BTC:return e.isBtcConnected;case ie.SOLANA:return e.isSolanaConnected;default:return!1}}function sd(e){if(!e)return"";switch(e){case ie.EVM:return"EVM";case ie.BTC:return"Bitcoin";case ie.SOLANA:return"Solana";default:return e}}function od(e,t){if(!t)return null;switch(t){case ie.EVM:return e.evmAddress;case ie.BTC:return e.btcAddress;case ie.SOLANA:return e.solanaAddress;default:return null}}async function Qo({provider:e,address:t,chainId:r,chainName:n="Unknown"}){let s=t;if(!s){const c=await e.request({method:"eth_accounts"});if(!c||c.length===0)throw new Error("No accounts found. Please connect your wallet first.");s=c[0]}let a=r;if(a===void 0){const c=await e.request({method:"eth_chainId"});a=parseInt(c,16)}return Ko({provider:e,address:s,chainId:a,chainName:n})}function Ko({provider:e,address:t,chainId:r,chainName:n="Unknown"}){return{address:t,publicKey:t,chain:{id:r,name:n,type:"EVM"},sendTransaction:async i=>{const u=i;return await e.request({method:"eth_sendTransaction",params:[{from:t,to:u.to,value:u.value?`0x${u.value.toString(16)}`:void 0,data:u.data}]})},getChainId:async()=>{const i=await e.request({method:"eth_chainId"});return parseInt(i,16)},switchChain:async i=>{try{await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${i.toString(16)}`}]})}catch(u){throw u.code===4902?new Error(`Chain ${i} not found in wallet. Please add it first.`):u}}}}const ad=Qo;async function id(e,t){const r=e.token_address||"native";let n;switch(e.network_type){case ie.BTC:n=await Ju(e,t);break;case ie.SOLANA:n=await rd(e,t);break;case ie.EVM:default:n=await Xu(e,t)}return{tokenId:r,networkId:e.network_id,walletAddress:t,rawBalance:n.rawBalance,formattedBalance:Ku(n.rawBalance,e.token_decimals),updatedAt:Date.now()}}const ld=30*1e3,cd=15*1e3;function ud(e,t){return!e||!t?["balance"]:["balance",e.network_id,e.token_address||"native",t]}function Go({token:e,walletAddress:t,enabled:r=!0,polling:n=!1,pollingInterval:s=cd}){const a=r&&!!e&&!!t,{data:c,isLoading:i,isFetching:u,error:d,refetch:f}=bt({queryKey:ud(e,t),queryFn:()=>id(e,t),enabled:a,staleTime:ld,retry:1,refetchOnWindowFocus:!1,refetchInterval:n?s:!1});return{balance:c,formattedBalance:c?.formattedBalance||"0",isLoading:a&&i,isFetching:a&&u,error:d,refetch:f}}function dd({token:e,isSelected:t,isDisabled:r,onSelect:n}){const s=kt(),a=od(s,e.network_type),{formattedBalance:c,isLoading:i}=Go({token:e,walletAddress:a,enabled:!!a}),u=!!a;return o.jsxs("button",{onClick:n,disabled:r,className:`flex w-full items-center gap-3 rounded-lg p-2 transition-colors ${t?"bg-white/5 text-[var(--optimex-text)]":r?"cursor-not-allowed opacity-50":"hover:bg-white/5"}`,children:[o.jsx(Je,{token:e}),o.jsxs("div",{className:"flex-1 text-left",children:[o.jsx("div",{className:"text-sm text-[var(--optimex-text-secondary)]",children:e.token_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[u&&o.jsx("span",{className:"text-sm font-medium text-[var(--optimex-text)]",children:i?o.jsx("span",{className:"inline-block h-4 w-12 animate-pulse rounded bg-white/10"}):c}),o.jsx("span",{className:"font-medium text-[var(--optimex-text)]",children:e.token_symbol})]})]}),t&&o.jsx(ln,{className:"h-5 w-5 text-[var(--optimex-primary)]"})]})}function fd({tokens:e,selectedTokenId:t,disabledTokenId:r,disabledTokenIds:n,isLoading:s,emptyMessage:a="No tokens available",onSelect:c}){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-[var(--optimex-text-secondary)]",children:a})}):o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1",children:e.map(i=>{const u=r===i.token_id||n?.has(i.token_id)===!0;return o.jsx(dd,{token:i,isSelected:t===i.token_id,isDisabled:u,onSelect:()=>c(i)},i.token_id)})})})}function hd({isOpen:e,onClose:t,onSelect:r,tokensData:n,isLoading:s,selectedToken:a,disabledTokenId:c,disabledTokenIds:i,tokens:u,emptyMessage:d,title:f="Select Token",filterNetworkType:h}){const[p,y]=x.useState(""),[v,m]=x.useState(null),[w,b]=x.useState(null),R=x.useMemo(()=>n?.supported_networks?h?n.supported_networks.filter(W=>W.type===h):n.supported_networks:[],[n,h]),T=u??n?.tokens,k=x.useMemo(()=>T?T.filter(W=>{if(h&&W.network_type!==h||v&&W.network_id!==v)return!1;if(p){const K=(X,J)=>X.toLowerCase().includes(J.toLowerCase()),D=p.toLowerCase();return K(W.token_symbol,D)||K(W.token_name,D)||K(W.token_address,D)}return!0}):[],[T,p,v,h]),A=x.useMemo(()=>{if(!T)return[];const W=new Map;return T.forEach(K=>{h&&K.network_type!==h||v&&K.network_id!==v||W.has(K.token_symbol)||W.set(K.token_symbol,K)}),Array.from(W.values())},[T,h,v]),L=x.useMemo(()=>w?k.filter(W=>W.token_symbol===w):k,[k,w]),j=()=>{y(""),m(null),b(null)},N=W=>{r(W),t(),j()},M=W=>{W||(t(),j())},U=W=>{m(W),b(null)};return o.jsx(pn,{open:e,onOpenChange:M,title:f,height:"70vh",children:o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o.jsx(Wu,{value:p,onChange:y}),o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(Hu,{networks:R,selectedNetwork:v,onSelectNetwork:U}),o.jsxs("div",{className:"flex flex-1 min-h-0 flex-col overflow-hidden",children:[o.jsx(Uu,{tokens:A,selectedSymbol:w,onSelectSymbol:b}),o.jsx(fd,{tokens:L,selectedTokenId:a?.token_id,disabledTokenId:c,disabledTokenIds:i,isLoading:s,emptyMessage:p?"No tokens found":d??"No tokens available",onSelect:N})]})]})]})})}function ts({token:e,amount:t,label:r,isEstimated:n=!1,highlight:s=!1,usdValue:a="$0.00"}){return o.jsx("div",{className:`p-4 rounded-xl border transition-all duration-200 ${s?"bg-[var(--optimex-surface)] border-[var(--optimex-primary)]/20 shadow-[0_0_15px_rgba(235,98,0,0.1)]":"bg-[var(--optimex-surface)] 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(Je,{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-[var(--optimex-text-secondary)]"}`,children:[r," ",n&&"(Est.)"]}),o.jsx("p",{className:"text-[var(--optimex-text)] text-sm font-semibold truncate",children:e.token_symbol}),o.jsx("p",{className:"text-[var(--optimex-text-secondary)] 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-[var(--optimex-text)] text-lg font-bold",children:n?`~${t}`:t}),o.jsx("p",{className:"text-[var(--optimex-text-secondary)] text-xs",children:a})]})]})})}function md({fromToken:e,toToken:t,fromAmount:r,toAmount:n,fromUsdValue:s="$0.00",toUsdValue:a="$0.00"}){return o.jsxs("div",{className:"relative flex flex-col gap-2",children:[o.jsx(ts,{token:e,amount:r,label:"You Pay",usdValue:s}),o.jsx(Vo,{onClick:()=>{},disabled:!0}),o.jsx(ts,{token:t,amount:n,label:"You Receive",usdValue:a})]})}function zr({label:e,value:t,borderTop:r}){return o.jsxs("div",{className:`flex justify-between items-center text-sm ${r?"pt-2 mt-2 border-t border-white/5":""}`,children:[o.jsx("span",{className:"text-[var(--optimex-text-secondary)]",children:e}),o.jsx("div",{className:"flex items-center gap-1 text-[var(--optimex-text)] font-medium",children:t})]})}function pd({minReceived:e,estimatedTime:t,slippage:r,networkFee:n="Included"}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] rounded-xl p-4 border border-white/5 space-y-3",children:[o.jsx(zr,{label:"Min. Received",value:e}),o.jsx(zr,{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(zr,{label:"Slippage Tolerance",value:r})]})}const xd=3e4,vd=6e4;function gr({symbol:e,enabled:t=!0}){const r=Mt(),{data:n,isLoading:s,isError:a}=bt({queryKey:["tokenPrice",e],queryFn:async()=>{if(!e)throw new Error("Symbol is required");return(await yt(r.apiBaseUrl).getTokenPrice(e)).current_price},enabled:t&&!!e,staleTime:xd,refetchInterval:vd,retry:2});return{price:n??null,isLoading:s,isError:a,calculateUsdValue:c=>Va(c,n??null)}}function gd({isOpen:e,onClose:t,onConfirm:r,fromToken:n,toToken:s,amountIn:a,quote:c,slippage:i,stage:u,receivingAddress:d=""}){const f=u!=="idle"&&u!=="confirming"&&u!=="error"&&u!=="submitted",h=u==="submitted",p=u==="error",y=ze(c.min_amount_out,s.token_decimals),{calculateUsdValue:v}=gr({symbol:n.token_symbol,enabled:e}),{calculateUsdValue:m}=gr({symbol:s.token_symbol,enabled:e}),w=v(a),b=m(y),R=k=>{!k&&!f&&t()},T=h?"Swap Complete":p?"Swap Failed":"Review Swap";return o.jsxs(pn,{open:e,onOpenChange:R,title:T,showCloseButton:!f,className:"w-[32rem]",children:[o.jsxs(wu,{className:"space-y-3",children:[o.jsx(md,{fromToken:n,toToken:s,fromAmount:a,toAmount:y,fromUsdValue:w,toUsdValue:b}),o.jsx(pd,{minReceived:`${y} ${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(vi,{icon:Cs,label:"Receiving Address",address:d})})]}),o.jsx(Cu,{children:o.jsx(cl,{state:f?"processing":h?"success":p?"error":"idle",onConfirm:h?t:r,confirmText:"Confirm Swap"})})]})}function bd({swap:e}){const{tokens:t,modals:r,tokenSelect:n,actions:s,input:a,quote:c,execution:i}=e;return o.jsxs(o.Fragment,{children:[r.tokenSelect.isOpen&&o.jsx(hd,{isOpen:r.tokenSelect.isOpen,onClose:r.tokenSelect.close,onSelect:s.selectToken,tokensData:t.data,isLoading:!1,selectedToken:n.type==="from"?t.from:t.to,disabledTokenId:n.type==="from"?t.to?.token_id:t.from?.token_id,tokens:n.type==="to"?t.availableTo:t.all,emptyMessage:n.type==="to"?"No available pairs for selected source token":void 0,title:n.type==="from"?"Select Source Token":"Select Destination Token"}),c.data&&t.from&&t.to&&r.confirm.isOpen&&o.jsx(gd,{isOpen:r.confirm.isOpen,onClose:s.closeConfirmModal,onConfirm:s.confirmSwap,fromToken:t.from,toToken:t.to,amountIn:a.amount,quote:c.data,slippage:a.slippage,stage:i.stage,txHash:i.txHash,error:i.error,receivingAddress:e.addresses.receiving})]})}function gn({status:e}){const t={pending:{icon:ws,text:"Processing",bgClass:"bg-yellow-500/10",textClass:"text-yellow-500",animate:!0},success:{icon:ln,text:"Completed",bgClass:"bg-green-500/10",textClass:"text-green-500",animate:!1},failed:{icon:si,text:"Failed",bgClass:"bg-red-500/10",textClass:"text-red-500",animate:!1}},{icon:r,text:n,bgClass:s,textClass:a,animate:c}=t[e];return o.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${s}`,children:[o.jsx(r,{className:`w-4 h-4 ${a} ${c?"animate-spin":""}`}),o.jsx("span",{className:`text-xs font-medium ${a}`,children:n})]})}function yd({onClose:e}){return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-white/10 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(gn,{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(Ze,{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-white/10 animate-pulse"}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("div",{className:"w-16 h-4 bg-white/10 rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-white/10 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-white/10 rounded animate-pulse"}),o.jsx("div",{className:"w-10 h-3 bg-white/10 rounded animate-pulse"})]}),o.jsx("div",{className:"w-6 h-6 rounded-full bg-white/10 animate-pulse"})]})]})]})}function wd({trade:e,status:t,isLoading:r,onClose:n}){if(r||!e)return o.jsx(yd,{onClose:n});const s=e.from_token,a=e.to_token,c=ze(e.amount_in,s.token_decimals),i=ze(e.min_amount_out,a.token_decimals);return o.jsxs("div",{className:"bg-[var(--optimex-surface)] border border-white/10 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(gn,{status:t}),n&&o.jsx("button",{onClick:n,className:"text-[var(--optimex-text-secondary)] hover:text-[var(--optimex-text)] transition-colors cursor-pointer","aria-label":"Close",children:o.jsx(Ze,{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(Je,{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:c}),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(Je,{token:a,size:"sm",showNetworkBadge:!1})]})]})]})}const Cd=1e4;function kd({apiBaseUrl:e,walletAddresses:t,enabled:r=!0,limit:n=20}){const{data:s,isLoading:a,isError:c,refetch:i}=bt({queryKey:["trades",t,n],queryFn:async()=>yt(e).listTrades({from_user_address:t,limit:n}),enabled:r&&!!t?.length,refetchInterval:Cd,retry:2,retryDelay:2e3});return{trades:s??[],isLoading:a,isError:c,refetch:i}}function jd(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 Sd({trade:e}){const t=e.from_token,r=e.to_token,n=jd(e.state),s=ze(e.amount_in,t.token_decimals),a=ze(e.min_amount_out,r.token_decimals);return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-white/10",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Je,{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:r.token_symbol})]}),o.jsx(Je,{token:r,size:"sm",showNetworkBadge:!1})]}),o.jsx("div",{className:"ml-3",children:o.jsx(gn,{status:n})})]})}function Wr(){return o.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[var(--optimex-surface)] border border-white/10",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 Ed(){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 Nd({open:e,onOpenChange:t,evmAddress:r,btcAddress:n,solanaAddress:s}){const a=Mt(),c=[r,n,s].filter(d=>!!d),{trades:i,isLoading:u}=kd({apiBaseUrl:a.apiBaseUrl,walletAddresses:c.length>0?c:void 0,enabled:e&&c.length>0});return o.jsx(pn,{open:e,onOpenChange:t,title:"Trade History",className:"w-[32rem]",children:o.jsxs("div",{className:"p-4 space-y-3 max-h-[60vh] overflow-y-auto",children:[u?o.jsxs(o.Fragment,{children:[o.jsx(Wr,{}),o.jsx(Wr,{}),o.jsx(Wr,{})]}):i.length===0?o.jsx(Ed,{}):i.map(d=>o.jsx(Sd,{trade:d},d.trade_id)),!u&&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(ws,{className:"w-3 h-3 animate-spin"}),o.jsx("span",{children:"Auto-refreshing"})]})]})})}function Td(e,t){return x.useMemo(()=>{const r=e.trim();if(!t||!r)return{isValid:!r,error:void 0};const n=an(r,t.network_type,t.network_id);return{isValid:n.isValid,error:n.isValid?void 0:n.error}},[e,t])}function Rd(){const[e,t]=x.useState(null),[r,n]=x.useState(!1),[s,a]=x.useState(!1),c=x.useCallback(()=>t("from"),[]),i=x.useCallback(()=>t("to"),[]),u=x.useCallback(()=>t(null),[]),d=x.useCallback(()=>n(!0),[]),f=x.useCallback(()=>n(!1),[]),h=x.useCallback(()=>a(y=>!y),[]),p=x.useCallback(()=>a(!1),[]);return{tokenSelect:{isOpen:e!==null,type:e,openFrom:c,openTo:i,close:u},confirm:{isOpen:r,open:d,close:f},settings:{isOpen:s,toggle:h,close:p}}}function Od({fromToken:e,toToken:t,amount:r,fromUserAddress:n,toUserAddress:s,userRefundPubkey:a,slippage:c,config:i}){return x.useMemo(()=>{const u=s.trim(),d=i.affiliateAddress&&i.affiliateFee?[{provider:i.affiliateProvider??"optimex-widget",rate:String(i.affiliateFee),receiver:i.affiliateAddress,network:"ethereum"}]:void 0,f=Math.round(c*100);return{from_token:e,to_token:t,amount:r,from_user_address:n,to_user_address:u||null,user_refund_pubkey:a,slippage:String(f),affiliate_fee_bps:i.affiliateFee?String(i.affiliateFee):void 0,affiliate_info:d,trade_timeout:i.tradeTimeout,script_timeout:i.scriptTimeout}},[e,t,r,n,s,a,c,i.affiliateFee,i.affiliateAddress,i.affiliateProvider,i.tradeTimeout,i.scriptTimeout])}function _d(e,t){return x.useMemo(()=>{if(!e||!t)return{walletAccount:void 0,evmWalletAccount:void 0};switch(e.network_type){case ie.EVM:return{walletAccount:t.evm,evmWalletAccount:t.evm};case ie.BTC:return{walletAccount:t.btc,evmWalletAccount:void 0};case ie.SOLANA:return{walletAccount:t.solana,evmWalletAccount:void 0};default:return{walletAccount:void 0,evmWalletAccount:void 0}}},[e,t])}const rs={BTC:1,EVM:2,Solana:3};function Ad(e){const{tokens:t,pairs:r,selectedFromToken:n}=e,s=x.useMemo(()=>{const y=new Map;if(!r)return y;for(const v of r){if(!v.is_active)continue;const m=y.get(v.from_token_id);m?m.add(v.to_token_id):y.set(v.from_token_id,new Set([v.to_token_id]))}return y},[r]),a=x.useMemo(()=>t??[],[t]),c=x.useMemo(()=>{const y=new Set;for(const v of a){const m=s.get(v.token_id);(!m||m.size===0)&&y.add(v.token_id)}return y},[a,s]),i=x.useMemo(()=>{if(!n)return[];const y=s.get(n.token_id);return!y||y.size===0?[]:a.filter(v=>y.has(v.token_id))},[n,s,a]),u=x.useCallback((y,v)=>s.get(y)?.has(v)??!1,[s]),d=x.useCallback(y=>(s.get(y)?.size??0)>0,[s]),f=x.useCallback(y=>[...y].sort((v,m)=>{const w=rs[v.network_type]??99,b=rs[m.network_type]??99;return w-b}),[]),h=x.useCallback(y=>{const v=s.get(y.token_id);if(!v||v.size===0)return null;const m=a.filter(b=>v.has(b.token_id));return m.length===0?null:f(m)[0]??null},[s,a,f]),p=x.useCallback(()=>{if(a.length===0)return null;const y=f(a);for(const v of y){const m=h(v);if(m)return{fromToken:v,toToken:m}}return null},[a,f,h]);return{allTokens:a,tokensWithoutPairs:c,availableToTokens:i,isPairValid:u,findBestToToken:h,hasValidPairs:d,getDefaultPair:p}}function Md(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 Pd(e,t){const r=Md(t);if(!r)throw new Error(`Cannot determine chain ID for token: ${t.token_id}`);return await e.getChainId()===r?!1:(await e.switchChain(r),!0)}const Id="0xdd62ed3e",Dd="0x095ea7b3",Ld="0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";function rn(e){return e.toLowerCase().replace("0x","").padStart(64,"0")}function Fd(e){return e.toString(16).padStart(64,"0")}function Bd(e){const t=e.startsWith("0x")?e.slice(2):e;return!t||t===""?0n:BigInt("0x"+t)}async function $d(e,t,r,n){const s=Cr(e),a=Id+rn(r)+rn(n),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 Bd(i.result)}function zd(e,t){const r=t?Fd(t):Ld.slice(2);return`${Dd}${rn(e)}${r}`}async function Wd(e,t,r,n){const s=zd(r,n);return await e.sendTransaction({to:t,data:s})}async function Hd(e,t,r=60,n=2e3){const s=Cr(e);for(let a=0;a<r;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 u=i.result;return{status:u.status==="0x1"?"success":"reverted",blockNumber:u.blockNumber,transactionHash:u.transactionHash}}await new Promise(u=>setTimeout(u,n))}throw new Error(`Transaction ${t} not confirmed after ${r} attempts`)}function Vd(e){return e?"getChainId"in e&&"switchChain"in e&&typeof e.getChainId=="function"&&typeof e.switchChain=="function":!1}function Ud({apiBaseUrl:e,onWalletTx:t,onSubmitTx:r,onError:n}){const[s,a]=x.useState({stage:"idle",txHash:null,tradeId:null,error:null}),c=x.useCallback(()=>{a({stage:"idle",txHash:null,tradeId:null,error:null})},[]),i=x.useCallback(()=>{a(h=>({stage:"idle",txHash:h.txHash,tradeId:h.tradeId,error:null}))},[]),u=x.useCallback((h,p,y)=>{a(v=>({...v,stage:"error",error:h})),n?.({error:h,stage:p,trade_id:y})},[n]),d=x.useCallback(async(h,p,y,v)=>{const m=y.deposit_address;if(!m)throw new Error("Missing deposit address for EVM transaction");a(T=>({...T,stage:"switching_chain"})),await Pd(h,p);const w=vn(p);if(!w&&p.token_address&&(a(k=>({...k,stage:"checking_allowance"})),await $d(p.network_id,p.token_address,h.address,m)<v)){a(L=>({...L,stage:"approving"}));const k=await Wd(h,p.token_address,m,v);if((await Hd(p.network_id,k)).status==="reverted")throw new Error("Token approval transaction reverted")}a(T=>({...T,stage:"broadcasting"}));const b={to:m,value:w?v:0n,data:y.payload?y.payload:void 0};return await h.sendTransaction(b)},[]),f=x.useCallback(async({quote:h,fromToken:p,toToken:y,amountIn:v,walletAccount:m,evmWalletAccount:w})=>{const b=yt(e);try{a({stage:"confirming",txHash:null,tradeId:h.trade_id,error:null});const R=w||m;if(!R)throw new Error("Wallet not available");a(A=>({...A,stage:"signing"}));let T;const k=gs(v,p.token_decimals);if(p.network_type===ie.EVM){const A=w||(Vd(m)?m:null);if(A)T=await d(A,p,h,k);else{const L=h.deposit_address,j=h.payload?h.payload:void 0;if(!L)throw new Error("Missing deposit address for EVM transaction");a(M=>({...M,stage:"broadcasting"}));const N={to:L,value:k,data:j};T=await R.sendTransaction(N)}}else if(p.network_type===ie.BTC){if(!h.deposit_address)throw new Error("Missing deposit address for BTC transaction");a(A=>({...A,stage:"broadcasting"})),T=await R.sendTransaction({toAddress:h.deposit_address,amount:k})}else if(p.network_type===ie.SOLANA){if(!h.payload)throw new Error("Missing payload for Solana transaction");a(A=>({...A,stage:"broadcasting"})),T=await R.sendTransaction(h.payload)}else throw new Error(`Unsupported network type: ${p.network_type}`);t?.({trade_id:h.trade_id,tx_hash:T,from_token:p,to_token:y,amount_in:v}),a(A=>({...A,txHash:T,stage:"submitting"}));try{await b.submitTransaction(h.trade_id,T),r?.({trade_id:h.trade_id,tx_hash:T,status:"success"})}catch(A){throw r?.({trade_id:h.trade_id,tx_hash:T,status:"error",error:A.message}),A}return a(A=>({...A,stage:"submitted"})),{tradeId:h.trade_id,txHash:T}}catch(R){const T=s.stage==="approving"?"approval":"wallet_tx";throw u(R,T,h.trade_id),R}},[e,t,r,u,d,s.stage]);return{...s,executeSwap:f,resetState:c,resetStateKeepTradeId:i,isExecuting:s.stage!=="idle"&&s.stage!=="submitted"&&s.stage!=="error"}}function qd({defaultPair:e,isPairValid:t,findBestToToken:r,hasValidPairs:n,defaultSlippage:s=.75,selectingToken:a=null}){const[c,i]=x.useState(null),[u,d]=x.useState(null),[f,h]=x.useState(""),[p,y]=x.useState(""),[v,m]=x.useState(s),w=c??e?.fromToken??null,b=u??e?.toToken??null,R=x.useCallback(()=>{w&&b&&t(b.token_id,w.token_id)&&(i(b),d(w),h(""))},[w,b,t]),T=x.useCallback(k=>{if(a==="from"){if(!n(k.token_id))return!1;if(k.token_id===b?.token_id)d(w);else if(b&&!t(k.token_id,b.token_id)){const A=r(k);d(A)}return i(k),!0}else if(a==="to")return k.token_id===w?.token_id&&i(b),d(k),!0;return!1},[a,w,b,t,r,n]);return{fromToken:w,toToken:b,handleTokenSelect:T,handleSwapDirection:R,amount:f,setAmount:h,receivingAddress:p,setReceivingAddress:y,slippage:v,setSlippage:m}}function Qd({fromToken:e,toToken:t}){const r=kt();return x.useMemo(()=>{const n=r.evmAddress,s=r.btcAddress,a=r.btcPublicKey;let c=null,i=null;return e?.network_type===ie.EVM?(c=n,i=n):e?.network_type===ie.BTC&&(c=s,i=a),{fromUserAddress:c,userRefundPubkey:i}},[r.evmAddress,r.btcAddress,r.btcPublicKey,e,t])}function Kd({fromToken:e,toToken:t,amount:r,quote:n,isLoadingQuote:s,isFetchingQuote:a,receivingAddress:c,onConnectWallet:i,onSwap:u}){const d=kt();return x.useMemo(()=>{if(!nd(d,e?.network_type)){const p=sd(e?.network_type);return{text:p?`Connect ${p} Wallet`:"Connect Wallet",disabled:!1,action:i}}return!e||!t?{text:"Select Tokens",disabled:!0,action:void 0}:!r||parseFloat(r)<=0?{text:"Enter Amount",disabled:!0,action:void 0}:c.trim()?an(c,t.network_type,t.network_id).isValid?s||a?{text:"Getting Quote...",disabled:!0,action:void 0}:n?{text:"Review",disabled:!1,action:u}:{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,r,s,a,n,i,u,c])}function Gd({tokens:e,defaultFromToken:t,defaultToToken:r,isPairValid:n}){return x.useMemo(()=>{if(!t||!r||!e)return null;const s=e.find(c=>c.token_id===t),a=e.find(c=>c.token_id===r);return!s||!a?null:n(s.token_id,a.token_id)?{fromToken:s,toToken:a}:null},[e,t,r,n])}function Yd(){const e=kt(),t=Mt(),r=Rd(),{tokensData:n}=Mu(),s=n.tokens,a=n.pairs,{allTokens:c,tokensWithoutPairs:i,isPairValid:u,findBestToToken:d,hasValidPairs:f,getDefaultPair:h}=Ad({tokens:s,pairs:a,selectedFromToken:null}),y=Gd({tokens:s,defaultFromToken:t.defaultFromToken,defaultToToken:t.defaultToToken,isPairValid:u})??h(),{fromToken:v,toToken:m,handleTokenSelect:w,handleSwapDirection:b,amount:R,setAmount:T,receivingAddress:k,setReceivingAddress:A,slippage:L,setSlippage:j}=qd({defaultPair:y,isPairValid:u,findBestToToken:d,hasValidPairs:f,defaultSlippage:t.defaultSlippage,selectingToken:r.tokenSelect.type}),N=x.useMemo(()=>v?c.filter(F=>u(v.token_id,F.token_id)):[],[v,c,u]),M=Td(k,m),{fromUserAddress:U,userRefundPubkey:W}=Qd({fromToken:v,toToken:m}),K=Od({fromToken:v,toToken:m,amount:R,fromUserAddress:U,toUserAddress:k,userRefundPubkey:W,slippage:L,config:{affiliateFee:t.affiliateFee,affiliateAddress:t.affiliateAddress,affiliateProvider:t.affiliateProvider,tradeTimeout:t.tradeTimeout,scriptTimeout:t.scriptTimeout}}),D=!!v&&!!m&&parseFloat(R)>0&&!!k.trim()&&!r.confirm.isOpen,{data:X,isLoading:J,isFetching:re,refetch:te}=ei(t.apiBaseUrl,{...K,enabled:D,onQuote:t.callbacks?.onQuote}),_=Ud({apiBaseUrl:t.apiBaseUrl,onWalletTx:t.callbacks?.onWalletTx,onSubmitTx:t.callbacks?.onSubmitTx,onError:t.callbacks?.onError}),{walletAccount:oe,evmWalletAccount:me}=_d(v,e.externalWalletClient??void 0),xe=x.useCallback(()=>{e.isExternalWallet?e.onRequestWallet?.(v?.network_id??""):e.openConnectModal?.()},[e,v?.network_id]),ve=x.useCallback(()=>{!X||!v||!m||(_.resetState(),r.confirm.open())},[X,v,m,r.confirm,_]),Y=x.useCallback((F=!1)=>{_.isExecuting||(r.confirm.close(),F&&_.resetStateKeepTradeId())},[_,r.confirm]),ne=x.useCallback(async()=>{if(!(!X||!v||!m))try{const{txHash:F}=await _.executeSwap({quote:X,fromToken:v,toToken:m,amountIn:R,walletAccount:oe,evmWalletAccount:me});Y(!!F),T(""),A("")}catch(F){console.error("Swap failed:",F)}},[X,v,m,R,oe,me,_,Y,T,A]),ye=x.useCallback(F=>{w(F)&&r.tokenSelect.close()},[w,r.tokenSelect]),Te=Kd({fromToken:v,toToken:m,amount:R,quote:X,isLoadingQuote:J,isFetchingQuote:re,receivingAddress:k,onConnectWallet:xe,onSwap:ve});return{tokens:{from:v,to:m,all:c,availableTo:N,withoutPairs:i,data:n},input:{amount:R,setAmount:T,receivingAddress:k,setReceivingAddress:A,slippage:L,setSlippage:j},quote:{data:X,isLoading:J,isFetching:re,refetch:te},validation:{address:M},buttonState:Te,modals:r,tokenSelect:{type:r.tokenSelect.type},actions:{selectToken:ye,swapDirection:b,connectWallet:xe,openSwapConfirm:ve,closeConfirmModal:Y,confirmSwap:ne},execution:{stage:_.stage,txHash:_.txHash,tradeId:_.tradeId,error:_.error,isExecuting:_.isExecuting},wallet:e,addresses:{sending:U,receiving:k}}}const Zd=5e3;function ns(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 Xd({apiBaseUrl:e,tradeId:t}){const{data:r,isLoading:n}=bt({queryKey:["trade",t],queryFn:async()=>yt(e).getTrade(t),enabled:!!t,refetchInterval:s=>{const a=s.state.data;return a&&ns(a.state)==="success"?!1:Zd},retry:!0,retryDelay:2e3});return{trade:r??null,status:ns(r?.state),isLoading:n}}function Yo(){const e=Yd(),t=Mt(),{tokens:r,input:n,quote:s,modals:a,buttonState:c,validation:i,actions:u,addresses:d,wallet:f,execution:h}=e,[p,y]=x.useState(!1),{trade:v,status:m,isLoading:w}=Xd({apiBaseUrl:t.apiBaseUrl,tradeId:h.tradeId}),{formattedBalance:b}=Go({token:r.from,walletAddress:d.sending,enabled:!!r.from&&!!d.sending,polling:!0}),{calculateUsdValue:R}=gr({symbol:r.from?.token_symbol,enabled:!!r.from}),{calculateUsdValue:T}=gr({symbol:r.to?.token_symbol,enabled:!!r.to}),k=f.isConnected,A=R(n.amount),L=s.data?T(ze(s.data.min_amount_out,r.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(Fu,{headerLeft:t.headerLeft,slippage:n.slippage,onSlippageChange:n.setSlippage,isSettingsOpen:a.settings.isOpen,onSettingsToggle:a.settings.toggle,onHistoryClick:()=>y(!0),hideHistory:t.hideHistory||!f.isConnected}),o.jsxs(xn,{children:[o.jsxs("div",{className:"space-y-2 relative",children:[o.jsx(es,{token:r.from,value:n.amount,onChange:n.setAmount,onSelectToken:a.tokenSelect.openFrom,balance:b,isWalletConnected:k,usdValue:A}),o.jsx(Vo,{onClick:u.swapDirection}),o.jsx(es,{token:r.to,value:s.data?ze(s.data.min_amount_out,r.to?.token_decimals||18):"",readOnly:!0,onSelectToken:a.tokenSelect.openTo,isOutput:!0,usdValue:L})]}),o.jsx("div",{className:"mt-4",children:o.jsx(Pu,{token:r.to,value:n.receivingAddress,onChange:n.setReceivingAddress,error:i.address.error})}),o.jsx("div",{className:"mt-4",children:o.jsx($u,{text:c.text,disabled:c.disabled,onClick:c.action})}),s.data&&r.from&&r.to&&o.jsx("div",{className:"mt-4",children:o.jsx(Bu,{quote:s.data,fromToken:r.from,toToken:r.to,amount:n.amount,slippage:n.slippage,isFetching:s.isFetching,onRefresh:s.refetch})}),o.jsx("div",{className:"mt-4",children:o.jsx(zu,{})}),h.tradeId&&h.txHash&&o.jsx("div",{className:"mt-4",children:o.jsx(wd,{trade:v,status:m,isLoading:w})})]})]}),o.jsx(bd,{swap:e}),p&&o.jsx(Nd,{open:p,onOpenChange:y,evmAddress:f.evmAddress??void 0,btcAddress:f.btcAddress??void 0,solanaAddress:f.solanaAddress??void 0})]})}function Jd({className:e,connectLabel:t="Connect Wallet",showNetworkBadge:r=!0,onClick:n}){const s=kt(),a=s.evmAddress||s.btcAddress||s.solanaAddress,c=()=>{if(n){n();return}s.isExternalWallet?s.onRequestWallet?.():s.openConnectModal?.()},i=()=>r?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:c,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:Wa(a)}),o.jsx(ii,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})]}):o.jsx("button",{onClick:c,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 ef({apiBaseUrl:e,walletClient:t,onRequestWallet:r,theme:n,defaultFromToken:s,defaultToToken:a,headerLeft:c,affiliateFee:i,affiliateAddress:u,affiliateProvider:d,tradeTimeout:f,scriptTimeout:h,defaultSlippage:p=.75,hideHistory:y=!1,children:v,renderLoading:m,renderError:w,queryClient:b,onQuote:R,onWalletTx:T,onSubmitTx:k,onSwapComplete:A,onError:L}){La(e);const j=x.useMemo(()=>b??new ha,[b]),M={apiBaseUrl:e,defaultSlippage:p,affiliateFee:i,affiliateAddress:u,affiliateProvider:d,tradeTimeout:f,scriptTimeout:h,defaultFromToken:s,defaultToToken:a,hideHistory:y,headerLeft:c,callbacks:{onQuote:R,onWalletTx:T,onSubmitTx:k,onSwapComplete:A,onError:L},renderLoading:m,renderError:w},U=v??o.jsx(Yo,{});return o.jsx("div",{className:"optx-widget",children:o.jsx(ga,{client:j,children:o.jsx(ti,{value:M,children:o.jsx(Pa,{theme:n,children:o.jsx(Da,{externalWalletClient:t,onRequestWallet:r,children:o.jsx(Au,{children:U})})})})})})}exports.ConnectButton=Jd;exports.SwapCard=Yo;exports.SwapWidget=ef;exports.createEvmWalletClient=Qo;exports.createEvmWalletClientAsync=ad;exports.createEvmWalletClientSync=Ko;exports.useWallet=kt;
|