slidetake 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.html +363 -40
- package/dist/slidetake.js +241 -49
- package/package.json +1 -1
package/dist/slidetake.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* Slidetake 0.
|
|
2
|
-
"use strict";(()=>{var
|
|
1
|
+
/* Slidetake 0.5.0 · https://slidetake.com · Apache-2.0 */
|
|
2
|
+
"use strict";(()=>{var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var wo,_r=G(()=>{wo=`---
|
|
3
3
|
title: Slidetake \u2014 write in markdown with AI, record without timeline editing
|
|
4
4
|
description: "Write a deck in markdown, with AI, present it on a spatial canvas, and record it slide by slide: retake any slide, pick the best take, download the video. Open source."
|
|
5
5
|
brand: slidetake
|
|
@@ -206,7 +206,7 @@ Your headings are the hierarchy: \`#\` is the first card, \`##\` branches from i
|
|
|
206
206
|
|
|
207
207
|
<!-- camera: on, full, on -->
|
|
208
208
|
|
|
209
|
-
A comment in a slide moves you: corner, full screen, or
|
|
209
|
+
A comment in a slide moves you: corner, full screen, beside the words, or a split screen. Turn on **Camera** and watch this slide do it.
|
|
210
210
|
|
|
211
211
|
### Your colours
|
|
212
212
|
|
|
@@ -365,7 +365,7 @@ Images next to the markdown load as they are. Save in any editor and the deck re
|
|
|
365
365
|
Open source, Apache 2.0: [github.com/slidetake/slidetake](https://github.com/slidetake/slidetake). Nothing to sign up for, and your decks stay yours: [Privacy](/privacy).
|
|
366
366
|
|
|
367
367
|
Next, every feature and what it saves you: **[Features \u2192](/features)**
|
|
368
|
-
`});var
|
|
368
|
+
`});var qr,Ur=G(()=>{qr=`---
|
|
369
369
|
title: Slidetake Docs
|
|
370
370
|
description: "How to use Slidetake, step by step: get started, write a deck, present it, record a video in the browser or with OBS, and share it."
|
|
371
371
|
brand: slidetake
|
|
@@ -510,6 +510,7 @@ title: My talk \u2190 page and video title
|
|
|
510
510
|
duration: 10m \u2190 for the timer
|
|
511
511
|
accent: "#3b82f6" \u2190 the deck's colour
|
|
512
512
|
mode: light \u2190 open in light mode
|
|
513
|
+
format: portrait \u2190 a 9:16 deck, for Shorts and Reels
|
|
513
514
|
brand: example.com \u2190 top-right corner text
|
|
514
515
|
brand_style: chip \u2190 the brand as a pill
|
|
515
516
|
logo: https://\u2026/l.png \u2190 image beside it
|
|
@@ -629,7 +630,7 @@ Two modes, both slide by slide, so there's no timeline to edit afterwards. **\u2
|
|
|
629
630
|
|
|
630
631
|
### Easy mode: record in the browser
|
|
631
632
|
|
|
632
|
-
1. **\u25CF Record** (R) the first time opens **\u2699 Setup**: pick your camera (or **No camera**) and microphone. Recording turns the camera on and off by itself.
|
|
633
|
+
1. **\u25CF Record** (R) the first time opens **\u2699 Setup**: pick your camera (or **No camera**, and **Mirror** if you want it flipped; off, it shows you as others see you) and microphone. Recording turns the camera on and off by itself.
|
|
633
634
|
2. **\u25CF Record** again, and share **this tab** when the browser asks. Only the 16:9 frame is recorded: slides and camera.
|
|
634
635
|
3. Next time, **\u25CF Record** carries on with the slides that have no take yet. When every slide has one, it records from the slide on screen to the end.
|
|
635
636
|
|
|
@@ -679,14 +680,14 @@ A dummy HDMI plug works on any system.
|
|
|
679
680
|
|
|
680
681
|
### Add your camera
|
|
681
682
|
|
|
682
|
-
**C** (or **Camera**) turns your webcam on in its box while presenting. A recording doesn't depend on it: it turns on the camera chosen for the deck (or none) by itself.
|
|
683
|
+
**C** (or **Camera**) turns your webcam on in its box while presenting. A recording doesn't depend on it: it turns on the camera chosen for the deck (or none) by itself. It stays as you left it when the page reloads. While it's off, the deck's camera settings are ignored, so readers get slides using the whole screen, except a slide with the camera behind it, which shows its layout over an empty frame.
|
|
683
684
|
|
|
684
685
|
\`\`\`yaml
|
|
685
686
|
---
|
|
686
687
|
pip: bottom-right \u2190 corner, or none
|
|
687
688
|
pip_size: 24% \u2190 box width
|
|
688
689
|
pip_shape: rect \u2190 or circle
|
|
689
|
-
pip_mirror: yes \u2190 mirror the webcam
|
|
690
|
+
pip_mirror: yes \u2190 mirror the webcam (until you choose in Setup)
|
|
690
691
|
camera: 24%, full, off \u2190 what V cycles
|
|
691
692
|
---
|
|
692
693
|
\`\`\`
|
|
@@ -705,10 +706,33 @@ A comment in a slide changes the camera from that slide on:
|
|
|
705
706
|
<!-- camera: 18% flip --> \u2190 small, other side
|
|
706
707
|
\`\`\`
|
|
707
708
|
|
|
708
|
-
Words you can combine: \`on\`, \`off\`, \`full\`, \`behind\` (
|
|
709
|
+
Words you can combine: \`on\`, \`off\`, \`full\`, \`behind\` (next), a size like \`30%\`, a corner, \`flip\`, \`circle\` / \`rect\`, \`mirror\` / \`unmirror\`. List them with commas to step through them on one slide: \`full, on\` opens on you, and the next \u2192 shrinks the camera to its corner and shows the slide.
|
|
709
710
|
|
|
710
711
|
**V** steps through the deck's \`camera:\` list by hand.
|
|
711
712
|
|
|
713
|
+
### Talk beside your slides
|
|
714
|
+
|
|
715
|
+
\`behind\` fills the frame with you and puts the slide's words beside you, on a half see-through card:
|
|
716
|
+
|
|
717
|
+
\`\`\`md
|
|
718
|
+
<!-- camera: behind --> \u2190 words on the left
|
|
719
|
+
<!-- camera: behind right --> \u2190 or right, top, bottom
|
|
720
|
+
<!-- camera: behind solid --> \u2190 split screen: you centred on the other side
|
|
721
|
+
<!-- camera: behind bottom clear --> \u2190 no card, for a plain wall
|
|
722
|
+
\`\`\`
|
|
723
|
+
|
|
724
|
+
It stays on its slide; \`pip: behind\` makes it the whole deck's. With the camera off, the slide still shows this way, over an empty frame.
|
|
725
|
+
|
|
726
|
+
### Shorts and Reels
|
|
727
|
+
|
|
728
|
+
\`format: portrait\` in the top block makes the deck a 9:16 column, and its video 1080\xD71920 (or 720\xD71280):
|
|
729
|
+
|
|
730
|
+
- \`top\` and \`bottom\` are halves, above or below you; \`left\` and \`right\` go below you
|
|
731
|
+
- a slide's words are larger, to read on a phone
|
|
732
|
+
- easy mode records the column from the middle of the screen: a Retina laptop makes 720p, a 16" one or a screen on its side 1080p
|
|
733
|
+
|
|
734
|
+
[An example](https://slidetake.com/gh/slidetake/slidetake/examples/portrait.md).
|
|
735
|
+
|
|
712
736
|
### Take by take
|
|
713
737
|
|
|
714
738
|
**\u25CF Record** (R) counts down and starts. From then on \u2192 drives everything: slides, reveals and camera moves (a Bluetooth clicker works).
|
|
@@ -783,7 +807,7 @@ Every deck you open is **read-only**: Slidetake's own decks, templates, files on
|
|
|
783
807
|
No accounts, and no decks kept. Recording stays on your device.
|
|
784
808
|
|
|
785
809
|
Next, everything that leaves your browser, and where it goes: **[Privacy \u2192](/privacy)**
|
|
786
|
-
`});var
|
|
810
|
+
`});var Gr,Vr=G(()=>{Gr=`---
|
|
787
811
|
title: Slidetake Features
|
|
788
812
|
description: "Every Slidetake feature, one line each: recording in the browser or with OBS, a map instead of a stack, the camera in the deck, plain markdown, your colours, and where it runs."
|
|
789
813
|
brand: slidetake
|
|
@@ -823,9 +847,12 @@ The complete list, one line each. Press \u2192 to walk it, **O** for the map.
|
|
|
823
847
|
|---|---|
|
|
824
848
|
| **Webcam in its box** | you and the slides in one recording, no compositing |
|
|
825
849
|
| **Camera per slide** | corner, size, side, circle, full screen, behind the slide or off |
|
|
850
|
+
| **Words around you** (\`behind left\`\u2026) | the slide's content beside, above or below you, on a see-through card, a solid one (split screen) or none |
|
|
851
|
+
| **Smooth moves** | the camera glides between corner, full frame and split screen, and swaps sides with the words |
|
|
826
852
|
| **Steps on one slide** | open on you, then reveal the slide |
|
|
827
853
|
| **Camera layouts** (V) | try them live, without editing the deck |
|
|
828
|
-
| **Off until you turn it on** |
|
|
854
|
+
| **Off until you turn it on** | the slides get the whole screen; a slide built around you shows an empty frame; a reload remembers it |
|
|
855
|
+
| **Mirror** (Setup) | off by default, so writing behind you reads the right way |
|
|
829
856
|
|
|
830
857
|
### Your colours
|
|
831
858
|
|
|
@@ -864,6 +891,7 @@ For Safari, Firefox or any browser, a screen too small for easy mode, or whateve
|
|
|
864
891
|
|---|---|
|
|
865
892
|
| **[OBS](https://obsproject.com), driven by the deck** | it starts and stops for you; you only talk |
|
|
866
893
|
| **16:9 check** | Setup warns before a video with bars; use a 16:9 screen, physical or virtual |
|
|
894
|
+
| **Shorts and Reels** (\`format: portrait\`) | a 9:16 deck and video, the words above or below you |
|
|
867
895
|
|
|
868
896
|
## \u2702\uFE0F Edit by picking the best take
|
|
869
897
|
|
|
@@ -893,7 +921,7 @@ For Safari, Firefox or any browser, a screen too small for easy mode, or whateve
|
|
|
893
921
|
| **Open source, Apache 2.0** | read it, host it, change it: [github.com/slidetake/slidetake](https://github.com/slidetake/slidetake) |
|
|
894
922
|
|
|
895
923
|
Next, see them working: **[Showcase \u2192](/showcase)**
|
|
896
|
-
`});var
|
|
924
|
+
`});var Kr,Yr=G(()=>{Kr=`---
|
|
897
925
|
title: Slidetake Privacy
|
|
898
926
|
brand: slidetake
|
|
899
927
|
pip: none
|
|
@@ -964,7 +992,7 @@ A shared link carries the whole deck after \`#\`. Browsers never send that part
|
|
|
964
992
|
## \u2709\uFE0F Questions
|
|
965
993
|
|
|
966
994
|
Open an issue on [github.com/slidetake/slidetake](https://github.com/slidetake/slidetake/issues). Slidetake is open source, so everything above can be checked in its code.
|
|
967
|
-
`});var
|
|
995
|
+
`});var $r,Jr=G(()=>{$r=`---
|
|
968
996
|
title: My deck
|
|
969
997
|
---
|
|
970
998
|
|
|
@@ -979,7 +1007,7 @@ Every heading is a card. \`##\` sections branch from the first card.
|
|
|
979
1007
|
### A detail
|
|
980
1008
|
|
|
981
1009
|
\`###\` branches from the section above it.
|
|
982
|
-
`});var
|
|
1010
|
+
`});var Qr,Xr=G(()=>{Qr=`---
|
|
983
1011
|
title: Talk title
|
|
984
1012
|
duration: 15m
|
|
985
1013
|
---
|
|
@@ -1020,7 +1048,7 @@ Something concrete the audience will recognise.
|
|
|
1020
1048
|
## \u{1F64F} Thank you
|
|
1021
1049
|
|
|
1022
1050
|
Where to find you, and the link to these slides.
|
|
1023
|
-
`});var
|
|
1051
|
+
`});var en,Zr=G(()=>{en=`---
|
|
1024
1052
|
title: Video title
|
|
1025
1053
|
duration: 10m
|
|
1026
1054
|
pip: bottom-right
|
|
@@ -1069,7 +1097,7 @@ Slides you talk over in the corner.
|
|
|
1069
1097
|
<!-- camera: on, full, on, off -->
|
|
1070
1098
|
|
|
1071
1099
|
Ends on you full screen, then back to the slide, then without the camera.
|
|
1072
|
-
`});var
|
|
1100
|
+
`});var an,tn=G(()=>{an=`---
|
|
1073
1101
|
title: Slidetake Showcase
|
|
1074
1102
|
description: "Everything a Slidetake deck can hold, working on screen: text, steps, code, Graphviz, D2, SVG, charts, image layouts, YouTube, the camera and the map."
|
|
1075
1103
|
brand: slidetake
|
|
@@ -1242,7 +1270,96 @@ A YouTube link alone on a line becomes the video: the next press plays it, leavi
|
|
|
1242
1270
|
|
|
1243
1271
|
<!-- camera: on, full, on -->
|
|
1244
1272
|
|
|
1245
|
-
Try it: press **C** to turn on your camera, then \u2192. This card puts you in the corner, then full screen, then back, from one comment: \`<!-- camera: on, full, on -->\`.
|
|
1273
|
+
Try it: press **C** to turn on your camera, then \u2192. This card puts you in the corner, then full screen, then back, from one comment: \`<!-- camera: on, full, on -->\`. The cards after it put the words beside you.
|
|
1274
|
+
|
|
1275
|
+
### Behind the slide
|
|
1276
|
+
|
|
1277
|
+
<!-- camera: behind -->
|
|
1278
|
+
|
|
1279
|
+
With the camera on, you fill the frame and this slide's words sit beside you: a talking head with slides. One comment does it: \`<!-- camera: behind -->\`, or \`pip: behind\` for a whole deck. They go on the left, on a half see-through card; \`right\`, \`top\` or \`bottom\` put them elsewhere.
|
|
1280
|
+
|
|
1281
|
+
### Words around you
|
|
1282
|
+
|
|
1283
|
+
<!-- camera: behind left, behind right, behind top, behind bottom -->
|
|
1284
|
+
|
|
1285
|
+
Press \u2192 and these words move around you: \`left\`, \`right\`, \`top\`, \`bottom\`. One comment, one press each.
|
|
1286
|
+
|
|
1287
|
+
### Split screen
|
|
1288
|
+
|
|
1289
|
+
<!-- camera: behind solid, behind right solid, behind top solid, behind bottom solid -->
|
|
1290
|
+
|
|
1291
|
+
Add \`solid\` and the card hides the camera behind it: a split screen, with the camera moved to the other side and you centred there.
|
|
1292
|
+
|
|
1293
|
+
### Clear
|
|
1294
|
+
|
|
1295
|
+
<!-- camera: behind clear, behind bottom clear -->
|
|
1296
|
+
|
|
1297
|
+
\`clear\` takes the card away: the words sit straight on the camera. Best over a plain wall or a green screen.
|
|
1298
|
+
|
|
1299
|
+
### Shorts and Reels
|
|
1300
|
+
|
|
1301
|
+
\`format: portrait\` in the top block turns the whole deck into a 9:16 column, for a video at 1080\xD71920. The words go above or below you. [Open the example](https://slidetake.com/gh/slidetake/slidetake/examples/portrait.md).
|
|
1302
|
+
|
|
1303
|
+
### A picture beside you
|
|
1304
|
+
|
|
1305
|
+
<!-- camera: behind right, behind left, behind bottom -->
|
|
1306
|
+
|
|
1307
|
+

|
|
1308
|
+
|
|
1309
|
+
### A Graphviz diagram beside you
|
|
1310
|
+
|
|
1311
|
+
<!-- camera: behind left, behind left solid -->
|
|
1312
|
+
|
|
1313
|
+
Talk through the flow while it sits beside you.
|
|
1314
|
+
|
|
1315
|
+
\`\`\`dot
|
|
1316
|
+
digraph {
|
|
1317
|
+
rankdir=LR
|
|
1318
|
+
node [shape=box style=rounded]
|
|
1319
|
+
Markdown -> Deck -> Takes -> Video
|
|
1320
|
+
}
|
|
1321
|
+
\`\`\`
|
|
1322
|
+
|
|
1323
|
+
### A D2 diagram beside you
|
|
1324
|
+
|
|
1325
|
+
<!-- camera: behind right, behind top -->
|
|
1326
|
+
|
|
1327
|
+
\`\`\`d2
|
|
1328
|
+
direction: right
|
|
1329
|
+
write: Write
|
|
1330
|
+
present: Present
|
|
1331
|
+
record: Record
|
|
1332
|
+
write -> present -> record
|
|
1333
|
+
\`\`\`
|
|
1334
|
+
|
|
1335
|
+
### An SVG beside you
|
|
1336
|
+
|
|
1337
|
+
<!-- camera: behind left, behind bottom solid -->
|
|
1338
|
+
|
|
1339
|
+
Drawn in the deck's colours.
|
|
1340
|
+
|
|
1341
|
+
\`\`\`svg
|
|
1342
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 130">
|
|
1343
|
+
<rect x="10" y="10" width="90" height="80" rx="10" style="fill:var(--accent)"/>
|
|
1344
|
+
<rect x="115" y="10" width="90" height="80" rx="10" style="fill:var(--accent);opacity:.6"/>
|
|
1345
|
+
<rect x="220" y="10" width="90" height="80" rx="10" fill="none" stroke="currentColor" stroke-width="2"/>
|
|
1346
|
+
<text x="160" y="120" text-anchor="middle" font-size="14" fill="currentColor">accent, faded, outlined</text>
|
|
1347
|
+
</svg>
|
|
1348
|
+
\`\`\`
|
|
1349
|
+
|
|
1350
|
+
### A chart beside you
|
|
1351
|
+
|
|
1352
|
+
<!-- camera: behind right, behind bottom -->
|
|
1353
|
+
|
|
1354
|
+
Views a month, and growing.
|
|
1355
|
+
|
|
1356
|
+
\`\`\`echarts
|
|
1357
|
+
{
|
|
1358
|
+
"xAxis": {"type": "category", "data": ["Jan", "Feb", "Mar", "Apr", "May"]},
|
|
1359
|
+
"yAxis": {"type": "value"},
|
|
1360
|
+
"series": [{"type": "bar", "data": [12, 19, 15, 24, 30]}]
|
|
1361
|
+
}
|
|
1362
|
+
\`\`\`
|
|
1246
1363
|
|
|
1247
1364
|
## \u{1F5FA}\uFE0F Layouts and the map
|
|
1248
1365
|
|
|
@@ -1275,50 +1392,50 @@ Open **\u270E Editor** and press **New** for a template (blank, talk or recordin
|
|
|
1275
1392
|
The templates and this deck live in [examples/](https://github.com/slidetake/slidetake/tree/main/examples) on GitHub.
|
|
1276
1393
|
|
|
1277
1394
|
Next, how it all works, step by step: **[Docs \u2192](/docs)**
|
|
1278
|
-
`});function
|
|
1395
|
+
`});function pt(e){return e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"")||"card"}function _t(e){return e.replace(/<[^>]*>/g,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[*_`~]/g,"").trim()}function A(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function on(e){if(typeof document<"u"){let t=document.createElement("textarea");return t.innerHTML=e,t.value}return e.replace(/&(#x[\da-f]+|#\d+|\w+);/gi,(t,a)=>a[0]==="#"?String.fromCodePoint(a[1].toLowerCase()==="x"?parseInt(a.slice(2),16):parseInt(a.slice(1),10)):js[a.toLowerCase()]??t)}function Ut(e){let t={};for(let a of e.matchAll(/([\w-]+)="([^"]*)"/g))t[a[1]]=a[2];return t}function qt(e,t){let a=[[]],o=null;return e.split(`
|
|
1279
1396
|
`).forEach(r=>{let n=r.match(/^\s{0,3}(`{3,}|~{3,})/);n&&(o?n[1][0]===o[0]&&n[1].length>=o.length&&(o=null):o=n[1]),!o&&!n&&t.test(r)?a.push([]):a[a.length-1].push(r)}),a.map(r=>r.join(`
|
|
1280
|
-
`))}function
|
|
1397
|
+
`))}function rn(e){let t=String(e??"").trim().toLowerCase();if(!t)return 0;let a=t.match(/^(\d+):(\d{1,2})$/);if(a)return(+a[1]*60+ +a[2])*1e3;if(a=t.match(/^(\d+(?:\.\d+)?)\s*(h|hrs?|hours?|m|mins?|minutes?|s|secs?|seconds?)?$/),!a)return 0;let o=(a[2]||"m")[0];return parseFloat(a[1])*(o==="h"?3600:o==="s"?1:60)*1e3}function wa(e){let t=Math.max(0,Math.round(e/1e3)),a=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60;return(a?a+":"+String(o).padStart(2,"0"):o)+":"+String(r).padStart(2,"0")}function ut(e){let t=Math.max(0,Math.round(e/1e3)),a=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60;return a?a+"h "+String(o).padStart(2,"0")+"m":o?o+"m "+String(r).padStart(2,"0")+"s":r+"s"}var js,xa=G(()=>{"use strict";js={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",rsquo:"\u2019",lsquo:"\u2018",rdquo:"\u201D",ldquo:"\u201C"}});function sn(e){let t=null;return e.split(`
|
|
1281
1398
|
`).filter(a=>{let o=a.match(/^\s{0,3}(`{3,}|~{3,})/);return o?(t?o[1][0]===t[0]&&o[1].length>=t.length&&(t=null):t=o[1],!1):!t}).join(`
|
|
1282
|
-
`).replace(/`[^`\n]*`/g,"")}function
|
|
1283
|
-
`).forEach(r=>{let n=r.match(/^\s+-\s+(.*)$/);if(n&&o){t[o].push(n[1].trim().replace(/^["']|["']$/g,""));return}let i=r.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);if(!i){o=null;return}let s=i[1].toLowerCase(),l=i[2].trim().replace(/^["']|["']$/g,"");l===""?(t[s]=[],o=s):(t[s]=l,o=null)}),{deck:t,body:e.slice(a[0].length)}}function
|
|
1399
|
+
`).replace(/`[^`\n]*`/g,"")}function xo(e){return/<!--\s*view\s*:\s*(overview|map)\s*-->/i.test(sn(e))}function ko(e){let t=sn(e).match(/<!--\s*camera\s*:\s*([\s\S]*?)\s*-->/i);return t?t[1].trim():null}function Ws(e){let t={},a=e.match(/^---[ \t]*\n([\s\S]*?)\n---[ \t]*(?:\n|$)/);if(!a)return{deck:t,body:e};let o=null;return a[1].split(`
|
|
1400
|
+
`).forEach(r=>{let n=r.match(/^\s+-\s+(.*)$/);if(n&&o){t[o].push(n[1].trim().replace(/^["']|["']$/g,""));return}let i=r.match(/^([A-Za-z_][\w-]*)\s*:\s*(.*)$/);if(!i){o=null;return}let s=i[1].toLowerCase(),l=i[2].trim().replace(/^["']|["']$/g,"");l===""?(t[s]=[],o=s):(t[s]=l,o=null)}),{deck:t,body:e.slice(a[0].length)}}function ln(e){let t=r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean",a=r=>String(r).replace(/\s*\n\s*/g," "),o=[];for(let[r,n]of Object.entries(e||{}))/^[A-Za-z_][\w-]*$/.test(r)&&(t(n)?o.push(r+": "+a(n)):Array.isArray(n)&&n.every(t)&&(o.push(r+":"),n.forEach(i=>o.push(" - "+a(i)))));return o.length?`---
|
|
1284
1401
|
`+o.join(`
|
|
1285
1402
|
`)+`
|
|
1286
1403
|
---
|
|
1287
|
-
`:""}function
|
|
1404
|
+
`:""}function _s(e){let t=e.split(`
|
|
1288
1405
|
`),a={},o=e;if(t[0]!==void 0&&t[0].trim()==="---"){let r=-1;for(let n=1;n<t.length;n++)if(t[n].trim()==="---"){r=n;break}r!==-1&&(t.slice(1,r).forEach(n=>{let i=n.indexOf(":");i>-1&&(a[n.slice(0,i).trim()]=n.slice(i+1).trim().replace(/^["']|["']$/g,""))}),o=t.slice(r+1).join(`
|
|
1289
|
-
`).replace(/^\n+/,""))}return{meta:a,body:o}}function
|
|
1290
|
-
`).map(i=>i.replace(/<[^>]+>/g,"").trim()).find(i=>i&&!/^[-|:\s]+$/.test(i));r=n?n.slice(0,60):null}return r?
|
|
1291
|
-
`);let n=/^\+\+\+[ \t]*$/m.test(e),i={};n||({deck:i,body:e}=
|
|
1292
|
-
`).forEach(x=>{let
|
|
1293
|
-
`);
|
|
1294
|
-
`).trim(),
|
|
1295
|
-
`).find(X=>X.trim())||"Intro").slice(0,48));x.id=o(x.explicitId||
|
|
1406
|
+
`).replace(/^\n+/,""))}return{meta:a,body:o}}function Us(e){let t=e.replace(/<!--[\s\S]*?-->/g,""),a=t.match(/^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/m),o=t.match(/<h[1-6][^>]*>([\s\S]*?)<\/h[1-6]>/i),r=null;if(a&&(!o||a.index<o.index)?r=a[1]:o&&(r=o[1].replace(/<[^>]+>/g," ")),!r){let n=t.split(`
|
|
1407
|
+
`).map(i=>i.replace(/<[^>]+>/g,"").trim()).find(i=>i&&!/^[-|:\s]+$/.test(i));r=n?n.slice(0,60):null}return r?on(_t(r)).replace(/\s+/g," ").trim():null}function nn(e){let t=e.match(/<!--\s*\.slide:([\s\S]*?)-->/i);return t?Ut(t[1]):{}}function cn(e,{render:t=a=>({html:a,err:null})}={}){let a=new Map,o=f=>{let b=f,p=2;for(;a.has(b);)b=f+"-"+p++;return b},r=f=>(a.set(f.id,{x:null,y:null,children:[],...f}),f.id);e=e.replace(/\r\n?/g,`
|
|
1408
|
+
`);let n=/^\+\+\+[ \t]*$/m.test(e),i={};n||({deck:i,body:e}=Ws(e));let s=/^slides?$/i.test(String(i.layout||""))||/^slides?$/i.test(String(i.type||"")),l=!n&&(qt(e,/^--\s*$/).length>1||s&&qt(e,/^---\s*$/).length>1),c=n?k():l?m():d();return a.forEach(f=>{(!f.parent||f.parent===f.id||!a.has(f.parent))&&(f.parent=null)}),a.forEach(f=>{let b=new Set([f.id]),p=f.parent;for(;p;){if(b.has(p)){f.parent=null;break}b.add(p),p=a.get(p).parent}}),a.forEach(f=>{f.parent&&a.get(f.parent).children.push(f.id)}),{deck:i,nodes:a,format:n?"+++":l?"reveal":"headings",errCount:c};function d(){let f=[],b=null,p=null,T={level:0,title:null,explicitId:null,lines:[]};e.split(`
|
|
1409
|
+
`).forEach(x=>{let y=x.match(/^\s{0,3}(`{3,}|~{3,})/);y&&(p?y[1][0]===p[0]&&y[1].length>=p.length&&(p=null):p=y[1]);let E=!p&&!y?x.match(/^\s{0,3}(#{1,6})\s+(.+?)\s*#*\s*$/):null;if(E){let L=E[2],$=null,ae=L.match(/\s*\{#([\w\-:.]+)\}\s*$/);ae&&($=ae[1],L=L.slice(0,ae.index)),b={level:E[1].length,title:_t(L),explicitId:$,lines:[E[1]+" "+L]},f.push(b)}else(b||T).lines.push(x)});let C=T.lines.join(`
|
|
1410
|
+
`);C.trim()&&(f.length&&!C.replace(/<!--[\s\S]*?-->/g,"").trim()?f[0].lines.splice(1,0,...T.lines):f.unshift(T));let w=[];return f.forEach(x=>{for(;w.length&&w[w.length-1].level>=x.level;)w.pop();let y=w.length?w[w.length-1].id:null,E=x.lines.join(`
|
|
1411
|
+
`).trim(),L=x.title||_t((E.split(`
|
|
1412
|
+
`).find(X=>X.trim())||"Intro").slice(0,48));x.id=o(x.explicitId||pt(L));let{html:$,err:ae}=t(E);r({id:x.id,parent:y,title:L,html:$,err:ae,camera:ko(E),mapFirst:xo(E)}),w.push(x)}),0}function k(){let f=e.split(/\n\+\+\+[ \t]*\n/).map(T=>T.trim()).filter(T=>T.length),b=null,p=0;return f.forEach((T,C)=>{let{meta:w,body:x}=_s(T),y=o(w.id||"slide-"+(C+1)),E="parent"in w?w.parent||null:b,L=x.match(/^#{1,6}\s+(.+)$/m),$=w.title||(L?_t(L[1]):y),{html:ae,err:X}=t(x);X&&p++,r({id:y,parent:E,title:$,html:ae,err:X,camera:w.camera||ko(x),mapFirst:xo(x),x:w.x!==void 0?parseFloat(w.x):null,y:w.y!==void 0?parseFloat(w.y):null}),b=y}),p}function m(){let f=0,b=0,p=null;function T(w,x){let y=w.body.trim();b++;let E=Us(y)||"Slide "+b,L=x?a.get(x).title:null;L&&E.startsWith(L+" / ")&&(E=E.slice(L.length+3));let $=o(pt(E)),{html:ae,err:X}=t(y);return X&&f++,r({id:$,parent:x,title:E,html:ae,err:X,camera:ko(y),mapFirst:xo(y),autoslide:parseInt(w.attrs["data-autoslide"],10)||0})}let C=[];return qt(e,/^---\s*$/).forEach(w=>{if(/<section\b/i.test(w)){for(let E of w.matchAll(/<section\b([^>]*)>([\s\S]*?)<\/section>/gi))C.push([{body:E[2],attrs:Ut(E[1])}]);let y=w.replace(/<section\b[^>]*>[\s\S]*?<\/section>/gi,"");y.trim()&&C.push([{body:y,attrs:nn(y)}]);return}let x=qt(w,/^--\s*$/).filter(y=>y.trim()).map(y=>({body:y,attrs:nn(y)}));x.length&&C.push(x)}),C.forEach(w=>{let x=null;w.forEach((y,E)=>{if(!p){p=x=T(y,null);return}E===0?x=T(y,p):T(y,x)})}),f}}var dn=G(()=>{"use strict";xa()});function Ke(e,t){return String(t||"").toLowerCase().split(/\s+/).forEach(a=>{a&&(a==="solid"?(e.card=100,e.used=!0):a==="clear"?(e.card=0,e.used=!0):a==="off"||a==="hide"?e.off=!0:a==="on"||a==="pip"||a==="show"?(e.off=!1,e.full=!1,e.behind=!1,e.place="",e.used=!0):a==="full"||a==="fullscreen"?(e.full=!0,e.behind=!1,e.place="",e.off=!1,e.used=!0):a==="behind"||a==="under"?(e.full=!0,e.behind=!0,e.place="left",e.off=!1,e.used=!0):qs.includes(a)?(e.place=a,e.used=!0):/^\d+(\.\d+)?%?$/.test(a)?(e.size=So(parseFloat(a)),e.used=!0):Vt.includes(a)?(e.corner=a,e.used=!0):a==="flip"?(e.flip=!e.flip,e.used=!0):a==="circle"?e.circle=!0:a==="rect"?e.circle=!1:a==="mirror"?e.mirror=!0:(a==="unmirror"||a==="no-mirror")&&(e.mirror=!1))}),e}function hn(e){return e?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function pn(e,t){let a=[];if(!e.length){for(let r=0;r<=t;r++)a.push({cam:0,frag:r});return a}let o=e.findIndex(r=>!Ke({},r).full);o<0&&(o=e.length-1);for(let r=0;r<=o;r++)a.push({cam:r,frag:0});for(let r=1;r<=t;r++)a.push({cam:o,frag:r});for(let r=o+1;r<e.length;r++)a.push({cam:r,frag:t});return a}var Vt,qs,So,un=G(()=>{"use strict";Vt=["top-left","top-right","bottom-left","bottom-right"],qs=["left","right","top","bottom"],So=e=>Math.max(8,Math.min(60,e))});function mn(e){let t=String(e||"").trim();if(!t)return null;let a;try{a=new URL(/^[a-z]+:\/\//i.test(t)?t:"https://"+t)}catch{return null}let o=a.pathname.split("/").filter(Boolean);if(a.hostname==="github.com"||a.hostname==="www.github.com"){let[r,n,i,s,...l]=o;if(r&&n&&(i==="blob"||i==="raw"||i==="tree")&&s){let c=l.join("/");return(i==="tree"||!/\.(md|markdown|txt)$/i.test(c))&&(c=(c?c+"/":"")+"index.md"),{kind:"url",url:Eo+[r,n,s].join("/")+"/"+c}}if(r&&n&&!i)return{kind:"url",url:Eo+r+"/"+n+"/HEAD/README.md"}}if(a.hostname==="gist.github.com"){let r=o.length>=2?o[1]:o[0];if(r&&/^[\da-f]+$/i.test(r))return{kind:"gist",id:r}}if(a.hostname==="slidetake.com"||a.hostname==="www.slidetake.com"){let r=Co(a.pathname);if(r)return r;let n=a.searchParams.get("src");if(n)return{kind:"url",url:n}}return{kind:"url",url:a.href}}function Co(e){let t=String(e||"").split("/").filter(Boolean).map(a=>{try{return decodeURIComponent(a)}catch{return a}});if(t[0]==="gh"&&t.length>=4){let[,a,o,...r]=t,n=o.indexOf("@"),i=n<0?o:o.slice(0,n),s=n<0?"HEAD":o.slice(n+1);return!a||!i||!s?null:{kind:"url",url:Eo+[a,i,s,...r].map(encodeURIComponent).join("/")}}return t.length===1&&(t[0]==="docs"||t[0]==="help")?{kind:"builtin",id:"docs"}:t[0]==="showcase"&&t.length===1?{kind:"builtin",id:"showcase"}:t[0]==="examples"&&(t.length===1||t.length===2&&t[1]==="showcase")?{kind:"builtin",id:"showcase"}:t.length===1&&t[0]==="features"?{kind:"builtin",id:"features"}:t.length===1&&t[0]==="privacy"?{kind:"builtin",id:"privacy"}:t[0]==="gist"&&t[1]&&/^[\da-f]+$/i.test(t[1])?t[2]?{kind:"gist",id:t[1],file:t[2]}:{kind:"gist",id:t[1]}:null}function fn(e){if(e.kind==="builtin")return e.id==="home"?"/":e.id==="showcase"?"/showcase":e.id.startsWith("template:")?"/new?template="+e.id.slice(9):"/"+e.id;if(e.kind==="gist")return"/gist/"+e.id+(e.file?"/"+encodeURIComponent(e.file):"");let t=e.url.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)\/(.+)$/);if(t){let[,a,o,r,n]=t;if(!/^refs$/.test(r))return"/gh/"+a+"/"+o+(r==="HEAD"?"":"@"+r)+"/"+n}return"/?src="+encodeURIComponent(e.url)}var Eo,Mo=G(()=>{"use strict";Eo="https://raw.githubusercontent.com/"});function Vs(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Gs(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4));return Uint8Array.from(t,a=>a.charCodeAt(0))}async function gn(e,t){let a=new Response(new Blob([e]).stream().pipeThrough(t));return new Uint8Array(await a.arrayBuffer())}async function yn(e){return Vs(await gn(new TextEncoder().encode(e),new CompressionStream("deflate-raw")))}async function bn(e){return new TextDecoder().decode(await gn(Gs(e),new DecompressionStream("deflate-raw")))}function ka(e){let t=e.replace(/^#/,"");if(!t.startsWith(To)){let n=t;try{n=decodeURIComponent(t)}catch{}return{data:null,slide:n}}let a=t.slice(To.length),o=a.indexOf("~"),r=o<0?"":a.slice(o+1);try{r=decodeURIComponent(r)}catch{}return{data:o<0?a:a.slice(0,o),slide:r}}function Lo(e,t){return"#"+To+e+(t?"~"+encodeURIComponent(t):"")}var To,Ao=G(()=>{"use strict";To="deflate:"});function vn(e,t,a){let o=e.replace(/\/+$/,"")||"/",r=new URLSearchParams(t),{data:n,slide:i}=ka(a);if(o==="/share")return n?{page:"share",data:n,slide:i}:{page:"source",source:{kind:"builtin",id:"home"},slide:""};if(o==="/edit")return{page:"edit",slide:i};if(o==="/new"){let c=r.get("template");return c&&Ys.includes(c)?{page:"source",source:{kind:"builtin",id:"template:"+c},slide:i}:{page:"pick"}}let s=Co(o);if(s)return{page:"source",source:s,slide:i};let l=r.get("src");return o==="/"&&l?{page:"source",source:{kind:"url",url:l},slide:i}:{page:"source",source:{kind:"builtin",id:"home"},slide:i}}function Ee(e){switch(e.kind){case"builtin":return e.id==="home"?"Home":e.id==="docs"||e.id==="help"?"the docs":e.id==="showcase"?"the showcase":e.id==="features"?"the features":e.id==="privacy"?"the privacy page":"the "+e.id.replace(/^template:/,"")+" template";case"gist":return"a gist"+(e.file?" ("+e.file+")":"");case"shared":return"a shared deck";case"file":return e.name;case"url":{let t=e.url.match(/^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/[^/]+\/(.+)$/);if(t)return t[1]+"/"+t[2]+"/"+t[3];try{let a=new URL(e.url);return a.hostname+a.pathname}catch{return e.url}}}}function Sa(e,t,{exported:a=!1}={}){return{text:e,origin:t,originText:e,exported:a?e:null}}function Ea(e){return e.text!==(e.exported??e.originText)}function Ca(e){return e.text===e.originText}function wn(e){try{let t=JSON.parse(e||"null");return!t||typeof t.text!="string"||!t.origin||typeof t.origin.kind!="string"?null:{text:t.text,origin:t.origin,originText:typeof t.originText=="string"?t.originText:t.text,exported:typeof t.exported=="string"?t.exported:null}}catch{return null}}var Ys,xn=G(()=>{"use strict";Mo();Ao();Ys=["blank","talk","recording"]});function Bo(e){let t;try{t=new URL(e)}catch{return null}let a=t.hostname.replace(/^(www\.|m\.)/,""),o=null,r=!1;if(a==="youtu.be")o=t.pathname.slice(1).split("/")[0];else if(a==="youtube.com"||a==="youtube-nocookie.com"){let n=t.pathname.split("/").filter(Boolean);n[0]==="watch"?o=t.searchParams.get("v"):["shorts","live","embed"].includes(n[0])&&(o=n[1]||null,r=n[0]==="shorts")}return!o||!/^[\w-]{6,}$/.test(o)?null:{id:o,start:Ks(t.searchParams.get("t")||t.searchParams.get("start")||""),portrait:r}}function Ks(e){if(/^\d+$/.test(e))return+e;let t=e.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);return t&&e?+(t[1]||0)*3600+ +(t[2]||0)*60+ +(t[3]||0):0}function kn(e){return"https://www.youtube-nocookie.com/embed/"+encodeURIComponent(e.id)+"?enablejsapi=1&rel=0&playsinline=1"+(e.start?"&start="+e.start:"")}var Sn=G(()=>{"use strict"});function be(e){let t=new Map,a=e.totalObs??e.total;return e.events.forEach((o,r)=>{t.has(o.id)||t.set(o.id,{id:o.id,title:o.title,takes:[]});let n=t.get(o.id),i=e.events[r+1];n.takes.push({no:n.takes.length+1,start:En(o)+(o.skip||0),end:i?En(i)-(i.lead||0):a})}),t}function Gt(e){let t=[],a=Ta(e);return be(e).forEach(o=>{let r=e.picks[o.id]??o.takes.length;if(!r)return;let n=o.takes[r-1];if(!n)return;let i=Cn(n.start,a),s=Cn(n.end,a);s>i&&t.push({id:o.id,title:o.title,f0:i,f1:s,start:i*1e3/a,end:s*1e3/a})}),t}function Js(e){let t=[];return e.forEach(a=>{let o=t[t.length-1];o&&a.f0===o.f1?(o.f1=a.f1,o.end=a.end):t.push({f0:a.f0,f1:a.f1,start:a.start,end:a.end})}),t}function Oo(e,t){let a=0,o=[];return Gt(e).forEach(r=>{let{sec:n,title:i}=t(r.id,r.title),s=o[o.length-1];(!s||s.sec!==n&&s.title!==i)&&o.push({sec:n,title:i,t:a}),a+=r.end-r.start}),{list:o,length:a}}function Tn(e,t){let{list:a,length:o}=Oo(e,t),r=a.filter((n,i)=>i===0||(a[i+1]?a[i+1].t:o)-n.t>=1e4);return r.length&&(r[0].t=0),{lines:r.map(n=>wa(n.t)+" "+n.title),dropped:a.length-r.length,length:o}}function Ln(e,t,{input:a,outputName:o,sectionOf:r,loudness:n}){let i=Js(Gt(e));if(!e.withObs)return"# This was a rehearsal: nothing was recorded.";if(!i.length)return"# Every slide is left out: nothing to render.";let s=$s(a)+o,{list:l,length:c}=Oo(e,r),d=y=>String(y).replace(/[=;#\\\n]/g,E=>"\\"+E),m=`cat > /tmp/slidetake-chapters.txt <<'EOF'
|
|
1296
1413
|
`+(`;FFMETADATA1
|
|
1297
1414
|
title=`+d(e.deckTitle)+`
|
|
1298
|
-
`+l.map((
|
|
1415
|
+
`+l.map((y,E)=>`[CHAPTER]
|
|
1299
1416
|
TIMEBASE=1/1000
|
|
1300
|
-
START=`+Math.round(
|
|
1301
|
-
END=`+Math.round(l[
|
|
1302
|
-
title=`+d(
|
|
1417
|
+
START=`+Math.round(y.t)+`
|
|
1418
|
+
END=`+Math.round(l[E+1]?l[E+1].t:c)+`
|
|
1419
|
+
title=`+d(y.title)).join(`
|
|
1303
1420
|
`))+`
|
|
1304
1421
|
EOF
|
|
1305
|
-
`,
|
|
1306
|
-
inpoint `+
|
|
1307
|
-
outpoint `+
|
|
1422
|
+
`,f=" -map 0:v:0 -map 0:a:0 -map_metadata 1 -map_chapters 1";if(t==="copy"){let y=i.map(L=>"file "+Ma(a)+`
|
|
1423
|
+
inpoint `+Mn(L.start)+`
|
|
1424
|
+
outpoint `+Mn(L.end)).join(`
|
|
1308
1425
|
`);return(i.length>1?`# Careful: without re-encoding, cuts can only land on keyframes (OBS puts one about every 2 s),
|
|
1309
1426
|
# so `+(i.length===2?"the cut":"each of the "+(i.length-1)+" cuts")+` here may keep or lose up to ~2 s. Use a frame-accurate option for retakes.
|
|
1310
1427
|
`:"")+`cat > /tmp/slidetake-cuts.txt <<'EOF'
|
|
1311
|
-
`+
|
|
1428
|
+
`+y+`
|
|
1312
1429
|
EOF
|
|
1313
|
-
`+m+"ffmpeg -f concat -safe 0 -i /tmp/slidetake-cuts.txt -i /tmp/slidetake-chapters.txt"+
|
|
1314
|
-
`)};[tl(),_&&_.colors].filter(Boolean).forEach(o=>{["dark","light"].forEach(r=>{let n={...o,...o[r]||{}},i=r==="dark";n.accent&&typeof n.accent=="string"&&(n.accentSoft=n.accentSoft||n.accent,n.line=n.line||"color-mix(in srgb, "+n.accent+(i?" 45%, #09090b)":" 55%, #fff)"),n.ring=n.ring||(i?n.accent:n.line),n.onAccent=n.onAccent||(i?"color-mix(in srgb, "+n.accent+" 15%, #000)":"#fff")),t(i?'body:not([data-mode="light"])':'body[data-mode="light"]',n)})});let a=document.getElementById("st-colors");a||(a=document.createElement("style"),a.id="st-colors",document.head.appendChild(a)),a.textContent!==e&&(a.textContent=e),document.body.classList.toggle("st-header-color",e.includes("--header-bg"))}function Me(e){let t=document.createElement("span");t.style.color="var("+e+")",document.body.appendChild(t);let a=getComputedStyle(t).color;return t.remove(),_e=_e||Object.assign(document.createElement("canvas"),{width:1,height:1}).getContext("2d",{willReadFrequently:!0}),_e.clearRect(0,0,1,1),_e.fillStyle="#000",_e.fillStyle=a,_e.fillRect(0,0,1,1),"#"+[..._e.getImageData(0,0,1,1).data.slice(0,3)].map(o=>o.toString(16).padStart(2,"0")).join("")}function ol(e,t,a){let o=i=>[1,3,5].map(s=>parseInt(i.slice(s,s+2),16)),r=o(e),n=o(t);return"#"+r.map((i,s)=>Math.round(i*a+n[s]*(1-a)).toString(16).padStart(2,"0")).join("")}function eo(){if(_&&_.themeKey&&!Rn){let t=W(_.themeKey);return t==="light"||t==="dark"?t:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return String(Rn||W("slidetake:mode")||R.mode||"dark").toLowerCase()==="light"?"light":"dark"}function ti(){let e=eo()==="light";e?document.body.dataset.mode="light":delete document.body.dataset.mode;let t=document.getElementById("btn-mode");t&&(t.innerHTML=e?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4.5"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>',t.title=(e?"Dark theme":"Light theme")+" (L)",t.setAttribute("aria-label",t.title))}function ai(){let e=eo()==="light"?"dark":"light";_&&_.themeKey?(U(_.themeKey,e),document.documentElement.classList.toggle("dark",e==="dark")):U("slidetake:mode",e),ti(),se.querySelector(".echarts-container, .diagram.d2, .diagram.dot")&&wt(!0)}function rl(){let t=(R.camera||"").replace(/^\[|\]$/g,"").split(",").map(a=>a.trim().replace(/^["']|["']$/g,"")).filter(Boolean);return t.length?t:["on","full","off"]}function Wo(e){return!re&&e?en(e.camera):[]}function Tt(e){return tn(Wo(e),e&&e.frags?e.frags.length:0)}function oi(){let e=Tt(u.get(f));return e[Math.min(we,e.length-1)]||{cam:0,frag:0}}function nl(){if(!f)return null;let e=u.get(f),t=Wo(e);if(t.length)return t[Math.min(oi().cam,t.length-1)];if(e&&e.el&&e.el.classList.contains("card-full"))return"off";for(let a=g.indexOf(f)-1;a>=0;a--){let o=Wo(u.get(g[a]));if(o.length)return o[o.length-1]}return null}function il(){let e={corner:(R.pip||"none").toLowerCase(),size:go(parseFloat(R.pip_size)||24),circle:(R.pip_shape||"").toLowerCase()==="circle",mirror:!/^(no|false|off)$/i.test(R.pip_mirror||""),full:!1,off:!1,flip:!1,used:!1};return(e.corner==="behind"||e.corner==="under")&&(e.corner="bottom-right",Ft(e,"behind")),Ft(e,nl()),ye&&!/\b(off|hide)\b/i.test(ye)&&(e.off=!1),Ft(e,ye),!Dt.includes(e.corner)&&(oe||e.used)&&(e.corner="bottom-right"),e.flip&&Dt.includes(e.corner)&&(e.corner=e.corner.includes("left")?e.corner.replace("left","right"):e.corner.replace("right","left")),e}function nr(){let e=!P.hidden&&P.offsetWidth?P.getBoundingClientRect():null,t=Pe=il(),a=Dt.includes(t.corner);if(P.className=a?[t.corner,t.circle&&"circle",oe&&"live",t.mirror&&"mirror",t.full&&"full",t.behind&&"behind",P.classList.contains("msg")&&"msg"].filter(Boolean).join(" "):"",P.style.width=t.size+"%",P.hidden=!a||re||t.off,ja.dataset.pip=P.hidden||t.full?"none":t.corner,ja.classList.toggle("cam-behind",!P.hidden&&!!t.behind),P.hidden||Mt||!P.animate)return;let o="cubic-bezier(.65,0,.35,1)";if(!e){P.animate([{opacity:0},{opacity:1}],{duration:300,easing:"ease-out"});return}let r=P.getBoundingClientRect();Math.abs(e.left-r.left)+Math.abs(e.top-r.top)+Math.abs(e.width-r.width)+Math.abs(e.height-r.height)<2||P.animate([{transformOrigin:"0 0",transform:"translate("+(e.left-r.left)+"px,"+(e.top-r.top)+"px) scale("+e.width/r.width+","+e.height/r.height+")"},{transformOrigin:"0 0",transform:"none"}],{duration:600,easing:o})}function sl(){let e=Pe;if(!e||P.hidden||e.full)return null;let t=H.clientWidth,a=H.clientHeight,o=16,r=t*e.size/100,n=e.circle?r:r*9/16,i=e.corner.includes("left")?o:t-o-r,s=e.corner.includes("top")?o:a-o-n;return{x0:i,y0:s,x1:i+r,y1:s+n}}function ll(){if(!Ze)return;if(re){pa(!0);return}let e=rl();Ie=(Ie+1)%e.length,ye=e[Ie],nr(),K||mt("Camera: "+ye),!oe&&!P.hidden?at():xe()}function ri(e){let t=Qr(e,{render:Qs});R=t.deck,u=t.nodes,_a();let a={"+++":"+++ format",reveal:"reveal.js format",headings:"headings"}[t.format];Us.textContent=u.size+(u.size===1?" card":" cards")+" \xB7 "+a,Jt.textContent=t.errCount?t.errCount+" card(s) had errors":""}function ni(){Ye=[...u.values()].filter(o=>!o.parent).map(o=>o.id);let e=0;function t(o,r){let n=u.get(o);if(n.depth=r,n.children.length===0)n._slot=e++;else{n.children.forEach(s=>t(s,r+1));let i=n.children.map(s=>u.get(s)._slot);n._slot=(Math.min(...i)+Math.max(...i))/2}}Ye.forEach(o=>t(o,0)),g=[];function a(o){g.push(o),u.get(o).children.forEach(a)}return Ye.forEach(a),Math.max(1,e)}function cl(){let e=[],t=[],a=[];return u.forEach(o=>{e[o.depth]=Math.max(e[o.depth]||0,o._h),t[o.depth]=Math.max(t[o.depth]||0,o._w),a[o.depth]=(a[o.depth]||0)+1}),{maxH:e,maxW:t,count:a,maxDepth:e.length-1}}function ii(e){e.x!==null&&!isNaN(e.x)&&(e.cx=e.x+e._w/2),e.y!==null&&!isNaN(e.y)&&(e.cy=e.y+e._h/2)}function dl(){let{maxH:e,maxDepth:t}=cl(),a=[0];for(let l=1;l<=t;l++)a[l]=a[l-1]+e[l-1]+Ys;let o=Vs-yt,r=[],n=(l,c)=>{let d=u.get(l);d.cx+=c,d.children.forEach(M=>n(M,c))},i=l=>{let c=u.get(l);r[c.depth]=Math.max(r[c.depth]??-1/0,c.cx+c._w/2),c.children.forEach(i)};function s(l){let c=u.get(l),d=r[c.depth]!==void 0?r[c.depth]+o:-1/0;c.children.length?(c.children.forEach(s),c.cx=(u.get(c.children[0]).cx+u.get(c.children[c.children.length-1]).cx)/2,c.cx-c._w/2<d&&n(l,d-(c.cx-c._w/2))):c.cx=(d===-1/0?0:d)+c._w/2,i(l)}Ye.forEach(s),u.forEach(l=>{l.cy=a[l.depth]+l._h/2,ii(l)})}function hl(e){let t=Math.PI*2/e,a=32,o=[],r=(s,l)=>Math.abs(s.cx-l.cx)<(s._w+l._w)/2+a&&Math.abs(s.cy-l.cy)<(s._h+l._h)/2+a,n=Math.max(0,...[...u.values()].map(s=>s.depth)),i=0;for(let s=0;s<=n;s++){let l=[...u.values()].filter(d=>d.depth===s);if(!l.length)continue;let c=s===0?Ye.length>1?Js*.5:0:i+Ks;for(let d=0;d<400&&(l.forEach(m=>{let y=(m._slot+.5)*t-Math.PI/2;m.cx=c*Math.cos(y),m.cy=c*Math.sin(y),ii(m)}),!!l.some((m,y)=>l.some((b,p)=>p>y&&r(m,b))||o.some(b=>r(m,b))));d++)c=c*1.02+10;i=c,o.push(...l)}}function pl(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),a=[];for(;t.nextNode();)a.push(t.currentNode);a.forEach(o=>{let r=o.data.match(/^\s*\.element:\s*([\s\S]*)$/);if(!r)return;let n=o.previousSibling;for(;n&&n.nodeType===3&&!n.data.trim();)n=n.previousSibling;let i=n&&n.nodeType===1?n:o.parentElement;i&&Object.entries(zt(r[1])).forEach(([s,l])=>{s==="class"?i.classList.add(...l.split(/\s+/).filter(Boolean)):s==="style"?i.style.cssText+=";"+l:i.setAttribute(s,l)})})}function ml(e){let t=new DOMParser().parseFromString(e,"image/svg+xml"),a=t.documentElement;if(!a||a.localName!=="svg"||t.getElementsByTagName("parsererror").length)return null;let o=a.namespaceURI,r=i=>{[...i.children].forEach(s=>{s.namespaceURI!==o||!ul.has(s.localName)?s.remove():r(s)}),[...i.attributes].forEach(s=>{let l=s.name.toLowerCase(),c=s.value;(l.startsWith("on")||/javascript:|expression\(/i.test(c)||/url\(\s*['"]?(?!#)/i.test(c)||(l==="href"||l==="xlink:href")&&!c.trim().startsWith("#"))&&i.removeAttribute(s.name)})};r(a);let n="st-svg"+ ++fl+"-";return[a,...a.querySelectorAll("*")].forEach(i=>[...i.attributes].forEach(s=>{let l=s.name==="id"?n+s.value:s.value.replace(/url\(\s*(['"]?)#/g,"url($1#"+n);(s.name==="href"||s.name==="xlink:href")&&l.startsWith("#")&&(l="#"+n+l.slice(1)),l!==s.value&&(s.value=l)})),document.importNode(a,!0)}function Oe(e,t){let a=e.classList.contains("fragment");["fragment","fade-up","visible","current-fragment"].forEach(o=>{e.classList.contains(o)&&(t.classList.add(o),e.classList.remove(o))}),e.dataset.fragmentIndex!==void 0&&(t.dataset.fragmentIndex=e.dataset.fragmentIndex,delete e.dataset.fragmentIndex),e.replaceWith(t),a&&u.forEach(o=>o.frags&&o.frags.forEach(r=>{let n=r.indexOf(e);n>=0&&(r[n]=t)}))}function Io(e){let t=document.createElement("figure");t.className="media",Oe(e,t),t.appendChild(e);let a=e.getAttribute("alt");return a&&t.insertAdjacentHTML("beforeend","<figcaption>"+A(a)+"</figcaption>"),t}function gl(e,t){let a=document.createElement("figure");return a.className="media yt fragment yt-play"+(e.portrait?" portrait":""),a.innerHTML='<div class="frame"><iframe src="'+pn(e)+'" title="'+A(t||"YouTube video")+'" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen loading="lazy"></iframe></div>'+(t?"<figcaption>"+A(t)+"</figcaption>":""),a}function Dn(e,t){let a=t<=4?t:t<=6?3:4;e.style.setProperty("--cols",a),e.style.setProperty("--rows",Math.ceil(t/a))}function vl(e,t){t.querySelectorAll("pre > code.language-svg").forEach(n=>{let i=ml(n.textContent.trim()),s=document.createElement("div");s.className=i?"diagram svg":"diagram err",i?s.appendChild(i):s.textContent="SVG error: not a valid <svg> drawing",Oe(n.parentElement,s)}),t.querySelectorAll(":scope > p").forEach(n=>{let i=n.children.length===1?n.children[0]:null;if(!i)return;let s=i.tagName==="A"&&n.textContent.trim()===i.textContent.trim()?i.getAttribute("href"):i.tagName==="IMG"?i.getAttribute("src"):null,l=s&&So(s);l&&Oe(n,gl(l,i.tagName==="IMG"?i.getAttribute("alt"):""))}),t.querySelectorAll(":scope > ul, :scope > ol").forEach(n=>{let i=[...n.children];!i.length||!i.every(s=>Po(s)||wl(s))||(n.classList.add("gallery"),i.some(s=>!Po(s))&&n.classList.add("diagrams"),i.forEach(s=>{if(!Po(s))return;let l=s.querySelector("img");s.innerHTML="",s.appendChild(l),Io(l)}),i.length>1&&i.every(s=>s.classList.contains("fragment"))?(n.classList.add("carousel"),i[0].classList.remove("fragment","fade-up"),i.forEach((s,l)=>{s.classList.replace("fade-up","current-visible");let c=s.querySelector("figcaption");c&&(c.dataset.count=l+1+" / "+i.length)})):Dn(n,i.length))}),t.querySelectorAll(":scope > p").forEach(n=>{if(!yl(n))return;let i=[...n.querySelectorAll("img")];if(i.length===1){Oe(n,i[0]),Io(i[0]);return}let s=document.createElement("div");s.className="gallery grid",Oe(n,s),i.forEach(l=>{s.appendChild(l),Io(l)}),Dn(s,i.length)});let a=[...t.children].filter(n=>!/^H[1-6]$/.test(n.tagName)&&!(n.nodeType===1&&n.tagName==="HR")),o=a.filter(n=>n.matches("figure.media"));o.length===1&&a.length===1&&e.classList.add("card-media");let r=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);for(;r.nextNode();)/^\s*view\s*:\s*full\s*$/i.test(r.currentNode.data)&&e.classList.add("card-full");if(a.length===1&&(a[0].matches("figure.media:not(.yt)")||a[0].matches(".gallery.carousel:not(.diagrams)")))e.classList.add("card-bleed");else if(o.length===1&&a.length>1&&!o[0].matches(".yt")){e.classList.add("card-split",a.indexOf(o[0])===0?"media-first":"media-last");let n=document.createElement("div");n.className="split-text",a.filter(i=>i!==o[0]).forEach(i=>n.appendChild(i)),o[0].after(n),a.indexOf(o[0])!==0&&n.after(o[0])}t.querySelector(".gallery")&&e.classList.add("card-gallery")}function si(e,t){let a=e.querySelector("iframe");a&&a.contentWindow&&a.contentWindow.postMessage(JSON.stringify({event:"command",func:t,args:[]}),"*")}function bl(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),a=[];for(;t.nextNode();)/^\s*steps\s*$/i.test(t.currentNode.data)&&a.push(t.currentNode);a.forEach(o=>{for(let r=o.nextSibling;r&&!(r.nodeType===8&&/^\s*steps\s*:\s*off\s*$/i.test(r.data));r=r.nextSibling)r.nodeType!==1||r.classList.contains("fragment")||(/^(UL|OL)$/.test(r.tagName)?r.querySelectorAll(":scope > li").forEach(n=>n.classList.add("fragment","fade-up")):r.classList.add("fragment","fade-up"))})}function xl(e){let t=r=>r.classList.contains("fragment")&&(r.tagName==="P"&&r.children.length===1&&r.children[0].tagName==="IMG"&&!r.textContent.trim()&&!So(r.children[0].getAttribute("src")||"")||r.tagName==="PRE"&&!!r.querySelector(li)),a=[],o=[];[...e.children].forEach(r=>{t(r)?o.push(r):(o.length>1&&a.push(o),o=[])}),o.length>1&&a.push(o),a.forEach(r=>{let n=document.createElement("ul");r[0].before(n),r.forEach(i=>{let s=document.createElement("li");s.className="fragment fade-up",i.classList.remove("fragment","fade-up"),s.appendChild(i),n.appendChild(s)})})}function kl(e){let t=[...e.querySelectorAll(".fragment")].map((r,n)=>({e:r,i:n,k:r.dataset.fragmentIndex}));if(t.every(r=>r.k===void 0))return t.map(r=>[r.e]);let a=0;t.forEach(r=>{r.k=r.k===void 0?a:parseFloat(r.k),a=Math.max(a,r.k)+1}),t.sort((r,n)=>r.k-n.k||r.i-n.i);let o=[];return t.forEach((r,n)=>{n&&t[n-1].k===r.k?o[o.length-1].push(r.e):o.push([r.e])}),o}function ir(e,t,a){!e||!e.frags||(a&&e.el.classList.add("snap"),e.frags.forEach((o,r)=>o.forEach(n=>{let i=n.classList.contains("visible");n.classList.toggle("visible",r<t),n.classList.toggle("current-fragment",r===t-1),n.classList.contains("yt-play")&&i!==r<t&&!a&&si(n,r<t?"playVideo":"pauseVideo")})),a&&(e.el.offsetWidth,e.el.classList.remove("snap")))}function Sl(){try{return R.base?new URL(R.base,ze||location.href):ze?new URL(ze):null}catch{return null}}function El(e){let t=Sl(),a=0;return e.querySelectorAll("img[src], source[src], video[src], iframe[src], a[href]").forEach(o=>{let r=o.hasAttribute("src")?"src":"href",n=o.getAttribute(r);if(!n||/^(#|[a-z][a-z0-9+.-]*:|\/\/)/i.test(n))return;if(!t){r==="src"&&!n.startsWith("/")&&a++;return}let i=t;try{R.site&&(i=new URL(R.site,t))}catch{}o.setAttribute(r,new URL(n,n.startsWith("/")?i:t).href)}),a}function to(e){let t=e.el,a=t.querySelector(".body");t.classList.add("measuring"),a.style.zoom="";let o=yt;e.visual=!!a.querySelector("iframe, .echarts-container, pre > code.language-dot, pre > code.language-d2, pre > code.language-echarts, .diagram, figure.media"),e.visual&&(o=le);let r=t.classList.contains("card-full");if(t.classList.remove("img-portrait","img-landscape","img-overlay","img-cover"),r&&(o=le),t.classList.contains("card-bleed")){let l=Math.max(0,...[...a.querySelectorAll("img")].map(d=>d.naturalWidth&&d.naturalHeight?d.naturalWidth/d.naturalHeight:0))||1.7777777777777777,c=le-Aa*l>=260;if(r&&c)t.classList.add("img-portrait"),t.style.setProperty("--img-w",Math.round(Aa*l)+"px"),o=le;else if(r||Math.abs(l-16/9)<.08)t.classList.add("img-overlay"),o=le,l>=16/9&&l<=16/9*1.15&&t.classList.add("img-cover");else if(l<1.3){let d=Math.min(Math.round(Aa*l),le-300);t.classList.add("img-portrait"),t.style.setProperty("--img-w",d+"px"),o=Math.min(le,Math.max(Oo,d*2))}else t.classList.add("img-landscape"),o=Math.round(Math.max(yt,Math.min(le,(Aa-Gs)*l))),t.style.setProperty("--img-h",Math.round(o/l)+"px")}else(a.querySelector('[style*="flex"], [style*="grid"], .r-hstack')||a.querySelectorAll("img").length>=4)&&(o=Oo);let n=a.querySelectorAll("table");if(n.length){t.style.width=le+"px";let l=t.offsetWidth-a.clientWidth;n.forEach(c=>{o=Math.max(o,Math.min(Oo,Math.ceil(c.offsetWidth)+l+12))})}let i=a.querySelectorAll("pre");if(i.length){t.style.width=le+"px";let l=t.offsetWidth-a.clientWidth;i.forEach(c=>{c.style.width="max-content",o=Math.max(o,Math.min(le,Math.ceil(c.offsetWidth)+l+2)),c.style.width=""})}let s=a.querySelectorAll(".fragment.grow");if(s.length){t.style.width=o+"px";let l=t.offsetWidth-a.clientWidth;s.forEach(c=>{o=Math.max(o,Math.min(le,Math.ceil(c.offsetWidth*1.3)+l))})}t.style.width=o+"px",t.scrollWidth>o+2&&(t.style.width=(o=Math.min(le,t.scrollWidth+24))+"px"),a.scrollWidth>a.clientWidth+2&&(a.style.zoom=(a.clientWidth/a.scrollWidth).toFixed(3)),e._w=o,e._h=t.offsetHeight||_o,t.classList.remove("measuring")}function Cl(){clearTimeout(Fn),Fn=setTimeout(()=>{u.forEach(to),ra(),xe(!0)},200)}function Al(){let e=eo()==="light"?"light":"dark",t=Me(e==="light"?"--accent-ring":"--accent"),a="slidetake-"+e+"-"+t.slice(1);return Nn.has(a)||(Bl(a,Ll[e],t),Nn.add(a)),a}function Bl(e,t,a){let o={axisLine:{lineStyle:{color:t.line}},axisTick:{lineStyle:{color:t.line}},axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.split}},nameTextStyle:{color:t.muted}};echarts.registerTheme(e,{color:[a,...t.palette],backgroundColor:"transparent",textStyle:{color:t.text,fontFamily:"'IBM Plex Sans', sans-serif"},title:{textStyle:{color:t.text},subtextStyle:{color:t.muted}},legend:{textStyle:{color:t.text}},tooltip:{backgroundColor:t.tip,borderColor:t.line,textStyle:{color:t.text}},categoryAxis:o,valueAxis:o,logAxis:o,timeAxis:o,line:{symbolSize:6,lineStyle:{width:2.5}},pie:{label:{color:t.text,textBorderWidth:0},labelLine:{lineStyle:{color:t.muted}}},funnel:{label:{color:t.text,textBorderWidth:0}}})}function Pl(){let e=eo()==="light"?"light":"dark",t=Me("--node-bg"),a=Me(e==="dark"?"--accent":"--accent-line"),o=e==="dark"?[.58,.38,.25,.18,.12]:[.7,.45,.25,.15,.08],r={...Il[e],N7:t,B1:Me("--accent")};return o.forEach((n,i)=>{r["B"+(i+2)]=ol(a,t,n)}),r}function zl(){let e=Me("--text"),t=Me("--text-muted"),a=Me("--accent"),o='"Helvetica,Arial,sans-serif"';return' graph [bgcolor=transparent color="'+t+'" fontcolor="'+e+'" fontname='+o+'] node [color="'+a+'" fontcolor="'+e+'" fontname='+o+'] edge [color="'+t+'" fontcolor="'+t+'" fontname='+o+"] "}function Uo(e){return zo[e]||(zo[e]=new Promise((t,a)=>{let o=document.createElement("script");o.src=e,o.onload=t,o.onerror=()=>{delete zo[e],a(new Error("could not load "+e))},document.head.appendChild(o)}))}async function Fl(){let e=We,t=[...se.querySelectorAll(".node pre > code.language-dot")];se.querySelectorAll(".node pre > code.language-echarts").forEach(n=>{let i=document.createElement("div");i.className="echarts-container",i.dataset.chart=n.textContent,Oe(n.parentElement,i)});let a=[...se.querySelectorAll(".node .echarts-container[data-chart]")],o=[...se.querySelectorAll(".node pre > code.language-d2")];if(!t.length&&!a.length&&!o.length)return;let r=[];if(t.length)try{if(await Uo(Ml),Ro=Ro||await Viz.instance(),e!==We)return;let n=zl();t.forEach(i=>{let s=document.createElement("div");s.className="diagram dot";try{s.appendChild(Ro.renderSVGElement(Rl(i.textContent,n)))}catch(l){s.className="diagram err",s.textContent="Diagram error: "+l.message}Oe(i.parentElement,s)})}catch{r.push("diagrams")}if(o.length)try{if(!Ba){let i=await import(Ol);Ba=new i.D2}if(e!==We)return;let n=Pl();for(let i of o){let s=document.createElement("div");s.className="diagram d2";try{let l=await Ba.compile(Dl(i.textContent));s.innerHTML=await Ba.render(l.diagram,{...l.renderOptions||{},themeOverrides:n,darkThemeOverrides:n})}catch(l){s.className="diagram err",s.textContent="Diagram error: "+(l.message||l)}if(e!==We)return;Oe(i.parentElement,s)}}catch{r.push("D2 diagrams")}if(a.length)try{if(await Uo(Tl),e!==We)return;let n=Al();a.forEach(i=>{let s;try{s=JSON.parse(i.dataset.chart)}catch{i.textContent="Chart data is not valid JSON.";return}echarts.init(i,n,{renderer:"svg"}).setOption(Object.assign({backgroundColor:"transparent",animation:!Mt},s))})}catch{r.push("charts")}e===We&&(r.length&&(Jt.textContent="Could not load the "+r.join(" and ")+" renderer (offline?)"),u.forEach(to),ra(),xe(!0))}function Nl(){let e=[];return g.forEach(t=>{let a=Ct(t),o=e[e.length-1];o&&o.sec===a?o.ids.push(t):e.push({sec:a,ids:[t]})}),e}function Hl(){let a=0,o=0,r=0;Nl().forEach((n,i)=>{let s=Math.max(...n.ids.map(d=>u.get(d)._h));i&&(a+=r/2+120+s/2);let l=o,c=o;n.ids.forEach((d,M)=>{let m=u.get(d);M&&(l+=90+m._w/2),m.cx=l,m.cy=a,c=l,l+=m._w/2}),o=c,r=s})}function jl(){u.forEach(e=>{e.cx=0,e.cy=0})}function ci(){We++,window.echarts&&se.querySelectorAll(".echarts-container").forEach(a=>{let o=echarts.getInstanceByDom(a);o&&o.dispose()}),se.querySelectorAll("div.node").forEach(a=>a.remove());let e=ni(),t=0;u.forEach(a=>{let o=document.createElement("div");o.className="node",o.tabIndex=0,o.dataset.id=a.id;let r=a.parent?ao(a.id).slice(0,-1).map(i=>u.get(i).title).join(" / "):"";o.innerHTML=(r?'<div class="crumb">'+A(r)+"</div>":"")+'<div class="body">'+a.html+"</div>"+(a.err?'<div class="err-badge">!</div>':"");let n=o.querySelector(".body");pl(n),bl(n),xl(n),vl(o,n),/^slidetake$/i.test(R.brand||"")&&el(n),n.querySelectorAll("thead").forEach(i=>{i.textContent.trim()||i.remove()}),t+=El(n),a.frags=kl(n),n.querySelectorAll("img").forEach(i=>{i.complete||i.addEventListener("load",Cl,{once:!0})}),o.querySelectorAll("a[href]").forEach(i=>{let s=i.getAttribute("href");if(s.startsWith("#")){let l=decodeURIComponent(s.slice(1));u.has(l)&&(i.classList.add("xlink"),i.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),h.active||j(l)}))}else i.target="_blank",i.rel="noopener",i.addEventListener("click",l=>l.stopPropagation())}),o.addEventListener("click",()=>{h.active||j(a.id)}),o.addEventListener("keydown",i=>{i.key==="Enter"&&i.target===o&&j(a.id)}),se.appendChild(o),a.el=o,ir(a,a.frags.length)}),t&&!Jt.textContent&&(Jt.textContent=t+" image(s) use relative paths: add base: to the deck, or open it with ?src="),u.forEach(to),ra(e),Fl()}function ra(e){e===void 0&&(e=ni()),J==="radial"?hl(e):J==="path"?Hl():J==="focus"?jl():dl(),se.classList.toggle("focus",J==="focus"),u.forEach(t=>{let a=t.el.style;a.setProperty("--cx",t.cx),a.setProperty("--cy",t.cy)}),_l(),Lt(),cr()}function _l(){let e="";if(J==="focus"){Bo.innerHTML="";return}if(J==="path"){for(let t=1;t<g.length;t++){let a=u.get(g[t-1]),o=u.get(g[t]);e+='<path data-from="'+a.id+'" data-to="'+o.id+'" d="M '+a.cx+" "+a.cy+" L "+o.cx+" "+o.cy+'"/>'}Bo.innerHTML=e;return}u.forEach(t=>{if(!t.parent)return;let a=u.get(t.parent);if(J==="radial")e+='<path data-from="'+a.id+'" data-to="'+t.id+'" d="M '+a.cx+" "+a.cy+" L "+t.cx+" "+t.cy+'"/>';else{let o=a.cy+a._h/2,r=t.cy-t._h/2,n=o+(r-o)/2;e+='<path data-from="'+a.id+'" data-to="'+t.id+'" d="M '+a.cx+" "+o+" L "+a.cx+" "+n+" L "+t.cx+" "+n+" L "+t.cx+" "+r+'"/>'}}),Bo.innerHTML=e}function ao(e){let t=[],a=e;for(;a;)t.unshift(a),a=u.get(a).parent;return t}function vt(){let e=H.clientWidth,t=H.clientHeight;se.style.transform="translate("+e/2+"px,"+t/2+"px) scale("+z.zoom+") translate("+-z.x+"px,"+-z.y+"px)",vi()}function sr(){Yt&&(Yt.kill(),Yt=null)}function di(e,t){if(sr(),t||Mt||!window.gsap){Object.assign(z,e),vt();return}let a=H.clientWidth,o=Math.hypot(e.x-z.x,e.y-z.y),r=e.zoom,n=gsap.timeline({onUpdate:vt,onComplete:()=>{Yt=null}}),{zoom:i,...s}=e,l=o*Math.min(z.zoom,r),c=Math.max(.55,Math.min(1.3,.55+l/a*.3));if(n.to(z,{...s,duration:c,ease:"power2.inOut"},0),l>a*1.2){let d=Math.max(.06,Math.min(z.zoom,r,a*.9/(o+yt)));n.to(z,{zoom:d,duration:c/2,ease:"sine.out"},0).to(z,{zoom:r,duration:c/2,ease:"sine.in"},c/2)}else n.to(z,{zoom:r,duration:c,ease:"power2.inOut"},0);Yt=n}function Wl(){let e=H.getBoundingClientRect(),t=14,a=[];if(!Ae.hidden&&Ae.offsetWidth){let r=Ae.getBoundingClientRect();a.push({x0:r.left-e.left-t,y0:r.top-e.top-t,x1:r.right-e.left+t,y1:r.bottom-e.top+t})}let o=sl();return o&&a.push({x0:o.x0-t,y0:o.y0-t,x1:o.x1+t,y1:o.y1+t}),a}function Ul(){let e=H.clientWidth,t=H.clientHeight,a=[{x0:16,y0:K?20:56,x1:e-16,y1:t-(K?20:74)}];return Wl().forEach(o=>{let r=[];a.forEach(n=>{if(o.x1<=n.x0||o.x0>=n.x1||o.y1<=n.y0||o.y0>=n.y1){r.push(n);return}[{...n,x1:Math.min(n.x1,o.x0)},{...n,x0:Math.max(n.x0,o.x1)},{...n,y1:Math.min(n.y1,o.y0)},{...n,y0:Math.max(n.y0,o.y1)}].forEach(i=>{i.x1-i.x0>80&&i.y1-i.y0>80&&r.push(i)})}),r.length&&(a=r)}),a}function qo(e,t,a){let o=H.clientWidth,r=H.clientHeight,n=null;return Ul().forEach(i=>{let s=a*Math.min((i.x1-i.x0)/e,(i.y1-i.y0)/t);(!n||s>n.zoom)&&(n={zoom:s,sx:(i.x0+i.x1)/2-o/2,sy:(i.y0+i.y1)/2-r/2})}),n}function hi(e,t,a,o){return{x:e-a.sx/o,y:t-a.sy/o}}function Xe(e,t){let a=u.get(e);if(!a)return;let o=qo(a._w,a._h,$t),r=Ct(e),n=g.filter(l=>Ct(l)===r&&!u.get(l).visual).map(l=>{let c=u.get(l);return qo(c._w,c._h,$t).zoom}).sort((l,c)=>l-c),i=n.length?n[Math.floor((n.length-1)/2)]:o.zoom,s=Math.max(.2,Math.min(5,o.zoom,i));di(Object.assign(hi(a.cx,a.cy,o,s),{zoom:s}),t)}function na(e){let t=[...u.values()];if(!t.length)return;let a=H.clientWidth,o=H.clientHeight,r=Math.min(...t.map(d=>d.cx-d._w/2)),n=Math.max(...t.map(d=>d.cx+d._w/2)),i=Math.min(...t.map(d=>d.cy-d._h/2)),s=Math.max(...t.map(d=>d.cy+d._h/2)),l=qo(n-r,s-i,.94),c=Math.max(.05,Math.min(1,l.zoom));di(Object.assign(hi((r+n)/2,(i+s)/2,l,c),{zoom:c}),e)}function xe(e){f&&u.has(f)?Xe(f,e):na(e)}function Lt(){let e=f?ao(f):[];u.forEach(t=>{let a=t.el;a.classList.toggle("current",t.id===f),a.classList.toggle("active-path",e.includes(t.id))}),se.querySelectorAll("#connectors path").forEach(t=>{let a=J==="path"?!!f&&g.indexOf(t.dataset.to)<=g.indexOf(f):e.includes(t.dataset.from)&&e.includes(t.dataset.to);t.classList.toggle("active",a)}),Yl(e),ui()}function pi(){return Kr(new URLSearchParams(location.search).get("duration")??R.duration)}function ql(){return K&&pi()>0&&(!h.active||/^always$/i.test(R.timer||""))}function Wa(){let e=ql()&&Re.start>0;if(qe.classList.toggle("timed",e),!e){qe.classList.remove("over");return}let a=(h.active&&h.t0?xt():performance.now()-Re.start)/pi();qe.firstChild.style.width=Math.min(100,a*100)+"%",qe.classList.toggle("over",a>=1)}function Gl(){Re.start=performance.now(),clearInterval(Re.timer),Re.timer=setInterval(Wa,1e3),Wa()}function Vl(){clearInterval(Re.timer),Re.timer=null,Re.start=0,Wa()}function ui(){let e=K&&g.length>1&&!/^(off|no|false)$/i.test(R.progress||"");if(qe.classList.toggle("show",e),!e)return;Wa();let t=g.indexOf(f),a=0,o=0;g.forEach((r,n)=>{let i=Tt(u.get(r)).length;a+=i,n<t?o+=i:n===t&&(o+=Math.min(we,i-1)+1)}),qe.lastChild.style.width=(a?o/a*100:0)+"%"}function Yl(e){Pn.innerHTML=e.map((t,a)=>(a>0?'<span class="sep">\u203A</span>':"")+'<button class="crumb-btn'+(t===f?" here":"")+'" data-id="'+A(t)+'">'+A(u.get(t).title)+"</button>").join(""),Pn.querySelectorAll(".crumb-btn").forEach(t=>t.addEventListener("click",()=>{h.active||j(t.dataset.id)}))}function ia(e){let t=u.get(f);t&&(ir(t,oi().frag,e),nr(),(P.hidden||!Pe||!Pe.full||Pe.behind)&&$l(t),lr(t))}function Jl(e){return!g.length||e.id!==g[0]&&e.id!==g[g.length-1]||e.el.querySelector("[data-gsap], .title-scramble")?null:[...e.el.querySelector(".body").children].filter(t=>!t.classList.contains("fragment"))}function $l(e){if(e._played||!window.gsap||Mt)return;e._played=!0;let t=Jl(e);if(t&&t.length){e._auto=t;let[a,...o]=t;/^H[1-3]$/.test(a.tagName)&&!a.children.length?(a.classList.add("auto-scramble"),Hn(a)):o.unshift(a),gsap.from(o,{opacity:0,y:24,duration:.7,ease:"power2.out",delay:.5,stagger:.45})}e.el.querySelectorAll("[data-gsap]").forEach(a=>{let o;try{o=JSON.parse(a.dataset.gsap)}catch{return}let r={duration:o.duration??1,delay:o.delay??0,ease:o.ease||"power2.out"};o.to?gsap.fromTo(a,o.from||{},Object.assign({},o.to,r)):o.from&&gsap.from(a,Object.assign({},o.from,r))}),e.el.querySelectorAll(".title-scramble").forEach(Hn)}function Xt(e){!e||!e._played||(e._played=!1,window.gsap&&(e._auto&&(e._auto.forEach(t=>{gsap.killTweensOf(t),gsap.set(t,{clearProps:"opacity,transform"})}),e._auto=null),e.el.querySelectorAll("[data-gsap]").forEach(t=>{gsap.killTweensOf(t);let a={};try{a=JSON.parse(t.dataset.gsap)}catch{}let o=new Set(Object.keys(Object.assign({},a.from,a.to)).map(r=>Kl.includes(r)?"transform":r));o.size&&gsap.set(t,{clearProps:[...o].join(",")})}),e.el.querySelectorAll(".title-scramble, .auto-scramble").forEach(t=>{t._scramble&&t._scramble.kill(),t.dataset.text&&(t.textContent=t.dataset.text)})))}function Hn(e){let t=e.dataset.text||(e.dataset.text=e.textContent),a=Array.from(t),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*+=?",r={p:0};e._scramble=gsap.to(r,{p:1,duration:1.4,ease:"none",onUpdate(){let n=Math.floor(r.p*a.length);e.textContent=a.map((i,s)=>s<n||/\s/.test(i)?i:o[Math.random()*o.length|0]).join("")},onComplete(){e.textContent=t}})}function lr(e){clearTimeout(bt),!(!K||!e||!e.autoslide||h.active&&(!h.t0||h.paused))&&(bt=setTimeout(()=>{f===e.id&&De(1)},e.autoslide))}function fi(e){let t=e&&e!==g[0]?e:"";try{E&&E.kind==="share"?history.replaceState(null,"",location.pathname+location.search+xo(E.data,t)):history.replaceState(null,"",e?"#"+encodeURIComponent(e):location.pathname+location.search)}catch{}}function j(e,t,a){if(!u.has(e))return;if(e!==f){ye=null,Ie=-1,we=a?Tt(u.get(e)).length-1:0;let n=u.get(f);n&&J==="focus"&&!t&&(n.el.classList.add("leaving"),setTimeout(()=>n.el.classList.remove("leaving"),600)),gi()}let o=e!==f;if(o&&(mi=f),f=e,clearTimeout(ge),ge=null,o&&J==="focus"&&!t&&!Mt){let n=u.get(e).el;n.classList.add("entering"),n.offsetWidth,n.classList.remove("entering")}ia(o),o&&!Te&&ta("slide",e);let r=u.get(e);o&&r.mapFirst&&!a&&!t&&J!=="focus"?(na(),ge=setTimeout(()=>{ge=null,f===e&&Xe(e)},1900)):Xe(e,t),Lt(),cr(),fi(e)}function gi(){let e=u.get(f);e&&(e.el.querySelectorAll("figure.yt").forEach(t=>si(t,"pauseVideo")),ir(e,e.frags.length,!0),Xt(e))}function Xl(){if(!f&&Ge&&u.has(Ge)){yi();return}f&&(Ge=f),J==="focus"&&dr("path"),gi(),clearTimeout(bt),f=null,Lt(),cr(),na(),fi(null)}function yi(){if(ge)return clearTimeout(ge),ge=null,Xe(f),!0;if(!f&&Ge&&u.has(Ge)){let e=Ge;return Ge=null,j(e),!0}return!1}function De(e){if(!f){g.length&&j(g[e>0?0:g.length-1]);return}if(ge&&e>0){clearTimeout(ge),ge=null,Xe(f);return}let t=Tt(u.get(f)),a=Math.min(we,t.length-1)+e;if(a>=0&&a<t.length){we=a,ye=null,Ie=-1,ia(),!oe&&!P.hidden&&Pe.used?at():xe(),Lt();return}let o=g.indexOf(f)+e;o>=0&&o<g.length&&j(g[o],!1,e<0)}function Ql(){let e=u.get(f);e&&e.parent&&j(e.parent)}function Zl(){let e=u.get(f);e&&e.children.length?j(e.children[0]):!f&&g.length&&j(g[0])}function cr(){let e=[...u.values()];if(!e.length){jo.innerHTML="",Ee=null;return}qs.textContent="map";let t=p=>p.cx,a=p=>p.cy,o=Math.min(...e.map(t))-yt/2,r=Math.max(...e.map(t))+yt/2,n=Math.min(...e.map(a))-_o/2,i=Math.max(...e.map(a))+_o/2,s=16,l=180,c=130,d=Math.min((l-2*s)/Math.max(1,r-o),(c-2*s-6)/Math.max(1,i-n)),M=l/2-(o+r)/2*d,m=c/2+5-(n+i)/2*d,y=f?ao(f):[],b="";e.forEach(p=>{if(!p.parent)return;let T=u.get(p.parent);b+='<line x1="'+(t(T)*d+M)+'" y1="'+(a(T)*d+m)+'" x2="'+(t(p)*d+M)+'" y2="'+(a(p)*d+m)+'" stroke="var(--panel-line)" stroke-width="1"/>'}),e.forEach(p=>{let T=p.id===f?"var(--accent)":y.includes(p.id)?"var(--accent-teal)":"var(--node-border)";b+='<circle data-id="'+A(p.id)+'" cx="'+(t(p)*d+M)+'" cy="'+(a(p)*d+m)+'" r="'+(p.id===f?4:3)+'" fill="'+T+'"><title>'+A(p.title)+"</title></circle>"}),b+='<rect id="mm-viewport" fill="none" stroke="var(--accent)" stroke-width="1" opacity="0.7"/>',jo.innerHTML=b,Ee={s:d,ox:M,oy:m},vi()}function vi(){let e=document.getElementById("mm-viewport");if(!e||!Ee)return;let t=H.clientWidth/z.zoom,a=H.clientHeight/z.zoom;e.setAttribute("x",(z.x-t/2)*Ee.s+Ee.ox),e.setAttribute("y",(z.y-a/2)*Ee.s+Ee.oy),e.setAttribute("width",Math.max(2,t*Ee.s)),e.setAttribute("height",Math.max(2,a*Ee.s))}function wt(e){ri(ie.value),f&&!u.has(f)&&(f=null),ci(),f?j(f,e):g.length?j(g[0],e):(f=null,na(!0))}function dr(e,t){J=e,U("slidetake:layout",e),document.querySelectorAll("#layout-toggle .seg-btn").forEach(a=>a.classList.toggle("active",a.dataset.mode===e)),u.size&&(!t&&!Mt&&(se.classList.add("morph"),setTimeout(()=>se.classList.remove("morph"),700)),ra(),vt(),f?Xe(f,t):na(t))}function bi(e){return Math.max(.04,Math.min(5,e))}function ec(e){$t=Math.round(Math.max($s,Math.min(Xs,e))*100)/100,U("slidetake:slideSize",$t),f&&Xe(f)}function jn(e){f?ec($t+e*.1):wi(e>0?1.2:1/1.2)}function wi(e,t,a){sr();let o=bi(z.zoom*e);if(t!==void 0){let r=H.getBoundingClientRect(),n=t-r.left-r.width/2,i=a-r.top-r.height/2;z.x+=n/z.zoom-n/o,z.y+=i/z.zoom-i/o}z.zoom=o,vt()}function oo(){_||(Ne.classList.toggle("collapsed"),document.getElementById("btn-edit-toggle").classList.toggle("active",!Ne.classList.contains("collapsed")))}function ve(e){K=e,document.body.classList.toggle("presenting",e),cs(document.getElementById("btn-present"),e),ds();let t=document.documentElement;e&&t.requestFullscreen&&!document.fullscreenElement&&t.requestFullscreen().catch(()=>{}),!e&&document.fullscreenElement&&document.exitFullscreen&&document.exitFullscreen().catch(()=>{}),e&&!f&&g.length&&j(g[0]);let a=R.camera||[...u.values()].some(o=>o.camera);e&&a&&!oe&&!re&&at(),e?lr(u.get(f)):clearTimeout(bt),e?Gl():Vl(),ui()}function xt(){return(h.paused?h.pauseAt:performance.now())-h.t0-h.pausedMs}function sa(e){e.classList.add("open")}function rc(e){if(U("slidetake:analytics",e?"on":"off"),!e){window["ga-disable-"+ac]=!0;let t=["","; Domain="+location.hostname,"; Domain=."+location.hostname.replace(/^www\./,"")];document.cookie.split(";").map(a=>a.split("=")[0].trim()).filter(a=>a==="_ga"||a.startsWith("_ga_")).forEach(a=>t.forEach(o=>{document.cookie=a+"=; Max-Age=0; Path=/"+o}))}ki()}function ki(){ur.querySelectorAll("[data-analytics]").forEach(e=>e.setAttribute("aria-checked",String(e.dataset.analytics==="on"===oc())))}function la(){document.querySelectorAll(".modal.open").forEach(e=>e.classList.remove("open"))}function nc(){let e=new URLSearchParams(location.search).get("obs");if(e){let[t,a,...o]=e.split(":");return Ua.value=t||"localhost",qa.value=a||"4455",Ga.value=o.join(":"),!0}try{let t=JSON.parse(W("slidetake:obs")||"null");t&&(Ua.value=t.host||"localhost",qa.value=t.port||"4455",Ga.value=t.password||"",hr.checked=!0)}catch{}return!1}function Ei(){if(hr.checked)U("slidetake:obs",JSON.stringify({host:Ua.value.trim(),port:qa.value.trim(),password:Ga.value}));else try{localStorage.removeItem("slidetake:obs")}catch{}}function _t(e,t,a){Kt.textContent=e,Kt.className=t||"",Kt.title=a||e;let o=document.getElementById("obs-detail");o.textContent=a||"",o.hidden=!a}function sc(e){return location.protocol==="https:"&&!ic(e)}async function fr(){let e=Ua.value.trim()||"localhost",t="ws://"+e+":"+(qa.value.trim()||"4455");if(sc(e)){Le=!1,_t("Blocked here","err",lc);return}_t("Connecting\u2026"),Kt.title="Connecting to "+t;try{await Uo(tc);let a=window.OBSWebSocket&&(window.OBSWebSocket.default||window.OBSWebSocket);if(ne)try{await ne.disconnect()}catch{}ne=new a,ne.on("ConnectionClosed",()=>{Le=!1,_t("Disconnected","err")}),ne.on("RecordStateChanged",r=>{r.outputState==="OBS_WEBSOCKET_OUTPUT_STARTED"&&Ve&&(Ve(),Ve=null),r.outputState==="OBS_WEBSOCKET_OUTPUT_STOPPED"&&h.active&&h.withObs&&!h.finishing&&Et("Stopped in OBS")});let o=await ne.connect(t,Ga.value||void 0);Le=!0;try{let r=await ne.call("GetVideoSettings");r&&r.fpsNumerator&&r.fpsDenominator&&(pr=r.fpsNumerator/r.fpsDenominator),xi=r&&r.outputWidth&&r.outputHeight?Sn(r.outputWidth,r.outputHeight):""}catch{}_t("Connected","ok",""),Kt.title="Connected"+(o&&o.obsWebSocketVersion?" \xB7 OBS WebSocket "+o.obsWebSocketVersion:""),Ei(),Y.classList.contains("open")&&et()&&(B("Connected to OBS. Press \u25CF Record."),je())}catch(a){Le=!1;let o=a&&a.message&&a.message!=="Error"?a.message+".":"Nothing answered at "+t+".";_t("Could not connect","err",o+" Is OBS running with its WebSocket server on, and are the port and password right?")}}function cc(){let e=document.getElementById("rec-screen"),t=screen.width,a=screen.height;if(Math.abs(t/a-16/9)<.02){e.innerHTML='<span class="ok">This screen is 16:9 ('+t+"\xD7"+a+"), right for YouTube.</span>";return}let o=[["16:10",1.6],["3:2",1.5],["4:3",4/3],["21:9",21/9],["16:9",16/9]],[r,n]=o.reduce((s,l)=>Math.abs(l[1]-t/a)<Math.abs(s[1]-t/a)?l:s),i=Math.abs(n-t/a)<.005?r:"about "+r;e.innerHTML='<span class="warn">This screen is '+i+" ("+t+"\xD7"+a+"), not 16:9, so the video will have bars or be cropped. Move this window to a 16:9 screen, physical or virtual (say 1920\xD71080), then press F there.</span>"}function ke(){let e=navigator.mediaDevices;if(!window.isSecureContext||!e||!e.getDisplayMedia)return{why:"This page can\u2019t capture itself here. Open Slidetake in Chrome or Edge on a computer."};if(!window.RestrictionTarget&&!window.CropTarget)return{why:"Recording in the browser needs Chrome or Edge (or another Chromium browser) on a computer."};let t=window.MediaRecorder?wn(r=>MediaRecorder.isTypeSupported(r)):"";if(!t||!navigator.storage||!navigator.storage.getDirectory)return{why:"This browser can\u2019t record video here. Use a recent Chrome or Edge."};let{quality:a,device:o}=bn(screen.width,screen.height,devicePixelRatio||1);return a?{ok:!0,type:t,quality:a}:{why:"This screen gives a "+o[0]+"\xD7"+o[1]+" frame, less than 720p. Use pro mode (OBS), or a larger screen."}}async function ro(){Yo++,de&&(cancelAnimationFrame(de.raf),de.stream.getTracks().forEach(e=>e.stop()),de.ctx.close().catch(()=>{}),de=null,Vo.value=0,ut.getContext("2d").clearRect(0,0,ut.width,ut.height),Mi())}function Mi(){Ko++,za&&(za.getTracks().forEach(e=>e.stop()),za=null),Ci.srcObject=null}async function Ti(){Mi();let e=Ko,t=pt.value;if(Ia.hidden=t!=="none"&&!!t,Ia.textContent="No camera",!(!t||t==="none"))try{let a=await navigator.mediaDevices.getUserMedia({video:t==="default"?!0:{deviceId:{exact:t}}});if(e!==Ko){a.getTracks().forEach(o=>o.stop());return}za=a,Ci.srcObject=a}catch{Ia.hidden=!1,Ia.textContent="The camera isn\u2019t available"}}async function Va(){await ro();let e=Yo;try{let t=kt.value,a=await navigator.mediaDevices.getUserMedia({audio:_i(t)});if(e!==Yo){a.getTracks().forEach(m=>m.stop());return}let o=new AudioContext,r=o.createAnalyser();r.fftSize=512,o.createMediaStreamSource(a).connect(r);let n=new Float32Array(r.fftSize),i=de={stream:a,ctx:o,raf:0},s=ut.getContext("2d"),l=ut.width,c=ut.height,d=Me("--accent"),M=()=>{if(de!==i)return;r.getFloatTimeDomainData(n);let m=0;for(let y of n)m=Math.max(m,Math.abs(y));Vo.value=Math.max(m,Vo.value*.85),s.clearRect(0,0,l,c),s.lineWidth=3,s.strokeStyle=d,s.lineJoin="round",s.beginPath();for(let y=0;y<n.length;y++){let b=y/(n.length-1)*l,p=c/2-Math.max(-1,Math.min(1,n[y]*3))*(c/2-4);y?s.lineTo(b,p):s.moveTo(b,p)}s.stroke(),i.raf=requestAnimationFrame(M)};M()}catch(t){ht.innerHTML='<span class="warn">The microphone isn\u2019t available: '+A(t.message||t.name)+". Allow it in the site settings.</span>"}}async function Ya(e=!0){try{e&&!de&&await Va();let t=await navigator.mediaDevices.enumerateDevices(),a=(n,i)=>{let s=t.filter(b=>b.kind===n),l=s.find(b=>b.deviceId==="default"),c=l?l.label.replace(/^Default - /,""):"",d=s.filter(b=>b.deviceId!=="default"&&b.deviceId!=="communications"),M=b=>!!l&&(b.label===c||!!l.groupId&&b.groupId===l.groupId&&!d.some(p=>p!==b&&p.label===c)),m=d.map((b,p)=>kn(b.label)||(n==="audioinput"?"Microphone ":"Camera ")+(p+1));m.forEach((b,p)=>{let T=m.slice(0,p).filter(L=>L===b).length;T&&(m[p]=b+" "+(T+1))});let y=d.some(b=>b.deviceId===i)||i==="none"?i:(d.find(M)||d[0]||{}).deviceId;return d.map((b,p)=>'<option value="'+A(b.deviceId)+'"'+(b.deviceId===y?" selected":"")+">"+A(m[p]+(M(b)?" (system default)":""))+"</option>").join("")},o=mr();pt.innerHTML='<option value="none"'+(o==="none"?" selected":"")+">No camera</option>"+a("videoinput",o);let r=W("slidetake:mic")||"";kt.innerHTML=a("audioinput",r),r&&kt.value===r&&de&&de.stream.getAudioTracks()[0].getSettings().deviceId!==r&&Va()}catch{}}function mr(){let e=W(Li());return e||(hc()?W("slidetake:cam")||"default":"none")}function pc(e){U(Li(),e),e!=="none"&&e!=="default"&&U("slidetake:cam",e)}function uc(){h.camWas=!re;let e=mr()!=="none";e!==!re&&pa(e,!0)}function Ai(){h.camWas!=null&&(h.camWas!==!re&&pa(h.camWas,!0),h.camWas=null)}async function Bi(){let e=ke();if(!e.ok)return ht.innerHTML='<span class="warn">'+A(e.why)+"</span>",e;Pa&&(ht.innerHTML='<span class="warn">'+A(Pa)+"</span>",Pa="");let t=lt.indexOf(e.quality),a=W("slidetake:quality");St.innerHTML=lt.slice(t).map(r=>"<option"+(r.name===a?" selected":"")+">"+r.name+"</option>").join("");let o="";try{let{quota:r,usage:n}=await navigator.storage.estimate(),i=lt.find(s=>s.name===St.value)||e.quality;o=" Room for about "+Math.floor((r-n)/xn(i))+" minutes of takes."}catch{}return ht.querySelector(".warn")||(ht.innerHTML='<span class="ok">Ready: this screen records up to '+e.quality.name+" in fullscreen."+A(o)+"</span>"),e}function fc(e){pe=e,U("slidetake:rec-mode",e),ea({setup:Bt()})}function ea(e={}){Ze&&(ke().ok&&(pe||"browser")==="browser"?kr(e):mc(e))}function mc(e={}){let t=no().find(a=>a.key===He()&&a.withObs&&!a.inBrowser);Gi(t||{key:He(),deckTitle:R.title||(g[0]?u.get(g[0]).title:"Deck"),date:new Date().toISOString(),withObs:!0,outputPath:null,reason:"",total:0,totalObs:null,fps:pr,events:[],picks:{},empty:!0},e)}async function gr(){if(!(!Ze||h.active||!g.length)){if(!gc()){Xo({note:"Set up once: after this, \u25CF Record (R) starts recording straight away."});return}if(ke().ok&&(pe||"browser")==="browser"){let t=Ta(tt(),lo()).filter(r=>!r.pick).map(r=>r.id),a=g.indexOf(f),o=t.length?t:a>0?g.slice(a):g;Ka("browser",o.length===g.length?null:o);return}if(!Le&&W("slidetake:obs")&&await fr(),Le){Ka("obs");return}Xo({note:"Connect to OBS first: OBS \u2192 Connect."})}}async function yr(e,t){return(await(await navigator.storage.getDirectory()).getDirectoryHandle("slidetake-takes",{create:!0})).getDirectoryHandle(e,{create:!!t})}async function vr(e){try{await(await(await navigator.storage.getDirectory()).getDirectoryHandle("slidetake-takes")).removeEntry(e,{recursive:!0})}catch{}}async function Ii(e){window.RestrictionTarget&&e.restrictTo?await e.restrictTo(await RestrictionTarget.fromElement(ja)):await e.cropTo(await CropTarget.fromElement(ja))}async function yc(e){try{window.RestrictionTarget&&e.track.restrictTo?await e.track.restrictTo(null):await e.track.cropTo(null),await Ii(e.track)}catch{}await e.track.applyConstraints(Oi(e.quality)).catch(()=>{}),await Zt()}async function vc(){let e=ke();if(!e.ok)throw new Error(e.why);let t=lt.find(s=>s.name===St.value)||e.quality;document.body.classList.add("rec-frame");let a=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:Ht},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),o=a.getVideoTracks()[0],r=()=>a.getTracks().forEach(s=>s.stop());if(!o.restrictTo&&!o.cropTo)throw r(),new Error("Share \u201Cthis tab\u201D to record the slides.");try{await Ii(o)}catch(s){throw r(),new Error("Chrome could not record just the slides ("+(s.message||s.name)+").")}await o.applyConstraints(Oi(t)).catch(()=>{});let n;try{let s=W("slidetake:mic");n=await navigator.mediaDevices.getUserMedia({audio:_i(s)})}catch(s){throw r(),new Error("The microphone isn\u2019t available ("+(s.message||s.name)+").")}let i=new Date().toISOString().replace(/[:.]/g,"-");h.browser={id:i,display:a,mic:n,track:o,quality:t,type:e.type,stream:new MediaStream([o,...n.getAudioTracks()]),dir:await yr(i,!0),clips:[],cur:null,chain:Promise.resolve(),error:null},o.addEventListener("ended",()=>{h.active&&!h.finishing&&Et("Sharing stopped")})}function Pi(){let e=h.browser;e&&(e.display.getTracks().forEach(t=>t.stop()),e.mic.getTracks().forEach(t=>t.stop()),document.body.classList.remove("rec-frame"))}function bc(e){let t=h.browser,a="take-"+t.clips.length+"."+Co(t.type),o={name:a,rec:null,done:null};t.clips.push(o),e.clip=t.id+"/"+a,t.chain=t.chain.then(async()=>{let r=await(await t.dir.getFileHandle(a,{create:!0})).createWritable(),n=new MediaRecorder(t.stream,{mimeType:t.type,videoBitsPerSecond:t.quality.bitrate,audioBitsPerSecond:Sa}),i=Promise.resolve();n.ondataavailable=l=>{l.data.size&&(i=i.then(()=>r.write(l.data)).catch(c=>{t.error=c}))},o.done=new Promise(l=>{n.onstop=async()=>{await i,await r.close().catch(()=>{}),l()}}),await new Promise(l=>{n.onstart=l,n.start(1e3)}),e.t=Math.round(xt()),e.cutAt!=null&&(e.lead=Math.max(0,Math.round(e.t-e.cutAt)));let s=t.cur;t.cur=o,o.rec=n,s&&s.rec.state!=="inactive"&&s.rec.stop()}).catch(r=>{t.error=r})}async function Ka(e,t){if(h.active||!g.length)return;let a=e==="obs";if(ro(),pe||(pe=a?"obs":"browser",U("slidetake:rec-mode",pe)),e==="browser"){K||ve(!0);try{await vc()}catch(l){document.body.classList.remove("rec-frame"),K&&ve(!1),Pa=l.name==="NotAllowedError"?"Recording needs this tab shared: press \u25CF Record again and choose Share.":l.message,kr({setup:!0});return}}la();let o=t&&t.length?t.filter(l=>g.includes(l)):null,r=o?o[0]:g[0],n=g[g.indexOf(r)-1]||null;Object.assign(h,{active:!0,withObs:a,counting:!0,paused:!1,finishing:!1,t0:0,pausedMs:0,events:[],outputPath:null,only:o?new Set(o):null}),e!=="browser"&&(h.browser=null),document.body.classList.add("recording"),Er(),K||ve(!0),uc(),n?(document.body.classList.add("no-anim"),u.get(n)._played=!0,Te=!0,j(n,!0,!0),Te=!1,P.getAnimations().forEach(l=>l.finish()),await Zt(),document.body.classList.remove("no-anim")):(f===r&&(we=0,ye=null,Ie=-1),j(r,!0)),!document.fullscreenElement&&document.documentElement.requestFullscreen&&await document.documentElement.requestFullscreen().catch(()=>{});let i=Ut.querySelector(".hint");for(let l=3;l>0;l--)if(i.textContent=(document.fullscreenElement?"":"Press F for fullscreen \xB7 ")+"recording starts after the countdown \xB7 Esc to cancel",Ut.querySelector(".num").textContent=l,Ut.classList.add("show"),await Qt(1e3),!h.active)return;if(Ut.classList.remove("show"),await Zt(),a){let l=new Promise(c=>{Ve=c,setTimeout(()=>{Ve&&(Ve(),Ve=null)},2500)});try{await ne.call("StartRecord")}catch(c){br("OBS could not start recording: "+(c&&c.message||c));return}if(await l,!h.active)return}h.browser&&await yc(h.browser),h.counting=!1,h.t0=performance.now();let s=u.get(r);if(n){ta("slide",r),h.browser&&await h.browser.chain,Xt(s),Te=!0,j(r),Te=!1;return}Xt(s),ia(!0),ta("slide",f)}function br(e){if(h.active=!1,h.counting=!1,h.browser){let t=h.browser;t.chain.then(()=>{t.cur&&t.cur.rec.state!=="inactive"&&t.cur.rec.stop()}).then(()=>vr(t.id)),Pi(),h.browser=null}Ut.classList.remove("show"),document.body.classList.remove("recording"),K&&ve(!1),Ai(),mt(e)}function ta(e,t,a){if(!h.active||!h.t0||h.finishing)return;let o=u.get(t),r={id:t,title:o?o.title:t,retake:e==="retake",t:Math.round(xt()),obsT:null};a==null&&h.browser&&(a=r.t),a!=null&&(r.cutAt=a,r.lead=Math.max(0,Math.round(r.t-a))),h.events.push(r),h.browser&&bc(r),h.withObs&&Le&&(ne.call("GetRecordStatus").then(n=>{n&&typeof n.outputDuration=="number"&&(r.obsT=n.outputDuration)}).catch(()=>{}),o&&ne.call("CreateRecordChapter",{chapterName:(r.retake?"RETAKE \xB7 ":"")+o.title}).catch(()=>{}))}function wc(e){let t=e.key;if((Wn.includes(t)||Un.includes(t)||qn.includes(t)||t==="Escape")&&e.preventDefault(),t==="Escape"){h.counting?br("Take cancelled"):Et("Stopped early");return}if((t==="f"||t==="F")&&!document.fullscreenElement&&document.documentElement.requestFullscreen){e.preventDefault(),document.documentElement.requestFullscreen().catch(()=>{});return}if(!(h.counting||h.finishing||Ke)){if(qn.includes(t)){Ec();return}h.paused||(Wn.includes(t)?xc():Un.includes(t)&&kc())}}function xc(){let e=Tt(u.get(f)),t=Math.min(we,e.length-1)>=e.length-1,a=g.indexOf(f);if(!t){De(1);return}if(!h.only){a===g.length-1?Et():De(1);return}let o=g.slice(a+1).find(r=>h.only.has(r));o?g[a+1]===o?De(1):zi(g[g.indexOf(o)-1],o,"slide"):Et()}async function kc(){let e=u.get(f);if(!e||Ke)return;let t=f,a=mi;if(!a||a===t||!u.has(a)){Sc(e);return}zi(a,t,"retake")}async function zi(e,t,a){let o=u.get(t);if(!o||Ke)return;Ke=!0;let r=xt();document.body.classList.add("no-anim");let n=u.get(e);Te=!0,n._played=!0,j(e,!0,!0),P.getAnimations().forEach(i=>i.finish()),Te=!1,await Zt(),document.body.classList.remove("no-anim"),ta(a,t,r),h.browser&&await h.browser.chain,h.withObs&&await Ri(),Xt(o),Te=!0,j(t),Te=!1,!oe&&!P.hidden&&Pe.used&&at(),Ke=!1}async function Ri(){let e=h.events[h.events.length-1];e&&(e.skip=Gn/2),await Qt(Gn)}async function Sc(e){Ke=!0,we=0,ye=null,Ie=-1,Xt(e),ia(!0),!oe&&!P.hidden&&Pe.used?at():xe(),Lt(),ta("retake",f),h.withObs&&await Ri(),Ke=!1}async function Ec(){if(h.t0)if(h.paused){if(Go.classList.remove("show"),await Zt(),h.withObs&&await ne.call("ResumeRecord").catch(()=>{}),h.browser){let e=h.browser;e.chain=e.chain.then(()=>{e.cur&&e.cur.rec.state==="paused"&&e.cur.rec.resume()})}h.pausedMs+=performance.now()-h.pauseAt,h.paused=!1,lr(u.get(f))}else{if(h.paused=!0,h.pauseAt=performance.now(),clearTimeout(bt),h.withObs&&await ne.call("PauseRecord").catch(()=>{}),h.browser){let e=h.browser;e.chain=e.chain.then(()=>{e.cur&&e.cur.rec.state==="recording"&&e.cur.rec.pause()})}Go.classList.add("show")}}async function Et(e){if(!h.active||h.finishing)return;if(h.counting){br("Take cancelled");return}h.finishing=!0,clearTimeout(bt),h.paused&&(h.pausedMs+=performance.now()-h.pauseAt,h.paused=!1,Go.classList.remove("show"));let t=Math.round(xt()),a=null;if(h.withObs){try{let n=await ne.call("GetRecordStatus");n&&typeof n.outputDuration=="number"&&(a=n.outputDuration)}catch{}await Qt(1200);try{let n=await ne.call("StopRecord");h.outputPath=n&&n.outputPath}catch(n){e=(e?e+". ":"")+"OBS did not confirm the stop ("+(n&&n.message||n)+")"}}let o=h.browser;o&&(await Qt(600),await o.chain,t=Math.round(xt()),o.cur&&o.cur.rec&&o.cur.rec.state!=="inactive"&&o.cur.rec.stop(),await Promise.all(o.clips.map(n=>n.done)),Pi(),h.browser=null,o.error&&(e=(e?e+". ":"")+"Some of the take could not be saved ("+(o.error.message||o.error.name)+")")),h.active=!1,h.finishing=!1,document.body.classList.remove("recording"),K&&ve(!1),Ai();let r={key:He(),deckTitle:R.title||u.get(g[0]).title,date:new Date().toISOString(),withObs:h.withObs,outputPath:h.outputPath,reason:e||"",total:t,totalObs:a,fps:o?Ht:pr,...o?{inBrowser:!0,takesId:o.id,quality:o.quality.name,type:o.type}:{},events:h.events.map(n=>({id:n.id,title:n.title,retake:n.retake,t:n.t,obsT:n.obsT,...n.lead?{lead:n.lead}:{},...n.skip?{skip:n.skip}:{},...n.clip?{clip:n.clip}:{}})),picks:{}};if(r.inBrowser){Ic(r);return}wr(r),Gi(r,{note:(e?e+". ":"")+me(r).size+" slides recorded with OBS."})}function He(){return nt(R.title||(g[0]?u.get(g[0]).title:"deck"))}function no(){try{return JSON.parse(W("slidetake:sessions")||"[]")}catch{return[]}}function wr(e){let t=no().filter(a=>a.date!==e.date);t.unshift(e),t.slice(12).forEach(a=>{a.takesId&&vr(a.takesId)}),U("slidetake:sessions",JSON.stringify(t.slice(0,12)))}function Ct(e){let t=u.has(e)?ao(e):[e];return t[Math.min(1,t.length-1)]}function Di(e,t){let a=Ct(e);return{sec:a,title:u.has(a)?u.get(a).title:t}}function B(e,{warn:t=!1,html:a="",title:o=""}={}){Wt.classList.toggle("warn",t),a?Wt.innerHTML=a:Wt.textContent=e,Wt.title=o||Wt.textContent;let r=document.getElementById("rv-save-again");r&&(r.onclick=()=>es(!0))}function Gi(e,t={}){la(),N=e,Z=null;let a=e.events.filter(i=>i.retake).length,o=e.empty?"":me(e).size+" slides, "+(a?a+" retake"+(a>1?"s":""):"no retakes")+", recorded "+it(e.totalObs??e.total)+". ";Y.classList.remove("in-browser","board"),Y.classList.add("obs");let r=document.getElementById("rv-rec");r.title="Records the deck with OBS: a new video in place of this one",r.disabled=!1,document.getElementById("rv-render-btn").disabled=document.getElementById("rv-clean").disabled=!!e.cleaned,document.getElementById("rv-file").textContent=e.outputPath?" ("+st(e.outputPath)+")":"";let n=xa(e);Ja.value=[...Ja.options].reduce((i,s)=>Math.abs(s.value-n)<Math.abs(i.value-n)?s:i).value,k.src&&(e.inBrowser||Fe!==st(e.outputPath)&&e.outputPath)&&(k.removeAttribute("src"),k.load(),Fe=""),document.getElementById("rv-novideo").hidden=!!k.src||!!e.empty,Z=null,F=null,At(),io(),sa(Y),t.setup?co(t):(ho(),Ya(!1).then(je)),B(t.note||(e.empty?Le?"Press \u25CF Record: OBS records the deck.":"Connect to OBS in Setup, then press \u25CF Record.":o+(k.src?"Click a take to preview it.":"Open the recording to preview it."))),e.empty||Fc(e)}function io(){if(N&&N.board){Qe();return}let e=N,t=document.getElementById("rv-list"),a=null;t.innerHTML=[...me(e).values()].map(o=>{let r=e.picks[o.id]??o.takes.length,n=Ct(o.id),i=n!==a;a=n;let s=o.takes.map(l=>'<button class="rv-chip'+(r===l.no?" on":"")+'" data-id="'+A(o.id)+'" data-take="'+l.no+'">Take '+l.no+" \xB7 "+it(l.end-l.start)+"</button>").join("");return'<div class="rv-row'+(i?" sec":"")+'"><div class="t">'+A(o.title)+"<small>"+fa(o.takes[0].start)+'</small></div><div class="rv-chips">'+s+"</div></div>"}).join(""),t.querySelectorAll(".rv-chip").forEach(o=>o.onclick=()=>{e.picks[o.dataset.id]=+o.dataset.take,wr(e),io();let r=me(e).get(o.dataset.id),n=r&&r.takes[+o.dataset.take-1];if(!n)return;let i=r.title+(r.takes.length>1?" \xB7 take "+n.no:"");if(e.inBrowser){let s=e.events.filter(l=>l.id===o.dataset.id)[n.no-1];s&&s.clip&&so([{clip:s.clip,keep:(n.end-n.start)/1e3,title:i}])}else Xa([{start:n.start,end:n.end,title:i}])}),document.getElementById("rv-ffmpeg-copy").disabled=document.getElementById("rv-play-final").disabled=!e.events.length,Yi(e),Ji(e)}function Yi(e){let t=Cc(e),a=document.getElementById("rv-chapters");Vi=t.lines.join(`
|
|
1315
|
-
`),a.disabled=t.lines.length<3,a.title=t.lines.length<3?"YouTube needs at least three chapters of 10 seconds or more":"Copies the "+t.lines.length+" chapters, to paste into the YouTube description"}function Ki(e,t){let a=e.dataset.label||(e.dataset.label=e.textContent);(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject()).catch(()=>{}),e.textContent="\u2713 Copied",clearTimeout(+e.dataset.timer),e.dataset.timer=String(setTimeout(()=>{e.textContent=a},1500))}async function Ji(e){let t=document.getElementById("rv-final"),a=++Fo,o=Nt(e).reduce((n,i)=>n+i.end-i.start,0),r=n=>(n?"about "+(n>1e9?(n/1e9).toFixed(1)+" GB":Math.max(1,Math.round(n/1e6))+" MB")+" \xB7 ":"Final cut ")+it(o);if(!e.inBrowser||e.cleaned){t.textContent=r(null);return}try{let n=0;for(let i of jt(e))Da.has(i.clip)||Da.set(i.clip,(await ca(i.clip)).size),n+=Da.get(i.clip);a===Fo&&(t.textContent=r(n))}catch{a===Fo&&(t.textContent=r(null))}}function Xa(e){if(!k.src){$a=e,B(Zo?"Opening the recording\u2026 it plays when ready.":"Open the recording to preview.");return}$a=null,Z={ranges:e,i:0},B("\u25B6 "+e[0].title);let t=()=>{k.currentTime=e[0].start/1e3,k.play().catch(a=>{a&&a.name!=="AbortError"&&B("Could not play: "+a.message,{warn:!0})})};k.readyState>=1?t():k.addEventListener("loadedmetadata",t,{once:!0})}function At(){ft=null}function xr(){let e=F&&!F.single&&!k.paused;$i.innerHTML=e?'\u275A\u275A <span><u class="key">P</u>ause</span>':'\u25B6 <span><u class="key">P</u>review</span>',document.querySelectorAll("#rv-list .rv-row.playing").forEach(o=>o.classList.remove("playing"));let t=F&&F.parts[F.i],a=t&&t.id&&document.querySelector('#rv-list .rv-row[data-id="'+CSS.escape(t.id)+'"]');a&&(a.classList.add("playing"),a.scrollIntoView({block:"nearest"}))}function Tc(e){let t=N?jt(N):[],a=t.findIndex(r=>r.id===e.id),o=a>=0?t[a+1]:null;ft=o?o.id:null,B(o?"Preview continues from "+o.title+".":"That was the last slide: Preview plays from the start.")}function Xi(e){return Array.from({length:e.numberOfChannels},(t,a)=>{let o=new Float32Array(e.numberOfFrames);return e.copyTo(o,{planeIndex:a,format:"f32-planar"}),o})}async function ca(e){let[t,a]=e.split("/");return(await(await yr(t)).getFileHandle(a)).getFile()}async function so(e,t=0,a=!1){if(!(!N||N.cleaned||!e.length)){Z=null,F={parts:e,i:t,single:a};try{let o=await ca(e[t].clip);if(!Y.classList.contains("open"))return;k.src&&URL.revokeObjectURL(k.src),k.src=URL.createObjectURL(o),B("\u25B6 "+e[t].title),await k.play()}catch(o){if(o&&o.name==="AbortError")return;F=null,B(o&&o.name==="NotFoundError"?"This take is no longer in the browser.":"Could not play this take: "+(o&&o.message||o),{warn:!0})}}}function Qi(){let e=F;if(e.i+1<e.parts.length){so(e.parts,e.i+1,e.single);return}F=null,k.pause(),e.single?Tc(e.parts[0]):B(""),xr()}async function Lc(e){if(!e.where)return!0;try{let t=await Sr("video-folder");return!t||t.name!==e.where||await t.queryPermission({mode:"readwrite"})!=="granted"||await t.getFileHandle(e.name),!0}catch{return!1}}async function es(e){let t=N;if(!t||!t.inBrowser||t.cleaned)return;let a=jt(t);if(!a.length){B("No slide has a take yet: nothing to save.",{warn:!0});return}let o=JSON.stringify([a.map(d=>[d.clip,Math.round(d.keep*1e3)]),Je(),aa(),t.type]),r=t.board&&O.lastDownload;if(!e&&r&&r.sig===o&&await Lc(r)){B("",{html:'<button class="btn small" id="rv-save-again">Save another copy</button> Already saved in '+A(No(r))+".",title:"Already saved in "+No(r)+". A new video is made only when a take or the sound settings change."});return}let n=Co(t.type||"")==="mp4",i=He()+" "+Bc(new Date)+"."+(n?"mp4":"webm"),s=null,l="";try{let d=await ts(!1);d&&(s=await(await d.getFileHandle(i,{create:!0})).createWritable(),l=d.name)}catch(d){if(d&&d.name==="AbortError")return}let c=Qa;c.disabled=!0,Ue("Preparing\u2026");try{let d=await import(dc),M=s?new d.StreamTarget(s):new d.BufferTarget,m=new d.Output({format:n?new d.Mp4OutputFormat({fastStart:s?!1:"in-memory"}):new d.WebMOutputFormat,target:M}),y=1,b="",p=Je()&&aa();if(Je()){let D=await Vn(d,a,1,!1,"Measuring");if(D&&isFinite(D.integrated)){let q=To(D,{limit:p});if(p&&Math.abs(q)>=.05){let Q=await Vn(d,a,Ma(q),!0,"Checking");Q&&isFinite(Q.integrated)&&(q=Math.min(q+(-14-Q.integrated),Mo))}y=Ma(q);let ce=p?-14:D.integrated+q,ae=!p&&To(D,{limit:!0})-q>.5;b=" \xB7 loudness "+D.integrated.toFixed(1)+(Math.abs(q)<.05?" LUFS, left as is":" \u2192 "+ce.toFixed(1)+" LUFS")+(ae?"; a loud peak held it back, turn on Peak limiter to reach "+-14:"")}}let T=y!==1||p;await Ac(d,a);let L=null,w=null,x=0,v=-1,S=-1,C=null,$=[],te=async()=>{for(;$.length&&C.ready()>=$[0].n;){let D=$.shift(),q=C.take(D.n),ce=new Float32Array(D.n*D.ch);q.forEach((ae,Q)=>ce.set(ae,Q*D.n)),await w.add(new d.AudioSample({data:ce,format:"f32-planar",numberOfChannels:D.ch,sampleRate:D.rate,timestamp:D.t}))}};for(let[D,q]of a.entries()){Ue("Joining "+(D+1)+"/"+a.length);let ce=new d.Input({source:new d.BlobSource(await ca(q.clip)),formats:d.ALL_FORMATS}),ae=await ce.getPrimaryVideoTrack(),Q=await ce.getPrimaryAudioTrack();if(!ae)throw new Error(q.title+" has no video");L||(L=new d.EncodedVideoPacketSource(await ae.getCodec()),m.addVideoTrack(L,{frameRate:Ht}),Q&&(w=T?new d.AudioSampleSource({codec:n?"aac":"opus",bitrate:Sa}):new d.EncodedAudioPacketSource(await Q.getCodec()),m.addAudioTrack(w)),await m.start());let It={decoderConfig:await ae.getDecoderConfig()},ot=0,Lr=!0;for await(let G of new d.EncodedPacketSink(ae).packets())G.timestamp>=q.keep||(v=Ea(v,x+G.timestamp),await L.add(G.clone({timestamp:v}),Lr&&D===0?It:void 0),Lr=!1,ot=Math.max(ot,G.timestamp+G.duration));if(Q&&w&&T)for await(let G of new d.AudioSampleSink(Q).samples(0,ot)){if(G.timestamp+G.duration>ot+1e-4){G.close();continue}S=Ea(S,x+G.timestamp);let ue=Xi(G);if(ue.forEach(fe=>{for(let rt=0;rt<fe.length;rt++)fe[rt]*=y}),p)C=C||Lo(G.sampleRate,ue.length),C.push(ue),$.push({t:S,n:G.numberOfFrames,rate:G.sampleRate,ch:ue.length}),G.close(),await te();else{let fe=G.numberOfFrames,rt=new Float32Array(fe*ue.length);ue.forEach((gs,ys)=>rt.set(gs,ys*fe)),await w.add(new d.AudioSample({data:rt,format:"f32-planar",numberOfChannels:ue.length,sampleRate:G.sampleRate,timestamp:S})),G.close()}}else if(Q&&w){let G={decoderConfig:await Q.getDecoderConfig()},ue=!0;for await(let fe of new d.EncodedPacketSink(Q).packets())fe.timestamp+fe.duration>ot+1e-4||(S=Ea(S,x+fe.timestamp),await w.add(fe.clone({timestamp:S}),ue&&D===0?G:void 0),ue=!1)}x+=ot}if(C&&(C.end(),await te(),C.events&&(b+=", "+C.events+" peak"+(C.events===1?"":"s")+" limited")),Ue("Finishing\u2026"),await m.finalize(),!s){let D=document.createElement("a");D.href=URL.createObjectURL(new Blob([M.buffer],{type:n?"video/mp4":"video/webm"})),D.download=i,D.click(),setTimeout(()=>URL.revokeObjectURL(D.href),1e4)}let X={sig:o,name:i,where:l};t.board&&(O.lastDownload=X,da()),B("Saved in "+No(X)+" ("+it(x*1e3)+b+")."),Ue("\u2713 Saved"),Zi=setTimeout(()=>Ue(),2500)}catch(d){Ue(),B("Could not save the video: "+(d&&d.message||d),{warn:!0}),s&&s.abort().catch(()=>{})}finally{c.disabled=!!t.cleaned}}async function Vn(e,t,a,o,r){let n=null,i=null;for(let[s,l]of t.entries()){Ue(r+" "+(s+1)+"/"+t.length);let c=await new e.Input({source:new e.BlobSource(await ca(l.clip)),formats:e.ALL_FORMATS}).getPrimaryAudioTrack();if(c)for await(let d of new e.AudioSampleSink(c).samples(0,l.keep)){let M=Xi(d);n=n||Cn(d.sampleRate,M.length),a!==1&&o?(M.forEach(m=>{for(let y=0;y<m.length;y++)m[y]*=a}),i=i||Lo(d.sampleRate,M.length),i.push(M),i.ready()&&n.add(i.take(i.ready()))):n.add(M),d.close()}}return i&&(i.end(),i.ready()&&n.add(i.take(i.ready()))),n?n.result():null}async function Ac(e,t){let a=[];for(let i of t){let s=await new e.Input({source:new e.BlobSource(await ca(i.clip)),formats:e.ALL_FORMATS}).getPrimaryVideoTrack(),l=s&&await s.getDecoderConfig();a.push(l?l.codec+" "+l.codedWidth+"\xD7"+l.codedHeight+" "+(l.description?[...new Uint8Array(l.description)].join("."):""):"none")}let o=new Map;a.forEach(i=>o.set(i,(o.get(i)||0)+1));let r=[...o.entries()].sort((i,s)=>s[1]-i[1])[0][0],n=t.filter((i,s)=>a[s]!==r);if(n.length)throw new Error(n.map(i=>i.title).join(", ")+(n.length===1?" was":" were")+" recorded at a different size ("+a[t.indexOf(n[0])].split(" ")[1]+", not "+r.split(" ")[1]+"). Tick "+(n.length===1?"it":"them")+" and record again")}async function ts(e){if(!window.showDirectoryPicker)return null;let t=e?null:await Sr("video-folder");if(t){let a=await t.queryPermission({mode:"readwrite"});if(a==="prompt"&&(a=await t.requestPermission({mode:"readwrite"})),a==="granted")return t}return t=await window.showDirectoryPicker({id:"slidetake-videos",mode:"readwrite",startIn:"videos"}),ns("video-folder",t),t}function tt(){let e=as();if(O&&$o===e)return O;$o=e;try{O=JSON.parse(W(e)||"null")}catch{O=null}return(!O||!Array.isArray(O.takes))&&(O={takes:[],picks:{},type:"",quality:""}),O}function Ic(e){tt();let t=An(e,e.takesId,lo());t.forEach(a=>{delete O.picks[a.id]}),O.takes.push(...t),Object.assign(O,{type:e.type,quality:e.quality}),da(),Be.clear(),kr({note:(e.reason?e.reason+". ":"")+t.length+" new take"+(t.length===1?"":"s")+" on the board."})}function os(){let e=Ta(tt(),lo()),t=Object.assign(Bn(e),{board:!0,inBrowser:!0,withObs:!1,type:O.type||"video/mp4",quality:O.quality||"",deckTitle:R.title||(g[0]?u.get(g[0]).title:"Deck"),date:new Date().toISOString()});return{rows:e,sess:t}}function co(e={}){Y.classList.add("setup-view"),Kn.textContent=e.note||"",Kn.hidden=!e.note,$e.textContent="\u2190 Back",$e.title="Back to Studio",$e.setAttribute("aria-expanded","true"),Pc()}function ho(){let e=Bt();e&&Y.classList.remove("setup-view"),$e.textContent="\u2699 Setup",$e.title="Settings: camera, microphone, video, OBS and files",$e.setAttribute("aria-expanded","false"),e&&(ro(),je())}function Xo(e={}){Y.classList.contains("open")?co(e):ea({...e,setup:!0})}function Pc(){let e=()=>{je(),Bt()&&Ti()};if(et()){cc(),Ya(!1).then(e);return}ht.innerHTML="",Bi().then(t=>{t.ok?Ya().then(e):e()})}function je(){let e=i=>{let s=i.selectedOptions[0];return s?s.textContent.replace(/ \(system default\)$/,""):""},t=e(pt)||(mr()==="none"?"No camera":"Camera"),a=et(),o=a?xi:ke().ok?St.value:"",r=a?[t]:[t,e(kt)||"Microphone"],n=document.getElementById("rv-using");n.textContent=r.join(" \xB7 "),n.title="Recording with "+r.join(" \xB7 "),document.getElementById("rv-size").textContent=o||"",dt.classList.toggle("on",a),dt.setAttribute("aria-pressed",String(a)),dt.disabled=!ke().ok,dt.title=dt.disabled?Fa+" records only with OBS: pro mode":a?"Pro mode: recording with OBS. Click for easy mode, in "+Fa:"Easy mode: recording in "+Fa+". Click for pro mode, with OBS"}function kr(e={}){Ze&&(la(),tt(),Y.classList.remove("obs"),Y.classList.add("in-browser","board"),document.getElementById("rv-rec").title="Records the whole deck, or only the ticked slides (shift-click ticks a range)",document.getElementById("rv-novideo").hidden=!0,k.src&&(URL.revokeObjectURL(k.src),k.removeAttribute("src"),k.load()),Z=null,F=null,At(),Ra=-1,Qe(),sa(Y),e.setup||!ke().ok?co(e):(ho(),Bi().then(()=>Ya(!1)).then(je)),B(e.note||qi()||(O.takes.length?zc()+". Click a take to preview it.":g.length+" slides, nothing recorded yet. Press \u25CF Record.")))}function zc(){let e=Ta(tt(),lo()),t=e.filter(o=>o.pick).length,a=e.filter(o=>o.takes.length&&!o.pick).length;return t+" of "+e.length+" slides ready"+(a?", "+a+" to record again":"")}function Qe(){let{rows:e,sess:t}=os();N=t;let a=document.getElementById("rv-list"),o=null;a.innerHTML=e.map(i=>{let s=Ct(i.id),l=s!==o;o=s;let c=A(i.id),d={slide:"Recorded before this slide changed",before:"Starts with the entry from the slide before, which has changed or is gone: record this slide again"},M=i.takes.length?i.takes.map(m=>'<button class="rv-chip'+(i.pick===m.uid?" on":"")+(m.outdated?' outdated" title="'+d[m.outdated]:"")+'" data-id="'+c+'" data-uid="'+A(m.uid)+'">Take '+m.no+" \xB7 "+it(m.ms)+"</button>").join("")+(i.pick?"":'<span class="rv-none">'+(i.takes.some(m=>m.outdated==="before")&&!i.takes.some(m=>m.outdated==="slide")?"The slide before changed: record again":"Changed since: record again")+"</span>"):'<span class="rv-none">No take yet</span>';return'<div class="rv-row with-sel'+(l?" sec":"")+(Be.has(i.id)?" selected":"")+'" data-id="'+c+'"><input type="checkbox" class="rv-sel" data-id="'+c+'"'+(Be.has(i.id)?" checked":"")+' aria-label="Select '+A(i.title)+' to record"><div><div class="t">'+A(i.title)+'</div><div class="rv-chips">'+M+"</div></div></div>"}).join(""),a.querySelectorAll(".rv-chip").forEach(i=>i.onclick=()=>{O.picks[i.dataset.id]=i.dataset.uid,da(),Qe();let s=e.find(c=>c.id===i.dataset.id),l=s&&s.takes.find(c=>c.uid===i.dataset.uid);l&&so([{id:s.id,clip:l.clip,keep:l.ms/1e3,title:s.title+" \xB7 take "+l.no}],0,!0)}),a.querySelectorAll(".rv-sel").forEach(i=>i.addEventListener("click",s=>{(s.shiftKey?On(g,Yn,i.dataset.id):[i.dataset.id]).forEach(c=>{i.checked?Be.add(c):Be.delete(c)}),At(),Yn=i.dataset.id,Qe()}));let r=La(g,Be),n=ke().ok;document.getElementById("rv-rec").disabled=!n,Ra>=0&&r.length!==Ra&&B(qi()||"Record takes the whole deck."),Ra=r.length,document.getElementById("rv-render-btn").disabled=document.getElementById("rv-play-final").disabled=!t.events.length,Yi(t),Ji(t)}async function Rc(e){for(let a of e)try{let[o,r]=a.clip.split("/");await(await yr(o)).removeEntry(r)}catch{}let t=new Set(e.map(a=>a.uid));O.takes=O.takes.filter(a=>!t.has(a.uid)),Object.keys(O.picks).forEach(a=>{t.has(O.picks[a])&&delete O.picks[a]}),da(),k.src&&(URL.revokeObjectURL(k.src),k.removeAttribute("src"),k.load()),F=null,At(),Qe()}function rs(e){return new Promise((t,a)=>{let o=indexedDB.open(e||"slidetake",1);o.onupgradeneeded=()=>o.result.createObjectStore("kv"),o.onsuccess=()=>t(o.result),o.onerror=()=>a(o.error)})}async function Sr(e){let t=async a=>{let o=await rs(a);return await new Promise(r=>{let n=o.transaction("kv").objectStore("kv").get(e);n.onsuccess=()=>r(n.result),n.onerror=()=>r(null)})};try{return await t()??await t("markcast")??await t("traverse")??null}catch{return null}}async function ns(e,t){try{(await rs()).transaction("kv","readwrite").objectStore("kv").put(t,e)}catch{}}async function po(e){Zo=!0;try{return await Dc(e)}finally{Zo=!1}}async function Dc(e){let t=await e.getFile();for(let a=0;a<10;a++){await new Promise(r=>setTimeout(r,1e3));let o=await e.getFile();if(o.size===t.size&&o.lastModified===t.lastModified)return o;t=o}return t}function ha(e,t,a){k.src&&URL.revokeObjectURL(k.src),qt=t||null,a||(Qo=0),k.src=URL.createObjectURL(e),Fe=e.name,document.getElementById("rv-novideo").hidden=!0,B("Loaded "+e.name+". Click a take to preview it."),$a?Xa($a):a&&Z&&Xa(Z.ranges.slice(Z.i))}async function Fc(e){let t=st(e.outputPath);if(!(!t||!window.showDirectoryPicker)&&!(Fe===t&&k.src))try{let a=await Sr("obs-folder");if(!a||await a.queryPermission({mode:"read"})!=="granted")return;let o=await a.getFileHandle(t);B("Opening "+t+"\u2026"),ha(await po(o),o)}catch{}}function mt(e,t){if(!h.active){if(clearTimeout(Na),!P.hidden&&!P.classList.contains("live")){Vt.classList.remove("show"),ss.textContent=e,P.classList.add("msg"),t||(Na=setTimeout(ls,9e3));return}Vt.textContent=e,Vt.classList.add("show"),t||(Na=setTimeout(()=>Vt.classList.remove("show"),9e3))}}function ls(){ss.textContent="PIP camera",P.classList.remove("msg")}function Er(){clearTimeout(Na),Vt.classList.remove("show"),ls()}function Ho(){let e=!1;try{e=window.top!==window.self}catch{e=!0}return e?" This page is running inside a preview frame that may not allow cameras. Open Slidetake directly in Chrome (from localhost or as a file).":window.isSecureContext?" Allow camera access for this page in the browser\u2019s site settings (the icon at the left of the address bar), then try again.":" Browsers only allow cameras on secure pages. Open it from http://localhost or as a local file in Chrome."}function Cr(){oe&&oe.getTracks().forEach(t=>t.stop()),oe=null;let e=P.querySelector("video");e&&e.remove()}async function at(){if(!(oe||re)){{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){mt("Camera not available on this page."+Ho(),!0);return}if(Ce.disabled)return;Ce.disabled=!0,mt("Waiting for camera permission \u2014 check the browser prompt near the address bar.",!0);try{let t=W("slidetake:cam");oe=await navigator.mediaDevices.getUserMedia({video:{...t?{deviceId:{ideal:t}}:{},width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},audio:!1}),Er()}catch(t){let a=t&&t.name;mt(a==="NotAllowedError"||a==="SecurityError"?"Camera access was blocked."+Ho():a==="NotFoundError"||a==="OverconstrainedError"?"No camera was found. Check that a webcam is connected.":a==="NotReadableError"?"The camera is busy \u2014 close other apps using it (Zoom, OBS, FaceTime) and try again.":"Could not start the camera"+(a?" ("+a+")":"")+"."+Ho(),!0);return}finally{Ce.disabled=!1,Mr()}oe.getVideoTracks().forEach(t=>t.addEventListener("ended",()=>{Cr(),_a(),xe()}));let e=document.createElement("video");e.autoplay=!0,e.muted=!0,e.playsInline=!0,e.srcObject=oe,P.appendChild(e)}_a(),xe()}}function cs(e,t){e.classList.toggle("on",t),e.setAttribute("aria-pressed",String(t))}function Mr(){Ce.querySelector("svg")||(Ce.innerHTML=Nc+'<span class="lbl"> <u class="key">C</u>amera</span>'),Ce.classList.toggle("on",!re),Ce.setAttribute("aria-pressed",String(!re)),Ce.title=re?"Camera is off for every slide (C)":"Camera is on and follows the deck (C)"}function pa(e,t){e&&!Ze||(re=!e,re&&(Cr(),Er()),ye=null,Ie=-1,we=Math.min(we,Math.max(0,Tt(u.get(f)).length-1)),Mr(),_a(),ia(),Lt(),xe(),!K&&!t&&mt(e?"Camera on \u2014 slides follow their camera settings.":"Camera off \u2014 camera settings are ignored and slides use the whole screen."),e&&at())}function ds(){document.body.classList.remove("idle"),clearTimeout(Jn),K&&(Jn=setTimeout(()=>document.body.classList.add("idle"),2e3))}function oa(e,t){gt.textContent=e,gt.classList.add("show"),clearTimeout(Xn),Xn=setTimeout(()=>gt.classList.remove("show"),t||2500)}function er(e,{keepObs:t=!0,keepEdit:a=!0,slide:o=""}={}){let r=new URL(rn(e),location.origin);return new URLSearchParams(location.search).forEach((n,i)=>{i==="src"||i==="obs"&&!t||i==="edit"&&!a||r.searchParams.set(i,n)}),o&&(r.hash=o),r.href.replace(r.pathname,r.pathname.replace(/%40/g,"@"))}async function jc(e){let t={keepObs:!1,keepEdit:!1,slide:e};if(E.kind==="source")return{link:er(E.source,t),inside:!1};if(E.kind==="copy"&&ba(I)&&["url","gist","builtin"].includes(I.origin.kind))return{link:er(I.origin,t),inside:!1};let o=E.kind==="share"?E.data:await sn(ie.value),r=new URLSearchParams(location.search);return["src","obs","edit"].forEach(n=>r.delete(n)),{link:location.origin+"/share"+(r.toString()?"?"+r:"")+xo(o,e),inside:!0}}function _c(){let e=W("slidetake:draft");if(!e||e===uo)return null;let t=ya(e,{kind:"file",name:"your earlier draft"},{exported:!0});U("slidetake:copy",JSON.stringify(t));try{localStorage.removeItem("slidetake:draft")}catch{}return t}function ua(){U("slidetake:copy",JSON.stringify(I))}function Ot(){if(_)return;let e;if(Tr())e='<span class="mine">'+A(he.file)+'</span> <span class="ro">\xB7 on this computer, saved as you type</span>';else if(E.kind==="copy")e='<span class="mine">Your copy of '+A(Se(I.origin))+"</span>"+(va(I)?' <span class="edited">\xB7 edited</span>':"");else{let a=E.kind==="share"?"a shared deck":Se(E.source);e='<span class="mine">'+A(a.charAt(0).toUpperCase()+a.slice(1))+'</span> <span class="ro">\xB7 read-only, typing makes your copy</span>'}document.getElementById("doc-state").innerHTML=e,Ne.classList.toggle("unsaved",E.kind==="copy"&&va(I)),document.getElementById("btn-reset").hidden=!(E.kind==="copy"&&!ba(I));let t=document.getElementById("continue");t.hidden=E.kind==="copy"||!I,I&&(t.textContent="Your copy \u2192",t.title="Continue your copy of "+Se(I.origin))}function hs(e){return!I||!va(I)?!0:confirm("Your copy of "+Se(I.origin)+" has edits you haven't saved or shared. Replace it with "+e+"?")}function ps(){let e=new URLSearchParams(location.search);return e.delete("src"),e.delete("template"),"/edit"+(e.toString()?"?"+e:"")}function Wc(){let e=E.kind==="share"?{kind:"shared"}:E.source;return hs("a copy of "+Se(e))?(I=ya(E.text,e),E={kind:"copy"},history.pushState(null,"",ps()+(f&&f!==g[0]?"#"+encodeURIComponent(f):"")),oa("Editing your own copy of "+Se(e)+". The original is unchanged.",4e3),!0):(ie.value=E.text,!1)}function Uc(){E={kind:"copy"},history.pushState(null,"",ps()),Ne.classList.contains("collapsed")&&oo(),ie.value=I.text,wt(!0),Ot()}function Tr(){return!!(he&&E&&E.kind==="source"&&E.source.kind==="url"&&new URL(E.source.url,location.href).pathname===he.deck)}function qc(e){fetch(he.save,{method:"PUT",body:e}).catch(()=>oa("Could not save "+he.file+": is npx slidetake still running?",6e3))}async function Gc(e){if(e.kind==="builtin")return Ha[e.id==="help"?"docs":e.id]??Ha.home;if(e.kind==="gist"){let a=await fetch("https://api.github.com/gists/"+encodeURIComponent(e.id));if(!a.ok)throw new Error(a.status===404?"no such gist":a.status+" "+a.statusText);let o=Object.values((await a.json()).files||{}),r=o.find(n=>n.filename===e.file)||o.find(n=>/\.(md|markdown)$/i.test(n.filename))||o[0];if(!r)throw new Error("the gist has no files");return ze=r.raw_url,r.truncated?await(await fetch(r.raw_url)).text():r.content}let t=await fetch(e.url);if(!t.ok)throw new Error(t.status===404?"not found":t.status+" "+t.statusText);return ze=new URL(e.url,location.href).href,await t.text()}function ei(){return E={kind:"source",source:{kind:"builtin",id:"home"},text:Ha.home},E.text}async function Vc(){if(he&&ee.page==="source"&&ee.source.kind==="builtin"&&ee.source.id==="home"&&location.pathname==="/"&&(ee.source={kind:"url",url:he.deck}),_)return ze=_.base||location.href,E={kind:"source",source:{kind:"url",url:ze},text:Xr(_.settings||{})+String(_.markdown||"")},E.text;if(ee.page==="edit"){if(I)return E={kind:"copy"},I.text;history.replaceState(null,"","/new"+location.search),ee.page="pick"}if(ee.page==="pick")return sa(document.getElementById("new-dialog")),E={kind:"source",source:{kind:"builtin",id:"template:blank"},text:Ha["template:blank"]},E.text;if(ee.page==="share")try{let e=await ln(ee.data);return E={kind:"share",data:ee.data,text:e},e}catch{return oa("This link's deck is damaged or cut short, so it could not be opened.",6e3),ei()}try{let e=await Gc(ee.source);return E={kind:"source",source:ee.source,text:e},e}catch(e){return Jt.textContent="Could not load the deck ("+e.message+")",oa("Could not load "+Se(ee.source)+": "+e.message,6e3),ei()}}var _,he,or,Ze,Mt,Ha,ie,H,se,Bo,Pn,Us,Jt,jo,qs,Ne,Aa,Gs,yt,Oo,le,_o,Vs,Ys,Ks,Js,$s,Xs,$t,u,g,Ye,f,rr,J,K,R,re,oe,Ae,P,ja,z,Yt,Zs,zn,_e,Rn,we,ye,Ie,Pe,ul,fl,yl,li,Po,wl,ze,Fn,Ml,Tl,Ll,Nn,Ol,Ba,Il,Rl,Dl,zo,We,Ro,qe,Re,Kl,bt,ge,mi,Te,Ge,Ee,Oa,Do,ct,_n,tc,Wn,Un,qn,Y,Ut,Go,Ua,qa,Ga,hr,Kt,ne,Le,Ve,pr,xi,h,Qt,Zt,ac,ur,oc,Si,ic,lc,dc,pt,kt,St,Vo,ht,ut,pe,Pa,de,Yo,Ci,Ia,za,Ko,hc,Li,et,gc,Oi,Ke,Gn,Fe,Cc,Mc,Fi,Je,Ni,Jo,aa,Hi,ji,_i,Wi,Ui,N,Z,k,Wt,Ra,qi,Vi,Da,Fo,Ja,$a,$i,ft,F,Qa,Zi,Ue,No,Bc,O,$o,Yn,Be,as,da,Oc,lo,$e,Kn,Bt,Fa,dt,qt,Qo,Zo,Gt,is,Ce,Vt,Na,ss,Nc,Jn,be,$n,gt,Xn,Hc,tr,ar,Qn,Za,ee,Zn,E,I,us=V(()=>{"use strict";Ir();Pr();Rr();Fr();Hr();_r();Ur();Gr();ma();Zr();an();bo();ko();hn();un();En();Mn();In();ka();_=window.SLIDETAKE||null;document.getElementById("deck-text")?.remove();he=window.SLIDETAKE_LOCAL||null,or=document.querySelector("header .mark .logo").outerHTML;document.documentElement.classList.toggle("embed",!!_);Ze=!_||_.recording===!0;document.documentElement.classList.toggle("no-record",!Ze);Mt=window.matchMedia("(prefers-reduced-motion: reduce)").matches,Ha={home:uo,docs:zr,features:Dr,privacy:Nr,showcase:Vr,"template:blank":jr,"template:talk":Wr,"template:recording":qr},ie=document.getElementById("editor"),H=document.getElementById("stage"),se=document.getElementById("world"),Bo=document.getElementById("connectors"),Pn=document.getElementById("breadcrumbs"),Us=document.getElementById("status-count"),Jt=document.getElementById("status-err"),jo=document.getElementById("mm-svg"),qs=document.getElementById("mm-label"),Ne=document.getElementById("editor-pane"),Aa=540,Gs=96,yt=440,Oo=720,le=960,_o=180,Vs=540,Ys=100,Ks=110,Js=420,$s=.35,Xs=1,$t=parseFloat(W("slidetake:slideSize"))||.92,u=new Map,g=[],Ye=[],f=null,rr=["focus","path","radial","tree"],J="path",K=!1,R={},re=!0,oe=null,Ae=document.getElementById("brand"),P=document.getElementById("pip"),ja=document.getElementById("stage-wrap"),z={x:0,y:0,zoom:.6},Yt=null;Zs='<span class="st-name">'+or+'Slide<span class="st-take">take</span></span>';zn={accent:"--accent",accentSoft:"--accent-teal",line:"--accent-line",ring:"--accent-ring",header:"--header-bg",headerText:"--header-ink",onAccent:"--on-accent"};_e=null;Rn=new URLSearchParams(location.search).get("mode");we=0;ye=null,Ie=-1,Pe=null;ul=new Set("svg g defs symbol use path rect circle ellipse line polyline polygon text tspan textPath title desc marker linearGradient radialGradient stop clipPath mask pattern filter feGaussianBlur feOffset feBlend feFlood feComposite feMerge feMergeNode feColorMatrix feDropShadow".split(" ")),fl=0;yl=e=>e.querySelector("img")&&!e.textContent.trim()&&[...e.children].every(t=>/^(IMG|BR)$/.test(t.tagName));li=["dot","d2","echarts","svg"].map(e=>":scope > code.language-"+e).join(", "),Po=e=>!!e.querySelector("img")&&!e.textContent.trim(),wl=e=>e.children.length===1&&(e.children[0].tagName==="PRE"&&!!e.children[0].querySelector(li)||e.children[0].matches("div.diagram"));ze=null;Fn=null;Ml="https://cdn.jsdelivr.net/npm/@viz-js/viz@3.4.0/lib/viz-standalone.js",Tl="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js",Ll={dark:{palette:["#60a5fa","#f472b6","#a78bfa","#fb923c","#facc15","#a1a1aa"],text:"#e4e4e7",muted:"#a1a1aa",line:"#3f3f46",split:"#27272a",tip:"#18181b"},light:{palette:["#2563eb","#db2777","#7c3aed","#ea580c","#ca8a04","#71717a"],text:"#27272a",muted:"#71717a",line:"#d4d4d8",split:"#e4e4e7",tip:"#ffffff"}};Nn=new Set;Ol="https://esm.sh/@terrastruct/d2@0.1.33",Ba=null,Il={dark:{N1:"#e4e4e7",N2:"#a1a1aa",N3:"#a1a1aa",N4:"#323238",N5:"#27272a",N6:"#18181b",N7:"#09090b"},light:{N1:"#27272a",N2:"#71717a",N3:"#71717a",N4:"#e4e4e7",N5:"#e4e4e7",N6:"#f4f4f5",N7:"#ffffff"}};Rl=(e,t)=>e.replace("{","{"+t),Dl=e=>/d2-config\s*:/.test(e)?e:`vars: {
|
|
1430
|
+
`+m+"ffmpeg -f concat -safe 0 -i /tmp/slidetake-cuts.txt -i /tmp/slidetake-chapters.txt"+f+" -c copy -movflags +faststart "+Ma(s)}let b=Ta(e),p=y=>(y/b).toFixed(6),T=y=>((y-.5)/b).toFixed(6),C=i.map(y=>"gte(t,"+T(y.f0)+")*lt(t,"+T(y.f1)+")").join("+"),w=i.map(y=>"gte(t,"+p(y.f0)+")*lt(t,"+p(y.f1)+")").join("+"),x=t==="mac"?"-c:v h264_videotoolbox -b:v 12M":"-c:v libx264 -crf 18 -preset medium";return m+"ffmpeg -i "+Ma(a)+" -i /tmp/slidetake-chapters.txt"+f+` -vf "select='`+C+`',setpts=N/FRAME_RATE/TB" -af "asetnsamples=n=48:p=0,aselect='`+w+"',asetpts=N/SR/TB"+(n?",loudnorm=I=-14:TP=-1:LRA=11":"")+'"'+(n?" -ar 48000":"")+" "+x+" -c:a aac -b:a 192k -movflags +faststart "+Ma(s)}var En,Ta,Cn,mt,$s,Ma,Mn,La=G(()=>{"use strict";xa();En=e=>e.obsT??e.t,Ta=e=>e.fps||60,Cn=(e,t)=>Math.round(e*t/1e3);mt=e=>String(e||"").split(/[\\/]/).pop()||"",$s=e=>{let t=Math.max(String(e).lastIndexOf("/"),String(e).lastIndexOf("\\"));return t>=0?String(e).slice(0,t+1):""},Ma=e=>"'"+String(e).replace(/'/g,"'\\''")+"'",Mn=e=>(e/1e3).toFixed(3)});function Xs(e,t,a){let o=a?.5625:1.7777777777777777,r=Math.min(e,t*o),n=r/o;return{w:r,h:n,x:(e-r)/2,y:(t-n)/2}}function An(e,t,a,o){let r=Xs(e,t,o),n=[Math.floor(r.w*a),Math.floor(r.h*a)];return{quality:ft.find(i=>{let s=Ba(i,o);return n[0]>=s.w&&n[1]>=s.h})||null,device:n}}function Yt(e){let t=new Map;e.events.forEach((o,r)=>{t.has(o.id)||t.set(o.id,[]),t.get(o.id).push(r)});let a=[];return be(e).forEach(o=>{let r=e.picks[o.id]??o.takes.length,n=r?o.takes[r-1]:null;if(!n)return;let i=e.events[t.get(o.id)[r-1]];i&&i.clip&&n.end>n.start&&a.push({id:o.id,title:o.title,clip:i.clip,keep:(n.end-n.start)/1e3})}),a}var ft,Aa,gt,Ba,Qs,Bn,Io,On,Oa,In,Pn,zn=G(()=>{"use strict";La();ft=[{name:"1080p",w:1920,h:1080,bitrate:8e6},{name:"720p",w:1280,h:720,bitrate:5e6}],Aa=192e3,gt=30,Ba=(e,t)=>t?{...e,w:e.h,h:e.w}:e;Qs=["video/mp4;codecs=avc1.640028,mp4a.40.2","video/mp4;codecs=avc1,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"],Bn=e=>Qs.find(t=>e(t))||"",Io=e=>e.startsWith("video/mp4")?"mp4":"webm",On=e=>Math.round((e.bitrate+Aa)/8*60);Oa=(e,t)=>t>e?t:e+.001,In=e=>e.replace(/\s*\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i,""),Pn=(e,t)=>Math.min(e,t)+"p"+(t>e?" portrait":"")});function Zs(e){let t=1681.974450955533,a=.7071752369554196,o=Math.tan(Math.PI*t/e),r=Math.pow(10,3.999843853973347/20),n=Math.pow(r,.4996667741545416),i=1+o/a+o*o,s={b0:(r+n*o/a+o*o)/i,b1:2*(o*o-r)/i,b2:(r-n*o/a+o*o)/i,a1:2*(o*o-1)/i,a2:(1-o/a+o*o)/i};t=38.13547087602444,a=.5003270373238773,o=Math.tan(Math.PI*t/e),i=1+o/a+o*o;let l={b0:1,b1:-2,b2:1,a1:2*(o*o-1)/i,a2:(1-o/a+o*o)/i};return{shelf:s,highPass:l}}function Rn(e,t){let{shelf:a,highPass:o}=Zs(e),r=Math.round(e/10),n=[],i=Array.from({length:t},()=>new Float64Array(8)),s=d=>d>=3&&d<=4?1.41:1,l=0,c=0;return{add(d){let k=d[0].length;for(let m=0;m<t;m++){let f=d[m]||d[0],b=i[m],p=s(m),[T,C,w,x,y,E,L,$]=b,ae=l,X=Math.floor(ae/r),D=(X+1)*r,q=0;for(let de=0;de<k;de++){let oe=f[de];oe>c?c=oe:-oe>c&&(c=-oe);let Q=a.b0*oe+a.b1*T+a.b2*C-a.a1*w-a.a2*x;C=T,T=oe,x=w,w=Q;let Wt=o.b0*Q+o.b1*y+o.b2*E-o.a1*L-o.a2*$;E=y,y=Q,$=L,L=Wt,q+=Wt*Wt,++ae===D&&(n[X]=(n[X]||0)+p*q,q=0,X++,D+=r)}q&&(n[X]=(n[X]||0)+p*q),b.set([T,C,w,x,y,E,L,$])}l+=k},result(){let d=Math.floor(l/r),k=[];for(let p=3;p<d;p++)k.push(((n[p-3]||0)+(n[p-2]||0)+(n[p-1]||0)+(n[p]||0))/(4*r));let m=p=>p.reduce((T,C)=>T+C,0)/p.length,f=k.filter(p=>Ia(p)>-70),b=f.length?f.filter(p=>Ia(p)>Ia(m(f))-10):[];return{integrated:b.length?Ia(m(b)):-1/0,peak:c,peakDb:c>0?el(c):-1/0}}}}function zo(e,{limit:t=!1,target:a=-14,ceiling:o=-1.5}={}){if(!isFinite(e.integrated))return 0;let r=Math.min(a-e.integrated,Po);return r<=0||t||e.peakDb==null||!isFinite(e.peakDb)?r:Math.max(0,Math.min(r,o-e.peakDb))}function Ro(e,t,a={}){let o=Pa(a.ceilingDb??-1.5),r=Math.max(1,Math.round((a.lookahead??.005)*e)),n=1-Math.exp(-1/((a.release??.05)*e)),i=Array.from({length:t},()=>[]),s=[],l=[],c=new Float64Array(r),d=0,k=r,m=1,f=!1,b=0,p=0;c.fill(1);let T=C=>{for(;l.length&&l[l.length-1][1]>=C;)l.pop();for(l.push([d,C]);l[0][0]<=d-r;)l.shift();let w=l[0][1];if(m=w<m?w:m+(w-m)*n,m>.999&&(m=1),k+=m-c[d%r],c[d%r]=m,d>=r-1){let x=k/r,y=x>.999?1:x;s.push(y),y<.999&&!f&&b++,f=y<.999}d++};return{push(C){let w=C[0].length;for(let x=0;x<w;x++){let y=0;for(let E=0;E<t;E++){let L=(C[E]||C[0])[x];i[E].push(L),L>y?y=L:-L>y&&(y=-L)}T(y>o?o/y:1)}},ready:()=>s.length-p,take(C){let w=Array.from({length:t},()=>new Float32Array(C));for(let x=0;x<C;x++){let y=s[p+x];for(let E=0;E<t;E++)w[E][x]=i[E][p+x]*y}return p+=C,p>65536&&(s.splice(0,p),i.forEach(x=>x.splice(0,p)),p=0),w},end(){for(let C=0;C<r-1;C++){for(let w=0;w<t;w++)i[w].push(0);T(1)}},get events(){return b}}}var el,Ia,Po,Pa,Dn=G(()=>{"use strict";el=e=>20*Math.log10(e),Ia=e=>-.691+10*Math.log10(e);Po=20;Pa=e=>Math.pow(10,e/20)});function Fn(e){let t=2166136261;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Nn(e,t){return e.map((a,o)=>{let r=e[o-1]||"";return{id:a,title:t(a).title,fp:t(a).fp,prev:r,prevFp:r?t(r).fp:""}})}function Hn(e,t,a){let o=new Map(a.map(i=>[i.id,i])),r=new Map;e.events.forEach(i=>{r.has(i.id)||r.set(i.id,[]),r.get(i.id).push(i)});let n=[];return be(e).forEach(i=>i.takes.forEach((s,l)=>{let c=r.get(i.id)[l];if(!c||!c.clip||s.end<=s.start)return;let d=o.get(i.id);d&&n.push({uid:c.clip,id:i.id,title:i.title,clip:c.clip,ms:s.end-s.start,run:t,date:e.date,fp:d.fp,prev:d.prev,prevFp:d.prevFp,at:s.start})})),n.sort((i,s)=>i.at-s.at).map(({at:i,...s})=>s)}function za(e,t){return t.map(a=>{let o=e.takes.filter(i=>i.id===a.id).map((i,s)=>({...i,no:s+1,outdated:i.fp!==a.fp?"slide":(i.prev??null)!==a.prev||i.prevFp!==a.prevFp?"before":""})),r=e.picks[a.id],n=null;if(r&&o.some(i=>i.uid===r))n=r;else{let i=o.filter(s=>!s.outdated);n=i.length?i[i.length-1].uid:null}return{id:a.id,title:a.title,takes:o,pick:n}})}function jn(e){let t=[],a=0;return e.forEach(o=>{let r=o.pick?o.takes.find(n=>n.uid===o.pick):null;r&&(t.push({id:o.id,title:o.title,t:a,clip:r.clip}),a+=r.ms)}),{events:t,picks:{},total:a}}function Ra(e,t){let a=new Set(t);return e.filter(o=>a.has(o))}function Wn(e,t,a){let o=t?e.indexOf(t):-1,r=e.indexOf(a);return o<0||r<0?[a]:e.slice(Math.min(o,r),Math.max(o,r)+1)}var _n=G(()=>{"use strict";La()});var sd={};function j(e){try{let t=localStorage.getItem(e);if(t!==null||!e.startsWith("slidetake:"))return t;let a=e.slice(10);return localStorage.getItem("slidetake:"+a)??localStorage.getItem("traverse:"+a)}catch{return null}}function W(e,t){try{localStorage.setItem(e,t)}catch{}}function dl(e){try{return{html:window.marked?window.marked.parse(e):"<pre>"+A(e)+"</pre>",err:null}}catch{return{html:"<p>(could not render)</p>",err:"render error"}}}function pl(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:o=>/Slidetake/.test(o.nodeValue||"")&&!o.parentElement?.closest("code, pre, kbd, svg, em, .st-name")?1:2}),a=[];for(;t.nextNode();)a.push(t.currentNode);a.forEach(o=>{let r=document.createElement("span");r.innerHTML=A(o.nodeValue||"").replace(/Slidetake/g,hl),o.replaceWith(...r.childNodes)})}function Ya(){let e=R.brand||"",t=R.logo||"",a=/^chip$/i.test(R.brand_style||""),o=/^slidetake$/i.test(e)?'<span class="st-mark">'+hr+'<span class="word">Slide<span>take</span></span></span>':(t?'<img alt="" src="'+A(t)+'">':"")+(e?"<span"+(a?' class="chip"':"")+">"+A(e)+"</span>":"");if(ze.dataset.html!==o){ze.dataset.html=o,ze.innerHTML=o;let n=ze.querySelector("img");n&&(n.onload=n.onerror=()=>fe(!0))}ze.hidden=!o;let r=document.body.classList.contains("portrait");document.body.classList.toggle("portrait",Ie()),r!==Ie()&&fe(!0),Pe(),document.title=R.title||"Slidetake",ml(),hi()}function ul(){let e=String(R.accent||"").trim();if(!e||!window.CSS||!CSS.supports("color",e))return null;if(!CSS.supports("color","oklch(from red l c h)"))return{accent:e,line:e};let t=a=>"oklch(from "+e+" "+a+" c h)";return{dark:{accent:t(.8),accentSoft:t(.87),line:t(.5)},light:{accent:t(.45),accentSoft:t(.4),line:t(.75),ring:t(.7)}}}function ml(){let e="",t=(o,r)=>{let n=Object.entries(r||{}).filter(([i,s])=>qn[i]&&s&&typeof s!="object").map(([i,s])=>qn[i]+":"+String(s).replace(/[;{}<>]/g,"")).join(";");n&&(e+=o+"{"+n+`}
|
|
1431
|
+
`)};[ul(),U&&U.colors].filter(Boolean).forEach(o=>{["dark","light"].forEach(r=>{let n={...o,...o[r]||{}},i=r==="dark";n.accent&&typeof n.accent=="string"&&(n.accentSoft=n.accentSoft||n.accent,n.line=n.line||"color-mix(in srgb, "+n.accent+(i?" 45%, #09090b)":" 55%, #fff)"),n.ring=n.ring||(i?n.accent:n.line),n.onAccent=n.onAccent||(i?"color-mix(in srgb, "+n.accent+" 15%, #000)":"#fff")),t(i?'body:not([data-mode="light"])':'body[data-mode="light"]',n)})});let a=document.getElementById("st-colors");a||(a=document.createElement("style"),a.id="st-colors",document.head.appendChild(a)),a.textContent!==e&&(a.textContent=e),document.body.classList.toggle("st-header-color",e.includes("--header-bg"))}function Le(e){let t=document.createElement("span");t.style.color="var("+e+")",document.body.appendChild(t);let a=getComputedStyle(t).color;return t.remove(),Je=Je||Object.assign(document.createElement("canvas"),{width:1,height:1}).getContext("2d",{willReadFrequently:!0}),Je.clearRect(0,0,1,1),Je.fillStyle="#000",Je.fillStyle=a,Je.fillRect(0,0,1,1),"#"+[...Je.getImageData(0,0,1,1).data.slice(0,3)].map(o=>o.toString(16).padStart(2,"0")).join("")}function fl(e,t,a){let o=i=>[1,3,5].map(s=>parseInt(i.slice(s,s+2),16)),r=o(e),n=o(t);return"#"+r.map((i,s)=>Math.round(i*a+n[s]*(1-a)).toString(16).padStart(2,"0")).join("")}function so(){if(U&&U.themeKey&&!Vn){let t=j(U.themeKey);return t==="light"||t==="dark"?t:matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return String(Vn||j("slidetake:mode")||R.mode||"dark").toLowerCase()==="light"?"light":"dark"}function hi(){let e=so()==="light";e?document.body.dataset.mode="light":delete document.body.dataset.mode;let t=document.getElementById("btn-mode");t&&(t.innerHTML=e?'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>':'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4.5"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>',t.title=(e?"Dark theme":"Light theme")+" (L)",t.setAttribute("aria-label",t.title))}function pi(){let e=so()==="light"?"dark":"light";U&&U.themeKey?(W(U.themeKey,e),document.documentElement.classList.toggle("dark",e==="dark")):W("slidetake:mode",e),hi(),se.querySelector(".echarts-container, .diagram.d2, .diagram.dot")&&At(!0)}function gl(){let t=(R.camera||"").replace(/^\[|\]$/g,"").split(",").map(a=>a.trim().replace(/^["']|["']$/g,"")).filter(Boolean);return t.length?t:["on","full","off"]}function Ko(e){if(!e)return[];let t=hn(e.camera);return!te||t.some(yl)?t:[]}function yl(e){return!!Ke({},e).behind}function Rt(e){return pn(Ko(e),e&&e.frags?e.frags.length:0)}function ui(){let e=Rt(u.get(g));return e[Math.min(ke,e.length-1)]||{cam:0,frag:0}}function bl(){if(!g)return null;let e=u.get(g),t=Ko(e);if(t.length)return t[Math.min(ui().cam,t.length-1)];if(e&&e.el&&e.el.classList.contains("card-full"))return"off";for(let a=v.indexOf(g)-1;a>=0;a--){let o=Ko(u.get(v[a]));if(o.length)return Ke({},o[o.length-1]).behind?null:o[o.length-1]}return null}function vl(){let e={corner:(R.pip||"none").toLowerCase(),size:So(parseFloat(R.pip_size)||(Ie()?40:24)),circle:(R.pip_shape||"").toLowerCase()==="circle",mirror:Fi(),full:!1,off:!1,flip:!1,used:!1,card:50};if(/^(behind|under)\b/.test(e.corner)){let t=e.corner;e.corner="bottom-right",Ke(e,t)}return Ke(e,bl()),ve&&!/\b(off|hide)\b/i.test(ve)&&(e.off=!1),Ke(e,ve),!Vt.includes(e.corner)&&(re||e.used)&&(e.corner="bottom-right"),e.flip&&Vt.includes(e.corner)&&(e.corner=e.corner.includes("left")?e.corner.replace("left","right"):e.corner.replace("right","left")),e}function Pe(){let e=!B.hidden&&B.offsetWidth?B.getBoundingClientRect():null,t=Ne=vl();t.behind&&(!g||ue)&&(t.full=!1,t.behind=!1);let a=Vt.includes(t.corner),o=te&&!!t.behind&&!t.off;B.className=a?[t.corner,t.circle&&"circle",re&&"live",t.mirror&&"mirror",t.full&&"full",t.behind&&"behind",o&&"empty",B.classList.contains("msg")&&"msg"].filter(Boolean).join(" "):"",B.style.width=t.full?"":t.size+"%",B.hidden=!a||t.off||te&&!o,ce.dataset.pip=B.hidden||t.full?"none":t.corner,ce.classList.toggle("cam-behind",!B.hidden&&!!t.behind),ce.style.setProperty("--cam-card",String((t.card||0)/100)),ce.classList.toggle("cam-card",(t.card||0)>0),ce.classList.toggle("cam-solid",(t.card||0)>=100),ce.classList.toggle("cam-live",!B.hidden&&!!t.behind&&!o);let r=!!Ae;if(Ie()&&/^(left|right)$/.test(t.place||"")&&(t.place="bottom"),Jo(!B.hidden&&t.behind&&t.place||""),Ae&&!r&&e&&!Ue&&Me.animate&&Me.animate([{opacity:0},{opacity:1}],{duration:300,delay:550,easing:"ease-out",fill:"backwards"}),B.hidden||Ue||!B.animate)return;let n="cubic-bezier(.65,0,.35,1)";if(!e){B.animate([{opacity:0},{opacity:1}],{duration:300,easing:"ease-out"});return}let i=B.getBoundingClientRect();if(Math.abs(e.left-i.left)+Math.abs(e.top-i.top)+Math.abs(e.width-i.width)+Math.abs(e.height-i.height)<2)return;let s=Math.max(e.width/i.width,e.height/i.height),l=e.left+e.width/2-(i.left+i.width/2),c=e.top+e.height/2-(i.top+i.height/2),d=Math.max(0,(i.width-e.width/s)/2),k=Math.max(0,(i.height-e.height/s)/2),m=parseFloat(getComputedStyle(B).borderTopLeftRadius)||0;B.animate([{transformOrigin:"50% 50%",transform:"translate("+l+"px,"+c+"px) scale("+s+")",clipPath:"inset("+k+"px "+d+"px round "+10/s+"px)"},{transformOrigin:"50% 50%",transform:"none",clipPath:"inset(0px 0px round "+m+"px)"}],{duration:600,easing:n})}function Jo(e){let t=Ae,a=Me.querySelector(".cam-box"),o=a&&a.getBoundingClientRect();Ae=e,ce.dataset.place=e,Me.innerHTML="";let r=e&&u.get(g);if(!r||!r.el)return;let n=r.el.querySelector(".body"),i=[...n.children].map(k=>{let m=k.cloneNode(!0);return[m,...m.querySelectorAll("[style]")].forEach(f=>{f.style.removeProperty("opacity"),f.style.removeProperty("transform"),f.style.removeProperty("visibility")}),[m,...m.querySelectorAll("[data-text]")].forEach(f=>{f.dataset.text&&(f.textContent=f.dataset.text)}),m}),s=k=>k.matches("figure.media, .diagram, .echarts-container, .gallery"),l=[[e,i]],c=n.clientWidth;l.forEach(([k,m])=>{if(!m.length)return;let f=document.createElement("div");f.className="cam-box "+k;let b=(p,T)=>{if(!T.length)return;let C=document.createElement("div");C.className=p;let w=document.createElement("section");w.className="node";let x=document.createElement("div");x.className="body",T.forEach(y=>x.appendChild(y)),w.appendChild(x),p==="cam-media"&&(w.style.width=c+"px"),C.appendChild(w),f.appendChild(C)};b("cam-text",m.filter(p=>!s(p))),b("cam-media",m.filter(s)),Me.appendChild(f)}),Me.querySelectorAll("img").forEach(k=>{k.complete||k.addEventListener("load",$o,{once:!0})}),$o();let d=Me.querySelector(".cam-box");if(o&&t&&t!==e&&d&&!Ue&&d.animate){let k=d.getBoundingClientRect();Math.abs(o.width-k.width)<2&&Math.abs(o.height-k.height)<2&&d.animate([{transform:"translate("+(o.left-k.left)+"px,"+(o.top-k.top)+"px)"},{transform:"none"}],{duration:600,easing:"cubic-bezier(.65,0,.35,1)"})}}function $o(){let e=N.clientHeight/240;Me.querySelectorAll(".cam-media").forEach(t=>{let a=t.firstElementChild,o=Math.min(t.clientWidth/a.offsetWidth,t.clientHeight/a.offsetHeight,e*1.5);a.style.transform="translate(-50%, -50%) scale("+o+")"}),Me.querySelectorAll(".cam-text").forEach(t=>{let a=t.firstElementChild,o=t.clientWidth,r=t.clientHeight,n=.3,i=e;for(let s=0;s<12;s++){let l=(n+i)/2;a.style.width=o/l+"px",a.offsetHeight*l<=r?n=l:i=l}a.style.width=o/n+"px",a.style.transform="scale("+n+")"})}function wl(){let e=Ne;if(!e||B.hidden||e.full)return null;let t=N.clientWidth,a=N.clientHeight,o=16,r=t*e.size/100,n=e.circle?r:r*9/16,i=e.corner.includes("left")?o:t-o-r,s=e.corner.includes("top")?o:a-o-n;return{x0:i,y0:s,x1:i+r,y1:s+n}}function xl(){if(!Ge)return;if(te){Ht(!0);return}let e=gl();Fe=(Fe+1)%e.length,ve=e[Fe],Pe(),K||Et("Camera: "+ve),!re&&!B.hidden?ct():fe()}function mi(e){let t=cn(e,{render:dl});R=t.deck,u=t.nodes,Ya();let a={"+++":"+++ format",reveal:"reveal.js format",headings:"headings"}[t.format];tl.textContent=u.size+(u.size===1?" card":" cards")+" \xB7 "+a,aa.textContent=t.errCount?t.errCount+" card(s) had errors":""}function fi(){tt=[...u.values()].filter(o=>!o.parent).map(o=>o.id);let e=0;function t(o,r){let n=u.get(o);if(n.depth=r,n.children.length===0)n._slot=e++;else{n.children.forEach(s=>t(s,r+1));let i=n.children.map(s=>u.get(s)._slot);n._slot=(Math.min(...i)+Math.max(...i))/2}}tt.forEach(o=>t(o,0)),v=[];function a(o){v.push(o),u.get(o).children.forEach(a)}return tt.forEach(a),Math.max(1,e)}function kl(){let e=[],t=[],a=[];return u.forEach(o=>{e[o.depth]=Math.max(e[o.depth]||0,o._h),t[o.depth]=Math.max(t[o.depth]||0,o._w),a[o.depth]=(a[o.depth]||0)+1}),{maxH:e,maxW:t,count:a,maxDepth:e.length-1}}function gi(e){e.x!==null&&!isNaN(e.x)&&(e.cx=e.x+e._w/2),e.y!==null&&!isNaN(e.y)&&(e.cy=e.y+e._h/2)}function Sl(){let{maxH:e,maxDepth:t}=kl(),a=[0];for(let l=1;l<=t;l++)a[l]=a[l-1]+e[l-1]+nl;let o=rl-Mt,r=[],n=(l,c)=>{let d=u.get(l);d.cx+=c,d.children.forEach(k=>n(k,c))},i=l=>{let c=u.get(l);r[c.depth]=Math.max(r[c.depth]??-1/0,c.cx+c._w/2),c.children.forEach(i)};function s(l){let c=u.get(l),d=r[c.depth]!==void 0?r[c.depth]+o:-1/0;c.children.length?(c.children.forEach(s),c.cx=(u.get(c.children[0]).cx+u.get(c.children[c.children.length-1]).cx)/2,c.cx-c._w/2<d&&n(l,d-(c.cx-c._w/2))):c.cx=(d===-1/0?0:d)+c._w/2,i(l)}tt.forEach(s),u.forEach(l=>{l.cy=a[l.depth]+l._h/2,gi(l)})}function El(e){let t=Math.PI*2/e,a=32,o=[],r=(s,l)=>Math.abs(s.cx-l.cx)<(s._w+l._w)/2+a&&Math.abs(s.cy-l.cy)<(s._h+l._h)/2+a,n=Math.max(0,...[...u.values()].map(s=>s.depth)),i=0;for(let s=0;s<=n;s++){let l=[...u.values()].filter(d=>d.depth===s);if(!l.length)continue;let c=s===0?tt.length>1?sl*.5:0:i+il;for(let d=0;d<400&&(l.forEach(m=>{let f=(m._slot+.5)*t-Math.PI/2;m.cx=c*Math.cos(f),m.cy=c*Math.sin(f),gi(m)}),!!l.some((m,f)=>l.some((b,p)=>p>f&&r(m,b))||o.some(b=>r(m,b))));d++)c=c*1.02+10;i=c,o.push(...l)}}function Cl(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),a=[];for(;t.nextNode();)a.push(t.currentNode);a.forEach(o=>{let r=o.data.match(/^\s*\.element:\s*([\s\S]*)$/);if(!r)return;let n=o.previousSibling;for(;n&&n.nodeType===3&&!n.data.trim();)n=n.previousSibling;let i=n&&n.nodeType===1?n:o.parentElement;i&&Object.entries(Ut(r[1])).forEach(([s,l])=>{s==="class"?i.classList.add(...l.split(/\s+/).filter(Boolean)):s==="style"?i.style.cssText+=";"+l:i.setAttribute(s,l)})})}function Ll(e){let t=new DOMParser().parseFromString(e,"image/svg+xml"),a=t.documentElement;if(!a||a.localName!=="svg"||t.getElementsByTagName("parsererror").length)return null;let o=a.namespaceURI,r=i=>{[...i.children].forEach(s=>{s.namespaceURI!==o||!Ml.has(s.localName)?s.remove():r(s)}),[...i.attributes].forEach(s=>{let l=s.name.toLowerCase(),c=s.value;(l.startsWith("on")||/javascript:|expression\(/i.test(c)||/url\(\s*['"]?(?!#)/i.test(c)||(l==="href"||l==="xlink:href")&&!c.trim().startsWith("#"))&&i.removeAttribute(s.name)})};r(a);let n="st-svg"+ ++Tl+"-";return[a,...a.querySelectorAll("*")].forEach(i=>[...i.attributes].forEach(s=>{let l=s.name==="id"?n+s.value:s.value.replace(/url\(\s*(['"]?)#/g,"url($1#"+n);(s.name==="href"||s.name==="xlink:href")&&l.startsWith("#")&&(l="#"+n+l.slice(1)),l!==s.value&&(s.value=l)})),document.importNode(a,!0)}function De(e,t){let a=e.classList.contains("fragment");["fragment","fade-up","visible","current-fragment"].forEach(o=>{e.classList.contains(o)&&(t.classList.add(o),e.classList.remove(o))}),e.dataset.fragmentIndex!==void 0&&(t.dataset.fragmentIndex=e.dataset.fragmentIndex,delete e.dataset.fragmentIndex),e.replaceWith(t),a&&u.forEach(o=>o.frags&&o.frags.forEach(r=>{let n=r.indexOf(e);n>=0&&(r[n]=t)}))}function Ho(e){let t=document.createElement("figure");t.className="media",De(e,t),t.appendChild(e);let a=e.getAttribute("alt");return a&&t.insertAdjacentHTML("beforeend","<figcaption>"+A(a)+"</figcaption>"),t}function Al(e,t){let a=document.createElement("figure");return a.className="media yt fragment yt-play"+(e.portrait?" portrait":""),a.innerHTML='<div class="frame"><iframe src="'+kn(e)+'" title="'+A(t||"YouTube video")+'" allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen loading="lazy"></iframe></div>'+(t?"<figcaption>"+A(t)+"</figcaption>":""),a}function Gn(e,t){let a=t<=4?t:t<=6?3:4;e.style.setProperty("--cols",a),e.style.setProperty("--rows",Math.ceil(t/a))}function Ol(e,t){t.querySelectorAll("pre > code.language-svg").forEach(n=>{let i=Ll(n.textContent.trim()),s=document.createElement("div");s.className=i?"diagram svg":"diagram err",i?s.appendChild(i):s.textContent="SVG error: not a valid <svg> drawing",De(n.parentElement,s)}),t.querySelectorAll(":scope > p").forEach(n=>{let i=n.children.length===1?n.children[0]:null;if(!i)return;let s=i.tagName==="A"&&n.textContent.trim()===i.textContent.trim()?i.getAttribute("href"):i.tagName==="IMG"?i.getAttribute("src"):null,l=s&&Bo(s);l&&De(n,Al(l,i.tagName==="IMG"?i.getAttribute("alt"):""))}),t.querySelectorAll(":scope > ul, :scope > ol").forEach(n=>{let i=[...n.children];!i.length||!i.every(s=>jo(s)||Pl(s))||(n.classList.add("gallery"),i.some(s=>!jo(s))&&n.classList.add("diagrams"),i.forEach(s=>{if(!jo(s))return;let l=s.querySelector("img");s.innerHTML="",s.appendChild(l),Ho(l)}),i.length>1&&i.every(s=>s.classList.contains("fragment"))?(n.classList.add("carousel"),i[0].classList.remove("fragment","fade-up"),i.forEach((s,l)=>{s.classList.replace("fade-up","current-visible");let c=s.querySelector("figcaption");c&&(c.dataset.count=l+1+" / "+i.length)})):Gn(n,i.length))}),t.querySelectorAll(":scope > p").forEach(n=>{if(!Bl(n))return;let i=[...n.querySelectorAll("img")];if(i.length===1){De(n,i[0]),Ho(i[0]);return}let s=document.createElement("div");s.className="gallery grid",De(n,s),i.forEach(l=>{s.appendChild(l),Ho(l)}),Gn(s,i.length)});let a=[...t.children].filter(n=>!/^H[1-6]$/.test(n.tagName)&&!(n.nodeType===1&&n.tagName==="HR")),o=a.filter(n=>n.matches("figure.media"));o.length===1&&a.length===1&&e.classList.add("card-media");let r=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT);for(;r.nextNode();)/^\s*view\s*:\s*full\s*$/i.test(r.currentNode.data)&&e.classList.add("card-full");if(a.length===1&&(a[0].matches("figure.media:not(.yt)")||a[0].matches(".gallery.carousel:not(.diagrams)")))e.classList.add("card-bleed");else if(o.length===1&&a.length>1&&!o[0].matches(".yt")){e.classList.add("card-split",a.indexOf(o[0])===0?"media-first":"media-last");let n=document.createElement("div");n.className="split-text",a.filter(i=>i!==o[0]).forEach(i=>n.appendChild(i)),o[0].after(n),a.indexOf(o[0])!==0&&n.after(o[0])}t.querySelector(".gallery")&&e.classList.add("card-gallery")}function yi(e,t){let a=e.querySelector("iframe");a&&a.contentWindow&&a.contentWindow.postMessage(JSON.stringify({event:"command",func:t,args:[]}),"*")}function Il(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),a=[];for(;t.nextNode();)/^\s*steps\s*$/i.test(t.currentNode.data)&&a.push(t.currentNode);a.forEach(o=>{for(let r=o.nextSibling;r&&!(r.nodeType===8&&/^\s*steps\s*:\s*off\s*$/i.test(r.data));r=r.nextSibling)r.nodeType!==1||r.classList.contains("fragment")||(/^(UL|OL)$/.test(r.tagName)?r.querySelectorAll(":scope > li").forEach(n=>n.classList.add("fragment","fade-up")):r.classList.add("fragment","fade-up"))})}function zl(e){let t=r=>r.classList.contains("fragment")&&(r.tagName==="P"&&r.children.length===1&&r.children[0].tagName==="IMG"&&!r.textContent.trim()&&!Bo(r.children[0].getAttribute("src")||"")||r.tagName==="PRE"&&!!r.querySelector(bi)),a=[],o=[];[...e.children].forEach(r=>{t(r)?o.push(r):(o.length>1&&a.push(o),o=[])}),o.length>1&&a.push(o),a.forEach(r=>{let n=document.createElement("ul");r[0].before(n),r.forEach(i=>{let s=document.createElement("li");s.className="fragment fade-up",i.classList.remove("fragment","fade-up"),s.appendChild(i),n.appendChild(s)})})}function Rl(e){let t=[...e.querySelectorAll(".fragment")].map((r,n)=>({e:r,i:n,k:r.dataset.fragmentIndex}));if(t.every(r=>r.k===void 0))return t.map(r=>[r.e]);let a=0;t.forEach(r=>{r.k=r.k===void 0?a:parseFloat(r.k),a=Math.max(a,r.k)+1}),t.sort((r,n)=>r.k-n.k||r.i-n.i);let o=[];return t.forEach((r,n)=>{n&&t[n-1].k===r.k?o[o.length-1].push(r.e):o.push([r.e])}),o}function ur(e,t,a){!e||!e.frags||(a&&e.el.classList.add("snap"),e.frags.forEach((o,r)=>o.forEach(n=>{let i=n.classList.contains("visible");n.classList.toggle("visible",r<t),n.classList.toggle("current-fragment",r===t-1),n.classList.contains("yt-play")&&i!==r<t&&!a&&yi(n,r<t?"playVideo":"pauseVideo")})),a&&(e.el.offsetWidth,e.el.classList.remove("snap")))}function Dl(){try{return R.base?new URL(R.base,He||location.href):He?new URL(He):null}catch{return null}}function Fl(e){let t=Dl(),a=0;return e.querySelectorAll("img[src], source[src], video[src], iframe[src], a[href]").forEach(o=>{let r=o.hasAttribute("src")?"src":"href",n=o.getAttribute(r);if(!n||/^(#|[a-z][a-z0-9+.-]*:|\/\/)/i.test(n))return;if(!t){r==="src"&&!n.startsWith("/")&&a++;return}let i=t;try{R.site&&(i=new URL(R.site,t))}catch{}o.setAttribute(r,new URL(n,n.startsWith("/")?i:t).href)}),a}function lo(e){let t=e.el,a=t.querySelector(".body");t.classList.add("measuring"),a.style.zoom="";let o=Mt;e.visual=!!a.querySelector("iframe, .echarts-container, pre > code.language-dot, pre > code.language-d2, pre > code.language-echarts, .diagram, figure.media"),e.visual&&(o=le);let r=t.classList.contains("card-full");if(t.classList.remove("img-portrait","img-landscape","img-overlay","img-cover"),r&&(o=le),t.classList.contains("card-bleed")){let l=Math.max(0,...[...a.querySelectorAll("img")].map(d=>d.naturalWidth&&d.naturalHeight?d.naturalWidth/d.naturalHeight:0))||1.7777777777777777,c=le-Da*l>=260;if(r&&c)t.classList.add("img-portrait"),t.style.setProperty("--img-w",Math.round(Da*l)+"px"),o=le;else if(r||Math.abs(l-16/9)<.08)t.classList.add("img-overlay"),o=le,l>=16/9&&l<=16/9*1.15&&t.classList.add("img-cover");else if(l<1.3){let d=Math.min(Math.round(Da*l),le-300);t.classList.add("img-portrait"),t.style.setProperty("--img-w",d+"px"),o=Math.min(le,Math.max(No,d*2))}else t.classList.add("img-landscape"),o=Math.round(Math.max(Mt,Math.min(le,(Da-ol)*l))),t.style.setProperty("--img-h",Math.round(o/l)+"px")}else(a.querySelector('[style*="flex"], [style*="grid"], .r-hstack')||a.querySelectorAll("img").length>=4)&&(o=No);let n=a.querySelectorAll("table");if(n.length){t.style.width=le+"px";let l=t.offsetWidth-a.clientWidth;n.forEach(c=>{o=Math.max(o,Math.min(No,Math.ceil(c.offsetWidth)+l+12))})}let i=a.querySelectorAll("pre");if(i.length){t.style.width=le+"px";let l=t.offsetWidth-a.clientWidth;i.forEach(c=>{c.style.width="max-content",o=Math.max(o,Math.min(le,Math.ceil(c.offsetWidth)+l+2)),c.style.width=""})}let s=a.querySelectorAll(".fragment.grow");if(s.length){t.style.width=o+"px";let l=t.offsetWidth-a.clientWidth;s.forEach(c=>{o=Math.max(o,Math.min(le,Math.ceil(c.offsetWidth*1.3)+l))})}t.style.width=o+"px",t.scrollWidth>o+2&&(t.style.width=(o=Math.min(le,t.scrollWidth+24))+"px"),a.scrollWidth>a.clientWidth+2&&(a.style.zoom=(a.clientWidth/a.scrollWidth).toFixed(3)),e._w=o,e._h=t.offsetHeight||Yo,t.classList.remove("measuring")}function Nl(){clearTimeout(Yn),Yn=setTimeout(()=>{u.forEach(lo),ha(),fe(!0)},200)}function _l(){let e=so()==="light"?"light":"dark",t=Le(e==="light"?"--accent-ring":"--accent"),a="slidetake-"+e+"-"+t.slice(1);return Kn.has(a)||(Ul(a,Wl[e],t),Kn.add(a)),a}function Ul(e,t,a){let o={axisLine:{lineStyle:{color:t.line}},axisTick:{lineStyle:{color:t.line}},axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.split}},nameTextStyle:{color:t.muted}};echarts.registerTheme(e,{color:[a,...t.palette],backgroundColor:"transparent",textStyle:{color:t.text,fontFamily:"'IBM Plex Sans', sans-serif"},title:{textStyle:{color:t.text},subtextStyle:{color:t.muted}},legend:{textStyle:{color:t.text}},tooltip:{backgroundColor:t.tip,borderColor:t.line,textStyle:{color:t.text}},categoryAxis:o,valueAxis:o,logAxis:o,timeAxis:o,line:{symbolSize:6,lineStyle:{width:2.5}},pie:{label:{color:t.text,textBorderWidth:0},labelLine:{lineStyle:{color:t.muted}}},funnel:{label:{color:t.text,textBorderWidth:0}}})}function Gl(){let e=so()==="light"?"light":"dark",t=Le("--node-bg"),a=Le(e==="dark"?"--accent":"--accent-line"),o=e==="dark"?[.58,.38,.25,.18,.12]:[.7,.45,.25,.15,.08],r={...Vl[e],N7:t,B1:Le("--accent")};return o.forEach((n,i)=>{r["B"+(i+2)]=fl(a,t,n)}),r}function Yl(){let e=Le("--text"),t=Le("--text-muted"),a=Le("--accent"),o='"Helvetica,Arial,sans-serif"';return' graph [bgcolor=transparent color="'+t+'" fontcolor="'+e+'" fontname='+o+'] node [color="'+a+'" fontcolor="'+e+'" fontname='+o+'] edge [color="'+t+'" fontcolor="'+t+'" fontname='+o+"] "}function Xo(e){return Wo[e]||(Wo[e]=new Promise((t,a)=>{let o=document.createElement("script");o.src=e,o.onload=t,o.onerror=()=>{delete Wo[e],a(new Error("could not load "+e))},document.head.appendChild(o)}))}async function $l(){let e=$e,t=[...se.querySelectorAll(".node pre > code.language-dot")];se.querySelectorAll(".node pre > code.language-echarts").forEach(n=>{let i=document.createElement("div");i.className="echarts-container",i.dataset.chart=n.textContent,De(n.parentElement,i)});let a=[...se.querySelectorAll(".node .echarts-container[data-chart]")],o=[...se.querySelectorAll(".node pre > code.language-d2")];if(!t.length&&!a.length&&!o.length)return;let r=[];if(t.length)try{if(await Xo(Hl),_o=_o||await Viz.instance(),e!==$e)return;let n=Yl();t.forEach(i=>{let s=document.createElement("div");s.className="diagram dot";try{s.appendChild(_o.renderSVGElement(Kl(i.textContent,n)))}catch(l){s.className="diagram err",s.textContent="Diagram error: "+l.message}De(i.parentElement,s)})}catch{r.push("diagrams")}if(o.length)try{if(!Fa){let i=await import(ql);Fa=new i.D2}if(e!==$e)return;let n=Gl();for(let i of o){let s=document.createElement("div");s.className="diagram d2";try{let l=await Fa.compile(Jl(i.textContent));s.innerHTML=await Fa.render(l.diagram,{...l.renderOptions||{},themeOverrides:n,darkThemeOverrides:n})}catch(l){s.className="diagram err",s.textContent="Diagram error: "+(l.message||l)}if(e!==$e)return;De(i.parentElement,s)}}catch{r.push("D2 diagrams")}if(a.length)try{if(await Xo(jl),e!==$e)return;let n=_l();a.forEach(i=>{let s;try{s=JSON.parse(i.dataset.chart)}catch{i.textContent="Chart data is not valid JSON.";return}let l=echarts.init(i,n,{renderer:"svg"});l.on("finished",()=>{Ae&&i.closest(".node")===(u.get(g)||{}).el&&Jo(Ae)}),l.setOption(Object.assign({backgroundColor:"transparent",animation:!Ue},s))})}catch{r.push("charts")}e===$e&&(Ae&&Jo(Ae),r.length&&(aa.textContent="Could not load the "+r.join(" and ")+" renderer (offline?)"),u.forEach(lo),ha(),fe(!0))}function Xl(){let e=[];return v.forEach(t=>{let a=zt(t),o=e[e.length-1];o&&o.sec===a?o.ids.push(t):e.push({sec:a,ids:[t]})}),e}function Ql(){let a=0,o=0,r=0;Xl().forEach((n,i)=>{let s=Math.max(...n.ids.map(d=>u.get(d)._h));i&&(a+=r/2+120+s/2);let l=o,c=o;n.ids.forEach((d,k)=>{let m=u.get(d);k&&(l+=90+m._w/2),m.cx=l,m.cy=a,c=l,l+=m._w/2}),o=c,r=s})}function Zl(){u.forEach(e=>{e.cx=0,e.cy=0})}function vi(){$e++,window.echarts&&se.querySelectorAll(".echarts-container").forEach(a=>{let o=echarts.getInstanceByDom(a);o&&o.dispose()}),se.querySelectorAll("div.node").forEach(a=>a.remove());let e=fi(),t=0;u.forEach(a=>{let o=document.createElement("div");o.className="node",o.tabIndex=0,o.dataset.id=a.id;let r=a.parent?co(a.id).slice(0,-1).map(i=>u.get(i).title).join(" / "):"";o.innerHTML=(r?'<div class="crumb">'+A(r)+"</div>":"")+'<div class="body">'+a.html+"</div>"+(a.err?'<div class="err-badge">!</div>':"");let n=o.querySelector(".body");Cl(n),Il(n),zl(n),Ol(o,n),/^slidetake$/i.test(R.brand||"")&&pl(n),n.querySelectorAll("thead").forEach(i=>{i.textContent.trim()||i.remove()}),t+=Fl(n),a.frags=Rl(n),n.querySelectorAll("img").forEach(i=>{i.complete||i.addEventListener("load",Nl,{once:!0})}),o.querySelectorAll("a[href]").forEach(i=>{let s=i.getAttribute("href");if(s.startsWith("#")){let l=decodeURIComponent(s.slice(1));u.has(l)&&(i.classList.add("xlink"),i.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),h.active||_(l)}))}else i.target="_blank",i.rel="noopener",i.addEventListener("click",l=>l.stopPropagation())}),o.addEventListener("click",()=>{h.active||_(a.id)}),o.addEventListener("keydown",i=>{i.key==="Enter"&&i.target===o&&_(a.id)}),se.appendChild(o),a.el=o,ur(a,a.frags.length)}),t&&!aa.textContent&&(aa.textContent=t+" image(s) use relative paths: add base: to the deck, or open it with ?src="),u.forEach(lo),ha(e),$l()}function ha(e){e===void 0&&(e=fi()),J==="radial"?El(e):J==="path"?Ql():J==="focus"?Zl():Sl(),se.classList.toggle("focus",J==="focus"),u.forEach(t=>{let a=t.el.style;a.setProperty("--cx",t.cx),a.setProperty("--cy",t.cy)}),ec(),Dt(),gr()}function ec(){let e="";if(J==="focus"){Fo.innerHTML="";return}if(J==="path"){for(let t=1;t<v.length;t++){let a=u.get(v[t-1]),o=u.get(v[t]);e+='<path data-from="'+a.id+'" data-to="'+o.id+'" d="M '+a.cx+" "+a.cy+" L "+o.cx+" "+o.cy+'"/>'}Fo.innerHTML=e;return}u.forEach(t=>{if(!t.parent)return;let a=u.get(t.parent);if(J==="radial")e+='<path data-from="'+a.id+'" data-to="'+t.id+'" d="M '+a.cx+" "+a.cy+" L "+t.cx+" "+t.cy+'"/>';else{let o=a.cy+a._h/2,r=t.cy-t._h/2,n=o+(r-o)/2;e+='<path data-from="'+a.id+'" data-to="'+t.id+'" d="M '+a.cx+" "+o+" L "+a.cx+" "+n+" L "+t.cx+" "+n+" L "+t.cx+" "+r+'"/>'}}),Fo.innerHTML=e}function co(e){let t=[],a=e;for(;a;)t.unshift(a),a=u.get(a).parent;return t}function Tt(){let e=N.clientWidth,t=N.clientHeight;se.style.transform="translate("+e/2+"px,"+t/2+"px) scale("+z.zoom+") translate("+-z.x+"px,"+-z.y+"px)",Li()}function mr(){ea&&(ea.kill(),ea=null)}function wi(e,t){if(mr(),t||Ue||!window.gsap){Object.assign(z,e),Tt();return}let a=N.clientWidth,o=Math.hypot(e.x-z.x,e.y-z.y),r=e.zoom,n=gsap.timeline({onUpdate:Tt,onComplete:()=>{ea=null}}),{zoom:i,...s}=e,l=o*Math.min(z.zoom,r),c=Math.max(.55,Math.min(1.3,.55+l/a*.3));if(n.to(z,{...s,duration:c,ease:"power2.inOut"},0),l>a*1.2){let d=Math.max(.06,Math.min(z.zoom,r,a*.9/(o+Mt)));n.to(z,{zoom:d,duration:c/2,ease:"sine.out"},0).to(z,{zoom:r,duration:c/2,ease:"sine.in"},c/2)}else n.to(z,{zoom:r,duration:c,ease:"power2.inOut"},0);ea=n}function tc(){let e=N.getBoundingClientRect(),t=14,a=[];if(!ze.hidden&&ze.offsetWidth){let r=ze.getBoundingClientRect();a.push({x0:r.left-e.left-t,y0:r.top-e.top-t,x1:r.right-e.left+t,y1:r.bottom-e.top+t})}let o=wl();return o&&a.push({x0:o.x0-t,y0:o.y0-t,x1:o.x1+t,y1:o.y1+t}),a}function ac(){let e=N.clientWidth,t=N.clientHeight,a=[{x0:16,y0:K?20:56,x1:e-16,y1:t-(K?20:74)}];return tc().forEach(o=>{let r=[];a.forEach(n=>{if(o.x1<=n.x0||o.x0>=n.x1||o.y1<=n.y0||o.y0>=n.y1){r.push(n);return}[{...n,x1:Math.min(n.x1,o.x0)},{...n,x0:Math.max(n.x0,o.x1)},{...n,y1:Math.min(n.y1,o.y0)},{...n,y0:Math.max(n.y0,o.y1)}].forEach(i=>{i.x1-i.x0>80&&i.y1-i.y0>80&&r.push(i)})}),r.length&&(a=r)}),a}function Qo(e,t,a){let o=N.clientWidth,r=N.clientHeight,n=null;return ac().forEach(i=>{let s=a*Math.min((i.x1-i.x0)/e,(i.y1-i.y0)/t);(!n||s>n.zoom)&&(n={zoom:s,sx:(i.x0+i.x1)/2-o/2,sy:(i.y0+i.y1)/2-r/2})}),n}function xi(e,t,a,o){return{x:e-a.sx/o,y:t-a.sy/o}}function nt(e,t){let a=u.get(e);if(!a)return;let o=Qo(a._w,a._h,oa),r=zt(e),n=v.filter(l=>zt(l)===r&&!u.get(l).visual).map(l=>{let c=u.get(l);return Qo(c._w,c._h,oa).zoom}).sort((l,c)=>l-c),i=n.length?n[Math.floor((n.length-1)/2)]:o.zoom,s=Math.max(.2,Math.min(5,o.zoom,i));wi(Object.assign(xi(a.cx,a.cy,o,s),{zoom:s}),t)}function pa(e){let t=[...u.values()];if(!t.length)return;let a=N.clientWidth,o=N.clientHeight,r=Math.min(...t.map(d=>d.cx-d._w/2)),n=Math.max(...t.map(d=>d.cx+d._w/2)),i=Math.min(...t.map(d=>d.cy-d._h/2)),s=Math.max(...t.map(d=>d.cy+d._h/2)),l=Qo(n-r,s-i,.94),c=Math.max(.05,Math.min(1,l.zoom));wi(Object.assign(xi((r+n)/2,(i+s)/2,l,c),{zoom:c}),e)}function fe(e){g&&u.has(g)?nt(g,e):pa(e)}function Dt(){let e=g?co(g):[];u.forEach(t=>{let a=t.el;a.classList.toggle("current",t.id===g),a.classList.toggle("active-path",e.includes(t.id))}),se.querySelectorAll("#connectors path").forEach(t=>{let a=J==="path"?!!g&&v.indexOf(t.dataset.to)<=v.indexOf(g):e.includes(t.dataset.from)&&e.includes(t.dataset.to);t.classList.toggle("active",a)}),ic(e),Si()}function ki(){return rn(new URLSearchParams(location.search).get("duration")??R.duration)}function oc(){return K&&ki()>0&&(!h.active||/^always$/i.test(R.timer||""))}function Ka(){let e=oc()&&je.start>0;if(Qe.classList.toggle("timed",e),!e){Qe.classList.remove("over");return}let a=(h.active&&h.t0?Bt():performance.now()-je.start)/ki();Qe.firstChild.style.width=Math.min(100,a*100)+"%",Qe.classList.toggle("over",a>=1)}function rc(){je.start=performance.now(),clearInterval(je.timer),je.timer=setInterval(Ka,1e3),Ka()}function nc(){clearInterval(je.timer),je.timer=null,je.start=0,Ka()}function Si(){let e=K&&v.length>1&&!/^(off|no|false)$/i.test(R.progress||"");if(Qe.classList.toggle("show",e),!e)return;Ka();let t=v.indexOf(g),a=0,o=0;v.forEach((r,n)=>{let i=Rt(u.get(r)).length;a+=i,n<t?o+=i:n===t&&(o+=Math.min(ke,i-1)+1)}),Qe.lastChild.style.width=(a?o/a*100:0)+"%"}function ic(e){Un.innerHTML=e.map((t,a)=>(a>0?'<span class="sep">\u203A</span>':"")+'<button class="crumb-btn'+(t===g?" here":"")+'" data-id="'+A(t)+'">'+A(u.get(t).title)+"</button>").join(""),Un.querySelectorAll(".crumb-btn").forEach(t=>t.addEventListener("click",()=>{h.active||_(t.dataset.id)}))}function ua(e){let t=u.get(g);t&&(ur(t,ui().frag,e),Pe(),(B.hidden||!Ne||!Ne.full||Ne.behind)&&cc(t),fr(t))}function lc(e){return!v.length||e.id!==v[0]&&e.id!==v[v.length-1]||e.el.querySelector("[data-gsap], .title-scramble")?null:[...e.el.querySelector(".body").children].filter(t=>!t.classList.contains("fragment"))}function cc(e){if(e._played||!window.gsap||Ue)return;e._played=!0;let t=lc(e);if(t&&t.length){e._auto=t;let[a,...o]=t;/^H[1-3]$/.test(a.tagName)&&!a.children.length?(a.classList.add("auto-scramble"),Jn(a)):o.unshift(a),gsap.from(o,{opacity:0,y:24,duration:.7,ease:"power2.out",delay:.5,stagger:.45})}e.el.querySelectorAll("[data-gsap]").forEach(a=>{let o;try{o=JSON.parse(a.dataset.gsap)}catch{return}let r={duration:o.duration??1,delay:o.delay??0,ease:o.ease||"power2.out"};o.to?gsap.fromTo(a,o.from||{},Object.assign({},o.to,r)):o.from&&gsap.from(a,Object.assign({},o.from,r))}),e.el.querySelectorAll(".title-scramble").forEach(Jn)}function ra(e){!e||!e._played||(e._played=!1,window.gsap&&(e._auto&&(e._auto.forEach(t=>{gsap.killTweensOf(t),gsap.set(t,{clearProps:"opacity,transform"})}),e._auto=null),e.el.querySelectorAll("[data-gsap]").forEach(t=>{gsap.killTweensOf(t);let a={};try{a=JSON.parse(t.dataset.gsap)}catch{}let o=new Set(Object.keys(Object.assign({},a.from,a.to)).map(r=>sc.includes(r)?"transform":r));o.size&&gsap.set(t,{clearProps:[...o].join(",")})}),e.el.querySelectorAll(".title-scramble, .auto-scramble").forEach(t=>{t._scramble&&t._scramble.kill(),t.dataset.text&&(t.textContent=t.dataset.text)})))}function Jn(e){let t=e.dataset.text||(e.dataset.text=e.textContent),a=Array.from(t),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*+=?",r={p:0};e._scramble=gsap.to(r,{p:1,duration:1.4,ease:"none",onUpdate(){let n=Math.floor(r.p*a.length);e.textContent=a.map((i,s)=>s<n||/\s/.test(i)?i:o[Math.random()*o.length|0]).join("")},onComplete(){e.textContent=t}})}function fr(e){clearTimeout(Lt),!(!K||!e||!e.autoslide||h.active&&(!h.t0||h.paused))&&(Lt=setTimeout(()=>{g===e.id&&We(1)},e.autoslide))}function Ei(e){let t=e&&e!==v[0]?e:"";try{M&&M.kind==="share"?history.replaceState(null,"",location.pathname+location.search+Lo(M.data,t)):history.replaceState(null,"",e?"#"+encodeURIComponent(e):location.pathname+location.search)}catch{}}function _(e,t,a){if(!u.has(e))return;if(e!==g){ve=null,Fe=-1,ke=a?Rt(u.get(e)).length-1:0;let n=u.get(g);n&&J==="focus"&&!t&&(n.el.classList.add("leaving"),setTimeout(()=>n.el.classList.remove("leaving"),600)),Mi()}let o=e!==g;if(o&&(Ci=g),g=e,clearTimeout(ue),ue=null,o&&J==="focus"&&!t&&!Ue){let n=u.get(e).el;n.classList.add("entering"),n.offsetWidth,n.classList.remove("entering")}ua(o),o&&!Be&&la("slide",e);let r=u.get(e);o&&r.mapFirst&&!a&&!t&&J!=="focus"?(pa(),ue=setTimeout(()=>{ue=null,g===e&&(Pe(),nt(e))},1900),Pe()):nt(e,t),Dt(),gr(),Ei(e)}function Mi(){let e=u.get(g);e&&(e.el.querySelectorAll("figure.yt").forEach(t=>yi(t,"pauseVideo")),ur(e,e.frags.length,!0),ra(e))}function dc(){if(!g&&Ze&&u.has(Ze)){Ti();return}g&&(Ze=g),J==="focus"&&yr("path"),Mi(),clearTimeout(Lt),g=null,Pe(),Dt(),gr(),pa(),Ei(null)}function Ti(){if(ue)return clearTimeout(ue),ue=null,Pe(),nt(g),!0;if(!g&&Ze&&u.has(Ze)){let e=Ze;return Ze=null,_(e),!0}return!1}function We(e){if(!g){v.length&&_(v[e>0?0:v.length-1]);return}if(ue&&e>0){clearTimeout(ue),ue=null,Pe(),nt(g);return}let t=Rt(u.get(g)),a=Math.min(ke,t.length-1)+e;if(a>=0&&a<t.length){ke=a,ve=null,Fe=-1,ua(),!re&&!B.hidden&&Ne.used?ct():fe(),Dt();return}let o=v.indexOf(g)+e;o>=0&&o<v.length&&_(v[o],!1,e<0)}function hc(){let e=u.get(g);e&&e.parent&&_(e.parent)}function pc(){let e=u.get(g);e&&e.children.length?_(e.children[0]):!g&&v.length&&_(v[0])}function gr(){let e=[...u.values()];if(!e.length){Go.innerHTML="",Ce=null;return}al.textContent="map";let t=p=>p.cx,a=p=>p.cy,o=Math.min(...e.map(t))-Mt/2,r=Math.max(...e.map(t))+Mt/2,n=Math.min(...e.map(a))-Yo/2,i=Math.max(...e.map(a))+Yo/2,s=16,l=180,c=130,d=Math.min((l-2*s)/Math.max(1,r-o),(c-2*s-6)/Math.max(1,i-n)),k=l/2-(o+r)/2*d,m=c/2+5-(n+i)/2*d,f=g?co(g):[],b="";e.forEach(p=>{if(!p.parent)return;let T=u.get(p.parent);b+='<line x1="'+(t(T)*d+k)+'" y1="'+(a(T)*d+m)+'" x2="'+(t(p)*d+k)+'" y2="'+(a(p)*d+m)+'" stroke="var(--panel-line)" stroke-width="1"/>'}),e.forEach(p=>{let T=p.id===g?"var(--accent)":f.includes(p.id)?"var(--accent-teal)":"var(--node-border)";b+='<circle data-id="'+A(p.id)+'" cx="'+(t(p)*d+k)+'" cy="'+(a(p)*d+m)+'" r="'+(p.id===g?4:3)+'" fill="'+T+'"><title>'+A(p.title)+"</title></circle>"}),b+='<rect id="mm-viewport" fill="none" stroke="var(--accent)" stroke-width="1" opacity="0.7"/>',Go.innerHTML=b,Ce={s:d,ox:k,oy:m},Li()}function Li(){let e=document.getElementById("mm-viewport");if(!e||!Ce)return;let t=N.clientWidth/z.zoom,a=N.clientHeight/z.zoom;e.setAttribute("x",(z.x-t/2)*Ce.s+Ce.ox),e.setAttribute("y",(z.y-a/2)*Ce.s+Ce.oy),e.setAttribute("width",Math.max(2,t*Ce.s)),e.setAttribute("height",Math.max(2,a*Ce.s))}function At(e){mi(ie.value),g&&!u.has(g)&&(g=null),vi(),g?_(g,e):v.length?_(v[0],e):(g=null,pa(!0))}function yr(e,t){J=e,W("slidetake:layout",e),document.querySelectorAll("#layout-toggle .seg-btn").forEach(a=>a.classList.toggle("active",a.dataset.mode===e)),u.size&&(!t&&!Ue&&(se.classList.add("morph"),setTimeout(()=>se.classList.remove("morph"),700)),ha(),Tt(),g?nt(g,t):pa(t))}function Ai(e){return Math.max(.04,Math.min(5,e))}function uc(e){oa=Math.round(Math.max(ll,Math.min(cl,e))*100)/100,W("slidetake:slideSize",oa),g&&nt(g)}function $n(e){g?uc(oa+e*.1):Bi(e>0?1.2:1/1.2)}function Bi(e,t,a){mr();let o=Ai(z.zoom*e);if(t!==void 0){let r=N.getBoundingClientRect(),n=t-r.left-r.width/2,i=a-r.top-r.height/2;z.x+=n/z.zoom-n/o,z.y+=i/z.zoom-i/o}z.zoom=o,Tt()}function ho(){U||(qe.classList.toggle("collapsed"),document.getElementById("btn-edit-toggle").classList.toggle("active",!qe.classList.contains("collapsed")))}function we(e){K=e,document.body.classList.toggle("presenting",e),ws(document.getElementById("btn-present"),e),xs();let t=document.documentElement;e&&t.requestFullscreen&&!document.fullscreenElement&&t.requestFullscreen().catch(()=>{}),!e&&document.fullscreenElement&&document.exitFullscreen&&document.exitFullscreen().catch(()=>{}),e&&!g&&v.length&&_(v[0]);let a=R.camera||[...u.values()].some(o=>o.camera);e&&a&&!re&&!te&&ct(),e?fr(u.get(g)):clearTimeout(Lt),e?rc():nc(),Si()}function Bt(){return(h.paused?h.pauseAt:performance.now())-h.t0-h.pausedMs}function ma(e){e.classList.add("open")}function yc(e){if(W("slidetake:analytics",e?"on":"off"),!e){window["ga-disable-"+fc]=!0;let t=["","; Domain="+location.hostname,"; Domain=."+location.hostname.replace(/^www\./,"")];document.cookie.split(";").map(a=>a.split("=")[0].trim()).filter(a=>a==="_ga"||a.startsWith("_ga_")).forEach(a=>t.forEach(o=>{document.cookie=a+"=; Max-Age=0; Path=/"+o}))}Ii()}function Ii(){wr.querySelectorAll("[data-analytics]").forEach(e=>e.setAttribute("aria-checked",String(e.dataset.analytics==="on"===gc())))}function fa(){document.querySelectorAll(".modal.open").forEach(e=>e.classList.remove("open"))}function bc(){let e=new URLSearchParams(location.search).get("obs");if(e){let[t,a,...o]=e.split(":");return Ja.value=t||"localhost",$a.value=a||"4455",Xa.value=o.join(":"),!0}try{let t=JSON.parse(j("slidetake:obs")||"null");t&&(Ja.value=t.host||"localhost",$a.value=t.port||"4455",Xa.value=t.password||"",br.checked=!0)}catch{}return!1}function zi(){if(br.checked)W("slidetake:obs",JSON.stringify({host:Ja.value.trim(),port:$a.value.trim(),password:Xa.value}));else try{localStorage.removeItem("slidetake:obs")}catch{}}function Kt(e,t,a){ta.textContent=e,ta.className=t||"",ta.title=a||e;let o=document.getElementById("obs-detail");o.textContent=a||"",o.hidden=!a}function wc(e){return location.protocol==="https:"&&!vc(e)}async function xr(){let e=Ja.value.trim()||"localhost",t="ws://"+e+":"+($a.value.trim()||"4455");if(wc(e)){Oe=!1,Kt("Blocked here","err",xc);return}Kt("Connecting\u2026"),ta.title="Connecting to "+t;try{await Xo(mc);let a=window.OBSWebSocket&&(window.OBSWebSocket.default||window.OBSWebSocket);if(ne)try{await ne.disconnect()}catch{}ne=new a,ne.on("ConnectionClosed",()=>{Oe=!1,Kt("Disconnected","err")}),ne.on("RecordStateChanged",r=>{r.outputState==="OBS_WEBSOCKET_OUTPUT_STARTED"&&et&&(et(),et=null),r.outputState==="OBS_WEBSOCKET_OUTPUT_STOPPED"&&h.active&&h.withObs&&!h.finishing&&Pt("Stopped in OBS")});let o=await ne.connect(t,Xa.value||void 0);Oe=!0;try{let r=await ne.call("GetVideoSettings");r&&r.fpsNumerator&&r.fpsDenominator&&(vr=r.fpsNumerator/r.fpsDenominator),Oi=r&&r.outputWidth&&r.outputHeight?Pn(r.outputWidth,r.outputHeight):""}catch{}Kt("Connected","ok",""),ta.title="Connected"+(o&&o.obsWebSocketVersion?" \xB7 OBS WebSocket "+o.obsWebSocketVersion:""),zi(),Y.classList.contains("open")&&st()&&(O("Connected to OBS. Press \u25CF Record."),Ye())}catch(a){Oe=!1;let o=a&&a.message&&a.message!=="Error"?a.message+".":"Nothing answered at "+t+".";Kt("Could not connect","err",o+" Is OBS running with its WebSocket server on, and are the port and password right?")}}function kc(){let e=document.getElementById("rec-screen"),t=screen.width,a=screen.height;if(Ie()){e.innerHTML='<span class="warn">This deck is portrait (9:16). In OBS, set the canvas to 1080\xD71920 (Settings \u2192 Video) and fit the 9:16 column in the middle of the screen to it.</span>';return}if(Math.abs(t/a-16/9)<.02){e.innerHTML='<span class="ok">This screen is 16:9 ('+t+"\xD7"+a+"), right for YouTube.</span>";return}let o=[["16:10",1.6],["3:2",1.5],["4:3",4/3],["21:9",21/9],["16:9",16/9]],[r,n]=o.reduce((s,l)=>Math.abs(l[1]-t/a)<Math.abs(s[1]-t/a)?l:s),i=Math.abs(n-t/a)<.005?r:"about "+r;e.innerHTML='<span class="warn">This screen is '+i+" ("+t+"\xD7"+a+"), not 16:9, so the video will have bars or be cropped. Move this window to a 16:9 screen, physical or virtual (say 1920\xD71080), then press F there.</span>"}function Se(){let e=navigator.mediaDevices;if(!window.isSecureContext||!e||!e.getDisplayMedia)return{why:"This page can\u2019t capture itself here. Open Slidetake in Chrome or Edge on a computer."};if(!window.RestrictionTarget&&!window.CropTarget)return{why:"Recording in the browser needs Chrome or Edge (or another Chromium browser) on a computer."};let t=window.MediaRecorder?Bn(r=>MediaRecorder.isTypeSupported(r)):"";if(!t||!navigator.storage||!navigator.storage.getDirectory)return{why:"This browser can\u2019t record video here. Use a recent Chrome or Edge."};let{quality:a,device:o}=An(screen.width,screen.height,devicePixelRatio||1,Ie());return a?{ok:!0,type:t,quality:a}:{why:"This screen gives a "+o[0]+"\xD7"+o[1]+" frame, less than 720p. Use pro mode (OBS), or a larger screen."}}async function po(){tr++,he&&(cancelAnimationFrame(he.raf),he.stream.getTracks().forEach(e=>e.stop()),he.ctx.close().catch(()=>{}),he=null,er.value=0,kt.getContext("2d").clearRect(0,0,kt.width,kt.height),Ri())}function Ri(){ar++,Wa&&(Wa.getTracks().forEach(e=>e.stop()),Wa=null),kr.srcObject=null}async function Di(){Ri(),Sr();let e=ar,t=xt.value;if(Ha.hidden=t!=="none"&&!!t,Ha.textContent="No camera",!(!t||t==="none"))try{let a=await navigator.mediaDevices.getUserMedia({video:t==="default"?!0:{deviceId:{exact:t}}});if(e!==ar){a.getTracks().forEach(o=>o.stop());return}Wa=a,kr.srcObject=a}catch{Ha.hidden=!1,Ha.textContent="The camera isn\u2019t available"}}async function Qa(){await po();let e=tr;try{let t=Ot.value,a=await navigator.mediaDevices.getUserMedia({audio:Qi(t)});if(e!==tr){a.getTracks().forEach(m=>m.stop());return}let o=new AudioContext,r=o.createAnalyser();r.fftSize=512,o.createMediaStreamSource(a).connect(r);let n=new Float32Array(r.fftSize),i=he={stream:a,ctx:o,raf:0},s=kt.getContext("2d"),l=kt.width,c=kt.height,d=Le("--accent"),k=()=>{if(he!==i)return;r.getFloatTimeDomainData(n);let m=0;for(let f of n)m=Math.max(m,Math.abs(f));er.value=Math.max(m,er.value*.85),s.clearRect(0,0,l,c),s.lineWidth=3,s.strokeStyle=d,s.lineJoin="round",s.beginPath();for(let f=0;f<n.length;f++){let b=f/(n.length-1)*l,p=c/2-Math.max(-1,Math.min(1,n[f]*3))*(c/2-4);f?s.lineTo(b,p):s.moveTo(b,p)}s.stroke(),i.raf=requestAnimationFrame(k)};k()}catch(t){vt.innerHTML='<span class="warn">The microphone isn\u2019t available: '+A(t.message||t.name)+". Allow it in the site settings.</span>"}}async function Za(e=!0){try{e&&!he&&await Qa();let t=await navigator.mediaDevices.enumerateDevices(),a=(n,i)=>{let s=t.filter(b=>b.kind===n),l=s.find(b=>b.deviceId==="default"),c=l?l.label.replace(/^Default - /,""):"",d=s.filter(b=>b.deviceId!=="default"&&b.deviceId!=="communications"),k=b=>!!l&&(b.label===c||!!l.groupId&&b.groupId===l.groupId&&!d.some(p=>p!==b&&p.label===c)),m=d.map((b,p)=>In(b.label)||(n==="audioinput"?"Microphone ":"Camera ")+(p+1));m.forEach((b,p)=>{let T=m.slice(0,p).filter(C=>C===b).length;T&&(m[p]=b+" "+(T+1))});let f=d.some(b=>b.deviceId===i)||i==="none"?i:(d.find(k)||d[0]||{}).deviceId;return d.map((b,p)=>'<option value="'+A(b.deviceId)+'"'+(b.deviceId===f?" selected":"")+">"+A(m[p]+(k(b)?" (system default)":""))+"</option>").join("")},o=Er();xt.innerHTML='<option value="none"'+(o==="none"?" selected":"")+">No camera</option>"+a("videoinput",o);let r=j("slidetake:mic")||"";Ot.innerHTML=a("audioinput",r),r&&Ot.value===r&&he&&he.stream.getAudioTracks()[0].getSettings().deviceId!==r&&Qa()}catch{}}function Fi(){let e=j("slidetake:mirror");return e?e==="on":/^(yes|true|on)$/i.test(R.pip_mirror||"")}function Sr(){eo.checked=Fi(),kr.parentElement.classList.toggle("mirror",eo.checked)}function Er(){let e=j(Ni());return e||(Ec()?j("slidetake:cam")||"default":"none")}function Cc(e){W(Ni(),e),e!=="none"&&e!=="default"&&W("slidetake:cam",e)}function Mc(){h.camWas=!te;let e=Er()!=="none";e!==!te&&Ht(e,!0)}function Hi(){h.camWas!=null&&(h.camWas!==!te&&Ht(h.camWas,!0),h.camWas=null)}async function ji(){let e=Se();if(!e.ok)return vt.innerHTML='<span class="warn">'+A(e.why)+"</span>",e;ja&&(vt.innerHTML='<span class="warn">'+A(ja)+"</span>",ja="");let t=ft.indexOf(e.quality),a=j("slidetake:quality");It.innerHTML=ft.slice(t).map(r=>"<option"+(r.name===a?" selected":"")+">"+r.name+"</option>").join("");let o="";try{let{quota:r,usage:n}=await navigator.storage.estimate(),i=ft.find(s=>s.name===It.value)||e.quality;o=" Room for about "+Math.floor((r-n)/On(i))+" minutes of takes."}catch{}return vt.querySelector(".warn")||(vt.innerHTML='<span class="ok">Ready: this screen records up to '+e.quality.name+" in fullscreen."+A(o)+"</span>"),e}function Tc(e){me=e,W("slidetake:rec-mode",e),sa({setup:Nt()})}function sa(e={}){Ge&&(Se().ok&&(me||"browser")==="browser"?Ir(e):Lc(e))}function Lc(e={}){let t=uo().find(a=>a.key===Ve()&&a.withObs&&!a.inBrowser);as(t||{key:Ve(),deckTitle:R.title||(v[0]?u.get(v[0]).title:"Deck"),date:new Date().toISOString(),withObs:!0,outputPath:null,reason:"",total:0,totalObs:null,fps:vr,events:[],picks:{},empty:!0},e)}async function Cr(){if(!(!Ge||h.active||!v.length)){if(!Ac()){nr({note:"Set up once: after this, \u25CF Record (R) starts recording straight away."});return}if(Se().ok&&(me||"browser")==="browser"){let t=za(lt(),go()).filter(r=>!r.pick).map(r=>r.id),a=v.indexOf(g),o=t.length?t:a>0?v.slice(a):v;to("browser",o.length===v.length?null:o);return}if(!Oe&&j("slidetake:obs")&&await xr(),Oe){to("obs");return}nr({note:"Connect to OBS first: OBS \u2192 Connect."})}}async function Mr(e,t){return(await(await navigator.storage.getDirectory()).getDirectoryHandle("slidetake-takes",{create:!0})).getDirectoryHandle(e,{create:!!t})}async function Tr(e){try{await(await(await navigator.storage.getDirectory()).getDirectoryHandle("slidetake-takes")).removeEntry(e,{recursive:!0})}catch{}}function _i(){if(!document.body.classList.contains("rec-frame"))return;let e=devicePixelRatio||1,t=Ie()?9/16:16/9,a=wt.clientWidth,o=wt.clientHeight,r=s=>Math.floor(s*e/2)*2/e,n=r(Math.min(o,a/t)),i=r(n*t);i>a&&(i=r(a),n=r(i/t)),Object.assign(ce.style,{width:i+"px",height:n+"px",aspectRatio:"auto",margin:Math.floor((o-n)/2)+"px 0 0 "+Math.floor((a-i)/2)+"px"})}function Lr(e){document.body.classList.toggle("rec-frame",e),e?_i():["width","height","aspectRatio","margin"].forEach(t=>ce.style.removeProperty(t.replace(/[A-Z]/g,a=>"-"+a.toLowerCase())))}async function Ui(e){window.RestrictionTarget&&e.restrictTo?await e.restrictTo(await RestrictionTarget.fromElement(ce)):await e.cropTo(await CropTarget.fromElement(ce))}function Bc(e,{w:t,h:a}){let o=document.createElement("video");o.muted=!0,o.playsInline=!0,o.srcObject=new MediaStream([e]);let r=document.createElement("canvas");r.width=t,r.height=a;let n=r.getContext("2d",{alpha:!1}),i=!0,s=()=>{if(!i)return;let c=o.videoWidth,d=o.videoHeight;if(c&&d){let k=Math.max(t/c,a/d),m=c*k,f=d*k;n.drawImage(o,(t-m)/2,(a-f)/2,m,f)}o.requestVideoFrameCallback(s)};o.requestVideoFrameCallback(s),o.play().catch(()=>{});let l=r.captureStream(gt).getVideoTracks()[0];return{track:l,stop(){i=!1,l.stop(),o.srcObject=null}}}async function Oc(e){try{window.RestrictionTarget&&e.track.restrictTo?await e.track.restrictTo(null):await e.track.cropTo(null),await Ui(e.track)}catch{}e.scaled||await e.track.applyConstraints(Wi(e.quality)).catch(t=>console.warn("Slidetake: the recording size was refused",t)),await ia()}async function Ic(){let e=Se();if(!e.ok)throw new Error(e.why);let t=ft.find(l=>l.name===It.value)||e.quality;Lr(!0);let a=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:gt},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",surfaceSwitching:"exclude",monitorTypeSurfaces:"exclude"}),o=a.getVideoTracks()[0],r=()=>a.getTracks().forEach(l=>l.stop());if(!o.restrictTo&&!o.cropTo)throw r(),new Error("Share \u201Cthis tab\u201D to record the slides.");try{await Ui(o)}catch(l){throw r(),new Error("Chrome could not record just the slides ("+(l.message||l.name)+").")}let n=Ie()?Bc(o,Ba(t,!0)):null;n||await o.applyConstraints(Wi(t)).catch(l=>console.warn("Slidetake: the recording size was refused",l));let i;try{let l=j("slidetake:mic");i=await navigator.mediaDevices.getUserMedia({audio:Qi(l)})}catch(l){throw r(),new Error("The microphone isn\u2019t available ("+(l.message||l.name)+").")}let s=new Date().toISOString().replace(/[:.]/g,"-");h.browser={id:s,display:a,mic:i,track:o,quality:t,type:e.type,scaled:n,stream:new MediaStream([n?n.track:o,...i.getAudioTracks()]),dir:await Mr(s,!0),clips:[],cur:null,chain:Promise.resolve(),error:null},o.addEventListener("ended",()=>{h.active&&!h.finishing&&Pt("Sharing stopped")})}function qi(){let e=h.browser;e&&(e.display.getTracks().forEach(t=>t.stop()),e.mic.getTracks().forEach(t=>t.stop()),e.scaled&&e.scaled.stop(),Lr(!1))}function Pc(e){let t=h.browser,a="take-"+t.clips.length+"."+Io(t.type),o={name:a,rec:null,done:null};t.clips.push(o),e.clip=t.id+"/"+a,t.chain=t.chain.then(async()=>{let r=await(await t.dir.getFileHandle(a,{create:!0})).createWritable(),n=new MediaRecorder(t.stream,{mimeType:t.type,videoBitsPerSecond:t.quality.bitrate,audioBitsPerSecond:Aa}),i=Promise.resolve();n.ondataavailable=l=>{l.data.size&&(i=i.then(()=>r.write(l.data)).catch(c=>{t.error=c}))},o.done=new Promise(l=>{n.onstop=async()=>{await i,await r.close().catch(()=>{}),l()}}),await new Promise(l=>{n.onstart=l,n.start(1e3)}),e.t=Math.round(Bt()),e.cutAt!=null&&(e.lead=Math.max(0,Math.round(e.t-e.cutAt)));let s=t.cur;t.cur=o,o.rec=n,s&&s.rec.state!=="inactive"&&s.rec.stop()}).catch(r=>{t.error=r})}async function to(e,t){if(h.active||!v.length)return;let a=e==="obs";if(po(),me||(me=a?"obs":"browser",W("slidetake:rec-mode",me)),e==="browser"){K||we(!0);try{await Ic()}catch(l){Lr(!1),K&&we(!1),ja=l.name==="NotAllowedError"?"Recording needs this tab shared: press \u25CF Record again and choose Share.":l.message,Ir({setup:!0});return}}fa();let o=t&&t.length?t.filter(l=>v.includes(l)):null,r=o?o[0]:v[0],n=v[v.indexOf(r)-1]||null;Object.assign(h,{active:!0,withObs:a,counting:!0,paused:!1,finishing:!1,t0:0,pausedMs:0,events:[],outputPath:null,only:o?new Set(o):null}),e!=="browser"&&(h.browser=null),document.body.classList.add("recording"),zr(),K||we(!0),Mc(),n?(document.body.classList.add("no-anim"),u.get(n)._played=!0,Be=!0,_(n,!0,!0),Be=!1,B.getAnimations().forEach(l=>l.finish()),await ia(),document.body.classList.remove("no-anim")):(g===r&&(ke=0,ve=null,Fe=-1),_(r,!0)),!document.fullscreenElement&&document.documentElement.requestFullscreen&&await document.documentElement.requestFullscreen().catch(()=>{});let i=$t.querySelector(".hint");for(let l=3;l>0;l--)if(i.textContent=(document.fullscreenElement?"":"Press F for fullscreen \xB7 ")+"recording starts after the countdown \xB7 Esc to cancel",$t.querySelector(".num").textContent=l,$t.classList.add("show"),await na(1e3),!h.active)return;if($t.classList.remove("show"),await ia(),a){let l=new Promise(c=>{et=c,setTimeout(()=>{et&&(et(),et=null)},2500)});try{await ne.call("StartRecord")}catch(c){Ar("OBS could not start recording: "+(c&&c.message||c));return}if(await l,!h.active)return}h.browser&&await Oc(h.browser),h.counting=!1,h.t0=performance.now();let s=u.get(r);if(n){la("slide",r),h.browser&&await h.browser.chain,ra(s),Be=!0,_(r),Be=!1;return}ra(s),ua(!0),la("slide",g)}function Ar(e){if(h.active=!1,h.counting=!1,h.browser){let t=h.browser;t.chain.then(()=>{t.cur&&t.cur.rec.state!=="inactive"&&t.cur.rec.stop()}).then(()=>Tr(t.id)),qi(),h.browser=null}$t.classList.remove("show"),document.body.classList.remove("recording"),K&&we(!1),Hi(),Et(e)}function la(e,t,a){if(!h.active||!h.t0||h.finishing)return;let o=u.get(t),r={id:t,title:o?o.title:t,retake:e==="retake",t:Math.round(Bt()),obsT:null};a==null&&h.browser&&(a=r.t),a!=null&&(r.cutAt=a,r.lead=Math.max(0,Math.round(r.t-a))),h.events.push(r),h.browser&&Pc(r),h.withObs&&Oe&&(ne.call("GetRecordStatus").then(n=>{n&&typeof n.outputDuration=="number"&&(r.obsT=n.outputDuration)}).catch(()=>{}),o&&ne.call("CreateRecordChapter",{chapterName:(r.retake?"RETAKE \xB7 ":"")+o.title}).catch(()=>{}))}function zc(e){let t=e.key;if((Qn.includes(t)||Zn.includes(t)||ei.includes(t)||t==="Escape")&&e.preventDefault(),t==="Escape"){h.counting?Ar("Take cancelled"):Pt("Stopped early");return}if((t==="f"||t==="F")&&!document.fullscreenElement&&document.documentElement.requestFullscreen){e.preventDefault(),document.documentElement.requestFullscreen().catch(()=>{});return}if(!(h.counting||h.finishing||at)){if(ei.includes(t)){Nc();return}h.paused||(Qn.includes(t)?Rc():Zn.includes(t)&&Dc())}}function Rc(){let e=Rt(u.get(g)),t=Math.min(ke,e.length-1)>=e.length-1,a=v.indexOf(g);if(!t){We(1);return}if(!h.only){a===v.length-1?Pt():We(1);return}let o=v.slice(a+1).find(r=>h.only.has(r));o?v[a+1]===o?We(1):Vi(v[v.indexOf(o)-1],o,"slide"):Pt()}async function Dc(){let e=u.get(g);if(!e||at)return;let t=g,a=Ci;if(!a||a===t||!u.has(a)){Fc(e);return}Vi(a,t,"retake")}async function Vi(e,t,a){let o=u.get(t);if(!o||at)return;at=!0;let r=Bt();document.body.classList.add("no-anim");let n=u.get(e);Be=!0,n._played=!0,_(e,!0,!0),B.getAnimations().forEach(i=>i.finish()),Be=!1,await ia(),document.body.classList.remove("no-anim"),la(a,t,r),h.browser&&await h.browser.chain,h.withObs&&await Gi(),ra(o),Be=!0,_(t),Be=!1,!re&&!B.hidden&&Ne.used&&ct(),at=!1}async function Gi(){let e=h.events[h.events.length-1];e&&(e.skip=ti/2),await na(ti)}async function Fc(e){at=!0,ke=0,ve=null,Fe=-1,ra(e),ua(!0),!re&&!B.hidden&&Ne.used?ct():fe(),Dt(),la("retake",g),h.withObs&&await Gi(),at=!1}async function Nc(){if(h.t0)if(h.paused){if(Zo.classList.remove("show"),await ia(),h.withObs&&await ne.call("ResumeRecord").catch(()=>{}),h.browser){let e=h.browser;e.chain=e.chain.then(()=>{e.cur&&e.cur.rec.state==="paused"&&e.cur.rec.resume()})}h.pausedMs+=performance.now()-h.pauseAt,h.paused=!1,fr(u.get(g))}else{if(h.paused=!0,h.pauseAt=performance.now(),clearTimeout(Lt),h.withObs&&await ne.call("PauseRecord").catch(()=>{}),h.browser){let e=h.browser;e.chain=e.chain.then(()=>{e.cur&&e.cur.rec.state==="recording"&&e.cur.rec.pause()})}Zo.classList.add("show")}}async function Pt(e){if(!h.active||h.finishing)return;if(h.counting){Ar("Take cancelled");return}h.finishing=!0,clearTimeout(Lt),h.paused&&(h.pausedMs+=performance.now()-h.pauseAt,h.paused=!1,Zo.classList.remove("show"));let t=Math.round(Bt()),a=null;if(h.withObs){try{let n=await ne.call("GetRecordStatus");n&&typeof n.outputDuration=="number"&&(a=n.outputDuration)}catch{}await na(1200);try{let n=await ne.call("StopRecord");h.outputPath=n&&n.outputPath}catch(n){e=(e?e+". ":"")+"OBS did not confirm the stop ("+(n&&n.message||n)+")"}}let o=h.browser;o&&(await na(600),await o.chain,t=Math.round(Bt()),o.cur&&o.cur.rec&&o.cur.rec.state!=="inactive"&&o.cur.rec.stop(),await Promise.all(o.clips.map(n=>n.done)),qi(),h.browser=null,o.error&&(e=(e?e+". ":"")+"Some of the take could not be saved ("+(o.error.message||o.error.name)+")")),h.active=!1,h.finishing=!1,document.body.classList.remove("recording"),K&&we(!1),Hi();let r={key:Ve(),deckTitle:R.title||u.get(v[0]).title,date:new Date().toISOString(),withObs:h.withObs,outputPath:h.outputPath,reason:e||"",total:t,totalObs:a,fps:o?gt:vr,...o?{inBrowser:!0,takesId:o.id,quality:o.quality.name,type:o.type}:{},events:h.events.map(n=>({id:n.id,title:n.title,retake:n.retake,t:n.t,obsT:n.obsT,...n.lead?{lead:n.lead}:{},...n.skip?{skip:n.skip}:{},...n.clip?{clip:n.clip}:{}})),picks:{}};if(r.inBrowser){Gc(r);return}Br(r),as(r,{note:(e?e+". ":"")+be(r).size+" slides recorded with OBS."})}function Ve(){return pt(R.title||(v[0]?u.get(v[0]).title:"deck"))}function uo(){try{return JSON.parse(j("slidetake:sessions")||"[]")}catch{return[]}}function Br(e){let t=uo().filter(a=>a.date!==e.date);t.unshift(e),t.slice(12).forEach(a=>{a.takesId&&Tr(a.takesId)}),W("slidetake:sessions",JSON.stringify(t.slice(0,12)))}function zt(e){let t=u.has(e)?co(e):[e];return t[Math.min(1,t.length-1)]}function Yi(e,t){let a=zt(e);return{sec:a,title:u.has(a)?u.get(a).title:t}}function O(e,{warn:t=!1,html:a="",title:o=""}={}){Jt.classList.toggle("warn",t),a?Jt.innerHTML=a:Jt.textContent=e,Jt.title=o||Jt.textContent;let r=document.getElementById("rv-save-again");r&&(r.onclick=()=>hs(!0))}function as(e,t={}){fa(),H=e,Z=null;let a=e.events.filter(i=>i.retake).length,o=e.empty?"":be(e).size+" slides, "+(a?a+" retake"+(a>1?"s":""):"no retakes")+", recorded "+ut(e.totalObs??e.total)+". ";Y.classList.remove("in-browser","board"),Y.classList.add("obs");let r=document.getElementById("rv-rec");r.title="Records the deck with OBS: a new video in place of this one",r.disabled=!1,document.getElementById("rv-render-btn").disabled=document.getElementById("rv-clean").disabled=!!e.cleaned,document.getElementById("rv-file").textContent=e.outputPath?" ("+mt(e.outputPath)+")":"";let n=Ta(e);ao.value=[...ao.options].reduce((i,s)=>Math.abs(s.value-n)<Math.abs(i.value-n)?s:i).value,S.src&&(e.inBrowser||_e!==mt(e.outputPath)&&e.outputPath)&&(S.removeAttribute("src"),S.load(),_e=""),document.getElementById("rv-novideo").hidden=!!S.src||!!e.empty,Z=null,F=null,Ft(),mo(),ma(Y),t.setup?yo(t):(bo(),Za(!1).then(Ye)),O(t.note||(e.empty?Oe?"Press \u25CF Record: OBS records the deck.":"Connect to OBS in Setup, then press \u25CF Record.":o+(S.src?"Click a take to preview it.":"Open the recording to preview it."))),e.empty||Xc(e)}function mo(){if(H&&H.board){it();return}let e=H,t=document.getElementById("rv-list"),a=null;t.innerHTML=[...be(e).values()].map(o=>{let r=e.picks[o.id]??o.takes.length,n=zt(o.id),i=n!==a;a=n;let s=o.takes.map(l=>'<button class="rv-chip'+(r===l.no?" on":"")+'" data-id="'+A(o.id)+'" data-take="'+l.no+'">Take '+l.no+" \xB7 "+ut(l.end-l.start)+"</button>").join("");return'<div class="rv-row'+(i?" sec":"")+'"><div class="t">'+A(o.title)+"<small>"+wa(o.takes[0].start)+'</small></div><div class="rv-chips">'+s+"</div></div>"}).join(""),t.querySelectorAll(".rv-chip").forEach(o=>o.onclick=()=>{e.picks[o.dataset.id]=+o.dataset.take,Br(e),mo();let r=be(e).get(o.dataset.id),n=r&&r.takes[+o.dataset.take-1];if(!n)return;let i=r.title+(r.takes.length>1?" \xB7 take "+n.no:"");if(e.inBrowser){let s=e.events.filter(l=>l.id===o.dataset.id)[n.no-1];s&&s.clip&&fo([{clip:s.clip,keep:(n.end-n.start)/1e3,title:i}])}else ro([{start:n.start,end:n.end,title:i}])}),document.getElementById("rv-ffmpeg-copy").disabled=document.getElementById("rv-play-final").disabled=!e.events.length,rs(e),is(e)}function rs(e){let t=Hc(e),a=document.getElementById("rv-chapters");os=t.lines.join(`
|
|
1432
|
+
`),a.disabled=t.lines.length<3,a.title=t.lines.length<3?"YouTube needs at least three chapters of 10 seconds or more":"Copies the "+t.lines.length+" chapters, to paste into the YouTube description"}function ns(e,t){let a=e.dataset.label||(e.dataset.label=e.textContent);(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject()).catch(()=>{}),e.textContent="\u2713 Copied",clearTimeout(+e.dataset.timer),e.dataset.timer=String(setTimeout(()=>{e.textContent=a},1500))}async function is(e){let t=document.getElementById("rv-final"),a=++Uo,o=Gt(e).reduce((n,i)=>n+i.end-i.start,0),r=n=>(n?"about "+(n>1e9?(n/1e9).toFixed(1)+" GB":Math.max(1,Math.round(n/1e6))+" MB")+" \xB7 ":"Final cut ")+ut(o);if(!e.inBrowser||e.cleaned){t.textContent=r(null);return}try{let n=0;for(let i of Yt(e))Ua.has(i.clip)||Ua.set(i.clip,(await ga(i.clip)).size),n+=Ua.get(i.clip);a===Uo&&(t.textContent=r(n))}catch{a===Uo&&(t.textContent=r(null))}}function ro(e){if(!S.src){oo=e,O(sr?"Opening the recording\u2026 it plays when ready.":"Open the recording to preview.");return}oo=null,Z={ranges:e,i:0},O("\u25B6 "+e[0].title);let t=()=>{S.currentTime=e[0].start/1e3,S.play().catch(a=>{a&&a.name!=="AbortError"&&O("Could not play: "+a.message,{warn:!0})})};S.readyState>=1?t():S.addEventListener("loadedmetadata",t,{once:!0})}function Ft(){St=null}function Or(){let e=F&&!F.single&&!S.paused;ss.innerHTML=e?'\u275A\u275A <span><u class="key">P</u>ause</span>':'\u25B6 <span><u class="key">P</u>review</span>',document.querySelectorAll("#rv-list .rv-row.playing").forEach(o=>o.classList.remove("playing"));let t=F&&F.parts[F.i],a=t&&t.id&&document.querySelector('#rv-list .rv-row[data-id="'+CSS.escape(t.id)+'"]');a&&(a.classList.add("playing"),a.scrollIntoView({block:"nearest"}))}function Wc(e){let t=H?Yt(H):[],a=t.findIndex(r=>r.id===e.id),o=a>=0?t[a+1]:null;St=o?o.id:null,O(o?"Preview continues from "+o.title+".":"That was the last slide: Preview plays from the start.")}function ls(e){return Array.from({length:e.numberOfChannels},(t,a)=>{let o=new Float32Array(e.numberOfFrames);return e.copyTo(o,{planeIndex:a,format:"f32-planar"}),o})}async function ga(e){let[t,a]=e.split("/");return(await(await Mr(t)).getFileHandle(a)).getFile()}async function fo(e,t=0,a=!1){if(!(!H||H.cleaned||!e.length)){Z=null,F={parts:e,i:t,single:a};try{let o=await ga(e[t].clip);if(!Y.classList.contains("open"))return;S.src&&URL.revokeObjectURL(S.src),S.src=URL.createObjectURL(o),O("\u25B6 "+e[t].title),await S.play()}catch(o){if(o&&o.name==="AbortError")return;F=null,O(o&&o.name==="NotFoundError"?"This take is no longer in the browser.":"Could not play this take: "+(o&&o.message||o),{warn:!0})}}}function cs(){let e=F;if(e.i+1<e.parts.length){fo(e.parts,e.i+1,e.single);return}F=null,S.pause(),e.single?Wc(e.parts[0]):O(""),Or()}async function _c(e){if(!e.where)return!0;try{let t=await Pr("video-folder");return!t||t.name!==e.where||await t.queryPermission({mode:"readwrite"})!=="granted"||await t.getFileHandle(e.name),!0}catch{return!1}}async function hs(e){let t=H;if(!t||!t.inBrowser||t.cleaned)return;let a=Yt(t);if(!a.length){O("No slide has a take yet: nothing to save.",{warn:!0});return}let o=JSON.stringify([a.map(d=>[d.clip,Math.round(d.keep*1e3)]),ot(),ca(),t.type]),r=t.board&&I.lastDownload;if(!e&&r&&r.sig===o&&await _c(r)){O("",{html:'<button class="btn small" id="rv-save-again">Save another copy</button> Already saved in '+A(qo(r))+".",title:"Already saved in "+qo(r)+". A new video is made only when a take or the sound settings change."});return}let n=Io(t.type||"")==="mp4",i=Ve()+" "+qc(new Date)+"."+(n?"mp4":"webm"),s=null,l="";try{let d=await ps(!1);d&&(s=await(await d.getFileHandle(i,{create:!0})).createWritable(),l=d.name)}catch(d){if(d&&d.name==="AbortError")return}let c=no;c.disabled=!0,Xe("Preparing\u2026");try{let d=await import(Sc),k=s?new d.StreamTarget(s):new d.BufferTarget,m=new d.Output({format:n?new d.Mp4OutputFormat({fastStart:s?!1:"in-memory"}):new d.WebMOutputFormat,target:k}),f=1,b="",p=ot()&&ca();if(ot()){let D=await ai(d,a,1,!1,"Measuring");if(D&&isFinite(D.integrated)){let q=zo(D,{limit:p});if(p&&Math.abs(q)>=.05){let Q=await ai(d,a,Pa(q),!0,"Checking");Q&&isFinite(Q.integrated)&&(q=Math.min(q+(-14-Q.integrated),Po))}f=Pa(q);let de=p?-14:D.integrated+q,oe=!p&&zo(D,{limit:!0})-q>.5;b=" \xB7 loudness "+D.integrated.toFixed(1)+(Math.abs(q)<.05?" LUFS, left as is":" \u2192 "+de.toFixed(1)+" LUFS")+(oe?"; a loud peak held it back, turn on Peak limiter to reach "+-14:"")}}let T=f!==1||p;await Uc(d,a);let C=null,w=null,x=0,y=-1,E=-1,L=null,$=[],ae=async()=>{for(;$.length&&L.ready()>=$[0].n;){let D=$.shift(),q=L.take(D.n),de=new Float32Array(D.n*D.ch);q.forEach((oe,Q)=>de.set(oe,Q*D.n)),await w.add(new d.AudioSample({data:de,format:"f32-planar",numberOfChannels:D.ch,sampleRate:D.rate,timestamp:D.t}))}};for(let[D,q]of a.entries()){Xe("Joining "+(D+1)+"/"+a.length);let de=new d.Input({source:new d.BlobSource(await ga(q.clip)),formats:d.ALL_FORMATS}),oe=await de.getPrimaryVideoTrack(),Q=await de.getPrimaryAudioTrack();if(!oe)throw new Error(q.title+" has no video");C||(C=new d.EncodedVideoPacketSource(await oe.getCodec()),m.addVideoTrack(C,{frameRate:gt}),Q&&(w=T?new d.AudioSampleSource({codec:n?"aac":"opus",bitrate:Aa}):new d.EncodedAudioPacketSource(await Q.getCodec()),m.addAudioTrack(w)),await m.start());let Wt={decoderConfig:await oe.getDecoderConfig()},dt=0,Nr=!0;for await(let V of new d.EncodedPacketSink(oe).packets())V.timestamp>=q.keep||(y=Oa(y,x+V.timestamp),await C.add(V.clone({timestamp:y}),Nr&&D===0?Wt:void 0),Nr=!1,dt=Math.max(dt,V.timestamp+V.duration));if(Q&&w&&T)for await(let V of new d.AudioSampleSink(Q).samples(0,dt)){if(V.timestamp+V.duration>dt+1e-4){V.close();continue}E=Oa(E,x+V.timestamp);let ge=ls(V);if(ge.forEach(ye=>{for(let ht=0;ht<ye.length;ht++)ye[ht]*=f}),p)L=L||Ro(V.sampleRate,ge.length),L.push(ge),$.push({t:E,n:V.numberOfFrames,rate:V.sampleRate,ch:ge.length}),V.close(),await ae();else{let ye=V.numberOfFrames,ht=new Float32Array(ye*ge.length);ge.forEach((Ts,Ls)=>ht.set(Ts,Ls*ye)),await w.add(new d.AudioSample({data:ht,format:"f32-planar",numberOfChannels:ge.length,sampleRate:V.sampleRate,timestamp:E})),V.close()}}else if(Q&&w){let V={decoderConfig:await Q.getDecoderConfig()},ge=!0;for await(let ye of new d.EncodedPacketSink(Q).packets())ye.timestamp+ye.duration>dt+1e-4||(E=Oa(E,x+ye.timestamp),await w.add(ye.clone({timestamp:E}),ge&&D===0?V:void 0),ge=!1)}x+=dt}if(L&&(L.end(),await ae(),L.events&&(b+=", "+L.events+" peak"+(L.events===1?"":"s")+" limited")),Xe("Finishing\u2026"),await m.finalize(),!s){let D=document.createElement("a");D.href=URL.createObjectURL(new Blob([k.buffer],{type:n?"video/mp4":"video/webm"})),D.download=i,D.click(),setTimeout(()=>URL.revokeObjectURL(D.href),1e4)}let X={sig:o,name:i,where:l};t.board&&(I.lastDownload=X,ya()),O("Saved in "+qo(X)+" ("+ut(x*1e3)+b+")."),Xe("\u2713 Saved"),ds=setTimeout(()=>Xe(),2500)}catch(d){Xe(),O("Could not save the video: "+(d&&d.message||d),{warn:!0}),s&&s.abort().catch(()=>{})}finally{c.disabled=!!t.cleaned}}async function ai(e,t,a,o,r){let n=null,i=null;for(let[s,l]of t.entries()){Xe(r+" "+(s+1)+"/"+t.length);let c=await new e.Input({source:new e.BlobSource(await ga(l.clip)),formats:e.ALL_FORMATS}).getPrimaryAudioTrack();if(c)for await(let d of new e.AudioSampleSink(c).samples(0,l.keep)){let k=ls(d);n=n||Rn(d.sampleRate,k.length),a!==1&&o?(k.forEach(m=>{for(let f=0;f<m.length;f++)m[f]*=a}),i=i||Ro(d.sampleRate,k.length),i.push(k),i.ready()&&n.add(i.take(i.ready()))):n.add(k),d.close()}}return i&&(i.end(),i.ready()&&n.add(i.take(i.ready()))),n?n.result():null}async function Uc(e,t){let a=[];for(let i of t){let s=await new e.Input({source:new e.BlobSource(await ga(i.clip)),formats:e.ALL_FORMATS}).getPrimaryVideoTrack(),l=s&&await s.getDecoderConfig();a.push(l?l.codec+" "+l.codedWidth+"\xD7"+l.codedHeight+" "+(l.description?[...new Uint8Array(l.description)].join("."):""):"none")}let o=new Map;a.forEach(i=>o.set(i,(o.get(i)||0)+1));let r=[...o.entries()].sort((i,s)=>s[1]-i[1])[0][0],n=t.filter((i,s)=>a[s]!==r);if(n.length)throw new Error(n.map(i=>i.title).join(", ")+(n.length===1?" was":" were")+" recorded at a different size ("+a[t.indexOf(n[0])].split(" ")[1]+", not "+r.split(" ")[1]+"). Tick "+(n.length===1?"it":"them")+" and record again")}async function ps(e){if(!window.showDirectoryPicker)return null;let t=e?null:await Pr("video-folder");if(t){let a=await t.queryPermission({mode:"readwrite"});if(a==="prompt"&&(a=await t.requestPermission({mode:"readwrite"})),a==="granted")return t}return t=await window.showDirectoryPicker({id:"slidetake-videos",mode:"readwrite",startIn:"videos"}),gs("video-folder",t),t}function lt(){let e=us();if(I&&rr===e)return I;rr=e;try{I=JSON.parse(j(e)||"null")}catch{I=null}return(!I||!Array.isArray(I.takes))&&(I={takes:[],picks:{},type:"",quality:""}),I}function Gc(e){lt();let t=Hn(e,e.takesId,go());t.forEach(a=>{delete I.picks[a.id]}),I.takes.push(...t),Object.assign(I,{type:e.type,quality:e.quality}),ya(),Re.clear(),Ir({note:(e.reason?e.reason+". ":"")+t.length+" new take"+(t.length===1?"":"s")+" on the board."})}function ms(){let e=za(lt(),go()),t=Object.assign(jn(e),{board:!0,inBrowser:!0,withObs:!1,type:I.type||"video/mp4",quality:I.quality||"",deckTitle:R.title||(v[0]?u.get(v[0]).title:"Deck"),date:new Date().toISOString()});return{rows:e,sess:t}}function yo(e={}){Y.classList.add("setup-view"),ri.textContent=e.note||"",ri.hidden=!e.note,rt.textContent="\u2190 Back",rt.title="Back to Studio",rt.setAttribute("aria-expanded","true"),Yc()}function bo(){let e=Nt();e&&Y.classList.remove("setup-view"),rt.textContent="\u2699 Setup",rt.title="Settings: camera, microphone, video, OBS and files",rt.setAttribute("aria-expanded","false"),e&&(po(),Ye())}function nr(e={}){Y.classList.contains("open")?yo(e):sa({...e,setup:!0})}function Yc(){let e=()=>{Ye(),Nt()&&Di()};if(st()){kc(),Za(!1).then(e);return}vt.innerHTML="",ji().then(t=>{t.ok?Za().then(e):e()})}function Ye(){let e=i=>{let s=i.selectedOptions[0];return s?s.textContent.replace(/ \(system default\)$/,""):""},t=e(xt)||(Er()==="none"?"No camera":"Camera"),a=st(),o=a?Oi:Se().ok?It.value:"",r=a?[t]:[t,e(Ot)||"Microphone"],n=document.getElementById("rv-using");n.textContent=r.join(" \xB7 "),n.title="Recording with "+r.join(" \xB7 "),document.getElementById("rv-size").textContent=o||"",bt.classList.toggle("on",a),bt.setAttribute("aria-pressed",String(a)),bt.disabled=!Se().ok,bt.title=bt.disabled?qa+" records only with OBS: pro mode":a?"Pro mode: recording with OBS. Click for easy mode, in "+qa:"Easy mode: recording in "+qa+". Click for pro mode, with OBS"}function Ir(e={}){Ge&&(fa(),lt(),Y.classList.remove("obs"),Y.classList.add("in-browser","board"),document.getElementById("rv-rec").title="Records the whole deck, or only the ticked slides (shift-click ticks a range)",document.getElementById("rv-novideo").hidden=!0,S.src&&(URL.revokeObjectURL(S.src),S.removeAttribute("src"),S.load()),Z=null,F=null,Ft(),_a=-1,it(),ma(Y),e.setup||!Se().ok?yo(e):(bo(),ji().then(()=>Za(!1)).then(Ye)),O(e.note||ts()||(I.takes.length?Kc()+". Click a take to preview it.":v.length+" slides, nothing recorded yet. Press \u25CF Record.")))}function Kc(){let e=za(lt(),go()),t=e.filter(o=>o.pick).length,a=e.filter(o=>o.takes.length&&!o.pick).length;return t+" of "+e.length+" slides ready"+(a?", "+a+" to record again":"")}function it(){let{rows:e,sess:t}=ms();H=t;let a=document.getElementById("rv-list"),o=null;a.innerHTML=e.map(i=>{let s=zt(i.id),l=s!==o;o=s;let c=A(i.id),d={slide:"Recorded before this slide changed",before:"Starts with the entry from the slide before, which has changed or is gone: record this slide again"},k=i.takes.length?i.takes.map(m=>'<button class="rv-chip'+(i.pick===m.uid?" on":"")+(m.outdated?' outdated" title="'+d[m.outdated]:"")+'" data-id="'+c+'" data-uid="'+A(m.uid)+'">Take '+m.no+" \xB7 "+ut(m.ms)+"</button>").join("")+(i.pick?"":'<span class="rv-none">'+(i.takes.some(m=>m.outdated==="before")&&!i.takes.some(m=>m.outdated==="slide")?"The slide before changed: record again":"Changed since: record again")+"</span>"):'<span class="rv-none">No take yet</span>';return'<div class="rv-row with-sel'+(l?" sec":"")+(Re.has(i.id)?" selected":"")+'" data-id="'+c+'"><input type="checkbox" class="rv-sel" data-id="'+c+'"'+(Re.has(i.id)?" checked":"")+' aria-label="Select '+A(i.title)+' to record"><div><div class="t">'+A(i.title)+'</div><div class="rv-chips">'+k+"</div></div></div>"}).join(""),a.querySelectorAll(".rv-chip").forEach(i=>i.onclick=()=>{I.picks[i.dataset.id]=i.dataset.uid,ya(),it();let s=e.find(c=>c.id===i.dataset.id),l=s&&s.takes.find(c=>c.uid===i.dataset.uid);l&&fo([{id:s.id,clip:l.clip,keep:l.ms/1e3,title:s.title+" \xB7 take "+l.no}],0,!0)}),a.querySelectorAll(".rv-sel").forEach(i=>i.addEventListener("click",s=>{(s.shiftKey?Wn(v,oi,i.dataset.id):[i.dataset.id]).forEach(c=>{i.checked?Re.add(c):Re.delete(c)}),Ft(),oi=i.dataset.id,it()}));let r=Ra(v,Re),n=Se().ok;document.getElementById("rv-rec").disabled=!n,_a>=0&&r.length!==_a&&O(ts()||"Record takes the whole deck."),_a=r.length,document.getElementById("rv-render-btn").disabled=document.getElementById("rv-play-final").disabled=!t.events.length,rs(t),is(t)}async function Jc(e){for(let a of e)try{let[o,r]=a.clip.split("/");await(await Mr(o)).removeEntry(r)}catch{}let t=new Set(e.map(a=>a.uid));I.takes=I.takes.filter(a=>!t.has(a.uid)),Object.keys(I.picks).forEach(a=>{t.has(I.picks[a])&&delete I.picks[a]}),ya(),S.src&&(URL.revokeObjectURL(S.src),S.removeAttribute("src"),S.load()),F=null,Ft(),it()}function fs(e){return new Promise((t,a)=>{let o=indexedDB.open(e||"slidetake",1);o.onupgradeneeded=()=>o.result.createObjectStore("kv"),o.onsuccess=()=>t(o.result),o.onerror=()=>a(o.error)})}async function Pr(e){let t=async a=>{let o=await fs(a);return await new Promise(r=>{let n=o.transaction("kv").objectStore("kv").get(e);n.onsuccess=()=>r(n.result),n.onerror=()=>r(null)})};try{return await t()??await t("markcast")??await t("traverse")??null}catch{return null}}async function gs(e,t){try{(await fs()).transaction("kv","readwrite").objectStore("kv").put(t,e)}catch{}}async function vo(e){sr=!0;try{return await $c(e)}finally{sr=!1}}async function $c(e){let t=await e.getFile();for(let a=0;a<10;a++){await new Promise(r=>setTimeout(r,1e3));let o=await e.getFile();if(o.size===t.size&&o.lastModified===t.lastModified)return o;t=o}return t}function ba(e,t,a){S.src&&URL.revokeObjectURL(S.src),Xt=t||null,a||(ir=0),S.src=URL.createObjectURL(e),_e=e.name,document.getElementById("rv-novideo").hidden=!0,O("Loaded "+e.name+". Click a take to preview it."),oo?ro(oo):a&&Z&&ro(Z.ranges.slice(Z.i))}async function Xc(e){let t=mt(e.outputPath);if(!(!t||!window.showDirectoryPicker)&&!(_e===t&&S.src))try{let a=await Pr("obs-folder");if(!a||await a.queryPermission({mode:"read"})!=="granted")return;let o=await a.getFileHandle(t);O("Opening "+t+"\u2026"),ba(await vo(o),o)}catch{}}function Et(e,t){if(!h.active){if(clearTimeout(Va),!B.hidden&&!B.classList.contains("live")){Zt.classList.remove("show"),bs.textContent=e,B.classList.add("msg"),t||(Va=setTimeout(vs,9e3));return}Zt.textContent=e,Zt.classList.add("show"),t||(Va=setTimeout(()=>Zt.classList.remove("show"),9e3))}}function vs(){bs.textContent="PIP camera",B.classList.remove("msg")}function zr(){clearTimeout(Va),Zt.classList.remove("show"),vs()}function Vo(){let e=!1;try{e=window.top!==window.self}catch{e=!0}return e?" This page is running inside a preview frame that may not allow cameras. Open Slidetake directly in Chrome (from localhost or as a file).":window.isSecureContext?" Allow camera access for this page in the browser\u2019s site settings (the icon at the left of the address bar), then try again.":" Browsers only allow cameras on secure pages. Open it from http://localhost or as a local file in Chrome."}function Rr(){re&&re.getTracks().forEach(t=>t.stop()),re=null;let e=B.querySelector("video");e&&e.remove()}async function ct(){if(!(re||te)){{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){Et("Camera not available on this page."+Vo(),!0);return}if(Te.disabled)return;Te.disabled=!0,Et("Waiting for camera permission \u2014 check the browser prompt near the address bar.",!0);try{let t=j("slidetake:cam");re=await navigator.mediaDevices.getUserMedia({video:{...t?{deviceId:{ideal:t}}:{},width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},audio:!1}),zr()}catch(t){let a=t&&t.name;Et(a==="NotAllowedError"||a==="SecurityError"?"Camera access was blocked."+Vo():a==="NotFoundError"||a==="OverconstrainedError"?"No camera was found. Check that a webcam is connected.":a==="NotReadableError"?"The camera is busy \u2014 close other apps using it (Zoom, OBS, FaceTime) and try again.":"Could not start the camera"+(a?" ("+a+")":"")+"."+Vo(),!0);return}finally{Te.disabled=!1,Dr()}re.getVideoTracks().forEach(t=>t.addEventListener("ended",()=>{Rr(),Ya(),fe()}));let e=document.createElement("video");e.autoplay=!0,e.muted=!0,e.playsInline=!0,e.srcObject=re,B.appendChild(e)}Ya(),fe()}}function ws(e,t){e.classList.toggle("on",t),e.setAttribute("aria-pressed",String(t))}function Dr(){Te.querySelector("svg")||(Te.innerHTML=Qc+'<span class="lbl"> <u class="key">C</u>amera</span>'),Te.classList.toggle("on",!te),Te.setAttribute("aria-pressed",String(!te)),Te.title=te?"Camera is off for every slide (C)":"Camera is on and follows the deck (C)"}function Ht(e,t){e&&!Ge||(te=!e,t||W("slidetake:camera",e?"on":"off"),te&&(Rr(),zr()),ve=null,Fe=-1,ke=Math.min(ke,Math.max(0,Rt(u.get(g)).length-1)),Dr(),Ya(),ua(),Dt(),fe(),!K&&!t&&Et(e?"Camera on \u2014 slides follow their camera settings.":"Camera off \u2014 camera settings are ignored and slides use the whole screen."),e&&ct())}function xs(){document.body.classList.remove("idle"),clearTimeout(ni),K&&(ni=setTimeout(()=>document.body.classList.add("idle"),2e3))}function da(e,t){Ct.textContent=e,Ct.classList.add("show"),clearTimeout(si),si=setTimeout(()=>Ct.classList.remove("show"),t||2500)}function lr(e,{keepObs:t=!0,keepEdit:a=!0,slide:o=""}={}){let r=new URL(fn(e),location.origin);return new URLSearchParams(location.search).forEach((n,i)=>{i==="src"||i==="obs"&&!t||i==="edit"&&!a||r.searchParams.set(i,n)}),o&&(r.hash=o),r.href.replace(r.pathname,r.pathname.replace(/%40/g,"@"))}async function ed(e){let t={keepObs:!1,keepEdit:!1,slide:e};if(M.kind==="source")return{link:lr(M.source,t),inside:!1};if(M.kind==="copy"&&Ca(P)&&["url","gist","builtin"].includes(P.origin.kind))return{link:lr(P.origin,t),inside:!1};let o=M.kind==="share"?M.data:await yn(ie.value),r=new URLSearchParams(location.search);return["src","obs","edit"].forEach(n=>r.delete(n)),{link:location.origin+"/share"+(r.toString()?"?"+r:"")+Lo(o,e),inside:!0}}function td(){let e=j("slidetake:draft");if(!e||e===wo)return null;let t=Sa(e,{kind:"file",name:"your earlier draft"},{exported:!0});W("slidetake:copy",JSON.stringify(t));try{localStorage.removeItem("slidetake:draft")}catch{}return t}function va(){W("slidetake:copy",JSON.stringify(P))}function jt(){if(U)return;let e;if(Fr())e='<span class="mine">'+A(pe.file)+'</span> <span class="ro">\xB7 on this computer, saved as you type</span>';else if(M.kind==="copy")e='<span class="mine">Your copy of '+A(Ee(P.origin))+"</span>"+(Ea(P)?' <span class="edited">\xB7 edited</span>':"");else{let a=M.kind==="share"?"a shared deck":Ee(M.source);e='<span class="mine">'+A(a.charAt(0).toUpperCase()+a.slice(1))+'</span> <span class="ro">\xB7 read-only, typing makes your copy</span>'}document.getElementById("doc-state").innerHTML=e,qe.classList.toggle("unsaved",M.kind==="copy"&&Ea(P)),document.getElementById("btn-reset").hidden=!(M.kind==="copy"&&!Ca(P));let t=document.getElementById("continue");t.hidden=M.kind==="copy"||!P,P&&(t.textContent="Your copy \u2192",t.title="Continue your copy of "+Ee(P.origin))}function ks(e){return!P||!Ea(P)?!0:confirm("Your copy of "+Ee(P.origin)+" has edits you haven't saved or shared. Replace it with "+e+"?")}function Ss(){let e=new URLSearchParams(location.search);return e.delete("src"),e.delete("template"),"/edit"+(e.toString()?"?"+e:"")}function ad(){let e=M.kind==="share"?{kind:"shared"}:M.source;return ks("a copy of "+Ee(e))?(P=Sa(M.text,e),M={kind:"copy"},history.pushState(null,"",Ss()+(g&&g!==v[0]?"#"+encodeURIComponent(g):"")),da("Editing your own copy of "+Ee(e)+". The original is unchanged.",4e3),!0):(ie.value=M.text,!1)}function od(){M={kind:"copy"},history.pushState(null,"",Ss()),qe.classList.contains("collapsed")&&ho(),ie.value=P.text,At(!0),jt()}function Fr(){return!!(pe&&M&&M.kind==="source"&&M.source.kind==="url"&&new URL(M.source.url,location.href).pathname===pe.deck)}function rd(e){fetch(pe.save,{method:"PUT",body:e}).catch(()=>da("Could not save "+pe.file+": is npx slidetake still running?",6e3))}async function nd(e){if(e.kind==="builtin")return Ga[e.id==="help"?"docs":e.id]??Ga.home;if(e.kind==="gist"){let a=await fetch("https://api.github.com/gists/"+encodeURIComponent(e.id));if(!a.ok)throw new Error(a.status===404?"no such gist":a.status+" "+a.statusText);let o=Object.values((await a.json()).files||{}),r=o.find(n=>n.filename===e.file)||o.find(n=>/\.(md|markdown)$/i.test(n.filename))||o[0];if(!r)throw new Error("the gist has no files");return He=r.raw_url,r.truncated?await(await fetch(r.raw_url)).text():r.content}let t=await fetch(e.url);if(!t.ok)throw new Error(t.status===404?"not found":t.status+" "+t.statusText);return He=new URL(e.url,location.href).href,await t.text()}function di(){return M={kind:"source",source:{kind:"builtin",id:"home"},text:Ga.home},M.text}async function id(){if(pe&&ee.page==="source"&&ee.source.kind==="builtin"&&ee.source.id==="home"&&location.pathname==="/"&&(ee.source={kind:"url",url:pe.deck}),U)return He=U.base||location.href,M={kind:"source",source:{kind:"url",url:He},text:ln(U.settings||{})+String(U.markdown||"")},M.text;if(ee.page==="edit"){if(P)return M={kind:"copy"},P.text;history.replaceState(null,"","/new"+location.search),ee.page="pick"}if(ee.page==="pick")return ma(document.getElementById("new-dialog")),M={kind:"source",source:{kind:"builtin",id:"template:blank"},text:Ga["template:blank"]},M.text;if(ee.page==="share")try{let e=await bn(ee.data);return M={kind:"share",data:ee.data,text:e},e}catch{return da("This link's deck is damaged or cut short, so it could not be opened.",6e3),di()}try{let e=await nd(ee.source);return M={kind:"source",source:ee.source,text:e},e}catch(e){return aa.textContent="Could not load the deck ("+e.message+")",da("Could not load "+Ee(ee.source)+": "+e.message,6e3),di()}}var U,pe,hr,Ge,Ue,Ga,ie,N,se,Fo,Un,tl,aa,Go,al,qe,Da,ol,Mt,No,le,Yo,rl,nl,il,sl,ll,cl,oa,u,v,tt,g,pr,J,K,R,te,re,ze,B,ce,z,ea,hl,Ie,qn,Je,Vn,ke,ve,Fe,Ne,Me,Ae,Ml,Tl,Bl,bi,jo,Pl,He,Yn,Hl,jl,Wl,Kn,ql,Fa,Vl,Kl,Jl,Wo,$e,_o,Qe,je,sc,Lt,ue,Ci,Be,Ze,Ce,Na,wt,yt,Xn,mc,Qn,Zn,ei,Y,$t,Zo,Ja,$a,Xa,br,ta,ne,Oe,et,vr,Oi,h,na,ia,fc,wr,gc,Pi,vc,xc,Sc,xt,Ot,It,er,vt,kt,me,ja,he,tr,kr,Ha,Wa,ar,eo,Ec,Ni,st,Ac,Wi,at,ti,_e,Hc,jc,Ki,ot,Ji,or,ca,$i,Xi,Qi,Zi,es,H,Z,S,Jt,_a,ts,os,Ua,Uo,ao,oo,ss,St,F,no,ds,Xe,qo,qc,I,rr,oi,Re,us,ya,Vc,go,rt,ri,Nt,qa,bt,Xt,ir,sr,Qt,ys,Te,Zt,Va,bs,Qc,ni,xe,ii,Ct,si,Zc,cr,dr,li,io,ee,ci,M,P,Es=G(()=>{"use strict";_r();Ur();Vr();Yr();Jr();Xr();Zr();tn();xa();dn();un();Mo();Ao();xn();Sn();zn();Dn();_n();La();U=window.SLIDETAKE||null;document.getElementById("deck-text")?.remove();pe=window.SLIDETAKE_LOCAL||null,hr=document.querySelector("header .mark .logo").outerHTML;document.documentElement.classList.toggle("embed",!!U);Ge=!U||U.recording===!0;document.documentElement.classList.toggle("no-record",!Ge);Ue=window.matchMedia("(prefers-reduced-motion: reduce)").matches,Ga={home:wo,docs:qr,features:Gr,privacy:Kr,showcase:an,"template:blank":$r,"template:talk":Qr,"template:recording":en},ie=document.getElementById("editor"),N=document.getElementById("stage"),se=document.getElementById("world"),Fo=document.getElementById("connectors"),Un=document.getElementById("breadcrumbs"),tl=document.getElementById("status-count"),aa=document.getElementById("status-err"),Go=document.getElementById("mm-svg"),al=document.getElementById("mm-label"),qe=document.getElementById("editor-pane"),Da=540,ol=96,Mt=440,No=720,le=960,Yo=180,rl=540,nl=100,il=110,sl=420,ll=.35,cl=1,oa=parseFloat(j("slidetake:slideSize"))||.92,u=new Map,v=[],tt=[],g=null,pr=["focus","path","radial","tree"],J="path",K=!1,R={},te=!0,re=null,ze=document.getElementById("brand"),B=document.getElementById("pip"),ce=document.getElementById("stage-wrap"),z={x:0,y:0,zoom:.6},ea=null;hl='<span class="st-name">'+hr+'Slide<span class="st-take">take</span></span>';Ie=()=>/^(portrait|vertical|9:16)$/i.test(String(R.format||"").trim());qn={accent:"--accent",accentSoft:"--accent-teal",line:"--accent-line",ring:"--accent-ring",header:"--header-bg",headerText:"--header-ink",onAccent:"--on-accent"};Je=null;Vn=new URLSearchParams(location.search).get("mode");ke=0;ve=null,Fe=-1,Ne=null;Me=document.getElementById("cam-overlay"),Ae="";new ResizeObserver(()=>{Ae&&$o()}).observe(ce);Ml=new Set("svg g defs symbol use path rect circle ellipse line polyline polygon text tspan textPath title desc marker linearGradient radialGradient stop clipPath mask pattern filter feGaussianBlur feOffset feBlend feFlood feComposite feMerge feMergeNode feColorMatrix feDropShadow".split(" ")),Tl=0;Bl=e=>e.querySelector("img")&&!e.textContent.trim()&&[...e.children].every(t=>/^(IMG|BR)$/.test(t.tagName));bi=["dot","d2","echarts","svg"].map(e=>":scope > code.language-"+e).join(", "),jo=e=>!!e.querySelector("img")&&!e.textContent.trim(),Pl=e=>e.children.length===1&&(e.children[0].tagName==="PRE"&&!!e.children[0].querySelector(bi)||e.children[0].matches("div.diagram"));He=null;Yn=null;Hl="https://cdn.jsdelivr.net/npm/@viz-js/viz@3.4.0/lib/viz-standalone.js",jl="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js",Wl={dark:{palette:["#60a5fa","#f472b6","#a78bfa","#fb923c","#facc15","#a1a1aa"],text:"#e4e4e7",muted:"#a1a1aa",line:"#3f3f46",split:"#27272a",tip:"#18181b"},light:{palette:["#2563eb","#db2777","#7c3aed","#ea580c","#ca8a04","#71717a"],text:"#27272a",muted:"#71717a",line:"#d4d4d8",split:"#e4e4e7",tip:"#ffffff"}};Kn=new Set;ql="https://esm.sh/@terrastruct/d2@0.1.33",Fa=null,Vl={dark:{N1:"#e4e4e7",N2:"#a1a1aa",N3:"#a1a1aa",N4:"#323238",N5:"#27272a",N6:"#18181b",N7:"#09090b"},light:{N1:"#27272a",N2:"#71717a",N3:"#71717a",N4:"#e4e4e7",N5:"#e4e4e7",N6:"#f4f4f5",N7:"#ffffff"}};Kl=(e,t)=>e.replace("{","{"+t),Jl=e=>/d2-config\s*:/.test(e)?e:`vars: {
|
|
1316
1433
|
d2-config: {
|
|
1317
1434
|
layout-engine: elk
|
|
1318
1435
|
}
|
|
1319
1436
|
}
|
|
1320
|
-
`+e,
|
|
1321
|
-
`+t.html):""},lo=()=>Ln(g,e=>({title:u.get(e).title,fp:Oc(e)}));$e=document.getElementById("rv-setup-btn"),Kn=document.getElementById("setup-note"),Bt=()=>Y.classList.contains("setup-view");new MutationObserver(()=>{Y.classList.contains("open")||ho()}).observe(Y,{attributes:!0,attributeFilter:["class"]});$e.onclick=()=>{Bt()?ho():co()};document.getElementById("setup-record").onclick=()=>{la(),pe||(pe=et()?"obs":"browser",U("slidetake:rec-mode",pe)),gr()};Y.addEventListener("click",e=>{(e.target===Y||e.target.closest("[data-close]"))&&ro()});Fa=(()=>{let e=(navigator.userAgentData&&navigator.userAgentData.brands||[]).map(a=>a.brand).filter(a=>!/chromium|not.?a.?brand/i.test(a));if(e.length)return e[0].replace(/^(Google|Microsoft) /,"");let t=navigator.userAgent;return/Firefox\//.test(t)?"Firefox":/Edg\//.test(t)?"Edge":/OPR\//.test(t)?"Opera":/Chrome\//.test(t)?"Chrome":/Safari\//.test(t)?"Safari":"this browser"})();document.querySelectorAll(".browser-name").forEach(e=>{e.textContent=Fa});document.getElementById("rv-rec").onclick=()=>{if(!et()){Ka("browser",La(g,Be));return}if(Le){Ka("obs");return}Xo({note:"Connect to OBS first: OBS \u2192 Connect."})};dt=document.getElementById("rv-pro");dt.onclick=()=>{ke().ok&&fc(et()?"browser":"obs")};document.querySelectorAll(".rv-purge .rv-menu button").forEach(e=>e.addEventListener("click",()=>{e.closest("details").open=!1}));document.getElementById("rv-clean-unused").onclick=async()=>{let{rows:e}=os(),t=new Set(e.map(o=>o.pick).filter(Boolean)),a=O.takes.filter(o=>!t.has(o.uid));if(!a.length){B("Every take is in use.");return}confirm("Purge "+a.length+" take"+(a.length===1?"":"s")+" the video doesn\u2019t use (earlier attempts and outdated takes)?")&&(await Rc(a),B("Purged "+a.length+" unused take"+(a.length===1?"":"s")+"."))};document.getElementById("rv-clean").onclick=async()=>{if(!O.takes.length||!confirm("Purge all "+O.takes.length+" takes of this deck from this browser? Download the video first if you need it."))return;let e=new Set(O.takes.map(t=>t.clip.split("/")[0]));O.takes=[],O.picks={},da();for(let t of e)await vr(t);k.src&&(URL.revokeObjectURL(k.src),k.removeAttribute("src"),k.load()),F=null,At(),B("All takes purged."),Qe()};document.getElementById("rv-clean-every").onclick=async()=>{let e,t=0,a=0;try{e=await navigator.storage.getDirectory()}catch{return}let o=async s=>{for await(let l of s.values())l.kind==="directory"?await o(l):(a++,t+=(await l.getFile()).size)};try{await o(await e.getDirectoryHandle("slidetake-takes"))}catch{}let r=[];try{for(let s=0;s<localStorage.length;s++){let l=localStorage.key(s);l&&l.startsWith("slidetake:board:")&&r.push(l)}}catch{}let n=r.filter(s=>{try{return JSON.parse(localStorage.getItem(s)||"{}").takes.length>0}catch{return!1}}).length;if(!a){B("No takes are kept in this browser.");return}let i=t>1e9?(t/1e9).toFixed(1)+" GB":Math.max(1,Math.round(t/1e6))+" MB";if(confirm("Purge "+i+" of takes ("+a+" file"+(a===1?"":"s")+") from "+(n||"no")+" deck"+(n===1?"":"s")+" and any left behind? Every deck loses its takes; download the videos you need first.")){try{await e.removeEntry("slidetake-takes",{recursive:!0})}catch{}r.forEach(s=>{try{localStorage.removeItem(s)}catch{}}),U("slidetake:sessions",JSON.stringify(no().map(s=>s.inBrowser?{...s,cleaned:!0}:s))),O=null,$o="",tt(),Da.clear(),k.src&&(URL.revokeObjectURL(k.src),k.removeAttribute("src"),k.load()),F=null,At(),Qe(),B("Purged "+i+" of takes from every deck.")}};qt=null,Qo=0,Zo=!1;k.addEventListener("error",async()=>{if(k.getAttribute("src")){if(qt&&Qo<5){Qo++,B("Reloading "+Fe+" (OBS was still finishing it)\u2026"),await new Promise(e=>setTimeout(e,1500));try{ha(await po(qt),qt,!0);return}catch{}}B(qt?"Chrome cannot play "+Fe+". In OBS set Recording Format to Hybrid MP4 (or MP4) with H.264 video; the ffmpeg command still works with this file.":"Could not play "+(Fe||"this file")+". If OBS was still finishing it when you opened it, open it again; if it still fails, set OBS to Hybrid MP4 (or MP4) with H.264 video.",{warn:!0})}});Gt=document.getElementById("rv-file-input");Gt.addEventListener("change",()=>{Gt.files[0]&&ha(Gt.files[0]),Gt.value=""});document.getElementById("rv-open").onclick=async()=>{if(!window.showOpenFilePicker)return Gt.click();try{let[e]=await window.showOpenFilePicker({id:"obs-recordings",types:[{description:"Recordings",accept:{"video/*":[".mov",".mp4",".m4v",".mkv",".webm"]}}]});B("Opening "+e.name+"\u2026"),ha(await po(e),e)}catch(e){(!e||e.name!=="AbortError")&&B("Could not open that file.",{warn:!0})}};is=document.getElementById("rv-folder");window.showDirectoryPicker||(is.style.display="none");is.onclick=async()=>{let e=N&&st(N.outputPath);try{let t=await window.showDirectoryPicker({id:"obs-recordings",mode:"read"});if(ns("obs-folder",t),!e){B("Folder remembered. This session has no file name from OBS; open the file instead.");return}let a=await t.getFileHandle(e);ha(await po(a),a)}catch{}};nc()&&new URLSearchParams(location.search).get("obs")&&fr();Ce=document.getElementById("btn-camera"),Vt=document.getElementById("pip-msg"),Na=null,ss=P.querySelector("span");Nc='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="6" width="14" height="12" rx="2"/><path d="M16 10.5 22 7v10l-6-3.5z"/></svg>';Ce.onclick=()=>pa(re);Mr();Jn=null;window.addEventListener("pointermove",ds);document.addEventListener("fullscreenchange",()=>{document.fullscreenElement||(h.active?Et("Stopped: the browser left fullscreen"):K&&ve(!1))});be=document.getElementById("help");new MutationObserver(()=>cs(document.getElementById("btn-keys"),be.classList.contains("open"))).observe(be,{attributes:!0,attributeFilter:["class"]});new MutationObserver(()=>{let e=Y.classList.contains("open");document.getElementById("btn-studio").classList.toggle("active",e),!e&&!k.paused&&k.pause()}).observe(Y,{attributes:!0,attributeFilter:["class"]});document.getElementById("btn-keys").onclick=()=>be.classList.add("open");document.getElementById("help-close").onclick=()=>be.classList.remove("open");be.addEventListener("click",e=>{e.target===be&&be.classList.remove("open")});window.addEventListener("keydown",e=>{if(e.key==="F5"){e.preventDefault(),h.active||ea();return}if(h.active){wc(e);return}if(document.querySelector(".modal.open")){let o=Y.classList.contains("open")&&Bt();if(e.key==="Escape")la();else if(Y.classList.contains("open")&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!/^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName||"")){let r=e.key.toLowerCase(),n=r==="r"?o?"setup-record":"rv-rec":o?"":r==="p"?"rv-play-final":r==="d"?et()?"rv-ffmpeg-copy":"rv-render-btn":"",i=n?document.getElementById(n):null;i&&!i.disabled&&(e.preventDefault(),i.click())}return}let t=document.activeElement&&document.activeElement.tagName;if(t==="TEXTAREA"||t==="INPUT"||e.metaKey||e.ctrlKey||e.altKey)return;if(be.classList.contains("open")){/^(Escape|k|K|\?|\/)$/.test(e.key)&&be.classList.remove("open");return}let a=e.key;a==="ArrowRight"||a===" "||a==="PageDown"?(e.preventDefault(),De(1)):a==="ArrowLeft"||a==="PageUp"?(e.preventDefault(),De(-1)):a==="ArrowDown"?(e.preventDefault(),Zl()):a==="ArrowUp"?(e.preventDefault(),Ql()):a==="Home"?g.length&&j(g[0]):a==="End"?g.length&&j(g[g.length-1]):a==="o"||a==="O"?Xl():a==="e"||a==="E"?oo():a==="f"||a==="F"||a==="p"||a==="P"?ve(!K):a==="r"||a==="R"?gr():a==="s"||a==="S"?ea():/^[1-4]$/.test(a)?dr(rr[+a-1]):a==="c"||a==="C"?pa(re):a==="v"||a==="V"?ll():a==="l"||a==="L"?ai():a==="+"||a==="="?jn(1):a==="-"||a==="_"?jn(-1):a==="?"||a==="/"||a==="k"||a==="K"?be.classList.add("open"):a==="Escape"&&!yi()&&K&&ve(!1)});window.addEventListener("hashchange",()=>{let{data:e,slide:t}=ga(location.hash);if(e&&!(E&&E.kind==="share"&&e===E.data)){location.reload();return}t&&t!==f&&u.has(t)&&j(t)});$n="";new ResizeObserver(()=>{let e=H.clientWidth+"x"+H.clientHeight;e!==$n&&($n=e,vt(),xe(!0))}).observe(H);gt=document.createElement("div");gt.id="toast";gt.setAttribute("role","status");document.body.appendChild(gt);Xn=null;Hc=document.getElementById("open-dialog"),tr=document.getElementById("open-url"),ar=document.getElementById("open-error");document.getElementById("btn-load").onclick=()=>{ar.hidden=!0,sa(Hc),tr.focus(),tr.select()};document.getElementById("open-form").onsubmit=e=>{e.preventDefault();let t=on(tr.value);if(!t){ar.textContent="That doesn't look like a link.",ar.hidden=!1;return}location.href=er(t)};document.getElementById("btn-share").onclick=async()=>{let{link:e,inside:t}=await jc(f&&f!==g[0]?f:""),a=t?"Link copied, with the whole deck inside it ("+(e.length/1024).toFixed(1)+" KB)"+(e.length>8e3?". Some chat apps cut long links short: a GitHub file or gist makes a shorter one.":"."):"Link copied.";try{await navigator.clipboard.writeText(e),oa(a,5e3)}catch{prompt("Copy this link:",e)}E.kind==="copy"&&(I.exported=I.text,ua(),Ot())};Qn=W("slidetake:layout");J=rr.includes(Qn)?Qn:"path";document.querySelectorAll("#layout-toggle .seg-btn").forEach(e=>e.classList.toggle("active",e.dataset.mode===J));Za=new URLSearchParams(location.search);rr.includes(Za.get("layout"))&&(J=Za.get("layout"),document.querySelectorAll("#layout-toggle .seg-btn").forEach(e=>e.classList.toggle("active",e.dataset.mode===J)));if(_){let e=(Array.isArray(_.trail)?_.trail:_.back?[_.back]:[]).filter(r=>r&&r.label),t=document.querySelector("header .brand");e.length&&(t.innerHTML='<nav class="trail" aria-label="Site">'+e.map((r,n)=>(n?'<span class="sep" aria-hidden="true">|</span>':"")+(r.url?'<a href="'+A(r.url)+'">'+A(r.label)+"</a>":"<span>"+A(r.label)+"</span>")).join("")+"</nav>");let a=document.createElement("a");a.id="credit",a.href="https://slidetake.com",a.target="_blank",a.rel="noopener",a.title="Made with Slidetake",a.setAttribute("aria-label","Made with Slidetake"),a.innerHTML=or+'<span class="word">Slide<span>take</span></span>';let o=document.querySelector("header .hdr-actions");o.insertBefore(a,o.firstChild),Ze||(o.insertAdjacentHTML("beforeend",'<button class="btn" id="hdr-keys" title="Keyboard shortcuts (K)">\u2328 Keys</button><button class="btn" id="hdr-full" title="Fullscreen (F)">\u26F6 Fullscreen</button>'),document.getElementById("hdr-keys").onclick=()=>document.getElementById("help").classList.add("open"),document.getElementById("hdr-full").onclick=()=>ve(!K))}ee=cn(location.pathname,location.search,location.hash),Zn=ee.page==="pick"?"":ee.slide,E=null,I=dn(W("slidetake:copy"))||_c();window.addEventListener("popstate",()=>location.reload());he&&window.EventSource&&(new EventSource(he.events).onmessage=async e=>{if(!Tr())return;let t=(JSON.parse(e.data).file||"").replace(/\\/g,"/");if(t===he.file){let a=await(await fetch(he.deck,{cache:"no-store"})).text();if(a===ie.value)return;ie.value=E.text=a,wt(!0);return}se.querySelectorAll("img").forEach(a=>{let o=new URL(a.src);decodeURIComponent(o.pathname).endsWith("/"+t)&&(o.searchParams.set("t",String(Date.now())),a.src=o.href)})});(Za.get("edit")==="1"||ee.page==="edit"&&I&&Za.get("edit")!=="0")&&oo();Vc().then(e=>(ie.value=e,Ot(),ri(ie.value),ci(),document.fonts?document.fonts.ready:null)).then(()=>{u.forEach(to),ra(),j(u.has(Zn)?Zn:g[0],!0)})});var Ar=` /* Every colour comes from these tokens. Slidetake's own is seafoam green: bright on zinc in dark mode,
|
|
1437
|
+
`+e,Wo={};$e=0,_o=null;Qe=document.getElementById("progress");Qe.innerHTML="<b></b><i></i>";je={start:0,timer:null};sc=["x","y","xPercent","yPercent","scale","scaleX","scaleY","rotation","rotate","skewX","skewY"];Lt=null;ue=null,Ci=null,Be=!1;Ze=null;Ce=null;Go.addEventListener("click",e=>{let t=e.target.closest("circle");t&&!h.active&&_(t.dataset.id)});Na=null;ie.addEventListener("input",()=>{if(Fr()){M.text=ie.value,clearTimeout(Na),Na=setTimeout(()=>{rd(ie.value),At(!0)},300);return}M.kind!=="copy"&&!ad()||(P.text=ie.value,jt(),clearTimeout(Na),Na=setTimeout(()=>{va(),At(!0)},300))});document.querySelectorAll("#layout-toggle .seg-btn").forEach(e=>{e.addEventListener("click",()=>{e.dataset.mode!==J&&yr(e.dataset.mode)})});(function(){let e=new Map,t=0,a=!1,o=null,r=()=>{let[i,s]=[...e.values()];return Math.hypot(i.x-s.x,i.y-s.y)||1};N.addEventListener("pointerdown",i=>{i.pointerType==="mouse"&&i.button!==0||h.active||i.target.closest("a, pre, code, input, textarea")||(e.set(i.pointerId,{x:i.clientX,y:i.clientY}),t=0,a=!1,e.size===2&&(o={d:r(),zoom:z.zoom}))}),window.addEventListener("pointermove",i=>{let s=e.get(i.pointerId);if(!s)return;let l=i.clientX-s.x,c=i.clientY-s.y;e.set(i.pointerId,{x:i.clientX,y:i.clientY}),t+=Math.abs(l)+Math.abs(c),!a&&t>5&&(a=!0,mr(),N.classList.add("dragging")),a&&(e.size===2&&o?z.zoom=Ai(o.zoom*r()/o.d):(z.x-=l/z.zoom,z.y-=c/z.zoom),Tt())});let n=i=>{e.delete(i.pointerId),e.size<2&&(o=null),e.size||N.classList.remove("dragging")};window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),N.addEventListener("click",i=>{a&&(i.stopPropagation(),i.preventDefault(),a=!1)},!0)})();N.addEventListener("wheel",e=>{e.preventDefault(),!h.active&&Bi(Math.exp(-e.deltaY*(e.ctrlKey?.01:.0015)),e.clientX,e.clientY)},{passive:!1});document.getElementById("nav-prev").onclick=()=>We(-1);document.getElementById("nav-next").onclick=()=>We(1);document.getElementById("btn-open").onclick=()=>document.getElementById("file-input").click();document.getElementById("file-input").addEventListener("change",e=>{let t=e.target.files[0];if(!t)return;let a=new FileReader;a.onload=()=>{ks("a copy of "+t.name)&&(P=Sa(String(a.result),{kind:"file",name:t.name},{exported:!0}),va(),He=null,g=null,od())},a.readAsText(t),e.target.value=""});document.getElementById("btn-save").onclick=()=>{let e=new Blob([ie.value],{type:"text/markdown"}),t=document.createElement("a");t.href=URL.createObjectURL(e),t.download=(tt[0]?pt(u.get(tt[0]).title):"deck")+".md",t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),1e3),M.kind==="copy"&&(P.exported=P.text,va(),jt())};document.getElementById("btn-reset").onclick=()=>{M.kind!=="copy"||Ca(P)||confirm("Discard your edits and go back to "+Ee(P.origin)+" as it was?")&&(P.text=P.originText,va(),ie.value=P.text,g=null,At(!0),jt())};document.getElementById("btn-edit-toggle").onclick=ho;wt=document.querySelector("main"),yt=document.getElementById("editor-resizer"),Xn=parseFloat(j("slidetake:editorWidth"));Xn&&qe.style.setProperty("--editor-w",Xn+"px");yt.addEventListener("pointerdown",e=>{e.preventDefault(),yt.setPointerCapture(e.pointerId),wt.classList.add("resizing");let t=wt.getBoundingClientRect().right,a=r=>{let n=Math.round(Math.max(280,Math.min(window.innerWidth*.75,t-r.clientX)));qe.style.setProperty("--editor-w",n+"px")},o=()=>{wt.classList.remove("resizing"),yt.removeEventListener("pointermove",a),W("slidetake:editorWidth",String(qe.getBoundingClientRect().width))};yt.addEventListener("pointermove",a),yt.addEventListener("pointerup",o,{once:!0})});yt.addEventListener("dblclick",()=>{qe.style.removeProperty("--editor-w");try{localStorage.removeItem("slidetake:editorWidth")}catch{}});document.getElementById("btn-mode").onclick=pi;document.getElementById("btn-present").onclick=()=>we(!K);mc="https://cdn.jsdelivr.net/npm/obs-websocket-js@5.0.5/dist/obs-ws.min.js",Qn=["ArrowRight","PageDown"," ","ArrowDown","Enter"],Zn=["ArrowLeft","PageUp","ArrowUp","r","R"],ei=["b","B","."],Y=document.getElementById("review"),$t=document.getElementById("rec-countdown"),Zo=document.getElementById("rec-paused"),Ja=document.getElementById("obs-host"),$a=document.getElementById("obs-port"),Xa=document.getElementById("obs-pass"),br=document.getElementById("obs-remember"),ta=document.getElementById("obs-status"),ne=null,Oe=!1,et=null,vr=null,Oi="",h={active:!1,withObs:!1,counting:!1,paused:!1,finishing:!1,t0:0,pauseAt:0,pausedMs:0,events:[],outputPath:null,browser:null},na=e=>new Promise(t=>setTimeout(t,e)),ia=()=>Promise.race([new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),na(100)]);fc="G-3S9FY4MQLS",wr=document.getElementById("analytics-dialog"),gc=()=>j("slidetake:analytics")!=="off";wr.querySelectorAll("[data-analytics]").forEach(e=>e.onclick=()=>yc(e.dataset.analytics==="on"));Pi=document.getElementById("btn-analytics");Pi.hidden=!/^(www\.)?slidetake\.com$/.test(location.hostname);Pi.onclick=()=>{Ii(),ma(wr)};document.querySelectorAll(".modal").forEach(e=>{e.addEventListener("click",t=>{(t.target===e||t.target.closest("[data-close]"))&&e.classList.remove("open")})});vc=e=>/^(localhost|127(\.\d+){3}|\[?::1\]?)$/i.test(e);xc="Run OBS on this computer and connect to localhost: a secure (https) page can't reach OBS at any other address.";document.getElementById("obs-connect").onclick=xr;br.addEventListener("change",zi);Sc="https://cdn.jsdelivr.net/npm/mediabunny@1.64.0/+esm",xt=document.getElementById("rec-cam"),Ot=document.getElementById("rec-mic"),It=document.getElementById("rec-quality"),er=document.getElementById("rec-meter"),vt=document.getElementById("rec-browser-check"),kt=document.getElementById("rec-wave"),me=j("slidetake:rec-mode")||"",ja="",he=null;tr=0;kr=document.getElementById("rec-cam-preview"),Ha=document.getElementById("rec-cam-none"),Wa=null,ar=0;Ot.onchange=()=>{W("slidetake:mic",Ot.value),Qa(),Ye()};eo=document.getElementById("rec-mirror");eo.onchange=()=>{W("slidetake:mirror",eo.checked?"on":"off"),Sr(),Pe()};Sr();xt.onchange=()=>{Cc(xt.value),xt.value!=="none"&&re&&(Rr(),ct()),Nt()&&Di(),Ye()};Ec=()=>(R.pip||"none").toLowerCase()!=="none"||!!R.camera||[...u.values()].some(e=>e.camera),Ni=()=>"slidetake:rec-cam:"+Ve();It.onchange=()=>{W("slidetake:quality",It.value),Ye()};st=()=>!(Se().ok&&(me||"browser")==="browser");document.getElementById("btn-studio").onclick=()=>sa();Ac=()=>!!me||lt().takes.length>0||uo().some(e=>e.key===Ve());document.getElementById("btn-record").onclick=()=>Cr();Wi=e=>{let t=Ba(e,Ie());return{width:t.w,height:t.h,aspectRatio:t.w/t.h,frameRate:gt,resizeMode:"crop-and-scale"}};new ResizeObserver(_i).observe(wt);at=!1;ti=600;_e="";Hc=e=>Tn(e,Yi),jc=(e,t)=>Ln(e,t,{input:e.outputPath||_e||"recording.mov",outputName:Ve()+"-final.mp4",sectionOf:Yi,loudness:ot()}),Ki=document.querySelectorAll(".rv-loud"),ot=()=>j("slidetake:loudness")!=="off",Ji=()=>Ki.forEach(e=>{e.setAttribute("aria-pressed",String(ot())),e.classList.toggle("on",ot())}),or=document.getElementById("rv-limiter"),ca=()=>j("slidetake:limiter")==="on",$i=()=>{or.setAttribute("aria-pressed",String(ca())),or.classList.toggle("on",ca())};$i();or.onclick=()=>{W("slidetake:limiter",ca()?"off":"on"),$i()};Xi=()=>j("slidetake:mic-sound")==="raw"?"raw":"voice",Qi=e=>({...e?{deviceId:{ideal:e}}:{},echoCancellation:!1,autoGainControl:!1,noiseSuppression:Xi()==="voice"}),Zi=document.querySelectorAll("[data-sound]"),es=()=>Zi.forEach(e=>{let t=e.dataset.sound===Xi();e.classList.toggle("active",t),e.setAttribute("aria-checked",String(t))});es();Zi.forEach(e=>e.onclick=()=>{W("slidetake:mic-sound",e.dataset.sound),es(),he&&Qa()});Ji();Ki.forEach(e=>e.onclick=()=>{W("slidetake:loudness",ot()?"off":"on"),Ji(),H&&mo()});H=null,Z=null,S=document.getElementById("rv-video"),Jt=document.getElementById("rv-now");_a=-1,ts=()=>{let e=Ra(v,Re).length;return e?e+"/"+v.length+" slide"+(e===1?"":"s")+" up for a take":""};os="";document.getElementById("rv-chapters").onclick=e=>ns(e.currentTarget,os);document.getElementById("rv-ffmpeg-copy").onclick=e=>{!H||!H.events.length||(ns(e.currentTarget,jc(H,document.getElementById("rv-mode").value)),O("Copied the ffmpeg command: run it in a terminal, in the folder with "+(mt(H.outputPath)||"the recording")+"."))};Ua=new Map,Uo=0;ao=document.getElementById("rv-fps");ao.onchange=()=>{H&&(H.fps=parseFloat(ao.value),Br(H),mo())};oo=null;S.addEventListener("timeupdate",()=>{if(!Z)return;let e=Z.ranges[Z.i];if(S.currentTime*1e3<e.end)return;if(Z.i++,Z.i>=Z.ranges.length){S.pause(),Z=null,O("");return}let t=Z.ranges[Z.i];S.currentTime=t.start/1e3,O("\u25B6 "+t.title)});ss=document.getElementById("rv-play-final"),St=null;ss.onclick=()=>{if(!H)return;if(!H.inBrowser){ro(Gt(H).map(a=>({start:a.start,end:a.end,title:a.title})));return}if(F&&!F.single){S.paused?S.play().catch(()=>{}):S.pause();return}let e=Yt(H),t=Math.max(0,St?e.findIndex(a=>a.id===St):0);St=null,fo(e.slice(t))};S.addEventListener("play",Or);S.addEventListener("pause",()=>{F&&F.single&&S.currentTime<F.parts[0].keep-.05&&(St=F.parts[0].id,O("Preview starts from "+F.parts[0].title.replace(/ · take \d+$/,"")+".")),Or()});F=null;S.addEventListener("timeupdate",()=>{F&&S.currentTime>=F.parts[F.i].keep&&cs()});S.addEventListener("ended",()=>{F&&cs()});no=document.getElementById("rv-render-btn");no.onclick=()=>hs(!1);ds=0,Xe=e=>{clearTimeout(ds),e?no.textContent=e:no.innerHTML='\u2193 <span><u class="key">D</u>ownload</span>'},qo=e=>e.where?"\u201C"+e.where+"\u201D as "+e.name:"your downloads as "+e.name;qc=e=>{let t=a=>String(a).padStart(2,"0");return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+"-"+t(e.getMinutes())+"-"+t(e.getSeconds())};document.getElementById("rv-folder-change").onclick=async()=>{try{let e=await ps(!0);e&&O("Videos now go to "+e.name+".")}catch{}};I=null,rr="",oi=null,Re=new Set,us=()=>"slidetake:board:"+Ve();ya=()=>W(us(),JSON.stringify(I)),Vc=e=>{let t=u.get(e);return t?Fn(t.title+`
|
|
1438
|
+
`+t.html):""},go=()=>Nn(v,e=>({title:u.get(e).title,fp:Vc(e)}));rt=document.getElementById("rv-setup-btn"),ri=document.getElementById("setup-note"),Nt=()=>Y.classList.contains("setup-view");new MutationObserver(()=>{Y.classList.contains("open")||bo()}).observe(Y,{attributes:!0,attributeFilter:["class"]});rt.onclick=()=>{Nt()?bo():yo()};document.getElementById("setup-record").onclick=()=>{fa(),me||(me=st()?"obs":"browser",W("slidetake:rec-mode",me)),Cr()};Y.addEventListener("click",e=>{(e.target===Y||e.target.closest("[data-close]"))&&po()});qa=(()=>{let e=(navigator.userAgentData&&navigator.userAgentData.brands||[]).map(a=>a.brand).filter(a=>!/chromium|not.?a.?brand/i.test(a));if(e.length)return e[0].replace(/^(Google|Microsoft) /,"");let t=navigator.userAgent;return/Firefox\//.test(t)?"Firefox":/Edg\//.test(t)?"Edge":/OPR\//.test(t)?"Opera":/Chrome\//.test(t)?"Chrome":/Safari\//.test(t)?"Safari":"this browser"})();document.querySelectorAll(".browser-name").forEach(e=>{e.textContent=qa});document.getElementById("rv-rec").onclick=()=>{if(!st()){to("browser",Ra(v,Re));return}if(Oe){to("obs");return}nr({note:"Connect to OBS first: OBS \u2192 Connect."})};bt=document.getElementById("rv-pro");bt.onclick=()=>{Se().ok&&Tc(st()?"browser":"obs")};document.querySelectorAll(".rv-purge .rv-menu button").forEach(e=>e.addEventListener("click",()=>{e.closest("details").open=!1}));document.getElementById("rv-clean-unused").onclick=async()=>{let{rows:e}=ms(),t=new Set(e.map(o=>o.pick).filter(Boolean)),a=I.takes.filter(o=>!t.has(o.uid));if(!a.length){O("Every take is in use.");return}confirm("Purge "+a.length+" take"+(a.length===1?"":"s")+" the video doesn\u2019t use (earlier attempts and outdated takes)?")&&(await Jc(a),O("Purged "+a.length+" unused take"+(a.length===1?"":"s")+"."))};document.getElementById("rv-clean").onclick=async()=>{if(!I.takes.length||!confirm("Purge all "+I.takes.length+" takes of this deck from this browser? Download the video first if you need it."))return;let e=new Set(I.takes.map(t=>t.clip.split("/")[0]));I.takes=[],I.picks={},ya();for(let t of e)await Tr(t);S.src&&(URL.revokeObjectURL(S.src),S.removeAttribute("src"),S.load()),F=null,Ft(),O("All takes purged."),it()};document.getElementById("rv-clean-every").onclick=async()=>{let e,t=0,a=0;try{e=await navigator.storage.getDirectory()}catch{return}let o=async s=>{for await(let l of s.values())l.kind==="directory"?await o(l):(a++,t+=(await l.getFile()).size)};try{await o(await e.getDirectoryHandle("slidetake-takes"))}catch{}let r=[];try{for(let s=0;s<localStorage.length;s++){let l=localStorage.key(s);l&&l.startsWith("slidetake:board:")&&r.push(l)}}catch{}let n=r.filter(s=>{try{return JSON.parse(localStorage.getItem(s)||"{}").takes.length>0}catch{return!1}}).length;if(!a){O("No takes are kept in this browser.");return}let i=t>1e9?(t/1e9).toFixed(1)+" GB":Math.max(1,Math.round(t/1e6))+" MB";if(confirm("Purge "+i+" of takes ("+a+" file"+(a===1?"":"s")+") from "+(n||"no")+" deck"+(n===1?"":"s")+" and any left behind? Every deck loses its takes; download the videos you need first.")){try{await e.removeEntry("slidetake-takes",{recursive:!0})}catch{}r.forEach(s=>{try{localStorage.removeItem(s)}catch{}}),W("slidetake:sessions",JSON.stringify(uo().map(s=>s.inBrowser?{...s,cleaned:!0}:s))),I=null,rr="",lt(),Ua.clear(),S.src&&(URL.revokeObjectURL(S.src),S.removeAttribute("src"),S.load()),F=null,Ft(),it(),O("Purged "+i+" of takes from every deck.")}};Xt=null,ir=0,sr=!1;S.addEventListener("error",async()=>{if(S.getAttribute("src")){if(Xt&&ir<5){ir++,O("Reloading "+_e+" (OBS was still finishing it)\u2026"),await new Promise(e=>setTimeout(e,1500));try{ba(await vo(Xt),Xt,!0);return}catch{}}O(Xt?"Chrome cannot play "+_e+". In OBS set Recording Format to Hybrid MP4 (or MP4) with H.264 video; the ffmpeg command still works with this file.":"Could not play "+(_e||"this file")+". If OBS was still finishing it when you opened it, open it again; if it still fails, set OBS to Hybrid MP4 (or MP4) with H.264 video.",{warn:!0})}});Qt=document.getElementById("rv-file-input");Qt.addEventListener("change",()=>{Qt.files[0]&&ba(Qt.files[0]),Qt.value=""});document.getElementById("rv-open").onclick=async()=>{if(!window.showOpenFilePicker)return Qt.click();try{let[e]=await window.showOpenFilePicker({id:"obs-recordings",types:[{description:"Recordings",accept:{"video/*":[".mov",".mp4",".m4v",".mkv",".webm"]}}]});O("Opening "+e.name+"\u2026"),ba(await vo(e),e)}catch(e){(!e||e.name!=="AbortError")&&O("Could not open that file.",{warn:!0})}};ys=document.getElementById("rv-folder");window.showDirectoryPicker||(ys.style.display="none");ys.onclick=async()=>{let e=H&&mt(H.outputPath);try{let t=await window.showDirectoryPicker({id:"obs-recordings",mode:"read"});if(gs("obs-folder",t),!e){O("Folder remembered. This session has no file name from OBS; open the file instead.");return}let a=await t.getFileHandle(e);ba(await vo(a),a)}catch{}};bc()&&new URLSearchParams(location.search).get("obs")&&xr();Te=document.getElementById("btn-camera"),Zt=document.getElementById("pip-msg"),Va=null,bs=B.querySelector("span");Qc='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="6" width="14" height="12" rx="2"/><path d="M16 10.5 22 7v10l-6-3.5z"/></svg>';Te.onclick=()=>Ht(te);Dr();ni=null;window.addEventListener("pointermove",xs);document.addEventListener("fullscreenchange",()=>{document.fullscreenElement||(h.active?Pt("Stopped: the browser left fullscreen"):K&&we(!1))});xe=document.getElementById("help");new MutationObserver(()=>ws(document.getElementById("btn-keys"),xe.classList.contains("open"))).observe(xe,{attributes:!0,attributeFilter:["class"]});new MutationObserver(()=>{let e=Y.classList.contains("open");document.getElementById("btn-studio").classList.toggle("active",e),!e&&!S.paused&&S.pause()}).observe(Y,{attributes:!0,attributeFilter:["class"]});document.getElementById("btn-keys").onclick=()=>xe.classList.add("open");document.getElementById("help-close").onclick=()=>xe.classList.remove("open");xe.addEventListener("click",e=>{e.target===xe&&xe.classList.remove("open")});window.addEventListener("keydown",e=>{if(e.key==="F5"){e.preventDefault(),h.active||sa();return}if(h.active){zc(e);return}if(document.querySelector(".modal.open")){let o=Y.classList.contains("open")&&Nt();if(e.key==="Escape")fa();else if(Y.classList.contains("open")&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!/^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName||"")){let r=e.key.toLowerCase(),n=r==="r"?o?"setup-record":"rv-rec":o?"":r==="p"?"rv-play-final":r==="d"?st()?"rv-ffmpeg-copy":"rv-render-btn":"",i=n?document.getElementById(n):null;i&&!i.disabled&&(e.preventDefault(),i.click())}return}let t=document.activeElement&&document.activeElement.tagName;if(t==="TEXTAREA"||t==="INPUT"||e.metaKey||e.ctrlKey||e.altKey)return;if(xe.classList.contains("open")){/^(Escape|k|K|\?|\/)$/.test(e.key)&&xe.classList.remove("open");return}let a=e.key;a==="ArrowRight"||a===" "||a==="PageDown"?(e.preventDefault(),We(1)):a==="ArrowLeft"||a==="PageUp"?(e.preventDefault(),We(-1)):a==="ArrowDown"?(e.preventDefault(),pc()):a==="ArrowUp"?(e.preventDefault(),hc()):a==="Home"?v.length&&_(v[0]):a==="End"?v.length&&_(v[v.length-1]):a==="o"||a==="O"?dc():a==="e"||a==="E"?ho():a==="f"||a==="F"||a==="p"||a==="P"?we(!K):a==="r"||a==="R"?Cr():a==="s"||a==="S"?sa():/^[1-4]$/.test(a)?yr(pr[+a-1]):a==="c"||a==="C"?Ht(te):a==="v"||a==="V"?xl():a==="l"||a==="L"?pi():a==="+"||a==="="?$n(1):a==="-"||a==="_"?$n(-1):a==="?"||a==="/"||a==="k"||a==="K"?xe.classList.add("open"):a==="Escape"&&!Ti()&&K&&we(!1)});window.addEventListener("hashchange",()=>{let{data:e,slide:t}=ka(location.hash);if(e&&!(M&&M.kind==="share"&&e===M.data)){location.reload();return}t&&t!==g&&u.has(t)&&_(t)});ii="";new ResizeObserver(()=>{let e=N.clientWidth+"x"+N.clientHeight;e!==ii&&(ii=e,Tt(),fe(!0))}).observe(N);Ct=document.createElement("div");Ct.id="toast";Ct.setAttribute("role","status");document.body.appendChild(Ct);si=null;Zc=document.getElementById("open-dialog"),cr=document.getElementById("open-url"),dr=document.getElementById("open-error");document.getElementById("btn-load").onclick=()=>{dr.hidden=!0,ma(Zc),cr.focus(),cr.select()};document.getElementById("open-form").onsubmit=e=>{e.preventDefault();let t=mn(cr.value);if(!t){dr.textContent="That doesn't look like a link.",dr.hidden=!1;return}location.href=lr(t)};document.getElementById("btn-share").onclick=async()=>{let{link:e,inside:t}=await ed(g&&g!==v[0]?g:""),a=t?"Link copied, with the whole deck inside it ("+(e.length/1024).toFixed(1)+" KB)"+(e.length>8e3?". Some chat apps cut long links short: a GitHub file or gist makes a shorter one.":"."):"Link copied.";try{await navigator.clipboard.writeText(e),da(a,5e3)}catch{prompt("Copy this link:",e)}M.kind==="copy"&&(P.exported=P.text,va(),jt())};li=j("slidetake:layout");J=pr.includes(li)?li:"path";document.querySelectorAll("#layout-toggle .seg-btn").forEach(e=>e.classList.toggle("active",e.dataset.mode===J));io=new URLSearchParams(location.search);pr.includes(io.get("layout"))&&(J=io.get("layout"),document.querySelectorAll("#layout-toggle .seg-btn").forEach(e=>e.classList.toggle("active",e.dataset.mode===J)));if(U){let e=(Array.isArray(U.trail)?U.trail:U.back?[U.back]:[]).filter(r=>r&&r.label),t=document.querySelector("header .brand");e.length&&(t.innerHTML='<nav class="trail" aria-label="Site">'+e.map((r,n)=>(n?'<span class="sep" aria-hidden="true">|</span>':"")+(r.url?'<a href="'+A(r.url)+'">'+A(r.label)+"</a>":"<span>"+A(r.label)+"</span>")).join("")+"</nav>");let a=document.createElement("a");a.id="credit",a.href="https://slidetake.com",a.target="_blank",a.rel="noopener",a.title="Made with Slidetake",a.setAttribute("aria-label","Made with Slidetake"),a.innerHTML=hr+'<span class="word">Slide<span>take</span></span>';let o=document.querySelector("header .hdr-actions");o.insertBefore(a,o.firstChild),Ge||(o.insertAdjacentHTML("beforeend",'<button class="btn" id="hdr-keys" title="Keyboard shortcuts (K)">\u2328 Keys</button><button class="btn" id="hdr-full" title="Fullscreen (F)">\u26F6 Fullscreen</button>'),document.getElementById("hdr-keys").onclick=()=>document.getElementById("help").classList.add("open"),document.getElementById("hdr-full").onclick=()=>we(!K))}ee=vn(location.pathname,location.search,location.hash),ci=ee.page==="pick"?"":ee.slide,M=null,P=wn(j("slidetake:copy"))||td();window.addEventListener("popstate",()=>location.reload());pe&&window.EventSource&&(new EventSource(pe.events).onmessage=async e=>{if(!Fr())return;let t=(JSON.parse(e.data).file||"").replace(/\\/g,"/");if(t===pe.file){let a=await(await fetch(pe.deck,{cache:"no-store"})).text();if(a===ie.value)return;ie.value=M.text=a,At(!0);return}se.querySelectorAll("img").forEach(a=>{let o=new URL(a.src);decodeURIComponent(o.pathname).endsWith("/"+t)&&(o.searchParams.set("t",String(Date.now())),a.src=o.href)})});(io.get("edit")==="1"||ee.page==="edit"&&P&&io.get("edit")!=="0")&&ho();id().then(e=>(ie.value=e,jt(),mi(ie.value),vi(),document.fonts?document.fonts.ready:null)).then(()=>{u.forEach(lo),ha(),_(u.has(ci)?ci:v[0],!0),Ge&&j("slidetake:camera")==="on"&&Ht(!0,!0)})});var Hr=` /* Every colour comes from these tokens. Slidetake's own is seafoam green: bright on zinc in dark mode,
|
|
1322
1439
|
deep on white in light mode. A host page passes its own (window.SLIDETAKE.colors) and a deck can carry
|
|
1323
1440
|
its own (accent: in its top block); see applyColors in app.js. */
|
|
1324
1441
|
:root{
|
|
@@ -1694,6 +1811,20 @@ EOF
|
|
|
1694
1811
|
only while it is its own stacking context, hence the isolation (without it the capture is silently empty). */
|
|
1695
1812
|
body.rec-frame main{background:#000;}
|
|
1696
1813
|
body.rec-frame #stage-wrap{flex:none;margin:auto;width:min(100%, calc(100vh * 16 / 9));aspect-ratio:16/9;isolation:isolate;}
|
|
1814
|
+
/* format: portrait \u2014 the deck is a 9:16 column, always: what you see is what a Short records */
|
|
1815
|
+
body.portrait main{background:color-mix(in srgb, var(--text) 5%, var(--bg));}
|
|
1816
|
+
body.portrait #stage-wrap, body.portrait.rec-frame #stage-wrap{flex:none;margin:0 auto;width:auto;height:100%;max-width:100%;aspect-ratio:9/16;isolation:isolate;}
|
|
1817
|
+
body.portrait.rec-frame main{background:#000;}
|
|
1818
|
+
body.portrait .rv-video{aspect-ratio:9/16;max-height:62vh;margin:0 auto;}
|
|
1819
|
+
/* the bottom bar and the map go beside the column, where the window is empty (they're never recorded); a window
|
|
1820
|
+
too narrow for that keeps the bar in the column and drops the map */
|
|
1821
|
+
@media (min-aspect-ratio: 1/1){
|
|
1822
|
+
body.portrait #navbar{position:fixed;left:16px;bottom:16px;transform:none;}
|
|
1823
|
+
body.portrait #stage-wrap[data-pip] #minimap{position:fixed;right:16px;bottom:16px;left:auto;}
|
|
1824
|
+
}
|
|
1825
|
+
@media (max-aspect-ratio: 1/1){ body.portrait #minimap{display:none;} }
|
|
1826
|
+
/* a card's words are larger for its width, so a slide filling the narrow column reads on a phone */
|
|
1827
|
+
body.portrait #world .node > .body{zoom:1.8;}
|
|
1697
1828
|
#review.in-browser #rv-novideo{display:none !important;}
|
|
1698
1829
|
/* the takes screen records in this browser, or with OBS: each mode's own controls */
|
|
1699
1830
|
#review.obs .for-browser, #review:not(.obs) .for-obs{display:none !important;}
|
|
@@ -1741,7 +1872,8 @@ EOF
|
|
|
1741
1872
|
#rv-setup{margin:8px 0 0;}
|
|
1742
1873
|
/* the chosen camera, live, as a recording would see it (mirrored like the camera box), and the mic's waveform */
|
|
1743
1874
|
.setup-cam{position:relative;aspect-ratio:16/9;background:#000;border-radius:8px;overflow:hidden;border:1px solid var(--panel-line);}
|
|
1744
|
-
.setup-cam video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;
|
|
1875
|
+
.setup-cam video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;}
|
|
1876
|
+
.setup-cam.mirror video{transform:scaleX(-1);}
|
|
1745
1877
|
.setup-cam span{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:12px;color:#a1a1aa;}
|
|
1746
1878
|
.setup-cam span[hidden]{display:none;}
|
|
1747
1879
|
.setup-wave{display:block;width:100%;height:60px;border-radius:8px;border:1px solid var(--panel-line);
|
|
@@ -1997,7 +2129,7 @@ EOF
|
|
|
1997
2129
|
html.embed.no-record #navbar{display:flex;}
|
|
1998
2130
|
html.embed.no-record #navbar > :not(.touch-only){display:none !important;}
|
|
1999
2131
|
}
|
|
2000
|
-
html.no-record #btn-camera, html.no-record #btn-studio, html.no-record #btn-record, html.no-record #pip, html.no-record #help tr.rec{display:none !important;}
|
|
2132
|
+
html.no-record #btn-camera, html.no-record #btn-studio, html.no-record #btn-record, html.no-record #pip:not(.empty), html.no-record #help tr.rec{display:none !important;}
|
|
2001
2133
|
/* the logo written into a heading: #  Slidetake */
|
|
2002
2134
|
.node .body :is(h1,h2) img[src$="favicon.svg"]{height:1em;width:auto;vertical-align:-.12em;margin-right:.25em;display:inline;}
|
|
2003
2135
|
#brand .st-mark{display:inline-flex;align-items:center;gap:8px;font-family:var(--display);font-weight:700;font-size:20px;color:var(--text);}
|
|
@@ -2028,13 +2160,69 @@ EOF
|
|
|
2028
2160
|
#pip.bottom-right{bottom:16px;right:16px;}
|
|
2029
2161
|
/* full: the camera takes the whole stage, under the brand and the controls */
|
|
2030
2162
|
/* it also swallows clicks, so a click can't land on the hidden cards behind it */
|
|
2031
|
-
#pip.full{inset:0;width:100
|
|
2163
|
+
#pip.full{inset:0;width:100%;height:100%;aspect-ratio:auto;border-radius:0;z-index:9;pointer-events:auto;}
|
|
2032
2164
|
/* behind: the camera fills the frame under the slides, which stay on top as cards; the stage's dotted
|
|
2033
2165
|
background makes way so the camera shows around them */
|
|
2034
2166
|
#pip.full.behind{z-index:0;pointer-events:none;box-shadow:none;}
|
|
2167
|
+
/* split screen (a solid card): the camera fills what the card leaves, centred there, and glides into it */
|
|
2168
|
+
/* behind a split screen the frame is the card's colour, so as the words and the camera pass each other on a
|
|
2169
|
+
swap, the edges they uncover read as card */
|
|
2170
|
+
#stage-wrap.cam-solid{background:var(--panel);}
|
|
2171
|
+
#stage-wrap.cam-solid[data-place="left"] #pip.full.behind{left:50%;width:50%;}
|
|
2172
|
+
#stage-wrap.cam-solid[data-place="right"] #pip.full.behind{right:50%;width:50%;}
|
|
2173
|
+
#stage-wrap.cam-solid[data-place="top"] #pip.full.behind{top:25%;height:75%;}
|
|
2174
|
+
#stage-wrap.cam-solid[data-place="bottom"] #pip.full.behind{bottom:25%;height:75%;}
|
|
2175
|
+
body.portrait #stage-wrap.cam-solid[data-place="top"] #pip.full.behind{top:50%;height:50%;}
|
|
2176
|
+
body.portrait #stage-wrap.cam-solid[data-place="bottom"] #pip.full.behind{bottom:50%;height:50%;}
|
|
2177
|
+
/* the camera behind the slide while it is off: an empty frame with a faint person where you'd be */
|
|
2178
|
+
#stage-wrap #pip.empty{border:none;background:color-mix(in srgb, var(--text) 6%, var(--bg)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='%23fff' fill-opacity='.07'%3E%3Ccircle cx='50' cy='40' r='15'/%3E%3Cpath d='M18 100c0-22 14-36 32-36s32 14 32 36z'/%3E%3C/g%3E%3C/svg%3E") 50% 100%/auto 70% no-repeat;}
|
|
2179
|
+
body[data-mode="light"] #stage-wrap #pip.empty{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='%23000' fill-opacity='.06'%3E%3Ccircle cx='50' cy='40' r='15'/%3E%3Cpath d='M18 100c0-22 14-36 32-36s32 14 32 36z'/%3E%3C/g%3E%3C/svg%3E");}
|
|
2180
|
+
/* the person stands where the words leave room */
|
|
2181
|
+
#stage-wrap[data-place="left"] #pip.empty{background-position:76% 100%;}
|
|
2182
|
+
#stage-wrap[data-place="right"] #pip.empty{background-position:24% 100%;}
|
|
2183
|
+
#pip.empty:not(.msg) > span{position:absolute;left:50%;bottom:4%;transform:translateX(-50%);font-size:0;}
|
|
2184
|
+
#pip.empty:not(.msg) > span::after{content:"Camera off \xB7 press C";font-size:12px;color:var(--text);opacity:.45;letter-spacing:.08em;}
|
|
2185
|
+
html.no-record #pip.empty > span{display:none;}
|
|
2035
2186
|
#stage-wrap.cam-behind #stage{z-index:1;background:transparent;}
|
|
2036
|
-
/*
|
|
2037
|
-
|
|
2187
|
+
/* behind: the slide's content in regions around the person (the card itself steps aside), in the deck's own
|
|
2188
|
+
colours, light or dark, camera on or off. A card under the words (half see-through unless set) keeps them
|
|
2189
|
+
readable; with card 0% they sit straight on the video, and diagrams, charts and table cells keep a pane */
|
|
2190
|
+
#cam-overlay{position:absolute;inset:0;z-index:2;pointer-events:none;display:none;color:var(--text);}
|
|
2191
|
+
#stage-wrap.cam-live:not(.cam-card) #cam-overlay .cam-media :is(.diagram, .echarts-container){
|
|
2192
|
+
background:color-mix(in srgb, var(--bg) 85%, transparent);border-radius:14px;padding:14px;}
|
|
2193
|
+
#stage-wrap.cam-live:not(.cam-card) #cam-overlay .body :is(th, td){background:color-mix(in srgb, var(--bg) 70%, transparent);}
|
|
2194
|
+
#stage-wrap:not([data-place=""])[data-place] #cam-overlay{display:block;}
|
|
2195
|
+
#stage-wrap:not([data-place=""])[data-place] #world{opacity:0;}
|
|
2196
|
+
/* the card under the words: half see-through, solid (no camera through it) or clear (none, kept off the edges) */
|
|
2197
|
+
#cam-overlay .cam-box{position:absolute;display:flex;flex-direction:column;gap:3%;box-sizing:border-box;padding:1.2%;
|
|
2198
|
+
border-radius:18px;background:color-mix(in srgb, var(--panel) calc(var(--cam-card, 0) * 100%), transparent);}
|
|
2199
|
+
#cam-overlay .cam-box.left{left:4%;top:8%;width:42%;height:84%;}
|
|
2200
|
+
#cam-overlay .cam-box.right{right:4%;top:8%;width:42%;height:84%;}
|
|
2201
|
+
#cam-overlay .cam-box.top{left:5%;top:3%;width:90%;height:22%;flex-direction:row;}
|
|
2202
|
+
#cam-overlay .cam-box.bottom{left:5%;bottom:3%;width:90%;height:22%;flex-direction:row;}
|
|
2203
|
+
/* with a card, the region fills its part of the frame edge to edge: a half or a quarter band */
|
|
2204
|
+
#stage-wrap.cam-card #cam-overlay .cam-box{border-radius:0;padding:2.5%;}
|
|
2205
|
+
#stage-wrap.cam-card #cam-overlay .cam-box.left{left:0;top:0;width:50%;height:100%;}
|
|
2206
|
+
#stage-wrap.cam-card #cam-overlay .cam-box.right{right:0;top:0;width:50%;height:100%;}
|
|
2207
|
+
#stage-wrap.cam-card #cam-overlay .cam-box.top{left:0;top:0;width:100%;height:25%;}
|
|
2208
|
+
#stage-wrap.cam-card #cam-overlay .cam-box.bottom{left:0;bottom:0;width:100%;height:25%;}
|
|
2209
|
+
/* portrait: the words take half the column, above or below you, stacked like a card */
|
|
2210
|
+
body.portrait #cam-overlay .cam-box:is(.top, .bottom){height:44%;flex-direction:column;}
|
|
2211
|
+
body.portrait #stage-wrap.cam-card #cam-overlay .cam-box:is(.top, .bottom){height:50%;}
|
|
2212
|
+
body.portrait #cam-overlay .cam-box:is(.top, .bottom) .cam-text + .cam-media{flex-basis:55%;}
|
|
2213
|
+
/* the words take what the picture leaves: below it beside you, to its left in a band */
|
|
2214
|
+
#cam-overlay .cam-text{flex:1 1 0;min-width:0;min-height:0;display:flex;align-items:center;}
|
|
2215
|
+
#cam-overlay .cam-box.top .cam-text{align-items:flex-start;}
|
|
2216
|
+
#cam-overlay .cam-box.bottom .cam-text{align-items:flex-end;}
|
|
2217
|
+
#cam-overlay .cam-media{flex:1 1 0;min-width:0;min-height:0;position:relative;}
|
|
2218
|
+
#cam-overlay .cam-text + .cam-media{flex:0 0 55%;}
|
|
2219
|
+
#cam-overlay :is(.cam-box.top, .cam-box.bottom) .cam-text + .cam-media{flex-basis:38%;}
|
|
2220
|
+
#cam-overlay .node{background:none;border:none;padding:0;}
|
|
2221
|
+
#cam-overlay .cam-text > .node{flex:none;transform-origin:0 0;}
|
|
2222
|
+
#cam-overlay .cam-box.bottom .cam-text > .node{transform-origin:0 100%;}
|
|
2223
|
+
#cam-overlay .cam-box.left .cam-text > .node, #cam-overlay .cam-box.right .cam-text > .node{transform-origin:0 50%;}
|
|
2224
|
+
#cam-overlay .cam-media > .node{position:absolute;left:50%;top:50%;transform-origin:50% 50%;}
|
|
2225
|
+
#cam-overlay .cam-media > .node > .body > *{margin:0;}
|
|
2038
2226
|
/* while presenting the box is empty so the camera overlay sits on plain background */
|
|
2039
2227
|
/* while presenting, the empty box stays as a faint guide for lining up a camera overlay */
|
|
2040
2228
|
body.presenting #pip{border-color:color-mix(in srgb, var(--accent-teal) 30%, transparent);background:none;}
|
|
@@ -2081,7 +2269,7 @@ EOF
|
|
|
2081
2269
|
#minimap{display:none;}
|
|
2082
2270
|
#navbar .lbl{display:none;}
|
|
2083
2271
|
}
|
|
2084
|
-
`;var
|
|
2272
|
+
`;var jr=`
|
|
2085
2273
|
<noscript>
|
|
2086
2274
|
<style>#deck-text{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;max-width:760px;margin:24px auto;padding:0 16px;}#deck-text img{max-width:100%;height:auto;}#deck-text :is(h1,h2) img{height:1em;width:auto;vertical-align:-.12em;}#deck-text table{border-collapse:collapse;}#deck-text :is(td,th){border:1px solid #3f3f46;padding:4px 8px;}#deck-text a{color:#29b685;}</style>
|
|
2087
2275
|
<p class="deck-text-note">Slidetake needs JavaScript to present and record decks. Here is this page as text; the source is on <a href="https://github.com/slidetake/slidetake">GitHub</a>.</p>
|
|
@@ -2132,6 +2320,7 @@ EOF
|
|
|
2132
2320
|
<div id="minimap"><div class="mm-label" id="mm-label">map</div><svg id="mm-svg" width="180" height="130"></svg></div>
|
|
2133
2321
|
<div id="brand" hidden></div>
|
|
2134
2322
|
<div id="pip" hidden><span>PIP camera</span></div>
|
|
2323
|
+
<div id="cam-overlay" aria-hidden="true"></div>
|
|
2135
2324
|
<div id="pip-msg" role="status"></div>
|
|
2136
2325
|
</div>
|
|
2137
2326
|
<div id="editor-resizer" role="separator" aria-orientation="vertical" aria-label="Resize the editor" title="Drag to resize"></div>
|
|
@@ -2265,6 +2454,9 @@ EOF
|
|
|
2265
2454
|
<h4>Camera</h4>
|
|
2266
2455
|
<select id="rec-cam" aria-label="Camera"></select>
|
|
2267
2456
|
<div class="setup-cam"><video id="rec-cam-preview" muted playsinline autoplay></video><span id="rec-cam-none">No camera</span></div>
|
|
2457
|
+
<div class="rv-setup-row">
|
|
2458
|
+
<label class="check rv-setup-label" title="Flip the camera left to right, like a mirror. Off, it shows you as others see you, and words on a shirt or sign read the right way."><input type="checkbox" id="rec-mirror"> Mirror</label>
|
|
2459
|
+
</div>
|
|
2268
2460
|
<p class="rv-setup-note">Turns on by itself when recording starts. Choose No camera for slides only.</p>
|
|
2269
2461
|
</section>
|
|
2270
2462
|
<section class="for-browser">
|
|
@@ -2357,5 +2549,5 @@ EOF
|
|
|
2357
2549
|
<div id="rec-paused">Paused \xB7 press B to resume</div>
|
|
2358
2550
|
|
|
2359
2551
|
<!-- The sample deck. Plain markdown, nothing else. -->
|
|
2360
|
-
`;var
|
|
2361
|
-
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet">`;var
|
|
2552
|
+
`;var Wr=`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
2553
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet">`;var Cs=e=>new Promise((t,a)=>{let o=document.createElement("script");o.src=e,o.onload=t,o.onerror=()=>a(new Error("could not load "+e)),document.head.appendChild(o)});async function Ms(){document.head.insertAdjacentHTML("beforeend",Wr);let e=document.createElement("style");e.textContent=Hr,document.head.appendChild(e),document.body.insertAdjacentHTML("afterbegin",jr),await Promise.all([window.gsap?null:Cs("https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"),window.marked?null:Cs("https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.2/marked.min.js")]),await Promise.resolve().then(()=>(Es(),sd))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ms,{once:!0}):Ms();})();
|