`),MyAccount.OnAccountSet.RemoveCallback(e))};MyAccount.OnAccountSet.AddCallback(e)})(),MyAccount.RetrieveSession=async e=>{setCookie("session_id",e),await MyAccount.OnReady,await async function(){if(getCookie("session_id")){let e=await _(getCookie("session_id"));if(!0===e.valid){let t=e.user_id;MyAccount.session_id=getCookie("session_id"),MyAccount.user_id=t,MyAccount.username=e.username,MyAccount.OnAccountSet.Invoke(MyAccount),await fetch("https://dapp.isotopic.io/home",{method:"GET",mode:"cors"}).then((e=>e.text())).then((n=>{document.getElementById("pageContent").innerHTML=n,$("#my-account-loading-svg").remove(),$("#profile-pic").attr("src","https://dapp.isotopic.io/api/v1/user/profile/pic/get?user_id="+t),M(),w(),setInterval(w,6e4),document.getElementById("username-field").innerHTML=e.username}))}else setCookie("session_id",null,null),setCookie("user_id",null,null),MyAccount.session_id=null,MyAccount.user_id=null,MyAccount.username=null,MyAccount.OnAccountSet.Invoke(MyAccount),await fetch("https://dapp.isotopic.io/login-form.html",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,a(),d(),u()}))}}()},window.addEventListener("hashchange",(async()=>{s()}),!1),getCookie("session_id")){let e=await _(getCookie("session_id"));if(!0===e.valid){let t=e.user_id;MyAccount.session_id=getCookie("session_id"),MyAccount.user_id=t,MyAccount.username=e.username,MyAccount.OnAccountSet.Invoke(MyAccount),fetch("https://dapp.isotopic.io/home",{method:"GET",mode:"cors"}).then((e=>e.text())).then((n=>{document.getElementById("pageContent").innerHTML=n,$("#my-account-loading-svg").remove(),$("#profile-pic").attr("src","https://dapp.isotopic.io/api/v1/user/profile/pic/get?user_id="+t),M(),w(),setInterval(w,6e4),document.getElementById("username-field").innerHTML=e.username}))}else setCookie("session_id",null,null),setCookie("user_id",null,null),MyAccount.session_id=null,MyAccount.user_id=null,MyAccount.username=null,MyAccount.OnAccountSet.Invoke(MyAccount),fetch("https://dapp.isotopic.io/login-form.html",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,a(),d(),u()}))}else fetch("https://dapp.isotopic.io/login-form.html",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,a(),d(),u()}));a(),d(),u();let c=!1;function a(){$("#username").on("keypress",(function(e){13==e.which&&$("#loginbtn").click()})),$("#password").on("keypress",(function(e){13==e.which&&$("#loginbtn").click()})),$("#loginbtn").click((()=>{if(c)return;c=!0;let e=document.getElementById("username").value,t=document.getElementById("password").value,n=navigator?.userAgent?.indexOf("Electron")>=0;fetch("https://dapp.isotopic.io/api/v1/user/login",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,expire:n?6048e5:null})}).then((e=>e.json())).then((t=>{"success"==t.result?(document.getElementById("pageContent").innerHTML=t,setCookie("session_id",t.session_id),setCookie("user_id",t.user_id),MyAccount.session_id=t.session_id,MyAccount.user_id=t.user_id,MyAccount.username=e,MyAccount.OnAccountSet.Invoke(MyAccount),fetch("https://dapp.isotopic.io/home",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,$("#profile-pic").attr("src","https://dapp.isotopic.io/api/v1/user/profile/pic/get?user_id="+getCookie("user_id")+"&refresh="+Date.now().toString()),c=!1,M(),document.getElementById("username-field").innerHTML=t.username}))):($("#login-error-field").text(t.error),c=!1)}))}))}let r=!1;let l=!1;function d(){$("#create-account-redirect").click((()=>{fetch("https://dapp.isotopic.io/signup",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,$("#createaccount-btn").click((()=>{if(!l){l=!0;var e=document.getElementById("username").value,t=document.getElementById("password").value,n=document.getElementById("email").value,o=!0,i=!0,s=!0;if($("#error-message").empty(),0===e.length||!e.match(/^[a-zA-Z0-9]{3,30}$/)){var c="Username is incorrect, use at least 3 characters and numbers.";o=!1,l=!1,$("#error-message").append(`\n
${c}
\n `)}0!==t.length&&t.match(/^.{5,64}$/)||(c="Password is incorrect, at least 5 characters needed.",i=!1,l=!1,$("#error-message").append(`\n
${c}
\n `)),0!==n.length&&n.match(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/)||(c="Email is incorrect.",s=!1,l=!1,$("#error-message").append(`\n
\n `)):(setCookie("session_id",e.session_id),setCookie("user_id",e.user_id),MyAccount.session_id=e.session_id,MyAccount.user_id=e.user_id,MyAccount.username=e.username,MyAccount.OnAccountSet.Invoke(MyAccount),ShowPopupModal("Please verify your account through the link we sent to your email address! You may need to check your spam folder."),fetch("https://dapp.isotopic.io/home",{method:"GET",mode:"cors"}).then((e=>e.text())).then((t=>{document.getElementById("pageContent").innerHTML=t,document.getElementById("username-field").innerHTML=e.username,l=!1,M()})))}))}})),$("#return-to-login").click((()=>{r||(r=!0,fetch("https://dapp.isotopic.io/login-form.html",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,r=!1,a(),d(),u()})))}))}))}))}function u(){$("#forgot-password").click((()=>{$("#pageContent").html('\n
\n
\n
Forgot Password
\n \n\n
\n \n
\n \n \n
\n
\n '),$("#send-email-button").click((()=>{fetch("https://dapp.isotopic.io/api/v1/user/password/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:$("#forgot-email").val()}),mode:"cors"}).catch((e=>{})),ShowPopupModal("Email sent. Check your inbox!"),$("#login-redirect").click()})),$("#login-redirect").click((()=>{fetch("https://dapp.isotopic.io/login-form.html",{method:"GET",mode:"cors"}).then((e=>e.text())).then((e=>{document.getElementById("pageContent").innerHTML=e,a(),d(),u()}))}))}))}let p=!1;let m=!1;function y(){$("#myaccount-wallets-btn").click((()=>{$("#myaccount-wallets-btn").removeClass("gray-bg"),$("#myaccount-developer-btn").addClass("gray-bg"),$("#myaccount-developer-assets-btn").css("display","none"),$("#myaccount-developer-games-btn").css("display","none"),e||(e=!0,t=!1,n=!1,fetch("https://dapp.isotopic.io/myaccount-wallets",{method:"GET",mode:"cors"}).then((e=>e.text())).then((async e=>{document.getElementById("myaccount-content").innerHTML=e;var t=getCookie("session_id");!function(e){$(".card-1"),$(".card-2"),$(".card-3");function t(e){$("#card-"+e+"-title").text("+"),$("#card-"+e+"-add-button").css({display:"inline"}),$("#card-"+e+"-remove-button").css({display:"none"})}function n(e,t,n){var o;$("#card-"+e+"-title").text(null==(o=t[n].address)?null:"0x..."+o.slice(o.length-4,o.length)),$("#card-"+e+"-add-button").css({display:"none"}),$("#card-"+e+"-remove-button").css({display:"inline"}),$("#card-"+e+"-wallet-address-field").text(t[n].address),$("#card-"+e+"-custodial").text(t[n].is_custodial?"(ISOTOPIC WALLET)":"")}let o=e.filter((e=>null==e.provider)),i=e.filter((e=>null!=e.provider))[0];function s(e,t){if($("#card-seq-add-button").off("click"),$("#sequence-wallet-myaccount").off("click"),$("#sequence-wallet-myaccount").off("mouseleave"),$("#sequence-wallet-myaccount").off("mouseenter"),MyAccount.SequenceWalletAddress=t,e){$("#card-seq-title").text("SEQUENCE (LINKED)"),$("#card-seq-add-button").html('Unlink ');let o=!1;$("#card-seq-add-button").click((async()=>{if(o)return;o=!0;let e=await E(MyAccount.session_id,t);"success"==e.result?(ShowPopupModal("Successfully unlinked Sequence."),s(!1)):ShowPopupModal(`Failed to unlink Sequence: ${e.error}`),o=!1}));let i=!1;$("#sequence-wallet-myaccount").click((async()=>{if(i)return;i=!0;let e=Web3Bundle.Sequence;await e.OnReady,null!=e.connectDetails&&1==e.connectDetails.connected?e.Wallet.openWallet():await e.ConnectAndAuthWallet(!0).catch((e=>{i=!1})),i=!1})),$("#sequence-wallet-myaccount").on("mouseenter",(()=>{$("#card-seq-title").text("OPEN SEQUENCE")})),$("#sequence-wallet-myaccount").on("mouseleave",(()=>{$("#card-seq-title").text("SEQUENCE (LINKED)")}))}else{$("#card-seq-add-button").text("Create / Link");let c=!1;async function n(){if(1==c)return;c=!0;let e=Web3Bundle.Sequence;await e.OnReady;let t=!1;if(ShowNotification("Sequence Wallet opened. Allow popups if you cannot see it.","sequence-opened",null,4e3),await e.ConnectAndAuthWallet().catch((e=>{t=!0})),t)c=!1;else if(ShowNotification("Linking Sequence Wallet to Isotopic...","seq-in-progress",null,4e3),1==e.connectDetails.connected){let t=await e.Wallet.getAddress();await C(MyAccount.session_id,t,"sequence",e.connectDetails.proof.proofString).then((e=>{"success"==e.result?(ShowPopupModal("Successfully linked Sequence!"),s(!0,t)):ShowPopupModal(`Error while linking wallet: ${e.error}`),c=!1})).catch((e=>{ShowPopupModal("Error while linking wallet: An unexpected error occured."),c=!1}))}else ShowPopupModal("Error while linking wallet: Authentication with Sequence Failed."),c=!1}$("#card-seq-add-button").click(n),$("#sequence-wallet-myaccount").click(n)}}s(null!=i,i?.address),0==o.length?(t(1),t(2),t(3)):1==o.length?(n(1,e,0),t(2),t(3)):2==o.length?(n(1,e,0),n(2,e,1),t(3)):3==o.length&&(n(1,e,0),n(2,e,1),n(3,e,2))}(await x(t)),function(){const e=async e=>{let t=getCookie("session_id"),n=await async function(){if(!ethereum)return null;let e=await ethereum.request({method:"eth_requestAccounts"}).catch((e=>null));return void 0===e[0]||0===e.length?null:e[0]}(),o=await C(t,n);if("success"==o.result){$("#wallets-error-field").text(""),$("#card-"+e+"-wallet-address-field").text(n);var i=null==n?null:"0x..."+n.slice(n.length-4,n.length);$("#card-"+e+"-title").text(i),$("#card-"+e+"-add-button").css({display:"none"}),$("#card-"+e+"-remove-button").css({display:"inline"})}else $("#wallets-error-field").text(o.error)};$("#card-1-add-button").click((()=>{e(1)})),$("#card-2-add-button").click((()=>{e(2)})),$("#card-3-add-button").click((()=>{e(3)})),$("#card-1-remove-button").click((()=>{t(1)})),$("#card-2-remove-button").click((()=>{t(2)})),$("#card-3-remove-button").click((()=>{t(3)})),$("#sequence-wallet-myaccount").click((()=>{})),$("#card-seq-add-button").click((()=>{}));const t=async e=>{let t=getCookie("session_id"),n=$("#card-"+e+"-wallet-address-field").text(),o=await E(t,n);"success"==o.result?($("#wallets-error-field").text(""),$("#card-"+e+"-wallet-address-field").text(""),$("#card-"+e+"-title").text("+"),$("#card-"+e+"-add-button").css({display:"inline"}),$("#card-"+e+"-remove-button").css({display:"none"})):$("#wallets-error-field").text(o.error)}}()})))}))}function h(){const o=async()=>{if($("#myaccount-wallets-btn").addClass("gray-bg"),$("#myaccount-developer-btn").removeClass("gray-bg"),$("#myaccount-developer-assets-btn").css("display","unset"),$("#myaccount-developer-games-btn").css("display","unset"),!t){$("#myaccount-developer-assets-btn").addClass("gray-bg"),$("#myaccount-developer-games-btn").removeClass("gray-bg"),$("#myaccount-developer-assets-btn").click((()=>{$("#myaccount-developer-assets-btn").removeClass("gray-bg"),$("#myaccount-developer-games-btn").addClass("gray-bg"),$("#myaccount-developer-games-btn").off("click"),$("#myaccount-developer-games-btn").click((()=>{t=!1,o()})),$("#myaccount-content").html('\n
My Assets
\n \n
\n
\n \n
\n
\n
Add New
\n
\n
\n ');var e=getCookie("session_id");let n=$("#account-developer-assets");(function(e){return new Promise(((t,n)=>{fetch(`https://dapp.isotopic.io/api/v1/assets/user/assets?user=${e}`,{method:"GET",mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))})(e).then((e=>{e.forEach((e=>{$(g(e.id,e.title,"Edit")).appendTo(n)}))}));const i=()=>{$("#add-asset-button").unbind("click"),$("#add-asset-button").css("visibility","hidden"),function(e){return new Promise(((t,n)=>{fetch("https://dapp.isotopic.io/api/v1/assets/page/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e}),mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))}(e).then((e=>{$("#add-asset-button").css("visibility",""),$("#add-asset-button").click(i),"success"===e.result?$(g(e.id,e.title,"Edit")).appendTo(n):ShowPopupModal(e.error??"An error occured.")}))};$("#add-asset-button").click(i)})),t=!0,e=!1,n=!1,$("#myaccount-content").html('\n
My Games
\n \n
\n
\n \n
\n
\n
Add New
\n
\n
\n ');var i=getCookie("session_id");let s=$("#account-developer-games");(function(e){return new Promise(((t,n)=>{fetch(`https://dapp.isotopic.io/api/v1/store/user/apps?user=${e}`,{method:"GET",mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))})(i).then((e=>{e.forEach((e=>{$(f(e.id,e.title,"Edit")).appendTo(s)}))}));const c=()=>{$("#add-game-button").unbind("click"),$("#add-game-button").css("visibility","hidden"),function(e){return new Promise(((t,n)=>{fetch("https://dapp.isotopic.io/api/v1/store/page/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e}),mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))}(i).then((e=>{$("#add-game-button").css("visibility",""),$("#add-game-button").click(c),"success"===e.result?$(f(e.id,e.title,"Edit")).appendTo(s):ShowPopupModal(e.error??"An error occured.")}))};$("#add-game-button").click(c)}};$("#myaccount-developer-btn").click(o)}const f=(e,t,n)=>`\n \n
\n ');let o=getCookie("session_id"),i=$("#notifications");S(o).then((e=>{e=e.sort(((e,t)=>e.is_read>t.is_read?1:-1)),i.empty(),e.forEach((e=>{let t=$(v(e.notification_id,e.data.url,e.data.title,e.data.imageURL,e.is_read));t.find(".notification-content").text(e.data.content),t.appendTo(i)})),$(".notification-item").click((async function(){let e=$(this).attr("notifid");A($(this).find(".notification-icon-img").attr("src"),$(this).find(".notification-title").text(),$(this).find(".notification-content").text(),$(this).attr("href")),T(o,e).then((e=>{w()}))}))}))}}))}(),$("#change-profile-pic").click((()=>{$("input[id='profile_pic_form_image']").click()})),$(".file-upload").on("change",(function(){$("#my_submit_button").click()})),$("#my_submit_button").click((()=>{$("#profile_pic_form_session_id").attr("value",getCookie("session_id")),$("#profile_pic_form")[0].submit(),$("#profile-pic").attr("src",$("#profile_pic_form_image").val())})),$("#profile_pic_form").on("submit",(function(){let e=new FileReader;return e.onload=e=>{$("#profile-pic").attr("src",e.target.result)},e.readAsDataURL($("#profile_pic_form_image")[0].files[0]),!1}))}function k(){return""==getCookie("rid")?null:getCookie("rid")}function _(e){return new Promise(((t,n)=>{fetch("https://dapp.isotopic.io/api/v1/user/session/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e}),mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))}function x(e){return new Promise(((t,n)=>{fetch("https://dapp.isotopic.io/api/v1/wallet/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e}),mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))}function C(e,t,n,o){return new Promise(((i,s)=>{fetch("https://dapp.isotopic.io/api/v1/wallet/link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e,wallet:t,provider:n,proof:o,proof:o}),mode:"cors"}).then((e=>e.json())).then((e=>{i(e),MyAccount.OnWalletsChanged.Invoke()}))}))}function E(e,t){return new Promise(((n,o)=>{fetch("https://dapp.isotopic.io/api/v1/wallet/unlink",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e,wallet:t}),mode:"cors"}).then((e=>e.json())).then((e=>{n(e)}))}))}function S(e){return new Promise(((t,n)=>{fetch("https://dapp.isotopic.io/api/v1/notifications/get",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e}),mode:"cors"}).then((e=>e.json())).then((e=>{t(e)}))}))}function T(e,t){return new Promise(((n,o)=>{fetch("https://dapp.isotopic.io/api/v1/notifications/set/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e,id:t,read:!0}),mode:"cors"}).then((e=>e.json())).then((e=>{n(e)}))}))}MyAccount.OpenWallets=()=>!!(MyAccount.IsLoggedIn&&MyAccount.IsReady&&MyAccount.OpenMyAccount())&&($("#myaccount-wallets-btn").click(),!0),MyAccount.OpenDev=()=>!!(MyAccount.IsLoggedIn&&MyAccount.IsReady&&MyAccount.OpenMyAccount())&&($("#myaccount-developer-btn").click(),!0),MyAccount.GetLinkedWallets=()=>x(MyAccount.session_id),MyAccount.OnAccountSet.AddCallback((async e=>{if(0==MyAccount.IsLoggedIn)return;if(100*Math.random()>30)return;let t=await new Promise(((e,t)=>{fetch("https://dapp.isotopic.io/api/v1/survey/questions",{method:"GET",mode:"cors"}).then((e=>e.json())).then((t=>{e(t)}))}));ShowNotification('\n
> Hello! Quick question, are you a Game Developer?
\n
\n
>
\n
[YES]
\n
/
\n
[NO]
\n
\n \n ',"random-survey-1"),$("#survey-1-no").click((()=>{RemoveNotification("random-survey-1"),ShowNotification("> Thanks for your answer! Your feedback lets us become better!","random-survey-no",null,3500)})),$("#survey-1-yes").click((()=>{RemoveNotification("random-survey-1");let e=t.questions[Math.floor(Math.random()*t.questions.length)];ShowNotification(`\n
> Please rate the statement below on how much you agree with it.
\n
> Q: "${e.question}"
\n
> Click below to answer:
\n
> [1] Strongly Disagree
\n
> [2] Disagree
\n
> [3] Neither Agree nor Disagree
\n
> [4] Agree
\n
> [5] Strongly Agree
\n
> [-] Not Sure
\n \n `,"random-survey-1"),$(".random-survey-answer").click((function(){let t=parseInt($(this).attr("answer"));RemoveNotification("random-survey-1"),ShowNotification("> Thanks for your answer! Your feedback lets us become better!","random-survey-no",null,3500),function(e,t){new Promise(((n,o)=>{fetch("https://dapp.isotopic.io/api/v1/survey/add-entry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:MyAccount.session_id,question_id:e,answer:t}),mode:"cors"}).then((e=>e.json())).then((e=>{n(e)}))}))}(e.id,t)}))}))})),MyAccount.OnMyAccountReady.Invoke(MyAccount),myAccountReadyRes(MyAccount),MyAccount.IsReady=!0,s()}))};let accountHandlerJqueryInterval=setInterval((()=>{"function"==typeof $&&(setDocumentReadyMyAccountCallback(),clearInterval(accountHandlerJqueryInterval))}),500);