function e(e,t,i){return e+"_"+t+"_"+i}function t(e){return!!e.data.tileUrl}const i="idle",s="loading",a="loaded",o="error",l="idle",h="decoding",r="decoded";class n{constructor(t,s,a,o){this.x=s,this.y=a,this.z=o,this.key=e(s,a,o),this.url=t,this.hasParent=!1,this.loadState=i,this.decodingState=l,this.styles=void 0,this._createImage()}isLoaded(){return this.loadState===a}isDecoded(){return this.decodingState===r}setStyles(e){if(e){this.styles=e;for(let e in this.styles)this.imageElement.style[e]=this.styles[e]}}tileDetached(){this.hasParent=!1,this.decodingState!==h&&(this.decodingState=l)}tileAttached(){this.hasParent=!0}_createImage(){this.imageElement=new Image,this.imageElement.setAttribute("role","presentation"),this.imageElement.setAttribute("alt",""),this.setStyles(this.styles)}decode(){if(this.loadState===a){if(this.decodingState===r)return void this._onDecoded();if(this.decodingState===h)return;this.decodingState===l&&this._startDecode()}else if(this.loadState===s){if(this.decodingState===h)return}else this._startDecode()}_startDecode(){this.loadState===o&&this._createImage(),this.imageElement.src||(this.imageElement.src=this.url),this.decodingState=h,this.loadState!==a&&(this.loadState=s),"decode"in this.imageElement?this.imageElement.decode().then((()=>{this._onDecoded()})).catch((e=>{this._onDecodeError()})):this.loadState===a?this._onDecoded():(this.imageElement.onload=()=>{this._onDecoded()},this.imageElement.onerror=e=>{this._onDecodeError()})}_onDecoded(){this.decodingState=this.hasParent?r:l,this.loadState=a,this.onDecoded&&this.onDecoded(this)}_onDecodeError(){this.decodingState=l,this.loadState=o,this.onError&&this.onError(this)}destroy(){this.imageElement&&(this.imageElement.onload=null,this.imageElement.onerror=null,this.imageElement=null),this.onError=null,this.onDecoded=null}}class d{constructor(e,t,i,s){this.tiler=s,this.tiledLayer=s.getLayer(i),this.x=e,this.y=t,this.z=i,this.isPlaceholder=!1,this.isInActiveLayer=!1,this.isAttached=!1,this.isDestroyed=!1,this.isFullyDisplayed=!1}_initImage(){if(this.tileImage)return;const e={position:"absolute",left:0,top:0,width:"auto",height:"auto",pointerEvents:"none",imageRendering:"-webkit-optimize-contrast",willChange:"transform"};if(window.pswpDebug&&window.pswpDebug.display_layer_borders){let t=["red","blue","green","white","yellow","purple","black","orange","violet"];t=t.concat(t).concat(t).concat(t).concat(t),e.outline="solid 5px "+t[this.z],e.outlineOffset="-5px"}const t=this.tiler.getBaseTileWidth(this.z),i=this.tiler.overlap,s=this.x>0?this.x*t-i:0,a=this.y>0?this.y*t-i:0;e.transform="translate("+s+"px, "+a+"px)",this.tileImage=this.tiler.manager.decodingQueue.getOrCreateImage(this.tiler.getTileUrl(this.x,this.y,this.z),this.x,this.y,this.z),this.isInActiveLayer&&this.isPlaceholder&&(this.tileImage.isLowRes=!0),this.tileImage.setStyles(e)}attach(){this.isAttached||(this.isAttached=!0,this.load())}detach(){this.isAttached&&(this.tileImage.tileDetached(),this.tileImage.imageElement&&this.tileImage.imageElement.parentNode&&this.tileImage.imageElement.remove(),this.isAttached=!1,this.isFading=!1,this.isFullyDisplayed=!1),this.fadeRaf&&(cancelAnimationFrame(this.fadeRaf),this.fadeRaf=null),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}canBeDisplayed(){return this.tileImage&&this.tileImage.loadState===a}destroy(){this.detach(),this.placeholderTile=null,this.isDestroyed=!0}load(){this._initImage(),this.tileImage.tileAttached(),this.tileImage.onDecoded=()=>{this._onImageDecoded()},this.tileImage.onError=()=>{this._onImageError()},this.tiler.manager.decodingQueue.loadImage(this.tileImage)}_onImageDecoded(e){this._addToDOM()}_onImageError(){this.tiler.manager.decodingQueue.cache.removeByKey(this.tileImage.key)}_addToDOM(){if(!this.isAttached)return;const e=this.tiler.options.fadeInDuration;if(!this.tileImage.imageElement.parentNode){if(!e||this.tiledLayer.isLowRes||this.isPlaceholder)return this.tileImage.imageElement.style.opacity=1,this.tileImage.imageElement.style.transition="none",void this.tiledLayer.addTileToDOMWithRaf(this,(()=>{this.isFullyDisplayed=!0,this.triggerDisplayed()}));this.isFading=!0,this.tileImage.imageElement.style.opacity=0,this.tileImage.imageElement.style.transition="opacity "+e+"ms linear",this.tiledLayer.addTileToDOMWithRaf(this,(()=>{this.fadeRaf=requestAnimationFrame((()=>{this.tileImage.imageElement.style.opacity=1,this.timeout=setTimeout((()=>{this.isAttached&&(this.timeout=null,this.tileImage.imageElement.transition="none",this.isFading=!1,this.isFullyDisplayed=!0,this.triggerDisplayed())}),e+200),this.fadeRaf=null}))}))}}triggerDisplayed(){this.tiler.onTileDisplayed(this)}}class m{constructor(e){this.limit=e,this._items=[]}add(e){if(this.removeByKey(e.key),this._items.push(e),this._items.length>this.limit){const e=this._items.findIndex((e=>!e.hasParent&&!e.isLowRes));if(-1!==e){this._items.splice(e,1)[0].destroy()}}}removeByKey(e){const t=this._items.findIndex((t=>t.key===e));-1!==t&&this._items.splice(t,1)}getByKey(e){return this._items.find((t=>t.key===e))}destroy(){this._items=null}}class c{constructor(e){this.images=[],this.maxDecodingCount=e.maxDecodingCount,this.minBatchRequestCount=e.minBatchRequestCount,this.cacheLimit=e.cacheLimit,this._imagesDecodingCount=0,this.cache=new m(this.cacheLimit)}cacheImage(e){e.loadState!==o&&this.cache.add(e)}hasLoadedImage(e,t,i){let s=this.getImage(e,t,i);return!(!s||s.loadState!==a)}getImage(t,i,s){let a=this.cache.getByKey(e(t,i,s));return a||(a=this.images.find((e=>e.x===t&&e.y===i&&e.z===s))),a}getOrCreateImage(e,t,i,s){let a=this.getImage(t,i,s);return a||(a=new n(e,t,i,s)),a}loadImage(e){this.images.includes(e)||(this.images.push(e),this._rafLoop||this.refresh())}refresh(){this._imagesDecodingCount=0,this._imagesLoadingCount=0,this.images=this.images.filter((e=>e.loadState!==o&&((e.loadState!==a||e.decodingState!==r)&&(!(!e.hasParent&&e.decodingState===l)&&(e.loadState===s&&this._imagesLoadingCount++,e.decodingState!==h||(this._imagesDecodingCount++,!0)))))),this.images.forEach((e=>{e.hasParent&&e.decodingState===l&&e.loadState===a&&(this._imagesDecodingCount<this.maxDecodingCount||e.isLowRes)&&this._decodeImage(e)})),this._imagesLoadingCount<this.minBatchRequestCount&&this.images.forEach((e=>{e.hasParent&&e.decodingState!==h&&this._imagesDecodingCount<this.maxDecodingCount&&this._decodeImage(e)})),0===this.images.length?this.stop():this._loop()}_decodeImage(e){this._imagesDecodingCount++,e.decode(),this.cacheImage(e)}_loop(){this._rafLoop=requestAnimationFrame((()=>{this.refresh()}))}stop(){this._rafLoop&&(cancelAnimationFrame(this._rafLoop),this._rafLoop=null)}add(e){const t=[],i=[],s=[];e.forEach((e=>{e.imageLoaded||e.imageLoading?t.push(e):e.isInActiveLayer?i.push(e):s.push(e)})),t.sort((function(e,t){return e.z-t.z})),this.images=this.images.concat(t).concat(i).concat(s)}clear(){this.images=[],this.stop()}destroy(){this.clear(),this.cache.destroy(),this.cache=void 0,this.images=[]}}class p{constructor(e){this.tiler=e,this.tiles={},this.decodingQueue=new c(e.options)}getOrCreateTile(t,i,s){const a=e(t,i,s);let o=this.getTileByKey(a);return o||(o=new d(t,i,s,this.tiler)),this.tiles[a]=o,o}getTileByKey(e){return this.tiles[e]}getTile(t,i,s){return this.getTileByKey(e(t,i,s))}_detachTile(t,i,s){const a=e(t,i,s);this.tiles[a]&&(this.tiles[a].detach(),delete this.tiles[a])}showPlaceholderTileBelow(e,t,i){if(e=Math.floor(e/2),t=Math.floor(t/2),(i-=1)<0)return!1;const s=this.decodingQueue.getImage(e,t,i);return!!(s&&s.isLoaded()&&(this.createPlaceholderTile(e,t,i),s.isDecoded()))||this.showPlaceholderTileBelow(e,t,i)}createPlaceholderTile(e,t,i){this.getOrCreateTile(e,t,i).isPlaceholder=!0}showPlaceholderTilesAbove(e,t,i,s){if((i+=1)>s)return!1;let a=0;for(let s=2*e;s<2*e+2;s++)for(let e=2*t;e<2*t+2;e++){let t=this.decodingQueue.getImage(s,e,i);t&&t.isLoaded()&&(this.createPlaceholderTile(s,e,i),t.isDecoded()&&a++)}if(a<4)for(let a=2*e;a<2*e+2;a++)for(let e=2*t;e<2*t+2;e++)this.showPlaceholderTilesAbove(a,e,i,s)}displayTiles(){let e=[];for(let t in this.tiles){let i=this.tiles[t];(i.isInActiveLayer||i.isPlaceholder)&&(i.isAttached||e.push(i))}const t=[],i=[],s=[];e.forEach((e=>{e.imageLoaded||e.imageLoading?t.push(e):e.isInActiveLayer?i.push(e):s.push(e)})),t.sort((function(e,t){return e.z-t.z})),e=[],e=e.concat(t).concat(i).concat(s),e.forEach((e=>{e.attach(),this.decodingQueue.cacheImage(e.tileImage)}))}destroyUnusedTiles(){for(let e in this.tiles){let t=this.tiles[e];t.isPlaceholder||t.isInActiveLayer||this._detachTile(t.x,t.y,t.z)}}activeTilesLoaded(){for(let e in this.tiles){let t=this.tiles[e];if(t.isInActiveLayer&&!t.isFullyDisplayed&&!t.isFading)return!1}return!0}resetTilesRelations(){for(let e in this.tiles){let t=this.tiles[e];t.isPlaceholder=!1,t.isInActiveLayer=!1}}destroy(){for(let e in this.tiles){this.tiles[e].destroy()}this.decodingQueue.destroy(),this.tiles={}}}function u(e,t,i){let s=Math.floor(e/t);return s=Math.max(s,0),s=Math.min(s,i-1),s}class g{constructor(e,t,i,s,a,o,l){this.tiler=e,this.z=t,this.scale=i,this.originalWidth=s,this.originalHeight=a,this.numXTiles=o,this.numYTiles=l,this.tileScale=1,this.element=void 0,this.preventNewTiles=!1,this.isActive=!1}activate(){this.isActive||(this.isActive=!0,this.element||(this.element=document.createElement("div"),this.element.className="pswp__deepzoom-tiles-container",this.element.style.position="absolute",this.element.style.left=0,this.element.dataset.z=this.z,this.element.style.top=0,this.element.style.zIndex=10*this.z+10,this.tiler.slide.container.appendChild(this.element)))}addTileToDOMWithRaf(e,t){requestAnimationFrame((()=>{e.isAttached&&e.tileImage.imageElement&&!e.tileImage.imageElement.parentNode&&(this.element.appendChild(e.tileImage.imageElement),t&&t())}))}updateScale(){this.tileScale=this.tiler.width/this.originalWidth,this.element&&(this.element.style.transform="scale("+this.tileScale+")")}updateTilesVisibility(e){if(!this.isActive)return[];this.updateScale(),this.getTileCoordinatesInViewport().forEach((t=>{let i=this.tiler.manager.getOrCreateTile(t.x,t.y,this.z);i.isInActiveLayer=!0,i.isPlaceholder=!!e,e||i.canBeDisplayed()&&i.isFullyDisplayed||(this.tiler.manager.showPlaceholderTileBelow(i.x,i.y,i.z),this.tiler.manager.showPlaceholderTilesAbove(i.x,i.y,i.z,this.z+1))}))}getTileCoordinatesInViewport(){const{slide:e}=this.tiler,t=e.currZoomLevel/(e.currentResolution||e.zoomLevels.initial),i=this.tiler.getBaseTileHeight(this.z)*this.tileScale*t,s=i,a=e.pan.x,o=e.pan.y,l=this.tiler.pswp.viewportSize.x,h=this.tiler.pswp.viewportSize.y,r=u(-a,i,this.numXTiles),n=u(l-a,i,this.numXTiles),d=u(-o,s,this.numYTiles),m=u(h-o,s,this.numYTiles),c=[];for(let e=d;e<=m;e++)for(let t=r;t<=n;t++)c.push({x:t,y:e,z:this.z});return c}destroy(){this.element&&(this.element.remove(),this.element=void 0)}}class y{constructor(e,t){this.slide=e,this.data=e.data,this.pswp=e.pswp,this.options=t,this.tileSize=this.data.tileSize||t.tileSize,this.tileType=this.data.tileType||this.options.tileType||"deepzoom",this.overlap=this.data.tileOverlap||t.tileOverlap||0,this.maxWidth=this.data.maxWidth,this.maxHeight=this.data.maxHeight,this.options.maxTilePixelRatio>1&&window.devicePixelRatio>1?this.tilePixelRatio=Math.min(window.devicePixelRatio,this.options.maxTilePixelRatio):this.tilePixelRatio=1,this.layers=[],this.manager=new p(this),this.blockLoading=!1,this.activeLayer=void 0,this.prevActiveLayer=void 0,this._prevProps={},"deepzoom"===this.tileType?this.setupDeepzoomLayers():"zoomify"===this.tileType&&this.setupZoomifyLayers(),this.createLayers()}setupDeepzoomLayers(){this.minZoomLayer=0,this.maxZoomLayer=Math.ceil(Math.log(Math.max(this.maxWidth,this.maxHeight))/Math.log(2))}setupZoomifyLayers(){let e=this.maxWidth,t=this.maxHeight;for(this._zoomifyLayers=[],this._addZoomifyLayer(e,t),this._totalZoomifyTilesCount=0;e>this.tileSize||t>this.tileSize;)e/=2,t/=2,this._addZoomifyLayer(e,t);this._zoomifyLayers.reverse(),this.minZoomLayer=0,this.maxZoomLayer=this._zoomifyLayers.length-1}createLayers(){let e,t,i;for(let s=this.minZoomLayer;s<=this.maxZoomLayer;s++)e=1/Math.pow(2,this.maxZoomLayer-s),t=Math.ceil(this.maxWidth*e),i=Math.ceil(this.maxHeight*e),this.layers.push(new g(this,s,e,t,i,Math.ceil(t/this.getBaseTileWidth(s)),Math.ceil(i/this.getBaseTileWidth(s))))}getBaseTileWidth(e){return this.tileSize}getBaseTileHeight(e){return this.tileSize}setSize(e,t,i,s){const{slide:a}=this;if(1!==a.currZoomLevel/(a.currentResolution||a.zoomLevels.initial))return;let o;if(this.width=e,this.height=t,e===this._prevProps.width&&t===this._prevProps.height||(o=!0),a.pan.x!==this._prevProps.x||(a.pan.y,this._prevProps.y),this._prevProps.width=e,this._prevProps.height=t,this._prevProps.x=a.pan.x,this._prevProps.y=a.pan.y,o)return this.updateSize(),void(this._updateSizeRaf&&(cancelAnimationFrame(this._updateSizeRaf),this._updateSizeRaf=void 0));this._updateSizeRaf||(this._updateSizeRaf=requestAnimationFrame((()=>{this._updateSizeRaf=void 0,this.updateSize()})))}updatePrimaryImageVisibility(){if(this.slide.primaryImageWidth&&this.width){if(this.width<=Math.round(this.pswp.currSlide.zoomLevels.fit*this.maxWidth))return!0;if(this.slide.primaryImageWidth/this.tilePixelRatio>=this.width)return!0}return!1}updateSize(){const e=this.options.useLowResLayer;let t;this.manager.resetTilesRelations(),e&&(t=this.layers.find((e=>e.originalWidth>=this.tileSize||e.originalHeight>=this.tileSize)));if(this.updatePrimaryImageVisibility())return void this.manager.destroyUnusedTiles();let i=this.layers.find((e=>e.originalWidth/this.tilePixelRatio>=this.width));i||(i=this.layers[this.layers.length-1]),this.activeLayer=i,this.layers.forEach((e=>{e.activate(),e===this.activeLayer?e.updateTilesVisibility():e===t?e.updateTilesVisibility(!0):e.updateScale()})),this.manager.destroyUnusedTiles(),this.blockLoading||this.manager.displayTiles()}onTileDisplayed(e){this.setSize(this.width,this.height,!1,!0)}getLayer(e){return this.layers.find((t=>t.z===e))}getTileUrl(e,t,i){if(this.options.getTileUrlFn)return this.options.getTileUrlFn(this.data,e,t,i);switch(this.tileType){case"deepzoom":return this.getDeepzoomTileUrl(e,t,i);case"zoomify":return this.getZoomifyTileUrl(e,t,i);default:return!1}}getDeepzoomTileUrl(e,t,i){return(this.data.tileUrl||this.options.tileUrl).replace("{x}",e).replace("{y}",t).replace("{z}",i)}getZoomifyTileUrl(e,t,i){let s=0;for(let e=0;e<i;e++)s+=this._zoomifyLayers[e].xTilesCount*this._zoomifyLayers[e].yTilesCount;return s+=this._zoomifyLayers[i].xTilesCount*t+e,(this.data.tileUrl||this.options.tileUrl).replace("{zoomify_group}",Math.floor(s/256)).replace("{x}",e).replace("{y}",t).replace("{z}",i)}_addZoomifyLayer(e,t){this._zoomifyLayers.push({xTilesCount:Math.ceil(e/this.tileSize),yTilesCount:Math.ceil(t/this.tileSize)})}destroy(){clearTimeout(this._setSizeTimeout),this._setSizeTimeout=void 0,this.layers.forEach((e=>{e.destroy()})),this.manager.destroy(),this._updateLayersRaf&&cancelAnimationFrame(this._updateLayersRaf)}}class f{constructor(e,i){this.pswp=e,this.options=i,e.on("uiRegister",(()=>{i.incrementalZoomButtons&&this.addButtons()})),e.on("imageClickAction",(i=>{t(e.currSlide)&&(i.preventDefault(),this.incrementalZoomIn(i.point))})),e.on("doubleTapAction",(i=>{t(e.currSlide)&&(i.preventDefault(),this.incrementalZoomIn(i.point))})),e.on("keydown",(e=>{const t=e.originalEvent;let i;187===t.keyCode?i="ZoomIn":189===t.keyCode&&(i="ZoomOut"),!i||t.metaKey||t.altKey||t.ctrlKey||(e.preventDefault(),t.preventDefault(),this["incremental"+i](!1))})),this.adjustPreloaderBehavior()}addButtons(){this.pswp.ui.registerElement({name:"incrementalZoomIn",title:"Zoom In",order:10,isButton:!0,html:{isCustomSVG:!0,inner:'<path d="M17.426 19.926a6 6 0 1 1 1.5-1.5L23 22.5 21.5 24l-4.074-4.074z" id="pswp__icn-incremental-zoom-in"/><path fill="currentColor" d="M11 16v-2h6v2z"/><path fill="currentColor" d="M13 12h2v6h-2z"/>',outlineID:"pswp__icn-incremental-zoom-in"},onClick:(e,t)=>{this.incrementalZoomIn(!1),this.updateZoomInButtonState(t)},onInit:e=>{pswp.on("zoomPanUpdate",(()=>{this.updateZoomInButtonState(e)}))}}),this.pswp.ui.registerElement({name:"incrementalZoomOut",title:"Zoom Out",order:9,isButton:!0,html:{isCustomSVG:!0,inner:'<path d="M17.426 19.926a6 6 0 1 1 1.5-1.5L23 22.5 21.5 24l-4.074-4.074z" id="pswp__icn-incremental-zoom-out"/><path fill="currentColor" d="M11 16v-2h6v2z"/>',outlineID:"pswp__icn-incremental-zoom-out"},onClick:(e,t)=>{this.incrementalZoomOut(!1),this.updateZoomOutButtonState(t)},onInit:e=>{pswp.on("zoomPanUpdate",(()=>{this.updateZoomOutButtonState(e)}))}}),this.pswp.ui.registerElement({name:"zoomToStart",title:"Zoom to start position",order:8,isButton:!0,html:{isCustomSVG:!0,inner:'<path d="M11.213 9.587 9.961 7.91l-1.852 5.794 6.082-.127-1.302-1.744a5.201 5.201 0 0 1 7.614 6.768 5.2 5.2 0 0 1-7.103 1.903L12 22.928a8 8 0 1 0-.787-13.34Z" id="pswp__icn-zoom-to-start"/>',outlineID:"pswp__icn-zoom-to-start"},onClick:(e,t)=>{this.zoomToStart(),this.updateZoomToStartButtonState(t)},onInit:e=>{pswp.on("zoomPanUpdate",(()=>{this.updateZoomToStartButtonState(e)}))}})}getClosestLayerZoomLevel(e){const{tiler:t}=this.pswp.currSlide;if(!t)return e;return t.layers.map((e=>e.scale)).reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t))}adjustPreloaderBehavior(){this.pswp.on("afterInit",(()=>{this.preloaderInterval=setInterval((()=>{!document.hidden&&pswp.ui.updatePreloaderVisibility&&pswp.ui.updatePreloaderVisibility()}),500)})),this.pswp.addFilter("isContentLoading",((e,t)=>!e&&t.slide&&t.slide.tiler?!t.slide.tiler.manager.activeTilesLoaded():e)),this.pswp.on("destroy",(()=>{this.preloaderInterval&&(clearInterval(this.preloaderInterval),this.preloaderInterval=null)}))}incrementalZoomIn(e){const{tiler:t}=this.pswp.currSlide;let i;if(t){i=2*this.pswp.currSlide.currZoomLevel;const e=this.getClosestLayerZoomLevel(i);e>this.pswp.currSlide.currZoomLevel&&(i=e),i=Math.min(i,this.pswp.currSlide.zoomLevels.secondary)}else i=this.pswp.currSlide.zoomLevels.secondary;this.pswp.zoomTo(i,e,this.pswp.options.zoomAnimationDuration)}zoomToStart(){this.pswp.zoomTo(this.pswp.currSlide.zoomLevels.fit,!1,this.pswp.options.zoomAnimationDuration)}incrementalZoomOut(e){const{tiler:t}=this.pswp.currSlide;let i;if(t){i=this.pswp.currSlide.currZoomLevel/2;const e=this.getClosestLayerZoomLevel(i);e<this.pswp.currSlide.currZoomLevel&&(i=e),i=Math.max(i,this.pswp.currSlide.zoomLevels.initial)}else i=this.pswp.currSlide.zoomLevels.initial;this.pswp.zoomTo(i,e,this.pswp.options.zoomAnimationDuration)}updateZoomInButtonState(e){!this.pswp.currSlide.currZoomLevel||!this.pswp.currSlide.isZoomable()||this.pswp.currSlide.currZoomLevel>=this.pswp.currSlide.zoomLevels.secondary?e.setAttribute("disabled","disabled"):e.removeAttribute("disabled")}updateZoomOutButtonState(e){!this.pswp.currSlide.currZoomLevel||!this.pswp.currSlide.isZoomable()||this.pswp.currSlide.currZoomLevel<=this.pswp.currSlide.zoomLevels.fit?e.setAttribute("disabled","disabled"):e.removeAttribute("disabled")}updateZoomToStartButtonState(e){!this.pswp.currSlide.currZoomLevel||!this.pswp.currSlide.isZoomable()||this.pswp.currSlide.currZoomLevel<=3*this.pswp.currSlide.zoomLevels.initial?(e.setAttribute("disabled","disabled"),e.style.display="none"):(e.removeAttribute("disabled"),e.style.display="block")}}const S={fadeInDuration:150,tileWidth:256,tileOverlap:0,incrementalZoomButtons:!0,maxTilePixelRatio:2,forceWillChange:!0,cacheLimit:200,maxDecodingCount:15,minBatchRequestCount:6};class w{constructor(e,t){e.on("init",(()=>{this.handlePhotoSwipeOpen(e.pswp,t)}))}handlePhotoSwipeOpen(e,i){this.pswp=e,this.options={...S,...i},this.ui=new f(e,this.options),e.on("itemData",(e=>{this.parseItemData(e.itemData)})),e.on("zoomLevelsUpdate",(e=>{if(e.slideData.tileUrl){if(e.slideData.maxZoomWidth){const t=e.slideData.maxZoomWidth;if(t){const i=t/e.zoomLevels.elementSize.x;e.zoomLevels.max=Math.max(e.zoomLevels.initial,i)}}e.zoomLevels.secondary=e.zoomLevels.max}})),e.on("slideInit",(e=>{t(e.slide)&&this._handleTiledSlideInit(e.slide)})),e.on("slideActivate",(e=>{t(e.slide)&&this.createTiler(e.slide)})),e.on("slideDeactivate",(e=>{t(e.slide)&&this.destroyTiler(e.slide)})),e.on("slideDestroy",(e=>{t(e.slide)&&this.destroyTiler(e.slide)})),e.on("appendHeavyContent",(e=>{t(e.slide)&&this._appendHeavyContent(e.slide)})),e.on("zoomPanUpdate",(e=>{t(e.slide)&&this._handleZoomPanChange(e.slide)})),e.on("imageSizeChange",(e=>{t(e.slide)&&this.updateTilerSize(e.slide)})),e.on("change",(()=>{t(e.currSlide)&&this.updateTilerSize(e.currSlide)})),e.on("loadComplete",(e=>{t(e.slide)&&e.slide.tiler&&e.slide.tiler.updatePrimaryImageVisibility()})),this._wheelTimeout=void 0,e.on("wheel",(i=>{t(e.currSlide)&&(e.currSlide.tiler&&(e.currSlide.tiler.blockLoading=!0),this._wheelTimeout&&clearTimeout(this._wheelTimeout),this._wheelTimeout=setTimeout((()=>{e.currSlide.tiler.blockLoading=!1,e.currSlide.tiler.updateSize(),this._wheelTimeout=void 0}),85))}))}createTiler(e){e.tiler||(e.tiler=new y(e,this.options))}destroyTiler(e){e.tiler&&(e.tiler.destroy(),e.tiler=void 0,e.image&&(e.image.style.display="block"))}_handleTiledSlideInit(e){e.primaryImageWidth||(e.primaryImageWidth=e.width,e.primaryImageHeight=e.height,e.width=e.data.maxWidth,e.height=e.data.maxHeight)}_appendHeavyContent(e){this.createTiler(e),this.updateTilerSize(e)}_handleZoomPanChange(e){e.isActive&&e.tiler&&this.updateTilerSize(e)}updateTilerSize(e){const t=e.currentResolution||e.zoomLevels.initial;if(e.tiler&&e.isActive){const i=e.content.element;e.placeholder&&this._setImgStyles(e.placeholder.element,5);const s=Math.round(e.width*t),a=Math.round(e.height*t);if(i)if(this._setImgStyles(i,7),s>=e.primaryImageWidth){if(i.srcset){parseInt(i.sizes,10)>=e.primaryImageWidth&&(i.sizes=e.primaryImageWidth+"px",i.dataset.largestUsedSize=s)}i.style.width=e.primaryImageWidth+"px",i.style.height=e.primaryImageHeight+"px";const t=s/e.primaryImageWidth;i.style.transform="scale3d("+t+","+t+",1)",i.style.transformOrigin="0 0"}else i.style.transform="none";e.tiler.setSize(s,a)}else e.image&&(e.image.style.transform="none")}parseItemData(e){const t=e.element;if(!t)return;const i="A"===t.tagName?t:t.querySelector("a");i&&(i.dataset.pswpTileUrl&&(e.tileUrl=i.dataset.pswpTileUrl),i.dataset.pswpTileType&&(e.tileType=i.dataset.pswpTileType),i.dataset.pswpTileSize&&(e.tileSize=parseInt(i.dataset.pswpTileSize,10)),i.dataset.pswpMaxWidth&&(e.maxWidth=parseInt(i.dataset.pswpMaxWidth,10)),i.dataset.pswpMaxZoomWidth&&(e.maxZoomWidth=parseInt(i.dataset.pswpMaxZoomWidth,10)),i.dataset.pswpMaxHeight&&(e.maxHeight=parseInt(i.dataset.pswpMaxHeight,10)),e.tileOverlap=parseInt(i.dataset.pswpTileOverlap,10)||0)}_setImgStyles(e,t){e&&"IMG"===e.tagName&&(e.style.zIndex=t,this.options.forceWillChange&&(e.style.willChange="transform"))}}export{w as default};
