/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "./app/javascripts/functionality.js":
/*!******************************************!*\
  !*** ./app/javascripts/functionality.js ***!
  \******************************************/
/***/ (() => {

eval("function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, \"throw\" === methodName && delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method) || \"return\" !== methodName && (context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a '\" + methodName + \"' method\")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __ = wp.i18n.__;\nvar imageSEO_Bulk = /*#__PURE__*/function () {\n  function imageSEO_Bulk() {\n    _classCallCheck(this, imageSEO_Bulk);\n    this.init();\n  }\n  _createClass(imageSEO_Bulk, [{\n    key: \"init\",\n    value: function () {\n      var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n        var instance;\n        return _regeneratorRuntime().wrap(function _callee$(_context) {\n          while (1) {\n            switch (_context.prev = _context.next) {\n              case 0:\n                instance = this; // Start bulk process\n                jQuery('#start_bulk_process').on('click', function (e) {\n                  e.preventDefault();\n                  jQuery(this).attr('disabled', 'disabled').addClass('disabled').after('<span class=\"imageseo-settings-response-info\">' + __('Bulk process started, please wait', 'imageseo') + '</span>');\n                  instance.startBulkProcess(imageseo_bulk_images.ids, imageseo_bulk_images.options);\n                });\n                // Show bulk preview\n                jQuery('#get_bulk_process').on('click', function (e) {\n                  e.preventDefault();\n                  var button = jQuery(this),\n                    $wrapper = button.closest('.notice');\n                  button.attr('disabled', 'disabled');\n                  instance.getCurrentBulk($wrapper, button);\n                });\n                // Stop bulk process\n                jQuery('#stop_bulk_process').on('click', function (e) {\n                  e.preventDefault();\n                  var button = jQuery(this),\n                    $wrapper = button.closest('.notice');\n                  button.attr('disabled', 'disabled');\n                  instance.stopCurrentProcess($wrapper, button);\n                });\n              case 4:\n              case \"end\":\n                return _context.stop();\n            }\n          }\n        }, _callee, this);\n      }));\n      function init() {\n        return _init.apply(this, arguments);\n      }\n      return init;\n    }()\n  }, {\n    key: \"startBulkProcess\",\n    value: function () {\n      var _startBulkProcess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, _ref) {\n        var formatAlt, formatAltCustom, language, optimizeAlt, optimizeFile, altFilter, formData, response, json_response;\n        return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n          while (1) {\n            switch (_context2.prev = _context2.next) {\n              case 0:\n                formatAlt = _ref.formatAlt, formatAltCustom = _ref.formatAltCustom, language = _ref.language, optimizeAlt = _ref.optimizeAlt, optimizeFile = _ref.optimizeFile, altFilter = _ref.altFilter;\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_start_bulk\");\n                formData.append(\"data\", data);\n                formData.append(\"formatAlt\", formatAlt);\n                formData.append(\"formatAltCustom\", formatAltCustom);\n                formData.append(\"language\", language);\n                formData.append(\"optimizeAlt\", optimizeAlt);\n                formData.append(\"optimizeFile\", optimizeFile);\n                formData.append(\"altFilter\", altFilter);\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                //@ts-ignore\n                formData.append(\"wantValidateResult\", false);\n                //@ts-ignore\n                _context2.next = 14;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 14:\n                response = _context2.sent;\n                _context2.next = 17;\n                return response.json();\n              case 17:\n                json_response = _context2.sent;\n                if (json_response.success) {\n                  window.location.reload();\n                } else {\n                  jQuery('.imageseo-settings-response-info').remove();\n                  jQuery('#start_bulk_process').attr('disabled', false).removeClass('disabled').after('<span class=\"imageseo-settings-response-info\">' + json_response.data.response + '</span>');\n                }\n              case 19:\n              case \"end\":\n                return _context2.stop();\n            }\n          }\n        }, _callee2);\n      }));\n      function startBulkProcess(_x, _x2) {\n        return _startBulkProcess.apply(this, arguments);\n      }\n      return startBulkProcess;\n    }()\n  }, {\n    key: \"restartBulkProcess\",\n    value: function () {\n      var _restartBulkProcess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n        var formData, response;\n        return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n          while (1) {\n            switch (_context3.prev = _context3.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_restart_bulk\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                //@ts-ignore\n                _context3.next = 5;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 5:\n                response = _context3.sent;\n                _context3.next = 8;\n                return response.json();\n              case 8:\n                return _context3.abrupt(\"return\", _context3.sent);\n              case 9:\n              case \"end\":\n                return _context3.stop();\n            }\n          }\n        }, _callee3);\n      }));\n      function restartBulkProcess() {\n        return _restartBulkProcess.apply(this, arguments);\n      }\n      return restartBulkProcess;\n    }()\n  }, {\n    key: \"getPreviewBulk\",\n    value: function () {\n      var _getPreviewBulk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n        var formData, response;\n        return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n          while (1) {\n            switch (_context4.prev = _context4.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_get_preview_bulk\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                //@ts-ignore\n                _context4.next = 5;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 5:\n                response = _context4.sent;\n                _context4.next = 8;\n                return response.json();\n              case 8:\n                return _context4.abrupt(\"return\", _context4.sent);\n              case 9:\n              case \"end\":\n                return _context4.stop();\n            }\n          }\n        }, _callee4);\n      }));\n      function getPreviewBulk() {\n        return _getPreviewBulk.apply(this, arguments);\n      }\n      return getPreviewBulk;\n    }()\n  }, {\n    key: \"getCurrentBulk\",\n    value: function () {\n      var _getCurrentBulk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5($wrapper, button) {\n        var formData, response, json_response, optimized;\n        return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n          while (1) {\n            switch (_context5.prev = _context5.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_get_current_bulk\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                //@ts-ignore\n                _context5.next = 5;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 5:\n                response = _context5.sent;\n                _context5.next = 8;\n                return response.json();\n              case 8:\n                json_response = _context5.sent;\n                if (json_response.data['finish']) {\n                  $wrapper.find('span.imageseo-optimization__optimized_images').text(__('Optimization finished, page will reload in a couple of seconds.', 'imageseo'));\n                  setTimeout(function () {\n                    window.location.reload();\n                  }, 2000);\n                }\n                button.removeAttr('disabled');\n                if (json_response.success) {\n                  optimized = json_response.data.current.id_images_optimized;\n                  if ('undefined' !== typeof optimized) {\n                    $wrapper.find('span.imageseo-optimization__optimized_images').text(__('Optimized: ', 'imageseo') + optimized.length + __(' images.', 'imageseo'));\n                  }\n                }\n              case 12:\n              case \"end\":\n                return _context5.stop();\n            }\n          }\n        }, _callee5);\n      }));\n      function getCurrentBulk(_x3, _x4) {\n        return _getCurrentBulk.apply(this, arguments);\n      }\n      return getCurrentBulk;\n    }()\n  }, {\n    key: \"stopCurrentProcess\",\n    value: function () {\n      var _stopCurrentProcess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6($wrapper, button) {\n        var formData, response, json_response;\n        return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n          while (1) {\n            switch (_context6.prev = _context6.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_stop_bulk\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                //@ts-ignore\n                _context6.next = 5;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 5:\n                response = _context6.sent;\n                _context6.next = 8;\n                return response.json();\n              case 8:\n                json_response = _context6.sent;\n                button.removeAttr('disabled');\n                if (json_response.success) {\n                  $wrapper.append('<p>' + __('Bulk process stopped.', 'imageseo') + '</p>');\n                  setTimeout(function () {\n                    window.location.reload();\n                  }, 1500);\n                }\n              case 11:\n              case \"end\":\n                return _context6.stop();\n            }\n          }\n        }, _callee6);\n      }));\n      function stopCurrentProcess(_x5, _x6) {\n        return _stopCurrentProcess.apply(this, arguments);\n      }\n      return stopCurrentProcess;\n    }()\n  }, {\n    key: \"queryImages\",\n    value: function () {\n      var _queryImages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options) {\n        var formData, response;\n        return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n          while (1) {\n            switch (_context7.prev = _context7.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_query_images\");\n                formData.append(\"filters\", JSON.stringify(get(options, \"filters\", {})));\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                _context7.next = 6;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 6:\n                response = _context7.sent;\n                _context7.next = 9;\n                return response.json();\n              case 9:\n                return _context7.abrupt(\"return\", _context7.sent);\n              case 10:\n              case \"end\":\n                return _context7.stop();\n            }\n          }\n        }, _callee7);\n      }));\n      function queryImages(_x7) {\n        return _queryImages.apply(this, arguments);\n      }\n      return queryImages;\n    }()\n  }]);\n  return imageSEO_Bulk;\n}();\nvar imageseo_Settings = /*#__PURE__*/function () {\n  function imageseo_Settings() {\n    _classCallCheck(this, imageseo_Settings);\n    _defineProperty(this, \"socialCard\", jQuery('#imageseo-preview-image'));\n    _defineProperty(this, \"colorPickers\", '.imageseo-colorpicker');\n    _defineProperty(this, \"initialState\", {});\n    _defineProperty(this, \"changedState\", {});\n    this.init();\n    this.setConditions();\n    this.createFilePicker();\n  }\n  _createClass(imageseo_Settings, [{\n    key: \"init\",\n    value: function init() {\n      var instance = this;\n\n      // Set initial state of the settings based on the inputs that exist on the page\n      jQuery('.imageseo-admin-settings').find('input,select').each(function () {\n        var $this = jQuery(this),\n          $type = $this.attr('type');\n        switch ($type) {\n          case 'radio':\n          case 'checkbox':\n            instance.initialState[$this.attr('name')] = $this.is(':checked') ? 'on' : 'off';\n            break;\n          default:\n            instance.initialState[$this.attr('name')] = $this.val();\n            break;\n        }\n      });\n      jQuery('#setting-layout').on('change', function (e) {\n        var $this = jQuery(this),\n          $val = $this.val();\n        if ('CARD_LEFT' === $val) {\n          instance.socialCard.removeClass('imageseo-media__layout--card-right').addClass('imageseo-media__layout--card-left');\n        } else {\n          instance.socialCard.removeClass('imageseo-media__layout--card-left').addClass('imageseo-media__layout--card-right');\n        }\n      });\n      jQuery('#setting-logoUrl').on('change', function (e) {\n        var $this = jQuery(this),\n          $val = $this.val();\n        instance.socialCard.find('.imageseo-media__content__logo').attr('src', $val);\n      });\n      jQuery('#setting-defaultBgImg').on('change', function (e) {\n        var $this = jQuery(this),\n          $val = $this.val();\n        instance.socialCard.find('.imageseo-media__container__image').css('background-image', 'url( ' + $val + ')');\n      });\n      instance.setColorPickers();\n      jQuery('table.imageseo-bulk_optimizations').find('input,select').on('change', function (e) {\n        var $element = jQuery(this),\n          $name = $element.attr('name'),\n          $val = $element.val(),\n          $type = $element.attr('type');\n        jQuery('.imageseo-settings-response-info').remove();\n        switch ($type) {\n          case 'radio':\n          case 'checkbox':\n            var currentState = $element.is(':checked') ? 'on' : 'off';\n            if (instance.initialState[$name] === currentState) {\n              delete instance.changedState[$name];\n            } else {\n              instance.changedState[$name] = currentState;\n            }\n            break;\n          default:\n            if (instance.initialState[$name] === $val) {\n              delete instance.changedState[$name];\n            } else {\n              instance.changedState[$name] = $val;\n            }\n            break;\n        }\n        // Check if there are any changes, if so, disable the start bulk process button\n        if (0 !== Object.keys(instance.changedState).length) {\n          jQuery('#start_bulk_process').attr('disabled', true).addClass('disabled').after('<span class=\"imageseo-settings-response-info\">' + __('Please save changes in order to start the optimization process.', 'imageseo') + '</span>');\n        } else {\n          jQuery('#start_bulk_process').removeAttr('disabled').removeClass('disabled');\n          jQuery('.imageseo-settings-response-info').remove();\n        }\n      });\n      jQuery('#register_account').on('click', function (e) {\n        e.preventDefault();\n        var button = jQuery(this),\n          data = {\n            firstname: jQuery('#setting-register_first_name').val(),\n            lastname: jQuery('#setting-register_last_name').val(),\n            password: jQuery('#setting-register_password').val(),\n            email: jQuery('#setting-register_email').val(),\n            terms: jQuery('#setting-terms').is(':checked'),\n            newsletters: jQuery('#setting-newsletter').is(':checked')\n          };\n        button.attr('disabled', 'disabled').addClass('disabled');\n        button.after('<p class=\"imageseo-register-form-error\">' + __('Registering your account and validating API KEY, please wait', 'imageseo') + '</p>');\n        var response = instance.checkRegisterFormData(data);\n        if (!response.success) {\n          jQuery('p.imageseo-register-form-error').remove();\n          button.after('<p class=\"imageseo-register-form-error\">' + response.code + '</p>');\n          button.removeAttr('disabled').removeClass('disabled');\n          return;\n        }\n        instance.register(data).then(function (response) {\n          var api_key = false;\n          jQuery('p.imageseo-register-form-error').remove();\n          if (response.success) {\n            if ('undefined' !== typeof response.data.user.projects && null !== response.data.user.projects) {\n              api_key = response.data.user.projects[0].apiKey;\n            } else {\n              button.after('<p>' + __('There was an error processing your request. Please try again later.', 'imageseo') + '</p>');\n              return;\n            }\n            if (!api_key) {\n              button.after('<p>' + __('There was an error processing your request. Please try again later.', 'imageseo') + '</p>');\n              return;\n            }\n            jQuery('#setting-api_key').val(api_key);\n            instance.validateApiKey(api_key);\n          } else {\n            if ('unknown_error' !== response.data.message && 'unknown_error' !== response.data.code) {\n              button.after('<p class=\"imageseo-register-form-error\">' + response.data.message + '</p>');\n            } else {\n              button.after('<p class=\"imageseo-register-form-error\">' + __('There was an error processing your request. Please try again later.', 'imageseo') + '</p>');\n            }\n            button.removeAttr('disabled').removeClass('disabled');\n          }\n        });\n      });\n      jQuery('#validate_api_key').on('click', function (e) {\n        e.preventDefault();\n        var key = jQuery('#setting-api_key').val(),\n          button = jQuery(this);\n        jQuery('.imageseo-imageseo-settings-response-info').remove();\n        if ('' === key) {\n          button.after('<span class=\"imageseo-settings-response-info\">' + __('Please enter a valid API Key', 'imageseo') + '</span>');\n          return;\n        }\n        button.attr('disabled', 'disabled').addClass('disabled');\n        button.after('<span class=\"imageseo-settings-response-info\">' + __('Validating API KEY, please wait', 'imageseo') + '</span>');\n        instance.validateApiKey(key);\n      });\n    }\n  }, {\n    key: \"setColorPickers\",\n    value: function setColorPickers() {\n      var instance = this;\n      jQuery(instance.colorPickers).each(function () {\n        var $this = jQuery(this),\n          input = $this.closest('tr').find('input');\n        input.wpColorPicker({\n          change: function change(event, ui) {\n            var $color = ui.color.toString(),\n              setting = $this.closest('tr').data('setting');\n            input.val($color);\n            switch (setting) {\n              case 'textColor':\n                instance.socialCard.find('.imageseo-media__container__content > *').css('color', $color);\n                break;\n              case 'contentBackgroundColor':\n                instance.socialCard.find('.imageseo-media__container__content').css('background-color', $color);\n                break;\n              case 'starColor':\n                instance.socialCard.find('svg').attr('fill', $color).attr('stroke', $color);\n                break;\n            }\n          }\n        });\n      });\n    }\n  }, {\n    key: \"validateApiKey\",\n    value: function () {\n      var _validateApiKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(apiKey) {\n        var formData, response, json_response;\n        return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n          while (1) {\n            switch (_context8.prev = _context8.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_valid_api_key\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                formData.append(\"api_key\", apiKey);\n\n                //@ts-ignore\n                _context8.next = 6;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 6:\n                response = _context8.sent;\n                _context8.next = 9;\n                return response.json();\n              case 9:\n                json_response = _context8.sent;\n                jQuery('.imageseo-settings-response-info').remove();\n                if (json_response.success) {\n                  if ('undefined' !== typeof json_response.data.user && null !== json_response.data.user) {\n                    if (json_response.data.user.is_active) {\n                      jQuery('#validate_api_key').after('<span class=\"imageseo-settings-response-info\">' + __('API key is valid.', 'imageseo') + '</span>');\n                    }\n                  } else {\n                    jQuery('#validate_api_key').after('<span class=\"imageseo-settings-response-info\">' + __('API key is invalid.', 'imageseo') + '</span>');\n                  }\n                  setTimeout(function () {\n                    window.location.reload();\n                  }, 1500);\n                }\n              case 12:\n              case \"end\":\n                return _context8.stop();\n            }\n          }\n        }, _callee8);\n      }));\n      function validateApiKey(_x8) {\n        return _validateApiKey.apply(this, arguments);\n      }\n      return validateApiKey;\n    }()\n  }, {\n    key: \"checkRegisterFormData\",\n    value: function checkRegisterFormData(data) {\n      var instance = this;\n      if (!data.email) {\n        return {\n          success: false,\n          code: __('Please enter your email', 'imageseo')\n        };\n      }\n      if (!instance.checkIfEmail(data.email)) {\n        return {\n          success: false,\n          error: true,\n          code: __('Please enter a valid email address', 'imageseo')\n        };\n      }\n      if (!data.password) {\n        return {\n          success: false,\n          code: __('Please enter your password', 'imageseo')\n        };\n      }\n      if (!data.terms) {\n        return {\n          success: false,\n          code: __('Please accept the terms and conditions', 'imageseo')\n        };\n      }\n      return {\n        success: true\n      };\n    }\n  }, {\n    key: \"checkIfEmail\",\n    value: function checkIfEmail(str) {\n      // Regular expression to check if string is email\n      var regexExp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/gi;\n      return regexExp.test(str);\n    }\n  }, {\n    key: \"register\",\n    value: function () {\n      var _register = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(data) {\n        var formData, response;\n        return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n          while (1) {\n            switch (_context9.prev = _context9.next) {\n              case 0:\n                formData = new FormData();\n                formData.append(\"action\", \"imageseo_register\");\n                formData.append(\"_wpnonce\", document.querySelector(\"#_wpnonce\").getAttribute(\"value\"));\n                formData.append(\"firstname\", data.firstname);\n                formData.append(\"lastname\", data.lastname);\n                formData.append(\"email\", data.email);\n                formData.append(\"password\", data.password);\n                if (data.newsletters) {\n                  formData.append(\"newsletters\", data.newsletters);\n                }\n\n                //@ts-ignore\n                _context9.next = 10;\n                return fetch(ajaxurl, {\n                  method: \"POST\",\n                  body: formData\n                });\n              case 10:\n                response = _context9.sent;\n                _context9.next = 13;\n                return response.json();\n              case 13:\n                return _context9.abrupt(\"return\", _context9.sent);\n              case 14:\n              case \"end\":\n                return _context9.stop();\n            }\n          }\n        }, _callee9);\n      }));\n      function register(_x9) {\n        return _register.apply(this, arguments);\n      }\n      return register;\n    }()\n  }, {\n    key: \"setConditions\",\n    value: function setConditions() {\n      var instance = this;\n      if (!jQuery('#setting-visibilityRating').is(':checked')) {\n        jQuery('tr[data-setting=\"starColor\"]').hide();\n      }\n      if (!jQuery('#setting-optimizeAlt').is(':checked')) {\n        jQuery('tr[data-setting=\"altFill\"],tr[data-setting=\"formatAlt\"],tr[data-setting=\"formatAltCustom\"]').hide();\n      }\n      if ('CUSTOM_FORMAT' !== jQuery('input[type=\"radio\"][name=\"imageseo[formatAlt]\"]:checked').val()) {\n        jQuery('tr[data-setting=\"formatAltCustom\"]').hide();\n      } else {\n        jQuery('tr[data-setting=\"formatAltCustom\"]').show();\n      }\n      jQuery('#setting-visibilitySubTitle').on('change', function (e) {\n        var $this = jQuery(this);\n        if ($this.is(':checked')) {\n          instance.socialCard.find('.imageseo-media__content__sub-title').show();\n        } else {\n          instance.socialCard.find('.imageseo-media__content__sub-title').hide();\n        }\n      });\n      jQuery('#setting-visibilitySubTitleTwo').on('change', function (e) {\n        var $this = jQuery(this);\n        if ($this.is(':checked')) {\n          instance.socialCard.find('.imageseo-media__content__sub-title-two').show();\n        } else {\n          instance.socialCard.find('.imageseo-media__content__sub-title-two').hide();\n        }\n      });\n      jQuery('#setting-visibilityRating').on('change', function (e) {\n        var $this = jQuery(this);\n        if ($this.is(':checked')) {\n          instance.socialCard.find('.imageseo-media__content__stars').show();\n          jQuery('tr[data-setting=\"starColor\"]').show();\n        } else {\n          instance.socialCard.find('.imageseo-media__content__stars').hide();\n          jQuery('tr[data-setting=\"starColor\"]').hide();\n        }\n      });\n      jQuery('#setting-visibilityAvatar').on('change', function (e) {\n        var $this = jQuery(this);\n        if ($this.is(':checked')) {\n          instance.socialCard.find('.imageseo-media__content__avatar').show();\n        } else {\n          instance.socialCard.find('.imageseo-media__content__avatar').hide();\n        }\n      });\n      jQuery('#setting-optimizeAlt').on('change', function (e) {\n        var $this = jQuery(this);\n        if ($this.is(':checked')) {\n          jQuery('tr[data-setting=\"altFill\"],tr[data-setting=\"formatAlt\"],tr[data-setting=\"formatAltCustom\"]').show();\n        } else {\n          jQuery('tr[data-setting=\"altFill\"],tr[data-setting=\"formatAlt\"],tr[data-setting=\"formatAltCustom\"]').hide();\n        }\n      });\n      jQuery('input[type=\"radio\"][name=\"imageseo[formatAlt]\"]').on('change', function () {\n        if ('CUSTOM_FORMAT' !== this.value) {\n          jQuery('tr[data-setting=\"formatAltCustom\"]').hide();\n        } else {\n          jQuery('tr[data-setting=\"formatAltCustom\"]').show();\n        }\n      });\n    }\n  }, {\n    key: \"createFilePicker\",\n    value: function createFilePicker() {\n      jQuery('.imageseo-file-picker').click(function (e) {\n        e.preventDefault();\n        var button = jQuery(this),\n          frame = wp.media({\n            button: {\n              text: 'Select'\n            },\n            multiple: false\n          });\n\n        // When a file is selected, run a callback\n        frame.on('select', function () {\n          var attachment = frame.state().get('selection').first().toJSON();\n          // Do something with the selected file URL, e.g., insert it into a text field\n          button.closest('.imageseo-file-picker-wrapper').find('.imageseo-file-picker-src').val(attachment.url).change();\n          button.closest('.imageseo-file-picker-wrapper').find('.imageseo-file-picker-image').attr('src', attachment.url).change();\n        });\n        frame.open();\n      });\n    }\n  }]);\n  return imageseo_Settings;\n}();\njQuery(function ($) {\n  // Bulk optimization functionality\n  var imageseo_fn = new imageSEO_Bulk();\n  // Social Card functionality\n  var imageseo_settings = new imageseo_Settings();\n});\n\n//# sourceURL=webpack://imageseo/./app/javascripts/functionality.js?");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval devtool is used.
/******/ 	var __webpack_exports__ = {};
/******/ 	__webpack_modules__["./app/javascripts/functionality.js"]();
/******/ 	
/******/ })()
;