{"version":3,"sources":["embla-carousel-auto-height.js"],"names":["defaultOptions","active","breakpoints","destroyHeight","heightEvents","optionsHandler","EmblaCarousel","inViewThreshold","carousel","optionsBase","merge","options","EmblaAutoHeight","globalOptions","setContainerHeight","evt","module","exports","concat","slidesInView","_a","internalEngine","target","containerNode","height","get","slideBounds","map","index","self","slideHeights","name","init","max","a","b","destroy","window","userOptions","slideRects","atMedia","axis","rect","findSlideBounds","undefined","forEach","on","inViewIndexes","off"],"mappings":"AAAA,CAAA,WACE,aAEA,IAAIA,EAAiB,CACnBC,OAAQ,CAAA,EACRC,YAAa,GACbC,cAAe,OACfC,aAAc,CAAC,SAAU,YAC3B,EAEA,SACMC,EAAiBC,GACrB,IAQIC,EAEJC,EAVIC,EAAcJ,cAAeK,eAC/BV,EAGEW,EAAON,EAAAK,MACXV,EACAY,EAAkBC,aAAE,EAKlBL,EAAgB,GAChBG,EAAUN,GAsDd,SAAAS,EAAAC,GAEAH,IAAAA,EAEWI,YAAPD,EACKE,EAAOd,cACT,GAAAe,QAvBLC,GAAAC,EADOZ,EAAAa,eAAA,GACPF,aAEAG,EAASR,EAAAA,OAKES,EAAsBC,MAAMF,EAASG,IAAA,EAAAC,CAAA,EAChDC,IAAA,SAAAC,GAEIC,OAAOC,EAAAF,EACTG,CAAAA,EACS1B,OAAAA,SAAqBI,EAAAA,GAC9BuB,OAAMA,KAAIC,IAAAC,EAAAC,CAAA,CACVC,EAAAA,CAAAA,GASG,IAAA,EACLC,EAAOzB,cAAe,EAAGA,MAAAA,OAAeY,CAC1C,CAfE,IAAIK,EAAO,CACTE,KAAM,aACNpB,QAASN,EAAeK,MAAMD,EAAa6B,CAAW,EACtDN,KApDF,SAMIb,GALFX,EAME+B,EAEF5B,EAAQN,EAAUmC,QAAAX,EAAAlB,OAAA,EAElBmB,IACEW,GAAOC,EADTZ,EAAeS,eAAe,GACrBG,QAAWD,KAClBtB,EAAAC,EAAAD,aACFR,EAAQP,EAAAA,WAEN,MAAAqC,IACF3B,EAAAA,EAAoB6B,gBAAAC,KAAAA,EAbFvB,EAaE,EACtBS,EAAAS,EAAAZ,IAAA,SAAAe,GAEA,OAASN,EAAOZ,MACdb,CAAAA,EAPAA,EAQEP,aAAmByC,QAAM/B,SAAAA,GACzB,OAAAN,EAAAsC,GAAA/B,EAAAD,CAAA,CACFA,CAAAA,EACFA,EAAA,EAEA,EA0BEsB,QAjCF,WACEzB,EASQP,aAAYyC,QAAA,SAAA9B,GAEpB,OAAIgC,EAAaC,IAAG7B,EAAAA,CAAyB,CAC7C,CAAA,EATAL,EAUSgB,SAAmB,CAT9B,CA6BA,EACA,OAAOD,CACT,CAEAjB,EAAgBC,cAAgB+B,KAAAA,EAEV,aAAlB,OAAO5B,QAAoD,KAAA,IAAnBA,OAAOC,QACjDD,OAAOC,QAAUL,EAEjByB,OAAOzB,gBAAkBA,CAE5B,EAAA","file":"../embla-carousel-auto-height.min.js","sourcesContent":["(function () {\r\n 'use strict';\r\n\r\n var defaultOptions = {\r\n active: true,\r\n breakpoints: {},\r\n destroyHeight: 'auto',\r\n heightEvents: ['select', 'pointerUp'],\r\n };\r\n\r\n function EmblaAutoHeight(userOptions) {\r\n var optionsHandler = EmblaCarousel.optionsHandler();\r\n var optionsBase = optionsHandler.merge(\r\n defaultOptions,\r\n EmblaAutoHeight.globalOptions\r\n );\r\n var options;\r\n var carousel;\r\n var slideBounds = [];\r\n var slideHeights = [];\r\n var inViewThreshold = 0.5;\r\n\r\n function init(embla) {\r\n carousel = embla;\r\n options = optionsHandler.atMedia(self.options);\r\n\r\n var _a = carousel.internalEngine(),\r\n axis = _a.options.axis,\r\n slidesInView = _a.slidesInView,\r\n slideRects = _a.slideRects;\r\n\r\n if (axis === 'y') return;\r\n slideBounds = slidesInView.findSlideBounds(undefined, inViewThreshold);\r\n slideHeights = slideRects.map(function (rect) {\r\n return rect.height;\r\n });\r\n options.heightEvents.forEach(function (evt) {\r\n return carousel.on(evt, setContainerHeight);\r\n });\r\n setContainerHeight();\r\n }\r\n\r\n function destroy() {\r\n options.heightEvents.forEach(function (evt) {\r\n return carousel.off(evt, setContainerHeight);\r\n });\r\n setContainerHeight('destroy');\r\n }\r\n\r\n function highestInView() {\r\n var _a = carousel.internalEngine(),\r\n slidesInView = _a.slidesInView,\r\n target = _a.target;\r\n\r\n var inViewIndexes = slidesInView.check(target.get(), slideBounds);\r\n var heights = inViewIndexes.map(function (index) {\r\n return slideHeights[index];\r\n });\r\n return heights.reduce(function (a, b) {\r\n return Math.max(a, b);\r\n }, 0);\r\n }\r\n\r\n function setContainerHeight(evt) {\r\n var height =\r\n evt === 'destroy'\r\n ? options.destroyHeight\r\n : ''.concat(highestInView(), 'px');\r\n carousel.containerNode().style.height = height;\r\n }\r\n\r\n var self = {\r\n name: 'autoHeight',\r\n options: optionsHandler.merge(optionsBase, userOptions),\r\n init: init,\r\n destroy: destroy,\r\n };\r\n return self;\r\n }\r\n\r\n EmblaAutoHeight.globalOptions = undefined;\r\n\r\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\r\n module.exports = EmblaAutoHeight;\r\n } else {\r\n window.EmblaAutoHeight = EmblaAutoHeight;\r\n }\r\n})();\r\n"]}