From 2108f32b23201ebddfb2db9f1692ca8e45737f71 Mon Sep 17 00:00:00 2001 From: Andre Kless Date: Tue, 23 Apr 2024 20:02:01 +0200 Subject: [PATCH] bugfix --- lang/ccm.lang.js | 2 +- lang/ccm.lang.min.js | 2 +- lang/ccm.lang.min.js.map | 2 +- lang/versions/ccm.lang-1.2.0.js | 2 +- lang/versions/ccm.lang-1.2.0.min.js | 2 +- lang/versions/ccm.lang-1.2.0.min.js.map | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/ccm.lang.js b/lang/ccm.lang.js index aa969084..4b2fae37 100644 --- a/lang/ccm.lang.js +++ b/lang/ccm.lang.js @@ -138,7 +138,7 @@ else if ( this.ccm.helper.isElement( content ) ) return translateElement( content ); else if ( this.ccm.helper.isObject( content )) - return translateDataset(); + return translateDataset( content ); else return translateElement(this.parent.element); } diff --git a/lang/ccm.lang.min.js b/lang/ccm.lang.min.js index 887cec75..86385e0b 100644 --- a/lang/ccm.lang.min.js +++ b/lang/ccm.lang.min.js @@ -1,2 +1,2 @@ -(()=>{const component={name:"lang",ccm:"https://ccmjs.github.io/ccm/versions/ccm-27.2.0.min.js",config:{css:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/styles.min.css"],dark:false,html:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/templates.mjs"],languages:{de:{de:"Deutsch",en:"Englisch"},en:{de:"German",en:"English"}},translations:{de:{},en:{}}},Instance:function(){let context;this.init=async()=>{context=(this.ccm.context.highestByProperty(this,"lang",true)||{}).lang;if(context)this.active=context.active;else{if(!this.active)this.active=document.body.getAttribute("lang");if(!this.active)this.active=navigator.language;this.active=this.active.split("-")[0].toLowerCase();if(!this.translations[this.active])this.active=Object.keys(this.translations)[0]}if(context){context.onchange.push(this.switch);this.onchange&&context.onchange.push(this.onchange);delete this.onchange}else this.onchange=this.onchange?[this.onchange]:[]};this.ready=async()=>{this.dark==="auto"&&this.element.classList.add("dark_auto");this.dark===true&&this.element.classList.add("dark_mode")};this.start=async()=>{if(context){this.element.innerHTML="";return}this.html.render(this.html.main(this.languages[this.active],this.active,this.switch),this.element)};this.getValue=()=>context?context.getValue():this.active;this.getContext=()=>context;this.observe=callback=>(context||this).onchange.push(callback);this.switch=lang=>{if(!this.translations[lang])return;if(context&&context.active!==lang)return context.switch(lang);this.active=lang;this.start();this.translate();this.onchange&&this.onchange.forEach((onchange=>onchange(lang)))};this.translate=content=>{if(typeof content==="string")return translateIndex(content);else if(this.ccm.helper.isElement(content))return translateElement(content);else if(this.ccm.helper.isObject(content))return translateDataset();else return translateElement(this.parent.element)};const translateIndex=index=>this.translations[this.active][index];const translateElement=elem=>{elem.querySelectorAll("*[data-lang]").forEach((elem=>{elem.dataset.lang.split(" ").forEach((index=>{if(!index)return;const split=index.split("-");let translation=this.ccm.helper.deepValue(this.translations[this.active],split[0]);if(!translation)return;if(split.length>2){let i=2;translation=translation.replace(/%%/g,(match=>split[i++]||match))}if(split[1])elem.setAttribute(split[1],translation);else elem.innerHTML=translation}))}))};const translateDataset=data=>{for(const key in data)if(data[key+"-"+this.active])data[key]=data[key+"-"+this.active]}}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||[""])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){(c="latest"?window.ccm:window.ccm[c]).component(component);document.head.removeChild(a)};a.src=component.ccm.url}})(); +(()=>{const component={name:"lang",ccm:"https://ccmjs.github.io/ccm/versions/ccm-27.2.0.min.js",config:{css:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/styles.min.css"],dark:false,html:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/templates.mjs"],languages:{de:{de:"Deutsch",en:"Englisch"},en:{de:"German",en:"English"}},translations:{de:{},en:{}}},Instance:function(){let context;this.init=async()=>{context=(this.ccm.context.highestByProperty(this,"lang",true)||{}).lang;if(context)this.active=context.active;else{if(!this.active)this.active=document.body.getAttribute("lang");if(!this.active)this.active=navigator.language;this.active=this.active.split("-")[0].toLowerCase();if(!this.translations[this.active])this.active=Object.keys(this.translations)[0]}if(context){context.onchange.push(this.switch);this.onchange&&context.onchange.push(this.onchange);delete this.onchange}else this.onchange=this.onchange?[this.onchange]:[]};this.ready=async()=>{this.dark==="auto"&&this.element.classList.add("dark_auto");this.dark===true&&this.element.classList.add("dark_mode")};this.start=async()=>{if(context){this.element.innerHTML="";return}this.html.render(this.html.main(this.languages[this.active],this.active,this.switch),this.element)};this.getValue=()=>context?context.getValue():this.active;this.getContext=()=>context;this.observe=callback=>(context||this).onchange.push(callback);this.switch=lang=>{if(!this.translations[lang])return;if(context&&context.active!==lang)return context.switch(lang);this.active=lang;this.start();this.translate();this.onchange&&this.onchange.forEach((onchange=>onchange(lang)))};this.translate=content=>{if(typeof content==="string")return translateIndex(content);else if(this.ccm.helper.isElement(content))return translateElement(content);else if(this.ccm.helper.isObject(content))return translateDataset(content);else return translateElement(this.parent.element)};const translateIndex=index=>this.translations[this.active][index];const translateElement=elem=>{elem.querySelectorAll("*[data-lang]").forEach((elem=>{elem.dataset.lang.split(" ").forEach((index=>{if(!index)return;const split=index.split("-");let translation=this.ccm.helper.deepValue(this.translations[this.active],split[0]);if(!translation)return;if(split.length>2){let i=2;translation=translation.replace(/%%/g,(match=>split[i++]||match))}if(split[1])elem.setAttribute(split[1],translation);else elem.innerHTML=translation}))}))};const translateDataset=data=>{for(const key in data)if(data[key+"-"+this.active])data[key]=data[key+"-"+this.active]}}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||[""])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){(c="latest"?window.ccm:window.ccm[c]).component(component);document.head.removeChild(a)};a.src=component.ccm.url}})(); //# sourceMappingURL=ccm.lang.min.js.map \ No newline at end of file diff --git a/lang/ccm.lang.min.js.map b/lang/ccm.lang.min.js.map index ca4465da..ff81cff3 100644 --- a/lang/ccm.lang.min.js.map +++ b/lang/ccm.lang.min.js.map @@ -1 +1 @@ -{"version":3,"names":["component","name","ccm","config","css","dark","html","languages","de","en","translations","Instance","context","this","init","async","highestByProperty","lang","active","document","body","getAttribute","navigator","language","split","toLowerCase","Object","keys","onchange","push","switch","ready","element","classList","add","start","innerHTML","render","main","getValue","getContext","observe","callback","translate","forEach","content","translateIndex","helper","isElement","translateElement","isObject","translateDataset","parent","index","elem","querySelectorAll","dataset","translation","deepValue","length","i","replace","match","setAttribute","data","key","b","version","join","window","files","components","url","c","a","createElement","head","appendChild","integrity","crossorigin","onload","removeChild","src"],"sources":["ccm.lang.js"],"mappings":"AAWA,MACE,MAAMA,UAAY,CAChBC,KAAM,OACNC,IAAK,yDACLC,OAAQ,CAENC,IAAO,CAAE,WAAY,2EACrBC,KAAQ,MACRC,KAAQ,CAAE,WAAY,0EACtBC,UAAa,CACXC,GAAM,CACJA,GAAM,UACNC,GAAM,YAERA,GAAM,CACJD,GAAM,SACNC,GAAM,YAIVC,aAAgB,CACdF,GAAM,CAAC,EACPC,GAAM,C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AOnE,KAAK,OAAOmE,OAAOnE,IAAIoE,MAAMJ,GAAG,OAAOG,OAAOnE,IAAIoE,MAAMJ,GAAGlE,WAAWkE,EAAEG,OAAOnE,KAAKmE,OAAOnE,IAAIqE,WAAWvE,UAAUC,QAAQiE,EAAEhE,MAAMF,UAAUE,IAAIgE,EAAEhE,KAAK,kBAAkBF,UAAUE,MAAMF,UAAUE,IAAI,CAACsE,IAAIxE,UAAUE,MAAM,IAAIuE,GAAGzE,UAAUE,IAAIsE,IAAIV,MAAM,6CAA6C,CAAC,KAAK,GAAG,GAAGO,OAAOnE,KAAKmE,OAAOnE,IAAIuE,GAAGJ,OAAOnE,IAAIuE,GAAGzE,UAAUA,eAAe,CAAC,IAAI0E,EAAEvD,SAASwD,cAAc,UAAUxD,SAASyD,KAAKC,YAAYH,GAAG1E,UAAUE,IAAI4E,WAAWJ,EAAEX,aAAa,YAAY/D,UAAUE,IAAI4E,WAAW9E,UAAUE,IAAI6E,aAAaL,EAAEX,aAAa,cAAc/D,UAAUE,IAAI6E,aAAaL,EAAEM,OAAO,YAAYP,EAAE,SAASJ,OAAOnE,IAAImE,OAAOnE,IAAIuE,IAAIzE,UAAUA,WAAWmB,SAASyD,KAAKK,YAAYP,EAAE,EAAEA,EAAEQ,IAAIlF,UAAUE,IAAIsE,GAAG,CACn0B,EAjKF"} \ No newline at end of file +{"version":3,"names":["component","name","ccm","config","css","dark","html","languages","de","en","translations","Instance","context","this","init","async","highestByProperty","lang","active","document","body","getAttribute","navigator","language","split","toLowerCase","Object","keys","onchange","push","switch","ready","element","classList","add","start","innerHTML","render","main","getValue","getContext","observe","callback","translate","forEach","content","translateIndex","helper","isElement","translateElement","isObject","translateDataset","parent","index","elem","querySelectorAll","dataset","translation","deepValue","length","i","replace","match","setAttribute","data","key","b","version","join","window","files","components","url","c","a","createElement","head","appendChild","integrity","crossorigin","onload","removeChild","src"],"sources":["ccm.lang.js"],"mappings":"AAWA,MACE,MAAMA,UAAY,CAChBC,KAAM,OAC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,OAAOD,KACjB,GAAKA,KAAKC,IAAM,IAAMpD,KAAKK,QACzB8C,KAAKC,KAAOD,KAAKC,IAAM,IAAMpD,KAAKK,OAAO,CAEjD,GAEF,IAAIgD,EAAE,OAAOlE,UAAUC,MAAMD,UAAUmE,QAAQ,IAAInE,UAAUmE,QAAQC,KAAK,KAAK,IAAI,MAAM,GAAGC,OAAOnE,KAAK,OAAOmE,OAAOnE,IAAIoE,MAAMJ,GAAG,OAAOG,OAAOnE,IAAIoE,MAAMJ,GAAGlE,WAAWkE,EAAEG,OAAOnE,KAAKmE,OAAOnE,IAAIqE,WAAWvE,UAAUC,QAAQiE,EAAEhE,MAAMF,UAAUE,IAAIgE,EAAEhE,KAAK,kBAAkBF,UAAUE,MAAMF,UAAUE,IAAI,CAACsE,IAAIxE,UAAUE,MAAM,IAAIuE,GAAGzE,UAAUE,IAAIsE,IAAIV,MAAM,6CAA6C,CAAC,KAAK,GAAG,GAAGO,OAAOnE,KAAKmE,OAAOnE,IAAIuE,GAAGJ,OAAOnE,IAAIuE,GAAGzE,UAAUA,eAAe,CAAC,IAAI0E,EAAEvD,SAASwD,cAAc,UAAUxD,SAASyD,KAAKC,YAAYH,GAAG1E,UAAUE,IAAI4E,WAAWJ,EAAEX,aAAa,YAAY/D,UAAUE,IAAI4E,WAAW9E,UAAUE,IAAI6E,aAAaL,EAAEX,aAAa,cAAc/D,UAAUE,IAAI6E,aAAaL,EAAEM,OAAO,YAAYP,EAAE,SAASJ,OAAOnE,IAAImE,OAAOnE,IAAIuE,IAAIzE,UAAUA,WAAWmB,SAASyD,KAAKK,YAAYP,EAAE,EAAEA,EAAEQ,IAAIlF,UAAUE,IAAIsE,GAAG,CACn0B,EAjKF"} \ No newline at end of file diff --git a/lang/versions/ccm.lang-1.2.0.js b/lang/versions/ccm.lang-1.2.0.js index e7734f62..7ef3e019 100644 --- a/lang/versions/ccm.lang-1.2.0.js +++ b/lang/versions/ccm.lang-1.2.0.js @@ -139,7 +139,7 @@ else if ( this.ccm.helper.isElement( content ) ) return translateElement( content ); else if ( this.ccm.helper.isObject( content )) - return translateDataset(); + return translateDataset( content ); else return translateElement(this.parent.element); } diff --git a/lang/versions/ccm.lang-1.2.0.min.js b/lang/versions/ccm.lang-1.2.0.min.js index 9d19a5a1..b928ef8e 100644 --- a/lang/versions/ccm.lang-1.2.0.min.js +++ b/lang/versions/ccm.lang-1.2.0.min.js @@ -1,2 +1,2 @@ -(()=>{const component={name:"lang",version:[1,2,0],ccm:"https://ccmjs.github.io/ccm/versions/ccm-27.2.0.min.js",config:{css:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/styles.min.css"],dark:false,html:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/templates.mjs"],languages:{de:{de:"Deutsch",en:"Englisch"},en:{de:"German",en:"English"}},translations:{de:{},en:{}}},Instance:function(){let context;this.init=async()=>{context=(this.ccm.context.highestByProperty(this,"lang",true)||{}).lang;if(context)this.active=context.active;else{if(!this.active)this.active=document.body.getAttribute("lang");if(!this.active)this.active=navigator.language;this.active=this.active.split("-")[0].toLowerCase();if(!this.translations[this.active])this.active=Object.keys(this.translations)[0]}if(context){context.onchange.push(this.switch);this.onchange&&context.onchange.push(this.onchange);delete this.onchange}else this.onchange=this.onchange?[this.onchange]:[]};this.ready=async()=>{this.dark==="auto"&&this.element.classList.add("dark_auto");this.dark===true&&this.element.classList.add("dark_mode")};this.start=async()=>{if(context){this.element.innerHTML="";return}this.html.render(this.html.main(this.languages[this.active],this.active,this.switch),this.element)};this.getValue=()=>context?context.getValue():this.active;this.getContext=()=>context;this.observe=callback=>(context||this).onchange.push(callback);this.switch=lang=>{if(!this.translations[lang])return;if(context&&context.active!==lang)return context.switch(lang);this.active=lang;this.start();this.translate();this.onchange&&this.onchange.forEach((onchange=>onchange(lang)))};this.translate=content=>{if(typeof content==="string")return translateIndex(content);else if(this.ccm.helper.isElement(content))return translateElement(content);else if(this.ccm.helper.isObject(content))return translateDataset();else return translateElement(this.parent.element)};const translateIndex=index=>this.translations[this.active][index];const translateElement=elem=>{elem.querySelectorAll("*[data-lang]").forEach((elem=>{elem.dataset.lang.split(" ").forEach((index=>{if(!index)return;const split=index.split("-");let translation=this.ccm.helper.deepValue(this.translations[this.active],split[0]);if(!translation)return;if(split.length>2){let i=2;translation=translation.replace(/%%/g,(match=>split[i++]||match))}if(split[1])elem.setAttribute(split[1],translation);else elem.innerHTML=translation}))}))};const translateDataset=data=>{for(const key in data)if(data[key+"-"+this.active])data[key]=data[key+"-"+this.active]}}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||[""])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){(c="latest"?window.ccm:window.ccm[c]).component(component);document.head.removeChild(a)};a.src=component.ccm.url}})(); +(()=>{const component={name:"lang",version:[1,2,0],ccm:"https://ccmjs.github.io/ccm/versions/ccm-27.2.0.min.js",config:{css:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/styles.min.css"],dark:false,html:["ccm.load","https://ccmjs.github.io/akless-components/lang/resources/templates.mjs"],languages:{de:{de:"Deutsch",en:"Englisch"},en:{de:"German",en:"English"}},translations:{de:{},en:{}}},Instance:function(){let context;this.init=async()=>{context=(this.ccm.context.highestByProperty(this,"lang",true)||{}).lang;if(context)this.active=context.active;else{if(!this.active)this.active=document.body.getAttribute("lang");if(!this.active)this.active=navigator.language;this.active=this.active.split("-")[0].toLowerCase();if(!this.translations[this.active])this.active=Object.keys(this.translations)[0]}if(context){context.onchange.push(this.switch);this.onchange&&context.onchange.push(this.onchange);delete this.onchange}else this.onchange=this.onchange?[this.onchange]:[]};this.ready=async()=>{this.dark==="auto"&&this.element.classList.add("dark_auto");this.dark===true&&this.element.classList.add("dark_mode")};this.start=async()=>{if(context){this.element.innerHTML="";return}this.html.render(this.html.main(this.languages[this.active],this.active,this.switch),this.element)};this.getValue=()=>context?context.getValue():this.active;this.getContext=()=>context;this.observe=callback=>(context||this).onchange.push(callback);this.switch=lang=>{if(!this.translations[lang])return;if(context&&context.active!==lang)return context.switch(lang);this.active=lang;this.start();this.translate();this.onchange&&this.onchange.forEach((onchange=>onchange(lang)))};this.translate=content=>{if(typeof content==="string")return translateIndex(content);else if(this.ccm.helper.isElement(content))return translateElement(content);else if(this.ccm.helper.isObject(content))return translateDataset(content);else return translateElement(this.parent.element)};const translateIndex=index=>this.translations[this.active][index];const translateElement=elem=>{elem.querySelectorAll("*[data-lang]").forEach((elem=>{elem.dataset.lang.split(" ").forEach((index=>{if(!index)return;const split=index.split("-");let translation=this.ccm.helper.deepValue(this.translations[this.active],split[0]);if(!translation)return;if(split.length>2){let i=2;translation=translation.replace(/%%/g,(match=>split[i++]||match))}if(split[1])elem.setAttribute(split[1],translation);else elem.innerHTML=translation}))}))};const translateDataset=data=>{for(const key in data)if(data[key+"-"+this.active])data[key]=data[key+"-"+this.active]}}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||[""])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){(c="latest"?window.ccm:window.ccm[c]).component(component);document.head.removeChild(a)};a.src=component.ccm.url}})(); //# sourceMappingURL=ccm.lang-1.2.0.min.js.map \ No newline at end of file diff --git a/lang/versions/ccm.lang-1.2.0.min.js.map b/lang/versions/ccm.lang-1.2.0.min.js.map index 3bcec094..8704d324 100644 --- a/lang/versions/ccm.lang-1.2.0.min.js.map +++ b/lang/versions/ccm.lang-1.2.0.min.js.map @@ -1 +1 @@ -{"version":3,"names":["component","name","version","ccm","config","css","dark","html","languages","de","en","translations","Instance","context","this","init","async","highestByProperty","lang","active","document","body","getAttribute","navigator","language","split","toLowerCase","Object","keys","onchange","push","switch","ready","element","classList","add","start","innerHTML","render","main","getValue","getContext","observe","callback","translate","forEach","content","translateIndex","helper","isElement","translateElement","isObject","translateDataset","parent","index","elem","querySelectorAll","dataset","translation","deepValue","length","i","replace","match","setAttribute","data","key","b","join","window","files","components","url","c","a","createElement","head","appendChild","integrity","crossorigin","onload","removeChild","src"],"sources":["ccm.lang-1.2.0.js"],"mappings":"AAWA,MACE,MAAMA,UAAY,CAChBC,KAAM,OACNC,QAAS,CAAE,EAAG,EAAG,GACjBC,IAAK,yDACLC,OAAQ,CAENC,IAAO,CAAE,WAAY,2EACrBC,KAAQ,MACRC,KAAQ,CAAE,WAAY,0EACtBC,UAAa,CACXC,GAAM,CACJA,GAAM,UACNC,GAAM,YAERA,GAAM,CACJD,GAAM,SACNC,GAAM,YAIVC,aAAgB,CACdF,GAAM,CAAC,EACPC,GAAM,CAAC,IAGXE,SAAU,WAMR,IAAIC,QAMJC,KAAKC,KAAOC,UAGVH,SAAYC,KAAKX,IAAIU,QAAQI,kBAAmBH,KAAM,OAAQ,OAAU,CAAC,GAAII,KAG7E,GAAKL,QACHC,KAAKK,OAASN,QAAQM,WACnB,CACH,IAAML,KAAKK,OAASL,KAAKK,OAASC,SAASC,KAAKC,aAAc,QAC9D,IAAMR,KAAKK,OAASL,KAAKK,OAASI,UA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sE,GAAGzE,UAAUG,IAAIqE,IAAIT,MAAM,6CAA6C,CAAC,KAAK,GAAG,GAAGM,OAAOlE,KAAKkE,OAAOlE,IAAIsE,GAAGJ,OAAOlE,IAAIsE,GAAGzE,UAAUA,eAAe,CAAC,IAAI0E,EAAEtD,SAASuD,cAAc,UAAUvD,SAASwD,KAAKC,YAAYH,GAAG1E,UAAUG,IAAI2E,WAAWJ,EAAEV,aAAa,YAAYhE,UAAUG,IAAI2E,WAAW9E,UAAUG,IAAI4E,aAAaL,EAAEV,aAAa,cAAchE,UAAUG,IAAI4E,aAAaL,EAAEM,OAAO,YAAYP,EAAE,SAASJ,OAAOlE,IAAIkE,OAAOlE,IAAIsE,IAAIzE,UAAUA,WAAWoB,SAASwD,KAAKK,YAAYP,EAAE,EAAEA,EAAEQ,IAAIlF,UAAUG,IAAIqE,GAAG,CACn0B,EAlKF"} \ No newline at end of file +{"version":3,"names":["component","name","version","ccm","config","css","dark","html","languages","de","en","translations","Instance","context","this","init","async","highestByProperty","lang","active","document","body","getAttribute","navigator","language","split","toLowerCase","Object","keys","onchange","push","switch","ready","element","classList","add","start","innerHTML","render","main","getValue","getContext","observe","callback","translate","forEach","content","translateIndex","helper","isElement","translateElement","isObject","translateDataset","parent","index","elem","querySelectorAll","dataset","translation","deepValue","length","i","replace","match","setAttribute","data","key","b","join","window","files","components","url","c","a","createElement","head","appendChild","integrity","crossorigin","onload","removeChild","src"],"sources":["ccm.lang-1.2.0.js"],"mappings":"AAWA,MACE,MAAMA,UAAY,CAChBC,KAAM,OACNC,QAAS,CAAE,EAAG,EAAG,GACjBC,IAAK,yDACLC,OAAQ,CAENC,IAAO,CAAE,WAAY,2EACrBC,KAAQ,MACRC,KAAQ,CAAE,WAAY,0EACtBC,UAAa,CACXC,GAAM,CACJA,GAAM,UACNC,GAAM,YAERA,GAAM,CACJD,GAAM,SACNC,GAAM,YAIVC,aAAgB,CACdF,GAAM,CAAC,EACPC,GAAM,CAAC,IAGXE,SAAU,WAMR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