@texonom/nreact 1.5.9 → 1.6.0

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