@tonconnect/sdk 3.3.0-beta.1 → 3.3.0-beta.3

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.
@@ -1,2 +1,2 @@
1
- var TonConnectSDK;(()=>{var e={57:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(3842),o=n(1472),i=n(3546),s=n(488),a=n(7321),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:r.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:r.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:r.UnknownAppError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:i.ManifestNotFoundError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:o.ManifestContentErrorError};t.connectErrorsParser=new class{parseError(e){let t=s.UnknownError;return e.code in c&&(t=c[e.code]||s.UnknownError),new t(e.message)}}},139:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},488:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(8900);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},520:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.callForSuccess=function(e,t){return r(this,void 0,void 0,function*(){var n,r;const a=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,c=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,l=(0,s.createAbortController)(null==t?void 0:t.signal);if("function"!=typeof e)throw new i.TonConnectError("Expected a function, got "+typeof e);let u,d=0;for(;d<a;){if(l.signal.aborted)throw new i.TonConnectError(`Aborted after attempts ${d}`);try{return yield e({signal:l.signal})}catch(e){u=e,d++,d<a&&(yield(0,o.delay)(c))}}throw u})};const o=n(9773),i=n(3842),s=n(5148)},630:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletMissingRequiredFeaturesError=o},719:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.BadRequestError=o},734:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletAlreadyConnectedError=o},816:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.createResource=function(e,t){let n=null,a=null,c=null,l=null,u=null;const d=(i,...d)=>r(this,void 0,void 0,function*(){if(l=null!=i?i:null,null==u||u.abort(),u=(0,s.createAbortController)(i),u.signal.aborted)throw new o.TonConnectError("Resource creation was aborted");a=null!=d?d:null;const r=e(u.signal,...d);c=r;const h=yield r;if(c!==r&&h!==n)throw yield t(h),new o.TonConnectError("Resource creation was aborted by a new resource creation");return n=h,n});return{create:d,current:()=>null!=n?n:null,dispose:()=>r(this,void 0,void 0,function*(){try{const e=n;n=null;const r=c;c=null;try{null==u||u.abort()}catch(e){}yield Promise.allSettled([e?t(e):Promise.resolve(),r?t(yield r):Promise.resolve()])}catch(e){}}),recreate:e=>r(this,void 0,void 0,function*(){const t=n,r=c,s=a,u=l;if(yield(0,i.delay)(e),t===n&&r===c&&s===a&&u===l)return yield d(l,...null!=s?s:[]);throw new o.TonConnectError("Resource recreation was aborted by a new resource creation")})}};const o=n(3842),i=n(9773),s=n(5148)},1401:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WrongAddressError=o},1472:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestContentErrorError=o},1653:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=n(7321),i=n(8900),s=n(3304),a=n(8111),c=n(7714),l=n(1824),u=n(7292),d=n(2003),h=n(520),f=n(5148);class p{static fromStorage(e){return r(this,void 0,void 0,function*(){const t=new c.BridgeConnectionStorage(e),n=yield t.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new p(e,n.connectionSource):new p(e,{bridgeUrl:n.session.bridgeUrl})})}constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new c.BridgeConnectionStorage(e)}connect(e,t){var n;const i=(0,f.createAbortController)(null==t?void 0:t.signal);null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,this.closeGateways();const s=new o.SessionCrypto;this.session={sessionCrypto:s,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:s}).then(()=>r(this,void 0,void 0,function*(){i.signal.aborted||(yield(0,h.callForSuccess)(e=>{var n;return this.openGateways(s,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal}))}));const a="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(a,e)}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;const r=(0,f.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return;this.closeGateways();const o=yield this.connectionStorage.getHttpConnection();if(!o)return;if(r.signal.aborted)return;const c=null!==(n=null==e?void 0:e.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS;if((0,a.isPendingConnectionHttp)(o))return this.session={sessionCrypto:o.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(o.sessionCrypto,{openingDeadlineMS:c,signal:null==r?void 0:r.signal});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=o.session,this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,o.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!r.signal.aborted){this.listeners.forEach(e=>e(o.connectEvent));try{yield(0,h.callForSuccess)(e=>this.gateway.registerSession({openingDeadlineMS:c,signal:e.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal})}catch(e){return void(yield this.disconnect({signal:r.signal}))}}})}sendRequest(e,t){const n={};return"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal,n.attempts=null==t?void 0:t.attempts),new Promise((t,s)=>r(this,void 0,void 0,function*(){var r;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,u.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));const c=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{yield this.gateway.send(c,this.session.walletPublicKey,e.method,{attempts:null==n?void 0:n.attempts,signal:null==n?void 0:n.signal}),null===(r=null==n?void 0:n.onRequestSent)||void 0===r||r.call(n),this.pendingRequests.set(a.toString(),t)}catch(e){s(e)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return r(this,void 0,void 0,function*(){return new Promise(t=>r(this,void 0,void 0,function*(){let n=!1,r=null;const o=()=>{n||(n=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=(0,f.createAbortController)(null==e?void 0:e.signal);r=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:o,signal:t.signal,attempts:1})}catch(e){(0,u.logDebug)("Disconnect error:",e),n||this.removeBridgeAndSession().then(t)}finally{r&&clearTimeout(r),o()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return r(this,void 0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return r(this,void 0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return r(this,void 0,void 0,function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)));if((0,u.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void(0,u.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void(0,u.logError)(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&((0,u.logDebug)("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(e=>e(t))})}gatewayErrorsListener(e){return r(this,void 0,void 0,function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return r(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return r(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",l.PROTOCOL_VERSION.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n=this.generateRegularUniversalLink("about:blank",t).split("?")[1],r="tonconnect-"+(0,d.encodeTelegramUrlParameters)(n),o=this.convertToDirectLink(e),i=new URL(o);return i.searchParams.append("startapp",r),i.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return r(this,void 0,void 0,function*(){return Array.isArray(this.walletConnectionSource)?(this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new s.BridgeGateway(this.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{});return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n}),void(yield Promise.allSettled(this.pendingGateways.map(e=>(0,h.callForSuccess)(n=>{var r;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(r=null==t?void 0:t.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS,signal:n.signal}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal}))))):(this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal}))})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}t.BridgeProvider=p},1689:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(8980),t)},1824:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},1926:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(2973);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},1934:(e,t)=>{"use strict";function n(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function r(e,t){var r,o,i,s,a,c,l,u;const d=(null===(r=null==t?void 0:t.connectItems)||void 0===r?void 0:r.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(i=null===(o=null==t?void 0:t.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,wallet_type:null!==(s=null==t?void 0:t.device.appName)&&void 0!==s?s:null,wallet_version:null!==(a=null==t?void 0:t.device.appVersion)&&void 0!==a?a:null,auth_type:d,custom_data:Object.assign({chain_id:null!==(l=null===(c=null==t?void 0:t.account)||void 0===c?void 0:c.chain)&&void 0!==l?l:null,provider:null!==(u=null==t?void 0:t.provider)&&void 0!==u?u:null},n(e))}}function o(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}Object.defineProperty(t,"__esModule",{value:!0}),t.createRequestVersionEvent=function(){return{type:"request-version"}},t.createResponseVersionEvent=function(e){return{type:"response-version",version:e}},t.createVersionInfo=n,t.createConnectionStartedEvent=function(e){return{type:"connection-started",custom_data:n(e)}},t.createConnectionCompletedEvent=function(e,t){return Object.assign({type:"connection-completed",is_success:!0},r(e,t))},t.createConnectionErrorEvent=function(e,t,r){return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=r?r:null,custom_data:n(e)}},t.createConnectionRestoringStartedEvent=function(e){return{type:"connection-restoring-started",custom_data:n(e)}},t.createConnectionRestoringCompletedEvent=function(e,t){return Object.assign({type:"connection-restoring-completed",is_success:!0},r(e,t))},t.createConnectionRestoringErrorEvent=function(e,t){return{type:"connection-restoring-error",is_success:!1,error_message:t,custom_data:n(e)}},t.createTransactionSentForSignatureEvent=function(e,t,n){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},r(e,t)),o(t,n))},t.createTransactionSignedEvent=function(e,t,n,i){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:i.boc},r(e,t)),o(t,n))},t.createTransactionSigningFailedEvent=function(e,t,n,i,s){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:i,error_code:null!=s?s:null},r(e,t)),o(t,n))},t.createDataSentForSignatureEvent=function(e,t,n){return Object.assign({type:"sign-data-request-initiated",data:n},r(e,t))},t.createDataSignedEvent=function(e,t,n,o){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:o},r(e,t))},t.createDataSigningFailedEvent=function(e,t,n,o,i){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:o,error_code:null!=i?i:null},r(e,t))},t.createDisconnectionEvent=function(e,t,n){return Object.assign({type:"disconnection",scope:n},r(e,t))}},1958:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(7321),o=n(3842),i=n(488),s=n(6582),a={[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}t.sendTransactionParser=new c},2003:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlLastSlash=n,t.addPathToUrl=function(e,t){return n(e)+"/"+t},t.isTelegramUrl=function(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname},t.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}},2242:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),s=i(e,"SendTransaction"),a={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!s)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(t.requireExtraCurrencies&&(!s||!s.extraCurrencySupported))throw new o.WalletNotSupportFeatureError("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(s&&void 0!==s.maxMessages){if(s.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${s.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}})}else(0,r.logWarning)("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")},t.checkSignDataSupport=function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new o.WalletNotSupportFeatureError(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})},t.checkRequiredWalletFeatures=function(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=i(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=i(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0};const r=n(7292),o=n(6886);function i(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}},2578:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FALLBACK_WALLETS_LIST=void 0,t.FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}]},2646:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.FetchWalletsError=o},2973:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ParseHexError=o},3016:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3122:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=n(7321),s=n(3335),a=n(1472),c=n(3546),l=n(8900),u=n(6886),d=n(5967),h=n(57),f=n(1958),p=n(5827),g=n(1653),v=n(6779),y=n(7714),b=n(8659),w=n(4945),E=n(5445),m=n(2242),_=n(520),R=n(7292),C=n(5148),O=n(4940),S=n(3370),T=n(3962),P=n(4496);class j{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){if(this.walletsList=new E.WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||(0,w.getWebPageManifest)(),storage:(null==e?void 0:e.storage)||new b.DefaultStorage},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.walletsList=new E.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),this.tracker=new O.TonConnectTracker({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectSdkVersion:S.tonConnectSdkVersion}),!this.dappSettings.manifestUrl)throw new s.DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new y.BridgeConnectionStorage(this.dappSettings.storage),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t){var n,r;const o={};if("object"==typeof t&&"tonProof"in t&&(o.request=t),"object"==typeof t&&("openingDeadlineMS"in t||"signal"in t||"request"in t)&&(o.request=null==t?void 0:t.request,o.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,o.signal=null==t?void 0:t.signal),o.request){const e=(0,T.validateConnectAdditionalRequest)(o.request);if(e){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new u.WalletAlreadyConnectedError;const i=(0,C.createAbortController)(null==o?void 0:o.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,i.signal.aborted)throw new l.TonConnectError("Connection was aborted");return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),i.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(null==o?void 0:o.request),{openingDeadlineMS:null==o?void 0:o.openingDeadlineMS,signal:i.signal})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;this.tracker.trackConnectionRestoringStarted();const o=(0,C.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=o,o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");const[i,s]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");let a=null;try{switch(i){case"http":a=yield g.BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":a=yield v.InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!s)return;a=this.createProvider(s)}}catch(e){return this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),null==a||a.closeConnection(),void(a=null)}if(o.signal.aborted)return null==a||a.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");if(!a)return(0,R.logError)("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored");null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const c=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),null==a||a.closeConnection(),a=null};o.signal.addEventListener("abort",c);const l=(0,_.callForSuccess)(t=>r(this,void 0,void 0,function*(){yield null==a?void 0:a.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal}),o.signal.removeEventListener("abort",c),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),u=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([l,u])})}sendTransaction(e,t){return r(this,void 0,void 0,function*(){const n={};"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal);const r=(0,T.validateSendTransactionRequest)(e);if(r){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SendTransactionRequest validation failed: "+r);console.error("SendTransactionRequest validation failed: "+r)}const i=(0,C.createAbortController)(null==n?void 0:n.signal);if(i.signal.aborted)throw new l.TonConnectError("Transaction sending was aborted");this.checkConnection();const s=e.messages.length,a=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);(0,m.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:s,requireExtraCurrencies:a}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:c,messages:u}=e,d=o(e,["validUntil","messages"]),h=e.from||this.account.address,p=e.network||this.account.chain,g=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},d),{from:h,network:p,valid_until:c,messages:u.map(e=>{var{extraCurrency:t}=e,n=o(e,["extraCurrency"]);return Object.assign(Object.assign({},n),{extra_currency:t})})})),{onRequestSent:n.onRequestSent,signal:i.signal});if(f.sendTransactionParser.isError(g))return this.tracker.trackTransactionSigningFailed(this.wallet,e,g.error.message,g.error.code),f.sendTransactionParser.parseAndThrowError(g);const v=f.sendTransactionParser.convertFromRpcResponse(g);return this.tracker.trackTransactionSigned(this.wallet,e,v),v})}signData(e,t){return r(this,void 0,void 0,function*(){const n=(0,C.createAbortController)(null==t?void 0:t.signal);if(n.signal.aborted)throw new l.TonConnectError("data sending was aborted");const r=(0,T.validateSignDataPayload)(e);if(r){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SignDataPayload validation failed: "+r);console.error("SignDataPayload validation failed: "+r)}this.checkConnection(),(0,m.checkSignDataSupport)(this.wallet.device.features,{requiredTypes:[e.type]}),this.tracker.trackDataSentForSignature(this.wallet,e);const o=e.from||this.account.address,i=e.network||this.account.chain,s=yield this.provider.sendRequest(p.signDataParser.convertToRpcRequest(Object.assign(Object.assign({},e),{from:o,network:i})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:n.signal});if(p.signDataParser.isError(s))return this.tracker.trackDataSigningFailed(this.wallet,e,s.error.message,s.error.code),p.signDataParser.parseAndThrowError(s);const a=p.signDataParser.convertFromRpcResponse(s);return this.tracker.trackDataSigned(this.wallet,e,a),a})}disconnect(e){return r(this,void 0,void 0,function*(){var t;if(!this.connected)throw new u.WalletNotConnectedError;const n=(0,C.createAbortController)(null==e?void 0:e.signal),r=this.abortController;if(this.abortController=n,n.signal.aborted)throw new l.TonConnectError("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield null===(t=this.provider)||void 0===t?void 0:t.disconnect({signal:n.signal}),null==r||r.abort()})}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=(0,w.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(e){(0,R.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}createProvider(e){let t;return t=!Array.isArray(e)&&(0,d.isWalletConnectionSourceJS)(e)?new v.InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new g.BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.tracker.trackConnectionError(e.payload.message,e.payload.code);const t=h.connectErrorsParser.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(e){var t;const n=e.items.find(e=>"ton_addr"===e.name),r=e.items.find(e=>"ton_proof"===e.name);if(!n)throw new l.TonConnectError("ton_addr connection item was not found");if(!(0,m.checkRequiredWalletFeatures)(e.device.features,this.walletsRequiredFeatures))return null===(t=this.provider)||void 0===t||t.disconnect(),void this.onWalletConnectError(new u.WalletMissingRequiredFeaturesError("Wallet does not support required features",{cause:{connectEvent:e}}));const o={device:e.device,provider:this.provider.type,account:{address:n.address,chain:n.network,walletStateInit:n.walletStateInit,publicKey:n.publicKey}};if(r){let e;try{if("proof"in r)e={name:"ton_proof",proof:{timestamp:r.proof.timestamp,domain:{lengthBytes:r.proof.domain.lengthBytes,value:r.proof.domain.value},payload:r.proof.payload,signature:r.proof.signature}};else{if(!("error"in r))throw new l.TonConnectError("Invalid data format");e={name:"ton_proof",error:{code:r.error.code,message:r.error.message}}}}catch(t){e={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}o.connectItems={tonProof:e}}this.wallet=o,this.tracker.trackConnectionCompleted(o)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),(0,R.logDebug)(e),e instanceof c.ManifestNotFoundError||e instanceof a.ManifestContentErrorError)throw(0,R.logError)(e),e}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new u.WalletNotConnectedError}createConnectRequest(e){const t=[{name:"ton_addr"}];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=j,j.walletsList=new E.WalletsListManager,j.isWalletInjected=e=>v.InjectedProvider.isWalletInjected(e),j.isInsideWalletBrowser=e=>v.InjectedProvider.isInsideWalletBrowser(e)},3235:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.HttpBridgeGatewayStorage=void 0,t.HttpBridgeGatewayStorage=class{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return n(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return n(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return n(this,void 0,void 0,function*(){return(yield this.storage.getItem(this.storeKey))||null})}}},3304:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=n(7321),i=n(8900),s=n(3235),a=n(2003);n(7523),n(4898);const c=n(520),l=n(7292),u=n(816),d=n(8949),h=n(5148);t.BridgeGateway=class{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,o,c){this.bridgeUrl=t,this.sessionId=n,this.listener=o,this.errorsListener=c,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=(0,u.createResource)((e,t)=>r(this,void 0,void 0,function*(){const n={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t};return yield function(e){return r(this,void 0,void 0,function*(){return yield(0,d.timeout)((t,n,o)=>r(this,void 0,void 0,function*(){var s;const c=(0,h.createAbortController)(o.signal).signal;if(c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const l=new URL((0,a.addPathToUrl)(e.bridgeUrl,e.ssePath));l.searchParams.append("client_id",e.sessionId);const u=yield e.bridgeGatewayStorage.getLastEventId();if(u&&l.searchParams.append("last_event_id",u),c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const d=new EventSource(l.toString());d.onerror=o=>r(this,void 0,void 0,function*(){if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));try{const n=yield e.errorHandler(d,o);n!==d&&d.close(),n&&n!==d&&t(n)}catch(e){d.close(),n(e)}}),d.onopen=()=>{if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));t(d)},d.onmessage=t=>{if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));e.messageHandler(t)},null===(s=e.signal)||void 0===s||s.addEventListener("abort",()=>{d.close(),n(new i.TonConnectError("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(n)}),e=>r(this,void 0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t)}registerSession(e){return r(this,void 0,void 0,function*(){yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS)})}send(e,t,n,s){return r(this,void 0,void 0,function*(){var l;const u={};"number"==typeof s?u.ttl=s:(u.ttl=null==s?void 0:s.ttl,u.signal=null==s?void 0:s.signal,u.attempts=null==s?void 0:s.attempts);const d=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));d.searchParams.append("client_id",this.sessionId),d.searchParams.append("to",t),d.searchParams.append("ttl",((null==u?void 0:u.ttl)||this.defaultTtl).toString()),d.searchParams.append("topic",n);const h=o.Base64.encode(e);yield(0,c.callForSuccess)(e=>r(this,void 0,void 0,function*(){const t=yield this.post(d,h,e.signal);if(!t.ok)throw new i.TonConnectError(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(l=null==u?void 0:u.attempts)&&void 0!==l?l:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==u?void 0:u.signal})})}pause(){this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge pause failed, ${e}`))}unPause(){return r(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return r(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return r(this,void 0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new i.TonConnectError(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return r(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new i.TonConnectError("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),(0,l.logDebug)(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new i.TonConnectError("Bridge error, unknown state")}try{this.errorsListener(t)}catch(e){}})}messagesHandler(e){return r(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{t=JSON.parse(e.data)}catch(t){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}},3335:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.DappMetadataError=o},3345:(e,t)=>{"use strict";function n(e){return r(e)&&e.injected}function r(e){return"jsBridgeKey"in e}Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoCurrentlyInjected=n,t.isWalletInfoCurrentlyEmbedded=function(e){return n(e)&&e.embedded},t.isWalletInfoInjectable=r,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},3370:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tonConnectSdkVersion=void 0,t.tonConnectSdkVersion="3.3.0-beta.1"},3443:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=function(e){try{return!(!(0,r.hasProperty)(e,"tonconnect")||!(0,r.hasProperty)(e.tonconnect,"walletInfo"))&&(0,r.hasProperties)(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(e){return!1}};const r=n(4207)},3546:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestNotFoundError=o},3842:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(n(8059),t),o(n(6886),t),o(n(7864),t),o(n(7645),t),o(n(6065),t),o(n(1926),t);var i=n(8900);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(488);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},3912:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{static getInstance(){return n.instance||(n.instance=new n),n.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}}t.InMemoryStorage=n},3962:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSendTransactionRequest=function(e){if(console.log("[Validation Debug] validateSendTransactionRequest called"),console.log("[Validation Debug] isQaModeEnabled():",(0,o.isQaModeEnabled)()),!d(e)){const e="Request must be an object";(0,o.logValidationError)(e);const t=(0,o.isQaModeEnabled)();return console.log("[Validation Debug] Should return null:",t),t?null:e}if(h(e,["validUntil","network","from","messages"])){const e="Request contains extra properties";return(0,o.logValidationError)(e),(0,o.isQaModeEnabled)()?null:e}if("number"!=typeof(t=e.validUntil)||isNaN(t)){const e="Incorrect 'validUntil'";return(0,o.logValidationError)(e),(0,o.isQaModeEnabled)()?null:e}var t;const n=Math.floor(Date.now()/1e3),i=n+300;if(e.validUntil>i&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${n})`),!(void 0===e.network||l(e.network)&&/^[\d-]+$/.test(e.network))){const e="Invalid 'network' format";return(0,o.logValidationError)(e),(0,o.isQaModeEnabled)()?null:e}if(!(void 0===e.from||l(e.from)&&(0,r.isValidRawAddress)(e.from))){const e="Invalid 'from' address format";return(0,o.logValidationError)(e),(0,o.isQaModeEnabled)()?null:e}if(!function(e){return Array.isArray(e)}(e.messages)||0===e.messages.length){const e="'messages' is required";return(0,o.logValidationError)(e),(0,o.isQaModeEnabled)()?null:e}for(let t=0;t<e.messages.length;t++){const n=f(e.messages[t],t);if(n)return n}return null},t.validateConnectAdditionalRequest=function(e){return d(e)?h(e,["tonProof"])?"Request contains extra properties":void 0===e.tonProof||l(e.tonProof)?null:"Invalid 'tonProof'":"Request must be an object"},t.validateSignDataPayload=function(e){if(!d(e))return"Payload must be an object";if(!l(e.type))return"'type' is required";switch(e.type){case"text":return function(e){return h(e,["type","text","network","from"])?"Text payload contains extra properties":l(e.text)?void 0===e.network||l(e.network)&&/^\d+$/.test(e.network)?void 0===e.from||l(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'text' is required"}(e);case"binary":return function(e){return h(e,["type","bytes","network","from"])?"Binary payload contains extra properties":l(e.bytes)?void 0===e.network||l(e.network)&&/^\d+$/.test(e.network)?void 0===e.from||l(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'bytes' is required"}(e);case"cell":return function(e){return h(e,["type","schema","cell","network","from"])?"Cell payload contains extra properties":l(e.schema)?l(e.cell)?u(e.cell)?void 0===e.network||l(e.network)&&/^\d+$/.test(e.network)?void 0===e.from||l(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"Invalid 'cell' format (must be valid base64)":"'cell' is required":"'schema' is required"}(e);default:return"Invalid 'type' value"}};const r=n(8350),o=n(4496),i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s="te6cc",a=/^-?\d+$/,c=/^\d+$/;function l(e){return"string"==typeof e&&e.length>0}function u(e){return"string"==typeof e&&i.test(e)&&e.startsWith(s)}function d(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function h(e,t){return Object.keys(e).some(e=>!t.includes(e))}function f(e,t){if(!d(e))return`Message at index ${t} must be an object`;if(h(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!l(e.address))return`'address' is required in message at index ${t}`;if(!(0,r.isValidUserFriendlyAddress)(e.address))return`Wrong 'address' format in message at index ${t}`;if(!l(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||l(e.stateInit)&&u(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||l(e.payload)&&u(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!d(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!a.test(n)||"string"!=typeof r||!c.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}},4207:(e,t)=>{"use strict";function n(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},4278:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserEventDispatcher=void 0;const o=n(4945);t.BrowserEventDispatcher=class{constructor(){this.window=(0,o.getWindow)()}dispatchEvent(e,t){return r(this,void 0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return r(this,void 0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}},4355:()=>{},4496:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enableQaMode=function(){n=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),i(),"undefined"==typeof window||r||(r=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&n?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>i(),100)):"ton-connect-qa-mode-styles"===t.id&&n&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>s(),100))}})})}),r.observe(document.body,{childList:!0,subtree:!1}),r.observe(document.head,{childList:!0,subtree:!1})),s()},t.isQaModeEnabled=o,t.logValidationError=function(e){o()&&console.error(`[QA Mode] Validation failed: ${e}`)};let n=!1,r=null;function o(){return n}function i(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),s()}function s(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}},4648:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UserRejectsError=o},4761:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var r=n(3345);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return r.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return r.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return r.isWalletInfoInjected}})},4888:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(719);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(8688);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},4898:()=>{},4940:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectTracker=void 0;const o=n(1934),i=n(4278);t.TonConnectTracker=class{get version(){return(0,o.createVersionInfo)({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){var t;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null!==(t=null==e?void 0:e.eventDispatcher)&&void 0!==t?t:new i.BrowserEventDispatcher,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return r(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return r(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>r(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",(0,o.createResponseVersionEvent)(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return r(this,void 0,void 0,function*(){return new Promise((e,t)=>r(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",(0,o.createRequestVersionEvent)())}catch(e){t(e)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(e){}}trackConnectionStarted(...e){try{const t=(0,o.createConnectionStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionCompleted(...e){try{const t=(0,o.createConnectionCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionError(...e){try{const t=(0,o.createConnectionErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringStarted(...e){try{const t=(0,o.createConnectionRestoringStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringCompleted(...e){try{const t=(0,o.createConnectionRestoringCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringError(...e){try{const t=(0,o.createConnectionRestoringErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDisconnection(...e){try{const t=(0,o.createDisconnectionEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSentForSignature(...e){try{const t=(0,o.createTransactionSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigned(...e){try{const t=(0,o.createTransactionSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigningFailed(...e){try{const t=(0,o.createTransactionSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSentForSignature(...e){try{const t=(0,o.createDataSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigned(...e){try{const t=(0,o.createDataSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigningFailed(...e){try{const t=(0,o.createDataSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}}},4945:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindow=i,t.tryGetWindowKeys=function(){const e=i();if(!e)return[];try{return Object.keys(e)}catch(e){return[]}},t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=i())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""},t.tryGetLocalStorage=function(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new o.TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return r.InMemoryStorage.getInstance()};const r=n(3912),o=n(3842);function i(){if("undefined"!=typeof window)return window}},5148:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAbortController=function(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}},5367:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.LocalstorageNotFoundError=o},5445:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=n(2646),i=n(3345),s=n(6779),a=n(7292),c=n(2578),l=n(4496);t.WalletsListManager=class{constructor(e){var t;this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,(0,l.isQaModeEnabled)()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs}getWallets(){return r(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then(()=>{this.walletsListCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null})),this.walletsListCache})}getEmbeddedWallet(){return r(this,void 0,void 0,function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1===e.length?e[0]:null})}fetchWalletsList(){return r(this,void 0,void 0,function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const n=e.filter(e=>!this.isCorrectWalletConfigDTO(e));n.length&&((0,a.logError)(`Wallet(s) ${n.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(e=>this.isCorrectWalletConfigDTO(e)))}catch(t){(0,a.logError)(t),e=c.FALLBACK_WALLETS_LIST}let t=[];try{t=s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){(0,a.logError)(e)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=s.InjectedProvider.isWalletInjected(e),t.embedded=s.InjectedProvider.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}},5827:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signDataParser=void 0;const r=n(7321),o=n(3842),i=n(488),s=n(6582),a={[r.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return e.result}}t.signDataParser=new c},5858:function(e){!function(t,n){"use strict";e.exports?e.exports=n():(t.nacl||(t.nacl={}),t.nacl.util=n())}(this,function(){"use strict";var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e})},5967:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e}},6065:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(1401);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},6582:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},6702:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotInjectedError=o},6779:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=n(6702),i=n(3443),s=n(7714),a=n(4945),c=n(1824),l=n(7292);class u{static fromStorage(e){return r(this,void 0,void 0,function*(){const t=new s.BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new u(e,n.jsBridgeKey)})}static isWalletInjected(e){return u.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!u.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,a.tryGetWindowKeys)().filter(([e,t])=>(0,i.isJSBridgeWithMetadata)(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features})):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=u.window;if(!u.isWindowContainsWallet(n,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}connect(e){this._connect(c.PROTOCOL_VERSION,e)}restoreConnection(){return r(this,void 0,void 0,function*(){try{(0,l.logDebug)("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();(0,l.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach(t=>t(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return r(this,void 0,void 0,function*(){return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,l.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},t)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n;const r={};"function"==typeof t?r.onRequestSent=t:(r.onRequestSent=null==t?void 0:t.onRequestSent,r.signal=null==t?void 0:t.signal);const o=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:o}));const i=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:o}));return i.then(e=>(0,l.logDebug)("Wallet message received:",e)),null===(n=null==r?void 0:r.onRequestSent)||void 0===n||n.call(r),i})}_connect(e,t){return r(this,void 0,void 0,function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(e=>e(n))}catch(e){(0,l.logDebug)("Injected Provider connect error:",e);const t={event:"connect_error",payload:{code:0,message:null==e?void 0:e.toString()}};this.listeners.forEach(e=>e(t))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(e=>{(0,l.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(e)),"disconnect"===e.event&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=u,u.window=(0,a.getWindow)()},6886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=t.WalletNotSupportFeatureError=t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(734);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(9475);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(6702);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}});var s=n(7916);Object.defineProperty(t,"WalletNotSupportFeatureError",{enumerable:!0,get:function(){return s.WalletNotSupportFeatureError}});var a=n(630);Object.defineProperty(t,"WalletMissingRequiredFeaturesError",{enumerable:!0,get:function(){return a.WalletMissingRequiredFeaturesError}})},7292:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=function(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logError=function(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logWarning=function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(e){}}},7321:(e,t,n)=>{"use strict";var r,o,i,s,a,c,l=n(5858),u=n(8861);t.CONNECT_EVENT_ERROR_CODES=void 0,(r=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[r.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",r[r.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",r[r.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",r[r.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",r[r.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",r[r.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",r[r.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const d={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=l.decodeUTF8(e)),function(e,t){const n=l.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(n),toObject(){try{return JSON.parse(l.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function h(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function f(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function p(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function g(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}t.Base64=d,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=p(this.keyPair.publicKey)}createKeypair(){return u.box.keyPair()}createKeypairFromString(e){return{publicKey:g(e.publicKey),secretKey:g(e.secretKey)}}createNonce(){return u.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return h(r,u.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=f(e,this.nonceLength),o=u.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:p(this.keyPair.publicKey),secretKey:p(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=g,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=f,t.toHexString=p},7523:()=>{},7645:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(2646);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},7663:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(4761),t),o(n(7982),t)},7714:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=n(7321),i=n(3842),s=n(8111);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!(0,s.isPendingConnectionHttp)(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return r(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if(!(0,s.isPendingConnectionHttpRaw)(t)){const e=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return(0,s.isExpiredPendingConnectionHttpRaw)(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}})}getHttpConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected connection is stored");if(!(0,s.isPendingConnectionHttp)(e))throw new i.TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new i.TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return r(this,void 0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!(0,s.isPendingConnectionHttp)(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}},7864:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(5367);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},7916:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},7982:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(139),t),o(n(3016),t),o(n(8941),t)},8059:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(1689),t),o(n(4888),t)},8111:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_HTTP_EXPIRATION_TIME=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)},t.isPendingConnectionHttpRaw=function(e){return!("connectEvent"in e)},t.isExpiredPendingConnectionHttpRaw=function(e){var n;return Date.now()-(null!==(n=e.createdAt)&&void 0!==n?n:0)>t.CONNECTION_HTTP_EXPIRATION_TIME},t.CONNECTION_HTTP_EXPIRATION_TIME=3e5},8350:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:r}=c(e);let a=i;t&&(a|=s);const u=new Int8Array(34);u[0]=a,u[1]=n,u.set(r,2);const d=new Uint8Array(36);return d.set(u),d.set(l(u),34),o.Base64.encode(d).replace(/\+/g,"-").replace(/\//g,"_")},t.isValidUserFriendlyAddress=function(e){try{return a(e),!0}catch(e){return!1}},t.isValidRawAddress=function(e){try{return c(e),!0}catch(e){return!1}},t.parseUserFriendlyAddress=a;const r=n(3842),o=n(7321),i=81,s=128;function a(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=o.Base64.decode(t).toUint8Array()}catch(t){throw new r.WrongAddressError(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new r.WrongAddressError(`Invalid address length: ${e}`);const i=n.slice(0,34),a=n.slice(34),c=l(i);if(!a.every((e,t)=>e===c[t]))throw new r.WrongAddressError(`Invalid checksum in address: ${e}`);const u=i[0],d=i[1],h=i.slice(2);if(0!==d&&-1!==d)throw new r.WrongAddressError(`Invalid workchain: ${d}`);const f=0!==(u&s),p=!!(64&u);return{wc:d,hex:Array.from(h).map(e=>e.toString(16).padStart(2,"0")).join(""),testOnly:f,isBounceable:p}}function c(e){if(!e.includes(":"))throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new r.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new r.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:n,hex:d(o)}}function l(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let e of n){let n=128;for(;n>0;)t<<=1,e&n&&(t+=1),n>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const u={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),u[t]=e}function d(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new r.ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,o=new Uint8Array(n);for(let t=0;t<n;t++){const n=2*t,i=e.substring(n,n+2);if(!u.hasOwnProperty(i))throw new r.ParseHexError("Invalid hex character: "+i);o[t]=u[i]}return o}},8659:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=n(4945);t.DefaultStorage=class{constructor(){this.localStorage=(0,o.tryGetLocalStorage)()}getItem(e){return r(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return r(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return r(this,void 0,void 0,function*(){this.localStorage.setItem(e,t)})}}},8688:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownAppError=o},8861:(e,t,n)=>{!function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw new Error("no PRNG")},o=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),a=t([1]),c=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function g(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function v(e,t,n,r){return g(e,t,n,r,16)}function y(e,t,n,r){return g(e,t,n,r,32)}function b(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,m=i,_=s,R=a,C=c,O=l,S=u,T=d,P=h,j=f,N=p,A=g,M=v,U=y,I=b,D=w,k=E,x=0;x<20;x+=2)m^=(o=(U^=(o=(j^=(o=(O^=(o=m+U|0)<<7|o>>>25)+m|0)<<9|o>>>23)+O|0)<<13|o>>>19)+j|0)<<18|o>>>14,S^=(o=(_^=(o=(I^=(o=(N^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+N|0)<<13|o>>>19)+I|0)<<18|o>>>14,A^=(o=(T^=(o=(R^=(o=(D^=(o=A+T|0)<<7|o>>>25)+A|0)<<9|o>>>23)+D|0)<<13|o>>>19)+R|0)<<18|o>>>14,k^=(o=(M^=(o=(P^=(o=(C^=(o=k+M|0)<<7|o>>>25)+k|0)<<9|o>>>23)+C|0)<<13|o>>>19)+P|0)<<18|o>>>14,m^=(o=(C^=(o=(R^=(o=(_^=(o=m+C|0)<<7|o>>>25)+m|0)<<9|o>>>23)+_|0)<<13|o>>>19)+R|0)<<18|o>>>14,S^=(o=(O^=(o=(P^=(o=(T^=(o=S+O|0)<<7|o>>>25)+S|0)<<9|o>>>23)+T|0)<<13|o>>>19)+P|0)<<18|o>>>14,A^=(o=(N^=(o=(j^=(o=(M^=(o=A+N|0)<<7|o>>>25)+A|0)<<9|o>>>23)+M|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(D^=(o=(I^=(o=(U^=(o=k+D|0)<<7|o>>>25)+k|0)<<9|o>>>23)+U|0)<<13|o>>>19)+I|0)<<18|o>>>14;m=m+i|0,_=_+s|0,R=R+a|0,C=C+c|0,O=O+l|0,S=S+u|0,T=T+d|0,P=P+h|0,j=j+f|0,N=N+p|0,A=A+g|0,M=M+v|0,U=U+y|0,I=I+b|0,D=D+w|0,k=k+E|0,e[0]=m>>>0&255,e[1]=m>>>8&255,e[2]=m>>>16&255,e[3]=m>>>24&255,e[4]=_>>>0&255,e[5]=_>>>8&255,e[6]=_>>>16&255,e[7]=_>>>24&255,e[8]=R>>>0&255,e[9]=R>>>8&255,e[10]=R>>>16&255,e[11]=R>>>24&255,e[12]=C>>>0&255,e[13]=C>>>8&255,e[14]=C>>>16&255,e[15]=C>>>24&255,e[16]=O>>>0&255,e[17]=O>>>8&255,e[18]=O>>>16&255,e[19]=O>>>24&255,e[20]=S>>>0&255,e[21]=S>>>8&255,e[22]=S>>>16&255,e[23]=S>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=P>>>0&255,e[29]=P>>>8&255,e[30]=P>>>16&255,e[31]=P>>>24&255,e[32]=j>>>0&255,e[33]=j>>>8&255,e[34]=j>>>16&255,e[35]=j>>>24&255,e[36]=N>>>0&255,e[37]=N>>>8&255,e[38]=N>>>16&255,e[39]=N>>>24&255,e[40]=A>>>0&255,e[41]=A>>>8&255,e[42]=A>>>16&255,e[43]=A>>>24&255,e[44]=M>>>0&255,e[45]=M>>>8&255,e[46]=M>>>16&255,e[47]=M>>>24&255,e[48]=U>>>0&255,e[49]=U>>>8&255,e[50]=U>>>16&255,e[51]=U>>>24&255,e[52]=I>>>0&255,e[53]=I>>>8&255,e[54]=I>>>16&255,e[55]=I>>>24&255,e[56]=D>>>0&255,e[57]=D>>>8&255,e[58]=D>>>16&255,e[59]=D>>>24&255,e[60]=k>>>0&255,e[61]=k>>>8&255,e[62]=k>>>16&255,e[63]=k>>>24&255}(e,t,n,r)}function w(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,E=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,m=0;m<20;m+=2)i^=(o=(y^=(o=(f^=(o=(l^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(b^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+b|0)<<18|o>>>14,g^=(o=(d^=(o=(a^=(o=(w^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+w|0)<<13|o>>>19)+a|0)<<18|o>>>14,E^=(o=(v^=(o=(h^=(o=(c^=(o=E+v|0)<<7|o>>>25)+E|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(c^=(o=(a^=(o=(s^=(o=i+c|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(l^=(o=(h^=(o=(d^=(o=u+l|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,g^=(o=(p^=(o=(f^=(o=(v^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+v|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(w^=(o=(b^=(o=(y^=(o=E+w|0)<<7|o>>>25)+E|0)<<9|o>>>23)+y|0)<<13|o>>>19)+b|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function m(e,t,n,r,o,i,s){var a,c,l=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)l[c]=0;for(c=0;c<8;c++)l[c]=i[c];for(;o>=64;){for(b(u,l,s,E),c=0;c<64;c++)e[t+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&l[c])|0,l[c]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(b(u,l,s,E),c=0;c<o;c++)e[t+c]=n[r+c]^u[c];return 0}function _(e,t,n,r,o){var i,s,a=new Uint8Array(16),c=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(b(c,a,o,E),s=0;s<64;s++)e[t+s]=c[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(b(c,a,o,E),s=0;s<n;s++)e[t+s]=c[s];return 0}function R(e,t,n,r,o){var i=new Uint8Array(32);w(i,r,o,E);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return _(e,t,n,s,i)}function C(e,t,n,r,o,i,s){var a=new Uint8Array(32);w(a,i,s,E);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return m(e,t,n,r,o,c,a)}var O=function(e){var t,n,r,o,i,s,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function S(e,t,n,r,o,i){var s=new O(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return S(s,0,n,r,o,i),v(e,t,s,0)}function P(e,t,n,r,o){var i;if(n<32)return-1;for(C(e,0,t,0,n,r,o),S(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function j(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(R(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(C(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function N(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function A(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function M(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function U(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(A(a),A(a),A(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,M(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function I(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,e),U(r,t),y(n,0,r,0)}function D(e){var t=new Uint8Array(32);return U(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function x(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function W(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function L(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,p=0,g=0,v=0,y=0,b=0,w=0,E=0,m=0,_=0,R=0,C=0,O=0,S=0,T=0,P=0,j=0,N=0,A=0,M=0,U=0,I=0,D=0,k=n[0],x=n[1],W=n[2],L=n[3],q=n[4],B=n[5],F=n[6],K=n[7],V=n[8],G=n[9],H=n[10],$=n[11],Q=n[12],J=n[13],Y=n[14],z=n[15];i+=(r=t[0])*k,s+=r*x,a+=r*W,c+=r*L,l+=r*q,u+=r*B,d+=r*F,h+=r*K,f+=r*V,p+=r*G,g+=r*H,v+=r*$,y+=r*Q,b+=r*J,w+=r*Y,E+=r*z,s+=(r=t[1])*k,a+=r*x,c+=r*W,l+=r*L,u+=r*q,d+=r*B,h+=r*F,f+=r*K,p+=r*V,g+=r*G,v+=r*H,y+=r*$,b+=r*Q,w+=r*J,E+=r*Y,m+=r*z,a+=(r=t[2])*k,c+=r*x,l+=r*W,u+=r*L,d+=r*q,h+=r*B,f+=r*F,p+=r*K,g+=r*V,v+=r*G,y+=r*H,b+=r*$,w+=r*Q,E+=r*J,m+=r*Y,_+=r*z,c+=(r=t[3])*k,l+=r*x,u+=r*W,d+=r*L,h+=r*q,f+=r*B,p+=r*F,g+=r*K,v+=r*V,y+=r*G,b+=r*H,w+=r*$,E+=r*Q,m+=r*J,_+=r*Y,R+=r*z,l+=(r=t[4])*k,u+=r*x,d+=r*W,h+=r*L,f+=r*q,p+=r*B,g+=r*F,v+=r*K,y+=r*V,b+=r*G,w+=r*H,E+=r*$,m+=r*Q,_+=r*J,R+=r*Y,C+=r*z,u+=(r=t[5])*k,d+=r*x,h+=r*W,f+=r*L,p+=r*q,g+=r*B,v+=r*F,y+=r*K,b+=r*V,w+=r*G,E+=r*H,m+=r*$,_+=r*Q,R+=r*J,C+=r*Y,O+=r*z,d+=(r=t[6])*k,h+=r*x,f+=r*W,p+=r*L,g+=r*q,v+=r*B,y+=r*F,b+=r*K,w+=r*V,E+=r*G,m+=r*H,_+=r*$,R+=r*Q,C+=r*J,O+=r*Y,S+=r*z,h+=(r=t[7])*k,f+=r*x,p+=r*W,g+=r*L,v+=r*q,y+=r*B,b+=r*F,w+=r*K,E+=r*V,m+=r*G,_+=r*H,R+=r*$,C+=r*Q,O+=r*J,S+=r*Y,T+=r*z,f+=(r=t[8])*k,p+=r*x,g+=r*W,v+=r*L,y+=r*q,b+=r*B,w+=r*F,E+=r*K,m+=r*V,_+=r*G,R+=r*H,C+=r*$,O+=r*Q,S+=r*J,T+=r*Y,P+=r*z,p+=(r=t[9])*k,g+=r*x,v+=r*W,y+=r*L,b+=r*q,w+=r*B,E+=r*F,m+=r*K,_+=r*V,R+=r*G,C+=r*H,O+=r*$,S+=r*Q,T+=r*J,P+=r*Y,j+=r*z,g+=(r=t[10])*k,v+=r*x,y+=r*W,b+=r*L,w+=r*q,E+=r*B,m+=r*F,_+=r*K,R+=r*V,C+=r*G,O+=r*H,S+=r*$,T+=r*Q,P+=r*J,j+=r*Y,N+=r*z,v+=(r=t[11])*k,y+=r*x,b+=r*W,w+=r*L,E+=r*q,m+=r*B,_+=r*F,R+=r*K,C+=r*V,O+=r*G,S+=r*H,T+=r*$,P+=r*Q,j+=r*J,N+=r*Y,A+=r*z,y+=(r=t[12])*k,b+=r*x,w+=r*W,E+=r*L,m+=r*q,_+=r*B,R+=r*F,C+=r*K,O+=r*V,S+=r*G,T+=r*H,P+=r*$,j+=r*Q,N+=r*J,A+=r*Y,M+=r*z,b+=(r=t[13])*k,w+=r*x,E+=r*W,m+=r*L,_+=r*q,R+=r*B,C+=r*F,O+=r*K,S+=r*V,T+=r*G,P+=r*H,j+=r*$,N+=r*Q,A+=r*J,M+=r*Y,U+=r*z,w+=(r=t[14])*k,E+=r*x,m+=r*W,_+=r*L,R+=r*q,C+=r*B,O+=r*F,S+=r*K,T+=r*V,P+=r*G,j+=r*H,N+=r*$,A+=r*Q,M+=r*J,U+=r*Y,I+=r*z,E+=(r=t[15])*k,s+=38*(_+=r*W),a+=38*(R+=r*L),c+=38*(C+=r*q),l+=38*(O+=r*B),u+=38*(S+=r*F),d+=38*(T+=r*K),h+=38*(P+=r*V),f+=38*(j+=r*G),p+=38*(N+=r*H),g+=38*(A+=r*$),v+=38*(M+=r*Q),y+=38*(U+=r*J),b+=38*(I+=r*Y),w+=38*(D+=r*z),i=(r=(i+=38*(m+=r*x))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),E=(r=E+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),E=(r=E+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=v,e[12]=y,e[13]=b,e[14]=w,e[15]=E}function q(e,t){L(e,t,t)}function B(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)q(o,o),2!==r&&4!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)q(o,o),1!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),u=t(),d=t(),h=t(),f=t(),p=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,k(a,r),i=0;i<16;i++)u[i]=a[i],h[i]=l[i]=d[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)M(l,u,o=s[i>>>3]>>>(7&i)&1),M(d,h,o),x(f,l,d),W(l,l,d),x(d,u,h),W(u,u,h),q(h,f),q(p,l),L(l,d,l),L(d,u,f),x(f,l,d),W(l,l,d),q(u,l),W(d,h,p),L(l,d,c),x(l,l,h),L(d,d,l),L(l,h,p),L(h,u,a),q(u,f),M(l,u,o),M(d,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=d[i],a[i+48]=u[i],a[i+64]=h[i];var g=a.subarray(32),v=a.subarray(16);return B(g,g),L(v,v,g),U(e,v),0}function V(e,t){return K(e,t,i)}function G(e,t){return r(t,32),V(e,t)}function H(e,t,n){var r=new Uint8Array(32);return K(r,n,t),w(e,o,r,E)}O.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,u,d,h,f,p,g,v,y,b,w,E,m,_=this.fin?0:2048,R=this.h[0],C=this.h[1],O=this.h[2],S=this.h[3],T=this.h[4],P=this.h[5],j=this.h[6],N=this.h[7],A=this.h[8],M=this.h[9],U=this.r[0],I=this.r[1],D=this.r[2],k=this.r[3],x=this.r[4],W=this.r[5],L=this.r[6],q=this.r[7],B=this.r[8],F=this.r[9];n>=16;)h=d=0,h+=(R+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*U,h+=(C+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),h+=(O+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*B),h+=(S+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*q),d=(h+=(T+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*L))>>>13,h&=8191,h+=(P+=a>>>1&8191)*(5*W),h+=(j+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*x),h+=(N+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*k),h+=(A+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*D),f=d+=(h+=(M+=u>>>5|_)*(5*I))>>>13,f+=R*I,f+=C*U,f+=O*(5*F),f+=S*(5*B),d=(f+=T*(5*q))>>>13,f&=8191,f+=P*(5*L),f+=j*(5*W),f+=N*(5*x),f+=A*(5*k),d+=(f+=M*(5*D))>>>13,f&=8191,p=d,p+=R*D,p+=C*I,p+=O*U,p+=S*(5*F),d=(p+=T*(5*B))>>>13,p&=8191,p+=P*(5*q),p+=j*(5*L),p+=N*(5*W),p+=A*(5*x),g=d+=(p+=M*(5*k))>>>13,g+=R*k,g+=C*D,g+=O*I,g+=S*U,d=(g+=T*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=j*(5*q),g+=N*(5*L),g+=A*(5*W),v=d+=(g+=M*(5*x))>>>13,v+=R*x,v+=C*k,v+=O*D,v+=S*I,d=(v+=T*U)>>>13,v&=8191,v+=P*(5*F),v+=j*(5*B),v+=N*(5*q),v+=A*(5*L),y=d+=(v+=M*(5*W))>>>13,y+=R*W,y+=C*x,y+=O*k,y+=S*D,d=(y+=T*I)>>>13,y&=8191,y+=P*U,y+=j*(5*F),y+=N*(5*B),y+=A*(5*q),b=d+=(y+=M*(5*L))>>>13,b+=R*L,b+=C*W,b+=O*x,b+=S*k,d=(b+=T*D)>>>13,b&=8191,b+=P*I,b+=j*U,b+=N*(5*F),b+=A*(5*B),w=d+=(b+=M*(5*q))>>>13,w+=R*q,w+=C*L,w+=O*W,w+=S*x,d=(w+=T*k)>>>13,w&=8191,w+=P*D,w+=j*I,w+=N*U,w+=A*(5*F),E=d+=(w+=M*(5*B))>>>13,E+=R*B,E+=C*q,E+=O*L,E+=S*W,d=(E+=T*x)>>>13,E&=8191,E+=P*k,E+=j*D,E+=N*I,E+=A*U,m=d+=(E+=M*(5*F))>>>13,m+=R*F,m+=C*B,m+=O*q,m+=S*L,d=(m+=T*W)>>>13,m&=8191,m+=P*x,m+=j*k,m+=N*D,m+=A*I,R=h=8191&(d=(d=((d+=(m+=M*U)>>>13)<<2)+d|0)+(h&=8191)|0),C=f+=d>>>=13,O=p&=8191,S=g&=8191,T=v&=8191,P=y&=8191,j=b&=8191,N=w&=8191,A=E&=8191,M=m&=8191,t+=16,n-=16;this.h[0]=R,this.h[1]=C,this.h[2]=O,this.h[3]=S,this.h[4]=T,this.h[5]=P,this.h[6]=j,this.h[7]=N,this.h[8]=A,this.h[9]=M},O.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},O.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var $=P,Q=j,J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Y(e,t,n,r){for(var o,i,s,a,c,l,u,d,h,f,p,g,v,y,b,w,E,m,_,R,C,O,S,T,P,j,N=new Int32Array(16),A=new Int32Array(16),M=e[0],U=e[1],I=e[2],D=e[3],k=e[4],x=e[5],W=e[6],L=e[7],q=t[0],B=t[1],F=t[2],K=t[3],V=t[4],G=t[5],H=t[6],$=t[7],Q=0;r>=128;){for(_=0;_<16;_++)R=8*_+Q,N[_]=n[R+0]<<24|n[R+1]<<16|n[R+2]<<8|n[R+3],A[_]=n[R+4]<<24|n[R+5]<<16|n[R+6]<<8|n[R+7];for(_=0;_<80;_++)if(o=M,i=U,s=I,a=D,c=k,l=x,u=W,h=q,f=B,p=F,g=K,v=V,y=G,b=H,S=65535&(O=$),T=O>>>16,P=65535&(C=L),j=C>>>16,S+=65535&(O=(V>>>14|k<<18)^(V>>>18|k<<14)^(k>>>9|V<<23)),T+=O>>>16,P+=65535&(C=(k>>>14|V<<18)^(k>>>18|V<<14)^(V>>>9|k<<23)),j+=C>>>16,S+=65535&(O=V&G^~V&H),T+=O>>>16,P+=65535&(C=k&x^~k&W),j+=C>>>16,S+=65535&(O=J[2*_+1]),T+=O>>>16,P+=65535&(C=J[2*_]),j+=C>>>16,C=N[_%16],T+=(O=A[_%16])>>>16,P+=65535&C,j+=C>>>16,P+=(T+=(S+=65535&O)>>>16)>>>16,S=65535&(O=m=65535&S|T<<16),T=O>>>16,P=65535&(C=E=65535&P|(j+=P>>>16)<<16),j=C>>>16,S+=65535&(O=(q>>>28|M<<4)^(M>>>2|q<<30)^(M>>>7|q<<25)),T+=O>>>16,P+=65535&(C=(M>>>28|q<<4)^(q>>>2|M<<30)^(q>>>7|M<<25)),j+=C>>>16,T+=(O=q&B^q&F^B&F)>>>16,P+=65535&(C=M&U^M&I^U&I),j+=C>>>16,d=65535&(P+=(T+=(S+=65535&O)>>>16)>>>16)|(j+=P>>>16)<<16,w=65535&S|T<<16,S=65535&(O=g),T=O>>>16,P=65535&(C=a),j=C>>>16,T+=(O=m)>>>16,P+=65535&(C=E),j+=C>>>16,U=o,I=i,D=s,k=a=65535&(P+=(T+=(S+=65535&O)>>>16)>>>16)|(j+=P>>>16)<<16,x=c,W=l,L=u,M=d,B=h,F=f,K=p,V=g=65535&S|T<<16,G=v,H=y,$=b,q=w,_%16==15)for(R=0;R<16;R++)C=N[R],S=65535&(O=A[R]),T=O>>>16,P=65535&C,j=C>>>16,C=N[(R+9)%16],S+=65535&(O=A[(R+9)%16]),T+=O>>>16,P+=65535&C,j+=C>>>16,E=N[(R+1)%16],S+=65535&(O=((m=A[(R+1)%16])>>>1|E<<31)^(m>>>8|E<<24)^(m>>>7|E<<25)),T+=O>>>16,P+=65535&(C=(E>>>1|m<<31)^(E>>>8|m<<24)^E>>>7),j+=C>>>16,E=N[(R+14)%16],T+=(O=((m=A[(R+14)%16])>>>19|E<<13)^(E>>>29|m<<3)^(m>>>6|E<<26))>>>16,P+=65535&(C=(E>>>19|m<<13)^(m>>>29|E<<3)^E>>>6),j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,N[R]=65535&P|j<<16,A[R]=65535&S|T<<16;S=65535&(O=q),T=O>>>16,P=65535&(C=M),j=C>>>16,C=e[0],T+=(O=t[0])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[0]=M=65535&P|j<<16,t[0]=q=65535&S|T<<16,S=65535&(O=B),T=O>>>16,P=65535&(C=U),j=C>>>16,C=e[1],T+=(O=t[1])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[1]=U=65535&P|j<<16,t[1]=B=65535&S|T<<16,S=65535&(O=F),T=O>>>16,P=65535&(C=I),j=C>>>16,C=e[2],T+=(O=t[2])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[2]=I=65535&P|j<<16,t[2]=F=65535&S|T<<16,S=65535&(O=K),T=O>>>16,P=65535&(C=D),j=C>>>16,C=e[3],T+=(O=t[3])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[3]=D=65535&P|j<<16,t[3]=K=65535&S|T<<16,S=65535&(O=V),T=O>>>16,P=65535&(C=k),j=C>>>16,C=e[4],T+=(O=t[4])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[4]=k=65535&P|j<<16,t[4]=V=65535&S|T<<16,S=65535&(O=G),T=O>>>16,P=65535&(C=x),j=C>>>16,C=e[5],T+=(O=t[5])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[5]=x=65535&P|j<<16,t[5]=G=65535&S|T<<16,S=65535&(O=H),T=O>>>16,P=65535&(C=W),j=C>>>16,C=e[6],T+=(O=t[6])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[6]=W=65535&P|j<<16,t[6]=H=65535&S|T<<16,S=65535&(O=$),T=O>>>16,P=65535&(C=L),j=C>>>16,C=e[7],T+=(O=t[7])>>>16,P+=65535&C,j+=C>>>16,j+=(P+=(T+=(S+=65535&O)>>>16)>>>16)>>>16,e[7]=L=65535&P|j<<16,t[7]=$=65535&S|T<<16,Q+=128,r-=128}return r}function z(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Y(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,p(s,n-8,a/536870912|0,a<<3),Y(o,i,s,n),r=0;r<8;r++)p(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();W(r,e[1],e[0]),W(h,n[1],n[0]),L(r,r,h),x(o,e[0],e[1]),x(h,n[0],n[1]),L(o,o,h),L(i,e[3],n[3]),L(i,i,u),L(s,e[2],n[2]),x(s,s,s),W(a,o,r),W(c,s,i),x(l,s,i),x(d,o,r),L(e[0],a,c),L(e[1],d,l),L(e[2],l,c),L(e[3],a,d)}function Z(e,t,n){var r;for(r=0;r<4;r++)M(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();B(i,n[2]),L(r,n[0],i),L(o,n[1],i),U(e,o),e[31]^=D(r)<<7}function te(e,t,n){var r,o;for(N(e[0],s),N(e[1],a),N(e[2],a),N(e[3],s),o=255;o>=0;--o)Z(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),Z(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];N(r[0],d),N(r[1],h),N(r[2],a),L(r[3],d,h),te(e,r,n)}function re(e,n,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||r(n,32),z(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,ne(a,s),ee(e,a),i=0;i<32;i++)n[i+32]=e[i];return 0}var oe=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*oe[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*oe[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*oe[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,n)}function ae(e,n,r,o){var i,s,a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];z(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(z(l,e.subarray(32),r+32),se(l),ne(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(z(c,e,r+64),se(c),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=c[i]*a[s];return ie(e.subarray(32),u),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),i=t(),c=t(),u=t(),d=t(),h=t();return N(e[2],a),k(e[1],n),q(i,e[1]),L(c,i,l),W(i,i,e[2]),x(c,e[2],c),q(u,c),q(d,u),L(h,d,u),L(r,h,i),L(r,r,c),F(r,r),L(r,r,i),L(r,r,c),L(r,r,c),L(e[0],r,c),q(o,e[0]),L(o,o,c),I(o,i)&&L(e[0],e[0],f),q(o,e[0]),L(o,o,c),I(o,i)?-1:(D(e[0])===n[31]>>7&&W(e[0],s,e[0]),L(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<r;i++)e[i]=n[i];for(i=0;i<32;i++)e[i+32]=o[i];if(z(u,e,r),se(u),te(d,h,u),ne(h,n.subarray(32)),X(d,h),ee(c,d),r-=64,y(n,0,c,0)){for(i=0;i<r;i++)e[i]=0;return-1}for(i=0;i<r;i++)e[i]=n[i+64];return r}var le,ue=64,de=32,he=64;function fe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function pe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ge(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:C,crypto_stream:R,crypto_stream_salsa20_xor:m,crypto_stream_salsa20:_,crypto_onetimeauth:S,crypto_onetimeauth_verify:T,crypto_verify_16:v,crypto_verify_32:y,crypto_secretbox:P,crypto_secretbox_open:j,crypto_scalarmult:K,crypto_scalarmult_base:V,crypto_box_beforenm:H,crypto_box_afternm:$,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),$(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return H(s,o,i),Q(e,t,n,r,s)},crypto_box_keypair:G,crypto_hash:z,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:de,crypto_sign_SECRETKEYBYTES:he,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:U,unpack25519:k,M:L,A:x,S:q,Z:W,pow2523:F,add:X,set25519:N,modL:ie,scalarmult:te,scalarbase:ne},e.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},e.secretbox=function(e,t,n){pe(e,t,n),fe(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return P(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){pe(e,t,n),fe(n,t);for(var r=new Uint8Array(16+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+16]=e[i];return r.length<32||0!==j(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(pe(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(pe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return V(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){pe(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return H(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return G(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(pe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return V(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(pe(e,t),t.length!==he)throw new Error("bad secret key size");var n=new Uint8Array(ue+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(pe(e,t),t.length!==de)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(ue),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(pe(e,t,n),t.length!==ue)throw new Error("bad signature size");if(n.length!==de)throw new Error("bad public key size");var r,o=new Uint8Array(ue+e.length),i=new Uint8Array(ue+e.length);for(r=0;r<ue;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+ue]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(de),t=new Uint8Array(he);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(pe(e),e.length!==he)throw new Error("bad secret key size");for(var t=new Uint8Array(de),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(pe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(de),n=new Uint8Array(he),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=de,e.sign.secretKeyLength=he,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){pe(e);var t=new Uint8Array(64);return z(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return pe(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===g(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG(function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)le.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];ge(r)}):(le=n(4355))&&le.randomBytes&&e.setPRNG(function(e,t){var n,r=le.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];ge(r)})}(e.exports?e.exports:self.nacl=self.nacl||{})},8900:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${n.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,n.prototype)}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},8928:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.isQaModeEnabled=t.enableQaMode=t.encodeTelegramUrlParameters=t.isTelegramUrl=t.checkRequiredWalletFeatures=t.toUserFriendlyAddress=t.SIGN_DATA_ERROR_CODES=t.SEND_TRANSACTION_ERROR_CODES=t.CONNECT_EVENT_ERROR_CODES=t.CONNECT_ITEM_ERROR_CODES=t.CHAIN=t.BrowserEventDispatcher=t.createVersionInfo=t.createResponseVersionEvent=t.createRequestVersionEvent=t.createDataSignedEvent=t.createDataSigningFailedEvent=t.createDataSentForSignatureEvent=t.createTransactionSignedEvent=t.createTransactionSigningFailedEvent=t.createTransactionSentForSignatureEvent=t.createDisconnectionEvent=t.createConnectionRestoringCompletedEvent=t.createConnectionRestoringErrorEvent=t.createConnectionRestoringStartedEvent=t.createConnectionCompletedEvent=t.createConnectionErrorEvent=t.createConnectionStartedEvent=t.WalletsListManager=t.default=void 0,o(n(3122),t),o(n(7663),t),o(n(3842),t);var i=n(3122);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(5445);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(1934);Object.defineProperty(t,"createConnectionStartedEvent",{enumerable:!0,get:function(){return a.createConnectionStartedEvent}}),Object.defineProperty(t,"createConnectionErrorEvent",{enumerable:!0,get:function(){return a.createConnectionErrorEvent}}),Object.defineProperty(t,"createConnectionCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionCompletedEvent}}),Object.defineProperty(t,"createConnectionRestoringStartedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringStartedEvent}}),Object.defineProperty(t,"createConnectionRestoringErrorEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringErrorEvent}}),Object.defineProperty(t,"createConnectionRestoringCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringCompletedEvent}}),Object.defineProperty(t,"createDisconnectionEvent",{enumerable:!0,get:function(){return a.createDisconnectionEvent}}),Object.defineProperty(t,"createTransactionSentForSignatureEvent",{enumerable:!0,get:function(){return a.createTransactionSentForSignatureEvent}}),Object.defineProperty(t,"createTransactionSigningFailedEvent",{enumerable:!0,get:function(){return a.createTransactionSigningFailedEvent}}),Object.defineProperty(t,"createTransactionSignedEvent",{enumerable:!0,get:function(){return a.createTransactionSignedEvent}}),Object.defineProperty(t,"createDataSentForSignatureEvent",{enumerable:!0,get:function(){return a.createDataSentForSignatureEvent}}),Object.defineProperty(t,"createDataSigningFailedEvent",{enumerable:!0,get:function(){return a.createDataSigningFailedEvent}}),Object.defineProperty(t,"createDataSignedEvent",{enumerable:!0,get:function(){return a.createDataSignedEvent}}),Object.defineProperty(t,"createRequestVersionEvent",{enumerable:!0,get:function(){return a.createRequestVersionEvent}}),Object.defineProperty(t,"createResponseVersionEvent",{enumerable:!0,get:function(){return a.createResponseVersionEvent}}),Object.defineProperty(t,"createVersionInfo",{enumerable:!0,get:function(){return a.createVersionInfo}});var c=n(4278);Object.defineProperty(t,"BrowserEventDispatcher",{enumerable:!0,get:function(){return c.BrowserEventDispatcher}});var l=n(7321);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return l.CHAIN}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_ITEM_ERROR_CODES}}),Object.defineProperty(t,"CONNECT_EVENT_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_EVENT_ERROR_CODES}}),Object.defineProperty(t,"SEND_TRANSACTION_ERROR_CODES",{enumerable:!0,get:function(){return l.SEND_TRANSACTION_ERROR_CODES}}),Object.defineProperty(t,"SIGN_DATA_ERROR_CODES",{enumerable:!0,get:function(){return l.SIGN_DATA_ERROR_CODES}});var u=n(8350);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return u.toUserFriendlyAddress}});var d=n(2242);Object.defineProperty(t,"checkRequiredWalletFeatures",{enumerable:!0,get:function(){return d.checkRequiredWalletFeatures}});var h=n(2003);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return h.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.encodeTelegramUrlParameters}});var f=n(4496);Object.defineProperty(t,"enableQaMode",{enumerable:!0,get:function(){return f.enableQaMode}}),Object.defineProperty(t,"isQaModeEnabled",{enumerable:!0,get:function(){return f.isQaModeEnabled}})},8941:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},8949:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=function(e,t){const n=null==t?void 0:t.timeout,s=null==t?void 0:t.signal,a=(0,i.createAbortController)(s);return new Promise((t,i)=>r(this,void 0,void 0,function*(){if(a.signal.aborted)return void i(new o.TonConnectError("Operation aborted"));let r;void 0!==n&&(r=setTimeout(()=>{a.abort(),i(new o.TonConnectError(`Timeout after ${n}ms`))},n)),a.signal.addEventListener("abort",()=>{clearTimeout(r),i(new o.TonConnectError("Operation aborted"))},{once:!0});const s={timeout:n,abort:a.signal};yield e((...e)=>{clearTimeout(r),t(...e)},()=>{clearTimeout(r),i()},s)}))};const o=n(3842),i=n(5148)},8980:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(4648);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},9475:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(8900);class o extends r.TonConnectError{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotConnectedError=o},9773:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(e,t){return r(this,void 0,void 0,function*(){return new Promise((n,r)=>{var i,s;if(null===(i=null==t?void 0:t.signal)||void 0===i?void 0:i.aborted)return void r(new o.TonConnectError("Delay aborted"));const a=setTimeout(()=>n(),e);null===(s=null==t?void 0:t.signal)||void 0===s||s.addEventListener("abort",()=>{clearTimeout(a),r(new o.TonConnectError("Delay aborted"))})})})};const o=n(3842)}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(8928);TonConnectSDK=n})();
1
+ var TonConnectSDK;(()=>{var e={48:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WrongAddressError=o},119:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestContentErrorError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestContentErrorError=o},151:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.isQaModeEnabled=t.enableQaMode=t.encodeTelegramUrlParameters=t.isTelegramUrl=t.checkRequiredWalletFeatures=t.toUserFriendlyAddress=t.SIGN_DATA_ERROR_CODES=t.SEND_TRANSACTION_ERROR_CODES=t.CONNECT_EVENT_ERROR_CODES=t.CONNECT_ITEM_ERROR_CODES=t.SessionCrypto=t.CHAIN=t.BrowserEventDispatcher=t.createVersionInfo=t.createResponseVersionEvent=t.createRequestVersionEvent=t.createDataSignedEvent=t.createDataSigningFailedEvent=t.createDataSentForSignatureEvent=t.createTransactionSignedEvent=t.createTransactionSigningFailedEvent=t.createTransactionSentForSignatureEvent=t.createDisconnectionEvent=t.createConnectionRestoringCompletedEvent=t.createConnectionRestoringErrorEvent=t.createConnectionRestoringStartedEvent=t.createConnectionCompletedEvent=t.createConnectionErrorEvent=t.createConnectionStartedEvent=t.WalletsListManager=t.default=void 0,o(n(2361),t),o(n(3062),t),o(n(2931),t);var i=n(2361);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return i.TonConnect}});var s=n(9660);Object.defineProperty(t,"WalletsListManager",{enumerable:!0,get:function(){return s.WalletsListManager}});var a=n(613);Object.defineProperty(t,"createConnectionStartedEvent",{enumerable:!0,get:function(){return a.createConnectionStartedEvent}}),Object.defineProperty(t,"createConnectionErrorEvent",{enumerable:!0,get:function(){return a.createConnectionErrorEvent}}),Object.defineProperty(t,"createConnectionCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionCompletedEvent}}),Object.defineProperty(t,"createConnectionRestoringStartedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringStartedEvent}}),Object.defineProperty(t,"createConnectionRestoringErrorEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringErrorEvent}}),Object.defineProperty(t,"createConnectionRestoringCompletedEvent",{enumerable:!0,get:function(){return a.createConnectionRestoringCompletedEvent}}),Object.defineProperty(t,"createDisconnectionEvent",{enumerable:!0,get:function(){return a.createDisconnectionEvent}}),Object.defineProperty(t,"createTransactionSentForSignatureEvent",{enumerable:!0,get:function(){return a.createTransactionSentForSignatureEvent}}),Object.defineProperty(t,"createTransactionSigningFailedEvent",{enumerable:!0,get:function(){return a.createTransactionSigningFailedEvent}}),Object.defineProperty(t,"createTransactionSignedEvent",{enumerable:!0,get:function(){return a.createTransactionSignedEvent}}),Object.defineProperty(t,"createDataSentForSignatureEvent",{enumerable:!0,get:function(){return a.createDataSentForSignatureEvent}}),Object.defineProperty(t,"createDataSigningFailedEvent",{enumerable:!0,get:function(){return a.createDataSigningFailedEvent}}),Object.defineProperty(t,"createDataSignedEvent",{enumerable:!0,get:function(){return a.createDataSignedEvent}}),Object.defineProperty(t,"createRequestVersionEvent",{enumerable:!0,get:function(){return a.createRequestVersionEvent}}),Object.defineProperty(t,"createResponseVersionEvent",{enumerable:!0,get:function(){return a.createResponseVersionEvent}}),Object.defineProperty(t,"createVersionInfo",{enumerable:!0,get:function(){return a.createVersionInfo}});var c=n(6895);Object.defineProperty(t,"BrowserEventDispatcher",{enumerable:!0,get:function(){return c.BrowserEventDispatcher}});var l=n(7321);Object.defineProperty(t,"CHAIN",{enumerable:!0,get:function(){return l.CHAIN}}),Object.defineProperty(t,"SessionCrypto",{enumerable:!0,get:function(){return l.SessionCrypto}}),Object.defineProperty(t,"CONNECT_ITEM_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_ITEM_ERROR_CODES}}),Object.defineProperty(t,"CONNECT_EVENT_ERROR_CODES",{enumerable:!0,get:function(){return l.CONNECT_EVENT_ERROR_CODES}}),Object.defineProperty(t,"SEND_TRANSACTION_ERROR_CODES",{enumerable:!0,get:function(){return l.SEND_TRANSACTION_ERROR_CODES}}),Object.defineProperty(t,"SIGN_DATA_ERROR_CODES",{enumerable:!0,get:function(){return l.SIGN_DATA_ERROR_CODES}});var u=n(8409);Object.defineProperty(t,"toUserFriendlyAddress",{enumerable:!0,get:function(){return u.toUserFriendlyAddress}});var d=n(3317);Object.defineProperty(t,"checkRequiredWalletFeatures",{enumerable:!0,get:function(){return d.checkRequiredWalletFeatures}});var h=n(2192);Object.defineProperty(t,"isTelegramUrl",{enumerable:!0,get:function(){return h.isTelegramUrl}}),Object.defineProperty(t,"encodeTelegramUrlParameters",{enumerable:!0,get:function(){return h.encodeTelegramUrlParameters}});var f=n(6351);Object.defineProperty(t,"enableQaMode",{enumerable:!0,get:function(){return f.enableQaMode}}),Object.defineProperty(t,"isQaModeEnabled",{enumerable:!0,get:function(){return f.isQaModeEnabled}})},166:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.signDataParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SIGN_DATA_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SIGN_DATA_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SIGN_DATA_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SIGN_DATA_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return e.result}}t.signDataParser=new c},332:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Storage was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.LocalstorageNotFoundError=o},359:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletAlreadyConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletAlreadyConnectedError=o},379:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},492:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},607:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAbortController=function(e){const t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}},613:(e,t)=>{"use strict";function n(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function r(e,t){var r,o,i,s,a,c,l,u;const d=(null===(r=null==t?void 0:t.connectItems)||void 0===r?void 0:r.tonProof)&&"proof"in t.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:null!==(i=null===(o=null==t?void 0:t.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,wallet_type:null!==(s=null==t?void 0:t.device.appName)&&void 0!==s?s:null,wallet_version:null!==(a=null==t?void 0:t.device.appVersion)&&void 0!==a?a:null,auth_type:d,custom_data:Object.assign({chain_id:null!==(l=null===(c=null==t?void 0:t.account)||void 0===c?void 0:c.chain)&&void 0!==l?l:null,provider:null!==(u=null==t?void 0:t.provider)&&void 0!==u?u:null},n(e))}}function o(e,t){var n,r,o,i;return{valid_until:null!==(n=String(t.validUntil))&&void 0!==n?n:null,from:null!==(i=null!==(r=t.from)&&void 0!==r?r:null===(o=null==e?void 0:e.account)||void 0===o?void 0:o.address)&&void 0!==i?i:null,messages:t.messages.map(e=>{var t,n;return{address:null!==(t=e.address)&&void 0!==t?t:null,amount:null!==(n=e.amount)&&void 0!==n?n:null}})}}Object.defineProperty(t,"__esModule",{value:!0}),t.createRequestVersionEvent=function(){return{type:"request-version"}},t.createResponseVersionEvent=function(e){return{type:"response-version",version:e}},t.createVersionInfo=n,t.createConnectionStartedEvent=function(e){return{type:"connection-started",custom_data:n(e)}},t.createConnectionCompletedEvent=function(e,t){return Object.assign({type:"connection-completed",is_success:!0},r(e,t))},t.createConnectionErrorEvent=function(e,t,r){return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=r?r:null,custom_data:n(e)}},t.createConnectionRestoringStartedEvent=function(e){return{type:"connection-restoring-started",custom_data:n(e)}},t.createConnectionRestoringCompletedEvent=function(e,t){return Object.assign({type:"connection-restoring-completed",is_success:!0},r(e,t))},t.createConnectionRestoringErrorEvent=function(e,t){return{type:"connection-restoring-error",is_success:!1,error_message:t,custom_data:n(e)}},t.createTransactionSentForSignatureEvent=function(e,t,n){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},r(e,t)),o(t,n))},t.createTransactionSignedEvent=function(e,t,n,i){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:i.boc},r(e,t)),o(t,n))},t.createTransactionSigningFailedEvent=function(e,t,n,i,s){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:i,error_code:null!=s?s:null},r(e,t)),o(t,n))},t.createDataSentForSignatureEvent=function(e,t,n){return Object.assign({type:"sign-data-request-initiated",data:n},r(e,t))},t.createDataSignedEvent=function(e,t,n,o){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:o},r(e,t))},t.createDataSigningFailedEvent=function(e,t,n,o,i){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:o,error_code:null!=i?i:null},r(e,t))},t.createDisconnectionEvent=function(e,t,n){return Object.assign({type:"disconnection",scope:n},r(e,t))}},939:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletMissingRequiredFeaturesError=o},1055:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=t.BadRequestError=void 0;var r=n(7688);Object.defineProperty(t,"BadRequestError",{enumerable:!0,get:function(){return r.BadRequestError}});var o=n(1739);Object.defineProperty(t,"UnknownAppError",{enumerable:!0,get:function(){return o.UnknownAppError}})},1203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logDebug=function(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logError=function(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(e){}},t.logWarning=function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(e){}}},1689:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectError=void 0;class n extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${n.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,n.prototype)}}t.TonConnectError=n,n.prefix="[TON_CONNECT_SDK_ERROR]"},1739:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownAppError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownAppError=o},2172:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DappMetadataError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.DappMetadataError=o},2192:(e,t)=>{"use strict";function n(e){return"/"===e.slice(-1)?e.slice(0,-1):e}Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlLastSlash=n,t.addPathToUrl=function(e,t){return n(e)+"/"+t},t.isTelegramUrl=function(e){if(!e)return!1;const t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname},t.encodeTelegramUrlParameters=function(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}},2209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PROTOCOL_VERSION=void 0,t.PROTOCOL_VERSION=2},2301:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ManifestNotFoundError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ManifestNotFoundError=o},2361:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnect=void 0;const i=n(7321),s=n(2172),a=n(119),c=n(2301),l=n(1689),u=n(6069),d=n(4814),h=n(7070),f=n(9509),p=n(166),g=n(6842),v=n(2636),y=n(4029),b=n(6344),w=n(5418),m=n(9660),E=n(3317),_=n(4241),O=n(1203),R=n(607),C=n(4927),S=n(3713),T=n(9651),P=n(6351);class j{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null===(e=this._wallet)||void 0===e?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(e=>e(this._wallet))}constructor(e){if(this.walletsList=new m.WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(null==e?void 0:e.manifestUrl)||(0,w.getWebPageManifest)(),storage:(null==e?void 0:e.storage)||new b.DefaultStorage},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.walletsList=new m.WalletsListManager({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs}),this.tracker=new C.TonConnectTracker({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectSdkVersion:S.tonConnectSdkVersion}),!this.dappSettings.manifestUrl)throw new s.DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new y.BridgeConnectionStorage(this.dappSettings.storage),(null==e?void 0:e.disableAutoPauseConnection)||this.addWindowFocusAndBlurSubscriptions()}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,t){return this.statusChangeSubscriptions.push(e),t&&this.statusChangeErrorSubscriptions.push(t),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(t=>t!==e),t&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(e=>e!==t))}}connect(e,t){var n,r;const o={};if("object"==typeof t&&"tonProof"in t&&(o.request=t),"object"==typeof t&&("openingDeadlineMS"in t||"signal"in t||"request"in t)&&(o.request=null==t?void 0:t.request,o.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,o.signal=null==t?void 0:t.signal),o.request){const e=(0,T.validateConnectAdditionalRequest)(o.request);if(e){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("ConnectAdditionalRequest validation failed: "+e);console.error("ConnectAdditionalRequest validation failed: "+e)}}if(this.connected)throw new u.WalletAlreadyConnectedError;const i=(0,R.createAbortController)(null==o?void 0:o.signal);if(null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,i.signal.aborted)throw new l.TonConnectError("Connection was aborted");return null===(r=this.provider)||void 0===r||r.closeConnection(),this.provider=this.createProvider(e),i.signal.addEventListener("abort",()=>{var e;null===(e=this.provider)||void 0===e||e.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(null==o?void 0:o.request),{openingDeadlineMS:null==o?void 0:o.openingDeadlineMS,signal:i.signal})}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;this.tracker.trackConnectionRestoringStarted();const o=(0,R.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=o,o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");const[i,s]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");let a=null;try{switch(i){case"http":a=yield g.BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":a=yield v.InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(!s)return;a=this.createProvider(s)}}catch(e){return this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),null==a||a.closeConnection(),void(a=null)}if(o.signal.aborted)return null==a||a.closeConnection(),void this.tracker.trackConnectionRestoringError("Connection restoring was aborted");if(!a)return(0,O.logError)("Provider is not restored"),void this.tracker.trackConnectionRestoringError("Provider is not restored");null===(n=this.provider)||void 0===n||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const c=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),null==a||a.closeConnection(),a=null};o.signal.addEventListener("abort",c);const l=(0,_.callForSuccess)(t=>r(this,void 0,void 0,function*(){yield null==a?void 0:a.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal}),o.signal.removeEventListener("abort",c),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),u=new Promise(e=>setTimeout(()=>e(),12e3));return Promise.race([l,u])})}sendTransaction(e,t){return r(this,void 0,void 0,function*(){const n={};"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal);const r=(0,T.validateSendTransactionRequest)(e);if(r){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SendTransactionRequest validation failed: "+r);console.error("SendTransactionRequest validation failed: "+r)}const i=(0,R.createAbortController)(null==n?void 0:n.signal);if(i.signal.aborted)throw new l.TonConnectError("Transaction sending was aborted");this.checkConnection();const s=e.messages.length,a=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);(0,E.checkSendTransactionSupport)(this.wallet.device.features,{requiredMessagesNumber:s,requireExtraCurrencies:a}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:c,messages:u}=e,d=o(e,["validUntil","messages"]),h=e.from||this.account.address,p=e.network||this.account.chain,g=yield this.provider.sendRequest(f.sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},d),{from:h,network:p,valid_until:c,messages:u.map(e=>{var{extraCurrency:t}=e,n=o(e,["extraCurrency"]);return Object.assign(Object.assign({},n),{extra_currency:t})})})),{onRequestSent:n.onRequestSent,signal:i.signal});if(f.sendTransactionParser.isError(g))return this.tracker.trackTransactionSigningFailed(this.wallet,e,g.error.message,g.error.code),f.sendTransactionParser.parseAndThrowError(g);const v=f.sendTransactionParser.convertFromRpcResponse(g);return this.tracker.trackTransactionSigned(this.wallet,e,v),v})}signData(e,t){return r(this,void 0,void 0,function*(){const n=(0,R.createAbortController)(null==t?void 0:t.signal);if(n.signal.aborted)throw new l.TonConnectError("data sending was aborted");const r=(0,T.validateSignDataPayload)(e);if(r){if(!(0,P.isQaModeEnabled)())throw new l.TonConnectError("SignDataPayload validation failed: "+r);console.error("SignDataPayload validation failed: "+r)}this.checkConnection(),(0,E.checkSignDataSupport)(this.wallet.device.features,{requiredTypes:[e.type]}),this.tracker.trackDataSentForSignature(this.wallet,e);const o=e.from||this.account.address,i=e.network||this.account.chain,s=yield this.provider.sendRequest(p.signDataParser.convertToRpcRequest(Object.assign(Object.assign({},e),{from:o,network:i})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:n.signal});if(p.signDataParser.isError(s))return this.tracker.trackDataSigningFailed(this.wallet,e,s.error.message,s.error.code),p.signDataParser.parseAndThrowError(s);const a=p.signDataParser.convertFromRpcResponse(s);return this.tracker.trackDataSigned(this.wallet,e,a),a})}disconnect(e){return r(this,void 0,void 0,function*(){var t;if(!this.connected)throw new u.WalletNotConnectedError;const n=(0,R.createAbortController)(null==e?void 0:e.signal),r=this.abortController;if(this.abortController=n,n.signal.aborted)throw new l.TonConnectError("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield null===(t=this.provider)||void 0===t?void 0:t.disconnect({signal:n.signal}),null==r||r.abort()})}getSessionId(){return r(this,void 0,void 0,function*(){if(!this.provider||!this.connected)return null;try{const e=yield this.bridgeConnectionStorage.getConnection();return e&&"injected"!==e.type?"sessionCrypto"in e?e.sessionCrypto.sessionId:e.session.sessionCrypto.sessionId:null}catch(e){return null}})}pauseConnection(){var e;"http"===(null===(e=this.provider)||void 0===e?void 0:e.type)&&this.provider.pause()}unPauseConnection(){var e;return"http"!==(null===(e=this.provider)||void 0===e?void 0:e.type)?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=(0,w.getDocument)();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(e){(0,O.logError)("Cannot subscribe to the document.visibilitychange: ",e)}}createProvider(e){let t;return t=!Array.isArray(e)&&(0,d.isWalletConnectionSourceJS)(e)?new v.InjectedProvider(this.dappSettings.storage,e.jsBridgeKey):new g.BridgeProvider(this.dappSettings.storage,e),t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.tracker.trackConnectionError(e.payload.message,e.payload.code);const t=h.connectErrorsParser.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(e){var t;const n=e.items.find(e=>"ton_addr"===e.name),r=e.items.find(e=>"ton_proof"===e.name);if(!n)throw new l.TonConnectError("ton_addr connection item was not found");if(!(0,E.checkRequiredWalletFeatures)(e.device.features,this.walletsRequiredFeatures))return null===(t=this.provider)||void 0===t||t.disconnect(),void this.onWalletConnectError(new u.WalletMissingRequiredFeaturesError("Wallet does not support required features",{cause:{connectEvent:e}}));const o={device:e.device,provider:this.provider.type,account:{address:n.address,chain:n.network,walletStateInit:n.walletStateInit,publicKey:n.publicKey}};if(r){const e=(0,T.validateTonProofItemReply)(r);let t;if(e)(0,P.isQaModeEnabled)()&&console.error("TonProofItem validation failed: "+e),t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:e}};else try{if("proof"in r)t={name:"ton_proof",proof:{timestamp:r.proof.timestamp,domain:{lengthBytes:r.proof.domain.lengthBytes,value:r.proof.domain.value},payload:r.proof.payload,signature:r.proof.signature}};else{if(!("error"in r))throw new l.TonConnectError("Invalid data format");t={name:"ton_proof",error:{code:r.error.code,message:r.error.message}}}}catch(e){t={name:"ton_proof",error:{code:i.CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,message:"Invalid data format"}}}o.connectItems={tonProof:t}}this.wallet=o,this.tracker.trackConnectionCompleted(o)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),(0,O.logDebug)(e),e instanceof c.ManifestNotFoundError||e instanceof a.ManifestContentErrorError)throw(0,O.logError)(e),e}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new u.WalletNotConnectedError}createConnectRequest(e){const t=[{name:"ton_addr"}];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}t.TonConnect=j,j.walletsList=new m.WalletsListManager,j.isWalletInjected=e=>v.InjectedProvider.isWalletInjected(e),j.isInsideWalletBrowser=e=>v.InjectedProvider.isInsideWalletBrowser(e)},2636:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectedProvider=void 0;const o=n(3809),i=n(3674),s=n(4029),a=n(5418),c=n(2209),l=n(1203);class u{static fromStorage(e){return r(this,void 0,void 0,function*(){const t=new s.BridgeConnectionStorage(e),n=yield t.getInjectedConnection();return new u(e,n.jsBridgeKey)})}static isWalletInjected(e){return u.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!u.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(0,a.getWindowEntries)().filter(([e,t])=>(0,i.isJSBridgeWithMetadata)(t)).map(([e,t])=>({name:t.tonconnect.walletInfo.name,appName:t.tonconnect.walletInfo.app_name,aboutUrl:t.tonconnect.walletInfo.about_url,imageUrl:t.tonconnect.walletInfo.image,tondns:t.tonconnect.walletInfo.tondns,jsBridgeKey:e,injected:!0,embedded:t.tonconnect.isWalletBrowser,platforms:t.tonconnect.walletInfo.platforms,features:t.tonconnect.walletInfo.features})):[]}static isWindowContainsWallet(e,t){return!!e&&t in e&&"object"==typeof e[t]&&"tonconnect"in e[t]}constructor(e,t){this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=u.window;if(!u.isWindowContainsWallet(n,t))throw new o.WalletNotInjectedError;this.connectionStorage=new s.BridgeConnectionStorage(e),this.injectedWallet=n[t].tonconnect}connect(e){this._connect(c.PROTOCOL_VERSION,e)}restoreConnection(){return r(this,void 0,void 0,function*(){try{(0,l.logDebug)("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();(0,l.logDebug)("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions(),this.listeners.forEach(t=>t(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return r(this,void 0,void 0,function*(){return new Promise(e=>{const t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){(0,l.logDebug)(e),this.sendRequest({method:"disconnect",params:[]},t)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null===(e=this.unsubscribeCallback)||void 0===e||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return r(this,void 0,void 0,function*(){var n;const r={};"function"==typeof t?r.onRequestSent=t:(r.onRequestSent=null==t?void 0:t.onRequestSent,r.signal=null==t?void 0:t.signal);const o=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,l.logDebug)("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:o}));const i=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:o}));return i.then(e=>(0,l.logDebug)("Wallet message received:",e)),null===(n=null==r?void 0:r.onRequestSent)||void 0===n||n.call(r),i})}_connect(e,t){return r(this,void 0,void 0,function*(){try{(0,l.logDebug)(`Injected Provider connect request: protocolVersion: ${e}, message:`,t);const n=yield this.injectedWallet.connect(e,t);(0,l.logDebug)("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(e=>e(n))}catch(e){(0,l.logDebug)("Injected Provider connect error:",e);const t={event:"connect_error",payload:{code:0,message:null==e?void 0:e.toString()}};this.listeners.forEach(e=>e(t))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(e=>{(0,l.logDebug)("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(e)),"disconnect"===e.event&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}t.InjectedProvider=u,u.window=(0,a.getWindow)()},2931:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.TonConnectError=void 0,o(n(8240),t),o(n(6069),t),o(n(8705),t),o(n(8372),t),o(n(4464),t),o(n(4381),t);var i=n(1689);Object.defineProperty(t,"TonConnectError",{enumerable:!0,get:function(){return i.TonConnectError}});var s=n(5137);Object.defineProperty(t,"UnknownError",{enumerable:!0,get:function(){return s.UnknownError}})},3062:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9746),t),o(n(6403),t)},3088:(e,t)=>{"use strict";function n(e,t){return!(!e||"object"!=typeof e)&&t.every(t=>t in e)}Object.defineProperty(t,"__esModule",{value:!0}),t.hasProperty=function(e,t){return n(e,[t])},t.hasProperties=n},3317:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkSendTransactionSupport=function(e,t){const n=e.includes("SendTransaction"),s=i(e,"SendTransaction"),a={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!s)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(t.requireExtraCurrencies&&(!s||!s.extraCurrencySupported))throw new o.WalletNotSupportFeatureError("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}});if(s&&void 0!==s.maxMessages){if(s.maxMessages<t.requiredMessagesNumber)throw new o.WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${s.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:a}}})}else(0,r.logWarning)("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")},t.checkSignDataSupport=function(e,t){const n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);if(!n)throw new o.WalletNotSupportFeatureError("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});const r=t.requiredTypes.filter(e=>!n.types.includes(e));if(r.length)throw new o.WalletNotSupportFeatureError(`Wallet doesn't support required SignData types: ${r.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:r}}}})},t.checkRequiredWalletFeatures=function(e,t){if("object"!=typeof t)return!0;const{sendTransaction:n,signData:r}=t;if(n){const t=i(e,"SendTransaction");if(!t)return!1;if(!function(e,t){const n=void 0===t.minMessages||t.minMessages<=e.maxMessages,r=!t.extraCurrencyRequired||e.extraCurrencySupported;return!(!n||!r)}(t,n))return!1}if(r){const t=i(e,"SignData");if(!t)return!1;if(!function(e,t){return t.types.every(t=>e.types.includes(t))}(t,r))return!1}return!0};const r=n(1203),o=n(6069);function i(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}},3586:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.ParseHexError=o},3674:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isJSBridgeWithMetadata=function(e){try{return!(!(0,r.hasProperty)(e,"tonconnect")||!(0,r.hasProperty)(e.tonconnect,"walletInfo"))&&(0,r.hasProperties)(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(e){return!1}};const r=n(3088)},3713:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tonConnectSdkVersion=void 0,t.tonConnectSdkVersion="3.3.0-beta.3"},3762:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=function(e,t){const n=null==t?void 0:t.timeout,s=null==t?void 0:t.signal,a=(0,i.createAbortController)(s);return new Promise((t,i)=>r(this,void 0,void 0,function*(){if(a.signal.aborted)return void i(new o.TonConnectError("Operation aborted"));let r;void 0!==n&&(r=setTimeout(()=>{a.abort(),i(new o.TonConnectError(`Timeout after ${n}ms`))},n)),a.signal.addEventListener("abort",()=>{clearTimeout(r),i(new o.TonConnectError("Operation aborted"))},{once:!0});const s={timeout:n,abort:a.signal};yield e((...e)=>{clearTimeout(r),t(...e)},()=>{clearTimeout(r),i()},s)}))};const o=n(2931),i=n(607)},3809:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotInjectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotInjectedError=o},4029:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeConnectionStorage=void 0;const o=n(7321),i=n(2931),s=n(8926);t.BridgeConnectionStorage=class{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return r(this,void 0,void 0,function*(){if("injected"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!(0,s.isPendingConnectionHttp)(e)){const t={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},n={type:"http",connectEvent:e.connectEvent,session:t,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(n))}const t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return r(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const t=JSON.parse(e);if("injected"===t.type)return t;if(!(0,s.isPendingConnectionHttpRaw)(t)){const e=new o.SessionCrypto(t.session.sessionKeyPair);return{type:"http",connectEvent:t.connectEvent,lastWalletEventId:t.lastWalletEventId,nextRpcRequestId:t.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:t.session.bridgeUrl,walletPublicKey:t.session.walletPublicKey}}}return(0,s.isExpiredPendingConnectionHttpRaw)(t)?(yield this.removeConnection(),null):{type:"http",sessionCrypto:new o.SessionCrypto(t.sessionCrypto),connectionSource:t.connectionSource}})}getHttpConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read HTTP connection source while nothing is stored");if("injected"===e.type)throw new i.TonConnectError("Trying to read HTTP connection source while injected connection is stored");if(!(0,s.isPendingConnectionHttp)(e))throw new i.TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new i.TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if("http"===(null==e?void 0:e.type))throw new i.TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return r(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return r(this,void 0,void 0,function*(){const t=yield this.getConnection();if(t&&"http"===t.type&&!(0,s.isPendingConnectionHttp)(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return r(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}},4241:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.callForSuccess=function(e,t){return r(this,void 0,void 0,function*(){var n,r;const a=null!==(n=null==t?void 0:t.attempts)&&void 0!==n?n:10,c=null!==(r=null==t?void 0:t.delayMs)&&void 0!==r?r:200,l=(0,s.createAbortController)(null==t?void 0:t.signal);if("function"!=typeof e)throw new i.TonConnectError("Expected a function, got "+typeof e);let u,d=0;for(;d<a;){if(l.signal.aborted)throw new i.TonConnectError(`Aborted after attempts ${d}`);try{return yield e({signal:l.signal})}catch(e){u=e,d++,d<a&&(yield(0,o.delay)(c))}}throw u})};const o=n(6878),i=n(2931),s=n(607)},4263:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UserRejectsError=o},4355:()=>{},4381:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ParseHexError=void 0;var r=n(3586);Object.defineProperty(t,"ParseHexError",{enumerable:!0,get:function(){return r.ParseHexError}})},4464:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrongAddressError=void 0;var r=n(48);Object.defineProperty(t,"WrongAddressError",{enumerable:!0,get:function(){return r.WrongAddressError}})},4475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RpcParser=void 0,t.RpcParser=class{isError(e){return"error"in e}}},4814:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletConnectionSourceJS=function(e){return"jsBridgeKey"in e}},4898:()=>{},4927:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.TonConnectTracker=void 0;const o=n(613),i=n(6895);t.TonConnectTracker=class{get version(){return(0,o.createVersionInfo)({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){var t;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null!==(t=null==e?void 0:e.eventDispatcher)&&void 0!==t?t:new i.BrowserEventDispatcher,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return r(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return r(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>r(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",(0,o.createResponseVersionEvent)(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return r(this,void 0,void 0,function*(){return new Promise((e,t)=>r(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",t=>{e(t.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",(0,o.createRequestVersionEvent)())}catch(e){t(e)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(e){}}trackConnectionStarted(...e){try{const t=(0,o.createConnectionStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionCompleted(...e){try{const t=(0,o.createConnectionCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionError(...e){try{const t=(0,o.createConnectionErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringStarted(...e){try{const t=(0,o.createConnectionRestoringStartedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringCompleted(...e){try{const t=(0,o.createConnectionRestoringCompletedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringError(...e){try{const t=(0,o.createConnectionRestoringErrorEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDisconnection(...e){try{const t=(0,o.createDisconnectionEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSentForSignature(...e){try{const t=(0,o.createTransactionSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigned(...e){try{const t=(0,o.createTransactionSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigningFailed(...e){try{const t=(0,o.createTransactionSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSentForSignature(...e){try{const t=(0,o.createDataSentForSignatureEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigned(...e){try{const t=(0,o.createDataSignedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigningFailed(...e){try{const t=(0,o.createDataSigningFailedEvent)(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}}},5137:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=void 0;const r=n(1689);class o extends r.TonConnectError{constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.UnknownError=o},5166:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5418:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getWindow=i,t.tryGetWindowKeys=function(){const e=i();if(!e)return[];try{return Object.keys(e)}catch(e){return[]}},t.getDocument=function(){if("undefined"!=typeof document)return document},t.getWebPageManifest=function(){var e;const t=null===(e=i())||void 0===e?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""},t.tryGetLocalStorage=function(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if("undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node)throw new o.TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return r.InMemoryStorage.getInstance()},t.getDomain=function(){try{return"undefined"!=typeof window&&window.location?window.location.hostname:null}catch(e){return null}},t.getWindowEntries=function(){const e=i();if(!e)return[];try{return Object.entries(e)}catch(e){return[]}};const r=n(5801),o=n(2931);function i(){if("undefined"!=typeof window)return window}},5465:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotSupportFeatureError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotSupportFeatureError=o},5496:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7005),t)},5801:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryStorage=void 0;class n{static getInstance(){return n.instance||(n.instance=new n),n.instance}constructor(){this.storage={}}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var t;return null!==(t=this.storage[e])&&void 0!==t?t:null}key(e){var t;const n=Object.keys(this.storage);return e<0||e>=n.length?null:null!==(t=n[e])&&void 0!==t?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}}t.InMemoryStorage=n},5858:function(e){!function(t,n){"use strict";e.exports?e.exports=n():(t.nacl||(t.nacl={}),t.nacl.util=n())}(this,function(){"use strict";var e={};function t(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r},e.encodeUTF8=function(e){var t,n=[];for(t=0;t<e.length;t++)n.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(n.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(e.encodeBase64=function(e){return Buffer.from(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(Buffer.from(e,"base64"),0))}):(e.encodeBase64=function(e){return new Buffer(e).toString("base64")},e.decodeBase64=function(e){return t(e),new Uint8Array(Array.prototype.slice.call(new Buffer(e,"base64"),0))}):(e.encodeBase64=function(e){var t,n=[],r=e.length;for(t=0;t<r;t++)n.push(String.fromCharCode(e[t]));return btoa(n.join(""))},e.decodeBase64=function(e){t(e);var n,r=atob(e),o=new Uint8Array(r.length);for(n=0;n<r.length;n++)o[n]=r.charCodeAt(n);return o}),e})},6069:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletMissingRequiredFeaturesError=t.WalletNotSupportFeatureError=t.WalletNotInjectedError=t.WalletNotConnectedError=t.WalletAlreadyConnectedError=void 0;var r=n(359);Object.defineProperty(t,"WalletAlreadyConnectedError",{enumerable:!0,get:function(){return r.WalletAlreadyConnectedError}});var o=n(8422);Object.defineProperty(t,"WalletNotConnectedError",{enumerable:!0,get:function(){return o.WalletNotConnectedError}});var i=n(3809);Object.defineProperty(t,"WalletNotInjectedError",{enumerable:!0,get:function(){return i.WalletNotInjectedError}});var s=n(5465);Object.defineProperty(t,"WalletNotSupportFeatureError",{enumerable:!0,get:function(){return s.WalletNotSupportFeatureError}});var a=n(939);Object.defineProperty(t,"WalletMissingRequiredFeaturesError",{enumerable:!0,get:function(){return a.WalletMissingRequiredFeaturesError}})},6152:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.HttpBridgeGatewayStorage=void 0,t.HttpBridgeGatewayStorage=class{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return n(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return n(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return n(this,void 0,void 0,function*(){return(yield this.storage.getItem(this.storeKey))||null})}}},6344:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultStorage=void 0;const o=n(5418);t.DefaultStorage=class{constructor(){this.localStorage=(0,o.tryGetLocalStorage)()}getItem(e){return r(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return r(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return r(this,void 0,void 0,function*(){this.localStorage.setItem(e,t)})}}},6351:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enableQaMode=function(){n=!0,console.warn("🚨 QA Mode enabled - validation is disabled. This is unsafe for production!"),i(),"undefined"==typeof window||r||(r=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;"ton-connect-qa-banner"===t.id&&n?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>i(),100)):"ton-connect-qa-mode-styles"===t.id&&n&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>s(),100))}})})}),r.observe(document.body,{childList:!0,subtree:!1}),r.observe(document.head,{childList:!0,subtree:!1})),s()},t.isQaModeEnabled=o,t.logValidationError=function(e){o()&&console.error(`[QA Mode] Validation failed: ${e}`)};let n=!1,r=null;function o(){return n}function i(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-banner"))return;const e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n background: linear-gradient(90deg, #ff6b6b, #ff8e8e);\n color: white;\n padding: 12px 20px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-weight: 600;\n font-size: 14px;\n z-index: 999999;\n box-shadow: 0 2px 8px rgba(0,0,0,0.2);\n animation: slideDown 0.3s ease-out;\n user-select: none;\n pointer-events: none;\n ",e.innerHTML="\n 🚨 QA Mode Active - Validation Disabled (Unsafe for Production)\n ";const t=document.createElement("style");t.textContent="\n @keyframes slideDown {\n from { transform: translateY(-100%); }\n to { transform: translateY(0); }\n }\n ",document.head.appendChild(t),document.body.appendChild(e),s()}function s(){if("undefined"==typeof window)return;if(document.getElementById("ton-connect-qa-mode-styles"))return;const e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent="\n body.qa-mode-active {\n padding-top: 48px !important;\n }\n \n body.qa-mode-active header {\n margin-top: 48px !important;\n }\n \n body.qa-mode-active .qa-mode-control {\n top: 128px !important;\n }\n ",document.head.appendChild(e),document.body.classList.add("qa-mode-active")}},6403:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5166),t),o(n(379),t),o(n(492),t)},6842:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeProvider=void 0;const o=n(7321),i=n(1689),s=n(8393),a=n(8926),c=n(4029),l=n(2209),u=n(1203),d=n(2192),h=n(4241),f=n(607);class p{static fromStorage(e){return r(this,void 0,void 0,function*(){const t=new c.BridgeConnectionStorage(e),n=yield t.getHttpConnection();return(0,a.isPendingConnectionHttp)(n)?new p(e,n.connectionSource):new p(e,{bridgeUrl:n.session.bridgeUrl})})}constructor(e,t){this.storage=e,this.walletConnectionSource=t,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new c.BridgeConnectionStorage(e)}connect(e,t){var n;const i=(0,f.createAbortController)(null==t?void 0:t.signal);null===(n=this.abortController)||void 0===n||n.abort(),this.abortController=i,this.closeGateways();const s=new o.SessionCrypto;this.session={sessionCrypto:s,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:s}).then(()=>r(this,void 0,void 0,function*(){i.signal.aborted||(yield(0,h.callForSuccess)(e=>{var n;return this.openGateways(s,{openingDeadlineMS:null!==(n=null==t?void 0:t.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal}))}));const a="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(a,e)}restoreConnection(e){return r(this,void 0,void 0,function*(){var t,n;const r=(0,f.createAbortController)(null==e?void 0:e.signal);if(null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=r,r.signal.aborted)return;this.closeGateways();const o=yield this.connectionStorage.getHttpConnection();if(!o)return;if(r.signal.aborted)return;const c=null!==(n=null==e?void 0:e.openingDeadlineMS)&&void 0!==n?n:this.defaultOpeningDeadlineMS;if((0,a.isPendingConnectionHttp)(o))return this.session={sessionCrypto:o.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(o.sessionCrypto,{openingDeadlineMS:c,signal:null==r?void 0:r.signal});if(Array.isArray(this.walletConnectionSource))throw new i.TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=o.session,this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,o.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!r.signal.aborted){this.listeners.forEach(e=>e(o.connectEvent));try{yield(0,h.callForSuccess)(e=>this.gateway.registerSession({openingDeadlineMS:c,signal:e.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r.signal})}catch(e){return void(yield this.disconnect({signal:r.signal}))}}})}sendRequest(e,t){const n={};return"function"==typeof t?n.onRequestSent=t:(n.onRequestSent=null==t?void 0:t.onRequestSent,n.signal=null==t?void 0:t.signal,n.attempts=null==t?void 0:t.attempts),new Promise((t,s)=>r(this,void 0,void 0,function*(){var r;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new i.TonConnectError("Trying to send bridge request without session");const a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),(0,u.logDebug)("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));const c=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),(0,o.hexToByteArray)(this.session.walletPublicKey));try{yield this.gateway.send(c,this.session.walletPublicKey,e.method,{attempts:null==n?void 0:n.attempts,signal:null==n?void 0:n.signal}),null===(r=null==n?void 0:n.onRequestSent)||void 0===r||r.call(n),this.pendingRequests.set(a.toString(),t)}catch(e){s(e)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return r(this,void 0,void 0,function*(){return new Promise(t=>r(this,void 0,void 0,function*(){let n=!1,r=null;const o=()=>{n||(n=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();const t=(0,f.createAbortController)(null==e?void 0:e.signal);r=setTimeout(()=>{t.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:o,signal:t.signal,attempts:1})}catch(e){(0,u.logDebug)("Disconnect error:",e),n||this.removeBridgeAndSession().then(t)}finally{r&&clearTimeout(r),o()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}pause(){var e;null===(e=this.gateway)||void 0===e||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return r(this,void 0,void 0,function*(){const e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return r(this,void 0,void 0,function*(){if(this.pendingGateways.includes(e))return this.closeGateways({except:e}),this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=t,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n);yield e.close()})}gatewayListener(e){return r(this,void 0,void 0,function*(){const t=JSON.parse(this.session.sessionCrypto.decrypt(o.Base64.decode(e.message).toUint8Array(),(0,o.hexToByteArray)(e.from)));if((0,u.logDebug)("Wallet message received:",t),!("event"in t)){const e=t.id.toString(),n=this.pendingRequests.get(e);return n?(n(t),void this.pendingRequests.delete(e)):void(0,u.logDebug)(`Response id ${e} doesn't match any request's id`)}if(void 0!==t.id){const e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&t.id<=e)return void(0,u.logError)(`Received event id (=${t.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==t.event&&(yield this.connectionStorage.storeLastWalletEventId(t.id))}const n=this.listeners;"connect"===t.event&&(yield this.updateSession(t,e.from)),"disconnect"===t.event&&((0,u.logDebug)("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(e=>e(t))})}gatewayErrorsListener(e){return r(this,void 0,void 0,function*(){throw new i.TonConnectError(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return r(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});const n=e.payload.items.find(e=>"ton_addr"===e.name),r=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:r,nextRpcRequestId:0})})}removeBridgeAndSession(){return r(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t){return(0,d.isTelegramUrl)(e)?this.generateTGUniversalLink(e,t):this.generateRegularUniversalLink(e,t)}generateRegularUniversalLink(e,t){const n=new URL(e);return n.searchParams.append("v",l.PROTOCOL_VERSION.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(t)),n.toString()}generateTGUniversalLink(e,t){const n=this.generateRegularUniversalLink("about:blank",t).split("?")[1],r="tonconnect-"+(0,d.encodeTelegramUrlParameters)(n),o=this.convertToDirectLink(e),i=new URL(o);return i.searchParams.append("startapp",r),i.toString()}convertToDirectLink(e){const t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return r(this,void 0,void 0,function*(){return Array.isArray(this.walletConnectionSource)?(this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{const n=new s.BridgeGateway(this.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{});return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n}),void(yield Promise.allSettled(this.pendingGateways.map(e=>(0,h.callForSuccess)(n=>{var r;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!==(r=null==t?void 0:t.openingDeadlineMS)&&void 0!==r?r:this.defaultOpeningDeadlineMS,signal:n.signal}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal}))))):(this.gateway&&((0,u.logDebug)("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new s.BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal}))})}closeGateways(e){var t;null===(t=this.gateway)||void 0===t||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}t.BridgeProvider=p},6878:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function(e,t){return r(this,void 0,void 0,function*(){return new Promise((n,r)=>{var i,s;if(null===(i=null==t?void 0:t.signal)||void 0===i?void 0:i.aborted)return void r(new o.TonConnectError("Delay aborted"));const a=setTimeout(()=>n(),e);null===(s=null==t?void 0:t.signal)||void 0===s||s.addEventListener("abort",()=>{clearTimeout(a),r(new o.TonConnectError("Delay aborted"))})})})};const o=n(2931)},6895:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserEventDispatcher=void 0;const o=n(5418);t.BrowserEventDispatcher=class{constructor(){this.window=(0,o.getWindow)()}dispatchEvent(e,t){return r(this,void 0,void 0,function*(){var n;const r=new CustomEvent(e,{detail:t});null===(n=this.window)||void 0===n||n.dispatchEvent(r)})}addEventListener(e,t,n){return r(this,void 0,void 0,function*(){var r;return null===(r=this.window)||void 0===r||r.addEventListener(e,t,n),()=>{var n;return null===(n=this.window)||void 0===n?void 0:n.removeEventListener(e,t)}})}}},7005:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserRejectsError=void 0;var r=n(4263);Object.defineProperty(t,"UserRejectsError",{enumerable:!0,get:function(){return r.UserRejectsError}})},7070:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectErrorsParser=void 0;const r=n(2931),o=n(119),i=n(2301),s=n(5137),a=n(7321),c={[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:s.UnknownError,[a.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:r.UserRejectsError,[a.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:r.BadRequestError,[a.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:r.UnknownAppError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:i.ManifestNotFoundError,[a.CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:o.ManifestContentErrorError};t.connectErrorsParser=new class{parseError(e){let t=s.UnknownError;return e.code in c&&(t=c[e.code]||s.UnknownError),new t(e.message)}}},7321:(e,t,n)=>{"use strict";var r,o,i,s,a,c,l=n(5858),u=n(8861);t.CONNECT_EVENT_ERROR_CODES=void 0,(r=t.CONNECT_EVENT_ERROR_CODES||(t.CONNECT_EVENT_ERROR_CODES={}))[r.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",r[r.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",r[r.MANIFEST_NOT_FOUND_ERROR=2]="MANIFEST_NOT_FOUND_ERROR",r[r.MANIFEST_CONTENT_ERROR=3]="MANIFEST_CONTENT_ERROR",r[r.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",r[r.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",r[r.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CONNECT_ITEM_ERROR_CODES=void 0,(o=t.CONNECT_ITEM_ERROR_CODES||(t.CONNECT_ITEM_ERROR_CODES={}))[o.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",o[o.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SEND_TRANSACTION_ERROR_CODES=void 0,(i=t.SEND_TRANSACTION_ERROR_CODES||(t.SEND_TRANSACTION_ERROR_CODES={}))[i.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",i[i.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",i[i.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",i[i.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",i[i.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.SIGN_DATA_ERROR_CODES=void 0,(s=t.SIGN_DATA_ERROR_CODES||(t.SIGN_DATA_ERROR_CODES={}))[s.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",s[s.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",s[s.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",s[s.USER_REJECTS_ERROR=300]="USER_REJECTS_ERROR",s[s.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.DISCONNECT_ERROR_CODES=void 0,(a=t.DISCONNECT_ERROR_CODES||(t.DISCONNECT_ERROR_CODES={}))[a.UNKNOWN_ERROR=0]="UNKNOWN_ERROR",a[a.BAD_REQUEST_ERROR=1]="BAD_REQUEST_ERROR",a[a.UNKNOWN_APP_ERROR=100]="UNKNOWN_APP_ERROR",a[a.METHOD_NOT_SUPPORTED=400]="METHOD_NOT_SUPPORTED",t.CHAIN=void 0,(c=t.CHAIN||(t.CHAIN={})).MAINNET="-239",c.TESTNET="-3";const d={encode:function(e,t=!1){let n;return e instanceof Uint8Array?n=e:("string"!=typeof e&&(e=JSON.stringify(e)),n=l.decodeUTF8(e)),function(e,t){const n=l.encodeBase64(e);return t?encodeURIComponent(n):n}(n,t)},decode:function(e,t=!1){const n=function(e,t){return t&&(e=decodeURIComponent(e)),l.decodeBase64(e)}(e,t);return{toString:()=>l.encodeUTF8(n),toObject(){try{return JSON.parse(l.encodeUTF8(n))}catch(e){return null}},toUint8Array:()=>n}}};function h(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function f(e,t){if(t>=e.length)throw new Error("Index is out of buffer");return[e.slice(0,t),e.slice(t)]}function p(e){let t="";return e.forEach(e=>{t+=("0"+(255&e).toString(16)).slice(-2)}),t}function g(e){if(e.length%2!=0)throw new Error(`Cannot convert ${e} to bytesArray`);const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}t.Base64=d,t.SessionCrypto=class{constructor(e){this.nonceLength=24,this.keyPair=e?this.createKeypairFromString(e):this.createKeypair(),this.sessionId=p(this.keyPair.publicKey)}createKeypair(){return u.box.keyPair()}createKeypairFromString(e){return{publicKey:g(e.publicKey),secretKey:g(e.secretKey)}}createNonce(){return u.randomBytes(this.nonceLength)}encrypt(e,t){const n=(new TextEncoder).encode(e),r=this.createNonce();return h(r,u.box(n,r,t,this.keyPair.secretKey))}decrypt(e,t){const[n,r]=f(e,this.nonceLength),o=u.box.open(r,n,t,this.keyPair.secretKey);if(!o)throw new Error(`Decryption error: \n message: ${e.toString()} \n sender pubkey: ${t.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);return(new TextDecoder).decode(o)}stringifyKeypair(){return{publicKey:p(this.keyPair.publicKey),secretKey:p(this.keyPair.secretKey)}}},t.concatUint8Arrays=h,t.hexToByteArray=g,t.isNode=function(){return"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node},t.splitToUint8Arrays=f,t.toHexString=p},7523:()=>{},7569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FALLBACK_WALLETS_LIST=void 0,t.FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}]},7688:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BadRequestError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.BadRequestError=o},8158:(e,t)=>{"use strict";function n(e){return r(e)&&e.injected}function r(e){return"jsBridgeKey"in e}Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoCurrentlyInjected=n,t.isWalletInfoCurrentlyEmbedded=function(e){return n(e)&&e.embedded},t.isWalletInfoInjectable=r,t.isWalletInfoRemote=function(e){return"bridgeUrl"in e},t.isWalletInfoInjected=function(e){return"jsBridgeKey"in e}},8240:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(5496),t),o(n(1055),t)},8372:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;var r=n(8599);Object.defineProperty(t,"FetchWalletsError",{enumerable:!0,get:function(){return r.FetchWalletsError}})},8393:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.BridgeGateway=void 0;const o=n(7321),i=n(1689),s=n(6152),a=n(2192);n(7523),n(4898);const c=n(4241),l=n(1203),u=n(9373),d=n(3762),h=n(607);t.BridgeGateway=class{get isReady(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,o,c){this.bridgeUrl=t,this.sessionId=n,this.listener=o,this.errorsListener=c,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=(0,u.createResource)((e,t)=>r(this,void 0,void 0,function*(){const n={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:e,openingDeadlineMS:t};return yield function(e){return r(this,void 0,void 0,function*(){return yield(0,d.timeout)((t,n,o)=>r(this,void 0,void 0,function*(){var s;const c=(0,h.createAbortController)(o.signal).signal;if(c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const l=new URL((0,a.addPathToUrl)(e.bridgeUrl,e.ssePath));l.searchParams.append("client_id",e.sessionId);const u=yield e.bridgeGatewayStorage.getLastEventId();if(u&&l.searchParams.append("last_event_id",u),c.aborted)return void n(new i.TonConnectError("Bridge connection aborted"));const d=new EventSource(l.toString());d.onerror=o=>r(this,void 0,void 0,function*(){if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));try{const n=yield e.errorHandler(d,o);n!==d&&d.close(),n&&n!==d&&t(n)}catch(e){d.close(),n(e)}}),d.onopen=()=>{if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));t(d)},d.onmessage=t=>{if(c.aborted)return d.close(),void n(new i.TonConnectError("Bridge connection aborted"));e.messageHandler(t)},null===(s=e.signal)||void 0===s||s.addEventListener("abort",()=>{d.close(),n(new i.TonConnectError("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(n)}),e=>r(this,void 0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new s.HttpBridgeGatewayStorage(e,t)}registerSession(e){return r(this,void 0,void 0,function*(){yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS)})}send(e,t,n,s){return r(this,void 0,void 0,function*(){var l;const u={};"number"==typeof s?u.ttl=s:(u.ttl=null==s?void 0:s.ttl,u.signal=null==s?void 0:s.signal,u.attempts=null==s?void 0:s.attempts);const d=new URL((0,a.addPathToUrl)(this.bridgeUrl,this.postPath));d.searchParams.append("client_id",this.sessionId),d.searchParams.append("to",t),d.searchParams.append("ttl",((null==u?void 0:u.ttl)||this.defaultTtl).toString()),d.searchParams.append("topic",n);const h=o.Base64.encode(e);yield(0,c.callForSuccess)(e=>r(this,void 0,void 0,function*(){const t=yield this.post(d,h,e.signal);if(!t.ok)throw new i.TonConnectError(`Bridge send failed, status ${t.status}`)}),{attempts:null!==(l=null==u?void 0:u.attempts)&&void 0!==l?l:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==u?void 0:u.signal})})}pause(){this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge pause failed, ${e}`))}unPause(){return r(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return r(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>(0,l.logError)(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return r(this,void 0,void 0,function*(){const r=yield fetch(e,{method:"post",body:t,signal:n});if(!r.ok)throw new i.TonConnectError(`Bridge send failed, status ${r.status}`);return r})}errorsHandler(e,t){return r(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new i.TonConnectError("Bridge error, failed to connect");if(!this.isReady){if(this.isClosed)return e.close(),(0,l.logDebug)(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new i.TonConnectError("Bridge error, unknown state")}try{this.errorsListener(t)}catch(e){}})}messagesHandler(e){return r(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage)return;if(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed)return;let t;try{t=JSON.parse(e.data)}catch(t){throw new i.TonConnectError(`Bridge message parse failed, message ${e.data}`)}this.listener(t)})}}},8409:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toUserFriendlyAddress=function(e,t=!1){const{wc:n,hex:r}=l(e);let i=s;t&&(i|=a);const c=new Int8Array(34);c[0]=i,c[1]=n,c.set(r,2);const d=new Uint8Array(36);return d.set(c),d.set(u(c),34),o.Base64.encode(d).replace(/\+/g,"-").replace(/\//g,"_")},t.isValidUserFriendlyAddress=function(e){try{return c(e),!0}catch(e){return!1}},t.isValidRawAddress=function(e){try{return l(e),!0}catch(e){return!1}},t.parseUserFriendlyAddress=c,t.hexToBytes=h;const r=n(2931),o=n(7321),i=17,s=81,a=128;function c(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");let n;try{n=o.Base64.decode(t).toUint8Array()}catch(t){throw new r.WrongAddressError(`Invalid base64 encoding in address: ${e}`)}if(36!==n.length)throw new r.WrongAddressError(`Invalid address length: ${e}`);const c=n.slice(0,34),l=n.slice(34,36),d=u(c);if(!l.every((e,t)=>e===d[t]))throw new r.WrongAddressError(`Invalid checksum in address: ${e}`);let h=c[0],f=!1,p=!1;if(h&a&&(f=!0,h^=a),h!==i&&h!==s)throw new r.WrongAddressError(`Unknown address tag: ${h}`);p=h===i;let g=null;g=255===c[1]?-1:c[1];const v=c.slice(2);if(0!==g&&-1!==g)throw new r.WrongAddressError(`Invalid workchain: ${g}`);return{wc:g,hex:Array.from(v).map(e=>e.toString(16).padStart(2,"0")).join(""),testOnly:f,isBounceable:p}}function l(e){if(!e.includes(":"))throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":".`);const t=e.split(":");if(2!==t.length)throw new r.WrongAddressError(`Wrong address ${e}. Address must include ":" only once.`);const n=parseInt(t[0]);if(0!==n&&-1!==n)throw new r.WrongAddressError(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);const o=t[1];if(64!==(null==o?void 0:o.length))throw new r.WrongAddressError(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==o?void 0:o.length} received.`);return{wc:n,hex:h(o)}}function u(e){let t=0;const n=new Uint8Array(e.length+2);n.set(e);for(let e of n){let n=128;for(;n>0;)t<<=1,e&n&&(t+=1),n>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}const d={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),d[t]=e}function h(e){const t=(e=e.toLowerCase()).length;if(t%2!=0)throw new r.ParseHexError("Hex string must have length a multiple of 2: "+e);const n=t/2,o=new Uint8Array(n);for(let t=0;t<n;t++){const n=2*t,i=e.substring(n,n+2);if(!d.hasOwnProperty(i))throw new r.ParseHexError("Invalid hex character: "+i);o[t]=d[i]}return o}},8422:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WalletNotConnectedError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.WalletNotConnectedError=o},8599:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FetchWalletsError=void 0;const r=n(1689);class o extends r.TonConnectError{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,o.prototype)}}t.FetchWalletsError=o},8705:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalstorageNotFoundError=void 0;var r=n(332);Object.defineProperty(t,"LocalstorageNotFoundError",{enumerable:!0,get:function(){return r.LocalstorageNotFoundError}})},8861:(e,t,n)=>{!function(e){"use strict";var t=function(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;t++)n[t]=e[t];return n},r=function(){throw new Error("no PRNG")},o=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),a=t([1]),c=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(e,t,n,r){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=255&r}function g(e,t,n,r,o){var i,s=0;for(i=0;i<o;i++)s|=e[t+i]^n[r+i];return(1&s-1>>>8)-1}function v(e,t,n,r){return g(e,t,n,r,16)}function y(e,t,n,r){return g(e,t,n,r,32)}function b(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,m=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=i,_=s,O=a,R=c,C=l,S=u,T=d,P=h,j=f,N=p,A=g,I=v,D=y,U=b,M=w,k=m,x=0;x<20;x+=2)E^=(o=(D^=(o=(j^=(o=(C^=(o=E+D|0)<<7|o>>>25)+E|0)<<9|o>>>23)+C|0)<<13|o>>>19)+j|0)<<18|o>>>14,S^=(o=(_^=(o=(U^=(o=(N^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+N|0)<<13|o>>>19)+U|0)<<18|o>>>14,A^=(o=(T^=(o=(O^=(o=(M^=(o=A+T|0)<<7|o>>>25)+A|0)<<9|o>>>23)+M|0)<<13|o>>>19)+O|0)<<18|o>>>14,k^=(o=(I^=(o=(P^=(o=(R^=(o=k+I|0)<<7|o>>>25)+k|0)<<9|o>>>23)+R|0)<<13|o>>>19)+P|0)<<18|o>>>14,E^=(o=(R^=(o=(O^=(o=(_^=(o=E+R|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+O|0)<<18|o>>>14,S^=(o=(C^=(o=(P^=(o=(T^=(o=S+C|0)<<7|o>>>25)+S|0)<<9|o>>>23)+T|0)<<13|o>>>19)+P|0)<<18|o>>>14,A^=(o=(N^=(o=(j^=(o=(I^=(o=A+N|0)<<7|o>>>25)+A|0)<<9|o>>>23)+I|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(M^=(o=(U^=(o=(D^=(o=k+M|0)<<7|o>>>25)+k|0)<<9|o>>>23)+D|0)<<13|o>>>19)+U|0)<<18|o>>>14;E=E+i|0,_=_+s|0,O=O+a|0,R=R+c|0,C=C+l|0,S=S+u|0,T=T+d|0,P=P+h|0,j=j+f|0,N=N+p|0,A=A+g|0,I=I+v|0,D=D+y|0,U=U+b|0,M=M+w|0,k=k+m|0,e[0]=E>>>0&255,e[1]=E>>>8&255,e[2]=E>>>16&255,e[3]=E>>>24&255,e[4]=_>>>0&255,e[5]=_>>>8&255,e[6]=_>>>16&255,e[7]=_>>>24&255,e[8]=O>>>0&255,e[9]=O>>>8&255,e[10]=O>>>16&255,e[11]=O>>>24&255,e[12]=R>>>0&255,e[13]=R>>>8&255,e[14]=R>>>16&255,e[15]=R>>>24&255,e[16]=C>>>0&255,e[17]=C>>>8&255,e[18]=C>>>16&255,e[19]=C>>>24&255,e[20]=S>>>0&255,e[21]=S>>>8&255,e[22]=S>>>16&255,e[23]=S>>>24&255,e[24]=T>>>0&255,e[25]=T>>>8&255,e[26]=T>>>16&255,e[27]=T>>>24&255,e[28]=P>>>0&255,e[29]=P>>>8&255,e[30]=P>>>16&255,e[31]=P>>>24&255,e[32]=j>>>0&255,e[33]=j>>>8&255,e[34]=j>>>16&255,e[35]=j>>>24&255,e[36]=N>>>0&255,e[37]=N>>>8&255,e[38]=N>>>16&255,e[39]=N>>>24&255,e[40]=A>>>0&255,e[41]=A>>>8&255,e[42]=A>>>16&255,e[43]=A>>>24&255,e[44]=I>>>0&255,e[45]=I>>>8&255,e[46]=I>>>16&255,e[47]=I>>>24&255,e[48]=D>>>0&255,e[49]=D>>>8&255,e[50]=D>>>16&255,e[51]=D>>>24&255,e[52]=U>>>0&255,e[53]=U>>>8&255,e[54]=U>>>16&255,e[55]=U>>>24&255,e[56]=M>>>0&255,e[57]=M>>>8&255,e[58]=M>>>16&255,e[59]=M>>>24&255,e[60]=k>>>0&255,e[61]=k>>>8&255,e[62]=k>>>16&255,e[63]=k>>>24&255}(e,t,n,r)}function w(e,t,n,r){!function(e,t,n,r){for(var o,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,s=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,l=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,f=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,y=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,w=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,m=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,E=0;E<20;E+=2)i^=(o=(y^=(o=(f^=(o=(l^=(o=i+y|0)<<7|o>>>25)+i|0)<<9|o>>>23)+l|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(b^=(o=(p^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+p|0)<<13|o>>>19)+b|0)<<18|o>>>14,g^=(o=(d^=(o=(a^=(o=(w^=(o=g+d|0)<<7|o>>>25)+g|0)<<9|o>>>23)+w|0)<<13|o>>>19)+a|0)<<18|o>>>14,m^=(o=(v^=(o=(h^=(o=(c^=(o=m+v|0)<<7|o>>>25)+m|0)<<9|o>>>23)+c|0)<<13|o>>>19)+h|0)<<18|o>>>14,i^=(o=(c^=(o=(a^=(o=(s^=(o=i+c|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(l^=(o=(h^=(o=(d^=(o=u+l|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+h|0)<<18|o>>>14,g^=(o=(p^=(o=(f^=(o=(v^=(o=g+p|0)<<7|o>>>25)+g|0)<<9|o>>>23)+v|0)<<13|o>>>19)+f|0)<<18|o>>>14,m^=(o=(w^=(o=(b^=(o=(y^=(o=m+w|0)<<7|o>>>25)+m|0)<<9|o>>>23)+y|0)<<13|o>>>19)+b|0)<<18|o>>>14;e[0]=i>>>0&255,e[1]=i>>>8&255,e[2]=i>>>16&255,e[3]=i>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=m>>>0&255,e[13]=m>>>8&255,e[14]=m>>>16&255,e[15]=m>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=f>>>0&255,e[25]=f>>>8&255,e[26]=f>>>16&255,e[27]=f>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,n,r)}var m=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function E(e,t,n,r,o,i,s){var a,c,l=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)l[c]=0;for(c=0;c<8;c++)l[c]=i[c];for(;o>=64;){for(b(u,l,s,m),c=0;c<64;c++)e[t+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&l[c])|0,l[c]=255&a,a>>>=8;o-=64,t+=64,r+=64}if(o>0)for(b(u,l,s,m),c=0;c<o;c++)e[t+c]=n[r+c]^u[c];return 0}function _(e,t,n,r,o){var i,s,a=new Uint8Array(16),c=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=r[s];for(;n>=64;){for(b(c,a,o,m),s=0;s<64;s++)e[t+s]=c[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(b(c,a,o,m),s=0;s<n;s++)e[t+s]=c[s];return 0}function O(e,t,n,r,o){var i=new Uint8Array(32);w(i,r,o,m);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=r[a+16];return _(e,t,n,s,i)}function R(e,t,n,r,o,i,s){var a=new Uint8Array(32);w(a,i,s,m);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=i[l+16];return E(e,t,n,r,o,c,a)}var C=function(e){var t,n,r,o,i,s,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,n=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|n<<3),r=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(n>>>10|r<<6),o=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(r>>>7|o<<9),i=255&e[8]|(255&e[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function S(e,t,n,r,o,i){var s=new C(i);return s.update(n,r,o),s.finish(e,t),0}function T(e,t,n,r,o,i){var s=new Uint8Array(16);return S(s,0,n,r,o,i),v(e,t,s,0)}function P(e,t,n,r,o){var i;if(n<32)return-1;for(R(e,0,t,0,n,r,o),S(e,16,e,32,n-32,e),i=0;i<16;i++)e[i]=0;return 0}function j(e,t,n,r,o){var i,s=new Uint8Array(32);if(n<32)return-1;if(O(s,0,32,r,o),0!==T(t,16,t,32,n-32,s))return-1;for(R(e,0,t,0,n,r,o),i=0;i<32;i++)e[i]=0;return 0}function N(e,t){var n;for(n=0;n<16;n++)e[n]=0|t[n]}function A(e){var t,n,r=1;for(t=0;t<16;t++)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-65536*r;e[0]+=r-1+37*(r-1)}function I(e,t,n){for(var r,o=~(n-1),i=0;i<16;i++)r=o&(e[i]^t[i]),e[i]^=r,t[i]^=r}function D(e,n){var r,o,i,s=t(),a=t();for(r=0;r<16;r++)a[r]=n[r];for(A(a),A(a),A(a),o=0;o<2;o++){for(s[0]=a[0]-65517,r=1;r<15;r++)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,I(a,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&a[r],e[2*r+1]=a[r]>>8}function U(e,t){var n=new Uint8Array(32),r=new Uint8Array(32);return D(n,e),D(r,t),y(n,0,r,0)}function M(e){var t=new Uint8Array(32);return D(t,e),1&t[0]}function k(e,t){var n;for(n=0;n<16;n++)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function x(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]+n[r]}function W(e,t,n){for(var r=0;r<16;r++)e[r]=t[r]-n[r]}function L(e,t,n){var r,o,i=0,s=0,a=0,c=0,l=0,u=0,d=0,h=0,f=0,p=0,g=0,v=0,y=0,b=0,w=0,m=0,E=0,_=0,O=0,R=0,C=0,S=0,T=0,P=0,j=0,N=0,A=0,I=0,D=0,U=0,M=0,k=n[0],x=n[1],W=n[2],L=n[3],q=n[4],B=n[5],F=n[6],K=n[7],H=n[8],G=n[9],V=n[10],$=n[11],Q=n[12],J=n[13],Y=n[14],z=n[15];i+=(r=t[0])*k,s+=r*x,a+=r*W,c+=r*L,l+=r*q,u+=r*B,d+=r*F,h+=r*K,f+=r*H,p+=r*G,g+=r*V,v+=r*$,y+=r*Q,b+=r*J,w+=r*Y,m+=r*z,s+=(r=t[1])*k,a+=r*x,c+=r*W,l+=r*L,u+=r*q,d+=r*B,h+=r*F,f+=r*K,p+=r*H,g+=r*G,v+=r*V,y+=r*$,b+=r*Q,w+=r*J,m+=r*Y,E+=r*z,a+=(r=t[2])*k,c+=r*x,l+=r*W,u+=r*L,d+=r*q,h+=r*B,f+=r*F,p+=r*K,g+=r*H,v+=r*G,y+=r*V,b+=r*$,w+=r*Q,m+=r*J,E+=r*Y,_+=r*z,c+=(r=t[3])*k,l+=r*x,u+=r*W,d+=r*L,h+=r*q,f+=r*B,p+=r*F,g+=r*K,v+=r*H,y+=r*G,b+=r*V,w+=r*$,m+=r*Q,E+=r*J,_+=r*Y,O+=r*z,l+=(r=t[4])*k,u+=r*x,d+=r*W,h+=r*L,f+=r*q,p+=r*B,g+=r*F,v+=r*K,y+=r*H,b+=r*G,w+=r*V,m+=r*$,E+=r*Q,_+=r*J,O+=r*Y,R+=r*z,u+=(r=t[5])*k,d+=r*x,h+=r*W,f+=r*L,p+=r*q,g+=r*B,v+=r*F,y+=r*K,b+=r*H,w+=r*G,m+=r*V,E+=r*$,_+=r*Q,O+=r*J,R+=r*Y,C+=r*z,d+=(r=t[6])*k,h+=r*x,f+=r*W,p+=r*L,g+=r*q,v+=r*B,y+=r*F,b+=r*K,w+=r*H,m+=r*G,E+=r*V,_+=r*$,O+=r*Q,R+=r*J,C+=r*Y,S+=r*z,h+=(r=t[7])*k,f+=r*x,p+=r*W,g+=r*L,v+=r*q,y+=r*B,b+=r*F,w+=r*K,m+=r*H,E+=r*G,_+=r*V,O+=r*$,R+=r*Q,C+=r*J,S+=r*Y,T+=r*z,f+=(r=t[8])*k,p+=r*x,g+=r*W,v+=r*L,y+=r*q,b+=r*B,w+=r*F,m+=r*K,E+=r*H,_+=r*G,O+=r*V,R+=r*$,C+=r*Q,S+=r*J,T+=r*Y,P+=r*z,p+=(r=t[9])*k,g+=r*x,v+=r*W,y+=r*L,b+=r*q,w+=r*B,m+=r*F,E+=r*K,_+=r*H,O+=r*G,R+=r*V,C+=r*$,S+=r*Q,T+=r*J,P+=r*Y,j+=r*z,g+=(r=t[10])*k,v+=r*x,y+=r*W,b+=r*L,w+=r*q,m+=r*B,E+=r*F,_+=r*K,O+=r*H,R+=r*G,C+=r*V,S+=r*$,T+=r*Q,P+=r*J,j+=r*Y,N+=r*z,v+=(r=t[11])*k,y+=r*x,b+=r*W,w+=r*L,m+=r*q,E+=r*B,_+=r*F,O+=r*K,R+=r*H,C+=r*G,S+=r*V,T+=r*$,P+=r*Q,j+=r*J,N+=r*Y,A+=r*z,y+=(r=t[12])*k,b+=r*x,w+=r*W,m+=r*L,E+=r*q,_+=r*B,O+=r*F,R+=r*K,C+=r*H,S+=r*G,T+=r*V,P+=r*$,j+=r*Q,N+=r*J,A+=r*Y,I+=r*z,b+=(r=t[13])*k,w+=r*x,m+=r*W,E+=r*L,_+=r*q,O+=r*B,R+=r*F,C+=r*K,S+=r*H,T+=r*G,P+=r*V,j+=r*$,N+=r*Q,A+=r*J,I+=r*Y,D+=r*z,w+=(r=t[14])*k,m+=r*x,E+=r*W,_+=r*L,O+=r*q,R+=r*B,C+=r*F,S+=r*K,T+=r*H,P+=r*G,j+=r*V,N+=r*$,A+=r*Q,I+=r*J,D+=r*Y,U+=r*z,m+=(r=t[15])*k,s+=38*(_+=r*W),a+=38*(O+=r*L),c+=38*(R+=r*q),l+=38*(C+=r*B),u+=38*(S+=r*F),d+=38*(T+=r*K),h+=38*(P+=r*H),f+=38*(j+=r*G),p+=38*(N+=r*V),g+=38*(A+=r*$),v+=38*(I+=r*Q),y+=38*(D+=r*J),b+=38*(U+=r*Y),w+=38*(M+=r*z),i=(r=(i+=38*(E+=r*x))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),i=(r=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(r/65536)),s=(r=s+o+65535)-65536*(o=Math.floor(r/65536)),a=(r=a+o+65535)-65536*(o=Math.floor(r/65536)),c=(r=c+o+65535)-65536*(o=Math.floor(r/65536)),l=(r=l+o+65535)-65536*(o=Math.floor(r/65536)),u=(r=u+o+65535)-65536*(o=Math.floor(r/65536)),d=(r=d+o+65535)-65536*(o=Math.floor(r/65536)),h=(r=h+o+65535)-65536*(o=Math.floor(r/65536)),f=(r=f+o+65535)-65536*(o=Math.floor(r/65536)),p=(r=p+o+65535)-65536*(o=Math.floor(r/65536)),g=(r=g+o+65535)-65536*(o=Math.floor(r/65536)),v=(r=v+o+65535)-65536*(o=Math.floor(r/65536)),y=(r=y+o+65535)-65536*(o=Math.floor(r/65536)),b=(r=b+o+65535)-65536*(o=Math.floor(r/65536)),w=(r=w+o+65535)-65536*(o=Math.floor(r/65536)),m=(r=m+o+65535)-65536*(o=Math.floor(r/65536)),i+=o-1+37*(o-1),e[0]=i,e[1]=s,e[2]=a,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=h,e[8]=f,e[9]=p,e[10]=g,e[11]=v,e[12]=y,e[13]=b,e[14]=w,e[15]=m}function q(e,t){L(e,t,t)}function B(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=253;r>=0;r--)q(o,o),2!==r&&4!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function F(e,n){var r,o=t();for(r=0;r<16;r++)o[r]=n[r];for(r=250;r>=0;r--)q(o,o),1!==r&&L(o,o,n);for(r=0;r<16;r++)e[r]=o[r]}function K(e,n,r){var o,i,s=new Uint8Array(32),a=new Float64Array(80),l=t(),u=t(),d=t(),h=t(),f=t(),p=t();for(i=0;i<31;i++)s[i]=n[i];for(s[31]=127&n[31]|64,s[0]&=248,k(a,r),i=0;i<16;i++)u[i]=a[i],h[i]=l[i]=d[i]=0;for(l[0]=h[0]=1,i=254;i>=0;--i)I(l,u,o=s[i>>>3]>>>(7&i)&1),I(d,h,o),x(f,l,d),W(l,l,d),x(d,u,h),W(u,u,h),q(h,f),q(p,l),L(l,d,l),L(d,u,f),x(f,l,d),W(l,l,d),q(u,l),W(d,h,p),L(l,d,c),x(l,l,h),L(d,d,l),L(l,h,p),L(h,u,a),q(u,f),I(l,u,o),I(d,h,o);for(i=0;i<16;i++)a[i+16]=l[i],a[i+32]=d[i],a[i+48]=u[i],a[i+64]=h[i];var g=a.subarray(32),v=a.subarray(16);return B(g,g),L(v,v,g),D(e,v),0}function H(e,t){return K(e,t,i)}function G(e,t){return r(t,32),H(e,t)}function V(e,t,n){var r=new Uint8Array(32);return K(r,n,t),w(e,o,r,m)}C.prototype.blocks=function(e,t,n){for(var r,o,i,s,a,c,l,u,d,h,f,p,g,v,y,b,w,m,E,_=this.fin?0:2048,O=this.h[0],R=this.h[1],C=this.h[2],S=this.h[3],T=this.h[4],P=this.h[5],j=this.h[6],N=this.h[7],A=this.h[8],I=this.h[9],D=this.r[0],U=this.r[1],M=this.r[2],k=this.r[3],x=this.r[4],W=this.r[5],L=this.r[6],q=this.r[7],B=this.r[8],F=this.r[9];n>=16;)h=d=0,h+=(O+=8191&(r=255&e[t+0]|(255&e[t+1])<<8))*D,h+=(R+=8191&(r>>>13|(o=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*F),h+=(C+=8191&(o>>>10|(i=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*B),h+=(S+=8191&(i>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*q),d=(h+=(T+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*L))>>>13,h&=8191,h+=(P+=a>>>1&8191)*(5*W),h+=(j+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*x),h+=(N+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*k),h+=(A+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*M),f=d+=(h+=(I+=u>>>5|_)*(5*U))>>>13,f+=O*U,f+=R*D,f+=C*(5*F),f+=S*(5*B),d=(f+=T*(5*q))>>>13,f&=8191,f+=P*(5*L),f+=j*(5*W),f+=N*(5*x),f+=A*(5*k),d+=(f+=I*(5*M))>>>13,f&=8191,p=d,p+=O*M,p+=R*U,p+=C*D,p+=S*(5*F),d=(p+=T*(5*B))>>>13,p&=8191,p+=P*(5*q),p+=j*(5*L),p+=N*(5*W),p+=A*(5*x),g=d+=(p+=I*(5*k))>>>13,g+=O*k,g+=R*M,g+=C*U,g+=S*D,d=(g+=T*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=j*(5*q),g+=N*(5*L),g+=A*(5*W),v=d+=(g+=I*(5*x))>>>13,v+=O*x,v+=R*k,v+=C*M,v+=S*U,d=(v+=T*D)>>>13,v&=8191,v+=P*(5*F),v+=j*(5*B),v+=N*(5*q),v+=A*(5*L),y=d+=(v+=I*(5*W))>>>13,y+=O*W,y+=R*x,y+=C*k,y+=S*M,d=(y+=T*U)>>>13,y&=8191,y+=P*D,y+=j*(5*F),y+=N*(5*B),y+=A*(5*q),b=d+=(y+=I*(5*L))>>>13,b+=O*L,b+=R*W,b+=C*x,b+=S*k,d=(b+=T*M)>>>13,b&=8191,b+=P*U,b+=j*D,b+=N*(5*F),b+=A*(5*B),w=d+=(b+=I*(5*q))>>>13,w+=O*q,w+=R*L,w+=C*W,w+=S*x,d=(w+=T*k)>>>13,w&=8191,w+=P*M,w+=j*U,w+=N*D,w+=A*(5*F),m=d+=(w+=I*(5*B))>>>13,m+=O*B,m+=R*q,m+=C*L,m+=S*W,d=(m+=T*x)>>>13,m&=8191,m+=P*k,m+=j*M,m+=N*U,m+=A*D,E=d+=(m+=I*(5*F))>>>13,E+=O*F,E+=R*B,E+=C*q,E+=S*L,d=(E+=T*W)>>>13,E&=8191,E+=P*x,E+=j*k,E+=N*M,E+=A*U,O=h=8191&(d=(d=((d+=(E+=I*D)>>>13)<<2)+d|0)+(h&=8191)|0),R=f+=d>>>=13,C=p&=8191,S=g&=8191,T=v&=8191,P=y&=8191,j=b&=8191,N=w&=8191,A=m&=8191,I=E&=8191,t+=16,n-=16;this.h[0]=O,this.h[1]=R,this.h[2]=C,this.h[3]=S,this.h[4]=T,this.h[5]=P,this.h[6]=j,this.h[7]=N,this.h[8]=A,this.h[9]=I},C.prototype.finish=function(e,t){var n,r,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,s[0]=this.h[0]+5,n=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+n,n=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,r=(1^n)-1,i=0;i<10;i++)s[i]&=r;for(r=~r,i=0;i<10;i++)this.h[i]=this.h[i]&r|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},C.prototype.update=function(e,t,n){var r,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),r=0;r<o;r++)this.buffer[this.leftover+r]=e[t+r];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(e,t,o),t+=o,n-=o),n){for(r=0;r<n;r++)this.buffer[this.leftover+r]=e[t+r];this.leftover+=n}};var $=P,Q=j,J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Y(e,t,n,r){for(var o,i,s,a,c,l,u,d,h,f,p,g,v,y,b,w,m,E,_,O,R,C,S,T,P,j,N=new Int32Array(16),A=new Int32Array(16),I=e[0],D=e[1],U=e[2],M=e[3],k=e[4],x=e[5],W=e[6],L=e[7],q=t[0],B=t[1],F=t[2],K=t[3],H=t[4],G=t[5],V=t[6],$=t[7],Q=0;r>=128;){for(_=0;_<16;_++)O=8*_+Q,N[_]=n[O+0]<<24|n[O+1]<<16|n[O+2]<<8|n[O+3],A[_]=n[O+4]<<24|n[O+5]<<16|n[O+6]<<8|n[O+7];for(_=0;_<80;_++)if(o=I,i=D,s=U,a=M,c=k,l=x,u=W,h=q,f=B,p=F,g=K,v=H,y=G,b=V,S=65535&(C=$),T=C>>>16,P=65535&(R=L),j=R>>>16,S+=65535&(C=(H>>>14|k<<18)^(H>>>18|k<<14)^(k>>>9|H<<23)),T+=C>>>16,P+=65535&(R=(k>>>14|H<<18)^(k>>>18|H<<14)^(H>>>9|k<<23)),j+=R>>>16,S+=65535&(C=H&G^~H&V),T+=C>>>16,P+=65535&(R=k&x^~k&W),j+=R>>>16,S+=65535&(C=J[2*_+1]),T+=C>>>16,P+=65535&(R=J[2*_]),j+=R>>>16,R=N[_%16],T+=(C=A[_%16])>>>16,P+=65535&R,j+=R>>>16,P+=(T+=(S+=65535&C)>>>16)>>>16,S=65535&(C=E=65535&S|T<<16),T=C>>>16,P=65535&(R=m=65535&P|(j+=P>>>16)<<16),j=R>>>16,S+=65535&(C=(q>>>28|I<<4)^(I>>>2|q<<30)^(I>>>7|q<<25)),T+=C>>>16,P+=65535&(R=(I>>>28|q<<4)^(q>>>2|I<<30)^(q>>>7|I<<25)),j+=R>>>16,T+=(C=q&B^q&F^B&F)>>>16,P+=65535&(R=I&D^I&U^D&U),j+=R>>>16,d=65535&(P+=(T+=(S+=65535&C)>>>16)>>>16)|(j+=P>>>16)<<16,w=65535&S|T<<16,S=65535&(C=g),T=C>>>16,P=65535&(R=a),j=R>>>16,T+=(C=E)>>>16,P+=65535&(R=m),j+=R>>>16,D=o,U=i,M=s,k=a=65535&(P+=(T+=(S+=65535&C)>>>16)>>>16)|(j+=P>>>16)<<16,x=c,W=l,L=u,I=d,B=h,F=f,K=p,H=g=65535&S|T<<16,G=v,V=y,$=b,q=w,_%16==15)for(O=0;O<16;O++)R=N[O],S=65535&(C=A[O]),T=C>>>16,P=65535&R,j=R>>>16,R=N[(O+9)%16],S+=65535&(C=A[(O+9)%16]),T+=C>>>16,P+=65535&R,j+=R>>>16,m=N[(O+1)%16],S+=65535&(C=((E=A[(O+1)%16])>>>1|m<<31)^(E>>>8|m<<24)^(E>>>7|m<<25)),T+=C>>>16,P+=65535&(R=(m>>>1|E<<31)^(m>>>8|E<<24)^m>>>7),j+=R>>>16,m=N[(O+14)%16],T+=(C=((E=A[(O+14)%16])>>>19|m<<13)^(m>>>29|E<<3)^(E>>>6|m<<26))>>>16,P+=65535&(R=(m>>>19|E<<13)^(E>>>29|m<<3)^m>>>6),j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,N[O]=65535&P|j<<16,A[O]=65535&S|T<<16;S=65535&(C=q),T=C>>>16,P=65535&(R=I),j=R>>>16,R=e[0],T+=(C=t[0])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[0]=I=65535&P|j<<16,t[0]=q=65535&S|T<<16,S=65535&(C=B),T=C>>>16,P=65535&(R=D),j=R>>>16,R=e[1],T+=(C=t[1])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[1]=D=65535&P|j<<16,t[1]=B=65535&S|T<<16,S=65535&(C=F),T=C>>>16,P=65535&(R=U),j=R>>>16,R=e[2],T+=(C=t[2])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[2]=U=65535&P|j<<16,t[2]=F=65535&S|T<<16,S=65535&(C=K),T=C>>>16,P=65535&(R=M),j=R>>>16,R=e[3],T+=(C=t[3])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[3]=M=65535&P|j<<16,t[3]=K=65535&S|T<<16,S=65535&(C=H),T=C>>>16,P=65535&(R=k),j=R>>>16,R=e[4],T+=(C=t[4])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[4]=k=65535&P|j<<16,t[4]=H=65535&S|T<<16,S=65535&(C=G),T=C>>>16,P=65535&(R=x),j=R>>>16,R=e[5],T+=(C=t[5])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[5]=x=65535&P|j<<16,t[5]=G=65535&S|T<<16,S=65535&(C=V),T=C>>>16,P=65535&(R=W),j=R>>>16,R=e[6],T+=(C=t[6])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[6]=W=65535&P|j<<16,t[6]=V=65535&S|T<<16,S=65535&(C=$),T=C>>>16,P=65535&(R=L),j=R>>>16,R=e[7],T+=(C=t[7])>>>16,P+=65535&R,j+=R>>>16,j+=(P+=(T+=(S+=65535&C)>>>16)>>>16)>>>16,e[7]=L=65535&P|j<<16,t[7]=$=65535&S|T<<16,Q+=128,r-=128}return r}function z(e,t,n){var r,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Y(o,i,t,n),n%=128,r=0;r<n;r++)s[r]=t[a-n+r];for(s[n]=128,s[(n=256-128*(n<112?1:0))-9]=0,p(s,n-8,a/536870912|0,a<<3),Y(o,i,s,n),r=0;r<8;r++)p(e,8*r,o[r],i[r]);return 0}function X(e,n){var r=t(),o=t(),i=t(),s=t(),a=t(),c=t(),l=t(),d=t(),h=t();W(r,e[1],e[0]),W(h,n[1],n[0]),L(r,r,h),x(o,e[0],e[1]),x(h,n[0],n[1]),L(o,o,h),L(i,e[3],n[3]),L(i,i,u),L(s,e[2],n[2]),x(s,s,s),W(a,o,r),W(c,s,i),x(l,s,i),x(d,o,r),L(e[0],a,c),L(e[1],d,l),L(e[2],l,c),L(e[3],a,d)}function Z(e,t,n){var r;for(r=0;r<4;r++)I(e[r],t[r],n)}function ee(e,n){var r=t(),o=t(),i=t();B(i,n[2]),L(r,n[0],i),L(o,n[1],i),D(e,o),e[31]^=M(r)<<7}function te(e,t,n){var r,o;for(N(e[0],s),N(e[1],a),N(e[2],a),N(e[3],s),o=255;o>=0;--o)Z(e,t,r=n[o/8|0]>>(7&o)&1),X(t,e),X(e,e),Z(e,t,r)}function ne(e,n){var r=[t(),t(),t(),t()];N(r[0],d),N(r[1],h),N(r[2],a),L(r[3],d,h),te(e,r,n)}function re(e,n,o){var i,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||r(n,32),z(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,ne(a,s),ee(e,a),i=0;i<32;i++)n[i+32]=e[i];return 0}var oe=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var n,r,o,i;for(r=63;r>=32;--r){for(n=0,o=r-32,i=r-12;o<i;++o)t[o]+=n-16*t[r]*oe[o-(r-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[r]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*oe[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*oe[o];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function se(e){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,n)}function ae(e,n,r,o){var i,s,a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),u=new Float64Array(64),d=[t(),t(),t(),t()];z(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=r+64;for(i=0;i<r;i++)e[64+i]=n[i];for(i=0;i<32;i++)e[32+i]=a[32+i];for(z(l,e.subarray(32),r+32),se(l),ne(d,l),ee(e,d),i=32;i<64;i++)e[i]=o[i];for(z(c,e,r+64),se(c),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=l[i];for(i=0;i<32;i++)for(s=0;s<32;s++)u[i+s]+=c[i]*a[s];return ie(e.subarray(32),u),h}function ce(e,n,r,o){var i,c=new Uint8Array(32),u=new Uint8Array(64),d=[t(),t(),t(),t()],h=[t(),t(),t(),t()];if(r<64)return-1;if(function(e,n){var r=t(),o=t(),i=t(),c=t(),u=t(),d=t(),h=t();return N(e[2],a),k(e[1],n),q(i,e[1]),L(c,i,l),W(i,i,e[2]),x(c,e[2],c),q(u,c),q(d,u),L(h,d,u),L(r,h,i),L(r,r,c),F(r,r),L(r,r,i),L(r,r,c),L(r,r,c),L(e[0],r,c),q(o,e[0]),L(o,o,c),U(o,i)&&L(e[0],e[0],f),q(o,e[0]),L(o,o,c),U(o,i)?-1:(M(e[0])===n[31]>>7&&W(e[0],s,e[0]),L(e[3],e[0],e[1]),0)}(h,o))return-1;for(i=0;i<r;i++)e[i]=n[i];for(i=0;i<32;i++)e[i+32]=o[i];if(z(u,e,r),se(u),te(d,h,u),ne(h,n.subarray(32)),X(d,h),ee(c,d),r-=64,y(n,0,c,0)){for(i=0;i<r;i++)e[i]=0;return-1}for(i=0;i<r;i++)e[i]=n[i+64];return r}var le,ue=64,de=32,he=64;function fe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function pe(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ge(e){for(var t=0;t<e.length;t++)e[t]=0}e.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:R,crypto_stream:O,crypto_stream_salsa20_xor:E,crypto_stream_salsa20:_,crypto_onetimeauth:S,crypto_onetimeauth_verify:T,crypto_verify_16:v,crypto_verify_32:y,crypto_secretbox:P,crypto_secretbox_open:j,crypto_scalarmult:K,crypto_scalarmult_base:H,crypto_box_beforenm:V,crypto_box_afternm:$,crypto_box:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),$(e,t,n,r,s)},crypto_box_open:function(e,t,n,r,o,i){var s=new Uint8Array(32);return V(s,o,i),Q(e,t,n,r,s)},crypto_box_keypair:G,crypto_hash:z,crypto_sign:ae,crypto_sign_keypair:re,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:de,crypto_sign_SECRETKEYBYTES:he,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:t,D:l,L:oe,pack25519:D,unpack25519:k,M:L,A:x,S:q,Z:W,pow2523:F,add:X,set25519:N,modL:ie,scalarmult:te,scalarbase:ne},e.randomBytes=function(e){var t=new Uint8Array(e);return r(t,e),t},e.secretbox=function(e,t,n){pe(e,t,n),fe(n,t);for(var r=new Uint8Array(32+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+32]=e[i];return P(o,r,r.length,t,n),o.subarray(16)},e.secretbox.open=function(e,t,n){pe(e,t,n),fe(n,t);for(var r=new Uint8Array(16+e.length),o=new Uint8Array(r.length),i=0;i<e.length;i++)r[i+16]=e[i];return r.length<32||0!==j(o,r,r.length,t,n)?null:o.subarray(32)},e.secretbox.keyLength=32,e.secretbox.nonceLength=24,e.secretbox.overheadLength=16,e.scalarMult=function(e,t){if(pe(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return K(n,e,t),n},e.scalarMult.base=function(e){if(pe(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return H(t,e),t},e.scalarMult.scalarLength=32,e.scalarMult.groupElementLength=32,e.box=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox(t,n,i)},e.box.before=function(e,t){pe(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var n=new Uint8Array(32);return V(n,e,t),n},e.box.after=e.secretbox,e.box.open=function(t,n,r,o){var i=e.box.before(r,o);return e.secretbox.open(t,n,i)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return G(e,t),{publicKey:e,secretKey:t}},e.box.keyPair.fromSecretKey=function(e){if(pe(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return H(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.box.publicKeyLength=32,e.box.secretKeyLength=32,e.box.sharedKeyLength=32,e.box.nonceLength=24,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(e,t){if(pe(e,t),t.length!==he)throw new Error("bad secret key size");var n=new Uint8Array(ue+e.length);return ae(n,e,e.length,t),n},e.sign.open=function(e,t){if(pe(e,t),t.length!==de)throw new Error("bad public key size");var n=new Uint8Array(e.length),r=ce(n,e,e.length,t);if(r<0)return null;for(var o=new Uint8Array(r),i=0;i<o.length;i++)o[i]=n[i];return o},e.sign.detached=function(t,n){for(var r=e.sign(t,n),o=new Uint8Array(ue),i=0;i<o.length;i++)o[i]=r[i];return o},e.sign.detached.verify=function(e,t,n){if(pe(e,t,n),t.length!==ue)throw new Error("bad signature size");if(n.length!==de)throw new Error("bad public key size");var r,o=new Uint8Array(ue+e.length),i=new Uint8Array(ue+e.length);for(r=0;r<ue;r++)o[r]=t[r];for(r=0;r<e.length;r++)o[r+ue]=e[r];return ce(i,o,o.length,n)>=0},e.sign.keyPair=function(){var e=new Uint8Array(de),t=new Uint8Array(he);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(pe(e),e.length!==he)throw new Error("bad secret key size");for(var t=new Uint8Array(de),n=0;n<t.length;n++)t[n]=e[32+n];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(pe(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(de),n=new Uint8Array(he),r=0;r<32;r++)n[r]=e[r];return re(t,n,!0),{publicKey:t,secretKey:n}},e.sign.publicKeyLength=de,e.sign.secretKeyLength=he,e.sign.seedLength=32,e.sign.signatureLength=ue,e.hash=function(e){pe(e);var t=new Uint8Array(64);return z(t,e,e.length),t},e.hash.hashLength=64,e.verify=function(e,t){return pe(e,t),0!==e.length&&0!==t.length&&e.length===t.length&&0===g(e,0,t,0,e.length)},e.setPRNG=function(e){r=e},(le="undefined"!=typeof self?self.crypto||self.msCrypto:null)&&le.getRandomValues?e.setPRNG(function(e,t){var n,r=new Uint8Array(t);for(n=0;n<t;n+=65536)le.getRandomValues(r.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=r[n];ge(r)}):(le=n(4355))&&le.randomBytes&&e.setPRNG(function(e,t){var n,r=le.randomBytes(t);for(n=0;n<t;n++)e[n]=r[n];ge(r)})}(e.exports?e.exports:self.nacl=self.nacl||{})},8926:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONNECTION_HTTP_EXPIRATION_TIME=void 0,t.isPendingConnectionHttp=function(e){return!("connectEvent"in e)},t.isPendingConnectionHttpRaw=function(e){return!("connectEvent"in e)},t.isExpiredPendingConnectionHttpRaw=function(e){var n;return Date.now()-(null!==(n=e.createdAt)&&void 0!==n?n:0)>t.CONNECTION_HTTP_EXPIRATION_TIME},t.CONNECTION_HTTP_EXPIRATION_TIME=3e5},9373:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.createResource=function(e,t){let n=null,a=null,c=null,l=null,u=null;const d=(i,...d)=>r(this,void 0,void 0,function*(){if(l=null!=i?i:null,null==u||u.abort(),u=(0,s.createAbortController)(i),u.signal.aborted)throw new o.TonConnectError("Resource creation was aborted");a=null!=d?d:null;const r=e(u.signal,...d);c=r;const h=yield r;if(c!==r&&h!==n)throw yield t(h),new o.TonConnectError("Resource creation was aborted by a new resource creation");return n=h,n});return{create:d,current:()=>null!=n?n:null,dispose:()=>r(this,void 0,void 0,function*(){try{const e=n;n=null;const r=c;c=null;try{null==u||u.abort()}catch(e){}yield Promise.allSettled([e?t(e):Promise.resolve(),r?t(yield r):Promise.resolve()])}catch(e){}}),recreate:e=>r(this,void 0,void 0,function*(){const t=n,r=c,s=a,u=l;if(yield(0,i.delay)(e),t===n&&r===c&&s===a&&u===l)return yield d(l,...null!=s?s:[]);throw new o.TonConnectError("Resource recreation was aborted by a new resource creation")})}};const o=n(2931),i=n(6878),s=n(607)},9509:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendTransactionParser=void 0;const r=n(7321),o=n(2931),i=n(5137),s=n(4475),a={[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:i.UnknownError,[r.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:o.UserRejectsError,[r.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:o.BadRequestError,[r.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:o.UnknownAppError};class c extends s.RpcParser{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=i.UnknownError;throw e.error.code in a&&(t=a[e.error.code]||i.UnknownError),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}t.sendTransactionParser=new c},9651:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateSendTransactionRequest=function(e){if(!y(e))return"Request must be an object";if(b(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!h(e.validUntil))return"Incorrect 'validUntil'";const t=Math.floor(Date.now()/1e3),n=t+300;e.validUntil>n&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!g(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!p(e.from))return"Invalid 'from' address format";if(t=e.messages,!Array.isArray(t)||0===e.messages.length)return"'messages' is required";var t;for(let t=0;t<e.messages.length;t++){const n=w(e.messages[t],t);if(n)return n}return null},t.validateConnectAdditionalRequest=function(e){if(!y(e))return"Request must be an object";if(b(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";const t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";const n=(0,o.getDomain)();if(!n)return null;const r=(new TextEncoder).encode(n).length;if(r>l)return"Current domain exceeds 128 bytes limit";const i=(new TextEncoder).encode(t).length;if(i>u)return"'tonProof' payload exceeds 128 bytes limit";if(r+i>d)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null},t.validateSignDataPayload=function(e){if(!y(e))return"Payload must be an object";if(!f(e.type))return"'type' is required";switch(e.type){case"text":return function(e){return b(e,["type","text","network","from"])?"Text payload contains extra properties":f(e.text)?void 0===e.network||g(e.network)?void 0===e.from||p(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'text' is required"}(e);case"binary":return function(e){return b(e,["type","bytes","network","from"])?"Binary payload contains extra properties":f(e.bytes)?void 0===e.network||g(e.network)?void 0===e.from||p(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"'bytes' is required"}(e);case"cell":return function(e){return b(e,["type","schema","cell","network","from"])?"Cell payload contains extra properties":f(e.schema)?f(e.cell)?v(e.cell)?void 0===e.network||g(e.network)?void 0===e.from||p(e.from)?null:"Invalid 'from'":"Invalid 'network' format":"Invalid 'cell' format (must be valid base64)":"'cell' is required":"'schema' is required"}(e);default:return"Invalid 'type' value"}},t.validateTonProofItemReply=function(e){if(!y(e))return"ton_proof item must be an object";if(b(e,["error","proof","name"]))return"ton_proof item contains extra properties";const t=Object.prototype.hasOwnProperty.call(e,"proof"),n=Object.prototype.hasOwnProperty.call(e,"error");if(!t&&!n)return"'ton_proof' item must contain either 'proof' or 'error'";if(t&&n)return"'ton_proof' item must contain either 'proof' or 'error', not both";if(t){const t=e.proof;if(!y(t))return"Invalid 'proof' object";if(b(t,["timestamp","domain","payload","signature"]))return"ton_proof item contains extra properties";if(!h(t.timestamp))return"Invalid 'proof.timestamp'";const n=t.domain;if(!y(n))return"Invalid 'proof.domain'";if(!h(n.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!f(n.value))return"Invalid 'proof.domain.value'";try{if(("undefined"!=typeof TextEncoder?(new TextEncoder).encode(n.value).length:n.value.length)!==n.lengthBytes)return"'proof.domain.lengthBytes' does not match 'proof.domain.value'"}catch(e){}if(!f(t.payload))return"Invalid 'proof.payload'";if(!f(t.signature)||!i.test(t.signature))return"Invalid 'proof.signature' format"}if(n){const t=e.error;if(!y(t))return"Invalid 'error' object";if(b(t,["code","message"]))return"ton_proof error contains extra properties";if(!h(t.code))return"Invalid 'error.code'";if(!f(t.message))return"Invalid 'error.message'"}return null};const r=n(8409),o=n(5418),i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s="te6cc",a=/^-?\d+$/,c=/^\d+$/,l=128,u=128,d=222;function h(e){return"number"==typeof e&&!isNaN(e)}function f(e){return"string"==typeof e&&e.length>0}function p(e){return f(e)&&((0,r.isValidRawAddress)(e)||(0,r.isValidUserFriendlyAddress)(e))}function g(e){return f(e)&&/^-?\d+$/.test(e)}function v(e){return"string"==typeof e&&i.test(e)&&e.startsWith(s)}function y(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function b(e,t){return Object.keys(e).some(e=>!t.includes(e))}function w(e,t){if(!y(e))return`Message at index ${t} must be an object`;if(b(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!f(e.address))return`'address' is required in message at index ${t}`;if(!(0,r.isValidUserFriendlyAddress)(e.address))return`Wrong 'address' format in message at index ${t}`;if(!f(e.amount))return`'amount' is required in message at index ${t}`;if(!/^[0-9]+$/.test(e.amount))return`Incorrect 'amount' in message at index ${t}`;if(!(void 0===e.stateInit||f(e.stateInit)&&v(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(!(void 0===e.payload||f(e.payload)&&v(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!y(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(const[n,r]of Object.entries(e.extraCurrency))if(!a.test(n)||"string"!=typeof r||!c.test(r))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}},9660:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.WalletsListManager=void 0;const o=n(8599),i=n(8158),s=n(2636),a=n(1203),c=n(7569),l=n(6351);t.WalletsListManager=class{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,(0,l.isQaModeEnabled)()?this.walletsListSource="https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json":this.walletsListSource=null!==(t=null==e?void 0:e.walletsListSource)&&void 0!==t?t:"https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs}getWallets(){return r(this,void 0,void 0,function*(){const[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return r(this,void 0,void 0,function*(){const e=(yield this.getWallets()).filter(i.isWalletInfoCurrentlyEmbedded);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return r(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListDTOCacheCreationTimestamp&&Date.now()>this.walletsListDTOCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListDTOCache=null),this.walletsListDTOCache||(this.walletsListDTOCache=this.fetchWalletsListFromSource(),this.walletsListDTOCache.then(()=>{this.walletsListDTOCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null})),this.walletsListDTOCache})}fetchWalletsListFromSource(){return r(this,void 0,void 0,function*(){let e=[];try{const t=yield fetch(this.walletsListSource);if(e=yield t.json(),!Array.isArray(e))throw new o.FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const n=e.filter(e=>!this.isCorrectWalletConfigDTO(e));n.length&&((0,a.logError)(`Wallet(s) ${n.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(e=>this.isCorrectWalletConfigDTO(e)))}catch(t){(0,a.logError)(t),e=c.FALLBACK_WALLETS_LIST}return e})}getCurrentlyInjectedWallets(){if(!(0,l.isQaModeEnabled)())return[];try{return s.InjectedProvider.getCurrentlyInjectedWallets()}catch(e){return(0,a.logError)(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{const t={name:e.name,appName:e.app_name,imageUrl:e.image,aboutUrl:e.about_url,tondns:e.tondns,platforms:e.platforms,features:e.features};return e.bridge.forEach(n=>{if("sse"===n.type&&(t.bridgeUrl=n.url,t.universalLink=e.universal_url,t.deepLink=e.deepLink),"js"===n.type){const e=n.key;t.jsBridgeKey=e,t.injected=s.InjectedProvider.isWalletInjected(e),t.embedded=s.InjectedProvider.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{const r=e.find(e=>e.name===n),o=t.find(e=>e.name===n);return Object.assign(Object.assign({},r&&Object.assign({},r)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;if(!("name"in e&&"image"in e&&"about_url"in e&&"platforms"in e&&"app_name"in e))return!1;if(!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length)return!1;if(!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const t=e.bridge;if(t.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;const n=t.find(e=>"sse"===e.type);if(n&&("object"!=typeof n||!("url"in n)||!n.url||!e.universal_url))return!1;const r=t.find(e=>"js"===e.type);return!!(!r||"object"==typeof r&&"key"in r&&r.key)}}},9746:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWalletInfoInjected=t.isWalletInfoRemote=t.isWalletInfoInjectable=t.isWalletInfoCurrentlyEmbedded=t.isWalletInfoCurrentlyInjected=void 0;var r=n(8158);Object.defineProperty(t,"isWalletInfoCurrentlyInjected",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyInjected}}),Object.defineProperty(t,"isWalletInfoCurrentlyEmbedded",{enumerable:!0,get:function(){return r.isWalletInfoCurrentlyEmbedded}}),Object.defineProperty(t,"isWalletInfoInjectable",{enumerable:!0,get:function(){return r.isWalletInfoInjectable}}),Object.defineProperty(t,"isWalletInfoRemote",{enumerable:!0,get:function(){return r.isWalletInfoRemote}}),Object.defineProperty(t,"isWalletInfoInjected",{enumerable:!0,get:function(){return r.isWalletInfoInjected}})}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(151);TonConnectSDK=n})();
2
2
  //# sourceMappingURL=tonconnect-sdk.min.js.map