"use strict";
/*
 * 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/).
 */
(self["webpackChunkwoocommerce_rtm_custom_emails"] = self["webpackChunkwoocommerce_rtm_custom_emails"] || []).push([["assets_src_js_react_routes_EmailAttachmentsRoute_tsx"],{

/***/ 88676:
/*!********************************************************************************!*\
  !*** ./assets/src/js/react/components/EmailAttachmentsList/styles.module.scss ***!
  \********************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// extracted by mini-css-extract-plugin\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\"listItem\":\"Wzlx00xvhhkKfVC_RcPi\"});\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./assets/src/js/react/components/EmailAttachmentsList/styles.module.scss?");

/***/ }),

/***/ 30885:
/*!***********************************************************************!*\
  !*** ./assets/src/js/react/components/EmailAttachmentsList/index.tsx ***!
  \***********************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 99196);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var js_react_lib_datafetching_email__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! js/react/lib/datafetching/email */ 21954);\n/* harmony import */ var _material_tailwind_react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material-tailwind/react */ 59335);\n/* harmony import */ var _material_tailwind_react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _styles_module_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./styles.module.scss */ 88676);\n/* harmony import */ var _lib_actions_email__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../lib/actions/email */ 72926);\n\n\n\n\n\nconst { toast } = window;\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__({ email, onEmailUpdated }) {\n    const [updating, setUpdating] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(null);\n    const { data: documents } = (0,js_react_lib_datafetching_email__WEBPACK_IMPORTED_MODULE_1__.useSupportedDocuments)(email);\n    const toggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((document) => {\n        const isAttached = email.attachments.includes(document.slug);\n        if (isAttached) {\n            email.attachments = email.attachments.filter(slug => slug !== document.slug);\n        }\n        else {\n            email.attachments.push(document.slug);\n        }\n        setUpdating(document.slug);\n        (0,_lib_actions_email__WEBPACK_IMPORTED_MODULE_4__.toggleDocument)(email, document.slug)\n            .catch(() => toast.error('Failed to ' + (isAttached ? 'remove' : 'attach') + ' document'))\n            .then(() => {\n            toast.success('Document ' + (isAttached ? 'removed' : 'attached') + ' successfully');\n            onEmailUpdated(email);\n        })\n            .finally(() => setUpdating(null));\n    }, [email, onEmailUpdated]);\n    const memoizedEmailAttachments = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => email.attachments, [email.attachments]);\n    return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_2__.Card, { color: 'white' },\n        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"ul\", { className: 'px-2' }, documents?.map(document => {\n            const isAttached = memoizedEmailAttachments.includes(document.slug);\n            return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"li\", { key: email.id + '-' + document.slug, className: _styles_module_scss__WEBPACK_IMPORTED_MODULE_3__[\"default\"].listItem },\n                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", { className: 'flex items-center gap-2' },\n                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"img\", { src: document.icon, alt: document.name, className: 'w-5 h-5' }),\n                    document.name),\n                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_2__.Button, { size: 'sm', color: isAttached ? 'red' : 'blue-gray', type: 'button', onClick: () => toggle(document), disabled: Boolean(updating), className: 'inline-flex' },\n                    updating === document.slug && react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_2__.Spinner, { className: 'mr-1 h-4 w-4' }),\n                    isAttached ? 'Remove' : 'Attach'));\n        })));\n}\n\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./assets/src/js/react/components/EmailAttachmentsList/index.tsx?");

/***/ }),

/***/ 71023:
/*!**************************************************************!*\
  !*** ./assets/src/js/react/routes/EmailAttachmentsRoute.tsx ***!
  \**************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 99196);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router */ 89250);\n/* harmony import */ var _components_EmailAttachmentsList__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/EmailAttachmentsList */ 30885);\n\n\n\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {\n    const ctx = (0,react_router__WEBPACK_IMPORTED_MODULE_2__.useOutletContext)();\n    const onUpdated = () => { };\n    return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_EmailAttachmentsList__WEBPACK_IMPORTED_MODULE_1__[\"default\"], { key: ctx.email.id, email: ctx.email, onEmailUpdated: onUpdated });\n}\n\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./assets/src/js/react/routes/EmailAttachmentsRoute.tsx?");

/***/ })

}]);