@texonom/nreact 1.6.1 → 1.6.2

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.
@@ -1,1154 +0,0 @@
1
- var le = Object.defineProperty, ue = Object.defineProperties;
2
- var me = Object.getOwnPropertyDescriptors;
3
- var B = Object.getOwnPropertySymbols;
4
- var Q = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
5
- var G = (e, n, r) => n in e ? le(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r, y = (e, n) => {
6
- for (var r in n || (n = {}))
7
- Q.call(n, r) && G(e, r, n[r]);
8
- if (B)
9
- for (var r of B(n))
10
- K.call(n, r) && G(e, r, n[r]);
11
- return e;
12
- }, k = (e, n) => ue(e, me(n));
13
- var x = (e, n) => {
14
- var r = {};
15
- for (var i in e)
16
- Q.call(e, i) && n.indexOf(i) < 0 && (r[i] = e[i]);
17
- if (e != null && B)
18
- for (var i of B(e))
19
- n.indexOf(i) < 0 && K.call(e, i) && (r[i] = e[i]);
20
- return r;
21
- };
22
- var T = (e, n, r) => new Promise((i, u) => {
23
- var s = (a) => {
24
- try {
25
- c(r.next(a));
26
- } catch (l) {
27
- u(l);
28
- }
29
- }, o = (a) => {
30
- try {
31
- c(r.throw(a));
32
- } catch (l) {
33
- u(l);
34
- }
35
- }, c = (a) => a.done ? i(a.value) : Promise.resolve(a.value).then(s, o);
36
- c((r = r.apply(e, n)).next());
37
- });
38
- import t, { useState as fe } from "react";
39
- import { normalizeUrl as pe, getBlockIcon as de, getBlockTitle as W, isUrl as ge, formatNotionDateTime as he, formatDate as z, parsePageId as D, getBlockParentPage as ye, getPageBreadcrumbs as Ee, defaultMapImageUrl as ne, defaultMapPageUrl as re, getTextContent as ve } from "@texonom/nutils";
40
- import { useHotkeys as Y } from "react-hotkeys-hook";
41
- import { g as Ce } from "./_commonjsHelpers-ByYUsBRP.js";
42
- function we(e) {
43
- return /* @__PURE__ */ t.createElement("svg", y({ viewBox: "0 0 14 14" }, e), /* @__PURE__ */ t.createElement("path", { d: "M5.5 12L14 3.5 12.5 2l-7 7-4-4.003L0 6.499z" }));
44
- }
45
- const Ne = ({ isChecked: e }) => {
46
- let n = null;
47
- return e ? n = /* @__PURE__ */ t.createElement("div", { className: "notion-property-checkbox-checked" }, /* @__PURE__ */ t.createElement(we, null)) : n = /* @__PURE__ */ t.createElement("div", { className: "notion-property-checkbox-unchecked" }), /* @__PURE__ */ t.createElement("span", { className: "notion-property notion-property-checkbox" }, n);
48
- }, oe = (e) => {
49
- const i = e, { className: n } = i, r = x(i, ["className"]);
50
- return /* @__PURE__ */ t.createElement("svg", y({ className: `notion-icon ${n || ""}`, viewBox: "0 0 17 17" }, r), /* @__PURE__ */ t.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" }));
51
- }, be = (e) => {
52
- const i = e, { className: n } = i, r = x(i, ["className"]);
53
- return /* @__PURE__ */ t.createElement("svg", k(y({ className: n }, r), { viewBox: "0 0 30 30", width: "16" }), /* @__PURE__ */ t.createElement("path", { d: "M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z" }));
54
- }, Oe = (e) => {
55
- const n = [];
56
- let r, i = -1;
57
- return Object.keys(e).forEach((u) => {
58
- var o, c;
59
- const s = (o = e[u]) == null ? void 0 : o.value;
60
- s && ((c = s.content) == null || c.forEach((a) => {
61
- var f, m;
62
- const l = (m = (f = e[a]) == null ? void 0 : f.value) == null ? void 0 : m.type;
63
- l && l !== r && (i++, r = l, n[i] = []), i > -1 && n[i].push(a);
64
- })), r = void 0;
65
- }), n;
66
- }, Ot = (e, n) => {
67
- const i = Oe(n).find((u) => u.includes(e));
68
- if (i)
69
- return i.indexOf(e) + 1;
70
- }, Se = (e) => e.includes("#") ? e.replace(/^.+(#.+)$/, "$1") : "", Le = typeof window != "undefined", Pe = /* @__PURE__ */ new Set([
71
- "youtu.be",
72
- "youtube.com",
73
- "www.youtube.com",
74
- "youtube-nocookie.com",
75
- "www.youtube-nocookie.com"
76
- ]), _e = (e) => {
77
- try {
78
- const { hostname: n } = new URL(e);
79
- if (!Pe.has(n)) return null;
80
- const r = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i, i = e.match(r);
81
- if (i && i[2].length == 11) return i[2];
82
- } catch (n) {
83
- }
84
- return null;
85
- }, U = (l) => {
86
- var f = l, { src: e, alt: n, className: r, style: i, zoomable: u = !1, priority: s = !1, height: o, onError: c } = f, a = x(f, ["src", "alt", "className", "style", "zoomable", "priority", "height", "onError"]);
87
- var g, v, w;
88
- const { recordMap: m, zoom: d, previewImages: E, forceCustomImages: h, components: p } = I(), N = t.useRef(d ? d.clone() : null), S = E ? (w = (g = m == null ? void 0 : m.preview_images) == null ? void 0 : g[e]) != null ? w : (v = m == null ? void 0 : m.preview_images) == null ? void 0 : v[pe(e)] : null, b = t.useCallback(
89
- (O) => {
90
- u && (O.target.src || O.target.srcset) && N.current && N.current.attach(O.target);
91
- },
92
- [N, u]
93
- ), _ = t.useCallback(
94
- (O) => {
95
- N.current && O && N.current.attach(O);
96
- },
97
- [N]
98
- ), C = t.useMemo(() => u ? _ : void 0, [u, _]);
99
- return S && p.Image ? /* @__PURE__ */ t.createElement(
100
- p.Image,
101
- {
102
- src: e,
103
- alt: n,
104
- style: i,
105
- className: r,
106
- width: S.originalWidth,
107
- height: S.originalHeight,
108
- blurDataURL: S.dataURIBase64,
109
- placeholder: "blur",
110
- priority: s,
111
- onLoad: b
112
- }
113
- ) : p.Image && h ? /* @__PURE__ */ t.createElement(
114
- p.Image,
115
- {
116
- src: e,
117
- alt: n,
118
- className: r,
119
- style: i,
120
- width: null,
121
- height: o || null,
122
- priority: s,
123
- onLoad: b
124
- }
125
- ) : /* @__PURE__ */ t.createElement(
126
- "img",
127
- y({
128
- className: r,
129
- style: i,
130
- src: e,
131
- alt: n,
132
- ref: C,
133
- loading: "lazy",
134
- decoding: "async",
135
- onError: c
136
- }, a)
137
- );
138
- }, xe = (e) => e.type === "page" || e.type === "callout" || e.type === "collection_view" || e.type === "collection_view_page", Ie = ({ block: e, className: n, inline: r = !0, hideDefaultIcon: i = !1, defaultIcon: u }) => {
139
- var f;
140
- const { mapImageUrl: s, recordMap: o, darkMode: c } = I();
141
- let a = !1, l = null;
142
- if (xe(e)) {
143
- const m = ((f = de(e, o)) == null ? void 0 : f.trim()) || u, d = W(e, o);
144
- if (m && ge(m)) {
145
- const E = s(m, e);
146
- a = !0, l = /* @__PURE__ */ t.createElement(U, { src: E, alt: d || "page icon", className: `${n || ""} notion-page-icon` });
147
- } else if (m && m.startsWith("/icons/")) {
148
- const E = "https://www.notion.so" + m + "?mode=" + (c ? "dark" : "light");
149
- l = /* @__PURE__ */ t.createElement(U, { src: E, alt: d || "page icon", className: `${n || ""} notion-page-icon` });
150
- } else m ? (a = !1, l = /* @__PURE__ */ t.createElement("span", { className: `${n || ""} notion-page-icon`, role: "img", "aria-label": m }, m)) : i || (a = !0, l = /* @__PURE__ */ t.createElement(be, { className: `${n || ""} notion-page-icon`, alt: d || "page icon" }));
151
- }
152
- return l ? /* @__PURE__ */ t.createElement(
153
- "div",
154
- {
155
- className: `
156
- ${r ? "notion-page-icon-inline" : "notion-page-icon-hero"}
157
- ${a ? "notion-page-icon-image" : "notion-page-icon-span"}
158
- `
159
- },
160
- l
161
- ) : null;
162
- }, q = t.memo(Ie), ke = (e) => {
163
- const i = e, { className: n } = i, r = x(i, ["className"]);
164
- return /* @__PURE__ */ t.createElement("svg", k(y({ className: `notion-icon ${n || ""}` }, r), { viewBox: "0 0 30 30" }), /* @__PURE__ */ t.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" }));
165
- }, $e = (e) => {
166
- const i = e, { className: n } = i, r = x(i, ["className"]);
167
- return /* @__PURE__ */ t.createElement("svg", k(y({ className: `notion-icon ${n || ""}` }, r), { viewBox: "0 0 24 24" }), /* @__PURE__ */ t.createElement("defs", null, /* @__PURE__ */ t.createElement("linearGradient", { x1: "28.1542969%", y1: "63.7402344%", x2: "74.6289062%", y2: "17.7832031%", id: "linearGradient-1" }, /* @__PURE__ */ t.createElement("stop", { stopColor: "rgba(164, 164, 164, 1)", offset: "0%" }), /* @__PURE__ */ t.createElement("stop", { stopColor: "rgba(164, 164, 164, 0)", stopOpacity: "0", offset: "100%" }))), /* @__PURE__ */ t.createElement("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none" }, /* @__PURE__ */ t.createElement("g", { transform: "translate(-236.000000, -286.000000)" }, /* @__PURE__ */ t.createElement("g", { transform: "translate(238.000000, 286.000000)" }, /* @__PURE__ */ t.createElement("circle", { id: "Oval-2", stroke: "url(#linearGradient-1)", strokeWidth: "4", cx: "10", cy: "12", r: "10" }), /* @__PURE__ */ t.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__ */ t.createElement("rect", { id: "Rectangle-1", fill: "rgba(164, 164, 164, 1)", x: "8", y: "0", width: "4", height: "4", rx: "8" })))));
168
- };
169
- function je(e) {
170
- return /* @__PURE__ */ t.createElement("svg", y({ viewBox: "0 0 260 260" }, e), /* @__PURE__ */ t.createElement("g", null, /* @__PURE__ */ t.createElement(
171
- "path",
172
- {
173
- 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",
174
- fill: "#161614"
175
- }
176
- )));
177
- }
178
- const Me = ({ block: e, inline: n, className: r }) => {
179
- var d, E, h;
180
- const { components: i } = I(), { original_url: u, attributes: s, domain: o } = (e == null ? void 0 : e.format) || {};
181
- if (!u || !s) return null;
182
- const c = (d = s.find((p) => p.id === "title")) == null ? void 0 : d.values[0];
183
- let a = (E = s.find((p) => p.id === "owner")) == null ? void 0 : E.values[0];
184
- const l = (h = s.find((p) => p.id === "updated_at")) == null ? void 0 : h.values[0], f = l ? he(l) : null;
185
- let m;
186
- switch (o) {
187
- case "github.com":
188
- if (m = /* @__PURE__ */ t.createElement(je, null), a) {
189
- const p = a.split("/");
190
- a = p[p.length - 1];
191
- }
192
- break;
193
- default:
194
- return process.env.NODE_ENV !== "production" && console.debug(`Unsupported external_object_instance domain "${o}"`, JSON.stringify(e, null, 2)), null;
195
- }
196
- return /* @__PURE__ */ t.createElement(
197
- i.Link,
198
- {
199
- target: "_blank",
200
- rel: "noopener noreferrer",
201
- href: u,
202
- className: `notion-external ${n ? "notion-external-mention" : "notion-external-block notion-row"} ${r || ""}`
203
- },
204
- m && /* @__PURE__ */ t.createElement("div", { className: "notion-external-image" }, m),
205
- /* @__PURE__ */ t.createElement("div", { className: "notion-external-description" }, /* @__PURE__ */ t.createElement("div", { className: "notion-external-title" }, c), (a || f) && /* @__PURE__ */ t.createElement("div", { className: "notion-external-subtitle" }, a && /* @__PURE__ */ t.createElement("span", null, a), a && f && /* @__PURE__ */ t.createElement("span", null, " • "), f && /* @__PURE__ */ t.createElement("span", null, "Updated ", f)))
206
- );
207
- };
208
- function M(e) {
209
- "@babel/helpers - typeof";
210
- return M = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
211
- return typeof n;
212
- } : function(n) {
213
- return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
214
- }, M(e);
215
- }
216
- function Be(e, n) {
217
- if (M(e) != "object" || !e) return e;
218
- var r = e[Symbol.toPrimitive];
219
- if (r !== void 0) {
220
- var i = r.call(e, n);
221
- if (M(i) != "object") return i;
222
- throw new TypeError("@@toPrimitive must return a primitive value.");
223
- }
224
- return (n === "string" ? String : Number)(e);
225
- }
226
- function Re(e) {
227
- var n = Be(e, "string");
228
- return M(n) == "symbol" ? n : n + "";
229
- }
230
- function ae(e, n, r) {
231
- return n = Re(n), n in e ? Object.defineProperty(e, n, {
232
- value: r,
233
- enumerable: !0,
234
- configurable: !0,
235
- writable: !0
236
- }) : e[n] = r, e;
237
- }
238
- function De(e, n) {
239
- if (e == null) return {};
240
- var r = {}, i = Object.keys(e), u, s;
241
- for (s = 0; s < i.length; s++)
242
- u = i[s], !(n.indexOf(u) >= 0) && (r[u] = e[u]);
243
- return r;
244
- }
245
- var ie = (function(e) {
246
- var n = e.decode, r = n === void 0 ? !0 : n, i = e.crossOrigin, u = i === void 0 ? "" : i;
247
- return function(s) {
248
- return new Promise(function(o, c) {
249
- var a = new Image();
250
- u && (a.crossOrigin = u), a.onload = function() {
251
- r && a.decode ? a.decode().then(o).catch(c) : o();
252
- }, a.onerror = c, a.src = s;
253
- });
254
- };
255
- });
256
- function X(e, n) {
257
- var r = Object.keys(e);
258
- if (Object.getOwnPropertySymbols) {
259
- var i = Object.getOwnPropertySymbols(e);
260
- n && (i = i.filter(function(u) {
261
- return Object.getOwnPropertyDescriptor(e, u).enumerable;
262
- })), r.push.apply(r, i);
263
- }
264
- return r;
265
- }
266
- function R(e) {
267
- for (var n = 1; n < arguments.length; n++) {
268
- var r = arguments[n] != null ? arguments[n] : {};
269
- n % 2 ? X(Object(r), !0).forEach(function(i) {
270
- ae(e, i, r[i]);
271
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : X(Object(r)).forEach(function(i) {
272
- Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i));
273
- });
274
- }
275
- return e;
276
- }
277
- var Te = function(n) {
278
- return n.filter(function(r) {
279
- return r;
280
- });
281
- }, ze = function(n) {
282
- return Array.isArray(n) ? n : [n];
283
- }, P = {}, Ve = function(n, r) {
284
- var i = !1;
285
- return new Promise(function(u, s) {
286
- var o = function(a) {
287
- return r(a).then(function() {
288
- i = !0, u(a);
289
- });
290
- };
291
- n.reduce(function(c, a) {
292
- return c.catch(function() {
293
- if (!i) return o(a);
294
- });
295
- }, o(n.shift())).catch(s);
296
- });
297
- };
298
- function Fe(e) {
299
- var n = e.srcList, r = e.imgPromise, i = r === void 0 ? ie({
300
- decode: !0
301
- }) : r, u = e.useSuspense, s = u === void 0 ? !0 : u, o = fe(!1), c = o[1], a = Te(ze(n)), l = a.join("");
302
- if (P[l] || (P[l] = {
303
- promise: Ve(a, i),
304
- cache: "pending",
305
- error: null
306
- }), P[l].cache === "resolved")
307
- return {
308
- src: P[l].src,
309
- isLoading: !1,
310
- error: null
311
- };
312
- if (P[l].cache === "rejected") {
313
- if (s) throw P[l].error;
314
- return {
315
- isLoading: !1,
316
- error: P[l].error,
317
- src: void 0
318
- };
319
- }
320
- if (P[l].promise.then(function(f) {
321
- P[l] = R(R({}, P[l]), {}, {
322
- cache: "resolved",
323
- src: f
324
- }), s || c(l);
325
- }).catch(function(f) {
326
- P[l] = R(R({}, P[l]), {}, {
327
- cache: "rejected",
328
- error: f
329
- }), s || c(l);
330
- }), s) throw P[l].promise;
331
- return {
332
- isLoading: !0,
333
- src: void 0,
334
- error: null
335
- };
336
- }
337
- var Ue = ["decode", "src", "loader", "unloader", "container", "loaderContainer", "unloaderContainer", "imgPromise", "crossorigin", "useSuspense"];
338
- function J(e, n) {
339
- var r = Object.keys(e);
340
- if (Object.getOwnPropertySymbols) {
341
- var i = Object.getOwnPropertySymbols(e);
342
- n && (i = i.filter(function(u) {
343
- return Object.getOwnPropertyDescriptor(e, u).enumerable;
344
- })), r.push.apply(r, i);
345
- }
346
- return r;
347
- }
348
- function qe(e) {
349
- for (var n = 1; n < arguments.length; n++) {
350
- var r = arguments[n] != null ? arguments[n] : {};
351
- n % 2 ? J(Object(r), !0).forEach(function(i) {
352
- ae(e, i, r[i]);
353
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : J(Object(r)).forEach(function(i) {
354
- Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i));
355
- });
356
- }
357
- return e;
358
- }
359
- var V = function(n) {
360
- return n;
361
- };
362
- function He(e) {
363
- var n = e.decode, r = n === void 0 ? !0 : n, i = e.src, u = i === void 0 ? [] : i, s = e.loader, o = s === void 0 ? null : s, c = e.unloader, a = c === void 0 ? null : c, l = e.container, f = l === void 0 ? V : l, m = e.loaderContainer, d = m === void 0 ? V : m, E = e.unloaderContainer, h = E === void 0 ? V : E, p = e.imgPromise, N = e.crossorigin, S = e.useSuspense, b = S === void 0 ? !1 : S, _ = De(e, Ue);
364
- p = p || ie({
365
- decode: r,
366
- crossOrigin: N
367
- });
368
- var C = Fe({
369
- srcList: u,
370
- imgPromise: p,
371
- useSuspense: b
372
- }), g = C.src, v = C.isLoading;
373
- return g ? f(/* @__PURE__ */ t.createElement("img", qe({
374
- src: g
375
- }, _))) : !b && v ? d(o) : !b && a ? h(a) : null;
376
- }
377
- const ee = (e) => Le ? /* @__PURE__ */ t.createElement(He, y({}, e)) : /* @__PURE__ */ t.createElement("img", y({}, e)), H = ({ value: e, block: n, linkProps: r, linkProtocol: i }) => {
378
- const { components: u, recordMap: s, mapPageUrl: o, mapImageUrl: c, rootDomain: a } = I();
379
- return /* @__PURE__ */ t.createElement(t.Fragment, null, e == null ? void 0 : e.map((l, f) => {
380
- const [m, d] = l;
381
- if (!d)
382
- return m === "," ? /* @__PURE__ */ t.createElement("span", { key: f, style: { padding: "0.5em" } }) : /* @__PURE__ */ t.createElement(t.Fragment, { key: f }, m);
383
- const E = d.reduce(
384
- (h, p) => {
385
- var N, S, b, _, C;
386
- switch (p[0]) {
387
- case "p": {
388
- const g = p[1], v = (N = s.block[g]) == null ? void 0 : N.value;
389
- return v ? /* @__PURE__ */ t.createElement(u.PageLink, { className: "notion-link", href: o(g) }, /* @__PURE__ */ t.createElement(A, { block: v })) : (console.debug('"p" missing block', g), null);
390
- }
391
- case "‣": {
392
- const g = p[1][0], v = p[1][1];
393
- switch (g) {
394
- case "u": {
395
- const w = (S = s.notion_user[v]) == null ? void 0 : S.value;
396
- if (!w)
397
- return console.debug('"‣" missing user', v), null;
398
- const O = [w.given_name, w.family_name].filter(Boolean).join(" "), $ = w.email;
399
- return /* @__PURE__ */ t.createElement(u.Link, y({ className: "notion-link", href: `mailto:${$}` }, r), /* @__PURE__ */ t.createElement(
400
- ee,
401
- {
402
- className: "notion-user",
403
- src: c(w.profile_photo, n),
404
- alt: O,
405
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
406
- }
407
- ), O);
408
- }
409
- default: {
410
- const w = (b = s.block[v]) == null ? void 0 : b.value;
411
- return w ? /* @__PURE__ */ t.createElement(
412
- u.PageLink,
413
- k(y({
414
- className: "notion-link",
415
- href: o(v)
416
- }, r), {
417
- target: "_blank",
418
- rel: "noopener noreferrer"
419
- }),
420
- /* @__PURE__ */ t.createElement(A, { block: w })
421
- ) : (console.debug('"‣" missing block', g, v), null);
422
- }
423
- }
424
- }
425
- case "h":
426
- return /* @__PURE__ */ t.createElement("span", { className: `notion-${p[1]}` }, h);
427
- case "c":
428
- return /* @__PURE__ */ t.createElement("code", { className: "notion-inline-code" }, h);
429
- case "b":
430
- return /* @__PURE__ */ t.createElement("b", null, h);
431
- case "i":
432
- return /* @__PURE__ */ t.createElement("em", null, h);
433
- case "s":
434
- return /* @__PURE__ */ t.createElement("s", null, h);
435
- case "_":
436
- return /* @__PURE__ */ t.createElement("span", { className: "notion-inline-underscore" }, h);
437
- case "e":
438
- return /* @__PURE__ */ t.createElement(u.Equation, { math: p[1], inline: !0 });
439
- case "m":
440
- return h;
441
- //still need to return the base element
442
- case "a": {
443
- const g = p[1], v = g.substring(1), w = D(v, { uuid: !0 });
444
- if ((g[0] === "/" || g.includes(a)) && w) {
445
- const O = g.includes(a) ? g : `${o(w)}${Se(g)}`;
446
- return /* @__PURE__ */ t.createElement(u.PageLink, y({ className: "notion-link", href: O }, r), h);
447
- } else
448
- return /* @__PURE__ */ t.createElement(
449
- u.Link,
450
- y({
451
- className: "notion-link",
452
- href: i ? `${i}:${p[1]}` : p[1]
453
- }, r),
454
- h
455
- );
456
- }
457
- // Date
458
- case "d": {
459
- const g = p[1], v = g == null ? void 0 : g.type;
460
- if (v === "date") {
461
- const w = g.start_date;
462
- return z(w);
463
- } else if (v === "daterange") {
464
- const w = g.start_date, O = g.end_date;
465
- return `${z(w)} → ${z(O)}`;
466
- } else
467
- return h;
468
- }
469
- // User
470
- case "u": {
471
- const g = p[1], v = (_ = s.notion_user[g]) == null ? void 0 : _.value;
472
- if (!v)
473
- return console.debug("missing user", g), null;
474
- const w = v.name, O = v.email;
475
- return /* @__PURE__ */ t.createElement(u.Link, y({ className: "notion-link", href: `mailto:${O}` }, r), /* @__PURE__ */ t.createElement(
476
- ee,
477
- {
478
- className: "notion-user",
479
- src: c(v.profile_photo, n),
480
- alt: w,
481
- style: { display: "inline", marginRight: "0.3em", marginBottom: "0.3em" }
482
- }
483
- ), w);
484
- }
485
- case "eoi": {
486
- const g = p[1], v = (C = s.block[g]) == null ? void 0 : C.value;
487
- return /* @__PURE__ */ t.createElement(Me, { block: v, inline: !0 });
488
- }
489
- default:
490
- return process.env.NODE_ENV !== "production" && console.debug("unsupported text format", p), h;
491
- }
492
- },
493
- /* @__PURE__ */ t.createElement(t.Fragment, null, m)
494
- );
495
- return /* @__PURE__ */ t.createElement(t.Fragment, { key: f }, E);
496
- }));
497
- }, Ae = (u) => {
498
- var s = u, { block: e, className: n, defaultIcon: r } = s, i = x(s, ["block", "className", "defaultIcon"]);
499
- var c, a;
500
- const { recordMap: o } = I();
501
- if (!e) return null;
502
- if (e.type === "collection_view_page" || e.type === "collection_view") {
503
- const l = W(e, o);
504
- if (!l) return null;
505
- const f = [[l]];
506
- return /* @__PURE__ */ t.createElement("span", y({ className: `notion-page-title ${n || ""}` }, i), /* @__PURE__ */ t.createElement(q, { block: e, defaultIcon: r, className: "notion-page-title-icon" }), /* @__PURE__ */ t.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ t.createElement(H, { value: f, block: e })));
507
- }
508
- return (c = e.properties) != null && c.title ? /* @__PURE__ */ t.createElement("span", y({ className: `notion-page-title ${n || ""}` }, i), /* @__PURE__ */ t.createElement(q, { block: e, defaultIcon: r, className: "notion-page-title-icon" }), /* @__PURE__ */ t.createElement("span", { className: "notion-page-title-text" }, /* @__PURE__ */ t.createElement(H, { value: (a = e.properties) == null ? void 0 : a.title, block: e }))) : null;
509
- }, A = t.memo(Ae), We = (e, n) => {
510
- let r;
511
- return (...i) => {
512
- r && clearTimeout(r), r = setTimeout(() => e(...i), n);
513
- };
514
- };
515
- class Ze extends t.Component {
516
- constructor(n) {
517
- super(n), this.state = {
518
- isLoading: !1,
519
- query: "",
520
- searchResult: null,
521
- searchError: null
522
- }, this._onAfterOpen = () => {
523
- this._inputRef.current && this._inputRef.current.focus();
524
- }, this._onChangeQuery = (r) => {
525
- const i = r.target.value;
526
- if (this.setState({ query: i }), i.trim())
527
- this._search();
528
- else {
529
- this.setState({ isLoading: !1, searchResult: null, searchError: null });
530
- return;
531
- }
532
- }, this._onClearQuery = () => {
533
- this._onChangeQuery({ target: { value: "" } });
534
- }, this._warmupSearch = () => T(this, null, function* () {
535
- const { searchNotion: r, rootBlockId: i, rootSpaceId: u } = this.props;
536
- yield r({
537
- query: "",
538
- spaceId: u,
539
- filters: {
540
- ancestors: [i],
541
- isDeletedOnly: !1,
542
- excludeTemplates: !0,
543
- navigableBlockContentOnly: !0,
544
- requireEditPermissions: !1
545
- }
546
- });
547
- }), this._searchImpl = () => T(this, null, function* () {
548
- const { searchNotion: r, rootBlockId: i, rootSpaceId: u } = this.props, { query: s } = this.state;
549
- if (!s.trim()) {
550
- this.setState({ isLoading: !1, searchResult: null, searchError: null });
551
- return;
552
- }
553
- this.setState({ isLoading: !0 });
554
- const o = yield r({
555
- query: s,
556
- spaceId: u,
557
- filters: {
558
- ancestors: [i],
559
- isDeletedOnly: !1,
560
- excludeTemplates: !0,
561
- navigableBlockContentOnly: !0,
562
- requireEditPermissions: !1
563
- }
564
- });
565
- console.debug("search", s, o);
566
- let c = null, a = null;
567
- if (o.error || o.errorId)
568
- a = o;
569
- else {
570
- c = y({}, o);
571
- const f = c.results.map((m) => {
572
- var h, p;
573
- const d = (h = c.recordMap.block[m.id]) == null ? void 0 : h.value;
574
- if (!d) return;
575
- const E = W(d, c.recordMap);
576
- if (E && (m.title = E, m.block = d, m.recordMap = c.recordMap, m.page = ye(d, c.recordMap, {
577
- inclusive: !0
578
- }) || d, !!m.page.id))
579
- return (p = m.highlight) != null && p.text && (m.highlight.html = m.highlight.text.replace(/<gzkNfoUU>/gi, "<b>").replace(/<\/gzkNfoUU>/gi, "</b>")), m;
580
- }).filter(Boolean).reduce(
581
- (m, d) => k(y({}, m), {
582
- [d.page.id]: d
583
- }),
584
- {}
585
- );
586
- c.results = Object.values(f);
587
- }
588
- this.state.query === s && this.setState({ isLoading: !1, searchResult: c, searchError: a });
589
- }), this._inputRef = t.createRef();
590
- }
591
- componentDidMount() {
592
- this._search = We(this._searchImpl.bind(this), 500), this._warmupSearch();
593
- }
594
- render() {
595
- const { isOpen: n, onClose: r } = this.props, { isLoading: i, query: u, searchResult: s, searchError: o } = this.state, c = !!u.trim();
596
- return /* @__PURE__ */ t.createElement(lt, null, (a) => {
597
- const { components: l, defaultPageIcon: f, mapPageUrl: m } = a;
598
- return /* @__PURE__ */ t.createElement(
599
- l.Modal,
600
- {
601
- isOpen: n,
602
- contentLabel: "Search",
603
- className: "notion-search",
604
- overlayClassName: "notion-search-overlay",
605
- onRequestClose: r,
606
- onAfterOpen: this._onAfterOpen
607
- },
608
- /* @__PURE__ */ t.createElement("div", { className: "quickFindMenu" }, /* @__PURE__ */ t.createElement("div", { className: "searchBar" }, /* @__PURE__ */ t.createElement("div", { className: "inlineIcon" }, i ? /* @__PURE__ */ t.createElement($e, { className: "loadingIcon" }) : /* @__PURE__ */ t.createElement(oe, null)), /* @__PURE__ */ t.createElement(
609
- "input",
610
- {
611
- className: "searchInput",
612
- placeholder: "Search",
613
- value: u,
614
- ref: this._inputRef,
615
- onInput: this._onChangeQuery
616
- }
617
- ), u && /* @__PURE__ */ t.createElement("div", { role: "button", className: "clearButton", onClick: this._onClearQuery }, /* @__PURE__ */ t.createElement(ke, { className: "clearIcon" }))), c && s && /* @__PURE__ */ t.createElement(t.Fragment, null, s.results.length ? /* @__PURE__ */ t.createElement(ct, k(y({}, a), { recordMap: s.recordMap }), /* @__PURE__ */ t.createElement("div", { className: "resultsPane" }, s.results.map((d) => {
618
- var E;
619
- return /* @__PURE__ */ t.createElement(
620
- l.PageLink,
621
- {
622
- key: d.id,
623
- className: "result notion-page-link",
624
- href: m(d.page.id, s.recordMap)
625
- },
626
- /* @__PURE__ */ t.createElement(A, { block: d.page, defaultIcon: f }),
627
- ((E = d.highlight) == null ? void 0 : E.html) && /* @__PURE__ */ t.createElement(
628
- "div",
629
- {
630
- className: "notion-search-result-highlight",
631
- dangerouslySetInnerHTML: {
632
- __html: d.highlight.html
633
- }
634
- }
635
- )
636
- );
637
- })), /* @__PURE__ */ t.createElement("footer", { className: "resultsFooter" }, /* @__PURE__ */ t.createElement("div", null, /* @__PURE__ */ t.createElement("span", { className: "resultsCount" }, s.total), s.total === 1 ? " result" : " results"))) : /* @__PURE__ */ t.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ t.createElement("div", { className: "noResults" }, "No results"), /* @__PURE__ */ t.createElement("div", { className: "noResultsDetail" }, "Try different search terms"))), c && !s && o && /* @__PURE__ */ t.createElement("div", { className: "noResultsPane" }, /* @__PURE__ */ t.createElement("div", { className: "noResults" }, "Search error")))
638
- );
639
- });
640
- }
641
- }
642
- const Ge = ({ block: e }) => /* @__PURE__ */ t.createElement("header", { className: "notion-header" }, /* @__PURE__ */ t.createElement("div", { className: "notion-nav-header" }, /* @__PURE__ */ t.createElement(Qe, { block: e }), /* @__PURE__ */ t.createElement(Ke, { block: e }))), Qe = ({ block: e, rootOnly: n = !1 }) => {
643
- const { recordMap: r, mapPageUrl: i, components: u } = I(), s = t.useMemo(() => {
644
- const o = Ee(r, e.id);
645
- return n ? [o[0]].filter(Boolean) : o;
646
- }, [r, e.id, n]);
647
- return /* @__PURE__ */ t.createElement("div", { className: "breadcrumbs", key: "breadcrumbs" }, s.map((o, c) => {
648
- if (!o) return null;
649
- const a = {}, l = {
650
- pageLink: u.PageLink
651
- };
652
- return o.active ? l.pageLink = (f) => /* @__PURE__ */ t.createElement("div", y({}, f)) : a.href = i(o.pageId), /* @__PURE__ */ t.createElement(t.Fragment, { key: o.pageId }, /* @__PURE__ */ t.createElement(l.pageLink, y({ className: `breadcrumb ${o.active && "active"}` }, a), o.icon && /* @__PURE__ */ t.createElement(q, { className: "icon", block: o.block }), o.title && /* @__PURE__ */ t.createElement("span", { className: "title" }, o.title)), c < s.length - 1 && /* @__PURE__ */ t.createElement("span", { className: "spacer" }, "/"));
653
- }));
654
- }, Ke = ({ block: e, search: n, title: r = "Search" }) => {
655
- const { searchNotion: i, rootPageId: u, isShowingSearch: s, onHideSearch: o, rootSpaceId: c } = I(), a = n || i, [l, f] = t.useState(s);
656
- t.useEffect(() => {
657
- f(s);
658
- }, [s]);
659
- const m = t.useCallback(() => {
660
- f(!0);
661
- }, []), d = t.useCallback(() => {
662
- f(!1), o && o();
663
- }, [o]);
664
- Y("cmd+p", (h) => {
665
- m(), h.preventDefault(), h.stopPropagation();
666
- }), Y("cmd+k", (h) => {
667
- m(), h.preventDefault(), h.stopPropagation();
668
- });
669
- const E = !!a;
670
- return /* @__PURE__ */ t.createElement(t.Fragment, null, E && /* @__PURE__ */ t.createElement("div", { role: "button", className: "breadcrumb button notion-search-button", onClick: m }, /* @__PURE__ */ t.createElement(oe, { className: "searchIcon" }), r && /* @__PURE__ */ t.createElement("span", { className: "title" }, r)), l && E && /* @__PURE__ */ t.createElement(
671
- Ze,
672
- {
673
- isOpen: l,
674
- rootBlockId: u || (e == null ? void 0 : e.id),
675
- rootSpaceId: c,
676
- onClose: d,
677
- searchNotion: a
678
- }
679
- ));
680
- };
681
- var F, te;
682
- function Ye() {
683
- if (te) return F;
684
- te = 1;
685
- var e = typeof Element != "undefined", n = typeof Map == "function", r = typeof Set == "function", i = typeof ArrayBuffer == "function" && !!ArrayBuffer.isView;
686
- function u(s, o) {
687
- if (s === o) return !0;
688
- if (s && o && typeof s == "object" && typeof o == "object") {
689
- if (s.constructor !== o.constructor) return !1;
690
- var c, a, l;
691
- if (Array.isArray(s)) {
692
- if (c = s.length, c != o.length) return !1;
693
- for (a = c; a-- !== 0; )
694
- if (!u(s[a], o[a])) return !1;
695
- return !0;
696
- }
697
- var f;
698
- if (n && s instanceof Map && o instanceof Map) {
699
- if (s.size !== o.size) return !1;
700
- for (f = s.entries(); !(a = f.next()).done; )
701
- if (!o.has(a.value[0])) return !1;
702
- for (f = s.entries(); !(a = f.next()).done; )
703
- if (!u(a.value[1], o.get(a.value[0]))) return !1;
704
- return !0;
705
- }
706
- if (r && s instanceof Set && o instanceof Set) {
707
- if (s.size !== o.size) return !1;
708
- for (f = s.entries(); !(a = f.next()).done; )
709
- if (!o.has(a.value[0])) return !1;
710
- return !0;
711
- }
712
- if (i && ArrayBuffer.isView(s) && ArrayBuffer.isView(o)) {
713
- if (c = s.length, c != o.length) return !1;
714
- for (a = c; a-- !== 0; )
715
- if (s[a] !== o[a]) return !1;
716
- return !0;
717
- }
718
- if (s.constructor === RegExp) return s.source === o.source && s.flags === o.flags;
719
- if (s.valueOf !== Object.prototype.valueOf && typeof s.valueOf == "function" && typeof o.valueOf == "function") return s.valueOf() === o.valueOf();
720
- if (s.toString !== Object.prototype.toString && typeof s.toString == "function" && typeof o.toString == "function") return s.toString() === o.toString();
721
- if (l = Object.keys(s), c = l.length, c !== Object.keys(o).length) return !1;
722
- for (a = c; a-- !== 0; )
723
- if (!Object.prototype.hasOwnProperty.call(o, l[a])) return !1;
724
- if (e && s instanceof Element) return !1;
725
- for (a = c; a-- !== 0; )
726
- if (!((l[a] === "_owner" || l[a] === "__v" || l[a] === "__o") && s.$$typeof) && !u(s[l[a]], o[l[a]]))
727
- return !1;
728
- return !0;
729
- }
730
- return s !== s && o !== o;
731
- }
732
- return F = function(o, c) {
733
- try {
734
- return u(o, c);
735
- } catch (a) {
736
- if ((a.message || "").match(/stack|recursion/i))
737
- return console.warn("react-fast-compare cannot handle circular refs"), !1;
738
- throw a;
739
- }
740
- }, F;
741
- }
742
- var Xe = Ye();
743
- const Je = /* @__PURE__ */ Ce(Xe), et = (e) => t.memo(function(f) {
744
- var m = f, {
745
- src: r,
746
- alt: i,
747
- width: u,
748
- height: s,
749
- className: o,
750
- style: c,
751
- layout: a
752
- } = m, l = x(m, [
753
- "src",
754
- "alt",
755
- "width",
756
- "height",
757
- "className",
758
- "style",
759
- "layout"
760
- ]);
761
- return a || (a = u && s ? "intrinsic" : "fill"), /* @__PURE__ */ t.createElement(
762
- e,
763
- y({
764
- className: o,
765
- src: r,
766
- alt: i,
767
- width: a === "intrinsic" && u,
768
- height: a === "intrinsic" && s,
769
- objectFit: c == null ? void 0 : c.objectFit,
770
- objectPosition: c == null ? void 0 : c.objectPosition,
771
- layout: a
772
- }, l)
773
- );
774
- }, Je), tt = (e) => function(E) {
775
- var h = E, {
776
- href: r,
777
- as: i,
778
- passHref: u,
779
- prefetch: s,
780
- replace: o,
781
- scroll: c,
782
- shallow: a,
783
- locale: l,
784
- className: f,
785
- style: m
786
- } = h, d = x(h, [
787
- "href",
788
- "as",
789
- "passHref",
790
- "prefetch",
791
- "replace",
792
- "scroll",
793
- "shallow",
794
- "locale",
795
- "className",
796
- "style"
797
- ]);
798
- return /* @__PURE__ */ t.createElement(
799
- e,
800
- y({
801
- href: r,
802
- as: i,
803
- prefetch: s,
804
- replace: o,
805
- scroll: c,
806
- shallow: a,
807
- locale: l,
808
- className: f,
809
- style: m
810
- }, d)
811
- );
812
- }, nt = (e) => /* @__PURE__ */ t.createElement("a", y({ target: "_blank", rel: "noopener noreferrer" }, e)), rt = t.memo(nt), ot = (r) => {
813
- var i = r, { href: e } = i, n = x(i, ["href"]);
814
- var c, a;
815
- const { recordMap: u, rootSpaceId: s } = I();
816
- let o = e;
817
- if (typeof e == "string" && s) {
818
- const l = D(e);
819
- if (l) {
820
- const f = (a = (c = u == null ? void 0 : u.block) == null ? void 0 : c[l]) == null ? void 0 : a.value;
821
- (!f || f.space_id !== s) && (o = `https://notion.so/${l.replace(/-/g, "")}`);
822
- }
823
- }
824
- return /* @__PURE__ */ t.createElement("a", y({ href: o }, n));
825
- }, at = t.memo(ot), it = (e) => /* @__PURE__ */ t.createElement(ht, y({}, e)), st = Ge, St = (s) => {
826
- var o = s, { href: e, rel: n, target: r, title: i } = o, u = x(o, ["href", "rel", "target", "title"]);
827
- return /* @__PURE__ */ t.createElement("span", y({}, u));
828
- }, j = (e) => () => (console.warn(`Warning: using empty component "${e}" (you should override this in NotionRenderer.components)`), null), L = (e, n) => n(), se = {
829
- Image: null,
830
- // disable custom images by default
831
- Link: rt,
832
- PageLink: at,
833
- Checkbox: Ne,
834
- Callout: void 0,
835
- // use the built-in callout rendering by default
836
- Code: j("Code"),
837
- Equation: j("Equation"),
838
- Collection: j("Collection"),
839
- Property: void 0,
840
- // use the built-in property rendering by default
841
- propertyTextValue: L,
842
- propertySelectValue: L,
843
- propertyRelationValue: L,
844
- propertyFormulaValue: L,
845
- propertyTitleValue: L,
846
- propertyPersonValue: L,
847
- propertyFileValue: L,
848
- propertyCheckboxValue: L,
849
- propertyUrlValue: L,
850
- propertyEmailValue: L,
851
- propertyPhoneNumberValue: L,
852
- propertyNumberValue: L,
853
- propertyLastEditedTimeValue: L,
854
- propertyCreatedTimeValue: L,
855
- propertyDateValue: L,
856
- Pdf: j("Pdf"),
857
- Tweet: j("Tweet"),
858
- Modal: j("Modal"),
859
- Header: st,
860
- Embed: it
861
- }, ce = {
862
- recordMap: {
863
- block: {},
864
- collection: {},
865
- collection_view: {},
866
- collection_query: {},
867
- notion_user: {},
868
- signed_urls: {}
869
- },
870
- components: se,
871
- mapPageUrl: re(),
872
- mapImageUrl: ne,
873
- searchNotion: null,
874
- isShowingSearch: !1,
875
- onHideSearch: null,
876
- fullPage: !1,
877
- darkMode: !1,
878
- previewImages: !1,
879
- forceCustomImages: !1,
880
- showCollectionViewDropdown: !0,
881
- linkTableTitleProperties: !0,
882
- isLinkCollectionToUrlProperty: !1,
883
- showTableOfContents: !1,
884
- minTableOfContentsItems: 3,
885
- defaultPageIcon: null,
886
- defaultPageCover: null,
887
- defaultPageCoverPosition: 0.5,
888
- zoom: null
889
- }, Z = t.createContext(ce), ct = (c) => {
890
- var a = c, {
891
- components: e = {},
892
- children: n,
893
- mapPageUrl: r,
894
- mapImageUrl: i,
895
- rootPageId: u,
896
- rootSpaceId: s
897
- } = a, o = x(a, [
898
- "components",
899
- "children",
900
- "mapPageUrl",
901
- "mapImageUrl",
902
- "rootPageId",
903
- "rootSpaceId"
904
- ]);
905
- for (const m of Object.keys(o)) o[m] === void 0 && delete o[m];
906
- const l = t.useMemo(() => {
907
- const m = y({}, e);
908
- if (m.nextImage && (m.Image = et(m.nextImage)), m.nextLink) {
909
- const d = tt(m.nextLink);
910
- m.nextLink = d, m.PageLink || (m.PageLink = d), m.Link || (m.Link = d);
911
- }
912
- for (const d of Object.keys(m)) m[d] || delete m[d];
913
- return m;
914
- }, [e]), f = t.useMemo(
915
- () => k(y(y({}, ce), o), {
916
- rootPageId: u,
917
- rootSpaceId: s,
918
- mapPageUrl: r != null ? r : re(u),
919
- mapImageUrl: i != null ? i : ne,
920
- components: y(y({}, se), l)
921
- }),
922
- [i, r, l, u, s, o]
923
- );
924
- return /* @__PURE__ */ t.createElement(Z.Provider, { value: f }, n);
925
- }, lt = Z.Consumer, I = () => t.useContext(Z), ut = (e) => Object.keys(e).map((n) => `${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`).join("&"), mt = ({
926
- id: e,
927
- defaultPlay: n = !1,
928
- mute: r = !1,
929
- lazyImage: i = !1,
930
- iframeTitle: u = "YouTube video",
931
- alt: s = "Video preview",
932
- params: o = {},
933
- adLinksPreconnect: c = !0,
934
- style: a,
935
- className: l
936
- }) => {
937
- const f = r || n ? "1" : "0", m = t.useMemo(() => ut(y({ autoplay: "1", mute: f }, o)), [f, o]), E = `https://i.ytimg.com/vi/${e}/hqdefault.jpg`, h = "https://www.youtube-nocookie.com", p = `${h}/embed/${e}?${m}`, [N, S] = t.useState(!1), [b, _] = t.useState(n), [C, g] = t.useState(!1), v = t.useCallback(() => {
938
- N || S(!0);
939
- }, [N]), w = t.useCallback(() => {
940
- b || _(!0);
941
- }, [b]), O = t.useCallback(() => {
942
- g(!0);
943
- }, []);
944
- return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("link", { rel: "preload", href: E, as: "image" }), N && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("link", { rel: "preconnect", href: h }), /* @__PURE__ */ t.createElement("link", { rel: "preconnect", href: "https://www.google.com" })), N && c && /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("link", { rel: "preconnect", href: "https://static.doubleclick.net" }), /* @__PURE__ */ t.createElement("link", { rel: "preconnect", href: "https://googleads.g.doubleclick.net" })), /* @__PURE__ */ t.createElement(
945
- "div",
946
- {
947
- onClick: w,
948
- onPointerOver: v,
949
- className: `notion-yt-lite
950
- ${C && "notion-yt-loaded"}
951
- ${b && "notion-yt-initialized"}
952
- ${l || ""}`,
953
- style: a
954
- },
955
- /* @__PURE__ */ t.createElement("img", { src: E, className: "notion-yt-thumbnail", loading: i ? "lazy" : void 0, alt: s }),
956
- /* @__PURE__ */ t.createElement("div", { className: "notion-yt-playbtn" }),
957
- b && /* @__PURE__ */ t.createElement(
958
- "iframe",
959
- {
960
- width: "560",
961
- height: "315",
962
- frameBorder: "0",
963
- allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
964
- allowFullScreen: !0,
965
- title: u,
966
- src: p,
967
- onLoad: O
968
- }
969
- )
970
- ));
971
- }, ft = typeof window == "undefined", pt = [
972
- "video",
973
- "image",
974
- "embed",
975
- "figma",
976
- "typeform",
977
- "excalidraw",
978
- "maps",
979
- "tweet",
980
- "pdf",
981
- "gist",
982
- "codepen",
983
- "drive"
984
- ], dt = ({ block: e, zoomable: n = !0, children: r }) => {
985
- var f, m, d, E, h, p, N, S, b, _;
986
- const { recordMap: i, mapImageUrl: u, components: s } = I();
987
- if (!e || !pt.includes(e.type)) return null;
988
- const o = {
989
- position: "relative",
990
- display: "flex",
991
- justifyContent: "center",
992
- alignSelf: "center",
993
- width: "100%",
994
- maxWidth: "100%",
995
- flexDirection: "column"
996
- }, c = {};
997
- if (e.format) {
998
- const { block_aspect_ratio: C, block_height: g, block_width: v, block_full_width: w, block_page_width: O, block_preserve_scale: $ } = e.format;
999
- if (w || O)
1000
- w ? o.width = "100vw" : o.width = "100%", e.type === "video" ? g ? o.height = g : C ? o.paddingBottom = `${C * 100}%` : $ && (o.objectFit = "contain") : C && e.type !== "image" ? o.paddingBottom = `${C * 100}%` : g ? o.height = g : $ && (e.type === "image" ? o.height = "100%" : (o.paddingBottom = "75%", o.minHeight = 100));
1001
- else {
1002
- switch ((f = e.format) == null ? void 0 : f.block_alignment) {
1003
- case "center": {
1004
- o.alignSelf = "center";
1005
- break;
1006
- }
1007
- case "left": {
1008
- o.alignSelf = "start";
1009
- break;
1010
- }
1011
- case "right": {
1012
- o.alignSelf = "end";
1013
- break;
1014
- }
1015
- }
1016
- v && (o.width = v), $ && e.type !== "image" ? (o.paddingBottom = "50%", o.minHeight = 100) : g && e.type !== "image" && (o.height = g);
1017
- }
1018
- e.type === "image" ? c.objectFit = "cover" : $ && (c.objectFit = "contain");
1019
- }
1020
- let a = ((m = i.signed_urls) == null ? void 0 : m[e.id]) || ((h = (E = (d = e.properties) == null ? void 0 : d.source) == null ? void 0 : E[0]) == null ? void 0 : h[0]), l = null;
1021
- if (!a) return null;
1022
- if (e.type === "tweet") {
1023
- const C = a;
1024
- if (!C) return null;
1025
- const g = C.split("?")[0].split("/").pop();
1026
- if (!g) return null;
1027
- l = /* @__PURE__ */ t.createElement(
1028
- "div",
1029
- {
1030
- style: k(y({}, c), {
1031
- maxWidth: 420,
1032
- width: "100%",
1033
- marginLeft: "auto",
1034
- marginRight: "auto"
1035
- })
1036
- },
1037
- /* @__PURE__ */ t.createElement(s.Tweet, { id: g })
1038
- );
1039
- } else if (e.type === "pdf")
1040
- o.overflow = "auto", o.background = "rgb(226, 226, 226)", o.display = "block", o.padding || (o.padding = "8px 16px"), ft || (l = /* @__PURE__ */ t.createElement(s.Pdf, { file: a }));
1041
- else if (e.type === "embed" || e.type === "video" || e.type === "figma" || e.type === "typeform" || e.type === "gist" || e.type === "maps" || e.type === "excalidraw" || e.type === "codepen" || e.type === "drive")
1042
- if (e.type === "video" && a && a.indexOf("youtube") < 0 && a.indexOf("youtu.be") < 0 && a.indexOf("vimeo") < 0 && a.indexOf("wistia") < 0 && a.indexOf("loom") < 0 && a.indexOf("videoask") < 0 && a.indexOf("getcloudapp") < 0)
1043
- o.paddingBottom = void 0, l = /* @__PURE__ */ t.createElement("video", { playsInline: !0, controls: !0, preload: "metadata", style: c, src: a, title: e.type });
1044
- else {
1045
- let C = ((p = e.format) == null ? void 0 : p.display_source) || a;
1046
- if (C) {
1047
- const g = e.type === "video" ? _e(C) : null;
1048
- g ? l = /* @__PURE__ */ t.createElement(mt, { id: g, style: c, className: "notion-asset-object-fit" }) : e.type === "gist" ? (C.endsWith(".pibb") || (C = `${C}.pibb`), c.width = "100%", o.paddingBottom = "50%", l = /* @__PURE__ */ t.createElement(
1049
- "iframe",
1050
- {
1051
- style: c,
1052
- className: "notion-asset-object-fit",
1053
- src: C,
1054
- title: "GitHub Gist",
1055
- frameBorder: "0",
1056
- loading: "lazy",
1057
- scrolling: "auto"
1058
- }
1059
- )) : l = /* @__PURE__ */ t.createElement(
1060
- "iframe",
1061
- {
1062
- className: "notion-asset-object-fit",
1063
- style: c,
1064
- src: C,
1065
- title: `iframe ${e.type}`,
1066
- frameBorder: "0",
1067
- allowFullScreen: !0,
1068
- loading: "lazy",
1069
- scrolling: "auto"
1070
- }
1071
- );
1072
- }
1073
- }
1074
- else if (e.type === "image") {
1075
- a.includes("file.notion.so") && (a = (b = (S = (N = e.properties) == null ? void 0 : N.source) == null ? void 0 : S[0]) == null ? void 0 : b[0]);
1076
- const C = u(a, e), v = ve((_ = e.properties) == null ? void 0 : _.caption) || "notion image";
1077
- l = /* @__PURE__ */ t.createElement(U, { src: C, alt: v, zoomable: n, height: o.height, style: c });
1078
- }
1079
- return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("div", { style: o }, l, e.type === "image" && r), e.type !== "image" && r);
1080
- }, gt = { width: "100%" }, ht = ({ blockId: e, block: n }) => {
1081
- var l, f, m, d, E, h;
1082
- const r = n, { components: i, mapPageUrl: u, rootDomain: s, zoom: o } = I();
1083
- let c = !1;
1084
- if (n.type === "image") {
1085
- const p = (m = (f = (l = r == null ? void 0 : r.properties) == null ? void 0 : l.caption) == null ? void 0 : f[0]) == null ? void 0 : m[0];
1086
- if (p) {
1087
- const N = D(p, { uuid: !0 });
1088
- (p.charAt(0) === "/" && N || yt(p)) && (c = !0);
1089
- }
1090
- }
1091
- const a = /* @__PURE__ */ t.createElement(
1092
- "figure",
1093
- {
1094
- className: `notion-asset-wrapper
1095
- notion-asset-wrapper-${n.type}
1096
- ${(d = r.format) != null && d.block_full_width ? "notion-asset-wrapper-full" : ""}
1097
- ${e}`
1098
- },
1099
- /* @__PURE__ */ t.createElement(dt, { block: r, zoomable: o && !c }, ((E = r == null ? void 0 : r.properties) == null ? void 0 : E.caption) && !c && /* @__PURE__ */ t.createElement("figcaption", { className: "notion-asset-caption" }, /* @__PURE__ */ t.createElement(H, { value: r.properties.caption, block: n })))
1100
- );
1101
- if (c) {
1102
- const p = (h = r == null ? void 0 : r.properties) == null ? void 0 : h.caption[0][0], N = D(p, { uuid: !0 }), S = p.charAt(0) === "/" && N, b = Et(p);
1103
- return /* @__PURE__ */ t.createElement(
1104
- i.PageLink,
1105
- {
1106
- style: gt,
1107
- href: S ? u(N) : p,
1108
- target: b && b !== s && !p.startsWith("/") ? "blank_" : null
1109
- },
1110
- a
1111
- );
1112
- }
1113
- return a;
1114
- };
1115
- function yt(e) {
1116
- return !!new RegExp(
1117
- "^(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_]*)?$",
1118
- "i"
1119
- ).test(e);
1120
- }
1121
- function Et(e) {
1122
- try {
1123
- return new URL(e).hostname;
1124
- } catch (n) {
1125
- return "";
1126
- }
1127
- }
1128
- export {
1129
- ht as A,
1130
- Qe as B,
1131
- Ne as C,
1132
- Me as E,
1133
- ee as G,
1134
- Ge as H,
1135
- U as L,
1136
- ct as N,
1137
- A as P,
1138
- Ke as S,
1139
- H as T,
1140
- q as a,
1141
- Se as b,
1142
- _e as c,
1143
- St as d,
1144
- lt as e,
1145
- Ie as f,
1146
- Ot as g,
1147
- Ze as h,
1148
- Le as i,
1149
- Ae as j,
1150
- mt as k,
1151
- dt as l,
1152
- I as u
1153
- };
1154
- //# sourceMappingURL=asset-wrapper-BbigBRET.js.map