"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_EmailSettingsRoute_tsx"],{

/***/ 82394:
/*!***************************************************************************!*\
  !*** ./node_modules/@fortawesome/free-solid-svg-icons/faFileArrowDown.js ***!
  \***************************************************************************/
/***/ ((__unused_webpack_module, exports) => {

eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar prefix = 'fas';\nvar iconName = 'file-arrow-down';\nvar width = 384;\nvar height = 512;\nvar aliases = [\"file-download\"];\nvar unicode = 'f56d';\nvar svgPathData = 'M64 0C28.7 0 0 28.7 0 64V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V160H256c-17.7 0-32-14.3-32-32V0H64zM256 0V128H384L256 0zM216 232V334.1l31-31c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-72 72c-9.4 9.4-24.6 9.4-33.9 0l-72-72c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l31 31V232c0-13.3 10.7-24 24-24s24 10.7 24 24z';\n\nexports.definition = {\n  prefix: prefix,\n  iconName: iconName,\n  icon: [\n    width,\n    height,\n    aliases,\n    unicode,\n    svgPathData\n  ]};\n\nexports.faFileArrowDown = exports.definition;\nexports.prefix = prefix;\nexports.iconName = iconName;\nexports.width = width;\nexports.height = height;\nexports.ligatures = aliases;\nexports.unicode = unicode;\nexports.svgPathData = svgPathData;\nexports.aliases = aliases;\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./node_modules/@fortawesome/free-solid-svg-icons/faFileArrowDown.js?");

/***/ }),

/***/ 29579:
/*!*************************************************************************!*\
  !*** ./node_modules/@fortawesome/free-solid-svg-icons/faFileArrowUp.js ***!
  \*************************************************************************/
/***/ ((__unused_webpack_module, exports) => {

eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar prefix = 'fas';\nvar iconName = 'file-arrow-up';\nvar width = 384;\nvar height = 512;\nvar aliases = [\"file-upload\"];\nvar unicode = 'f574';\nvar svgPathData = 'M64 0C28.7 0 0 28.7 0 64V448c0 35.3 28.7 64 64 64H320c35.3 0 64-28.7 64-64V160H256c-17.7 0-32-14.3-32-32V0H64zM256 0V128H384L256 0zM216 408c0 13.3-10.7 24-24 24s-24-10.7-24-24V305.9l-31 31c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l72-72c9.4-9.4 24.6-9.4 33.9 0l72 72c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-31-31V408z';\n\nexports.definition = {\n  prefix: prefix,\n  iconName: iconName,\n  icon: [\n    width,\n    height,\n    aliases,\n    unicode,\n    svgPathData\n  ]};\n\nexports.faFileArrowUp = exports.definition;\nexports.prefix = prefix;\nexports.iconName = iconName;\nexports.width = width;\nexports.height = height;\nexports.ligatures = aliases;\nexports.unicode = unicode;\nexports.svgPathData = svgPathData;\nexports.aliases = aliases;\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./node_modules/@fortawesome/free-solid-svg-icons/faFileArrowUp.js?");

/***/ }),

/***/ 24473:
/*!**************************************************************************!*\
  !*** ./node_modules/@fortawesome/free-solid-svg-icons/faFileDownload.js ***!
  \**************************************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar source = __webpack_require__(/*! ./faFileArrowDown */ 82394);\nexports.definition = {\n  prefix: source.prefix,\n  iconName: source.iconName,\n  icon: [\n    source.width,\n    source.height,\n    source.aliases,\n    source.unicode,\n    source.svgPathData\n  ]};\n\nexports.faFileDownload = exports.definition;\nexports.prefix = source.prefix;\nexports.iconName = source.iconName;\nexports.width = source.width;\nexports.height = source.height;\nexports.ligatures = source.aliases;\nexports.unicode = source.unicode;\nexports.svgPathData = source.svgPathData;\nexports.aliases = source.aliases;\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./node_modules/@fortawesome/free-solid-svg-icons/faFileDownload.js?");

/***/ }),

/***/ 85124:
/*!************************************************************************!*\
  !*** ./node_modules/@fortawesome/free-solid-svg-icons/faFileUpload.js ***!
  \************************************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nvar source = __webpack_require__(/*! ./faFileArrowUp */ 29579);\nexports.definition = {\n  prefix: source.prefix,\n  iconName: source.iconName,\n  icon: [\n    source.width,\n    source.height,\n    source.aliases,\n    source.unicode,\n    source.svgPathData\n  ]};\n\nexports.faFileUpload = exports.definition;\nexports.prefix = source.prefix;\nexports.iconName = source.iconName;\nexports.width = source.width;\nexports.height = source.height;\nexports.ligatures = source.aliases;\nexports.unicode = source.unicode;\nexports.svgPathData = source.svgPathData;\nexports.aliases = source.aliases;\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./node_modules/@fortawesome/free-solid-svg-icons/faFileUpload.js?");

/***/ }),

/***/ 55945:
/*!**********************************************************!*\
  !*** ./assets/src/js/react/components/EmailSettings.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 _lib_datafetching_email__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../lib/datafetching/email */ 21954);\n/* harmony import */ var _lib_rjsf_SchemaForm__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/rjsf/SchemaForm */ 29561);\n/* harmony import */ var js_schema_settings_uiSchema_json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! js/schema/settings.uiSchema.json */ 99711);\n/* harmony import */ var _material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @material-tailwind/react */ 59335);\n/* harmony import */ var _material_tailwind_react__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _lib_actions_email__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../lib/actions/email */ 72926);\n/* harmony import */ var _fortawesome_react_fontawesome__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @fortawesome/react-fontawesome */ 67814);\n/* harmony import */ var _fortawesome_free_solid_svg_icons_faFileUpload__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @fortawesome/free-solid-svg-icons/faFileUpload */ 85124);\n/* harmony import */ var _fortawesome_free_solid_svg_icons_faFileDownload__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @fortawesome/free-solid-svg-icons/faFileDownload */ 24473);\n\n\n\n\n\n\n\n\n\nconst { toast } = window;\nconst isEmptyValue = (value) => {\n    return !value\n        || (Array.isArray(value) && value.length === 0)\n        || (typeof value === 'object' && Object.keys(value).length === 0)\n        || value === '';\n};\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__({ email, onEmailUpdated, disabled = false }) {\n    const mutate = (0,_lib_datafetching_email__WEBPACK_IMPORTED_MODULE_1__.useEmailMutate)();\n    const [submitting, setSubmitting] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(false);\n    const { data: schema, isLoading: isLoadingSchema } = (0,_lib_datafetching_email__WEBPACK_IMPORTED_MODULE_1__.useEmailSettingsSchema)(email);\n    const [exporting, setExporting] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(false);\n    const [importing, setImporting] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(false);\n    const importRef = react__WEBPACK_IMPORTED_MODULE_0___default().useRef(null);\n    const [settings, setSettings] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(email.settings ?? {});\n    const saveSettings = (data) => {\n        setSubmitting(true);\n        (0,_lib_actions_email__WEBPACK_IMPORTED_MODULE_5__.saveEmail)({ ...email, settings: data })\n            .catch((error) => {\n            toast.error('Error saving email sections: ' + error.message);\n        })\n            .then((email) => {\n            toast.success('Email sections saved', { duration: 3000 });\n            onEmailUpdated(email);\n        })\n            .finally(() => setSubmitting(false));\n    };\n    const exportSettings = () => {\n        setExporting(true);\n        (0,_lib_actions_email__WEBPACK_IMPORTED_MODULE_5__.exportEmail)(email)\n            .then(response => {\n            const a = document.createElement(\"a\");\n            const file = new Blob([JSON.stringify(response)], { type: 'text/plain' });\n            a.href = URL.createObjectURL(file);\n            a.download = 'export-' + email.id + '.json';\n            a.click();\n        })\n            .catch(err => toast.error(`Error exporting email settings: ${err.message}`))\n            .finally(() => setExporting(false));\n    };\n    const importSettings = () => {\n        setImporting(true);\n        const response = confirm(\"Importing email settings will overwrite your current settings. Make sure you have a backup of your current settings. Do you want to continue?\");\n        if (!response) {\n            setImporting(false);\n            return;\n        }\n        importRef.current?.click();\n    };\n    const onFileInput = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((e) => {\n        const file = e.target.files?.[0];\n        if (file) {\n            const reader = new FileReader();\n            reader.onload = (evt) => {\n                const content = evt.target?.result;\n                try {\n                    const data = JSON.parse(content);\n                    (0,_lib_actions_email__WEBPACK_IMPORTED_MODULE_5__.importEmail)(email, data)\n                        .then((email) => mutate(email))\n                        .catch((error) => toast.error('Error importing email settings: ' + error.message))\n                        .finally(() => setImporting(false));\n                }\n                catch (e) {\n                    toast.error('Error reading file: ' + (e instanceof Error ? e.message : 'Unknown error'));\n                }\n            };\n            reader.readAsText(file);\n        }\n    }, [email]);\n    const suppressEmptyOptionalObjectError = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((errors) => {\n        function shouldSuppressError(formData, error) {\n            if (error.name === 'required' && error.property) {\n                const parentFieldId = error.property\n                    .replace(`['${error.params.missingProperty}']`, '')\n                    .replace(\"['\", '')\n                    .replace(\"']\", '');\n                const parentFieldValue = formData[parentFieldId];\n                return Boolean(parentFieldId) && JSON.stringify(parentFieldValue) === '{}';\n            }\n            if (error.property && isEmptyValue(settings[error.property])) {\n                return true;\n            }\n            return false;\n        }\n        return errors.filter(error => !shouldSuppressError(settings, error));\n    }, [settings]);\n    return react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null,\n        isLoadingSchema && react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"div\", { className: 'flex justify-center mb-2' },\n            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.Spinner, null)),\n        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_lib_rjsf_SchemaForm__WEBPACK_IMPORTED_MODULE_2__[\"default\"], { disabled: disabled || isLoadingSchema || submitting, schema: schema ?? {}, uiSchema: js_schema_settings_uiSchema_json__WEBPACK_IMPORTED_MODULE_3__, data: settings, transformErrors: suppressEmptyOptionalObjectError, onSubmit: saveSettings, onChange: ({ formData }) => {\n                setSettings(formData);\n            }, submitLabel: submitting ? 'Saving...' : 'Save' }),\n        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.ButtonGroup, { size: 'sm', color: 'white', fullWidth: true, className: 'mt-2' },\n            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.Button, { onClick: importSettings, className: 'border border-gray-200 inline-flex justify-center', disabled: importing },\n                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_fortawesome_react_fontawesome__WEBPACK_IMPORTED_MODULE_6__.FontAwesomeIcon, { icon: _fortawesome_free_solid_svg_icons_faFileUpload__WEBPACK_IMPORTED_MODULE_7__.faFileUpload, className: 'pr-1' }),\n                importing ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.Spinner, { className: 'w-4 h-4 pr-1' }) : 'Import'),\n            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.Button, { onClick: exportSettings, className: 'border border-gray-200 inline-flex justify-center', disabled: exporting },\n                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_fortawesome_react_fontawesome__WEBPACK_IMPORTED_MODULE_6__.FontAwesomeIcon, { icon: _fortawesome_free_solid_svg_icons_faFileDownload__WEBPACK_IMPORTED_MODULE_8__.faFileDownload, className: 'pr-1' }),\n                exporting ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_tailwind_react__WEBPACK_IMPORTED_MODULE_4__.Spinner, { className: 'w-4 h-4 pr-1' }) : 'Export')),\n        react__WEBPACK_IMPORTED_MODULE_0___default().createElement(\"input\", { type: 'file', accept: 'application/json', className: 'hidden', onInput: onFileInput, ref: importRef }));\n}\n\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./assets/src/js/react/components/EmailSettings.tsx?");

/***/ }),

/***/ 76701:
/*!***********************************************************!*\
  !*** ./assets/src/js/react/routes/EmailSettingsRoute.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_3__ = __webpack_require__(/*! react-router */ 89250);\n/* harmony import */ var _components_EmailSettings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/EmailSettings */ 55945);\n/* harmony import */ var _lib_datafetching_email__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../lib/datafetching/email */ 21954);\n\n\n\n\n/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {\n    const revalidateAll = (0,_lib_datafetching_email__WEBPACK_IMPORTED_MODULE_2__.useEmailsMutate)();\n    const ctx = (0,react_router__WEBPACK_IMPORTED_MODULE_3__.useOutletContext)();\n    const onUpdated = () => {\n        revalidateAll();\n    };\n    return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_components_EmailSettings__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/EmailSettingsRoute.tsx?");

/***/ }),

/***/ 99711:
/*!*****************************************************!*\
  !*** ./assets/src/js/schema/settings.uiSchema.json ***!
  \*****************************************************/
/***/ ((module) => {

eval("module.exports = JSON.parse('{\"ui:submitButtonOptions\":{\"props\":{\"className\":\"self-end\"}},\"trigger_hooks\":{\"ui:widget\":\"multiselect\"}}');\n\n//# sourceURL=webpack://woocommerce-rtm-custom-emails/./assets/src/js/schema/settings.uiSchema.json?");

/***/ })

}]);