{"version":3,"file":"putPreloader-YG6jLs1E.js","sources":["../src/components/putPreloader.ts"],"sourcesContent":["/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nimport {MOUNT_CLASS_TO} from '../config/debug';\nimport {_tgico} from '../helpers/tgico';\n\nexport function putPreloader(elem: Element, returnDiv = false): HTMLElement {\n const html = `\n `;\n\n if(returnDiv) {\n const div = document.createElement('div');\n div.classList.add('preloader');\n div.innerHTML = html;\n\n if(elem) {\n elem.appendChild(div);\n }\n\n return div;\n }\n\n elem.insertAdjacentHTML('beforeend', html);\n return elem.lastElementChild as HTMLElement;\n}\n\nMOUNT_CLASS_TO.putPreloader = putPreloader;\n\nexport function setButtonLoader(elem: HTMLButtonElement, icon: Icon = 'check') {\n const iconElement = elem.querySelector('.tgico');\n iconElement?.remove();\n elem.disabled = true;\n putPreloader(elem);\n\n return () => {\n elem.replaceChildren();\n if(iconElement) elem.append(iconElement);\n elem.removeAttribute('disabled');\n };\n}\n\n/* export function parseMenuButtonsTo(to: {[name: string]: HTMLElement}, elements: HTMLCollection | NodeListOf) {\n Array.from(elements).forEach((el) => {\n const match = el.className.match(/(?:^|\\s)menu-(.+?)(?:$|\\s)/);\n if(!match) return;\n to[match[1]] = el as HTMLElement;\n });\n} */\n"],"names":["putPreloader","elem","returnDiv","html","div","MOUNT_CLASS_TO","setButtonLoader","icon","iconElement"],"mappings":"wCASgB,SAAAA,EAAaC,EAAeC,EAAY,GAAoB,CAC1E,MAAMC,EAAO;AAAA;AAAA;AAAA,UAKb,GAAGD,EAAW,CACN,MAAAE,EAAM,SAAS,cAAc,KAAK,EACpC,OAAAA,EAAA,UAAU,IAAI,WAAW,EAC7BA,EAAI,UAAYD,EAEbF,GACDA,EAAK,YAAYG,CAAG,EAGfA,CACT,CAEK,OAAAH,EAAA,mBAAmB,YAAaE,CAAI,EAClCF,EAAK,gBACd,CAEAI,EAAe,aAAeL,EAEd,SAAAM,EAAgBL,EAAyBM,EAAa,QAAS,CACvE,MAAAC,EAAcP,EAAK,cAAc,QAAQ,EAC/C,OAAAO,GAAa,OAAO,EACpBP,EAAK,SAAW,GAChBD,EAAaC,CAAI,EAEV,IAAM,CACXA,EAAK,gBAAgB,EAClBO,GAAaP,EAAK,OAAOO,CAAW,EACvCP,EAAK,gBAAgB,UAAU,CAAA,CAEnC"}