/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@mocanetwork/airkit@1.9.0-beta.3/dist/airkit.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Airkit={})}(this,(function(e){"use strict";var t=function(e,s){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},t(e,s)};function s(e,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function n(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(n.prototype=s.prototype,new n)}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],n=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var n,i,r=s.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=r.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=r.return)&&s.call(r)}finally{if(i)throw i.error}}return a}function r(e,t,s){if(s||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function a(e,t,s,n){if("a"===s&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)}function o(e,t,s,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,s):i?i.value=s:t.set(e,s),s}"function"==typeof SuppressedError&&SuppressedError;var c="1.9.0-beta.3";const l="air_auth_setup_completed",h="air_auth_initialization_request",d="air_auth_initialization_response",u="air_auth_login_request",p="air_auth_login_response",f="air_auth_update_session_config_request",_="air_auth_update_session_config_response",w="air_auth_partner_user_info_request",y="air_auth_partner_user_info_response",E="air_auth_iframe_visibility_request",g="air_auth_setup_wallet_request",m="air_auth_setup_wallet_response",I="air_auth_setup_recovery_request",v="air_auth_setup_recovery_response",A="air_auth_setup_credential_request",R="air_auth_setup_credential_response",S="air_auth_cross_partner_token_request",N="air_auth_cross_partner_token_response",T="air_auth_partner_access_token_request",b="air_auth_partner_access_token_response",O="air_auth_logout_request",L="air_auth_logout_response",M="air_start_recovery_request",C="air_start_recovery_response",D="air_auth_expired_logout_request",U="air_credential_service_started",P="air_credential_initialization_request",W="air_credential_initialization_response",k="air_credential_iframe_visibility_request",q="air_credential_update_session_config_request",x="air_credential_update_session_config_response",K="air_credential_logout_request",$="air_credential_logout_response",F="air_credential_issue_request",V="air_credential_verify_request",H="air_credential_issue_response",G="air_credential_verify_response",z={SERVICE_STARTED:"air_recovery_service_started",INITIALIZATION_REQUEST:"air_recovery_initialization_request",INITIALIZATION_RESPONSE:"air_recovery_initialization_response",RECOVERY_INITIALIZED:"air_recovery_initialized",RECOVERY_IFRAME_VISIBILITY_REQUEST:"air_recovery_iframe_visibility_request",UPDATE_SESSION_CONFIG_REQUEST:"air_recovery_update_session_config_request",UPDATE_SESSION_CONFIG_RESPONSE:"air_recovery_update_session_config_response",GET_AGENT_KEYS_REQUEST:"air_recovery_get_agent_keys_request",GET_AGENT_KEYS_RESPONSE:"air_recovery_get_agent_keys_response",REGISTER_AGENT_KEY_REQUEST:"air_recovery_register_agent_key_request",REGISTER_AGENT_KEY_RESPONSE:"air_recovery_register_agent_key_response",REMOVE_AGENT_KEY_REQUEST:"air_recovery_remove_agent_key_request",REMOVE_AGENT_KEY_RESPONSE:"air_recovery_remove_agent_key_response",LOGOUT_REQUEST:"air_recovery_logout_request",LOGOUT_RESPONSE:"air_recovery_logout_response"},Y="air_service_started",j="air_initialization_request",X="air_initialization_response",B="air_wallet_initialized",Z="air_wallet_update_session_config_request",Q="air_wallet_update_session_config_response",J="air_wallet_login_request",ee="air_wallet_login_response",te="air_setup_mfa_request",se="air_setup_mfa_response",ne="air_claim_id_request",ie="air_claim_id_response",re="air_show_swap_ui_request",ae="air_show_swap_ui_response",oe="air_show_on_ramp_ui_request",ce="air_show_on_ramp_ui_response",le="air_show_transfer_ui_request",he="air_show_transfer_ui_response",de="air_show_receive_ui_request",ue="air_show_receive_ui_response",pe="air_deploy_smart_account_request",fe="air_deploy_smart_account_response",_e="air_wallet_iframe_visibility_request",we="air_is_smart_account_deployed_request",ye="air_is_smart_account_deployed_response",Ee="air_logout_request",ge="air_logout_response",me="air_open_window_request",Ie="air_open_window_response",ve="air_open_window_retry_request",Ae="air_open_window_retry_response",Re="air_window_closed";function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ne,Te={exports:{}},be=Te.exports;var Oe=(Ne||(Ne=1,function(e){var t,s;t=be,s=function(){var e=function(){},t="undefined",s=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],i={},r=null;function a(e,t){var s=e[t];if("function"==typeof s.bind)return s.bind(e);try{return Function.prototype.bind.call(s,e)}catch(t){return function(){return Function.prototype.apply.apply(s,[e,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var s=this.getLevel(),i=0;i<n.length;i++){var r=n[i];this[r]=i<s?e:this.methodFactory(r,s,this.name)}if(this.log=this.debug,typeof console===t&&s<this.levels.SILENT)return"No console available for logging"}function l(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function h(n,i,r){return function(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&s?o:void 0!==console[n]?a(console,n):void 0!==console.log?a(console,"log"):e)}(n)||l.apply(this,arguments)}function d(e,s){var a,o,l,d=this,u="loglevel";function p(){var e;if(typeof window!==t&&u){try{e=window.localStorage[u]}catch(e){}if(typeof e===t)try{var s=window.document.cookie,n=encodeURIComponent(u),i=s.indexOf(n+"=");-1!==i&&(e=/^([^;]+)/.exec(s.slice(i+n.length+1))[1])}catch(e){}return void 0===d.levels[e]&&(e=void 0),e}}function f(e){var t=e;if("string"==typeof t&&void 0!==d.levels[t.toUpperCase()]&&(t=d.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=d.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?u+=":"+e:"symbol"==typeof e&&(u=void 0),d.name=e,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=s||h,d.getLevel=function(){return null!=l?l:null!=o?o:a},d.setLevel=function(e,s){return l=f(e),!1!==s&&function(e){var s=(n[e]||"silent").toUpperCase();if(typeof window!==t&&u){try{return void(window.localStorage[u]=s)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+s+";"}catch(e){}}}(l),c.call(d)},d.setDefaultLevel=function(e){o=f(e),p()||d.setLevel(e,!1)},d.resetLevel=function(){l=null,function(){if(typeof window!==t&&u){try{window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(d)},d.enableAll=function(e){d.setLevel(d.levels.TRACE,e)},d.disableAll=function(e){d.setLevel(d.levels.SILENT,e)},d.rebuild=function(){if(r!==d&&(a=f(r.getLevel())),c.call(d),r===d)for(var e in i)i[e].rebuild()},a=f(r?r.getLevel():"WARN");var _=p();null!=_&&(l=f(_)),c.call(d)}(r=new d).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=i[e];return t||(t=i[e]=new d(e,r.methodFactory)),t};var u=typeof window!==t?window.log:void 0;return r.noConflict=function(){return typeof window!==t&&window.log===r&&(window.log=u),r},r.getLoggers=function(){return i},r.default=r,r},e.exports?e.exports=s():t.log=s()}(Te)),Te.exports),Le=Se(Oe);class Me extends Error{constructor(e,t,s={}){const{cause:n,context:i}=s;super(t||e),this.name=e,this.stack=n?.stack,this.cause=n,this.context=i}toJSON(){return{name:this.name,message:this.message,context:this.context,cause:this.cause}}}function Ce(e){if(e instanceof Error)return e;let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch{}return new Error(`This value was not thrown as type Error: ${t}`)}const De=(e,t)=>{let s=Le.levels.ERROR;"development"===e?s=t?Le.levels.TRACE:Le.levels.INFO:"staging"===e?s=t?Le.levels.DEBUG:Le.levels.INFO:"uat"===e||"sandbox"===e?s=t?Le.levels.INFO:Le.levels.WARN:"production"===e&&(s=t?Le.levels.WARN:Le.levels.ERROR),Le.setLevel(s),Le.info(`[${window?.location?.href}] LogLevel: ${(e=>{const t=Object.keys(Le.levels);return e>=0&&e<t.length?t[e]:"UNKNOWN"})(Le.getLevel())}`)},Ue={PRODUCTION:"production",UAT:"uat",STAGING:"staging",DEVELOPMENT:"development",SANDBOX:"sandbox"},Pe=["air-wallet","air-credential","air-auth","air-recovery"],We=["https://fonts.googleapis.com","https://fonts.gstatic.com"],ke={authUrl:"https://account.sandbox-testnet.air3.com/auth/",walletUrl:"https://account.sandbox-testnet.air3.com/wallet/",recoveryUrl:"https://account.sandbox-testnet.air3.com/recovery/",credentialUrl:"https://account.sandbox-testnet.air3.com/credential/"},qe={[Ue.DEVELOPMENT]:{authUrl:"https://localhost:8200/auth/",walletUrl:"https://localhost:8200/wallet/",recoveryUrl:"https://localhost:8200/recovery/",credentialUrl:"https://localhost:8200/credential/"},[Ue.STAGING]:{authUrl:"https://account.staging.air3.com/auth/",walletUrl:"https://account.staging.air3.com/wallet/",recoveryUrl:"https://account.staging.air3.com/recovery/",credentialUrl:"https://account.staging.air3.com/credential/"},[Ue.UAT]:{authUrl:"https://account.uat.air3.com/auth/",walletUrl:"https://account.uat.air3.com/wallet/",recoveryUrl:"https://account.uat.air3.com/recovery/",credentialUrl:"https://account.uat.air3.com/credential/"},[Ue.SANDBOX]:{authUrl:"https://account.sandbox.air3.com/auth/",walletUrl:"https://account.sandbox.air3.com/wallet/",recoveryUrl:"https://account.sandbox.air3.com/recovery/",credentialUrl:"https://account.sandbox.air3.com/credential/"},[Ue.PRODUCTION]:{authUrl:"https://account.air3.com/auth/",walletUrl:"https://account.air3.com/wallet/",recoveryUrl:"https://account.air3.com/recovery/",credentialUrl:"https://account.air3.com/credential/"}},xe=(e,t)=>e===Ue.SANDBOX&&"testnet"===t?ke:qe[e],Ke=(e,t)=>{try{const s=new URL(e,window.location.href),n=s.origin!==window.location.origin,i=document.head,r=(e,t,s,n)=>{if(i.querySelector(`link[rel="${e}"][href="${t}"]`))return;const r=document.createElement("link");r.rel=e,r.href=t,n&&(r.crossOrigin="anonymous"),i.appendChild(r)};if(r("dns-prefetch",`//${s.hostname}`),r("preconnect",s.origin,void 0,n),!1!==t?.prefetch&&HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){const e=`speculation-${btoa(s.href).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}`;if(!document.getElementById(e)){const n=document.createElement("script");n.id=e,n.type="speculationrules";const i=[{source:"list",urls:[s.href],eagerness:"immediate"}],r={..."document"===(t?.as??"document")?{prerender:i}:{prefetch:i}};n.textContent=JSON.stringify(r),document.body.appendChild(n)}}}catch(t){Le.warn("[addResourceHints] Invalid URL:",e,t)}},$e=e=>e instanceof Element||e instanceof Document,Fe=()=>Math.random().toString(36).slice(2);class Ve extends Me{static from(e){return e instanceof Ve?e:e instanceof Object&&"message"in e?"User cancelled login"===e.message?new Ve("USER_CANCELLED",e.message):new Ve("UNKNOWN_ERROR",e.message.toString()):new Ve("UNKNOWN_ERROR")}}class He extends Error{constructor(e){super(e),this.metaMessages=[]}}class Ge extends He{constructor(){super(...arguments),this.code=4001,this.name="UserRejectedRequestError"}}class ze extends He{constructor(){super(...arguments),this.code=4100,this.name="UnauthorizedProviderError"}}class Ye extends He{constructor(){super(...arguments),this.code=4200,this.name="UnsupportedProviderMethodError"}}class je extends He{constructor(){super(...arguments),this.code=4900,this.name="ProviderDisconnectedError"}}class Xe extends He{constructor(){super(...arguments),this.code=4901,this.name="ChainDisconnectedError"}}class Be extends He{constructor(){super(...arguments),this.code=4902,this.name="SwitchChainError"}}class Ze extends He{constructor(e){const t=e.replace(/\nVersion:.*$/,"");super(t),this.code=-32003,this.name="TransactionRejectedRpcError",this.metaMessages.push((e=>{if(!e)return"";if(e.includes("reason:")){const t=e.match(/reason:\s*(0x[a-fA-F0-9]+)/);return t?t[1].trim():""}if(e.includes("with reason:")){const t=e.match(/with reason:\s*(0x[a-fA-F0-9]+)/);return t?t[1].trim():""}const t=e.match(/(0x[a-fA-F0-9]{8,})/);return t?t[1].trim():""})(t))}}class Qe extends He{constructor(){super(...arguments),this.code=-32600,this.name="InvalidRequestRpcError"}}class Je extends He{constructor(){super(...arguments),this.code=-32601,this.name="MethodNotFoundRpcError"}}class et extends He{constructor(){super(...arguments),this.code=-32602,this.name="InvalidParamsRpcError"}}class tt extends He{constructor(){super(...arguments),this.code=-32603,this.name="InternalRpcError"}}function st(e){if(e instanceof He)return e;if("object"==typeof e&&null!==e&&"errorCode"in e&&"errorMessage"in e&&"number"==typeof e.errorCode&&"string"==typeof e.errorMessage)switch(e.errorCode){case 4001:return new Ge(e.errorMessage);case 4100:return new ze(e.errorMessage);case 4200:return new Ye(e.errorMessage);case 4900:return new je(e.errorMessage);case 4901:return new Xe(e.errorMessage);case 4902:return new Be(e.errorMessage);case-32003:return new Ze(e.errorMessage)}let t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch{}return new tt(`Invalid value for ProviderRpcError: ${t}`)}function nt(e){return"function"==typeof e}function it(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var rt=it((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n  "):"",this.name="UnsubscriptionError",this.errors=t}}));function at(e,t){if(e){var s=e.indexOf(t);0<=s&&e.splice(s,1)}}var ot=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,s,a,o;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var l=n(c),h=l.next();!h.done;h=l.next()){h.value.remove(this)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}else c.remove(this);var d=this.initialTeardown;if(nt(d))try{d()}catch(e){o=e instanceof rt?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var p=n(u),f=p.next();!f.done;f=p.next()){var _=f.value;try{ht(_)}catch(e){o=null!=o?o:[],e instanceof rt?o=r(r([],i(o)),i(e.errors)):o.push(e)}}}catch(e){s={error:e}}finally{try{f&&!f.done&&(a=p.return)&&a.call(p)}finally{if(s)throw s.error}}}if(o)throw new rt(o)}},e.prototype.add=function(t){var s;if(t&&t!==this)if(this.closed)ht(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(s=this._finalizers)&&void 0!==s?s:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&at(t,e)},e.prototype.remove=function(t){var s=this._finalizers;s&&at(s,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),ct=ot.EMPTY;function lt(e){return e instanceof ot||e&&"closed"in e&&nt(e.remove)&&nt(e.add)&&nt(e.unsubscribe)}function ht(e){nt(e)?e():e.unsubscribe()}var dt={Promise:void 0},ut=function(e,t){for(var s=[],n=2;n<arguments.length;n++)s[n-2]=arguments[n];return setTimeout.apply(void 0,r([e,t],i(s)))};function pt(){}function ft(e){e()}var _t=function(e){function t(t){var s=e.call(this)||this;return s.isStopped=!1,t?(s.destination=t,lt(t)&&t.add(s)):s.destination=gt,s}return s(t,e),t.create=function(e,t,s){return new yt(e,t,s)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ot),wt=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Et(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Et(e)}else Et(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Et(e)}},e}(),yt=function(e){function t(t,s,n){var i,r=e.call(this)||this;return i=nt(t)||!t?{next:null!=t?t:void 0,error:null!=s?s:void 0,complete:null!=n?n:void 0}:t,r.destination=new wt(i),r}return s(t,e),t}(_t);function Et(e){var t;t=e,ut((function(){throw t}))}var gt={closed:!0,next:pt,error:function(e){throw e},complete:pt},mt="function"==typeof Symbol&&Symbol.observable||"@@observable";function It(e){return e}var vt=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var s=new e;return s.source=this,s.operator=t,s},e.prototype.subscribe=function(e,t,s){var n,i=this,r=(n=e)&&n instanceof _t||function(e){return e&&nt(e.next)&&nt(e.error)&&nt(e.complete)}(n)&&lt(n)?e:new yt(e,t,s);return ft((function(){var e=i,t=e.operator,s=e.source;r.add(t?t.call(r,s):s?i._subscribe(r):i._trySubscribe(r))})),r},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var s=this;return new(t=At(t))((function(t,n){var i=new yt({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});s.subscribe(i)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[mt]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],s=0;s<arguments.length;s++)t[s]=arguments[s];return(0===(e=t).length?It:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=At(e))((function(e,s){var n;t.subscribe((function(e){return n=e}),(function(e){return s(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function At(e){var t;return null!==(t=null!=e?e:dt.Promise)&&void 0!==t?t:Promise}function Rt(e){return function(t){if(function(e){return nt(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function St(e,t,s,n,i){return new Nt(e,t,s,n,i)}var Nt=function(e){function t(t,s,n,i,r,a){var o=e.call(this,t)||this;return o.onFinalize=r,o.shouldUnsubscribe=a,o._next=s?function(e){try{s(e)}catch(e){t.error(e)}}:e.prototype._next,o._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,o._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,o}return s(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var s=this.closed;e.prototype.unsubscribe.call(this),!s&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(_t),Tt=it((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),bt=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return s(t,e),t.prototype.lift=function(e){var t=new Ot(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Tt},t.prototype.next=function(e){var t=this;ft((function(){var s,i;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var r=n(t.currentObservers),a=r.next();!a.done;a=r.next()){a.value.next(e)}}catch(e){s={error:e}}finally{try{a&&!a.done&&(i=r.return)&&i.call(r)}finally{if(s)throw s.error}}}}))},t.prototype.error=function(e){var t=this;ft((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var s=t.observers;s.length;)s.shift().error(e)}}))},t.prototype.complete=function(){var e=this;ft((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,s=this,n=s.hasError,i=s.isStopped,r=s.observers;return n||i?ct:(this.currentObservers=null,r.push(e),new ot((function(){t.currentObservers=null,at(r,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,s=t.hasError,n=t.thrownError,i=t.isStopped;s?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new vt;return e.source=this,e},t.create=function(e,t){return new Ot(e,t)},t}(vt),Ot=function(e){function t(t,s){var n=e.call(this)||this;return n.destination=t,n.source=s,n}return s(t,e),t.prototype.next=function(e){var t,s;null===(s=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===s||s.call(t,e)},t.prototype.error=function(e){var t,s;null===(s=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===s||s.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,s;return null!==(s=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==s?s:ct},t}(bt),Lt=it((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Mt(e,t){return new Promise((function(t,s){var n=new yt({next:function(e){t(e),n.unsubscribe()},error:s,complete:function(){s(new Lt)}});e.subscribe(n)}))}function Ct(e,t){return Rt((function(s,n){var i=0;s.subscribe(St(n,(function(s){return e.call(t,s,i++)&&n.next(s)})))}))}const Dt=(e,t)=>"bigint"==typeof t?t.toString():t;var Ut,Pt,Wt,kt,qt,xt,Kt,$t,Ft,Vt,Ht,Gt,zt;!function(e){e.UNAUTHORIZED="UNAUTHORIZED",e.INVALID_TOKEN="INVALID_TOKEN",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS"}(Ut||(Ut={})),function(e){e.PARTNER_ACCESS_TOKEN_INVALID="PARTNER_ACCESS_TOKEN_INVALID",e.USER_MISMATCH="USER_MISMATCH"}(Pt||(Pt={})),function(e){e.REALM_ID_NOT_FOUND="REALM_ID_NOT_FOUND",e.REALM_ID_INVALID_NAME="REALM_ID_INVALID_NAME",e.REALM_ID_ALREADY_EXISTS="REALM_ID_ALREADY_EXISTS",e.REALM_ID_DUPLICATE_PARTNER_USER="REALM_ID_DUPLICATE_PARTNER_USER"}(Wt||(Wt={})),function(e){e.INVALID_PARAMETER="INVALID_PARAMETER"}(kt||(kt={})),function(e){e.INTERNAL_SERVER_ERROR="INTERNAL_SERVER_ERROR"}(qt||(qt={})),function(e){e.PASSKEY_REGISTRATION_FAILED="PASSKEY_REGISTRATION_FAILED",e.PASSKEY_AUTHENTICATION_FAILED="PASSKEY_AUTHENTICATION_FAILED",e.PASSKEY_LIMIT_EXCEEDED="PASSKEY_LIMIT_EXCEEDED",e.PASSKEY_NOT_FOUND="PASSKEY_NOT_FOUND",e.PASSKEY_UNAUTHORIZED="PASSKEY_UNAUTHORIZED",e.PASSKEY_CHALLENGE_INVALID="PASSKEY_CHALLENGE_INVALID"}(xt||(xt={})),function(e){e.PASSWORDLESS_CODE_EXPIRED="PASSWORDLESS_CODE_EXPIRED",e.PASSWORDLESS_INVALID_CODE="PASSWORDLESS_INVALID_CODE",e.PASSWORDLESS_MAX_ATTEMPTS="PASSWORDLESS_MAX_ATTEMPTS",e.PASSWORDLESS_HOURLY_LIMIT="PASSWORDLESS_HOURLY_LIMIT",e.PASSWORDLESS_LOCK_EXCEEDED="PASSWORDLESS_LOCK_EXCEEDED",e.CAPTCHA_TOKEN_VERIFICATION_FAILED="CAPTCHA_TOKEN_VERIFICATION_FAILED",e.CAPTCHA_TOKEN_INVALID="CAPTCHA_TOKEN_INVALID",e.CAPTCHA_SECRET_MISSING="CAPTCHA_SECRET_MISSING",e.CAPTCHA_TOKEN_MISSING="CAPTCHA_TOKEN_MISSING"}(Kt||(Kt={})),function(e){e.AUTH_WALLET_LOCK_EXCEEDED="AUTH_WALLET_LOCK_EXCEEDED",e.AUTH_WALLET_NONCE_EXPIRED_OR_INVALID="AUTH_WALLET_NONCE_EXPIRED_OR_INVALID",e.AUTH_WALLET_ADDRESS_MISMATCH="AUTH_WALLET_ADDRESS_MISMATCH",e.AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED="AUTH_WALLET_SIGNATURE_VERIFICATION_FAILED"}($t||($t={})),function(e){e.LINK_WALLET_ALREADY_LINKED="LINK_WALLET_ALREADY_LINKED",e.LINK_WALLET_LINKED_OTHER_ACCOUNT="LINK_WALLET_LINKED_OTHER_ACCOUNT",e.LINK_EMAIL_LINKED_OTHER_ACCOUNT="LINK_EMAIL_LINKED_OTHER_ACCOUNT"}(Ft||(Ft={})),function(e){e.INTENT_INVALID="INTENT_INVALID",e.INTENT_LOCK_EXCEEDED="INTENT_LOCK_EXCEEDED",e.INTENT_REQUIRED="INTENT_REQUIRED",e.INTENT_UNSUPPORTED_TYPE="INTENT_UNSUPPORTED_TYPE"}(Vt||(Vt={})),function(e){e.WALLET_PROVIDER_ERROR="WALLET_PROVIDER_ERROR"}(Ht||(Ht={})),function(e){e.AIR_ID_MINT_TRANSACTION_NOT_FOUND="AIR_ID_MINT_TRANSACTION_NOT_FOUND",e.AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND="AIR_ID_ON_CHAIN_TRANSACTION_NOT_FOUND",e.AIR_ID_NOT_FOUND="AIR_ID_NOT_FOUND",e.AIR_ID_INVALID_OR_DISABLED_CONFIGURATION="AIR_ID_INVALID_OR_DISABLED_CONFIGURATION",e.AIR_ID_RPC_URL_NOT_CONFIGURED="AIR_ID_RPC_URL_NOT_CONFIGURED",e.AIR_ID_INVALID_STATUS="AIR_ID_INVALID_STATUS",e.AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED="AIR_ID_PARTNER_ELIGIBILITY_CHECK_FAILED",e.AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT="AIR_ID_PARTNER_ELIGIBILITY_CHECK_TIMEOUT",e.AIR_ID_MULTIPLE_AIR_IDS_FOUND="AIR_ID_MULTIPLE_AIR_IDS_FOUND",e.AIR_ID_NAME_RESERVED="AIR_ID_NAME_RESERVED",e.AIR_ID_NAME_PROFANITY="AIR_ID_NAME_PROFANITY",e.AIR_ID_USER_ALREADY_HAS_AIR_ID="AIR_ID_USER_ALREADY_HAS_AIR_ID",e.AIR_ID_NAME_ALREADY_EXISTS="AIR_ID_NAME_ALREADY_EXISTS",e.AIR_ID_INVALID_MINT_NAME="AIR_ID_INVALID_MINT_NAME",e.AIR_ID_MINT_TRANSACTION_HASH_MISMATCH="AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"}(Gt||(Gt={})),function(e){e.WINDOW_BLOCKED="WINDOW_BLOCKED",e.WINDOW_CLOSED="WINDOW_CLOSED"}(zt||(zt={}));const Yt={...Ut,...Pt,...Wt,...kt,...qt,...xt,...Kt,...$t,...Ft,...Vt,...Ht,...Gt,...zt};class jt extends Me{}new Set(["USER_CANCELLED","CONFIG_ERROR","CLIENT_ERROR","UNKNOWN_ERROR","PERMISSION_NOT_ENABLED","SMART_ACCOUNT_NOT_DEPLOYED","ACCOUNT_DELETION_PENDING","SWAP_TO_ONRAMP","USER_REJECTED"]),new Set(Object.values(Yt));class Xt extends MessageEvent{}class Bt{get events$(){return this._events$}get messages$(){return this._messages$}get isOpen(){return!!this.closeListener}constructor(e,t){this.name=e,this.allowedMessageTypes=t,this.closeListener=null}static _getName(e,t){return`${e} Service: ${t} Channel`}async _open(e){var t,s;await this.close(),this.eventSubject=new bt,this._events$=this.eventSubject.asObservable(),this._messages$=this.eventSubject.pipe((t=e=>e.data,Rt((function(e,n){var i=0;e.subscribe(St(n,(function(e){n.next(t.call(s,e,i++))})))})))),this._events$.subscribe((e=>{const t=e instanceof Xt?"sent":"received";Le.debug(`[${this.name}] Message ${t}:`,JSON.stringify(e.data,Dt))}));const n=async e=>{(!this.targetOrigin||e.origin===this.targetOrigin)&&e.data&&e.data instanceof Object&&this.isMessageAllowed(e.data)&&(await this.onBeforeEvent(e),this.eventSubject.next(e))};e instanceof MessagePort?(this.messagePort=e,e.onmessage=n,this.closeListener=async()=>{this.messagePort?.close(),this.messagePort=void 0}):e instanceof BroadcastChannel?(this.messageChannel=e,e.onmessage=n,this.closeListener=async()=>{this.messageChannel?.close(),this.messageChannel=void 0}):(this.targetWindow=e.window,this.targetOrigin=e.origin,window.addEventListener("message",n),this.closeListener=async()=>{window.removeEventListener("message",n)})}isMessageAllowed(e){return this.allowedMessageTypes.includes(e.type)}async onBeforeEvent(e){}async close(){this.closeListener&&(await this.closeListener(),this.closeListener=null),this.eventSubject&&!this.eventSubject.closed&&this.eventSubject.complete()}createErrorResponseMessage(e,t){return{type:e,payload:{success:!1,errorName:t instanceof jt?t.name:"UNKNOWN_ERROR",errorMessage:t.message}}}async sendMessage(e,t){const s=this.deepClone(e);if(this.messagePort)this.messagePort.postMessage(s);else if(this.messageChannel)this.messageChannel.postMessage(s);else{if(!this.targetWindow||!this.targetOrigin)return void Le.debug(`[${this.name}] Not opened yet`);this.targetWindow.postMessage(s,this.targetOrigin,t)}this.eventSubject.next(new Xt("message",{data:s,origin:window.origin}))}deepClone(e){try{return JSON.parse(JSON.stringify(e,Dt))}catch(t){return Le.warn("Error generating cloneable message",t),e}}}var Zt,Qt,Jt;!function(e){e.REQUEST="JRPC_REQUEST",e.RESPONSE="JRPC_RESPONSE",e.EVENT="JRPC_EVENT"}(Zt||(Zt={}));const es=[Zt.RESPONSE,Zt.EVENT];class ts extends Bt{static create(){return a(this,Qt,"f",Jt)||o(this,Qt,new Qt("Embed Service: Provider Channel",es),"f",Jt),a(this,Qt,"f",Jt)}async open(e){const t=new URL(e.src).origin,s=e.contentWindow;await super._open({window:s,origin:t})}async sendWalletProviderRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===Zt.RESPONSE)),Ct((t=>t.payload.method===e.method&&t.payload.requestId===e.requestId))));return await this.sendMessage({type:Zt.REQUEST,payload:e}),t}}var ss,ns,is,rs,as,os,cs,ls,hs,ds,us,ps;Qt=ts,Jt={value:void 0};class fs{constructor({ensureWallet:e,isWalletInitialized:t,getLoginResult:s}){ss.add(this),ns.set(this,void 0),is.set(this,void 0),rs.set(this,void 0),as.set(this,void 0),os.set(this,void 0),cs.set(this,null),this.startEventMessageListening=async e=>{await a(this,ns,"f").open(e),a(this,ns,"f").messages$.pipe(Ct((e=>e.type===Zt.EVENT))).subscribe((e=>{if("chainChanged"===e.payload.event){const t=a(this,ss,"m",ds).call(this,e.payload.data);null!==t&&o(this,cs,t,"f")}a(this,ss,"m",ls).call(this,e.payload.event,e.payload.data)}))},o(this,ns,ts.create(),"f"),o(this,as,e,"f"),o(this,os,{connect:[],disconnect:[],accountsChanged:[],chainChanged:[],message:[]},"f"),o(this,is,t,"f"),o(this,rs,s,"f")}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Qe("Invalid request");const{method:t,params:s}=e;if("string"!=typeof t||0===t.length)throw new Je("Invalid method");if(void 0!==s&&!Array.isArray(s)&&("object"!=typeof s||null===s))throw new et("Invalid params");const n=a(this,rs,"f").call(this);if(!n)throw new ze("User is not logged in");if(("eth_accounts"===t||"eth_requestAccounts"===t)&&!a(this,is,"f").call(this)){const e=a(this,ss,"m",hs).call(this,n);if(e)return[e]}const i=["eth_chainId"];try{i.includes(t)?await a(this,as,"f").call(this,{skipWalletLogin:!0}):await a(this,as,"f").call(this)}catch(e){throw st(e)}const r=Fe(),c=await a(this,ns,"f").sendWalletProviderRequest({requestId:r,...e});if(!c.success)throw st(c.payload);if("eth_chainId"===t){const e=a(this,ss,"m",ds).call(this,c.payload.response);null!==e&&o(this,cs,e,"f")}return c.payload.response}on(e,t){a(this,os,"f")[e]=a(this,os,"f")[e]||[],a(this,os,"f")[e].push(t)}removeListener(e,t){a(this,os,"f")[e]=a(this,os,"f")[e]||[];const s=a(this,os,"f")[e].indexOf(t);s>=0&&a(this,os,"f")[e].splice(s,1)}removeAllListeners(){o(this,os,{connect:[],disconnect:[],accountsChanged:[],chainChanged:[],message:[]},"f")}}ns=new WeakMap,is=new WeakMap,rs=new WeakMap,as=new WeakMap,os=new WeakMap,cs=new WeakMap,ss=new WeakSet,ls=function(e,...t){(a(this,os,"f")[e]||[]).forEach((e=>{try{return e(...t)}catch(e){Le.warn(e)}}))},hs=function(e){const t=a(this,cs,"f");if(e.abstractAccountAddresses&&null!==t){const s=String(t),n=e.abstractAccountAddresses.find((e=>e.chainIds.includes(s)));if(n)return n.address}return e.abstractAccountAddress},ds=function(e){if("number"==typeof e)return Number.isFinite(e)?e:null;if("bigint"==typeof e)return Number(e);if("string"!=typeof e||!e)return null;const t=e.startsWith("0x")?parseInt(e,16):parseInt(e,10);return Number.isNaN(t)?null:t};const _s=[d,p,g,I,A,L,_,y,N,b,E,C,D];class ws extends Bt{static create(){return a(this,us,"f",ps)||o(this,us,new us("Embed Service: Auth Channel",_s),"f",ps),a(this,us,"f",ps)}async open(e){const t=new URL(e.src).origin,s=e.contentWindow;await super._open({window:s,origin:t})}async sendPartnerUserInfoRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===y))));return await this.sendMessage({type:w,payload:{allowCache:!1}}),e}async sendUpdateSessionConfigRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===_))));return await this.sendMessage({type:f,payload:e}),t}async sendLoginRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===p))));return await this.sendMessage({type:u,payload:e}),t}onLoggedIn(){return Mt(this.messages$.pipe(Ct((e=>e.type===p&&!0===e.payload?.success))))}async logout(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===L))));return await this.sendMessage({type:O}),e}async sendInitializationRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===d))));return await this.sendMessage({type:h,payload:e}),t}async sendSetupWalletSuccessResponse(){await this.sendMessage({type:m,payload:{success:!0}})}async sendSetupWalletErrorResponse(e){await this.sendMessage(this.createErrorResponseMessage(m,e))}async sendSetupRecoverySuccessResponse(){await this.sendMessage({type:v,payload:{success:!0}})}async sendSetupRecoveryErrorResponse(e){await this.sendMessage({type:v,payload:{success:!1,errorName:e instanceof jt?e.name:"UNKNOWN_ERROR",errorMessage:e.message}})}async sendSetupCredentialSuccessResponse(){await this.sendMessage({type:R,payload:{success:!0}})}async sendSetupCredentialErrorResponse(e){await this.sendMessage(this.createErrorResponseMessage(R,e))}async sendCrossPartnerTokenRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===N))));return await this.sendMessage({type:S,payload:{targetPartnerUrl:e}}),t}async sendPartnerAccessTokenRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===b))));return await this.sendMessage({type:T}),e}async sendAccountRecoveryRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===C))));return await this.sendMessage({type:M,payload:e}),t}}var ys,Es;us=ws,ps={value:void 0};const gs=[W,k,x,$,H,G];class ms extends Bt{static create(){return a(this,ys,"f",Es)||o(this,ys,new ys("Embed Service: Credential Channel",gs),"f",Es),a(this,ys,"f",Es)}async open(e){await this._open({window:e.contentWindow,origin:new URL(e.src).origin})}async sendInitializationRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===W))));return await this.sendMessage({type:P,payload:e}),t}async sendUpdateSessionConfigRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===x))));return await this.sendMessage({type:q,payload:e}),t}async logout(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===$))));return await this.sendMessage({type:K}),e}async sendIssueCredentialRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===H))));return await this.sendMessage({type:F,payload:e}),t}async sendVerifyCredentialRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===G))));return await this.sendMessage({type:V,payload:e}),t}async close(){await super.close()}}ys=ms,Es={value:void 0};class Is{getZIndex(){for(let e=0;e<Pe.length;e++)if(this.iframeId.includes(Pe[e]))return Is.HIGHEST_Z_INDEX-e;return Is.HIGHEST_Z_INDEX-Pe.length}constructor(e,t,s){this._iframeElement=null,this.state={...Is.DEFAULT_STATE,...s},this.iframeUrl=t,this.iframeId=`${e}-${Fe()}`}get iframeElement(){return this._iframeElement}createIframe(){if(this._iframeElement)return this._iframeElement;const e=document.createElement("iframe");return e.id=this.iframeId,e.allow=["publickey-credentials-get *","publickey-credentials-create *","ch-ua-model","ch-ua-platform-version","clipboard-write","web-share"].join("; "),e.src=this.iframeUrl,e.style.position="fixed",e.style.zIndex=`${this.getZIndex()}`,e.style.border="none",e.style.margin="0",e.style.padding="0",e.style.display="none",e.style.colorScheme="auto",e.setAttribute("sandbox",["allow-scripts","allow-same-origin","allow-storage-access-by-user-activation","allow-modals","allow-popups","allow-popups-to-escape-sandbox","allow-forms","allow-downloads","allow-top-navigation-by-user-activation"].join(" ")),document.body.appendChild(e),this._iframeElement=e,e}setIframeVisibility(e){this.state.isVisible=e}updateIframeState(){if(!this.iframeElement)return;const e={};e.display=this.state.isVisible?"block":"none",e.width="100%",e.height="100%",e.top="0px",e.right="0px",e.left="0px",e.bottom="0px",Object.assign(this.iframeElement.style,e)}destroy(){this.iframeElement&&(this.iframeElement.remove(),this._iframeElement=null)}postMessage(e){if(!this.iframeElement)return;const{origin:t}=new URL(this.iframeElement.src);this.iframeElement.contentWindow.postMessage(e,t)}}var vs,As;Is.DEFAULT_STATE={isVisible:!1},Is.HIGHEST_Z_INDEX=2147483647;const Rs=Object.values(z);class Ss extends Bt{static create(){return a(this,vs,"f",As)||o(this,vs,new vs("Recovery Service",Rs),"f",As),a(this,vs,"f",As)}async sendInitializationRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===z.INITIALIZATION_RESPONSE))));return await this.sendMessage({type:z.INITIALIZATION_REQUEST,payload:e}),t}async onInitialized(){return Mt(this.messages$.pipe(Ct((e=>e.type===z.RECOVERY_INITIALIZED))))}async sendUpdateSessionConfigRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===z.UPDATE_SESSION_CONFIG_RESPONSE))));return await this.sendMessage({type:z.UPDATE_SESSION_CONFIG_REQUEST,payload:e}),t}async logout(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===z.LOGOUT_RESPONSE))));return await this.sendMessage({type:z.LOGOUT_REQUEST}),e}async sendGetAgentKeysRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===z.GET_AGENT_KEYS_RESPONSE))));return await this.sendMessage({type:z.GET_AGENT_KEYS_REQUEST}),e}async sendRegisterAgentKeyRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===z.REGISTER_AGENT_KEY_RESPONSE))));return await this.sendMessage({type:z.REGISTER_AGENT_KEY_REQUEST,payload:e}),t}async sendRemoveAgentKeyRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===z.REMOVE_AGENT_KEY_RESPONSE))));return await this.sendMessage({type:z.REMOVE_AGENT_KEY_REQUEST,payload:e}),t}async open(e){await this._open({window:e.contentWindow,origin:new URL(e.src).origin})}async close(){await super.close()}}var Ns,Ts;vs=Ss,As={value:void 0};const bs=[X,B,Q,ee,se,ae,ce,he,ue,ie,ye,fe,_e,ge,me,Ae];class Os extends Bt{static create(){return a(this,Ns,"f",Ts)||o(this,Ns,new Ns("Embed Service: Wallet Channel",bs),"f",Ts),a(this,Ns,"f",Ts)}async open(e){const t=new URL(e.src).origin,s=e.contentWindow;await super._open({window:s,origin:t})}async sendDeploySmartAccountRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===fe))));return await this.sendMessage({type:pe}),e}async sendIsSmartAccountDeployedRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===ye))));return await this.sendMessage({type:we}),e}async logout(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===ge))));return await this.sendMessage({type:Ee}),e}async sendInitializationRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===X))));return await this.sendMessage({type:j,payload:e}),t}onInitialized(){return Mt(this.messages$.pipe(Ct((e=>e.type===B))))}async sendUpdateSessionConfigRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===Q))));return await this.sendMessage({type:Z,payload:e}),t}async sendLoginRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===ee))));return await this.sendMessage({type:J}),e}async sendSetupMfaRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===se))));return await this.sendMessage({type:te}),e}async sendOpenWindowSuccessResponse(e,t){await this.sendMessage({type:Ie,payload:{success:!0,windowId:e}},[t])}async sendOpenWindowErrorResponse(e,t){const s=this.createErrorResponseMessage(Ie,t);await this.sendMessage({...s,payload:{...s.payload,windowId:e}})}async sendOpenWindowRetryRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===Ae)),Ct((t=>t.payload.windowId===e))));return await this.sendMessage({type:ve,payload:{windowId:e}}),t}async sendWindowClosed(e){await this.sendMessage({type:Re,payload:{windowId:e}})}async sendClaimIdRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===ie))));return await this.sendMessage({type:ne,payload:e}),t}async sendShowSwapUIRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===ae))));return await this.sendMessage({type:re,payload:{initialFromToken:e?.initialFromToken,fallbackFromToken:e?.fallbackFromToken,initialToToken:e?.initialToToken,defaultSlippage:e?.defaultSlippage?.toString()}}),t}async sendShowOnRampUIRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===ce))));return await this.sendMessage({type:oe,payload:e}),t}async sendShowTransferUIRequest(e){const t=Mt(this.messages$.pipe(Ct((e=>e.type===he))));return await this.sendMessage({type:le,payload:{tokenSymbol:e?.tokenSymbol,chainId:e?.chainId,recipientAddress:e?.recipientAddress,amount:e?.amount}}),t}async sendShowReceiveUIRequest(){const e=Mt(this.messages$.pipe(Ct((e=>e.type===ue))));return await this.sendMessage({type:de}),e}}Ns=Os,Ts={value:void 0};class Ls{get messages$(){return this._messages$.asObservable()}constructor(e,t){this._windowInstance=null,this._messageHandler=null,this._messages$=new bt,this.windowId=e,this.windowUrl=t,this.windowOrigin=new URL(t).origin,this._messageHandler=e=>{e.source===this._windowInstance&&e.origin===this.windowOrigin&&e.data&&e.data instanceof Object&&this._messages$.next(e)},window.addEventListener("message",this._messageHandler)}get windowInstance(){return this._windowInstance}async openWindow(e){let t=this.tryOpenWindow();if(!t&&(await e(),t=this.tryOpenWindow(),!t))throw new jt(zt.WINDOW_BLOCKED);const s=new Promise(((s,n)=>{setTimeout((()=>{this.isWindowOpen(t)?(this.scheduleWindowClosedChecks(t),s("opened")):e().then((()=>{t=this.tryOpenWindow(),t?(this._windowInstance=t,t.focus(),this.scheduleWindowClosedChecks(t),s("retry")):n(new jt(zt.WINDOW_BLOCKED))})).catch(n)}),1e3)}));return this._windowInstance=t,t.focus(),{pendingWindowOpenCheck:s}}postMessage(e,t){this._windowInstance&&this._windowInstance.postMessage(e,this.windowOrigin,t)}onMessage(e){const t=t=>{t.source===this._windowInstance&&t.origin===this.windowOrigin&&e(t)};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return this.onClose(s),{close:s}}cleanup(){this._windowInstance&&!this._windowInstance.closed&&this._windowInstance.close(),this._windowInstance=null,this._messageHandler&&(window.removeEventListener("message",this._messageHandler),this._messageHandler=null),this._messages$&&!this._messages$.closed&&this._messages$.complete()}onClose(e){return this._messages$.subscribe({complete:e})}isWindowOpen(e){return!(!e||e.closed||void 0===e.closed)}tryOpenWindow(){const e=window.open(this.windowUrl,this.windowId,((e,t)=>{const s=void 0!==window.screenLeft?window.screenLeft:window.screenX,n=void 0!==window.screenTop?window.screenTop:window.screenY,i=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,r=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height,a=.95*Math.min(i,e),o=.95*Math.min(r,t),c=Math.abs((i-a)/2/1+s);return`titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=${o/1},width=${a/1},top=${Math.abs((r-o)/2/1+n)},left=${c}`})(425,680));return this.isWindowOpen(e)?e:null}scheduleWindowClosedChecks(e){const t=setInterval((()=>{e&&!e.closed||(clearInterval(t),e===this._windowInstance&&this.cleanup())}),500)}}var Ms,Cs,Ds,Us,Ps,Ws,ks,qs,xs,Ks,$s,Fs,Vs,Hs,Gs,zs,Ys,js,Xs,Bs,Zs,Qs,Js,en,tn,sn,nn,rn,an,on,cn,ln,hn,dn,un,pn,fn,_n,wn,yn,En,gn,mn,In,vn,An=class{constructor(){this.windowControllers=new Map}static get instance(){return this._instance||(this._instance=new this)}async sendWindowInitializationRequest(e,t,s){const n=this.windowControllers.get(e);if(!n)throw new Error("Window controller not found");if(!n.windowInstance)throw new Error("Window instance not found");const i=Mt(n.messages$.pipe(Ct((e=>e.data.type===X))));return n.postMessage({type:j,payload:t},[s]),(await i).data}async openAndInitializeWalletServiceWindow({url:e,windowId:t,sessionId:s,partnerId:n,enableLogging:i,onRetry:r,sdkVersion:a,enableAutomation:o}){if(this.windowControllers.has(t))throw new Error("Window controller already exists");const c=new Ls(t,e),{pendingWindowOpenCheck:l}=await c.openWindow(r);c.onClose((()=>{this.removeWindowController(t)})),this.windowControllers.set(t,c);let h=null;const d=()=>new Promise(((e,r)=>{c.onMessage((async c=>{if(c.data===Y)try{h=new MessageChannel;const{payload:c}=await this.sendWindowInitializationRequest(t,{sessionId:s,partnerId:n,enableLogging:i,sdkVersion:a,enableAutomation:o},h.port1);!1===c.success?r(new Ve(c.errorName,c.errorMessage)):e()}catch(e){r(e)}}))})),u=d();return"retry"===await l?await d():await u,{windowController:c,port:h.port2}}getWindowController(e){return this.windowControllers.get(e)}removeWindowController(e){this.windowControllers.delete(e)}}.instance;const Rn=c;Cs=new WeakMap,Ds=new WeakMap,Us=new WeakMap,Ps=new WeakMap,Ws=new WeakMap,ks=new WeakMap,qs=new WeakMap,xs=new WeakMap,Ks=new WeakMap,$s=new WeakMap,Fs=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,Gs=new WeakMap,zs=new WeakMap,Ys=new WeakMap,js=new WeakMap,Xs=new WeakMap,Bs=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,Js=new WeakMap,Ms=new WeakSet,en=function(){if(!a(this,Ks,"f"))throw new Ve("NOT_INITIALIZED","Service is not initialized")},tn=function(){if(a(this,Ms,"m",en).call(this),!this.isLoggedIn)throw new Ve("NOT_LOGGED_IN","User not logged in")},sn=async function(){a(this,Ms,"m",en).call(this),a(this,Ms,"m",on).call(this,{skipWalletLogin:!0});try{a(this,Bs,"f")||o(this,Bs,a(this,Ms,"m",nn).call(this),"f"),await a(this,Bs,"f")}catch(e){throw o(this,Bs,null,"f"),Le.error("Error ensuring credentials",e),Ve.from(e)}},nn=async function(){if(a(this,Bs,"f"))throw new Ve("ALREADY_INITIALIZING","Already initializing credentials");const{credentialUrl:e}=xe(a(this,Ds,"f"),a(this,Js,"f")),t=new URL(e).origin;let s=!1;try{const n=new Promise(((e,n)=>{const i=async r=>{if(r.origin===t&&r.data===U){window.removeEventListener("message",i);const{payload:t}=await a(this,Zs,"f").sendInitializationRequest({sessionId:a(this,Ws,"f"),partnerId:a(this,Ps,"f"),enableLogging:a(this,Us,"f"),sdkVersion:Rn,partnerDAppUrl:window.location.href,enableAutomation:this.shouldEnableAutomation(),sessionConfig:a(this,ks,"f"),...a(this,Js,"f")&&{credentialNetwork:a(this,Js,"f")}});!0===t.success?e():(s=!!t.closeDApp,n(new Ve(t.errorName,t.errorMessage)))}};window.addEventListener("message",i)}));o(this,Qs,new Is("air-credential",e),"f"),a(this,Qs,"f").createIframe(),Le.info(e,"url loaded"),await a(this,Zs,"f").open(a(this,Qs,"f").iframeElement),a(this,Ms,"m",rn).call(this),await n,await a(this,Ms,"m",on).call(this,{skipWalletLogin:!0}),a(this,Ms,"m",on).call(this),Le.info("Credential service initialized successfully")}catch(e){throw Le.error("Error initializing credentials",e),await a(this,Ms,"m",an).call(this),s&&window.close(),Ve.from(e)}},rn=function(){a(this,Zs,"f").messages$.subscribe((async e=>{if(e.type===k)a(this,Qs,"f").setIframeVisibility(e.payload.visible),a(this,Qs,"f").updateIframeState()}))},an=async function(){if(!a(this,Ks,"f"))return;const e=a(this,Qs,"f")?.iframeElement;$e(e)&&window.document.body.contains(e)&&(await a(this,Zs,"f").logout(),a(this,Qs,"f").destroy(),o(this,Qs,void 0,"f")),await a(this,Zs,"f").close(),o(this,Bs,void 0,"f")},on=async function(e){if(a(this,Ms,"m",en).call(this),a(this,Hs,"f")||o(this,Hs,a(this,Ms,"m",cn).call(this,e),"f"),a(this,Gs,"f"))return a(this,Gs,"f");try{const t=await a(this,Hs,"f");if(e?.skipWalletLogin||t.isWalletLoggedIn)return a(this,Ms,"m",wn).call(this,t)}catch(e){throw o(this,Hs,null,"f"),Le.error("Error initializing wallet",e),Ve.from(e)}if(a(this,Gs,"f"))return a(this,Gs,"f");const t=await a(this,Fs,"f").sendLoginRequest();if(!0!==t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage);return a(this,Ms,"m",wn).call(this,t.payload)},cn=async function(e){if(a(this,Hs,"f"))throw new Ve("ALREADY_INITIALIZING","Already initializing");const{walletUrl:t}=xe(a(this,Ds,"f"),a(this,Js,"f")),s=new URL(t).origin;try{const n=new Promise(((e,t)=>{const n=async i=>{if(i.origin===s&&i.data===Y){window.removeEventListener("message",n);const{payload:s}=await a(this,Fs,"f").sendInitializationRequest({sessionId:a(this,Ws,"f"),partnerId:a(this,Ps,"f"),partnerDAppUrl:window.location.href,enableLogging:a(this,Us,"f"),sdkVersion:Rn,enableAutomation:this.shouldEnableAutomation(),sessionConfig:a(this,ks,"f")});!0===s.success?e():t(new Ve(s.errorName,s.errorMessage))}};window.addEventListener("message",n)}));o(this,Vs,new Is("air-wallet",t),"f"),a(this,Vs,"f").createIframe(),Le.info(t,"url loaded"),await a(this,Fs,"f").open(a(this,Vs,"f").iframeElement),a(this,Ms,"m",ln).call(this),await a(this,zs,"f").startEventMessageListening(a(this,Vs,"f").iframeElement);const i=a(this,Fs,"f").onInitialized();await n,this.isLoggedIn||e?.skipWalletLogin||await a(this,qs,"f").onLoggedIn();const r=await i;if(!0!==r.payload.success)throw new Ve(r.payload.errorName,r.payload.errorMessage);return!a(this,Gs,"f")&&r.payload.isWalletLoggedIn&&(o(this,Gs,a(this,Ms,"m",wn).call(this,r.payload),"f"),a(this,Ms,"m",fn).call(this,a(this,Gs,"f"))),r.payload}catch(e){throw Le.error("Error initializing wallet",e),await a(this,Ms,"m",En).call(this),Ve.from(e)}},ln=function(){a(this,Fs,"f").messages$.subscribe((async e=>{switch(e.type){case _e:{const t=a(this,Vs,"f");t.setIframeVisibility(e.payload.visible),t.updateIframeState();break}case ee:!0!==e.payload.success||a(this,Gs,"f")||(o(this,Gs,a(this,Ms,"m",wn).call(this,e.payload),"f"),a(this,Ms,"m",fn).call(this,a(this,Gs,"f")));break;case me:try{const t=async()=>{const{payload:t}=await a(this,Fs,"f").sendOpenWindowRetryRequest(e.payload.windowId);if(!1===t.success)throw new Ve(t.errorName,t.errorMessage)},{windowController:s,port:n}=await An.openAndInitializeWalletServiceWindow({url:e.payload.url,windowId:e.payload.windowId,sessionId:a(this,Ws,"f"),partnerId:a(this,Ps,"f"),enableLogging:a(this,Us,"f"),sdkVersion:Rn,enableAutomation:this.shouldEnableAutomation(),onRetry:t});s.onClose((async()=>await a(this,Fs,"f").sendWindowClosed(e.payload.windowId))),await a(this,Fs,"f").sendOpenWindowSuccessResponse(e.payload.windowId,n)}catch(t){const s=Ce(t);await a(this,Fs,"f").sendOpenWindowErrorResponse(e.payload.windowId,s)}}}))},hn=function(e){a(this,$s,"f").forEach((t=>{t(e)}))},dn=function(e){a(this,Ms,"m",hn).call(this,{event:"initialized",result:e})},un=function(){a(this,Ms,"m",hn).call(this,{event:"logged_in",result:a(this,Cs,"f")})},pn=function(){a(this,Ms,"m",hn).call(this,{event:"logged_out"})},fn=function(e){a(this,Ms,"m",hn).call(this,{event:"wallet_initialized",result:e})},_n=function(e){return{isLoggedIn:!0,id:e.id,abstractAccountAddress:e.abstractAccountAddress,abstractAccountAddresses:e.abstractAccountAddresses,token:e.partnerAccessToken,isMFASetup:e.activeMfaMethods.length>0}},wn=function(e){return"isWalletLoggedIn"in e&&!e.isWalletLoggedIn?{abstractAccountAddress:null,isMFASetup:a(this,Cs,"f")?.isMFASetup??!1}:{abstractAccountAddress:e.addresses.aa,isMFASetup:e.activeMfaMethods.length>0}},yn=async function(){await a(this,qs,"f").logout();const e=a(this,xs,"f")?.iframeElement;$e(e)&&window.document.body.contains(e)&&(a(this,xs,"f").destroy(),o(this,xs,void 0,"f")),await a(this,qs,"f").close(),o(this,Ks,!1,"f")},En=async function(){if(!a(this,Ks,"f"))return;const e=a(this,Vs,"f")?.iframeElement;$e(e)&&window.document.body.contains(e)&&(await a(this,Fs,"f").logout(),a(this,Vs,"f").destroy(),o(this,Vs,void 0,"f")),await a(this,Fs,"f").close(),o(this,Gs,void 0,"f"),o(this,Hs,void 0,"f")},gn=async function(){a(this,Ms,"m",en).call(this),a(this,Ys,"f")||o(this,Ys,a(this,Ms,"m",mn).call(this),"f");try{await a(this,Ys,"f")}catch(e){throw o(this,Ys,null,"f"),Le.error("Error initializing recovery",e),Ve.from(e)}},mn=async function(){if(a(this,Ys,"f"))throw new Ve("ALREADY_INITIALIZING","Already initializing");const{recoveryUrl:e}=xe(a(this,Ds,"f"),a(this,Js,"f")),t=new URL(e).origin;try{const s=new Promise(((e,s)=>{const n=async i=>{if(i.origin===t&&i.data===z.SERVICE_STARTED){window.removeEventListener("message",n);const{payload:t}=await a(this,js,"f").sendInitializationRequest({sessionId:a(this,Ws,"f"),partnerId:a(this,Ps,"f"),partnerDAppUrl:window.location.href,enableLogging:a(this,Us,"f"),sdkVersion:Rn,enableAutomation:this.shouldEnableAutomation(),sessionConfig:a(this,ks,"f")});!0===t.success?e():s(new Ve(t.errorName,t.errorMessage))}};window.addEventListener("message",n)}));o(this,Xs,new Is("air-recovery",e),"f"),a(this,Xs,"f").createIframe(),Le.info(e,"url loaded"),await a(this,js,"f").open(a(this,Xs,"f").iframeElement),a(this,Ms,"m",In).call(this);const n=a(this,js,"f").onInitialized();await s,await n}catch(e){throw Le.error("Error initializing recovery",e),await a(this,Ms,"m",vn).call(this),Ve.from(e)}},In=function(){a(this,js,"f").messages$.subscribe((async e=>{switch(e.type){case z.RECOVERY_IFRAME_VISIBILITY_REQUEST:{const t=a(this,Xs,"f");t.setIframeVisibility(e.payload.visible),t.updateIframeState();break}}}))},vn=async function(){if(!a(this,Ks,"f"))return;const e=a(this,Xs,"f")?.iframeElement;$e(e)&&window.document.body.contains(e)&&(await a(this,js,"f").logout(),a(this,Xs,"f").destroy(),o(this,Xs,void 0,"f")),await a(this,js,"f").close(),o(this,Ys,void 0,"f")},e.AirService=class{constructor({partnerId:e}){Ms.add(this),Cs.set(this,void 0),Ds.set(this,void 0),Us.set(this,!1),Ps.set(this,void 0),Ws.set(this,void 0),ks.set(this,void 0),qs.set(this,void 0),xs.set(this,void 0),Ks.set(this,!1),$s.set(this,[]),Fs.set(this,void 0),Vs.set(this,void 0),Hs.set(this,void 0),Gs.set(this,void 0),zs.set(this,void 0),Ys.set(this,void 0),js.set(this,void 0),Xs.set(this,void 0),Bs.set(this,void 0),Zs.set(this,void 0),Qs.set(this,void 0),Js.set(this,void 0),o(this,Ps,e,"f"),o(this,qs,ws.create(),"f"),o(this,Fs,Os.create(),"f"),o(this,js,Ss.create(),"f"),o(this,Zs,ms.create(),"f"),o(this,zs,new fs({isWalletInitialized:()=>this.isWalletInitialized,ensureWallet:a(this,Ms,"m",on).bind(this),getLoginResult:()=>a(this,Cs,"f")}),"f"),We.forEach((e=>Ke(e,{prefetch:!1})))}get buildEnv(){return a(this,Ds,"f")}get isInitialized(){return a(this,Ks,"f")}get isLoggedIn(){return!!a(this,Cs,"f")}get loginResult(){return a(this,Cs,"f")}get isWalletInitialized(){return!!a(this,Gs,"f")}get provider(){const e=a(this,zs,"f");return{request:e.request.bind(e),on:e.on.bind(e),removeListener:e.removeListener.bind(e)}}shouldEnableAutomation(){return"true"===localStorage.getItem("automation")&&a(this,Ds,"f")!==Ue.PRODUCTION}async init(e){const{buildEnv:t=Ue.PRODUCTION,enableLogging:s=!1,skipRehydration:n=!1,sessionConfig:i,preloadWallet:r=!1,preloadCredential:c=!1,credentialNetwork:h="devnet"}=e;if(!a(this,Ps,"f"))throw new Ve("CLIENT_ERROR","Partner ID is required to initialize the service");if(a(this,Ks,"f"))return a(this,Cs,"f")??null;o(this,Js,t===Ue.SANDBOX?h:void 0,"f"),De(t,s);const{authUrl:d,walletUrl:u,credentialUrl:p}=xe(t,a(this,Js,"f"));Ke(d),r&&Ke(u),c&&Ke(p),o(this,Ds,t,"f"),o(this,Us,s,"f"),o(this,ks,i,"f"),o(this,Ws,Fe(),"f");const f=new URL(d).origin;o(this,xs,new Is("air-auth",d),"f");try{a(this,xs,"f").createIframe(),Le.info(d,"url loaded"),await a(this,qs,"f").open(a(this,xs,"f").iframeElement),a(this,qs,"f").messages$.subscribe((async e=>{switch(e.type){case E:{const t=a(this,xs,"f");t.setIframeVisibility(e.payload.visible),t.updateIframeState();break}case g:try{await a(this,Ms,"m",on).call(this,{skipWalletLogin:!0}),await a(this,qs,"f").sendSetupWalletSuccessResponse()}catch(e){const t=Ce(e);await a(this,qs,"f").sendSetupWalletErrorResponse(t)}break;case I:try{await a(this,Ms,"m",gn).call(this),await a(this,qs,"f").sendSetupRecoverySuccessResponse()}catch(e){const t=Ce(e);await a(this,qs,"f").sendSetupRecoveryErrorResponse(t)}break;case A:try{await a(this,Ms,"m",sn).call(this),await a(this,qs,"f").sendSetupCredentialSuccessResponse()}catch(e){const t=Ce(e);await a(this,qs,"f").sendSetupCredentialErrorResponse(t)}break;case D:await this.logout()}}));const e=await new Promise(((e,t)=>{const s=async r=>{if(r.origin===f&&r.data===l){window.removeEventListener("message",s);const{payload:r}=await a(this,qs,"f").sendInitializationRequest({sessionId:a(this,Ws,"f"),partnerId:a(this,Ps,"f"),skipRehydration:n,partnerDAppUrl:window.location.href,sdkVersion:Rn,enableLogging:a(this,Us,"f"),enableAutomation:this.shouldEnableAutomation(),sessionConfig:i});!0===r.success?e(r):t(new Ve(r.errorName,r.errorMessage))}};window.addEventListener("message",s)}));if(o(this,Ks,!0,"f"),a(this,Ms,"m",dn).call(this,{rehydrated:e.rehydrated}),(e.preloadWallet||r)&&this.preloadWallet(),c&&this.preloadCredential(),e.rehydrated)return o(this,Cs,a(this,Ms,"m",_n).call(this,e),"f"),a(this,Ms,"m",un).call(this),a(this,Cs,"f")}catch(e){throw Le.debug("Error initializing auth service",e),await this.cleanUp(),Ve.from(e)}return null}async login(e){if(a(this,Ms,"m",en).call(this),a(this,Cs,"f"))return a(this,Cs,"f");const{payload:t}=await a(this,qs,"f").sendLoginRequest({partnerLoginToken:e?.authToken});if(!0===t.success)return o(this,Cs,a(this,Ms,"m",_n).call(this,t),"f"),a(this,Ms,"m",un).call(this),a(this,Cs,"f");throw new Ve(t.errorName,t.errorMessage)}async deploySmartAccount(){await a(this,Ms,"m",on).call(this),Le.info("deploySmartAccount");const{payload:e}=await a(this,Fs,"f").sendDeploySmartAccountRequest();if(!1===e.success)throw new Ve(e.errorName,e.errorMessage);return{txHash:e.txHash}}async isSmartAccountDeployed(){await a(this,Ms,"m",on).call(this);const{payload:e}=await a(this,Fs,"f").sendIsSmartAccountDeployedRequest();if(!1===e.success)throw new Ve(e.errorName,e.errorMessage);return e.isDeployed}getProvider(){return this.provider}async preloadWallet(){await a(this,Ms,"m",on).call(this,{skipWalletLogin:!0})}async setupOrUpdateMfa(){await a(this,Ms,"m",on).call(this,{skipWalletLogin:!0});const e=await a(this,Fs,"f").sendSetupMfaRequest();if(!1===e.payload.success)throw new Ve(e.payload.errorName,e.payload.errorMessage);o(this,Cs,{...a(this,Cs,"f"),isMFASetup:!0},"f")}async claimAirId(e){await a(this,Ms,"m",on).call(this);const t=await a(this,Fs,"f").sendClaimIdRequest(e??{});if(!0===t.payload.success)return{airId:t.payload.airId};throw new Ve(t.payload.errorName,t.payload.errorMessage)}async showSwapUI(e){await a(this,Ms,"m",on).call(this);const t=await a(this,Fs,"f").sendShowSwapUIRequest(e);if(!1===t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage);return t.payload}async showOnRampUI(e){await a(this,Ms,"m",on).call(this);const t=await a(this,Fs,"f").sendShowOnRampUIRequest(e);if(!1===t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage)}async showTransferUI(e){await a(this,Ms,"m",on).call(this);const t=await a(this,Fs,"f").sendShowTransferUIRequest(e);if(!1===t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage);return{txHash:t.payload.txHash,symbol:t.payload.symbol,chainId:t.payload.chainId,decimals:t.payload.decimals,address:t.payload.address,recipientAddress:t.payload.recipientAddress,amount:t.payload.amount}}async showReceiveUI(){await a(this,Ms,"m",on).call(this);const e=await a(this,Fs,"f").sendShowReceiveUIRequest();if(!1===e.payload.success){if("USER_CANCELLED"===e.payload.errorName)return;throw new Ve(e.payload.errorName,e.payload.errorMessage)}}async getAgentKeys(){await a(this,Ms,"m",gn).call(this);const{payload:e}=await a(this,js,"f").sendGetAgentKeysRequest();if(!1===e.success)throw new Ve(e.errorName,e.errorMessage);return e.agentKeys}async registerAgentKey(e){await a(this,Ms,"m",gn).call(this);const{payload:t}=await a(this,js,"f").sendRegisterAgentKeyRequest({publicKey:e});if(!1===t.success)throw new Ve(t.errorName,t.errorMessage);return{id:t.id,publicKey:t.publicKey,createdAt:t.createdAt}}async removeAgentKey(e){await a(this,Ms,"m",gn).call(this);const{payload:t}=await a(this,js,"f").sendRemoveAgentKeyRequest({id:e});if(!1===t.success)throw new Ve(t.errorName,t.errorMessage)}async getUserInfo(){a(this,Ms,"m",tn).call(this);const e=await a(this,qs,"f").sendPartnerUserInfoRequest();if(!1===e.payload.success)throw new Ve(e.payload.errorName,e.payload.errorMessage);return{partnerId:e.payload.partnerId,partnerUserId:e.payload.partnerUserId,airId:e.payload.airId,user:{id:e.payload.user.id,abstractAccountAddress:e.payload.user.abstractAccountAddress,email:e.payload.user.email,isMFASetup:e.payload.user.activeMfaMethods.length>0}}}async updateSessionConfig(e){a(this,Ms,"m",en).call(this),o(this,ks,e,"f");const t=[a(this,qs,"f").sendUpdateSessionConfigRequest(e)];a(this,Hs,"f")&&t.push(a(this,Hs,"f").then((()=>a(this,Fs,"f").sendUpdateSessionConfigRequest(e))).catch((()=>null))),a(this,Ys,"f")&&t.push(a(this,Ys,"f").then((()=>a(this,js,"f").sendUpdateSessionConfigRequest(e))).catch((()=>null))),a(this,Bs,"f")&&t.push(a(this,Bs,"f").then((()=>a(this,Zs,"f").sendUpdateSessionConfigRequest(e))).catch((()=>null)));const s=await Promise.all(t);for(const e of s)if(e&&!1===e.payload.success)throw new Ve(e.payload.errorName,e.payload.errorMessage);const n={locale:s[0].payload.locale,currency:s[0].payload.currency};return o(this,ks,n,"f"),n}async goToPartner(e){a(this,Ms,"m",tn).call(this);const t=await a(this,qs,"f").sendCrossPartnerTokenRequest(e);if(!1===t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage);return{urlWithToken:t.payload.urlWithToken}}async startRecovery(e){const t=await a(this,qs,"f").sendAccountRecoveryRequest(e);if(!1===t.payload.success)throw new Ve(t.payload.errorName,t.payload.errorMessage)}async getAccessToken(){a(this,Ms,"m",tn).call(this);const e=await a(this,qs,"f").sendPartnerAccessTokenRequest();if(!0!==e.payload.success)throw new Ve(e.payload.errorName,e.payload.errorMessage);if(!e.payload.partnerAccessToken)throw new Ve("UNAUTHORIZED","Partner access token not found in response");return{token:e.payload.partnerAccessToken}}async logout(){a(this,Ms,"m",tn).call(this),await a(this,Ms,"m",an).call(this),await Promise.all([a(this,Ms,"m",En).call(this),a(this,Ms,"m",vn).call(this),a(this,qs,"f").logout()]),o(this,Cs,void 0,"f"),a(this,Ms,"m",pn).call(this)}async cleanUp(){await a(this,Ms,"m",an).call(this),await a(this,Ms,"m",vn).call(this),await a(this,Ms,"m",En).call(this),await a(this,Ms,"m",yn).call(this),o(this,$s,[],"f"),o(this,Ws,void 0,"f"),o(this,Ds,void 0,"f")}on(e){a(this,$s,"f").indexOf(e)<0&&a(this,$s,"f").push(e)}off(e){a(this,$s,"f").indexOf(e)>=0&&a(this,$s,"f").splice(a(this,$s,"f").indexOf(e),1)}async preloadCredential(){await a(this,Ms,"m",sn).call(this)}async issueCredential({authToken:e,issuerDid:t,credentialId:s,credentialSubject:n,curve:i,offchain:r}){await a(this,Ms,"m",sn).call(this);const o=await a(this,Zs,"f").sendIssueCredentialRequest({partnerToken:e,issuerDid:t,credentialId:s,credentialSubject:n,curve:i,offchain:r}),{payload:c}=o;if(c.closeDApp&&window.close(),!1===c.success)throw new Ve(c.errorName,c.errorMessage);return{cakPublicKey:c.cakPublicKey}}async verifyCredential({authToken:e,programId:t,redirectUrl:s,fieldsToDisclose:n,offchain:i}){if(Array.isArray(n)&&0===n.length)throw new Ve("CLIENT_ERROR","fieldsToDisclose array must contain at least one field");await a(this,Ms,"m",sn).call(this);const{payload:r}=await a(this,Zs,"f").sendVerifyCredentialRequest({partnerToken:e,programId:t,redirectUrl:s,fieldsToDisclose:n,offchain:i});if(!1===r.success)throw new Ve(r.errorName,r.errorMessage);return r.verificationResult}},e.AirServiceError=Ve,e.BUILD_ENV=Ue,e.ChainDisconnectedError=Xe,e.IFRAME_NAME_PREFIX_SET=Pe,e.InternalRpcError=tt,e.InvalidParamsRpcError=et,e.InvalidRequestRpcError=Qe,e.MethodNotFoundRpcError=Je,e.ProviderDisconnectedError=je,e.ProviderRpcError=He,e.SwitchChainError=Be,e.TransactionRejectedRpcError=Ze,e.UnauthorizedProviderError=ze,e.UnsupportedProviderMethodError=Ye,e.UserRejectedRequestError=Ge,e.ensureProviderRpcError=st,e.mocaDevnet={id:5151,name:"Moca Devnet",nativeCurrency:{decimals:18,name:"Moca Network",symbol:"MOCA"},rpcUrls:{default:{http:["https://devnet-rpc.mocachain.org"],webSocket:["wss://devnet-rpc.mocachain.org"]}},blockExplorers:{default:{name:"Moca Devnet",url:"https://devnet-scan.mocachain.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3837540}},testnet:!0},e.mocaMainnet={id:2288,name:"Moca Mainnet",nativeCurrency:{decimals:18,name:"Moca Network",symbol:"MOCA"},rpcUrls:{default:{http:["https://rpc.mocachain.org"],webSocket:["wss://rpc.mocachain.org/ws"]}},blockExplorers:{default:{name:"Moca Mainnet",url:"https://scan.mocachain.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3668598}},testnet:!1},e.mocaTestnet={id:222888,name:"Moca Testnet",nativeCurrency:{decimals:18,name:"Moca Network",symbol:"MOCA"},rpcUrls:{default:{http:["https://rpc.testnet.mocachain.dev"],webSocket:["wss://ws.testnet.mocachain.dev"]}},blockExplorers:{default:{name:"Moca Testnet",url:"https://testnet-scan.mocachain.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:1330259}},testnet:!0}}));
//# sourceMappingURL=/sm/a48f6459bfbc5167cf034b924571709584ebd8bb2abd0952031f32ffd1ffd00b.map