{"version":3,"sources":["webpack:///./Scripts/GreatIt.Cms/Pages/MediaMaterialPage/MediaMaterialPage.js"],"names":["downloadFilesOnClick","element","addEventListener","event","fileUrls","dataset","split","length","forEach","fileUrl","trim","link","document","createElement","href","download","pop","body","appendChild","click","removeChild","window","downloadEmployeePrint","querySelectorAll","downloadEmployeeWeb","downloadLogo","downloadAllLogo","push","zip","JSZip","zipFolder","folder","fetchPromises","map","fetch","then","response","blob","fileName","file","catch","error","console","Promise","all","generateAsync","type","zipLink","URL","createObjectURL","downloadAllLogoOnClick"],"mappings":"iEAYA,SAASA,EAAqBC,GAC1BA,EAAQC,iBAAiB,SAASC,IAC9B,IAAIC,EACJA,EAAWH,EAAQI,QAAQD,SAASE,MAAM,KACtCF,EAASG,OAAS,GAClBH,EAASI,SAAQC,IACb,GAAIA,GAA8B,KAAnBA,EAAQC,OAAe,CAClC,MAAMC,EAAOC,SAASC,cAAc,KACpCF,EAAKG,KAAOL,EACZE,EAAKI,SAAWN,EAAQH,MAAM,KAAKU,MACnCJ,SAASK,KAAKC,YAAYP,GAC1BA,EAAKQ,QACLP,SAASK,KAAKG,YAAYT,EAC9B,IAER,GAER,CA7BAU,OAAOnB,iBAAiB,QAAQ,KAC5B,MAAMoB,EAAwBV,SAASW,iBAAiB,uBAClDC,EAAsBZ,SAASW,iBAAiB,qBAChDE,EAAeb,SAASW,iBAAiB,4CACzCG,EAAkBd,SAASW,iBAAiB,gCAElDD,EAAsBd,SAAQP,GAAWD,EAAqBC,KAC9DuB,EAAoBhB,SAAQP,GAAWD,EAAqBC,KAC5DwB,EAAajB,SAAQP,GAAWD,EAAqBC,KACrDyB,EAAgBlB,SAAQP,GAsB5B,SAAgCA,GAC5BA,EAAQC,iBAAiB,SAASC,IAC9B,IAAIC,EAAW,GASf,GARsBQ,SAASW,iBAAiB,4CAClCf,SAAQG,IAClB,MAAMF,EAAUE,EAAKN,QAAQD,SACzBK,GAA8B,KAAnBA,EAAQC,QACnBN,EAASuB,KAAKlB,EAClB,IAGAL,EAASG,OAAS,EAAG,CACrB,MAAMqB,EAAM,IAAIC,MACVC,EAAYF,EAAIG,OAAO,cACvBC,EAAgB5B,EAAS6B,KAAIxB,GACxByB,MAAMzB,GACR0B,MAAKC,GAAYA,EAASC,SAC1BF,MAAKE,IACF,MAAMC,EAAW7B,EAAQH,MAAM,KAAKU,MACpCc,EAAUS,KAAKD,EAAUD,EAAK,IAEjCG,OAAMC,IACHC,QAAQD,MAAM,wBAAwBhC,IAAWgC,EAAM,MAInEE,QAAQC,IAAIZ,GACPG,MAAK,KACFP,EAAIiB,cAAc,CAAEC,KAAM,SACrBX,MAAKE,IACF,MAAMU,EAAUnC,SAASC,cAAc,KACvCkC,EAAQjC,KAAOkC,IAAIC,gBAAgBZ,GACnCU,EAAQhC,SAAW,iBACnBH,SAASK,KAAKC,YAAY6B,GAC1BA,EAAQ5B,QACRP,SAASK,KAAKG,YAAY2B,EAAQ,IAErCP,OAAMC,IACHC,QAAQD,MAAM,4BAA6BA,EAAM,GACnD,GAElB,IAER,CAjEuCS,CAAuBjD,IAAS,G","file":"133.98c60f7fa2ad0c6c9aea.js","sourcesContent":["window.addEventListener('load', () => {\r\n const downloadEmployeePrint = document.querySelectorAll('.mm-emp-item__print');\r\n const downloadEmployeeWeb = document.querySelectorAll('.mm-emp-item__web');\r\n const downloadLogo = document.querySelectorAll('.mm-logo-container__item__logo-container');\r\n const downloadAllLogo = document.querySelectorAll('.mm-logo-container__download');\r\n\r\n downloadEmployeePrint.forEach(element => downloadFilesOnClick(element));\r\n downloadEmployeeWeb.forEach(element => downloadFilesOnClick(element));\r\n downloadLogo.forEach(element => downloadFilesOnClick(element));\r\n downloadAllLogo.forEach(element => downloadAllLogoOnClick(element));\r\n});\r\n\r\nfunction downloadFilesOnClick(element) {\r\n element.addEventListener('click', event => {\r\n let fileUrls;\r\n fileUrls = element.dataset.fileUrls.split(',');\r\n if (fileUrls.length > 0) {\r\n fileUrls.forEach(fileUrl => {\r\n if (fileUrl && fileUrl.trim() !== \"\") {\r\n const link = document.createElement('a');\r\n link.href = fileUrl;\r\n link.download = fileUrl.split('/').pop();\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n }\r\n });\r\n }\r\n });\r\n}\r\n\r\nfunction downloadAllLogoOnClick(element) {\r\n element.addEventListener('click', event => {\r\n let fileUrls = [];\r\n const downloadLinks = document.querySelectorAll('.mm-logo-container__item__logo-container');\r\n downloadLinks.forEach(link => {\r\n const fileUrl = link.dataset.fileUrls;\r\n if (fileUrl && fileUrl.trim() !== \"\") {\r\n fileUrls.push(fileUrl);\r\n }\r\n });\r\n\r\n if (fileUrls.length > 0) {\r\n const zip = new JSZip();\r\n const zipFolder = zip.folder(\"logo_files\");\r\n const fetchPromises = fileUrls.map(fileUrl => {\r\n return fetch(fileUrl)\r\n .then(response => response.blob())\r\n .then(blob => {\r\n const fileName = fileUrl.split('/').pop();\r\n zipFolder.file(fileName, blob);\r\n })\r\n .catch(error => {\r\n console.error(`Error fetching file: ${fileUrl}`, error);\r\n });\r\n });\r\n\r\n Promise.all(fetchPromises)\r\n .then(() => {\r\n zip.generateAsync({ type: \"blob\" })\r\n .then(blob => {\r\n const zipLink = document.createElement('a');\r\n zipLink.href = URL.createObjectURL(blob);\r\n zipLink.download = \"logo_files.zip\";\r\n document.body.appendChild(zipLink);\r\n zipLink.click();\r\n document.body.removeChild(zipLink);\r\n })\r\n .catch(error => {\r\n console.error('Error generating zip file', error);\r\n });\r\n });\r\n }\r\n });\r\n}"],"sourceRoot":""}