@cntrl-site/components 1.0.107-alpha.6 → 1.0.108-alpha.0

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.
@@ -1,321 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),ne=require("./scalingValue-CSHYgTZl.js"),on=require("./useScopedStyles-Bf6yohVQ.js"),sn=require("./useLazyVideos-CdCbc2j0.js"),lt=require("./EmbedMediaFrame-DsOTKE4i.js"),an=require("./LazyVideo-imbU18js.js"),r=require("react"),ln=require("react-dom"),cn=require("./HiveLightboxTitles-DlyptAaK.js"),un=require("./getImageRect-BQhQXvT8.js");function fn(t){return`calc(var(--cntrl-article-width, 100vw) * ${t/1440})`}function dn(t){return`
2
- .${t}-wrapper {
3
- display: grid;
4
- align-items: start;
5
- justify-content: center;
6
- min-height: ${fn(48)};
7
- }
8
- .${t}-item {
9
- display: flex;
10
- flex-direction: column;
11
- justify-content: center;
12
- align-items: center;
13
- }
14
- .${t}-item-inner {
15
- display: flex;
16
- flex-direction: column;
17
- align-items: center;
18
- outline: 1px solid #FF5C02;
19
- }
20
- .${t}-item-inner-hidden {
21
- display: flex;
22
- flex-direction: column;
23
- align-items: center;
24
- }
25
- .${t}-item-image-wrapper {
26
- display: flex;
27
- justify-content: center;
28
- align-items: center;
29
- align-self: center;
30
- }
31
- .${t}-item-image-link {
32
- width: 100%;
33
- display: flex;
34
- flex-direction: column;
35
- align-items: center;
36
- }
37
- .${t}-item-image {
38
- width: 100%;
39
- height: 100%;
40
- display: block;
41
- max-width: 100%;
42
- }
43
- .${t}-item-video {
44
- width: 100%;
45
- height: 100%;
46
- display: block;
47
- max-width: 100%;
48
- }
49
- .${t}-image-align-top .${t}-item-image-wrapper {
50
- align-items: flex-start;
51
- }
52
- .${t}-image-align-center .${t}-item-image-wrapper {
53
- align-items: center;
54
- }
55
- .${t}-image-align-bottom .${t}-item-image-wrapper {
56
- align-items: flex-end;
57
- }
58
- .${t}-align-entries .${t}-item {
59
- display: contents;
60
- }
61
- .${t}-align-entries .${t}-item-inner,
62
- .${t}-align-entries .${t}-item-inner-hidden {
63
- display: grid;
64
- grid-template-rows: subgrid;
65
- grid-row: span 3;
66
- justify-self: center;
67
- margin-bottom: var(--${t}-align-entries-row-gap, 0);
68
- }
69
- .${t}-align-entries .${t}-item-inner-last-row {
70
- margin-bottom: 0;
71
- }
72
- .${t}-align-entries .${t}-item-title-row,
73
- .${t}-align-entries .${t}-item-subtitle-row {
74
- display: flex;
75
- flex-direction: column;
76
- align-items: center;
77
- width: 100%;
78
- min-height: 100%;
79
- }
80
- .${t}-align-entries .${t}-item-image-link {
81
- width: 100%;
82
- height: 100%;
83
- min-height: 100%;
84
- display: flex;
85
- flex-direction: column;
86
- align-items: center;
87
- justify-content: flex-start;
88
- }
89
- .${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
90
- flex-shrink: 0;
91
- height: auto;
92
- align-self: auto;
93
- }
94
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
95
- margin-top: 0;
96
- margin-bottom: auto;
97
- }
98
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
99
- margin-top: auto;
100
- margin-bottom: auto;
101
- }
102
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-link > .${t}-item-image-wrapper {
103
- margin-top: auto;
104
- margin-bottom: 0;
105
- }
106
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-wrapper {
107
- align-items: flex-start;
108
- }
109
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-wrapper {
110
- align-items: center;
111
- }
112
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-wrapper {
113
- align-items: flex-end;
114
- }
115
- .${t}-image-align-top.${t}-align-entries .${t}-item-image-link {
116
- justify-content: flex-start;
117
- }
118
- .${t}-image-align-center.${t}-align-entries .${t}-item-image-link {
119
- justify-content: center;
120
- }
121
- .${t}-image-align-bottom.${t}-align-entries .${t}-item-image-link {
122
- justify-content: flex-end;
123
- }
124
- .${t}-titles-row {
125
- position: relative;
126
- flex: 0 1 auto;
127
- z-index: 2;
128
- box-sizing: border-box;
129
- pointer-events: none;
130
- word-break: break-word;
131
- min-width: 0;
132
- display: flex;
133
- flex-direction: row;
134
- align-items: baseline;
135
- }
136
- .${t}-titles-row-header {
137
- flex: 1;
138
- align-items: baseline;
139
- }
140
- .${t}-titles-row-header-controls {
141
- display: flex;
142
- flex-direction: row;
143
- align-items: baseline;
144
- flex-shrink: 0;
145
- }
146
- .${t}-close-icon {
147
- position: relative;
148
- flex-shrink: 0;
149
- align-self: center;
150
- pointer-events: auto;
151
- z-index: 2;
152
- display: flex;
153
- align-items: center;
154
- justify-content: center;
155
- border: none;
156
- background-color: transparent;
157
- padding: 0;
158
- }
159
- .${t}-close-icon-inner {
160
- all: unset;
161
- position: relative;
162
- cursor: pointer;
163
- width: 100%;
164
- height: 100%;
165
- pointer-events: auto;
166
- }
167
- .${t}-close-icon-img {
168
- position: absolute;
169
- top: 50%;
170
- left: 50%;
171
- transform: translate(-50%, -50%);
172
- }
173
- .${t}-titles-baseline-strut {
174
- width: 0;
175
- overflow: hidden;
176
- flex-shrink: 0;
177
- pointer-events: none;
178
- white-space: nowrap;
179
- }
180
- .${t}-titles-row-titles {
181
- position: relative;
182
- flex: 1;
183
- min-width: 0;
184
- align-self: flex-start;
185
- }
186
- .${t}-titles-stack {
187
- position: relative;
188
- display: flex;
189
- flex-direction: row;
190
- align-items: baseline;
191
- align-self: flex-start;
192
- min-width: 0;
193
- }
194
- .${t}-titles-row-two-row {
195
- display: flex;
196
- flex: 1;
197
- height: 100%;
198
- min-height: 0;
199
- align-self: stretch;
200
- flex-direction: column;
201
- width: 100%;
202
- }
203
- .${t}-titles-row-top {
204
- display: flex;
205
- flex-direction: row;
206
- align-items: baseline;
207
- width: 100%;
208
- flex-shrink: 0;
209
- margin-bottom: 0;
210
- }
211
- .${t}-titles-row-top .${t}-title-cell[data-title="title1"] {
212
- flex: 0 0 auto;
213
- min-width: 0;
214
- }
215
- .${t}-titles-row-bottom-wrap {
216
- display: flex;
217
- flex-direction: column;
218
- width: 100%;
219
- margin-top: auto;
220
- flex-shrink: 0;
221
- }
222
- .${t}-titles-row-bottom-area {
223
- position: relative;
224
- flex: 1;
225
- min-height: 0;
226
- display: flex;
227
- flex-direction: column;
228
- width: 100%;
229
- }
230
- .${t}-titles-row-bottom {
231
- position: relative;
232
- display: flex;
233
- flex-direction: row;
234
- align-items: flex-end;
235
- width: 100%;
236
- }
237
- .${t}-titles-row-bottom .${t}-title-cell {
238
- flex: 0 0 auto;
239
- }
240
- .${t}-title-cell {
241
- position: relative;
242
- flex: 0 0 auto;
243
- min-width: 0;
244
- box-sizing: border-box;
245
- }
246
- .${t}-text-bar-cell {
247
- position: relative;
248
- flex: 0 1 auto;
249
- min-width: 0;
250
- display: flex;
251
- align-items: baseline;
252
- }
253
- .${t}-title1,
254
- .${t}-title2,
255
- .${t}-title3 {
256
- margin: 0;
257
- min-width: 0;
258
- }
259
- .${t}-title-resize-handle {
260
- background: transparent;
261
- }
262
- .${t}-lightbox {
263
- position: fixed;
264
- inset: 0;
265
- z-index: 9997;
266
- overscroll-behavior: none;
267
- overflow: hidden;
268
- }
269
- .${t}-lightbox-editor {
270
- inset: auto;
271
- top: var(--cntrl-article-top, 0);
272
- left: var(--cntrl-article-left, 0);
273
- width: var(--cntrl-article-width, 100vw) !important;
274
- height: var(--cntrl-viewport-height, 100vh) !important;
275
- }
276
- .${t}-lightbox-edit-mode {
277
- z-index: 1;
278
- }
279
- .${t}-lightbox-dismiss-area {
280
- position: relative;
281
- width: 100%;
282
- height: 100%;
283
- }
284
- .${t}-lightbox-overlay-content {
285
- position: absolute;
286
- inset: 0;
287
- z-index: 3;
288
- pointer-events: none;
289
- display: flex;
290
- flex-direction: column;
291
- isolation: isolate;
292
- }
293
- .${t}-lightbox-content-area {
294
- position: relative;
295
- display: flex;
296
- flex-direction: row;
297
- align-items: flex-start;
298
- flex: 1;
299
- min-width: 0;
300
- min-height: 0;
301
- }
302
- .${t}-lightbox-content-area-stacked {
303
- align-items: stretch;
304
- align-self: stretch;
305
- }
306
- .${t}-text-bar-cell-stacked {
307
- align-self: stretch;
308
- flex: 1;
309
- min-width: 0;
310
- min-height: 0;
311
- height: 100%;
312
- flex-direction: column;
313
- align-items: stretch;
314
- }
315
- .${t}-control {
316
- position: relative;
317
- z-index: 2;
318
- pointer-events: auto;
319
- flex-shrink: 0;
320
- }
321
- `}const ze={assetId:"",name:"",objectFit:"cover"},tt=500,Gt=650,D="cubic-bezier(0.22, 1, 0.36, 1)",hn=72,gn=50,pn=1e4,mn=650,wn=500;function vn(t,e){const i=t.width/e.width,o=t.height/e.height,s=t.left-e.left,c=t.top-e.top;return`translate(${s}px, ${c}px) scale(${i}, ${o})`}function Ve(t,e){if(e==="contain"&&t instanceof HTMLImageElement){const o=un.getDisplayedImageRect(t);return{left:o.x,top:o.y,width:o.width,height:o.height}}const i=t.getBoundingClientRect();return{left:i.left,top:i.top,width:i.width,height:i.height}}function xn(t,e,i){const o=t.querySelector(`[data-hive-grid-index="${e}"]`);return o instanceof HTMLElement?Ve(o,i):null}function yn(t){return t.reduce((e,i,o)=>{const s=ve(i.gallery),p=xe(s).filter(u=>u.lightboxMedia).map(u=>u.lightboxMedia);return p.length===0||e.push({gridIndex:o,items:p,entry:{title1:i.title1??"",title2:i.title2??"",title3:i.title3??""}}),e},[])}function Xt(t,e,i){var s;if(t.length<=1)return null;const o=(e+i+t.length)%t.length;return((s=t[o])==null?void 0:s.items[0])??null}function De(t,e,i){if(t.length<=2)return null;const o=(e+i+t.length)%t.length;return Xt(t,o,i)}const $n=.03;function Be(t){return t.width*$n}const me={left:0,top:0,width:typeof window<"u"?window.innerWidth:1440,height:typeof window<"u"?window.innerHeight:900};function ie(t,e){return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}function _e(t){const e=t.getBoundingClientRect();return{width:e.width,height:e.height,left:e.left,top:e.top}}function bn(t){return t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:{width:t.naturalWidth,height:t.naturalHeight}}function we(t,e,i){const o=t.getBoundingClientRect(),s=o.width,c=o.height,p=e/i,u=s/c;if(p>u){const b=s/p;return{width:s,height:b,left:o.left,top:o.top+(c-b)/2}}const H=c*p;return{width:H,height:c,left:o.left+(s-H)/2,top:o.top}}function In(t,e){return!t||!(e!=null&&e.width)||!(e!=null&&e.height)?null:we(t,e.width,e.height)}function Sn(t,e){if(lt.isEmbedMedia(t)){e(t.assetId,lt.getEmbedAspect(t),1);return}if(Nt(t)){const o=document.createElement("video"),s=()=>{o.videoWidth>0&&o.videoHeight>0&&e(t.assetId,o.videoWidth,o.videoHeight),o.removeEventListener("loadedmetadata",s)};o.addEventListener("loadedmetadata",s),o.preload="auto",o.src=t.assetId,o.load();return}const i=new Image;i.onload=()=>{i.naturalWidth>0&&i.naturalHeight>0&&e(t.assetId,i.naturalWidth,i.naturalHeight)},i.src=t.assetId}function kn(t){const e=new Set,i=[];for(const o of t){const s=ve(o.gallery),c=xe(s);for(const p of c)for(const u of[p.displayMedia,p.lightboxMedia])u!=null&&u.assetId&&!e.has(u.assetId)&&(e.add(u.assetId),i.push(u))}return i}function Ln({mediaList:t}){const[e,i]=r.useState(null);sn.useLazyVideos(e,{preload:"metadata"});const o=t.filter(s=>!lt.isEmbedMedia(s));return o.length===0?null:l.jsx("div",{ref:i,"aria-hidden":!0,style:{position:"absolute",width:0,height:0,overflow:"hidden",opacity:0,pointerEvents:"none"},children:o.map(s=>Nt(s)?l.jsx("video",{src:s.assetId,preload:"none",muted:!0,playsInline:!0},s.assetId):l.jsx("img",{src:s.assetId,alt:""},s.assetId))})}function Ft(t,e,i){const{width:o,height:s,top:c}=t,{left:p,width:u}=i,H=Be(i);return e==="left"?{left:p+H-o,top:c,width:o,height:s}:{left:p+u-H,top:c,width:o,height:s}}function oe(t,e,i){const o=Ft(t,e,i);return{...o,left:2*o.left-t.left}}function jn(t,e,i){const{left:o,width:s}=i,c=Be(i);return e==="left"?{left:o,top:t.top,width:c,height:t.height}:{left:o+s-c,top:t.top,width:c,height:t.height}}function qe(t,e,i,o){const s=Ft(t,"left",o),c=Ft(t,"right",o),p=oe(t,"left",o),u=oe(t,"right",o);if(i===1)switch(e){case"center":return{start:t,end:s};case"right-adjacent":return{start:c,end:t};case"left-adjacent":return{start:s,end:p};case"far-right":return{start:u,end:c};default:return{start:t,end:t}}switch(e){case"center":return{start:t,end:c};case"left-adjacent":return{start:s,end:t};case"right-adjacent":return{start:c,end:u};case"far-left":return{start:p,end:s};default:return{start:t,end:t}}}function Rn(t,e,i,o){const{start:s,end:c}=qe(t,e,i,o);return{x:c.left-s.left,y:c.top-s.top}}function Cn(t,e,i){const o=Ft(t,e,i),s=oe(t,e,i);return{x:s.left-o.left,y:s.top-o.top}}function Ge(t){if(!Array.isArray(t)||t.length===0)return!1;const e=t[0];return e!==null&&typeof e=="object"&&"media"in e&&Array.isArray(e.media)}function ve(t){if(!t)return;if(Ge(t))return t;if(!Array.isArray(t))return;const[e,i]=t,o=e!=null&&e.assetId?e:void 0,s=i!=null&&i.assetId?i:void 0;if(!(!o&&!s))return[{media:[s??o??ze,o??s??ze]}]}function En(t){const[e,i]=t.media;return i!=null&&i.assetId?i:e!=null&&e.assetId?e:null}function An(t){const[e]=t.media;return e!=null&&e.assetId?e:null}function xe(t){if(!Array.isArray(t)||t.length===0)return[];if(Ge(t)){const e=[];for(const i of t){const o=En(i);if(!o)continue;const s=An(i);e.push({displayMedia:o,lightboxMedia:s!=null&&s.assetId?s:null})}return e}return t.filter(e=>e==null?void 0:e.assetId).map(e=>({displayMedia:e,lightboxMedia:e}))}function Nt(t){return lt.isEmbedMedia(t)?!1:t.type==="video"?!0:/\.(mp4|webm|ogg|mov)(\?|#|$)/i.test(t.assetId)}function Tn({media:t,className:e,style:i,gridIndex:o,onMediaClick:s}){return lt.isEmbedMedia(t)?l.jsx(lt.EmbedMediaFrame,{media:t,fit:i.objectFit==="contain"?"contain":"cover",silentLoop:!0,className:e,"data-hive-grid-index":o,style:{...i,cursor:s?"pointer":"default"},onClick:s}):Nt(t)?l.jsx(an.LazyVideo,{src:t.assetId,className:e,"data-hive-grid-index":o,style:{...i,cursor:s?"pointer":"default"},muted:!0,autoPlay:!0,loop:!0,playsInline:!0,onClick:s}):l.jsx("img",{src:t.assetId,alt:t.name,className:e,"data-hive-grid-index":o,style:{...i,cursor:s?"pointer":"default"},onClick:s})}function Hn({src:t,onMediaElement:e,wrapperStyle:i,videoStyle:o,onLoadedMetadata:s,onTransitionEnd:c}){const p=r.useRef(null);return r.useEffect(()=>{const u=p.current;return e==null||e(u??null),()=>{u==null||u.pause(),e==null||e(null)}},[t,e]),l.jsx("div",{style:i,onTransitionEnd:c,children:l.jsx("video",{ref:p,src:t,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,preload:"auto",onLoadedMetadata:s,style:o},t)})}function re({media:t,style:e,onTransitionEnd:i,onMeasure:o}){return lt.isEmbedMedia(t)?l.jsx("img",{src:t.thumbnail,alt:t.name,style:e,onTransitionEnd:i}):Nt(t)?l.jsx("video",{src:t.assetId,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,preload:"auto",style:e,onLoadedMetadata:s=>{const c=s.currentTarget;c.videoWidth>0&&c.videoHeight>0&&(o==null||o(t.assetId,c.videoWidth,c.videoHeight))},onTransitionEnd:i}):l.jsx("img",{src:t.assetId,alt:t.name,style:e,onLoad:s=>{const c=s.currentTarget;c.naturalWidth>0&&c.naturalHeight>0&&(o==null||o(t.assetId,c.naturalWidth,c.naturalHeight))},onTransitionEnd:i})}function Fn({prefix:t,items:e,index:i,entry:o,settings:s,isEditor:c,isEditMode:p,isPreviewMode:u,canNavigate:H,lightboxEntries:b,entryIdx:et,layoutId:_,sourceRect:F,resolveCloseSourceRect:kt,onClose:Wt,onPrev:Mt,onNext:Ot}){const Yt=r.useRef(null),Lt=r.useRef(null),jt=r.useRef(null),Rt=r.useRef(new Map),[B,Ct]=r.useState(0),nt=r.useRef(null),xt=r.useRef(0),N=r.useRef(0),T=r.useRef("none"),q=r.useRef(!1),G=r.useRef(!1),it=r.useRef(!1),rt=r.useRef(null),I=r.useRef(null),Et=r.useRef(null),ct=r.useRef(()=>{}),X=r.useRef(null),W=r.useRef(null),ut=r.useRef(null),ot=r.useRef(!1),[k,yt]=r.useState(null),[L,Ut]=r.useState(me),[se,ae]=r.useState(0),[g,ft]=r.useState("opening"),[Y,$t]=r.useState(0),[zt,S]=r.useState(0),[V,le]=r.useState(!1),[U,dt]=r.useState(null),[bt,ht]=r.useState(null),[x,w]=r.useState(null),[gt,j]=r.useState(!1),[pt,Dt]=r.useState(null),[_t,Z]=r.useState(!1),It=r.useRef(!1),[M,A]=r.useState(!1),[Xe,ye]=r.useState(!1),$e=r.useRef(i),be=r.useRef(void 0),d=e[i],Ie=d?Nt(d):!1,Se=d?lt.isEmbedMedia(d):!1,mt=zt!==0||V,ce=!p&&(!c||!!u),st=H&&!p,wt=b.length>1,At=r.useCallback((n,a)=>e.length<=1?null:e[(n+a+e.length)%e.length]??null,[e]),R=wt?Xt(b,et,-1):At(i,-1),C=wt?Xt(b,et,1):At(i,1),ue=U===-1&&mt?wt&&bt!==null?Xt(b,bt,-1):x!==null?At(x,-1):null:null,fe=U===1&&mt?wt&&bt!==null?Xt(b,bt,1):x!==null?At(x,1):null:null,Ye=ue&&ue.assetId!==(R==null?void 0:R.assetId)?ue:null,Ue=fe&&fe.assetId!==(C==null?void 0:C.assetId)?fe:null,Ze=R&&st?(()=>{const n=wt?De(b,et,-1):e.length>2?At((i-1+e.length)%e.length,-1):null;return n&&n.assetId!==R.assetId?n:null})():null,Ke=C&&st?(()=>{const n=wt?De(b,et,1):e.length>2?At((i+1)%e.length,1):null;return n&&n.assetId!==C.assetId?n:null})():null,Zt=Ye??Ze,Kt=Ue??Ke,vt=r.useCallback((n,a,h)=>{if(!n||!a||!h)return;const f=Rt.current,v=f.get(n);(v==null?void 0:v.width)===a&&(v==null?void 0:v.height)===h||(f.set(n,{width:a,height:h}),Ct(z=>z+1))},[]),Tt=r.useCallback(n=>{if(!(n!=null&&n.assetId))return null;const a=Rt.current.get(n.assetId);return In(Lt.current,a)},[B,se]),Jt=r.useCallback(()=>{if(!d)return;const n=Tt(d);if(n){yt(n);return}const a=Lt.current;a&&yt(_e(a))},[d,Tt]),Qt=r.useCallback(n=>{if(wt){const a=b.length;ht((et+n+a)%a),w(null);return}e.length>1&&(w((i+n+e.length)%e.length),ht(null))},[wt,b.length,et,e.length,i]),E=r.useCallback(n=>{it.current=n,le(n)},[]),y=r.useCallback(()=>{rt.current!==null&&(window.clearTimeout(rt.current),rt.current=null)},[]),ke=r.useCallback(()=>{y(),rt.current=window.setTimeout(()=>{y(),E(!1)},Gt+32)},[y,E]),Le=r.useCallback(()=>{const n=Yt.current;if(!n){Ut({left:0,top:0,width:typeof window<"u"?window.innerWidth:me.width,height:typeof window<"u"?window.innerHeight:me.height});return}const a=n.getBoundingClientRect();Ut({left:a.left,top:a.top,width:a.width,height:a.height})},[]),je=r.useCallback((n,a)=>{if(mt){if(M&&!V)return`translate(${zt}px, 0px)`;if(V&&U!==null){const h=Tt(n);if(!h)return;const{x:f,y:v}=Rn(h,a,U,L);return`translate(${f}px, ${v}px)`}if(V)return"translate(0px, 0px)"}},[mt,M,V,zt,U,L,Tt]),Ht=r.useCallback(()=>{const n=I.current;I.current=null,y(),E(!1),dt(null),ht(null),w(null),S(0),A(!1),q.current=!1,N.current=0,T.current="none",n===-1?Mt():n===1&&Ot()},[y,E,Mt,Ot]),Pt=r.useCallback(()=>{y(),rt.current=window.setTimeout(()=>{I.current!==null&&Ht()},Gt+32)},[y,Ht]),Re=r.useCallback(()=>{y(),I.current=null,E(!1),dt(null),ht(null),w(null),S(0),A(!1),q.current=!1,N.current=0,T.current="none"},[y,E]),Ce=r.useCallback(n=>{if(!(!st||!k)){if(it.current){if(I.current===n){Et.current=n,Ht();return}Re()}y(),Qt(n),I.current=n,dt(n),E(!0),Pt()}},[st,k,Ht,Re,y,Qt,E,Pt]);ct.current=Ce;const at=r.useCallback(()=>{X.current=null,ot.current=!1,W.current!==null&&(window.clearInterval(W.current),W.current=null),ut.current!==null&&(window.clearTimeout(ut.current),ut.current=null)},[]),de=r.useCallback(n=>{W.current!==null&&window.clearInterval(W.current);const a=ot.current?wn:mn;W.current=window.setInterval(()=>{ct.current(n)},a)},[]),Ee=r.useCallback(n=>{X.current!==n&&(at(),X.current=n,ot.current=!1,ct.current(n),de(n),ut.current=window.setTimeout(()=>{ut.current=null,X.current===n&&(ot.current=!0,de(n))},pn))},[at,de]),K=r.useCallback(()=>{const n=Lt.current;if(!n)return;const a=d==null?void 0:d.assetId,h=a?Rt.current.get(a):void 0;if(h!=null&&h.width&&(h!=null&&h.height)){yt(we(n,h.width,h.height));return}const f=jt.current;if(f&&a&&(f.src===a||f.currentSrc===a)){const{width:z,height:m}=bn(f);if(z&&m){vt(a,z,m),yt(we(n,z,m));return}}const v=_e(n);!v.width||!v.height||yt(v)},[d==null?void 0:d.assetId,vt]),Ae=r.useCallback(n=>{if(jt.current=n,!!n){if(n instanceof HTMLVideoElement){n.readyState>=1&&n.videoWidth>0&&K();return}n.complete&&n.naturalWidth>0&&K()}},[K]),Vt=r.useCallback(()=>{Le(),K(),ae(n=>n+1)},[Le,K]);r.useEffect(()=>{Vt();const n=Lt.current,a=Yt.current,h=new ResizeObserver(()=>Vt());return n&&h.observe(n),a&&h.observe(a),window.addEventListener("resize",Vt),()=>{h.disconnect(),window.removeEventListener("resize",Vt)}},[Vt,i,_]),r.useLayoutEffect(()=>{if(!d)return;const n=jt.current;if(n){if(n instanceof HTMLImageElement&&n.complete&&n.naturalWidth>0){K();return}n instanceof HTMLVideoElement&&n.readyState>=1&&n.videoWidth>0&&K()}},[d==null?void 0:d.assetId,i,K]),r.useEffect(()=>{Jt()},[Jt,B]),r.useEffect(()=>{const n=new Set,a=[],h=f=>{!(f!=null&&f.assetId)||n.has(f.assetId)||(n.add(f.assetId),a.push(f))};e.forEach(h),b.forEach(f=>f.items.forEach(h)),a.forEach(f=>{Rt.current.has(f.assetId)||Sn(f,vt)})},[e,b,vt]),r.useEffect(()=>{if(g!=="opening"||!k)return;if(!F){ft("open");return}j(!1);const n=requestAnimationFrame(()=>{requestAnimationFrame(()=>{j(!0),ft("open")})});return()=>cancelAnimationFrame(n)},[g,k,F]),r.useEffect(()=>{if(g!=="closing")return;const n=setTimeout(()=>Wt(),tt);return()=>clearTimeout(n)},[g,Wt]),r.useEffect(()=>()=>{y()},[y]),r.useLayoutEffect(()=>{$e.current===i&&be.current===(d==null?void 0:d.assetId)||(y(),I.current=null,dt(null),ht(null),w(null),$t(0),S(0),E(!1),ye(!1),A(!1),xt.current=0,N.current=0,T.current="none",q.current=!1,nt.current=null,G.current=!1,jt.current=null,Jt(),$e.current=i,be.current=d==null?void 0:d.assetId)},[i,d==null?void 0:d.assetId,E,y,Jt]),r.useLayoutEffect(()=>{const n=Et.current;n!==null&&(Et.current=null,requestAnimationFrame(()=>{ct.current(n)}))},[i,et,d==null?void 0:d.assetId]),r.useLayoutEffect(()=>{if(g==="opening"){It.current=!1,Z(!1);return}if(g!=="open"||It.current)return;if(!R&&!C){It.current=!0;return}Z(!1);const n=requestAnimationFrame(()=>{requestAnimationFrame(()=>{Z(!0),It.current=!0})});return()=>cancelAnimationFrame(n)},[g,R==null?void 0:R.assetId,C==null?void 0:C.assetId]),r.useEffect(()=>{if(g!=="open")return;const n=()=>{const m=$=>{$.stopPropagation(),$.preventDefault(),document.removeEventListener("click",m,!0)};document.addEventListener("click",m,!0)},a=m=>{const $=m<0?1:-1;y(),Qt($),I.current=$,dt($),E(!0),Pt()},h=m=>{if(Math.abs(m)>gn&&st){a(m);return}I.current=null,dt(null),ht(null),w(null),E(!0),S(0),ke()},f=m=>{if(m.touches.length!==1||it.current)return;const $=m.touches[0];G.current=!0,nt.current={x:$.clientX,y:$.clientY},T.current="none",N.current=0,q.current=!1},v=m=>{if(!nt.current||m.touches.length!==1||it.current)return;const $=m.touches[0],Q=$.clientX-nt.current.x,P=$.clientY-nt.current.y;if(T.current==="none"){if(Math.abs(Q)<10&&Math.abs(P)<10)return;if(Math.abs(Q)>Math.abs(P)){if(!st)return;T.current="horizontal"}else if(P>0){if(!ce)return;T.current="vertical"}else return}if(T.current==="horizontal"){q.current=!0,A(!0),N.current=Q,S(Q),m.preventDefault();return}T.current==="vertical"&&(q.current=!0,A(!0),xt.current=P,$t(P),m.preventDefault())},z=()=>{if(!nt.current)return;const m=T.current,$=q.current;if($&&m==="horizontal")h(N.current),n();else if($&&m==="vertical"){const Q=xt.current;if(ce&&Q>hn){const P=window.innerHeight;xt.current=P,ye(!0),$t(P),ft("closing")}else xt.current=0,$t(0);n()}else m==="horizontal"&&Math.abs(N.current)>0&&(h(N.current),n());nt.current=null,T.current="none",N.current=0,q.current=!1,A(!1)};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("touchend",z),document.addEventListener("touchcancel",z),()=>{document.removeEventListener("touchstart",f),document.removeEventListener("touchmove",v),document.removeEventListener("touchend",z),document.removeEventListener("touchcancel",z)}},[g,st,E,ke,y,ce,Pt,Qt]);const he=r.useCallback(()=>{const n=(kt==null?void 0:kt())??F??null;n&&k&&(Dt(n),j(!0)),ft("closing")},[kt,F,k]);r.useEffect(()=>{const n=f=>{if(f.key==="Escape"){if(c&&u||g==="closing")return;at(),he();return}if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight"||g!=="open"||!st)return;f.preventDefault();const v=f.key==="ArrowLeft"?-1:1;f.repeat&&X.current===v||Ee(v)},a=f=>{if(f.key!=="ArrowLeft"&&f.key!=="ArrowRight")return;const v=f.key==="ArrowLeft"?-1:1;X.current===v&&at()},h=()=>{at()};return window.addEventListener("keydown",n),window.addEventListener("keyup",a),window.addEventListener("blur",h),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",a),window.removeEventListener("blur",h),at()}},[g,c,u,he,st,Ee,at]),r.useEffect(()=>{g!=="open"&&at()},[g,at]);const Te=()=>{g==="closing"||p||he()},J=g==="open",te=g==="closing",Je=Y>0?Math.max(0,1-Y/500):1,Qe=Y>0?Math.max(.35,1-Y/500):1,St=r.useCallback(n=>{if(!(n.propertyName!=="transform"||!it.current)){if(I.current!==null){Ht();return}y(),E(!1)}},[y,E,Ht]),ge=g==="closing"?pt??F:F,Pe=ge&&k&&(g==="opening"||te)?vn(ge,k):void 0,tn=mt&&d?je(d,"center"):Y>0?`translateY(${Y}px)`:Pe,O=k?ie(k,L):null,He=!!(ge&&k),en=He&&(g==="closing"||g==="open"&&gt),pe={position:"absolute",top:O==null?void 0:O.top,left:O==null?void 0:O.left,width:O==null?void 0:O.width,height:O==null?void 0:O.height,objectFit:"contain",transformOrigin:"top left",transform:tn,opacity:Y>0?Qe:He?1:g==="opening"||te?0:1,transition:M&&!V?"none":V?`transform ${Gt}ms ${D}`:Xe?`transform ${tt}ms ${D}, opacity ${tt}ms ${D}`:en?`transform ${tt}ms ${D}`:g==="opening"||te?`opacity ${tt}ms ${D}`:"none",pointerEvents:"none",zIndex:1,overflow:Ie||Se?"hidden":void 0},Fe={width:"100%",height:"100%",display:"block",objectFit:"contain",pointerEvents:"none"},ee=(n,a,h="adjacent")=>{const f=Tt(n);if(!f)return{display:"none"};const v=h==="far"?a==="left"?"far-left":"far-right":a==="left"?"left-adjacent":"right-adjacent",{start:z}=U!==null?qe(f,v,U,L):{start:h==="far"?oe(f,a,L):Ft(f,a,L)},m=ie(z,L),$=je(n,v),Q=!mt&&h==="adjacent"&&J&&!_t?Cn(f,a,L):null,P=h==="far"&&mt&&U===(a==="left"?-1:1),nn=M&&!V?!1:V,rn=h==="adjacent"&&J&&_t&&!mt;return{position:"absolute",top:m.top,left:m.left,width:m.width,height:m.height,objectFit:"contain",transform:$??(Q?`translate(${Q.x}px, ${Q.y}px)`:void 0),opacity:h==="far"?J&&P?1:0:J?1:0,transition:nn?h==="far"?`transform ${Gt}ms ${D}`:`transform ${Gt}ms ${D}, opacity ${tt}ms ${D}`:rn?`transform ${tt}ms ${D}`:g==="opening"||te?`opacity ${tt}ms ${D}`:"none",pointerEvents:"none",zIndex:1}},Ne=(n,a)=>{const h=Tt(n);return h?jn(Ft(h,a,L),a,L):null},We=n=>a=>{if(!p){if(G.current){G.current=!1;return}a.stopPropagation(),Ce(n)}},Me=R?Ne(R,"left"):null,Oe=C?Ne(C,"right"):null,Bt=Me?ie(Me,L):null,qt=Oe?ie(Oe,L):null;return l.jsxs("div",{ref:Yt,className:[`${t}-lightbox`,c?`${t}-lightbox-editor`:"",p?`${t}-lightbox-edit-mode`:""].filter(Boolean).join(" "),style:{touchAction:g==="open"?"none":void 0},onClick:Te,children:[l.jsx("div",{style:{position:"absolute",inset:0,background:s.backgroundColor??"#FFFFFF",opacity:J?Je:0,transition:M?"none":`opacity ${tt}ms ${D}`,pointerEvents:"none"}}),l.jsxs("div",{className:`${t}-lightbox-dismiss-area`,children:[l.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[l.jsx("div",{style:{height:"10%"}}),l.jsx("div",{style:{width:"70%",height:"80%",display:"flex",justifyContent:"center",alignItems:"center"},children:l.jsx("div",{ref:Lt,style:{width:"100%",height:"100%"}})}),l.jsx("div",{style:{height:"10%"}})]}),l.jsx("div",{style:{position:"absolute",inset:0,opacity:J?1:0,transition:M?"none":`opacity ${tt}ms ${D}`,pointerEvents:"none"},children:l.jsx(cn.HiveLightboxTitles,{prefix:t,entry:o,settings:s,isEditor:c,isEditMode:p,isPreviewMode:u,onClose:Te})})]}),J&&Zt&&l.jsx(re,{media:Zt,style:ee(Zt,"left","far"),onMeasure:vt,onTransitionEnd:St},`far-prev-${Zt.assetId}`),J&&R&&l.jsxs(l.Fragment,{children:[l.jsx(re,{media:R,style:ee(R,"left"),onMeasure:vt,onTransitionEnd:St},`prev-${R.assetId}`),Bt&&l.jsx("div",{style:{position:"absolute",top:Bt.top,left:Bt.left,width:Bt.width,height:Bt.height,cursor:p||M?"default":"pointer",pointerEvents:p||M?"none":"auto",zIndex:3},onClick:We(-1)})]}),J&&C&&l.jsxs(l.Fragment,{children:[l.jsx(re,{media:C,style:ee(C,"right"),onMeasure:vt,onTransitionEnd:St},`next-${C.assetId}`),qt&&l.jsx("div",{style:{position:"absolute",top:qt.top,left:qt.left,width:qt.width,height:qt.height,cursor:p||M?"default":"pointer",pointerEvents:p||M?"none":"auto",zIndex:3},onClick:We(1)})]}),J&&Kt&&l.jsx(re,{media:Kt,style:ee(Kt,"right","far"),onMeasure:vt,onTransitionEnd:St},`far-next-${Kt.assetId}`),k&&d&&(Se?l.jsx("div",{style:pe,onTransitionEnd:St,children:l.jsx(lt.EmbedMediaFrame,{media:d,fit:"contain",lazy:!1,startsAtOnce:!0,style:Fe})},`${i}-${d.assetId}`):Ie?l.jsx(Hn,{src:d.assetId,onMediaElement:Ae,wrapperStyle:pe,videoStyle:Fe,onLoadedMetadata:K,onTransitionEnd:St},`${i}-${d.assetId}`):l.jsx("img",{ref:Ae,src:d.assetId,alt:d.name,onLoad:K,onTransitionEnd:St,style:pe},`${i}-${d.assetId}`))]})}function Nn({settings:t,content:e,isEditor:i,isPreviewMode:o,isEditMode:s,layoutId:c,portalId:p}){const{prefix:u}=on.useScopedStyles(),{gridLayout:H,verticalGap:b,align:et="top",imageDisplay:_}=t,F=(_==null?void 0:_.display)==="cover",kt=(_==null?void 0:_.ratioValue)??"1:1",Wt=(_==null?void 0:_.reversed)??!1,[Mt,Ot]=kt.split(":").map(Number),jt=`${Wt?Ot:Mt} / ${Wt?Mt:Ot}`,Rt=H.entryWidth??.2,B=H.columnsCount,Ct=ne.scalingValue(Rt,i),nt=ne.scalingValue(H.horizontalGap??0,i),xt=Ct,N=Ct,T={width:xt,...F?{aspectRatio:jt,height:"auto",overflow:"hidden"}:{height:"auto"}},q=F?{objectFit:"cover",pointerEvents:"auto",width:"100%",height:"100%",maxWidth:"100%"}:{objectFit:"contain",pointerEvents:"auto",width:"auto",height:"auto",maxWidth:"100%"},G=r.useRef(null),[it,rt]=r.useState(!1),[I,Et]=r.useState([]),[ct,X]=r.useState(0),[W,ut]=r.useState(0),[ot,k]=r.useState(null),[yt,L]=r.useState({title1:"",title2:"",title3:""}),Ut=(()=>{const x={},w=G.current?getComputedStyle(G.current).getPropertyValue("--cntrl-article-width").trim():"";return w&&(x["--cntrl-article-width"]=w),x})(),se=!i||o||s,ae=r.useMemo(()=>dn(u),[u]),g=e??[],ft=g.length%B||B,Y=ft<B&&g.length>0,$t=g.length-ft,zt=Y?Math.floor((B-ft)/2)+1:1,S=r.useMemo(()=>yn(g),[g]),V=r.useMemo(()=>kn(g),[g]),le=(x,w,gt)=>{if(i&&!s&&!o)return;const j=S.findIndex(Dt=>Dt.gridIndex===x);if(j<0)return;const pt=S[j];ut(j),Et(pt.items),X(w),L(pt.entry),k(gt??null),rt(!0)},U=r.useCallback(()=>{rt(!1),k(null)},[]),dt=r.useCallback(()=>{const x=S[W];return!x||!G.current?ot:xn(G.current,x.gridIndex,F?"cover":"contain")??ot},[S,W,ot,F]),bt=r.useCallback(x=>{if(S.length>1){const w=S.length,gt=(W+x+w)%w,j=S[gt],pt=Math.min(ct,j.items.length-1);ut(gt),Et(j.items),X(pt),L(j.entry);return}X(w=>(w+x+I.length)%I.length)},[S,W,ct,I.length]),ht=S.length>1||I.length>1;return r.useEffect(()=>{if(!it||typeof document>"u")return;const x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x}},[it]),r.useEffect(()=>{!i||s||o||rt(!1)},[i,s,o]),l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:ae}}),l.jsx(Ln,{mediaList:V}),l.jsx("div",{ref:G,className:`${u}-wrapper ${u}-align-entries ${u}-image-align-${et}`.trim(),style:{gridTemplateColumns:`repeat(${B}, ${Ct})`,rowGap:0,columnGap:nt,width:ne.scalingValue(H.wrapperWidth??0,i),[`--${u}-align-entries-row-gap`]:ne.scalingValue(b??0,i)},children:g.map((x,w)=>{const gt=ve(x.gallery),j=xe(gt),pt=j.filter(A=>A.lightboxMedia).map(A=>A.lightboxMedia),Dt=Math.floor(w/B)===Math.ceil(g.length/B)-1,_t=Y&&w>=$t?`${zt+(w-$t)}`:void 0,Z=j[0],It=Z!=null&&Z.lightboxMedia?pt.findIndex(A=>A.assetId===Z.lightboxMedia.assetId):-1,M=l.jsx("div",{className:`${u}-item-image-wrapper`,style:T,children:j.length>0&&l.jsx(Tn,{media:Z.displayMedia,gridIndex:w,className:`${u}-item-${Nt(Z.displayMedia)?"video":"image"}`.trim(),style:q,onMediaClick:se&&It>=0?A=>le(w,It,Ve(A.currentTarget,F?"cover":"contain")):void 0})});return l.jsx("div",{className:`${u}-item`,children:l.jsxs("div",{className:[s?`${u}-item-inner`:`${u}-item-inner-hidden`,Dt?`${u}-item-inner-last-row`:""].filter(Boolean).join(" "),style:{width:Ct,..._t?{gridColumn:_t}:{}},children:[l.jsx("div",{className:`${u}-item-title-row`,children:l.jsx("div",{style:{height:0,width:N}})}),l.jsx("a",{className:`${u}-item-image-link`,children:M}),l.jsx("div",{className:`${u}-item-subtitle-row`,children:l.jsx("div",{style:{height:0,width:N}})})]})},w)})}),it&&typeof document<"u"&&(()=>{const x=(p?document.getElementById(p):null)??document.body;return ln.createPortal(l.jsx("div",{style:Ut,"data-selection":"none",children:l.jsx(Fn,{prefix:u,items:I,index:ct,entry:yt,settings:t,isEditor:i,isEditMode:s,isPreviewMode:o,canNavigate:ht,lightboxEntries:S,entryIdx:W,layoutId:c,sourceRect:ot,resolveCloseSourceRect:dt,onClose:U,onPrev:()=>bt(-1),onNext:()=>bt(1)})}),x)})()]})}exports.Hive=Nn;