@texonom/nreact 1.4.7 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/build/_commonjsHelpers-bAxELxBV.js +9 -0
  2. package/build/_commonjsHelpers-bAxELxBV.js.map +1 -0
  3. package/build/asset-wrapper-CmbIDPIw.js +921 -0
  4. package/build/asset-wrapper-CmbIDPIw.js.map +1 -0
  5. package/build/block.d.ts +20 -20
  6. package/build/collection-column-title-l4hmVo49.js +99 -0
  7. package/build/collection-column-title-l4hmVo49.js.map +1 -0
  8. package/build/components/asset-wrapper.d.ts +6 -6
  9. package/build/components/asset.d.ts +7 -7
  10. package/build/components/audio.d.ts +6 -6
  11. package/build/components/checkbox.d.ts +5 -5
  12. package/build/components/eoi.d.ts +7 -7
  13. package/build/components/file.d.ts +6 -6
  14. package/build/components/google-drive.d.ts +6 -6
  15. package/build/components/graceful-image.d.ts +3 -3
  16. package/build/components/header.d.ts +15 -15
  17. package/build/components/lazy-image.d.ts +13 -13
  18. package/build/components/lite-youtube-embed.d.ts +13 -13
  19. package/build/components/page-aside.d.ts +11 -11
  20. package/build/components/page-icon.d.ts +16 -16
  21. package/build/components/page-title.d.ts +12 -12
  22. package/build/components/search-dialog.d.ts +26 -26
  23. package/build/components/search-dialog.d.ts.map +1 -1
  24. package/build/components/sync-pointer-block.d.ts +6 -6
  25. package/build/components/text.d.ts +19 -19
  26. package/build/context.d.ts +64 -64
  27. package/build/context.d.ts.map +1 -1
  28. package/build/icons/check.d.ts +3 -3
  29. package/build/icons/chevron-down-icon.d.ts +2 -2
  30. package/build/icons/clear-icon.d.ts +2 -2
  31. package/build/icons/collection-view-board.d.ts +3 -3
  32. package/build/icons/collection-view-calendar.d.ts +3 -3
  33. package/build/icons/collection-view-gallery.d.ts +3 -3
  34. package/build/icons/collection-view-icon.d.ts +8 -8
  35. package/build/icons/collection-view-list.d.ts +3 -3
  36. package/build/icons/collection-view-table.d.ts +3 -3
  37. package/build/icons/copy.d.ts +3 -3
  38. package/build/icons/default-page-icon.d.ts +2 -2
  39. package/build/icons/empty-icon.d.ts +2 -2
  40. package/build/icons/file-icon.d.ts +2 -2
  41. package/build/icons/link-icon.d.ts +2 -2
  42. package/build/icons/loading-icon.d.ts +2 -2
  43. package/build/icons/property-icon.d.ts +44 -44
  44. package/build/icons/search-icon.d.ts +2 -2
  45. package/build/icons/type-checkbox.d.ts +3 -3
  46. package/build/icons/type-date.d.ts +3 -3
  47. package/build/icons/type-email.d.ts +3 -3
  48. package/build/icons/type-file.d.ts +3 -3
  49. package/build/icons/type-formula.d.ts +3 -3
  50. package/build/icons/type-github.d.ts +3 -3
  51. package/build/icons/type-multi-select.d.ts +3 -3
  52. package/build/icons/type-number.d.ts +3 -3
  53. package/build/icons/type-person-2.d.ts +3 -3
  54. package/build/icons/type-person.d.ts +3 -3
  55. package/build/icons/type-phone-number.d.ts +3 -3
  56. package/build/icons/type-relation.d.ts +3 -3
  57. package/build/icons/type-select.d.ts +3 -3
  58. package/build/icons/type-text.d.ts +3 -3
  59. package/build/icons/type-timestamp.d.ts +3 -3
  60. package/build/icons/type-title.d.ts +3 -3
  61. package/build/icons/type-url.d.ts +3 -3
  62. package/build/index.d.ts +24 -24
  63. package/build/index.js +478 -691
  64. package/build/index.js.map +1 -0
  65. package/build/next.d.ts +1 -1
  66. package/build/renderer.d.ts +50 -50
  67. package/build/third-party/code.d.ts +7 -16
  68. package/build/third-party/code.js +174 -114
  69. package/build/third-party/code.js.map +1 -0
  70. package/build/third-party/collection-card.d.ts +3 -3
  71. package/build/third-party/collection-card.d.ts.map +1 -1
  72. package/build/third-party/collection-column-title.d.ts +5 -5
  73. package/build/third-party/collection-group.d.ts +3 -3
  74. package/build/third-party/collection-row.d.ts +7 -7
  75. package/build/third-party/collection-utils.d.ts +2 -2
  76. package/build/third-party/collection-view-board.d.ts +3 -3
  77. package/build/third-party/collection-view-gallery.d.ts +3 -3
  78. package/build/third-party/collection-view-list.d.ts +3 -3
  79. package/build/third-party/collection-view-table.d.ts +3 -3
  80. package/build/third-party/collection-view.d.ts +4 -4
  81. package/build/third-party/collection.d.ts +14 -14
  82. package/build/third-party/collection.js +2295 -3321
  83. package/build/third-party/collection.js.map +1 -0
  84. package/build/third-party/equation.d.ts +8 -8
  85. package/build/third-party/equation.js +35 -25
  86. package/build/third-party/equation.js.map +1 -0
  87. package/build/third-party/eval-formula.d.ts +20 -20
  88. package/build/third-party/modal.d.ts +2 -2
  89. package/build/third-party/modal.js +3 -5
  90. package/build/third-party/modal.js.map +1 -0
  91. package/build/third-party/pdf.d.ts +4 -4
  92. package/build/third-party/property.d.ts +21 -21
  93. package/build/types.d.ts +93 -93
  94. package/build/utils.d.ts +6 -6
  95. package/package.json +13 -13
  96. package/readme.md +59 -0
  97. package/LICENSE +0 -21
  98. package/README.md +0 -19
  99. package/build/.tsbuildinfo +0 -1
  100. package/build/chunk-2U7I3XVC.js +0 -157
  101. package/build/chunk-72RHNPWF.js +0 -1307
  102. package/build/chunk-C6BUIPAM.js +0 -83
  103. package/build/chunk-FCO7MUK6.js +0 -83
  104. package/build/chunk-H4QYS6CQ.js +0 -1185
  105. package/build/chunk-IMWLLIUB.js +0 -1182
  106. package/build/chunk-P7HX4BAT.js +0 -156
  107. package/build/chunk-VP33CFNB.js +0 -1358
  108. package/build/chunk-YMM43AZ3.js +0 -1207
  109. package/build/dev/chunk-64UJZ76E.js +0 -1308
  110. package/build/dev/chunk-64UJZ76E.js.map +0 -1
  111. package/build/dev/chunk-ABDRHJEI.js +0 -157
  112. package/build/dev/chunk-ABDRHJEI.js.map +0 -1
  113. package/build/dev/chunk-N6EDMIQD.js +0 -1359
  114. package/build/dev/chunk-N6EDMIQD.js.map +0 -1
  115. package/build/dev/chunk-OAIRL2FN.js +0 -84
  116. package/build/dev/chunk-OAIRL2FN.js.map +0 -1
  117. package/build/dev/chunk-P3V5A3W4.js +0 -1183
  118. package/build/dev/chunk-P3V5A3W4.js.map +0 -1
  119. package/build/dev/chunk-PM5CWL6O.js +0 -158
  120. package/build/dev/chunk-PM5CWL6O.js.map +0 -1
  121. package/build/dev/chunk-Q4G2SZRD.js +0 -84
  122. package/build/dev/chunk-Q4G2SZRD.js.map +0 -1
  123. package/build/dev/chunk-SEA7YL2O.js +0 -1308
  124. package/build/dev/chunk-SEA7YL2O.js.map +0 -1
  125. package/build/dev/chunk-SVHGWLRK.js +0 -1208
  126. package/build/dev/chunk-SVHGWLRK.js.map +0 -1
  127. package/build/dev/chunk-ZJAJPWJX.js +0 -1186
  128. package/build/dev/chunk-ZJAJPWJX.js.map +0 -1
  129. package/build/dev/index.js +0 -890
  130. package/build/dev/index.js.map +0 -1
  131. package/build/dev/third-party/code.js +0 -140
  132. package/build/dev/third-party/code.js.map +0 -1
  133. package/build/dev/third-party/collection.js +0 -4382
  134. package/build/dev/third-party/collection.js.map +0 -1
  135. package/build/dev/third-party/equation.js +0 -35
  136. package/build/dev/third-party/equation.js.map +0 -1
  137. package/build/dev/third-party/modal.js +0 -8
  138. package/build/dev/third-party/modal.js.map +0 -1
  139. package/build/dev/third-party/pdf.js +0 -21
  140. package/build/dev/third-party/pdf.js.map +0 -1
  141. package/build/third-party/pdf.js +0 -20
@@ -1,1307 +0,0 @@
1
- import {
2
- __async,
3
- __commonJS,
4
- __objRest,
5
- __spreadProps,
6
- __spreadValues,
7
- __toESM
8
- } from "./chunk-C6BUIPAM.js";
9
-
10
- // ../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
11
- var require_lodash = __commonJS({
12
- "../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module) {
13
- var FUNC_ERROR_TEXT = "Expected a function";
14
- var NAN = 0 / 0;
15
- var symbolTag = "[object Symbol]";
16
- var reTrim = /^\s+|\s+$/g;
17
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
18
- var reIsBinary = /^0b[01]+$/i;
19
- var reIsOctal = /^0o[0-7]+$/i;
20
- var freeParseInt = parseInt;
21
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
22
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
23
- var root = freeGlobal || freeSelf || Function("return this")();
24
- var objectProto = Object.prototype;
25
- var objectToString = objectProto.toString;
26
- var nativeMax = Math.max;
27
- var nativeMin = Math.min;
28
- var now = function() {
29
- return root.Date.now();
30
- };
31
- function debounce(func, wait, options) {
32
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
33
- if (typeof func != "function") {
34
- throw new TypeError(FUNC_ERROR_TEXT);
35
- }
36
- wait = toNumber(wait) || 0;
37
- if (isObject(options)) {
38
- leading = !!options.leading;
39
- maxing = "maxWait" in options;
40
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
41
- trailing = "trailing" in options ? !!options.trailing : trailing;
42
- }
43
- function invokeFunc(time) {
44
- var args = lastArgs, thisArg = lastThis;
45
- lastArgs = lastThis = void 0;
46
- lastInvokeTime = time;
47
- result = func.apply(thisArg, args);
48
- return result;
49
- }
50
- function leadingEdge(time) {
51
- lastInvokeTime = time;
52
- timerId = setTimeout(timerExpired, wait);
53
- return leading ? invokeFunc(time) : result;
54
- }
55
- function remainingWait(time) {
56
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
57
- return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
58
- }
59
- function shouldInvoke(time) {
60
- var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
61
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
62
- }
63
- function timerExpired() {
64
- var time = now();
65
- if (shouldInvoke(time)) {
66
- return trailingEdge(time);
67
- }
68
- timerId = setTimeout(timerExpired, remainingWait(time));
69
- }
70
- function trailingEdge(time) {
71
- timerId = void 0;
72
- if (trailing && lastArgs) {
73
- return invokeFunc(time);
74
- }
75
- lastArgs = lastThis = void 0;
76
- return result;
77
- }
78
- function cancel() {
79
- if (timerId !== void 0) {
80
- clearTimeout(timerId);
81
- }
82
- lastInvokeTime = 0;
83
- lastArgs = lastCallTime = lastThis = timerId = void 0;
84
- }
85
- function flush() {
86
- return timerId === void 0 ? result : trailingEdge(now());
87
- }
88
- function debounced() {
89
- var time = now(), isInvoking = shouldInvoke(time);
90
- lastArgs = arguments;
91
- lastThis = this;
92
- lastCallTime = time;
93
- if (isInvoking) {
94
- if (timerId === void 0) {
95
- return leadingEdge(lastCallTime);
96
- }
97
- if (maxing) {
98
- timerId = setTimeout(timerExpired, wait);
99
- return invokeFunc(lastCallTime);
100
- }
101
- }
102
- if (timerId === void 0) {
103
- timerId = setTimeout(timerExpired, wait);
104
- }
105
- return result;
106
- }
107
- debounced.cancel = cancel;
108
- debounced.flush = flush;
109
- return debounced;
110
- }
111
- function throttle2(func, wait, options) {
112
- var leading = true, trailing = true;
113
- if (typeof func != "function") {
114
- throw new TypeError(FUNC_ERROR_TEXT);
115
- }
116
- if (isObject(options)) {
117
- leading = "leading" in options ? !!options.leading : leading;
118
- trailing = "trailing" in options ? !!options.trailing : trailing;
119
- }
120
- return debounce(func, wait, {
121
- "leading": leading,
122
- "maxWait": wait,
123
- "trailing": trailing
124
- });
125
- }
126
- function isObject(value) {
127
- var type = typeof value;
128
- return !!value && (type == "object" || type == "function");
129
- }
130
- function isObjectLike(value) {
131
- return !!value && typeof value == "object";
132
- }
133
- function isSymbol(value) {
134
- return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
135
- }
136
- function toNumber(value) {
137
- if (typeof value == "number") {
138
- return value;
139
- }
140
- if (isSymbol(value)) {
141
- return NAN;
142
- }
143
- if (isObject(value)) {
144
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
145
- value = isObject(other) ? other + "" : other;
146
- }
147
- if (typeof value != "string") {
148
- return value === 0 ? value : +value;
149
- }
150
- value = value.replace(reTrim, "");
151
- var isBinary = reIsBinary.test(value);
152
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
153
- }
154
- module.exports = throttle2;
155
- }
156
- });
157
-
158
- // src/components/checkbox.tsx
159
- import React2 from "react";
160
-
161
- // src/icons/check.tsx
162
- import React from "react";
163
- function SvgCheck(props) {
164
- return /* @__PURE__ */ React.createElement("svg", __spreadValues({ viewBox: "0 0 14 14" }, props), /* @__PURE__ */ React.createElement("path", { d: "M5.5 12L14 3.5 12.5 2l-7 7-4-4.003L0 6.499z" }));
165
- }
166
- var check_default = SvgCheck;
167
-
168
- // src/components/checkbox.tsx
169
- var Checkbox = ({ isChecked }) => {
170
- let content = null;
171
- if (isChecked)
172
- content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-checked" }, /* @__PURE__ */ React2.createElement(check_default, null));
173
- else content = /* @__PURE__ */ React2.createElement("div", { className: "notion-property-checkbox-unchecked" });
174
- return /* @__PURE__ */ React2.createElement("span", { className: "notion-property notion-property-checkbox" }, content);
175
- };
176
-
177
- // src/utils.ts
178
- import { isUrl, formatDate, formatNotionDateTime } from "@texonom/nutils";
179
- var groupBlockContent = (blockMap) => {
180
- const output = [];
181
- let lastType = void 0;
182
- let index = -1;
183
- Object.keys(blockMap).forEach((id) => {
184
- var _a, _b;
185
- const blockValue = (_a = blockMap[id]) == null ? void 0 : _a.value;
186
- if (blockValue)
187
- (_b = blockValue.content) == null ? void 0 : _b.forEach((blockId) => {
188
- var _a2, _b2;
189
- const blockType = (_b2 = (_a2 = blockMap[blockId]) == null ? void 0 : _a2.value) == null ? void 0 : _b2.type;
190
- if (blockType && blockType !== lastType) {
191
- index++;
192
- lastType = blockType;
193
- output[index] = [];
194
- }
195
- if (index > -1) output[index].push(blockId);
196
- });
197
- lastType = void 0;
198
- });
199
- return output;
200
- };
201
- var getListNumber = (blockId, blockMap) => {
202
- const groups = groupBlockContent(blockMap);
203
- const group = groups.find((g) => g.includes(blockId));
204
- if (!group) return;
205
- return group.indexOf(blockId) + 1;
206
- };
207
- var getHashFragmentValue = (url) => {
208
- return url.includes("#") ? url.replace(/^.+(#.+)$/, "$1") : "";
209
- };
210
- var isBrowser = typeof window !== "undefined";
211
- var youtubeDomains = /* @__PURE__ */ new Set([
212
- "youtu.be",
213
- "youtube.com",
214
- "www.youtube.com",
215
- "youtube-nocookie.com",
216
- "www.youtube-nocookie.com"
217
- ]);
218
- var getYoutubeId = (url) => {
219
- try {
220
- const { hostname } = new URL(url);
221
- if (!youtubeDomains.has(hostname)) return null;
222
- const regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i;
223
- const match = url.match(regExp);
224
- if (match && match[2].length == 11) return match[2];
225
- } catch (e) {
226
- }
227
- return null;
228
- };
229
-
230
- // src/components/page-icon.tsx
231
- import React20 from "react";
232
- import { getBlockIcon, getBlockTitle as getBlockTitle3 } from "@texonom/nutils";
233
-
234
- // src/context.tsx
235
- import React18 from "react";
236
- import { defaultMapImageUrl, defaultMapPageUrl } from "@texonom/nutils";
237
-
238
- // src/components/asset-wrapper.tsx
239
- import React11 from "react";
240
- import { parsePageId as parsePageId2 } from "@texonom/nutils";
241
-
242
- // src/components/asset.tsx
243
- import React5 from "react";
244
- import { getTextContent } from "@texonom/nutils";
245
-
246
- // src/components/lazy-image.tsx
247
- import React3 from "react";
248
- import { normalizeUrl } from "@texonom/nutils";
249
- var LazyImage = (_a) => {
250
- var _b = _a, { src, alt, className, style, zoomable = false, priority = false, height } = _b, rest = __objRest(_b, ["src", "alt", "className", "style", "zoomable", "priority", "height"]);
251
- var _a2, _b2, _c;
252
- const { recordMap, zoom, previewImages, forceCustomImages, components } = useNotionContext();
253
- const zoomRef = React3.useRef(zoom ? zoom.clone() : null);
254
- const previewImage = previewImages ? (_c = (_a2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _a2[src]) != null ? _c : (_b2 = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _b2[normalizeUrl(src)] : null;
255
- const onLoad = React3.useCallback(
256
- (e) => {
257
- if (zoomable && (e.target.src || e.target.srcset)) {
258
- if (zoomRef.current) zoomRef.current.attach(e.target);
259
- }
260
- },
261
- [zoomRef, zoomable]
262
- );
263
- const attachZoom = React3.useCallback(
264
- (image) => {
265
- if (zoomRef.current && image) zoomRef.current.attach(image);
266
- },
267
- [zoomRef]
268
- );
269
- const attachZoomRef = React3.useMemo(() => zoomable ? attachZoom : void 0, [zoomable, attachZoom]);
270
- if (previewImage && components.Image) {
271
- return /* @__PURE__ */ React3.createElement(
272
- components.Image,
273
- {
274
- src,
275
- alt,
276
- style,
277
- className,
278
- width: previewImage.originalWidth,
279
- height: previewImage.originalHeight,
280
- blurDataURL: previewImage.dataURIBase64,
281
- placeholder: "blur",
282
- priority,
283
- onLoad
284
- }
285
- );
286
- } else {
287
- if (components.Image && forceCustomImages)
288
- return /* @__PURE__ */ React3.createElement(
289
- components.Image,
290
- {
291
- src,
292
- alt,
293
- className,
294
- style,
295
- width: null,
296
- height: height || null,
297
- priority,
298
- onLoad
299
- }
300
- );
301
- return /* @__PURE__ */ React3.createElement(
302
- "img",
303
- __spreadValues({
304
- className,
305
- style,
306
- src,
307
- alt,
308
- ref: attachZoomRef,
309
- loading: "lazy",
310
- decoding: "async"
311
- }, rest)
312
- );
313
- }
314
- };
315
-
316
- // src/components/lite-youtube-embed.tsx
317
- import React4 from "react";
318
- var qs = (params) => {
319
- return Object.keys(params).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join("&");
320
- };
321
- var LiteYouTubeEmbed = ({
322
- id,
323
- defaultPlay = false,
324
- mute = false,
325
- lazyImage = false,
326
- iframeTitle = "YouTube video",
327
- alt = "Video preview",
328
- params = {},
329
- adLinksPreconnect = true,
330
- style,
331
- className
332
- }) => {
333
- const muteParam = mute || defaultPlay ? "1" : "0";
334
- const queryString = React4.useMemo(() => qs(__spreadValues({ autoplay: "1", mute: muteParam }, params)), [muteParam, params]);
335
- const resolution = "hqdefault";
336
- const posterUrl = `https://i.ytimg.com/vi/${id}/${resolution}.jpg`;
337
- const ytUrl = "https://www.youtube-nocookie.com";
338
- const iframeSrc = `${ytUrl}/embed/${id}?${queryString}`;
339
- const [isPreconnected, setIsPreconnected] = React4.useState(false);
340
- const [iframeInitialized, setIframeInitialized] = React4.useState(defaultPlay);
341
- const [isIframeLoaded, setIsIframeLoaded] = React4.useState(false);
342
- const warmConnections = React4.useCallback(() => {
343
- if (isPreconnected) return;
344
- setIsPreconnected(true);
345
- }, [isPreconnected]);
346
- const onLoadIframe = React4.useCallback(() => {
347
- if (iframeInitialized) return;
348
- setIframeInitialized(true);
349
- }, [iframeInitialized]);
350
- const onIframeLoaded = React4.useCallback(() => {
351
- setIsIframeLoaded(true);
352
- }, []);
353
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preload", href: posterUrl, as: "image" }), isPreconnected && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: ytUrl }), /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://www.google.com" })), isPreconnected && adLinksPreconnect && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://static.doubleclick.net" }), /* @__PURE__ */ React4.createElement("link", { rel: "preconnect", href: "https://googleads.g.doubleclick.net" })), /* @__PURE__ */ React4.createElement(
354
- "div",
355
- {
356
- onClick: onLoadIframe,
357
- onPointerOver: warmConnections,
358
- className: `notion-yt-lite
359
- ${isIframeLoaded && "notion-yt-loaded"}
360
- ${iframeInitialized && "notion-yt-initialized"}
361
- ${className || ""}`,
362
- style
363
- },
364
- /* @__PURE__ */ React4.createElement("img", { src: posterUrl, className: "notion-yt-thumbnail", loading: lazyImage ? "lazy" : void 0, alt }),
365
- /* @__PURE__ */ React4.createElement("div", { className: "notion-yt-playbtn" }),
366
- iframeInitialized && /* @__PURE__ */ React4.createElement(
367
- "iframe",
368
- {
369
- width: "560",
370
- height: "315",
371
- frameBorder: "0",
372
- allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
373
- allowFullScreen: true,
374
- title: iframeTitle,
375
- src: iframeSrc,
376
- onLoad: onIframeLoaded
377
- }
378
- )
379
- ));
380
- };
381
-
382
- // src/components/asset.tsx
383
- var isServer = typeof window === "undefined";
384
- var supportedAssetTypes = [
385
- "video",
386
- "image",
387
- "embed",
388
- "figma",
389
- "typeform",
390
- "excalidraw",
391
- "maps",
392
- "tweet",
393
- "pdf",
394
- "gist",
395
- "codepen",
396
- "drive"
397
- ];
398
- var Asset = ({ block, zoomable = true, children }) => {
399
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
400
- const { recordMap, mapImageUrl, components } = useNotionContext();
401
- if (!block || !supportedAssetTypes.includes(block.type)) return null;
402
- const style = {
403
- position: "relative",
404
- display: "flex",
405
- justifyContent: "center",
406
- alignSelf: "center",
407
- width: "100%",
408
- maxWidth: "100%",
409
- flexDirection: "column"
410
- };
411
- const assetStyle = {};
412
- if (block.format) {
413
- const { block_aspect_ratio, block_height, block_width, block_full_width, block_page_width, block_preserve_scale } = block.format;
414
- if (block_full_width || block_page_width) {
415
- if (block_full_width) style.width = "100vw";
416
- else style.width = "100%";
417
- if (block.type === "video") {
418
- if (block_height) style.height = block_height;
419
- else if (block_aspect_ratio) style.paddingBottom = `${block_aspect_ratio * 100}%`;
420
- else if (block_preserve_scale) style.objectFit = "contain";
421
- } else if (block_aspect_ratio && block.type !== "image") {
422
- style.paddingBottom = `${block_aspect_ratio * 100}%`;
423
- } else if (block_height) {
424
- style.height = block_height;
425
- } else if (block_preserve_scale) {
426
- if (block.type === "image") {
427
- style.height = "100%";
428
- } else {
429
- style.paddingBottom = "75%";
430
- style.minHeight = 100;
431
- }
432
- }
433
- } else {
434
- switch ((_a = block.format) == null ? void 0 : _a.block_alignment) {
435
- case "center": {
436
- style.alignSelf = "center";
437
- break;
438
- }
439
- case "left": {
440
- style.alignSelf = "start";
441
- break;
442
- }
443
- case "right": {
444
- style.alignSelf = "end";
445
- break;
446
- }
447
- }
448
- if (block_width) style.width = block_width;
449
- if (block_preserve_scale && block.type !== "image") {
450
- style.paddingBottom = "50%";
451
- style.minHeight = 100;
452
- } else {
453
- if (block_height && block.type !== "image") style.height = block_height;
454
- }
455
- }
456
- if (block.type === "image") assetStyle.objectFit = "cover";
457
- else if (block_preserve_scale) assetStyle.objectFit = "contain";
458
- }
459
- let source = ((_b = recordMap.signed_urls) == null ? void 0 : _b[block.id]) || ((_e = (_d = (_c = block.properties) == null ? void 0 : _c.source) == null ? void 0 : _d[0]) == null ? void 0 : _e[0]);
460
- let content = null;
461
- if (!source) return null;
462
- if (block.type === "tweet") {
463
- const src = source;
464
- if (!src) return null;
465
- const id = src.split("?")[0].split("/").pop();
466
- if (!id) return null;
467
- content = /* @__PURE__ */ React5.createElement(
468
- "div",
469
- {
470
- style: __spreadProps(__spreadValues({}, assetStyle), {
471
- maxWidth: 420,
472
- width: "100%",
473
- marginLeft: "auto",
474
- marginRight: "auto"
475
- })
476
- },
477
- /* @__PURE__ */ React5.createElement(components.Tweet, { id })
478
- );
479
- } else if (block.type === "pdf") {
480
- style.overflow = "auto";
481
- style.background = "rgb(226, 226, 226)";
482
- style.display = "block";
483
- if (!style.padding) style.padding = "8px 16px";
484
- if (!isServer) content = /* @__PURE__ */ React5.createElement(components.Pdf, { file: source });
485
- } else if (block.type === "embed" || block.type === "video" || block.type === "figma" || block.type === "typeform" || block.type === "gist" || block.type === "maps" || block.type === "excalidraw" || block.type === "codepen" || block.type === "drive") {
486
- if (block.type === "video" && source && source.indexOf("youtube") < 0 && source.indexOf("youtu.be") < 0 && source.indexOf("vimeo") < 0 && source.indexOf("wistia") < 0 && source.indexOf("loom") < 0 && source.indexOf("videoask") < 0 && source.indexOf("getcloudapp") < 0) {
487
- style.paddingBottom = void 0;
488
- content = /* @__PURE__ */ React5.createElement("video", { playsInline: true, controls: true, preload: "metadata", style: assetStyle, src: source, title: block.type });
489
- } else {
490
- let src = ((_f = block.format) == null ? void 0 : _f.display_source) || source;
491
- if (src) {
492
- const youtubeVideoId = block.type === "video" ? getYoutubeId(src) : null;
493
- if (youtubeVideoId) {
494
- content = /* @__PURE__ */ React5.createElement(LiteYouTubeEmbed, { id: youtubeVideoId, style: assetStyle, className: "notion-asset-object-fit" });
495
- } else if (block.type === "gist") {
496
- if (!src.endsWith(".pibb")) src = `${src}.pibb`;
497
- assetStyle.width = "100%";
498
- style.paddingBottom = "50%";
499
- content = /* @__PURE__ */ React5.createElement(
500
- "iframe",
501
- {
502
- style: assetStyle,
503
- className: "notion-asset-object-fit",
504
- src,
505
- title: "GitHub Gist",
506
- frameBorder: "0",
507
- loading: "lazy",
508
- scrolling: "auto"
509
- }
510
- );
511
- } else {
512
- content = /* @__PURE__ */ React5.createElement(
513
- "iframe",
514
- {
515
- className: "notion-asset-object-fit",
516
- style: assetStyle,
517
- src,
518
- title: `iframe ${block.type}`,
519
- frameBorder: "0",
520
- allowFullScreen: true,
521
- loading: "lazy",
522
- scrolling: "auto"
523
- }
524
- );
525
- }
526
- }
527
- }
528
- } else if (block.type === "image") {
529
- if (source.includes("file.notion.so")) source = (_i = (_h = (_g = block.properties) == null ? void 0 : _g.source) == null ? void 0 : _h[0]) == null ? void 0 : _i[0];
530
- const src = mapImageUrl(source, block);
531
- const caption = getTextContent((_j = block.properties) == null ? void 0 : _j.caption);
532
- const alt = caption || "notion image";
533
- content = /* @__PURE__ */ React5.createElement(LazyImage, { src, alt, zoomable, height: style.height, style: assetStyle });
534
- }
535
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { style }, content, block.type === "image" && children), block.type !== "image" && children);
536
- };
537
-
538
- // src/components/text.tsx
539
- import React10 from "react";
540
- import { parsePageId } from "@texonom/nutils";
541
-
542
- // src/components/eoi.tsx
543
- import React7 from "react";
544
-
545
- // src/icons/type-github.tsx
546
- import React6 from "react";
547
- function SvgTypeGitHub(props) {
548
- return /* @__PURE__ */ React6.createElement("svg", __spreadValues({ viewBox: "0 0 260 260" }, props), /* @__PURE__ */ React6.createElement("g", null, /* @__PURE__ */ React6.createElement(
549
- "path",
550
- {
551
- d: "M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z",
552
- fill: "#161614"
553
- }
554
- )));
555
- }
556
- var type_github_default = SvgTypeGitHub;
557
-
558
- // src/components/eoi.tsx
559
- var EOI = ({ block, inline, className }) => {
560
- var _a, _b, _c;
561
- const { components } = useNotionContext();
562
- const { original_url, attributes, domain } = (block == null ? void 0 : block.format) || {};
563
- if (!original_url || !attributes) return null;
564
- const title = (_a = attributes.find((attr) => attr.id === "title")) == null ? void 0 : _a.values[0];
565
- let owner = (_b = attributes.find((attr) => attr.id === "owner")) == null ? void 0 : _b.values[0];
566
- const lastUpdatedAt = (_c = attributes.find((attr) => attr.id === "updated_at")) == null ? void 0 : _c.values[0];
567
- const lastUpdated = lastUpdatedAt ? formatNotionDateTime(lastUpdatedAt) : null;
568
- let externalImage;
569
- switch (domain) {
570
- case "github.com":
571
- externalImage = /* @__PURE__ */ React7.createElement(type_github_default, null);
572
- if (owner) {
573
- const parts = owner.split("/");
574
- owner = parts[parts.length - 1];
575
- }
576
- break;
577
- default:
578
- if (true)
579
- console.debug(`Unsupported external_object_instance domain "${domain}"`, JSON.stringify(block, null, 2));
580
- return null;
581
- }
582
- return /* @__PURE__ */ React7.createElement(
583
- components.Link,
584
- {
585
- target: "_blank",
586
- rel: "noopener noreferrer",
587
- href: original_url,
588
- className: `notion-external ${inline ? "notion-external-mention" : "notion-external-block notion-row"} ${className || ""}`
589
- },
590
- externalImage && /* @__PURE__ */ React7.createElement("div", { className: "notion-external-image" }, externalImage),
591
- /* @__PURE__ */ React7.createElement("div", { className: "notion-external-description" }, /* @__PURE__ */ React7.createElement("div", { className: "notion-external-title" }, title), (owner || lastUpdated) && /* @__PURE__ */ React7.createElement("div", { className: "notion-external-subtitle" }, owner && /* @__PURE__ */ React7.createElement("span", null, owner), owner && lastUpdated && /* @__PURE__ */ React7.createElement("span", null, " \u2022 "), lastUpdated && /* @__PURE__ */ React7.createElement("span", null, "Updated ", lastUpdated)))
592
- );
593
- };
594
-
595
- // src/components/graceful-image.tsx
596
- import React8 from "react";
597
- import { Img } from "react-image";
598
- var GracefulImage = (props) => {
599
- if (isBrowser) return /* @__PURE__ */ React8.createElement(Img, __spreadValues({}, props));
600
- else return /* @__PURE__ */ React8.createElement("img", __spreadValues({}, props));
601
- };
602
-
603
- // src/components/page-title.tsx
604
- import React9 from "react";
605
- import { getBlockTitle } from "@texonom/nutils";
606
- var PageTitleImpl = (_a) => {
607
- var _b = _a, { block, className, defaultIcon } = _b, rest = __objRest(_b, ["block", "className", "defaultIcon"]);
608
- var _a2, _b2;
609
- const { recordMap } = useNotionContext();
610
- if (!block) return null;
611
- if (block.type === "collection_view_page" || block.type === "collection_view") {
612
- const title = getBlockTitle(block, recordMap);
613
- if (!title) return null;
614
- const titleDecoration = [[title]];
615
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: `notion-page-title ${className || ""}` }, rest), /* @__PURE__ */ React9.createElement(PageIcon, { block, defaultIcon, className: "notion-page-title-icon" }), /* @__PURE__ */ React9.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ React9.createElement(Text, { value: titleDecoration, block })));
616
- }
617
- if (!((_a2 = block.properties) == null ? void 0 : _a2.title)) return null;
618
- return /* @__PURE__ */ React9.createElement("span", __spreadValues({ className: `notion-page-title ${className || ""}` }, rest), /* @__PURE__ */ React9.createElement(PageIcon, { block, defaultIcon, className: "notion-page-title-icon" }), /* @__PURE__ */ React9.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ React9.createElement(Text, { value: (_b2 = block.properties) == null ? void 0 : _b2.title, block })));
619
- };
620
- var PageTitle = React9.memo(PageTitleImpl);
621
-
622
- // src/components/text.tsx
623
- var Text = ({ value, block, linkProps, linkProtocol }) => {
624
- const { components, recordMap, mapPageUrl, mapImageUrl, rootDomain } = useNotionContext();
625
- return /* @__PURE__ */ React10.createElement(React10.Fragment, null, value == null ? void 0 : value.map((deco, index) => {
626
- const [text, decorations] = deco;
627
- if (!decorations)
628
- if (text === ",") return /* @__PURE__ */ React10.createElement("span", { key: index, style: { padding: "0.5em" } });
629
- else return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, text);
630
- const formatted = decorations.reduce(
631
- (element, decorator) => {
632
- var _a, _b, _c, _d, _e;
633
- switch (decorator[0]) {
634
- case "p": {
635
- const blockId = decorator[1];
636
- const linkedBlock = (_a = recordMap.block[blockId]) == null ? void 0 : _a.value;
637
- if (!linkedBlock) {
638
- console.debug('"p" missing block', blockId);
639
- return null;
640
- }
641
- return /* @__PURE__ */ React10.createElement(components.PageLink, { className: "notion-link", href: mapPageUrl(blockId) }, /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock }));
642
- }
643
- case "\u2023": {
644
- const linkType = decorator[1][0];
645
- const id = decorator[1][1];
646
- switch (linkType) {
647
- case "u": {
648
- const user = (_b = recordMap.notion_user[id]) == null ? void 0 : _b.value;
649
- if (!user) {
650
- console.debug('"\u2023" missing user', id);
651
- return null;
652
- }
653
- const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
654
- const email = user.email;
655
- return /* @__PURE__ */ React10.createElement(components.Link, __spreadValues({ className: "notion-link", href: `mailto:${email}` }, linkProps), /* @__PURE__ */ React10.createElement(
656
- GracefulImage,
657
- {
658
- className: "notion-user",
659
- src: mapImageUrl(user.profile_photo, block),
660
- alt: name,
661
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
662
- }
663
- ), name);
664
- }
665
- default: {
666
- const linkedBlock = (_c = recordMap.block[id]) == null ? void 0 : _c.value;
667
- if (!linkedBlock) {
668
- console.debug('"\u2023" missing block', linkType, id);
669
- return null;
670
- }
671
- return /* @__PURE__ */ React10.createElement(
672
- components.PageLink,
673
- __spreadProps(__spreadValues({
674
- className: "notion-link",
675
- href: mapPageUrl(id)
676
- }, linkProps), {
677
- target: "_blank",
678
- rel: "noopener noreferrer"
679
- }),
680
- /* @__PURE__ */ React10.createElement(PageTitle, { block: linkedBlock })
681
- );
682
- }
683
- }
684
- }
685
- case "h":
686
- return /* @__PURE__ */ React10.createElement("span", { className: `notion-${decorator[1]}` }, element);
687
- case "c":
688
- return /* @__PURE__ */ React10.createElement("code", { className: "notion-inline-code" }, element);
689
- case "b":
690
- return /* @__PURE__ */ React10.createElement("b", null, element);
691
- case "i":
692
- return /* @__PURE__ */ React10.createElement("em", null, element);
693
- case "s":
694
- return /* @__PURE__ */ React10.createElement("s", null, element);
695
- case "_":
696
- return /* @__PURE__ */ React10.createElement("span", { className: "notion-inline-underscore" }, element);
697
- case "e":
698
- return /* @__PURE__ */ React10.createElement(components.Equation, { math: decorator[1], inline: true });
699
- case "m":
700
- return element;
701
- //still need to return the base element
702
- case "a": {
703
- const v = decorator[1];
704
- const pathname = v.substring(1);
705
- const id = parsePageId(pathname, { uuid: true });
706
- if ((v[0] === "/" || v.includes(rootDomain)) && id) {
707
- const href = v.includes(rootDomain) ? v : `${mapPageUrl(id)}${getHashFragmentValue(v)}`;
708
- return /* @__PURE__ */ React10.createElement(components.PageLink, __spreadValues({ className: "notion-link", href }, linkProps), element);
709
- } else {
710
- return /* @__PURE__ */ React10.createElement(
711
- components.Link,
712
- __spreadValues({
713
- className: "notion-link",
714
- href: linkProtocol ? `${linkProtocol}:${decorator[1]}` : decorator[1]
715
- }, linkProps),
716
- element
717
- );
718
- }
719
- }
720
- // Date
721
- case "d": {
722
- const v = decorator[1];
723
- const type = v == null ? void 0 : v.type;
724
- if (type === "date") {
725
- const startDate = v.start_date;
726
- return formatDate(startDate);
727
- } else if (type === "daterange") {
728
- const startDate = v.start_date;
729
- const endDate = v.end_date;
730
- return `${formatDate(startDate)} \u2192 ${formatDate(endDate)}`;
731
- } else {
732
- return element;
733
- }
734
- }
735
- // User
736
- case "u": {
737
- const userId = decorator[1];
738
- const user = (_d = recordMap.notion_user[userId]) == null ? void 0 : _d.value;
739
- if (!user) {
740
- console.debug("missing user", userId);
741
- return null;
742
- }
743
- const name = user.name;
744
- const email = user.email;
745
- return /* @__PURE__ */ React10.createElement(components.Link, __spreadValues({ className: "notion-link", href: `mailto:${email}` }, linkProps), /* @__PURE__ */ React10.createElement(
746
- GracefulImage,
747
- {
748
- className: "notion-user",
749
- src: mapImageUrl(user.profile_photo, block),
750
- alt: name,
751
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
752
- }
753
- ), name);
754
- }
755
- case "eoi": {
756
- const blockId = decorator[1];
757
- const externalObjectInstance = (_e = recordMap.block[blockId]) == null ? void 0 : _e.value;
758
- return /* @__PURE__ */ React10.createElement(EOI, { block: externalObjectInstance, inline: true });
759
- }
760
- default:
761
- if (true) console.debug("unsupported text format", decorator);
762
- return element;
763
- }
764
- },
765
- /* @__PURE__ */ React10.createElement(React10.Fragment, null, text)
766
- );
767
- return /* @__PURE__ */ React10.createElement(React10.Fragment, { key: index }, formatted);
768
- }));
769
- };
770
-
771
- // src/components/asset-wrapper.tsx
772
- var urlStyle = { width: "100%" };
773
- var AssetWrapper = ({ blockId, block }) => {
774
- var _a, _b, _c, _d, _e, _f;
775
- const value = block;
776
- const { components, mapPageUrl, rootDomain, zoom } = useNotionContext();
777
- let isURL = false;
778
- if (block.type === "image") {
779
- const caption = (_c = (_b = (_a = value == null ? void 0 : value.properties) == null ? void 0 : _a.caption) == null ? void 0 : _b[0]) == null ? void 0 : _c[0];
780
- if (caption) {
781
- const id = parsePageId2(caption, { uuid: true });
782
- const isPage = caption.charAt(0) === "/" && id;
783
- if (isPage || isValidURL(caption)) isURL = true;
784
- }
785
- }
786
- const figure = /* @__PURE__ */ React11.createElement(
787
- "figure",
788
- {
789
- className: `notion-asset-wrapper
790
- notion-asset-wrapper-${block.type}
791
- ${((_d = value.format) == null ? void 0 : _d.block_full_width) ? "notion-asset-wrapper-full" : ""}
792
- ${blockId}`
793
- },
794
- /* @__PURE__ */ React11.createElement(Asset, { block: value, zoomable: zoom && !isURL }, ((_e = value == null ? void 0 : value.properties) == null ? void 0 : _e.caption) && !isURL && /* @__PURE__ */ React11.createElement("figcaption", { className: "notion-asset-caption" }, /* @__PURE__ */ React11.createElement(Text, { value: value.properties.caption, block })))
795
- );
796
- if (isURL) {
797
- const caption = (_f = value == null ? void 0 : value.properties) == null ? void 0 : _f.caption[0][0];
798
- const id = parsePageId2(caption, { uuid: true });
799
- const isPage = caption.charAt(0) === "/" && id;
800
- const captionHostname = extractHostname(caption);
801
- return /* @__PURE__ */ React11.createElement(
802
- components.PageLink,
803
- {
804
- style: urlStyle,
805
- href: isPage ? mapPageUrl(id) : caption,
806
- target: captionHostname && captionHostname !== rootDomain && !caption.startsWith("/") ? "blank_" : null
807
- },
808
- figure
809
- );
810
- }
811
- return figure;
812
- };
813
- function isValidURL(str) {
814
- const pattern = new RegExp(
815
- "^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$",
816
- "i"
817
- );
818
- return !!pattern.test(str);
819
- }
820
- function extractHostname(url) {
821
- try {
822
- const hostname = new URL(url).hostname;
823
- return hostname;
824
- } catch (err) {
825
- return "";
826
- }
827
- }
828
-
829
- // src/components/header.tsx
830
- import React16 from "react";
831
- import { getPageBreadcrumbs } from "@texonom/nutils";
832
- import { useHotkeys } from "react-hotkeys-hook";
833
-
834
- // src/icons/search-icon.tsx
835
- import React12 from "react";
836
- var SearchIcon = (props) => {
837
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
838
- return /* @__PURE__ */ React12.createElement("svg", __spreadValues({ className: `notion-icon ${className || ""}`, viewBox: "0 0 17 17" }, rest), /* @__PURE__ */ React12.createElement("path", { d: "M6.78027 13.6729C8.24805 13.6729 9.60156 13.1982 10.709 12.4072L14.875 16.5732C15.0684 16.7666 15.3232 16.8633 15.5957 16.8633C16.167 16.8633 16.5713 16.4238 16.5713 15.8613C16.5713 15.5977 16.4834 15.3516 16.29 15.1582L12.1504 11.0098C13.0205 9.86719 13.5391 8.45215 13.5391 6.91406C13.5391 3.19629 10.498 0.155273 6.78027 0.155273C3.0625 0.155273 0.0214844 3.19629 0.0214844 6.91406C0.0214844 10.6318 3.0625 13.6729 6.78027 13.6729ZM6.78027 12.2139C3.87988 12.2139 1.48047 9.81445 1.48047 6.91406C1.48047 4.01367 3.87988 1.61426 6.78027 1.61426C9.68066 1.61426 12.0801 4.01367 12.0801 6.91406C12.0801 9.81445 9.68066 12.2139 6.78027 12.2139Z" }));
839
- };
840
-
841
- // src/components/search-dialog.tsx
842
- var import_lodash = __toESM(require_lodash(), 1);
843
- import React15 from "react";
844
- import { getBlockParentPage, getBlockTitle as getBlockTitle2 } from "@texonom/nutils";
845
-
846
- // src/icons/clear-icon.tsx
847
- import React13 from "react";
848
- var ClearIcon = (props) => {
849
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
850
- return /* @__PURE__ */ React13.createElement("svg", __spreadProps(__spreadValues({ className: `notion-icon ${className || ""}` }, rest), { viewBox: "0 0 30 30" }), /* @__PURE__ */ React13.createElement("path", { d: "M15,0C6.716,0,0,6.716,0,15s6.716,15,15,15s15-6.716,15-15S23.284,0,15,0z M22,20.6L20.6,22L15,16.4L9.4,22L8,20.6l5.6-5.6 L8,9.4L9.4,8l5.6,5.6L20.6,8L22,9.4L16.4,15L22,20.6z" }));
851
- };
852
-
853
- // src/icons/loading-icon.tsx
854
- import React14 from "react";
855
- var LoadingIcon = (props) => {
856
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
857
- return /* @__PURE__ */ React14.createElement("svg", __spreadProps(__spreadValues({ className: `notion-icon ${className || ""}` }, rest), { viewBox: "0 0 24 24" }), /* @__PURE__ */ React14.createElement("defs", null, /* @__PURE__ */ React14.createElement("linearGradient", { x1: "28.1542969%", y1: "63.7402344%", x2: "74.6289062%", y2: "17.7832031%", id: "linearGradient-1" }, /* @__PURE__ */ React14.createElement("stop", { stopColor: "rgba(164, 164, 164, 1)", offset: "0%" }), /* @__PURE__ */ React14.createElement("stop", { stopColor: "rgba(164, 164, 164, 0)", stopOpacity: "0", offset: "100%" }))), /* @__PURE__ */ React14.createElement("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none" }, /* @__PURE__ */ React14.createElement("g", { transform: "translate(-236.000000, -286.000000)" }, /* @__PURE__ */ React14.createElement("g", { transform: "translate(238.000000, 286.000000)" }, /* @__PURE__ */ React14.createElement("circle", { id: "Oval-2", stroke: "url(#linearGradient-1)", strokeWidth: "4", cx: "10", cy: "12", r: "10" }), /* @__PURE__ */ React14.createElement("path", { d: "M10,2 C4.4771525,2 0,6.4771525 0,12", id: "Oval-2", stroke: "rgba(164, 164, 164, 1)", strokeWidth: "4" }), /* @__PURE__ */ React14.createElement("rect", { id: "Rectangle-1", fill: "rgba(164, 164, 164, 1)", x: "8", y: "0", width: "4", height: "4", rx: "8" })))));
858
- };
859
-
860
- // src/components/search-dialog.tsx
861
- var SearchDialog = class extends React15.Component {
862
- constructor(props) {
863
- super(props);
864
- this.state = {
865
- isLoading: false,
866
- query: "",
867
- searchResult: null,
868
- searchError: null
869
- };
870
- this._onAfterOpen = () => {
871
- if (this._inputRef.current) this._inputRef.current.focus();
872
- };
873
- this._onChangeQuery = (e) => {
874
- const query = e.target.value;
875
- this.setState({ query });
876
- if (!query.trim()) {
877
- this.setState({ isLoading: false, searchResult: null, searchError: null });
878
- return;
879
- } else {
880
- this._search();
881
- }
882
- };
883
- this._onClearQuery = () => {
884
- this._onChangeQuery({ target: { value: "" } });
885
- };
886
- this._warmupSearch = () => __async(this, null, function* () {
887
- const { searchNotion, rootBlockId } = this.props;
888
- yield searchNotion({
889
- query: "",
890
- ancestorId: rootBlockId
891
- });
892
- });
893
- this._searchImpl = () => __async(this, null, function* () {
894
- const { searchNotion, rootBlockId } = this.props;
895
- const { query } = this.state;
896
- if (!query.trim()) {
897
- this.setState({ isLoading: false, searchResult: null, searchError: null });
898
- return;
899
- }
900
- this.setState({ isLoading: true });
901
- const result = yield searchNotion({
902
- query,
903
- ancestorId: rootBlockId
904
- });
905
- console.debug("search", query, result);
906
- let searchResult = null;
907
- let searchError = null;
908
- if (result.error || result.errorId) {
909
- searchError = result;
910
- } else {
911
- searchResult = __spreadValues({}, result);
912
- const results = searchResult.results.map((result2) => {
913
- var _a, _b;
914
- const block = (_a = searchResult.recordMap.block[result2.id]) == null ? void 0 : _a.value;
915
- if (!block) return;
916
- const title = getBlockTitle2(block, searchResult.recordMap);
917
- if (!title) return;
918
- result2.title = title;
919
- result2.block = block;
920
- result2.recordMap = searchResult.recordMap;
921
- result2.page = getBlockParentPage(block, searchResult.recordMap, {
922
- inclusive: true
923
- }) || block;
924
- if (!result2.page.id) return;
925
- if ((_b = result2.highlight) == null ? void 0 : _b.text)
926
- result2.highlight.html = result2.highlight.text.replace(/<gzkNfoUU>/gi, "<b>").replace(/<\/gzkNfoUU>/gi, "</b>");
927
- return result2;
928
- }).filter(Boolean);
929
- const searchResultsMap = results.reduce(
930
- (map, result2) => __spreadProps(__spreadValues({}, map), {
931
- [result2.page.id]: result2
932
- }),
933
- {}
934
- );
935
- searchResult.results = Object.values(searchResultsMap);
936
- }
937
- if (this.state.query === query) this.setState({ isLoading: false, searchResult, searchError });
938
- });
939
- this._inputRef = React15.createRef();
940
- }
941
- componentDidMount() {
942
- this._search = (0, import_lodash.default)(this._searchImpl.bind(this), 1e3);
943
- this._warmupSearch();
944
- }
945
- render() {
946
- const { isOpen, onClose } = this.props;
947
- const { isLoading, query, searchResult, searchError } = this.state;
948
- const hasQuery = !!query.trim();
949
- return /* @__PURE__ */ React15.createElement(NotionContextConsumer, null, (ctx2) => {
950
- const { components, defaultPageIcon, mapPageUrl } = ctx2;
951
- return /* @__PURE__ */ React15.createElement(
952
- components.Modal,
953
- {
954
- isOpen,
955
- contentLabel: "Search",
956
- className: "notion-search",
957
- overlayClassName: "notion-search-overlay",
958
- onRequestClose: onClose,
959
- onAfterOpen: this._onAfterOpen
960
- },
961
- /* @__PURE__ */ React15.createElement("div", { className: "quickFindMenu" }, /* @__PURE__ */ React15.createElement("div", { className: "searchBar" }, /* @__PURE__ */ React15.createElement("div", { className: "inlineIcon" }, isLoading ? /* @__PURE__ */ React15.createElement(LoadingIcon, { className: "loadingIcon" }) : /* @__PURE__ */ React15.createElement(SearchIcon, null)), /* @__PURE__ */ React15.createElement(
962
- "input",
963
- {
964
- className: "searchInput",
965
- placeholder: "Search",
966
- value: query,
967
- ref: this._inputRef,
968
- onChange: this._onChangeQuery
969
- }
970
- ), query && /* @__PURE__ */ React15.createElement("div", { role: "button", className: "clearButton", onClick: this._onClearQuery }, /* @__PURE__ */ React15.createElement(ClearIcon, { className: "clearIcon" }))), hasQuery && searchResult && /* @__PURE__ */ React15.createElement(React15.Fragment, null, searchResult.results.length ? /* @__PURE__ */ React15.createElement(NotionContextProvider, __spreadProps(__spreadValues({}, ctx2), { recordMap: searchResult.recordMap }), /* @__PURE__ */ React15.createElement("div", { className: "resultsPane" }, searchResult.results.map((result) => {
971
- var _a;
972
- return /* @__PURE__ */ React15.createElement(
973
- components.PageLink,
974
- {
975
- key: result.id,
976
- className: `result notion-page-link`,
977
- href: mapPageUrl(result.page.id, searchResult.recordMap)
978
- },
979
- /* @__PURE__ */ React15.createElement(PageTitle, { block: result.page, defaultIcon: defaultPageIcon }),
980
- ((_a = result.highlight) == null ? void 0 : _a.html) && /* @__PURE__ */ React15.createElement(
981
- "div",
982
- {
983
- className: "notion-search-result-highlight",
984
- dangerouslySetInnerHTML: {
985
- __html: result.highlight.html
986
- }
987
- }
988
- )
989
- );
990
- })), /* @__PURE__ */ React15.createElement("footer", { className: "resultsFooter" }, /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement("span", { className: "resultsCount" }, searchResult.total), searchResult.total === 1 ? " result" : " results"))) : /* @__PURE__ */ React15.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ React15.createElement("div", { className: "noResults" }, "No results"), /* @__PURE__ */ React15.createElement("div", { className: "noResultsDetail" }, "Try different search terms"))), hasQuery && !searchResult && searchError && /* @__PURE__ */ React15.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ React15.createElement("div", { className: "noResults" }, "Search error")))
991
- );
992
- });
993
- }
994
- };
995
-
996
- // src/components/header.tsx
997
- var Header = ({ block }) => {
998
- return /* @__PURE__ */ React16.createElement("header", { className: "notion-header" }, /* @__PURE__ */ React16.createElement("div", { className: "notion-nav-header" }, /* @__PURE__ */ React16.createElement(Breadcrumbs, { block }), /* @__PURE__ */ React16.createElement(Search, { block })));
999
- };
1000
- var Breadcrumbs = ({ block, rootOnly = false }) => {
1001
- const { recordMap, mapPageUrl, components } = useNotionContext();
1002
- const breadcrumbs = React16.useMemo(() => {
1003
- const breadcrumbs2 = getPageBreadcrumbs(recordMap, block.id);
1004
- if (rootOnly) return [breadcrumbs2[0]].filter(Boolean);
1005
- return breadcrumbs2;
1006
- }, [recordMap, block.id, rootOnly]);
1007
- return /* @__PURE__ */ React16.createElement("div", { className: "breadcrumbs", key: "breadcrumbs" }, breadcrumbs.map((breadcrumb, index) => {
1008
- if (!breadcrumb) return null;
1009
- const pageLinkProps = {};
1010
- const componentMap = {
1011
- pageLink: components.PageLink
1012
- };
1013
- if (breadcrumb.active) componentMap.pageLink = (props) => /* @__PURE__ */ React16.createElement("div", __spreadValues({}, props));
1014
- else pageLinkProps.href = mapPageUrl(breadcrumb.pageId);
1015
- return /* @__PURE__ */ React16.createElement(React16.Fragment, { key: breadcrumb.pageId }, /* @__PURE__ */ React16.createElement(componentMap.pageLink, __spreadValues({ className: `breadcrumb ${breadcrumb.active && "active"}` }, pageLinkProps), breadcrumb.icon && /* @__PURE__ */ React16.createElement(PageIcon, { className: "icon", block: breadcrumb.block }), breadcrumb.title && /* @__PURE__ */ React16.createElement("span", { className: "title" }, breadcrumb.title)), index < breadcrumbs.length - 1 && /* @__PURE__ */ React16.createElement("span", { className: "spacer" }, "/"));
1016
- }));
1017
- };
1018
- var Search = ({ block, search, title = "Search" }) => {
1019
- const { searchNotion, rootPageId, isShowingSearch, onHideSearch } = useNotionContext();
1020
- const onSearchNotion = search || searchNotion;
1021
- const [isSearchOpen, setIsSearchOpen] = React16.useState(isShowingSearch);
1022
- React16.useEffect(() => {
1023
- setIsSearchOpen(isShowingSearch);
1024
- }, [isShowingSearch]);
1025
- const onOpenSearch = React16.useCallback(() => {
1026
- setIsSearchOpen(true);
1027
- }, []);
1028
- const onCloseSearch = React16.useCallback(() => {
1029
- setIsSearchOpen(false);
1030
- if (onHideSearch) onHideSearch();
1031
- }, [onHideSearch]);
1032
- useHotkeys("cmd+p", (event) => {
1033
- onOpenSearch();
1034
- event.preventDefault();
1035
- event.stopPropagation();
1036
- });
1037
- useHotkeys("cmd+k", (event) => {
1038
- onOpenSearch();
1039
- event.preventDefault();
1040
- event.stopPropagation();
1041
- });
1042
- const hasSearch = !!onSearchNotion;
1043
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, hasSearch && /* @__PURE__ */ React16.createElement("div", { role: "button", className: `breadcrumb button notion-search-button`, onClick: onOpenSearch }, /* @__PURE__ */ React16.createElement(SearchIcon, { className: "searchIcon" }), title && /* @__PURE__ */ React16.createElement("span", { className: "title" }, title)), isSearchOpen && hasSearch && /* @__PURE__ */ React16.createElement(
1044
- SearchDialog,
1045
- {
1046
- isOpen: isSearchOpen,
1047
- rootBlockId: rootPageId || (block == null ? void 0 : block.id),
1048
- onClose: onCloseSearch,
1049
- searchNotion: onSearchNotion
1050
- }
1051
- ));
1052
- };
1053
-
1054
- // src/next.tsx
1055
- import React17 from "react";
1056
- import isEqual from "react-fast-compare";
1057
- var wrapNextImage = (NextImage) => {
1058
- return React17.memo(function ReactNotionXNextImage(_a) {
1059
- var _b = _a, {
1060
- src,
1061
- alt,
1062
- width,
1063
- height,
1064
- className,
1065
- style,
1066
- layout
1067
- } = _b, rest = __objRest(_b, [
1068
- "src",
1069
- "alt",
1070
- "width",
1071
- "height",
1072
- "className",
1073
- "style",
1074
- "layout"
1075
- ]);
1076
- if (!layout) layout = width && height ? "intrinsic" : "fill";
1077
- return /* @__PURE__ */ React17.createElement(
1078
- NextImage,
1079
- __spreadValues({
1080
- className,
1081
- src,
1082
- alt,
1083
- width: layout === "intrinsic" && width,
1084
- height: layout === "intrinsic" && height,
1085
- objectFit: style == null ? void 0 : style.objectFit,
1086
- objectPosition: style == null ? void 0 : style.objectPosition,
1087
- layout
1088
- }, rest)
1089
- );
1090
- }, isEqual);
1091
- };
1092
- var wrapNextLink = (NextLink) => (function ReactNotionXNextLink(_a) {
1093
- var _b = _a, { href, as, passHref, prefetch, replace, scroll, shallow, locale } = _b, linkProps = __objRest(_b, ["href", "as", "passHref", "prefetch", "replace", "scroll", "shallow", "locale"]);
1094
- return /* @__PURE__ */ React17.createElement(
1095
- NextLink,
1096
- {
1097
- href,
1098
- as,
1099
- passHref,
1100
- prefetch,
1101
- replace,
1102
- scroll,
1103
- shallow,
1104
- locale
1105
- },
1106
- /* @__PURE__ */ React17.createElement("a", __spreadValues({}, linkProps))
1107
- );
1108
- });
1109
-
1110
- // src/context.tsx
1111
- var DefaultLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({ target: "_blank", rel: "noopener noreferrer" }, props));
1112
- var DefaultLinkMemo = React18.memo(DefaultLink);
1113
- var DefaultPageLink = (props) => /* @__PURE__ */ React18.createElement("a", __spreadValues({}, props));
1114
- var DefaultPageLinkMemo = React18.memo(DefaultPageLink);
1115
- var DefaultEmbed = (props) => /* @__PURE__ */ React18.createElement(AssetWrapper, __spreadValues({}, props));
1116
- var DefaultHeader = Header;
1117
- var dummyLink = (_a) => {
1118
- var _b = _a, { href, rel, target, title } = _b, rest = __objRest(_b, ["href", "rel", "target", "title"]);
1119
- return /* @__PURE__ */ React18.createElement("span", __spreadValues({}, rest));
1120
- };
1121
- var dummyComponent = (name) => () => {
1122
- console.warn(`Warning: using empty component "${name}" (you should override this in NotionRenderer.components)`);
1123
- return null;
1124
- };
1125
- var dummyOverrideFn = (_, defaultValueFn) => defaultValueFn();
1126
- var defaultComponents = {
1127
- Image: null,
1128
- // disable custom images by default
1129
- Link: DefaultLinkMemo,
1130
- PageLink: DefaultPageLinkMemo,
1131
- Checkbox,
1132
- Callout: void 0,
1133
- // use the built-in callout rendering by default
1134
- Code: dummyComponent("Code"),
1135
- Equation: dummyComponent("Equation"),
1136
- Collection: dummyComponent("Collection"),
1137
- Property: void 0,
1138
- // use the built-in property rendering by default
1139
- propertyTextValue: dummyOverrideFn,
1140
- propertySelectValue: dummyOverrideFn,
1141
- propertyRelationValue: dummyOverrideFn,
1142
- propertyFormulaValue: dummyOverrideFn,
1143
- propertyTitleValue: dummyOverrideFn,
1144
- propertyPersonValue: dummyOverrideFn,
1145
- propertyFileValue: dummyOverrideFn,
1146
- propertyCheckboxValue: dummyOverrideFn,
1147
- propertyUrlValue: dummyOverrideFn,
1148
- propertyEmailValue: dummyOverrideFn,
1149
- propertyPhoneNumberValue: dummyOverrideFn,
1150
- propertyNumberValue: dummyOverrideFn,
1151
- propertyLastEditedTimeValue: dummyOverrideFn,
1152
- propertyCreatedTimeValue: dummyOverrideFn,
1153
- propertyDateValue: dummyOverrideFn,
1154
- Pdf: dummyComponent("Pdf"),
1155
- Tweet: dummyComponent("Tweet"),
1156
- Modal: dummyComponent("Modal"),
1157
- Header: DefaultHeader,
1158
- Embed: DefaultEmbed
1159
- };
1160
- var defaultNotionContext = {
1161
- recordMap: {
1162
- block: {},
1163
- collection: {},
1164
- collection_view: {},
1165
- collection_query: {},
1166
- notion_user: {},
1167
- signed_urls: {}
1168
- },
1169
- components: defaultComponents,
1170
- mapPageUrl: defaultMapPageUrl(),
1171
- mapImageUrl: defaultMapImageUrl,
1172
- searchNotion: null,
1173
- isShowingSearch: false,
1174
- onHideSearch: null,
1175
- fullPage: false,
1176
- darkMode: false,
1177
- previewImages: false,
1178
- forceCustomImages: false,
1179
- showCollectionViewDropdown: true,
1180
- linkTableTitleProperties: true,
1181
- isLinkCollectionToUrlProperty: false,
1182
- showTableOfContents: false,
1183
- minTableOfContentsItems: 3,
1184
- defaultPageIcon: null,
1185
- defaultPageCover: null,
1186
- defaultPageCoverPosition: 0.5,
1187
- zoom: null
1188
- };
1189
- var ctx = React18.createContext(defaultNotionContext);
1190
- var NotionContextProvider = (_a) => {
1191
- var _b = _a, {
1192
- components: themeComponents = {},
1193
- children,
1194
- mapPageUrl,
1195
- mapImageUrl,
1196
- rootPageId
1197
- } = _b, rest = __objRest(_b, [
1198
- "components",
1199
- "children",
1200
- "mapPageUrl",
1201
- "mapImageUrl",
1202
- "rootPageId"
1203
- ]);
1204
- for (const key of Object.keys(rest)) if (rest[key] === void 0) delete rest[key];
1205
- const wrappedThemeComponents = React18.useMemo(
1206
- () => __spreadValues({}, themeComponents),
1207
- [themeComponents]
1208
- );
1209
- if (wrappedThemeComponents.nextImage) wrappedThemeComponents.Image = wrapNextImage(themeComponents.nextImage);
1210
- if (wrappedThemeComponents.nextLink) wrappedThemeComponents.nextLink = wrapNextLink(themeComponents.nextLink);
1211
- for (const key of Object.keys(wrappedThemeComponents)) if (!wrappedThemeComponents[key]) delete wrappedThemeComponents[key];
1212
- const value = React18.useMemo(
1213
- () => __spreadProps(__spreadValues(__spreadValues({}, defaultNotionContext), rest), {
1214
- rootPageId,
1215
- mapPageUrl: mapPageUrl != null ? mapPageUrl : defaultMapPageUrl(rootPageId),
1216
- mapImageUrl: mapImageUrl != null ? mapImageUrl : defaultMapImageUrl,
1217
- components: __spreadValues(__spreadValues({}, defaultComponents), wrappedThemeComponents)
1218
- }),
1219
- [mapImageUrl, mapPageUrl, wrappedThemeComponents, rootPageId, rest]
1220
- );
1221
- return /* @__PURE__ */ React18.createElement(ctx.Provider, { value }, children);
1222
- };
1223
- var NotionContextConsumer = ctx.Consumer;
1224
- var useNotionContext = () => {
1225
- return React18.useContext(ctx);
1226
- };
1227
-
1228
- // src/icons/default-page-icon.tsx
1229
- import React19 from "react";
1230
- var DefaultPageIcon = (props) => {
1231
- const _a = props, { className } = _a, rest = __objRest(_a, ["className"]);
1232
- return /* @__PURE__ */ React19.createElement("svg", __spreadProps(__spreadValues({ className }, rest), { viewBox: "0 0 30 30", width: "16" }), /* @__PURE__ */ React19.createElement("path", { d: "M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z" }));
1233
- };
1234
-
1235
- // src/components/page-icon.tsx
1236
- var isIconBlock = (value) => {
1237
- return value.type === "page" || value.type === "callout" || value.type === "collection_view" || value.type === "collection_view_page";
1238
- };
1239
- var PageIconImpl = ({ block, className, inline = true, hideDefaultIcon = false, defaultIcon }) => {
1240
- var _a;
1241
- const { mapImageUrl, recordMap, darkMode } = useNotionContext();
1242
- let isImage = false;
1243
- let content = null;
1244
- if (isIconBlock(block)) {
1245
- const icon = ((_a = getBlockIcon(block, recordMap)) == null ? void 0 : _a.trim()) || defaultIcon;
1246
- const title = getBlockTitle3(block, recordMap);
1247
- if (icon && isUrl(icon)) {
1248
- const url = mapImageUrl(icon, block);
1249
- isImage = true;
1250
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: `${className || ""} notion-page-icon` });
1251
- } else if (icon && icon.startsWith("/icons/")) {
1252
- const url = "https://www.notion.so" + icon + "?mode=" + (darkMode ? "dark" : "light");
1253
- content = /* @__PURE__ */ React20.createElement(LazyImage, { src: url, alt: title || "page icon", className: `${className || ""} notion-page-icon` });
1254
- } else if (!icon) {
1255
- if (!hideDefaultIcon) {
1256
- isImage = true;
1257
- content = /* @__PURE__ */ React20.createElement(DefaultPageIcon, { className: `${className || ""} notion-page-icon`, alt: title ? title : "page icon" });
1258
- }
1259
- } else {
1260
- isImage = false;
1261
- content = /* @__PURE__ */ React20.createElement("span", { className: `${className || ""} notion-page-icon`, role: "img", "aria-label": icon }, icon);
1262
- }
1263
- }
1264
- if (!content) return null;
1265
- return /* @__PURE__ */ React20.createElement(
1266
- "div",
1267
- {
1268
- className: `
1269
- ${inline ? "notion-page-icon-inline" : "notion-page-icon-hero"}
1270
- ${isImage ? "notion-page-icon-image" : "notion-page-icon-span"}
1271
- `
1272
- },
1273
- content
1274
- );
1275
- };
1276
- var PageIcon = React20.memo(PageIconImpl);
1277
-
1278
- export {
1279
- Checkbox,
1280
- getListNumber,
1281
- getHashFragmentValue,
1282
- isBrowser,
1283
- getYoutubeId,
1284
- isUrl,
1285
- formatDate,
1286
- formatNotionDateTime,
1287
- LazyImage,
1288
- PageIconImpl,
1289
- PageIcon,
1290
- require_lodash,
1291
- EOI,
1292
- GracefulImage,
1293
- Text,
1294
- PageTitleImpl,
1295
- PageTitle,
1296
- SearchDialog,
1297
- Header,
1298
- Breadcrumbs,
1299
- Search,
1300
- dummyLink,
1301
- NotionContextProvider,
1302
- NotionContextConsumer,
1303
- useNotionContext,
1304
- LiteYouTubeEmbed,
1305
- Asset,
1306
- AssetWrapper
1307
- };