react-material-overlay
Version:
A fully featured Material UI implementation of overlays like modals, alert dialogs, lightboxes, and bottom sheets featuring easy stack management and browser history integration
1 lines • 251 kB
JavaScript
"use strict";var e=require("async-mutex"),t=require("react"),n=require("lodash"),r=require("clsx"),o=require("react/jsx-runtime"),i=require("@mui/material"),a=require("@emotion/react"),s=require("react-dom"),c=require("@emotion/cache");function l(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=l(t);const d=e=>"number"==typeof e&&!isNaN(e),f=e=>"string"==typeof e,h=e=>"function"==typeof e,p=e=>f(e)||d(e);function v(e){return!!e&&"object"==typeof e&&"current"in e}const m=e=>t.isValidElement(e)||f(e)||h(e)||d(e);let g=1;const y=new Map,b=[],_=new e.Mutex;function w(e,t=!1){t||y.get(e)?.(),y.delete(e)}async function x(e=1){return new Promise((t=>{window.addEventListener("popstate",(function e(n){(n.state?.rmoStackLength||0)===b.length&&(window.removeEventListener("popstate",e),t())})),window.history.go(-e)}))}"undefined"!=typeof window&&function(){const e=window.history.state?.rmoStackLength;d(e)&&e>0&&window.history.go(-e),window.addEventListener("popstate",(e=>{_.isLocked()||(e.state?.rmoStackLength||0)<b.length&&_.runExclusive((()=>{const e=b.pop();e&&w(e)}))}))}();const E={push:async e=>_.runExclusive((()=>{const t=e.id&&p(e.id)?e.id:""+g++;if(b.some((e=>e===t)))throw new Error(`The push request is duplicate with id: ${t}. \n Each push must be made with a unique id.`);return b.push(t),y.set(t,e.onPopState),window.history.pushState({...window.history.state,rmoStackLength:b.length},""),{id:t,index:b.length-1}})),pop:(e,t)=>_.runExclusive((async()=>{d(e)?(e<2&&console.warn("for multiple pops, count must be at least 2, otherwise use pop without count parameter."),await async function(e,t=!1){const n=b.splice(-Math.abs(e));0!==n.length&&(n.forEach((e=>w(e,t))),await x(n.length))}(e,t)):await async function(e){const t=b.at(-1);!t||e?.id&&e.id!==t||(b.pop(),w(t,e?.preventEventTriggering),await x())}(e)})),flush:async(e=!1)=>_.runExclusive((async()=>{const t=b.splice(0);0!==t.length&&(t.forEach((t=>w(t,e))),await x(t.length))})),findIndexById:e=>b.indexOf(e),get length(){return b.length}};let S=1;var k;!function(e){e[e.CONTAINER_ID=1]="CONTAINER_ID"}(k||(k={}));var O=Object.freeze({__proto__:null,get Default(){return k}});function C(e,r){return n.mergeWith({},e,r,((e,r,o)=>v(r)||t.isValidElement(r)||h(r)?r:"sx"===o&&e&&r&&(n.isFunction(e)||n.isFunction(r))?t=>n.merge({},n.isFunction(e)?e(t):e??{},n.isFunction(r)?r(t):r??{}):void 0))}function P(e,t){const n={};for(const t in e)t in e&&(n[t]=e[t]);for(const e in t)e in t&&(n[e]=n[e]?`${n[e]} ${t[e]}`:t[e]);return n}function R(e,t){let r=0,o=[],i=[],a=t;const s=new Map,c=new Set,l=()=>{i=Array.from(s.values()),c.forEach((e=>e()))};const u=()=>{o=o.slice(0,-1),l()};return{id:e,defaultOptions:a,observe:e=>(c.add(e),()=>c.delete(e)),pushAlertDialog:async e=>{const{alertDialogId:t,onOpen:n}=e;s.set(t,e),o=[...o,t],l(),h(n)&&n()},popAlertDialog:u,get alertDialogCount(){return r},buildAlertDialog:t=>{if(s.has(t.alertDialogId))throw new Error("alert dialog is duplicated!");const{alertDialogId:i}=t;r++;const{classes:c,...d}=a,{classes:f,...p}=t,v={...C(d,n.omitBy(p,n.isNull)),alertDialogId:i,containerId:e,closeAlertDialog:async()=>{(function(e){return o.at(-1)!==e})(i)||(u(),await E.pop({id:i,preventEventTriggering:!0}))},deleteAlertDialog(){const e=s.get(i),{onClose:t}=e;h(t)&&t(),s.delete(i),r--,r<0&&(r=0),l()}};return h(f)?v.classes=f(c):v.classes=c&&f?P(c,f):c||f,v},setDefaultOptions(e){a=e},isAlertDialogActive:e=>o.some((t=>t===e)),getSnapshot:()=>i}}const I=new Map;function N(e,t){if(t)return!!I.get(t)?.isAlertDialogActive(e);let n=!1;return I.forEach((t=>{t.isAlertDialogActive(e)&&(n=!0)})),n}function T(e){if(!(I.size>0))throw new Error("there is no container for push new alert dialog!");const t=e.containerId||k.CONTAINER_ID,n=I.get(t);if(!n)throw new Error(`there is no container with id: ${t} for push new alert dialog!`);return n.buildAlertDialog(e)}function D(e){return e&&p(e.alertDialogId)?e.alertDialogId:"ad_"+S++}let M=1;function A(e,o){let i=0,a=[],s=[],c=o;const l=new Map,u=new Set,d=()=>{s=Array.from(l.values()),u.forEach((e=>e()))};const p=()=>{a=a.slice(0,-1),d()};return{id:e,defaultOptions:c,observe:e=>(u.add(e),()=>u.delete(e)),popBottomSheet:p,pushBottomSheet:async e=>{const{bottomSheetId:t,onOpen:n}=e.props;l.set(t,e),a=[...a,t],d(),h(n)&&n()},get bottomSheetCount(){return i},buildBottomSheet:(o,s)=>{if(l.has(s.bottomSheetId))throw new Error("bottom sheet is duplicated!");const{bottomSheetId:u}=s,v=async()=>{(function(e){return a.at(-1)!==e})(u)||(p(),await E.pop({id:u,preventEventTriggering:!0}))};i++;const{className:g,footer:y,header:b,sibling:_,closeButton:w,...x}=c,{className:S,footer:k,sibling:O,header:P,closeButton:R,...I}=s,N={...C(x,n.omitBy(I,n.isNull)),bottomSheetId:u,containerId:e,closeBottomSheet:v,deleteBottomSheet(){const e=l.get(u),{onClose:t}=e.props;h(t)&&t(),l.delete(u),i--,i<0&&(i=0),d()}};h(S)?N.className=S(g):N.className=g&&S?r(g,S):g||S;const T={closeBottomSheet:v,bottomSheetProps:N};N.closeButton=w,!1===R||m(R)?N.closeButton=R:!0===R&&(N.closeButton=!m(w)||w),N.header=b,!1===P||m(P)?N.header=P:!0===P&&(N.header=!m(b)||b);let D=y;(!1===k||m(k))&&(D=k),D&&(h(D)?N.footer=D(T):t.isValidElement(D)&&(N.footer=t.cloneElement(D,T)));let M=_;(!1===O||m(O))&&(M=O),M&&(h(M)?N.sibling=M(T):t.isValidElement(M)&&(N.sibling=t.cloneElement(M,T)));let A=o;t.isValidElement(o)&&!f(o.type)?A=t.cloneElement(o,T):h(o)&&(A=o(T));return{content:A,props:N}},setDefaultOptions(e){c=e},isBottomSheetActive:e=>a.some((t=>t===e)),getSnapshot:()=>s}}const j=new Map;function L(e,t){if(t)return!!j.get(t)?.isBottomSheetActive(e);let n=!1;return j.forEach((t=>{t.isBottomSheetActive(e)&&(n=!0)})),n}function z(e,t){if(!m(e))throw new Error("bottom sheet contnet can not be rendered!");if(!(j.size>0))throw new Error("there is no container for push new bottom sheet!");const n=t.containerId||k.CONTAINER_ID,r=j.get(n);if(!r)throw new Error(`there is no container with id: ${n} for push new bottom sheet!`);return r.buildBottomSheet(e,t)}function F(e){return e&&p(e.bottomSheetId)?e.bottomSheetId:"bs_"+M++}function B(e,t){let o=0,i=[],a=[],s=t;const c=new Map,l=new Set,u=()=>{a=Array.from(c.values()),l.forEach((e=>e()))};const d=()=>{i=i.slice(0,-1),u()};return{id:e,defaultOptions:s,observe:e=>(l.add(e),()=>l.delete(e)),pushLightbox:async e=>{const{lightboxId:t,onOpen:n}=e;c.set(t,e),i=[...i,t],u(),h(n)&&n()},popLightbox:d,get alertDialogCount(){return o},buildLightbox:t=>{if(c.has(t.lightboxId))throw new Error("lightbox is already opened!");const{lightboxId:a}=t;o++;const{className:l,styles:f,...p}=s,{className:v,styles:m,...g}=t,y={...C(p,n.omitBy(g,n.isNull)),lightboxId:a,containerId:e,closeLightbox:async()=>{(function(e){return i.at(-1)!==e})(a)||(d(),await E.pop({id:a,preventEventTriggering:!0}))},deleteLightbox(){const e=c.get(a),{onClose:t}=e;h(t)&&t(),c.delete(a),o--,o<0&&(o=0),u()}};return h(v)?y.className=v(l):y.className=l&&v?r(l,v):l||v,y.styles=f&&m?e=>n.merge({},h(f)?f(e):f,h(m)?m(e):m):m||f,y},setDefaultOptions(e){s=e},isLightboxActive:e=>i.some((t=>t===e)),getSnapshot:()=>a}}const V=new Map;function H(e,t){if(t)return!!V.get(t)?.isLightboxActive(e);let n=!1;return V.forEach((t=>{t.isLightboxActive(e)&&(n=!0)})),n}function W(e){if(!(V.size>0))throw new Error("there is no container for push new lightbox!");const t=e.containerId||k.CONTAINER_ID,n=V.get(t);if(!n)throw new Error(`there is no container with id: ${t} for push new lightbox!`);return n.buildLightbox(e)}function $(e){return e&&p(e.lightboxId)?e.lightboxId:"lightbox-overlay"}let G=1;function q(e,r){let o=0,i=[],a=[],s=r;const c=new Map,l=new Set,u=()=>{a=Array.from(c.values()),l.forEach((e=>e()))};const d=()=>{i=i.slice(0,-1),u()};return{id:e,defaultOptions:s,observe:e=>(l.add(e),()=>l.delete(e)),popModal:d,pushModal:e=>{const{modalId:t,onOpen:n}=e.props;c.set(t,e),i=[...i,t],u(),h(n)&&n()},get modalCount(){return o},buildModal:(r,a)=>{if(c.has(a.modalId))throw new Error("modal is duplicated!");const{modalId:l}=a,p=async()=>{(function(e){return i.at(-1)!==e})(l)||(d(),await E.pop({id:l,preventEventTriggering:!0}))};o++;const{classes:v,closeButton:g,header:y,closeButtonIcon:b,contentWrapper:_,...w}=s,{classes:x,closeButton:S,header:k,closeButtonIcon:O,contentWrapper:R,...I}=a,N={...C(w,n.omitBy(I,n.isNull)),modalId:l,containerId:e,closeModal:p,deleteModal(){const e=c.get(l),{onClose:t}=e.props;h(t)&&t(),c.delete(l),o--,o<0&&(o=0),u()}};h(x)?N.classes=x(v):N.classes=v&&x?P(v,x):v||x,N.closeButton=g,!1===S||m(S)?N.closeButton=S:!0===S&&(N.closeButton=!m(g)||g),N.closeButtonIcon=O||b,N.header=y,!1===k||m(k)?N.header=k:!0===k&&(N.header=!m(y)||y),N.contentWrapper=_,!1===R||m(R)?N.contentWrapper=R:!0===R&&(N.contentWrapper=!m(_)||_);let T=r;t.isValidElement(r)&&!f(r.type)?T=t.cloneElement(r,{closeModal:p,modalProps:N}):h(r)&&(T=r({closeModal:p,modalProps:N}));return{content:T,props:N}},setDefaultOptions(e){s=e},isModalActive:e=>i.some((t=>t===e)),getSnapshot:()=>a}}const X=new Map;function Z(e,t){if(t)return!!X.get(t)?.isModalActive(e);let n=!1;return X.forEach((t=>{t.isModalActive(e)&&(n=!0)})),n}function U(e,t){if(!m(e))throw new Error("modal contnet can not be rendered!");if(!(X.size>0))throw new Error("there is no container for push new modal!");const n=t.containerId||k.CONTAINER_ID,r=X.get(n);if(!r)throw new Error(`there is no container with id: ${n} for push new modal!`);return r.buildModal(e,t)}function Y(e){return e&&p(e.modalId)?e.modalId:"m_"+G++}function K(e){const{subscribe:n,getSnapshot:r,setDefaultOptions:o}=t.useRef(function({defaultOptions:e,containerId:t}){const n=t||k.CONTAINER_ID;return{subscribe(t){const r=R(n,e);I.set(n,r);const o=r.observe(t);return()=>{o(),I.delete(n)}},setDefaultOptions(e){I.get(n)?.setDefaultOptions(e)},getSnapshot:()=>I.get(n)?.getSnapshot()}}(e)).current;o(e.defaultOptions);return{alertDialogList:t.useSyncExternalStore(n,r,r)||[],isAlertDialogActive:N}}function J(e){const{subscribe:n,getSnapshot:r,setDefaultOptions:o}=t.useRef(function({defaultOptions:e,containerId:t}){const n=t||k.CONTAINER_ID;return{subscribe(t){const r=A(n,e);j.set(n,r);const o=r.observe(t);return()=>{o(),j.delete(n)}},setDefaultOptions(e){j.get(n)?.setDefaultOptions(e)},getSnapshot:()=>j.get(n)?.getSnapshot()}}(e)).current;o(e.defaultOptions);return{bottomSheetList:t.useSyncExternalStore(n,r,r)||[],isBottomSheetActive:L}}const Q="carousel",ee="controller",te="portal",ne="toolbar",re="captions",oe="fullscreen",ie="slideshow",ae="thumbnails",se="zoom",ce="loading",le="playing",ue="error",de="complete",fe=e=>`active-slide-${e}`,he=fe(ce),pe=fe(le),ve=fe(ue),me=fe(de),ge="fullsize",ye="flex_center",be="no_scroll_padding",_e="slide",we="slide_wrapper",xe="prev",Ee="next",Se="swipe",ke="close",Oe="onPointerDown",Ce="onPointerMove",Pe="onPointerUp",Re="onPointerLeave",Ie="onPointerCancel",Ne="onKeyDown",Te="onWheel",De="icon",Me="contain",Ae="cover",je="Unknown action type",Le="yarl__";function ze(...e){return[...e].filter(Boolean).join(" ")}function Fe(e){return`${Le}${e}`}function Be(e){return`--${Le}${e}`}function Ve(e,t){return`${e}${t?`_${t}`:""}`}function He(e){return t=>Ve(e,t)}function We(...e){return()=>{e.forEach((e=>{e()}))}}function $e(e,t,n){return()=>{const r=u.useContext(n);if(!r)throw new Error(`${e} must be used within a ${t}.Provider`);return r}}function Ge(){return"undefined"!=typeof window}function qe(e,t=0){const n=10**t;return Math.round((e+Number.EPSILON)*n)/n}function Xe(e){return void 0===e.type||"image"===e.type}function Ze(e,t){return e.imageFit===Ae||e.imageFit!==Me&&t===Ae}function Ue(e){return"string"==typeof e?Number.parseInt(e,10):e}function Ye(e){if("number"==typeof e)return{pixel:e};if("string"==typeof e){const t=Ue(e);return e.endsWith("%")?{percent:t}:{pixel:t}}return{pixel:0}}function Ke(e,t){const n=Ye(t),r=void 0!==n.percent?e.width/100*n.percent:n.pixel;return{width:Math.max(e.width-2*r,0),height:Math.max(e.height-2*r,0)}}function Je(e,t){return t>0?(e%t+t)%t:0}function Qe(e){return e.length>0}function et(e,t){return e[Je(t,e.length)]}function tt(e,t){return Qe(e)?et(e,t):void 0}function nt(e){return Xe(e)?e.src:void 0}function rt(e,t,n){if(!n)return e;const{buttons:r,...o}=e,i=r.findIndex((e=>e===t)),a=u.isValidElement(n)?u.cloneElement(n,{key:t},null):n;if(i>=0){const e=[...r];return e.splice(i,1,a),{buttons:e,...o}}return{buttons:[a,...r],...o}}function ot(e,t,n=0){return Math.min(e.preload,Math.max(e.finite?t.length-1:Math.floor(t.length/2),n))}const it=Number(u.version.split(".")[0])>=19;function at(e){e.scrollTop}const st={open:!1,close:()=>{},index:0,slides:[],render:{},plugins:[],toolbar:{buttons:[ke]},labels:{},animation:{fade:250,swipe:500,easing:{fade:"ease",swipe:"ease-out",navigation:"ease-in-out"}},carousel:{finite:!1,preload:2,padding:"16px",spacing:"30%",imageFit:Me,imageProps:{}},controller:{ref:null,focus:!0,aria:!1,touchAction:"none",closeOnPullUp:!1,closeOnPullDown:!1,closeOnBackdropClick:!1,preventDefaultWheelX:!0,preventDefaultWheelY:!1,disableSwipeNavigation:!1},portal:{},noScroll:{disabled:!1},on:{},styles:{},className:""};function ct(e,t){return{name:e,component:t}}function lt(e,t){return{module:e,children:t}}function ut(e,t,n){return e.module.name===t?n(e):e.children?[lt(e.module,e.children.flatMap((e=>{var r;return null!==(r=ut(e,t,n))&&void 0!==r?r:[]})))]:[e]}function dt(e,t,n){return e.flatMap((e=>{var r;return null!==(r=ut(e,t,n))&&void 0!==r?r:[]}))}const ft=u.createContext(null),ht=$e("useDocument","DocumentContext",ft);function pt({nodeRef:e,children:t}){const n=u.useMemo((()=>{const t=t=>{var n;return(null===(n=t||e.current)||void 0===n?void 0:n.ownerDocument)||document};return{getOwnerDocument:t,getOwnerWindow:e=>{var n;return(null===(n=t(e))||void 0===n?void 0:n.defaultView)||window}}}),[e]);return u.createElement(ft.Provider,{value:n},t)}const vt=u.createContext(null),mt=$e("useEvents","EventsContext",vt);function gt({children:e}){const[t]=u.useState({});u.useEffect((()=>()=>{Object.keys(t).forEach((e=>delete t[e]))}),[t]);const n=u.useMemo((()=>{const e=(e,n)=>{var r;null===(r=t[e])||void 0===r||r.splice(0,t[e].length,...t[e].filter((e=>e!==n)))};return{publish:(...[e,n])=>{var r;null===(r=t[e])||void 0===r||r.forEach((e=>e(n)))},subscribe:(n,r)=>(t[n]||(t[n]=[]),t[n].push(r),()=>e(n,r)),unsubscribe:e}}),[t]);return u.createElement(vt.Provider,{value:n},e)}const yt=u.createContext(null),bt=$e("useLightboxProps","LightboxPropsContext",yt);function _t({children:e,...t}){return u.createElement(yt.Provider,{value:t},e)}const wt=u.createContext(null),xt=$e("useLightboxState","LightboxStateContext",wt),Et=u.createContext(null),St=$e("useLightboxDispatch","LightboxDispatchContext",Et);function kt(e,t){switch(t.type){case"swipe":{const{slides:n}=e,r=(null==t?void 0:t.increment)||0,o=e.globalIndex+r,i=Je(o,n.length);return{slides:n,currentIndex:i,globalIndex:o,currentSlide:tt(n,i),animation:r||void 0!==t.duration?{increment:r,duration:t.duration,easing:t.easing}:void 0}}case"update":return t.slides!==e.slides||t.index!==e.currentIndex?{slides:t.slides,currentIndex:t.index,globalIndex:t.index,currentSlide:tt(t.slides,t.index)}:e;default:throw new Error(je)}}function Ot({slides:e,index:t,children:n}){const[r,o]=u.useReducer(kt,{slides:e,currentIndex:t,globalIndex:t,currentSlide:tt(e,t)});u.useEffect((()=>{o({type:"update",slides:e,index:t})}),[e,t]);const i=u.useMemo((()=>({...r,state:r,dispatch:o})),[r,o]);return u.createElement(Et.Provider,{value:o},u.createElement(wt.Provider,{value:i},n))}const Ct=u.createContext(null),Pt=$e("useTimeouts","TimeoutsContext",Ct);function Rt({children:e}){const[t]=u.useState([]);u.useEffect((()=>()=>{t.forEach((e=>window.clearTimeout(e))),t.splice(0,t.length)}),[t]);const n=u.useMemo((()=>{const e=e=>{t.splice(0,t.length,...t.filter((t=>t!==e)))};return{setTimeout:(n,r)=>{const o=window.setTimeout((()=>{e(o),n()}),r);return t.push(o),o},clearTimeout:t=>{void 0!==t&&(e(t),window.clearTimeout(t))}}}),[t]);return u.createElement(Ct.Provider,{value:n},e)}const It=u.forwardRef((function({label:e,className:t,icon:n,renderIcon:r,onClick:o,style:i,...a},s){const{styles:c,labels:l}=bt(),d=function(e,t){var n;return null!==(n=null==e?void 0:e[t])&&void 0!==n?n:t}(l,e);return u.createElement("button",{ref:s,type:"button",title:d,"aria-label":d,className:ze(Fe("button"),t),onClick:o,style:{...i,...c.button},...a},r?r():u.createElement(n,{className:Fe(De),style:c.icon}))}));function Nt(e,t){const n=e=>u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",...e},t);return n.displayName=e,n}function Tt(e,t){return Nt(e,u.createElement("g",{fill:"currentColor"},u.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t))}function Dt(e,t){return Nt(e,u.createElement(u.Fragment,null,u.createElement("defs",null,u.createElement("mask",{id:"strike"},u.createElement("path",{d:"M0 0h24v24H0z",fill:"white"}),u.createElement("path",{d:"M0 0L24 24",stroke:"black",strokeWidth:4}))),u.createElement("path",{d:"M0.70707 2.121320L21.878680 23.292883",stroke:"currentColor",strokeWidth:2}),u.createElement("g",{fill:"currentColor",mask:"url(#strike)"},u.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t)))}const Mt=Tt("Close",u.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),At=Tt("Previous",u.createElement("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})),jt=Tt("Next",u.createElement("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})),Lt=Tt("Loading",u.createElement(u.Fragment,null,Array.from({length:8}).map(((e,t,n)=>u.createElement("line",{key:t,x1:"12",y1:"6.5",x2:"12",y2:"1.8",strokeLinecap:"round",strokeWidth:"2.6",stroke:"currentColor",strokeOpacity:1/n.length*(t+1),transform:`rotate(${360/n.length*t}, 12, 12)`}))))),zt=Tt("Error",u.createElement("path",{d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})),Ft=Ge()?u.useLayoutEffect:u.useEffect;function Bt(){const[e,t]=u.useState(!1);return u.useEffect((()=>{var e,n;const r=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-reduced-motion: reduce)");t(null==r?void 0:r.matches);const o=e=>t(e.matches);return null===(n=null==r?void 0:r.addEventListener)||void 0===n||n.call(r,"change",o),()=>{var e;return null===(e=null==r?void 0:r.removeEventListener)||void 0===e?void 0:e.call(r,"change",o)}}),[]),e}function Vt(e,t){const n=u.useRef(void 0),r=u.useRef(void 0),o=Bt();return Ft((()=>{var i,a,s;if(e.current&&void 0!==n.current&&!o){const{keyframes:o,duration:c,easing:l,onfinish:u}=t(n.current,e.current.getBoundingClientRect(),function(e){let t=0,n=0,r=0;const o=window.getComputedStyle(e).transform.match(/matrix.*\((.+)\)/);if(o){const e=o[1].split(",").map(Ue);6===e.length?(t=e[4],n=e[5]):16===e.length&&(t=e[12],n=e[13],r=e[14])}return{x:t,y:n,z:r}}(e.current))||{};if(o&&c){null===(i=r.current)||void 0===i||i.cancel(),r.current=void 0;try{r.current=null===(s=(a=e.current).animate)||void 0===s?void 0:s.call(a,o,{duration:c,easing:l})}catch(e){console.error(e)}r.current&&(r.current.onfinish=()=>{r.current=void 0,null==u||u()})}}n.current=void 0})),{prepareAnimation:e=>{n.current=e},isAnimationPlaying:()=>{var e;return"running"===(null===(e=r.current)||void 0===e?void 0:e.playState)}}}function Ht(){const e=u.useRef(null),t=u.useRef(void 0),[n,r]=u.useState();return{setContainerRef:u.useCallback((n=>{e.current=n,t.current&&(t.current.disconnect(),t.current=void 0);const o=()=>{if(n){const e=window.getComputedStyle(n),t=e=>parseFloat(e)||0;r({width:Math.round(n.clientWidth-t(e.paddingLeft)-t(e.paddingRight)),height:Math.round(n.clientHeight-t(e.paddingTop)-t(e.paddingBottom))})}else r(void 0)};o(),n&&"undefined"!=typeof ResizeObserver&&(t.current=new ResizeObserver(o),t.current.observe(n))}),[]),containerRef:e,containerRect:n}}function Wt(){const e=u.useRef(void 0),{setTimeout:t,clearTimeout:n}=Pt();return u.useCallback(((r,o)=>{n(e.current),e.current=t(r,o>0?o:0)}),[t,n])}function $t(e){const t=u.useRef(e);return Ft((()=>{t.current=e})),u.useCallback(((...e)=>{var n;return null===(n=t.current)||void 0===n?void 0:n.call(t,...e)}),[])}function Gt(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function qt(e,t){return u.useMemo((()=>null==e&&null==t?null:n=>{Gt(e,n),Gt(t,n)}),[e,t])}function Xt(e,t=!1){const n=u.useRef(!1);Ft((()=>{t&&n.current&&(n.current=!1,e())}),[t,e]);return{onFocus:u.useCallback((()=>{n.current=!0}),[]),onBlur:u.useCallback((()=>{n.current=!1}),[])}}function Zt(){const[e,t]=u.useState(!1);return Ft((()=>{t("rtl"===window.getComputedStyle(window.document.documentElement).direction)}),[]),e}function Ut(){const[e]=u.useState({}),t=u.useCallback(((t,n)=>{var r;null===(r=e[t])||void 0===r||r.forEach((e=>{n.isPropagationStopped()||e(n)}))}),[e]),n=u.useMemo((()=>({onPointerDown:e=>t(Oe,e),onPointerMove:e=>t(Ce,e),onPointerUp:e=>t(Pe,e),onPointerLeave:e=>t(Re,e),onPointerCancel:e=>t(Ie,e),onKeyDown:e=>t(Ne,e),onKeyUp:e=>t("onKeyUp",e),onWheel:e=>t(Te,e)})),[t]),r=u.useCallback(((t,n)=>(e[t]||(e[t]=[]),e[t].unshift(n),()=>{const r=e[t];r&&r.splice(0,r.length,...r.filter((e=>e!==n)))})),[e]);return{registerSensors:n,subscribeSensors:r}}function Yt(e,t){const n=u.useRef(0),r=Wt(),o=$t(((...t)=>{n.current=Date.now(),e(t)}));return u.useCallback(((...e)=>{r((()=>{o(e)}),t-(Date.now()-n.current))}),[t,o,r])}const Kt=He("slide"),Jt=He("slide_image");function Qt({slide:e,offset:t,render:n,rect:r,imageFit:o,imageProps:i,onClick:a,onLoad:s,onError:c,style:l}){var d,f,h,p,v,m,g;const[y,b]=u.useState(ce),{publish:_}=mt(),{setTimeout:w}=Pt(),x=u.useRef(null);u.useEffect((()=>{0===t&&_(fe(y))}),[t,y,_]);const E=$t((e=>{("decode"in e?e.decode():Promise.resolve()).catch((()=>{})).then((()=>{e.parentNode&&(b(de),w((()=>{null==s||s(e)}),0))}))})),S=u.useCallback((e=>{x.current=e,(null==e?void 0:e.complete)&&E(e)}),[E]),k=u.useCallback((e=>{E(e.currentTarget)}),[E]),O=$t((()=>{b(ue),null==c||c()})),C=Ze(e,o),P=(e,t)=>Number.isFinite(e)?e:t,R=P(Math.max(...(null!==(f=null===(d=e.srcSet)||void 0===d?void 0:d.map((e=>e.width)))&&void 0!==f?f:[]).concat(e.width?[e.width]:[]).filter(Boolean)),(null===(h=x.current)||void 0===h?void 0:h.naturalWidth)||0),I=P(Math.max(...(null!==(v=null===(p=e.srcSet)||void 0===p?void 0:p.map((e=>e.height)))&&void 0!==v?v:[]).concat(e.height?[e.height]:[]).filter(Boolean)),(null===(m=x.current)||void 0===m?void 0:m.naturalHeight)||0),N=R&&I?{maxWidth:`min(${R}px, 100%)`,maxHeight:`min(${I}px, 100%)`}:{maxWidth:"100%",maxHeight:"100%"},T=null===(g=e.srcSet)||void 0===g?void 0:g.sort(((e,t)=>e.width-t.width)).map((e=>`${e.src} ${e.width}w`)).join(", "),D=T&&r&&Ge()?`${Math.round(Math.min(r&&!C&&e.width&&e.height?r.height/e.height*e.width:Number.MAX_VALUE,r.width))}px`:void 0,{style:M,className:A,...j}=i||{};return u.createElement(u.Fragment,null,u.createElement("img",{ref:S,onLoad:k,onError:O,onClick:a,draggable:!1,className:ze(Fe(Jt()),C&&Fe(Jt("cover")),y!==de&&Fe(Jt("loading")),A),style:{...N,...l,...M},...j,alt:e.alt,sizes:D,srcSet:T,src:e.src}),y!==de&&u.createElement("div",{className:Fe(Kt("placeholder"))},y===ce&&((null==n?void 0:n.iconLoading)?n.iconLoading():u.createElement(Lt,{className:ze(Fe(De),Fe(Kt(ce)))})),y===ue&&((null==n?void 0:n.iconError)?n.iconError():u.createElement(zt,{className:ze(Fe(De),Fe(Kt(ue)))}))))}const en=u.forwardRef((function({className:e,children:t,...n},r){const o=u.useRef(null);return u.createElement(pt,{nodeRef:o},u.createElement("div",{ref:qt(r,o),className:ze(Fe("root"),e),...n},t))}));var tn,nn;function rn(e,t,n,r,o){u.useEffect((()=>o?()=>{}:We(e(Oe,t),e(Ce,n),e(Pe,r),e(Re,r),e(Ie,r))),[e,t,n,r,o])}!function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL",e[e.ANIMATION=3]="ANIMATION"}(tn||(tn={})),function(e){e[e.NONE=0]="NONE",e[e.SWIPE=1]="SWIPE",e[e.PULL=2]="PULL"}(nn||(nn={}));const on=He("container"),an=u.createContext(null),sn=$e("useController","ControllerContext",an);const cn=ct(ee,(function({children:e,...t}){var n;const{carousel:r,animation:o,controller:i,on:a,styles:s,render:c}=t,{closeOnPullUp:l,closeOnPullDown:d,preventDefaultWheelX:f,preventDefaultWheelY:h}=i,[p,v]=u.useState(),m=xt(),g=St(),[y,b]=u.useState(tn.NONE),_=u.useRef(0),w=u.useRef(0),x=u.useRef(1),{registerSensors:E,subscribeSensors:S}=Ut(),{subscribe:k,publish:O}=mt(),C=Wt(),P=Wt(),R=Wt(),{containerRef:I,setContainerRef:N,containerRect:T}=Ht(),D=qt(function({preventDefaultWheelX:e,preventDefaultWheelY:t}){const n=u.useRef(null),r=$t((n=>{const r=Math.abs(n.deltaX)>Math.abs(n.deltaY);(r&&e||!r&&t||n.ctrlKey)&&n.preventDefault()}));return u.useCallback((e=>{var t;e?e.addEventListener("wheel",r,{passive:!1}):null===(t=n.current)||void 0===t||t.removeEventListener("wheel",r),n.current=e}),[r])}({preventDefaultWheelX:f,preventDefaultWheelY:h}),N),M=u.useRef(null),A=qt(M,void 0),{getOwnerDocument:j}=ht(),L=Zt(),z=e=>(L?-1:1)*("number"==typeof e?e:1),F=$t((()=>{var e;return null===(e=I.current)||void 0===e?void 0:e.focus()})),B=$t((()=>t)),V=$t((()=>m)),H=u.useCallback((e=>O(xe,e)),[O]),W=u.useCallback((e=>O(Ee,e)),[O]),$=u.useCallback((()=>O(ke)),[O]),G=e=>!(r.finite&&(z(e)>0&&0===m.currentIndex||z(e)<0&&m.currentIndex===m.slides.length-1)),q=e=>{var t;_.current=e,null===(t=I.current)||void 0===t||t.style.setProperty(Be("swipe_offset"),`${Math.round(e)}px`)},X=e=>{var t,n;w.current=e,x.current=(()=>{const t=d&&e>0?e:l&&e<0?-e:0;return Math.min(Math.max(qe(1-t/60*.5,2),.5),1)})(),null===(t=I.current)||void 0===t||t.style.setProperty(Be("pull_offset"),`${Math.round(e)}px`),null===(n=I.current)||void 0===n||n.style.setProperty(Be("pull_opacity"),`${x.current}`)},{prepareAnimation:Z}=Vt(M,((e,t,n)=>{if(M.current&&T)return{keyframes:[{transform:`translate(0, ${e.rect.y-t.y+n.y}px)`,opacity:e.opacity},{transform:"translate(0, 0)",opacity:1}],duration:e.duration,easing:o.easing.fade}})),U=(e,t)=>{if(l||d){X(e);let n=0;M.current&&(n=o.fade*(t?2:1),Z({rect:M.current.getBoundingClientRect(),opacity:x.current,duration:n})),R((()=>{X(0),b(tn.NONE)}),n),b(tn.ANIMATION),t||$()}},{prepareAnimation:Y,isAnimationPlaying:K}=Vt(M,((e,t,n)=>{var o;if(M.current&&T&&(null===(o=m.animation)||void 0===o?void 0:o.duration)){const o=Ye(r.spacing),i=(o.percent?o.percent*T.width/100:o.pixel)||0;return{keyframes:[{transform:`translate(${z(m.globalIndex-e.index)*(T.width+i)+e.rect.x-t.x+n.x}px, 0)`},{transform:"translate(0, 0)"}],duration:m.animation.duration,easing:m.animation.easing}}})),J=$t((e=>{var t,n;const r=e.offset||0,i=r?o.swipe:null!==(t=o.navigation)&&void 0!==t?t:o.swipe,a=r||K()?o.easing.swipe:o.easing.navigation;let{direction:s}=e;const c=null!==(n=e.count)&&void 0!==n?n:1;let l=tn.ANIMATION,u=i*c;if(!s){const t=null==T?void 0:T.width,n=e.duration||0,o=t?i/t*Math.abs(r):i;0!==c?(n<o?u=u/o*Math.max(n,o/5):t&&(u=i/t*(t-Math.abs(r))),s=z(r)>0?xe:Ee):u=i/2}let d=0;s===xe?G(z(1))?d=-c:(l=tn.NONE,u=i):s===Ee&&(G(z(-1))?d=c:(l=tn.NONE,u=i)),u=Math.round(u),P((()=>{q(0),b(tn.NONE)}),u),M.current&&Y({rect:M.current.getBoundingClientRect(),index:m.globalIndex}),b(l),O(Se,{type:"swipe",increment:d,duration:u,easing:a})}));u.useEffect((()=>{var e,t;(null===(e=m.animation)||void 0===e?void 0:e.increment)&&(null===(t=m.animation)||void 0===t?void 0:t.duration)&&C((()=>g({type:"swipe",increment:0})),m.animation.duration)}),[m.animation,g,C]);const Q=[S,G,(null==T?void 0:T.width)||0,o.swipe,()=>b(tn.SWIPE),e=>q(e),(e,t)=>J({offset:e,duration:t,count:1}),e=>J({offset:e,count:0})],ee=[()=>{d&&b(tn.PULL)},e=>X(e),e=>U(e),e=>U(e,!0)];!function({disableSwipeNavigation:e,closeOnBackdropClick:t},n,r,o,i,a,s,c,l,d,f,h,p,v,m,g){const y=u.useRef(0),b=u.useRef([]),_=u.useRef(void 0),w=u.useRef(0),x=u.useRef(nn.NONE),E=u.useCallback((e=>{_.current===e.pointerId&&(_.current=void 0,x.current=nn.NONE);const t=b.current;t.splice(0,t.length,...t.filter((t=>t.pointerId!==e.pointerId)))}),[]),S=u.useCallback((e=>{E(e),e.persist(),b.current.push(e)}),[E]),k=u.useCallback((e=>b.current.find((({pointerId:t})=>e.pointerId===t))),[]),O=$t((e=>{S(e)})),C=(e,t)=>f&&e>t||d&&e<-t,P=$t((e=>{const n=k(e);if(n)if(_.current===e.pointerId){const e=Date.now()-w.current,t=y.current;x.current===nn.SWIPE?Math.abs(t)>.3*o||Math.abs(t)>5&&e<i?c(t,e):l(t):x.current===nn.PULL&&(C(t,60)?v(t,e):m(t)),y.current=0,x.current=nn.NONE}else{const{target:r}=e;t&&r instanceof HTMLElement&&r===n.target&&(r.classList.contains(Fe(_e))||r.classList.contains(Fe(we)))&&g()}E(e)}));rn(n,O,$t((t=>{const n=k(t);if(n){const o=_.current===t.pointerId;if(0===t.buttons)return void(o&&0!==y.current?P(t):E(n));const i=t.clientX-n.clientX,c=t.clientY-n.clientY;if(void 0===_.current){const n=e=>{S(t),_.current=t.pointerId,w.current=Date.now(),x.current=e};Math.abs(i)>Math.abs(c)&&Math.abs(i)>30&&r(i)?e||(n(nn.SWIPE),a()):Math.abs(c)>Math.abs(i)&&C(c,30)&&(n(nn.PULL),h())}else o&&(x.current===nn.SWIPE?(y.current=i,s(i)):x.current===nn.PULL&&(y.current=c,p(c)))}})),P)}(i,...Q,l,d,...ee,$),function(e,t,n,r,o,i,a,s,c){const l=u.useRef(0),d=u.useRef(0),f=u.useRef(void 0),h=u.useRef(void 0),p=u.useRef(0),v=u.useRef(void 0),m=u.useRef(0),{setTimeout:g,clearTimeout:y}=Pt(),b=u.useCallback((()=>{f.current&&(y(f.current),f.current=void 0)}),[y]),_=u.useCallback((()=>{h.current&&(y(h.current),h.current=void 0)}),[y]),w=$t((()=>{e!==tn.SWIPE&&(l.current=0,m.current=0,b(),_())}));u.useEffect(w,[e,w]);const x=$t((e=>{h.current=void 0,l.current===e&&c(l.current)})),E=$t((t=>{if(t.ctrlKey)return;if(Math.abs(t.deltaY)>Math.abs(t.deltaX))return;const c=e=>{p.current=e,y(v.current),v.current=e>0?g((()=>{p.current=0,v.current=void 0}),300):void 0};if(e===tn.NONE){if(Math.abs(t.deltaX)<=1.2*Math.abs(p.current))return void c(t.deltaX);if(!n(-t.deltaX))return;if(d.current+=t.deltaX,b(),Math.abs(d.current)>30)d.current=0,c(0),m.current=Date.now(),i();else{const e=d.current;f.current=g((()=>{f.current=void 0,e===d.current&&(d.current=0)}),o)}}else if(e===tn.SWIPE){let e=l.current-t.deltaX;if(e=Math.min(Math.abs(e),r)*Math.sign(e),l.current=e,a(e),_(),Math.abs(e)>.2*r)return c(t.deltaX),void s(e,Date.now()-m.current);h.current=g((()=>x(e)),2*o)}else c(t.deltaX)}));u.useEffect((()=>t(Te,E)),[t,E])}(y,...Q);const ne=$t((()=>{i.focus&&j().querySelector(`.${Fe(te)} .${Fe(on())}`)&&F()}));u.useEffect(ne,[ne]);const re=$t((()=>{var e;null===(e=a.view)||void 0===e||e.call(a,{index:m.currentIndex})}));u.useEffect(re,[m.globalIndex,re]),u.useEffect((()=>We(k(xe,(e=>J({direction:xe,...e}))),k(Ee,(e=>J({direction:Ee,...e}))),k(Se,(e=>g(e))))),[k,J,g]);const oe=u.useMemo((()=>({prev:H,next:W,close:$,focus:F,slideRect:T?Ke(T,r.padding):{width:0,height:0},containerRect:T||{width:0,height:0},subscribeSensors:S,containerRef:I,setCarouselRef:A,toolbarWidth:p,setToolbarWidth:v})),[H,W,$,F,S,T,I,A,p,v,r.padding]);return u.useImperativeHandle(i.ref,(()=>({prev:H,next:W,close:$,focus:F,getLightboxProps:B,getLightboxState:V})),[H,W,$,F,B,V]),u.createElement("div",{ref:D,className:ze(Fe(on()),Fe(ye)),style:{...y===tn.SWIPE?{[Be("swipe_offset")]:`${Math.round(_.current)}px`}:null,...y===tn.PULL?{[Be("pull_offset")]:`${Math.round(w.current)}px`,[Be("pull_opacity")]:`${x.current}`}:null,..."none"!==i.touchAction?{[Be("controller_touch_action")]:i.touchAction}:null,...s.container},...i.aria?{role:"region","aria-live":"polite","aria-roledescription":"carousel"}:null,tabIndex:-1,...E},T&&u.createElement(an.Provider,{value:oe},e,null===(n=c.controls)||void 0===n?void 0:n.call(c)))}));function ln(e){return Ve(Q,e)}function un(e){return Ve(_e,e)}function dn({slide:e,offset:t}){const n=u.useRef(null),{currentIndex:r}=xt(),{slideRect:o,focus:i}=sn(),{render:a,carousel:{imageFit:s,imageProps:c},on:{click:l},styles:{slide:d}}=bt(),{getOwnerDocument:f}=ht(),h=0!==t;u.useEffect((()=>{var e;h&&(null===(e=n.current)||void 0===e?void 0:e.contains(f().activeElement))&&i()}),[h,i,f]);return u.createElement("div",{ref:n,className:ze(Fe(un()),!h&&Fe(un("current")),Fe(ye)),...(p=h,{inert:it?p:p?"":void 0}),style:d,role:"region","aria-roledescription":"slide"},(()=>{var n,i,d,f;let p=null===(n=a.slide)||void 0===n?void 0:n.call(a,{slide:e,offset:t,rect:o});return!p&&Xe(e)&&(p=u.createElement(Qt,{slide:e,offset:t,render:a,rect:o,imageFit:s,imageProps:c,onClick:h?void 0:()=>null==l?void 0:l({index:r})})),p?u.createElement(u.Fragment,null,null===(i=a.slideHeader)||void 0===i?void 0:i.call(a,{slide:e}),(null!==(d=a.slideContainer)&&void 0!==d?d:({children:e})=>e)({slide:e,children:p}),null===(f=a.slideFooter)||void 0===f?void 0:f.call(a,{slide:e})):null})());var p}function fn(){const e=bt().styles.slide;return u.createElement("div",{className:Fe(_e),style:e})}const hn=ct(Q,(function({carousel:e}){const{slides:t,currentIndex:n,globalIndex:r}=xt(),{setCarouselRef:o}=sn(),i=Ye(e.spacing),a=Ye(e.padding),s=ot(e,t,1),c=[];if(Qe(t))for(let o=n-s;o<=n+s;o+=1){const i=et(t,o),a=r-n+o,s=e.finite&&(o<0||o>t.length-1);c.push(s?{key:a}:{key:[`${a}`,nt(i)].filter(Boolean).join("|"),offset:o-n,slide:i})}return u.createElement("div",{ref:o,className:ze(Fe(ln()),c.length>0&&Fe(ln("with_slides"))),style:{[`${Be(ln("slides_count"))}`]:c.length,[`${Be(ln("spacing_px"))}`]:i.pixel||0,[`${Be(ln("spacing_percent"))}`]:i.percent||0,[`${Be(ln("padding_px"))}`]:a.pixel||0,[`${Be(ln("padding_percent"))}`]:a.percent||0}},c.map((({key:e,slide:t,offset:n})=>t?u.createElement(dn,{key:e,slide:t,offset:n}):u.createElement(fn,{key:e}))))}));function pn(){const{carousel:e}=bt(),{slides:t,currentIndex:n}=xt();return{prevDisabled:0===t.length||e.finite&&0===n,nextDisabled:0===t.length||e.finite&&n===t.length-1}}function vn(e){var t;const n=Zt(),{publish:r}=mt(),{animation:o}=bt(),{prevDisabled:i,nextDisabled:a}=pn(),s=(null!==(t=o.navigation)&&void 0!==t?t:o.swipe)/2,c=Yt((()=>r(xe)),s),l=Yt((()=>r(Ee)),s),d=$t((e=>{switch(e.key){case"Escape":r(ke);break;case"ArrowLeft":(n?a:i)||(n?l:c)();break;case"ArrowRight":(n?i:a)||(n?c:l)()}}));u.useEffect((()=>e(Ne,d)),[e,d])}function mn({label:e,icon:t,renderIcon:n,action:r,onClick:o,disabled:i,style:a}){return u.createElement(It,{label:e,icon:t,renderIcon:n,className:Fe(`navigation_${r}`),disabled:i,onClick:o,style:a,...Xt(sn().focus,i)})}const gn=ct("navigation",(function({render:{buttonPrev:e,buttonNext:t,iconPrev:n,iconNext:r},styles:o}){const{prev:i,next:a,subscribeSensors:s}=sn(),{prevDisabled:c,nextDisabled:l}=pn();return vn(s),u.createElement(u.Fragment,null,e?e():u.createElement(mn,{label:"Previous",action:xe,icon:At,renderIcon:n,style:o.navigationPrev,disabled:c,onClick:i}),t?t():u.createElement(mn,{label:"Next",action:Ee,icon:jt,renderIcon:r,style:o.navigationNext,disabled:l,onClick:a}))})),yn=Fe("no_scroll"),bn=Fe(be);function _n(e){return"style"in e}function wn(e,t,n){const r=window.getComputedStyle(e),o=n?"padding-left":"padding-right",i=n?r.paddingLeft:r.paddingRight,a=e.style.getPropertyValue(o);return e.style.setProperty(o,`${(Ue(i)||0)+t}px`),()=>{a?e.style.setProperty(o,a):e.style.removeProperty(o)}}const xn=ct("no-scroll",(function({noScroll:{disabled:e},children:t}){const n=Zt(),{getOwnerDocument:r,getOwnerWindow:o}=ht();return u.useEffect((()=>{if(e)return()=>{};const t=[],i=o(),{body:a,documentElement:s}=r(),c=Math.round(i.innerWidth-s.clientWidth);if(c>0){t.push(wn(a,c,n));const e=a.getElementsByTagName("*");for(let r=0;r<e.length;r+=1){const o=e[r];_n(o)&&"fixed"===i.getComputedStyle(o).getPropertyValue("position")&&!o.classList.contains(bn)&&t.push(wn(o,c,n))}}return a.classList.add(yn),()=>{a.classList.remove(yn),t.forEach((e=>e()))}}),[n,e,r,o]),u.createElement(u.Fragment,null,t)}));function En(e){return Ve(te,e)}function Sn(e,t,n){const r=e.getAttribute(t);return e.setAttribute(t,n),()=>{r?e.setAttribute(t,r):e.removeAttribute(t)}}const kn=ct(te,(function({children:e,animation:t,styles:n,className:r,on:o,portal:i,close:a}){const[c,l]=u.useState(!1),[d,f]=u.useState(!1),h=u.useRef([]),p=u.useRef(null),{setTimeout:v}=Pt(),{subscribe:m}=mt(),g=Bt()?0:t.fade;u.useEffect((()=>(l(!0),()=>{l(!1),f(!1)})),[]);const y=$t((()=>{h.current.forEach((e=>e())),h.current=[]})),b=$t((()=>{var e;f(!1),y(),null===(e=o.exiting)||void 0===e||e.call(o),v((()=>{var e;null===(e=o.exited)||void 0===e||e.call(o),a()}),g)}));u.useEffect((()=>m(ke,b)),[m,b]);const _=$t((e=>{var t,n,r;at(e),f(!0),null===(t=o.entering)||void 0===t||t.call(o);const i=null!==(r=null===(n=e.parentNode)||void 0===n?void 0:n.children)&&void 0!==r?r:[];for(let t=0;t<i.length;t+=1){const n=i[t];-1===["TEMPLATE","SCRIPT","STYLE"].indexOf(n.tagName)&&n!==e&&(h.current.push(Sn(n,"inert","")),h.current.push(Sn(n,"aria-hidden","true")))}h.current.push((()=>{var e,t;null===(t=null===(e=p.current)||void 0===e?void 0:e.focus)||void 0===t||t.call(e)})),v((()=>{var e;null===(e=o.entered)||void 0===e||e.call(o)}),g)})),w=u.useCallback((e=>{e?_(e):y()}),[_,y]);return c?s.createPortal(u.createElement(en,{ref:w,className:ze(r,Fe(En()),Fe(be),d&&Fe(En("open"))),"aria-modal":!0,role:"dialog","aria-live":"polite","aria-roledescription":"lightbox",style:{...t.fade!==st.animation.fade?{[Be("fade_animation_duration")]:`${g}ms`}:null,...t.easing.fade!==st.animation.easing.fade?{[Be("fade_animation_timing_function")]:t.easing.fade}:null,...n.root},onFocus:e=>{p.current||(p.current=e.relatedTarget)}},e),i.root||document.body):null}));const On=ct("root",(function({children:e}){return u.createElement(u.Fragment,null,e)}));const Cn=ct(ne,(function({toolbar:{buttons:e},render:{buttonClose:t,iconClose:n},styles:r}){const{close:o,setToolbarWidth:i}=sn(),{setContainerRef:a,containerRect:s}=Ht();return Ft((()=>{i(null==s?void 0:s.width)}),[i,null==s?void 0:s.width]),u.createElement("div",{ref:a,style:r.toolbar,className:Fe(Ve(ne,c))},null==e?void 0:e.map((e=>e===ke?t?t():u.createElement(It,{key:ke,label:"Close",icon:Mt,renderIcon:n,onClick:o}):e)));var c}));function Pn(e,t){var n;return u.createElement(e.module.component,{key:e.module.name,...t},null===(n=e.children)||void 0===n?void 0:n.map((e=>Pn(e,t))))}function Rn(e,t={}){const{easing:n,...r}=e,{easing:o,...i}=t;return{easing:{...n,...o},...r,...i}}function In({carousel:e,animation:t,render:n,toolbar:r,controller:o,noScroll:i,on:a,plugins:s,slides:c,index:l,...d}){const{animation:f,carousel:h,render:p,toolbar:v,controller:m,noScroll:g,on:y,slides:b,index:_,plugins:w,...x}=st,{config:E,augmentation:S}=function(e,t=[],n=[]){let r=e;const o=e=>{const t=[...r];for(;t.length>0;){const n=t.pop();if((null==n?void 0:n.module.name)===e)return!0;(null==n?void 0:n.children)&&t.push(...n.children)}return!1},i=(e,t)=>{r=""!==e?dt(r,e,(e=>[lt(t,[e])])):[lt(t,r)]},a=(e,t)=>{r=dt(r,e,(e=>[lt(e.module,[lt(t,e.children)])]))},s=(e,t,n)=>{r=dt(r,e,(e=>{var r;return[lt(e.module,[...n?[lt(t)]:[],...null!==(r=e.children)&&void 0!==r?r:[],...n?[]:[lt(t)]])]}))},c=(e,t,n)=>{r=dt(r,e,(e=>[...n?[lt(t)]:[],e,...n?[]:[lt(t)]]))},l=e=>{a(ee,e)},u=(e,t)=>{r=dt(r,e,(e=>[lt(t,e.children)]))},d=e=>{r=dt(r,e,(e=>e.children))},f=e=>{n.push(e)};return t.forEach((e=>{e({contains:o,addParent:i,append:a,addChild:s,addSibling:c,addModule:l,replace:u,remove:d,augment:f})})),{config:r,augmentation:e=>n.reduce(((e,t)=>t(e)),e)}}([lt(kn,[lt(xn,[lt(cn,[lt(hn),lt(Cn),lt(gn)])])])],s||w),k=S({animation:Rn(f,t),carousel:{...h,...e},render:{...p,...n},toolbar:{...v,...r},controller:{...m,...o},noScroll:{...g,...i},on:{...y,...a},...x,...d});return k.open?u.createElement(_t,{...k},u.createElement(Ot,{slides:c||b,index:Ue(l||_)},u.createElement(Rt,null,u.createElement(gt,null,Pn(lt(On,E),k))))):null}const Nn=e=>Fe(`slide_${e}`),Tn={descriptionTextAlign:"start",descriptionMaxLines:3,showToggle:!1,hidden:!1},Dn=e=>({...Tn,...e});const Mn=u.createContext(null),An=$e("useCaptions","CaptionsContext",Mn);function jn({captions:e,children:t}){const{ref:n,hidden:r}=Dn(e),[o,i]=u.useState(!r),a=u.useMemo((()=>({visible:o,show:()=>i(!0),hide:()=>i(!1)})),[o]);return u.useImperativeHandle(n,(()=>a),[a]),u.createElement(Mn.Provider,{value:a},t)}function Ln({title:e}){const{toolbarWidth:t}=sn(),{styles:n}=bt(),{visible:r}=An();return r?u.createElement("div",{style:n.captionsTitleContainer,className:ze(Nn("captions_container"),Nn("title_container"))},u.createElement("div",{className:Nn("title"),style:{...t?{[Be("toolbar_width")]:`${t}px`}:null,...n.captionsTitle}},e)):null}function zn({description:e}){const{descriptionTextAlign:t,descriptionMaxLines:n}=function(){const{captions:e}=bt();return Dn(e)}(),{styles:r}=bt(),{visible:o}=An();return o?u.createElement("div",{style:r.captionsDescriptionContainer,className:ze(Nn("captions_container"),Nn("description_container"))},u.createElement("div",{className:Nn("description"),style:{...t!==Tn.descriptionTextAlign||n!==Tn.descriptionMaxLines?{[Be("slide_description_text_align")]:t,[Be("slide_description_max_lines")]:n}:null,...r.captionsDescription}},"string"==typeof e?e.split("\n").flatMap(((e,t)=>[...t>0?[u.createElement("br",{key:t})]:[],e])):e)):null}const Fn=()=>u.createElement(u.Fragment,null,u.createElement("path",{strokeWidth:2,stroke:"currentColor",strokeLinejoin:"round",fill:"none",d:"M3 5l18 0l0 14l-18 0l0-14z"}),u.createElement("path",{d:"M7 15h3c.55 0 1-.45 1-1v-1H9.5v.5h-2v-3h2v.5H11v-1c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm7 0h3c.55 0 1-.45 1-1v-1h-1.5v.5h-2v-3h2v.5H18v-1c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1z"})),Bn=Tt("CaptionsVisible",Fn()),Vn=Dt("CaptionsVisible",Fn());function Hn(){const{visible:e,show:t,hide:n}=An(),{render:r}=bt();return r.buttonCaptions?u.createElement(u.Fragment,null,r.buttonCaptions({visible:e,show:t,hide:n})):u.createElement(It,{label:e?"Hide captions":"Show captions",icon:e?Bn:Vn,renderIcon:e?r.iconCaptionsVisible:r.iconCaptionsHidden,onClick:e?n:t})}function Wn({augment:e,addModule:t}){e((({captions:e,render:{slideFooter:t,...n},toolbar:r,...o})=>{const i=Dn(e);return{render:{slideFooter:({slide:e})=>u.createElement(u.Fragment,null,null==t?void 0:t({slide:e}),e.title&&u.createElement(Ln,{title:e.title}),e.description&&u.createElement(zn,{description:e.description})),...n},toolbar:rt(r,re,i.showToggle?u.createElement(Hn,null):null),captions:i,...o}})),t(ct(re,jn))}const $n={separator:"/",container:{}},Gn=e=>({...$n,...e});function qn({counter:e}){const{slides:t,currentIndex:n}=xt(),{separator:r,container:{className:o,...i},className:a,...s}=Gn(e);return 0===t.length?null:u.createElement("div",{className:ze(Fe("counter"),o||a),...s,...i},n+1," ",r," ",t.length)}function Xn({augment:e,addChild:t}){e((({counter:e,...t})=>({counter:Gn(e),...t}))),t(ee,ct("counter",qn))}const Zn={download:void 0},Un=e=>({...Zn,...e});function Yn(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(t){const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}function Kn(e,t){const n=document.createElement("a");n.rel="noopener",n.download=t||"",n.download||(n.target="_blank"),"string"==typeof e?(n.href=e,n.origin!==window.location.origin?function(e){const t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}(n.href)?function(e,t){const n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=()=>{Kn(n.response,t)},n.onerror=()=>{console.error("Failed to download file")},n.send()}(e,t):(n.target="_blank",Yn(n)):Yn(n)):(n.href=URL.createObjectURL(e),setTimeout((()=>URL.revokeObjectURL(n.href)),3e4),setTimeout((()=>Yn(n)),0))}const Jn=Tt("DownloadIcon",u.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}));function Qn(){const{render:e,on:t,download:n}=bt(),{download:r}=Un(n),{currentSlide:o,currentIndex:i}=xt();if(e.buttonDownload)return u.createElement(u.Fragment,null,e.buttonDownload());const a=o&&(o.downloadUrl||"string"==typeof o.download&&o.download||"object"==typeof o.download&&o.download.url||Xe(o)&&o.src)||void 0,s=r?!1!==(null==o?void 0:o.download):Boolean(a),c=()=>{if(o&&a){const e=o.downloadFilename||"object"==typeof o.download&&o.download.filename||void 0;Kn(a,e)}};return u.createElement(It,{label:"Download",icon:Jn,renderIcon:e.iconDownload,disabled:!s,onClick:()=>{var e;o&&((r||c)({slide:o,saveAs:Kn}),null===(e=t.download)||void 0===e||e.call(t,{index:i}))}})}function er({augment:e}){e((({toolbar:e,download:t,...n})=>({toolbar:rt(e,"download",u.createElement(Qn,null)),download:Un(t),...n})))}const tr={auto:!1,ref:null},nr=e=>({...tr,...e}),rr=u.createContext(null),or=$e("useFullscreen","FullscreenContext",rr);function ir({fullscreen:e,on:t,children:n}){const{auto:r,ref:o}=nr(e),i=u.useRef(null),[a,s]=u.useState(),[c,l]=u.useState(!1),d=u.useRef(!1),{getOwnerDocument:f}=ht();Ft((()=>{var e,t,n,r;const o=f();s(!(null!==(r=null!==(n=null!==(t=null!==(e=o.fullscreenEnabled)&&void 0!==e?e:o.webkitFullscreenEnabled)&&void 0!==t?t:o.mozFullScreenEnabled)&&void 0!==n?n:o.msFullscreenEnabled)&&void 0!==r&&r))}),[f]);const h=u.useCallback((()=>{var e;const t=f(),n=t.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return(null===(e=null==n?void 0:n.shadowRoot)||void 0===e?void 0:e.fullscreenElement)||n}),[f]),p=u.useCallback((()=>{const e=i.current;try{e.requestFullscreen?e.requestFullscreen().catch((()=>{})):e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()}catch(e){}}),[]),v=u.useCallback((()=>{if(!h())return;const e=f();try{e.exitFullscreen?e.exitFullscreen().catch((()=>{})):e.webkitExitFullscreen?e.webkitExitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.msExitFullscreen&&e.msExitFullscreen()}catch(e){}}),[h,f]);u.useEffect((()=>{const e=f(),t=()=>{l(h()===i.current)};return We(...["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"].map((n=>(e.addEventListener(n,t),()=>e.removeEventListener(n,t)))))}),[h,f]);const m=$t((()=>{var e;return null===(e=t.enterFullscreen)||void 0===e?void 0:e.call(t)})),g=$t((()=>{var e;return null===(e=t.exitFullscreen)||void 0===e?void 0:e.call(t)}));u.useEffect((()=>{c&&(d.current=!0),d.current&&(c?m:g)()}),[c,m,g]);const y=$t((()=>{var e;return null===(e=r?p:null)||void 0===e||e(),v}));u.useEffect(y,[y]);const b=u.useMemo((()=>({fullscreen:c,disabled:a,enter:p,exit:v})),[c,a,p,v]);return u.useImperativeHandle(o,(()=>b),[b]),u.createElement("div",{ref:i,className:ze(Fe(oe),Fe(ge))},u.createElement(rr.Provider,{value:b},n))}const ar=Tt("EnterFullscreen",u.createElement("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})),sr=Tt("ExitFullscreen",u.createElement("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"}));function cr(){var e;const{fullscreen:t,disabled:n,enter:r,exit:o}=or(),{render:i}=bt();return n?null:i.buttonFullscreen?u.createElement(u.Fragment,null,null===(e=i.buttonFullscreen)||void 0===e?void 0:e.call(i,{fullscreen:t,disabled:n,enter:r,exit:o})):u.createElement(It,{disabled:n,label:t?"Exit Fullscreen":"Enter Fullscreen",icon:t?sr:ar,renderIcon:t?i.iconExitFullscreen:i.iconEnterFullscreen,onClick:t?o:r})}function lr({augment:e,contains:t,addParent:n}){e((({fullscreen:e,toolbar:t,...n})=>({toolbar:rt(t,oe,u.createElement(cr,null)),fullscreen:nr(e),...n}))),n(t(ae)?ae:ee,ct(oe,ir))}const ur={share:void 0},dr=e=>({...ur,...e});const fr=Tt("ShareIcon",u.createElement("path",{d:"m16 5-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z"}));function hr(){const{render:e,on:t,share:n}=bt(),{share:r}=dr(n),{currentSlide:o,currentIndex:i}=xt();if("undefined"==typeof navigator||!Boolean(navigator.canShare))return null;if(e.buttonShare)return u.createElement(u.Fragment,null,e.buttonShare());const a=o&&("object"==typeof o.share&&o.share||"string"==typeof o.share&&{url:o.share}||Xe(o)&&{url:o.src})||void 0,s=r?!1!==(null==o?void 0:o.share):a&&navigator.canShare(a),c=()=>{a&&navigator.share(a).catch((()=>{}))};return u.createElement(It,{label:"Share",icon:fr,renderIcon:e.iconShare,disabled:!s,onClick:()=>{var e;o&&((r||c)({slide:o}),null===(e=t.share)||void 0===e||e.call(t,{index:i}))}})}function pr({augment:e}){e((({toolbar:e,share:t,...n})=>({toolbar:rt(e,"share",u.createElement(hr,null)),share:dr(t),...n})))}const vr={autoplay:!1,delay:3e3,ref:null},mr=e=>({...vr,...e}),gr=u.createContext(null),yr=$e("useSlideshow","SlideshowContext",gr);function br({slideshow:e,carousel:{finite:t},on:n,children:r}){const{autoplay:o,delay:i,ref:a}=mr(e),s=u.useRef(o),[c,l]=u.useState(o),d=u.useRef(void 0),f=u.useRef(void 0),{slides:h,currentIndex:p}=xt(),{setTimeout:v,clearTimeout:m}=Pt(),{subscribe:g}=mt(),{next:y}=sn(),b=0===h.length||t&&p===h.length-1,_=u.useCallback((()=>{c||b||l(!0)}),[c,b]),w=u.useCallback((()=>{c&&l(!1)}),[c]),x=u.useCallback((()=>{m(d.current),d.current=void 0}),[m]),E=$t((()=>{x(),c&&!b&&f.current!==ce&&f.current!==le&&(d.current=v((()=>{c&&(f.current=void 0,y())}),i))}));u.useEffect(E,[p,c,E]),u.useEffect((()=>{c&&b&&l(!1)}),[p,c,b]);const S=$t((()=>{var e;return null===(e=n.slideshowStart)||void 0===e?void 0:e.call(n)})),k=$t((()=>{var e;return null===(e=n.slideshowStop)||void 0===e?void 0:e.call(n)}));u.useEffect((()=>{c?S():s.current&&k(),s.current=c}),[c,S,k]),u.useEffect((()=>We(x,g(he,(()=>{f.current=ce,x()})),g(pe,(()=>{f.current=le,x()})),g(ve,(()=>{f.current=ue,E()})),g(me,(()=>{f.current=de,E()})))),[g,x,E]);const O=u.useMemo((()=>({playing:c,disabled:b,play:_,pause:w})),[c,b,_,w]);return u.useImperativeHandle(a,(()=>O),[O]),u.createElement(gr.Provider,{value:O},r)}const _r=Tt("Play",u.createElement("path",