exports.id = 742;
exports.ids = [742];
exports.modules = {

/***/ 1108:
/***/ ((module) => {

// Exports
module.exports = {
	"center": "Product_center__mndim",
	"paper": "Product_paper__1Vh8i",
	"styledScrollBarList": "Product_styledScrollBarList__odXWa",
	"page": "Product_page__CPjBB",
	"pageHeader": "Product_pageHeader__cVvAZ",
	"pageContent": "Product_pageContent__VabDs",
	"pageTitle": "Product_pageTitle__oO3X3",
	"customIcon": "Product_customIcon__S0HDM",
	"Product": "Product_Product__zUjSM",
	"header": "Product_header__Vnl8m",
	"headerLeft": "Product_headerLeft__ddqSc",
	"headerActions": "Product_headerActions__nxMaj",
	"tab": "Product_tab__y8Kl0",
	"mainTab": "Product_mainTab__fNi3c",
	"textField": "Product_textField__bEz_L",
	"imageBlock": "Product_imageBlock__jUZVR",
	"imageItem": "Product_imageItem__iJGZ_",
	"imageActions": "Product_imageActions__vBKzW",
	"saveBtn": "Product_saveBtn__uHklk",
	"attributeBlock": "Product_attributeBlock__WeWj6",
	"attributeHeader": "Product_attributeHeader__FMBFN",
	"attributeName": "Product_attributeName__L2tp7",
	"attributeInstanceValue": "Product_attributeInstanceValue__y5Lai",
	"editingProductVariant": "Product_editingProductVariant__UUIqh",
	"editingProductVariantCard": "Product_editingProductVariantCard__q9Y0x",
	"editingProductVariantTitle": "Product_editingProductVariantTitle__E6Io8",
	"tag": "Product_tag__6kARt",
	"notFoundPage": "Product_notFoundPage__yg9p_",
	"notFoundText": "Product_notFoundText__yYPbK",
	"galleryActions": "Product_galleryActions__QvDEU",
	"galleryContainer": "Product_galleryContainer__QxhdG",
	"galleryActionBtn": "Product_galleryActionBtn__Plcz8",
	"galleryAddImageBtn": "Product_galleryAddImageBtn__vxwub",
	"openPageBtn": "Product_openPageBtn__00QZP",
	"newAttributesList": "Product_newAttributesList__3SFeb",
	"newAttributeOption": "Product_newAttributeOption__ynXG5",
	"descriptionEditor": "Product_descriptionEditor__1AL7I",
	"CategoriesTab": "Product_CategoriesTab__nqcU_",
	"PageContent": "Product_PageContent__qkRn9",
	"AttributesTab": "Product_AttributesTab__Aj5d2",
	"checklist": "Product_checklist__qXlqd",
	"popoverPaper": "Product_popoverPaper__ta8gk"
};


/***/ }),

/***/ 5742:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ ProductPage)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _apollo_client__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9114);
/* harmony import */ var _apollo_client__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_apollo_client__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _cromwell_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1815);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4536);
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9103);
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(query_string__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _components_entity_entityEdit_EntityEdit__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4342);
/* harmony import */ var _constants_PageInfos__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(379);
/* harmony import */ var _helpers_customFields__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(9143);
/* harmony import */ var _components_Header__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1699);
/* harmony import */ var _components_PageContent__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3471);
/* harmony import */ var _contexts_Product__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(6392);
/* harmony import */ var _hooks_useTabs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3739);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_entity_entityEdit_EntityEdit__WEBPACK_IMPORTED_MODULE_6__, _helpers_customFields__WEBPACK_IMPORTED_MODULE_8__, _components_PageContent__WEBPACK_IMPORTED_MODULE_10__]);
([_components_entity_entityEdit_EntityEdit__WEBPACK_IMPORTED_MODULE_6__, _helpers_customFields__WEBPACK_IMPORTED_MODULE_8__, _components_PageContent__WEBPACK_IMPORTED_MODULE_10__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);













function ProductPage() {
    const [store, setStore] = (0,react__WEBPACK_IMPORTED_MODULE_5__.useState)({
        tab: Number(query_string__WEBPACK_IMPORTED_MODULE_4___default().parse(window.location.search).tab || "0"),
        productRef: {
            data: null
        }
    });
    const client = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_3__.getGraphQLClient)();
    const [activeTabNum] = (0,_hooks_useTabs__WEBPACK_IMPORTED_MODULE_12__/* .useTabs */ .Y)({
        store,
        setStore
    });
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_contexts_Product__WEBPACK_IMPORTED_MODULE_11__/* .ProductContext.Provider */ .H.Provider, {
        value: {
            store,
            setStore
        },
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_entity_entityEdit_EntityEdit__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
            entityCategory: _cromwell_core__WEBPACK_IMPORTED_MODULE_2__.EDBEntity.Product,
            entityListRoute: _constants_PageInfos__WEBPACK_IMPORTED_MODULE_7__/* .productListInfo.route */ .e8.route,
            entityBaseRoute: _constants_PageInfos__WEBPACK_IMPORTED_MODULE_7__/* .productPageInfo.baseRoute */ .On.baseRoute,
            listLabel: "Products",
            entityLabel: "Product",
            defaultPageName: "product",
            getById: (id)=>{
                return client.getProductById(id, _apollo_client__WEBPACK_IMPORTED_MODULE_1__.gql`
          fragment AdminPanelProductFragment on Product {
              id
              slug
              createDate
              updateDate
              isEnabled
              pageTitle
              pageDescription
              meta {
                  keywords
              }
              name
              price
              oldPrice
              sku
              mainImage
              images
              description
              descriptionDelta
              views
              mainCategoryId
              stockAmount
              stockStatus
              manageStock
              categories {
                  id
                  name
                  parent {
                    id
                  }
              }
              customMeta (keys: ${JSON.stringify((0,_helpers_customFields__WEBPACK_IMPORTED_MODULE_8__/* .getCustomMetaKeysFor */ .He)(_cromwell_core__WEBPACK_IMPORTED_MODULE_2__.EDBEntity.Product))})
              attributes {
                  key
                  values {
                      value
                  }
              }
              variants {
                  id
                  name
                  price
                  oldPrice
                  sku
                  mainImage
                  images
                  description
                  descriptionDelta
                  stockAmount
                  stockStatus
                  manageStock
                  attributes
                  customMeta (keys: ${JSON.stringify((0,_helpers_customFields__WEBPACK_IMPORTED_MODULE_8__/* .getCustomMetaKeysFor */ .He)(_cromwell_core__WEBPACK_IMPORTED_MODULE_2__.EDBEntity.ProductVariant))})
              }
          }`, "AdminPanelProductFragment");
            },
            onSave: async (data)=>{
                const product = {
                    ...Object.assign({}, (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_2__.removeUndefinedOrNull)(store.productRef?.data), (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_2__.removeUndefinedOrNull)(data))
                };
                const productAttributes = product.attributes?.map((attr)=>({
                        key: attr.key,
                        values: attr.values ? attr.values.map((val)=>({
                                value: val.value
                            })) : []
                    }));
                const categoryIds = product?.categories?.map((cat)=>cat.id) || [];
                if (product.mainCategoryId && !categoryIds.includes(product.mainCategoryId)) {
                    categoryIds.push(product.mainCategoryId);
                }
                return {
                    name: product.name,
                    categoryIds,
                    mainCategoryId: product.mainCategoryId,
                    price: typeof product.price === "string" ? parseFloat(product.price) : product.price,
                    oldPrice: typeof product.oldPrice === "string" ? parseFloat(product.oldPrice) : product.oldPrice,
                    sku: product.sku,
                    mainImage: product.mainImage,
                    images: product.images,
                    stockStatus: product.stockStatus ?? "In stock",
                    stockAmount: product.stockAmount,
                    manageStock: product.manageStock,
                    description: product.description,
                    descriptionDelta: product.descriptionDelta,
                    slug: product.slug,
                    attributes: productAttributes,
                    pageTitle: product.pageTitle,
                    pageDescription: product.pageDescription,
                    meta: product.meta && {
                        keywords: product.meta.keywords
                    },
                    variants: product.variants?.map((variant)=>({
                            id: typeof variant.id === "number" ? variant.id : undefined,
                            name: variant.name,
                            price: typeof variant.price === "string" ? parseFloat(variant.price) : variant.price,
                            oldPrice: typeof variant.oldPrice === "string" ? parseFloat(variant.oldPrice) : variant.oldPrice,
                            sku: variant.sku,
                            mainImage: variant.mainImage,
                            images: variant.images,
                            description: variant.description,
                            descriptionDelta: variant.descriptionDelta,
                            stockAmount: variant.stockAmount,
                            stockStatus: variant.stockStatus,
                            manageStock: variant.manageStock,
                            attributes: variant.attributes,
                            customMeta: variant.customMeta
                        })),
                    customMeta: Object.assign({}, product.customMeta, await (0,_helpers_customFields__WEBPACK_IMPORTED_MODULE_8__/* .getCustomMetaFor */ .Q7)(_cromwell_core__WEBPACK_IMPORTED_MODULE_2__.EDBEntity.Product)),
                    isEnabled: product.isEnabled
                };
            },
            update: client.updateProduct,
            create: client.createProduct,
            deleteOne: client.deleteProduct,
            customElements: {
                getEntityFields: (props)=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_PageContent__WEBPACK_IMPORTED_MODULE_10__/* .PageContent */ .J, {
                        ...props
                    }),
                getEntityHeaderCenter: ()=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_Header__WEBPACK_IMPORTED_MODULE_9__/* .Header */ .h, {})
            },
            disableMeta: activeTabNum !== 0
        })
    });
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 1316:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "t": () => (/* binding */ AttributesTab)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2135);
/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _components_buttons_IconButton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4137);
/* harmony import */ var _components_buttons_TextButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2789);
/* harmony import */ var _components_transferList_TransferList__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1092);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1108);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_Product_module_scss__WEBPACK_IMPORTED_MODULE_7__);








function AttributesTab(props) {
    const { product , attributes , setProdData , forceUpdate  } = props;
    const [popperAnchorEl, setPopperAnchorEl] = react__WEBPACK_IMPORTED_MODULE_3___default().useState(null);
    const [popperOpen, setPopperOpen] = react__WEBPACK_IMPORTED_MODULE_3___default().useState(false);
    const leftAttributesToAdd = [];
    attributes.forEach((attr)=>{
        if (product) {
            const hasAttr = product.attributes ? product.attributes.some((a)=>a.key === attr.key) : false;
            if (!hasAttr) {
                leftAttributesToAdd.push(attr);
            }
        }
    });
    const addAttribute = (key)=>{
        const prod = JSON.parse(JSON.stringify(product));
        if (!prod.attributes) prod.attributes = [];
        prod.attributes.push({
            key,
            values: []
        });
        setPopperOpen(false);
        setProdData(prod);
        forceUpdate();
    };
    const deleteAttribute = (index)=>{
        const prod = JSON.parse(JSON.stringify(product));
        if (prod.attributes) {
            prod.attributes = prod.attributes.filter((a, i)=>i !== index);
            setProdData(prod);
            forceUpdate();
        }
    };
    const setRight = (prodAttrIdx, val)=>{
        const prod = JSON.parse(JSON.stringify(product));
        if (!prod.attributes) prod.attributes = [];
        const newVals = [];
        val.forEach((newVal)=>{
            let hasVal = false;
            prod.attributes?.[prodAttrIdx]?.values.forEach((prodVal)=>{
                if (prodVal.value === newVal) {
                    newVals.push(prodVal);
                    hasVal = true;
                }
            });
            if (!hasVal) {
                newVals.push({
                    value: newVal
                });
            }
        });
        prod.attributes[prodAttrIdx].values = newVals.sort((a, b)=>a.value > b.value ? 1 : -1);
        setProdData(prod);
        forceUpdate();
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().AttributesTab),
        children: [
            product.attributes && attributes && product.attributes.map((prodAttr, prodAttrIdx)=>{
                const attribute = attributes.find((a)=>a.key === prodAttr.key);
                if (!attribute) return null;
                const leftValues = attribute.values?.filter((v)=>!prodAttr.values.some((pv)=>pv.value === v.value)) || [];
                const rightValues = prodAttr.values?.map((v)=>v.value) || [];
                return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().attributeBlock),
                    children: [
                        /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                            className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().attributeHeader),
                            children: [
                                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
                                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().attributeName),
                                    children: attribute.title || attribute.key || ""
                                }),
                                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_buttons_IconButton__WEBPACK_IMPORTED_MODULE_4__/* .IconButton */ .h, {
                                    "aria-label": "delete attribute",
                                    onClick: ()=>deleteAttribute(prodAttrIdx),
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.TrashIcon, {
                                        className: "w-5 h-5"
                                    })
                                })
                            ]
                        }),
                        attribute.type !== "text_input" && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_transferList_TransferList__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                            text: {
                                choices: "Available",
                                chosen: "Assigned"
                            },
                            left: leftValues.map((v)=>v.value),
                            setLeft: ()=>{},
                            right: rightValues,
                            classes: {
                                checklist: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().checklist)
                            },
                            itemComp: (props)=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().attributeInstanceValue),
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
                                        children: props.value
                                    })
                                }),
                            setRight: (val)=>setRight(prodAttrIdx, val)
                        })
                    ]
                }, prodAttr.key);
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Box, {
                sx: {
                    my: 1
                },
                style: {
                    width: "100%",
                    display: "flex"
                },
                children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_components_buttons_TextButton__WEBPACK_IMPORTED_MODULE_5__/* .TextButton */ .A, {
                    color: "primary",
                    style: {
                        margin: "0 auto"
                    },
                    onClick: (event)=>{
                        setPopperAnchorEl(event.currentTarget);
                        setPopperOpen((prev)=>!prev);
                    },
                    disabled: !leftAttributesToAdd.length,
                    children: [
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.PlusIcon, {
                            className: "w-5 h-5 mr-1"
                        }),
                        "Add attribute"
                    ]
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Popper, {
                open: popperOpen,
                anchorEl: popperAnchorEl,
                placement: "bottom-start",
                transition: true,
                children: ({ TransitionProps  })=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_2__.Fade, {
                        ...TransitionProps,
                        timeout: 350,
                        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                            className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().newAttributesList),
                            children: leftAttributesToAdd.map((attr)=>{
                                if (!attr.key) return null;
                                return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_2__.MenuItem, {
                                    disableRipple: true,
                                    onClick: ()=>addAttribute(attr.key),
                                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_7___default().newAttributeOption),
                                    children: attr.title ?? attr.key ?? ""
                                }, attr.key);
                            })
                        })
                    })
            })
        ]
    });
}


/***/ }),

/***/ 1699:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "h": () => (/* binding */ Header)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _hooks_useTabs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3739);




function Header() {
    const [activeTabNum, setActiveTabNum] = (0,_hooks_useTabs__WEBPACK_IMPORTED_MODULE_3__/* .useTabs */ .Y)();
    const handleTabChange = (event, newValue)=>{
        setActiveTabNum(newValue);
    };
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Box, {
        children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tabs, {
            value: activeTabNum,
            indicatorColor: "primary",
            textColor: "primary",
            onChange: handleTabChange,
            children: [
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, {
                    label: "Main",
                    disableRipple: true
                }),
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, {
                    label: "Attributes",
                    disableRipple: true
                }),
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_1__.Tab, {
                    label: "Variants",
                    disableRipple: true
                })
            ]
        })
    });
}


/***/ }),

/***/ 8313:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_inputs_GalleryInput_GalleryInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9281);
/* harmony import */ var _components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6672);
/* harmony import */ var _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1239);
/* harmony import */ var _components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2032);
/* harmony import */ var _cromwell_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1815);
/* harmony import */ var _helpers_customFields__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9143);
/* harmony import */ var _helpers_editor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7586);
/* harmony import */ var _helpers_forceUpdate__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8673);
/* harmony import */ var _mui_icons_material_InfoOutlined__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1947);
/* harmony import */ var _mui_icons_material_InfoOutlined__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_mui_icons_material_InfoOutlined__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_10__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_11__);
/* harmony import */ var throttle_debounce__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(7261);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(1108);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_Product_module_scss__WEBPACK_IMPORTED_MODULE_13__);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_2__, _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_3__, _helpers_customFields__WEBPACK_IMPORTED_MODULE_6__, _helpers_editor__WEBPACK_IMPORTED_MODULE_7__, throttle_debounce__WEBPACK_IMPORTED_MODULE_12__]);
([_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_2__, _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_3__, _helpers_customFields__WEBPACK_IMPORTED_MODULE_6__, _helpers_editor__WEBPACK_IMPORTED_MODULE_7__, throttle_debounce__WEBPACK_IMPORTED_MODULE_12__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);














const MainInfoCard = (props)=>{
    const productPrevRef = (0,react__WEBPACK_IMPORTED_MODULE_11__.useRef)(props.product);
    const cardIdRef = (0,react__WEBPACK_IMPORTED_MODULE_11__.useRef)((0,_cromwell_core__WEBPACK_IMPORTED_MODULE_5__.getRandStr)(10));
    const productRef = (0,react__WEBPACK_IMPORTED_MODULE_11__.useRef)(props.product);
    const canUpdateMeta = (0,react__WEBPACK_IMPORTED_MODULE_11__.useRef)(false);
    if (props.product !== productPrevRef.current) {
        productPrevRef.current = props.product;
        productRef.current = props.product;
    }
    const forceUpdate = (0,_helpers_forceUpdate__WEBPACK_IMPORTED_MODULE_8__/* .useForceUpdate */ .N)();
    const editorId = "prod-text-editor_" + cardIdRef.current;
    const product = productRef.current;
    const setProdData = (data)=>{
        if (!productRef.current) productRef.current = {
            ...data
        };
        else {
            Object.keys(data).forEach((key)=>{
                productRef.current[key] = data[key];
            });
        }
        props.setProdData(data);
    };
    (0,react__WEBPACK_IMPORTED_MODULE_11__.useEffect)(()=>{
        init();
    }, []);
    const init = async ()=>{
        let descriptionDelta;
        if (product?.descriptionDelta) {
            try {
                descriptionDelta = JSON.parse(product.descriptionDelta);
            } catch (e) {
                console.error(e);
            }
        }
        const updateText = (0,throttle_debounce__WEBPACK_IMPORTED_MODULE_12__.debounce)(300, async ()=>{
            if (productRef.current) {
                const description = await (0,_helpers_editor__WEBPACK_IMPORTED_MODULE_7__/* .getEditorHtml */ .eZ)(editorId);
                const descriptionDelta = JSON.stringify(await (0,_helpers_editor__WEBPACK_IMPORTED_MODULE_7__/* .getEditorData */ .Hd)(editorId));
                productRef.current.description = description;
                productRef.current.descriptionDelta = descriptionDelta;
                props.setProdData({
                    ...productRef.current,
                    description,
                    descriptionDelta
                });
            }
        });
        await (0,_helpers_editor__WEBPACK_IMPORTED_MODULE_7__/* .initTextEditor */ .V$)({
            htmlId: editorId,
            data: descriptionDelta,
            placeholder: "Product description...",
            onChange: updateText
        });
    };
    const handleChange = (prop, val)=>{
        if (product) {
            const prod = Object.assign({}, product, {
                [prop]: val
            });
            if (prop === "images") {
                prod.mainImage = val?.[0];
            }
            setProdData(prod);
            forceUpdate();
        }
    };
    const onMetaChange = (0,react__WEBPACK_IMPORTED_MODULE_11__.useMemo)(()=>{
        return (0,throttle_debounce__WEBPACK_IMPORTED_MODULE_12__.debounce)(300, async ()=>{
            if (!canUpdateMeta.current) return;
            const meta = await (0,_helpers_customFields__WEBPACK_IMPORTED_MODULE_6__/* .getCustomMetaFor */ .Q7)(_cromwell_core__WEBPACK_IMPORTED_MODULE_5__.EDBEntity.ProductVariant);
            setProdData(Object.assign({}, product, {
                customMeta: meta
            }));
        });
    }, []);
    if (!product) return null;
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
        container: true,
        spacing: 3,
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 12,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__/* .TextInput */ .o, {
                    label: "Name",
                    value: product.name ?? "",
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().textField),
                    onChange: (e)=>{
                        handleChange("name", e.target.value);
                    },
                    error: props.canValidate && !product?.name
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__/* .TextInput */ .o, {
                    label: "SKU",
                    value: product.sku ?? "",
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().textField),
                    onChange: (e)=>{
                        handleChange("sku", e.target.value);
                    }
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_2__/* .SelectInput */ .l, {
                    label: "Stock status",
                    value: product.stockStatus,
                    onChange: (value)=>{
                        handleChange("stockStatus", value);
                    },
                    options: [
                        "In stock",
                        "Out of stock",
                        "On backorder"
                    ]
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__/* .TextInput */ .o, {
                    label: "Stock amount",
                    value: product.stockAmount ?? "",
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().textField),
                    type: "number",
                    onChange: (e)=>{
                        let val = parseInt(e.target.value);
                        if (isNaN(val)) val = null;
                        if (val && val < 0) val = 0;
                        handleChange("stockAmount", val);
                    }
                })
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 12,
                style: {
                    display: "flex",
                    alignItems: "center"
                },
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_3__/* .SwitchInput */ .D, {
                        label: "Manage stock",
                        value: !!product?.manageStock,
                        onChange: ()=>handleChange("manageStock", !product?.manageStock)
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Tooltip, {
                        title: "Automatically manage stock amount when new orders placed",
                        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_InfoOutlined__WEBPACK_IMPORTED_MODULE_9___default()), {
                            sx: {
                                height: "20px",
                                width: "20px",
                                ml: 2
                            }
                        })
                    })
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__/* .TextInput */ .o, {
                    label: "Price",
                    type: "currency",
                    value: product.price ?? "",
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().textField),
                    onChange: (e)=>{
                        handleChange("price", e.target.value);
                    }
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 6,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_TextInput_TextInput__WEBPACK_IMPORTED_MODULE_4__/* .TextInput */ .o, {
                    label: "Old price",
                    type: "currency",
                    value: product.oldPrice ?? "",
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().textField),
                    onChange: (e)=>{
                        const val = e.target.value;
                        handleChange("oldPrice", val ? val : null);
                    }
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 12,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().imageBlock),
                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_GalleryInput_GalleryInput__WEBPACK_IMPORTED_MODULE_1__/* .GalleryPicker */ .K, {
                        classes: {
                            imageInput: {
                                root: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().imageItem)
                            }
                        },
                        label: "Gallery",
                        images: (product?.images ?? []).map((src)=>({
                                src
                            })),
                        onChange: (val)=>handleChange("images", val.map((s)=>s.src))
                    })
                })
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 12,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                    className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().descriptionEditor),
                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                        style: {
                            minHeight: "300px"
                        },
                        id: editorId
                    })
                })
            }),
            props.isProductVariant && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_10__.Grid, {
                item: true,
                xs: 12,
                sm: 12,
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_helpers_customFields__WEBPACK_IMPORTED_MODULE_6__/* .RenderCustomFields */ ._i, {
                    entityType: _cromwell_core__WEBPACK_IMPORTED_MODULE_5__.EDBEntity.ProductVariant,
                    entityData: product,
                    refetchMeta: async ()=>product.customMeta,
                    onChange: onMetaChange,
                    onDidMount: ()=>setTimeout(()=>canUpdateMeta.current = true, 10)
                })
            })
        ]
    });
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MainInfoCard);

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 3471:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "J": () => (/* binding */ PageContent)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _components_entity_entityEdit_components_EntityCustomFields__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7796);
/* harmony import */ var _components_entity_entityEdit_components_EntityMetaFields__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4290);
/* harmony import */ var _components_inputs_Search_SearchInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9376);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4536);
/* harmony import */ var _helpers_forceUpdate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8673);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9103);
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(query_string__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4661);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _constants_PageInfos__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(379);
/* harmony import */ var _contexts_Product__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(6392);
/* harmony import */ var _hooks_useTabs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3739);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(1108);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_Product_module_scss__WEBPACK_IMPORTED_MODULE_16__);
/* harmony import */ var _AttributesTab__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(1316);
/* harmony import */ var _MainInfoCard__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(8313);
/* harmony import */ var _VariantsTab__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(6832);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_entity_entityEdit_components_EntityCustomFields__WEBPACK_IMPORTED_MODULE_1__, _components_entity_entityEdit_components_EntityMetaFields__WEBPACK_IMPORTED_MODULE_2__, _components_inputs_Search_SearchInput__WEBPACK_IMPORTED_MODULE_3__, _MainInfoCard__WEBPACK_IMPORTED_MODULE_14__, _VariantsTab__WEBPACK_IMPORTED_MODULE_15__]);
([_components_entity_entityEdit_components_EntityCustomFields__WEBPACK_IMPORTED_MODULE_1__, _components_entity_entityEdit_components_EntityMetaFields__WEBPACK_IMPORTED_MODULE_2__, _components_inputs_Search_SearchInput__WEBPACK_IMPORTED_MODULE_3__, _MainInfoCard__WEBPACK_IMPORTED_MODULE_14__, _VariantsTab__WEBPACK_IMPORTED_MODULE_15__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);

















const PageContent = ({ entityData , canValidate  })=>{
    const client = (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_4__.getGraphQLClient)();
    const location = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_9__.useLocation)();
    const productRef = react__WEBPACK_IMPORTED_MODULE_8___default().useRef(entityData);
    const context = (0,react__WEBPACK_IMPORTED_MODULE_8__.useContext)(_contexts_Product__WEBPACK_IMPORTED_MODULE_11__/* .ProductContext */ .H);
    const [mainCategory, setMainCategory] = (0,react__WEBPACK_IMPORTED_MODULE_8__.useState)(null);
    const [activeTabNum, changeTab] = (0,_hooks_useTabs__WEBPACK_IMPORTED_MODULE_12__/* .useTabs */ .Y)();
    const [attributes, setAttributes] = (0,react__WEBPACK_IMPORTED_MODULE_8__.useState)([]);
    const [usedVariantAttributes, setUsedVariantAttributes] = (0,react__WEBPACK_IMPORTED_MODULE_8__.useState)(entityData?.variants?.reduce((prev, curr)=>{
        Object.entries(curr.attributes ?? {}).forEach(([key])=>{
            if (key && !prev.includes(key)) prev.push(key);
        });
        return prev;
    }, []) || []);
    const forceUpdate = (0,_helpers_forceUpdate__WEBPACK_IMPORTED_MODULE_5__/* .useForceUpdate */ .N)();
    if (!context.store.productRef.data && productRef.current) {
        context.store.productRef.data = productRef.current;
    }
    const setProdData = (data)=>{
        productRef.current = Object.assign({}, productRef.current, data);
        context.store.productRef.data = productRef.current;
    };
    const handleSearchCategory = async (text, params)=>{
        return client.getProductCategories({
            filterParams: {
                nameSearch: text
            },
            pagedParams: params
        });
    };
    const handleChangeCategories = (data)=>{
        if (!data?.length) setProdData({
            categories: null
        });
        else setProdData({
            categories: data
        });
    };
    const handleMainCategoryChange = (data)=>{
        if (productRef.current?.mainCategoryId === data?.id) return;
        setProdData({
            mainCategoryId: data?.id || null
        });
    };
    (0,react__WEBPACK_IMPORTED_MODULE_8__.useEffect)(()=>{
        getMainCategory();
        getAttributes();
    }, []);
    (0,react__WEBPACK_IMPORTED_MODULE_8__.useEffect)(()=>{
        const parsed = query_string__WEBPACK_IMPORTED_MODULE_7___default().parse(location.search);
        if (location.pathname.startsWith(_constants_PageInfos__WEBPACK_IMPORTED_MODULE_10__/* .productPageInfo.baseRoute */ .On.baseRoute + "/")) changeTab(Number(parsed.tab ?? "0"));
    }, [
        location
    ]);
    const getMainCategory = async ()=>{
        if (productRef.current?.mainCategoryId) {
            try {
                const main = await client.getProductCategoryById(productRef.current?.mainCategoryId);
                if (main) {
                    setMainCategory(main);
                }
            } catch (e) {
                console.error(e);
            }
        }
    };
    const getAttributes = async ()=>{
        try {
            const attr = await client?.getAttributes({
                pagedParams: {
                    pageSize: 1000
                }
            });
            if (attr?.elements) setAttributes(attr.elements);
        } catch (e) {
            console.error(e);
        }
    };
    if (!productRef.current) return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Box, {
        className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_16___default().PageContent),
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h1", {
            children: "Product not found"
        })
    });
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Box, {
        className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_16___default().PageContent),
        children: [
            activeTabNum === 0 && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Box, {
                sx: {
                    padding: "20px",
                    borderRadius: "10px"
                },
                className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_16___default().paper),
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_MainInfoCard__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .Z, {
                        product: productRef.current,
                        setProdData: setProdData,
                        canValidate: canValidate
                    }),
                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Grid, {
                        container: true,
                        spacing: 3,
                        sx: {
                            mt: "15px"
                        },
                        children: [
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Grid, {
                                item: true,
                                xs: 12,
                                sm: 12,
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_Search_SearchInput__WEBPACK_IMPORTED_MODULE_3__/* .SearchInput */ .M, {
                                    multiple: true,
                                    loader: handleSearchCategory,
                                    onSelect: handleChangeCategories,
                                    getOptionLabel: (data)=>`${data.name} (id: ${data.id}${data?.parent?.id ? `; parent id: ${data.parent.id}` : ""})`,
                                    getOptionValue: (data)=>data.name || "",
                                    fullWidth: true,
                                    defaultValue: productRef.current.categories ?? [],
                                    label: "Categories"
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_6__.Grid, {
                                item: true,
                                xs: 12,
                                sm: 12,
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_Search_SearchInput__WEBPACK_IMPORTED_MODULE_3__/* .SearchInput */ .M, {
                                    loader: handleSearchCategory,
                                    onSelect: handleMainCategoryChange,
                                    getOptionLabel: (data)=>`${data.name} (id: ${data.id}${data?.parent?.id ? `; parent id: ${data.parent.id}` : ""})`,
                                    getOptionValue: (data)=>data.name || "",
                                    fullWidth: true,
                                    defaultValue: mainCategory,
                                    label: "Main category"
                                })
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_entity_entityEdit_components_EntityMetaFields__WEBPACK_IMPORTED_MODULE_2__/* .EntityMetaFields */ .Q, {}),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_entity_entityEdit_components_EntityCustomFields__WEBPACK_IMPORTED_MODULE_1__/* .EntityCustomFields */ .O, {})
                        ]
                    })
                ]
            }),
            activeTabNum === 1 && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_AttributesTab__WEBPACK_IMPORTED_MODULE_13__/* .AttributesTab */ .t, {
                    forceUpdate: forceUpdate,
                    product: productRef.current,
                    setProdData: setProdData,
                    attributes: attributes
                })
            }),
            activeTabNum === 2 && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_VariantsTab__WEBPACK_IMPORTED_MODULE_15__/* .VariantsTab */ .O, {
                    forceUpdate: forceUpdate,
                    product: productRef.current,
                    setProdData: setProdData,
                    attributes: attributes,
                    usedVariantAttributes: usedVariantAttributes,
                    setUsedVariantAttributes: setUsedVariantAttributes
                })
            })
        ]
    });
};

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 6832:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "O": () => (/* binding */ VariantsTab)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _cromwell_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1815);
/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2135);
/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8802);
/* harmony import */ var _heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var rfdc__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7990);
/* harmony import */ var rfdc__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(rfdc__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _components_buttons_IconButton__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4137);
/* harmony import */ var _components_buttons_TextButton__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2789);
/* harmony import */ var _components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(6672);
/* harmony import */ var _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1239);
/* harmony import */ var _components_modal_Confirmation__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1571);
/* harmony import */ var _styles_common_module_scss__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(1490);
/* harmony import */ var _styles_common_module_scss__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_styles_common_module_scss__WEBPACK_IMPORTED_MODULE_14__);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(1108);
/* harmony import */ var _Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_Product_module_scss__WEBPACK_IMPORTED_MODULE_13__);
/* harmony import */ var _MainInfoCard__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(8313);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_9__, _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_10__, _MainInfoCard__WEBPACK_IMPORTED_MODULE_12__]);
([_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_9__, _components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_10__, _MainInfoCard__WEBPACK_IMPORTED_MODULE_12__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);















function VariantsTab({ product , setProdData , forceUpdate , usedVariantAttributes =[] , attributes , setUsedVariantAttributes  }) {
    const [expandedVariants, setExpandedVariants] = (0,react__WEBPACK_IMPORTED_MODULE_5__.useState)({});
    const [isEditingAttributes, setIsEditingAttributes] = (0,react__WEBPACK_IMPORTED_MODULE_5__.useState)(false);
    const [popperAnchorEl, setPopperAnchorEl] = react__WEBPACK_IMPORTED_MODULE_5___default().useState(null);
    if (product.variants?.length) {
        for (const variant of product.variants){
            if (!variant.id) variant.id = (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_1__.getRandStr)(8);
        }
    }
    const handleAddProductVariant = ()=>{
        setProdData({
            ...product,
            variants: [
                ...product?.variants ?? [],
                {
                    id: (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_1__.getRandStr)(8)
                }
            ]
        });
        forceUpdate();
    };
    const expandVariant = (id)=>{
        setExpandedVariants({
            [id]: !expandedVariants[id]
        });
        setTimeout(()=>{
            document.getElementById(`variant-${id}`)?.scrollIntoView();
            const getScrollParent = (node)=>{
                if (!node) return;
                if (node.scrollHeight > node.clientHeight) {
                    return node;
                } else {
                    return getScrollParent(node.parentNode);
                }
            };
            const scrollParent = getScrollParent(document.getElementById("product-variants-tab"));
            if (scrollParent) scrollParent.scrollTop = scrollParent.scrollTop - 90;
        }, 10);
    };
    const handleDeleteVariant = async (variant)=>{
        if (!await (0,_components_modal_Confirmation__WEBPACK_IMPORTED_MODULE_11__/* .askConfirmation */ .UB)({
            title: "Delete variant?"
        })) return;
        const newProduct = rfdc__WEBPACK_IMPORTED_MODULE_6___default()({
            proto: true
        })(product);
        newProduct.variants = newProduct.variants?.filter((v)=>variant.id !== v.id) || [];
        setProdData(newProduct);
        forceUpdate();
    };
    const onAttributeChange = (variant, attribute, value)=>{
        const newProduct = rfdc__WEBPACK_IMPORTED_MODULE_6___default()({
            proto: true
        })(product);
        if (!attribute.key) return;
        newProduct.variants = newProduct.variants?.map((v)=>{
            if (v.id === variant.id) {
                v.attributes = {
                    ...v.attributes ?? {},
                    [attribute.key]: value
                };
            }
            return v;
        }) || [];
        setProdData(newProduct);
        forceUpdate();
    };
    const handleEditAttributes = (event)=>{
        setPopperAnchorEl(event.currentTarget);
        setIsEditingAttributes(!isEditingAttributes);
    };
    const onUsedAttributeChange = (key)=>{
        const used = !!usedVariantAttributes.includes(key);
        if (!used) setUsedVariantAttributes([
            key,
            ...usedVariantAttributes
        ]);
        else {
            setUsedVariantAttributes(usedVariantAttributes.filter((a)=>a !== key));
            const newProduct = rfdc__WEBPACK_IMPORTED_MODULE_6___default()({
                proto: true
            })(product);
            if (!newProduct.variants) newProduct.variants = [];
            newProduct.variants = newProduct.variants.map((v)=>{
                if (v.attributes) delete v.attributes[key];
                return v;
            });
            setProdData(newProduct);
            forceUpdate();
        }
    };
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
        id: "product-variants-tab",
        sx: {
            width: "100%"
        },
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                sx: {
                    width: "100%"
                },
                children: product?.variants?.map((variant)=>/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                        id: `variant-${variant.id}`,
                        className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().paper),
                        sx: {
                            mb: 4,
                            width: "100%"
                        },
                        children: [
                            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                                sx: {
                                    display: "flex",
                                    justifyContent: "space-between",
                                    alignItems: "center",
                                    px: 1,
                                    borderBottom: expandedVariants[variant.id] ? "2px dashed #ddd" : undefined,
                                    minHeight: "50px"
                                },
                                children: [
                                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                                        sx: {
                                            display: "flex",
                                            alignItems: "center",
                                            px: 1
                                        },
                                        flexWrap: "wrap",
                                        justifyContent: "space-between",
                                        children: attributes?.filter((attr)=>attr.key && usedVariantAttributes.includes(attr.key))?.map((attr)=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_SelectInput__WEBPACK_IMPORTED_MODULE_9__/* .SelectInput */ .l, {
                                                label: attr.key,
                                                options: [
                                                    ...attr.values?.map((value)=>({
                                                            label: value.value,
                                                            value: value.value
                                                        })) ?? [],
                                                    {
                                                        label: "any",
                                                        value: "any"
                                                    }
                                                ],
                                                value: variant.attributes?.[attr.key] ?? "any",
                                                style: {
                                                    margin: "10px 15px 10px 0",
                                                    minWidth: "100px"
                                                },
                                                onChange: (value)=>onAttributeChange(variant, attr, value)
                                            }, attr.key))
                                    }),
                                    /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                                        children: [
                                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_buttons_IconButton__WEBPACK_IMPORTED_MODULE_7__/* .IconButton */ .h, {
                                                onClick: ()=>expandVariant(variant.id),
                                                "aria-label": "show more",
                                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.PencilIcon, {
                                                    className: "w-5 h-5"
                                                })
                                            }),
                                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_buttons_IconButton__WEBPACK_IMPORTED_MODULE_7__/* .IconButton */ .h, {
                                                onClick: ()=>handleDeleteVariant(variant),
                                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.TrashIcon, {
                                                    className: "w-5 h-5"
                                                })
                                            })
                                        ]
                                    })
                                ]
                            }),
                            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Collapse, {
                                in: expandedVariants[variant.id],
                                timeout: 0,
                                unmountOnExit: true,
                                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                                    sx: {
                                        my: 1,
                                        p: 2
                                    },
                                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_MainInfoCard__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .Z, {
                                        product: variant,
                                        setProdData: (data)=>{
                                            const newProduct = rfdc__WEBPACK_IMPORTED_MODULE_6___default()({
                                                proto: true
                                            })(product);
                                            if (!newProduct.variants) newProduct.variants = [];
                                            newProduct.variants = newProduct.variants.map((v)=>{
                                                if (v.id === variant.id) {
                                                    return {
                                                        ...data
                                                    };
                                                }
                                                return v;
                                            });
                                            setProdData(newProduct);
                                        },
                                        isProductVariant: true
                                    })
                                })
                            })
                        ]
                    }, variant.id))
            }),
            !usedVariantAttributes?.length && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                sx: {
                    display: "flex",
                    justifyContent: "center",
                    p: "40px 0"
                },
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_solid__WEBPACK_IMPORTED_MODULE_3__.InformationCircleIcon, {
                        className: "w-6 h-6 fill-blue-500 mr-2"
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Typography, {
                        children: "Assign some attributes first to create new variants"
                    })
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                sx: {
                    width: "100%",
                    my: 4,
                    display: "flex"
                },
                children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Box, {
                    sx: {
                        mx: "auto",
                        display: "flex"
                    },
                    children: [
                        /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_components_buttons_TextButton__WEBPACK_IMPORTED_MODULE_8__/* .TextButton */ .A, {
                            style: {
                                marginRight: "15px"
                            },
                            onClick: handleAddProductVariant,
                            disabled: !usedVariantAttributes?.length,
                            children: [
                                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.PlusIcon, {
                                    className: "w-5 h-5 mr-1"
                                }),
                                "Add product variant"
                            ]
                        }),
                        /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_components_buttons_TextButton__WEBPACK_IMPORTED_MODULE_8__/* .TextButton */ .A, {
                            onClick: handleEditAttributes,
                            children: [
                                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.CogIcon, {
                                    className: "w-5 h-5 mr-1"
                                }),
                                "Edit attributes"
                            ]
                        }),
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_4__.Popover, {
                            open: isEditingAttributes,
                            anchorEl: popperAnchorEl,
                            classes: {
                                paper: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().popoverPaper)
                            },
                            elevation: 0,
                            onClose: handleEditAttributes,
                            anchorOrigin: {
                                vertical: "bottom",
                                horizontal: "left"
                            },
                            children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                className: (_Product_module_scss__WEBPACK_IMPORTED_MODULE_13___default().newAttributesList),
                                children: attributes?.map((attr)=>{
                                    if (!attr.key) return null;
                                    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                        style: {
                                            display: "flex",
                                            alignItems: "center",
                                            justifyContent: "space-between",
                                            width: "100%",
                                            minWidth: "20px",
                                            padding: "10px 15px"
                                        },
                                        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                                            className: (_styles_common_module_scss__WEBPACK_IMPORTED_MODULE_14___default().center),
                                            children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_inputs_SwitchInput__WEBPACK_IMPORTED_MODULE_10__/* .SwitchInput */ .D, {
                                                value: !!usedVariantAttributes.includes(attr.key),
                                                onChange: ()=>onUsedAttributeChange(attr.key),
                                                label: attr.key
                                            })
                                        })
                                    }, attr.key);
                                })
                            })
                        })
                    ]
                })
            })
        ]
    });
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

/***/ 6392:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "H": () => (/* binding */ ProductContext)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);

const ProductContext = react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});


/***/ }),

/***/ 3739:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Y": () => (/* binding */ useTabs)
/* harmony export */ });
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9103);
/* harmony import */ var query_string__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(query_string__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4661);
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _contexts_Product__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6392);




function useTabs(init) {
    const navigate = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useNavigate)();
    const location = (0,react_router_dom__WEBPACK_IMPORTED_MODULE_2__.useLocation)();
    const context = (0,react__WEBPACK_IMPORTED_MODULE_1__.useContext)(_contexts_Product__WEBPACK_IMPORTED_MODULE_3__/* .ProductContext */ .H);
    const setStore = init?.setStore ?? context.setStore ?? (()=>{});
    const store = init?.store ?? context.store;
    const changeTab = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)((value)=>{
        if (value == store.tab || !value && !store.tab) return;
        setStore({
            ...store,
            tab: value
        });
        if (store.productRef?.data?.id) {
            const parsed = query_string__WEBPACK_IMPORTED_MODULE_0___default().parse(window.location.search);
            if (value != parsed.tab) {
                parsed.tab = value;
                if (!value || value == "0") delete parsed.tab;
                navigate(`${location.pathname}?${query_string__WEBPACK_IMPORTED_MODULE_0___default().stringify(parsed)}`);
            }
        }
    }, [
        store
    ]);
    return [
        store.tab,
        changeTab
    ];
}


/***/ })

};
;