{"version":3,"file":"index-legacy.DgoGwVIu.js","sources":["../../../packages/global-b3/index.ts","../src/load-functions.ts","../src/main.ts"],"sourcesContent":["/**\n * B3Local will be removed soon, this is just to TS warns you if you add more variables to it\n */\nexport interface B3Local {\n setting: {\n b2b_url: string\n b2b_socket_url: string\n captcha_setkey: string\n }\n 'dom.checkoutRegisterParentElement': '#b2bParent'\n 'dom.openB3Checkout': 'childB2b'\n 'dom.navUserLoginElement': '#headless-container'\n before_login_goto_page: '/'\n}\ninterface ThemeElementsProps {\n [key: string]: string\n}\n\nconst themeOtherElementConfig = () => {\n const originElement =\n '[href^=\"/account.php\"], [href^=\"/account.php\"] .navUser-item-accountLabel, [href^=\"/account.php?action=address_book\"], [href^=\"/account.php?action=order_status\"], [href^=\"/account.php?action=account_details\"], [href=\"/login.php\"], [href=\"/login.php?action=create_account\"]'\n let allOtherElement = originElement\n // Deadline: September 05, 2023--[Theme Camden and theme RightRope] and [Theme LifeStyle and theme Vault] require the same configuration, so only one is required\n // Camden: '[href=\"/account.php\"] svg, [href=\"/account.php\"] svg use, [href=\"/account.php\"] span, [href=\"/account.php\"], [href=\"/login.php\"] span, [href=\"/login.php\"] svg use, [href=\"/login.php\"] svg, [href=\"/login.php\"]'\n // Vault: '.navUser-item--account a, .navUser-item--account a svg',\n // Fortune: '[href=\"/login.php?action=create_account\"]',\n // Pinnacle: Theme Pinnacle and NextGen are compatible with the theme LifeStyle;; Artisan、CoventGarden、 Artify: method compatible\n const themeElements: ThemeElementsProps = {\n Hera: '[href^=\"/account.php\"] span, .account-item .account-action span svg, .account-item .account-action span svg use, [href^=\"/login.php?action=logout\"], [href=\"/login.php\"] .icon, .account-item .account-action span',\n RightRope:\n '[href=\"/account.php\"] svg, [href=\"/account.php\"] svg use, [href=\"/account.php\"] span, [href=\"/account.php\"], [href=\"/login.php\"] span, [href=\"/login.php\"] svg use, [href=\"/login.php\"] svg, [href=\"/login.php\"]',\n SuperMarket: '[href=\"/login.php\"] span, [href=\"/account.php\"] span',\n LifeStyle:\n '.navUser-item--account a, .navUser-item--account a svg, .navUser-section-sub .navUser-item .needsclick, .navUser-section-sub .navUser-item .needsclick svg, .navUser-section-sub .navUser-item .needsclick span, .navUser-section-sub .navUser-item a, .navUser-section-sub .navUser-item a svg, .navUser-section-sub .navUser-item a svg use, .navUser-section-sub .navUser-item a span',\n Chiara:\n '.navUser-item--more, #navUser-more-toggle, #navUser-more-toggle .navUser-item-icon, #navUser-more-toggle .navUser-item-icon svg, #navUser-more-toggle .navUser-item-icon svg use, #navUser-more-toggle .navUser-item-moreLabel, .header-top-item--login, .header-top-item--login .header-top-action, .header-top-item--logout, .header-top-item--logout [href^=\"/login.php?action=logout\"]',\n HaloOne:\n '[href^=\"/account.php\"] svg, [href^=\"/account.php\"] svg path, [href=\"/login.php\"] svg path',\n FinchUS: '[href^=\"/account.php\"] img',\n Beautify: '[href^=\"/account.php\"] .new-icon-account',\n }\n\n Object.values(themeElements).forEach((value) => {\n allOtherElement = allOtherElement.concat(value, ',')\n })\n allOtherElement = allOtherElement.slice(0, -1)\n\n return {\n 'dom.allOtherElement': `${allOtherElement}`,\n }\n}\n\nconst globalB3 = {\n 'dom.registerElement':\n '[href^=\"/login.php\"], #checkout-customer-login, [href=\"/login.php\"] .navUser-item-loginLabel, #checkout-customer-returning .form-legend-container [href=\"#\"]',\n 'dom.registerUrl': '/register',\n 'dom.checkoutRegisterParentElement': '#checkout-app',\n 'dom.navUserLoginElement': '.navUser-item.navUser-item--account',\n 'dom.setToQuote': '#form-action-addToCart',\n 'dom.setToShoppingListParentEl': '#add-to-cart-wrapper',\n 'dom.setToNoPuchasable': '#add-to-cart-wrapper',\n 'dom.cartActions.container': '.cart-actions',\n 'dom.openB3Checkout': 'checkout-customer-continue',\n 'dom.cart':\n '[href=\"/cart.php\"], #form-action-addToCart, [data-button-type=\"add-cart\"], [data-emthemesmodez-cart-item-add]',\n 'dom.productView': '.productView',\n 'dom.register': '[href^=\"/login.php?action=create_account\"]',\n 'dom.hideThemePayments':\n '.cart-additionalCheckoutButtons, .previewCart-additionalCheckoutButtons, .previewCartCheckout-additionalCheckoutButtons, [data-content-region=\"cart_below_totals\"], .add-to-cart-wallet-buttons, [data-content-region=\"product_below_price\"]',\n before_login_goto_page: '/account.php?action=order_status',\n checkout_super_clear_session: 'true',\n ...themeOtherElementConfig(),\n ...window.B3Local,\n setting: {\n b2b_url: 'https://api-b2b.staging.zone',\n b2b_socket_url: 'https://api-b2b.staging.zone',\n ...window.B3Local?.setting,\n },\n}\n\nexport default globalB3\n","import globalB3 from '@b3/global-b3';\n\nexport const requestIdleCallbackFunction: typeof window.requestIdleCallback =\n window.requestIdleCallback\n ? window.requestIdleCallback\n : (cb: IdleRequestCallback) => {\n const start = Date.now();\n return window.setTimeout(() => {\n cb({\n didTimeout: false,\n timeRemaining() {\n return Math.max(0, 50 - (Date.now() - start));\n },\n });\n }, 1);\n };\n\nexport class InitializationEnvironment {\n clickedLinkElement?: HTMLElement;\n\n #isInitVariable = false;\n\n isInitListener?: () => void;\n\n set isInit(value: boolean) {\n this.#isInitVariable = value;\n this.isInitListener?.();\n }\n\n get isInit() {\n return this.#isInitVariable;\n }\n}\n\nwindow.b2b = {\n ...window.b2b,\n initializationEnvironment: new InitializationEnvironment(),\n};\n\nexport const initApp = async () => {\n if (window.b2b.initializationEnvironment.isInit) return;\n\n await import('./react-setup');\n};\n\nconst clickLink = async (e: MouseEvent) => {\n window.b2b.initializationEnvironment.clickedLinkElement = e.target as HTMLElement;\n e.preventDefault();\n e.stopPropagation();\n await initApp();\n};\n\nexport const bindLinks = () => {\n const links: NodeListOf = document.querySelectorAll(\n `${globalB3['dom.registerElement']}, ${globalB3['dom.allOtherElement']}`,\n );\n\n links.forEach((accessLink) => accessLink.addEventListener('click', clickLink));\n};\nexport const unbindLinks = () => {\n const links: NodeListOf = document.querySelectorAll(\n `${globalB3['dom.registerElement']}, ${globalB3['dom.allOtherElement']}`,\n );\n\n links.forEach((accessLink) => accessLink.removeEventListener('click', clickLink));\n};\n","import { bindLinks, initApp, requestIdleCallbackFunction, unbindLinks } from './load-functions';\n\n// check if the accesed url contains a hashtag\nif (window.location.hash.startsWith('#/')) {\n initApp();\n} else {\n // load the app when the browser is free\n requestIdleCallbackFunction(initApp);\n // and bind links to load the app\n bindLinks();\n window.addEventListener('beforeunload', unbindLinks);\n // and observe global flag to simulate click\n window.b2b.initializationEnvironment.isInitListener = () => {\n unbindLinks();\n setTimeout(() => window.b2b.initializationEnvironment.clickedLinkElement?.click(), 0);\n };\n}\n"],"names":["globalB3","exports","before_login_goto_page","checkout_super_clear_session","themeOtherElementConfig","allOtherElement","Object","values","Hera","RightRope","SuperMarket","LifeStyle","Chiara","HaloOne","FinchUS","Beautify","forEach","value","concat","slice","window","B3Local","setting","b2b_url","b2b_socket_url","requestIdleCallbackFunction","requestIdleCallback","cb","start","Date","now","setTimeout","didTimeout","timeRemaining","Math","max","b2b","initializationEnvironment","clickedLinkElement","isInitVariable","isInitListener","isInit","this","initApp","async","__vitePreload","module","import","clickLink","e","target","preventDefault","stopPropagation","unbindLinks","document","querySelectorAll","accessLink","removeEventListener","location","hash","startsWith","addEventListener","click"],"mappings":"oSAoDMA,EAAWC,EAAA,IAAA,CACf,sBACE,+JACF,kBAAmB,YACnB,oCAAqC,gBACrC,0BAA2B,sCAC3B,iBAAkB,yBAClB,gCAAiC,uBACjC,wBAAyB,uBACzB,4BAA6B,gBAC7B,qBAAsB,6BACtB,WACE,gHACF,kBAAmB,eACnB,eAAgB,6CAChB,wBACE,+OACFC,uBAAwB,mCACxBC,6BAA8B,UApDAC,MAG9B,IAAIC,EADF,oRA2BK,OALPC,OAAOC,OAfmC,CACxCC,KAAM,qNACNC,UACE,mNACFC,YAAa,uDACbC,UACE,2XACFC,OACE,6XACFC,QACE,4FACFC,QAAS,6BACTC,SAAU,6CAGiBC,SAASC,IAClBZ,EAAAA,EAAgBa,OAAOD,EAAO,IAAG,IAEnCZ,EAAAA,EAAgBc,MAAM,GAAK,GAEtC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