From 88f4650f0c2c28a9ee4166e1f42212fd5df61543 Mon Sep 17 00:00:00 2001 From: Norman Rusch Date: Mon, 8 Nov 2021 16:14:38 +0100 Subject: [PATCH] 1.0.1 --- dist/features/buttons/index.js | 2 +- dist/features/mouse/index.js | 18 +++++++++--------- dist/features/pagination/index.js | 5 ++++- dist/formats/cjs/caroucssel.js | 27 +++++++++++++++------------ dist/formats/cjs/caroucssel.min.js | 2 +- dist/formats/iife/caroucssel.js | 27 +++++++++++++++------------ dist/formats/iife/caroucssel.min.js | 2 +- dist/formats/umd/caroucssel.js | 29 +++++++++++++++++------------ dist/formats/umd/caroucssel.min.js | 2 +- dist/index.d.ts | 2 +- dist/index.js | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 13 files changed, 69 insertions(+), 55 deletions(-) diff --git a/dist/features/buttons/index.js b/dist/features/buttons/index.js index 3d511b4a..98201878 100644 --- a/dist/features/buttons/index.js +++ b/dist/features/buttons/index.js @@ -145,7 +145,7 @@ export class Buttons { */ _remove() { const buttons = fromCache(this, CACHE_KEY_BUTTONS); - buttons.forEach((button) => { + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button) => { var _a; // The onClick listener is already bound in the constructor. // diff --git a/dist/features/mouse/index.js b/dist/features/mouse/index.js index 7d83f04b..106b7146 100644 --- a/dist/features/mouse/index.js +++ b/dist/features/mouse/index.js @@ -122,16 +122,16 @@ export class Mouse { * @param event the event that triggered the dragging */ _onDrag(event) { - var _a; + var _a, _b, _c; const config = fromCache(this, CACHE_KEY_CONFIGURATION); const { el } = fromCache(this, CACHE_KEY_PROXY); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const x = fromCache(this, CACHE_KEY_POSITION_X); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0; const currentX = __getPositionX(event); const deltaX = x - currentX; el.scrollLeft = left + deltaX; // Call the hook: - (_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event }); + (_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event }); } /** * Handles the drag end event. @@ -139,11 +139,11 @@ export class Mouse { * @param event the event that triggered the drag end */ _onEnd(event) { - var _a, _b; + var _a, _b, _c, _d; const proxy = fromCache(this, CACHE_KEY_PROXY); const config = fromCache(this, CACHE_KEY_CONFIGURATION); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX)) !== null && _b !== void 0 ? _b : 0; clearCache(this, CACHE_KEY_SCROLL_LEFT); clearCache(this, CACHE_KEY_POSITION_X); clearCache(this, CACHE_KEY_PAGE_INDEX); @@ -161,7 +161,7 @@ export class Mouse { if (offset > threshold) { const direction = distance / offset; const at = Math.max(pageIndex + direction, 0); - index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index; + index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index; } // Apply the index until the styles are rendered to the element. This is // required to have a smooth scroll-behaviour which is disabled during the @@ -183,6 +183,6 @@ export class Mouse { window.removeEventListener(EVENT_END, this._onEnd); /* eslint-enable @typescript-eslint/unbound-method */ // Call the hook: - (_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { originalEvent: event }); + (_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event }); } } diff --git a/dist/features/pagination/index.js b/dist/features/pagination/index.js index 4cbcc641..7012f87d 100644 --- a/dist/features/pagination/index.js +++ b/dist/features/pagination/index.js @@ -126,7 +126,7 @@ export class Pagination { const proxy = fromCache(this, CACHE_KEY_PROXY); const buttons = fromCache(this, CACHE_KEY_BUTTONS); const { pageIndex } = proxy; - buttons.forEach((button, at) => button.disabled = (at === pageIndex)); + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button, at) => button.disabled = (at === pageIndex)); } /** * Removes the whole pagination element and removes all attached event handlers. @@ -158,6 +158,9 @@ export class Pagination { _onClick(event) { const proxy = fromCache(this, CACHE_KEY_PROXY); const buttons = fromCache(this, CACHE_KEY_BUTTONS); + if (!buttons) { + return; + } const target = event.currentTarget; const index = buttons.indexOf(target); proxy.index = proxy.pages[index]; diff --git a/dist/formats/cjs/caroucssel.js b/dist/formats/cjs/caroucssel.js index a0c06154..0918f359 100644 --- a/dist/formats/cjs/caroucssel.js +++ b/dist/formats/cjs/caroucssel.js @@ -142,7 +142,7 @@ class Buttons { } _remove() { const buttons = fromCache(this, CACHE_KEY_BUTTONS$1); - buttons.forEach((button) => { + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button) => { var _a; button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onPrev); button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onNext); @@ -229,22 +229,22 @@ class Mouse { (_a = config.onStart) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event }); } _onDrag(event) { - var _a; + var _a, _b, _c; const config = fromCache(this, CACHE_KEY_CONFIGURATION$3); const { el } = fromCache(this, CACHE_KEY_PROXY$3); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const x = fromCache(this, CACHE_KEY_POSITION_X); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0; const currentX = __getPositionX(event); const deltaX = x - currentX; el.scrollLeft = left + deltaX; - (_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event }); + (_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event }); } _onEnd(event) { - var _a, _b; + var _a, _b, _c, _d; const proxy = fromCache(this, CACHE_KEY_PROXY$3); const config = fromCache(this, CACHE_KEY_CONFIGURATION$3); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX$1); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX$1)) !== null && _b !== void 0 ? _b : 0; clearCache(this, CACHE_KEY_SCROLL_LEFT); clearCache(this, CACHE_KEY_POSITION_X); clearCache(this, CACHE_KEY_PAGE_INDEX$1); @@ -260,7 +260,7 @@ class Mouse { if (offset > threshold) { const direction = distance / offset; const at = Math.max(pageIndex + direction, 0); - index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index; + index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index; } window.requestAnimationFrame(() => { proxy.index = index; @@ -271,7 +271,7 @@ class Mouse { writeCache(this, CACHE_KEY_TIMEOUT, timeout); window.removeEventListener(EVENT_DRAG, this._onDrag); window.removeEventListener(EVENT_END, this._onEnd); - (_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { originalEvent: event }); + (_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event }); } } @@ -367,7 +367,7 @@ class Pagination { const proxy = fromCache(this, CACHE_KEY_PROXY$2); const buttons = fromCache(this, CACHE_KEY_BUTTONS); const { pageIndex } = proxy; - buttons.forEach((button, at) => button.disabled = (at === pageIndex)); + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button, at) => button.disabled = (at === pageIndex)); } _remove() { var _a; @@ -385,6 +385,9 @@ class Pagination { _onClick(event) { const proxy = fromCache(this, CACHE_KEY_PROXY$2); const buttons = fromCache(this, CACHE_KEY_BUTTONS); + if (!buttons) { + return; + } const target = event.currentTarget; const index = buttons.indexOf(target); proxy.index = proxy.pages[index]; @@ -796,7 +799,7 @@ class Carousel { } } -const version = '1.0.0'; +const version = '1.0.1'; exports.Buttons = Buttons; exports.Carousel = Carousel; diff --git a/dist/formats/cjs/caroucssel.min.js b/dist/formats/cjs/caroucssel.min.js index fe3038b6..862bcefc 100644 --- a/dist/formats/cjs/caroucssel.min.js +++ b/dist/formats/cjs/caroucssel.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=new WeakMap;function e(e,s,i){const n=t.get(e)||{};if(s in n)return n[s];if(!i)return;const r=i();return n[s]=r,t.set(e,n),r}function s(e,s,i){const n=t.get(e)||{};n[s]=i,t.set(e,n)}function i(e,s){const i=t.get(e);i&&(i[s]=void 0,delete i[s])}function n(e){t.delete(e)}function r(t,e){const s=document.createElement("div");s.innerHTML=t(e);const i=s.firstElementChild;return i||null}const o={template:({className:t,controls:e,label:s,title:i})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};function l(t){return t instanceof MouseEvent?t.clientX:0}const a={indicator:!1};var h,d;exports.UpdateType=void 0,(h=exports.UpdateType||(exports.UpdateType={})).SCROLL="scroll",h.RESIZE="resize",h.FORCED="forced",h.FEATURE="feature",exports.ScrollBehavior=void 0,(d=exports.ScrollBehavior||(exports.ScrollBehavior={})).AUTO="auto",d.SMOOTH="smooth";const c={template:({className:t,controls:e,pages:s,label:i,title:n})=>`\n\t\t\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};class u{constructor(){window.addEventListener("resize",(()=>{i(this,"dims")}))}get dimensions(){return e(this,"dims",(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const s=t.offsetHeight;e.style.overflow="scroll";let i=t.offsetHeight;i=s===i?e.clientHeight:i;const n=s-i;return document.body.removeChild(e),{height:n}}))}}let p;const g={enabled:!0,className:"caroucssel-mask",tagName:"div"};class m{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},g),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=e(this,"mask"))&&void 0!==t?t:null}init(t){s(this,"prxy",t),p=null!=p?p:new u,this._render()}destroy(){this._remove(),n(this)}update(t){switch(t.type){case exports.UpdateType.RESIZE:case exports.UpdateType.FORCED:i(this,"hght"),this._render();break;default:this._render()}}_render(){const{enabled:t,className:i,tagName:n}=e(this,"conf");if(!t)return;const r=e(this,"prxy").el;let{height:o}=p.dimensions;r.scrollWidth<=r.clientWidth&&(o=0),e(this,"mask",(()=>{var t;const e=document.createElement(n);return e.className=i,e.style.overflow="hidden",e.style.height="100%",null===(t=r.parentNode)||void 0===t||t.insertBefore(e,r),e.appendChild(r),e}));o!==e(this,"hght")&&(s(this,"hght",o),r.style.height=`calc(100% + ${o}px)`,r.style.marginBottom=-1*o+"px")}_remove(){var t,s;const{el:i}=e(this,"prxy"),n=e(this,"mask");null===(t=null==n?void 0:n.parentNode)||void 0===t||t.insertBefore(i,n),null===(s=null==n?void 0:n.parentNode)||void 0===s||s.removeChild(n),i.removeAttribute("style")}}function v(t){return e(t,"inst")}class f{constructor(t,e){s(this,"inst",t),s(this,"feat",e)}get id(){return v(this).id}get el(){return v(this).el}get mask(){return v(this).mask}get index(){return v(this).index}set index(t){v(this).index=t}get items(){return v(this).items}get pages(){return v(this).pages}get pageIndex(){return v(this).pageIndex}update(t){var s;v(this).update(),(s=this,e(s,"feat")).forEach((e=>{e!==t&&e.update({type:exports.UpdateType.FEATURE})}))}}function x(t,e){let s=null;return(...i)=>{null!==s&&clearTimeout(s),s=setTimeout((()=>t(...i)),e)}}const y=/^caroucssel-[0-9]*$/,b=/^(link|meta|noscript|script|style|title)$/i;let _=0;const E={features:[],filterItem:()=>!0,onScroll:()=>{}};exports.Buttons=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},o),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,"prxy",t),this._render()}destroy(){this._remove(),n(this)}update(){this._render()}_render(){const t=e(this,"prxy"),s=e(this,"conf"),{el:i,mask:n,pages:o,pageIndex:l}=t,[a,h]=e(this,"btns",(()=>{const t=null!=n?n:i,{template:e,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:d,nextLabel:c,nextTitle:u}=s;return[{controls:i.id,label:c,title:u,className:[o,d].join(" "),handler:this._onNext},{controls:i.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((s=>{var i,{handler:n}=s,o=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(t);n{var e;null==t||t.removeEventListener("click",this._onPrev),null==t||t.removeEventListener("click",this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=e(this,"prxy"),{pages:s,pageIndex:i}=t,n=s[i-1]||s[0];t.index=n}_onNext(){const t=e(this,"prxy"),{pages:s,pageIndex:i}=t,n=s[i+1]||s[s.length-1];t.index=n}},exports.Carousel=class{constructor(t,e={}){if(this.behavior=exports.ScrollBehavior.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);s(this,"element",t),_++,t.id=t.id||`caroucssel-${_}`,s(this,"id",t.id);const i=Object.assign(Object.assign({},E),e);s(this,"config",i);let n=null,r=[...i.features];const o=i.features.findIndex((t=>t instanceof m));o>-1&&([n]=r.splice(o,1)),null!=n||(n=new m),r=r.filter((t=>!(t instanceof m))),r=[n,...r],s(this,"mask",n);const l=new f(this,r);switch(s(this,"proxy",l),s(this,"feautres",r),r.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=exports.ScrollBehavior.SMOOTH,this._onScroll=x(this._onScroll.bind(this),25),this._onResize=x(this._onResize.bind(this),25),t.addEventListener("scroll",this._onScroll),window.addEventListener("resize",this._onResize)}static resetInstanceCount(){}get el(){return e(this,"element")}get mask(){var t;return null!==(t=e(this,"mask").el)&&void 0!==t?t:null}get id(){return e(this,"id")}get index(){return e(this,"index",(()=>{const{el:t,items:e}=this,{length:s}=e,{clientWidth:i}=t,n=t.getBoundingClientRect().left,r=[];let o=0;for(;o=0&&l+.75*s<=i&&r.push(o)}return 0===r.length?[0]:r}))}set index(t){const{behavior:e,el:s,items:n}=this,{length:r}=n;if(!Array.isArray(t)||!t.length)return;let o=t[0]||0;o=Math.max(Math.min(o,r-1),0);const{scrollLeft:l}=s,a=l,h={left:n[o].offsetLeft};o===this.pages[0][0]&&(h.left=0),a!==h.left&&(i(this,"index"),s.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return e(this,"items",(()=>{const{filterItem:t}=e(this,"config"),{el:s}=this;return Array.from(s.children).filter((t=>!b.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return e(this,"pages",(()=>{const{el:t,items:e}=this,{clientWidth:s}=t;if(0===s)return e.map(((t,e)=>[e]));let i=[[]];return e.map(((t,e)=>{const{offsetLeft:s,clientWidth:i}=t;return{left:s,width:i,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:n}=t,r=i[i.length-1],o=r[0];let l=(null==o?void 0:o.left)||0;r===i[0]&&(l=0);let a=Math.floor((e-l+.75*n)/s);for(;a>0;)i.push([]),a--;i[i.length-1].push(t)})),i=i.filter((t=>0!==t.length)),i.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return e(this,"page-index",(()=>{const{el:t,items:e,index:s,pages:i}=this,n=t.getBoundingClientRect().left,{clientWidth:r}=t;let o=s.reduce(((t,s)=>{if(!e[s])return t;let{left:i,right:o}=e[s].getBoundingClientRect();return i=Math.round(i-n),o=Math.round(o-n),i<0||r{const i=e[t].getBoundingClientRect().right;return e[s].getBoundingClientRect().right-i}))[0];return i.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;y.test(t.id)&&t.removeAttribute("id");e(this,"feautres").forEach((t=>t.destroy())),t.removeEventListener("scroll",this._onScroll),window.removeEventListener("resize",this._onResize),n(this)}update(){i(this,"index"),i(this,"items"),i(this,"pages"),i(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.FORCED})))}_onScroll(t){i(this,"index"),i(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.SCROLL})));const{index:s}=this;e(this,"config").onScroll({index:s,type:"scroll",target:this,originalEvent:t})}_onResize(){i(this,"pages"),i(this,"index"),i(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.RESIZE})))}},exports.Mask=m,exports.Mouse=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},a),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,"prxy",t);const i=e(this,"conf"),{el:n}=t;n.style.cursor=i.indicator?"grab":"",n.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){n(this)}update(){}_onStart(t){var s;const i=e(this,"time");clearTimeout(i);const n=e(this,"conf"),r=e(this,"prxy"),o=r.el;e(this,"scrl",(()=>o.scrollLeft)),e(this,"posx",(()=>l(t))),e(this,"pgidx",(()=>r.pageIndex)),o.style.userSelect="none",o.style.scrollBehavior="auto",o.style.scrollSnapType="none",o.style.cursor=n.indicator?"grabbing":"",window.addEventListener("mousemove",this._onDrag,{passive:!0}),window.addEventListener("mouseup",this._onEnd,{passive:!0}),null===(s=n.onStart)||void 0===s||s.call(n,{originalEvent:t})}_onDrag(t){var s;const i=e(this,"conf"),{el:n}=e(this,"prxy"),r=e(this,"scrl"),o=e(this,"posx")-l(t);n.scrollLeft=r+o,null===(s=i.onDrag)||void 0===s||s.call(i,{originalEvent:t})}_onEnd(t){var n,r;const o=e(this,"prxy"),l=e(this,"conf"),a=e(this,"scrl"),h=e(this,"pgidx");i(this,"scrl"),i(this,"posx"),i(this,"pgidx");const d=o.el,c=Math.min(Math.max(100,.25*d.clientWidth),250),u=d.scrollLeft-a,p=Math.abs(u);d.style.removeProperty("user-select"),d.style.removeProperty("scroll-behavior"),d.style.cursor=l.indicator?"grab":"";let g=o.index;if(p>c){const t=u/p,e=Math.max(h+t,0);g=null!==(n=o.pages[e])&&void 0!==n?n:g}window.requestAnimationFrame((()=>{o.index=g}));s(this,"time",window.setTimeout((()=>{d.style.removeProperty("scroll-snap-type")}),1e3)),window.removeEventListener("mousemove",this._onDrag),window.removeEventListener("mouseup",this._onEnd),null===(r=l.onEnd)||void 0===r||r.call(l,{originalEvent:t})}},exports.Pagination=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},c),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,"prxy",t),this._add()}destroy(){this._remove(),n(this)}update(t){switch(t.type){case exports.UpdateType.SCROLL:this._update();break;default:this._remove(),this._add()}}_add(){var t;const i=e(this,"prxy"),n=e(this,"conf"),{el:o,mask:l,pages:a}=i,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=n,g=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const m=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(g),s(this,"pags",g),s(this,"btns",m),this._update()}_update(){const t=e(this,"prxy"),s=e(this,"btns"),{pageIndex:i}=t;s.forEach(((t,e)=>t.disabled=e===i))}_remove(){var t;const s=e(this,"pags"),n=e(this,"btns");null==n||n.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==s?void 0:s.parentNode)||void 0===t||t.removeChild(s),i(this,"btns"),i(this,"pags")}_onClick(t){const s=e(this,"prxy"),i=e(this,"btns"),n=t.currentTarget,r=i.indexOf(n);s.index=s.pages[r]}},exports.version="1.0.0"; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=new WeakMap;function e(e,s,n){const i=t.get(e)||{};if(s in i)return i[s];if(!n)return;const r=n();return i[s]=r,t.set(e,i),r}function s(e,s,n){const i=t.get(e)||{};i[s]=n,t.set(e,i)}function n(e,s){const n=t.get(e);n&&(n[s]=void 0,delete n[s])}function i(e){t.delete(e)}function r(t,e){const s=document.createElement("div");s.innerHTML=t(e);const n=s.firstElementChild;return n||null}const o={template:({className:t,controls:e,label:s,title:n})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};function l(t){return t instanceof MouseEvent?t.clientX:0}const a={indicator:!1};var d,h;exports.UpdateType=void 0,(d=exports.UpdateType||(exports.UpdateType={})).SCROLL="scroll",d.RESIZE="resize",d.FORCED="forced",d.FEATURE="feature",exports.ScrollBehavior=void 0,(h=exports.ScrollBehavior||(exports.ScrollBehavior={})).AUTO="auto",h.SMOOTH="smooth";const c={template:({className:t,controls:e,pages:s,label:n,title:i})=>`\n\t\t
    \n\t\t\t${s.map(((t,r)=>{const o={index:r,page:t,pages:s},l=n(o),a=i(o);return`
  • \n\t\t\t\t\t\n\t\t\t\t
  • `})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};class u{constructor(){window.addEventListener("resize",(()=>{n(this,"dims")}))}get dimensions(){return e(this,"dims",(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const s=t.offsetHeight;e.style.overflow="scroll";let n=t.offsetHeight;n=s===n?e.clientHeight:n;const i=s-n;return document.body.removeChild(e),{height:i}}))}}let p;const g={enabled:!0,className:"caroucssel-mask",tagName:"div"};class m{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},g),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=e(this,"mask"))&&void 0!==t?t:null}init(t){s(this,"prxy",t),p=null!=p?p:new u,this._render()}destroy(){this._remove(),i(this)}update(t){switch(t.type){case exports.UpdateType.RESIZE:case exports.UpdateType.FORCED:n(this,"hght"),this._render();break;default:this._render()}}_render(){const{enabled:t,className:n,tagName:i}=e(this,"conf");if(!t)return;const r=e(this,"prxy").el;let{height:o}=p.dimensions;r.scrollWidth<=r.clientWidth&&(o=0),e(this,"mask",(()=>{var t;const e=document.createElement(i);return e.className=n,e.style.overflow="hidden",e.style.height="100%",null===(t=r.parentNode)||void 0===t||t.insertBefore(e,r),e.appendChild(r),e}));o!==e(this,"hght")&&(s(this,"hght",o),r.style.height=`calc(100% + ${o}px)`,r.style.marginBottom=-1*o+"px")}_remove(){var t,s;const{el:n}=e(this,"prxy"),i=e(this,"mask");null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(n,i),null===(s=null==i?void 0:i.parentNode)||void 0===s||s.removeChild(i),n.removeAttribute("style")}}function v(t){return e(t,"inst")}class f{constructor(t,e){s(this,"inst",t),s(this,"feat",e)}get id(){return v(this).id}get el(){return v(this).el}get mask(){return v(this).mask}get index(){return v(this).index}set index(t){v(this).index=t}get items(){return v(this).items}get pages(){return v(this).pages}get pageIndex(){return v(this).pageIndex}update(t){var s;v(this).update(),(s=this,e(s,"feat")).forEach((e=>{e!==t&&e.update({type:exports.UpdateType.FEATURE})}))}}function x(t,e){let s=null;return(...n)=>{null!==s&&clearTimeout(s),s=setTimeout((()=>t(...n)),e)}}const y=/^caroucssel-[0-9]*$/,b=/^(link|meta|noscript|script|style|title)$/i;let _=0;const E={features:[],filterItem:()=>!0,onScroll:()=>{}};exports.Buttons=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},o),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){s(this,"prxy",t),this._render()}destroy(){this._remove(),i(this)}update(){this._render()}_render(){const t=e(this,"prxy"),s=e(this,"conf"),{el:n,mask:i,pages:o,pageIndex:l}=t,[a,d]=e(this,"btns",(()=>{const t=null!=i?i:n,{template:e,className:o,previousClassName:l,previousLabel:a,previousTitle:d,nextClassName:h,nextLabel:c,nextTitle:u}=s;return[{controls:n.id,label:c,title:u,className:[o,h].join(" "),handler:this._onNext},{controls:n.id,label:a,title:d,className:[o,l].join(" "),handler:this._onPrev}].map((s=>{var n,{handler:i}=s,o=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i{var e;null==t||t.removeEventListener("click",this._onPrev),null==t||t.removeEventListener("click",this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=e(this,"prxy"),{pages:s,pageIndex:n}=t,i=s[n-1]||s[0];t.index=i}_onNext(){const t=e(this,"prxy"),{pages:s,pageIndex:n}=t,i=s[n+1]||s[s.length-1];t.index=i}},exports.Carousel=class{constructor(t,e={}){if(this.behavior=exports.ScrollBehavior.AUTO,!(t&&t instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof t}" was passed.`);s(this,"element",t),_++,t.id=t.id||`caroucssel-${_}`,s(this,"id",t.id);const n=Object.assign(Object.assign({},E),e);s(this,"config",n);let i=null,r=[...n.features];const o=n.features.findIndex((t=>t instanceof m));o>-1&&([i]=r.splice(o,1)),null!=i||(i=new m),r=r.filter((t=>!(t instanceof m))),r=[i,...r],s(this,"mask",i);const l=new f(this,r);switch(s(this,"proxy",l),s(this,"feautres",r),r.forEach((t=>t.init(l))),!0){case Array.isArray(e.index):this.index=e.index;break;case!isNaN(e.index):this.index=[e.index]}this.behavior=exports.ScrollBehavior.SMOOTH,this._onScroll=x(this._onScroll.bind(this),25),this._onResize=x(this._onResize.bind(this),25),t.addEventListener("scroll",this._onScroll),window.addEventListener("resize",this._onResize)}static resetInstanceCount(){}get el(){return e(this,"element")}get mask(){var t;return null!==(t=e(this,"mask").el)&&void 0!==t?t:null}get id(){return e(this,"id")}get index(){return e(this,"index",(()=>{const{el:t,items:e}=this,{length:s}=e,{clientWidth:n}=t,i=t.getBoundingClientRect().left,r=[];let o=0;for(;o=0&&l+.75*s<=n&&r.push(o)}return 0===r.length?[0]:r}))}set index(t){const{behavior:e,el:s,items:i}=this,{length:r}=i;if(!Array.isArray(t)||!t.length)return;let o=t[0]||0;o=Math.max(Math.min(o,r-1),0);const{scrollLeft:l}=s,a=l,d={left:i[o].offsetLeft};o===this.pages[0][0]&&(d.left=0),a!==d.left&&(n(this,"index"),s.scrollTo(Object.assign(Object.assign({},d),{behavior:e})))}get items(){return e(this,"items",(()=>{const{filterItem:t}=e(this,"config"),{el:s}=this;return Array.from(s.children).filter((t=>!b.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return e(this,"pages",(()=>{const{el:t,items:e}=this,{clientWidth:s}=t;if(0===s)return e.map(((t,e)=>[e]));let n=[[]];return e.map(((t,e)=>{const{offsetLeft:s,clientWidth:n}=t;return{left:s,width:n,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:i}=t,r=n[n.length-1],o=r[0];let l=(null==o?void 0:o.left)||0;r===n[0]&&(l=0);let a=Math.floor((e-l+.75*i)/s);for(;a>0;)n.push([]),a--;n[n.length-1].push(t)})),n=n.filter((t=>0!==t.length)),n.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return e(this,"page-index",(()=>{const{el:t,items:e,index:s,pages:n}=this,i=t.getBoundingClientRect().left,{clientWidth:r}=t;let o=s.reduce(((t,s)=>{if(!e[s])return t;let{left:n,right:o}=e[s].getBoundingClientRect();return n=Math.round(n-i),o=Math.round(o-i),n<0||r{const n=e[t].getBoundingClientRect().right;return e[s].getBoundingClientRect().right-n}))[0];return n.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;y.test(t.id)&&t.removeAttribute("id");e(this,"feautres").forEach((t=>t.destroy())),t.removeEventListener("scroll",this._onScroll),window.removeEventListener("resize",this._onResize),i(this)}update(){n(this,"index"),n(this,"items"),n(this,"pages"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.FORCED})))}_onScroll(t){n(this,"index"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.SCROLL})));const{index:s}=this;e(this,"config").onScroll({index:s,type:"scroll",target:this,originalEvent:t})}_onResize(){n(this,"pages"),n(this,"index"),n(this,"page-index");e(this,"feautres").forEach((t=>t.update({type:exports.UpdateType.RESIZE})))}},exports.Mask=m,exports.Mouse=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},a),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){s(this,"prxy",t);const n=e(this,"conf"),{el:i}=t;i.style.cursor=n.indicator?"grab":"",i.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){i(this)}update(){}_onStart(t){var s;const n=e(this,"time");clearTimeout(n);const i=e(this,"conf"),r=e(this,"prxy"),o=r.el;e(this,"scrl",(()=>o.scrollLeft)),e(this,"posx",(()=>l(t))),e(this,"pgidx",(()=>r.pageIndex)),o.style.userSelect="none",o.style.scrollBehavior="auto",o.style.scrollSnapType="none",o.style.cursor=i.indicator?"grabbing":"",window.addEventListener("mousemove",this._onDrag,{passive:!0}),window.addEventListener("mouseup",this._onEnd,{passive:!0}),null===(s=i.onStart)||void 0===s||s.call(i,{originalEvent:t})}_onDrag(t){var s,n,i;const r=e(this,"conf"),{el:o}=e(this,"prxy"),a=null!==(s=e(this,"scrl"))&&void 0!==s?s:0,d=(null!==(n=e(this,"posx"))&&void 0!==n?n:0)-l(t);o.scrollLeft=a+d,null===(i=r.onDrag)||void 0===i||i.call(r,{originalEvent:t})}_onEnd(t){var i,r,o,l;const a=e(this,"prxy"),d=e(this,"conf"),h=null!==(i=e(this,"scrl"))&&void 0!==i?i:0,c=null!==(r=e(this,"pgidx"))&&void 0!==r?r:0;n(this,"scrl"),n(this,"posx"),n(this,"pgidx");const u=a.el,p=Math.min(Math.max(100,.25*u.clientWidth),250),g=u.scrollLeft-h,m=Math.abs(g);u.style.removeProperty("user-select"),u.style.removeProperty("scroll-behavior"),u.style.cursor=d.indicator?"grab":"";let v=a.index;if(m>p){const t=g/m,e=Math.max(c+t,0);v=null!==(o=a.pages[e])&&void 0!==o?o:v}window.requestAnimationFrame((()=>{a.index=v}));s(this,"time",window.setTimeout((()=>{u.style.removeProperty("scroll-snap-type")}),1e3)),window.removeEventListener("mousemove",this._onDrag),window.removeEventListener("mouseup",this._onEnd),null===(l=d.onEnd)||void 0===l||l.call(d,{originalEvent:t})}},exports.Pagination=class{constructor(t={}){s(this,"conf",Object.assign(Object.assign({},c),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){s(this,"prxy",t),this._add()}destroy(){this._remove(),i(this)}update(t){switch(t.type){case exports.UpdateType.SCROLL:this._update();break;default:this._remove(),this._add()}}_add(){var t;const n=e(this,"prxy"),i=e(this,"conf"),{el:o,mask:l,pages:a}=n,d=null!=l?l:o;if(a.length<2)return;const{template:h,className:c,label:u,title:p}=i,g=r(h,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const m=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=d.parentNode)||void 0===t||t.appendChild(g),s(this,"pags",g),s(this,"btns",m),this._update()}_update(){const t=e(this,"prxy"),s=e(this,"btns"),{pageIndex:n}=t;null==s||s.forEach(((t,e)=>t.disabled=e===n))}_remove(){var t;const s=e(this,"pags"),i=e(this,"btns");null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==s?void 0:s.parentNode)||void 0===t||t.removeChild(s),n(this,"btns"),n(this,"pags")}_onClick(t){const s=e(this,"prxy"),n=e(this,"btns");if(!n)return;const i=t.currentTarget,r=n.indexOf(i);s.index=s.pages[r]}},exports.version="1.0.1"; diff --git a/dist/formats/iife/caroucssel.js b/dist/formats/iife/caroucssel.js index 0d603411..fa72a5a2 100644 --- a/dist/formats/iife/caroucssel.js +++ b/dist/formats/iife/caroucssel.js @@ -141,7 +141,7 @@ var caroucssel = (function (exports) { } _remove() { const buttons = fromCache(this, CACHE_KEY_BUTTONS$1); - buttons.forEach((button) => { + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button) => { var _a; button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onPrev); button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, this._onNext); @@ -228,22 +228,22 @@ var caroucssel = (function (exports) { (_a = config.onStart) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event }); } _onDrag(event) { - var _a; + var _a, _b, _c; const config = fromCache(this, CACHE_KEY_CONFIGURATION$3); const { el } = fromCache(this, CACHE_KEY_PROXY$3); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const x = fromCache(this, CACHE_KEY_POSITION_X); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0; const currentX = __getPositionX(event); const deltaX = x - currentX; el.scrollLeft = left + deltaX; - (_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { originalEvent: event }); + (_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event }); } _onEnd(event) { - var _a, _b; + var _a, _b, _c, _d; const proxy = fromCache(this, CACHE_KEY_PROXY$3); const config = fromCache(this, CACHE_KEY_CONFIGURATION$3); - const left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - const pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX$1); + const left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + const pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX$1)) !== null && _b !== void 0 ? _b : 0; clearCache(this, CACHE_KEY_SCROLL_LEFT); clearCache(this, CACHE_KEY_POSITION_X); clearCache(this, CACHE_KEY_PAGE_INDEX$1); @@ -259,7 +259,7 @@ var caroucssel = (function (exports) { if (offset > threshold) { const direction = distance / offset; const at = Math.max(pageIndex + direction, 0); - index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index; + index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index; } window.requestAnimationFrame(() => { proxy.index = index; @@ -270,7 +270,7 @@ var caroucssel = (function (exports) { writeCache(this, CACHE_KEY_TIMEOUT, timeout); window.removeEventListener(EVENT_DRAG, this._onDrag); window.removeEventListener(EVENT_END, this._onEnd); - (_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { originalEvent: event }); + (_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event }); } } @@ -366,7 +366,7 @@ var caroucssel = (function (exports) { const proxy = fromCache(this, CACHE_KEY_PROXY$2); const buttons = fromCache(this, CACHE_KEY_BUTTONS); const { pageIndex } = proxy; - buttons.forEach((button, at) => button.disabled = (at === pageIndex)); + buttons === null || buttons === void 0 ? void 0 : buttons.forEach((button, at) => button.disabled = (at === pageIndex)); } _remove() { var _a; @@ -384,6 +384,9 @@ var caroucssel = (function (exports) { _onClick(event) { const proxy = fromCache(this, CACHE_KEY_PROXY$2); const buttons = fromCache(this, CACHE_KEY_BUTTONS); + if (!buttons) { + return; + } const target = event.currentTarget; const index = buttons.indexOf(target); proxy.index = proxy.pages[index]; @@ -795,7 +798,7 @@ var caroucssel = (function (exports) { } } - const version = '1.0.0'; + const version = '1.0.1'; exports.Buttons = Buttons; exports.Carousel = Carousel; diff --git a/dist/formats/iife/caroucssel.min.js b/dist/formats/iife/caroucssel.min.js index 19a2d6da..da28f364 100644 --- a/dist/formats/iife/caroucssel.min.js +++ b/dist/formats/iife/caroucssel.min.js @@ -1 +1 @@ -var caroucssel=function(t){"use strict";const e=new WeakMap;function i(t,i,n){const s=e.get(t)||{};if(i in s)return s[i];if(!n)return;const o=n();return s[i]=o,e.set(t,s),o}function n(t,i,n){const s=e.get(t)||{};s[i]=n,e.set(t,s)}function s(t,i){const n=e.get(t);n&&(n[i]=void 0,delete n[i])}function o(t){e.delete(t)}function r(t,e){const i=document.createElement("div");i.innerHTML=t(e);const n=i.firstElementChild;return n||null}const l="prxy",a="conf",h="btns",d="click",c={template:({className:t,controls:e,label:i,title:n})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};const u="prxy",p="conf",g="pgidx",v="posx",m="scrl",f="time",b="grab",y="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.UpdateType=void 0,(w=t.UpdateType||(t.UpdateType={})).SCROLL="scroll",w.RESIZE="resize",w.FORCED="forced",w.FEATURE="feature",t.ScrollBehavior=void 0,(N=t.ScrollBehavior||(t.ScrollBehavior={})).AUTO="auto",N.SMOOTH="smooth";const O="prxy",C="conf",L="pags",S="btns",T={template:({className:t,controls:e,pages:i,label:n,title:s})=>`\n\t\t
    \n\t\t\t${i.map(((t,o)=>{const r={index:o,page:t,pages:i},l=n(r),a=s(r);return`
  • \n\t\t\t\t\t\n\t\t\t\t
  • `})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};const k="dims";class R{constructor(){window.addEventListener("resize",(()=>{s(this,k)}))}get dimensions(){return i(this,k,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const i=t.offsetHeight;e.style.overflow="scroll";let n=t.offsetHeight;n=i===n?e.clientHeight:n;const s=i-n;return document.body.removeChild(e),{height:s}}))}}const j="prxy",I="conf",$="mask",B="hght";let M;const A={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(t={}){n(this,I,Object.assign(Object.assign({},A),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=i(this,$))&&void 0!==t?t:null}init(t){n(this,j,t),M=null!=M?M:new R,this._render()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.RESIZE:case t.UpdateType.FORCED:s(this,B),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:s}=i(this,I);if(!t)return;const o=i(this,j).el;let{height:r}=M.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),i(this,$,(()=>{var t;const i=document.createElement(s);return i.className=e,i.style.overflow="hidden",i.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(i,o),i.appendChild(o),i}));r!==i(this,B)&&(n(this,B,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:n}=i(this,j),s=i(this,$);null===(t=null==s?void 0:s.parentNode)||void 0===t||t.insertBefore(n,s),null===(e=null==s?void 0:s.parentNode)||void 0===e||e.removeChild(s),n.removeAttribute("style")}}const U="inst",D="feat";function z(t){return i(t,U)}class W{constructor(t,e){n(this,U,t),n(this,D,e)}get id(){return z(this).id}get el(){return z(this).el}get mask(){return z(this).mask}get index(){return z(this).index}set index(t){z(this).index=t}get items(){return z(this).items}get pages(){return z(this).pages}get pageIndex(){return z(this).pageIndex}update(e){var n;z(this).update(),(n=this,i(n,D)).forEach((i=>{i!==e&&i.update({type:t.UpdateType.FEATURE})}))}}function F(t,e){let i=null;return(...n)=>{null!==i&&clearTimeout(i),i=setTimeout((()=>t(...n)),e)}}const H=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,it=/^(link|meta|noscript|script|style|title)$/i;let nt=0;const st={features:[],filterItem:()=>!0,onScroll:()=>{}};return t.Buttons=class{constructor(t={}){n(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){n(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=i(this,l),e=i(this,a),{el:n,mask:s,pages:o,pageIndex:c}=t,[u,p]=i(this,h,(()=>{const t=null!=s?s:n,{template:i,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:n.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:n.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var n,{handler:s}=e,o=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(t);s{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=i(this,l),{pages:e,pageIndex:n}=t,s=e[n-1]||e[0];t.index=s}_onNext(){const t=i(this,l),{pages:e,pageIndex:n}=t,s=e[n+1]||e[e.length-1];t.index=s}},t.Carousel=class{constructor(e,i={}){if(this.behavior=t.ScrollBehavior.AUTO,!(e&&e instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof e}" was passed.`);n(this,q,e),nt++,e.id=e.id||`caroucssel-${nt}`,n(this,"id",e.id);const s=Object.assign(Object.assign({},st),i);n(this,V,s);let o=null,r=[...s.features];const l=s.features.findIndex((t=>t instanceof P));l>-1&&([o]=r.splice(l,1)),null!=o||(o=new P),r=r.filter((t=>!(t instanceof P))),r=[o,...r],n(this,Y,o);const a=new W(this,r);switch(n(this,"proxy",a),n(this,tt,r),r.forEach((t=>t.init(a))),!0){case Array.isArray(i.index):this.index=i.index;break;case!isNaN(i.index):this.index=[i.index]}this.behavior=t.ScrollBehavior.SMOOTH,this._onScroll=F(this._onScroll.bind(this),25),this._onResize=F(this._onResize.bind(this),25),e.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}static resetInstanceCount(){}get el(){return i(this,q)}get mask(){var t;return null!==(t=i(this,Y).el)&&void 0!==t?t:null}get id(){return i(this,"id")}get index(){return i(this,X,(()=>{const{el:t,items:e}=this,{length:i}=e,{clientWidth:n}=t,s=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*i<=n&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:i,items:n}=this,{length:o}=n;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=i,a=l,h={left:n[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(s(this,X),i.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return i(this,J,(()=>{const{filterItem:t}=i(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!it.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return i(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:i}=t;if(0===i)return e.map(((t,e)=>[e]));let n=[[]];return e.map(((t,e)=>{const{offsetLeft:i,clientWidth:n}=t;return{left:i,width:n,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:s}=t,o=n[n.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===n[0]&&(l=0);let a=Math.floor((e-l+.75*s)/i);for(;a>0;)n.push([]),a--;n[n.length-1].push(t)})),n=n.filter((t=>0!==t.length)),n.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return i(this,Q,(()=>{const{el:t,items:e,index:i,pages:n}=this,s=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=i.reduce(((t,i)=>{if(!e[i])return t;let{left:n,right:r}=e[i].getBoundingClientRect();return n=Math.round(n-s),r=Math.round(r-s),n<0||o{const n=e[t].getBoundingClientRect().right;return e[i].getBoundingClientRect().right-n}))[0];return n.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;H.test(t.id)&&t.removeAttribute("id");i(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){s(this,X),s(this,J),s(this,K),s(this,Q);i(this,tt).forEach((e=>e.update({type:t.UpdateType.FORCED})))}_onScroll(e){s(this,X),s(this,Q);i(this,tt).forEach((e=>e.update({type:t.UpdateType.SCROLL})));const{index:n}=this;i(this,V).onScroll({index:n,type:G,target:this,originalEvent:e})}_onResize(){s(this,K),s(this,X),s(this,Q);i(this,tt).forEach((e=>e.update({type:t.UpdateType.RESIZE})))}},t.Mask=P,t.Mouse=class{constructor(t={}){n(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){n(this,u,t);const e=i(this,p),{el:s}=t;s.style.cursor=e.indicator?b:"",s.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const n=i(this,f);clearTimeout(n);const s=i(this,p),o=i(this,u),r=o.el;i(this,m,(()=>r.scrollLeft)),i(this,v,(()=>_(t))),i(this,g,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=s.indicator?"grabbing":"",window.addEventListener(y,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=s.onStart)||void 0===e||e.call(s,{originalEvent:t})}_onDrag(t){var e;const n=i(this,p),{el:s}=i(this,u),o=i(this,m),r=i(this,v)-_(t);s.scrollLeft=o+r,null===(e=n.onDrag)||void 0===e||e.call(n,{originalEvent:t})}_onEnd(t){var e,o;const r=i(this,u),l=i(this,p),a=i(this,m),h=i(this,g);s(this,m),s(this,v),s(this,g);const d=r.el,c=Math.min(Math.max(100,.25*d.clientWidth),250),_=d.scrollLeft-a,E=Math.abs(_);d.style.removeProperty("user-select"),d.style.removeProperty("scroll-behavior"),d.style.cursor=l.indicator?b:"";let w=r.index;if(E>c){const t=_/E,i=Math.max(h+t,0);w=null!==(e=r.pages[i])&&void 0!==e?e:w}window.requestAnimationFrame((()=>{r.index=w}));const N=window.setTimeout((()=>{d.style.removeProperty("scroll-snap-type")}),1e3);n(this,f,N),window.removeEventListener(y,this._onDrag),window.removeEventListener(x,this._onEnd),null===(o=l.onEnd)||void 0===o||o.call(l,{originalEvent:t})}},t.Pagination=class{constructor(t={}){n(this,C,Object.assign(Object.assign({},T),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){n(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.SCROLL:this._update();break;default:this._remove(),this._add()}}_add(){var t;const e=i(this,O),s=i(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=s,g=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!g)return;const v=Array.from(g.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(g),n(this,L,g),n(this,S,v),this._update()}_update(){const t=i(this,O),e=i(this,S),{pageIndex:n}=t;e.forEach(((t,e)=>t.disabled=e===n))}_remove(){var t;const e=i(this,L),n=i(this,S);null==n||n.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),s(this,S),s(this,L)}_onClick(t){const e=i(this,O),n=i(this,S),s=t.currentTarget,o=n.indexOf(s);e.index=e.pages[o]}},t.version="1.0.0",Object.defineProperty(t,"__esModule",{value:!0}),t}({}); +var caroucssel=function(t){"use strict";const e=new WeakMap;function n(t,n,i){const s=e.get(t)||{};if(n in s)return s[n];if(!i)return;const o=i();return s[n]=o,e.set(t,s),o}function i(t,n,i){const s=e.get(t)||{};s[n]=i,e.set(t,s)}function s(t,n){const i=e.get(t);i&&(i[n]=void 0,delete i[n])}function o(t){e.delete(t)}function r(t,e){const n=document.createElement("div");n.innerHTML=t(e);const i=n.firstElementChild;return i||null}const l="prxy",a="conf",h="btns",d="click",c={template:({className:t,controls:e,label:n,title:i})=>`\n\t\t\n\t`,className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"};const u="prxy",p="conf",v="pgidx",g="posx",m="scrl",f="time",b="grab",y="mousemove",x="mouseup";function _(t){return t instanceof MouseEvent?t.clientX:0}const E={indicator:!1};var w,N;t.UpdateType=void 0,(w=t.UpdateType||(t.UpdateType={})).SCROLL="scroll",w.RESIZE="resize",w.FORCED="forced",w.FEATURE="feature",t.ScrollBehavior=void 0,(N=t.ScrollBehavior||(t.ScrollBehavior={})).AUTO="auto",N.SMOOTH="smooth";const O="prxy",C="conf",L="pags",S="btns",T={template:({className:t,controls:e,pages:n,label:i,title:s})=>`\n\t\t
    \n\t\t\t${n.map(((t,o)=>{const r={index:o,page:t,pages:n},l=i(r),a=s(r);return`
  • \n\t\t\t\t\t\n\t\t\t\t
  • `})).join("")}\n\t\t
\n\t`,className:"pagination",label:({index:t})=>`${t+1}`,title:({index:t})=>`Go to ${t+1}. page`};const k="dims";class R{constructor(){window.addEventListener("resize",(()=>{s(this,k)}))}get dimensions(){return n(this,k,(()=>{const t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";const n=t.offsetHeight;e.style.overflow="scroll";let i=t.offsetHeight;i=n===i?e.clientHeight:i;const s=n-i;return document.body.removeChild(e),{height:s}}))}}const j="prxy",I="conf",$="mask",B="hght";let M;const A={enabled:!0,className:"caroucssel-mask",tagName:"div"};class P{constructor(t={}){i(this,I,Object.assign(Object.assign({},A),t))}get name(){return"buildin:mask"}get el(){var t;return null!==(t=n(this,$))&&void 0!==t?t:null}init(t){i(this,j,t),M=null!=M?M:new R,this._render()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.RESIZE:case t.UpdateType.FORCED:s(this,B),this._render();break;default:this._render()}}_render(){const{enabled:t,className:e,tagName:s}=n(this,I);if(!t)return;const o=n(this,j).el;let{height:r}=M.dimensions;o.scrollWidth<=o.clientWidth&&(r=0),n(this,$,(()=>{var t;const n=document.createElement(s);return n.className=e,n.style.overflow="hidden",n.style.height="100%",null===(t=o.parentNode)||void 0===t||t.insertBefore(n,o),n.appendChild(o),n}));r!==n(this,B)&&(i(this,B,r),o.style.height=`calc(100% + ${r}px)`,o.style.marginBottom=-1*r+"px")}_remove(){var t,e;const{el:i}=n(this,j),s=n(this,$);null===(t=null==s?void 0:s.parentNode)||void 0===t||t.insertBefore(i,s),null===(e=null==s?void 0:s.parentNode)||void 0===e||e.removeChild(s),i.removeAttribute("style")}}const U="inst",D="feat";function z(t){return n(t,U)}class W{constructor(t,e){i(this,U,t),i(this,D,e)}get id(){return z(this).id}get el(){return z(this).el}get mask(){return z(this).mask}get index(){return z(this).index}set index(t){z(this).index=t}get items(){return z(this).items}get pages(){return z(this).pages}get pageIndex(){return z(this).pageIndex}update(e){var i;z(this).update(),(i=this,n(i,D)).forEach((n=>{n!==e&&n.update({type:t.UpdateType.FEATURE})}))}}function F(t,e){let n=null;return(...i)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>t(...i)),e)}}const H=/^caroucssel-[0-9]*$/,G="scroll",Z="resize",q="element",V="config",X="index",J="items",K="pages",Q="page-index",Y="mask",tt="feautres",et=.25,nt=/^(link|meta|noscript|script|style|title)$/i;let it=0;const st={features:[],filterItem:()=>!0,onScroll:()=>{}};return t.Buttons=class{constructor(t={}){i(this,a,Object.assign(Object.assign({},c),t)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}get name(){return"buildin:buttons"}init(t){i(this,l,t),this._render()}destroy(){this._remove(),o(this)}update(){this._render()}_render(){const t=n(this,l),e=n(this,a),{el:i,mask:s,pages:o,pageIndex:c}=t,[u,p]=n(this,h,(()=>{const t=null!=s?s:i,{template:n,className:o,previousClassName:l,previousLabel:a,previousTitle:h,nextClassName:c,nextLabel:u,nextTitle:p}=e;return[{controls:i.id,label:u,title:p,className:[o,c].join(" "),handler:this._onNext},{controls:i.id,label:a,title:h,className:[o,l].join(" "),handler:this._onPrev}].map((e=>{var i,{handler:s}=e,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s{var e;null==t||t.removeEventListener(d,this._onPrev),null==t||t.removeEventListener(d,this._onNext),null===(e=null==t?void 0:t.parentNode)||void 0===e||e.removeChild(t)}))}_onPrev(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i-1]||e[0];t.index=s}_onNext(){const t=n(this,l),{pages:e,pageIndex:i}=t,s=e[i+1]||e[e.length-1];t.index=s}},t.Carousel=class{constructor(e,n={}){if(this.behavior=t.ScrollBehavior.AUTO,!(e&&e instanceof Element))throw new Error(`Carousel needs a dom element but "${typeof e}" was passed.`);i(this,q,e),it++,e.id=e.id||`caroucssel-${it}`,i(this,"id",e.id);const s=Object.assign(Object.assign({},st),n);i(this,V,s);let o=null,r=[...s.features];const l=s.features.findIndex((t=>t instanceof P));l>-1&&([o]=r.splice(l,1)),null!=o||(o=new P),r=r.filter((t=>!(t instanceof P))),r=[o,...r],i(this,Y,o);const a=new W(this,r);switch(i(this,"proxy",a),i(this,tt,r),r.forEach((t=>t.init(a))),!0){case Array.isArray(n.index):this.index=n.index;break;case!isNaN(n.index):this.index=[n.index]}this.behavior=t.ScrollBehavior.SMOOTH,this._onScroll=F(this._onScroll.bind(this),25),this._onResize=F(this._onResize.bind(this),25),e.addEventListener(G,this._onScroll),window.addEventListener(Z,this._onResize)}static resetInstanceCount(){}get el(){return n(this,q)}get mask(){var t;return null!==(t=n(this,Y).el)&&void 0!==t?t:null}get id(){return n(this,"id")}get index(){return n(this,X,(()=>{const{el:t,items:e}=this,{length:n}=e,{clientWidth:i}=t,s=t.getBoundingClientRect().left,o=[];let r=0;for(;r=0&&l+.75*n<=i&&o.push(r)}return 0===o.length?[0]:o}))}set index(t){const{behavior:e,el:n,items:i}=this,{length:o}=i;if(!Array.isArray(t)||!t.length)return;let r=t[0]||0;r=Math.max(Math.min(r,o-1),0);const{scrollLeft:l}=n,a=l,h={left:i[r].offsetLeft};r===this.pages[0][0]&&(h.left=0),a!==h.left&&(s(this,X),n.scrollTo(Object.assign(Object.assign({},h),{behavior:e})))}get items(){return n(this,J,(()=>{const{filterItem:t}=n(this,V),{el:e}=this;return Array.from(e.children).filter((t=>!nt.test(t.tagName)&&!t.hidden)).filter(t)}))}get pages(){return n(this,K,(()=>{const{el:t,items:e}=this,{clientWidth:n}=t;if(0===n)return e.map(((t,e)=>[e]));let i=[[]];return e.map(((t,e)=>{const{offsetLeft:n,clientWidth:i}=t;return{left:n,width:i,item:t,index:e}})).sort(((t,e)=>t.left-e.left)).forEach((t=>{const{left:e,width:s}=t,o=i[i.length-1],r=o[0];let l=(null==r?void 0:r.left)||0;o===i[0]&&(l=0);let a=Math.floor((e-l+.75*s)/n);for(;a>0;)i.push([]),a--;i[i.length-1].push(t)})),i=i.filter((t=>0!==t.length)),i.map((t=>t.map((({index:t})=>t))))}))}get pageIndex(){return n(this,Q,(()=>{const{el:t,items:e,index:n,pages:i}=this,s=t.getBoundingClientRect().left,{clientWidth:o}=t;let r=n.reduce(((t,n)=>{if(!e[n])return t;let{left:i,right:r}=e[n].getBoundingClientRect();return i=Math.round(i-s),r=Math.round(r-s),i<0||o{const i=e[t].getBoundingClientRect().right;return e[n].getBoundingClientRect().right-i}))[0];return i.findIndex((t=>t.includes(l)))}))}destroy(){const{el:t}=this;H.test(t.id)&&t.removeAttribute("id");n(this,tt).forEach((t=>t.destroy())),t.removeEventListener(G,this._onScroll),window.removeEventListener(Z,this._onResize),o(this)}update(){s(this,X),s(this,J),s(this,K),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.FORCED})))}_onScroll(e){s(this,X),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.SCROLL})));const{index:i}=this;n(this,V).onScroll({index:i,type:G,target:this,originalEvent:e})}_onResize(){s(this,K),s(this,X),s(this,Q);n(this,tt).forEach((e=>e.update({type:t.UpdateType.RESIZE})))}},t.Mask=P,t.Mouse=class{constructor(t={}){i(this,p,Object.assign(Object.assign({},E),t)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}get name(){return"buildin:mouse"}init(t){i(this,u,t);const e=n(this,p),{el:s}=t;s.style.cursor=e.indicator?b:"",s.addEventListener("mousedown",this._onStart,{passive:!0})}destroy(){o(this)}update(){}_onStart(t){var e;const i=n(this,f);clearTimeout(i);const s=n(this,p),o=n(this,u),r=o.el;n(this,m,(()=>r.scrollLeft)),n(this,g,(()=>_(t))),n(this,v,(()=>o.pageIndex)),r.style.userSelect="none",r.style.scrollBehavior="auto",r.style.scrollSnapType="none",r.style.cursor=s.indicator?"grabbing":"",window.addEventListener(y,this._onDrag,{passive:!0}),window.addEventListener(x,this._onEnd,{passive:!0}),null===(e=s.onStart)||void 0===e||e.call(s,{originalEvent:t})}_onDrag(t){var e,i,s;const o=n(this,p),{el:r}=n(this,u),l=null!==(e=n(this,m))&&void 0!==e?e:0,a=(null!==(i=n(this,g))&&void 0!==i?i:0)-_(t);r.scrollLeft=l+a,null===(s=o.onDrag)||void 0===s||s.call(o,{originalEvent:t})}_onEnd(t){var e,o,r,l;const a=n(this,u),h=n(this,p),d=null!==(e=n(this,m))&&void 0!==e?e:0,c=null!==(o=n(this,v))&&void 0!==o?o:0;s(this,m),s(this,g),s(this,v);const _=a.el,E=Math.min(Math.max(100,.25*_.clientWidth),250),w=_.scrollLeft-d,N=Math.abs(w);_.style.removeProperty("user-select"),_.style.removeProperty("scroll-behavior"),_.style.cursor=h.indicator?b:"";let O=a.index;if(N>E){const t=w/N,e=Math.max(c+t,0);O=null!==(r=a.pages[e])&&void 0!==r?r:O}window.requestAnimationFrame((()=>{a.index=O}));const C=window.setTimeout((()=>{_.style.removeProperty("scroll-snap-type")}),1e3);i(this,f,C),window.removeEventListener(y,this._onDrag),window.removeEventListener(x,this._onEnd),null===(l=h.onEnd)||void 0===l||l.call(h,{originalEvent:t})}},t.Pagination=class{constructor(t={}){i(this,C,Object.assign(Object.assign({},T),t)),this._onClick=this._onClick.bind(this)}get name(){return"buildin:pagination"}init(t){i(this,O,t),this._add()}destroy(){this._remove(),o(this)}update(e){switch(e.type){case t.UpdateType.SCROLL:this._update();break;default:this._remove(),this._add()}}_add(){var t;const e=n(this,O),s=n(this,C),{el:o,mask:l,pages:a}=e,h=null!=l?l:o;if(a.length<2)return;const{template:d,className:c,label:u,title:p}=s,v=r(d,{label:u,title:p,pages:a,className:c,controls:o.id});if(!v)return;const g=Array.from(v.querySelectorAll("button")).map((t=>(t.addEventListener("click",this._onClick,!0),t)));null===(t=h.parentNode)||void 0===t||t.appendChild(v),i(this,L,v),i(this,S,g),this._update()}_update(){const t=n(this,O),e=n(this,S),{pageIndex:i}=t;null==e||e.forEach(((t,e)=>t.disabled=e===i))}_remove(){var t;const e=n(this,L),i=n(this,S);null==i||i.forEach((t=>{var e;t.removeEventListener("click",this._onClick),null===(e=t.parentNode)||void 0===e||e.removeChild(t)})),null===(t=null==e?void 0:e.parentNode)||void 0===t||t.removeChild(e),s(this,S),s(this,L)}_onClick(t){const e=n(this,O),i=n(this,S);if(!i)return;const s=t.currentTarget,o=i.indexOf(s);e.index=e.pages[o]}},t.version="1.0.1",Object.defineProperty(t,"__esModule",{value:!0}),t}({}); diff --git a/dist/formats/umd/caroucssel.js b/dist/formats/umd/caroucssel.js index 183b73d4..ee853d26 100644 --- a/dist/formats/umd/caroucssel.js +++ b/dist/formats/umd/caroucssel.js @@ -245,7 +245,7 @@ var _this2 = this; var buttons = fromCache(this, CACHE_KEY_BUTTONS$1); - buttons.forEach(function (button) { + buttons === null || buttons === void 0 ? void 0 : buttons.forEach(function (button) { var _a; button === null || button === void 0 ? void 0 : button.removeEventListener(EVENT_CLICK, _this2._onPrev); @@ -378,33 +378,33 @@ }, { key: "_onDrag", value: function _onDrag(event) { - var _a; + var _a, _b, _c; var config = fromCache(this, CACHE_KEY_CONFIGURATION$3); var _fromCache3 = fromCache(this, CACHE_KEY_PROXY$3), el = _fromCache3.el; - var left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - var x = fromCache(this, CACHE_KEY_POSITION_X); + var left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + var x = (_b = fromCache(this, CACHE_KEY_POSITION_X)) !== null && _b !== void 0 ? _b : 0; var currentX = __getPositionX(event); var deltaX = x - currentX; el.scrollLeft = left + deltaX; - (_a = config.onDrag) === null || _a === void 0 ? void 0 : _a.call(config, { + (_c = config.onDrag) === null || _c === void 0 ? void 0 : _c.call(config, { originalEvent: event }); } }, { key: "_onEnd", value: function _onEnd(event) { - var _a, _b; + var _a, _b, _c, _d; var proxy = fromCache(this, CACHE_KEY_PROXY$3); var config = fromCache(this, CACHE_KEY_CONFIGURATION$3); - var left = fromCache(this, CACHE_KEY_SCROLL_LEFT); - var pageIndex = fromCache(this, CACHE_KEY_PAGE_INDEX$1); + var left = (_a = fromCache(this, CACHE_KEY_SCROLL_LEFT)) !== null && _a !== void 0 ? _a : 0; + var pageIndex = (_b = fromCache(this, CACHE_KEY_PAGE_INDEX$1)) !== null && _b !== void 0 ? _b : 0; clearCache(this, CACHE_KEY_SCROLL_LEFT); clearCache(this, CACHE_KEY_POSITION_X); clearCache(this, CACHE_KEY_PAGE_INDEX$1); @@ -421,7 +421,7 @@ if (offset > threshold) { var direction = distance / offset; var at = Math.max(pageIndex + direction, 0); - index = (_a = proxy.pages[at]) !== null && _a !== void 0 ? _a : index; + index = (_c = proxy.pages[at]) !== null && _c !== void 0 ? _c : index; } window.requestAnimationFrame(function () { @@ -433,7 +433,7 @@ writeCache(this, CACHE_KEY_TIMEOUT, timeout); window.removeEventListener(EVENT_DRAG, this._onDrag); window.removeEventListener(EVENT_END, this._onEnd); - (_b = config.onEnd) === null || _b === void 0 ? void 0 : _b.call(config, { + (_d = config.onEnd) === null || _d === void 0 ? void 0 : _d.call(config, { originalEvent: event }); } @@ -591,7 +591,7 @@ var proxy = fromCache(this, CACHE_KEY_PROXY$2); var buttons = fromCache(this, CACHE_KEY_BUTTONS); var pageIndex = proxy.pageIndex; - buttons.forEach(function (button, at) { + buttons === null || buttons === void 0 ? void 0 : buttons.forEach(function (button, at) { return button.disabled = at === pageIndex; }); } @@ -619,6 +619,11 @@ value: function _onClick(event) { var proxy = fromCache(this, CACHE_KEY_PROXY$2); var buttons = fromCache(this, CACHE_KEY_BUTTONS); + + if (!buttons) { + return; + } + var target = event.currentTarget; var index = buttons.indexOf(target); proxy.index = proxy.pages[index]; @@ -1268,6 +1273,6 @@ }(); _exports.Carousel = Carousel; - var version = '1.0.0'; + var version = '1.0.1'; _exports.version = version; }); diff --git a/dist/formats/umd/caroucssel.min.js b/dist/formats/umd/caroucssel.min.js index 1d2f4b79..1c0d3353 100644 --- a/dist/formats/umd/caroucssel.min.js +++ b/dist/formats/umd/caroucssel.min.js @@ -1 +1 @@ -!function(t,e){if("function"==typeof define&&define.amd)define("caroucssel",["exports"],e);else if("undefined"!=typeof exports)e(exports);else{var n={exports:{}};e(n.exports),t.caroucssel=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t){function e(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var i,r,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);a=!0);}catch(t){s=!0,r=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return o}(t,e)||r(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n\n\t\t\t').concat(i,"\n\t\t\n\t")},className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"},x=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,y,Object.assign(Object.assign({},b),e)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:buttons"}},{key:"init",value:function(t){h(this,p,t),this._render()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(){this._render()}},{key:"_render",value:function(){var t=this,e=c(this,p),n=c(this,y),r=e.el,o=e.mask,a=e.pages,s=e.pageIndex,l=i(c(this,m,(function(){var e=null!=o?o:r,i=n.template,a=n.className,s=n.previousClassName,l=n.previousLabel,u=n.previousTitle,c=n.nextClassName,h=n.nextLabel,f=n.nextTitle;return[{controls:r.id,label:h,title:f,className:[a,c].join(" "),handler:t._onNext},{controls:r.id,label:l,title:u,className:[a,s].join(" "),handler:t._onPrev}].map((function(t){var n,r=t.handler,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,_,Object.assign(Object.assign({},I),e)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:mouse"}},{key:"init",value:function(t){h(this,k,t);var e=c(this,_),n=t.el;n.style.cursor=e.indicator?C:"",n.addEventListener("mousedown",this._onStart,{passive:!0})}},{key:"destroy",value:function(){d(this)}},{key:"update",value:function(){}},{key:"_onStart",value:function(t){var e,n=c(this,O);clearTimeout(n);var i=c(this,_),r=c(this,k),o=r.el;c(this,S,(function(){return o.scrollLeft})),c(this,w,(function(){return T(t)})),c(this,E,(function(){return r.pageIndex})),o.style.userSelect="none",o.style.scrollBehavior="auto",o.style.scrollSnapType="none",o.style.cursor=i.indicator?"grabbing":"",window.addEventListener(N,this._onDrag,{passive:!0}),window.addEventListener(L,this._onEnd,{passive:!0}),null===(e=i.onStart)||void 0===e||e.call(i,{originalEvent:t})}},{key:"_onDrag",value:function(t){var e,n=c(this,_),i=c(this,k).el,r=c(this,S),o=c(this,w)-T(t);i.scrollLeft=r+o,null===(e=n.onDrag)||void 0===e||e.call(n,{originalEvent:t})}},{key:"_onEnd",value:function(t){var e,n,i=c(this,k),r=c(this,_),o=c(this,S),a=c(this,E);f(this,S),f(this,w),f(this,E);var s=i.el,l=Math.min(Math.max(100,.25*s.clientWidth),250),u=s.scrollLeft-o,d=Math.abs(u);s.style.removeProperty("user-select"),s.style.removeProperty("scroll-behavior"),s.style.cursor=r.indicator?C:"";var v=i.index;if(d>l){var p=u/d,y=Math.max(a+p,0);v=null!==(e=i.pages[y])&&void 0!==e?e:v}window.requestAnimationFrame((function(){i.index=v}));var m=window.setTimeout((function(){s.style.removeProperty("scroll-snap-type")}),1e3);h(this,O,m),window.removeEventListener(N,this._onDrag),window.removeEventListener(L,this._onEnd),null===(n=r.onEnd)||void 0===n||n.call(r,{originalEvent:t})}}]),t}();t.Mouse=R,t.UpdateType=j,function(t){t.SCROLL="scroll",t.RESIZE="resize",t.FORCED="forced",t.FEATURE="feature"}(j||(t.UpdateType=j={})),t.ScrollBehavior=A,function(t){t.AUTO="auto",t.SMOOTH="smooth"}(A||(t.ScrollBehavior=A={}));var M="prxy",B="conf",P="pags",D="btns",z={template:function(t){var e=t.className,n=t.controls,i=t.pages,r=t.label,o=t.title;return'\n\t\t
    \n\t\t\t').concat(i.map((function(t,e){var a={index:e,page:t,pages:i},s=r(a),l=o(a);return'
  • \n\t\t\t\t\t\n\t\t\t\t
  • ")})).join(""),"\n\t\t
\n\t")},className:"pagination",label:function(t){var e=t.index;return"".concat(e+1)},title:function(t){var e=t.index;return"Go to ".concat(e+1,". page")}},U=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,B,Object.assign(Object.assign({},z),e)),this._onClick=this._onClick.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:pagination"}},{key:"init",value:function(t){h(this,M,t),this._add()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(t){switch(t.type){case j.SCROLL:this._update();break;default:this._remove(),this._add()}}},{key:"_add",value:function(){var t,e=this,n=c(this,M),i=c(this,B),r=n.el,o=n.mask,a=n.pages,s=null!=o?o:r;if(!(a.length<2)){var l=i.template,u=i.className,f=v(l,{label:i.label,title:i.title,pages:a,className:u,controls:r.id});if(f){var d=Array.from(f.querySelectorAll("button")).map((function(t){return t.addEventListener("click",e._onClick,!0),t}));null===(t=s.parentNode)||void 0===t||t.appendChild(f),h(this,P,f),h(this,D,d),this._update()}}}},{key:"_update",value:function(){var t=c(this,M),e=c(this,D),n=t.pageIndex;e.forEach((function(t,e){return t.disabled=e===n}))}},{key:"_remove",value:function(){var t,e=this,n=c(this,P),i=c(this,D);null==i||i.forEach((function(t){var n;t.removeEventListener("click",e._onClick),null===(n=t.parentNode)||void 0===n||n.removeChild(t)})),null===(t=null==n?void 0:n.parentNode)||void 0===t||t.removeChild(n),f(this,D),f(this,P)}},{key:"_onClick",value:function(t){var e=c(this,M),n=c(this,D),i=t.currentTarget,r=n.indexOf(i);e.index=e.pages[r]}}]),t}();t.Pagination=U;var W,F="dims",H=function(){function t(){var e=this;a(this,t),window.addEventListener("resize",(function(){f(e,F)}))}return l(t,[{key:"dimensions",get:function(){return c(this,F,(function(){var t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";var n=t.offsetHeight;e.style.overflow="scroll";var i=t.offsetHeight,r=n-(i=n===i?e.clientHeight:i);return document.body.removeChild(e),{height:r}}))}}]),t}(),G="prxy",Z="conf",$="mask",q="hght",V={enabled:!0,className:"caroucssel-mask",tagName:"div"},X=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,Z,Object.assign(Object.assign({},V),e))}return l(t,[{key:"name",get:function(){return"buildin:mask"}},{key:"el",get:function(){var t;return null!==(t=c(this,$))&&void 0!==t?t:null}},{key:"init",value:function(t){h(this,G,t),W=null!=W?W:new H,this._render()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(t){switch(t.type){case j.RESIZE:case j.FORCED:f(this,q),this._render();break;default:this._render()}}},{key:"_render",value:function(){var t=c(this,Z),e=t.enabled,n=t.className,i=t.tagName;if(e){var r=c(this,G).el,o=W.dimensions.height;r.scrollWidth<=r.clientWidth&&(o=0),c(this,$,(function(){var t,e=document.createElement(i);return e.className=n,e.style.overflow="hidden",e.style.height="100%",null===(t=r.parentNode)||void 0===t||t.insertBefore(e,r),e.appendChild(r),e})),o!==c(this,q)&&(h(this,q,o),r.style.height="calc(100% + ".concat(o,"px)"),r.style.marginBottom="".concat(-1*o,"px"))}}},{key:"_remove",value:function(){var t,e,n=c(this,G).el,i=c(this,$);null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(n,i),null===(e=null==i?void 0:i.parentNode)||void 0===e||e.removeChild(i),n.removeAttribute("style")}}]),t}();t.Mask=X;var J="inst",K="feat";function Q(t){return c(t,J)}var Y=function(){function t(e,n){a(this,t),h(this,J,e),h(this,K,n)}return l(t,[{key:"id",get:function(){return Q(this).id}},{key:"el",get:function(){return Q(this).el}},{key:"mask",get:function(){return Q(this).mask}},{key:"index",get:function(){return Q(this).index},set:function(t){Q(this).index=t}},{key:"items",get:function(){return Q(this).items}},{key:"pages",get:function(){return Q(this).pages}},{key:"pageIndex",get:function(){return Q(this).pageIndex}},{key:"update",value:function(t){var e;Q(this).update(),(e=this,c(e,K)).forEach((function(e){e!==t&&e.update({type:j.FEATURE})}))}}]),t}();function tt(t,e){var n=null;return function(){for(var i=arguments.length,r=new Array(i),o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if(a(this,t),this.behavior=A.AUTO,!(r&&r instanceof Element))throw new Error('Carousel needs a dom element but "'.concat(n(r),'" was passed.'));h(this,ot,r),mt++,r.id=r.id||et(mt),h(this,at,r.id);var s=Object.assign(Object.assign({},gt),o);h(this,st,s);var l=null,u=e(s.features),c=s.features.findIndex((function(t){return t instanceof X}));if(c>-1){var f=u.splice(c,1),d=i(f,1);l=d[0]}null!=l||(l=new X),u=u.filter((function(t){return!(t instanceof X)})),u=[l].concat(e(u)),h(this,ft,l);var v=new Y(this,u);switch(h(this,dt,v),h(this,vt,u),u.forEach((function(t){return t.init(v)})),!0){case Array.isArray(o.index):this.index=o.index;break;case!isNaN(o.index):this.index=[o.index]}this.behavior=A.SMOOTH,this._onScroll=tt(this._onScroll.bind(this),25),this._onResize=tt(this._onResize.bind(this),25),r.addEventListener(it,this._onScroll),window.addEventListener(rt,this._onResize)}return l(t,[{key:"el",get:function(){return c(this,ot)}},{key:"mask",get:function(){var t;return null!==(t=c(this,ft).el)&&void 0!==t?t:null}},{key:"id",get:function(){return c(this,at)}},{key:"index",get:function(){var t=this;return c(this,lt,(function(){for(var e=t.el,n=t.items,i=n.length,r=e.clientWidth,o=e.getBoundingClientRect().left,a=[],s=0;s=0&&c+.75*u<=r&&a.push(s)}return 0===a.length?[0]:a}))},set:function(t){var e=this.behavior,n=this.el,i=this.items,r=i.length;if(Array.isArray(t)&&t.length){var o=t[0]||0;o=Math.max(Math.min(o,r-1),0);var a=n.scrollLeft,s={left:i[o].offsetLeft};o===this.pages[0][0]&&(s.left=0),a!==s.left&&(f(this,lt),n.scrollTo(Object.assign(Object.assign({},s),{behavior:e})))}}},{key:"items",get:function(){var t=this;return c(this,ut,(function(){var e=c(t,st).filterItem,n=t.el;return Array.from(n.children).filter((function(t){return!yt.test(t.tagName)&&!t.hidden})).filter(e)}))}},{key:"pages",get:function(){var t=this;return c(this,ct,(function(){var e=t.el,n=t.items,i=e.clientWidth;if(0===i)return n.map((function(t,e){return[e]}));var r=[[]];return n.map((function(t,e){return{left:t.offsetLeft,width:t.clientWidth,item:t,index:e}})).sort((function(t,e){return t.left-e.left})).forEach((function(t){var e=t.left,n=t.width,o=r[r.length-1],a=o[0],s=(null==a?void 0:a.left)||0;o===r[0]&&(s=0);for(var l=Math.floor((e-s+.75*n)/i);l>0;)r.push([]),l--;r[r.length-1].push(t)})),(r=r.filter((function(t){return 0!==t.length}))).map((function(t){return t.map((function(t){return t.index}))}))}))}},{key:"pageIndex",get:function(){var t=this;return c(this,ht,(function(){var e=t.el,n=t.items,i=t.index,r=t.pages,o=e.getBoundingClientRect().left,a=e.clientWidth,s=i.reduce((function(t,e){if(!n[e])return t;var i=n[e].getBoundingClientRect(),r=i.left,s=i.right;return r=Math.round(r-o),s=Math.round(s-o),r<0||at.length)&&(e=t.length);for(var n=0,i=new Array(e);n\n\t\t\t').concat(i,"\n\t\t\n\t")},className:"button",nextClassName:"is-next",nextLabel:"Next",nextTitle:"Go to next",previousClassName:"is-previous",previousLabel:"Previous",previousTitle:"Go to previous"},x=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,y,Object.assign(Object.assign({},b),e)),this._onPrev=this._onPrev.bind(this),this._onNext=this._onNext.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:buttons"}},{key:"init",value:function(t){h(this,p,t),this._render()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(){this._render()}},{key:"_render",value:function(){var t=this,e=c(this,p),n=c(this,y),r=e.el,o=e.mask,a=e.pages,s=e.pageIndex,l=i(c(this,m,(function(){var e=null!=o?o:r,i=n.template,a=n.className,s=n.previousClassName,l=n.previousLabel,u=n.previousTitle,c=n.nextClassName,h=n.nextLabel,f=n.nextTitle;return[{controls:r.id,label:h,title:f,className:[a,c].join(" "),handler:t._onNext},{controls:r.id,label:l,title:u,className:[a,s].join(" "),handler:t._onPrev}].map((function(t){var n,r=t.handler,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,_,Object.assign(Object.assign({},I),e)),this._onStart=this._onStart.bind(this),this._onDrag=this._onDrag.bind(this),this._onEnd=this._onEnd.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:mouse"}},{key:"init",value:function(t){h(this,k,t);var e=c(this,_),n=t.el;n.style.cursor=e.indicator?C:"",n.addEventListener("mousedown",this._onStart,{passive:!0})}},{key:"destroy",value:function(){d(this)}},{key:"update",value:function(){}},{key:"_onStart",value:function(t){var e,n=c(this,O);clearTimeout(n);var i=c(this,_),r=c(this,k),o=r.el;c(this,S,(function(){return o.scrollLeft})),c(this,w,(function(){return T(t)})),c(this,E,(function(){return r.pageIndex})),o.style.userSelect="none",o.style.scrollBehavior="auto",o.style.scrollSnapType="none",o.style.cursor=i.indicator?"grabbing":"",window.addEventListener(N,this._onDrag,{passive:!0}),window.addEventListener(L,this._onEnd,{passive:!0}),null===(e=i.onStart)||void 0===e||e.call(i,{originalEvent:t})}},{key:"_onDrag",value:function(t){var e,n,i,r=c(this,_),o=c(this,k).el,a=null!==(e=c(this,S))&&void 0!==e?e:0,s=(null!==(n=c(this,w))&&void 0!==n?n:0)-T(t);o.scrollLeft=a+s,null===(i=r.onDrag)||void 0===i||i.call(r,{originalEvent:t})}},{key:"_onEnd",value:function(t){var e,n,i,r,o=c(this,k),a=c(this,_),s=null!==(e=c(this,S))&&void 0!==e?e:0,l=null!==(n=c(this,E))&&void 0!==n?n:0;f(this,S),f(this,w),f(this,E);var u=o.el,d=Math.min(Math.max(100,.25*u.clientWidth),250),v=u.scrollLeft-s,p=Math.abs(v);u.style.removeProperty("user-select"),u.style.removeProperty("scroll-behavior"),u.style.cursor=a.indicator?C:"";var y=o.index;if(p>d){var m=v/p,g=Math.max(l+m,0);y=null!==(i=o.pages[g])&&void 0!==i?i:y}window.requestAnimationFrame((function(){o.index=y}));var b=window.setTimeout((function(){u.style.removeProperty("scroll-snap-type")}),1e3);h(this,O,b),window.removeEventListener(N,this._onDrag),window.removeEventListener(L,this._onEnd),null===(r=a.onEnd)||void 0===r||r.call(a,{originalEvent:t})}}]),t}();t.Mouse=R,t.UpdateType=j,function(t){t.SCROLL="scroll",t.RESIZE="resize",t.FORCED="forced",t.FEATURE="feature"}(j||(t.UpdateType=j={})),t.ScrollBehavior=A,function(t){t.AUTO="auto",t.SMOOTH="smooth"}(A||(t.ScrollBehavior=A={}));var M="prxy",B="conf",P="pags",D="btns",z={template:function(t){var e=t.className,n=t.controls,i=t.pages,r=t.label,o=t.title;return'\n\t\t
    \n\t\t\t').concat(i.map((function(t,e){var a={index:e,page:t,pages:i},s=r(a),l=o(a);return'
  • \n\t\t\t\t\t\n\t\t\t\t
  • ")})).join(""),"\n\t\t
\n\t")},className:"pagination",label:function(t){var e=t.index;return"".concat(e+1)},title:function(t){var e=t.index;return"Go to ".concat(e+1,". page")}},U=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,B,Object.assign(Object.assign({},z),e)),this._onClick=this._onClick.bind(this)}return l(t,[{key:"name",get:function(){return"buildin:pagination"}},{key:"init",value:function(t){h(this,M,t),this._add()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(t){switch(t.type){case j.SCROLL:this._update();break;default:this._remove(),this._add()}}},{key:"_add",value:function(){var t,e=this,n=c(this,M),i=c(this,B),r=n.el,o=n.mask,a=n.pages,s=null!=o?o:r;if(!(a.length<2)){var l=i.template,u=i.className,f=v(l,{label:i.label,title:i.title,pages:a,className:u,controls:r.id});if(f){var d=Array.from(f.querySelectorAll("button")).map((function(t){return t.addEventListener("click",e._onClick,!0),t}));null===(t=s.parentNode)||void 0===t||t.appendChild(f),h(this,P,f),h(this,D,d),this._update()}}}},{key:"_update",value:function(){var t=c(this,M),e=c(this,D),n=t.pageIndex;null==e||e.forEach((function(t,e){return t.disabled=e===n}))}},{key:"_remove",value:function(){var t,e=this,n=c(this,P),i=c(this,D);null==i||i.forEach((function(t){var n;t.removeEventListener("click",e._onClick),null===(n=t.parentNode)||void 0===n||n.removeChild(t)})),null===(t=null==n?void 0:n.parentNode)||void 0===t||t.removeChild(n),f(this,D),f(this,P)}},{key:"_onClick",value:function(t){var e=c(this,M),n=c(this,D);if(n){var i=t.currentTarget,r=n.indexOf(i);e.index=e.pages[r]}}}]),t}();t.Pagination=U;var W,F="dims",H=function(){function t(){var e=this;a(this,t),window.addEventListener("resize",(function(){f(e,F)}))}return l(t,[{key:"dimensions",get:function(){return c(this,F,(function(){var t=document.createElement("div"),e=document.createElement("div");document.body.appendChild(e),e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.appendChild(t),t.style.width="200px",t.style.height="100%",e.style.width="150px",e.style.height="200px",e.style.overflow="hidden";var n=t.offsetHeight;e.style.overflow="scroll";var i=t.offsetHeight,r=n-(i=n===i?e.clientHeight:i);return document.body.removeChild(e),{height:r}}))}}]),t}(),G="prxy",Z="conf",$="mask",q="hght",V={enabled:!0,className:"caroucssel-mask",tagName:"div"},X=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),h(this,Z,Object.assign(Object.assign({},V),e))}return l(t,[{key:"name",get:function(){return"buildin:mask"}},{key:"el",get:function(){var t;return null!==(t=c(this,$))&&void 0!==t?t:null}},{key:"init",value:function(t){h(this,G,t),W=null!=W?W:new H,this._render()}},{key:"destroy",value:function(){this._remove(),d(this)}},{key:"update",value:function(t){switch(t.type){case j.RESIZE:case j.FORCED:f(this,q),this._render();break;default:this._render()}}},{key:"_render",value:function(){var t=c(this,Z),e=t.enabled,n=t.className,i=t.tagName;if(e){var r=c(this,G).el,o=W.dimensions.height;r.scrollWidth<=r.clientWidth&&(o=0),c(this,$,(function(){var t,e=document.createElement(i);return e.className=n,e.style.overflow="hidden",e.style.height="100%",null===(t=r.parentNode)||void 0===t||t.insertBefore(e,r),e.appendChild(r),e})),o!==c(this,q)&&(h(this,q,o),r.style.height="calc(100% + ".concat(o,"px)"),r.style.marginBottom="".concat(-1*o,"px"))}}},{key:"_remove",value:function(){var t,e,n=c(this,G).el,i=c(this,$);null===(t=null==i?void 0:i.parentNode)||void 0===t||t.insertBefore(n,i),null===(e=null==i?void 0:i.parentNode)||void 0===e||e.removeChild(i),n.removeAttribute("style")}}]),t}();t.Mask=X;var J="inst",K="feat";function Q(t){return c(t,J)}var Y=function(){function t(e,n){a(this,t),h(this,J,e),h(this,K,n)}return l(t,[{key:"id",get:function(){return Q(this).id}},{key:"el",get:function(){return Q(this).el}},{key:"mask",get:function(){return Q(this).mask}},{key:"index",get:function(){return Q(this).index},set:function(t){Q(this).index=t}},{key:"items",get:function(){return Q(this).items}},{key:"pages",get:function(){return Q(this).pages}},{key:"pageIndex",get:function(){return Q(this).pageIndex}},{key:"update",value:function(t){var e;Q(this).update(),(e=this,c(e,K)).forEach((function(e){e!==t&&e.update({type:j.FEATURE})}))}}]),t}();function tt(t,e){var n=null;return function(){for(var i=arguments.length,r=new Array(i),o=0;o1&&void 0!==arguments[1]?arguments[1]:{};if(a(this,t),this.behavior=A.AUTO,!(r&&r instanceof Element))throw new Error('Carousel needs a dom element but "'.concat(n(r),'" was passed.'));h(this,ot,r),mt++,r.id=r.id||et(mt),h(this,at,r.id);var s=Object.assign(Object.assign({},gt),o);h(this,st,s);var l=null,u=e(s.features),c=s.features.findIndex((function(t){return t instanceof X}));if(c>-1){var f=u.splice(c,1),d=i(f,1);l=d[0]}null!=l||(l=new X),u=u.filter((function(t){return!(t instanceof X)})),u=[l].concat(e(u)),h(this,ft,l);var v=new Y(this,u);switch(h(this,dt,v),h(this,vt,u),u.forEach((function(t){return t.init(v)})),!0){case Array.isArray(o.index):this.index=o.index;break;case!isNaN(o.index):this.index=[o.index]}this.behavior=A.SMOOTH,this._onScroll=tt(this._onScroll.bind(this),25),this._onResize=tt(this._onResize.bind(this),25),r.addEventListener(it,this._onScroll),window.addEventListener(rt,this._onResize)}return l(t,[{key:"el",get:function(){return c(this,ot)}},{key:"mask",get:function(){var t;return null!==(t=c(this,ft).el)&&void 0!==t?t:null}},{key:"id",get:function(){return c(this,at)}},{key:"index",get:function(){var t=this;return c(this,lt,(function(){for(var e=t.el,n=t.items,i=n.length,r=e.clientWidth,o=e.getBoundingClientRect().left,a=[],s=0;s=0&&c+.75*u<=r&&a.push(s)}return 0===a.length?[0]:a}))},set:function(t){var e=this.behavior,n=this.el,i=this.items,r=i.length;if(Array.isArray(t)&&t.length){var o=t[0]||0;o=Math.max(Math.min(o,r-1),0);var a=n.scrollLeft,s={left:i[o].offsetLeft};o===this.pages[0][0]&&(s.left=0),a!==s.left&&(f(this,lt),n.scrollTo(Object.assign(Object.assign({},s),{behavior:e})))}}},{key:"items",get:function(){var t=this;return c(this,ut,(function(){var e=c(t,st).filterItem,n=t.el;return Array.from(n.children).filter((function(t){return!yt.test(t.tagName)&&!t.hidden})).filter(e)}))}},{key:"pages",get:function(){var t=this;return c(this,ct,(function(){var e=t.el,n=t.items,i=e.clientWidth;if(0===i)return n.map((function(t,e){return[e]}));var r=[[]];return n.map((function(t,e){return{left:t.offsetLeft,width:t.clientWidth,item:t,index:e}})).sort((function(t,e){return t.left-e.left})).forEach((function(t){var e=t.left,n=t.width,o=r[r.length-1],a=o[0],s=(null==a?void 0:a.left)||0;o===r[0]&&(s=0);for(var l=Math.floor((e-s+.75*n)/i);l>0;)r.push([]),l--;r[r.length-1].push(t)})),(r=r.filter((function(t){return 0!==t.length}))).map((function(t){return t.map((function(t){return t.index}))}))}))}},{key:"pageIndex",get:function(){var t=this;return c(this,ht,(function(){var e=t.el,n=t.items,i=t.index,r=t.pages,o=e.getBoundingClientRect().left,a=e.clientWidth,s=i.reduce((function(t,e){if(!n[e])return t;var i=n[e].getBoundingClientRect(),r=i.left,s=i.right;return r=Math.round(r-o),s=Math.round(s-o),r<0||a