@septkit/ui 0.0.88 → 0.0.90

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