window.__BECHTLE_SERVER_CTX__ = {"country":"FR","language":"fr","bid":"d859638595ac4744969e4dc8e35f4cd4_1793309950197_500dbdb88d000bbd1a6886eb40d2d066","vid":"0896dc704208433db3259c128646f6f0","user":{"context":"anonymous","xInternal":false,"isInCustomerContext":false,"isInternalUser":false},"tenant":"bechtle-comsoft-fr","xAbTesting":"","environment":"production"};
(function(){"use strict";function I(){document.cookie.indexOf("_dy_cs_gcg")<0&&(!(Math.floor(Math.random()*100)<5)||document.cookie.indexOf("autotest=true")>=0?f("Dynamic Yield Experiences"):f("Control Group"))}function f(n){const e=new Date(Date.now()+3154e10);document.cookie=`_dy_cs_gcg=${n};path=/;expires=${e};`}function U(){document.cookie="_dy_cs_gcg=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function S(){const n={},e={BECHTLE_SERVER_CTX_READY:[],CONSENT_CHANGE:[],PAGE_TYPE_READY:[],GTM_ID_READY:[],PERSISTENCE_ID_CHANGE:[],REALTIME_FILTER_READY:[],BEUS_TRACKING_CTX_READY:[]};return{get currentState(){return n},get listeners(){return e},on(t,o){const i=n[t];i!==void 0&&o(i),e[t].push({listener:o,isOnce:!1})},once(t,o){const i=n[t];if(i!==void 0)return o(i);e[t].push({listener:o,isOnce:!0})},off(t,o){const i=e[t].map(s=>s.listener).indexOf(o);e[t].splice(i,1)},dispatch(t,o){n[t]=o,e[t].forEach(({listener:s})=>{s(o)});const i=e[t].filter(({isOnce:s})=>!s).map(s=>s);e[t]=i},reset(t){n[t]=void 0,e[t].forEach(({listener:o})=>o(void 0))}}}const k=n=>typeof n=="string",L=(n,e,t)=>n&&k(n)?n.split(";").reduce((o,i)=>{const[s,u]=i.split("=").map(l=>l.trim());return o[decodeURIComponent(s)]=decodeURIComponent(u),o},{})[e]:t,r=[];for(let n=0;n<256;++n)r.push((n+256).toString(16).slice(1));function N(n,e=0){return(r[n[e+0]]+r[n[e+1]]+r[n[e+2]]+r[n[e+3]]+"-"+r[n[e+4]]+r[n[e+5]]+"-"+r[n[e+6]]+r[n[e+7]]+"-"+r[n[e+8]]+r[n[e+9]]+"-"+r[n[e+10]]+r[n[e+11]]+r[n[e+12]]+r[n[e+13]]+r[n[e+14]]+r[n[e+15]]).toLowerCase()}let m;const G=new Uint8Array(16);function H(){if(!m){if(typeof crypto=="undefined"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");m=crypto.getRandomValues.bind(crypto)}return m(G)}var b={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Y(n,e,t){var i,s,u;if(b.randomUUID&&!e&&!n)return b.randomUUID();n=n||{};const o=(u=(s=n.random)!=null?s:(i=n.rng)==null?void 0:i.call(n))!=null?u:H();if(o.length<16)throw new Error("Random bytes length must be >= 16");if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let l=0;l<16;++l)e[t+l]=o[l];return e}return N(o)}const B=()=>{if(document.cookie.includes("bechtle-p"))return L(document.cookie,"bechtle-p","");{const n=new Date;n.setMonth(n.getMonth()+13);const e=Y();return document.cookie=`bechtle-p=${e};path=/;expires=${n};`,e}},M=()=>{document.cookie="bechtle-p=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;"};function V(n){window.addEventListener("UC_EVENT",function(e){n(e.detail)})}const $=()=>{window.ACC=window.ACC||{config:{}}},y={portfolioType:0,showDynamicContent:!0};async function O(){return fetch("/api/beus/context/tracking",{credentials:"include",headers:new Headers({accept:"application/json"})}).then(async n=>n.status===200?await n.json():(console.error("Response status was not successful, using default TrackingContext"),y)).catch(()=>(console.error("Error fetching from BeUS, using default TrackingContext"),y))}const F=async n=>{var e,t,o,i;const s=n?await O():y;(t=(e=window.bechtle)==null?void 0:e.events)==null||t.dispatch("BEUS_TRACKING_CTX_READY",s);const{portfolioType:u,showDynamicContent:l}=s,_=u===1?"portfolio":u===2?"special_portfolio":"no_portfolio";(i=(o=window.bechtle)==null?void 0:o.analytics)==null||i.data("init_preferences",{event:"init_preferences",dc_preferences:{portfolio_type:_,show_dynamic_content:l}})},P=n=>{var e,t;const{language:o,country:i,vid:s,user:u}=n,{partnerId:l,hashedEMail:_,customer:g,context:E,seco:v,isProcurementUser:C,xInternal:T,xCustomer:R,cloudsActive:c}=u,a=T?"intern":"extern",d=C?"punchout":"public",h=E==="admin"?"employee-global":E.length!==0?E:"anonymous",p={shop_country:i,shop_language:o,vid:s,context:h,procurement:d,intern:a};c!==void 0&&(p.clouds=c),l&&(p.partner=l),_&&(p.logged_in="login",p.modus=v?"self":"care",p.hashed_email=_,p.be_nr=R||g),(t=(e=window.bechtle)==null?void 0:e.analytics)==null||t.data("init_session_data",{event:"init_session_data",session_data:p})},X=";",W="=",j="experience_impression",J=(n,e)=>({event:j,experience_id:n,experience_group:e}),K=n=>{var e,t;if(typeof n!="string"||!n)return;const o=n.split(X);for(const i of o){const[s,u]=i.split(W);s&&u&&((t=(e=window.bechtle)==null?void 0:e.analytics)==null||t.push(J(s,u)))}},q=["init_session_data","init_preferences"],z=()=>{var n;const e=window.dataLayer=(n=window.dataLayer)!=null?n:[],t=[{"gtm.start":new Date().getTime(),event:"gtm.js"}];let o=!1,i=!1;const s=()=>{for(i=!0;t.length;){const c=t.shift();c&&e.push(c)}},u=c=>i?e.push(c):t.push(c),l={};let _=[];const g=c=>c.every(a=>l[a]!==void 0),E=(c,a)=>{const d=typeof c=="function"?c(l):c;a?i=!0:o=!0,Array.isArray(d)?d.forEach(h=>e.push(h)):e.push(d),a&&s()},v=()=>{const{allDepsReady:c,stillWaiting:a}=_.reduce((d,h)=>(g(h.dependentFrom)?d.allDepsReady.push(h):d.stillWaiting.push(h),d),{allDepsReady:[],stillWaiting:[]});_=a,c.forEach(d=>E(d.callback,d.flush))},C=(c,a,d)=>{i&&!d&&e.push(a),l[c]=a,v()},T=(c,a)=>{var d,h;if(typeof c!="function"&&!a){const Q=c;c=x=>[x.init_session_data,Q,x.init_preferences]}const p={callback:c,dependentFrom:(d=a==null?void 0:a.dependentFrom)!=null?d:q,flush:(h=a==null?void 0:a.flush)!=null?h:!0};g(p.dependentFrom)?E(p.callback,p.flush):_.push(p)},R=window.dataLayer.push;return window.dataLayer.push=function(c){return i||o?(o&&(o=!1),R.apply(window.dataLayer,[c])):(t.push(c),t.length)},{data:C,ready:T,push:u,queue:t,waitingForData:_,dataStorage:l}},D=S(),A=z();window.bechtle?(window.bechtle.events=D,window.bechtle.analytics=A):window.bechtle={events:D,analytics:A},window.dispatchEvent(new CustomEvent("BECHTLE_LIB_READY"));const w=window.__BECHTLE_SERVER_CTX__;window.bechtle.events.dispatch("BECHTLE_SERVER_CTX_READY",w),window.dispatchEvent(new CustomEvent("BECHTLE_SERVER_CTX_READY",{detail:w})),P(w),F(!!w.user.hashedEMail),$(),K(w.xAbTesting),V(n=>{if(window.bechtle.events.dispatch("CONSENT_CHANGE",n),n["Persistence ID"]){const e=B();window.bechtle.events.dispatch("PERSISTENCE_ID_CHANGE",e)}else M(),window.bechtle.events.dispatch("PERSISTENCE_ID_CHANGE",null);n["Dynamic Yield"]?I():U()})})();
