{"version":3,"file":"product-card.js","sources":["../../../../../Flow.Showcase.Static.Bundler/Root/entrypoints/product-card.ts"],"sourcesContent":["// @ts-nocheck\n\nimport eventBus from \"../modules/event-bus.module.ts\";\nimport { showPopup } from \"../modules/popup.module.ts\";\nimport { commonState } from \"../modules/common-state.module.ts\";\n\n// Изменение стилей карточки после измениния количества товара\neventBus.subscribe('cart-changed', ({ variantId, quantity }) => {\n const addToCartButton = document.querySelectorAll(`[data-catalog-product-card] [data-add-to-cart-btn][data-variant-id=\"${variantId}\"]`);\n const counter = document.querySelectorAll(`[data-catalog-product-card] [data-counter][data-variant-id=\"${variantId}\"]`);\n if (quantity > 0) {\n if (addToCartButton) {\n addToCartButton.forEach(e => e.classList.add('display-none'));\n }\n if (counter) {\n counter.forEach(e => e.classList.remove('display-none'));\n }\n } else {\n if (addToCartButton) {\n addToCartButton.forEach(e => e.classList.remove('display-none'));\n }\n if (counter) {\n counter.forEach(e => e.classList.add('display-none'));\n }\n }\n})\n\n// При нажатии на кнопку Добавить, спрятать эту кнопку и показать счетчик\nconst productCards = document.querySelectorAll('[data-catalog-product-card]');\nproductCards.forEach(productCard => {\n const addButton = productCard.querySelector('[data-add-btn]');\n const counter = productCard.querySelector('[data-counter]');\n\n if (addButton) {\n addButton.addEventListener(\"click\", () => {\n addButton.classList.add('display-none');\n if (counter) {\n counter.classList.remove('display-none');\n }\n });\n }\n});\n\n// Показать уведомление, если товар добавлен в корзину\neventBus.subscribe(\"cart-changed\", ({ quantity, quantityPrev }) => {\n if (quantity > quantityPrev) {\n showPopup(commonState.translations[\"Product added to cart\"], 3000);\n }\n})\n"],"names":["eventBus","variantId","quantity","addToCartButton","counter","e","productCards","productCard","addButton","quantityPrev","showPopup","commonState"],"mappings":"gLAOAA,EAAS,UAAU,eAAgB,CAAC,CAAE,UAAAC,EAAW,SAAAC,KAAe,CAC5D,MAAMC,EAAkB,SAAS,iBAAiB,uEAAuEF,CAAS,IAAI,EAChIG,EAAU,SAAS,iBAAiB,+DAA+DH,CAAS,IAAI,EAClHC,EAAW,GACPC,GACAA,EAAgB,QAAaE,GAAAA,EAAE,UAAU,IAAI,cAAc,CAAC,EAE5DD,GACAA,EAAQ,QAAaC,GAAAA,EAAE,UAAU,OAAO,cAAc,CAAC,IAGvDF,GACAA,EAAgB,QAAaE,GAAAA,EAAE,UAAU,OAAO,cAAc,CAAC,EAE/DD,GACAA,EAAQ,QAAaC,GAAAA,EAAE,UAAU,IAAI,cAAc,CAAC,EAGhE,CAAC,EAGD,MAAMC,EAAe,SAAS,iBAAiB,6BAA6B,EAC5EA,EAAa,QAAuBC,GAAA,CAC1B,MAAAC,EAAYD,EAAY,cAAc,gBAAgB,EACtDH,EAAUG,EAAY,cAAc,gBAAgB,EAEtDC,GACUA,EAAA,iBAAiB,QAAS,IAAM,CAC5BA,EAAA,UAAU,IAAI,cAAc,EAClCJ,GACQA,EAAA,UAAU,OAAO,cAAc,CAC3C,CACH,CAET,CAAC,EAGDJ,EAAS,UAAU,eAAgB,CAAC,CAAE,SAAAE,EAAU,aAAAO,KAAmB,CAC3DP,EAAWO,GACXC,EAAUC,EAAY,aAAa,uBAAuB,EAAG,GAAI,CAEzE,CAAC"}