@bigbinary/neeto-themes-frontend 4.0.25 → 4.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2600 @@
1
+ import { shallow } from 'zustand/shallow';
2
+ import { Suspense, lazy, useEffect, createElement, useState, memo, useRef, useCallback, useMemo } from 'react';
3
+ import { Toastr, Spinner, Typography, Button, ColorPicker, Select, Checkbox, Switch, Input, Tooltip, Popover, Alert } from '@bigbinary/neeto-atoms';
4
+ import { isPresent, hyphenate, findBy, findIndexBy, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, capitalize, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
+ import { useQueryParams, useBreakpoints, PageTitle } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
6
+ import { useTranslation, Trans } from 'react-i18next';
7
+ import { u as useShowGlobalTheme, a as useFetchTheme, b as useCreateTheme, c as useUpdateTheme, d as routes, e as useCloneTheme, f as useApplyTheme, g as useListThemes, h as useShowThemeEntity, i as useDeleteTheme, r as registerNeetoThemesTranslations } from '../useGlobalThemesApi-NQA1B1Zs.js';
8
+ import { a as useExpandedSection, b as useConfigStore, c as useThemeStore, u as useThemeUtils, d as useSyncExpandedSectionFromUrl } from '../useExpandedSection-CelNLEKQ.js';
9
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
10
+ import _regeneratorRuntime from '@babel/runtime/regenerator';
11
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
12
+ import classnames from 'classnames';
13
+ import { joinHyphenCase, buildUrl } from '@bigbinary/neeto-commons-frontend/v2/utils';
14
+ import Collapse from '@bigbinary/neeto-icons/Collapse';
15
+ import { useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
16
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
17
+ import { RadioGroup, Input as Input$1, Form, BlockNavigation } from '@bigbinary/neeto-atoms/formik';
18
+ import Close from '@bigbinary/neeto-icons/Close';
19
+ import { isEmpty, negate, isNotNil } from 'ramda';
20
+ import i18n, { t } from 'i18next';
21
+ import * as yup from 'yup';
22
+ import { useFormikContext, Field } from 'formik';
23
+ import { c as setCustomCSS } from '../index-BZB12oJt.js';
24
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
25
+ import Right from '@bigbinary/neeto-icons/Right';
26
+ import Left from '@bigbinary/neeto-icons/Left';
27
+ import HelpPopover from '@bigbinary/neeto-molecules/v2/HelpPopover';
28
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
29
+ import { flushSync } from 'react-dom';
30
+ import CenterAlign from '@bigbinary/neeto-icons/CenterAlign';
31
+ import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
32
+ import { Slider } from 'antd';
33
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
34
+ import ImageUploader from '@bigbinary/neeto-image-uploader-frontend/v2/ImageUploader';
35
+ import Search from '@bigbinary/neeto-molecules/v2/Search';
36
+ import AddImage from '@bigbinary/neeto-icons/AddImage';
37
+ import CodeBlock from '@bigbinary/neeto-icons/CodeBlock';
38
+ import ColorPicker$1 from '@bigbinary/neeto-icons/ColorPicker';
39
+ import MoreDropdown from '@bigbinary/neeto-molecules/v2/MoreDropdown';
40
+ import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
41
+ import RightArrow from '@bigbinary/neeto-icons/RightArrow';
42
+ import Search$1 from '@bigbinary/neeto-icons/Search';
43
+ import '@tanstack/react-query';
44
+ import 'axios';
45
+ import '@bigbinary/neeto-commons-frontend/react-utils';
46
+ import 'zustand';
47
+ import '@bigbinary/neetoui/Toastr';
48
+
49
+ var getImageFromUrl = function getImageFromUrl(source) {
50
+ var image = new Image();
51
+ image.crossOrigin = "anonymous";
52
+ image.src = source;
53
+ return new Promise(function (resolve) {
54
+ image.onload = function () {
55
+ resolve(image);
56
+ };
57
+ });
58
+ };
59
+ var getDominantColorFromUrl = /*#__PURE__*/function () {
60
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(imageUrl) {
61
+ var image, context, c;
62
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
63
+ while (1) switch (_context.prev = _context.next) {
64
+ case 0:
65
+ _context.prev = 0;
66
+ _context.next = 3;
67
+ return getImageFromUrl(imageUrl);
68
+ case 3:
69
+ image = _context.sent;
70
+ context = document.createElement("canvas").getContext("2d");
71
+ context === null || context === void 0 || context.drawImage(image, 0, 0, 1, 1);
72
+ c = context === null || context === void 0 ? void 0 : context.getImageData(0, 0, 1, 1).data;
73
+ if (!c) {
74
+ _context.next = 9;
75
+ break;
76
+ }
77
+ return _context.abrupt("return", "#".concat(((1 << 24) + (c[0] << 16) + (c[1] << 8) + c[2]).toString(16).slice(1)));
78
+ case 9:
79
+ return _context.abrupt("return", null);
80
+ case 12:
81
+ _context.prev = 12;
82
+ _context.t0 = _context["catch"](0);
83
+ Toastr.error(_context.t0);
84
+ return _context.abrupt("return", null);
85
+ case 16:
86
+ case "end":
87
+ return _context.stop();
88
+ }
89
+ }, _callee, null, [[0, 12]]);
90
+ }));
91
+ return function getDominantColorFromUrl(_x) {
92
+ return _ref.apply(this, arguments);
93
+ };
94
+ }();
95
+ var scrollElementIntoView = function scrollElementIntoView(elementId) {
96
+ var elementToScroll = document.getElementById(elementId);
97
+ var sidebarContainer = document.querySelector(".neeto-themes-sidebar__scroll");
98
+ if (!elementToScroll || !sidebarContainer) return;
99
+ var elementRect = elementToScroll.getBoundingClientRect();
100
+ var sidebarContainerRect = sidebarContainer.getBoundingClientRect();
101
+ var offset = elementRect.top - sidebarContainerRect.top + sidebarContainer.scrollTop;
102
+ sidebarContainer.scrollTo({
103
+ top: offset,
104
+ behavior: "smooth"
105
+ });
106
+ };
107
+ var isFunction = function isFunction(obj) {
108
+ return typeof obj === "function";
109
+ };
110
+ var isNewThemeRoute = function isNewThemeRoute() {
111
+ return location.pathname.endsWith("new");
112
+ };
113
+ var isEditThemeRoute = function isEditThemeRoute() {
114
+ return location.pathname.endsWith("edit");
115
+ };
116
+
117
+ // Keeps the spinner visible a bit longer so the apply feels deliberate,
118
+ // before the card glides into the pinned active section.
119
+ var APPLY_SPINNER_DELAY = 900;
120
+
121
+ var POSITION_OPTIONS = [{
122
+ label: "Left",
123
+ value: "left"
124
+ }, {
125
+ label: "Right",
126
+ value: "right"
127
+ }];
128
+ var FONT_OPTIONS = [{
129
+ label: "System UI",
130
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
131
+ }, {
132
+ label: "Cedarville Cursive",
133
+ value: "'Cedarville Cursive', cursive"
134
+ }, {
135
+ label: "Poppins",
136
+ value: "Poppins, sans-serif"
137
+ }, {
138
+ label: "Roboto",
139
+ value: "Roboto, sans-serif"
140
+ }, {
141
+ label: "Open Sans",
142
+ value: "Open Sans, sans-serif"
143
+ }, {
144
+ label: "Montserrat",
145
+ value: "Montserrat, sans-serif"
146
+ }, {
147
+ label: "Raleway",
148
+ value: "Raleway, sans-serif"
149
+ }, {
150
+ label: "Quicksand",
151
+ value: "Quicksand, sans-serif"
152
+ }, {
153
+ label: "Inter",
154
+ value: "Inter, sans-serif"
155
+ }, {
156
+ label: "Satoshi",
157
+ value: "Satoshi, sans-serif"
158
+ }, {
159
+ label: "Chillax",
160
+ value: "Chillax, sans-serif"
161
+ }, {
162
+ label: "Clash Display",
163
+ value: "Clash Display, sans-serif"
164
+ }, {
165
+ label: "General Sans",
166
+ value: "General Sans, sans-serif"
167
+ }, {
168
+ label: "Cabinet Grotesk",
169
+ value: "Cabinet Grotesk, sans-serif"
170
+ }, {
171
+ label: "Lora",
172
+ value: "Lora, serif"
173
+ }, {
174
+ label: "Merriweather",
175
+ value: "Merriweather, serif"
176
+ }, {
177
+ label: "Boska",
178
+ value: "Boska, serif"
179
+ }, {
180
+ label: "Playfair Display",
181
+ value: "Playfair Display, serif"
182
+ }, {
183
+ label: "Roboto Slab",
184
+ value: "Roboto Slab, serif"
185
+ }, {
186
+ label: "Dancing Script",
187
+ value: "Dancing Script, cursive"
188
+ }, {
189
+ label: "Tw Cent",
190
+ value: "Tw Cen MT, Tahoma, sans-serif"
191
+ }, {
192
+ label: "Comic Sans",
193
+ value: "Comic Sans MS, cursive"
194
+ }];
195
+ var THEME_VALIDATION_SCHEMA = yup.object().shape({
196
+ name: yup.string().required(function () {
197
+ return t("neetoThemes.validations.nameRequired");
198
+ }),
199
+ properties: yup.array().of(yup.object().shape({
200
+ key: yup.string(),
201
+ value: yup.string().when("key", {
202
+ is: function is(key) {
203
+ return key === null || key === void 0 ? void 0 : key.endsWith("_url");
204
+ },
205
+ then: function then(schema) {
206
+ return schema.url(function () {
207
+ return t("neetoThemes.validations.invalidUrl");
208
+ });
209
+ }
210
+ })
211
+ }))
212
+ });
213
+ var OVERLAY_OPACITY_SLIDER_MARKS = {
214
+ 0: " "
215
+ };
216
+ var HUNDRED = 100;
217
+
218
+ var DESIGN_SCREENS = {
219
+ THEMES: "Themes",
220
+ Customize: "Customize",
221
+ CustomCSS: "CustomCSS"
222
+ };
223
+ var ONE_MEGABYTE = 1;
224
+
225
+ var MonacoEditor = /*#__PURE__*/lazy(function () {
226
+ return import('@monaco-editor/react');
227
+ });
228
+ var Editor = function Editor(_ref) {
229
+ var value = _ref.value,
230
+ isCustomCssScreen = _ref.isCustomCssScreen,
231
+ onChange = _ref.onChange;
232
+ return /*#__PURE__*/jsx(Suspense, {
233
+ fallback: /*#__PURE__*/jsx(Spinner, {}),
234
+ children: /*#__PURE__*/jsx(MonacoEditor, {
235
+ onChange: onChange,
236
+ value: value,
237
+ language: "css",
238
+ theme: "vs-dark",
239
+ className: classnames({
240
+ rounded: true,
241
+ "css-editor-height__expanded": isCustomCssScreen,
242
+ "css-editor-height__regular": !isCustomCssScreen
243
+ }),
244
+ options: {
245
+ scrollBeyondLastLine: false,
246
+ minimap: {
247
+ enabled: false
248
+ }
249
+ }
250
+ })
251
+ });
252
+ };
253
+
254
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
255
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
256
+ var Card$2 = function Card(_ref) {
257
+ var _ref$title = _ref.title,
258
+ title = _ref$title === void 0 ? "" : _ref$title,
259
+ children = _ref.children,
260
+ name = _ref.name,
261
+ className = _ref.className,
262
+ helpPopoverProps = _ref.helpPopoverProps,
263
+ required = _ref.required;
264
+ var _useExpandedSection = useExpandedSection(),
265
+ expandedSection = _useExpandedSection.expandedSection,
266
+ setExpandedSection = _useExpandedSection.setExpandedSection;
267
+ var isOpen = expandedSection === name;
268
+ var isRTL = i18n.dir() === "rtl";
269
+ var ToggleIcon = isRTL ? Left : Right;
270
+ var handleToggle = function handleToggle() {
271
+ return setExpandedSection(isOpen ? "" : name);
272
+ };
273
+ return /*#__PURE__*/jsxs("div", {
274
+ "data-testid": "theme-".concat(hyphenate(title), "-properties"),
275
+ className: classnames("neeto-themes-nano-section border-border border-b pt-2 transition-all duration-300 last:border-none", className, {
276
+ "pb-2": !isOpen,
277
+ "pb-3": isOpen
278
+ }),
279
+ children: [title && /*#__PURE__*/jsxs("button", {
280
+ className: "neeto-themes-nano-section__title flex w-full cursor-pointer items-center justify-between px-1 py-2 focus:outline-none",
281
+ type: "button",
282
+ onClick: handleToggle,
283
+ children: [/*#__PURE__*/jsx(Typography, {
284
+ asChild: true,
285
+ className: "flex min-w-0 grow items-center gap-2 text-start",
286
+ "data-testid": "theme-properties",
287
+ variant: "h4",
288
+ weight: "semibold",
289
+ children: /*#__PURE__*/jsxs("span", {
290
+ children: [title, required && /*#__PURE__*/jsx("span", {
291
+ "aria-hidden": true,
292
+ className: "-ms-1",
293
+ children: "*"
294
+ }), isPresent(helpPopoverProps) && /*#__PURE__*/jsx(HelpPopover, _objectSpread$4({}, helpPopoverProps))]
295
+ })
296
+ }), /*#__PURE__*/jsx(ToggleIcon, {
297
+ size: 20,
298
+ className: classnames("transition-all duration-300", {
299
+ "rotate-90 rtl:-rotate-90": isOpen
300
+ })
301
+ })]
302
+ }), children && /*#__PURE__*/jsx("div", {
303
+ className: classnames("neeto-themes-nano-section__content w-full space-y-3 overflow-hidden px-1 transition-all duration-300", {
304
+ "neeto-themes-nano-section__content--closed": !isOpen,
305
+ "neeto-themes-nano-section__content--open pb-1": isOpen
306
+ }),
307
+ children: children
308
+ })]
309
+ });
310
+ };
311
+
312
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
313
+ 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; } }
314
+ 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; }
315
+ var isScreenCustomCSS = function isScreenCustomCSS(screen) {
316
+ return screen === DESIGN_SCREENS.CustomCSS;
317
+ };
318
+ var buildPathname = function buildPathname(route) {
319
+ var pathname = "";
320
+ var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
321
+ _step;
322
+ try {
323
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
324
+ var segment = _step.value;
325
+ if (isEmpty(segment)) {
326
+ continue;
327
+ }
328
+ if (segment === "themes") {
329
+ break;
330
+ }
331
+ pathname += "/".concat(segment);
332
+ }
333
+ } catch (err) {
334
+ _iterator.e(err);
335
+ } finally {
336
+ _iterator.f();
337
+ }
338
+ return "".concat(pathname).concat(route);
339
+ };
340
+
341
+ // FLIP: measure each theme card's position, apply the React update, then
342
+ // transform every card back to its old spot and let a CSS transition glide
343
+ // it to the new one. The animation itself is CSS (.neeto-themes-flip-animating).
344
+ var animateThemeReorder = function animateThemeReorder(updateFn) {
345
+ var prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
346
+ var cards = _toConsumableArray(document.querySelectorAll("[data-flip-id]"));
347
+ var scrollContainer = document.querySelector(".neeto-themes-sidebar__scroll");
348
+ if (prefersReducedMotion || cards.length === 0) {
349
+ updateFn();
350
+ if (scrollContainer) scrollContainer.scrollTop = 0;
351
+ return;
352
+ }
353
+ var oldRects = new Map(cards.map(function (card) {
354
+ return [card.dataset.flipId, card.getBoundingClientRect()];
355
+ }));
356
+ flushSync(updateFn);
357
+
358
+ // Move the viewport to the top — the applied theme is now the first card.
359
+ // The FLIP deltas below are measured after this, so the scroll is folded
360
+ // into the glide instead of showing as an instant jump.
361
+ if (scrollContainer) scrollContainer.scrollTop = 0;
362
+ var flips = _toConsumableArray(document.querySelectorAll("[data-flip-id]")).map(function (card) {
363
+ var oldRect = oldRects.get(card.dataset.flipId);
364
+ if (!oldRect) return null;
365
+ var newRect = card.getBoundingClientRect();
366
+ var dx = oldRect.left - newRect.left;
367
+ var dy = oldRect.top - newRect.top;
368
+ return dx || dy ? {
369
+ card: card,
370
+ dx: dx,
371
+ dy: dy
372
+ } : null;
373
+ }).filter(Boolean);
374
+ if (flips.length === 0) return;
375
+ flips.forEach(function (_ref) {
376
+ var card = _ref.card,
377
+ dx = _ref.dx,
378
+ dy = _ref.dy;
379
+ card.style.transform = "translate(".concat(dx, "px, ").concat(dy, "px)");
380
+ });
381
+
382
+ // Force a reflow so the starting transform is committed before animating.
383
+ document.body.offsetHeight;
384
+ flips.forEach(function (_ref2) {
385
+ var card = _ref2.card;
386
+ card.classList.add("neeto-themes-flip-animating");
387
+ card.style.transform = "";
388
+ card.addEventListener("transitionend", function () {
389
+ card.classList.remove("neeto-themes-flip-animating");
390
+ }, {
391
+ once: true
392
+ });
393
+ });
394
+ };
395
+
396
+ var CustomCSS = function CustomCSS(_ref) {
397
+ var onEditCSSClick = _ref.onEditCSSClick,
398
+ currentScreen = _ref.currentScreen,
399
+ isEnabled = _ref.isEnabled,
400
+ isProFeature = _ref.isProFeature;
401
+ var _useTranslation = useTranslation(),
402
+ t = _useTranslation.t;
403
+ var _useFormikContext = useFormikContext(),
404
+ values = _useFormikContext.values,
405
+ setFieldValue = _useFormikContext.setFieldValue;
406
+ var _useConfigStore = useConfigStore(function (store) {
407
+ return {
408
+ themePropertiesSchema: store["themePropertiesSchema"],
409
+ helpPopoverProps: store["helpPopoverProps"]
410
+ };
411
+ }, shallow),
412
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
413
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
414
+ var _helpPopoverProps$cus = helpPopoverProps.customCss,
415
+ customCssHelpPopoverProps = _helpPopoverProps$cus === void 0 ? {} : _helpPopoverProps$cus;
416
+ var _useExpandedSection = useExpandedSection(),
417
+ expandedSection = _useExpandedSection.expandedSection;
418
+ var isExpanded = expandedSection === "customcss";
419
+ var customCSS = findBy({
420
+ kind: "custom_css"
421
+ }, values.properties);
422
+ if (!customCSS || !isEnabled && !isProFeature) return null;
423
+ var parentElementClass = findBy({
424
+ kind: "custom_css"
425
+ }, themePropertiesSchema).parentClass;
426
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
427
+ var handleEditorToggle = function handleEditorToggle() {
428
+ if (!isCustomCssScreen) return onEditCSSClick(DESIGN_SCREENS.CustomCSS);
429
+ onEditCSSClick(DESIGN_SCREENS.Customize);
430
+ return setTimeout(function () {
431
+ scrollElementIntoView("css-editor");
432
+ }, 400);
433
+ };
434
+ var handleChange = function handleChange(value) {
435
+ var index = findIndexBy({
436
+ key: customCSS.key
437
+ }, values.properties);
438
+ if (index !== -1 && values.properties[index].value !== value) {
439
+ setFieldValue("properties[".concat(index, "].value"), value);
440
+ setCustomCSS({
441
+ css: value,
442
+ elementId: customCSS.key,
443
+ parentElementClass: parentElementClass
444
+ });
445
+ }
446
+ };
447
+ return /*#__PURE__*/jsx("div", {
448
+ className: "neeto-themes-sidebar__custom-css-wrapper",
449
+ id: "css-editor",
450
+ children: /*#__PURE__*/jsx(Card$2, {
451
+ name: "customcss",
452
+ helpPopoverProps: isEnabled ? customCssHelpPopoverProps : {
453
+ title: t("neetoThemes.common.proFeature.customCSS.title"),
454
+ description: t("neetoThemes.common.proFeature.customCSS.description")
455
+ },
456
+ title: isCustomCssScreen ? "" : t("neetoThemes.build.leftSideBar.themes.customCSS"),
457
+ children: isEnabled ? /*#__PURE__*/jsxs("div", {
458
+ className: "w-full",
459
+ children: [/*#__PURE__*/jsx("div", {
460
+ className: "neeto-themes-sidebar__custom-css-editor-header w-full justify-end gap-1 rounded-b-none p-2",
461
+ children: /*#__PURE__*/jsx(Button, {
462
+ size: "sm",
463
+ variant: "outline",
464
+ label: isCustomCssScreen ? t("neetoThemes.buttons.minimizeEditor") : t("neetoThemes.buttons.expandEditor"),
465
+ onClick: handleEditorToggle
466
+ })
467
+ }), isExpanded && /*#__PURE__*/jsx(Editor, {
468
+ isCustomCssScreen: isCustomCssScreen,
469
+ value: customCSS.value,
470
+ onChange: handleChange
471
+ })]
472
+ }) : /*#__PURE__*/jsx("div", {
473
+ className: "px-1 py-2",
474
+ children: /*#__PURE__*/jsx(Typography, {
475
+ variant: "body2",
476
+ children: t("neetoThemes.common.proFeature.customCSS.description")
477
+ })
478
+ })
479
+ })
480
+ });
481
+ };
482
+
483
+ var LogoPosition = function LogoPosition() {
484
+ var _useTranslation = useTranslation(),
485
+ t = _useTranslation.t;
486
+ var _useFormikContext = useFormikContext(),
487
+ values = _useFormikContext.values;
488
+ var index = findIndexBy({
489
+ key: "logo_position"
490
+ }, values.properties);
491
+ // Do not show this field if the logo_position property is not present.
492
+ if (index === -1) return null;
493
+ return /*#__PURE__*/jsxs(RadioGroup, {
494
+ name: "properties[".concat(index, "].value"),
495
+ orientation: "vertical",
496
+ label: /*#__PURE__*/jsx(Typography, {
497
+ asChild: true,
498
+ className: "my-3",
499
+ variant: "body2",
500
+ weight: "semibold",
501
+ children: /*#__PURE__*/jsx("span", {
502
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.title")
503
+ })
504
+ }),
505
+ children: [/*#__PURE__*/jsx(RadioGroup.Item, {
506
+ value: "over_left",
507
+ label: /*#__PURE__*/jsxs("span", {
508
+ className: "flex flex-col gap-1",
509
+ children: [/*#__PURE__*/jsx(Typography, {
510
+ asChild: true,
511
+ variant: "body2",
512
+ weight: "semibold",
513
+ children: /*#__PURE__*/jsx("span", {
514
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeft")
515
+ })
516
+ }), /*#__PURE__*/jsx(Typography, {
517
+ asChild: true,
518
+ variant: "body3",
519
+ weight: "normal",
520
+ children: /*#__PURE__*/jsx("span", {
521
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeftDescription")
522
+ })
523
+ })]
524
+ })
525
+ }), /*#__PURE__*/jsx(RadioGroup.Item, {
526
+ value: "below_left",
527
+ label: /*#__PURE__*/jsxs("span", {
528
+ className: "flex flex-col gap-1",
529
+ children: [/*#__PURE__*/jsx(Typography, {
530
+ asChild: true,
531
+ variant: "body2",
532
+ weight: "semibold",
533
+ children: /*#__PURE__*/jsx("span", {
534
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeft")
535
+ })
536
+ }), /*#__PURE__*/jsx(Typography, {
537
+ asChild: true,
538
+ variant: "body3",
539
+ weight: "normal",
540
+ children: /*#__PURE__*/jsx("span", {
541
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeftDescription")
542
+ })
543
+ })]
544
+ })
545
+ })]
546
+ });
547
+ };
548
+
549
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
550
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
551
+
552
+ // Capitalizes the first letter of the displayed label while keeping the
553
+ // underlying value untouched (position values like "top left" are used
554
+ // verbatim as CSS background-position, so they must stay lowercase).
555
+ var toCapitalizedOption = function toCapitalizedOption(value) {
556
+ var _toLabelAndValue = toLabelAndValue(value),
557
+ label = _toLabelAndValue.label,
558
+ optionValue = _toLabelAndValue.value;
559
+ return {
560
+ label: label ? capitalize(label) : label,
561
+ value: optionValue
562
+ };
563
+ };
564
+ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
565
+ if (isPresent(theme)) return theme;
566
+ return {
567
+ name: t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
568
+ properties: themePropertiesSchema.map(function (_ref) {
569
+ var key = _ref.key,
570
+ kind = _ref.kind,
571
+ defaultValue = _ref.defaultValue,
572
+ _ref$order = _ref.order,
573
+ order = _ref$order === void 0 ? null : _ref$order,
574
+ dependsOn = _ref.dependsOn;
575
+ switch (kind) {
576
+ case "text_input":
577
+ return _objectSpread$3({
578
+ value: defaultValue || "",
579
+ kind: "text_input",
580
+ key: key,
581
+ dependsOn: dependsOn
582
+ }, order !== null && {
583
+ order: order
584
+ });
585
+ case "color":
586
+ return _objectSpread$3({
587
+ value: defaultValue,
588
+ kind: "color",
589
+ key: key,
590
+ dependsOn: dependsOn
591
+ }, order !== null && {
592
+ order: order
593
+ });
594
+ case "font_family":
595
+ return _objectSpread$3({
596
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
597
+ kind: "font_family",
598
+ key: key,
599
+ dependsOn: dependsOn
600
+ }, order !== null && {
601
+ order: order
602
+ });
603
+ case "overlay_opacity":
604
+ return _objectSpread$3({
605
+ value: 0,
606
+ kind: "overlay_opacity",
607
+ key: key,
608
+ dependsOn: dependsOn
609
+ }, order !== null && {
610
+ order: order
611
+ });
612
+ case "slider":
613
+ return _objectSpread$3({
614
+ value: 0,
615
+ kind: "slider",
616
+ key: key,
617
+ dependsOn: dependsOn
618
+ }, order !== null && {
619
+ order: order
620
+ });
621
+ case "radius":
622
+ return _objectSpread$3({
623
+ value: defaultValue,
624
+ kind: "radius",
625
+ key: key,
626
+ dependsOn: dependsOn
627
+ }, order !== null && {
628
+ order: order
629
+ });
630
+ case "boolean":
631
+ return _objectSpread$3({
632
+ value: String(defaultValue),
633
+ kind: "boolean",
634
+ key: key,
635
+ dependsOn: dependsOn
636
+ }, order !== null && {
637
+ order: order
638
+ });
639
+ case "order_selector":
640
+ return _objectSpread$3({
641
+ value: defaultValue,
642
+ kind: "order_selector",
643
+ key: key,
644
+ dependsOn: dependsOn
645
+ }, order !== null && {
646
+ order: order
647
+ });
648
+ case "alignment_block":
649
+ return _objectSpread$3({
650
+ value: defaultValue,
651
+ kind: "alignment_block",
652
+ key: key,
653
+ dependsOn: dependsOn
654
+ }, order !== null && {
655
+ order: order
656
+ });
657
+ case "custom_css":
658
+ return _objectSpread$3({
659
+ value: defaultValue,
660
+ kind: "custom_css",
661
+ key: key,
662
+ dependsOn: dependsOn
663
+ }, order !== null && {
664
+ order: order
665
+ });
666
+ case "logo_position":
667
+ return _objectSpread$3({
668
+ value: defaultValue,
669
+ kind: "logo_position",
670
+ key: key,
671
+ dependsOn: dependsOn
672
+ }, order !== null && {
673
+ order: order
674
+ });
675
+ default:
676
+ return null;
677
+ }
678
+ }).filter(isNot(null))
679
+ };
680
+ };
681
+ var buildImageData = function buildImageData(values, themePropertiesSchema) {
682
+ return filterBy({
683
+ kind: "image"
684
+ }, themePropertiesSchema).reduce(function (acc, item) {
685
+ var _values$snakeToCamelC;
686
+ var signedId = (_values$snakeToCamelC = values[snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
687
+ acc[item.key] = signedId;
688
+ return acc;
689
+ }, {});
690
+ };
691
+ var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
692
+ var property = findBy({
693
+ key: key
694
+ }, themePropertiesSchema);
695
+ if (isNotPresent(property)) return false;
696
+ if (property !== null && property !== void 0 && property.hidden) return false;
697
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
698
+ if (isNotPresent(conditionalKey)) return true;
699
+ var dependentPropertySchema = findBy({
700
+ key: conditionalKey
701
+ }, themePropertiesSchema);
702
+ var dependentProperty = findBy({
703
+ key: conditionalKey
704
+ }, formikValues.properties);
705
+ if (dependentPropertySchema.kind === "image") {
706
+ var _formikValues$snakeTo;
707
+ return isPresent((_formikValues$snakeTo = formikValues[snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
708
+ } else if (dependentPropertySchema.kind === "boolean") {
709
+ return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
710
+ }
711
+ return isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
712
+ };
713
+ var buildLabel = function buildLabel(key, kind) {
714
+ return t("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
715
+ };
716
+ var buildProperties = function buildProperties(values, condition, themePropertiesSchema) {
717
+ values.forEach(function (value) {
718
+ themePropertiesSchema.forEach(function (theme) {
719
+ if (!(value.key === theme.key)) return;
720
+ value.dependsOn = theme.dependsOn;
721
+ });
722
+ });
723
+ if (condition) {
724
+ return filterBy({
725
+ dependsOn: condition
726
+ }, values);
727
+ }
728
+ var imageKeys = new Set();
729
+ filterBy({
730
+ kind: "image"
731
+ }, themePropertiesSchema).forEach(function (ele) {
732
+ return imageKeys.add(ele.key);
733
+ });
734
+ return values === null || values === void 0 ? void 0 : values.filter(function (_ref2) {
735
+ var dependsOn = _ref2.dependsOn;
736
+ return !imageKeys.has(dependsOn);
737
+ });
738
+ };
739
+
740
+ var AlignmentBlock = function AlignmentBlock(_ref) {
741
+ var label = _ref.label,
742
+ name = _ref.name;
743
+ return /*#__PURE__*/jsxs("div", {
744
+ className: "flex items-center justify-between gap-2",
745
+ "data-testid": joinHyphenCase(label),
746
+ children: [/*#__PURE__*/jsx(Typography, {
747
+ "data-testid": "style-fields-labels",
748
+ variant: "body2",
749
+ children: label
750
+ }), /*#__PURE__*/jsx(Field, {
751
+ name: name,
752
+ children: function children(_ref2) {
753
+ var value = _ref2.field.value,
754
+ setFieldValue = _ref2.form.setFieldValue;
755
+ return /*#__PURE__*/jsxs("div", {
756
+ className: "border-input neeto-themes-nano-alignment-block flex items-center border",
757
+ children: [/*#__PURE__*/jsx(Button, {
758
+ className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-left",
759
+ "data-testid": "alignment-left",
760
+ variant: value === "left" ? "default" : "ghost",
761
+ icon: function icon() {
762
+ return /*#__PURE__*/jsx(LeftAlign, {
763
+ size: 20,
764
+ className: classnames({
765
+ rounded: true,
766
+ "text-primary": value === "left",
767
+ "text-muted-foreground": value !== "left"
768
+ })
769
+ });
770
+ },
771
+ tooltipProps: {
772
+ content: "Left align",
773
+ position: "bottom"
774
+ },
775
+ onClick: function onClick() {
776
+ return setFieldValue(name, "left");
777
+ }
778
+ }), /*#__PURE__*/jsx("div", {
779
+ className: "neeto-themes-nano-alignment-divider"
780
+ }), /*#__PURE__*/jsx(Button, {
781
+ className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-center",
782
+ "data-testid": "alignment-center",
783
+ variant: value === "center" ? "default" : "ghost",
784
+ icon: function icon() {
785
+ return /*#__PURE__*/jsx(CenterAlign, {
786
+ size: 20,
787
+ className: classnames({
788
+ rounded: true,
789
+ "text-primary": value === "center",
790
+ "text-muted-foreground": value !== "center"
791
+ })
792
+ });
793
+ },
794
+ tooltipProps: {
795
+ content: "Center align",
796
+ position: "bottom"
797
+ },
798
+ onClick: function onClick() {
799
+ return setFieldValue(name, "center");
800
+ }
801
+ })]
802
+ });
803
+ }
804
+ })]
805
+ });
806
+ };
807
+
808
+ var ColorBlock = function ColorBlock(_ref) {
809
+ var label = _ref.label,
810
+ _ref$color = _ref.color,
811
+ color = _ref$color === void 0 ? "#FFFFFF" : _ref$color,
812
+ onChange = _ref.onChange,
813
+ showTransparencyControl = _ref.showTransparencyControl;
814
+ return /*#__PURE__*/jsxs("div", {
815
+ className: "flex items-center justify-between",
816
+ "data-testid": "theme-style-".concat(joinHyphenCase(label)),
817
+ children: [/*#__PURE__*/jsx(Typography, {
818
+ "data-testid": "style-fields-labels",
819
+ variant: "body2",
820
+ children: label
821
+ }), /*#__PURE__*/jsx(ColorPicker, {
822
+ color: color,
823
+ onChange: onChange,
824
+ showTransparencyControl: showTransparencyControl,
825
+ showEyeDropper: true,
826
+ size: "medium"
827
+ })]
828
+ });
829
+ };
830
+
831
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
832
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
833
+ var FontPickerBlock = function FontPickerBlock(_ref) {
834
+ var label = _ref.label,
835
+ _ref$placeholder = _ref.placeholder,
836
+ placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
837
+ value = _ref.value,
838
+ options = _ref.options,
839
+ onChange = _ref.onChange;
840
+ return /*#__PURE__*/jsxs("div", {
841
+ className: "flex items-center justify-between",
842
+ "data-testid": "theme-style-".concat(joinHyphenCase(label)),
843
+ children: [/*#__PURE__*/jsx(Typography, {
844
+ "data-testid": "style-fields-labels",
845
+ variant: "body2",
846
+ children: label
847
+ }), /*#__PURE__*/jsx("div", {
848
+ className: "w-40",
849
+ children: /*#__PURE__*/jsx(Select, {
850
+ onChange: onChange,
851
+ options: options,
852
+ placeholder: placeholder,
853
+ value: value,
854
+ menuPosition: "fixed",
855
+ styles: {
856
+ option: function option(styles, _ref2) {
857
+ var data = _ref2.data;
858
+ return _objectSpread$2(_objectSpread$2({}, styles), {}, {
859
+ fontFamily: data.value
860
+ });
861
+ }
862
+ }
863
+ })
864
+ })]
865
+ });
866
+ };
867
+
868
+ var SelectBlock = function SelectBlock(_ref) {
869
+ var label = _ref.label,
870
+ _ref$placeholder = _ref.placeholder,
871
+ placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
872
+ value = _ref.value,
873
+ options = _ref.options,
874
+ onChange = _ref.onChange;
875
+ return /*#__PURE__*/jsxs("div", {
876
+ className: "border-border flex flex-col gap-2 border-t pt-3",
877
+ "data-testid": "theme-style-".concat(joinHyphenCase(label)),
878
+ children: [/*#__PURE__*/jsx(Typography, {
879
+ "data-testid": "logo-field-labels",
880
+ variant: "body2",
881
+ children: label
882
+ }), /*#__PURE__*/jsx(Select, {
883
+ onChange: onChange,
884
+ options: options,
885
+ placeholder: placeholder,
886
+ value: value
887
+ })]
888
+ });
889
+ };
890
+
891
+ var SliderBlock = function SliderBlock(_ref) {
892
+ var label = _ref.label,
893
+ onChange = _ref.onChange,
894
+ value = _ref.value,
895
+ min = _ref.min,
896
+ max = _ref.max,
897
+ marks = _ref.marks;
898
+ return /*#__PURE__*/jsxs("div", {
899
+ className: "flex items-center justify-between gap-3",
900
+ "data-testid": "theme-style-".concat(joinHyphenCase(label)),
901
+ children: [/*#__PURE__*/jsx(Typography, {
902
+ "data-testid": "style-fields-labels",
903
+ variant: "body2",
904
+ children: label
905
+ }), /*#__PURE__*/jsx(Slider, {
906
+ marks: marks,
907
+ max: max,
908
+ min: min,
909
+ onChange: onChange,
910
+ value: value,
911
+ className: "my-2 w-20",
912
+ tooltip: {
913
+ formatter: null
914
+ }
915
+ })]
916
+ });
917
+ };
918
+
919
+ var _excluded = ["label", "name", "asCheckbox"];
920
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
921
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
922
+ var SwitchBlock = function SwitchBlock(_ref) {
923
+ var label = _ref.label,
924
+ name = _ref.name,
925
+ _ref$asCheckbox = _ref.asCheckbox,
926
+ asCheckbox = _ref$asCheckbox === void 0 ? false : _ref$asCheckbox,
927
+ inputProps = _objectWithoutProperties(_ref, _excluded);
928
+ var _useTranslation = useTranslation(),
929
+ t = _useTranslation.t,
930
+ i18n = _useTranslation.i18n;
931
+ var translationKey = "neetoThemes.properties.boolean.".concat(name, "HelpText");
932
+ var doesHelpTextExist = i18n.exists(translationKey);
933
+ if (asCheckbox) {
934
+ return /*#__PURE__*/jsxs("div", {
935
+ className: "flex items-center gap-2",
936
+ "data-testid": "theme-style-content-background",
937
+ children: [/*#__PURE__*/jsx(Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
938
+ label: label,
939
+ name: name
940
+ }, inputProps)), {}, {
941
+ "data-testid": "enable-background-color-toggle"
942
+ })), doesHelpTextExist && /*#__PURE__*/jsx(HelpPopover, {
943
+ className: "shrink-0",
944
+ description: t(translationKey)
945
+ })]
946
+ });
947
+ }
948
+ return /*#__PURE__*/jsxs("div", {
949
+ className: "flex items-center justify-between",
950
+ "data-testid": "theme-style-content-background",
951
+ children: [/*#__PURE__*/jsxs("div", {
952
+ className: "inline-flex items-center gap-4",
953
+ children: [/*#__PURE__*/jsx(Typography, {
954
+ "data-testid": "style-fields-labels",
955
+ variant: "body2",
956
+ className: classnames({
957
+ "w-32": doesHelpTextExist,
958
+ "w-auto": !doesHelpTextExist
959
+ }),
960
+ children: label
961
+ }), doesHelpTextExist && /*#__PURE__*/jsx(HelpPopover, {
962
+ className: "shrink-0",
963
+ description: t(translationKey)
964
+ })]
965
+ }), /*#__PURE__*/jsx(Switch, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
966
+ name: name
967
+ }, inputProps)), {}, {
968
+ "data-testid": "enable-background-color-toggle"
969
+ }))]
970
+ });
971
+ };
972
+
973
+ var TextBlock = function TextBlock(_ref) {
974
+ var label = _ref.label,
975
+ name = _ref.name,
976
+ _ref$type = _ref.type,
977
+ type = _ref$type === void 0 ? "text" : _ref$type,
978
+ value = _ref.value,
979
+ onChange = _ref.onChange,
980
+ placeholder = _ref.placeholder,
981
+ error = _ref.error;
982
+ return /*#__PURE__*/jsxs("div", {
983
+ className: "flex items-center justify-between",
984
+ "data-testid": "theme-style-".concat(joinHyphenCase(label)),
985
+ children: [/*#__PURE__*/jsx(Typography, {
986
+ "data-testid": "style-fields-labels",
987
+ variant: "body2",
988
+ children: label
989
+ }), /*#__PURE__*/jsx("div", {
990
+ className: "w-40",
991
+ children: /*#__PURE__*/jsx(Input, {
992
+ error: error,
993
+ name: name,
994
+ onChange: onChange,
995
+ placeholder: placeholder,
996
+ type: type,
997
+ value: value
998
+ })
999
+ })]
1000
+ });
1001
+ };
1002
+
1003
+ var Properties = function Properties(_ref) {
1004
+ var onPropertiesChange = _ref.onPropertiesChange,
1005
+ condition = _ref.condition,
1006
+ themeId = _ref.themeId;
1007
+ var _useConfigStore = useConfigStore(function (store) {
1008
+ return {
1009
+ themePropertiesSchema: store["themePropertiesSchema"]
1010
+ };
1011
+ }, shallow),
1012
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1013
+ var _useThemeStore = useThemeStore(function (store) {
1014
+ return {
1015
+ setThemeState: store["setThemeState"]
1016
+ };
1017
+ }, shallow),
1018
+ setThemeState = _useThemeStore.setThemeState;
1019
+ var _useFormikContext = useFormikContext(),
1020
+ setFieldValue = _useFormikContext.setFieldValue,
1021
+ values = _useFormikContext.values,
1022
+ errors = _useFormikContext.errors;
1023
+ var _useThemeUtils = useThemeUtils(),
1024
+ setVariable = _useThemeUtils.setVariable,
1025
+ setTheme = _useThemeUtils.setTheme;
1026
+ var handleColorChange = function handleColorChange(name) {
1027
+ return function (_ref2) {
1028
+ var hex = _ref2.hex,
1029
+ rgb = _ref2.rgb;
1030
+ if (name === "background_color") {
1031
+ var _findBy, _values$backgroundIma;
1032
+ var isDominantBackgroundColorEnabled = ((_findBy = findBy({
1033
+ key: "is_dominant_background_color_enabled"
1034
+ }, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) === "true";
1035
+ var hasImageWithDominantColor = values === null || values === void 0 || (_values$backgroundIma = values.backgroundImage) === null || _values$backgroundIma === void 0 ? void 0 : _values$backgroundIma.dominantColor;
1036
+ if (isDominantBackgroundColorEnabled && hasImageWithDominantColor) {
1037
+ return;
1038
+ }
1039
+ }
1040
+ handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
1041
+ };
1042
+ };
1043
+ var handleChange = function handleChange(name, value, variableValue) {
1044
+ var index = findIndexBy({
1045
+ key: name
1046
+ }, values.properties);
1047
+ if (index !== -1 && values.properties[index].value !== value) {
1048
+ setFieldValue("properties[".concat(index, "].value"), value);
1049
+ }
1050
+ setVariable(snakeToCamelCase(name), variableValue !== null && variableValue !== void 0 ? variableValue : value);
1051
+ };
1052
+ var handleOverlayChange = function handleOverlayChange(key, value) {
1053
+ var index = findIndexBy({
1054
+ key: key
1055
+ }, values.properties);
1056
+ var overlayColorVariable = "".concat(key, "_overlay_color");
1057
+ setFieldValue("properties[".concat(index, "].value"), value);
1058
+ setVariable("".concat(key, "_overlay_opacity"), Math.abs(value / 100));
1059
+ if (value < 0) {
1060
+ handleChange(overlayColorVariable, "#000000", "0, 0, 0");
1061
+ } else {
1062
+ handleChange(overlayColorVariable, "#ffffff", "255, 255, 255");
1063
+ }
1064
+ };
1065
+ useEffect(function () {
1066
+ if (!((values === null || values === void 0 ? void 0 : values.id) === themeId)) return;
1067
+ onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
1068
+ setTheme(values);
1069
+ setThemeState({
1070
+ previewingTheme: values
1071
+ });
1072
+ }, [values]);
1073
+ return /*#__PURE__*/jsx(Fragment, {
1074
+ children: buildProperties(values === null || values === void 0 ? void 0 : values.properties, condition, themePropertiesSchema).sort(function (a, b) {
1075
+ var order = function order(key) {
1076
+ var _findBy2;
1077
+ return ((_findBy2 = findBy({
1078
+ key: key
1079
+ }, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.order) || Infinity;
1080
+ };
1081
+ return order(a.key) - order(b.key);
1082
+ }).map(function (_ref3) {
1083
+ var _findBy3;
1084
+ var key = _ref3.key,
1085
+ value = _ref3.value,
1086
+ kind = _ref3.kind;
1087
+ var isCurrentPropertyVisible = isPropertyVisible(key, values, themePropertiesSchema);
1088
+ if (!isCurrentPropertyVisible) return null;
1089
+ switch (kind) {
1090
+ case "text_input":
1091
+ {
1092
+ var _errors$properties;
1093
+ var index = findIndexBy({
1094
+ key: key
1095
+ }, values.properties);
1096
+ var error = errors === null || errors === void 0 || (_errors$properties = errors.properties) === null || _errors$properties === void 0 || (_errors$properties = _errors$properties[index]) === null || _errors$properties === void 0 ? void 0 : _errors$properties.value;
1097
+ return /*#__PURE__*/createElement(TextBlock, {
1098
+ error: error,
1099
+ key: key,
1100
+ label: buildLabel(key, kind),
1101
+ name: "properties[".concat(index, "].value"),
1102
+ value: value || "",
1103
+ onChange: function onChange(e) {
1104
+ return setFieldValue("properties[".concat(index, "].value"), e.target.value);
1105
+ }
1106
+ });
1107
+ }
1108
+ case "font_family":
1109
+ return /*#__PURE__*/jsx(FontPickerBlock, {
1110
+ label: buildLabel(key, kind),
1111
+ options: FONT_OPTIONS,
1112
+ value: findBy({
1113
+ value: value || null
1114
+ }, FONT_OPTIONS),
1115
+ onChange: function onChange(_ref4) {
1116
+ var value = _ref4.value;
1117
+ return handleChange(key, value);
1118
+ }
1119
+ }, key);
1120
+ case "color":
1121
+ return /*#__PURE__*/jsx(ColorBlock, {
1122
+ color: value,
1123
+ label: buildLabel(key, kind),
1124
+ showTransparencyControl: ((_findBy3 = findBy({
1125
+ key: key
1126
+ }, themePropertiesSchema)) === null || _findBy3 === void 0 ? void 0 : _findBy3.showTransparencyControl) || false,
1127
+ onChange: handleColorChange(key)
1128
+ }, key);
1129
+ case "radius":
1130
+ return /*#__PURE__*/jsx(SliderBlock, {
1131
+ label: buildLabel(key, kind),
1132
+ max: 50,
1133
+ min: 0,
1134
+ value: Number(value) || 0,
1135
+ onChange: function onChange(radius) {
1136
+ return handleChange(key, radius, "".concat(radius, "px"));
1137
+ }
1138
+ }, key);
1139
+ case "overlay_opacity":
1140
+ return /*#__PURE__*/jsx(SliderBlock, {
1141
+ label: buildLabel(key, kind),
1142
+ marks: OVERLAY_OPACITY_SLIDER_MARKS,
1143
+ max: HUNDRED,
1144
+ min: negate(HUNDRED),
1145
+ value: Number(value) || 0,
1146
+ onChange: function onChange(opacity) {
1147
+ return handleOverlayChange(key, opacity);
1148
+ }
1149
+ }, key);
1150
+ case "position_selector":
1151
+ {
1152
+ var _findBy4;
1153
+ var _index = findIndexBy({
1154
+ key: key
1155
+ }, values.properties);
1156
+ var options = (_findBy4 = findBy({
1157
+ key: key
1158
+ }, themePropertiesSchema)) === null || _findBy4 === void 0 || (_findBy4 = _findBy4.options) === null || _findBy4 === void 0 ? void 0 : _findBy4.map(toCapitalizedOption);
1159
+ return /*#__PURE__*/jsx(SelectBlock, {
1160
+ label: buildLabel(key, kind),
1161
+ options: options || POSITION_OPTIONS,
1162
+ placeholder: "left",
1163
+ value: toCapitalizedOption(value),
1164
+ onChange: function onChange(option) {
1165
+ return setFieldValue("properties[".concat(_index, "].value"), option.value);
1166
+ }
1167
+ }, key);
1168
+ }
1169
+ case "boolean":
1170
+ {
1171
+ var _findBy5;
1172
+ var _index2 = findIndexBy({
1173
+ key: key
1174
+ }, values.properties);
1175
+ var renderAsCheckbox = ((_findBy5 = findBy({
1176
+ key: key
1177
+ }, themePropertiesSchema)) === null || _findBy5 === void 0 ? void 0 : _findBy5.renderAsCheckbox) || false;
1178
+ return /*#__PURE__*/jsx(SwitchBlock, {
1179
+ asCheckbox: renderAsCheckbox,
1180
+ checked: value !== "false",
1181
+ label: buildLabel(key, kind),
1182
+ name: snakeToCamelCase(key),
1183
+ onCheckedChange: function onCheckedChange(checked) {
1184
+ return setFieldValue("properties[".concat(_index2, "].value"), String(checked));
1185
+ }
1186
+ }, key);
1187
+ }
1188
+ case "alignment_block":
1189
+ {
1190
+ var _index3 = findIndexBy({
1191
+ key: key
1192
+ }, values.properties);
1193
+ return /*#__PURE__*/jsx(AlignmentBlock, {
1194
+ label: buildLabel(key, kind),
1195
+ name: "properties[".concat(_index3, "].value")
1196
+ });
1197
+ }
1198
+ default:
1199
+ return null;
1200
+ }
1201
+ })
1202
+ });
1203
+ };
1204
+
1205
+ var ImageBlock = function ImageBlock(_ref) {
1206
+ var _findBy;
1207
+ var label = _ref.label,
1208
+ name = _ref.name,
1209
+ _ref$imageData = _ref.imageData,
1210
+ imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
1211
+ _ref$uploadConfig = _ref.uploadConfig,
1212
+ uploadConfig = _ref$uploadConfig === void 0 ? {
1213
+ maxImageSize: ONE_MEGABYTE
1214
+ } : _ref$uploadConfig,
1215
+ attribute = _ref.attribute,
1216
+ defaultImageSize = _ref.defaultImageSize,
1217
+ useDefaultImageSize = _ref.useDefaultImageSize,
1218
+ fixedAspectRatio = _ref.fixedAspectRatio;
1219
+ var _useTranslation = useTranslation(),
1220
+ t = _useTranslation.t;
1221
+ var _useFormikContext = useFormikContext(),
1222
+ setFieldValue = _useFormikContext.setFieldValue,
1223
+ values = _useFormikContext.values;
1224
+ var _useConfigStore = useConfigStore(function (store) {
1225
+ return {
1226
+ themePropertiesSchema: store["themePropertiesSchema"]
1227
+ };
1228
+ }, shallow),
1229
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1230
+ var propertySchema = findBy({
1231
+ key: attribute
1232
+ }, themePropertiesSchema);
1233
+ var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
1234
+ var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
1235
+ var positionKeyInSchema = findBy({
1236
+ key: "".concat(name, "_position")
1237
+ }, themePropertiesSchema);
1238
+ var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && isPresent(positionKeyInSchema);
1239
+ var positionKeyIndex = findIndexBy({
1240
+ key: "".concat(name, "_position")
1241
+ }, values.properties);
1242
+ var handleImageChange = /*#__PURE__*/function () {
1243
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
1244
+ var dominantColor;
1245
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1246
+ while (1) switch (_context.prev = _context.next) {
1247
+ case 0:
1248
+ _context.prev = 0;
1249
+ if (!(isEmpty(image.signedId) || isEmpty(image.url))) {
1250
+ _context.next = 4;
1251
+ break;
1252
+ }
1253
+ setFieldValue(name, {
1254
+ signedId: null,
1255
+ url: image.url
1256
+ });
1257
+ return _context.abrupt("return");
1258
+ case 4:
1259
+ _context.next = 6;
1260
+ return getDominantColorFromUrl(image.url);
1261
+ case 6:
1262
+ dominantColor = _context.sent;
1263
+ setFieldValue(name, {
1264
+ signedId: image.signedId,
1265
+ url: image.url,
1266
+ dominantColor: dominantColor
1267
+ });
1268
+ _context.next = 13;
1269
+ break;
1270
+ case 10:
1271
+ _context.prev = 10;
1272
+ _context.t0 = _context["catch"](0);
1273
+ Toastr.error(_context.t0);
1274
+ case 13:
1275
+ case "end":
1276
+ return _context.stop();
1277
+ }
1278
+ }, _callee, null, [[0, 10]]);
1279
+ }));
1280
+ return function handleImageChange(_x) {
1281
+ return _ref2.apply(this, arguments);
1282
+ };
1283
+ }();
1284
+ return /*#__PURE__*/jsxs("div", {
1285
+ className: "space-y-3",
1286
+ "data-testid": "theme-style-".concat(label ? joinHyphenCase(label) : "image-block"),
1287
+ children: [label && /*#__PURE__*/jsx("div", {
1288
+ className: "flex items-center justify-between",
1289
+ children: /*#__PURE__*/jsx(Typography, {
1290
+ "data-testid": "style-fields-labels",
1291
+ variant: "body2",
1292
+ children: label
1293
+ })
1294
+ }), /*#__PURE__*/jsxs("div", {
1295
+ className: "space-y-3",
1296
+ children: [/*#__PURE__*/createElement(ImageUploader, {
1297
+ fixedAspectRatio: fixedAspectRatio,
1298
+ uploadConfig: uploadConfig,
1299
+ className: "h-40 w-full",
1300
+ defaultImageSize: useDefaultImageSize ? defaultImageSize : {},
1301
+ key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
1302
+ src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
1303
+ onUploadComplete: handleImageChange
1304
+ }), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
1305
+ label: buildLabel("".concat(name, "Position"), "image"),
1306
+ options: (options === null || options === void 0 ? void 0 : options.map(toCapitalizedOption)) || POSITION_OPTIONS,
1307
+ placeholder: t("neetoThemes.common.left"),
1308
+ value: toCapitalizedOption(((_findBy = findBy({
1309
+ key: "".concat(name, "_position")
1310
+ }, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
1311
+ onChange: function onChange(option) {
1312
+ return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
1313
+ }
1314
+ })]
1315
+ })]
1316
+ });
1317
+ };
1318
+
1319
+ var Images = function Images(_ref) {
1320
+ var _values$coverImage;
1321
+ var attribute = _ref.attribute,
1322
+ className = _ref.className,
1323
+ onPropertiesChange = _ref.onPropertiesChange,
1324
+ defaultImageSize = _ref.defaultImageSize,
1325
+ useDefaultImageSize = _ref.useDefaultImageSize,
1326
+ fixedAspectRatio = _ref.fixedAspectRatio;
1327
+ var _useFormikContext = useFormikContext(),
1328
+ values = _useFormikContext.values;
1329
+ var _useConfigStore = useConfigStore(function (store) {
1330
+ return {
1331
+ helpPopoverProps: store["helpPopoverProps"]
1332
+ };
1333
+ }, shallow),
1334
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
1335
+ var key = snakeToCamelCase(attribute);
1336
+ var title = buildLabel(key, "image");
1337
+ var imageData = values[key];
1338
+ return /*#__PURE__*/jsxs(Card$2, {
1339
+ className: className,
1340
+ title: title,
1341
+ helpPopoverProps: helpPopoverProps[key],
1342
+ name: key,
1343
+ children: [/*#__PURE__*/jsx(ImageBlock, {
1344
+ attribute: attribute,
1345
+ defaultImageSize: defaultImageSize,
1346
+ fixedAspectRatio: fixedAspectRatio,
1347
+ imageData: imageData,
1348
+ useDefaultImageSize: useDefaultImageSize,
1349
+ name: key
1350
+ }), /*#__PURE__*/jsx(Properties, {
1351
+ onPropertiesChange: onPropertiesChange,
1352
+ condition: attribute
1353
+ }), key === "logo" && ((_values$coverImage = values.coverImage) === null || _values$coverImage === void 0 ? void 0 : _values$coverImage.url) && /*#__PURE__*/jsx(LogoPosition, {})]
1354
+ });
1355
+ };
1356
+
1357
+ var ThemeMeta = function ThemeMeta(_ref) {
1358
+ var className = _ref.className;
1359
+ var _useTranslation = useTranslation(),
1360
+ t = _useTranslation.t;
1361
+ var _useConfigStore = useConfigStore(function (store) {
1362
+ return {
1363
+ helpPopoverProps: store["helpPopoverProps"]
1364
+ };
1365
+ }, shallow),
1366
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
1367
+ var _helpPopoverProps$nam = helpPopoverProps.name,
1368
+ nameHelpPopoverProps = _helpPopoverProps$nam === void 0 ? {} : _helpPopoverProps$nam;
1369
+ return /*#__PURE__*/jsx(Card$2, {
1370
+ className: className,
1371
+ required: true,
1372
+ helpPopoverProps: nameHelpPopoverProps,
1373
+ name: "name",
1374
+ title: t("neetoThemes.common.name"),
1375
+ children: /*#__PURE__*/jsx(Input$1, {
1376
+ autoFocus: true,
1377
+ "data-testid": "theme-name-property",
1378
+ name: "name"
1379
+ })
1380
+ });
1381
+ };
1382
+
1383
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1384
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1385
+ var Customize = function Customize(_ref) {
1386
+ var theme = _ref.theme,
1387
+ onCreateTheme = _ref.onCreateTheme,
1388
+ onApplyTheme = _ref.onApplyTheme,
1389
+ onUpdateTheme = _ref.onUpdateTheme,
1390
+ isApplyingTheme = _ref.isApplyingTheme,
1391
+ onPropertiesChange = _ref.onPropertiesChange,
1392
+ defaultImageSize = _ref.defaultImageSize,
1393
+ fixedAspectRatio = _ref.fixedAspectRatio,
1394
+ onEditCSSClick = _ref.onEditCSSClick,
1395
+ currentScreen = _ref.currentScreen;
1396
+ var _useTranslation = useTranslation(),
1397
+ t = _useTranslation.t;
1398
+ useSyncExpandedSectionFromUrl();
1399
+ var history = useHistory();
1400
+ var _useState = useState(false),
1401
+ _useState2 = _slicedToArray(_useState, 2),
1402
+ isNotAppliedPopoverOpen = _useState2[0],
1403
+ setIsNotAppliedPopoverOpen = _useState2[1];
1404
+ var _useConfigStore = useConfigStore(function (store) {
1405
+ return {
1406
+ themePropertiesSchema: store["themePropertiesSchema"],
1407
+ entityType: store["entityType"],
1408
+ isFetchingSchema: store["isFetchingSchema"],
1409
+ helpPopoverProps: store["helpPopoverProps"],
1410
+ enabledFeatures: store["enabledFeatures"],
1411
+ proFeatures: store["proFeatures"]
1412
+ };
1413
+ }, shallow),
1414
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1415
+ entityType = _useConfigStore.entityType,
1416
+ isFetchingSchema = _useConfigStore.isFetchingSchema,
1417
+ helpPopoverProps = _useConfigStore.helpPopoverProps,
1418
+ enabledFeatures = _useConfigStore.enabledFeatures,
1419
+ proFeatures = _useConfigStore.proFeatures;
1420
+ var _useParams = useParams(),
1421
+ themeId = _useParams.themeId;
1422
+ var _useThemeStore = useThemeStore(function (store) {
1423
+ return {
1424
+ currentTheme: store["currentTheme"],
1425
+ setThemeState: store["setThemeState"]
1426
+ };
1427
+ }, shallow),
1428
+ currentTheme = _useThemeStore.currentTheme,
1429
+ setThemeState = _useThemeStore.setThemeState;
1430
+ var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1431
+ _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1432
+ _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1433
+ _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1434
+ globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1435
+ var _useFetchTheme = useFetchTheme(themeId, {
1436
+ enabled: isEditThemeRoute() && isNotNil(themeId),
1437
+ initialData: theme !== null && theme !== void 0 ? theme : undefined
1438
+ }),
1439
+ _useFetchTheme$data = _useFetchTheme.data,
1440
+ themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
1441
+ isLoadingTheme = _useFetchTheme.isLoadingTheme;
1442
+ var isLoading = isFetchingSchema || isLoadingTheme;
1443
+ var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1444
+ var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1445
+ var _helpPopoverProps$sty = helpPopoverProps.style,
1446
+ styleHelpPopoverProps = _helpPopoverProps$sty === void 0 ? {} : _helpPopoverProps$sty;
1447
+ var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1448
+ var _useCreateTheme = useCreateTheme(),
1449
+ createTheme = _useCreateTheme.mutate,
1450
+ isCreating = _useCreateTheme.isPending;
1451
+ var _useUpdateTheme = useUpdateTheme(themeId),
1452
+ updateTheme = _useUpdateTheme.mutate,
1453
+ isUpdating = _useUpdateTheme.isPending;
1454
+ var isSubmitting = isCreating || isUpdating;
1455
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
1456
+ var onSubmit = function onSubmit(values, _ref2) {
1457
+ var resetForm = _ref2.resetForm;
1458
+ var imageData = buildImageData(values, themePropertiesSchema);
1459
+ var themeToSave = _objectSpread({
1460
+ propertiesAttributes: values.properties,
1461
+ name: values.name,
1462
+ shouldSetAsGlobalTheme: values.shouldSetAsGlobalTheme,
1463
+ entityType: values.entityType
1464
+ }, imageData);
1465
+ if (!themeId) {
1466
+ return createTheme(themeToSave, {
1467
+ onSuccess: function onSuccess(_ref3) {
1468
+ var theme = _ref3.theme;
1469
+ resetForm({
1470
+ values: theme
1471
+ });
1472
+ onCreateTheme(theme);
1473
+ history.replace(buildUrl(buildPathname(routes.themes.edit), {
1474
+ themeId: theme.id
1475
+ }));
1476
+ }
1477
+ });
1478
+ }
1479
+ return updateTheme(themeToSave, {
1480
+ onSuccess: function onSuccess(_ref4) {
1481
+ var theme = _ref4.theme;
1482
+ onUpdateTheme(theme);
1483
+ resetForm({
1484
+ values: theme
1485
+ });
1486
+ }
1487
+ });
1488
+ };
1489
+ useEffect(function () {
1490
+ if (isNotNil(themeId) && !isLoadingTheme) {
1491
+ setThemeState({
1492
+ previewingTheme: themeData
1493
+ });
1494
+ }
1495
+ }, [isLoadingTheme]);
1496
+ if (isLoading) {
1497
+ return /*#__PURE__*/jsx("div", {
1498
+ className: "flex h-full w-full items-center justify-center",
1499
+ children: /*#__PURE__*/jsx(Spinner, {})
1500
+ });
1501
+ }
1502
+ return /*#__PURE__*/jsx(Form, {
1503
+ formikProps: {
1504
+ initialValues: _objectSpread(_objectSpread({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
1505
+ shouldSetAsGlobalTheme: isThemeGlobalTheme,
1506
+ entityType: entityType
1507
+ }),
1508
+ validationSchema: THEME_VALIDATION_SCHEMA,
1509
+ enableReinitialize: true,
1510
+ onSubmit: onSubmit
1511
+ },
1512
+ children: function children(_ref5) {
1513
+ var dirty = _ref5.dirty,
1514
+ isValid = _ref5.isValid,
1515
+ values = _ref5.values,
1516
+ setFieldValue = _ref5.setFieldValue;
1517
+ var isNotAppliedCondition = !isEditingCurrentlyAppliedTheme && !(isCurrentThemeAndGlobalThemeSame && values.shouldSetAsGlobalTheme);
1518
+ return /*#__PURE__*/jsxs("div", {
1519
+ className: "neeto-themes-sidebar__scroll",
1520
+ children: [/*#__PURE__*/jsxs("div", {
1521
+ className: "neeto-themes-sidebar__scroll-content flex grow flex-col px-4 pb-4 lg:px-5",
1522
+ children: [!isSubmitting && /*#__PURE__*/jsx(BlockNavigation, {}), /*#__PURE__*/jsx(ThemeMeta, {
1523
+ className: classnames({
1524
+ hidden: isCustomCssScreen
1525
+ })
1526
+ }), /*#__PURE__*/jsx(Card$2, {
1527
+ className: classnames({
1528
+ hidden: isCustomCssScreen
1529
+ }),
1530
+ helpPopoverProps: styleHelpPopoverProps,
1531
+ name: "style",
1532
+ title: t("neetoThemes.common.style"),
1533
+ children: /*#__PURE__*/jsx(Properties, {
1534
+ onPropertiesChange: onPropertiesChange,
1535
+ themeId: themeId
1536
+ })
1537
+ }), filterBy({
1538
+ kind: "image"
1539
+ }, themePropertiesSchema).map(function (_ref6) {
1540
+ var key = _ref6.key,
1541
+ useDefaultImageSize = _ref6.useDefaultImageSize,
1542
+ propertyDefaultSize = _ref6.defaultImageSize,
1543
+ propertyFixedAspectRatio = _ref6.fixedAspectRatio;
1544
+ return /*#__PURE__*/createElement(Images, _defineProperty({
1545
+ fixedAspectRatio: fixedAspectRatio,
1546
+ onPropertiesChange: onPropertiesChange,
1547
+ useDefaultImageSize: useDefaultImageSize,
1548
+ attribute: key,
1549
+ className: classnames({
1550
+ hidden: isCustomCssScreen
1551
+ }),
1552
+ defaultImageSize: propertyDefaultSize || defaultImageSize,
1553
+ key: key
1554
+ }, "fixedAspectRatio", propertyFixedAspectRatio || fixedAspectRatio));
1555
+ }), /*#__PURE__*/jsx(CustomCSS, {
1556
+ currentScreen: currentScreen,
1557
+ onEditCSSClick: onEditCSSClick,
1558
+ isEnabled: enabledFeatures.customCSS,
1559
+ isProFeature: proFeatures.customCSS
1560
+ }), /*#__PURE__*/jsxs("div", {
1561
+ className: "bg-muted/50 border-border mt-2 flex flex-col space-y-2 border p-2",
1562
+ children: [/*#__PURE__*/jsx(Tooltip, {
1563
+ disabled: !isThemeGlobalTheme,
1564
+ content: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.tooltipContent"),
1565
+ children: /*#__PURE__*/jsx(Switch, {
1566
+ checked: values.shouldSetAsGlobalTheme,
1567
+ disabled: isThemeGlobalTheme,
1568
+ name: "shouldSetAsGlobalTheme",
1569
+ label: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.label"),
1570
+ onCheckedChange: function onCheckedChange(checked) {
1571
+ return setFieldValue("shouldSetAsGlobalTheme", checked);
1572
+ }
1573
+ })
1574
+ }), /*#__PURE__*/jsx(Typography, {
1575
+ className: "text-sm",
1576
+ variant: "body2",
1577
+ children: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.helpText", {
1578
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()), {
1579
+ count: 2
1580
+ })
1581
+ })
1582
+ })]
1583
+ })]
1584
+ }), /*#__PURE__*/jsxs("div", {
1585
+ className: "bg-background shadow-sm sticky bottom-0 start-0 end-0 flex justify-end gap-x-2 px-4 py-6 lg:px-5 xl:px-6",
1586
+ children: [/*#__PURE__*/jsx(Button, {
1587
+ "data-testid": "reset-button",
1588
+ disabled: !dirty || isSubmitting,
1589
+ label: t("neetoThemes.buttons.reset"),
1590
+ type: "reset",
1591
+ variant: "ghost"
1592
+ }), /*#__PURE__*/jsx(Popover, {
1593
+ open: isNotAppliedPopoverOpen,
1594
+ position: "top",
1595
+ trigger: /*#__PURE__*/jsx(Button, {
1596
+ "data-testid": "save-changes-button",
1597
+ label: t("neetoThemes.buttons.save"),
1598
+ loading: isSubmitting,
1599
+ type: "submit",
1600
+ disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting || !isValid,
1601
+ onClick: function onClick() {
1602
+ if (isNotAppliedCondition) {
1603
+ setIsNotAppliedPopoverOpen(true);
1604
+ }
1605
+ }
1606
+ }),
1607
+ onOpenChange: setIsNotAppliedPopoverOpen,
1608
+ children: /*#__PURE__*/jsxs("div", {
1609
+ className: "flex flex-col items-start gap-2",
1610
+ children: [/*#__PURE__*/jsx(Button, {
1611
+ className: "absolute end-1 top-1 z-0",
1612
+ icon: Close,
1613
+ size: "sm",
1614
+ variant: "ghost",
1615
+ onClick: function onClick() {
1616
+ return setIsNotAppliedPopoverOpen(false);
1617
+ }
1618
+ }), /*#__PURE__*/jsx(Typography, {
1619
+ className: "w-72 pe-5",
1620
+ variant: "body2",
1621
+ weight: "normal",
1622
+ children: /*#__PURE__*/jsx(Trans, {
1623
+ components: {
1624
+ bold: /*#__PURE__*/jsx("strong", {})
1625
+ },
1626
+ i18nKey: "neetoThemes.build.leftSideBar.themes.notAppliedYet",
1627
+ values: {
1628
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
1629
+ }
1630
+ })
1631
+ }), /*#__PURE__*/jsx(Button, {
1632
+ disabled: isApplyingTheme,
1633
+ label: t("neetoThemes.buttons.applyThisTheme"),
1634
+ loading: isApplyingTheme,
1635
+ onClick: function onClick() {
1636
+ return onApplyTheme(themeData);
1637
+ }
1638
+ })]
1639
+ })
1640
+ })]
1641
+ })]
1642
+ });
1643
+ }
1644
+ });
1645
+ };
1646
+
1647
+ var QuickActionRow = function QuickActionRow(_ref) {
1648
+ var Icon = _ref.icon,
1649
+ label = _ref.label,
1650
+ onClick = _ref.onClick,
1651
+ testId = _ref.testId;
1652
+ return /*#__PURE__*/jsxs("button", {
1653
+ onClick: onClick,
1654
+ className: "border-border hover:bg-muted flex w-full cursor-pointer items-center gap-3 border-t px-3 py-2 text-start transition-colors",
1655
+ "data-testid": testId,
1656
+ type: "button",
1657
+ children: [/*#__PURE__*/jsx(Icon, {
1658
+ size: 16
1659
+ }), /*#__PURE__*/jsx(Typography, {
1660
+ variant: "body2",
1661
+ children: label
1662
+ })]
1663
+ });
1664
+ };
1665
+
1666
+ var Thumbnail = function Thumbnail(_ref) {
1667
+ var _theme$snakeToCamelCa, _findBy, _findBy2;
1668
+ var active = _ref.active,
1669
+ isPreviewing = _ref.isPreviewing,
1670
+ isHighLightedTheme = _ref.isHighLightedTheme,
1671
+ theme = _ref.theme;
1672
+ var _useConfigStore = useConfigStore(function (store) {
1673
+ return {
1674
+ themePropertiesSchema: store["themePropertiesSchema"]
1675
+ };
1676
+ }, shallow),
1677
+ _useConfigStore$theme = _useConfigStore.themePropertiesSchema,
1678
+ themePropertiesSchema = _useConfigStore$theme === void 0 ? [] : _useConfigStore$theme;
1679
+ var _themePropertiesSchem = _slicedToArray(themePropertiesSchema, 2),
1680
+ colorObject1 = _themePropertiesSchem[0],
1681
+ colorObject2 = _themePropertiesSchem[1];
1682
+ var primaryLabel = humanize(colorObject1 === null || colorObject1 === void 0 ? void 0 : colorObject1.key);
1683
+ var secondaryLabel = humanize(colorObject2 === null || colorObject2 === void 0 ? void 0 : colorObject2.key);
1684
+ var primaryColor = findBy({
1685
+ key: colorObject1.key
1686
+ }, theme.properties).value;
1687
+ var secondaryColor = findBy({
1688
+ key: colorObject2.key
1689
+ }, theme.properties).value;
1690
+ var backgroundImageUrl = (_theme$snakeToCamelCa = theme[snakeToCamelCase(findBy({
1691
+ useAsCardBackground: true
1692
+ }, themePropertiesSchema).key)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url;
1693
+ var buttonBackgroundColor = (_findBy = findBy({
1694
+ key: (_findBy2 = findBy({
1695
+ useAsCardButtonBackground: true
1696
+ }, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.key
1697
+ }, theme.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value;
1698
+ return /*#__PURE__*/jsx("div", {
1699
+ className: classnames("neeto-themes-theme-thumbnail rounded-lg border transition-all duration-300 ease-in-out", {
1700
+ "border-gray-400": !active,
1701
+ "border-gray-800 neeto-themes-theme-thumbnail--active": active,
1702
+ "neeto-themes-theme-thumbnail--preview-active": isPreviewing,
1703
+ "neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
1704
+ }),
1705
+ style: {
1706
+ backgroundImage: backgroundImageUrl ? "url(".concat(backgroundImageUrl, ")") : "initial",
1707
+ backgroundSize: "cover"
1708
+ },
1709
+ children: /*#__PURE__*/jsx("div", {
1710
+ className: "rounded-lg cursor-pointer p-3 transition-all duration-300 ease-in-out group-hover:opacity-85",
1711
+ children: /*#__PURE__*/jsxs("div", {
1712
+ className: "rounded-lg p-3",
1713
+ children: [/*#__PURE__*/jsxs("div", {
1714
+ className: "mb-3",
1715
+ children: [/*#__PURE__*/jsx(Typography, {
1716
+ variant: "h3",
1717
+ weight: "semibold",
1718
+ children: /*#__PURE__*/jsx("span", {
1719
+ style: {
1720
+ color: primaryColor
1721
+ },
1722
+ children: primaryLabel
1723
+ })
1724
+ }), /*#__PURE__*/jsx(Typography, {
1725
+ className: "text-muted-foreground",
1726
+ variant: "body2",
1727
+ children: /*#__PURE__*/jsx("span", {
1728
+ style: {
1729
+ color: secondaryColor
1730
+ },
1731
+ children: secondaryLabel
1732
+ })
1733
+ })]
1734
+ }), /*#__PURE__*/jsx("div", {
1735
+ className: "rounded-lg h-5 w-12",
1736
+ style: {
1737
+ backgroundColor: buttonBackgroundColor
1738
+ }
1739
+ })]
1740
+ })
1741
+ })
1742
+ });
1743
+ };
1744
+
1745
+ var Card$1 = function Card(_ref) {
1746
+ var _ref$active = _ref.active,
1747
+ active = _ref$active === void 0 ? false : _ref$active,
1748
+ isPreviewing = _ref.isPreviewing,
1749
+ onSetPreviewTheme = _ref.onSetPreviewTheme,
1750
+ onDeleteTheme = _ref.onDeleteTheme,
1751
+ onEditTheme = _ref.onEditTheme,
1752
+ theme = _ref.theme,
1753
+ isApplyingTheme = _ref.isApplyingTheme,
1754
+ onCloneTheme = _ref.onCloneTheme,
1755
+ isHighLightedTheme = _ref.isHighLightedTheme,
1756
+ isGlobalTheme = _ref.isGlobalTheme,
1757
+ onApplyTheme = _ref.onApplyTheme,
1758
+ Thumbnail$1 = _ref.thumbnail;
1759
+ var _useTranslation = useTranslation(),
1760
+ t = _useTranslation.t;
1761
+ var _useConfigStore = useConfigStore(function (store) {
1762
+ return {
1763
+ themePropertiesSchema: store["themePropertiesSchema"]
1764
+ };
1765
+ }, shallow),
1766
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1767
+ var id = theme.id,
1768
+ name = theme.name;
1769
+ var imageProperties = filterBy({
1770
+ kind: "image"
1771
+ }, themePropertiesSchema);
1772
+ var handleDeleteTheme = function handleDeleteTheme() {
1773
+ return onDeleteTheme(id, name);
1774
+ };
1775
+ var handleQuickEdit = function handleQuickEdit(section) {
1776
+ return function (e) {
1777
+ e.stopPropagation();
1778
+ if (isPresent(onEditTheme)) onEditTheme(theme, section);else onCloneTheme(theme, section);
1779
+ };
1780
+ };
1781
+ var showMoreDropdown = isFunction(onDeleteTheme);
1782
+ return /*#__PURE__*/jsx("div", {
1783
+ className: "group space-y-2 pt-0.5",
1784
+ "data-flip-id": theme.id,
1785
+ "data-testid": active ? "active-theme-card" : "theme-card",
1786
+ id: theme.id,
1787
+ children: /*#__PURE__*/jsxs("div", {
1788
+ className: classnames("neeto-themes-theme-thumbnail rounded-lg relative cursor-pointer border-2 transition-all duration-300 ease-in-out", {
1789
+ "border-gray-400": !active,
1790
+ "neeto-themes-theme-thumbnail--active": active,
1791
+ "neeto-themes-theme-thumbnail--preview-active": isPreviewing,
1792
+ "neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
1793
+ }),
1794
+ onClick: function onClick() {
1795
+ return onSetPreviewTheme(theme);
1796
+ },
1797
+ children: [/*#__PURE__*/jsxs("div", {
1798
+ className: "rounded-lg relative overflow-hidden rounded-bl-none rounded-br-none transition-all duration-300 ease-in-out",
1799
+ children: [active ? /*#__PURE__*/jsx("div", {
1800
+ className: "neeto-themes-theme-thumbnail__active-banner absolute start-0 top-0 z-10 w-full py-1 text-center text-xs font-semibold uppercase tracking-wide",
1801
+ "data-testid": "active-theme-label",
1802
+ children: t("neetoThemes.common.activeTheme")
1803
+ }) : /*#__PURE__*/jsx("div", {
1804
+ className: "absolute start-0 top-0 z-10 flex h-full w-full items-center justify-center px-3 pb-3 pt-3",
1805
+ children: /*#__PURE__*/jsxs("div", {
1806
+ className: classnames("-translate-y-9 flex w-full items-center justify-between gap-2", {
1807
+ hidden: !isPreviewing,
1808
+ "group-hover:flex": true
1809
+ }),
1810
+ children: [/*#__PURE__*/jsx(Button, {
1811
+ "data-testid": "preview-theme-button",
1812
+ disabled: isPreviewing,
1813
+ label: t("neetoThemes.common.previewTheme"),
1814
+ variant: "secondary",
1815
+ className: classnames({
1816
+ "neeto-themes-theme-thumbnail__preview-btn--disabled opacity-100": isPreviewing,
1817
+ "neeto-themes-theme-thumbnail__preview-btn shrink-0 justify-center": true
1818
+ }),
1819
+ onClick: function onClick() {
1820
+ return onSetPreviewTheme(theme);
1821
+ }
1822
+ }), /*#__PURE__*/jsx(Button, {
1823
+ className: "neeto-themes-theme-thumbnail__apply-btn shrink-0 justify-center",
1824
+ "data-testid": "apply-theme-button",
1825
+ disabled: isApplyingTheme,
1826
+ label: t("neetoThemes.common.useTheme"),
1827
+ loading: isApplyingTheme,
1828
+ variant: "default",
1829
+ onClick: function onClick() {
1830
+ return onApplyTheme(theme);
1831
+ }
1832
+ })]
1833
+ })
1834
+ }), /*#__PURE__*/jsx("div", {
1835
+ className: "neeto-themes-theme-thumbnail__overlay w-full transition-all duration-300 ease-in-out",
1836
+ children: Thumbnail$1 ? /*#__PURE__*/jsx(Thumbnail$1, {
1837
+ active: active,
1838
+ isHighLightedTheme: isHighLightedTheme,
1839
+ isPreviewing: isPreviewing,
1840
+ theme: theme
1841
+ }) : /*#__PURE__*/jsx(Thumbnail, {
1842
+ active: active,
1843
+ isHighLightedTheme: isHighLightedTheme,
1844
+ isPreviewing: isPreviewing,
1845
+ theme: theme
1846
+ })
1847
+ })]
1848
+ }), /*#__PURE__*/jsxs("div", {
1849
+ className: "border-border flex items-start justify-between gap-1 border-t p-2",
1850
+ children: [/*#__PURE__*/jsxs("div", {
1851
+ className: "flex items-center space-x-2",
1852
+ children: [/*#__PURE__*/jsx(Typography, {
1853
+ className: "text-muted-foreground line-clamp-2 min-w-0 grow wrap-anywhere pt-1 italic",
1854
+ "data-testid": "theme-name",
1855
+ variant: "body2",
1856
+ children: name
1857
+ }), isGlobalTheme && /*#__PURE__*/jsx(Typography, {
1858
+ className: "text-muted-foreground shrink-0 pt-1 italic",
1859
+ "data-testid": "default-theme-label",
1860
+ variant: "body2",
1861
+ children: t("neetoThemes.common.defaultTheme")
1862
+ })]
1863
+ }), showMoreDropdown && /*#__PURE__*/jsx(MoreDropdown, {
1864
+ dropdownButtonProps: {
1865
+ size: "sm"
1866
+ },
1867
+ dropdownProps: {
1868
+ strategy: "fixed",
1869
+ onClick: function onClick(e) {
1870
+ return e.stopPropagation();
1871
+ }
1872
+ },
1873
+ menuItems: [{
1874
+ key: "delete",
1875
+ "data-testid": "delete-theme-menu-item",
1876
+ label: t("neetoThemes.build.leftSideBar.themes.themeOptions.delete"),
1877
+ isDisabled: isApplyingTheme,
1878
+ onClick: function onClick(e) {
1879
+ e.stopPropagation();
1880
+ handleDeleteTheme();
1881
+ }
1882
+ }]
1883
+ })]
1884
+ }), active && /*#__PURE__*/jsxs("div", {
1885
+ className: "flex flex-col",
1886
+ children: [/*#__PURE__*/jsx(QuickActionRow, {
1887
+ icon: ColorPicker$1,
1888
+ label: t("neetoThemes.common.customizeStyle"),
1889
+ testId: "quick-customize-style",
1890
+ onClick: handleQuickEdit("style")
1891
+ }), imageProperties.map(function (_ref2) {
1892
+ var _theme$camelKey;
1893
+ var key = _ref2.key;
1894
+ var camelKey = snakeToCamelCase(key);
1895
+ var hasImage = isPresent((_theme$camelKey = theme[camelKey]) === null || _theme$camelKey === void 0 ? void 0 : _theme$camelKey.url);
1896
+ var action = hasImage ? "change" : "add";
1897
+ var specificKey = "neetoThemes.common.".concat(action).concat(capitalize(camelKey));
1898
+ return /*#__PURE__*/jsx(QuickActionRow, {
1899
+ icon: AddImage,
1900
+ label: t([specificKey, "neetoThemes.common.addImage"]),
1901
+ testId: "quick-add-".concat(hyphenate(key)),
1902
+ onClick: handleQuickEdit(camelKey)
1903
+ }, key);
1904
+ }), /*#__PURE__*/jsx(QuickActionRow, {
1905
+ icon: CodeBlock,
1906
+ label: t("neetoThemes.build.leftSideBar.themes.customCSS"),
1907
+ testId: "quick-custom-css",
1908
+ onClick: handleQuickEdit("customcss")
1909
+ })]
1910
+ })]
1911
+ })
1912
+ });
1913
+ };
1914
+ var Card = /*#__PURE__*/memo(Card$1);
1915
+
1916
+ var Themes = function Themes(_ref) {
1917
+ var onEditTheme = _ref.onEditTheme,
1918
+ _ref$themes = _ref.themes,
1919
+ themes = _ref$themes === void 0 ? [] : _ref$themes,
1920
+ _ref$defaultThemes = _ref.defaultThemes,
1921
+ defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
1922
+ onDeleteTheme = _ref.onDeleteTheme,
1923
+ themeToHighlight = _ref.themeToHighlight,
1924
+ didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
1925
+ isLoading = _ref.isLoading,
1926
+ currentTheme = _ref.currentTheme,
1927
+ isCurrentThemeLoading = _ref.isCurrentThemeLoading,
1928
+ thumbnail = _ref.thumbnail,
1929
+ themeBeingApplied = _ref.themeBeingApplied,
1930
+ onApplyTheme = _ref.onApplyTheme,
1931
+ onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1932
+ _ref$isSearchVisible = _ref.isSearchVisible,
1933
+ isSearchVisible = _ref$isSearchVisible === void 0 ? false : _ref$isSearchVisible;
1934
+ var _useTranslation = useTranslation(),
1935
+ t = _useTranslation.t;
1936
+ var _useThemeUtils = useThemeUtils(),
1937
+ setTheme = _useThemeUtils.setTheme;
1938
+ var _useThemeStore = useThemeStore(function (store) {
1939
+ return {
1940
+ setThemeState: store["setThemeState"],
1941
+ previewingTheme: store["previewingTheme"]
1942
+ };
1943
+ }, shallow),
1944
+ setThemeState = _useThemeStore.setThemeState,
1945
+ previewingTheme = _useThemeStore.previewingTheme;
1946
+ var _useConfigStore = useConfigStore(function (store) {
1947
+ return {
1948
+ entityType: store["entityType"],
1949
+ entityId: store["entityId"]
1950
+ };
1951
+ }, shallow),
1952
+ entityType = _useConfigStore.entityType,
1953
+ entityId = _useConfigStore.entityId;
1954
+ var _useQueryParams = useQueryParams(),
1955
+ _useQueryParams$searc = _useQueryParams.searchTerm,
1956
+ searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
1957
+ var _useCloneTheme = useCloneTheme(),
1958
+ cloneTheme = _useCloneTheme.mutate;
1959
+ var _useApplyTheme = useApplyTheme({}),
1960
+ applyClonedTheme = _useApplyTheme.mutate;
1961
+ var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1962
+ _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1963
+ _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1964
+ _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1965
+ globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3,
1966
+ isLoadingGlobalTheme = _useShowGlobalTheme.isLoading;
1967
+ useEffect(function () {
1968
+ if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
1969
+ didScrollActiveThemeIntoView.current = true;
1970
+ setTimeout(function () {
1971
+ scrollElementIntoView(currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1972
+ }, 100);
1973
+ }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
1974
+ var setPreviewTheme = function setPreviewTheme(theme) {
1975
+ setThemeState({
1976
+ previewingTheme: theme
1977
+ });
1978
+ setTheme(theme);
1979
+ };
1980
+ var activeThemeId = currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id;
1981
+ var lowerSearchTerm = searchTerm.toLowerCase();
1982
+ var matchesSearch = function matchesSearch(theme) {
1983
+ return theme.name.toLowerCase().includes(lowerSearchTerm);
1984
+ };
1985
+ var activeTheme = activeThemeId ? [].concat(_toConsumableArray(defaultThemes), _toConsumableArray(themes)).find(function (theme) {
1986
+ return theme.id === activeThemeId;
1987
+ }) : null;
1988
+ var isActiveThemeCustom = themes.some(function (theme) {
1989
+ return theme.id === activeThemeId;
1990
+ });
1991
+ var filteredDefaultThemes = defaultThemes.filter(function (theme) {
1992
+ return theme.id !== activeThemeId && matchesSearch(theme);
1993
+ });
1994
+ var filteredThemes = themes.filter(function (theme) {
1995
+ return theme.id !== activeThemeId && matchesSearch(theme);
1996
+ });
1997
+ var showActiveThemeSection = activeTheme && matchesSearch(activeTheme);
1998
+ var handleCloneTheme = function handleCloneTheme(data, section) {
1999
+ cloneTheme(data.id, {
2000
+ onSuccess: function onSuccess(_ref2) {
2001
+ var clonedTheme = _ref2.theme;
2002
+ applyClonedTheme({
2003
+ themeId: clonedTheme.id,
2004
+ entityId: entityId,
2005
+ entityType: entityType
2006
+ }, {
2007
+ onSuccess: function onSuccess() {
2008
+ onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(clonedTheme);
2009
+ onEditTheme(clonedTheme, section);
2010
+ }
2011
+ });
2012
+ }
2013
+ });
2014
+ };
2015
+ if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
2016
+ return /*#__PURE__*/jsx("div", {
2017
+ className: "flex h-full w-full items-center justify-center",
2018
+ children: /*#__PURE__*/jsx(Spinner, {})
2019
+ });
2020
+ }
2021
+ var activeThemeSection = showActiveThemeSection && /*#__PURE__*/jsx("div", {
2022
+ className: "border-border mb-6 border-b px-6 pb-6 lg:px-5 xl:px-6",
2023
+ children: /*#__PURE__*/jsx(Card, {
2024
+ onApplyTheme: onApplyTheme,
2025
+ thumbnail: thumbnail,
2026
+ active: true,
2027
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === activeTheme.id,
2028
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === activeTheme.id,
2029
+ isHighLightedTheme: activeTheme.id === themeToHighlight,
2030
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === activeTheme.id,
2031
+ theme: activeTheme,
2032
+ onCloneTheme: handleCloneTheme,
2033
+ onEditTheme: isActiveThemeCustom ? onEditTheme : undefined,
2034
+ onSetPreviewTheme: setPreviewTheme
2035
+ })
2036
+ });
2037
+ var systemThemesSection = isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsx("div", {
2038
+ className: "mb-6 space-y-3",
2039
+ children: /*#__PURE__*/jsx("div", {
2040
+ className: "flex flex-col gap-4 px-6 pb-10 lg:px-5 xl:px-6",
2041
+ "data-testid": "system-themes",
2042
+ children: filteredDefaultThemes.map(function (theme) {
2043
+ return /*#__PURE__*/createElement(Card, {
2044
+ onApplyTheme: onApplyTheme,
2045
+ theme: theme,
2046
+ thumbnail: thumbnail,
2047
+ active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
2048
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
2049
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2050
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
2051
+ key: theme.id,
2052
+ onCloneTheme: handleCloneTheme,
2053
+ onSetPreviewTheme: setPreviewTheme
2054
+ });
2055
+ })
2056
+ })
2057
+ });
2058
+ var customThemesSection = isNotEmpty(filteredThemes) && /*#__PURE__*/jsx("div", {
2059
+ className: "mb-6 space-y-3",
2060
+ children: /*#__PURE__*/jsx("div", {
2061
+ className: "flex flex-col gap-4 px-6",
2062
+ "data-testid": "custom-themes",
2063
+ children: filteredThemes.map(function (theme) {
2064
+ var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
2065
+ var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
2066
+ return /*#__PURE__*/createElement(Card, {
2067
+ isPreviewing: isPreviewing,
2068
+ onApplyTheme: onApplyTheme,
2069
+ onEditTheme: onEditTheme,
2070
+ theme: theme,
2071
+ thumbnail: thumbnail,
2072
+ active: isActive,
2073
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
2074
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2075
+ isHighLightedTheme: theme.id === themeToHighlight,
2076
+ key: theme.id,
2077
+ onCloneTheme: handleCloneTheme,
2078
+ onDeleteTheme: !isActive && onDeleteTheme,
2079
+ onSetPreviewTheme: setPreviewTheme
2080
+ });
2081
+ })
2082
+ })
2083
+ });
2084
+ return /*#__PURE__*/jsxs("div", {
2085
+ className: "neeto-themes-sidebar__scroll",
2086
+ children: [/*#__PURE__*/jsxs("div", {
2087
+ className: "mb-6 space-y-3",
2088
+ children: [isSearchVisible && /*#__PURE__*/jsx(Search, {
2089
+ autoFocus: true,
2090
+ enableUrlSync: true,
2091
+ autoComplete: "off",
2092
+ className: "mb-4 mt-1 px-6",
2093
+ placeholder: t("neetoThemes.common.searchThemes")
2094
+ }), isEmpty(filteredThemes) && isEmpty(filteredDefaultThemes) && /*#__PURE__*/jsx(Typography, {
2095
+ className: "text-center",
2096
+ "data-testid": "no-data-title",
2097
+ variant: "body2",
2098
+ children: t("neetoThemes.common.noResultsFound")
2099
+ })]
2100
+ }), activeThemeSection, systemThemesSection, customThemesSection]
2101
+ });
2102
+ };
2103
+
2104
+ var TitleBar = function TitleBar(_ref) {
2105
+ var currentScreen = _ref.currentScreen,
2106
+ handleBackPress = _ref.handleBackPress,
2107
+ handleToggleSearch = _ref.handleToggleSearch;
2108
+ var _useTranslation = useTranslation(),
2109
+ t = _useTranslation.t;
2110
+ var _useThemeStore = useThemeStore(function (store) {
2111
+ return {
2112
+ previewingTheme: store["previewingTheme"]
2113
+ };
2114
+ }, shallow),
2115
+ previewingTheme = _useThemeStore.previewingTheme;
2116
+ var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
2117
+ var _useConfigStore = useConfigStore(function (store) {
2118
+ return {
2119
+ entityType: store["entityType"],
2120
+ helpDocUrl: store["helpDocUrl"]
2121
+ };
2122
+ }, shallow),
2123
+ entityType = _useConfigStore.entityType,
2124
+ helpDocUrl = _useConfigStore.helpDocUrl;
2125
+ var isCustomizeScreen = isEditThemeRoute() || isNewThemeRoute();
2126
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2127
+ var isRTL = i18n.dir() === "rtl";
2128
+ var BackButtonIcon = isRTL ? RightArrow : LeftArrow;
2129
+ if (isCustomizeScreen) {
2130
+ return /*#__PURE__*/jsx("div", {
2131
+ className: "neeto-themes-sidebar__header px-4",
2132
+ children: /*#__PURE__*/jsxs("div", {
2133
+ className: "flex items-center justify-start space-x-2",
2134
+ children: [/*#__PURE__*/jsx(Button, {
2135
+ "data-testid": "customize-themes-back-button",
2136
+ icon: BackButtonIcon,
2137
+ iconPosition: "left",
2138
+ variant: "ghost",
2139
+ tooltipProps: {
2140
+ content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
2141
+ position: "top"
2142
+ },
2143
+ onClick: function onClick() {
2144
+ return handleBackPress(themeId);
2145
+ }
2146
+ }), /*#__PURE__*/jsxs(Typography, {
2147
+ "data-testid": "themes-header",
2148
+ variant: "h3",
2149
+ weight: "semibold",
2150
+ children: [isCustomizeScreen && !isCustomCssScreen && (isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
2151
+ })]
2152
+ })
2153
+ });
2154
+ }
2155
+ return /*#__PURE__*/jsx("div", {
2156
+ className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
2157
+ children: /*#__PURE__*/jsxs("div", {
2158
+ className: "flex items-center justify-between space-x-2",
2159
+ children: [/*#__PURE__*/jsxs("div", {
2160
+ className: "flex space-x-2",
2161
+ children: [/*#__PURE__*/jsx(Typography, {
2162
+ "data-testid": "themes-header",
2163
+ variant: "h3",
2164
+ weight: "semibold",
2165
+ children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
2166
+ }), /*#__PURE__*/jsx(HelpPopover, {
2167
+ helpLinkProps: helpDocUrl && {
2168
+ href: helpDocUrl
2169
+ },
2170
+ title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
2171
+ description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
2172
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
2173
+ })
2174
+ })]
2175
+ }), /*#__PURE__*/jsx("div", {
2176
+ className: "self-end",
2177
+ children: /*#__PURE__*/jsx(Button, {
2178
+ "data-testid": "themes-search-toggle-button",
2179
+ icon: Search$1,
2180
+ iconPosition: "left",
2181
+ variant: "ghost",
2182
+ tooltipProps: {
2183
+ content: t("neetoThemes.common.searchThemes"),
2184
+ position: "top"
2185
+ },
2186
+ onClick: handleToggleSearch
2187
+ })
2188
+ })]
2189
+ })
2190
+ });
2191
+ };
2192
+
2193
+ var MemoizedAlert = /*#__PURE__*/memo(Alert);
2194
+ var Sidebar = function Sidebar(_ref) {
2195
+ var _themeToDelete$curren2;
2196
+ var thumbnail = _ref.thumbnail,
2197
+ onPropertiesChange = _ref.onPropertiesChange,
2198
+ defaultImageSize = _ref.defaultImageSize,
2199
+ fixedAspectRatio = _ref.fixedAspectRatio,
2200
+ onApplyThemeSuccess = _ref.onApplyThemeSuccess,
2201
+ onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
2202
+ var _useState = useState(DESIGN_SCREENS.THEMES),
2203
+ _useState2 = _slicedToArray(_useState, 2),
2204
+ currentScreen = _useState2[0],
2205
+ setCurrentScreen = _useState2[1];
2206
+ var _useState3 = useState(false),
2207
+ _useState4 = _slicedToArray(_useState3, 2),
2208
+ isDeleteAlertOpen = _useState4[0],
2209
+ setIsDeleteAlertOpen = _useState4[1];
2210
+ var _useState5 = useState(null),
2211
+ _useState6 = _slicedToArray(_useState5, 2),
2212
+ themeToHighlight = _useState6[0],
2213
+ setThemeToHighlight = _useState6[1];
2214
+ var _useState7 = useState({}),
2215
+ _useState8 = _slicedToArray(_useState7, 2),
2216
+ themeBeingApplied = _useState8[0],
2217
+ setThemeBeingApplied = _useState8[1];
2218
+ var _useBreakpoints = useBreakpoints(),
2219
+ isSize = _useBreakpoints.isSize;
2220
+ var isLargerScreen = !isSize("mobile");
2221
+ var _useState9 = useState(!isLargerScreen),
2222
+ _useState10 = _slicedToArray(_useState9, 2),
2223
+ isThemesSidebarCollapsed = _useState10[0],
2224
+ setIsThemesSidebarCollapsed = _useState10[1];
2225
+ var history = useHistory();
2226
+ useEffect(function () {
2227
+ setIsThemesSidebarCollapsed(!isLargerScreen);
2228
+ }, [isLargerScreen]);
2229
+ var _useConfigStore = useConfigStore(function (store) {
2230
+ return {
2231
+ entityType: store["entityType"],
2232
+ entityId: store["entityId"],
2233
+ isFetchingSchema: store["isFetchingSchema"],
2234
+ defaultThemeName: store["defaultThemeName"]
2235
+ };
2236
+ }, shallow),
2237
+ entityType = _useConfigStore.entityType,
2238
+ entityId = _useConfigStore.entityId,
2239
+ isFetchingSchema = _useConfigStore.isFetchingSchema,
2240
+ defaultThemeName = _useConfigStore.defaultThemeName;
2241
+ var _useThemeStore = useThemeStore(function (store) {
2242
+ return {
2243
+ setThemeState: store["setThemeState"]
2244
+ };
2245
+ }, shallow),
2246
+ setThemeState = _useThemeStore.setThemeState;
2247
+ var didScrollActiveThemeIntoView = useRef(null);
2248
+ var _useTranslation = useTranslation(),
2249
+ t = _useTranslation.t;
2250
+ var _useThemeUtils = useThemeUtils(),
2251
+ setTheme = _useThemeUtils.setTheme;
2252
+ var _useListThemes = useListThemes(entityId),
2253
+ _useListThemes$data = _useListThemes.data,
2254
+ _useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
2255
+ _useListThemes$data2$ = _useListThemes$data2.themes,
2256
+ themes = _useListThemes$data2$ === void 0 ? [] : _useListThemes$data2$,
2257
+ _useListThemes$data2$2 = _useListThemes$data2.defaultThemes,
2258
+ defaultThemes = _useListThemes$data2$2 === void 0 ? [] : _useListThemes$data2$2,
2259
+ isLoading = _useListThemes.isLoading;
2260
+ var _useShowThemeEntity = useShowThemeEntity(entityId),
2261
+ _useShowThemeEntity$d = _useShowThemeEntity.data,
2262
+ _useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
2263
+ _useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
2264
+ currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
2265
+ isCurrentThemeLoading = _useShowThemeEntity.isLoading;
2266
+ var _useDeleteTheme = useDeleteTheme(),
2267
+ deleteTheme = _useDeleteTheme.mutate,
2268
+ isDeleting = _useDeleteTheme.isPending;
2269
+ var _useApplyTheme = useApplyTheme({
2270
+ onSuccess: function onSuccess(_ref2) {
2271
+ var theme = _ref2.theme;
2272
+ var applyUpdates = function applyUpdates() {
2273
+ setTheme(theme);
2274
+ highlightTheme(theme);
2275
+ setThemeState({
2276
+ previewingTheme: theme
2277
+ });
2278
+ setThemeBeingApplied({});
2279
+ setCurrentScreen(DESIGN_SCREENS.THEMES);
2280
+ onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
2281
+ };
2282
+
2283
+ // Keep the spinner visible a bit longer so the apply feels deliberate,
2284
+ // then glide the card into the pinned active section.
2285
+ setTimeout(function () {
2286
+ return animateThemeReorder(applyUpdates);
2287
+ }, APPLY_SPINNER_DELAY);
2288
+ }
2289
+ }),
2290
+ applyTheme = _useApplyTheme.mutate,
2291
+ isApplyingTheme = _useApplyTheme.isPending;
2292
+ var themeToDelete = useRef(null);
2293
+ var themeToEdit = useRef(null);
2294
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2295
+ var _useState11 = useState(false),
2296
+ _useState12 = _slicedToArray(_useState11, 2),
2297
+ isSearchVisible = _useState12[0],
2298
+ setIsSearchVisible = _useState12[1];
2299
+ var handleToggleSearch = function handleToggleSearch() {
2300
+ setIsSearchVisible(function (prev) {
2301
+ var next = !prev;
2302
+ if (!next) {
2303
+ var params = new URLSearchParams(history.location.search);
2304
+ params["delete"]("searchTerm");
2305
+ history.replace({
2306
+ search: params.toString()
2307
+ });
2308
+ }
2309
+ return next;
2310
+ });
2311
+ };
2312
+ var handleEditTheme = function handleEditTheme(theme, section) {
2313
+ themeToEdit.current = theme;
2314
+ var pathname = buildUrl(buildPathname(routes.themes.edit), {
2315
+ themeId: theme.id
2316
+ });
2317
+ history.push({
2318
+ pathname: pathname,
2319
+ search: section ? "?section=".concat(section) : ""
2320
+ });
2321
+ };
2322
+ var onApplyTheme = function onApplyTheme(theme) {
2323
+ if (themeBeingApplied !== null && themeBeingApplied !== void 0 && themeBeingApplied.id) return;
2324
+ setThemeBeingApplied(theme);
2325
+ applyTheme({
2326
+ themeId: theme.id,
2327
+ entityId: entityId,
2328
+ entityType: entityType
2329
+ }, {
2330
+ onError: function onError() {
2331
+ return setThemeBeingApplied({});
2332
+ }
2333
+ });
2334
+ };
2335
+ var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
2336
+ highlightTheme(isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
2337
+ history.push(buildPathname(routes.themes.index));
2338
+ themeToEdit.current = null;
2339
+ };
2340
+ var handleBackPress = function handleBackPress(themeId) {
2341
+ if (isCustomCssScreen) {
2342
+ setCurrentScreen(DESIGN_SCREENS.Customize);
2343
+ return;
2344
+ }
2345
+ navigateToThemesScreen(themeId);
2346
+ };
2347
+ var highlightTheme = function highlightTheme(themeIdToHighlight) {
2348
+ setTimeout(function () {
2349
+ scrollElementIntoView(themeIdToHighlight);
2350
+ }, 1500);
2351
+ setTimeout(function () {
2352
+ setThemeToHighlight(null);
2353
+ }, 4000);
2354
+ setThemeToHighlight(themeIdToHighlight);
2355
+ };
2356
+ var onCreateTheme = function onCreateTheme(createdTheme) {
2357
+ themeToEdit.current = createdTheme;
2358
+ setTheme(createdTheme);
2359
+ setThemeState({
2360
+ previewingTheme: createdTheme
2361
+ });
2362
+ };
2363
+ var onUpdateTheme = function onUpdateTheme(updatedTheme) {
2364
+ themeToEdit.current = updatedTheme;
2365
+ onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(updatedTheme);
2366
+ };
2367
+ var handleDelete = function handleDelete(themeId, name) {
2368
+ setIsDeleteAlertOpen(true);
2369
+ themeToDelete.current = {
2370
+ id: themeId,
2371
+ name: name
2372
+ };
2373
+ };
2374
+ var handleCloseDeleteAlert = useCallback(function () {
2375
+ setIsDeleteAlertOpen(false);
2376
+ themeToDelete.current = null;
2377
+ }, [themeToDelete]);
2378
+ var handleDeleteTheme = useCallback(function () {
2379
+ var _themeToDelete$curren;
2380
+ deleteTheme((_themeToDelete$curren = themeToDelete.current) === null || _themeToDelete$curren === void 0 ? void 0 : _themeToDelete$curren.id, {
2381
+ onSuccess: function onSuccess() {
2382
+ setIsDeleteAlertOpen(false);
2383
+ themeToDelete.current = null;
2384
+ }
2385
+ });
2386
+ }, [deleteTheme, themeToDelete]);
2387
+ return /*#__PURE__*/jsxs(Fragment, {
2388
+ children: [!isThemesSidebarCollapsed && /*#__PURE__*/jsx("div", {
2389
+ className: "neeto-themes-sidebar__backdrop",
2390
+ onClick: function onClick() {
2391
+ setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
2392
+ }
2393
+ }), /*#__PURE__*/jsxs("div", {
2394
+ className: classnames("neeto-themes-sidebar border-border shrink-0 border-e transition-all duration-300", {
2395
+ "neeto-themes-sidebar--expanded": isCustomCssScreen
2396
+ }, {
2397
+ "neeto-themes-sidebar--collapsed": isThemesSidebarCollapsed
2398
+ }),
2399
+ children: [/*#__PURE__*/jsx(TitleBar, {
2400
+ currentScreen: currentScreen,
2401
+ handleBackPress: handleBackPress,
2402
+ handleToggleSearch: handleToggleSearch
2403
+ }), /*#__PURE__*/jsxs(Switch$1, {
2404
+ children: [/*#__PURE__*/jsx(Route, {
2405
+ exact: true,
2406
+ path: buildPathname(routes.themes.index),
2407
+ render: function render() {
2408
+ return /*#__PURE__*/jsx(Themes, {
2409
+ currentTheme: currentTheme,
2410
+ defaultThemes: defaultThemes,
2411
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2412
+ highlightTheme: highlightTheme,
2413
+ isCurrentThemeLoading: isCurrentThemeLoading,
2414
+ isSearchVisible: isSearchVisible,
2415
+ onApplyTheme: onApplyTheme,
2416
+ onApplyThemeSuccess: onApplyThemeSuccess,
2417
+ themeBeingApplied: themeBeingApplied,
2418
+ themeToHighlight: themeToHighlight,
2419
+ themes: themes,
2420
+ thumbnail: thumbnail,
2421
+ isLoading: isLoading || isFetchingSchema,
2422
+ onDeleteTheme: handleDelete,
2423
+ onEditTheme: handleEditTheme
2424
+ });
2425
+ }
2426
+ }), /*#__PURE__*/jsx(Route, {
2427
+ path: buildPathname(routes.themes["new"]),
2428
+ render: function render() {
2429
+ return /*#__PURE__*/jsx(Customize, {
2430
+ currentScreen: currentScreen,
2431
+ defaultImageSize: defaultImageSize,
2432
+ fixedAspectRatio: fixedAspectRatio,
2433
+ isApplyingTheme: isApplyingTheme,
2434
+ onApplyTheme: onApplyTheme,
2435
+ onCreateTheme: onCreateTheme,
2436
+ onPropertiesChange: onPropertiesChange,
2437
+ onUpdateTheme: onUpdateTheme,
2438
+ theme: themeToEdit.current,
2439
+ onEditCSSClick: setCurrentScreen
2440
+ });
2441
+ }
2442
+ }), /*#__PURE__*/jsx(Route, {
2443
+ path: buildPathname(routes.themes.edit),
2444
+ render: function render() {
2445
+ return /*#__PURE__*/jsx(Customize, {
2446
+ currentScreen: currentScreen,
2447
+ defaultImageSize: defaultImageSize,
2448
+ fixedAspectRatio: fixedAspectRatio,
2449
+ isApplyingTheme: isApplyingTheme,
2450
+ onApplyTheme: onApplyTheme,
2451
+ onCreateTheme: onCreateTheme,
2452
+ onPropertiesChange: onPropertiesChange,
2453
+ onUpdateTheme: onUpdateTheme,
2454
+ theme: themeToEdit.current,
2455
+ onEditCSSClick: setCurrentScreen
2456
+ });
2457
+ }
2458
+ })]
2459
+ }), /*#__PURE__*/jsx(MemoizedAlert, {
2460
+ isOpen: isDeleteAlertOpen,
2461
+ isSubmitting: isDeleting,
2462
+ title: t("neetoThemes.alerts.title.deleteTheme"),
2463
+ message: t("neetoThemes.alerts.message.deleteTheme", {
2464
+ name: (_themeToDelete$curren2 = themeToDelete.current) === null || _themeToDelete$curren2 === void 0 ? void 0 : _themeToDelete$curren2.name,
2465
+ defaultThemeName: defaultThemeName,
2466
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
2467
+ }),
2468
+ onClose: handleCloseDeleteAlert,
2469
+ onSubmit: handleDeleteTheme
2470
+ }), /*#__PURE__*/jsx(Button, {
2471
+ className: "neeto-themes-sidebar__toggler",
2472
+ icon: Collapse,
2473
+ variant: "outline",
2474
+ onClick: function onClick() {
2475
+ setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
2476
+ }
2477
+ })]
2478
+ })]
2479
+ });
2480
+ };
2481
+
2482
+ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2483
+ var children = _ref.children,
2484
+ entityType = _ref.entityType,
2485
+ entityId = _ref.entityId,
2486
+ thumbnail = _ref.thumbnail,
2487
+ onPropertiesChange = _ref.onPropertiesChange,
2488
+ _ref$defaultImageSize = _ref.defaultImageSize,
2489
+ defaultImageSize = _ref$defaultImageSize === void 0 ? {} : _ref$defaultImageSize,
2490
+ _ref$fixedAspectRatio = _ref.fixedAspectRatio,
2491
+ fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio,
2492
+ _ref$helpDocUrl = _ref.helpDocUrl,
2493
+ helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
2494
+ _ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
2495
+ isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
2496
+ _ref$pageTitle = _ref.pageTitle,
2497
+ pageTitle = _ref$pageTitle === void 0 ? null : _ref$pageTitle,
2498
+ _ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
2499
+ onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? noop : _ref$onApplyThemeSucc,
2500
+ _ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
2501
+ onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? noop : _ref$onUpdateThemeSuc,
2502
+ _ref$helpPopoverProps = _ref.helpPopoverProps,
2503
+ helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
2504
+ _ref$enabledFeatures = _ref.enabledFeatures,
2505
+ enabledFeatures = _ref$enabledFeatures === void 0 ? {
2506
+ customCSS: true
2507
+ } : _ref$enabledFeatures,
2508
+ _ref$proFeatures = _ref.proFeatures,
2509
+ proFeatures = _ref$proFeatures === void 0 ? {} : _ref$proFeatures;
2510
+ useMemo(registerNeetoThemesTranslations, []);
2511
+ var _useThemeStore = useThemeStore(function (store) {
2512
+ return {
2513
+ setThemeState: store["setThemeState"]
2514
+ };
2515
+ }, shallow),
2516
+ setThemeState = _useThemeStore.setThemeState;
2517
+ var _useThemeUtils = useThemeUtils(),
2518
+ setTheme = _useThemeUtils.setTheme;
2519
+ var _useConfigStore = useConfigStore(function (store) {
2520
+ return {
2521
+ setConfigState: store["setConfigState"]
2522
+ };
2523
+ }, shallow),
2524
+ setConfigState = _useConfigStore.setConfigState;
2525
+ var _useTranslation = useTranslation(),
2526
+ t = _useTranslation.t;
2527
+ var _useShowThemeEntity = useShowThemeEntity(entityId),
2528
+ _useShowThemeEntity$d = _useShowThemeEntity.data,
2529
+ _useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
2530
+ _useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
2531
+ currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
2532
+ isLoading = _useShowThemeEntity.isLoading,
2533
+ isFetchingCurrentTheme = _useShowThemeEntity.isFetching;
2534
+ var isCurrentThemeLoading = isLoading || isFetchingCurrentTheme;
2535
+ useEffect(function () {
2536
+ setConfigState({
2537
+ entityType: entityType,
2538
+ entityId: entityId,
2539
+ isTemplateThemesEnabled: isTemplateThemesEnabled,
2540
+ helpDocUrl: helpDocUrl,
2541
+ helpPopoverProps: helpPopoverProps,
2542
+ enabledFeatures: enabledFeatures,
2543
+ proFeatures: proFeatures
2544
+ });
2545
+ }, []);
2546
+ useEffect(function () {
2547
+ if (isNotPresent(currentTheme) || isEditThemeRoute()) {
2548
+ return;
2549
+ }
2550
+ setThemeState({
2551
+ previewingTheme: currentTheme
2552
+ });
2553
+ setTheme(currentTheme);
2554
+ }, [isLoading, entityId, currentTheme]);
2555
+ useEffect(function () {
2556
+ if (isNotPresent(currentTheme)) return;
2557
+ setThemeState({
2558
+ currentTheme: currentTheme,
2559
+ isCurrentThemeLoading: isCurrentThemeLoading
2560
+ });
2561
+ }, [currentTheme, isCurrentThemeLoading]);
2562
+ useEffect(function () {
2563
+ var setViewportHeight = function setViewportHeight() {
2564
+ document.documentElement.style.setProperty("--viewport-height", "".concat(window.innerHeight, "px"));
2565
+ };
2566
+ setViewportHeight();
2567
+ window.addEventListener("load", setViewportHeight);
2568
+ window.addEventListener("resize", setViewportHeight);
2569
+ window.addEventListener("orientationchange", setViewportHeight);
2570
+ window.addEventListener("scroll", setViewportHeight);
2571
+ return function () {
2572
+ window.removeEventListener("load", setViewportHeight);
2573
+ window.removeEventListener("resize", setViewportHeight);
2574
+ window.removeEventListener("orientationchange", setViewportHeight);
2575
+ window.removeEventListener("scroll", setViewportHeight);
2576
+ };
2577
+ }, []);
2578
+ return /*#__PURE__*/jsxs("div", {
2579
+ className: "neeto-themes__wrapper",
2580
+ children: [/*#__PURE__*/jsx(PageTitle, {
2581
+ title: pageTitle || t("neetoThemes.common.theme")
2582
+ }), /*#__PURE__*/jsx(Sidebar, {
2583
+ defaultImageSize: defaultImageSize,
2584
+ fixedAspectRatio: fixedAspectRatio,
2585
+ onApplyThemeSuccess: onApplyThemeSuccess,
2586
+ onPropertiesChange: onPropertiesChange,
2587
+ onUpdateThemeSuccess: onUpdateThemeSuccess,
2588
+ thumbnail: thumbnail
2589
+ }), /*#__PURE__*/jsx("div", {
2590
+ className: "neeto-themes-preview__wrapper",
2591
+ children: isCurrentThemeLoading ? /*#__PURE__*/jsx("div", {
2592
+ className: "m-auto flex h-full w-full items-center justify-center",
2593
+ children: /*#__PURE__*/jsx(Spinner, {})
2594
+ }) : children
2595
+ })]
2596
+ });
2597
+ };
2598
+
2599
+ export { NeetoThemesBuilder as default };
2600
+ //# sourceMappingURL=NeetoThemesBuilder.js.map