function e(e){throw new Error("Unreachable")}const t="crec-props";async function n(){try{return await(window.ikea?.experiment?.init("J4wafuTQxMTEeN37Gq6iSq",{timeout:-1}))}catch(e){}}async function c(e){const t=await n();console.log(`Opti track call: ${e}`),void 0!==t&&t.track(e)}const a="pdec-vugc-min-count",i=["compact-feed-vugc","compact-feed-imc","long-feed-imc"];async function r(e){try{const t=await fetch(e);return t.ok?t.text():null}catch(e){return null}}function o(e){const t=new URLSearchParams(window.location.search),n=t.get("crecVariationKey"),c=t.get("crecFlagKey");n&&e.searchParams.set("variationKey",n),c&&e.searchParams.set("flagKey",c)}async function s(t,c,a){const i=(s=c,!!window.location.toString().includes("/p/")&&"compact-feed-vugc"===s);var s;let l,d=null;i&&(l=await n());const f=new URLSearchParams(window.location.search).get("ingkaDAMCteUrlFlag"),u=new URL(a);if(f&&u.searchParams.append("cteUrl",f),l){if(i){const e="feed054-static-vugc-on-pip",t=l.decide(e);u.searchParams.append("variationKey",t.variationKey),u.searchParams.append("flagKey",e)}o(u),d=await r(u.toString())}else o(u),d=await r(u.toString());if(d&&!d.includes("data-error"))try{const n=new DOMParser,a=n.parseFromString(d,"text/html").body.firstElementChild,i=a?.children,r=[];if(i)for(let e=0;e{const t=document.querySelectorAll(`[data-crec-component-type="${e}"]`);t.forEach((async(c,i)=>{if(l.has(c))return;l.add(c);const r=t.item(i);if(!(r&&r instanceof HTMLElement))return;const o=r.dataset,d=o.crecContentfragmenturl;if(!d){if(o.crecVugc123experimentvariant){r.style.display="block",r.style.visibility="hidden",r.style.height="0px";new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const e=await n();e?.decide(a),t.disconnect()}}))})).observe(r)}return}const f=window.screen.availHeight;let u=!1;new IntersectionObserver(((t,n)=>{t.forEach((async t=>{t.isIntersecting&&!u&&(u=!0,await s(r,e,d),n.disconnect())}))}),{rootMargin:`${f}px 0px ${f}px 0px`}).observe(r)}))}))}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",(e=>{d()})):d(),window.ikea||(window.ikea={}),window.ikea.contentRec||(window.ikea.contentRec={loadFragments:d});export{t as F,a as f,n as i,c as t,e as u};