PageSourceSearch

https://cas-ru-jack-jt.life/_next/static/chunks/9e84c5da.bb4b3cef161a02e6.js

js cas-ru-jack-jt.life collected 2026-10-09 21:26:19 UTC 105,228 bytes, 37 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="18fb3a7f-80f0-4c0d-93b6-a99b0d2539fb",e._sentryDebugIdIdentifier="sentry-dbid-18fb3a7f-80f0-4c0d-93b6-a99b0d2539fb")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4084],{95636:(e,t,n)=>{let i;n.d(t,{$2:()=>eF,$e:()=>ej,AL:()=>eS,BH:()=>eR,Bk:()=>T,CY:()=>C,Dg:()=>eB,Dj:()=>Z,Dn:()=>r.Dn,Ee:()=>ed,Es:()=>eO,F2:()=>r.F2,GE:()=>td,Gz:()=>eT,IS:()=>r.IS,K3:()=>l,K4:()=>r.K4,L4:()=>ey,LC:()=>h,Mx:()=>eP,NQ:()=>eq,NU:()=>g,S5:()=>r.S5,Sq:()=>eJ,TB:()=>eA,TW:()=>S,UserRejectsError:()=>y,VA:()=>eD,Vb:()=>D,_0:()=>eC,aV:()=>eM,dQ:()=>e$,fB:()=>N,hq:()=>v,iA:()=>f,ik:()=>_,ip:()=>ep,isWalletInfoCurrentlyEmbedded:()=>eu,j9:()=>eW,kB:()=>tl,kO:()=>b,kT:()=>m,kW:()=>p,lp:()=>eN,m5:()=>eE,m_:()=>tn,nB:()=>B,o2:()=>r.o2,oJ:()=>eg,q:()=>eU,qC:()=>eK,rG:()=>U,rH:()=>ta,sQ:()=>ex,te:()=>eh,v7:()=>w,xk:()=>ew,zf:()=>I});var r=n(67868),o=n(87358);function s(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}function a(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class l extends Error{get info(){return""}constructor(e,t){super(e,t),this.message=`${l.prefix} ${this.constructor.name}${this.info?": "+this.info:""}${e?"\n"+e:""}`,Object.setPrototypeOf(this,l.prototype)}}l.prefix="[TON_CONNECT_SDK_ERROR]";class c extends l{get info(){return"Passed DappMetadata is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,c.prototype)}}class d extends l{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,d.prototype)}}class u extends l{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,u.prototype)}}class h extends l{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,h.prototype)}}class p extends l{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,p.prototype)}}class g extends l{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,g.prototype)}}class m extends l{get info(){return"Wallet doesn't support requested feature method."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,m.prototype)}}class f extends l{get info(){return"Missing required features. You need to update your wallet."}constructor(e,t){super(e,t),Object.setPrototypeOf(this,f.prototype)}}class v extends l{constructor(e,t){super(e,t),this.name="WalletWrongNetworkError",Object.setPrototypeOf(this,v.prototype)}}class y extends l{get info(){return"User rejects the action in the wallet."}constructor(...e){super(...e),Object.setPrototypeOf(this,y.prototype)}}class w extends l{get info(){return"Request to the wallet contains errors."}constructor(...e){super(...e),Object.setPrototypeOf(this,w.prototype)}}class b extends l{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(...e){super(...e),Object.setPrototypeOf(this,b.prototype)}}class _ extends l{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,_.prototype)}}class S extends l{get info(){return"An error occurred while fetching the wallets list."}constructor(...e){super(...e),Object.setPrototypeOf(this,S.prototype)}}class C extends l{get info(){return"Passed address is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,C.prototype)}}class I extends l{get info(){return"Passed hex is in incorrect format."}constructor(...e){super(...e),Object.setPrototypeOf(this,I.prototype)}}class T extends l{constructor(...e){super(...e),Object.setPrototypeOf(this,T.prototype)}}let E={[r.IS.UNKNOWN_ERROR]:T,[r.IS.USER_REJECTS_ERROR]:y,[r.IS.BAD_REQUEST_ERROR]:w,[r.IS.UNKNOWN_APP_ERROR]:b,[r.IS.MANIFEST_NOT_FOUND_ERROR]:u,[r.IS.MANIFEST_CONTENT_ERROR]:d};class R{parseError(e){let t=T;return e.code in E&&(t=E[e.code]||T),new t(e.message)}}let k=new R;class O{isError(e){return"error"in e}}let x={[r.K4.UNKNOWN_ERROR]:T,[r.K4.USER_REJECTS_ERROR]:y,[r.K4.BAD_REQUEST_ERROR]:w,[r.
1K4.UNKNOWN_APP_ERROR]:b};class j extends O{convertToRpcRequest(e){return{method:"sendTransaction",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=T;throw e.error.code in x&&(t=x[e.error.code]||T),new t(e.error.message)}convertFromRpcResponse(e){return{boc:e.result}}}let W=new j,q={[r.Dn.UNKNOWN_ERROR]:T,[r.Dn.USER_REJECTS_ERROR]:y,[r.Dn.BAD_REQUEST_ERROR]:w,[r.Dn.UNKNOWN_APP_ERROR]:b};class P extends O{convertToRpcRequest(e){return{method:"signData",params:[JSON.stringify(e)]}}parseAndThrowError(e){let t=T;throw e.error.code in q&&(t=q[e.error.code]||T),new t(e.error.message)}convertFromRpcResponse(e){return e.result}}let L=new P;class M{constructor(e,t){this.storage=e,this.storeKey="ton-connect-storage_http-bridge-gateway::"+t}storeLastEventId(e){return a(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,e)})}removeLastEventId(){return a(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return a(this,void 0,void 0,function*(){let e=yield this.storage.getItem(this.storeKey);return e||null})}}function A(e,t){return("/"===e.slice(-1)?e.slice(0,-1):e)+"/"+t}function D(e){if(!e)return!1;let t=new URL(e);return"tg:"===t.protocol||"t.me"===t.hostname}function U(e){return!!e&&(e.includes("ton_addr")||e.includes("ton--5Faddr"))}function N(e){return e.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}function B(e){return e.replaceAll("--","%").replaceAll("__","=").replaceAll("-","&").replaceAll("%5F","_").replaceAll("%2D","-").replaceAll("%2E",".")}function $(e,t){return a(this,void 0,void 0,function*(){return new Promise((t,n)=>{setTimeout(()=>t(),e)})})}function K(e){let t=new AbortController;return(null==e?void 0:e.aborted)?t.abort():null==e||e.addEventListener("abort",()=>t.abort(),{once:!0}),t}function F(e,t){return a(this,void 0,void 0,function*(){var n,i;let r,o=null!=(n=null==t?void 0:t.attempts)?n:10,s=null!=(i=null==t?void 0:t.delayMs)?i:200,a=K(null==t?void 0:t.signal);if("function"!=typeof e)throw new l(`Expected a function, got ${typeof e}`);let c=0;for(;c<o;){if(a.signal.aborted)throw new l(`Aborted after attempts ${c}`);try{return yield e({signal:a.signal})}catch(e){r=e,++c<o&&(yield $(s))}}throw r})}function G(...e){try{console.debug("[TON_CONNECT_SDK]",...e)}catch(e){}}function z(...e){try{console.error("[TON_CONNECT_SDK]",...e)}catch(e){}}class J{get isReady(){let e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.OPEN}get isClosed(){let e=this.eventSource.current();return(null==e?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){let e=this.eventSource.current();return(null==e?void 0:e.readyState)===EventSource.CONNECTING}constructor(e,t,n,i,r,o){this.bridgeUrl=t,this.sessionId=n,this.listener=i,this.errorsListener=r,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=function(e,t){let n=null,i=null,r=null,o=null,s=null,c=(c,...d)=>a(this,void 0,void 0,function*(){if(o=null!=c?c:null,null==s||s.abort(),(s=K(c)).signal.aborted)throw new l("Resource creation was aborted");i=null!=d?d:null;let a=e(s.signal,...d);r=a;let u=yield a;if(r!==a&&u!==n)throw yield t(u),new l("Resource creation was aborted by a new resource creation");return n=u}),d=e=>a(this,void 0,void 0,function*(){let t=n,s=r,a=i,d=o;if(yield $(e),t===n&&s===r&&a===i&&d===o)return yield c(o,...null!=a?a:[]);throw new l("Resource recreation was aborted by a new resource creation")});return{create:c,current:()=>null!=n?n:null,dispose:()=>a(this,void 0,void 0,function*(){try{let e=n;n=null;let i=r;r=null;try{null==s||s.abort()}catch(e){}yield Promise.allSettled([e?t(e):Promise.resolve(),i?t((yield i)):Promise.resolve()])}catch(e){}}),recreate:d}}((e,t,n)=>a(this,void 0,void 0,function*(){let i={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,traceId:n};return yield function(e){return a(this,void 0,void 0,function*(){return yield function(e,t){let n=null==t?void 0:t.t
1imeout,i=K(null==t?void 0:t.signal);return new Promise((t,r)=>a(this,void 0,void 0,function*(){let o;if(i.signal.aborted)return void r(new l("Operation aborted"));void 0!==n&&(o=setTimeout(()=>{i.abort(),r(new l(`Timeout after ${n}ms`))},n)),i.signal.addEventListener("abort",()=>{clearTimeout(o),r(new l("Operation aborted"))},{once:!0});let s={timeout:n,abort:i.signal};yield e((...e)=>{clearTimeout(o),t(...e)},()=>{clearTimeout(o),r()},s)}))}((t,n,i)=>a(this,void 0,void 0,function*(){var r;let o=K(i.signal).signal;if(o.aborted)return void n(new l("Bridge connection aborted"));let s=new URL(A(e.bridgeUrl,e.ssePath));s.searchParams.append("client_id",e.sessionId);let c=yield e.bridgeGatewayStorage.getLastEventId();if(c&&s.searchParams.append("last_event_id",c),e.traceId&&s.searchParams.append("trace_id",e.traceId),o.aborted)return void n(new l("Bridge connection aborted"));let d=new EventSource(s.toString());d.onerror=i=>a(this,void 0,void 0,function*(){if(o.aborted){d.close(),n(new l("Bridge connection aborted"));return}try{let n=yield e.errorHandler(d,i);n!==d&&d.close(),n&&n!==d&&t(n)}catch(e){d.close(),n(e)}}),d.onopen=()=>{if(o.aborted){d.close(),n(new l("Bridge connection aborted"));return}t(d)},d.onmessage=t=>{if(o.aborted){d.close(),n(new l("Bridge connection aborted"));return}e.messageHandler(t)},null==(r=e.signal)||r.addEventListener("abort",()=>{d.close(),n(new l("Bridge connection aborted"))})}),{timeout:e.openingDeadlineMS,signal:e.signal})})}(i)}),e=>a(this,void 0,void 0,function*(){e.close()})),this.bridgeGatewayStorage=new M(e,t),this.analytics=null==o?void 0:o.scoped({bridge_url:t,client_id:n})}registerSession(e){return a(this,void 0,void 0,function*(){var t,n,i;try{null==(t=this.analytics)||t.emitBridgeClientConnectStarted({trace_id:null==e?void 0:e.traceId});let i=Date.now();yield this.eventSource.create(null==e?void 0:e.signal,null==e?void 0:e.openingDeadlineMS,null==e?void 0:e.traceId);let r=Date.now()-i;null==(n=this.analytics)||n.emitBridgeClientConnectEstablished({bridge_connect_duration:r,trace_id:null==e?void 0:e.traceId})}catch(t){throw null==(i=this.analytics)||i.emitBridgeClientConnectError({trace_id:null==e?void 0:e.traceId,error_message:String(t)}),t}})}send(e,t,n,i){return a(this,void 0,void 0,function*(){var o;let s={};"number"==typeof i?s.ttl=i:(s.ttl=null==i?void 0:i.ttl,s.signal=null==i?void 0:i.signal,s.attempts=null==i?void 0:i.attempts,s.traceId=null==i?void 0:i.traceId);let c=new URL(A(this.bridgeUrl,this.postPath));c.searchParams.append("client_id",this.sessionId),c.searchParams.append("to",t),c.searchParams.append("ttl",((null==s?void 0:s.ttl)||this.defaultTtl).toString()),c.searchParams.append("topic",n),(null==s?void 0:s.traceId)&&c.searchParams.append("trace_id",s.traceId);let d=r.o4.encode(e);yield F(e=>a(this,void 0,void 0,function*(){let t=yield this.post(c,d,e.signal);if(!t.ok)throw new l(`Bridge send failed, status ${t.status}`)}),{attempts:null!=(o=null==s?void 0:s.attempts)?o:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:null==s?void 0:s.signal})})}pause(){this.eventSource.dispose().catch(e=>z(`Bridge pause failed, ${e}`))}unPause(){return a(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return a(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>z(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,t,n){return a(this,void 0,void 0,function*(){let i=yield fetch(e,{method:"post",body:t,signal:n});if(!i.ok)throw new l(`Bridge send failed, status ${i.status}`);return i})}errorsHandler(e,t){return a(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new l("Bridge error, failed to connect");if(this.isReady){try{this.errorsListener(t)}catch(e){}return}if(this.isClosed)return e.close(),G(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new l("Bridge error, unknown state")})}messagesHandler(e){return a(this,void 0,void 0,function*(){let t;if(e.data!==this.heartbeatMessage&&(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),!this.isClosed)){try{let n=JSON.parse(e.data);t={message:n.message,from:n.from,traceId:n.trace_id}}catch(t){throw new l(`Bridge message parse failed, message ${e.data}`)}this.listener(t)}})}}function H(e){return!("connectEvent"in e)}let V=new Uint8Array(16);function Q(){if(!i){if("undefined"==typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");i=crypto.getRandomValues.bind(crypto)}return i(V)}
1let X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));let Y={};function Z(e,t,n){var i,r,o,s,a,l;let c;if(e)c=ee(null!=(o=null!=(i=e.random)?i:null==(r=e.rng)?void 0:r.call(e))?o:Q(),e.msecs,e.seq,t,n);else{let e=Date.now(),i=Q();s=Y,a=e,l=i,null!=s.msecs||(s.msecs=-1/0),null!=s.seq||(s.seq=0),a>s.msecs?(s.seq=l[6]<<23|l[7]<<16|l[8]<<8|l[9],s.msecs=a):(s.seq=s.seq+1|0,0===s.seq&&s.msecs++),c=ee(i,Y.msecs,Y.seq,t,n)}return null!=t?t:function(e,t=0){return(X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+"-"+X[e[t+4]]+X[e[t+5]]+"-"+X[e[t+6]]+X[e[t+7]]+"-"+X[e[t+8]]+X[e[t+9]]+"-"+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]).toLowerCase()}(c)}function ee(e,t,n,i,r=0){if(e.length<16)throw Error("Random bytes length must be >= 16");if(i){if(r<0||r+16>i.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`)}else i=new Uint8Array(16),r=0;return null!=t||(t=Date.now()),null!=n||(n=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9]),i[r++]=t/0x10000000000&255,i[r++]=t/0x100000000&255,i[r++]=t/0x1000000&255,i[r++]=t/65536&255,i[r++]=t/256&255,i[r++]=255&t,i[r++]=112|n>>>28&15,i[r++]=n>>>20&255,i[r++]=128|n>>>14&63,i[r++]=n>>>6&255,i[r++]=n<<2&255|3&e[10],i[r++]=e[11],i[r++]=e[12],i[r++]=e[13],i[r++]=e[14],i[r++]=e[15],i}class et{static fromStorage(e,t){return a(this,void 0,void 0,function*(){let n=yield e.getHttpConnection();return H(n)?new et(e,n.connectionSource,t):new et(e,{bridgeUrl:n.session.bridgeUrl},t)})}constructor(e,t,n){var i;this.connectionStorage=e,this.walletConnectionSource=t,this.analyticsManager=n,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.optionalOpenGateways=3,this.analytics=null==(i=this.analyticsManager)?void 0:i.scoped()}connect(e,t){var n,i;let o=null!=(n=null==t?void 0:t.traceId)?n:Z(),s=K(null==t?void 0:t.signal);null==(i=this.abortController)||i.abort(),this.abortController=s,this.closeGateways();let l=new r.o2;this.session={sessionCrypto:l,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:l}).then(()=>a(this,void 0,void 0,function*(){s.signal.aborted||(yield F(e=>{var n;return this.openGateways(l,{openingDeadlineMS:null!=(n=null==t?void 0:t.openingDeadlineMS)?n:this.defaultOpeningDeadlineMS,signal:null==e?void 0:e.signal,traceId:o})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:s.signal}))}));let c="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(c,e,{traceId:o})}restoreConnection(e){return a(this,void 0,void 0,function*(){var t,n,i;let r=null!=(t=null==e?void 0:e.traceId)?t:Z(),o=K(null==e?void 0:e.signal);if(null==(n=this.abortController)||n.abort(),this.abortController=o,o.signal.aborted)return;this.closeGateways();let s=yield this.connectionStorage.getHttpConnection();if(!s||o.signal.aborted)return;let a=null!=(i=null==e?void 0:e.openingDeadlineMS)?i:this.defaultOpeningDeadlineMS;if(H(s))return this.session={sessionCrypto:s.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(s.sessionCrypto,{openingDeadlineMS:a,signal:null==o?void 0:o.signal,traceId:null==e?void 0:e.traceId});if(Array.isArray(this.walletConnectionSource))throw new l("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=s.session,this.gateway&&(G("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new J(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,s.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),!o.signal.aborted){this.listeners.forEac
1h(e=>e(Object.assign(Object.assign({},s.connectEvent),{traceId:r})));try{yield F(e=>this.gateway.registerSession({openingDeadlineMS:a,signal:e.signal,traceId:r}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:o.signal})}catch(e){yield this.disconnect({signal:o.signal,traceId:r});return}}})}sendRequest(e,t){let 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,n.traceId=null==t?void 0:t.traceId),null!=n.traceId||(n.traceId=Z()),new Promise((t,i)=>a(this,void 0,void 0,function*(){var o,s;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new l("Trying to send bridge request without session");let a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),G("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));let c=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),(0,r.Aq)(this.session.walletPublicKey));try{null==(o=this.analytics)||o.emitBridgeClientMessageSent({bridge_url:this.gateway.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:this.session.walletPublicKey,message_id:a,request_type:e.method,trace_id:n.traceId}),yield this.gateway.send(c,this.session.walletPublicKey,e.method,{attempts:null==n?void 0:n.attempts,signal:null==n?void 0:n.signal,traceId:n.traceId}),null==(s=null==n?void 0:n.onRequestSent)||s.call(n),this.pendingRequests.set(a.toString(),t)}catch(e){i(e)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return a(this,void 0,void 0,function*(){var t;let n=null!=(t=null==e?void 0:e.traceId)?t:Z();return new Promise(t=>a(this,void 0,void 0,function*(){let i=!1,r=null,o=()=>{i||(i=!0,this.removeBridgeAndSession().then(t))};try{this.closeGateways();let t=K(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,traceId:n})}catch(e){G("Disconnect error:",e),i||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)||e.pause(),this.pendingGateways.forEach(e=>e.pause())}unPause(){return a(this,void 0,void 0,function*(){let e=this.pendingGateways.map(e=>e.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,t,n){return a(this,void 0,void 0,function*(){return this.pendingGateways.includes(e)?(this.closeGateways({except:e}),this.gateway&&(G("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)):void(yield e.close())})}gatewayListener(e){return a(this,void 0,void 0,function*(){var t,n,i;let o,s=null!=(t=e.traceId)?t:Z();try{o=JSON.parse(this.session.sessionCrypto.decrypt(r.o4.decode(e.message).toUint8Array(),(0,r.Aq)(e.from)))}catch(t){throw null==(n=this.analytics)||n.emitBridgeClientMessageDecodeError({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,error_message:String(t),trace_id:null==e?void 0:e.traceId}),t}G("Wallet message received:",o);let a="event"in o?o.event:"";if(null==(i=this.analytics)||i.emitBridgeClientMessageReceived({bridge_url:this.session.bridgeUrl,client_id:this.session.sessionCrypto.sessionId,wallet_id:e.from,message_id:String(o.id),request_type:a,trace_id:null==e?void 0:e.traceId}),!("event"in o)){let e=o.id.toString(),t=this.pendingRequests.get(e);return t?(t(Object.assign(Object.assign({},o),{traceId:s})),void this.pendingRequests.delete(e)):void G(`Response id ${e} doesn't match any request's id`)}if(void 0!==o.id){let e=yield this.connectionStorage.getLastWalletEventId();if(void 0!==e&&o.id<=e)return void z(`Received event id (=${o.id}) must be greater than stored last wallet event id (=${e}) `);"connect"!==o.event&&(yield this.connectionStorage.storeLastWalletEventId(o.id))}let l=this.listeners;"connect"===o.event&&(yield this.updateSession(o,e.from)),"disconnect"===o.event&&(G("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),l.forEach(e
1=>e(Object.assign(Object.assign({},o),{traceId:s})))})}gatewayErrorsListener(e){return a(this,void 0,void 0,function*(){throw new l(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,t){return a(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:t});let n=e.payload.items.find(e=>"ton_addr"===e.name),i=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:i,nextRpcRequestId:0})})}removeBridgeAndSession(){return a(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,t,n){return D(e)?this.generateTGUniversalLink(e,t,n):this.generateRegularUniversalLink(e,t,n)}generateRegularUniversalLink(e,t,n){let i=new URL(e);return i.searchParams.append("v","2"),i.searchParams.append("id",this.session.sessionCrypto.sessionId),i.searchParams.append("trace_id",n.traceId),i.searchParams.append("r",JSON.stringify(t)),i.toString()}generateTGUniversalLink(e,t,n){let i="tonconnect-"+N(this.generateRegularUniversalLink("about:blank",t,n).split("?")[1]),r=new URL(this.convertToDirectLink(e));return r.searchParams.append("startapp",i),r.toString()}convertToDirectLink(e){let t=new URL(e);return t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start"),t.toString()}openGateways(e,t){return a(this,void 0,void 0,function*(){var n;let i=null!=(n=null==t?void 0:t.traceId)?n:Z();if(!Array.isArray(this.walletConnectionSource))return this.gateway&&(G("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new J(this.connectionStorage.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this),this.analyticsManager),yield this.gateway.registerSession({openingDeadlineMS:null==t?void 0:t.openingDeadlineMS,signal:null==t?void 0:t.signal,traceId:i});{this.pendingGateways.map(e=>e.close().catch()),this.pendingGateways=this.walletConnectionSource.map(t=>{let n=new J(this.connectionStorage.storage,t.bridgeUrl,e.sessionId,()=>{},()=>{},this.analyticsManager);return n.setListener(e=>this.pendingGatewaysListener(n,t.bridgeUrl,e)),n});let n=Math.max(this.pendingGateways.length-this.optionalOpenGateways,1);yield function(e,t){return a(this,void 0,void 0,function*(){if(t<=0)return[];if(t>e.length)throw RangeError("count cannot be greater than the number of promises");let n=Array(e.length),i=0;return new Promise(r=>{e.forEach((e,o)=>{Promise.resolve(e).then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e})).then(e=>{n[o]=e,++i===t&&r(n)})})})})}(this.pendingGateways.map(e=>F(n=>{var r;return this.pendingGateways.some(t=>t===e)?e.registerSession({openingDeadlineMS:null!=(r=null==t?void 0:t.openingDeadlineMS)?r:this.defaultOpeningDeadlineMS,signal:n.signal,traceId:i}):e.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:null==t?void 0:t.signal})),n);return}})}closeGateways(e){var t;null==(t=this.gateway)||t.close(),this.pendingGateways.filter(t=>t!==(null==e?void 0:e.except)).forEach(e=>e.close()),this.pendingGateways=[]}}function en(e,t){return!!e&&"object"==typeof e&&t.every(t=>t in e)}class ei{static getInstance(){return ei.instance||(ei.instance=new ei),ei.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])?t:null}key(e){var t;let n=Object.keys(this.storage);return e<0||e>=n.length?null:null!=(t=n[e])?t:null}removeItem(e){delete this.storage[e]}setItem(e,t){this.storage[e]=t}}function er(){if("undefined"!=typeof window)return window}function eo(){if("undefined"!=typeof document)return document}function es(){var e,t,n,i;let r=null==(t=null==(e=er())?void 0:e.location)?void 0:t.origin,o=null==(i=null==(n=er())?void 0:n.location)?void 0:i.pathname;return r&&o?r+o:""}class ea{static fromStorage(e,t){return a(this,void 0,void 0,function*(){let n=yield e.getInjectedConnection();return new ea(e,n.jsBridgeKey,t)})}static isWalletInjected(e){return ea.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return!!ea.isWindowContainsWallet(this.window,e)&&this.window[e].tonconnect.isWalletBrowser}static getCurrentlyInjectedWallets(){return this.window?(function(){let e=er();if(!e)return[];try{return Object.entries(e)}catch(e){return[]}})().filter(([e,t])=>(function(e){try{var t;if(!en(e,["tonconnect"])||(t=e.tonconnect,!en(t,["walletInfo"])))return!1;return en(e.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch(e){return!1}})(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,n){this.connectionStorage=e,this.injectedWalletKey=t,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];let i=ea.window;if(!ea.isWindowContainsWallet(i,t))throw new g;
1this.injectedWallet=i[t].tonconnect,n&&(this.analytics=n.scoped({bridge_key:t,wallet_app_name:this.injectedWallet.deviceInfo.appName,wallet_app_version:this.injectedWallet.deviceInfo.appVersion}))}connect(e,t){this._connect(2,e,t)}restoreConnection(e){return a(this,void 0,void 0,function*(){var t,n,i,r;let o=null!=(t=null==e?void 0:e.traceId)?t:Z();try{G("Injected Provider restoring connection..."),null==(n=this.analytics)||n.emitJsBridgeCall({js_bridge_method:"restoreConnection",trace_id:o});let e=yield this.injectedWallet.restoreConnection();null==(i=this.analytics)||i.emitJsBridgeResponse({js_bridge_method:"restoreConnection",trace_id:o}),G("Injected Provider restoring connection response",e),"connect"===e.event?(this.makeSubscriptions({traceId:o}),this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:o})))):yield this.connectionStorage.removeConnection()}catch(e){null==(r=this.analytics)||r.emitJsBridgeError({js_bridge_method:"restoreConnection",error_message:String(e),trace_id:o}),yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(e){return a(this,void 0,void 0,function*(){var t;let n=null!=(t=null==e?void 0:e.traceId)?t:Z();return new Promise(e=>{let t=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),t()}catch(e){G(e),this.sendRequest({method:"disconnect",params:[]},{onRequestSent:t,traceId:n})}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],null==(e=this.unsubscribeCallback)||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}sendRequest(e,t){return a(this,void 0,void 0,function*(){var n,i,r;let o={};"function"==typeof t?(o.onRequestSent=t,o.traceId=Z()):(o.onRequestSent=null==t?void 0:t.onRequestSent,o.signal=null==t?void 0:t.signal,o.attempts=null==t?void 0:t.attempts,o.traceId=null!=(n=null==t?void 0:t.traceId)?n:Z());let s=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),G("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:s})),null==(i=this.analytics)||i.emitJsBridgeCall({js_bridge_method:"send"});let a=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:s}));return a.then(e=>{var t;null==(t=this.analytics)||t.emitJsBridgeResponse({js_bridge_method:"send"}),G("Wallet message received:",e)}).catch(e=>{var t;null==(t=this.analytics)||t.emitJsBridgeError({js_bridge_method:"send",error_message:String(e)})}),null==(r=null==o?void 0:o.onRequestSent)||r.call(o),a})}_connect(e,t,n){return a(this,void 0,void 0,function*(){var i,r,o,s;let a=null!=(i=null==n?void 0:n.traceId)?i:Z();try{G(`Injected Provider connect request: protocolVersion: ${e}, message:`,t),null==(r=this.analytics)||r.emitJsBridgeCall({js_bridge_method:"connect",trace_id:a});let n=yield this.injectedWallet.connect(e,t);null==(o=this.analytics)||o.emitJsBridgeResponse({js_bridge_method:"connect"}),G("Injected Provider connect response:",n),"connect"===n.event&&(yield this.updateSession(),this.makeSubscriptions({traceId:a})),this.listeners.forEach(e=>e(Object.assign(Object.assign({},n),{traceId:a})))}catch(t){null==(s=this.analytics)||s.emitJsBridgeError({js_bridge_method:"connect",error_message:String(t),trace_id:a}),G("Injected Provider connect error:",t);let e={event:"connect_error",payload:{code:0,message:null==t?void 0:t.toString()}};this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:a})))}})}makeSubscriptions(e){var t,n,i;this.listenSubscriptions=!0,null==(t=this.analytics)||t.emitJsBridgeCall({js_bridge_method:"listen",trace_id:e.traceId});try{this.unsubscribeCallback=this.injectedWallet.listen(e=>{var t;let n=null!=(t=e.traceId)?t:Z();G("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(t=>t(Object.assign(Object.assign({},e),{traceId:n}))),"disconnect"===e.event&&this.disconnect({traceId:n})}),null==(n=this.analytics)||n.emitJsBridgeResponse({js_bridge_method:"listen",trace_id:e.traceId})}catch(t){throw null==(i=this.analytics)||i.emitJsBridgeError({js_bridge_method:"listen",error_message:String(t),trace_id:e.traceId}),t}}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}ea.window=er();
1class el{constructor(e,t){this.storage=e,this.walletsListManager=t,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return a(this,void 0,void 0,function*(){if("injected"===e.type||"wallet-connect"===e.type)return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!H(e)){let 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))}let t={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair(),createdAt:Date.now()};return this.storage.setItem(this.storeKey,JSON.stringify(t))})}removeConnection(){return a(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return a(this,void 0,void 0,function*(){try{var e;let t=yield this.storage.getItem(this.storeKey);if(!t)return null;let n=JSON.parse(t);if("injected"===n.type||"wallet-connect"===n.type)return n;if("connectEvent"in n){let e=new r.o2(n.session.sessionKeyPair);return yield this.actualizeBridgeConnection({type:"http",connectEvent:n.connectEvent,lastWalletEventId:n.lastWalletEventId,nextRpcRequestId:n.nextRpcRequestId,session:{sessionCrypto:e,bridgeUrl:n.session.bridgeUrl,walletPublicKey:n.session.walletPublicKey}})}if(Date.now()-(null!=(e=n.createdAt)?e:0)>3e5)return yield this.removeConnection(),null;return{type:"http",sessionCrypto:new r.o2(n.sessionCrypto),connectionSource:n.connectionSource}}catch(e){return G("Error retrieving connection",e),null}})}getHttpConnection(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(!e)throw new l("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new l(`Trying to read HTTP connection source while ${e.type} connection is stored`);return e})}getHttpPendingConnection(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(!e)throw new l("Trying to read HTTP connection source while nothing is stored");if("http"!==e.type)throw new l(`Trying to read HTTP connection source while ${e.type} connection is stored`);if(!H(e))throw new l("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(!e)throw new l("Trying to read Injected bridge connection source while nothing is stored");if((null==e?void 0:e.type)!=="injected")throw new l(`Trying to read Injected bridge connection source while ${e.type} connection is stored`);return e})}getWalletConnectConnection(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(!e)throw new l("Trying to read wallet connect bridge connection source while nothing is stored");if((null==e?void 0:e.type)!=="wallet-connect")throw new l(`Trying to read wallet connect bridge connection source while ${e.type} connection is stored`);return e})}storedConnectionType(){return a(this,void 0,void 0,function*(){let e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return a(this,void 0,void 0,function*(){let t=yield this.getConnection();if(t&&"http"===t.type&&!H(t))return t.lastWalletEventId=e,this.storeConnection(t)})}getLastWalletEventId(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){let t=e.nextRpcRequestId||0;return e.nextRpcRequestId=t+1,this.storeConnection(e)}})}getNextRpcRequestId(){return a(this,void 0,void 0,function*(){let e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}actualizeBridgeConnection(e){return a(this,void 0,void 0,function*(){try{let t=e.connectEvent.payload.device.appName,n=yield this.walletsListManager.getRemoteWallet(t);if(n.bridgeUrl===e.session.bridgeUrl)return e;let i=Object.assign(Object.assign({},e),{session:Object.assign(Object.assign({},e.session),{bridgeUrl:n.bridgeUrl})});return yield this.storeConnection(i),i}catch(t){return G("Failed to actualize bridge connection",t),e}})}}class ec{constructor(){this.localStorage=function(){if(function(){try{return"undefined"!=typeof localStorage}catch(e){return!1}}())return localStorage;if(void 0!==o&&null!=o.versions&&null!=o.versions.node)throw new l("`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 ei.getInstance()}()}getItem(e){return a(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return a(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,t){return a(this,void 0,void 0,function*(){this.localStorage.setItem(e,t)})}}function ed(e){return eh(e)&&e.injected}function eu(e){return ed(e)&&e.embedded}function eh(e){return"jsBridgeKey"in e}function ep(e){return"bridgeUrl"in e}function eg(e){return"jsBridgeKey"in e}let em=[{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/bri
1dge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{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"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://myton
vendor: 12,419 bytes, line 1
1wallet.io",universal_url:"https://connect.mytonwallet.org",deepLink:"mytonwallet-tc://",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{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"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{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",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"binanceWeb3TonWallet",name:"Binance 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",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"fintopio-tg",name:"Fintopio",image:"https://raw.githubusercontent.com/fintopio/ton-pub/refs/heads/main/logos/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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{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://gate.onelink.me/Hls0/web3?gate_web3_wallet_universal_type=ton_connect",features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:1,extraCurrencySupported:!1}]},{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"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"bitgetWalletLite",name:"Bitget Wallet Lite",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_lite_logo_288.png",about_url:"https://web3.bitget.com",universal_url:"https://t.me/BitgetWallet_TGBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tomoWallet",name:"Tomo Wallet",image:"https://pub.tomo.inc/logo.png",about_url:"https://www.tomo.inc/",universal_url:"https://t.me/tomowalletbot?attach=wallet",bridge:[{type:"sse",url:"https://go-bridge.tomo.inc/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"miraiapp-tg",name:"Mirai Mini App",image:"https://cdn.mirailabs.co/miraihub/miraiapp-tg-icon-288.png",about_url:"https://mirai.app",universal_url:"https://t.me/MiraiAppBot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.mirai.app"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"Architec.ton",name:"Architec.ton",image:"https://raw.githubusercontent.com/Architec-Ton/wallet-tma/refs/heads/dev/public/images/arcwallet_logo.png",about_url:"https://architecton.tech",universal_url:"https://t.me/architec_ton_bot?attach=wallet",bridge:[{type:"sse",url:"https://tc.architecton.su/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"tokenpocket",name:"TokenPocket",image:"https://hk.tpstatic.net/logo/tokenpocket.png",about_url:"https://www.tokenpocket.pro",universal_url:"https://tp-lab.tptool.pro/ton-connect/",bridge:[{type:"js",key:"tokenpocket"},{type:"sse",url:"https://ton-connect.mytokenpocket.vip/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"uxuyWallet",name:"UXUY Wallet",image:"https://chain-cdn.uxuy.com/logo/square_288.png",about_url:"https://docs.uxuy.com",universal_url:"https://t.me/UXUYbot?attach=wallet",bridge:[{type:"sse",url:"https://bridge.uxuy.me/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"tonkeeper-pro",name:"Tonkeeper Pro",image:"https://tonkeeper.com/assets/tonconnect-icon-pro.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com/pro",universal_url:"https://app.tonkeeper.com/pro/ton-connect",deepLink:"tonkeeper-pro-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["ios","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!0},{name:"SignData",types:["text","binary","cell"]}]},{app_name:"nicegramWallet",name:"Nicegram Wallet",image:"https://static.nicegram.app/icon.png",about_url:"https://nicegram.app",universal_url:"https://nicegram.app/tc",deepLink:"nicegram-tc://",bridge:[{type:"sse",url:"https://tc.nicegram.app/bridge"},{type:"js",key:"nicegramWallet"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"echoooTonWallet",name:"EchoooWallet",image:"https://cdn.echooo.xyz/front-end/source/images/logo/echooo-ton.png",about_url:"https://www.echooo.xyz",universal_url:"https://www.echooo.xyz/ton-connect",deepLink:"echooo://",bridge:[{type:"js",key:"echoooTonWallet"},{type:"sse",url:"https://ton-connect-bridge.echooo.link/bridge"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"blitzwallet",name:"BLITZ wallet",image:"https://blitzwallet.cfd/wallet/public/logo.png",about_url:"https://blitzwallet.cfd",universal_url:"https://t.me/blitz_wallet_bot?attach=wallet",bridge:[{type:"sse",url:"https://blitzwallet.cfd/bridge/"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]},{app_name:"koloWeb3Wallet",name:"Kolo",image:"https://raw.githubusercontent.com/onidev1/tc-assets/refs/heads/main/kolo_logo_288.png",about_url:"https://kolo.xyz",universal_url:"https://t.me/kolo?attach=wallet",bridge:[{type:"sse",url:"https://web3-bridge.kolo.in/bridge"}],platforms:["ios","android","macos","windows","linux"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"imToken",name:"imToken",image:"https://aws-v2-cdn.token.im/orbit/token-v2/icons/logo-ton-connect.png",about_url:"https://token.im",universal_url:"https://connect.token.im/link/ton-connect",deepLink:"imtokenv2://link/ton-connect",bridge:[{type:"sse",url:"https://connect.token.im/tonbridge"},{type:"js",key:"imToken"}],platforms:["ios","android"],features:[{name:"SendTransaction",maxMessages:255,extraCurrencySupported:!1}]},{app_name:"cactuslink",name:"Cactus Link",image:"https://downloads.mycactus.com/288_cactus_link.png",about_url:"https://www.mycactus.com/defi-connector",bridge:[{type:"js",key:"cactuslink_ton"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1},{name:"SignData",types:["text","binary"]}]},{app_name:"onekey",name:"OneKey",image:"https://uni.onekey-asset.com/static/logo/onekey-x288.png",about_url:"https://onekey.so",bridge:[{type:"js",key:"onekeyTonWallet"}],platforms:["chrome"],features:[{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}]}]
1,ef=!1,ev=null;function ey(){ef=!0,console.warn("\uD83D\uDEA8 QA Mode enabled - validation is disabled. This is unsafe for production!"),eb(),"undefined"==typeof window||ev||((ev=new MutationObserver(e=>{e.forEach(e=>{"childList"===e.type&&e.removedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&("ton-connect-qa-banner"===e.id&&ef?(console.warn("QA Mode banner was removed, restoring..."),setTimeout(()=>eb(),100)):"ton-connect-qa-mode-styles"===e.id&&ef&&(console.warn("QA Mode styles were removed, restoring..."),setTimeout(()=>e_(),100)))})})})).observe(document.body,{childList:!0,subtree:!1}),ev.observe(document.head,{childList:!0,subtree:!1})),e_()}function ew(){return ef}function eb(){if("undefined"==typeof window||document.getElementById("ton-connect-qa-banner"))return;let e=document.createElement("div");e.id="ton-connect-qa-banner",e.style.cssText=`
2        position: fixed;
3        top: 0;
4        left: 0;
5        right: 0;
6        background: linear-gradient(90deg, #ff6b6b, #ff8e8e);
7        color: white;
8        padding: 12px 20px;
9        text-align: center;
10        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
11        font-weight: 600;
12        font-size: 14px;
13        z-index: 999999;
14        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
15        animation: slideDown 0.3s ease-out;
16        user-select: none;
17        pointer-events: none;
18    `,e.innerHTML=`
19        🚨 QA Mode Active - Validation Disabled (Unsafe for Production)
20    `;let t=document.createElement("style");t.textContent=`
21        @keyframes slideDown {
22            from { transform: translateY(-100%); }
23            to { transform: translateY(0); }
24        }
25    `,document.head.appendChild(t),document.body.appendChild(e),e_()}function e_(){if("undefined"==typeof window||document.getElementById("ton-connect-qa-mode-styles"))return;let e=document.createElement("style");e.id="ton-connect-qa-mode-styles",e.textContent=`
26        body.qa-mode-active {
27            padding-top: 48px !important;
28        }
29        
30        body.qa-mode-active header {
31            margin-top: 48px !important;
32        }
33        
34        body.qa-mode-active .qa-mode-control {
35            top: 128px !important;
36        }
37    `,document.head.appendChild(e),document.body.classList.add("qa-mode-active")}class eS{constructor(e){var t;this.walletsListDTOCache=null,this.walletsListDTOCacheCreationTimestamp=null,ef?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)?t:"https://config.ton.org/wallets-v2.json",this.cacheTTLMs=null==e?void 0:e.cacheTTLMs,this.onDownloadDurationMeasured=null==e?void 0:e.onDownloadDurationMeasured}getWallets(){return a(this,void 0,void 0,function*(){let[e,t]=yield Promise.all([this.fetchWalletsListDTO(),this.getCurrentlyInjectedWallets()]);return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),t)})}getEmbeddedWallet(){return a(this,void 0,void 0,function*(){let e=(yield this.getWallets()).filter(eu);return 1===e.length?e[0]:null})}fetchWalletsListDTO(){return a(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})}getRemoteWallet(e){return a(this,void 0,void 0,function*(){let t=(yield this.getWallets()).find(t=>t.appName===e);if(!t)throw new l(`Wallet info not found for appName: "${e}"`);
37if(!ep(t))throw new l(`Wallet "${e}" is not remote`);return t})}fetchWalletsListFromSource(){return a(this,void 0,void 0,function*(){var e,t;let n=[],i=performance.now();try{let t=yield fetch(this.walletsListSource);if(n=yield t.json(),!Array.isArray(n))throw new S("Wrong wallets list format, wallets list must be an array.");let r=n.filter(e=>!this.isCorrectWalletConfigDTO(e));r.length&&(z(`Wallet(s) ${r.map(e=>(null==e?void 0:e.name)||"unknown").join(", ")} config format is wrong. They were removed from the wallets list.`),n=n.filter(e=>this.isCorrectWalletConfigDTO(e)));let o=performance.now(),s=Math.round(o-i);null==(e=this.onDownloadDurationMeasured)||e.call(this,s)}catch(e){z(e),n=em,null==(t=this.onDownloadDurationMeasured)||t.call(this,void 0)}return n})}getCurrentlyInjectedWallets(){if(!ef)return[];try{return ea.getCurrentlyInjectedWallets()}catch(e){return z(e),[]}}walletConfigDTOListToWalletConfigList(e){return e.map(e=>{let 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){let e=n.key;t.jsBridgeKey=e,t.injected=ea.isWalletInjected(e),t.embedded=ea.isInsideWalletBrowser(e)}}),t})}mergeWalletsLists(e,t){return[...new Set(e.concat(t).map(e=>e.name)).values()].map(n=>{let i=e.find(e=>e.name===n),r=t.find(e=>e.name===n);return Object.assign(Object.assign({},i&&Object.assign({},i)),r&&Object.assign({},r))})}isCorrectWalletConfigDTO(e){if(!e||"object"!=typeof e)return!1;let t="name"in e,n="app_name"in e,i="image"in e,r="about_url"in e,o="platforms"in e;if(!t||!i||!r||!o||!n||!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length||!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;let s=e.bridge;if(s.some(e=>!e||"object"!=typeof e||!("type"in e)))return!1;let a=s.find(e=>"sse"===e.type);if(a&&(!("object"==typeof a&&"url"in a)||!a.url||!e.universal_url))return!1;let l=s.find(e=>"js"===e.type);return!l||"object"==typeof l&&"key"in l&&!!l.key}}function eC(e,t){if("object"!=typeof t)return!0;let{sendTransaction:n,signData:i}=t;if(n){let t=eI(e,"SendTransaction");if(!t||!function(e,t){let n=void 0===t.minMessages||t.minMessages<=e.maxMessages,i=!t.extraCurrencyRequired||e.extraCurrencySupported;return!!(n&&i)}(t,n))return!1}if(i){var r;let t=eI(e,"SignData");if(!t||(r=t,!i.types.every(e=>r.types.includes(e))))return!1}return!0}function eI(e,t){return e.find(e=>e&&"object"==typeof e&&e.name===t)}function eT(){return{type:"request-version"}}function eE(e){return{type:"response-version",version:e}}function eR(e){return{ton_connect_sdk_lib:e.ton_connect_sdk_lib,ton_connect_ui_lib:e.ton_connect_ui_lib}}function ek(e,t,n){var i,r,o,s,a,l,c,d,u,h,p;let g=(null==(i=null==t?void 0:t.connectItems)?void 0:i.tonProof)&&"proof"in t.connectItems.tonProof;return{wallet_address:null!=(o=null==(r=null==t?void 0:t.account)?void 0:r.address)?o:null,wallet_state_init:null!=(s=null==t?void 0:t.account.walletStateInit)?s:null,wallet_type:null!=(a=null==t?void 0:t.device.appName)?a:null,wallet_version:null!=(l=null==t?void 0:t.device.appVersion)?l:null,auth_type:g?"ton_proof":"ton_addr",custom_data:Object.assign({client_id:null!=(c=null==n?void 0:n.clientId)?c:null,wallet_id:null!=(d=null==n?void 0:n.walletId)?d:null,chain_id:null!=(h=null==(u=null==t?void 0:t.account)?void 0:u.chain)?h:null,provider:null!=(p=null==t?void 0:t.provider)?p:null},eR(e))}}function eO(e,t){return{type:"connection-started",custom_data:eR(e),trace_id:null!=t?t:null}}function ex(e,t,n,i){return Object.assign({type:"connection-completed",is_success:!0,trace_id:null!=i?i:null},ek(e,t,n))}function ej(e,t,n,i,r){var o,s;return{type:"connection-error",is_success:!1,error_message:t,error_code:null!=n?n:null,trace_id:null!=r?r:null,custom_data:Object.assign({client_id:null!=(o=null==i?void 0:i.clientId)?o:null,wallet_id:null!=(s=null==i?void 0:i.walletId)?s:null},eR(e))}}function eW(e,t){return{type:"connection-restoring-started",custom_data:eR(e),trace_id:null!=t?t:null}}function eq(e,t,n,i){return Object.assign({type:"connection-restoring-completed",is_success:!0,trace_id:null!=i?i:null},ek(e,t,n))}function eP(e,t,n){return{type:"connection-restoring-error",is_success:!1,error_message:t,trace_id:null!=n?n:null,custom_data:eR(e)}}function eL(e,t){var n,i,r,o;return{valid_until:null!=(n=String(t.validUntil))?n:null,from:null!=(o=null!=(i=t.from)?i:null==(r=null==e?void 0:e.account)?void 0:r.address)?o:null,messages:t.messages.map(e=>{var t,n;return{address:null!=(t=e.address)?t:null,amount:null!=(n=e.amount)?n:null}})}}function eM(e,t,n,i,r){return Object.assign(Object.assign({type:"transaction-sent-for-signature",trace_id:null!=r?r:null},ek(e,t,i)),eL(t,n))}function eA(e,t,n,i,r,o){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:i.boc,trace_id:null!=o?o:null},ek(e,t,r)),eL(t,n))}function eD(e,t,n,i,r,o,s){var a,l,c,d;return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:i,error_code:null!=r?r:null,trace_id:null!=s?s:null},ek(e,t,o)),{valid_until:null!=(a=String(n.validUntil))?a:null,from:null!=(d=null!=(l=n.from)?l:null==(c=null==t?void 0:t.account)?void 0:c.address)?d:null,messages:n.messages.map(e=>{var t,n,i,r;return{address:null!=(t=e.address)?t:null,amount:null!=(n=e.amount)?n:null,payload:null!=(i=e.payload)?i:null,
37state_init:null!=(r=e.stateInit)?r:null}})})}function eU(e,t,n,i,r){return Object.assign({type:"sign-data-request-initiated",data:n,trace_id:null!=r?r:null},ek(e,t,i))}function eN(e,t,n,i,r,o){return Object.assign({type:"sign-data-request-completed",is_success:!0,data:n,signed_data:i,trace_id:null!=o?o:null},ek(e,t,r))}function eB(e,t,n,i,r,o,s){return Object.assign({type:"sign-data-request-failed",is_success:!1,data:n,error_message:i,error_code:null!=r?r:null,trace_id:null!=s?s:null},ek(e,t,o))}function e$(e,t,n,i,r){return Object.assign({type:"disconnection",scope:n,trace_id:null!=r?r:null},ek(e,t,i))}function eK(e,t,n,i){return{type:"wallet-modal-opened",visible_wallets:t,client_id:null!=n?n:null,custom_data:e,trace_id:null!=i?i:null}}function eF(e,t,n,i,r,o,s,a){var l;let c=o;return!c&&r&&(c=D(r)?"tg_link":"external_link"),{type:"selected-wallet",wallets_menu:i,visible_wallets:t,client_id:null!=s?s:null,custom_data:e,trace_id:null!=a?a:null,wallet_redirect_method:c,wallet_redirect_link:r||void 0,wallet_type:null!=(l=null==n?void 0:n.appName)?l:null}}class eG{get version(){return eR({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}constructor(e){this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=null==e?void 0:e.eventDispatcher,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}init(){return a(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch(e){}})}setRequestVersionHandler(){return a(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>a(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",eE(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return a(this,void 0,void 0,function*(){return new Promise((e,t)=>a(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",eT())}catch(e){t(e)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(e){}}trackConnectionStarted(...e){try{let t=eO(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionCompleted(...e){try{let t=ex(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionError(...e){try{let t=ej(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringStarted(...e){try{let t=eW(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringCompleted(...e){try{let t=eq(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackConnectionRestoringError(...e){try{let t=eP(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDisconnection(...e){try{let t=e$(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSentForSignature(...e){try{let t=eM(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigned(...e){try{let t=eA(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackTransactionSigningFailed(...e){try{let t=eD(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSentForSignature(...e){try{let t=eU(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigned(...e){try{let t=eN(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}trackDataSigningFailed(...e){try{let t=eB(this.version,...e);this.dispatchUserActionEvent(t)}catch(e){}}}let ez="3.4.1";function eJ(e,t=!1){let{wc:n,hex:i}=eQ(e),o=81;t&&(o|=128);let s=new Int8Array(34);s[0]=o,s[1]=n,s.set(i,2);let a=new Uint8Array(36);return a.set(s),a.set(eX(s),34),r.o4.encode(a).replace(/\+/g,"-").replace(/\//g,"_")}function eH(e){try{return eV(e),!0}catch(e){return!1}}function eV(e){let t,n=e.replace(/-/g,"+").replace(/_/g,"/");try{t=r.o4.decode(n).toUint8Array()}catch(t){throw new C(`Invalid base64 encoding in address: ${e}`)}if(36!==t.length)throw new C(`Invalid address length: ${e}`);let i=t.slice(0,34),o=t.slice(34,36),s=eX(i);if(!o.every((e,t)=>e===s[t]))throw new C(`Invalid checksum in address: ${e}`);
37let a=i[0],l=!1,c=!1;if(128&a&&(l=!0,a^=128),17!==a&&81!==a)throw new C(`Unknown address tag: ${a}`);c=17===a;let d=null;d=255===i[1]?-1:i[1];let u=i.slice(2);if(0!==d&&-1!==d)throw new C(`Invalid workchain: ${d}`);return{wc:d,hex:Array.from(u).map(e=>e.toString(16).padStart(2,"0")).join(""),testOnly:l,isBounceable:c}}function eQ(e){if(!e.includes(":"))throw new C(`Wrong address ${e}. Address must include ":".`);let t=e.split(":");if(2!==t.length)throw new C(`Wrong address ${e}. Address must include ":" only once.`);let n=parseInt(t[0]);if(0!==n&&-1!==n)throw new C(`Wrong address ${e}. WC must be eq 0 or -1, but ${n} received.`);let i=t[1];if((null==i?void 0:i.length)!==64)throw new C(`Wrong address ${e}. Hex part must be 64bytes length, but ${null==i?void 0:i.length} received.`);return{wc:n,hex:function(e){let t=(e=e.toLowerCase()).length;if(t%2!=0)throw new I("Hex string must have length a multiple of 2: "+e);let n=t/2,i=new Uint8Array(n);for(let t=0;t<n;t++){let n=2*t,r=e.substring(n,n+2);if(!eY.hasOwnProperty(r))throw new I("Invalid hex character: "+r);i[t]=eY[r]}return i}(i)}}function eX(e){let t=0,n=new Uint8Array(e.length+2);for(let i of(n.set(e),n)){let e=128;for(;e>0;)t<<=1,i&e&&(t+=1),e>>=1,t>65535&&(t&=65535,t^=4129)}return new Uint8Array([Math.floor(t/256),t%256])}let eY={};for(let e=0;e<=255;e++){let t=e.toString(16);t.length<2&&(t="0"+t),eY[t]=e}let eZ=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,e0=/^[A-Za-z0-9\-_]+$/,e1=/^-?\d+$/,e2=/^\d+$/;function e5(e){return"number"==typeof e&&!isNaN(e)}function e3(e){return"string"==typeof e&&e.length>0}function e4(e){return e3(e)&&(function(e){try{return eQ(e),!0}catch(e){return!1}}(e)||eH(e))}function e8(e){return e3(e)&&/^-?\d+$/.test(e)}function e6(e){return"string"==typeof e&&(eZ.test(e)||e0.test(e))&&e.startsWith("te6cc")}function e9(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function e7(e,t){return Object.keys(e).some(e=>!t.includes(e))}function te(e){if("string"!=typeof e)return;let t=e.length+(4-e.length%4)%4;return e.replace(/-/g,"+").replace(/_/g,"/").padEnd(t,"=")}class tt{constructor(e={}){var t,n,i,r,o,s;this.events=[],this.timeoutId=null,this.isProcessing=!1,this.backoff=1,this.shouldSend=!0,this.batchTimeoutMs=null!=(t=e.batchTimeoutMs)?t:2e3,this.currentBatchTimeoutMs=this.batchTimeoutMs,this.maxBatchSize=null!=(n=e.maxBatchSize)?n:100,this.analyticsUrl=null!=(i=e.analyticsUrl)?i:"https://analytics.ton.org/events",this.mode=null!=(r=e.mode)?r:"telemetry",this.baseEvent=Object.assign({subsystem:"dapp-sdk",version:ez,client_environment:null==(s=null==(o=e.environment)?void 0:o.getClientEnvironment)?void 0:s.call(o)},function(){let e={};try{let t=performance.getEntriesByType("navigation");if(t.length>0){let n=t[0];n.responseStart&&n.requestStart&&(e.conn_ttfb=Math.round(n.responseStart-n.requestStart))}}catch(e){}return e}()),this.addWindowFocusAndBlurSubscriptions()}scoped(e){return new Proxy(this,{get(t,n){let i=n.toString();if(i.startsWith("emit")){let n=i.replace("emit","").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return function(i){let r=Object.fromEntries(Object.entries(null!=e?e:{}).map(([e,t])=>[e,"function"==typeof t?t():t]));return t.emit(Object.assign(Object.assign({event_name:n},r),i))}}return t[n]}})}emit(e){var t;if("off"===this.mode)return;let n=null!=(t=e.trace_id)?t:Z(),i=function(){let e={};try{let t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;n&&(void 0!==n.rtt&&(e.conn_rtt=n.rtt),n.effectiveType?e.conn_network_type=n.effectiveType:n.type&&(e.conn_network_type=n.type))}catch(e){}return e}(),r=Object.assign(Object.assign(Object.assign(Object.assign({},this.baseEvent),i),e),{event_id:Z(),client_timestamp:Math.floor(Date.now()/1e3),trace_id:n}),o="telemetry"===this.mode?this.filterFullModeFields(r):r;if(ef&&G(o),this.events.push(o),this.events.length>=this.maxBatchSize)return void this.flush();this.startTimeout()}startTimeout(){this.timeoutId||this.isProcessing||(this.timeoutId=setTimeout(()=>{this.flush()},this.currentBatchTimeoutMs))}flush(){return a(this,void 0,void 0,function*(){if(this.isProcessing||0===this.events.length||!this.shouldSe
37nd)return;this.clearTimeout(),this.isProcessing=!0;let e=this.extractEventsToSend();try{yield this.processEventsBatch(e),G("Analytics events sent successfully")}catch(t){this.restoreEvents(e),z("Failed to send analytics events:",t)}finally{this.isProcessing=!1,this.scheduleNextFlushIfNeeded()}})}clearTimeout(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}extractEventsToSend(){let e=this.events.slice(0,this.maxBatchSize);return this.events=this.events.slice(this.maxBatchSize),e}processEventsBatch(e){return a(this,void 0,void 0,function*(){G("Sending analytics events...",e.length);try{let t=yield this.sendEvents(e);this.handleResponse(t)}catch(e){this.handleUnknownError(e)}})}handleResponse(e){let{status:t,statusText:n}=e;this.isTooManyRequests(t)?this.handleTooManyRequests(t,n):this.isClientError(t)?this.handleClientError(t,n):this.isServerError(t)&&this.handleUnknownError({status:t,statusText:n})}restoreEvents(e){this.events.unshift(...e)}scheduleNextFlushIfNeeded(){this.events.length>0&&this.startTimeout()}sendEvents(e){return a(this,void 0,void 0,function*(){return yield fetch(this.analyticsUrl,{method:"POST",headers:{"Content-Type":"application/json","X-Client-Timestamp":Math.floor(Date.now()/1e3).toString()},body:JSON.stringify(e)})})}isClientError(e){return e>=tt.HTTP_STATUS.CLIENT_ERROR_START&&e<tt.HTTP_STATUS.SERVER_ERROR_START}isServerError(e){return e>=tt.HTTP_STATUS.SERVER_ERROR_START}isTooManyRequests(e){return e===tt.HTTP_STATUS.TOO_MANY_REQUESTS}handleClientError(e,t){z("Failed to send analytics events:",new l(`Analytics API error: ${e} ${t}`))}handleUnknownError(e){if(this.backoff<tt.MAX_BACKOFF_ATTEMPTS)throw this.backoff++,this.currentBatchTimeoutMs*=tt.BACKOFF_MULTIPLIER,new l(`Unknown analytics API error: ${e}`);this.currentBatchTimeoutMs=this.batchTimeoutMs,this.backoff=1}handleTooManyRequests(e,t){throw new l(`Analytics API error: ${e} ${t}`)}addWindowFocusAndBlurSubscriptions(){let e=eo();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?(this.clearTimeout(),this.shouldSend=!1):(this.shouldSend=!0,this.scheduleNextFlushIfNeeded())})}catch(e){z("Cannot subscribe to the document.visibilitychange: ",e)}}getMode(){return this.mode}getPendingEventsCount(){return this.events.length}filterFullModeFields(e){let t=Object.assign({},e);for(let e of tt.FULL_MODE_FIELDS)delete t[e];let n="event_name"in e?String(e.event_name):"";return!("error_code"in e||"error_message"in e||n.includes("error")||"connection-error"===n||"transaction-signing-failed"===n||"sign-data-request-failed"===n)&&"wallet_address"in t&&delete t.wallet_address,t}setWalletListDownloadDuration(e){this.baseEvent=Object.assign(Object.assign({},this.baseEvent),{wallet_list_download_duration:e})}}tt.HTTP_STATUS={TOO_MANY_REQUESTS:429,CLIENT_ERROR_START:400,SERVER_ERROR_START:500},tt.MAX_BACKOFF_ATTEMPTS=5,tt.BACKOFF_MULTIPLIER=2,tt.FULL_MODE_FIELDS=["user_id","tg_id","locale","tma_is_premium"];class tn{constructor(){this.window=er()}dispatchEvent(e,t){return a(this,void 0,void 0,function*(){var n;let i=new CustomEvent(e,{detail:t});null==(n=this.window)||n.dispatchEvent(i)})}addEventListener(e,t,n){return a(this,void 0,void 0,function*(){var i;return null==(i=this.window)||i.addEventListener(e,t,n),()=>{var n;return null==(n=this.window)?void 0:n.removeEventListener(e,t)}})}}function ti(e){return{"@tonconnect/sdk":e.ton_connect_sdk_lib||"","@tonconnect/ui":e.ton_connect_ui_lib||""}}function tr(e){var t,n,i,r,o,s,a,l;return{versions:ti(e.custom_data),network_id:null!=(t=e.custom_data.chain_id)?t:"",client_id:null!=(n=e.custom_data.client_id)?n:"",wallet_id:null!=(i=e.custom_data.wallet_id)?i:"",wallet_address:null!=(r=e.wallet_address)?r:"",wallet_app_name:null!=(o=e.wallet_type)?o:"",wallet_app_version:null!=(s=e.wallet_version)?s:"",wallet_state_init:null!=(a=e.wallet_state_init)?a:"",trace_id:null!=(l=e.trace_id)?l:void 0}}class to{getClientEnvironment(){return""}getBrowser(){return""}getLocale(){return""}getPlatform(){return""}getTelegramUser(){}}let ts={};function ta(e,t){if((null==ts?void 0:ts.walletConnectOptions)!==void 0||(null==ts?void 0:ts.UniversalConnectorCls)!==void 0)throw new l("Wallet Connect already initialized.");
37if("function"!=typeof e||!("init"in e))throw new l("Initialize UniversalConnectorCls must be set");ts.UniversalConnectorCls=e,ts.walletConnectOptions=t}function tl(){return void 0!==ts.UniversalConnectorCls&&void 0!==ts.walletConnectOptions}class tc{constructor(e){this.connectionStorage=e,this.type="injected",this.listeners=[],this.connector=void 0;let{projectId:t,metadata:n}=function(){if(void 0===ts.walletConnectOptions)throw new l("Wallet Connect is not initialized.");return ts.walletConnectOptions}();this.config={networks:[{namespace:"ton",chains:[{id:-239,chainNamespace:"ton",caipNetworkId:"ton:-239",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}},{id:-3,chainNamespace:"ton",caipNetworkId:"ton:-3",name:"TON",nativeCurrency:{name:"TON",symbol:"TON",decimals:9},rpcUrls:{default:{http:[]}}}],methods:["ton_sendMessage","ton_signData"],events:[]}],projectId:t,metadata:n}}static fromStorage(e){return a(this,void 0,void 0,function*(){return new tc(e)})}initialize(){return a(this,void 0,void 0,function*(){return this.connector||(this.connector=yield(function(){if(void 0===ts.UniversalConnectorCls)throw new l("Wallet Connect is not initialized.");return ts.UniversalConnectorCls})().init(this.config)),this.connector})}connect(e,t){var n,i;let r=null!=(n=null==t?void 0:t.traceId)?n:Z(),o=K(null==t?void 0:t.signal);null==(i=this.abortController)||i.abort(),this.abortController=o,this._connect(e,{traceId:r,signal:o.signal,abortController:o}).catch(e=>G("WalletConnect connect unexpected error",e))}_connect(e,t){return a(this,void 0,void 0,function*(){var n,i;let o=yield this.initialize();if(null==(n=t.signal)?void 0:n.aborted){G("WalletConnect connect aborted before start"),this.clearAbortController(t.abortController);return}let s=e.items.find(e=>"ton_proof"===e.name),a=s?[{domain:new URL(this.config.metadata.url).hostname,chains:["ton:-239"],nonce:"",uri:"ton_proof",ttl:0,statement:s.payload}]:void 0;G("Connecting through this.connector.connect");try{yield o.connect({authentication:a})}catch(n){if(null==(i=t.signal)?void 0:i.aborted){G("WalletConnect connect aborted via signal"),this.clearAbortController(t.abortController);return}G("WalletConnect connect error",n);let e={id:0,event:"connect_error",traceId:t.traceId,payload:{code:r.IS.USER_REJECTS_ERROR,message:"User declined the connection"}};G("WalletConnect connect response:",e),this.emit(e),this.clearAbortController(t.abortController);return}G("Connected through this.connector.connect");try{yield this.onConnect(o,Object.assign(Object.assign({},t),{includeTonProof:!0}))}catch(e){G("WalletConnect onConnect error",e),yield this.disconnect({traceId:t.traceId,signal:t.signal})}finally{this.clearAbortController(t.abortController)}})}restoreConnection(e){return a(this,void 0,void 0,function*(){var t,n;let i=null!=(t=null==e?void 0:e.traceId)?t:Z(),r=K(null==e?void 0:e.signal);if(null==(n=this.abortController)||n.abort(),this.abortController=r,!r.signal.aborted)try{if(G("Restoring WalletConnect connection..."),!(yield this.connectionStorage.getWalletConnectConnection())||r.signal.aborted)return;let e=yield this.initialize();if(r.signal.aborted)return;yield this.onConnect(e,{includeTonProof:!1,traceId:i,signal:r.signal}),G("WalletConnect successfully restored.")}catch(e){G("WalletConnect restore error",e),yield this.disconnect({traceId:i,signal:r.signal})}finally{this.clearAbortController(r)}})}closeConnection(){var e;null==(e=this.abortController)||e.abort(),this.abortController=void 0,this.disconnect()}disconnect(e){return a(this,void 0,void 0,function*(){var t,n;let i=K(null==e?void 0:e.signal);if(null==(t=this.abortController)||t.abort(),this.abortController=i,!i.signal.aborted)try{if(yield this.connectionStorage.removeConnection(),i.signal.aborted)return;yield null==(n=this.connector)?void 0:n.disconnect()}catch(e){G("WalletConnect disconnect error",e)}finally{this.clearAbortController(i)}})}sendRequest(e,t){return a(this,void 0,void 0,function*(){var n,i,o;if(!this.connector)throw new l("Wallet Connect not initialized");let a={};"function"==typeof t?a.onRequestSent=t:(a.onRequestSent=null==t?void 0:t.onRequestSent,a.signal=null==t?void 0:t.signal,a.attempts=null==t?void 0:t.attempts,a.traceId=null==t?void 0:t.traceId),null!=a.traceId||(a.traceId=Z());try{if(null==(n=a.signal)?void 0:n.aborted)throw new l("WalletConnect request aborted");if(G("Send wallet-connect request:",Object.assign(Object.assign({},e),{id:"0"})),"sendTransaction"===e.method){let t=JSON.parse(e.params[0]),{network:n}=t,r=s(t,["network"]),o=this.connector.request({method:"ton_sendMessage",params:r},`ton:${n}`);null==(i=null==a?void 0:a.onRequestSent)||i.call(a);let l=yield o;return G("Wallet message received:",{result:l,id:"0"}),{result:l,id:"0",traceId:a.traceId}}if("signData"===e.method){let t=JSON.parse(e.params[0]),{network:n}=t,i=s(t,["network"]),r=this.connector.request({method:"ton_signData",params:i},`ton:${n}`);null==(o=null==a?void 0:a.onRequestSent)||o.call(a);let l=yield r;return G("Wallet message received:",{result:l,id:"0"}),{result:l,traceId:a.traceId,id:"0"}}if("disconnect"===e.method)return{id:"0",traceId:a.traceId}}catch(t){G("WalletConnect request error",t,t.stack);let e=yield this.handleWalletConnectError(t,{traceId:a.traceId});return G("Wallet message received:",e),e}return{id:"0",error:{code:r.Rx.UNKNOWN_ERROR,message:"Not implemented."},traceId:a.traceId}})}handleWalletConnectError(e,t){return a(this,void 0,void 0,function*(){if("object"==typeof e&&null!==e){let n=String("message"in e?e.message:"msg"in e?e.msg:e);return n.toLowerCase().includes("reject")?{id:"0",traceId:t.traceId,error:{code:r.K4.USER_REJECTS_ERROR,message:n}}:n.toLowerCase().includes("tonvalidationerror")?{id:"0",traceId:t.traceId,error:{code:r.K4.BAD_REQUEST_ERROR,message:n}}:{id:"0",traceId:t.traceId,error:{code:r.K4.UNKNOWN_ERROR,message:n}}}return{id:"0",traceId:t.traceId,error:{code:r.K4.UNKNOWN_ERROR,message:String(e)}}})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(t=>t!==e)}buildTonProof(e){var t,n,i;let r=null==(t=e.provider.session.authentication)?void 0:t[0],o=null==(n=null==r?void 0:r.p)?void 0:n.iat,s=null==(i=null==r?void 0:r.p)?void 0:i.statement;if(!o||!s)return;let a=r.p.domain;return{name:"ton_proof",proof:{timestamp:Math.floor(new Date(o).getTime()/1e3),domain:{lengthBytes:a.length,value:a},payload:s,signature:r.s.s}}}onConnect(e,t){return a(this,void 0,void 0,function*(){var n,i,o,s;if(null==(n=t.signal)?void 0:n.aborted)return void G("WalletConnect onConnect aborted");let l=e.provider.session,c=l.namespaces.ton;if(!(null==(i=null==c?void 0:c.accounts)?void 0:i[0]))return void(yield this.disconnectWithError({traceId:t.traceId,code:r.IS.BAD_REQUEST_ERROR,message:"Connection error. No TON accounts connected."}));let[,d,u]=c.accounts[0].split(":",3),h=null==(o=l.sessionProperties)?void 0:o.ton_getPublicKey;if(!h)return void(yield this.disconnectWithError({traceId:t.traceId,code:r.IS.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getPublicKey provided."}));let p=null==(s=l.sessionProperties)?void 0:s.ton_getStateInit;if(!p)return void(yield this.disconnectWithError({traceId:t.traceId,code:r.IS.BAD_REQUEST_ERROR,message:"Connection error. No sessionProperties.ton_getStateInit provided."}));e.provider.once("session_delete",()=>
37a(this,void 0,void 0,function*(){try{yield this.connectionStorage.removeConnection();let e={event:"disconnect",traceId:Z(),payload:{}};G("Wallet message received:",e),this.emit(e)}catch(e){G("Error while deleting session",e)}}));let g=(null==t?void 0:t.includeTonProof)?this.buildTonProof(e):void 0,m={items:[{name:"ton_addr",address:eH(u)?function({wc:e,hex:t}){return`${e}:${t}`}(eV(u)):u,network:d,publicKey:h,walletStateInit:p},...g?[g]:[]],device:{appName:"wallet_connect",appVersion:"",maxProtocolVersion:2,features:this.buildFeatureList(c.methods),platform:"browser"}};G("WalletConnect connect response:",{event:"connect",payload:m,id:0}),this.emit({event:"connect",payload:m,traceId:t.traceId}),yield this.storeConnection()})}buildFeatureList(e){let t=[];return e.includes("ton_sendMessage")&&t.push("SendTransaction",{name:"SendTransaction",maxMessages:4,extraCurrencySupported:!1}),e.includes("ton_signData")&&t.push({name:"SignData",types:["text","binary","cell"]}),t}disconnectWithError(e){return a(this,void 0,void 0,function*(){yield this.disconnect();let t={code:e.code,message:e.message};G("WalletConnect connect response:",{event:"connect_error",id:0,payload:t}),this.emit({event:"connect_error",traceId:e.traceId,payload:t})})}clearAbortController(e){this.abortController===e&&(this.abortController=void 0)}emit(e,t){(null!=t?t:this.listeners).forEach(t=>t(e))}storeConnection(){return this.connectionStorage.storeConnection({type:"wallet-connect"})}}class td{static getWallets(){return this.walletsList.getWallets()}get connected(){return null!==this._wallet}get account(){var e;return(null==(e=this._wallet)?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){var t,n,i;this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[];let r=(null==e?void 0:e.manifestUrl)||function(){var e;let t=null==(e=er())?void 0:e.location.origin;return t?t+"/tonconnect-manifest.json":""}();this.dappSettings={manifestUrl:r,storage:(null==e?void 0:e.storage)||new ec},this.walletsRequiredFeatures=null==e?void 0:e.walletsRequiredFeatures,this.environment=null!=(t=null==e?void 0:e.environment)?t:new to,this.walletsList=new eS({walletsListSource:null==e?void 0:e.walletsListSource,cacheTTLMs:null==e?void 0:e.walletsListCacheTTLMs,onDownloadDurationMeasured:e=>{var t;null==(t=this.analytics)||t.setWalletListDownloadDuration(e)}});let o=null!=(n=null==e?void 0:e.eventDispatcher)?n:new tn;if(this.tracker=new eG({eventDispatcher:o,tonConnectSdkVersion:ez}),this.environment=null!=(i=null==e?void 0:e.environment)?i:new to,this.initAnalytics(r,o,e),!this.dappSettings.manifestUrl)throw new c("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 el(this.dappSettings.storage,this.walletsList),(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,n){var i,r,o;let s=Object.assign({},n);if("object"==typeof t&&null!==t&&"tonProof"in t&&(s.request=t),"object"==typeof t&&null!==t&&("openingDeadlineMS"in t||"signal"in t||"request"in t||"traceId"in t)&&(s.request=null==t?void 0:t.request,s.openingDeadlineMS=null==t?void 0:t.openingDeadlineMS,s.signal=null==t?void 0:t.signal),s.request){let e=function(e){if(!e9(e))return"Request must be an object";if(e7(e,["tonProof"]))return"Request contains extra properties";if(void 0!==e.tonProof){if("string"!=typeof e.tonProof)return"Invalid 'tonProof'";let t=e.tonProof;if(0===t.length)return"Empty 'tonProof' payload";let n=function(){try{if("undefined"!=typeof window&&window.location)return window.location.hostname;return null}catch(e){return null}}();if(!n)return null;let i=new TextEncoder().encode(n).length;if(i>128)return"Current domain exceeds 128 bytes limit";let r=new TextEncoder().encode(t).length;if(r>128)return"'tonProof' payload exceeds 128 bytes limit";if(i+r>222)return"'tonProof' domain + payload exceeds 222 bytes limit"}return null}(s.request);if(e)if(ef)console.error("ConnectAdditionalRequest validation failed: "+e);else throw new l("ConnectAdditionalRequest validation failed: "+e)}if(this.connected)throw new h;let a=K(null==s?void 0:s.signal);if(null==(i=this.abortController)||i.abort(),this.abortController=a,a.signal.aborted)throw new l("Connection was aborted");null==(r=this.provider)||r.closeConnection(),this.provider=this.createProvider(e),a.signal.addEventListener("abort",()=>{var e;null==(e=this.provider)||e.closeConnection(),this.provider=null});let c=null!=(o=null==s?void 0:s.traceId)?o:Z();return this.tracker.trackConnectionStarted(c),this.provider.connect(this.createConnectRequest(null==s?void 0:s.request),{openingDeadlineMS:null==s?void 0:s.openingDeadlineMS,signal:a.signal,traceId:c})}restoreConnection(e){return a(this,void 0,void 0,function*(){var t,n,i;let r=null!=(t=null==e?void 0:e.traceId)?t:Z();this.tracker.trackConnectionRestoringStarted(r);let o=K(null==e?void 0:e.signal);if(null==(n=this.abortController)||n.abort(),this.abortController=o,o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",r);let[s,l]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(o.signal.aborted)return void this.tracker.trackConnectionRestoringError("Connection restoring was aborted",r);let c=null;try{switch(s){case"http":c=yield et.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"injected":c=yield ea.fromStorage(this.bridgeConnectionStorage,this.analytics);break;case"wallet-connect":c=yield tc.fromStorage(this.bridgeConnectionStorage);break;default:if(!l)return;c=this.createProvider(l)}}catch(e){G("Provider is not restored",e),this.tracker.trackConnectionRestoringError("Provider is not restored",r),yield this.bridgeConnectionStorage.removeConnection(),null==c||c.closeConnection(),c=null;return}if(o.signal.aborted){null==c||c.closeConnection(),this.tracker.trackConnectionRestoringError("Connection restoring was aborted",r);return}if(!c){z("Provider is not restored"),this.tracker.trackConnectionRestoringError("Provider is not restored",r);return}null==(i=this.provider)||i.closeConnection(),this.provider=c,c.listen(this.walletEventsListener.bind(this));let d=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted",r),null==c||c.closeConnection(),c=null};return o.signal.addEventListener("abort",d),Promise.race([F(t=>a(this,void 0,void 0,function*(){if(yield null==c?void 0:c.restoreConnection({openingDeadlineMS:null==e?void 0:e.openingDeadlineMS,signal:t.signal,traceId:r}),o.signal.removeEventListener("abort",d),this.connected){let e=this.getSessionInfo();this.tracker.trackConnectionRestoringCompleted(this.wallet,e,r)}else this.tracker.trackConnectionRestoringError("Connection restoring failed",r)}
37),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:null==e?void 0:e.signal}),new Promise(e=>setTimeout(()=>e(),12e3))])})}sendTransaction(e,t){return a(this,void 0,void 0,function*(){var n,i,r,o;let a={};"function"==typeof t?a.onRequestSent=t:(a.onRequestSent=null==t?void 0:t.onRequestSent,a.signal=null==t?void 0:t.signal,a.traceId=null==t?void 0:t.traceId);let c=function(e){if(!e9(e))return"Request must be an object";if(e7(e,["validUntil","network","from","messages"]))return"Request contains extra properties";if(e.validUntil){if(!e5(e.validUntil))return"Incorrect 'validUntil'";let t=Math.floor(Date.now()/1e3);e.validUntil>t+300&&console.warn(`validUntil (${e.validUntil}) is more than 5 minutes from now (${t})`)}if(void 0!==e.network&&!e8(e.network))return"Invalid 'network' format";if(void 0!==e.from&&!e4(e.from))return"Invalid 'from' address format";if(!Array.isArray(e.messages)||0===e.messages.length)return"'messages' is required";for(let t=0;t<e.messages.length;t++){let n=function(e,t){if(!e9(e))return`Message at index ${t} must be an object`;if(e7(e,["address","amount","stateInit","payload","extraCurrency"]))return`Message at index ${t} contains extra properties`;if(!e3(e.address))return`'address' is required in message at index ${t}`;if(!eH(e.address))return`Wrong 'address' format in message at index ${t}`;if(!e3(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&&(!e3(e.stateInit)||!e6(e.stateInit)))return`Invalid 'stateInit' in message at index ${t}`;if(void 0!==e.payload&&(!e3(e.payload)||!e6(e.payload)))return`Invalid 'payload' in message at index ${t}`;if(void 0!==e.extraCurrency){if(!e9(e.extraCurrency))return`Invalid 'extraCurrency' in message at index ${t}`;for(let[n,i]of Object.entries(e.extraCurrency))if(!e1.test(n)||"string"!=typeof i||!e2.test(i))return`Invalid 'extraCurrency' format in message at index ${t}`}return null}(e.messages[t],t);if(n)return n}return null}(e);if(c)if(ef)console.error("SendTransactionRequest validation failed: "+c);else throw new l("SendTransactionRequest validation failed: "+c);let d=K(null==a?void 0:a.signal);if(d.signal.aborted)throw new l("Transaction sending was aborted");this.checkConnection();let u=e.messages.length,h=e.messages.some(e=>e.extraCurrency&&Object.keys(e.extraCurrency).length>0);!function(e,t){let n=e.includes("SendTransaction"),i=eI(e,"SendTransaction"),r={minMessages:t.requiredMessagesNumber,extraCurrencyRequired:t.requireExtraCurrencies};if(!n&&!i)throw new m("Wallet doesn't support SendTransaction feature.",{cause:{requiredFeature:{featureName:"SendTransaction",value:r}}});if(t.requireExtraCurrencies&&(!i||!i.extraCurrencySupported))throw new m("Wallet is not able to handle such SendTransaction request. Extra currencies support is required.",{cause:{requiredFeature:{featureName:"SendTransaction",value:r}}});if(i&&void 0!==i.maxMessages){if(i.maxMessages<t.requiredMessagesNumber)throw new m(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${i.maxMessages}, but ${t.requiredMessagesNumber} is required.`,{cause:{requiredFeature:{featureName:"SendTransaction",value:r}}});return}!function(...e){try{console.warn("[TON_CONNECT_SDK]",...e)}catch(e){}}("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")}(this.wallet.device.features,{requiredMessagesNumber:u,requireExtraCurrencies:h});let p=this.getSessionInfo(),g=null!=(n=null==a?void 0:a.traceId)?n:Z();this.tracker.trackTransactionSentForSignature(this.wallet,e,p,g);let{validUntil:f,messages:y}=e,w=s(e,["validUntil","messages"]),b=e.from||this.account.address,_=e.network||this.account.chain;if((null==(i=this.wallet)?void 0:i.account.chain)&&_!==this.wallet.account.chain){if(!ef)throw new v("Wallet connected to a wrong network",{cause:{expectedChainId:null==(r=this.wallet)?void 0:r.account.chain,actualChainId:_}});console.error("Wallet connected to a wrong network",{expectedChainId:null==(o=this.wallet)?void 0:o.account.chain,actualChainId:_})}let S=yield this.provider.sendRequest(W.convertToRpcRequest(Object.assign(Object.assign({},w),{from:b,network:_,valid_until:f,messages:y.map(e=>{var{extraCurrency:t,payload:n,stateInit:i}=e;return Object.assign(Object.assign({},s(e,["extraCurrency","payload","stateInit"])),{payload:te(n),stateInit:te(i),extra_currency:t})})})),{onRequestSent:a.onRequestSent,signal:d.signal,traceId:g});if(W.isError(S))return this.tracker.trackTransactionSigningFailed(this.wallet,e,S.error.message,S.error.code,p,g),W.parseAndThrowError(S);let C=W.convertFromRpcResponse(S);return this.tracker.trackTransactionSigned(this.wallet,e,C,p,g),Object.assign(Object.assign({},C),{traceId:S.traceId})})}signData(e,t){return a(this,void 0,void 0,function*(){var n,i,r,o;let s=K(null==t?void 0:t.signal);if(s.signal.aborted)throw new l("data sending was aborted");let a=function(e){var t,n,i;if(!e9(e))return"Payload must be an object";if(!e3(e.type))return"'type' is required";switch(e.type){case"text":return e7(t=e,["type","text","network","from"])?"Text payload contains extra properties":e3(t.text)?void 0===t.network||e8(t.network)?void 0===t.from||e4(t.from)?null:"Invalid 'from'":"Invalid 'network' format":"'text' is required";case"binary":return e7(n=e,["type","bytes","network","from"])?"Binary payload contains extra properties":e3(n.bytes)?void 0===n.network||e8(n.network)?void 0===n.from||e4(n.from)?null:"Invalid 'from'":"Invalid 'network' format":"'bytes' is required";case"cell":return e7(i=e,["type","schema","cell","network","from"])?"Cell payload contains extra properties":e3(i.schema)?e3(i.cell)?e6(i.cell)?void 0===i.network||e8(i.network)?void 0===i.from||e4(i.from)?null:"Invalid 'from'":"Invalid 'network' format":"Invalid 'cell' format (must be valid base64)":"'cell' is required":"'schema' is required";default:return"Invalid 'type' value"}}(e);if(a)if(ef)console.error("SignDataPayload validation failed: "+a);else throw new l("SignDataPayload validation failed: "+a);this.checkConnection(),function(e,t){let n=e.find(e=>e&&"object"==typeof e&&"SignData"===e.name);
37if(!n)throw new m("Wallet doesn't support SignData feature.",{cause:{requiredFeature:{featureName:"SignData",value:{types:t.requiredTypes}}}});let i=t.requiredTypes.filter(e=>!n.types.includes(e));if(i.length)throw new m(`Wallet doesn't support required SignData types: ${i.join(", ")}.`,{cause:{requiredFeature:{featureName:"SignData",value:{types:i}}}})}(this.wallet.device.features,{requiredTypes:[e.type]});let c=this.getSessionInfo(),d=null!=(n=null==t?void 0:t.traceId)?n:Z();this.tracker.trackDataSentForSignature(this.wallet,e,c,d);let u=e.from||this.account.address,h=e.network||this.account.chain;if((null==(i=this.wallet)?void 0:i.account.chain)&&h!==this.wallet.account.chain){if(!ef)throw new v("Wallet connected to a wrong network",{cause:{expectedChainId:null==(r=this.wallet)?void 0:r.account.chain,actualChainId:h}});console.error("Wallet connected to a wrong network",{expectedChainId:null==(o=this.wallet)?void 0:o.account.chain,actualChainId:h})}let p=yield this.provider.sendRequest(L.convertToRpcRequest(Object.assign(Object.assign(Object.assign({},e),"cell"===e.type?{cell:te(e.cell)}:{}),{from:u,network:h})),{onRequestSent:null==t?void 0:t.onRequestSent,signal:s.signal,traceId:d});if(L.isError(p))return this.tracker.trackDataSigningFailed(this.wallet,e,p.error.message,p.error.code,c,d),L.parseAndThrowError(p);let g=L.convertFromRpcResponse(p);return this.tracker.trackDataSigned(this.wallet,e,g,c,d),Object.assign(Object.assign({},g),{traceId:d})})}setConnectionNetwork(e){if(this.connected)throw new l("Cannot change network while wallet is connected");this.desiredChainId=e}disconnect(e){return a(this,void 0,void 0,function*(){var t,n;if(!this.connected)throw new p;let i=K(null==e?void 0:e.signal),r=this.abortController;if(this.abortController=i,i.signal.aborted)throw new l("Disconnect was aborted");let o=null!=(t=null==e?void 0:e.traceId)?t:Z();this.onWalletDisconnected("dapp",{traceId:o}),yield null==(n=this.provider)?void 0:n.disconnect({signal:i.signal,traceId:o}),null==r||r.abort()})}getSessionId(){return a(this,void 0,void 0,function*(){if(!this.provider)return null;try{let e=yield this.bridgeConnectionStorage.getConnection();if(!e||"http"!==e.type)return null;if("sessionCrypto"in e)return e.sessionCrypto.sessionId;return e.session.sessionCrypto.sessionId}catch(e){return null}})}getSessionInfo(){var e;if((null==(e=this.provider)?void 0:e.type)!=="http"||!("session"in this.provider))return null;try{let e=this.provider.session;if(!e)return null;let t=e.sessionCrypto.sessionId,n=null;return"walletPublicKey"in e&&(n=e.walletPublicKey),{clientId:t,walletId:n}}catch(e){return null}}pauseConnection(){var e;(null==(e=this.provider)?void 0:e.type)==="http"&&this.provider.pause()}unPauseConnection(){var e;return(null==(e=this.provider)?void 0:e.type)!=="http"?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){let e=eo();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch(()=>{})})}catch(e){z("Cannot subscribe to the document.visibilitychange: ",e)}}initAnalytics(e,t,n){var i,r;let o=null==n?void 0:n.analytics,s=null!=(i=null==o?void 0:o.mode)?i:"telemetry";if("off"===s)return;let a=new tt({environment:this.environment,mode:s});this.analytics=a;let l=this.environment.getTelegramUser(),c={browser:this.environment.getBrowser(),platform:this.environment.getPlatform(),manifest_json_url:e,origin_url:es,locale:this.environment.getLocale()};l&&(c.tg_id=l.id,c.tma_is_premium=l.isPremium),r=a.scoped(c),t.addEventListener("ton-connect-ui-wallet-modal-opened",e=>{var t;let{detail:n}=e;r.emitConnectionStarted({client_id:n.client_id||"",versions:ti(n.custom_data),main_screen:n.visible_wallets,trace_id:null!=(t=n.trace_id)?t:void 0})}),t.addEventListener("ton-connect-ui-selected-wallet",e=>{var t,n;let{detail:i}=e;r.emitConnectionSelectedWallet({client_id:i.client_id||"",versions:ti(i.custom_data),main_screen:i.visible_wallets,wallets_menu:i.wallets_menu,trace_id:null!=(t=i.trace_id)?t:void 0,wallet_app_name:null!=(n=i.wallet_type)?n:"",wallet_redirect_method:i.wallet_redirect_method,wallet_redirect_link:i.wallet_redirect_link})}),t.addEventListener("ton-connect-connection-completed",e=>{let{detail:t}=e;r.emitConnectionCompleted(tr(t))}),t.addEventListener("ton-connect-connection-error",e=>{var t,n;let{detail:i}=e;r.emitConnectionError({client_id:i.custom_data.client_id||"",wallet_id:i.custom_data.wallet_id||"",error_code:null!=(t=i.error_code)?t:0,error_message:i.error_message,trace_id:null!=(n=i.trace_id)?n:void 0})}),t.addEventListener("ton-connect-disconnection",e=>{let{detail:t}=e;r.emitDisconnection(tr(t))}),t.addEventListener("ton-connect-transaction-sent-for-signature",e=>{let{detail:t}=e;r.emitTransactionSent(tr(t))}),t.addEventListener("ton-connect-transaction-signed",e=>{let{detail:t}=e;r.emitTransactionSigned(Object.assign(Object.assign({},tr(t)),{signed_boc:e.detail.signed_transaction}))}),t.addEventListener("ton-connect-transaction-signing-failed",e=>{var t;let{detail:n}=e;r.emitTransactionSigningFailed(Object.assign(Object.assign({},tr(n)),{valid_until:Number(n.valid_until),messages:n.messages.map(e=>{var t,n,i,r;return{address:null!=(t=e.address)?t:"",amount:null!=(n=e.amount)?n:"",payload:null!=(i=e.payload)?i:"",state_init:null!=(r=e.state_init)?r:""}}),error_message:n.error_message,error_code:null!=(t=n.error_code)?t:0}))}),t.addEventListener("ton-connect-sign-data-request-initiated",e=>{let{detail:t}=e;null==r||r.emitSignDataRequestInitiated(tr(t))}),t.addEventListener("ton-connect-sign-data-request-completed",e=>{let{detail:t}=e;null==r||r.emitSignDataRequestCompleted(tr(t))}),t.addEventListener("ton-connect-sign-data-request-failed",e=>{var t;let n,{detail:i}=e,o="";"text"===i.data.type&&(o=i.data.text),"cell"===i.data.type&&(o=i.data.cell,n=i.data.schema),"binary"===i.data.type&&(o=i.data.bytes),null==r||r.emitSignDataRequestFailed(Object.assign(Object.assign({},tr(i)),{sign_data_type:i.data.type,sign_data_value:o,sign_data_schema:n,error_code:null!=(t=i.error_code)?t:0,error_message:i.error_message}))})}createProvider(e){let t;if(!Array.isArray(e)&&"jsBridgeKey"in e)t=new ea(this.bridgeConnectionStorage,e.
37jsBridgeKey,this.analytics);else{var n;t=!Array.isArray(e)&&"type"in(n=e)&&"wallet-connect"===n.type?new tc(this.bridgeConnectionStorage):new et(this.bridgeConnectionStorage,e,this.analytics)}return t.listen(this.walletEventsListener.bind(this)),t}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload,{traceId:e.traceId});break;case"connect_error":this.tracker.trackConnectionError(e.payload.message,e.payload.code,this.getSessionInfo(),e.traceId);let t=k.parseError(e.payload);this.onWalletConnectError(t);break;case"disconnect":this.onWalletDisconnected("wallet",{traceId:e.traceId})}}onWalletConnected(e,t){var n,i;let o=e.items.find(e=>"ton_addr"===e.name),s=e.items.find(e=>"ton_proof"===e.name);if(!o)throw new l("ton_addr connection item was not found");if(!eC(e.device.features,this.walletsRequiredFeatures)){null==(n=this.provider)||n.disconnect(),this.onWalletConnectError(new f("Wallet does not support required features",{cause:{connectEvent:e}}));return}let a={device:e.device,provider:this.provider.type,account:{address:o.address,chain:o.network,walletStateInit:o.walletStateInit,publicKey:o.publicKey}};if(this.desiredChainId&&a.account.chain!==this.desiredChainId){let e=this.desiredChainId,t=a.account.chain;null==(i=this.provider)||i.disconnect(),this.onWalletConnectError(new v("Wallet connected to a wrong network",{cause:{expectedChainId:e,actualChainId:t}}));return}if(s){let e,t=function(e){if(!e9(e))return"ton_proof item must be an object";if(e7(e,["error","proof","name"]))return"ton_proof item contains extra properties";let 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){let t=e.proof;if(!e9(t))return"Invalid 'proof' object";if(!e5(t.timestamp))return"Invalid 'proof.timestamp'";let n=t.domain;if(!e9(n))return"Invalid 'proof.domain'";if(!e5(n.lengthBytes))return"Invalid 'proof.domain.lengthBytes'";if(!e3(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(!e3(t.payload))return"Invalid 'proof.payload'";if(!e3(t.signature)||!eZ.test(t.signature))return"Invalid 'proof.signature' format"}if(n){let t=e.error;if(!e9(t))return"Invalid 'error' object";if(e7(t,["code","message"]))return"ton_proof error contains extra properties";if(!e5(t.code))return"Invalid 'error.code'";if(!e3(t.message))return"Invalid 'error.message'"}return null}(s);if(t)ef&&console.error("TonProofItem validation failed: "+t),e={name:"ton_proof",error:{code:r.F2.UNKNOWN_ERROR,message:t}};else try{if("proof"in s)e={name:"ton_proof",proof:{timestamp:s.proof.timestamp,domain:{lengthBytes:s.proof.domain.lengthBytes,value:s.proof.domain.value},payload:s.proof.payload,signature:s.proof.signature}};else if("error"in s)e={name:"ton_proof",error:{code:s.error.code,message:s.error.message}};else throw new l("Invalid data format")}catch(t){e={name:"ton_proof",error:{code:r.F2.UNKNOWN_ERROR,message:"Invalid data format"}}}a.connectItems={tonProof:e}}this.wallet=a;let c=this.getSessionInfo();this.tracker.trackConnectionCompleted(a,c,null==t?void 0:t.traceId)}onWalletConnectError(e){if(this.statusChangeErrorSubscriptions.forEach(t=>t(e)),G(e),e instanceof u||e instanceof d)throw z(e),e}onWalletDisconnected(e,t){let n=this.getSessionInfo();this.tracker.trackDisconnection(this.wallet,e,n,null==t?void 0:t.traceId),this.wallet=null}checkConnection(){if(!this.connected)throw new p}createConnectRequest(e){let t=[Object.assign({name:"ton_addr"},this.desiredChainId?{network:this.desiredChainId}:{})];return(null==e?void 0:e.tonProof)&&t.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:t}}}td.walletsList=new eS,td.isWalletInjected=e=>ea.isWalletInjected(e),td.isInsideWalletBrowser=e=>ea.isInsideWalletBrowser(e)}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.