{"version":3,"file":"js/smush-global.min.js","mappings":"yBAIAA,SAASC,iBAAiB,oBAAoB,WAQ7C,SAASC,EAAoBC,GAC5BA,EAAMC,iBAEN,IACMC,EADSF,EAAMG,OACCC,QAAQ,6BAG9BC,EAFYH,EAAOI,aAAa,YAEZJ,EACrB,CAEA,SAASG,EAAeE,EAAKL,GAC5B,IAAMM,EAAM,IAAIC,eAChBD,EAAIE,KACH,OACAC,QAAU,oCAAsCJ,EAAM,gBAAkBK,aAAaC,OACrF,GAEDL,EAAIM,OAAS,WACRZ,GACHA,EAAOa,cAAc,yBAAyBC,cAAc,IAAIC,WAAW,QAAS,CACnFC,KAAMC,OACNC,SAAS,EACTC,YAAY,IAGf,EACAb,EAAIc,MACL,CAlC4BzB,SAAS0B,iBACpC,0DAEmBC,SAAQ,SAACC,GAC5BA,EAAO3B,iBAAiB,QAASC,EAClC,KAiC2B,WAC1B,IAAM2B,EAAe7B,SAASkB,cAAc,uCAC5C,GAAOW,GAAkBA,EAAaC,GAAtC,CAIA,IAAAC,EAAgCF,EAAaG,QAArCC,EAAUF,EAAVE,WAAYC,EAAOH,EAAPG,QACpB,GAAOD,GAAgBC,EAAvB,CAIAL,EAAaM,QAAU,SAACC,GACvB,IAAMC,EAAYD,EAAE9B,OAAO+B,UACHA,IAAeA,EAAUC,SAAS,mBAAqBD,EAAUC,SAAS,qBAIlG9B,EAAeyB,EAChB,EAEA,IAAMM,EAAgB,CACrBC,KAAM,UACNC,KAAM,OACNC,QAAS,CACRC,MAAM,EACNC,MAAOC,cAAcC,cACrBC,QAASF,cAAcG,uBAIzB1B,OAAO2B,IAAIC,WACVrB,EAAaC,GACbI,EACAK,EAxBD,CALA,CA+BD,CAEAY,EAED,G","sources":["webpack://wp-smushit/./_src/js/global.js"],"sourcesContent":["import '../scss/common.scss';\n\n/* global ajaxurl */\n\ndocument.addEventListener('DOMContentLoaded', function () {\n\tconst dismissNoticeButton = document.querySelectorAll(\n\t\t'.smush-dismissible-notice .smush-dismiss-notice-button'\n\t);\n\tdismissNoticeButton.forEach((button) => {\n\t\tbutton.addEventListener('click', handleDismissNotice);\n\t});\n\n\tfunction handleDismissNotice(event) {\n\t\tevent.preventDefault();\n\n\t\tconst button = event.target;\n\t\tconst notice = button.closest('.smush-dismissible-notice');\n\t\tconst key = notice.getAttribute('data-key');\n\n\t\tdismissNotice( key, notice );\n\t}\n\n\tfunction dismissNotice( key, notice ) {\n\t\tconst xhr = new XMLHttpRequest();\n\t\txhr.open(\n\t\t\t'POST',\n\t\t\tajaxurl + '?action=smush_dismiss_notice&key=' + key + '&_ajax_nonce=' + smush_global.nonce,\n\t\t\ttrue\n\t\t);\n\t\txhr.onload = () => {\n\t\t\tif (notice) {\n\t\t\t\tnotice.querySelector('button.notice-dismiss').dispatchEvent(new MouseEvent('click', {\n\t\t\t\t\tview: window,\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tcancelable: true\n\t\t\t\t}));\n\t\t\t}\n\t\t};\n\t\txhr.send();\n\t}\n\n\n\t// Show header notices.\n\tconst handleHeaderNotice = () => {\n\t\tconst headerNotice = document.querySelector('.wp-smush-dismissible-header-notice');\n\t\tif ( ! headerNotice || ! headerNotice.id ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { dismissKey, message } = headerNotice.dataset;\n\t\tif ( ! dismissKey || ! message ) {\n\t\t\treturn;\n\t\t}\n\n\t\theaderNotice.onclick = (e) => {\n\t\t\tconst classList = e.target.classList;\n\t\t\tconst isDismissButton = classList && ( classList.contains('sui-icon-check') || classList.contains('sui-button-icon') );\n\t\t\tif ( ! isDismissButton ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdismissNotice( dismissKey );\n\t\t}\n\n\t\tconst noticeOptions = {\n\t\t\ttype: 'warning',\n\t\t\ticon: 'info',\n\t\t\tdismiss: {\n\t\t\t\tshow: true,\n\t\t\t\tlabel: wp_smush_msgs.noticeDismiss,\n\t\t\t\ttooltip: wp_smush_msgs.noticeDismissTooltip,\n\t\t\t},\n\t\t};\n\n\t\twindow.SUI.openNotice(\n\t\t\theaderNotice.id,\n\t\t\tmessage,\n\t\t\tnoticeOptions\n\t\t);\n\t}\n\n\thandleHeaderNotice();\n\t\n});\n"],"names":["document","addEventListener","handleDismissNotice","event","preventDefault","notice","target","closest","dismissNotice","getAttribute","key","xhr","XMLHttpRequest","open","ajaxurl","smush_global","nonce","onload","querySelector","dispatchEvent","MouseEvent","view","window","bubbles","cancelable","send","querySelectorAll","forEach","button","headerNotice","id","_headerNotice$dataset","dataset","dismissKey","message","onclick","e","classList","contains","noticeOptions","type","icon","dismiss","show","label","wp_smush_msgs","noticeDismiss","tooltip","noticeDismissTooltip","SUI","openNotice","handleHeaderNotice"],"sourceRoot":""}