@cntrl-site/components 1.0.97-7 → 1.0.97-8
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/dist/Components/Pretext/Pretext.d.ts +2 -1
- package/dist/Components/utils/EmbedMediaFrame.d.ts +15 -6
- package/dist/Components/utils/embedMedia.d.ts +24 -5
- package/dist/Components/utils/index.d.ts +2 -2
- package/dist/EmbedMediaFrame-C__c1jQ6.js +1 -0
- package/dist/EmbedMediaFrame-Mkas2vMk.mjs +296 -0
- package/dist/index.js +97 -184
- package/dist/index.mjs +8396 -8539
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +12 -10
- package/package.json +1 -1
- package/dist/EmbedMediaFrame-BqqoaiHc.mjs +0 -236
- package/dist/EmbedMediaFrame-C5O6lDaq.js +0 -1
|
@@ -70,6 +70,7 @@ export type PretextProps = {
|
|
|
70
70
|
isPreviewMode?: boolean;
|
|
71
71
|
isEditMode?: boolean;
|
|
72
72
|
isSelected?: boolean;
|
|
73
|
+
isUIHidden?: boolean;
|
|
73
74
|
onUpdateSettings?: (settings: PretextSettings) => void;
|
|
74
75
|
} & CommonComponentProps;
|
|
75
76
|
export type Pt = {
|
|
@@ -273,4 +274,4 @@ export type ImageEditorProps = {
|
|
|
273
274
|
};
|
|
274
275
|
export { EDIT_VIEW_BOX } from './vecContours';
|
|
275
276
|
export { mapContours, scaleContours, parsePathNodes, serializeContours, flattenContours, ringsToContours, settingsForEditablePreset, moveNodeTo, moveSelectedNodesBy, removeContourNodes, setNodeHandle, clearNodeHandle, insertNodeOnSegment, removeContourNode, toggleNodeSmooth, nearestSegmentHit, } from './vecContours';
|
|
276
|
-
export declare function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode, isSelected, onUpdateSettings }: PretextProps): import("react/jsx-runtime").JSX.Element;
|
|
277
|
+
export declare function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode, isSelected, isUIHidden, onUpdateSettings }: PretextProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
import { EmbedMediaLike
|
|
2
|
+
import { EmbedMediaLike } from './embedMedia';
|
|
3
3
|
export interface EmbedMediaFrameProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
4
4
|
media: EmbedMediaLike;
|
|
5
|
-
mode: EmbedPlayerMode;
|
|
6
5
|
/** How the video fills the box, the way an image's object-fit would. */
|
|
7
6
|
fit: 'cover' | 'contain';
|
|
8
|
-
/** Whether the player takes the pointer; a background one leaves it to the box around it. */
|
|
9
|
-
interactive?: boolean;
|
|
10
7
|
/** Framed only while near the viewport, so a track of copies holds one player per visible card. */
|
|
11
8
|
lazy?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Played at once whatever starts it elsewhere: opening a lightbox, or pointing at what a preview shows for,
|
|
11
|
+
* is already the gesture, and the click is left to the box around it.
|
|
12
|
+
*/
|
|
13
|
+
startsAtOnce?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Played as a silent loop whatever the media says, the click left to the box: a cell that opens a lightbox
|
|
16
|
+
* shows the video there as it was set to play.
|
|
17
|
+
*/
|
|
18
|
+
silentLoop?: boolean;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* A Vimeo or YouTube video in the room of an image or a video: a box the caller sizes and places,
|
|
15
|
-
* showing the stored thumbnail until the player is framed over it
|
|
16
|
-
*
|
|
22
|
+
* showing the stored thumbnail until the player is framed over it, and playing as the media says.
|
|
23
|
+
* A video that waits for a hover or a click is framed only then, and paused and played again after.
|
|
24
|
+
* Its controls, or a click that plays it, take the click, which then opens nothing around it; any
|
|
25
|
+
* other video is clicked like a picture. A box with no height of its own takes the video's aspect.
|
|
17
26
|
*/
|
|
18
27
|
export declare const EmbedMediaFrame: FC<EmbedMediaFrameProps>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export type EmbedProvider = 'vimeo' | 'youtube';
|
|
2
|
-
|
|
2
|
+
export type EmbedPlayMode = 'auto' | 'on-hover' | 'on-click';
|
|
3
|
+
/**
|
|
4
|
+
* What a media value holds of a Vimeo or YouTube video: its player url, the picture and size the player has
|
|
5
|
+
* none of, and how it plays, as the editor's embed form set it.
|
|
6
|
+
*/
|
|
3
7
|
export type EmbedMediaLike = {
|
|
4
8
|
assetId?: string;
|
|
5
9
|
type?: string;
|
|
@@ -7,15 +11,30 @@ export type EmbedMediaLike = {
|
|
|
7
11
|
thumbnail?: string;
|
|
8
12
|
width?: number;
|
|
9
13
|
height?: number;
|
|
14
|
+
play?: EmbedPlayMode;
|
|
15
|
+
controls?: boolean;
|
|
16
|
+
loop?: boolean;
|
|
17
|
+
muted?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type EmbedPlayback = {
|
|
20
|
+
play: EmbedPlayMode;
|
|
21
|
+
controls: boolean;
|
|
22
|
+
loop: boolean;
|
|
23
|
+
muted: boolean;
|
|
10
24
|
};
|
|
11
|
-
export type EmbedPlayerMode = 'background' | 'player';
|
|
12
25
|
/** The provider whose player a media is framed from, none for a file or a value that only claims to be one. */
|
|
13
26
|
export declare function getEmbedProvider(media: EmbedMediaLike | null | undefined): EmbedProvider | null;
|
|
14
27
|
export declare function isEmbedMedia(media: EmbedMediaLike | null | undefined): boolean;
|
|
15
28
|
/** Width over height of the video, 16:9 when the media does not say. */
|
|
16
29
|
export declare function getEmbedAspect(media: EmbedMediaLike): number;
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
31
|
+
* How the video plays: a media that does not say plays as an uploaded video does, on its own, muted and
|
|
32
|
+
* looping, with no controls. Only a click lets sound play, and YouTube's player, with no loop or sound to
|
|
33
|
+
* set, loops and is muted until clicked.
|
|
20
34
|
*/
|
|
21
|
-
export declare function
|
|
35
|
+
export declare function getEmbedPlayback(media: EmbedMediaLike): EmbedPlayback;
|
|
36
|
+
/** The player url set to play at once the way the media says; a player waiting for a hover or a click is framed only then. */
|
|
37
|
+
export declare function getEmbedPlayerSrc(media: EmbedMediaLike): string;
|
|
38
|
+
export type EmbedCommand = 'listen' | 'play' | 'pause';
|
|
39
|
+
/** Plays or pauses a framed player through the messages its provider's player listens to. */
|
|
40
|
+
export declare function postEmbedCommand(iframe: HTMLIFrameElement, provider: EmbedProvider, command: EmbedCommand): void;
|
|
@@ -11,7 +11,7 @@ export { getAvailableStatePanels, getUnavailableStates, isPanelAvailable, } from
|
|
|
11
11
|
export type { PanelAvailabilityContext } from './panelAvailability';
|
|
12
12
|
export { LinkWrapper } from './LinkWrapper';
|
|
13
13
|
export type { ContentLink } from '../../types/SchemaV1';
|
|
14
|
-
export { getEmbedAspect, getEmbedPlayerSrc, getEmbedProvider, isEmbedMedia } from './embedMedia';
|
|
15
|
-
export type { EmbedMediaLike,
|
|
14
|
+
export { getEmbedAspect, getEmbedPlayback, getEmbedPlayerSrc, getEmbedProvider, isEmbedMedia, postEmbedCommand } from './embedMedia';
|
|
15
|
+
export type { EmbedCommand, EmbedMediaLike, EmbedPlayback, EmbedPlayMode, EmbedProvider } from './embedMedia';
|
|
16
16
|
export { EmbedMediaFrame } from './EmbedMediaFrame';
|
|
17
17
|
export type { EmbedMediaFrameProps } from './EmbedMediaFrame';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("react"),h=require("react/jsx-runtime");function Z(t,e=!1){return e?`calc(var(--cntrl-article-width) * ${t})`:`${t*100}vw`}const tt=(t,e,n,s,r)=>{const i={};for(const[o,c]of Object.entries(n))i[`--${t}-${c}`]=e[o];const a=new Set(s);if(r)for(const o of Object.keys(r))a.add(o);for(const o of a){const c=r==null?void 0:r[o];if(c)for(const[g,b]of Object.entries(n)){const d=c[g];d!==void 0&&(i[`--${t}-${o}-${b}`]=d)}}return i};function et(t){const e=t.trim();if(!e||e==="none")return 1;if(e.endsWith("%")){const s=parseFloat(e);return Number.isFinite(s)?s/100:1}const n=parseFloat(e);return Number.isFinite(n)?n:1}function nt(t){const e=t.lastIndexOf("/");if(e!==-1)return et(t.slice(e+1))}function rt(t){const e=t.trim().toLowerCase();if(!e||e==="transparent")return 0;const n=e.match(/^(?:oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\((.+)\)$/);if(n){const r=n[1],i=nt(r);if(i!==void 0)return i;if(/^(?:rgba|hsla)$/.test(e.slice(0,4))){const a=r.split(",").map(o=>parseFloat(o.trim()));if(a.length===4&&Number.isFinite(a[3]))return a[3]}return 1}const s=e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);if(s){const r=s[1],i=r.length===4?r[3]+r[3]:r.slice(6,8);return parseInt(i,16)/255}return 1}const st=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,O=t=>st.test(t.trim()),B=t=>{const e=t.replace(/\D/g,"");return e.length>=7&&e.length<=15},ot=(t,e)=>{var n;for(const s of t){const r=((n=e[s.name])==null?void 0:n.trim())??"";if(r){if(s.type==="email"&&!O(r))return"Please enter a valid email address.";if(s.type==="phone"&&!B(r))return"Please enter a valid phone number."}}return null};function it(){const e=`cf-${u.useId().replace(/:/g,"")}`;return{prefix:e,cls:n=>`${e}-${n}`}}const at=(t,e)=>{const n=Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce((r,i)=>Math.max(r,i.getBoundingClientRect().height),0),s=Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce((r,i)=>Math.max(r,i.getBoundingClientRect().height),0);e({maxTextPx:n,maxCaptionPx:s})};function q(t,e){const n=t==null?void 0:t.availableWhen;return n?Object.entries(n).every(([s,r])=>{if(!(r!=null&&r.length))return!0;const i=e[s];return i===void 0?!0:r.includes(i)}):!0}function D(t,e){const n=t==null?void 0:t.statePanels;return n!=null&&n.length?n.filter(s=>{var i;const r=(i=t==null?void 0:t.panels)==null?void 0:i.find(a=>a.id===s);return q(r,e)}):null}function lt(t,e){const n=t==null?void 0:t.statePanels;if(!(n!=null&&n.length))return[];const s=new Set(D(t,e)??[]);return n.filter(r=>!s.has(r))}const ct=["http://","https://","/","mailto:","tel:","file:","ftp:","javascript","#"];function ut(t){return ct.some(e=>t.startsWith(e))?t:`//${t}`}const ft=({link:t,className:e,style:n,children:s})=>{if(!(t!=null&&t.value))return h.jsx(h.Fragment,{children:s});const r=t.target==="blank"||t.target==="_blank"?{target:"_blank",rel:"noreferrer"}:{};return h.jsx("a",{href:ut(t.value),className:e,style:n,...r,children:s})},dt={vimeo:/^player\.vimeo\.com$/i,youtube:/^(?:www\.)?youtube(?:-nocookie)?\.com$/i};function y(t){if(!(t!=null&&t.assetId)||t.type!=="vimeo"&&t.type!=="youtube")return null;try{const e=new URL(t.assetId);return!dt[t.type].test(e.hostname)||t.type==="youtube"&&!e.pathname.startsWith("/embed/")?null:t.type}catch{return null}}function pt(t){return y(t)!==null}function H(t){const{width:e,height:n}=t;return e&&n&&e>0&&n>0?e/n:16/9}function k(t){const e=t.play??"auto",n=t.controls??!1,s=e==="on-click";return y(t)==="youtube"?{play:e,controls:n,loop:!0,muted:!s}:{play:e,controls:n,loop:t.loop??!0,muted:!s||(t.muted??!0)}}function J(t){const e=y(t);if(!e||!t.assetId)return t.assetId??"";const{play:n,controls:s,loop:r,muted:i}=k(t),a=new URL(t.assetId),o=a.searchParams,c=g=>g?"1":"0";return e==="vimeo"?(n==="auto"&&!s&&r&&i&&o.set("background","1"),o.set("autoplay","1"),o.set("muted",c(i)),o.set("loop",c(r)),o.set("controls",c(s)),o.set("title","0"),o.set("byline","0"),o.set("portrait","0"),o.set("autopause","0")):(o.set("autoplay","1"),o.set("mute",c(i)),o.set("loop","1"),o.set("playlist",a.pathname.slice(7)),o.set("controls",c(s)),o.set("disablekb",c(!s)),o.set("enablejsapi","1"),o.set("iv_load_policy","3"),o.set("playsinline","1"),o.set("rel","0"),o.set("modestbranding","1")),a.toString()}function ht(t,e){return t==="vimeo"?e==="listen"?null:{method:e}:e==="listen"?{event:"listening",id:1,channel:"widget"}:{event:"command",func:e==="play"?"playVideo":"pauseVideo",args:[]}}function X(t,e,n){const s=ht(e,n),r=t.contentWindow;if(!(!s||!r))try{r.postMessage(JSON.stringify(s),new URL(t.src).origin)}catch{}}const gt={play:"auto",controls:!1,loop:!0,muted:!0};function bt(t,e,n){const s=t.width/t.height,r=n==="cover"?e<=s:e>=s,i=r?t.width:t.height*e,a=r?t.width/e:t.height;return{width:i,height:a,left:(t.width-i)/2,top:(t.height-a)/2}}const mt=({media:t,fit:e,lazy:n=!0,startsAtOnce:s=!1,silentLoop:r=!1,style:i,onClick:a,onMouseEnter:o,onMouseLeave:c,...g})=>{const b=u.useRef(null),d=u.useRef(null),[v,Y]=u.useState(null),[R,V]=u.useState(!n),[C,F]=u.useState(!1),w=u.useRef(!1),I=u.useRef(!1),f=r?{...t,...gt}:t,L=H(f),_=y(f),S=k(f),E=s?"auto":S.play,T=!s&&(S.controls||S.play==="on-click");u.useEffect(()=>{const l=b.current;if(!l||typeof ResizeObserver>"u")return;const m=()=>{const{width:N,height:U}=l.getBoundingClientRect();Y(x=>x&&x.width===N&&x.height===U?x:{width:N,height:U})};m();const P=new ResizeObserver(m);return P.observe(l),()=>P.disconnect()},[]),u.useEffect(()=>{const l=b.current;if(!n||!l||typeof IntersectionObserver>"u"){V(!0);return}const m=new IntersectionObserver(([P])=>V(P.isIntersecting),{rootMargin:"200px"});return m.observe(l),()=>m.disconnect()},[n]),u.useEffect(()=>{R||(F(!1),w.current=!1)},[R]);const p=v&&v.width>0&&v.height>0?bt(v,L,e):null,$=R&&p!==null&&(E==="auto"||C);u.useEffect(()=>{$||(I.current=!1)},[$]);const A=l=>{d.current&&_&&X(d.current,_,l)},W=()=>{w.current=!0,C?A("play"):F(!0)},M=()=>{w.current=!1,I.current?A("pause"):F(!1)},z=l=>{if(!T){a==null||a(l);return}l.preventDefault(),l.stopPropagation(),E==="on-click"&&(w.current?M():W())},{width:j,...G}=i??{},K={position:"relative",overflow:"hidden",aspectRatio:`${L}`,width:j===void 0||j==="auto"?"100%":j,...G,...T&&{cursor:"pointer"}},Q={position:"absolute",inset:0,width:"100%",height:"100%",objectFit:e,pointerEvents:"none"};return h.jsxs("div",{ref:b,"data-embed-frame":"",style:K,...g,onClick:z,onMouseEnter:l=>{o==null||o(l),E==="on-hover"&&W()},onMouseLeave:l=>{c==null||c(l),E==="on-hover"&&M()},children:[f.thumbnail&&h.jsx("img",{src:f.thumbnail,alt:f.name??"",draggable:!1,style:Q}),$&&p&&h.jsx("iframe",{ref:d,src:J(f),title:f.name||"Embedded video",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,style:{position:"absolute",left:p.left,top:p.top,width:p.width,height:p.height,border:0,pointerEvents:S.controls?"auto":"none"},onLoad:()=>{I.current=!0,A("listen")}})]})};exports.EmbedMediaFrame=mt;exports.LinkWrapper=ft;exports.buildColorVars=tt;exports.getAvailableStatePanels=D;exports.getColorAlpha=rt;exports.getEmbedAspect=H;exports.getEmbedPlayback=k;exports.getEmbedPlayerSrc=J;exports.getEmbedProvider=y;exports.getFormFieldValidationError=ot;exports.getUnavailableStates=lt;exports.isEmbedMedia=pt;exports.isPanelAvailable=q;exports.isValidEmailFormat=O;exports.isValidPhoneFormat=B;exports.postEmbedCommand=X;exports.readTestimonialTextMeasure=at;exports.scalingValue=Z;exports.useScopedStyles=it;
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { useId as Y, useRef as x, useState as j, useEffect as E } from "react";
|
|
2
|
+
import { jsx as I, Fragment as z, jsxs as G } from "react/jsx-runtime";
|
|
3
|
+
function gt(t, e = !1) {
|
|
4
|
+
return e ? `calc(var(--cntrl-article-width) * ${t})` : `${t * 100}vw`;
|
|
5
|
+
}
|
|
6
|
+
const bt = (t, e, n, s, r) => {
|
|
7
|
+
const i = {};
|
|
8
|
+
for (const [o, c] of Object.entries(n))
|
|
9
|
+
i[`--${t}-${c}`] = e[o];
|
|
10
|
+
const a = new Set(s);
|
|
11
|
+
if (r)
|
|
12
|
+
for (const o of Object.keys(r))
|
|
13
|
+
a.add(o);
|
|
14
|
+
for (const o of a) {
|
|
15
|
+
const c = r == null ? void 0 : r[o];
|
|
16
|
+
if (c)
|
|
17
|
+
for (const [p, h] of Object.entries(n)) {
|
|
18
|
+
const f = c[p];
|
|
19
|
+
f !== void 0 && (i[`--${t}-${o}-${h}`] = f);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return i;
|
|
23
|
+
};
|
|
24
|
+
function K(t) {
|
|
25
|
+
const e = t.trim();
|
|
26
|
+
if (!e || e === "none") return 1;
|
|
27
|
+
if (e.endsWith("%")) {
|
|
28
|
+
const s = parseFloat(e);
|
|
29
|
+
return Number.isFinite(s) ? s / 100 : 1;
|
|
30
|
+
}
|
|
31
|
+
const n = parseFloat(e);
|
|
32
|
+
return Number.isFinite(n) ? n : 1;
|
|
33
|
+
}
|
|
34
|
+
function Q(t) {
|
|
35
|
+
const e = t.lastIndexOf("/");
|
|
36
|
+
if (e !== -1)
|
|
37
|
+
return K(t.slice(e + 1));
|
|
38
|
+
}
|
|
39
|
+
function mt(t) {
|
|
40
|
+
const e = t.trim().toLowerCase();
|
|
41
|
+
if (!e || e === "transparent") return 0;
|
|
42
|
+
const n = e.match(/^(?:oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\((.+)\)$/);
|
|
43
|
+
if (n) {
|
|
44
|
+
const r = n[1], i = Q(r);
|
|
45
|
+
if (i !== void 0) return i;
|
|
46
|
+
if (/^(?:rgba|hsla)$/.test(e.slice(0, 4))) {
|
|
47
|
+
const a = r.split(",").map((o) => parseFloat(o.trim()));
|
|
48
|
+
if (a.length === 4 && Number.isFinite(a[3]))
|
|
49
|
+
return a[3];
|
|
50
|
+
}
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
const s = e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);
|
|
54
|
+
if (s) {
|
|
55
|
+
const r = s[1], i = r.length === 4 ? r[3] + r[3] : r.slice(6, 8);
|
|
56
|
+
return parseInt(i, 16) / 255;
|
|
57
|
+
}
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
const Z = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, tt = (t) => Z.test(t.trim()), et = (t) => {
|
|
61
|
+
const e = t.replace(/\D/g, "");
|
|
62
|
+
return e.length >= 7 && e.length <= 15;
|
|
63
|
+
}, yt = (t, e) => {
|
|
64
|
+
var n;
|
|
65
|
+
for (const s of t) {
|
|
66
|
+
const r = ((n = e[s.name]) == null ? void 0 : n.trim()) ?? "";
|
|
67
|
+
if (r) {
|
|
68
|
+
if (s.type === "email" && !tt(r))
|
|
69
|
+
return "Please enter a valid email address.";
|
|
70
|
+
if (s.type === "phone" && !et(r))
|
|
71
|
+
return "Please enter a valid phone number.";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
function vt() {
|
|
77
|
+
const e = `cf-${Y().replace(/:/g, "")}`;
|
|
78
|
+
return {
|
|
79
|
+
prefix: e,
|
|
80
|
+
cls: (n) => `${e}-${n}`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const wt = (t, e) => {
|
|
84
|
+
const n = Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce(
|
|
85
|
+
(r, i) => Math.max(r, i.getBoundingClientRect().height),
|
|
86
|
+
0
|
|
87
|
+
), s = Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce(
|
|
88
|
+
(r, i) => Math.max(r, i.getBoundingClientRect().height),
|
|
89
|
+
0
|
|
90
|
+
);
|
|
91
|
+
e({ maxTextPx: n, maxCaptionPx: s });
|
|
92
|
+
};
|
|
93
|
+
function nt(t, e) {
|
|
94
|
+
const n = t == null ? void 0 : t.availableWhen;
|
|
95
|
+
return n ? Object.entries(n).every(([s, r]) => {
|
|
96
|
+
if (!(r != null && r.length)) return !0;
|
|
97
|
+
const i = e[s];
|
|
98
|
+
return i === void 0 ? !0 : r.includes(i);
|
|
99
|
+
}) : !0;
|
|
100
|
+
}
|
|
101
|
+
function rt(t, e) {
|
|
102
|
+
const n = t == null ? void 0 : t.statePanels;
|
|
103
|
+
return n != null && n.length ? n.filter((s) => {
|
|
104
|
+
var i;
|
|
105
|
+
const r = (i = t == null ? void 0 : t.panels) == null ? void 0 : i.find((a) => a.id === s);
|
|
106
|
+
return nt(r, e);
|
|
107
|
+
}) : null;
|
|
108
|
+
}
|
|
109
|
+
function St(t, e) {
|
|
110
|
+
const n = t == null ? void 0 : t.statePanels;
|
|
111
|
+
if (!(n != null && n.length)) return [];
|
|
112
|
+
const s = new Set(rt(t, e) ?? []);
|
|
113
|
+
return n.filter((r) => !s.has(r));
|
|
114
|
+
}
|
|
115
|
+
const st = ["http://", "https://", "/", "mailto:", "tel:", "file:", "ftp:", "javascript", "#"];
|
|
116
|
+
function ot(t) {
|
|
117
|
+
return st.some((e) => t.startsWith(e)) ? t : `//${t}`;
|
|
118
|
+
}
|
|
119
|
+
const xt = ({ link: t, className: e, style: n, children: s }) => {
|
|
120
|
+
if (!(t != null && t.value)) return /* @__PURE__ */ I(z, { children: s });
|
|
121
|
+
const r = t.target === "blank" || t.target === "_blank" ? { target: "_blank", rel: "noreferrer" } : {};
|
|
122
|
+
return /* @__PURE__ */ I("a", { href: ot(t.value), className: e, style: n, ...r, children: s });
|
|
123
|
+
}, it = {
|
|
124
|
+
vimeo: /^player\.vimeo\.com$/i,
|
|
125
|
+
youtube: /^(?:www\.)?youtube(?:-nocookie)?\.com$/i
|
|
126
|
+
};
|
|
127
|
+
function P(t) {
|
|
128
|
+
if (!(t != null && t.assetId) || t.type !== "vimeo" && t.type !== "youtube") return null;
|
|
129
|
+
try {
|
|
130
|
+
const e = new URL(t.assetId);
|
|
131
|
+
return !it[t.type].test(e.hostname) || t.type === "youtube" && !e.pathname.startsWith("/embed/") ? null : t.type;
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function Et(t) {
|
|
137
|
+
return P(t) !== null;
|
|
138
|
+
}
|
|
139
|
+
function at(t) {
|
|
140
|
+
const { width: e, height: n } = t;
|
|
141
|
+
return e && n && e > 0 && n > 0 ? e / n : 16 / 9;
|
|
142
|
+
}
|
|
143
|
+
function M(t) {
|
|
144
|
+
const e = t.play ?? "auto", n = t.controls ?? !1, s = e === "on-click";
|
|
145
|
+
return P(t) === "youtube" ? { play: e, controls: n, loop: !0, muted: !s } : { play: e, controls: n, loop: t.loop ?? !0, muted: !s || (t.muted ?? !0) };
|
|
146
|
+
}
|
|
147
|
+
function lt(t) {
|
|
148
|
+
const e = P(t);
|
|
149
|
+
if (!e || !t.assetId) return t.assetId ?? "";
|
|
150
|
+
const { play: n, controls: s, loop: r, muted: i } = M(t), a = new URL(t.assetId), o = a.searchParams, c = (p) => p ? "1" : "0";
|
|
151
|
+
return e === "vimeo" ? (n === "auto" && !s && r && i && o.set("background", "1"), o.set("autoplay", "1"), o.set("muted", c(i)), o.set("loop", c(r)), o.set("controls", c(s)), o.set("title", "0"), o.set("byline", "0"), o.set("portrait", "0"), o.set("autopause", "0")) : (o.set("autoplay", "1"), o.set("mute", c(i)), o.set("loop", "1"), o.set("playlist", a.pathname.slice(7)), o.set("controls", c(s)), o.set("disablekb", c(!s)), o.set("enablejsapi", "1"), o.set("iv_load_policy", "3"), o.set("playsinline", "1"), o.set("rel", "0"), o.set("modestbranding", "1")), a.toString();
|
|
152
|
+
}
|
|
153
|
+
function ct(t, e) {
|
|
154
|
+
return t === "vimeo" ? e === "listen" ? null : { method: e } : e === "listen" ? { event: "listening", id: 1, channel: "widget" } : { event: "command", func: e === "play" ? "playVideo" : "pauseVideo", args: [] };
|
|
155
|
+
}
|
|
156
|
+
function ut(t, e, n) {
|
|
157
|
+
const s = ct(e, n), r = t.contentWindow;
|
|
158
|
+
if (!(!s || !r))
|
|
159
|
+
try {
|
|
160
|
+
r.postMessage(JSON.stringify(s), new URL(t.src).origin);
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const ft = { play: "auto", controls: !1, loop: !0, muted: !0 };
|
|
165
|
+
function dt(t, e, n) {
|
|
166
|
+
const s = t.width / t.height, r = n === "cover" ? e <= s : e >= s, i = r ? t.width : t.height * e, a = r ? t.width / e : t.height;
|
|
167
|
+
return { width: i, height: a, left: (t.width - i) / 2, top: (t.height - a) / 2 };
|
|
168
|
+
}
|
|
169
|
+
const It = ({
|
|
170
|
+
media: t,
|
|
171
|
+
fit: e,
|
|
172
|
+
lazy: n = !0,
|
|
173
|
+
startsAtOnce: s = !1,
|
|
174
|
+
silentLoop: r = !1,
|
|
175
|
+
style: i,
|
|
176
|
+
onClick: a,
|
|
177
|
+
onMouseEnter: o,
|
|
178
|
+
onMouseLeave: c,
|
|
179
|
+
...p
|
|
180
|
+
}) => {
|
|
181
|
+
const h = x(null), f = x(null), [b, q] = j(null), [R, _] = j(!n), [C, $] = j(!1), m = x(!1), F = x(!1), u = r ? { ...t, ...ft } : t, N = at(u), V = P(u), y = M(u), v = s ? "auto" : y.play, W = !s && (y.controls || y.play === "on-click");
|
|
182
|
+
E(() => {
|
|
183
|
+
const l = h.current;
|
|
184
|
+
if (!l || typeof ResizeObserver > "u") return;
|
|
185
|
+
const g = () => {
|
|
186
|
+
const { width: U, height: B } = l.getBoundingClientRect();
|
|
187
|
+
q((S) => S && S.width === U && S.height === B ? S : { width: U, height: B });
|
|
188
|
+
};
|
|
189
|
+
g();
|
|
190
|
+
const w = new ResizeObserver(g);
|
|
191
|
+
return w.observe(l), () => w.disconnect();
|
|
192
|
+
}, []), E(() => {
|
|
193
|
+
const l = h.current;
|
|
194
|
+
if (!n || !l || typeof IntersectionObserver > "u") {
|
|
195
|
+
_(!0);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const g = new IntersectionObserver(([w]) => _(w.isIntersecting), { rootMargin: "200px" });
|
|
199
|
+
return g.observe(l), () => g.disconnect();
|
|
200
|
+
}, [n]), E(() => {
|
|
201
|
+
R || ($(!1), m.current = !1);
|
|
202
|
+
}, [R]);
|
|
203
|
+
const d = b && b.width > 0 && b.height > 0 ? dt(b, N, e) : null, A = R && d !== null && (v === "auto" || C);
|
|
204
|
+
E(() => {
|
|
205
|
+
A || (F.current = !1);
|
|
206
|
+
}, [A]);
|
|
207
|
+
const k = (l) => {
|
|
208
|
+
f.current && V && ut(f.current, V, l);
|
|
209
|
+
}, O = () => {
|
|
210
|
+
m.current = !0, C ? k("play") : $(!0);
|
|
211
|
+
}, T = () => {
|
|
212
|
+
m.current = !1, F.current ? k("pause") : $(!1);
|
|
213
|
+
}, D = (l) => {
|
|
214
|
+
if (!W) {
|
|
215
|
+
a == null || a(l);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
l.preventDefault(), l.stopPropagation(), v === "on-click" && (m.current ? T() : O());
|
|
219
|
+
}, { width: L, ...H } = i ?? {}, J = {
|
|
220
|
+
position: "relative",
|
|
221
|
+
overflow: "hidden",
|
|
222
|
+
aspectRatio: `${N}`,
|
|
223
|
+
width: L === void 0 || L === "auto" ? "100%" : L,
|
|
224
|
+
...H,
|
|
225
|
+
...W && { cursor: "pointer" }
|
|
226
|
+
}, X = {
|
|
227
|
+
position: "absolute",
|
|
228
|
+
inset: 0,
|
|
229
|
+
width: "100%",
|
|
230
|
+
height: "100%",
|
|
231
|
+
objectFit: e,
|
|
232
|
+
pointerEvents: "none"
|
|
233
|
+
};
|
|
234
|
+
return /* @__PURE__ */ G(
|
|
235
|
+
"div",
|
|
236
|
+
{
|
|
237
|
+
ref: h,
|
|
238
|
+
"data-embed-frame": "",
|
|
239
|
+
style: J,
|
|
240
|
+
...p,
|
|
241
|
+
onClick: D,
|
|
242
|
+
onMouseEnter: (l) => {
|
|
243
|
+
o == null || o(l), v === "on-hover" && O();
|
|
244
|
+
},
|
|
245
|
+
onMouseLeave: (l) => {
|
|
246
|
+
c == null || c(l), v === "on-hover" && T();
|
|
247
|
+
},
|
|
248
|
+
children: [
|
|
249
|
+
u.thumbnail && /* @__PURE__ */ I("img", { src: u.thumbnail, alt: u.name ?? "", draggable: !1, style: X }),
|
|
250
|
+
A && d && /* @__PURE__ */ I(
|
|
251
|
+
"iframe",
|
|
252
|
+
{
|
|
253
|
+
ref: f,
|
|
254
|
+
src: lt(u),
|
|
255
|
+
title: u.name || "Embedded video",
|
|
256
|
+
allow: "autoplay; fullscreen; picture-in-picture",
|
|
257
|
+
allowFullScreen: !0,
|
|
258
|
+
style: {
|
|
259
|
+
position: "absolute",
|
|
260
|
+
left: d.left,
|
|
261
|
+
top: d.top,
|
|
262
|
+
width: d.width,
|
|
263
|
+
height: d.height,
|
|
264
|
+
border: 0,
|
|
265
|
+
pointerEvents: y.controls ? "auto" : "none"
|
|
266
|
+
},
|
|
267
|
+
onLoad: () => {
|
|
268
|
+
F.current = !0, k("listen");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
export {
|
|
277
|
+
It as E,
|
|
278
|
+
xt as L,
|
|
279
|
+
yt as a,
|
|
280
|
+
bt as b,
|
|
281
|
+
et as c,
|
|
282
|
+
rt as d,
|
|
283
|
+
St as e,
|
|
284
|
+
nt as f,
|
|
285
|
+
mt as g,
|
|
286
|
+
at as h,
|
|
287
|
+
tt as i,
|
|
288
|
+
M as j,
|
|
289
|
+
lt as k,
|
|
290
|
+
P as l,
|
|
291
|
+
Et as m,
|
|
292
|
+
ut as p,
|
|
293
|
+
wt as r,
|
|
294
|
+
gt as s,
|
|
295
|
+
vt as u
|
|
296
|
+
};
|