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