nanomcf
Version:
Module Common Functions
3 lines (2 loc) • 24.8 kB
JavaScript
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e="undefined"!=typeof globalThis?globalThis:e||self).mcf=o()}(this,(function(){"use strict";function __awaiter(e,o,t,n){return new(t||(t=Promise))((function(i,r){function s(e){try{d(n.next(e))}catch(e){r(e)}}function l(e){try{d(n.throw(e))}catch(e){r(e)}}function d(e){var o;e.done?i(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(s,l)}d((n=n.apply(e,o||[])).next())}))}var ClientInfoResults,ClientTransferProtocols;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.Crash=0]="Crash",e[e.Priv=1]="Priv",e[e.Public=2]="Public"}(ClientInfoResults||(ClientInfoResults={})),function(e){e[e.Unknown=0]="Unknown",e[e.Plaintext=1]="Plaintext",e[e.Patch=2]="Patch"}(ClientTransferProtocols||(ClientTransferProtocols={}));var moduleCommonFunctions={version:2,switchFullscreen:!1,loadedLibs:[],loadingLibs:[],loadedCss:[],tempBinds:[],binds:[],modalBinds:[],loadedAudioFiles:[],windowHistoryXhr:null,isInLcTab:!0,commonUniversalModalOpen:!1,prefDarkTheme:!1,prefFriendsPanel:!1,universalModalMode:"url",templates:[],evSignalReadyFn:[],signalIsReady:!1,registeredFunctions:[],registeredScripts:[],loadingPromises:[],minTemplates:!0,signalsToDispatch:[],tempTitleOn:!1,tempTitleTimer:null,tempTitleMode:!1,uniqueEvents:[],tooltips:[],observedNodes:[],observerInitialized:!1,callsQue:[],disposeQue:[],debugObservers:[],eventAborter:new AbortController,lastBodyScroll:{x:0,y:0},differ:null,ini:function(e){},requireLibCompleted:function(e){for(var o=0;o<moduleCommonFunctions["requireLibCompletedCallbacks_"+e].length;o++)moduleCommonFunctions["requireLibCompletedCallbacks_"+e][o]();moduleCommonFunctions["requireLibCompletedCallbacks_"+e]=[]},clientHash:()=>new Promise((e=>{mcf.requireLib("game",(()=>{try{window.FingerprintJS.load().then((e=>e.get())).then((o=>{e(o.visitorId)}))}catch(o){return void e("")}}))})),getUserAgent:()=>navigator.userAgent,clientStorage:()=>{var e=localStorage.getItem("clientHash");return!e||e.length<=0?(e=mcf.iiid(),localStorage.setItem("clientHash",e),e):e},clientInfo:()=>new Promise((e=>{mcf.requireLib("info",(()=>{try{window.getInfo().then((o=>{o&&o.isPrivate?e(ClientInfoResults.Priv):e(ClientInfoResults.Public)}))}catch(o){return void e(ClientInfoResults.Crash)}}))})),callFnIfDefined:(e,...o)=>{""!==e&&"function"==typeof window[e]&&window[e](...o)},displayInfo:()=>({width:Math.round(window.visualViewport.width),height:Math.round(window.visualViewport.height)}),eval:e=>{try{new Function(`return (() => { ${e} })();`)()}catch(e){}},requireCssArr:(e,o=()=>{})=>{Array.isArray(e)||(e=e.trim().replaceAll(" ","").split(","));for(var t=mcf.iiid(),n=[],i=0;i<e.length;i++)n[i]=!1;window[t+"_data"]=n,window[t+"_fn"]=e=>{window[t+"_data"][e]=!0,void 0===window[t+"_data"].find((e=>!1===e))&&o()};for(i=0;i<e.length;i++){let o=i;mcf.requireCss(e[i],(()=>{window[t+"_fn"](o)}))}},debugCancelAll:()=>{for(var e of mcf.debugObservers)e.disconnect();mcf.debugObservers=[]},debugObserveProperty:(e,o)=>{var t=new MutationObserver((function(e){e.forEach((function(e){e.attributeName==o&&console.log("Debug observe property: ","old value",e.oldValue,"new value",e.target.getAttribute(o),"mutation",e)}))}));return t.observe(e,{attributes:!0,attributeOldValue:!0}),mcf.debugObservers.push(t),t},requireLibArrAsync:(e,...o)=>__awaiter(void 0,[e,...o],void 0,(function*(e,o=()=>{},t=!1,n=!0){Array.isArray(e)||(e=e.trim().replaceAll(" ","").split(","));var i=window.localStorage.getItem("appVersion");window.mcfDebug&&(i=mcf.guid());const r=[];for(const s of e)if(moduleCommonFunctions.loadedLibs.includes(s))o();else if(moduleCommonFunctions.loadingLibs.includes(s)||t)if(t){moduleCommonFunctions["requireLibCompletedCallbacks_"+s]=[o];let e="/Scripts/"+s+`.js?v=${i}`;n||(e=s);const t=new Promise(((o,t)=>{const n=document.createElement("script");document.body.appendChild(n),n.onload=o,n.onerror=t,n.async=!1,n.src=e}));mcf.loadingPromises[s]=t,r.push({promise:t,callback:()=>{moduleCommonFunctions.loadedLibs.push(s),moduleCommonFunctions.requireLibCompleted(s)}})}else moduleCommonFunctions["requireLibCompletedCallbacks_"+s].push(o),moduleCommonFunctions.loadingPromises[s]&&(yield moduleCommonFunctions.loadingPromises[s]);else{moduleCommonFunctions.loadingLibs.push(s),moduleCommonFunctions["requireLibCompletedCallbacks_"+s]=[o];let e="/Scripts/"+s+`.js?v=${i}`;n||(e=s);const t=new Promise(((o,t)=>{const n=document.createElement("script");document.body.appendChild(n),n.onload=o,n.onerror=t,n.async=!1,n.src=e}));mcf.loadingPromises[s]=t,r.push({promise:t,callback:()=>{moduleCommonFunctions.loadedLibs.push(s),moduleCommonFunctions.requireLibCompleted(s)}})}if(r.length>0){const e=r.map((e=>e.promise));yield Promise.allSettled(e);for(const e of r)e.callback()}})),requireLibArr:(e,o=()=>{})=>{Array.isArray(e)||(e=e.trim().replaceAll(" ","").split(","));for(var t=mcf.iiid(),n=[],i=0;i<e.length;i++)n[i]=!1;window[t+"_data"]=n,window[t+"_fn"]=e=>{window[t+"_data"][e]=!0,void 0===window[t+"_data"].find((e=>!1===e))&&o()};for(i=0;i<e.length;i++){let o=i;mcf.requireLib(e[i],(()=>{window[t+"_fn"](o)}))}},bodyToggleScroll:e=>{var o=window.innerWidth>document.documentElement.clientWidth,t=document.body.style||window.getComputedStyle(document.body,"");if(o=o||"visible"==t.overflow||"visible"==t.overflowY||o&&"auto"==t.overflow||o&&"auto"==t.overflowY){if(!e)return mcf.lastBodyScroll={x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop},document.body.style.top=`-${mcf.lastBodyScroll.y}px`,document.body.style.position="fixed",document.body.style.width="100%",void(document.body.style.overflowY="scroll");var n=mcf.lastBodyScroll.y,i=mcf.lastBodyScroll.x;document.body.style.position="",document.body.style.top="",document.body.style.overflowY="auto",window.scrollTo({left:i,top:n,behavior:"instant"})}},getErrorsInInterval:e=>0,getErrors:(e=!1)=>{var o=localStorage.getItem("serverErrors"),t=[];return o&&o.length>0&&(t=JSON.parse(o)),e&&localStorage.setItem("serverErrors",""),t},storeError:e=>{var o=localStorage.getItem("serverErrors"),t=[];o&&o.length>0&&(t=JSON.parse(o)),t.push({date:new Date,exception:JSON.parse(e)}),localStorage.setItem("serverErrors",JSON.stringify(t)),mcf.getErrorsInInterval(10)>=10&&(window.location="/bugsplash")},polyfill:(e,o)=>{},setAppVersion:e=>{window.localStorage.setItem("appVersion",e)},refreshStaticAssets:()=>{window.localStorage.setItem("appVersion",mcf.iiid()),location.reload(!0)},log:e=>{console.log(e)},focus:e=>{const o=document.getElementById(e);if(o){o.focus();const e=o=>{if(!o||o===document.body)return document.body;const t=getComputedStyle(o).overflowY;return("auto"===t||"scroll"===t)&&o.scrollHeight>o.clientHeight?o:e(o.parentNode)},t=e(o);if(t){const e=o.getBoundingClientRect(),n=t.getBoundingClientRect();if(!(e.top>=n.top&&e.bottom<=n.bottom)){const o=e.top-n.top+t.scrollTop;t.scrollTo({top:o-t.clientHeight/2+e.height/2,behavior:"instant"})}}else o.scrollIntoView({behavior:"instant",block:"nearest"});return!0}return!1},select:e=>{var o=document.getElementById(e);o&&o.select()},copy:e=>{if(window.clipboardData&&window.clipboardData.setData)return window.clipboardData.setData("Text",e);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){var o=document.createElement("textarea");o.textContent=e,o.style.position="fixed",document.body.appendChild(o),o.select();var t=!1;try{document.execCommand("copy"),t=!0}catch(e){t=!1}finally{document.body.removeChild(o)}if(t)return!0;try{return navigator.clipboard.writeText(e).then((function(){return!0}),(function(e){return!1})),!0}catch(e){return!1}}},requireLibAsync:function(e){return __awaiter(this,arguments,void 0,(function*(e,o=function(){},t=!1,n=!0){if(Array.isArray(e)||e.includes(","))return yield mcf.requireLibArrAsync(e,o,t,n);var i=window.localStorage.getItem("appVersion");if(window.mcfDebug&&(i=mcf.guid()),moduleCommonFunctions.loadedLibs.includes(e))o();else if(moduleCommonFunctions.loadingLibs.includes(e)||t)if(t){moduleCommonFunctions["requireLibCompletedCallbacks_"+e]=[o];r="/Scripts/"+e+`.js?v=${i}`;n||(r=e);s=new Promise(((e,o)=>{const t=document.createElement("script");document.body.appendChild(t),t.onload=e,t.onerror=o,t.async=!1,t.src=r}));mcf.loadingPromises[e]=s,yield s,moduleCommonFunctions.loadedLibs.push(e),moduleCommonFunctions.requireLibCompleted(e)}else moduleCommonFunctions["requireLibCompletedCallbacks_"+e].push(o),moduleCommonFunctions.loadingPromises[e]&&(yield moduleCommonFunctions.loadingPromises[e]);else{moduleCommonFunctions.loadingLibs.push(e),moduleCommonFunctions["requireLibCompletedCallbacks_"+e]=[o];var r="/Scripts/"+e+`.js?v=${i}`;n||(r=e);var s=new Promise(((e,o)=>{const t=document.createElement("script");document.body.appendChild(t),t.onload=e,t.onerror=o,t.async=!1,t.src=r}));mcf.loadingPromises[e]=s,yield s,moduleCommonFunctions.loadedLibs.push(e),moduleCommonFunctions.requireLibCompleted(e)}}))},requireLib:function(e,o=function(){},t=!1,n=!0){if(Array.isArray(e)||e.includes(","))return mcf.requireLibArr(e,o);var i=window.localStorage.getItem("appVersion"),r=e;if(window.mcfDebug&&(i=mcf.guid()),moduleCommonFunctions.loadedLibs.includes(r))o();else if(moduleCommonFunctions.loadingLibs.includes(r)||t)if(t){moduleCommonFunctions["requireLibCompletedCallbacks_"+r]=[o];s="/Scripts/"+r+`.js?v=${i}`;n||(s=e),new Promise(((e,o)=>{const t=document.createElement("script");document.body.appendChild(t),t.onload=e,t.onerror=o,t.async=!0,t.src=s})).then((()=>{moduleCommonFunctions.loadedLibs.push(r),moduleCommonFunctions.requireLibCompleted(r)}))}else moduleCommonFunctions["requireLibCompletedCallbacks_"+r].push(o);else{moduleCommonFunctions.loadingLibs.push(r),moduleCommonFunctions["requireLibCompletedCallbacks_"+r]=[o];var s="/Scripts/"+e+`.js?v=${i}`;n||(s=e),new Promise(((e,o)=>{const t=document.createElement("script");document.body.appendChild(t),t.onload=e,t.onerror=o,t.async=!0,t.src=s})).then((()=>{moduleCommonFunctions.loadedLibs.push(r),moduleCommonFunctions.requireLibCompleted(r)}))}},openInNewTab:(e,o=!0)=>{var t=window.open(e,"_blank");t&&o&&t.focus()},messageCompress:(e,o)=>__awaiter(void 0,void 0,void 0,(function*(){if(o.length<100)return{data:o,protocol:ClientTransferProtocols.Plaintext};yield mcf.requireLibAsync("diffpatch"),mcf.differ||(mcf.differ=new window.diff_match_patch);var t=mcf.differ,n=t.patch_make(e||"",o||"");return{data:t.patch_toText(n),protocol:ClientTransferProtocols.Patch}})),fetchText:e=>__awaiter(void 0,void 0,void 0,(function*(){return(yield fetch(e)).text()})),requireCssAsync:function(e){return __awaiter(this,arguments,void 0,(function*(e,o=function(){},t="commonCss",n="append"){if(Array.isArray(e)||e.includes(","))return mcf.requireCssArr(e,o);var i;if("body"===t)moduleCommonFunctions.loadedCss.includes(e)?o():i=new Promise(((o,t)=>{var n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.onload=o,n.href="/Content/"+e+".css?v="+window.lcVer,document.body.appendChild(n),moduleCommonFunctions.loadedCss.push(e)}));else if(!document.getElementById(t)){let e=document.createElement("div");e.id=t,document.head.appendChild(e)}"force"!==n&&"replace"!==n||(i=new Promise(((o,n)=>{var i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.onload=o,i.href="/Content/"+e+".css?v="+window.lcVer,document.getElementById(t).innerHTML=i.outerHTML,moduleCommonFunctions.loadedCss.push(e)}))),moduleCommonFunctions.loadedCss.includes(e)?o():i=new Promise(((o,n)=>{var i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.onload=o,i.href="/Content/"+e+".css?v="+window.lcVer,document.getElementById(t).appendChild(i),moduleCommonFunctions.loadedCss.push(e)})),i&&(yield i.then((()=>{o()})))}))},requireCss:function(e,o=function(){},t="commonCss",n="append"){if(Array.isArray(e)||e.includes(","))return mcf.requireCssArr(e,o);if("body"===t)if(moduleCommonFunctions.loadedCss.includes(e))o();else{let t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.onload=()=>{o()},t.href="/Content/"+e+".css?v="+window.lcVer,document.body.appendChild(t),moduleCommonFunctions.loadedCss.push(e)}else if(!document.getElementById(t)){let e=document.createElement("div");e.id=t,document.head.appendChild(e)}if("force"===n||"replace"===n){let n=document.createElement("link");return n.rel="stylesheet",n.type="text/css",n.onload=()=>{o()},n.href="/Content/"+e+".css?v="+window.lcVer,document.getElementById(t).innerHTML=n.outerHTML,void moduleCommonFunctions.loadedCss.push(e)}if(moduleCommonFunctions.loadedCss.includes(e))o();else{let n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.onload=()=>{o()},n.href="/Content/"+e+".css?v="+window.lcVer,document.getElementById(t).appendChild(n),moduleCommonFunctions.loadedCss.push(e)}},requireOnce:function(e,o=function(){}){window.moduleCore.isModuleLoaded(e)?o():window.moduleCore.registerModule(e,o)},execFn:(e,...o)=>{console.log("exec fn called"),console.log(e);var t=moduleCommonFunctions.registeredFunctions.filter((o=>o.Name===e));return console.log(t),t.length>0?t[0].Fn(...o):0},canSignal:()=>void 0!==window.signalConnection&&"Connected"===window.signalConnection.state,execFnCallback:(e,o=()=>{},...t)=>{var n=moduleCommonFunctions.registeredFunctions.filter((o=>o.Name===e));n.length>0&&(n[0].Fn(...t),o())},preregisterFn:e=>{moduleCommonFunctions.registeredFunctions.some((o=>o.Name===e))||moduleCommonFunctions.registeredFunctions.push({Name:e,Fn:()=>{},Ready:!1,ReadyQue:[]})},registerFn:(e,o)=>{var t=moduleCommonFunctions.registeredFunctions.filter((o=>o.Name===e));if(t.length>0&&(t[0].Fn=o,t[0].Ready=!0,t[0].ReadyQue.length>0))for(var n=0;n<t[0].ReadyQue.length;n++)t[0].ReadyQue[n]()},getElementValue:e=>{let o=document.getElementById(e);return null==o?void 0:o.value},decode:e=>{var o=document.createElement("textarea");return o.innerHTML=e,o.value},hideAllTooltips:()=>{mcf.requireLib("popper2",(()=>{mcf.requireLib("tippy",(()=>{window.tippy.hideAll({duration:0})}))}))},setupObserver:()=>{mcf.observerInitialized=!0,new MutationObserver((function(e){e.forEach((function(e){e.removedNodes.forEach((function(e){if(e.id)for(var o=0;o<mcf.observedNodes.length;o++){var t=mcf.observedNodes[o];e.id.includes("_container")&&mcf.toast("info",e.id),e.id===t.nodeId&&(t.onDelete(t.data),mcf.observedNodes.splice(o,1))}}))}))})).observe(document.getElementById("mcfRoot"),{subtree:!0,childList:!0})},watchNode:(e,o={},t=e=>{})=>{},disposeAllTooltips:()=>{for(var e of mcf.tooltips)e.inst.destroy(),window[`tooltipInst_${e.elId}`]=void 0,delete window[`tooltipInst_${e.elId}`];mcf.tooltips=[]},tooltipDispose:e=>{var o=mcf.tooltips.find((o=>o.elId===e));if(o){o.inst.destroy(),window[`tooltipInst_${e}`]=void 0,delete window[`tooltipInst_${e}`];var t=mcf.tooltips.indexOf(o);return mcf.tooltips=mcf.tooltips.splice(t,1),!0}return!1},tooltip:(e,o,...t)=>__awaiter(void 0,[e,o,...t],void 0,(function*(e,o,t=!1,n="top",i=!1){if(yield mcf.requireLibAsync("popper2"),yield mcf.requireLibAsync("tippy"),mcf.tooltips.filter((o=>o.elId===e)).forEach((e=>{e&&e.inst&&e.inst.setContent&&e.inst.setContent(o)})),!mcf.tooltips.find((o=>o.elId===e))){window[`tooltipInst_${e}`]=window.tippy(document.getElementById(e),{content:o,allowHTML:!0,hideOnClick:!t,placement:n.toLowerCase()}),window[`tooltipInst_${e}`].show();var r={inst:window[`tooltipInst_${e}`],elId:e,persistent:i};return mcf.tooltips.push(r),r}})),navigateTo:(e="/")=>{window.location=e},reload:()=>{location.reload()},delay:e=>__awaiter(void 0,void 0,void 0,(function*(){yield new Promise((o=>setTimeout(o,e)))})),execScript:(e,o=(e={})=>{})=>{var t=document.createElement("script");t.async=!0,t.src="/scripts/owned/"+e+".js",t.onload=()=>{fetch("/scripts/owned/"+e+".js").then((e=>e.text())).then((e=>{console.log(e);var t=new Function(e).call(null,1,2);o(t)}))},document.body.appendChild(t)},requireFn:(name,callback=e=>{},argsObj)=>{if(window.fnArgs=argsObj,moduleCommonFunctions.registeredFunctions.some((e=>e.Name===name))){var fn=moduleCommonFunctions.registeredFunctions.find((e=>e.Name===name));void 0!==fn&&(fn.Ready?callback({}):fn.ReadyQue.push(callback));var script=mcf.registeredScripts.find((e=>e.key===name));void 0!==script&&(console.log("fn ------------------ backup"),console.log(script),window.fnArgs=argsObj,eval(script.script))}else moduleCommonFunctions.preregisterFn(name),new Promise(((resolve,reject)=>{var script=document.createElement("script");script.onerror=reject,script.async=!0,script.src="/scripts/owned/"+name+".js",script.onload=()=>{setTimeout((()=>{window.fnArgs=argsObj,console.log("eval:"),console.log(script.innerHTML);var result=eval(script.innerHTML);console.log("eval result"),console.log(result);var obj={key:name,script:"",scriptLoaded:!1};mcf.registeredScripts.push(obj),fetch("/scripts/owned/"+name+".js").then((e=>e.text())).then((e=>{obj.script=e,obj.scriptLoaded=!0})),callback(result)}))},document.body.appendChild(script)}))},download:(e,o)=>{var t=document.createElement("a");t.setAttribute("download",o),t.href=e,document.body.appendChild(t),t.click(),t.remove()},progressStart:()=>{window.NProgress.start()},progressEnd:()=>{window.NProgress.done()},fn:(e,...o)=>{moduleCommonFunctions.requireFn(e,(()=>{moduleCommonFunctions.execFn(e,...o)}),o)},fnCallback:(e,o=()=>{},...t)=>{moduleCommonFunctions.requireFn(e,(()=>{moduleCommonFunctions.execFnCallback(e,o,...t)}),t)},ready:function(e=function(){}){"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e)},scrollToTop:(e,o="")=>{if(o.length<1)window.scrollTo({left:0,top:0,behavior:e?"smooth":"auto"});else{var t=document.getElementById(o);t&&t.scrollIntoView({behavior:e?"smooth":"auto"})}},callIfDefined:(e="",...o)=>{for(var t=e.split("."),n=window,i=0;i<t.length;i++){var r=t[i];if(!n[r])break;i===t.length-1?n[r](...o):n=n[r]}},dispose:(e="")=>{window[e]&&window[e].dispose&&window[e].dispose(e)},scrollToOffset:(e="",o=100)=>{var t=o,n=document.getElementById(e).getBoundingClientRect().top+window.pageYOffset-t;setTimeout((()=>{window.scrollTo({top:n,behavior:"smooth"})}),50)},scrollToElement:e=>{var o=document.getElementById(e);if(o){var t=o.getBoundingClientRect().top+window.pageYOffset-45;window.scrollTo({left:0,top:t})}},scrollToBottom:()=>{window.scrollTo({left:0,top:document.body.scrollHeight,behavior:"smooth"})},postAsync:(e,o)=>__awaiter(void 0,void 0,void 0,(function*(){let t=new Headers;t.append("X-Requested-With","XMLHttpRequest"),t.append("LcRequest","inlinePost");var n=yield fetch(e,{body:new URLSearchParams(o),headers:t,method:"POST"});return yield n.json()})),post:function(e,o,t=e=>{},n="",i=!0,r=""){function s(e){try{JSON.parse(e)}catch(e){return!1}return!0}let l=new Headers;l.append("X-Requested-With","XMLHttpRequest"),l.append("LcRequest","inlinePost"),""!==r&&l.append("Content-Type",r),""===n?fetch(e,{body:new URLSearchParams(o),headers:l,method:"POST"}).then((e=>e.text())).then((o=>{s(o)?t(JSON.parse(o)):mcf.toast("error",`Požadavek na server, adresa ${e} skončil neošetřenou chybou:<br/>${o}<br/>Kontaktuj prosím podporu / nahlas chybu v našem úkolovacím systému (obojí z bočního menu). Děkujeme!`)})):void 0!==window[n]&&!1!==window[n]||(window[n]=!0,i&&fetch(e,{body:new URLSearchParams(o),headers:l,method:"POST"}).then((e=>e.text())).then((o=>{s(o)?t(JSON.parse(o)):mcf.toast("error",`Požadavek na server, adresa ${e} skončil neošetřenou chybou:<br/>${o}<br/>. Kontaktuj prosím podporu / nahlas chybu v našem úkolovacím systému. Děkujeme!`),window[n]=!1})))},formdata:function(e,o,t=e=>{},n=""){let i=new Headers;i.append("X-Requested-With","XMLHttpRequest"),""!==n?void 0!==window[n]&&!1!==window[n]||(window[n]=!0,fetch(e,{body:o,headers:i,method:"POST"}).then((e=>e.json())).then((e=>{t(e),window[n]=!1}))):fetch(e,{body:o,headers:i,method:"POST"}).then((e=>e.json())).then((e=>{t(e)}))},requireOnceMultiple:function(e,o=function(){}){var t=[];e.forEach((function(e,n){t.push(1),moduleCommonFunctions.requireOnce(e,(function(){t[n]=0,t.every((e=>0===e))&&o()}))}))},getSocketId:()=>{var e=localStorage.getItem("websocketId");return e&&e.startsWith("ua_")&&39===e.length||(e=`ua_${mcf.iiid()}`,localStorage.setItem("websocketId",e)),e},toastClear:()=>{mcf.requireLib("toastr",(()=>{window.toastr.clear()}))},toast:(e="info",o="notifikace",t=null)=>{"ok"===e?e="success":"err"===e&&(e="error"),mcf.requireCss("toastr",(()=>{mcf.requireLib("toastr",(()=>{"function"==typeof window.toastr[e]?t?window.toastr[e](o,t):window.toastr[e](o):window.toastr.error("mcf.toast -> první parametr očekávan jako info|ok|success|warning|error|err. Poskytnuto: "+e)}))}))},choose:function(e){return e[Math.floor(Math.random()*e.length)]},guid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var o=16*Math.random()|0;return("x"==e?o:3&o|8).toString(16)}))},iiid:function(){return"xxxxxxxx_xxxx_4xxx_yxxx_xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var o=16*Math.random()|0;return("x"==e?o:3&o|8).toString(16)}))},fullscreenLoadStart:function(e,o=300){$("#globalOverlayText").html(e),$("#overlay").fadeIn(o)},fullscreenLoadEnd:function(e=300,o=function(){}){$("#overlay").fadeOut(e,o)},evalScripts:e=>{let o=document.createElement("div");o.innerHTML=e;let t=o.querySelectorAll("script");o.childNodes;for(let e=0;e<t.length;e++){let o=document.createElement("script");o.type=t[e].type||"text/javascript",t[e].hasAttribute("src")&&(o.src=t[e].src),o.innerHTML=t[e].innerHTML,document.head.appendChild(o),document.head.removeChild(o)}},clearCalls:()=>{mcf.callsQue=[]},registerDispose:(e,o)=>{e&&e.dispose&&mcf.disposeQue.push({obj:e,id:o})},checkForCall:e=>{var o=mcf.callsQue.find((o=>o.key===e));if(o){var t=mcf.callsQue.indexOf(o);t>=0&&mcf.callsQue.splice(t,1),o.fn(o.data)}},registerCall:(e,o={},t)=>{var n=mcf.callsQue.find((e=>e.key===t));if(n){var i=mcf.callsQue.indexOf(n);i>=0&&mcf.callsQue.splice(i,1)}o.mcfRegisteredCall=!0,mcf.callsQue.push({fn:e,data:o,key:t})},disposePersistentTooltips:()=>{mcf.tooltips.forEach((e=>{if(e&&e.inst&&e.inst.destroy){if(!e.persistent)return;e.inst.destroy()}window[`tooltipInst_${e.elId}`]=void 0,delete window[`tooltipInst_${e.elId}`]}))},disposeSafeEvents:()=>{for(var e of(mcf.eventAborter.abort(),mcf.uniqueEvents.forEach((e=>{removeEventListener(e.name,e.fn)})),mcf.uniqueEvents=[],mcf.tooltips.forEach((e=>{if(e&&e.inst&&e.inst.destroy){if(e.persistent)return;e.inst.destroy()}window[`tooltipInst_${e.elId}`]=void 0,delete window[`tooltipInst_${e.elId}`]})),mcf.tooltips=[],mcf.eventAborter=new AbortController,mcf.clearCalls(),mcf.disposeQue))e&&e.obj&&e.obj.dispose&&e.obj.dispose(e.id);return mcf.disposeQue=[],!0},toggleCheckbox:e=>{document.getElementById(e).checked=!document.getElementById(e).checked},addSafeEventListener:(e,o,t=e=>{})=>{if(mcf.uniqueEvents.find((t=>t.name===`mcfUniqueEvent_${e}_${o}`))){for(var n=mcf.uniqueEvents.filter((t=>t.name===`mcfUniqueEvent_${e}_${o}`)),i=0;i<n.length;i++)document.getElementById(e).removeEventListener(o,n[i].fn);mcf.uniqueEvents=mcf.uniqueEvents.filter((t=>t.name!==`mcfUniqueEvent_${e}_${o}`))}if(!mcf.uniqueEvents.find((t=>t.name===`mcfUniqueEvent_${e}_${o}`))){if(!document.getElementById(e))return!1;try{var r=e=>{t(e)};return document.getElementById(e).addEventListener(o,r,{signal:mcf.eventAborter.signal}),mcf.uniqueEvents.push({name:`mcfUniqueEvent_${e}_${o}`,fn:r}),!0}catch(e){return!1}}return!1},insertHTML:function(e,o,t=!1,n=!1){if("string"==typeof o&&(o=document.getElementById(o)),t||n||null!=o&&(o.innerHTML=""),null==o)return;var i="";"TBODY"===o.nodeName&&(i="table");let r=document.createElement(""===i?"div":"tbody");r.innerHTML=e;let s=r.querySelectorAll("script"),l=r.childNodes;for(let e=0;e<l.length;e++)n?o.insertBefore(l[e].cloneNode(!0),o.firstChild):o.appendChild(l[e].cloneNode(!0));for(let e=0;e<s.length;e++){let o=document.createElement("script");o.type=s[e].type||"text/javascript",s[e].hasAttribute("src")&&(o.src=s[e].src),o.innerHTML=s[e].innerHTML,document.head.appendChild(o),document.head.removeChild(o)}return!0},setCookie:(e,o,t=365)=>{var n="";if(t){var i=new Date;i.setTime(i.getTime()+24*t*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=e+"="+(o||"")+n+"; path=/;SameSite=Lax"},getCookie:e=>{for(var o=e+"=",t=document.cookie.split(";"),n=0;n<t.length;n++){for(var i=t[n];" "==i.charAt(0);)i=i.substring(1,i.length);if(0==i.indexOf(o))return i.substring(o.length,i.length)}return null},eraseCookie:e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;SameSite=Lax"}},mcf=moduleCommonFunctions;return"undefined"!=typeof window&&(window.mcf=mcf),mcf}));
//# sourceMappingURL=nanoMcf.min.js.map