import{isMobile as e,isAndroid as n}from"react-device-detect";import{P as t}from"./errors-Dd6zfYtp.mjs";import{base64url as r}from"jose";import{f as i}from"./context-BKnOUECq.mjs";import{s as o}from"./wallet-connect-58EobR5U.mjs";function a(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function c(r,i){let o=a(i);if(e&&n&&o.universalLink)return h(o.universalLink,r);if(o.deepLink)return p(o.deepLink,r);if(o.universalLink)return h(o.universalLink,r);throw new t(`Unsupported wallet ${i.id}`)}function u(e,n){let t=a(n);if(t.universalLink)return h(t.universalLink,e)}let s="WALLETCONNECT_DEEPLINK_CHOICE";function f(){try{localStorage.removeItem(s)}catch{}}function l({href:e,name:n}){try{localStorage.setItem(s,JSON.stringify({href:e,name:n}))}catch{}}function m(){try{localStorage.removeItem(s)}catch{}}function d(e){return e.startsWith("http://")||e.startsWith("https://")}function p(e,n){if(d(e))return h(e,n);let t=e;return t.includes("://")||(t=e.replaceAll("/","").replaceAll(":",""),t=`${t}://`),t.endsWith("/")||(t=`${t}/`),{redirect:`${t}wc?uri=${encodeURIComponent(n)}`,href:t}}function h(e,n){if(!d(e))return p(e,n);let t=e;return t.endsWith("/")||(t=`${t}/`),{redirect:`${t}wc?uri=${encodeURIComponent(n)}`,href:t}}function w(e,n){window.open(e,n,"noreferrer noopener")}function L(e){return crypto.getRandomValues(new Uint8Array(e))}function v(){return r.encode(L(36))}function k(){return v()}async function y(e,n="S256"){if("S256"!=n)return e;{let n=await async function(e){let n=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",n))}(e);return r.encode(n)}}function g(){let e=o.get(i);if(!e)throw new t("Authentication error.");return e}export{k as a,c as b,v as c,y as d,f as e,u as f,L as g,g as h,w as o,m as r,l as s};
//# sourceMappingURL=pkce-BinverJO.mjs.map
