@luno-kit/ui 0.0.3 → 0.0.4

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.d.cts CHANGED
@@ -51,7 +51,6 @@ interface LunokitTheme {
51
51
  info: string;
52
52
  infoForeground: string;
53
53
  skeleton: string;
54
- cutLine: string;
55
54
  };
56
55
  fonts: {
57
56
  body: string;
@@ -110,4 +109,21 @@ interface LunoKitProviderProps {
110
109
  }
111
110
  declare const LunoKitProvider: React.FC<LunoKitProviderProps>;
112
111
 
113
- export { ConnectButton, LunoKitProvider, type LunoKitProviderProps, type LunokitTheme, type ThemeMode, useLunoTheme };
112
+ declare const useConnectModal: () => {
113
+ isOpen: boolean;
114
+ open?: () => void;
115
+ close: () => void;
116
+ };
117
+ declare const useAccountModal: () => {
118
+ isOpen: boolean;
119
+ open?: () => void;
120
+ close: () => void;
121
+ };
122
+ declare const useChainModal: () => {
123
+ isOpen: boolean;
124
+ open?: () => void;
125
+ close: () => void;
126
+ };
127
+ declare const useCloseAllModals: () => () => void;
128
+
129
+ export { ConnectButton, LunoKitProvider, type LunoKitProviderProps, type LunokitTheme, type ThemeMode, useAccountModal, useChainModal, useCloseAllModals, useConnectModal, useLunoTheme };
package/dist/index.d.ts CHANGED
@@ -51,7 +51,6 @@ interface LunokitTheme {
51
51
  info: string;
52
52
  infoForeground: string;
53
53
  skeleton: string;
54
- cutLine: string;
55
54
  };
56
55
  fonts: {
57
56
  body: string;
@@ -110,4 +109,21 @@ interface LunoKitProviderProps {
110
109
  }
111
110
  declare const LunoKitProvider: React.FC<LunoKitProviderProps>;
112
111
 
113
- export { ConnectButton, LunoKitProvider, type LunoKitProviderProps, type LunokitTheme, type ThemeMode, useLunoTheme };
112
+ declare const useConnectModal: () => {
113
+ isOpen: boolean;
114
+ open?: () => void;
115
+ close: () => void;
116
+ };
117
+ declare const useAccountModal: () => {
118
+ isOpen: boolean;
119
+ open?: () => void;
120
+ close: () => void;
121
+ };
122
+ declare const useChainModal: () => {
123
+ isOpen: boolean;
124
+ open?: () => void;
125
+ close: () => void;
126
+ };
127
+ declare const useCloseAllModals: () => () => void;
128
+
129
+ export { ConnectButton, LunoKitProvider, type LunoKitProviderProps, type LunokitTheme, type ThemeMode, useAccountModal, useChainModal, useCloseAllModals, useConnectModal, useLunoTheme };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use client'
2
- import{useCallback as fo,useMemo as Ye}from"react";import{useAccount as ho,useActiveConnector as xo,useBalance as go,useChain as wo}from"@luno-kit/react";import le from"react";import*as N from"@radix-ui/react-dialog";import{clsx as Ct}from"clsx";import{extendTailwindMerge as vt}from"tailwind-merge";var bt=vt({extend:{classGroups:{"font-size":["text-xs","text-sm","text-base","text-lg"]}}});function d(...e){return bt(Ct(e))}function Re(e,n){let t;return()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,e()},n)}}import{jsx as Pe,jsxs as Nt}from"react/jsx-runtime";var yt=({open:e,onOpenChange:n,children:t,contentClassName:r,overlayClassName:o})=>Pe(N.Root,{open:e,onOpenChange:n,children:Nt(N.Portal,{children:[le.createElement(N.Overlay,{className:d("fixed inset-0 z-[100] bg-modalBackdrop luno-kit","data-[state=open]:[animation:overlay-in_150ms_ease-out]",o)}),Pe(N.Content,{className:d("luno-kit font-body fixed z-[200] text-modalText text-base leading-base","bg-modalBackground shadow-primary focus:outline-none overflow-hidden","transition-all duration-200","rounded-t-modalMobile bottom-0 left-0 w-full","translate-y-0 -translate-x-0","data-[state=open]:[animation:slide-up_200ms_ease-out]","md:bottom-auto md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2","md:w-auto md:rounded-modal","md:data-[state=open]:[animation:dialog-in_150ms_ease-out]",r),children:t})]})}),St=({children:e,className:n})=>le.createElement(N.Title,{className:d("font-heading",n)},e),Mt=({children:e,className:n,onClick:t})=>le.createElement(N.Close,{className:n,onClick:t},e),G=yt,E=Mt,D=St;import{createContext as At,useCallback as me,useContext as ue,useEffect as kt,useMemo as Tt,useState as Rt}from"react";import{ConnectionStatus as q,useStatus as Pt}from"@luno-kit/react";import{jsx as Vt}from"react/jsx-runtime";function de(){let[e,n]=Rt(!1),t=me(()=>n(!0),[]),r=me(()=>n(!1),[]);return{isOpen:e,open:t,close:r}}var K=At(void 0),Ve=({children:e})=>{let{isOpen:n,open:t,close:r}=de(),{isOpen:o,open:a,close:i}=de(),{isOpen:m,open:p,close:u}=de(),f=Pt(),c=me(()=>{r(),i(),u()},[r,i,u]);kt(()=>{f===q.Disconnected&&(i(),u())},[f,i,u]);let s=Tt(()=>({isConnectModalOpen:n,isAccountModalOpen:o,isChainModalOpen:m,openConnectModal:f!==q.Connected?t:void 0,closeConnectModal:r,openAccountModal:f===q.Connected?a:void 0,closeAccountModal:i,openChainModal:f===q.Connected?p:void 0,closeChainModal:u,closeAllModals:c}),[n,t,r,o,a,i,m,p,u,c,f]);return Vt(K.Provider,{value:s,children:e})},J=()=>{let e=ue(K);if(!e)throw new Error("[ModalContext]: useConnectModal must be used within a ModalProvider");return{isOpen:e.isConnectModalOpen,open:e.openConnectModal,close:e.closeConnectModal}},Y=()=>{let e=ue(K);if(!e)throw new Error("[ModalContext]: useAccountModal must be used within a ModalProvider");return{isOpen:e.isAccountModalOpen,open:e.openAccountModal,close:e.closeAccountModal}},X=()=>{let e=ue(K);if(!e)throw new Error("[ModalContext]: useChainModal must be used within a ModalProvider");return{isOpen:e.isChainModalOpen,open:e.openChainModal,close:e.closeChainModal}};import{jsx as Ie}from"react/jsx-runtime";var It=e=>Ie("svg",{xmlns:"http://www.w3.org/2000/svg",className:"arrow_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:Ie("path",{d:"M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"})}),pe=It;import{jsx as Be}from"react/jsx-runtime";var Bt=e=>Be("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Be("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"})}),W=Bt;import{jsx as Ee}from"react/jsx-runtime";var Et=e=>Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Ee("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})}),V=Et;import{jsx as De}from"react/jsx-runtime";var Dt=e=>De("svg",{xmlns:"http://www.w3.org/2000/svg",className:"copy_svg__icon",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 256 256",...e,children:De("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"})}),fe=Dt;import{jsx as Le}from"react/jsx-runtime";var Lt=e=>Le("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 256 256",width:"20",height:"20",...e,children:Le("path",{d:"M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z"})}),he=Lt;import{jsx as Oe}from"react/jsx-runtime";var Ot=e=>Oe("svg",{xmlns:"http://www.w3.org/2000/svg",className:"list_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:Oe("path",{d:"M232,48V88a8,8,0,0,1-16,0V56H184a8,8,0,0,1,0-16h40A8,8,0,0,1,232,48ZM72,200H40V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16Zm152-40a8,8,0,0,0-8,8v32H184a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,224,160ZM32,96a8,8,0,0,0,8-8V56H72a8,8,0,0,0,0-16H32a8,8,0,0,0-8,8V88A8,8,0,0,0,32,96ZM188,167l-56,32a8,8,0,0,1-7.94,0L68,167A8,8,0,0,1,64,160V96a8,8,0,0,1,4-7l56-32a8,8,0,0,1,7.94,0l56,32a8,8,0,0,1,4,7v64A8,8,0,0,1,188,167ZM88.12,96,128,118.79,167.88,96,128,73.21ZM80,155.36l40,22.85V132.64L80,109.79Zm96,0V109.79l-40,22.85v45.57Z"})}),xe=Ot;import{jsx as _e}from"react/jsx-runtime";var _t=e=>_e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"loading_svg__icon",viewBox:"0 0 256 256",...e,children:_e("path",{d:"M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z"})}),Q=_t;import{jsx as He}from"react/jsx-runtime";var Ht=e=>He("svg",{xmlns:"http://www.w3.org/2000/svg",className:"success_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:He("path",{d:"M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z"})}),ge=Ht;import{jsx as Ge}from"react/jsx-runtime";var Gt=e=>Ge("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",className:"switch_svg__icon",viewBox:"0 0 256 256",fill:"currentColor",...e,children:Ge("path",{d:"M253.66,133.66l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L216,132.69V128A88,88,0,0,0,56.49,76.67a8,8,0,0,1-13-9.34A104,104,0,0,1,232,128v4.69l10.34-10.35a8,8,0,0,1,11.32,11.32Zm-41.18,55A104,104,0,0,1,24,128v-4.69L13.66,133.66A8,8,0,0,1,2.34,122.34l24-24a8,8,0,0,1,11.32,0l24,24a8,8,0,0,1-11.32,11.32L40,123.31V128a87.62,87.62,0,0,0,22.24,58.41A79.66,79.66,0,0,1,98.3,157.66a48,48,0,1,1,59.4,0,79.59,79.59,0,0,1,36.08,28.78,89.68,89.68,0,0,0,5.71-7.11,8,8,0,0,1,13,9.34ZM128,152a32,32,0,1,0-32-32A32,32,0,0,0,128,152Zm0,64a88.2,88.2,0,0,0,53.92-18.49,64,64,0,0,0-107.84,0A87.57,87.57,0,0,0,128,216Z"})}),we=Gt;import{useMemo as Ft}from"react";import{jsx as Fe}from"react/jsx-runtime";var F=({chainIconUrl:e,chainName:n,className:t})=>e?Fe("img",{src:e,alt:n||"Chain icon",className:d("w-full h-full object-cover rounded-full",t)}):Fe("div",{className:d("w-full h-full bg-gray-500 text-modalText font-semibold","flex items-center justify-center rounded-full",t),children:n?n.charAt(0).toUpperCase():"C"});import{useAccount as $t,useChain as Zt,useDisconnect as zt,getExplorerUrl as Wt}from"@luno-kit/react";import{Fragment as Ze,jsx as v,jsxs as $}from"react/jsx-runtime";var ze=({onViewChange:e,onModalClose:n})=>{let{address:t}=$t(),{chain:r}=Zt(),{disconnectAsync:o}=zt(),a=Ft(()=>[{key:"Chain Name",content:$("div",{className:"flex items-stretch w-full justify-between",children:[$("div",{className:"flex items-center gap-2",children:[v(F,{className:"w-[20px] h-[20px]",chainIconUrl:r?.chainIconUrl,chainName:r?.name}),v("span",{className:"text-base text-modalText",children:r?.name||"Polkadot"})]}),v("div",{className:"flex items-center justify-center",children:v(pe,{className:"w-[16px] h-[16px] "})})]}),onClick:()=>e("switchChain")},{key:"View on Explorer",content:$(Ze,{children:[v(xe,{}),v("span",{className:"text-base text-accountActionItemText",children:"View on Explorer"})]}),onClick:()=>window.open(Wt(r?.blockExplorers?.default?.url,t,"address"))},{key:"Switch Account",content:$(Ze,{children:[v(we,{}),v("span",{className:"text-base text-accountActionItemText",children:"Switch Account"})]}),onClick:()=>e("switchAccount")}],[e,r,t]),i=async()=>{await o(),n()};return $("div",{className:"flex flex-col items-center gap-3 w-full",children:[v("div",{className:"flex flex-col gap-1.5 w-full px-4",children:a.map(m=>v($e,{onClick:m.onClick,children:m.content},m.key))}),v("div",{className:"w-full mx-[-100px] h-[1px] bg-cutLine"}),v("div",{className:"w-full px-4 pb-4",children:$($e,{onClick:i,children:[v(he,{}),v("span",{className:"font-medium text-base text-accountActionItemText",children:"Disconnect"})]})})]})},$e=({children:e,onClick:n})=>v("button",{type:"button",onClick:()=>n?.(),className:d("w-full p-3.5 rounded-accountActionItem border-none text-left flex items-center gap-2 font-medium","bg-accountActionItemBackground hover:bg-accountActionItemBackgroundHover","transition-colors duration-200",n?"cursor-pointer":"cursor-auto"),"aria-label":typeof e=="string"?e:void 0,children:e});import Qt,{useCallback as Ut}from"react";import{useAccount as jt,useAccounts as qt,useActiveConnector as Kt,useBalance as Jt,useChain as Yt}from"@luno-kit/react";import{formatAddress as Xt}from"@luno-kit/react";import{Fragment as to,jsx as I,jsxs as ee}from"react/jsx-runtime";var Ce=({onBack:e})=>{let{accounts:n,selectAccount:t}=qt(),{address:r}=jt(),o=Ut(a=>{t(a),e()},[e]);return I("div",{className:"flex flex-col gap-1.5 pt-3 overflow-auto max-h-[400px] no-scrollbar p-4 pt-0",children:n.map(a=>I(eo,{account:a,isSelected:a.address===r,selectAccount:o},a.address))})};Ce.title="Switch Accounts";var eo=Qt.memo(({isSelected:e,account:n,selectAccount:t})=>{let{chain:r}=Yt(),o=n.address,{data:a}=Jt({address:o}),i=Kt();return ee("button",{type:"button",onClick:()=>t(n),className:d("px-3.5 py-2.5 w-full rounded-accountSelectItem border-none","bg-accountSelectItemBackground","text-left flex items-center justify-between gap-2","transition-colors duration-200",e?"cursor-auto":"cursor-pointer hover:bg-accountSelectItemBackgroundHover"),"aria-label":n.name||o,disabled:e,children:[ee("div",{className:"flex items-center gap-2",children:[I("div",{className:"shrink-0 w-[24px] h-[24px] bg-pink-500 rounded-full flex items-center justify-center",children:i?.icon&&I("img",{src:i?.icon,alt:"luno account"})}),ee("div",{className:"flex flex-col items-start",children:[I("span",{className:"font-medium text-sm leading-sm text-accountSelectItemText",children:n.name||Xt(o)}),I("span",{className:"text-xs text-modalTextSecondary font-medium",children:a===void 0?I("div",{className:"animate-pulse rounded w-[60px] h-[18px] bg-skeleton"}):ee(to,{children:[a?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}),e&&I("div",{className:"border-[1px] border-solid border-accentColor rounded-full overflow-hidden flex items-center justify-center w-[18px] h-[18px]",children:I("div",{className:"rounded-full bg-accentColor w-[10px] h-[10px]"})})]})});import oo,{useMemo as no,useState as We}from"react";import{useApi as ro,useChain as ao,useChains as io,useSwitchChain as so}from"@luno-kit/react";import{Fragment as Qe,jsx as y,jsxs as Z}from"react/jsx-runtime";var co=[{key:"All",label:"All"},{key:"Mainnets",label:"Mainnets"},{key:"Testnets",label:"Testnets"}],te=({onChainSwitched:e})=>{let{chain:n}=ao(),t=io(),{switchChainAsync:r}=so(),{isApiReady:o,apiError:a}=ro(),[i,m]=We("All"),[p,u]=We(null),f=no(()=>{switch(i){case"Mainnets":return t.filter(s=>!s.testnet);case"Testnets":return t.filter(s=>s.testnet);case"All":default:return t}},[t,i]),c=async s=>{if(s.genesisHash!==n?.genesisHash&&!(!o&&!a)){u(s.genesisHash);try{await r({chainId:s.genesisHash}),e?.(s)}catch(l){console.error("Failed to switch chain:",l)}finally{u(null)}}};return Z(Qe,{children:[y("div",{className:"flex items-center gap-1.5 w-full",children:co.map(s=>y("button",{onClick:()=>m(s.key),className:d("px-3.5 flex items-center justify-center cursor-pointer min-w-[48px] min-h-[24px] rounded-networkSelectItem text-[12px] leading-[16px] font-medium transition-colors",i===s.key?"bg-navigationButtonBackground text-modalText":"bg-transparent text-modalTextSecondary hover:text-modalText"),children:s.label},s.key))}),y("div",{className:"flex flex-col gap-1.5 overflow-y-auto custom-scrollbar max-h-[450px]",children:f.map(s=>y(lo,{chain:s,isSelected:s.genesisHash===n?.genesisHash,onSelect:c,isLoading:(p===s.genesisHash||!o)&&!a},s.genesisHash))}),f.length===0&&y("div",{className:"flex items-center justify-center py-12",children:Z("span",{className:"text-modalTextSecondary text-xs",children:["No ",i==="All"?"chains":i.toLowerCase()," available"]})})]})},lo=oo.memo(({chain:e,isSelected:n,isLoading:t,onSelect:r})=>Z("button",{onClick:()=>r(e),disabled:n||t,className:d("flex items-center justify-between p-2 rounded-sm","bg-networkSelectItemBackground","transition-colors duration-200",n||t?"cursor-default":"cursor-pointer hover:bg-networkSelectItemBackgroundHover",t&&"opacity-80"),children:[Z("div",{className:"flex items-center gap-2",children:[y(F,{className:"w-[24px] bg-modal-bg h-[24px] flex items-center justify-center",chainIconUrl:e?.chainIconUrl,chainName:e?.name}),y("div",{className:"flex flex-col items-start",children:y("span",{className:"font-medium text-base text-modalText",children:e.name})})]}),y("div",{className:"flex items-center justify-center h-[20px]",children:n?t?Z(Qe,{children:[y("span",{className:"text-accentColor text-xs leading-xs mr-1.5",children:"Switching"}),y(Q,{className:"text-accentColor animate-[spin_2s_linear_infinite]",width:"15px",height:"15px"})]}):Z("span",{className:"status-dot-container",children:[y("span",{className:"ping-animation"}),y("span",{className:"status-dot"})]}):null})]}));import{jsx as Ue}from"react/jsx-runtime";var oe=({onBack:e})=>Ue("div",{className:"flex flex-col gap-3.5 p-4 pt-0",children:Ue(te,{})});oe.title="Select Networks";import{useCallback as mo,useState as uo}from"react";import{jsx as je,jsxs as po}from"react/jsx-runtime";var ne=({copyText:e,label:n,className:t=""})=>{let[r,o]=uo(!1),a=mo(async i=>{try{return navigator.clipboard&&navigator.clipboard.writeText?(await navigator.clipboard.writeText(i),o(!0),setTimeout(()=>o(!1),2e3),!0):!1}catch(m){return console.error("Copy failed:",m),!1}},[]);return po("button",{type:"button",className:d("cursor-pointer bg-transparent border-none p-0 m-0 inline-flex items-center justify-center gap-1",t),onClick:()=>!r&&e&&a(e),"aria-label":"Copy address to clipboard",disabled:r,children:[r?je(ge,{className:"text-accentColor",width:16,height:16}):je(fe,{width:16,height:16}),n]})};import{formatAddress as Co}from"@luno-kit/react";import{useCallback as qe,useState as Ke,useRef as Je}from"react";function re({initialView:e,animationDuration:n=200,animationEasing:t="ease-out"}){let[r,o]=Ke(e),[a,i]=Ke(!1),m=Je(null),p=Je(null),u=qe(c=>{if(c===r||a)return;if(i(!0),!m.current){o(c),i(!1);return}let s=m.current,l=s.offsetHeight;o(c),requestAnimationFrame(()=>{if(!s||!p.current){i(!1);return}let h=p.current.offsetHeight;s.animate([{height:l+"px"},{height:h+"px"}],{duration:n,easing:t,fill:"forwards"}).addEventListener("finish",()=>{i(!1)})})},[r,a,n,t]),f=qe(()=>{o(e),i(!1)},[e]);return{currentView:r,isAnimating:a,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}}import{Fragment as Xe,jsx as g,jsxs as H}from"react/jsx-runtime";var et=()=>{let{isOpen:e,close:n}=Y(),{address:t}=ho(),{chain:r}=wo(),{data:o}=go({address:t}),a=xo(),{currentView:i,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}=re({initialView:"main"}),c=fo(()=>{n(),f()},[n]),s=Ye(()=>i==="switchAccount"?"Switch Account":i==="switchChain"?oe.title:null,[i]),l=Ye(()=>({main:g(ze,{onViewChange:u,onModalClose:c}),switchAccount:g(Ce,{onBack:()=>u("main")}),switchChain:g(oe,{onBack:()=>u("main")})}),[u,c]);return g(G,{open:e,onOpenChange:c,children:H("div",{className:d("flex flex-col w-full md:w-[360px] max-h-[500px] text-modalText","bg-modalBackground shadow-modal",i==="main"?"gap-6":"gap-3.5"),children:[H("div",{className:"flex items-stretch justify-between w-full px-4 pt-4",children:[i==="main"?H("div",{className:"flex items-center gap-3",children:[a?.icon&&g("div",{className:"flex items-center justify-center w-[55px] h-[55px]",children:g("img",{src:a.icon,alt:""})}),H("div",{className:"flex flex-col items-start gap-2 w-full",children:[g(D,{className:"sr-only",children:"Account Details"}),H("div",{className:"flex items-center gap-1.5 w-full",children:[g("span",{className:"text-base text-modalText font-semibold",children:Co(t)}),g(ne,{copyText:t})]}),g("div",{className:"text-sm text-modalTextSecondary font-medium min-h-[20px]",children:o===void 0?g("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-skeleton"}):H(Xe,{children:[o?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}):H(Xe,{children:[g("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>u("main"),"aria-label":"Back",children:g(W,{})}),g(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:s})]}),g(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:g(V,{})})]}),g("div",{ref:m,className:"relative overflow-hidden",children:g("div",{ref:p,children:l[i]})})]})})};import{jsx as z,jsxs as tt}from"react/jsx-runtime";var ot=()=>{let{isOpen:e,close:n}=X();return z(G,{open:e,onOpenChange:t=>!t&&n(),children:tt("div",{className:"flex flex-col w-full md:w-[360px] max-h-[500px] p-4 gap-3.5 text-modalText",children:[tt("div",{className:"flex items-center justify-between w-full",children:[z("div",{className:"w-[30px]"})," ",z(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:"Select Network"}),z(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:z(V,{})})]}),z(te,{})]})})};import{useEffect as ye,useMemo as Oo,useState as dt}from"react";import{useConnect as _o,isMobileDevice as Ho}from"@luno-kit/react";import{useStatus as vo,useAccount as bo,useChain as yo,useBalance as So,ConnectionStatus as ae,useChains as Mo,useActiveConnector as No,formatAddress as Ao}from"@luno-kit/react";function nt(){let e=vo(),{account:n,address:t}=bo(),{chain:r}=yo(),o=Mo(),{data:a}=So({address:t}),i=No(),{open:m,isOpen:p}=J(),{open:u,isOpen:f}=Y(),{open:c,isOpen:s}=X(),l=e===ae.Connecting,h=e===ae.Connected,x=e===ae.Disconnected||e===ae.Disconnecting,R=!!r&&o.some(C=>C.genesisHash.toLowerCase()===r.genesisHash.toLowerCase());return{activeConnector:i,connectionStatus:e,isConnected:h,isDisconnected:x,isConnecting:l,account:n,address:t,displayAddress:Ao(t),currentChain:r,configuredChains:o,isChainSupported:R,chainIconUrl:r?.chainIconUrl,chainName:r?.name,balance:a,openConnectModal:m,openAccountModal:u,openChainModal:c,isConnectModalOpen:p,isAccountModalOpen:f,isChainModalOpen:s}}import{useEffect as ko,useState as To}from"react";var ie=()=>{let[e,n]=To({height:void 0,width:void 0});return ko(()=>{let t=Re(()=>{n({height:window.innerHeight,width:window.innerWidth})},500);return window.addEventListener("resize",t),t(),()=>window.removeEventListener("resize",t)},[]),e};import Eo from"react";import{Cuer as Ro}from"cuer";import{jsx as L,jsxs as rt}from"react/jsx-runtime";var at=({logoBackground:e,uri:n,size:t})=>{if(!n){let a=Math.floor(14.25),i=t/57,m=a*i,p=Math.floor(57/2-a/2),u=p+a,f=()=>{let l=[];for(let h=0;h<57;h++)for(let x=0;x<57;x++){if(h>=p&&h<=u&&x>=p&&x<=u||h<8&&x<8||h<8&&x>=49||h>=49&&x<8)continue;let C=x+.5,S=h+.5;l.push(L("rect",{x:C-.4,y:S-.4,width:.8,height:.8,rx:.4,fill:"var(--color-walletSelectItemBackground)"},`${h}-${x}`))}return l},c=({position:l})=>{let h=7*i,x={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0}};return rt("div",{className:"absolute z-[4]",style:{width:`${h}px`,height:`${h}px`,...x[l]},children:[L("div",{className:"absolute inset-0",style:{borderRadius:`${2*i}px`,border:`${i}px solid var(--color-walletSelectItemBackground)`}}),L("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:`${3*i}px`,height:`${3*i}px`,borderRadius:`${.5*i}px`,backgroundColor:"var(--color-walletSelectItemBackground)"}})]})},s=()=>{let l=Math.ceil(28.5-a/2)*i;return L("div",{className:"absolute z-[4] flex items-center justify-center box-border",style:{width:`${m}px`,height:`${m}px`,left:`${l}px`,top:`${l}px`,borderRadius:`${i}px`,padding:`${i/2}px`},children:L("img",{src:e,alt:"QR Code Logo",className:"h-full w-full object-cover",style:{borderRadius:`${i}px`}})})};return rt("div",{className:"relative overflow-hidden flex items-center justify-center",style:{width:t,height:t,borderRadius:`${2*i}px`},children:[L("svg",{className:"absolute inset-0 z-[3]",width:t,height:t,viewBox:"0 0 57 57",children:f()}),L("div",{className:"absolute inset-0 z-[100]",style:{background:"linear-gradient(90deg, transparent 50%, var(--color-walletSelectItemBackgroundHover), transparent)",backgroundSize:"200% 100%",transform:"scale(1.5) rotate(45deg)",animation:"shimmer 1000ms linear infinite both"}}),c({position:"top-left"}),c({position:"top-right"}),c({position:"bottom-left"}),e&&s()]})}return L(Ro,{arena:e,value:n})};import{jsx as O,jsxs as U}from"react/jsx-runtime";var j="transition-transform transition-[125] hover:scale-[1.03] transition-ease",Po=({className:e,label:n="Connect Wallet",accountStatus:t="full",chainStatus:r="full",showBalance:o=!0})=>{let{isConnected:a,isDisconnected:i,displayAddress:m,balance:p,openConnectModal:u,openAccountModal:f,openChainModal:c,chainIconUrl:s,chainName:l,currentChain:h,activeConnector:x}=nt(),{width:R}=ie(),C=R&&R>768;return i||!a||!x?O("button",{type:"button",onClick:()=>u?.(),className:d("cursor-pointer font-semibold inline-flex items-center justify-center focus:outline-none","text-connectButtonText bg-connectButtonBackground shadow-button active:scale-[0.95]","rounded-connectButton",j,"px-3.5 text-base leading-base min-h-[40px]",e),children:n}):U("div",{className:d("text-modalText flex items-stretch bg-transparent font-semibold text-base leading-base gap-3",e),children:[r!=="none"&&U("button",{type:"button",onClick:()=>c?.(),className:d("flex items-center rounded-currentNetworkButton cursor-pointer","bg-currentNetworkButtonBackground shadow-button","py-2 px-2.5 gap-1.5",j),"aria-label":"Switch chain",children:[r==="full"||r==="icon"?O(F,{chainIconUrl:s,chainName:l,className:"w-[24px] h-[24px]"}):null,(r==="full"||r==="name")&&C&&O("span",{children:h?.name||"Unknown Chain"})]}),U("button",{type:"button",onClick:()=>f?.(),className:d("flex items-center cursor-pointer rounded-connectButton bg-connectButtonBackground shadow-button",j),"aria-label":"Open account modal",children:[o&&C&&O("div",{className:"p-2 pl-3",children:p===void 0?O("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-accountActionItemBackgroundHover"}):U("span",{className:"",children:[p?.formattedTransferable||p?.formattedTotal||0," ",h?.nativeCurrency?.symbol||""]})}),U("div",{className:d("flex items-center bg-connectButtonInnerBackground border-2 border-connectButtonBackground rounded-connectButton gap-1.5 max-h-[40px]",o&&C?"bg-connectButtonInnerBackground py-1.5 px-2":"bg-connectButtonBackground py-2 px-2.5"),children:[t==="full"&&O("span",{className:"w-[24px] h-[24px]",children:O("img",{src:x.icon,alt:"luno"})}),O("span",{"aria-label":"Wallet icon placeholder",className:"",children:m})]})]})]})};import{useEffect as Vo,useRef as Io}from"react";import{jsx as Bo}from"react/jsx-runtime";var it=({size:e=160,dotCount:n=300,duration:t=3,className:r=""})=>{let o=Io(null);return Vo(()=>{if(!o.current)return;let a=1,i=2,m=Math.PI*(3-Math.sqrt(5)),p=e/2,u=p-i-a,f="http://www.w3.org/2000/svg";o.current.innerHTML="";let c=document.createElementNS(f,"svg");c.setAttribute("width",e.toString()),c.setAttribute("height",e.toString()),c.setAttribute("viewBox",`0 0 ${e} ${e}`),c.style.display="block",o.current.appendChild(c);for(let s=0;s<n;s++){let l=s+.5,h=l/n,x=Math.sqrt(h)*u,R=l*m,C=p+x*Math.cos(R),S=p+x*Math.sin(R),P=document.createElementNS(f,"circle");P.setAttribute("cx",C.toString()),P.setAttribute("cy",S.toString()),P.setAttribute("r",a.toString()),P.setAttribute("fill","currentColor"),P.setAttribute("opacity","0.6"),c.appendChild(P);let b=document.createElementNS(f,"animate");b.setAttribute("attributeName","r"),b.setAttribute("values",`${a*.5};${a*1.8};${a*.5}`),b.setAttribute("dur",`${t}s`),b.setAttribute("begin",`${h*t}s`),b.setAttribute("repeatCount","indefinite"),b.setAttribute("calcMode","spline"),b.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),P.appendChild(b);let M=document.createElementNS(f,"animate");M.setAttribute("attributeName","opacity"),M.setAttribute("values","0.2;1;0.2"),M.setAttribute("dur",`${t}s`),M.setAttribute("begin",`${h*t}s`),M.setAttribute("repeatCount","indefinite"),M.setAttribute("calcMode","spline"),M.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),P.appendChild(M)}},[e,n,t]),Bo("div",{ref:o,className:d("text-accentColor inline-flex w-full h-full justify-center align-center",r)})};import{Fragment as st,jsx as w,jsxs as B}from"react/jsx-runtime";var ve=Eo.memo(({selectedConnector:e,onConnect:n,qrCode:t,isWide:r,connectState:o})=>{let a=e?.hasConnectionUri();return B("div",{className:d("flex flex-col items-center",r?"w-[400px] p-4 min-h-[472px]":"justify-center w-full min-h-[400px]"),children:[r&&w("div",{className:"w-full",children:B("div",{className:"flex items-center justify-between",children:[w("div",{}),w(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:w(V,{})})]})}),w("div",{className:d("flex items-center py-12 flex-col grow justify-start",e&&a?"max-w-[220px]":"max-w-[360px]"),children:e?a?B("div",{className:"flex flex-col items-center gap-4",children:[w(at,{size:220,logoBackground:e.icon,uri:t}),B("div",{className:"text-secondaryFont leading-secondary font-[500] text-center",children:["Scan the QR Code with ",e.id==="nova"?"the Nova app":"your phone"]}),e.links?.browserExtension?B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer pt-[16px] text-base leading-base text-accentColor font-bold text-center",children:["Don\u2018t have ",e.name,"?"]}):t?w(ne,{className:"text-sm leading-sm text-accentColor",copyText:t,label:"Copy Link"}):null]}):B(st,{children:[w("div",{className:"w-[102px] h-[102px] pb-[16px]",children:w("img",{src:e.icon,className:"w-full h-full",alt:""})}),B("p",{className:"pb-[10px] text-primary leading-primary text-modalFont font-[600]",children:["Opening ",e.name,"..."]}),w("p",{className:"pb-[10px] text-secondaryFont text-secondary leading-secondary font-[500] text-center",children:"Confirm connection in the extension"}),o.isConnecting&&w(Q,{className:"w-[24px] h-[24px] text-secondaryFont animate-[spin_3s_linear_infinite]"}),!e.isInstalled()&&e.links.browserExtension&&B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer pt-[16px] text-base leading-base text-accentColor font-bold text-center",children:["Don\u2018t have ",e.name,"?"]}),!o.isConnecting&&o.isError&&e.isInstalled()&&w("button",{className:d("rounded-connectButton focus:outline-none py-[4px] px-[12px] cursor-pointer font-[600] text-primaryFont bg-connectButtonBackground shadow-connectButton active:scale-[0.95]",j),onClick:()=>n(e),children:"Retry"})]}):B(st,{children:[w("div",{className:"w-[160px] h-[160px] mb-4",children:w(it,{})}),w("p",{className:"cursor-pointer pb-[16px] text-base leading-base text-accentColor font-bold text-center",children:"New to wallets?"}),w("p",{className:"text-modalTextSecondary text-sm leading-sm font-medium text-center",children:"Your gateway to the decentralized world Connect a wallet to get started"})]})}),w("div",{})]})});import ct from"react";import{useConnectors as Do,isMobileDevice as Lo}from"@luno-kit/react";import{jsx as T,jsxs as se}from"react/jsx-runtime";var lt=ct.memo(({onConnect:e})=>{let n=Do();if(Lo()){let o=n.filter(a=>a.links.deepLink);return T("div",{className:"flex flex-col items-start gap-1 w-full",children:o.map(a=>T(be,{connector:a,onConnect:()=>e(a)},`${a.id}-${a.name}`))})}let t=n.filter(o=>o.isInstalled()),r=n.filter(o=>!o.isInstalled());return se("div",{className:"flex flex-col items-start gap-4 w-full",children:[se("div",{className:"flex flex-col items-start gap-3 w-full",children:[T("div",{className:"text-base text-modalText font-semibold leading-base",children:"Installed"}),T("div",{className:"flex flex-col items-start gap-1.5 w-full",children:t.map(o=>T(be,{connector:o,onConnect:()=>e(o)},o.id))})]}),r.length>0&&se("div",{className:"flex flex-col items-start gap-3 w-full",children:[T("div",{className:"text-base text-modalText font-semibold leading-base",children:"More"}),T("div",{className:"flex flex-col items-start gap-1 w-full",children:r.map(o=>T(be,{connector:o,onConnect:()=>e(o)},o.id))})]})]})}),be=ct.memo(({connector:e,onConnect:n})=>se("button",{onClick:n,className:d("cursor-pointer bg-walletSelectItemBackground p-2 w-full flex items-center gap-3 rounded-walletSelectItem border-none","hover:bg-walletSelectItemBackgroundHover transition-transform active:scale-[0.95]","text-left"),children:[T("div",{className:"w-[24px] h-[24px]",children:T("img",{src:e.icon,alt:e.name,className:"w-full h-full"})}),T("span",{className:"font-semibold leading-base text-base text-modalText",children:e.name})]}));import{Fragment as Go,jsx as A,jsxs as ce}from"react/jsx-runtime";var mt=({size:e="wide"})=>{let{isOpen:n,close:t}=J(),{connectAsync:r,reset:o,isPending:a,isError:i}=_o(),[m,p]=dt(null),[u,f]=dt(),{width:c}=ie(),s=c&&c>768,l=!!(e==="wide"&&s),{containerRef:h,currentViewRef:x,resetView:R,handleViewChange:C,currentView:S}=re({initialView:"Connect Wallet"}),P=async k=>{let Te=await k.getConnectionUri();f(Te)},b=async k=>{if(Ho()&&k.links.deepLink)try{await r({connectorId:k.id}),M(!1);return}catch{window.location.href=`${k.links.deepLink}?url=${window.location.href}`;return}!l&&C("walletView"),p(k),f(void 0),k.hasConnectionUri()&&P(k),await r({connectorId:k.id}),M(!1)},M=k=>{!k&&t(),o(),R(),p(null),f(void 0)},wt=Oo(()=>({"Connect Wallet":A(lt,{onConnect:b}),walletView:A(ve,{connectState:{isConnecting:a,isError:i},isWide:l,selectedConnector:m,qrCode:u,onConnect:b})}),[l,m,u,b,a,i]);return ye(()=>{l&&S==="walletView"&&C("Connect Wallet")},[l,S]),ye(()=>{l&&S==="walletView"&&C("Connect Wallet")},[l,S]),ye(()=>{l&&S==="walletView"&&C("Connect Wallet")},[l,S]),A(G,{open:n,onOpenChange:M,children:ce("div",{className:d("flex items-stretch justify-between w-full md:max-h-[504px] md:max-w-[724px]"),children:[ce("div",{className:d("flex flex-col items-start py-4 px-5 md:min-w-[360px] w-full md:w-auto",l&&"border-r-[1px] border-r-solid border-r-separatorLine"),children:[ce("div",{className:d("flex items-center justify-between w-full",!l&&"pb-4"),children:[S==="Connect Wallet"?A(D,{className:d("text-lg leading-lg text-modalText font-bold",l&&"pb-6"),children:"Connect Wallet"}):ce(Go,{children:[A("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>C("Connect Wallet"),"aria-label":"Back",children:A(W,{})}),A(D,{className:d("text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",!m?.hasConnectionUri()&&"sr-only"),children:m?.hasConnectionUri()&&"Scan by your phone"})]}),!l&&A(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:A(V,{})})]}),A("div",{ref:h,className:"relative overflow-hidden w-full",children:A("div",{ref:x,children:wt[S]})})]}),l&&A(ve,{connectState:{isConnecting:a,isError:i},isWide:l,selectedConnector:m,qrCode:u,onConnect:b})]})})};import{useState as jo}from"react";import{LunoProvider as qo}from"@luno-kit/react";import{QueryClient as Ko,QueryClientProvider as Jo}from"@tanstack/react-query";import{createContext as $o,useState as Ne,useContext as Zo,useMemo as Se,useCallback as zo,useEffect as ft}from"react";import{useEffect as Fo}from"react";var ut=["--color-accentColor","--color-walletSelectItemBackground","--color-walletSelectItemBackgroundHover","--color-walletSelectItemText","--color-connectButtonBackground","--color-connectButtonInnerBackground","--color-connectButtonText","--color-accountActionItemBackground","--color-accountActionItemBackgroundHover","--color-accountActionItemText","--color-accountSelectItemBackground","--color-accountSelectItemBackgroundHover","--color-accountSelectItemText","--color-currentNetworkButtonBackground","--color-currentNetworkButtonText","--color-networkSelectItemBackground","--color-networkSelectItemBackgroundHover","--color-networkSelectItemText","--color-navigationButtonBackground","--color-separatorLine","--color-modalBackground","--color-modalBackdrop","--color-modalBorder","--color-modalText","--color-modalTextSecondary","--color-modalControlButtonBackgroundHover","--color-modalControlButtonText","--color-success","--color-successForeground","--color-warning","--color-warningForeground","--color-error","--color-errorForeground","--color-info","--color-infoForeground","--color-skeleton","--color-cutLine","--font-body","--font-heading","--font-mono","--radius-walletSelectItem","--radius-connectButton","--radius-modalControlButton","--radius-accountActionItem","--radius-accountSelectItem","--radius-currentNetworkButton","--radius-networkSelectItem","--radius-modal","--radius-modalMobile","--shadow-button","--shadow-modal","--blur-modalOverlay"],pt=(e,n)=>{Fo(()=>{if(typeof window>"u")return;let t=document.documentElement;e.type==="complete"&&e.completeTheme?(Object.entries(e.completeTheme.colors).forEach(([r,o])=>{o&&t.style.setProperty(`--color-${r}`,o)}),Object.entries(e.completeTheme.fonts).forEach(([r,o])=>{o&&t.style.setProperty(`--font-${r}`,o)}),Object.entries(e.completeTheme.radii).forEach(([r,o])=>{o&&t.style.setProperty(`--radius-${r}`,o)}),Object.entries(e.completeTheme.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--shadow-${r}`,o)}),Object.entries(e.completeTheme.blurs).forEach(([r,o])=>{o&&t.style.setProperty(`--blur-${r}`,o)}),t.removeAttribute("data-theme")):e.type==="partial"&&e.partialOverrides?(t.setAttribute("data-theme",n),Object.keys(e.partialOverrides).length>0&&(ut.forEach(o=>{t.style.removeProperty(o)}),e.partialOverrides.colors&&Object.entries(e.partialOverrides.colors).forEach(([o,a])=>{a&&t.style.setProperty(`--color-${o}`,a)}),e.partialOverrides.fonts&&Object.entries(e.partialOverrides.fonts).forEach(([o,a])=>{a&&t.style.setProperty(`--font-${o}`,a)}),e.partialOverrides.radii&&Object.entries(e.partialOverrides.radii).forEach(([o,a])=>{a&&t.style.setProperty(`--radius-${o}`,a)}),e.partialOverrides.shadows&&Object.entries(e.partialOverrides.shadows).forEach(([o,a])=>{a&&t.style.setProperty(`--shadow-${o}`,a)}),e.partialOverrides.blurs&&Object.entries(e.partialOverrides.blurs).forEach(([o,a])=>{a&&t.style.setProperty(`--blur-${o}`,a)}))):(t.setAttribute("data-theme",n),ut.forEach(r=>{t.style.removeProperty(r)}))},[e,n])};import{jsx as Uo}from"react/jsx-runtime";var Ae="luno.lastThemePreference",Wo=e=>{try{localStorage.setItem(Ae,JSON.stringify(e))}catch{}},ht=$o(void 0),Me=e=>"colors"in e&&"fonts"in e&&"radii"in e&&"shadows"in e&&"blurs"in e,Qo=()=>{let[e,n]=Ne(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return ft(()=>{if(typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),r=o=>{n(o.matches?"dark":"light")};return r(t),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e},ke=({children:e,theme:n})=>{let t=Qo(),[r,o]=Ne(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ae);if(s){let l=JSON.parse(s);if(l?.isAuto)return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(l?.preferredTheme)return l.preferredTheme}}catch{}return!n||Me(n)?"light":n.defaultMode||"light"}),[a,i]=Ne(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ae);if(s)return JSON.parse(s)?.isAuto??!1}catch{}return!n||Me(n)?!1:n.autoMode??!1}),m=Se(()=>{if(!n)return{type:"default",completeTheme:null,partialOverrides:null};if(Me(n))return{type:"complete",completeTheme:n,partialOverrides:null};let c=n;if(c.theme)return{type:"complete",completeTheme:c.theme,partialOverrides:null};let s=null;return r==="light"&&c.light?s=c.light:r==="dark"&&c.dark?s=c.dark:s={...c},{type:"partial",completeTheme:null,partialOverrides:s}},[r,n]),p=Se(()=>m.type==="complete"?m.completeTheme:null,[m]);pt(m,r);let u=zo(c=>{let s=c==="auto";i(s),o(s?t||"light":c);let l={isAuto:s,...s?{}:{preferredTheme:c}};Wo(l)},[t]);ft(()=>{a&&o(t||"light")},[t,a]);let f=Se(()=>({themeMode:r,setThemeChoice:u,currentTheme:p}),[r,u,p]);return Uo(ht.Provider,{value:f,children:e})},xt=()=>{let e=Zo(ht);if(!e)throw new Error("useLunoTheme must be used within a ThemeProvider (which is part of LunoKitProvider)");return e};import{Fragment as Xo,jsx as _,jsxs as gt}from"react/jsx-runtime";var ci=({children:e,config:n,queryClientConfig:t,theme:r})=>{let[o]=jo(()=>new Ko(t));return _(Jo,{client:o,children:_(qo,{config:n,children:_(ke,{theme:r,children:gt(Ve,{children:[_("div",{className:"font-base luno-kit",children:e}),_(Yo,{modalSize:n.modalSize})]})})})})},Yo=({modalSize:e})=>gt(Xo,{children:[_(mt,{size:e}),_(et,{}),_(ot,{})]});export{Po as ConnectButton,ci as LunoKitProvider,xt as useLunoTheme};
2
+ import{useCallback as lo,useMemo as je}from"react";import{useAccount as co,useActiveConnector as mo,useBalance as uo,useChain as po}from"@luno-kit/react";import ce from"react";import*as M from"@radix-ui/react-dialog";import{clsx as ht}from"clsx";import{extendTailwindMerge as xt}from"tailwind-merge";var gt=xt({extend:{classGroups:{"font-size":["text-xs","text-sm","text-base","text-lg"]}}});function d(...e){return gt(ht(e))}function Ae(e,n){let t;return()=>{t&&clearTimeout(t),t=setTimeout(()=>{t=null,e()},n)}}import{jsx as Te,jsxs as bt}from"react/jsx-runtime";var wt=({open:e,onOpenChange:n,children:t,contentClassName:r,overlayClassName:o})=>Te(M.Root,{open:e,onOpenChange:n,children:bt(M.Portal,{children:[ce.createElement(M.Overlay,{className:d("fixed inset-0 z-[100] bg-modalBackdrop luno-kit","data-[state=open]:[animation:overlay-in_150ms_ease-out]",o)}),Te(M.Content,{className:d("luno-kit font-body fixed z-[200] text-modalText text-base leading-base","bg-modalBackground shadow-modal focus:outline-none overflow-hidden border border-modalBorder","transition-all duration-200","rounded-t-modalMobile bottom-0 left-0 w-full","translate-y-0 -translate-x-0","data-[state=open]:[animation:slide-up_200ms_ease-out]","md:bottom-auto md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2","md:w-auto md:rounded-modal","md:data-[state=open]:[animation:dialog-in_150ms_ease-out]",r),children:t})]})}),Ct=({children:e,className:n})=>ce.createElement(M.Title,{className:n},e),vt=({children:e,className:n,onClick:t})=>ce.createElement(M.Close,{className:n,onClick:t},e),G=wt,E=vt,D=Ct;import{createContext as yt,useCallback as me,useContext as ee,useEffect as St,useMemo as Nt,useState as Mt}from"react";import{ConnectionStatus as Y,useStatus as kt}from"@luno-kit/react";import{jsx as Tt}from"react/jsx-runtime";function de(){let[e,n]=Mt(!1),t=me(()=>n(!0),[]),r=me(()=>n(!1),[]);return{isOpen:e,open:t,close:r}}var z=yt(void 0),Re=({children:e})=>{let{isOpen:n,open:t,close:r}=de(),{isOpen:o,open:a,close:i}=de(),{isOpen:m,open:p,close:u}=de(),f=kt(),l=me(()=>{r(),i(),u()},[r,i,u]);St(()=>{f===Y.Disconnected&&(i(),u())},[f,i,u]);let s=Nt(()=>({isConnectModalOpen:n,isAccountModalOpen:o,isChainModalOpen:m,openConnectModal:f!==Y.Connected?t:void 0,closeConnectModal:r,openAccountModal:f===Y.Connected?a:void 0,closeAccountModal:i,openChainModal:f===Y.Connected?p:void 0,closeChainModal:u,closeAllModals:l}),[n,t,r,o,a,i,m,p,u,l,f]);return Tt(z.Provider,{value:s,children:e})},W=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useConnectModal must be used within a ModalProvider");return{isOpen:e.isConnectModalOpen,open:e.openConnectModal,close:e.closeConnectModal}},Q=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useAccountModal must be used within a ModalProvider");return{isOpen:e.isAccountModalOpen,open:e.openAccountModal,close:e.closeAccountModal}},U=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useChainModal must be used within a ModalProvider");return{isOpen:e.isChainModalOpen,open:e.openChainModal,close:e.closeChainModal}},At=()=>{let e=ee(z);if(!e)throw new Error("[ModalContext]: useCloseAllModals must be used within a ModalProvider");return e.closeAllModals};import{jsx as Pe}from"react/jsx-runtime";var Rt=e=>Pe("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Pe("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"})}),j=Rt;import{jsx as Ve}from"react/jsx-runtime";var Pt=e=>Ve("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Ve("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})}),V=Pt;import{jsx as Ie}from"react/jsx-runtime";var Vt=e=>Ie("svg",{xmlns:"http://www.w3.org/2000/svg",className:"copy_svg__icon",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 256 256",...e,children:Ie("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"})}),ue=Vt;import{jsx as Be}from"react/jsx-runtime";var It=e=>Be("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 256 256",width:"20",height:"20",...e,children:Be("path",{d:"M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z"})}),pe=It;import{jsx as Ee}from"react/jsx-runtime";var Bt=e=>Ee("svg",{xmlns:"http://www.w3.org/2000/svg",className:"list_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:Ee("path",{d:"M232,48V88a8,8,0,0,1-16,0V56H184a8,8,0,0,1,0-16h40A8,8,0,0,1,232,48ZM72,200H40V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16Zm152-40a8,8,0,0,0-8,8v32H184a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,224,160ZM32,96a8,8,0,0,0,8-8V56H72a8,8,0,0,0,0-16H32a8,8,0,0,0-8,8V88A8,8,0,0,0,32,96ZM188,167l-56,32a8,8,0,0,1-7.94,0L68,167A8,8,0,0,1,64,160V96a8,8,0,0,1,4-7l56-32a8,8,0,0,1,7.94,0l56,32a8,8,0,0,1,4,7v64A8,8,0,0,1,188,167ZM88.12,96,128,118.79,167.88,96,128,73.21ZM80,155.36l40,22.85V132.64L80,109.79Zm96,0V109.79l-40,22.85v45.57Z"})}),fe=Bt;import{jsx as De}from"react/jsx-runtime";var Et=e=>De("svg",{xmlns:"http://www.w3.org/2000/svg",className:"success_svg__icon",viewBox:"0 0 256 256",width:"20",height:"20",fill:"currentColor",...e,children:De("path",{d:"M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z"})}),he=Et;import{jsx as Le}from"react/jsx-runtime";var Dt=e=>Le("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",className:"switch_svg__icon",viewBox:"0 0 256 256",fill:"currentColor",...e,children:Le("path",{d:"M253.66,133.66l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L216,132.69V128A88,88,0,0,0,56.49,76.67a8,8,0,0,1-13-9.34A104,104,0,0,1,232,128v4.69l10.34-10.35a8,8,0,0,1,11.32,11.32Zm-41.18,55A104,104,0,0,1,24,128v-4.69L13.66,133.66A8,8,0,0,1,2.34,122.34l24-24a8,8,0,0,1,11.32,0l24,24a8,8,0,0,1-11.32,11.32L40,123.31V128a87.62,87.62,0,0,0,22.24,58.41A79.66,79.66,0,0,1,98.3,157.66a48,48,0,1,1,59.4,0,79.59,79.59,0,0,1,36.08,28.78,89.68,89.68,0,0,0,5.71-7.11,8,8,0,0,1,13,9.34ZM128,152a32,32,0,1,0-32-32A32,32,0,0,0,128,152Zm0,64a88.2,88.2,0,0,0,53.92-18.49,64,64,0,0,0-107.84,0A87.57,87.57,0,0,0,128,216Z"})}),xe=Dt;import{useMemo as Lt}from"react";import{jsx as Oe}from"react/jsx-runtime";var F=({chainIconUrl:e,chainName:n,className:t})=>e?Oe("img",{src:e,alt:n||"Chain icon",className:d("w-full h-full object-cover rounded-full",t)}):Oe("div",{className:d("w-full h-full bg-gray-500 text-modalText font-semibold","flex items-center justify-center rounded-full",t),children:n?n.charAt(0).toUpperCase():"C"});import{useAccount as Ot,useChain as _t,useDisconnect as Ht,getExplorerUrl as Gt}from"@luno-kit/react";import{Fragment as He,jsx as C,jsxs as q}from"react/jsx-runtime";var Ge=({onViewChange:e,onModalClose:n})=>{let{address:t}=Ot(),{chain:r}=_t(),{disconnectAsync:o}=Ht(),a=Lt(()=>[{key:"Chain Name",content:C("div",{className:"flex items-stretch w-full justify-between",children:q("div",{className:"flex items-center gap-2",children:[C("div",{className:"relative",children:C(F,{className:"w-[20px] h-[20px]",chainIconUrl:r?.chainIconUrl,chainName:r?.name})}),C("span",{className:"text-base text-modalText",children:r?.name||"Polkadot"})]})}),onClick:()=>e("switchChain")},{key:"View on Explorer",content:q(He,{children:[C(fe,{}),C("span",{className:"text-base text-accountActionItemText",children:"View on Explorer"})]}),onClick:()=>window.open(Gt(r?.blockExplorers?.default?.url,t,"address"))},{key:"Switch Account",content:q(He,{children:[C(xe,{}),C("span",{className:"text-base text-accountActionItemText",children:"Switch Account"})]}),onClick:()=>e("switchAccount")}],[e,r,t]),i=async()=>{await o(),n()};return q("div",{className:"flex flex-col items-center gap-3 w-full",children:[C("div",{className:"flex flex-col gap-1.5 w-full px-4",children:a.map(m=>C(_e,{onClick:m.onClick,children:m.content},m.key))}),C("div",{className:"w-full mx-[-100px] h-[1px] bg-separatorLine"}),C("div",{className:"w-full px-4 pb-4",children:q(_e,{onClick:i,children:[C(pe,{}),C("span",{className:"font-medium text-base text-accountActionItemText",children:"Disconnect"})]})})]})},_e=({children:e,onClick:n})=>C("button",{type:"button",onClick:()=>n?.(),className:d("w-full p-2.5 rounded-accountActionItem border-none text-left flex items-center gap-2 font-medium","bg-accountActionItemBackground hover:bg-accountActionItemBackgroundHover","transition-colors duration-200",n?"cursor-pointer":"cursor-auto"),"aria-label":typeof e=="string"?e:void 0,children:e});import Ft,{useCallback as $t}from"react";import{useAccount as Zt,useAccounts as zt,useActiveConnector as Wt,useBalance as Qt,useChain as Ut}from"@luno-kit/react";import{formatAddress as jt}from"@luno-kit/react";import{Fragment as Kt,jsx as I,jsxs as te}from"react/jsx-runtime";var ge=({onBack:e})=>{let{accounts:n,selectAccount:t}=zt(),{address:r}=Zt(),o=$t(a=>{t(a),e()},[e]);return I("div",{className:"flex flex-col gap-1.5 pt-3 overflow-auto max-h-[400px] no-scrollbar p-4 pt-0",children:n.map(a=>I(qt,{account:a,isSelected:a.address===r,selectAccount:o},a.address))})};ge.title="Switch Accounts";var qt=Ft.memo(({isSelected:e,account:n,selectAccount:t})=>{let{chain:r}=Ut(),o=n.address,{data:a}=Qt({address:o}),i=Wt();return te("button",{type:"button",onClick:()=>t(n),className:d("px-3.5 py-2.5 w-full rounded-accountSelectItem border-none","bg-accountSelectItemBackground","text-left flex items-center justify-between gap-2","transition-colors duration-200",e?"cursor-auto":"cursor-pointer hover:bg-accountSelectItemBackgroundHover"),"aria-label":n.name||o,disabled:e,children:[te("div",{className:"flex items-center gap-2",children:[I("div",{className:"shrink-0 w-[24px] h-[24px] rounded-full flex items-center justify-center",children:i?.icon&&I("img",{src:i?.icon,alt:"luno account"})}),te("div",{className:"flex flex-col items-start",children:[I("span",{className:"font-medium text-sm leading-sm text-accountSelectItemText",children:n.name||jt(o)}),I("span",{className:"text-xs text-modalTextSecondary font-medium",children:a===void 0?I("div",{className:"animate-pulse rounded w-[60px] h-[18px] bg-skeleton"}):te(Kt,{children:[a?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}),e&&I("div",{className:"border-[1px] border-solid border-accentColor rounded-full overflow-hidden flex items-center justify-center w-[18px] h-[18px]",children:I("div",{className:"rounded-full bg-accentColor w-[10px] h-[10px]"})})]})});import Jt,{useMemo as Xt,useState as Fe}from"react";import{useApi as Yt,useChain as eo,useChains as to,useSwitchChain as oo}from"@luno-kit/react";import{Fragment as $e,jsx as S,jsxs as $}from"react/jsx-runtime";var no=[{key:"All",label:"All"},{key:"Mainnets",label:"Mainnets"},{key:"Testnets",label:"Testnets"}],oe=({onChainSwitched:e})=>{let{chain:n}=eo(),t=to(),{switchChainAsync:r}=oo(),{isApiReady:o,apiError:a}=Yt(),[i,m]=Fe("All"),[p,u]=Fe(null),f=Xt(()=>{switch(i){case"Mainnets":return t.filter(s=>!s.testnet);case"Testnets":return t.filter(s=>s.testnet);case"All":default:return t}},[t,i]),l=async s=>{if(s.genesisHash!==n?.genesisHash&&!(!o&&!a)){u(s.genesisHash);try{await r({chainId:s.genesisHash}),e?.(s)}catch(c){console.error("Failed to switch chain:",c)}finally{u(null)}}};return $($e,{children:[S("div",{className:"flex items-center gap-1.5 w-full",children:no.map(s=>S("button",{onClick:()=>m(s.key),className:d("px-3.5 flex items-center justify-center cursor-pointer min-w-[48px] min-h-[24px] rounded-networkSelectItem text-[12px] leading-[16px] font-medium transition-colors",i===s.key?"bg-navigationButtonBackground text-modalText":"bg-transparent text-modalTextSecondary hover:text-modalText"),children:s.label},s.key))}),S("div",{className:"flex flex-col gap-1.5 overflow-y-auto custom-scrollbar max-h-[450px]",children:f.map(s=>S(ro,{chain:s,isSelected:s.genesisHash===n?.genesisHash,onSelect:l,isLoading:(p===s.genesisHash||!o)&&!a},s.genesisHash))}),f.length===0&&S("div",{className:"flex items-center justify-center py-12",children:$("span",{className:"text-modalTextSecondary text-xs",children:["No ",i==="All"?"chains":i.toLowerCase()," available"]})})]})},ro=Jt.memo(({chain:e,isSelected:n,isLoading:t,onSelect:r})=>$("button",{onClick:()=>r(e),disabled:n||t,className:d("flex items-center justify-between p-2.5 rounded-networkSelectItem","bg-networkSelectItemBackground","transition-colors duration-200",n||t?"cursor-default":"cursor-pointer hover:bg-networkSelectItemBackgroundHover",t&&"opacity-80"),children:[$("div",{className:"flex items-center gap-2",children:[S(F,{className:"w-[20px] bg-modal-bg h-[20px] flex items-center justify-center",chainIconUrl:e?.chainIconUrl,chainName:e?.name}),S("div",{className:"flex flex-col items-start",children:S("span",{className:"font-medium text-base text-modalText",children:e.name})})]}),S("div",{className:"flex items-center justify-center h-[20px]",children:n?t?$($e,{children:[S("span",{className:"text-accentColor text-xs leading-xs mr-1.5",children:"Switching"}),S("div",{className:"loading text-accentColor w-[15px] h-[15px]"})]}):$("span",{className:"status-dot-container",children:[S("span",{className:"ping-animation"}),S("span",{className:"status-dot"})]}):null})]}));import{jsx as Ze}from"react/jsx-runtime";var ne=({onBack:e})=>Ze("div",{className:"flex flex-col gap-3.5 p-4 pt-0",children:Ze(oe,{})});ne.title="Select Networks";import{useCallback as ao,useState as io}from"react";import{jsx as ze,jsxs as so}from"react/jsx-runtime";var re=({copyText:e,label:n,className:t=""})=>{let[r,o]=io(!1),a=ao(async i=>{try{return navigator.clipboard&&navigator.clipboard.writeText?(await navigator.clipboard.writeText(i),o(!0),setTimeout(()=>o(!1),2e3),!0):!1}catch(m){return console.error("Copy failed:",m),!1}},[]);return so("button",{type:"button",className:d("cursor-pointer bg-transparent border-none p-0 m-0 inline-flex items-center justify-center gap-1",t),onClick:()=>!r&&e&&a(e),"aria-label":"Copy address to clipboard",disabled:r,children:[r?ze(he,{className:"text-accentColor",width:16,height:16}):ze(ue,{width:16,height:16}),n]})};import{formatAddress as fo}from"@luno-kit/react";import{useCallback as We,useState as Qe,useRef as Ue}from"react";function ae({initialView:e,animationDuration:n=200,animationEasing:t="ease-out"}){let[r,o]=Qe(e),[a,i]=Qe(!1),m=Ue(null),p=Ue(null),u=We(l=>{if(l===r||a)return;if(i(!0),!m.current){o(l),i(!1);return}let s=m.current,c=s.offsetHeight;o(l),requestAnimationFrame(()=>{if(!s||!p.current){i(!1);return}let h=p.current.offsetHeight;s.animate([{height:c+"px"},{height:h+"px"}],{duration:n,easing:t,fill:"forwards"}).addEventListener("finish",()=>{i(!1)})})},[r,a,n,t]),f=We(()=>{o(e),i(!1)},[e]);return{currentView:r,isAnimating:a,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}}import{Fragment as qe,jsx as g,jsxs as H}from"react/jsx-runtime";var Ke=()=>{let{isOpen:e,close:n}=Q(),{address:t}=co(),{chain:r}=po(),{data:o}=uo({address:t}),a=mo(),{currentView:i,containerRef:m,currentViewRef:p,handleViewChange:u,resetView:f}=ae({initialView:"main"}),l=lo(()=>{n(),f()},[n]),s=je(()=>i==="switchAccount"?"Switch Account":i==="switchChain"?ne.title:null,[i]),c=je(()=>({main:g(Ge,{onViewChange:u,onModalClose:l}),switchAccount:g(ge,{onBack:()=>u("main")}),switchChain:g(ne,{onBack:()=>u("main")})}),[u,l]);return g(G,{open:e,onOpenChange:l,children:H("div",{className:d("flex flex-col w-full md:w-[360px] max-h-[500px] text-modalText","bg-modalBackground shadow-modal",i==="main"?"gap-6":"gap-3.5"),children:[H("div",{className:"flex items-stretch justify-between w-full px-4 pt-4",children:[i==="main"?H("div",{className:"flex items-center gap-3",children:[a?.icon&&g("div",{className:"flex items-center justify-center w-[55px] h-[55px]",children:g("img",{src:a.icon,alt:""})}),H("div",{className:"flex flex-col items-start gap-1 w-full",children:[g(D,{className:"sr-only",children:"Account Details"}),H("div",{className:"flex items-center gap-1.5 w-full",children:[g("span",{className:"text-base text-modalText font-semibold",children:fo(t)}),g(re,{copyText:t})]}),g("div",{className:"text-sm text-modalTextSecondary font-medium min-h-[20px]",children:o===void 0?g("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-skeleton"}):H(qe,{children:[o?.formattedTransferable||"0.00"," ",r?.nativeCurrency?.symbol||"DOT"]})})]})]}):H(qe,{children:[g("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>u("main"),"aria-label":"Back",children:g(j,{})}),g(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:s})]}),g(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:g(V,{})})]}),g("div",{ref:m,className:"relative overflow-hidden",children:g("div",{ref:p,children:c[i]})})]})})};import{jsx as Z,jsxs as Je}from"react/jsx-runtime";var Xe=()=>{let{isOpen:e,close:n}=U();return Z(G,{open:e,onOpenChange:t=>!t&&n(),children:Je("div",{className:"flex flex-col w-full md:w-[360px] max-h-[500px] p-4 gap-3.5 text-modalText",children:[Je("div",{className:"flex items-center justify-between w-full",children:[Z("div",{className:"w-[30px]"})," ",Z(D,{className:"text-lg leading-lg text-modalText font-semibold transition-opacity duration-300",children:"Select Network"}),Z(E,{className:"z-10 flex items-center justify-center h-[30px] w-[30px] rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200 cursor-pointer",children:Z(V,{})})]}),Z(oe,{})]})})};import{useEffect as Io,useMemo as Bo,useState as it}from"react";import{useConnect as Eo,isMobileDevice as Do}from"@luno-kit/react";import{useStatus as ho,useAccount as xo,useChain as go,useBalance as wo,ConnectionStatus as ie,useChains as Co,useActiveConnector as vo,formatAddress as bo}from"@luno-kit/react";function Ye(){let e=ho(),{account:n,address:t}=xo(),{chain:r}=go(),o=Co(),{data:a}=wo({address:t}),i=vo(),{open:m,isOpen:p}=W(),{open:u,isOpen:f}=Q(),{open:l,isOpen:s}=U(),c=e===ie.Connecting,h=e===ie.Connected,x=e===ie.Disconnected||e===ie.Disconnecting,T=!!r&&o.some(b=>b.genesisHash.toLowerCase()===r.genesisHash.toLowerCase());return{activeConnector:i,connectionStatus:e,isConnected:h,isDisconnected:x,isConnecting:c,account:n,address:t,displayAddress:bo(t),currentChain:r,configuredChains:o,isChainSupported:T,chainIconUrl:r?.chainIconUrl,chainName:r?.name,balance:a,openConnectModal:m,openAccountModal:u,openChainModal:l,isConnectModalOpen:p,isAccountModalOpen:f,isChainModalOpen:s}}import{useEffect as yo,useState as So}from"react";var se=()=>{let[e,n]=So({height:void 0,width:void 0});return yo(()=>{let t=Ae(()=>{n({height:window.innerHeight,width:window.innerWidth})},500);return window.addEventListener("resize",t),t(),()=>window.removeEventListener("resize",t)},[]),e};import Ro from"react";import{Cuer as No}from"cuer";import{jsx as L,jsxs as et}from"react/jsx-runtime";var tt=({logoBackground:e,uri:n,size:t})=>{if(!n){let a=Math.floor(14.25),i=t/57,m=a*i,p=Math.ceil(57/2-a/2),u=p+a,f=()=>{let c=[];for(let h=0;h<57;h++)for(let x=0;x<57;x++){if(h>=p&&h<u&&x>=p&&x<u||h<8&&x<8||h<8&&x>=49||h>=49&&x<8)continue;let b=x+.5,P=h+.5;c.push(L("rect",{x:b-.4,y:P-.4,width:.8,height:.8,rx:.4,fill:"var(--color-walletSelectItemBackground)"},`${h}-${x}`))}return c},l=({position:c})=>{let h=7*i,x={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0}};return et("div",{className:"absolute z-[4]",style:{width:`${h}px`,height:`${h}px`,...x[c]},children:[L("div",{className:"absolute inset-0",style:{borderRadius:`${2*i}px`,border:`${i}px solid var(--color-walletSelectItemBackground)`}}),L("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",style:{width:`${3*i}px`,height:`${3*i}px`,borderRadius:`${.5*i}px`,backgroundColor:"var(--color-walletSelectItemBackground)"}})]})},s=()=>{let c=p*i;return L("div",{className:"absolute z-[4] flex items-center justify-center box-border",style:{width:`${m}px`,height:`${m}px`,left:`${c}px`,top:`${c}px`,borderRadius:`${i}px`,padding:`${i/2}px`},children:L("img",{src:e,alt:"QR Code Logo",className:"h-full w-full object-cover",style:{borderRadius:`${i}px`}})})};return et("div",{className:"relative overflow-hidden flex items-center justify-center",style:{width:t,height:t,borderRadius:`${2*i}px`},children:[L("svg",{className:"absolute inset-0 z-[3]",width:t,height:t,viewBox:"0 0 57 57",children:f()}),L("div",{className:"absolute inset-0 z-[100]",style:{background:"linear-gradient(90deg, transparent 50%, var(--color-walletSelectItemBackgroundHover), transparent)",backgroundSize:"200% 100%",transform:"scale(1.5) rotate(45deg)",animation:"shimmer 1000ms linear infinite both"}}),l({position:"top-left"}),l({position:"top-right"}),l({position:"bottom-left"}),e&&s()]})}return L(No,{arena:e,value:n})};import{jsx as O,jsxs as K}from"react/jsx-runtime";var J="transition-transform transition-[125] hover:scale-[1.03] transition-ease",Mo=({className:e,label:n="Connect Wallet",accountStatus:t="full",chainStatus:r="full",showBalance:o=!0})=>{let{isConnected:a,isDisconnected:i,displayAddress:m,balance:p,openConnectModal:u,openAccountModal:f,openChainModal:l,chainIconUrl:s,chainName:c,currentChain:h,activeConnector:x}=Ye(),{width:T}=se(),b=T&&T>768;return i||!a||!x?O("button",{type:"button",onClick:()=>u?.(),className:d("cursor-pointer font-semibold inline-flex items-center justify-center focus:outline-none","text-connectButtonText bg-connectButtonBackground shadow-button active:scale-[0.95]","rounded-connectButton",J,"px-3.5 text-base leading-base min-h-[40px]",e),children:n}):K("div",{className:d("text-modalText flex items-stretch bg-transparent font-semibold text-base leading-base gap-3",e),children:[r!=="none"&&K("button",{type:"button",onClick:()=>l?.(),className:d("flex items-center rounded-currentNetworkButton cursor-pointer","bg-currentNetworkButtonBackground shadow-button","py-2 px-2.5 gap-1.5",J),"aria-label":"Switch chain",children:[r==="full"||r==="icon"?O(F,{chainIconUrl:s,chainName:c,className:"w-[24px] h-[24px]"}):null,(r==="full"||r==="name")&&b&&O("span",{children:h?.name||"Unknown Chain"})]}),K("button",{type:"button",onClick:()=>f?.(),className:d("flex items-center cursor-pointer rounded-connectButton bg-connectButtonBackground shadow-button",J),"aria-label":"Open account modal",children:[o&&b&&O("div",{className:"p-2 pl-3",children:p===void 0?O("div",{className:"animate-pulse rounded w-[80px] h-[20px] bg-accountActionItemBackgroundHover"}):K("span",{className:"",children:[p?.formattedTransferable||p?.formattedTotal||0," ",h?.nativeCurrency?.symbol||""]})}),K("div",{className:d("flex items-center bg-connectButtonInnerBackground border-2 border-connectButtonBackground rounded-connectButton gap-1.5 max-h-[40px]",o&&b?"bg-connectButtonInnerBackground py-1.5 px-2":"bg-connectButtonBackground py-2 px-2.5"),children:[t==="full"&&O("span",{className:"w-[24px] h-[24px]",children:O("img",{src:x.icon,alt:"luno"})}),O("span",{"aria-label":"Wallet icon placeholder",className:"",children:m})]})]})]})};import{useEffect as ko,useRef as Ao}from"react";import{jsx as To}from"react/jsx-runtime";var ot=({size:e=160,dotCount:n=300,duration:t=3,className:r=""})=>{let o=Ao(null);return ko(()=>{if(!o.current)return;let a=1,i=2,m=Math.PI*(3-Math.sqrt(5)),p=e/2,u=p-i-a,f="http://www.w3.org/2000/svg";o.current.innerHTML="";let l=document.createElementNS(f,"svg");l.setAttribute("width",e.toString()),l.setAttribute("height",e.toString()),l.setAttribute("viewBox",`0 0 ${e} ${e}`),l.style.display="block",o.current.appendChild(l);for(let s=0;s<n;s++){let c=s+.5,h=c/n,x=Math.sqrt(h)*u,T=c*m,b=p+x*Math.cos(T),P=p+x*Math.sin(T),R=document.createElementNS(f,"circle");R.setAttribute("cx",b.toString()),R.setAttribute("cy",P.toString()),R.setAttribute("r",a.toString()),R.setAttribute("fill","currentColor"),R.setAttribute("opacity","0.6"),l.appendChild(R);let y=document.createElementNS(f,"animate");y.setAttribute("attributeName","r"),y.setAttribute("values",`${a*.5};${a*1.8};${a*.5}`),y.setAttribute("dur",`${t}s`),y.setAttribute("begin",`${h*t}s`),y.setAttribute("repeatCount","indefinite"),y.setAttribute("calcMode","spline"),y.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),R.appendChild(y);let N=document.createElementNS(f,"animate");N.setAttribute("attributeName","opacity"),N.setAttribute("values","0.2;1;0.2"),N.setAttribute("dur",`${t}s`),N.setAttribute("begin",`${h*t}s`),N.setAttribute("repeatCount","indefinite"),N.setAttribute("calcMode","spline"),N.setAttribute("keySplines","0.4 0 0.6 1;0.4 0 0.6 1"),R.appendChild(N)}},[e,n,t]),To("div",{ref:o,className:d("text-accentColor inline-flex w-full h-full justify-center align-center",r)})};import{Fragment as nt,jsx as w,jsxs as B}from"react/jsx-runtime";var we=Ro.memo(({selectedConnector:e,onConnect:n,qrCode:t,isWide:r,connectState:o})=>{let a=e?.hasConnectionUri();return B("div",{className:d("flex flex-col items-center",r?"w-[450px] p-4 min-h-[472px]":"justify-center w-full min-h-[400px]"),children:[r&&w("div",{className:"w-full",children:B("div",{className:"flex items-center justify-between",children:[w("div",{}),w(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:w(V,{})})]})}),w("div",{className:d("flex items-center gap-4 flex-col grow justify-center",e&&a?"max-w-[300px]":"max-w-[360px]"),children:e?a?B("div",{className:"flex flex-col items-center gap-2.5",children:[w(tt,{size:300,logoBackground:e.icon,uri:t}),B("div",{className:"text-base leading-base font-medium text-center text-modalTextSecondary",children:["Scan the QR code with ",e.id==="nova"?"the Nova":"your phone"]}),w("div",{className:"min-h-[20px] flex items-center justify-center ",children:e.links?.browserExtension?B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer text-sm text-accentColor font-medium text-center hover:text-modalText",children:["Don't have ",e.name,"?"]}):t?w(re,{className:"text-sm leading-sm font-medium text-accentColor hover:text-modalText",copyText:t,label:"Copy Link"}):null})]}):B(nt,{children:[w("div",{className:"w-[80px] h-[80px]",children:w("img",{src:e.icon,className:"w-full h-full",alt:""})}),B("p",{className:"text-lg leading-lg text-modalFont font-bold",children:["Opening ",e.name,"..."]}),w("p",{className:"pb-[10px] text-base text-modalTextSecondary leading-base font-medium text-center",children:"Confirm connection in the extension"}),o.isConnecting&&w("div",{className:"loading text-modalText"}),!e.isInstalled()&&e.links.browserExtension&&B("p",{onClick:()=>window.open(e.links.browserExtension),className:"cursor-pointer pt-6 text-sm text-accentColor font-medium text-center hover:text-modalText",children:["Don\u2018t have ",e.name,"?"]}),!o.isConnecting&&o.isError&&e.isInstalled()&&w("button",{className:d("rounded-connectButton focus:outline-none py-[4px] px-[12px] cursor-pointer font-semibold text-sm text-modalText bg-connectButtonBackground shadow-connectButton active:scale-[0.95]",J),onClick:()=>n(e),children:"Retry"})]}):B(nt,{children:[w("div",{className:"w-[160px] h-[160px] mb-4",children:w(ot,{})}),w("p",{className:"cursor-pointer text-base leading-base text-accentColor font-semibold text-center",onClick:()=>window.open("https://polkadot.com/get-started/wallets/"),children:"New to wallets?"}),w("p",{className:"text-modalTextSecondary w-[250px] text-sm leading-sm font-medium text-center",children:"Connect your wallet to sign in and start using your assets."})]})}),w("div",{})]})});import rt from"react";import{useConnectors as Po,isMobileDevice as Vo}from"@luno-kit/react";import{jsx as A,jsxs as le}from"react/jsx-runtime";var at=rt.memo(({onConnect:e})=>{let n=Po();if(Vo()){let o=n.filter(a=>a.links.deepLink);return A("div",{className:"flex flex-col items-start gap-1 w-full",children:o.map(a=>A(Ce,{connector:a,onConnect:()=>e(a)},`${a.id}-${a.name}`))})}let t=n.filter(o=>o.isInstalled()),r=n.filter(o=>!o.isInstalled());return le("div",{className:"flex flex-col items-start gap-4 w-full",children:[le("div",{className:"flex flex-col items-start gap-2 w-full",children:[A("div",{className:"text-sm text-accentColor font-semibold leading-base",children:"Installed"}),A("div",{className:"flex flex-col items-start gap-1.5 w-full",children:t.map(o=>A(Ce,{connector:o,onConnect:()=>e(o)},o.id))})]}),r.length>0&&le("div",{className:"flex flex-col items-start gap-2 w-full",children:[A("div",{className:"text-sm text-modalTextSecondary font-semibold leading-base",children:"More"}),A("div",{className:"flex flex-col items-start gap-1 w-full",children:r.map(o=>A(Ce,{connector:o,onConnect:()=>e(o)},o.id))})]})]})}),Ce=rt.memo(({connector:e,onConnect:n})=>le("button",{onClick:n,className:d("cursor-pointer bg-walletSelectItemBackground p-2 w-full flex items-center gap-3 rounded-walletSelectItem border-none","hover:bg-walletSelectItemBackgroundHover transition-transform active:scale-[0.95]","text-left"),children:[A("div",{className:"w-[28px] h-[28px]",children:A("img",{src:e.icon,alt:e.name,className:"w-full h-full"})}),A("span",{className:"font-semibold leading-base text-base text-modalText",children:e.name})]}));import{Fragment as ve,jsx as v,jsxs as X}from"react/jsx-runtime";var st=({size:e="wide"})=>{let{isOpen:n,close:t}=W(),{connectAsync:r,reset:o,isPending:a,isError:i}=Eo(),[m,p]=it(null),[u,f]=it(),{width:l}=se(),s=l&&l>768,c=!!(e==="wide"&&s),{containerRef:h,currentViewRef:x,resetView:T,handleViewChange:b,currentView:P}=ae({initialView:"Connect Wallet"}),R=async k=>{let ke=await k.getConnectionUri();f(ke)},y=async k=>{if(Do()&&k.links.deepLink)try{await r({connectorId:k.id}),N(!1);return}catch{window.location.href=`${k.links.deepLink}?url=${window.location.href}`;return}!c&&b("walletView"),p(k),f(void 0),k.hasConnectionUri()&&R(k),await r({connectorId:k.id}),N(!1)},N=k=>{!k&&t(),o(),T(),p(null),f(void 0)},ft=Bo(()=>({"Connect Wallet":v(at,{onConnect:y}),walletView:v(we,{connectState:{isConnecting:a,isError:i},isWide:c,selectedConnector:m,qrCode:u,onConnect:y})}),[c,m,u,y,a,i]);return Io(()=>{c&&P==="walletView"&&b("Connect Wallet")},[c,P]),v(G,{open:n,onOpenChange:N,children:X("div",{className:d("flex items-stretch justify-between w-full md:max-h-[504px] md:max-w-[724px]"),children:[X("div",{className:d("flex flex-col items-start py-4 px-5 w-full md:w-auto",c?"md:min-w-[300px] border-r-[1px] border-r-solid border-r-separatorLine":"md:min-w-[360px]"),children:[X("div",{className:d("flex items-center justify-between w-full",!c&&"pb-4"),children:[P==="Connect Wallet"?X(ve,{children:[!c&&v("div",{className:"w-[30px] h-[30px]","aria-hidden":!0}),v(D,{className:d("text-lg leading-lg text-modalText font-bold",c?"pb-6":"flex-1 text-center"),children:"Connect Wallet"})]}):X(ve,{children:[v("button",{className:"flex items-center justify-center w-[30px] h-[30px] cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",onClick:()=>b("Connect Wallet"),"aria-label":"Back",children:v(j,{})}),v(D,{className:d("text-lg leading-lg text-modalText font-semibold transition-opacity duration-300"),children:m?.name})]}),!c&&v(E,{className:"z-10 w-[30px] h-[30px] flex items-center justify-center cursor-pointer rounded-modalControlButton border-none hover:bg-modalControlButtonBackgroundHover transition-colors duration-200",children:v(V,{})})]}),v("div",{ref:h,className:"relative overflow-hidden w-full",children:v("div",{ref:x,children:ft[P]})}),!c&&P==="Connect Wallet"&&v(ve,{children:v("p",{className:"cursor-pointer w-full pt-4 text-sm leading-sm text-accentColor font-medium text-center hover:text-modalText",onClick:()=>window.open("https://polkadot.com/get-started/wallets/"),children:"New to wallets?"})})]}),c&&v(we,{connectState:{isConnecting:a,isError:i},isWide:c,selectedConnector:m,qrCode:u,onConnect:y})]})})};import{useState as Zo}from"react";import{LunoProvider as zo}from"@luno-kit/react";import{QueryClient as Wo,QueryClientProvider as Qo}from"@tanstack/react-query";import{createContext as Oo,useState as Se,useContext as _o,useMemo as be,useCallback as Ho,useEffect as dt}from"react";import{useEffect as Lo}from"react";var lt=["--color-accentColor","--color-walletSelectItemBackground","--color-walletSelectItemBackgroundHover","--color-walletSelectItemText","--color-connectButtonBackground","--color-connectButtonInnerBackground","--color-connectButtonText","--color-accountActionItemBackground","--color-accountActionItemBackgroundHover","--color-accountActionItemText","--color-accountSelectItemBackground","--color-accountSelectItemBackgroundHover","--color-accountSelectItemText","--color-currentNetworkButtonBackground","--color-currentNetworkButtonText","--color-networkSelectItemBackground","--color-networkSelectItemBackgroundHover","--color-networkSelectItemText","--color-navigationButtonBackground","--color-separatorLine","--color-modalBackground","--color-modalBackdrop","--color-modalBorder","--color-modalText","--color-modalTextSecondary","--color-modalControlButtonBackgroundHover","--color-modalControlButtonText","--color-success","--color-successForeground","--color-warning","--color-warningForeground","--color-error","--color-errorForeground","--color-info","--color-infoForeground","--color-skeleton","--font-body","--radius-walletSelectItem","--radius-connectButton","--radius-modalControlButton","--radius-accountActionItem","--radius-accountSelectItem","--radius-currentNetworkButton","--radius-networkSelectItem","--radius-modal","--radius-modalMobile","--shadow-button","--shadow-modal","--blur-modalOverlay"],ct=(e,n)=>{Lo(()=>{if(typeof window>"u")return;let t=document.documentElement;e.type==="complete"&&e.completeTheme?(Object.entries(e.completeTheme.colors).forEach(([r,o])=>{o&&t.style.setProperty(`--color-${r}`,o)}),Object.entries(e.completeTheme.fonts).forEach(([r,o])=>{o&&t.style.setProperty(`--font-${r}`,o)}),Object.entries(e.completeTheme.radii).forEach(([r,o])=>{o&&t.style.setProperty(`--radius-${r}`,o)}),Object.entries(e.completeTheme.shadows).forEach(([r,o])=>{o&&t.style.setProperty(`--shadow-${r}`,o)}),Object.entries(e.completeTheme.blurs).forEach(([r,o])=>{o&&t.style.setProperty(`--blur-${r}`,o)}),t.removeAttribute("data-theme")):e.type==="partial"&&e.partialOverrides?(t.setAttribute("data-theme",n),Object.keys(e.partialOverrides).length>0&&(lt.forEach(o=>{t.style.removeProperty(o)}),e.partialOverrides.colors&&Object.entries(e.partialOverrides.colors).forEach(([o,a])=>{a&&t.style.setProperty(`--color-${o}`,a)}),e.partialOverrides.fonts&&Object.entries(e.partialOverrides.fonts).forEach(([o,a])=>{a&&t.style.setProperty(`--font-${o}`,a)}),e.partialOverrides.radii&&Object.entries(e.partialOverrides.radii).forEach(([o,a])=>{a&&t.style.setProperty(`--radius-${o}`,a)}),e.partialOverrides.shadows&&Object.entries(e.partialOverrides.shadows).forEach(([o,a])=>{a&&t.style.setProperty(`--shadow-${o}`,a)}),e.partialOverrides.blurs&&Object.entries(e.partialOverrides.blurs).forEach(([o,a])=>{a&&t.style.setProperty(`--blur-${o}`,a)}))):(t.setAttribute("data-theme",n),lt.forEach(r=>{t.style.removeProperty(r)}))},[e,n])};import{jsx as $o}from"react/jsx-runtime";var Ne="luno.lastThemePreference",Go=e=>{try{localStorage.setItem(Ne,JSON.stringify(e))}catch{}},mt=Oo(void 0),ye=e=>"colors"in e&&"fonts"in e&&"radii"in e&&"shadows"in e&&"blurs"in e,Fo=()=>{let[e,n]=Se(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return dt(()=>{if(typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),r=o=>{n(o.matches?"dark":"light")};return r(t),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e},Me=({children:e,theme:n})=>{let t=Fo(),[r,o]=Se(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ne);if(s){let c=JSON.parse(s);if(c?.isAuto)return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(c?.preferredTheme)return c.preferredTheme}}catch{}return!n||ye(n)?"light":n.defaultMode||"light"}),[a,i]=Se(()=>{if(typeof window<"u")try{let s=localStorage.getItem(Ne);if(s)return JSON.parse(s)?.isAuto??!1}catch{}return!n||ye(n)?!1:n.autoMode??!1}),m=be(()=>{if(!n)return{type:"default",completeTheme:null,partialOverrides:null};if(ye(n))return{type:"complete",completeTheme:n,partialOverrides:null};let l=n;if(l.theme)return{type:"complete",completeTheme:l.theme,partialOverrides:null};let s=null;return r==="light"&&l.light?s=l.light:r==="dark"&&l.dark?s=l.dark:s={...l},{type:"partial",completeTheme:null,partialOverrides:s}},[r,n]),p=be(()=>m.type==="complete"?m.completeTheme:null,[m]);ct(m,r);let u=Ho(l=>{let s=l==="auto";i(s),o(s?t||"light":l);let c={isAuto:s,...s?{}:{preferredTheme:l}};Go(c)},[t]);dt(()=>{a&&o(t||"light")},[t,a]);let f=be(()=>({themeMode:r,setThemeChoice:u,currentTheme:p}),[r,u,p]);return $o(mt.Provider,{value:f,children:e})},ut=()=>{let e=_o(mt);if(!e)throw new Error("useLunoTheme must be used within a ThemeProvider (which is part of LunoKitProvider)");return e};import{Fragment as jo,jsx as _,jsxs as pt}from"react/jsx-runtime";var Ja=({children:e,config:n,queryClientConfig:t,theme:r})=>{let[o]=Zo(()=>new Wo(t));return _(Qo,{client:o,children:_(zo,{config:n,children:_(Me,{theme:r,children:pt(Re,{children:[_("div",{className:"font-base luno-kit",children:e}),_(Uo,{modalSize:n.modalSize})]})})})})},Uo=({modalSize:e})=>pt(jo,{children:[_(st,{size:e}),_(Ke,{}),_(Xe,{})]});export{Mo as ConnectButton,Ja as LunoKitProvider,Q as useAccountModal,U as useChainModal,At as useCloseAllModals,W as useConnectModal,ut as useLunoTheme};
3
3
  //# sourceMappingURL=index.js.map