@michaelyagi/shoji 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/esm/core/EventBus.d.ts +16 -0
- package/dist/esm/core/FocusTrap.d.ts +9 -0
- package/dist/esm/core/Gallery.d.ts +221 -0
- package/dist/esm/core/GestureController.d.ts +57 -0
- package/dist/esm/core/LiveRegion.d.ts +6 -0
- package/dist/esm/core/SlideManager.d.ts +85 -0
- package/dist/esm/core/bodyScrollLock.d.ts +2 -0
- package/dist/esm/core/dom.d.ts +27 -0
- package/dist/esm/core/icons.d.ts +6 -0
- package/dist/esm/core/index.d.ts +5 -0
- package/dist/esm/core/index.js +2105 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/plugin.d.ts +54 -0
- package/dist/esm/core/rotateFlipNormalize.d.ts +19 -0
- package/dist/esm/core/scan.d.ts +19 -0
- package/dist/esm/core/types.d.ts +290 -0
- package/dist/esm/core/zoomTransition.d.ts +33 -0
- package/dist/esm/gestures/GestureEngine.d.ts +78 -0
- package/dist/esm/index.css +540 -0
- package/dist/esm/index.d.ts +32 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index2.css +22 -0
- package/dist/esm/index3.css +170 -0
- package/dist/esm/index4.css +27 -0
- package/dist/esm/plugins/activeThumbnail/index.d.ts +26 -0
- package/dist/esm/plugins/activeThumbnail/index.js +63 -0
- package/dist/esm/plugins/activeThumbnail/index.js.map +1 -0
- package/dist/esm/plugins/autoplay/icons.d.ts +3 -0
- package/dist/esm/plugins/autoplay/index.d.ts +19 -0
- package/dist/esm/plugins/autoplay/index.js +207 -0
- package/dist/esm/plugins/autoplay/index.js.map +1 -0
- package/dist/esm/plugins/fullscreen/icons.d.ts +3 -0
- package/dist/esm/plugins/fullscreen/index.d.ts +17 -0
- package/dist/esm/plugins/fullscreen/index.js +74 -0
- package/dist/esm/plugins/fullscreen/index.js.map +1 -0
- package/dist/esm/plugins/layout/index.d.ts +191 -0
- package/dist/esm/plugins/layout/index.js +752 -0
- package/dist/esm/plugins/layout/index.js.map +1 -0
- package/dist/esm/plugins/layout/justified.d.ts +68 -0
- package/dist/esm/plugins/layout/masonry.d.ts +92 -0
- package/dist/esm/plugins/rotateFlip/icons.d.ts +5 -0
- package/dist/esm/plugins/rotateFlip/index.d.ts +17 -0
- package/dist/esm/plugins/rotateFlip/index.js +138 -0
- package/dist/esm/plugins/rotateFlip/index.js.map +1 -0
- package/dist/esm/plugins/video/index.d.ts +13 -0
- package/dist/esm/plugins/video/index.js +207 -0
- package/dist/esm/plugins/video/index.js.map +1 -0
- package/dist/esm/plugins/video/vimeo.d.ts +43 -0
- package/dist/esm/plugins/video/youtube.d.ts +61 -0
- package/dist/esm/plugins/zoom/icons.d.ts +4 -0
- package/dist/esm/plugins/zoom/index.d.ts +30 -0
- package/dist/esm/plugins/zoom/index.js +274 -0
- package/dist/esm/plugins/zoom/index.js.map +1 -0
- package/dist/esm/plugins/zoom/zoomMath.d.ts +24 -0
- package/dist/esm/transitions/SlideTransition.d.ts +25 -0
- package/dist/esm/transitions/presets.d.ts +21 -0
- package/dist/esm/zoomTransition-bbKHpVpA.js +110 -0
- package/dist/esm/zoomTransition-bbKHpVpA.js.map +1 -0
- package/dist/shoji.css +759 -0
- package/dist/shoji.js +3907 -0
- package/dist/shoji.js.map +1 -0
- package/dist/shoji.min.css +1 -0
- package/dist/shoji.min.js +2 -0
- package/dist/shoji.min.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.shoji-autoplay-progress{position:absolute;left:0;right:0;bottom:0;height:3px;background:#ffffff26;z-index:var(--shoji-z-toolbar)}.shoji-autoplay-progress[hidden]{display:none}.shoji-autoplay-progress-bar{height:100%;width:0%;background:var(--shoji-progress)}.shoji-layout{position:relative}.shoji-layout--masonry,.shoji-layout--justified,.shoji-layout--grid{contain:layout style}.shoji-layout-tile{display:block;cursor:pointer}.shoji-layout-tile img{display:block;width:100%;height:100%;object-fit:cover}.shoji-layout--masonry .shoji-layout-tile,.shoji-layout--justified .shoji-layout-tile{position:absolute;top:0;left:0;visibility:hidden}.shoji-layout--masonry.shoji-layout--animate .shoji-layout-tile,.shoji-layout--justified.shoji-layout--animate .shoji-layout-tile{transition:transform var(--shoji-duration) var(--shoji-easing)}.shoji-layout--grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--shoji-layout-column-width, 240px),1fr));gap:var(--shoji-layout-gutter, 8px)}.shoji-layout--grid .shoji-layout-tile{aspect-ratio:var(--shoji-layout-tile-aspect, 1)}.shoji-layout-heading{margin:0}.shoji-layout--grid .shoji-layout-heading{grid-column:1 / -1}.shoji-layout--masonry .shoji-layout-heading,.shoji-layout--justified .shoji-layout-heading{position:absolute;top:0;left:0;width:100%}.shoji-layout--justified .shoji-layout-heading{width:auto;white-space:nowrap}.shoji-layout--masonry.shoji-layout--animate .shoji-layout-heading,.shoji-layout--justified.shoji-layout--animate .shoji-layout-heading{transition:transform var(--shoji-duration) var(--shoji-easing)}.shoji-layout-heading{font-family:var(--shoji-layout-heading-font-family, inherit)}.shoji-layout-heading-title{font-size:var(--shoji-layout-heading-title-font-size, .875rem);font-weight:var(--shoji-layout-heading-title-font-weight, 400);color:var(--shoji-layout-heading-title-color, #767676);overflow-wrap:break-word}.shoji-layout-heading-subtitle{margin-left:.6em;font-size:var(--shoji-layout-heading-subtitle-font-size, .875rem);font-weight:var(--shoji-layout-heading-subtitle-font-weight, 700);color:var(--shoji-layout-heading-subtitle-color, inherit);overflow-wrap:break-word}.shoji-layout--grid .shoji-layout-heading--sticky{position:sticky;top:0;z-index:1}.shoji-zoom-enabled{cursor:zoom-in}.shoji-zoom-enabled.shoji-zoomed{cursor:grab;will-change:transform}.shoji-zoom-enabled.shoji-zoomed:active{cursor:grabbing}:root{--shoji-z-base: 9000;--shoji-z-backdrop: 0;--shoji-z-slides: 10;--shoji-z-overlay: 20;--shoji-z-toolbar: 30;--shoji-z-toast: 40;--shoji-color-bg: #0b0b0d;--shoji-color-fg: #f5f5f5;--shoji-color-accent: #4da3ff;--shoji-color-backdrop: rgba(0, 0, 0, .92);--shoji-color-toolbar-bg: rgba(20, 20, 22, .85);--shoji-color-disabled: rgba(245, 245, 245, .35);--shoji-focus-ring: 2px solid var(--shoji-color-accent);--shoji-progress: var(--shoji-color-accent);--shoji-spacing-sm: .5rem;--shoji-spacing-md: 1rem;--shoji-spacing-lg: 1.5rem;--shoji-easing: cubic-bezier(.4, 0, .2, 1);--shoji-duration: .3s;--shoji-caption-max-height: min(8rem, 30%);--shoji-provider-video-top-inset: calc(44px + 2 * var(--shoji-spacing-sm));--shoji-momentum-easing: cubic-bezier(.2, 0, 0, 1);--shoji-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"}.shoji-light{--shoji-color-bg: #fafafa;--shoji-color-fg: #111111;--shoji-color-backdrop: rgba(255, 255, 255, .96);--shoji-color-toolbar-bg: rgba(255, 255, 255, .9);--shoji-color-disabled: rgba(17, 17, 17, .35)}@media(prefers-reduced-motion:reduce){:root{--shoji-duration: 0ms}}.shoji-outer{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--shoji-z-base)}.shoji-outer.shoji-open{display:block}.shoji-backdrop{position:absolute;top:0;right:0;bottom:0;left:0;z-index:var(--shoji-z-backdrop);background:var(--shoji-color-backdrop)}.shoji-dialog{position:relative;z-index:var(--shoji-z-slides);display:flex;flex-direction:column;height:100%;color:var(--shoji-color-fg);font-family:var(--shoji-font-family);outline:none;touch-action:none}.shoji-toolbar{position:absolute;inset:0 0 auto 0;z-index:var(--shoji-z-toolbar);display:flex;justify-content:space-between;padding:var(--shoji-spacing-sm);pointer-events:none;will-change:transform}.shoji-toolbar-slot{display:flex;flex-wrap:wrap;align-items:center;gap:var(--shoji-spacing-sm);pointer-events:auto;max-width:45%}.shoji-toolbar-left{justify-content:flex-start}.shoji-toolbar-right{justify-content:flex-end}.shoji-close,.shoji-nav,.shoji-toolbar-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;padding:0;width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:#0006;color:var(--shoji-color-fg);cursor:pointer}.shoji-close:hover,.shoji-nav:hover,.shoji-toolbar-button:hover{background:#0009}.shoji-close:focus-visible,.shoji-nav:focus-visible,.shoji-toolbar-button:focus-visible{outline:var(--shoji-focus-ring);outline-offset:2px}.shoji-nav{position:absolute;top:50%;transform:translateY(-50%);z-index:var(--shoji-z-toolbar)}.shoji-nav-prev{left:var(--shoji-spacing-md)}.shoji-nav-next{right:var(--shoji-spacing-md)}.shoji-nav:disabled{opacity:.3;cursor:default;pointer-events:none}.shoji-close[hidden],.shoji-nav[hidden],.shoji-toolbar-button[hidden]{display:none}.shoji-outer.shoji-slide-loading .shoji-toolbar-button{opacity:.3;cursor:default;pointer-events:none}.shoji-slides{position:relative;flex:1;overflow:hidden}.shoji-slide{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center}.shoji-slide-media{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.shoji-slide-img,.shoji-slide-video{display:block;max-width:100%;max-height:100%;object-fit:contain}.shoji-slide-open-placeholder{width:100%;height:100%}.shoji-slide-provider-video{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:100%;box-sizing:border-box;padding-top:var(--shoji-provider-video-top-inset);container-type:size}.shoji-slide-provider-video[hidden]{display:none}.shoji-slide-provider-video>iframe,.shoji-video-mount{width:min(100cqw,calc(100cqh * 16 / 9))!important;height:min(100cqh,56.25cqw)!important;margin:0!important;padding:0!important}.shoji-slide-provider-video iframe{display:block;border:0}.shoji-video-mount iframe{position:static!important;width:100%!important;height:100%!important}.shoji-video-play-overlay{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--shoji-video-overlay-size, 64px);height:var(--shoji-video-overlay-size, 64px);border-radius:50%;border:none;padding:0;display:flex;align-items:center;justify-content:center;background:var(--shoji-video-overlay-bg, rgba(0, 0, 0, .4));color:var(--shoji-video-overlay-color, var(--shoji-color-fg));cursor:pointer}.shoji-video-play-overlay[hidden]{display:none}.shoji-slide-ghost{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;pointer-events:none}.shoji-slide-placeholder{color:var(--shoji-color-disabled)}.shoji-slide-spinner{width:var(--shoji-spinner-size, 40px);height:var(--shoji-spinner-size, 40px);border-radius:50%;border:var(--shoji-spinner-thickness, 3px) solid var(--shoji-color-disabled);border-top-color:var(--shoji-color-accent);animation:shoji-spin .8s linear infinite}@keyframes shoji-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.shoji-slide-spinner{animation:none}}.shoji-counter{padding:.25rem .6rem;border-radius:999px;background:#0006;font-size:.875rem;white-space:nowrap}.shoji-counter[hidden]{display:none}.shoji-caption{position:absolute;bottom:var(--shoji-spacing-md);left:var(--shoji-spacing-md);z-index:var(--shoji-z-toolbar);width:fit-content;max-width:calc(100% - 2 * var(--shoji-spacing-md));max-height:var(--shoji-caption-max-height);overflow-y:auto;overscroll-behavior:contain;padding:var(--shoji-spacing-sm) var(--shoji-spacing-md);border-radius:8px;background:var(--shoji-color-toolbar-bg);text-align:left}.shoji-caption--video{pointer-events:none}.shoji-caption--video>*{pointer-events:auto}.shoji-caption[hidden]{display:none}.shoji-toolbar,.shoji-nav,.shoji-counter,.shoji-caption{transition:opacity var(--shoji-duration) var(--shoji-easing)}.shoji-controls-hidden .shoji-toolbar,.shoji-controls-hidden .shoji-nav,.shoji-controls-hidden .shoji-counter,.shoji-controls-hidden .shoji-caption{opacity:0;pointer-events:none}.shoji-controls-hidden,.shoji-controls-hidden *{cursor:none!important}.shoji-live-region{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(tt,it){typeof exports=="object"&&typeof module<"u"?module.exports=it():typeof define=="function"&&define.amd?define(it):(tt=typeof globalThis<"u"?globalThis:tt||self,tt.Shoji=it())})(this,(function(){"use strict";var fn=Object.defineProperty;var pn=(tt,it,wt)=>it in tt?fn(tt,it,{enumerable:!0,configurable:!0,writable:!0,value:wt}):tt[it]=wt;var g=(tt,it,wt)=>pn(tt,typeof it!="symbol"?it+"":it,wt);let tt=0,it="",wt="";function Ae(){tt===0&&(it=document.body.style.overflow,document.body.style.overflow="hidden",wt=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"),tt++}function Pe(){tt=Math.max(0,tt-1),tt===0&&(document.body.style.overflow=it,document.documentElement.style.overflow=wt)}class ke{constructor(){g(this,"listeners",new Map)}on(t,e){let n=this.listeners.get(t);return n||(n=new Set,this.listeners.set(t,n)),n.add(e),()=>this.off(t,e)}off(t,e){var n;(n=this.listeners.get(t))==null||n.delete(e)}emit(t,e){const n=this.listeners.get(t);if(n)for(const o of n)o(e)}clear(){this.listeners.clear()}}const He='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>',Oe='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 6l-6 6 6 6"/></svg>',Re='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>',De='<svg viewBox="0 0 24 24" width="28" height="28" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',Ne='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M7 10h10M7 14h6"/></svg>';let Ve=0;function Pt(i,t,e){const n=document.createElement("button");return n.type="button",n.className=i,n.ariaLabel=n.title=e,n.innerHTML=t,n}function $e(i,t){const e=`shoji-counter-${++Ve}`,n=document.createElement("div");n.className="shoji-outer";const o=document.createElement("div");o.className="shoji-backdrop",n.appendChild(o);const s=document.createElement("div");s.className="shoji-dialog",s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",e),s.tabIndex=-1;const r=document.createElement("div");r.className="shoji-toolbar";const a=document.createElement("div");a.className="shoji-toolbar-slot shoji-toolbar-left";const l=document.createElement("div");l.className="shoji-toolbar-slot shoji-toolbar-center";const c=document.createElement("div");c.className="shoji-toolbar-slot shoji-toolbar-right";const d=Pt("shoji-close",He,t.close),m=Pt("shoji-toolbar-button shoji-caption-toggle",Ne,t.showCaption);m.setAttribute("aria-pressed","false"),m.hidden=!0,c.append(m,d);const v=document.createElement("div");v.className="shoji-counter",v.id=e,a.appendChild(v),r.append(a,l,c),s.appendChild(r);const S=Pt("shoji-nav shoji-nav-prev",Oe,t.previous),b=Pt("shoji-nav shoji-nav-next",Re,t.next);s.appendChild(S),s.appendChild(b),s.appendChild(i);const I=document.createElement("div");return I.className="shoji-caption",s.appendChild(I),n.appendChild(s),{outer:n,dialog:s,counter:v,caption:I,closeButton:d,prevButton:S,nextButton:b,captionToggleButton:m,toolbarLeft:a,toolbarCenter:l,toolbarRight:c}}const Be='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), video[controls], [tabindex]:not([tabindex="-1"])';class Ye{constructor(){g(this,"container",null);g(this,"previouslyFocused",null);g(this,"onKeydown",t=>{if(t.key!=="Tab"||!this.container)return;const e=this.getFocusable();if(e.length===0){t.preventDefault(),this.container.focus();return}const n=e[0],o=e[e.length-1],s=document.activeElement,r=s instanceof HTMLElement&&e.includes(s);t.shiftKey?(!r||s===n)&&(t.preventDefault(),o.focus()):(!r||s===o)&&(t.preventDefault(),n.focus())})}getFocusable(){return this.container?Array.from(this.container.querySelectorAll(Be)):[]}activate(t){this.previouslyFocused=document.activeElement,this.container=t,document.addEventListener("keydown",this.onKeydown,!0),t.focus()}deactivate(){var t;document.removeEventListener("keydown",this.onKeydown,!0),this.container=null,(t=this.previouslyFocused)==null||t.focus({preventScroll:!0}),this.previouslyFocused=null}}const We=300,_e=30,ze=500;class Fe{constructor(t,e,n){g(this,"target");g(this,"options");g(this,"callbacks");g(this,"pointers",new Map);g(this,"primaryPointerId",null);g(this,"direction",null);g(this,"dragStartDistance",0);g(this,"pinching",!1);g(this,"pinchStartDistance",0);g(this,"lastTapTime",-1/0);g(this,"lastTapX",0);g(this,"lastTapY",0);g(this,"onPointerDown",t=>{var e,n,o,s;if(!(t.isPrimary===!1&&this.pointers.size===0)&&!(this.pointers.size===0&&((n=(e=this.callbacks).ignore)!=null&&n.call(e,t)))){if(this.pointers.set(t.pointerId,{startX:t.clientX,startY:t.clientY,startTime:t.timeStamp,lastX:t.clientX,lastY:t.clientY,lastTime:t.timeStamp}),this.pointers.size===1)this.primaryPointerId=t.pointerId,this.direction=null;else if(this.pointers.size===2){this.direction=null,this.pinching=!0;const[r,a]=[...this.pointers.values()];this.pinchStartDistance=Kt(r,a);const l=Jt(r,a);(s=(o=this.callbacks).onPinchStart)==null||s.call(o,l.x,l.y)}}});g(this,"onPointerMove",t=>{var r,a,l,c,d,m,v,S;const e=this.pointers.get(t.pointerId);if(!e)return;if(e.lastX=t.clientX,e.lastY=t.clientY,e.lastTime=t.timeStamp,this.pinching){if(this.pointers.size<2)return;const[b,I]=[...this.pointers.values()],P=Kt(b,I),N=this.pinchStartDistance>0?P/this.pinchStartDistance:1,C=Jt(b,I);(a=(r=this.callbacks).onPinchMove)==null||a.call(r,N,C.x,C.y);return}if(t.pointerId!==this.primaryPointerId)return;const n=t.clientX-e.startX,o=t.clientY-e.startY;if(this.direction===null){const b=Math.abs(n),I=Math.abs(o);if(Math.max(b,I)<this.options.lockThreshold)return;this.direction=b>I?"horizontal":"vertical",this.dragStartDistance=this.direction==="horizontal"?n:o,(((c=(l=this.callbacks).shouldCapture)==null?void 0:c.call(l))??!0)&&this.target.setPointerCapture(t.pointerId),(m=(d=this.callbacks).onDragStart)==null||m.call(d,this.direction,t)}this.direction==="horizontal"&&t.preventDefault();const s=(this.direction==="horizontal"?n:o)-this.dragStartDistance;(S=(v=this.callbacks).onDragMove)==null||S.call(v,this.direction,s,t)});g(this,"onPointerUp",t=>{this.finishPointer(t,!1)});g(this,"onPointerCancel",t=>{this.finishPointer(t,!0)});g(this,"onWheel",t=>{var n,o;if(!t.ctrlKey)return;t.preventDefault();const e=-t.deltaY*.01;(o=(n=this.callbacks).onWheelZoom)==null||o.call(n,e,t.clientX,t.clientY,t)});this.target=t,this.callbacks=e,this.options={lockThreshold:(n==null?void 0:n.lockThreshold)??10,swipeThreshold:(n==null?void 0:n.swipeThreshold)??50,swipeVelocity:(n==null?void 0:n.swipeVelocity)??.3},this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerCancel),this.target.addEventListener("wheel",this.onWheel,{passive:!1})}destroy(){this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerCancel),this.target.removeEventListener("wheel",this.onWheel),this.pointers.clear()}finishPointer(t,e){var o,s,r,a;const n=this.pointers.get(t.pointerId);if(n){if(n.lastX=t.clientX,n.lastY=t.clientY,n.lastTime=t.timeStamp,this.pointers.delete(t.pointerId),this.pinching){this.pointers.size<2&&(this.pinching=!1,(s=(o=this.callbacks).onPinchEnd)==null||s.call(o));return}if(t.pointerId===this.primaryPointerId){if(this.direction===null)!e&&t.timeStamp-n.startTime<=ze&&this.registerTap(n.lastX,n.lastY,t);else{const l=Math.max(1,n.lastTime-n.startTime),c=(this.direction==="horizontal"?n.lastX-n.startX:n.lastY-n.startY)-this.dragStartDistance,d=c/l,m=!e&&(Math.abs(c)>=this.options.swipeThreshold||Math.abs(d)>=this.options.swipeVelocity);(a=(r=this.callbacks).onDragEnd)==null||a.call(r,this.direction,c,d,m,e)}this.primaryPointerId=null,this.direction=null}}}registerTap(t,e,n){var r,a,l,c;const o=n.timeStamp;o-this.lastTapTime<=We&&Math.hypot(t-this.lastTapX,e-this.lastTapY)<=_e?((a=(r=this.callbacks).onDoubleTap)==null||a.call(r,t,e,n),this.lastTapTime=0):((c=(l=this.callbacks).onTap)==null||c.call(l,t,e,n),this.lastTapTime=o,this.lastTapX=t,this.lastTapY=e)}}function Kt(i,t){return Math.hypot(i.lastX-t.lastX,i.lastY-t.lastY)}function Jt(i,t){return{x:(i.lastX+t.lastX)/2,y:(i.lastY+t.lastY)/2}}function Qt(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Xe(i){var e;const t=((e=i.split(",")[0])==null?void 0:e.trim())??"";return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?parseFloat(t)*1e3:0}function Ue(i,t){const e=i.width/i.height,n=t>e?i.width:i.height*t,o=t>e?i.width/t:i.height;return{left:i.left+(i.width-n)/2,top:i.top+(i.height-o)/2,width:n,height:o}}function Ze(i,t){const e=i.firstElementChild,n=e instanceof HTMLElement&&(e.classList.contains("shoji-slide-spinner")||e.classList.contains("shoji-slide-open-placeholder"));if(e instanceof HTMLElement&&!n){const s=e.getBoundingClientRect();if(s.width>0&&s.height>0)return s}const o=i.getBoundingClientRect();return t&&o.width>0&&o.height>0?Ue(o,t):o}function te(i,t,e){const n=i.getBoundingClientRect(),o=Ze(t,e);if(o.width===0||o.height===0||n.width===0||n.height===0)return null;const s=Math.min(n.width/o.width,n.height/o.height),r=n.left+n.width/2-(o.left+o.width/2),a=n.top+n.height/2-(o.top+o.height/2);return`translate3d(${r}px, ${a}px, 0) scale3d(${s}, ${s}, 1)`}function Ct(i,t){const e=Xe(getComputedStyle(i).transitionDuration);let n=!1;const o=()=>{n||(n=!0,i.removeEventListener("transitionend",s),t())},s=r=>{r.target===i&&r.propertyName==="transform"&&o()};i.addEventListener("transitionend",s),setTimeout(o,e+100)}function ee(i,t){i.style.transition="",i.style.transformOrigin="",i.style.willChange="",i.style.transform===t&&(i.style.transform="")}function qe({origin:i,target:t,aspectRatio:e}){if(Qt())return;const n=te(i,t,e);n&&(t.style.transition="none",t.style.transformOrigin="center",t.style.willChange="transform",t.style.transform=n,t.offsetHeight,t.style.transition="transform var(--shoji-duration) var(--shoji-easing)",t.style.transform="none",Ct(t,()=>ee(t,"none")))}function Ge({origin:i,target:t,aspectRatio:e},n){if(Qt()){n();return}const o=te(i,t,e);if(!o){n();return}t.style.transformOrigin="center",t.style.willChange="transform",t.style.transition="transform var(--shoji-duration) var(--shoji-easing)",t.offsetHeight,t.style.transform=o;const s=t.style.transform;Ct(t,()=>{ee(t,s),n()})}const Ke="transform var(--shoji-duration) var(--shoji-momentum-easing)",Je="transform var(--shoji-duration) var(--shoji-momentum-easing), opacity var(--shoji-duration) var(--shoji-momentum-easing)",Qe=160,ie="button, video, input, select, textarea, a[href], [data-shoji-no-drag]";function ti(i){return i.composedPath().some(t=>t instanceof Element&&t.matches(ie))}class ei{constructor(t,e,n){g(this,"engine");g(this,"onDragMove",(t,e)=>{this.host.isZoomed()||(t==="horizontal"?this.host.slides.setDragOffset(e,null):this.host.canClose()&&this.applyVerticalDragFeedback(e))});g(this,"onDragEnd",(t,e,n,o)=>{this.host.isZoomed()||(t==="horizontal"?this.finishHorizontalDrag(e,o):this.finishVerticalDrag(o))});this.host=t,this.engine=new Fe(t.dialog,{ignore:ti,shouldCapture:()=>!t.isZoomed(),onDragStart:()=>t.onActivity(),onDragMove:this.onDragMove,onDragEnd:this.onDragEnd,onTap:(o,s)=>e.onTap(o,s),onDoubleTap:(o,s)=>e.onDoubleTap(o,s),onPinchStart:(o,s)=>e.onPinchStart(o,s),onPinchMove:(o,s,r)=>e.onPinchMove(o,s,r),onPinchEnd:()=>e.onPinchEnd(),onWheelZoom:(o,s,r)=>e.onWheelZoom(o,s,r)},n)}destroy(){this.engine.destroy()}finishHorizontalDrag(t,e){const n=t<0,o=n?this.host.canGoNext():this.host.canGoPrev();if(!e||t===0||!o){this.settleDragOffset(0,()=>{});return}const s=this.host.dialog.getBoundingClientRect().width||1,r=n?-s:s;this.settleDragOffset(r,()=>{this.host.slides.setDragOffset(0,null),n?this.host.next():this.host.prev()})}settleDragOffset(t,e){const n=this.host.slides.getSlotRoot(0);if(this.host.slides.setDragOffset(t,Ke),!n){e();return}Ct(n,e)}applyVerticalDragFeedback(t){const e=Math.min(Math.abs(t)/Qe,1),n=this.host.dialog;n.style.transition="",n.style.transform=`translateY(${t}px) scale(${1-e*.15})`,n.style.opacity=String(1-e*.6)}clearVerticalDragFeedback(t){const e=this.host.dialog;e.style.transition=t?Je:"",e.style.transform="",e.style.opacity=""}finishVerticalDrag(t){t&&this.host.canClose()?(this.clearVerticalDragFeedback(!1),this.host.close()):this.clearVerticalDragFeedback(!0)}}class ii{constructor(){g(this,"element");this.element=document.createElement("div"),this.element.className="shoji-live-region",this.element.setAttribute("role","status"),this.element.setAttribute("aria-live","polite")}announce(t){this.element.textContent="",this.element.offsetWidth,this.element.textContent=t}}const Bt=":scope > a, :scope > [data-shoji-src], :scope > [data-shoji-video]";function ne(i,t=Bt){const e=Array.from(i.querySelectorAll(t)),n=[];for(const o of e){const s=si(o)??oi(o);s&&n.push({element:o,item:s})}return n}function ot(i,t){return i.getAttribute(t)??void 0}function oe(i,t){const e=i.getAttribute(t);if(e===null)return;const n=Number(e);return Number.isFinite(n)?n:void 0}const ni=new Set(["no-drag","video-id","video-provider"]);function Yt(i,t,e){const n=ot(i,"data-shoji-caption");n&&(t.caption=n),t.id=ot(i,"data-shoji-id")??e;let o;for(const s of i.attributes){if(!s.name.startsWith("data-shoji-"))continue;const r=s.name.slice(11);!ni.has(r)&&!(r in t)&&((o??(o={}))[r]=s.value)}o&&(t.data=o)}function oi(i){const t=ot(i,"href")??ot(i,"data-shoji-src");if(!t)return;const e={src:t},n=i.querySelector("img"),o=(n==null?void 0:n.getAttribute("src"))??ot(i,"data-shoji-thumb");o&&(e.thumb=o);const s=(n==null?void 0:n.getAttribute("alt"))??ot(i,"data-shoji-alt");s&&(e.alt=s);const r=oe(i,"data-shoji-width");r!==void 0&&(e.width=r);const a=oe(i,"data-shoji-height");a!==void 0&&(e.height=a);const l=ot(i,"data-shoji-srcset");l&&(e.srcset=l);const c=ot(i,"data-shoji-sizes");return c&&(e.sizes=c),Yt(i,e,t),e}function si(i){var o;const t=ot(i,"data-shoji-video-id"),e=i.querySelector("video");if(e){t&&console.warn(`Shoji: data-shoji-video-id="${t}" ignored — no effect on a nested <video> (always html5).`);const s=Array.from(e.querySelectorAll("source")).map(c=>({src:c.getAttribute("src")??"",type:c.getAttribute("type")??""})).filter(c=>c.src),r=e.getAttribute("src")??((o=s[0])==null?void 0:o.src);if(!r)return;const a={src:r,video:{provider:"html5"}};s.length&&(a.sources=s);const l=e.getAttribute("poster");return l&&(a.poster=l),Yt(i,a,r),a}const n=ot(i,"data-shoji-video");if(n){const s=ot(i,"data-shoji-video-provider"),r=ai(n,s,t),a={src:n,video:r.video};r.sources&&(a.sources=r.sources);const l=ot(i,"data-shoji-poster");return l&&(a.poster=l),Yt(i,a,n),a}t&&console.warn(`Shoji: data-shoji-video-id="${t}" ignored — requires a data-shoji-video URL.`)}const ri=new Set(["youtube","vimeo","html5"]);function Wt(i){return{video:{provider:"html5"},sources:[{src:i,type:li(i)}]}}function ai(i,t,e){if(t&&!ri.has(t)&&(console.warn(`Shoji: data-shoji-video-provider="${t}" isn't recognized — ignored.`),t=void 0),t==="html5")return e&&console.warn(`Shoji: data-shoji-video-id="${e}" ignored — provider html5 has no id.`),Wt(i);const n=se("youtube",i,t,e,le,de);if(n)return n;const o=se("vimeo",i,t,e,ce,ue);return o||(e&&console.warn(`Shoji: data-shoji-video-id="${e}" ignored — data-shoji-video="${i}" isn't a recognized YouTube/Vimeo URL; falling back to html5.`),Wt(i))}function se(i,t,e,n,o,s){const r=e===i;if(!r&&!o(t))return;const a=n??s(t);if(!a){if(!r)return Wt(t);console.warn(`Shoji: data-shoji-video-provider="${i}" but no id could be parsed from "${t}".`)}return{video:{provider:i,id:a,url:t}}}const re=new Set(["youtu.be","youtube.com","youtube-nocookie.com"]),ae=new Set(["vimeo.com","player.vimeo.com"]);function kt(i){return i.replace(/^(www|m|music)\./,"")}function le(i){try{return re.has(kt(new URL(i,window.location.href).hostname))}catch{return!1}}function ce(i){try{return ae.has(kt(new URL(i,window.location.href).hostname))}catch{return!1}}function de(i){let t;try{t=new URL(i,window.location.href)}catch{return}const e=kt(t.hostname);if(e==="youtu.be")return t.pathname.slice(1).split("/")[0]||void 0;if(!re.has(e))return;if(t.pathname==="/watch")return t.searchParams.get("v")??void 0;const n=t.pathname.match(/^\/(?:embed|shorts|live|v)\/([^/?]+)/);return n==null?void 0:n[1]}function ue(i){var e;let t;try{t=new URL(i,window.location.href)}catch{return}if(ae.has(kt(t.hostname)))return(e=t.pathname.match(/\/(\d+)(?:\/|$)/))==null?void 0:e[1]}const he=[{provider:"youtube",isHost:le,detectId:de},{provider:"vimeo",isHost:ce,detectId:ue}];function fe(i){return i.map(t=>{var s,r;if(t.video===!0){const a=he.find(c=>c.isHost(t.src)),l=a?{provider:a.provider,id:a.detectId(t.src)}:{provider:"html5"};return(l.provider==="youtube"||l.provider==="vimeo")&&!l.id&&console.warn(`Shoji: item "${t.id??t.src}" has video: true, but no id could be parsed from src ("${t.src}") — the embed won't load. Use an explicit video.id instead.`),{...t,video:l}}const e=t,n=(s=e.video)==null?void 0:s.provider;if(n!=="youtube"&&n!=="vimeo"||e.video&&"id"in e.video&&e.video.id)return e;const o=he.find(a=>a.provider===n).detectId(e.src);return o?{...e,video:{provider:n,id:o,url:(r=e.video)==null?void 0:r.url}}:(console.warn(`Shoji: item "${e.id??e.src}" has video.provider: '${n}' with no id, and src ("${e.src}") isn't a recognized ${n==="youtube"?"YouTube":"Vimeo"} URL — the embed won't load. Set video.id explicitly.`),e)})}function li(i){const t=i.split(/[?#]/)[0]??i,e=t.slice(t.lastIndexOf(".")+1).toLowerCase();return e==="webm"?"video/webm":e==="ogg"||e==="ogv"?"video/ogg":"video/mp4"}const ci=200;class di{constructor(t){g(this,"element");g(this,"slots");g(this,"preload");g(this,"playVideoLabel");g(this,"videoProviders");g(this,"dragOffsetPx",0);g(this,"cache",new Map);g(this,"pending",new Map);this.element=document.createElement("div"),this.element.className="shoji-slides",this.preload=t.preload,this.playVideoLabel=t.playVideoLabel,this.videoProviders=t.videoProviders;const e=t.preload*2+1;this.slots=Array.from({length:e},(n,o)=>{const s=o-t.preload,r=document.createElement("div");r.className="shoji-slide";const a=document.createElement("div");return a.className="shoji-slide-media",r.appendChild(a),this.element.appendChild(r),{root:r,media:a,offset:s,assignedIndex:null,ready:!1}}),this.applyTransforms(null)}getActiveMedia(){var t;return((t=this.slots.find(e=>e.offset===0))==null?void 0:t.media)??null}isActiveReady(){var t;return((t=this.slots.find(e=>e.offset===0))==null?void 0:t.ready)??!1}setDragOffset(t,e){this.dragOffsetPx=t,this.applyTransforms(e)}getSlotRoot(t){var e;return((e=this.slots.find(n=>n.offset===t))==null?void 0:e.root)??null}applyTransforms(t){for(const e of this.slots)e.root.style.transition=t??"",e.root.style.transform=`translateX(calc(${e.offset*100}% + ${this.dragOffsetPx}px))`}render(t,e,n,o){for(const[d,m]of this.cache)(d<e-this.preload||d>e+this.preload)&&(me(m.node),this.cache.delete(d));const s=this.slots.map((d,m)=>{const v=m-this.preload,S=e+v,b=S>=0&&S<t.length?t[S]:void 0;return{offset:v,index:S,item:b}}),r=new Set,a=new Set;for(const d of s){if(!d.item)continue;const m=this.slots.find(v=>v.assignedIndex===d.index&&v.ready);m&&(r.add(d.index),a.add(m),m.offset!==d.offset&&(m.offset=d.offset,n(d.index)))}const l=this.slots.filter(d=>!a.has(d));s.filter(d=>!d.item||!r.has(d.index)).forEach((d,m)=>{var I;const v=l[m];v.offset=d.offset;const{index:S,item:b}=d;if(!b){v.assignedIndex=null,v.ready=!1,Ht(v.media),v.media.replaceChildren();return}v.assignedIndex!==S&&(v.assignedIndex=S,v.ready=!1,Ht(v.media),v.media.replaceChildren(hi()),S===e&&o&&this.revealOpenPlaceholder(o,v,S),((I=b.video)==null?void 0:I.provider)==="html5"?this.renderVideo(b,v,S,n):b.video?this.renderProviderVideo(b,v,S,n):this.ensureImageDecoding(b,S,n))}),this.applyTransforms(null)}applyAspect(t,e){e.width&&e.height?t.media.style.aspectRatio=`${e.width} / ${e.height}`:t.media.style.removeProperty("aspect-ratio")}swapIn(t,e,n,o,s){Ht(t.media),this.applyAspect(t,n),s?t.media.replaceChildren(e,s):t.media.replaceChildren(e),t.ready=!0,this.cache.set(o,{node:e,item:n,extra:s})}moveIn(t,e,n){this.applyAspect(t,e.item),e.extra?t.media.replaceChildren(e.node,e.extra):t.media.replaceChildren(e.node),t.ready=!0,this.cache.set(n,e)}ensureImageDecoding(t,e,n){if(this.pending.has(e))return;const o=document.createElement("img");o.className="shoji-slide-img",o.alt=t.alt??"",o.draggable=!1,"fetchPriority"in o&&(o.fetchPriority="high"),t.srcset&&(o.srcset=t.srcset),t.sizes&&(o.sizes=t.sizes),o.src=t.src,this.pending.set(e,o);const s=()=>{this.pending.delete(e);const r={node:o,item:t};this.cache.set(e,r);const a=this.slots.find(l=>l.assignedIndex===e);a&&(this.moveIn(a,r,e),n(e))};typeof o.decode=="function"?o.decode().then(s,s):(o.addEventListener("load",s,{once:!0}),o.addEventListener("error",s,{once:!0}))}revealOpenPlaceholder(t,e,n){const o=ui(t),s=()=>{var r;e.assignedIndex!==n||e.ready||((r=e.media.querySelector(".shoji-slide-spinner"))==null||r.remove(),e.media.appendChild(o))};typeof o.decode=="function"?o.decode().then(s,s):(o.addEventListener("load",s,{once:!0}),o.addEventListener("error",s,{once:!0}))}renderVideo(t,e,n,o){if(!(!!t.src||!!(t.sources&&t.sources.length>0))){const l=document.createElement("div");l.className="shoji-slide-placeholder",l.textContent="Video",this.swapIn(e,l,t,n),o(n);return}const r=document.createElement("video");if(r.className="shoji-slide-video",r.controls=!0,r.playsInline=!0,t.poster&&(r.poster=t.poster),t.sources&&t.sources.length>0)for(const l of t.sources){const c=document.createElement("source");c.src=l.src,c.type=l.type,r.appendChild(c)}else r.src=t.src;this.swapIn(e,r,t,n,this.createVideoPlayOverlay(r));const a=()=>o(n);r.addEventListener("loadedmetadata",a,{once:!0}),r.addEventListener("error",a,{once:!0})}createVideoPlayOverlay(t){const e=document.createElement("button");e.type="button",e.className="shoji-video-play-overlay",e.innerHTML=De,e.ariaLabel=e.title=this.playVideoLabel,e.hidden=!t.paused;let n=null;const o=()=>{n!==null&&(clearTimeout(n),n=null)};return e.addEventListener("click",s=>{s.stopPropagation(),t.play().catch(()=>{})}),t.addEventListener("play",()=>{o(),e.hidden=!0}),t.addEventListener("pause",()=>{o(),n=setTimeout(()=>{n=null,t.paused&&(e.hidden=!1)},ci)}),t.addEventListener("ended",()=>{o(),e.hidden=!1}),e}renderProviderVideo(t,e,n,o){const s=t.video,r=s.provider==="custom"?s.render:this.videoProviders.get(s.provider);if(!r){const m=document.createElement("div");m.className="shoji-slide-placeholder",m.textContent="Video",this.swapIn(e,m,t,n),o(n);return}const a=document.createElement("div");a.className="shoji-slide-provider-video",a.hidden=!0;const l=new AbortController;_t.set(a,l),e.media.appendChild(a);let c=!1;r(a,t,()=>{var m;c||l.signal.aborted||(c=!0,a.hidden=!1,(m=e.media.querySelector(".shoji-slide-spinner, .shoji-slide-open-placeholder"))==null||m.remove(),this.applyAspect(e,t),e.ready=!0,this.cache.set(n,{node:a,item:t}),o(n))},l.signal)}destroy(){for(const t of this.slots)Ht(t.media),t.media.replaceChildren(),t.assignedIndex=null,t.ready=!1;this.cache.clear(),this.pending.clear(),this.element.remove()}}function ui(i){const t=document.createElement("img");return t.className="shoji-slide-img shoji-slide-open-placeholder",t.alt="",t.draggable=!1,t.src=i,t}function hi(){const i=document.createElement("div");return i.className="shoji-slide-spinner",i.setAttribute("aria-hidden","true"),i}const _t=new WeakMap;function Ht(i){const t=i.querySelector("video");t&&me(t);const e=i.querySelector(".shoji-slide-provider-video");e&&ge(e)}function pe(i){const t=i==null?void 0:i.querySelector("video");if(t){t.pause();return}const e=i==null?void 0:i.querySelector(".shoji-slide-provider-video");e&&typeof e.pause=="function"&&e.pause()}function me(i){if(i.tagName!=="VIDEO"){ge(i);return}const t=i;t.pause(),t.removeAttribute("src"),t.load()}function ge(i){const t=_t.get(i);t&&(_t.delete(i),t.abort())}function ve(i,t){const e=i.directional?t:1,n=[];i.perspective&&n.push(`perspective(${i.perspective}px)`);const o=i.translateX!==void 0?i.translateX*e:0,s=i.translateY??0;return(o!==0||s!==0)&&n.push(`translate(${o}%, ${s}%)`),i.rotateY!==void 0&&n.push(`rotateY(${i.rotateY*e}deg)`),i.rotateX!==void 0&&n.push(`rotateX(${i.rotateX}deg)`),i.rotateZ!==void 0&&n.push(`rotateZ(${i.rotateZ*e}deg)`),i.scale!==void 0&&n.push(`scale(${i.scale})`),{transform:n.length>0?n.join(" "):"none",opacity:i.opacity??1}}function U(i){return{name:i.name,enter:t=>ve(i.enter,t),leave:t=>ve(i.leave,t)}}const fi=[U({name:"slide",enter:{directional:!0,translateX:100},leave:{directional:!0,translateX:-100}}),U({name:"fade",enter:{opacity:0},leave:{opacity:0}}),U({name:"zoom",enter:{scale:.6,opacity:0},leave:{scale:1.4,opacity:0}}),U({name:"deck",enter:{translateY:6,scale:.85,opacity:0},leave:{translateY:-4,scale:.92,opacity:0}}),U({name:"slideVertical",enter:{directional:!0,translateY:100},leave:{directional:!0,translateY:-100}}),U({name:"push",enter:{directional:!0,translateX:120},leave:{directional:!0,translateX:-120}}),U({name:"fadeUp",enter:{translateY:12,opacity:0},leave:{translateY:-12,opacity:0}}),U({name:"fadeDown",enter:{translateY:-12,opacity:0},leave:{translateY:12,opacity:0}}),U({name:"fadeLeft",enter:{translateX:-12,opacity:0},leave:{translateX:12,opacity:0}}),U({name:"fadeRight",enter:{translateX:12,opacity:0},leave:{translateX:-12,opacity:0}}),U({name:"zoomOut",enter:{scale:1.4,opacity:0},leave:{scale:.6,opacity:0}}),U({name:"scaleUp",enter:{scale:.7},leave:{scale:1.3}}),U({name:"scaleDown",enter:{scale:1.3},leave:{scale:.7}}),U({name:"rotate",enter:{rotateZ:15,opacity:0},leave:{rotateZ:-15,opacity:0}}),U({name:"rotateLeft",enter:{directional:!0,rotateZ:-25,opacity:0},leave:{directional:!0,rotateZ:25,opacity:0}}),U({name:"rotateRight",enter:{directional:!0,rotateZ:25,opacity:0},leave:{directional:!0,rotateZ:-25,opacity:0}}),U({name:"flipX",enter:{rotateX:90,perspective:1200,opacity:0},leave:{rotateX:-90,perspective:1200,opacity:0}}),U({name:"flipY",enter:{directional:!0,rotateY:90,perspective:1200,opacity:0},leave:{directional:!0,rotateY:-90,perspective:1200,opacity:0}}),U({name:"cube",enter:{directional:!0,rotateY:70,translateX:40,perspective:1600,opacity:1},leave:{directional:!0,rotateY:-70,translateX:-40,perspective:1600,opacity:1}}),U({name:"coverflow",enter:{directional:!0,rotateY:35,translateX:60,scale:.8,perspective:1400,opacity:0},leave:{directional:!0,rotateY:-35,translateX:-60,scale:.8,perspective:1400,opacity:0}}),U({name:"drop",enter:{translateY:-30,opacity:0},leave:{translateY:20,opacity:0}})],pi=Object.fromEntries(fi.map(i=>[i.name,i]));function mi(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ye(i){var e;const t=((e=i.split(",")[0])==null?void 0:e.trim())??"";return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?parseFloat(t)*1e3:0}function we(i,t){const e=getComputedStyle(i),n=Math.max(ye(e.transitionDuration),ye(e.animationDuration));let o=!1;const s=()=>{o||(o=!0,i.removeEventListener("transitionend",r),i.removeEventListener("animationend",r),t())},r=a=>{a.target===i&&s()};i.addEventListener("transitionend",r),i.addEventListener("animationend",r),setTimeout(s,n+100)}function gi(i,t,e){i.style.transition="none",i.style.transformOrigin="center",i.style.transform=t,i.style.opacity=String(e),i.offsetHeight,i.style.transition="transform var(--shoji-duration) var(--shoji-easing), opacity var(--shoji-duration) var(--shoji-easing)",i.style.transform="none",i.style.opacity="1"}function vi(i,t,e){i.style.transformOrigin="center",i.style.transition="transform var(--shoji-duration) var(--shoji-easing), opacity var(--shoji-duration) var(--shoji-easing)",i.offsetHeight,i.style.transform=t,i.style.opacity=String(e)}function yi(i){i.style.transition="",i.style.transform="",i.style.opacity="",i.style.transformOrigin=""}class wi{constructor(t){this.slides=t}animate(t,e,n){this.run(n,(o,s)=>{const r=t.leave(e);vi(o,r.transform,r.opacity);const a=t.enter(e);gi(s,a.transform,a.opacity)})}animateCustom(t,e,n){const o=e===1?"next":"prev";this.run(n,(s,r)=>{s.dataset.shojiDirection=o,s.classList.add(`shoji-transition-${t}-leave`),r.dataset.shojiDirection=o,r.classList.add(`shoji-transition-${t}-enter`)},s=>{s.classList.remove(`shoji-transition-${t}-enter`),delete s.dataset.shojiDirection})}run(t,e,n=yi){if(mi()){t();return}const o=this.slides.getActiveMedia();if(!o){t();return}const s=document.createElement("div");s.className="shoji-slide-ghost",s.appendChild(o.cloneNode(!0)),this.slides.element.appendChild(s),s.offsetHeight,t();const r=this.slides.getActiveMedia();if(!r){s.remove();return}e(s,r),we(s,()=>s.remove()),we(r,()=>n(r))}}function zt(i){return i.id??i.src}function bi(i){if(typeof i!="string")return i;const t=document.querySelector(i);if(!t)throw new Error(`Shoji: no element matches selector "${i}"`);return t}const Ot=new WeakMap,Ft=new Set,be={close:"Close",previous:"Previous image",next:"Next image",playVideo:"Play video",showCaption:"Show caption",hideCaption:"Hide caption"};function Si(i){return!i.composedPath().some(t=>t instanceof Element&&t.matches(`.shoji-slide-img, .shoji-slide-provider-video, .shoji-counter, .shoji-caption, ${ie}`))}function Ei(i){return typeof i=="object"&&i!==null&&typeof i.dangerouslySetInnerHTML=="string"}class Ci{constructor(t,e={}){g(this,"options",{});g(this,"element");g(this,"bus",new ke);g(this,"selector",Bt);g(this,"isDynamicMode",!1);g(this,"preload",1);g(this,"locale",be);g(this,"showCounter",!0);g(this,"captionVisibleOnVideo",!1);g(this,"loop",!0);g(this,"closable",!0);g(this,"autoHideDelay",5e3);g(this,"focusTrap",new Ye);g(this,"liveRegion",new ii);g(this,"autoHideTimer",null);g(this,"autoHidden",!1);g(this,"hoveredControlCount",0);g(this,"isClosing",!1);g(this,"itemList",[]);g(this,"scannedElements",[]);g(this,"activeIndex",0);g(this,"opened",!1);g(this,"destroyed",!1);g(this,"slides",null);g(this,"dom",null);g(this,"gesture",null);g(this,"transition",null);g(this,"shortcuts",new Map);g(this,"pluginStorage",new Map);g(this,"activePluginNames",new Set);g(this,"videoProviders",new Map);g(this,"zoomGate",null);g(this,"pluginCleanups",[]);g(this,"onContainerClick",t=>{let e=t.target;for(;e&&e!==this.element;){if(e instanceof HTMLElement){const n=this.scannedElements.indexOf(e);if(n!==-1){t.preventDefault(),this.open(n);return}}e=e.parentNode}});g(this,"onOuterClick",t=>{this.closable&&Si(t)&&this.close()});g(this,"onActivity",()=>{this.autoHideDelay!==0&&(this.showControls(),this.scheduleAutoHide())});g(this,"onKeydown",t=>{if(!(document.activeElement instanceof HTMLVideoElement&&t.key!=="Escape")){switch(this.onActivity(),t.key){case"Escape":this.closable&&this.close();break;case"ArrowLeft":case"a":case"A":this.prev();break;case"ArrowRight":case"d":case"D":this.next();break;case"Home":this.goTo(0);break;case"End":this.goTo(this.itemList.length-1);break;default:{const e=this.shortcuts.get(t.key);if(!e)return;e(t)}}t.preventDefault()}});this.element=bi(t),Ot.set(this.element,this),Ft.add(this),this.applyOptions(e)}static getInstance(t){return Ot.get(t)}static instances(){return Ft.values()}applyOptions(t){if(this.options=t,this.selector=t.selector??Bt,this.isDynamicMode=t.items!==void 0,this.preload=t.preload??1,this.locale={...be,...t.locale},this.showCounter=t.counter??!0,this.loop=t.loop??!0,this.closable=t.closable??!0,this.autoHideDelay=t.autoHideDelay??5e3,this.activeIndex=0,this.scannedElements=[],this.isDynamicMode)this.itemList=fe(t.items??[]);else{const e=ne(this.element,this.selector);this.itemList=e.map(n=>n.item),this.scannedElements=e.map(n=>n.element),this.element.addEventListener("click",this.onContainerClick)}this.ensureLightbox(),this.dom.closeButton.hidden=!this.closable,t.openOnInit&&this.itemList.length>0&&this.open(t.index??0)}get items(){return this.itemList}get currentIndex(){return this.activeIndex}get isOpen(){return this.opened}get isDestroyed(){return this.destroyed}get controlsHidden(){return this.autoHidden}getActivePlugins(){return[...this.activePluginNames]}getActiveMedia(){var t;return((t=this.slides)==null?void 0:t.getActiveMedia())??null}registerZoomGate(t){return this.zoomGate=t,()=>{this.zoomGate===t&&(this.zoomGate=null)}}on(t,e){return this.bus.on(t,e)}clampToRange(t){return Math.min(Math.max(t,0),Math.max(this.itemList.length-1,0))}ensureLightbox(){if(this.dom)return;this.slides=new di({preload:this.preload,playVideoLabel:this.locale.playVideo,videoProviders:this.videoProviders}),this.transition=new wi(this.slides);const t=$e(this.slides.element,this.locale);this.dom=t,t.outer.appendChild(this.liveRegion.element),t.closeButton.addEventListener("click",()=>this.close()),t.prevButton.addEventListener("click",()=>this.prev()),t.nextButton.addEventListener("click",()=>this.next()),t.captionToggleButton.addEventListener("click",()=>{this.captionVisibleOnVideo=!this.captionVisibleOnVideo,this.updateCaptionVisibility()}),t.outer.addEventListener("click",this.onOuterClick),t.outer.addEventListener("pointermove",this.onActivity,{passive:!0}),t.outer.addEventListener("pointerdown",this.onActivity,{passive:!0}),t.outer.addEventListener("touchstart",this.onActivity,{passive:!0}),t.outer.addEventListener("wheel",this.onActivity,{passive:!0}),t.outer.addEventListener("focusin",this.onActivity),t.outer.addEventListener("focusout",()=>this.scheduleAutoHide());for(const e of[t.closeButton,t.prevButton,t.nextButton,t.captionToggleButton,t.caption,t.counter,t.toolbarLeft,t.toolbarCenter,t.toolbarRight])this.wireControlHover(e);document.body.appendChild(t.outer),this.gesture=new ei({dialog:t.dialog,slides:this.slides,canGoNext:()=>this.loop||this.activeIndex<this.itemList.length-1,canGoPrev:()=>this.loop||this.activeIndex>0,next:()=>this.navigate(this.nextIndex(),1,!1),prev:()=>this.navigate(this.prevIndex(),-1,!1),close:()=>this.close(),canClose:()=>this.closable,onActivity:()=>this.onActivity(),isZoomed:()=>{var e;return((e=this.zoomGate)==null?void 0:e.call(this))??!1}},{onTap:(e,n)=>this.bus.emit("tap",{x:e,y:n}),onDoubleTap:(e,n)=>this.bus.emit("doubleTap",{x:e,y:n}),onPinchStart:(e,n)=>this.bus.emit("pinchStart",{centerX:e,centerY:n}),onPinchMove:(e,n,o)=>this.bus.emit("pinchMove",{scale:e,centerX:n,centerY:o}),onPinchEnd:()=>this.bus.emit("pinchEnd",{}),onWheelZoom:(e,n,o)=>this.bus.emit("wheelZoom",{deltaScale:e,x:n,y:o})},this.options.gestures),this.initPlugins()}initPlugins(){this.activePluginNames.clear(),this.videoProviders.clear();for(const t of this.options.plugins??[]){if(!t||typeof t.init!="function"){console.error("Shoji: skipping an invalid plugins[] entry (not a ShojiPlugin object):",t);continue}const e=(t.requires??[]).filter(r=>!this.activePluginNames.has(r));if(e.length>0){console.error(`Shoji: plugin "${t.name}" requires [${e.join(", ")}] to be registered first — skipping.`);continue}const n={...t.defaults,...this.options[t.name]},o={gallery:this,options:n,on:this.on.bind(this),emit:(r,a)=>this.bus.emit(r,a),ui:{toolbar:(r,a)=>this.pluginToolbar(r,a),overlay:(r,a)=>this.pluginOverlay(r,a),outer:()=>this.dom.outer,registerShortcut:(r,a)=>(this.shortcuts.set(r,a),()=>this.shortcuts.delete(r)),registerVideoProvider:(r,a)=>(this.videoProviders.set(r,a),()=>{this.videoProviders.get(r)===a&&this.videoProviders.delete(r)})},storage:{get:r=>this.pluginStorage.get(r),set:(r,a)=>{this.pluginStorage.set(r,a)}}},s=t.init(o);typeof s=="function"&&this.pluginCleanups.push(s),this.activePluginNames.add(t.name)}}pluginToolbar(t,e){const n=this.dom,o=e instanceof HTMLElement,s=o?e:this.buildToolbarButton(e),r=o?this.wireControlHover(s):null;return t==="right"?n.toolbarRight.insertBefore(s,n.closeButton):(t==="left"?n.toolbarLeft:n.toolbarCenter).appendChild(s),()=>{r==null||r(),s.remove()}}buildToolbarButton(t){const e=document.createElement("button");return e.type="button",e.className="shoji-toolbar-button",t.icon?(e.ariaLabel=e.title=t.label,e.innerHTML=t.icon):e.textContent=t.label,e.addEventListener("click",t.onClick),this.wireControlHover(e),e}pluginOverlay(t,e){e!==void 0&&(t.style.zIndex=String(e)),this.dom.dialog.appendChild(t);const n=this.wireControlHover(t);return()=>{n(),t.remove()}}wireControlHover(t){let e=!1;const n=()=>{e=!0,this.hoveredControlCount++,this.onActivity()},o=()=>{e=!1,this.hoveredControlCount--,this.scheduleAutoHide()};return t.addEventListener("pointerenter",n),t.addEventListener("pointerleave",o),()=>{t.removeEventListener("pointerenter",n),t.removeEventListener("pointerleave",o),e&&(e=!1,this.hoveredControlCount--,this.scheduleAutoHide())}}isControlActive(){return this.hoveredControlCount>0}getOriginElement(t){const e=this.itemList[t];if(e!=null&&e.id&&typeof CSS<"u"&&typeof CSS.escape=="function"){const n=document.querySelector(`[data-shoji-id="${CSS.escape(e.id)}"]`);if(n)return n}return this.scannedElements[t]??null}scheduleAutoHide(){if(this.autoHideTimer!==null&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),!!this.opened){if(this.autoHideDelay===0){this.hideControls();return}this.autoHideTimer=setTimeout(()=>this.hideControls(),this.autoHideDelay)}}hideControls(){!this.dom||this.autoHidden||this.isControlActive()||(this.autoHidden=!0,this.dom.dialog.classList.add("shoji-controls-hidden"),this.bus.emit("controls:hide",{}))}showControls(){!this.dom||!this.autoHidden||(this.autoHidden=!1,this.dom.dialog.classList.remove("shoji-controls-hidden"),this.bus.emit("controls:show",{}))}renderCaption(t,e){return e instanceof HTMLElement?(t.replaceChildren(e),!1):Ei(e)?(t.innerHTML=e.dangerouslySetInnerHTML,e.dangerouslySetInnerHTML===""):(t.textContent=e??"",!e)}setSlideLoading(t){if(this.dom){this.dom.outer.classList.toggle("shoji-slide-loading",t);for(const e of this.dom.outer.querySelectorAll(".shoji-toolbar-button"))e.ariaDisabled=t?"true":null,t?e.tabIndex=-1:e.removeAttribute("tabindex")}}updateCaptionVisibility(){if(!this.dom||!this.slides)return;const t=this.itemList[this.activeIndex],e=this.renderCaption(this.dom.caption,t==null?void 0:t.caption),n=!!(t!=null&&t.video);this.dom.caption.classList.toggle("shoji-caption--video",n);const o=n&&!this.captionVisibleOnVideo;this.dom.caption.hidden=e||!this.slides.isActiveReady()||o;const s=this.dom.captionToggleButton;s.hidden=!n||e,s.hidden||(s.setAttribute("aria-pressed",String(this.captionVisibleOnVideo)),s.ariaLabel=s.title=this.captionVisibleOnVideo?this.locale.hideCaption:this.locale.showCaption)}renderCurrentSlide(t){if(!this.slides||!this.dom)return;const e=this.dom;this.slides.render(this.itemList,this.activeIndex,r=>{r===this.activeIndex&&(this.bus.emit("slideItemLoad",{index:r}),this.setSlideLoading(!1),this.updateCaptionVisibility())},t),this.setSlideLoading(!this.slides.isActiveReady());const n=this.itemList[this.activeIndex],o=this.itemList.length;e.counter.textContent=o>0?`${this.activeIndex+1} / ${o}`:"",e.counter.hidden=!this.showCounter||o===0,this.updateCaptionVisibility();const s=`Image ${this.activeIndex+1} of ${o}${n!=null&&n.alt?`: ${n.alt}`:""}`;this.liveRegion.announce(s),e.prevButton.hidden=o<=1,e.nextButton.hidden=o<=1,e.prevButton.disabled=!this.loop&&this.activeIndex<=0,e.nextButton.disabled=!this.loop&&this.activeIndex>=o-1}open(t=this.options.index??0){var o;if(this.destroyed||this.opened)return;this.bus.emit("beforeOpen",{index:t}),this.ensureLightbox(),this.opened=!0,this.activeIndex=t,this.captionVisibleOnVideo=!!this.options.showVideoCaption,Ae();const e=this.getOriginElement(t);this.renderCurrentSlide(this.resolveOpenPlaceholderSrc(this.itemList[t],e)),this.dom.outer.classList.add("shoji-open"),document.addEventListener("keydown",this.onKeydown),this.focusTrap.activate(this.dom.dialog),this.scheduleAutoHide(),this.applyMobileControlsSetting();const n=(o=this.slides)==null?void 0:o.getActiveMedia();n&&e&&qe({origin:e,target:n,aspectRatio:this.resolveAspectRatio(t,e)}),this.bus.emit("open",{index:t}),this.bus.emit("afterOpen",{index:t})}resolveOpenPlaceholderSrc(t,e){if(t!=null&&t.thumb)return t.thumb;const n=e==null?void 0:e.getAttribute("data-shoji-thumb");if(n)return n;const o=e==null?void 0:e.querySelector("img");return(o==null?void 0:o.currentSrc)||(o==null?void 0:o.src)||void 0}goTo(t,e){if(this.destroyed||!this.opened||this.itemList.length===0)return;const n=this.clampToRange(t);if(n===this.activeIndex)return;const o=n>this.activeIndex?1:-1;this.navigate(n,o,(e==null?void 0:e.animate)??!0)}next(){this.navigate(this.nextIndex(),1,!0)}prev(){this.navigate(this.prevIndex(),-1,!0)}nextIndex(){return this.activeIndex>=this.itemList.length-1&&this.loop?0:this.activeIndex+1}prevIndex(){return this.activeIndex<=0&&this.loop?this.itemList.length-1:this.activeIndex-1}navigate(t,e,n){var a;if(this.destroyed||!this.opened||this.itemList.length===0)return;const o=this.clampToRange(t);if(o===this.activeIndex)return;const s=this.activeIndex;this.bus.emit("beforeSlide",{from:s,to:o}),pe(((a=this.slides)==null?void 0:a.getActiveMedia())??null),this.activeIndex=o;const r=()=>this.renderCurrentSlide();if(n&&this.transition){const l=this.resolveTransitionMode(),c=pi[l];c?this.transition.animate(c,e,r):this.transition.animateCustom(l,e,r)}else r();this.bus.emit("afterSlide",{from:s,to:o})}resolveTransitionMode(){var t;return this.isMobileQuery()&&((t=this.options.mobileSettings)!=null&&t.mode)?this.options.mobileSettings.mode:this.options.mode??"slide"}isMobileQuery(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}applyMobileControlsSetting(){var t;this.isMobileQuery()&&((t=this.options.mobileSettings)==null?void 0:t.controls)===!1&&this.hideControls()}close(){var n;if(this.destroyed||!this.opened||this.isClosing)return;this.bus.emit("beforeClose",{}),this.isClosing=!0;const t=(n=this.slides)==null?void 0:n.getActiveMedia();pe(t??null);const e=this.getOriginElement(this.activeIndex);if(t&&e){const o=this.resolveAspectRatio(this.activeIndex,e);Ge({origin:e,target:t,aspectRatio:o},()=>this.finishClose())}else this.finishClose()}resolveAspectRatio(t,e){const n=this.itemList[t];if(n!=null&&n.width&&n.height)return n.width/n.height;const o=e==null?void 0:e.querySelector("img");if(o!=null&&o.naturalWidth&&o.naturalHeight)return o.naturalWidth/o.naturalHeight}finishClose(){var t,e;this.opened&&(this.isClosing=!1,this.opened=!1,Pe(),document.removeEventListener("keydown",this.onKeydown),this.focusTrap.deactivate(),(t=this.dom)==null||t.outer.classList.remove("shoji-open"),this.autoHideTimer!==null&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.autoHidden=!1,this.hoveredControlCount=0,(e=this.dom)==null||e.dialog.classList.remove("shoji-controls-hidden"),this.bus.emit("close",{}),this.bus.emit("afterClose",{}))}updateSlides(t,e){if(this.destroyed)return;const n=this.itemList[this.activeIndex],o=n?zt(n):void 0;this.itemList=fe(t);let s=e;if(s===void 0&&o!==void 0){const r=t.findIndex(a=>zt(a)===o);r!==-1&&(s=r)}this.activeIndex=Math.min(Math.max(s??this.activeIndex,0),Math.max(t.length-1,0)),this.opened&&this.renderCurrentSlide(),this.bus.emit("itemsUpdated",{items:this.itemList})}addSlides(t,e){if(this.destroyed)return;const n=[...this.itemList];n.splice(e??n.length,0,...t),this.updateSlides(n)}removeSlides(t){if(this.destroyed)return;const e=Array.isArray(t)?t:[t],n=new Set(e.filter(r=>typeof r=="number")),o=new Set(e.filter(r=>typeof r=="string")),s=this.itemList.filter((r,a)=>!n.has(a)&&!o.has(zt(r)));this.updateSlides(s)}refresh(){if(this.destroyed)return;if(this.isDynamicMode){console.warn("Shoji: refresh() is a no-op in dynamic mode — call updateSlides() instead.");return}const t=ne(this.element,this.selector);this.scannedElements=t.map(e=>e.element),this.updateSlides(t.map(e=>e.item))}teardown(){var t,e,n;this.opened&&(this.isClosing||this.bus.emit("beforeClose",{}),this.finishClose());for(const o of this.pluginCleanups)o();this.pluginCleanups=[],this.shortcuts.clear(),this.pluginStorage.clear(),this.activePluginNames.clear(),this.videoProviders.clear(),this.isDynamicMode||this.element.removeEventListener("click",this.onContainerClick),(t=this.gesture)==null||t.destroy(),this.gesture=null,this.transition=null,(e=this.slides)==null||e.destroy(),(n=this.dom)==null||n.outer.remove(),this.slides=null,this.dom=null}destroy(){this.destroyed||(Ot.get(this.element)===this&&Ot.delete(this.element),Ft.delete(this),this.teardown(),this.bus.emit("destroy",{}),this.bus.clear(),this.destroyed=!0)}reinit(t=this.options){this.destroyed||(this.teardown(),this.bus.clear(),this.applyOptions(t))}}function xi(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const Li={name:"activeThumbnail",defaults:{activeClass:"shoji-thumb-active",scrollIntoView:!0},init(i){const{gallery:t}=i,e=String(i.options.activeClass??"shoji-thumb-active"),n=i.options.scrollIntoView!==!1;let o=null,s=null;function r(){s!==null&&(clearTimeout(s),s=null)}function a(v){const S=t.getOriginElement(v);o&&o!==S&&o.classList.remove(e),r(),S&&(S.classList.add(e),n&&(s=setTimeout(()=>{s=null;try{S.scrollIntoView({block:"nearest",inline:"nearest",behavior:xi()?"auto":"smooth"})}catch{}},80))),o=S}function l(){r(),o==null||o.classList.remove(e),o=null}const c=i.on("afterOpen",({index:v})=>a(v)),d=i.on("afterSlide",({to:v})=>a(v)),m=i.on("close",l);return()=>{c(),d(),m(),l()}}},Se='<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',Mi='<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M7 5h4v14H7zM13 5h4v14h-4z"/></svg>';function Ti(i){const t=i==null?void 0:i.querySelector("video");if(t)return t;const e=i==null?void 0:i.querySelector(".shoji-slide-provider-video");return e&&typeof e.play=="function"?e:null}function ji(i){const t=i==null?void 0:i.querySelector(".shoji-slide-provider-video");return!!t&&typeof t.play!="function"}const Ee=400,Ii=8,Ai={name:"autoplay",defaults:{interval:5e3,showProgress:!0},init(i){const{gallery:t}=i,e=Number(i.options.interval??5e3),n=i.options.showProgress!==!1,o=i.options.autoStart===!0,s=i.options.locale,r=(s==null?void 0:s.play)??"Play slideshow",a=(s==null?void 0:s.pause)??"Pause slideshow";let l=!1,c=null,d=null,m=!1;const v=i.ui.outer();function S(T){if(!l)return;const W=t.getActiveMedia();W&&T.target instanceof Node&&W.contains(T.target)&&A()}v.addEventListener("error",S);const b=document.createElement("button");b.type="button",b.className="shoji-toolbar-button shoji-autoplay-toggle",b.setAttribute("aria-label",r),b.title=r,b.innerHTML=Se;const I=document.createElement("div");I.className="shoji-autoplay-progress",I.hidden=!0;const P=document.createElement("div");P.className="shoji-autoplay-progress-bar",I.appendChild(P);function N(){c!==null&&(clearTimeout(c),c=null)}function C(){n&&(I.hidden=!0,P.style.transition="none",P.style.width="0%")}function Z(T){n&&(I.hidden=!1,P.style.transition="none",P.style.width="0%",P.offsetWidth,P.style.transition=`width ${T}ms linear`,P.style.width="100%")}function Y(T){l=T,b.innerHTML=T?Mi:Se,b.setAttribute("aria-label",T?a:r),b.title=T?a:r}function H(){l&&A()}function R(){d!=null&&d.ended||L()}function X(){d&&(d.removeEventListener("ended",H),d.removeEventListener("pause",R),d=null)}function M(T,W){T.muted=!0;const J=T.play();J&&typeof J.then=="function"?V(T,W,J):O(T,W)}function O(T,W){setTimeout(()=>{d!==T||!l||T.paused&&(W>0?M(T,W-1):A())},Ee)}function V(T,W,J){J.catch(()=>{}),setTimeout(()=>{d!==T||!l||T.paused&&(W>0?V(T,W-1,J):A())},Ee)}function st(){if(N(),X(),C(),m=!1,!l)return;const T=t.getActiveMedia(),W=Ti(T);if(W){if(d=W,W.addEventListener("ended",H),W.addEventListener("pause",R),W instanceof HTMLVideoElement){const J=W.play();J&&typeof J.catch=="function"&&J.catch(yt=>{d!==W||!l||(yt instanceof DOMException&&yt.name==="NotAllowedError"?L():A())})}else M(W,Ii);return}m=ji(T),Z(e),c=setTimeout(A,e)}function A(){const T=t.currentIndex;t.next(),t.currentIndex===T&&L()}function $(){l||(Y(!0),i.emit("autoplayStart",{}),st())}function L(){l&&(Y(!1),N(),C(),d&&!d.paused&&d.pause(),X(),i.emit("autoplayStop",{}))}function lt(){l?L():$()}b.addEventListener("click",lt);const ct=i.ui.toolbar("right",b),et=n?i.ui.overlay(I):null,mt=i.ui.registerShortcut(" ",lt),Lt=i.on("beforeSlide",()=>X()),gt=i.on("afterSlide",()=>{l&&st()}),bt=i.on("slideItemLoad",({index:T})=>{l&&m&&T===t.currentIndex&&st()}),vt=i.on("close",()=>L()),dt=i.on("afterOpen",()=>{o&&$()});return()=>{L(),v.removeEventListener("error",S),ct(),et==null||et(),mt(),Lt(),gt(),bt(),dt(),vt()}}},Ce='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Pi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function ki(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)}function Hi(){return document.fullscreenElement??document.webkitFullscreenElement??null}function Oi(i){var e;const t=i;t.requestFullscreen?t.requestFullscreen().catch(()=>{}):(e=t.webkitRequestFullscreen)==null||e.call(t)}function Xt(){var t;const i=document;document.exitFullscreen?document.exitFullscreen().catch(()=>{}):(t=i.webkitExitFullscreen)==null||t.call(i)}const Ri={name:"fullscreen",init(i){if(!ki())return;const t=i.ui.outer(),e=i.gallery.options.locale??{},n=e.enterFullscreen??"Enter fullscreen",o=e.exitFullscreen??"Exit fullscreen",s=document.createElement("button");s.type="button",s.className="shoji-toolbar-button",s.innerHTML=Ce,s.setAttribute("aria-label",n),s.title=n,s.setAttribute("aria-pressed","false");function r(){return Hi()===t}function a(m){s.innerHTML=m?Pi:Ce,s.setAttribute("aria-label",m?o:n),s.title=m?o:n,s.setAttribute("aria-pressed",String(m))}s.addEventListener("click",()=>{r()?Xt():Oi(t)});const l=()=>{const m=r();a(m),i.emit("fullscreenChange",{fullscreen:m})};document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l);const c=i.ui.toolbar("right",s),d=i.on("close",()=>{r()&&Xt()});return()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),c(),d(),r()&&Xt()}}};function Di(i){const{containerWidth:t,gutterX:e,columns:n}=i;if(typeof n=="number")return Math.max(1,Math.floor(n));const o=Math.max(1,Math.floor((t+e)/(i.columnWidth+e))),s=Math.max(1,Math.floor((t+e)/(i.minColumnWidth+e))),r=Math.max(1,Math.ceil((t+e)/(i.maxColumnWidth+e)));return Math.max(r,Math.min(o,s))}function Ni(i,t,e){return(i-t*(e-1))/e}function xe(i,t,e){const n=Di(t),o=Ni(t.containerWidth,t.gutterX,n),s=e&&e.length===n?[...e]:new Array(n).fill(0),r=i.map((l,c)=>{const d=t.fill==="ordered"?c%n:Vi(s),m=l.width>0?o*(l.height/l.width):o,v=d*(o+t.gutterX),S=s[d];return s[d]=S+m+t.gutterY,{x:v,y:S,width:o,height:m}}),a=i.length===0?0:Math.max(...s)-t.gutterY;return{positions:r,columnCount:n,columnWidth:o,columnHeights:s,containerHeight:a}}function Vi(i){let t=0;for(let e=1;e<i.length;e++)i[e]<i[t]&&(t=e);return t}function $i(i,t){const{containerWidth:e,gutterX:n,gutterY:o,rowHeight:s}=t,r=new Array(i.length);let a=0,l=0,c=0,d=0;function m(b){return b.height>0?s*(b.width/b.height):s}function v(b,I){let P=0;for(let N=b;N<I;N++){const C=m(i[N]);r[N]={x:P,y:a,width:C,height:s},P+=C+n}d++,a+=s+o}for(let b=0;b<i.length;b++){const I=m(i[b]),P=b-l,N=c+(P>0?n:0)+I;P>0&&N>e?(v(l,b),l=b,c=I):c=N}l<i.length&&v(l,i.length);const S=i.length===0?0:a-o;return{positions:r,rowCount:d,containerHeight:S}}function Tt(i){return i.width>0&&i.height>0?i.width/i.height:1}function Rt(i,t){const{containerWidth:e,gutterX:n,gutterY:o,rowHeight:s,minRowHeight:r,maxRowHeight:a,lastRow:l}=t,c=new Array(i.length).fill(null),d=[];let m=0,v=0,S=0;function b(C,Z,Y){return(e-n*(Z-C-1))/Y}function I(C,Z,Y){let H=0;for(let R=C;R<Z;R++){const X=Y*Tt(i[R]);c[R]={x:H,y:m,width:X,height:Y},H+=X+n}d.push({start:C,end:Z,y:m,height:Y}),m+=Y+o}function P(C,Z,Y){let H=Z,R=Y;for(;H-C>1&&b(C,H,R)<r;)H--,R-=Tt(i[H]);const X=b(C,H,R),M=H-C===1&&X<r?X:Math.min(Math.max(X,r),a);return I(C,H,M),H}for(let C=0;C<i.length;C++){S+=Tt(i[C]);const Z=C-v+1;if(s*S+n*(Z-1)>=e){const H=P(v,C+1,S);v=H,S=0;for(let R=H;R<=C;R++)S+=Tt(i[R])}}if(v<i.length)if(l==="justify"){let C=v;for(;C<i.length;){let Z=0;for(let Y=C;Y<i.length;Y++)Z+=Tt(i[Y]);C=P(C,i.length,Z)}}else l==="left"&&I(v,i.length,s);const N=i.length===0?0:Math.max(0,m-o);return{positions:c,containerHeight:N,rows:d}}const Bi={width:4,height:3};function Le(i){if(i&&typeof i=="object"){const e=i;return{x:Number(e.x??8),y:Number(e.y??8)}}const t=Number(i??8);return{x:t,y:t}}function Me(i){return i.id??i.src}function Yi(i,t){if(t.length<=i.length)return!1;for(let e=0;e<i.length;e++)if(Me(i[e])!==Me(t[e]))return!1;return!0}const Wi={name:"layout",defaults:{type:"justified",gutter:8,columns:"auto",columnWidth:240,minColumnWidth:160,maxColumnWidth:480,fill:"shortest",animate:!0,autoMeasure:!0},init(i){const{gallery:t}=i,e=i.options.type??"justified",n=Le(i.options.gutter),o=Number(i.options.aspectRatio??1),s=i.options.orientation??"vertical",r=i.options.columns??"auto",a=Number(i.options.columnWidth??240),l=Number(i.options.minColumnWidth??160),c=Number(i.options.maxColumnWidth??480),d=i.options.fill??"shortest",m=Number(i.options.rowHeight??220),v=Number(i.options.minRowHeight??120),S=Number(i.options.maxRowHeight??360),b=i.options.lastRow??"justify",I=i.options.animate!==!1,P=i.options.autoMeasure!==!1,N=e==="masonry"&&s==="horizontal",C=i.options.groupBy,Z=i.options.renderHeading,Y=i.options.headingOverflow??"show",H=i.options.stickyHeadings===!0,R=H&&e==="grid";H&&e!=="grid"&&console.warn("Shoji: layout plugin — stickyHeadings is only implemented for type: 'grid'; ignored (see the option's doc comment)."),C&&N&&console.warn("Shoji: layout plugin — groupBy isn't supported with orientation: 'horizontal'; ignored.");const X=!!C&&!N,M={gutter:n,columns:r,columnWidth:a,minColumnWidth:l,maxColumnWidth:c,fill:d,rowHeight:m,minRowHeight:v,maxRowHeight:S,lastRow:b},O=i.options.breakpoints,V=O?Object.entries(O).map(([h,p])=>[Number(h),p]).sort((h,p)=>h[0]-p[0]):[];function st(h){const p=V.find(([E])=>h<=E);if(!p)return M;const u=p[1];return{gutter:u.gutter!==void 0?Le(u.gutter):M.gutter,columns:u.columns??M.columns,columnWidth:u.columnWidth??M.columnWidth,minColumnWidth:u.minColumnWidth??M.minColumnWidth,maxColumnWidth:u.maxColumnWidth??M.maxColumnWidth,fill:u.fill??M.fill,rowHeight:u.rowHeight??M.rowHeight,minRowHeight:u.minRowHeight??M.minRowHeight,maxRowHeight:u.maxRowHeight??M.maxRowHeight,lastRow:u.lastRow??M.lastRow}}const A=t.element;A.classList.add("shoji-layout",`shoji-layout--${e}`),I&&A.classList.add("shoji-layout--animate");let $=[],L=[],lt,ct=[],et=!1;const mt=new WeakMap;function Lt(h){const p=[];for(let u=0;u<h.length;u++){const E=C(h[u]),k=p[p.length-1];!k||k.key!==E?p.push({key:E,startIndex:u,endIndex:u+1}):k.endIndex=u+1}return p}function gt(h,p){const u=Z?Z(h,p):h;let E,k=null;if(typeof u=="string")E=document.createElement("h2"),E.textContent=u;else if(u instanceof HTMLElement)E=u;else{E=document.createElement("h2");const _=document.createElement("span");_.className="shoji-layout-heading-title",_.textContent=u.title,E.appendChild(_);let Q=null;u.subtitle&&(Q=document.createElement("span"),Q.className="shoji-layout-heading-subtitle",Q.textContent=u.subtitle,E.appendChild(Q)),k={titleEl:_,subtitleEl:Q}}return E.classList.add("shoji-layout-heading"),R&&E.classList.add("shoji-layout-heading--sticky"),{root:E,structured:k}}function bt(){return L.map((h,p)=>({heading:h,start:h.tileStart,end:p+1<L.length?L[p+1].tileStart:$.length}))}function vt(h){return h.thumb??h.poster??(h.video?void 0:h.src)}function dt(h){if(h!=null&&h.width&&h.height)return{width:h.width,height:h.height};const p=h&&mt.get(h);if(p)return p;const u=P&&!!h&&!!vt(h);return!et&&!u&&(et=!0,console.warn(P?"Shoji: layout plugin — item(s) missing width/height with no measurable thumb/poster/src to auto-measure from either; falling back to a 4:3 placeholder ratio permanently for those.":"Shoji: layout plugin — item(s) missing width/height and autoMeasure is disabled. Masonry/justified positions are computed from aspect ratios up front, never by measuring loaded images (DESIGN.md §5.2 — that causes layout-jump), so items without dimensions fall back to a 4:3 placeholder ratio instead.")),Bi}function T(h,p){const u=document.createElement("a");u.className="shoji-layout-tile",h.id&&(u.dataset.shojiId=h.id),u.dataset.shojiIndex=String(p);const E=document.createElement("img");E.src=h.thumb??h.poster??h.src,E.loading="lazy",E.alt=h.alt??"",u.appendChild(E);const k={index:p,root:u,img:E};return u.addEventListener("click",_=>{_.preventDefault(),t.open(k.index)}),k}function W(h){const p=A.getBoundingClientRect().width,u=st(p);A.style.setProperty("--shoji-layout-column-width",`${u.columnWidth}px`),A.style.setProperty("--shoji-layout-gutter",`${u.gutter.y}px ${u.gutter.x}px`);for(const E of h)E.root.style.setProperty("--shoji-layout-tile-aspect",`${o}`)}function J(h){const p=A.getBoundingClientRect().width;if(p<=0)return;const u=st(p),E={containerWidth:p,gutterX:u.gutter.x,gutterY:u.gutter.y,columns:u.columns,columnWidth:u.columnWidth,minColumnWidth:u.minColumnWidth,maxColumnWidth:u.maxColumnWidth,fill:u.fill};if(X&&L.length>0){const ut=bt(),At=ut.map(ft=>ft.heading.root.getBoundingClientRect().height);let at=0;ut.forEach(({heading:ft,start:pt,end:w},x)=>{const j=$.slice(pt,w);ft.root.style.transform=`translate(0px, ${at}px)`,at+=At[x]+u.gutter.y;const B=xe(j.map(D=>dt(t.items[D.index])),E);j.forEach((D,q)=>{const K=B.positions[q];D.root.style.width=`${K.width}px`,D.root.style.height=`${K.height}px`,D.root.style.visibility="visible",D.root.style.transform=`translate(${K.x}px, ${at+K.y}px)`}),at+=B.containerHeight+u.gutter.y}),lt=void 0,A.style.height=`${Math.max(0,at-u.gutter.y)}px`;return}const k=h??$,_=k.map(ut=>dt(t.items[ut.index])),rt=xe(_,E,h?lt:void 0);k.forEach((ut,At)=>{const at=rt.positions[At];ut.root.style.width=`${at.width}px`,ut.root.style.height=`${at.height}px`,ut.root.style.visibility="visible",ut.root.style.transform=`translate(${at.x}px, ${at.y}px)`}),lt=rt.columnHeights,A.style.height=`${rt.containerHeight}px`}function yt(){const h=A.getBoundingClientRect().width;if(h<=0)return;const p=st(h),u=$.map(k=>dt(t.items[k.index])),E=$i(u,{containerWidth:h,gutterX:p.gutter.x,gutterY:p.gutter.y,rowHeight:p.rowHeight});$.forEach((k,_)=>{const Q=E.positions[_];k.root.style.width=`${Q.width}px`,k.root.style.height=`${Q.height}px`,k.root.style.visibility="visible",k.root.style.transform=`translate(${Q.x}px, ${Q.y}px)`}),A.style.height=`${E.containerHeight}px`}function Ut(h,p,u){const E=new Map,k=new Map;if(Y==="fit")for(const w of L){if(!w.structured)continue;const{subtitleEl:x}=w.structured;w.root.style.maxWidth="none",w.root.style.whiteSpace="nowrap",x&&(x.hidden=!1),E.set(w.tileStart,w.root.getBoundingClientRect().width),x?(x.hidden=!0,k.set(w.tileStart,w.root.getBoundingClientRect().width),x.hidden=!1):k.set(w.tileStart,E.get(w.tileStart))}function _(w,x){return $.slice(w,x).map(j=>dt(t.items[j.index]))}function Q(w,x){const j=L[w].tileStart,B=x<L.length?L[x].tileStart:$.length,D=Rt(_(j,B),h);for(let q=w;q<x;q++){const K=L[q];if(!K.structured)continue;const F=D.positions[K.tileStart-j];if(!F)continue;const G=q+1<x?L[q+1]:void 0,nt=G?D.positions[G.tileStart-j]:null,Gt=(!!nt&&Math.abs(nt.y-F.y)<.5?nt.x:u)-F.x-p.gutter.x;if(Math.min(E.get(K.tileStart)??1/0,k.get(K.tileStart)??1/0)>Gt)return null}return D}function rt(){if(Y!=="fit")return[{startSection:0,endSection:L.length,tileStart:0,tileEnd:$.length,result:Rt(_(0,$.length),h)}];const w=[];let x=0;for(;x<L.length;){const j=Q(x,x+1),B=L[x].tileStart;if(j===null){const F=x+1<L.length?L[x+1].tileStart:$.length;w.push({startSection:x,endSection:x+1,tileStart:B,tileEnd:F,result:Rt(_(B,F),h)}),x+=1;continue}let D=x+1,q=j;for(;D<L.length;){const F=Q(x,D+1);if(F===null)break;D+=1,q=F}const K=D<L.length?L[D].tileStart:$.length;w.push({startSection:x,endSection:D,tileStart:B,tileEnd:K,result:q}),x=D}return w}function ut(w){for(let x=w.startSection;x<w.endSection;x++){const j=L[x];if(!j.structured)continue;const B=w.result.positions[j.tileStart-w.tileStart];if(!B)continue;const D=x+1<w.endSection?L[x+1]:void 0,q=D?w.result.positions[D.tileStart-w.tileStart]:null,F=(!!q&&Math.abs(q.y-B.y)<.5?q.x:u)-B.x-p.gutter.x,{subtitleEl:G}=j.structured;j.root.style.whiteSpace="nowrap",j.root.style.maxWidth="none",j.root.style.overflow="",j.root.style.textOverflow="",G&&(G.hidden=!1),!((E.get(j.tileStart)??0)<=F)&&(G&&(G.hidden=!0,(k.get(j.tileStart)??0)<=F)||(j.root.style.maxWidth=`${Math.max(0,F)}px`,j.root.style.overflow="hidden",j.root.style.textOverflow="ellipsis"))}}function At(w){for(let x=w.startSection;x<w.endSection;x++){const j=L[x];if(!j.structured)continue;const B=w.result.positions[j.tileStart-w.tileStart];if(!B)continue;const D=x+1<w.endSection?L[x+1]:void 0,q=D?w.result.positions[D.tileStart-w.tileStart]:null,F=(!!q&&Math.abs(q.y-B.y)<.5?q.x:u)-B.x-p.gutter.x;j.root.style.whiteSpace="normal",j.root.style.maxWidth=`${Math.max(0,F)}px`;const G=getComputedStyle(j.root),nt=parseFloat(G.lineHeight),qt=Number.isFinite(nt)?nt:parseFloat(G.fontSize)*1.2,Gt=Math.max(1,Math.floor(p.maxRowHeight/qt));j.root.style.display="-webkit-box",j.root.style.overflow="hidden",j.root.style.setProperty("-webkit-box-orient","vertical"),j.root.style.setProperty("-webkit-line-clamp",`${Gt}`)}}const at=rt();let ft=0,pt=0;for(const w of at){Y==="fit"?ut(w):Y==="wrap"&&At(w);const x=new Map;for(let B=w.startSection;B<w.endSection;B++){const D=L[B];x.set(D.tileStart,D.root.getBoundingClientRect().height)}for(const B of w.result.rows){const D=B.start+w.tileStart,q=B.end+w.tileStart;let K=0;for(;pt<w.endSection&&L[pt].tileStart<q;){const F=L[pt],G=w.result.positions[F.tileStart-w.tileStart];G&&(F.root.hidden=!1,F.root.style.transform=`translate(${G.x}px, ${B.y+ft}px)`,K=Math.max(K,x.get(F.tileStart)??0)),pt++}K>0&&(ft+=K+p.gutter.y);for(let F=D;F<q;F++){const G=w.result.positions[F-w.tileStart],nt=$[F];nt.root.hidden=G===null,G&&(nt.root.style.width=`${G.width}px`,nt.root.style.height=`${G.height}px`,nt.root.style.visibility="visible",nt.root.style.transform=`translate(${G.x}px, ${G.y+ft}px)`)}}const j=w.result.rows.length>0?w.result.rows[w.result.rows.length-1].end+w.tileStart:w.tileStart;for(let B=j;B<w.tileEnd;B++)$[B].root.hidden=!0;ft+=w.result.containerHeight+p.gutter.y}for(;pt<L.length;)L[pt].root.hidden=!0,pt++;A.style.height=`${Math.max(0,ft-p.gutter.y)}px`}function Vt(){const h=A.getBoundingClientRect().width;if(h<=0)return;const p=st(h),u={containerWidth:h,gutterX:p.gutter.x,gutterY:p.gutter.y,rowHeight:p.rowHeight,minRowHeight:p.minRowHeight,maxRowHeight:p.maxRowHeight,lastRow:p.lastRow};if(X&&L.length>0){Ut(u,p,h);return}const E=$.map(_=>dt(t.items[_.index])),k=Rt(E,u);$.forEach((_,Q)=>{const rt=k.positions[Q];_.root.hidden=rt===null,rt&&(_.root.style.width=`${rt.width}px`,_.root.style.height=`${rt.height}px`,_.root.style.visibility="visible",_.root.style.transform=`translate(${rt.x}px, ${rt.y}px)`)}),A.style.height=`${k.containerHeight}px`}function jt(){N?yt():e==="masonry"?J(null):e==="justified"?Vt():W($)}let Mt=!1,St=null;function Zt(){St!==null||Mt||(St=requestAnimationFrame(()=>{St=null,!Mt&&(X?y(t.items):jt())}))}function $t(h){if(P)for(const p of h){const u=t.items[p.index];if(!u||u.width&&u.height||mt.has(u)||!vt(u))continue;const E=()=>{Mt||p.img.naturalWidth>0&&p.img.naturalHeight>0&&(mt.set(u,{width:p.img.naturalWidth,height:p.img.naturalHeight}),Zt())};p.img.complete?E():p.img.addEventListener("load",E,{once:!0})}}function f(h){i.emit("layoutRender",{tiles:h.map(p=>({index:p.index,element:p.root}))})}function y(h){if(A.replaceChildren(),$=h.map((p,u)=>T(p,u)),L=[],X)for(const p of Lt(h)){const u=h.slice(p.startIndex,p.endIndex),{root:E,structured:k}=gt(p.key,u);A.appendChild(E),L.push({root:E,tileStart:p.startIndex,structured:k});for(let _=p.startIndex;_<p.endIndex;_++)A.appendChild($[_].root)}else for(const p of $)A.appendChild(p.root);lt=void 0,jt(),$t($),f($)}function z(h,p){const u=h.map((E,k)=>T(E,p+k));for(const E of u)A.appendChild(E.root);$=[...$,...u],N?yt():e==="masonry"?J(u):e==="justified"?Vt():W(u),$t(u),f(u)}y(t.items),ct=t.items;const It=i.on("itemsUpdated",({items:h})=>{X?y(h):Yi(ct,h)?z(h.slice(ct.length),ct.length):y(h),ct=h});let Et=null,ht;return(e==="masonry"||e==="justified"||V.length>0)&&(ht=new ResizeObserver(()=>{Et===null&&(Et=requestAnimationFrame(()=>{Et=null,jt()}))}),ht.observe(A)),()=>{Mt=!0,St!==null&&cancelAnimationFrame(St),ht==null||ht.disconnect(),Et!==null&&cancelAnimationFrame(Et),It(),A.classList.remove("shoji-layout",`shoji-layout--${e}`,"shoji-layout--animate"),A.style.removeProperty("height"),A.style.removeProperty("width"),A.replaceChildren()}}};function _i(i){const t=(i.rotation%360+360)%360;return i.flipH&&i.flipV?{flipH:!1,flipV:!1,rotation:(t+180)%360}:{flipH:i.flipH,flipV:i.flipV,rotation:t}}const zi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 1 1 0 12H9"/></svg>',Fi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14 20 9l-5-5"/><path d="M20 9H10a6 6 0 1 0 0 12h5"/></svg>',Xi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v18"/><path d="M17 7l3 5-3 5"/><path d="M7 7l-3 5 3 5"/></svg>',Ui='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/><path d="M7 17l5 3 5-3"/><path d="M7 7l5-3 5 3"/></svg>',Te={flipH:!1,flipV:!1,rotation:0};function Zi(i,t,e,n){if(!i&&!t&&e===0&&n===1)return"none";const o=(i?-1:1)*n,s=(t?-1:1)*n;return`scaleX(${o}) scaleY(${s}) rotate(${e}deg)`}function qi(i,t,e,n,o){if(!i||!t||!n||!o||e/90%2===0)return 1;const s=Math.min(1,i/n,t/o);return Math.min(1,i/o,t/n)/s}const Gi={name:"rotateFlip",init(i){const{gallery:t}=i,e=t.options.locale??{},n=e.rotateLeft??"Rotate left",o=e.rotateRight??"Rotate right",s=e.flipHorizontal??"Flip horizontal",r=e.flipVertical??"Flip vertical";let a={...Te},l=0,c=!1,d=!1;function m(M){const O=t.items[t.currentIndex];if(O!=null&&O.width&&O.height)return{width:O.width,height:O.height};const V=M.querySelector("img");if(V!=null&&V.naturalWidth&&V.naturalHeight)return{width:V.naturalWidth,height:V.naturalHeight}}function v(M){const O=t.getActiveMedia();if(!O)return;const V=m(O),st=qi(O.clientWidth,O.clientHeight,l,V==null?void 0:V.width,V==null?void 0:V.height),A=Zi(c,d,l,st);if(!M){O.style.transform=A;return}O.style.transition="transform var(--shoji-duration) var(--shoji-easing)",O.style.transform=A,Ct(O,()=>{O.style.transition=""})}function S(M,O){const V=document.createElement("button");return V.type="button",V.className="shoji-toolbar-button",V.innerHTML=M,V.setAttribute("aria-label",O),V.title=O,V}const b=S(zi,n),I=S(Fi,o),P=S(Xi,s),N=S(Ui,r);P.setAttribute("aria-pressed","false"),N.setAttribute("aria-pressed","false");function C(M,O){a=_i({...a,...M}),O!==void 0&&(l+=O),v(!0),P.setAttribute("aria-pressed",String(a.flipH)),N.setAttribute("aria-pressed",String(a.flipV)),i.emit("rotateFlipChange",{index:t.currentIndex,...a})}function Z(M){return M!==(c!==d)?90:-90}b.addEventListener("click",()=>{const M=Z(!1);C({rotation:a.rotation+M},M)}),I.addEventListener("click",()=>{const M=Z(!0);C({rotation:a.rotation+M},M)}),P.addEventListener("click",()=>{c=!c,C({flipH:!a.flipH})}),N.addEventListener("click",()=>{d=!d,C({flipV:!a.flipV})});function Y(){a={...Te},l=0,c=!1,d=!1,v(!1),P.setAttribute("aria-pressed","false"),N.setAttribute("aria-pressed","false")}const H=[b,I,P,N].map(M=>i.ui.toolbar("right",M)),R=i.on("afterOpen",Y),X=i.on("afterSlide",Y);return()=>{for(const M of H)M();R(),X()}}};let Dt=null;const Ki=250;function Ji(){var i;return(i=window.Vimeo)!=null&&i.Player?Promise.resolve(window.Vimeo):Dt||(Dt=new Promise(t=>{const e=document.createElement("script");e.src="https://player.vimeo.com/api/player.js",e.onload=()=>t(window.Vimeo),document.head.appendChild(e)}),Dt)}function Qi(i,t){const e=i;e.paused=!0,e.ended=!1,e.play=()=>t.play(),e.pause=()=>t.pause();let n=!1;return Object.defineProperty(e,"muted",{configurable:!0,get:()=>n,set:o=>{n=o,t.setMuted(o)}}),e}const tn=(i,t,e,n)=>{var a;if(((a=t.video)==null?void 0:a.provider)!=="vimeo")return;const{id:o,url:s}=t.video;if(!o&&!s){const l=document.createElement("div");l.className="shoji-slide-placeholder",l.textContent="Video",i.appendChild(l),e();return}const r=document.createElement("div");r.className="shoji-video-mount",i.appendChild(r),Ji().then(l=>{if(n.aborted)return;const c=i,d=new l.Player(r,{...s?{url:s}:{id:Number(o)},playsinline:!0});let m=null;function v(){m!==null&&(clearTimeout(m),m=null)}d.on("play",()=>{v(),c.paused=!1,c.dispatchEvent(new Event("play"))}),d.on("pause",()=>{c.paused=!0,v(),m=setTimeout(()=>{m=null,c.dispatchEvent(new Event("pause"))},Ki)}),d.on("ended",()=>{v(),c.paused=!0,c.ended=!0,c.dispatchEvent(new Event("ended"))}),d.on("error",S=>c.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{name:S.name}}))),d.ready().then(()=>{Qi(i,d),e()}),n.addEventListener("abort",()=>{v(),d.destroy()},{once:!0})})};let Nt=null;function en(){var i;return(i=window.YT)!=null&&i.Player?Promise.resolve(window.YT):Nt||(Nt=new Promise(t=>{const e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{e==null||e(),t(window.YT)};const n=document.createElement("script");n.src="https://www.youtube.com/iframe_api",document.head.appendChild(n)}),Nt)}function nn(i,t){const e=i;return e.paused=!0,e.ended=!1,e.play=()=>t.playVideo(),e.pause=()=>t.pauseVideo(),Object.defineProperty(e,"muted",{configurable:!0,get:()=>t.isMuted(),set:n=>n?t.mute():t.unMute()}),e}function on(i,t,e){i.data===t.PlayerState.PLAYING?(e.paused=!1,e.dispatchEvent(new Event("play"))):i.data===t.PlayerState.PAUSED?(e.paused=!0,e.dispatchEvent(new Event("pause"))):i.data===t.PlayerState.ENDED&&(e.paused=!0,e.ended=!0,e.dispatchEvent(new Event("ended")))}const sn=(i,t,e,n)=>{var r;if(((r=t.video)==null?void 0:r.provider)!=="youtube")return;const o=t.video.id;if(!o){const a=document.createElement("div");a.className="shoji-slide-placeholder",a.textContent="Video",i.appendChild(a),e();return}const s=document.createElement("div");i.appendChild(s),en().then(a=>{if(n.aborted)return;const l=i,c=new a.Player(s,{videoId:o,playerVars:{playsinline:1,rel:0},events:{onReady:()=>{nn(i,c),e()},onStateChange:d=>on(d,a,l),onError:d=>l.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{code:d.data}}))}});n.addEventListener("abort",()=>c.destroy(),{once:!0})})},rn={name:"video",init(i){const t=i.ui.registerVideoProvider("youtube",sn),e=i.ui.registerVideoProvider("vimeo",tn);return()=>{t(),e()}}},an='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7"/><path d="M21 21l-5.5-5.5M10 7v6M7 10h6"/></svg>',ln='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7"/><path d="M21 21l-5.5-5.5M7 10h6"/></svg>',cn='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="1"/><path d="M9 15l6-6M9 9h0M15 15h0"/></svg>';function dn(i,t,e){return Math.min(e,Math.max(t,i))}function je(i,t,e,n,o,s){const r=t*e;if(r<=o)return n+(o-r)/2-i;const a=n+o-r,l=n,c=i+s;return Math.min(l,Math.max(a,c))-i}function Ie(i,t,e,n){return{tx:je(i.left,i.width,e,t.left,t.width,n.tx),ty:je(i.top,i.height,e,t.top,t.height,n.ty)}}function un(i,t,e,n,o,s){const r=i.left+t.tx,a=i.top+t.ty,l=o-r,c=s-a,d=1-n/e;return{tx:t.tx+l*d,ty:t.ty+c*d}}const xt=1.001;function hn(i){return i.composedPath().some(t=>t instanceof Element&&t.matches("button, video, input, select, textarea, a[href], [data-shoji-no-drag]"))}return Object.assign(Ci,{Autoplay:Ai,Layout:Wi,ActiveThumbnail:Li,Fullscreen:Ri,RotateFlip:Gi,Video:rn,Zoom:{name:"zoom",defaults:{maxScale:4,doubleTapScale:2,buttonStep:1.5},init(i){const{gallery:t}=i,e=Number(i.options.maxScale??4),n=Number(i.options.doubleTapScale??2),o=Number(i.options.buttonStep??1.5),s=t.options.locale??{},r=s.zoomIn??"Zoom in",a=s.zoomOut??"Zoom out",l=s.zoomActualSize??"Actual size";let c=1,d={tx:0,ty:0},m=null,v=null,S=1;function b(){const f=t.getActiveMedia(),y=f==null?void 0:f.firstElementChild;return y instanceof HTMLImageElement?y:null}function I(f){const y=f.getBoundingClientRect();return{left:y.left,top:y.top,width:y.width,height:y.height}}function P(f){return m&&v?!0:c!==1?!1:(m=I(f),v=I(f.parentElement??f),!0)}function N(f){const y=t.getActiveMedia();if(!y||y.style.transition===""){f();return}Ct(y,f)}function C(){const f=b();f&&(f.style.transformOrigin="0 0",f.style.transform=c===1&&d.tx===0&&d.ty===0?"none":`translate3d(${d.tx}px, ${d.ty}px, 0) scale3d(${c}, ${c}, 1)`,f.classList.toggle("shoji-zoomed",c>1))}function Z(){i.emit("zoomChange",{index:t.currentIndex,scale:c})}function Y(f,y,z){f.style.transition="transform var(--shoji-duration) var(--shoji-easing)",y(),Ct(f,()=>{f.style.transition="",z==null||z()})}function H(f,y,z,It=e,Et=!1){N(()=>{const ht=b();if(!ht||!P(ht))return;const h=dn(f,1,Math.max(It,1));d=un(m,d,c,h,y,z),c=h,d=Ie(m,v,c,d),Et?Y(ht,C):C(),Z()})}function R(f=!1){c=1,d={tx:0,ty:0},m=null,v=null;const y=b();if(!y)return;const z=()=>{y.style.transform="",y.classList.remove("shoji-zoomed")};f?Y(y,z,()=>{y.style.transformOrigin=""}):(z(),y.style.transformOrigin="")}function X(){var f;(f=b())==null||f.classList.add("shoji-zoom-enabled")}function M(f,y){c>xt?R(!0):H(n,f,y,e,!0)}const O=i.on("pinchStart",()=>{S=c}),V=i.on("pinchMove",({scale:f,centerX:y,centerY:z})=>{H(S*f,y,z)}),st=i.on("pinchEnd",()=>{c<=xt&&R()}),A=i.on("doubleTap",({x:f,y})=>M(f,y)),$=i.on("wheelZoom",({deltaScale:f,x:y,y:z})=>{H(c+f,y,z)});let L=null,lt=0,ct=0;const et=i.ui.outer();function mt(f){c<=xt||hn(f)||(L=f.pointerId,lt=f.clientX,ct=f.clientY)}function Lt(f){if(L!==f.pointerId||!m||!v)return;f.preventDefault();const y=f.clientX-lt,z=f.clientY-ct;lt=f.clientX,ct=f.clientY,d=Ie(m,v,c,{tx:d.tx+y,ty:d.ty+z}),C()}function gt(f){L===f.pointerId&&(L=null)}et.addEventListener("pointerdown",mt),et.addEventListener("pointermove",Lt,{passive:!1}),et.addEventListener("pointerup",gt),et.addEventListener("pointercancel",gt);function bt(f,y){const z=document.createElement("button");return z.type="button",z.className="shoji-toolbar-button",z.innerHTML=f,z.setAttribute("aria-label",y),z.title=y,z}function vt(){const f=t.getActiveMedia(),y=f==null?void 0:f.getBoundingClientRect();return y?{x:y.left+y.width/2,y:y.top+y.height/2}:{x:0,y:0}}function dt(){const{x:f,y}=vt();H(c*o,f,y,e,!0)}function T(){const{x:f,y}=vt();c/o<=xt?R(!0):H(c/o,f,y,e,!0)}const W=bt(an,r),J=bt(ln,a),yt=bt(cn,l);W.addEventListener("click",dt),J.addEventListener("click",T),yt.addEventListener("click",()=>{N(()=>{const f=b();if(!f||!f.naturalWidth||!P(f))return;if(c>xt){R(!0);return}const y=f.naturalWidth/m.width,{x:z,y:It}=vt();H(y,z,It,y,!0)})});const Ut=[W,J,yt].map(f=>i.ui.toolbar("right",f)),Vt=[i.ui.registerShortcut("w",dt),i.ui.registerShortcut("W",dt),i.ui.registerShortcut("s",T),i.ui.registerShortcut("S",T)],jt=i.on("afterOpen",()=>{R(),X()}),Mt=i.on("beforeSlide",()=>R()),St=i.on("afterSlide",()=>{R(),X()}),Zt=i.on("beforeClose",()=>R()),$t=t.registerZoomGate(()=>c>xt);return X(),()=>{var f;for(const y of Ut)y();for(const y of Vt)y();jt(),Mt(),St(),Zt(),O(),V(),st(),A(),$(),et.removeEventListener("pointerdown",mt),et.removeEventListener("pointermove",Lt),et.removeEventListener("pointerup",gt),et.removeEventListener("pointercancel",gt),$t(),R(),(f=b())==null||f.classList.remove("shoji-zoom-enabled")}}},version:"0.1.0-alpha.10"})}));
|
|
2
|
+
//# sourceMappingURL=shoji.min.js.map
|