window.index_conversion=window.index_conversion||{},window.index_conversion.automatic_event=window.index_conversion.automatic_event||[];let dp_xdataSent=!1;const dp_scriptURL=document.currentScript?.src||window.location.href;window.dp_scriptURL=dp_scriptURL;var REPORT_URL="https://n8n.advisio.cz/webhook/cc0a1f34-d512-46b6-b8ad-f60750a019ea";function dp_sendData(){if(!dp_xdataSent){try{const e=new URL(dp_scriptURL).origin,t="undefined"!=typeof window&&window.screen&&window.screen.width&&window.screen.height?window.screen.width+"x"+window.screen.height:"unknown";index_conversion.currentURL=window.location.href||"",index_conversion.referrerURL=document.referrer||"",index_conversion.titleURL=document.title||"",index_conversion.screen_resolution=t,index_conversion.language=("undefined"!=typeof navigator&&navigator.language?navigator.language:"cs-cz").toLowerCase(),index_conversion.mobile="undefined"!=typeof navigator&&((navigator.userAgentData&&navigator.userAgentData.mobile)??/Mobi|Android/i.test(navigator.userAgent||"")),index_conversion.version="4",index_conversion.cookie=getSpecificCookies();const n=(index_conversion.automatic_event||[]).reduce(((e,t)=>e+(Array.isArray(t.items)?t.items.length:0)),0)>2,o=JSON.stringify(index_conversion);let r=`z=${Date.now()}`;if(!n)for(const e in index_conversion)if(Object.prototype.hasOwnProperty.call(index_conversion,e)){let t=index_conversion[e];"object"==typeof t&&null!==t&&(t=JSON.stringify(t)),r+=`&${encodeURIComponent(e)}=${encodeURIComponent(t)}`}const a=`${e}/index_gv3/?${r}&img=true`;window.dpTransport&&window.dpTransport.begin&&window.dpTransport.begin({where:"dp_sendData",url:a});const i=()=>{if(!window.fetch)return d();try{fetch(a,{method:n?"POST":"GET",mode:"no-cors",headers:{"Content-Type":"text/plain"},body:n?o:null,cache:"no-store",keepalive:!0}).then((()=>{window.dpTransport&&window.dpTransport.succeed("fetch")})).catch((e=>{window.dpTransport&&window.dpTransport.fail("fetch",e,{method:n?"POST":"GET",url:a}),d()}))}catch(e){window.dpTransport&&window.dpTransport.fail("fetch",e,{method:n?"POST":"GET",url:a}),d()}},d=()=>{const e=new XMLHttpRequest;e.open(n?"POST":"GET",a,!0),e.setRequestHeader("Content-Type","text/plain"),e.timeout=8e3,e.onreadystatechange=()=>{e.readyState===XMLHttpRequest.DONE&&(e.status>=200&&e.status<300||444===e.status?window.dpTransport&&window.dpTransport.succeed("xhr"):(window.dpTransport&&window.dpTransport.fail("xhr",new Error(`XHR state DONE error: ${e.status} ${e.statusText}`),{method:n?"POST":"GET",url:a,status:e.status,statusText:e.statusText}),s()))},e.onerror=()=>{window.dpTransport&&window.dpTransport.fail("xhr",new Error(`XHR failed: ${e.status} ${e.statusText}`),{method:n?"POST":"GET",url:a,status:e.status,statusText:e.statusText}),s()},e.ontimeout=()=>{window.dpTransport&&window.dpTransport.fail("xhr",new Error("XHR timeout"),{method:n?"POST":"GET",url:a}),s()},e.onabort=()=>{window.dpTransport&&window.dpTransport.fail("xhr",new Error("XHR aborted"),{method:n?"POST":"GET",url:a}),s()},e.send(n?o:null)},s=()=>{try{const e=new Image;let t=!1;const n=setTimeout((()=>{t||(t=!0,window.dpTransport&&window.dpTransport.fail("img",new Error("IMG timeout (~2s)"),{url:a}),window.dpTransport&&window.dpTransport.finalize())}),2e3);e.onload=()=>{t||(t=!0,clearTimeout(n),window.dpTransport&&window.dpTransport.succeed("img"))},e.onerror=()=>{t||(t=!0,clearTimeout(n),window.dpTransport&&window.dpTransport.fail("img",new Error("IMG onerror"),{url:a}),window.dpTransport&&window.dpTransport.finalize())},e.src=a}catch(e){window.dpTransport&&window.dpTransport.fail("img",e,{url:a}),window.dpTransport&&window.dpTransport.finalize()}};i(),dp_xdataSent=!0,window.index_conversion&&Array.isArray(window.index_conversion.automatic_event)&&(window.index_conversion.automatic_event=[])}catch(e){window.dpTransport&&window.dpTransport.fail("setup",e,{where:"dp_sendData.wrapper"}),window.dpTransport&&window.dpTransport.finalize(),console.error("dp_sendData() error:",e),dp_reportError(e,{where:"dp_sendData.wrapper"})}window.index_conversion.automatic_event=[]}}function dp_sendCustomEvent(e){try{if(!e||"object"!=typeof e)return;if(!e.event||"string"!=typeof e.event)return;window.index_conversion=window.index_conversion||{},window.index_conversion.automatic_event=window.index_conversion.automatic_event||[],dp_xdataSent=!1,window.index_conversion.automatic_event=[];const t={name:e.event,version:"custom"};e.user_data&&"object"==typeof e.user_data&&(window.index_conversion.user_data=window.index_conversion.user_data||{},Object.keys(e.user_data).forEach((t=>{const n=e.user_data[t];null!=n&&(window.index_conversion.user_data[t]="number"==typeof n?n:String(n))})));const n={};Object.keys(e).forEach((t=>{if("event"===t||"user_data"===t)return;const o=e[t];null!=o&&(n[t]="number"==typeof o?o:String(o))})),Object.keys(n).length>0&&(t.event_data=n),window.index_conversion.automatic_event.push(t),dp_sendData()}catch(t){dp_reportError(t,{where:"dp_sendCustomEvent",payload:e})}}function getSpecificCookies(){const e=["_ga","_fbp","_fbc","d5b8v3a2d7v3","_gcl_aw"],t=[],n=document?.cookie?.split(";")||[];for(const o of n){const[n,...r]=o.trim().split("=");let a=r.join("=");e.includes(n)&&("_gcl_aw"===n&&3===a.split(".").length?t.push(n+"="+a.split(".")[2]):t.push(n+"="+a))}return t.join("; ")}if(function(){function e(e,t){try{if(function(e){return!!e&&(e=String(e).toLowerCase(),["googlebot","adsbot","adsbot-google","mediapartners-google","bingbot","duckduckbot","slurp","baiduspider","yandexbot","facebot","ia_archiver","semrush","ahrefsbot","mj12bot","screaming frog","lighthouse","chrome-lighthouse","pagespeed","google-inspectiontool","gtmetrix","uptimerobot","headlesschrome","puppeteer","phantomjs","crawler","spider","bot/","bot "].some((function(t){return-1!==e.indexOf(t)})))}("undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent:""))return;if(!t||!t.where)return void console.warn("[DataPlus] Error without context - ignoring:",e);if(!["dp_sendData","dp_sendData.wrapper","dp_checkAndSendAiOverview","sendUsingImage","sendUsingXHR","sendUsingFetch","dp_sendCustomEvent"].includes(t.where))return void console.warn("[DataPlus] Error from unknown context - ignoring:",t.where,e);let n="",o="",r="";e&&"object"==typeof e?(n=String(e.message||""),o=String(e.stack||""),r=e.name||typeof e):(n=String(e),r="Error");let a=null,i=0;try{if(window.index_conversion?.automatic_event?.length>0){i=window.index_conversion.automatic_event.length;const e=window.index_conversion.automatic_event[i-1];a=e?.name||null}}catch(e){}const d="string"==typeof dp_scriptURL?dp_scriptURL:"undefined"!=typeof location?location.href:"",s="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent:"Unknown",c="undefined"!=typeof navigator&&navigator.language?navigator.language:"Unknown",u={fetch:"function"==typeof window.fetch,xhr:"function"==typeof window.XMLHttpRequest,image:"function"==typeof window.Image},p={online:"undefined"!=typeof navigator?navigator.onLine:null};try{const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;e&&(p.type=e.effectiveType||e.type||null,p.rtt=e.rtt||null,p.downlink=e.downlink||null)}catch(e){}const l={readyState:"undefined"!=typeof document?document.readyState:null,visibilityState:"undefined"!=typeof document?document.visibilityState:null};let w="*🚨 DataPlus Script Error*\n\n";if(w+=`*${r}:* \`${n}\`\n\n`,o&&(w+=`*Stack Trace:*\n\`\`\`\n${o}\n\`\`\`\n\n`),t||a){if(w+="*Context:*\n",t?.where&&(w+=`  • where: ${t.where}\n`),a&&(w+=`  • processing_event: ${a}\n`),t){const e={...t};delete e.where,Object.entries(e).forEach((([e,t])=>{null!=t&&("failures"===e&&Array.isArray(t)?(w+="  • failures:\n",t.forEach(((e,t)=>{w+=`    ${t+1}. Transport: ${e.step||"unknown"}\n`,e.name&&(w+=`       Error Type: ${e.name}\n`),e.message&&(w+=`       Message: ${e.message}\n`),e.extra&&(w+=`       Details: ${JSON.stringify(e.extra)}\n`)}))):w+=`  • ${e}: ${"object"==typeof t?JSON.stringify(t):t}\n`)}))}w+="\n"}w+="*Environment:*\n",w+=`  • Browser: fetch=${u.fetch}, xhr=${u.xhr}, img=${u.image}\n`,w+=`  • Network: online=${p.online}`,p.type&&(w+=`, type=${p.type}`,p.rtt&&(w+=`, rtt=${p.rtt}ms`)),w+="\n",w+=`  • Page: ${l.readyState}, visibility=${l.visibilityState}\n`,w+=`  • State: dp_xdataSent=${dp_xdataSent}, event_count=${i}\n\n`,w+=`*URL:* ${d}\n`,w+=`*User Agent:* ${s}\n`,w+=`*Language:* ${c}`;const _={text:w},m="string"==typeof urlForErrors&&urlForErrors?urlForErrors:"string"==typeof REPORT_URL&&REPORT_URL?REPORT_URL:"";if(!m)return;fetch(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_),mode:"cors",keepalive:!0}).catch((e=>{console.error("Error reporting failed:",e)}))}catch(e){console.error("dp_reportError failed:",e)}}!function(){var t=null;function n(e){return t={startedAt:Date.now(),url:e&&e.url||"",where:e&&e.where||"dp_sendData",failures:[],success:null},!0}window.dpTransport={begin:n,fail:function(e,o,r){t||n({}),t.failures.push({step:e,at:Date.now(),message:o&&o.message?String(o.message):String(o||""),name:o&&o.name?String(o.name):"",extra:r||null})},succeed:function(e){t&&(t.success={step:e,at:Date.now()},t=null)},finalize:function(){if(t){if(!t.success){var n={where:t.where,outcome:"failed",url:t.url,failures:t.failures};e("All transports failed: "+(t.failures.map((function(e){return e.step})).join(", ")||"none"),n)}t=null}}}}(),window.dp_reportError=e}(),window.dp_sendCustomEvent=window.dp_sendCustomEvent||dp_sendCustomEvent,function(e){const t=e.pushState,n=e.replaceState;e.pushState=function(...e){const n=t.apply(this,e);return dp_xdataSent=!1,dp_sendData(),n},e.replaceState=function(...e){const t=n.apply(this,e);return dp_xdataSent=!1,dp_sendData(),t},window.addEventListener("popstate",(()=>{dp_xdataSent=!1,dp_sendData()}))}(window.history),function e(){try{if(!document.referrer?.includes(".google."))return;const e=location.href,t="string"==typeof e?e.match(/#:~:text=([^&]*)/):null;if(t?.[1]){const e=decodeURIComponent(t[1]).normalize("NFD").replace(/[\u0300-\u036f\u2013]/g,"");window.index_conversion=window.index_conversion||{},window.index_conversion.automatic_event=window.index_conversion.automatic_event||[],window.index_conversion.automatic_event.push({name:"ai_overview",ai_overview_text:e}),dp_xdataSent=!1,dp_sendData()}}catch(e){dp_reportError(e,{where:"dp_checkAndSendAiOverview"})}window.dp_checkAndSendAiOverview=e}(),"undefined"!=typeof cookieStore){const e=t=>{for(const n of t.changed)if("_ga"===n.name){dp_xdataSent=!1,dp_sendData(),cookieStore.removeEventListener("change",e);break}};cookieStore.get("_ga").then((t=>{t||cookieStore.addEventListener("change",e)}))}document.addEventListener("DOMContentLoaded",dp_sendData),window.addEventListener("load",dp_sendData),window.addEventListener("beforeunload",dp_sendData),window.dpContext=window.dpContext||{platform:"unknown",eventMap:{view_item:["view_item","viewItem","ViewItem"],add_to_cart:["add_to_cart","addToCart","AddToCart"],remove_from_cart:["remove_from_cart","removeFromCart","RemoveFromCart"],view_cart:["view_cart","viewCart","ViewCart"],begin_checkout:["begin_checkout","beginCheckout","BeginCheckout"],add_shipping_info:["add_shipping_info","addShippingInfo","AddShippingInfo"],add_payment_info:["add_payment_info","addPaymentInfo","AddPaymentInfo"]},tax:1.21};const metaAuthor=document.querySelector("meta[name='author']"),dataWebAuthor=metaAuthor?.getAttribute("data-web-author");dataWebAuthor&&"BSSHOP s.r.o."===dataWebAuthor&&(window.dpContext.platform="bsshop"),window.dataLayer=window.dataLayer||[];const originalPush=window.dataLayer.push;window.dataLayer.push=function(...e){const t=originalPush.apply(this,e);return onDataLayerPush(...e),t};const itemsFromBasket=(e,t)=>{const n=dataLayer.find((e=>"product"===e.page_type));if("category"===t){const t=e=>{const t=localStorage.getItem(e);if(!t)return{};const n=t.split(" > ").map((e=>e.trim())),o={};return n.length>0&&(o.ca=n[0],n.slice(1).forEach(((e,t)=>{o[`c${t+2}`]=e}))),o};return e?.product_id?t(e.product_id):Array.isArray(e?.basketProducts)?e.basketProducts.map((e=>t(e.product_id))):{}}if(n){const t=e?.ecomm_category?e.ecomm_category.split(">").map((e=>e.trim())):[],n={id:e.product_id||null,nm:e.product_name||null,pr:e.product_price?.toFixed(2)||null,qt:"1",br:e.product_brand||null};return t.length>0&&(n.ca=t[0],t.slice(1).forEach(((e,t)=>{n[`c${t+2}`]=e}))),n}if(e?.product_id){const t=e,n={id:t.product_id||null,nm:t.product_name||null,pr:t.product_price?.toFixed(2)||null,qt:String(t.product_quantity)||null,br:t.product_brand||null},o=localStorage.getItem(t.product_id);if(o){const e=o.split(" > ").map((e=>e.trim()));e.length>0&&(n.ca=e[0],e.slice(1).forEach(((e,t)=>{n[`c${t+2}`]=e})))}return n}return Array.isArray(e?.basketProducts)?e.basketProducts.map((e=>{const t={id:e.product_id||null,nm:e.product_name||null,pr:e.product_price?.toFixed(2)||null,qt:String(e.product_quantity)||null,br:e.product_brand||null},n=localStorage.getItem(e.product_id);if(n){const e=n.split(" > ").map((e=>e.trim()));e.length>0&&(t.ca=e[0],e.slice(1).forEach(((e,n)=>{t[`c${n+2}`]=e})))}return t})):[]};function onDataLayerPush(...e){e.forEach((e=>{if(!e?.event)return;const t=e.event.toLowerCase().replaceAll("_","");let n=null;for(const e in window.dpContext.eventMap)if(window.dpContext.eventMap[e].some((e=>e.toLowerCase()===t))){n=e;break}if(!n)return;e.event.toLowerCase().replaceAll("_","");const o={};Object.keys(e).forEach((t=>{o[t.toLowerCase()]=e[t]}));const r=window.dataLayer&&Array.isArray(window.dataLayer)?window.dataLayer.find((e=>e&&e.page_type)):null;if("addtocart"===t||"removefromcart"===t){let o=e.event.charAt(0).toLowerCase()+e.event.slice(1);const a=e[`${o}_product_id`]||null,i=(r&&r.basketProducts&&Array.isArray(r.basketProducts)&&r.basketProducts.find((e=>String(e.product_id)===String(a))),{product_id:a,product_name:e[`${o}_product_name`]||null,product_price:"addtocart"===t?e[`${o}_value`]||null:e[`${o}_value`]/window.dpContext.tax||null,product_quantity:e[`${o}_quantity`]||null,product_brand:e[`${o}_product_brand`]||null});dp_xdataSent=!1,window.index_conversion.automatic_event.push({name:n,currency:e[`${o}_currency`]||null,value:"addtocart"===t?e[`${o}_value`]?.toFixed(2)||null:(e[`${o}_value`]/window.dpContext.tax)?.toFixed(2)||null,version:window.dpContext.platform,items:[{id:i.product_id,nm:i.product_name,pr:"number"==typeof i.product_price?i.product_price.toFixed(2):null,qt:String(i.product_quantity),br:i.product_brand,...itemsFromBasket(i,"category")}]}),dp_sendData()}else if("addshippinginfo"===t||"addpaymentinfo"===t){dp_xdataSent=!1;const o={name:n,currency:r?.currency||null,value:r?.ecomm_totalvalue?.toFixed(2)||null,version:window.dpContext.platform,items:[]};"addshippinginfo"===t&&(o.shipping_tier=e.name_s),"addpaymentinfo"===t&&(o.payment_type=e.name_s),r&&Array.isArray(r.basketProducts)&&r.basketProducts.length>0&&(o.items=itemsFromBasket(r)),window.index_conversion.automatic_event.push(o),dp_sendData()}}))}!function(){function e(){document.querySelectorAll("#DeliverySelector .item").forEach((e=>{e.dataset.listenerDelivery||(e.addEventListener("click",(()=>{const t=e.querySelector("* > label")?.textContent;t&&dataLayer.push({event:"add_shipping_info",name_s:t})})),e.dataset.listenerDelivery="true")}));document.querySelectorAll("#PaymentSelector .item").forEach((e=>{e.dataset.listenerPayment||(e.addEventListener("click",(()=>{const t=e.querySelector("* > label")?.textContent;t&&dataLayer.push({event:"add_payment_info",name_s:t})})),e.dataset.listenerPayment="true")}))}const t=document.querySelector("#OrderMaster");if(!t)return;new MutationObserver((()=>{e()})).observe(t,{childList:!0,subtree:!0}),e()}(),function(){const e=dataLayer.find((e=>"product"===e.page_type));if(e?.ecomm_category&&(localStorage.setItem(e.product_id,e.ecomm_category),e?.variants_ids&&e?.variants_ids.forEach((t=>{localStorage.setItem(t,e.ecomm_category)}))),e){dp_xdataSent=!1;const t={name:"view_item",currency:e.currency||null,value:e.ecomm_totalvalue?.toFixed(2)||null,version:window.dpContext.platform,items:[]};Object.keys(e).length>0&&(t.items=[itemsFromBasket(e)]),window.index_conversion.automatic_event.push(t),dp_sendData()}}(),function(){const e=dataLayer.find((e=>"cart"===e.page_type));if(e){dp_xdataSent=!1;const t={name:"view_cart",currency:e.currency||null,value:e.ecomm_totalvalue?.toFixed(2)||null,version:window.dpContext.platform,items:[]};Array.isArray(e.basketProducts)&&e.basketProducts.length>0&&(t.items=itemsFromBasket(e)),window.index_conversion.automatic_event.push(t),dp_sendData()}}(),function(){if("/objednat-krok2/"===window.location.pathname){const e=dataLayer.find((e=>"other"===e.page_type));if(e){dp_xdataSent=!1;const t={name:"begin_checkout",currency:e.currency||null,value:e.ecomm_totalvalue?.toFixed(2)||null,version:window.dpContext.platform,items:[]};Array.isArray(e.basketProducts)&&e.basketProducts.length>0&&(t.items=itemsFromBasket(e)),window.index_conversion.automatic_event.push(t),dp_sendData()}}}(),function(){const e=dataLayer.find((e=>"purchase"===e.page_type)),t=dataLayer.find((e=>"trackTrans"===e.event));if(e&&t){dp_xdataSent=!1;const n={name:"purchase",transaction_id:t.transactionId,currency:t.transactionCurrency||e.currency||null,value:Number(t.transactionTotal)?.toFixed(2)||e.ecomm_totalvalue?.toFixed(2)||null,tax:Number(t.transactionTax)?.toFixed(2)||null,shipping:Number(t.transactionShipping)?.toFixed(2)||null,version:window.dpContext.platform,items:Array.isArray(t.transactionProducts)?t.transactionProducts.map((e=>{const t={};if("string"==typeof e.category){e.category.split("->").map((e=>e.trim())).forEach(((e,n)=>{0===n?t.ca=e:t[`c${n+1}`]=e}))}return{id:e.id||null,nm:e.name||null,pr:null!=e.price?Number(e.price).toFixed(2):null,qt:String(e.quantity)||null,br:e.brand||null,...t}})):[]};window.index_conversion.automatic_event.push(n),dp_sendData()}}();