{"version":3,"file":"scrollbar-khuBHtuT.js","sources":["../../../app/frontend/entrypoints/marketing/bootstrap/mdb-prefix/util/scrollbar.js"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * Bootstrap (v5.1.3): util/scrollBar.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nimport SelectorEngine from '../dom/selector-engine';\nimport Manipulator from '../dom/manipulator';\nimport { isElement } from './index';\n\nconst SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';\nconst SELECTOR_STICKY_CONTENT = '.sticky-top';\n\nclass ScrollBarHelper {\n constructor() {\n this._element = document.body;\n }\n\n getWidth() {\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes\n const documentWidth = document.documentElement.clientWidth;\n return Math.abs(window.innerWidth - documentWidth);\n }\n\n hide() {\n const width = this.getWidth();\n this._disableOverFlow();\n // give padding to element to balance the hidden scrollbar width\n this._setElementAttributes(\n this._element,\n 'paddingRight',\n (calculatedValue) => calculatedValue + width\n );\n // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth\n this._setElementAttributes(\n SELECTOR_FIXED_CONTENT,\n 'paddingRight',\n (calculatedValue) => calculatedValue + width\n );\n this._setElementAttributes(\n SELECTOR_STICKY_CONTENT,\n 'marginRight',\n (calculatedValue) => calculatedValue - width\n );\n }\n\n _disableOverFlow() {\n this._saveInitialAttribute(this._element, 'overflow');\n this._element.style.overflow = 'hidden';\n }\n\n _setElementAttributes(selector, styleProp, callback) {\n const scrollbarWidth = this.getWidth();\n const manipulationCallBack = (element) => {\n if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {\n return;\n }\n\n this._saveInitialAttribute(element, styleProp);\n const calculatedValue = window.getComputedStyle(element)[styleProp];\n element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;\n };\n\n this._applyManipulationCallback(selector, manipulationCallBack);\n }\n\n reset() {\n this._resetElementAttributes(this._element, 'overflow');\n this._resetElementAttributes(this._element, 'paddingRight');\n this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');\n this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');\n }\n\n _saveInitialAttribute(element, styleProp) {\n const actualValue = element.style[styleProp];\n if (actualValue) {\n Manipulator.setDataAttribute(element, styleProp, actualValue);\n }\n }\n\n _resetElementAttributes(selector, styleProp) {\n const manipulationCallBack = (element) => {\n const value = Manipulator.getDataAttribute(element, styleProp);\n if (typeof value === 'undefined') {\n element.style.removeProperty(styleProp);\n } else {\n Manipulator.removeDataAttribute(element, styleProp);\n element.style[styleProp] = value;\n }\n };\n\n this._applyManipulationCallback(selector, manipulationCallBack);\n }\n\n _applyManipulationCallback(selector, callBack) {\n if (isElement(selector)) {\n callBack(selector);\n } else {\n SelectorEngine.find(selector, this._element).forEach(callBack);\n }\n }\n\n isOverflowing() {\n return this.getWidth() > 0;\n }\n}\n\nexport default ScrollBarHelper;\n"],"names":["SELECTOR_FIXED_CONTENT","SELECTOR_STICKY_CONTENT","ScrollBarHelper","documentWidth","width","calculatedValue","selector","styleProp","callback","scrollbarWidth","manipulationCallBack","element","actualValue","Manipulator","value","callBack","isElement","SelectorEngine"],"mappings":"wIAWA,MAAMA,EAAyB,oDACzBC,EAA0B,cAEhC,MAAMC,CAAgB,CACpB,aAAc,CACZ,KAAK,SAAW,SAAS,IAC1B,CAED,UAAW,CAET,MAAMC,EAAgB,SAAS,gBAAgB,YAC/C,OAAO,KAAK,IAAI,OAAO,WAAaA,CAAa,CAClD,CAED,MAAO,CACL,MAAMC,EAAQ,KAAK,WACnB,KAAK,iBAAgB,EAErB,KAAK,sBACH,KAAK,SACL,eACCC,GAAoBA,EAAkBD,CAC7C,EAEI,KAAK,sBACHJ,EACA,eACCK,GAAoBA,EAAkBD,CAC7C,EACI,KAAK,sBACHH,EACA,cACCI,GAAoBA,EAAkBD,CAC7C,CACG,CAED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