// ==UserScript==
// @name Magnet-Peek 磁力预览
// @name:en Magnet-Peek
// @namespace xyjtyskfydhqss.magnet-peek
// @version 0.0.3
// @author xyjtyskfydhqss
// @description 使用 whatslink.info 预览磁力内容
// @description:en whatslink.info for magnet search engines
// @license MIT
// @icon https://s2.loli.net/2024/04/07/VPsL8iKdaTEmA6Z.png
// @homepageURL https://sleazyfork.org/zh-CN/scripts/491847
// @match https://yhg007.com/*
// @match https://btdig.com/*
// @match https://u3c3.com/*
// @match https://sukebei.nyaa.si/*
// @require https://registry.npmmirror.com/react/18.2.0/files/umd/react.production.min.js
// @require https://registry.npmmirror.com/react-dom/18.2.0/files/umd/react-dom.production.min.js
// @require https://registry.npmmirror.com/axios/1.6.8/files/dist/axios.min.js
// @require https://registry.npmmirror.com/lodash/4.17.21/files/lodash.min.js
// @require https://registry.npmmirror.com/dayjs/1.11.10/files/dayjs.min.js
// @require https://registry.npmmirror.com/antd/5.16.1/files/dist/antd-with-locales.min.js
// @grant GM_addStyle
// @run-at document-body
// ==/UserScript==
(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const o=document.createElement("style");o.textContent=t,document.head.append(o)})(` .fancybox__backdrop {
--fancybox-bg: rgba(24, 24, 27, 0.85);
}:root{--f-spinner-width: 36px;--f-spinner-height: 36px;--f-spinner-color-1: rgba(0, 0, 0, 0.1);--f-spinner-color-2: rgba(17, 24, 28, 0.8);--f-spinner-stroke: 2.75}.f-spinner{margin:auto;padding:0;width:var(--f-spinner-width);height:var(--f-spinner-height)}.f-spinner svg{width:100%;height:100%;vertical-align:top;animation:f-spinner-rotate 2s linear infinite}.f-spinner svg *{stroke-width:var(--f-spinner-stroke);fill:none}.f-spinner svg *:first-child{stroke:var(--f-spinner-color-1)}.f-spinner svg *:last-child{stroke:var(--f-spinner-color-2);animation:f-spinner-dash 2s ease-in-out infinite}@keyframes f-spinner-rotate{100%{transform:rotate(360deg)}}@keyframes f-spinner-dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}.f-throwOutUp{animation:var(--f-throw-out-duration, 0.175s) ease-out both f-throwOutUp}.f-throwOutDown{animation:var(--f-throw-out-duration, 0.175s) ease-out both f-throwOutDown}@keyframes f-throwOutUp{to{transform:translate3d(0, calc(var(--f-throw-out-distance, 150px) * -1), 0);opacity:0}}@keyframes f-throwOutDown{to{transform:translate3d(0, var(--f-throw-out-distance, 150px), 0);opacity:0}}.f-zoomInUp{animation:var(--f-transition-duration, 0.2s) ease .1s both f-zoomInUp}.f-zoomOutDown{animation:var(--f-transition-duration, 0.2s) ease both f-zoomOutDown}@keyframes f-zoomInUp{from{transform:scale(0.975) translate3d(0, 16px, 0);opacity:0}to{transform:scale(1) translate3d(0, 0, 0);opacity:1}}@keyframes f-zoomOutDown{to{transform:scale(0.975) translate3d(0, 16px, 0);opacity:0}}.f-fadeIn{animation:var(--f-transition-duration, 0.2s) var(--f-transition-easing, ease) var(--f-transition-delay, 0s) both f-fadeIn;z-index:2}.f-fadeOut{animation:var(--f-transition-duration, 0.2s) var(--f-transition-easing, ease) var(--f-transition-delay, 0s) both f-fadeOut;z-index:1}@keyframes f-fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes f-fadeOut{100%{opacity:0}}.f-fadeFastIn{animation:var(--f-transition-duration, 0.2s) ease-out both f-fadeFastIn;z-index:2}.f-fadeFastOut{animation:var(--f-transition-duration, 0.1s) ease-out both f-fadeFastOut;z-index:2}@keyframes f-fadeFastIn{0%{opacity:.75}100%{opacity:1}}@keyframes f-fadeFastOut{100%{opacity:0}}.f-fadeSlowIn{animation:var(--f-transition-duration, 0.5s) ease both f-fadeSlowIn;z-index:2}.f-fadeSlowOut{animation:var(--f-transition-duration, 0.5s) ease both f-fadeSlowOut;z-index:1}@keyframes f-fadeSlowIn{0%{opacity:0}100%{opacity:1}}@keyframes f-fadeSlowOut{100%{opacity:0}}.f-crossfadeIn{animation:var(--f-transition-duration, 0.2s) ease-out both f-crossfadeIn;z-index:2}.f-crossfadeOut{animation:calc(var(--f-transition-duration, 0.2s)*.5) linear .1s both f-crossfadeOut;z-index:1}@keyframes f-crossfadeIn{0%{opacity:0}100%{opacity:1}}@keyframes f-crossfadeOut{100%{opacity:0}}.f-slideIn.from-next{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-slideInNext}.f-slideIn.from-prev{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-slideInPrev}.f-slideOut.to-next{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-slideOutNext}.f-slideOut.to-prev{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-slideOutPrev}@keyframes f-slideInPrev{0%{transform:translateX(100%)}100%{transform:translate3d(0, 0, 0)}}@keyframes f-slideInNext{0%{transform:translateX(-100%)}100%{transform:translate3d(0, 0, 0)}}@keyframes f-slideOutNext{100%{transform:translateX(-100%)}}@keyframes f-slideOutPrev{100%{transform:translateX(100%)}}.f-classicIn.from-next{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-classicInNext;z-index:2}.f-classicIn.from-prev{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-classicInPrev;z-index:2}.f-classicOut.to-next{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-classicOutNext;z-index:1}.f-classicOut.to-prev{animation:var(--f-transition-duration, 0.85s) cubic-bezier(0.16, 1, 0.3, 1) f-classicOutPrev;z-index:1}@keyframes f-classicInNext{0%{transform:translateX(-75px);opacity:0}100%{transform:translate3d(0, 0, 0);opacity:1}}@keyframes f-classicInPrev{0%{transform:translateX(75px);opacity:0}100%{transform:translate3d(0, 0, 0);opacity:1}}@keyframes f-classicOutNext{100%{transform:translateX(-75px);opacity:0}}@keyframes f-classicOutPrev{100%{transform:translateX(75px);opacity:0}}:root{--f-button-width: 40px;--f-button-height: 40px;--f-button-border: 0;--f-button-border-radius: 0;--f-button-color: #374151;--f-button-bg: #f8f8f8;--f-button-hover-bg: #e0e0e0;--f-button-active-bg: #d0d0d0;--f-button-shadow: none;--f-button-transition: all 0.15s ease;--f-button-transform: none;--f-button-svg-width: 20px;--f-button-svg-height: 20px;--f-button-svg-stroke-width: 1.5;--f-button-svg-fill: none;--f-button-svg-filter: none;--f-button-svg-disabled-opacity: 0.65}.f-button{display:flex;justify-content:center;align-items:center;box-sizing:content-box;position:relative;margin:0;padding:0;width:var(--f-button-width);height:var(--f-button-height);border:var(--f-button-border);border-radius:var(--f-button-border-radius);color:var(--f-button-color);background:var(--f-button-bg);box-shadow:var(--f-button-shadow);pointer-events:all;cursor:pointer;transition:var(--f-button-transition)}@media(hover: hover){.f-button:hover:not([disabled]){color:var(--f-button-hover-color);background-color:var(--f-button-hover-bg)}}.f-button:active:not([disabled]){background-color:var(--f-button-active-bg)}.f-button:focus:not(:focus-visible){outline:none}.f-button:focus-visible{outline:none;box-shadow:inset 0 0 0 var(--f-button-outline, 2px) var(--f-button-outline-color, var(--f-button-color))}.f-button svg{width:var(--f-button-svg-width);height:var(--f-button-svg-height);fill:var(--f-button-svg-fill);stroke:currentColor;stroke-width:var(--f-button-svg-stroke-width);stroke-linecap:round;stroke-linejoin:round;transition:opacity .15s ease;transform:var(--f-button-transform);filter:var(--f-button-svg-filter);pointer-events:none}.f-button[disabled]{cursor:default}.f-button[disabled] svg{opacity:var(--f-button-svg-disabled-opacity)}.f-carousel__nav .f-button.is-prev,.f-carousel__nav .f-button.is-next,.fancybox__nav .f-button.is-prev,.fancybox__nav .f-button.is-next{position:absolute;z-index:1}.is-horizontal .f-carousel__nav .f-button.is-prev,.is-horizontal .f-carousel__nav .f-button.is-next,.is-horizontal .fancybox__nav .f-button.is-prev,.is-horizontal .fancybox__nav .f-button.is-next{top:50%;transform:translateY(-50%)}.is-horizontal .f-carousel__nav .f-button.is-prev,.is-horizontal .fancybox__nav .f-button.is-prev{left:var(--f-button-prev-pos)}.is-horizontal .f-carousel__nav .f-button.is-next,.is-horizontal .fancybox__nav .f-button.is-next{right:var(--f-button-next-pos)}.is-horizontal.is-rtl .f-carousel__nav .f-button.is-prev,.is-horizontal.is-rtl .fancybox__nav .f-button.is-prev{left:auto;right:var(--f-button-next-pos)}.is-horizontal.is-rtl .f-carousel__nav .f-button.is-next,.is-horizontal.is-rtl .fancybox__nav .f-button.is-next{right:auto;left:var(--f-button-prev-pos)}.is-vertical .f-carousel__nav .f-button.is-prev,.is-vertical .f-carousel__nav .f-button.is-next,.is-vertical .fancybox__nav .f-button.is-prev,.is-vertical .fancybox__nav .f-button.is-next{top:auto;left:50%;transform:translateX(-50%)}.is-vertical .f-carousel__nav .f-button.is-prev,.is-vertical .fancybox__nav .f-button.is-prev{top:var(--f-button-next-pos)}.is-vertical .f-carousel__nav .f-button.is-next,.is-vertical .fancybox__nav .f-button.is-next{bottom:var(--f-button-next-pos)}.is-vertical .f-carousel__nav .f-button.is-prev svg,.is-vertical .f-carousel__nav .f-button.is-next svg,.is-vertical .fancybox__nav .f-button.is-prev svg,.is-vertical .fancybox__nav .f-button.is-next svg{transform:rotate(90deg)}.f-carousel__nav .f-button:disabled,.fancybox__nav .f-button:disabled{pointer-events:none}html.with-fancybox{width:auto;overflow:visible;scroll-behavior:auto}html.with-fancybox body{touch-action:none}html.with-fancybox body.hide-scrollbar{width:auto;margin-right:calc(var(--fancybox-body-margin, 0px) + var(--fancybox-scrollbar-compensate, 0px));overflow:hidden !important;overscroll-behavior-y:none}.fancybox__container{--fancybox-color: #dbdbdb;--fancybox-hover-color: #fff;--fancybox-bg: rgba(24, 24, 27, 0.98);--fancybox-slide-gap: 10px;--f-spinner-width: 50px;--f-spinner-height: 50px;--f-spinner-color-1: rgba(255, 255, 255, 0.1);--f-spinner-color-2: #bbb;--f-spinner-stroke: 3.65;position:fixed;top:0;left:0;bottom:0;right:0;direction:ltr;display:flex;flex-direction:column;box-sizing:border-box;margin:0;padding:0;color:#f8f8f8;-webkit-tap-highlight-color:rgba(0,0,0,0);overflow:visible;z-index:var(--fancybox-zIndex, 1050);outline:none;transform-origin:top left;-webkit-text-size-adjust:100%;-moz-text-size-adjust:none;-ms-text-size-adjust:100%;text-size-adjust:100%;overscroll-behavior-y:contain}.fancybox__container *,.fancybox__container *::before,.fancybox__container *::after{box-sizing:inherit}.fancybox__container *:empty{display:block}.fancybox__container::backdrop{background-color:rgba(0,0,0,0)}.fancybox__backdrop{position:fixed;top:0;left:0;bottom:0;right:0;z-index:-1;background:var(--fancybox-bg);opacity:var(--fancybox-opacity, 1);will-change:opacity}.fancybox__carousel{position:relative;box-sizing:border-box;flex:1;min-height:0;z-index:10;overflow-y:visible;overflow-x:clip}.fancybox__viewport{width:100%;height:100%}.fancybox__viewport.is-draggable{cursor:move;cursor:grab}.fancybox__viewport.is-dragging{cursor:move;cursor:grabbing}.fancybox__track{display:flex;margin:0 auto;height:100%}.fancybox__slide{flex:0 0 auto;position:relative;display:flex;flex-direction:column;align-items:center;width:100%;height:100%;margin:0 var(--fancybox-slide-gap) 0 0;padding:4px;overflow:auto;overscroll-behavior:contain;transform:translate3d(0, 0, 0);backface-visibility:hidden}.fancybox__container:not(.is-compact) .fancybox__slide.has-close-btn{padding-top:40px}.fancybox__slide.has-iframe,.fancybox__slide.has-video,.fancybox__slide.has-html5video{overflow:hidden}.fancybox__slide.has-image{overflow:hidden}.fancybox__slide.has-image.is-animating,.fancybox__slide.has-image.is-selected{overflow:visible}.fancybox__slide::before,.fancybox__slide::after{content:"";flex:0 0 0;margin:auto}.fancybox__content{align-self:center;display:flex;flex-direction:column;position:relative;margin:0;padding:2rem;max-width:100%;color:var(--fancybox-content-color, #374151);background:var(--fancybox-content-bg, #fff);cursor:default;border-radius:0;z-index:20}.is-loading .fancybox__content{opacity:0}.is-draggable .fancybox__content{cursor:move;cursor:grab}.can-zoom_in .fancybox__content{cursor:zoom-in}.can-zoom_out .fancybox__content{cursor:zoom-out}.is-dragging .fancybox__content{cursor:move;cursor:grabbing}.fancybox__content [data-selectable],.fancybox__content [contenteditable]{cursor:auto}.fancybox__slide.has-image>.fancybox__content{padding:0;background:rgba(0,0,0,0);min-height:1px;background-repeat:no-repeat;background-size:contain;background-position:center center;transition:none;transform:translate3d(0, 0, 0);backface-visibility:hidden}.fancybox__slide.has-image>.fancybox__content>picture>img{width:100%;height:auto;max-height:100%}.is-animating .fancybox__content,.is-dragging .fancybox__content{will-change:transform,width,height}.fancybox-image{margin:auto;display:block;width:100%;height:100%;min-height:0;object-fit:contain;user-select:none;filter:blur(0px)}.fancybox__caption{align-self:center;max-width:100%;flex-shrink:0;margin:0;padding:14px 0 4px 0;overflow-wrap:anywhere;line-height:1.375;color:var(--fancybox-color, currentColor);opacity:var(--fancybox-opacity, 1);cursor:auto;visibility:visible}.is-loading .fancybox__caption,.is-closing .fancybox__caption{opacity:0;visibility:hidden}.is-compact .fancybox__caption{padding-bottom:0}.f-button.is-close-btn{--f-button-svg-stroke-width: 2;position:absolute;top:0;right:8px;z-index:40}.fancybox__content>.f-button.is-close-btn{--f-button-width: 34px;--f-button-height: 34px;--f-button-border-radius: 4px;--f-button-color: var(--fancybox-color, #fff);--f-button-hover-color: var(--fancybox-color, #fff);--f-button-bg: transparent;--f-button-hover-bg: transparent;--f-button-active-bg: transparent;--f-button-svg-width: 22px;--f-button-svg-height: 22px;position:absolute;top:-38px;right:0;opacity:.75}.is-loading .fancybox__content>.f-button.is-close-btn{visibility:hidden}.is-zooming-out .fancybox__content>.f-button.is-close-btn{visibility:hidden}.fancybox__content>.f-button.is-close-btn:hover{opacity:1}.fancybox__footer{padding:0;margin:0;position:relative}.fancybox__footer .fancybox__caption{width:100%;padding:24px;opacity:var(--fancybox-opacity, 1);transition:all .25s ease}.is-compact .fancybox__footer{position:absolute;bottom:0;left:0;right:0;z-index:20;background:rgba(24,24,27,.5)}.is-compact .fancybox__footer .fancybox__caption{padding:12px}.is-compact .fancybox__content>.f-button.is-close-btn{--f-button-border-radius: 50%;--f-button-color: #fff;--f-button-hover-color: #fff;--f-button-outline-color: #000;--f-button-bg: rgba(0, 0, 0, 0.6);--f-button-active-bg: rgba(0, 0, 0, 0.6);--f-button-hover-bg: rgba(0, 0, 0, 0.6);--f-button-svg-width: 18px;--f-button-svg-height: 18px;--f-button-svg-filter: none;top:5px;right:5px}.fancybox__nav{--f-button-width: 50px;--f-button-height: 50px;--f-button-border: 0;--f-button-border-radius: 50%;--f-button-color: var(--fancybox-color);--f-button-hover-color: var(--fancybox-hover-color);--f-button-bg: transparent;--f-button-hover-bg: rgba(24, 24, 27, 0.3);--f-button-active-bg: rgba(24, 24, 27, 0.5);--f-button-shadow: none;--f-button-transition: all 0.15s ease;--f-button-transform: none;--f-button-svg-width: 26px;--f-button-svg-height: 26px;--f-button-svg-stroke-width: 2.5;--f-button-svg-fill: none;--f-button-svg-filter: drop-shadow(1px 1px 1px rgba(24, 24, 27, 0.5));--f-button-svg-disabled-opacity: 0.65;--f-button-next-pos: 1rem;--f-button-prev-pos: 1rem;opacity:var(--fancybox-opacity, 1)}.fancybox__nav .f-button:before{position:absolute;content:"";top:-30px;right:-20px;left:-20px;bottom:-30px;z-index:1}.is-idle .fancybox__nav{animation:.15s ease-out both f-fadeOut}.is-idle.is-compact .fancybox__footer{pointer-events:none;animation:.15s ease-out both f-fadeOut}.fancybox__slide>.f-spinner{position:absolute;top:50%;left:50%;margin:var(--f-spinner-top, calc(var(--f-spinner-width) * -0.5)) 0 0 var(--f-spinner-left, calc(var(--f-spinner-height) * -0.5));z-index:30;cursor:pointer}.fancybox-protected{position:absolute;top:0;left:0;right:0;bottom:0;z-index:40;user-select:none}.fancybox-ghost{position:absolute;top:0;left:0;width:100%;height:100%;min-height:0;object-fit:contain;z-index:40;user-select:none;pointer-events:none}.fancybox-focus-guard{outline:none;opacity:0;position:fixed;pointer-events:none}.fancybox__container:not([aria-hidden]){opacity:0}.fancybox__container.is-animated[aria-hidden=false]>*:not(.fancybox__backdrop,.fancybox__carousel),.fancybox__container.is-animated[aria-hidden=false] .fancybox__carousel>*:not(.fancybox__viewport),.fancybox__container.is-animated[aria-hidden=false] .fancybox__slide>*:not(.fancybox__content){animation:var(--f-interface-enter-duration, 0.25s) ease .1s backwards f-fadeIn}.fancybox__container.is-animated[aria-hidden=false] .fancybox__backdrop{animation:var(--f-backdrop-enter-duration, 0.35s) ease backwards f-fadeIn}.fancybox__container.is-animated[aria-hidden=true]>*:not(.fancybox__backdrop,.fancybox__carousel),.fancybox__container.is-animated[aria-hidden=true] .fancybox__carousel>*:not(.fancybox__viewport),.fancybox__container.is-animated[aria-hidden=true] .fancybox__slide>*:not(.fancybox__content){animation:var(--f-interface-exit-duration, 0.15s) ease forwards f-fadeOut}.fancybox__container.is-animated[aria-hidden=true] .fancybox__backdrop{animation:var(--f-backdrop-exit-duration, 0.35s) ease forwards f-fadeOut}.has-iframe .fancybox__content,.has-map .fancybox__content,.has-pdf .fancybox__content,.has-youtube .fancybox__content,.has-vimeo .fancybox__content,.has-html5video .fancybox__content{max-width:100%;flex-shrink:1;min-height:1px;overflow:visible}.has-iframe .fancybox__content,.has-map .fancybox__content,.has-pdf .fancybox__content{width:calc(100% - 120px);height:90%}.fancybox__container.is-compact .has-iframe .fancybox__content,.fancybox__container.is-compact .has-map .fancybox__content,.fancybox__container.is-compact .has-pdf .fancybox__content{width:100%;height:100%}.has-youtube .fancybox__content,.has-vimeo .fancybox__content,.has-html5video .fancybox__content{width:960px;height:540px;max-width:100%;max-height:100%}.has-map .fancybox__content,.has-pdf .fancybox__content,.has-youtube .fancybox__content,.has-vimeo .fancybox__content,.has-html5video .fancybox__content{padding:0;background:rgba(24,24,27,.9);color:#fff}.has-map .fancybox__content{background:#e5e3df}.fancybox__html5video,.fancybox__iframe{border:0;display:block;height:100%;width:100%;background:rgba(0,0,0,0)}.fancybox-placeholder{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.f-carousel__thumbs{--f-thumb-width: 96px;--f-thumb-height: 72px;--f-thumb-outline: 0;--f-thumb-outline-color: #5eb0ef;--f-thumb-opacity: 1;--f-thumb-hover-opacity: 1;--f-thumb-selected-opacity: 1;--f-thumb-border-radius: 2px;--f-thumb-offset: 0px;--f-button-next-pos: 0;--f-button-prev-pos: 0}.f-carousel__thumbs.is-classic{--f-thumb-gap: 8px;--f-thumb-opacity: 0.5;--f-thumb-hover-opacity: 1;--f-thumb-selected-opacity: 1}.f-carousel__thumbs.is-modern{--f-thumb-gap: 4px;--f-thumb-extra-gap: 16px;--f-thumb-clip-width: 46px}.f-thumbs{position:relative;flex:0 0 auto;margin:0;overflow:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);user-select:none;perspective:1000px;transform:translateZ(0)}.f-thumbs .f-spinner{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:2px;background-image:linear-gradient(#ebeff2, #e2e8f0);z-index:-1}.f-thumbs .f-spinner svg{display:none}.f-thumbs.is-vertical{height:100%}.f-thumbs__viewport{width:100%;height:auto;overflow:hidden;transform:translate3d(0, 0, 0)}.f-thumbs__track{display:flex}.f-thumbs__slide{position:relative;flex:0 0 auto;box-sizing:content-box;display:flex;align-items:center;justify-content:center;padding:0;margin:0;width:var(--f-thumb-width);height:var(--f-thumb-height);overflow:visible;cursor:pointer}.f-thumbs__slide.is-loading img{opacity:0}.is-classic .f-thumbs__viewport{height:100%}.is-modern .f-thumbs__track{width:max-content}.is-modern .f-thumbs__track::before{content:"";position:absolute;top:0;bottom:0;left:calc((var(--f-thumb-clip-width, 0))*-0.5);width:calc(var(--width, 0)*1px + var(--f-thumb-clip-width, 0));cursor:pointer}.is-modern .f-thumbs__slide{width:var(--f-thumb-clip-width);transform:translate3d(calc(var(--shift, 0) * -1px), 0, 0);transition:none;pointer-events:none}.is-modern.is-resting .f-thumbs__slide{transition:transform .33s ease}.is-modern.is-resting .f-thumbs__slide__button{transition:clip-path .33s ease}.is-using-tab .is-modern .f-thumbs__slide:focus-within{filter:drop-shadow(-1px 0px 0px var(--f-thumb-outline-color)) drop-shadow(2px 0px 0px var(--f-thumb-outline-color)) drop-shadow(0px -1px 0px var(--f-thumb-outline-color)) drop-shadow(0px 2px 0px var(--f-thumb-outline-color))}.f-thumbs__slide__button{appearance:none;width:var(--f-thumb-width);height:100%;margin:0 -100% 0 -100%;padding:0;border:0;position:relative;border-radius:var(--f-thumb-border-radius);overflow:hidden;background:rgba(0,0,0,0);outline:none;cursor:pointer;pointer-events:auto;touch-action:manipulation;opacity:var(--f-thumb-opacity);transition:opacity .2s ease}.f-thumbs__slide__button:hover{opacity:var(--f-thumb-hover-opacity)}.f-thumbs__slide__button:focus:not(:focus-visible){outline:none}.f-thumbs__slide__button:focus-visible{outline:none;opacity:var(--f-thumb-selected-opacity)}.is-modern .f-thumbs__slide__button{--clip-path: inset( 0 calc( ((var(--f-thumb-width, 0) - var(--f-thumb-clip-width, 0))) * (1 - var(--progress, 0)) * 0.5 ) round var(--f-thumb-border-radius, 0) );clip-path:var(--clip-path)}.is-classic .is-nav-selected .f-thumbs__slide__button{opacity:var(--f-thumb-selected-opacity)}.is-classic .is-nav-selected .f-thumbs__slide__button::after{content:"";position:absolute;top:0;left:0;right:0;height:auto;bottom:0;border:var(--f-thumb-outline, 0) solid var(--f-thumb-outline-color, transparent);border-radius:var(--f-thumb-border-radius);animation:f-fadeIn .2s ease-out;z-index:10}.f-thumbs__slide__img{overflow:hidden;position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;margin:0;padding:var(--f-thumb-offset);box-sizing:border-box;pointer-events:none;object-fit:cover;border-radius:var(--f-thumb-border-radius)}.f-thumbs.is-horizontal .f-thumbs__track{padding:8px 0 12px 0}.f-thumbs.is-horizontal .f-thumbs__slide{margin:0 var(--f-thumb-gap) 0 0}.f-thumbs.is-vertical .f-thumbs__track{flex-wrap:wrap;padding:0 8px}.f-thumbs.is-vertical .f-thumbs__slide{margin:0 0 var(--f-thumb-gap) 0}.fancybox__thumbs{--f-thumb-width: 96px;--f-thumb-height: 72px;--f-thumb-border-radius: 2px;--f-thumb-outline: 2px;--f-thumb-outline-color: #ededed;position:relative;opacity:var(--fancybox-opacity, 1);transition:max-height .35s cubic-bezier(0.23, 1, 0.32, 1)}.fancybox__thumbs.is-classic{--f-thumb-gap: 8px;--f-thumb-opacity: 0.5;--f-thumb-hover-opacity: 1}.fancybox__thumbs.is-classic .f-spinner{background-image:linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05))}.fancybox__thumbs.is-modern{--f-thumb-gap: 4px;--f-thumb-extra-gap: 16px;--f-thumb-clip-width: 46px;--f-thumb-opacity: 1;--f-thumb-hover-opacity: 1}.fancybox__thumbs.is-modern .f-spinner{background-image:linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05))}.fancybox__thumbs.is-horizontal{padding:0 var(--f-thumb-gap)}.fancybox__thumbs.is-vertical{padding:var(--f-thumb-gap) 0}.is-compact .fancybox__thumbs{--f-thumb-width: 64px;--f-thumb-clip-width: 32px;--f-thumb-height: 48px;--f-thumb-extra-gap: 10px}.fancybox__thumbs.is-masked{max-height:0px !important}.is-closing .fancybox__thumbs{transition:none !important}.fancybox__toolbar{--f-progress-color: var(--fancybox-color, rgba(255, 255, 255, 0.94));--f-button-width: 46px;--f-button-height: 46px;--f-button-color: var(--fancybox-color);--f-button-hover-color: var(--fancybox-hover-color);--f-button-bg: rgba(24, 24, 27, 0.65);--f-button-hover-bg: rgba(70, 70, 73, 0.65);--f-button-active-bg: rgba(90, 90, 93, 0.65);--f-button-border-radius: 0;--f-button-svg-width: 24px;--f-button-svg-height: 24px;--f-button-svg-stroke-width: 1.5;--f-button-svg-filter: drop-shadow(1px 1px 1px rgba(24, 24, 27, 0.15));--f-button-svg-fill: none;--f-button-svg-disabled-opacity: 0.65;display:flex;flex-direction:row;justify-content:space-between;margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;color:var(--fancybox-color, currentColor);opacity:var(--fancybox-opacity, 1);text-shadow:var(--fancybox-toolbar-text-shadow, 1px 1px 1px rgba(0, 0, 0, 0.5));pointer-events:none;z-index:20}.fancybox__toolbar :focus-visible{z-index:1}.fancybox__toolbar.is-absolute,.is-compact .fancybox__toolbar{position:absolute;top:0;left:0;right:0}.is-idle .fancybox__toolbar{pointer-events:none;animation:.15s ease-out both f-fadeOut}.fancybox__toolbar__column{display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start}.fancybox__toolbar__column.is-left,.fancybox__toolbar__column.is-right{flex-grow:1;flex-basis:0}.fancybox__toolbar__column.is-right{display:flex;justify-content:flex-end;flex-wrap:nowrap}.fancybox__infobar{padding:0 5px;line-height:var(--f-button-height);text-align:center;font-size:17px;font-variant-numeric:tabular-nums;-webkit-font-smoothing:subpixel-antialiased;cursor:default;user-select:none}.fancybox__infobar span{padding:0 5px}.fancybox__infobar:not(:first-child):not(:last-child){background:var(--f-button-bg)}[data-fancybox-toggle-slideshow]{position:relative}[data-fancybox-toggle-slideshow] .f-progress{height:100%;opacity:.3}[data-fancybox-toggle-slideshow] svg g:first-child{display:flex}[data-fancybox-toggle-slideshow] svg g:last-child{display:none}.has-slideshow [data-fancybox-toggle-slideshow] svg g:first-child{display:none}.has-slideshow [data-fancybox-toggle-slideshow] svg g:last-child{display:flex}[data-fancybox-toggle-fullscreen] svg g:first-child{display:flex}[data-fancybox-toggle-fullscreen] svg g:last-child{display:none}:fullscreen [data-fancybox-toggle-fullscreen] svg g:first-child{display:none}:fullscreen [data-fancybox-toggle-fullscreen] svg g:last-child{display:flex}.f-progress{position:absolute;top:0;left:0;right:0;height:3px;transform:scaleX(0);transform-origin:0;transition-property:transform;transition-timing-function:linear;background:var(--f-progress-color, var(--f-carousel-theme-color, #0091ff));z-index:30;user-select:none;pointer-events:none}.i-icon{display:inline-block;color:inherit;font-style:normal;line-height:0;text-align:center;text-transform:none;vertical-align:-.125em;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.i-icon-spin svg{animation:i-icon-spin 1s infinite linear}.i-icon-rtl{transform:scaleX(-1)}@keyframes i-icon-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes i-icon-spin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}} `);
(function (lodash, React, axios, antd, require$$0) {
'use strict';
function _interopNamespaceDefault(e) {
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
if (e) {
for (const k in e) {
if (k !== 'default') {
const d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: () => e[k]
});
}
}
}
n.default = e;
return Object.freeze(n);
}
const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
/**
* natural-orderby v3.0.2
*
* Copyright (c) Olaf Ennen
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var compareNumbers = function compareNumbers2(numberA, numberB) {
if (numberA < numberB) {
return -1;
}
if (numberA > numberB) {
return 1;
}
return 0;
};
var compareUnicode = function compareUnicode2(stringA, stringB) {
var result = stringA.localeCompare(stringB);
return result ? result / Math.abs(result) : 0;
};
var RE_NUMBERS = /(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g;
var RE_LEADING_OR_TRAILING_WHITESPACES = /^\s+|\s+$/g;
var RE_WHITESPACES = /\s+/g;
var RE_INT_OR_FLOAT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
var RE_DATE = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/;
var RE_LEADING_ZERO = /^0+[1-9]{1}[0-9]*$/;
var RE_UNICODE_CHARACTERS = /[^\x00-\x80]/;
var stringCompare = function stringCompare2(stringA, stringB) {
if (stringA < stringB) {
return -1;
}
if (stringA > stringB) {
return 1;
}
return 0;
};
var compareChunks = function compareChunks2(chunksA, chunksB) {
var lengthA = chunksA.length;
var lengthB = chunksB.length;
var size = Math.min(lengthA, lengthB);
for (var i2 = 0; i2 < size; i2++) {
var chunkA = chunksA[i2];
var chunkB = chunksB[i2];
if (chunkA.normalizedString !== chunkB.normalizedString) {
if (chunkA.normalizedString === "" !== (chunkB.normalizedString === "")) {
return chunkA.normalizedString === "" ? -1 : 1;
}
if (chunkA.parsedNumber !== void 0 && chunkB.parsedNumber !== void 0) {
var result = compareNumbers(chunkA.parsedNumber, chunkB.parsedNumber);
if (result === 0) {
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}
return result;
} else if (chunkA.parsedNumber !== void 0 || chunkB.parsedNumber !== void 0) {
return chunkA.parsedNumber !== void 0 ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA.normalizedString + chunkB.normalizedString)) {
return compareUnicode(chunkA.normalizedString, chunkB.normalizedString);
} else {
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}
}
}
if (lengthA > size || lengthB > size) {
return lengthA <= size ? -1 : 1;
}
return 0;
};
var compareOtherTypes = function compareOtherTypes2(valueA, valueB) {
if (!valueA.chunks ? valueB.chunks : !valueB.chunks) {
return !valueA.chunks ? 1 : -1;
}
if (valueA.isNaN ? !valueB.isNaN : valueB.isNaN) {
return valueA.isNaN ? -1 : 1;
}
if (valueA.isSymbol ? !valueB.isSymbol : valueB.isSymbol) {
return valueA.isSymbol ? -1 : 1;
}
if (valueA.isObject ? !valueB.isObject : valueB.isObject) {
return valueA.isObject ? -1 : 1;
}
if (valueA.isArray ? !valueB.isArray : valueB.isArray) {
return valueA.isArray ? -1 : 1;
}
if (valueA.isFunction ? !valueB.isFunction : valueB.isFunction) {
return valueA.isFunction ? -1 : 1;
}
if (valueA.isNull ? !valueB.isNull : valueB.isNull) {
return valueA.isNull ? -1 : 1;
}
return 0;
};
var compareValues = function compareValues2(valueA, valueB) {
if (valueA.value === valueB.value) {
return 0;
}
if (valueA.parsedNumber !== void 0 && valueB.parsedNumber !== void 0) {
return compareNumbers(valueA.parsedNumber, valueB.parsedNumber);
}
if (valueA.chunks && valueB.chunks) {
return compareChunks(valueA.chunks, valueB.chunks);
}
return compareOtherTypes(valueA, valueB);
};
var normalizeAlphaChunk = function normalizeAlphaChunk2(chunk) {
return chunk.replace(RE_WHITESPACES, " ").replace(RE_LEADING_OR_TRAILING_WHITESPACES, "");
};
var parseNumber = function parseNumber2(value) {
if (value.length !== 0) {
var parsedNumber = Number(value);
if (!Number.isNaN(parsedNumber)) {
return parsedNumber;
}
}
return void 0;
};
var normalizeNumericChunk = function normalizeNumericChunk2(chunk, index, chunks) {
if (RE_INT_OR_FLOAT.test(chunk)) {
if (!RE_LEADING_ZERO.test(chunk) || index === 0 || chunks[index - 1] !== ".") {
return parseNumber(chunk) || 0;
}
}
return void 0;
};
var createChunkMap = function createChunkMap2(chunk, index, chunks) {
return {
parsedNumber: normalizeNumericChunk(chunk, index, chunks),
normalizedString: normalizeAlphaChunk(chunk)
};
};
var createChunks = function createChunks2(value) {
return value.replace(RE_NUMBERS, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0");
};
var createChunkMaps = function createChunkMaps2(value) {
var chunksMaps = createChunks(value).map(createChunkMap);
return chunksMaps;
};
var isFunction$1 = function isFunction(value) {
return typeof value === "function";
};
var isNaN$1 = function isNaN2(value) {
return Number.isNaN(value) || value instanceof Number && Number.isNaN(value.valueOf());
};
var isNull = function isNull2(value) {
return value === null;
};
var isObject$5 = function isObject(value) {
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Number) && !(value instanceof String) && !(value instanceof Boolean) && !(value instanceof Date);
};
var isSymbol$2 = function isSymbol(value) {
return typeof value === "symbol";
};
var isUndefined = function isUndefined2(value) {
return value === void 0;
};
var parseDate = function parseDate2(value) {
try {
var parsedDate = Date.parse(value);
if (!Number.isNaN(parsedDate)) {
if (RE_DATE.test(value)) {
return parsedDate;
}
}
return void 0;
} catch (_unused) {
return void 0;
}
};
var numberify = function numberify2(value) {
var parsedNumber = parseNumber(value);
if (parsedNumber !== void 0) {
return parsedNumber;
}
return parseDate(value);
};
var stringify$1 = function stringify(value) {
if (typeof value === "boolean" || value instanceof Boolean) {
return Number(value).toString();
}
if (typeof value === "number" || value instanceof Number) {
return value.toString();
}
if (value instanceof Date) {
return value.getTime().toString();
}
if (typeof value === "string" || value instanceof String) {
return value.toLowerCase().replace(RE_LEADING_OR_TRAILING_WHITESPACES, "");
}
return "";
};
var getMappedValueRecord = function getMappedValueRecord2(value) {
if (typeof value === "string" || value instanceof String || (typeof value === "number" || value instanceof Number) && !isNaN$1(value) || typeof value === "boolean" || value instanceof Boolean || value instanceof Date) {
var stringValue = stringify$1(value);
var parsedNumber = numberify(stringValue);
var chunks = createChunkMaps(parsedNumber ? "" + parsedNumber : stringValue);
return {
parsedNumber,
chunks,
value
};
}
return {
isArray: Array.isArray(value),
isFunction: isFunction$1(value),
isNaN: isNaN$1(value),
isNull: isNull(value),
isObject: isObject$5(value),
isSymbol: isSymbol$2(value),
isUndefined: isUndefined(value),
value
};
};
var compareMultiple = function compareMultiple2(recordA, recordB, orders) {
var indexA = recordA.index, valuesA = recordA.values;
var indexB = recordB.index, valuesB = recordB.values;
var length2 = valuesA.length;
var ordersLength = orders.length;
for (var i2 = 0; i2 < length2; i2++) {
var order = i2 < ordersLength ? orders[i2] : null;
if (order && typeof order === "function") {
var result = order(valuesA[i2].value, valuesB[i2].value);
if (result) {
return result;
}
} else {
var _result = compareValues(valuesA[i2], valuesB[i2]);
if (_result) {
return _result * (order === "desc" ? -1 : 1);
}
}
}
return indexA - indexB;
};
var createIdentifierFn = function createIdentifierFn2(identifier2) {
if (typeof identifier2 === "function") {
return identifier2;
}
return function(value) {
if (Array.isArray(value)) {
var index = Number(identifier2);
if (Number.isInteger(index)) {
return value[index];
}
} else if (value && typeof value === "object") {
var result = Object.getOwnPropertyDescriptor(value, identifier2);
return result == null ? void 0 : result.value;
}
return value;
};
};
var getElementByIndex = function getElementByIndex2(collection, index) {
return collection[index];
};
var getValueByIdentifier = function getValueByIdentifier2(value, getValue) {
return getValue(value);
};
var baseOrderBy = function baseOrderBy2(collection, identifiers, orders) {
var identifierFns = identifiers.length ? identifiers.map(createIdentifierFn) : [function(value) {
return value;
}];
var mappedCollection = collection.map(function(element, index) {
var values = identifierFns.map(function(identifier2) {
return getValueByIdentifier(element, identifier2);
}).map(getMappedValueRecord);
return {
index,
values
};
});
mappedCollection.sort(function(recordA, recordB) {
return compareMultiple(recordA, recordB, orders);
});
return mappedCollection.map(function(element) {
return getElementByIndex(collection, element.index);
});
};
var getIdentifiers = function getIdentifiers2(identifiers) {
if (!identifiers) {
return [];
}
var identifierList = !Array.isArray(identifiers) ? [identifiers] : [].concat(identifiers);
if (identifierList.some(function(identifier2) {
return typeof identifier2 !== "string" && typeof identifier2 !== "number" && typeof identifier2 !== "function";
})) {
return [];
}
return identifierList;
};
var getOrders = function getOrders2(orders) {
if (!orders) {
return [];
}
var orderList = !Array.isArray(orders) ? [orders] : [].concat(orders);
if (orderList.some(function(order) {
return order !== "asc" && order !== "desc" && typeof order !== "function";
})) {
return [];
}
return orderList;
};
function orderBy(collection, identifiers, orders) {
if (!collection || !Array.isArray(collection)) {
return [];
}
var validatedIdentifiers = getIdentifiers(identifiers);
var validatedOrders = getOrders(orders);
return baseOrderBy(collection, validatedIdentifiers, validatedOrders);
}
Array.prototype.uniq = function() {
return lodash.uniq(this);
};
Array.prototype.orderBy = function(...[columns, orders]) {
return orderBy(this, columns, orders);
};
Array.prototype._map = function(field) {
return lodash.map(this, field);
};
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
function getDefaultExportFromCjs(x2) {
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
}
var jsxRuntime = { exports: {} };
var reactJsxRuntime_production_min = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var f$2 = React, k$2 = Symbol.for("react.element"), l$2 = Symbol.for("react.fragment"), m$4 = Object.prototype.hasOwnProperty, n$2 = f$2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p$2 = { key: true, ref: true, __self: true, __source: true };
function q$2(c2, a2, g2) {
var b2, d2 = {}, e2 = null, h2 = null;
void 0 !== g2 && (e2 = "" + g2);
void 0 !== a2.key && (e2 = "" + a2.key);
void 0 !== a2.ref && (h2 = a2.ref);
for (b2 in a2)
m$4.call(a2, b2) && !p$2.hasOwnProperty(b2) && (d2[b2] = a2[b2]);
if (c2 && c2.defaultProps)
for (b2 in a2 = c2.defaultProps, a2)
void 0 === d2[b2] && (d2[b2] = a2[b2]);
return { $$typeof: k$2, type: c2, key: e2, ref: h2, props: d2, _owner: n$2.current };
}
reactJsxRuntime_production_min.Fragment = l$2;
reactJsxRuntime_production_min.jsx = q$2;
reactJsxRuntime_production_min.jsxs = q$2;
{
jsxRuntime.exports = reactJsxRuntime_production_min;
}
var jsxRuntimeExports = jsxRuntime.exports;
function sheetForTag(tag) {
if (tag.sheet) {
return tag.sheet;
}
for (var i2 = 0; i2 < document.styleSheets.length; i2++) {
if (document.styleSheets[i2].ownerNode === tag) {
return document.styleSheets[i2];
}
}
}
function createStyleElement(options) {
var tag = document.createElement("style");
tag.setAttribute("data-emotion", options.key);
if (options.nonce !== void 0) {
tag.setAttribute("nonce", options.nonce);
}
tag.appendChild(document.createTextNode(""));
tag.setAttribute("data-s", "");
return tag;
}
var StyleSheet = /* @__PURE__ */ function() {
function StyleSheet2(options) {
var _this = this;
this._insertTag = function(tag) {
var before;
if (_this.tags.length === 0) {
if (_this.insertionPoint) {
before = _this.insertionPoint.nextSibling;
} else if (_this.prepend) {
before = _this.container.firstChild;
} else {
before = _this.before;
}
} else {
before = _this.tags[_this.tags.length - 1].nextSibling;
}
_this.container.insertBefore(tag, before);
_this.tags.push(tag);
};
this.isSpeedy = options.speedy === void 0 ? true : options.speedy;
this.tags = [];
this.ctr = 0;
this.nonce = options.nonce;
this.key = options.key;
this.container = options.container;
this.prepend = options.prepend;
this.insertionPoint = options.insertionPoint;
this.before = null;
}
var _proto = StyleSheet2.prototype;
_proto.hydrate = function hydrate(nodes) {
nodes.forEach(this._insertTag);
};
_proto.insert = function insert(rule) {
if (this.ctr % (this.isSpeedy ? 65e3 : 1) === 0) {
this._insertTag(createStyleElement(this));
}
var tag = this.tags[this.tags.length - 1];
if (this.isSpeedy) {
var sheet = sheetForTag(tag);
try {
sheet.insertRule(rule, sheet.cssRules.length);
} catch (e2) {
}
} else {
tag.appendChild(document.createTextNode(rule));
}
this.ctr++;
};
_proto.flush = function flush() {
this.tags.forEach(function(tag) {
return tag.parentNode && tag.parentNode.removeChild(tag);
});
this.tags = [];
this.ctr = 0;
};
return StyleSheet2;
}();
var MS = "-ms-";
var MOZ = "-moz-";
var WEBKIT = "-webkit-";
var COMMENT = "comm";
var RULESET = "rule";
var DECLARATION = "decl";
var IMPORT = "@import";
var KEYFRAMES = "@keyframes";
var LAYER = "@layer";
var abs = Math.abs;
var from = String.fromCharCode;
var assign = Object.assign;
function hash(value, length2) {
return charat(value, 0) ^ 45 ? (((length2 << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3) : 0;
}
function trim(value) {
return value.trim();
}
function match(value, pattern) {
return (value = pattern.exec(value)) ? value[0] : value;
}
function replace(value, pattern, replacement) {
return value.replace(pattern, replacement);
}
function indexof(value, search) {
return value.indexOf(search);
}
function charat(value, index) {
return value.charCodeAt(index) | 0;
}
function substr(value, begin, end) {
return value.slice(begin, end);
}
function strlen(value) {
return value.length;
}
function sizeof(value) {
return value.length;
}
function append(value, array) {
return array.push(value), value;
}
function combine(array, callback) {
return array.map(callback).join("");
}
var line = 1;
var column = 1;
var length = 0;
var position = 0;
var character = 0;
var characters = "";
function node(value, root2, parent, type, props, children, length2) {
return { value, root: root2, parent, type, props, children, line, column, length: length2, return: "" };
}
function copy(root2, props) {
return assign(node("", null, null, "", null, null, 0), root2, { length: -root2.length }, props);
}
function char() {
return character;
}
function prev() {
character = position > 0 ? charat(characters, --position) : 0;
if (column--, character === 10)
column = 1, line--;
return character;
}
function next() {
character = position < length ? charat(characters, position++) : 0;
if (column++, character === 10)
column = 1, line++;
return character;
}
function peek() {
return charat(characters, position);
}
function caret() {
return position;
}
function slice(begin, end) {
return substr(characters, begin, end);
}
function token(type) {
switch (type) {
case 0:
case 9:
case 10:
case 13:
case 32:
return 5;
case 33:
case 43:
case 44:
case 47:
case 62:
case 64:
case 126:
case 59:
case 123:
case 125:
return 4;
case 58:
return 3;
case 34:
case 39:
case 40:
case 91:
return 2;
case 41:
case 93:
return 1;
}
return 0;
}
function alloc(value) {
return line = column = 1, length = strlen(characters = value), position = 0, [];
}
function dealloc(value) {
return characters = "", value;
}
function delimit(type) {
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
}
function whitespace(type) {
while (character = peek())
if (character < 33)
next();
else
break;
return token(type) > 2 || token(character) > 3 ? "" : " ";
}
function escaping(index, count) {
while (--count && next())
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97)
break;
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
}
function delimiter(type) {
while (next())
switch (character) {
case type:
return position;
case 34:
case 39:
if (type !== 34 && type !== 39)
delimiter(character);
break;
case 40:
if (type === 41)
delimiter(type);
break;
case 92:
next();
break;
}
return position;
}
function commenter(type, index) {
while (next())
if (type + character === 47 + 10)
break;
else if (type + character === 42 + 42 && peek() === 47)
break;
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
}
function identifier(index) {
while (!token(peek()))
next();
return slice(index, position);
}
function compile(value) {
return dealloc(parse$1("", null, null, null, [""], value = alloc(value), 0, [0], value));
}
function parse$1(value, root2, parent, rule, rules, rulesets, pseudo, points, declarations) {
var index = 0;
var offset = 0;
var length2 = pseudo;
var atrule = 0;
var property = 0;
var previous = 0;
var variable = 1;
var scanning = 1;
var ampersand = 1;
var character2 = 0;
var type = "";
var props = rules;
var children = rulesets;
var reference = rule;
var characters2 = type;
while (scanning)
switch (previous = character2, character2 = next()) {
case 40:
if (previous != 108 && charat(characters2, length2 - 1) == 58) {
if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f") != -1)
ampersand = -1;
break;
}
case 34:
case 39:
case 91:
characters2 += delimit(character2);
break;
case 9:
case 10:
case 13:
case 32:
characters2 += whitespace(previous);
break;
case 92:
characters2 += escaping(caret() - 1, 7);
continue;
case 47:
switch (peek()) {
case 42:
case 47:
append(comment(commenter(next(), caret()), root2, parent), declarations);
break;
default:
characters2 += "/";
}
break;
case 123 * variable:
points[index++] = strlen(characters2) * ampersand;
case 125 * variable:
case 59:
case 0:
switch (character2) {
case 0:
case 125:
scanning = 0;
case 59 + offset:
if (ampersand == -1)
characters2 = replace(characters2, /\f/g, "");
if (property > 0 && strlen(characters2) - length2)
append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2), declarations);
break;
case 59:
characters2 += ";";
default:
append(reference = ruleset(characters2, root2, parent, index, offset, rules, points, type, props = [], children = [], length2), rulesets);
if (character2 === 123)
if (offset === 0)
parse$1(characters2, root2, reference, reference, props, rulesets, length2, points, children);
else
switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
case 100:
case 108:
case 109:
case 115:
parse$1(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children);
break;
default:
parse$1(characters2, reference, reference, reference, [""], children, 0, points, children);
}
}
index = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
break;
case 58:
length2 = 1 + strlen(characters2), property = previous;
default:
if (variable < 1) {
if (character2 == 123)
--variable;
else if (character2 == 125 && variable++ == 0 && prev() == 125)
continue;
}
switch (characters2 += from(character2), character2 * variable) {
case 38:
ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
break;
case 44:
points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
break;
case 64:
if (peek() === 45)
characters2 += delimit(next());
atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++;
break;
case 45:
if (previous === 45 && strlen(characters2) == 2)
variable = 0;
}
}
return rulesets;
}
function ruleset(value, root2, parent, index, offset, rules, points, type, props, children, length2) {
var post = offset - 1;
var rule = offset === 0 ? rules : [""];
var size = sizeof(rule);
for (var i2 = 0, j2 = 0, k2 = 0; i2 < index; ++i2)
for (var x2 = 0, y2 = substr(value, post + 1, post = abs(j2 = points[i2])), z2 = value; x2 < size; ++x2)
if (z2 = trim(j2 > 0 ? rule[x2] + " " + y2 : replace(y2, /&\f/g, rule[x2])))
props[k2++] = z2;
return node(value, root2, parent, offset === 0 ? RULESET : type, props, children, length2);
}
function comment(value, root2, parent) {
return node(value, root2, parent, COMMENT, from(char()), substr(value, 2, -2), 0);
}
function declaration(value, root2, parent, length2) {
return node(value, root2, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2);
}
function serialize(children, callback) {
var output = "";
var length2 = sizeof(children);
for (var i2 = 0; i2 < length2; i2++)
output += callback(children[i2], i2, children, callback) || "";
return output;
}
function stringify2(element, index, children, callback) {
switch (element.type) {
case LAYER:
if (element.children.length)
break;
case IMPORT:
case DECLARATION:
return element.return = element.return || element.value;
case COMMENT:
return "";
case KEYFRAMES:
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
case RULESET:
element.value = element.props.join(",");
}
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
}
function middleware(collection) {
var length2 = sizeof(collection);
return function(element, index, children, callback) {
var output = "";
for (var i2 = 0; i2 < length2; i2++)
output += collection[i2](element, index, children, callback) || "";
return output;
};
}
function rulesheet(callback) {
return function(element) {
if (!element.root) {
if (element = element.return)
callback(element);
}
};
}
function memoize(fn) {
var cache2 = /* @__PURE__ */ Object.create(null);
return function(arg) {
if (cache2[arg] === void 0)
cache2[arg] = fn(arg);
return cache2[arg];
};
}
var identifierWithPointTracking = function identifierWithPointTracking2(begin, points, index) {
var previous = 0;
var character2 = 0;
while (true) {
previous = character2;
character2 = peek();
if (previous === 38 && character2 === 12) {
points[index] = 1;
}
if (token(character2)) {
break;
}
next();
}
return slice(begin, position);
};
var toRules = function toRules2(parsed, points) {
var index = -1;
var character2 = 44;
do {
switch (token(character2)) {
case 0:
if (character2 === 38 && peek() === 12) {
points[index] = 1;
}
parsed[index] += identifierWithPointTracking(position - 1, points, index);
break;
case 2:
parsed[index] += delimit(character2);
break;
case 4:
if (character2 === 44) {
parsed[++index] = peek() === 58 ? "&\f" : "";
points[index] = parsed[index].length;
break;
}
default:
parsed[index] += from(character2);
}
} while (character2 = next());
return parsed;
};
var getRules = function getRules2(value, points) {
return dealloc(toRules(alloc(value), points));
};
var fixedElements = /* @__PURE__ */ new WeakMap();
var compat = function compat2(element) {
if (element.type !== "rule" || !element.parent || // positive .length indicates that this rule contains pseudo
// negative .length indicates that this rule has been already prefixed
element.length < 1) {
return;
}
var value = element.value, parent = element.parent;
var isImplicitRule = element.column === parent.column && element.line === parent.line;
while (parent.type !== "rule") {
parent = parent.parent;
if (!parent)
return;
}
if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) {
return;
}
if (isImplicitRule) {
return;
}
fixedElements.set(element, true);
var points = [];
var rules = getRules(value, points);
var parentRules = parent.props;
for (var i2 = 0, k2 = 0; i2 < rules.length; i2++) {
for (var j2 = 0; j2 < parentRules.length; j2++, k2++) {
element.props[k2] = points[i2] ? rules[i2].replace(/&\f/g, parentRules[j2]) : parentRules[j2] + " " + rules[i2];
}
}
};
var removeLabel = function removeLabel2(element) {
if (element.type === "decl") {
var value = element.value;
if (
// charcode for l
value.charCodeAt(0) === 108 && // charcode for b
value.charCodeAt(2) === 98
) {
element["return"] = "";
element.value = "";
}
}
};
function prefix(value, length2) {
switch (hash(value, length2)) {
case 5103:
return WEBKIT + "print-" + value + value;
case 5737:
case 4201:
case 3177:
case 3433:
case 1641:
case 4457:
case 2921:
case 5572:
case 6356:
case 5844:
case 3191:
case 6645:
case 3005:
case 6391:
case 5879:
case 5623:
case 6135:
case 4599:
case 4855:
case 4215:
case 6389:
case 5109:
case 5365:
case 5621:
case 3829:
return WEBKIT + value + value;
case 5349:
case 4246:
case 4810:
case 6968:
case 2756:
return WEBKIT + value + MOZ + value + MS + value + value;
case 6828:
case 4268:
return WEBKIT + value + MS + value + value;
case 6165:
return WEBKIT + value + MS + "flex-" + value + value;
case 5187:
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
case 5443:
return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value;
case 4675:
return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value;
case 5548:
return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
case 5292:
return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
case 6060:
return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
case 4554:
return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
case 6187:
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
case 5495:
case 3959:
return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1");
case 4968:
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
case 4095:
case 3583:
case 4068:
case 2532:
return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
case 8116:
case 7059:
case 5753:
case 5535:
case 5445:
case 5701:
case 4933:
case 4677:
case 5533:
case 5789:
case 5021:
case 4765:
if (strlen(value) - 1 - length2 > 6)
switch (charat(value, length2 + 1)) {
case 109:
if (charat(value, length2 + 4) !== 45)
break;
case 102:
return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length2 + 3) == 108 ? "$3" : "$2-$3")) + value;
case 115:
return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length2) + value : value;
}
break;
case 4949:
if (charat(value, length2 + 1) !== 115)
break;
case 6444:
switch (charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))) {
case 107:
return replace(value, ":", ":" + WEBKIT) + value;
case 101:
return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value;
}
break;
case 5936:
switch (charat(value, length2 + 11)) {
case 114:
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
case 108:
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
case 45:
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
}
return WEBKIT + value + MS + value + value;
}
return value;
}
var prefixer = function prefixer2(element, index, children, callback) {
if (element.length > -1) {
if (!element["return"])
switch (element.type) {
case DECLARATION:
element["return"] = prefix(element.value, element.length);
break;
case KEYFRAMES:
return serialize([copy(element, {
value: replace(element.value, "@", "@" + WEBKIT)
})], callback);
case RULESET:
if (element.length)
return combine(element.props, function(value) {
switch (match(value, /(::plac\w+|:read-\w+)/)) {
case ":read-only":
case ":read-write":
return serialize([copy(element, {
props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")]
})], callback);
case "::placeholder":
return serialize([copy(element, {
props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")]
}), copy(element, {
props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")]
}), copy(element, {
props: [replace(value, /:(plac\w+)/, MS + "input-$1")]
})], callback);
}
return "";
});
}
}
};
var defaultStylisPlugins = [prefixer];
var createCache = function createCache2(options) {
var key = options.key;
if (key === "css") {
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])");
Array.prototype.forEach.call(ssrStyles, function(node2) {
var dataEmotionAttribute = node2.getAttribute("data-emotion");
if (dataEmotionAttribute.indexOf(" ") === -1) {
return;
}
document.head.appendChild(node2);
node2.setAttribute("data-s", "");
});
}
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
var inserted = {};
var container;
var nodesToHydrate = [];
{
container = options.container || document.head;
Array.prototype.forEach.call(
// this means we will ignore elements which don't have a space in them which
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
document.querySelectorAll('style[data-emotion^="' + key + ' "]'),
function(node2) {
var attrib = node2.getAttribute("data-emotion").split(" ");
for (var i2 = 1; i2 < attrib.length; i2++) {
inserted[attrib[i2]] = true;
}
nodesToHydrate.push(node2);
}
);
}
var _insert;
var omnipresentPlugins = [compat, removeLabel];
{
var currentSheet;
var finalizingPlugins = [stringify2, rulesheet(function(rule) {
currentSheet.insert(rule);
})];
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
var stylis = function stylis2(styles) {
return serialize(compile(styles), serializer);
};
_insert = function insert(selector, serialized, sheet, shouldCache) {
currentSheet = sheet;
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
if (shouldCache) {
cache2.inserted[serialized.name] = true;
}
};
}
var cache2 = {
key,
sheet: new StyleSheet({
key,
container,
nonce: options.nonce,
speedy: options.speedy,
prepend: options.prepend,
insertionPoint: options.insertionPoint
}),
nonce: options.nonce,
inserted,
registered: {},
insert: _insert
};
cache2.sheet.hydrate(nodesToHydrate);
return cache2;
};
var reactIs$1 = { exports: {} };
var reactIs_production_min = {};
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var b$1 = "function" === typeof Symbol && Symbol.for, c$1 = b$1 ? Symbol.for("react.element") : 60103, d$2 = b$1 ? Symbol.for("react.portal") : 60106, e$1 = b$1 ? Symbol.for("react.fragment") : 60107, f$1 = b$1 ? Symbol.for("react.strict_mode") : 60108, g$1 = b$1 ? Symbol.for("react.profiler") : 60114, h$2 = b$1 ? Symbol.for("react.provider") : 60109, k$1 = b$1 ? Symbol.for("react.context") : 60110, l$1 = b$1 ? Symbol.for("react.async_mode") : 60111, m$3 = b$1 ? Symbol.for("react.concurrent_mode") : 60111, n$1 = b$1 ? Symbol.for("react.forward_ref") : 60112, p$1 = b$1 ? Symbol.for("react.suspense") : 60113, q$1 = b$1 ? Symbol.for("react.suspense_list") : 60120, r$1 = b$1 ? Symbol.for("react.memo") : 60115, t$1 = b$1 ? Symbol.for("react.lazy") : 60116, v$1 = b$1 ? Symbol.for("react.block") : 60121, w$2 = b$1 ? Symbol.for("react.fundamental") : 60117, x$1 = b$1 ? Symbol.for("react.responder") : 60118, y$2 = b$1 ? Symbol.for("react.scope") : 60119;
function z$1(a2) {
if ("object" === typeof a2 && null !== a2) {
var u2 = a2.$$typeof;
switch (u2) {
case c$1:
switch (a2 = a2.type, a2) {
case l$1:
case m$3:
case e$1:
case g$1:
case f$1:
case p$1:
return a2;
default:
switch (a2 = a2 && a2.$$typeof, a2) {
case k$1:
case n$1:
case t$1:
case r$1:
case h$2:
return a2;
default:
return u2;
}
}
case d$2:
return u2;
}
}
}
function A$1(a2) {
return z$1(a2) === m$3;
}
reactIs_production_min.AsyncMode = l$1;
reactIs_production_min.ConcurrentMode = m$3;
reactIs_production_min.ContextConsumer = k$1;
reactIs_production_min.ContextProvider = h$2;
reactIs_production_min.Element = c$1;
reactIs_production_min.ForwardRef = n$1;
reactIs_production_min.Fragment = e$1;
reactIs_production_min.Lazy = t$1;
reactIs_production_min.Memo = r$1;
reactIs_production_min.Portal = d$2;
reactIs_production_min.Profiler = g$1;
reactIs_production_min.StrictMode = f$1;
reactIs_production_min.Suspense = p$1;
reactIs_production_min.isAsyncMode = function(a2) {
return A$1(a2) || z$1(a2) === l$1;
};
reactIs_production_min.isConcurrentMode = A$1;
reactIs_production_min.isContextConsumer = function(a2) {
return z$1(a2) === k$1;
};
reactIs_production_min.isContextProvider = function(a2) {
return z$1(a2) === h$2;
};
reactIs_production_min.isElement = function(a2) {
return "object" === typeof a2 && null !== a2 && a2.$$typeof === c$1;
};
reactIs_production_min.isForwardRef = function(a2) {
return z$1(a2) === n$1;
};
reactIs_production_min.isFragment = function(a2) {
return z$1(a2) === e$1;
};
reactIs_production_min.isLazy = function(a2) {
return z$1(a2) === t$1;
};
reactIs_production_min.isMemo = function(a2) {
return z$1(a2) === r$1;
};
reactIs_production_min.isPortal = function(a2) {
return z$1(a2) === d$2;
};
reactIs_production_min.isProfiler = function(a2) {
return z$1(a2) === g$1;
};
reactIs_production_min.isStrictMode = function(a2) {
return z$1(a2) === f$1;
};
reactIs_production_min.isSuspense = function(a2) {
return z$1(a2) === p$1;
};
reactIs_production_min.isValidElementType = function(a2) {
return "string" === typeof a2 || "function" === typeof a2 || a2 === e$1 || a2 === m$3 || a2 === g$1 || a2 === f$1 || a2 === p$1 || a2 === q$1 || "object" === typeof a2 && null !== a2 && (a2.$$typeof === t$1 || a2.$$typeof === r$1 || a2.$$typeof === h$2 || a2.$$typeof === k$1 || a2.$$typeof === n$1 || a2.$$typeof === w$2 || a2.$$typeof === x$1 || a2.$$typeof === y$2 || a2.$$typeof === v$1);
};
reactIs_production_min.typeOf = z$1;
{
reactIs$1.exports = reactIs_production_min;
}
var reactIsExports = reactIs$1.exports;
var reactIs = reactIsExports;
var FORWARD_REF_STATICS = {
"$$typeof": true,
render: true,
defaultProps: true,
displayName: true,
propTypes: true
};
var MEMO_STATICS = {
"$$typeof": true,
compare: true,
defaultProps: true,
displayName: true,
propTypes: true,
type: true
};
var TYPE_STATICS = {};
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
var isBrowser$1 = true;
function getRegisteredStyles(registered, registeredStyles, classNames) {
var rawClassName = "";
classNames.split(" ").forEach(function(className) {
if (registered[className] !== void 0) {
registeredStyles.push(registered[className] + ";");
} else {
rawClassName += className + " ";
}
});
return rawClassName;
}
var registerStyles = function registerStyles2(cache2, serialized, isStringTag) {
var className = cache2.key + "-" + serialized.name;
if (
// we only need to add the styles to the registered cache if the
// class name could be used further down
// the tree but if it's a string tag, we know it won't
// so we don't have to add it to registered cache.
// this improves memory usage since we can avoid storing the whole style string
(isStringTag === false || // we need to always store it if we're in compat mode and
// in node since emotion-server relies on whether a style is in
// the registered cache to know whether a style is global or not
// also, note that this check will be dead code eliminated in the browser
isBrowser$1 === false) && cache2.registered[className] === void 0
) {
cache2.registered[className] = serialized.styles;
}
};
var insertStyles = function insertStyles2(cache2, serialized, isStringTag) {
registerStyles(cache2, serialized, isStringTag);
var className = cache2.key + "-" + serialized.name;
if (cache2.inserted[serialized.name] === void 0) {
var current = serialized;
do {
cache2.insert(serialized === current ? "." + className : "", current, cache2.sheet, true);
current = current.next;
} while (current !== void 0);
}
};
function murmur2(str) {
var h2 = 0;
var k2, i2 = 0, len = str.length;
for (; len >= 4; ++i2, len -= 4) {
k2 = str.charCodeAt(i2) & 255 | (str.charCodeAt(++i2) & 255) << 8 | (str.charCodeAt(++i2) & 255) << 16 | (str.charCodeAt(++i2) & 255) << 24;
k2 = /* Math.imul(k, m): */
(k2 & 65535) * 1540483477 + ((k2 >>> 16) * 59797 << 16);
k2 ^= /* k >>> r: */
k2 >>> 24;
h2 = /* Math.imul(k, m): */
(k2 & 65535) * 1540483477 + ((k2 >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
}
switch (len) {
case 3:
h2 ^= (str.charCodeAt(i2 + 2) & 255) << 16;
case 2:
h2 ^= (str.charCodeAt(i2 + 1) & 255) << 8;
case 1:
h2 ^= str.charCodeAt(i2) & 255;
h2 = /* Math.imul(h, m): */
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
}
h2 ^= h2 >>> 13;
h2 = /* Math.imul(h, m): */
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
return ((h2 ^ h2 >>> 15) >>> 0).toString(36);
}
var unitlessKeys = {
animationIterationCount: 1,
aspectRatio: 1,
borderImageOutset: 1,
borderImageSlice: 1,
borderImageWidth: 1,
boxFlex: 1,
boxFlexGroup: 1,
boxOrdinalGroup: 1,
columnCount: 1,
columns: 1,
flex: 1,
flexGrow: 1,
flexPositive: 1,
flexShrink: 1,
flexNegative: 1,
flexOrder: 1,
gridRow: 1,
gridRowEnd: 1,
gridRowSpan: 1,
gridRowStart: 1,
gridColumn: 1,
gridColumnEnd: 1,
gridColumnSpan: 1,
gridColumnStart: 1,
msGridRow: 1,
msGridRowSpan: 1,
msGridColumn: 1,
msGridColumnSpan: 1,
fontWeight: 1,
lineHeight: 1,
opacity: 1,
order: 1,
orphans: 1,
tabSize: 1,
widows: 1,
zIndex: 1,
zoom: 1,
WebkitLineClamp: 1,
// SVG-related properties
fillOpacity: 1,
floodOpacity: 1,
stopOpacity: 1,
strokeDasharray: 1,
strokeDashoffset: 1,
strokeMiterlimit: 1,
strokeOpacity: 1,
strokeWidth: 1
};
var hyphenateRegex$1 = /[A-Z]|^ms/g;
var animationRegex$1 = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
var isCustomProperty$1 = function isCustomProperty2(property) {
return property.charCodeAt(1) === 45;
};
var isProcessableValue$1 = function isProcessableValue2(value) {
return value != null && typeof value !== "boolean";
};
var processStyleName$1 = /* @__PURE__ */ memoize(function(styleName) {
return isCustomProperty$1(styleName) ? styleName : styleName.replace(hyphenateRegex$1, "-$&").toLowerCase();
});
var processStyleValue$1 = function processStyleValue2(key, value) {
switch (key) {
case "animation":
case "animationName": {
if (typeof value === "string") {
return value.replace(animationRegex$1, function(match2, p1, p2) {
cursor$1 = {
name: p1,
styles: p2,
next: cursor$1
};
return p1;
});
}
}
}
if (unitlessKeys[key] !== 1 && !isCustomProperty$1(key) && typeof value === "number" && value !== 0) {
return value + "px";
}
return value;
};
var noComponentSelectorMessage$1 = "Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";
function handleInterpolation$1(mergedProps, registered, interpolation) {
if (interpolation == null) {
return "";
}
if (interpolation.__emotion_styles !== void 0) {
return interpolation;
}
switch (typeof interpolation) {
case "boolean": {
return "";
}
case "object": {
if (interpolation.anim === 1) {
cursor$1 = {
name: interpolation.name,
styles: interpolation.styles,
next: cursor$1
};
return interpolation.name;
}
if (interpolation.styles !== void 0) {
var next2 = interpolation.next;
if (next2 !== void 0) {
while (next2 !== void 0) {
cursor$1 = {
name: next2.name,
styles: next2.styles,
next: cursor$1
};
next2 = next2.next;
}
}
var styles = interpolation.styles + ";";
return styles;
}
return createStringFromObject$1(mergedProps, registered, interpolation);
}
case "function": {
if (mergedProps !== void 0) {
var previousCursor = cursor$1;
var result = interpolation(mergedProps);
cursor$1 = previousCursor;
return handleInterpolation$1(mergedProps, registered, result);
}
break;
}
}
if (registered == null) {
return interpolation;
}
var cached = registered[interpolation];
return cached !== void 0 ? cached : interpolation;
}
function createStringFromObject$1(mergedProps, registered, obj) {
var string = "";
if (Array.isArray(obj)) {
for (var i2 = 0; i2 < obj.length; i2++) {
string += handleInterpolation$1(mergedProps, registered, obj[i2]) + ";";
}
} else {
for (var _key in obj) {
var value = obj[_key];
if (typeof value !== "object") {
if (registered != null && registered[value] !== void 0) {
string += _key + "{" + registered[value] + "}";
} else if (isProcessableValue$1(value)) {
string += processStyleName$1(_key) + ":" + processStyleValue$1(_key, value) + ";";
}
} else {
if (_key === "NO_COMPONENT_SELECTOR" && false) {
throw new Error(noComponentSelectorMessage$1);
}
if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
for (var _i = 0; _i < value.length; _i++) {
if (isProcessableValue$1(value[_i])) {
string += processStyleName$1(_key) + ":" + processStyleValue$1(_key, value[_i]) + ";";
}
}
} else {
var interpolated = handleInterpolation$1(mergedProps, registered, value);
switch (_key) {
case "animation":
case "animationName": {
string += processStyleName$1(_key) + ":" + interpolated + ";";
break;
}
default: {
string += _key + "{" + interpolated + "}";
}
}
}
}
}
}
return string;
}
var labelPattern$1 = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
var cursor$1;
var serializeStyles$1 = function serializeStyles2(args, registered, mergedProps) {
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
return args[0];
}
var stringMode = true;
var styles = "";
cursor$1 = void 0;
var strings = args[0];
if (strings == null || strings.raw === void 0) {
stringMode = false;
styles += handleInterpolation$1(mergedProps, registered, strings);
} else {
styles += strings[0];
}
for (var i2 = 1; i2 < args.length; i2++) {
styles += handleInterpolation$1(mergedProps, registered, args[i2]);
if (stringMode) {
styles += strings[i2];
}
}
labelPattern$1.lastIndex = 0;
var identifierName = "";
var match2;
while ((match2 = labelPattern$1.exec(styles)) !== null) {
identifierName += "-" + // $FlowFixMe we know it's not null
match2[1];
}
var name = murmur2(styles) + identifierName;
return {
name,
styles,
next: cursor$1
};
};
var syncFallback = function syncFallback2(create) {
return create();
};
var useInsertionEffect = React__namespace["useInsertionEffect"] ? React__namespace["useInsertionEffect"] : false;
var useInsertionEffectAlwaysWithSyncFallback = useInsertionEffect || syncFallback;
var hasOwn = {}.hasOwnProperty;
var EmotionCacheContext = /* @__PURE__ */ React__namespace.createContext(
// we're doing this to avoid preconstruct's dead code elimination in this one case
// because this module is primarily intended for the browser and node
// but it's also required in react native and similar environments sometimes
// and we could have a special build just for that
// but this is much easier and the native packages
// might use a different theme context in the future anyway
typeof HTMLElement !== "undefined" ? /* @__PURE__ */ createCache({
key: "css"
}) : null
);
EmotionCacheContext.Provider;
var withEmotionCache = function withEmotionCache2(func) {
return /* @__PURE__ */ React.forwardRef(function(props, ref) {
var cache2 = React.useContext(EmotionCacheContext);
return func(props, cache2, ref);
});
};
var ThemeContext = /* @__PURE__ */ React__namespace.createContext({});
var typePropName = "__EMOTION_TYPE_PLEASE_DO_NOT_USE__";
var createEmotionProps = function createEmotionProps2(type, props) {
var newProps = {};
for (var key in props) {
if (hasOwn.call(props, key)) {
newProps[key] = props[key];
}
}
newProps[typePropName] = type;
return newProps;
};
var Insertion = function Insertion2(_ref) {
var cache2 = _ref.cache, serialized = _ref.serialized, isStringTag = _ref.isStringTag;
registerStyles(cache2, serialized, isStringTag);
useInsertionEffectAlwaysWithSyncFallback(function() {
return insertStyles(cache2, serialized, isStringTag);
});
return null;
};
var Emotion = /* @__PURE__ */ withEmotionCache(function(props, cache2, ref) {
var cssProp = props.css;
if (typeof cssProp === "string" && cache2.registered[cssProp] !== void 0) {
cssProp = cache2.registered[cssProp];
}
var WrappedComponent = props[typePropName];
var registeredStyles = [cssProp];
var className = "";
if (typeof props.className === "string") {
className = getRegisteredStyles(cache2.registered, registeredStyles, props.className);
} else if (props.className != null) {
className = props.className + " ";
}
var serialized = serializeStyles$1(registeredStyles, void 0, React__namespace.useContext(ThemeContext));
className += cache2.key + "-" + serialized.name;
var newProps = {};
for (var key in props) {
if (hasOwn.call(props, key) && key !== "css" && key !== typePropName && true) {
newProps[key] = props[key];
}
}
newProps.ref = ref;
newProps.className = className;
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(Insertion, {
cache: cache2,
serialized,
isStringTag: typeof WrappedComponent === "string"
}), /* @__PURE__ */ React__namespace.createElement(WrappedComponent, newProps));
});
var Emotion$1 = Emotion;
function jsx(type, props, key) {
if (!hasOwn.call(props, "css")) {
return jsxRuntimeExports.jsx(type, props, key);
}
return jsxRuntimeExports.jsx(Emotion$1, createEmotionProps(type, props), key);
}
const APP_NAME = "magnet-peek";
function commonjsRequire(path) {
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var localforage$1 = { exports: {} };
/*!
localForage -- Offline Storage, Improved
Version 1.10.0
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/
(function(module, exports) {
(function(f2) {
{
module.exports = f2();
}
})(function() {
return function e2(t2, n2, r2) {
function s2(o3, u2) {
if (!n2[o3]) {
if (!t2[o3]) {
var a2 = typeof commonjsRequire == "function" && commonjsRequire;
if (!u2 && a2)
return a2(o3, true);
if (i2)
return i2(o3, true);
var f2 = new Error("Cannot find module '" + o3 + "'");
throw f2.code = "MODULE_NOT_FOUND", f2;
}
var l2 = n2[o3] = { exports: {} };
t2[o3][0].call(l2.exports, function(e3) {
var n3 = t2[o3][1][e3];
return s2(n3 ? n3 : e3);
}, l2, l2.exports, e2, t2, n2, r2);
}
return n2[o3].exports;
}
var i2 = typeof commonjsRequire == "function" && commonjsRequire;
for (var o2 = 0; o2 < r2.length; o2++)
s2(r2[o2]);
return s2;
}({ 1: [function(_dereq_, module2, exports2) {
(function(global2) {
var Mutation = global2.MutationObserver || global2.WebKitMutationObserver;
var scheduleDrain;
{
if (Mutation) {
var called = 0;
var observer = new Mutation(nextTick);
var element = global2.document.createTextNode("");
observer.observe(element, {
characterData: true
});
scheduleDrain = function() {
element.data = called = ++called % 2;
};
} else if (!global2.setImmediate && typeof global2.MessageChannel !== "undefined") {
var channel = new global2.MessageChannel();
channel.port1.onmessage = nextTick;
scheduleDrain = function() {
channel.port2.postMessage(0);
};
} else if ("document" in global2 && "onreadystatechange" in global2.document.createElement("script")) {
scheduleDrain = function() {
var scriptEl = global2.document.createElement("script");
scriptEl.onreadystatechange = function() {
nextTick();
scriptEl.onreadystatechange = null;
scriptEl.parentNode.removeChild(scriptEl);
scriptEl = null;
};
global2.document.documentElement.appendChild(scriptEl);
};
} else {
scheduleDrain = function() {
setTimeout(nextTick, 0);
};
}
}
var draining;
var queue = [];
function nextTick() {
draining = true;
var i2, oldQueue;
var len = queue.length;
while (len) {
oldQueue = queue;
queue = [];
i2 = -1;
while (++i2 < len) {
oldQueue[i2]();
}
len = queue.length;
}
draining = false;
}
module2.exports = immediate;
function immediate(task) {
if (queue.push(task) === 1 && !draining) {
scheduleDrain();
}
}
}).call(this, typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
}, {}], 2: [function(_dereq_, module2, exports2) {
var immediate = _dereq_(1);
function INTERNAL() {
}
var handlers = {};
var REJECTED = ["REJECTED"];
var FULFILLED = ["FULFILLED"];
var PENDING = ["PENDING"];
module2.exports = Promise2;
function Promise2(resolver) {
if (typeof resolver !== "function") {
throw new TypeError("resolver must be a function");
}
this.state = PENDING;
this.queue = [];
this.outcome = void 0;
if (resolver !== INTERNAL) {
safelyResolveThenable(this, resolver);
}
}
Promise2.prototype["catch"] = function(onRejected) {
return this.then(null, onRejected);
};
Promise2.prototype.then = function(onFulfilled, onRejected) {
if (typeof onFulfilled !== "function" && this.state === FULFILLED || typeof onRejected !== "function" && this.state === REJECTED) {
return this;
}
var promise = new this.constructor(INTERNAL);
if (this.state !== PENDING) {
var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
unwrap(promise, resolver, this.outcome);
} else {
this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
}
return promise;
};
function QueueItem(promise, onFulfilled, onRejected) {
this.promise = promise;
if (typeof onFulfilled === "function") {
this.onFulfilled = onFulfilled;
this.callFulfilled = this.otherCallFulfilled;
}
if (typeof onRejected === "function") {
this.onRejected = onRejected;
this.callRejected = this.otherCallRejected;
}
}
QueueItem.prototype.callFulfilled = function(value) {
handlers.resolve(this.promise, value);
};
QueueItem.prototype.otherCallFulfilled = function(value) {
unwrap(this.promise, this.onFulfilled, value);
};
QueueItem.prototype.callRejected = function(value) {
handlers.reject(this.promise, value);
};
QueueItem.prototype.otherCallRejected = function(value) {
unwrap(this.promise, this.onRejected, value);
};
function unwrap(promise, func, value) {
immediate(function() {
var returnValue;
try {
returnValue = func(value);
} catch (e2) {
return handlers.reject(promise, e2);
}
if (returnValue === promise) {
handlers.reject(promise, new TypeError("Cannot resolve promise with itself"));
} else {
handlers.resolve(promise, returnValue);
}
});
}
handlers.resolve = function(self2, value) {
var result = tryCatch(getThen, value);
if (result.status === "error") {
return handlers.reject(self2, result.value);
}
var thenable = result.value;
if (thenable) {
safelyResolveThenable(self2, thenable);
} else {
self2.state = FULFILLED;
self2.outcome = value;
var i2 = -1;
var len = self2.queue.length;
while (++i2 < len) {
self2.queue[i2].callFulfilled(value);
}
}
return self2;
};
handlers.reject = function(self2, error) {
self2.state = REJECTED;
self2.outcome = error;
var i2 = -1;
var len = self2.queue.length;
while (++i2 < len) {
self2.queue[i2].callRejected(error);
}
return self2;
};
function getThen(obj) {
var then = obj && obj.then;
if (obj && (typeof obj === "object" || typeof obj === "function") && typeof then === "function") {
return function appyThen() {
then.apply(obj, arguments);
};
}
}
function safelyResolveThenable(self2, thenable) {
var called = false;
function onError(value) {
if (called) {
return;
}
called = true;
handlers.reject(self2, value);
}
function onSuccess(value) {
if (called) {
return;
}
called = true;
handlers.resolve(self2, value);
}
function tryToUnwrap() {
thenable(onSuccess, onError);
}
var result = tryCatch(tryToUnwrap);
if (result.status === "error") {
onError(result.value);
}
}
function tryCatch(func, value) {
var out = {};
try {
out.value = func(value);
out.status = "success";
} catch (e2) {
out.status = "error";
out.value = e2;
}
return out;
}
Promise2.resolve = resolve;
function resolve(value) {
if (value instanceof this) {
return value;
}
return handlers.resolve(new this(INTERNAL), value);
}
Promise2.reject = reject;
function reject(reason) {
var promise = new this(INTERNAL);
return handlers.reject(promise, reason);
}
Promise2.all = all;
function all(iterable) {
var self2 = this;
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
return this.reject(new TypeError("must be an array"));
}
var len = iterable.length;
var called = false;
if (!len) {
return this.resolve([]);
}
var values = new Array(len);
var resolved = 0;
var i2 = -1;
var promise = new this(INTERNAL);
while (++i2 < len) {
allResolver(iterable[i2], i2);
}
return promise;
function allResolver(value, i3) {
self2.resolve(value).then(resolveFromAll, function(error) {
if (!called) {
called = true;
handlers.reject(promise, error);
}
});
function resolveFromAll(outValue) {
values[i3] = outValue;
if (++resolved === len && !called) {
called = true;
handlers.resolve(promise, values);
}
}
}
}
Promise2.race = race;
function race(iterable) {
var self2 = this;
if (Object.prototype.toString.call(iterable) !== "[object Array]") {
return this.reject(new TypeError("must be an array"));
}
var len = iterable.length;
var called = false;
if (!len) {
return this.resolve([]);
}
var i2 = -1;
var promise = new this(INTERNAL);
while (++i2 < len) {
resolver(iterable[i2]);
}
return promise;
function resolver(value) {
self2.resolve(value).then(function(response) {
if (!called) {
called = true;
handlers.resolve(promise, response);
}
}, function(error) {
if (!called) {
called = true;
handlers.reject(promise, error);
}
});
}
}
}, { "1": 1 }], 3: [function(_dereq_, module2, exports2) {
(function(global2) {
if (typeof global2.Promise !== "function") {
global2.Promise = _dereq_(2);
}
}).call(this, typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
}, { "2": 2 }], 4: [function(_dereq_, module2, exports2) {
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
return typeof obj;
} : function(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function getIDB() {
try {
if (typeof indexedDB !== "undefined") {
return indexedDB;
}
if (typeof webkitIndexedDB !== "undefined") {
return webkitIndexedDB;
}
if (typeof mozIndexedDB !== "undefined") {
return mozIndexedDB;
}
if (typeof OIndexedDB !== "undefined") {
return OIndexedDB;
}
if (typeof msIndexedDB !== "undefined") {
return msIndexedDB;
}
} catch (e2) {
return;
}
}
var idb = getIDB();
function isIndexedDBValid() {
try {
if (!idb || !idb.open) {
return false;
}
var isSafari = typeof openDatabase !== "undefined" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);
var hasFetch = typeof fetch === "function" && fetch.toString().indexOf("[native code") !== -1;
return (!isSafari || hasFetch) && typeof indexedDB !== "undefined" && // some outdated implementations of IDB that appear on Samsung
// and HTC Android devices <4.4 are missing IDBKeyRange
// See: https://github.com/mozilla/localForage/issues/128
// See: https://github.com/mozilla/localForage/issues/272
typeof IDBKeyRange !== "undefined";
} catch (e2) {
return false;
}
}
function createBlob(parts, properties) {
parts = parts || [];
properties = properties || {};
try {
return new Blob(parts, properties);
} catch (e2) {
if (e2.name !== "TypeError") {
throw e2;
}
var Builder = typeof BlobBuilder !== "undefined" ? BlobBuilder : typeof MSBlobBuilder !== "undefined" ? MSBlobBuilder : typeof MozBlobBuilder !== "undefined" ? MozBlobBuilder : WebKitBlobBuilder;
var builder = new Builder();
for (var i2 = 0; i2 < parts.length; i2 += 1) {
builder.append(parts[i2]);
}
return builder.getBlob(properties.type);
}
}
if (typeof Promise === "undefined") {
_dereq_(3);
}
var Promise$1 = Promise;
function executeCallback(promise, callback) {
if (callback) {
promise.then(function(result) {
callback(null, result);
}, function(error) {
callback(error);
});
}
}
function executeTwoCallbacks(promise, callback, errorCallback) {
if (typeof callback === "function") {
promise.then(callback);
}
if (typeof errorCallback === "function") {
promise["catch"](errorCallback);
}
}
function normalizeKey(key2) {
if (typeof key2 !== "string") {
console.warn(key2 + " used as a key, but it is not a string.");
key2 = String(key2);
}
return key2;
}
function getCallback() {
if (arguments.length && typeof arguments[arguments.length - 1] === "function") {
return arguments[arguments.length - 1];
}
}
var DETECT_BLOB_SUPPORT_STORE = "local-forage-detect-blob-support";
var supportsBlobs = void 0;
var dbContexts = {};
var toString = Object.prototype.toString;
var READ_ONLY = "readonly";
var READ_WRITE = "readwrite";
function _binStringToArrayBuffer(bin) {
var length3 = bin.length;
var buf = new ArrayBuffer(length3);
var arr = new Uint8Array(buf);
for (var i2 = 0; i2 < length3; i2++) {
arr[i2] = bin.charCodeAt(i2);
}
return buf;
}
function _checkBlobSupportWithoutCaching(idb2) {
return new Promise$1(function(resolve) {
var txn = idb2.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
var blob = createBlob([""]);
txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, "key");
txn.onabort = function(e2) {
e2.preventDefault();
e2.stopPropagation();
resolve(false);
};
txn.oncomplete = function() {
var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
var matchedEdge = navigator.userAgent.match(/Edge\//);
resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
};
})["catch"](function() {
return false;
});
}
function _checkBlobSupport(idb2) {
if (typeof supportsBlobs === "boolean") {
return Promise$1.resolve(supportsBlobs);
}
return _checkBlobSupportWithoutCaching(idb2).then(function(value) {
supportsBlobs = value;
return supportsBlobs;
});
}
function _deferReadiness(dbInfo) {
var dbContext = dbContexts[dbInfo.name];
var deferredOperation = {};
deferredOperation.promise = new Promise$1(function(resolve, reject) {
deferredOperation.resolve = resolve;
deferredOperation.reject = reject;
});
dbContext.deferredOperations.push(deferredOperation);
if (!dbContext.dbReady) {
dbContext.dbReady = deferredOperation.promise;
} else {
dbContext.dbReady = dbContext.dbReady.then(function() {
return deferredOperation.promise;
});
}
}
function _advanceReadiness(dbInfo) {
var dbContext = dbContexts[dbInfo.name];
var deferredOperation = dbContext.deferredOperations.pop();
if (deferredOperation) {
deferredOperation.resolve();
return deferredOperation.promise;
}
}
function _rejectReadiness(dbInfo, err) {
var dbContext = dbContexts[dbInfo.name];
var deferredOperation = dbContext.deferredOperations.pop();
if (deferredOperation) {
deferredOperation.reject(err);
return deferredOperation.promise;
}
}
function _getConnection(dbInfo, upgradeNeeded) {
return new Promise$1(function(resolve, reject) {
dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
if (dbInfo.db) {
if (upgradeNeeded) {
_deferReadiness(dbInfo);
dbInfo.db.close();
} else {
return resolve(dbInfo.db);
}
}
var dbArgs = [dbInfo.name];
if (upgradeNeeded) {
dbArgs.push(dbInfo.version);
}
var openreq = idb.open.apply(idb, dbArgs);
if (upgradeNeeded) {
openreq.onupgradeneeded = function(e2) {
var db2 = openreq.result;
try {
db2.createObjectStore(dbInfo.storeName);
if (e2.oldVersion <= 1) {
db2.createObjectStore(DETECT_BLOB_SUPPORT_STORE);
}
} catch (ex) {
if (ex.name === "ConstraintError") {
console.warn('The database "' + dbInfo.name + '" has been upgraded from version ' + e2.oldVersion + " to version " + e2.newVersion + ', but the storage "' + dbInfo.storeName + '" already exists.');
} else {
throw ex;
}
}
};
}
openreq.onerror = function(e2) {
e2.preventDefault();
reject(openreq.error);
};
openreq.onsuccess = function() {
var db2 = openreq.result;
db2.onversionchange = function(e2) {
e2.target.close();
};
resolve(db2);
_advanceReadiness(dbInfo);
};
});
}
function _getOriginalConnection(dbInfo) {
return _getConnection(dbInfo, false);
}
function _getUpgradedConnection(dbInfo) {
return _getConnection(dbInfo, true);
}
function _isUpgradeNeeded(dbInfo, defaultVersion) {
if (!dbInfo.db) {
return true;
}
var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);
var isDowngrade = dbInfo.version < dbInfo.db.version;
var isUpgrade = dbInfo.version > dbInfo.db.version;
if (isDowngrade) {
if (dbInfo.version !== defaultVersion) {
console.warn('The database "' + dbInfo.name + `" can't be downgraded from version ` + dbInfo.db.version + " to version " + dbInfo.version + ".");
}
dbInfo.version = dbInfo.db.version;
}
if (isUpgrade || isNewStore) {
if (isNewStore) {
var incVersion = dbInfo.db.version + 1;
if (incVersion > dbInfo.version) {
dbInfo.version = incVersion;
}
}
return true;
}
return false;
}
function _encodeBlob(blob) {
return new Promise$1(function(resolve, reject) {
var reader = new FileReader();
reader.onerror = reject;
reader.onloadend = function(e2) {
var base64 = btoa(e2.target.result || "");
resolve({
__local_forage_encoded_blob: true,
data: base64,
type: blob.type
});
};
reader.readAsBinaryString(blob);
});
}
function _decodeBlob(encodedBlob) {
var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
return createBlob([arrayBuff], { type: encodedBlob.type });
}
function _isEncodedBlob(value) {
return value && value.__local_forage_encoded_blob;
}
function _fullyReady(callback) {
var self2 = this;
var promise = self2._initReady().then(function() {
var dbContext = dbContexts[self2._dbInfo.name];
if (dbContext && dbContext.dbReady) {
return dbContext.dbReady;
}
});
executeTwoCallbacks(promise, callback, callback);
return promise;
}
function _tryReconnect(dbInfo) {
_deferReadiness(dbInfo);
var dbContext = dbContexts[dbInfo.name];
var forages = dbContext.forages;
for (var i2 = 0; i2 < forages.length; i2++) {
var forage = forages[i2];
if (forage._dbInfo.db) {
forage._dbInfo.db.close();
forage._dbInfo.db = null;
}
}
dbInfo.db = null;
return _getOriginalConnection(dbInfo).then(function(db2) {
dbInfo.db = db2;
if (_isUpgradeNeeded(dbInfo)) {
return _getUpgradedConnection(dbInfo);
}
return db2;
}).then(function(db2) {
dbInfo.db = dbContext.db = db2;
for (var i3 = 0; i3 < forages.length; i3++) {
forages[i3]._dbInfo.db = db2;
}
})["catch"](function(err) {
_rejectReadiness(dbInfo, err);
throw err;
});
}
function createTransaction(dbInfo, mode, callback, retries) {
if (retries === void 0) {
retries = 1;
}
try {
var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
callback(null, tx);
} catch (err) {
if (retries > 0 && (!dbInfo.db || err.name === "InvalidStateError" || err.name === "NotFoundError")) {
return Promise$1.resolve().then(function() {
if (!dbInfo.db || err.name === "NotFoundError" && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
if (dbInfo.db) {
dbInfo.version = dbInfo.db.version + 1;
}
return _getUpgradedConnection(dbInfo);
}
}).then(function() {
return _tryReconnect(dbInfo).then(function() {
createTransaction(dbInfo, mode, callback, retries - 1);
});
})["catch"](callback);
}
callback(err);
}
}
function createDbContext() {
return {
// Running localForages sharing a database.
forages: [],
// Shared database.
db: null,
// Database readiness (promise).
dbReady: null,
// Deferred operations on the database.
deferredOperations: []
};
}
function _initStorage(options) {
var self2 = this;
var dbInfo = {
db: null
};
if (options) {
for (var i2 in options) {
dbInfo[i2] = options[i2];
}
}
var dbContext = dbContexts[dbInfo.name];
if (!dbContext) {
dbContext = createDbContext();
dbContexts[dbInfo.name] = dbContext;
}
dbContext.forages.push(self2);
if (!self2._initReady) {
self2._initReady = self2.ready;
self2.ready = _fullyReady;
}
var initPromises = [];
function ignoreErrors() {
return Promise$1.resolve();
}
for (var j2 = 0; j2 < dbContext.forages.length; j2++) {
var forage = dbContext.forages[j2];
if (forage !== self2) {
initPromises.push(forage._initReady()["catch"](ignoreErrors));
}
}
var forages = dbContext.forages.slice(0);
return Promise$1.all(initPromises).then(function() {
dbInfo.db = dbContext.db;
return _getOriginalConnection(dbInfo);
}).then(function(db2) {
dbInfo.db = db2;
if (_isUpgradeNeeded(dbInfo, self2._defaultConfig.version)) {
return _getUpgradedConnection(dbInfo);
}
return db2;
}).then(function(db2) {
dbInfo.db = dbContext.db = db2;
self2._dbInfo = dbInfo;
for (var k2 = 0; k2 < forages.length; k2++) {
var forage2 = forages[k2];
if (forage2 !== self2) {
forage2._dbInfo.db = dbInfo.db;
forage2._dbInfo.version = dbInfo.version;
}
}
});
}
function getItem(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store.get(key2);
req.onsuccess = function() {
var value = req.result;
if (value === void 0) {
value = null;
}
if (_isEncodedBlob(value)) {
value = _decodeBlob(value);
}
resolve(value);
};
req.onerror = function() {
reject(req.error);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function iterate(iterator, callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store.openCursor();
var iterationNumber = 1;
req.onsuccess = function() {
var cursor2 = req.result;
if (cursor2) {
var value = cursor2.value;
if (_isEncodedBlob(value)) {
value = _decodeBlob(value);
}
var result = iterator(value, cursor2.key, iterationNumber++);
if (result !== void 0) {
resolve(result);
} else {
cursor2["continue"]();
}
} else {
resolve();
}
};
req.onerror = function() {
reject(req.error);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function setItem(key2, value, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
var dbInfo;
self2.ready().then(function() {
dbInfo = self2._dbInfo;
if (toString.call(value) === "[object Blob]") {
return _checkBlobSupport(dbInfo.db).then(function(blobSupport) {
if (blobSupport) {
return value;
}
return _encodeBlob(value);
});
}
return value;
}).then(function(value2) {
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
if (value2 === null) {
value2 = void 0;
}
var req = store.put(value2, key2);
transaction.oncomplete = function() {
if (value2 === void 0) {
value2 = null;
}
resolve(value2);
};
transaction.onabort = transaction.onerror = function() {
var err2 = req.error ? req.error : req.transaction.error;
reject(err2);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function removeItem(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store["delete"](key2);
transaction.oncomplete = function() {
resolve();
};
transaction.onerror = function() {
reject(req.error);
};
transaction.onabort = function() {
var err2 = req.error ? req.error : req.transaction.error;
reject(err2);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function clear(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_WRITE, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store.clear();
transaction.oncomplete = function() {
resolve();
};
transaction.onabort = transaction.onerror = function() {
var err2 = req.error ? req.error : req.transaction.error;
reject(err2);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function length2(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store.count();
req.onsuccess = function() {
resolve(req.result);
};
req.onerror = function() {
reject(req.error);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function key(n2, callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
if (n2 < 0) {
resolve(null);
return;
}
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var advanced = false;
var req = store.openKeyCursor();
req.onsuccess = function() {
var cursor2 = req.result;
if (!cursor2) {
resolve(null);
return;
}
if (n2 === 0) {
resolve(cursor2.key);
} else {
if (!advanced) {
advanced = true;
cursor2.advance(n2);
} else {
resolve(cursor2.key);
}
}
};
req.onerror = function() {
reject(req.error);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function keys(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
createTransaction(self2._dbInfo, READ_ONLY, function(err, transaction) {
if (err) {
return reject(err);
}
try {
var store = transaction.objectStore(self2._dbInfo.storeName);
var req = store.openKeyCursor();
var keys2 = [];
req.onsuccess = function() {
var cursor2 = req.result;
if (!cursor2) {
resolve(keys2);
return;
}
keys2.push(cursor2.key);
cursor2["continue"]();
};
req.onerror = function() {
reject(req.error);
};
} catch (e2) {
reject(e2);
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function dropInstance(options, callback) {
callback = getCallback.apply(this, arguments);
var currentConfig = this.config();
options = typeof options !== "function" && options || {};
if (!options.name) {
options.name = options.name || currentConfig.name;
options.storeName = options.storeName || currentConfig.storeName;
}
var self2 = this;
var promise;
if (!options.name) {
promise = Promise$1.reject("Invalid arguments");
} else {
var isCurrentDb = options.name === currentConfig.name && self2._dbInfo.db;
var dbPromise = isCurrentDb ? Promise$1.resolve(self2._dbInfo.db) : _getOriginalConnection(options).then(function(db2) {
var dbContext = dbContexts[options.name];
var forages = dbContext.forages;
dbContext.db = db2;
for (var i2 = 0; i2 < forages.length; i2++) {
forages[i2]._dbInfo.db = db2;
}
return db2;
});
if (!options.storeName) {
promise = dbPromise.then(function(db2) {
_deferReadiness(options);
var dbContext = dbContexts[options.name];
var forages = dbContext.forages;
db2.close();
for (var i2 = 0; i2 < forages.length; i2++) {
var forage = forages[i2];
forage._dbInfo.db = null;
}
var dropDBPromise = new Promise$1(function(resolve, reject) {
var req = idb.deleteDatabase(options.name);
req.onerror = function() {
var db3 = req.result;
if (db3) {
db3.close();
}
reject(req.error);
};
req.onblocked = function() {
console.warn('dropInstance blocked for database "' + options.name + '" until all open connections are closed');
};
req.onsuccess = function() {
var db3 = req.result;
if (db3) {
db3.close();
}
resolve(db3);
};
});
return dropDBPromise.then(function(db3) {
dbContext.db = db3;
for (var i3 = 0; i3 < forages.length; i3++) {
var _forage = forages[i3];
_advanceReadiness(_forage._dbInfo);
}
})["catch"](function(err) {
(_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function() {
});
throw err;
});
});
} else {
promise = dbPromise.then(function(db2) {
if (!db2.objectStoreNames.contains(options.storeName)) {
return;
}
var newVersion = db2.version + 1;
_deferReadiness(options);
var dbContext = dbContexts[options.name];
var forages = dbContext.forages;
db2.close();
for (var i2 = 0; i2 < forages.length; i2++) {
var forage = forages[i2];
forage._dbInfo.db = null;
forage._dbInfo.version = newVersion;
}
var dropObjectPromise = new Promise$1(function(resolve, reject) {
var req = idb.open(options.name, newVersion);
req.onerror = function(err) {
var db3 = req.result;
db3.close();
reject(err);
};
req.onupgradeneeded = function() {
var db3 = req.result;
db3.deleteObjectStore(options.storeName);
};
req.onsuccess = function() {
var db3 = req.result;
db3.close();
resolve(db3);
};
});
return dropObjectPromise.then(function(db3) {
dbContext.db = db3;
for (var j2 = 0; j2 < forages.length; j2++) {
var _forage2 = forages[j2];
_forage2._dbInfo.db = db3;
_advanceReadiness(_forage2._dbInfo);
}
})["catch"](function(err) {
(_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function() {
});
throw err;
});
});
}
}
executeCallback(promise, callback);
return promise;
}
var asyncStorage = {
_driver: "asyncStorage",
_initStorage,
_support: isIndexedDBValid(),
iterate,
getItem,
setItem,
removeItem,
clear,
length: length2,
key,
keys,
dropInstance
};
function isWebSQLValid() {
return typeof openDatabase === "function";
}
var BASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var BLOB_TYPE_PREFIX = "~~local_forage_type~";
var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
var SERIALIZED_MARKER = "__lfsc__:";
var SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;
var TYPE_ARRAYBUFFER = "arbf";
var TYPE_BLOB = "blob";
var TYPE_INT8ARRAY = "si08";
var TYPE_UINT8ARRAY = "ui08";
var TYPE_UINT8CLAMPEDARRAY = "uic8";
var TYPE_INT16ARRAY = "si16";
var TYPE_INT32ARRAY = "si32";
var TYPE_UINT16ARRAY = "ur16";
var TYPE_UINT32ARRAY = "ui32";
var TYPE_FLOAT32ARRAY = "fl32";
var TYPE_FLOAT64ARRAY = "fl64";
var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;
var toString$1 = Object.prototype.toString;
function stringToBuffer(serializedString) {
var bufferLength = serializedString.length * 0.75;
var len = serializedString.length;
var i2;
var p2 = 0;
var encoded1, encoded2, encoded3, encoded4;
if (serializedString[serializedString.length - 1] === "=") {
bufferLength--;
if (serializedString[serializedString.length - 2] === "=") {
bufferLength--;
}
}
var buffer = new ArrayBuffer(bufferLength);
var bytes = new Uint8Array(buffer);
for (i2 = 0; i2 < len; i2 += 4) {
encoded1 = BASE_CHARS.indexOf(serializedString[i2]);
encoded2 = BASE_CHARS.indexOf(serializedString[i2 + 1]);
encoded3 = BASE_CHARS.indexOf(serializedString[i2 + 2]);
encoded4 = BASE_CHARS.indexOf(serializedString[i2 + 3]);
bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
}
return buffer;
}
function bufferToString(buffer) {
var bytes = new Uint8Array(buffer);
var base64String = "";
var i2;
for (i2 = 0; i2 < bytes.length; i2 += 3) {
base64String += BASE_CHARS[bytes[i2] >> 2];
base64String += BASE_CHARS[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
base64String += BASE_CHARS[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
base64String += BASE_CHARS[bytes[i2 + 2] & 63];
}
if (bytes.length % 3 === 2) {
base64String = base64String.substring(0, base64String.length - 1) + "=";
} else if (bytes.length % 3 === 1) {
base64String = base64String.substring(0, base64String.length - 2) + "==";
}
return base64String;
}
function serialize2(value, callback) {
var valueType = "";
if (value) {
valueType = toString$1.call(value);
}
if (value && (valueType === "[object ArrayBuffer]" || value.buffer && toString$1.call(value.buffer) === "[object ArrayBuffer]")) {
var buffer;
var marker = SERIALIZED_MARKER;
if (value instanceof ArrayBuffer) {
buffer = value;
marker += TYPE_ARRAYBUFFER;
} else {
buffer = value.buffer;
if (valueType === "[object Int8Array]") {
marker += TYPE_INT8ARRAY;
} else if (valueType === "[object Uint8Array]") {
marker += TYPE_UINT8ARRAY;
} else if (valueType === "[object Uint8ClampedArray]") {
marker += TYPE_UINT8CLAMPEDARRAY;
} else if (valueType === "[object Int16Array]") {
marker += TYPE_INT16ARRAY;
} else if (valueType === "[object Uint16Array]") {
marker += TYPE_UINT16ARRAY;
} else if (valueType === "[object Int32Array]") {
marker += TYPE_INT32ARRAY;
} else if (valueType === "[object Uint32Array]") {
marker += TYPE_UINT32ARRAY;
} else if (valueType === "[object Float32Array]") {
marker += TYPE_FLOAT32ARRAY;
} else if (valueType === "[object Float64Array]") {
marker += TYPE_FLOAT64ARRAY;
} else {
callback(new Error("Failed to get type for BinaryArray"));
}
}
callback(marker + bufferToString(buffer));
} else if (valueType === "[object Blob]") {
var fileReader = new FileReader();
fileReader.onload = function() {
var str = BLOB_TYPE_PREFIX + value.type + "~" + bufferToString(this.result);
callback(SERIALIZED_MARKER + TYPE_BLOB + str);
};
fileReader.readAsArrayBuffer(value);
} else {
try {
callback(JSON.stringify(value));
} catch (e2) {
console.error("Couldn't convert value into a JSON string: ", value);
callback(null, e2);
}
}
}
function deserialize(value) {
if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {
return JSON.parse(value);
}
var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
var blobType;
if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
blobType = matcher[1];
serializedString = serializedString.substring(matcher[0].length);
}
var buffer = stringToBuffer(serializedString);
switch (type) {
case TYPE_ARRAYBUFFER:
return buffer;
case TYPE_BLOB:
return createBlob([buffer], { type: blobType });
case TYPE_INT8ARRAY:
return new Int8Array(buffer);
case TYPE_UINT8ARRAY:
return new Uint8Array(buffer);
case TYPE_UINT8CLAMPEDARRAY:
return new Uint8ClampedArray(buffer);
case TYPE_INT16ARRAY:
return new Int16Array(buffer);
case TYPE_UINT16ARRAY:
return new Uint16Array(buffer);
case TYPE_INT32ARRAY:
return new Int32Array(buffer);
case TYPE_UINT32ARRAY:
return new Uint32Array(buffer);
case TYPE_FLOAT32ARRAY:
return new Float32Array(buffer);
case TYPE_FLOAT64ARRAY:
return new Float64Array(buffer);
default:
throw new Error("Unkown type: " + type);
}
}
var localforageSerializer = {
serialize: serialize2,
deserialize,
stringToBuffer,
bufferToString
};
function createDbTable(t2, dbInfo, callback, errorCallback) {
t2.executeSql("CREATE TABLE IF NOT EXISTS " + dbInfo.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], callback, errorCallback);
}
function _initStorage$1(options) {
var self2 = this;
var dbInfo = {
db: null
};
if (options) {
for (var i2 in options) {
dbInfo[i2] = typeof options[i2] !== "string" ? options[i2].toString() : options[i2];
}
}
var dbInfoPromise = new Promise$1(function(resolve, reject) {
try {
dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
} catch (e2) {
return reject(e2);
}
dbInfo.db.transaction(function(t2) {
createDbTable(t2, dbInfo, function() {
self2._dbInfo = dbInfo;
resolve();
}, function(t3, error) {
reject(error);
});
}, reject);
});
dbInfo.serializer = localforageSerializer;
return dbInfoPromise;
}
function tryExecuteSql(t2, dbInfo, sqlStatement, args, callback, errorCallback) {
t2.executeSql(sqlStatement, args, callback, function(t3, error) {
if (error.code === error.SYNTAX_ERR) {
t3.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [dbInfo.storeName], function(t4, results) {
if (!results.rows.length) {
createDbTable(t4, dbInfo, function() {
t4.executeSql(sqlStatement, args, callback, errorCallback);
}, errorCallback);
} else {
errorCallback(t4, error);
}
}, errorCallback);
} else {
errorCallback(t3, error);
}
}, errorCallback);
}
function getItem$1(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "SELECT * FROM " + dbInfo.storeName + " WHERE key = ? LIMIT 1", [key2], function(t3, results) {
var result = results.rows.length ? results.rows.item(0).value : null;
if (result) {
result = dbInfo.serializer.deserialize(result);
}
resolve(result);
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function iterate$1(iterator, callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "SELECT * FROM " + dbInfo.storeName, [], function(t3, results) {
var rows = results.rows;
var length3 = rows.length;
for (var i2 = 0; i2 < length3; i2++) {
var item = rows.item(i2);
var result = item.value;
if (result) {
result = dbInfo.serializer.deserialize(result);
}
result = iterator(result, item.key, i2 + 1);
if (result !== void 0) {
resolve(result);
return;
}
}
resolve();
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function _setItem(key2, value, callback, retriesLeft) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
if (value === void 0) {
value = null;
}
var originalValue = value;
var dbInfo = self2._dbInfo;
dbInfo.serializer.serialize(value, function(value2, error) {
if (error) {
reject(error);
} else {
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "INSERT OR REPLACE INTO " + dbInfo.storeName + " (key, value) VALUES (?, ?)", [key2, value2], function() {
resolve(originalValue);
}, function(t3, error2) {
reject(error2);
});
}, function(sqlError) {
if (sqlError.code === sqlError.QUOTA_ERR) {
if (retriesLeft > 0) {
resolve(_setItem.apply(self2, [key2, originalValue, callback, retriesLeft - 1]));
return;
}
reject(sqlError);
}
});
}
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function setItem$1(key2, value, callback) {
return _setItem.apply(this, [key2, value, callback, 1]);
}
function removeItem$1(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "DELETE FROM " + dbInfo.storeName + " WHERE key = ?", [key2], function() {
resolve();
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function clear$1(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "DELETE FROM " + dbInfo.storeName, [], function() {
resolve();
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function length$1(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "SELECT COUNT(key) as c FROM " + dbInfo.storeName, [], function(t3, results) {
var result = results.rows.item(0).c;
resolve(result);
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function key$1(n2, callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "SELECT key FROM " + dbInfo.storeName + " WHERE id = ? LIMIT 1", [n2 + 1], function(t3, results) {
var result = results.rows.length ? results.rows.item(0).key : null;
resolve(result);
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function keys$1(callback) {
var self2 = this;
var promise = new Promise$1(function(resolve, reject) {
self2.ready().then(function() {
var dbInfo = self2._dbInfo;
dbInfo.db.transaction(function(t2) {
tryExecuteSql(t2, dbInfo, "SELECT key FROM " + dbInfo.storeName, [], function(t3, results) {
var keys2 = [];
for (var i2 = 0; i2 < results.rows.length; i2++) {
keys2.push(results.rows.item(i2).key);
}
resolve(keys2);
}, function(t3, error) {
reject(error);
});
});
})["catch"](reject);
});
executeCallback(promise, callback);
return promise;
}
function getAllStoreNames(db2) {
return new Promise$1(function(resolve, reject) {
db2.transaction(function(t2) {
t2.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(t3, results) {
var storeNames = [];
for (var i2 = 0; i2 < results.rows.length; i2++) {
storeNames.push(results.rows.item(i2).name);
}
resolve({
db: db2,
storeNames
});
}, function(t3, error) {
reject(error);
});
}, function(sqlError) {
reject(sqlError);
});
});
}
function dropInstance$1(options, callback) {
callback = getCallback.apply(this, arguments);
var currentConfig = this.config();
options = typeof options !== "function" && options || {};
if (!options.name) {
options.name = options.name || currentConfig.name;
options.storeName = options.storeName || currentConfig.storeName;
}
var self2 = this;
var promise;
if (!options.name) {
promise = Promise$1.reject("Invalid arguments");
} else {
promise = new Promise$1(function(resolve) {
var db2;
if (options.name === currentConfig.name) {
db2 = self2._dbInfo.db;
} else {
db2 = openDatabase(options.name, "", "", 0);
}
if (!options.storeName) {
resolve(getAllStoreNames(db2));
} else {
resolve({
db: db2,
storeNames: [options.storeName]
});
}
}).then(function(operationInfo) {
return new Promise$1(function(resolve, reject) {
operationInfo.db.transaction(function(t2) {
function dropTable(storeName) {
return new Promise$1(function(resolve2, reject2) {
t2.executeSql("DROP TABLE IF EXISTS " + storeName, [], function() {
resolve2();
}, function(t3, error) {
reject2(error);
});
});
}
var operations = [];
for (var i2 = 0, len = operationInfo.storeNames.length; i2 < len; i2++) {
operations.push(dropTable(operationInfo.storeNames[i2]));
}
Promise$1.all(operations).then(function() {
resolve();
})["catch"](function(e2) {
reject(e2);
});
}, function(sqlError) {
reject(sqlError);
});
});
});
}
executeCallback(promise, callback);
return promise;
}
var webSQLStorage = {
_driver: "webSQLStorage",
_initStorage: _initStorage$1,
_support: isWebSQLValid(),
iterate: iterate$1,
getItem: getItem$1,
setItem: setItem$1,
removeItem: removeItem$1,
clear: clear$1,
length: length$1,
key: key$1,
keys: keys$1,
dropInstance: dropInstance$1
};
function isLocalStorageValid() {
try {
return typeof localStorage !== "undefined" && "setItem" in localStorage && // in IE8 typeof localStorage.setItem === 'object'
!!localStorage.setItem;
} catch (e2) {
return false;
}
}
function _getKeyPrefix(options, defaultConfig) {
var keyPrefix = options.name + "/";
if (options.storeName !== defaultConfig.storeName) {
keyPrefix += options.storeName + "/";
}
return keyPrefix;
}
function checkIfLocalStorageThrows() {
var localStorageTestKey = "_localforage_support_test";
try {
localStorage.setItem(localStorageTestKey, true);
localStorage.removeItem(localStorageTestKey);
return false;
} catch (e2) {
return true;
}
}
function _isLocalStorageUsable() {
return !checkIfLocalStorageThrows() || localStorage.length > 0;
}
function _initStorage$2(options) {
var self2 = this;
var dbInfo = {};
if (options) {
for (var i2 in options) {
dbInfo[i2] = options[i2];
}
}
dbInfo.keyPrefix = _getKeyPrefix(options, self2._defaultConfig);
if (!_isLocalStorageUsable()) {
return Promise$1.reject();
}
self2._dbInfo = dbInfo;
dbInfo.serializer = localforageSerializer;
return Promise$1.resolve();
}
function clear$2(callback) {
var self2 = this;
var promise = self2.ready().then(function() {
var keyPrefix = self2._dbInfo.keyPrefix;
for (var i2 = localStorage.length - 1; i2 >= 0; i2--) {
var key2 = localStorage.key(i2);
if (key2.indexOf(keyPrefix) === 0) {
localStorage.removeItem(key2);
}
}
});
executeCallback(promise, callback);
return promise;
}
function getItem$2(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = self2.ready().then(function() {
var dbInfo = self2._dbInfo;
var result = localStorage.getItem(dbInfo.keyPrefix + key2);
if (result) {
result = dbInfo.serializer.deserialize(result);
}
return result;
});
executeCallback(promise, callback);
return promise;
}
function iterate$2(iterator, callback) {
var self2 = this;
var promise = self2.ready().then(function() {
var dbInfo = self2._dbInfo;
var keyPrefix = dbInfo.keyPrefix;
var keyPrefixLength = keyPrefix.length;
var length3 = localStorage.length;
var iterationNumber = 1;
for (var i2 = 0; i2 < length3; i2++) {
var key2 = localStorage.key(i2);
if (key2.indexOf(keyPrefix) !== 0) {
continue;
}
var value = localStorage.getItem(key2);
if (value) {
value = dbInfo.serializer.deserialize(value);
}
value = iterator(value, key2.substring(keyPrefixLength), iterationNumber++);
if (value !== void 0) {
return value;
}
}
});
executeCallback(promise, callback);
return promise;
}
function key$2(n2, callback) {
var self2 = this;
var promise = self2.ready().then(function() {
var dbInfo = self2._dbInfo;
var result;
try {
result = localStorage.key(n2);
} catch (error) {
result = null;
}
if (result) {
result = result.substring(dbInfo.keyPrefix.length);
}
return result;
});
executeCallback(promise, callback);
return promise;
}
function keys$2(callback) {
var self2 = this;
var promise = self2.ready().then(function() {
var dbInfo = self2._dbInfo;
var length3 = localStorage.length;
var keys2 = [];
for (var i2 = 0; i2 < length3; i2++) {
var itemKey = localStorage.key(i2);
if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {
keys2.push(itemKey.substring(dbInfo.keyPrefix.length));
}
}
return keys2;
});
executeCallback(promise, callback);
return promise;
}
function length$2(callback) {
var self2 = this;
var promise = self2.keys().then(function(keys2) {
return keys2.length;
});
executeCallback(promise, callback);
return promise;
}
function removeItem$2(key2, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = self2.ready().then(function() {
var dbInfo = self2._dbInfo;
localStorage.removeItem(dbInfo.keyPrefix + key2);
});
executeCallback(promise, callback);
return promise;
}
function setItem$2(key2, value, callback) {
var self2 = this;
key2 = normalizeKey(key2);
var promise = self2.ready().then(function() {
if (value === void 0) {
value = null;
}
var originalValue = value;
return new Promise$1(function(resolve, reject) {
var dbInfo = self2._dbInfo;
dbInfo.serializer.serialize(value, function(value2, error) {
if (error) {
reject(error);
} else {
try {
localStorage.setItem(dbInfo.keyPrefix + key2, value2);
resolve(originalValue);
} catch (e2) {
if (e2.name === "QuotaExceededError" || e2.name === "NS_ERROR_DOM_QUOTA_REACHED") {
reject(e2);
}
reject(e2);
}
}
});
});
});
executeCallback(promise, callback);
return promise;
}
function dropInstance$2(options, callback) {
callback = getCallback.apply(this, arguments);
options = typeof options !== "function" && options || {};
if (!options.name) {
var currentConfig = this.config();
options.name = options.name || currentConfig.name;
options.storeName = options.storeName || currentConfig.storeName;
}
var self2 = this;
var promise;
if (!options.name) {
promise = Promise$1.reject("Invalid arguments");
} else {
promise = new Promise$1(function(resolve) {
if (!options.storeName) {
resolve(options.name + "/");
} else {
resolve(_getKeyPrefix(options, self2._defaultConfig));
}
}).then(function(keyPrefix) {
for (var i2 = localStorage.length - 1; i2 >= 0; i2--) {
var key2 = localStorage.key(i2);
if (key2.indexOf(keyPrefix) === 0) {
localStorage.removeItem(key2);
}
}
});
}
executeCallback(promise, callback);
return promise;
}
var localStorageWrapper = {
_driver: "localStorageWrapper",
_initStorage: _initStorage$2,
_support: isLocalStorageValid(),
iterate: iterate$2,
getItem: getItem$2,
setItem: setItem$2,
removeItem: removeItem$2,
clear: clear$2,
length: length$2,
key: key$2,
keys: keys$2,
dropInstance: dropInstance$2
};
var sameValue = function sameValue2(x2, y2) {
return x2 === y2 || typeof x2 === "number" && typeof y2 === "number" && isNaN(x2) && isNaN(y2);
};
var includes = function includes2(array, searchElement) {
var len = array.length;
var i2 = 0;
while (i2 < len) {
if (sameValue(array[i2], searchElement)) {
return true;
}
i2++;
}
return false;
};
var isArray = Array.isArray || function(arg) {
return Object.prototype.toString.call(arg) === "[object Array]";
};
var DefinedDrivers = {};
var DriverSupport = {};
var DefaultDrivers = {
INDEXEDDB: asyncStorage,
WEBSQL: webSQLStorage,
LOCALSTORAGE: localStorageWrapper
};
var DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];
var OptionalDriverMethods = ["dropInstance"];
var LibraryMethods = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(OptionalDriverMethods);
var DefaultConfig = {
description: "",
driver: DefaultDriverOrder.slice(),
name: "localforage",
// Default DB size is _JUST UNDER_ 5MB, as it's the highest size
// we can use without a prompt.
size: 4980736,
storeName: "keyvaluepairs",
version: 1
};
function callWhenReady(localForageInstance, libraryMethod) {
localForageInstance[libraryMethod] = function() {
var _args = arguments;
return localForageInstance.ready().then(function() {
return localForageInstance[libraryMethod].apply(localForageInstance, _args);
});
};
}
function extend() {
for (var i2 = 1; i2 < arguments.length; i2++) {
var arg = arguments[i2];
if (arg) {
for (var _key in arg) {
if (arg.hasOwnProperty(_key)) {
if (isArray(arg[_key])) {
arguments[0][_key] = arg[_key].slice();
} else {
arguments[0][_key] = arg[_key];
}
}
}
}
}
return arguments[0];
}
var LocalForage = function() {
function LocalForage2(options) {
_classCallCheck(this, LocalForage2);
for (var driverTypeKey in DefaultDrivers) {
if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {
var driver = DefaultDrivers[driverTypeKey];
var driverName = driver._driver;
this[driverTypeKey] = driverName;
if (!DefinedDrivers[driverName]) {
this.defineDriver(driver);
}
}
}
this._defaultConfig = extend({}, DefaultConfig);
this._config = extend({}, this._defaultConfig, options);
this._driverSet = null;
this._initDriver = null;
this._ready = false;
this._dbInfo = null;
this._wrapLibraryMethodsWithReady();
this.setDriver(this._config.driver)["catch"](function() {
});
}
LocalForage2.prototype.config = function config(options) {
if ((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object") {
if (this._ready) {
return new Error("Can't call config() after localforage has been used.");
}
for (var i2 in options) {
if (i2 === "storeName") {
options[i2] = options[i2].replace(/\W/g, "_");
}
if (i2 === "version" && typeof options[i2] !== "number") {
return new Error("Database version must be a number.");
}
this._config[i2] = options[i2];
}
if ("driver" in options && options.driver) {
return this.setDriver(this._config.driver);
}
return true;
} else if (typeof options === "string") {
return this._config[options];
} else {
return this._config;
}
};
LocalForage2.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {
var promise = new Promise$1(function(resolve, reject) {
try {
var driverName = driverObject._driver;
var complianceError = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
if (!driverObject._driver) {
reject(complianceError);
return;
}
var driverMethods = LibraryMethods.concat("_initStorage");
for (var i2 = 0, len = driverMethods.length; i2 < len; i2++) {
var driverMethodName = driverMethods[i2];
var isRequired = !includes(OptionalDriverMethods, driverMethodName);
if ((isRequired || driverObject[driverMethodName]) && typeof driverObject[driverMethodName] !== "function") {
reject(complianceError);
return;
}
}
var configureMissingMethods = function configureMissingMethods2() {
var methodNotImplementedFactory = function methodNotImplementedFactory2(methodName) {
return function() {
var error = new Error("Method " + methodName + " is not implemented by the current driver");
var promise2 = Promise$1.reject(error);
executeCallback(promise2, arguments[arguments.length - 1]);
return promise2;
};
};
for (var _i = 0, _len = OptionalDriverMethods.length; _i < _len; _i++) {
var optionalDriverMethod = OptionalDriverMethods[_i];
if (!driverObject[optionalDriverMethod]) {
driverObject[optionalDriverMethod] = methodNotImplementedFactory(optionalDriverMethod);
}
}
};
configureMissingMethods();
var setDriverSupport = function setDriverSupport2(support) {
if (DefinedDrivers[driverName]) {
console.info("Redefining LocalForage driver: " + driverName);
}
DefinedDrivers[driverName] = driverObject;
DriverSupport[driverName] = support;
resolve();
};
if ("_support" in driverObject) {
if (driverObject._support && typeof driverObject._support === "function") {
driverObject._support().then(setDriverSupport, reject);
} else {
setDriverSupport(!!driverObject._support);
}
} else {
setDriverSupport(true);
}
} catch (e2) {
reject(e2);
}
});
executeTwoCallbacks(promise, callback, errorCallback);
return promise;
};
LocalForage2.prototype.driver = function driver() {
return this._driver || null;
};
LocalForage2.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {
var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error("Driver not found."));
executeTwoCallbacks(getDriverPromise, callback, errorCallback);
return getDriverPromise;
};
LocalForage2.prototype.getSerializer = function getSerializer(callback) {
var serializerPromise = Promise$1.resolve(localforageSerializer);
executeTwoCallbacks(serializerPromise, callback);
return serializerPromise;
};
LocalForage2.prototype.ready = function ready(callback) {
var self2 = this;
var promise = self2._driverSet.then(function() {
if (self2._ready === null) {
self2._ready = self2._initDriver();
}
return self2._ready;
});
executeTwoCallbacks(promise, callback, callback);
return promise;
};
LocalForage2.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {
var self2 = this;
if (!isArray(drivers)) {
drivers = [drivers];
}
var supportedDrivers = this._getSupportedDrivers(drivers);
function setDriverToConfig() {
self2._config.driver = self2.driver();
}
function extendSelfWithDriver(driver) {
self2._extend(driver);
setDriverToConfig();
self2._ready = self2._initStorage(self2._config);
return self2._ready;
}
function initDriver(supportedDrivers2) {
return function() {
var currentDriverIndex = 0;
function driverPromiseLoop() {
while (currentDriverIndex < supportedDrivers2.length) {
var driverName = supportedDrivers2[currentDriverIndex];
currentDriverIndex++;
self2._dbInfo = null;
self2._ready = null;
return self2.getDriver(driverName).then(extendSelfWithDriver)["catch"](driverPromiseLoop);
}
setDriverToConfig();
var error = new Error("No available storage method found.");
self2._driverSet = Promise$1.reject(error);
return self2._driverSet;
}
return driverPromiseLoop();
};
}
var oldDriverSetDone = this._driverSet !== null ? this._driverSet["catch"](function() {
return Promise$1.resolve();
}) : Promise$1.resolve();
this._driverSet = oldDriverSetDone.then(function() {
var driverName = supportedDrivers[0];
self2._dbInfo = null;
self2._ready = null;
return self2.getDriver(driverName).then(function(driver) {
self2._driver = driver._driver;
setDriverToConfig();
self2._wrapLibraryMethodsWithReady();
self2._initDriver = initDriver(supportedDrivers);
});
})["catch"](function() {
setDriverToConfig();
var error = new Error("No available storage method found.");
self2._driverSet = Promise$1.reject(error);
return self2._driverSet;
});
executeTwoCallbacks(this._driverSet, callback, errorCallback);
return this._driverSet;
};
LocalForage2.prototype.supports = function supports(driverName) {
return !!DriverSupport[driverName];
};
LocalForage2.prototype._extend = function _extend(libraryMethodsAndProperties) {
extend(this, libraryMethodsAndProperties);
};
LocalForage2.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {
var supportedDrivers = [];
for (var i2 = 0, len = drivers.length; i2 < len; i2++) {
var driverName = drivers[i2];
if (this.supports(driverName)) {
supportedDrivers.push(driverName);
}
}
return supportedDrivers;
};
LocalForage2.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {
for (var i2 = 0, len = LibraryMethods.length; i2 < len; i2++) {
callWhenReady(this, LibraryMethods[i2]);
}
};
LocalForage2.prototype.createInstance = function createInstance2(options) {
return new LocalForage2(options);
};
return LocalForage2;
}();
var localforage_js = new LocalForage();
module2.exports = localforage_js;
}, { "3": 3 }] }, {}, [4])(4);
});
})(localforage$1);
var localforageExports = localforage$1.exports;
const localforage = /* @__PURE__ */ getDefaultExportFromCjs(localforageExports);
const dbName = `localforage-${APP_NAME}`;
function createDBWithTable(tableName) {
return localforage.createInstance({
driver: localforage.INDEXEDDB,
name: dbName,
storeName: tableName
});
}
const request = axios.create({});
function css$1() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return serializeStyles$1(args);
}
const t = (t2, e2 = 1e4) => (t2 = parseFloat(t2 + "") || 0, Math.round((t2 + Number.EPSILON) * e2) / e2), e = function(t2) {
if (!(t2 && t2 instanceof Element && t2.offsetParent))
return false;
const e2 = t2.scrollHeight > t2.clientHeight, i2 = window.getComputedStyle(t2).overflowY, n2 = -1 !== i2.indexOf("hidden"), s2 = -1 !== i2.indexOf("visible");
return e2 && !n2 && !s2;
}, i = function(t2, n2 = void 0) {
return !(!t2 || t2 === document.body || n2 && t2 === n2) && (e(t2) ? t2 : i(t2.parentElement, n2));
}, n = function(t2) {
var e2 = new DOMParser().parseFromString(t2, "text/html").body;
if (e2.childElementCount > 1) {
for (var i2 = document.createElement("div"); e2.firstChild; )
i2.appendChild(e2.firstChild);
return i2;
}
return e2.firstChild;
}, s$1 = (t2) => `${t2 || ""}`.split(" ").filter((t3) => !!t3), o = (t2, e2, i2) => {
t2 && s$1(e2).forEach((e3) => {
t2.classList.toggle(e3, i2 || false);
});
};
class a {
constructor(t2) {
Object.defineProperty(this, "pageX", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "pageY", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "clientX", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "clientY", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "time", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "nativePointer", { enumerable: true, configurable: true, writable: true, value: void 0 }), this.nativePointer = t2, this.pageX = t2.pageX, this.pageY = t2.pageY, this.clientX = t2.clientX, this.clientY = t2.clientY, this.id = self.Touch && t2 instanceof Touch ? t2.identifier : -1, this.time = Date.now();
}
}
const r = { passive: false };
class l {
constructor(t2, { start: e2 = () => true, move: i2 = () => {
}, end: n2 = () => {
} }) {
Object.defineProperty(this, "element", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "startCallback", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "moveCallback", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "endCallback", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "currentPointers", { enumerable: true, configurable: true, writable: true, value: [] }), Object.defineProperty(this, "startPointers", { enumerable: true, configurable: true, writable: true, value: [] }), this.element = t2, this.startCallback = e2, this.moveCallback = i2, this.endCallback = n2;
for (const t3 of ["onPointerStart", "onTouchStart", "onMove", "onTouchEnd", "onPointerEnd", "onWindowBlur"])
this[t3] = this[t3].bind(this);
this.element.addEventListener("mousedown", this.onPointerStart, r), this.element.addEventListener("touchstart", this.onTouchStart, r), this.element.addEventListener("touchmove", this.onMove, r), this.element.addEventListener("touchend", this.onTouchEnd), this.element.addEventListener("touchcancel", this.onTouchEnd);
}
onPointerStart(t2) {
if (!t2.buttons || 0 !== t2.button)
return;
const e2 = new a(t2);
this.currentPointers.some((t3) => t3.id === e2.id) || this.triggerPointerStart(e2, t2) && (window.addEventListener("mousemove", this.onMove), window.addEventListener("mouseup", this.onPointerEnd), window.addEventListener("blur", this.onWindowBlur));
}
onTouchStart(t2) {
for (const e2 of Array.from(t2.changedTouches || []))
this.triggerPointerStart(new a(e2), t2);
window.addEventListener("blur", this.onWindowBlur);
}
onMove(t2) {
const e2 = this.currentPointers.slice(), i2 = "changedTouches" in t2 ? Array.from(t2.changedTouches || []).map((t3) => new a(t3)) : [new a(t2)], n2 = [];
for (const t3 of i2) {
const e3 = this.currentPointers.findIndex((e4) => e4.id === t3.id);
e3 < 0 || (n2.push(t3), this.currentPointers[e3] = t3);
}
n2.length && this.moveCallback(t2, this.currentPointers.slice(), e2);
}
onPointerEnd(t2) {
t2.buttons > 0 && 0 !== t2.button || (this.triggerPointerEnd(t2, new a(t2)), window.removeEventListener("mousemove", this.onMove), window.removeEventListener("mouseup", this.onPointerEnd), window.removeEventListener("blur", this.onWindowBlur));
}
onTouchEnd(t2) {
for (const e2 of Array.from(t2.changedTouches || []))
this.triggerPointerEnd(t2, new a(e2));
}
triggerPointerStart(t2, e2) {
return !!this.startCallback(e2, t2, this.currentPointers.slice()) && (this.currentPointers.push(t2), this.startPointers.push(t2), true);
}
triggerPointerEnd(t2, e2) {
const i2 = this.currentPointers.findIndex((t3) => t3.id === e2.id);
i2 < 0 || (this.currentPointers.splice(i2, 1), this.startPointers.splice(i2, 1), this.endCallback(t2, e2, this.currentPointers.slice()));
}
onWindowBlur() {
this.clear();
}
clear() {
for (; this.currentPointers.length; ) {
const t2 = 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: true, cancelable: true, clientX: t2.clientX, clientY: t2.clientY }), t2, this.currentPointers.slice());
}
}
stop() {
this.element.removeEventListener("mousedown", this.onPointerStart, r), this.element.removeEventListener("touchstart", this.onTouchStart, r), this.element.removeEventListener("touchmove", this.onMove, r), 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 c(t2, e2) {
return e2 ? Math.sqrt(Math.pow(e2.clientX - t2.clientX, 2) + Math.pow(e2.clientY - t2.clientY, 2)) : 0;
}
function h$1(t2, e2) {
return e2 ? { clientX: (t2.clientX + e2.clientX) / 2, clientY: (t2.clientY + e2.clientY) / 2 } : t2;
}
const d$1 = (t2) => "object" == typeof t2 && null !== t2 && t2.constructor === Object && "[object Object]" === Object.prototype.toString.call(t2), u = (t2, ...e2) => {
const i2 = e2.length;
for (let n2 = 0; n2 < i2; n2++) {
const i3 = e2[n2] || {};
Object.entries(i3).forEach(([e3, i4]) => {
const n3 = Array.isArray(i4) ? [] : {};
t2[e3] || Object.assign(t2, { [e3]: n3 }), d$1(i4) ? Object.assign(t2[e3], u(n3, i4)) : Array.isArray(i4) ? Object.assign(t2, { [e3]: [...i4] }) : Object.assign(t2, { [e3]: i4 });
});
}
return t2;
}, p = function(t2, e2) {
return t2.split(".").reduce((t3, e3) => "object" == typeof t3 ? t3[e3] : void 0, e2);
};
class f {
constructor(t2 = {}) {
Object.defineProperty(this, "options", { enumerable: true, configurable: true, writable: true, value: t2 }), Object.defineProperty(this, "events", { enumerable: true, configurable: true, writable: true, value: /* @__PURE__ */ new Map() }), this.setOptions(t2);
for (const t3 of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))
t3.startsWith("on") && "function" == typeof this[t3] && (this[t3] = this[t3].bind(this));
}
setOptions(t2) {
this.options = t2 ? u({}, this.constructor.defaults, t2) : {};
for (const [t3, e2] of Object.entries(this.option("on") || {}))
this.on(t3, e2);
}
option(t2, ...e2) {
let i2 = p(t2, this.options);
return i2 && "function" == typeof i2 && (i2 = i2.call(this, this, ...e2)), i2;
}
optionFor(t2, e2, i2, ...n2) {
let s2 = p(e2, t2);
var o2;
"string" != typeof (o2 = s2) || isNaN(o2) || isNaN(parseFloat(o2)) || (s2 = parseFloat(s2)), "true" === s2 && (s2 = true), "false" === s2 && (s2 = false), s2 && "function" == typeof s2 && (s2 = s2.call(this, this, t2, ...n2));
let a2 = p(e2, this.options);
return a2 && "function" == typeof a2 ? s2 = a2.call(this, this, t2, ...n2, s2) : void 0 === s2 && (s2 = a2), void 0 === s2 ? i2 : s2;
}
cn(t2) {
const e2 = this.options.classes;
return e2 && e2[t2] || "";
}
localize(t2, e2 = []) {
t2 = String(t2).replace(/\{\{(\w+).?(\w+)?\}\}/g, (t3, e3, i2) => {
let n2 = "";
return i2 ? n2 = this.option(`${e3[0] + e3.toLowerCase().substring(1)}.l10n.${i2}`) : e3 && (n2 = this.option(`l10n.${e3}`)), n2 || (n2 = t3), n2;
});
for (let i2 = 0; i2 < e2.length; i2++)
t2 = t2.split(e2[i2][0]).join(e2[i2][1]);
return t2 = t2.replace(/\{\{(.*?)\}\}/g, (t3, e3) => e3);
}
on(t2, e2) {
let i2 = [];
"string" == typeof t2 ? i2 = t2.split(" ") : Array.isArray(t2) && (i2 = t2), this.events || (this.events = /* @__PURE__ */ new Map()), i2.forEach((t3) => {
let i3 = this.events.get(t3);
i3 || (this.events.set(t3, []), i3 = []), i3.includes(e2) || i3.push(e2), this.events.set(t3, i3);
});
}
off(t2, e2) {
let i2 = [];
"string" == typeof t2 ? i2 = t2.split(" ") : Array.isArray(t2) && (i2 = t2), i2.forEach((t3) => {
const i3 = this.events.get(t3);
if (Array.isArray(i3)) {
const t4 = i3.indexOf(e2);
t4 > -1 && i3.splice(t4, 1);
}
});
}
emit(t2, ...e2) {
[...this.events.get(t2) || []].forEach((t3) => t3(this, ...e2)), "*" !== t2 && this.emit("*", t2, ...e2);
}
}
Object.defineProperty(f, "version", { enumerable: true, configurable: true, writable: true, value: "5.0.35" }), Object.defineProperty(f, "defaults", { enumerable: true, configurable: true, writable: true, value: {} });
class g extends f {
constructor(t2 = {}) {
super(t2), Object.defineProperty(this, "plugins", { enumerable: true, configurable: true, writable: true, value: {} });
}
attachPlugins(t2 = {}) {
const e2 = /* @__PURE__ */ new Map();
for (const [i2, n2] of Object.entries(t2)) {
const t3 = this.option(i2), s2 = this.plugins[i2];
s2 || false === t3 ? s2 && false === t3 && (s2.detach(), delete this.plugins[i2]) : e2.set(i2, new n2(this, t3 || {}));
}
for (const [t3, i2] of e2)
this.plugins[t3] = i2, i2.attach();
}
detachPlugins(t2) {
t2 = t2 || Object.keys(this.plugins);
for (const e2 of t2) {
const t3 = this.plugins[e2];
t3 && t3.detach(), delete this.plugins[e2];
}
return this.emit("detachPlugins"), this;
}
}
var m$2;
!function(t2) {
t2[t2.Init = 0] = "Init", t2[t2.Error = 1] = "Error", t2[t2.Ready = 2] = "Ready", t2[t2.Panning = 3] = "Panning", t2[t2.Mousemove = 4] = "Mousemove", t2[t2.Destroy = 5] = "Destroy";
}(m$2 || (m$2 = {}));
const v = ["a", "b", "c", "d", "e", "f"], b = { 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" }, y$1 = { content: null, width: "auto", height: "auto", panMode: "drag", touch: true, dragMinThreshold: 3, lockAxis: false, mouseMoveFactor: 1, mouseMoveFriction: 0.12, zoom: true, pinchToZoom: true, panOnlyZoomed: "auto", minScale: 1, maxScale: 2, friction: 0.25, dragFriction: 0.35, decelFriction: 0.05, click: "toggleZoom", dblClick: false, wheel: "zoom", wheelLimit: 7, spinner: true, bounds: "auto", infinite: false, rubberband: true, bounce: true, maxVelocity: 75, transformParent: false, 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: b }, w$1 = '<circle cx="25" cy="25" r="20"></circle>', x = '<div class="f-spinner"><svg viewBox="0 0 50 50">' + w$1 + w$1 + "</svg></div>", E = (t2) => t2 && null !== t2 && t2 instanceof Element && "nodeType" in t2, S = (t2, e2) => {
t2 && s$1(e2).forEach((e3) => {
t2.classList.remove(e3);
});
}, P = (t2, e2) => {
t2 && s$1(e2).forEach((e3) => {
t2.classList.add(e3);
});
}, C = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, T = 1e5, M = 1e4, O = "mousemove", A = "drag", L = "content", z = "auto";
let R = null, k = null;
class I extends g {
get fits() {
return this.contentRect.width - this.contentRect.fitWidth < 1 && this.contentRect.height - this.contentRect.fitHeight < 1;
}
get isTouchDevice() {
return null === k && (k = window.matchMedia("(hover: none)").matches), k;
}
get isMobile() {
return null === R && (R = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)), R;
}
get panMode() {
return this.options.panMode !== O || this.isTouchDevice ? A : O;
}
get panOnlyZoomed() {
const t2 = this.options.panOnlyZoomed;
return t2 === z ? this.isTouchDevice : t2;
}
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: t2, b: e2 } = this.current;
return Math.sqrt(t2 * t2 + e2 * e2) || 1;
}
get targetScale() {
const { a: t2, b: e2 } = this.target;
return Math.sqrt(t2 * t2 + e2 * e2) || 1;
}
get minScale() {
return this.option("minScale") || 1;
}
get fullScale() {
const { contentRect: t2 } = this;
return t2.fullWidth / t2.fitWidth || 1;
}
get maxScale() {
return this.fullScale * (this.option("maxScale") || 1) || 1;
}
get coverScale() {
const { containerRect: t2, contentRect: e2 } = this, i2 = Math.max(t2.height / e2.fitHeight, t2.width / e2.fitWidth) || 1;
return Math.min(this.fullScale, i2);
}
get isScaling() {
return Math.abs(this.targetScale - this.scale) > 1e-5 && !this.isResting;
}
get isContentLoading() {
const t2 = this.content;
return !!(t2 && t2 instanceof HTMLImageElement) && !t2.complete;
}
get isResting() {
if (this.isBouncingX || this.isBouncingY)
return false;
for (const t2 of v) {
const e2 = "e" == t2 || "f" === t2 ? 1e-4 : 1e-5;
if (Math.abs(this.target[t2] - this.current[t2]) > e2)
return false;
}
return !(!this.ignoreBounds && !this.checkBounds().inBounds);
}
constructor(t2, e2 = {}, i2 = {}) {
var s2;
if (super(e2), Object.defineProperty(this, "pointerTracker", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "resizeObserver", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "updateTimer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "clickTimer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "rAF", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "isTicking", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "ignoreBounds", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "isBouncingX", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "isBouncingY", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "clicks", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "trackingPoints", { enumerable: true, configurable: true, writable: true, value: [] }), Object.defineProperty(this, "pwt", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "cwd", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "pmme", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "friction", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: m$2.Init }), Object.defineProperty(this, "isDragging", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "content", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "spinner", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "containerRect", { enumerable: true, configurable: true, writable: true, value: { width: 0, height: 0, innerWidth: 0, innerHeight: 0 } }), Object.defineProperty(this, "contentRect", { enumerable: true, configurable: true, writable: true, 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: true, configurable: true, writable: true, value: { x: 0, y: 0, top: 0, left: 0, time: 0 } }), Object.defineProperty(this, "dragOffset", { enumerable: true, configurable: true, writable: true, value: { x: 0, y: 0, time: 0 } }), Object.defineProperty(this, "current", { enumerable: true, configurable: true, writable: true, value: Object.assign({}, C) }), Object.defineProperty(this, "target", { enumerable: true, configurable: true, writable: true, value: Object.assign({}, C) }), Object.defineProperty(this, "velocity", { enumerable: true, configurable: true, writable: true, value: { a: 0, b: 0, c: 0, d: 0, e: 0, f: 0 } }), Object.defineProperty(this, "lockedAxis", { enumerable: true, configurable: true, writable: true, value: false }), !t2)
throw new Error("Container Element Not Found");
this.container = t2, this.initContent(), this.attachPlugins(Object.assign(Object.assign({}, I.Plugins), i2)), this.emit("attachPlugins"), this.emit("init");
const o2 = this.content;
if (o2.addEventListener("load", this.onLoad), o2.addEventListener("error", this.onError), this.isContentLoading) {
if (this.option("spinner")) {
t2.classList.add(this.cn("isLoading"));
const e3 = n(x);
!t2.contains(o2) || o2.parentElement instanceof HTMLPictureElement ? this.spinner = t2.appendChild(e3) : this.spinner = (null === (s2 = o2.parentElement) || void 0 === s2 ? void 0 : s2.insertBefore(e3, o2)) || null;
}
this.emit("beforeLoad");
} else
queueMicrotask(() => {
this.enable();
});
}
initContent() {
const { container: t2 } = this, e2 = this.cn(L);
let i2 = this.option(L) || t2.querySelector(`.${e2}`);
if (i2 || (i2 = t2.querySelector("img,picture") || t2.firstElementChild, i2 && P(i2, e2)), i2 instanceof HTMLPictureElement && (i2 = i2.querySelector("img")), !i2)
throw new Error("No content found");
this.content = i2;
}
onLoad() {
const { spinner: t2, container: e2, state: i2 } = this;
t2 && (t2.remove(), this.spinner = null), this.option("spinner") && e2.classList.remove(this.cn("isLoading")), this.emit("afterLoad"), i2 === m$2.Init ? this.enable() : this.updateMetrics();
}
onError() {
this.state !== m$2.Destroy && (this.spinner && (this.spinner.remove(), this.spinner = null), this.stop(), this.detachEvents(), this.state = m$2.Error, this.emit("error"));
}
getNextScale(t2) {
const { fullScale: e2, targetScale: i2, coverScale: n2, maxScale: s2, minScale: o2 } = this;
let a2 = o2;
switch (t2) {
case "toggleMax":
a2 = i2 - o2 < 0.5 * (s2 - o2) ? s2 : o2;
break;
case "toggleCover":
a2 = i2 - o2 < 0.5 * (n2 - o2) ? n2 : o2;
break;
case "toggleZoom":
a2 = i2 - o2 < 0.5 * (e2 - o2) ? e2 : o2;
break;
case "iterateZoom":
let t3 = [1, e2, s2].sort((t4, e3) => t4 - e3), r2 = t3.findIndex((t4) => t4 > i2 + 1e-5);
a2 = t3[r2] || 1;
}
return a2;
}
attachObserver() {
var t2;
const e2 = () => {
const { container: t3, containerRect: e3 } = this;
return Math.abs(e3.width - t3.getBoundingClientRect().width) > 0.1 || Math.abs(e3.height - t3.getBoundingClientRect().height) > 0.1;
};
this.resizeObserver || void 0 === window.ResizeObserver || (this.resizeObserver = new ResizeObserver(() => {
this.updateTimer || (e2() ? (this.onResize(), this.isMobile && (this.updateTimer = setTimeout(() => {
e2() && this.onResize(), this.updateTimer = null;
}, 500))) : this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null));
})), null === (t2 = this.resizeObserver) || void 0 === t2 || t2.observe(this.container);
}
detachObserver() {
var t2;
null === (t2 = this.resizeObserver) || void 0 === t2 || t2.disconnect();
}
attachEvents() {
const { container: t2 } = this;
t2.addEventListener("click", this.onClick, { passive: false, capture: false }), t2.addEventListener("wheel", this.onWheel, { passive: false }), this.pointerTracker = new l(t2, { start: this.onPointerDown, move: this.onPointerMove, end: this.onPointerUp }), document.addEventListener(O, this.onMouseMove);
}
detachEvents() {
var t2;
const { container: e2 } = this;
e2.removeEventListener("click", this.onClick, { passive: false, capture: false }), e2.removeEventListener("wheel", this.onWheel, { passive: false }), null === (t2 = this.pointerTracker) || void 0 === t2 || t2.stop(), this.pointerTracker = null, document.removeEventListener(O, this.onMouseMove), document.removeEventListener("keydown", this.onKeydown, true), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.updateTimer && (clearTimeout(this.updateTimer), this.updateTimer = null);
}
animate() {
this.setTargetForce();
const t2 = this.friction, e2 = this.option("maxVelocity");
for (const i2 of v)
t2 ? (this.velocity[i2] *= 1 - t2, e2 && !this.isScaling && (this.velocity[i2] = Math.max(Math.min(this.velocity[i2], e2), -1 * e2)), this.current[i2] += this.velocity[i2]) : this.current[i2] = this.target[i2];
this.setTransform(), this.setEdgeForce(), !this.isResting || this.isDragging ? this.rAF = requestAnimationFrame(() => this.animate()) : this.stop("current");
}
setTargetForce() {
for (const t2 of v)
"e" === t2 && this.isBouncingX || "f" === t2 && this.isBouncingY || (this.velocity[t2] = (1 / (1 - this.friction) - 1) * (this.target[t2] - this.current[t2]));
}
checkBounds(t2 = 0, e2 = 0) {
const { current: i2 } = this, n2 = i2.e + t2, s2 = i2.f + e2, o2 = this.getBounds(), { x: a2, y: r2 } = o2, l2 = a2.min, c2 = a2.max, h2 = r2.min, d2 = r2.max;
let u2 = 0, p2 = 0;
return l2 !== 1 / 0 && n2 < l2 ? u2 = l2 - n2 : c2 !== 1 / 0 && n2 > c2 && (u2 = c2 - n2), h2 !== 1 / 0 && s2 < h2 ? p2 = h2 - s2 : d2 !== 1 / 0 && s2 > d2 && (p2 = d2 - s2), Math.abs(u2) < 1e-4 && (u2 = 0), Math.abs(p2) < 1e-4 && (p2 = 0), Object.assign(Object.assign({}, o2), { xDiff: u2, yDiff: p2, inBounds: !u2 && !p2 });
}
clampTargetBounds() {
const { target: t2 } = this, { x: e2, y: i2 } = this.getBounds();
e2.min !== 1 / 0 && (t2.e = Math.max(t2.e, e2.min)), e2.max !== 1 / 0 && (t2.e = Math.min(t2.e, e2.max)), i2.min !== 1 / 0 && (t2.f = Math.max(t2.f, i2.min)), i2.max !== 1 / 0 && (t2.f = Math.min(t2.f, i2.max));
}
calculateContentDim(t2 = this.current) {
const { content: e2, contentRect: i2 } = this, { fitWidth: n2, fitHeight: s2, fullWidth: o2, fullHeight: a2 } = i2;
let r2 = o2, l2 = a2;
if (this.option("zoom") || 0 !== this.angle) {
const i3 = !(e2 instanceof HTMLImageElement) && ("none" === window.getComputedStyle(e2).maxWidth || "none" === window.getComputedStyle(e2).maxHeight), c2 = i3 ? o2 : n2, h2 = i3 ? a2 : s2, d2 = this.getMatrix(t2), u2 = new DOMPoint(0, 0).matrixTransform(d2), p2 = new DOMPoint(0 + c2, 0).matrixTransform(d2), f2 = new DOMPoint(0 + c2, 0 + h2).matrixTransform(d2), g2 = new DOMPoint(0, 0 + h2).matrixTransform(d2), m2 = Math.abs(f2.x - u2.x), v2 = Math.abs(f2.y - u2.y), b2 = Math.abs(g2.x - p2.x), y2 = Math.abs(g2.y - p2.y);
r2 = Math.max(m2, b2), l2 = Math.max(v2, y2);
}
return { contentWidth: r2, contentHeight: l2 };
}
setEdgeForce() {
if (this.ignoreBounds || this.isDragging || this.panMode === O || this.targetScale < this.scale)
return this.isBouncingX = false, void (this.isBouncingY = false);
const { target: t2 } = this, { x: e2, y: i2, xDiff: n2, yDiff: s2 } = this.checkBounds();
const o2 = this.option("maxVelocity");
let a2 = this.velocity.e, r2 = this.velocity.f;
0 !== n2 ? (this.isBouncingX = true, n2 * a2 <= 0 ? a2 += 0.14 * n2 : (a2 = 0.14 * n2, e2.min !== 1 / 0 && (this.target.e = Math.max(t2.e, e2.min)), e2.max !== 1 / 0 && (this.target.e = Math.min(t2.e, e2.max))), o2 && (a2 = Math.max(Math.min(a2, o2), -1 * o2))) : this.isBouncingX = false, 0 !== s2 ? (this.isBouncingY = true, s2 * r2 <= 0 ? r2 += 0.14 * s2 : (r2 = 0.14 * s2, i2.min !== 1 / 0 && (this.target.f = Math.max(t2.f, i2.min)), i2.max !== 1 / 0 && (this.target.f = Math.min(t2.f, i2.max))), o2 && (r2 = Math.max(Math.min(r2, o2), -1 * o2))) : this.isBouncingY = false, this.isBouncingX && (this.velocity.e = a2), this.isBouncingY && (this.velocity.f = r2);
}
enable() {
const { content: t2 } = this, e2 = new DOMMatrixReadOnly(window.getComputedStyle(t2).transform);
for (const t3 of v)
this.current[t3] = this.target[t3] = e2[t3];
this.updateMetrics(), this.attachObserver(), this.attachEvents(), this.state = m$2.Ready, this.emit("ready");
}
onClick(t2) {
var e2;
"click" === t2.type && 0 === t2.detail && (this.dragOffset.x = 0, this.dragOffset.y = 0), this.isDragging && (null === (e2 = this.pointerTracker) || void 0 === e2 || e2.clear(), this.trackingPoints = [], this.startDecelAnim());
const i2 = t2.target;
if (!i2 || t2.defaultPrevented)
return;
if (i2.hasAttribute("disabled"))
return t2.preventDefault(), void t2.stopPropagation();
if ((() => {
const t3 = window.getSelection();
return t3 && "Range" === t3.type;
})() && !i2.closest("button"))
return;
const n2 = i2.closest("[data-panzoom-action]"), s2 = i2.closest("[data-panzoom-change]"), o2 = n2 || s2, a2 = o2 && E(o2) ? o2.dataset : null;
if (a2) {
const e3 = a2.panzoomChange, i3 = a2.panzoomAction;
if ((e3 || i3) && t2.preventDefault(), e3) {
let t3 = {};
try {
t3 = JSON.parse(e3);
} catch (t4) {
console && console.warn("The given data was not valid JSON");
}
return void this.applyChange(t3);
}
if (i3)
return void (this[i3] && this[i3]());
}
if (Math.abs(this.dragOffset.x) > 3 || Math.abs(this.dragOffset.y) > 3)
return t2.preventDefault(), void t2.stopPropagation();
if (i2.closest("[data-fancybox]"))
return;
const r2 = this.content.getBoundingClientRect(), l2 = this.dragStart;
if (l2.time && !this.canZoomOut() && (Math.abs(r2.x - l2.x) > 2 || Math.abs(r2.y - l2.y) > 2))
return;
this.dragStart.time = 0;
const c2 = (e3) => {
this.option("zoom", t2) && e3 && "string" == typeof e3 && /(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(e3) && "function" == typeof this[e3] && (t2.preventDefault(), this[e3]({ event: t2 }));
}, h2 = this.option("click", t2), d2 = this.option("dblClick", t2);
d2 ? (this.clicks++, 1 == this.clicks && (this.clickTimer = setTimeout(() => {
1 === this.clicks ? (this.emit("click", t2), !t2.defaultPrevented && h2 && c2(h2)) : (this.emit("dblClick", t2), t2.defaultPrevented || c2(d2)), this.clicks = 0, this.clickTimer = null;
}, 350))) : (this.emit("click", t2), !t2.defaultPrevented && h2 && c2(h2));
}
addTrackingPoint(t2) {
const e2 = this.trackingPoints.filter((t3) => t3.time > Date.now() - 100);
e2.push(t2), this.trackingPoints = e2;
}
onPointerDown(t2, e2, i2) {
var n2;
if (false === this.option("touch", t2))
return false;
this.pwt = 0, this.dragOffset = { x: 0, y: 0, time: 0 }, this.trackingPoints = [];
const s2 = this.content.getBoundingClientRect();
if (this.dragStart = { x: s2.x, y: s2.y, top: s2.top, left: s2.left, time: Date.now() }, this.clickTimer)
return false;
if (this.panMode === O && this.targetScale > 1)
return t2.preventDefault(), t2.stopPropagation(), false;
const o2 = t2.composedPath()[0];
if (!i2.length) {
if (["TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO", "IFRAME"].includes(o2.nodeName) || o2.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]"))
return false;
null === (n2 = window.getSelection()) || void 0 === n2 || n2.removeAllRanges();
}
if ("mousedown" === t2.type)
["A", "BUTTON"].includes(o2.nodeName) || t2.preventDefault();
else if (Math.abs(this.velocity.a) > 0.3)
return false;
return this.target.e = this.current.e, this.target.f = this.current.f, this.stop(), this.isDragging || (this.isDragging = true, this.addTrackingPoint(e2), this.emit("touchStart", t2)), true;
}
onPointerMove(e2, n2, s2) {
if (false === this.option("touch", e2))
return;
if (!this.isDragging)
return;
if (n2.length < 2 && this.panOnlyZoomed && t(this.targetScale) <= t(this.minScale))
return;
if (this.emit("touchMove", e2), e2.defaultPrevented)
return;
this.addTrackingPoint(n2[0]);
const { content: o2 } = this, a2 = h$1(s2[0], s2[1]), r2 = h$1(n2[0], n2[1]);
let l2 = 0, d2 = 0;
if (n2.length > 1) {
const t2 = o2.getBoundingClientRect();
l2 = a2.clientX - t2.left - 0.5 * t2.width, d2 = a2.clientY - t2.top - 0.5 * t2.height;
}
const u2 = c(s2[0], s2[1]), p2 = c(n2[0], n2[1]);
let f2 = u2 ? p2 / u2 : 1, g2 = r2.clientX - a2.clientX, m2 = r2.clientY - a2.clientY;
this.dragOffset.x += g2, this.dragOffset.y += m2, this.dragOffset.time = Date.now() - this.dragStart.time;
let v2 = t(this.targetScale) === t(this.minScale) && this.option("lockAxis");
if (v2 && !this.lockedAxis)
if ("xy" === v2 || "y" === v2 || "touchmove" === e2.type) {
if (Math.abs(this.dragOffset.x) < 6 && Math.abs(this.dragOffset.y) < 6)
return void e2.preventDefault();
const t2 = Math.abs(180 * Math.atan2(this.dragOffset.y, this.dragOffset.x) / Math.PI);
this.lockedAxis = t2 > 45 && t2 < 135 ? "y" : "x", this.dragOffset.x = 0, this.dragOffset.y = 0, g2 = 0, m2 = 0;
} else
this.lockedAxis = v2;
if (i(e2.target, this.content) && (v2 = "x", this.dragOffset.y = 0), v2 && "xy" !== v2 && this.lockedAxis !== v2 && t(this.targetScale) === t(this.minScale))
return;
e2.cancelable && e2.preventDefault(), this.container.classList.add(this.cn("isDragging"));
const b2 = this.checkBounds(g2, m2);
this.option("rubberband") ? ("x" !== this.isInfinite && (b2.xDiff > 0 && g2 < 0 || b2.xDiff < 0 && g2 > 0) && (g2 *= Math.max(0, 0.5 - Math.abs(0.75 / this.contentRect.fitWidth * b2.xDiff))), "y" !== this.isInfinite && (b2.yDiff > 0 && m2 < 0 || b2.yDiff < 0 && m2 > 0) && (m2 *= Math.max(0, 0.5 - Math.abs(0.75 / this.contentRect.fitHeight * b2.yDiff)))) : (b2.xDiff && (g2 = 0), b2.yDiff && (m2 = 0));
const y2 = this.targetScale, w2 = this.minScale, x2 = this.maxScale;
y2 < 0.5 * w2 && (f2 = Math.max(f2, w2)), y2 > 1.5 * x2 && (f2 = Math.min(f2, x2)), "y" === this.lockedAxis && t(y2) === t(w2) && (g2 = 0), "x" === this.lockedAxis && t(y2) === t(w2) && (m2 = 0), this.applyChange({ originX: l2, originY: d2, panX: g2, panY: m2, scale: f2, friction: this.option("dragFriction"), ignoreBounds: true });
}
onPointerUp(t2, e2, n2) {
if (n2.length)
return this.dragOffset.x = 0, this.dragOffset.y = 0, void (this.trackingPoints = []);
this.container.classList.remove(this.cn("isDragging")), this.isDragging && (this.addTrackingPoint(e2), this.panOnlyZoomed && this.contentRect.width - this.contentRect.fitWidth < 1 && this.contentRect.height - this.contentRect.fitHeight < 1 && (this.trackingPoints = []), i(t2.target, this.content) && "y" === this.lockedAxis && (this.trackingPoints = []), this.emit("touchEnd", t2), this.isDragging = false, this.lockedAxis = false, this.state !== m$2.Destroy && (t2.defaultPrevented || this.startDecelAnim()));
}
startDecelAnim() {
var e2;
const i2 = this.isScaling;
this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.isBouncingX = false, this.isBouncingY = false;
for (const t2 of v)
this.velocity[t2] = 0;
this.target.e = this.current.e, this.target.f = this.current.f, S(this.container, "is-scaling"), S(this.container, "is-animating"), this.isTicking = false;
const { trackingPoints: n2 } = this, s2 = n2[0], o2 = n2[n2.length - 1];
let a2 = 0, r2 = 0, l2 = 0;
o2 && s2 && (a2 = o2.clientX - s2.clientX, r2 = o2.clientY - s2.clientY, l2 = o2.time - s2.time);
const c2 = (null === (e2 = window.visualViewport) || void 0 === e2 ? void 0 : e2.scale) || 1;
1 !== c2 && (a2 *= c2, r2 *= c2);
let h2 = 0, d2 = 0, u2 = 0, p2 = 0, f2 = this.option("decelFriction");
const g2 = this.targetScale;
if (l2 > 0) {
u2 = Math.abs(a2) > 3 ? a2 / (l2 / 30) : 0, p2 = Math.abs(r2) > 3 ? r2 / (l2 / 30) : 0;
const t2 = this.option("maxVelocity");
t2 && (u2 = Math.max(Math.min(u2, t2), -1 * t2), p2 = Math.max(Math.min(p2, t2), -1 * t2));
}
u2 && (h2 = u2 / (1 / (1 - f2) - 1)), p2 && (d2 = p2 / (1 / (1 - f2) - 1)), ("y" === this.option("lockAxis") || "xy" === this.option("lockAxis") && "y" === this.lockedAxis && t(g2) === this.minScale) && (h2 = u2 = 0), ("x" === this.option("lockAxis") || "xy" === this.option("lockAxis") && "x" === this.lockedAxis && t(g2) === this.minScale) && (d2 = p2 = 0);
const m2 = this.dragOffset.x, b2 = this.dragOffset.y, y2 = this.option("dragMinThreshold") || 0;
Math.abs(m2) < y2 && Math.abs(b2) < y2 && (h2 = d2 = 0, u2 = p2 = 0), (this.option("zoom") && (g2 < this.minScale - 1e-5 || g2 > this.maxScale + 1e-5) || i2 && !h2 && !d2) && (f2 = 0.35), this.applyChange({ panX: h2, panY: d2, friction: f2 }), this.emit("decel", u2, p2, m2, b2);
}
onWheel(t2) {
var e2 = [-t2.deltaX || 0, -t2.deltaY || 0, -t2.detail || 0].reduce(function(t3, e3) {
return Math.abs(e3) > Math.abs(t3) ? e3 : t3;
});
const i2 = Math.max(-1, Math.min(1, e2));
if (this.emit("wheel", t2, i2), this.panMode === O)
return;
if (t2.defaultPrevented)
return;
const n2 = this.option("wheel");
"pan" === n2 ? (t2.preventDefault(), this.panOnlyZoomed && !this.canZoomOut() || this.applyChange({ panX: 2 * -t2.deltaX, panY: 2 * -t2.deltaY, bounce: false })) : "zoom" === n2 && false !== this.option("zoom") && this.zoomWithWheel(t2);
}
onMouseMove(t2) {
this.panWithMouse(t2);
}
onKeydown(t2) {
"Escape" === t2.key && this.toggleFS();
}
onResize() {
this.updateMetrics(), this.checkBounds().inBounds || this.requestTick();
}
setTransform() {
this.emit("beforeTransform");
const { current: e2, target: i2, content: n2, contentRect: s2 } = this, o2 = Object.assign({}, C);
for (const n3 of v) {
const s3 = "e" == n3 || "f" === n3 ? M : T;
o2[n3] = t(e2[n3], s3), Math.abs(i2[n3] - e2[n3]) < ("e" == n3 || "f" === n3 ? 0.51 : 1e-3) && (e2[n3] = i2[n3]);
}
let { a: a2, b: r2, c: l2, d: c2, e: h2, f: d2 } = o2, u2 = `matrix(${a2}, ${r2}, ${l2}, ${c2}, ${h2}, ${d2})`, p2 = n2.parentElement instanceof HTMLPictureElement ? n2.parentElement : n2;
if (this.option("transformParent") && (p2 = p2.parentElement || p2), p2.style.transform === u2)
return;
p2.style.transform = u2;
const { contentWidth: f2, contentHeight: g2 } = this.calculateContentDim();
s2.width = f2, s2.height = g2, this.emit("afterTransform");
}
updateMetrics(e2 = false) {
var i2;
if (!this || this.state === m$2.Destroy)
return;
if (this.isContentLoading)
return;
const n2 = Math.max(1, (null === (i2 = window.visualViewport) || void 0 === i2 ? void 0 : i2.scale) || 1), { container: s2, content: o2 } = this, a2 = o2 instanceof HTMLImageElement, r2 = s2.getBoundingClientRect(), l2 = getComputedStyle(this.container);
let c2 = r2.width * n2, h2 = r2.height * n2;
const d2 = parseFloat(l2.paddingTop) + parseFloat(l2.paddingBottom), u2 = c2 - (parseFloat(l2.paddingLeft) + parseFloat(l2.paddingRight)), p2 = h2 - d2;
this.containerRect = { width: c2, height: h2, innerWidth: u2, innerHeight: p2 };
const f2 = parseFloat(o2.dataset.width || "") || ((t2) => {
let e3 = 0;
return e3 = t2 instanceof HTMLImageElement ? t2.naturalWidth : t2 instanceof SVGElement ? t2.width.baseVal.value : Math.max(t2.offsetWidth, t2.scrollWidth), e3 || 0;
})(o2), g2 = parseFloat(o2.dataset.height || "") || ((t2) => {
let e3 = 0;
return e3 = t2 instanceof HTMLImageElement ? t2.naturalHeight : t2 instanceof SVGElement ? t2.height.baseVal.value : Math.max(t2.offsetHeight, t2.scrollHeight), e3 || 0;
})(o2);
let v2 = this.option("width", f2) || z, b2 = this.option("height", g2) || z;
const y2 = v2 === z, w2 = b2 === z;
"number" != typeof v2 && (v2 = f2), "number" != typeof b2 && (b2 = g2), y2 && (v2 = f2 * (b2 / g2)), w2 && (b2 = g2 / (f2 / v2));
let x2 = o2.parentElement instanceof HTMLPictureElement ? o2.parentElement : o2;
this.option("transformParent") && (x2 = x2.parentElement || x2);
const E2 = x2.getAttribute("style") || "";
x2.style.setProperty("transform", "none", "important"), a2 && (x2.style.width = "", x2.style.height = ""), x2.offsetHeight;
const S2 = o2.getBoundingClientRect();
let P2 = S2.width * n2, C2 = S2.height * n2, T2 = P2, M2 = C2;
P2 = Math.min(P2, v2), C2 = Math.min(C2, b2), a2 ? { width: P2, height: C2 } = ((t2, e3, i3, n3) => {
const s3 = i3 / t2, o3 = n3 / e3, a3 = Math.min(s3, o3);
return { width: t2 *= a3, height: e3 *= a3 };
})(v2, b2, P2, C2) : (P2 = Math.min(P2, v2), C2 = Math.min(C2, b2));
let O2 = 0.5 * (M2 - C2), A2 = 0.5 * (T2 - P2);
this.contentRect = Object.assign(Object.assign({}, this.contentRect), { top: S2.top - r2.top + O2, bottom: r2.bottom - S2.bottom + O2, left: S2.left - r2.left + A2, right: r2.right - S2.right + A2, fitWidth: P2, fitHeight: C2, width: P2, height: C2, fullWidth: v2, fullHeight: b2 }), x2.style.cssText = E2, a2 && (x2.style.width = `${P2}px`, x2.style.height = `${C2}px`), this.setTransform(), true !== e2 && this.emit("refresh"), this.ignoreBounds || (t(this.targetScale) < t(this.minScale) ? this.zoomTo(this.minScale, { friction: 0 }) : this.targetScale > this.maxScale ? this.zoomTo(this.maxScale, { friction: 0 }) : this.state === m$2.Init || this.checkBounds().inBounds || this.requestTick()), this.updateControls();
}
calculateBounds() {
const { contentWidth: e2, contentHeight: i2 } = this.calculateContentDim(this.target), { targetScale: n2, lockedAxis: s2 } = this, { fitWidth: o2, fitHeight: a2 } = this.contentRect;
let r2 = 0, l2 = 0, c2 = 0, h2 = 0;
const d2 = this.option("infinite");
if (true === d2 || s2 && d2 === s2)
r2 = -1 / 0, c2 = 1 / 0, l2 = -1 / 0, h2 = 1 / 0;
else {
let { containerRect: s3, contentRect: d3 } = this, u2 = t(o2 * n2, M), p2 = t(a2 * n2, M), { innerWidth: f2, innerHeight: g2 } = s3;
if (s3.width === u2 && (f2 = s3.width), s3.width === p2 && (g2 = s3.height), e2 > f2) {
c2 = 0.5 * (e2 - f2), r2 = -1 * c2;
let t2 = 0.5 * (d3.right - d3.left);
r2 += t2, c2 += t2;
}
if (o2 > f2 && e2 < f2 && (r2 -= 0.5 * (o2 - f2), c2 -= 0.5 * (o2 - f2)), i2 > g2) {
h2 = 0.5 * (i2 - g2), l2 = -1 * h2;
let t2 = 0.5 * (d3.bottom - d3.top);
l2 += t2, h2 += t2;
}
a2 > g2 && i2 < g2 && (r2 -= 0.5 * (a2 - g2), c2 -= 0.5 * (a2 - g2));
}
return { x: { min: r2, max: c2 }, y: { min: l2, max: h2 } };
}
getBounds() {
const t2 = this.option("bounds");
return t2 !== z ? t2 : this.calculateBounds();
}
updateControls() {
const e2 = this, i2 = e2.container, { panMode: n2, contentRect: s2, targetScale: a2, minScale: r2 } = e2;
let l2 = r2, c2 = e2.option("click") || false;
c2 && (l2 = e2.getNextScale(c2));
let h2 = e2.canZoomIn(), d2 = e2.canZoomOut(), u2 = n2 === A && !!this.option("touch"), p2 = d2 && u2;
if (u2 && (t(a2) < t(r2) && !this.panOnlyZoomed && (p2 = true), (t(s2.width, 1) > t(s2.fitWidth, 1) || t(s2.height, 1) > t(s2.fitHeight, 1)) && (p2 = true)), t(s2.width * a2, 1) < t(s2.fitWidth, 1) && (p2 = false), n2 === O && (p2 = false), o(i2, this.cn("isDraggable"), p2), !this.option("zoom"))
return;
let f2 = h2 && t(l2) > t(a2), g2 = !f2 && !p2 && d2 && t(l2) < t(a2);
o(i2, this.cn("canZoomIn"), f2), o(i2, this.cn("canZoomOut"), g2);
for (const t2 of i2.querySelectorAll("[data-panzoom-action]")) {
let e3 = false, i3 = false;
switch (t2.dataset.panzoomAction) {
case "zoomIn":
h2 ? e3 = true : i3 = true;
break;
case "zoomOut":
d2 ? e3 = true : i3 = true;
break;
case "toggleZoom":
case "iterateZoom":
h2 || d2 ? e3 = true : i3 = true;
const n3 = t2.querySelector("g");
n3 && (n3.style.display = h2 ? "" : "none");
}
e3 ? (t2.removeAttribute("disabled"), t2.removeAttribute("tabindex")) : i3 && (t2.setAttribute("disabled", ""), t2.setAttribute("tabindex", "-1"));
}
}
panTo({ x: t2 = this.target.e, y: e2 = this.target.f, scale: i2 = this.targetScale, friction: n2 = this.option("friction"), angle: s2 = 0, originX: o2 = 0, originY: a2 = 0, flipX: r2 = false, flipY: l2 = false, ignoreBounds: c2 = false }) {
this.state !== m$2.Destroy && this.applyChange({ panX: t2 - this.target.e, panY: e2 - this.target.f, scale: i2 / this.targetScale, angle: s2, originX: o2, originY: a2, friction: n2, flipX: r2, flipY: l2, ignoreBounds: c2 });
}
applyChange({ panX: e2 = 0, panY: i2 = 0, scale: n2 = 1, angle: s2 = 0, originX: o2 = -this.current.e, originY: a2 = -this.current.f, friction: r2 = this.option("friction"), flipX: l2 = false, flipY: c2 = false, ignoreBounds: h2 = false, bounce: d2 = this.option("bounce") }) {
const u2 = this.state;
if (u2 === m$2.Destroy)
return;
this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.friction = r2 || 0, this.ignoreBounds = h2;
const { current: p2 } = this, f2 = p2.e, g2 = p2.f, b2 = this.getMatrix(this.target);
let y2 = new DOMMatrix().translate(f2, g2).translate(o2, a2).translate(e2, i2);
if (this.option("zoom")) {
if (!h2) {
const t2 = this.targetScale, e3 = this.minScale, i3 = this.maxScale;
t2 * n2 < e3 && (n2 = e3 / t2), t2 * n2 > i3 && (n2 = i3 / t2);
}
y2 = y2.scale(n2);
}
y2 = y2.translate(-o2, -a2).translate(-f2, -g2).multiply(b2), s2 && (y2 = y2.rotate(s2)), l2 && (y2 = y2.scale(-1, 1)), c2 && (y2 = y2.scale(1, -1));
for (const e3 of v)
"e" !== e3 && "f" !== e3 && (y2[e3] > this.minScale + 1e-5 || y2[e3] < this.minScale - 1e-5) ? this.target[e3] = y2[e3] : this.target[e3] = t(y2[e3], M);
(this.targetScale < this.scale || Math.abs(n2 - 1) > 0.1 || this.panMode === O || false === d2) && !h2 && this.clampTargetBounds(), u2 === m$2.Init ? this.animate() : this.isResting || (this.state = m$2.Panning, this.requestTick());
}
stop(t2 = false) {
if (this.state === m$2.Init || this.state === m$2.Destroy)
return;
const e2 = this.isTicking;
this.rAF && (cancelAnimationFrame(this.rAF), this.rAF = null), this.isBouncingX = false, this.isBouncingY = false;
for (const e3 of v)
this.velocity[e3] = 0, "current" === t2 ? this.current[e3] = this.target[e3] : "target" === t2 && (this.target[e3] = this.current[e3]);
this.setTransform(), S(this.container, "is-scaling"), S(this.container, "is-animating"), this.isTicking = false, this.state = m$2.Ready, e2 && (this.emit("endAnimation"), this.updateControls());
}
requestTick() {
this.isTicking || (this.emit("startAnimation"), this.updateControls(), P(this.container, "is-animating"), this.isScaling && P(this.container, "is-scaling")), this.isTicking = true, this.rAF || (this.rAF = requestAnimationFrame(() => this.animate()));
}
panWithMouse(e2, i2 = this.option("mouseMoveFriction")) {
if (this.pmme = e2, this.panMode !== O || !e2)
return;
if (t(this.targetScale) <= t(this.minScale))
return;
this.emit("mouseMove", e2);
const { container: n2, containerRect: s2, contentRect: o2 } = this, a2 = s2.width, r2 = s2.height, l2 = n2.getBoundingClientRect(), c2 = (e2.clientX || 0) - l2.left, h2 = (e2.clientY || 0) - l2.top;
let { contentWidth: d2, contentHeight: u2 } = this.calculateContentDim(this.target);
const p2 = this.option("mouseMoveFactor");
p2 > 1 && (d2 !== a2 && (d2 *= p2), u2 !== r2 && (u2 *= p2));
let f2 = 0.5 * (d2 - a2) - c2 / a2 * 100 / 100 * (d2 - a2);
f2 += 0.5 * (o2.right - o2.left);
let g2 = 0.5 * (u2 - r2) - h2 / r2 * 100 / 100 * (u2 - r2);
g2 += 0.5 * (o2.bottom - o2.top), this.applyChange({ panX: f2 - this.target.e, panY: g2 - this.target.f, friction: i2 });
}
zoomWithWheel(e2) {
if (this.state === m$2.Destroy || this.state === m$2.Init)
return;
const i2 = Date.now();
if (i2 - this.pwt < 45)
return void e2.preventDefault();
this.pwt = i2;
var n2 = [-e2.deltaX || 0, -e2.deltaY || 0, -e2.detail || 0].reduce(function(t2, e3) {
return Math.abs(e3) > Math.abs(t2) ? e3 : t2;
});
const s2 = Math.max(-1, Math.min(1, n2)), { targetScale: o2, maxScale: a2, minScale: r2 } = this;
let l2 = o2 * (100 + 45 * s2) / 100;
t(l2) < t(r2) && t(o2) <= t(r2) ? (this.cwd += Math.abs(s2), l2 = r2) : t(l2) > t(a2) && t(o2) >= t(a2) ? (this.cwd += Math.abs(s2), l2 = a2) : (this.cwd = 0, l2 = Math.max(Math.min(l2, a2), r2)), this.cwd > this.option("wheelLimit") || (e2.preventDefault(), t(l2) !== t(o2) && this.zoomTo(l2, { event: e2 }));
}
canZoomIn() {
return this.option("zoom") && (t(this.contentRect.width, 1) < t(this.contentRect.fitWidth, 1) || t(this.targetScale) < t(this.maxScale));
}
canZoomOut() {
return this.option("zoom") && t(this.targetScale) > t(this.minScale);
}
zoomIn(t2 = 1.25, e2) {
this.zoomTo(this.targetScale * t2, e2);
}
zoomOut(t2 = 0.8, e2) {
this.zoomTo(this.targetScale * t2, e2);
}
zoomToFit(t2) {
this.zoomTo("fit", t2);
}
zoomToCover(t2) {
this.zoomTo("cover", t2);
}
zoomToFull(t2) {
this.zoomTo("full", t2);
}
zoomToMax(t2) {
this.zoomTo("max", t2);
}
toggleZoom(t2) {
this.zoomTo(this.getNextScale("toggleZoom"), t2);
}
toggleMax(t2) {
this.zoomTo(this.getNextScale("toggleMax"), t2);
}
toggleCover(t2) {
this.zoomTo(this.getNextScale("toggleCover"), t2);
}
iterateZoom(t2) {
this.zoomTo("next", t2);
}
zoomTo(t2 = 1, { friction: e2 = z, originX: i2 = z, originY: n2 = z, event: s2 } = {}) {
if (this.isContentLoading || this.state === m$2.Destroy)
return;
const { targetScale: o2, fullScale: a2, maxScale: r2, coverScale: l2 } = this;
if (this.stop(), this.panMode === O && (s2 = this.pmme || s2), s2 || i2 === z || n2 === z) {
const t3 = this.content.getBoundingClientRect(), e3 = this.container.getBoundingClientRect(), o3 = s2 ? s2.clientX : e3.left + 0.5 * e3.width, a3 = s2 ? s2.clientY : e3.top + 0.5 * e3.height;
i2 = o3 - t3.left - 0.5 * t3.width, n2 = a3 - t3.top - 0.5 * t3.height;
}
let c2 = 1;
"number" == typeof t2 ? c2 = t2 : "full" === t2 ? c2 = a2 : "cover" === t2 ? c2 = l2 : "max" === t2 ? c2 = r2 : "fit" === t2 ? c2 = 1 : "next" === t2 && (c2 = this.getNextScale("iterateZoom")), c2 = c2 / o2 || 1, e2 = e2 === z ? c2 > 1 ? 0.15 : 0.25 : e2, this.applyChange({ scale: c2, originX: i2, originY: n2, friction: e2 }), s2 && this.panMode === O && this.panWithMouse(s2, e2);
}
rotateCCW() {
this.applyChange({ angle: -90 });
}
rotateCW() {
this.applyChange({ angle: 90 });
}
flipX() {
this.applyChange({ flipX: true });
}
flipY() {
this.applyChange({ flipY: true });
}
fitX() {
this.stop("target");
const { containerRect: t2, contentRect: e2, target: i2 } = this;
this.applyChange({ panX: 0.5 * t2.width - (e2.left + 0.5 * e2.fitWidth) - i2.e, panY: 0.5 * t2.height - (e2.top + 0.5 * e2.fitHeight) - i2.f, scale: t2.width / e2.fitWidth / this.targetScale, originX: 0, originY: 0, ignoreBounds: true });
}
fitY() {
this.stop("target");
const { containerRect: t2, contentRect: e2, target: i2 } = this;
this.applyChange({ panX: 0.5 * t2.width - (e2.left + 0.5 * e2.fitWidth) - i2.e, panY: 0.5 * t2.innerHeight - (e2.top + 0.5 * e2.fitHeight) - i2.f, scale: t2.height / e2.fitHeight / this.targetScale, originX: 0, originY: 0, ignoreBounds: true });
}
toggleFS() {
const { container: t2 } = this, e2 = this.cn("inFullscreen"), i2 = this.cn("htmlHasFullscreen");
t2.classList.toggle(e2);
const n2 = t2.classList.contains(e2);
n2 ? (document.documentElement.classList.add(i2), document.addEventListener("keydown", this.onKeydown, true)) : (document.documentElement.classList.remove(i2), document.removeEventListener("keydown", this.onKeydown, true)), this.updateMetrics(), this.emit(n2 ? "enterFS" : "exitFS");
}
getMatrix(t2 = this.current) {
const { a: e2, b: i2, c: n2, d: s2, e: o2, f: a2 } = t2;
return new DOMMatrix([e2, i2, n2, s2, o2, a2]);
}
reset(t2) {
if (this.state !== m$2.Init && this.state !== m$2.Destroy) {
this.stop("current");
for (const t3 of v)
this.target[t3] = C[t3];
this.target.a = this.minScale, this.target.d = this.minScale, this.clampTargetBounds(), this.isResting || (this.friction = void 0 === t2 ? this.option("friction") : t2, this.state = m$2.Panning, this.requestTick());
}
}
destroy() {
this.stop(), this.state = m$2.Destroy, this.detachEvents(), this.detachObserver();
const { container: t2, content: e2 } = this, i2 = this.option("classes") || {};
for (const e3 of Object.values(i2))
t2.classList.remove(e3 + "");
e2 && (e2.removeEventListener("load", this.onLoad), e2.removeEventListener("error", this.onError)), this.detachPlugins();
}
}
Object.defineProperty(I, "defaults", { enumerable: true, configurable: true, writable: true, value: y$1 }), Object.defineProperty(I, "Plugins", { enumerable: true, configurable: true, writable: true, value: {} });
const D = function(t2, e2) {
let i2 = true;
return (...n2) => {
i2 && (i2 = false, t2(...n2), setTimeout(() => {
i2 = true;
}, e2));
};
}, F = (t2, e2) => {
let i2 = [];
return t2.childNodes.forEach((t3) => {
t3.nodeType !== Node.ELEMENT_NODE || e2 && !t3.matches(e2) || i2.push(t3);
}), i2;
}, j = { viewport: null, track: null, enabled: true, slides: [], axis: "x", transition: "fade", preload: 1, slidesPerPage: "auto", initialPage: 0, friction: 0.12, Panzoom: { decelFriction: 0.12 }, center: true, infinite: true, fill: true, dragFree: false, adaptiveHeight: false, 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 B;
!function(t2) {
t2[t2.Init = 0] = "Init", t2[t2.Ready = 1] = "Ready", t2[t2.Destroy = 2] = "Destroy";
}(B || (B = {}));
const H = (t2) => {
if ("string" == typeof t2 || t2 instanceof HTMLElement)
t2 = { html: t2 };
else {
const e2 = t2.thumb;
void 0 !== e2 && ("string" == typeof e2 && (t2.thumbSrc = e2), e2 instanceof HTMLImageElement && (t2.thumbEl = e2, t2.thumbElSrc = e2.src, t2.thumbSrc = e2.src), delete t2.thumb);
}
return Object.assign({ html: "", el: null, isDom: false, class: "", customClass: "", index: -1, dim: 0, gap: 0, pos: 0, transition: false }, t2);
}, N = (t2 = {}) => Object.assign({ index: -1, slides: [], dim: 0, pos: -1 }, t2);
class _ extends f {
constructor(t2, e2) {
super(e2), Object.defineProperty(this, "instance", { enumerable: true, configurable: true, writable: true, value: t2 });
}
attach() {
}
detach() {
}
}
const $ = { 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: '<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>', dynamicFrom: 11, maxCount: 1 / 0, minCount: 2 };
class W extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "isDynamic", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "list", { enumerable: true, configurable: true, writable: true, value: null });
}
onRefresh() {
this.refresh();
}
build() {
let t2 = this.list;
if (!t2) {
t2 = document.createElement("ul"), P(t2, this.cn("list")), t2.setAttribute("role", "tablist");
const e2 = this.instance.container;
e2.appendChild(t2), P(e2, this.cn("hasDots")), this.list = t2;
}
return t2;
}
refresh() {
var t2;
const e2 = this.instance.pages.length, i2 = Math.min(2, this.option("minCount")), n2 = Math.max(2e3, this.option("maxCount")), s2 = this.option("dynamicFrom");
if (e2 < i2 || e2 > n2)
return void this.cleanup();
const a2 = "number" == typeof s2 && e2 > 5 && e2 >= s2, r2 = !this.list || this.isDynamic !== a2 || this.list.children.length !== e2;
r2 && this.cleanup();
const l2 = this.build();
if (o(l2, this.cn("isDynamic"), !!a2), r2)
for (let t3 = 0; t3 < e2; t3++)
l2.append(this.createItem(t3));
let c2, h2 = 0;
for (const e3 of [...l2.children]) {
const i3 = h2 === this.instance.page;
i3 && (c2 = e3), o(e3, this.cn("isCurrent"), i3), null === (t2 = e3.children[0]) || void 0 === t2 || t2.setAttribute("aria-selected", i3 ? "true" : "false");
for (const t3 of ["isBeforePrev", "isPrev", "isNext", "isAfterNext"])
S(e3, this.cn(t3));
h2++;
}
if (c2 = c2 || l2.firstChild, a2 && c2) {
const t3 = c2.previousElementSibling, e3 = t3 && t3.previousElementSibling;
P(t3, this.cn("isPrev")), P(e3, this.cn("isBeforePrev"));
const i3 = c2.nextElementSibling, n3 = i3 && i3.nextElementSibling;
P(i3, this.cn("isNext")), P(n3, this.cn("isAfterNext"));
}
this.isDynamic = a2;
}
createItem(t2 = 0) {
var e2;
const i2 = document.createElement("li");
i2.setAttribute("role", "presentation");
const s2 = n(this.instance.localize(this.option("dotTpl"), [["%d", t2 + 1]]).replace(/\%i/g, t2 + ""));
return i2.appendChild(s2), null === (e2 = i2.children[0]) || void 0 === e2 || e2.setAttribute("role", "tab"), i2;
}
cleanup() {
this.list && (this.list.remove(), this.list = null), this.isDynamic = false, S(this.instance.container, this.cn("hasDots"));
}
attach() {
this.instance.on(["refresh", "change"], this.onRefresh);
}
detach() {
this.instance.off(["refresh", "change"], this.onRefresh), this.cleanup();
}
}
Object.defineProperty(W, "defaults", { enumerable: true, configurable: true, writable: true, value: $ });
const X = "disabled", q = "next", Y = "prev";
class V extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "prev", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "next", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "isDom", { enumerable: true, configurable: true, writable: true, value: false });
}
onRefresh() {
const t2 = this.instance, e2 = t2.pages.length, i2 = t2.page;
if (e2 < 2)
return void this.cleanup();
this.build();
let n2 = this.prev, s2 = this.next;
n2 && s2 && (n2.removeAttribute(X), s2.removeAttribute(X), t2.isInfinite || (i2 <= 0 && n2.setAttribute(X, ""), i2 >= e2 - 1 && s2.setAttribute(X, "")));
}
addBtn(t2) {
var e2;
const i2 = this.instance, n2 = document.createElement("button");
n2.setAttribute("tabindex", "0"), n2.setAttribute("title", i2.localize(`{{${t2.toUpperCase()}}}`)), P(n2, this.cn("button") + " " + this.cn(t2 === q ? "isNext" : "isPrev"));
const s2 = i2.isRTL ? t2 === q ? Y : q : t2;
var o2;
return n2.innerHTML = i2.localize(this.option(`${s2}Tpl`)), n2.dataset[`carousel${o2 = t2, o2 ? o2.match("^[a-z]") ? o2.charAt(0).toUpperCase() + o2.substring(1) : o2 : ""}`] = "true", null === (e2 = this.container) || void 0 === e2 || e2.appendChild(n2), n2;
}
build() {
const t2 = this.instance.container, e2 = this.cn("container");
let { container: i2, prev: n2, next: s2 } = this;
i2 || (i2 = t2.querySelector("." + e2), this.isDom = !!i2), i2 || (i2 = document.createElement("div"), P(i2, e2), t2.appendChild(i2)), this.container = i2, s2 || (s2 = i2.querySelector("[data-carousel-next]")), s2 || (s2 = this.addBtn(q)), this.next = s2, n2 || (n2 = i2.querySelector("[data-carousel-prev]")), n2 || (n2 = this.addBtn(Y)), this.prev = n2;
}
cleanup() {
this.isDom || (this.prev && this.prev.remove(), this.next && this.next.remove(), this.container && this.container.remove()), this.prev = null, this.next = null, this.container = null, this.isDom = false;
}
attach() {
this.instance.on(["refresh", "change"], this.onRefresh);
}
detach() {
this.instance.off(["refresh", "change"], this.onRefresh), this.cleanup();
}
}
Object.defineProperty(V, "defaults", { enumerable: true, configurable: true, writable: true, value: { classes: { container: "f-carousel__nav", button: "f-button", isNext: "is-next", isPrev: "is-prev" }, nextTpl: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>', prevTpl: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>' } });
class Z extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "selectedIndex", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "target", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "nav", { enumerable: true, configurable: true, writable: true, value: null });
}
addAsTargetFor(t2) {
this.target = this.instance, this.nav = t2, this.attachEvents();
}
addAsNavFor(t2) {
this.nav = this.instance, this.target = t2, this.attachEvents();
}
attachEvents() {
const { nav: t2, target: e2 } = this;
t2 && e2 && (t2.options.initialSlide = e2.options.initialPage, t2.state === B.Ready ? this.onNavReady(t2) : t2.on("ready", this.onNavReady), e2.state === B.Ready ? this.onTargetReady(e2) : e2.on("ready", this.onTargetReady));
}
onNavReady(t2) {
t2.on("createSlide", this.onNavCreateSlide), t2.on("Panzoom.click", this.onNavClick), t2.on("Panzoom.touchEnd", this.onNavTouch), this.onTargetChange();
}
onTargetReady(t2) {
t2.on("change", this.onTargetChange), t2.on("Panzoom.refresh", this.onTargetChange), this.onTargetChange();
}
onNavClick(t2, e2, i2) {
this.onNavTouch(t2, t2.panzoom, i2);
}
onNavTouch(t2, e2, i2) {
var n2, s2;
if (Math.abs(e2.dragOffset.x) > 3 || Math.abs(e2.dragOffset.y) > 3)
return;
const o2 = i2.target, { nav: a2, target: r2 } = this;
if (!a2 || !r2 || !o2)
return;
const l2 = o2.closest("[data-index]");
if (i2.stopPropagation(), i2.preventDefault(), !l2)
return;
const c2 = parseInt(l2.dataset.index || "", 10) || 0, h2 = r2.getPageForSlide(c2), d2 = a2.getPageForSlide(c2);
a2.slideTo(d2), r2.slideTo(h2, { friction: (null === (s2 = null === (n2 = this.nav) || void 0 === n2 ? void 0 : n2.plugins) || void 0 === s2 ? void 0 : s2.Sync.option("friction")) || 0 }), this.markSelectedSlide(c2);
}
onNavCreateSlide(t2, e2) {
e2.index === this.selectedIndex && this.markSelectedSlide(e2.index);
}
onTargetChange() {
var t2, e2;
const { target: i2, nav: n2 } = this;
if (!i2 || !n2)
return;
if (n2.state !== B.Ready || i2.state !== B.Ready)
return;
const s2 = null === (e2 = null === (t2 = i2.pages[i2.page]) || void 0 === t2 ? void 0 : t2.slides[0]) || void 0 === e2 ? void 0 : e2.index, o2 = n2.getPageForSlide(s2);
this.markSelectedSlide(s2), n2.slideTo(o2, null === n2.prevPage && null === i2.prevPage ? { friction: 0 } : void 0);
}
markSelectedSlide(t2) {
const e2 = this.nav;
e2 && e2.state === B.Ready && (this.selectedIndex = t2, [...e2.slides].map((e3) => {
e3.el && e3.el.classList[e3.index === t2 ? "add" : "remove"]("is-nav-selected");
}));
}
attach() {
const t2 = this;
let e2 = t2.options.target, i2 = t2.options.nav;
e2 ? t2.addAsNavFor(e2) : i2 && t2.addAsTargetFor(i2);
}
detach() {
const t2 = this, e2 = t2.nav, i2 = t2.target;
e2 && (e2.off("ready", t2.onNavReady), e2.off("createSlide", t2.onNavCreateSlide), e2.off("Panzoom.click", t2.onNavClick), e2.off("Panzoom.touchEnd", t2.onNavTouch)), t2.nav = null, i2 && (i2.off("ready", t2.onTargetReady), i2.off("refresh", t2.onTargetChange), i2.off("change", t2.onTargetChange)), t2.target = null;
}
}
Object.defineProperty(Z, "defaults", { enumerable: true, configurable: true, writable: true, value: { friction: 0.35 } });
const U = { Navigation: V, Dots: W, Sync: Z }, G = "animationend", K = "isSelected", J = "slide";
class Q extends g {
get axis() {
return this.isHorizontal ? "e" : "f";
}
get isEnabled() {
return this.state === B.Ready;
}
get isInfinite() {
let t2 = false;
const { contentDim: e2, viewportDim: i2, pages: n2, slides: s2 } = this, o2 = s2[0];
return n2.length >= 2 && o2 && e2 + o2.dim >= i2 && (t2 = this.option("infinite")), t2;
}
get isRTL() {
return "rtl" === this.option("direction");
}
get isHorizontal() {
return "x" === this.option("axis");
}
constructor(t2, e2 = {}, i2 = {}) {
if (super(), Object.defineProperty(this, "bp", { enumerable: true, configurable: true, writable: true, value: "" }), Object.defineProperty(this, "lp", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "userOptions", { enumerable: true, configurable: true, writable: true, value: {} }), Object.defineProperty(this, "userPlugins", { enumerable: true, configurable: true, writable: true, value: {} }), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: B.Init }), Object.defineProperty(this, "page", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "prevPage", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: void 0 }), Object.defineProperty(this, "viewport", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "track", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "slides", { enumerable: true, configurable: true, writable: true, value: [] }), Object.defineProperty(this, "pages", { enumerable: true, configurable: true, writable: true, value: [] }), Object.defineProperty(this, "panzoom", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "inTransition", { enumerable: true, configurable: true, writable: true, value: /* @__PURE__ */ new Set() }), Object.defineProperty(this, "contentDim", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "viewportDim", { enumerable: true, configurable: true, writable: true, value: 0 }), "string" == typeof t2 && (t2 = document.querySelector(t2)), !t2 || !E(t2))
throw new Error("No Element found");
this.container = t2, this.slideNext = D(this.slideNext.bind(this), 150), this.slidePrev = D(this.slidePrev.bind(this), 150), this.userOptions = e2, this.userPlugins = i2, queueMicrotask(() => {
this.processOptions();
});
}
processOptions() {
var t2, e2;
const i2 = u({}, Q.defaults, this.userOptions);
let n2 = "";
const s2 = i2.breakpoints;
if (s2 && d$1(s2))
for (const [t3, e3] of Object.entries(s2))
window.matchMedia(t3).matches && d$1(e3) && (n2 += t3, u(i2, e3));
n2 === this.bp && this.state !== B.Init || (this.bp = n2, this.state === B.Ready && (i2.initialSlide = (null === (e2 = null === (t2 = this.pages[this.page]) || void 0 === t2 ? void 0 : t2.slides[0]) || void 0 === e2 ? void 0 : e2.index) || 0), this.state !== B.Init && this.destroy(), super.setOptions(i2), false === this.option("enabled") ? this.attachEvents() : setTimeout(() => {
this.init();
}, 0));
}
init() {
this.state = B.Init, this.emit("init"), this.attachPlugins(Object.assign(Object.assign({}, Q.Plugins), this.userPlugins)), this.emit("attachPlugins"), this.initLayout(), this.initSlides(), this.updateMetrics(), this.setInitialPosition(), this.initPanzoom(), this.attachEvents(), this.state = B.Ready, this.emit("ready");
}
initLayout() {
const { container: t2 } = this, e2 = this.option("classes");
P(t2, this.cn("container")), o(t2, e2.isLTR, !this.isRTL), o(t2, e2.isRTL, this.isRTL), o(t2, e2.isVertical, !this.isHorizontal), o(t2, e2.isHorizontal, this.isHorizontal);
let i2 = this.option("viewport") || t2.querySelector(`.${e2.viewport}`);
i2 || (i2 = document.createElement("div"), P(i2, e2.viewport), i2.append(...F(t2, `.${e2.slide}`)), t2.prepend(i2)), i2.addEventListener("scroll", this.onScroll);
let n2 = this.option("track") || t2.querySelector(`.${e2.track}`);
n2 || (n2 = document.createElement("div"), P(n2, e2.track), n2.append(...Array.from(i2.childNodes))), n2.setAttribute("aria-live", "polite"), i2.contains(n2) || i2.prepend(n2), this.viewport = i2, this.track = n2, this.emit("initLayout");
}
initSlides() {
const { track: t2 } = this;
if (!t2)
return;
const e2 = [...this.slides], i2 = [];
[...F(t2, `.${this.cn(J)}`)].forEach((t3) => {
if (E(t3)) {
const e3 = H({ el: t3, isDom: true, index: this.slides.length });
i2.push(e3);
}
});
for (let t3 of [...this.option("slides", []) || [], ...e2])
i2.push(H(t3));
this.slides = i2;
for (let t3 = 0; t3 < this.slides.length; t3++)
this.slides[t3].index = t3;
for (const t3 of i2)
this.emit("beforeInitSlide", t3, t3.index), this.emit("initSlide", t3, t3.index);
this.emit("initSlides");
}
setInitialPage() {
const t2 = this.option("initialSlide");
this.page = "number" == typeof t2 ? this.getPageForSlide(t2) : parseInt(this.option("initialPage", 0) + "", 10) || 0;
}
setInitialPosition() {
const { track: t2, pages: e2, isHorizontal: i2 } = this;
if (!t2 || !e2.length)
return;
let n2 = this.page;
e2[n2] || (this.page = n2 = 0);
const s2 = (e2[n2].pos || 0) * (this.isRTL && i2 ? 1 : -1), o2 = i2 ? `${s2}px` : "0", a2 = i2 ? "0" : `${s2}px`;
t2.style.transform = `translate3d(${o2}, ${a2}, 0) scale(1)`, this.option("adaptiveHeight") && this.setViewportHeight();
}
initPanzoom() {
this.panzoom && (this.panzoom.destroy(), this.panzoom = null);
const t2 = this.option("Panzoom") || {};
this.panzoom = new I(this.viewport, u({}, { content: this.track, zoom: false, panOnlyZoomed: false, lockAxis: this.isHorizontal ? "x" : "y", infinite: this.isInfinite, click: false, dblClick: false, touch: (t3) => !(this.pages.length < 2 && !t3.options.infinite), bounds: () => this.getBounds(), maxVelocity: (t3) => Math.abs(t3.target[this.axis] - t3.current[this.axis]) < 2 * this.viewportDim ? 100 : 0 }, t2)), this.panzoom.on("*", (t3, e2, ...i2) => {
this.emit(`Panzoom.${e2}`, t3, ...i2);
}), this.panzoom.on("decel", this.onDecel), this.panzoom.on("refresh", this.onRefresh), this.panzoom.on("beforeTransform", this.onBeforeTransform), this.panzoom.on("endAnimation", this.onEndAnimation);
}
attachEvents() {
const t2 = this.container;
t2 && (t2.addEventListener("click", this.onClick, { passive: false, capture: false }), t2.addEventListener("slideTo", this.onSlideTo)), window.addEventListener("resize", this.onResize);
}
createPages() {
let t2 = [];
const { contentDim: e2, viewportDim: i2 } = this;
let n2 = this.option("slidesPerPage");
n2 = ("auto" === n2 || e2 <= i2) && false !== this.option("fill") ? 1 / 0 : parseFloat(n2 + "");
let s2 = 0, o2 = 0, a2 = 0;
for (const e3 of this.slides)
(!t2.length || o2 + e3.dim - i2 > 0.05 || a2 >= n2) && (t2.push(N()), s2 = t2.length - 1, o2 = 0, a2 = 0), t2[s2].slides.push(e3), o2 += e3.dim + e3.gap, a2++;
return t2;
}
processPages() {
const e2 = this.pages, { contentDim: i2, viewportDim: n2, isInfinite: s2 } = this, o2 = this.option("center"), a2 = this.option("fill"), r2 = a2 && o2 && i2 > n2 && !s2;
if (e2.forEach((t2, e3) => {
var s3;
t2.index = e3, t2.pos = (null === (s3 = t2.slides[0]) || void 0 === s3 ? void 0 : s3.pos) || 0, t2.dim = 0;
for (const [e4, i3] of t2.slides.entries())
t2.dim += i3.dim, e4 < t2.slides.length - 1 && (t2.dim += i3.gap);
r2 && t2.pos + 0.5 * t2.dim < 0.5 * n2 ? t2.pos = 0 : r2 && t2.pos + 0.5 * t2.dim >= i2 - 0.5 * n2 ? t2.pos = i2 - n2 : o2 && (t2.pos += -0.5 * (n2 - t2.dim));
}), e2.forEach((e3) => {
a2 && !s2 && i2 > n2 && (e3.pos = Math.max(e3.pos, 0), e3.pos = Math.min(e3.pos, i2 - n2)), e3.pos = t(e3.pos, 1e3), e3.dim = t(e3.dim, 1e3), Math.abs(e3.pos) <= 0.1 && (e3.pos = 0);
}), s2)
return e2;
const l2 = [];
let c2;
return e2.forEach((t2) => {
const e3 = Object.assign({}, t2);
c2 && e3.pos === c2.pos ? (c2.dim += e3.dim, c2.slides = [...c2.slides, ...e3.slides]) : (e3.index = l2.length, c2 = e3, l2.push(e3));
}), l2;
}
getPageFromIndex(t2 = 0) {
const e2 = this.pages.length;
let i2;
return t2 = parseInt((t2 || 0).toString()) || 0, i2 = this.isInfinite ? (t2 % e2 + e2) % e2 : Math.max(Math.min(t2, e2 - 1), 0), i2;
}
getSlideMetrics(e2) {
var i2, n2;
const s2 = this.isHorizontal ? "width" : "height";
let o2 = 0, a2 = 0, r2 = e2.el;
const l2 = !(!r2 || r2.parentNode);
if (r2 ? o2 = parseFloat(r2.dataset[s2] || "") || 0 : (r2 = document.createElement("div"), r2.style.visibility = "hidden", (this.track || document.body).prepend(r2)), P(r2, this.cn(J) + " " + e2.class + " " + e2.customClass), o2)
r2.style[s2] = `${o2}px`, r2.style["width" === s2 ? "height" : "width"] = "";
else {
l2 && (this.track || document.body).prepend(r2), o2 = r2.getBoundingClientRect()[s2] * Math.max(1, (null === (i2 = window.visualViewport) || void 0 === i2 ? void 0 : i2.scale) || 1);
let t2 = r2[this.isHorizontal ? "offsetWidth" : "offsetHeight"];
t2 - 1 > o2 && (o2 = t2);
}
const c2 = getComputedStyle(r2);
return "content-box" === c2.boxSizing && (this.isHorizontal ? (o2 += parseFloat(c2.paddingLeft) || 0, o2 += parseFloat(c2.paddingRight) || 0) : (o2 += parseFloat(c2.paddingTop) || 0, o2 += parseFloat(c2.paddingBottom) || 0)), a2 = parseFloat(c2[this.isHorizontal ? "marginRight" : "marginBottom"]) || 0, l2 ? null === (n2 = r2.parentElement) || void 0 === n2 || n2.removeChild(r2) : e2.el || r2.remove(), { dim: t(o2, 1e3), gap: t(a2, 1e3) };
}
getBounds() {
const { isInfinite: t2, isRTL: e2, isHorizontal: i2, pages: n2 } = this;
let s2 = { min: 0, max: 0 };
if (t2)
s2 = { min: -1 / 0, max: 1 / 0 };
else if (n2.length) {
const t3 = n2[0].pos, o2 = n2[n2.length - 1].pos;
s2 = e2 && i2 ? { min: t3, max: o2 } : { min: -1 * o2, max: -1 * t3 };
}
return { x: i2 ? s2 : { min: 0, max: 0 }, y: i2 ? { min: 0, max: 0 } : s2 };
}
repositionSlides() {
let e2, { isHorizontal: i2, isRTL: n2, isInfinite: s2, viewport: o2, viewportDim: a2, contentDim: r2, page: l2, pages: c2, slides: h2, panzoom: d2 } = this, u2 = 0, p2 = 0, f2 = 0, g2 = 0;
d2 ? g2 = -1 * d2.current[this.axis] : c2[l2] && (g2 = c2[l2].pos || 0), e2 = i2 ? n2 ? "right" : "left" : "top", n2 && i2 && (g2 *= -1);
for (const i3 of h2) {
const n3 = i3.el;
n3 ? ("top" === e2 ? (n3.style.right = "", n3.style.left = "") : n3.style.top = "", i3.index !== u2 ? n3.style[e2] = 0 === p2 ? "" : `${t(p2, 1e3)}px` : n3.style[e2] = "", f2 += i3.dim + i3.gap, u2++) : p2 += i3.dim + i3.gap;
}
if (s2 && f2 && o2) {
let n3 = getComputedStyle(o2), s3 = "padding", l3 = i2 ? "Right" : "Bottom", c3 = parseFloat(n3[s3 + (i2 ? "Left" : "Top")]);
g2 -= c3, a2 += c3, a2 += parseFloat(n3[s3 + l3]);
for (const i3 of h2)
i3.el && (t(i3.pos) < t(a2) && t(i3.pos + i3.dim + i3.gap) < t(g2) && t(g2) > t(r2 - a2) && (i3.el.style[e2] = `${t(p2 + f2, 1e3)}px`), t(i3.pos + i3.gap) >= t(r2 - a2) && t(i3.pos) > t(g2 + a2) && t(g2) < t(a2) && (i3.el.style[e2] = `-${t(f2, 1e3)}px`));
}
let m2, v2, b2 = [...this.inTransition];
if (b2.length > 1 && (m2 = c2[b2[0]], v2 = c2[b2[1]]), m2 && v2) {
let i3 = 0;
for (const n3 of h2)
n3.el ? this.inTransition.has(n3.index) && m2.slides.indexOf(n3) < 0 && (n3.el.style[e2] = `${t(i3 + (m2.pos - v2.pos), 1e3)}px`) : i3 += n3.dim + n3.gap;
}
}
createSlideEl(t2) {
const { track: e2, slides: i2 } = this;
if (!e2 || !t2)
return;
if (t2.el && t2.el.parentNode)
return;
const n2 = t2.el || document.createElement("div");
P(n2, this.cn(J)), P(n2, t2.class), P(n2, t2.customClass);
const s2 = t2.html;
s2 && (s2 instanceof HTMLElement ? n2.appendChild(s2) : n2.innerHTML = t2.html + "");
const o2 = [];
i2.forEach((t3, e3) => {
t3.el && o2.push(e3);
});
const a2 = t2.index;
let r2 = null;
if (o2.length) {
r2 = i2[o2.reduce((t3, e3) => Math.abs(e3 - a2) < Math.abs(t3 - a2) ? e3 : t3)];
}
const l2 = r2 && r2.el && r2.el.parentNode ? r2.index < t2.index ? r2.el.nextSibling : r2.el : null;
e2.insertBefore(n2, e2.contains(l2) ? l2 : null), t2.el = n2, this.emit("createSlide", t2);
}
removeSlideEl(t2, e2 = false) {
const i2 = null == t2 ? void 0 : t2.el;
if (!i2 || !i2.parentNode)
return;
const n2 = this.cn(K);
if (i2.classList.contains(n2) && (S(i2, n2), this.emit("unselectSlide", t2)), t2.isDom && !e2)
return i2.removeAttribute("aria-hidden"), i2.removeAttribute("data-index"), void (i2.style.left = "");
this.emit("removeSlide", t2);
const s2 = new CustomEvent(G);
i2.dispatchEvent(s2), t2.el && (t2.el.remove(), t2.el = null);
}
transitionTo(t2 = 0, e2 = this.option("transition")) {
var i2, n2, s2, o2;
if (!e2)
return false;
const a2 = this.page, { pages: r2, panzoom: l2 } = this;
t2 = parseInt((t2 || 0).toString()) || 0;
const c2 = this.getPageFromIndex(t2);
if (!l2 || !r2[c2] || r2.length < 2 || Math.abs(((null === (n2 = null === (i2 = r2[a2]) || void 0 === i2 ? void 0 : i2.slides[0]) || void 0 === n2 ? void 0 : n2.dim) || 0) - this.viewportDim) > 1)
return false;
let h2 = t2 > a2 ? 1 : -1;
this.isInfinite && (0 === a2 && t2 === r2.length - 1 && (h2 = -1), a2 === r2.length - 1 && 0 === t2 && (h2 = 1));
const d2 = r2[c2].pos * (this.isRTL ? 1 : -1);
if (a2 === c2 && Math.abs(d2 - l2.target[this.axis]) < 1)
return false;
this.clearTransitions();
const u2 = l2.isResting;
P(this.container, this.cn("inTransition"));
const p2 = (null === (s2 = r2[a2]) || void 0 === s2 ? void 0 : s2.slides[0]) || null, f2 = (null === (o2 = r2[c2]) || void 0 === o2 ? void 0 : o2.slides[0]) || null;
this.inTransition.add(f2.index), this.createSlideEl(f2);
let g2 = p2.el, m2 = f2.el;
u2 || e2 === J || (e2 = "fadeFast", g2 = null);
const v2 = this.isRTL ? "next" : "prev", b2 = this.isRTL ? "prev" : "next";
return g2 && (this.inTransition.add(p2.index), p2.transition = e2, g2.addEventListener(G, this.onAnimationEnd), g2.classList.add(`f-${e2}Out`, `to-${h2 > 0 ? b2 : v2}`)), m2 && (f2.transition = e2, m2.addEventListener(G, this.onAnimationEnd), m2.classList.add(`f-${e2}In`, `from-${h2 > 0 ? v2 : b2}`)), l2.current[this.axis] = d2, l2.target[this.axis] = d2, l2.requestTick(), this.onChange(c2), true;
}
manageSlideVisiblity() {
const t2 = /* @__PURE__ */ new Set(), e2 = /* @__PURE__ */ new Set(), i2 = this.getVisibleSlides(parseFloat(this.option("preload", 0) + "") || 0);
for (const n2 of this.slides)
i2.has(n2) ? t2.add(n2) : e2.add(n2);
for (const e3 of this.inTransition)
t2.add(this.slides[e3]);
for (const e3 of t2)
this.createSlideEl(e3), this.lazyLoadSlide(e3);
for (const i3 of e2)
t2.has(i3) || this.removeSlideEl(i3);
this.markSelectedSlides(), this.repositionSlides();
}
markSelectedSlides() {
if (!this.pages[this.page] || !this.pages[this.page].slides)
return;
const t2 = "aria-hidden";
let e2 = this.cn(K);
if (e2)
for (const i2 of this.slides) {
const n2 = i2.el;
n2 && (n2.dataset.index = `${i2.index}`, n2.classList.contains("f-thumbs__slide") ? this.getVisibleSlides(0).has(i2) ? n2.removeAttribute(t2) : n2.setAttribute(t2, "true") : this.pages[this.page].slides.includes(i2) ? (n2.classList.contains(e2) || (P(n2, e2), this.emit("selectSlide", i2)), n2.removeAttribute(t2)) : (n2.classList.contains(e2) && (S(n2, e2), this.emit("unselectSlide", i2)), n2.setAttribute(t2, "true")));
}
}
flipInfiniteTrack() {
const { axis: t2, isHorizontal: e2, isInfinite: i2, isRTL: n2, viewportDim: s2, contentDim: o2 } = this, a2 = this.panzoom;
if (!a2 || !i2)
return;
let r2 = a2.current[t2], l2 = a2.target[t2] - r2, c2 = 0, h2 = 0.5 * s2;
n2 && e2 ? (r2 < -h2 && (c2 = -1, r2 += o2), r2 > o2 - h2 && (c2 = 1, r2 -= o2)) : (r2 > h2 && (c2 = 1, r2 -= o2), r2 < -o2 + h2 && (c2 = -1, r2 += o2)), c2 && (a2.current[t2] = r2, a2.target[t2] = r2 + l2);
}
lazyLoadImg(t2, e2) {
const i2 = this, s2 = "f-fadeIn", o2 = "is-preloading";
let a2 = false, r2 = null;
const l2 = () => {
a2 || (a2 = true, r2 && (r2.remove(), r2 = null), S(e2, o2), e2.complete && (P(e2, s2), setTimeout(() => {
S(e2, s2);
}, 350)), this.option("adaptiveHeight") && t2.el && this.pages[this.page].slides.indexOf(t2) > -1 && (i2.updateMetrics(), i2.setViewportHeight()), this.emit("load", t2));
};
P(e2, o2), e2.src = e2.dataset.lazySrcset || e2.dataset.lazySrc || "", delete e2.dataset.lazySrc, delete e2.dataset.lazySrcset, e2.addEventListener("error", () => {
l2();
}), e2.addEventListener("load", () => {
l2();
}), setTimeout(() => {
const i3 = e2.parentNode;
i3 && t2.el && (e2.complete ? l2() : a2 || (r2 = n(x), i3.insertBefore(r2, e2)));
}, 300);
}
lazyLoadSlide(t2) {
const e2 = t2 && t2.el;
if (!e2)
return;
const i2 = /* @__PURE__ */ new Set();
let n2 = Array.from(e2.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));
e2.dataset.lazySrc && n2.push(e2), n2.map((t3) => {
t3 instanceof HTMLImageElement ? i2.add(t3) : t3 instanceof HTMLElement && t3.dataset.lazySrc && (t3.style.backgroundImage = `url('${t3.dataset.lazySrc}')`, delete t3.dataset.lazySrc);
});
for (const e3 of i2)
this.lazyLoadImg(t2, e3);
}
onAnimationEnd(t2) {
var e2;
const i2 = t2.target, n2 = i2 ? parseInt(i2.dataset.index || "", 10) || 0 : -1, s2 = this.slides[n2], o2 = t2.animationName;
if (!i2 || !s2 || !o2)
return;
const a2 = !!this.inTransition.has(n2) && s2.transition;
a2 && o2.substring(0, a2.length + 2) === `f-${a2}` && this.inTransition.delete(n2), this.inTransition.size || this.clearTransitions(), n2 === this.page && (null === (e2 = this.panzoom) || void 0 === e2 ? void 0 : e2.isResting) && this.emit("settle");
}
onDecel(t2, e2 = 0, i2 = 0, n2 = 0, s2 = 0) {
if (this.option("dragFree"))
return void this.setPageFromPosition();
const { isRTL: o2, isHorizontal: a2, axis: r2, pages: l2 } = this, c2 = l2.length, h2 = Math.abs(Math.atan2(i2, e2) / (Math.PI / 180));
let d2 = 0;
if (d2 = h2 > 45 && h2 < 135 ? a2 ? 0 : i2 : a2 ? e2 : 0, !c2)
return;
let u2 = this.page, p2 = o2 && a2 ? 1 : -1;
const f2 = t2.current[r2] * p2;
let { pageIndex: g2 } = this.getPageFromPosition(f2);
Math.abs(d2) > 5 ? (l2[u2].dim < document.documentElement["client" + (this.isHorizontal ? "Width" : "Height")] - 1 && (u2 = g2), u2 = o2 && a2 ? d2 < 0 ? u2 - 1 : u2 + 1 : d2 < 0 ? u2 + 1 : u2 - 1) : u2 = 0 === n2 && 0 === s2 ? u2 : g2, this.slideTo(u2, { transition: false, friction: t2.option("decelFriction") });
}
onClick(t2) {
const e2 = t2.target, i2 = e2 && E(e2) ? e2.dataset : null;
let n2, s2;
i2 && (void 0 !== i2.carouselPage ? (s2 = "slideTo", n2 = i2.carouselPage) : void 0 !== i2.carouselNext ? s2 = "slideNext" : void 0 !== i2.carouselPrev && (s2 = "slidePrev")), s2 ? (t2.preventDefault(), t2.stopPropagation(), e2 && !e2.hasAttribute("disabled") && this[s2](n2)) : this.emit("click", t2);
}
onSlideTo(t2) {
const e2 = t2.detail || 0;
this.slideTo(this.getPageForSlide(e2), { friction: 0 });
}
onChange(t2, e2 = 0) {
const i2 = this.page;
this.prevPage = i2, this.page = t2, this.option("adaptiveHeight") && this.setViewportHeight(), t2 !== i2 && (this.markSelectedSlides(), this.emit("change", t2, i2, e2));
}
onRefresh() {
let t2 = this.contentDim, e2 = this.viewportDim;
this.updateMetrics(), this.contentDim === t2 && this.viewportDim === e2 || this.slideTo(this.page, { friction: 0, transition: false });
}
onScroll() {
var t2;
null === (t2 = this.viewport) || void 0 === t2 || t2.scroll(0, 0);
}
onResize() {
this.option("breakpoints") && this.processOptions();
}
onBeforeTransform(t2) {
this.lp !== t2.current[this.axis] && (this.flipInfiniteTrack(), this.manageSlideVisiblity()), this.lp = t2.current.e;
}
onEndAnimation() {
this.inTransition.size || this.emit("settle");
}
reInit(t2 = null, e2 = null) {
this.destroy(), this.state = B.Init, this.prevPage = null, this.userOptions = t2 || this.userOptions, this.userPlugins = e2 || this.userPlugins, this.processOptions();
}
slideTo(t2 = 0, { friction: e2 = this.option("friction"), transition: i2 = this.option("transition") } = {}) {
if (this.state === B.Destroy)
return;
t2 = parseInt((t2 || 0).toString()) || 0;
const n2 = this.getPageFromIndex(t2), { axis: s2, isHorizontal: o2, isRTL: a2, pages: r2, panzoom: l2 } = this, c2 = r2.length, h2 = a2 && o2 ? 1 : -1;
if (!l2 || !c2)
return;
if (this.page !== n2) {
const e3 = new Event("beforeChange", { bubbles: true, cancelable: true });
if (this.emit("beforeChange", e3, t2), e3.defaultPrevented)
return;
}
if (this.transitionTo(t2, i2))
return;
let d2 = r2[n2].pos;
if (this.isInfinite) {
const e3 = this.contentDim, i3 = l2.target[s2] * h2;
if (2 === c2)
d2 += e3 * Math.floor(parseFloat(t2 + "") / 2);
else {
d2 = [d2, d2 - e3, d2 + e3].reduce(function(t3, e4) {
return Math.abs(e4 - i3) < Math.abs(t3 - i3) ? e4 : t3;
});
}
}
d2 *= h2, Math.abs(l2.target[s2] - d2) < 1 || (l2.panTo({ x: o2 ? d2 : 0, y: o2 ? 0 : d2, friction: e2 }), this.onChange(n2));
}
slideToClosest(t2) {
if (this.panzoom) {
const { pageIndex: e2 } = this.getPageFromPosition();
this.slideTo(e2, t2);
}
}
slideNext() {
this.slideTo(this.page + 1);
}
slidePrev() {
this.slideTo(this.page - 1);
}
clearTransitions() {
this.inTransition.clear(), S(this.container, this.cn("inTransition"));
const t2 = ["to-prev", "to-next", "from-prev", "from-next"];
for (const e2 of this.slides) {
const i2 = e2.el;
if (i2) {
i2.removeEventListener(G, this.onAnimationEnd), i2.classList.remove(...t2);
const n2 = e2.transition;
n2 && i2.classList.remove(`f-${n2}Out`, `f-${n2}In`);
}
}
this.manageSlideVisiblity();
}
addSlide(t2, e2) {
var i2, n2, s2, o2;
const a2 = this.panzoom, r2 = (null === (i2 = this.pages[this.page]) || void 0 === i2 ? void 0 : i2.pos) || 0, l2 = (null === (n2 = this.pages[this.page]) || void 0 === n2 ? void 0 : n2.dim) || 0, c2 = this.contentDim < this.viewportDim;
let h2 = Array.isArray(e2) ? e2 : [e2];
const d2 = [];
for (const t3 of h2)
d2.push(H(t3));
this.slides.splice(t2, 0, ...d2);
for (let t3 = 0; t3 < this.slides.length; t3++)
this.slides[t3].index = t3;
for (const t3 of d2)
this.emit("beforeInitSlide", t3, t3.index);
if (this.page >= t2 && (this.page += d2.length), this.updateMetrics(), a2) {
const e3 = (null === (s2 = this.pages[this.page]) || void 0 === s2 ? void 0 : s2.pos) || 0, i3 = (null === (o2 = this.pages[this.page]) || void 0 === o2 ? void 0 : o2.dim) || 0, n3 = this.pages.length || 1, h3 = this.isRTL ? l2 - i3 : i3 - l2, d3 = this.isRTL ? r2 - e3 : e3 - r2;
c2 && 1 === n3 ? (t2 <= this.page && (a2.current[this.axis] -= h3, a2.target[this.axis] -= h3), a2.panTo({ [this.isHorizontal ? "x" : "y"]: -1 * e3 })) : d3 && t2 <= this.page && (a2.target[this.axis] -= d3, a2.current[this.axis] -= d3, a2.requestTick());
}
for (const t3 of d2)
this.emit("initSlide", t3, t3.index);
}
prependSlide(t2) {
this.addSlide(0, t2);
}
appendSlide(t2) {
this.addSlide(this.slides.length, t2);
}
removeSlide(t2) {
const e2 = this.slides.length;
t2 = (t2 % e2 + e2) % e2;
const i2 = this.slides[t2];
if (i2) {
this.removeSlideEl(i2, true), this.slides.splice(t2, 1);
for (let t3 = 0; t3 < this.slides.length; t3++)
this.slides[t3].index = t3;
this.updateMetrics(), this.slideTo(this.page, { friction: 0, transition: false }), this.emit("destroySlide", i2);
}
}
updateMetrics() {
const { panzoom: e2, viewport: i2, track: n2, slides: s2, isHorizontal: o2, isInfinite: a2 } = this;
if (!n2)
return;
const r2 = o2 ? "width" : "height", l2 = o2 ? "offsetWidth" : "offsetHeight";
if (i2) {
let e3 = Math.max(i2[l2], t(i2.getBoundingClientRect()[r2], 1e3)), n3 = getComputedStyle(i2), s3 = "padding", a3 = o2 ? "Right" : "Bottom";
e3 -= parseFloat(n3[s3 + (o2 ? "Left" : "Top")]) + parseFloat(n3[s3 + a3]), this.viewportDim = e3;
}
let c2, h2 = 0;
for (const [e3, i3] of s2.entries()) {
let n3 = 0, o3 = 0;
!i3.el && c2 ? (n3 = c2.dim, o3 = c2.gap) : ({ dim: n3, gap: o3 } = this.getSlideMetrics(i3), c2 = i3), n3 = t(n3, 1e3), o3 = t(o3, 1e3), i3.dim = n3, i3.gap = o3, i3.pos = h2, h2 += n3, (a2 || e3 < s2.length - 1) && (h2 += o3);
}
h2 = t(h2, 1e3), this.contentDim = h2, e2 && (e2.contentRect[r2] = h2, e2.contentRect[o2 ? "fullWidth" : "fullHeight"] = h2), this.pages = this.createPages(), this.pages = this.processPages(), this.state === B.Init && this.setInitialPage(), this.page = Math.max(0, Math.min(this.page, this.pages.length - 1)), this.manageSlideVisiblity(), this.emit("refresh");
}
getProgress(e2, i2 = false, n2 = false) {
void 0 === e2 && (e2 = this.page);
const s2 = this, o2 = s2.panzoom, a2 = s2.contentDim, r2 = s2.pages[e2] || 0;
if (!r2 || !o2)
return e2 > this.page ? -1 : 1;
let l2 = -1 * o2.current.e, c2 = t((l2 - r2.pos) / (1 * r2.dim), 1e3), h2 = c2, d2 = c2;
this.isInfinite && true !== n2 && (h2 = t((l2 - r2.pos + a2) / (1 * r2.dim), 1e3), d2 = t((l2 - r2.pos - a2) / (1 * r2.dim), 1e3));
let u2 = [c2, h2, d2].reduce(function(t2, e3) {
return Math.abs(e3) < Math.abs(t2) ? e3 : t2;
});
return i2 ? u2 : u2 > 1 ? 1 : u2 < -1 ? -1 : u2;
}
setViewportHeight() {
const { page: t2, pages: e2, viewport: i2, isHorizontal: n2 } = this;
if (!i2 || !e2[t2])
return;
let s2 = 0;
n2 && this.track && (this.track.style.height = "auto", e2[t2].slides.forEach((t3) => {
t3.el && (s2 = Math.max(s2, t3.el.offsetHeight));
})), i2.style.height = s2 ? `${s2}px` : "";
}
getPageForSlide(t2) {
for (const e2 of this.pages)
for (const i2 of e2.slides)
if (i2.index === t2)
return e2.index;
return -1;
}
getVisibleSlides(t2 = 0) {
var e2;
const i2 = /* @__PURE__ */ new Set();
let { panzoom: n2, contentDim: s2, viewportDim: o2, pages: a2, page: r2 } = this;
if (o2) {
s2 = s2 + (null === (e2 = this.slides[this.slides.length - 1]) || void 0 === e2 ? void 0 : e2.gap) || 0;
let l2 = 0;
l2 = n2 && n2.state !== m$2.Init && n2.state !== m$2.Destroy ? -1 * n2.current[this.axis] : a2[r2] && a2[r2].pos || 0, this.isInfinite && (l2 -= Math.floor(l2 / s2) * s2), this.isRTL && this.isHorizontal && (l2 *= -1);
const c2 = l2 - o2 * t2, h2 = l2 + o2 * (t2 + 1), d2 = this.isInfinite ? [-1, 0, 1] : [0];
for (const t3 of this.slides)
for (const e3 of d2) {
const n3 = t3.pos + e3 * s2, o3 = n3 + t3.dim + t3.gap;
n3 < h2 && o3 > c2 && i2.add(t3);
}
}
return i2;
}
getPageFromPosition(t2) {
const { viewportDim: e2, contentDim: i2, slides: n2, pages: s2, panzoom: o2 } = this, a2 = s2.length, r2 = n2.length, l2 = n2[0], c2 = n2[r2 - 1], h2 = this.option("center");
let d2 = 0, u2 = 0, p2 = 0, f2 = void 0 === t2 ? -1 * ((null == o2 ? void 0 : o2.target[this.axis]) || 0) : t2;
h2 && (f2 += 0.5 * e2), this.isInfinite ? (f2 < l2.pos - 0.5 * c2.gap && (f2 -= i2, p2 = -1), f2 > c2.pos + c2.dim + 0.5 * c2.gap && (f2 -= i2, p2 = 1)) : f2 = Math.max(l2.pos || 0, Math.min(f2, c2.pos));
let g2 = c2, m2 = n2.find((t3) => {
const e3 = t3.pos - 0.5 * g2.gap, i3 = t3.pos + t3.dim + 0.5 * t3.gap;
return g2 = t3, f2 >= e3 && f2 < i3;
});
return m2 || (m2 = c2), u2 = this.getPageForSlide(m2.index), d2 = u2 + p2 * a2, { page: d2, pageIndex: u2 };
}
setPageFromPosition() {
const { pageIndex: t2 } = this.getPageFromPosition();
this.onChange(t2);
}
destroy() {
if ([B.Destroy].includes(this.state))
return;
this.state = B.Destroy;
const { container: t2, viewport: e2, track: i2, slides: n2, panzoom: s2 } = this, o2 = this.option("classes");
t2.removeEventListener("click", this.onClick, { passive: false, capture: false }), t2.removeEventListener("slideTo", this.onSlideTo), window.removeEventListener("resize", this.onResize), s2 && (s2.destroy(), this.panzoom = null), n2 && n2.forEach((t3) => {
this.removeSlideEl(t3);
}), this.detachPlugins(), e2 && (e2.removeEventListener("scroll", this.onScroll), e2.offsetParent && i2 && i2.offsetParent && e2.replaceWith(...i2.childNodes));
for (const [e3, i3] of Object.entries(o2))
"container" !== e3 && i3 && t2.classList.remove(i3);
this.track = null, this.viewport = null, this.page = 0, this.slides = [];
const a2 = this.events.get("ready");
this.events = /* @__PURE__ */ new Map(), a2 && this.events.set("ready", a2);
}
}
Object.defineProperty(Q, "Panzoom", { enumerable: true, configurable: true, writable: true, value: I }), Object.defineProperty(Q, "defaults", { enumerable: true, configurable: true, writable: true, value: j }), Object.defineProperty(Q, "Plugins", { enumerable: true, configurable: true, writable: true, value: U });
const tt = function(t2) {
if (!E(t2))
return 0;
const e2 = window.scrollY, i2 = window.innerHeight, n2 = e2 + i2, s2 = t2.getBoundingClientRect(), o2 = s2.y + e2, a2 = s2.height, r2 = o2 + a2;
if (e2 > r2 || n2 < o2)
return 0;
if (e2 < o2 && n2 > r2)
return 100;
if (o2 < e2 && r2 > n2)
return 100;
let l2 = a2;
o2 < e2 && (l2 -= e2 - o2), r2 > n2 && (l2 -= r2 - n2);
const c2 = l2 / i2 * 100;
return Math.round(c2);
}, et = !("undefined" == typeof window || !window.document || !window.document.createElement);
let it;
const nt = ["a[href]", "area[href]", 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', "select:not([disabled]):not([aria-hidden])", "textarea:not([disabled]):not([aria-hidden])", "button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)", "iframe", "object", "embed", "video", "audio", "[contenteditable]", '[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","), st = (t2) => {
if (t2 && et) {
void 0 === it && document.createElement("div").focus({ get preventScroll() {
return it = true, false;
} });
try {
if (it)
t2.focus({ preventScroll: true });
else {
const e2 = window.scrollY || document.body.scrollTop, i2 = window.scrollX || document.body.scrollLeft;
t2.focus(), document.body.scrollTo({ top: e2, left: i2, behavior: "auto" });
}
} catch (t3) {
}
}
}, ot = () => {
const t2 = document;
let e2, i2 = "", n2 = "", s2 = "";
return t2.fullscreenEnabled ? (i2 = "requestFullscreen", n2 = "exitFullscreen", s2 = "fullscreenElement") : t2.webkitFullscreenEnabled && (i2 = "webkitRequestFullscreen", n2 = "webkitExitFullscreen", s2 = "webkitFullscreenElement"), i2 && (e2 = { request: function(e3 = t2.documentElement) {
return "webkitRequestFullscreen" === i2 ? e3[i2](Element.ALLOW_KEYBOARD_INPUT) : e3[i2]();
}, exit: function() {
return t2[s2] && t2[n2]();
}, isFullscreen: function() {
return t2[s2];
} }), e2;
}, at = { animated: true, autoFocus: true, backdropClick: "close", Carousel: { classes: { container: "fancybox__carousel", viewport: "fancybox__viewport", track: "fancybox__track", slide: "fancybox__slide" } }, closeButton: "auto", closeExisting: false, commonCaption: false, compact: () => window.matchMedia("(max-width: 578px), (max-height: 578px)").matches, contentClick: "toggleZoom", contentDblClick: false, defaultType: "image", defaultDisplay: "block", dragToClose: true, Fullscreen: { autoStart: false }, groupAll: false, groupAttr: "data-fancybox", hideClass: "f-fadeOut", hideScrollbar: true, idle: 3500, keyboard: { Escape: "close", Delete: "close", Backspace: "close", PageUp: "next", PageDown: "prev", ArrowUp: "prev", ArrowDown: "next", ArrowRight: "next", ArrowLeft: "prev" }, l10n: Object.assign(Object.assign({}, b), { CLOSE: "Close", NEXT: "Next", PREV: "Previous", MODAL: "You can close this modal content with the ESC key", ERROR: "Something Went Wrong, Please Try Again Later", IMAGE_ERROR: "Image Not Found", ELEMENT_NOT_FOUND: "HTML Element Not Found", AJAX_NOT_FOUND: "Error Loading AJAX : Not Found", AJAX_FORBIDDEN: "Error Loading AJAX : Forbidden", IFRAME_ERROR: "Error Loading Page", TOGGLE_ZOOM: "Toggle zoom level", TOGGLE_THUMBS: "Toggle thumbnails", TOGGLE_SLIDESHOW: "Toggle slideshow", TOGGLE_FULLSCREEN: "Toggle full-screen mode", DOWNLOAD: "Download" }), parentEl: null, placeFocusBack: true, showClass: "f-zoomInUp", startIndex: 0, tpl: { closeButton: '<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>', main: '<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">\n <div class="fancybox__backdrop"></div>\n <div class="fancybox__carousel"></div>\n <div class="fancybox__footer"></div>\n </div>' }, trapFocus: true, wheel: "zoom" };
var rt, lt;
!function(t2) {
t2[t2.Init = 0] = "Init", t2[t2.Ready = 1] = "Ready", t2[t2.Closing = 2] = "Closing", t2[t2.CustomClosing = 3] = "CustomClosing", t2[t2.Destroy = 4] = "Destroy";
}(rt || (rt = {})), function(t2) {
t2[t2.Loading = 0] = "Loading", t2[t2.Opening = 1] = "Opening", t2[t2.Ready = 2] = "Ready", t2[t2.Closing = 3] = "Closing";
}(lt || (lt = {}));
let ct = "", ht = false, dt = false, ut = null;
const pt = () => {
let t2 = "", e2 = "";
const i2 = Oe.getInstance();
if (i2) {
const n2 = i2.carousel, s2 = i2.getSlide();
if (n2 && s2) {
let o2 = s2.slug || void 0, a2 = s2.triggerEl || void 0;
e2 = o2 || (i2.option("slug") || ""), !e2 && a2 && a2.dataset && (e2 = a2.dataset.fancybox || ""), e2 && "true" !== e2 && (t2 = "#" + e2 + (!o2 && n2.slides.length > 1 ? "-" + (s2.index + 1) : ""));
}
}
return { hash: t2, slug: e2, index: 1 };
}, ft = () => {
const t2 = new URL(document.URL).hash, e2 = t2.slice(1).split("-"), i2 = e2[e2.length - 1], n2 = i2 && /^\+?\d+$/.test(i2) && parseInt(e2.pop() || "1", 10) || 1;
return { hash: t2, slug: e2.join("-"), index: n2 };
}, gt = () => {
const { slug: t2, index: e2 } = ft();
if (!t2)
return;
let i2 = document.querySelector(`[data-slug="${t2}"]`);
if (i2 && i2.dispatchEvent(new CustomEvent("click", { bubbles: true, cancelable: true })), Oe.getInstance())
return;
const n2 = document.querySelectorAll(`[data-fancybox="${t2}"]`);
n2.length && (i2 = n2[e2 - 1], i2 && i2.dispatchEvent(new CustomEvent("click", { bubbles: true, cancelable: true })));
}, mt = () => {
if (false === Oe.defaults.Hash)
return;
const t2 = Oe.getInstance();
if (false === (null == t2 ? void 0 : t2.options.Hash))
return;
const { slug: e2, index: i2 } = ft(), { slug: n2 } = pt();
t2 && (e2 === n2 ? t2.jumpTo(i2 - 1) : (ht = true, t2.close())), gt();
}, vt = () => {
ut && clearTimeout(ut), queueMicrotask(() => {
mt();
});
}, bt = () => {
window.addEventListener("hashchange", vt, false), setTimeout(() => {
mt();
}, 500);
};
et && (/complete|interactive|loaded/.test(document.readyState) ? bt() : document.addEventListener("DOMContentLoaded", bt));
const yt = "is-zooming-in";
class wt extends _ {
onCreateSlide(t2, e2, i2) {
const n2 = this.instance.optionFor(i2, "src") || "";
i2.el && "image" === i2.type && "string" == typeof n2 && this.setImage(i2, n2);
}
onRemoveSlide(t2, e2, i2) {
i2.panzoom && i2.panzoom.destroy(), i2.panzoom = void 0, i2.imageEl = void 0;
}
onChange(t2, e2, i2, n2) {
S(this.instance.container, yt);
for (const t3 of e2.slides) {
const e3 = t3.panzoom;
e3 && t3.index !== i2 && e3.reset(0.35);
}
}
onClose() {
var t2;
const e2 = this.instance, i2 = e2.container, n2 = e2.getSlide();
if (!i2 || !i2.parentElement || !n2)
return;
const { el: s2, contentEl: o2, panzoom: a2, thumbElSrc: r2 } = n2;
if (!s2 || !r2 || !o2 || !a2 || a2.isContentLoading || a2.state === m$2.Init || a2.state === m$2.Destroy)
return;
a2.updateMetrics();
let l2 = this.getZoomInfo(n2);
if (!l2)
return;
this.instance.state = rt.CustomClosing, i2.classList.remove(yt), i2.classList.add("is-zooming-out"), o2.style.backgroundImage = `url('${r2}')`;
const c2 = i2.getBoundingClientRect();
1 === ((null === (t2 = window.visualViewport) || void 0 === t2 ? void 0 : t2.scale) || 1) && Object.assign(i2.style, { position: "absolute", top: `${i2.offsetTop + window.scrollY}px`, left: `${i2.offsetLeft + window.scrollX}px`, bottom: "auto", right: "auto", width: `${c2.width}px`, height: `${c2.height}px`, overflow: "hidden" });
const { x: h2, y: d2, scale: u2, opacity: p2 } = l2;
if (p2) {
const t3 = ((t4, e3, i3, n3) => {
const s3 = e3 - t4, o3 = n3 - i3;
return (e4) => i3 + ((e4 - t4) / s3 * o3 || 0);
})(a2.scale, u2, 1, 0);
a2.on("afterTransform", () => {
o2.style.opacity = t3(a2.scale) + "";
});
}
a2.on("endAnimation", () => {
e2.destroy();
}), a2.target.a = u2, a2.target.b = 0, a2.target.c = 0, a2.target.d = u2, a2.panTo({ x: h2, y: d2, scale: u2, friction: p2 ? 0.2 : 0.33, ignoreBounds: true }), a2.isResting && e2.destroy();
}
setImage(t2, e2) {
const i2 = this.instance;
t2.src = e2, this.process(t2, e2).then((e3) => {
const { contentEl: n2, imageEl: s2, thumbElSrc: o2, el: a2 } = t2;
if (i2.isClosing() || !n2 || !s2)
return;
n2.offsetHeight;
const r2 = !!i2.isOpeningSlide(t2) && this.getZoomInfo(t2);
if (this.option("protected") && a2) {
a2.addEventListener("contextmenu", (t4) => {
t4.preventDefault();
});
const t3 = document.createElement("div");
P(t3, "fancybox-protected"), n2.appendChild(t3);
}
if (o2 && r2) {
const s3 = e3.contentRect, a3 = Math.max(s3.fullWidth, s3.fullHeight);
let c2 = null;
!r2.opacity && a3 > 1200 && (c2 = document.createElement("img"), P(c2, "fancybox-ghost"), c2.src = o2, n2.appendChild(c2));
const h2 = () => {
c2 && (P(c2, "f-fadeFastOut"), setTimeout(() => {
c2 && (c2.remove(), c2 = null);
}, 200));
};
(l2 = o2, new Promise((t3, e4) => {
const i3 = new Image();
i3.onload = t3, i3.onerror = e4, i3.src = l2;
})).then(() => {
i2.hideLoading(t2), t2.state = lt.Opening, this.instance.emit("reveal", t2), this.zoomIn(t2).then(() => {
h2(), this.instance.done(t2);
}, () => {
}), c2 && setTimeout(() => {
h2();
}, a3 > 2500 ? 800 : 200);
}, () => {
i2.hideLoading(t2), i2.revealContent(t2);
});
} else {
const n3 = this.optionFor(t2, "initialSize"), s3 = this.optionFor(t2, "zoom"), o3 = { event: i2.prevMouseMoveEvent || i2.options.event, friction: s3 ? 0.12 : 0 };
let a3 = i2.optionFor(t2, "showClass") || void 0, r3 = true;
i2.isOpeningSlide(t2) && ("full" === n3 ? e3.zoomToFull(o3) : "cover" === n3 ? e3.zoomToCover(o3) : "max" === n3 ? e3.zoomToMax(o3) : r3 = false, e3.stop("current")), r3 && a3 && (a3 = e3.isDragging ? "f-fadeIn" : ""), i2.hideLoading(t2), i2.revealContent(t2, a3);
}
var l2;
}, () => {
i2.setError(t2, "{{IMAGE_ERROR}}");
});
}
process(t2, e2) {
return new Promise((i2, s2) => {
var o2;
const a2 = this.instance, r2 = t2.el;
a2.clearContent(t2), a2.showLoading(t2);
let l2 = this.optionFor(t2, "content");
if ("string" == typeof l2 && (l2 = n(l2)), !l2 || !E(l2)) {
if (l2 = document.createElement("img"), l2 instanceof HTMLImageElement) {
let i3 = "", n2 = t2.caption;
i3 = "string" == typeof n2 && n2 ? n2.replace(/<[^>]+>/gi, "").substring(0, 1e3) : `Image ${t2.index + 1} of ${(null === (o2 = a2.carousel) || void 0 === o2 ? void 0 : o2.pages.length) || 1}`, l2.src = e2 || "", l2.alt = i3, l2.draggable = false, t2.srcset && l2.setAttribute("srcset", t2.srcset), this.instance.isOpeningSlide(t2) && (l2.fetchPriority = "high");
}
t2.sizes && l2.setAttribute("sizes", t2.sizes);
}
P(l2, "fancybox-image"), t2.imageEl = l2, a2.setContent(t2, l2, false);
t2.panzoom = new I(r2, u({ transformParent: true }, this.option("Panzoom") || {}, { content: l2, width: (e3, i3) => a2.optionFor(t2, "width", "auto", i3) || "auto", height: (e3, i3) => a2.optionFor(t2, "height", "auto", i3) || "auto", wheel: () => {
const t3 = a2.option("wheel");
return ("zoom" === t3 || "pan" == t3) && t3;
}, click: (e3, i3) => {
var n2, s3;
if (a2.isCompact || a2.isClosing())
return false;
if (t2.index !== (null === (n2 = a2.getSlide()) || void 0 === n2 ? void 0 : n2.index))
return false;
if (i3) {
const t3 = i3.composedPath()[0];
if (["A", "BUTTON", "TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO"].includes(t3.nodeName))
return false;
}
let o3 = !i3 || i3.target && (null === (s3 = t2.contentEl) || void 0 === s3 ? void 0 : s3.contains(i3.target));
return a2.option(o3 ? "contentClick" : "backdropClick") || false;
}, dblClick: () => a2.isCompact ? "toggleZoom" : a2.option("contentDblClick") || false, spinner: false, panOnlyZoomed: true, wheelLimit: 1 / 0, on: { ready: (t3) => {
i2(t3);
}, error: () => {
s2();
}, destroy: () => {
s2();
} } }));
});
}
zoomIn(t2) {
return new Promise((e2, i2) => {
const n2 = this.instance, s2 = n2.container, { panzoom: o2, contentEl: a2, el: r2 } = t2;
o2 && o2.updateMetrics();
const l2 = this.getZoomInfo(t2);
if (!(l2 && r2 && a2 && o2 && s2))
return void i2();
const { x: c2, y: h2, scale: d2, opacity: u2 } = l2, p2 = () => {
t2.state !== lt.Closing && (u2 && (a2.style.opacity = Math.max(Math.min(1, 1 - (1 - o2.scale) / (1 - d2)), 0) + ""), o2.scale >= 1 && o2.scale > o2.targetScale - 0.1 && e2(o2));
}, f2 = (t3) => {
(t3.scale < 0.99 || t3.scale > 1.01) && !t3.isDragging || (S(s2, yt), a2.style.opacity = "", t3.off("endAnimation", f2), t3.off("touchStart", f2), t3.off("afterTransform", p2), e2(t3));
};
o2.on("endAnimation", f2), o2.on("touchStart", f2), o2.on("afterTransform", p2), o2.on(["error", "destroy"], () => {
i2();
}), o2.panTo({ x: c2, y: h2, scale: d2, friction: 0, ignoreBounds: true }), o2.stop("current");
const g2 = { event: "mousemove" === o2.panMode ? n2.prevMouseMoveEvent || n2.options.event : void 0 }, m2 = this.optionFor(t2, "initialSize");
P(s2, yt), n2.hideLoading(t2), "full" === m2 ? o2.zoomToFull(g2) : "cover" === m2 ? o2.zoomToCover(g2) : "max" === m2 ? o2.zoomToMax(g2) : o2.reset(0.172);
});
}
getZoomInfo(t2) {
const { el: e2, imageEl: i2, thumbEl: n2, panzoom: s2 } = t2, o2 = this.instance, a2 = o2.container;
if (!e2 || !i2 || !n2 || !s2 || tt(n2) < 3 || !this.optionFor(t2, "zoom") || !a2 || o2.state === rt.Destroy)
return false;
if ("0" === getComputedStyle(a2).getPropertyValue("--f-images-zoom"))
return false;
const r2 = window.visualViewport || null;
if (1 !== (r2 ? r2.scale : 1))
return false;
let { top: l2, left: c2, width: h2, height: d2 } = n2.getBoundingClientRect(), { top: u2, left: p2, fitWidth: f2, fitHeight: g2 } = s2.contentRect;
if (!(h2 && d2 && f2 && g2))
return false;
const m2 = s2.container.getBoundingClientRect();
p2 += m2.left, u2 += m2.top;
const v2 = -1 * (p2 + 0.5 * f2 - (c2 + 0.5 * h2)), b2 = -1 * (u2 + 0.5 * g2 - (l2 + 0.5 * d2)), y2 = h2 / f2;
let w2 = this.option("zoomOpacity") || false;
return "auto" === w2 && (w2 = Math.abs(h2 / d2 - f2 / g2) > 0.1), { x: v2, y: b2, scale: y2, opacity: w2 };
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("Carousel.change", t2.onChange), e2.on("Carousel.createSlide", t2.onCreateSlide), e2.on("Carousel.removeSlide", t2.onRemoveSlide), e2.on("close", t2.onClose);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("Carousel.change", t2.onChange), e2.off("Carousel.createSlide", t2.onCreateSlide), e2.off("Carousel.removeSlide", t2.onRemoveSlide), e2.off("close", t2.onClose);
}
}
Object.defineProperty(wt, "defaults", { enumerable: true, configurable: true, writable: true, value: { initialSize: "fit", Panzoom: { maxScale: 1 }, protected: false, zoom: true, zoomOpacity: "auto" } }), "function" == typeof SuppressedError && SuppressedError;
const xt = "html", Et = "image", St = "map", Pt = "youtube", Ct = "vimeo", Tt = "html5video", Mt = (t2, e2 = {}) => {
const i2 = new URL(t2), n2 = new URLSearchParams(i2.search), s2 = new URLSearchParams();
for (const [t3, i3] of [...n2, ...Object.entries(e2)]) {
let e3 = i3 + "";
if ("t" === t3) {
let t4 = e3.match(/((\d*)m)?(\d*)s?/);
t4 && s2.set("start", 60 * parseInt(t4[2] || "0") + parseInt(t4[3] || "0") + "");
} else
s2.set(t3, e3);
}
let o2 = s2 + "", a2 = t2.match(/#t=((.*)?\d+s)/);
return a2 && (o2 += `#t=${a2[1]}`), o2;
}, Ot = { ajax: null, autoSize: true, iframeAttr: { allow: "autoplay; fullscreen", scrolling: "auto" }, preload: true, videoAutoplay: true, videoRatio: 16 / 9, videoTpl: `<video class="fancybox__html5video" playsinline controls controlsList="nodownload" poster="{{poster}}">
<source src="{{src}}" type="{{format}}" />Sorry, your browser doesn't support embedded videos.</video>`, videoFormat: "", vimeo: { byline: 1, color: "00adef", controls: 1, dnt: 1, muted: 0 }, youtube: { controls: 1, enablejsapi: 1, nocookie: 1, rel: 0, fs: 1 } }, At = ["image", "html", "ajax", "inline", "clone", "iframe", "map", "pdf", "html5video", "youtube", "vimeo"];
class Lt extends _ {
onBeforeInitSlide(t2, e2, i2) {
this.processType(i2);
}
onCreateSlide(t2, e2, i2) {
this.setContent(i2);
}
onClearContent(t2, e2) {
e2.xhr && (e2.xhr.abort(), e2.xhr = null);
const i2 = e2.iframeEl;
i2 && (i2.onload = i2.onerror = null, i2.src = "//about:blank", e2.iframeEl = null);
const n2 = e2.contentEl, s2 = e2.placeholderEl;
if ("inline" === e2.type && n2 && s2)
n2.classList.remove("fancybox__content"), "none" !== n2.style.display && (n2.style.display = "none"), s2.parentNode && s2.parentNode.insertBefore(n2, s2), s2.remove(), e2.contentEl = void 0, e2.placeholderEl = void 0;
else
for (; e2.el && e2.el.firstChild; )
e2.el.removeChild(e2.el.firstChild);
}
onSelectSlide(t2, e2, i2) {
i2.state === lt.Ready && this.playVideo();
}
onUnselectSlide(t2, e2, i2) {
var n2, s2;
if (i2.type === Tt) {
try {
null === (s2 = null === (n2 = i2.el) || void 0 === n2 ? void 0 : n2.querySelector("video")) || void 0 === s2 || s2.pause();
} catch (t3) {
}
return;
}
let o2;
i2.type === Ct ? o2 = { method: "pause", value: "true" } : i2.type === Pt && (o2 = { event: "command", func: "pauseVideo" }), o2 && i2.iframeEl && i2.iframeEl.contentWindow && i2.iframeEl.contentWindow.postMessage(JSON.stringify(o2), "*"), i2.poller && clearTimeout(i2.poller);
}
onDone(t2, e2) {
t2.isCurrentSlide(e2) && !t2.isClosing() && this.playVideo();
}
onRefresh(t2, e2) {
e2.slides.forEach((t3) => {
t3.el && (this.resizeIframe(t3), this.setAspectRatio(t3));
});
}
onMessage(t2) {
try {
let e2 = JSON.parse(t2.data);
if ("https://player.vimeo.com" === t2.origin) {
if ("ready" === e2.event)
for (let e3 of Array.from(document.getElementsByClassName("fancybox__iframe")))
e3 instanceof HTMLIFrameElement && e3.contentWindow === t2.source && (e3.dataset.ready = "true");
} else if (t2.origin.match(/^https:\/\/(www.)?youtube(-nocookie)?.com$/) && "onReady" === e2.event) {
const t3 = document.getElementById(e2.id);
t3 && (t3.dataset.ready = "true");
}
} catch (t3) {
}
}
loadAjaxContent(t2) {
const e2 = this.instance.optionFor(t2, "src") || "";
this.instance.showLoading(t2);
const i2 = this.instance, n2 = new XMLHttpRequest();
i2.showLoading(t2), n2.onreadystatechange = function() {
n2.readyState === XMLHttpRequest.DONE && i2.state === rt.Ready && (i2.hideLoading(t2), 200 === n2.status ? i2.setContent(t2, n2.responseText) : i2.setError(t2, 404 === n2.status ? "{{AJAX_NOT_FOUND}}" : "{{AJAX_FORBIDDEN}}"));
};
const s2 = t2.ajax || null;
n2.open(s2 ? "POST" : "GET", e2 + ""), n2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"), n2.setRequestHeader("X-Requested-With", "XMLHttpRequest"), n2.send(s2), t2.xhr = n2;
}
setInlineContent(t2) {
let e2 = null;
if (E(t2.src))
e2 = t2.src;
else if ("string" == typeof t2.src) {
const i2 = t2.src.split("#", 2).pop();
e2 = i2 ? document.getElementById(i2) : null;
}
if (e2) {
if ("clone" === t2.type || e2.closest(".fancybox__slide")) {
e2 = e2.cloneNode(true);
const i2 = e2.dataset.animationName;
i2 && (e2.classList.remove(i2), delete e2.dataset.animationName);
let n2 = e2.getAttribute("id");
n2 = n2 ? `${n2}--clone` : `clone-${this.instance.id}-${t2.index}`, e2.setAttribute("id", n2);
} else if (e2.parentNode) {
const i2 = document.createElement("div");
i2.classList.add("fancybox-placeholder"), e2.parentNode.insertBefore(i2, e2), t2.placeholderEl = i2;
}
this.instance.setContent(t2, e2);
} else
this.instance.setError(t2, "{{ELEMENT_NOT_FOUND}}");
}
setIframeContent(t2) {
const { src: e2, el: i2 } = t2;
if (!e2 || "string" != typeof e2 || !i2)
return;
i2.classList.add("is-loading");
const n2 = this.instance, s2 = document.createElement("iframe");
s2.className = "fancybox__iframe", s2.setAttribute("id", `fancybox__iframe_${n2.id}_${t2.index}`);
for (const [e3, i3] of Object.entries(this.optionFor(t2, "iframeAttr") || {}))
s2.setAttribute(e3, i3);
s2.onerror = () => {
n2.setError(t2, "{{IFRAME_ERROR}}");
}, t2.iframeEl = s2;
const o2 = this.optionFor(t2, "preload");
if ("iframe" !== t2.type || false === o2)
return s2.setAttribute("src", t2.src + ""), n2.setContent(t2, s2, false), this.resizeIframe(t2), void n2.revealContent(t2);
n2.showLoading(t2), s2.onload = () => {
if (!s2.src.length)
return;
const e3 = "true" !== s2.dataset.ready;
s2.dataset.ready = "true", this.resizeIframe(t2), e3 ? n2.revealContent(t2) : n2.hideLoading(t2);
}, s2.setAttribute("src", e2), n2.setContent(t2, s2, false);
}
resizeIframe(t2) {
const { type: e2, iframeEl: i2 } = t2;
if (e2 === Pt || e2 === Ct)
return;
const n2 = null == i2 ? void 0 : i2.parentElement;
if (!i2 || !n2)
return;
let s2 = t2.autoSize;
void 0 === s2 && (s2 = this.optionFor(t2, "autoSize"));
let o2 = t2.width || 0, a2 = t2.height || 0;
o2 && a2 && (s2 = false);
const r2 = n2 && n2.style;
if (false !== t2.preload && false !== s2 && r2)
try {
const t3 = window.getComputedStyle(n2), e3 = parseFloat(t3.paddingLeft) + parseFloat(t3.paddingRight), s3 = parseFloat(t3.paddingTop) + parseFloat(t3.paddingBottom), l2 = i2.contentWindow;
if (l2) {
const t4 = l2.document, i3 = t4.getElementsByTagName(xt)[0], n3 = t4.body;
r2.width = "", n3.style.overflow = "hidden", o2 = o2 || i3.scrollWidth + e3, r2.width = `${o2}px`, n3.style.overflow = "", r2.flex = "0 0 auto", r2.height = `${n3.scrollHeight}px`, a2 = i3.scrollHeight + s3;
}
} catch (t3) {
}
if (o2 || a2) {
const t3 = { flex: "0 1 auto", width: "", height: "" };
o2 && "auto" !== o2 && (t3.width = `${o2}px`), a2 && "auto" !== a2 && (t3.height = `${a2}px`), Object.assign(r2, t3);
}
}
playVideo() {
const t2 = this.instance.getSlide();
if (!t2)
return;
const { el: e2 } = t2;
if (!e2 || !e2.offsetParent)
return;
if (!this.optionFor(t2, "videoAutoplay"))
return;
if (t2.type === Tt)
try {
const t3 = e2.querySelector("video");
if (t3) {
const e3 = t3.play();
void 0 !== e3 && e3.then(() => {
}).catch((e4) => {
t3.muted = true, t3.play();
});
}
} catch (t3) {
}
if (t2.type !== Pt && t2.type !== Ct)
return;
const i2 = () => {
if (t2.iframeEl && t2.iframeEl.contentWindow) {
let e3;
if ("true" === t2.iframeEl.dataset.ready)
return e3 = t2.type === Pt ? { event: "command", func: "playVideo" } : { method: "play", value: "true" }, e3 && t2.iframeEl.contentWindow.postMessage(JSON.stringify(e3), "*"), void (t2.poller = void 0);
t2.type === Pt && (e3 = { event: "listening", id: t2.iframeEl.getAttribute("id") }, t2.iframeEl.contentWindow.postMessage(JSON.stringify(e3), "*"));
}
t2.poller = setTimeout(i2, 250);
};
i2();
}
processType(t2) {
if (t2.html)
return t2.type = xt, t2.src = t2.html, void (t2.html = "");
const e2 = this.instance.optionFor(t2, "src", "");
if (!e2 || "string" != typeof e2)
return;
let i2 = t2.type, n2 = null;
if (n2 = e2.match(/(youtube\.com|youtu\.be|youtube\-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/|shorts\/|embed\/?)?(videoseries\?list=(?:.*)|[\w-]{11}|\?listType=(?:.*)&list=(?:.*))(?:.*)/i)) {
const s2 = this.optionFor(t2, Pt), { nocookie: o2 } = s2, a2 = function(t3, e3) {
var i3 = {};
for (var n3 in t3)
Object.prototype.hasOwnProperty.call(t3, n3) && e3.indexOf(n3) < 0 && (i3[n3] = t3[n3]);
if (null != t3 && "function" == typeof Object.getOwnPropertySymbols) {
var s3 = 0;
for (n3 = Object.getOwnPropertySymbols(t3); s3 < n3.length; s3++)
e3.indexOf(n3[s3]) < 0 && Object.prototype.propertyIsEnumerable.call(t3, n3[s3]) && (i3[n3[s3]] = t3[n3[s3]]);
}
return i3;
}(s2, ["nocookie"]), r2 = `www.youtube${o2 ? "-nocookie" : ""}.com`, l2 = Mt(e2, a2), c2 = encodeURIComponent(n2[2]);
t2.videoId = c2, t2.src = `https://${r2}/embed/${c2}?${l2}`, t2.thumbSrc = t2.thumbSrc || `https://i.ytimg.com/vi/${c2}/mqdefault.jpg`, i2 = Pt;
} else if (n2 = e2.match(/^.+vimeo.com\/(?:\/)?([\d]+)((\/|\?h=)([a-z0-9]+))?(.*)?/)) {
const s2 = Mt(e2, this.optionFor(t2, Ct)), o2 = encodeURIComponent(n2[1]), a2 = n2[4] || "";
t2.videoId = o2, t2.src = `https://player.vimeo.com/video/${o2}?${a2 ? `h=${a2}${s2 ? "&" : ""}` : ""}${s2}`, i2 = Ct;
}
if (!i2 && t2.triggerEl) {
const e3 = t2.triggerEl.dataset.type;
At.includes(e3) && (i2 = e3);
}
i2 || "string" == typeof e2 && ("#" === e2.charAt(0) ? i2 = "inline" : (n2 = e2.match(/\.(mp4|mov|ogv|webm)((\?|#).*)?$/i)) ? (i2 = Tt, t2.videoFormat = t2.videoFormat || "video/" + ("ogv" === n2[1] ? "ogg" : n2[1])) : e2.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i) ? i2 = Et : e2.match(/\.(pdf)((\?|#).*)?$/i) && (i2 = "pdf")), (n2 = e2.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:(?:(?:maps\/(?:place\/(?:.*)\/)?\@(.*),(\d+.?\d+?)z))|(?:\?ll=))(.*)?/i)) ? (t2.src = `https://maps.google.${n2[1]}/?ll=${(n2[2] ? n2[2] + "&z=" + Math.floor(parseFloat(n2[3])) + (n2[4] ? n2[4].replace(/^\//, "&") : "") : n2[4] + "").replace(/\?/, "&")}&output=${n2[4] && n2[4].indexOf("layer=c") > 0 ? "svembed" : "embed"}`, i2 = St) : (n2 = e2.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/search\/)(.*)/i)) && (t2.src = `https://maps.google.${n2[1]}/maps?q=${n2[2].replace("query=", "q=").replace("api=1", "")}&output=embed`, i2 = St), i2 = i2 || this.instance.option("defaultType"), t2.type = i2, i2 === Et && (t2.thumbSrc = t2.thumbSrc || t2.src);
}
setContent(t2) {
const e2 = this.instance.optionFor(t2, "src") || "";
if (t2 && t2.type && e2) {
switch (t2.type) {
case xt:
this.instance.setContent(t2, e2);
break;
case Tt:
const i2 = this.option("videoTpl");
i2 && this.instance.setContent(t2, i2.replace(/\{\{src\}\}/gi, e2 + "").replace(/\{\{format\}\}/gi, this.optionFor(t2, "videoFormat") || "").replace(/\{\{poster\}\}/gi, t2.poster || t2.thumbSrc || ""));
break;
case "inline":
case "clone":
this.setInlineContent(t2);
break;
case "ajax":
this.loadAjaxContent(t2);
break;
case "pdf":
case St:
case Pt:
case Ct:
t2.preload = false;
case "iframe":
this.setIframeContent(t2);
}
this.setAspectRatio(t2);
}
}
setAspectRatio(t2) {
const e2 = t2.contentEl;
if (!(t2.el && e2 && t2.type && [Pt, Ct, Tt].includes(t2.type)))
return;
let i2, n2 = t2.width || "auto", s2 = t2.height || "auto";
if ("auto" === n2 || "auto" === s2) {
i2 = this.optionFor(t2, "videoRatio");
const e3 = (i2 + "").match(/(\d+)\s*\/\s?(\d+)/);
i2 = e3 && e3.length > 2 ? parseFloat(e3[1]) / parseFloat(e3[2]) : parseFloat(i2 + "");
} else
n2 && s2 && (i2 = n2 / s2);
if (!i2)
return;
e2.style.aspectRatio = "", e2.style.width = "", e2.style.height = "", e2.offsetHeight;
const o2 = e2.getBoundingClientRect(), a2 = o2.width || 1, r2 = o2.height || 1;
e2.style.aspectRatio = i2 + "", i2 < a2 / r2 ? (s2 = "auto" === s2 ? r2 : Math.min(r2, s2), e2.style.width = "auto", e2.style.height = `${s2}px`) : (n2 = "auto" === n2 ? a2 : Math.min(a2, n2), e2.style.width = `${n2}px`, e2.style.height = "auto");
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("Carousel.beforeInitSlide", t2.onBeforeInitSlide), e2.on("Carousel.createSlide", t2.onCreateSlide), e2.on("Carousel.selectSlide", t2.onSelectSlide), e2.on("Carousel.unselectSlide", t2.onUnselectSlide), e2.on("Carousel.Panzoom.refresh", t2.onRefresh), e2.on("done", t2.onDone), e2.on("clearContent", t2.onClearContent), window.addEventListener("message", t2.onMessage);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("Carousel.beforeInitSlide", t2.onBeforeInitSlide), e2.off("Carousel.createSlide", t2.onCreateSlide), e2.off("Carousel.selectSlide", t2.onSelectSlide), e2.off("Carousel.unselectSlide", t2.onUnselectSlide), e2.off("Carousel.Panzoom.refresh", t2.onRefresh), e2.off("done", t2.onDone), e2.off("clearContent", t2.onClearContent), window.removeEventListener("message", t2.onMessage);
}
}
Object.defineProperty(Lt, "defaults", { enumerable: true, configurable: true, writable: true, value: Ot });
const zt = "play", Rt = "pause", kt = "ready";
class It extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: kt }), Object.defineProperty(this, "inHover", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "timer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "progressBar", { enumerable: true, configurable: true, writable: true, value: null });
}
get isActive() {
return this.state !== kt;
}
onReady(t2) {
this.option("autoStart") && (t2.isInfinite || t2.page < t2.pages.length - 1) && this.start();
}
onChange() {
this.removeProgressBar(), this.pause();
}
onSettle() {
this.resume();
}
onVisibilityChange() {
"visible" === document.visibilityState ? this.resume() : this.pause();
}
onMouseEnter() {
this.inHover = true, this.pause();
}
onMouseLeave() {
var t2;
this.inHover = false, (null === (t2 = this.instance.panzoom) || void 0 === t2 ? void 0 : t2.isResting) && this.resume();
}
onTimerEnd() {
const t2 = this.instance;
"play" === this.state && (t2.isInfinite || t2.page !== t2.pages.length - 1 ? t2.slideNext() : t2.slideTo(0));
}
removeProgressBar() {
this.progressBar && (this.progressBar.remove(), this.progressBar = null);
}
createProgressBar() {
var t2;
if (!this.option("showProgress"))
return null;
this.removeProgressBar();
const e2 = this.instance, i2 = (null === (t2 = e2.pages[e2.page]) || void 0 === t2 ? void 0 : t2.slides) || [];
let n2 = this.option("progressParentEl");
if (n2 || (n2 = (1 === i2.length ? i2[0].el : null) || e2.viewport), !n2)
return null;
const s2 = document.createElement("div");
return P(s2, "f-progress"), n2.prepend(s2), this.progressBar = s2, s2.offsetHeight, s2;
}
set() {
const t2 = this, e2 = t2.instance;
if (e2.pages.length < 2)
return;
if (t2.timer)
return;
const i2 = t2.option("timeout");
t2.state = zt, P(e2.container, "has-autoplay");
let n2 = t2.createProgressBar();
n2 && (n2.style.transitionDuration = `${i2}ms`, n2.style.transform = "scaleX(1)"), t2.timer = setTimeout(() => {
t2.timer = null, t2.inHover || t2.onTimerEnd();
}, i2), t2.emit("set");
}
clear() {
const t2 = this;
t2.timer && (clearTimeout(t2.timer), t2.timer = null), t2.removeProgressBar();
}
start() {
const t2 = this;
if (t2.set(), t2.state !== kt) {
if (t2.option("pauseOnHover")) {
const e2 = t2.instance.container;
e2.addEventListener("mouseenter", t2.onMouseEnter, false), e2.addEventListener("mouseleave", t2.onMouseLeave, false);
}
document.addEventListener("visibilitychange", t2.onVisibilityChange, false), t2.emit("start");
}
}
stop() {
const t2 = this, e2 = t2.state, i2 = t2.instance.container;
t2.clear(), t2.state = kt, i2.removeEventListener("mouseenter", t2.onMouseEnter, false), i2.removeEventListener("mouseleave", t2.onMouseLeave, false), document.removeEventListener("visibilitychange", t2.onVisibilityChange, false), S(i2, "has-autoplay"), e2 !== kt && t2.emit("stop");
}
pause() {
const t2 = this;
t2.state === zt && (t2.state = Rt, t2.clear(), t2.emit(Rt));
}
resume() {
const t2 = this, e2 = t2.instance;
if (e2.isInfinite || e2.page !== e2.pages.length - 1)
if (t2.state !== zt) {
if (t2.state === Rt && !t2.inHover) {
const e3 = new Event("resume", { bubbles: true, cancelable: true });
t2.emit("resume", e3), e3.defaultPrevented || t2.set();
}
} else
t2.set();
else
t2.stop();
}
toggle() {
this.state === zt || this.state === Rt ? this.stop() : this.start();
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("ready", t2.onReady), e2.on("Panzoom.startAnimation", t2.onChange), e2.on("Panzoom.endAnimation", t2.onSettle), e2.on("Panzoom.touchMove", t2.onChange);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("ready", t2.onReady), e2.off("Panzoom.startAnimation", t2.onChange), e2.off("Panzoom.endAnimation", t2.onSettle), e2.off("Panzoom.touchMove", t2.onChange), t2.stop();
}
}
Object.defineProperty(It, "defaults", { enumerable: true, configurable: true, writable: true, value: { autoStart: true, pauseOnHover: true, progressParentEl: null, showProgress: true, timeout: 3e3 } });
class Dt extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "ref", { enumerable: true, configurable: true, writable: true, value: null });
}
onPrepare(t2) {
const e2 = t2.carousel;
if (!e2)
return;
const i2 = t2.container;
i2 && (e2.options.Autoplay = u({ autoStart: false }, this.option("Autoplay") || {}, { pauseOnHover: false, timeout: this.option("timeout"), progressParentEl: () => this.option("progressParentEl") || null, on: { start: () => {
t2.emit("startSlideshow");
}, set: (e3) => {
var n2;
i2.classList.add("has-slideshow"), (null === (n2 = t2.getSlide()) || void 0 === n2 ? void 0 : n2.state) !== lt.Ready && e3.pause();
}, stop: () => {
i2.classList.remove("has-slideshow"), t2.isCompact || t2.endIdle(), t2.emit("endSlideshow");
}, resume: (e3, i3) => {
var n2, s2, o2;
!i3 || !i3.cancelable || (null === (n2 = t2.getSlide()) || void 0 === n2 ? void 0 : n2.state) === lt.Ready && (null === (o2 = null === (s2 = t2.carousel) || void 0 === s2 ? void 0 : s2.panzoom) || void 0 === o2 ? void 0 : o2.isResting) || i3.preventDefault();
} } }), e2.attachPlugins({ Autoplay: It }), this.ref = e2.plugins.Autoplay);
}
onReady(t2) {
const e2 = t2.carousel, i2 = this.ref;
i2 && e2 && this.option("playOnStart") && (e2.isInfinite || e2.page < e2.pages.length - 1) && i2.start();
}
onDone(t2, e2) {
const i2 = this.ref, n2 = t2.carousel;
if (!i2 || !n2)
return;
const s2 = e2.panzoom;
s2 && s2.on("startAnimation", () => {
t2.isCurrentSlide(e2) && i2.stop();
}), t2.isCurrentSlide(e2) && i2.resume();
}
onKeydown(t2, e2) {
var i2;
const n2 = this.ref;
n2 && e2 === this.option("key") && "BUTTON" !== (null === (i2 = document.activeElement) || void 0 === i2 ? void 0 : i2.nodeName) && n2.toggle();
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("Carousel.init", t2.onPrepare), e2.on("Carousel.ready", t2.onReady), e2.on("done", t2.onDone), e2.on("keydown", t2.onKeydown);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("Carousel.init", t2.onPrepare), e2.off("Carousel.ready", t2.onReady), e2.off("done", t2.onDone), e2.off("keydown", t2.onKeydown);
}
}
Object.defineProperty(Dt, "defaults", { enumerable: true, configurable: true, writable: true, value: { key: " ", playOnStart: false, progressParentEl: (t2) => {
var e2;
return (null === (e2 = t2.instance.container) || void 0 === e2 ? void 0 : e2.querySelector(".fancybox__toolbar [data-fancybox-toggle-slideshow]")) || t2.instance.container;
}, timeout: 3e3 } });
const Ft = { classes: { container: "f-thumbs f-carousel__thumbs", viewport: "f-thumbs__viewport", track: "f-thumbs__track", slide: "f-thumbs__slide", isResting: "is-resting", isSelected: "is-selected", isLoading: "is-loading", hasThumbs: "has-thumbs" }, minCount: 2, parentEl: null, thumbTpl: '<button class="f-thumbs__slide__button" tabindex="0" type="button" aria-label="{{GOTO}}" data-carousel-index="%i"><img class="f-thumbs__slide__img" data-lazy-src="{{%s}}" alt="" /></button>', type: "modern" };
var jt;
!function(t2) {
t2[t2.Init = 0] = "Init", t2[t2.Ready = 1] = "Ready", t2[t2.Hidden = 2] = "Hidden";
}(jt || (jt = {}));
const Bt = "isResting", Ht = "thumbWidth", Nt = "thumbHeight", _t = "thumbClipWidth";
let $t = class extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "type", { enumerable: true, configurable: true, writable: true, value: "modern" }), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "track", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "carousel", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "thumbWidth", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "thumbClipWidth", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "thumbHeight", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "thumbGap", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "thumbExtraGap", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: jt.Init });
}
get isModern() {
return "modern" === this.type;
}
onInitSlide(t2, e2) {
const i2 = e2.el ? e2.el.dataset : void 0;
i2 && (e2.thumbSrc = i2.thumbSrc || e2.thumbSrc || "", e2[_t] = parseFloat(i2[_t] || "") || e2[_t] || 0, e2[Nt] = parseFloat(i2.thumbHeight || "") || e2[Nt] || 0), this.addSlide(e2);
}
onInitSlides() {
this.build();
}
onChange() {
var t2;
if (!this.isModern)
return;
const e2 = this.container, i2 = this.instance, n2 = i2.panzoom, s2 = this.carousel, a2 = s2 ? s2.panzoom : null, r2 = i2.page;
if (n2 && s2 && a2) {
if (n2.isDragging) {
S(e2, this.cn(Bt));
let n3 = (null === (t2 = s2.pages[r2]) || void 0 === t2 ? void 0 : t2.pos) || 0;
n3 += i2.getProgress(r2) * (this[_t] + this.thumbGap);
let o2 = a2.getBounds();
-1 * n3 > o2.x.min && -1 * n3 < o2.x.max && a2.panTo({ x: -1 * n3, friction: 0.12 });
} else
o(e2, this.cn(Bt), n2.isResting);
this.shiftModern();
}
}
onRefresh() {
this.updateProps();
for (const t2 of this.instance.slides || [])
this.resizeModernSlide(t2);
this.shiftModern();
}
isDisabled() {
const t2 = this.option("minCount") || 0;
if (t2) {
const e3 = this.instance;
let i2 = 0;
for (const t3 of e3.slides || [])
t3.thumbSrc && i2++;
if (i2 < t2)
return true;
}
const e2 = this.option("type");
return ["modern", "classic"].indexOf(e2) < 0;
}
getThumb(t2) {
const e2 = this.option("thumbTpl") || "";
return { html: this.instance.localize(e2, [["%i", t2.index], ["%d", t2.index + 1], ["%s", t2.thumbSrc || "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]]) };
}
addSlide(t2) {
const e2 = this.carousel;
e2 && e2.addSlide(t2.index, this.getThumb(t2));
}
getSlides() {
const t2 = [];
for (const e2 of this.instance.slides || [])
t2.push(this.getThumb(e2));
return t2;
}
resizeModernSlide(t2) {
this.isModern && (t2[Ht] = t2[_t] && t2[Nt] ? Math.round(this[Nt] * (t2[_t] / t2[Nt])) : this[Ht]);
}
updateProps() {
const t2 = this.container;
if (!t2)
return;
const e2 = (e3) => parseFloat(getComputedStyle(t2).getPropertyValue("--f-thumb-" + e3)) || 0;
this.thumbGap = e2("gap"), this.thumbExtraGap = e2("extra-gap"), this[Ht] = e2("width") || 40, this[_t] = e2("clip-width") || 40, this[Nt] = e2("height") || 40;
}
build() {
const t2 = this;
if (t2.state !== jt.Init)
return;
if (t2.isDisabled())
return void t2.emit("disabled");
const e2 = t2.instance, i2 = e2.container, n2 = t2.getSlides(), s2 = t2.option("type");
t2.type = s2;
const o2 = t2.option("parentEl"), a2 = t2.cn("container"), r2 = t2.cn("track");
let l2 = null == o2 ? void 0 : o2.querySelector("." + a2);
l2 || (l2 = document.createElement("div"), P(l2, a2), o2 ? o2.appendChild(l2) : i2.after(l2)), P(l2, `is-${s2}`), P(i2, t2.cn("hasThumbs")), t2.container = l2, t2.updateProps();
let c2 = l2.querySelector("." + r2);
c2 || (c2 = document.createElement("div"), P(c2, t2.cn("track")), l2.appendChild(c2)), t2.track = c2;
const h2 = u({}, { track: c2, infinite: false, center: true, fill: "classic" === s2, dragFree: true, slidesPerPage: 1, transition: false, preload: 0.25, friction: 0.12, Panzoom: { maxVelocity: 0 }, Dots: false, Navigation: false, classes: { container: "f-thumbs", viewport: "f-thumbs__viewport", track: "f-thumbs__track", slide: "f-thumbs__slide" } }, t2.option("Carousel") || {}, { Sync: { target: e2 }, slides: n2 }), d2 = new e2.constructor(l2, h2);
d2.on("createSlide", (e3, i3) => {
t2.setProps(i3.index), t2.emit("createSlide", i3, i3.el);
}), d2.on("ready", () => {
t2.shiftModern(), t2.emit("ready");
}), d2.on("refresh", () => {
t2.shiftModern();
}), d2.on("Panzoom.click", (e3, i3, n3) => {
t2.onClick(n3);
}), t2.carousel = d2, t2.state = jt.Ready;
}
onClick(t2) {
t2.preventDefault(), t2.stopPropagation();
const e2 = this.instance, { pages: i2, page: n2 } = e2, s2 = (t3) => {
if (t3) {
const e3 = t3.closest("[data-carousel-index]");
if (e3)
return [parseInt(e3.dataset.carouselIndex || "", 10) || 0, e3];
}
return [-1, void 0];
}, o2 = (t3, e3) => {
const i3 = document.elementFromPoint(t3, e3);
return i3 ? s2(i3) : [-1, void 0];
};
let [a2, r2] = s2(t2.target);
if (a2 > -1)
return;
const l2 = this[_t], c2 = t2.clientX, h2 = t2.clientY;
let [d2, u2] = o2(c2 - l2, h2), [p2, f2] = o2(c2 + l2, h2);
u2 && f2 ? (a2 = Math.abs(c2 - u2.getBoundingClientRect().right) < Math.abs(c2 - f2.getBoundingClientRect().left) ? d2 : p2, a2 === n2 && (a2 = a2 === d2 ? p2 : d2)) : u2 ? a2 = d2 : f2 && (a2 = p2), a2 > -1 && i2[a2] && e2.slideTo(a2);
}
getShift(t2) {
var e2;
const i2 = this, { instance: n2 } = i2, s2 = i2.carousel;
if (!n2 || !s2)
return 0;
const o2 = i2[Ht], a2 = i2[_t], r2 = i2.thumbGap, l2 = i2.thumbExtraGap;
if (!(null === (e2 = s2.slides[t2]) || void 0 === e2 ? void 0 : e2.el))
return 0;
const c2 = 0.5 * (o2 - a2), h2 = n2.pages.length - 1;
let d2 = n2.getProgress(0), u2 = n2.getProgress(h2), p2 = n2.getProgress(t2, false, true), f2 = 0, g2 = c2 + l2 + r2;
const m2 = d2 < 0 && d2 > -1, v2 = u2 > 0 && u2 < 1;
return 0 === t2 ? (f2 = g2 * Math.abs(d2), v2 && 1 === d2 && (f2 -= g2 * Math.abs(u2))) : t2 === h2 ? (f2 = g2 * Math.abs(u2) * -1, m2 && -1 === u2 && (f2 += g2 * Math.abs(d2))) : m2 || v2 ? (f2 = -1 * g2, f2 += g2 * Math.abs(d2), f2 += g2 * (1 - Math.abs(u2))) : f2 = g2 * p2, f2;
}
setProps(e2) {
var i2;
const n2 = this;
if (!n2.isModern)
return;
const { instance: s2 } = n2, o2 = n2.carousel;
if (s2 && o2) {
const a2 = null === (i2 = o2.slides[e2]) || void 0 === i2 ? void 0 : i2.el;
if (a2 && a2.childNodes.length) {
let i3 = t(1 - Math.abs(s2.getProgress(e2))), o3 = t(n2.getShift(e2));
a2.style.setProperty("--progress", i3 ? i3 + "" : ""), a2.style.setProperty("--shift", o3 + "");
}
}
}
shiftModern() {
const t2 = this;
if (!t2.isModern)
return;
const { instance: e2, track: i2 } = t2, n2 = e2.panzoom, s2 = t2.carousel;
if (!(e2 && i2 && n2 && s2))
return;
if (n2.state === m$2.Init || n2.state === m$2.Destroy)
return;
for (const i3 of e2.slides)
t2.setProps(i3.index);
let o2 = (t2[_t] + t2.thumbGap) * (s2.slides.length || 0);
i2.style.setProperty("--width", o2 + "");
}
cleanup() {
const t2 = this;
t2.carousel && t2.carousel.destroy(), t2.carousel = null, t2.container && t2.container.remove(), t2.container = null, t2.track && t2.track.remove(), t2.track = null, t2.state = jt.Init, S(t2.instance.container, t2.cn("hasThumbs"));
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("initSlide", t2.onInitSlide), e2.state === B.Init ? e2.on("initSlides", t2.onInitSlides) : t2.onInitSlides(), e2.on(["change", "Panzoom.afterTransform"], t2.onChange), e2.on("Panzoom.refresh", t2.onRefresh);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("initSlide", t2.onInitSlide), e2.off("initSlides", t2.onInitSlides), e2.off(["change", "Panzoom.afterTransform"], t2.onChange), e2.off("Panzoom.refresh", t2.onRefresh), t2.cleanup();
}
};
Object.defineProperty($t, "defaults", { enumerable: true, configurable: true, writable: true, value: Ft });
const Wt = Object.assign(Object.assign({}, Ft), { key: "t", showOnStart: true, parentEl: null }), Xt = "is-masked", qt = "aria-hidden";
class Yt extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "ref", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "hidden", { enumerable: true, configurable: true, writable: true, value: false });
}
get isEnabled() {
const t2 = this.ref;
return t2 && !t2.isDisabled();
}
get isHidden() {
return this.hidden;
}
onClick(t2, e2) {
e2.stopPropagation();
}
onCreateSlide(t2, e2) {
var i2, n2, s2;
const o2 = (null === (s2 = null === (n2 = null === (i2 = this.instance) || void 0 === i2 ? void 0 : i2.carousel) || void 0 === n2 ? void 0 : n2.slides[e2.index]) || void 0 === s2 ? void 0 : s2.type) || "", a2 = e2.el;
if (a2 && o2) {
let t3 = `for-${o2}`;
["video", "youtube", "vimeo", "html5video"].includes(o2) && (t3 += " for-video"), P(a2, t3);
}
}
onInit() {
var t2;
const e2 = this, i2 = e2.instance, n2 = i2.carousel;
if (e2.ref || !n2)
return;
const s2 = e2.option("parentEl") || i2.footer || i2.container;
if (!s2)
return;
const o2 = u({}, e2.options, { parentEl: s2, classes: { container: "f-thumbs fancybox__thumbs" }, Carousel: { Sync: { friction: i2.option("Carousel.friction") || 0 } }, on: { ready: (t3) => {
const i3 = t3.container;
i3 && this.hidden && (e2.refresh(), i3.style.transition = "none", e2.hide(), i3.offsetHeight, queueMicrotask(() => {
i3.style.transition = "", e2.show();
}));
} } });
o2.Carousel = o2.Carousel || {}, o2.Carousel.on = u((null === (t2 = e2.options.Carousel) || void 0 === t2 ? void 0 : t2.on) || {}, { click: this.onClick, createSlide: this.onCreateSlide }), n2.options.Thumbs = o2, n2.attachPlugins({ Thumbs: $t }), e2.ref = n2.plugins.Thumbs, e2.option("showOnStart") || (e2.ref.state = jt.Hidden, e2.hidden = true);
}
onResize() {
var t2;
const e2 = null === (t2 = this.ref) || void 0 === t2 ? void 0 : t2.container;
e2 && (e2.style.maxHeight = "");
}
onKeydown(t2, e2) {
const i2 = this.option("key");
i2 && i2 === e2 && this.toggle();
}
toggle() {
const t2 = this.ref;
if (t2 && !t2.isDisabled())
return t2.state === jt.Hidden ? (t2.state = jt.Init, void t2.build()) : void (this.hidden ? this.show() : this.hide());
}
show() {
const t2 = this.ref;
if (!t2 || t2.isDisabled())
return;
const e2 = t2.container;
e2 && (this.refresh(), e2.offsetHeight, e2.removeAttribute(qt), e2.classList.remove(Xt), this.hidden = false);
}
hide() {
const t2 = this.ref, e2 = t2 && t2.container;
e2 && (this.refresh(), e2.offsetHeight, e2.classList.add(Xt), e2.setAttribute(qt, "true")), this.hidden = true;
}
refresh() {
const t2 = this.ref;
if (!t2 || !t2.state)
return;
const e2 = t2.container, i2 = (null == e2 ? void 0 : e2.firstChild) || null;
e2 && i2 && i2.childNodes.length && (e2.style.maxHeight = `${i2.getBoundingClientRect().height}px`);
}
attach() {
const t2 = this, e2 = t2.instance;
e2.state === rt.Init ? e2.on("Carousel.init", t2.onInit) : t2.onInit(), e2.on("resize", t2.onResize), e2.on("keydown", t2.onKeydown);
}
detach() {
var t2;
const e2 = this, i2 = e2.instance;
i2.off("Carousel.init", e2.onInit), i2.off("resize", e2.onResize), i2.off("keydown", e2.onKeydown), null === (t2 = i2.carousel) || void 0 === t2 || t2.detachPlugins(["Thumbs"]), e2.ref = null;
}
}
Object.defineProperty(Yt, "defaults", { enumerable: true, configurable: true, writable: true, value: Wt });
const Vt = { panLeft: { icon: '<svg><path d="M5 12h14M5 12l6 6M5 12l6-6"/></svg>', change: { panX: -100 } }, panRight: { icon: '<svg><path d="M5 12h14M13 18l6-6M13 6l6 6"/></svg>', change: { panX: 100 } }, panUp: { icon: '<svg><path d="M12 5v14M18 11l-6-6M6 11l6-6"/></svg>', change: { panY: -100 } }, panDown: { icon: '<svg><path d="M12 5v14M18 13l-6 6M6 13l6 6"/></svg>', change: { panY: 100 } }, zoomIn: { icon: '<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M11 8v6M8 11h6"/></svg>', action: "zoomIn" }, zoomOut: { icon: '<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>', action: "zoomOut" }, toggle1to1: { icon: '<svg><path d="M3.51 3.07c5.74.02 11.48-.02 17.22.02 1.37.1 2.34 1.64 2.18 3.13 0 4.08.02 8.16 0 12.23-.1 1.54-1.47 2.64-2.79 2.46-5.61-.01-11.24.02-16.86-.01-1.36-.12-2.33-1.65-2.17-3.14 0-4.07-.02-8.16 0-12.23.1-1.36 1.22-2.48 2.42-2.46Z"/><path d="M5.65 8.54h1.49v6.92m8.94-6.92h1.49v6.92M11.5 9.4v.02m0 5.18v0"/></svg>', action: "toggleZoom" }, toggleZoom: { icon: '<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>', action: "toggleZoom" }, iterateZoom: { icon: '<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>', action: "iterateZoom" }, rotateCCW: { icon: '<svg><path d="M15 4.55a8 8 0 0 0-6 14.9M9 15v5H4M18.37 7.16v.01M13 19.94v.01M16.84 18.37v.01M19.37 15.1v.01M19.94 11v.01"/></svg>', action: "rotateCCW" }, rotateCW: { icon: '<svg><path d="M9 4.55a8 8 0 0 1 6 14.9M15 15v5h5M5.63 7.16v.01M4.06 11v.01M4.63 15.1v.01M7.16 18.37v.01M11 19.94v.01"/></svg>', action: "rotateCW" }, flipX: { icon: '<svg style="stroke-width: 1.3"><path d="M12 3v18M16 7v10h5L16 7M8 7v10H3L8 7"/></svg>', action: "flipX" }, flipY: { icon: '<svg style="stroke-width: 1.3"><path d="M3 12h18M7 16h10L7 21v-5M7 8h10L7 3v5"/></svg>', action: "flipY" }, fitX: { icon: '<svg><path d="M4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v6M10 18H3M21 18h-7M6 15l-3 3 3 3M18 15l3 3-3 3"/></svg>', action: "fitX" }, fitY: { icon: '<svg><path d="M12 20H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h6M18 14v7M18 3v7M15 18l3 3 3-3M15 6l3-3 3 3"/></svg>', action: "fitY" }, reset: { icon: '<svg><path d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg>', action: "reset" }, toggleFS: { icon: '<svg><g><path d="M14.5 9.5 21 3m0 0h-6m6 0v6M3 21l6.5-6.5M3 21v-6m0 6h6"/></g><g><path d="m14 10 7-7m-7 7h6m-6 0V4M3 21l7-7m0 0v6m0-6H4"/></g></svg>', action: "toggleFS" } };
var Zt;
!function(t2) {
t2[t2.Init = 0] = "Init", t2[t2.Ready = 1] = "Ready", t2[t2.Disabled = 2] = "Disabled";
}(Zt || (Zt = {}));
const Ut = { absolute: "auto", display: { left: ["infobar"], middle: [], right: ["iterateZoom", "slideshow", "fullscreen", "thumbs", "close"] }, enabled: "auto", items: { infobar: { tpl: '<div class="fancybox__infobar" tabindex="-1"><span data-fancybox-current-index></span>/<span data-fancybox-count></span></div>' }, download: { tpl: '<a class="f-button" title="{{DOWNLOAD}}" data-fancybox-download href="javasript:;"><svg><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2M7 11l5 5 5-5M12 4v12"/></svg></a>' }, prev: { tpl: '<button class="f-button" title="{{PREV}}" data-fancybox-prev><svg><path d="m15 6-6 6 6 6"/></svg></button>' }, next: { tpl: '<button class="f-button" title="{{NEXT}}" data-fancybox-next><svg><path d="m9 6 6 6-6 6"/></svg></button>' }, slideshow: { tpl: '<button class="f-button" title="{{TOGGLE_SLIDESHOW}}" data-fancybox-toggle-slideshow><svg><g><path d="M8 4v16l13 -8z"></path></g><g><path d="M8 4v15M17 4v15"/></g></svg></button>' }, fullscreen: { tpl: '<button class="f-button" title="{{TOGGLE_FULLSCREEN}}" data-fancybox-toggle-fullscreen><svg><g><path d="M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2M16 4h2a2 2 0 0 1 2 2v2M16 20h2a2 2 0 0 0 2-2v-2"/></g><g><path d="M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5"/></g></svg></button>' }, thumbs: { tpl: '<button class="f-button" title="{{TOGGLE_THUMBS}}" data-fancybox-toggle-thumbs><svg><circle cx="5.5" cy="5.5" r="1"/><circle cx="12" cy="5.5" r="1"/><circle cx="18.5" cy="5.5" r="1"/><circle cx="5.5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18.5" cy="12" r="1"/><circle cx="5.5" cy="18.5" r="1"/><circle cx="12" cy="18.5" r="1"/><circle cx="18.5" cy="18.5" r="1"/></svg></button>' }, close: { tpl: '<button class="f-button" title="{{CLOSE}}" data-fancybox-close><svg><path d="m19.5 4.5-15 15M4.5 4.5l15 15"/></svg></button>' } }, parentEl: null }, Gt = { tabindex: "-1", width: "24", height: "24", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, Kt = "has-toolbar", Jt = "fancybox__toolbar";
class Qt extends _ {
constructor() {
super(...arguments), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: Zt.Init }), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: null });
}
onReady(t2) {
var e2;
if (!t2.carousel)
return;
let i2 = this.option("display"), n2 = this.option("absolute"), s2 = this.option("enabled");
if ("auto" === s2) {
const t3 = this.instance.carousel;
let e3 = 0;
if (t3)
for (const i3 of t3.slides)
(i3.panzoom || "image" === i3.type) && e3++;
e3 || (s2 = false);
}
s2 || (i2 = void 0);
let o2 = 0;
const a2 = { left: [], middle: [], right: [] };
if (i2)
for (const t3 of ["left", "middle", "right"])
for (const n3 of i2[t3]) {
const i3 = this.createEl(n3);
i3 && (null === (e2 = a2[t3]) || void 0 === e2 || e2.push(i3), o2++);
}
let r2 = null;
if (o2 && (r2 = this.createContainer()), r2) {
for (const [t3, e3] of Object.entries(a2)) {
const i3 = document.createElement("div");
P(i3, Jt + "__column is-" + t3);
for (const t4 of e3)
i3.appendChild(t4);
"auto" !== n2 || "middle" !== t3 || e3.length || (n2 = true), r2.appendChild(i3);
}
true === n2 && P(r2, "is-absolute"), this.state = Zt.Ready, this.onRefresh();
} else
this.state = Zt.Disabled;
}
onClick(t2) {
var e2, i2;
const n2 = this.instance, s2 = n2.getSlide(), o2 = null == s2 ? void 0 : s2.panzoom, a2 = t2.target, r2 = a2 && E(a2) ? a2.dataset : null;
if (!r2)
return;
if (void 0 !== r2.fancyboxToggleThumbs)
return t2.preventDefault(), t2.stopPropagation(), void (null === (e2 = n2.plugins.Thumbs) || void 0 === e2 || e2.toggle());
if (void 0 !== r2.fancyboxToggleFullscreen)
return t2.preventDefault(), t2.stopPropagation(), void this.instance.toggleFullscreen();
if (void 0 !== r2.fancyboxToggleSlideshow) {
t2.preventDefault(), t2.stopPropagation();
const e3 = null === (i2 = n2.carousel) || void 0 === i2 ? void 0 : i2.plugins.Autoplay;
let s3 = e3.isActive;
return o2 && "mousemove" === o2.panMode && !s3 && o2.reset(), void (s3 ? e3.stop() : e3.start());
}
const l2 = r2.panzoomAction, c2 = r2.panzoomChange;
if ((c2 || l2) && (t2.preventDefault(), t2.stopPropagation()), c2) {
let t3 = {};
try {
t3 = JSON.parse(c2);
} catch (t4) {
}
o2 && o2.applyChange(t3);
} else
l2 && o2 && o2[l2] && o2[l2]();
}
onChange() {
this.onRefresh();
}
onRefresh() {
if (this.instance.isClosing())
return;
const t2 = this.container;
if (!t2)
return;
const e2 = this.instance.getSlide();
if (!e2 || e2.state !== lt.Ready)
return;
const i2 = e2 && !e2.error && e2.panzoom;
for (const e3 of t2.querySelectorAll("[data-panzoom-action]"))
i2 ? (e3.removeAttribute("disabled"), e3.removeAttribute("tabindex")) : (e3.setAttribute("disabled", ""), e3.setAttribute("tabindex", "-1"));
let n2 = i2 && i2.canZoomIn(), s2 = i2 && i2.canZoomOut();
for (const e3 of t2.querySelectorAll('[data-panzoom-action="zoomIn"]'))
n2 ? (e3.removeAttribute("disabled"), e3.removeAttribute("tabindex")) : (e3.setAttribute("disabled", ""), e3.setAttribute("tabindex", "-1"));
for (const e3 of t2.querySelectorAll('[data-panzoom-action="zoomOut"]'))
s2 ? (e3.removeAttribute("disabled"), e3.removeAttribute("tabindex")) : (e3.setAttribute("disabled", ""), e3.setAttribute("tabindex", "-1"));
for (const e3 of t2.querySelectorAll('[data-panzoom-action="toggleZoom"],[data-panzoom-action="iterateZoom"]')) {
s2 || n2 ? (e3.removeAttribute("disabled"), e3.removeAttribute("tabindex")) : (e3.setAttribute("disabled", ""), e3.setAttribute("tabindex", "-1"));
const t3 = e3.querySelector("g");
t3 && (t3.style.display = n2 ? "" : "none");
}
}
onDone(t2, e2) {
var i2;
null === (i2 = e2.panzoom) || void 0 === i2 || i2.on("afterTransform", () => {
this.instance.isCurrentSlide(e2) && this.onRefresh();
}), this.instance.isCurrentSlide(e2) && this.onRefresh();
}
createContainer() {
const t2 = this.instance.container;
if (!t2)
return null;
const e2 = this.option("parentEl") || t2;
let i2 = e2.querySelector("." + Jt);
return i2 || (i2 = document.createElement("div"), P(i2, Jt), e2.prepend(i2)), i2.addEventListener("click", this.onClick, { passive: false, capture: true }), t2 && P(t2, Kt), this.container = i2, i2;
}
createEl(t2) {
const e2 = this.instance, i2 = e2.carousel;
if (!i2)
return null;
if ("toggleFS" === t2)
return null;
if ("fullscreen" === t2 && !ot())
return null;
let s2 = null;
const o2 = i2.slides.length || 0;
let a2 = 0, r2 = 0;
for (const t3 of i2.slides)
(t3.panzoom || "image" === t3.type) && a2++, ("image" === t3.type || t3.downloadSrc) && r2++;
if (o2 < 2 && ["infobar", "prev", "next"].includes(t2))
return s2;
if (void 0 !== Vt[t2] && !a2)
return null;
if ("download" === t2 && !r2)
return null;
if ("thumbs" === t2) {
const t3 = e2.plugins.Thumbs;
if (!t3 || !t3.isEnabled)
return null;
}
if ("slideshow" === t2) {
if (!i2.plugins.Autoplay || o2 < 2)
return null;
}
if (void 0 !== Vt[t2]) {
const e3 = Vt[t2];
s2 = document.createElement("button"), s2.setAttribute("title", this.instance.localize(`{{${t2.toUpperCase()}}}`)), P(s2, "f-button"), e3.action && (s2.dataset.panzoomAction = e3.action), e3.change && (s2.dataset.panzoomChange = JSON.stringify(e3.change)), s2.appendChild(n(this.instance.localize(e3.icon)));
} else {
const e3 = (this.option("items") || [])[t2];
e3 && (s2 = n(this.instance.localize(e3.tpl)), "function" == typeof e3.click && s2.addEventListener("click", (t3) => {
t3.preventDefault(), t3.stopPropagation(), "function" == typeof e3.click && e3.click.call(this, this, t3);
}));
}
const l2 = null == s2 ? void 0 : s2.querySelector("svg");
if (l2)
for (const [t3, e3] of Object.entries(Gt))
l2.getAttribute(t3) || l2.setAttribute(t3, String(e3));
return s2;
}
removeContainer() {
const t2 = this.container;
t2 && t2.remove(), this.container = null, this.state = Zt.Disabled;
const e2 = this.instance.container;
e2 && S(e2, Kt);
}
attach() {
const t2 = this, e2 = t2.instance;
e2.on("Carousel.initSlides", t2.onReady), e2.on("done", t2.onDone), e2.on(["reveal", "Carousel.change"], t2.onChange), t2.onReady(t2.instance);
}
detach() {
const t2 = this, e2 = t2.instance;
e2.off("Carousel.initSlides", t2.onReady), e2.off("done", t2.onDone), e2.off(["reveal", "Carousel.change"], t2.onChange), t2.removeContainer();
}
}
Object.defineProperty(Qt, "defaults", { enumerable: true, configurable: true, writable: true, value: Ut });
const te = { Hash: class extends _ {
onReady() {
ht = false;
}
onChange(t2) {
ut && clearTimeout(ut);
const { hash: e2 } = pt(), { hash: i2 } = ft(), n2 = t2.isOpeningSlide(t2.getSlide());
n2 && (ct = i2 === e2 ? "" : i2), e2 && e2 !== i2 && (ut = setTimeout(() => {
try {
if (t2.state === rt.Ready) {
let t3 = "replaceState";
n2 && !dt && (t3 = "pushState", dt = true), window.history[t3]({}, document.title, window.location.pathname + window.location.search + e2);
}
} catch (t3) {
}
}, 300));
}
onClose(t2) {
if (ut && clearTimeout(ut), !ht && dt)
return dt = false, ht = false, void window.history.back();
if (!ht)
try {
window.history.replaceState({}, document.title, window.location.pathname + window.location.search + (ct || ""));
} catch (t3) {
}
}
attach() {
const t2 = this.instance;
t2.on("ready", this.onReady), t2.on(["Carousel.ready", "Carousel.change"], this.onChange), t2.on("close", this.onClose);
}
detach() {
const t2 = this.instance;
t2.off("ready", this.onReady), t2.off(["Carousel.ready", "Carousel.change"], this.onChange), t2.off("close", this.onClose);
}
static parseURL() {
return ft();
}
static startFromUrl() {
gt();
}
static destroy() {
window.removeEventListener("hashchange", vt, false);
}
}, Html: Lt, Images: wt, Slideshow: Dt, Thumbs: Yt, Toolbar: Qt }, ee = "with-fancybox", ie = "hide-scrollbar", ne = "--fancybox-scrollbar-compensate", se = "--fancybox-body-margin", oe = "aria-hidden", ae = "is-using-tab", re = "is-animated", le = "is-compact", ce = "is-loading", he = "is-opening", de = "has-caption", ue = "disabled", pe = "tabindex", fe = "download", ge = "href", me = "src", ve = (t2) => "string" == typeof t2, be = function() {
var t2 = window.getSelection();
return !!t2 && "Range" === t2.type;
};
let ye, we = null, xe = null, Ee = 0, Se = 0, Pe = 0, Ce = 0;
const Te = /* @__PURE__ */ new Map();
let Me = 0;
class Oe extends g {
get isIdle() {
return this.idle;
}
get isCompact() {
return this.option("compact");
}
constructor(t2 = [], e2 = {}, i2 = {}) {
super(e2), Object.defineProperty(this, "userSlides", { enumerable: true, configurable: true, writable: true, value: [] }), Object.defineProperty(this, "userPlugins", { enumerable: true, configurable: true, writable: true, value: {} }), Object.defineProperty(this, "idle", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "idleTimer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "clickTimer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "pwt", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "ignoreFocusChange", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "startedFs", { enumerable: true, configurable: true, writable: true, value: false }), Object.defineProperty(this, "state", { enumerable: true, configurable: true, writable: true, value: rt.Init }), Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: 0 }), Object.defineProperty(this, "container", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "caption", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "footer", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "carousel", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "lastFocus", { enumerable: true, configurable: true, writable: true, value: null }), Object.defineProperty(this, "prevMouseMoveEvent", { enumerable: true, configurable: true, writable: true, value: void 0 }), ye || (ye = ot()), this.id = e2.id || ++Me, Te.set(this.id, this), this.userSlides = t2, this.userPlugins = i2, queueMicrotask(() => {
this.init();
});
}
init() {
if (this.state === rt.Destroy)
return;
this.state = rt.Init, this.attachPlugins(Object.assign(Object.assign({}, Oe.Plugins), this.userPlugins)), this.emit("init"), this.emit("attachPlugins"), true === this.option("hideScrollbar") && (() => {
if (!et)
return;
const t3 = document, e2 = t3.body, i2 = t3.documentElement;
if (e2.classList.contains(ie))
return;
let n2 = window.innerWidth - i2.getBoundingClientRect().width;
const s2 = parseFloat(window.getComputedStyle(e2).marginRight);
n2 < 0 && (n2 = 0), i2.style.setProperty(ne, `${n2}px`), s2 && e2.style.setProperty(se, `${s2}px`), e2.classList.add(ie);
})(), this.initLayout(), this.scale();
const t2 = () => {
this.initCarousel(this.userSlides), this.state = rt.Ready, this.attachEvents(), this.emit("ready"), setTimeout(() => {
this.container && this.container.setAttribute(oe, "false");
}, 16);
};
this.option("Fullscreen.autoStart") && ye && !ye.isFullscreen() ? ye.request().then(() => {
this.startedFs = true, t2();
}).catch(() => t2()) : t2();
}
initLayout() {
var t2, e2;
const i2 = this.option("parentEl") || document.body, s2 = n(this.localize(this.option("tpl.main") || ""));
if (s2) {
if (s2.setAttribute("id", `fancybox-${this.id}`), s2.setAttribute("aria-label", this.localize("{{MODAL}}")), s2.classList.toggle(le, this.isCompact), P(s2, this.option("mainClass") || ""), P(s2, he), this.container = s2, this.footer = s2.querySelector(".fancybox__footer"), i2.appendChild(s2), P(document.documentElement, ee), we && xe || (we = document.createElement("span"), P(we, "fancybox-focus-guard"), we.setAttribute(pe, "0"), we.setAttribute(oe, "true"), we.setAttribute("aria-label", "Focus guard"), xe = we.cloneNode(), null === (t2 = s2.parentElement) || void 0 === t2 || t2.insertBefore(we, s2), null === (e2 = s2.parentElement) || void 0 === e2 || e2.append(xe)), s2.addEventListener("mousedown", (t3) => {
Ee = t3.pageX, Se = t3.pageY, S(s2, ae);
}), this.option("closeExisting"))
for (const t3 of Te.values())
t3.id !== this.id && t3.close();
else
this.option("animated") && (P(s2, re), setTimeout(() => {
this.isClosing() || S(s2, re);
}, 350));
this.emit("initLayout");
}
}
initCarousel(t2) {
const i2 = this.container;
if (!i2)
return;
const n2 = i2.querySelector(".fancybox__carousel");
if (!n2)
return;
const s2 = this.carousel = new Q(n2, u({}, { slides: t2, transition: "fade", Panzoom: { lockAxis: this.option("dragToClose") ? "xy" : "x", infinite: !!this.option("dragToClose") && "y" }, Dots: false, Navigation: { classes: { container: "fancybox__nav", button: "f-button", isNext: "is-next", isPrev: "is-prev" } }, initialPage: this.option("startIndex"), l10n: this.option("l10n") }, this.option("Carousel") || {}));
s2.on("*", (t3, e2, ...i3) => {
this.emit(`Carousel.${e2}`, t3, ...i3);
}), s2.on(["ready", "change"], () => {
this.manageCaption();
}), this.on("Carousel.removeSlide", (t3, e2, i3) => {
this.clearContent(i3), i3.state = void 0;
}), s2.on("Panzoom.touchStart", () => {
var t3, e2;
this.isCompact || this.endIdle(), (null === (t3 = document.activeElement) || void 0 === t3 ? void 0 : t3.closest(".f-thumbs")) && (null === (e2 = this.container) || void 0 === e2 || e2.focus());
}), s2.on("settle", () => {
this.idleTimer || this.isCompact || !this.option("idle") || this.setIdle(), this.option("autoFocus") && !this.isClosing && this.checkFocus();
}), this.option("dragToClose") && (s2.on("Panzoom.afterTransform", (t3, i3) => {
const n3 = this.getSlide();
if (n3 && e(n3.el))
return;
const s3 = this.container;
if (s3) {
const t4 = Math.abs(i3.current.f), e2 = t4 < 1 ? "" : Math.max(0.5, Math.min(1, 1 - t4 / i3.contentRect.fitHeight * 1.5));
s3.style.setProperty("--fancybox-ts", e2 ? "0s" : ""), s3.style.setProperty("--fancybox-opacity", e2 + "");
}
}), s2.on("Panzoom.touchEnd", (t3, i3, n3) => {
var s3;
const o2 = this.getSlide();
if (o2 && e(o2.el))
return;
if (i3.isMobile && document.activeElement && -1 !== ["TEXTAREA", "INPUT"].indexOf(null === (s3 = document.activeElement) || void 0 === s3 ? void 0 : s3.nodeName))
return;
const a2 = Math.abs(i3.dragOffset.y);
"y" === i3.lockedAxis && (a2 >= 200 || a2 >= 50 && i3.dragOffset.time < 300) && (n3 && n3.cancelable && n3.preventDefault(), this.close(n3, "f-throwOut" + (i3.current.f < 0 ? "Up" : "Down")));
})), s2.on("change", (t3) => {
var e2;
let i3 = null === (e2 = this.getSlide()) || void 0 === e2 ? void 0 : e2.triggerEl;
if (i3) {
const e3 = new CustomEvent("slideTo", { bubbles: true, cancelable: true, detail: t3.page });
i3.dispatchEvent(e3);
}
}), s2.on(["refresh", "change"], (t3) => {
const e2 = this.container;
if (!e2)
return;
for (const i4 of e2.querySelectorAll("[data-fancybox-current-index]"))
i4.innerHTML = t3.page + 1;
for (const i4 of e2.querySelectorAll("[data-fancybox-count]"))
i4.innerHTML = t3.pages.length;
if (!t3.isInfinite) {
for (const i4 of e2.querySelectorAll("[data-fancybox-next]"))
t3.page < t3.pages.length - 1 ? (i4.removeAttribute(ue), i4.removeAttribute(pe)) : (i4.setAttribute(ue, ""), i4.setAttribute(pe, "-1"));
for (const i4 of e2.querySelectorAll("[data-fancybox-prev]"))
t3.page > 0 ? (i4.removeAttribute(ue), i4.removeAttribute(pe)) : (i4.setAttribute(ue, ""), i4.setAttribute(pe, "-1"));
}
const i3 = this.getSlide();
if (!i3)
return;
let n3 = i3.downloadSrc || "";
n3 || "image" !== i3.type || i3.error || !ve(i3[me]) || (n3 = i3[me]);
for (const t4 of e2.querySelectorAll("[data-fancybox-download]")) {
const e3 = i3.downloadFilename;
n3 ? (t4.removeAttribute(ue), t4.removeAttribute(pe), t4.setAttribute(ge, n3), t4.setAttribute(fe, e3 || n3), t4.setAttribute("target", "_blank")) : (t4.setAttribute(ue, ""), t4.setAttribute(pe, "-1"), t4.removeAttribute(ge), t4.removeAttribute(fe));
}
}), this.emit("initCarousel");
}
attachEvents() {
const t2 = this, e2 = t2.container;
if (!e2)
return;
e2.addEventListener("click", t2.onClick, { passive: false, capture: false }), e2.addEventListener("wheel", t2.onWheel, { passive: false, capture: false }), document.addEventListener("keydown", t2.onKeydown, { passive: false, capture: true }), document.addEventListener("visibilitychange", t2.onVisibilityChange, false), document.addEventListener("mousemove", t2.onMousemove), t2.option("trapFocus") && document.addEventListener("focus", t2.onFocus, true), window.addEventListener("resize", t2.onResize);
const i2 = window.visualViewport;
i2 && (i2.addEventListener("scroll", t2.onResize), i2.addEventListener("resize", t2.onResize));
}
detachEvents() {
const t2 = this, e2 = t2.container;
if (!e2)
return;
document.removeEventListener("keydown", t2.onKeydown, { passive: false, capture: true }), e2.removeEventListener("wheel", t2.onWheel, { passive: false, capture: false }), e2.removeEventListener("click", t2.onClick, { passive: false, capture: false }), document.removeEventListener("mousemove", t2.onMousemove), window.removeEventListener("resize", t2.onResize);
const i2 = window.visualViewport;
i2 && (i2.removeEventListener("resize", t2.onResize), i2.removeEventListener("scroll", t2.onResize)), document.removeEventListener("visibilitychange", t2.onVisibilityChange, false), document.removeEventListener("focus", t2.onFocus, true);
}
scale() {
const t2 = this.container;
if (!t2)
return;
const e2 = window.visualViewport, i2 = Math.max(1, (null == e2 ? void 0 : e2.scale) || 1);
let n2 = "", s2 = "", o2 = "";
if (e2 && i2 > 1) {
let t3 = `${e2.offsetLeft}px`, a2 = `${e2.offsetTop}px`;
n2 = e2.width * i2 + "px", s2 = e2.height * i2 + "px", o2 = `translate3d(${t3}, ${a2}, 0) scale(${1 / i2})`;
}
t2.style.transform = o2, t2.style.width = n2, t2.style.height = s2;
}
onClick(t2) {
var e2;
const { container: i2, isCompact: n2 } = this;
if (!i2 || this.isClosing())
return;
!n2 && this.option("idle") && this.resetIdle();
const s2 = t2.composedPath()[0];
if (s2.closest(".fancybox-spinner") || s2.closest("[data-fancybox-close]"))
return t2.preventDefault(), void this.close(t2);
if (s2.closest("[data-fancybox-prev]"))
return t2.preventDefault(), void this.prev();
if (s2.closest("[data-fancybox-next]"))
return t2.preventDefault(), void this.next();
if ("click" === t2.type && 0 === t2.detail)
return;
if (Math.abs(t2.pageX - Ee) > 30 || Math.abs(t2.pageY - Se) > 30)
return;
const o2 = document.activeElement;
if (be() && o2 && i2.contains(o2))
return;
if (n2 && "image" === (null === (e2 = this.getSlide()) || void 0 === e2 ? void 0 : e2.type))
return void (this.clickTimer ? (clearTimeout(this.clickTimer), this.clickTimer = null) : this.clickTimer = setTimeout(() => {
this.toggleIdle(), this.clickTimer = null;
}, 350));
if (this.emit("click", t2), t2.defaultPrevented)
return;
let a2 = false;
if (s2.closest(".fancybox__content")) {
if (o2) {
if (o2.closest("[contenteditable]"))
return;
s2.matches(nt) || o2.blur();
}
if (be())
return;
a2 = this.option("contentClick");
} else
s2.closest(".fancybox__carousel") && !s2.matches(nt) && (a2 = this.option("backdropClick"));
"close" === a2 ? (t2.preventDefault(), this.close(t2)) : "next" === a2 ? (t2.preventDefault(), this.next()) : "prev" === a2 && (t2.preventDefault(), this.prev());
}
onWheel(t2) {
const e2 = t2.target;
let n2 = this.option("wheel", t2);
e2.closest(".fancybox__thumbs") && (n2 = "slide");
const s2 = "slide" === n2, o2 = [-t2.deltaX || 0, -t2.deltaY || 0, -t2.detail || 0].reduce(function(t3, e3) {
return Math.abs(e3) > Math.abs(t3) ? e3 : t3;
}), a2 = Math.max(-1, Math.min(1, o2)), r2 = Date.now();
this.pwt && r2 - this.pwt < 300 ? s2 && t2.preventDefault() : (this.pwt = r2, this.emit("wheel", t2, a2), t2.defaultPrevented || ("close" === n2 ? (t2.preventDefault(), this.close(t2)) : "slide" === n2 && (i(e2) || (t2.preventDefault(), this[a2 > 0 ? "prev" : "next"]()))));
}
onScroll() {
window.scrollTo(Pe, Ce);
}
onKeydown(t2) {
if (!this.isTopmost())
return;
this.isCompact || !this.option("idle") || this.isClosing() || this.resetIdle();
const e2 = t2.key, i2 = this.option("keyboard");
if (!i2)
return;
const n2 = t2.composedPath()[0], s2 = document.activeElement && document.activeElement.classList, o2 = s2 && s2.contains("f-button") || n2.dataset.carouselPage || n2.dataset.carouselIndex;
if ("Escape" !== e2 && !o2 && E(n2)) {
if (n2.isContentEditable || -1 !== ["TEXTAREA", "OPTION", "INPUT", "SELECT", "VIDEO"].indexOf(n2.nodeName))
return;
}
if ("Tab" === t2.key ? P(this.container, ae) : S(this.container, ae), t2.ctrlKey || t2.altKey || t2.shiftKey)
return;
this.emit("keydown", e2, t2);
const a2 = i2[e2];
a2 && "function" == typeof this[a2] && (t2.preventDefault(), this[a2]());
}
onResize() {
const t2 = this.container;
if (!t2)
return;
const e2 = this.isCompact;
t2.classList.toggle(le, e2), this.manageCaption(this.getSlide()), this.isCompact ? this.clearIdle() : this.endIdle(), this.scale(), this.emit("resize");
}
onFocus(t2) {
this.isTopmost() && this.checkFocus(t2);
}
onMousemove(t2) {
this.prevMouseMoveEvent = t2, !this.isCompact && this.option("idle") && this.resetIdle();
}
onVisibilityChange() {
"visible" === document.visibilityState ? this.checkFocus() : this.endIdle();
}
manageCloseBtn(t2) {
const e2 = this.optionFor(t2, "closeButton") || false;
if ("auto" === e2) {
const t3 = this.plugins.Toolbar;
if (t3 && t3.state === Zt.Ready)
return;
}
if (!e2)
return;
if (!t2.contentEl || t2.closeBtnEl)
return;
const i2 = this.option("tpl.closeButton");
if (i2) {
const e3 = n(this.localize(i2));
t2.closeBtnEl = t2.contentEl.appendChild(e3), t2.el && P(t2.el, "has-close-btn");
}
}
manageCaption(t2 = void 0) {
var e2, i2;
const n2 = "fancybox__caption", s2 = this.container;
if (!s2)
return;
S(s2, de);
const o2 = this.isCompact || this.option("commonCaption"), a2 = !o2;
if (this.caption && this.stop(this.caption), a2 && this.caption && (this.caption.remove(), this.caption = null), o2 && !this.caption)
for (const t3 of (null === (e2 = this.carousel) || void 0 === e2 ? void 0 : e2.slides) || [])
t3.captionEl && (t3.captionEl.remove(), t3.captionEl = void 0, S(t3.el, de), null === (i2 = t3.el) || void 0 === i2 || i2.removeAttribute("aria-labelledby"));
if (t2 || (t2 = this.getSlide()), !t2 || o2 && !this.isCurrentSlide(t2))
return;
const r2 = t2.el;
let l2 = this.optionFor(t2, "caption", "");
if (!l2)
return void (o2 && this.caption && this.animate(this.caption, "f-fadeOut", () => {
this.caption && (this.caption.innerHTML = "");
}));
let c2 = null;
if (a2) {
if (c2 = t2.captionEl || null, r2 && !c2) {
const e3 = n2 + `_${this.id}_${t2.index}`;
c2 = document.createElement("div"), P(c2, n2), c2.setAttribute("id", e3), t2.captionEl = r2.appendChild(c2), P(r2, de), r2.setAttribute("aria-labelledby", e3);
}
} else {
if (c2 = this.caption, c2 || (c2 = s2.querySelector("." + n2)), !c2) {
c2 = document.createElement("div"), c2.dataset.fancyboxCaption = "", P(c2, n2);
(this.footer || s2).prepend(c2);
}
P(s2, de), this.caption = c2;
}
c2 && (c2.innerHTML = "", ve(l2) || "number" == typeof l2 ? c2.innerHTML = l2 + "" : l2 instanceof HTMLElement && c2.appendChild(l2));
}
checkFocus(t2) {
this.focus(t2);
}
focus(t2) {
var e2;
if (this.ignoreFocusChange)
return;
const i2 = document.activeElement || null, n2 = (null == t2 ? void 0 : t2.target) || null, s2 = this.container, o2 = null === (e2 = this.carousel) || void 0 === e2 ? void 0 : e2.viewport;
if (!s2 || !o2)
return;
if (!t2 && i2 && s2.contains(i2))
return;
const a2 = this.getSlide(), r2 = a2 && a2.state === lt.Ready ? a2.el : null;
if (!r2 || r2.contains(i2) || s2 === i2)
return;
t2 && t2.cancelable && t2.preventDefault(), this.ignoreFocusChange = true;
const l2 = Array.from(s2.querySelectorAll(nt));
let c2 = [], h2 = null;
for (let t3 of l2) {
const e3 = !t3.offsetParent || !!t3.closest('[aria-hidden="true"]'), i3 = r2 && r2.contains(t3), n3 = !o2.contains(t3);
if (t3 === s2 || (i3 || n3) && !e3) {
c2.push(t3);
const e4 = t3.dataset.origTabindex;
void 0 !== e4 && e4 && (t3.tabIndex = parseFloat(e4)), t3.removeAttribute("data-orig-tabindex"), !t3.hasAttribute("autoFocus") && h2 || (h2 = t3);
} else {
const e4 = void 0 === t3.dataset.origTabindex ? t3.getAttribute("tabindex") || "" : t3.dataset.origTabindex;
e4 && (t3.dataset.origTabindex = e4), t3.tabIndex = -1;
}
}
let d2 = null;
t2 ? (!n2 || c2.indexOf(n2) < 0) && (d2 = h2 || s2, c2.length && (i2 === xe ? d2 = c2[0] : this.lastFocus !== s2 && i2 !== we || (d2 = c2[c2.length - 1]))) : d2 = a2 && "image" === a2.type ? s2 : h2 || s2, d2 && st(d2), this.lastFocus = document.activeElement, this.ignoreFocusChange = false;
}
next() {
const t2 = this.carousel;
t2 && t2.pages.length > 1 && t2.slideNext();
}
prev() {
const t2 = this.carousel;
t2 && t2.pages.length > 1 && t2.slidePrev();
}
jumpTo(...t2) {
this.carousel && this.carousel.slideTo(...t2);
}
isTopmost() {
var t2;
return (null === (t2 = Oe.getInstance()) || void 0 === t2 ? void 0 : t2.id) == this.id;
}
animate(t2 = null, e2 = "", i2) {
if (!t2 || !e2)
return void (i2 && i2());
this.stop(t2);
const n2 = (s2) => {
s2.target === t2 && t2.dataset.animationName && (t2.removeEventListener("animationend", n2), delete t2.dataset.animationName, i2 && i2(), S(t2, e2));
};
t2.dataset.animationName = e2, t2.addEventListener("animationend", n2), P(t2, e2);
}
stop(t2) {
t2 && t2.dispatchEvent(new CustomEvent("animationend", { bubbles: false, cancelable: true, currentTarget: t2 }));
}
setContent(t2, e2 = "", i2 = true) {
if (this.isClosing())
return;
const s2 = t2.el;
if (!s2)
return;
let o2 = null;
if (E(e2) ? o2 = e2 : (o2 = n(e2 + ""), E(o2) || (o2 = document.createElement("div"), o2.innerHTML = e2 + "")), ["img", "picture", "iframe", "video", "audio"].includes(o2.nodeName.toLowerCase())) {
const t3 = document.createElement("div");
t3.appendChild(o2), o2 = t3;
}
E(o2) && t2.filter && !t2.error && (o2 = o2.querySelector(t2.filter)), o2 && E(o2) ? (P(o2, "fancybox__content"), t2.id && o2.setAttribute("id", t2.id), "none" !== o2.style.display && "none" !== getComputedStyle(o2).getPropertyValue("display") || (o2.style.display = t2.display || this.option("defaultDisplay") || "flex"), s2.classList.add(`has-${t2.error ? "error" : t2.type || "unknown"}`), s2.prepend(o2), t2.contentEl = o2, i2 && this.revealContent(t2), this.manageCloseBtn(t2), this.manageCaption(t2)) : this.setError(t2, "{{ELEMENT_NOT_FOUND}}");
}
revealContent(t2, e2) {
const i2 = t2.el, n2 = t2.contentEl;
i2 && n2 && (this.emit("reveal", t2), this.hideLoading(t2), t2.state = lt.Opening, (e2 = this.isOpeningSlide(t2) ? void 0 === e2 ? this.optionFor(t2, "showClass") : e2 : "f-fadeIn") ? this.animate(n2, e2, () => {
this.done(t2);
}) : this.done(t2));
}
done(t2) {
this.isClosing() || (t2.state = lt.Ready, this.emit("done", t2), P(t2.el, "is-done"), this.isCurrentSlide(t2) && this.option("autoFocus") && queueMicrotask(() => {
var e2;
null === (e2 = t2.panzoom) || void 0 === e2 || e2.updateControls(), this.option("autoFocus") && this.focus();
}), this.isOpeningSlide(t2) && (S(this.container, he), !this.isCompact && this.option("idle") && this.setIdle()));
}
isCurrentSlide(t2) {
const e2 = this.getSlide();
return !(!t2 || !e2) && e2.index === t2.index;
}
isOpeningSlide(t2) {
var e2, i2;
return null === (null === (e2 = this.carousel) || void 0 === e2 ? void 0 : e2.prevPage) && t2 && t2.index === (null === (i2 = this.getSlide()) || void 0 === i2 ? void 0 : i2.index);
}
showLoading(t2) {
t2.state = lt.Loading;
const e2 = t2.el;
if (!e2)
return;
P(e2, ce), this.emit("loading", t2), t2.spinnerEl || setTimeout(() => {
if (!this.isClosing() && !t2.spinnerEl && t2.state === lt.Loading) {
let i2 = n(x);
P(i2, "fancybox-spinner"), t2.spinnerEl = i2, e2.prepend(i2), this.animate(i2, "f-fadeIn");
}
}, 250);
}
hideLoading(t2) {
const e2 = t2.el;
if (!e2)
return;
const i2 = t2.spinnerEl;
this.isClosing() ? null == i2 || i2.remove() : (S(e2, ce), i2 && this.animate(i2, "f-fadeOut", () => {
i2.remove();
}), t2.state === lt.Loading && (this.emit("loaded", t2), t2.state = lt.Ready));
}
setError(t2, e2) {
if (this.isClosing())
return;
const i2 = new Event("error", { bubbles: true, cancelable: true });
if (this.emit("error", i2, t2), i2.defaultPrevented)
return;
t2.error = e2, this.hideLoading(t2), this.clearContent(t2);
const n2 = document.createElement("div");
n2.classList.add("fancybox-error"), n2.innerHTML = this.localize(e2 || "<p>{{ERROR}}</p>"), this.setContent(t2, n2);
}
clearContent(t2) {
if (void 0 === t2.state)
return;
this.emit("clearContent", t2), t2.contentEl && (t2.contentEl.remove(), t2.contentEl = void 0);
const e2 = t2.el;
e2 && (S(e2, "has-error"), S(e2, "has-unknown"), S(e2, `has-${t2.type || "unknown"}`)), t2.closeBtnEl && t2.closeBtnEl.remove(), t2.closeBtnEl = void 0, t2.captionEl && t2.captionEl.remove(), t2.captionEl = void 0, t2.spinnerEl && t2.spinnerEl.remove(), t2.spinnerEl = void 0;
}
getSlide() {
var t2;
const e2 = this.carousel;
return (null === (t2 = null == e2 ? void 0 : e2.pages[null == e2 ? void 0 : e2.page]) || void 0 === t2 ? void 0 : t2.slides[0]) || void 0;
}
close(t2, e2) {
if (this.isClosing())
return;
const i2 = new Event("shouldClose", { bubbles: true, cancelable: true });
if (this.emit("shouldClose", i2, t2), i2.defaultPrevented)
return;
t2 && t2.cancelable && (t2.preventDefault(), t2.stopPropagation());
const n2 = () => {
this.proceedClose(t2, e2);
};
this.startedFs && ye && ye.isFullscreen() ? Promise.resolve(ye.exit()).then(() => n2()) : n2();
}
clearIdle() {
this.idleTimer && clearTimeout(this.idleTimer), this.idleTimer = null;
}
setIdle(t2 = false) {
const e2 = () => {
this.clearIdle(), this.idle = true, P(this.container, "is-idle"), this.emit("setIdle");
};
if (this.clearIdle(), !this.isClosing())
if (t2)
e2();
else {
const t3 = this.option("idle");
t3 && (this.idleTimer = setTimeout(e2, t3));
}
}
endIdle() {
this.clearIdle(), this.idle && !this.isClosing() && (this.idle = false, S(this.container, "is-idle"), this.emit("endIdle"));
}
resetIdle() {
this.endIdle(), this.setIdle();
}
toggleIdle() {
this.idle ? this.endIdle() : this.setIdle(true);
}
toggleFullscreen() {
ye && (ye.isFullscreen() ? ye.exit() : ye.request().then(() => {
this.startedFs = true;
}));
}
isClosing() {
return [rt.Closing, rt.CustomClosing, rt.Destroy].includes(this.state);
}
proceedClose(t2, e2) {
var i2, n2;
this.state = rt.Closing, this.clearIdle(), this.detachEvents();
const s2 = this.container, o2 = this.carousel, a2 = this.getSlide(), r2 = a2 && this.option("placeFocusBack") ? a2.triggerEl || this.option("triggerEl") : null;
if (r2 && (tt(r2) ? st(r2) : r2.focus()), s2 && (S(s2, he), P(s2, "is-closing"), s2.setAttribute(oe, "true"), this.option("animated") && P(s2, re), s2.style.pointerEvents = "none"), o2) {
o2.clearTransitions(), null === (i2 = o2.panzoom) || void 0 === i2 || i2.destroy(), null === (n2 = o2.plugins.Navigation) || void 0 === n2 || n2.detach();
for (const t3 of o2.slides) {
t3.state = lt.Closing, this.hideLoading(t3);
const e3 = t3.contentEl;
e3 && this.stop(e3);
const i3 = null == t3 ? void 0 : t3.panzoom;
i3 && (i3.stop(), i3.detachEvents(), i3.detachObserver()), this.isCurrentSlide(t3) || o2.emit("removeSlide", t3);
}
}
Pe = window.scrollX, Ce = window.scrollY, window.addEventListener("scroll", this.onScroll), this.emit("close", t2), this.state !== rt.CustomClosing ? (void 0 === e2 && a2 && (e2 = this.optionFor(a2, "hideClass")), e2 && a2 ? (this.animate(a2.contentEl, e2, () => {
o2 && o2.emit("removeSlide", a2);
}), setTimeout(() => {
this.destroy();
}, 500)) : this.destroy()) : setTimeout(() => {
this.destroy();
}, 500);
}
destroy() {
var t2;
if (this.state === rt.Destroy)
return;
window.removeEventListener("scroll", this.onScroll), this.state = rt.Destroy, null === (t2 = this.carousel) || void 0 === t2 || t2.destroy();
const e2 = this.container;
e2 && e2.remove(), Te.delete(this.id);
const i2 = Oe.getInstance();
i2 ? i2.focus() : (we && (we.remove(), we = null), xe && (xe.remove(), xe = null), S(document.documentElement, ee), (() => {
if (!et)
return;
const t3 = document, e3 = t3.body;
e3.classList.remove(ie), e3.style.setProperty(se, ""), t3.documentElement.style.setProperty(ne, "");
})(), this.emit("destroy"));
}
static bind(t2, e2, i2) {
if (!et)
return;
let n2, s2 = "", o2 = {};
if (void 0 === t2 ? n2 = document.body : ve(t2) ? (n2 = document.body, s2 = t2, "object" == typeof e2 && (o2 = e2 || {})) : (n2 = t2, ve(e2) && (s2 = e2), "object" == typeof i2 && (o2 = i2 || {})), !n2 || !E(n2))
return;
s2 = s2 || "[data-fancybox]";
const a2 = Oe.openers.get(n2) || /* @__PURE__ */ new Map();
a2.set(s2, o2), Oe.openers.set(n2, a2), 1 === a2.size && n2.addEventListener("click", Oe.fromEvent);
}
static unbind(t2, e2) {
let i2, n2 = "";
if (ve(t2) ? (i2 = document.body, n2 = t2) : (i2 = t2, ve(e2) && (n2 = e2)), !i2)
return;
const s2 = Oe.openers.get(i2);
s2 && n2 && s2.delete(n2), n2 && s2 || (Oe.openers.delete(i2), i2.removeEventListener("click", Oe.fromEvent));
}
static destroy() {
let t2;
for (; t2 = Oe.getInstance(); )
t2.destroy();
for (const t3 of Oe.openers.keys())
t3.removeEventListener("click", Oe.fromEvent);
Oe.openers = /* @__PURE__ */ new Map();
}
static fromEvent(t2) {
if (t2.defaultPrevented)
return;
if (t2.button && 0 !== t2.button)
return;
if (t2.ctrlKey || t2.metaKey || t2.shiftKey)
return;
let e2 = t2.composedPath()[0];
const i2 = e2.closest("[data-fancybox-trigger]");
if (i2) {
const t3 = i2.dataset.fancyboxTrigger || "", n3 = document.querySelectorAll(`[data-fancybox="${t3}"]`), s3 = parseInt(i2.dataset.fancyboxIndex || "", 10) || 0;
e2 = n3[s3] || e2;
}
if (!(e2 && e2 instanceof Element))
return;
let n2, s2, o2, a2;
if ([...Oe.openers].reverse().find(([t3, i3]) => !(!t3.contains(e2) || ![...i3].reverse().find(([i4, r3]) => {
let l3 = e2.closest(i4);
return !!l3 && (n2 = t3, s2 = i4, o2 = l3, a2 = r3, true);
}))), !n2 || !s2 || !o2)
return;
a2 = a2 || {}, t2.preventDefault(), e2 = o2;
let r2 = [], l2 = u({}, at, a2);
l2.event = t2, l2.triggerEl = e2, l2.delegate = i2;
const c2 = l2.groupAll, h2 = l2.groupAttr, d2 = h2 && e2 ? e2.getAttribute(`${h2}`) : "";
if ((!e2 || d2 || c2) && (r2 = [].slice.call(n2.querySelectorAll(s2))), e2 && !c2 && (r2 = d2 ? r2.filter((t3) => t3.getAttribute(`${h2}`) === d2) : [e2]), !r2.length)
return;
const p2 = Oe.getInstance();
return p2 && p2.options.triggerEl && r2.indexOf(p2.options.triggerEl) > -1 ? void 0 : (e2 && (l2.startIndex = r2.indexOf(e2)), Oe.fromNodes(r2, l2));
}
static fromSelector(t2, e2, i2) {
let n2 = null, s2 = "", o2 = {};
if (ve(t2) ? (n2 = document.body, s2 = t2, "object" == typeof e2 && (o2 = e2 || {})) : t2 instanceof HTMLElement && ve(e2) && (n2 = t2, s2 = e2, "object" == typeof i2 && (o2 = i2 || {})), !n2 || !s2)
return false;
const a2 = Oe.openers.get(n2);
return !!a2 && (o2 = u({}, a2.get(s2) || {}, o2), !!o2 && Oe.fromNodes(Array.from(n2.querySelectorAll(s2)), o2));
}
static fromNodes(t2, e2) {
e2 = u({}, at, e2 || {});
const i2 = [];
for (const n2 of t2) {
const t3 = n2.dataset || {}, s2 = t3[me] || n2.getAttribute(ge) || n2.getAttribute("currentSrc") || n2.getAttribute(me) || void 0;
let o2;
const a2 = e2.delegate;
let r2;
a2 && i2.length === e2.startIndex && (o2 = a2 instanceof HTMLImageElement ? a2 : a2.querySelector("img:not([aria-hidden])")), o2 || (o2 = n2 instanceof HTMLImageElement ? n2 : n2.querySelector("img:not([aria-hidden])")), o2 && (r2 = o2.currentSrc || o2[me] || void 0, !r2 && o2.dataset && (r2 = o2.dataset.lazySrc || o2.dataset[me] || void 0));
const l2 = { src: s2, triggerEl: n2, thumbEl: o2, thumbElSrc: r2, thumbSrc: r2 };
for (const e3 in t3) {
let i3 = t3[e3] + "";
i3 = "false" !== i3 && ("true" === i3 || i3), l2[e3] = i3;
}
i2.push(l2);
}
return new Oe(i2, e2);
}
static getInstance(t2) {
if (t2)
return Te.get(t2);
return Array.from(Te.values()).reverse().find((t3) => !t3.isClosing() && t3) || null;
}
static getSlide() {
var t2;
return (null === (t2 = Oe.getInstance()) || void 0 === t2 ? void 0 : t2.getSlide()) || null;
}
static show(t2 = [], e2 = {}) {
return new Oe(t2, e2);
}
static next() {
const t2 = Oe.getInstance();
t2 && t2.next();
}
static prev() {
const t2 = Oe.getInstance();
t2 && t2.prev();
}
static close(t2 = true, ...e2) {
if (t2)
for (const t3 of Te.values())
t3.close(...e2);
else {
const t3 = Oe.getInstance();
t3 && t3.close(...e2);
}
}
}
Object.defineProperty(Oe, "version", { enumerable: true, configurable: true, writable: true, value: "5.0.35" }), Object.defineProperty(Oe, "defaults", { enumerable: true, configurable: true, writable: true, value: at }), Object.defineProperty(Oe, "Plugins", { enumerable: true, configurable: true, writable: true, value: te }), Object.defineProperty(Oe, "openers", { enumerable: true, configurable: true, writable: true, value: /* @__PURE__ */ new Map() });
var _excluded = ["size", "strokeWidth", "strokeLinecap", "strokeLinejoin", "theme", "fill", "className", "spin"];
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i2 = 1; i2 < arguments.length; i2++) {
var source = null != arguments[i2] ? arguments[i2] : {};
i2 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
} else {
obj[key] = value;
}
return obj;
}
function _objectWithoutProperties(source, excluded) {
if (source == null)
return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i2;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) {
key = sourceSymbolKeys[i2];
if (excluded.indexOf(key) >= 0)
continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key))
continue;
target[key] = source[key];
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null)
return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i2;
for (i2 = 0; i2 < sourceKeys.length; i2++) {
key = sourceKeys[i2];
if (excluded.indexOf(key) >= 0)
continue;
target[key] = source[key];
}
return target;
}
var DEFAULT_ICON_CONFIGS = {
size: "1em",
strokeWidth: 4,
strokeLinecap: "round",
strokeLinejoin: "round",
rtl: false,
theme: "outline",
colors: {
outline: {
fill: "#333",
background: "transparent"
},
filled: {
fill: "#333",
background: "#FFF"
},
twoTone: {
fill: "#333",
twoTone: "#2F88FF"
},
multiColor: {
outStrokeColor: "#333",
outFillColor: "#2F88FF",
innerStrokeColor: "#FFF",
innerFillColor: "#43CCF8"
}
},
prefix: "i"
};
function guid() {
return "icon-" + ((1 + Math.random()) * 4294967296 | 0).toString(16).substring(1);
}
function IconConverter(id, icon, config) {
var fill = typeof icon.fill === "string" ? [icon.fill] : icon.fill || [];
var colors = [];
var theme = icon.theme || config.theme;
switch (theme) {
case "outline":
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push("none");
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push("none");
break;
case "filled":
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push("#FFF");
colors.push("#FFF");
break;
case "two-tone":
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push(typeof fill[1] === "string" ? fill[1] : config.colors.twoTone.twoTone);
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push(typeof fill[1] === "string" ? fill[1] : config.colors.twoTone.twoTone);
break;
case "multi-color":
colors.push(typeof fill[0] === "string" ? fill[0] : "currentColor");
colors.push(typeof fill[1] === "string" ? fill[1] : config.colors.multiColor.outFillColor);
colors.push(typeof fill[2] === "string" ? fill[2] : config.colors.multiColor.innerStrokeColor);
colors.push(typeof fill[3] === "string" ? fill[3] : config.colors.multiColor.innerFillColor);
break;
}
return {
size: icon.size || config.size,
strokeWidth: icon.strokeWidth || config.strokeWidth,
strokeLinecap: icon.strokeLinecap || config.strokeLinecap,
strokeLinejoin: icon.strokeLinejoin || config.strokeLinejoin,
colors,
id
};
}
var IconContext = /* @__PURE__ */ React.createContext(DEFAULT_ICON_CONFIGS);
IconContext.Provider;
function IconWrapper(name, rtl, render) {
return function(props) {
var size = props.size, strokeWidth = props.strokeWidth, strokeLinecap = props.strokeLinecap, strokeLinejoin = props.strokeLinejoin, theme = props.theme, fill = props.fill, className = props.className, spin = props.spin, extra = _objectWithoutProperties(props, _excluded);
var ICON_CONFIGS = React.useContext(IconContext);
var id = React.useMemo(guid, []);
var svgProps = IconConverter(id, {
size,
strokeWidth,
strokeLinecap,
strokeLinejoin,
theme,
fill
}, ICON_CONFIGS);
var cls = [ICON_CONFIGS.prefix + "-icon"];
cls.push(ICON_CONFIGS.prefix + "-icon-" + name);
if (rtl && ICON_CONFIGS.rtl) {
cls.push(ICON_CONFIGS.prefix + "-icon-rtl");
}
if (spin) {
cls.push(ICON_CONFIGS.prefix + "-icon-spin");
}
if (className) {
cls.push(className);
}
return /* @__PURE__ */ React.createElement("span", _objectSpread(_objectSpread({}, extra), {}, {
className: cls.join(" ")
}), render(svgProps));
};
}
const Picture = IconWrapper("picture", true, function(props) {
return /* @__PURE__ */ React.createElement("svg", {
width: props.size,
height: props.size,
viewBox: "0 0 48 48",
fill: "none"
}, /* @__PURE__ */ React.createElement("path", {
d: "M39 6H9C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6Z",
stroke: props.colors[0],
strokeWidth: props.strokeWidth,
strokeLinecap: props.strokeLinecap,
strokeLinejoin: props.strokeLinejoin
}), /* @__PURE__ */ React.createElement("path", {
d: "M18 23C20.7614 23 23 20.7614 23 18C23 15.2386 20.7614 13 18 13C15.2386 13 13 15.2386 13 18C13 20.7614 15.2386 23 18 23Z",
fill: props.colors[1],
stroke: props.colors[0],
strokeWidth: props.strokeWidth,
strokeLinecap: props.strokeLinecap,
strokeLinejoin: props.strokeLinejoin
}), /* @__PURE__ */ React.createElement("path", {
d: "M27.7901 26.2194C28.6064 25.1269 30.2528 25.1538 31.0329 26.2725L39.8077 38.8561C40.7322 40.182 39.7835 42.0001 38.1671 42.0001H16L27.7901 26.2194Z",
stroke: props.colors[0],
strokeWidth: props.strokeWidth,
strokeLinecap: props.strokeLinecap,
strokeLinejoin: props.strokeLinejoin
}));
});
var createUpdateEffect = function(hook) {
return function(effect, deps) {
var isMounted = React.useRef(false);
hook(function() {
return function() {
isMounted.current = false;
};
}, []);
hook(function() {
if (!isMounted.current) {
isMounted.current = true;
} else {
return effect();
}
}, deps);
};
};
var __assign = function() {
__assign = Object.assign || function __assign2(t2) {
for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
s2 = arguments[i2];
for (var p2 in s2)
if (Object.prototype.hasOwnProperty.call(s2, p2))
t2[p2] = s2[p2];
}
return t2;
};
return __assign.apply(this, arguments);
};
function __rest(s2, e2) {
var t2 = {};
for (var p2 in s2)
if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0)
t2[p2] = s2[p2];
if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) {
if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i2]))
t2[p2[i2]] = s2[p2[i2]];
}
return t2;
}
function __awaiter(thisArg, _arguments, P2, generator) {
function adopt(value) {
return value instanceof P2 ? value : new P2(function(resolve) {
resolve(value);
});
}
return new (P2 || (P2 = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e2) {
reject(e2);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e2) {
reject(e2);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _2 = { label: 0, sent: function() {
if (t2[0] & 1)
throw t2[1];
return t2[1];
}, trys: [], ops: [] }, f2, y2, t2, g2;
return g2 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g2[Symbol.iterator] = function() {
return this;
}), g2;
function verb(n2) {
return function(v2) {
return step([n2, v2]);
};
}
function step(op) {
if (f2)
throw new TypeError("Generator is already executing.");
while (g2 && (g2 = 0, op[0] && (_2 = 0)), _2)
try {
if (f2 = 1, y2 && (t2 = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t2 = y2["return"]) && t2.call(y2), 0) : y2.next) && !(t2 = t2.call(y2, op[1])).done)
return t2;
if (y2 = 0, t2)
op = [op[0] & 2, t2.value];
switch (op[0]) {
case 0:
case 1:
t2 = op;
break;
case 4:
_2.label++;
return { value: op[1], done: false };
case 5:
_2.label++;
y2 = op[1];
op = [0];
continue;
case 7:
op = _2.ops.pop();
_2.trys.pop();
continue;
default:
if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_2 = 0;
continue;
}
if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
_2.label = op[1];
break;
}
if (op[0] === 6 && _2.label < t2[1]) {
_2.label = t2[1];
t2 = op;
break;
}
if (t2 && _2.label < t2[2]) {
_2.label = t2[2];
_2.ops.push(op);
break;
}
if (t2[2])
_2.ops.pop();
_2.trys.pop();
continue;
}
op = body.call(thisArg, _2);
} catch (e2) {
op = [6, e2];
y2 = 0;
} finally {
f2 = t2 = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __read(o2, n2) {
var m2 = typeof Symbol === "function" && o2[Symbol.iterator];
if (!m2)
return o2;
var i2 = m2.call(o2), r2, ar = [], e2;
try {
while ((n2 === void 0 || n2-- > 0) && !(r2 = i2.next()).done)
ar.push(r2.value);
} catch (error) {
e2 = { error };
} finally {
try {
if (r2 && !r2.done && (m2 = i2["return"]))
m2.call(i2);
} finally {
if (e2)
throw e2.error;
}
}
return ar;
}
function __spreadArray(to, from2, pack) {
if (pack || arguments.length === 2)
for (var i2 = 0, l2 = from2.length, ar; i2 < l2; i2++) {
if (ar || !(i2 in from2)) {
if (!ar)
ar = Array.prototype.slice.call(from2, 0, i2);
ar[i2] = from2[i2];
}
}
return to.concat(ar || Array.prototype.slice.call(from2));
}
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message2) {
var e2 = new Error(message2);
return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
};
var isFunction2 = function(value) {
return typeof value === "function";
};
function useMemoizedFn(fn) {
var fnRef = React.useRef(fn);
fnRef.current = React.useMemo(function() {
return fn;
}, [fn]);
var memoizedFn = React.useRef();
if (!memoizedFn.current) {
memoizedFn.current = function() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fnRef.current.apply(this, args);
};
}
return memoizedFn.current;
}
const useUpdateEffect = createUpdateEffect(React.useEffect);
var useAutoRunPlugin = function(fetchInstance, _a) {
var manual = _a.manual, _b = _a.ready, ready = _b === void 0 ? true : _b, _c = _a.defaultParams, defaultParams = _c === void 0 ? [] : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, refreshDepsAction = _a.refreshDepsAction;
var hasAutoRun = React.useRef(false);
hasAutoRun.current = false;
useUpdateEffect(function() {
if (!manual && ready) {
hasAutoRun.current = true;
fetchInstance.run.apply(fetchInstance, __spreadArray([], __read(defaultParams), false));
}
}, [ready]);
useUpdateEffect(function() {
if (hasAutoRun.current) {
return;
}
if (!manual) {
hasAutoRun.current = true;
if (refreshDepsAction) {
refreshDepsAction();
} else {
fetchInstance.refresh();
}
}
}, __spreadArray([], __read(refreshDeps), false));
return {
onBefore: function() {
if (!ready) {
return {
stopNow: true
};
}
}
};
};
useAutoRunPlugin.onInit = function(_a) {
var _b = _a.ready, ready = _b === void 0 ? true : _b, manual = _a.manual;
return {
loading: !manual && ready
};
};
const useAutoRunPlugin$1 = useAutoRunPlugin;
function depsAreSame(oldDeps, deps) {
if (oldDeps === deps)
return true;
for (var i2 = 0; i2 < oldDeps.length; i2++) {
if (!Object.is(oldDeps[i2], deps[i2]))
return false;
}
return true;
}
function useCreation(factory, deps) {
var current = React.useRef({
deps,
obj: void 0,
initialized: false
}).current;
if (current.initialized === false || !depsAreSame(current.deps, deps)) {
current.deps = deps;
current.obj = factory();
current.initialized = true;
}
return current.obj;
}
function useLatest(value) {
var ref = React.useRef(value);
ref.current = value;
return ref;
}
var useUnmount = function(fn) {
var fnRef = useLatest(fn);
React.useEffect(function() {
return function() {
fnRef.current();
};
}, []);
};
var cache = /* @__PURE__ */ new Map();
var setCache = function(key, cacheTime, cachedData) {
var currentCache = cache.get(key);
if (currentCache === null || currentCache === void 0 ? void 0 : currentCache.timer) {
clearTimeout(currentCache.timer);
}
var timer = void 0;
if (cacheTime > -1) {
timer = setTimeout(function() {
cache.delete(key);
}, cacheTime);
}
cache.set(key, __assign(__assign({}, cachedData), {
timer
}));
};
var getCache = function(key) {
return cache.get(key);
};
var cachePromise = /* @__PURE__ */ new Map();
var getCachePromise = function(cacheKey) {
return cachePromise.get(cacheKey);
};
var setCachePromise = function(cacheKey, promise) {
cachePromise.set(cacheKey, promise);
promise.then(function(res) {
cachePromise.delete(cacheKey);
return res;
}).catch(function() {
cachePromise.delete(cacheKey);
});
};
var listeners$2 = {};
var trigger = function(key, data) {
if (listeners$2[key]) {
listeners$2[key].forEach(function(item) {
return item(data);
});
}
};
var subscribe$2 = function(key, listener) {
if (!listeners$2[key]) {
listeners$2[key] = [];
}
listeners$2[key].push(listener);
return function unsubscribe() {
var index = listeners$2[key].indexOf(listener);
listeners$2[key].splice(index, 1);
};
};
var useCachePlugin = function(fetchInstance, _a) {
var cacheKey = _a.cacheKey, _b = _a.cacheTime, cacheTime = _b === void 0 ? 5 * 60 * 1e3 : _b, _c = _a.staleTime, staleTime = _c === void 0 ? 0 : _c, customSetCache = _a.setCache, customGetCache = _a.getCache;
var unSubscribeRef = React.useRef();
var currentPromiseRef = React.useRef();
var _setCache = function(key, cachedData) {
if (customSetCache) {
customSetCache(cachedData);
} else {
setCache(key, cacheTime, cachedData);
}
trigger(key, cachedData.data);
};
var _getCache = function(key, params) {
if (params === void 0) {
params = [];
}
if (customGetCache) {
return customGetCache(params);
}
return getCache(key);
};
useCreation(function() {
if (!cacheKey) {
return;
}
var cacheData = _getCache(cacheKey);
if (cacheData && Object.hasOwnProperty.call(cacheData, "data")) {
fetchInstance.state.data = cacheData.data;
fetchInstance.state.params = cacheData.params;
if (staleTime === -1 || (/* @__PURE__ */ new Date()).getTime() - cacheData.time <= staleTime) {
fetchInstance.state.loading = false;
}
}
unSubscribeRef.current = subscribe$2(cacheKey, function(data) {
fetchInstance.setState({
data
});
});
}, []);
useUnmount(function() {
var _a2;
(_a2 = unSubscribeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(unSubscribeRef);
});
if (!cacheKey) {
return {};
}
return {
onBefore: function(params) {
var cacheData = _getCache(cacheKey, params);
if (!cacheData || !Object.hasOwnProperty.call(cacheData, "data")) {
return {};
}
if (staleTime === -1 || (/* @__PURE__ */ new Date()).getTime() - cacheData.time <= staleTime) {
return {
loading: false,
data: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data,
error: void 0,
returnNow: true
};
} else {
return {
data: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data,
error: void 0
};
}
},
onRequest: function(service, args) {
var servicePromise = getCachePromise(cacheKey);
if (servicePromise && servicePromise !== currentPromiseRef.current) {
return {
servicePromise
};
}
servicePromise = service.apply(void 0, __spreadArray([], __read(args), false));
currentPromiseRef.current = servicePromise;
setCachePromise(cacheKey, servicePromise);
return {
servicePromise
};
},
onSuccess: function(data, params) {
var _a2;
if (cacheKey) {
(_a2 = unSubscribeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(unSubscribeRef);
_setCache(cacheKey, {
data,
params,
time: (/* @__PURE__ */ new Date()).getTime()
});
unSubscribeRef.current = subscribe$2(cacheKey, function(d2) {
fetchInstance.setState({
data: d2
});
});
}
},
onMutate: function(data) {
var _a2;
if (cacheKey) {
(_a2 = unSubscribeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(unSubscribeRef);
_setCache(cacheKey, {
data,
params: fetchInstance.state.params,
time: (/* @__PURE__ */ new Date()).getTime()
});
unSubscribeRef.current = subscribe$2(cacheKey, function(d2) {
fetchInstance.setState({
data: d2
});
});
}
}
};
};
const useCachePlugin$1 = useCachePlugin;
function isObject$4(value) {
var type = typeof value;
return value != null && (type == "object" || type == "function");
}
var isObject_1 = isObject$4;
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
var _freeGlobal = freeGlobal$1;
var freeGlobal = _freeGlobal;
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
var root$2 = freeGlobal || freeSelf || Function("return this")();
var _root = root$2;
var root$1 = _root;
var now$1 = function() {
return root$1.Date.now();
};
var now_1 = now$1;
var reWhitespace = /\s/;
function trimmedEndIndex$1(string) {
var index = string.length;
while (index-- && reWhitespace.test(string.charAt(index))) {
}
return index;
}
var _trimmedEndIndex = trimmedEndIndex$1;
var trimmedEndIndex = _trimmedEndIndex;
var reTrimStart = /^\s+/;
function baseTrim$1(string) {
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
}
var _baseTrim = baseTrim$1;
var root = _root;
var Symbol$3 = root.Symbol;
var _Symbol = Symbol$3;
var Symbol$2 = _Symbol;
var objectProto$1 = Object.prototype;
var hasOwnProperty = objectProto$1.hasOwnProperty;
var nativeObjectToString$1 = objectProto$1.toString;
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : void 0;
function getRawTag$1(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag$1), tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = void 0;
var unmasked = true;
} catch (e2) {
}
var result = nativeObjectToString$1.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
var _getRawTag = getRawTag$1;
var objectProto = Object.prototype;
var nativeObjectToString = objectProto.toString;
function objectToString$1(value) {
return nativeObjectToString.call(value);
}
var _objectToString = objectToString$1;
var Symbol$1 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
function baseGetTag$1(value) {
if (value == null) {
return value === void 0 ? undefinedTag : nullTag;
}
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
}
var _baseGetTag = baseGetTag$1;
function isObjectLike$1(value) {
return value != null && typeof value == "object";
}
var isObjectLike_1 = isObjectLike$1;
var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
var symbolTag = "[object Symbol]";
function isSymbol$1(value) {
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
}
var isSymbol_1 = isSymbol$1;
var baseTrim = _baseTrim, isObject$3 = isObject_1, isSymbol2 = isSymbol_1;
var NAN = 0 / 0;
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
var reIsBinary = /^0b[01]+$/i;
var reIsOctal = /^0o[0-7]+$/i;
var freeParseInt = parseInt;
function toNumber$1(value) {
if (typeof value == "number") {
return value;
}
if (isSymbol2(value)) {
return NAN;
}
if (isObject$3(value)) {
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
value = isObject$3(other) ? other + "" : other;
}
if (typeof value != "string") {
return value === 0 ? value : +value;
}
value = baseTrim(value);
var isBinary = reIsBinary.test(value);
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
var toNumber_1 = toNumber$1;
var isObject$2 = isObject_1, now = now_1, toNumber = toNumber_1;
var FUNC_ERROR_TEXT$1 = "Expected a function";
var nativeMax = Math.max, nativeMin = Math.min;
function debounce$1(func, wait, options) {
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
if (typeof func != "function") {
throw new TypeError(FUNC_ERROR_TEXT$1);
}
wait = toNumber(wait) || 0;
if (isObject$2(options)) {
leading = !!options.leading;
maxing = "maxWait" in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = "trailing" in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs, thisArg = lastThis;
lastArgs = lastThis = void 0;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
lastInvokeTime = time;
timerId = setTimeout(timerExpired, wait);
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = void 0;
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = void 0;
return result;
}
function cancel() {
if (timerId !== void 0) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = void 0;
}
function flush() {
return timerId === void 0 ? result : trailingEdge(now());
}
function debounced() {
var time = now(), isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === void 0) {
return leadingEdge(lastCallTime);
}
if (maxing) {
clearTimeout(timerId);
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === void 0) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
var debounce_1 = debounce$1;
const debounce$2 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
var useDebouncePlugin = function(fetchInstance, _a) {
var debounceWait = _a.debounceWait, debounceLeading = _a.debounceLeading, debounceTrailing = _a.debounceTrailing, debounceMaxWait = _a.debounceMaxWait;
var debouncedRef = React.useRef();
var options = React.useMemo(function() {
var ret = {};
if (debounceLeading !== void 0) {
ret.leading = debounceLeading;
}
if (debounceTrailing !== void 0) {
ret.trailing = debounceTrailing;
}
if (debounceMaxWait !== void 0) {
ret.maxWait = debounceMaxWait;
}
return ret;
}, [debounceLeading, debounceTrailing, debounceMaxWait]);
React.useEffect(function() {
if (debounceWait) {
var _originRunAsync_1 = fetchInstance.runAsync.bind(fetchInstance);
debouncedRef.current = debounce$2(function(callback) {
callback();
}, debounceWait, options);
fetchInstance.runAsync = function() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new Promise(function(resolve, reject) {
var _a2;
(_a2 = debouncedRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(debouncedRef, function() {
_originRunAsync_1.apply(void 0, __spreadArray([], __read(args), false)).then(resolve).catch(reject);
});
});
};
return function() {
var _a2;
(_a2 = debouncedRef.current) === null || _a2 === void 0 ? void 0 : _a2.cancel();
fetchInstance.runAsync = _originRunAsync_1;
};
}
}, [debounceWait, options]);
if (!debounceWait) {
return {};
}
return {
onCancel: function() {
var _a2;
(_a2 = debouncedRef.current) === null || _a2 === void 0 ? void 0 : _a2.cancel();
}
};
};
const useDebouncePlugin$1 = useDebouncePlugin;
var useLoadingDelayPlugin = function(fetchInstance, _a) {
var loadingDelay = _a.loadingDelay, ready = _a.ready;
var timerRef = React.useRef();
if (!loadingDelay) {
return {};
}
var cancelTimeout = function() {
if (timerRef.current) {
clearTimeout(timerRef.current);
}
};
return {
onBefore: function() {
cancelTimeout();
if (ready !== false) {
timerRef.current = setTimeout(function() {
fetchInstance.setState({
loading: true
});
}, loadingDelay);
}
return {
loading: false
};
},
onFinally: function() {
cancelTimeout();
},
onCancel: function() {
cancelTimeout();
}
};
};
const useLoadingDelayPlugin$1 = useLoadingDelayPlugin;
var isBrowser = !!(typeof window !== "undefined" && window.document && window.document.createElement);
function isDocumentVisible() {
if (isBrowser) {
return document.visibilityState !== "hidden";
}
return true;
}
var listeners$1 = [];
function subscribe$1(listener) {
listeners$1.push(listener);
return function unsubscribe() {
var index = listeners$1.indexOf(listener);
listeners$1.splice(index, 1);
};
}
if (isBrowser) {
var revalidate$1 = function() {
if (!isDocumentVisible())
return;
for (var i2 = 0; i2 < listeners$1.length; i2++) {
var listener = listeners$1[i2];
listener();
}
};
window.addEventListener("visibilitychange", revalidate$1, false);
}
var usePollingPlugin = function(fetchInstance, _a) {
var pollingInterval = _a.pollingInterval, _b = _a.pollingWhenHidden, pollingWhenHidden = _b === void 0 ? true : _b, _c = _a.pollingErrorRetryCount, pollingErrorRetryCount = _c === void 0 ? -1 : _c;
var timerRef = React.useRef();
var unsubscribeRef = React.useRef();
var countRef = React.useRef(0);
var stopPolling = function() {
var _a2;
if (timerRef.current) {
clearTimeout(timerRef.current);
}
(_a2 = unsubscribeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(unsubscribeRef);
};
useUpdateEffect(function() {
if (!pollingInterval) {
stopPolling();
}
}, [pollingInterval]);
if (!pollingInterval) {
return {};
}
return {
onBefore: function() {
stopPolling();
},
onError: function() {
countRef.current += 1;
},
onSuccess: function() {
countRef.current = 0;
},
onFinally: function() {
if (pollingErrorRetryCount === -1 || // When an error occurs, the request is not repeated after pollingErrorRetryCount retries
pollingErrorRetryCount !== -1 && countRef.current <= pollingErrorRetryCount) {
timerRef.current = setTimeout(function() {
if (!pollingWhenHidden && !isDocumentVisible()) {
unsubscribeRef.current = subscribe$1(function() {
fetchInstance.refresh();
});
} else {
fetchInstance.refresh();
}
}, pollingInterval);
} else {
countRef.current = 0;
}
},
onCancel: function() {
stopPolling();
}
};
};
const usePollingPlugin$1 = usePollingPlugin;
function limit(fn, timespan) {
var pending = false;
return function() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (pending)
return;
pending = true;
fn.apply(void 0, __spreadArray([], __read(args), false));
setTimeout(function() {
pending = false;
}, timespan);
};
}
function isOnline() {
if (isBrowser && typeof navigator.onLine !== "undefined") {
return navigator.onLine;
}
return true;
}
var listeners = [];
function subscribe(listener) {
listeners.push(listener);
return function unsubscribe() {
var index = listeners.indexOf(listener);
if (index > -1) {
listeners.splice(index, 1);
}
};
}
if (isBrowser) {
var revalidate = function() {
if (!isDocumentVisible() || !isOnline())
return;
for (var i2 = 0; i2 < listeners.length; i2++) {
var listener = listeners[i2];
listener();
}
};
window.addEventListener("visibilitychange", revalidate, false);
window.addEventListener("focus", revalidate, false);
}
var useRefreshOnWindowFocusPlugin = function(fetchInstance, _a) {
var refreshOnWindowFocus = _a.refreshOnWindowFocus, _b = _a.focusTimespan, focusTimespan = _b === void 0 ? 5e3 : _b;
var unsubscribeRef = React.useRef();
var stopSubscribe = function() {
var _a2;
(_a2 = unsubscribeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(unsubscribeRef);
};
React.useEffect(function() {
if (refreshOnWindowFocus) {
var limitRefresh_1 = limit(fetchInstance.refresh.bind(fetchInstance), focusTimespan);
unsubscribeRef.current = subscribe(function() {
limitRefresh_1();
});
}
return function() {
stopSubscribe();
};
}, [refreshOnWindowFocus, focusTimespan]);
useUnmount(function() {
stopSubscribe();
});
return {};
};
const useRefreshOnWindowFocusPlugin$1 = useRefreshOnWindowFocusPlugin;
var useRetryPlugin = function(fetchInstance, _a) {
var retryInterval = _a.retryInterval, retryCount = _a.retryCount;
var timerRef = React.useRef();
var countRef = React.useRef(0);
var triggerByRetry = React.useRef(false);
if (!retryCount) {
return {};
}
return {
onBefore: function() {
if (!triggerByRetry.current) {
countRef.current = 0;
}
triggerByRetry.current = false;
if (timerRef.current) {
clearTimeout(timerRef.current);
}
},
onSuccess: function() {
countRef.current = 0;
},
onError: function() {
countRef.current += 1;
if (retryCount === -1 || countRef.current <= retryCount) {
var timeout2 = retryInterval !== null && retryInterval !== void 0 ? retryInterval : Math.min(1e3 * Math.pow(2, countRef.current), 3e4);
timerRef.current = setTimeout(function() {
triggerByRetry.current = true;
fetchInstance.refresh();
}, timeout2);
} else {
countRef.current = 0;
}
},
onCancel: function() {
countRef.current = 0;
if (timerRef.current) {
clearTimeout(timerRef.current);
}
}
};
};
const useRetryPlugin$1 = useRetryPlugin;
var debounce = debounce_1, isObject$1 = isObject_1;
var FUNC_ERROR_TEXT = "Expected a function";
function throttle(func, wait, options) {
var leading = true, trailing = true;
if (typeof func != "function") {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (isObject$1(options)) {
leading = "leading" in options ? !!options.leading : leading;
trailing = "trailing" in options ? !!options.trailing : trailing;
}
return debounce(func, wait, {
"leading": leading,
"maxWait": wait,
"trailing": trailing
});
}
var throttle_1 = throttle;
const throttle$1 = /* @__PURE__ */ getDefaultExportFromCjs(throttle_1);
var useThrottlePlugin = function(fetchInstance, _a) {
var throttleWait = _a.throttleWait, throttleLeading = _a.throttleLeading, throttleTrailing = _a.throttleTrailing;
var throttledRef = React.useRef();
var options = {};
if (throttleLeading !== void 0) {
options.leading = throttleLeading;
}
if (throttleTrailing !== void 0) {
options.trailing = throttleTrailing;
}
React.useEffect(function() {
if (throttleWait) {
var _originRunAsync_1 = fetchInstance.runAsync.bind(fetchInstance);
throttledRef.current = throttle$1(function(callback) {
callback();
}, throttleWait, options);
fetchInstance.runAsync = function() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new Promise(function(resolve, reject) {
var _a2;
(_a2 = throttledRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(throttledRef, function() {
_originRunAsync_1.apply(void 0, __spreadArray([], __read(args), false)).then(resolve).catch(reject);
});
});
};
return function() {
var _a2;
fetchInstance.runAsync = _originRunAsync_1;
(_a2 = throttledRef.current) === null || _a2 === void 0 ? void 0 : _a2.cancel();
};
}
}, [throttleWait, throttleLeading, throttleTrailing]);
if (!throttleWait) {
return {};
}
return {
onCancel: function() {
var _a2;
(_a2 = throttledRef.current) === null || _a2 === void 0 ? void 0 : _a2.cancel();
}
};
};
const useThrottlePlugin$1 = useThrottlePlugin;
var useMount = function(fn) {
React.useEffect(function() {
fn === null || fn === void 0 ? void 0 : fn();
}, []);
};
var useUpdate = function() {
var _a = __read(React.useState({}), 2), setState = _a[1];
return React.useCallback(function() {
return setState({});
}, []);
};
var Fetch = (
/** @class */
function() {
function Fetch2(serviceRef, options, subscribe2, initState) {
if (initState === void 0) {
initState = {};
}
this.serviceRef = serviceRef;
this.options = options;
this.subscribe = subscribe2;
this.initState = initState;
this.count = 0;
this.state = {
loading: false,
params: void 0,
data: void 0,
error: void 0
};
this.state = __assign(__assign(__assign({}, this.state), {
loading: !options.manual
}), initState);
}
Fetch2.prototype.setState = function(s2) {
if (s2 === void 0) {
s2 = {};
}
this.state = __assign(__assign({}, this.state), s2);
this.subscribe();
};
Fetch2.prototype.runPluginHandler = function(event) {
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
var r2 = this.pluginImpls.map(function(i2) {
var _a;
return (_a = i2[event]) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([i2], __read(rest), false));
}).filter(Boolean);
return Object.assign.apply(Object, __spreadArray([{}], __read(r2), false));
};
Fetch2.prototype.runAsync = function() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
return __awaiter(this, void 0, void 0, function() {
var currentCount, _l, _m, stopNow, _o, returnNow, state, servicePromise, res, error_1;
var _p;
return __generator(this, function(_q) {
switch (_q.label) {
case 0:
this.count += 1;
currentCount = this.count;
_l = this.runPluginHandler("onBefore", params), _m = _l.stopNow, stopNow = _m === void 0 ? false : _m, _o = _l.returnNow, returnNow = _o === void 0 ? false : _o, state = __rest(_l, ["stopNow", "returnNow"]);
if (stopNow) {
return [2, new Promise(function() {
})];
}
this.setState(__assign({
loading: true,
params
}, state));
if (returnNow) {
return [2, Promise.resolve(state.data)];
}
(_b = (_a = this.options).onBefore) === null || _b === void 0 ? void 0 : _b.call(_a, params);
_q.label = 1;
case 1:
_q.trys.push([1, 3, , 4]);
servicePromise = this.runPluginHandler("onRequest", this.serviceRef.current, params).servicePromise;
if (!servicePromise) {
servicePromise = (_p = this.serviceRef).current.apply(_p, __spreadArray([], __read(params), false));
}
return [4, servicePromise];
case 2:
res = _q.sent();
if (currentCount !== this.count) {
return [2, new Promise(function() {
})];
}
this.setState({
data: res,
error: void 0,
loading: false
});
(_d = (_c = this.options).onSuccess) === null || _d === void 0 ? void 0 : _d.call(_c, res, params);
this.runPluginHandler("onSuccess", res, params);
(_f = (_e = this.options).onFinally) === null || _f === void 0 ? void 0 : _f.call(_e, params, res, void 0);
if (currentCount === this.count) {
this.runPluginHandler("onFinally", params, res, void 0);
}
return [2, res];
case 3:
error_1 = _q.sent();
if (currentCount !== this.count) {
return [2, new Promise(function() {
})];
}
this.setState({
error: error_1,
loading: false
});
(_h = (_g = this.options).onError) === null || _h === void 0 ? void 0 : _h.call(_g, error_1, params);
this.runPluginHandler("onError", error_1, params);
(_k = (_j = this.options).onFinally) === null || _k === void 0 ? void 0 : _k.call(_j, params, void 0, error_1);
if (currentCount === this.count) {
this.runPluginHandler("onFinally", params, void 0, error_1);
}
throw error_1;
case 4:
return [
2
/*return*/
];
}
});
});
};
Fetch2.prototype.run = function() {
var _this = this;
var params = [];
for (var _i = 0; _i < arguments.length; _i++) {
params[_i] = arguments[_i];
}
this.runAsync.apply(this, __spreadArray([], __read(params), false)).catch(function(error) {
if (!_this.options.onError) {
console.error(error);
}
});
};
Fetch2.prototype.cancel = function() {
this.count += 1;
this.setState({
loading: false
});
this.runPluginHandler("onCancel");
};
Fetch2.prototype.refresh = function() {
this.run.apply(this, __spreadArray([], __read(this.state.params || []), false));
};
Fetch2.prototype.refreshAsync = function() {
return this.runAsync.apply(this, __spreadArray([], __read(this.state.params || []), false));
};
Fetch2.prototype.mutate = function(data) {
var targetData = isFunction2(data) ? data(this.state.data) : data;
this.runPluginHandler("onMutate", targetData);
this.setState({
data: targetData
});
};
return Fetch2;
}()
);
const Fetch$1 = Fetch;
function useRequestImplement(service, options, plugins) {
if (options === void 0) {
options = {};
}
if (plugins === void 0) {
plugins = [];
}
var _a = options.manual, manual = _a === void 0 ? false : _a, rest = __rest(options, ["manual"]);
var fetchOptions = __assign({
manual
}, rest);
var serviceRef = useLatest(service);
var update = useUpdate();
var fetchInstance = useCreation(function() {
var initState = plugins.map(function(p2) {
var _a2;
return (_a2 = p2 === null || p2 === void 0 ? void 0 : p2.onInit) === null || _a2 === void 0 ? void 0 : _a2.call(p2, fetchOptions);
}).filter(Boolean);
return new Fetch$1(serviceRef, fetchOptions, update, Object.assign.apply(Object, __spreadArray([{}], __read(initState), false)));
}, []);
fetchInstance.options = fetchOptions;
fetchInstance.pluginImpls = plugins.map(function(p2) {
return p2(fetchInstance, fetchOptions);
});
useMount(function() {
if (!manual) {
var params = fetchInstance.state.params || options.defaultParams || [];
fetchInstance.run.apply(fetchInstance, __spreadArray([], __read(params), false));
}
});
useUnmount(function() {
fetchInstance.cancel();
});
return {
loading: fetchInstance.state.loading,
data: fetchInstance.state.data,
error: fetchInstance.state.error,
params: fetchInstance.state.params || [],
cancel: useMemoizedFn(fetchInstance.cancel.bind(fetchInstance)),
refresh: useMemoizedFn(fetchInstance.refresh.bind(fetchInstance)),
refreshAsync: useMemoizedFn(fetchInstance.refreshAsync.bind(fetchInstance)),
run: useMemoizedFn(fetchInstance.run.bind(fetchInstance)),
runAsync: useMemoizedFn(fetchInstance.runAsync.bind(fetchInstance)),
mutate: useMemoizedFn(fetchInstance.mutate.bind(fetchInstance))
};
}
function useRequest(service, options, plugins) {
return useRequestImplement(service, options, __spreadArray(__spreadArray([], __read(plugins || []), false), [useDebouncePlugin$1, useLoadingDelayPlugin$1, usePollingPlugin$1, useRefreshOnWindowFocusPlugin$1, useThrottlePlugin$1, useAutoRunPlugin$1, useCachePlugin$1, useRetryPlugin$1], false));
}
var s = 1e3;
var m$1 = s * 60;
var h = m$1 * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
var ms = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match2) {
return;
}
var n2 = parseFloat(match2[1]);
var type = (match2[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n2 * y;
case "weeks":
case "week":
case "w":
return n2 * w;
case "days":
case "day":
case "d":
return n2 * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n2 * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n2 * m$1;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n2 * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n2;
default:
return void 0;
}
}
function fmtShort(ms2) {
var msAbs = Math.abs(ms2);
if (msAbs >= d) {
return Math.round(ms2 / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms2 / h) + "h";
}
if (msAbs >= m$1) {
return Math.round(ms2 / m$1) + "m";
}
if (msAbs >= s) {
return Math.round(ms2 / s) + "s";
}
return ms2 + "ms";
}
function fmtLong(ms2) {
var msAbs = Math.abs(ms2);
if (msAbs >= d) {
return plural(ms2, msAbs, d, "day");
}
if (msAbs >= h) {
return plural(ms2, msAbs, h, "hour");
}
if (msAbs >= m$1) {
return plural(ms2, msAbs, m$1, "minute");
}
if (msAbs >= s) {
return plural(ms2, msAbs, s, "second");
}
return ms2 + " ms";
}
function plural(ms2, msAbs, n2, name) {
var isPlural = msAbs >= n2 * 1.5;
return Math.round(ms2 / n2) + " " + name + (isPlural ? "s" : "");
}
const ms$1 = /* @__PURE__ */ getDefaultExportFromCjs(ms);
async function _fetchFromWhatslink(magnetUrl) {
const res = await request.get("https://whatslink.info/api/v1/link", {
params: {
url: magnetUrl
}
});
const json = res.data;
return json;
}
const db = createDBWithTable("whatslink");
const CACHE_TTL = ms$1("1d");
async function getFromWhatslink(magnetUrl) {
const cacheKey = magnetUrl;
{
const item = await db.getItem(cacheKey);
if (item && item.ts && item.json) {
if (Date.now() - item.ts < CACHE_TTL) {
return item.json;
}
}
}
const json = await _fetchFromWhatslink(magnetUrl);
if (!json || json.error) {
antd.message.error((json == null ? void 0 : json.error) || "未知错误");
return;
}
await db.setItem(cacheKey, { json, ts: Date.now() });
return json;
}
async function showPreviewImgs(magnetUrl, magnetTitle, getExtraImgs) {
const fromWhatslink = async () => {
const json = await getFromWhatslink(magnetUrl);
if (!json)
return [];
const imgs = (json.screenshots || []).map((s2) => s2.screenshot);
return imgs.map((src2) => ({ src: src2, caption: `${magnetTitle}${" ".repeat(2)} (来源: whatslink.info)` }));
};
const fromExtraImgs = async () => {
const srcs = await (getExtraImgs == null ? void 0 : getExtraImgs()) || [];
return srcs.map((src2) => ({ src: src2, caption: `${magnetTitle}${" ".repeat(2)} (来源: 详情页)` }));
};
const [whatslinkImgs, extraImgs] = await Promise.all([fromWhatslink(), fromExtraImgs()]);
const imgSrcs = [whatslinkImgs, extraImgs].flat().filter(Boolean);
if (!imgSrcs.length) {
antd.message.warning("没有找到图片", 1.5);
return;
}
const msg = [
`从 whatslink.info 找到 ${whatslinkImgs.length} 张图片`,
!!getExtraImgs && `详情页找到 ${extraImgs.length} 张图片`
].filter(Boolean).join(", ");
antd.message.info(msg);
Oe.show(imgSrcs, {
caption: magnetTitle,
wheel: "pan",
Thumbs: {
type: "classic"
},
Toolbar: {
display: {
left: ["infobar"],
middle: ["zoomIn", "zoomOut", "toggle1to1", "rotateCCW", "rotateCW", "flipX", "flipY"],
right: ["slideshow", "thumbs", "close"]
}
}
});
}
function PreviewIcon({
magnetUrl,
magnetTitle,
iconComponent,
iconProps,
getExtraImgs
}) {
const { loading, runAsync } = useRequest(() => showPreviewImgs(magnetUrl, magnetTitle, getExtraImgs), {
manual: true,
cacheTime: 864e8,
cacheKey: magnetUrl
});
const IconComponent = iconComponent || Picture;
return jsx(
"div",
{
css: css$1`
display: inline-flex;
padding: 5px;
margin-right: 4px;
cursor: pointer;
`,
onClick: async () => {
if (loading)
return;
return runAsync();
},
children: jsx(
IconComponent,
{
theme: "outline",
size: "18",
spin: loading,
...iconProps,
css: css$1`
margin: 0 !important;
`
}
)
}
);
}
var createRoot;
var m = require$$0;
{
createRoot = m.createRoot;
m.hydrateRoot;
}
var hyphenateRegex = /[A-Z]|^ms/g;
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
var isCustomProperty = function isCustomProperty22(property) {
return property.charCodeAt(1) === 45;
};
var isProcessableValue = function isProcessableValue22(value) {
return value != null && typeof value !== "boolean";
};
var processStyleName = /* @__PURE__ */ memoize(function(styleName) {
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
});
var processStyleValue = function processStyleValue22(key, value) {
switch (key) {
case "animation":
case "animationName": {
if (typeof value === "string") {
return value.replace(animationRegex, function(match2, p1, p2) {
cursor = {
name: p1,
styles: p2,
next: cursor
};
return p1;
});
}
}
}
if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) {
return value + "px";
}
return value;
};
var noComponentSelectorMessage = "Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";
function handleInterpolation(mergedProps, registered, interpolation) {
if (interpolation == null) {
return "";
}
if (interpolation.__emotion_styles !== void 0) {
return interpolation;
}
switch (typeof interpolation) {
case "boolean": {
return "";
}
case "object": {
if (interpolation.anim === 1) {
cursor = {
name: interpolation.name,
styles: interpolation.styles,
next: cursor
};
return interpolation.name;
}
if (interpolation.styles !== void 0) {
var next2 = interpolation.next;
if (next2 !== void 0) {
while (next2 !== void 0) {
cursor = {
name: next2.name,
styles: next2.styles,
next: cursor
};
next2 = next2.next;
}
}
var styles = interpolation.styles + ";";
return styles;
}
return createStringFromObject(mergedProps, registered, interpolation);
}
case "function": {
if (mergedProps !== void 0) {
var previousCursor = cursor;
var result = interpolation(mergedProps);
cursor = previousCursor;
return handleInterpolation(mergedProps, registered, result);
}
break;
}
}
if (registered == null) {
return interpolation;
}
var cached = registered[interpolation];
return cached !== void 0 ? cached : interpolation;
}
function createStringFromObject(mergedProps, registered, obj) {
var string = "";
if (Array.isArray(obj)) {
for (var i2 = 0; i2 < obj.length; i2++) {
string += handleInterpolation(mergedProps, registered, obj[i2]) + ";";
}
} else {
for (var _key in obj) {
var value = obj[_key];
if (typeof value !== "object") {
if (registered != null && registered[value] !== void 0) {
string += _key + "{" + registered[value] + "}";
} else if (isProcessableValue(value)) {
string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
}
} else {
if (_key === "NO_COMPONENT_SELECTOR" && false) {
throw new Error(noComponentSelectorMessage);
}
if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
for (var _i = 0; _i < value.length; _i++) {
if (isProcessableValue(value[_i])) {
string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
}
}
} else {
var interpolated = handleInterpolation(mergedProps, registered, value);
switch (_key) {
case "animation":
case "animationName": {
string += processStyleName(_key) + ":" + interpolated + ";";
break;
}
default: {
string += _key + "{" + interpolated + "}";
}
}
}
}
}
}
return string;
}
var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
var cursor;
var serializeStyles = function serializeStyles22(args, registered, mergedProps) {
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
return args[0];
}
var stringMode = true;
var styles = "";
cursor = void 0;
var strings = args[0];
if (strings == null || strings.raw === void 0) {
stringMode = false;
styles += handleInterpolation(mergedProps, registered, strings);
} else {
styles += strings[0];
}
for (var i2 = 1; i2 < args.length; i2++) {
styles += handleInterpolation(mergedProps, registered, args[i2]);
if (stringMode) {
styles += strings[i2];
}
}
labelPattern.lastIndex = 0;
var identifierName = "";
var match2;
while ((match2 = labelPattern.exec(styles)) !== null) {
identifierName += "-" + // $FlowFixMe we know it's not null
match2[1];
}
var name = murmur2(styles) + identifierName;
return {
name,
styles,
next: cursor
};
};
function insertWithoutScoping(cache2, serialized) {
if (cache2.inserted[serialized.name] === void 0) {
return cache2.insert("", serialized, cache2.sheet, true);
}
}
function merge(registered, css2, className) {
var registeredStyles = [];
var rawClassName = getRegisteredStyles(registered, registeredStyles, className);
if (registeredStyles.length < 2) {
return className;
}
return rawClassName + css2(registeredStyles);
}
var createEmotion = function createEmotion2(options) {
var cache2 = createCache(options);
cache2.sheet.speedy = function(value) {
this.isSpeedy = value;
};
cache2.compat = true;
var css2 = function css22() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var serialized = serializeStyles(args, cache2.registered, void 0);
insertStyles(cache2, serialized, false);
return cache2.key + "-" + serialized.name;
};
var keyframes = function keyframes2() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var serialized = serializeStyles(args, cache2.registered);
var animation = "animation-" + serialized.name;
insertWithoutScoping(cache2, {
name: serialized.name,
styles: "@keyframes " + animation + "{" + serialized.styles + "}"
});
return animation;
};
var injectGlobal = function injectGlobal2() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
var serialized = serializeStyles(args, cache2.registered);
insertWithoutScoping(cache2, serialized);
};
var cx = function cx2() {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
return merge(cache2.registered, css2, classnames(args));
};
return {
css: css2,
cx,
injectGlobal,
keyframes,
hydrate: function hydrate(ids) {
ids.forEach(function(key) {
cache2.inserted[key] = true;
});
},
flush: function flush() {
cache2.registered = {};
cache2.inserted = {};
cache2.sheet.flush();
},
// $FlowFixMe
sheet: cache2.sheet,
cache: cache2,
getRegisteredStyles: getRegisteredStyles.bind(null, cache2.registered),
merge: merge.bind(null, cache2.registered, css2)
};
};
var classnames = function classnames2(args) {
var cls = "";
for (var i2 = 0; i2 < args.length; i2++) {
var arg = args[i2];
if (arg == null)
continue;
var toAdd = void 0;
switch (typeof arg) {
case "boolean":
break;
case "object": {
if (Array.isArray(arg)) {
toAdd = classnames2(arg);
} else {
toAdd = "";
for (var k2 in arg) {
if (arg[k2] && k2) {
toAdd && (toAdd += " ");
toAdd += k2;
}
}
}
break;
}
default: {
toAdd = arg;
}
}
if (toAdd) {
cls && (cls += " ");
cls += toAdd;
}
}
return cls;
};
var _createEmotion = createEmotion({
key: "css"
}), css = _createEmotion.css;
const styled = { generateClassName: css };
class HTTPError extends Error {
constructor(response, request2, options) {
const code = response.status || response.status === 0 ? response.status : "";
const title = response.statusText || "";
const status = `${code} ${title}`.trim();
const reason = status ? `status code ${status}` : "an unknown error";
super(`Request failed with ${reason}`);
Object.defineProperty(this, "response", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "request", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "options", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.name = "HTTPError";
this.response = response;
this.request = request2;
this.options = options;
}
}
class TimeoutError extends Error {
constructor(request2) {
super("Request timed out");
Object.defineProperty(this, "request", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.name = "TimeoutError";
this.request = request2;
}
}
const isObject2 = (value) => value !== null && typeof value === "object";
const validateAndMerge = (...sources) => {
for (const source of sources) {
if ((!isObject2(source) || Array.isArray(source)) && source !== void 0) {
throw new TypeError("The `options` argument must be an object");
}
}
return deepMerge({}, ...sources);
};
const mergeHeaders = (source1 = {}, source2 = {}) => {
const result = new globalThis.Headers(source1);
const isHeadersInstance = source2 instanceof globalThis.Headers;
const source = new globalThis.Headers(source2);
for (const [key, value] of source.entries()) {
if (isHeadersInstance && value === "undefined" || value === void 0) {
result.delete(key);
} else {
result.set(key, value);
}
}
return result;
};
const deepMerge = (...sources) => {
let returnValue = {};
let headers = {};
for (const source of sources) {
if (Array.isArray(source)) {
if (!Array.isArray(returnValue)) {
returnValue = [];
}
returnValue = [...returnValue, ...source];
} else if (isObject2(source)) {
for (let [key, value] of Object.entries(source)) {
if (isObject2(value) && key in returnValue) {
value = deepMerge(returnValue[key], value);
}
returnValue = { ...returnValue, [key]: value };
}
if (isObject2(source.headers)) {
headers = mergeHeaders(headers, source.headers);
returnValue.headers = headers;
}
}
}
return returnValue;
};
const supportsRequestStreams = (() => {
let duplexAccessed = false;
let hasContentType = false;
const supportsReadableStream = typeof globalThis.ReadableStream === "function";
const supportsRequest = typeof globalThis.Request === "function";
if (supportsReadableStream && supportsRequest) {
hasContentType = new globalThis.Request("https://empty.invalid", {
body: new globalThis.ReadableStream(),
method: "POST",
// @ts-expect-error - Types are outdated.
get duplex() {
duplexAccessed = true;
return "half";
}
}).headers.has("Content-Type");
}
return duplexAccessed && !hasContentType;
})();
const supportsAbortController = typeof globalThis.AbortController === "function";
const supportsResponseStreams = typeof globalThis.ReadableStream === "function";
const supportsFormData = typeof globalThis.FormData === "function";
const requestMethods = ["get", "post", "put", "patch", "head", "delete"];
const responseTypes = {
json: "application/json",
text: "text/*",
formData: "multipart/form-data",
arrayBuffer: "*/*",
blob: "*/*"
};
const maxSafeTimeout = 2147483647;
const stop = Symbol("stop");
const kyOptionKeys = {
json: true,
parseJson: true,
searchParams: true,
prefixUrl: true,
retry: true,
timeout: true,
hooks: true,
throwHttpErrors: true,
onDownloadProgress: true,
fetch: true
};
const requestOptionsRegistry = {
method: true,
headers: true,
body: true,
mode: true,
credentials: true,
cache: true,
redirect: true,
referrer: true,
referrerPolicy: true,
integrity: true,
keepalive: true,
signal: true,
window: true,
dispatcher: true,
duplex: true,
priority: true
};
const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
const retryMethods = ["get", "put", "head", "delete", "options", "trace"];
const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
const retryAfterStatusCodes = [413, 429, 503];
const defaultRetryOptions = {
limit: 2,
methods: retryMethods,
statusCodes: retryStatusCodes,
afterStatusCodes: retryAfterStatusCodes,
maxRetryAfter: Number.POSITIVE_INFINITY,
backoffLimit: Number.POSITIVE_INFINITY,
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1e3
};
const normalizeRetryOptions = (retry = {}) => {
if (typeof retry === "number") {
return {
...defaultRetryOptions,
limit: retry
};
}
if (retry.methods && !Array.isArray(retry.methods)) {
throw new Error("retry.methods must be an array");
}
if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {
throw new Error("retry.statusCodes must be an array");
}
return {
...defaultRetryOptions,
...retry,
afterStatusCodes: retryAfterStatusCodes
};
};
async function timeout(request2, init, abortController, options) {
return new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
if (abortController) {
abortController.abort();
}
reject(new TimeoutError(request2));
}, options.timeout);
void options.fetch(request2, init).then(resolve).catch(reject).then(() => {
clearTimeout(timeoutId);
});
});
}
async function delay(ms2, { signal }) {
return new Promise((resolve, reject) => {
if (signal) {
signal.throwIfAborted();
signal.addEventListener("abort", abortHandler, { once: true });
}
function abortHandler() {
clearTimeout(timeoutId);
reject(signal.reason);
}
const timeoutId = setTimeout(() => {
signal == null ? void 0 : signal.removeEventListener("abort", abortHandler);
resolve();
}, ms2);
});
}
const findUnknownOptions = (request2, options) => {
const unknownOptions = {};
for (const key in options) {
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request2)) {
unknownOptions[key] = options[key];
}
}
return unknownOptions;
};
class Ky {
static create(input, options) {
const ky2 = new Ky(input, options);
const function_ = async () => {
if (typeof ky2._options.timeout === "number" && ky2._options.timeout > maxSafeTimeout) {
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
}
await Promise.resolve();
let response = await ky2._fetch();
for (const hook of ky2._options.hooks.afterResponse) {
const modifiedResponse = await hook(ky2.request, ky2._options, ky2._decorateResponse(response.clone()));
if (modifiedResponse instanceof globalThis.Response) {
response = modifiedResponse;
}
}
ky2._decorateResponse(response);
if (!response.ok && ky2._options.throwHttpErrors) {
let error = new HTTPError(response, ky2.request, ky2._options);
for (const hook of ky2._options.hooks.beforeError) {
error = await hook(error);
}
throw error;
}
if (ky2._options.onDownloadProgress) {
if (typeof ky2._options.onDownloadProgress !== "function") {
throw new TypeError("The `onDownloadProgress` option must be a function");
}
if (!supportsResponseStreams) {
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
}
return ky2._stream(response.clone(), ky2._options.onDownloadProgress);
}
return response;
};
const isRetriableMethod = ky2._options.retry.methods.includes(ky2.request.method.toLowerCase());
const result = isRetriableMethod ? ky2._retry(function_) : function_();
for (const [type, mimeType] of Object.entries(responseTypes)) {
result[type] = async () => {
ky2.request.headers.set("accept", ky2.request.headers.get("accept") || mimeType);
const awaitedResult = await result;
const response = awaitedResult.clone();
if (type === "json") {
if (response.status === 204) {
return "";
}
const arrayBuffer = await response.clone().arrayBuffer();
const responseSize = arrayBuffer.byteLength;
if (responseSize === 0) {
return "";
}
if (options.parseJson) {
return options.parseJson(await response.text());
}
}
return response[type]();
};
}
return result;
}
// eslint-disable-next-line complexity
constructor(input, options = {}) {
Object.defineProperty(this, "request", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "abortController", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_retryCount", {
enumerable: true,
configurable: true,
writable: true,
value: 0
});
Object.defineProperty(this, "_input", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "_options", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this._input = input;
const credentials = this._input instanceof Request && "credentials" in Request.prototype ? this._input.credentials : void 0;
this._options = {
...credentials && { credentials },
// For exactOptionalPropertyTypes
...options,
headers: mergeHeaders(this._input.headers, options.headers),
hooks: deepMerge({
beforeRequest: [],
beforeRetry: [],
beforeError: [],
afterResponse: []
}, options.hooks),
method: normalizeRequestMethod(options.method ?? this._input.method),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
prefixUrl: String(options.prefixUrl || ""),
retry: normalizeRetryOptions(options.retry),
throwHttpErrors: options.throwHttpErrors !== false,
timeout: options.timeout ?? 1e4,
fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
};
if (typeof this._input !== "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
throw new TypeError("`input` must be a string, URL, or Request");
}
if (this._options.prefixUrl && typeof this._input === "string") {
if (this._input.startsWith("/")) {
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
}
if (!this._options.prefixUrl.endsWith("/")) {
this._options.prefixUrl += "/";
}
this._input = this._options.prefixUrl + this._input;
}
if (supportsAbortController) {
this.abortController = new globalThis.AbortController();
if (this._options.signal) {
const originalSignal = this._options.signal;
this._options.signal.addEventListener("abort", () => {
this.abortController.abort(originalSignal.reason);
});
}
this._options.signal = this.abortController.signal;
}
if (supportsRequestStreams) {
this._options.duplex = "half";
}
this.request = new globalThis.Request(this._input, this._options);
if (this._options.searchParams) {
const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString();
const searchParams = "?" + textSearchParams;
const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
if ((supportsFormData && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"])) {
this.request.headers.delete("content-type");
}
this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
}
if (this._options.json !== void 0) {
this._options.body = JSON.stringify(this._options.json);
this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json");
this.request = new globalThis.Request(this.request, { body: this._options.body });
}
}
_calculateRetryDelay(error) {
this._retryCount++;
if (this._retryCount <= this._options.retry.limit && !(error instanceof TimeoutError)) {
if (error instanceof HTTPError) {
if (!this._options.retry.statusCodes.includes(error.response.status)) {
return 0;
}
const retryAfter = error.response.headers.get("Retry-After");
if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {
let after = Number(retryAfter);
if (Number.isNaN(after)) {
after = Date.parse(retryAfter) - Date.now();
} else {
after *= 1e3;
}
if (this._options.retry.maxRetryAfter !== void 0 && after > this._options.retry.maxRetryAfter) {
return 0;
}
return after;
}
if (error.response.status === 413) {
return 0;
}
}
const retryDelay = this._options.retry.delay(this._retryCount);
return Math.min(this._options.retry.backoffLimit, retryDelay);
}
return 0;
}
_decorateResponse(response) {
if (this._options.parseJson) {
response.json = async () => this._options.parseJson(await response.text());
}
return response;
}
async _retry(function_) {
try {
return await function_();
} catch (error) {
const ms2 = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
if (ms2 !== 0 && this._retryCount > 0) {
await delay(ms2, { signal: this._options.signal });
for (const hook of this._options.hooks.beforeRetry) {
const hookResult = await hook({
request: this.request,
options: this._options,
error,
retryCount: this._retryCount
});
if (hookResult === stop) {
return;
}
}
return this._retry(function_);
}
throw error;
}
}
async _fetch() {
for (const hook of this._options.hooks.beforeRequest) {
const result = await hook(this.request, this._options);
if (result instanceof Request) {
this.request = result;
break;
}
if (result instanceof Response) {
return result;
}
}
const nonRequestOptions = findUnknownOptions(this.request, this._options);
if (this._options.timeout === false) {
return this._options.fetch(this.request.clone(), nonRequestOptions);
}
return timeout(this.request.clone(), nonRequestOptions, this.abortController, this._options);
}
/* istanbul ignore next */
_stream(response, onDownloadProgress) {
const totalBytes = Number(response.headers.get("content-length")) || 0;
let transferredBytes = 0;
if (response.status === 204) {
if (onDownloadProgress) {
onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
}
return new globalThis.Response(null, {
status: response.status,
statusText: response.statusText,
headers: response.headers
});
}
return new globalThis.Response(new globalThis.ReadableStream({
async start(controller) {
const reader = response.body.getReader();
if (onDownloadProgress) {
onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());
}
async function read() {
const { done, value } = await reader.read();
if (done) {
controller.close();
return;
}
if (onDownloadProgress) {
transferredBytes += value.byteLength;
const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
onDownloadProgress({ percent, transferredBytes, totalBytes }, value);
}
controller.enqueue(value);
await read();
}
await read();
}
}), {
status: response.status,
statusText: response.statusText,
headers: response.headers
});
}
}
/*! MIT License © Sindre Sorhus */
const createInstance = (defaults) => {
const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
for (const method of requestMethods) {
ky2[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
}
ky2.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
ky2.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));
ky2.stop = stop;
return ky2;
};
const ky = createInstance();
var src = { exports: {} };
var worker = function mapOnWorker(arr, fn, workers) {
return new Promise(function(resolve, reject) {
var completed = 0;
var started = 0;
var running = 0;
var results = new Array(arr.length).fill(void 0);
var rejected = false;
var workerIsUnsing = /* @__PURE__ */ new WeakMap();
var getWorker = function(index) {
for (var i2 = 0; i2 < workers.length; i2++) {
var worker2 = workers[i2];
if (workerIsUnsing.get(worker2)) {
continue;
} else {
workerIsUnsing.set(worker2, index);
return worker2;
}
}
};
function start(index) {
var cur = arr[index];
var worker2 = getWorker(index);
Promise.resolve(fn.call(cur, cur, index, arr, worker2)).then(function(result) {
workerIsUnsing.delete(worker2);
running--;
results[index] = result;
completed++;
replenish();
}).catch(function(err) {
rejected = true;
reject(err);
});
}
function replenish() {
if (rejected)
return;
if (completed >= arr.length) {
return resolve(results);
}
while (running < workers.length && started < arr.length) {
start(started);
started++;
running++;
}
}
replenish();
});
};
src.exports = function pmap(arr, fn, concurrency) {
concurrency = concurrency || Infinity;
if (typeof concurrency !== "number") {
throw new TypeError(String(concurrency) + " is not a number");
}
return new Promise(function(resolve, reject) {
var completed = 0;
var started = 0;
var running = 0;
var results = new Array(arr.length).fill(void 0);
var rejected = false;
function start(index) {
var cur = arr[index];
Promise.resolve(fn.call(cur, cur, index, arr)).then(function(result) {
running--;
completed++;
results[index] = result;
replenish();
}).catch(function(err) {
rejected = true;
reject(err);
});
}
function replenish() {
if (rejected)
return;
if (completed >= arr.length) {
return resolve(results);
}
while (running < concurrency && started < arr.length) {
start(started);
running++;
started++;
}
}
replenish();
});
};
var pmapWorker = worker;
src.exports.pmapWorker = pmapWorker;
var srcExports = src.exports;
const pmap2 = /* @__PURE__ */ getDefaultExportFromCjs(srcExports);
class AbstractAdapter {
constructor() {
__publicField(this, "iconComponent");
__publicField(this, "iconProps");
__publicField(this, "getExtraImgsFactory");
}
}
const vCenter = styled.generateClassName`
display: inline-flex;
align-items: center;
`;
class Yhg extends AbstractAdapter {
constructor() {
super(...arguments);
__publicField(this, "domain", "yhg007.com");
__publicField(this, "magnetItemsSelector", ".tbox > .ssbox");
__publicField(this, "getMagnetUrl", (itemEl) => {
var _a;
return ((_a = this._getMagnetLinkEl(itemEl)) == null ? void 0 : _a.href) || "";
});
__publicField(this, "getMagnetTitle", (itemEl) => {
var _a;
return ((_a = itemEl.querySelector(":scope > .title")) == null ? void 0 : _a.innerText.trim()) || "";
});
__publicField(this, "iconProps", { size: 15 });
__publicField(this, "insertPreviewIcon", (itemEl, rcEl) => {
var _a;
const a2 = this._getMagnetLinkEl(itemEl);
(_a = a2 == null ? void 0 : a2.closest(".sbar")) == null ? void 0 : _a.classList.add(vCenter);
rcEl.classList.add(
vCenter,
styled.generateClassName`
margin: 0 !important;
`
);
const span = a2 == null ? void 0 : a2.closest("span");
span == null ? void 0 : span.insertAdjacentElement("afterend", rcEl);
});
}
_getMagnetLinkEl(itemEl) {
return itemEl.querySelector(`:scope > .sbar a[href^="magnet:"]`);
}
}
class Btdig extends AbstractAdapter {
constructor() {
super(...arguments);
__publicField(this, "domain", "btdig.com");
__publicField(this, "magnetItemsSelector", ".one_result");
__publicField(this, "getMagnetUrl", (itemEl) => {
var _a;
return ((_a = this._getMagnetLinkEl(itemEl)) == null ? void 0 : _a.href) || "";
});
__publicField(this, "getMagnetTitle", (itemEl) => {
var _a;
return ((_a = itemEl.querySelector(".torrent_name")) == null ? void 0 : _a.innerText.trim()) || "";
});
__publicField(this, "iconProps", { size: 20 });
__publicField(this, "insertPreviewIcon", (itemEl, rcEl) => {
var _a;
const a2 = this._getMagnetLinkEl(itemEl);
(_a = a2 == null ? void 0 : a2.closest(".fa")) == null ? void 0 : _a.classList.add(styled.generateClassName`
display: flex;
align-items: center;
`);
rcEl.classList.add(styled.generateClassName`
margin-left: 10px;
color: #333;
`);
a2 == null ? void 0 : a2.insertAdjacentElement("afterend", rcEl);
});
}
_getMagnetLinkEl(itemEl) {
return itemEl.querySelector(`.torrent_magnet a[href^="magnet:"]`);
}
}
class U3c3 extends AbstractAdapter {
constructor() {
super(...arguments);
__publicField(this, "domain", ["u3c3.com"]);
__publicField(this, "magnetItemsSelector", `tr.default:has(a[href^='/view?id='])`);
__publicField(this, "iconProps", { size: 16 });
__publicField(this, "getMagnetUrl", (itemEl) => {
var _a;
return ((_a = this._getMagnetLinkEl(itemEl)) == null ? void 0 : _a.href) || "";
});
__publicField(this, "insertPreviewIcon", (itemEl, rcEl) => {
const a2 = this._getMagnetLinkEl(itemEl);
rcEl.classList.add(
vCenter,
styled.generateClassName`
position: relative;
top: 2px;
`
);
a2 == null ? void 0 : a2.insertAdjacentElement("afterend", rcEl);
});
__publicField(this, "getExtraImgsFactory", (itemEl) => {
var _a;
const detailUrl = (_a = itemEl.querySelector(`a[href^='/view?id=']`)) == null ? void 0 : _a.href;
return async function() {
if (!detailUrl)
return [];
const res = await request.get(detailUrl, { responseType: "text" });
const html = res.data;
const doc = new DOMParser().parseFromString(html, "text/html");
const srcs = Array.from(doc.querySelectorAll(".panel-footer > img")).map((img) => img.src);
return (await pmap2(
srcs,
async (src2) => {
const res2 = await ky.get(src2, {
mode: "no-cors",
throwHttpErrors: false
});
if (res2.status === 404)
return;
return src2;
},
10
)).filter(Boolean);
};
});
}
_getMagnetLinkEl(itemEl) {
return itemEl.querySelector(`a[href^='magnet:']`);
}
getMagnetTitle(itemEl) {
var _a;
return ((_a = itemEl.querySelector(`a[href^='/view?id=']`)) == null ? void 0 : _a.innerText.trim()) || "";
}
}
class Sukebei extends AbstractAdapter {
constructor() {
super(...arguments);
__publicField(this, "domain", ["sukebei.nyaa.si"]);
__publicField(this, "magnetItemsSelector", `tr:has(a[href^='/view/'])`);
__publicField(this, "iconProps", { size: 16 });
__publicField(this, "getMagnetUrl", (itemEl) => {
var _a;
return ((_a = this._getMagnetLinkEl(itemEl)) == null ? void 0 : _a.href) || "";
});
__publicField(this, "insertPreviewIcon", (itemEl, rcEl) => {
const a2 = this._getMagnetLinkEl(itemEl);
rcEl.classList.add(
vCenter,
styled.generateClassName`
position: relative;
top: 3px;
`
);
a2 == null ? void 0 : a2.insertAdjacentElement("afterend", rcEl);
});
__publicField(this, "getExtraImgsFactory", (itemEl) => {
var _a;
const detailUrl = (_a = itemEl.querySelector(`a[href^='/view/']`)) == null ? void 0 : _a.href;
return async function() {
var _a2;
if (!detailUrl)
return [];
const html = await getHtml(detailUrl);
const doc = new DOMParser().parseFromString(html, "text/html");
const markdownText = ((_a2 = doc.querySelector("#torrent-description")) == null ? void 0 : _a2.innerText) || "";
const reg = /\!\[[\S]+?\]\(([^)]+?)\)/g;
const matches = markdownText.matchAll(reg);
const srcs = [...matches].map((execArr) => execArr[1]);
return srcs;
};
});
}
_getMagnetLinkEl(itemEl) {
return itemEl.querySelector(`a[href^='magnet:']`);
}
getMagnetTitle(itemEl) {
var _a;
return ((_a = itemEl.querySelector(`a[href^='/view/']`)) == null ? void 0 : _a.innerText.trim()) || "";
}
}
const htmlDb = createDBWithTable("magnet-detail-html");
async function getHtml(url) {
let html = await htmlDb.getItem(url);
if (html)
return html;
const res = await request.get(url, { responseType: "text" });
html = res.data || "";
await htmlDb.setItem(url, html);
return html;
}
const adapters = [new Yhg(), new Btdig(), new U3c3(), new Sukebei()];
async function initAddPreview() {
const domain = location.host;
const adapter = adapters.find((r2) => [r2.domain].flat().includes(domain));
if (!adapter)
return;
const {
magnetItemsSelector,
getMagnetTitle,
getMagnetUrl,
insertPreviewIcon,
iconComponent,
iconProps,
getExtraImgsFactory
} = adapter;
const set = /* @__PURE__ */ new WeakSet();
function processPreview() {
const items = Array.from(document.querySelectorAll(magnetItemsSelector)).filter(
(item) => !set.has(item)
);
if (!items.length)
return;
for (const item of items) {
const magnetUrl = getMagnetUrl(item);
const magnetTitle = getMagnetTitle(item);
const getExtraImgs = getExtraImgsFactory == null ? void 0 : getExtraImgsFactory(item);
const rcEl = document.createElement("span");
insertPreviewIcon(item, rcEl);
const root2 = createRoot(rcEl);
root2.render(
jsx(
PreviewIcon,
{
magnetUrl,
magnetTitle,
iconComponent,
iconProps,
getExtraImgs
}
)
);
set.add(item);
}
}
processPreview();
const ob = new MutationObserver(() => {
processPreview();
});
ob.observe(document.body, {
subtree: true,
childList: true
});
}
main();
async function main() {
initAddPreview();
}
})(_, React, axios, antd, ReactDOM);