@pretextbook/import 0.9.0 → 0.10.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.
Files changed (44) hide show
  1. package/dist/convert-worker.cjs +1 -1
  2. package/dist/convert-worker.js +1 -1
  3. package/dist/{import-mode-DuPFMu97.cjs → import-mode-CV7gCDzF.cjs} +1 -1
  4. package/dist/{import-mode-BaaBvzcy.js → import-mode-DQ8g5P8P.js} +1 -1
  5. package/dist/import.css +1 -1
  6. package/dist/index.cjs +3 -3
  7. package/dist/index.d.ts +9 -5
  8. package/dist/index.js +523 -216
  9. package/dist/lib/assets/images.d.ts +49 -0
  10. package/dist/lib/detect-snippet-format.d.ts +32 -0
  11. package/dist/lib/insert/dedupe-ids.d.ts +36 -0
  12. package/dist/lib/insert/destination.d.ts +21 -0
  13. package/dist/lib/insert/index.d.ts +4 -0
  14. package/dist/lib/insert/prepare.d.ts +44 -0
  15. package/dist/lib/insert/retarget.d.ts +35 -0
  16. package/dist/lib/layout/xml-scan.d.ts +28 -0
  17. package/dist/lib/pandoc/formats.d.ts +40 -0
  18. package/dist/lib/pandoc/index.d.ts +3 -0
  19. package/dist/lib/pandoc/pandoc-engine.d.ts +24 -0
  20. package/dist/lib/pandoc/remote-pandoc.d.ts +74 -0
  21. package/dist/lib/pool/division-pool.d.ts +5 -0
  22. package/dist/lib/pool/index.d.ts +5 -1
  23. package/dist/lib/pool/place-divisions.d.ts +25 -0
  24. package/dist/lib/pool/placeholders.d.ts +4 -0
  25. package/dist/lib/pool/refs.d.ts +8 -0
  26. package/dist/lib/pool/serialize-destination.d.ts +24 -0
  27. package/dist/lib/pool/serialize-files.d.ts +1 -2
  28. package/dist/lib/pool/serialize-insert-records.d.ts +22 -0
  29. package/dist/lib/pool/serialize-insert.d.ts +44 -0
  30. package/dist/lib/pool/serialize-plus.d.ts +4 -4
  31. package/dist/lib/pool/serialize-records.d.ts +11 -0
  32. package/dist/lib/pretext-divisions.d.ts +25 -0
  33. package/dist/lib/select/divisions.d.ts +44 -0
  34. package/dist/lib/types.d.ts +82 -2
  35. package/dist/lib/upload.d.ts +56 -4
  36. package/dist/react/import-wizard.d.ts +30 -1
  37. package/dist/react/index.d.ts +1 -1
  38. package/dist/react.cjs +2 -2
  39. package/dist/react.js +658 -511
  40. package/dist/upload-BnRj1gU1.cjs +135 -0
  41. package/dist/upload-H_OCZBBn.js +7648 -0
  42. package/package.json +1 -1
  43. package/dist/upload-BmErkg8I.js +0 -7140
  44. package/dist/upload-BtS22hIH.cjs +0 -135
package/dist/react.js CHANGED
@@ -1,150 +1,150 @@
1
- import Ce, { useState as p, useRef as ie, useEffect as Re, useMemo as ae } from "react";
2
- import { S as Ee, $ as Ae, j as Fe, T as Oe, g as Le, h as ke, E as De, A as Ie } from "./upload-BmErkg8I.js";
3
- import { D as $e, f as Me, h as Xe, r as ze, e as je } from "./import-mode-BaaBvzcy.js";
4
- var ce = { exports: {} }, re = {};
5
- var ve;
6
- function Ue() {
7
- if (ve) return re;
8
- ve = 1;
9
- var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
10
- function x(h, j, d) {
11
- var y = null;
12
- if (d !== void 0 && (y = "" + d), j.key !== void 0 && (y = "" + j.key), "key" in j) {
13
- d = {};
14
- for (var S in j)
15
- S !== "key" && (d[S] = j[S]);
16
- } else d = j;
17
- return j = d.ref, {
18
- $$typeof: s,
19
- type: h,
20
- key: y,
21
- ref: j !== void 0 ? j : null,
22
- props: d
1
+ import Be, { useState as g, useRef as pe, useEffect as We, useMemo as K } from "react";
2
+ import { Y as Fe, a8 as Ke, a3 as Ve, D as qe, m as Ge, j as Je, g as He, h as De, K as Ze, G as Qe } from "./upload-H_OCZBBn.js";
3
+ import { D as et, f as tt, h as Se, r as st, e as Pe } from "./import-mode-DQ8g5P8P.js";
4
+ var xe = { exports: {} }, ae = {};
5
+ var Ce;
6
+ function rt() {
7
+ if (Ce) return ae;
8
+ Ce = 1;
9
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function d(u, x, c) {
11
+ var N = null;
12
+ if (c !== void 0 && (N = "" + c), x.key !== void 0 && (N = "" + x.key), "key" in x) {
13
+ c = {};
14
+ for (var C in x)
15
+ C !== "key" && (c[C] = x[C]);
16
+ } else c = x;
17
+ return x = c.ref, {
18
+ $$typeof: r,
19
+ type: u,
20
+ key: N,
21
+ ref: x !== void 0 ? x : null,
22
+ props: c
23
23
  };
24
24
  }
25
- return re.Fragment = u, re.jsx = x, re.jsxs = x, re;
25
+ return ae.Fragment = o, ae.jsx = d, ae.jsxs = d, ae;
26
26
  }
27
- var se = {};
28
- var Ne;
29
- function Ye() {
30
- return Ne || (Ne = 1, process.env.NODE_ENV !== "production" && (function() {
31
- function s(t) {
27
+ var le = {};
28
+ var Re;
29
+ function nt() {
30
+ return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ function r(t) {
32
32
  if (t == null) return null;
33
33
  if (typeof t == "function")
34
- return t.$$typeof === Z ? null : t.displayName || t.name || null;
34
+ return t.$$typeof === fe ? null : t.displayName || t.name || null;
35
35
  if (typeof t == "string") return t;
36
36
  switch (t) {
37
- case F:
37
+ case Y:
38
38
  return "Fragment";
39
- case X:
39
+ case z:
40
40
  return "Profiler";
41
- case C:
41
+ case R:
42
42
  return "StrictMode";
43
- case de:
43
+ case ee:
44
44
  return "Suspense";
45
- case ne:
45
+ case oe:
46
46
  return "SuspenseList";
47
- case ue:
47
+ case he:
48
48
  return "Activity";
49
49
  }
50
50
  if (typeof t == "object")
51
51
  switch (typeof t.tag == "number" && console.error(
52
52
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
53
53
  ), t.$$typeof) {
54
- case A:
54
+ case D:
55
55
  return "Portal";
56
56
  case _:
57
57
  return t.displayName || "Context";
58
- case g:
58
+ case j:
59
59
  return (t._context.displayName || "Context") + ".Consumer";
60
- case B:
61
- var a = t.render;
62
- return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
63
- case W:
64
- return a = t.displayName || null, a !== null ? a : s(t.type) || "Memo";
65
- case K:
66
- a = t._payload, t = t._init;
60
+ case A:
61
+ var l = t.render;
62
+ return t = t.displayName, t || (t = l.displayName || l.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
63
+ case ce:
64
+ return l = t.displayName || null, l !== null ? l : r(t.type) || "Memo";
65
+ case V:
66
+ l = t._payload, t = t._init;
67
67
  try {
68
- return s(t(a));
68
+ return r(t(l));
69
69
  } catch {
70
70
  }
71
71
  }
72
72
  return null;
73
73
  }
74
- function u(t) {
74
+ function o(t) {
75
75
  return "" + t;
76
76
  }
77
- function x(t) {
77
+ function d(t) {
78
78
  try {
79
- u(t);
80
- var a = !1;
79
+ o(t);
80
+ var l = !1;
81
81
  } catch {
82
- a = !0;
82
+ l = !0;
83
83
  }
84
- if (a) {
85
- a = console;
86
- var i = a.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
87
- return i.call(
88
- a,
84
+ if (l) {
85
+ l = console;
86
+ var h = l.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
87
+ return h.call(
88
+ l,
89
89
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
90
  f
91
- ), u(t);
91
+ ), o(t);
92
92
  }
93
93
  }
94
- function h(t) {
95
- if (t === F) return "<>";
96
- if (typeof t == "object" && t !== null && t.$$typeof === K)
94
+ function u(t) {
95
+ if (t === Y) return "<>";
96
+ if (typeof t == "object" && t !== null && t.$$typeof === V)
97
97
  return "<...>";
98
98
  try {
99
- var a = s(t);
100
- return a ? "<" + a + ">" : "<...>";
99
+ var l = r(t);
100
+ return l ? "<" + l + ">" : "<...>";
101
101
  } catch {
102
102
  return "<...>";
103
103
  }
104
104
  }
105
- function j() {
106
- var t = z.A;
105
+ function x() {
106
+ var t = q.A;
107
107
  return t === null ? null : t.getOwner();
108
108
  }
109
- function d() {
109
+ function c() {
110
110
  return Error("react-stack-top-frame");
111
111
  }
112
- function y(t) {
113
- if (Q.call(t, "key")) {
114
- var a = Object.getOwnPropertyDescriptor(t, "key").get;
115
- if (a && a.isReactWarning) return !1;
112
+ function N(t) {
113
+ if (B.call(t, "key")) {
114
+ var l = Object.getOwnPropertyDescriptor(t, "key").get;
115
+ if (l && l.isReactWarning) return !1;
116
116
  }
117
117
  return t.key !== void 0;
118
118
  }
119
- function S(t, a) {
120
- function i() {
121
- ee || (ee = !0, console.error(
119
+ function C(t, l) {
120
+ function h() {
121
+ G || (G = !0, console.error(
122
122
  "%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)",
123
- a
123
+ l
124
124
  ));
125
125
  }
126
- i.isReactWarning = !0, Object.defineProperty(t, "key", {
127
- get: i,
126
+ h.isReactWarning = !0, Object.defineProperty(t, "key", {
127
+ get: h,
128
128
  configurable: !0
129
129
  });
130
130
  }
131
- function w() {
132
- var t = s(this.type);
133
- return V[t] || (V[t] = !0, console.error(
131
+ function p() {
132
+ var t = r(this.type);
133
+ return J[t] || (J[t] = !0, console.error(
134
134
  "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."
135
135
  )), t = this.props.ref, t !== void 0 ? t : null;
136
136
  }
137
- function P(t, a, i, f, O, $) {
138
- var m = i.ref;
137
+ function S(t, l, h, f, X, H) {
138
+ var b = h.ref;
139
139
  return t = {
140
- $$typeof: k,
140
+ $$typeof: P,
141
141
  type: t,
142
- key: a,
143
- props: i,
142
+ key: l,
143
+ props: h,
144
144
  _owner: f
145
- }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
145
+ }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(t, "ref", {
146
146
  enumerable: !1,
147
- get: w
147
+ get: p
148
148
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
149
149
  configurable: !1,
150
150
  enumerable: !1,
@@ -159,33 +159,33 @@ function Ye() {
159
159
  configurable: !1,
160
160
  enumerable: !1,
161
161
  writable: !0,
162
- value: O
162
+ value: X
163
163
  }), Object.defineProperty(t, "_debugTask", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: $
167
+ value: H
168
168
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
169
169
  }
170
- function v(t, a, i, f, O, $) {
171
- var m = a.children;
172
- if (m !== void 0)
170
+ function T(t, l, h, f, X, H) {
171
+ var b = l.children;
172
+ if (b !== void 0)
173
173
  if (f)
174
- if (U(m)) {
175
- for (f = 0; f < m.length; f++)
176
- b(m[f]);
177
- Object.freeze && Object.freeze(m);
174
+ if (ie(b)) {
175
+ for (f = 0; f < b.length; f++)
176
+ y(b[f]);
177
+ Object.freeze && Object.freeze(b);
178
178
  } else
179
179
  console.error(
180
180
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
181
181
  );
182
- else b(m);
183
- if (Q.call(a, "key")) {
184
- m = s(t);
185
- var R = Object.keys(a).filter(function(me) {
186
- return me !== "key";
182
+ else y(b);
183
+ if (B.call(l, "key")) {
184
+ b = r(t);
185
+ var E = Object.keys(l).filter(function(O) {
186
+ return O !== "key";
187
187
  });
188
- f = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", J[m + f] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ f = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", re[b + f] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
189
189
  `A props object containing a "key" prop is being spread into JSX:
190
190
  let props = %s;
191
191
  <%s {...props} />
@@ -193,91 +193,91 @@ React keys must be passed directly to JSX without using spread:
193
193
  let props = %s;
194
194
  <%s key={someKey} {...props} />`,
195
195
  f,
196
- m,
197
- R,
198
- m
199
- ), J[m + f] = !0);
196
+ b,
197
+ E,
198
+ b
199
+ ), re[b + f] = !0);
200
200
  }
201
- if (m = null, i !== void 0 && (x(i), m = "" + i), y(a) && (x(a.key), m = "" + a.key), "key" in a) {
202
- i = {};
203
- for (var H in a)
204
- H !== "key" && (i[H] = a[H]);
205
- } else i = a;
206
- return m && S(
207
- i,
201
+ if (b = null, h !== void 0 && (d(h), b = "" + h), N(l) && (d(l.key), b = "" + l.key), "key" in l) {
202
+ h = {};
203
+ for (var Z in l)
204
+ Z !== "key" && (h[Z] = l[Z]);
205
+ } else h = l;
206
+ return b && C(
207
+ h,
208
208
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
209
- ), P(
209
+ ), S(
210
210
  t,
211
- m,
212
- i,
213
- j(),
214
- O,
215
- $
211
+ b,
212
+ h,
213
+ x(),
214
+ X,
215
+ H
216
216
  );
217
217
  }
218
- function b(t) {
219
- D(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === K && (t._payload.status === "fulfilled" ? D(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
218
+ function y(t) {
219
+ v(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === V && (t._payload.status === "fulfilled" ? v(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
220
220
  }
221
- function D(t) {
222
- return typeof t == "object" && t !== null && t.$$typeof === k;
221
+ function v(t) {
222
+ return typeof t == "object" && t !== null && t.$$typeof === P;
223
223
  }
224
- var E = Ce, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), F = /* @__PURE__ */ Symbol.for("react.fragment"), C = /* @__PURE__ */ Symbol.for("react.strict_mode"), X = /* @__PURE__ */ Symbol.for("react.profiler"), g = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), B = /* @__PURE__ */ Symbol.for("react.forward_ref"), de = /* @__PURE__ */ Symbol.for("react.suspense"), ne = /* @__PURE__ */ Symbol.for("react.suspense_list"), W = /* @__PURE__ */ Symbol.for("react.memo"), K = /* @__PURE__ */ Symbol.for("react.lazy"), ue = /* @__PURE__ */ Symbol.for("react.activity"), Z = /* @__PURE__ */ Symbol.for("react.client.reference"), z = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Q = Object.prototype.hasOwnProperty, U = Array.isArray, q = console.createTask ? console.createTask : function() {
224
+ var F = Be, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), Y = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), ee = /* @__PURE__ */ Symbol.for("react.suspense"), oe = /* @__PURE__ */ Symbol.for("react.suspense_list"), ce = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), he = /* @__PURE__ */ Symbol.for("react.activity"), fe = /* @__PURE__ */ Symbol.for("react.client.reference"), q = F.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, ie = Array.isArray, te = console.createTask ? console.createTask : function() {
225
225
  return null;
226
226
  };
227
- E = {
227
+ F = {
228
228
  react_stack_bottom_frame: function(t) {
229
229
  return t();
230
230
  }
231
231
  };
232
- var ee, V = {}, G = E.react_stack_bottom_frame.bind(
233
- E,
234
- d
235
- )(), I = q(h(d)), J = {};
236
- se.Fragment = F, se.jsx = function(t, a, i) {
237
- var f = 1e4 > z.recentlyCreatedOwnerStacks++;
238
- return v(
232
+ var G, J = {}, se = F.react_stack_bottom_frame.bind(
233
+ F,
234
+ c
235
+ )(), M = te(u(c)), re = {};
236
+ le.Fragment = Y, le.jsx = function(t, l, h) {
237
+ var f = 1e4 > q.recentlyCreatedOwnerStacks++;
238
+ return T(
239
239
  t,
240
- a,
241
- i,
240
+ l,
241
+ h,
242
242
  !1,
243
- f ? Error("react-stack-top-frame") : G,
244
- f ? q(h(t)) : I
243
+ f ? Error("react-stack-top-frame") : se,
244
+ f ? te(u(t)) : M
245
245
  );
246
- }, se.jsxs = function(t, a, i) {
247
- var f = 1e4 > z.recentlyCreatedOwnerStacks++;
248
- return v(
246
+ }, le.jsxs = function(t, l, h) {
247
+ var f = 1e4 > q.recentlyCreatedOwnerStacks++;
248
+ return T(
249
249
  t,
250
- a,
251
- i,
250
+ l,
251
+ h,
252
252
  !0,
253
- f ? Error("react-stack-top-frame") : G,
254
- f ? q(h(t)) : I
253
+ f ? Error("react-stack-top-frame") : se,
254
+ f ? te(u(t)) : M
255
255
  );
256
256
  };
257
- })()), se;
257
+ })()), le;
258
258
  }
259
- var ye;
260
- function Be() {
261
- return ye || (ye = 1, process.env.NODE_ENV === "production" ? ce.exports = Ue() : ce.exports = Ye()), ce.exports;
259
+ var _e;
260
+ function at() {
261
+ return _e || (_e = 1, process.env.NODE_ENV === "production" ? xe.exports = rt() : xe.exports = nt()), xe.exports;
262
262
  }
263
- var e = Be();
264
- function We() {
265
- const [s, u] = p(0), x = ie(Date.now());
266
- return Re(() => {
267
- const h = setInterval(() => {
268
- u(Math.floor((Date.now() - x.current) / 1e3));
263
+ var e = at();
264
+ function lt() {
265
+ const [r, o] = g(0), d = pe(Date.now());
266
+ return We(() => {
267
+ const u = setInterval(() => {
268
+ o(Math.floor((Date.now() - d.current) / 1e3));
269
269
  }, 1e3);
270
- return () => clearInterval(h);
271
- }, []), s;
270
+ return () => clearInterval(u);
271
+ }, []), r;
272
272
  }
273
- function Ke(s) {
274
- return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
273
+ function ot(r) {
274
+ return `${Math.floor(r / 60)}:${String(r % 60).padStart(2, "0")}`;
275
275
  }
276
- function qe({
277
- message: s = "Processing your file…",
278
- onCancel: u
276
+ function ct({
277
+ message: r = "Processing your file…",
278
+ onCancel: o
279
279
  }) {
280
- const x = We();
280
+ const d = lt();
281
281
  return /* @__PURE__ */ e.jsxs(
282
282
  "div",
283
283
  {
@@ -286,14 +286,14 @@ function qe({
286
286
  "aria-live": "polite",
287
287
  children: [
288
288
  /* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-2 border-blue-700 border-t-transparent" }),
289
- /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: s }),
290
- /* @__PURE__ */ e.jsx("p", { className: "text-xs tabular-nums text-slate-500", children: Ke(x) }),
291
- x >= 10 ? /* @__PURE__ */ e.jsx("p", { className: "max-w-xs text-center text-xs text-slate-500", children: "Large documents can take a while. You can keep working in other tabs." }) : null,
292
- u ? /* @__PURE__ */ e.jsx(
289
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: r }),
290
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs tabular-nums text-slate-500", children: ot(d) }),
291
+ d >= 10 ? /* @__PURE__ */ e.jsx("p", { className: "max-w-xs text-center text-xs text-slate-500", children: "Large documents can take a while. You can keep working in other tabs." }) : null,
292
+ o ? /* @__PURE__ */ e.jsx(
293
293
  "button",
294
294
  {
295
295
  type: "button",
296
- onClick: u,
296
+ onClick: o,
297
297
  className: "mt-2 rounded border border-slate-300 px-3 py-1.5 text-xs font-medium text-slate-700 hover:bg-slate-50",
298
298
  children: "Cancel"
299
299
  }
@@ -302,7 +302,7 @@ function qe({
302
302
  }
303
303
  );
304
304
  }
305
- const Te = [
305
+ const Oe = [
306
306
  ".tex",
307
307
  ".md",
308
308
  ".markdown",
@@ -312,188 +312,208 @@ const Te = [
312
312
  ".gz",
313
313
  ".tar.gz",
314
314
  ".tgz"
315
- ], Ve = {
315
+ ], it = {
316
316
  id: "builtin",
317
317
  label: "Built-in converter",
318
318
  description: "Create a new project starting with LaTeX, Markdown, or PreTeXt files.",
319
- acceptExtensions: Te,
320
- convertFile: Ee,
321
- prepare: async (s) => {
322
- const { files: u, assets: x } = await Le(s);
319
+ acceptExtensions: Oe,
320
+ convertFile: Fe,
321
+ prepare: async (r) => {
322
+ const { files: o, assets: d } = await He(r);
323
323
  return {
324
- fileName: s.name,
325
- files: u,
326
- assets: x,
327
- analysis: ke(u)
324
+ fileName: r.name,
325
+ files: o,
326
+ assets: d,
327
+ analysis: De(o)
328
328
  };
329
329
  },
330
- convertPrepared: (s, u) => Oe(s.files, {
331
- ...u,
332
- assets: s.assets
330
+ convertPrepared: (r, o) => Je(r.files, {
331
+ ...o,
332
+ assets: r.assets
333
333
  })
334
334
  };
335
- function fe() {
336
- return new Promise((s) => {
335
+ function Ne() {
336
+ return new Promise((r) => {
337
337
  if (typeof requestAnimationFrame != "function") {
338
- setTimeout(s, 0);
338
+ setTimeout(r, 0);
339
339
  return;
340
340
  }
341
- requestAnimationFrame(() => setTimeout(s, 0));
341
+ requestAnimationFrame(() => setTimeout(r, 0));
342
342
  });
343
343
  }
344
- const we = {
344
+ const Ae = {
345
345
  pretext: "PreTeXt",
346
346
  latex: "LaTeX",
347
347
  markdown: "Markdown"
348
348
  };
349
- function Ge(s) {
350
- const u = s.reason === "manifest-target" ? `project.ptx target “${s.targetName}”` : s.reason === "latex-root" ? "LaTeX document" : s.reason === "pretext-root" ? "PreTeXt document" : s.reason === "markdown-root" ? "Markdown document" : "possible document";
351
- return s.title ? `${s.title} — ${u}` : u;
349
+ function dt(r) {
350
+ const o = r.reason === "manifest-target" ? `project.ptx target “${r.targetName}”` : r.reason === "latex-root" ? "LaTeX document" : r.reason === "pretext-root" ? "PreTeXt document" : r.reason === "markdown-root" ? "Markdown document" : "possible document";
351
+ return r.title ? `${r.title} — ${o}` : o;
352
352
  }
353
- function Je(s) {
354
- return s.candidates.filter(
355
- (x) => x.reason === "manifest-target"
356
- ).length > 1 ? !0 : s.manifest && s.primary?.reason === "manifest-target" ? !1 : s.formats.length > 1 || s.candidates.length > 1 || s.extraRoots.length > 0;
353
+ function ut(r) {
354
+ return r.candidates.filter(
355
+ (d) => d.reason === "manifest-target"
356
+ ).length > 1 ? !0 : r.manifest && r.primary?.reason === "manifest-target" ? !1 : r.formats.length > 1 || r.candidates.length > 1 || r.extraRoots.length > 0;
357
357
  }
358
- function st({
359
- onConfirm: s,
360
- onCancel: u,
361
- importOptions: x,
362
- defaultDocumentKind: h = "auto",
363
- defaultImportMode: j = $e,
364
- lockImportMode: d = !1,
365
- onImportModeChange: y,
366
- engines: S
358
+ function jt({
359
+ onConfirm: r,
360
+ onCancel: o,
361
+ importOptions: d,
362
+ defaultDocumentKind: u = "auto",
363
+ defaultImportMode: x = et,
364
+ lockImportMode: c = !1,
365
+ onImportModeChange: N,
366
+ engines: C,
367
+ insertTarget: p
367
368
  }) {
368
- const w = S && S.length > 0 ? S : [Ve], P = ie(null), [v, b] = p({ name: "upload" }), [D, E] = p(!1), [k, A] = p(h), [F, C] = p(null), [X, g] = p(/* @__PURE__ */ new Set()), [_, B] = p(w[0].id), [de, ne] = p(j), [W, K] = p(!1), [ue, Z] = p(/* @__PURE__ */ new Set()), [z, Q] = p(null), [U, q] = p(
369
+ const S = C && C.length > 0 ? C : [it], T = pe(null), [y, v] = g({ name: "upload" }), [F, P] = g(!1), [D, Y] = g(u), [R, z] = g(null), [j, _] = g(null), [A, ee] = g([]), [oe, ce] = g(/* @__PURE__ */ new Set()), [V, he] = g(S[0].id), [fe, q] = g(x), [B, ie] = g(!1), [te, G] = g(/* @__PURE__ */ new Set()), [J, se] = g(null), [M, re] = g(
369
370
  "auto"
370
- ), [ee, V] = p(null), [G, I] = p({}), [J, t] = p(!1), a = ie(!1), i = w.find((r) => r.id === _) ?? w[0], f = i.acceptExtensions ?? Te, O = v.name === "review" ? v.result : null, $ = ae(
371
- () => O && F !== null ? Ae(O, F) : O,
372
- [O, F]
373
- ), m = ae(
371
+ ), [t, l] = g(null), [h, f] = g({}), [X, H] = g(!1), b = pe(!1), E = S.find((n) => n.id === V) ?? S[0], Z = E.acceptExtensions ?? Oe, O = y.name === "review" ? y.result : null, de = K(
372
+ () => O && (R !== null || j !== null || A.length > 0) ? Ke(O, {
373
+ splitLevel: R ?? void 0,
374
+ targetTag: j ?? void 0,
375
+ selection: A
376
+ }) : O,
377
+ [O, R, j, A]
378
+ ), be = K(
379
+ () => O ? Ve(O.pretextSource) : [],
380
+ [O]
381
+ ), U = K(
374
382
  () => new Map(
375
- $ ? Me($).map((r) => [r.path, r]) : []
383
+ de ? tt(de).map((n) => [n.path, n]) : []
376
384
  ),
377
- [$]
378
- ), R = () => x ?? {
379
- documentKind: k === "auto" ? void 0 : k
380
- }, H = (r) => ke(r.files, {
381
- sourceFormat: U === "auto" ? void 0 : U,
382
- mainFile: ee ?? void 0
383
- }), me = (r) => {
384
- a.current = !0, i.cancel?.(), b(
385
- r ? { name: "sources", prepared: r } : { name: "upload" }
385
+ [de]
386
+ ), ye = K(
387
+ () => p ? {
388
+ kind: "insert",
389
+ targetTag: j ?? p.defaultTargetTag,
390
+ takenIds: new Set(p.takenIds),
391
+ hrefBase: p.hrefBase
392
+ } : void 0,
393
+ [p, j]
394
+ ), ge = () => ({
395
+ ...d ?? {
396
+ documentKind: D === "auto" ? void 0 : D
397
+ },
398
+ ...ye ? { destination: ye } : {},
399
+ ...p?.externalDir ? { externalDir: p.externalDir } : {}
400
+ }), we = (n) => De(n.files, {
401
+ sourceFormat: M === "auto" ? void 0 : M,
402
+ mainFile: t ?? void 0
403
+ }), $e = (n) => {
404
+ b.current = !0, E.cancel?.(), v(
405
+ n ? { name: "sources", prepared: n } : { name: "upload" }
386
406
  );
387
- }, Se = async (r) => {
388
- a.current = !1, b({ name: "processing" }), await fe();
407
+ }, Me = async (n) => {
408
+ b.current = !1, v({ name: "processing" }), await Ne();
389
409
  try {
390
- const l = H(r).extraRoots.map((c) => ({
391
- path: c.path,
392
- include: G[c.path]?.include ?? !0,
393
- level: G[c.path]?.level
394
- })), N = await i.convertPrepared(r, {
395
- ...R(),
396
- sourceFormat: U === "auto" ? void 0 : U,
397
- mainFile: ee ?? void 0,
398
- attachRoots: l
410
+ const a = we(n).extraRoots.map((m) => ({
411
+ path: m.path,
412
+ include: h[m.path]?.include ?? !0,
413
+ level: h[m.path]?.level
414
+ })), k = await E.convertPrepared(n, {
415
+ ...ge(),
416
+ sourceFormat: M === "auto" ? void 0 : M,
417
+ mainFile: t ?? void 0,
418
+ attachRoots: a
399
419
  });
400
- "pretextError" in N ? b({ name: "error", message: N.pretextError }) : b({ name: "review", result: N });
401
- } catch (o) {
402
- if (a.current)
420
+ "pretextError" in k ? v({ name: "error", message: k.pretextError }) : v({ name: "review", result: k });
421
+ } catch (i) {
422
+ if (b.current)
403
423
  return;
404
- b({
424
+ v({
405
425
  name: "error",
406
- message: o instanceof Error ? o.message : "An unexpected error occurred."
426
+ message: i instanceof Error ? i.message : "An unexpected error occurred."
407
427
  });
408
428
  }
409
- }, he = async (r) => {
410
- a.current = !1, b({ name: "processing" }), await fe();
429
+ }, ke = async (n) => {
430
+ b.current = !1, v({ name: "processing" }), await Ne();
411
431
  try {
412
- if (i.prepare && i.convertPrepared) {
413
- const l = await i.prepare(r);
414
- if (Q(l), q("auto"), V(null), I({}), Je(l.analysis)) {
415
- b({ name: "sources", prepared: l });
432
+ if (E.prepare && E.convertPrepared) {
433
+ const a = await E.prepare(n);
434
+ if (se(a), re("auto"), l(null), f({}), ut(a.analysis)) {
435
+ v({ name: "sources", prepared: a });
416
436
  return;
417
437
  }
418
- await fe();
419
- const N = await i.convertPrepared(
420
- l,
421
- R()
438
+ await Ne();
439
+ const k = await E.convertPrepared(
440
+ a,
441
+ ge()
422
442
  );
423
- b(
424
- "pretextError" in N ? { name: "error", message: N.pretextError } : { name: "review", result: N }
443
+ v(
444
+ "pretextError" in k ? { name: "error", message: k.pretextError } : { name: "review", result: k }
425
445
  );
426
446
  return;
427
447
  }
428
- const o = await i.convertFile(r, R());
429
- "pretextError" in o ? b({ name: "error", message: o.pretextError }) : b({ name: "review", result: o });
430
- } catch (o) {
431
- if (a.current)
448
+ const i = await E.convertFile(n, ge());
449
+ "pretextError" in i ? v({ name: "error", message: i.pretextError }) : v({ name: "review", result: i });
450
+ } catch (i) {
451
+ if (b.current)
432
452
  return;
433
- b({
453
+ v({
434
454
  name: "error",
435
- message: o instanceof Error ? o.message : "An unexpected error occurred."
455
+ message: i instanceof Error ? i.message : "An unexpected error occurred."
436
456
  });
437
457
  }
438
- }, xe = () => {
439
- b({ name: "upload" }), ne(j), K(!1), Z(/* @__PURE__ */ new Set()), g(/* @__PURE__ */ new Set()), C(null), Q(null);
458
+ }, je = () => {
459
+ v({ name: "upload" }), q(x), ie(!1), G(/* @__PURE__ */ new Set()), ce(/* @__PURE__ */ new Set()), z(null), _(null), ee([]), se(null);
440
460
  };
441
- function be(r, o) {
442
- return [...r].sort((l, N) => l === o ? -1 : N === o ? 1 : l.localeCompare(N));
461
+ function Ee(n, i) {
462
+ return [...n].sort((a, k) => a === i ? -1 : k === i ? 1 : a.localeCompare(k));
443
463
  }
444
- function ge(r, o) {
445
- const l = je(r, o), N = o === "converted" ? r.projectLayout.mainSourcePath : r.sourcePath, c = be(Object.keys(l), N)[0];
446
- Z(c ? /* @__PURE__ */ new Set([c]) : /* @__PURE__ */ new Set());
464
+ function Te(n, i) {
465
+ const a = Pe(n, i), k = i === "converted" ? n.projectLayout.mainSourcePath : n.sourcePath, m = Ee(Object.keys(a), k)[0];
466
+ G(m ? /* @__PURE__ */ new Set([m]) : /* @__PURE__ */ new Set());
447
467
  }
448
- function Pe(r) {
449
- Z((o) => {
450
- const l = new Set(o);
451
- return l.has(r) ? l.delete(r) : l.add(r), l;
468
+ function Xe(n) {
469
+ G((i) => {
470
+ const a = new Set(i);
471
+ return a.has(n) ? a.delete(n) : a.add(n), a;
452
472
  });
453
473
  }
454
- if (v.name === "processing")
474
+ if (y.name === "processing")
455
475
  return /* @__PURE__ */ e.jsx(
456
- qe,
476
+ ct,
457
477
  {
458
- onCancel: i.cancel ? () => me(z) : void 0
478
+ onCancel: E.cancel ? () => $e(J) : void 0
459
479
  }
460
480
  );
461
- if (v.name === "error")
481
+ if (y.name === "error")
462
482
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
463
483
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800", children: [
464
484
  /* @__PURE__ */ e.jsx("p", { className: "font-semibold", children: "Import failed" }),
465
- /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: v.message })
485
+ /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: y.message })
466
486
  ] }),
467
487
  /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ e.jsx(
468
488
  "button",
469
489
  {
470
490
  type: "button",
471
- onClick: xe,
491
+ onClick: je,
472
492
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
473
493
  children: "Try Another File"
474
494
  }
475
495
  ) })
476
496
  ] });
477
- if (v.name === "sources") {
478
- const r = v.prepared, o = H(r), l = o.manifest, N = o.primary?.path ?? "";
497
+ if (y.name === "sources") {
498
+ const n = y.prepared, i = we(n), a = i.manifest, k = i.primary?.path ?? "";
479
499
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
480
500
  /* @__PURE__ */ e.jsxs("div", { children: [
481
501
  /* @__PURE__ */ e.jsx("h3", { className: "text-sm font-semibold text-slate-700", children: "Choose what to import" }),
482
502
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-sm text-slate-500", children: [
483
- r.fileName,
503
+ n.fileName,
484
504
  " contains more than one possible starting point."
485
505
  ] })
486
506
  ] }),
487
- l ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
507
+ a ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
488
508
  /* @__PURE__ */ e.jsxs("p", { className: "font-medium", children: [
489
509
  "Found ",
490
- l.manifestPath,
510
+ a.manifestPath,
491
511
  " — an existing PreTeXt project."
492
512
  ] }),
493
513
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-blue-800", children: [
494
514
  "Its publication file, assets, and directory layout will be kept as they are. Targets:",
495
515
  " ",
496
- l.targets.map((c) => c.name).join(", "),
516
+ a.targets.map((m) => m.name).join(", "),
497
517
  "."
498
518
  ] })
499
519
  ] }) : null,
@@ -502,24 +522,24 @@ function st({
502
522
  /* @__PURE__ */ e.jsxs(
503
523
  "select",
504
524
  {
505
- value: U,
506
- onChange: (c) => {
507
- q(c.currentTarget.value), V(null), I({});
525
+ value: M,
526
+ onChange: (m) => {
527
+ re(m.currentTarget.value), l(null), f({});
508
528
  },
509
529
  className: "rounded border border-slate-300 px-2 py-1 text-sm",
510
530
  children: [
511
531
  /* @__PURE__ */ e.jsxs("option", { value: "auto", children: [
512
532
  "Auto detect",
513
- o.primary ? ` (${we[o.primary.format]})` : ""
533
+ i.primary ? ` (${Ae[i.primary.format]})` : ""
514
534
  ] }),
515
- o.formats.map((c) => /* @__PURE__ */ e.jsx("option", { value: c, children: we[c] }, c))
535
+ i.formats.map((m) => /* @__PURE__ */ e.jsx("option", { value: m, children: Ae[m] }, m))
516
536
  ]
517
537
  }
518
538
  )
519
539
  ] }) }),
520
- o.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
540
+ i.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
521
541
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Main document" }),
522
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: o.candidates.map((c) => /* @__PURE__ */ e.jsxs(
542
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: i.candidates.map((m) => /* @__PURE__ */ e.jsxs(
523
543
  "label",
524
544
  {
525
545
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -529,28 +549,28 @@ function st({
529
549
  {
530
550
  type: "radio",
531
551
  name: "main-file",
532
- value: c.path,
533
- checked: N === c.path,
552
+ value: m.path,
553
+ checked: k === m.path,
534
554
  onChange: () => {
535
- V(c.path), I({});
555
+ l(m.path), f({});
536
556
  },
537
557
  className: "mt-0.5"
538
558
  }
539
559
  ),
540
560
  /* @__PURE__ */ e.jsxs("span", { children: [
541
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: c.path }),
542
- /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: Ge(c) })
561
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: m.path }),
562
+ /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: dt(m) })
543
563
  ] })
544
564
  ]
545
565
  },
546
- c.path
566
+ m.path
547
567
  )) })
548
568
  ] }) : null,
549
- o.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
569
+ i.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
550
570
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Other documents" }),
551
571
  /* @__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." }),
552
- /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: o.extraRoots.map((c) => {
553
- const L = G[c.path], te = L?.include ?? !0;
572
+ /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: i.extraRoots.map((m) => {
573
+ const ne = h[m.path], L = ne?.include ?? !0;
554
574
  return /* @__PURE__ */ e.jsxs(
555
575
  "div",
556
576
  {
@@ -561,20 +581,20 @@ function st({
561
581
  "input",
562
582
  {
563
583
  type: "checkbox",
564
- checked: te,
565
- onChange: (M) => I((Y) => ({
566
- ...Y,
567
- [c.path]: {
568
- ...Y[c.path],
569
- include: M.currentTarget.checked
584
+ checked: L,
585
+ onChange: (W) => f((I) => ({
586
+ ...I,
587
+ [m.path]: {
588
+ ...I[m.path],
589
+ include: W.currentTarget.checked
570
590
  }
571
591
  }))
572
592
  }
573
593
  ),
574
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: c.path }),
575
- c.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
594
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: m.path }),
595
+ m.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
576
596
  "— ",
577
- c.title
597
+ m.title
578
598
  ] }) : null
579
599
  ] }),
580
600
  /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
@@ -582,13 +602,13 @@ function st({
582
602
  /* @__PURE__ */ e.jsxs(
583
603
  "select",
584
604
  {
585
- value: L?.level ?? "auto",
586
- disabled: !te,
587
- onChange: (M) => I((Y) => ({
588
- ...Y,
589
- [c.path]: {
590
- include: Y[c.path]?.include ?? !0,
591
- level: M.currentTarget.value === "auto" ? void 0 : M.currentTarget.value
605
+ value: ne?.level ?? "auto",
606
+ disabled: !L,
607
+ onChange: (W) => f((I) => ({
608
+ ...I,
609
+ [m.path]: {
610
+ include: I[m.path]?.include ?? !0,
611
+ level: W.currentTarget.value === "auto" ? void 0 : W.currentTarget.value
592
612
  }
593
613
  })),
594
614
  className: "rounded border border-slate-300 px-2 py-1 text-sm disabled:opacity-50",
@@ -602,7 +622,7 @@ function st({
602
622
  ] })
603
623
  ]
604
624
  },
605
- c.path
625
+ m.path
606
626
  );
607
627
  }) })
608
628
  ] }) : null,
@@ -611,7 +631,7 @@ function st({
611
631
  "button",
612
632
  {
613
633
  type: "button",
614
- onClick: xe,
634
+ onClick: je,
615
635
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
616
636
  children: "Start Over"
617
637
  }
@@ -620,7 +640,7 @@ function st({
620
640
  "button",
621
641
  {
622
642
  type: "button",
623
- onClick: () => Se(r),
643
+ onClick: () => Me(n),
624
644
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
625
645
  children: "Continue"
626
646
  }
@@ -628,56 +648,63 @@ function st({
628
648
  ] })
629
649
  ] });
630
650
  }
631
- if (v.name === "review") {
632
- let r = function(n) {
633
- ne(n), y?.(n), W && ge(l, n);
634
- }, o = function(n) {
635
- g((T) => {
636
- const oe = new Set(T);
637
- return oe.has(n) ? oe.delete(n) : oe.add(n), oe;
651
+ if (y.name === "review") {
652
+ let n = function(s) {
653
+ q(s), N?.(s), B && Te(a, s);
654
+ }, i = function(s) {
655
+ ce((w) => {
656
+ const Q = new Set(w);
657
+ return Q.has(s) ? Q.delete(s) : Q.add(s), Q;
638
658
  });
639
659
  };
640
- const l = $ ?? v.result, N = l.splitLevel, c = Xe(l), L = ze(l, de), te = l.detectedSourceFormat === "markdown" ? "Markdown" : "LaTeX", M = l.warnings.length, Y = Object.keys(l.outputFiles).length, pe = je(l, L), _e = L === "converted" ? l.projectLayout.mainSourcePath : l.sourcePath, le = be(
641
- Object.keys(pe),
642
- _e
660
+ const a = de ?? y.result, k = a.splitLevel, m = A.length > 0, ne = Se(a) && !m, L = ne ? st(a, fe) : "converted", W = a.detectedSourceFormat === "markdown" ? "Markdown" : "LaTeX", I = a.warnings.length, Ue = Object.keys(a.outputFiles).length, $ = a.insert, ue = a.destination.kind === "insert" ? a.destination.targetTag : void 0, Ye = p?.targetTags ?? [...qe], ve = Pe(a, L), ze = L === "converted" ? a.projectLayout.mainSourcePath : a.sourcePath, me = Ee(
661
+ Object.keys(ve),
662
+ ze
643
663
  );
644
664
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
645
665
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-slate-200 bg-slate-50 p-4", children: [
646
666
  /* @__PURE__ */ e.jsx("h3", { className: "mb-3 text-sm font-semibold text-slate-700", children: "Import Summary" }),
647
667
  /* @__PURE__ */ e.jsxs("dl", { className: "grid grid-cols-2 gap-x-6 gap-y-2 text-sm", children: [
648
668
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Source" }),
649
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: l.sourceName }),
669
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: a.sourceName }),
650
670
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Detected format" }),
651
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: l.detectedSourceFormat }),
671
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: a.detectedSourceFormat }),
652
672
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Document kind" }),
653
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: l.documentKind }),
673
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: a.documentKind }),
654
674
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Output files" }),
655
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: Y }),
656
- l.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
675
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: Ue }),
676
+ p ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
677
+ /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Destination" }),
678
+ /* @__PURE__ */ e.jsxs("dd", { className: "font-medium text-slate-900", children: [
679
+ "Inserted into ",
680
+ p.documentLabel
681
+ ] })
682
+ ] }) : null,
683
+ a.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
657
684
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Existing project" }),
658
685
  /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: "Kept publication file, assets, and layout" })
659
686
  ] }) : null,
660
- l.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
687
+ a.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
661
688
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Attached" }),
662
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: l.attachedRoots.map((n) => `${n.title} (${n.level})`).join(", ") })
689
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: a.attachedRoots.map((s) => `${s.title} (${s.level})`).join(", ") })
663
690
  ] }) : null
664
691
  ] })
665
692
  ] }),
666
- M > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
693
+ I > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
667
694
  /* @__PURE__ */ e.jsxs("summary", { className: "cursor-pointer font-semibold text-amber-800", children: [
668
- M,
695
+ I,
669
696
  " conversion",
670
697
  " ",
671
- M === 1 ? "warning" : "warnings"
698
+ I === 1 ? "warning" : "warnings"
672
699
  ] }),
673
- /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: l.warnings.map((n, T) => /* @__PURE__ */ e.jsxs("li", { children: [
674
- /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: n.macro }),
700
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: a.warnings.map((s, w) => /* @__PURE__ */ e.jsxs("li", { children: [
701
+ /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: s.macro }),
675
702
  " — ",
676
- n.action === "replace" || n.action === "rewrite" ? `replaced with \`${n.replacement}\`` : n.message ?? n.action,
677
- n.occurrences > 1 ? ` (×${n.occurrences})` : null
678
- ] }, T)) })
703
+ s.action === "replace" || s.action === "rewrite" ? `replaced with \`${s.replacement}\`` : s.message ?? s.action,
704
+ s.occurrences > 1 ? ` (×${s.occurrences})` : null
705
+ ] }, w)) })
679
706
  ] }) : /* @__PURE__ */ e.jsx("p", { className: "text-sm text-green-700", children: "No conversion warnings." }),
680
- c && !d ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
707
+ ne && !c ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
681
708
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Import mode" }),
682
709
  /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-col gap-3", children: [
683
710
  /* @__PURE__ */ e.jsxs("label", { className: "flex cursor-pointer items-start gap-3 text-sm", children: [
@@ -688,7 +715,7 @@ function st({
688
715
  name: "import-mode",
689
716
  value: "converted",
690
717
  checked: L === "converted",
691
- onChange: () => r("converted"),
718
+ onChange: () => n("converted"),
692
719
  className: "mt-0.5"
693
720
  }
694
721
  ),
@@ -705,58 +732,123 @@ function st({
705
732
  name: "import-mode",
706
733
  value: "native",
707
734
  checked: L === "native",
708
- onChange: () => r("native"),
735
+ onChange: () => n("native"),
709
736
  className: "mt-0.5"
710
737
  }
711
738
  ),
712
739
  /* @__PURE__ */ e.jsxs("span", { children: [
713
740
  /* @__PURE__ */ e.jsxs("span", { className: "font-medium text-slate-900", children: [
714
741
  "Keep as ",
715
- te
742
+ W
716
743
  ] }),
717
744
  /* @__PURE__ */ e.jsxs("span", { className: "block text-slate-500", children: [
718
745
  "Preserve the original ",
719
- te,
746
+ W,
720
747
  " source. The conversion will not be applied."
721
748
  ] })
722
749
  ] })
723
750
  ] })
724
751
  ] })
725
752
  ] }) : null,
726
- !x && l.cleanChunks.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
753
+ be.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
754
+ /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Divisions to import" }),
755
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2 text-sm", children: [
756
+ /* @__PURE__ */ e.jsx(
757
+ "button",
758
+ {
759
+ type: "button",
760
+ onClick: () => ee([]),
761
+ className: "rounded border border-slate-300 px-3 py-1 text-slate-700 hover:bg-slate-50",
762
+ children: "Everything"
763
+ }
764
+ ),
765
+ /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: A.length === 0 ? "The whole document" : `${A.length} of ${Le(be)} divisions` })
766
+ ] }),
767
+ /* @__PURE__ */ e.jsx("div", { className: "mt-3 max-h-56 overflow-auto", children: /* @__PURE__ */ e.jsx(
768
+ Ie,
769
+ {
770
+ items: be,
771
+ selection: A,
772
+ onToggle: (s) => ee(
773
+ (w) => w.includes(s) ? w.filter((Q) => Q !== s) : [...w, s].sort(mt)
774
+ )
775
+ }
776
+ ) }),
777
+ A.length > 0 ? /* @__PURE__ */ e.jsxs("p", { className: "mt-2 text-sm text-slate-500", children: [
778
+ "A selected division is imported whole, with everything inside it. Divisions above one you selected are kept as structure.",
779
+ Se(y.result) ? " Selecting divisions imports the converted PreTeXt; keeping the original source imports the document whole." : ""
780
+ ] }) : null
781
+ ] }) : null,
782
+ $ && p ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
783
+ /* @__PURE__ */ e.jsxs("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: [
784
+ "Attach to ",
785
+ p.documentLabel
786
+ ] }),
787
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: Ye.map((s) => /* @__PURE__ */ e.jsxs(
788
+ "button",
789
+ {
790
+ type: "button",
791
+ onClick: () => _(s),
792
+ "aria-pressed": ue === s,
793
+ className: ue === s ? "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",
794
+ children: [
795
+ "<",
796
+ s,
797
+ ">"
798
+ ]
799
+ },
800
+ s
801
+ )) }),
802
+ /* @__PURE__ */ e.jsxs("p", { className: "mt-3 text-sm text-slate-600", children: [
803
+ $.includes.length === 1 ? `One <${ue}> is added to ${p.documentLabel}, ` : `${$.includes.length} <${ue}> divisions are added to ${p.documentLabel}, `,
804
+ $.includes.length === 1 ? "included from a new file beside it." : "each included from a new file beside it."
805
+ ] }),
806
+ $.renamed.length > 0 ? /* @__PURE__ */ e.jsxs("p", { className: "mt-2 text-sm text-amber-700", children: [
807
+ $.renamed.length,
808
+ " id",
809
+ $.renamed.length === 1 ? "" : "s",
810
+ " already used in this project",
811
+ " ",
812
+ $.renamed.length === 1 ? "was" : "were",
813
+ " renamed:",
814
+ " ",
815
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs", children: $.renamed.map((s) => `${s.from} → ${s.to}`).join(", ") })
816
+ ] }) : null
817
+ ] }) : null,
818
+ !d && a.cleanChunks.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
727
819
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Split into files" }),
728
820
  /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
729
821
  Array.from(
730
- { length: Fe + 1 },
731
- (n, T) => /* @__PURE__ */ e.jsx(
822
+ { length: Ge + 1 },
823
+ (s, w) => /* @__PURE__ */ e.jsx(
732
824
  "button",
733
825
  {
734
826
  type: "button",
735
- onClick: () => C(T),
736
- "aria-pressed": N === T,
737
- className: N === T ? "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",
738
- children: T === 0 ? "One file" : `${T} level${T === 1 ? "" : "s"}`
827
+ onClick: () => z(w),
828
+ "aria-pressed": k === w,
829
+ className: k === 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",
830
+ children: w === 0 ? "One file" : `${w} level${w === 1 ? "" : "s"}`
739
831
  },
740
- T
832
+ w
741
833
  )
742
834
  ),
743
835
  /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-sm text-slate-500", children: [
744
- le.length,
836
+ me.length,
745
837
  " file",
746
- le.length === 1 ? "" : "s"
838
+ me.length === 1 ? "" : "s"
747
839
  ] })
748
840
  ] }),
749
- /* @__PURE__ */ e.jsx("ul", { className: "mt-3 max-h-48 overflow-auto font-mono text-xs text-slate-600", children: le.map((n) => /* @__PURE__ */ e.jsxs("li", { className: "truncate py-0.5", children: [
750
- n,
751
- m.get(n)?.fixCount ? /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-amber-700", children: [
752
- m.get(n).fixCount,
841
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 max-h-48 overflow-auto font-mono text-xs text-slate-600", children: me.map((s) => /* @__PURE__ */ e.jsxs("li", { className: "truncate py-0.5", children: [
842
+ s,
843
+ U.get(s)?.fixCount ? /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-amber-700", children: [
844
+ U.get(s).fixCount,
753
845
  " change",
754
- m.get(n).fixCount === 1 ? "" : "s"
846
+ U.get(s).fixCount === 1 ? "" : "s"
755
847
  ] }) : null
756
- ] }, n)) })
848
+ ] }, s)) })
757
849
  ] }) : null,
758
- W ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: le.map((n) => {
759
- const T = ue.has(n);
850
+ B ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: me.map((s) => {
851
+ const w = te.has(s);
760
852
  return /* @__PURE__ */ e.jsxs(
761
853
  "div",
762
854
  {
@@ -766,42 +858,42 @@ function st({
766
858
  "button",
767
859
  {
768
860
  type: "button",
769
- onClick: () => Pe(n),
861
+ onClick: () => Xe(s),
770
862
  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",
771
863
  children: [
772
- /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: T ? "▾" : "▸" }),
773
- /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: n }),
864
+ /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: w ? "▾" : "▸" }),
865
+ /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: s }),
774
866
  /* @__PURE__ */ e.jsxs("span", { className: "shrink-0 text-slate-400", children: [
775
- (pe[n].length / 1024).toFixed(1),
867
+ (ve[s].length / 1024).toFixed(1),
776
868
  " KB"
777
869
  ] })
778
870
  ]
779
871
  }
780
872
  ),
781
- T ? /* @__PURE__ */ e.jsxs("div", { className: "bg-white", children: [
782
- m.get(n)?.hunks.length ? /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 border-b border-slate-200 px-4 py-2", children: [
873
+ w ? /* @__PURE__ */ e.jsxs("div", { className: "bg-white", children: [
874
+ U.get(s)?.hunks.length ? /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 border-b border-slate-200 px-4 py-2", children: [
783
875
  /* @__PURE__ */ e.jsx(
784
876
  "button",
785
877
  {
786
878
  type: "button",
787
- onClick: () => o(n),
879
+ onClick: () => i(s),
788
880
  className: "rounded border border-slate-300 px-2 py-0.5 text-xs text-slate-700 hover:bg-slate-50",
789
- children: X.has(n) ? "Show converted file" : "Show what changed"
881
+ children: oe.has(s) ? "Show converted file" : "Show what changed"
790
882
  }
791
883
  ),
792
884
  /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-slate-500", children: [
793
885
  "+",
794
- m.get(n).stats.added,
886
+ U.get(s).stats.added,
795
887
  " −",
796
- m.get(n).stats.removed,
888
+ U.get(s).stats.removed,
797
889
  " in the LaTeX source"
798
890
  ] })
799
891
  ] }) : null,
800
- X.has(n) && m.has(n) ? /* @__PURE__ */ e.jsx(He, { hunks: m.get(n).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: pe[n] })
892
+ oe.has(s) && U.has(s) ? /* @__PURE__ */ e.jsx(xt, { hunks: U.get(s).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: ve[s] })
801
893
  ] }) : null
802
894
  ]
803
895
  },
804
- n
896
+ s
805
897
  );
806
898
  }) }) : null,
807
899
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-3 pt-1", children: [
@@ -809,17 +901,17 @@ function st({
809
901
  "button",
810
902
  {
811
903
  type: "button",
812
- onClick: u ?? xe,
904
+ onClick: o ?? je,
813
905
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
814
- children: u ? "Cancel" : "Start Over"
906
+ children: o ? "Cancel" : "Start Over"
815
907
  }
816
908
  ),
817
909
  /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
818
- z ? /* @__PURE__ */ e.jsx(
910
+ J ? /* @__PURE__ */ e.jsx(
819
911
  "button",
820
912
  {
821
913
  type: "button",
822
- onClick: () => b({ name: "sources", prepared: z }),
914
+ onClick: () => v({ name: "sources", prepared: J }),
823
915
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
824
916
  children: "Change Sources"
825
917
  }
@@ -829,29 +921,29 @@ function st({
829
921
  {
830
922
  type: "button",
831
923
  onClick: () => {
832
- W || ge(l, L), K((n) => !n);
924
+ B || Te(a, L), ie((s) => !s);
833
925
  },
834
926
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
835
- children: W ? "Hide Preview" : "Preview"
927
+ children: B ? "Hide Preview" : "Preview"
836
928
  }
837
929
  ),
838
930
  /* @__PURE__ */ e.jsxs(
839
931
  "button",
840
932
  {
841
933
  type: "button",
842
- disabled: J,
934
+ disabled: X,
843
935
  onClick: async () => {
844
- t(!0);
936
+ H(!0);
845
937
  try {
846
- await s(l, L);
938
+ await r(a, L);
847
939
  } finally {
848
- t(!1);
940
+ H(!1);
849
941
  }
850
942
  },
851
943
  className: "flex items-center gap-2 rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600 disabled:opacity-60",
852
944
  children: [
853
- J ? /* @__PURE__ */ e.jsx("span", { className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-white border-t-transparent" }) : null,
854
- J ? "Importing…" : "Confirm Import"
945
+ X ? /* @__PURE__ */ e.jsx("span", { className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-white border-t-transparent" }) : null,
946
+ X ? p ? "Inserting…" : "Importing…" : p ? "Confirm Insert" : "Confirm Import"
855
947
  ]
856
948
  }
857
949
  )
@@ -860,9 +952,9 @@ function st({
860
952
  ] });
861
953
  }
862
954
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
863
- w.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
955
+ S.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
864
956
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Converter" }),
865
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: w.map((r) => /* @__PURE__ */ e.jsxs(
957
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: S.map((n) => /* @__PURE__ */ e.jsxs(
866
958
  "label",
867
959
  {
868
960
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -872,29 +964,29 @@ function st({
872
964
  {
873
965
  type: "radio",
874
966
  name: "import-engine",
875
- value: r.id,
876
- checked: _ === r.id,
877
- onChange: () => B(r.id),
967
+ value: n.id,
968
+ checked: V === n.id,
969
+ onChange: () => he(n.id),
878
970
  className: "mt-0.5"
879
971
  }
880
972
  ),
881
973
  /* @__PURE__ */ e.jsxs("span", { children: [
882
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: r.label }),
883
- r.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: r.description }) : null
974
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: n.label }),
975
+ n.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: n.description }) : null
884
976
  ] })
885
977
  ]
886
978
  },
887
- r.id
979
+ n.id
888
980
  )) })
889
981
  ] }) : null,
890
- x ? 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: [
982
+ d ? 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: [
891
983
  /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: "Document kind" }),
892
984
  /* @__PURE__ */ e.jsxs(
893
985
  "select",
894
986
  {
895
- value: k,
896
- onChange: (r) => A(
897
- r.currentTarget.value
987
+ value: D,
988
+ onChange: (n) => Y(
989
+ n.currentTarget.value
898
990
  ),
899
991
  className: "rounded border border-slate-300 px-2 py-1 text-sm",
900
992
  children: [
@@ -910,26 +1002,26 @@ function st({
910
1002
  {
911
1003
  role: "button",
912
1004
  tabIndex: 0,
913
- onKeyDown: (r) => r.key === "Enter" && P.current?.click(),
914
- onClick: () => P.current?.click(),
915
- onDragOver: (r) => {
916
- r.preventDefault(), E(!0);
1005
+ onKeyDown: (n) => n.key === "Enter" && T.current?.click(),
1006
+ onClick: () => T.current?.click(),
1007
+ onDragOver: (n) => {
1008
+ n.preventDefault(), P(!0);
917
1009
  },
918
- onDragLeave: () => E(!1),
919
- onDrop: (r) => {
920
- r.preventDefault(), E(!1);
921
- const o = r.dataTransfer.files?.[0];
922
- o && he(o);
1010
+ onDragLeave: () => P(!1),
1011
+ onDrop: (n) => {
1012
+ n.preventDefault(), P(!1);
1013
+ const i = n.dataTransfer.files?.[0];
1014
+ i && ke(i);
923
1015
  },
924
- className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${D ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
1016
+ className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${F ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
925
1017
  children: [
926
1018
  /* @__PURE__ */ e.jsx("p", { className: "text-slate-600", children: "Drop a file here, or click to select." }),
927
1019
  /* @__PURE__ */ e.jsx(
928
1020
  "button",
929
1021
  {
930
1022
  type: "button",
931
- onClick: (r) => {
932
- r.stopPropagation(), P.current?.click();
1023
+ onClick: (n) => {
1024
+ n.stopPropagation(), T.current?.click();
933
1025
  },
934
1026
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
935
1027
  children: "Select File"
@@ -937,18 +1029,18 @@ function st({
937
1029
  ),
938
1030
  /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-slate-400", children: [
939
1031
  "Supports ",
940
- f.join(", ")
1032
+ Z.join(", ")
941
1033
  ] }),
942
1034
  /* @__PURE__ */ e.jsx(
943
1035
  "input",
944
1036
  {
945
- ref: P,
1037
+ ref: T,
946
1038
  type: "file",
947
1039
  hidden: !0,
948
- accept: f.join(","),
949
- onChange: (r) => {
950
- const o = r.currentTarget.files?.[0];
951
- o && he(o), r.currentTarget.value = "";
1040
+ accept: Z.join(","),
1041
+ onChange: (n) => {
1042
+ const i = n.currentTarget.files?.[0];
1043
+ i && ke(i), n.currentTarget.value = "";
952
1044
  }
953
1045
  }
954
1046
  )
@@ -957,23 +1049,78 @@ function st({
957
1049
  )
958
1050
  ] });
959
1051
  }
960
- function He({ hunks: s }) {
961
- return s.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: s.map((u, x) => /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-100 last:border-b-0", children: [
962
- x > 0 ? /* @__PURE__ */ e.jsx("div", { className: "bg-slate-50 px-4 py-1 text-slate-400", children: "⋯" }) : null,
963
- u.lines.map((h, j) => /* @__PURE__ */ e.jsxs(
1052
+ function Le(r) {
1053
+ return r.reduce(
1054
+ (o, d) => o + 1 + Le(d.children),
1055
+ 0
1056
+ );
1057
+ }
1058
+ function mt(r, o) {
1059
+ const d = r.split(".").map(Number), u = o.split(".").map(Number);
1060
+ for (let x = 0; x < Math.max(d.length, u.length); x++) {
1061
+ const c = (d[x] ?? -1) - (u[x] ?? -1);
1062
+ if (c !== 0)
1063
+ return c;
1064
+ }
1065
+ return 0;
1066
+ }
1067
+ function Ie({
1068
+ items: r,
1069
+ selection: o,
1070
+ onToggle: d
1071
+ }) {
1072
+ return /* @__PURE__ */ e.jsx("ul", { className: "space-y-0.5 text-sm", children: r.map((u) => {
1073
+ const x = o.includes(u.path), c = o.some(
1074
+ (N) => u.path.startsWith(`${N}.`)
1075
+ );
1076
+ return /* @__PURE__ */ e.jsxs("li", { children: [
1077
+ /* @__PURE__ */ e.jsxs("label", { className: "flex items-baseline gap-2", children: [
1078
+ /* @__PURE__ */ e.jsx(
1079
+ "input",
1080
+ {
1081
+ type: "checkbox",
1082
+ checked: x || c,
1083
+ disabled: c,
1084
+ onChange: () => d(u.path)
1085
+ }
1086
+ ),
1087
+ /* @__PURE__ */ e.jsxs("span", { className: c ? "text-slate-400" : "text-slate-700", children: [
1088
+ u.title || /* @__PURE__ */ e.jsx("em", { children: "Untitled" }),
1089
+ /* @__PURE__ */ e.jsxs("span", { className: "ml-2 font-mono text-xs text-slate-400", children: [
1090
+ "<",
1091
+ u.tag,
1092
+ ">"
1093
+ ] })
1094
+ ] })
1095
+ ] }),
1096
+ u.children.length > 0 ? /* @__PURE__ */ e.jsx("div", { className: "ml-5 border-l border-slate-200 pl-3", children: /* @__PURE__ */ e.jsx(
1097
+ Ie,
1098
+ {
1099
+ items: u.children,
1100
+ selection: o,
1101
+ onToggle: d
1102
+ }
1103
+ ) }) : null
1104
+ ] }, u.path);
1105
+ }) });
1106
+ }
1107
+ function xt({ hunks: r }) {
1108
+ return r.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: r.map((o, d) => /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-100 last:border-b-0", children: [
1109
+ d > 0 ? /* @__PURE__ */ e.jsx("div", { className: "bg-slate-50 px-4 py-1 text-slate-400", children: "⋯" }) : null,
1110
+ o.lines.map((u, x) => /* @__PURE__ */ e.jsxs(
964
1111
  "div",
965
1112
  {
966
- className: h.op === "add" ? "bg-green-50 px-4 text-green-900" : h.op === "remove" ? "bg-red-50 px-4 text-red-900" : "px-4 text-slate-600",
1113
+ className: u.op === "add" ? "bg-green-50 px-4 text-green-900" : u.op === "remove" ? "bg-red-50 px-4 text-red-900" : "px-4 text-slate-600",
967
1114
  children: [
968
- /* @__PURE__ */ e.jsx("span", { className: "mr-2 select-none text-slate-400", children: h.op === "add" ? "+" : h.op === "remove" ? "−" : " " }),
969
- h.text || " "
1115
+ /* @__PURE__ */ e.jsx("span", { className: "mr-2 select-none text-slate-400", children: u.op === "add" ? "+" : u.op === "remove" ? "−" : " " }),
1116
+ u.text || " "
970
1117
  ]
971
1118
  },
972
- j
1119
+ x
973
1120
  ))
974
- ] }, x)) });
1121
+ ] }, d)) });
975
1122
  }
976
- const Ze = {
1123
+ const pt = {
977
1124
  title: "Import Source Content",
978
1125
  description: "Paste LaTeX, Markdown, or PreTeXt source to convert into PreTeXt.",
979
1126
  sourceLabel: "Source",
@@ -984,59 +1131,59 @@ const Ze = {
984
1131
  successPrefix: "Ready",
985
1132
  errorPrefix: "Error"
986
1133
  };
987
- function at({
988
- initialSource: s = "",
989
- initialSourceFormat: u,
990
- labels: x,
991
- disabled: h = !1,
992
- onImport: j
1134
+ function vt({
1135
+ initialSource: r = "",
1136
+ initialSourceFormat: o,
1137
+ labels: d,
1138
+ disabled: u = !1,
1139
+ onImport: x
993
1140
  }) {
994
- const d = ae(
995
- () => ({ ...Ze, ...x ?? {} }),
996
- [x]
997
- ), [y, S] = p(s), [w, P] = p(
998
- u ?? "auto"
999
- ), [v, b] = p(
1141
+ const c = K(
1142
+ () => ({ ...pt, ...d ?? {} }),
1143
+ [d]
1144
+ ), [N, C] = g(r), [p, S] = g(
1145
+ o ?? "auto"
1146
+ ), [T, y] = g(
1000
1147
  null
1001
- ), D = ae(
1002
- () => De(y),
1003
- [y]
1004
- ), E = h || !y.trim();
1148
+ ), v = K(
1149
+ () => Ze(N),
1150
+ [N]
1151
+ ), F = u || !N.trim();
1005
1152
  return /* @__PURE__ */ e.jsx(
1006
1153
  "form",
1007
1154
  {
1008
- onSubmit: (k) => {
1009
- k.preventDefault();
1010
- const A = Ie(
1011
- y,
1012
- w === "auto" ? void 0 : w
1155
+ onSubmit: (P) => {
1156
+ P.preventDefault();
1157
+ const D = Qe(
1158
+ N,
1159
+ p === "auto" ? void 0 : p
1013
1160
  );
1014
- b(A), j(A);
1161
+ y(D), x(D);
1015
1162
  },
1016
1163
  "aria-label": "Import source form",
1017
- children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: h, children: [
1018
- /* @__PURE__ */ e.jsx("legend", { children: d.title }),
1019
- /* @__PURE__ */ e.jsx("p", { children: d.description }),
1164
+ children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: u, children: [
1165
+ /* @__PURE__ */ e.jsx("legend", { children: c.title }),
1166
+ /* @__PURE__ */ e.jsx("p", { children: c.description }),
1020
1167
  /* @__PURE__ */ e.jsxs("label", { children: [
1021
- d.sourceLabel,
1168
+ c.sourceLabel,
1022
1169
  /* @__PURE__ */ e.jsx(
1023
1170
  "textarea",
1024
1171
  {
1025
- value: y,
1026
- onChange: (k) => S(k.currentTarget.value),
1027
- placeholder: d.sourcePlaceholder,
1172
+ value: N,
1173
+ onChange: (P) => C(P.currentTarget.value),
1174
+ placeholder: c.sourcePlaceholder,
1028
1175
  rows: 12
1029
1176
  }
1030
1177
  )
1031
1178
  ] }),
1032
1179
  /* @__PURE__ */ e.jsxs("label", { children: [
1033
- d.formatLabel,
1180
+ c.formatLabel,
1034
1181
  /* @__PURE__ */ e.jsxs(
1035
1182
  "select",
1036
1183
  {
1037
- value: w,
1038
- onChange: (k) => P(
1039
- k.currentTarget.value
1184
+ value: p,
1185
+ onChange: (P) => S(
1186
+ P.currentTarget.value
1040
1187
  ),
1041
1188
  children: [
1042
1189
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -1048,26 +1195,26 @@ function at({
1048
1195
  )
1049
1196
  ] }),
1050
1197
  /* @__PURE__ */ e.jsxs("p", { children: [
1051
- d.detectedFormatPrefix,
1198
+ c.detectedFormatPrefix,
1052
1199
  ": ",
1053
- /* @__PURE__ */ e.jsx("strong", { children: D })
1200
+ /* @__PURE__ */ e.jsx("strong", { children: v })
1054
1201
  ] }),
1055
- /* @__PURE__ */ e.jsx("button", { type: "submit", disabled: E, children: d.convertButton }),
1056
- v ? "pretextError" in v ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
1057
- d.errorPrefix,
1202
+ /* @__PURE__ */ e.jsx("button", { type: "submit", disabled: F, children: c.convertButton }),
1203
+ T ? "pretextError" in T ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
1204
+ c.errorPrefix,
1058
1205
  ": ",
1059
- v.pretextError
1206
+ T.pretextError
1060
1207
  ] }) : /* @__PURE__ */ e.jsxs("p", { children: [
1061
- d.successPrefix,
1208
+ c.successPrefix,
1062
1209
  ": ",
1063
- v.pretextSource.length,
1210
+ T.pretextSource.length,
1064
1211
  " characters of PreTeXt generated."
1065
1212
  ] }) : null
1066
1213
  ] })
1067
1214
  }
1068
1215
  );
1069
1216
  }
1070
- const Qe = {
1217
+ const ht = {
1071
1218
  title: "Upload Source File",
1072
1219
  hint: "Supports .tex, .md, .ptx, .xml, .zip, and .tar.gz files.",
1073
1220
  selectButton: "Select File",
@@ -1075,43 +1222,43 @@ const Qe = {
1075
1222
  documentKindLabel: "Document kind",
1076
1223
  splitSectionsLabel: "Split each chapter into sections"
1077
1224
  };
1078
- function nt({
1079
- labels: s,
1080
- disabled: u = !1,
1081
- defaultDocumentKind: x = "auto",
1082
- importOptions: h,
1083
- onImport: j
1225
+ function Nt({
1226
+ labels: r,
1227
+ disabled: o = !1,
1228
+ defaultDocumentKind: d = "auto",
1229
+ importOptions: u,
1230
+ onImport: x
1084
1231
  }) {
1085
- const d = ae(
1086
- () => ({ ...Qe, ...s ?? {} }),
1087
- [s]
1088
- ), y = ie(null), [S, w] = p(!1), [P, v] = p(!1), [b, D] = p(
1232
+ const c = K(
1233
+ () => ({ ...ht, ...r ?? {} }),
1234
+ [r]
1235
+ ), N = pe(null), [C, p] = g(!1), [S, T] = g(!1), [y, v] = g(
1089
1236
  []
1090
- ), [E, k] = p(x), [A, F] = p(!1), C = u || P, X = async (g) => {
1091
- v(!0);
1237
+ ), [F, P] = g(d), [D, Y] = g(!1), R = o || S, z = async (j) => {
1238
+ T(!0);
1092
1239
  try {
1093
- const B = await Ee(g, h ?? {
1094
- documentKind: E === "auto" ? void 0 : E,
1095
- splitSections: A
1240
+ const A = await Fe(j, u ?? {
1241
+ documentKind: F === "auto" ? void 0 : F,
1242
+ splitSections: D
1096
1243
  });
1097
- D(B.statusMessages), j(B);
1244
+ v(A.statusMessages), x(A);
1098
1245
  } finally {
1099
- v(!1);
1246
+ T(!1);
1100
1247
  }
1101
1248
  };
1102
1249
  return /* @__PURE__ */ e.jsxs("section", { "aria-label": "Import upload panel", children: [
1103
- /* @__PURE__ */ e.jsx("h3", { children: d.title }),
1104
- /* @__PURE__ */ e.jsx("p", { children: d.hint }),
1105
- h ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
1250
+ /* @__PURE__ */ e.jsx("h3", { children: c.title }),
1251
+ /* @__PURE__ */ e.jsx("p", { children: c.hint }),
1252
+ u ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
1106
1253
  /* @__PURE__ */ e.jsxs("label", { children: [
1107
- d.documentKindLabel,
1254
+ c.documentKindLabel,
1108
1255
  /* @__PURE__ */ e.jsxs(
1109
1256
  "select",
1110
1257
  {
1111
- value: E,
1112
- disabled: C,
1113
- onChange: (g) => k(
1114
- g.currentTarget.value
1258
+ value: F,
1259
+ disabled: R,
1260
+ onChange: (j) => P(
1261
+ j.currentTarget.value
1115
1262
  ),
1116
1263
  children: [
1117
1264
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -1126,73 +1273,73 @@ function nt({
1126
1273
  "input",
1127
1274
  {
1128
1275
  type: "checkbox",
1129
- checked: A,
1130
- disabled: C,
1131
- onChange: (g) => F(g.currentTarget.checked)
1276
+ checked: D,
1277
+ disabled: R,
1278
+ onChange: (j) => Y(j.currentTarget.checked)
1132
1279
  }
1133
1280
  ),
1134
- d.splitSectionsLabel
1281
+ c.splitSectionsLabel
1135
1282
  ] })
1136
1283
  ] }),
1137
1284
  /* @__PURE__ */ e.jsxs(
1138
1285
  "div",
1139
1286
  {
1140
- onDragOver: (g) => {
1141
- g.preventDefault(), C || w(!0);
1287
+ onDragOver: (j) => {
1288
+ j.preventDefault(), R || p(!0);
1142
1289
  },
1143
- onDragLeave: () => w(!1),
1144
- onDrop: (g) => {
1145
- if (g.preventDefault(), w(!1), C)
1290
+ onDragLeave: () => p(!1),
1291
+ onDrop: (j) => {
1292
+ if (j.preventDefault(), p(!1), R)
1146
1293
  return;
1147
- const _ = g.dataTransfer.files?.[0];
1148
- _ && X(_);
1294
+ const _ = j.dataTransfer.files?.[0];
1295
+ _ && z(_);
1149
1296
  },
1150
1297
  children: [
1151
- /* @__PURE__ */ e.jsx("p", { children: d.dropHint }),
1298
+ /* @__PURE__ */ e.jsx("p", { children: c.dropHint }),
1152
1299
  /* @__PURE__ */ e.jsxs(
1153
1300
  "button",
1154
1301
  {
1155
1302
  type: "button",
1156
- disabled: C,
1157
- onClick: () => y.current?.click(),
1303
+ disabled: R,
1304
+ onClick: () => N.current?.click(),
1158
1305
  className: "inline-flex items-center gap-2",
1159
1306
  children: [
1160
- P ? /* @__PURE__ */ e.jsx(
1307
+ S ? /* @__PURE__ */ e.jsx(
1161
1308
  "span",
1162
1309
  {
1163
1310
  className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent",
1164
1311
  "aria-hidden": "true"
1165
1312
  }
1166
1313
  ) : null,
1167
- P ? "Processing…" : d.selectButton
1314
+ S ? "Processing…" : c.selectButton
1168
1315
  ]
1169
1316
  }
1170
1317
  ),
1171
1318
  /* @__PURE__ */ e.jsx(
1172
1319
  "input",
1173
1320
  {
1174
- ref: y,
1321
+ ref: N,
1175
1322
  type: "file",
1176
1323
  hidden: !0,
1177
- disabled: C,
1324
+ disabled: R,
1178
1325
  accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
1179
- onChange: (g) => {
1180
- const _ = g.currentTarget.files?.[0];
1181
- _ && X(_), g.currentTarget.value = "";
1326
+ onChange: (j) => {
1327
+ const _ = j.currentTarget.files?.[0];
1328
+ _ && z(_), j.currentTarget.value = "";
1182
1329
  }
1183
1330
  }
1184
1331
  )
1185
1332
  ]
1186
1333
  }
1187
1334
  ),
1188
- P ? /* @__PURE__ */ e.jsx("p", { role: "status", "aria-live": "polite", children: "Converting your file — this can take a while for a long document." }) : null,
1189
- b.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: b.map((g, _) => /* @__PURE__ */ e.jsx("li", { children: g.message }, `${g.type}-${_}`)) }) : null,
1190
- S && !C ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1335
+ S ? /* @__PURE__ */ e.jsx("p", { role: "status", "aria-live": "polite", children: "Converting your file — this can take a while for a long document." }) : null,
1336
+ y.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: y.map((j, _) => /* @__PURE__ */ e.jsx("li", { children: j.message }, `${j.type}-${_}`)) }) : null,
1337
+ C && !R ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1191
1338
  ] });
1192
1339
  }
1193
1340
  export {
1194
- at as ImportSourceForm,
1195
- nt as ImportUploadPanel,
1196
- st as ImportWizard,
1197
- qe as ProcessingPanel
1341
+ vt as ImportSourceForm,
1342
+ Nt as ImportUploadPanel,
1343
+ jt as ImportWizard,
1344
+ ct as ProcessingPanel
1198
1345
  };