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