@pretextbook/import 0.5.0 → 0.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.
package/dist/react.js CHANGED
@@ -1,49 +1,49 @@
1
- import me, { useRef as ce, useState as h, useMemo as re } from "react";
2
- import { H as ie, D as se, I as xe, B as pe, h as de, y as fe, u as he } from "./import-mode-Dc8qmZP6.js";
3
- var te = { exports: {} }, K = {};
4
- var ae;
5
- function be() {
6
- if (ae) return K;
7
- ae = 1;
8
- var o = /* @__PURE__ */ Symbol.for("react.transitional.element"), f = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function v(E, b, c) {
10
- var j = null;
11
- if (c !== void 0 && (j = "" + c), b.key !== void 0 && (j = "" + b.key), "key" in b) {
1
+ import ve, { useRef as he, useState as g, useMemo as re } from "react";
2
+ import { Z as be, a7 as Ne, O as ye, R as ue, h as Ee, _ as Te, N as we, j as ge, E as ke, A as Se } from "./import-mode-C0KIll3S.js";
3
+ var ie = { exports: {} }, te = {};
4
+ var me;
5
+ function Pe() {
6
+ if (me) return te;
7
+ me = 1;
8
+ var l = /* @__PURE__ */ Symbol.for("react.transitional.element"), m = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function f(j, h, c) {
10
+ var v = null;
11
+ if (c !== void 0 && (v = "" + c), h.key !== void 0 && (v = "" + h.key), "key" in h) {
12
12
  c = {};
13
- for (var g in b)
14
- g !== "key" && (c[g] = b[g]);
15
- } else c = b;
16
- return b = c.ref, {
17
- $$typeof: o,
18
- type: E,
19
- key: j,
20
- ref: b !== void 0 ? b : null,
13
+ for (var N in h)
14
+ N !== "key" && (c[N] = h[N]);
15
+ } else c = h;
16
+ return h = c.ref, {
17
+ $$typeof: l,
18
+ type: j,
19
+ key: v,
20
+ ref: h !== void 0 ? h : null,
21
21
  props: c
22
22
  };
23
23
  }
24
- return K.Fragment = f, K.jsx = v, K.jsxs = v, K;
24
+ return te.Fragment = m, te.jsx = f, te.jsxs = f, te;
25
25
  }
26
- var q = {};
27
- var ne;
28
- function je() {
29
- return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function o(t) {
26
+ var se = {};
27
+ var xe;
28
+ function _e() {
29
+ return xe || (xe = 1, process.env.NODE_ENV !== "production" && (function() {
30
+ function l(t) {
31
31
  if (t == null) return null;
32
32
  if (typeof t == "function")
33
- return t.$$typeof === H ? null : t.displayName || t.name || null;
33
+ return t.$$typeof === M ? null : t.displayName || t.name || null;
34
34
  if (typeof t == "string") return t;
35
35
  switch (t) {
36
- case O:
36
+ case D:
37
37
  return "Fragment";
38
- case L:
38
+ case K:
39
39
  return "Profiler";
40
- case N:
40
+ case P:
41
41
  return "StrictMode";
42
- case Y:
42
+ case ae:
43
43
  return "Suspense";
44
- case J:
44
+ case de:
45
45
  return "SuspenseList";
46
- case G:
46
+ case ne:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof t == "object")
@@ -52,96 +52,96 @@ function je() {
52
52
  ), t.$$typeof) {
53
53
  case R:
54
54
  return "Portal";
55
- case k:
55
+ case S:
56
56
  return t.displayName || "Context";
57
- case m:
57
+ case d:
58
58
  return (t._context.displayName || "Context") + ".Consumer";
59
- case $:
60
- var n = t.render;
61
- return t = t.displayName, t || (t = n.displayName || n.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
59
+ case A:
60
+ var r = t.render;
61
+ return t = t.displayName, t || (t = r.displayName || r.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
62
+ case J:
63
+ return r = t.displayName || null, r !== null ? r : l(t.type) || "Memo";
62
64
  case V:
63
- return n = t.displayName || null, n !== null ? n : o(t.type) || "Memo";
64
- case _:
65
- n = t._payload, t = t._init;
65
+ r = t._payload, t = t._init;
66
66
  try {
67
- return o(t(n));
67
+ return l(t(r));
68
68
  } catch {
69
69
  }
70
70
  }
71
71
  return null;
72
72
  }
73
- function f(t) {
73
+ function m(t) {
74
74
  return "" + t;
75
75
  }
76
- function v(t) {
76
+ function f(t) {
77
77
  try {
78
- f(t);
79
- var n = !1;
78
+ m(t);
79
+ var r = !1;
80
80
  } catch {
81
- n = !0;
81
+ r = !0;
82
82
  }
83
- if (n) {
84
- n = console;
85
- var d = n.error, p = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
86
- return d.call(
87
- n,
83
+ if (r) {
84
+ r = console;
85
+ var u = r.error, b = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
86
+ return u.call(
87
+ r,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- p
90
- ), f(t);
89
+ b
90
+ ), m(t);
91
91
  }
92
92
  }
93
- function E(t) {
94
- if (t === O) return "<>";
95
- if (typeof t == "object" && t !== null && t.$$typeof === _)
93
+ function j(t) {
94
+ if (t === D) return "<>";
95
+ if (typeof t == "object" && t !== null && t.$$typeof === V)
96
96
  return "<...>";
97
97
  try {
98
- var n = o(t);
99
- return n ? "<" + n + ">" : "<...>";
98
+ var r = l(t);
99
+ return r ? "<" + r + ">" : "<...>";
100
100
  } catch {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function b() {
105
- var t = D.A;
104
+ function h() {
105
+ var t = G.A;
106
106
  return t === null ? null : t.getOwner();
107
107
  }
108
108
  function c() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function j(t) {
112
- if (M.call(t, "key")) {
113
- var n = Object.getOwnPropertyDescriptor(t, "key").get;
114
- if (n && n.isReactWarning) return !1;
111
+ function v(t) {
112
+ if (H.call(t, "key")) {
113
+ var r = Object.getOwnPropertyDescriptor(t, "key").get;
114
+ if (r && r.isReactWarning) return !1;
115
115
  }
116
116
  return t.key !== void 0;
117
117
  }
118
- function g(t, n) {
119
- function d() {
120
- U || (U = !0, console.error(
118
+ function N(t, r) {
119
+ function u() {
120
+ I || (I = !0, console.error(
121
121
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
- n
122
+ r
123
123
  ));
124
124
  }
125
- d.isReactWarning = !0, Object.defineProperty(t, "key", {
126
- get: d,
125
+ u.isReactWarning = !0, Object.defineProperty(t, "key", {
126
+ get: u,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
130
  function x() {
131
- var t = o(this.type);
132
- return X[t] || (X[t] = !0, console.error(
131
+ var t = l(this.type);
132
+ return C[t] || (C[t] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), t = this.props.ref, t !== void 0 ? t : null;
135
135
  }
136
- function C(t, n, d, p, r, s) {
137
- var a = d.ref;
136
+ function O(t, r, u, b, Y, B) {
137
+ var p = u.ref;
138
138
  return t = {
139
- $$typeof: S,
139
+ $$typeof: k,
140
140
  type: t,
141
- key: n,
142
- props: d,
143
- _owner: p
144
- }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(t, "ref", {
141
+ key: r,
142
+ props: u,
143
+ _owner: b
144
+ }, (p !== void 0 ? p : null) !== null ? Object.defineProperty(t, "ref", {
145
145
  enumerable: !1,
146
146
  get: x
147
147
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
@@ -158,69 +158,69 @@ function je() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: r
161
+ value: Y
162
162
  }), Object.defineProperty(t, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: s
166
+ value: B
167
167
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
168
168
  }
169
- function y(t, n, d, p, r, s) {
170
- var a = n.children;
171
- if (a !== void 0)
172
- if (p)
173
- if (I(a)) {
174
- for (p = 0; p < a.length; p++)
175
- w(a[p]);
176
- Object.freeze && Object.freeze(a);
169
+ function E(t, r, u, b, Y, B) {
170
+ var p = r.children;
171
+ if (p !== void 0)
172
+ if (b)
173
+ if (Z(p)) {
174
+ for (b = 0; b < p.length; b++)
175
+ _(p[b]);
176
+ Object.freeze && Object.freeze(p);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else w(a);
182
- if (M.call(n, "key")) {
183
- a = o(t);
184
- var u = Object.keys(n).filter(function(F) {
185
- return F !== "key";
181
+ else _(p);
182
+ if (H.call(r, "key")) {
183
+ p = l(t);
184
+ var F = Object.keys(r).filter(function(s) {
185
+ return s !== "key";
186
186
  });
187
- p = 0 < u.length ? "{key: someKey, " + u.join(": ..., ") + ": ...}" : "{key: someKey}", W[a + p] || (u = 0 < u.length ? "{" + u.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ b = 0 < F.length ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}", U[p + b] || (F = 0 < F.length ? "{" + F.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
+ b,
194
195
  p,
195
- a,
196
- u,
197
- a
198
- ), W[a + p] = !0);
196
+ F,
197
+ p
198
+ ), U[p + b] = !0);
199
199
  }
200
- if (a = null, d !== void 0 && (v(d), a = "" + d), j(n) && (v(n.key), a = "" + n.key), "key" in n) {
201
- d = {};
202
- for (var l in n)
203
- l !== "key" && (d[l] = n[l]);
204
- } else d = n;
205
- return a && g(
206
- d,
200
+ if (p = null, u !== void 0 && (f(u), p = "" + u), v(r) && (f(r.key), p = "" + r.key), "key" in r) {
201
+ u = {};
202
+ for (var ee in r)
203
+ ee !== "key" && (u[ee] = r[ee]);
204
+ } else u = r;
205
+ return p && N(
206
+ u,
207
207
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
208
- ), C(
208
+ ), O(
209
209
  t,
210
- a,
211
- d,
212
- b(),
213
- r,
214
- s
210
+ p,
211
+ u,
212
+ h(),
213
+ Y,
214
+ B
215
215
  );
216
216
  }
217
- function w(t) {
218
- A(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === _ && (t._payload.status === "fulfilled" ? A(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
217
+ function _(t) {
218
+ L(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === V && (t._payload.status === "fulfilled" ? L(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
219
219
  }
220
- function A(t) {
221
- return typeof t == "object" && t !== null && t.$$typeof === S;
220
+ function L(t) {
221
+ return typeof t == "object" && t !== null && t.$$typeof === k;
222
222
  }
223
- var T = me, S = /* @__PURE__ */ Symbol.for("react.transitional.element"), R = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), N = /* @__PURE__ */ Symbol.for("react.strict_mode"), L = /* @__PURE__ */ Symbol.for("react.profiler"), m = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), $ = /* @__PURE__ */ Symbol.for("react.forward_ref"), Y = /* @__PURE__ */ Symbol.for("react.suspense"), J = /* @__PURE__ */ Symbol.for("react.suspense_list"), V = /* @__PURE__ */ Symbol.for("react.memo"), _ = /* @__PURE__ */ Symbol.for("react.lazy"), G = /* @__PURE__ */ Symbol.for("react.activity"), H = /* @__PURE__ */ Symbol.for("react.client.reference"), D = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, I = Array.isArray, P = console.createTask ? console.createTask : function() {
223
+ var T = ve, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), R = /* @__PURE__ */ Symbol.for("react.portal"), D = /* @__PURE__ */ Symbol.for("react.fragment"), P = /* @__PURE__ */ Symbol.for("react.strict_mode"), K = /* @__PURE__ */ Symbol.for("react.profiler"), d = /* @__PURE__ */ Symbol.for("react.consumer"), S = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), ae = /* @__PURE__ */ Symbol.for("react.suspense"), de = /* @__PURE__ */ Symbol.for("react.suspense_list"), J = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), ne = /* @__PURE__ */ Symbol.for("react.activity"), M = /* @__PURE__ */ Symbol.for("react.client.reference"), G = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = Object.prototype.hasOwnProperty, Z = Array.isArray, X = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
226
  T = {
@@ -228,39 +228,39 @@ React keys must be passed directly to JSX without using spread:
228
228
  return t();
229
229
  }
230
230
  };
231
- var U, X = {}, B = T.react_stack_bottom_frame.bind(
231
+ var I, C = {}, Q = T.react_stack_bottom_frame.bind(
232
232
  T,
233
233
  c
234
- )(), Z = P(E(c)), W = {};
235
- q.Fragment = O, q.jsx = function(t, n, d) {
236
- var p = 1e4 > D.recentlyCreatedOwnerStacks++;
237
- return y(
234
+ )(), z = X(j(c)), U = {};
235
+ se.Fragment = D, se.jsx = function(t, r, u) {
236
+ var b = 1e4 > G.recentlyCreatedOwnerStacks++;
237
+ return E(
238
238
  t,
239
- n,
240
- d,
239
+ r,
240
+ u,
241
241
  !1,
242
- p ? Error("react-stack-top-frame") : B,
243
- p ? P(E(t)) : Z
242
+ b ? Error("react-stack-top-frame") : Q,
243
+ b ? X(j(t)) : z
244
244
  );
245
- }, q.jsxs = function(t, n, d) {
246
- var p = 1e4 > D.recentlyCreatedOwnerStacks++;
247
- return y(
245
+ }, se.jsxs = function(t, r, u) {
246
+ var b = 1e4 > G.recentlyCreatedOwnerStacks++;
247
+ return E(
248
248
  t,
249
- n,
250
- d,
249
+ r,
250
+ u,
251
251
  !0,
252
- p ? Error("react-stack-top-frame") : B,
253
- p ? P(E(t)) : Z
252
+ b ? Error("react-stack-top-frame") : Q,
253
+ b ? X(j(t)) : z
254
254
  );
255
255
  };
256
- })()), q;
256
+ })()), se;
257
257
  }
258
- var le;
259
- function ve() {
260
- return le || (le = 1, process.env.NODE_ENV === "production" ? te.exports = be() : te.exports = je()), te.exports;
258
+ var pe;
259
+ function Re() {
260
+ return pe || (pe = 1, process.env.NODE_ENV === "production" ? ie.exports = Pe() : ie.exports = _e()), ie.exports;
261
261
  }
262
- var e = ve();
263
- const ue = [
262
+ var e = Re();
263
+ const je = [
264
264
  ".tex",
265
265
  ".md",
266
266
  ".markdown",
@@ -270,154 +270,161 @@ const ue = [
270
270
  ".gz",
271
271
  ".tar.gz",
272
272
  ".tgz"
273
- ], ge = {
273
+ ], Ce = {
274
274
  id: "builtin",
275
275
  label: "Built-in converter",
276
276
  description: "Create a new project starting with LaTeX, Markdown, or PreTeXt files.",
277
- acceptExtensions: ue,
278
- convertFile: ie,
279
- prepare: async (o) => {
280
- const { files: f, assets: v } = await pe(o);
277
+ acceptExtensions: je,
278
+ convertFile: be,
279
+ prepare: async (l) => {
280
+ const { files: m, assets: f } = await we(l);
281
281
  return {
282
- fileName: o.name,
283
- files: f,
284
- assets: v,
285
- analysis: de(f)
282
+ fileName: l.name,
283
+ files: m,
284
+ assets: f,
285
+ analysis: ge(m)
286
286
  };
287
287
  },
288
- convertPrepared: (o, f) => xe(o.files, {
289
- ...f,
290
- assets: o.assets
288
+ convertPrepared: (l, m) => Te(l.files, {
289
+ ...m,
290
+ assets: l.assets
291
291
  })
292
- }, oe = {
292
+ }, fe = {
293
293
  pretext: "PreTeXt",
294
294
  latex: "LaTeX",
295
295
  markdown: "Markdown"
296
296
  };
297
- function Ne(o) {
298
- const f = o.reason === "manifest-target" ? `project.ptx target “${o.targetName}”` : o.reason === "latex-root" ? "LaTeX document" : o.reason === "pretext-root" ? "PreTeXt document" : o.reason === "markdown-root" ? "Markdown document" : "possible document";
299
- return o.title ? `${o.title} — ${f}` : f;
297
+ function Ae(l) {
298
+ const m = l.reason === "manifest-target" ? `project.ptx target “${l.targetName}”` : l.reason === "latex-root" ? "LaTeX document" : l.reason === "pretext-root" ? "PreTeXt document" : l.reason === "markdown-root" ? "Markdown document" : "possible document";
299
+ return l.title ? `${l.title} — ${m}` : m;
300
300
  }
301
- function ye(o) {
302
- return o.candidates.filter(
303
- (v) => v.reason === "manifest-target"
304
- ).length > 1 ? !0 : o.manifest && o.primary?.reason === "manifest-target" ? !1 : o.formats.length > 1 || o.candidates.length > 1 || o.extraRoots.length > 0;
301
+ function Fe(l) {
302
+ return l.candidates.filter(
303
+ (f) => f.reason === "manifest-target"
304
+ ).length > 1 ? !0 : l.manifest && l.primary?.reason === "manifest-target" ? !1 : l.formats.length > 1 || l.candidates.length > 1 || l.extraRoots.length > 0;
305
305
  }
306
- function we({
307
- onConfirm: o,
308
- onCancel: f,
309
- importOptions: v,
310
- defaultDocumentKind: E = "auto",
311
- engines: b
306
+ function Me({
307
+ onConfirm: l,
308
+ onCancel: m,
309
+ importOptions: f,
310
+ defaultDocumentKind: j = "auto",
311
+ engines: h
312
312
  }) {
313
- const c = b && b.length > 0 ? b : [ge], j = ce(null), [g, x] = h({ name: "upload" }), [C, y] = h(!1), [w, A] = h(E), [T, S] = h(!1), [R, O] = h(c[0].id), [N, L] = h("converted"), [m, k] = h(!1), [$, Y] = h(/* @__PURE__ */ new Set()), [J, V] = h(null), [_, G] = h(
313
+ const c = h && h.length > 0 ? h : [Ce], v = he(null), [N, x] = g({ name: "upload" }), [O, E] = g(!1), [_, L] = g(j), [T, k] = g(null), [R, D] = g(/* @__PURE__ */ new Set()), [P, K] = g(c[0].id), [d, S] = g("converted"), [A, ae] = g(!1), [de, J] = g(/* @__PURE__ */ new Set()), [V, ne] = g(null), [M, G] = g(
314
314
  "auto"
315
- ), [H, D] = h(null), [M, I] = h({}), P = c.find((r) => r.id === R) ?? c[0], U = P.acceptExtensions ?? ue, X = () => v ?? {
316
- documentKind: w === "auto" ? void 0 : w,
317
- splitSections: T
318
- }, B = (r) => de(r.files, {
319
- sourceFormat: _ === "auto" ? void 0 : _,
315
+ ), [H, Z] = g(null), [X, I] = g({}), C = c.find((s) => s.id === P) ?? c[0], Q = C.acceptExtensions ?? je, z = N.name === "review" ? N.result : null, U = re(
316
+ () => z && T !== null ? Ne(z, T) : z,
317
+ [z, T]
318
+ ), t = re(
319
+ () => new Map(
320
+ U ? ye(U).map((s) => [s.path, s]) : []
321
+ ),
322
+ [U]
323
+ ), r = () => f ?? {
324
+ documentKind: _ === "auto" ? void 0 : _
325
+ }, u = (s) => ge(s.files, {
326
+ sourceFormat: M === "auto" ? void 0 : M,
320
327
  mainFile: H ?? void 0
321
- }), Z = (r) => {
328
+ }), b = (s) => {
322
329
  x({ name: "processing" });
323
330
  try {
324
- const a = B(r).extraRoots.map((l) => ({
325
- path: l.path,
326
- include: M[l.path]?.include ?? !0,
327
- level: M[l.path]?.level
328
- })), u = P.convertPrepared(r, {
329
- ...X(),
330
- sourceFormat: _ === "auto" ? void 0 : _,
331
+ const n = u(s).extraRoots.map((i) => ({
332
+ path: i.path,
333
+ include: X[i.path]?.include ?? !0,
334
+ level: X[i.path]?.level
335
+ })), y = C.convertPrepared(s, {
336
+ ...r(),
337
+ sourceFormat: M === "auto" ? void 0 : M,
331
338
  mainFile: H ?? void 0,
332
- attachRoots: a
339
+ attachRoots: n
333
340
  });
334
- "pretextError" in u ? x({ name: "error", message: u.pretextError }) : x({ name: "review", result: u });
335
- } catch (s) {
341
+ "pretextError" in y ? x({ name: "error", message: y.pretextError }) : x({ name: "review", result: y });
342
+ } catch (o) {
336
343
  x({
337
344
  name: "error",
338
- message: s instanceof Error ? s.message : "An unexpected error occurred."
345
+ message: o instanceof Error ? o.message : "An unexpected error occurred."
339
346
  });
340
347
  }
341
- }, W = async (r) => {
348
+ }, Y = async (s) => {
342
349
  x({ name: "processing" });
343
350
  try {
344
- if (P.prepare && P.convertPrepared) {
345
- const a = await P.prepare(r);
346
- if (V(a), G("auto"), D(null), I({}), ye(a.analysis)) {
347
- x({ name: "sources", prepared: a });
351
+ if (C.prepare && C.convertPrepared) {
352
+ const n = await C.prepare(s);
353
+ if (ne(n), G("auto"), Z(null), I({}), Fe(n.analysis)) {
354
+ x({ name: "sources", prepared: n });
348
355
  return;
349
356
  }
350
- const u = P.convertPrepared(a, X());
357
+ const y = C.convertPrepared(n, r());
351
358
  x(
352
- "pretextError" in u ? { name: "error", message: u.pretextError } : { name: "review", result: u }
359
+ "pretextError" in y ? { name: "error", message: y.pretextError } : { name: "review", result: y }
353
360
  );
354
361
  return;
355
362
  }
356
- const s = await P.convertFile(r, X());
357
- "pretextError" in s ? x({ name: "error", message: s.pretextError }) : x({ name: "review", result: s });
358
- } catch (s) {
363
+ const o = await C.convertFile(s, r());
364
+ "pretextError" in o ? x({ name: "error", message: o.pretextError }) : x({ name: "review", result: o });
365
+ } catch (o) {
359
366
  x({
360
367
  name: "error",
361
- message: s instanceof Error ? s.message : "An unexpected error occurred."
368
+ message: o instanceof Error ? o.message : "An unexpected error occurred."
362
369
  });
363
370
  }
364
- }, t = () => {
365
- x({ name: "upload" }), L("converted"), k(!1), Y(/* @__PURE__ */ new Set()), V(null);
371
+ }, B = () => {
372
+ x({ name: "upload" }), S("converted"), ae(!1), J(/* @__PURE__ */ new Set()), D(/* @__PURE__ */ new Set()), k(null), ne(null);
366
373
  };
367
- function n(r, s) {
368
- return [...r].sort((a, u) => a === s ? -1 : u === s ? 1 : a.localeCompare(u));
374
+ function p(s, o) {
375
+ return [...s].sort((n, y) => n === o ? -1 : y === o ? 1 : n.localeCompare(y));
369
376
  }
370
- function d(r, s) {
371
- const a = se(r, s), u = s === "converted" ? r.projectLayout.mainSourcePath : r.sourcePath, l = n(Object.keys(a), u)[0];
372
- Y(l ? /* @__PURE__ */ new Set([l]) : /* @__PURE__ */ new Set());
377
+ function F(s, o) {
378
+ const n = ue(s, o), y = o === "converted" ? s.projectLayout.mainSourcePath : s.sourcePath, i = p(Object.keys(n), y)[0];
379
+ J(i ? /* @__PURE__ */ new Set([i]) : /* @__PURE__ */ new Set());
373
380
  }
374
- function p(r) {
375
- Y((s) => {
376
- const a = new Set(s);
377
- return a.has(r) ? a.delete(r) : a.add(r), a;
381
+ function ee(s) {
382
+ J((o) => {
383
+ const n = new Set(o);
384
+ return n.has(s) ? n.delete(s) : n.add(s), n;
378
385
  });
379
386
  }
380
- if (g.name === "processing")
387
+ if (N.name === "processing")
381
388
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-slate-600", children: [
382
389
  /* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-2 border-blue-700 border-t-transparent" }),
383
390
  /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: "Processing your file…" })
384
391
  ] });
385
- if (g.name === "error")
392
+ if (N.name === "error")
386
393
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
387
394
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800", children: [
388
395
  /* @__PURE__ */ e.jsx("p", { className: "font-semibold", children: "Import failed" }),
389
- /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: g.message })
396
+ /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: N.message })
390
397
  ] }),
391
398
  /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ e.jsx(
392
399
  "button",
393
400
  {
394
401
  type: "button",
395
- onClick: t,
402
+ onClick: B,
396
403
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
397
404
  children: "Try Another File"
398
405
  }
399
406
  ) })
400
407
  ] });
401
- if (g.name === "sources") {
402
- const r = g.prepared, s = B(r), a = s.manifest, u = s.primary?.path ?? "";
408
+ if (N.name === "sources") {
409
+ const s = N.prepared, o = u(s), n = o.manifest, y = o.primary?.path ?? "";
403
410
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
404
411
  /* @__PURE__ */ e.jsxs("div", { children: [
405
412
  /* @__PURE__ */ e.jsx("h3", { className: "text-sm font-semibold text-slate-700", children: "Choose what to import" }),
406
413
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-sm text-slate-500", children: [
407
- r.fileName,
414
+ s.fileName,
408
415
  " contains more than one possible starting point."
409
416
  ] })
410
417
  ] }),
411
- a ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
418
+ n ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
412
419
  /* @__PURE__ */ e.jsxs("p", { className: "font-medium", children: [
413
420
  "Found ",
414
- a.manifestPath,
421
+ n.manifestPath,
415
422
  " — an existing PreTeXt project."
416
423
  ] }),
417
424
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-blue-800", children: [
418
425
  "Its publication file, assets, and directory layout will be kept as they are. Targets:",
419
426
  " ",
420
- a.targets.map((l) => l.name).join(", "),
427
+ n.targets.map((i) => i.name).join(", "),
421
428
  "."
422
429
  ] })
423
430
  ] }) : null,
@@ -426,24 +433,24 @@ function we({
426
433
  /* @__PURE__ */ e.jsxs(
427
434
  "select",
428
435
  {
429
- value: _,
430
- onChange: (l) => {
431
- G(l.currentTarget.value), D(null), I({});
436
+ value: M,
437
+ onChange: (i) => {
438
+ G(i.currentTarget.value), Z(null), I({});
432
439
  },
433
440
  className: "rounded border border-slate-300 px-2 py-1 text-sm",
434
441
  children: [
435
442
  /* @__PURE__ */ e.jsxs("option", { value: "auto", children: [
436
443
  "Auto detect",
437
- s.primary ? ` (${oe[s.primary.format]})` : ""
444
+ o.primary ? ` (${fe[o.primary.format]})` : ""
438
445
  ] }),
439
- s.formats.map((l) => /* @__PURE__ */ e.jsx("option", { value: l, children: oe[l] }, l))
446
+ o.formats.map((i) => /* @__PURE__ */ e.jsx("option", { value: i, children: fe[i] }, i))
440
447
  ]
441
448
  }
442
449
  )
443
450
  ] }) }),
444
- s.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
451
+ o.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
445
452
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Main document" }),
446
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: s.candidates.map((l) => /* @__PURE__ */ e.jsxs(
453
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: o.candidates.map((i) => /* @__PURE__ */ e.jsxs(
447
454
  "label",
448
455
  {
449
456
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -453,28 +460,28 @@ function we({
453
460
  {
454
461
  type: "radio",
455
462
  name: "main-file",
456
- value: l.path,
457
- checked: u === l.path,
463
+ value: i.path,
464
+ checked: y === i.path,
458
465
  onChange: () => {
459
- D(l.path), I({});
466
+ Z(i.path), I({});
460
467
  },
461
468
  className: "mt-0.5"
462
469
  }
463
470
  ),
464
471
  /* @__PURE__ */ e.jsxs("span", { children: [
465
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: l.path }),
466
- /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: Ne(l) })
472
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: i.path }),
473
+ /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: Ae(i) })
467
474
  ] })
468
475
  ]
469
476
  },
470
- l.path
477
+ i.path
471
478
  )) })
472
479
  ] }) : null,
473
- s.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
480
+ o.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
474
481
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Other documents" }),
475
482
  /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-sm text-slate-500", children: "These files also stand on their own. Attach them to the main document, or leave them out." }),
476
- /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: s.extraRoots.map((l) => {
477
- const F = M[l.path], Q = F?.include ?? !0;
483
+ /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: o.extraRoots.map((i) => {
484
+ const q = X[i.path], le = q?.include ?? !0;
478
485
  return /* @__PURE__ */ e.jsxs(
479
486
  "div",
480
487
  {
@@ -485,20 +492,20 @@ function we({
485
492
  "input",
486
493
  {
487
494
  type: "checkbox",
488
- checked: Q,
489
- onChange: (z) => I((i) => ({
490
- ...i,
491
- [l.path]: {
492
- ...i[l.path],
493
- include: z.currentTarget.checked
495
+ checked: le,
496
+ onChange: ($) => I((W) => ({
497
+ ...W,
498
+ [i.path]: {
499
+ ...W[i.path],
500
+ include: $.currentTarget.checked
494
501
  }
495
502
  }))
496
503
  }
497
504
  ),
498
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: l.path }),
499
- l.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
505
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: i.path }),
506
+ i.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
500
507
  "— ",
501
- l.title
508
+ i.title
502
509
  ] }) : null
503
510
  ] }),
504
511
  /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
@@ -506,13 +513,13 @@ function we({
506
513
  /* @__PURE__ */ e.jsxs(
507
514
  "select",
508
515
  {
509
- value: F?.level ?? "auto",
510
- disabled: !Q,
511
- onChange: (z) => I((i) => ({
512
- ...i,
513
- [l.path]: {
514
- include: i[l.path]?.include ?? !0,
515
- level: z.currentTarget.value === "auto" ? void 0 : z.currentTarget.value
516
+ value: q?.level ?? "auto",
517
+ disabled: !le,
518
+ onChange: ($) => I((W) => ({
519
+ ...W,
520
+ [i.path]: {
521
+ include: W[i.path]?.include ?? !0,
522
+ level: $.currentTarget.value === "auto" ? void 0 : $.currentTarget.value
516
523
  }
517
524
  })),
518
525
  className: "rounded border border-slate-300 px-2 py-1 text-sm disabled:opacity-50",
@@ -526,7 +533,7 @@ function we({
526
533
  ] })
527
534
  ]
528
535
  },
529
- l.path
536
+ i.path
530
537
  );
531
538
  }) })
532
539
  ] }) : null,
@@ -535,7 +542,7 @@ function we({
535
542
  "button",
536
543
  {
537
544
  type: "button",
538
- onClick: t,
545
+ onClick: B,
539
546
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
540
547
  children: "Start Over"
541
548
  }
@@ -544,7 +551,7 @@ function we({
544
551
  "button",
545
552
  {
546
553
  type: "button",
547
- onClick: () => Z(r),
554
+ onClick: () => b(s),
548
555
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
549
556
  children: "Continue"
550
557
  }
@@ -552,51 +559,56 @@ function we({
552
559
  ] })
553
560
  ] });
554
561
  }
555
- if (g.name === "review") {
556
- let r = function(i) {
557
- L(i), m && d(s, i);
562
+ if (N.name === "review") {
563
+ let s = function(a) {
564
+ S(a), A && F(n, a);
565
+ }, o = function(a) {
566
+ D((w) => {
567
+ const ce = new Set(w);
568
+ return ce.has(a) ? ce.delete(a) : ce.add(a), ce;
569
+ });
558
570
  };
559
- const { result: s } = g, a = s.detectedSourceFormat === "latex", u = s.warnings.length, l = Object.keys(s.outputFiles).length, F = se(s, N), Q = N === "converted" ? s.projectLayout.mainSourcePath : s.sourcePath, z = n(
560
- Object.keys(F),
561
- Q
571
+ const n = U ?? N.result, y = n.splitLevel, i = n.detectedSourceFormat === "latex", q = n.warnings.length, le = Object.keys(n.outputFiles).length, $ = ue(n, d), W = d === "converted" ? n.projectLayout.mainSourcePath : n.sourcePath, oe = p(
572
+ Object.keys($),
573
+ W
562
574
  );
563
575
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
564
576
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-slate-200 bg-slate-50 p-4", children: [
565
577
  /* @__PURE__ */ e.jsx("h3", { className: "mb-3 text-sm font-semibold text-slate-700", children: "Import Summary" }),
566
578
  /* @__PURE__ */ e.jsxs("dl", { className: "grid grid-cols-2 gap-x-6 gap-y-2 text-sm", children: [
567
579
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Source" }),
568
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: s.sourceName }),
580
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: n.sourceName }),
569
581
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Detected format" }),
570
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: s.detectedSourceFormat }),
582
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: n.detectedSourceFormat }),
571
583
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Document kind" }),
572
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: s.documentKind }),
584
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: n.documentKind }),
573
585
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Output files" }),
574
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: l }),
575
- s.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
586
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: le }),
587
+ n.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
576
588
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Existing project" }),
577
589
  /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: "Kept publication file, assets, and layout" })
578
590
  ] }) : null,
579
- s.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
591
+ n.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
580
592
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Attached" }),
581
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: s.attachedRoots.map((i) => `${i.title} (${i.level})`).join(", ") })
593
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: n.attachedRoots.map((a) => `${a.title} (${a.level})`).join(", ") })
582
594
  ] }) : null
583
595
  ] })
584
596
  ] }),
585
- u > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
597
+ q > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
586
598
  /* @__PURE__ */ e.jsxs("summary", { className: "cursor-pointer font-semibold text-amber-800", children: [
587
- u,
599
+ q,
588
600
  " conversion",
589
601
  " ",
590
- u === 1 ? "warning" : "warnings"
602
+ q === 1 ? "warning" : "warnings"
591
603
  ] }),
592
- /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: s.warnings.map((i, ee) => /* @__PURE__ */ e.jsxs("li", { children: [
593
- /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: i.macro }),
604
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: n.warnings.map((a, w) => /* @__PURE__ */ e.jsxs("li", { children: [
605
+ /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: a.macro }),
594
606
  " — ",
595
- i.action === "replace" || i.action === "rewrite" ? `replaced with \`${i.replacement}\`` : i.message ?? i.action,
596
- i.occurrences > 1 ? ` (×${i.occurrences})` : null
597
- ] }, ee)) })
607
+ a.action === "replace" || a.action === "rewrite" ? `replaced with \`${a.replacement}\`` : a.message ?? a.action,
608
+ a.occurrences > 1 ? ` (×${a.occurrences})` : null
609
+ ] }, w)) })
598
610
  ] }) : /* @__PURE__ */ e.jsx("p", { className: "text-sm text-green-700", children: "No conversion warnings." }),
599
- a ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
611
+ i ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
600
612
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Import mode" }),
601
613
  /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-col gap-3", children: [
602
614
  /* @__PURE__ */ e.jsxs("label", { className: "flex cursor-pointer items-start gap-3 text-sm", children: [
@@ -606,8 +618,8 @@ function we({
606
618
  type: "radio",
607
619
  name: "import-mode",
608
620
  value: "converted",
609
- checked: N === "converted",
610
- onChange: () => r("converted"),
621
+ checked: d === "converted",
622
+ onChange: () => s("converted"),
611
623
  className: "mt-0.5"
612
624
  }
613
625
  ),
@@ -623,8 +635,8 @@ function we({
623
635
  type: "radio",
624
636
  name: "import-mode",
625
637
  value: "native",
626
- checked: N === "native",
627
- onChange: () => r("native"),
638
+ checked: d === "native",
639
+ onChange: () => s("native"),
628
640
  className: "mt-0.5"
629
641
  }
630
642
  ),
@@ -635,8 +647,40 @@ function we({
635
647
  ] })
636
648
  ] })
637
649
  ] }) : null,
638
- m ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: z.map((i) => {
639
- const ee = $.has(i);
650
+ !f && n.cleanChunks.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
651
+ /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Split into files" }),
652
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
653
+ Array.from(
654
+ { length: Ee + 1 },
655
+ (a, w) => /* @__PURE__ */ e.jsx(
656
+ "button",
657
+ {
658
+ type: "button",
659
+ onClick: () => k(w),
660
+ "aria-pressed": y === w,
661
+ className: y === w ? "rounded bg-blue-700 px-3 py-1 text-sm font-medium text-white" : "rounded border border-slate-300 px-3 py-1 text-sm text-slate-700 hover:bg-slate-50",
662
+ children: w === 0 ? "One file" : `${w} level${w === 1 ? "" : "s"}`
663
+ },
664
+ w
665
+ )
666
+ ),
667
+ /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-sm text-slate-500", children: [
668
+ oe.length,
669
+ " file",
670
+ oe.length === 1 ? "" : "s"
671
+ ] })
672
+ ] }),
673
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 max-h-48 overflow-auto font-mono text-xs text-slate-600", children: oe.map((a) => /* @__PURE__ */ e.jsxs("li", { className: "truncate py-0.5", children: [
674
+ a,
675
+ t.get(a)?.fixCount ? /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-amber-700", children: [
676
+ t.get(a).fixCount,
677
+ " change",
678
+ t.get(a).fixCount === 1 ? "" : "s"
679
+ ] }) : null
680
+ ] }, a)) })
681
+ ] }) : null,
682
+ A ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: oe.map((a) => {
683
+ const w = de.has(a);
640
684
  return /* @__PURE__ */ e.jsxs(
641
685
  "div",
642
686
  {
@@ -646,22 +690,42 @@ function we({
646
690
  "button",
647
691
  {
648
692
  type: "button",
649
- onClick: () => p(i),
693
+ onClick: () => ee(a),
650
694
  className: "flex w-full items-center gap-2 bg-slate-100 px-4 py-2 text-left font-mono text-xs text-slate-700 hover:bg-slate-200",
651
695
  children: [
652
- /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: ee ? "▾" : "▸" }),
653
- /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: i }),
696
+ /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: w ? "▾" : "▸" }),
697
+ /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: a }),
654
698
  /* @__PURE__ */ e.jsxs("span", { className: "shrink-0 text-slate-400", children: [
655
- (F[i].length / 1024).toFixed(1),
699
+ ($[a].length / 1024).toFixed(1),
656
700
  " KB"
657
701
  ] })
658
702
  ]
659
703
  }
660
704
  ),
661
- ee ? /* @__PURE__ */ e.jsx("pre", { className: "m-0 max-h-72 overflow-auto bg-white p-4 font-mono text-xs leading-relaxed text-slate-800", children: F[i] }) : null
705
+ w ? /* @__PURE__ */ e.jsxs("div", { className: "bg-white", children: [
706
+ t.get(a)?.hunks.length ? /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 border-b border-slate-200 px-4 py-2", children: [
707
+ /* @__PURE__ */ e.jsx(
708
+ "button",
709
+ {
710
+ type: "button",
711
+ onClick: () => o(a),
712
+ className: "rounded border border-slate-300 px-2 py-0.5 text-xs text-slate-700 hover:bg-slate-50",
713
+ children: R.has(a) ? "Show converted file" : "Show what changed"
714
+ }
715
+ ),
716
+ /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-slate-500", children: [
717
+ "+",
718
+ t.get(a).stats.added,
719
+ " −",
720
+ t.get(a).stats.removed,
721
+ " in the LaTeX source"
722
+ ] })
723
+ ] }) : null,
724
+ R.has(a) && t.has(a) ? /* @__PURE__ */ e.jsx(Oe, { hunks: t.get(a).hunks }) : /* @__PURE__ */ e.jsx("pre", { className: "m-0 max-h-72 overflow-auto p-4 font-mono text-xs leading-relaxed text-slate-800", children: $[a] })
725
+ ] }) : null
662
726
  ]
663
727
  },
664
- i
728
+ a
665
729
  );
666
730
  }) }) : null,
667
731
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-3 pt-1", children: [
@@ -669,17 +733,17 @@ function we({
669
733
  "button",
670
734
  {
671
735
  type: "button",
672
- onClick: f ?? t,
736
+ onClick: m ?? B,
673
737
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
674
- children: f ? "Cancel" : "Start Over"
738
+ children: m ? "Cancel" : "Start Over"
675
739
  }
676
740
  ),
677
741
  /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
678
- J ? /* @__PURE__ */ e.jsx(
742
+ V ? /* @__PURE__ */ e.jsx(
679
743
  "button",
680
744
  {
681
745
  type: "button",
682
- onClick: () => x({ name: "sources", prepared: J }),
746
+ onClick: () => x({ name: "sources", prepared: V }),
683
747
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
684
748
  children: "Change Sources"
685
749
  }
@@ -689,17 +753,17 @@ function we({
689
753
  {
690
754
  type: "button",
691
755
  onClick: () => {
692
- m || d(s, N), k((i) => !i);
756
+ A || F(n, d), ae((a) => !a);
693
757
  },
694
758
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
695
- children: m ? "Hide Preview" : "Preview"
759
+ children: A ? "Hide Preview" : "Preview"
696
760
  }
697
761
  ),
698
762
  /* @__PURE__ */ e.jsx(
699
763
  "button",
700
764
  {
701
765
  type: "button",
702
- onClick: () => o(s, N),
766
+ onClick: () => l(n, d),
703
767
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
704
768
  children: "Confirm Import"
705
769
  }
@@ -711,7 +775,7 @@ function we({
711
775
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
712
776
  c.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
713
777
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Converter" }),
714
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: c.map((r) => /* @__PURE__ */ e.jsxs(
778
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: c.map((s) => /* @__PURE__ */ e.jsxs(
715
779
  "label",
716
780
  {
717
781
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -721,77 +785,64 @@ function we({
721
785
  {
722
786
  type: "radio",
723
787
  name: "import-engine",
724
- value: r.id,
725
- checked: R === r.id,
726
- onChange: () => O(r.id),
788
+ value: s.id,
789
+ checked: P === s.id,
790
+ onChange: () => K(s.id),
727
791
  className: "mt-0.5"
728
792
  }
729
793
  ),
730
794
  /* @__PURE__ */ e.jsxs("span", { children: [
731
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: r.label }),
732
- r.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: r.description }) : null
795
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: s.label }),
796
+ s.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: s.description }) : null
733
797
  ] })
734
798
  ]
735
799
  },
736
- r.id
800
+ s.id
737
801
  )) })
738
802
  ] }) : null,
739
- v ? null : /* @__PURE__ */ e.jsxs("div", { className: "flex flex-wrap gap-4 text-sm", children: [
740
- /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
741
- /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: "Document kind" }),
742
- /* @__PURE__ */ e.jsxs(
743
- "select",
744
- {
745
- value: w,
746
- onChange: (r) => A(
747
- r.currentTarget.value
748
- ),
749
- className: "rounded border border-slate-300 px-2 py-1 text-sm",
750
- children: [
751
- /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
752
- /* @__PURE__ */ e.jsx("option", { value: "article", children: "Article" }),
753
- /* @__PURE__ */ e.jsx("option", { value: "book", children: "Book" })
754
- ]
755
- }
756
- )
757
- ] }),
758
- /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-sm text-slate-700", children: [
759
- /* @__PURE__ */ e.jsx(
760
- "input",
761
- {
762
- type: "checkbox",
763
- checked: T,
764
- onChange: (r) => S(r.currentTarget.checked)
765
- }
766
- ),
767
- "Split sections into separate files"
768
- ] })
769
- ] }),
803
+ f ? null : /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-4 text-sm", children: /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
804
+ /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: "Document kind" }),
805
+ /* @__PURE__ */ e.jsxs(
806
+ "select",
807
+ {
808
+ value: _,
809
+ onChange: (s) => L(
810
+ s.currentTarget.value
811
+ ),
812
+ className: "rounded border border-slate-300 px-2 py-1 text-sm",
813
+ children: [
814
+ /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
815
+ /* @__PURE__ */ e.jsx("option", { value: "article", children: "Article" }),
816
+ /* @__PURE__ */ e.jsx("option", { value: "book", children: "Book" })
817
+ ]
818
+ }
819
+ )
820
+ ] }) }),
770
821
  /* @__PURE__ */ e.jsxs(
771
822
  "div",
772
823
  {
773
824
  role: "button",
774
825
  tabIndex: 0,
775
- onKeyDown: (r) => r.key === "Enter" && j.current?.click(),
776
- onClick: () => j.current?.click(),
777
- onDragOver: (r) => {
778
- r.preventDefault(), y(!0);
826
+ onKeyDown: (s) => s.key === "Enter" && v.current?.click(),
827
+ onClick: () => v.current?.click(),
828
+ onDragOver: (s) => {
829
+ s.preventDefault(), E(!0);
779
830
  },
780
- onDragLeave: () => y(!1),
781
- onDrop: (r) => {
782
- r.preventDefault(), y(!1);
783
- const s = r.dataTransfer.files?.[0];
784
- s && W(s);
831
+ onDragLeave: () => E(!1),
832
+ onDrop: (s) => {
833
+ s.preventDefault(), E(!1);
834
+ const o = s.dataTransfer.files?.[0];
835
+ o && Y(o);
785
836
  },
786
- className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${C ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
837
+ className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${O ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
787
838
  children: [
788
839
  /* @__PURE__ */ e.jsx("p", { className: "text-slate-600", children: "Drop a file here, or click to select." }),
789
840
  /* @__PURE__ */ e.jsx(
790
841
  "button",
791
842
  {
792
843
  type: "button",
793
- onClick: (r) => {
794
- r.stopPropagation(), j.current?.click();
844
+ onClick: (s) => {
845
+ s.stopPropagation(), v.current?.click();
795
846
  },
796
847
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
797
848
  children: "Select File"
@@ -799,18 +850,18 @@ function we({
799
850
  ),
800
851
  /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-slate-400", children: [
801
852
  "Supports ",
802
- U.join(", ")
853
+ Q.join(", ")
803
854
  ] }),
804
855
  /* @__PURE__ */ e.jsx(
805
856
  "input",
806
857
  {
807
- ref: j,
858
+ ref: v,
808
859
  type: "file",
809
860
  hidden: !0,
810
- accept: U.join(","),
811
- onChange: (r) => {
812
- const s = r.currentTarget.files?.[0];
813
- s && W(s), r.currentTarget.value = "";
861
+ accept: Q.join(","),
862
+ onChange: (s) => {
863
+ const o = s.currentTarget.files?.[0];
864
+ o && Y(o), s.currentTarget.value = "";
814
865
  }
815
866
  }
816
867
  )
@@ -819,7 +870,23 @@ function we({
819
870
  )
820
871
  ] });
821
872
  }
822
- const Ee = {
873
+ function Oe({ hunks: l }) {
874
+ return l.length === 0 ? /* @__PURE__ */ e.jsx("p", { className: "m-0 px-4 py-3 text-xs text-slate-500", children: "Nothing was changed in this file." }) : /* @__PURE__ */ e.jsx("div", { className: "max-h-72 overflow-auto bg-white font-mono text-xs leading-relaxed", children: l.map((m, f) => /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-100 last:border-b-0", children: [
875
+ f > 0 ? /* @__PURE__ */ e.jsx("div", { className: "bg-slate-50 px-4 py-1 text-slate-400", children: "⋯" }) : null,
876
+ m.lines.map((j, h) => /* @__PURE__ */ e.jsxs(
877
+ "div",
878
+ {
879
+ className: j.op === "add" ? "bg-green-50 px-4 text-green-900" : j.op === "remove" ? "bg-red-50 px-4 text-red-900" : "px-4 text-slate-600",
880
+ children: [
881
+ /* @__PURE__ */ e.jsx("span", { className: "mr-2 select-none text-slate-400", children: j.op === "add" ? "+" : j.op === "remove" ? "−" : " " }),
882
+ j.text || " "
883
+ ]
884
+ },
885
+ h
886
+ ))
887
+ ] }, f)) });
888
+ }
889
+ const Le = {
823
890
  title: "Import Source Content",
824
891
  description: "Paste LaTeX, Markdown, or PreTeXt source to convert into PreTeXt.",
825
892
  sourceLabel: "Source",
@@ -830,37 +897,37 @@ const Ee = {
830
897
  successPrefix: "Ready",
831
898
  errorPrefix: "Error"
832
899
  };
833
- function Pe({
834
- initialSource: o = "",
835
- initialSourceFormat: f,
836
- labels: v,
837
- disabled: E = !1,
838
- onImport: b
900
+ function Xe({
901
+ initialSource: l = "",
902
+ initialSourceFormat: m,
903
+ labels: f,
904
+ disabled: j = !1,
905
+ onImport: h
839
906
  }) {
840
907
  const c = re(
841
- () => ({ ...Ee, ...v ?? {} }),
842
- [v]
843
- ), [j, g] = h(o), [x, C] = h(
844
- f ?? "auto"
845
- ), [y, w] = h(
908
+ () => ({ ...Le, ...f ?? {} }),
909
+ [f]
910
+ ), [v, N] = g(l), [x, O] = g(
911
+ m ?? "auto"
912
+ ), [E, _] = g(
846
913
  null
847
- ), A = re(
848
- () => fe(j),
849
- [j]
850
- ), T = E || !j.trim();
914
+ ), L = re(
915
+ () => ke(v),
916
+ [v]
917
+ ), T = j || !v.trim();
851
918
  return /* @__PURE__ */ e.jsx(
852
919
  "form",
853
920
  {
854
- onSubmit: (S) => {
855
- S.preventDefault();
856
- const R = he(
857
- j,
921
+ onSubmit: (k) => {
922
+ k.preventDefault();
923
+ const R = Se(
924
+ v,
858
925
  x === "auto" ? void 0 : x
859
926
  );
860
- w(R), b(R);
927
+ _(R), h(R);
861
928
  },
862
929
  "aria-label": "Import source form",
863
- children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: E, children: [
930
+ children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: j, children: [
864
931
  /* @__PURE__ */ e.jsx("legend", { children: c.title }),
865
932
  /* @__PURE__ */ e.jsx("p", { children: c.description }),
866
933
  /* @__PURE__ */ e.jsxs("label", { children: [
@@ -868,8 +935,8 @@ function Pe({
868
935
  /* @__PURE__ */ e.jsx(
869
936
  "textarea",
870
937
  {
871
- value: j,
872
- onChange: (S) => g(S.currentTarget.value),
938
+ value: v,
939
+ onChange: (k) => N(k.currentTarget.value),
873
940
  placeholder: c.sourcePlaceholder,
874
941
  rows: 12
875
942
  }
@@ -881,8 +948,8 @@ function Pe({
881
948
  "select",
882
949
  {
883
950
  value: x,
884
- onChange: (S) => C(
885
- S.currentTarget.value
951
+ onChange: (k) => O(
952
+ k.currentTarget.value
886
953
  ),
887
954
  children: [
888
955
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -896,24 +963,24 @@ function Pe({
896
963
  /* @__PURE__ */ e.jsxs("p", { children: [
897
964
  c.detectedFormatPrefix,
898
965
  ": ",
899
- /* @__PURE__ */ e.jsx("strong", { children: A })
966
+ /* @__PURE__ */ e.jsx("strong", { children: L })
900
967
  ] }),
901
968
  /* @__PURE__ */ e.jsx("button", { type: "submit", disabled: T, children: c.convertButton }),
902
- y ? "pretextError" in y ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
969
+ E ? "pretextError" in E ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
903
970
  c.errorPrefix,
904
971
  ": ",
905
- y.pretextError
972
+ E.pretextError
906
973
  ] }) : /* @__PURE__ */ e.jsxs("p", { children: [
907
974
  c.successPrefix,
908
975
  ": ",
909
- y.pretextSource.length,
976
+ E.pretextSource.length,
910
977
  " characters of PreTeXt generated."
911
978
  ] }) : null
912
979
  ] })
913
980
  }
914
981
  );
915
982
  }
916
- const Te = {
983
+ const De = {
917
984
  title: "Upload Source File",
918
985
  hint: "Supports .tex, .md, .ptx, .xml, .zip, and .tar.gz files.",
919
986
  selectButton: "Select File",
@@ -921,43 +988,43 @@ const Te = {
921
988
  documentKindLabel: "Document kind",
922
989
  splitSectionsLabel: "Split each chapter into sections"
923
990
  };
924
- function Re({
925
- labels: o,
926
- disabled: f = !1,
927
- defaultDocumentKind: v = "auto",
928
- importOptions: E,
929
- onImport: b
991
+ function ze({
992
+ labels: l,
993
+ disabled: m = !1,
994
+ defaultDocumentKind: f = "auto",
995
+ importOptions: j,
996
+ onImport: h
930
997
  }) {
931
998
  const c = re(
932
- () => ({ ...Te, ...o ?? {} }),
933
- [o]
934
- ), j = ce(null), [g, x] = h(!1), [C, y] = h(!1), [w, A] = h(
999
+ () => ({ ...De, ...l ?? {} }),
1000
+ [l]
1001
+ ), v = he(null), [N, x] = g(!1), [O, E] = g(!1), [_, L] = g(
935
1002
  []
936
- ), [T, S] = h(v), [R, O] = h(!1), N = f || C, L = async (m) => {
937
- y(!0);
1003
+ ), [T, k] = g(f), [R, D] = g(!1), P = m || O, K = async (d) => {
1004
+ E(!0);
938
1005
  try {
939
- const $ = await ie(m, E ?? {
1006
+ const A = await be(d, j ?? {
940
1007
  documentKind: T === "auto" ? void 0 : T,
941
1008
  splitSections: R
942
1009
  });
943
- A($.statusMessages), b($);
1010
+ L(A.statusMessages), h(A);
944
1011
  } finally {
945
- y(!1);
1012
+ E(!1);
946
1013
  }
947
1014
  };
948
1015
  return /* @__PURE__ */ e.jsxs("section", { "aria-label": "Import upload panel", children: [
949
1016
  /* @__PURE__ */ e.jsx("h3", { children: c.title }),
950
1017
  /* @__PURE__ */ e.jsx("p", { children: c.hint }),
951
- E ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
1018
+ j ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
952
1019
  /* @__PURE__ */ e.jsxs("label", { children: [
953
1020
  c.documentKindLabel,
954
1021
  /* @__PURE__ */ e.jsxs(
955
1022
  "select",
956
1023
  {
957
1024
  value: T,
958
- disabled: N,
959
- onChange: (m) => S(
960
- m.currentTarget.value
1025
+ disabled: P,
1026
+ onChange: (d) => k(
1027
+ d.currentTarget.value
961
1028
  ),
962
1029
  children: [
963
1030
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -973,8 +1040,8 @@ function Re({
973
1040
  {
974
1041
  type: "checkbox",
975
1042
  checked: R,
976
- disabled: N,
977
- onChange: (m) => O(m.currentTarget.checked)
1043
+ disabled: P,
1044
+ onChange: (d) => D(d.currentTarget.checked)
978
1045
  }
979
1046
  ),
980
1047
  c.splitSectionsLabel
@@ -983,15 +1050,15 @@ function Re({
983
1050
  /* @__PURE__ */ e.jsxs(
984
1051
  "div",
985
1052
  {
986
- onDragOver: (m) => {
987
- m.preventDefault(), N || x(!0);
1053
+ onDragOver: (d) => {
1054
+ d.preventDefault(), P || x(!0);
988
1055
  },
989
1056
  onDragLeave: () => x(!1),
990
- onDrop: (m) => {
991
- if (m.preventDefault(), x(!1), N)
1057
+ onDrop: (d) => {
1058
+ if (d.preventDefault(), x(!1), P)
992
1059
  return;
993
- const k = m.dataTransfer.files?.[0];
994
- k && L(k);
1060
+ const S = d.dataTransfer.files?.[0];
1061
+ S && K(S);
995
1062
  },
996
1063
  children: [
997
1064
  /* @__PURE__ */ e.jsx("p", { children: c.dropHint }),
@@ -999,34 +1066,34 @@ function Re({
999
1066
  "button",
1000
1067
  {
1001
1068
  type: "button",
1002
- disabled: N,
1003
- onClick: () => j.current?.click(),
1004
- children: C ? "Processing..." : c.selectButton
1069
+ disabled: P,
1070
+ onClick: () => v.current?.click(),
1071
+ children: O ? "Processing..." : c.selectButton
1005
1072
  }
1006
1073
  ),
1007
1074
  /* @__PURE__ */ e.jsx(
1008
1075
  "input",
1009
1076
  {
1010
- ref: j,
1077
+ ref: v,
1011
1078
  type: "file",
1012
1079
  hidden: !0,
1013
- disabled: N,
1080
+ disabled: P,
1014
1081
  accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
1015
- onChange: (m) => {
1016
- const k = m.currentTarget.files?.[0];
1017
- k && L(k), m.currentTarget.value = "";
1082
+ onChange: (d) => {
1083
+ const S = d.currentTarget.files?.[0];
1084
+ S && K(S), d.currentTarget.value = "";
1018
1085
  }
1019
1086
  }
1020
1087
  )
1021
1088
  ]
1022
1089
  }
1023
1090
  ),
1024
- w.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: w.map((m, k) => /* @__PURE__ */ e.jsx("li", { children: m.message }, `${m.type}-${k}`)) }) : null,
1025
- g && !N ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1091
+ _.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: _.map((d, S) => /* @__PURE__ */ e.jsx("li", { children: d.message }, `${d.type}-${S}`)) }) : null,
1092
+ N && !P ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1026
1093
  ] });
1027
1094
  }
1028
1095
  export {
1029
- Pe as ImportSourceForm,
1030
- Re as ImportUploadPanel,
1031
- we as ImportWizard
1096
+ Xe as ImportSourceForm,
1097
+ ze as ImportUploadPanel,
1098
+ Me as ImportWizard
1032
1099
  };