/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./src/js/components/Label.js":
/*!************************************!*\
  !*** ./src/js/components/Label.js ***!
  \************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ Label)
/* harmony export */ });
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function Label(_ref) {
  var text = _ref.text,
    image = _ref.image,
    name = _ref.name;
  var _window$wp$element = window.wp.element,
    useState = _window$wp$element.useState,
    useEffect = _window$wp$element.useEffect;
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    labelUrl = _useState2[0],
    setLabelUrl = _useState2[1];
  var _useState3 = useState(''),
    _useState4 = _slicedToArray(_useState3, 2),
    labelTitle = _useState4[0],
    setLabelTitle = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    isStartFetching = _useState6[0],
    setIsStartFetching = _useState6[1];
  useEffect(function () {
    var wkwc_adyen = wkwc_adyen_util;
    if (!!labelUrl) {
      return;
    }
    if (isStartFetching) {
      return;
    }
    if (!image) {
      setIsStartFetching(true);
      jQuery.ajax({
        url: wkwc_adyen.ajax.url,
        method: 'POST',
        data: {
          action: 'wkwc_adyen_get_payment_method_data',
          security: wkwc_adyen.ajax.nonce,
          payment_method: name
        },
        success: function success(res) {
          if (!!res.icon) {
            setLabelUrl(res.icon);
          }
          if (!!res.title) {
            setLabelTitle(res.title);
          }
          setIsStartFetching(false);
        }
      });
    }
  });
  return /*#__PURE__*/React.createElement("span", {
    style: {
      width: '100%'
    }
  }, labelTitle ? labelTitle : text, labelUrl ? /*#__PURE__*/React.createElement("img", {
    src: labelUrl,
    style: {
      "float": 'right',
      marginRight: '20px'
    }
  }) : image ? /*#__PURE__*/React.createElement("img", {
    src: image,
    style: {
      "float": 'right',
      marginRight: '20px'
    }
  }) : '');
}

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
/*!****************************************************************!*\
  !*** ./src/js/wkwc-adyen-checkout-blocks-klarna-paynow/app.js ***!
  \****************************************************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _components_Label__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../components/Label */ "./src/js/components/Label.js");

var settings = window.wc.wcSettings.getSetting('wkwc_adyen_klarna_paynow_data', {
  icon: false
});
var title = window.wp.htmlEntities.decodeEntities(settings.title) || window.wp.i18n.__('Adyen - Klarna - Pay now', 'wkwc-adyen');
var Content = function Content() {
  return window.wp.htmlEntities.decodeEntities(settings.description || '');
};
var Adyen_Klarna_PayNow_Block_Gateway = {
  name: 'wkwc_adyen_klarna_paynow',
  label: /*#__PURE__*/React.createElement(_components_Label__WEBPACK_IMPORTED_MODULE_0__["default"], {
    text: title,
    image: settings.icon,
    name: 'wkwc_adyen_klarna_paynow'
  }),
  content: Object(window.wp.element.createElement)(Content, null),
  edit: Object(window.wp.element.createElement)(Content, null),
  canMakePayment: function canMakePayment() {
    return true;
  },
  ariaLabel: title,
  supports: {
    features: settings.supports
  }
};
window.wc.wcBlocksRegistry.registerPaymentMethod(Adyen_Klarna_PayNow_Block_Gateway);
/******/ })()
;
//# sourceMappingURL=wkwc-adyen-checkout-blocks-klarna-paynow.js.map