@easyeyes_threshold/runtime 1.20261103.61508 → 1.20261103.81936

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/js/first.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){try{var n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},e=(new n.Error).stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="bb7b98df-3b54-4319-bf0a-17b1cb3fd67a",n._sentryDebugIdIdentifier="sentry-dbid-bb7b98df-3b54-4319-bf0a-17b1cb3fd67a")}catch(n){}}();const n=new class{constructor(){this.currentPercentage=0,this.listeners=[],this.progressIntervalId=null}startProgressAnimation(){this.progressIntervalId||(this.progressIntervalId=setInterval(()=>{if(this.currentPercentage<90){const n=4*Math.random()+1;this.currentPercentage=Math.min(90,this.currentPercentage+n),this.notifyListeners()}},800))}stopProgressAnimation(){this.progressIntervalId&&(clearInterval(this.progressIntervalId),this.progressIntervalId=null)}notifyListeners(){this.listeners.forEach(n=>{n(this.currentPercentage)}),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("threshold-init-progress",{detail:{percentage:Math.round(this.currentPercentage)}}))}reset(){this.stopProgressAnimation(),this.currentPercentage=0}},e=async()=>{const[n,e]=window.location.pathname.split("/").filter(Boolean),t=new URLSearchParams(window.location.search).get("preview-deploy")||("localhost"!==window.location.hostname?"https://easyeyes.app":"http://localhost:8888"),o=await fetch(`${t}/.netlify/functions/phrases?pinned=${n}/${e}`);if(!o.ok)throw new Error(`phrases pin fetch failed: ${o.status}`);const{version:i}=await o.json(),s=await fetch(`${t}/.netlify/functions/phrases?v=${i}`);if(!s.ok)throw new Error(`phrases fetch failed: ${s.status}`);return(await s.json()).phrases};document.addEventListener("DOMContentLoaded",()=>{document.body.setAttribute("dir","undefined"!=typeof experimentLanguageDirection&&"rtl"===String(experimentLanguageDirection).toLowerCase()?"rtl":"ltr"),n.startProgressAnimation();const t=document.createElement("div");t.className="loading-container",t.innerHTML='\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text"></div>\n <div class="progress-bar">\n <div class="progress-fill" id="progressFill"></div>\n </div>\n <div class="progress-percent" id="progressPercent">0%</div>\n <div id="timeoutMessage" class="timeout-message" style="display: none;"></div>\n <button id="reloadButton" class="reload-button" style="display: none;"></button>\n </div>\n ',document.body.appendChild(t);let o=!1,i=!1;const s=()=>{if(!o||!i||!t.parentNode)return;const n=document.getElementById("timeoutMessage"),e=document.getElementById("reloadButton");n&&(n.style.display="block"),e&&(e.style.display="block")};e().then(n=>{const e=((n,e)=>{let t;return t=e&&Object.prototype.hasOwnProperty.call(n.EE_LanguageEnglishName,e)?e:Object.keys(n.EE_LanguageEnglishName).find(t=>n.EE_LanguageEnglishName[t]===e),t?{loadingText:n.RC_LoadingStudy[t],timeoutMessage:n.RC_LoadingStudyTakingLonger[t],reloadButton:n.RC_ReloadStudyButton[t]}:null})(n,experimentLanguage);if(e){const n=t.querySelector(".loading-text");n&&(n.textContent=e.loadingText);const i=document.getElementById("timeoutMessage");i&&(i.textContent=e.timeoutMessage);const r=document.getElementById("reloadButton");r&&(r.textContent=e.reloadButton),o=!0,s()}}).catch(n=>{console.warn("Failed to load phrases:",n);const e=t.querySelector(".loading-text");e&&(e.textContent="Loading …")});const r=setTimeout(()=>{i=!0,s()},1e4),a=document.getElementById("reloadButton");a&&a.addEventListener("click",()=>{window.location.reload()}),window.addEventListener("threshold-init-progress",n=>{const{percentage:e}=n.detail,t=document.getElementById("progressFill"),o=document.getElementById("progressPercent");t&&(t.style.width=e+"%"),o&&(o.textContent=Math.round(e)+"%")});const d=()=>{clearTimeout(r),n.stopProgressAnimation(),n.currentPercentage=100,n.notifyListeners(),t.parentNode&&t.remove()};window.removeLoadingScreen=d,window.showCriticalLoadError=(e,t)=>{clearTimeout(r),n.stopProgressAnimation(),"undefined"!=typeof Swal&&Swal.fire({allowOutsideClick:!1,icon:"error",title:e||"Loading Failed",text:t||"Please refresh the page to try again.",confirmButtonText:"Refresh"}).then(()=>window.location.reload())},window.addEventListener("threshold-ready-for-ui",()=>{d()})});const t=document.createElement("style");t.textContent='\n body, html {\n margin: 0;\n padding: 0;\n }\n\n .loading-container {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n transition: opacity 0.4s ease;\n padding: 0;\n margin: 0;\n height: 100vh;\n width: 100vw;\n background: white;\n z-index: 10000;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 20px;\n width: 400px;\n max-width: 90vw;\n padding: 20px;\n }\n\n .loading-spinner {\n border: 5px solid #f3f3f3;\n border-top: 5px solid #3498db;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n font-size: 18px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n color: #333;\n font-weight: 500;\n }\n\n .progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: #3498db;\n width: 0%;\n transition: width 0.3s ease;\n }\n\n .progress-percent {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n\n .progress-step {\n font-size: 12px;\n color: #999;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n min-height: 16px;\n }\n\n .timeout-message {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n font-weight: 400;\n text-align: center;\n }\n\n .reload-button {\n background: #3498db;\n color: white;\n border: none;\n padding: 12px 24px;\n border-radius: 4px;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s ease;\n }\n\n .reload-button:hover {\n background: #2980b9;\n }\n\n .reload-button:active {\n background: #1f618d;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n .fade-out {\n opacity: 0;\n }\n\n /* Center-align Swal2 modal title and content for consistent alignment */\n .swal2-title,\n .swal2-html-container {\n text-align: center !important;\n }\n',document.head.appendChild(t);
1
+ !function(){try{var n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},e=(new n.Error).stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="c70cc7c3-8a40-4623-a982-14862e976975",n._sentryDebugIdIdentifier="sentry-dbid-c70cc7c3-8a40-4623-a982-14862e976975")}catch(n){}}();const n=new class{constructor(){this.currentPercentage=0,this.listeners=[],this.progressIntervalId=null}startProgressAnimation(){this.progressIntervalId||(this.progressIntervalId=setInterval(()=>{if(this.currentPercentage<90){const n=4*Math.random()+1;this.currentPercentage=Math.min(90,this.currentPercentage+n),this.notifyListeners()}},800))}stopProgressAnimation(){this.progressIntervalId&&(clearInterval(this.progressIntervalId),this.progressIntervalId=null)}notifyListeners(){this.listeners.forEach(n=>{n(this.currentPercentage)}),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("threshold-init-progress",{detail:{percentage:Math.round(this.currentPercentage)}}))}reset(){this.stopProgressAnimation(),this.currentPercentage=0}},e=async()=>{const[n,e]=window.location.pathname.split("/").filter(Boolean),t=await(async()=>{const n=new URLSearchParams(window.location.search).get("preview-deploy");if(n)return n;if("localhost"!==window.location.hostname)return"https://easyeyes.app";try{return await fetch("http://localhost:8888",{method:"HEAD",mode:"no-cors"}),"http://localhost:8888"}catch{return"https://easyeyes.app"}})(),o=await fetch(`${t}/.netlify/functions/phrases?pinned=${n}/${e}`);if(!o.ok)throw new Error(`phrases pin fetch failed: ${o.status}`);const{version:s}=await o.json(),i=await fetch(`${t}/.netlify/functions/phrases?v=${s}`);if(!i.ok)throw new Error(`phrases fetch failed: ${i.status}`);return(await i.json()).phrases};document.addEventListener("DOMContentLoaded",()=>{document.body.setAttribute("dir","undefined"!=typeof experimentLanguageDirection&&"rtl"===String(experimentLanguageDirection).toLowerCase()?"rtl":"ltr"),n.startProgressAnimation();const t=document.createElement("div");t.className="loading-container",t.innerHTML='\n <div class="loading-content">\n <div class="loading-spinner"></div>\n <div class="loading-text"></div>\n <div class="progress-bar">\n <div class="progress-fill" id="progressFill"></div>\n </div>\n <div class="progress-percent" id="progressPercent">0%</div>\n <div id="timeoutMessage" class="timeout-message" style="display: none;"></div>\n <button id="reloadButton" class="reload-button" style="display: none;"></button>\n </div>\n ',document.body.appendChild(t);let o=!1,s=!1;const i=()=>{if(!o||!s||!t.parentNode)return;const n=document.getElementById("timeoutMessage"),e=document.getElementById("reloadButton");n&&(n.style.display="block"),e&&(e.style.display="block")};e().then(n=>{const e=((n,e)=>{let t;return t=e&&Object.prototype.hasOwnProperty.call(n.EE_LanguageEnglishName,e)?e:Object.keys(n.EE_LanguageEnglishName).find(t=>n.EE_LanguageEnglishName[t]===e),t?{loadingText:n.RC_LoadingStudy[t],timeoutMessage:n.RC_LoadingStudyTakingLonger[t],reloadButton:n.RC_ReloadStudyButton[t]}:null})(n,experimentLanguage);if(e){const n=t.querySelector(".loading-text");n&&(n.textContent=e.loadingText);const s=document.getElementById("timeoutMessage");s&&(s.textContent=e.timeoutMessage);const r=document.getElementById("reloadButton");r&&(r.textContent=e.reloadButton),o=!0,i()}}).catch(n=>{console.warn("Failed to load phrases:",n);const e=t.querySelector(".loading-text");e&&(e.textContent="Loading …")});const r=setTimeout(()=>{s=!0,i()},1e4),a=document.getElementById("reloadButton");a&&a.addEventListener("click",()=>{window.location.reload()}),window.addEventListener("threshold-init-progress",n=>{const{percentage:e}=n.detail,t=document.getElementById("progressFill"),o=document.getElementById("progressPercent");t&&(t.style.width=e+"%"),o&&(o.textContent=Math.round(e)+"%")});const d=()=>{clearTimeout(r),n.stopProgressAnimation(),n.currentPercentage=100,n.notifyListeners(),t.parentNode&&t.remove()};window.removeLoadingScreen=d,window.showCriticalLoadError=(e,t)=>{clearTimeout(r),n.stopProgressAnimation(),"undefined"!=typeof Swal&&Swal.fire({allowOutsideClick:!1,icon:"error",title:e||"Loading Failed",text:t||"Please refresh the page to try again.",confirmButtonText:"Refresh"}).then(()=>window.location.reload())},window.addEventListener("threshold-ready-for-ui",()=>{d()})});const t=document.createElement("style");t.textContent='\n body, html {\n margin: 0;\n padding: 0;\n }\n\n .loading-container {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n transition: opacity 0.4s ease;\n padding: 0;\n margin: 0;\n height: 100vh;\n width: 100vw;\n background: white;\n z-index: 10000;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 20px;\n width: 400px;\n max-width: 90vw;\n padding: 20px;\n }\n\n .loading-spinner {\n border: 5px solid #f3f3f3;\n border-top: 5px solid #3498db;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n font-size: 18px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n color: #333;\n font-weight: 500;\n }\n\n .progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: #3498db;\n width: 0%;\n transition: width 0.3s ease;\n }\n\n .progress-percent {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n }\n\n .progress-step {\n font-size: 12px;\n color: #999;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n min-height: 16px;\n }\n\n .timeout-message {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n font-weight: 400;\n text-align: center;\n }\n\n .reload-button {\n background: #3498db;\n color: white;\n border: none;\n padding: 12px 24px;\n border-radius: 4px;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s ease;\n }\n\n .reload-button:hover {\n background: #2980b9;\n }\n\n .reload-button:active {\n background: #1f618d;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n .fade-out {\n opacity: 0;\n }\n\n /* Center-align Swal2 modal title and content for consistent alignment */\n .swal2-title,\n .swal2-html-container {\n text-align: center !important;\n }\n',document.head.appendChild(t);
2
2
  //# sourceMappingURL=first.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"first.min.js","sources":["../components/timeoutUtils.js","../first.js","../components/loadingScreenText.ts"],"sourcesContent":["/**\n * Class to track initialization progress\n */\nexport class InitializationProgress {\n constructor() {\n this.currentPercentage = 0;\n this.listeners = [];\n this.progressIntervalId = null;\n }\n /**\n * Start progress animation for better UX\n * Gradually increases progress if not already at target\n */\n startProgressAnimation() {\n if (this.progressIntervalId) return; // Already running\n\n this.progressIntervalId = setInterval(() => {\n // Gradually increase progress between updates (but slower as we get higher)\n if (this.currentPercentage < 90) {\n // Math.random (not the seeded rng): first.js imports this module and\n // must stay a standalone bundle; the increment is cosmetic only.\n const increment = Math.random() * (5 - 1) + 1; // Random 1-5% increment\n this.currentPercentage = Math.min(\n 90,\n this.currentPercentage + increment,\n );\n this.notifyListeners();\n }\n }, 800); // Update every 800ms\n }\n\n /**\n * Stop progress animation\n */\n stopProgressAnimation() {\n if (this.progressIntervalId) {\n clearInterval(this.progressIntervalId);\n this.progressIntervalId = null;\n }\n }\n\n /**\n * Notify all listeners of progress update\n */\n notifyListeners() {\n this.listeners.forEach((callback) => {\n callback(this.currentPercentage);\n });\n\n // Also dispatch custom event for cross-module communication\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"threshold-init-progress\", {\n detail: {\n percentage: Math.round(this.currentPercentage),\n },\n }),\n );\n }\n }\n\n /**\n * Reset progress\n */\n reset() {\n this.stopProgressAnimation();\n this.currentPercentage = 0;\n }\n}\n\n// Create a singleton instance\nexport const initProgress = new InitializationProgress();\n","// Import only what's needed for initial page rendering\nimport { initProgress } from \"./components/timeoutUtils.js\";\nimport * as sentry from \"./components/sentry\";\nimport { localizeLoadingScreen } from \"./components/loadingScreenText\";\n\n// Resolve the EasyEyes base URL for the loading-screen phrases fetch. Kept\n// self-contained (no shared imports) so first.js stays a standalone bundle —\n// see loadPhrases below. Mirrors components/easyeyesBaseUrl.ts for the deployed\n// cases (preview-deploy param, production); a local dev server is assumed at\n// :8888 without probing, since the spinner falls back gracefully on failure.\nconst getBaseUrl = () => {\n const previewDeployBase = new URLSearchParams(window.location.search).get(\n \"preview-deploy\",\n );\n if (previewDeployBase) return previewDeployBase;\n if (window.location.hostname !== \"localhost\") return \"https://easyeyes.app\";\n return \"http://localhost:8888\";\n};\n\n// Load phrases for the loading screen from the same versioned read-path the\n// experiment uses. Inlined here (not imported from preprocess/phrases-loader,\n// which has a top-level await) so first.js bundles standalone — sharing a module\n// across that async boundary would split a chunk that Pavlovia does not deploy.\n// A single attempt is enough: setupInitialUI's .catch falls back to plain text.\nconst loadPhrases = async () => {\n const [username, experimentName] = window.location.pathname\n .split(\"/\")\n .filter(Boolean);\n const base = getBaseUrl();\n // Two-step read: resolve the (mutable, uncached) pin to a version, then fetch\n // the immutable payload by explicit ?v= — the same cacheable URL the\n // experiment loader uses. Single attempt: the .catch falls back to plain text.\n const pinnedRes = await fetch(\n `${base}/.netlify/functions/phrases?pinned=${username}/${experimentName}`,\n );\n if (!pinnedRes.ok)\n throw new Error(`phrases pin fetch failed: ${pinnedRes.status}`);\n const { version } = await pinnedRes.json();\n const res = await fetch(`${base}/.netlify/functions/phrases?v=${version}`);\n if (!res.ok) throw new Error(`phrases fetch failed: ${res.status}`);\n const data = await res.json();\n return data.phrases;\n};\n\n// Initial UI setup function - show spinner immediately\nconst setupInitialUI = () => {\n // experimentLanguageDirection is defined (alongside experimentLanguage) in\n // the compile-time generated js/experimentLanguage.js loaded by index.html;\n // it holds the _language's direction per the phrases' EE_LanguageDirection.\n // Set <body dir> so every HTML element inherits the experiment's text\n // direction by default. Guarded with typeof: experiments compiled before\n // this constant existed ship an experimentLanguage.js without it.\n document.body.setAttribute(\n \"dir\",\n typeof experimentLanguageDirection !== \"undefined\" &&\n String(experimentLanguageDirection).toLowerCase() === \"rtl\"\n ? \"rtl\"\n : \"ltr\",\n );\n\n // Start the progress animation immediately (no i18n needed)\n initProgress.startProgressAnimation();\n\n // Create loading indicator with spinner only (no text initially)\n const loadingElement = document.createElement(\"div\");\n loadingElement.className = \"loading-container\";\n loadingElement.innerHTML = `\n <div class=\"loading-content\">\n <div class=\"loading-spinner\"></div>\n <div class=\"loading-text\"></div>\n <div class=\"progress-bar\">\n <div class=\"progress-fill\" id=\"progressFill\"></div>\n </div>\n <div class=\"progress-percent\" id=\"progressPercent\">0%</div>\n <div id=\"timeoutMessage\" class=\"timeout-message\" style=\"display: none;\"></div>\n <button id=\"reloadButton\" class=\"reload-button\" style=\"display: none;\"></button>\n </div>\n `;\n document.body.appendChild(loadingElement);\n\n // Show the timeout message and reload button only once BOTH conditions hold:\n // the 10s timer has fired and phrases have loaded (so they have localized\n // text). Either side can be the last to happen, so each calls this helper.\n let phrasesLoaded = false;\n let timeoutReached = false;\n const maybeShowTimeoutUI = () => {\n if (!phrasesLoaded || !timeoutReached || !loadingElement.parentNode) return;\n const timeoutMessage = document.getElementById(\"timeoutMessage\");\n const reloadButton = document.getElementById(\"reloadButton\");\n if (timeoutMessage) {\n timeoutMessage.style.display = \"block\";\n }\n if (reloadButton) {\n reloadButton.style.display = \"block\";\n }\n };\n\n // Lazy-load i18n and update text elements once available\n loadPhrases()\n .then((phrases) => {\n // experimentLanguage is loaded in the index.html\n const text = localizeLoadingScreen(phrases, experimentLanguage);\n if (text) {\n // Update text elements (DOM already has them, just populate)\n const loadingText = loadingElement.querySelector(\".loading-text\");\n if (loadingText) {\n loadingText.textContent = text.loadingText;\n }\n const timeoutMessage = document.getElementById(\"timeoutMessage\");\n if (timeoutMessage) {\n timeoutMessage.textContent = text.timeoutMessage;\n }\n const reloadButton = document.getElementById(\"reloadButton\");\n if (reloadButton) {\n reloadButton.textContent = text.reloadButton;\n }\n phrasesLoaded = true;\n maybeShowTimeoutUI();\n }\n })\n .catch((err) => {\n console.warn(\"Failed to load phrases:\", err);\n const loadingText = loadingElement.querySelector(\".loading-text\");\n if (loadingText) {\n loadingText.textContent = \"Loading …\";\n }\n });\n\n // Setup timeout warning and reload button (10 seconds)\n const timeoutWarningTimer = setTimeout(() => {\n timeoutReached = true;\n maybeShowTimeoutUI();\n }, 10000);\n\n // Reload button click handler\n const reloadButton = document.getElementById(\"reloadButton\");\n if (reloadButton) {\n reloadButton.addEventListener(\"click\", () => {\n window.location.reload();\n });\n }\n\n // Listen for initialization progress updates\n window.addEventListener(\"threshold-init-progress\", (event) => {\n const { percentage } = event.detail;\n const progressFill = document.getElementById(\"progressFill\");\n const progressPercent = document.getElementById(\"progressPercent\");\n\n if (progressFill) {\n progressFill.style.width = percentage + \"%\";\n }\n if (progressPercent) {\n progressPercent.textContent = Math.round(percentage) + \"%\";\n }\n });\n\n // Extract loading screen removal function\n const removeLoadingScreen = () => {\n // Clear timeout timer\n clearTimeout(timeoutWarningTimer);\n\n // Stop progress animation and ensure progress bar shows 100%\n initProgress.stopProgressAnimation();\n initProgress.currentPercentage = 100;\n initProgress.notifyListeners();\n\n if (loadingElement.parentNode) {\n loadingElement.remove();\n }\n };\n\n // Expose globally for threshold.js (before threshold.js loads)\n window.removeLoadingScreen = removeLoadingScreen;\n\n // Show critical load error using Swal2 (loaded in index.html before first.js)\n window.showCriticalLoadError = (title, text) => {\n clearTimeout(timeoutWarningTimer);\n initProgress.stopProgressAnimation();\n if (typeof Swal !== \"undefined\") {\n Swal.fire({\n allowOutsideClick: false,\n icon: \"error\",\n title: title || \"Loading Failed\",\n text: text || \"Please refresh the page to try again.\",\n confirmButtonText: \"Refresh\",\n }).then(() => window.location.reload());\n }\n };\n\n // Remove loading screen when ready for UI (compatibility page)\n window.addEventListener(\"threshold-ready-for-ui\", () => {\n removeLoadingScreen(); // Delegates to extracted function\n });\n};\n\n// Run immediately\ndocument.addEventListener(\"DOMContentLoaded\", setupInitialUI);\n\n// Add some CSS for the loading screen\nconst style = document.createElement(\"style\");\nstyle.textContent = `\n body, html {\n margin: 0;\n padding: 0;\n }\n\n .loading-container {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n transition: opacity 0.4s ease;\n padding: 0;\n margin: 0;\n height: 100vh;\n width: 100vw;\n background: white;\n z-index: 10000;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 20px;\n width: 400px;\n max-width: 90vw;\n padding: 20px;\n }\n\n .loading-spinner {\n border: 5px solid #f3f3f3;\n border-top: 5px solid #3498db;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n font-size: 18px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n color: #333;\n font-weight: 500;\n }\n\n .progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: #3498db;\n width: 0%;\n transition: width 0.3s ease;\n }\n\n .progress-percent {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n }\n\n .progress-step {\n font-size: 12px;\n color: #999;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n min-height: 16px;\n }\n\n .timeout-message {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n font-weight: 400;\n text-align: center;\n }\n\n .reload-button {\n background: #3498db;\n color: white;\n border: none;\n padding: 12px 24px;\n border-radius: 4px;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s ease;\n }\n\n .reload-button:hover {\n background: #2980b9;\n }\n\n .reload-button:active {\n background: #1f618d;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n .fade-out {\n opacity: 0;\n }\n\n /* Center-align Swal2 modal title and content for consistent alignment */\n .swal2-title,\n .swal2-html-container {\n text-align: center !important;\n }\n`;\ndocument.head.appendChild(style);\n\n// Export things that threshold.js might need\nexport { setupInitialUI };\n","type Phrases = Record<string, Record<string, string>>;\n\nexport interface LoadingScreenText {\n loadingText: string;\n timeoutMessage: string;\n reloadButton: string;\n}\n\n/**\n * Resolve the loading-screen strings for the experiment's language (as set in\n * index.html). Accepts either a language code (e.g. \"fr\") or, for backward\n * compatibility, the full English name. Returns null when nothing matches.\n */\nexport const localizeLoadingScreen = (\n phrases: Phrases,\n experimentLanguageName: string,\n): LoadingScreenText | null => {\n let lang: string | undefined;\n // _language now takes a language code; use it directly when it is one.\n if (\n experimentLanguageName &&\n Object.prototype.hasOwnProperty.call(\n phrases.EE_LanguageEnglishName,\n experimentLanguageName,\n )\n ) {\n lang = experimentLanguageName;\n } else {\n lang = Object.keys(phrases.EE_LanguageEnglishName).find(\n (key) => phrases.EE_LanguageEnglishName[key] === experimentLanguageName,\n );\n }\n if (!lang) return null;\n return {\n loadingText: phrases.RC_LoadingStudy[lang],\n timeoutMessage: phrases.RC_LoadingStudyTakingLonger[lang],\n reloadButton: phrases.RC_ReloadStudyButton[lang],\n };\n};\n"],"names":["initProgress","constructor","this","currentPercentage","listeners","progressIntervalId","startProgressAnimation","setInterval","increment","Math","random","min","notifyListeners","stopProgressAnimation","clearInterval","forEach","callback","window","dispatchEvent","CustomEvent","detail","percentage","round","reset","loadPhrases","async","username","experimentName","location","pathname","split","filter","Boolean","base","URLSearchParams","search","get","hostname","pinnedRes","fetch","ok","Error","status","version","json","res","phrases","document","addEventListener","body","setAttribute","experimentLanguageDirection","String","toLowerCase","loadingElement","createElement","className","innerHTML","appendChild","phrasesLoaded","timeoutReached","maybeShowTimeoutUI","parentNode","timeoutMessage","getElementById","reloadButton","style","display","then","text","experimentLanguageName","lang","Object","prototype","hasOwnProperty","call","EE_LanguageEnglishName","keys","find","key","loadingText","RC_LoadingStudy","RC_LoadingStudyTakingLonger","RC_ReloadStudyButton","localizeLoadingScreen","experimentLanguage","querySelector","textContent","catch","err","console","warn","timeoutWarningTimer","setTimeout","reload","event","progressFill","progressPercent","width","removeLoadingScreen","clearTimeout","remove","showCriticalLoadError","title","Swal","fire","allowOutsideClick","icon","confirmButtonText","head"],"mappings":"gYAuEO,MAAMA,EAAe,IApErB,MACL,WAAAC,GACEC,KAAKC,kBAAoB,EACzBD,KAAKE,UAAY,GACjBF,KAAKG,mBAAqB,IAC5B,CAKA,sBAAAC,GACMJ,KAAKG,qBAETH,KAAKG,mBAAqBE,YAAY,KAEpC,GAAIL,KAAKC,kBAAoB,GAAI,CAG/B,MAAMK,EAAyB,EAAbC,KAAKC,SAAqB,EAC5CR,KAAKC,kBAAoBM,KAAKE,IAC5B,GACAT,KAAKC,kBAAoBK,GAE3BN,KAAKU,iBACP,GACC,KACL,CAKA,qBAAAC,GACMX,KAAKG,qBACPS,cAAcZ,KAAKG,oBACnBH,KAAKG,mBAAqB,KAE9B,CAKA,eAAAO,GACEV,KAAKE,UAAUW,QAASC,IACtBA,EAASd,KAAKC,qBAIM,oBAAXc,QACTA,OAAOC,cACL,IAAIC,YAAY,0BAA2B,CACzCC,OAAQ,CACNC,WAAYZ,KAAKa,MAAMpB,KAAKC,sBAKtC,CAKA,KAAAoB,GACErB,KAAKW,wBACLX,KAAKC,kBAAoB,CAC3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OAAOW,SAASkE,WAKlC7E,OAAO+B,iBAAiB,yBAA0B,KAChDmD,QAQJ,MAAMjC,EAAQnB,SAASQ,cAAc,SACrCW,EAAMqB,YAAc,kyFAyHpBxC,SAAS8D,KAAKnD,YAAYQ"}
1
+ {"version":3,"file":"first.min.js","sources":["../components/timeoutUtils.js","../first.js","../components/loadingScreenText.ts"],"sourcesContent":["/**\n * Class to track initialization progress\n */\nexport class InitializationProgress {\n constructor() {\n this.currentPercentage = 0;\n this.listeners = [];\n this.progressIntervalId = null;\n }\n /**\n * Start progress animation for better UX\n * Gradually increases progress if not already at target\n */\n startProgressAnimation() {\n if (this.progressIntervalId) return; // Already running\n\n this.progressIntervalId = setInterval(() => {\n // Gradually increase progress between updates (but slower as we get higher)\n if (this.currentPercentage < 90) {\n // Math.random (not the seeded rng): first.js imports this module and\n // must stay a standalone bundle; the increment is cosmetic only.\n const increment = Math.random() * (5 - 1) + 1; // Random 1-5% increment\n this.currentPercentage = Math.min(\n 90,\n this.currentPercentage + increment,\n );\n this.notifyListeners();\n }\n }, 800); // Update every 800ms\n }\n\n /**\n * Stop progress animation\n */\n stopProgressAnimation() {\n if (this.progressIntervalId) {\n clearInterval(this.progressIntervalId);\n this.progressIntervalId = null;\n }\n }\n\n /**\n * Notify all listeners of progress update\n */\n notifyListeners() {\n this.listeners.forEach((callback) => {\n callback(this.currentPercentage);\n });\n\n // Also dispatch custom event for cross-module communication\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"threshold-init-progress\", {\n detail: {\n percentage: Math.round(this.currentPercentage),\n },\n }),\n );\n }\n }\n\n /**\n * Reset progress\n */\n reset() {\n this.stopProgressAnimation();\n this.currentPercentage = 0;\n }\n}\n\n// Create a singleton instance\nexport const initProgress = new InitializationProgress();\n","// Import only what's needed for initial page rendering\nimport { initProgress } from \"./components/timeoutUtils.js\";\nimport * as sentry from \"./components/sentry\";\nimport { localizeLoadingScreen } from \"./components/loadingScreenText\";\n\n// Resolve the EasyEyes base URL for the loading-screen phrases fetch. Kept\n// self-contained (no shared imports) so first.js stays a standalone bundle —\n// see loadPhrases below. Mirrors components/easyeyesBaseUrl.ts: preview-deploy\n// wins; localhost uses a local backend when its probe answers, otherwise production.\nconst getBaseUrl = async () => {\n const previewDeployBase = new URLSearchParams(window.location.search).get(\n \"preview-deploy\",\n );\n if (previewDeployBase) return previewDeployBase;\n if (window.location.hostname !== \"localhost\") return \"https://easyeyes.app\";\n try {\n await fetch(\"http://localhost:8888\", { method: \"HEAD\", mode: \"no-cors\" });\n return \"http://localhost:8888\";\n } catch {\n return \"https://easyeyes.app\";\n }\n};\n\n// Load phrases for the loading screen from the same versioned read-path the\n// experiment uses. Inlined here (not imported from preprocess/phrases-loader,\n// which has a top-level await) so first.js bundles standalone — sharing a module\n// across that async boundary would split a chunk that Pavlovia does not deploy.\n// A single attempt is enough: setupInitialUI's .catch falls back to plain text.\nconst loadPhrases = async () => {\n const [username, experimentName] = window.location.pathname\n .split(\"/\")\n .filter(Boolean);\n const base = await getBaseUrl();\n // Two-step read: resolve the (mutable, uncached) pin to a version, then fetch\n // the immutable payload by explicit ?v= — the same cacheable URL the\n // experiment loader uses. Single attempt: the .catch falls back to plain text.\n const pinnedRes = await fetch(\n `${base}/.netlify/functions/phrases?pinned=${username}/${experimentName}`,\n );\n if (!pinnedRes.ok)\n throw new Error(`phrases pin fetch failed: ${pinnedRes.status}`);\n const { version } = await pinnedRes.json();\n const res = await fetch(`${base}/.netlify/functions/phrases?v=${version}`);\n if (!res.ok) throw new Error(`phrases fetch failed: ${res.status}`);\n const data = await res.json();\n return data.phrases;\n};\n\n// Initial UI setup function - show spinner immediately\nconst setupInitialUI = () => {\n // experimentLanguageDirection is defined (alongside experimentLanguage) in\n // the compile-time generated js/experimentLanguage.js loaded by index.html;\n // it holds the _language's direction per the phrases' EE_LanguageDirection.\n // Set <body dir> so every HTML element inherits the experiment's text\n // direction by default. Guarded with typeof: experiments compiled before\n // this constant existed ship an experimentLanguage.js without it.\n document.body.setAttribute(\n \"dir\",\n typeof experimentLanguageDirection !== \"undefined\" &&\n String(experimentLanguageDirection).toLowerCase() === \"rtl\"\n ? \"rtl\"\n : \"ltr\",\n );\n\n // Start the progress animation immediately (no i18n needed)\n initProgress.startProgressAnimation();\n\n // Create loading indicator with spinner only (no text initially)\n const loadingElement = document.createElement(\"div\");\n loadingElement.className = \"loading-container\";\n loadingElement.innerHTML = `\n <div class=\"loading-content\">\n <div class=\"loading-spinner\"></div>\n <div class=\"loading-text\"></div>\n <div class=\"progress-bar\">\n <div class=\"progress-fill\" id=\"progressFill\"></div>\n </div>\n <div class=\"progress-percent\" id=\"progressPercent\">0%</div>\n <div id=\"timeoutMessage\" class=\"timeout-message\" style=\"display: none;\"></div>\n <button id=\"reloadButton\" class=\"reload-button\" style=\"display: none;\"></button>\n </div>\n `;\n document.body.appendChild(loadingElement);\n\n // Show the timeout message and reload button only once BOTH conditions hold:\n // the 10s timer has fired and phrases have loaded (so they have localized\n // text). Either side can be the last to happen, so each calls this helper.\n let phrasesLoaded = false;\n let timeoutReached = false;\n const maybeShowTimeoutUI = () => {\n if (!phrasesLoaded || !timeoutReached || !loadingElement.parentNode) return;\n const timeoutMessage = document.getElementById(\"timeoutMessage\");\n const reloadButton = document.getElementById(\"reloadButton\");\n if (timeoutMessage) {\n timeoutMessage.style.display = \"block\";\n }\n if (reloadButton) {\n reloadButton.style.display = \"block\";\n }\n };\n\n // Lazy-load i18n and update text elements once available\n loadPhrases()\n .then((phrases) => {\n // experimentLanguage is loaded in the index.html\n const text = localizeLoadingScreen(phrases, experimentLanguage);\n if (text) {\n // Update text elements (DOM already has them, just populate)\n const loadingText = loadingElement.querySelector(\".loading-text\");\n if (loadingText) {\n loadingText.textContent = text.loadingText;\n }\n const timeoutMessage = document.getElementById(\"timeoutMessage\");\n if (timeoutMessage) {\n timeoutMessage.textContent = text.timeoutMessage;\n }\n const reloadButton = document.getElementById(\"reloadButton\");\n if (reloadButton) {\n reloadButton.textContent = text.reloadButton;\n }\n phrasesLoaded = true;\n maybeShowTimeoutUI();\n }\n })\n .catch((err) => {\n console.warn(\"Failed to load phrases:\", err);\n const loadingText = loadingElement.querySelector(\".loading-text\");\n if (loadingText) {\n loadingText.textContent = \"Loading …\";\n }\n });\n\n // Setup timeout warning and reload button (10 seconds)\n const timeoutWarningTimer = setTimeout(() => {\n timeoutReached = true;\n maybeShowTimeoutUI();\n }, 10000);\n\n // Reload button click handler\n const reloadButton = document.getElementById(\"reloadButton\");\n if (reloadButton) {\n reloadButton.addEventListener(\"click\", () => {\n window.location.reload();\n });\n }\n\n // Listen for initialization progress updates\n window.addEventListener(\"threshold-init-progress\", (event) => {\n const { percentage } = event.detail;\n const progressFill = document.getElementById(\"progressFill\");\n const progressPercent = document.getElementById(\"progressPercent\");\n\n if (progressFill) {\n progressFill.style.width = percentage + \"%\";\n }\n if (progressPercent) {\n progressPercent.textContent = Math.round(percentage) + \"%\";\n }\n });\n\n // Extract loading screen removal function\n const removeLoadingScreen = () => {\n // Clear timeout timer\n clearTimeout(timeoutWarningTimer);\n\n // Stop progress animation and ensure progress bar shows 100%\n initProgress.stopProgressAnimation();\n initProgress.currentPercentage = 100;\n initProgress.notifyListeners();\n\n if (loadingElement.parentNode) {\n loadingElement.remove();\n }\n };\n\n // Expose globally for threshold.js (before threshold.js loads)\n window.removeLoadingScreen = removeLoadingScreen;\n\n // Show critical load error using Swal2 (loaded in index.html before first.js)\n window.showCriticalLoadError = (title, text) => {\n clearTimeout(timeoutWarningTimer);\n initProgress.stopProgressAnimation();\n if (typeof Swal !== \"undefined\") {\n Swal.fire({\n allowOutsideClick: false,\n icon: \"error\",\n title: title || \"Loading Failed\",\n text: text || \"Please refresh the page to try again.\",\n confirmButtonText: \"Refresh\",\n }).then(() => window.location.reload());\n }\n };\n\n // Remove loading screen when ready for UI (compatibility page)\n window.addEventListener(\"threshold-ready-for-ui\", () => {\n removeLoadingScreen(); // Delegates to extracted function\n });\n};\n\n// Run immediately\ndocument.addEventListener(\"DOMContentLoaded\", setupInitialUI);\n\n// Add some CSS for the loading screen\nconst style = document.createElement(\"style\");\nstyle.textContent = `\n body, html {\n margin: 0;\n padding: 0;\n }\n\n .loading-container {\n position: fixed;\n top: 0;\n left: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n transition: opacity 0.4s ease;\n padding: 0;\n margin: 0;\n height: 100vh;\n width: 100vw;\n background: white;\n z-index: 10000;\n }\n\n .loading-content {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 20px;\n width: 400px;\n max-width: 90vw;\n padding: 20px;\n }\n\n .loading-spinner {\n border: 5px solid #f3f3f3;\n border-top: 5px solid #3498db;\n border-radius: 50%;\n width: 50px;\n height: 50px;\n animation: spin 1s linear infinite;\n }\n\n .loading-text {\n font-size: 18px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n color: #333;\n font-weight: 500;\n }\n\n .progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n }\n\n .progress-fill {\n height: 100%;\n background: #3498db;\n width: 0%;\n transition: width 0.3s ease;\n }\n\n .progress-percent {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n }\n\n .progress-step {\n font-size: 12px;\n color: #999;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n min-height: 16px;\n }\n\n .timeout-message {\n font-size: 14px;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n font-weight: 400;\n text-align: center;\n }\n\n .reload-button {\n background: #3498db;\n color: white;\n border: none;\n padding: 12px 24px;\n border-radius: 4px;\n font-size: 14px;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.2s ease;\n }\n\n .reload-button:hover {\n background: #2980b9;\n }\n\n .reload-button:active {\n background: #1f618d;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n\n .fade-out {\n opacity: 0;\n }\n\n /* Center-align Swal2 modal title and content for consistent alignment */\n .swal2-title,\n .swal2-html-container {\n text-align: center !important;\n }\n`;\ndocument.head.appendChild(style);\n\n// Export things that threshold.js might need\nexport { setupInitialUI, getBaseUrl };\n","type Phrases = Record<string, Record<string, string>>;\n\nexport interface LoadingScreenText {\n loadingText: string;\n timeoutMessage: string;\n reloadButton: string;\n}\n\n/**\n * Resolve the loading-screen strings for the experiment's language (as set in\n * index.html). Accepts either a language code (e.g. \"fr\") or, for backward\n * compatibility, the full English name. Returns null when nothing matches.\n */\nexport const localizeLoadingScreen = (\n phrases: Phrases,\n experimentLanguageName: string,\n): LoadingScreenText | null => {\n let lang: string | undefined;\n // _language now takes a language code; use it directly when it is one.\n if (\n experimentLanguageName &&\n Object.prototype.hasOwnProperty.call(\n phrases.EE_LanguageEnglishName,\n experimentLanguageName,\n )\n ) {\n lang = experimentLanguageName;\n } else {\n lang = Object.keys(phrases.EE_LanguageEnglishName).find(\n (key) => phrases.EE_LanguageEnglishName[key] === experimentLanguageName,\n );\n }\n if (!lang) return null;\n return {\n loadingText: phrases.RC_LoadingStudy[lang],\n timeoutMessage: phrases.RC_LoadingStudyTakingLonger[lang],\n reloadButton: phrases.RC_ReloadStudyButton[lang],\n };\n};\n"],"names":["initProgress","constructor","this","currentPercentage","listeners","progressIntervalId","startProgressAnimation","setInterval","increment","Math","random","min","notifyListeners","stopProgressAnimation","clearInterval","forEach","callback","window","dispatchEvent","CustomEvent","detail","percentage","round","reset","loadPhrases","async","username","experimentName","location","pathname","split","filter","Boolean","base","previewDeployBase","URLSearchParams","search","get","hostname","fetch","method","mode","getBaseUrl","pinnedRes","ok","Error","status","version","json","res","phrases","document","addEventListener","body","setAttribute","experimentLanguageDirection","String","toLowerCase","loadingElement","createElement","className","innerHTML","appendChild","phrasesLoaded","timeoutReached","maybeShowTimeoutUI","parentNode","timeoutMessage","getElementById","reloadButton","style","display","then","text","experimentLanguageName","lang","Object","prototype","hasOwnProperty","call","EE_LanguageEnglishName","keys","find","key","loadingText","RC_LoadingStudy","RC_LoadingStudyTakingLonger","RC_ReloadStudyButton","localizeLoadingScreen","experimentLanguage","querySelector","textContent","catch","err","console","warn","timeoutWarningTimer","setTimeout","reload","event","progressFill","progressPercent","width","removeLoadingScreen","clearTimeout","remove","showCriticalLoadError","title","Swal","fire","allowOutsideClick","icon","confirmButtonText","head"],"mappings":"gYAuEO,MAAMA,EAAe,IApErB,MACL,WAAAC,GACEC,KAAKC,kBAAoB,EACzBD,KAAKE,UAAY,GACjBF,KAAKG,mBAAqB,IAC5B,CAKA,sBAAAC,GACMJ,KAAKG,qBAETH,KAAKG,mBAAqBE,YAAY,KAEpC,GAAIL,KAAKC,kBAAoB,GAAI,CAG/B,MAAMK,EAAyB,EAAbC,KAAKC,SAAqB,EAC5CR,KAAKC,kBAAoBM,KAAKE,IAC5B,GACAT,KAAKC,kBAAoBK,GAE3BN,KAAKU,iBACP,GACC,KACL,CAKA,qBAAAC,GACMX,KAAKG,qBACPS,cAAcZ,KAAKG,oBACnBH,KAAKG,mBAAqB,KAE9B,CAKA,eAAAO,GACEV,KAAKE,UAAUW,QAASC,IACtBA,EAASd,KAAKC,qBAIM,oBAAXc,QACTA,OAAOC,cACL,IAAIC,YAAY,0BAA2B,CACzCC,OAAQ,CACNC,WAAYZ,KAAKa,MAAMpB,KAAKC,sBAKtC,CAKA,KAAAoB,GACErB,KAAKW,wBACLX,KAAKC,kBAAoB,CAC3B,GCvCIqB,EAAcC,UAClB,MAAOC,EAAUC,GAAkBV,OAAOW,SAASC,SAChDC,MAAM,KACNC,OAAOC,SACJC,OAvBWR,WACjB,MAAMS,EAAoB,IAAIC,gBAAgBlB,OAAOW,SAASQ,QAAQC,IACpE,kBAEF,GAAIH,EAAmB,OAAOA,EAC9B,GAAiC,cAA7BjB,O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