@kanorio/elements 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/MediaPlayer-MWIDJORE.js +2 -0
- package/dist/MediaPlayer-STITRANS.js +13 -0
- package/dist/PDFViewerFull-HIUSAO57.js +13 -0
- package/dist/PDFViewerFull-L7VMOAMU.js +28062 -0
- package/dist/altcha-DSOKKAAV.js +3153 -0
- package/dist/altcha-FLBUR2LJ.js +4 -0
- package/dist/ar-4CBE4BWH.js +1233 -0
- package/dist/ar-6G7ZVSQ3.js +2 -0
- package/dist/ar-XCPH4WO5.js +98 -0
- package/dist/ar-ZVJL6XGE.js +2 -0
- package/dist/bg-4WPFSAMC.js +2 -0
- package/dist/bg-BKFL64I6.js +98 -0
- package/dist/bg-CB273F4D.js +1233 -0
- package/dist/bg-HCH4LMEX.js +2 -0
- package/dist/bn-HLYDEXHQ.js +1233 -0
- package/dist/bn-HVEVBAGM.js +98 -0
- package/dist/bn-OY7YGJIT.js +2 -0
- package/dist/bn-XX3O4VQB.js +2 -0
- package/dist/chunk-2UBPQBQI.js +1848 -0
- package/dist/chunk-5OB57Z46.js +23620 -0
- package/dist/chunk-6LJZ4HRF.js +1350 -0
- package/dist/chunk-6TUB24LJ.js +415 -0
- package/dist/chunk-74RRJOB4.js +15 -0
- package/dist/chunk-7TNRMVML.js +2 -0
- package/dist/chunk-BH27SBYG.js +2 -0
- package/dist/chunk-BQU7QZGC.js +4 -0
- package/dist/chunk-CHSZMJ5D.js +15103 -0
- package/dist/chunk-DDKQOHPW.js +930 -0
- package/dist/chunk-E5ZVE4VL.js +5 -0
- package/dist/chunk-FGBB7FT5.js +4 -0
- package/dist/chunk-FSH5K5FU.js +57 -0
- package/dist/chunk-G3PMV62Z.js +36 -0
- package/dist/chunk-IUB5YLUU.js +1538 -0
- package/dist/chunk-J7AP6FJF.js +8616 -0
- package/dist/chunk-LKOMEUNH.js +72 -0
- package/dist/chunk-NB57OIQA.js +2 -0
- package/dist/chunk-NLJE74VA.js +2 -0
- package/dist/chunk-NQBPWU5Z.js +15 -0
- package/dist/chunk-OJQYDPRD.js +39 -0
- package/dist/chunk-PDKFEXLU.js +59 -0
- package/dist/chunk-POG53MIA.js +2 -0
- package/dist/chunk-PXABHOW4.js +10871 -0
- package/dist/chunk-QDUG7UMV.js +363 -0
- package/dist/chunk-RFBBAUMM.js +2 -0
- package/dist/chunk-RJTKNOYT.js +67 -0
- package/dist/chunk-VH4656UY.js +2 -0
- package/dist/chunk-XAORGJWX.js +2 -0
- package/dist/chunk-Y77XXKLY.js +1858 -0
- package/dist/cs-EDLILQAV.js +1233 -0
- package/dist/cs-EOBDWVFI.js +2 -0
- package/dist/cs-Q732FDDB.js +98 -0
- package/dist/cs-UO3FC3H4.js +2 -0
- package/dist/da-43RMOYSN.js +98 -0
- package/dist/da-ANHSL3GD.js +2 -0
- package/dist/da-RBW34GCF.js +2 -0
- package/dist/da-SJ7YQT4L.js +1233 -0
- package/dist/de-2D2GW24Z.js +2 -0
- package/dist/de-5WGC4CMF.js +1233 -0
- package/dist/de-CPU2ARG7.js +98 -0
- package/dist/de-GVWNGUWZ.js +2 -0
- package/dist/deliverables-QUJISOBO.js +98 -0
- package/dist/deliverables-Z6ZBT6D3.js +2046 -0
- package/dist/el-FRNBHLQF.js +98 -0
- package/dist/el-HCBWOOCJ.js +1233 -0
- package/dist/el-KK7DBDUW.js +2 -0
- package/dist/el-SK362ZEN.js +2 -0
- package/dist/elements.css +2 -0
- package/dist/en-AU-BQA3DX35.js +1233 -0
- package/dist/en-AU-VZAXNXRA.js +2 -0
- package/dist/en-CA-T2VRZJVQ.js +2 -0
- package/dist/en-CA-ZWY5HD2Z.js +1233 -0
- package/dist/en-GB-CH3IGZSE.js +1233 -0
- package/dist/en-GB-MZQ2MGOR.js +2 -0
- package/dist/en-M24TV37U.js +2 -0
- package/dist/en-OURP64TI.js +2 -0
- package/dist/en-US-VWMNQOMN.js +2 -0
- package/dist/en-US-WJZ2OBFI.js +1233 -0
- package/dist/en-USCPKTM6.js +1233 -0
- package/dist/en-YND44PUO.js +98 -0
- package/dist/errors-7SQHRWKX.js +77 -0
- package/dist/errors-S6NFCUG2.js +2 -0
- package/dist/es-419-EMD4NA5M.js +2 -0
- package/dist/es-419-GPBJSXLV.js +2 -0
- package/dist/es-419-S6IHEZ4E.js +1233 -0
- package/dist/es-419-XPZOWYCA.js +98 -0
- package/dist/es-ES-EGMSPSY2.js +1233 -0
- package/dist/es-ES-U6NF6JHU.js +2 -0
- package/dist/es-es-ILD7QLKC.js +98 -0
- package/dist/es-es-MPX25JA6.js +2 -0
- package/dist/fa-5J3M6LW4.js +2 -0
- package/dist/fa-OC7ZPRF2.js +98 -0
- package/dist/fa-OFIO7IXD.js +1233 -0
- package/dist/fa-ZTPM4LEB.js +2 -0
- package/dist/fi-2V2STXSQ.js +2 -0
- package/dist/fi-7J4LPMG2.js +98 -0
- package/dist/fi-FMEAITYP.js +1233 -0
- package/dist/fi-N3BC4FYB.js +2 -0
- package/dist/fr-CA-IKSBTBHG.js +2 -0
- package/dist/fr-CA-S23ERMPM.js +1233 -0
- package/dist/fr-FR-RRTMSQWD.js +2 -0
- package/dist/fr-FR-SOIXFVK2.js +1233 -0
- package/dist/fr-ca-SUWTTOEW.js +2 -0
- package/dist/fr-ca-UUHAWMHI.js +98 -0
- package/dist/fr-fr-SGQ77PBC.js +98 -0
- package/dist/fr-fr-XE2V7MKM.js +2 -0
- package/dist/gu-RT7GQT5B.js +2 -0
- package/dist/gu-Z2QX2VCX.js +1233 -0
- package/dist/he-27MBDHSP.js +2 -0
- package/dist/he-E7RIZOIT.js +1233 -0
- package/dist/he-QGD477CH.js +98 -0
- package/dist/he-R3UJFF46.js +2 -0
- package/dist/hi-2AVAXR7K.js +1233 -0
- package/dist/hi-6ZBMVMGH.js +2 -0
- package/dist/hi-SGQH4OWG.js +98 -0
- package/dist/hi-XJHFN25N.js +2 -0
- package/dist/hls-C5FWCMHH.js +37426 -0
- package/dist/hls-ZQNRY2TQ.js +45 -0
- package/dist/hu-IOGZTF7L.js +2 -0
- package/dist/hu-KNZXJ7ZI.js +98 -0
- package/dist/hu-ORVGO3ZY.js +1233 -0
- package/dist/hu-PKL3T3JT.js +2 -0
- package/dist/id-FKFVQIN6.js +2 -0
- package/dist/id-JH2DLDBA.js +98 -0
- package/dist/id-TMOJUCBD.js +1233 -0
- package/dist/id-WLBO2VOW.js +2 -0
- package/dist/index.d.ts +2955 -0
- package/dist/index.js +67 -0
- package/dist/it-AGUEDSVA.js +2 -0
- package/dist/it-PJAB5BQB.js +98 -0
- package/dist/it-WF5BTFFJ.js +2 -0
- package/dist/it-YMZRYSIJ.js +1233 -0
- package/dist/ja-2ZVND7MB.js +2 -0
- package/dist/ja-555SY4AF.js +1233 -0
- package/dist/ja-RMBJ7E5Z.js +2 -0
- package/dist/ja-ZKBUQDUT.js +98 -0
- package/dist/kanorio-elements.js +97 -0
- package/dist/km-DF366BBP.js +1233 -0
- package/dist/km-JIUQ7MSM.js +2 -0
- package/dist/kn-KTJPREMQ.js +2 -0
- package/dist/kn-MJKASLJD.js +1233 -0
- package/dist/ko-CGY75OW4.js +2 -0
- package/dist/ko-KECCYX66.js +2 -0
- package/dist/ko-L5735TRU.js +98 -0
- package/dist/ko-S3OTZKIG.js +1233 -0
- package/dist/lo-7R55FKUB.js +1233 -0
- package/dist/lo-DNWTAFYF.js +2 -0
- package/dist/ml-B4BJPFVQ.js +2 -0
- package/dist/ml-FCTNQ4SP.js +1233 -0
- package/dist/mr-FJ4EDO7F.js +2 -0
- package/dist/mr-TZTFABWX.js +2 -0
- package/dist/mr-VZ5Y74YA.js +1233 -0
- package/dist/mr-Y464JCKX.js +98 -0
- package/dist/ms-VCX47GHB.js +2 -0
- package/dist/ms-WAJKD7ZV.js +1233 -0
- package/dist/my-S5L32WDK.js +2 -0
- package/dist/my-T7Y3Y64H.js +1233 -0
- package/dist/nb-53GCFBHF.js +2 -0
- package/dist/nb-IJDALVGX.js +99 -0
- package/dist/nb-LXBBUZUD.js +1233 -0
- package/dist/nb-PWWLEFUC.js +2 -0
- package/dist/ne-F7EEIDMA.js +2 -0
- package/dist/ne-NDLRKG6T.js +1233 -0
- package/dist/nl-262SKC6R.js +98 -0
- package/dist/nl-BE-3KOYUD6Y.js +1233 -0
- package/dist/nl-BE-VZJDK6CH.js +2 -0
- package/dist/nl-NL-3OIKN2DQ.js +2 -0
- package/dist/nl-NL-T7SQOLLA.js +1233 -0
- package/dist/nl-XKCUNU3P.js +2 -0
- package/dist/nn-AHWRAFXZ.js +1233 -0
- package/dist/nn-YH7F7UK3.js +2 -0
- package/dist/pa-HC24FOUI.js +2 -0
- package/dist/pa-J26C5J7M.js +1233 -0
- package/dist/pl-QSTOYTPG.js +1233 -0
- package/dist/pl-T7J6A26Y.js +2 -0
- package/dist/pl-TYHET6JJ.js +2 -0
- package/dist/pl-XDJJ6AUG.js +98 -0
- package/dist/prod-MRWX5W24.js +38 -0
- package/dist/prod-YHXWTKNF.js +2 -0
- package/dist/pt-BR-4QRR4PXU.js +2 -0
- package/dist/pt-BR-7JM75AGX.js +1233 -0
- package/dist/pt-PT-W3WZEROD.js +1233 -0
- package/dist/pt-PT-Z5FI4CLF.js +2 -0
- package/dist/pt-br-2W4P4ZAJ.js +2 -0
- package/dist/pt-br-JP6VI5C5.js +98 -0
- package/dist/pt-pt-22LJFZT5.js +98 -0
- package/dist/pt-pt-HOBFIPWZ.js +2 -0
- package/dist/ro-3KXIEYVK.js +98 -0
- package/dist/ro-3YUPB2TJ.js +1233 -0
- package/dist/ro-JXHNIBOA.js +2 -0
- package/dist/ro-KHPOLQC6.js +2 -0
- package/dist/ru-5ZVLKPFN.js +2 -0
- package/dist/ru-ASND25AB.js +2 -0
- package/dist/ru-ATGZC5LB.js +1233 -0
- package/dist/ru-W44AHOIC.js +98 -0
- package/dist/si-RHXLIDQI.js +1233 -0
- package/dist/si-U3O6NRHE.js +2 -0
- package/dist/srt-parser-6DEDUV5P.js +43 -0
- package/dist/srt-parser-E666S3YO.js +3 -0
- package/dist/ssa-parser-5GJ737XF.js +309 -0
- package/dist/ssa-parser-BR3CTDHR.js +5 -0
- package/dist/sv-5LOOKXJA.js +98 -0
- package/dist/sv-6GKNCPMS.js +2 -0
- package/dist/sv-LL3HMUIA.js +1233 -0
- package/dist/sv-RRJ6LYFT.js +2 -0
- package/dist/sw-HBNHIHPG.js +2 -0
- package/dist/sw-HP7MYGQ5.js +1233 -0
- package/dist/sw-NTSCFQXY.js +2 -0
- package/dist/sw-YIUB7QN3.js +98 -0
- package/dist/ta-4RG3PWN5.js +98 -0
- package/dist/ta-ARSNSDK5.js +2 -0
- package/dist/ta-Q2LBTDH6.js +2 -0
- package/dist/ta-Z5EVUBYF.js +1233 -0
- package/dist/te-FAWIFHVW.js +2 -0
- package/dist/te-FXJYUGGL.js +98 -0
- package/dist/te-GDV3DJFJ.js +1233 -0
- package/dist/te-TIMB7HBY.js +2 -0
- package/dist/th-7CEFYE5H.js +2 -0
- package/dist/th-CFAEFK3E.js +1233 -0
- package/dist/th-KGPTXFIF.js +2 -0
- package/dist/th-TC6J25FB.js +98 -0
- package/dist/tl-2JDK2CBL.js +2 -0
- package/dist/tl-SGZM4XSX.js +1233 -0
- package/dist/tr-27OEWIPE.js +1233 -0
- package/dist/tr-2MEHQO75.js +98 -0
- package/dist/tr-7P2UAX7U.js +2 -0
- package/dist/tr-NKD6C4RY.js +2 -0
- package/dist/uk-CXQISVJP.js +2 -0
- package/dist/uk-EJIGGLKY.js +1233 -0
- package/dist/uk-JCI3UE6Q.js +98 -0
- package/dist/uk-QM5BBWP7.js +2 -0
- package/dist/ur-5EWYHPME.js +1233 -0
- package/dist/ur-IIOUQYSA.js +98 -0
- package/dist/ur-M3QWGAPF.js +2 -0
- package/dist/ur-TLLPXSTM.js +2 -0
- package/dist/vi-AXQYYRD3.js +2 -0
- package/dist/vi-JALLXYS7.js +1233 -0
- package/dist/vi-SS65KZTI.js +2 -0
- package/dist/vi-YQVNQEVG.js +98 -0
- package/dist/vidstack-B9fTkxQO-LJP5ADOO.js +215 -0
- package/dist/vidstack-B9fTkxQO-OCT23G55.js +2 -0
- package/dist/vidstack-BmcqUMKx-A2W3TQB6.js +2 -0
- package/dist/vidstack-BmcqUMKx-G6TB22IC.js +286 -0
- package/dist/vidstack-C0fPJIzs-7AH6MOHO.js +2 -0
- package/dist/vidstack-C0fPJIzs-PNQOR4TK.js +11 -0
- package/dist/vidstack-CHcsWfRV-UAVLHO6N.js +40 -0
- package/dist/vidstack-CHcsWfRV-V52LFHYG.js +2 -0
- package/dist/vidstack-CvezEmSQ-JXKCQ4VQ.js +2 -0
- package/dist/vidstack-CvezEmSQ-R32NZKJ2.js +130 -0
- package/dist/vidstack-D2vrrUMs-7XAY5IBS.js +2 -0
- package/dist/vidstack-D2vrrUMs-FNQR2A5M.js +467 -0
- package/dist/vidstack-Di0HObvT-6ND3AXWZ.js +112 -0
- package/dist/vidstack-Di0HObvT-ZV7XK2OT.js +2 -0
- package/dist/vidstack-DiaLSJYx-H762DXYG.js +2 -0
- package/dist/vidstack-DiaLSJYx-S7DDW2H3.js +380 -0
- package/dist/vidstack-Dy74GavT-EYLL6MEF.js +2 -0
- package/dist/vidstack-Dy74GavT-XNIJ7PF4.js +11 -0
- package/dist/vidstack-GkTzay8D-C7EJKMV4.js +2 -0
- package/dist/vidstack-GkTzay8D-SQU5IF3P.js +482 -0
- package/dist/web-components.d.ts +12 -0
- package/dist/web-components.js +123 -0
- package/dist/worker.js +1 -0
- package/dist/zh-CN-PVVDP25S.js +2 -0
- package/dist/zh-CN-TLPNCXUN.js +1233 -0
- package/dist/zh-HK-GOKVZUJZ.js +1233 -0
- package/dist/zh-HK-Z5B2ANLW.js +2 -0
- package/dist/zh-Hant-2R7T4HJT.js +1233 -0
- package/dist/zh-Hant-MWAFLLDD.js +2 -0
- package/dist/zh-cn-D36OS2SI.js +2 -0
- package/dist/zh-cn-Z5YVUN62.js +98 -0
- package/dist/zh-tw-JWILJCBD.js +2 -0
- package/dist/zh-tw-X7JGMR4G.js +98 -0
- package/package.json +84 -3
|
@@ -0,0 +1,2046 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AudioPlayer,
|
|
3
|
+
FileDownloadCard,
|
|
4
|
+
MediaPlayer,
|
|
5
|
+
PDFViewer,
|
|
6
|
+
VideoPlayer
|
|
7
|
+
} from "./chunk-PXABHOW4.js";
|
|
8
|
+
import "./chunk-2UBPQBQI.js";
|
|
9
|
+
import "./chunk-IUB5YLUU.js";
|
|
10
|
+
import {
|
|
11
|
+
ARTICLE_CONTENT_STYLES,
|
|
12
|
+
AuthorList,
|
|
13
|
+
DEFAULT_IMAGE_LAYOUT,
|
|
14
|
+
GALLERY_COLS_CLASS,
|
|
15
|
+
Input,
|
|
16
|
+
MediaFactsProvider,
|
|
17
|
+
SiteImage,
|
|
18
|
+
applyProfile,
|
|
19
|
+
buildInlineStyle,
|
|
20
|
+
createHeadingIdAssigner,
|
|
21
|
+
deliverablePlayerLabels,
|
|
22
|
+
getEmbedUrl,
|
|
23
|
+
imageLayoutClassName,
|
|
24
|
+
isAllowedArticleMarkdownHref,
|
|
25
|
+
isExternalArticleMarkdownHref,
|
|
26
|
+
isHostedVideoUrl,
|
|
27
|
+
isImageAlign,
|
|
28
|
+
isImageSize,
|
|
29
|
+
parseArticleSegments,
|
|
30
|
+
parseMarkdown,
|
|
31
|
+
useMediaFacts
|
|
32
|
+
} from "./chunk-CHSZMJ5D.js";
|
|
33
|
+
import {
|
|
34
|
+
displayFileName,
|
|
35
|
+
fillLabel,
|
|
36
|
+
useMediaProtection
|
|
37
|
+
} from "./chunk-DDKQOHPW.js";
|
|
38
|
+
import {
|
|
39
|
+
formatFileSize
|
|
40
|
+
} from "./chunk-Y77XXKLY.js";
|
|
41
|
+
import {
|
|
42
|
+
ArrowLeft,
|
|
43
|
+
Award,
|
|
44
|
+
Check,
|
|
45
|
+
ChevronDown,
|
|
46
|
+
ChevronLeft,
|
|
47
|
+
Circle,
|
|
48
|
+
CircleCheck,
|
|
49
|
+
CirclePlay,
|
|
50
|
+
CircleX,
|
|
51
|
+
Download,
|
|
52
|
+
ExternalLink,
|
|
53
|
+
FileText,
|
|
54
|
+
List,
|
|
55
|
+
Lock,
|
|
56
|
+
PanelLeft,
|
|
57
|
+
Paperclip,
|
|
58
|
+
RotateCw,
|
|
59
|
+
Search,
|
|
60
|
+
Settings2,
|
|
61
|
+
X,
|
|
62
|
+
cn,
|
|
63
|
+
useSiteLabels
|
|
64
|
+
} from "./chunk-J7AP6FJF.js";
|
|
65
|
+
import "./chunk-G3PMV62Z.js";
|
|
66
|
+
|
|
67
|
+
// ../shared/components/deliverables/DeliverablePlayer.tsx
|
|
68
|
+
import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
69
|
+
|
|
70
|
+
// ../shared/components/deliverables/TranscriptPanel.tsx
|
|
71
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
72
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
73
|
+
var BORDER = "border-[var(--site-border,rgba(0,0,0,0.1))]";
|
|
74
|
+
var SURFACE = "bg-[var(--site-surface,#ffffff)] dark:bg-zinc-900";
|
|
75
|
+
var MUTED = "text-[var(--site-fg-muted,#71717a)]";
|
|
76
|
+
var FG = "text-[var(--site-fg,#18181b)]";
|
|
77
|
+
var CHIP = "inline-flex min-h-9 items-center rounded-full border px-3 text-xs";
|
|
78
|
+
function fill(template, values) {
|
|
79
|
+
return template.replace(/\{(\w+)\}/g, (_m, key) => String(values[key] ?? ""));
|
|
80
|
+
}
|
|
81
|
+
function formatTime(seconds) {
|
|
82
|
+
const total = Math.max(0, Math.floor(seconds));
|
|
83
|
+
const h = Math.floor(total / 3600);
|
|
84
|
+
const m = Math.floor(total % 3600 / 60);
|
|
85
|
+
const s = total % 60;
|
|
86
|
+
const mm = h > 0 ? String(m).padStart(2, "0") : String(m);
|
|
87
|
+
return `${h > 0 ? `${h}:` : ""}${mm}:${String(s).padStart(2, "0")}`;
|
|
88
|
+
}
|
|
89
|
+
function languageName(locale, uiLocale) {
|
|
90
|
+
try {
|
|
91
|
+
return new Intl.DisplayNames([uiLocale], { type: "language" }).of(locale) ?? locale;
|
|
92
|
+
} catch {
|
|
93
|
+
return locale;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function activeSegmentIndex(segments, time) {
|
|
97
|
+
let lo = 0;
|
|
98
|
+
let hi = segments.length - 1;
|
|
99
|
+
let hit = -1;
|
|
100
|
+
while (lo <= hi) {
|
|
101
|
+
const mid = lo + hi >> 1;
|
|
102
|
+
if (segments[mid].s <= time) {
|
|
103
|
+
hit = mid;
|
|
104
|
+
lo = mid + 1;
|
|
105
|
+
} else hi = mid - 1;
|
|
106
|
+
}
|
|
107
|
+
return hit;
|
|
108
|
+
}
|
|
109
|
+
function highlight(text, query) {
|
|
110
|
+
if (!query) return text;
|
|
111
|
+
const lower = text.toLowerCase();
|
|
112
|
+
const needle = query.toLowerCase();
|
|
113
|
+
const parts = [];
|
|
114
|
+
let from = 0;
|
|
115
|
+
for (; ; ) {
|
|
116
|
+
const at = lower.indexOf(needle, from);
|
|
117
|
+
if (at === -1) break;
|
|
118
|
+
if (at > from) parts.push(text.slice(from, at));
|
|
119
|
+
parts.push(
|
|
120
|
+
/* @__PURE__ */ jsx("mark", { className: "rounded-sm bg-yellow-200 px-0.5 text-inherit dark:bg-yellow-500/40", children: text.slice(at, at + needle.length) }, at)
|
|
121
|
+
);
|
|
122
|
+
from = at + needle.length;
|
|
123
|
+
}
|
|
124
|
+
if (from < text.length) parts.push(text.slice(from));
|
|
125
|
+
return parts;
|
|
126
|
+
}
|
|
127
|
+
function TranscriptPanel({ labels, open, onToggle, status, data, activeIndex, onSeek, onLocaleChange, onRetry, uiLocale, fileName, className }) {
|
|
128
|
+
const [query, setQuery] = useState("");
|
|
129
|
+
const [follow, setFollow] = useState(true);
|
|
130
|
+
const listRef = useRef(null);
|
|
131
|
+
const trimmed = query.trim();
|
|
132
|
+
const matches = useMemo(() => {
|
|
133
|
+
if (!data || !trimmed) return null;
|
|
134
|
+
const needle = trimmed.toLowerCase();
|
|
135
|
+
return data.segments.map((seg, index) => seg.t.toLowerCase().includes(needle) ? index : -1).filter((i) => i >= 0);
|
|
136
|
+
}, [data, trimmed]);
|
|
137
|
+
const visible = matches ?? (data ? data.segments.map((_seg, index) => index) : []);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!open || !follow || matches || activeIndex < 0) return;
|
|
140
|
+
const list = listRef.current;
|
|
141
|
+
const row = list?.querySelector(`[data-index="${activeIndex}"]`);
|
|
142
|
+
if (!list || !row) return;
|
|
143
|
+
const top = row.offsetTop - list.offsetTop;
|
|
144
|
+
const bottom = top + row.offsetHeight;
|
|
145
|
+
if (top < list.scrollTop || bottom > list.scrollTop + list.clientHeight) list.scrollTo({ top: Math.max(0, top - list.clientHeight / 3), behavior: "smooth" });
|
|
146
|
+
}, [activeIndex, open, follow, matches]);
|
|
147
|
+
const download = () => {
|
|
148
|
+
if (!data) return;
|
|
149
|
+
const blob = new Blob([data.segments.map((seg) => seg.t).join("\n")], { type: "text/plain;charset=utf-8" });
|
|
150
|
+
const url = URL.createObjectURL(blob);
|
|
151
|
+
const a = document.createElement("a");
|
|
152
|
+
a.href = url;
|
|
153
|
+
a.download = `${fileName || "transcript"}.${data.locale}.txt`;
|
|
154
|
+
document.body.appendChild(a);
|
|
155
|
+
a.click();
|
|
156
|
+
a.remove();
|
|
157
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
158
|
+
};
|
|
159
|
+
const trackLabel = (track) => {
|
|
160
|
+
const name = languageName(track.locale, uiLocale);
|
|
161
|
+
if (track.edited) return name;
|
|
162
|
+
if (track.source === "ai") return `${name}\uFF08${labels.transcriptAutoGenerated}\uFF09`;
|
|
163
|
+
if (track.source === "translation") return `${name}\uFF08${labels.transcriptAutoTranslated}\uFF09`;
|
|
164
|
+
return name;
|
|
165
|
+
};
|
|
166
|
+
return /* @__PURE__ */ jsxs("section", { className: cn("rounded-[var(--site-radius-card,0.75rem)] border", BORDER, SURFACE, className), "aria-label": labels.transcript, "data-kanorio-transcript": true, children: [
|
|
167
|
+
/* @__PURE__ */ jsxs(
|
|
168
|
+
"button",
|
|
169
|
+
{
|
|
170
|
+
type: "button",
|
|
171
|
+
onClick: () => onToggle(!open),
|
|
172
|
+
"aria-expanded": open,
|
|
173
|
+
className: cn("flex min-h-12 w-full items-center gap-2 px-3 text-left text-sm font-semibold", FG),
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsx(FileText, { className: cn("h-4 w-4 shrink-0", MUTED), "aria-hidden": "true" }),
|
|
176
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.transcript }),
|
|
177
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-xs font-normal", MUTED), children: open ? labels.transcriptHide : labels.transcriptShow }),
|
|
178
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: cn("h-4 w-4 shrink-0 transition-transform", MUTED, open && "rotate-180"), "aria-hidden": "true" })
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
open && /* @__PURE__ */ jsx("div", { className: cn("border-t", BORDER), children: status === "loading" || status === "idle" ? /* @__PURE__ */ jsx("div", { className: "space-y-2 p-3", "aria-busy": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx("div", { className: "h-4 animate-pulse rounded bg-black/5 dark:bg-white/10", style: { width: `${80 - i * 15}%` } }, i)) }) : status === "error" || !data ? /* @__PURE__ */ jsxs("div", { role: "alert", className: cn("flex flex-col items-center gap-2 p-6 text-center text-sm", MUTED), children: [
|
|
183
|
+
/* @__PURE__ */ jsx("p", { children: labels.loadError }),
|
|
184
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: onRetry, className: cn(CHIP, BORDER, FG), children: [
|
|
185
|
+
/* @__PURE__ */ jsx(RotateCw, { className: "mr-1 h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
186
|
+
" ",
|
|
187
|
+
labels.retry
|
|
188
|
+
] })
|
|
189
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
190
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 p-3", children: [
|
|
191
|
+
/* @__PURE__ */ jsxs("label", { className: "relative min-w-40 flex-1", children: [
|
|
192
|
+
/* @__PURE__ */ jsx(Search, { className: cn("pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2", MUTED), "aria-hidden": "true" }),
|
|
193
|
+
/* @__PURE__ */ jsx(Input, { type: "search", value: query, onChange: (e) => setQuery(e.target.value), placeholder: labels.transcriptSearch, "aria-label": labels.transcriptSearch, className: "h-10 pl-9" })
|
|
194
|
+
] }),
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
type: "button",
|
|
199
|
+
onClick: () => setFollow((v) => !v),
|
|
200
|
+
"aria-pressed": follow,
|
|
201
|
+
className: cn(CHIP, BORDER, follow ? FG : MUTED, follow && "bg-black/5 dark:bg-white/10"),
|
|
202
|
+
children: labels.transcriptFollow
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick: download, className: cn(CHIP, BORDER, FG), children: [
|
|
206
|
+
/* @__PURE__ */ jsx(Download, { className: "mr-1 h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
207
|
+
" ",
|
|
208
|
+
labels.transcriptDownload
|
|
209
|
+
] })
|
|
210
|
+
] }),
|
|
211
|
+
data.tracks.length > 1 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2 px-3 pb-3", role: "group", "aria-label": labels.transcriptLanguage, children: data.tracks.map((track) => /* @__PURE__ */ jsx(
|
|
212
|
+
"button",
|
|
213
|
+
{
|
|
214
|
+
type: "button",
|
|
215
|
+
onClick: () => onLocaleChange(track.locale),
|
|
216
|
+
"aria-pressed": track.locale === data.locale,
|
|
217
|
+
lang: track.locale,
|
|
218
|
+
className: cn(CHIP, BORDER, track.locale === data.locale ? cn(FG, "bg-black/5 dark:bg-white/10") : MUTED),
|
|
219
|
+
children: trackLabel(track)
|
|
220
|
+
},
|
|
221
|
+
track.locale
|
|
222
|
+
)) }),
|
|
223
|
+
matches && /* @__PURE__ */ jsx("p", { className: cn("px-3 pb-2 text-xs", MUTED), role: "status", children: matches.length > 0 ? fill(labels.transcriptMatches, { count: matches.length }) : labels.transcriptNoResults }),
|
|
224
|
+
/* @__PURE__ */ jsx("ol", { ref: listRef, className: "max-h-80 overflow-y-auto px-2 pb-2", lang: data.locale, children: visible.map((index) => {
|
|
225
|
+
const seg = data.segments[index];
|
|
226
|
+
const active = index === activeIndex;
|
|
227
|
+
return /* @__PURE__ */ jsx("li", { "data-index": index, children: /* @__PURE__ */ jsxs(
|
|
228
|
+
"button",
|
|
229
|
+
{
|
|
230
|
+
type: "button",
|
|
231
|
+
onClick: () => onSeek(seg.s),
|
|
232
|
+
"aria-current": active ? "true" : void 0,
|
|
233
|
+
className: cn(
|
|
234
|
+
"flex w-full gap-3 rounded-[var(--site-radius-button,0.5rem)] px-2 py-1.5 text-left text-sm hover:bg-black/5 dark:hover:bg-white/10",
|
|
235
|
+
active ? cn(FG, "bg-black/5 font-medium dark:bg-white/10") : FG
|
|
236
|
+
),
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsx("span", { className: cn("w-11 shrink-0 pt-0.5 font-mono text-xs tabular-nums", MUTED), children: formatTime(seg.s) }),
|
|
239
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 leading-relaxed", children: highlight(seg.t, trimmed) })
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
) }, index);
|
|
243
|
+
}) })
|
|
244
|
+
] }) })
|
|
245
|
+
] });
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ../shared/deliverables/playback.ts
|
|
249
|
+
function classifyDevice(input) {
|
|
250
|
+
if (input.width < 768) return "mobile";
|
|
251
|
+
if (input.coarsePointer && input.width < 1024) return "tablet";
|
|
252
|
+
return "desktop";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ../shared/components/blog/ArticleMarkdown.tsx
|
|
256
|
+
import { Fragment as Fragment4 } from "react";
|
|
257
|
+
|
|
258
|
+
// ../shared/markdown/article-view.tsx
|
|
259
|
+
import React2 from "react";
|
|
260
|
+
|
|
261
|
+
// ../shared/markdown/view.tsx
|
|
262
|
+
import React from "react";
|
|
263
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
264
|
+
function styleOf(params) {
|
|
265
|
+
if (!params) return {};
|
|
266
|
+
const built = buildInlineStyle(params);
|
|
267
|
+
const style = {};
|
|
268
|
+
if (built.style) {
|
|
269
|
+
for (const decl of built.style.split(";")) {
|
|
270
|
+
const idx = decl.indexOf(":");
|
|
271
|
+
if (idx === -1) continue;
|
|
272
|
+
const prop = decl.slice(0, idx).trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
273
|
+
const value = decl.slice(idx + 1).trim();
|
|
274
|
+
if (prop && value) style[prop] = value;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return { className: built.className ?? void 0, style: built.style ? style : void 0 };
|
|
278
|
+
}
|
|
279
|
+
function renderPhrasing(nodes, keyPrefix, overrides = {}) {
|
|
280
|
+
return (nodes ?? []).map((node, index) => {
|
|
281
|
+
const key = `${keyPrefix}-${index}`;
|
|
282
|
+
const inner = () => renderPhrasing(node.children, key, overrides);
|
|
283
|
+
if (node.type === "text") return /* @__PURE__ */ jsx2(React.Fragment, { children: node.value }, key);
|
|
284
|
+
if (node.type === "strong") return /* @__PURE__ */ jsx2("strong", { children: inner() }, key);
|
|
285
|
+
if (node.type === "emphasis") return /* @__PURE__ */ jsx2("em", { children: inner() }, key);
|
|
286
|
+
if (node.type === "delete") return /* @__PURE__ */ jsx2("del", { children: inner() }, key);
|
|
287
|
+
if (node.type === "underline") return /* @__PURE__ */ jsx2("u", { children: inner() }, key);
|
|
288
|
+
if (node.type === "inlineCode") {
|
|
289
|
+
return /* @__PURE__ */ jsx2("code", { className: "bg-zinc-100 dark:bg-zinc-800 rounded px-1.5 py-0.5 font-mono text-sm", children: node.value }, key);
|
|
290
|
+
}
|
|
291
|
+
if (node.type === "inlineStyle") {
|
|
292
|
+
const styled = styleOf(node.params);
|
|
293
|
+
return /* @__PURE__ */ jsx2("span", { className: styled.className, style: styled.style, children: inner() }, key);
|
|
294
|
+
}
|
|
295
|
+
if (node.type === "break") return /* @__PURE__ */ jsx2("br", {}, key);
|
|
296
|
+
if (node.type === "link") {
|
|
297
|
+
if (overrides.link) return overrides.link(node, key, inner());
|
|
298
|
+
const url = node.url ?? "";
|
|
299
|
+
if (!isAllowedArticleMarkdownHref(url)) return /* @__PURE__ */ jsx2("span", { children: inner() }, key);
|
|
300
|
+
return /* @__PURE__ */ jsx2(
|
|
301
|
+
"a",
|
|
302
|
+
{
|
|
303
|
+
href: url,
|
|
304
|
+
...isExternalArticleMarkdownHref(url) ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
305
|
+
className: "text-[var(--brand-text,var(--brand-color))] underline font-medium hover:opacity-80 break-words",
|
|
306
|
+
children: inner()
|
|
307
|
+
},
|
|
308
|
+
key
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
if (node.type === "image") return overrides.image ? overrides.image(node, key) : null;
|
|
312
|
+
if (node.children) return /* @__PURE__ */ jsx2(React.Fragment, { children: inner() }, key);
|
|
313
|
+
return null;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function renderListItem(item, key, renderBlocks) {
|
|
317
|
+
const children = item.children ?? [];
|
|
318
|
+
const [first, ...rest] = children;
|
|
319
|
+
if (first?.type === "paragraph") {
|
|
320
|
+
return /* @__PURE__ */ jsxs2("li", { children: [
|
|
321
|
+
renderPhrasing(first.children, key),
|
|
322
|
+
rest.length > 0 && renderBlocks(rest)
|
|
323
|
+
] }, key);
|
|
324
|
+
}
|
|
325
|
+
return /* @__PURE__ */ jsx2("li", { children: renderBlocks(children) }, key);
|
|
326
|
+
}
|
|
327
|
+
function renderBodyBlocks(nodes) {
|
|
328
|
+
return (nodes ?? []).map((node, index) => {
|
|
329
|
+
const key = `b-${index}`;
|
|
330
|
+
if (node.type === "paragraph") {
|
|
331
|
+
return /* @__PURE__ */ jsx2("p", { className: "break-words", children: renderPhrasing(node.children, key) }, key);
|
|
332
|
+
}
|
|
333
|
+
if (node.type === "list" && node.ordered) {
|
|
334
|
+
return /* @__PURE__ */ jsx2("ol", { className: "list-decimal list-outside pl-6 space-y-1 break-words", children: (node.children ?? []).map((item, itemIndex) => renderListItem(item, `${key}-${itemIndex}`, renderBodyBlocks)) }, key);
|
|
335
|
+
}
|
|
336
|
+
if (node.type === "list") {
|
|
337
|
+
return /* @__PURE__ */ jsx2("ul", { className: "list-disc list-outside pl-6 space-y-1 break-words", children: (node.children ?? []).map((item, itemIndex) => renderListItem(item, `${key}-${itemIndex}`, renderBodyBlocks)) }, key);
|
|
338
|
+
}
|
|
339
|
+
if (node.type === "blockquote") {
|
|
340
|
+
return /* @__PURE__ */ jsx2(
|
|
341
|
+
"blockquote",
|
|
342
|
+
{
|
|
343
|
+
className: "border-l-4 border-[var(--brand-text,var(--brand-color))] pl-4 italic text-zinc-600 dark:text-zinc-300",
|
|
344
|
+
children: renderBodyBlocks(node.children)
|
|
345
|
+
},
|
|
346
|
+
key
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if (node.type === "code") {
|
|
350
|
+
return /* @__PURE__ */ jsx2(
|
|
351
|
+
"pre",
|
|
352
|
+
{
|
|
353
|
+
className: "bg-zinc-100 dark:bg-zinc-800 rounded-[var(--site-radius-lg,0.5rem)] p-4 font-mono text-sm leading-6 overflow-x-auto whitespace-pre-wrap text-zinc-700 dark:text-zinc-300",
|
|
354
|
+
children: /* @__PURE__ */ jsx2("code", { children: node.value })
|
|
355
|
+
},
|
|
356
|
+
key
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function RichTextView({
|
|
363
|
+
content,
|
|
364
|
+
profile,
|
|
365
|
+
className,
|
|
366
|
+
blockClassName = "space-y-2"
|
|
367
|
+
}) {
|
|
368
|
+
if (!content) return null;
|
|
369
|
+
const applied = applyProfile(parseMarkdown(content, profile).tree, profile);
|
|
370
|
+
if (profile === "inline") {
|
|
371
|
+
const paragraph = applied.tree.children?.[0];
|
|
372
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: renderPhrasing(paragraph?.children, "i") });
|
|
373
|
+
}
|
|
374
|
+
if (!applied.tree.children?.length) return null;
|
|
375
|
+
return /* @__PURE__ */ jsx2("div", { className: cn("site-body-text break-words min-w-0", blockClassName, className), children: renderBodyBlocks(applied.tree.children) });
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ../shared/markdown/article-view.tsx
|
|
379
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
380
|
+
function plainTextOf(node) {
|
|
381
|
+
if (!node) return "";
|
|
382
|
+
if (node.type === "text") return node.value ?? "";
|
|
383
|
+
return (node.children ?? []).map(plainTextOf).join("");
|
|
384
|
+
}
|
|
385
|
+
var ARTICLE_OVERRIDES = {
|
|
386
|
+
link(node, key, children) {
|
|
387
|
+
const href = node.url ?? "";
|
|
388
|
+
if (!isAllowedArticleMarkdownHref(href)) {
|
|
389
|
+
return /* @__PURE__ */ jsx3("span", { className: "text-[var(--brand-text,var(--brand-color))] font-medium", children }, key);
|
|
390
|
+
}
|
|
391
|
+
return /* @__PURE__ */ jsx3(
|
|
392
|
+
"a",
|
|
393
|
+
{
|
|
394
|
+
href,
|
|
395
|
+
className: "text-[var(--brand-text,var(--brand-color))] underline font-medium hover:opacity-80",
|
|
396
|
+
...isExternalArticleMarkdownHref(href) ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
397
|
+
children
|
|
398
|
+
},
|
|
399
|
+
key
|
|
400
|
+
);
|
|
401
|
+
},
|
|
402
|
+
image(node, key) {
|
|
403
|
+
const rawSize = node.data?.hProperties?.["data-size"];
|
|
404
|
+
const rawAlign = node.data?.hProperties?.["data-align"];
|
|
405
|
+
const layout = {
|
|
406
|
+
size: isImageSize(rawSize) ? rawSize : DEFAULT_IMAGE_LAYOUT.size,
|
|
407
|
+
align: isImageAlign(rawAlign) ? rawAlign : DEFAULT_IMAGE_LAYOUT.align
|
|
408
|
+
};
|
|
409
|
+
return /* @__PURE__ */ jsx3(
|
|
410
|
+
SiteImage,
|
|
411
|
+
{
|
|
412
|
+
src: node.url ?? "",
|
|
413
|
+
responsive: true,
|
|
414
|
+
explicitAlt: node.alt ?? void 0,
|
|
415
|
+
altType: "article-image",
|
|
416
|
+
title: node.title ?? void 0,
|
|
417
|
+
className: `block rounded-[var(--site-radius-media)] my-5 h-auto ${imageLayoutClassName(layout)}`
|
|
418
|
+
},
|
|
419
|
+
key
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
function renderArticlePhrasing(nodes, keyPrefix) {
|
|
424
|
+
return renderPhrasing(nodes, keyPrefix, ARTICLE_OVERRIDES);
|
|
425
|
+
}
|
|
426
|
+
function renderTable(node, key) {
|
|
427
|
+
const rows = node.children ?? [];
|
|
428
|
+
const [headerRow, ...bodyRows] = rows;
|
|
429
|
+
return /* @__PURE__ */ jsxs3("table", { children: [
|
|
430
|
+
headerRow && /* @__PURE__ */ jsx3("thead", { children: /* @__PURE__ */ jsx3("tr", { children: (headerRow.children ?? []).map((cell, cellIndex) => /* @__PURE__ */ jsx3("th", { children: renderArticlePhrasing(cell.children, `${key}-h-${cellIndex}`) }, cellIndex)) }) }),
|
|
431
|
+
/* @__PURE__ */ jsx3("tbody", { children: bodyRows.map((row, rowIndex) => /* @__PURE__ */ jsx3("tr", { children: (row.children ?? []).map((cell, cellIndex) => /* @__PURE__ */ jsx3("td", { children: renderArticlePhrasing(cell.children, `${key}-${rowIndex}-${cellIndex}`) }, cellIndex)) }, rowIndex)) })
|
|
432
|
+
] }, key);
|
|
433
|
+
}
|
|
434
|
+
function renderListItems(items, keyPrefix, assignId) {
|
|
435
|
+
return items.map((item, index) => {
|
|
436
|
+
const key = `${keyPrefix}-${index}`;
|
|
437
|
+
const isTask = typeof item.checked === "boolean";
|
|
438
|
+
const contentNodes = (item.children ?? []).flatMap((child) => child.type === "paragraph" ? child.children ?? [] : []);
|
|
439
|
+
const blockChildren = (item.children ?? []).filter((child) => child.type !== "paragraph");
|
|
440
|
+
if (isTask) {
|
|
441
|
+
return /* @__PURE__ */ jsxs3("li", { className: "flex items-start gap-2", children: [
|
|
442
|
+
/* @__PURE__ */ jsx3(
|
|
443
|
+
"span",
|
|
444
|
+
{
|
|
445
|
+
role: "checkbox",
|
|
446
|
+
"aria-checked": item.checked ?? false,
|
|
447
|
+
"aria-disabled": "true",
|
|
448
|
+
className: "mt-1.5 inline-block size-4 shrink-0 rounded-sm border border-zinc-400 text-center text-xs leading-4",
|
|
449
|
+
children: item.checked ? "\u2713" : ""
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsx3("span", { children: renderArticlePhrasing(contentNodes, key) })
|
|
453
|
+
] }, key);
|
|
454
|
+
}
|
|
455
|
+
return /* @__PURE__ */ jsxs3("li", { children: [
|
|
456
|
+
renderArticlePhrasing(contentNodes, key),
|
|
457
|
+
blockChildren.length > 0 && renderArticleBlocks(blockChildren, assignId)
|
|
458
|
+
] }, key);
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
function renderArticleBlocks(nodes, assignId) {
|
|
462
|
+
return (nodes ?? []).map((node, index) => {
|
|
463
|
+
const key = `a-${index}`;
|
|
464
|
+
if (node.type === "paragraph") {
|
|
465
|
+
return /* @__PURE__ */ jsx3("p", { className: `${ARTICLE_CONTENT_STYLES.body} mb-4 text-zinc-700 dark:text-zinc-300`, children: renderArticlePhrasing(node.children, key) }, key);
|
|
466
|
+
}
|
|
467
|
+
if (node.type === "heading") {
|
|
468
|
+
const level = node.depth === 1 ? 2 : node.depth ?? 2;
|
|
469
|
+
const id = assignId(plainTextOf(node));
|
|
470
|
+
const Tag = `h${level}`;
|
|
471
|
+
const styleKey = `h${level}`;
|
|
472
|
+
const className = level <= 3 ? `${ARTICLE_CONTENT_STYLES[styleKey]} ${level === 2 ? "mt-8 mb-4" : "mt-6 mb-3"} text-zinc-900 dark:text-zinc-50 scroll-mt-24` : `${ARTICLE_CONTENT_STYLES[styleKey]} mt-5 mb-2 text-zinc-800 dark:text-zinc-100`;
|
|
473
|
+
return /* @__PURE__ */ jsx3(Tag, { id, className, children: renderArticlePhrasing(node.children, key) }, key);
|
|
474
|
+
}
|
|
475
|
+
if (node.type === "list" && node.ordered) {
|
|
476
|
+
return /* @__PURE__ */ jsx3("ol", { className: `list-decimal list-outside pl-6 space-y-2 my-5 ${ARTICLE_CONTENT_STYLES.body} text-zinc-700 dark:text-zinc-300`, children: renderListItems(node.children ?? [], key, assignId) }, key);
|
|
477
|
+
}
|
|
478
|
+
if (node.type === "list") {
|
|
479
|
+
const hasTask = (node.children ?? []).some((item) => typeof item.checked === "boolean");
|
|
480
|
+
return /* @__PURE__ */ jsx3(
|
|
481
|
+
"ul",
|
|
482
|
+
{
|
|
483
|
+
className: hasTask ? `list-none pl-0 space-y-2 my-5 ${ARTICLE_CONTENT_STYLES.body} text-zinc-700 dark:text-zinc-300` : `list-disc list-outside pl-6 space-y-2 my-5 ${ARTICLE_CONTENT_STYLES.body} text-zinc-700 dark:text-zinc-300`,
|
|
484
|
+
children: renderListItems(node.children ?? [], key, assignId)
|
|
485
|
+
},
|
|
486
|
+
key
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
if (node.type === "blockquote") {
|
|
490
|
+
return /* @__PURE__ */ jsx3(
|
|
491
|
+
"blockquote",
|
|
492
|
+
{
|
|
493
|
+
className: `border-l-4 border-[var(--brand-text,var(--brand-color))] pl-4 italic ${ARTICLE_CONTENT_STYLES.body} text-zinc-600 dark:text-zinc-300 my-5`,
|
|
494
|
+
children: renderArticleBlocks(node.children, assignId)
|
|
495
|
+
},
|
|
496
|
+
key
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
if (node.type === "code") {
|
|
500
|
+
return /* @__PURE__ */ jsx3(
|
|
501
|
+
"pre",
|
|
502
|
+
{
|
|
503
|
+
className: "bg-zinc-100 dark:bg-zinc-800 rounded-[var(--site-radius-lg)] p-4 font-mono text-sm leading-6 my-5 overflow-x-auto whitespace-pre-wrap text-zinc-700 dark:text-zinc-300",
|
|
504
|
+
children: /* @__PURE__ */ jsx3("code", { children: node.value })
|
|
505
|
+
},
|
|
506
|
+
key
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
if (node.type === "thematicBreak") {
|
|
510
|
+
return /* @__PURE__ */ jsx3("hr", { className: "my-6 border-zinc-200 dark:border-zinc-700" }, key);
|
|
511
|
+
}
|
|
512
|
+
if (node.type === "table") return renderTable(node, key);
|
|
513
|
+
if (node.type === "image" || node.type === "link") {
|
|
514
|
+
return /* @__PURE__ */ jsx3(React2.Fragment, { children: renderArticlePhrasing([node], key) }, key);
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function ArticleInlineRichText({ content }) {
|
|
520
|
+
const applied = applyProfile(parseMarkdown(content, "article").tree, "article");
|
|
521
|
+
const paragraph = applied.tree.children?.find((node) => node.type === "paragraph");
|
|
522
|
+
return /* @__PURE__ */ jsx3(Fragment3, { children: renderArticlePhrasing(paragraph?.children, "ai") });
|
|
523
|
+
}
|
|
524
|
+
function renderArticleRichText(content, assignId) {
|
|
525
|
+
const applied = applyProfile(parseMarkdown(content, "article").tree, "article");
|
|
526
|
+
if (!applied.tree.children?.length) return null;
|
|
527
|
+
return /* @__PURE__ */ jsx3(Fragment3, { children: renderArticleBlocks(applied.tree.children, assignId) });
|
|
528
|
+
}
|
|
529
|
+
function ArticleRichText({
|
|
530
|
+
content,
|
|
531
|
+
assignId
|
|
532
|
+
}) {
|
|
533
|
+
return /* @__PURE__ */ jsx3(Fragment3, { children: renderArticleRichText(content, assignId) });
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// ../shared/components/blog/ctaStyles.ts
|
|
537
|
+
var ctaStyles = {
|
|
538
|
+
/**
|
|
539
|
+
* 外框:比照文字小卡 — 實色背景、跟隨站台圓角、陰影,置中。
|
|
540
|
+
* 註:原本的 `my-8` 與 `md:p-10` 因本 .ts 檔先前未被 Tailwind 掃描,公開站從未生效;
|
|
541
|
+
* 掃描修正後為維持公開站外觀不變,暫不啟用。若要補回設計稿的外距/大內距,
|
|
542
|
+
* 加回 `my-8 @vp-md/article:p-10` 即可(編輯器與公開站會同步改變)。
|
|
543
|
+
*/
|
|
544
|
+
container: "rounded-[var(--site-radius-card)] bg-zinc-100 dark:bg-zinc-800 p-8 shadow-lg text-center",
|
|
545
|
+
/** 自由排版內文容器(markdown 渲染) */
|
|
546
|
+
content: "text-zinc-700 dark:text-zinc-200 leading-relaxed [&_p]:my-1.5 [&_strong]:text-zinc-900 dark:[&_strong]:text-zinc-50 [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:text-left [&_ul]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:text-left [&_ol]:my-2 [&_a]:text-[var(--brand-text,var(--brand-color))] [&_a]:underline",
|
|
547
|
+
/** 內文與按鈕之間的間距(有按鈕時套用) */
|
|
548
|
+
contentSpacing: "mb-6",
|
|
549
|
+
/** 按鈕:比照站台 CTA 按鈕(CtaButtons)— 品牌色、跟隨站台圓角、≥44px 觸控 */
|
|
550
|
+
button: "inline-flex items-center justify-center gap-2 rounded-[var(--site-radius-button)] bg-[var(--brand-color)] px-6 @vp-md/article:px-8 py-3 min-h-[44px] text-base font-bold text-[var(--brand-foreground)] shadow-md transition-all duration-200 hover:scale-[1.02] hover:shadow-lg active:scale-[0.98]"
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// ../shared/components/blog/UserCtaShortcodeBlock.tsx
|
|
554
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
555
|
+
function UserCtaShortcodeBlock({
|
|
556
|
+
config,
|
|
557
|
+
presets
|
|
558
|
+
}) {
|
|
559
|
+
let buttonText;
|
|
560
|
+
let href;
|
|
561
|
+
if (config.type === "preset") {
|
|
562
|
+
const preset = config.slug ? presets?.[config.slug] : void 0;
|
|
563
|
+
if (preset) {
|
|
564
|
+
buttonText = preset.label;
|
|
565
|
+
href = preset.href;
|
|
566
|
+
}
|
|
567
|
+
} else {
|
|
568
|
+
buttonText = config.buttonText;
|
|
569
|
+
href = config.href;
|
|
570
|
+
}
|
|
571
|
+
const hasContent = Boolean(config.content?.trim());
|
|
572
|
+
const hasButton = Boolean(buttonText && href);
|
|
573
|
+
if (!hasContent && !hasButton) return null;
|
|
574
|
+
const isExternal = href ? /^https?:\/\//.test(href) : false;
|
|
575
|
+
return /* @__PURE__ */ jsxs4("div", { className: ctaStyles.container, children: [
|
|
576
|
+
hasContent && /* @__PURE__ */ jsx4("div", { className: `${ctaStyles.content}${hasButton ? ` ${ctaStyles.contentSpacing}` : ""}`, children: /* @__PURE__ */ jsx4(ArticleRichText, { content: config.content, assignId: createHeadingIdAssigner() }) }),
|
|
577
|
+
hasButton && href && /* @__PURE__ */ jsx4(
|
|
578
|
+
"a",
|
|
579
|
+
{
|
|
580
|
+
href,
|
|
581
|
+
className: ctaStyles.button,
|
|
582
|
+
"data-cta-track": "",
|
|
583
|
+
"data-cta-button-name": buttonText,
|
|
584
|
+
"data-cta-element-id": "blog-article-cta",
|
|
585
|
+
...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
586
|
+
children: buttonText
|
|
587
|
+
}
|
|
588
|
+
)
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ../shared/components/blog/UserFaqShortcodeBlock.tsx
|
|
593
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
594
|
+
function UserFaqShortcodeBlock({ config }) {
|
|
595
|
+
if (config.items.length === 0) return null;
|
|
596
|
+
const assignId = createHeadingIdAssigner();
|
|
597
|
+
return /* @__PURE__ */ jsxs5("section", { className: "my-6 space-y-4", children: [
|
|
598
|
+
config.title && /* @__PURE__ */ jsx5("h2", { className: "text-2xl font-bold text-zinc-900 dark:text-zinc-50 mb-2", children: config.title }),
|
|
599
|
+
config.items.map((item, i) => /* @__PURE__ */ jsxs5("div", { className: "my-4", children: [
|
|
600
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-start gap-2 text-zinc-900 dark:text-zinc-100", children: [
|
|
601
|
+
/* @__PURE__ */ jsx5("span", { className: "shrink-0 mt-0.5 w-5 h-5 rounded bg-emerald-100 dark:bg-emerald-900/40 flex items-center justify-center text-emerald-700 dark:text-emerald-300 text-[10px] font-bold", children: "Q" }),
|
|
602
|
+
/* @__PURE__ */ jsx5("span", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsx5(ArticleInlineRichText, { content: item.question }) })
|
|
603
|
+
] }),
|
|
604
|
+
/* @__PURE__ */ jsxs5("div", { className: "mt-1 flex items-start gap-2", children: [
|
|
605
|
+
/* @__PURE__ */ jsx5("span", { className: "shrink-0 mt-0.5 w-5 h-5 rounded bg-blue-100 dark:bg-blue-900/40 flex items-center justify-center text-blue-700 dark:text-blue-300 text-[10px] font-bold", children: "A" }),
|
|
606
|
+
/* @__PURE__ */ jsx5("div", { className: "flex-1 min-w-0 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", children: /* @__PURE__ */ jsx5(ArticleRichText, { content: item.answer, assignId }) })
|
|
607
|
+
] })
|
|
608
|
+
] }, i))
|
|
609
|
+
] });
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// ../shared/components/blog/EmbedBlock.tsx
|
|
613
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
614
|
+
function EmbedBlock({ url, embedType }) {
|
|
615
|
+
const { ui } = useSiteLabels();
|
|
616
|
+
const facts = useMediaFacts({ url });
|
|
617
|
+
if (isHostedVideoUrl(url)) {
|
|
618
|
+
return /* @__PURE__ */ jsx6("div", { className: "my-6 not-prose", children: /* @__PURE__ */ jsx6(VideoPlayer, { src: url, hlsSrc: facts?.hls, thumbnails: facts?.thumbnails, streamingPartial: facts?.streamingPartial, captions: facts?.captions, chapters: facts?.chapters, storageKey: url, poster: facts?.cover }) });
|
|
619
|
+
}
|
|
620
|
+
const embedUrl = getEmbedUrl(url, embedType);
|
|
621
|
+
if (!embedUrl) {
|
|
622
|
+
return /* @__PURE__ */ jsx6("div", { className: "my-6 p-4 rounded-[var(--site-radius-media)] border border-zinc-200 dark:border-zinc-700 bg-zinc-50 dark:bg-zinc-800/50", children: /* @__PURE__ */ jsx6("p", { className: "text-sm text-zinc-500 dark:text-zinc-400", children: fillLabel(ui.embedLoadFailed, { url }) }) });
|
|
623
|
+
}
|
|
624
|
+
return /* @__PURE__ */ jsx6("div", { className: "my-6 rounded-[var(--site-radius-media)] overflow-hidden", children: /* @__PURE__ */ jsx6("div", { className: "aspect-video bg-zinc-900", children: /* @__PURE__ */ jsx6(
|
|
625
|
+
"iframe",
|
|
626
|
+
{
|
|
627
|
+
src: embedUrl,
|
|
628
|
+
className: "w-full h-full",
|
|
629
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
630
|
+
allowFullScreen: true,
|
|
631
|
+
loading: "lazy"
|
|
632
|
+
}
|
|
633
|
+
) }) });
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// ../shared/components/blog/AudioBlock.tsx
|
|
637
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
638
|
+
function AudioBlock({ src, title }) {
|
|
639
|
+
const displayTitle = title || src.split("/").pop()?.replace(/\.[^.]+$/, "") || "";
|
|
640
|
+
const facts = useMediaFacts({ url: src });
|
|
641
|
+
return /* @__PURE__ */ jsx7("div", { className: "my-6 not-prose", children: /* @__PURE__ */ jsx7(AudioPlayer, { src, title: displayTitle, storageKey: src, coverImage: facts?.cover, captions: facts?.captions, chapters: facts?.chapters }) });
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// ../shared/components/blog/FileAttachmentBlock.tsx
|
|
645
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
646
|
+
function fileAttachmentDownloadUrl(apiBase, websiteId, assetId, name) {
|
|
647
|
+
if (!websiteId) return "";
|
|
648
|
+
const base = `${apiBase ?? ""}/api/public/sites/${encodeURIComponent(websiteId)}/assets/${encodeURIComponent(assetId)}/download`;
|
|
649
|
+
return name ? `${base}?name=${encodeURIComponent(name)}` : base;
|
|
650
|
+
}
|
|
651
|
+
function FileAttachmentBlock({ assetId, name, size, mimeType, apiBase, websiteId }) {
|
|
652
|
+
const facts = useMediaFacts({ assetId });
|
|
653
|
+
const shownName = displayFileName(name, facts);
|
|
654
|
+
return /* @__PURE__ */ jsx8("div", { className: "my-6 not-prose", children: /* @__PURE__ */ jsx8(
|
|
655
|
+
FileDownloadCard,
|
|
656
|
+
{
|
|
657
|
+
name: shownName,
|
|
658
|
+
size: facts?.size ?? size,
|
|
659
|
+
mimeType: facts?.mime ?? mimeType,
|
|
660
|
+
href: fileAttachmentDownloadUrl(apiBase, websiteId, assetId, shownName)
|
|
661
|
+
}
|
|
662
|
+
) });
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// ../shared/components/blog/PdfBlock.tsx
|
|
666
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
667
|
+
function PdfBlock({ src, title, pageCount, thumbnailUrl, assetId, display, apiBase, websiteId }) {
|
|
668
|
+
const facts = useMediaFacts({ url: src, assetId });
|
|
669
|
+
const { protection } = useMediaProtection();
|
|
670
|
+
const fileName = title || src.split("/").pop()?.replace(/\.[^.]+$/, "") || void 0;
|
|
671
|
+
const downloadUrl = assetId && fileAttachmentDownloadUrl(apiBase, websiteId, assetId, fileName) || src;
|
|
672
|
+
return /* @__PURE__ */ jsx9("div", { className: "my-6 not-prose", children: /* @__PURE__ */ jsx9(
|
|
673
|
+
PDFViewer,
|
|
674
|
+
{
|
|
675
|
+
src,
|
|
676
|
+
thumbnailUrl: facts?.cover ?? thumbnailUrl,
|
|
677
|
+
thumbnailAlt: fileName,
|
|
678
|
+
fileName,
|
|
679
|
+
pageCount: facts?.pages ?? pageCount,
|
|
680
|
+
allowDownload: protection.allowDownload,
|
|
681
|
+
downloadUrl,
|
|
682
|
+
variant: display === "card" ? "card" : "preview"
|
|
683
|
+
}
|
|
684
|
+
) });
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// ../shared/components/blog/ToggleBlock.tsx
|
|
688
|
+
import { useState as useState2 } from "react";
|
|
689
|
+
|
|
690
|
+
// ../shared/components/ui/simple-rich-text-renderer.tsx
|
|
691
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
692
|
+
function InlineRichText({ content }) {
|
|
693
|
+
return /* @__PURE__ */ jsx10(RichTextView, { content, profile: "inline" });
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// ../shared/components/blog/ToggleBlock.tsx
|
|
697
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
698
|
+
function ToggleBlock({
|
|
699
|
+
title,
|
|
700
|
+
children,
|
|
701
|
+
defaultOpen = true
|
|
702
|
+
}) {
|
|
703
|
+
const [isOpen, setIsOpen] = useState2(defaultOpen);
|
|
704
|
+
return /* @__PURE__ */ jsxs6("div", { className: "toggle-block my-4", children: [
|
|
705
|
+
/* @__PURE__ */ jsxs6(
|
|
706
|
+
"button",
|
|
707
|
+
{
|
|
708
|
+
type: "button",
|
|
709
|
+
onClick: () => setIsOpen(!isOpen),
|
|
710
|
+
className: "flex items-start gap-1 w-full text-left",
|
|
711
|
+
children: [
|
|
712
|
+
/* @__PURE__ */ jsx11("span", { className: "shrink-0 mt-1 p-0.5 rounded hover:bg-zinc-200/50 dark:hover:bg-zinc-700/50 transition-colors", children: /* @__PURE__ */ jsx11(
|
|
713
|
+
ChevronDown,
|
|
714
|
+
{
|
|
715
|
+
className: `w-4 h-4 text-zinc-400 transition-transform ${isOpen ? "" : "-rotate-90"}`
|
|
716
|
+
}
|
|
717
|
+
) }),
|
|
718
|
+
/* @__PURE__ */ jsx11("span", { className: "flex-1 min-w-0 text-zinc-700 dark:text-zinc-300", children: /* @__PURE__ */ jsx11(InlineRichText, { content: title }) })
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
isOpen && /* @__PURE__ */ jsx11("div", { className: "pl-6 [&>*:last-child]:mb-0", children })
|
|
723
|
+
] });
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// ../shared/components/blog/GalleryBlock.tsx
|
|
727
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
728
|
+
function GalleryBlock({ config }) {
|
|
729
|
+
if (config.items.length === 0) return null;
|
|
730
|
+
return /* @__PURE__ */ jsx12(
|
|
731
|
+
"div",
|
|
732
|
+
{
|
|
733
|
+
className: `my-5 grid items-start gap-3 ${GALLERY_COLS_CLASS[config.cols]}`,
|
|
734
|
+
"data-gallery-cols": config.cols,
|
|
735
|
+
children: config.items.map((item, i) => /* @__PURE__ */ jsx12(
|
|
736
|
+
SiteImage,
|
|
737
|
+
{
|
|
738
|
+
src: item.src,
|
|
739
|
+
responsive: true,
|
|
740
|
+
sizes: `(min-width: 1024px) ${Math.round(60 / config.cols)}vw, (min-width: 640px) ${Math.round(100 / config.cols)}vw, 100vw`,
|
|
741
|
+
alt: item.alt,
|
|
742
|
+
className: "block h-auto w-full rounded-[var(--site-radius-media)]"
|
|
743
|
+
},
|
|
744
|
+
`${item.src}-${i}`
|
|
745
|
+
))
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// ../shared/components/blog/CalloutBlock.tsx
|
|
751
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
752
|
+
var TONE_COLOR = {
|
|
753
|
+
info: "var(--brand-color, #2563eb)",
|
|
754
|
+
tip: "#16a34a",
|
|
755
|
+
warning: "#d97706",
|
|
756
|
+
danger: "#dc2626"
|
|
757
|
+
};
|
|
758
|
+
function CalloutBlock({ tone, title, children }) {
|
|
759
|
+
const style = {
|
|
760
|
+
borderRadius: "var(--site-radius-card, 12px)",
|
|
761
|
+
borderLeft: `4px solid ${TONE_COLOR[tone]}`,
|
|
762
|
+
background: "var(--site-card-bg, color-mix(in srgb, currentColor 6%, transparent))"
|
|
763
|
+
};
|
|
764
|
+
return /* @__PURE__ */ jsxs7("aside", { className: "callout-block my-6 px-5 py-4 [&>*:last-child]:mb-0", "data-callout-tone": tone, style, children: [
|
|
765
|
+
title && /* @__PURE__ */ jsx13("p", { className: "mb-1.5 font-semibold", style: { color: TONE_COLOR[tone] }, children: title }),
|
|
766
|
+
children
|
|
767
|
+
] });
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// ../shared/components/blog/ArticleMarkdown.tsx
|
|
771
|
+
import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
772
|
+
function coalesceFaqSegments(segments) {
|
|
773
|
+
const out = [];
|
|
774
|
+
for (const segment of segments) {
|
|
775
|
+
const prev = out[out.length - 1];
|
|
776
|
+
if (segment.type === "faq" && prev && prev.type === "faq") {
|
|
777
|
+
out[out.length - 1] = {
|
|
778
|
+
type: "faq",
|
|
779
|
+
config: {
|
|
780
|
+
title: prev.config.title,
|
|
781
|
+
items: [...prev.config.items, ...segment.config.items]
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
} else {
|
|
785
|
+
out.push(segment);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return out;
|
|
789
|
+
}
|
|
790
|
+
var HIGHLIGHT_DARK_VARS = `
|
|
791
|
+
--highlight-yellow: rgb(113, 63, 18);
|
|
792
|
+
--highlight-green: rgb(20, 83, 45);
|
|
793
|
+
--highlight-blue: rgb(30, 58, 138);
|
|
794
|
+
--highlight-pink: rgb(131, 24, 67);
|
|
795
|
+
--highlight-orange: rgb(124, 45, 18);
|
|
796
|
+
--highlight-purple: rgb(76, 29, 149);
|
|
797
|
+
`;
|
|
798
|
+
var ARTICLE_HIGHLIGHT_CSS = `
|
|
799
|
+
.article-body {
|
|
800
|
+
--highlight-yellow: rgb(254, 249, 195);
|
|
801
|
+
--highlight-green: rgb(187, 247, 208);
|
|
802
|
+
--highlight-blue: rgb(191, 219, 254);
|
|
803
|
+
--highlight-pink: rgb(251, 207, 232);
|
|
804
|
+
--highlight-orange: rgb(254, 215, 170);
|
|
805
|
+
--highlight-purple: rgb(221, 214, 254);
|
|
806
|
+
}
|
|
807
|
+
/* \u624B\u52D5\u6DF1\u8272\uFF08\u5E33\u865F\u4E3B\u984C\uFF09\u8207\u56FA\u5B9A\u6DF1\u8272\u7AD9\u53F0 */
|
|
808
|
+
.dark .article-body,
|
|
809
|
+
html:has(.site-renderer-root[data-color-scheme="dark"]) .article-body {
|
|
810
|
+
${HIGHLIGHT_DARK_VARS}
|
|
811
|
+
}
|
|
812
|
+
/* \u56FA\u5B9A\u6DFA\u8272\u7AD9\u53F0\uFF1A\u5F37\u5236\u6DFA\u8272\u8B8A\u6578\uFF0C\u58D3\u904E\u5916\u5C64 html.dark */
|
|
813
|
+
html:has(.site-renderer-root[data-color-scheme="light"]) .article-body {
|
|
814
|
+
--highlight-yellow: rgb(254, 249, 195);
|
|
815
|
+
--highlight-green: rgb(187, 247, 208);
|
|
816
|
+
--highlight-blue: rgb(191, 219, 254);
|
|
817
|
+
--highlight-pink: rgb(251, 207, 232);
|
|
818
|
+
--highlight-orange: rgb(254, 215, 170);
|
|
819
|
+
--highlight-purple: rgb(221, 214, 254);
|
|
820
|
+
}
|
|
821
|
+
@media (prefers-color-scheme: dark) {
|
|
822
|
+
/* \u7CFB\u7D71\u8DDF\u96A8\uFF1A\u6392\u9664\u56FA\u5B9A\u6DFA\u8272\u7AD9\u53F0 */
|
|
823
|
+
html.system:not(:has(.site-renderer-root[data-color-scheme="light"])) .article-body {
|
|
824
|
+
${HIGHLIGHT_DARK_VARS}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
`;
|
|
828
|
+
var ARTICLE_TABLE_CSS = `
|
|
829
|
+
.article-body table {
|
|
830
|
+
border-collapse: separate;
|
|
831
|
+
border-spacing: 0;
|
|
832
|
+
width: 100%;
|
|
833
|
+
table-layout: auto;
|
|
834
|
+
margin: 1.5rem 0;
|
|
835
|
+
border: 1px solid rgb(228 228 231);
|
|
836
|
+
border-radius: var(--site-radius-xl, 12px);
|
|
837
|
+
overflow: hidden;
|
|
838
|
+
}
|
|
839
|
+
.dark .article-body table { border-color: rgb(63 63 70); }
|
|
840
|
+
.article-body thead, .article-body tbody tr { border: 0; }
|
|
841
|
+
.article-body th, .article-body td {
|
|
842
|
+
border-right: 1px solid rgb(228 228 231);
|
|
843
|
+
border-bottom: 1px solid rgb(228 228 231);
|
|
844
|
+
padding: 0.5rem 0.75rem;
|
|
845
|
+
text-align: left;
|
|
846
|
+
vertical-align: top;
|
|
847
|
+
min-width: 4rem;
|
|
848
|
+
font-size: 0.95rem;
|
|
849
|
+
line-height: 1.6;
|
|
850
|
+
}
|
|
851
|
+
.dark .article-body th, .dark .article-body td {
|
|
852
|
+
border-right-color: rgb(63 63 70);
|
|
853
|
+
border-bottom-color: rgb(63 63 70);
|
|
854
|
+
}
|
|
855
|
+
.article-body th {
|
|
856
|
+
font-weight: inherit;
|
|
857
|
+
background: rgb(244 244 245);
|
|
858
|
+
color: rgb(24 24 27);
|
|
859
|
+
}
|
|
860
|
+
.dark .article-body th {
|
|
861
|
+
background: rgb(39 39 42);
|
|
862
|
+
color: rgb(244 244 245);
|
|
863
|
+
}
|
|
864
|
+
.article-body th:last-child, .article-body td:last-child { border-right: 0; }
|
|
865
|
+
.article-body tr:last-child td, .article-body tr:last-child th { border-bottom: 0; }
|
|
866
|
+
/* \u56DB\u89D2 cell \u660E\u78BA\u5E36\u5713\u89D2\uFF0C\u9632\u6B62 overflow:hidden \u5728 table \u4E0A\u4E0D\u53EF\u9760\u6642\u80CC\u666F\u6EA2\u51FA\u3002
|
|
867
|
+
top corners \u5339\u914D th/td\uFF1Bbottom corners \u50C5\u5339\u914D td\uFF0C\u907F\u514D thead \u5217\u8AA4\u5957\u7528\u3002 */
|
|
868
|
+
.article-body tr:first-child th:first-child, .article-body tr:first-child td:first-child { border-top-left-radius: calc(var(--site-radius-xl, 12px) - 1px); }
|
|
869
|
+
.article-body tr:first-child th:last-child, .article-body tr:first-child td:last-child { border-top-right-radius: calc(var(--site-radius-xl, 12px) - 1px); }
|
|
870
|
+
.article-body tr:last-child td:first-child { border-bottom-left-radius: calc(var(--site-radius-xl, 12px) - 1px); }
|
|
871
|
+
.article-body tr:last-child td:last-child { border-bottom-right-radius: calc(var(--site-radius-xl, 12px) - 1px); }
|
|
872
|
+
/* \u7A7A\u767D\u5132\u5B58\u683C\u4ECD\u7DAD\u6301\u4E00\u884C\u9AD8\u5EA6\uFF08\u5C0D\u9F4A\u7DE8\u8F2F\u5668\u7A7A\u6BB5\u843D\uFF0C\u907F\u514D\u5217\u9AD8\u584C\u9677\uFF09 */
|
|
873
|
+
.article-body th:empty::after, .article-body td:empty::after {
|
|
874
|
+
content: "\\00a0";
|
|
875
|
+
}
|
|
876
|
+
/* \u5340\u584A\u7A0B\u5F0F\u78BC\u5167\u7684 <code> \u5DF2\u7531 <pre> \u63D0\u4F9B\u5E95\u8272\uFF0C\u79FB\u9664 inline code \u7684\u91CD\u8907\u6A23\u5F0F */
|
|
877
|
+
.article-body pre code {
|
|
878
|
+
background: transparent;
|
|
879
|
+
padding: 0;
|
|
880
|
+
border-radius: 0;
|
|
881
|
+
font-size: inherit;
|
|
882
|
+
}
|
|
883
|
+
/* \u7A7A\u767D\u7A0B\u5F0F\u78BC\u5340\u584A\u4ECD\u7DAD\u6301\u4E00\u884C\u9AD8\u5EA6 */
|
|
884
|
+
.article-body pre:empty::after, .article-body pre code:empty::after {
|
|
885
|
+
content: "\\00a0";
|
|
886
|
+
}
|
|
887
|
+
`;
|
|
888
|
+
function ArticleMarkdown({ content, ctaPresets, apiBase, websiteId }) {
|
|
889
|
+
const segments = coalesceFaqSegments(parseArticleSegments(content));
|
|
890
|
+
const assignId = createHeadingIdAssigner();
|
|
891
|
+
return /* @__PURE__ */ jsxs8(Fragment5, { children: [
|
|
892
|
+
/* @__PURE__ */ jsx14(
|
|
893
|
+
"style",
|
|
894
|
+
{
|
|
895
|
+
dangerouslySetInnerHTML: {
|
|
896
|
+
__html: `${ARTICLE_HIGHLIGHT_CSS}${ARTICLE_TABLE_CSS}`
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
),
|
|
900
|
+
/* @__PURE__ */ jsx14("div", { className: "article-body max-w-none [&>*:first-child]:mt-0 [&>*:first-child>*:first-child]:mt-0", children: segments.map((segment, i) => {
|
|
901
|
+
if (segment.type === "cta") {
|
|
902
|
+
return /* @__PURE__ */ jsx14(
|
|
903
|
+
UserCtaShortcodeBlock,
|
|
904
|
+
{
|
|
905
|
+
config: segment.config,
|
|
906
|
+
presets: ctaPresets
|
|
907
|
+
},
|
|
908
|
+
i
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
if (segment.type === "faq") {
|
|
912
|
+
return /* @__PURE__ */ jsx14(UserFaqShortcodeBlock, { config: segment.config }, i);
|
|
913
|
+
}
|
|
914
|
+
if (segment.type === "embed") {
|
|
915
|
+
return /* @__PURE__ */ jsx14(
|
|
916
|
+
EmbedBlock,
|
|
917
|
+
{
|
|
918
|
+
url: segment.config.url,
|
|
919
|
+
embedType: segment.config.embedType
|
|
920
|
+
},
|
|
921
|
+
i
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
if (segment.type === "audio") {
|
|
925
|
+
return /* @__PURE__ */ jsx14(
|
|
926
|
+
AudioBlock,
|
|
927
|
+
{
|
|
928
|
+
src: segment.config.src,
|
|
929
|
+
title: segment.config.title
|
|
930
|
+
},
|
|
931
|
+
i
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
if (segment.type === "pdf") {
|
|
935
|
+
return /* @__PURE__ */ jsx14(
|
|
936
|
+
PdfBlock,
|
|
937
|
+
{
|
|
938
|
+
src: segment.config.src,
|
|
939
|
+
title: segment.config.title,
|
|
940
|
+
pageCount: segment.config.pageCount,
|
|
941
|
+
thumbnailUrl: segment.config.thumbnailUrl,
|
|
942
|
+
assetId: segment.config.assetId,
|
|
943
|
+
display: segment.config.display,
|
|
944
|
+
apiBase,
|
|
945
|
+
websiteId
|
|
946
|
+
},
|
|
947
|
+
i
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
if (segment.type === "file") {
|
|
951
|
+
return /* @__PURE__ */ jsx14(
|
|
952
|
+
FileAttachmentBlock,
|
|
953
|
+
{
|
|
954
|
+
assetId: segment.config.assetId,
|
|
955
|
+
name: segment.config.name,
|
|
956
|
+
size: segment.config.size,
|
|
957
|
+
mimeType: segment.config.mimeType,
|
|
958
|
+
apiBase,
|
|
959
|
+
websiteId
|
|
960
|
+
},
|
|
961
|
+
i
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
if (segment.type === "gallery") {
|
|
965
|
+
return /* @__PURE__ */ jsx14(GalleryBlock, { config: segment.config }, i);
|
|
966
|
+
}
|
|
967
|
+
if (segment.type === "toggle") {
|
|
968
|
+
return /* @__PURE__ */ jsx14(ToggleBlock, { title: segment.config.title, children: renderArticleRichText(segment.config.content, assignId) }, i);
|
|
969
|
+
}
|
|
970
|
+
if (segment.type === "callout") {
|
|
971
|
+
return /* @__PURE__ */ jsx14(CalloutBlock, { tone: segment.config.tone, title: segment.config.title, children: renderArticleRichText(segment.config.content, assignId) }, i);
|
|
972
|
+
}
|
|
973
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: renderArticleRichText(segment.value, assignId) }, i);
|
|
974
|
+
}) })
|
|
975
|
+
] });
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// ../shared/deliverables/settings.ts
|
|
979
|
+
import { z } from "zod";
|
|
980
|
+
var DELIVERABLE_EMBED_PROVIDERS = ["youtube", "vimeo", "loom"];
|
|
981
|
+
var deliverableEmbedSchema = z.object({
|
|
982
|
+
provider: z.enum(DELIVERABLE_EMBED_PROVIDERS),
|
|
983
|
+
/** 供應商端 id(YouTube video id、Vimeo id、Loom share id) */
|
|
984
|
+
id: z.string().trim().min(1).max(128)
|
|
985
|
+
});
|
|
986
|
+
var certificateSettingsSchema = z.object({
|
|
987
|
+
enabled: z.boolean().default(false),
|
|
988
|
+
/** 證書名稱;空=依網站語系的「結業證書」 */
|
|
989
|
+
title: z.string().trim().max(120).nullable().default(null),
|
|
990
|
+
/** 簽署人姓名或機構;空=不印簽名列 */
|
|
991
|
+
signatureName: z.string().trim().max(80).nullable().default(null),
|
|
992
|
+
/** 簽署人頭銜(例如「主講講師」),印在姓名下方 */
|
|
993
|
+
signatureTitle: z.string().trim().max(80).nullable().default(null),
|
|
994
|
+
/** 簽名圖:公開圖片的媒體帳本列 id(同封面),印在簽名線上方 */
|
|
995
|
+
signatureAssetId: z.string().trim().min(1).nullable().default(null),
|
|
996
|
+
/** 印網站的品牌標誌(Website.brandSettings.logo);標誌是圖示而非圖片時不印 */
|
|
997
|
+
showLogo: z.boolean().default(true),
|
|
998
|
+
/** 一行補充說明(例如課程時數),印在課程名稱下方 */
|
|
999
|
+
note: z.string().trim().max(160).nullable().default(null),
|
|
1000
|
+
/**
|
|
1001
|
+
* 背景圖:公開圖片的媒體帳本列 id(同封面),依 A4 橫式置中裁切鋪滿整頁;有背景圖時不畫預設外框
|
|
1002
|
+
* (對照 Kajabi、Thinkific 新版:品牌設計在外部工具做好再上傳,文字版位固定)
|
|
1003
|
+
*/
|
|
1004
|
+
backgroundAssetId: z.string().trim().min(1).nullable().default(null),
|
|
1005
|
+
/** 背景圖上覆蓋一層半透明白色,讓文字在色彩豐富的背景上清楚(Kajabi 的白色遮罩);沒有背景圖時無作用 */
|
|
1006
|
+
backgroundOverlay: z.boolean().default(false)
|
|
1007
|
+
});
|
|
1008
|
+
var DEFAULT_CERTIFICATE_SETTINGS = {
|
|
1009
|
+
enabled: false,
|
|
1010
|
+
title: null,
|
|
1011
|
+
signatureName: null,
|
|
1012
|
+
signatureTitle: null,
|
|
1013
|
+
signatureAssetId: null,
|
|
1014
|
+
showLogo: true,
|
|
1015
|
+
note: null,
|
|
1016
|
+
backgroundAssetId: null,
|
|
1017
|
+
backgroundOverlay: false
|
|
1018
|
+
};
|
|
1019
|
+
var completionRuleSchema = z.discriminatedUnion("type", [
|
|
1020
|
+
z.object({ type: z.literal("all_units") }),
|
|
1021
|
+
z.object({ type: z.literal("percent"), percent: z.number().int().min(1).max(100) }),
|
|
1022
|
+
z.object({ type: z.literal("quiz_passed"), unitId: z.string().trim().min(1) })
|
|
1023
|
+
]);
|
|
1024
|
+
var deliverableSettingsSchema = z.object({
|
|
1025
|
+
completionRule: completionRuleSchema.default({ type: "all_units" }),
|
|
1026
|
+
/**
|
|
1027
|
+
* 結業證書:PDF 在學員下載時才產生,永遠照目前的設定與網站品牌;只有序號與發證日在發證當天固定
|
|
1028
|
+
* (對照 Accredible、Certifier:改設計全部跟著變)。品牌標誌與主色不另存,沿用網站設定。
|
|
1029
|
+
*/
|
|
1030
|
+
certificate: certificateSettingsSchema.default(DEFAULT_CERTIFICATE_SETTINGS),
|
|
1031
|
+
comments: z.object({
|
|
1032
|
+
enabled: z.boolean().default(false),
|
|
1033
|
+
threaded: z.boolean().default(true),
|
|
1034
|
+
requireReview: z.boolean().default(true),
|
|
1035
|
+
reactions: z.boolean().default(false)
|
|
1036
|
+
}).default({ enabled: false, threaded: true, requireReview: true, reactions: false }),
|
|
1037
|
+
/** 要求依序完成單元(對照 Whop require_completing_lessons_in_order) */
|
|
1038
|
+
requireSequential: z.boolean().default(false),
|
|
1039
|
+
/**
|
|
1040
|
+
* 影音單元看過幾成算完成(課程層可調;對照 Thinkific 課程層百分比)。分子是看過的段落聯集,不是最遠位置,
|
|
1041
|
+
* 快轉到結尾不算;100 含結尾 2 秒容差。沒有段落資料的自建播放器退回最遠位置比例。
|
|
1042
|
+
*/
|
|
1043
|
+
mediaCompletionPercent: z.number().int().min(50).max(100).multipleOf(5).default(90)
|
|
1044
|
+
});
|
|
1045
|
+
var DEFAULT_DELIVERABLE_SETTINGS = deliverableSettingsSchema.parse({});
|
|
1046
|
+
var DELIVERABLE_UNIT_BODY_MAX_BYTES = 512 * 1024;
|
|
1047
|
+
var featureKeySchema = z.string().trim().min(1).max(80).regex(/^[a-z0-9][a-z0-9-]*$/, "\u7279\u6027\u9375\u53EA\u80FD\u662F\u5C0F\u5BEB\u82F1\u6578\u8207\u9023\u5B57\u865F");
|
|
1048
|
+
function computeSequenceLocks(input) {
|
|
1049
|
+
const locks = /* @__PURE__ */ new Map();
|
|
1050
|
+
let gate = null;
|
|
1051
|
+
for (const leaf of input.leaves) {
|
|
1052
|
+
const counts = leaf.countsTowardCompletion !== false;
|
|
1053
|
+
if (gate && counts && !leaf.isPreview) locks.set(leaf.id, gate);
|
|
1054
|
+
if (gate || !counts || input.completedUnitIds.has(leaf.id)) continue;
|
|
1055
|
+
if (input.requireSequential || leaf.isPrerequisite) gate = leaf.id;
|
|
1056
|
+
}
|
|
1057
|
+
return locks;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// ../shared/deliverables/wire.ts
|
|
1061
|
+
function groupUnits(units) {
|
|
1062
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
1063
|
+
for (const u of units) {
|
|
1064
|
+
const list = byParent.get(u.parentId) ?? [];
|
|
1065
|
+
list.push(u);
|
|
1066
|
+
byParent.set(u.parentId, list);
|
|
1067
|
+
}
|
|
1068
|
+
const sort = (list) => [...list].sort((a, b) => a.order - b.order);
|
|
1069
|
+
const top = sort(byParent.get(null) ?? []);
|
|
1070
|
+
const groups = [];
|
|
1071
|
+
const loose = [];
|
|
1072
|
+
for (const t of top) {
|
|
1073
|
+
const children = byParent.get(t.id);
|
|
1074
|
+
if (children && children.length > 0) groups.push({ chapter: t, units: sort(children) });
|
|
1075
|
+
else if (t.kind !== "chapter") loose.push(t);
|
|
1076
|
+
else groups.push({ chapter: t, units: [] });
|
|
1077
|
+
}
|
|
1078
|
+
if (loose.length > 0) groups.unshift({ chapter: null, units: loose });
|
|
1079
|
+
return groups;
|
|
1080
|
+
}
|
|
1081
|
+
function orderedLeafUnits(units) {
|
|
1082
|
+
return groupUnits(units).flatMap((g) => g.units);
|
|
1083
|
+
}
|
|
1084
|
+
function pickResumeUnit(units) {
|
|
1085
|
+
const leaves = orderedLeafUnits(units);
|
|
1086
|
+
return leaves.find((u) => u.access.granted && u.progress !== "completed") ?? leaves.find((u) => u.access.granted) ?? null;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
// ../shared/components/deliverables/DeliverablePlayer.tsx
|
|
1090
|
+
import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1091
|
+
var AUTOPLAY_STORAGE_KEY = "kanorio:autoplay-next";
|
|
1092
|
+
var TRANSCRIPT_STORAGE_KEY = "kanorio:transcript-open";
|
|
1093
|
+
function captionTracksOf(renditions) {
|
|
1094
|
+
const tracks = (renditions ?? []).flatMap((r) => r.kind === "captions" && r.locale ? [{ locale: r.locale, url: r.url, source: r.source ?? "ai", edited: r.edited ?? false }] : []);
|
|
1095
|
+
return tracks.length > 0 ? tracks : void 0;
|
|
1096
|
+
}
|
|
1097
|
+
function fill2(template, vars) {
|
|
1098
|
+
return template.replace(/\{(\w+)\}/g, (_, k) => String(vars[k] ?? ""));
|
|
1099
|
+
}
|
|
1100
|
+
function formatDateTime(iso, locale, timeZone) {
|
|
1101
|
+
try {
|
|
1102
|
+
return new Intl.DateTimeFormat(locale ?? void 0, { dateStyle: "medium", timeStyle: "short", timeZone: timeZone ?? void 0 }).format(new Date(iso));
|
|
1103
|
+
} catch {
|
|
1104
|
+
return iso;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function formatDate(iso, locale, timeZone) {
|
|
1108
|
+
try {
|
|
1109
|
+
return new Intl.DateTimeFormat(locale ?? void 0, { dateStyle: "medium", timeZone: timeZone ?? void 0 }).format(new Date(iso));
|
|
1110
|
+
} catch {
|
|
1111
|
+
return iso;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
function stripLeadingTitle(markdown, title) {
|
|
1115
|
+
const match = /^\s*#\s+(.+?)\s*(?:\n|$)/.exec(markdown);
|
|
1116
|
+
if (match && title && match[1].trim() === title.trim()) return markdown.slice(match[0].length);
|
|
1117
|
+
return markdown;
|
|
1118
|
+
}
|
|
1119
|
+
var SURFACE2 = "bg-[var(--site-surface,#ffffff)] dark:bg-zinc-900";
|
|
1120
|
+
var BORDER2 = "border-[var(--site-border,rgba(0,0,0,0.1))]";
|
|
1121
|
+
var MUTED2 = "text-[var(--site-fg-muted,#71717a)]";
|
|
1122
|
+
var FG2 = "text-[var(--site-fg,#18181b)]";
|
|
1123
|
+
var SECONDARY_BUTTON = `inline-flex min-h-11 items-center justify-center gap-1.5 rounded-[var(--site-radius-button,0.5rem)] border border-[var(--site-border,rgba(0,0,0,0.15))] px-3.5 text-sm ${FG2} disabled:opacity-40`;
|
|
1124
|
+
var PRIMARY_BUTTON = "inline-flex min-h-11 items-center justify-center gap-1.5 rounded-[var(--site-radius-button,0.5rem)] px-4 text-sm font-medium text-[var(--brand-foreground,#ffffff)] disabled:opacity-40";
|
|
1125
|
+
var ICON_BUTTON = `inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-[var(--site-radius-button,0.5rem)] ${MUTED2} hover:bg-black/5 dark:hover:bg-white/10`;
|
|
1126
|
+
function embedSrc(embed) {
|
|
1127
|
+
const id = encodeURIComponent(embed.id);
|
|
1128
|
+
switch (embed.provider) {
|
|
1129
|
+
case "youtube":
|
|
1130
|
+
return `https://www.youtube-nocookie.com/embed/${id}`;
|
|
1131
|
+
case "vimeo":
|
|
1132
|
+
return `https://player.vimeo.com/video/${id}`;
|
|
1133
|
+
case "loom":
|
|
1134
|
+
return `https://www.loom.com/embed/${id}`;
|
|
1135
|
+
default:
|
|
1136
|
+
return null;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
var REPORT_INTERVAL_MS = 2e4;
|
|
1140
|
+
var RUN_BREAK_SECONDS = 2.5;
|
|
1141
|
+
var PlaybackTracker = class {
|
|
1142
|
+
sessionId;
|
|
1143
|
+
runStart = null;
|
|
1144
|
+
lastTime = 0;
|
|
1145
|
+
rate = 1;
|
|
1146
|
+
pending = [];
|
|
1147
|
+
seekTargets = [];
|
|
1148
|
+
stallStartedAt = null;
|
|
1149
|
+
stallCount = 0;
|
|
1150
|
+
stallMs = 0;
|
|
1151
|
+
startupMs = null;
|
|
1152
|
+
startupSent = false;
|
|
1153
|
+
playRequestedAt = null;
|
|
1154
|
+
rendition = null;
|
|
1155
|
+
renditionSent = null;
|
|
1156
|
+
duration = 0;
|
|
1157
|
+
constructor() {
|
|
1158
|
+
this.sessionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `s_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
|
|
1159
|
+
}
|
|
1160
|
+
get position() {
|
|
1161
|
+
return this.lastTime;
|
|
1162
|
+
}
|
|
1163
|
+
closeRun() {
|
|
1164
|
+
if (this.runStart !== null && this.lastTime - this.runStart >= 0.2) this.pending.push([this.runStart, this.lastTime, this.rate]);
|
|
1165
|
+
this.runStart = null;
|
|
1166
|
+
}
|
|
1167
|
+
timeUpdate(time, duration) {
|
|
1168
|
+
if (duration > 0) this.duration = duration;
|
|
1169
|
+
if (this.runStart === null) {
|
|
1170
|
+
this.runStart = time;
|
|
1171
|
+
} else if (Math.abs(time - this.lastTime) > RUN_BREAK_SECONDS) {
|
|
1172
|
+
this.closeRun();
|
|
1173
|
+
this.runStart = time;
|
|
1174
|
+
}
|
|
1175
|
+
this.lastTime = time;
|
|
1176
|
+
}
|
|
1177
|
+
event(e) {
|
|
1178
|
+
switch (e.type) {
|
|
1179
|
+
case "play":
|
|
1180
|
+
if (this.playRequestedAt === null && this.startupMs === null) this.playRequestedAt = Date.now();
|
|
1181
|
+
break;
|
|
1182
|
+
case "started":
|
|
1183
|
+
if (this.playRequestedAt !== null && this.startupMs === null) this.startupMs = Date.now() - this.playRequestedAt;
|
|
1184
|
+
break;
|
|
1185
|
+
case "pause":
|
|
1186
|
+
case "ended":
|
|
1187
|
+
this.closeRun();
|
|
1188
|
+
this.lastTime = e.time;
|
|
1189
|
+
break;
|
|
1190
|
+
case "seeked":
|
|
1191
|
+
this.closeRun();
|
|
1192
|
+
this.seekTargets.push(Math.floor(e.time));
|
|
1193
|
+
this.lastTime = e.time;
|
|
1194
|
+
this.runStart = null;
|
|
1195
|
+
break;
|
|
1196
|
+
case "ratechange":
|
|
1197
|
+
this.closeRun();
|
|
1198
|
+
this.rate = e.rate > 0 ? e.rate : 1;
|
|
1199
|
+
break;
|
|
1200
|
+
case "waiting":
|
|
1201
|
+
if (this.stallStartedAt === null) this.stallStartedAt = Date.now();
|
|
1202
|
+
break;
|
|
1203
|
+
case "playing":
|
|
1204
|
+
if (this.stallStartedAt !== null) {
|
|
1205
|
+
const ms = Date.now() - this.stallStartedAt;
|
|
1206
|
+
this.stallStartedAt = null;
|
|
1207
|
+
if (this.startupMs !== null || this.playRequestedAt === null) {
|
|
1208
|
+
this.stallCount += 1;
|
|
1209
|
+
this.stallMs += ms;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
break;
|
|
1213
|
+
case "quality":
|
|
1214
|
+
if (e.height) this.rendition = this.rendition === null ? e.height : Math.min(this.rendition, e.height);
|
|
1215
|
+
break;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
/** 取出這次要送的內容(送完清空);`final` 時連進行中的段一起收 */
|
|
1219
|
+
flush(final) {
|
|
1220
|
+
if (final) this.closeRun();
|
|
1221
|
+
else if (this.runStart !== null && this.lastTime - this.runStart >= 0.2) {
|
|
1222
|
+
this.pending.push([this.runStart, this.lastTime, this.rate]);
|
|
1223
|
+
this.runStart = this.lastTime;
|
|
1224
|
+
}
|
|
1225
|
+
const hasStats = this.stallCount > 0 || this.startupMs !== null && !this.startupSent || this.rendition !== null && this.rendition !== this.renditionSent;
|
|
1226
|
+
if (this.pending.length === 0 && this.seekTargets.length === 0 && !hasStats) return null;
|
|
1227
|
+
const item = {
|
|
1228
|
+
sessionId: this.sessionId,
|
|
1229
|
+
segments: this.pending,
|
|
1230
|
+
positionSeconds: this.lastTime,
|
|
1231
|
+
...this.duration > 0 ? { durationSeconds: this.duration } : {},
|
|
1232
|
+
...this.seekTargets.length ? { seekTargets: this.seekTargets } : {},
|
|
1233
|
+
...this.stallCount > 0 ? { stallCount: this.stallCount, stallMs: this.stallMs } : {},
|
|
1234
|
+
...this.startupMs !== null && !this.startupSent ? { startupMs: this.startupMs } : {},
|
|
1235
|
+
...this.rendition !== null && this.rendition !== this.renditionSent ? { rendition: this.rendition } : {},
|
|
1236
|
+
device: classifyDevice({ width: typeof window !== "undefined" ? window.innerWidth : 1280, coarsePointer: typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(pointer: coarse)").matches : false })
|
|
1237
|
+
};
|
|
1238
|
+
this.pending = [];
|
|
1239
|
+
this.seekTargets = [];
|
|
1240
|
+
this.stallCount = 0;
|
|
1241
|
+
this.stallMs = 0;
|
|
1242
|
+
if (this.startupMs !== null) this.startupSent = true;
|
|
1243
|
+
if (this.rendition !== null) this.renditionSent = this.rendition;
|
|
1244
|
+
return item;
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
function DeliverablePlayer({ tree, client, labels, locale, timeZone, initialUnitId, onUnitChange, layout = "embedded", backHref, backLabel, className, captionLocale, onCaptionChange }) {
|
|
1248
|
+
const page = layout === "page";
|
|
1249
|
+
const HeaderTag = page ? "header" : "div";
|
|
1250
|
+
const MainTag = page ? "main" : "div";
|
|
1251
|
+
const AsideTag = page ? "aside" : "div";
|
|
1252
|
+
const NavTag = page ? "nav" : "div";
|
|
1253
|
+
const isDownloadPack = tree.structure === "DOWNLOAD";
|
|
1254
|
+
const groups = useMemo2(() => groupUnits(tree.units), [tree.units]);
|
|
1255
|
+
const leaves = useMemo2(() => groups.flatMap((g) => g.units), [groups]);
|
|
1256
|
+
const [progressByUnit, setProgressByUnit] = useState3(
|
|
1257
|
+
() => Object.fromEntries(tree.units.map((u) => [u.id, u.progress]))
|
|
1258
|
+
);
|
|
1259
|
+
const [deliverableProgress, setDeliverableProgress] = useState3(tree.progress);
|
|
1260
|
+
const [currentId, setCurrentId] = useState3(() => {
|
|
1261
|
+
const requested = initialUnitId ? tree.units.find((u) => u.id === initialUnitId) : null;
|
|
1262
|
+
return (requested ?? pickResumeUnit(tree.units))?.id ?? null;
|
|
1263
|
+
});
|
|
1264
|
+
const current = leaves.find((u) => u.id === currentId) ?? null;
|
|
1265
|
+
const currentIndex = current ? leaves.findIndex((u) => u.id === current.id) : -1;
|
|
1266
|
+
const [resumeId] = useState3(() => tree.units.some((u) => u.progress !== "not_started") ? pickResumeUnit(tree.units)?.id ?? null : null);
|
|
1267
|
+
const [sidebarOpen, setSidebarOpen] = useState3(true);
|
|
1268
|
+
const [drawerOpen, setDrawerOpen] = useState3(false);
|
|
1269
|
+
const [collapsedChapters, setCollapsedChapters] = useState3(() => /* @__PURE__ */ new Set());
|
|
1270
|
+
const [settingsOpen, setSettingsOpen] = useState3(false);
|
|
1271
|
+
const [retryTick, setRetryTick] = useState3(0);
|
|
1272
|
+
const [attachmentBusy, setAttachmentBusy] = useState3(null);
|
|
1273
|
+
const [attachmentFailed, setAttachmentFailed] = useState3(false);
|
|
1274
|
+
const completedIds = useMemo2(
|
|
1275
|
+
() => new Set(Object.entries(progressByUnit).filter(([, status]) => status === "completed").map(([id]) => id)),
|
|
1276
|
+
[progressByUnit]
|
|
1277
|
+
);
|
|
1278
|
+
const locks = useMemo2(
|
|
1279
|
+
() => computeSequenceLocks({
|
|
1280
|
+
leaves: leaves.map((u) => ({ id: u.id, isPreview: u.isPreview, countsTowardCompletion: u.countsTowardCompletion, isPrerequisite: u.isPrerequisite })),
|
|
1281
|
+
completedUnitIds: completedIds,
|
|
1282
|
+
requireSequential: Boolean(tree.settings?.requireSequential)
|
|
1283
|
+
}),
|
|
1284
|
+
[leaves, completedIds, tree.settings?.requireSequential]
|
|
1285
|
+
);
|
|
1286
|
+
const isGranted = useCallback((u) => u.access.granted || u.access.reason === "prerequisite" && !locks.has(u.id), [locks]);
|
|
1287
|
+
const lockedByTitle = (u) => leaves.find((x) => x.id === (locks.get(u.id) ?? u.access.lockedByUnitId))?.title || "";
|
|
1288
|
+
const [opened, setOpened] = useState3(null);
|
|
1289
|
+
const [openError, setOpenError] = useState3(null);
|
|
1290
|
+
const [loading, setLoading] = useState3(false);
|
|
1291
|
+
const [transcriptOpen, setTranscriptOpen] = useState3(false);
|
|
1292
|
+
useEffect2(() => {
|
|
1293
|
+
try {
|
|
1294
|
+
setTranscriptOpen(window.localStorage.getItem(TRANSCRIPT_STORAGE_KEY) === "1");
|
|
1295
|
+
} catch {
|
|
1296
|
+
}
|
|
1297
|
+
}, []);
|
|
1298
|
+
const toggleTranscript = (next2) => {
|
|
1299
|
+
setTranscriptOpen(next2);
|
|
1300
|
+
try {
|
|
1301
|
+
window.localStorage.setItem(TRANSCRIPT_STORAGE_KEY, next2 ? "1" : "0");
|
|
1302
|
+
} catch {
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
const [transcriptLocale, setTranscriptLocale] = useState3(null);
|
|
1306
|
+
const [transcript, setTranscript] = useState3({ unitId: "", status: "loading", data: null });
|
|
1307
|
+
const [transcriptTick, setTranscriptTick] = useState3(0);
|
|
1308
|
+
const [activeSegment, setActiveSegment] = useState3(-1);
|
|
1309
|
+
const [seekTo, setSeekTo] = useState3(null);
|
|
1310
|
+
const transcriptSegmentsRef = useRef2([]);
|
|
1311
|
+
transcriptSegmentsRef.current = transcript.status === "ready" && transcript.data && transcript.unitId === currentId ? transcript.data.segments : [];
|
|
1312
|
+
const transcriptAvailable = Boolean(current && (current.kind === "video" || current.kind === "audio") && opened && client.getTranscript);
|
|
1313
|
+
useEffect2(() => {
|
|
1314
|
+
if (!transcriptAvailable || !current || !client.getTranscript) return;
|
|
1315
|
+
let cancelled = false;
|
|
1316
|
+
const unitId = current.id;
|
|
1317
|
+
setTranscript({ unitId, status: "loading", data: null });
|
|
1318
|
+
setActiveSegment(-1);
|
|
1319
|
+
const wanted = transcriptLocale ?? captionLocale ?? locale ?? null;
|
|
1320
|
+
client.getTranscript(unitId, wanted).then((res) => {
|
|
1321
|
+
if (cancelled) return;
|
|
1322
|
+
if (res.ok) setTranscript({ unitId, status: "ready", data: res });
|
|
1323
|
+
else setTranscript({ unitId, status: res.code === "NO_TRANSCRIPT" || res.code === "NO_FILE" ? "unavailable" : "error", data: null });
|
|
1324
|
+
}).catch(() => {
|
|
1325
|
+
if (!cancelled) setTranscript({ unitId, status: "error", data: null });
|
|
1326
|
+
});
|
|
1327
|
+
return () => {
|
|
1328
|
+
cancelled = true;
|
|
1329
|
+
};
|
|
1330
|
+
}, [transcriptAvailable, current?.id, transcriptLocale, transcriptTick]);
|
|
1331
|
+
const transcriptForCurrent = current && transcript.unitId === current.id ? transcript : null;
|
|
1332
|
+
const showTranscriptPanel = transcriptAvailable && transcriptForCurrent !== null && (transcriptForCurrent.status === "ready" || transcriptForCurrent.status === "error");
|
|
1333
|
+
useEffect2(() => setTranscriptLocale(null), [currentId]);
|
|
1334
|
+
const [quizAnswers, setQuizAnswers] = useState3({});
|
|
1335
|
+
const [quizResult, setQuizResult] = useState3(null);
|
|
1336
|
+
const [quizBusy, setQuizBusy] = useState3(false);
|
|
1337
|
+
useEffect2(() => {
|
|
1338
|
+
setQuizAnswers({});
|
|
1339
|
+
setQuizResult(null);
|
|
1340
|
+
}, [currentId]);
|
|
1341
|
+
const [autoplayNext, setAutoplayNext] = useState3(false);
|
|
1342
|
+
useEffect2(() => {
|
|
1343
|
+
try {
|
|
1344
|
+
setAutoplayNext(window.localStorage.getItem(AUTOPLAY_STORAGE_KEY) === "1");
|
|
1345
|
+
} catch {
|
|
1346
|
+
}
|
|
1347
|
+
}, []);
|
|
1348
|
+
const toggleAutoplay = (next2) => {
|
|
1349
|
+
setAutoplayNext(next2);
|
|
1350
|
+
try {
|
|
1351
|
+
window.localStorage.setItem(AUTOPLAY_STORAGE_KEY, next2 ? "1" : "0");
|
|
1352
|
+
} catch {
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
const [certificate, setCertificate] = useState3(tree.certificate ?? null);
|
|
1356
|
+
const [certificateBusy, setCertificateBusy] = useState3(false);
|
|
1357
|
+
const downloadCertificate = async () => {
|
|
1358
|
+
setCertificateBusy(true);
|
|
1359
|
+
try {
|
|
1360
|
+
const res = await client.getCertificate(tree.id);
|
|
1361
|
+
if (res.ok) {
|
|
1362
|
+
setCertificate((prev) => ({ enabled: true, serial: res.certificate.serial, issuedAt: res.certificate.issuedAt, ...prev ? {} : {} }));
|
|
1363
|
+
window.open(res.certificate.url, "_blank", "noopener,noreferrer");
|
|
1364
|
+
}
|
|
1365
|
+
} finally {
|
|
1366
|
+
setCertificateBusy(false);
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
const lastReportAt = useRef2(0);
|
|
1370
|
+
const trackerRef = useRef2(null);
|
|
1371
|
+
const trackerUnitRef = useRef2(null);
|
|
1372
|
+
const trackerFor = useCallback((unitId) => {
|
|
1373
|
+
if (trackerUnitRef.current !== unitId || !trackerRef.current) {
|
|
1374
|
+
trackerRef.current = new PlaybackTracker();
|
|
1375
|
+
trackerUnitRef.current = unitId;
|
|
1376
|
+
}
|
|
1377
|
+
return trackerRef.current;
|
|
1378
|
+
}, []);
|
|
1379
|
+
const select = useCallback(
|
|
1380
|
+
(id) => {
|
|
1381
|
+
setCurrentId(id);
|
|
1382
|
+
setDrawerOpen(false);
|
|
1383
|
+
onUnitChange?.(id);
|
|
1384
|
+
},
|
|
1385
|
+
[onUnitChange]
|
|
1386
|
+
);
|
|
1387
|
+
useEffect2(() => {
|
|
1388
|
+
const chapterId = current?.parentId;
|
|
1389
|
+
if (!chapterId) return;
|
|
1390
|
+
setCollapsedChapters((prev) => {
|
|
1391
|
+
if (!prev.has(chapterId)) return prev;
|
|
1392
|
+
const next2 = new Set(prev);
|
|
1393
|
+
next2.delete(chapterId);
|
|
1394
|
+
return next2;
|
|
1395
|
+
});
|
|
1396
|
+
}, [current?.parentId, currentId]);
|
|
1397
|
+
const wasCompleted = useRef2(Boolean(tree.progress?.completed));
|
|
1398
|
+
const [justCompleted, setJustCompleted] = useState3(false);
|
|
1399
|
+
useEffect2(() => {
|
|
1400
|
+
const completed = Boolean(deliverableProgress?.completed);
|
|
1401
|
+
if (completed && !wasCompleted.current) setJustCompleted(true);
|
|
1402
|
+
wasCompleted.current = completed;
|
|
1403
|
+
}, [deliverableProgress?.completed]);
|
|
1404
|
+
useEffect2(() => {
|
|
1405
|
+
setOpened(null);
|
|
1406
|
+
setOpenError(null);
|
|
1407
|
+
setAttachmentFailed(false);
|
|
1408
|
+
setLoading(false);
|
|
1409
|
+
if (!current || !isGranted(current)) return;
|
|
1410
|
+
if (!current.hasFile) return;
|
|
1411
|
+
let cancelled = false;
|
|
1412
|
+
setLoading(true);
|
|
1413
|
+
client.openUnit(current.id, "read").then((res) => {
|
|
1414
|
+
if (cancelled) return;
|
|
1415
|
+
if (res.ok) setOpened(res);
|
|
1416
|
+
else setOpenError(res.code);
|
|
1417
|
+
}).catch(() => {
|
|
1418
|
+
if (!cancelled) setOpenError("NETWORK");
|
|
1419
|
+
}).finally(() => {
|
|
1420
|
+
if (!cancelled) setLoading(false);
|
|
1421
|
+
});
|
|
1422
|
+
return () => {
|
|
1423
|
+
cancelled = true;
|
|
1424
|
+
};
|
|
1425
|
+
}, [current, client, isGranted, retryTick]);
|
|
1426
|
+
const report = useCallback(
|
|
1427
|
+
async (unitId, input, options) => {
|
|
1428
|
+
if (isDownloadPack) return;
|
|
1429
|
+
try {
|
|
1430
|
+
const res = await client.reportProgress({ unitId, reports: [input], ...options?.lite ? { lite: true } : {} });
|
|
1431
|
+
if (res.ok) {
|
|
1432
|
+
setProgressByUnit((prev) => ({ ...prev, [unitId]: res.unit }));
|
|
1433
|
+
if (res.deliverable) setDeliverableProgress({ percent: res.deliverable.percent, completed: res.deliverable.completed, completedAt: res.deliverable.completedAt ?? null });
|
|
1434
|
+
}
|
|
1435
|
+
} catch {
|
|
1436
|
+
}
|
|
1437
|
+
},
|
|
1438
|
+
[client, isDownloadPack]
|
|
1439
|
+
);
|
|
1440
|
+
const flushTracker = useCallback(
|
|
1441
|
+
(unitId, mode) => {
|
|
1442
|
+
const tracker = trackerRef.current;
|
|
1443
|
+
if (!tracker || trackerUnitRef.current !== unitId) return;
|
|
1444
|
+
const item = tracker.flush(mode !== "heartbeat");
|
|
1445
|
+
if (!item) return;
|
|
1446
|
+
lastReportAt.current = Date.now();
|
|
1447
|
+
void report(unitId, item, { lite: mode === "heartbeat" });
|
|
1448
|
+
},
|
|
1449
|
+
[report]
|
|
1450
|
+
);
|
|
1451
|
+
const handleTimeUpdate = useCallback(
|
|
1452
|
+
(currentTime, duration) => {
|
|
1453
|
+
if (!current) return;
|
|
1454
|
+
trackerFor(current.id).timeUpdate(currentTime, duration);
|
|
1455
|
+
const segments = transcriptSegmentsRef.current;
|
|
1456
|
+
if (segments.length > 0) {
|
|
1457
|
+
const index = activeSegmentIndex(segments, currentTime);
|
|
1458
|
+
setActiveSegment((prev) => prev === index ? prev : index);
|
|
1459
|
+
}
|
|
1460
|
+
const now = Date.now();
|
|
1461
|
+
if (now - lastReportAt.current < REPORT_INTERVAL_MS) return;
|
|
1462
|
+
flushTracker(current.id, "heartbeat");
|
|
1463
|
+
},
|
|
1464
|
+
[current, trackerFor, flushTracker]
|
|
1465
|
+
);
|
|
1466
|
+
const handlePlaybackEvent = useCallback(
|
|
1467
|
+
(event) => {
|
|
1468
|
+
if (!current) return;
|
|
1469
|
+
trackerFor(current.id).event(event);
|
|
1470
|
+
if (event.type === "pause" || event.type === "seeked") flushTracker(current.id, "event");
|
|
1471
|
+
},
|
|
1472
|
+
[current, trackerFor, flushTracker]
|
|
1473
|
+
);
|
|
1474
|
+
const handleComplete = useCallback(() => {
|
|
1475
|
+
if (!current) return;
|
|
1476
|
+
const tracker = trackerFor(current.id);
|
|
1477
|
+
const item = tracker.flush(true) ?? { sessionId: tracker.sessionId, positionSeconds: tracker.position, ...tracker.duration > 0 ? { durationSeconds: tracker.duration } : {} };
|
|
1478
|
+
lastReportAt.current = Date.now();
|
|
1479
|
+
void report(current.id, { ...item, completed: true });
|
|
1480
|
+
if (autoplayNext) {
|
|
1481
|
+
const next2 = leaves[currentIndex + 1];
|
|
1482
|
+
if (next2 && isGranted(next2)) window.setTimeout(() => select(next2.id), 800);
|
|
1483
|
+
}
|
|
1484
|
+
}, [current, trackerFor, report, autoplayNext, leaves, currentIndex, isGranted, select]);
|
|
1485
|
+
const submitQuiz = async () => {
|
|
1486
|
+
if (!current) return;
|
|
1487
|
+
setQuizBusy(true);
|
|
1488
|
+
try {
|
|
1489
|
+
const res = await client.submitQuiz({ unitId: current.id, answers: quizAnswers });
|
|
1490
|
+
if (res.ok) {
|
|
1491
|
+
setQuizResult(res);
|
|
1492
|
+
setProgressByUnit((prev) => ({ ...prev, [current.id]: res.unit }));
|
|
1493
|
+
setDeliverableProgress({ percent: res.deliverable.percent, completed: res.deliverable.completed, completedAt: res.deliverable.completedAt ?? null });
|
|
1494
|
+
}
|
|
1495
|
+
} finally {
|
|
1496
|
+
setQuizBusy(false);
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
const autoTracked = !!current && (current.kind === "video" || current.kind === "audio" || Boolean(opened?.mimeType && (opened.mimeType.startsWith("video/") || opened.mimeType.startsWith("audio/"))));
|
|
1500
|
+
const currentStatus = current ? progressByUnit[current.id] ?? current.progress : "not_started";
|
|
1501
|
+
const canMarkComplete = !!current && !isDownloadPack && isGranted(current) && !autoTracked && currentStatus !== "completed";
|
|
1502
|
+
useEffect2(() => {
|
|
1503
|
+
if (!current) return;
|
|
1504
|
+
const unitId = current.id;
|
|
1505
|
+
const onHide = () => flushTracker(unitId, "final");
|
|
1506
|
+
const onVisibility = () => {
|
|
1507
|
+
if (document.visibilityState === "hidden") flushTracker(unitId, "event");
|
|
1508
|
+
};
|
|
1509
|
+
window.addEventListener("pagehide", onHide);
|
|
1510
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
1511
|
+
return () => {
|
|
1512
|
+
window.removeEventListener("pagehide", onHide);
|
|
1513
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
1514
|
+
flushTracker(unitId, "final");
|
|
1515
|
+
};
|
|
1516
|
+
}, [current, flushTracker]);
|
|
1517
|
+
useEffect2(() => {
|
|
1518
|
+
if (!current || isDownloadPack || !isGranted(current)) return;
|
|
1519
|
+
if (current.kind === "video" || current.kind === "audio") return;
|
|
1520
|
+
if ((progressByUnit[current.id] ?? current.progress) !== "not_started") return;
|
|
1521
|
+
void report(current.id, { opened: true });
|
|
1522
|
+
}, [current?.id, isDownloadPack]);
|
|
1523
|
+
const resumeAt = (unit) => {
|
|
1524
|
+
if (isDownloadPack) return void 0;
|
|
1525
|
+
const status = progressByUnit[unit.id] ?? unit.progress;
|
|
1526
|
+
if (status === "completed") return void 0;
|
|
1527
|
+
const at = typeof unit.lastPosition === "number" ? unit.lastPosition : unit.positionSeconds;
|
|
1528
|
+
return at > 5 ? at : void 0;
|
|
1529
|
+
};
|
|
1530
|
+
const goto = (delta) => {
|
|
1531
|
+
const next2 = leaves[currentIndex + delta];
|
|
1532
|
+
if (next2 && isGranted(next2)) select(next2.id);
|
|
1533
|
+
};
|
|
1534
|
+
const downloadUnit = async (unitId) => {
|
|
1535
|
+
const res = await client.openUnit(unitId, "download");
|
|
1536
|
+
if (res.ok) window.open(res.url, "_blank", "noopener,noreferrer");
|
|
1537
|
+
};
|
|
1538
|
+
const handleDownload = () => {
|
|
1539
|
+
if (current) void downloadUnit(current.id);
|
|
1540
|
+
};
|
|
1541
|
+
const downloadAttachment = async (unitId, attachmentId) => {
|
|
1542
|
+
if (attachmentBusy) return;
|
|
1543
|
+
setAttachmentBusy(attachmentId);
|
|
1544
|
+
setAttachmentFailed(false);
|
|
1545
|
+
const res = await client.openUnit(unitId, "download", { attachmentId }).catch(() => ({ ok: false, code: "NETWORK" }));
|
|
1546
|
+
setAttachmentBusy(null);
|
|
1547
|
+
if (res.ok) window.open(res.url, "_blank", "noopener,noreferrer");
|
|
1548
|
+
else setAttachmentFailed(true);
|
|
1549
|
+
};
|
|
1550
|
+
const next = currentIndex >= 0 ? leaves[currentIndex + 1] ?? null : null;
|
|
1551
|
+
const previous = currentIndex > 0 ? leaves[currentIndex - 1] : null;
|
|
1552
|
+
const manualComplete = canMarkComplete && current?.kind !== "quiz";
|
|
1553
|
+
const nextOpensAfterComplete = () => {
|
|
1554
|
+
if (!next || !current) return false;
|
|
1555
|
+
if (next.access.granted) return true;
|
|
1556
|
+
if (next.access.reason !== "prerequisite") return false;
|
|
1557
|
+
const after = computeSequenceLocks({
|
|
1558
|
+
leaves: leaves.map((u) => ({ id: u.id, isPreview: u.isPreview, countsTowardCompletion: u.countsTowardCompletion, isPrerequisite: u.isPrerequisite })),
|
|
1559
|
+
completedUnitIds: /* @__PURE__ */ new Set([...completedIds, current.id]),
|
|
1560
|
+
requireSequential: Boolean(tree.settings?.requireSequential)
|
|
1561
|
+
});
|
|
1562
|
+
return !after.has(next.id);
|
|
1563
|
+
};
|
|
1564
|
+
const [advancing, setAdvancing] = useState3(false);
|
|
1565
|
+
const completeAndContinue = async () => {
|
|
1566
|
+
if (!current || advancing) return;
|
|
1567
|
+
setAdvancing(true);
|
|
1568
|
+
try {
|
|
1569
|
+
const opens = nextOpensAfterComplete();
|
|
1570
|
+
await report(current.id, { completed: true });
|
|
1571
|
+
if (next && opens) select(next.id);
|
|
1572
|
+
} finally {
|
|
1573
|
+
setAdvancing(false);
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
const nextReady = Boolean(next && isGranted(next));
|
|
1577
|
+
const blockedByCurrent = Boolean(next && !nextReady && !manualComplete && currentStatus !== "completed" && next.access.reason === "prerequisite");
|
|
1578
|
+
const primaryAction = manualComplete ? { label: next ? labels.completeAndContinue : labels.markComplete, onClick: () => void completeAndContinue(), disabled: advancing, icon: true } : { label: labels.nextUnit, onClick: () => goto(1), disabled: !nextReady, icon: false };
|
|
1579
|
+
const showPrimary = manualComplete || Boolean(next);
|
|
1580
|
+
const unitMeta = (u) => u.duration ? fill2(labels.minutes, { count: Math.max(1, Math.round(u.duration / 60)) }) : u.pageCount ? fill2(labels.pages, { count: u.pageCount }) : null;
|
|
1581
|
+
const toggleChapter = (chapterId) => setCollapsedChapters((prev) => {
|
|
1582
|
+
const nextSet = new Set(prev);
|
|
1583
|
+
if (nextSet.has(chapterId)) nextSet.delete(chapterId);
|
|
1584
|
+
else nextSet.add(chapterId);
|
|
1585
|
+
return nextSet;
|
|
1586
|
+
});
|
|
1587
|
+
const outline = /* @__PURE__ */ jsxs9(Fragment6, { children: [
|
|
1588
|
+
/* @__PURE__ */ jsxs9("div", { className: cn("shrink-0 border-b px-4 py-2", BORDER2), children: [
|
|
1589
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex min-h-10 items-center justify-between gap-2", children: [
|
|
1590
|
+
/* @__PURE__ */ jsxs9("div", { className: "min-w-0", children: [
|
|
1591
|
+
tree.authors && tree.authors.length > 0 && /* @__PURE__ */ jsx15(AuthorList, { authors: tree.authors, className: "mb-1.5" }),
|
|
1592
|
+
/* @__PURE__ */ jsxs9("p", { className: cn("text-xs", MUTED2), children: [
|
|
1593
|
+
fill2(labels.unitsCount, { count: leaves.length }),
|
|
1594
|
+
deliverableProgress && !isDownloadPack ? ` \xB7 ${fill2(labels.progress, { percent: deliverableProgress.percent })}` : ""
|
|
1595
|
+
] })
|
|
1596
|
+
] }),
|
|
1597
|
+
!isDownloadPack && leaves.length > 1 && /* @__PURE__ */ jsx15("button", { type: "button", onClick: () => setSettingsOpen((open) => !open), "aria-expanded": settingsOpen, "aria-label": labels.settings, title: labels.settings, className: cn(ICON_BUTTON, "-mr-2"), children: /* @__PURE__ */ jsx15(Settings2, { className: "h-4 w-4", "aria-hidden": "true" }) })
|
|
1598
|
+
] }),
|
|
1599
|
+
settingsOpen && /* @__PURE__ */ jsxs9("button", { type: "button", role: "switch", "aria-checked": autoplayNext, onClick: () => toggleAutoplay(!autoplayNext), className: cn("flex min-h-10 w-full items-center justify-between gap-3 text-left text-sm", FG2), children: [
|
|
1600
|
+
labels.autoplayNext,
|
|
1601
|
+
/* @__PURE__ */ jsx15("span", { "aria-hidden": true, className: cn("relative inline-flex h-5 w-9 shrink-0 rounded-full transition", autoplayNext ? "bg-[var(--brand-color,#18181b)]" : "bg-black/20 dark:bg-white/25"), children: /* @__PURE__ */ jsx15("span", { className: cn("absolute top-0.5 h-4 w-4 rounded-full bg-white transition", autoplayNext ? "left-[18px]" : "left-0.5") }) })
|
|
1602
|
+
] }),
|
|
1603
|
+
certificate?.enabled && deliverableProgress?.completed && /* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => void downloadCertificate(), disabled: certificateBusy, className: cn(SECONDARY_BUTTON, "my-2 w-full"), children: [
|
|
1604
|
+
/* @__PURE__ */ jsx15(Award, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1605
|
+
" ",
|
|
1606
|
+
labels.certificateDownload
|
|
1607
|
+
] })
|
|
1608
|
+
] }),
|
|
1609
|
+
/* @__PURE__ */ jsxs9(NavTag, { role: page ? void 0 : "navigation", "aria-label": labels.outline, className: "min-h-0 flex-1 overflow-y-auto p-2", children: [
|
|
1610
|
+
leaves.length === 0 && /* @__PURE__ */ jsx15("p", { className: cn("p-3 text-sm", MUTED2), children: labels.noUnits }),
|
|
1611
|
+
groups.map((g, gi) => {
|
|
1612
|
+
const chapterId = g.chapter?.id ?? null;
|
|
1613
|
+
const collapsed = chapterId ? collapsedChapters.has(chapterId) : false;
|
|
1614
|
+
const counted = g.units.filter((u) => u.countsTowardCompletion !== false);
|
|
1615
|
+
const done = counted.filter((u) => (progressByUnit[u.id] ?? u.progress) === "completed").length;
|
|
1616
|
+
return /* @__PURE__ */ jsxs9("div", { className: "mb-1", children: [
|
|
1617
|
+
g.chapter && /* @__PURE__ */ jsxs9(
|
|
1618
|
+
"button",
|
|
1619
|
+
{
|
|
1620
|
+
type: "button",
|
|
1621
|
+
onClick: () => toggleChapter(g.chapter.id),
|
|
1622
|
+
"aria-expanded": !collapsed,
|
|
1623
|
+
className: cn("flex w-full items-start gap-2 rounded-lg px-2 py-2 text-left text-sm font-semibold hover:bg-black/[0.03] dark:hover:bg-white/[0.06]", FG2),
|
|
1624
|
+
children: [
|
|
1625
|
+
/* @__PURE__ */ jsx15(ChevronDown, { className: cn("mt-0.5 h-4 w-4 shrink-0 transition-transform", MUTED2, collapsed && "-rotate-90"), "aria-hidden": "true" }),
|
|
1626
|
+
/* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1", children: g.chapter.title }),
|
|
1627
|
+
!isDownloadPack && counted.length > 0 && /* @__PURE__ */ jsxs9("span", { className: cn("shrink-0 text-xs font-normal tabular-nums", MUTED2), children: [
|
|
1628
|
+
done,
|
|
1629
|
+
"/",
|
|
1630
|
+
counted.length
|
|
1631
|
+
] })
|
|
1632
|
+
]
|
|
1633
|
+
}
|
|
1634
|
+
),
|
|
1635
|
+
!collapsed && /* @__PURE__ */ jsx15("ul", { className: "space-y-0.5", children: g.units.map((u) => {
|
|
1636
|
+
const status = progressByUnit[u.id] ?? u.progress;
|
|
1637
|
+
const active = u.id === currentId;
|
|
1638
|
+
const locked = !isGranted(u);
|
|
1639
|
+
const rowDownload = isDownloadPack && !locked && u.allowDownload && u.hasFile;
|
|
1640
|
+
const meta = unitMeta(u);
|
|
1641
|
+
const lockText = locked && u.access.reason === "not_released" && u.access.availableAt ? fill2(labels.unlocksAt, { date: formatDateTime(u.access.availableAt, locale, timeZone) }) : locked && u.access.reason === "prerequisite" ? fill2(labels.lockedBy, { title: lockedByTitle(u) }) : locked ? labels.locked : null;
|
|
1642
|
+
const tags = [u.countsTowardCompletion === false && !isDownloadPack ? labels.optional : null, u.isPreview && !locked ? labels.preview : null, meta].filter(Boolean);
|
|
1643
|
+
return /* @__PURE__ */ jsxs9("li", { className: cn(rowDownload && "flex items-start gap-1"), children: [
|
|
1644
|
+
/* @__PURE__ */ jsxs9(
|
|
1645
|
+
"button",
|
|
1646
|
+
{
|
|
1647
|
+
type: "button",
|
|
1648
|
+
disabled: locked,
|
|
1649
|
+
"aria-current": active ? "true" : void 0,
|
|
1650
|
+
onClick: () => select(u.id),
|
|
1651
|
+
className: cn(
|
|
1652
|
+
"flex w-full items-start gap-2.5 rounded-lg px-2 py-2 text-left text-sm transition",
|
|
1653
|
+
active ? "bg-black/5 font-medium dark:bg-white/10" : "hover:bg-black/[0.03] dark:hover:bg-white/[0.06]",
|
|
1654
|
+
locked && "cursor-not-allowed opacity-60",
|
|
1655
|
+
rowDownload && "min-w-0 flex-1"
|
|
1656
|
+
),
|
|
1657
|
+
children: [
|
|
1658
|
+
/* @__PURE__ */ jsx15("span", { className: cn("mt-0.5 shrink-0", MUTED2), children: locked ? /* @__PURE__ */ jsx15(Lock, { className: "h-4 w-4" }) : isDownloadPack ? /* @__PURE__ */ jsx15(FileText, { className: "h-4 w-4" }) : status === "completed" ? /* @__PURE__ */ jsx15(CircleCheck, { className: "h-4 w-4 text-emerald-600" }) : status === "in-progress" ? /* @__PURE__ */ jsx15(CirclePlay, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx15(Circle, { className: "h-4 w-4" }) }),
|
|
1659
|
+
/* @__PURE__ */ jsxs9("span", { className: "min-w-0 flex-1", children: [
|
|
1660
|
+
/* @__PURE__ */ jsx15("span", { className: cn("line-clamp-2", FG2), children: u.title || u.kind }),
|
|
1661
|
+
tags.length > 0 && /* @__PURE__ */ jsx15("span", { className: cn("block text-xs", MUTED2), children: tags.join(" \xB7 ") }),
|
|
1662
|
+
lockText && /* @__PURE__ */ jsx15("span", { className: cn("block text-xs", MUTED2), children: lockText }),
|
|
1663
|
+
u.id === resumeId && !locked && status !== "completed" && /* @__PURE__ */ jsx15("span", { className: "block text-xs font-normal text-[var(--site-accent-text,var(--brand-color,#18181b))]", children: labels.lastViewed })
|
|
1664
|
+
] })
|
|
1665
|
+
]
|
|
1666
|
+
}
|
|
1667
|
+
),
|
|
1668
|
+
rowDownload && /* @__PURE__ */ jsx15("button", { type: "button", onClick: () => void downloadUnit(u.id), "aria-label": `${labels.download}: ${u.title || u.kind}`, title: labels.download, className: cn(ICON_BUTTON, "mt-0.5 h-9 w-9"), children: /* @__PURE__ */ jsx15(Download, { className: "h-4 w-4" }) })
|
|
1669
|
+
] }, u.id);
|
|
1670
|
+
}) })
|
|
1671
|
+
] }, chapterId ?? `loose-${gi}`);
|
|
1672
|
+
})
|
|
1673
|
+
] })
|
|
1674
|
+
] });
|
|
1675
|
+
const mediaFirst = !!current && (current.kind === "video" || current.kind === "audio" || Boolean(current.embed && embedSrc(current.embed)));
|
|
1676
|
+
const heading = current ? /* @__PURE__ */ jsxs9("div", { children: [
|
|
1677
|
+
/* @__PURE__ */ jsx15("h2", { className: cn("text-lg font-bold sm:text-xl", FG2), children: current.title || current.kind }),
|
|
1678
|
+
current.description && /* @__PURE__ */ jsx15("p", { className: cn("mt-1 text-sm", MUTED2), children: current.description })
|
|
1679
|
+
] }) : null;
|
|
1680
|
+
const unitBody = !current ? null : current.embed && embedSrc(current.embed) ? /* @__PURE__ */ jsx15("div", { className: "aspect-video w-full overflow-hidden rounded-[var(--site-radius-media,0.75rem)] bg-black", children: /* @__PURE__ */ jsx15("iframe", { title: current.title ?? current.kind, src: embedSrc(current.embed), className: "h-full w-full", allow: "accelerometer; autoplay; encrypted-media; picture-in-picture", allowFullScreen: true }) }) : current.kind === "quiz" ? /* @__PURE__ */ jsx15(
|
|
1681
|
+
QuizView,
|
|
1682
|
+
{
|
|
1683
|
+
body: current.body,
|
|
1684
|
+
summary: current.quiz ?? null,
|
|
1685
|
+
answers: quizAnswers,
|
|
1686
|
+
result: quizResult,
|
|
1687
|
+
busy: quizBusy,
|
|
1688
|
+
labels,
|
|
1689
|
+
onAnswer: (questionId, optionIds) => setQuizAnswers((prev) => ({ ...prev, [questionId]: optionIds })),
|
|
1690
|
+
onSubmit: () => void submitQuiz(),
|
|
1691
|
+
onRetry: () => {
|
|
1692
|
+
setQuizAnswers({});
|
|
1693
|
+
setQuizResult(null);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
) : current.kind === "text" ? (
|
|
1697
|
+
// 內文嵌的影音:事實隨單元回(串流、字幕、章節、封面;媒體 ADR 0005、0011)
|
|
1698
|
+
/* @__PURE__ */ jsx15(MediaFactsProvider, { facts: current.body?.mediaFacts, children: /* @__PURE__ */ jsx15("div", { className: "max-w-none", children: /* @__PURE__ */ jsx15(ArticleMarkdown, { content: stripLeadingTitle(typeof current.body?.markdown === "string" ? current.body.markdown : "", current.title) }) }) })
|
|
1699
|
+
) : loading ? /* @__PURE__ */ jsx15("div", { className: "aspect-video w-full animate-pulse rounded-[var(--site-radius-media,0.75rem)] bg-black/5 dark:bg-white/10" }) : openError && openError !== "NO_FILE" ? (
|
|
1700
|
+
// 學員看到的是能做什麼(再試一次),不是內部錯誤碼
|
|
1701
|
+
/* @__PURE__ */ jsxs9("div", { role: "alert", className: cn("flex flex-col items-center gap-3 rounded-[var(--site-radius-media,0.75rem)] border border-dashed px-4 py-10 text-center text-sm", BORDER2, MUTED2), children: [
|
|
1702
|
+
/* @__PURE__ */ jsx15("p", { children: labels.loadError }),
|
|
1703
|
+
/* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => setRetryTick((tick) => tick + 1), className: SECONDARY_BUTTON, children: [
|
|
1704
|
+
/* @__PURE__ */ jsx15(RotateCw, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1705
|
+
" ",
|
|
1706
|
+
labels.retry
|
|
1707
|
+
] })
|
|
1708
|
+
] })
|
|
1709
|
+
) : opened ? /* @__PURE__ */ jsx15(
|
|
1710
|
+
MediaPlayer,
|
|
1711
|
+
{
|
|
1712
|
+
src: opened.url,
|
|
1713
|
+
hlsSrc: opened.renditions?.find((r) => r.kind === "hls")?.url,
|
|
1714
|
+
thumbnails: opened.thumbnails ?? opened.renditions?.find((r) => r.kind === "thumbnails")?.url,
|
|
1715
|
+
streamingPartial: opened.streaming === "partial",
|
|
1716
|
+
captions: captionTracksOf(opened.renditions),
|
|
1717
|
+
captionLocale,
|
|
1718
|
+
onCaptionChange,
|
|
1719
|
+
thumbnailUrl: opened.poster ?? void 0,
|
|
1720
|
+
mimeType: opened.mimeType ?? "application/octet-stream",
|
|
1721
|
+
title: opened.title ?? current.title ?? void 0,
|
|
1722
|
+
fileName: opened.fileName,
|
|
1723
|
+
pageCount: current.pageCount ?? void 0,
|
|
1724
|
+
storageKey: `unit:${current.id}`,
|
|
1725
|
+
startTime: resumeAt(current),
|
|
1726
|
+
seekTo,
|
|
1727
|
+
chapters: opened.renditions?.find((r) => r.kind === "chapters")?.url,
|
|
1728
|
+
allowDownload: opened.allowDownload,
|
|
1729
|
+
downloadUrl: opened.allowDownload ? opened.url : void 0,
|
|
1730
|
+
onTimeUpdate: handleTimeUpdate,
|
|
1731
|
+
onComplete: handleComplete,
|
|
1732
|
+
onPlaybackEvent: handlePlaybackEvent
|
|
1733
|
+
},
|
|
1734
|
+
current.id
|
|
1735
|
+
) : /* @__PURE__ */ jsx15("div", { className: cn("rounded-[var(--site-radius-media,0.75rem)] border border-dashed px-4 py-10 text-center text-sm", BORDER2, MUTED2), children: labels.unitEmpty });
|
|
1736
|
+
const primaryButton = showPrimary ? /* @__PURE__ */ jsxs9("button", { type: "button", onClick: primaryAction.onClick, disabled: primaryAction.disabled, className: cn(PRIMARY_BUTTON, "min-w-0"), style: { backgroundColor: "var(--brand-color,#18181b)" }, children: [
|
|
1737
|
+
primaryAction.icon && /* @__PURE__ */ jsx15(CircleCheck, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }),
|
|
1738
|
+
/* @__PURE__ */ jsx15("span", { className: "truncate", children: primaryAction.label })
|
|
1739
|
+
] }) : null;
|
|
1740
|
+
return /* @__PURE__ */ jsxs9(
|
|
1741
|
+
"div",
|
|
1742
|
+
{
|
|
1743
|
+
className: cn(
|
|
1744
|
+
"flex flex-col",
|
|
1745
|
+
page ? "h-dvh bg-[var(--site-surface-muted,#f4f4f5)]" : cn("overflow-hidden rounded-[var(--site-radius-card,1rem)] border", BORDER2, SURFACE2),
|
|
1746
|
+
className
|
|
1747
|
+
),
|
|
1748
|
+
children: [
|
|
1749
|
+
/* @__PURE__ */ jsxs9(HeaderTag, { className: cn("flex h-14 shrink-0 items-center gap-1 border-b px-2 sm:px-3", BORDER2, SURFACE2), children: [
|
|
1750
|
+
backHref && /* @__PURE__ */ jsx15("a", { href: backHref, "aria-label": backLabel, title: backLabel, className: ICON_BUTTON, children: /* @__PURE__ */ jsx15(ArrowLeft, { className: "h-5 w-5", "aria-hidden": "true" }) }),
|
|
1751
|
+
/* @__PURE__ */ jsx15(
|
|
1752
|
+
"button",
|
|
1753
|
+
{
|
|
1754
|
+
type: "button",
|
|
1755
|
+
onClick: () => setSidebarOpen((open) => !open),
|
|
1756
|
+
"aria-expanded": sidebarOpen,
|
|
1757
|
+
"aria-label": sidebarOpen ? labels.hideOutline : labels.showOutline,
|
|
1758
|
+
title: sidebarOpen ? labels.hideOutline : labels.showOutline,
|
|
1759
|
+
className: cn(ICON_BUTTON, "hidden lg:inline-flex"),
|
|
1760
|
+
children: /* @__PURE__ */ jsx15(PanelLeft, { className: "h-5 w-5", "aria-hidden": "true" })
|
|
1761
|
+
}
|
|
1762
|
+
),
|
|
1763
|
+
/* @__PURE__ */ jsx15("p", { className: cn("min-w-0 flex-1 truncate px-1 text-sm font-semibold sm:text-base", FG2), children: tree.title }),
|
|
1764
|
+
deliverableProgress && !isDownloadPack && /* @__PURE__ */ jsxs9("div", { className: "flex shrink-0 items-center gap-2 pr-1", "aria-label": fill2(labels.progress, { percent: deliverableProgress.percent }), children: [
|
|
1765
|
+
/* @__PURE__ */ jsx15("div", { className: "hidden h-1.5 w-24 overflow-hidden rounded-full bg-black/5 sm:block dark:bg-white/10", children: /* @__PURE__ */ jsx15("div", { className: "h-full rounded-full", style: { width: `${deliverableProgress.percent}%`, backgroundColor: "var(--brand-color,#18181b)" } }) }),
|
|
1766
|
+
/* @__PURE__ */ jsxs9("span", { className: cn("text-xs tabular-nums", MUTED2), children: [
|
|
1767
|
+
deliverableProgress.percent,
|
|
1768
|
+
"%"
|
|
1769
|
+
] })
|
|
1770
|
+
] })
|
|
1771
|
+
] }),
|
|
1772
|
+
/* @__PURE__ */ jsxs9("div", { className: cn("flex min-h-0 flex-1", !page && "lg:max-h-[80vh]"), children: [
|
|
1773
|
+
sidebarOpen && /* @__PURE__ */ jsx15(AsideTag, { className: cn("hidden w-80 shrink-0 flex-col border-r lg:flex", BORDER2, SURFACE2), children: outline }),
|
|
1774
|
+
/* @__PURE__ */ jsx15(MainTag, { className: "min-w-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx15("div", { className: cn("mx-auto w-full max-w-4xl px-4 py-5 sm:px-6 lg:py-8", page && "pb-24 lg:pb-8"), children: !current ? /* @__PURE__ */ jsx15("div", { className: cn("rounded-[var(--site-radius-card,1rem)] border border-dashed p-10 text-center text-sm", BORDER2, MUTED2), children: labels.noUnits }) : /* @__PURE__ */ jsxs9("div", { className: "space-y-4", children: [
|
|
1775
|
+
justCompleted && /* @__PURE__ */ jsxs9("div", { className: cn("flex flex-col items-center gap-3 rounded-[var(--site-radius-card,1rem)] border p-6 text-center", BORDER2, SURFACE2), role: "status", children: [
|
|
1776
|
+
/* @__PURE__ */ jsx15("span", { className: "flex h-12 w-12 items-center justify-center rounded-full", style: { backgroundColor: "var(--brand-color,#18181b)", color: "var(--brand-foreground,#ffffff)" }, children: /* @__PURE__ */ jsx15(Award, { className: "h-6 w-6", "aria-hidden": "true" }) }),
|
|
1777
|
+
/* @__PURE__ */ jsxs9("div", { children: [
|
|
1778
|
+
/* @__PURE__ */ jsx15("p", { className: cn("text-lg font-bold", FG2), children: labels.courseCompletedTitle }),
|
|
1779
|
+
deliverableProgress?.completedAt && /* @__PURE__ */ jsx15("p", { className: cn("mt-1 text-sm", MUTED2), children: fill2(labels.courseCompletedOn, { date: formatDate(deliverableProgress.completedAt, locale, timeZone) }) })
|
|
1780
|
+
] }),
|
|
1781
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
|
|
1782
|
+
certificate?.enabled && /* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => void downloadCertificate(), disabled: certificateBusy, className: PRIMARY_BUTTON, style: { backgroundColor: "var(--brand-color,#18181b)" }, children: [
|
|
1783
|
+
/* @__PURE__ */ jsx15(Award, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1784
|
+
" ",
|
|
1785
|
+
labels.certificateDownload
|
|
1786
|
+
] }),
|
|
1787
|
+
backHref && backLabel && /* @__PURE__ */ jsx15("a", { href: backHref, className: SECONDARY_BUTTON, children: backLabel }),
|
|
1788
|
+
/* @__PURE__ */ jsx15("button", { type: "button", onClick: () => setJustCompleted(false), className: SECONDARY_BUTTON, children: labels.keepBrowsing })
|
|
1789
|
+
] })
|
|
1790
|
+
] }),
|
|
1791
|
+
!mediaFirst && heading,
|
|
1792
|
+
unitBody,
|
|
1793
|
+
mediaFirst && heading,
|
|
1794
|
+
showTranscriptPanel && current && transcriptForCurrent && /* @__PURE__ */ jsx15(
|
|
1795
|
+
TranscriptPanel,
|
|
1796
|
+
{
|
|
1797
|
+
labels,
|
|
1798
|
+
open: transcriptOpen,
|
|
1799
|
+
onToggle: toggleTranscript,
|
|
1800
|
+
status: transcriptForCurrent.status === "ready" ? "ready" : "error",
|
|
1801
|
+
data: transcriptForCurrent.data,
|
|
1802
|
+
activeIndex: activeSegment,
|
|
1803
|
+
onSeek: (time) => setSeekTo({ time, nonce: Date.now() }),
|
|
1804
|
+
onLocaleChange: (next2) => setTranscriptLocale(next2),
|
|
1805
|
+
onRetry: () => setTranscriptTick((tick) => tick + 1),
|
|
1806
|
+
uiLocale: locale ?? "en",
|
|
1807
|
+
fileName: current.title || opened?.fileName || "transcript"
|
|
1808
|
+
}
|
|
1809
|
+
),
|
|
1810
|
+
current.attachments && current.attachments.length > 0 && /* @__PURE__ */ jsxs9("div", { role: "group", "aria-label": labels.attachments, children: [
|
|
1811
|
+
/* @__PURE__ */ jsx15("h3", { className: cn("mb-2 text-sm font-semibold", FG2), children: labels.attachments }),
|
|
1812
|
+
/* @__PURE__ */ jsx15("ul", { className: cn("divide-y rounded-[var(--site-radius-card,0.75rem)] border", BORDER2, SURFACE2), children: current.attachments.map((file) => /* @__PURE__ */ jsxs9("li", { className: cn("flex min-h-14 items-center gap-3 px-3 py-2", BORDER2), children: [
|
|
1813
|
+
/* @__PURE__ */ jsx15(Paperclip, { className: cn("h-4 w-4 shrink-0", MUTED2), "aria-hidden": "true" }),
|
|
1814
|
+
/* @__PURE__ */ jsxs9("span", { className: "min-w-0 flex-1", children: [
|
|
1815
|
+
/* @__PURE__ */ jsx15("span", { className: cn("block break-words text-sm font-medium", FG2), children: file.fileName }),
|
|
1816
|
+
file.bytes != null && /* @__PURE__ */ jsx15("span", { className: cn("block text-xs", MUTED2), children: formatFileSize(file.bytes, { locale: locale ?? "en" }) })
|
|
1817
|
+
] }),
|
|
1818
|
+
/* @__PURE__ */ jsxs9(
|
|
1819
|
+
"button",
|
|
1820
|
+
{
|
|
1821
|
+
type: "button",
|
|
1822
|
+
onClick: () => void downloadAttachment(current.id, file.id),
|
|
1823
|
+
disabled: attachmentBusy !== null,
|
|
1824
|
+
"aria-label": fill2(labels.downloadFile, { name: file.fileName }),
|
|
1825
|
+
className: cn(SECONDARY_BUTTON, "shrink-0"),
|
|
1826
|
+
children: [
|
|
1827
|
+
/* @__PURE__ */ jsx15(Download, { className: cn("h-4 w-4", attachmentBusy === file.id && "animate-pulse"), "aria-hidden": "true" }),
|
|
1828
|
+
" ",
|
|
1829
|
+
/* @__PURE__ */ jsx15("span", { className: "hidden sm:inline", children: labels.download })
|
|
1830
|
+
]
|
|
1831
|
+
}
|
|
1832
|
+
)
|
|
1833
|
+
] }, file.id)) }),
|
|
1834
|
+
attachmentFailed && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-2 text-sm text-red-600 dark:text-red-400", children: labels.loadError })
|
|
1835
|
+
] }),
|
|
1836
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1837
|
+
current.allowDownload && current.hasFile && /* @__PURE__ */ jsxs9("button", { type: "button", onClick: handleDownload, className: SECONDARY_BUTTON, children: [
|
|
1838
|
+
/* @__PURE__ */ jsx15(Download, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1839
|
+
" ",
|
|
1840
|
+
labels.download
|
|
1841
|
+
] }),
|
|
1842
|
+
current.embed && embedSrc(current.embed) && /* @__PURE__ */ jsxs9("a", { href: embedSrc(current.embed).replace("/embed/", "/watch?v="), target: "_blank", rel: "noopener noreferrer", className: cn("inline-flex min-h-11 items-center gap-1.5 text-sm underline underline-offset-4", MUTED2), children: [
|
|
1843
|
+
/* @__PURE__ */ jsx15(ExternalLink, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1844
|
+
" ",
|
|
1845
|
+
labels.open
|
|
1846
|
+
] }),
|
|
1847
|
+
!isDownloadPack && currentStatus === "completed" && /* @__PURE__ */ jsxs9("span", { className: "inline-flex items-center gap-1 text-sm text-emerald-600 dark:text-emerald-400", children: [
|
|
1848
|
+
/* @__PURE__ */ jsx15(CircleCheck, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1849
|
+
" ",
|
|
1850
|
+
labels.completed
|
|
1851
|
+
] })
|
|
1852
|
+
] }),
|
|
1853
|
+
/* @__PURE__ */ jsxs9("div", { className: cn("items-center justify-between gap-3 border-t pt-4", BORDER2, page ? "hidden lg:flex" : "flex"), children: [
|
|
1854
|
+
/* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => goto(-1), disabled: !previous, className: SECONDARY_BUTTON, children: [
|
|
1855
|
+
/* @__PURE__ */ jsx15(ChevronLeft, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1856
|
+
" ",
|
|
1857
|
+
labels.previousUnit
|
|
1858
|
+
] }),
|
|
1859
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex min-w-0 items-center gap-3", children: [
|
|
1860
|
+
blockedByCurrent && /* @__PURE__ */ jsx15("span", { className: cn("text-xs", MUTED2), children: labels.completeToContinue }),
|
|
1861
|
+
primaryButton
|
|
1862
|
+
] })
|
|
1863
|
+
] })
|
|
1864
|
+
] }) }) })
|
|
1865
|
+
] }),
|
|
1866
|
+
page ? /* @__PURE__ */ jsxs9("div", { className: cn("fixed inset-x-0 bottom-0 z-30 flex items-center gap-2 border-t px-3 pt-2 pb-[calc(0.5rem+env(safe-area-inset-bottom))] lg:hidden", BORDER2, SURFACE2), children: [
|
|
1867
|
+
/* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => setDrawerOpen(true), "aria-haspopup": "dialog", "aria-expanded": drawerOpen, className: cn(SECONDARY_BUTTON, "shrink-0"), children: [
|
|
1868
|
+
/* @__PURE__ */ jsx15(List, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1869
|
+
" ",
|
|
1870
|
+
labels.outline
|
|
1871
|
+
] }),
|
|
1872
|
+
/* @__PURE__ */ jsx15("button", { type: "button", onClick: () => goto(-1), disabled: !previous, "aria-label": labels.previousUnit, title: labels.previousUnit, className: cn(SECONDARY_BUTTON, "shrink-0 px-3"), children: /* @__PURE__ */ jsx15(ChevronLeft, { className: "h-4 w-4", "aria-hidden": "true" }) }),
|
|
1873
|
+
primaryButton ? /* @__PURE__ */ jsx15("div", { className: "flex min-w-0 flex-1 justify-end [&>button]:w-full", children: primaryButton }) : /* @__PURE__ */ jsx15("div", { className: "flex-1" })
|
|
1874
|
+
] }) : /* @__PURE__ */ jsx15("div", { className: cn("flex border-t p-2 lg:hidden", BORDER2), children: /* @__PURE__ */ jsxs9("button", { type: "button", onClick: () => setDrawerOpen(true), "aria-haspopup": "dialog", "aria-expanded": drawerOpen, className: cn(SECONDARY_BUTTON, "w-full"), children: [
|
|
1875
|
+
/* @__PURE__ */ jsx15(List, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
1876
|
+
" ",
|
|
1877
|
+
labels.outline
|
|
1878
|
+
] }) }),
|
|
1879
|
+
drawerOpen && /* @__PURE__ */ jsxs9("div", { className: "fixed inset-0 z-40 lg:hidden", role: "dialog", "aria-modal": "true", "aria-label": labels.outline, children: [
|
|
1880
|
+
/* @__PURE__ */ jsx15("button", { type: "button", "aria-label": labels.closeOutline, onClick: () => setDrawerOpen(false), className: "absolute inset-0 bg-black/40" }),
|
|
1881
|
+
/* @__PURE__ */ jsxs9("div", { className: cn("absolute inset-x-0 bottom-0 flex max-h-[85dvh] flex-col rounded-t-2xl pb-[env(safe-area-inset-bottom)]", SURFACE2), children: [
|
|
1882
|
+
/* @__PURE__ */ jsxs9("div", { className: cn("flex shrink-0 items-center justify-between gap-2 border-b px-4 py-2", BORDER2), children: [
|
|
1883
|
+
/* @__PURE__ */ jsx15("p", { className: cn("min-w-0 truncate text-sm font-semibold", FG2), children: labels.outline }),
|
|
1884
|
+
/* @__PURE__ */ jsx15("button", { type: "button", onClick: () => setDrawerOpen(false), "aria-label": labels.closeOutline, title: labels.closeOutline, className: ICON_BUTTON, children: /* @__PURE__ */ jsx15(X, { className: "h-5 w-5", "aria-hidden": "true" }) })
|
|
1885
|
+
] }),
|
|
1886
|
+
outline
|
|
1887
|
+
] })
|
|
1888
|
+
] })
|
|
1889
|
+
]
|
|
1890
|
+
}
|
|
1891
|
+
);
|
|
1892
|
+
}
|
|
1893
|
+
function toggleOption(chosen, optionId) {
|
|
1894
|
+
const next = new Set(chosen);
|
|
1895
|
+
if (next.has(optionId)) next.delete(optionId);
|
|
1896
|
+
else next.add(optionId);
|
|
1897
|
+
return [...next];
|
|
1898
|
+
}
|
|
1899
|
+
function QuizView({
|
|
1900
|
+
body,
|
|
1901
|
+
summary,
|
|
1902
|
+
answers,
|
|
1903
|
+
result,
|
|
1904
|
+
busy,
|
|
1905
|
+
labels,
|
|
1906
|
+
onAnswer,
|
|
1907
|
+
onSubmit,
|
|
1908
|
+
onRetry
|
|
1909
|
+
}) {
|
|
1910
|
+
const questions = body?.questions ?? [];
|
|
1911
|
+
if (!body || questions.length === 0) return /* @__PURE__ */ jsx15("p", { className: "text-sm text-[var(--site-fg-muted,#71717a)]", children: labels.quizNotReady });
|
|
1912
|
+
const practice = (body.settings.mode ?? summary?.mode ?? "graded") === "practice";
|
|
1913
|
+
const revealed = result?.reveal ? new Map(result.reveal.questions.map((q) => [q.id, q])) : null;
|
|
1914
|
+
const allAnswered = questions.every((q) => (answers[q.id] ?? []).some((v) => v.trim().length > 0));
|
|
1915
|
+
const attemptsLeft = practice || summary?.maxAttempts == null ? null : Math.max(0, summary.maxAttempts - summary.attemptsUsed - (result ? 1 : 0));
|
|
1916
|
+
const alreadyPassed = !practice && !result && Boolean(summary?.passed);
|
|
1917
|
+
const outOfAttempts = !practice && !result && !alreadyPassed && attemptsLeft === 0;
|
|
1918
|
+
const muted = "text-[var(--site-fg-muted,#71717a)]";
|
|
1919
|
+
const border = "border-[var(--site-border,rgba(0,0,0,0.12))]";
|
|
1920
|
+
const fg = "text-[var(--site-fg,#18181b)]";
|
|
1921
|
+
const primaryButton = "min-h-10 rounded-[var(--site-radius-button,0.5rem)] px-3.5 text-sm font-medium text-[var(--brand-fg,#ffffff)] disabled:opacity-40";
|
|
1922
|
+
return /* @__PURE__ */ jsxs9("div", { className: "space-y-5", children: [
|
|
1923
|
+
practice ? /* @__PURE__ */ jsx15("p", { className: cn("text-xs", muted), children: labels.quizPracticeHint }) : /* @__PURE__ */ jsxs9("p", { className: cn("text-xs", muted), children: [
|
|
1924
|
+
fill2(labels.quizPassingScore, { percent: body.settings.passingPercent }),
|
|
1925
|
+
attemptsLeft !== null && !alreadyPassed && !result?.passed ? ` \xB7 ${fill2(labels.quizAttemptsLeft, { count: attemptsLeft })}` : ""
|
|
1926
|
+
] }),
|
|
1927
|
+
alreadyPassed && /* @__PURE__ */ jsxs9("p", { className: "inline-flex items-center gap-1 text-sm text-emerald-600 dark:text-emerald-400", children: [
|
|
1928
|
+
/* @__PURE__ */ jsx15(CircleCheck, { className: "h-4 w-4" }),
|
|
1929
|
+
" ",
|
|
1930
|
+
labels.quizPassed,
|
|
1931
|
+
summary?.bestScore != null ? ` \xB7 ${fill2(labels.quizScore, { score: summary.bestScore })}` : ""
|
|
1932
|
+
] }),
|
|
1933
|
+
/* @__PURE__ */ jsx15("ol", { className: "space-y-4", children: questions.map((q, index) => {
|
|
1934
|
+
const multiple = q.type === "multiple";
|
|
1935
|
+
const isText = q.type === "short_text" || q.type === "numeric";
|
|
1936
|
+
const chosen = new Set(answers[q.id] ?? []);
|
|
1937
|
+
const reveal = revealed?.get(q.id);
|
|
1938
|
+
const correctSet = reveal ? new Set(reveal.correctOptionIds) : null;
|
|
1939
|
+
const outcome = result ? result.perQuestion[q.id] ?? null : null;
|
|
1940
|
+
const locked = Boolean(result) || busy || alreadyPassed || outOfAttempts;
|
|
1941
|
+
return /* @__PURE__ */ jsxs9("li", { className: cn("rounded-[var(--site-radius-media,0.75rem)] border p-4", border), children: [
|
|
1942
|
+
/* @__PURE__ */ jsxs9("p", { className: cn("flex items-start gap-2 text-sm font-medium", fg), children: [
|
|
1943
|
+
outcome === true ? /* @__PURE__ */ jsx15(CircleCheck, { className: "mt-0.5 h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400", "aria-label": labels.quizCorrectMark }) : outcome === false ? /* @__PURE__ */ jsx15(CircleX, { className: "mt-0.5 h-4 w-4 shrink-0 text-red-600 dark:text-red-400", "aria-label": labels.quizWrongMark }) : null,
|
|
1944
|
+
/* @__PURE__ */ jsxs9("span", { children: [
|
|
1945
|
+
index + 1,
|
|
1946
|
+
". ",
|
|
1947
|
+
q.prompt,
|
|
1948
|
+
multiple ? /* @__PURE__ */ jsx15("span", { className: cn("ml-2 text-xs font-normal", muted), children: labels.quizSelectAll }) : null
|
|
1949
|
+
] })
|
|
1950
|
+
] }),
|
|
1951
|
+
q.image ? (
|
|
1952
|
+
// eslint-disable-next-line @next/next/no-img-element -- 共用元件也在 Elements 跑,沒有 next/image
|
|
1953
|
+
/* @__PURE__ */ jsx15("img", { src: q.image.url, alt: q.image.alt ?? "", width: q.image.width ?? void 0, height: q.image.height ?? void 0, loading: "lazy", className: "mt-3 max-h-80 w-auto max-w-full rounded-[var(--site-radius-media,0.75rem)]" })
|
|
1954
|
+
) : null,
|
|
1955
|
+
isText ? /* @__PURE__ */ jsxs9("div", { className: "mt-3", children: [
|
|
1956
|
+
/* @__PURE__ */ jsx15(
|
|
1957
|
+
Input,
|
|
1958
|
+
{
|
|
1959
|
+
type: "text",
|
|
1960
|
+
inputMode: q.type === "numeric" ? "decimal" : void 0,
|
|
1961
|
+
value: answers[q.id]?.[0] ?? "",
|
|
1962
|
+
disabled: locked,
|
|
1963
|
+
maxLength: 500,
|
|
1964
|
+
placeholder: q.type === "numeric" ? labels.quizNumericPlaceholder : labels.quizTextPlaceholder,
|
|
1965
|
+
"aria-label": q.prompt,
|
|
1966
|
+
onChange: (event) => onAnswer(q.id, event.target.value ? [event.target.value] : []),
|
|
1967
|
+
className: cn(
|
|
1968
|
+
"rounded-lg bg-transparent dark:bg-transparent disabled:cursor-default disabled:opacity-100",
|
|
1969
|
+
border,
|
|
1970
|
+
fg,
|
|
1971
|
+
outcome === true && "bg-emerald-50 dark:bg-emerald-950/30",
|
|
1972
|
+
outcome === false && "bg-red-50 dark:bg-red-950/30"
|
|
1973
|
+
)
|
|
1974
|
+
}
|
|
1975
|
+
),
|
|
1976
|
+
reveal && reveal.acceptedAnswers && reveal.acceptedAnswers.length > 0 ? /* @__PURE__ */ jsx15("p", { className: cn("mt-2 text-xs", muted), children: fill2(labels.quizAcceptedAnswers, { answers: reveal.acceptedAnswers.join(" / ") }) }) : null
|
|
1977
|
+
] }) : (
|
|
1978
|
+
// 選項有圖時排成格狀卡片(Google Forms:圖在上、圈選與文字在下),沒有圖照舊一列一個
|
|
1979
|
+
/* @__PURE__ */ jsx15("ul", { role: multiple ? "group" : "radiogroup", "aria-label": q.prompt, className: cn("mt-3", q.options.some((o) => o.image) ? "grid grid-cols-2 gap-2 sm:grid-cols-3" : "space-y-2"), children: q.options.map((option) => {
|
|
1980
|
+
const checked = chosen.has(option.id);
|
|
1981
|
+
const isCorrect = correctSet ? correctSet.has(option.id) : null;
|
|
1982
|
+
return /* @__PURE__ */ jsx15("li", { children: /* @__PURE__ */ jsxs9(
|
|
1983
|
+
"button",
|
|
1984
|
+
{
|
|
1985
|
+
type: "button",
|
|
1986
|
+
role: multiple ? "checkbox" : "radio",
|
|
1987
|
+
"aria-checked": checked,
|
|
1988
|
+
disabled: locked,
|
|
1989
|
+
onClick: () => onAnswer(q.id, multiple ? toggleOption(chosen, option.id) : [option.id]),
|
|
1990
|
+
className: cn(
|
|
1991
|
+
"w-full rounded-lg border text-left text-sm disabled:cursor-default",
|
|
1992
|
+
option.image ? "flex h-full flex-col gap-2 p-2" : "flex items-start gap-2 px-3 py-2",
|
|
1993
|
+
border,
|
|
1994
|
+
fg,
|
|
1995
|
+
checked && "border-[var(--brand-color,#18181b)]",
|
|
1996
|
+
isCorrect === true && "bg-emerald-50 dark:bg-emerald-950/30",
|
|
1997
|
+
isCorrect === false && checked && "bg-red-50 dark:bg-red-950/30"
|
|
1998
|
+
),
|
|
1999
|
+
children: [
|
|
2000
|
+
option.image ? (
|
|
2001
|
+
// 點圖也是選這個選項;圖保留原比例、最高 192px
|
|
2002
|
+
// eslint-disable-next-line @next/next/no-img-element -- 共用元件也在 Elements 跑,沒有 next/image
|
|
2003
|
+
/* @__PURE__ */ jsx15("img", { src: option.image.url, alt: option.image.alt ?? "", width: option.image.width ?? void 0, height: option.image.height ?? void 0, loading: "lazy", className: "block max-h-48 w-full rounded-md object-contain" })
|
|
2004
|
+
) : null,
|
|
2005
|
+
/* @__PURE__ */ jsxs9("span", { className: cn("flex items-start gap-2", option.image ? "px-1 pb-1" : "contents"), children: [
|
|
2006
|
+
/* @__PURE__ */ jsx15(
|
|
2007
|
+
"span",
|
|
2008
|
+
{
|
|
2009
|
+
"aria-hidden": true,
|
|
2010
|
+
className: cn(
|
|
2011
|
+
"mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center border",
|
|
2012
|
+
multiple ? "rounded" : "rounded-full",
|
|
2013
|
+
checked ? "border-[var(--brand-color,#18181b)] bg-[var(--brand-color,#18181b)] text-[var(--brand-fg,#ffffff)]" : "border-[var(--site-border,rgba(0,0,0,0.3))]"
|
|
2014
|
+
),
|
|
2015
|
+
children: checked ? /* @__PURE__ */ jsx15(Check, { className: "h-3 w-3" }) : null
|
|
2016
|
+
}
|
|
2017
|
+
),
|
|
2018
|
+
/* @__PURE__ */ jsx15("span", { className: "min-w-0", children: option.text })
|
|
2019
|
+
] })
|
|
2020
|
+
]
|
|
2021
|
+
}
|
|
2022
|
+
) }, option.id);
|
|
2023
|
+
}) })
|
|
2024
|
+
),
|
|
2025
|
+
reveal?.explanation ? /* @__PURE__ */ jsx15("p", { className: cn("mt-2 text-xs", muted), children: reveal.explanation }) : null
|
|
2026
|
+
] }, q.id);
|
|
2027
|
+
}) }),
|
|
2028
|
+
result ? /* @__PURE__ */ jsx15("div", { className: cn("rounded-[var(--site-radius-media,0.75rem)] border p-4 text-sm", border), children: practice ? /* @__PURE__ */ jsxs9(Fragment6, { children: [
|
|
2029
|
+
/* @__PURE__ */ jsx15("p", { className: cn("font-medium", fg), children: fill2(labels.quizCorrectCount, { correct: result.correct, total: result.total }) }),
|
|
2030
|
+
/* @__PURE__ */ jsx15("button", { type: "button", onClick: onRetry, className: cn("mt-3", primaryButton), style: { backgroundColor: "var(--brand-color,#18181b)" }, children: labels.quizPracticeAgain })
|
|
2031
|
+
] }) : /* @__PURE__ */ jsxs9(Fragment6, { children: [
|
|
2032
|
+
/* @__PURE__ */ jsxs9("p", { className: cn("font-medium", result.passed ? "text-emerald-600 dark:text-emerald-400" : fg), children: [
|
|
2033
|
+
fill2(labels.quizScore, { score: result.score }),
|
|
2034
|
+
" \xB7 ",
|
|
2035
|
+
result.passed ? labels.quizPassed : fill2(labels.quizFailed, { percent: body.settings.passingPercent }),
|
|
2036
|
+
/* @__PURE__ */ jsx15("span", { className: cn("ml-2 text-xs font-normal", muted), children: fill2(labels.quizCorrectCount, { correct: result.correct, total: result.total }) })
|
|
2037
|
+
] }),
|
|
2038
|
+
!result.passed && (result.canRetry ? /* @__PURE__ */ jsx15("button", { type: "button", onClick: onRetry, className: cn("mt-3", primaryButton), style: { backgroundColor: "var(--brand-color,#18181b)" }, children: labels.quizRetry }) : /* @__PURE__ */ jsx15("p", { className: cn("mt-2 text-xs", muted), children: labels.quizNoAttempts }))
|
|
2039
|
+
] }) }) : outOfAttempts ? /* @__PURE__ */ jsx15("p", { className: cn("text-sm", muted), children: labels.quizNoAttempts }) : alreadyPassed ? null : /* @__PURE__ */ jsx15("button", { type: "button", onClick: onSubmit, disabled: !allAnswered || busy, className: primaryButton, style: { backgroundColor: "var(--brand-color,#18181b)" }, children: labels.quizSubmit })
|
|
2040
|
+
] });
|
|
2041
|
+
}
|
|
2042
|
+
export {
|
|
2043
|
+
DeliverablePlayer,
|
|
2044
|
+
deliverablePlayerLabels
|
|
2045
|
+
};
|
|
2046
|
+
//# sourceMappingURL=deliverables-Z6ZBT6D3.js.map
|