'use strict';const dotclear={msg:{},};dotclear.storeLocalData=(id,value=null)=>{localStorage.setItem(id,JSON.stringify(value));};dotclear.dropLocalData=(id)=>{localStorage.removeItem(id);};dotclear.readLocalData=(id)=>{const info=localStorage.getItem(id);if(info!==null){return JSON.parse(info);}
return info;};dotclear.getData=(id,clear=true,remove=false)=>{let data={};const element=document.getElementById(`${id}-data`);if(element){try{data=JSON.parse(element.textContent);if(remove){element.remove();}else if(clear){element.innerHTML='';}}catch(e){}}
return data;};dotclear.isObject=(item)=>item&&typeof item==='object'&&!Array.isArray(item);dotclear.isEmptyObject=(item)=>dotclear.isObject(item)&&Object.keys(item).length===0;dotclear.mergeDeep=(target,...sources)=>{if(!sources.length)return target;const source=sources.shift();if(dotclear.isObject(target)&&dotclear.isObject(source)){for(const key in source){if(dotclear.isObject(source[key])){if(!target[key])
Object.assign(target,{[key]:{},});dotclear.mergeDeep(target[key],source[key]);}else{Object.assign(target,{[key]:source[key],});}}}
return dotclear.mergeDeep(target,...sources);};dotclear.trimHtml=(html,options={})=>{const limit=options.limit||100;const preserveTags=typeof options.preserveTags==='undefined'?true:options.preserveTags;const wordBreak=typeof options.wordBreak==='undefined'?false:options.wordBreak;const suffix=options.suffix||'...';const moreLink=options.moreLink||'';const arr=html.replace(/</g,'\n<').replace(/>/g,'>\n').replace(/\n\n/g,'\n').replace(/^\n/g,'').replace(/\n$/g,'').split('\n');let sum=0;let row;let cut;let add;let tagMatch;let tagName;const tagStack=[];let more=false;let rowCut;for(let i=0;i<arr.length;i++){row=arr[i];rowCut=row.replace(/ +/g,' ');if(!row.length){continue;}
if(!row.startsWith('<')){if(sum>=limit){row='';}else if(sum+rowCut.length>=limit){cut=limit-sum;if(row[cut-1]===' '){while(cut){cut-=1;if(row[cut-1]!==' '){break;}}}else{add=row.substring(cut).split('').indexOf(' ');if(!wordBreak){if(add===-1){cut=row.length;}else{cut+=add;}}}
row=row.substring(0,cut)+suffix;if(moreLink){row+=`<a href="${moreLink}" style="display:inline">»</a>`;}
sum=limit;more=true;}else{sum+=rowCut.length;}}else if(!preserveTags){row='';}else if(sum>=limit){tagMatch=row.match(/[a-zA-Z]+/);tagName=tagMatch?tagMatch[0]:'';if(tagName){if(row.substring(0,2)==='</'){while(tagStack[tagStack.length-1]!==tagName&&tagStack.length){tagStack.pop();}
if(tagStack.length){row='';}
tagStack.pop();}else{tagStack.push(tagName);row='';}}else{row='';}}
arr[i]=row;}
return{html:arr.join('\n').replace(/\n/g,''),more,};};const storeLocalData=(id,value=null)=>{console.warn('Dotclear: storeLocalData() is deprecated. Use dotclear.storeLocalData().');dotclear.storeLocalData(id,value);};const dropLocalData=(id)=>{console.warn('Dotclear: dropLocalData() is deprecated. Use dotclear.dropLocalData().');dotclear.dropLocalData(id);};const readLocalData=(id)=>{console.warn('Dotclear: readLocalData() is deprecated. Use dotclear.readLocalData().');return dotclear.readLocalData(id);};const getData=(id,clear=true,remove=false)=>{console.warn('Dotclear: getData() is deprecated. Use dotclear.getData().');return dotclear.getData(id,clear,remove);};const isObject=(item)=>{console.warn('Dotclear: isObject() is deprecated. Use dotclear.isObject().');return dotclear.isObject(item);};const mergeDeep=(target,...sources)=>{console.warn('Dotclear: mergeDeep() is deprecated. Use dotclear.mergeDeep().');return dotclear.mergeDeep(target,...sources);};