@tonconnect/ui 2.0.9-beta.2 → 2.0.9-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tonconnect-ui.min.js +2 -2
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +12 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +12 -13
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -732,7 +732,7 @@ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnP
|
|
|
732
732
|
width: 32px;
|
|
733
733
|
height: 32px;
|
|
734
734
|
border-radius: ${e=>rc[e.theme.borderRadius]};
|
|
735
|
-
`,vc=e=>{const[t]=ji();return vt((()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())}))};function yc(e,t){let n;n="string"==typeof t?t:_o()?t.twaReturnUrl||t.returnStrategy:"none";const r=function(e,t,n){const r=new URL(e);return r.searchParams.append(t,n),r.toString()}(e,"ret",n);if(!te(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+ne(o)}function bc(e,t){t=__spreadValues({},t);const n=function(e){const t=new URL(e);t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start");return t.toString()}(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),ko()){t.returnStrategy="back";ar(yc(r.toString(),t.returnStrategy))}else if(_o())if(xo("ios","android","macos","tdesktop","web")){t.returnStrategy="back";Eo(yc(r.toString(),t.returnStrategy))}else xo("weba")?Eo(yc(r.toString(),t)):ar(yc(r.toString(),t));else if(gr("ios")){"back"===t.returnStrategy&&(pr("safari")?t.returnStrategy="back":pr("chrome")?t.returnStrategy="googlechrome://":pr("firefox")?t.returnStrategy="firefox://":pr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=pr("chrome"),n=pr("firefox");if((e||n)&&!t.forceRedirect){const e=yc(r.toString(),t.returnStrategy);lr(xc(e),(()=>ar(e)))}else{ar(yc(r.toString(),t.returnStrategy))}}else if(gr("android")){t.returnStrategy="back";const e=pr("chrome"),n=pr("firefox");if((e||n)&&!t.forceRedirect){const e=yc(r.toString(),t.returnStrategy);lr(xc(e),(()=>ar(e)))}else{ar(yc(r.toString(),t.returnStrategy))}}else if(gr("ipad")){"back"===t.returnStrategy&&(pr("safari")?t.returnStrategy="back":pr("chrome")?t.returnStrategy="googlechrome://":pr("firefox")?t.returnStrategy="firefox://":pr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=pr("chrome"),n=pr("firefox");if((e||n)&&!t.forceRedirect){const e=yc(r.toString(),t.returnStrategy);lr(xc(e),(()=>ar(e)))}else{ar(yc(r.toString(),t.returnStrategy))}}else if(gr("macos","windows","linux"))if(t.returnStrategy="back",t.twaReturnUrl=void 0,t.forceRedirect)ar(yc(r.toString(),t));else{const e=yc(r.toString(),t);lr(xc(e),(()=>ar(e)))}else ar(yc(r.toString(),t))}function Cc(e,t,n,r){if(n=__spreadValues({},n),ko())if(gr("ios","android"))"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link"),sr(yc(e,n.returnStrategy),"_self");else{r("universal-link");ar(yc(e,n.returnStrategy))}else if(_o())if(xo("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=yc(e,n.returnStrategy);Eo(t,(()=>{r("universal-link"),ar(t)}))}else if(xo("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else if(xo("weba")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy=location.href:pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else if(xo("web")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy=location.href:pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else{r("universal-link");ar(yc(e,n.returnStrategy))}else if(gr("ios"))"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),pr("chrome")?(r("universal-link"),sr(yc(e,n.returnStrategy),"_self")):(r("universal-link"),ar(yc(e,n.returnStrategy)));else if(gr("android"))"back"===n.returnStrategy&&(pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),ar(yc(e,n.returnStrategy));else if(gr("ipad"))"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),pr("chrome")?(r("universal-link"),sr(yc(e,n.returnStrategy),"_self")):(r("universal-link"),ar(yc(e,n.returnStrategy)));else if(gr("macos","windows","linux")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else r("universal-link"),ar(yc(e,n.returnStrategy))}function xc(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const _c=e=>{const[t,n]=gt("mobile"),[r,o]=gt(!1),[i,s]=gt(),[a,l]=gt(!0),c=Et(Ir);_t(c.onStatusChange((()=>{}),(()=>{e.wallet.appName!==ra&&o(!0)})));const u=()=>{try{const t=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest);s(t)}catch(Ju){}};mt((()=>{"extension"!==Ct(t)&&(ql(e.wallet)||Fl(e.wallet))&&u()}));const d=()=>{o(!1),"extension"===t()&&u(),n("mobile"),Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:"qrcode"}))},h=()=>{if(o(!1),"extension"===t()&&u(),n("desktop"),te(i()))f();else{const t=!a();l(!1),Cc(i(),e.wallet.deepLink,{returnStrategy:Dl.returnStrategy,forceRedirect:t},(t=>{Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:t}))}))}},f=()=>{const t=!a();l(!1),Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:"universal-link"})),bc(i(),{returnStrategy:Dl.returnStrategy,twaReturnUrl:Dl.twaReturnUrl,forceRedirect:t})},g=()=>{o(!1),n("extension"),be(e.wallet)&&(Ar(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest))};return ql(e.wallet)?d():zl(e.wallet)?g():h(),qt(oc,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[qt(Xt,{get when(){return!e.backDisabled},get children(){return qt(cc,{icon:"arrow",onClick:()=>e.onBackClick()})}}),qt(ac,{get children(){return e.wallet.name}}),qt(Xt,{get when(){return"mobile"===t()},get children(){return qt(lc,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",vt((()=>e.wallet.name)),"’s camera"]}})}}),qt(ic,{get qr(){return"mobile"===t()},get children(){return qt(en,{get children(){return[qt(tn,{get when(){return"mobile"===t()},get children(){return qt(sc,{disableCopy:!1,get sourceUrl(){return yc(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),qt(tn,{get when(){return r()},get children(){return[qt(gc,{size:"s"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"}),qt(uc,{get children(){return qt(jo,{get leftIcon(){return qt(Ns,{})},get onClick(){return"extension"===t()?g:h},get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),qt(tn,{get when(){return"extension"===t()},get children(){return[qt(Xt,{get when(){return be(e.wallet)},get children(){return[qt(fc,{size:"s"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," browser extension…"]}}),qt(uc,{get children(){return qt(jo,{get leftIcon(){return qt(Ns,{})},onClick:g,get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),qt(Xt,{get when(){return!be(e.wallet)},get children(){return[qt(pc,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",vt((()=>e.wallet.name))," browser extension"]}}),qt(uc,{get children(){return qt(wa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return qt(jo,{get rightIcon(){return qt($s,{})},onClick:g,get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})}})]}})]}}),qt(tn,{get when(){return"desktop"===t()},get children(){return[qt(Cs,{size:"m"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," on desktop…"]}}),qt(uc,{get children(){return[qt(jo,{get leftIcon(){return qt(Ns,{})},onClick:h,get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}}),qt(wa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return qt(jo,{get rightIcon(){return qt($s,{})},get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})]}})]}})]}})}}),qt(Xt,{get when(){return e.wallet.appName===ra},get children(){return qt(wc,{get rightIcon(){return qt(mc,{get src(){return ia}})},scale:"s",onClick:f,get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),qt(Xt,{get when(){return e.wallet.appName!==ra},get children(){return qt(dc,{get children(){return[qt(Xt,{get when(){return vt((()=>"mobile"!==t()))()&&ql(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Ls,{})},onClick:d,get children(){return qt(vc,{translationKey:"common.mobile",children:"Mobile"})}})}}),qt(Xt,{get when(){return vt((()=>"extension"!==t()))()&&zl(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Rs,{})},onClick:g,get children(){return qt(vc,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),qt(Xt,{get when(){return vt((()=>"desktop"!==t()))()&&Fl(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Ms,{})},onClick:h,get children(){return qt(vc,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},kc=qn.div``,Sc=qn(ei)`
|
|
735
|
+
`,vc=e=>{const[t]=ji();return vt((()=>{var n;return t(e.translationKey,e.translationValues,null==(n=e.children)?void 0:n.toString())}))};function yc(e,t){let n;n="string"==typeof t?t:_o()?t.twaReturnUrl||t.returnStrategy:"none";const r=function(e,t,n){const r=new URL(e);return r.searchParams.append(t,n),r.toString()}(e,"ret",n);if(!te(e))return r;const o=r.slice(r.lastIndexOf("&")+1);return r.slice(0,r.lastIndexOf("&"))+"-"+ne(o)}function bc(e,t){t=__spreadValues({},t);const n=function(e){const t=new URL(e);t.searchParams.has("attach")&&(t.searchParams.delete("attach"),t.pathname+="/start");return t.toString()}(e),r=new URL(n);if(r.searchParams.has("startapp")||r.searchParams.append("startapp","tonconnect"),ko()){t.returnStrategy="back";ar(yc(r.toString(),t.returnStrategy))}else if(_o())if(xo("ios","android","macos","tdesktop","web")){t.returnStrategy="back";Eo(yc(r.toString(),t.returnStrategy))}else xo("weba")?Eo(yc(r.toString(),t)):ar(yc(r.toString(),t));else if(gr("ios")){"back"===t.returnStrategy&&(pr("safari")?t.returnStrategy="back":pr("chrome")?t.returnStrategy="googlechrome://":pr("firefox")?t.returnStrategy="firefox://":pr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=pr("chrome"),n=pr("firefox");if((e||n)&&!t.forceRedirect){const e=yc(r.toString(),t.returnStrategy);lr(xc(e),(()=>ar(e)))}else{ar(yc(r.toString(),t.returnStrategy))}}else if(gr("android")){t.returnStrategy="back";const e=pr("chrome"),n=pr("firefox");if((e||n)&&!t.forceRedirect){const e=yc(r.toString(),t.returnStrategy);lr(xc(e),(()=>ar(e)))}else{ar(yc(r.toString(),t.returnStrategy))}}else if(gr("ipad")){"back"===t.returnStrategy&&(pr("safari")?t.returnStrategy="back":pr("chrome")?t.returnStrategy="googlechrome://":pr("firefox")?t.returnStrategy="firefox://":pr("opera")?t.returnStrategy="opera-http://":t.returnStrategy=location.href);const e=pr("chrome"),n=pr("firefox"),o=(e||n)&&!t.forceRedirect,i=yc(r.toString(),t.returnStrategy);if(o){lr(xc(i),(()=>ar(i)))}else ar(i)}else if(gr("macos","windows","linux")){t.returnStrategy="back",t.twaReturnUrl=void 0;const e=yc(r.toString(),t.returnStrategy);if(t.forceRedirect)ar(e);else{lr(xc(e),(()=>ar(e)))}}else ar(yc(r.toString(),t))}function Cc(e,t,n,r){if(n=__spreadValues({},n),ko())if(gr("ios","android"))"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link"),sr(yc(e,n.returnStrategy),"_self");else{r("universal-link");ar(yc(e,n.returnStrategy))}else if(_o())if(xo("ios","android")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve"),r("universal-link");const t=yc(e,n.returnStrategy);Eo(t,(()=>{r("universal-link"),ar(t)}))}else if(xo("macos","tdesktop")){"back"===n.returnStrategy&&(n.returnStrategy="tg://resolve");const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else if(xo("weba")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy=location.href:pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else if(xo("web")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy=location.href:pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href);const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else{r("universal-link");ar(yc(e,n.returnStrategy))}else if(gr("ios"))"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),pr("chrome")?(r("universal-link"),sr(yc(e,n.returnStrategy),"_self")):(r("universal-link"),ar(yc(e,n.returnStrategy)));else if(gr("android"))"back"===n.returnStrategy&&(pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),r("universal-link"),ar(yc(e,n.returnStrategy));else if(gr("ipad"))"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy=location.href),pr("chrome")?(r("universal-link"),sr(yc(e,n.returnStrategy),"_self")):(r("universal-link"),ar(yc(e,n.returnStrategy)));else if(gr("macos","windows","linux")){"back"===n.returnStrategy&&(pr("safari")?n.returnStrategy="none":pr("chrome")?n.returnStrategy="googlechrome://":pr("firefox")?n.returnStrategy="firefox://":pr("opera")?n.returnStrategy="opera-http://":n.returnStrategy="none");const o=yc(e,n.returnStrategy);!!t&&!n.forceRedirect?(r("custom-deeplink"),lr(wr(o,t),(()=>{r("universal-link"),ar(o)}))):(r("universal-link"),ar(o))}else r("universal-link"),ar(yc(e,n.returnStrategy))}function xc(e){const t=new URL(e),[,n,r]=t.pathname.split("/");return`tg://resolve?domain=${n}&appname=${r}&startapp=${t.searchParams.get("startapp")}`}const _c=e=>{const[t,n]=gt("mobile"),[r,o]=gt(!1),[i,s]=gt(),[a,l]=gt(!0),c=Et(Ir);_t(c.onStatusChange((()=>{}),(()=>{e.wallet.appName!==ra&&o(!0)})));const u=()=>{try{const t=c.connect({universalLink:e.wallet.universalLink,bridgeUrl:e.wallet.bridgeUrl},e.additionalRequest);s(t)}catch(Ju){}};mt((()=>{"extension"!==Ct(t)&&(ql(e.wallet)||Fl(e.wallet))&&u()}));const d=()=>{o(!1),"extension"===t()&&u(),n("mobile"),Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:"qrcode"}))},h=()=>{if(o(!1),"extension"===t()&&u(),n("desktop"),te(i()))f();else{const t=!a();l(!1),Cc(i(),e.wallet.deepLink,{returnStrategy:Dl.returnStrategy,forceRedirect:t},(t=>{Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:t}))}))}},f=()=>{const t=!a();l(!1),Ar(__spreadProps(__spreadValues({},e.wallet),{openMethod:"universal-link"})),bc(i(),{returnStrategy:Dl.returnStrategy,twaReturnUrl:Dl.twaReturnUrl,forceRedirect:t})},g=()=>{o(!1),n("extension"),be(e.wallet)&&(Ar(e.wallet),c.connect({jsBridgeKey:e.wallet.jsBridgeKey},e.additionalRequest))};return ql(e.wallet)?d():zl(e.wallet)?g():h(),qt(oc,{"data-tc-wallets-modal-connection-desktop":"true",get children(){return[qt(Xt,{get when(){return!e.backDisabled},get children(){return qt(cc,{icon:"arrow",onClick:()=>e.onBackClick()})}}),qt(ac,{get children(){return e.wallet.name}}),qt(Xt,{get when(){return"mobile"===t()},get children(){return qt(lc,{translationKey:"walletModal.desktopConnectionModal.scanQR",get translationValues(){return{name:e.wallet.name}},get children(){return["Scan the QR code below with your phone’s or ",vt((()=>e.wallet.name)),"’s camera"]}})}}),qt(ic,{get qr(){return"mobile"===t()},get children(){return qt(en,{get children(){return[qt(tn,{get when(){return"mobile"===t()},get children(){return qt(sc,{disableCopy:!1,get sourceUrl(){return yc(i(),"none")},get imageUrl(){return e.wallet.imageUrl}})}}),qt(tn,{get when(){return r()},get children(){return[qt(gc,{size:"s"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.connectionDeclined",children:"Connection declined"}),qt(uc,{get children(){return qt(jo,{get leftIcon(){return qt(Ns,{})},get onClick(){return"extension"===t()?g:h},get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),qt(tn,{get when(){return"extension"===t()},get children(){return[qt(Xt,{get when(){return be(e.wallet)},get children(){return[qt(fc,{size:"s"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.continueInExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," browser extension…"]}}),qt(uc,{get children(){return qt(jo,{get leftIcon(){return qt(Ns,{})},onClick:g,get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}})}})]}}),qt(Xt,{get when(){return!be(e.wallet)},get children(){return[qt(pc,{translationKey:"walletModal.desktopConnectionModal.dontHaveExtension",get translationValues(){return{name:e.wallet.name}},get children(){return["Seems you don't have installed ",vt((()=>e.wallet.name))," browser extension"]}}),qt(uc,{get children(){return qt(wa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return qt(jo,{get rightIcon(){return qt($s,{})},onClick:g,get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})}})]}})]}}),qt(tn,{get when(){return"desktop"===t()},get children(){return[qt(Cs,{size:"m"}),qt(pc,{translationKey:"walletModal.desktopConnectionModal.continueOnDesktop",get translationValues(){return{name:e.wallet.name}},get children(){return["Continue in ",vt((()=>e.wallet.name))," on desktop…"]}}),qt(uc,{get children(){return[qt(jo,{get leftIcon(){return qt(Ns,{})},onClick:h,get children(){return qt(vc,{translationKey:"common.retry",children:"Retry"})}}),qt(wa,{get href(){return e.wallet.aboutUrl},blank:!0,get children(){return qt(jo,{get rightIcon(){return qt($s,{})},get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.getWallet",get translationValues(){return{name:e.wallet.name}},get children(){return["Get ",vt((()=>e.wallet.name))]}})}})}})]}})]}})]}})}}),qt(Xt,{get when(){return e.wallet.appName===ra},get children(){return qt(wc,{get rightIcon(){return qt(mc,{get src(){return ia}})},scale:"s",onClick:f,get children(){return qt(vc,{translationKey:"walletModal.desktopConnectionModal.openWalletOnTelegram",children:"Open Wallet in Telegram on desktop"})}})}}),qt(Xt,{get when(){return e.wallet.appName!==ra},get children(){return qt(dc,{get children(){return[qt(Xt,{get when(){return vt((()=>"mobile"!==t()))()&&ql(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Ls,{})},onClick:d,get children(){return qt(vc,{translationKey:"common.mobile",children:"Mobile"})}})}}),qt(Xt,{get when(){return vt((()=>"extension"!==t()))()&&zl(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Rs,{})},onClick:g,get children(){return qt(vc,{translationKey:"common.browserExtension",children:"Browser Extension"})}})}}),qt(Xt,{get when(){return vt((()=>"desktop"!==t()))()&&Fl(e.wallet)},get children(){return qt(hc,{appearance:"secondary",get leftIcon(){return qt(Ms,{})},onClick:h,get children(){return qt(vc,{translationKey:"common.desktop",children:"Desktop"})}})}})]}})}})]}})},kc=qn.div``,Sc=qn(ei)`
|
|
736
736
|
position: absolute;
|
|
737
737
|
top: 16px;
|
|
738
738
|
left: 16px;
|
|
@@ -1024,5 +1024,5 @@ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnP
|
|
|
1024
1024
|
width: 16px;
|
|
1025
1025
|
`,Mu=qn(jo)`
|
|
1026
1026
|
margin-top: 32px;
|
|
1027
|
-
`,Ou=e=>{const t=Wo(e),n=Et(ma),[r,o]=gt(!0),[i,s]=gt(!1);let a,l;mt((()=>{const e=Mr();s(!!e&&"sent"in e&&e.sent)})),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||te(n.wallet.universalLink)&&_o())&&(a=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||te(n.wallet.deepLink)&&_o())&&(l=n.wallet.deepLink);const c=()=>{const e=Mr(),t="returnStrategy"in e?e.returnStrategy:Dl.returnStrategy,n=!r();o(!1),te(a)?bc(a,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Dl.twaReturnUrl,forceRedirect:n}):Cc(a,l,{returnStrategy:t,forceRedirect:n},(()=>{}))};return qt(Eu,Yt(t,{get children(){return[vt((()=>e.icon)),qt(Ru,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),qt(Tu,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),qt(Xt,{get when(){return!i()&&("open-wallet"===e.showButton&&a||"open-wallet"!==e.showButton)},get children(){return qt(Lu,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return qt(Au,{})}})}}),qt(Xt,{get when(){return i()},get children(){return[qt(Xt,{get when(){return"open-wallet"!==e.showButton},get children(){return qt(Mu,{onClick:()=>e.onClose(),get children(){return qt(vc,{translationKey:"common.close",children:"Close"})}})}}),qt(Xt,{get when(){return"open-wallet"===e.showButton&&a},get children(){return qt(Mu,{onClick:c,get children(){return qt(vc,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Nu=e=>{const t=Et(ma),[n]=ji();return qt(Ou,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return qt(Cs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Pu=e=>qt(Ou,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return qt(ms,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),$u=e=>qt(Ou,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return qt(fs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Iu=()=>qt(wi,{get opened(){var e;return vt((()=>null!==Mr()))()&&!0===(null==(e=Mr())?void 0:e.openModal)},get enableAndroidBackHandler(){return Dl.enableAndroidBackHandler},onClose:()=>Or(null),"data-tc-actions-modal-container":"true",get children(){return qt(en,{get children(){return[qt(tn,{get when(){return"transaction-sent"===Mr().name},get children(){return qt($u,{onClose:()=>Or(null)})}}),qt(tn,{get when(){return"transaction-canceled"===Mr().name},get children(){return qt(Pu,{onClose:()=>Or(null)})}}),qt(tn,{get when(){return"confirm-transaction"===Mr().name},get children(){return qt(Nu,{onClose:()=>Or(null)})}})]}})}}),Uu=()=>{const{locale:e}=ji()[1];mt((()=>e(Dl.language))),mt((()=>{Sr()&&fa()}));const t=Et(Ir),n=Et(ma),[r,o]=gt(!1),i=()=>{var e;return"loading"===(null==(e=Dl.connectRequestParameters)?void 0:e.state)},s=vt((()=>{var e;if(!i())return null==(e=Dl.connectRequestParameters)?void 0:e.value})),a=e=>{n.closeSingleWalletModal(e)};return _t(t.onStatusChange((e=>{e&&a("wallet-selected")}))),_t((()=>{o(!1)})),qt(Wl,{get opened(){return Sr()},get enableAndroidBackHandler(){return Dl.enableAndroidBackHandler},onClose:()=>a("action-cancelled"),onClickQuestion:()=>o((e=>!e)),"data-tc-wallets-modal-container":"true",get children(){return[qt(Xt,{get when(){return r()},get children(){return qt(Nc,{onBackClick:()=>o(!1)})}}),qt(Xt,{get when(){return!r()},get children(){return[qt(Xt,{get when(){return i()},get children(){return[qt(jl,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),qt(Bl,{get children(){return qt(Cs,{size:"m"})}})]}}),qt(Xt,{get when(){return!i()},get children(){return qt(Tn,{get component(){return da()?Gc:_c},get wallet(){return Er()},get additionalRequest(){return s()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},Wu=e=>{const t=Ui(Pr,Dl.language);return customElements.define(Zn,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),qt(Wi.Provider,{value:t,get children(){return qt(ma.Provider,{get value(){return e.tonConnectUI},get children(){return qt(Ir.Provider,{get value(){return Dl.connector},get children(){return[qt(Qn,{}),qt(Vn,{theme:ho,get children(){return[qt(Xt,{get when(){return Dl.buttonRootId},get children(){return qt(Rn,{get mount(){return document.getElementById(Dl.buttonRootId)},get children(){return qt(Ul,{})}})}}),qt(Tn,{component:Zn,get children(){return[qt(Su,{}),qt(Uu,{}),qt(Iu,{})]}})]}})]}})}})}})},ju=()=>{setTimeout((()=>Cr({status:"opened",closeReason:null})))},Bu=e=>{setTimeout((()=>Cr({status:"closed",closeReason:e})))},Du=e=>{setTimeout((()=>kr({status:"opened",closeReason:null,walletInfo:e})))},Hu=e=>{setTimeout((()=>kr({status:"closed",closeReason:e})))},Vu=e=>{setTimeout((()=>Or(e)))},Ku=()=>{setTimeout((()=>Or(null)))},Fu=()=>Tr(),qu=()=>Ar(null),zu=(e,t)=>function(e,t,n,r={}){let o;return ft((r=>{o=r,t===document?e():wn(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}((()=>qt(Wu,{tonConnectUI:t})),document.getElementById(e));class Zu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",br()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=br();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(Ce);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bu(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return __async(this,null,(function*(){return _o()&&So(),ju(),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Gu{constructor(e){__publicField(this,"connector"),__publicField(this,"consumers",[]),this.connector=e.connector,mt((()=>{const e=Mr();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}class Yu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",_r()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=_r();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(e){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const t=Kl(yield this.connector.getWallets(),Dl.walletsListConfiguration),n=t.find(Ce);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(_e).find((t=>Zl(t,e)));if(!!r)return this.openSingleWalletModal(r);const o=`Trying to open modal window with unknown wallet "${e}".`;throw this.tracker.trackConnectionError(o),new or(o)}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Hu("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return __async(this,null,(function*(){return _o()&&So(),Du(e),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Qu{constructor(e){var t;__publicField(this,"eventPrefix","ton-connect-ui-"),__publicField(this,"tonConnectUiVersion"),__publicField(this,"tonConnectSdkVersion",null),__publicField(this,"eventDispatcher"),this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new Ve,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return Ae({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __async(this,null,(function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Ju){}}))}setRequestVersionHandler(){return __async(this,null,(function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",(()=>__async(this,null,(function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Le(this.tonConnectUiVersion))}))))}))}requestTonConnectSdkVersion(){return __async(this,null,(function*(){return new Promise(((e,t)=>__async(this,null,(function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-response-version",(t=>{e(t.detail.version)}),{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-request-version",{type:"request-version"})}catch(Ju){t(Ju)}}))))}))}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Ju){}}trackConnectionStarted(...e){try{const t=Oe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionCompleted(...e){try{const t=Ne(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionError(...e){try{const t=Pe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringStarted(...e){try{const t=$e(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringCompleted(...e){try{const t=Ie(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringError(...e){try{const t=Ue(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackDisconnection(...e){try{const t=He(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSentForSignature(...e){try{const t=je(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSigned(...e){try{const t=Be(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSigningFailed(...e){try{const t=De(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}}e.BadRequestError=B,e.BrowserEventDispatcher=Ve,e.FetchWalletsError=K,e.LocalstorageNotFoundError=V,e.ParseHexError=q,e.THEME=Ln,e.TonConnect=Fe,e.TonConnectError=N,e.TonConnectUI=class{constructor(e){if(__publicField(this,"walletInfoStorage",new mr),__publicField(this,"preferredWalletStorage",new vr),__publicField(this,"tracker"),__publicField(this,"walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"walletsList"),__publicField(this,"connectRequestParametersCallback"),__publicField(this,"connector"),__publicField(this,"modal"),__publicField(this,"singleWalletModal"),__publicField(this,"transactionModal"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new or("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new Fe({manifestUrl:e.manifestUrl,eventDispatcher:null==e?void 0:e.eventDispatcher})}this.tracker=new Qu({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.0.9-beta.2"}),this.modal=new Zu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new Yu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new Gu({connector:this.connector}),this.walletsList=this.getWallets(),this.walletsList.then((e=>{return ur((t=e.map((e=>e.imageUrl)),[...new Set(t)]));var t}));const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return __async(this,null,(function*(){return yield new Promise((e=>requestAnimationFrame(e))),e()}))}((()=>__async(this,null,(function*(){return this.tracker.trackConnectionRestoringStarted(),yield this.connector.restoreConnection(),this.connector.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):(this.tracker.trackConnectionRestoringError("Connection was not restored"),this.walletInfoStorage.removeWalletInfo()),this.connector.connected}))))),this.uiOptions=uo(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();Hl({connector:this.connector,preferredWalletAppName:n}),zu(t,this)}static getWallets(){return Fe.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?__spreadValues(__spreadValues({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,s,a;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),wo(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(wo(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Ln.LIGHT:Ln.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Ln.DARK:Ln.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(wo))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(s=e.uiPreferences.colorsSet,po[Ln.DARK]=uo(s[Ln.DARK],po[Ln.DARK]),po[Ln.LIGHT]=uo(s[Ln.LIGHT],po[Ln.LIGHT]),fo((e=>({colors:uo(po[e.theme],go[e.theme])})))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(a=e.uiPreferences.borderRadius,fo({borderRadius:a})),Hl((t=>{var n,r;const o=uo(__spreadValues(__spreadValues(__spreadValues(__spreadValues({},e.language&&{language:e.language}),!!(null==(n=e.actionsConfiguration)?void 0:n.returnStrategy)&&{returnStrategy:e.actionsConfiguration.returnStrategy}),!!(null==(r=e.actionsConfiguration)?void 0:r.twaReturnUrl)&&{twaReturnUrl:e.actionsConfiguration.twaReturnUrl}),!!e.walletsListConfiguration&&{walletsListConfiguration:e.walletsListConfiguration}),Hr(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o}))}setConnectRequestParameters(e){var t;Hl({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>__async(this,null,(function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(__spreadValues(__spreadValues({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}))),t)}openModal(){return __async(this,null,(function*(){return this.modal.open()}))}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return __async(this,null,(function*(){return this.singleWalletModal.open(e)}))}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return __async(this,null,(function*(){const e=(yield this.getWallets()).find(Ce);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()}))}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),Ku(),qu(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new or("Connect wallet to send a transaction.");_o()&&So();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i,skipRedirectToWallet:s}=this.getModalsAndNotificationsConfiguration(t);Vu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1});const a=()=>{l.signal.aborted||(Vu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0}),this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)&&(te(this.walletInfo.universalLink)?bc(this.walletInfo.universalLink,{returnStrategy:o,twaReturnUrl:i||Dl.twaReturnUrl,forceRedirect:!1}):Cc(this.walletInfo.universalLink,this.walletInfo.deepLink,{returnStrategy:o,forceRedirect:!1},(()=>{}))))},l=new AbortController,c=this.onTransactionModalStateChange((e=>{(null==e?void 0:e.openModal)||(c(),e||l.abort())}));try{const t=yield this.waitForSendTransaction({transaction:e,signal:l.signal},a);return this.tracker.trackTransactionSigned(this.wallet,e,t),Vu({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(Ju){throw Vu({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),Ju instanceof N?Ju:(console.error(Ju),new or("Unhandled error:"+Ju))}finally{c()}}))}connectEmbeddedWallet(e){return __async(this,null,(function*(){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})}))}connectExternalWallet(){return __async(this,null,(function*(){const e=new AbortController;ju();const t=this.onModalStateChange((n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())}));return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})}))}waitForWalletConnection(e){return __async(this,null,(function*(){return new Promise(((t,n)=>{this.tracker.trackConnectionStarted();const{ignoreErrors:r=!1,signal:o=null}=e;if(o&&o.aborted)return this.tracker.trackConnectionError("Connection was cancelled"),n(new or("Wallet was not connected"));const i=e=>__async(this,null,(function*(){if(e)this.tracker.trackConnectionCompleted(e),a(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;a(),n(new or("Wallet was not connected"))}})),s=e=>{this.tracker.trackConnectionError(e.message),r||(a(),n(e))},a=this.onStatusChange((e=>i(e)),(e=>s(e)));o&&o.addEventListener("abort",(()=>{a(),n(new or("Wallet was not connected"))}),{once:!0})}))}))}waitForSendTransaction(e,t){return __async(this,null,(function*(){return new Promise(((n,r)=>{const{transaction:o,signal:i}=e;if(i.aborted)return this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new or("Transaction was not sent"));const s=e=>__async(this,null,(function*(){n(e)})),a=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new or("Transaction was not sent"))};i.addEventListener("abort",a,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then((e=>(i.removeEventListener("abort",a),s(e)))).catch((e=>(i.removeEventListener("abort",a),(e=>{r(e)})(e))))}))}))}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange((e=>__async(this,null,(function*(){var t;e?(yield this.updateWalletInfo(e),this.setPreferredWalletAppName((null==(t=this.walletInfo)?void 0:t.appName)||e.device.appName)):this.walletInfoStorage.removeWalletInfo()}))))}setPreferredWalletAppName(e){this.preferredWalletStorage.setPreferredWalletAppName(e),Hl({preferredWalletAppName:e})}getSelectedWalletInfo(e){return __async(this,null,(function*(){let t,n=Fu();if(!n)return null;if("name"in n)t=n;else{const r=Kl(yield this.walletsList,Dl.walletsListConfiguration).find((t=>Zl(t,e.device.appName)));if(!r)throw new or(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=__spreadValues(__spreadValues({},r),n)}return t}))}updateWalletInfo(e){return __async(this,null,(function*(){const t=yield this.getSelectedWalletInfo(e);if(t)return this.walletInfo=t,void this.walletInfoStorage.setWalletInfo(t);const n=this.walletInfoStorage.getWalletInfo();this.walletInfo=n||((yield this.walletsList).find((t=>Zl(t,e.device.appName)))||null)}))}normalizeWidgetRoot(e){if(!e||!document.getElementById(e)){e="tc-widget-root";const t=document.createElement("div");t.id=e,document.body.appendChild(t)}return e}checkButtonRootExist(e){if(null!=e&&!document.getElementById(e))throw new or(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,s;const a=["before","success","error"];let l=a;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(l=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(l="all"===e.notifications?a:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?a:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?a:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(s=this.actionsConfiguration)?void 0:s.skipRedirectToWallet)||"ios";return _o()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=or,e.UnknownAppError=D,e.UnknownError=z,e.UserRejectsError=j,e.WalletAlreadyConnectedError=U,e.WalletNotConnectedError=W,e.WalletNotInjectedError=H,e.WalletsListManager=Se,e.WrongAddressError=F,e.createConnectionCompletedEvent=Ne,e.createConnectionErrorEvent=Pe,e.createConnectionRestoringCompletedEvent=Ie,e.createConnectionRestoringErrorEvent=Ue,e.createConnectionRestoringStartedEvent=$e,e.createConnectionStartedEvent=Oe,e.createDisconnectionEvent=He,e.createRequestVersionEvent=Te,e.createResponseVersionEvent=Le,e.createTransactionSentForSignatureEvent=je,e.createTransactionSignedEvent=Be,e.createTransactionSigningFailedEvent=De,e.createVersionInfo=Ae,e.encodeTelegramUrlParameters=ne,e.isTelegramUrl=te,e.isWalletInfoCurrentlyEmbedded=Ce,e.isWalletInfoCurrentlyInjected=be,e.isWalletInfoInjectable=xe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=_e,e.toUserFriendlyAddress=Ze,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1027
|
+
`,Ou=e=>{const t=Wo(e),n=Et(ma),[r,o]=gt(!0),[i,s]=gt(!1);let a,l;mt((()=>{const e=Mr();s(!!e&&"sent"in e&&e.sent)})),(null==n?void 0:n.wallet)&&"universalLink"in n.wallet&&("universal-link"===n.wallet.openMethod||te(n.wallet.universalLink)&&_o())&&(a=n.wallet.universalLink),(null==n?void 0:n.wallet)&&"deepLink"in n.wallet&&("custom-deeplink"===n.wallet.openMethod||te(n.wallet.deepLink)&&_o())&&(l=n.wallet.deepLink);const c=()=>{const e=Mr(),t="returnStrategy"in e?e.returnStrategy:Dl.returnStrategy,n=!r();o(!1),te(a)?bc(a,{returnStrategy:t,twaReturnUrl:"twaReturnUrl"in e?e.twaReturnUrl:Dl.twaReturnUrl,forceRedirect:n}):Cc(a,l,{returnStrategy:t,forceRedirect:n},(()=>{}))};return qt(Eu,Yt(t,{get children(){return[vt((()=>e.icon)),qt(Ru,{get translationKey(){return e.headerTranslationKey},get translationValues(){return e.headerTranslationValues}}),qt(Tu,{get translationKey(){return e.textTranslationKey},get translationValues(){return e.textTranslationValues}}),qt(Xt,{get when(){return!i()&&("open-wallet"===e.showButton&&a||"open-wallet"!==e.showButton)},get children(){return qt(Lu,{disabled:!0,"data-tc-connect-button-loading":"true",get children(){return qt(Au,{})}})}}),qt(Xt,{get when(){return i()},get children(){return[qt(Xt,{get when(){return"open-wallet"!==e.showButton},get children(){return qt(Mu,{onClick:()=>e.onClose(),get children(){return qt(vc,{translationKey:"common.close",children:"Close"})}})}}),qt(Xt,{get when(){return"open-wallet"===e.showButton&&a},get children(){return qt(Mu,{onClick:c,get children(){return qt(vc,{translationKey:"common.openWallet",children:"Open wallet"})}})}})]}})]}}))},Nu=e=>{const t=Et(ma),[n]=ji();return qt(Ou,{headerTranslationKey:"actionModal.confirmTransaction.header",get headerTranslationValues(){return{name:t.wallet&&"name"in t.wallet?t.wallet.name:n("common.yourWallet",{},"Your wallet")}},textTranslationKey:"actionModal.confirmTransaction.text",get icon(){return qt(Cs,{size:"m"})},onClose:()=>e.onClose(),showButton:"open-wallet","data-tc-confirm-modal":"true"})},Pu=e=>qt(Ou,{headerTranslationKey:"actionModal.transactionCanceled.header",textTranslationKey:"actionModal.transactionCanceled.text",get icon(){return qt(ms,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-canceled-modal":"true"}),$u=e=>qt(Ou,{headerTranslationKey:"actionModal.transactionSent.header",textTranslationKey:"actionModal.transactionSent.text",get icon(){return qt(fs,{size:"m"})},onClose:()=>e.onClose(),"data-tc-transaction-sent-modal":"true"}),Iu=()=>qt(wi,{get opened(){var e;return vt((()=>null!==Mr()))()&&!0===(null==(e=Mr())?void 0:e.openModal)},get enableAndroidBackHandler(){return Dl.enableAndroidBackHandler},onClose:()=>Or(null),"data-tc-actions-modal-container":"true",get children(){return qt(en,{get children(){return[qt(tn,{get when(){return"transaction-sent"===Mr().name},get children(){return qt($u,{onClose:()=>Or(null)})}}),qt(tn,{get when(){return"transaction-canceled"===Mr().name},get children(){return qt(Pu,{onClose:()=>Or(null)})}}),qt(tn,{get when(){return"confirm-transaction"===Mr().name},get children(){return qt(Nu,{onClose:()=>Or(null)})}})]}})}}),Uu=()=>{const{locale:e}=ji()[1];mt((()=>e(Dl.language))),mt((()=>{Sr()&&fa()}));const t=Et(Ir),n=Et(ma),[r,o]=gt(!1),i=()=>{var e;return"loading"===(null==(e=Dl.connectRequestParameters)?void 0:e.state)},s=vt((()=>{var e;if(!i())return null==(e=Dl.connectRequestParameters)?void 0:e.value})),a=e=>{n.closeSingleWalletModal(e)};return _t(t.onStatusChange((e=>{e&&a("wallet-selected")}))),_t((()=>{o(!1)})),qt(Wl,{get opened(){return Sr()},get enableAndroidBackHandler(){return Dl.enableAndroidBackHandler},onClose:()=>a("action-cancelled"),onClickQuestion:()=>o((e=>!e)),"data-tc-wallets-modal-container":"true",get children(){return[qt(Xt,{get when(){return r()},get children(){return qt(Nc,{onBackClick:()=>o(!1)})}}),qt(Xt,{get when(){return!r()},get children(){return[qt(Xt,{get when(){return i()},get children(){return[qt(jl,{translationKey:"walletModal.loading",children:"Wallets list is loading"}),qt(Bl,{get children(){return qt(Cs,{size:"m"})}})]}}),qt(Xt,{get when(){return!i()},get children(){return qt(Tn,{get component(){return da()?Gc:_c},get wallet(){return Er()},get additionalRequest(){return s()},onBackClick:()=>{},backDisabled:!0})}})]}})]}})},Wu=e=>{const t=Ui(Pr,Dl.language);return customElements.define(Zn,class extends HTMLElement{}),document.body.hasAttribute("ontouchstart")||document.body.setAttribute("ontouchstart",""),qt(Wi.Provider,{value:t,get children(){return qt(ma.Provider,{get value(){return e.tonConnectUI},get children(){return qt(Ir.Provider,{get value(){return Dl.connector},get children(){return[qt(Qn,{}),qt(Vn,{theme:ho,get children(){return[qt(Xt,{get when(){return Dl.buttonRootId},get children(){return qt(Rn,{get mount(){return document.getElementById(Dl.buttonRootId)},get children(){return qt(Ul,{})}})}}),qt(Tn,{component:Zn,get children(){return[qt(Su,{}),qt(Uu,{}),qt(Iu,{})]}})]}})]}})}})}})},ju=()=>{setTimeout((()=>Cr({status:"opened",closeReason:null})))},Bu=e=>{setTimeout((()=>Cr({status:"closed",closeReason:e})))},Du=e=>{setTimeout((()=>kr({status:"opened",closeReason:null,walletInfo:e})))},Hu=e=>{setTimeout((()=>kr({status:"closed",closeReason:e})))},Vu=e=>{setTimeout((()=>Or(e)))},Ku=()=>{setTimeout((()=>Or(null)))},Fu=()=>Tr(),qu=()=>Ar(null),zu=(e,t)=>function(e,t,n,r={}){let o;return ft((r=>{o=r,t===document?e():wn(t,e(),t.firstChild?null:void 0,n)}),r.owner),()=>{o(),t.textContent=""}}((()=>qt(Wu,{tonConnectUI:t})),document.getElementById(e));class Zu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",br()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=br();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const e=(yield this.connector.getWallets()).find(Ce);return e?this.connectEmbeddedWallet(e):this.openWalletsModal()}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Bu(e)}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openWalletsModal(){return __async(this,null,(function*(){return _o()&&So(),ju(),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Gu{constructor(e){__publicField(this,"connector"),__publicField(this,"consumers",[]),this.connector=e.connector,mt((()=>{const e=Mr();this.consumers.forEach((t=>t(e)))}))}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}}class Yu{constructor(e){__publicField(this,"connector"),__publicField(this,"setConnectRequestParametersCallback"),__publicField(this,"consumers",[]),__publicField(this,"tracker"),__publicField(this,"state",_r()),this.connector=e.connector,this.tracker=e.tracker,this.setConnectRequestParametersCallback=e.setConnectRequestParametersCallback,mt((()=>{const e=_r();this.state=e,this.consumers.forEach((t=>t(e)))}))}open(e){return __async(this,null,(function*(){this.tracker.trackConnectionStarted();const t=Kl(yield this.connector.getWallets(),Dl.walletsListConfiguration),n=t.find(Ce);if(!!n)return this.connectEmbeddedWallet(n);const r=t.filter(_e).find((t=>Zl(t,e)));if(!!r)return this.openSingleWalletModal(r);const o=`Trying to open modal window with unknown wallet "${e}".`;throw this.tracker.trackConnectionError(o),new or(o)}))}close(e="action-cancelled"){"action-cancelled"===e&&this.tracker.trackConnectionError("Connection was cancelled"),Hu("action-cancelled")}onStateChange(e){return this.consumers.push(e),()=>{this.consumers=this.consumers.filter((t=>t!==e))}}connectEmbeddedWallet(e){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;"loading"===(null==n?void 0:n.state)?this.setConnectRequestParametersCallback(t):t(null==n?void 0:n.value)}openSingleWalletModal(e){return __async(this,null,(function*(){return _o()&&So(),Du(e),new Promise((e=>{const t=this.onStateChange((n=>{const{status:r}=n;"opened"===r&&(t(),e())}))}))}))}}class Qu{constructor(e){var t;__publicField(this,"eventPrefix","ton-connect-ui-"),__publicField(this,"tonConnectUiVersion"),__publicField(this,"tonConnectSdkVersion",null),__publicField(this,"eventDispatcher"),this.eventDispatcher=null!=(t=null==e?void 0:e.eventDispatcher)?t:new Ve,this.tonConnectUiVersion=e.tonConnectUiVersion,this.init().catch()}get version(){return Ae({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __async(this,null,(function*(){try{yield this.setRequestVersionHandler(),this.tonConnectSdkVersion=yield this.requestTonConnectSdkVersion()}catch(Ju){}}))}setRequestVersionHandler(){return __async(this,null,(function*(){yield this.eventDispatcher.addEventListener("ton-connect-ui-request-version",(()=>__async(this,null,(function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-ui-response-version",Le(this.tonConnectUiVersion))}))))}))}requestTonConnectSdkVersion(){return __async(this,null,(function*(){return new Promise(((e,t)=>__async(this,null,(function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-response-version",(t=>{e(t.detail.version)}),{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-request-version",{type:"request-version"})}catch(Ju){t(Ju)}}))))}))}dispatchUserActionEvent(e){var t;try{null==(t=this.eventDispatcher)||t.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch(Ju){}}trackConnectionStarted(...e){try{const t=Oe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionCompleted(...e){try{const t=Ne(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionError(...e){try{const t=Pe(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringStarted(...e){try{const t=$e(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringCompleted(...e){try{const t=Ie(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackConnectionRestoringError(...e){try{const t=Ue(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackDisconnection(...e){try{const t=He(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSentForSignature(...e){try{const t=je(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSigned(...e){try{const t=Be(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}trackTransactionSigningFailed(...e){try{const t=De(this.version,...e);this.dispatchUserActionEvent(t)}catch(Ju){}}}e.BadRequestError=B,e.BrowserEventDispatcher=Ve,e.FetchWalletsError=K,e.LocalstorageNotFoundError=V,e.ParseHexError=q,e.THEME=Ln,e.TonConnect=Fe,e.TonConnectError=N,e.TonConnectUI=class{constructor(e){if(__publicField(this,"walletInfoStorage",new mr),__publicField(this,"preferredWalletStorage",new vr),__publicField(this,"tracker"),__publicField(this,"walletInfo",null),__publicField(this,"systemThemeChangeUnsubscribe",null),__publicField(this,"actionsConfiguration"),__publicField(this,"walletsList"),__publicField(this,"connectRequestParametersCallback"),__publicField(this,"connector"),__publicField(this,"modal"),__publicField(this,"singleWalletModal"),__publicField(this,"transactionModal"),__publicField(this,"connectionRestored",Promise.resolve(!1)),e&&"connector"in e&&e.connector)this.connector=e.connector;else{if(!(e&&"manifestUrl"in e&&e.manifestUrl))throw new or("You have to specify a `manifestUrl` or a `connector` in the options.");this.connector=new Fe({manifestUrl:e.manifestUrl,eventDispatcher:null==e?void 0:e.eventDispatcher})}this.tracker=new Qu({eventDispatcher:null==e?void 0:e.eventDispatcher,tonConnectUiVersion:"2.0.9-beta.3"}),this.modal=new Zu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.singleWalletModal=new Yu({connector:this.connector,tracker:this.tracker,setConnectRequestParametersCallback:e=>{this.connectRequestParametersCallback=e}}),this.transactionModal=new Gu({connector:this.connector}),this.walletsList=this.getWallets(),this.walletsList.then((e=>{return ur((t=e.map((e=>e.imageUrl)),[...new Set(t)]));var t}));const t=this.normalizeWidgetRoot(null==e?void 0:e.widgetRootId);this.subscribeToWalletChange(),!1!==(null==e?void 0:e.restoreConnection)&&(this.connectionRestored=function(e){return __async(this,null,(function*(){return yield new Promise((e=>requestAnimationFrame(e))),e()}))}((()=>__async(this,null,(function*(){return this.tracker.trackConnectionRestoringStarted(),yield this.connector.restoreConnection(),this.connector.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):(this.tracker.trackConnectionRestoringError("Connection was not restored"),this.walletInfoStorage.removeWalletInfo()),this.connector.connected}))))),this.uiOptions=uo(e,{uiPreferences:{theme:"SYSTEM"}});const n=this.preferredWalletStorage.getPreferredWalletAppName();Hl({connector:this.connector,preferredWalletAppName:n}),zu(t,this)}static getWallets(){return Fe.getWallets()}get connected(){return this.connector.connected}get account(){return this.connector.account}get wallet(){return this.connector.wallet?__spreadValues(__spreadValues({},this.connector.wallet),this.walletInfo):null}set uiOptions(e){var t,n,r,o,i,s,a;this.checkButtonRootExist(e.buttonRootId),this.actionsConfiguration=e.actionsConfiguration,(null==(t=e.uiPreferences)?void 0:t.theme)?"SYSTEM"!==(null==(n=e.uiPreferences)?void 0:n.theme)?(null==(r=this.systemThemeChangeUnsubscribe)||r.call(this),wo(e.uiPreferences.theme,e.uiPreferences.colorsSet)):(wo(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?Ln.LIGHT:Ln.DARK,e.uiPreferences.colorsSet),this.systemThemeChangeUnsubscribe||(this.systemThemeChangeUnsubscribe=function(e){const t=t=>e(t.matches?Ln.DARK:Ln.LIGHT);return window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t),()=>window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",t)}(wo))):(null==(o=e.uiPreferences)?void 0:o.colorsSet)&&(s=e.uiPreferences.colorsSet,po[Ln.DARK]=uo(s[Ln.DARK],po[Ln.DARK]),po[Ln.LIGHT]=uo(s[Ln.LIGHT],po[Ln.LIGHT]),fo((e=>({colors:uo(po[e.theme],go[e.theme])})))),(null==(i=e.uiPreferences)?void 0:i.borderRadius)&&(a=e.uiPreferences.borderRadius,fo({borderRadius:a})),Hl((t=>{var n,r;const o=uo(__spreadValues(__spreadValues(__spreadValues(__spreadValues({},e.language&&{language:e.language}),!!(null==(n=e.actionsConfiguration)?void 0:n.returnStrategy)&&{returnStrategy:e.actionsConfiguration.returnStrategy}),!!(null==(r=e.actionsConfiguration)?void 0:r.twaReturnUrl)&&{twaReturnUrl:e.actionsConfiguration.twaReturnUrl}),!!e.walletsListConfiguration&&{walletsListConfiguration:e.walletsListConfiguration}),Hr(t));return void 0!==e.buttonRootId&&(o.buttonRootId=e.buttonRootId),void 0!==e.enableAndroidBackHandler&&(o.enableAndroidBackHandler=e.enableAndroidBackHandler),o}))}setConnectRequestParameters(e){var t;Hl({connectRequestParameters:e}),"ready"!==(null==e?void 0:e.state)&&e||null==(t=this.connectRequestParametersCallback)||t.call(this,null==e?void 0:e.value)}getWallets(){return __async(this,null,(function*(){return this.connector.getWallets()}))}onStatusChange(e,t){return this.connector.onStatusChange((t=>__async(this,null,(function*(){if(t){const n=yield this.getSelectedWalletInfo(t);e(__spreadValues(__spreadValues({},t),n||this.walletInfoStorage.getWalletInfo()))}else e(t)}))),t)}openModal(){return __async(this,null,(function*(){return this.modal.open()}))}closeModal(e){this.modal.close(e)}onModalStateChange(e){return this.modal.onStateChange(e)}get modalState(){return this.modal.state}openSingleWalletModal(e){return __async(this,null,(function*(){return this.singleWalletModal.open(e)}))}closeSingleWalletModal(e){this.singleWalletModal.close(e)}onSingleWalletModalStateChange(e){return this.singleWalletModal.onStateChange(e)}get singleWalletModalState(){return this.singleWalletModal.state}connectWallet(){return __async(this,null,(function*(){const e=(yield this.getWallets()).find(Ce);return e?yield this.connectEmbeddedWallet(e):yield this.connectExternalWallet()}))}disconnect(){return this.tracker.trackDisconnection(this.wallet,"dapp"),Ku(),qu(),this.walletInfoStorage.removeWalletInfo(),this.connector.disconnect()}sendTransaction(e,t){return __async(this,null,(function*(){if(this.tracker.trackTransactionSentForSignature(this.wallet,e),!this.connected)throw this.tracker.trackTransactionSigningFailed(this.wallet,e,"Wallet was not connected"),new or("Connect wallet to send a transaction.");_o()&&So();const{notifications:n,modals:r,returnStrategy:o,twaReturnUrl:i,skipRedirectToWallet:s}=this.getModalsAndNotificationsConfiguration(t);Vu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!1});const a=()=>{l.signal.aborted||(Vu({name:"confirm-transaction",showNotification:n.includes("before"),openModal:r.includes("before"),sent:!0}),this.walletInfo&&"universalLink"in this.walletInfo&&("universal-link"===this.walletInfo.openMethod||"custom-deeplink"===this.walletInfo.openMethod)&&(te(this.walletInfo.universalLink)?bc(this.walletInfo.universalLink,{returnStrategy:o,twaReturnUrl:i||Dl.twaReturnUrl,forceRedirect:!1}):Cc(this.walletInfo.universalLink,this.walletInfo.deepLink,{returnStrategy:o,forceRedirect:!1},(()=>{}))))},l=new AbortController,c=this.onTransactionModalStateChange((e=>{(null==e?void 0:e.openModal)||(c(),e||l.abort())}));try{const t=yield this.waitForSendTransaction({transaction:e,signal:l.signal},a);return this.tracker.trackTransactionSigned(this.wallet,e,t),Vu({name:"transaction-sent",showNotification:n.includes("success"),openModal:r.includes("success")}),t}catch(Ju){throw Vu({name:"transaction-canceled",showNotification:n.includes("error"),openModal:r.includes("error")}),Ju instanceof N?Ju:(console.error(Ju),new or("Unhandled error:"+Ju))}finally{c()}}))}connectEmbeddedWallet(e){return __async(this,null,(function*(){const t=t=>{Ar(e),this.connector.connect({jsBridgeKey:e.jsBridgeKey},t)},n=Dl.connectRequestParameters;return"loading"===(null==n?void 0:n.state)?this.connectRequestParametersCallback=t:t(null==n?void 0:n.value),yield this.waitForWalletConnection({ignoreErrors:!1})}))}connectExternalWallet(){return __async(this,null,(function*(){const e=new AbortController;ju();const t=this.onModalStateChange((n=>{const{status:r,closeReason:o}=n;"opened"!==r&&(t(),"action-cancelled"===o&&e.abort())}));return yield this.waitForWalletConnection({ignoreErrors:!0,signal:e.signal})}))}waitForWalletConnection(e){return __async(this,null,(function*(){return new Promise(((t,n)=>{this.tracker.trackConnectionStarted();const{ignoreErrors:r=!1,signal:o=null}=e;if(o&&o.aborted)return this.tracker.trackConnectionError("Connection was cancelled"),n(new or("Wallet was not connected"));const i=e=>__async(this,null,(function*(){if(e)this.tracker.trackConnectionCompleted(e),a(),t(e);else{if(this.tracker.trackConnectionError("Connection was cancelled"),r)return;a(),n(new or("Wallet was not connected"))}})),s=e=>{this.tracker.trackConnectionError(e.message),r||(a(),n(e))},a=this.onStatusChange((e=>i(e)),(e=>s(e)));o&&o.addEventListener("abort",(()=>{a(),n(new or("Wallet was not connected"))}),{once:!0})}))}))}waitForSendTransaction(e,t){return __async(this,null,(function*(){return new Promise(((n,r)=>{const{transaction:o,signal:i}=e;if(i.aborted)return this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new or("Transaction was not sent"));const s=e=>__async(this,null,(function*(){n(e)})),a=()=>{this.tracker.trackTransactionSigningFailed(this.wallet,o,"Transaction was cancelled"),r(new or("Transaction was not sent"))};i.addEventListener("abort",a,{once:!0}),this.connector.sendTransaction(o,{onRequestSent:t,signal:i}).then((e=>(i.removeEventListener("abort",a),s(e)))).catch((e=>(i.removeEventListener("abort",a),(e=>{r(e)})(e))))}))}))}onTransactionModalStateChange(e){return this.transactionModal.onStateChange(e)}subscribeToWalletChange(){this.connector.onStatusChange((e=>__async(this,null,(function*(){var t;e?(yield this.updateWalletInfo(e),this.setPreferredWalletAppName((null==(t=this.walletInfo)?void 0:t.appName)||e.device.appName)):this.walletInfoStorage.removeWalletInfo()}))))}setPreferredWalletAppName(e){this.preferredWalletStorage.setPreferredWalletAppName(e),Hl({preferredWalletAppName:e})}getSelectedWalletInfo(e){return __async(this,null,(function*(){let t,n=Fu();if(!n)return null;if("name"in n)t=n;else{const r=Kl(yield this.walletsList,Dl.walletsListConfiguration).find((t=>Zl(t,e.device.appName)));if(!r)throw new or(`Cannot find WalletInfo for the '${e.device.appName}' wallet`);t=__spreadValues(__spreadValues({},r),n)}return t}))}updateWalletInfo(e){return __async(this,null,(function*(){const t=yield this.getSelectedWalletInfo(e);if(t)return this.walletInfo=t,void this.walletInfoStorage.setWalletInfo(t);const n=this.walletInfoStorage.getWalletInfo();this.walletInfo=n||((yield this.walletsList).find((t=>Zl(t,e.device.appName)))||null)}))}normalizeWidgetRoot(e){if(!e||!document.getElementById(e)){e="tc-widget-root";const t=document.createElement("div");t.id=e,document.body.appendChild(t)}return e}checkButtonRootExist(e){if(null!=e&&!document.getElementById(e))throw new or(`${e} element not found in the document.`)}getModalsAndNotificationsConfiguration(e){var t,n,r,o,i,s;const a=["before","success","error"];let l=a;(null==(t=this.actionsConfiguration)?void 0:t.notifications)&&"all"!==(null==(n=this.actionsConfiguration)?void 0:n.notifications)&&(l=this.actionsConfiguration.notifications),(null==e?void 0:e.notifications)&&(l="all"===e.notifications?a:e.notifications);let c=["before"];(null==(r=this.actionsConfiguration)?void 0:r.modals)&&(c="all"===this.actionsConfiguration.modals?a:this.actionsConfiguration.modals),(null==e?void 0:e.modals)&&(c="all"===e.modals?a:e.modals);const u=(null==e?void 0:e.returnStrategy)||(null==(o=this.actionsConfiguration)?void 0:o.returnStrategy)||"back",d=(null==e?void 0:e.twaReturnUrl)||(null==(i=this.actionsConfiguration)?void 0:i.twaReturnUrl);let h=(null==e?void 0:e.skipRedirectToWallet)||(null==(s=this.actionsConfiguration)?void 0:s.skipRedirectToWallet)||"ios";return _o()&&(h="never"),{notifications:l,modals:c,returnStrategy:u,twaReturnUrl:d,skipRedirectToWallet:h}}},e.TonConnectUIError=or,e.UnknownAppError=D,e.UnknownError=z,e.UserRejectsError=j,e.WalletAlreadyConnectedError=U,e.WalletNotConnectedError=W,e.WalletNotInjectedError=H,e.WalletsListManager=Se,e.WrongAddressError=F,e.createConnectionCompletedEvent=Ne,e.createConnectionErrorEvent=Pe,e.createConnectionRestoringCompletedEvent=Ie,e.createConnectionRestoringErrorEvent=Ue,e.createConnectionRestoringStartedEvent=$e,e.createConnectionStartedEvent=Oe,e.createDisconnectionEvent=He,e.createRequestVersionEvent=Te,e.createResponseVersionEvent=Le,e.createTransactionSentForSignatureEvent=je,e.createTransactionSignedEvent=Be,e.createTransactionSigningFailedEvent=De,e.createVersionInfo=Ae,e.encodeTelegramUrlParameters=ne,e.isTelegramUrl=te,e.isWalletInfoCurrentlyEmbedded=Ce,e.isWalletInfoCurrentlyInjected=be,e.isWalletInfoInjectable=xe,e.isWalletInfoInjected=function(e){return"jsBridgeKey"in e},e.isWalletInfoRemote=_e,e.toUserFriendlyAddress=Ze,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
1028
1028
|
//# sourceMappingURL=tonconnect-ui.min.js.map
|