@backmatter/studio 0.0.20 → 0.0.21

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 (57) hide show
  1. package/dist/chunks/{UiKitApp-C269OA8v.js → UiKitApp-CMMcsaX4.js} +2 -2
  2. package/dist/chunks/{WorkspaceRoutes-B4B5jjje.js → WorkspaceRoutes-DW0sLdpJ.js} +27141 -26241
  3. package/dist/chunks/dashboard-By0P4Yny.js +1879 -0
  4. package/dist/chunks/{index-7-TtXaMq.js → index-DTPUqaHE.js} +1 -1
  5. package/dist/dashboard.js +2 -2
  6. package/dist/index.js +205 -194
  7. package/dist/site-widget.css +208 -0
  8. package/dist/site-widget.js +10495 -9947
  9. package/dist/studio.css +276 -32
  10. package/package.json +2 -2
  11. package/src/App.tsx +7 -1
  12. package/src/api.ts +106 -13
  13. package/src/chat/ChatFiles.tsx +261 -0
  14. package/src/chat/ChatMessage.tsx +5 -0
  15. package/src/chat/ChatPanel.tsx +218 -14
  16. package/src/chat/ChatProvider.tsx +72 -22
  17. package/src/chat/Composer.tsx +83 -6
  18. package/src/chat/PendingFileRow.tsx +188 -0
  19. package/src/chat/chat-context.ts +7 -1
  20. package/src/chat/chat-helpers.ts +49 -0
  21. package/src/chat/chat-state.ts +17 -6
  22. package/src/chat/icons.tsx +28 -0
  23. package/src/chat/model-copy.ts +41 -0
  24. package/src/chat/pending-files.ts +236 -0
  25. package/src/chat/side-width.ts +48 -0
  26. package/src/chrome/AppShell.tsx +9 -1
  27. package/src/chrome/CommandPalette.tsx +7 -0
  28. package/src/chrome/ContentExplorerSidebar.tsx +43 -74
  29. package/src/chrome/folder-create-context.ts +56 -11
  30. package/src/chrome/hotkeys.ts +8 -0
  31. package/src/fields/FieldControl.tsx +331 -115
  32. package/src/fields/LinkFieldInput.tsx +13 -6
  33. package/src/fields/array-item-title.ts +28 -0
  34. package/src/fields/field-label.ts +8 -0
  35. package/src/host-pointer.ts +2 -0
  36. package/src/install-preview-pointer.ts +1 -0
  37. package/src/pages/BlockPicker.tsx +362 -0
  38. package/src/pages/BlocksList.tsx +39 -67
  39. package/src/pages/CliAuthorizePage.tsx +138 -25
  40. package/src/pages/DocEditorPage.tsx +95 -18
  41. package/src/pages/EmbedPublishPage.tsx +40 -2
  42. package/src/pages/LoginPage.tsx +118 -31
  43. package/src/pages/SettingsSchemaPage.tsx +19 -3
  44. package/src/pages/WorkspaceLayout.tsx +16 -1
  45. package/src/pages/block-picker.ts +116 -0
  46. package/src/pages/editor-grab.ts +61 -13
  47. package/src/pages/preview-split.ts +24 -0
  48. package/src/pages/session-preview.ts +1 -0
  49. package/src/replica/types.ts +2 -0
  50. package/src/sign-in-link.ts +45 -0
  51. package/src/site-pointer.ts +14 -1
  52. package/src/site-widget.tsx +12 -1
  53. package/src/ui/Field.tsx +26 -0
  54. package/src/workspace/schema-source.tsx +126 -0
  55. package/dist/chunks/dashboard-DeNgythd.js +0 -1779
  56. package/src/site-devbar-overlay-inject.ts +0 -15
  57. package/src/site-publish-menu.tsx +0 -33
@@ -1,7 +1,7 @@
1
1
  var Rs = Object.defineProperty;
2
2
  var Es = (r, e, t) => e in r ? Rs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var M = (r, e, t) => Es(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { aN as Bt, aO as Bs, aP as a0, aQ as ct, aR as xt, aS as ea, aT as Gn, aU as Is, aV as Ls, aW as Ds, aX as La, aY as Ps, aZ as Os, a_ as Le, a$ as qs } from "./WorkspaceRoutes-B4B5jjje.js";
4
+ import { aP as Bt, aQ as Bs, aR as a0, aS as ct, aT as xt, aU as ea, aV as Gn, aW as Is, aX as Ls, aY as Ds, aZ as La, a_ as Ps, a$ as Os, b0 as Le, b1 as qs } from "./WorkspaceRoutes-DW0sLdpJ.js";
5
5
  function Fs() {
6
6
  return {
7
7
  enter: {
package/dist/dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as a, i as s } from "./chunks/dashboard-DeNgythd.js";
2
- import { G as t, H as f } from "./chunks/WorkspaceRoutes-B4B5jjje.js";
1
+ import { A as a, i as s } from "./chunks/dashboard-By0P4Yny.js";
2
+ import { G as t, H as f } from "./chunks/WorkspaceRoutes-DW0sLdpJ.js";
3
3
  export {
4
4
  a as DashboardApp,
5
5
  t as configureStudio,
package/dist/index.js CHANGED
@@ -1,40 +1,40 @@
1
- import { jsx as t, jsxs as u } from "react/jsx-runtime";
2
- import { useLayoutEffect as ue, useEffect as h, useRef as Y, useState as p, useMemo as de } from "react";
3
- import { i as Z, T as xe, E as me, C as he, a as fe, b as pe, u as ge, D as I, c as ee, d as K, e as be, f as te, g as V, h as we, p as ye, j as ve, k as z, l as E, m as ke, n as qe, o as S, s as ze, r as Ee, q as Ce, t as Ne, v as Se, w as Pe, x as Re, y as Le, z as Ue, B as je, A as Te, S as Me, F as $e, G as ne, H as U, I as Be, J as Fe, K as De, R as Oe, L as Ae, M as _e, N as Ge, O as P, P as H, Q as Ie, U as Ke, V as W, W as Ve } from "./chunks/WorkspaceRoutes-B4B5jjje.js";
4
- import { X as pt } from "./chunks/WorkspaceRoutes-B4B5jjje.js";
5
- import { u as He, S as We } from "./chunks/define-studio-DlYjgrwr.js";
6
- import { d as bt } from "./chunks/define-studio-DlYjgrwr.js";
1
+ import { jsx as t, jsxs as u, Fragment as he } from "react/jsx-runtime";
2
+ import { useLayoutEffect as pe, useEffect as p, useRef as ee, useState as m, useMemo as fe } from "react";
3
+ import { i as te, T as ge, E as be, C as ye, a as we, b as ve, u as ke, D as V, c as ne, d as H, e as qe, f as re, g as W, h as ze, p as Ee, j as Ce, k as w, l as v, m as Ne, n as Se, o as L, s as Le, r as Pe, q as Re, t as je, v as Ue, w as Te, x as Me, y as $e, z as Fe, B as Be, A as Oe, S as Ae, F as De, G as ie, H as U, I as Ge, J as _e, K as Ie, R as Ke, L as Ve, M as He, N as We, O as P, P as X, Q as Xe, U as Je, V as J, W as Qe } from "./chunks/WorkspaceRoutes-DW0sLdpJ.js";
4
+ import { X as kt } from "./chunks/WorkspaceRoutes-DW0sLdpJ.js";
5
+ import { u as Ye, S as Ze } from "./chunks/define-studio-DlYjgrwr.js";
6
+ import { d as zt } from "./chunks/define-studio-DlYjgrwr.js";
7
7
  const R = {
8
8
  accent: "var(--x11n7hvk)",
9
9
  accentHover: "var(--x1vnpaut)",
10
10
  focus: "var(--x1nzi8h4)"
11
11
  };
12
- function Xe(e) {
12
+ function et(e) {
13
13
  const n = /^var\((--[^,)]+)/.exec(e);
14
14
  return (n == null ? void 0 : n[1]) ?? null;
15
15
  }
16
- const Je = [R.accent, R.accentHover, R.focus];
17
- function Qe() {
18
- var n, s;
19
- const e = (s = (n = He().theme) == null ? void 0 : n.accent) == null ? void 0 : s.trim();
20
- return ue(() => {
16
+ const tt = [R.accent, R.accentHover, R.focus];
17
+ function nt() {
18
+ var n, o;
19
+ const e = (o = (n = Ye().theme) == null ? void 0 : n.accent) == null ? void 0 : o.trim();
20
+ return pe(() => {
21
21
  if (!e) return;
22
- const a = document.documentElement, i = Je.map(Xe).filter((o) => !!o);
23
- for (const o of i) a.style.setProperty(o, e);
22
+ const i = document.documentElement, a = tt.map(et).filter((s) => !!s);
23
+ for (const s of a) i.style.setProperty(s, e);
24
24
  return () => {
25
- for (const o of i) a.style.removeProperty(o);
25
+ for (const s of a) i.style.removeProperty(s);
26
26
  };
27
27
  }, [e]), null;
28
28
  }
29
- function Ye({ workspaceId: e }) {
30
- return h(() => Z(), []), /* @__PURE__ */ t(xe, { children: /* @__PURE__ */ t(me, { children: /* @__PURE__ */ t(he, { workspaceId: e, startOpen: !0, pointer: !0, children: /* @__PURE__ */ u(fe, { children: [
31
- /* @__PURE__ */ t(Ze, {}),
32
- /* @__PURE__ */ t(et, {}),
33
- /* @__PURE__ */ t(tt, {}),
34
- /* @__PURE__ */ t(pe, { fill: !0 })
29
+ function rt({ workspaceId: e }) {
30
+ return p(() => te(), []), /* @__PURE__ */ t(ge, { children: /* @__PURE__ */ t(be, { children: /* @__PURE__ */ t(ye, { workspaceId: e, startOpen: !0, pointer: !0, children: /* @__PURE__ */ u(we, { children: [
31
+ /* @__PURE__ */ t(it, {}),
32
+ /* @__PURE__ */ t(at, {}),
33
+ /* @__PURE__ */ t(ot, {}),
34
+ /* @__PURE__ */ t(ve, { fill: !0 })
35
35
  ] }) }) }) });
36
36
  }
37
- function v() {
37
+ function q() {
38
38
  if (!document.referrer) return "";
39
39
  try {
40
40
  return new URL(document.referrer).origin;
@@ -42,69 +42,69 @@ function v() {
42
42
  return "";
43
43
  }
44
44
  }
45
- function Ze() {
46
- const { setFocus: e } = ge();
47
- return h(() => {
48
- const n = v();
49
- function s(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 o = i.doc;
54
- !(o != null && o.type) || !o.slug || e({
55
- docRef: { type: o.type, slug: o.slug },
45
+ function it() {
46
+ const { setFocus: e } = ke();
47
+ return p(() => {
48
+ const n = q();
49
+ function o(i) {
50
+ if (!n || i.origin !== n) return;
51
+ const a = i.data;
52
+ if ((a == null ? void 0 : a.type) !== "backmatter:focus") return;
53
+ const s = a.doc;
54
+ !(s != null && s.type) || !s.slug || e({
55
+ docRef: { type: s.type, slug: s.slug },
56
56
  frontmatter: {},
57
57
  body: "",
58
58
  selection: null
59
59
  });
60
60
  }
61
- return window.addEventListener("message", s), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", s);
62
- }, [e]), h(() => {
63
- const n = v();
64
- function s(a) {
65
- const i = a.detail;
66
- !n || !(i != null && i.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: i.docRef }, n);
61
+ return window.addEventListener("message", o), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", o);
62
+ }, [e]), p(() => {
63
+ const n = q();
64
+ function o(i) {
65
+ const a = i.detail;
66
+ !n || !(a != null && a.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: a.docRef }, n);
67
67
  }
68
- return window.addEventListener(I, s), () => window.removeEventListener(I, s);
68
+ return window.addEventListener(V, o), () => window.removeEventListener(V, o);
69
69
  }, []), null;
70
70
  }
71
- function et() {
72
- const { addPointer: e } = ee();
73
- return h(() => {
74
- const n = v();
75
- function s(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 o = be(
80
- i.doc ?? {},
81
- i.grab
71
+ function at() {
72
+ const { addPointer: e } = ne();
73
+ return p(() => {
74
+ const n = q();
75
+ function o(i) {
76
+ if (!n || i.origin !== n || i.source !== window.parent) return;
77
+ const a = i.data;
78
+ if ((a == null ? void 0 : a.type) !== "backmatter:pointer-grab") return;
79
+ const s = qe(
80
+ a.doc ?? {},
81
+ a.grab
82
82
  );
83
- o && e(o);
83
+ s && e(s);
84
84
  }
85
- return window.addEventListener("message", s), () => window.removeEventListener("message", s);
85
+ return window.addEventListener("message", o), () => window.removeEventListener("message", o);
86
86
  }, [e]), null;
87
87
  }
88
- function tt() {
89
- const { panel: e, dispatch: n } = ee(), s = e.mode, a = Y(s);
90
- return h(() => {
91
- const i = v();
92
- if (!i || window.parent === window) return;
93
- const o = K(a.current);
94
- a.current = s, o && !K(s) && window.parent.postMessage({ type: "backmatter:chat-closed" }, i);
95
- }, [s]), h(() => {
96
- const i = v();
97
- function o(f) {
98
- var m;
99
- !i || f.origin !== i || ((m = f.data) == null ? void 0 : m.type) === "backmatter:chat-open" && (n({ type: "open" }), requestAnimationFrame(() => {
88
+ function ot() {
89
+ const { panel: e, dispatch: n } = ne(), o = e.mode, i = ee(o);
90
+ return p(() => {
91
+ const a = q();
92
+ if (!a || window.parent === window) return;
93
+ const s = H(i.current);
94
+ i.current = o, s && !H(o) && window.parent.postMessage({ type: "backmatter:chat-closed" }, a);
95
+ }, [o]), p(() => {
96
+ const a = q();
97
+ function s(f) {
98
+ var h;
99
+ !a || f.origin !== a || ((h = f.data) == null ? void 0 : h.type) === "backmatter:chat-open" && (n({ type: "open" }), requestAnimationFrame(() => {
100
100
  window.dispatchEvent(new Event("backmatter:chat-focus"));
101
101
  }));
102
102
  }
103
- return window.addEventListener("message", o), () => window.removeEventListener("message", o);
103
+ return window.addEventListener("message", s), () => window.removeEventListener("message", s);
104
104
  }, [n]), null;
105
105
  }
106
- const nt = 8e3;
107
- function X() {
106
+ const st = 8e3;
107
+ function Q() {
108
108
  if (!document.referrer) return "";
109
109
  try {
110
110
  return new URL(document.referrer).origin;
@@ -112,111 +112,111 @@ function X() {
112
112
  return "";
113
113
  }
114
114
  }
115
- function L(e) {
115
+ function j(e) {
116
116
  return `${e.type}/${e.slug}`;
117
117
  }
118
- const rt = {
118
+ const ct = {
119
119
  modified: "modified",
120
120
  added: "new",
121
121
  conflict: "conflict",
122
122
  deleted: "deleted"
123
123
  };
124
- function it({
124
+ function lt({
125
125
  workspaceId: e,
126
126
  onStatus: n,
127
- onPublished: s
127
+ onPublished: o
128
128
  }) {
129
- h(() => Z(), []);
130
- const [a, i] = p(null), [o, f] = p("viewer"), [m, b] = p(""), [c, g] = p(null), [ie, j] = p(null), [C, T] = p(!1), [k, M] = p(null);
131
- h(() => {
129
+ p(() => te(), []);
130
+ const [i, a] = m(null), [s, f] = m("viewer"), [h, g] = m(""), [c, b] = m(null), [oe, T] = m(null), [C, M] = m(!1), [z, $] = m(null), [F, N] = m(null), [se, ce] = m(0);
131
+ p(() => {
132
132
  let r = !1;
133
- return te(e).then((l) => {
133
+ return re(e).then((l) => {
134
134
  r || f(l.workspace.role);
135
135
  }).catch(() => {
136
- r || g("Could not load this workspace");
136
+ r || b("Could not load this workspace");
137
137
  }), () => {
138
138
  r = !0;
139
139
  };
140
140
  }, [e]);
141
- const q = Y(n);
142
- q.current = n, h(() => {
141
+ const E = ee(n);
142
+ E.current = n, p(() => {
143
143
  let r = !1;
144
144
  const l = () => {
145
- S(e).then((x) => {
146
- var G;
145
+ L(e).then((x) => {
146
+ var K;
147
147
  if (r) return;
148
- i(x);
149
- const O = x.changes.length, A = V(x);
150
- (G = q.current) == null || G.call(q, {
151
- changeCount: O,
152
- conflictCount: A
148
+ a(x), N(null);
149
+ const G = x.changes.length, _ = W(x);
150
+ (K = E.current) == null || K.call(E, {
151
+ changeCount: G,
152
+ conflictCount: _
153
153
  });
154
- const _ = X();
155
- !_ || window.parent === window || window.parent.postMessage({
154
+ const I = Q();
155
+ !I || window.parent === window || window.parent.postMessage({
156
156
  type: "backmatter:git",
157
- changeCount: O,
158
- conflictCount: A
159
- }, _);
157
+ changeCount: G,
158
+ conflictCount: _
159
+ }, I);
160
160
  }).catch((x) => {
161
- r || g(x instanceof Error ? x.message : "Git status failed");
161
+ r || N(x instanceof Error ? x.message : "Git status failed");
162
162
  });
163
163
  };
164
164
  l();
165
- const w = window.setInterval(l, nt);
165
+ const y = window.setInterval(l, st);
166
166
  return () => {
167
- r = !0, window.clearInterval(w);
167
+ r = !0, window.clearInterval(y);
168
168
  };
169
- }, [e]);
170
- const d = (a == null ? void 0 : a.changes) ?? [], ae = V(a), y = ze(ae, Le(o)), {
171
- failure: $,
172
- checking: se
173
- } = we(e, y === "commit", ye(d)), N = ie ?? $, B = Ne({
169
+ }, [e, se]);
170
+ const d = (i == null ? void 0 : i.changes) ?? [], le = W(i), k = Le(le, $e(s)), {
171
+ failure: B,
172
+ checking: ue
173
+ } = ze(e, k === "commit", Ee(d)), S = oe ?? B, O = je({
174
174
  committing: C,
175
- checking: se,
176
- failure: $
177
- }), F = de(() => d.filter((r) => r.status === "conflict"), [d]), oe = ve(d);
175
+ checking: ue,
176
+ failure: B
177
+ }), A = fe(() => d.filter((r) => r.status === "conflict"), [d]), de = Ce(d);
178
178
  async function D(r, l) {
179
- const w = `${L(r)}:${l}`;
180
- M(w), g(null);
179
+ const y = `${j(r)}:${l}`;
180
+ $(y), b(null);
181
181
  try {
182
- await Ee(e, r.type, r.slug, l), Ce({
182
+ await Pe(e, r.type, r.slug, l), Re({
183
183
  workspaceId: e,
184
184
  type: r.type,
185
185
  slug: r.slug,
186
186
  status: l === "theirs" ? "clean" : "modified"
187
187
  });
188
- const x = await S(e);
189
- i(x);
188
+ const x = await L(e);
189
+ a(x);
190
190
  } catch (x) {
191
- g(x instanceof Error ? x.message : "Resolve failed");
191
+ b(x instanceof Error ? x.message : "Resolve failed");
192
192
  } finally {
193
- M(null);
193
+ $(null);
194
194
  }
195
195
  }
196
- async function ce(r) {
197
- if (r.preventDefault(), !(C || y !== "commit" || d.length === 0)) {
198
- T(!0), g(null), j(null);
196
+ async function xe(r) {
197
+ if (r.preventDefault(), !(C || k !== "commit" || d.length === 0)) {
198
+ M(!0), b(null), T(null);
199
199
  try {
200
- const l = await Se(e, m);
201
- b(""), Pe(e, l.files), s == null || s();
202
- const w = X();
203
- w && window.parent !== window && window.parent.postMessage({
200
+ const l = await Ue(e, h);
201
+ g(""), Te(e, l.files), o == null || o();
202
+ const y = Q();
203
+ y && window.parent !== window && window.parent.postMessage({
204
204
  type: "backmatter:published"
205
- }, w), i(await S(e));
205
+ }, y), a(await L(e));
206
206
  } catch (l) {
207
- j(Re(l));
207
+ T(Me(l));
208
208
  } finally {
209
- T(!1);
209
+ M(!1);
210
210
  }
211
211
  }
212
212
  }
213
- const le = (a == null ? void 0 : a.currentBranch) ?? "main";
214
- return F.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
215
- /* @__PURE__ */ t("p", { ...z(E.groupLabel), children: "Resolve conflicts" }),
213
+ const me = (i == null ? void 0 : i.currentBranch) ?? "main";
214
+ return i ? A.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
215
+ /* @__PURE__ */ t("p", { ...w(v.groupLabel), children: "Resolve conflicts" }),
216
216
  /* @__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." }),
217
217
  c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null,
218
- /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: F.map((r) => {
219
- const l = L(r);
218
+ /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: A.map((r) => {
219
+ const l = j(r);
220
220
  return /* @__PURE__ */ u("li", { className: "x78zum5 xdt5ytf xpw8yq9 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay", children: [
221
221
  /* @__PURE__ */ u("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
222
222
  r.type,
@@ -224,16 +224,16 @@ function it({
224
224
  r.slug
225
225
  ] }),
226
226
  /* @__PURE__ */ u("div", { className: "x78zum5 xpw8yq9", children: [
227
- /* @__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" }),
228
- /* @__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" })
227
+ /* @__PURE__ */ t("button", { type: "button", disabled: z !== null, onClick: () => void D(r, "mine"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: z === `${l}:mine` ? "Keeping…" : "Keep mine" }),
228
+ /* @__PURE__ */ t("button", { type: "button", disabled: z !== null, onClick: () => void D(r, "theirs"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x13oidi x1hb2obb x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60 x1nf6o4h x1trrqm4", children: z === `${l}:theirs` ? "Taking…" : "Take theirs" })
229
229
  ] })
230
230
  ] }, l);
231
231
  }) })
232
- ] }) : /* @__PURE__ */ u("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (r) => void ce(r), children: [
233
- /* @__PURE__ */ t("p", { ...z(E.groupLabel), children: d.length === 0 ? "Nothing to publish" : `${d.length} ${d.length === 1 ? "file" : "files"} → ${le}` }),
234
- N ? /* @__PURE__ */ t(ke, { failure: N }) : null,
232
+ ] }) : /* @__PURE__ */ u("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (r) => void xe(r), children: [
233
+ /* @__PURE__ */ t("p", { ...w(v.groupLabel), children: d.length === 0 ? "Nothing to publish" : `${d.length} ${d.length === 1 ? "file" : "files"} → ${me}` }),
234
+ S ? /* @__PURE__ */ t(Ne, { failure: S }) : null,
235
235
  d.length > 0 ? /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: d.map((r) => {
236
- const l = qe(N, `${r.type}/${r.slug}`).length > 0;
236
+ const l = Se(S, `${r.type}/${r.slug}`).length > 0;
237
237
  return /* @__PURE__ */ t("li", { children: /* @__PURE__ */ u("div", { className: "x78zum5 x6s0dn4 x3smv4v x1rz828m x1ghz6dp x1obou79 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay x111yfic", children: [
238
238
  /* @__PURE__ */ u("span", { ...{
239
239
  0: {
@@ -247,34 +247,45 @@ function it({
247
247
  "/",
248
248
  r.slug
249
249
  ] }),
250
- /* @__PURE__ */ t("span", { ...z(E.itemMeta), children: rt[r.status] })
251
- ] }) }, L(r));
250
+ /* @__PURE__ */ t("span", { ...w(v.itemMeta), children: ct[r.status] })
251
+ ] }) }, j(r));
252
252
  }) }) : null,
253
- d.length > 0 ? /* @__PURE__ */ t("div", { ...z(E.separator) }) : null,
253
+ d.length > 0 ? /* @__PURE__ */ t("div", { ...w(v.separator) }) : null,
254
254
  d.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: [
255
- /* @__PURE__ */ t("input", { value: m, onChange: (r) => b(r.target.value), placeholder: oe, "aria-label": "Publish message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: C || y !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
255
+ /* @__PURE__ */ t("input", { value: h, onChange: (r) => g(r.target.value), placeholder: de, "aria-label": "Publish message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: C || k !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
256
256
  c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x10qp4ay x1trrqm4 xnjsko4 x18d9i69", children: c }) : null,
257
- y === "blocked" ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ t("button", { type: "submit", disabled: y !== "commit" || B.disabled, 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: B.label })
257
+ k === "blocked" ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ t("button", { type: "submit", disabled: k !== "commit" || O.disabled, 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: O.label })
258
258
  ] }) : c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null
259
- ] });
259
+ ] }) : /* @__PURE__ */ t("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: F ? /* @__PURE__ */ u(he, { children: [
260
+ /* @__PURE__ */ t("p", { ...w(v.groupLabel), children: "Could not load changes" }),
261
+ /* @__PURE__ */ t("p", { role: "alert", className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: F }),
262
+ /* @__PURE__ */ t("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: /* @__PURE__ */ t("button", { type: "button", onClick: () => {
263
+ N(null), ce((r) => r + 1);
264
+ }, className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: "Try again" }) })
265
+ ] }) : /* @__PURE__ */ t("p", { role: "status", ...w(v.groupLabel, ut.loading), children: "Loading changes…" }) });
260
266
  }
261
- const J = "backmatter:enter-at", at = 1e4;
262
- function re(e, n) {
267
+ const ut = {
268
+ loading: {
269
+ kGO01o: "x1y1hw3e",
270
+ $$css: !0
271
+ }
272
+ }, Y = "backmatter:enter-at", dt = 1e4;
273
+ function ae(e, n) {
263
274
  if (typeof window > "u") return !1;
264
- const s = !!(window.top && window.top !== window);
265
- if (Te(s) === "parent")
275
+ const o = !!(window.top && window.top !== window);
276
+ if (Oe(o) === "parent")
266
277
  return window.parent.postMessage({
267
- type: Me
278
+ type: Ae
268
279
  }, window.location.origin), !0;
269
- const a = Number(window.sessionStorage.getItem(J) ?? 0);
270
- return Date.now() - a < at ? !1 : (window.sessionStorage.setItem(J, String(Date.now())), window.location.assign($e(n, {
280
+ const i = Number(window.sessionStorage.getItem(Y) ?? 0);
281
+ return Date.now() - i < dt ? !1 : (window.sessionStorage.setItem(Y, String(Date.now())), window.location.assign(De(n, {
271
282
  workspaceId: e,
272
283
  returnUrl: window.location.href
273
284
  })), !0);
274
285
  }
275
- function st(e) {
286
+ function xt(e) {
276
287
  const n = e.dashboardUrl ?? "https://dash.backmatter.app";
277
- return ne({
288
+ return ie({
278
289
  baseUrl: e.proxyPath ?? "/api/backmatter/cms",
279
290
  publicApiUrl: e.apiUrl,
280
291
  credentials: "same-origin",
@@ -282,79 +293,79 @@ function st(e) {
282
293
  version: e.version,
283
294
  dashboardUrl: n,
284
295
  onUnauthorized: ({
285
- status: s
296
+ status: o
286
297
  }) => {
287
- s === 401 && re(e.workspaceId, n);
298
+ o === 401 && ae(e.workspaceId, n);
288
299
  }
289
300
  }), U();
290
301
  }
291
- function mt(e) {
292
- const n = e.basePath ?? "/backmatter", [s] = p(() => st(e));
293
- return /* @__PURE__ */ t(We, { definition: e.studio, children: /* @__PURE__ */ u(Ue, { children: [
294
- /* @__PURE__ */ t(Qe, {}),
295
- /* @__PURE__ */ t(je, { basename: n, children: /* @__PURE__ */ t(ot, { ...e }) })
302
+ function yt(e) {
303
+ const n = e.basePath ?? "/backmatter", [o] = m(() => xt(e));
304
+ return /* @__PURE__ */ t(Ze, { definition: e.studio, children: /* @__PURE__ */ u(Fe, { children: [
305
+ /* @__PURE__ */ t(nt, {}),
306
+ /* @__PURE__ */ t(Be, { basename: n, children: /* @__PURE__ */ t(mt, { ...e }) })
296
307
  ] }) });
297
308
  }
298
- function ot(e) {
299
- const n = Be(), s = e.dashboardUrl ?? "https://dash.backmatter.app", [a, i] = p("loading");
300
- if (h(() => {
301
- let m = !1;
302
- const b = U().onUnauthorized;
303
- return ne({
309
+ function mt(e) {
310
+ const n = Ge(), o = e.dashboardUrl ?? "https://dash.backmatter.app", [i, a] = m("loading");
311
+ if (p(() => {
312
+ let h = !1;
313
+ const g = U().onUnauthorized;
314
+ return ie({
304
315
  ...U(),
305
316
  onUnauthorized: (c) => {
306
- c.status === 426 ? i("outdated") : b == null || b(c);
317
+ c.status === 426 ? a("outdated") : g == null || g(c);
307
318
  }
308
- }), Fe().then(async (c) => {
309
- if (m) return;
319
+ }), _e().then(async (c) => {
320
+ if (h) return;
310
321
  if (!(c != null && c.user)) {
311
- re(e.workspaceId, s) || i("unauthorized");
322
+ ae(e.workspaceId, o) || a("unauthorized");
312
323
  return;
313
324
  }
314
325
  const {
315
- workspace: g
316
- } = await te(e.workspaceId);
317
- m || i({
326
+ workspace: b
327
+ } = await re(e.workspaceId);
328
+ h || a({
318
329
  user: {
319
330
  id: c.user.id,
320
331
  email: c.user.email
321
332
  },
322
- slug: g.slug
333
+ slug: b.slug
323
334
  });
324
335
  }).catch(() => {
325
- m || i((c) => c === "outdated" ? c : "unauthorized");
336
+ h || a((c) => c === "outdated" ? c : "unauthorized");
326
337
  }), () => {
327
- m = !0;
338
+ h = !0;
328
339
  };
329
- }, [e.workspaceId, s]), a === "loading") return /* @__PURE__ */ t(De, {});
330
- if (a === "outdated")
331
- return /* @__PURE__ */ u(Q, { title: "This site's editor is out of date", children: [
340
+ }, [e.workspaceId, o]), i === "loading") return /* @__PURE__ */ t(Ie, {});
341
+ if (i === "outdated")
342
+ return /* @__PURE__ */ u(Z, { title: "This site's editor is out of date", children: [
332
343
  "Update ",
333
344
  /* @__PURE__ */ t("code", { children: "@backmatter/studio" }),
334
345
  " and ",
335
346
  /* @__PURE__ */ t("code", { children: "@backmatter/next" }),
336
347
  " on the site, then reload."
337
348
  ] });
338
- if (a === "unauthorized")
339
- return /* @__PURE__ */ u(Q, { title: "Could not start editing", children: [
349
+ if (i === "unauthorized")
350
+ return /* @__PURE__ */ u(Z, { title: "Could not start editing", children: [
340
351
  "The site did not receive a session from the dashboard. Check that this site's origin is listed in the workspace settings and that ",
341
352
  /* @__PURE__ */ t("code", { children: "/api/backmatter" }),
342
353
  " routes are deployed."
343
354
  ] });
344
- const o = n.pathname.match(/^\/embed\/chat\/([^/]+)\/?$/);
345
- if (o != null && o[1])
346
- return /* @__PURE__ */ t(Ye, { workspaceId: decodeURIComponent(o[1]) });
355
+ const s = n.pathname.match(/^\/embed\/chat\/([^/]+)\/?$/);
356
+ if (s != null && s[1])
357
+ return /* @__PURE__ */ t(rt, { workspaceId: decodeURIComponent(s[1]) });
347
358
  const f = n.pathname.match(/^\/embed\/publish\/([^/]+)\/?$/);
348
- return f != null && f[1] ? /* @__PURE__ */ t(it, { workspaceId: decodeURIComponent(f[1]) }) : /* @__PURE__ */ t(Oe, { user: a.user, children: /* @__PURE__ */ t(Ae, { children: /* @__PURE__ */ t(_e, { userId: a.user.id, email: a.user.email, onLogout: () => {
349
- ct(e.previewEntryPath ?? "/api/backmatter/preview", s);
350
- }, children: /* @__PURE__ */ u(Ge, { children: [
351
- /* @__PURE__ */ t(P, { path: "/", element: /* @__PURE__ */ t(H, { to: `/${a.slug}`, replace: !0 }) }),
352
- /* @__PURE__ */ t(P, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(Ie, {}) }),
353
- Ke(),
354
- /* @__PURE__ */ t(P, { path: "*", element: /* @__PURE__ */ t(H, { to: "/", replace: !0 }) })
359
+ return f != null && f[1] ? /* @__PURE__ */ t(lt, { workspaceId: decodeURIComponent(f[1]) }) : /* @__PURE__ */ t(Ke, { user: i.user, children: /* @__PURE__ */ t(Ve, { children: /* @__PURE__ */ t(He, { userId: i.user.id, email: i.user.email, onLogout: () => {
360
+ ht(e.previewEntryPath ?? "/api/backmatter/preview", o);
361
+ }, children: /* @__PURE__ */ u(We, { children: [
362
+ /* @__PURE__ */ t(P, { path: "/", element: /* @__PURE__ */ t(X, { to: `/${i.slug}`, replace: !0 }) }),
363
+ /* @__PURE__ */ t(P, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(Xe, {}) }),
364
+ Je(),
365
+ /* @__PURE__ */ t(P, { path: "*", element: /* @__PURE__ */ t(X, { to: "/", replace: !0 }) })
355
366
  ] }) }) }) });
356
367
  }
357
- async function ct(e, n) {
368
+ async function ht(e, n) {
358
369
  try {
359
370
  await fetch(e, {
360
371
  method: "POST",
@@ -362,23 +373,23 @@ async function ct(e, n) {
362
373
  });
363
374
  } catch {
364
375
  }
365
- Ve.wipe(), window.location.assign(n);
376
+ Qe.wipe(), window.location.assign(n);
366
377
  }
367
- function Q({
378
+ function Z({
368
379
  title: e,
369
380
  children: n
370
381
  }) {
371
382
  return /* @__PURE__ */ t("div", { className: "x1ov3xa9 xrvj5dj x1ku5rj1 x1t7e3gq", children: /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf x1ndbd79 xq2pcee x1t7e3gq x4pepcl x1d0qn7y", children: [
372
- /* @__PURE__ */ t(W, { size: "lg", weight: "medium", children: e }),
373
- /* @__PURE__ */ t(W, { tone: "muted", children: n })
383
+ /* @__PURE__ */ t(J, { size: "lg", weight: "medium", children: e }),
384
+ /* @__PURE__ */ t(J, { tone: "muted", children: n })
374
385
  ] }) });
375
386
  }
376
387
  export {
377
- mt as SiteStudio,
378
- pt as apiUrl,
379
- re as bounceToEnter,
380
- st as configureSiteStudio,
381
- ne as configureStudio,
382
- bt as defineStudio,
388
+ yt as SiteStudio,
389
+ kt as apiUrl,
390
+ ae as bounceToEnter,
391
+ xt as configureSiteStudio,
392
+ ie as configureStudio,
393
+ zt as defineStudio,
383
394
  U as studioConfig
384
395
  };