!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("WalletConnectBrowserUtils",[],e):"object"==typeof exports?exports.WalletConnectBrowserUtils=e():t.WalletConnectBrowserUtils=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return o})),n.d(e,"__assign",(function(){return i})),n.d(e,"__rest",(function(){return u})),n.d(e,"__decorate",(function(){return a})),n.d(e,"__param",(function(){return c})),n.d(e,"__metadata",(function(){return s})),n.d(e,"__awaiter",(function(){return f})),n.d(e,"__generator",(function(){return l})),n.d(e,"__exportStar",(function(){return d})),n.d(e,"__values",(function(){return g})),n.d(e,"__read",(function(){return p})),n.d(e,"__spread",(function(){return h})),n.d(e,"__await",(function(){return w})),n.d(e,"__asyncGenerator",(function(){return y})),n.d(e,"__asyncDelegator",(function(){return m})),n.d(e,"__asyncValues",(function(){return v})),n.d(e,"__makeTemplateObject",(function(){return b})),n.d(e,"__importStar",(function(){return O})),n.d(e,"__importDefault",(function(){return _})); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function o(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n=0;a--)(o=t[a])&&(u=(i<3?o(u):i>3?o(e,n,u):o(e,n))||u);return i>3&&u&&Object.defineProperty(e,n,u),u}function c(t,e){return function(n,r){e(n,r,t)}}function s(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function f(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n((function(e){e(t.value)})).then(u,a)}c((r=r.apply(t,e||[])).next())}))}function l(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function p(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function h(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(n=o[t](e)).value instanceof w?Promise.resolve(n.value.v).then(c,s):f(i[0][2],n)}catch(t){f(i[0][3],t)}var n}function c(t){a("next",t)}function s(t){a("throw",t)}function f(t,e){t(e),i.shift(),i.length&&a(i[0][0],i[0][1])}}function m(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,o){e[r]=t[r]?function(e){return(n=!n)?{value:w(t[r](e)),done:"return"===r}:o?o(e):e}:o}}function v(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=g(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,o,(e=t[n](e)).done,e.value)}))}}}function b(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function O(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function _(t){return t&&t.__esModule?t:{default:t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getClientMeta=e.getLocalStorage=e.getLocalStorageOrThrow=e.getCrypto=e.getCryptoOrThrow=e.getLocation=e.getLocationOrThrow=e.getNavigator=e.getNavigatorOrThrow=e.getDocument=e.getDocumentOrThrow=e.getFromWindowOrThrow=e.getFromWindow=e.isBrowser=e.isNode=e.isMobile=e.isIOS=e.isAndroid=e.detectOS=e.detectEnv=void 0;const r=n(0),o=r.__importStar(n(6)),i=r.__importStar(n(2)),u=n(7);function a(t){return(0,u.detect)(t)}function c(){const t=a();return t&&t.os?t.os:void 0}function s(){const t=c();return!!t&&t.toLowerCase().includes("android")}function f(){const t=c();return!!t&&(t.toLowerCase().includes("ios")||t.toLowerCase().includes("mac")&&navigator.maxTouchPoints>1)}function l(){const t=a();return!(!t||!t.name)&&"node"===t.name.toLowerCase()}e.detectEnv=a,e.detectOS=c,e.isAndroid=s,e.isIOS=f,e.isMobile=function(){return!!c()&&(s()||f())},e.isNode=l,e.isBrowser=function(){return!l()&&!!(0,e.getNavigator)()},e.getFromWindow=i.getFromWindow,e.getFromWindowOrThrow=i.getFromWindowOrThrow,e.getDocumentOrThrow=i.getDocumentOrThrow,e.getDocument=i.getDocument,e.getNavigatorOrThrow=i.getNavigatorOrThrow,e.getNavigator=i.getNavigator,e.getLocationOrThrow=i.getLocationOrThrow,e.getLocation=i.getLocation,e.getCryptoOrThrow=i.getCryptoOrThrow,e.getCrypto=i.getCrypto,e.getLocalStorageOrThrow=i.getLocalStorageOrThrow,e.getLocalStorage=i.getLocalStorage,e.getClientMeta=function(){return o.getWindowMetadata()}},function(t,e,n){"use strict";function r(t){let e=void 0;return"undefined"!=typeof window&&void 0!==window[t]&&(e=window[t]),e}function o(t){const e=r(t);if(!e)throw new Error(t+" is not defined in Window");return e}Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalStorage=e.getLocalStorageOrThrow=e.getCrypto=e.getCryptoOrThrow=e.getLocation=e.getLocationOrThrow=e.getNavigator=e.getNavigatorOrThrow=e.getDocument=e.getDocumentOrThrow=e.getFromWindowOrThrow=e.getFromWindow=void 0,e.getFromWindow=r,e.getFromWindowOrThrow=o,e.getDocumentOrThrow=function(){return o("document")},e.getDocument=function(){return r("document")},e.getNavigatorOrThrow=function(){return o("navigator")},e.getNavigator=function(){return r("navigator")},e.getLocationOrThrow=function(){return o("location")},e.getLocation=function(){return r("location")},e.getCryptoOrThrow=function(){return o("crypto")},e.getCrypto=function(){return r("crypto")},e.getLocalStorageOrThrow=function(){return o("localStorage")},e.getLocalStorage=function(){return r("localStorage")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.safeJsonStringify=e.safeJsonParse=void 0;const r=n(0).__importStar(n(9));e.safeJsonParse=r.safeJsonParse,e.safeJsonStringify=r.safeJsonStringify},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.removeLocal=e.getLocal=e.setLocal=void 0;const r=n(3),o=n(1);e.setLocal=function(t,e){const n=(0,r.safeJsonStringify)(e),i=(0,o.getLocalStorage)();i&&i.setItem(t,n)},e.getLocal=function(t){let e=null,n=null;const i=(0,o.getLocalStorage)();return i&&(n=i.getItem(t)),e=n?(0,r.safeJsonParse)(n):n,e},e.removeLocal=function(t){const e=(0,o.getLocalStorage)();e&&e.removeItem(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(0);r.__exportStar(n(1),e),r.__exportStar(n(3),e),r.__exportStar(n(4),e),r.__exportStar(n(10),e),r.__exportStar(n(11),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getWindowMetadata=void 0;const r=n(2);e.getWindowMetadata=function(){let t,e;try{t=r.getDocumentOrThrow(),e=r.getLocationOrThrow()}catch(t){return null}function n(...e){const n=t.getElementsByTagName("meta");for(let t=0;tr.getAttribute(t)).filter(t=>!!t&&e.includes(t));if(o.length&&o){const t=r.getAttribute("content");if(t)return t}}return""}const o=function(){let e=n("name","og:site_name","og:title","twitter:title");return e||(e=t.title),e}();return{description:n("description","og:description","twitter:description","keywords"),url:e.origin,icons:function(){const n=t.getElementsByTagName("link"),r=[];for(let t=0;t-1){const t=o.getAttribute("href");if(t)if(-1===t.toLowerCase().indexOf("https:")&&-1===t.toLowerCase().indexOf("http:")&&0!==t.indexOf("//")){let n=e.protocol+"//"+e.host;if(0===t.indexOf("/"))n+=t;else{const r=e.pathname.split("/");r.pop();n+=r.join("/")+"/"+t}r.push(n)}else if(0===t.indexOf("//")){const n=e.protocol+t;r.push(n)}else r.push(t)}}return r}(),name:o}}},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"BrowserInfo",(function(){return o})),n.d(e,"NodeInfo",(function(){return i})),n.d(e,"SearchBotDeviceInfo",(function(){return u})),n.d(e,"BotInfo",(function(){return a})),n.d(e,"ReactNativeInfo",(function(){return c})),n.d(e,"detect",(function(){return d})),n.d(e,"browserName",(function(){return p})),n.d(e,"parseUserAgent",(function(){return h})),n.d(e,"detectOS",(function(){return w})),n.d(e,"getNodeVersion",(function(){return y}));var r=function(){for(var t=0,e=0,n=arguments.length;e1)for(var n=1;nt.name.toLowerCase().includes(e.toLowerCase()))[0]}e.mobileLinkChoiceKey="WALLETCONNECT_DEEPLINK_CHOICE",e.formatIOSMobile=function(t,e){const n=encodeURIComponent(t);return e.universalLink?`${e.universalLink}/wc?uri=${n}`:e.deepLink?`${e.deepLink}${e.deepLink.endsWith(":")?"//":"/"}wc?uri=${n}`:""},e.saveMobileLinkInfo=function(t){const n=t.href.split("?")[0];(0,r.setLocal)(e.mobileLinkChoiceKey,Object.assign(Object.assign({},t),{href:n}))},e.getMobileRegistryEntry=o,e.getMobileLinkRegistry=function(t,e){let n=t;return e&&(n=e.map(e=>o(t,e)).filter(Boolean)),n}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.formatMobileRegistry=e.formatMobileRegistryEntry=e.getDappRegistryUrl=e.getWalletRegistryUrl=void 0;const r="https://registry.walletconnect.com";function o(t,e="mobile"){var n;return{name:t.name||"",shortName:t.metadata.shortName||"",color:t.metadata.colors.primary||"",logo:null!==(n=t.image_url.sm)&&void 0!==n?n:"",universalLink:t[e].universal||"",deepLink:t[e].native||""}}e.getWalletRegistryUrl=function(){return r+"/api/v2/wallets"},e.getDappRegistryUrl=function(){return r+"/api/v2/dapps"},e.formatMobileRegistryEntry=o,e.formatMobileRegistry=function(t,e="mobile"){return Object.values(t).filter(t=>!!t[e].universal||!!t[e].native).map(t=>o(t,e))}}])}));