@septkit/ui 0.0.74 → 0.0.76

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 (27) hide show
  1. package/dist/dialecte/composables/use-live-data.js +2 -1
  2. package/dist/dialecte/create-document-store.js +4 -4
  3. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/dialecte-gIPrRzni.js +4415 -0
  4. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/helpers-DVShv41E.js +179 -0
  5. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/helpers.js +3 -0
  6. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/index.js +5 -0
  7. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/project-key-Ch34EtFa.js +1370 -0
  8. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/rolldown-runtime-CYdcPHCu.js +13 -0
  9. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/running-operations-vnijBvn7.js +61 -0
  10. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/same-json-value-C6kUaoyt.js +1543 -0
  11. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/utils-USNkj4sT.js +962 -0
  12. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/utils.js +2 -0
  13. package/dist/external/.pnpm/{@dialecte_scl@0.8.1/node_modules/@dialecte/scl/dist/hooks-C05NpRNi.js → @dialecte_scl@0.11.0_libxml2-wasm@0.7.2_vitest@4.1.10/node_modules/@dialecte/scl/dist/hooks-F61-rgXT.js} +974 -242
  14. package/dist/external/.pnpm/{@dialecte_scl@0.8.1 → @dialecte_scl@0.11.0_libxml2-wasm@0.7.2_vitest@4.1.10}/node_modules/@dialecte/scl/dist/v2019C1/index.js +4 -4
  15. package/dist/merge/check-files/identity-warning.js +1 -1
  16. package/dist/merge/confirm/outcome.js +4 -3
  17. package/dist/merge/match/match.js +6 -7
  18. package/dist/merge/session/merge.service.js +2 -2
  19. package/dist/merge/session/use-merge-session.js +2 -0
  20. package/dist/merge/wording.js +6 -7
  21. package/dist/xpath-input/xpath-input.vue_vue_type_script_setup_true_lang.js +6 -2
  22. package/package.json +3 -3
  23. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/helpers.js +0 -229
  24. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/index.js +0 -3
  25. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/project-sK-5Xc-5.js +0 -7371
  26. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/utils-CTBHUFs9.js +0 -440
  27. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/utils.js +0 -2
@@ -0,0 +1,1370 @@
1
+ import { A as e, B as t, O as n, R as r, S as i, W as a, a as o, f as s, h as c, w as l, y as u } from "./utils-USNkj4sT.js";
2
+ //#region node_modules/.pnpm/@dialecte+core@0.8.0/node_modules/@dialecte/core/dist/project-key-Ch34EtFa.js
3
+ var d = [
4
+ "",
5
+ ".",
6
+ ".."
7
+ ], f = "xel_";
8
+ function p(e) {
9
+ return `${f}${e}`;
10
+ }
11
+ function m(e) {
12
+ let { project: t, dialecteId: n } = e;
13
+ (d.includes(t) || n !== void 0 && d.includes(n)) && a("PROJECT_NAME_INVALID", {
14
+ detail: `A project cannot be named ${JSON.stringify(t)}${n === void 0 ? "" : ` in dialecte ${JSON.stringify(n)}`}: neither its name nor its dialecte's id may be empty, \`.\` or \`..\``,
15
+ meta: {
16
+ project: t,
17
+ ...n !== void 0 && { dialecteId: n }
18
+ }
19
+ });
20
+ }
21
+ var h = {
22
+ bigint: "a BigInt",
23
+ function: "a function",
24
+ symbol: "a symbol"
25
+ }, g = "not well-formed UTF-16 (a lone surrogate)", ee = `text that is ${g}`, te = `a key that is ${g}`;
26
+ function ne(e) {
27
+ let { documentId: t } = e;
28
+ a("STORE_DUPLICATE_ID", {
29
+ detail: `Document "${t}" is already registered`,
30
+ meta: { documentId: t }
31
+ });
32
+ }
33
+ function re(e) {
34
+ let { path: t, reason: n } = e;
35
+ a("DOCUMENT_PATH_INVALID", {
36
+ detail: `The document path ${JSON.stringify(t)} is refused: ${n}`,
37
+ meta: { path: t }
38
+ });
39
+ }
40
+ function ie(e) {
41
+ let { documentId: t, path: n, takenBy: r } = e;
42
+ a("DOCUMENT_PATH_TAKEN", {
43
+ detail: `Document "${t}" cannot take the path "${n}": document "${r}" holds that place`,
44
+ meta: {
45
+ documentId: t,
46
+ path: n,
47
+ takenBy: r
48
+ }
49
+ });
50
+ }
51
+ function ae(e) {
52
+ let { documentId: t, what: n } = e;
53
+ a("DOCUMENT_NOT_REGISTERED", {
54
+ detail: `Cannot write ${n} to document "${t}": it is not registered`,
55
+ meta: { documentId: t }
56
+ });
57
+ }
58
+ function oe(e) {
59
+ let { documentId: t, recordId: n } = e;
60
+ a("STORE_RECORD_NOT_FOUND", {
61
+ detail: `Record "${n}" is not in document "${t}": nothing to update`,
62
+ meta: {
63
+ documentId: t,
64
+ recordId: n
65
+ }
66
+ });
67
+ }
68
+ function se(e) {
69
+ let { documentId: t, held: n, repeated: r, cause: i } = e;
70
+ a("STORE_DUPLICATE_ID", {
71
+ detail: `Document "${t}" refuses ids to create - ${[n.length > 0 ? `already holds: ${_(n).join(", ")}` : void 0, r.length > 0 ? `given twice: ${_(r).join(", ")}` : void 0].filter((e) => e !== void 0).join("; ")}`,
72
+ meta: {
73
+ documentId: t,
74
+ recordIds: _([...n, ...r])
75
+ },
76
+ cause: i
77
+ });
78
+ }
79
+ function _(e) {
80
+ return [...new Set(e)];
81
+ }
82
+ function ce(e) {
83
+ let { storeName: t, connections: n } = e;
84
+ a("PROJECT_OPEN_ELSEWHERE", {
85
+ detail: `Project "${t}" cannot be destroyed while another connection has it open: close that one first`,
86
+ meta: {
87
+ project: t,
88
+ ...n !== void 0 && { connections: n }
89
+ }
90
+ });
91
+ }
92
+ function le(e) {
93
+ let { storeName: t } = e;
94
+ a("STORE_CLOSED", {
95
+ detail: `Store "${t}" is closed: open it again before using it`,
96
+ meta: { storeName: t }
97
+ });
98
+ }
99
+ function ue(e) {
100
+ pe({ walk: function() {
101
+ v({
102
+ value: e.value,
103
+ field: "",
104
+ inArray: !1,
105
+ ancestors: []
106
+ });
107
+ } });
108
+ }
109
+ function de(e) {
110
+ ue({ value: { writeId: e.writeId } });
111
+ }
112
+ function fe(e) {
113
+ return pe({ walk: function() {
114
+ return y({
115
+ value: e.value,
116
+ field: "",
117
+ inArray: !1,
118
+ ancestors: []
119
+ });
120
+ } });
121
+ }
122
+ function pe(e) {
123
+ try {
124
+ return e.walk();
125
+ } catch (e) {
126
+ let t = e instanceof Error ? e : void 0;
127
+ a("STORE_VALUE_NOT_JSON", {
128
+ detail: t?.message ?? String(e),
129
+ cause: t
130
+ });
131
+ }
132
+ }
133
+ function v(e) {
134
+ let t = ge(e);
135
+ if (t === "leaf") return;
136
+ let { ancestors: n } = e;
137
+ if (n.push(e.value), t === "array") {
138
+ let t = e.value, { length: r } = t;
139
+ for (let e = 0; e < r; e++) {
140
+ let r = t[e];
141
+ x({ value: r }) || v({
142
+ value: r,
143
+ field: e,
144
+ inArray: !0,
145
+ ancestors: n
146
+ });
147
+ }
148
+ } else {
149
+ let t = e.value;
150
+ for (let r of Object.keys(t)) {
151
+ r.isWellFormed() || C({
152
+ step: e,
153
+ kind: te
154
+ });
155
+ let i = t[r];
156
+ x({ value: i }) || v({
157
+ value: i,
158
+ field: r,
159
+ inArray: !1,
160
+ ancestors: n
161
+ });
162
+ }
163
+ }
164
+ n.pop();
165
+ }
166
+ function y(e) {
167
+ let t = ge(e);
168
+ if (t === "leaf") return b({ value: e.value });
169
+ let { ancestors: n } = e;
170
+ n.push(e.value);
171
+ let r = t === "array" ? me(e) : he(e);
172
+ return n.pop(), r;
173
+ }
174
+ function me(e) {
175
+ let { ancestors: t } = e, n = e.value, r = [], { length: i } = n;
176
+ for (let e = 0; e < i; e++) {
177
+ let i = n[e];
178
+ r.push(x({ value: i }) ? b({ value: i }) : y({
179
+ value: i,
180
+ field: e,
181
+ inArray: !0,
182
+ ancestors: t
183
+ }));
184
+ }
185
+ return r;
186
+ }
187
+ function he(e) {
188
+ let { ancestors: t } = e, n = e.value, r = {};
189
+ for (let i of Object.keys(n)) {
190
+ i.isWellFormed() || C({
191
+ step: e,
192
+ kind: te
193
+ });
194
+ let a = n[i], o = x({ value: a }) ? b({ value: a }) : y({
195
+ value: a,
196
+ field: i,
197
+ inArray: !1,
198
+ ancestors: t
199
+ });
200
+ o !== void 0 && (i === "__proto__" ? Object.defineProperty(r, i, {
201
+ value: o,
202
+ writable: !0,
203
+ enumerable: !0,
204
+ configurable: !0
205
+ }) : r[i] = o);
206
+ }
207
+ return r;
208
+ }
209
+ function b(e) {
210
+ return e.value === 0 ? 0 : e.value;
211
+ }
212
+ function x(e) {
213
+ let { value: t } = e;
214
+ switch (typeof t) {
215
+ case "string": return t.isWellFormed();
216
+ case "boolean": return !0;
217
+ case "number": return Number.isFinite(t);
218
+ case "object": return t === null;
219
+ default: return !1;
220
+ }
221
+ }
222
+ function ge(e) {
223
+ let { value: t } = e, n = typeof t;
224
+ switch (n) {
225
+ case "string": return t.isWellFormed() ? "leaf" : C({
226
+ step: e,
227
+ kind: ee
228
+ });
229
+ case "boolean": return "leaf";
230
+ case "number": return Number.isFinite(t) ? "leaf" : C({
231
+ step: e,
232
+ kind: String(t)
233
+ });
234
+ case "undefined": return t === void 0 ? e.inArray ? C({
235
+ step: e,
236
+ kind: "undefined in an array"
237
+ }) : "leaf" : S({
238
+ step: e,
239
+ held: t
240
+ });
241
+ case "object": return t === null ? "leaf" : S({
242
+ step: e,
243
+ held: t
244
+ });
245
+ default: return C({
246
+ step: e,
247
+ kind: h[n]
248
+ });
249
+ }
250
+ }
251
+ function S(e) {
252
+ let { step: t, held: n } = e, r = Array.isArray(n), i = Object.getPrototypeOf(n);
253
+ return _e({
254
+ prototype: i,
255
+ name: r ? "Array" : "Object"
256
+ }) || C({
257
+ step: t,
258
+ kind: `an instance of ${n.constructor?.name || "a class"}`
259
+ }), i === null && JSON.isRawJSON?.(n) && C({
260
+ step: t,
261
+ kind: "a raw JSON value"
262
+ }), typeof n.toJSON == "function" && C({
263
+ step: t,
264
+ kind: "a value with toJSON"
265
+ }), t.ancestors.includes(n) && C({
266
+ step: t,
267
+ kind: "a cycle"
268
+ }), t.ancestors.length >= 512 && C({
269
+ step: t,
270
+ kind: "a value nested more than 512 levels deep"
271
+ }), r ? "array" : "object";
272
+ }
273
+ function _e(e) {
274
+ let { prototype: t, name: n } = e;
275
+ if (t === (n === "Array" ? Array.prototype : Object.prototype)) return !0;
276
+ if (t === null) return n === "Object";
277
+ let r = Object.getOwnPropertyDescriptor(t, "constructor")?.value;
278
+ return typeof r == "function" && r.name === n;
279
+ }
280
+ function C(e) {
281
+ let t = String(e.step.field);
282
+ throw TypeError(`${e.kind} is not a JSON value${t ? ` (field "${t}")` : ""}`);
283
+ }
284
+ var w = /* @__PURE__ */ new WeakSet();
285
+ function T(e) {
286
+ let { listener: t, value: n, of: r, call: i } = e;
287
+ if (t) try {
288
+ let e = t(n);
289
+ ye(e) && Promise.resolve(e).catch(function(e) {
290
+ E({
291
+ call: i,
292
+ of: r,
293
+ thrown: e
294
+ });
295
+ });
296
+ } catch (e) {
297
+ E({
298
+ call: i,
299
+ of: r,
300
+ thrown: e
301
+ });
302
+ }
303
+ }
304
+ function ve(e) {
305
+ return `the changes of project "${e.name}"`;
306
+ }
307
+ function E(e) {
308
+ let { call: t } = e;
309
+ if (t !== void 0) {
310
+ if (w.has(t)) return;
311
+ w.add(t);
312
+ }
313
+ console.error(`[dialecte] a listener of ${e.of} threw; what told it goes on:`, e.thrown);
314
+ }
315
+ function ye(e) {
316
+ return typeof e == "object" && !!e && typeof e.then == "function";
317
+ }
318
+ var D = {
319
+ importProgress: "an import's progress",
320
+ exportProgress: "an export's progress",
321
+ commitProgress: "a commit's progress",
322
+ callProgress: "a call's progress",
323
+ engineChanges: "a project engine's changes"
324
+ }, O = Object.freeze({
325
+ start() {},
326
+ stop() {},
327
+ count() {},
328
+ time(e, t) {
329
+ return t();
330
+ },
331
+ profile(e, t) {
332
+ return t();
333
+ },
334
+ report() {
335
+ return {};
336
+ },
337
+ log() {},
338
+ reset() {},
339
+ snapshot() {
340
+ return {
341
+ timeOrigin: performance.timeOrigin,
342
+ spans: [],
343
+ totals: {}
344
+ };
345
+ },
346
+ merge() {}
347
+ }), k = "dialecte::";
348
+ function A({ enabled: e, timeline: t = !0 }) {
349
+ if (!e) return O;
350
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = [], o = 0;
351
+ function s(e) {
352
+ t ? performance.measure(k + e.name, {
353
+ start: e.startTime,
354
+ duration: e.duration
355
+ }) : a.push(e);
356
+ }
357
+ function c() {
358
+ return t ? performance.getEntriesByType("measure").filter((e) => e.name.startsWith(k)).map((e) => ({
359
+ name: e.name.slice(10),
360
+ startTime: e.startTime,
361
+ duration: e.duration
362
+ })) : a;
363
+ }
364
+ function l(e, t, n) {
365
+ let r = i.get(e) ?? i.set(e, {
366
+ calls: 0,
367
+ totalMs: 0
368
+ }).get(e);
369
+ r.calls += t, r.totalMs += n;
370
+ }
371
+ let u = {
372
+ start(e) {
373
+ let r = k + e, i = `${r}:${++o}`;
374
+ t && performance.mark(i), (n.get(r) ?? n.set(r, []).get(r)).push({
375
+ mark: i,
376
+ startTime: performance.now()
377
+ });
378
+ },
379
+ stop(e) {
380
+ let r = k + e, i = n.get(r)?.pop();
381
+ i && (t ? (performance.measure(r, i.mark), performance.clearMarks(i.mark)) : a.push({
382
+ name: e,
383
+ startTime: i.startTime,
384
+ duration: performance.now() - i.startTime
385
+ }));
386
+ },
387
+ count(e) {
388
+ let t = k + e;
389
+ r.set(t, (r.get(t) ?? 0) + 1);
390
+ },
391
+ time(e, t) {
392
+ let n = k + e, r = performance.now();
393
+ try {
394
+ return t();
395
+ } finally {
396
+ l(n, 1, performance.now() - r);
397
+ }
398
+ },
399
+ profile(e, t) {
400
+ return typeof console.profile == "function" ? (console.profile(k + e), Promise.resolve(t()).finally(() => console.profileEnd(k + e))) : t();
401
+ },
402
+ report() {
403
+ let e = {};
404
+ for (let { name: t, duration: n } of c()) {
405
+ let r = e[t] ??= {
406
+ calls: 0,
407
+ totalMs: 0,
408
+ avgMs: 0
409
+ };
410
+ r.calls++, r.totalMs += n, r.avgMs = r.totalMs / r.calls;
411
+ }
412
+ return d(e);
413
+ },
414
+ log() {
415
+ console.table(u.report());
416
+ },
417
+ reset() {
418
+ t && (performance.clearMarks(), performance.clearMeasures()), n.clear(), a.length = 0, r.clear(), i.clear();
419
+ },
420
+ snapshot() {
421
+ return {
422
+ timeOrigin: performance.timeOrigin,
423
+ spans: [...c()],
424
+ totals: d({})
425
+ };
426
+ },
427
+ merge({ report: e, prefix: t }) {
428
+ let n = e.timeOrigin - performance.timeOrigin;
429
+ for (let r of e.spans) s({
430
+ name: `${t}::${r.name}`,
431
+ startTime: Math.max(0, r.startTime + n),
432
+ duration: r.duration
433
+ });
434
+ for (let [n, i] of Object.entries(e.totals)) {
435
+ let e = `${k}${t}::${n}`;
436
+ i.calls > 0 && l(e, i.calls, i.totalMs), i.count !== void 0 && r.set(e, (r.get(e) ?? 0) + i.count);
437
+ }
438
+ }
439
+ };
440
+ function d(e) {
441
+ for (let [t, n] of i) {
442
+ let r = t.slice(10), i = e[r] ??= {
443
+ calls: 0,
444
+ totalMs: 0,
445
+ avgMs: 0
446
+ };
447
+ i.calls += n.calls, i.totalMs += n.totalMs, i.avgMs = i.calls ? i.totalMs / i.calls : 0;
448
+ }
449
+ for (let [t, n] of r) {
450
+ let r = t.slice(10), i = e[r] ??= {
451
+ calls: 0,
452
+ totalMs: 0,
453
+ avgMs: 0
454
+ };
455
+ i.count = n;
456
+ }
457
+ return e;
458
+ }
459
+ return u;
460
+ }
461
+ function j(e) {
462
+ let { configs: t, defaultConfigKey: n, configKey: r = n } = e, i = t[r];
463
+ return s(i, {
464
+ key: "UNKNOWN_CONFIG_KEY",
465
+ detail: `Unknown configKey: "${r}". Available: ${Object.keys(t).join(", ")}`
466
+ }), {
467
+ configKey: r,
468
+ config: i
469
+ };
470
+ }
471
+ function M() {
472
+ return new Promise(function(e) {
473
+ let t = new MessageChannel();
474
+ t.port1.onmessage = function() {
475
+ t.port1.close(), e();
476
+ }, t.port2.postMessage(null);
477
+ });
478
+ }
479
+ function N(e) {
480
+ let { record: t, config: n } = e;
481
+ return t.tagName === n.rootElementName && t.parent === null;
482
+ }
483
+ var be = "_temp-idb-id", xe = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", Se = " ", Ce = /[&<>"\t\n\r]/, we = /[&<>"\t\n\r]/g, Te = /[&<>]/, Ee = /[&<>]/g, De = /[&<>\r]/, Oe = /[&<>\r]/g, ke = {
484
+ "&": "&amp;",
485
+ "<": "&lt;",
486
+ ">": "&gt;",
487
+ "\"": "&quot;",
488
+ " ": "&#9;",
489
+ "\n": "&#10;",
490
+ "\r": "&#13;"
491
+ }, P = {
492
+ bindings: /* @__PURE__ */ new Map(),
493
+ parent: void 0
494
+ }, Ae = /* @__PURE__ */ new Set();
495
+ function je(e) {
496
+ let { namespaceURI: t, qualifiedName: n, parent: r } = e;
497
+ if (t === null) return {
498
+ namespaceURI: t,
499
+ prefix: null,
500
+ localName: n,
501
+ attributes: [],
502
+ parent: r
503
+ };
504
+ let { prefix: i, localName: a } = Le(n);
505
+ return {
506
+ namespaceURI: t,
507
+ prefix: i,
508
+ localName: a,
509
+ attributes: [],
510
+ parent: r
511
+ };
512
+ }
513
+ function F(e) {
514
+ let { element: t, qualifiedName: n, value: r } = e, i = t.attributes.find((e) => G(e) === n);
515
+ i ? i.value = r : t.attributes.push({
516
+ namespaceURI: null,
517
+ prefix: null,
518
+ localName: n,
519
+ value: r
520
+ });
521
+ }
522
+ function I(e) {
523
+ let { element: t, namespaceURI: n, qualifiedName: r, value: i } = e, { prefix: a, localName: o } = Le(r), s = K({
524
+ element: t,
525
+ namespaceURI: n,
526
+ localName: o
527
+ });
528
+ s ? s.value = i : t.attributes.push({
529
+ namespaceURI: n,
530
+ prefix: a,
531
+ localName: o,
532
+ value: i
533
+ });
534
+ }
535
+ function L(e) {
536
+ let { element: t, qualifiedName: n } = e;
537
+ return t.attributes.some((e) => G(e) === n);
538
+ }
539
+ function R(e) {
540
+ return K(e)?.value ?? null;
541
+ }
542
+ function z(e) {
543
+ return K(e) !== void 0;
544
+ }
545
+ function B(e) {
546
+ let { prefix: t } = e;
547
+ for (let n = e.element; n; n = n.parent) {
548
+ if (n.namespaceURI !== null && n.prefix === t) return n.namespaceURI;
549
+ let e = n.attributes.find((e) => Re({
550
+ attribute: e,
551
+ prefix: t
552
+ }));
553
+ if (e) return e.value || null;
554
+ }
555
+ return null;
556
+ }
557
+ function V(e) {
558
+ let { namespaceURI: t } = e;
559
+ if (!t) return null;
560
+ for (let n = e.element; n; n = n.parent) {
561
+ if (n.namespaceURI === t && n.prefix !== null) return n.prefix;
562
+ let e = n.attributes.find((e) => e.namespaceURI === "http://www.w3.org/2000/xmlns/" && e.prefix === "xmlns" && e.value === t);
563
+ if (e) return e.localName;
564
+ }
565
+ return null;
566
+ }
567
+ function H(e) {
568
+ let { element: t, prefixes: n } = e, r, i = e.scope, a;
569
+ for (let e of t.attributes) {
570
+ let t = ze(e);
571
+ t !== void 0 && q({
572
+ parent: i,
573
+ own: a,
574
+ prefix: t
575
+ }) !== e.value && (a ??= /* @__PURE__ */ new Map(), a.set(t, e.value));
576
+ }
577
+ let o = `<${G(t)}`, s = t.prefix ?? "", c = t.namespaceURI ?? "", l = q({
578
+ parent: i,
579
+ own: a,
580
+ prefix: ""
581
+ });
582
+ (t.namespaceURI !== null || l) && (q({
583
+ parent: i,
584
+ own: a,
585
+ prefix: s
586
+ }) ?? "") !== c && (o += s ? ` xmlns:${s}="${U(c)}"` : ` xmlns="${U(c)}"`, a ??= /* @__PURE__ */ new Map(), a.set(s, c));
587
+ for (let e of t.attributes) {
588
+ let { namespaceURI: t } = e;
589
+ if (t === null || t === "http://www.w3.org/2000/xmlns/" || t === "http://www.w3.org/XML/1998/namespace" || e.prefix === null) {
590
+ o += ` ${G(e)}="${U(e.value)}"`;
591
+ continue;
592
+ }
593
+ let { prefix: s, declare: c } = Me({
594
+ attribute: e,
595
+ parent: i,
596
+ own: a,
597
+ prefixes: n
598
+ });
599
+ c && (o += ` xmlns:${s}="${U(t)}"`, a ??= /* @__PURE__ */ new Map(), a.set(s, t), r ??= /* @__PURE__ */ new Set(), r.add(s)), o += ` ${s}:${e.localName}="${U(e.value)}"`;
600
+ }
601
+ return {
602
+ text: o,
603
+ scope: a ? {
604
+ bindings: a,
605
+ parent: i
606
+ } : i,
607
+ generated: r ?? Ae
608
+ };
609
+ }
610
+ function Me(e) {
611
+ let { attribute: t, parent: n, own: r, prefixes: i } = e, a = t.namespaceURI, o = t.prefix, s = q({
612
+ parent: n,
613
+ own: r,
614
+ prefix: o
615
+ });
616
+ if (s === a) return {
617
+ prefix: o,
618
+ declare: !1
619
+ };
620
+ let c = Ne({
621
+ parent: n,
622
+ own: r,
623
+ namespaceURI: a
624
+ });
625
+ if (c !== void 0) return {
626
+ prefix: c,
627
+ declare: !1
628
+ };
629
+ if (s === void 0) return {
630
+ prefix: o,
631
+ declare: !0
632
+ };
633
+ for (;;) {
634
+ let e = `ns${i.next}`;
635
+ if (i.next++, q({
636
+ parent: n,
637
+ own: r,
638
+ prefix: e
639
+ }) === void 0) return {
640
+ prefix: e,
641
+ declare: !0
642
+ };
643
+ }
644
+ }
645
+ function Ne(e) {
646
+ let { parent: t, own: n, namespaceURI: r } = e, i = /* @__PURE__ */ new Set(), a = [n, ...Pe(t)];
647
+ for (let e of a) if (e) {
648
+ for (let [t, n] of [...e].reverse()) if (!i.has(t) && (i.add(t), t && n === r)) return t;
649
+ }
650
+ }
651
+ function Pe(e) {
652
+ let t = [];
653
+ for (let n = e; n; n = n.parent) t.push(n.bindings);
654
+ return t;
655
+ }
656
+ function U(e) {
657
+ return Ce.test(e) ? e.replace(we, W) : e;
658
+ }
659
+ function Fe(e) {
660
+ return De.test(e) ? e.replace(Oe, W) : e;
661
+ }
662
+ function Ie(e) {
663
+ return Te.test(e) ? e.replace(Ee, W) : e;
664
+ }
665
+ function W(e) {
666
+ return ke[e];
667
+ }
668
+ function Le(e) {
669
+ let t = e.indexOf(":");
670
+ return t === -1 ? {
671
+ prefix: null,
672
+ localName: e
673
+ } : {
674
+ prefix: e.slice(0, t),
675
+ localName: e.slice(t + 1)
676
+ };
677
+ }
678
+ function G(e) {
679
+ return e.prefix ? `${e.prefix}:${e.localName}` : e.localName;
680
+ }
681
+ function K(e) {
682
+ let { element: t, namespaceURI: n, localName: r } = e;
683
+ return t.attributes.find((e) => e.namespaceURI === n && e.localName === r);
684
+ }
685
+ function Re(e) {
686
+ let { attribute: t, prefix: n } = e;
687
+ return t.namespaceURI === "http://www.w3.org/2000/xmlns/" ? n === null ? t.prefix === null && t.localName === "xmlns" : t.prefix === "xmlns" && t.localName === n : !1;
688
+ }
689
+ function ze(e) {
690
+ if (e.namespaceURI === "http://www.w3.org/2000/xmlns/") return e.prefix === "xmlns" ? e.localName : "";
691
+ if (e.namespaceURI === null && e.localName === "xmlns") return "";
692
+ }
693
+ function Be(e) {
694
+ let { prefix: t } = e;
695
+ for (let n = e.scope; n; n = n.parent) {
696
+ let e = n.bindings.get(t);
697
+ if (e !== void 0) return e;
698
+ }
699
+ }
700
+ function q(e) {
701
+ let { parent: t, own: n, prefix: r } = e;
702
+ return n?.get(r) ?? Be({
703
+ scope: t,
704
+ prefix: r
705
+ });
706
+ }
707
+ function Ve(e) {
708
+ let { context: t, record: n, parent: r } = e;
709
+ return r === void 0 ? He({
710
+ context: t,
711
+ record: n
712
+ }) : Ue({
713
+ context: t,
714
+ record: n,
715
+ parent: r
716
+ });
717
+ }
718
+ function He(e) {
719
+ let { context: t, record: n } = e, { config: r, declareNamespaces: i, withDatabaseIds: a } = t, o = We({
720
+ context: t,
721
+ record: n,
722
+ parent: void 0
723
+ });
724
+ return t.rootElement = o, i && F({
725
+ element: o,
726
+ qualifiedName: "xmlns",
727
+ value: n.namespace.uri
728
+ }), Ge({
729
+ context: t,
730
+ element: o,
731
+ attributes: n.attributes,
732
+ isRoot: !0
733
+ }), t.documentRoot && qe({
734
+ config: r,
735
+ element: o,
736
+ namespace: n.namespace,
737
+ rootRecord: t.documentRoot
738
+ }), a && F({
739
+ element: o,
740
+ qualifiedName: "_temp-idb-id",
741
+ value: n.id
742
+ }), i && Je({
743
+ context: t,
744
+ element: o,
745
+ record: n
746
+ }), o;
747
+ }
748
+ function Ue(e) {
749
+ let { context: t, record: n, parent: r } = e, { config: i, declareNamespaces: a, withDatabaseIds: o } = t, s = n.namespace.uri === i.namespaces.default.uri, c = We({
750
+ context: t,
751
+ record: n,
752
+ parent: r
753
+ });
754
+ return a && !s && n.namespace.prefix && n.namespace.prefix !== "xmlns" && J({
755
+ context: t,
756
+ namespace: n.namespace
757
+ }), Ge({
758
+ context: t,
759
+ element: c,
760
+ attributes: n.attributes,
761
+ isRoot: !1
762
+ }), a && Ke({
763
+ context: t,
764
+ element: c,
765
+ record: n
766
+ }), o && F({
767
+ element: c,
768
+ qualifiedName: "_temp-idb-id",
769
+ value: n.id
770
+ }), a && Je({
771
+ context: t,
772
+ element: c,
773
+ record: n
774
+ }), c;
775
+ }
776
+ function We(e) {
777
+ let { context: t, record: n, parent: r } = e, i = n.namespace.uri !== t.config.namespaces.default.uri && n.namespace.prefix && n.namespace.prefix !== "xmlns" ? `${n.namespace.prefix}:${n.tagName}` : n.tagName;
778
+ return je({
779
+ namespaceURI: t.declareNamespaces ? n.namespace.uri : null,
780
+ qualifiedName: i,
781
+ parent: r
782
+ });
783
+ }
784
+ function Ge(e) {
785
+ let { context: t, element: n, attributes: r, isRoot: i } = e;
786
+ for (let e of r) {
787
+ if (Ze(e)) continue;
788
+ let r = String(e.value);
789
+ if (!Xe(e) || !e.namespace.prefix) {
790
+ F({
791
+ element: n,
792
+ qualifiedName: e.name,
793
+ value: r
794
+ });
795
+ continue;
796
+ }
797
+ let a = `${e.namespace.prefix}:${u(e.name)}`;
798
+ t.declareNamespaces ? (i || J({
799
+ context: t,
800
+ namespace: e.namespace
801
+ }), I({
802
+ element: n,
803
+ namespaceURI: e.namespace.uri,
804
+ qualifiedName: a,
805
+ value: r
806
+ })) : F({
807
+ element: n,
808
+ qualifiedName: a,
809
+ value: r
810
+ });
811
+ }
812
+ }
813
+ function Ke(e) {
814
+ let { context: t, element: n, record: r } = e, { config: a } = t, o = l({
815
+ dialecteConfig: a,
816
+ record: r
817
+ })?.attributes.details;
818
+ if (o) for (let [e, s] of Object.entries(o)) {
819
+ let o = i({
820
+ dialecteConfig: a,
821
+ record: r,
822
+ attributeName: e,
823
+ defaults: "required"
824
+ });
825
+ if (o === void 0) continue;
826
+ let c = u(e);
827
+ (s.namespace ? z({
828
+ element: n,
829
+ namespaceURI: s.namespace.uri,
830
+ localName: c
831
+ }) : L({
832
+ element: n,
833
+ qualifiedName: c
834
+ })) || (s.namespace && s.namespace.prefix && s.namespace.prefix !== "xmlns" ? (J({
835
+ context: t,
836
+ namespace: s.namespace
837
+ }), I({
838
+ element: n,
839
+ namespaceURI: s.namespace.uri,
840
+ qualifiedName: `${s.namespace.prefix}:${c}`,
841
+ value: o
842
+ })) : F({
843
+ element: n,
844
+ qualifiedName: c,
845
+ value: o
846
+ }));
847
+ }
848
+ }
849
+ function J(e) {
850
+ let { context: t, namespace: n } = e, r = t.rootElement;
851
+ r && n.prefix && n.prefix !== "xmlns" && R({
852
+ element: r,
853
+ namespaceURI: "http://www.w3.org/2000/xmlns/",
854
+ localName: n.prefix
855
+ }) === null && (I({
856
+ element: r,
857
+ namespaceURI: "http://www.w3.org/2000/xmlns/",
858
+ qualifiedName: `xmlns:${n.prefix}`,
859
+ value: n.uri
860
+ }), t.documentRoot && qe({
861
+ config: t.config,
862
+ element: r,
863
+ namespace: n,
864
+ rootRecord: t.documentRoot
865
+ }));
866
+ }
867
+ function qe(e) {
868
+ let { config: t, element: n, namespace: r, rootRecord: a } = e, o = l({
869
+ dialecteConfig: t,
870
+ record: a
871
+ })?.attributes.details ?? {}, s = r.uri === t.namespaces.default.uri;
872
+ for (let [e, c] of Object.entries(o)) {
873
+ let o = i({
874
+ dialecteConfig: t,
875
+ record: a,
876
+ attributeName: e,
877
+ defaults: "required"
878
+ });
879
+ if (o === void 0 || !(s ? !c.namespace : c.namespace?.prefix === r.prefix && c.namespace?.uri === r.uri)) continue;
880
+ let l = u(e);
881
+ (c.namespace ? z({
882
+ element: n,
883
+ namespaceURI: c.namespace.uri,
884
+ localName: l
885
+ }) : L({
886
+ element: n,
887
+ qualifiedName: l
888
+ })) || (c.namespace ? I({
889
+ element: n,
890
+ namespaceURI: c.namespace.uri,
891
+ qualifiedName: `${c.namespace.prefix}:${l}`,
892
+ value: o
893
+ }) : F({
894
+ element: n,
895
+ qualifiedName: l,
896
+ value: o
897
+ }));
898
+ }
899
+ }
900
+ function Je(t) {
901
+ let { context: i, element: a, record: o } = t, { config: s } = i, c = R({
902
+ element: a,
903
+ namespaceURI: r.uri,
904
+ localName: "type"
905
+ });
906
+ if (c === null) return;
907
+ let l = e({
908
+ value: c,
909
+ namespaceOf: n({
910
+ dialecteConfig: s,
911
+ attributes: o.attributes
912
+ })
913
+ });
914
+ if (l === void 0 || l.namespace === "") return;
915
+ let u = c.indexOf(":"), d = u === -1 ? "" : c.slice(0, u), f = Object.values(s.namespaces).some((e) => e.prefix === d && e.uri === l.namespace);
916
+ if (d && f && J({
917
+ context: i,
918
+ namespace: {
919
+ prefix: d,
920
+ uri: l.namespace
921
+ }
922
+ }), B({
923
+ element: a,
924
+ prefix: d || null
925
+ }) === l.namespace) return;
926
+ let p = V({
927
+ element: a,
928
+ namespaceURI: l.namespace
929
+ }), m = p !== null && B({
930
+ element: a,
931
+ prefix: p
932
+ }) === l.namespace ? p : null, h = m ?? Ye({ element: a });
933
+ m === null && I({
934
+ element: a,
935
+ namespaceURI: "http://www.w3.org/2000/xmlns/",
936
+ qualifiedName: `xmlns:${h}`,
937
+ value: l.namespace
938
+ });
939
+ let g = V({
940
+ element: a,
941
+ namespaceURI: r.uri
942
+ }) ?? "xsi";
943
+ I({
944
+ element: a,
945
+ namespaceURI: r.uri,
946
+ qualifiedName: `${g}:type`,
947
+ value: `${h}:${l.local}`
948
+ });
949
+ }
950
+ function Ye(e) {
951
+ let { element: t } = e;
952
+ for (let e = 1;; e++) {
953
+ let n = `ns${e}`;
954
+ if (B({
955
+ element: t,
956
+ prefix: n
957
+ }) === null) return n;
958
+ }
959
+ }
960
+ function Xe(e) {
961
+ return !!e.namespace;
962
+ }
963
+ function Ze(e) {
964
+ return e.name === "xmlns" || e.name.startsWith("xmlns:") ? !0 : e.namespace?.prefix === "xmlns";
965
+ }
966
+ function Qe(e) {
967
+ let t = c.exec(e.text);
968
+ if (t) return `U+${t[0].charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
969
+ }
970
+ function $e(e) {
971
+ let { record: t, withId: n = !1 } = e, r = et({ record: t }) ?? tt({
972
+ record: t,
973
+ withId: n
974
+ });
975
+ if (!r) return;
976
+ let { character: i, attribute: o, part: s } = r;
977
+ a("XML_CHARACTER_NOT_ALLOWED", {
978
+ detail: `${nt({
979
+ place: r,
980
+ element: t.tagName ? `<${t.tagName}> '${t.id}'` : `the record '${t.id}'`
981
+ })} holds ${i}, a character XML does not allow.`,
982
+ ...t.tagName && { ref: {
983
+ tagName: t.tagName,
984
+ id: t.id
985
+ } },
986
+ meta: {
987
+ recordId: t.id,
988
+ ...t.tagName && { tagName: t.tagName },
989
+ ...o && { attribute: o },
990
+ part: s,
991
+ character: i
992
+ }
993
+ });
994
+ }
995
+ function et(e) {
996
+ let { record: t } = e, n = t.value === void 0 ? void 0 : Y({
997
+ text: t.value,
998
+ part: "value"
999
+ });
1000
+ if (n) return n;
1001
+ let r = t.namespace && Y({
1002
+ text: t.namespace.uri,
1003
+ part: "namespace"
1004
+ });
1005
+ if (r) return r;
1006
+ for (let e of t.attributes ?? []) {
1007
+ let t = Y({
1008
+ text: e.value,
1009
+ part: "value",
1010
+ attribute: e.name
1011
+ }) ?? (e.namespace && Y({
1012
+ text: e.namespace.uri,
1013
+ part: "namespace",
1014
+ attribute: e.name
1015
+ }));
1016
+ if (t) return t;
1017
+ }
1018
+ }
1019
+ function tt(e) {
1020
+ let { record: t, withId: n } = e, r = t.tagName === void 0 ? void 0 : Y({
1021
+ text: t.tagName,
1022
+ part: "name"
1023
+ });
1024
+ if (r) return r;
1025
+ let i = t.namespace && Y({
1026
+ text: t.namespace.prefix,
1027
+ part: "prefix"
1028
+ });
1029
+ if (i) return i;
1030
+ for (let e of t.attributes ?? []) {
1031
+ let t = e.namespace && Y({
1032
+ text: e.namespace.prefix,
1033
+ part: "prefix",
1034
+ attribute: e.name
1035
+ }) || Y({
1036
+ text: e.name,
1037
+ part: "name",
1038
+ attribute: e.name
1039
+ });
1040
+ if (t) return t;
1041
+ }
1042
+ return n ? Y({
1043
+ text: t.id,
1044
+ part: "id"
1045
+ }) : void 0;
1046
+ }
1047
+ function nt(e) {
1048
+ let { place: t, element: n } = e, { part: r, attribute: i } = t;
1049
+ return i ? r === "value" ? `The attribute ${i} of ${n}` : r === "name" ? `The name of the attribute ${i} of ${n}` : `The ${r === "prefix" ? "namespace prefix" : "namespace URI"} of the attribute ${i} of ${n}` : r === "name" ? `The tag name of ${n}` : r === "prefix" ? `The namespace prefix of ${n}` : r === "namespace" ? `The namespace URI of ${n}` : r === "id" ? `The id of ${n}` : `The value of ${n}`;
1050
+ }
1051
+ function Y(e) {
1052
+ let { text: t, part: n, attribute: r } = e, i = Qe({ text: t });
1053
+ if (i) return {
1054
+ character: i,
1055
+ part: n,
1056
+ ...r !== void 0 && { attribute: r }
1057
+ };
1058
+ }
1059
+ var rt = class {
1060
+ constructor(e) {
1061
+ this.openElements = [], this.body = [], this.rootBindings = /* @__PURE__ */ new Map(), this.rootScope = {
1062
+ bindings: this.rootBindings,
1063
+ parent: void 0
1064
+ }, this.rootAttributeCount = -1, this.prefixes = { next: 1 }, this.newLines = [];
1065
+ let { config: t, documentRoot: n, declareNamespaces: r = !0, withDatabaseIds: i = !1 } = e;
1066
+ this.context = {
1067
+ config: t,
1068
+ declareNamespaces: r,
1069
+ withDatabaseIds: i,
1070
+ documentRoot: n,
1071
+ rootElement: void 0
1072
+ }, this.indent = e.indent ?? !0, this.includeXmlDeclaration = e.includeXmlDeclaration ?? !0;
1073
+ }
1074
+ openElement(e) {
1075
+ let { record: n } = e;
1076
+ $e({
1077
+ record: n,
1078
+ withId: this.context.withDatabaseIds
1079
+ });
1080
+ let r = this.openElements.at(-1), i = Ve({
1081
+ context: this.context,
1082
+ record: n,
1083
+ parent: r?.element
1084
+ }), a = n.value ? t({ text: n.value }) : "", o = n.children.length > 0, s = r ? r.level + 1 : 0, c = r ? r.inline || r.insideInline : !1, l = {
1085
+ element: i,
1086
+ qualifiedName: G(i),
1087
+ level: s,
1088
+ scope: this.rootScope,
1089
+ empty: !a && !o,
1090
+ inline: !this.indent || c || it({
1091
+ element: i,
1092
+ text: a,
1093
+ hasChildren: o
1094
+ }),
1095
+ insideInline: c
1096
+ };
1097
+ if (r) {
1098
+ this.refreshRootScope();
1099
+ let { text: e, scope: t } = H({
1100
+ element: i,
1101
+ scope: r.scope,
1102
+ prefixes: this.prefixes
1103
+ });
1104
+ l.scope = t, c || this.newLine({ level: s }), this.body.push(e, l.empty ? "/>" : ">");
1105
+ } else this.root = l;
1106
+ this.openElements.push(l), a && this.writeText({
1107
+ text: a,
1108
+ owner: l
1109
+ });
1110
+ }
1111
+ closeElement() {
1112
+ let e = this.openElements.pop();
1113
+ e && !e.empty && (e.inline || this.newLine({ level: e.level }), this.body.push(`</${e.qualifiedName}>`));
1114
+ }
1115
+ take() {
1116
+ let e = this.body.join("");
1117
+ return this.body = [], e;
1118
+ }
1119
+ head() {
1120
+ let e = this.root;
1121
+ if (!e) return "";
1122
+ let { text: t } = H({
1123
+ element: e.element,
1124
+ scope: P,
1125
+ prefixes: { next: 1 }
1126
+ });
1127
+ return (this.includeXmlDeclaration ? xe + (this.indent ? "\r\n" : "") : "") + t + (e.empty ? "/>" : ">");
1128
+ }
1129
+ refreshRootScope() {
1130
+ let e = this.root;
1131
+ if (!e) return;
1132
+ let t = e.element.attributes.length;
1133
+ if (t === this.rootAttributeCount) return;
1134
+ this.rootAttributeCount = t;
1135
+ let { scope: n, generated: r } = H({
1136
+ element: e.element,
1137
+ scope: P,
1138
+ prefixes: { next: 1 }
1139
+ });
1140
+ this.rootBindings.clear();
1141
+ for (let [e, t] of n.bindings) r.has(e) || this.rootBindings.set(e, t);
1142
+ }
1143
+ writeText(e) {
1144
+ let { text: t, owner: n } = e;
1145
+ if (!this.indent) {
1146
+ this.body.push(Fe(t));
1147
+ return;
1148
+ }
1149
+ let r = Ie(t);
1150
+ n.inline || this.newLine({ level: n.level + 1 }), this.body.push(ot(r));
1151
+ }
1152
+ newLine(e) {
1153
+ if (!this.indent) return;
1154
+ let { level: t } = e;
1155
+ this.newLines[t] ??= "\r\n" + Se.repeat(t), this.body.push(this.newLines[t]);
1156
+ }
1157
+ };
1158
+ function it(e) {
1159
+ let { element: t, text: n, hasChildren: r } = e;
1160
+ return at(t) ? !0 : n ? !r || !n.includes("\n") : !1;
1161
+ }
1162
+ function at(e) {
1163
+ return e.attributes.some((e) => e.value === "preserve" && (e.namespaceURI === "http://www.w3.org/XML/1998/namespace" && e.localName === "space" || e.namespaceURI === null && e.localName === "xml:space"));
1164
+ }
1165
+ function ot(e) {
1166
+ return e.includes("\n") ? e.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : e;
1167
+ }
1168
+ async function st(e, t = {}) {
1169
+ let { source: n, runtime: r, documentId: i } = e, o = A({
1170
+ enabled: r.perf ?? !1,
1171
+ timeline: !1
1172
+ });
1173
+ $({
1174
+ signal: t.signal,
1175
+ documentId: i
1176
+ });
1177
+ let s = await lt({
1178
+ source: n,
1179
+ documentId: i
1180
+ }), { config: c } = j({
1181
+ configs: r.configs,
1182
+ defaultConfigKey: r.defaultConfigKey,
1183
+ configKey: s.configKey
1184
+ }), l = ct({ options: e.options });
1185
+ o.start("export");
1186
+ let u;
1187
+ try {
1188
+ let n = await ut({
1189
+ ...e,
1190
+ config: c,
1191
+ control: t,
1192
+ perf: o,
1193
+ batchSize: l
1194
+ });
1195
+ u = n.status === "moved" ? await ut({
1196
+ ...e,
1197
+ config: c,
1198
+ control: t,
1199
+ perf: o,
1200
+ batchSize: l
1201
+ }) : n;
1202
+ } finally {
1203
+ o.stop("export");
1204
+ }
1205
+ return u.status === "moved" && a("EXPORT_CONFLICT", {
1206
+ detail: `Document "${s.name}" changed twice while it was exported: export it again`,
1207
+ meta: { documentId: i }
1208
+ }), {
1209
+ file: u.file,
1210
+ filename: `${s.name}${s.extension}`,
1211
+ ...r.perf && { perf: o.snapshot() }
1212
+ };
1213
+ }
1214
+ function ct(e) {
1215
+ let t = e.options?.batchSize ?? 2e3;
1216
+ return (!Number.isInteger(t) || t < 1) && a("ASSERTION_FAILED", { detail: `An export batch size is a whole number from 1, not ${t}` }), t;
1217
+ }
1218
+ async function lt(e) {
1219
+ let { source: t, documentId: n } = e, r = await t.getDocument(n);
1220
+ return r && r.status === "ready" || Q({ documentId: n }), r;
1221
+ }
1222
+ async function ut(e) {
1223
+ let { source: t, documentId: n, options: r, config: i, control: o, perf: s, batchSize: c } = e, l = await t.getExportVersion({ documentId: n });
1224
+ l === void 0 && Q({ documentId: n });
1225
+ let u = await t.count(n), d = await ft({
1226
+ source: t,
1227
+ documentId: n,
1228
+ config: i
1229
+ });
1230
+ if (!d) {
1231
+ if (await Z({
1232
+ source: t,
1233
+ documentId: n,
1234
+ version: l
1235
+ })) return { status: "moved" };
1236
+ a("EXPORT_ROOT_NOT_FOUND", { detail: `No ${i.rootElementName} root element found in document "${n}"` });
1237
+ }
1238
+ let f = {
1239
+ source: t,
1240
+ documentId: n,
1241
+ version: l,
1242
+ totalRecords: u,
1243
+ control: o,
1244
+ perf: s,
1245
+ writer: new rt({
1246
+ config: i,
1247
+ documentRoot: d,
1248
+ indent: r?.indent,
1249
+ withDatabaseIds: r?.withDatabaseIds
1250
+ }),
1251
+ parts: [],
1252
+ recordsWritten: 0
1253
+ }, p = [dt({
1254
+ pass: f,
1255
+ record: d,
1256
+ config: i
1257
+ })];
1258
+ if (f.recordsWritten % c === 0 && await X(f)) return { status: "moved" };
1259
+ for (; p.length > 0;) {
1260
+ let e = p.at(-1);
1261
+ if (e.next >= e.childRefs.length) {
1262
+ s.time("export::write", () => f.writer.closeElement()), p.pop();
1263
+ continue;
1264
+ }
1265
+ if (e.next >= e.chunkStart + e.chunk.length) {
1266
+ let r = e.childRefs.slice(e.next, e.next + c).map(mt);
1267
+ s.start("export::read");
1268
+ try {
1269
+ e.chunk = await t.getMany(r, n);
1270
+ } finally {
1271
+ s.stop("export::read");
1272
+ }
1273
+ e.chunkStart = e.next;
1274
+ }
1275
+ let r = e.childRefs[e.next], o = e.chunk[e.next - e.chunkStart];
1276
+ if (e.next++, !o) {
1277
+ if (await Z(f)) return { status: "moved" };
1278
+ a("EXPORT_ORPHAN_CHILD_REF", {
1279
+ detail: `Parent '${e.record.tagName}' references non-existent child '${r.tagName}' (id: ${r.id})`,
1280
+ ref: {
1281
+ tagName: e.record.tagName,
1282
+ id: e.record.id
1283
+ }
1284
+ });
1285
+ }
1286
+ if (p.push(dt({
1287
+ pass: f,
1288
+ record: o,
1289
+ config: i
1290
+ })), f.recordsWritten % c === 0 && await X(f)) return { status: "moved" };
1291
+ }
1292
+ if (pt(f), f.recordsWritten % c !== 0 && await X(f)) return { status: "moved" };
1293
+ s.start("export::assemble");
1294
+ try {
1295
+ return {
1296
+ status: "written",
1297
+ file: new Blob([f.writer.head(), ...f.parts], { type: "application/xml" })
1298
+ };
1299
+ } finally {
1300
+ s.stop("export::assemble");
1301
+ }
1302
+ }
1303
+ function dt(e) {
1304
+ let { pass: t, record: n, config: r } = e;
1305
+ return t.perf.time("export::write", () => t.writer.openElement({ record: n })), t.recordsWritten++, {
1306
+ record: n,
1307
+ childRefs: o({
1308
+ parentTagName: n.tagName,
1309
+ children: n.children,
1310
+ childrenConfig: r.children,
1311
+ definition: r.definition
1312
+ }),
1313
+ next: 0,
1314
+ chunk: [],
1315
+ chunkStart: 0
1316
+ };
1317
+ }
1318
+ async function ft(e) {
1319
+ let { source: t, documentId: n, config: r } = e;
1320
+ return (await t.getByTagNameInDocument(r.rootElementName, n)).find((e) => N({
1321
+ record: e,
1322
+ config: r
1323
+ }));
1324
+ }
1325
+ async function X(e) {
1326
+ let { control: t, documentId: n, recordsWritten: r, totalRecords: i } = e;
1327
+ return pt(e), T({
1328
+ listener: t.onProgress,
1329
+ value: {
1330
+ recordsWritten: r,
1331
+ totalRecords: i
1332
+ },
1333
+ of: D.exportProgress,
1334
+ call: t
1335
+ }), $({
1336
+ signal: t.signal,
1337
+ documentId: n
1338
+ }), await M(), Z(e);
1339
+ }
1340
+ function pt(e) {
1341
+ let t = e.writer.take();
1342
+ t && e.parts.push(new Blob([t]));
1343
+ }
1344
+ async function Z(e) {
1345
+ let { source: t, documentId: n, version: r } = e, i = await t.getExportVersion({ documentId: n });
1346
+ return i === void 0 && Q({ documentId: n }), i !== r;
1347
+ }
1348
+ function mt(e) {
1349
+ return e.id;
1350
+ }
1351
+ function Q(e) {
1352
+ let { documentId: t } = e;
1353
+ a("DOCUMENT_NOT_REGISTERED", {
1354
+ detail: `Document "${t}" is not registered, or not ready, in this store`,
1355
+ meta: { documentId: t }
1356
+ });
1357
+ }
1358
+ function $(e) {
1359
+ let { signal: t, documentId: n } = e;
1360
+ t?.aborted && a("EXPORT_ABORTED", {
1361
+ detail: `The export of document "${n}" was aborted`,
1362
+ meta: { documentId: n }
1363
+ });
1364
+ }
1365
+ function ht(e) {
1366
+ let { dialecteId: t, project: n } = e;
1367
+ return `${encodeURIComponent(t)}/${encodeURIComponent(n)}`;
1368
+ }
1369
+ //#endregion
1370
+ export { ce as A, _e as C, re as D, ae as E, p as J, f as K, le as M, g as N, ie as O, m as P, de as S, ne as T, D as _, $ as a, nt as c, be as d, N as f, O as g, A as h, st as i, oe as j, se as k, et as l, j as m, ht as n, rt as o, M as p, $e as s, Qe as u, ve as v, fe as w, ue as x, T as y };