@backmatter/studio 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/chunks/{UiKitApp-BxvTwsko.js → UiKitApp-ZZXQt3zy.js} +29 -29
  2. package/dist/chunks/{WorkspaceRoutes-BKKEkAq7.js → WorkspaceRoutes-CCDPtLla.js} +22712 -22498
  3. package/dist/chunks/{dashboard-8rjkfEXl.js → dashboard-Dw0zfTXg.js} +35 -35
  4. package/dist/chunks/{index-laWAz5_p.js → index-DhZGCAru.js} +1 -1
  5. package/dist/dashboard.js +2 -2
  6. package/dist/index.js +199 -193
  7. package/dist/site-widget.css +9 -1
  8. package/dist/site-widget.js +6060 -5936
  9. package/dist/studio.css +5 -25
  10. package/package.json +5 -1
  11. package/src/api.ts +1 -1
  12. package/src/chat/ChatProvider.tsx +13 -2
  13. package/src/chat/Composer.tsx +2 -1
  14. package/src/chat/PointerChip.tsx +15 -2
  15. package/src/chat/chat-helpers.ts +6 -0
  16. package/src/chat/pointer-arm.ts +3 -0
  17. package/src/chrome/WorkspaceStatusBar.tsx +64 -25
  18. package/src/chrome/branch-head.ts +14 -0
  19. package/src/chrome/commit-error.ts +82 -0
  20. package/src/chrome/commit-failure.tsx +111 -0
  21. package/src/install-preview-pointer.ts +116 -0
  22. package/src/pages/BlocksList.tsx +17 -2
  23. package/src/pages/DocEditorPage.tsx +121 -23
  24. package/src/pages/EmbedPublishPage.tsx +27 -24
  25. package/src/pages/RenderedBody.tsx +141 -322
  26. package/src/pages/document-paint.ts +79 -0
  27. package/src/pages/editor-grab.ts +39 -0
  28. package/src/pages/html-to-markdown.ts +26 -0
  29. package/src/pages/preview-bridge.ts +8 -1
  30. package/src/pages/preview-url.ts +15 -0
  31. package/src/pages/selection-format.ts +5 -2
  32. package/src/preview-highlight.ts +16 -0
  33. package/src/preview-pointer-host.ts +30 -0
  34. package/src/shell-resets.css +13 -0
  35. package/src/site-changes.ts +46 -0
  36. package/src/site-pointer.ts +39 -6
  37. package/src/site-widget.tsx +66 -23
package/dist/index.js CHANGED
@@ -1,37 +1,37 @@
1
- import { jsx as t, jsxs as d } from "react/jsx-runtime";
2
- import { useLayoutEffect as re, useEffect as f, useRef as W, useState as g, useMemo as oe } from "react";
3
- import { i as J, T as ae, E as se, C as ce, a as le, b as de, u as ue, D as A, c as X, d as B, e as xe, f as Y, g as G, h as me, p as z, j as C, k as N, r as fe, n as he, s as pe, l as ge, m as we, o as be, q as ye, B as ve, t as ke, S as qe, v as Ee, w as Q, x as P, y as ze, z as Ce, A as Ne, R as Se, F as Re, G as Le, H as Pe, I as S, N as I, L as Ue, J as je, K as F, M as Te } from "./chunks/WorkspaceRoutes-BKKEkAq7.js";
4
- import { O as ot } from "./chunks/WorkspaceRoutes-BKKEkAq7.js";
5
- import { u as Me, S as _e } from "./chunks/define-studio-BYtYDGLX.js";
6
- import { d as st } from "./chunks/define-studio-BYtYDGLX.js";
7
- const R = {
1
+ import { jsx as t, jsxs as u } from "react/jsx-runtime";
2
+ import { useLayoutEffect as oe, useEffect as f, useRef as Q, useState as h, useMemo as se } from "react";
3
+ import { i as X, T as ce, E as le, C as ue, a as de, b as xe, u as me, D as _, c as Y, d as I, e as fe, f as Z, g as G, h as pe, p as E, j as C, k as he, l as ge, m as S, r as we, n as be, s as ye, o as ve, q as ke, t as qe, v as ze, w as Ee, B as Ce, x as Ne, S as Se, y as Re, z as ee, A as U, F as Pe, G as Le, H as Ue, R as je, I as Te, J as Me, K as $e, L as R, N as K, M as De, O as Fe, P as H, Q as Oe } from "./chunks/WorkspaceRoutes-CCDPtLla.js";
4
+ import { U as lt } from "./chunks/WorkspaceRoutes-CCDPtLla.js";
5
+ import { u as Ae, S as Be } from "./chunks/define-studio-BYtYDGLX.js";
6
+ import { d as dt } from "./chunks/define-studio-BYtYDGLX.js";
7
+ const P = {
8
8
  accent: "var(--x11n7hvk)",
9
9
  accentHover: "var(--x1vnpaut)",
10
10
  focus: "var(--x1nzi8h4)"
11
11
  };
12
- function $e(e) {
12
+ function _e(e) {
13
13
  const n = /^var\((--[^,)]+)/.exec(e);
14
14
  return (n == null ? void 0 : n[1]) ?? null;
15
15
  }
16
- const De = [R.accent, R.accentHover, R.focus];
17
- function Oe() {
18
- var n, a;
19
- const e = (a = (n = Me().theme) == null ? void 0 : n.accent) == null ? void 0 : a.trim();
20
- return re(() => {
16
+ const Ie = [P.accent, P.accentHover, P.focus];
17
+ function Ge() {
18
+ var n, o;
19
+ const e = (o = (n = Ae().theme) == null ? void 0 : n.accent) == null ? void 0 : o.trim();
20
+ return oe(() => {
21
21
  if (!e) return;
22
- const o = document.documentElement, r = De.map($e).filter((s) => !!s);
23
- for (const s of r) o.style.setProperty(s, e);
22
+ const a = document.documentElement, i = Ie.map(_e).filter((s) => !!s);
23
+ for (const s of i) a.style.setProperty(s, e);
24
24
  return () => {
25
- for (const s of r) o.style.removeProperty(s);
25
+ for (const s of i) a.style.removeProperty(s);
26
26
  };
27
27
  }, [e]), null;
28
28
  }
29
- function Ae({ workspaceId: e }) {
30
- return f(() => J(), []), /* @__PURE__ */ t(ae, { children: /* @__PURE__ */ t(se, { children: /* @__PURE__ */ t(ce, { workspaceId: e, startOpen: !0, pointer: !0, children: /* @__PURE__ */ d(le, { children: [
31
- /* @__PURE__ */ t(Be, {}),
32
- /* @__PURE__ */ t(Ge, {}),
33
- /* @__PURE__ */ t(Ie, {}),
34
- /* @__PURE__ */ t(de, { fill: !0 })
29
+ function Ke({ workspaceId: e }) {
30
+ return f(() => X(), []), /* @__PURE__ */ t(ce, { children: /* @__PURE__ */ t(le, { children: /* @__PURE__ */ t(ue, { workspaceId: e, startOpen: !0, pointer: !0, children: /* @__PURE__ */ u(de, { children: [
31
+ /* @__PURE__ */ t(He, {}),
32
+ /* @__PURE__ */ t(Ve, {}),
33
+ /* @__PURE__ */ t(We, {}),
34
+ /* @__PURE__ */ t(xe, { fill: !0 })
35
35
  ] }) }) }) });
36
36
  }
37
37
  function y() {
@@ -42,15 +42,15 @@ function y() {
42
42
  return "";
43
43
  }
44
44
  }
45
- function Be() {
46
- const { setFocus: e } = ue();
45
+ function He() {
46
+ const { setFocus: e } = me();
47
47
  return f(() => {
48
48
  const n = y();
49
- function a(o) {
50
- if (!n || o.origin !== n) return;
51
- const r = o.data;
52
- if ((r == null ? void 0 : r.type) !== "backmatter:focus") return;
53
- const s = r.doc;
49
+ function o(a) {
50
+ if (!n || a.origin !== n) return;
51
+ const i = a.data;
52
+ if ((i == null ? void 0 : i.type) !== "backmatter:focus") return;
53
+ const s = i.doc;
54
54
  !(s != null && s.locale) || !s.type || !s.slug || e({
55
55
  docRef: { locale: s.locale, type: s.type, slug: s.slug },
56
56
  frontmatter: {},
@@ -58,53 +58,53 @@ function Be() {
58
58
  selection: null
59
59
  });
60
60
  }
61
- return window.addEventListener("message", a), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", a);
61
+ return window.addEventListener("message", o), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", o);
62
62
  }, [e]), f(() => {
63
63
  const n = y();
64
- function a(o) {
65
- const r = o.detail;
66
- !n || !(r != null && r.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: r.docRef }, n);
64
+ function o(a) {
65
+ const i = a.detail;
66
+ !n || !(i != null && i.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: i.docRef }, n);
67
67
  }
68
- return window.addEventListener(A, a), () => window.removeEventListener(A, a);
68
+ return window.addEventListener(_, o), () => window.removeEventListener(_, o);
69
69
  }, []), null;
70
70
  }
71
- function Ge() {
72
- const { addPointer: e } = X();
71
+ function Ve() {
72
+ const { addPointer: e } = Y();
73
73
  return f(() => {
74
74
  const n = y();
75
- function a(o) {
76
- if (!n || o.origin !== n || o.source !== window.parent) return;
77
- const r = o.data;
78
- if ((r == null ? void 0 : r.type) !== "backmatter:pointer-grab") return;
79
- const s = xe(
80
- r.doc ?? {},
81
- r.grab
75
+ function o(a) {
76
+ if (!n || a.origin !== n || a.source !== window.parent) return;
77
+ const i = a.data;
78
+ if ((i == null ? void 0 : i.type) !== "backmatter:pointer-grab") return;
79
+ const s = fe(
80
+ i.doc ?? {},
81
+ i.grab
82
82
  );
83
83
  s && e(s);
84
84
  }
85
- return window.addEventListener("message", a), () => window.removeEventListener("message", a);
85
+ return window.addEventListener("message", o), () => window.removeEventListener("message", o);
86
86
  }, [e]), null;
87
87
  }
88
- function Ie() {
89
- const { panel: e, dispatch: n } = X(), a = e.mode, o = W(a);
88
+ function We() {
89
+ const { panel: e, dispatch: n } = Y(), o = e.mode, a = Q(o);
90
90
  return f(() => {
91
- const r = y();
92
- if (!r || window.parent === window) return;
93
- const s = B(o.current);
94
- o.current = a, s && !B(a) && window.parent.postMessage({ type: "backmatter:chat-closed" }, r);
95
- }, [a]), f(() => {
96
- const r = y();
97
- function s(h) {
91
+ const i = y();
92
+ if (!i || window.parent === window) return;
93
+ const s = I(a.current);
94
+ a.current = o, s && !I(o) && window.parent.postMessage({ type: "backmatter:chat-closed" }, i);
95
+ }, [o]), f(() => {
96
+ const i = y();
97
+ function s(p) {
98
98
  var m;
99
- !r || h.origin !== r || ((m = h.data) == null ? void 0 : m.type) === "backmatter:chat-open" && (n({ type: "open" }), requestAnimationFrame(() => {
99
+ !i || p.origin !== i || ((m = p.data) == null ? void 0 : m.type) === "backmatter:chat-open" && (n({ type: "open" }), requestAnimationFrame(() => {
100
100
  window.dispatchEvent(new Event("backmatter:chat-focus"));
101
101
  }));
102
102
  }
103
103
  return window.addEventListener("message", s), () => window.removeEventListener("message", s);
104
104
  }, [n]), null;
105
105
  }
106
- const Fe = 8e3;
107
- function K() {
106
+ const Je = 8e3;
107
+ function V() {
108
108
  if (!document.referrer) return "";
109
109
  try {
110
110
  return new URL(document.referrer).origin;
@@ -112,157 +112,163 @@ function K() {
112
112
  return "";
113
113
  }
114
114
  }
115
- function Ke(e) {
116
- if (!(e instanceof Error)) return "Commit failed";
117
- const n = e;
118
- return n.code === "conflict" ? "Resolve conflicts before committing" : n.code === "nothing_to_commit" ? "Nothing to commit" : n.code === "validation" ? e.message.replace(/^validation:\s*/, "Validation failed: ") : n.code === "github_not_bound" ? "Connect GitHub first" : e.message;
119
- }
120
115
  function L(e) {
121
116
  return `${e.locale}/${e.type}/${e.slug}`;
122
117
  }
123
- const He = {
118
+ const Qe = {
124
119
  modified: "modified",
125
120
  added: "new",
126
121
  conflict: "conflict",
127
122
  deleted: "deleted"
128
123
  };
129
- function Ve({
124
+ function Xe({
130
125
  workspaceId: e,
131
126
  onStatus: n,
132
- onPublished: a
127
+ onPublished: o
133
128
  }) {
134
- f(() => J(), []);
135
- const [o, r] = g(null), [s, h] = g("viewer"), [m, w] = g(""), [c, p] = g(null), [v, U] = g(!1), [k, j] = g(null);
129
+ f(() => X(), []);
130
+ const [a, i] = h(null), [s, p] = h("viewer"), [m, w] = h(""), [c, g] = h(null), [N, j] = h(null), [v, T] = h(!1), [k, M] = h(null);
136
131
  f(() => {
137
- let i = !1;
138
- return Y(e).then((l) => {
139
- i || h(l.workspace.role);
132
+ let r = !1;
133
+ return Z(e).then((l) => {
134
+ r || p(l.workspace.role);
140
135
  }).catch(() => {
141
- i || p("Could not load this workspace");
136
+ r || g("Could not load this workspace");
142
137
  }), () => {
143
- i = !0;
138
+ r = !0;
144
139
  };
145
140
  }, [e]);
146
- const q = W(n);
141
+ const q = Q(n);
147
142
  q.current = n, f(() => {
148
- let i = !1;
143
+ let r = !1;
149
144
  const l = () => {
150
- N(e).then((x) => {
151
- var O;
152
- if (i) return;
153
- r(x);
154
- const _ = x.changes.length, $ = G(x);
155
- (O = q.current) == null || O.call(q, {
156
- changeCount: _,
157
- conflictCount: $
145
+ S(e).then((x) => {
146
+ var B;
147
+ if (r) return;
148
+ i(x);
149
+ const F = x.changes.length, O = G(x);
150
+ (B = q.current) == null || B.call(q, {
151
+ changeCount: F,
152
+ conflictCount: O
158
153
  });
159
- const D = K();
160
- !D || window.parent === window || window.parent.postMessage({
154
+ const A = V();
155
+ !A || window.parent === window || window.parent.postMessage({
161
156
  type: "backmatter:git",
162
- changeCount: _,
163
- conflictCount: $
164
- }, D);
157
+ changeCount: F,
158
+ conflictCount: O
159
+ }, A);
165
160
  }).catch((x) => {
166
- i || p(x instanceof Error ? x.message : "Git status failed");
161
+ r || g(x instanceof Error ? x.message : "Git status failed");
167
162
  });
168
163
  };
169
164
  l();
170
- const b = window.setInterval(l, Fe);
165
+ const b = window.setInterval(l, Je);
171
166
  return () => {
172
- i = !0, window.clearInterval(b);
167
+ r = !0, window.clearInterval(b);
173
168
  };
174
169
  }, [e]);
175
- const u = (o == null ? void 0 : o.changes) ?? [], ee = G(o), E = pe(ee, be(s)), T = oe(() => u.filter((i) => i.status === "conflict"), [u]), te = me(u);
176
- async function M(i, l) {
177
- const b = `${L(i)}:${l}`;
178
- j(b), p(null);
170
+ const d = (a == null ? void 0 : a.changes) ?? [], ne = G(a), z = ye(ne, ze(s)), $ = se(() => d.filter((r) => r.status === "conflict"), [d]), re = pe(d);
171
+ async function D(r, l) {
172
+ const b = `${L(r)}:${l}`;
173
+ M(b), g(null);
179
174
  try {
180
- await fe(e, i.locale, i.type, i.slug, l), he({
175
+ await we(e, r.locale, r.type, r.slug, l), be({
181
176
  workspaceId: e,
182
- locale: i.locale,
183
- type: i.type,
184
- slug: i.slug,
177
+ locale: r.locale,
178
+ type: r.type,
179
+ slug: r.slug,
185
180
  status: l === "theirs" ? "clean" : "modified"
186
181
  });
187
- const x = await N(e);
188
- r(x);
182
+ const x = await S(e);
183
+ i(x);
189
184
  } catch (x) {
190
- p(x instanceof Error ? x.message : "Resolve failed");
185
+ g(x instanceof Error ? x.message : "Resolve failed");
191
186
  } finally {
192
- j(null);
187
+ M(null);
193
188
  }
194
189
  }
195
- async function ne(i) {
196
- if (i.preventDefault(), !(v || E !== "commit" || u.length === 0)) {
197
- U(!0), p(null);
190
+ async function ie(r) {
191
+ if (r.preventDefault(), !(v || z !== "commit" || d.length === 0)) {
192
+ T(!0), g(null), j(null);
198
193
  try {
199
- const l = await ge(e, m);
200
- w(""), we(e, l.files), a == null || a();
201
- const b = K();
194
+ const l = await ve(e, m);
195
+ w(""), ke(e, l.files), o == null || o();
196
+ const b = V();
202
197
  b && window.parent !== window && window.parent.postMessage({
203
198
  type: "backmatter:published"
204
- }, b), r(await N(e));
199
+ }, b), i(await S(e));
205
200
  } catch (l) {
206
- p(Ke(l));
201
+ j(qe(l));
207
202
  } finally {
208
- U(!1);
203
+ T(!1);
209
204
  }
210
205
  }
211
206
  }
212
- const ie = (o == null ? void 0 : o.currentBranch) ?? "main";
213
- return T.length > 0 ? /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
214
- /* @__PURE__ */ t("p", { ...z(C.groupLabel), children: "Resolve conflicts" }),
207
+ const ae = (a == null ? void 0 : a.currentBranch) ?? "main";
208
+ return $.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
209
+ /* @__PURE__ */ t("p", { ...E(C.groupLabel), children: "Resolve conflicts" }),
215
210
  /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Pick a side for each file. Commit stays blocked until every conflict is resolved." }),
216
211
  c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null,
217
- /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: T.map((i) => {
218
- const l = L(i);
219
- return /* @__PURE__ */ d("li", { className: "x78zum5 xdt5ytf xpw8yq9 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay", children: [
220
- /* @__PURE__ */ d("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
221
- i.type,
212
+ /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: $.map((r) => {
213
+ const l = L(r);
214
+ return /* @__PURE__ */ u("li", { className: "x78zum5 xdt5ytf xpw8yq9 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay", children: [
215
+ /* @__PURE__ */ u("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
216
+ r.type,
222
217
  "/",
223
- i.slug
218
+ r.slug
224
219
  ] }),
225
- /* @__PURE__ */ d("div", { className: "x78zum5 xpw8yq9", children: [
226
- /* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void M(i, "mine"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: k === `${l}:mine` ? "Keeping…" : "Keep mine" }),
227
- /* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void M(i, "theirs"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x13oidi x1hb2obb x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60 x1nf6o4h x1trrqm4", children: k === `${l}:theirs` ? "Taking…" : "Take theirs" })
220
+ /* @__PURE__ */ u("div", { className: "x78zum5 xpw8yq9", children: [
221
+ /* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void D(r, "mine"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: k === `${l}:mine` ? "Keeping…" : "Keep mine" }),
222
+ /* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void D(r, "theirs"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x13oidi x1hb2obb x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60 x1nf6o4h x1trrqm4", children: k === `${l}:theirs` ? "Taking…" : "Take theirs" })
228
223
  ] })
229
224
  ] }, l);
230
225
  }) })
231
- ] }) : /* @__PURE__ */ d("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (i) => void ne(i), children: [
232
- /* @__PURE__ */ t("p", { ...z(C.groupLabel), children: u.length === 0 ? "Nothing to publish" : `${u.length} ${u.length === 1 ? "file" : "files"} → ${ie}` }),
233
- u.length > 0 ? /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: u.map((i) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ d("div", { className: "x78zum5 x6s0dn4 x3smv4v x1rz828m x1ghz6dp x1obou79 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay x111yfic", children: [
234
- /* @__PURE__ */ d("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
235
- i.type,
236
- "/",
237
- i.slug
238
- ] }),
239
- /* @__PURE__ */ t("span", { ...z(C.itemMeta), children: He[i.status] })
240
- ] }) }, L(i))) }) : null,
241
- u.length > 0 ? /* @__PURE__ */ t("div", { ...z(C.separator) }) : null,
242
- u.length > 0 ? /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: [
243
- /* @__PURE__ */ t("input", { value: m, onChange: (i) => w(i.target.value), placeholder: te, "aria-label": "Commit message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: v || E !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
226
+ ] }) : /* @__PURE__ */ u("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (r) => void ie(r), children: [
227
+ /* @__PURE__ */ t("p", { ...E(C.groupLabel), children: d.length === 0 ? "Nothing to publish" : `${d.length} ${d.length === 1 ? "file" : "files"} → ${ae}` }),
228
+ N ? /* @__PURE__ */ t(he, { failure: N }) : null,
229
+ d.length > 0 ? /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: d.map((r) => {
230
+ const l = ge(N, `${r.type}/${r.slug}`).length > 0;
231
+ return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ u("div", { className: "x78zum5 x6s0dn4 x3smv4v x1rz828m x1ghz6dp x1obou79 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay x111yfic", children: [
232
+ /* @__PURE__ */ u("span", { ...{
233
+ 0: {
234
+ className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft"
235
+ },
236
+ 1: {
237
+ className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft x1trrqm4"
238
+ }
239
+ }[!!l << 0], children: [
240
+ r.type,
241
+ "/",
242
+ r.slug
243
+ ] }),
244
+ /* @__PURE__ */ t("span", { ...E(C.itemMeta), children: Qe[r.status] })
245
+ ] }) }, L(r));
246
+ }) }) : null,
247
+ d.length > 0 ? /* @__PURE__ */ t("div", { ...E(C.separator) }) : null,
248
+ d.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: [
249
+ /* @__PURE__ */ t("input", { value: m, onChange: (r) => w(r.target.value), placeholder: re, "aria-label": "Commit message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: v || z !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
244
250
  c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x10qp4ay x1trrqm4 xnjsko4 x18d9i69", children: c }) : null,
245
- E === "blocked" ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ t("button", { type: "submit", disabled: v || E !== "commit", className: "x78zum5 xh8yej3 x6s0dn4 xl56j7k x1fgtraw x161b3w3 xmkeg23 x1y0btm7 x14aomtw x13oidi xrb6rkd xfja90d x10qp4ay xk50ysn xuxw1ft x1ypdohk x2q2s9b x1dih85f xk0mbs4 x1s07b3s xd3so5o x784prv x9v5kkp x1yxvn1h x13iak60 xb93eig", children: v ? "Committing…" : "Commit & push" })
251
+ z === "blocked" ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ t("button", { type: "submit", disabled: v || z !== "commit", className: "x78zum5 xh8yej3 x6s0dn4 xl56j7k x1fgtraw x161b3w3 xmkeg23 x1y0btm7 x14aomtw x13oidi xrb6rkd xfja90d x10qp4ay xk50ysn xuxw1ft x1ypdohk x2q2s9b x1dih85f xk0mbs4 x1s07b3s xd3so5o x784prv x9v5kkp x1yxvn1h x13iak60 xb93eig", children: v ? "Committing…" : "Commit & push" })
246
252
  ] }) : c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null
247
253
  ] });
248
254
  }
249
- const H = "backmatter:enter-at", We = 1e4;
250
- function Z(e, n) {
255
+ const W = "backmatter:enter-at", Ye = 1e4;
256
+ function te(e, n) {
251
257
  if (typeof window > "u") return !1;
252
- const a = !!(window.top && window.top !== window);
253
- if (ke(a) === "parent")
258
+ const o = !!(window.top && window.top !== window);
259
+ if (Ne(o) === "parent")
254
260
  return window.parent.postMessage({
255
- type: qe
261
+ type: Se
256
262
  }, window.location.origin), !0;
257
- const o = Number(window.sessionStorage.getItem(H) ?? 0);
258
- return Date.now() - o < We ? !1 : (window.sessionStorage.setItem(H, String(Date.now())), window.location.assign(Ee(n, {
263
+ const a = Number(window.sessionStorage.getItem(W) ?? 0);
264
+ return Date.now() - a < Ye ? !1 : (window.sessionStorage.setItem(W, String(Date.now())), window.location.assign(Re(n, {
259
265
  workspaceId: e,
260
266
  returnUrl: window.location.href
261
267
  })), !0);
262
268
  }
263
- function Je(e) {
269
+ function Ze(e) {
264
270
  const n = e.dashboardUrl ?? "https://dash.backmatter.app";
265
- return Q({
271
+ return ee({
266
272
  baseUrl: e.proxyPath ?? "/api/backmatter/cms",
267
273
  publicApiUrl: e.apiUrl,
268
274
  credentials: "same-origin",
@@ -270,79 +276,79 @@ function Je(e) {
270
276
  version: e.version,
271
277
  dashboardUrl: n,
272
278
  onUnauthorized: ({
273
- status: a
279
+ status: o
274
280
  }) => {
275
- a === 401 && Z(e.workspaceId, n);
281
+ o === 401 && te(e.workspaceId, n);
276
282
  }
277
- }), P();
283
+ }), U();
278
284
  }
279
- function nt(e) {
280
- const n = e.basePath ?? "/backmatter", [a] = g(() => Je(e));
281
- return /* @__PURE__ */ t(_e, { definition: e.studio, children: /* @__PURE__ */ d(ye, { children: [
282
- /* @__PURE__ */ t(Oe, {}),
283
- /* @__PURE__ */ t(ve, { basename: n, children: /* @__PURE__ */ t(Xe, { ...e }) })
285
+ function ot(e) {
286
+ const n = e.basePath ?? "/backmatter", [o] = h(() => Ze(e));
287
+ return /* @__PURE__ */ t(Be, { definition: e.studio, children: /* @__PURE__ */ u(Ee, { children: [
288
+ /* @__PURE__ */ t(Ge, {}),
289
+ /* @__PURE__ */ t(Ce, { basename: n, children: /* @__PURE__ */ t(et, { ...e }) })
284
290
  ] }) });
285
291
  }
286
- function Xe(e) {
287
- const n = ze(), a = e.dashboardUrl ?? "https://dash.backmatter.app", [o, r] = g("loading");
292
+ function et(e) {
293
+ const n = Pe(), o = e.dashboardUrl ?? "https://dash.backmatter.app", [a, i] = h("loading");
288
294
  if (f(() => {
289
295
  let m = !1;
290
- const w = P().onUnauthorized;
291
- return Q({
292
- ...P(),
296
+ const w = U().onUnauthorized;
297
+ return ee({
298
+ ...U(),
293
299
  onUnauthorized: (c) => {
294
- c.status === 426 ? r("outdated") : w == null || w(c);
300
+ c.status === 426 ? i("outdated") : w == null || w(c);
295
301
  }
296
- }), Ce().then(async (c) => {
302
+ }), Le().then(async (c) => {
297
303
  if (m) return;
298
304
  if (!(c != null && c.user)) {
299
- Z(e.workspaceId, a) || r("unauthorized");
305
+ te(e.workspaceId, o) || i("unauthorized");
300
306
  return;
301
307
  }
302
308
  const {
303
- workspace: p
304
- } = await Y(e.workspaceId);
305
- m || r({
309
+ workspace: g
310
+ } = await Z(e.workspaceId);
311
+ m || i({
306
312
  user: {
307
313
  id: c.user.id,
308
314
  email: c.user.email
309
315
  },
310
- slug: p.slug
316
+ slug: g.slug
311
317
  });
312
318
  }).catch(() => {
313
- m || r((c) => c === "outdated" ? c : "unauthorized");
319
+ m || i((c) => c === "outdated" ? c : "unauthorized");
314
320
  }), () => {
315
321
  m = !0;
316
322
  };
317
- }, [e.workspaceId, a]), o === "loading") return /* @__PURE__ */ t(Ne, {});
318
- if (o === "outdated")
319
- return /* @__PURE__ */ d(V, { title: "This site's editor is out of date", children: [
323
+ }, [e.workspaceId, o]), a === "loading") return /* @__PURE__ */ t(Ue, {});
324
+ if (a === "outdated")
325
+ return /* @__PURE__ */ u(J, { title: "This site's editor is out of date", children: [
320
326
  "Update ",
321
327
  /* @__PURE__ */ t("code", { children: "@backmatter/studio" }),
322
328
  " and ",
323
329
  /* @__PURE__ */ t("code", { children: "@backmatter/next" }),
324
330
  " on the site, then reload."
325
331
  ] });
326
- if (o === "unauthorized")
327
- return /* @__PURE__ */ d(V, { title: "Could not start editing", children: [
332
+ if (a === "unauthorized")
333
+ return /* @__PURE__ */ u(J, { title: "Could not start editing", children: [
328
334
  "The site did not receive a session from the dashboard. Check that this site's origin is listed in the workspace settings and that ",
329
335
  /* @__PURE__ */ t("code", { children: "/api/backmatter" }),
330
336
  " routes are deployed."
331
337
  ] });
332
338
  const s = n.pathname.match(/^\/embed\/chat\/([^/]+)\/?$/);
333
339
  if (s != null && s[1])
334
- return /* @__PURE__ */ t(Ae, { workspaceId: decodeURIComponent(s[1]) });
335
- const h = n.pathname.match(/^\/embed\/publish\/([^/]+)\/?$/);
336
- return h != null && h[1] ? /* @__PURE__ */ t(Ve, { workspaceId: decodeURIComponent(h[1]) }) : /* @__PURE__ */ t(Se, { user: o.user, children: /* @__PURE__ */ t(Re, { children: /* @__PURE__ */ t(Le, { userId: o.user.id, email: o.user.email, onLogout: () => {
337
- Ye(e.previewEntryPath ?? "/api/backmatter/preview", a);
338
- }, children: /* @__PURE__ */ d(Pe, { children: [
339
- /* @__PURE__ */ t(S, { path: "/", element: /* @__PURE__ */ t(I, { to: `/${o.slug}`, replace: !0 }) }),
340
- /* @__PURE__ */ t(S, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(Ue, {}) }),
341
- je(),
342
- /* @__PURE__ */ t(S, { path: "*", element: /* @__PURE__ */ t(I, { to: "/", replace: !0 }) })
340
+ return /* @__PURE__ */ t(Ke, { workspaceId: decodeURIComponent(s[1]) });
341
+ const p = n.pathname.match(/^\/embed\/publish\/([^/]+)\/?$/);
342
+ return p != null && p[1] ? /* @__PURE__ */ t(Xe, { workspaceId: decodeURIComponent(p[1]) }) : /* @__PURE__ */ t(je, { user: a.user, children: /* @__PURE__ */ t(Te, { children: /* @__PURE__ */ t(Me, { userId: a.user.id, email: a.user.email, onLogout: () => {
343
+ tt(e.previewEntryPath ?? "/api/backmatter/preview", o);
344
+ }, children: /* @__PURE__ */ u($e, { children: [
345
+ /* @__PURE__ */ t(R, { path: "/", element: /* @__PURE__ */ t(K, { to: `/${a.slug}`, replace: !0 }) }),
346
+ /* @__PURE__ */ t(R, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(De, {}) }),
347
+ Fe(),
348
+ /* @__PURE__ */ t(R, { path: "*", element: /* @__PURE__ */ t(K, { to: "/", replace: !0 }) })
343
349
  ] }) }) }) });
344
350
  }
345
- async function Ye(e, n) {
351
+ async function tt(e, n) {
346
352
  try {
347
353
  await fetch(e, {
348
354
  method: "POST",
@@ -350,23 +356,23 @@ async function Ye(e, n) {
350
356
  });
351
357
  } catch {
352
358
  }
353
- Te.wipe(), window.location.assign(n);
359
+ Oe.wipe(), window.location.assign(n);
354
360
  }
355
- function V({
361
+ function J({
356
362
  title: e,
357
363
  children: n
358
364
  }) {
359
- return /* @__PURE__ */ t("div", { className: "x1ov3xa9 xrvj5dj x1ku5rj1 x1t7e3gq", children: /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf x1ndbd79 xq2pcee x1t7e3gq x4pepcl x1d0qn7y", children: [
360
- /* @__PURE__ */ t(F, { size: "lg", weight: "medium", children: e }),
361
- /* @__PURE__ */ t(F, { tone: "muted", children: n })
365
+ return /* @__PURE__ */ t("div", { className: "x1ov3xa9 xrvj5dj x1ku5rj1 x1t7e3gq", children: /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf x1ndbd79 xq2pcee x1t7e3gq x4pepcl x1d0qn7y", children: [
366
+ /* @__PURE__ */ t(H, { size: "lg", weight: "medium", children: e }),
367
+ /* @__PURE__ */ t(H, { tone: "muted", children: n })
362
368
  ] }) });
363
369
  }
364
370
  export {
365
- nt as SiteStudio,
366
- ot as apiUrl,
367
- Z as bounceToEnter,
368
- Je as configureSiteStudio,
369
- Q as configureStudio,
370
- st as defineStudio,
371
- P as studioConfig
371
+ ot as SiteStudio,
372
+ lt as apiUrl,
373
+ te as bounceToEnter,
374
+ Ze as configureSiteStudio,
375
+ ee as configureStudio,
376
+ dt as defineStudio,
377
+ U as studioConfig
372
378
  };