const t=t=>"object"==typeof t&&null!==t&&t.constructor===Object&&"[object Object]"===Object.prototype.toString.call(t),e=(i,...s)=>{const n=s.length;for(let o=0;o{const o=Array.isArray(n)?[]:{};i[s]||Object.assign(i,{[s]:o}),t(n)?Object.assign(i[s],e(o,n)):Array.isArray(n)?Object.assign(i,{[s]:[...n]}):Object.assign(i,{[s]:n})}))}return i},i=function(t,e){let i=!0;return(...s)=>{i&&(i=!1,t(...s),setTimeout((()=>{i=!0}),e))}},s=(t,e)=>{let i=[];return t.childNodes.forEach((t=>{t.nodeType!==Node.ELEMENT_NODE||e&&!t.matches(e)||i.push(t)})),i},n=function(t){return(new DOMParser).parseFromString(t,"text/html").body.firstChild},o=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),a=t=>`${t||""}`.split(" ").filter((t=>!!t)),r=(t,e)=>{a(e).forEach((e=>{t&&t.classList.add(e)}))},h=(t,e)=>{a(e).forEach((e=>{t&&t.classList.remove(e)}))},l=(t,e,i)=>{a(e).forEach((e=>{t&&t.classList.toggle(e,i||!1)}))},c='
',d=function(t,e){return t.split(".").reduce(((t,e)=>"object"==typeof t?t[e]:void 0),e)};class u{constructor(t={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(t);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith("on")&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}setOptions(t){this.options=t?e({},this.constructor.defaults,t):{};for(const[t,e]of Object.entries(this.option("on")||{}))this.on(t,e)}option(t,...e){let i=d(t,this.options);return i&&"function"==typeof i&&(i=i.call(this,this,...e)),i}optionFor(t,e,i,...s){let n=d(e,t);var o;"string"!=typeof(o=n)||isNaN(o)||isNaN(parseFloat(o))||(n=parseFloat(n)),"true"===n&&(n=!0),"false"===n&&(n=!1),n&&"function"==typeof n&&(n=n.call(this,this,t,...s));let a=d(e,this.options);return a&&"function"==typeof a?n=a.call(this,this,t,...s,n):void 0===n&&(n=a),void 0===n?i:n}cn(t){const e=this.options.classes;return e&&e[t]||""}localize(t,e=[]){t=String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,((t,e,i)=>{let s="";return i?s=this.option(`${e[0]+e.toLowerCase().substring(1)}.l10n.${i}`):e&&(s=this.option(`l10n.${e}`)),s||(s=t),s}));for(let i=0;ie))}on(t,e){let i=[];"string"==typeof t?i=t.split(" "):Array.isArray(t)&&(i=t),this.events||(this.events=new Map),i.forEach((t=>{let i=this.events.get(t);i||(this.events.set(t,[]),i=[]),i.includes(e)||i.push(e),this.events.set(t,i)}))}off(t,e){let i=[];"string"==typeof t?i=t.split(" "):Array.isArray(t)&&(i=t),i.forEach((t=>{const i=this.events.get(t);if(Array.isArray(i)){const t=i.indexOf(e);t>-1&&i.splice(t,1)}}))}emit(t,...e){[...this.events.get(t)||[]].forEach((t=>t(this,...e))),"*"!==t&&this.emit("*",t,...e)}}Object.defineProperty(u,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.5"}),Object.defineProperty(u,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class g extends u{constructor(t={}){super(t),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(t={}){const e=new Map;for(const[i,s]of Object.entries(t)){const t=this.option(i),n=this.plugins[i];n||!1===t?n&&!1===t&&(n.detach(),delete this.plugins[i]):e.set(i,new s(this,t||{}))}for(const[t,i]of e)this.plugins[t]=i,i.attach();this.emit("attachPlugins")}detachPlugins(){for(const t of Object.values(this.plugins))t.detach();return this.plugins={},this.emit("detachPlugins"),this}}const p=function(t,e){return!(!t||t===document.body||e&&t===e)&&(function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,i=window.getComputedStyle(t).overflowY,s=-1!==i.indexOf("hidden"),n=-1!==i.indexOf("visible");return e&&!s&&!n}(t)?t:p(t.parentElement,e))};class f{constructor(t){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=t,this.pageX=t.pageX,this.pageY=t.pageY,this.clientX=t.clientX,this.clientY=t.clientY,this.id=self.Touch&&t instanceof Touch?t.identifier:-1,this.time=Date.now()}}const m={passive:!1};class b{constructor(t,{start:e=(()=>!0),move:i=(()=>{}),end:s=(()=>{})}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=t,this.startCallback=e,this.moveCallback=i,this.endCallback=s;for(const t of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[t]=this[t].bind(this);this.element.addEventListener("touchstart",this.onTouchStart,m),this.element.addEventListener("touchmove",this.onMove,m),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd),this.element.addEventListener("mousedown",this.onPointerStart,m)}onPointerStart(t){if(!t.buttons||0!==t.button)return;const e=new f(t);this.currentPointers.some((t=>t.id===e.id))||this.triggerPointerStart(e,t)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(t){for(const e of Array.from(t.changedTouches))this.triggerPointerStart(new f(e),t);window.addEventListener("blur",this.onWindowBlur)}onMove(t){const e=this.currentPointers.slice(),i="changedTouches"in t?Array.from(t.changedTouches).map((t=>new f(t))):[new f(t)],s=[];for(const t of i){const e=this.currentPointers.findIndex((e=>e.id===t.id));e<0||(s.push(t),this.currentPointers[e]=t)}s.length&&this.moveCallback(t,this.currentPointers.slice(),e)}onPointerEnd(t){t.buttons>0&&0!==t.button||(this.triggerPointerEnd(t,new f(t)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(t){for(const e of Array.from(t.changedTouches))this.triggerPointerEnd(t,new f(e))}triggerPointerStart(t,e){return!!this.startCallback(e,t,this.currentPointers.slice())&&(this.currentPointers.push(t),this.startPointers.push(t),!0)}triggerPointerEnd(t,e){const i=this.currentPointers.findIndex((t=>t.id===e.id));i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(t,e,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const t=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event("touchend",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY}),t,this.currentPointers.slice())}}stop(){this.element.removeEventListener("mousedown",this.onPointerStart,m),this.element.removeEventListener("touchstart",this.onTouchStart,m),this.element.removeEventListener("touchmove",this.onMove,m),this.element.removeEventListener("touchend",this.onTouchEnd),this.element.removeEventListener("touchcancel",this.onTouchEnd),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur)}}function v(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function y(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}var x;!function(t){t[t.Init=0]="Init",t[t.Error=1]="Error",t[t.Ready=2]="Ready",t[t.Panning=3]="Panning",t[t.Mousemove=4]="Mousemove",t[t.Destroy=5]="Destroy"}(x||(x={}));const w=["a","b","c","d","e","f"],P={content:null,width:"auto",height:"auto",panMode:"drag",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:"auto",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:"toggleZoom",dblClick:!1,wheel:"zoom",wheelLimit:7,spinner:!0,bounds:"auto",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:"f-panzoom__content",isLoading:"is-loading",canZoomIn:"can-zoom_in",canZoomOut:"can-zoom_out",isDraggable:"is-draggable",isDragging:"is-dragging",inFullscreen:"in-fullscreen",htmlHasFullscreen:"with-panzoom-in-fullscreen"},l10n:{PANUP:"Move up",PANDOWN:"Move down",PANLEFT:"Move left",PANRIGHT:"Move right",ZOOMIN:"Zoom in",ZOOMOUT:"Zoom out",TOGGLEZOOM:"Toggle zoom level",TOGGLE1TO1:"Toggle zoom level",ITERATEZOOM:"Toggle zoom level",ROTATECCW:"Rotate counterclockwise",ROTATECW:"Rotate clockwise",FLIPX:"Flip horizontally",FLIPY:"Flip vertically",FITX:"Fit horizontally",FITY:"Fit vertically",RESET:"Reset",TOGGLEFS:"Toggle fullscreen"}},S=t=>t&&null!==t&&t instanceof Element&&"nodeType"in t,T={a:1,b:0,c:0,d:1,e:0,f:0};let M=null,O=null;class E extends g{get isTouchDevice(){return null===O&&(O=window.matchMedia("(hover: none)").matches),O}get isMobile(){return null===M&&(M=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),M}get panMode(){return"mousemove"!==this.options.panMode||this.isTouchDevice?"drag":"mousemove"}get panOnlyZoomed(){const t=this.options.panOnlyZoomed;return"auto"===t?this.isTouchDevice:t}get isInfinite(){return this.option("infinite")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:t,b:e}=this.current;return Math.sqrt(t*t+e*e)||1}get targetScale(){const{a:t,b:e}=this.target;return Math.sqrt(t*t+e*e)||1}get minScale(){return this.option("minScale")||1}get fullScale(){const{contentRect:t}=this;return t.fullWidth/t.fitWidth||1}get maxScale(){return this.fullScale*(this.option("maxScale")||1)||1}get coverScale(){const{containerRect:t,contentRect:e}=this,i=Math.max(t.height/e.fitHeight,t.width/e.fitWidth)||1;return Math.min(this.fullScale,i)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const t=this.content;return!!(t&&t instanceof HTMLImageElement)&&!t.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const t of w){const e="e"==t||"f"===t?.001:1e-5;if(Math.abs(this.target[t]-this.current[t])>e)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(t,e={},i={}){var s;if(super(e),Object.defineProperty(this,"pointerTracker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"resizeObserver",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"updateTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rAF",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isTicking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"friction",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"ignoreBounds",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingX",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingY",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"clicks",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"trackingPoints",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"wheelDelta",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevWheelDelta",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevWheelTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevMouseMoveEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:x.Init}),Object.defineProperty(this,"isDragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"spinner",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"containerRect",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,"contentRect",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,"dragStart",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,"dragOffset",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,"current",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},T)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},T)}),Object.defineProperty(this,"velocity",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,"lockedAxis",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!t)throw new Error("No Element found");if(this.container=t,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},E.Plugins),i)),this.emit("init"),this.isContentLoading){const e=this.content;if(this.option("spinner")){t.classList.add(this.cn("isLoading"));const i=n(c);t.contains(e)?this.spinner=(null===(s=e.parentElement)||void 0===s?void 0:s.insertBefore(i,e))||null:this.spinner=t.appendChild(i)}this.emit("beforeLoad"),e.addEventListener("load",this.onLoad),e.addEventListener("error",this.onError)}else queueMicrotask((()=>{this.enable()}))}initContent(){const{container:t}=this;let e=this.option("content")||t.querySelector(`.${this.cn("content")}`);if(e||(e=t.querySelector("img")||t.firstElementChild,e&&e.classList.add(this.cn("content"))),!e)throw new Error("No content found");this.content=e}onLoad(){this.spinner&&(this.spinner.remove(),this.spinner=null),this.option("spinner")&&this.container.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),this.state===x.Init&&this.enable()}onError(){this.state!==x.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=x.Error,this.emit("error"))}attachObserver(){var t;let e=!1;this.resizeObserver||void 0===window.ResizeObserver||(this.resizeObserver=new ResizeObserver((t=>{if(e)if(Math.abs(this.containerRect.width-t[0].contentRect.width)<.1&&Math.abs(this.containerRect.height-t[0].contentRect.height)<.1)this.updateTimer=null;else{if(this.updateTimer)return;this.onResize(),this.isMobile&&(this.updateTimer=setTimeout((()=>{this.onResize(),this.updateTimer=null}),300))}else e=!0}))),null===(t=this.resizeObserver)||void 0===t||t.observe(this.container)}detachObserver(){var t;null===(t=this.resizeObserver)||void 0===t||t.disconnect()}attachEvents(){const{container:t}=this;t.addEventListener("click",this.onClick,{passive:!1,capture:!1}),t.addEventListener("wheel",this.onWheel,{passive:!1}),this.pointerTracker=new b(t,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener("mousemove",this.onMouseMove)}detachEvents(){var t;const{container:e}=this;e.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),e.removeEventListener("wheel",this.onWheel,{passive:!1}),null===(t=this.pointerTracker)||void 0===t||t.stop(),this.pointerTracker=null,document.removeEventListener("mousemove",this.onMouseMove),document.removeEventListener("keydown",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){this.setTargetForce();const t=this.option("maxVelocity");for(const e of w)this.friction?(this.velocity[e]*=1-this.friction,t&&!this.isScaling&&(this.velocity[e]=Math.max(Math.min(this.velocity[e],t),-1*t)),this.current[e]+=this.velocity[e]):this.current[e]=this.target[e];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame((()=>this.animate())):this.stop("current")}setTargetForce(){for(const t of w)"e"===t&&this.isBouncingX||"f"===t&&this.isBouncingY||(this.velocity[t]=(1/(1-this.friction)-1)*(this.target[t]-this.current[t]))}checkBounds(t=0,e=0){const{current:i}=this,s=i.e+t,n=i.f+e,o=this.getBounds(),{x:a,y:r}=o,h=a.min,l=a.max,c=r.min,d=r.max;let u=0,g=0;return h!==1/0&&sl&&(u=l-s),c!==1/0&&nd&&(g=d-n),Math.abs(u)<.001&&(u=0),Math.abs(g)<.001&&(g=0),Object.assign(Object.assign({},o),{xDiff:u,yDiff:g,inBounds:!u&&!g})}clampTargetBounds(){const{target:t}=this,{x:e,y:i}=this.getBounds();e.min!==1/0&&(t.e=Math.max(t.e,e.min)),e.max!==1/0&&(t.e=Math.min(t.e,e.max)),i.min!==1/0&&(t.f=Math.max(t.f,i.min)),i.max!==1/0&&(t.f=Math.min(t.f,i.max))}calculateContentDim(t=this.current){const{content:e,contentRect:i}=this,{fitWidth:s,fitHeight:n,fullWidth:o,fullHeight:a}=i;let r=o,h=a;if(this.option("zoom")||0!==this.angle){const i=!(e instanceof HTMLImageElement)&&("none"===window.getComputedStyle(e).maxWidth||"none"===window.getComputedStyle(e).maxHeight),l=i?o:s,c=i?a:n,d=this.getMatrix(t),u=new DOMPoint(0,0).matrixTransform(d),g=new DOMPoint(0+l,0).matrixTransform(d),p=new DOMPoint(0+l,0+c).matrixTransform(d),f=new DOMPoint(0,0+c).matrixTransform(d),m=Math.abs(p.x-u.x),b=Math.abs(p.y-u.y),v=Math.abs(f.x-g.x),y=Math.abs(f.y-g.y);r=Math.max(m,v),h=Math.max(b,y)}return{contentWidth:r,contentHeight:h}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||"mousemove"===this.panMode||this.targetScale{const t=window.getSelection();return t&&"Range"===t.type})()&&!i.closest("button"))return;const s=i.closest("[data-panzoom-action]"),n=i.closest("[data-panzoom-change]"),o=s||n,a=o&&S(o)?o.dataset:null;if(a){const e=a.panzoomChange,i=a.panzoomAction;if((e||i)&&t.preventDefault(),e){let t={};try{t=JSON.parse(e)}catch(t){console&&console.warn("The given data was not valid JSON")}return void this.applyChange(t)}if(i)return void(this[i]&&this[i]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return t.preventDefault(),void t.stopPropagation();const r=this.content.getBoundingClientRect();if(this.dragStart.time&&!this.canZoomOut()&&(Math.abs(r.x-this.dragStart.x)>2||Math.abs(r.y-this.dragStart.y)>2))return;this.dragStart.time=0;const h=e=>{!this.option("zoom")||Math.abs(this.velocity.a)>.3||e&&"string"==typeof e&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(e)&&"function"==typeof this[e]&&(t.preventDefault(),this[e]({event:t}))},l=this.option("click",t),c=this.option("dblClick",t);c?(this.clicks++,1==this.clicks&&(this.clickTimer=setTimeout((()=>{1===this.clicks?(this.emit("click",t),!t.defaultPrevented&&l&&h(l)):(this.emit("dblClick",t),t.defaultPrevented||h(c)),this.clicks=0,this.clickTimer=null}),350))):(this.emit("click",t),!t.defaultPrevented&&l&&h(l))}addTrackingPoint(t){const e=this.trackingPoints.filter((t=>t.time>Date.now()-100));e.push(t),this.trackingPoints=e}onPointerDown(t,e,i){var s;this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const n=this.content.getBoundingClientRect();if(this.dragStart={x:n.x,y:n.y,top:n.top,left:n.left,time:Date.now()},!1===this.option("touch",t))return!1;if(this.clickTimer)return!1;if("mousemove"===this.panMode&&this.targetScale>1)return t.preventDefault(),t.stopPropagation(),!1;if(!i.length){const e=t.composedPath()[0];if(["A","TEXTAREA","OPTION","INPUT","SELECT","VIDEO"].includes(e.nodeName)||e.closest("[contenteditable]")||e.closest("[data-selectable]")||e.closest("[data-panzoom-change]")||e.closest("[data-panzoom-action]"))return!1;null===(s=window.getSelection())||void 0===s||s.removeAllRanges()}return"mousedown"===t.type&&t.preventDefault(),o(this.targetScale,1e3)===o(this.minScale,1e3)?(this.stop(),this.target.e=this.current.e,this.target.f=this.current.f):this.stop("target"),this.isDragging=!0,this.addTrackingPoint(e),this.emit("touchStart",t),!0}onPointerMove(t,e,i){if(!this.isDragging)return;if(e.length<2&&this.panOnlyZoomed&&o(this.targetScale)<=o(this.minScale))return;if(this.emit("touchMove",t),t.defaultPrevented)return;this.addTrackingPoint(e[0]);const{content:s}=this,n=y(i[0],i[1]),a=y(e[0],e[1]);let r=0,h=0;if(e.length>1){const t=s.getBoundingClientRect();r=n.clientX-t.left-.5*t.width,h=n.clientY-t.top-.5*t.height}const l=v(i[0],i[1]),c=v(e[0],e[1]);let d=l?c/l:1,u=a.clientX-n.clientX,g=a.clientY-n.clientY;this.dragOffset.x+=u,this.dragOffset.y+=g,this.dragOffset.time=Date.now()-this.dragStart.time;let f=o(this.targetScale)===o(this.minScale)&&this.option("lockAxis");if(f&&!this.lockedAxis)if("xy"===f||"y"===f||"touchmove"===t.type){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void t.preventDefault();const e=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=e>45&&e<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,u=0,g=0}else this.lockedAxis=f;if(p(t.target,this.content)&&(f="x",this.dragOffset.y=0),f&&"xy"!==f&&this.lockedAxis!==f&&o(this.targetScale)===o(this.minScale))return;t.cancelable&&t.preventDefault(),this.container.classList.add(this.cn("isDragging"));const m=this.checkBounds(u,g);this.option("rubberband")?("x"!==this.isInfinite&&(m.xDiff>0&&u<0||m.xDiff<0&&u>0)&&(u*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*m.xDiff))),"y"!==this.isInfinite&&(m.yDiff>0&&g<0||m.yDiff<0&&g>0)&&(g*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*m.yDiff)))):(m.xDiff&&(u=0),m.yDiff&&(g=0));const b=this.targetScale,x=this.minScale,w=this.maxScale;b<.5*x&&(d=Math.max(d,x)),b>1.5*w&&(d=Math.min(d,w)),"y"===this.lockedAxis&&o(b)===o(x)&&(u=0),"x"===this.lockedAxis&&o(b)===o(x)&&(g=0),this.applyChange({originX:r,originY:h,panX:u,panY:g,scale:d,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(t,e,i){if(i.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn("isDragging")),this.isDragging&&(this.isDragging=!1,this.addTrackingPoint(e),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),p(t.target,this.content)&&"y"===this.lockedAxis&&(this.trackingPoints=[]),this.emit("touchEnd",t),this.state!==x.Destroy&&(t.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const t of w)this.velocity[t]=0,this.target[t]=this.current[t];h(this.container,"is-scaling"),h(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:t}=this,e=t[0],i=t[t.length-1];let s=0,n=0,a=0;i&&e&&(s=i.clientX-e.clientX,n=i.clientY-e.clientY,a=i.time-e.time);let r=0,l=0,c=0,d=0,u=this.option("decelFriction");const g=this.targetScale;if((gthis.maxScale+1e-5)&&(u=.35),a>0){c=Math.abs(s)>3?s/(a/30):0,d=Math.abs(n)>3?n/(a/30):0;const t=this.option("maxVelocity");t&&(c=Math.max(Math.min(c,t),-1*t),d=Math.max(Math.min(d,t),-1*t))}c&&(r=c/(1/(1-u)-1)),d&&(l=d/(1/(1-u)-1)),("y"===this.option("lockAxis")||"xy"===this.option("lockAxis")&&"y"===this.lockedAxis&&o(g)===this.minScale)&&(r=c=0),("x"===this.option("lockAxis")||"xy"===this.option("lockAxis")&&"x"===this.lockedAxis&&o(g)===this.minScale)&&(l=d=0);const p=this.option("dragMinThreshold")||0;Math.abs(this.dragOffset.x){let e=0;return e=t instanceof HTMLImageElement?t.naturalWidth:t instanceof SVGElement?t.width.baseVal.value:t.offsetWidth,Math.max(e,t.scrollWidth)})(s)),"auto"===p&&(p=parseFloat(s.dataset.height||"")||(t=>{let e=0;return e=t instanceof HTMLImageElement?t.naturalHeight:t instanceof SVGElement?t.height.baseVal.value:t.offsetHeight,Math.max(e,t.scrollHeight)})(s));const f=(this.option("transformParent")?s.parentElement:null)||s,m=f.getAttribute("style")||"";f.style.setProperty("transform","none","important"),f.style.setProperty("transition","none","important"),f.style.setProperty("animation","none","important"),s instanceof HTMLImageElement&&(f.style.width="",f.style.height=""),f.offsetHeight;const b=s.getBoundingClientRect();let v=b.width,y=b.height,w=0,P=0;if(s instanceof HTMLImageElement&&({width:v,height:y,top:w,left:P}=((t,e,i,s)=>{const n=i/s;return n>t/e?(i=t,s=t/n):(i=e*n,s=e),{width:i,height:s,top:.5*(e-s),left:.5*(t-i)}})(b.width,b.height,g,p)),this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:b.top-r.top+w,bottom:r.bottom-b.bottom+w,left:b.left-r.left+P,right:r.right-b.right+P,fitWidth:v,fitHeight:y,width:v,height:y,fullWidth:g,fullHeight:p}),f.style.cssText=m,s instanceof HTMLImageElement&&(f.style.width=`${v}px`,f.style.height=`${y}px`),this.setTransform(),!0!==t){let t="";Math.abs(l-n)>1&&(t+="x"),Math.abs(c-a)>1&&(t+="y"),t&&this.emit("refresh",t)}this.ignoreBounds||(o(this.targetScale)this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===x.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}getBounds(){const t=this.option("bounds");if("auto"!==t)return t;const{contentWidth:e,contentHeight:i}=this.calculateContentDim(this.target);let s=0,n=0,a=0,r=0;const h=this.option("infinite");if(!0===h||this.lockedAxis&&h===this.lockedAxis)s=-1/0,a=1/0,n=-1/0,r=1/0;else{let{containerRect:t,contentRect:h}=this,l=o(this.contentRect.fitWidth*this.targetScale,1e3),c=o(this.contentRect.fitHeight*this.targetScale,1e3),{innerWidth:d,innerHeight:u}=t;if(this.containerRect.width===l&&(d=t.width),this.containerRect.width===c&&(u=t.height),e>d){a=.5*(e-d),s=-1*a;let t=.5*(h.right-h.left);s+=t,a+=t}if(this.contentRect.fitWidth>d&&eu){r=.5*(i-u),n=-1*r;let t=.5*(h.bottom-h.top);n+=t,r+=t}this.contentRect.fitHeight>u&&i-1||this.contentRect.height-this.contentRect.fitHeight>-1)&&(r=!0),this.contentRect.width*this.targetScaleo(this.targetScale),c=!h&&!r&&n&&o(i).9*t.fullScale?"none":"")}}panTo({x:t=this.target.e,y:e=this.target.f,scale:i=this.targetScale,friction:s=this.option("friction"),angle:n=0,originX:o=0,originY:a=0,flipX:r=!1,flipY:h=!1,ignoreBounds:l=!1}){this.state!==x.Destroy&&this.applyChange({panX:t-this.target.e,panY:e-this.target.f,scale:i/this.targetScale,angle:n,originX:o,originY:a,friction:s,flipX:r,flipY:h,ignoreBounds:l})}applyChange({panX:t=0,panY:e=0,scale:i=1,angle:s=0,originX:n=-this.current.e,originY:a=-this.current.f,friction:r=this.option("friction"),flipX:h=!1,flipY:l=!1,ignoreBounds:c=!1,bounce:d=this.option("bounce")}){const u=this.state;if(u===x.Init||u===x.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const t of w)this.velocity[t]=0;this.friction=r||0,this.ignoreBounds=c;const{current:g}=this,p=g.e,f=g.f,m=this.getMatrix(this.target);let b=(new DOMMatrix).translate(p,f).translate(n,a).translate(t,e);if(this.option("zoom")){if(!c){const t=this.targetScale,e=this.minScale,s=this.maxScale;t*is&&(i=s/t)}b=b.scale(i)}b=b.translate(-n,-a).translate(-p,-f).multiply(m),s&&(b=b.rotate(s)),h&&(b=b.scale(-1,1)),l&&(b=b.scale(1,-1));for(const t of w)"a"!=t&&"d"!=t||!(b[t]>this.minScale+1e-5||b[t].1||"mousemove"===this.panMode||!1===d)&&!c&&this.clampTargetBounds(),this.isResting||(this.state=x.Panning,this.requestTick())}stop(t=!1){if(this.state!==x.Init&&this.state!==x.Destroy){this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const e of w)this.velocity[e]=0,"current"===t?this.current[e]=this.target[e]:"target"===t&&(this.target[e]=this.current[e]);this.setTransform(),this.isTicking&&(this.emit("endAnimation"),this.updateControls()),h(this.container,"is-scaling"),h(this.container,"is-animating"),this.isTicking=!1,this.isDragging=!1,this.lockedAxis=!1,this.state=x.Ready}}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),r(this.container,"is-animating"),this.isScaling&&r(this.container,"is-scaling")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame((()=>this.animate())))}panWithMouse(t,e=this.option("mouseMoveFriction")){if(this.prevMouseMoveEvent=t,"mousemove"!==this.panMode||!t)return;if(o(this.targetScale)<=o(this.minScale))return;this.emit("mouseMove",t);const{container:i,containerRect:s,contentRect:n}=this,a=s.width,r=s.height,h=i.getBoundingClientRect(),l=(t.clientX||0)-h.left,c=(t.clientY||0)-h.top;let{contentWidth:d,contentHeight:u}=this.calculateContentDim(this.target);const g=this.option("mouseMoveFactor");g>1&&(d!==a&&(d*=g),u!==r&&(u*=g));let p=.5*(d-a)-l/a*100/100*(d-a);p+=.5*(n.right-n.left);let f=.5*(u-r)-c/r*100/100*(u-r);f+=.5*(n.bottom-n.top),this.applyChange({panX:p-this.target.e,panY:f-this.target.f,friction:e})}zoomWithWheel(t){if(this.state===x.Destroy||this.state===x.Init)return;const e=Math.abs(t.deltaY)<100&&Math.abs(t.deltaX)<100?25:50,i=Math.max(-1,Math.min(1,-t.deltaY||-t.deltaX||-t.detail)),s=this.targetScale,n=this.maxScale,o=this.minScale;let a=s*(100+i*e)/100;an&&s>=n?(this.wheelDelta+=Math.abs(i),a=n):(this.wheelDelta=0,a=Math.max(Math.min(a,n),o)),this.wheelDelta>this.option("wheelLimit")||(t.preventDefault(),a!==s&&this.zoomTo(a,{event:t}))}canZoomIn(){return this.option("zoom")&&(this.contentRect.widththis.minScale+1e-5}zoomIn(t=1.25,e){this.zoomTo(this.targetScale*t,e)}zoomOut(t=.8,e){this.zoomTo(this.targetScale*t,e)}zoomToFit(t){this.zoomTo("fit",t)}zoomToCover(t){this.zoomTo("cover",t)}zoomToFull(t){this.zoomTo("full",t)}zoomToMax(t){this.zoomTo("max",t)}toggleZoom(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.fullScale-this.minScale)?"full":"fit",t)}toggleMax(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.maxScale-this.minScale)?"max":"fit",t)}toggleCover(t){this.zoomTo(this.targetScale-this.minScale<.5*(this.coverScale-this.minScale)?"cover":"fit",t)}iterateZoom(t){this.zoomTo("next",t)}zoomTo(t=1,{friction:e="auto",originX:i=0,originY:s=0,event:n}={}){if(this.isContentLoading||this.state===x.Destroy)return;this.stop();const{targetScale:o}=this;let a=1;if("mousemove"===this.panMode&&(n=this.prevMouseMoveEvent||n),n){const t=this.content.getBoundingClientRect(),e=n.clientX||0,o=n.clientY||0;i=e-t.left-.5*t.width,s=o-t.top-.5*t.height}const r=this.fullScale,h=this.maxScale;let l=this.coverScale;"number"==typeof t?a=t/o:("next"===t&&(r-l<.2&&(l=r),t=o1?.15:.25:e,this.applyChange({scale:a,originX:i,originY:s,friction:e}),n&&"mousemove"===this.panMode&&this.panWithMouse(n,e)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop("target");const{containerRect:t,contentRect:e,target:i}=this;this.applyChange({panX:.5*t.width-(e.left+.5*e.fitWidth)-i.e,panY:.5*t.height-(e.top+.5*e.fitHeight)-i.f,scale:t.width/e.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:t,contentRect:e,target:i}=this;this.applyChange({panX:.5*t.width-(e.left+.5*e.fitWidth)-i.e,panY:.5*t.height-(e.top+.5*e.fitHeight)-i.f,scale:t.height/e.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:t}=this,e=this.cn("inFullscreen"),i=this.cn("htmlHasFullscreen");t.classList.toggle(e);const s=t.classList.contains(e);s?(document.documentElement.classList.add(i),document.addEventListener("keydown",this.onKeydown,!0)):(document.documentElement.classList.remove(i),document.removeEventListener("keydown",this.onKeydown,!0)),this.updateMetrics(),this.emit(s?"enterFS":"exitFS")}getMatrix(t=this.current){const{a:e,b:i,c:s,d:n,e:o,f:a}=t;return new DOMMatrix([e,i,s,n,o,a])}reset(t){if(this.state!==x.Init&&this.state!==x.Destroy){this.stop("current");for(const t of w)this.target[t]=T[t];this.target.a=this.minScale,this.target.d=this.minScale,this.isResting||(this.friction=void 0===t?this.option("friction"):t,this.state=x.Panning,this.requestTick())}}destroy(){this.stop(),this.state=x.Destroy,this.detachEvents(),this.detachObserver();const{container:t,content:e}=this,i=this.option("classes")||{};for(const e of Object.values(i))t.classList.remove(e+"");e&&(e.removeEventListener("load",this.onLoad),e.removeEventListener("error",this.onError)),this.detachPlugins()}}Object.defineProperty(E,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:P}),Object.defineProperty(E,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const z={viewport:null,track:null,enabled:!0,slides:[],axis:"x",transition:"fade",preload:1,slidesPerPage:"auto",initialPage:0,friction:.12,center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:"ltr",classes:{container:"f-carousel",viewport:"f-carousel__viewport",track:"f-carousel__track",slide:"f-carousel__slide",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",inTransition:"in-transition",isSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide #%d"}};var k;!function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"}(k||(k={}));const R=t=>{if("string"==typeof t&&(t={html:t}),!(t instanceof String||t instanceof HTMLElement)){const e=t.thumb;void 0!==e&&("string"==typeof e&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},D=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);class L extends u{constructor(t,e){super(e),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:t})}attach(){}detach(){}}const A={classes:{list:"f-carousel__dots",isDynamic:"is-dynamic",hasDots:"has-dots",dot:"f-carousel__dot",isBeforePrev:"is-before-prev",isPrev:"is-prev",isCurrent:"is-current",isNext:"is-next",isAfterNext:"is-after-next"},dotTpl:'',dynamicFrom:11,maxCount:1/0,minCount:2};class C extends L{constructor(){super(...arguments),Object.defineProperty(this,"isDynamic",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let t=this.list;return t||(t=document.createElement("ul"),r(t,this.cn("list")),t.setAttribute("role","tablist"),this.instance.container.appendChild(t),r(this.instance.container,this.cn("hasDots")),this.list=t),t}refresh(){var t;const e=this.instance.pages.length,i=Math.min(2,this.option("minCount")),s=Math.max(2e3,this.option("maxCount")),n=this.option("dynamicFrom");if(es)return void this.cleanup();const o="number"==typeof n&&e>5&&e>=n,a=!this.list||this.isDynamic!==o||this.list.children.length!==e;a&&this.cleanup();const c=this.build();if(l(c,this.cn("isDynamic"),!!o),a)for(let t=0;t=e-1&&n.setAttribute("disabled","")))}createButton(t){const e=this.instance,i=document.createElement("button");i.setAttribute("tabindex","0"),i.setAttribute("title",e.localize(`{{${t.toUpperCase()}}}`)),r(i,this.cn("button")+" "+this.cn("next"===t?"isNext":"isPrev"));const s=e.isRTL?"next"===t?"prev":"next":t;var n;return i.innerHTML=e.localize(this.option(`${s}Tpl`)),i.dataset[`carousel${n=t,n?n.match("^[a-z]")?n.charAt(0).toUpperCase()+n.substring(1):n:""}`]="true",i}build(){let t=this.container;t||(this.container=t=document.createElement("div"),r(t,this.cn("container")),this.instance.container.appendChild(t)),this.next||(this.next=t.appendChild(this.createButton("next"))),this.prev||(this.prev=t.appendChild(this.createButton("prev")))}cleanup(){this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove(),this.prev=null,this.next=null,this.container=null}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}}Object.defineProperty(j,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:"f-carousel__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"},nextTpl:'',prevTpl:''}});class F extends L{constructor(){super(...arguments),Object.defineProperty(this,"selectedIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(t){this.target=this.instance,this.nav=t,this.attachEvents()}addAsNavFor(t){this.nav=this.instance,this.target=t,this.attachEvents()}attachEvents(){this.nav&&this.target&&(this.nav.options.initialSlide=this.target.options.initialPage,this.nav.on("ready",this.onNavReady),this.nav.state===k.Ready&&this.onNavReady(this.nav),this.target.on("ready",this.onTargetReady),this.target.state===k.Ready&&this.onTargetReady(this.target))}onNavReady(t){t.on("createSlide",this.onNavCreateSlide),t.on("Panzoom.click",this.onNavClick),this.onTargetChange()}onTargetReady(t){t.on("change",this.onTargetChange),t.on("Panzoom.refresh",this.onTargetChange),this.onTargetChange()}onNavClick(t,e,i){var s,n;const o=i.target,{nav:a,target:r}=this;if(!a||!r||!o)return;const h=o.closest("[data-index]");if(!h)return;i.stopPropagation(),i.preventDefault();const l=parseInt(h.dataset.index||"",10)||0,c=r.getPageForSlide(l),d=a.getPageForSlide(l);r.page!==c&&r.slideTo(c,{friction:null===(n=null===(s=this.nav)||void 0===s?void 0:s.plugins)||void 0===n?void 0:n.Sync.option("friction")}),this.markSelectedSlide(l),a.page!==d&&a.slideTo(d)}onNavCreateSlide(t,e){e.index===this.selectedIndex&&this.markSelectedSlide(e.index)}onTargetChange(){const{target:t,nav:e}=this;if(!t||!e)return;if(e.state!==k.Ready||t.state!==k.Ready)return;const i=t.pages[t.page].slides[0].index,s=e.getPageForSlide(i);this.markSelectedSlide(i),e.slideTo(s)}markSelectedSlide(t){const{nav:e}=this;if(!e||e.state!==k.Ready)return;this.selectedIndex=t,[...e.slides].filter((t=>t.el&&t.el.classList.remove("is-nav-selected")));const i=e.slides[t];i&&i.el&&i.el.classList.add("is-nav-selected")}attach(){let t=this.options.target,e=this.options.nav;t?this.addAsNavFor(t):e&&this.addAsTargetFor(e)}detach(){this.nav&&(this.nav.off("ready",this.onNavReady),this.nav.off("Panzoom.click",this.onNavClick),this.nav.off("createSlide",this.onNavCreateSlide)),this.nav=null,this.target&&(this.target.off("ready",this.onTargetReady),this.target.off("refresh",this.onTargetChange),this.target.off("change",this.onTargetChange)),this.target=null}}Object.defineProperty(F,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const I={Navigation:j,Dots:C,Sync:F};class H extends g{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===k.Ready}get isInfinite(){let t=!1;const e=this.contentDim,i=this.viewportDim;return this.pages.length>=2&&e>1.5*i&&(t=this.option("infinite")),t}get isRTL(){return"rtl"===this.option("direction")}get isHorizontal(){return"x"===this.option("axis")}constructor(t,e={},s={}){if(super(),Object.defineProperty(this,"userOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"bp",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:k.Init}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevPage",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"viewport",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"slides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"panzoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"inTransition",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"contentDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"viewportDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),"string"==typeof t&&(t=document.querySelector(t)),!t||!S(t))throw new Error("No Element found");this.container=t,this.slideNext=i(this.slideNext.bind(this),175),this.slidePrev=i(this.slidePrev.bind(this),175),this.userOptions=e,this.userPlugins=s,queueMicrotask((()=>{this.processOptions()}))}processOptions(){const i=e({},H.defaults,this.userOptions);let s="";const n=i.breakpoints;if(n&&t(n))for(const[o,a]of Object.entries(n))window.matchMedia(o).matches&&t(a)&&(s+=o,e(i,a));s===this.bp&&this.state!==k.Init||(this.bp=s,this.state===k.Ready&&(i.initialSlide=this.pages[this.page].slides[0].index),this.state!==k.Init&&this.destroy(),super.setOptions(i),!1===this.option("enabled")?this.attachEvents():setTimeout((()=>{this.init()}),0))}init(){this.state=k.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},H.Plugins),this.userPlugins)),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=k.Ready,this.emit("ready")}initLayout(){const{container:t}=this,e=this.option("classes");r(t,this.cn("container")),l(t,e.isLTR,!this.isRTL),l(t,e.isRTL,this.isRTL),l(t,e.isVertical,!this.isHorizontal),l(t,e.isHorizontal,this.isHorizontal);let i=this.option("viewport")||t.querySelector(`.${e.viewport}`);i||(i=document.createElement("div"),r(i,e.viewport),i.append(...s(t,`.${e.slide}`)),t.prepend(i));let n=this.option("track")||t.querySelector(`.${e.track}`);n||(n=document.createElement("div"),r(n,e.track),n.append(...Array.from(i.childNodes))),n.setAttribute("aria-live","polite"),i.contains(n)||i.prepend(n),this.viewport=i,this.track=n,this.emit("initLayout")}initSlides(){const{track:t}=this;if(t){this.slides=[],[...s(t,`.${this.cn("slide")}`)].forEach((t=>{if(S(t)){const e=R({el:t,isDom:!0,index:this.slides.length});this.slides.push(e),this.emit("initSlide",e,this.slides.length)}}));for(let t of this.option("slides",[])){const e=R(t);e.index=this.slides.length,this.slides.push(e),this.emit("initSlide",t,this.slides.length)}this.emit("initSlides")}}setInitialPage(){let t=0;const e=this.option("initialSlide");t="number"==typeof e?this.getPageForSlide(e):parseInt(this.option("initialPage",0)+"",10)||0,this.page=t}setInitialPosition(){if(!this.track||!this.pages.length)return;let t=this.page;this.pages[t]||(this.page=t=0);const e=this.pages[t].pos*(this.isRTL&&this.isHorizontal?1:-1),i=this.isHorizontal?`${e}px`:"0",s=this.isHorizontal?"0":`${e}px`;this.track.style.transform=`translate3d(${i}, ${s}, 0) scale(1)`,this.option("adaptiveHeight")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const t=this.option("Panzoom")||{};this.panzoom=new E(this.viewport,e({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,decelFriction:.12,click:!1,dblClick:!1,touch:t=>!(this.pages.length<2&&!t.options.infinite),bounds:()=>this.getBounds(),maxVelocity:t=>Math.abs(t.target[this.axis]-t.current[this.axis])<2*this.viewportDim?100:0},t)),this.panzoom.on("*",((t,e,...i)=>{this.emit(`Panzoom.${e}`,t,...i)})),this.panzoom.on("decel",this.onDecel),this.panzoom.on("refresh",this.onRefresh),this.panzoom.on("beforeTransform",this.onBeforeTransform),this.panzoom.on("endAnimation",this.onEndAnimation),this.panzoom.on("touchStart",((t,e)=>{this.inTransition.size&&e.preventDefault()}))}attachEvents(){const t=this.container;t&&(t.addEventListener("click",this.onClick,{passive:!1,capture:!1}),t.addEventListener("slideTo",this.onSlideTo)),window.addEventListener("resize",this.onResize)}createPages(){let t=[];const{contentDim:e,viewportDim:i}=this,s=this.option("slidesPerPage");if("number"==typeof s&&e>i){for(let e=0;ei)&&(t.push(D()),n=t.length-1,o=0),o+=e.dim+e.gap,t[n].slides.push(e);return t}processPages(){const t=this.pages,{contentDim:e,viewportDim:i}=this,s=this.option("center"),n=this.option("fill");if(t.forEach(((t,e)=>{t.index=e,t.pos=t.slides[0].pos,t.dim=0;for(const[e,i]of t.slides.entries())t.dim+=i.dim,e{n&&!this.isInfinite&&e>i&&(t.pos=Math.max(t.pos,0),t.pos=Math.min(t.pos,e-i)),t.pos=o(t.pos,1e3),t.dim=o(t.dim,1e3)})),this.isInfinite)return t;const a=[];let r;return t.forEach((t=>{const e=Object.assign({},t);r&&e.pos===r.pos?(r.dim+=e.dim,r.slides=[...r.slides,...e.slides]):(e.index=a.length,r=e,a.push(e))})),a}getPageFromIndex(t=0){const e=this.pages.length;let i;return t=parseInt((t||0).toString())||0,i=this.isInfinite?(t%e+e)%e:Math.max(Math.min(t,this.pages.length-1),0),i}getSlideMetrics(t){const e=this.isHorizontal?"width":"height";let i=0,s=0,n=t.el;n?i=parseFloat(n.dataset[e]||"")||0:(n=document.createElement("div"),n.style.visibility="hidden",r(n,this.cn("slide")+" "+t.class),(this.track||document.body).prepend(n)),i?(n.style[e]=`${i}px`,n.style["width"===e?"height":"width"]=""):i=n.getBoundingClientRect()[e];const o=getComputedStyle(n);return"content-box"===o.boxSizing&&(this.isHorizontal?(i+=parseFloat(o.paddingLeft)||0,i+=parseFloat(o.paddingRight)||0):(i+=parseFloat(o.paddingTop)||0,i+=parseFloat(o.paddingBottom)||0)),s=parseFloat(o[this.isHorizontal?"marginRight":"marginBottom"])||0,this.isHorizontal,t.el||n.remove(),{dim:i,gap:s}}getBounds(){let t={min:0,max:0};if(this.isInfinite)t={min:-1/0,max:1/0};else if(this.pages.length){const e=this.pages[0].pos,i=this.pages[this.pages.length-1].pos;t=this.isRTL&&this.isHorizontal?{min:e,max:i}:{min:-1*i,max:-1*e}}return{x:this.isHorizontal?t:{min:0,max:0},y:this.isHorizontal?{min:0,max:0}:t}}repositionSlides(){const{viewportDim:t,contentDim:e,page:i,pages:s}=this;let n,a=0,r=0,h=0,l=0;this.panzoom?l=-1*this.panzoom.current[this.isHorizontal?"e":"f"]:s[i]&&(l=s[i].pos||0),n=this.isHorizontal?this.isRTL?"right":"left":"top",this.isRTL&&this.isHorizontal&&(l*=-1);for(const t of this.slides)t.el?("top"===n?(t.el.style.right="",t.el.style.left=""):t.el.style.top="",t.index!==a?t.el.style[n]=0===r?"":`${r}px`:t.el.style[n]="",h+=t.dim+t.gap,a++):r+=t.dim+t.gap;if(this.isInfinite&&h)for(const i of this.slides)i.el&&(o(i.pos)o(e-t)&&(i.el.style[n]=`${r+h}px`),o(i.pos+i.gap)>=o(e-t)&&o(i.pos)>o(l+t)&&o(l)1&&(c=this.pages[u[0]],d=this.pages[u[1]]),c&&d){let t=0;for(const e of this.slides)e.el?this.inTransition.has(e.index)&&c.slides.indexOf(e)<0&&(e.el.style[n]=`${t+(c.pos-d.pos)}px`):t+=e.dim+e.gap}}createSlideEl(t){if(!this.track||!t)return;if(t.el)return;const e=document.createElement("div");r(e,this.cn("slide")),r(e,t.class),t.html&&(e.innerHTML=t.html);const i=[];this.slides.forEach(((t,e)=>{t.el&&i.push(e)}));const s=t.index;let n=null;if(i.length){let t=i.reduce(((t,e)=>Math.abs(e-s)this.page?1:-1,a=this.pages[n].pos*(this.isRTL?1:-1);if(this.page===n&&a===s.target[this.axis])return!1;this.clearTransitions();const h=s.isResting;r(this.container,this.cn("inTransition"));const l=this.pages[this.page].slides[0],c=this.pages[n].slides[0];this.inTransition.add(c.index),this.createSlideEl(c);let d=l.el,u=c.el;h||"slide"===e||(e="fadeFast",d=null);const g=this.isRTL?"next":"prev",p=this.isRTL?"prev":"next";return d&&(this.inTransition.add(l.index),l.transition=e,d.addEventListener("animationend",this.onAnimationEnd),d.classList.add(`f-${e}Out`,`to-${o>0?p:g}`)),u&&(c.transition=e,u.addEventListener("animationend",this.onAnimationEnd),u.classList.add(`f-${e}In`,`from-${o>0?g:p}`)),s.panTo({x:this.isHorizontal?a:0,y:this.isHorizontal?0:a,friction:0}),this.onChange(n),!0}manageSlideVisiblity(){const t=new Set,e=new Set,i=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const s of this.slides)i.has(s)?t.add(s):e.add(s);for(const e of this.inTransition)t.add(this.slides[e]);for(const e of t)this.createSlideEl(e),this.lazyLoadSlide(e);for(const i of e)t.has(i)||this.removeSlideEl(i);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const t="aria-hidden";let e=this.cn("isSelected");if(e)for(const i of this.slides)i.el&&(i.el.dataset.index=`${i.index}`,this.pages[this.page].slides.includes(i)?(i.el.classList.contains(e)||(r(i.el,e),this.emit("selectSlide",i)),i.el.removeAttribute(t)):(i.el.classList.contains(e)&&(h(i.el,e),this.emit("unselectSlide",i)),i.el.setAttribute(t,"true")))}flipInfiniteTrack(){const t=this.panzoom;if(!t||!this.isInfinite)return;const e="x"===this.option("axis")?"e":"f",{viewportDim:i,contentDim:s}=this;let n=t.current[e],o=t.target[e]-n,a=0,r=.5*i,h=s;this.isRTL&&this.isHorizontal?(n<-r&&(a=-1,n+=h),n>h-r&&(a=1,n-=h)):(n>r&&(a=1,n-=h),n<-h+r&&(a=-1,n+=h)),a&&(t.current[e]=n,t.target[e]=n+o)}lazyLoadSlide(t){const e=this,i=t&&t.el;if(!i)return;const s=new Set;i.querySelectorAll("[data-lazy-srcset]").forEach((t=>{t instanceof HTMLImageElement&&s.add(t)})),i.querySelectorAll("[data-lazy-src]").forEach((t=>{t instanceof HTMLImageElement?s.add(t):S(t)&&(t.style.backgroundImage=`url('${t.dataset.lazySrc||""}')`)}));const o=(t,i,s)=>{s&&(s.remove(),s=null),i.complete&&(i.style.display=""),this.option("adaptiveHeight")&&t.el&&this.pages[this.page].slides.indexOf(t)>-1&&e.setViewportHeight()};for(const e of s){let i=null;e.src=e.dataset.lazySrcset||e.dataset.lazySrc||"",delete e.dataset.lazySrc,delete e.dataset.lazySrcset,e.style.display="none",e.addEventListener("error",(()=>{o(t,e,i)})),e.addEventListener("load",(()=>{o(t,e,i)})),setTimeout((()=>{e.parentNode&&t.el&&(e.complete?o(t,e,i):(i=n(c),e.parentNode.insertBefore(i,e)))}),300)}let a=i.dataset.lazySrc;a&&a.length&&(i.style.backgroundImage=`url('${a}')`)}clearTransitions(){this.inTransition.clear(),h(this.container,this.cn("inTransition"));const t=["to-prev","to-next","from-prev","from-next"];for(const e of this.slides){const i=e.el;if(i){i.removeEventListener("animationend",this.onAnimationEnd),i.classList.remove(...t);const s=e.transition;s&&i.classList.remove(`f-${s}Out`,`f-${s}In`)}}this.manageSlideVisiblity()}onAnimationEnd(t){const e=t.target,i=e?parseInt(e.dataset.index||"",10)||0:-1,s=this.slides[i],n=t.animationName;if(!e||!s||!n)return;const o=!!this.inTransition.has(i)&&s.transition;o&&n.substring(0,o.length+2)===`f-${o}`&&this.inTransition.delete(i),this.inTransition.size||this.clearTransitions(),i===this.page&&this.emit("settle")}onDecel(t,e=0,i=0){const s=this.isInfinite,n=this.isHorizontal?e:i,o=this.pages.length;if(!o)return;const a=this.option("dragFree");let r=this.page,h=0;const l=this.axis;!s&&(t.target[l],this.viewportDim);const c=t.current[l]*(this.isRTL&&this.isHorizontal?1:-1);let{pageIndex:d}=this.getPageFromPosition(c);if(a||Math.abs(n)<10){const e=t.target[l]*(this.isRTL&&this.isHorizontal?1:-1),{pageIndex:i}=this.getPageFromPosition(e);r=i}else r=this.isRTL&&this.isHorizontal?n<0?d-1:d+1:n<0?d+1:d-1,s||(r=Math.max(0,Math.min(r,this.pages.length-1)));if(s&&(h=Math.floor(r/o)||0),r=(r%o+o)%o,a&&t.dragOffset["e"===l?"x":"y"]);else{const e=this.contentDim;let i=(this.pages[r].pos+h*e)*(this.isRTL&&this.isHorizontal?1:-1);if(Math.abs(t.target[l]-i)<.1&&t.lockedAxis===("e"==l?"y":"x"))return;if(t.target[l]===i)return;t.applyChange({panX:this.isHorizontal?i-t.target.e:0,panY:this.isHorizontal?0:i-t.target.f,friction:t.option("decelFriction")})}r!==this.page&&this.onChange(r)}onClick(t){const e=t.target,i=e&&S(e)?e.dataset:null;let s;i&&(void 0!==i.carouselPage?s="slideTo":void 0!==i.carouselNext?s="slideNext":void 0!==i.carouselPrev&&(s="slidePrev")),s?(t.preventDefault(),t.stopPropagation(),e&&!e.hasAttribute("disabled")&&this[s](i&&"slideTo"===s?i.carouselPage:void 0)):this.emit("click",t)}onSlideTo(t){const e=t.detail||0;this.slideTo(this.getPageForSlide(e),{friction:0})}onChange(t,e=0){const i=this.page;this.prevPage=i,this.page=t,this.option("adaptiveHeight")&&this.setViewportHeight(),this.emit("change",t,i,e)}onRefresh(t,e=""){let i=this.contentDim,s=this.viewportDim;this.updateMetrics(),this.contentDim===i&&this.viewportDim===s||this.slideTo(this.page,{friction:0,transition:!1})}onResize(){this.option("breakpoints")&&this.processOptions()}onBeforeTransform(){this.flipInfiniteTrack(),this.manageSlideVisiblity()}onEndAnimation(){this.emit("settle")}reInit(t=null,e=null){this.destroy(),this.state=k.Init,this.userOptions=t||this.userOptions,this.userPlugins=e||this.userPlugins,this.processOptions()}slideTo(t=0,{friction:e=this.option("friction"),transition:i=this.option("transition")}={}){if(this.state===k.Destroy)return;const s=this.panzoom,n=this.pages.length;if(!s||!n)return;if(this.transitionTo(t,i))return;const o=this.axis,a=this.getPageFromIndex(t);let r=this.pages[a].pos,h=0;if(this.isInfinite){const t=s.current[o]*(this.isRTL&&this.isHorizontal?1:-1),e=this.contentDim,i=r+e,n=r-e;Math.abs(t-i){t.el&&(n=Math.max(n,t.el.offsetHeight))}))),i.style.height=n?`${n}px`:""}getPageForSlide(t){for(const e of this.pages)for(const i of e.slides)if(i.index===t)return e.index;return-1}getVisibleSlides(t=0){var e;const i=new Set;let{contentDim:s,viewportDim:n,pages:a,page:r}=this;s=s+(null===(e=this.slides[this.slides.length-1])||void 0===e?void 0:e.gap)||0;let h=0;h=this.panzoom?-1*this.panzoom.current[this.axis]:a[r]&&a[r].pos||0,this.isInfinite&&(h-=Math.floor(h/s)*s),this.isRTL&&this.isHorizontal&&(h*=-1),h=o(h,1e3);const l=o(h-n*t,1e3),c=o(h+n*(t+1),1e3),d=this.isInfinite?[-1,0,1]:[0];for(const t of this.slides)for(const e of d){const n=t.pos+e*s,o=t.pos+t.dim+t.gap+e*s;nl&&i.add(t)}return i}getPageFromPosition(t){const{viewportDim:e,contentDim:i}=this,s=this.pages.length;let n=0,o=0;const a=this.option("center");a&&(t+=.5*e),this.isInfinite||(t=Math.max(this.slides[0].pos,Math.min(t,this.slides[this.slides.length-1].pos)));const r=i+this.slides[this.slides.length-1].gap,h=Math.floor(t/r)||0;t-=h*r;let l=this.slides[this.slides.length-1],c=this.slides.find((e=>{const i=t+(l&&!a?.5*l.dim:0);return l=e,e.pos<=i&&e.pos+e.dim+e.gap>i}));return c||(c=this.slides[this.slides.length-1]),o=this.getPageForSlide(c.index),n=o+h*s,{page:n,pageIndex:o}}destroy(){if([k.Destroy].includes(this.state))return;this.state=k.Destroy;const{container:t,viewport:e,track:i,slides:s,panzoom:n}=this,o=this.option("classes");t.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),t.removeEventListener("slideTo",this.onSlideTo),window.removeEventListener("resize",this.onResize),n&&(n.destroy(),this.panzoom=null),s&&s.forEach((t=>{this.removeSlideEl(t)})),this.detachPlugins(),this.track=null,this.viewport=null,this.page=0,e&&i&&e.replaceWith(...i.childNodes);for(const[e,i]of Object.entries(o))"container"!==e&&i&&t.classList.remove(i);this.slides=[];const a=this.events.get("ready");this.events=new Map,a&&this.events.set("ready",a)}}Object.defineProperty(H,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:E}),Object.defineProperty(H,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:z}),Object.defineProperty(H,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:I});export{H as Carousel};