(function(){function b(){return window.location.search.includes("jdgm_debug=true")}const S=b();function d(...e){S&&console.log(...e)}window.jdgm=window.jdgm||{},window.jdgm.debugLog=d,d("[Judge.me Widget Loader] Script loaded and executing...");const y=".jdgm-widget[data-entry-point]",w=document.querySelectorAll(y);if(w.length===0){d("[Judge.me Widget Loader] No containers found with selector:",y);return}const c=w[0];d("[Judge.me Widget Loader] Found container, analyzing...");const m=c.dataset.entryPoint,v=c.dataset.entryKey;if(!m||!v)return;function W(){const e=window.jdgmSettings?.review_widget_revamp_enabled,s=c.dataset.productId,r=c.dataset.hasLegacy==="1",t=c.dataset.hasRevamp==="1";let a=null,o="",i="",n=!1;return e?t?(n=!0,r?(a=1,o="Revamp enabled + both data sources available",i="Loading revamp widget (preferred)"):(a=3,o="Revamp enabled + only revamp data",i="Loading revamp widget (only option available)")):r?(a=2,o="Revamp enabled + only legacy data",i="Falling back to legacy widget (revamp data not available)",n=!1):(a="edge-revamp-no-data",o="Revamp enabled + no data sources",i="Loading revamp widget for empty state",n=!0):r?(n=!1,t?(a=4,o="Revamp disabled + both data sources available",i="Showing legacy widget (preferred)"):(a=6,o="Revamp disabled + only legacy data",i="Showing legacy widget (only option available)")):t?(a=5,o="Revamp disabled + only revamp data",i="Falling back to revamp widget (legacy not available)",n=!0):(a="edge-no-data",o="Revamp disabled + no data sources",i="No widget will be shown (no data available)",n=!1),{scenarioId:a,scenarioName:o,decision:i,shouldLoadRevamp:n,metadata:{productId:s,revampEnabled:e,hasLegacyData:r,hasRevampData:t}}}function E(e){d("[Judge.me Widget Loader] Scenario "+e.scenarioId+": "+e.scenarioName),d("[Judge.me Widget Loader] Decision:",e.decision),d("[Judge.me Widget Loader] Debug info:",{...e.metadata,willLoadRevamp:e.shouldLoadRevamp});const s=window.jdgm?.data?.reviewWidget?.[e.metadata.productId],r=!!s?.reviews;e.metadata.hasRevampData!==r&&(console.warn("[Judge.me Widget Loader] ⚠️ Data mismatch detected!!"),console.warn("[Judge.me Widget Loader] Liquid says hasRevamp:",e.metadata.hasRevampData),console.warn("[Judge.me Widget Loader] JavaScript sees data:",r),console.warn("[Judge.me Widget Loader] Actual data:",s));const t=c.querySelector(".jdgm-legacy-widget-content");if(t){const a=t.innerHTML.trim().length;if(a>0&&a<=20){const o=t.innerHTML.trim().substring(0,50);d("[Judge.me Widget Loader] 📏 Legacy widget is small ("+a+' chars), treating as empty. Content: "'+o+'"')}}}function R(){const e=c.querySelector(".jdgm-legacy-widget-content");e&&(e.style.display=""),d("[Judge.me Widget Loader] ✅ Legacy widget displayed")}function J(){const e=c.querySelector(".jdgm-rev-widg");e&&(e.style.display="none",d("[Judge.me Widget Loader] 🙈 Hidden legacy widget element (.jdgm-rev-widg)")),d("[Judge.me Widget Loader] ⏳ Loading revamp widget...");const s=window.jdgm.CDN_BASE_URL,r=s+m;document.querySelector('script[src="'+r+'"]')||j(s,v).finally(()=>{const t=document.createElement("script");t.type="module",t.src=r,t.onload=()=>{d("[Judge.me Widget Loader] ✅ Revamp widget script loaded successfully")},t.onerror=()=>{console.error("[Judge.me Widget Loader] ❌ Failed to load revamp widget script")},document.head.appendChild(t)})}async function j(e,s){if(!(e+m).includes("localhost"))try{let u=function(p){const l=i[p];l&&(l.css&&l.css.forEach(g=>{const L=e+g;if(!document.querySelector('link[href="'+L+'"]')){const f=document.createElement("link");f.rel="stylesheet",f.href=L,document.head.appendChild(f)}}),l.imports&&l.imports.forEach(u))};var t=u;const a=e+"manifest.json?v="+Date.now(),i=await(await fetch(a)).json(),n=i[s];n&&n.css&&n.css.forEach(p=>{const l=e+p;if(!document.querySelector('link[href="'+l+'"]')){const g=document.createElement("link");g.rel="stylesheet",g.href=l,document.head.appendChild(g)}}),n&&n.imports&&n.imports.forEach(u)}catch(a){console.warn("Could not load manifest or CSS files:",a)}}const h=W();E(h),h.shouldLoadRevamp?J():R()})();