@bendyline/squisq-react 0.1.3 → 1.0.1
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/BlockRenderer.d.ts +37 -0
- package/dist/BlockRenderer.d.ts.map +1 -0
- package/dist/BlockRenderer.js +51 -0
- package/dist/BlockRenderer.js.map +1 -0
- package/dist/CaptionOverlay.d.ts +24 -0
- package/dist/CaptionOverlay.d.ts.map +1 -0
- package/dist/CaptionOverlay.js +40 -0
- package/dist/CaptionOverlay.js.map +1 -0
- package/dist/DocControlsBottom.d.ts +28 -0
- package/dist/DocControlsBottom.d.ts.map +1 -0
- package/dist/DocControlsBottom.js +23 -0
- package/dist/DocControlsBottom.js.map +1 -0
- package/dist/DocControlsOverlay.d.ts +28 -0
- package/dist/DocControlsOverlay.d.ts.map +1 -0
- package/dist/DocControlsOverlay.js +75 -0
- package/dist/DocControlsOverlay.js.map +1 -0
- package/dist/DocControlsSidebar.d.ts +27 -0
- package/dist/DocControlsSidebar.d.ts.map +1 -0
- package/dist/DocControlsSidebar.js +6 -0
- package/dist/DocControlsSidebar.js.map +1 -0
- package/dist/DocControlsSlideshow.d.ts +20 -0
- package/dist/DocControlsSlideshow.d.ts.map +1 -0
- package/dist/DocControlsSlideshow.js +69 -0
- package/dist/DocControlsSlideshow.js.map +1 -0
- package/dist/DocPlayer.d.ts +87 -0
- package/dist/DocPlayer.d.ts.map +1 -0
- package/dist/DocPlayer.js +604 -0
- package/dist/DocPlayer.js.map +1 -0
- package/dist/DocPlayerWithSidebar.d.ts +41 -0
- package/dist/DocPlayerWithSidebar.d.ts.map +1 -0
- package/dist/DocPlayerWithSidebar.js +68 -0
- package/dist/DocPlayerWithSidebar.js.map +1 -0
- package/dist/DocProgressBar.d.ts +31 -0
- package/dist/DocProgressBar.d.ts.map +1 -0
- package/dist/DocProgressBar.js +122 -0
- package/dist/DocProgressBar.js.map +1 -0
- package/dist/LinearDocView.d.ts +47 -0
- package/dist/LinearDocView.d.ts.map +1 -0
- package/dist/LinearDocView.js +184 -0
- package/dist/LinearDocView.js.map +1 -0
- package/dist/MarkdownRenderer.d.ts +32 -0
- package/dist/MarkdownRenderer.d.ts.map +1 -0
- package/dist/MarkdownRenderer.js +133 -0
- package/dist/MarkdownRenderer.js.map +1 -0
- package/dist/__tests__/BlockRenderer.test.d.ts +2 -0
- package/dist/__tests__/BlockRenderer.test.d.ts.map +1 -0
- package/dist/__tests__/BlockRenderer.test.js +82 -0
- package/dist/__tests__/BlockRenderer.test.js.map +1 -0
- package/dist/__tests__/DocControlsSlideshow.test.d.ts +2 -0
- package/dist/__tests__/DocControlsSlideshow.test.d.ts.map +1 -0
- package/dist/__tests__/DocControlsSlideshow.test.js +88 -0
- package/dist/__tests__/DocControlsSlideshow.test.js.map +1 -0
- package/dist/__tests__/LinearDocView.test.d.ts +2 -0
- package/dist/__tests__/LinearDocView.test.d.ts.map +1 -0
- package/dist/__tests__/LinearDocView.test.js +160 -0
- package/dist/__tests__/LinearDocView.test.js.map +1 -0
- package/dist/__tests__/MarkdownRenderer.test.d.ts +2 -0
- package/dist/__tests__/MarkdownRenderer.test.d.ts.map +1 -0
- package/dist/__tests__/MarkdownRenderer.test.js +208 -0
- package/dist/__tests__/MarkdownRenderer.test.js.map +1 -0
- package/dist/__tests__/exports.test.d.ts +2 -0
- package/dist/__tests__/exports.test.d.ts.map +1 -0
- package/dist/__tests__/exports.test.js +48 -0
- package/dist/__tests__/exports.test.js.map +1 -0
- package/dist/hooks/AudioProvider.d.ts +71 -0
- package/dist/hooks/AudioProvider.d.ts.map +1 -0
- package/dist/hooks/AudioProvider.js +52 -0
- package/dist/hooks/AudioProvider.js.map +1 -0
- package/dist/hooks/MediaContext.d.ts +35 -0
- package/dist/hooks/MediaContext.d.ts.map +1 -0
- package/dist/hooks/MediaContext.js +66 -0
- package/dist/hooks/MediaContext.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAudioSync.d.ts +18 -0
- package/dist/hooks/useAudioSync.d.ts.map +1 -0
- package/dist/hooks/useAudioSync.js +338 -0
- package/dist/hooks/useAudioSync.js.map +1 -0
- package/dist/hooks/useDocPlayback.d.ts +47 -0
- package/dist/hooks/useDocPlayback.d.ts.map +1 -0
- package/dist/hooks/useDocPlayback.js +176 -0
- package/dist/hooks/useDocPlayback.js.map +1 -0
- package/dist/hooks/useViewportOrientation.d.ts +31 -0
- package/dist/hooks/useViewportOrientation.d.ts.map +1 -0
- package/dist/hooks/useViewportOrientation.js +92 -0
- package/dist/hooks/useViewportOrientation.js.map +1 -0
- package/dist/index.d.ts +25 -563
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -3179
- package/dist/index.js.map +1 -1
- package/dist/layers/ImageLayer.d.ts +23 -0
- package/dist/layers/ImageLayer.d.ts.map +1 -0
- package/dist/layers/ImageLayer.js +104 -0
- package/dist/layers/ImageLayer.js.map +1 -0
- package/dist/layers/MapLayer.d.ts +29 -0
- package/dist/layers/MapLayer.d.ts.map +1 -0
- package/dist/layers/MapLayer.js +97 -0
- package/dist/layers/MapLayer.js.map +1 -0
- package/dist/layers/ShapeLayer.d.ts +20 -0
- package/dist/layers/ShapeLayer.d.ts.map +1 -0
- package/dist/layers/ShapeLayer.js +35 -0
- package/dist/layers/ShapeLayer.js.map +1 -0
- package/dist/layers/TextLayer.d.ts +23 -0
- package/dist/layers/TextLayer.d.ts.map +1 -0
- package/dist/layers/TextLayer.js +126 -0
- package/dist/layers/TextLayer.js.map +1 -0
- package/dist/layers/VideoLayer.d.ts +40 -0
- package/dist/layers/VideoLayer.d.ts.map +1 -0
- package/dist/layers/VideoLayer.js +105 -0
- package/dist/layers/VideoLayer.js.map +1 -0
- package/dist/layers/index.d.ts +6 -0
- package/dist/layers/index.d.ts.map +1 -0
- package/dist/layers/index.js +6 -0
- package/dist/layers/index.js.map +1 -0
- package/dist/squisq-player.global.js +1 -1
- package/dist/standalone-entry.d.ts +61 -0
- package/dist/standalone-entry.d.ts.map +1 -0
- package/dist/standalone-entry.js +169 -0
- package/dist/standalone-entry.js.map +1 -0
- package/dist/standalone-source.js +1 -1
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/animationUtils.d.ts +8 -0
- package/dist/utils/animationUtils.d.ts.map +1 -0
- package/dist/utils/animationUtils.js +8 -0
- package/dist/utils/animationUtils.js.map +1 -0
- package/dist/utils/layerUtils.d.ts +17 -0
- package/dist/utils/layerUtils.d.ts.map +1 -0
- package/dist/utils/layerUtils.js +37 -0
- package/dist/utils/layerUtils.js.map +1 -0
- package/dist/utils/mapTileUtils.d.ts +105 -0
- package/dist/utils/mapTileUtils.d.ts.map +1 -0
- package/dist/utils/mapTileUtils.js +268 -0
- package/dist/utils/mapTileUtils.js.map +1 -0
- package/package.json +3 -4
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* VideoLayer Component
|
|
4
|
+
*
|
|
5
|
+
* Renders a video clip layer within an SVG block. Uses an HTML5 <video> element
|
|
6
|
+
* inside a <foreignObject> (same pattern as ImageLayer for cover-mode images).
|
|
7
|
+
* Videos are always muted — narration audio is the only sound track.
|
|
8
|
+
*
|
|
9
|
+
* Two modes of operation:
|
|
10
|
+
* 1. Normal playback: Video auto-plays from clipStart to clipEnd on mount,
|
|
11
|
+
* pausing when the clip ends or when the block is no longer active.
|
|
12
|
+
* 2. Render/seekTo mode (Playwright frame capture): Video is paused and seeked
|
|
13
|
+
* programmatically via data attributes read by DocPlayer's seekTo handler.
|
|
14
|
+
*
|
|
15
|
+
* The <video> element carries data-clip-start and data-clip-end attributes so
|
|
16
|
+
* the seekTo handler can calculate the correct video time for any doc time.
|
|
17
|
+
*
|
|
18
|
+
* Related Files:
|
|
19
|
+
* - schemas/Doc.ts — VideoLayer type definition
|
|
20
|
+
* - shared/doc/templates/videoWithCaption.ts — template producing VideoLayers
|
|
21
|
+
* - site/src/components/doc/DocPlayer.tsx — seekTo handler for video sync
|
|
22
|
+
* - site/src/components/doc/layers/ImageLayer.tsx — similar foreignObject pattern
|
|
23
|
+
*/
|
|
24
|
+
import { useRef, useEffect } from 'react';
|
|
25
|
+
import { useMediaUrl } from '../hooks/MediaContext';
|
|
26
|
+
import { resolveValue, getAnchorOffset } from '../utils/layerUtils';
|
|
27
|
+
export function VideoLayer({ layer, basePath, viewport, blockTime: _blockTime, isPlaying, }) {
|
|
28
|
+
const { content, position } = layer;
|
|
29
|
+
const videoRef = useRef(null);
|
|
30
|
+
const hasStartedRef = useRef(false);
|
|
31
|
+
// Resolve position values to pixels
|
|
32
|
+
const x = resolveValue(position.x, viewport.width);
|
|
33
|
+
const y = resolveValue(position.y, viewport.height);
|
|
34
|
+
const width = position.width ? resolveValue(position.width, viewport.width) : viewport.width;
|
|
35
|
+
const height = position.height ? resolveValue(position.height, viewport.height) : viewport.height;
|
|
36
|
+
// Apply anchor offset
|
|
37
|
+
const offset = getAnchorOffset(position.anchor, width, height);
|
|
38
|
+
const finalX = x + offset.x;
|
|
39
|
+
const finalY = y + offset.y;
|
|
40
|
+
// Resolve video URL via MediaProvider (if available), falling back to basePath
|
|
41
|
+
const src = useMediaUrl(content.src, basePath);
|
|
42
|
+
// Always call the hook (Rules of Hooks), but pass empty string when no poster
|
|
43
|
+
const resolvedPoster = useMediaUrl(content.posterSrc || '', basePath);
|
|
44
|
+
const posterSrc = content.posterSrc ? resolvedPoster : undefined;
|
|
45
|
+
// On mount: seek to clipStart and set up clipEnd boundary.
|
|
46
|
+
// The video will be muted and play silently alongside the narration.
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const video = videoRef.current;
|
|
49
|
+
if (!video)
|
|
50
|
+
return;
|
|
51
|
+
// Set initial time to clipStart
|
|
52
|
+
video.currentTime = content.clipStart;
|
|
53
|
+
hasStartedRef.current = true;
|
|
54
|
+
// Start playing if doc is already playing
|
|
55
|
+
if (isPlaying) {
|
|
56
|
+
const playPromise = video.play();
|
|
57
|
+
if (playPromise) {
|
|
58
|
+
playPromise.catch(() => {
|
|
59
|
+
// Autoplay blocked — fine for Playwright seekTo mode
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Monitor timeupdate to pause at clipEnd
|
|
64
|
+
const handleTimeUpdate = () => {
|
|
65
|
+
if (video.currentTime >= content.clipEnd) {
|
|
66
|
+
video.pause();
|
|
67
|
+
video.currentTime = content.clipEnd;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
video.addEventListener('timeupdate', handleTimeUpdate);
|
|
71
|
+
return () => {
|
|
72
|
+
video.removeEventListener('timeupdate', handleTimeUpdate);
|
|
73
|
+
video.pause();
|
|
74
|
+
};
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- isPlaying is handled by the separate sync effect below
|
|
76
|
+
}, [content.src, content.clipStart, content.clipEnd]);
|
|
77
|
+
// Sync video play/pause with doc playback state
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const video = videoRef.current;
|
|
80
|
+
if (!video || !hasStartedRef.current)
|
|
81
|
+
return;
|
|
82
|
+
// Don't resume if clip has already reached its end
|
|
83
|
+
if (video.currentTime >= content.clipEnd)
|
|
84
|
+
return;
|
|
85
|
+
if (isPlaying) {
|
|
86
|
+
const playPromise = video.play();
|
|
87
|
+
if (playPromise) {
|
|
88
|
+
playPromise.catch(() => { });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
video.pause();
|
|
93
|
+
}
|
|
94
|
+
}, [isPlaying, content.clipEnd]);
|
|
95
|
+
return (_jsx("g", { className: "block-layer block-layer--video", "data-layer-id": layer.id, children: _jsx("foreignObject", { x: finalX, y: finalY, width: width, height: height, children: _jsx("video", { ref: videoRef, src: src, poster: posterSrc, muted: true, playsInline: true, preload: "auto", "data-clip-start": content.clipStart, "data-clip-end": content.clipEnd, style: {
|
|
96
|
+
width: '100%',
|
|
97
|
+
height: '100%',
|
|
98
|
+
objectFit: content.fit || 'cover',
|
|
99
|
+
objectPosition: 'center',
|
|
100
|
+
display: 'block',
|
|
101
|
+
pointerEvents: 'none',
|
|
102
|
+
} }) }) }));
|
|
103
|
+
}
|
|
104
|
+
export default VideoLayer;
|
|
105
|
+
//# sourceMappingURL=VideoLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoLayer.js","sourceRoot":"","sources":["../../src/layers/VideoLayer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAcpE,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EAAE,UAAU,EACrB,SAAS,GACO;IAChB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,oCAAoC;IACpC,MAAM,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CA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wBAAe,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAC/D,gBACE,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,SAAS,EACjB,KAAK,QACL,WAAW,QACX,OAAO,EAAC,MAAM,qBACG,OAAO,CAAC,SAAS,mBACnB,OAAO,CAAC,OAAO,EAC9B,KAAK,EAAE;oBACL,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,MAAM;oBACd,SAAS,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO;oBACjC,cAAc,EAAE,QAAQ;oBACxB,OAAO,EAAE,OAAO;oBAChB,aAAa,EAAE,MAAM;iBACtB,GACD,GACY,GACd,CACL,CAAC;AACJ,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/layers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -2,5 +2,5 @@ var SquisqPlayer=(function(exports){'use strict';var rt,B,hn,ge,pn,gn,yn,bn,St,x
|
|
|
2
2
|
`),h=f?y.reduce((w,A)=>w.concat(ri(A,s.fontSize,f)),[]):y;if(s.maxLines&&h.length>s.maxLines){h=h.slice(0,s.maxLines);let w=h[h.length-1];h[h.length-1]=w.replace(/\s*$/,"")+"...";}let b=s.lineHeight||1.4,v=s.fontSize*b,_={fontSize:`${s.fontSize}px`,fontFamily:s.fontFamily||Nt,fontWeight:s.fontWeight||"normal",fill:s.color,...p.style},S=s.shadow?`shadow-${e.id}`:void 0;return l("g",{className:`block-layer block-layer--text ${p.className}`,"data-layer-id":e.id,children:[s.shadow&&l("defs",{children:l("filter",{id:S,x:"-20%",y:"-20%",width:"140%",height:"140%",children:l("feDropShadow",{dx:"0",dy:"2",stdDeviation:"3",floodColor:"rgba(0,0,0,0.7)"})})}),s.background&&l("rect",{x:u-(s.padding||16),y:c-s.fontSize-(s.padding||16),width:ni(h,s)+(s.padding||16)*2,height:h.length*v+(s.padding||16)*2,fill:s.background,rx:4,ry:4}),l("text",{x:u,y:c,textAnchor:d,dominantBaseline:m,style:_,filter:S?`url(#${S})`:void 0,children:h.map((w,A)=>l("tspan",{x:u,dy:A===0?0:v,children:[w||"\xA0"," "]},A))})]})}function ei(e,t){return e==="center"?"middle":e==="right"?"end":e==="left"?"start":t?.includes("right")?"end":t==="center"?"middle":"start"}function ti(e){return e?.includes("bottom")?"text-after-edge":e==="center"?"middle":"text-before-edge"}function ni(e,t){return Math.max(...e.map(r=>r.length))*t.fontSize*.55}function ri(e,t,n){if(!e.trim())return [""];let r=t*.5,o=Math.floor(n/r);if(o<=0)return [e];let i=e.split(/\s+/),a=[],s="";for(let u of i){let c=s?`${s} ${u}`:u;if(c.length<=o)s=c;else if(s&&a.push(s),u.length>o){let f=u;for(;f.length>o;)a.push(f.slice(0,o)),f=f.slice(o);s=f;}else s=u;}return s&&a.push(s),a.length>0?a:[""]}function Cr({layer:e,viewport:t,blockTime:n}){let{content:r,position:o,animation:i}=e,a=H(o.x,t.width),s=H(o.y,t.height),u=o.width?H(o.width,t.width):100,c=o.height?H(o.height,t.height):100,f=ae(i,n),d=r.fill||"none",m=typeof d=="string"&&d.includes("gradient(");if(r.shape==="rect"&&m)return l("g",{className:`block-layer block-layer--shape ${f.className}`,style:f.style,"data-layer-id":e.id,children:l("foreignObject",{x:a,y:s,width:u,height:c,children:l("div",{style:{width:"100%",height:"100%",background:d,borderRadius:r.borderRadius?`${r.borderRadius}px`:void 0,pointerEvents:"none"}})})});let p={fill:d,stroke:r.stroke,strokeWidth:r.strokeWidth};return l("g",{className:`block-layer block-layer--shape ${f.className}`,style:f.style,"data-layer-id":e.id,children:[r.shape==="rect"&&l("rect",{x:a,y:s,width:u,height:c,rx:r.borderRadius,ry:r.borderRadius,...p}),r.shape==="circle"&&l("circle",{cx:a+u/2,cy:s+c/2,r:Math.min(u,c)/2,...p}),r.shape==="line"&&l("line",{x1:a,y1:s,x2:a+u,y2:s+c,stroke:r.stroke||"#ffffff",strokeWidth:r.strokeWidth||2})]})}var oi={terrain:{url:"https://tile.opentopomap.org/{z}/{x}/{y}.png",attribution:"Map: OpenTopoMap (CC-BY-SA)",maxZoom:17},road:{url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xA9 OpenStreetMap contributors",maxZoom:19},satellite:{url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attribution:"Imagery: Esri, Maxar, Earthstar",maxZoom:18},toner:{url:"https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}.png",attribution:"Map: Stadia Maps, Stamen Design",maxZoom:20},watercolor:{url:"https://tiles.stadiamaps.com/tiles/stamen_watercolor/{z}/{x}/{y}.jpg",attribution:"Map: Stadia Maps, Stamen Design",maxZoom:16}};function Ut(e,t,n){let r=Math.pow(2,n),o=Math.floor((t+180)/360*r),i=e*Math.PI/180,a=Math.floor((1-Math.log(Math.tan(i)+1/Math.cos(i))/Math.PI)/2*r);return {x:o,y:a}}function Yt(e,t,n,r=256){let o=Math.pow(2,n),i=(t+180)/360*o,a=e*Math.PI/180,s=(1-Math.log(Math.tan(a)+1/Math.cos(a))/Math.PI)/2*o;return {x:(i-Math.floor(i))*r,y:(s-Math.floor(s))*r}}function ii(e,t,n,r,o,i=256){let a=Ut(e,t,n),s=Yt(e,t,n,i),u=Math.ceil(r/i)+1,c=Math.ceil(o/i)+1,f=a.x-Math.floor(u/2),d=a.y-Math.floor(c/2),m=r/2-s.x,p=o/2-s.y,y=[];for(let h=0;h<c;h++)for(let b=0;b<u;b++){let v=f+b,_=d+h,S=m+(v-a.x)*i,w=p+(_-a.y)*i;y.push({x:v,y:_,screenX:S,screenY:w});}return y}function ai(e,t,n,r){return e.url.replace("{z}",String(r)).replace("{x}",String(t)).replace("{y}",String(n))}async function si(e){return new Promise((t,n)=>{let r=new Image;r.crossOrigin="anonymous",r.onload=()=>t(r),r.onerror=()=>n(new Error(`Failed to load tile: ${e}`)),r.src=e;})}async function Ar(e){let{center:t,zoom:n,style:r,width:o,height:i,markers:a=[],showAttribution:s=true}=e,u=oi[r],c=u.tileSize||256,f=Math.min(n,u.maxZoom),d=document.createElement("canvas");d.width=o,d.height=i;let m=d.getContext("2d");if(!m)throw new Error("Failed to get canvas context");m.fillStyle=r==="toner"?"#ffffff":"#e5e7eb",m.fillRect(0,0,o,i);let y=ii(t.lat,t.lng,f,o,i,c).map(async h=>{let b=ai(u,h.x,h.y,f);try{let v=await si(b);m.drawImage(v,h.screenX,h.screenY,c,c);}catch(v){console.warn(`Tile load failed: ${b}`,v);}});await Promise.all(y);for(let h of a)li(m,h,t,f,o,i,c);return s&&ui(m,u.attribution,o,i),d.toDataURL("image/png")}function li(e,t,n,r,o,i,a){let s=Ut(n.lat,n.lng,r),u=Ut(t.lat,t.lng,r),c=Yt(n.lat,n.lng,r,a),f=Yt(t.lat,t.lng,r,a),d=(u.x-s.x)*a+(f.x-c.x),m=(u.y-s.y)*a+(f.y-c.y),p=o/2+d,y=i/2+m,h=t.color||"#ef4444",b=t.icon||"pin";e.save(),b==="pin"?(e.fillStyle=h,e.beginPath(),e.arc(p,y-12,8,Math.PI,0,false),e.lineTo(p,y),e.closePath(),e.fill(),e.fillStyle="#ffffff",e.beginPath(),e.arc(p,y-12,3,0,Math.PI*2),e.fill()):b==="circle"?(e.fillStyle=h,e.beginPath(),e.arc(p,y,8,0,Math.PI*2),e.fill(),e.strokeStyle="#ffffff",e.lineWidth=2,e.stroke()):b==="star"&&(e.fillStyle=h,ci(e,p,y,5,10,5),e.fill()),t.label&&(e.fillStyle="#1f2937",e.font="bold 12px system-ui, sans-serif",e.textAlign="center",e.fillText(t.label,p,y+20)),e.restore();}function ci(e,t,n,r,o,i){let a=Math.PI/2*3,s=Math.PI/r;e.beginPath(),e.moveTo(t,n-o);for(let u=0;u<r;u++)e.lineTo(t+Math.cos(a)*o,n+Math.sin(a)*o),a+=s,e.lineTo(t+Math.cos(a)*i,n+Math.sin(a)*i),a+=s;e.lineTo(t,n-o),e.closePath();}function ui(e,t,n,r){e.save(),e.fillStyle="rgba(255, 255, 255, 0.8)";let o=4;e.font="10px system-ui, sans-serif";let i=e.measureText(t).width;e.fillRect(n-i-o*2-4,r-16,i+o*2,14),e.fillStyle="#374151",e.textAlign="right",e.fillText(t,n-o-4,r-5),e.restore();}function Mr({layer:e,basePath:t,viewport:n,blockTime:r}){let{content:o,position:i,animation:a}=e,[s,u]=O(null),[c,f]=O(true),[d,m]=O(null),p=H(i.x,n.width),y=H(i.y,n.height),h=i.width?H(i.width,n.width):n.width,b=i.height?H(i.height,n.height):n.height,v=Be(i.anchor,h,b),_=p+v.x,S=y+v.y;D(()=>{let A=false;if(o.staticSrc){let I=o.staticSrc.startsWith("http")?o.staticSrc:`${t}/${o.staticSrc}`;u(I),f(false);return}return f(true),m(null),Ar({center:o.center,zoom:o.zoom,style:o.style,width:h,height:b,markers:o.markers,showAttribution:o.showAttribution!==false}).then(I=>{A||(u(I),f(false));}).catch(I=>{A||(console.error("Failed to compose map:",I),m(I instanceof Error?I.message:String(I)),f(false));}),()=>{A=true;}},[o.center.lat,o.center.lng,o.zoom,o.style,o.staticSrc,h,b,t]);let w=ae(a,r);return c?l("g",{className:`block-layer block-layer--map ${w.className}`,style:w.style,"data-layer-id":e.id,children:[l("rect",{x:_,y:S,width:h,height:b,fill:"#e5e7eb"}),l("text",{x:_+h/2,y:S+b/2,textAnchor:"middle",dominantBaseline:"middle",fill:"#9ca3af",fontSize:"24",fontFamily:"system-ui, sans-serif",children:"Loading map..."})]}):d||!s?l("g",{className:`block-layer block-layer--map ${w.className}`,style:w.style,"data-layer-id":e.id,children:[l("rect",{x:_,y:S,width:h,height:b,fill:"#fef2f2"}),l("text",{x:_+h/2,y:S+b/2,textAnchor:"middle",dominantBaseline:"middle",fill:"#dc2626",fontSize:"18",fontFamily:"system-ui, sans-serif",children:"Map failed to load"})]}):l("g",{className:`block-layer block-layer--map ${w.className}`,style:w.style,"data-layer-id":e.id,children:[l("defs",{children:l("clipPath",{id:`clip-${e.id}`,children:l("rect",{x:_,y:S,width:h,height:b})})}),l("g",{clipPath:`url(#clip-${e.id})`,children:l("image",{href:s,x:_,y:S,width:h,height:b,preserveAspectRatio:"xMidYMid slice",style:{pointerEvents:"none"}})})]})}function Lr({layer:e,basePath:t,viewport:n,blockTime:r,isPlaying:o}){let{content:i,position:a}=e,s=q(null),u=q(false),c=H(a.x,n.width),f=H(a.y,n.height),d=a.width?H(a.width,n.width):n.width,m=a.height?H(a.height,n.height):n.height,p=Be(a.anchor,d,m),y=c+p.x,h=f+p.y,b=Ue(i.src,t),v=Ue(i.posterSrc||"",t),_=i.posterSrc?v:void 0;return D(()=>{let S=s.current;if(!S)return;if(S.currentTime=i.clipStart,u.current=true,o){let A=S.play();A&&A.catch(()=>{});}let w=()=>{S.currentTime>=i.clipEnd&&(S.pause(),S.currentTime=i.clipEnd);};return S.addEventListener("timeupdate",w),()=>{S.removeEventListener("timeupdate",w),S.pause();}},[i.src,i.clipStart,i.clipEnd]),D(()=>{let S=s.current;if(!(!S||!u.current)&&!(S.currentTime>=i.clipEnd))if(o){let w=S.play();w&&w.catch(()=>{});}else S.pause();},[o,i.clipEnd]),l("g",{className:"block-layer block-layer--video","data-layer-id":e.id,children:l("foreignObject",{x:y,y:h,width:d,height:m,children:l("video",{ref:s,src:b,poster:_,muted:true,playsInline:true,preload:"auto","data-clip-start":i.clipStart,"data-clip-end":i.clipEnd,style:{width:"100%",height:"100%",objectFit:i.fit||"cover",objectPosition:"center",display:"block",pointerEvents:"none"}})})})}var di={width:1920,height:1080};function Ee({block:e,blockTime:t,basePath:n,isEntering:r=false,isExiting:o=false,viewport:i=di,isPlaying:a}){let s="",u={};e.transition&&r?(s=Ve(e.transition.type,true),u["--transition-duration"]=`${e.transition.duration}s`):e.transition&&o&&(s=Ve(e.transition.type,false),u["--transition-duration"]=`${e.transition.duration}s`);let c=`vb-clip-${e.id}`;return l("svg",{className:`block-svg ${s}`,style:u,viewBox:`0 0 ${i.width} ${i.height}`,preserveAspectRatio:"xMidYMid meet",overflow:"hidden","data-block-id":e.id,children:[l("defs",{children:l("clipPath",{id:c,children:l("rect",{x:"0",y:"0",width:i.width,height:i.height})})}),l("g",{clipPath:`url(#${c})`,children:(e.layers??[]).map(f=>l(pi,{layer:f,basePath:n,viewport:i,blockTime:t,isPlaying:a},f.id))})]})}function pi({layer:e,basePath:t,viewport:n,blockTime:r,isPlaying:o}){switch(e.type){case "image":return l(Sr,{layer:e,basePath:t,viewport:n,blockTime:r});case "text":return l(Tr,{layer:e,viewport:n,blockTime:r});case "shape":return l(Cr,{layer:e,viewport:n,blockTime:r});case "map":return l(Mr,{layer:e,basePath:t,viewport:n,blockTime:r});case "video":return l(Lr,{layer:e,basePath:t,viewport:n,blockTime:r,isPlaying:o});default:return console.warn(`Unknown layer type: ${e.type}`),null}}function Pr({captions:e,currentTime:t,enabled:n=true,fontSize:r=16}){let i=(n&&e?qe(e,t):null)?.text??null;return l("div",{className:"caption-overlay",style:{position:"absolute",top:"6px",left:"50%",transform:"translateX(-50%)",zIndex:50,pointerEvents:"none",maxWidth:"100%",width:"100%",textAlign:"center",opacity:i?1:0,transition:"opacity 0.15s ease-in-out",padding:"0 4px",boxSizing:"border-box"},children:i&&l("div",{style:{display:"inline-block",padding:"3px 10px",background:"rgba(0, 0, 0, 0.65)",borderRadius:"4px",backdropFilter:"blur(4px)"},children:l("span",{style:{color:"#ffffff",fontSize:`${r}px`,fontFamily:"'Hanken Grotesk', system-ui, sans-serif",fontWeight:500,lineHeight:1.25,textShadow:"0 1px 3px rgba(0,0,0,0.5)",whiteSpace:"pre-wrap",wordWrap:"break-word"},children:i})})})}function Br(e,t,n=""){let[r,o]=O(0),[i,a]=O(false),[s,u]=O(0),[c,f]=O(false),[d,m]=O(false),[p,y]=O(0),h=q([]),b=q(null),v=q(false),_=q(new Map),S=q(new Map),w=q(false);D(()=>{if(!t?.segments)return;let k=0;h.current=t.segments.map(g=>{let x=k;return k+=g.duration,x}),y(k);},[t]);let A=j(async k=>{let g=n?`${n}/${k}`:k;if(_.current.has(k))return _.current.get(k);if(S.current.has(k))return S.current.get(k);let x=(async()=>{try{let C=await fetch(g);if(!C.ok)throw new Error(`HTTP ${C.status}`);let R=await C.blob(),M=URL.createObjectURL(R);return _.current.set(k,M),M}catch{return g}finally{S.current.delete(k);}})();return S.current.set(k,x),x},[n]);D(()=>{if(!t?.segments)return;t.segments.forEach(g=>{A(g.src);});let k=_.current;return ()=>{k.forEach(g=>{URL.revokeObjectURL(g);}),k.clear();}},[t,A]),D(()=>{let k=e.current;if(!k)return;let g=()=>{let Y=(h.current[s]||0)+k.currentTime;o(Y);},x=()=>{w.current=false,a(true);},C=()=>a(false),R=()=>{m(true);},M=()=>{t&&s<t.segments.length-1?(v.current=true,u(E=>E+1)):(f(true),a(false));};return k.addEventListener("timeupdate",g),k.addEventListener("play",x),k.addEventListener("pause",C),k.addEventListener("ended",M),k.addEventListener("error",R),()=>{k.removeEventListener("timeupdate",g),k.removeEventListener("play",x),k.removeEventListener("pause",C),k.removeEventListener("ended",M),k.removeEventListener("error",R);}},[e,s,t]),D(()=>{let k=e.current;if(!k||!t?.segments)return;let g=t.segments[s];if(!g)return;let x=()=>{if(b.current!==null){let E=h.current[s]||0,Y=b.current-E;k.currentTime=Math.max(0,Y),o(b.current),b.current=null;}v.current&&(k.play().catch(()=>{}),v.current=false);},C=k.src,R=_.current.get(g.src);C&&(C===R||C.endsWith(g.src))?x():(async()=>{let Y=await A(g.src),K=()=>{m(true),x(),k.removeEventListener("canplay",K);};k.addEventListener("canplay",K),k.src=Y,k.load(),await Promise.resolve(),k.readyState>=3&&(k.removeEventListener("canplay",K),m(true),x());})();},[e,s,t,A]);let I=j(()=>{let k=e.current;k&&(c&&(u(0),f(false)),k.play().then(()=>{w.current=false;}).catch(()=>{w.current=true,a(true);}));},[e,c]),$=j(()=>{let k=e.current;k&&k.pause(),a(false);},[e]),N=j(()=>{e.current&&(i?$():I());},[e,i,I,$]),W=j(k=>{let g=e.current;if(!g||!t?.segments)return;let x=Math.max(0,Math.min(k,p)),C=0,R=0;for(let E=0;E<t.segments.length;E++){let Y=R+t.segments[E].duration;if(x<Y){C=E;break}R=Y,E===t.segments.length-1&&(C=E);}let M=!g.paused;if(f(false),C!==s)b.current=x,v.current=M,u(C);else {let E=x-R;g.currentTime=Math.max(0,E),o(x);}},[e,t,s,p]),U=j(k=>{!t?.segments||k<0||k>=t.segments.length||(u(k),f(false));},[t]),se=j(async()=>{W(0),await new Promise(k=>setTimeout(k,50)),I();},[W,I]);return D(()=>{if(!i||!w.current||!p)return;let k=performance.now(),g,x=C=>{if(!w.current)return;let R=(C-k)/1e3;k=C,o(M=>{let E=M+R;return E>=p?(w.current=false,f(true),a(false),p):E}),g=requestAnimationFrame(x);};return g=requestAnimationFrame(x),()=>cancelAnimationFrame(g)},[i,p]),{currentTime:r,isPlaying:i,currentSegment:s,totalDuration:p,isEnded:c,isReady:d,isAvailable:true,play:async()=>I(),pause:async()=>$(),toggle:async()=>N(),seekTo:async k=>W(k),skipToSegment:async k=>U(k),restart:se}}function Er(e,t,n=J.landscape,r=false,o){let [i,a]=O({entering:false,exiting:false,previousBlock:null}),s=F(()=>{if(!e?.blocks)return [];if(e.blocks.some(ne)){let I=e.audio?.segments?.map(N=>({startTime:N.startTime,duration:N.duration}));return Ot(e.blocks,{audioSegments:I,viewport:n,persistentLayers:e.persistentLayers,theme:o})}return e.blocks},[e?.blocks,e?.audio?.segments,e?.persistentLayers,n,o]),u=F(()=>It(s,t),[s,t]),c=F(()=>u?s.indexOf(u):-1,[s,u]),f=F(()=>u?Math.max(0,t-u.startTime):0,[u,t]),d=F(()=>!u||u.duration===0?0:Math.min(1,f/u.duration),[u,f]),m=F(()=>!e||e.duration===0?0:Math.min(1,t/e.duration),[e,t]);F(()=>u,[c]);D(()=>{if(!(!u||r)&&i.previousBlock?.id!==u.id){let I=u.transition?.duration||0;if(I>0){a({entering:true,exiting:true,previousBlock:i.previousBlock});let $=setTimeout(()=>{a({entering:false,exiting:false,previousBlock:u});},I*1e3);return ()=>clearTimeout($)}else a({entering:false,exiting:false,previousBlock:u});}},[u?.id,r]);let y=q(null);D(()=>{if(!(!r||!u)&&i.previousBlock?.id!==u.id){let A=i.previousBlock;y.current=A,a(I=>({...I,previousBlock:u}));}},[u?.id,r]);let h=u?.transition?.duration||0,b=r&&h>0&&f<h,v=b&&y.current!==null,_=j(A=>{if(!e||A<0||A>=s.length)return;let I=s[A];if(I)return I.startTime},[e,s]),S=j(()=>{if(c<s.length-1)return _(c+1)},[c,s.length,_]),w=j(()=>{if(c>0)return _(c-1)},[c,_]);return {currentBlock:u,currentBlockIndex:c,previousBlock:r?v?y.current:null:i.exiting?i.previousBlock:null,isEntering:r?b:i.entering,isExiting:r?v:i.exiting,blockTime:f,blockProgress:d,docProgress:m,nextBlock:S,prevBlock:w,goToBlock:_,blocks:s}}function fi(e,t){let n=e/t;return n>1.2?"landscape":n<.83?"portrait":"landscape"}function mi(e){switch(e){case "portrait":return J.portrait;case "square":return J.square;default:return J.landscape}}function Ir(){let[e,t]=O(()=>({width:typeof window<"u"?window.innerWidth:1920,height:typeof window<"u"?window.innerHeight:1080}));D(()=>{if(typeof window>"u")return;let o=()=>{t({width:window.innerWidth,height:window.innerHeight});},i,a=()=>{clearTimeout(i),i=setTimeout(o,100);};return window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),clearTimeout(i);}},[]);let n=F(()=>fi(e.width,e.height),[e.width,e.height]);return {viewport:F(()=>mi(n),[n]),orientation:n,windowSize:e}}function Ye(e){let t=Math.floor(e/60),n=Math.floor(e%60);return `${t}:${n.toString().padStart(2,"0")}`}function dt({state:e,actions:t,blockMarkers:n,expandedBlocks:r,getBlockTitle:o}){let i=q(null),[a,s]=O(null),u=j(d=>{let m=i.current;if(!m)return;let p=m.getBoundingClientRect(),y=d.clientX-p.left,h=Math.max(0,Math.min(1,y/p.width));s(h);},[]),c=j(()=>{s(null);},[]),f=j(d=>{for(let m=r.length-1;m>=0;m--){let p=r[m];if(d>=p.startTime)return {block:p,index:m}}return r.length>0?{block:r[0],index:0}:null},[r]);return l("div",{ref:i,style:{flex:1,height:"24px",cursor:"pointer",position:"relative",display:"flex",alignItems:"center"},onClick:d=>{let m=d.currentTarget.getBoundingClientRect(),y=(d.clientX-m.left)/m.width;t.seekTo(y*e.totalDuration);},onMouseMove:u,onMouseLeave:c,children:[l("div",{style:{position:"absolute",left:0,right:0,height:"6px",background:"rgba(255,255,255,0.2)",borderRadius:"3px"}}),l("div",{style:{position:"absolute",left:0,width:`${e.docProgress*100}%`,height:"6px",background:"#3d5a80",borderRadius:"3px",transition:"width 0.1s"}}),n.map((d,m)=>l("div",{style:{position:"absolute",left:`${d.position}%`,transform:"translateX(-50%)",width:"10px",height:"10px",borderRadius:"50%",background:d.index===e.currentBlockIndex?"#ffffff":"rgba(255,255,255,0.5)",border:"2px solid #3d5a80",cursor:"pointer",zIndex:2,transition:"transform 0.15s, background 0.15s"},title:d.title,onClick:p=>{p.stopPropagation(),t.seekTo(d.block.startTime);},onMouseEnter:p=>{p.currentTarget.style.transform="translateX(-50%) scale(1.3)";},onMouseLeave:p=>{p.currentTarget.style.transform="translateX(-50%)";}},`${d.block.id}-${m}`)),a!==null&&l("div",{style:{position:"absolute",left:`${a*100}%`,bottom:"100%",transform:"translateX(-50%)",marginBottom:"8px",padding:"6px 10px",background:"rgba(0,0,0,0.9)",borderRadius:"4px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:10},children:[l("div",{style:{color:"white",fontSize:"12px",fontFamily:"monospace"},children:Ye(a*e.totalDuration)}),(()=>{let d=a*e.totalDuration,m=f(d);return m&&o?l("div",{style:{color:"rgba(255,255,255,0.7)",fontSize:"11px",marginTop:"2px"},children:o(m.block)}):null})()]}),a!==null&&l("div",{style:{position:"absolute",left:`${a*100}%`,top:"50%",transform:"translate(-50%, -50%)",width:"2px",height:"16px",background:"rgba(255,255,255,0.6)",pointerEvents:"none",zIndex:1}})]})}function Rr({state:e,actions:t,blockMarkers:n,expandedBlocks:r,getBlockTitle:o}){return l("div",{className:"doc-player__controls",style:{position:"absolute",bottom:0,left:0,right:0,padding:"12px 16px",background:"linear-gradient(transparent, rgba(0,0,0,0.8))",display:"flex",alignItems:"center",gap:"8px",zIndex:100},children:[l("button",{onClick:t.restart,style:{background:"none",border:"none",color:"rgba(255,255,255,0.7)",cursor:"pointer",padding:"8px",fontSize:"14px",display:"flex",alignItems:"center"},title:"Restart","aria-label":"Restart from beginning",children:l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"})})}),l("button",{onClick:t.toggle,style:{background:"rgba(255,255,255,0.2)",border:"none",borderRadius:"50%",color:"white",cursor:"pointer",padding:"10px",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"40px"},"aria-label":e.isPlaying?"Pause":"Play",children:e.isPlaying?l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}):l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l("path",{d:"M8 5v14l11-7z"})})}),l("span",{style:{color:"white",fontSize:"12px",minWidth:"80px",fontFamily:"monospace"},children:[Ye(e.currentTime)," / ",Ye(e.totalDuration)]}),l(dt,{state:e,actions:t,blockMarkers:n,expandedBlocks:r,getBlockTitle:o}),l("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:"11px",whiteSpace:"nowrap"},children:[e.currentBlockIndex+1,"/",e.totalBlocks]}),e.hasCaptions&&l("button",{onClick:()=>t.setCaptionsEnabled(!e.captionsEnabled),style:{background:e.captionsEnabled?"rgba(255,255,255,0.2)":"none",border:"none",color:e.captionsEnabled?"white":"rgba(255,255,255,0.5)",cursor:"pointer",padding:"8px",fontSize:"12px",display:"flex",alignItems:"center",borderRadius:"4px"},title:e.captionsEnabled?"Hide captions":"Show captions","aria-label":e.captionsEnabled?"Hide captions":"Show captions",children:l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M19 4H5a2 2 0 00-2 2v12a2 2 0 002 2h14a2 2 0 002-2V6a2 2 0 00-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-4a1 1 0 011-1h3a1 1 0 011 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1a1 1 0 01-1 1h-3a1 1 0 01-1-1v-4a1 1 0 011-1h3a1 1 0 011 1v1z"})})}),t.toggleFullscreen&&l("button",{onClick:t.toggleFullscreen,style:{background:e.isFullscreen?"rgba(255,255,255,0.2)":"none",border:"none",color:e.isFullscreen?"white":"rgba(255,255,255,0.5)",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",borderRadius:"4px"},title:e.isFullscreen?"Exit fullscreen (F)":"Fullscreen (F)","aria-label":e.isFullscreen?"Exit fullscreen":"Enter fullscreen",children:e.isFullscreen?l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}):l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})})})]})}function $r({state:e,slideNav:t}){let{currentBlockIndex:n,totalBlocks:r}=e,o=n<=0,i=n>=r-1;return l("div",{className:"doc-controls-slideshow","data-testid":"slideshow-controls",style:{position:"absolute",bottom:"16px",right:"16px",display:"flex",alignItems:"center",gap:"2px",background:"rgba(0, 0, 0, 0.65)",borderRadius:"8px",padding:"4px 6px",zIndex:100,userSelect:"none",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[l("button",{onClick:a=>{a.stopPropagation(),t.prevSlide();},disabled:o,"data-testid":"slide-prev","aria-label":"Previous slide",title:"Previous slide",style:{background:"none",border:"none",color:o?"rgba(255,255,255,0.3)":"rgba(255,255,255,0.9)",cursor:o?"default":"pointer",padding:"6px 8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background 0.15s"},onMouseEnter:a=>{o||(a.currentTarget.style.background="rgba(255,255,255,0.1)");},onMouseLeave:a=>{a.currentTarget.style.background="none";},children:l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),l("span",{"data-testid":"slide-counter",style:{color:"rgba(255,255,255,0.9)",fontSize:"13px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontVariantNumeric:"tabular-nums",minWidth:"48px",textAlign:"center",padding:"0 4px",letterSpacing:"0.02em"},children:r>0?`${n+1} / ${r}`:"\u2014"}),l("button",{onClick:a=>{a.stopPropagation(),t.nextSlide();},disabled:i,"data-testid":"slide-next","aria-label":"Next slide",title:"Next slide",style:{background:"none",border:"none",color:i?"rgba(255,255,255,0.3)":"rgba(255,255,255,0.9)",cursor:i?"default":"pointer",padding:"6px 8px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",transition:"background 0.15s"},onMouseEnter:a=>{i||(a.currentTarget.style.background="rgba(255,255,255,0.1)");},onMouseLeave:a=>{a.currentTarget.style.background="none";},children:l("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})})]})}function re(e,t=""){return e.map((n,r)=>{let o=`${t}i${r}`;switch(n.type){case "text":return l(te,{children:n.value},o);case "emphasis":return l("em",{className:"squisq-md-em",children:re(n.children,o)},o);case "strong":return l("strong",{className:"squisq-md-strong",children:re(n.children,o)},o);case "delete":return l("del",{className:"squisq-md-del",children:re(n.children,o)},o);case "inlineCode":return l("code",{className:"squisq-md-inline-code",children:n.value},o);case "link":return l("a",{className:"squisq-md-link",href:n.url,title:n.title??void 0,target:"_blank",rel:"noopener noreferrer",children:re(n.children,o)},o);case "image":return l("img",{className:"squisq-md-image",src:n.url,alt:n.alt??"",title:n.title??void 0},o);case "break":return l("br",{},o);case "inlineMath":return l("code",{className:"squisq-md-inline-math",children:n.value},o);case "htmlInline":return l("span",{className:"squisq-md-html-inline",dangerouslySetInnerHTML:{__html:n.rawHtml}},o);case "footnoteReference":return l("sup",{className:"squisq-md-footnote-ref",children:l("a",{href:`#fn-${n.identifier}`,children:["[",n.label??n.identifier,"]"]})},o);case "linkReference":return l("span",{className:"squisq-md-link-ref",children:re(n.children,o)},o);case "imageReference":return l("span",{className:"squisq-md-image-ref",children:["[",n.alt??n.identifier,"]"]},o);case "textDirective":return l("span",{className:"squisq-md-text-directive","data-directive":n.name,children:re(n.children,o)},o);default:return null}})}function gi(e,t){switch(e.type){case "paragraph":return l("p",{className:"squisq-md-p",children:re(e.children,t)},t);case "heading":{let n=`h${e.depth}`;return l(n,{className:`squisq-md-heading squisq-md-h${e.depth}`,children:re(e.children,t)},t)}case "blockquote":return l("blockquote",{className:"squisq-md-blockquote",children:Ie(e.children,t)},t);case "list":return e.ordered?l("ol",{className:"squisq-md-list squisq-md-ol",start:e.start??void 0,children:e.children.map((n,r)=>Nr(n,`${t}li${r}`))},t):l("ul",{className:"squisq-md-list squisq-md-ul",children:e.children.map((n,r)=>Nr(n,`${t}li${r}`))},t);case "code":return l("pre",{className:"squisq-md-code-block",children:l("code",{className:e.lang?`language-${e.lang}`:void 0,children:e.value})},t);case "thematicBreak":return l("hr",{className:"squisq-md-hr"},t);case "table":return yi(e.children,e.align,t);case "htmlBlock":return l("div",{className:"squisq-md-html-block",dangerouslySetInnerHTML:{__html:e.rawHtml}},t);case "math":return l("pre",{className:"squisq-md-math-block",children:l("code",{children:e.value})},t);case "definition":return null;case "footnoteDefinition":return l("div",{className:"squisq-md-footnote-def",id:`fn-${e.identifier}`,children:[l("sup",{children:e.label??e.identifier}),Ie(e.children,t)]},t);case "containerDirective":return l("div",{className:`squisq-md-directive squisq-md-directive-${e.name}`,"data-directive":e.name,children:[e.label&&l("div",{className:"squisq-md-directive-label",children:e.label}),Ie(e.children,t)]},t);case "leafDirective":return l("div",{className:`squisq-md-directive squisq-md-directive-${e.name}`,"data-directive":e.name,children:re(e.children,t)},t);case "definitionList":return l("dl",{className:"squisq-md-dl",children:e.children.map((n,r)=>n.type==="definitionTerm"?l("dt",{className:"squisq-md-dt",children:re(n.children,`${t}dt${r}`)},`${t}dt${r}`):l("dd",{className:"squisq-md-dd",children:Ie(n.children,`${t}dd${r}`)},`${t}dd${r}`))},t);default:return null}}function Nr(e,t){let n=e.checked!==null&&e.checked!==void 0;return l("li",{className:`squisq-md-li${n?" squisq-md-task":""}`,children:[n&&l("input",{type:"checkbox",checked:!!e.checked,readOnly:true,className:"squisq-md-checkbox"}),Ie(e.children,t)]},t)}function yi(e,t,n){let[r,...o]=e;return l("table",{className:"squisq-md-table",children:[r&&l("thead",{children:l("tr",{children:r.children.map((i,a)=>l("th",{className:"squisq-md-th",style:t?.[a]?{textAlign:t[a]}:void 0,children:re(i.children,`${n}th${a}`)},`${n}th${a}`))})}),o.length>0&&l("tbody",{children:o.map((i,a)=>l("tr",{children:i.children.map((s,u)=>l("td",{className:"squisq-md-td",style:t?.[u]?{textAlign:t[u]}:void 0,children:re(s.children,`${n}td${a}-${u}`)},`${n}td${a}-${u}`))},`${n}tr${a}`))})]},n)}function Ie(e,t=""){return e.map((n,r)=>gi(n,`${t}b${r}`))}function pt({nodes:e,className:t}){return !e||e.length===0?null:l("div",{className:`squisq-md ${t||""}`,children:Ie(e)})}function bi(e){let t=e.sourceHeading?.templateAnnotation;return t?Ht(t.template):false}function Dr(e){let t=0;for(let n of e)t++,n.children&&(t+=Dr(n.children));return t}function Fr({block:e,basePath:t,viewport:n,renderContext:r,blockIndex:o}){let i=bi(e),a=F(()=>{if(!i)return null;let s=e.sourceHeading.templateAnnotation,u=xe(e.sourceHeading),c=_i(e.contents),f={id:e.id,template:s.template,startTime:0,duration:1,audioSegment:0,title:u,...vi(s.template,u,c,e.contents),...s.params,...e.templateOverrides},d={...r,blockIndex:o},m=Wt(f,d);return {...e,layers:m,template:s.template}},[e,i,r,o]);return l("div",{className:"squisq-linear-section","data-block-id":e.id,"data-template":i?e.sourceHeading?.templateAnnotation?.template:void 0,children:[e.sourceHeading&&!i&&l(pt,{nodes:[e.sourceHeading]}),i&&a&&l("div",{className:"squisq-linear-card",children:[e.sourceHeading&&l("div",{className:"squisq-linear-card-label squisq-md",children:l(pt,{nodes:[e.sourceHeading]})}),l("div",{className:"squisq-linear-card-svg",style:{width:"100%",aspectRatio:`${n.width} / ${n.height}`,overflow:"hidden",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.12)",marginBottom:"1em"},children:l(Ee,{block:a,blockTime:0,basePath:t,viewport:n})})]}),!i&&e.contents&&e.contents.length>0&&l(pt,{nodes:e.contents}),e.children&&e.children.length>0&&l("div",{className:"squisq-linear-children",children:e.children.map((s,u)=>l(Fr,{block:s,basePath:t,viewport:n,renderContext:r,blockIndex:o+u+1},s.id))})]})}function _i(e){return !e||e.length===0?"":e.map(t=>xe(t)).join(`
|
|
3
3
|
`).trim()}function xi(e){if(!e)return [];let t=[];for(let n of e)if(n.type==="list")for(let r of n.children){let o=xe(r).trim();o&&t.push(o);}return t}function vi(e,t,n,r){switch(e){case "statHighlight":return {stat:t,description:n||t};case "quoteBlock":case "fullBleedQuote":case "pullQuote":return {quote:n||t};case "factCard":return {fact:t,explanation:n||t};case "comparisonBar":return {leftLabel:"A",leftValue:60,rightLabel:"B",rightValue:40};case "listBlock":return {items:xi(r)||["Item 1","Item 2","Item 3"]};case "definitionCard":return {term:t,definition:n||t};case "dateEvent":return {date:t,description:n||t};default:return {}}}function ft({doc:e,basePath:t="/",viewport:n,className:r,theme:o}){let i=n??J.landscape,a=F(()=>Dr(e.blocks),[e.blocks]),s=F(()=>({theme:o??fe,viewport:i,totalBlocks:a}),[i,a,o]);return l("div",{className:`squisq-linear ${r||""}`,style:{width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden"},children:l("div",{className:"squisq-linear-content",style:{maxWidth:"720px",margin:"0 auto",padding:"24px 16px",lineHeight:1.7,fontSize:"16px",color:"var(--squisq-text, #1f2937)"},children:e.blocks.map((u,c)=>l(Fr,{block:u,basePath:t,viewport:i,renderContext:s,blockIndex:c},u.id))})})}var ki=new Set(["a","an","the","and","but","or","for","nor","on","at","to","in","of","by","is"]);function zr(e){let t=new Map;for(let n of e.blocks)if(ne(n)&&n.template==="sectionHeader"&&"title"in n){let r=n.audioSegment;t.has(r)||t.set(r,n.title);}for(let n=0;n<e.audio.segments.length;n++)if(!t.has(n)){let r=e.audio.segments[n].name;if(r==="intro"||r.includes("intro"))t.set(n,"Introduction");else if(r==="flight-context"||r.includes("flight-context"))t.set(n,"Flight Context");else {let i=r.split("-").map((a,s)=>s===0||!ki.has(a)?a.charAt(0).toUpperCase()+a.slice(1):a).join(" ");t.set(n,i);}}return t}function qr({script:e,basePath:t,renderMode:n=false,autoPlay:r=false,onEnded:o,onTimeUpdate:i,audioProvider:a,showControls:s=true,showScrubber:u=false,muted:c=false,captionsEnabled:f,onCaptionsToggle:d,onPlaybackStateChange:m,onControlsReady:p,isFullscreen:y=false,onFullscreenToggle:h,onBlockMarkers:b,forceViewport:v,displayMode:_="video",theme:S}){let w=_==="slideshow",A=_==="linear",I=q(null),$=q(null),[N,W]=O(null),U=q(),{viewport:se,orientation:k}=Ir(),g=v||(n?J.landscape:se),x=F(()=>typeof window>"u"?false:new URLSearchParams(window.location.search).get("debug")==="true",[]),C=Br(I,e.audio,t),R=a||C,{currentTime:M,isPlaying:E,currentSegment:Y,totalDuration:K,isEnded:jt,isReady:Xt,isAvailable:Wr,unavailableMessage:Zt,play:je,pause:we,toggle:Se,seekTo:oe,skipToSegment:Li,restart:Gt}=R,ht=q(M);ht.current=M;let Qt=q(K);Qt.current=K;let Kt=q(0),Vr=j(T=>{if(n||w||A||T.target.closest("button, a, input, .doc-player__controls, .doc-player__scrubber, .doc-controls-sidebar, .doc-controls-slideshow"))return;Se(),W(E?"play":"pause"),clearTimeout(U.current),U.current=setTimeout(()=>W(null),600);},[n,Se,E,w,A]),{currentBlock:_e,currentBlockIndex:me,previousBlock:Jt,isEntering:Ur,isExiting:Yr,blockTime:gt,docProgress:en,blocks:X}=Er(e,M,g,n,S),he=F(()=>{let T=e.startBlock;if(!T)return null;let L=pe(S??fe,0,1,g);return {id:"cover-block",startTime:-1,duration:0,audioSegment:-1,layers:qt(T,L)}},[e.startBlock,g,S]),[jr,tn]=O(false),[Xr,nn]=O(false),rn=q(),yt=q(false);he&&!E&&M===0&&!n&&!r&&(yt.current=true),D(()=>{if(E&&yt.current&&he&&!n)return yt.current=false,nn(true),rn.current=setTimeout(()=>nn(false),3e3),()=>clearTimeout(rn.current)},[E,he,n]);let Xe=!w&&!A&&he&&(jr||Xr||!E&&M===0&&!n&&!r),on=q(false);D(()=>{Xt&&r&&!on.current&&(on.current=true,je());},[Xt,r,je]),D(()=>{i?.(M);},[M,i]),D(()=>{jt&&o?.();},[jt,o]),D(()=>{if((n||x)&&typeof window<"u"){let T=window;T.seekTo=L=>(oe(L),new Promise(z=>{requestAnimationFrame(()=>{let Q=0;for(let ce=X.length-1;ce>=0;ce--)if(L>=X[ce].startTime){Q=X[ce].startTime;break}let ln=(L-Q)*1e3;document.getAnimations().forEach(ce=>{let Ne=ce.effect?.target;Ne&&(Ne.closest(".doc-player__block--active")||Ne.closest(".doc-player__block--previous"))&&(ce.currentTime=Math.max(0,ln));});let Zr=L-Q,cn=[],un=document.querySelector(".doc-player__block--active");un&&un.querySelectorAll("video[data-clip-start]").forEach(Ne=>{let Ae=Ne,Gr=parseFloat(Ae.dataset.clipStart||"0"),Qr=parseFloat(Ae.dataset.clipEnd||"0"),dn=Math.min(Gr+Math.max(0,Zr),Qr);Ae.pause(),Ae.currentTime=dn,cn.push(new Promise(_t=>{Math.abs(Ae.currentTime-dn)<.1?_t():(Ae.addEventListener("seeked",()=>_t(),{once:true}),setTimeout(_t,200));}));}),Promise.all(cn).then(()=>{requestAnimationFrame(()=>z());});});})),T.getDuration=()=>K,T.getBlocks=()=>X.map(L=>({id:L.id,template:L.template??"raw",startTime:L.startTime,duration:L.duration})),T.getAudioSegments=()=>e.audio.segments.map(L=>({src:L.src,name:L.name,duration:L.duration,startTime:L.startTime})),T.getCaptions=()=>e.captions?.phrases?.map(L=>({text:L.text,startTime:L.startTime,endTime:L.endTime}))||[],T.getChapters=()=>{let L=zr(e);return e.audio.segments.map((z,Q)=>({title:L.get(Q)||z.name,startTime:z.startTime,duration:z.duration}))},T.showCover=()=>(tn(true),new Promise(L=>requestAnimationFrame(()=>L()))),T.hideCover=()=>(tn(false),new Promise(L=>requestAnimationFrame(()=>L()))),T.hasCoverBlock=()=>!!he;}return ()=>{if(typeof window<"u"){let T=window;delete T.seekTo,delete T.getDuration,delete T.getBlocks,delete T.getAudioSegments,delete T.getCaptions,delete T.getChapters,delete T.showCover,delete T.hideCover,delete T.hasCoverBlock;}}},[n,x,oe,K,X,he]);let Te=f!==void 0?f:true,an=j(T=>{d?.(T);},[d]),Ze=e.captions&&e.captions.phrases.length>0,sn=F(()=>zr(e),[e]),Re=F(()=>({isPlaying:E,currentTime:M,totalDuration:K,currentBlockIndex:me,totalBlocks:X.length,docProgress:en,hasCaptions:!!Ze,captionsEnabled:Te,isFullscreen:y,currentSegmentIndex:Y,currentSegmentName:sn.get(Y)??e.audio.segments[Y]?.name??null,currentBlock:_e??null}),[E,M,K,me,X.length,en,Ze,Te,y,Y,sn,_e]),Ge=F(()=>({toggle:Se,restart:Gt,seekTo:oe,setCaptionsEnabled:an,toggleFullscreen:h}),[Se,Gt,oe,an,h]),Ce=F(()=>({nextSlide:()=>{if(me<X.length-1){let T=X[me+1];T&&(oe(T.startTime),we());}},prevSlide:()=>{if(me>0){let T=X[me-1];T&&(oe(T.startTime),we());}},goToSlide:T=>{if(T>=0&&T<X.length){let L=X[T];L&&(oe(L.startTime),we());}}}),[me,X,oe,we]);D(()=>{m?.(Re);},[Re,m]),D(()=>{p?.({play:je,pause:we,...Ge});},[je,we,Ge,p]);let Qe=j(T=>{let L=T;if(ne(L)){let z=L;if(typeof z.title=="string")return z.title;if(typeof z.stat=="string")return z.stat;if(typeof z.quote=="string"){let Q=z.quote.split(`
|
|
4
4
|
`)[0];return Q.length<=30?Q:Q.slice(0,27)+"..."}if(typeof z.date=="string")return z.date;if(typeof z.fact=="string")return z.fact}if(T.layers&&Array.isArray(T.layers)){let z=T.layers.find(Q=>Q.type==="text");if(z?.content?.text){let Q=z.content.text.split(`
|
|
5
|
-
`)[0];return Q.length<=30?Q:Q.slice(0,27)+"..."}}return T.id.replace(/-/g," ").replace(/\b\w/g,z=>z.toUpperCase())},[]),$e=F(()=>{if(!K||!X.length)return [];let T=-1;return X.map((L,z)=>{let Q=L.audioSegment!==T;return T=L.audioSegment,{block:L,index:z,position:L.startTime/K*100,title:Qe(L),isSectionStart:Q}})},[X,K,Qe]);D(()=>{$e.length>0&&b?.($e);},[$e,b]),Kt.current=X.length;let bt=j(T=>{let L=document.activeElement;if(!(L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"||L.tagName==="SELECT"))&&!A)if(w)switch(T.key){case "ArrowRight":case "ArrowDown":case " ":T.preventDefault(),Ce.nextSlide();break;case "ArrowLeft":case "ArrowUp":T.preventDefault(),Ce.prevSlide();break;case "Home":T.preventDefault(),Ce.goToSlide(0);break;case "End":T.preventDefault(),Ce.goToSlide(Kt.current-1);break}else switch(T.key){case " ":T.preventDefault(),Se();break;case "ArrowRight":oe(Math.min(ht.current+10,Qt.current));break;case "ArrowLeft":oe(Math.max(ht.current-10,0));break}},[w,A,Se,oe,Ce]);return D(()=>{if(!n)return window.addEventListener("keydown",bt),()=>window.removeEventListener("keydown",bt)},[bt,n]),A?l("div",{ref:$,className:"doc-player doc-player--linear",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:l(ft,{doc:e,basePath:t,viewport:g})}):l("div",{ref:$,className:"doc-player",onClick:Vr,style:{position:"relative",width:"100%",aspectRatio:`${g.width} / ${g.height}`,margin:"0 auto",overflow:"hidden",cursor:n?void 0:"pointer"},children:[l("audio",{ref:I,preload:"auto",muted:c}),l("div",{className:"doc-player__viewport",children:[Xe&&he&&l("div",{className:"doc-player__block doc-player__block--cover",children:l(Ee,{block:he,blockTime:0,basePath:t,isEntering:false,viewport:g})}),!Xe&&Jt&&Yr&&l("div",{className:"doc-player__block doc-player__block--previous",children:l(Ee,{block:Jt,blockTime:gt,basePath:t,isExiting:true,viewport:g})}),!Xe&&_e&&l("div",{className:"doc-player__block doc-player__block--active",children:l(Ee,{block:_e,blockTime:gt,basePath:t,isEntering:Ur,viewport:g,isPlaying:E})}),Ze&&!n&&l(Pr,{captions:e.captions,currentTime:M,enabled:Te&&(E||M>0),fontSize:16}),x&&l("div",{className:"doc-player__debug",style:{position:"absolute",top:"8px",right:"8px",padding:"8px 12px",background:"rgba(0, 0, 0, 0.85)",borderRadius:"6px",color:"#00ff00",fontFamily:"monospace",fontSize:"11px",lineHeight:"1.5",zIndex:200,maxWidth:"280px",pointerEvents:"none",textAlign:"left"},children:[l("div",{style:{color:"#ffcc00",fontWeight:"bold",marginBottom:"4px"},children:"DEBUG MODE"}),l("div",{children:[l("span",{style:{color:"#888"},children:"template:"})," ",l("span",{style:{color:"#ff6b6b"},children:_e?.template??"raw"})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"block:"})," ",me+1,"/",X.length," ",l("span",{style:{color:"#666"},children:["(",_e?.id||"none",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"time:"})," ",M.toFixed(2),"s /"," ",K.toFixed(1),"s"]}),l("div",{children:[l("span",{style:{color:"#888"},children:"blockTime:"})," ",gt.toFixed(2),"s /"," ",(_e?.duration||0).toFixed(1),"s"]}),l("div",{children:[l("span",{style:{color:"#888"},children:"segment:"})," ",Y,"/",e.audio.segments.length-1," ",l("span",{style:{color:"#666"},children:["(",e.audio.segments[Y]?.name||"none",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"viewport:"})," ",g.name||`${g.width}x${g.height}`," ",l("span",{style:{color:"#666"},children:["(",k,")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"playing:"})," ",l("span",{style:{color:E?"#4ade80":"#f87171"},children:E?"yes":"no"}),Xe&&l("span",{style:{color:"#60a5fa"},children:" (cover)"})]}),Ze&&(()=>{let T=qe(e.captions,M),L=Te&&(E||M>0);return l(te,{children:[l("div",{children:[l("span",{style:{color:"#888"},children:"captions:"})," ",e.captions?.phrases.length||0," phrases"," ",l("span",{style:{color:Te?"#4ade80":"#666"},children:["(",Te?"on":"off",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"cc.enabled:"})," ",l("span",{style:{color:L?"#4ade80":"#f87171"},children:String(L)})," ",l("span",{style:{color:"#666"},children:["(playing=",String(E)," t>0=",String(M>0),")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"cc.phrase:"})," ",l("span",{style:{color:T?"#4ade80":"#f87171"},children:T?`"${T.text.slice(0,30)}..."`:"null"})]}),T&&l("div",{children:[l("span",{style:{color:"#888"},children:"cc.range:"})," ",l("span",{style:{color:"#60a5fa"},children:[T.startTime.toFixed(2),"-",T.endTime.toFixed(2)]})]})]})})()]})]}),!Wr&&Zt&&l("div",{className:"doc-player__unavailable",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:"16px",background:"rgba(0, 0, 0, 0.7)",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",zIndex:50},children:[l("span",{style:{fontSize:"32px"},children:"\u{1F50A}"}),l("span",{children:Zt})]}),!n&&!w&&s&&l(Rr,{state:Re,actions:Ge,blockMarkers:$e,expandedBlocks:X,getBlockTitle:Qe}),!n&&!w&&!s&&u&&l("div",{className:"doc-player__scrubber",style:{position:"absolute",bottom:0,left:0,right:0,padding:"12px 16px 8px",background:"linear-gradient(transparent, rgba(0,0,0,0.6))",display:"flex",alignItems:"center",zIndex:100},children:l(dt,{state:Re,actions:Ge,blockMarkers:$e,expandedBlocks:X,getBlockTitle:Qe})}),!n&&w&&l($r,{state:Re,slideNav:Ce}),!w&&N&&l("div",{className:"doc-player__tap-feedback",children:l("svg",{viewBox:"0 0 24 24",fill:"white",width:"48",height:"48",children:N==="pause"?l("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"}):l("path",{d:"M8 5v14l11-7z"})})},Date.now())]})}var Or={};var Hr=false;function Si(){if(Hr||typeof document>"u")return;let e=document.createElement("style");e.setAttribute("data-squisq-player","animations"),e.textContent=Or,document.head.appendChild(e),Hr=true;}function Ti(e,t){return {async resolveUrl(n){return n in e?e[n]:n.startsWith("http")||n.startsWith("data:")||n.startsWith("blob:")?n:`${t}/${n}`},async listMedia(){return Object.keys(e).map(n=>({name:n,mimeType:Ci(n),size:0}))},async addMedia(){throw new Error("Standalone player is read-only")},async removeMedia(){throw new Error("Standalone player is read-only")},dispose(){}}}function Ci(e){let t=e.split(".").pop()?.toLowerCase()??"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",webm:"video/webm"}[t]??"application/octet-stream"}function Ai(e,t){if(!e.audio?.segments?.length)return e;let n=e.audio.segments.map(r=>{let o=t[r.name]??t[r.src]??r.src;return {...r,src:o}});return {...e,audio:{...e.audio,segments:n}}}var mt=new WeakMap;function Mi(e,t,n={}){Si();let{mode:r="slideshow",basePath:o=".",images:i,audio:a,autoPlay:s=false,theme:u}=n,c=a?Ai(t,a):t,f=i?Ti(i,o):null,d;r==="static"?d=de(ft,{doc:c,basePath:o,theme:u}):d=de(qr,{script:c,basePath:o,displayMode:"slideshow",autoPlay:s,showControls:true,theme:u}),f&&(d=de(Vt.Provider,{value:f},d));let m=mt.get(e);m||(m=Jn(e),mt.set(e,m)),m.render(d);}function Dl(e,t,n={}){Mi(e,t,{...n,mode:"static"});}function Fl(e){let t=mt.get(e);t&&(t.unmount(),mt.delete(e));}var zl="0.
|
|
5
|
+
`)[0];return Q.length<=30?Q:Q.slice(0,27)+"..."}}return T.id.replace(/-/g," ").replace(/\b\w/g,z=>z.toUpperCase())},[]),$e=F(()=>{if(!K||!X.length)return [];let T=-1;return X.map((L,z)=>{let Q=L.audioSegment!==T;return T=L.audioSegment,{block:L,index:z,position:L.startTime/K*100,title:Qe(L),isSectionStart:Q}})},[X,K,Qe]);D(()=>{$e.length>0&&b?.($e);},[$e,b]),Kt.current=X.length;let bt=j(T=>{let L=document.activeElement;if(!(L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"||L.tagName==="SELECT"))&&!A)if(w)switch(T.key){case "ArrowRight":case "ArrowDown":case " ":T.preventDefault(),Ce.nextSlide();break;case "ArrowLeft":case "ArrowUp":T.preventDefault(),Ce.prevSlide();break;case "Home":T.preventDefault(),Ce.goToSlide(0);break;case "End":T.preventDefault(),Ce.goToSlide(Kt.current-1);break}else switch(T.key){case " ":T.preventDefault(),Se();break;case "ArrowRight":oe(Math.min(ht.current+10,Qt.current));break;case "ArrowLeft":oe(Math.max(ht.current-10,0));break}},[w,A,Se,oe,Ce]);return D(()=>{if(!n)return window.addEventListener("keydown",bt),()=>window.removeEventListener("keydown",bt)},[bt,n]),A?l("div",{ref:$,className:"doc-player doc-player--linear",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:l(ft,{doc:e,basePath:t,viewport:g})}):l("div",{ref:$,className:"doc-player",onClick:Vr,style:{position:"relative",width:"100%",aspectRatio:`${g.width} / ${g.height}`,margin:"0 auto",overflow:"hidden",cursor:n?void 0:"pointer"},children:[l("audio",{ref:I,preload:"auto",muted:c}),l("div",{className:"doc-player__viewport",children:[Xe&&he&&l("div",{className:"doc-player__block doc-player__block--cover",children:l(Ee,{block:he,blockTime:0,basePath:t,isEntering:false,viewport:g})}),!Xe&&Jt&&Yr&&l("div",{className:"doc-player__block doc-player__block--previous",children:l(Ee,{block:Jt,blockTime:gt,basePath:t,isExiting:true,viewport:g})}),!Xe&&_e&&l("div",{className:"doc-player__block doc-player__block--active",children:l(Ee,{block:_e,blockTime:gt,basePath:t,isEntering:Ur,viewport:g,isPlaying:E})}),Ze&&!n&&l(Pr,{captions:e.captions,currentTime:M,enabled:Te&&(E||M>0),fontSize:16}),x&&l("div",{className:"doc-player__debug",style:{position:"absolute",top:"8px",right:"8px",padding:"8px 12px",background:"rgba(0, 0, 0, 0.85)",borderRadius:"6px",color:"#00ff00",fontFamily:"monospace",fontSize:"11px",lineHeight:"1.5",zIndex:200,maxWidth:"280px",pointerEvents:"none",textAlign:"left"},children:[l("div",{style:{color:"#ffcc00",fontWeight:"bold",marginBottom:"4px"},children:"DEBUG MODE"}),l("div",{children:[l("span",{style:{color:"#888"},children:"template:"})," ",l("span",{style:{color:"#ff6b6b"},children:_e?.template??"raw"})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"block:"})," ",me+1,"/",X.length," ",l("span",{style:{color:"#666"},children:["(",_e?.id||"none",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"time:"})," ",M.toFixed(2),"s /"," ",K.toFixed(1),"s"]}),l("div",{children:[l("span",{style:{color:"#888"},children:"blockTime:"})," ",gt.toFixed(2),"s /"," ",(_e?.duration||0).toFixed(1),"s"]}),l("div",{children:[l("span",{style:{color:"#888"},children:"segment:"})," ",Y,"/",e.audio.segments.length-1," ",l("span",{style:{color:"#666"},children:["(",e.audio.segments[Y]?.name||"none",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"viewport:"})," ",g.name||`${g.width}x${g.height}`," ",l("span",{style:{color:"#666"},children:["(",k,")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"playing:"})," ",l("span",{style:{color:E?"#4ade80":"#f87171"},children:E?"yes":"no"}),Xe&&l("span",{style:{color:"#60a5fa"},children:" (cover)"})]}),Ze&&(()=>{let T=qe(e.captions,M),L=Te&&(E||M>0);return l(te,{children:[l("div",{children:[l("span",{style:{color:"#888"},children:"captions:"})," ",e.captions?.phrases.length||0," phrases"," ",l("span",{style:{color:Te?"#4ade80":"#666"},children:["(",Te?"on":"off",")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"cc.enabled:"})," ",l("span",{style:{color:L?"#4ade80":"#f87171"},children:String(L)})," ",l("span",{style:{color:"#666"},children:["(playing=",String(E)," t>0=",String(M>0),")"]})]}),l("div",{children:[l("span",{style:{color:"#888"},children:"cc.phrase:"})," ",l("span",{style:{color:T?"#4ade80":"#f87171"},children:T?`"${T.text.slice(0,30)}..."`:"null"})]}),T&&l("div",{children:[l("span",{style:{color:"#888"},children:"cc.range:"})," ",l("span",{style:{color:"#60a5fa"},children:[T.startTime.toFixed(2),"-",T.endTime.toFixed(2)]})]})]})})()]})]}),!Wr&&Zt&&l("div",{className:"doc-player__unavailable",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:"16px",background:"rgba(0, 0, 0, 0.7)",color:"rgba(255, 255, 255, 0.9)",fontSize:"14px",zIndex:50},children:[l("span",{style:{fontSize:"32px"},children:"\u{1F50A}"}),l("span",{children:Zt})]}),!n&&!w&&s&&l(Rr,{state:Re,actions:Ge,blockMarkers:$e,expandedBlocks:X,getBlockTitle:Qe}),!n&&!w&&!s&&u&&l("div",{className:"doc-player__scrubber",style:{position:"absolute",bottom:0,left:0,right:0,padding:"12px 16px 8px",background:"linear-gradient(transparent, rgba(0,0,0,0.6))",display:"flex",alignItems:"center",zIndex:100},children:l(dt,{state:Re,actions:Ge,blockMarkers:$e,expandedBlocks:X,getBlockTitle:Qe})}),!n&&w&&l($r,{state:Re,slideNav:Ce}),!w&&N&&l("div",{className:"doc-player__tap-feedback",children:l("svg",{viewBox:"0 0 24 24",fill:"white",width:"48",height:"48",children:N==="pause"?l("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"}):l("path",{d:"M8 5v14l11-7z"})})},Date.now())]})}var Or={};var Hr=false;function Si(){if(Hr||typeof document>"u")return;let e=document.createElement("style");e.setAttribute("data-squisq-player","animations"),e.textContent=Or,document.head.appendChild(e),Hr=true;}function Ti(e,t){return {async resolveUrl(n){return n in e?e[n]:n.startsWith("http")||n.startsWith("data:")||n.startsWith("blob:")?n:`${t}/${n}`},async listMedia(){return Object.keys(e).map(n=>({name:n,mimeType:Ci(n),size:0}))},async addMedia(){throw new Error("Standalone player is read-only")},async removeMedia(){throw new Error("Standalone player is read-only")},dispose(){}}}function Ci(e){let t=e.split(".").pop()?.toLowerCase()??"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",webm:"video/webm"}[t]??"application/octet-stream"}function Ai(e,t){if(!e.audio?.segments?.length)return e;let n=e.audio.segments.map(r=>{let o=t[r.name]??t[r.src]??r.src;return {...r,src:o}});return {...e,audio:{...e.audio,segments:n}}}var mt=new WeakMap;function Mi(e,t,n={}){Si();let{mode:r="slideshow",basePath:o=".",images:i,audio:a,autoPlay:s=false,theme:u}=n,c=a?Ai(t,a):t,f=i?Ti(i,o):null,d;r==="static"?d=de(ft,{doc:c,basePath:o,theme:u}):d=de(qr,{script:c,basePath:o,displayMode:"slideshow",autoPlay:s,showControls:true,theme:u}),f&&(d=de(Vt.Provider,{value:f},d));let m=mt.get(e);m||(m=Jn(e),mt.set(e,m)),m.render(d);}function Dl(e,t,n={}){Mi(e,t,{...n,mode:"static"});}function Fl(e){let t=mt.get(e);t&&(t.unmount(),mt.delete(e));}var zl="1.0.0";exports.mount=Mi;exports.mountStatic=Dl;exports.unmount=Fl;exports.version=zl;return exports;})({});//# sourceMappingURL=squisq-player.global.js.map
|
|
6
6
|
//# sourceMappingURL=squisq-player.global.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone Entry Point — IIFE bundle for self-contained HTML rendering.
|
|
3
|
+
*
|
|
4
|
+
* This file is the entry point for the standalone `squisq-player.iife.js` bundle.
|
|
5
|
+
* It bundles Preact (via preact/compat), squisq core, and all rendering components
|
|
6
|
+
* into a single self-contained script that can be loaded in any HTML page.
|
|
7
|
+
*
|
|
8
|
+
* The bundle exposes a global `SquisqPlayer` object with methods to mount
|
|
9
|
+
* interactive or static document views into any DOM element.
|
|
10
|
+
*
|
|
11
|
+
* Usage (in HTML):
|
|
12
|
+
* <script src="squisq-player.iife.js"></script>
|
|
13
|
+
* <div id="root"></div>
|
|
14
|
+
* <script>
|
|
15
|
+
* SquisqPlayer.mount(document.getElementById('root'), docJson, {
|
|
16
|
+
* mode: 'slideshow',
|
|
17
|
+
* images: { 'hero.jpg': 'data:image/jpeg;base64,...' }
|
|
18
|
+
* });
|
|
19
|
+
* </script>
|
|
20
|
+
*/
|
|
21
|
+
import type { Doc } from '@bendyline/squisq/schemas';
|
|
22
|
+
import type { Theme } from '@bendyline/squisq/schemas';
|
|
23
|
+
export interface MountOptions {
|
|
24
|
+
/** Rendering mode: 'slideshow' (interactive, default) or 'static' (scrollable) */
|
|
25
|
+
mode?: 'slideshow' | 'static';
|
|
26
|
+
/** Base path for resolving relative media URLs */
|
|
27
|
+
basePath?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Map of relative image paths to data URIs or blob URLs.
|
|
30
|
+
* Used in single-HTML exports where images are inlined as base64.
|
|
31
|
+
* Example: { 'hero.jpg': 'data:image/jpeg;base64,...' }
|
|
32
|
+
*/
|
|
33
|
+
images?: Record<string, string>;
|
|
34
|
+
/**
|
|
35
|
+
* Map of audio segment names/paths to URLs (data URIs, blob URLs, or relative paths).
|
|
36
|
+
* Used in ZIP exports where audio files are included alongside the HTML.
|
|
37
|
+
*/
|
|
38
|
+
audio?: Record<string, string>;
|
|
39
|
+
/** Optional theme override */
|
|
40
|
+
theme?: Theme;
|
|
41
|
+
/** Auto-play on mount (only for slideshow mode, default: false) */
|
|
42
|
+
autoPlay?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mount a SquisqPlayer into a DOM element.
|
|
46
|
+
*
|
|
47
|
+
* @param element - The DOM element to render into
|
|
48
|
+
* @param doc - A Doc object (parsed JSON)
|
|
49
|
+
* @param options - Rendering options
|
|
50
|
+
*/
|
|
51
|
+
export declare function mount(element: Element, doc: Doc, options?: MountOptions): void;
|
|
52
|
+
/**
|
|
53
|
+
* Mount a static scrollable document view (alias for mount with mode='static').
|
|
54
|
+
*/
|
|
55
|
+
export declare function mountStatic(element: Element, doc: Doc, options?: Omit<MountOptions, 'mode'>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Unmount a previously mounted SquisqPlayer from an element.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unmount(element: Element): void;
|
|
60
|
+
export declare const version: string;
|
|
61
|
+
//# sourceMappingURL=standalone-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone-entry.d.ts","sourceRoot":"","sources":["../src/standalone-entry.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAiB,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAWvD,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgGD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,YAAiB,GAAG,IAAI,CA0ClF;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAM,GACvC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAM9C;AAID,eAAO,MAAM,OAAO,EAAE,MACoD,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone Entry Point — IIFE bundle for self-contained HTML rendering.
|
|
3
|
+
*
|
|
4
|
+
* This file is the entry point for the standalone `squisq-player.iife.js` bundle.
|
|
5
|
+
* It bundles Preact (via preact/compat), squisq core, and all rendering components
|
|
6
|
+
* into a single self-contained script that can be loaded in any HTML page.
|
|
7
|
+
*
|
|
8
|
+
* The bundle exposes a global `SquisqPlayer` object with methods to mount
|
|
9
|
+
* interactive or static document views into any DOM element.
|
|
10
|
+
*
|
|
11
|
+
* Usage (in HTML):
|
|
12
|
+
* <script src="squisq-player.iife.js"></script>
|
|
13
|
+
* <div id="root"></div>
|
|
14
|
+
* <script>
|
|
15
|
+
* SquisqPlayer.mount(document.getElementById('root'), docJson, {
|
|
16
|
+
* mode: 'slideshow',
|
|
17
|
+
* images: { 'hero.jpg': 'data:image/jpeg;base64,...' }
|
|
18
|
+
* });
|
|
19
|
+
* </script>
|
|
20
|
+
*/
|
|
21
|
+
import { createElement } from 'react';
|
|
22
|
+
import { createRoot } from 'react-dom/client';
|
|
23
|
+
import { DocPlayer } from './DocPlayer';
|
|
24
|
+
import { LinearDocView } from './LinearDocView';
|
|
25
|
+
import { MediaContext } from './hooks/MediaContext';
|
|
26
|
+
// CSS is loaded as text via esbuild's text loader (configured in tsup.standalone.config.ts)
|
|
27
|
+
// @ts-expect-error — .css import returns a string when esbuild uses 'text' loader (standalone build only)
|
|
28
|
+
import animationCss from './styles/doc-animations.css';
|
|
29
|
+
// ── CSS Injection ──────────────────────────────────────────────────
|
|
30
|
+
let cssInjected = false;
|
|
31
|
+
function injectCss() {
|
|
32
|
+
if (cssInjected || typeof document === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
const style = document.createElement('style');
|
|
35
|
+
style.setAttribute('data-squisq-player', 'animations');
|
|
36
|
+
style.textContent = animationCss;
|
|
37
|
+
document.head.appendChild(style);
|
|
38
|
+
cssInjected = true;
|
|
39
|
+
}
|
|
40
|
+
// ── Inline Media Provider ──────────────────────────────────────────
|
|
41
|
+
/**
|
|
42
|
+
* Creates a MediaProvider that resolves URLs from an inline image map.
|
|
43
|
+
* Falls back to basePath-based resolution for unknown paths.
|
|
44
|
+
*/
|
|
45
|
+
function createInlineMediaProvider(images, basePath) {
|
|
46
|
+
return {
|
|
47
|
+
async resolveUrl(relativePath) {
|
|
48
|
+
if (relativePath in images)
|
|
49
|
+
return images[relativePath];
|
|
50
|
+
// Fallback to basePath
|
|
51
|
+
if (relativePath.startsWith('http') ||
|
|
52
|
+
relativePath.startsWith('data:') ||
|
|
53
|
+
relativePath.startsWith('blob:')) {
|
|
54
|
+
return relativePath;
|
|
55
|
+
}
|
|
56
|
+
return `${basePath}/${relativePath}`;
|
|
57
|
+
},
|
|
58
|
+
async listMedia() {
|
|
59
|
+
return Object.keys(images).map((name) => ({
|
|
60
|
+
name,
|
|
61
|
+
mimeType: inferMimeType(name),
|
|
62
|
+
size: 0,
|
|
63
|
+
}));
|
|
64
|
+
},
|
|
65
|
+
async addMedia() {
|
|
66
|
+
throw new Error('Standalone player is read-only');
|
|
67
|
+
},
|
|
68
|
+
async removeMedia() {
|
|
69
|
+
throw new Error('Standalone player is read-only');
|
|
70
|
+
},
|
|
71
|
+
dispose() {
|
|
72
|
+
// no-op
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function inferMimeType(filename) {
|
|
77
|
+
const ext = filename.split('.').pop()?.toLowerCase() ?? '';
|
|
78
|
+
const map = {
|
|
79
|
+
jpg: 'image/jpeg',
|
|
80
|
+
jpeg: 'image/jpeg',
|
|
81
|
+
png: 'image/png',
|
|
82
|
+
gif: 'image/gif',
|
|
83
|
+
webp: 'image/webp',
|
|
84
|
+
svg: 'image/svg+xml',
|
|
85
|
+
mp3: 'audio/mpeg',
|
|
86
|
+
mp4: 'video/mp4',
|
|
87
|
+
webm: 'video/webm',
|
|
88
|
+
};
|
|
89
|
+
return map[ext] ?? 'application/octet-stream';
|
|
90
|
+
}
|
|
91
|
+
// ── Audio Rewriting ────────────────────────────────────────────────
|
|
92
|
+
/**
|
|
93
|
+
* Rewrite audio segment URLs in a Doc if an audio map is provided.
|
|
94
|
+
* Returns a shallow-modified copy — does not mutate the original.
|
|
95
|
+
*/
|
|
96
|
+
function rewriteAudioUrls(doc, audioMap) {
|
|
97
|
+
if (!doc.audio?.segments?.length)
|
|
98
|
+
return doc;
|
|
99
|
+
const segments = doc.audio.segments.map((seg) => {
|
|
100
|
+
const resolved = audioMap[seg.name] ?? audioMap[seg.src] ?? seg.src;
|
|
101
|
+
return { ...seg, src: resolved };
|
|
102
|
+
});
|
|
103
|
+
return { ...doc, audio: { ...doc.audio, segments } };
|
|
104
|
+
}
|
|
105
|
+
// ── Root Tracking ──────────────────────────────────────────────────
|
|
106
|
+
const roots = new WeakMap();
|
|
107
|
+
// ── Public API ─────────────────────────────────────────────────────
|
|
108
|
+
/**
|
|
109
|
+
* Mount a SquisqPlayer into a DOM element.
|
|
110
|
+
*
|
|
111
|
+
* @param element - The DOM element to render into
|
|
112
|
+
* @param doc - A Doc object (parsed JSON)
|
|
113
|
+
* @param options - Rendering options
|
|
114
|
+
*/
|
|
115
|
+
export function mount(element, doc, options = {}) {
|
|
116
|
+
injectCss();
|
|
117
|
+
const { mode = 'slideshow', basePath = '.', images, audio, autoPlay = false, theme } = options;
|
|
118
|
+
// Rewrite audio URLs if map provided
|
|
119
|
+
const finalDoc = audio ? rewriteAudioUrls(doc, audio) : doc;
|
|
120
|
+
// Build the media provider if images are provided
|
|
121
|
+
const mediaProvider = images ? createInlineMediaProvider(images, basePath) : null;
|
|
122
|
+
let content;
|
|
123
|
+
if (mode === 'static') {
|
|
124
|
+
content = createElement(LinearDocView, {
|
|
125
|
+
doc: finalDoc,
|
|
126
|
+
basePath,
|
|
127
|
+
theme,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
content = createElement(DocPlayer, {
|
|
132
|
+
script: finalDoc,
|
|
133
|
+
basePath,
|
|
134
|
+
displayMode: 'slideshow',
|
|
135
|
+
autoPlay,
|
|
136
|
+
showControls: true,
|
|
137
|
+
theme,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// Wrap in MediaContext if provider is available
|
|
141
|
+
if (mediaProvider) {
|
|
142
|
+
content = createElement(MediaContext.Provider, { value: mediaProvider }, content);
|
|
143
|
+
}
|
|
144
|
+
// Create or reuse React root
|
|
145
|
+
let root = roots.get(element);
|
|
146
|
+
if (!root) {
|
|
147
|
+
root = createRoot(element);
|
|
148
|
+
roots.set(element, root);
|
|
149
|
+
}
|
|
150
|
+
root.render(content);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Mount a static scrollable document view (alias for mount with mode='static').
|
|
154
|
+
*/
|
|
155
|
+
export function mountStatic(element, doc, options = {}) {
|
|
156
|
+
mount(element, doc, { ...options, mode: 'static' });
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Unmount a previously mounted SquisqPlayer from an element.
|
|
160
|
+
*/
|
|
161
|
+
export function unmount(element) {
|
|
162
|
+
const root = roots.get(element);
|
|
163
|
+
if (root) {
|
|
164
|
+
root.unmount();
|
|
165
|
+
roots.delete(element);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
export const version = typeof __SQUISQ_VERSION__ !== 'undefined' ? __SQUISQ_VERSION__ : '0.0.0';
|
|
169
|
+
//# sourceMappingURL=standalone-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone-entry.js","sourceRoot":"","sources":["../src/standalone-entry.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM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