-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload-game-ff6c26a637.min.js
More file actions
1 lines (1 loc) · 25.2 KB
/
load-game-ff6c26a637.min.js
File metadata and controls
1 lines (1 loc) · 25.2 KB
1
var SW=SW||{};SW.Load={},SW.Errors={};var settings={store:window.sessionStorage};const ENVIRONMENTS={PRODUCTION:"production",STAGING:"staging",DEVELOPMENT:"dev",LOCAL:"local"};var prodigyWeb={};SW.Load.ERROR_TITLE_OLD_DEVICE="Warning!",SW.Load.ERROR_DESCRIPTION_OLD_DEVICE='You are using a device that does not have WebGL enabled.<br><br>You will need this to play Prodigy Math Game! <br><br>Please <a id="openfaq" href="#">read our FAQ</a> with a Parent or Guardian <br id="mobile-inline">for more information.',SW.Load.WEBGL_FAQ_URL="www.prodigygame.com/main-en/our-online-access-is-changing";var loadingText=["Feeding pets","Studying spells","Delivering mail","Counting coins","Rearranging furniture","Solving for x","Planting grass","Burying fossils","Darkening the tower","Stocking shops","Dirtying socks","Cutting pizza","Carving wands","Sewing outfits","Petting buddies","Gathering clouds","Heating lava","Raking sand","Balancing equations","Mixing fractions","Carrying the one","Picking apples","Lighting lanterns","Going on tangents","Pulling levers","Planting beanstalks","Turning on weather machines","Waking Floatlings","Sharpening pencils","Memorizing times tables","Brewing potions","Morphing marbles","Getting lost in archives","Preparing questions","Warming up dance moves","Lighting fireworks","Sweeping confetti","Packing snowballs","Baking cakes","Chasing waterfalls","Hiding secrets","Rehearsing lines","Counting vertices","Comparing sizes"],unusedText=[],cycleTextTimeout=null,LEGACY_ASSET_MAPPINGS="legacy-asset-mappings.json",LEGACY_PREFAB_MAPPINGS="legacy-prefab-mappings.json",LEGACY_DUPLICATE_ASSET_MAPPINGS="legacy-duplicate-asset-mappings.json";SW.Load.bgPath="https://cdn.prodigygame.com/game/assets/v1_cache/single-images/login-bg-13/1/login-bg-13.png",SW.Load.bgLoaded=!1,SW.Load.bgShowing=!1,SW.Load.RETRY_WAIT_MS=1e3,SW.Load.RETRY_ATTEMPTS_MAX=3,SW.Load.browserName=null,SW.Load.env=null,SW.Load.devicePlatform=null,SW.Load.DISPLAY_HIDE="none",SW.Load.DISPLAY_SHOW="",SW.Load.DIV_GAME_LOADING_CONTAINER="game-loading-container-div",SW.Load.DIV_ERROR="error-div",SW.Load.DIV_LOADING="loading-div",SW.Load.DIV_SPLASH_IMAGE="splash-image",SW.Load.CSS_ED_PROGRESS_BAR=".ed-progress-bar",SW.Load.STORAGE_START_EVENT_TS="startEventTimestamp",SW.Load.STORAGE_EVENT_DATA="eventData",SW.Load.STORAGE_DEVICE_INFO="device-information",SW.Load.ERROR_TITLE_DEFAULT="Error Code",SW.Load.ERROR_DESCRIPTION_DEFAULT="Oops something went wrong!</br>Try logging in again or come back later.",SW.Load.ERROR_TITLE_CLOCK_SKEW="Clock Error",SW.Load.ERROR_DESCRIPTION_CLOCK_SKEW="Ensure that the clock on your device is the</br>correct time and then try logging in again.",SW.Load.SENTRY_URL="https://a84188f8494e47ea9adc6469ec4f4deb@sentry.io/1217080",SW.Load.SENTRY_SAMPLE_RATE_PROD=.01,SW.Load.SENTRY_SAMPLE_RATE_STAGING=.01,SW.Load.SENTRY_SAMPLE_RATE_DEFAULT=0,SW.Errors.ERROR_CODE_GAME_STATUS=10,SW.Errors.ERROR_CODE_GAME_MAINTENANCE=12,SW.Errors.ERROR_CODE_OIDC_REDIRECT_CALLBACK=20,SW.Errors.ERROR_CODE_OIDC_REDIRECT_SIGNIN=30,SW.Errors.ERROR_CODE_LOGIN_GAME_AUTH_API=36,SW.Errors.ERROR_CODE_LOADER_GAME_MAINTENANCE=40,SW.Errors.ERROR_CODE_NO_USER=48,SW.Errors.ERROR_CODE_LOAD_GAME_BUNDLES=50,SW.Errors.ERROR_CODE_OIDC_SIGNIN=60,SW.Errors.ERROR_CODE_EDUCATION_STATUS=70,SW.Errors.ERROR_CODE_CHARACTER=72,SW.Errors.ERROR_CODE_ASSET_MAPPINGS=80,SW.Errors.ERROR_CODE_EDUCATION_API=84,SW.Errors.ERROR_CODE_PREFAB_MAPPINGS=90,SW.Errors.ERROR_CODE_QI=96,SW.Errors.ERROR_CODE_MENU_ASSETS=108,SW.Errors.ERROR_CODE_SECURE_CHARACTER=132,SW.Errors.ERROR_CODE_EXPERIMENT_PROVIDER=144,SW.Load.pendingError=!1,SW.Load.pendingErrorTitle,SW.Load.pendingErrorDesc,SW.Load.pendingErrorID=0,SW.Load.init=function(){var e=SW.Storage.get(SW.Load.STORAGE_EVENT_DATA);e?window.eventData=JSON.parse(e):console.log("Warning: eventData not found."),SW.Load.sentryInit(window.eventData),SW.Load.displayVersion(),window.eventData.trackingCookie=SW.Load.getTrackingCookie(),SW.Load.isAutoLogin()||SW.Load.launcher().then((()=>console.log("Loading credentials"))).catch((()=>{console.log("Check for user failed. Signing redirect"),SW.Load.checkRedirect("checkForUser",SW.Errors.ERROR_CODE_OIDC_REDIRECT_SIGNIN)}));var o=window.location.href.indexOf("?"),n="";if(o>=0){var t=window.location.href.indexOf("#");n=t>=0?window.location.href.substring(o,t):window.location.href.substring(o)}var r=prodigyUrlPrefix+(prodigyUrlPrefix.endsWith("/")?"":"/")+n;history.replaceState({},"Prodigy Game",r),SW.Load.sendLoadStart(),SW.Load.sendLoginEnd(),SW.Load.getSplashImage()},SW.Load.sendLoadStart=function(){SW.Load.setupEventParams();const e=`${SW.Load.getServiceURL()}events-api/v3/anonymous-events`,o={renderType:SW.Device.isWebGLSupported()?"webGL":"canvas"};window.loadStartTime=Date.now(),SW.Load.sendV3Event(e,{type:"login_screen_funnel",name:"load_start",timeDelta:0},o)},SW.Load.sendLoginEnd=function(){const e=`${SW.Load.getServiceURL()}events-api/v3/anonymous-events`,o=SW.Storage.get(SW.Load.STORAGE_START_EVENT_TS),n={type:"login_time_funnel",name:"load_end",timeDelta:Date.now()-o};SW.Load.sendV3Event(e,n)},SW.Load.getUrlVars=function(){var e=decodeURIComponent(window.location.href),o={};e.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(e,n,t){o[n]=t.replace(/\+/g," ")}));return o},SW.Load.getUrlVar=function(e){var o=SW.Load.getUrlVars();for(var n in o)if(n==e)return o[n]},SW.Load.getWebURL=function(){return prodigyWebUrl},SW.Load._request=function(e,o,n,t,r,a,i,s,d){void 0===r&&(r=SW.Load.RETRY_ATTEMPTS_MAX),a||(a="json"),i||(i="GET"),s||(s=!1);const c=new XMLHttpRequest;c.onreadystatechange=function(){if(c.readyState===XMLHttpRequest.DONE)if(200===this.status){var d=s?c.response:c.response.data;o&&o(d)}else r>0?(r--,window.setTimeout((()=>{SW.Load._request(e,o,n,t,r,a,i,s)}),SW.Load.RETRY_WAIT_MS*(SW.Load.RETRY_ATTEMPTS_MAX-r))):(console.log("_request failed"),SW.Load.setErrorScreen(`${n}: Too many requests. Gave up. Http status ${this.status}`,void 0,void 0,t))},c.responseType=a,c.open(i,e,!0),d&&(c.withCredentials=!0),c.send("")},SW.Load.getEducationStatus=function(){const e=`${SW.Load.getEducationFrontendAssetsURL()}education-api/v1/frontend-paths`;SW.Load._request(e,(function(e){var o,n,t=e;"iOS"!==SW.Device.getOS()&&"Android"!==SW.Device.getOS()&&!SW.Device.isNativeApp()||SW.Device.isTablet()?(o=_.find(t,{id:"question-renderer"}).path,n=_.find(t,{id:"desktop-question-interface"}).path):(o=_.find(t,{id:"mobile-question-renderer"}).path,n=_.find(t,{id:"mobile-question-interface"}).path),window.questionRendererURL=o,window.questionInterfaceURL=n}),"Education Status",SW.Errors.ERROR_CODE_EDUCATION_STATUS,void 0,void 0,void 0,void 0,!0)},SW.Load.loadAssetsMappingJSON=function(){SW.Load._request(window.legacyAssetMappingsURL,(function(e){window.legacyAssetMappings=e}),LEGACY_ASSET_MAPPINGS,SW.Errors.ERROR_CODE_ASSET_MAPPINGS,void 0,void 0,void 0,!0)},SW.Load.loadDuplicateAssetsMappingJSON=function(){SW.Load._request(window.legacyDuplicateAssetMappingsURL,(function(e){window.legacyDuplicateAssetMappings=e}),LEGACY_DUPLICATE_ASSET_MAPPINGS,SW.Errors.ERROR_CODE_ASSET_MAPPINGS,void 0,void 0,void 0,!0)},SW.Load.loadPrefabMappingJSON=function(){SW.Load._request(window.legacyPrefabMappingsURL,(function(e){window.legacyPrefabMappings=e}),LEGACY_PREFAB_MAPPINGS,SW.Errors.ERROR_CODE_PREFAB_MAPPINGS,void 0,void 0,void 0,!0)},SW.Load.generateEventHandler=function(e,o){const n=t=>{let r={};const a=typeof t.data;if("object"===a)r=t.data;else if("string"===a)try{r=JSON.parse(t.data)}catch(i){console.error(`Could not parse JSON: ${t.data}`)}"object"==typeof r&&r.type===e&&(window.removeEventListener("message",n),o(r.success))};return n},SW.Load.isMinimumIapVersion=function(){const e=SW.Device.getMobileVersion();if(e.length<1)return!1;const o=e.indexOf(".");if(o<1)return!1;const n=e.substring(0,o),t=Number.parseInt(n);return!isNaN(t)&&t>=SW.IAP.MINIMUM_IAP_MOBILE_VERSION},SW.Load.loadGame=function(){window.onload=function(){SW.Load.checkPendingSplashScreen(),SW.Load.checkPendingErrorScreen(),document.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),prodigyWeb.membershipFlow={$el:$("#membership-flow"),$game:$("#game-wrapper"),student:{name:void 0,userID:void 0},closeCallback:void 0,isNativeIosApp:!1,open:function(e,o,n,t,r,a,i,s,d,c,S){const l=SW.Load.isMinimumIapVersion();let u;this.isNativeIosApp=SW.Device.isNativeIosApp()&&l,u=this.isNativeIosApp?SW.Load.generateEventHandler("parental-gate-closed",(e=>{$("#parental-gate-container").hide(),e?this.performIAPFlow():this.close(!1)})):SW.Load.generateEventHandler("membership-iframe-closed",(e=>this.close(e))),window.addEventListener("message",u);const g=c?"upgrade":"game",p=S||window.sessionStorage.getItem("identityToken"),L=SW.Load.getWebURL(),E=new Headers;return E.append("Content-Type","application/json"),E.append("Authorization",`Bearer ${p}`),fetch(`${L}Memberships/api/game-uuid/`,{credentials:"include",method:"POST",headers:E,redirect:"follow"}).then((e=>e.json())).then((({uuid:e})=>`${L}Memberships/math/${g}/?game=1&game-uuid=${e}&tag=${t}&funnelName=${r}&isPlayingFromHome=${a}&metaData=${i}&utm_source=${r}&utm_medium=game&utm_campaign=${d}`)).then((e=>{const o=$(`<iframe src="${e}">`);this.isNativeIosApp?($("#iap-spinner").show(),$("#parental-gate-container").show()):this.$el.show().append(o),this.$game.hide()})),this.student.name=e,this.student.userID=o,this.closeCallback=n,this.isNativeIosApp?"iOS-IAP":"MLP"},performIAPFlow:function(){SW.IAP.purchaseItemAsync(SW.IAP.productId).catch((e=>{console.error(`purchase call failed: ${JSON.stringify(e)}`),this.close(!1)}))},close:function(e){this.isNativeIosApp?($("#iap-spinner").hide(),$("#eml-form-container").hide()):this.$el.hide().html(""),this.$game.show();const o=document.getElementsByTagName("canvas")[0];o.style.width=`${o.width}px`,o.style.height=`${o.height}px`,window.dispatchEvent(new Event("resize")),window.postMessage(JSON.stringify({name:"membership-flow-closed",success:e}),"*"),_.isUndefined(this.closeCallback)||this.closeCallback(e)}}},SW.Load.cycleLoadingText()},SW.Load.getDeviceInformationFromAPI=function(){const e=SW.Storage.get(SW.Load.STORAGE_DEVICE_INFO);if(e)return void(window.deviceInformation=e);const o=new XMLHttpRequest;var n=SW.Load.getServiceURL()+"device-detect-api/v1/information?";n=n+"user_agent="+navigator.userAgent,"undefined"!=typeof DeviceAtlas&&(n=n+"&properties="+encodeURIComponent(DeviceAtlas.getPropertiesAsString())),o.onreadystatechange=function(){if(o.readyState===XMLHttpRequest.DONE&&200===this.status){const e=o.response;e&&e.model&&(SW.Storage.set(SW.Load.STORAGE_DEVICE_INFO,o.response),window.deviceInformation=e)}},o.responseType="json",o.open("GET",n,!0),o.send("")},SW.Load.setLoadingVisible=function(e){SW.Load.setDivDisplay(SW.Load.DIV_GAME_LOADING_CONTAINER,e)},SW.Load.cycleLoadingText=function(){var e=3500;if(0===unusedText.length)unusedText=[...loadingText],document.getElementById("loading-text").innerHTML="Loading game",e=1e3;else{var o=Math.floor(Math.random()*unusedText.length),n=unusedText[o];unusedText.splice(o,1),$(".game-loading__font").fadeOut(500,(()=>{$(".game-loading__font").fadeIn(500),document.getElementById("loading-text").innerHTML=n}))}window.clearTimeout(cycleTextTimeout),cycleTextTimeout=window.setTimeout(SW.Load.cycleLoadingText,e)},SW.Load.getSplashImage=function(){var e=new Image;return e.onload=function(){SW.Load.bgLoaded=!0,SW.Load.showSplashScreen()},e.src=SW.Load.bgPath,e},SW.Load.showSplashScreen=function(){var e=document.getElementById(SW.Load.DIV_SPLASH_IMAGE);if(e){var o=e.style;SW.Load.isErrorScreen()||(o.display=""),o.backgroundImage=`url(${SW.Load.bgPath})`,SW.Load.bgShowing=!0}else console.log("Warning: Splash screen div not found")},SW.Load.checkPendingSplashScreen=function(){return!(SW.Load.bgShowing||!SW.Load.bgLoaded)&&(SW.Load.showSplashScreen(),!0)},SW.Load.getTrackingCookie=function(){return SW.Cookie.getTrackingCookie()},SW.Load.checkRedirect=function(e,o){const n=`${e}`;-1!==n.indexOf("exp is in the past")||-1!==n.indexOf("iat is in the future")?SW.Load.setErrorScreen(`Clockskew: ${e}`,SW.Load.ERROR_TITLE_CLOCK_SKEW,SW.Load.ERROR_DESCRIPTION_CLOCK_SKEW,o):SW.Cookie.getRedirectCookie()?(SW.Load.setErrorScreen(`User signin redirect failed: ${e}`,void 0,void 0,o),SW.Cookie.clearRedirectCookie()):(SW.Cookie.setRedirectCookie(),SW.Load.redirectToLauncher())},SW.Load.launcher=async()=>{SW.Load.userInfo=()=>{const e=JSON.stringify({accessToken:"",uuid:"",email:"",name:"",sid:"",identity_provider:"",premises:""});return SW.Load.userInfo.value=e,e}},SW.Load.updateProgressBar=function(e){document.querySelector(SW.Load.CSS_ED_PROGRESS_BAR).style.width=`${e}%`},SW.Load.loadFonts=function(){WebFont.load({custom:{families:["Fredoka One","Luckiest Guy","Paytone One","ABeeZee"]}})},SW.Load.loadSemaphore=1,SW.Load.decrementLoadSemaphore=function(){--SW.Load.loadSemaphore<=0&&SW.Load.onGameLoad()},SW.Load.onGameLoad=function(){if(window.gameApiStatusData.maintenance)SW.Load.setErrorScreen(null,"Maintenance",window.gameApiStatusData.maintenanceMessage,SW.Errors.ERROR_CODE_LOADER_GAME_MAINTENANCE);else{window.updateGameLoaderProgress=SW.Load.updateProgressBar,window.gameLoaderLogout=SW.Load.logout;var e=document.createElement("script");e.type="text/javascript",e.src="https://apis.google.com/js/platform.js?onload=onGooglePlatformLoad",e.async=!0,document.head.appendChild(e),SW.Load={...SW.Load,...SW.LoadIdentity},Boot.init(),SW.Load.setLoadingVisible(!0),window.hideGameLoader=function(){window.prodigyLoadComplete?(window.prodigyLoaderHidden=!0,SW.Load.setLoadingVisible(!1)):window.prodigyLoadComplete=!0},_.delay((function(){window.hideGameLoader()}),1e3)}},SW.IAP={},SW.IAP.DEFAULT_PURCHASE_ITEM="prodigy_math_yearly_membership",SW.IAP.RECEIPT_VERIFICATION_MUTATION="mutation PurchaseInApp($receipt: String!) { purchaseInApp(input: { appleReceipt: $receipt }) { membershipId } }",SW.IAP.MINIMUM_IAP_MOBILE_VERSION=4,SW.IAP.isInit=!1,SW.IAP.userId=null,SW.IAP.authToken=null,SW.IAP.membershipId=null,SW.IAP.messageId=0,SW.IAP.callbacksById={},SW.IAP.productId=null,SW.IAP.purchaseCallback=e=>{console.error("Got an unhandled IAP purchase callback: ",e)},SW.IAP.performIAPCall=function(e,o){if(!SW.IAP.isInit)return;const n={payload:e};if(o){const e=SW.IAP.messageId;SW.IAP.messageId+=1,SW.IAP.callbacksById[e]=o,n.iapResponseId=e}setTimeout((()=>{window.postMessage(JSON.stringify({type:"CALL_IAP",payload:n}),"*")}),100)},SW.IAP.iapMessageListener=function(e){let o;try{o=JSON.parse(e)}catch(t){return void console.error(t)}const n=o.category;if("general"===n){const e=o.iapResponseId;if("number"==typeof e){const n=SW.IAP.callbacksById[e];delete SW.IAP.callbacksById[e],n(o.payload)}}else"purchaseListener"===n?SW.IAP.purchaseCallback(o.payload):console.error(`Unknown IAP message category: "${n}"`)},SW.IAP.verifyReceipt=function(e){return SW.IAP.sendGQLRequest(SW.IAP.RECEIPT_VERIFICATION_MUTATION,{receipt:e.transactionReceipt}).then((e=>{if(e&&e.purchaseInApp&&e.purchaseInApp.membershipId){const o=e.purchaseInApp.membershipId;SW.IAP.membershipId=o}})).catch((e=>{console.error(e)})).then((()=>SW.IAP.finishTransactionAsync(e,!1)))},SW.IAP.handleBadPurchaseResult=function(e){const o=e.responseCode;return window.prodigyWeb.membershipFlow.close(!1),1===o?Promise.resolve():2===o?(console.error("Purchasing error"),Promise.reject("purchasing error")):3===o?(console.error("Purchase was deferred"),Promise.reject("purchase deferred")):(console.error(`Unknown purchase error: ${o}`),Promise.reject(`Unknown purchase error: ${o}`))},SW.IAP.initIAP=function(e,o,n){if(SW.IAP.isInit)return Promise.resolve();if(!SW.Device.isNativeIosApp()||!SW.Load.isMinimumIapVersion())return Promise.resolve();SW.IAP.userId=e,SW.IAP.authToken=o,window.iapMessageListener=SW.IAP.iapMessageListener,SW.IAP.isInit=!0;const t=SW.Utility.getUrlVar("mobileProductOverride")||n||SW.IAP.DEFAULT_PURCHASE_ITEM;return SW.IAP.connectAsync().then((()=>SW.IAP.getProductsAsync([t]))).then((e=>{SW.IAP.productId=e[0].productId,SW.IAP.setPurchaseListener((e=>{if(e.responseCode>0)return SW.IAP.handleBadPurchaseResult(e);let o=!1;const n=[];for(let t=0;t<e.results.length;t+=1){const r=e.results[t];void 0===r.description&&(_.isString(r.transactionReceipt)?(o=!0,n.push(SW.IAP.verifyReceipt(r))):n.push(SW.IAP.finishTransactionAsync(r,!1)))}return Promise.allSettled(n).then((e=>{if(o&&e.length>0&&_.every(e,"value")){const e=SW.Load.generateEventHandler("membership-iframe-closed",(e=>window.prodigyWeb.membershipFlow.close(e)));window.addEventListener("message",e),$("#eml-form-container").show(),$("#game-wrapper").hide()}else window.prodigyWeb.membershipFlow.close(!0)})).catch((e=>{window.alert(`Receipt verification failed: ${e}`)}))}))}))},SW.IAP.connectAsync=function(){return new Promise(((e,o)=>{SW.IAP.performIAPCall({method:"connectAsync"},(n=>{n.result?e(!0):o(n.err)}))}))},SW.IAP.disconnectAsync=function(){return new Promise(((e,o)=>{SW.IAP.performIAPCall({method:"disconnectAsync"},(n=>{n.result?e(!0):o(n.err)}))}))},SW.IAP.getProductsAsync=function(e){return new Promise(((o,n)=>{SW.IAP.performIAPCall({method:"getProductsAsync",data:e},(e=>{e.result?o(e.itemDetails):n(e.err)}))}))},SW.IAP.purchaseItemAsync=function(e){return new Promise(((o,n)=>{SW.IAP.performIAPCall({method:"purchaseItemAsync",data:e},(e=>{e.result?o(!0):n(e.err)}))}))},SW.IAP.finishTransactionAsync=function(e,o){return new Promise(((n,t)=>{SW.IAP.performIAPCall({method:"finishTransactionAsync",data:{purchase:e,consumeItem:o}},(e=>{e.result?n(!0):(console.error(`Transaction finished with error: ${JSON.stringify(e)}`),t(e.err))}))}))},SW.IAP.getPurchaseHistoryAsync=function(e){return new Promise(((o,n)=>{SW.IAP.performIAPCall({method:"getPurchaseHistoryAsync",data:e},(e=>{e.result?o(e.purchaseDetails):n(e.err)}))}))},SW.IAP.setPurchaseListener=function(e){SW.IAP.purchaseCallback=e,SW.IAP.performIAPCall({method:"setPurchaseListener"})},SW.IAP.sendGQLRequest=function(e,o){if(!SW.IAP.isInit)return Promise.reject("IAP is not initialized before GQL request.");if(null===SW.IAP.userId)return Promise.reject("No user ID for GQL request.");if(null===SW.IAP.authToken)return Promise.reject("No auth token for GQL request.");const n=`${SW.Load.getAPIRootUrl()}/graphql/`;return new Promise(((t,r)=>{const a=new XMLHttpRequest;a.open("POST",n,!0),a.setRequestHeader("token",SW.IAP.authToken),a.setRequestHeader("userID",`${SW.IAP.userId}`),a.setRequestHeader("usertype","student"),a.setRequestHeader("apollographql-client-name","prodigy-game"),a.setRequestHeader("apollographql-client-version","1.0"),a.setRequestHeader("Content-Type","application/json"),a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){const o=a.status;if(0===o||o>=200&&o<400)try{const e=JSON.parse(a.responseText);t(e.data)}catch(e){r(`JSON Parse Error for: ${a.responseText}`)}else r(`${o} ${a.statusText}`)}},a.send(JSON.stringify({query:e,variables:o||{}}))}))},SW.Load.setOldDeviceErrorScreen=function(){SW.Load.setDivDisplay("warning-div",!0),SW.Load.setDivDisplay(SW.Load.DIV_LOADING,!0),SW.Load.setDivDisplay(SW.Load.DIV_SPLASH_IMAGE,!1),document.getElementById("loading-div").style.display="none";const e=SW.Load.ERROR_TITLE_OLD_DEVICE;document.getElementById("warning-title").innerHTML=e;const o=SW.Load.ERROR_DESCRIPTION_OLD_DEVICE;document.getElementById("warning-text").innerHTML=o,document.getElementById("openfaq").onclick=()=>(SW.Load.showLeaveGamePrompt(SW.Load.WEBGL_FAQ_URL),!1)},SW.Load.showLeaveGamePrompt=function(e){const o=e=>SW.Load.setDivDisplay("leave-game-panel",e);o(!0),document.getElementById("leave-button").onclick=()=>{SW.Device.openWebsite(e),o(!1)},document.getElementById("stay-button").onclick=()=>o(!1)},SW.Load.setDivDisplay=function(e,o){var n=!1,t=document.getElementById(e);return t?(t.style.display=o?SW.Load.DISPLAY_SHOW:SW.Load.DISPLAY_HIDE,n=!0):console.log(`setDivDisplay div not found: ${e}`),n},SW.Load.setDivCSS=function(e,o){var n=!1,t=document.getElementById(e);return t?(t.style.cssText=o,n=!0):console.log(`setDivCSS div not found: ${e}`),n},SW.Load.getUrlVariables=function(e){const o={};return e.replace(/[?&]+([^=&]+)=([^&]*)/gi,((e,n,t)=>o[n]=t)),o},SW.Load.isAutoLogin=function(e=!0){var o=SW.Load.getUrlVariables(window.location.href);if("true"===o.autoLogin){if(!e)return!0;var n=window.localStorage.getItem("autoLogin");if(n)return n.length>0}else void 0!==o.autoLogin&&window.localStorage.removeItem("autoLogin");return!1},SW.Load.redirectToLauncher=function(e){var o=window.location.search,n=e;o&&(n=`${e}${o}`),window.location.href=n},SW.Load.logout=function(){settings.store.clear()},SW.Load.isErrorScreen=function(){var e=SW.Load.pending;if(!e){var o=document.getElementById("error-div");o&&(e="none"!==o.style.display)}return e},SW.Load.toggleErrorScreen=function(e){SW.Load.setDivDisplay(SW.Load.DIV_ERROR,e),document.getElementById(SW.Load.DIV_LOADING)&&SW.Load.setDivDisplay(SW.Load.DIV_LOADING,!e),document.getElementById(SW.Load.DIV_SPLASH_IMAGE)&&SW.Load.setDivDisplay(SW.Load.DIV_SPLASH_IMAGE,!e)},SW.Load.setErrorScreen=function(e,o,n,t){if(e&&Sentry.captureMessage(`Loader Error: ${e}`),document.getElementById("error-div")){SW.Load.toggleErrorScreen(!0);var r=o||`${SW.Load.ERROR_TITLE_DEFAULT}: ${t}`;document.getElementById("error-title").innerHTML=r;var a=n||SW.Load.ERROR_DESCRIPTION_DEFAULT;document.getElementById("error-text").innerHTML=a,document.getElementById("try-again-button").onclick=()=>{SW.Load.redirectToLauncher(window.launcherUrl)}}else SW.Load.pendingError=!0,SW.Load.pendingErrorTitle=o,SW.Load.pendingErrorDesc=n,SW.Load.pendingErrorID=t},SW.Load.checkPendingErrorScreen=function(){SW.Load.pendingError&&(SW.Load.setErrorScreen(null,SW.Load.pendingErrorTitle,SW.Load.pendingErrorDesc,SW.Load.pendingErrorID),SW.Load.pendingError=!1,SW.Load.pendingErrorTitle=void 0,SW.Load.pendingErrorDesc=void 0,SW.Load.pendingErrorID=0)},SW.Load.getServiceURL=function(){return prodigyServiceUrl},SW.Load.getAPIRootUrl=function(){let e=window.location.search;e.startsWith("?")&&(e=e.substring(1));const o=e.split("&"),n={};for(let t=0;t<o.length;t+=1){const e=o[t].split("=");2===e.length?n[e[0]]=e[1]:n[e[0]]=!0}switch(SW.Load.env){case ENVIRONMENTS.PRODUCTION:return"https://api.prodigygame.com";case ENVIRONMENTS.STAGING:return"https://api.prodigygame.org";case ENVIRONMENTS.DEVELOPMENT:return"https://api.prodigygame.net";case ENVIRONMENTS.LOCAL:return void 0!==n.env&&n.env.indexOf("-qa")>-1?`https://${n.env}.prodigygame.${void 0!==n.boxEnv?n.boxEnv:"org"}`:`https://${window.location.host}`;default:return""}},SW.Load.getEducationFrontendAssetsURL=function(){return"undefined"!=typeof prodigyEducationFrontendAssetsUrl&&prodigyEducationFrontendAssetsUrl?prodigyEducationFrontendAssetsUrl:SW.Load.getServiceURL()},SW.Load.setupEventParams=function(){const e=window.location.host,o=window.location.search;var n="dev";e.indexOf("-qa")>=0||e.indexOf("dev.prodigygame.org")>=0?n=ENVIRONMENTS.LOCAL:e.indexOf("prodigygame.net")>=0||o.indexOf("env=dev")>=0?n=ENVIRONMENTS.DEVELOPMENT:e.indexOf("prodigygame.org")>=0||o.indexOf("env=staging")>=0?n=ENVIRONMENTS.STAGING:(e.indexOf("prodigygame.com")>=0||o.indexOf("env=production")>=0||o.indexOf("env=prod")>=0)&&(n=ENVIRONMENTS.PRODUCTION);var t,r="unknown",a=window.navigator.userAgent;a.indexOf("Opera")>-1||a.indexOf("OPR")>-1?r="Opera":a.indexOf("Chrome")>-1?r="Chrome":a.indexOf("Safari")>-1?r="Safari":a.indexOf("Firefox")>-1?r="Firefox":a.indexOf("SamsungBrowser")>-1?r="Samsung Internet for Android":a.indexOf("Trident")>-1?r="Internet Explorer":a.indexOf("Edge")>-1?r="Microsoft Edge":a.indexOf("Silk")>-1&&(r="Amazon Silk");var i="",s=0;/iPad|iPhone|iPod/.test(navigator.platform)?/nativeApp/.test(window.location.href)?(t="iOS-App",i=SW.Device.getMobileVersion()):(t="iOS-Browser",s=(i=/OS (\d+)_(\d+)_?(\d+)?/.exec(a))&&i[3]?i[3]:0,i=i&&i[1]&&i[2]?`${i[1]}.${i[2]}.${s}`:"unknown"):/Android|Linux/.test(navigator.platform)?/nativeApp/.test(window.location.href)?(t="Android-App",i=SW.Device.getMobileVersion()):(t="Android-Browser",i=(i=/Android ([._\d]+)/.exec(a))&&i[1]?i[1]:"unknown"):t="Desktop-Browser",SW.Load.browserName=r,SW.Load.env=n,SW.Load.deviceOSVersion=i,SW.Load.devicePlatform=t},SW.Load.sendV3Event=function(e,o,n){const t={name:"anonymous_game_complete_v3",version:3,uuid:window.eventData.uuid,timestamp:Date.now(),timezone_offset:(new Date).getTimezoneOffset(),client_version:SW.Load.env,device_platform:SW.Load.devicePlatform,browser:SW.Load.browserName,device_os_version:SW.Load.deviceOSVersion,meta:o,custom:n},r=new XMLHttpRequest;r.open("POST",e),r.setRequestHeader("Content-Type","application/json"),r.send(JSON.stringify({events:JSON.stringify([t])}))},SW.Load.sendLoginStart=function(){SW.Load.setupEventParams();const e=`${SW.Load.getServiceURL()}events-api/v3/anonymous-events`;SW.Load.sendV3Event(e,{type:"login_time_funnel",name:"load_start",timeDelta:0})},SW.Load.sentryInit=function(e){var o,n=e.env,t=`PGL-${e.version}`;o=n===ENVIRONMENTS.PRODUCTION?SW.Load.SENTRY_SAMPLE_RATE_PROD:n===ENVIRONMENTS.STAGING?SW.Load.SENTRY_SAMPLE_RATE_STAGING:SW.Load.SENTRY_SAMPLE_RATE_DEFAULT,Sentry.init({dsn:SW.Load.SENTRY_URL,release:t,environment:n,sampleRate:o,attachStacktrace:!0});const r={id:window.eventData.uuid};Sentry.setUser(r)},SW.Load.uuidv4=function(){const e=window.crypto||window.msCrypto;return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(o=>(o^e.getRandomValues(new Uint8Array(1))[0]&15>>o/4).toString(16)))},SW.Load.setTrackingCookie=function(){const e=SW.Cookie.getTrackingCookie()||SW.Load.uuidv4();SW.Cookie.setTrackingCookie(e)},SW.Load.displayVersion=function(){var e=["%c ♥ Prodigy Loader v"+eventData.version+" ♥ ","color: #ffffff; background: #fc8cb2"];return console.log.apply(console,e),e};