@nouxwell/tabula-vue 0.0.0-stage → 0.5.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/index.js ADDED
@@ -0,0 +1,4848 @@
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, mergeModels as l, nextTick as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderList as _, renderSlot as v, shallowRef as y, toDisplayString as b, toRaw as x, unref as S, useId as C, useModel as w, vModelCheckbox as T, vModelText as ee, watch as E, withDirectives as te, withKeys as D, withModifiers as O } from "vue";
2
+ import { REDO_ORIGIN as k, RowView as A, Selection as j, SheetValidator as M, TabulaError as ne, UNDO_ORIGIN as re, UndoHistory as ie, VALUE_SETTINGS as N, adjustValue as ae, arrangeColumns as oe, autoColumnWidth as se, clampColumnWidth as ce, distinctValues as le, editText as ue, fillValues as de, filterKeys as fe, findCells as P, formatCell as F, formulaParts as pe, hasRange as me, headerDisplayText as he, mapDraft as ge, mergeColumnFormats as _e, parseTsv as ve, readInput as ye, replaceCells as be, resolveColumnSizing as xe, rowOrder as Se, rowStyles as Ce, rowsMatching as we, suggestRenames as Te, summarizeCells as Ee, toTsv as De, valueProblem as Oe, withColumn as ke, withDefaults as Ae } from "@nouxwell/tabula-core";
3
+ // src/address.ts
4
+ function je(e) {
5
+ let t = "";
6
+ for (let n = Math.floor(e) + 1; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
7
+ return t;
8
+ }
9
+ function Me(e) {
10
+ let t = /^\s*([A-Za-z]{1,3})\s*(\d{1,9})\s*$/.exec(e), n = t?.[1], r = t?.[2];
11
+ if (n === void 0 || r === void 0) return null;
12
+ let i = 0;
13
+ for (let e of n.toUpperCase()) i = i * 26 + (e.charCodeAt(0) - 64);
14
+ let a = Number(r);
15
+ return a > 0 ? {
16
+ col: i - 1,
17
+ row: a
18
+ } : null;
19
+ }
20
+ // src/ScrollThumbs.vue?vue&type=script&setup=true&lang.ts
21
+ var I = 2, L = 9, Ne = 24, Pe = /* @__PURE__ */ c({
22
+ __name: "ScrollThumbs",
23
+ props: {
24
+ target: {},
25
+ insetTop: { default: 0 },
26
+ insetLeft: { default: 0 },
27
+ layer: { default: void 0 }
28
+ },
29
+ setup(t) {
30
+ let n = t, a = y(null), o = y(null), s = y(null), c = 0, l = null, u = null, m = null;
31
+ function g(e, t, n, r, i) {
32
+ let a = t - e, o = e - r - 4 - i;
33
+ if (a < 1 || o < Ne) return null;
34
+ let s = Math.max(0, e - r) / Math.max(1, t - r), c = Math.min(o, Math.max(Ne, Math.round(o * s)));
35
+ return {
36
+ start: r + I,
37
+ length: o,
38
+ thumb: c,
39
+ range: a,
40
+ at: n
41
+ };
42
+ }
43
+ let _ = {
44
+ x: null,
45
+ y: null
46
+ };
47
+ function v() {
48
+ c = 0;
49
+ let e = n.target;
50
+ if (!e) {
51
+ a.value = o.value = null, _ = {
52
+ x: null,
53
+ y: null
54
+ };
55
+ return;
56
+ }
57
+ let t = e.scrollWidth - e.clientWidth >= 1, r = e.scrollHeight - e.clientHeight >= 1, i = g(e.clientHeight, e.scrollHeight, e.scrollTop, n.insetTop, t ? L : 0), s = g(e.clientWidth, e.scrollWidth, e.scrollLeft, n.insetLeft, r ? L : 0);
58
+ _ = {
59
+ x: s,
60
+ y: i
61
+ }, a.value = i ? {
62
+ top: `${e.offsetTop + i.start + (i.length - i.thumb) * i.at / i.range}px`,
63
+ left: `${e.offsetLeft + e.clientWidth}px`,
64
+ height: `${i.thumb}px`
65
+ } : null, o.value = s ? {
66
+ top: `${e.offsetTop + e.clientHeight}px`,
67
+ left: `${e.offsetLeft + s.start + (s.length - s.thumb) * s.at / s.range}px`,
68
+ width: `${s.thumb}px`
69
+ } : null;
70
+ }
71
+ function b() {
72
+ c === 0 && (c = requestAnimationFrame(v));
73
+ }
74
+ function x(e) {
75
+ l = new ResizeObserver(b), l.observe(e);
76
+ for (let t of Array.from(e.children)) l.observe(t);
77
+ u = new MutationObserver(b), u.observe(e, {
78
+ childList: !0,
79
+ attributes: !0,
80
+ attributeFilter: ["style", "class"]
81
+ }), e.addEventListener("scroll", b, { passive: !0 });
82
+ }
83
+ function S(e) {
84
+ l?.disconnect(), u?.disconnect(), l = u = null, e?.removeEventListener("scroll", b);
85
+ }
86
+ E(() => n.target, (e, t) => {
87
+ S(t ?? null), e && x(e), b();
88
+ }, { immediate: !0 }), E(() => [n.insetTop, n.insetLeft], b);
89
+ function C(e, t) {
90
+ let r = n.target, i = _[t];
91
+ e.button === 0 && r && i && (e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), m = {
92
+ axis: t,
93
+ from: t === "y" ? e.clientY : e.clientX,
94
+ scroll: t === "y" ? r.scrollTop : r.scrollLeft,
95
+ ratio: i.range / Math.max(1, i.length - i.thumb)
96
+ }, s.value = t);
97
+ }
98
+ function w(e) {
99
+ let t = n.target;
100
+ if (!m || !t) return;
101
+ let r = (m.axis === "y" ? e.clientY : e.clientX) - m.from;
102
+ m.axis === "y" ? t.scrollTop = m.scroll + r * m.ratio : t.scrollLeft = m.scroll + r * m.ratio;
103
+ }
104
+ function T() {
105
+ m = null, s.value = null;
106
+ }
107
+ return p(() => {
108
+ S(n.target), cancelAnimationFrame(c);
109
+ }), (n, c) => (h(), i(e, null, [a.value ? (h(), i("div", {
110
+ key: 0,
111
+ class: d(["tabula-thumb is-vertical", { "is-dragging": s.value === "y" }]),
112
+ style: f([a.value, t.layer === void 0 ? {} : { zIndex: t.layer }]),
113
+ "aria-hidden": "true",
114
+ onPointerdown: c[0] ||= (e) => C(e, "y"),
115
+ onPointermove: w,
116
+ onPointerup: T,
117
+ onPointercancel: T,
118
+ onMousedown: c[1] ||= O(() => {}, ["prevent", "stop"])
119
+ }, null, 38)) : r("", !0), o.value ? (h(), i("div", {
120
+ key: 1,
121
+ class: d(["tabula-thumb is-horizontal", { "is-dragging": s.value === "x" }]),
122
+ style: f([o.value, t.layer === void 0 ? {} : { zIndex: t.layer }]),
123
+ "aria-hidden": "true",
124
+ onPointerdown: c[2] ||= (e) => C(e, "x"),
125
+ onPointermove: w,
126
+ onPointerup: T,
127
+ onPointercancel: T,
128
+ onMousedown: c[3] ||= O(() => {}, ["prevent", "stop"])
129
+ }, null, 38)) : r("", !0)], 64));
130
+ }
131
+ });
132
+ // src/alignment.ts
133
+ function Fe(e) {
134
+ switch (e.type) {
135
+ case "integer":
136
+ case "decimal":
137
+ case "money":
138
+ case "quantity":
139
+ case "percent": return "right";
140
+ case "bool":
141
+ case "date":
142
+ case "datetime": return "center";
143
+ default: return "left";
144
+ }
145
+ }
146
+ // src/messages.ts
147
+ var R = {
148
+ tr: {
149
+ required: () => "Bu alan zorunlu.",
150
+ not_a_number: (e) => `“${e.value}” sayı olarak okunamadı.`,
151
+ not_an_integer: (e) => `“${e.value}” tam sayı değil.`,
152
+ not_a_date: (e) => `“${e.value}” tarih olarak okunamadı. Örnek: ${Je(e.format)}`,
153
+ not_a_boolean: (e) => `“${e.value}” Evet/Hayır değeri değil. Kabul edilenler: ${e.accepted}`,
154
+ not_an_option: (e) => `“${e.value}” listede yok. Seçenekler: ${e.options || "(seçenek yok)"}`,
155
+ not_matched: (e) => `“${e.value}” bir kayıtla eşleşmedi; listeden seçin.`,
156
+ min_value: (e, t) => `En az ${qe(e.min, t)} olmalı.`,
157
+ max_value: (e, t) => `En fazla ${qe(e.max, t)} olabilir.`,
158
+ min_length: (e) => `En az ${e.min} karakter olmalı; ${e.length} karakter.`,
159
+ max_length: (e) => `En fazla ${e.max} karakter olabilir; ${e.length} karakter.`,
160
+ not_unique: (e) => `Bu değer kolonda ${e.count} kez geçiyor; bir kez geçmeli.`,
161
+ formula_error: (e) => `Formül hesaplanamadı: ${e.error}${Xe(e.error, "tr")}`,
162
+ check_filled: (e) => `Bu alan zorunlu${V(e, "tr")}.`,
163
+ check_empty: (e) => `Bu alan boş bırakılmalı${V(e, "tr")}.`,
164
+ check_compare: (e) => `${z.tr[e.op ?? ""]?.(e.operand ?? "") ?? ""}${V(e, "tr")}.`
165
+ },
166
+ en: {
167
+ required: () => "This field is required.",
168
+ not_a_number: (e) => `“${e.value}” could not be read as a number.`,
169
+ not_an_integer: (e) => `“${e.value}” is not a whole number.`,
170
+ not_a_date: (e) => `“${e.value}” could not be read as a date. For example: ${Je(e.format)}`,
171
+ not_a_boolean: (e) => `“${e.value}” is not a Yes/No value. Accepted: ${e.accepted}`,
172
+ not_an_option: (e) => `“${e.value}” is not in the list. Options: ${e.options || "(no options)"}`,
173
+ not_matched: (e) => `“${e.value}” is not matched to a record; pick one from the list.`,
174
+ min_value: (e, t) => `Must be at least ${qe(e.min, t)}.`,
175
+ max_value: (e, t) => `Must be at most ${qe(e.max, t)}.`,
176
+ min_length: (e) => `Must be at least ${e.min} characters; it is ${e.length}.`,
177
+ max_length: (e) => `Must be at most ${e.max} characters; it is ${e.length}.`,
178
+ not_unique: (e) => `This value appears ${e.count} times in the column; it may appear once.`,
179
+ formula_error: (e) => `The formula could not be worked out: ${e.error}${Xe(e.error, "en")}`,
180
+ check_filled: (e) => `This field is required${V(e, "en")}.`,
181
+ check_empty: (e) => `This field must be left empty${V(e, "en")}.`,
182
+ check_compare: (e) => `${z.en[e.op ?? ""]?.(e.operand ?? "") ?? ""}${V(e, "en")}.`
183
+ }
184
+ }, z = {
185
+ tr: {
186
+ "=": (e) => `${e} ile aynı olmalı`,
187
+ "!=": (e) => `${e} ile aynı olamaz`,
188
+ "<": (e) => `${e} değerinden küçük olmalı`,
189
+ "<=": (e) => `${e} değerinden büyük olamaz`,
190
+ ">": (e) => `${e} değerinden büyük olmalı`,
191
+ ">=": (e) => `${e} değerinden küçük olamaz`
192
+ },
193
+ en: {
194
+ "=": (e) => `Must equal ${e}`,
195
+ "!=": (e) => `Cannot equal ${e}`,
196
+ "<": (e) => `Must be less than ${e}`,
197
+ "<=": (e) => `Cannot be greater than ${e}`,
198
+ ">": (e) => `Must be greater than ${e}`,
199
+ ">=": (e) => `Cannot be less than ${e}`
200
+ }
201
+ }, B = {
202
+ "=": "=",
203
+ "!=": "≠",
204
+ "<": "<",
205
+ "<=": "≤",
206
+ ">": ">",
207
+ ">=": "≥"
208
+ };
209
+ function V(e, t) {
210
+ let n = Number(e.when ?? "0"), r = [];
211
+ for (let i = 0; i < n; i++) {
212
+ let n = e[`when${i}Field`] ?? "", a = e[`when${i}Op`] ?? "", o = e[`when${i}Value`] ?? "";
213
+ a === "filled" || a === "empty" ? r.push(`${n} ${t === "tr" ? a === "filled" ? "dolu" : "boş" : `is ${a}`}`) : r.push(`${n} ${B[a] ?? a} ${o}`);
214
+ }
215
+ return r.length === 0 ? "" : t === "tr" ? ` (${r.join(" ve ")} olduğunda)` : ` when ${r.join(" and ")}`;
216
+ }
217
+ var Ie = {
218
+ tr: {
219
+ title: "Sorunlar",
220
+ errors: "hata",
221
+ warnings: "uyarı",
222
+ stale: "yeniden kontrol",
223
+ rows: "satır",
224
+ none: "Sorun yok.",
225
+ previous: "Önceki",
226
+ next: "Sonraki",
227
+ row: "Satır",
228
+ sheet: "Sayfa",
229
+ recheck: "Değişti, yeniden kontrol edilmeli",
230
+ more: "sorun daha",
231
+ onlyIssueRows: "Yalnız sorunlu satırlar",
232
+ refresh: "Yenile",
233
+ refreshHint: "Süzgeci tablonun şimdiki hâline yeniden uygula",
234
+ local: "Tarayıcı",
235
+ server: "Sunucu",
236
+ goToCell: "Hücreye git",
237
+ open: "Sorunları göster",
238
+ close: "Kapat"
239
+ },
240
+ en: {
241
+ title: "Issues",
242
+ errors: "errors",
243
+ warnings: "warnings",
244
+ stale: "to check again",
245
+ rows: "rows",
246
+ none: "No issues.",
247
+ previous: "Previous",
248
+ next: "Next",
249
+ row: "Row",
250
+ sheet: "Sheet",
251
+ recheck: "Changed, to be checked again",
252
+ more: "more issues",
253
+ onlyIssueRows: "Only rows with issues",
254
+ refresh: "Refresh",
255
+ refreshHint: "Apply the filter again to the sheet as it is now",
256
+ local: "Browser",
257
+ server: "Server",
258
+ goToCell: "Go to cell",
259
+ open: "Show issues",
260
+ close: "Close"
261
+ }
262
+ }, H = {
263
+ tr: {
264
+ title: "İşlenecekler",
265
+ create: "yeni kayıt",
266
+ update: "güncelleme",
267
+ unchanged: "değişmeyen",
268
+ unknown: "bilinmeyen",
269
+ warned: "uyarılı",
270
+ createOne: "Yeni kayıt",
271
+ updateOne: "Güncelleme",
272
+ unchangedOne: "Değişmeyen",
273
+ unknownOne: "Bilinmiyor",
274
+ all: "Tümü",
275
+ filterCreate: "Yeni",
276
+ filterUpdate: "Güncelleme",
277
+ filterUnchanged: "Değişmeyen",
278
+ filterUnknown: "Bilinmeyen",
279
+ filterWarned: "Uyarılı",
280
+ filters: "Satırları süz",
281
+ row: "Satır",
282
+ empty: "boş",
283
+ same: "Sunucudaki kayıtla aynı; bir şey değişmeyecek.",
284
+ noChanges: "Sunucu hangi alanların değişeceğini bildirmedi.",
285
+ unknownRow: "Ne olacağı bilinmiyor.",
286
+ noPlan: "Sunucu satırların ne olacağını bildirmedi; yalnız sayıları belli.",
287
+ stale: "Tablo son kontrolden sonra değişti; önizleme eski olabilir.",
288
+ sent: "satır gönderilecek",
289
+ more: "{n} satır daha göster",
290
+ none: "Bu süzgeçte satır yok."
291
+ },
292
+ en: {
293
+ title: "To be processed",
294
+ create: "new",
295
+ update: "updates",
296
+ unchanged: "unchanged",
297
+ unknown: "unknown",
298
+ warned: "with warnings",
299
+ createOne: "New record",
300
+ updateOne: "Update",
301
+ unchangedOne: "Unchanged",
302
+ unknownOne: "Unknown",
303
+ all: "All",
304
+ filterCreate: "New",
305
+ filterUpdate: "Updates",
306
+ filterUnchanged: "Unchanged",
307
+ filterUnknown: "Unknown",
308
+ filterWarned: "Warnings",
309
+ filters: "Filter the rows",
310
+ row: "Row",
311
+ empty: "empty",
312
+ same: "The same as the record on the server; nothing will change.",
313
+ noChanges: "The server did not say which fields will change.",
314
+ unknownRow: "What it will do is not known.",
315
+ noPlan: "The server did not say what the rows will do; only their number is known.",
316
+ stale: "The sheet changed after the last check; the preview may be out of date.",
317
+ sent: "rows to send",
318
+ more: "Show {n} more rows",
319
+ none: "No rows under this filter."
320
+ }
321
+ }, Le = {
322
+ tr: {
323
+ saved: "{date} tarihinde kaydedildi · {rows} satır · şema {from}. sürüm, şimdi {to}. sürüm",
324
+ fromHead: "Taslaktaki alan",
325
+ toHead: "Şimdiki alan",
326
+ drop: "Bırak, değerler silinir",
327
+ otherType: "tür farklı",
328
+ suggested: "Önerilen",
329
+ moves: "{n} değer taşınır",
330
+ losing: "{n} satırdaki değer silinecek",
331
+ noValues: "Değeri yok",
332
+ retyped: "Türü değişti: {from} → {to}",
333
+ unreadable: "{n} değer yeni türde okunamıyor; açılınca işaretlenir",
334
+ added: "Yeni alan",
335
+ addedNote: "boş açılır",
336
+ same: "{n} alan aynı",
337
+ mapped: "{n} alan eşlendi",
338
+ dropped: "{n} alan bırakılıyor",
339
+ string: "Metin",
340
+ integer: "Tam sayı",
341
+ decimal: "Ondalık",
342
+ money: "Para",
343
+ quantity: "Miktar",
344
+ percent: "Yüzde",
345
+ bool: "Evet/Hayır",
346
+ date: "Tarih",
347
+ datetime: "Tarih ve saat",
348
+ options: "Seçenek",
349
+ lookup: "Kayıt"
350
+ },
351
+ en: {
352
+ saved: "Saved {date} · {rows} rows · schema version {from}, now {to}",
353
+ fromHead: "Field in the draft",
354
+ toHead: "Field now",
355
+ drop: "Drop, values are deleted",
356
+ otherType: "other type",
357
+ suggested: "Suggested",
358
+ moves: "{n} values move",
359
+ losing: "Values in {n} rows will be deleted",
360
+ noValues: "No values",
361
+ retyped: "Type changed: {from} → {to}",
362
+ unreadable: "{n} values cannot be read as the new type; they open marked",
363
+ added: "New field",
364
+ addedNote: "opens empty",
365
+ same: "{n} fields unchanged",
366
+ mapped: "{n} fields mapped",
367
+ dropped: "{n} fields dropped",
368
+ string: "Text",
369
+ integer: "Whole number",
370
+ decimal: "Decimal",
371
+ money: "Money",
372
+ quantity: "Quantity",
373
+ percent: "Percent",
374
+ bool: "Yes/no",
375
+ date: "Date",
376
+ datetime: "Date and time",
377
+ options: "Option",
378
+ lookup: "Record"
379
+ }
380
+ }, Re = {
381
+ tr: {
382
+ sheets: "Sayfalar",
383
+ add: "Sayfa ekle",
384
+ menu: "Sayfa seçenekleri",
385
+ rename: "Yeniden adlandır",
386
+ duplicate: "Çoğalt",
387
+ remove: "Sayfayı sil",
388
+ name: "Sayfanın adı",
389
+ errors: "{n} hata",
390
+ done: "İşlendi",
391
+ doubleClick: "çift tık",
392
+ moveLeft: "Sola taşı",
393
+ moveRight: "Sağa taşı"
394
+ },
395
+ en: {
396
+ sheets: "Sheets",
397
+ add: "Add a sheet",
398
+ menu: "Sheet options",
399
+ rename: "Rename",
400
+ duplicate: "Duplicate",
401
+ remove: "Delete sheet",
402
+ name: "Sheet name",
403
+ errors: "{n} errors",
404
+ done: "Processed",
405
+ doubleClick: "double click",
406
+ moveLeft: "Move left",
407
+ moveRight: "Move right"
408
+ }
409
+ }, ze = {
410
+ tr: {
411
+ formulaBar: "Formül çubuğu",
412
+ address: "Hücre adresi",
413
+ addressHint: "Bir adres yazıp Enter'a basın, örneğin D9",
414
+ noAddress: "Böyle bir hücre yok",
415
+ value: "Hücrenin değeri",
416
+ formulaHint: "Formülle hesaplanan sütun: yazılmaz; okuduğu sütunlar tabloda aynı renkte",
417
+ statusBar: "Durum çubuğu",
418
+ rows: "satır",
419
+ issues: "sorun",
420
+ selected: "Seçili",
421
+ sum: "Toplam",
422
+ average: "Ortalama"
423
+ },
424
+ en: {
425
+ formulaBar: "Formula bar",
426
+ address: "Cell address",
427
+ addressHint: "Type an address and press Enter, such as D9",
428
+ noAddress: "There is no such cell",
429
+ value: "The cell's value",
430
+ formulaHint: "A column worked out by its formula: not typed into; the columns it reads are in the same colours",
431
+ statusBar: "Status bar",
432
+ rows: "rows",
433
+ issues: "issues",
434
+ selected: "Selected",
435
+ sum: "Sum",
436
+ average: "Average"
437
+ }
438
+ }, Be = {
439
+ tr: {
440
+ title: "Bul ve değiştir",
441
+ find: "Bul",
442
+ replace: "Değiştir",
443
+ where: "Nerede",
444
+ selection: "Seçimde",
445
+ column: "Sütunda",
446
+ sheet: "Tabloda",
447
+ matchCase: "Büyük ve küçük harf ayrı",
448
+ whole: "Hücrenin tamamı eşleşsin",
449
+ wholeShort: "Tam hücre",
450
+ count: "{current} / {total} hücre",
451
+ none: "Bulunamadı",
452
+ previous: "Önceki",
453
+ next: "Sonraki",
454
+ replaceOne: "Değiştir",
455
+ replaceAll: "Tümünü değiştir",
456
+ close: "Kapat",
457
+ replaced: "{n} hücre değişti",
458
+ skipped: "{n} hücre değiştirilemedi"
459
+ },
460
+ en: {
461
+ title: "Find and replace",
462
+ find: "Find",
463
+ replace: "Replace",
464
+ where: "Where",
465
+ selection: "In the selection",
466
+ column: "In the column",
467
+ sheet: "In the sheet",
468
+ matchCase: "Match case",
469
+ whole: "Match the whole cell",
470
+ wholeShort: "Whole cell",
471
+ count: "{current} of {total} cells",
472
+ none: "Not found",
473
+ previous: "Previous",
474
+ next: "Next",
475
+ replaceOne: "Replace",
476
+ replaceAll: "Replace all",
477
+ close: "Close",
478
+ replaced: "{n} cells replaced",
479
+ skipped: "{n} cells could not be changed"
480
+ }
481
+ }, U = {
482
+ tr: {
483
+ succeeded: "İşlendi",
484
+ failed: "İşlenemedi",
485
+ skipped: "İşlenmedi",
486
+ sending: "Gönderiliyor",
487
+ recheck: "Değişti, yeniden kontrol edilmeli",
488
+ searching: "Aranıyor…",
489
+ none: "Eşleşen kayıt yok",
490
+ more: "Daha fazlası var; aramayı daraltın",
491
+ unavailable: "Arama yapılamadı",
492
+ columnMenu: "Kolon seçenekleri",
493
+ pin: "Sabitle",
494
+ unpin: "Sabitlemeyi kaldır",
495
+ hide: "Gizle",
496
+ showHidden: "Gizli kolonları göster",
497
+ sortAsc: "Artan sırala",
498
+ sortDesc: "Azalan sırala",
499
+ sortClear: "Sıralamayı kaldır",
500
+ filter: "Filtrele…",
501
+ filterClear: "Filtreyi kaldır",
502
+ filterTitle: "Filtre",
503
+ filtered: "Filtre uygulanmış",
504
+ search: "Değerlerde ara",
505
+ selectAll: "Tümünü seç",
506
+ empty: "(Boş)",
507
+ from: "En az",
508
+ to: "En çok",
509
+ apply: "Uygula",
510
+ clear: "Temizle",
511
+ cancel: "Vazgeç",
512
+ moreValues: "değer listede yok; arayarak bulun",
513
+ badBound: "Bu değer okunamadı; sütunun yazdığı gibi yazın.",
514
+ fillHandle: "Doldurmak için sürükleyin; çift tıklayınca yandaki sütun bitene dek aşağı doldurur.",
515
+ picked: "seçili · aramak için yazın",
516
+ pickHint: "Boşluk ya da tık seçer; Enter yazar, Esc vazgeçer.",
517
+ cellMenu: "Hücre menüsü",
518
+ cut: "Kes",
519
+ copy: "Kopyala",
520
+ paste: "Yapıştır",
521
+ clearCells: "İçeriği temizle",
522
+ fillDown: "Aşağı doldur",
523
+ fillRight: "Sağa doldur",
524
+ insertAbove: "Üste satır ekle",
525
+ insertBelow: "Alta satır ekle",
526
+ removeRows: "Satırları sil",
527
+ filterValue: "Bu değere göre süz",
528
+ pasteRefused: "Tarayıcı panoyu okumaya izin vermedi; Ctrl+V ile yapıştırın.",
529
+ totals: "Alttaki satırda ne gösterilsin",
530
+ totalSum: "Toplam",
531
+ totalAverage: "Ortalama",
532
+ totalMin: "En az",
533
+ totalMax: "En çok",
534
+ newRow: "+ Yeni satır: tıklayın, sonra yazın ya da yapıştırın"
535
+ },
536
+ en: {
537
+ cellMenu: "Cell menu",
538
+ cut: "Cut",
539
+ copy: "Copy",
540
+ paste: "Paste",
541
+ clearCells: "Clear contents",
542
+ fillDown: "Fill down",
543
+ fillRight: "Fill right",
544
+ insertAbove: "Insert row above",
545
+ insertBelow: "Insert row below",
546
+ removeRows: "Delete rows",
547
+ filterValue: "Filter by this value",
548
+ pasteRefused: "The browser did not let the clipboard be read; paste with Ctrl+V.",
549
+ totals: "What the row at the bottom shows",
550
+ totalSum: "Sum",
551
+ totalAverage: "Average",
552
+ totalMin: "Smallest",
553
+ totalMax: "Largest",
554
+ newRow: "+ New row: click, then type or paste",
555
+ succeeded: "Processed",
556
+ failed: "Failed",
557
+ skipped: "Not processed",
558
+ sending: "Being sent",
559
+ recheck: "Changed, to be checked again",
560
+ searching: "Searching…",
561
+ none: "No matching records",
562
+ more: "There are more; narrow the search",
563
+ unavailable: "The search could not be made",
564
+ columnMenu: "Column options",
565
+ pin: "Pin",
566
+ unpin: "Unpin",
567
+ hide: "Hide",
568
+ showHidden: "Show hidden columns",
569
+ sortAsc: "Sort ascending",
570
+ sortDesc: "Sort descending",
571
+ sortClear: "Remove sort",
572
+ filter: "Filter…",
573
+ filterClear: "Clear filter",
574
+ filterTitle: "Filter",
575
+ filtered: "Filtered",
576
+ search: "Search the values",
577
+ selectAll: "Select all",
578
+ empty: "(Empty)",
579
+ from: "From",
580
+ to: "To",
581
+ apply: "Apply",
582
+ clear: "Clear",
583
+ cancel: "Cancel",
584
+ moreValues: "more values not listed; search to find them",
585
+ badBound: "This value cannot be read; write it as the column does.",
586
+ fillHandle: "Drag to fill; double-click to fill down as far as the column beside goes.",
587
+ picked: "picked · type to search",
588
+ pickHint: "Space or a click ticks; Enter writes, Esc cancels."
589
+ }
590
+ };
591
+ function Ve(e, t, n) {
592
+ if (e.source !== "local") return e.message;
593
+ let r = e.params[`message.${t}`];
594
+ if (r) return r;
595
+ let i = R[t][e.code];
596
+ return i ? i(e.params, n) : e.message;
597
+ }
598
+ function He(e, t, n, r) {
599
+ let i = (e) => t.has(e) ? t.field(e).label : e, a = (e) => e.other === null ? e.value === null || !t.has(e.field) ? "" : F(t.field(e.field), e.value, r) : i(e.other), o = { when: String(e.when.length) };
600
+ e.when.forEach((e, t) => {
601
+ o[`when${t}Field`] = i(e.field), o[`when${t}Op`] = e.op, o[`when${t}Value`] = a(e);
602
+ });
603
+ let s = i(e.assert.field), c = e.assert.op, l;
604
+ if (c === "filled" || c === "empty") l = n === "tr" ? `${s} ${c === "filled" ? "dolu" : "boş"} olmalı` : `${s} must be ${c === "filled" ? "filled" : "empty"}`;
605
+ else {
606
+ let t = z[n][c]?.(a(e.assert)) ?? "";
607
+ l = n === "tr" ? `${s}, ${t}` : `${s}: ${t.charAt(0).toLowerCase()}${t.slice(1)}`;
608
+ }
609
+ return `${l}${V(o, n)}`;
610
+ }
611
+ var Ue = [
612
+ "sayı1",
613
+ "sayı2",
614
+ "…"
615
+ ], We = [
616
+ "number1",
617
+ "number2",
618
+ "…"
619
+ ], Ge = {
620
+ tr: {
621
+ ABS: {
622
+ params: ["sayı"],
623
+ short: "işaretsiz değer",
624
+ text: "Sayının işaretsiz değeri: -5 için 5."
625
+ },
626
+ AND: {
627
+ params: [
628
+ "koşul1",
629
+ "koşul2",
630
+ "…"
631
+ ],
632
+ short: "hepsi doğruysa",
633
+ text: "Koşulların hepsi doğruysa DOĞRU, biri yanlışsa YANLIŞ."
634
+ },
635
+ AVERAGE: {
636
+ params: Ue,
637
+ short: "ortalama",
638
+ text: "Sayıların ortalaması; boş alanlar sayılmaz."
639
+ },
640
+ CONCAT: {
641
+ params: [
642
+ "metin1",
643
+ "metin2",
644
+ "…"
645
+ ],
646
+ short: "metinleri birleştirir",
647
+ text: "Metinleri art arda ekler."
648
+ },
649
+ IF: {
650
+ params: [
651
+ "koşul",
652
+ "doğruysa",
653
+ "yanlışsa"
654
+ ],
655
+ short: "koşula göre değer",
656
+ text: "Koşul doğruysa ikinci değeri, değilse üçüncüyü verir; yalnız gereken hesaplanır."
657
+ },
658
+ IFERROR: {
659
+ params: ["değer", "hatada"],
660
+ short: "hata yerine değer",
661
+ text: "Değer bir hataysa (#DIV/0! gibi) yerine ikinci değeri verir."
662
+ },
663
+ ISBLANK: {
664
+ params: ["değer"],
665
+ short: "boş mu",
666
+ text: "Değer boşsa DOĞRU."
667
+ },
668
+ LEN: {
669
+ params: ["metin"],
670
+ short: "karakter sayısı",
671
+ text: "Metindeki karakter sayısı."
672
+ },
673
+ MAX: {
674
+ params: Ue,
675
+ short: "en büyük değer",
676
+ text: "En büyük sayı; boş alanlar sayılmaz."
677
+ },
678
+ MIN: {
679
+ params: Ue,
680
+ short: "en küçük değer",
681
+ text: "En küçük sayı; boş alanlar sayılmaz."
682
+ },
683
+ NOT: {
684
+ params: ["koşul"],
685
+ short: "tersi",
686
+ text: "Koşul doğruysa YANLIŞ, yanlışsa DOĞRU."
687
+ },
688
+ OR: {
689
+ params: [
690
+ "koşul1",
691
+ "koşul2",
692
+ "…"
693
+ ],
694
+ short: "biri doğruysa",
695
+ text: "Koşullardan biri doğruysa DOĞRU, hepsi yanlışsa YANLIŞ."
696
+ },
697
+ ROUND: {
698
+ params: ["sayı", "basamak"],
699
+ short: "yuvarlar",
700
+ text: "Sayıyı verilen ondalık basamağa yuvarlar: yarım ve üstü yukarı."
701
+ },
702
+ ROUNDDOWN: {
703
+ params: ["sayı", "basamak"],
704
+ short: "aşağı yuvarlar",
705
+ text: "Sayıyı verilen basamakta sıfıra doğru keser."
706
+ },
707
+ ROUNDUP: {
708
+ params: ["sayı", "basamak"],
709
+ short: "yukarı yuvarlar",
710
+ text: "Sayıyı verilen basamakta sıfırdan uzağa yuvarlar."
711
+ },
712
+ SUM: {
713
+ params: Ue,
714
+ short: "toplam",
715
+ text: "Sayıların toplamı; boş alanlar sayılmaz."
716
+ }
717
+ },
718
+ en: {
719
+ ABS: {
720
+ params: ["number"],
721
+ short: "without its sign",
722
+ text: "The number without its sign: 5 for -5."
723
+ },
724
+ AND: {
725
+ params: [
726
+ "condition1",
727
+ "condition2",
728
+ "…"
729
+ ],
730
+ short: "true if all are",
731
+ text: "TRUE when every condition holds, FALSE when one does not."
732
+ },
733
+ AVERAGE: {
734
+ params: We,
735
+ short: "average",
736
+ text: "The average of the numbers; empty fields are not counted."
737
+ },
738
+ CONCAT: {
739
+ params: [
740
+ "text1",
741
+ "text2",
742
+ "…"
743
+ ],
744
+ short: "joins texts",
745
+ text: "The texts one after another."
746
+ },
747
+ IF: {
748
+ params: [
749
+ "condition",
750
+ "if true",
751
+ "if false"
752
+ ],
753
+ short: "a value by a condition",
754
+ text: "The second value when the condition holds, the third when not; only the one needed is worked out."
755
+ },
756
+ IFERROR: {
757
+ params: ["value", "on error"],
758
+ short: "a value for an error",
759
+ text: "The second value in place of the first when it is an error, such as #DIV/0!."
760
+ },
761
+ ISBLANK: {
762
+ params: ["value"],
763
+ short: "is it empty",
764
+ text: "TRUE when the value is empty."
765
+ },
766
+ LEN: {
767
+ params: ["text"],
768
+ short: "number of characters",
769
+ text: "How many characters the text has."
770
+ },
771
+ MAX: {
772
+ params: We,
773
+ short: "the largest",
774
+ text: "The largest number; empty fields are not counted."
775
+ },
776
+ MIN: {
777
+ params: We,
778
+ short: "the smallest",
779
+ text: "The smallest number; empty fields are not counted."
780
+ },
781
+ NOT: {
782
+ params: ["condition"],
783
+ short: "the opposite",
784
+ text: "FALSE when the condition holds, TRUE when not."
785
+ },
786
+ OR: {
787
+ params: [
788
+ "condition1",
789
+ "condition2",
790
+ "…"
791
+ ],
792
+ short: "true if one is",
793
+ text: "TRUE when a condition holds, FALSE when none does."
794
+ },
795
+ ROUND: {
796
+ params: ["number", "places"],
797
+ short: "rounds",
798
+ text: "The number rounded to the decimal places given: a half and above goes up."
799
+ },
800
+ ROUNDDOWN: {
801
+ params: ["number", "places"],
802
+ short: "rounds down",
803
+ text: "The number cut towards zero at the places given."
804
+ },
805
+ ROUNDUP: {
806
+ params: ["number", "places"],
807
+ short: "rounds up",
808
+ text: "The number rounded away from zero at the places given."
809
+ },
810
+ SUM: {
811
+ params: We,
812
+ short: "sum",
813
+ text: "The sum of the numbers; empty fields are not counted."
814
+ }
815
+ }
816
+ };
817
+ function Ke(e, t) {
818
+ return Ge[t][e.toUpperCase()] ?? null;
819
+ }
820
+ function qe(e, t) {
821
+ return (e ?? "").replace(".", t.decimalSeparator);
822
+ }
823
+ function Je(e) {
824
+ let t = {
825
+ d: "31",
826
+ j: "31",
827
+ m: "12",
828
+ n: "12",
829
+ Y: "2026",
830
+ y: "26",
831
+ H: "13",
832
+ G: "13",
833
+ i: "45",
834
+ s: "00"
835
+ }, n = "", r = e ?? "";
836
+ for (let e = 0; e < r.length; e++) {
837
+ let i = r.charAt(e);
838
+ i === "\\" ? (e++, n += r.charAt(e)) : i !== "!" && i !== "|" && (n += t[i] ?? i);
839
+ }
840
+ return n;
841
+ }
842
+ var Ye = {
843
+ tr: {
844
+ "#DIV/0!": "sıfıra bölme",
845
+ "#VALUE!": "bir değer beklenen türde değil",
846
+ "#NAME?": "bilinmeyen fonksiyon",
847
+ "#NUM!": "sayı olarak hesaplanamıyor"
848
+ },
849
+ en: {
850
+ "#DIV/0!": "a division by zero",
851
+ "#VALUE!": "a value is not of the kind expected",
852
+ "#NAME?": "an unknown function",
853
+ "#NUM!": "not a number that can be worked out"
854
+ }
855
+ };
856
+ function Xe(e, t) {
857
+ let n = Ye[t][e ?? ""];
858
+ return n ? ` (${n})` : "";
859
+ }
860
+ // src/measure.ts
861
+ function Ze(e) {
862
+ let t = getComputedStyle(e), n = document.createElement("canvas").getContext("2d");
863
+ if (!n) {
864
+ let e = Number.parseFloat(t.fontSize) || 13;
865
+ return (t) => t.length * e * .6;
866
+ }
867
+ return n.font = `${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`, (e) => n.measureText(e).width;
868
+ }
869
+ function Qe(e) {
870
+ let t = getComputedStyle(e);
871
+ return (Number.parseFloat(t.paddingLeft) || 0) + (Number.parseFloat(t.paddingRight) || 0);
872
+ }
873
+ // src/TabulaGrid.vue?vue&type=script&setup=true&lang.ts
874
+ var $e = [
875
+ "tabindex",
876
+ "data-tabula-theme",
877
+ "aria-rowcount",
878
+ "aria-colcount",
879
+ "aria-readonly",
880
+ "aria-activedescendant"
881
+ ], et = [
882
+ "aria-colindex",
883
+ "aria-sort",
884
+ "title",
885
+ "onMousedown"
886
+ ], tt = ["textContent"], nt = {
887
+ key: 1,
888
+ class: "tabula-grid-fx",
889
+ "aria-hidden": "true"
890
+ }, rt = { class: "tabula-grid-th-text" }, it = {
891
+ key: 2,
892
+ class: "tabula-grid-required",
893
+ "aria-hidden": "true"
894
+ }, at = {
895
+ key: 3,
896
+ class: "tabula-grid-sort",
897
+ "aria-hidden": "true"
898
+ }, ot = ["aria-label"], st = ["aria-label", "onMousedown"], ct = ["onMousedown", "onDblclick"], lt = [
899
+ "aria-colindex",
900
+ "aria-sort",
901
+ "title",
902
+ "onMousedown"
903
+ ], ut = ["textContent"], dt = {
904
+ key: 1,
905
+ class: "tabula-grid-fx",
906
+ "aria-hidden": "true"
907
+ }, ft = { class: "tabula-grid-th-text" }, pt = {
908
+ key: 2,
909
+ class: "tabula-grid-required",
910
+ "aria-hidden": "true"
911
+ }, mt = {
912
+ key: 3,
913
+ class: "tabula-grid-sort",
914
+ "aria-hidden": "true"
915
+ }, ht = ["aria-label"], gt = ["aria-label", "onMousedown"], _t = ["onMousedown", "onDblclick"], vt = ["title", "onMousedown"], yt = ["data-version"], bt = ["data-row"], xt = [
916
+ "id",
917
+ "aria-colindex",
918
+ "aria-selected",
919
+ "aria-readonly",
920
+ "aria-invalid",
921
+ "title"
922
+ ], St = ["title"], Ct = [
923
+ "aria-rowindex",
924
+ "data-row",
925
+ "aria-owns"
926
+ ], wt = [
927
+ "id",
928
+ "aria-colindex",
929
+ "aria-selected",
930
+ "aria-readonly",
931
+ "aria-invalid",
932
+ "title"
933
+ ], Tt = ["aria-label"], Et = ["textContent"], Dt = ["title"], Ot = [
934
+ "aria-label",
935
+ "role",
936
+ "aria-autocomplete",
937
+ "aria-expanded",
938
+ "aria-controls",
939
+ "aria-activedescendant",
940
+ "placeholder"
941
+ ], kt = [
942
+ "aria-expanded",
943
+ "aria-label",
944
+ "title"
945
+ ], At = ["textContent"], jt = ["aria-label"], Mt = [
946
+ "aria-selected",
947
+ "onMouseenter",
948
+ "onClick"
949
+ ], Nt = ["textContent"], Pt = {
950
+ key: 0,
951
+ class: "tabula-grid-totals-tick",
952
+ viewBox: "0 0 24 24",
953
+ "aria-hidden": "true"
954
+ }, Ft = ["aria-multiselectable"], It = [
955
+ "id",
956
+ "aria-selected",
957
+ "aria-disabled",
958
+ "onMousedown",
959
+ "onMousemove"
960
+ ], Lt = {
961
+ key: 0,
962
+ class: "tabula-grid-option-check",
963
+ "aria-hidden": "true"
964
+ }, Rt = { class: "tabula-grid-option-label" }, zt = {
965
+ key: 1,
966
+ class: "tabula-grid-option-description"
967
+ }, Bt = {
968
+ key: 0,
969
+ class: "tabula-grid-list-note",
970
+ role: "presentation"
971
+ }, Vt = {
972
+ key: 1,
973
+ class: "tabula-grid-list-note",
974
+ role: "presentation"
975
+ }, Ht = ["aria-label"], Ut = ["disabled"], Wt = ["aria-label"], Gt = ["textContent"], Kt = ["textContent"], qt = {
976
+ key: 0,
977
+ class: "tabula-grid-menu-line",
978
+ role: "separator"
979
+ }, Jt = {
980
+ key: 1,
981
+ class: "tabula-grid-menu-item"
982
+ }, Yt = [
983
+ "aria-expanded",
984
+ "data-key",
985
+ "disabled",
986
+ "onClick",
987
+ "onMouseenter"
988
+ ], Xt = ["textContent"], Zt = ["aria-label"], Qt = ["disabled", "onClick"], $t = ["textContent"], en = ["textContent"], tn = [
989
+ "data-key",
990
+ "disabled",
991
+ "onClick"
992
+ ], nn = ["textContent"], rn = ["textContent"], an = ["aria-label"], on = { class: "tabula-grid-filter-title" }, sn = {
993
+ key: 0,
994
+ class: "tabula-grid-filter-range"
995
+ }, cn = {
996
+ key: 1,
997
+ class: "tabula-grid-filter-problem",
998
+ role: "alert"
999
+ }, ln = ["placeholder", "aria-label"], un = { class: "tabula-grid-filter-all" }, dn = ["checked", "indeterminate"], fn = ["checked", "onChange"], pn = { class: "tabula-grid-filter-value" }, mn = { class: "tabula-grid-filter-count" }, hn = {
1000
+ key: 2,
1001
+ class: "tabula-grid-filter-more"
1002
+ }, gn = { class: "tabula-grid-filter-buttons" }, _n = 32, vn = 20, yn = 6, bn = 2, xn = 6, Sn = 5e3, Cn = 10, wn = 22, Tn = 8, En = 150, Dn = "columns", On = 6, kn = /* @__PURE__ */ c({
1003
+ __name: "TabulaGrid",
1004
+ props: /*@__PURE__*/ l({
1005
+ schema: {
1006
+ type: Object,
1007
+ required: !0
1008
+ },
1009
+ store: {
1010
+ type: Object,
1011
+ required: !0
1012
+ },
1013
+ columnSizing: {
1014
+ type: Object,
1015
+ default: void 0
1016
+ },
1017
+ columnOverrides: {
1018
+ type: Object,
1019
+ default: void 0
1020
+ },
1021
+ readonly: {
1022
+ type: Boolean,
1023
+ default: !1
1024
+ },
1025
+ theme: {
1026
+ type: String,
1027
+ default: "light"
1028
+ },
1029
+ valueSettings: {
1030
+ type: Object,
1031
+ default: () => N.tr
1032
+ },
1033
+ rowHeight: {
1034
+ type: Number,
1035
+ default: 30
1036
+ },
1037
+ issues: {
1038
+ type: Object,
1039
+ default: void 0
1040
+ },
1041
+ results: {
1042
+ type: Object,
1043
+ default: void 0
1044
+ },
1045
+ view: {
1046
+ type: Object,
1047
+ default: void 0
1048
+ },
1049
+ lookups: {
1050
+ type: Object,
1051
+ default: void 0
1052
+ },
1053
+ history: {
1054
+ type: Object,
1055
+ default: void 0
1056
+ },
1057
+ changes: {
1058
+ type: Object,
1059
+ default: void 0
1060
+ },
1061
+ columnLetters: {
1062
+ type: Boolean,
1063
+ default: !1
1064
+ },
1065
+ menuItems: {
1066
+ type: Array,
1067
+ default: () => []
1068
+ },
1069
+ locale: {
1070
+ type: String,
1071
+ default: "tr"
1072
+ },
1073
+ marks: {
1074
+ type: Object,
1075
+ default: void 0
1076
+ },
1077
+ found: {
1078
+ type: Object,
1079
+ default: void 0
1080
+ },
1081
+ fit: {
1082
+ type: Boolean,
1083
+ default: !1
1084
+ },
1085
+ totals: {
1086
+ type: Boolean,
1087
+ default: !1
1088
+ },
1089
+ zoom: {
1090
+ type: Number,
1091
+ default: 1
1092
+ },
1093
+ defaultFormats: {
1094
+ type: Object,
1095
+ default: void 0
1096
+ },
1097
+ newRow: {
1098
+ type: Boolean,
1099
+ default: !1
1100
+ }
1101
+ }, {
1102
+ columnWidths: { default: () => ({}) },
1103
+ columnWidthsModifiers: {},
1104
+ columns: { default: () => ({}) },
1105
+ columnsModifiers: {},
1106
+ filters: { default: () => ({}) },
1107
+ filtersModifiers: {},
1108
+ sort: { default: null },
1109
+ sortModifiers: {}
1110
+ }),
1111
+ emits: /*@__PURE__*/ l(["menu", "find"], [
1112
+ "update:columnWidths",
1113
+ "update:columns",
1114
+ "update:filters",
1115
+ "update:sort"
1116
+ ]),
1117
+ setup(c, { expose: l, emit: v }) {
1118
+ let T = c, D = v, N = w(c, "columnWidths"), P = w(c, "columns"), ge = w(c, "filters"), be = w(c, "sort"), Te = {
1119
+ ArrowUp: "up",
1120
+ ArrowDown: "down",
1121
+ ArrowLeft: "left",
1122
+ ArrowRight: "right"
1123
+ }, Oe = {
1124
+ up: {
1125
+ row: -1,
1126
+ col: 0
1127
+ },
1128
+ down: {
1129
+ row: 1,
1130
+ col: 0
1131
+ },
1132
+ left: {
1133
+ row: 0,
1134
+ col: -1
1135
+ },
1136
+ right: {
1137
+ row: 0,
1138
+ col: 1
1139
+ }
1140
+ }, I = y(x(T.store)), L = y(x(T.schema)), Ne = t(() => oe(L.value.fields, P.value)), R = t(() => Ne.value.fields), z = t(() => Ne.value.pinned), B = new j(0, 0), V = y(0), Ie = y(0), H = y(0), Le = C(), Re = g(null), ze = g(null), Be = g(null), He = g(null), Ue = g(null), We = g(null), Ge = g(null), Ke = g(null), qe = g(null), Je = t(() => R.value.map((e) => xe(T.columnSizing, T.columnOverrides?.[e.key]))), Ye = y([]), Xe = y(null), kn = y(0), W = t(() => Math.max(16, Math.round(T.rowHeight * T.zoom))), An = t(() => {
1141
+ let e = R.value.map((e, t) => {
1142
+ let n = Je.value[t] ?? xe();
1143
+ if (Xe.value?.key === e.key) return Xe.value.width;
1144
+ let r = N.value[e.key];
1145
+ return r === void 0 ? Math.max(Ye.value[t] ?? n.minWidth, Math.round(n.minWidth * T.zoom)) : Math.round(ce(r, n) * T.zoom);
1146
+ });
1147
+ return T.fit ? jn(e) : e;
1148
+ });
1149
+ function jn(e) {
1150
+ let t = kn.value - e.reduce((e, t) => e + t, 0) - Cn, n = R.value.flatMap((e, t) => N.value[e.key] === void 0 && Xe.value?.key !== e.key ? [t] : []), r = n.reduce((t, n) => t + (e[n] ?? 0), 0);
1151
+ if (t <= 0 || r <= 0) return e;
1152
+ let i = [...e], a = t;
1153
+ return n.forEach((o, s) => {
1154
+ let c = s === n.length - 1 ? a : Math.floor(t * (e[o] ?? 0) / r);
1155
+ i[o] = (i[o] ?? 0) + c, a -= c;
1156
+ }), i;
1157
+ }
1158
+ let G = t(() => {
1159
+ let e = [0];
1160
+ for (let t of An.value) e.push((e[e.length - 1] ?? 0) + t);
1161
+ return e;
1162
+ }), Mn = t(() => G.value[G.value.length - 1] ?? 0), Nn = t(() => G.value[z.value] ?? 0), Pn = t(() => H.value * W.value), Fn = t(() => T.newRow && !T.readonly && R.value.length > 0 ? W.value : 0), K = t(() => Math.max(44, String(Math.max(H.value, 1)).length * 8 + 20)), In = t(() => An.value.map((e, t) => `left:${G.value[t] ?? 0}px;width:${e}px`)), Ln = t(() => _n + (T.columnLetters ? vn : 0)), Rn = t(() => _e(T.defaultFormats, P.value.formats)), zn = t(() => R.value.map((e) => {
1163
+ let t = Rn.value[e.key]?.align ?? Fe(e), n = t === "left" ? "" : `is-${t}`;
1164
+ return q(e) ? n : `${n} is-readonly`;
1165
+ }));
1166
+ function q(e) {
1167
+ return e !== void 0 && e.editable && !T.readonly;
1168
+ }
1169
+ function Bn(e) {
1170
+ let t = R.value[e];
1171
+ return t?.formula ? `${t.label}\n= ${t.formula}` : t?.label;
1172
+ }
1173
+ function Vn(e) {
1174
+ let t = R.value[e], n = Je.value[e];
1175
+ return t && n ? he(t.label, n.headerDisplayMaxLength) : "";
1176
+ }
1177
+ function Hn(e) {
1178
+ return `left:${(e < z.value ? 0 : K.value) + (G.value[e] ?? 0)}px;width:${An.value[e] ?? 0}px`;
1179
+ }
1180
+ function Un(e) {
1181
+ let t = G.value, n = 0, r = Math.max(0, R.value.length - 1);
1182
+ for (; n < r;) {
1183
+ let i = n + r + 1 >> 1;
1184
+ (t[i] ?? 0) <= e ? n = i : r = i - 1;
1185
+ }
1186
+ return n;
1187
+ }
1188
+ function Wn() {
1189
+ let e = We.value;
1190
+ if (!e) return;
1191
+ let t = Ze(e), n = Qe(e), r = t(" *");
1192
+ Ye.value = R.value.map((e, i) => {
1193
+ let a = Je.value[i] ?? xe(), o = t(Vn(i)) + n + (e.required ? r : 0) + xn;
1194
+ return se(o, a);
1195
+ });
1196
+ }
1197
+ function Gn(e) {
1198
+ let t = R.value[e], n = Je.value[e];
1199
+ if (!t || !n || !We.value || !qe.value) return;
1200
+ let r = Ze(We.value), i = Ze(qe.value), a = Qe(qe.value), o = r(Vn(e)) + Qe(We.value) + (t.required ? r(" *") : 0) + xn, s = $.value, c = Math.max(1, Math.ceil(s.size / Sn));
1201
+ for (let e = 0; e < s.size; e += c) {
1202
+ let n = s.rowIdAt(e), r = n === void 0 ? "" : F(t, I.value.get(n, t.key), T.valueSettings);
1203
+ r !== "" && (o = Math.max(o, i(r) + a));
1204
+ }
1205
+ Kn(t.key, se(o, n));
1206
+ }
1207
+ function Kn(e, t) {
1208
+ let n = Math.round(t / T.zoom);
1209
+ N.value[e] !== n && (N.value = Object.freeze({
1210
+ ...N.value,
1211
+ [e]: n
1212
+ }));
1213
+ }
1214
+ let qn = y(0), Jn = y(-1), Yn = y(0), Xn = y(-1), Zn = y(1), Qn = y(1), $n = t(() => rr(qn.value, Jn.value)), er = t(() => rr(Yn.value, Xn.value)), tr = t(() => rr(0, z.value - 1)), nr = y(0);
1215
+ function rr(e, t) {
1216
+ let n = [];
1217
+ for (let r = e; r <= t; r++) n.push(r);
1218
+ return n;
1219
+ }
1220
+ function ir() {
1221
+ let e = ze.value;
1222
+ return {
1223
+ width: Math.max(0, (e?.clientWidth ?? 0) - K.value),
1224
+ height: Math.max(0, (e?.clientHeight ?? 0) - Ln.value)
1225
+ };
1226
+ }
1227
+ function ar() {
1228
+ let e = ze.value;
1229
+ if (!e) return;
1230
+ let { width: t, height: n } = ir();
1231
+ kn.value = t;
1232
+ let r = H.value, i = R.value.length, a = e.scrollTop, o = e.scrollLeft, s = Math.max(1, Math.min(...An.value, Infinity));
1233
+ Zn.value = Math.ceil(n / W.value) + 12 + 2, Qn.value = Math.max(1, Math.min(i, Math.ceil(t / s) + 4 + 2)), qn.value = Math.max(0, Math.floor(a / W.value) - yn), Jn.value = Math.min(r - 1, Math.floor((a + n) / W.value) + yn);
1234
+ let c = z.value;
1235
+ nr.value = o, Yn.value = i <= c ? c : Math.max(c, Un(o + Nn.value) - bn), Xn.value = i <= c ? c - 1 : Math.min(i - 1, Un(o + t) + bn), Ai.value && Vi();
1236
+ }
1237
+ function or(e = B.head) {
1238
+ let t = ze.value;
1239
+ if (!t || !e) return;
1240
+ let { width: n, height: r } = ir(), i = e.row * W.value, a = G.value[e.col] ?? 0, o = G.value[e.col + 1] ?? a;
1241
+ i < t.scrollTop ? t.scrollTop = i : i + W.value > t.scrollTop + r && (t.scrollTop = i + W.value - r), e.col < z.value || (a < t.scrollLeft + Nn.value ? t.scrollLeft = a - Nn.value : o > t.scrollLeft + n && (t.scrollLeft = Math.min(a - Nn.value, o - n)));
1242
+ }
1243
+ function sr(e, t) {
1244
+ V.value;
1245
+ let n = $.value.rowIdAt(e), r = R.value[t];
1246
+ if (n === void 0 || r === void 0) return "";
1247
+ let i = I.value.get(n, r.key), a = F(r, i, T.valueSettings, { decimals: Rn.value[r.key]?.decimals });
1248
+ return cr(r) && lr(i) > 0 ? `+${a}` : a;
1249
+ }
1250
+ function cr(e) {
1251
+ return "tone" in e && e.tone === "sign";
1252
+ }
1253
+ function lr(e) {
1254
+ return typeof e == "number" ? Math.sign(e) : typeof e != "string" || !/^-?\d+(\.\d+)?$/.test(e) || /^-?0+(\.0+)?$/.test(e) ? 0 : e.startsWith("-") ? -1 : 1;
1255
+ }
1256
+ function ur(e, t) {
1257
+ let n = R.value[t];
1258
+ if (n === void 0 || !cr(n)) return;
1259
+ V.value;
1260
+ let r = $.value.rowIdAt(e), i = r === void 0 ? 0 : lr(I.value.get(r, n.key));
1261
+ return i > 0 ? "is-positive" : i < 0 ? "is-negative" : void 0;
1262
+ }
1263
+ let dr = y(0);
1264
+ E(() => x(T.marks), (e, t, n) => {
1265
+ dr.value++, e && n(e.subscribe(() => dr.value++));
1266
+ }, { immediate: !0 });
1267
+ let fr = /* @__PURE__ */ new Map(), pr = -1;
1268
+ E([L, () => T.valueSettings], () => fr.clear());
1269
+ function mr(e) {
1270
+ let t = L.value.styles;
1271
+ if (t.length === 0) return null;
1272
+ pr !== V.value && (fr.clear(), pr = V.value);
1273
+ let n = fr.get(e);
1274
+ if (!n) {
1275
+ let r = L.value;
1276
+ n = Ce(t, (e) => r.field(e), (t) => I.value.get(e, t), T.valueSettings), fr.set(e, n);
1277
+ }
1278
+ return n;
1279
+ }
1280
+ function hr(e, t) {
1281
+ V.value, dr.value;
1282
+ let n = $.value.rowIdAt(e), r = R.value[t];
1283
+ if (n === void 0 || r === void 0) return;
1284
+ let i = mr(n), a = i?.get(null), o = i?.get(r.key), s = x(T.marks)?.get(n, r.key) ?? null, c = s?.fill ?? o?.fill ?? a?.fill ?? null, l = s?.color ?? o?.color ?? a?.color ?? null, u = [];
1285
+ return c && u.push(`is-fill-${c}`), l && u.push(`is-text-${l}`), (s?.bold || o?.bold || a?.bold) && u.push("is-bold"), s?.italic && u.push("is-italic"), u.length > 0 ? u.join(" ") : void 0;
1286
+ }
1287
+ let gr = t(() => {
1288
+ let e = T.found;
1289
+ return e ? new Set(e.cells.map((e) => JSON.stringify([e.rowId, e.field]))) : null;
1290
+ });
1291
+ function _r(e, t) {
1292
+ let n = gr.value;
1293
+ if (!n || n.size === 0) return;
1294
+ let r = $.value.rowIdAt(e), i = R.value[t];
1295
+ if (r === void 0 || i === void 0) return;
1296
+ let a = T.found?.current;
1297
+ return a && a.rowId === r && a.field === i.key ? "is-found-current" : n.has(JSON.stringify([r, i.key])) ? "is-found" : void 0;
1298
+ }
1299
+ function vr() {
1300
+ let e = Zr.value;
1301
+ if (!e) return [];
1302
+ let t = [];
1303
+ for (let n = e.top; n <= e.bottom; n++) {
1304
+ let r = $.value.rowIdAt(n);
1305
+ if (r !== void 0) for (let n = e.left; n <= e.right; n++) {
1306
+ let e = R.value[n];
1307
+ e && t.push({
1308
+ rowId: r,
1309
+ field: e.key
1310
+ });
1311
+ }
1312
+ }
1313
+ return t;
1314
+ }
1315
+ function yr() {
1316
+ let e = Zr.value;
1317
+ return e ? R.value.slice(e.left, e.right + 1).map((e) => e.key) : [];
1318
+ }
1319
+ function br(e) {
1320
+ let t = x(T.marks), n = vr();
1321
+ return !t || n.length === 0 ? !1 : (t.mark(n, e), !0);
1322
+ }
1323
+ function xr(e) {
1324
+ let t = x(T.marks), n = vr();
1325
+ return !t || n.length === 0 ? !1 : (t.toggle(n, e), !0);
1326
+ }
1327
+ function Sr() {
1328
+ let e = x(T.marks), t = vr();
1329
+ return !e || t.length === 0 ? !1 : (e.clear(t), !0);
1330
+ }
1331
+ function Cr(e, t) {
1332
+ return L.value.has(t) && q(L.value.field(t)) && !Ur(e);
1333
+ }
1334
+ let wr = [
1335
+ "sum",
1336
+ "average",
1337
+ "min",
1338
+ "max"
1339
+ ], Tr = {
1340
+ sum: "totalSum",
1341
+ average: "totalAverage",
1342
+ min: "totalMin",
1343
+ max: "totalMax"
1344
+ }, Er = g("sum"), Dr = y(null), Or = g("sum"), kr = g(null), Ar = null;
1345
+ function jr() {
1346
+ let e = kr.value?.getBoundingClientRect(), t = Re.value?.getBoundingClientRect();
1347
+ if (!e || !t) return;
1348
+ Or.value = Er.value, Dr.value = {
1349
+ left: e.left - t.left,
1350
+ bottom: t.bottom - e.top + 4,
1351
+ width: Math.max(e.width, 150)
1352
+ };
1353
+ let n = (e) => {
1354
+ let t = e.target instanceof Element ? e.target : null;
1355
+ !t?.closest(".tabula-grid-totals-menu") && !t?.closest(".tabula-grid-totals-pick") && Mr();
1356
+ };
1357
+ window.addEventListener("mousedown", n, !0), Ar = () => window.removeEventListener("mousedown", n, !0);
1358
+ }
1359
+ function Mr() {
1360
+ Ar?.(), Ar = null, Dr.value = null;
1361
+ }
1362
+ function Nr(e) {
1363
+ Er.value = e, Mr(), kr.value?.focus();
1364
+ }
1365
+ function Pr(e) {
1366
+ let t = wr.indexOf(Or.value);
1367
+ if (e.stopPropagation(), e.key === "ArrowDown" || e.key === "ArrowUp") {
1368
+ if (!Dr.value) jr();
1369
+ else {
1370
+ let n = e.key === "ArrowDown" ? 1 : -1;
1371
+ Or.value = wr[(t + n + wr.length) % wr.length] ?? "sum";
1372
+ }
1373
+ } else if ((e.key === "Enter" || e.key === " ") && Dr.value) Nr(Or.value);
1374
+ else if (e.key === "Escape" && Dr.value) Mr();
1375
+ else return;
1376
+ e.preventDefault();
1377
+ }
1378
+ p(Mr);
1379
+ let Fr = t(() => {
1380
+ if (!T.totals) return null;
1381
+ V.value, ja.value;
1382
+ let e = $.value;
1383
+ return R.value.map((t) => {
1384
+ if (!wo.has(t.type)) return null;
1385
+ let n = Ee(function* () {
1386
+ for (let n = 0; n < e.size; n++) {
1387
+ let r = e.rowIdAt(n);
1388
+ r !== void 0 && (yield {
1389
+ field: t,
1390
+ value: I.value.get(r, t.key)
1391
+ });
1392
+ }
1393
+ }())[Er.value];
1394
+ return n === null ? "" : F(t, n, T.valueSettings, { decimals: Rn.value[t.key]?.decimals });
1395
+ });
1396
+ });
1397
+ function Ir(e) {
1398
+ let t = e < z.value ? 0 : nr.value;
1399
+ return `left:${K.value + (G.value[e] ?? 0) - t}px;width:${An.value[e] ?? 0}px`;
1400
+ }
1401
+ function Lr(e, t) {
1402
+ let n = x(T.changes);
1403
+ if (!n) return;
1404
+ za.value;
1405
+ let r = $.value.rowIdAt(e), i = R.value[t];
1406
+ return r !== void 0 && i !== void 0 && n.isChanged(r, i.key) ? "is-changed" : void 0;
1407
+ }
1408
+ function Rr(e, t) {
1409
+ La.value;
1410
+ let n = $.value.rowIdAt(e), r = R.value[t];
1411
+ return n === void 0 || r === void 0 ? [] : Ia.value.issuesAt(n, r.key);
1412
+ }
1413
+ function zr(e) {
1414
+ let t = e.filter((e) => !e.stale);
1415
+ return t.length > 0 ? t.some((e) => e.severity === "error") ? "is-error" : "is-warning" : e.length > 0 ? "is-stale" : void 0;
1416
+ }
1417
+ function Br(e, t) {
1418
+ return zr(Rr(e, t));
1419
+ }
1420
+ function Vr(e) {
1421
+ return e.length === 0 ? void 0 : e.map((e) => {
1422
+ let t = Ve(e, T.locale, T.valueSettings);
1423
+ return e.stale ? `${U[T.locale].recheck}: ${t}` : t;
1424
+ }).join("\n");
1425
+ }
1426
+ function Hr(e, t) {
1427
+ return Vr(Rr(e, t));
1428
+ }
1429
+ function Ur(e) {
1430
+ return Ba.value?.isLocked(e) ?? !1;
1431
+ }
1432
+ function Wr(e) {
1433
+ Va.value;
1434
+ let t = $.value.rowIdAt(e);
1435
+ return t !== void 0 && Ur(t);
1436
+ }
1437
+ function Gr(e) {
1438
+ let t = Ba.value?.resultOf(e) ?? null;
1439
+ return Ba.value?.isLocked(e) && t?.outcome !== "succeeded" ? "sending" : t?.outcome ?? null;
1440
+ }
1441
+ function Kr(e) {
1442
+ Va.value, La.value;
1443
+ let t = $.value.rowIdAt(e);
1444
+ if (t === void 0) return [];
1445
+ let n = Gr(t), r = zr(Ia.value.rowIssues(t));
1446
+ return [n ? `is-${n}` : "", r ?? ""].filter(Boolean);
1447
+ }
1448
+ function qr(e) {
1449
+ La.value;
1450
+ let t = $.value.rowIdAt(e);
1451
+ if (t === void 0 || !Ia.value.hasIssues(t)) return;
1452
+ let n = [...Ia.value.rowIssues(t)];
1453
+ for (let e of L.value.fields) n.push(...Ia.value.issuesAt(t, e.key));
1454
+ return zr(n);
1455
+ }
1456
+ function Jr(e) {
1457
+ Va.value, La.value;
1458
+ let t = $.value.rowIdAt(e);
1459
+ if (t === void 0) return;
1460
+ let n = Gr(t), r = [n ? U[T.locale][n] : void 0, Vr(Ia.value.rowIssues(t))].filter(Boolean).join("\n");
1461
+ return r === "" ? void 0 : r;
1462
+ }
1463
+ function Yr(e, t) {
1464
+ return ye(e, t, T.valueSettings).value;
1465
+ }
1466
+ function Xr(e, t) {
1467
+ let n = $.value.rowIdAt(e), r = R.value[t];
1468
+ return n === void 0 || r === void 0 || I.value.get(n, r.key) === null;
1469
+ }
1470
+ let J = t(() => (Ie.value, B.active)), Zr = t(() => (Ie.value, B.range)), Qr = t(() => J.value ? `${Le}-${J.value.row}-${J.value.col}` : void 0), $r = t(() => {
1471
+ let e = J.value, t = e ? R.value[e.col] : void 0;
1472
+ return e && t ? `${t.label}: ${sr(e.row, e.col)}` : void 0;
1473
+ });
1474
+ function ei(e, t) {
1475
+ return J.value !== null && J.value.row === e && J.value.col === t;
1476
+ }
1477
+ function ti(e, t) {
1478
+ let n = Zr.value;
1479
+ return n !== null && e >= n.top && e <= n.bottom && t >= n.left && t <= n.right;
1480
+ }
1481
+ function ni(e) {
1482
+ return Zr.value !== null && e >= Zr.value.top && e <= Zr.value.bottom;
1483
+ }
1484
+ function ri(e) {
1485
+ return Zr.value !== null && e >= Zr.value.left && e <= Zr.value.right;
1486
+ }
1487
+ function ii(e, t = 0) {
1488
+ let n = G.value[e.left] ?? 0;
1489
+ return {
1490
+ transform: `translate(${n + t}px, ${e.top * W.value}px)`,
1491
+ width: `${(G.value[e.right + 1] ?? n) - n}px`,
1492
+ height: `${(e.bottom - e.top + 1) * W.value}px`
1493
+ };
1494
+ }
1495
+ function ai(e) {
1496
+ let t = z.value;
1497
+ return {
1498
+ pinned: e && e.left < t ? ii({
1499
+ ...e,
1500
+ right: Math.min(e.right, t - 1)
1501
+ }) : null,
1502
+ free: e && e.right >= t ? ii({
1503
+ ...e,
1504
+ left: Math.max(e.left, t)
1505
+ }) : null
1506
+ };
1507
+ }
1508
+ let oi = t(() => ai(Zr.value)), si = t(() => {
1509
+ let e = Zr.value;
1510
+ if (!e || T.readonly || Y.value) return null;
1511
+ let t = Math.min(G.value[e.right + 1] ?? 0, Mn.value - 4), n = Math.min((e.bottom + 1) * W.value, Pn.value - 4);
1512
+ return {
1513
+ pinned: e.right < z.value,
1514
+ style: { transform: `translate(${t}px, ${n}px)` }
1515
+ };
1516
+ }), ci = t(() => {
1517
+ let e = aa.value;
1518
+ return e?.target ? ai(sa(e.source, e.target)) : null;
1519
+ }), li = t(() => J.value !== null && J.value.col < z.value), ui = t(() => {
1520
+ let e = J.value;
1521
+ return e ? ii({
1522
+ top: e.row,
1523
+ bottom: e.row,
1524
+ left: e.col,
1525
+ right: e.col
1526
+ }) : {};
1527
+ }), di = t(() => {
1528
+ let e = J.value;
1529
+ return e && li.value ? ii({
1530
+ top: e.row,
1531
+ bottom: e.row,
1532
+ left: e.col,
1533
+ right: e.col
1534
+ }, nr.value) : ui.value;
1535
+ }), Y = y(null), X = g(""), fi = null, pi = t(() => {
1536
+ let e = Y.value;
1537
+ if (!e) return {};
1538
+ let t = An.value[e.col] ?? 0, n = Mn.value - (G.value[e.col] ?? 0), r = fi ? fi(X.value) + wn : t;
1539
+ return {
1540
+ ...di.value,
1541
+ width: `${Math.min(Math.max(t, r), Math.max(t, n))}px`
1542
+ };
1543
+ });
1544
+ function mi() {
1545
+ u(() => Ue.value?.focus({ preventScroll: !0 }));
1546
+ }
1547
+ function hi(e) {
1548
+ e.target === Re.value && mi();
1549
+ }
1550
+ function gi(e) {
1551
+ let t = B.active, n = t ? R.value[t.col] : void 0, r = t ? $.value.rowIdAt(t.row) : void 0;
1552
+ if (!t || !q(n) || r === void 0 || Wr(t.row)) return !1;
1553
+ fi = qe.value ? Ze(qe.value) : null;
1554
+ let i = I.value.get(r, n.key);
1555
+ return Q.value = n.type === "options" && n.multiple ? new Set(e === "enter" || !Array.isArray(i) ? [] : i.map((e) => String(e))) : null, Y.value = {
1556
+ row: t.row,
1557
+ col: t.col,
1558
+ original: ue(n, i, T.valueSettings),
1559
+ mode: e
1560
+ }, or(), !0;
1561
+ }
1562
+ function _i() {
1563
+ gi("edit") && (X.value = Q.value ? "" : Y.value?.original ?? "", u(() => {
1564
+ let e = Ue.value;
1565
+ e?.focus({ preventScroll: !0 }), e?.setSelectionRange(e.value.length, e.value.length);
1566
+ }));
1567
+ }
1568
+ function vi(e) {
1569
+ if (Y.value || e.isComposing) return;
1570
+ let t = e.target, n = t.value;
1571
+ n !== "" && (gi("enter") ? X.value = n : (t.value = "", X.value = ""));
1572
+ }
1573
+ function yi() {
1574
+ Y.value || gi("enter");
1575
+ }
1576
+ function bi(e) {
1577
+ e.isComposing || e.keyCode === 229 || (Y.value ? Gi(e) : qi(e));
1578
+ }
1579
+ function xi() {
1580
+ Si(!1);
1581
+ }
1582
+ function Si(e = !0) {
1583
+ let t = Y.value;
1584
+ if (!t) return;
1585
+ let n = X.value, r = Q.value;
1586
+ Y.value = null, X.value = "", Q.value = null;
1587
+ let i = $.value.rowIdAt(t.row), a = R.value[t.col];
1588
+ if (i !== void 0 && a?.type === "options" && r && n.trim() === "") {
1589
+ let e = a.options.filter((e) => r.has(String(e.value))).map((e) => e.value), t = e.length === 0 ? null : Object.freeze(e);
1590
+ JSON.stringify(t) !== JSON.stringify(I.value.get(i, a.key)) && I.value.setCell(i, a.key, t);
1591
+ } else i !== void 0 && a !== void 0 && n !== t.original && I.value.setCell(i, a.key, Yr(a, n));
1592
+ e && mi();
1593
+ }
1594
+ function Ci() {
1595
+ Y.value = null, X.value = "", Q.value = null, mi();
1596
+ }
1597
+ let wi = y([]), Z = y(-1), Ti = y(null), Ei = y(null), Di = `${Le}-list`, Oi = null, ki = null, Ai = t(() => Y.value !== null && (wi.value.length > 0 || Ti.value !== null)), Q = y(null), ji = t(() => {
1598
+ let e = Y.value ? R.value[Y.value.col] : void 0;
1599
+ return e?.type === "options" || e?.type === "lookup" && T.lookups ? e : null;
1600
+ });
1601
+ function Mi(e) {
1602
+ return e.trim().toLocaleLowerCase(T.locale);
1603
+ }
1604
+ function Ni() {
1605
+ Oi !== null && (clearTimeout(Oi), Oi = null), ki?.abort(), ki = null;
1606
+ }
1607
+ function Pi() {
1608
+ Ni(), wi.value = [], Z.value = -1, Ti.value = null;
1609
+ }
1610
+ function Fi(e, t) {
1611
+ let n = Mi(t), r = e.filter((e) => !e.disabled), i = r.filter((e) => Mi(e.label) === n), a = i.length === 1 ? i[0] : i.length === 0 && r.length === 1 ? r[0] : void 0;
1612
+ return a ? e.indexOf(a) : -1;
1613
+ }
1614
+ function Ii(e, t, n) {
1615
+ wi.value = e, Z.value = Q.value && e.length > 0 ? Math.max(0, Fi(e, t)) : Fi(e, t), Ti.value = n, u(Vi);
1616
+ }
1617
+ function Li() {
1618
+ let e = ji.value, t = X.value;
1619
+ if (Ni(), e?.type === "options") {
1620
+ let n = Mi(t), r = e.options.filter((e) => n === "" || Mi(e.label).includes(n) || Mi(String(e.value)) === n).map((e) => ({
1621
+ key: String(e.value),
1622
+ label: e.label,
1623
+ description: null,
1624
+ disabled: !1,
1625
+ value: e.value
1626
+ }));
1627
+ r.length > 0 ? Ii(r, t, null) : Pi();
1628
+ } else e?.type !== "lookup" || t.trim() === "" ? Pi() : (Ti.value = "searching", u(Vi), Oi = setTimeout(() => void Ri(e.key, t), En));
1629
+ }
1630
+ async function Ri(e, t) {
1631
+ let n = T.lookups, r = new AbortController();
1632
+ Oi = null, ki = r;
1633
+ try {
1634
+ let i = await n?.search(e, t, r.signal, Tn);
1635
+ if (ki !== r || !i) return;
1636
+ let a = i.items.map((e) => ({
1637
+ key: String(e.id),
1638
+ label: e.label,
1639
+ description: e.description ?? null,
1640
+ disabled: e.disabled === !0,
1641
+ value: Object.freeze({
1642
+ id: e.id,
1643
+ label: e.label
1644
+ })
1645
+ }));
1646
+ Ii(a, t, a.length === 0 ? "none" : i.more ? "more" : null);
1647
+ } catch {
1648
+ ki === r && Ii([], t, "unavailable");
1649
+ } finally {
1650
+ ki === r && (ki = null);
1651
+ }
1652
+ }
1653
+ E([Y, X], () => Li());
1654
+ function zi(e) {
1655
+ let t = wi.value;
1656
+ for (let n = 1; n <= t.length; n++) {
1657
+ let r = (Z.value + e * n + t.length * 2) % t.length;
1658
+ if (!t[r]?.disabled) {
1659
+ Z.value = r;
1660
+ return;
1661
+ }
1662
+ }
1663
+ }
1664
+ function Bi(e) {
1665
+ let t = wi.value[e], n = Y.value;
1666
+ if (!t || t.disabled || !n) return !1;
1667
+ if (Q.value) {
1668
+ let n = new Set(Q.value);
1669
+ return n.delete(t.key) || n.add(t.key), Q.value = n, X.value === "" ? Z.value = e : X.value = "", !0;
1670
+ }
1671
+ let r = $.value.rowIdAt(n.row), i = R.value[n.col];
1672
+ return Y.value = null, X.value = "", Pi(), r !== void 0 && i && I.value.setCell(r, i.key, t.value), mi(), !0;
1673
+ }
1674
+ function Vi() {
1675
+ let e = Ue.value, t = Re.value, n = t?.querySelector(".tabula-grid-list");
1676
+ if (!e || !t || !Ai.value) {
1677
+ Ei.value = null;
1678
+ return;
1679
+ }
1680
+ let r = e.getBoundingClientRect(), i = t.getBoundingClientRect(), a = n?.offsetHeight ?? 0, o = i.bottom - r.bottom, s = a > o && r.top - i.top > o;
1681
+ Ei.value = {
1682
+ left: r.left - i.left,
1683
+ top: s ? r.top - i.top - a : r.bottom - i.top,
1684
+ width: r.width
1685
+ };
1686
+ }
1687
+ function Hi(e) {
1688
+ return e.key === "ArrowDown" || e.key === "ArrowUp" ? (zi(e.key === "ArrowDown" ? 1 : -1), !0) : Q.value ? Ui(e) : e.key === "Escape" ? (Pi(), !0) : (e.key === "Enter" || e.key === "Tab") && Z.value >= 0 && Bi(Z.value) ? (e.key === "Enter" ? Ki(e.shiftKey ? -1 : 1, 0) : Ki(0, e.shiftKey ? -1 : 1), !0) : !1;
1689
+ }
1690
+ function Ui(e) {
1691
+ let t = X.value.trim() !== "";
1692
+ return e.key === " " && !t && Z.value >= 0 || e.key === "Enter" && t && Z.value >= 0 ? Bi(Z.value) : !1;
1693
+ }
1694
+ function Wi() {
1695
+ let e = B.active;
1696
+ return (e ? R.value[e.col] : void 0)?.type !== "options" || !gi("edit") ? !1 : (X.value = "", u(() => Ue.value?.focus({ preventScroll: !0 })), !0);
1697
+ }
1698
+ function Gi(e) {
1699
+ let t = Y.value;
1700
+ if (t) {
1701
+ if (Ai.value && Hi(e)) e.preventDefault();
1702
+ else {
1703
+ if (e.key === "Enter") Si(), Ki(e.shiftKey ? -1 : 1, 0);
1704
+ else if (e.key === "Tab") Si(), Ki(0, e.shiftKey ? -1 : 1);
1705
+ else if (e.key === "Escape") Ci();
1706
+ else if (t.mode === "enter" && Te[e.key] !== void 0) {
1707
+ let t = Oe[Te[e.key]];
1708
+ Si(), Ki(t.row, t.col);
1709
+ } else return;
1710
+ e.preventDefault();
1711
+ }
1712
+ }
1713
+ }
1714
+ function Ki(e, t, n = !1) {
1715
+ B.move(e, t, { extend: n }), or();
1716
+ }
1717
+ function qi(e) {
1718
+ let t = e.ctrlKey || e.metaKey, n = e.shiftKey, r = (n ? B.head : B.active) ?? {
1719
+ row: 0,
1720
+ col: 0
1721
+ }, i = Math.max(1, Math.floor(ir().height / W.value) - 1), a = Te[e.key], o = Yi(e);
1722
+ if (o !== null) e.preventDefault(), Xi(o);
1723
+ else if (e.altKey && e.key === "ArrowDown" && Wi()) e.preventDefault();
1724
+ else {
1725
+ if (a !== void 0) {
1726
+ if (t) B.jump(a, Xr, { extend: n });
1727
+ else {
1728
+ let e = Oe[a];
1729
+ B.move(e.row, e.col, { extend: n });
1730
+ }
1731
+ } else switch (e.key) {
1732
+ case "Tab": {
1733
+ let e = B.active?.col ?? 0;
1734
+ if (n ? e <= 0 : e >= R.value.length - 1) return;
1735
+ B.move(0, n ? -1 : 1);
1736
+ break;
1737
+ }
1738
+ case "Enter":
1739
+ B.move(n ? -1 : 1, 0);
1740
+ break;
1741
+ case "Home":
1742
+ B.moveTo(t ? 0 : r.row, 0, { extend: n });
1743
+ break;
1744
+ case "End":
1745
+ B.moveTo(t ? Infinity : r.row, Infinity, { extend: n });
1746
+ break;
1747
+ case "PageDown":
1748
+ B.move(i, 0, { extend: n });
1749
+ break;
1750
+ case "PageUp":
1751
+ B.move(-i, 0, { extend: n });
1752
+ break;
1753
+ case "F2":
1754
+ _i();
1755
+ break;
1756
+ case "Delete":
1757
+ case "Backspace":
1758
+ ra("clear");
1759
+ break;
1760
+ default: if (!Ji(e, t)) return;
1761
+ }
1762
+ e.preventDefault(), or();
1763
+ }
1764
+ }
1765
+ function Ji(e, t) {
1766
+ let n = e.ctrlKey && e.altKey;
1767
+ if (e.key === " " && e.shiftKey && !t) {
1768
+ let e = B.active;
1769
+ return e && B.selectRows(e.row), !0;
1770
+ }
1771
+ if (e.key === " " && t && !e.shiftKey) {
1772
+ let e = B.active;
1773
+ return e && B.selectColumns(e.col), !0;
1774
+ }
1775
+ if (t && !n && e.key.toLowerCase() === "a") return B.selectAll(), !0;
1776
+ if (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey && !t) return Uo(null), !0;
1777
+ if (t && !n && (e.key === "+" || e.code === "NumpadAdd") && !T.readonly) {
1778
+ let e = B.range;
1779
+ return e && e.left === 0 && e.right >= R.value.length - 1 ? Po("above") : e && B.selectRows(e.top, e.bottom), !0;
1780
+ }
1781
+ if (t && !n && (e.key === "-" || e.code === "NumpadSubtract") && !T.readonly) {
1782
+ let e = B.range;
1783
+ return e && e.left === 0 && e.right >= R.value.length - 1 ? Mo() : e && B.selectRows(e.top, e.bottom), !0;
1784
+ }
1785
+ let r = e.key.toLowerCase();
1786
+ return t && !n && !e.shiftKey && (r === "b" || r === "i") && x(T.marks) ? (xr(r === "b" ? "bold" : "italic"), !0) : t && !n && !e.shiftKey && r === "h" ? (D("find"), !0) : t && !n && !e.shiftKey && (r === "d" || r === "r") && !T.readonly ? (ha(r === "d" ? "down" : "right"), !0) : !1;
1787
+ }
1788
+ function Yi(e) {
1789
+ let t = e.key.toLowerCase();
1790
+ return !(e.ctrlKey || e.metaKey) || e.altKey || t !== "z" && t !== "y" ? null : t === "y" || e.shiftKey ? "redo" : "undo";
1791
+ }
1792
+ function Xi(e) {
1793
+ if (T.readonly) return !1;
1794
+ Si(!1);
1795
+ try {
1796
+ return (e === "undo" ? Fa.value.undo() : Fa.value.redo()) !== null;
1797
+ } catch (e) {
1798
+ if (e instanceof ne && e.code === "conflict") return !1;
1799
+ throw e;
1800
+ }
1801
+ }
1802
+ function Zi(e) {
1803
+ let t = $.value, n = new Map(R.value.flatMap((e, t) => e.formula === null ? [[e.key, t]] : [])), r = {
1804
+ top: Infinity,
1805
+ left: Infinity,
1806
+ bottom: -1,
1807
+ right: -1
1808
+ }, i = {
1809
+ top: Infinity,
1810
+ bottom: -1
1811
+ }, a = Infinity;
1812
+ for (let o of e.operations) if (o.kind === "set") {
1813
+ let e = t.indexOf(o.rowId), i = n.get(o.field);
1814
+ e >= 0 && i !== void 0 && (r.top = Math.min(r.top, e), r.bottom = Math.max(r.bottom, e), r.left = Math.min(r.left, i), r.right = Math.max(r.right, i));
1815
+ } else if (o.kind === "insert") for (let e of o.rows) {
1816
+ let n = t.indexOf(e.rowId);
1817
+ n >= 0 && (i.top = Math.min(i.top, n), i.bottom = Math.max(i.bottom, n));
1818
+ }
1819
+ else a = Math.min(a, o.rows[0]?.index ?? Infinity);
1820
+ Y.value = null, X.value = "", r.bottom >= 0 ? (B.moveTo(r.top, r.left), B.moveTo(r.bottom, r.right, { extend: !0 })) : i.bottom >= 0 ? B.selectRows(i.top, i.bottom) : a !== Infinity && B.moveTo(a, B.active?.col ?? 0), or(B.active);
1821
+ }
1822
+ function Qi(e) {
1823
+ let t = [];
1824
+ for (let n = e.top; n <= e.bottom; n++) {
1825
+ let r = [];
1826
+ for (let t = e.left; t <= e.right; t++) r.push(sr(n, t));
1827
+ t.push(r);
1828
+ }
1829
+ return De(t);
1830
+ }
1831
+ function $i(e) {
1832
+ let t = B.range;
1833
+ !Y.value && t && e.clipboardData && (e.clipboardData.setData("text/plain", Qi(t)), e.preventDefault());
1834
+ }
1835
+ function ea(e) {
1836
+ Y.value || T.readonly || ($i(e), ra("cut"));
1837
+ }
1838
+ function ta(e) {
1839
+ Y.value || T.readonly || !B.range && H.value > 0 || (e.preventDefault(), na(e.clipboardData?.getData("text/plain") ?? ""));
1840
+ }
1841
+ function na(e) {
1842
+ let t = B.range ?? (H.value === 0 && R.value.length > 0 ? {
1843
+ top: 0,
1844
+ left: 0,
1845
+ bottom: 0,
1846
+ right: 0
1847
+ } : null), n = ve(e);
1848
+ if (T.readonly || !t || n.length === 0) return;
1849
+ let r = n.length === 1 && n[0]?.length === 1 && (t.bottom > t.top || t.right > t.left), i = r ? t.bottom - t.top + 1 : n.length, a = r ? t.right - t.left + 1 : Math.max(...n.map((e) => e.length)), o = I.value, s = R.value;
1850
+ o.transact(() => {
1851
+ let e = $.value.size, c = t.top + i - e, l = c > 0 ? o.appendRows(Ae(L.value, c)) : [], u = (t) => t < e ? $.value.rowIdAt(t) : l[t - e];
1852
+ for (let e = 0; e < i; e++) {
1853
+ let i = u(t.top + e);
1854
+ for (let c = 0; c < a && t.left + c < s.length; c++) {
1855
+ let a = s[t.left + c], l = r ? n[0]?.[0] : n[e]?.[c];
1856
+ i !== void 0 && q(a) && l !== void 0 && !Ur(i) && o.setCell(i, a.key, Yr(a, l));
1857
+ }
1858
+ }
1859
+ }, { origin: "paste" }), B.moveTo(t.top, t.left), B.moveTo(t.top + i - 1, Math.min(t.left + a, s.length) - 1, { extend: !0 }), or();
1860
+ }
1861
+ function ra(e) {
1862
+ let t = B.range;
1863
+ if (!t || T.readonly) return;
1864
+ let n = I.value;
1865
+ n.transact(() => {
1866
+ for (let e = t.top; e <= t.bottom; e++) {
1867
+ let r = $.value.rowIdAt(e);
1868
+ for (let e = t.left; e <= t.right; e++) {
1869
+ let t = R.value[e];
1870
+ r !== void 0 && q(t) && !Ur(r) && n.setCell(r, t.key, null);
1871
+ }
1872
+ }
1873
+ }, { origin: e });
1874
+ }
1875
+ let ia = /* @__PURE__ */ new Set([
1876
+ "string",
1877
+ "integer",
1878
+ "decimal",
1879
+ "money",
1880
+ "quantity",
1881
+ "percent",
1882
+ "bool",
1883
+ "date",
1884
+ "datetime"
1885
+ ]), aa = y(null);
1886
+ function oa(e, t, n) {
1887
+ return n === null || e.key === t.key || e.type === t.type && ia.has(t.type) ? n : Yr(t, F(e, n, T.valueSettings));
1888
+ }
1889
+ function sa(e, t) {
1890
+ return {
1891
+ top: e.top + Math.min(0, t.rows),
1892
+ bottom: e.bottom + Math.max(0, t.rows),
1893
+ left: e.left + Math.min(0, t.cols),
1894
+ right: e.right + Math.max(0, t.cols)
1895
+ };
1896
+ }
1897
+ function ca(e, t) {
1898
+ let n = t.row > e.bottom ? t.row - e.bottom : Math.min(0, t.row - e.top), r = t.col > e.right ? t.col - e.right : Math.min(0, t.col - e.left);
1899
+ return n === 0 && r === 0 ? null : {
1900
+ rows: n,
1901
+ cols: r
1902
+ };
1903
+ }
1904
+ function la(e, t, n) {
1905
+ T.readonly || t.rows === 0 && t.cols === 0 || I.value.transact(() => {
1906
+ t.rows !== 0 && ua(e, t.rows, n), t.cols !== 0 && da(sa(e, {
1907
+ rows: t.rows,
1908
+ cols: 0
1909
+ }), t.cols, n);
1910
+ }, { origin: "fill" });
1911
+ }
1912
+ function ua(e, t, n) {
1913
+ let r = I.value, i = $.value, a = {
1914
+ backward: t < 0,
1915
+ mode: n
1916
+ }, o = Math.abs(t);
1917
+ for (let t = e.left; t <= e.right; t++) {
1918
+ let n = R.value[t];
1919
+ if (!q(n)) continue;
1920
+ let s = rr(e.top, e.bottom).map((e) => {
1921
+ let t = i.rowIdAt(e);
1922
+ return t === void 0 ? null : r.get(t, n.key);
1923
+ });
1924
+ de(n, s, o, a).forEach((t, o) => {
1925
+ let s = i.rowIdAt(a.backward ? e.top - 1 - o : e.bottom + 1 + o);
1926
+ s !== void 0 && !Ur(s) && r.setCell(s, n.key, t);
1927
+ });
1928
+ }
1929
+ }
1930
+ function da(e, t, n) {
1931
+ let r = I.value, i = $.value, a = {
1932
+ backward: t < 0,
1933
+ mode: n
1934
+ }, o = Math.abs(t), s = R.value.slice(e.left, e.right + 1), c = s[0], l = c && ia.has(c.type) && s.every((e) => e.type === c.type) ? c : null, u = de(null, s.map((e, t) => t), o, a);
1935
+ for (let t = e.top; t <= e.bottom; t++) {
1936
+ let n = i.rowIdAt(t);
1937
+ if (n === void 0 || Ur(n)) continue;
1938
+ let c = s.map((e) => r.get(n, e.key)), d = l ? de(l, c, o, a) : null;
1939
+ for (let t = 0; t < o; t++) {
1940
+ let i = R.value[a.backward ? e.left - 1 - t : e.right + 1 + t], o = u[t] ?? 0, f = l ?? s[o];
1941
+ q(i) && f && r.setCell(n, i.key, oa(f, i, d ? d[t] ?? null : c[o] ?? null));
1942
+ }
1943
+ }
1944
+ }
1945
+ function fa(e) {
1946
+ B.moveTo(e.top, e.left), B.moveTo(e.bottom, e.right, { extend: !0 }), or();
1947
+ }
1948
+ function pa(e) {
1949
+ let t = B.range;
1950
+ e.button === 0 && t && !T.readonly && (ba(e), aa.value = {
1951
+ source: t,
1952
+ target: null
1953
+ }, _a((e) => {
1954
+ let n = ya(e);
1955
+ n && (aa.value = {
1956
+ source: t,
1957
+ target: ca(t, n)
1958
+ });
1959
+ }, (e) => {
1960
+ let n = aa.value?.target ?? null;
1961
+ aa.value = null, e && n && (la(t, n, e.ctrlKey || e.altKey ? "alternate" : "auto"), fa(sa(t, n)));
1962
+ }));
1963
+ }
1964
+ function ma() {
1965
+ let e = B.range;
1966
+ if (!e || T.readonly) return;
1967
+ let t = [e.left - 1, e.right + 1].find((t) => t >= 0 && t < R.value.length && !Xr(e.bottom + 1, t));
1968
+ if (t === void 0) return;
1969
+ let n = e.bottom + 1;
1970
+ for (; n + 1 < H.value && !Xr(n + 1, t);) n++;
1971
+ let r = {
1972
+ rows: n - e.bottom,
1973
+ cols: 0
1974
+ };
1975
+ la(e, r, "auto"), fa(sa(e, r));
1976
+ }
1977
+ function ha(e) {
1978
+ let t = B.range;
1979
+ if (!t) return;
1980
+ if (e === "down") {
1981
+ let e = t.bottom > t.top ? t.top : t.top - 1;
1982
+ e >= 0 && la({
1983
+ ...t,
1984
+ top: e,
1985
+ bottom: e
1986
+ }, {
1987
+ rows: t.bottom - e,
1988
+ cols: 0
1989
+ }, "copy");
1990
+ return;
1991
+ }
1992
+ let n = t.right > t.left ? t.left : t.left - 1;
1993
+ n >= 0 && la({
1994
+ ...t,
1995
+ left: n,
1996
+ right: n
1997
+ }, {
1998
+ rows: 0,
1999
+ cols: t.right - n
2000
+ }, "copy");
2001
+ }
2002
+ let ga = null;
2003
+ function _a(e, t) {
2004
+ ga?.();
2005
+ let n = (r) => {
2006
+ window.removeEventListener("mousemove", e), window.removeEventListener("mouseup", n), ga = null, t?.(r instanceof MouseEvent ? r : null);
2007
+ };
2008
+ window.addEventListener("mousemove", e), window.addEventListener("mouseup", n), ga = n;
2009
+ }
2010
+ function va(e, t, n) {
2011
+ return Math.min(n, Math.max(t, e));
2012
+ }
2013
+ function ya(e) {
2014
+ let t = He.value;
2015
+ if (!t || H.value === 0 || R.value.length === 0) return null;
2016
+ let n = t.getBoundingClientRect();
2017
+ return {
2018
+ row: va(Math.floor((e.clientY - n.top) / W.value), 0, H.value - 1),
2019
+ col: Sa(e.clientX)
2020
+ };
2021
+ }
2022
+ function ba(e) {
2023
+ e.preventDefault(), Si(!1), mi();
2024
+ }
2025
+ function xa(e) {
2026
+ if (e.button !== 0 || Y.value && e.target === Ue.value) return;
2027
+ ba(e);
2028
+ let t = ya(e);
2029
+ t && (B.moveTo(t.row, t.col, { extend: e.shiftKey }), _a((e) => {
2030
+ let t = ya(e);
2031
+ t && B.moveTo(t.row, t.col, { extend: !0 });
2032
+ }));
2033
+ }
2034
+ function Sa(e) {
2035
+ let t = ze.value, n = e - (t?.getBoundingClientRect().left ?? 0) - K.value;
2036
+ return z.value > 0 && n < Nn.value ? Un(Math.max(0, n)) : Un(va(n + (t?.scrollLeft ?? 0), 0, Math.max(0, Mn.value - 1)));
2037
+ }
2038
+ function Ca(e) {
2039
+ let t = Be.value?.getBoundingClientRect();
2040
+ return va(Math.floor((e - (t?.top ?? 0)) / W.value), 0, Math.max(0, H.value - 1));
2041
+ }
2042
+ function wa(e, t) {
2043
+ if (e.button !== 0) return;
2044
+ ba(e);
2045
+ let n = e.shiftKey && B.active ? B.active.col : t;
2046
+ B.selectColumns(n, t), _a((e) => B.selectColumns(n, Sa(e.clientX)));
2047
+ }
2048
+ function Ta(e, t) {
2049
+ if (e.button !== 0) return;
2050
+ ba(e);
2051
+ let n = e.shiftKey && B.active ? B.active.row : t;
2052
+ B.selectRows(n, t), _a((e) => B.selectRows(n, Ca(e.clientY)));
2053
+ }
2054
+ function Ea(e) {
2055
+ e.button === 0 && (ba(e), B.selectAll());
2056
+ }
2057
+ function Da(e, t) {
2058
+ let n = R.value[t], r = Je.value[t];
2059
+ if (e.button !== 0 || !n || !r) return;
2060
+ let i = e.clientX, a = An.value[t] ?? r.minWidth;
2061
+ _a((e) => {
2062
+ Xe.value = {
2063
+ key: n.key,
2064
+ width: ce(a + e.clientX - i, r)
2065
+ };
2066
+ }, () => {
2067
+ let e = Xe.value;
2068
+ Xe.value = null, e && e.width !== a && Kn(e.key, e.width);
2069
+ });
2070
+ }
2071
+ function Oa() {
2072
+ H.value = $.value.size, B.resize(H.value, R.value.length), ar();
2073
+ }
2074
+ let ka = B.subscribe(() => {
2075
+ Ie.value++;
2076
+ }), Aa = null, $ = y(x(T.view) ?? (Aa = new A(I.value))), ja = y(0);
2077
+ E(() => x(T.store), (e, t, n) => {
2078
+ I.value = e, Y.value = null, Oa(), V.value++, n(e.subscribe((e) => {
2079
+ V.value++, $.value.size !== H.value && Oa(), (e.origin === re || e.origin === k) && Zi(e);
2080
+ }));
2081
+ }, { immediate: !0 }), E(() => [x(T.view), I.value], ([e, t], n, r) => {
2082
+ e ? (Aa?.dispose(), Aa = null, $.value = e) : Aa && n === void 0 || (Aa?.dispose(), Aa = new A(t), $.value = Aa), ja.value++, Oa(), r($.value.subscribe(() => {
2083
+ ja.value++, V.value++, Oa();
2084
+ }));
2085
+ }, { immediate: !0 });
2086
+ let Ma = t(() => (ja.value, $.value.arranged));
2087
+ function Na(e) {
2088
+ ja.value;
2089
+ let t = Ma.value ? $.value.rowIdAt(e) : void 0;
2090
+ return t === void 0 ? e + 1 : I.value.indexOf(t) + 1;
2091
+ }
2092
+ let Pa = null, Fa = y(x(T.history) ?? (Pa = new ie(I.value)));
2093
+ E(() => [x(T.history), I.value], ([e, t]) => {
2094
+ Pa?.dispose(), Pa = e ? null : new ie(t), Fa.value = e ?? Pa;
2095
+ }), E(() => x(T.schema), (e) => {
2096
+ L.value = e, Y.value = null, Oa();
2097
+ });
2098
+ let Ia = y(x(T.issues) ?? new M(L.value, I.value, T.valueSettings)), La = y(0), Ra = T.issues ? null : Ia.value;
2099
+ E(() => [
2100
+ x(T.issues),
2101
+ L.value,
2102
+ I.value
2103
+ ], ([e, t, n], r, i) => {
2104
+ e ? (Ra?.dispose(), Ra = null, Ia.value = e) : Ra && r === void 0 || (Ra?.dispose(), Ra = new M(t, n, T.valueSettings), Ia.value = Ra), La.value++, i(Ia.value.subscribe(() => La.value++));
2105
+ }, { immediate: !0 });
2106
+ let za = y(0);
2107
+ E(() => x(T.changes), (e, t, n) => {
2108
+ za.value++, e && n(e.subscribe(() => za.value++));
2109
+ }, { immediate: !0 });
2110
+ let Ba = y(x(T.results)), Va = y(0);
2111
+ E(() => x(T.results), (e, t, n) => {
2112
+ Ba.value = e, Va.value++, e && n(e.subscribe(() => Va.value++));
2113
+ }, { immediate: !0 }), E(() => T.valueSettings, (e) => {
2114
+ Ra?.setSettings(e);
2115
+ }), E(Je, () => Wn()), E(() => T.zoom, () => void u(() => Wn())), E(Ne, () => {
2116
+ Y.value = null, qa(), Wo(), Oa();
2117
+ });
2118
+ let Ha = y(null), Ua = null, Wa = t(() => (P.value.hidden ?? []).filter((e) => L.value.has(e)).length);
2119
+ function Ga(e, t) {
2120
+ let n = Re.value, r = e.currentTarget;
2121
+ if (!n || !r) return;
2122
+ let i = r.getBoundingClientRect();
2123
+ Ka(t, i.left, i.bottom);
2124
+ }
2125
+ function Ka(e, t, n) {
2126
+ let r = Re.value;
2127
+ if (!r) return;
2128
+ Si(!1), qa(), Wo();
2129
+ let i = r.getBoundingClientRect();
2130
+ Ha.value = {
2131
+ col: e,
2132
+ left: t - i.left,
2133
+ top: n - i.top
2134
+ };
2135
+ let a = (e) => {
2136
+ let t = r.querySelector(".tabula-grid-menu");
2137
+ e.target instanceof Node && t?.contains(e.target) || qa();
2138
+ };
2139
+ window.addEventListener("mousedown", a, !0), Ua = () => window.removeEventListener("mousedown", a, !0), u(() => r.querySelector(".tabula-grid-menu button")?.focus());
2140
+ }
2141
+ function qa(e = !1) {
2142
+ Ua?.(), Ua = null, Ha.value = null, e && mi();
2143
+ }
2144
+ function Ja(e) {
2145
+ let t = Ha.value, n = t ? R.value[t.col] : void 0;
2146
+ e === "filter" && t ? (qa(), fo(t.col, t.left, t.top)) : (qa(!0), e === "sortAsc" || e === "sortDesc" ? n && (be.value = Object.freeze({
2147
+ key: n.key,
2148
+ direction: e === "sortAsc" ? "asc" : "desc"
2149
+ })) : e === "sortClear" ? be.value = null : e === "filterClear" ? n && _o(n.key, null) : e === "showHidden" ? P.value = Object.freeze({
2150
+ ...P.value,
2151
+ hidden: []
2152
+ }) : n && (P.value = ke(P.value, n.key, e === "hide" ? { hidden: !0 } : { pinned: e === "pin" })));
2153
+ }
2154
+ function Ya(e) {
2155
+ let t = [...Re.value?.querySelectorAll(".tabula-grid-menu button:not(:disabled)") ?? []], n = t.indexOf(document.activeElement);
2156
+ if (e.key === "Escape") qa(!0);
2157
+ else if (e.key === "ArrowDown" || e.key === "ArrowUp") t[(n + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus();
2158
+ else return;
2159
+ e.preventDefault();
2160
+ }
2161
+ E([
2162
+ ge,
2163
+ be,
2164
+ $,
2165
+ () => T.locale
2166
+ ], ([e, t, n]) => {
2167
+ Object.keys(e).some((e) => L.value.has(e)) ? n.filter(we(I.value, L.value, e), Dn) : n.clear(Dn), n.sort(t && L.value.has(t.key) ? Se(I.value, L.value, t, T.locale) : null);
2168
+ }, { immediate: !0 });
2169
+ function Xa(e) {
2170
+ let t = R.value[e];
2171
+ return t && be.value?.key === t.key ? be.value.direction : null;
2172
+ }
2173
+ function Za(e) {
2174
+ let t = R.value[e];
2175
+ return t !== void 0 && ge.value[t.key] !== void 0;
2176
+ }
2177
+ function Qa(e) {
2178
+ let t = Xa(e);
2179
+ return t === "asc" ? "ascending" : t === "desc" ? "descending" : void 0;
2180
+ }
2181
+ let $a = y(null), eo = g(""), to = y(/* @__PURE__ */ new Set()), no = g(""), ro = g(""), io = g(null), ao = null;
2182
+ function oo(e) {
2183
+ let t = $a.value?.field;
2184
+ if (e.key === "" || !t) return U[T.locale].empty ?? "";
2185
+ let n = t.type === "options" && t.multiple && !Array.isArray(e.value) ? [e.value] : e.value;
2186
+ return F(t, n, T.valueSettings);
2187
+ }
2188
+ let so = t(() => {
2189
+ let e = $a.value, t = Mi(eo.value);
2190
+ return e ? t === "" ? e.values : e.values.filter((e) => Mi(oo(e)).includes(t)) : [];
2191
+ }), co = t(() => so.value.every((e) => to.value.has(e.key))), lo = t(() => so.value.some((e) => to.value.has(e.key)));
2192
+ function uo(e, t) {
2193
+ return t === null ? "" : ue(e, t, T.valueSettings);
2194
+ }
2195
+ function fo(e, t, n) {
2196
+ let r = R.value[e];
2197
+ if (!r) return;
2198
+ let i = { ...ge.value };
2199
+ delete i[r.key];
2200
+ let a = we(I.value, L.value, i), o = I.value.rowIds().filter((e) => a(e)), { values: s, more: c } = le(I.value, r, o, { locale: T.locale }), l = ge.value[r.key];
2201
+ $a.value = {
2202
+ col: e,
2203
+ field: r,
2204
+ left: t,
2205
+ top: n,
2206
+ values: s,
2207
+ more: c,
2208
+ range: me(r)
2209
+ }, eo.value = "", io.value = null, to.value = new Set(l?.kind === "values" ? l.keys : s.map((e) => e.key)), no.value = l?.kind === "range" ? uo(r, l.from) : "", ro.value = l?.kind === "range" ? uo(r, l.to) : "";
2210
+ let d = Re.value, f = (e) => {
2211
+ let t = d?.querySelector(".tabula-grid-filter");
2212
+ e.target instanceof Node && t?.contains(e.target) || po();
2213
+ };
2214
+ window.addEventListener("mousedown", f, !0), ao = () => window.removeEventListener("mousedown", f, !0), u(() => d?.querySelector(".tabula-grid-filter input")?.focus());
2215
+ }
2216
+ function po(e = !1) {
2217
+ ao?.(), ao = null, $a.value = null, e && mi();
2218
+ }
2219
+ function mo(e) {
2220
+ let t = new Set(to.value);
2221
+ t.has(e) ? t.delete(e) : t.add(e), to.value = t;
2222
+ }
2223
+ function ho() {
2224
+ let e = new Set(to.value), t = !co.value;
2225
+ for (let n of so.value) t ? e.add(n.key) : e.delete(n.key);
2226
+ to.value = e;
2227
+ }
2228
+ function go(e, t) {
2229
+ if (t.trim() === "") return null;
2230
+ let { value: n, problem: r } = ye(e, t, T.valueSettings);
2231
+ return r === null && typeof n == "string" ? n : void 0;
2232
+ }
2233
+ function _o(e, t) {
2234
+ let n = { ...ge.value };
2235
+ t ? n[e] = t : delete n[e], ge.value = Object.freeze(n);
2236
+ }
2237
+ function vo() {
2238
+ let e = $a.value;
2239
+ if (!e) return;
2240
+ let t = e.field.key;
2241
+ if (e.range && (no.value.trim() !== "" || ro.value.trim() !== "")) {
2242
+ let n = go(e.field, no.value), r = go(e.field, ro.value);
2243
+ if (n === void 0 || r === void 0) {
2244
+ io.value = U[T.locale].badBound ?? null;
2245
+ return;
2246
+ }
2247
+ _o(t, {
2248
+ kind: "range",
2249
+ from: n,
2250
+ to: r
2251
+ });
2252
+ } else {
2253
+ let n = eo.value.trim() !== "", r = (n ? so.value : e.values).filter((e) => to.value.has(e.key)).map((e) => e.key);
2254
+ _o(t, !n && r.length === e.values.length && e.more === 0 ? null : {
2255
+ kind: "values",
2256
+ keys: r
2257
+ });
2258
+ }
2259
+ po(!0);
2260
+ }
2261
+ function yo() {
2262
+ let e = $a.value;
2263
+ e && _o(e.field.key, null), po(!0);
2264
+ }
2265
+ function bo(e) {
2266
+ e.key === "Escape" ? (e.preventDefault(), po(!0)) : e.key === "Enter" && e.target.tagName === "INPUT" && e.target.type !== "checkbox" && (e.preventDefault(), vo());
2267
+ }
2268
+ E(G, () => ar()), E(() => W.value, () => ar());
2269
+ let xo = null;
2270
+ m(() => {
2271
+ Wn(), ar(), ze.value && (xo = new ResizeObserver(() => ar()), xo.observe(ze.value)), document.fonts?.ready.then(() => Wn());
2272
+ }), p(() => {
2273
+ Ni(), qa(), po(), Ra?.dispose(), Pa?.dispose(), Aa?.dispose(), xo?.disconnect(), ga?.(), ka();
2274
+ });
2275
+ function So(e, t) {
2276
+ return Co(e, t ?? null, !0);
2277
+ }
2278
+ function Co(e, t, n, r = !0) {
2279
+ if (!$.value.show(e)) return !1;
2280
+ let i = $.value.indexOf(e);
2281
+ if (i < 0) return !1;
2282
+ Si(!1);
2283
+ let a = t ? R.value.findIndex((e) => e.key === t) : -1;
2284
+ return t && a < 0 && n && P.value.hidden?.includes(t) ? (P.value = ke(P.value, t, { hidden: !1 }), u(() => Co(e, t, !1, r)), !0) : (B.moveTo(i, a < 0 ? B.active?.col ?? 0 : a), or(), r && mi(), !0);
2285
+ }
2286
+ let wo = /* @__PURE__ */ new Set([
2287
+ "integer",
2288
+ "decimal",
2289
+ "money",
2290
+ "quantity",
2291
+ "percent"
2292
+ ]), To = t(() => {
2293
+ V.value, Va.value;
2294
+ let e = J.value, t = e ? R.value[e.col] : void 0, n = e ? $.value.rowIdAt(e.row) : void 0;
2295
+ if (!e || t === void 0 || n === void 0) return null;
2296
+ let r = t.formula ? Object.freeze(pe(t.formula, L.value.fields)) : null;
2297
+ return Object.freeze({
2298
+ rowId: n,
2299
+ field: t,
2300
+ address: `${je(e.col)}${Na(e.row)}`,
2301
+ text: ue(t, I.value.get(n, t.key), T.valueSettings),
2302
+ editable: q(t) && !Ur(n),
2303
+ formula: r,
2304
+ references: r ? [...new Set(r.flatMap((e) => e.field ? [e.field] : []))] : []
2305
+ });
2306
+ }), Eo = t(() => new Map((To.value?.references ?? []).map((e, t) => [e, t % On])));
2307
+ function Do(e, t) {
2308
+ let n = R.value[t], r = n ? Eo.value.get(n.key) : void 0;
2309
+ if (r !== void 0) return `is-ref tabula-ref-${r}${e !== null && J.value?.row === e ? " is-ref-here" : ""}`;
2310
+ }
2311
+ let Oo = t(() => {
2312
+ V.value;
2313
+ let e = Zr.value;
2314
+ if (!e) return null;
2315
+ let t = $.value, n = R.value.slice(e.left, e.right + 1), r = `${je(e.left)}${Na(e.top)}`, i = `${je(e.right)}${Na(e.bottom)}`;
2316
+ return Object.freeze({
2317
+ ...Ee(function* () {
2318
+ for (let r = e.top; r <= e.bottom; r++) {
2319
+ let e = t.rowIdAt(r);
2320
+ if (e !== void 0) for (let t of n) yield {
2321
+ field: t,
2322
+ value: I.value.get(e, t.key)
2323
+ };
2324
+ }
2325
+ }()),
2326
+ address: r === i ? r : `${r}:${i}`,
2327
+ rows: e.bottom - e.top + 1,
2328
+ columns: n.length,
2329
+ field: n.find((e) => wo.has(e.type)) ?? null
2330
+ });
2331
+ });
2332
+ function ko(e) {
2333
+ let t = Me(e), n = t ? R.value[t.col] : void 0, r = t ? I.value.rowIdAt(t.row - 1) : void 0;
2334
+ return n !== void 0 && r !== void 0 && Co(r, n.key, !1);
2335
+ }
2336
+ function Ao(e, t, n) {
2337
+ let r = L.value.has(t) ? L.value.field(t) : void 0;
2338
+ return !q(r) || !I.value.has(e) || Ur(e) ? !1 : (Y.value && Si(!1), n !== ue(r, I.value.get(e, t), T.valueSettings) && I.value.setCell(e, t, Yr(r, n)), !0);
2339
+ }
2340
+ function jo(e) {
2341
+ let t = B.range;
2342
+ if (!t || T.readonly) return 0;
2343
+ Si(!1);
2344
+ let n = I.value, r = 0;
2345
+ return n.transact(() => {
2346
+ for (let i = t.top; i <= t.bottom; i++) {
2347
+ let a = $.value.rowIdAt(i);
2348
+ if (!(a === void 0 || Ur(a))) for (let i = t.left; i <= t.right; i++) {
2349
+ let t = R.value[i];
2350
+ if (!q(t) || t.formula) continue;
2351
+ let o = ae(t, n.get(a, t.key), e, T.valueSettings);
2352
+ o !== null && (n.setCell(a, t.key, o), r++);
2353
+ }
2354
+ }
2355
+ }, { origin: "adjust" }), r;
2356
+ }
2357
+ function Mo() {
2358
+ let e = B.range;
2359
+ if (!e || T.readonly) return 0;
2360
+ Si(!1);
2361
+ let t = [];
2362
+ for (let n = e.top; n <= e.bottom; n++) {
2363
+ let e = $.value.rowIdAt(n), r = e !== void 0 && Ur(e) && Ba.value?.resultOf(e)?.outcome !== "succeeded";
2364
+ e !== void 0 && !r && t.push(e);
2365
+ }
2366
+ return t.length > 0 && (I.value.transact(() => I.value.removeRows(t), { origin: "remove" }), B.moveTo(e.top, B.active?.col ?? 0)), t.length;
2367
+ }
2368
+ function No(e) {
2369
+ if (e.button !== 0 || T.readonly) return;
2370
+ ba(e);
2371
+ let t = Sa(e.clientX), n = q(R.value[t]) ? t : R.value.findIndex((e) => q(e)), r = I.value, i = [];
2372
+ r.transact(() => {
2373
+ i = r.appendRows(Ae(L.value, 1));
2374
+ }, { origin: "insert" });
2375
+ let a = $.value.indexOf(i[0] ?? "");
2376
+ a >= 0 && (B.moveTo(a, Math.max(0, n)), or());
2377
+ }
2378
+ function Po(e) {
2379
+ let t = B.range;
2380
+ if (!t || T.readonly) return [];
2381
+ Si(!1);
2382
+ let n = I.value, r = $.value.rowIdAt(e === "above" ? t.top : t.bottom), i = r === void 0 ? n.size : n.indexOf(r) + +(e === "below"), a = [];
2383
+ n.transact(() => {
2384
+ a = n.insertRows(i, Ae(L.value, t.bottom - t.top + 1));
2385
+ }, { origin: "insert" });
2386
+ let o = $.value.indexOf(a[0] ?? ""), s = $.value.indexOf(a[a.length - 1] ?? "");
2387
+ return o >= 0 && (B.selectRows(o, Math.max(o, s)), or()), a;
2388
+ }
2389
+ let Fo = y(null), Io = g(null), Lo = g(!1), Ro = null, zo = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform);
2390
+ function Bo(e) {
2391
+ return zo ? `⌘${e}` : `Ctrl+${e}`;
2392
+ }
2393
+ let Vo = t(() => {
2394
+ let e = Fo.value, t = U[T.locale], n = T.readonly;
2395
+ if (!e) return [];
2396
+ let r = [
2397
+ {
2398
+ key: "tabula:cut",
2399
+ label: t.cut ?? "",
2400
+ shortcut: Bo("X"),
2401
+ disabled: n
2402
+ },
2403
+ {
2404
+ key: "tabula:copy",
2405
+ label: t.copy ?? "",
2406
+ shortcut: Bo("C")
2407
+ },
2408
+ {
2409
+ key: "tabula:paste",
2410
+ label: t.paste ?? "",
2411
+ shortcut: Bo("V"),
2412
+ disabled: n || typeof navigator > "u" || !navigator.clipboard?.readText
2413
+ },
2414
+ null
2415
+ ];
2416
+ return e.kind === "cell" && r.push({
2417
+ key: "tabula:clear",
2418
+ label: t.clearCells ?? "",
2419
+ shortcut: "Delete",
2420
+ disabled: n
2421
+ }, {
2422
+ key: "tabula:fillDown",
2423
+ label: t.fillDown ?? "",
2424
+ shortcut: Bo("D"),
2425
+ disabled: n
2426
+ }, {
2427
+ key: "tabula:fillRight",
2428
+ label: t.fillRight ?? "",
2429
+ shortcut: Bo("R"),
2430
+ disabled: n
2431
+ }, null), r.push({
2432
+ key: "tabula:insertAbove",
2433
+ label: t.insertAbove ?? "",
2434
+ shortcut: Bo("+"),
2435
+ disabled: n
2436
+ }, {
2437
+ key: "tabula:insertBelow",
2438
+ label: t.insertBelow ?? "",
2439
+ disabled: n
2440
+ }, {
2441
+ key: "tabula:removeRows",
2442
+ label: t.removeRows ?? "",
2443
+ shortcut: Bo("−"),
2444
+ disabled: n
2445
+ }), T.menuItems.length > 0 && r.push(null, ...T.menuItems), e.kind === "cell" && r.push(null, {
2446
+ key: "tabula:filterValue",
2447
+ label: t.filterValue ?? ""
2448
+ }, {
2449
+ key: "tabula:sortAsc",
2450
+ label: t.sortAsc ?? ""
2451
+ }, {
2452
+ key: "tabula:sortDesc",
2453
+ label: t.sortDesc ?? ""
2454
+ }), r;
2455
+ });
2456
+ function Ho(e) {
2457
+ let t = e.target instanceof Element ? e.target : null;
2458
+ if (Y.value || t?.closest(".tabula-grid-filter") || (e.preventDefault(), t?.closest(".tabula-grid-menu"))) return;
2459
+ if (t === Ue.value || e.clientX === 0 && e.clientY === 0) {
2460
+ Uo(null);
2461
+ return;
2462
+ }
2463
+ let n = t?.closest(".tabula-grid-th");
2464
+ if (n) {
2465
+ let t = Number(n.getAttribute("aria-colindex")) - 1;
2466
+ t >= 0 && Ka(t, e.clientX, e.clientY);
2467
+ return;
2468
+ }
2469
+ if (ba(e), t?.closest(".tabula-grid-rh")) {
2470
+ let t = Ca(e.clientY), n = B.range;
2471
+ n && n.left === 0 && n.right >= R.value.length - 1 && t >= n.top && t <= n.bottom || B.selectRows(t), Uo({
2472
+ kind: "row",
2473
+ x: e.clientX,
2474
+ y: e.clientY
2475
+ });
2476
+ return;
2477
+ }
2478
+ let r = ya(e);
2479
+ r && !ti(r.row, r.col) && B.moveTo(r.row, r.col), Uo({
2480
+ kind: "cell",
2481
+ x: e.clientX,
2482
+ y: e.clientY
2483
+ });
2484
+ }
2485
+ function Uo(e) {
2486
+ let t = Re.value, n = B.active;
2487
+ if (!t || !n) return;
2488
+ Si(!1), qa(), Wo();
2489
+ let r = e;
2490
+ if (!r) {
2491
+ let e = t.querySelector(".tabula-grid-active")?.getBoundingClientRect();
2492
+ r = {
2493
+ kind: "cell",
2494
+ x: e?.left ?? 0,
2495
+ y: e?.bottom ?? 0
2496
+ };
2497
+ }
2498
+ let i = r.kind === "cell" ? Rr(n.row, n.col) : [];
2499
+ Fo.value = {
2500
+ kind: r.kind,
2501
+ left: r.x,
2502
+ top: r.y,
2503
+ issues: i.map((e) => Ve(e, T.locale, T.valueSettings))
2504
+ };
2505
+ let a = (e) => {
2506
+ let n = t.querySelector(".tabula-grid-context");
2507
+ e.target instanceof Node && n?.contains(e.target) || Wo();
2508
+ };
2509
+ window.addEventListener("mousedown", a, !0), Ro = () => window.removeEventListener("mousedown", a, !0), u(() => {
2510
+ let e = t.querySelector(".tabula-grid-context"), n = Fo.value;
2511
+ if (!e || !n) return;
2512
+ let r = e.offsetWidth, i = e.offsetHeight, a = Math.max(8, Math.min(n.left, window.innerWidth - r - 8)), o = Math.max(8, Math.min(n.top, window.innerHeight - i - 8));
2513
+ (a !== n.left || o !== n.top) && (Fo.value = {
2514
+ ...n,
2515
+ left: a,
2516
+ top: o
2517
+ }), e.querySelector("button:not(:disabled)")?.focus();
2518
+ });
2519
+ }
2520
+ function Wo(e = !1) {
2521
+ Ro?.(), Ro = null, Fo.value = null, Io.value = null, Lo.value = !1, e && mi();
2522
+ }
2523
+ function Go(e) {
2524
+ if (e.disabled) return;
2525
+ if (e.children && e.children.length > 0) {
2526
+ Io.value = Io.value === e.key ? null : e.key;
2527
+ return;
2528
+ }
2529
+ if (e.key === "tabula:paste") {
2530
+ Ko();
2531
+ return;
2532
+ }
2533
+ Wo(!0);
2534
+ let t = B.range, n = B.active, r = n ? R.value[n.col] : void 0, i = n ? $.value.rowIdAt(n.row) : void 0;
2535
+ switch (e.key) {
2536
+ case "tabula:copy":
2537
+ case "tabula:cut":
2538
+ t && (navigator.clipboard?.writeText(Qi(t)).catch(() => void 0), e.key === "tabula:cut" && ra("cut"));
2539
+ break;
2540
+ case "tabula:clear":
2541
+ ra("clear");
2542
+ break;
2543
+ case "tabula:fillDown":
2544
+ ha("down");
2545
+ break;
2546
+ case "tabula:fillRight":
2547
+ ha("right");
2548
+ break;
2549
+ case "tabula:insertAbove":
2550
+ Po("above");
2551
+ break;
2552
+ case "tabula:insertBelow":
2553
+ Po("below");
2554
+ break;
2555
+ case "tabula:removeRows":
2556
+ Mo();
2557
+ break;
2558
+ case "tabula:filterValue":
2559
+ r && i !== void 0 && _o(r.key, {
2560
+ kind: "values",
2561
+ keys: fe(r, I.value.get(i, r.key))
2562
+ });
2563
+ break;
2564
+ case "tabula:sortAsc":
2565
+ case "tabula:sortDesc":
2566
+ r && (be.value = Object.freeze({
2567
+ key: r.key,
2568
+ direction: e.key === "tabula:sortAsc" ? "asc" : "desc"
2569
+ }));
2570
+ break;
2571
+ default: D("menu", e.key);
2572
+ }
2573
+ }
2574
+ async function Ko() {
2575
+ try {
2576
+ let e = await navigator.clipboard.readText();
2577
+ Wo(!0), na(e);
2578
+ } catch {
2579
+ Lo.value = !0;
2580
+ }
2581
+ }
2582
+ function qo(e) {
2583
+ let t = Re.value?.querySelector(".tabula-grid-context"), n = document.activeElement, r = !!n?.closest(".tabula-grid-submenu"), i = [...(r ? n?.closest(".tabula-grid-submenu") : t)?.querySelectorAll(r ? "button:not(:disabled)" : ":scope > button:not(:disabled), :scope > .tabula-grid-menu-item > button:not(:disabled)") ?? []], a = i.indexOf(n);
2584
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") i[(a + (e.key === "ArrowDown" ? 1 : -1) + i.length) % i.length]?.focus();
2585
+ else if (e.key === "ArrowRight" && !r && n?.dataset.key) {
2586
+ let e = Vo.value.find((e) => e?.key === n.dataset.key);
2587
+ e?.children?.length && (Io.value = e.key, u(() => t?.querySelector(".tabula-grid-submenu button:not(:disabled)")?.focus()));
2588
+ } else if ((e.key === "ArrowLeft" || e.key === "Escape") && r) {
2589
+ let e = Io.value;
2590
+ Io.value = null, u(() => t?.querySelector(`button[data-key="${e}"]`)?.focus());
2591
+ } else if (e.key === "Escape" || e.key === "Tab") Wo(!0);
2592
+ else return;
2593
+ e.preventDefault();
2594
+ }
2595
+ function Jo() {
2596
+ let e = B.active, t = ze.value;
2597
+ return Object.freeze({
2598
+ rowId: e ? $.value.rowIdAt(e.row) ?? null : null,
2599
+ field: e ? R.value[e.col]?.key ?? null : null,
2600
+ top: t?.scrollTop ?? 0,
2601
+ left: t?.scrollLeft ?? 0
2602
+ });
2603
+ }
2604
+ function Yo(e) {
2605
+ let t = e.rowId === null ? -1 : $.value.indexOf(e.rowId), n = e.field === null ? -1 : R.value.findIndex((t) => t.key === e.field);
2606
+ t >= 0 && n >= 0 && B.moveTo(t, n);
2607
+ let r = ze.value;
2608
+ r && (r.scrollTop = e.top, r.scrollLeft = e.left, ar());
2609
+ }
2610
+ function Xo(e, t) {
2611
+ let n = R.value.findIndex((e) => e.key === t), r = I.value.indexOf(e);
2612
+ return n < 0 || r < 0 ? null : `${je(n)}${r + 1}`;
2613
+ }
2614
+ let Zo = t(() => (V.value, ja.value, Object.freeze({
2615
+ shown: $.value.size,
2616
+ total: I.value.size
2617
+ }))), Qo = t(() => (La.value, Ia.value.summary()));
2618
+ function $o(e, t) {
2619
+ return F(e, t, T.valueSettings);
2620
+ }
2621
+ return l({
2622
+ selection: B,
2623
+ cell: To,
2624
+ selected: Oo,
2625
+ rows: Zo,
2626
+ issueSummary: Qo,
2627
+ formatValue: $o,
2628
+ goTo: So,
2629
+ goToAddress: ko,
2630
+ writeCell: Ao,
2631
+ adjustSelection: jo,
2632
+ removeRows: Mo,
2633
+ insertRows: Po,
2634
+ addressOf: Xo,
2635
+ position: Jo,
2636
+ restorePosition: Yo,
2637
+ focus: mi,
2638
+ autoFit: Gn,
2639
+ selectedCells: vr,
2640
+ selectedFields: yr,
2641
+ markSelection: br,
2642
+ toggleSelection: xr,
2643
+ clearSelectionMarks: Sr,
2644
+ canEdit: Cr,
2645
+ showCell: (e, t) => Co(e, t ?? null, !0, !1),
2646
+ shownFields: () => R.value.map((e) => e.key),
2647
+ undo: () => (mi(), Xi("undo")),
2648
+ redo: () => (mi(), Xi("redo"))
2649
+ }), (t, l) => (h(), i("div", {
2650
+ ref_key: "root",
2651
+ ref: Re,
2652
+ class: d(["tabula-grid tabula-theme", {
2653
+ "is-filtered": Ma.value,
2654
+ "is-scrolled-x": nr.value > 0,
2655
+ "is-filling": aa.value,
2656
+ "has-letters": c.columnLetters
2657
+ }]),
2658
+ role: "grid",
2659
+ tabindex: J.value ? -1 : 0,
2660
+ "data-tabula-theme": c.theme,
2661
+ style: f({
2662
+ "--tabula-row-height": `${W.value}px`,
2663
+ "--tabula-zoom": c.zoom
2664
+ }),
2665
+ "aria-rowcount": H.value + 1,
2666
+ "aria-colcount": R.value.length,
2667
+ "aria-readonly": c.readonly || void 0,
2668
+ "aria-multiselectable": "true",
2669
+ "aria-activedescendant": Qr.value,
2670
+ onFocus: hi,
2671
+ onCopy: $i,
2672
+ onCut: ea,
2673
+ onPaste: ta,
2674
+ onContextmenu: Ho
2675
+ }, [
2676
+ a("div", {
2677
+ ref_key: "scroller",
2678
+ ref: ze,
2679
+ class: "tabula-grid-scroller tabula-scroll",
2680
+ onScrollPassive: ar
2681
+ }, [a("div", {
2682
+ class: "tabula-grid-sheet",
2683
+ style: f({
2684
+ width: `${K.value + Mn.value + Cn}px`,
2685
+ height: `${Ln.value + Pn.value + Fn.value + Cn}px`
2686
+ })
2687
+ }, [
2688
+ a("div", {
2689
+ class: "tabula-grid-head",
2690
+ role: "row",
2691
+ "aria-rowindex": "1",
2692
+ style: f({
2693
+ width: `${K.value + Mn.value}px`,
2694
+ height: `${Ln.value}px`
2695
+ })
2696
+ }, [
2697
+ a("div", {
2698
+ class: "tabula-grid-corner",
2699
+ style: f({ width: `${K.value}px` }),
2700
+ onMousedown: Ea
2701
+ }, null, 36),
2702
+ z.value > 0 ? (h(), i("div", {
2703
+ key: 0,
2704
+ class: "tabula-grid-head-pinned",
2705
+ style: f({
2706
+ left: `${K.value}px`,
2707
+ width: `${Nn.value}px`
2708
+ })
2709
+ }, [(h(!0), i(e, null, _(tr.value, (e) => (h(), i("div", {
2710
+ key: e,
2711
+ class: d(["tabula-grid-th is-pinned", [{
2712
+ "is-right": zn.value[e]?.includes("is-right"),
2713
+ "is-center": zn.value[e]?.includes("is-center"),
2714
+ "is-selected": ri(e)
2715
+ }, Do(null, e)]]),
2716
+ role: "columnheader",
2717
+ "aria-colindex": e + 1,
2718
+ "aria-sort": Qa(e),
2719
+ style: f(Hn(e)),
2720
+ title: Bn(e),
2721
+ onMousedown: (t) => wa(t, e)
2722
+ }, [
2723
+ c.columnLetters ? (h(), i("span", {
2724
+ key: 0,
2725
+ class: "tabula-grid-th-letter",
2726
+ "aria-hidden": "true",
2727
+ textContent: b(S(je)(e))
2728
+ }, null, 8, tt)) : r("", !0),
2729
+ R.value[e]?.formula ? (h(), i("span", nt, "ƒx")) : r("", !0),
2730
+ a("span", rt, b(Vn(e)), 1),
2731
+ R.value[e]?.required ? (h(), i("span", it, "*")) : r("", !0),
2732
+ Xa(e) ? (h(), i("span", at, b(Xa(e) === "asc" ? "↑" : "↓"), 1)) : r("", !0),
2733
+ Za(e) ? (h(), i("svg", {
2734
+ key: 4,
2735
+ class: "tabula-grid-filtered",
2736
+ viewBox: "0 0 24 24",
2737
+ role: "img",
2738
+ "aria-label": S(U)[c.locale].filtered
2739
+ }, [...l[19] ||= [a("path", { d: "M3 5h18l-7 8v6l-4 2v-8Z" }, null, -1)]], 8, ot)) : r("", !0),
2740
+ a("button", {
2741
+ type: "button",
2742
+ class: "tabula-grid-th-menu",
2743
+ tabindex: "-1",
2744
+ "aria-label": S(U)[c.locale].columnMenu,
2745
+ onMousedown: O((t) => Ga(t, e), ["stop", "prevent"])
2746
+ }, " ⋯ ", 40, st),
2747
+ Je.value[e]?.resizable ? (h(), i("span", {
2748
+ key: 5,
2749
+ class: "tabula-grid-resize",
2750
+ "aria-hidden": "true",
2751
+ onMousedown: O((t) => Da(t, e), ["stop"]),
2752
+ onDblclick: O((t) => Gn(e), ["stop"])
2753
+ }, null, 40, ct)) : r("", !0)
2754
+ ], 46, et))), 128))], 4)) : r("", !0),
2755
+ (h(!0), i(e, null, _(er.value, (e) => (h(), i("div", {
2756
+ key: e % Qn.value,
2757
+ class: d(["tabula-grid-th", [{
2758
+ "is-right": zn.value[e]?.includes("is-right"),
2759
+ "is-center": zn.value[e]?.includes("is-center"),
2760
+ "is-selected": ri(e)
2761
+ }, Do(null, e)]]),
2762
+ role: "columnheader",
2763
+ "aria-colindex": e + 1,
2764
+ "aria-sort": Qa(e),
2765
+ style: f(Hn(e)),
2766
+ title: Bn(e),
2767
+ onMousedown: (t) => wa(t, e)
2768
+ }, [
2769
+ c.columnLetters ? (h(), i("span", {
2770
+ key: 0,
2771
+ class: "tabula-grid-th-letter",
2772
+ "aria-hidden": "true",
2773
+ textContent: b(S(je)(e))
2774
+ }, null, 8, ut)) : r("", !0),
2775
+ R.value[e]?.formula ? (h(), i("span", dt, "ƒx")) : r("", !0),
2776
+ a("span", ft, b(Vn(e)), 1),
2777
+ R.value[e]?.required ? (h(), i("span", pt, "*")) : r("", !0),
2778
+ Xa(e) ? (h(), i("span", mt, b(Xa(e) === "asc" ? "↑" : "↓"), 1)) : r("", !0),
2779
+ Za(e) ? (h(), i("svg", {
2780
+ key: 4,
2781
+ class: "tabula-grid-filtered",
2782
+ viewBox: "0 0 24 24",
2783
+ role: "img",
2784
+ "aria-label": S(U)[c.locale].filtered
2785
+ }, [...l[20] ||= [a("path", { d: "M3 5h18l-7 8v6l-4 2v-8Z" }, null, -1)]], 8, ht)) : r("", !0),
2786
+ a("button", {
2787
+ type: "button",
2788
+ class: "tabula-grid-th-menu",
2789
+ tabindex: "-1",
2790
+ "aria-label": S(U)[c.locale].columnMenu,
2791
+ onMousedown: O((t) => Ga(t, e), ["stop", "prevent"])
2792
+ }, " ⋯ ", 40, gt),
2793
+ Je.value[e]?.resizable ? (h(), i("span", {
2794
+ key: 5,
2795
+ class: "tabula-grid-resize",
2796
+ "aria-hidden": "true",
2797
+ onMousedown: O((t) => Da(t, e), ["stop"]),
2798
+ onDblclick: O((t) => Gn(e), ["stop"])
2799
+ }, null, 40, _t)) : r("", !0)
2800
+ ], 46, lt))), 128))
2801
+ ], 4),
2802
+ a("div", {
2803
+ ref_key: "gutter",
2804
+ ref: Be,
2805
+ class: "tabula-grid-gutter",
2806
+ "aria-hidden": "true",
2807
+ style: f({
2808
+ width: `${K.value}px`,
2809
+ height: `${Pn.value + Fn.value}px`
2810
+ })
2811
+ }, [(h(!0), i(e, null, _($n.value, (e) => (h(), i("div", {
2812
+ key: e % Zn.value,
2813
+ class: d(["tabula-grid-rh", [{ "is-selected": ni(e) }, Kr(e)]]),
2814
+ title: Jr(e),
2815
+ style: f({ transform: `translateY(${e * W.value}px)` }),
2816
+ onMousedown: (t) => Ta(t, e)
2817
+ }, [o(b(Na(e)) + " ", 1), qr(e) ? (h(), i("span", {
2818
+ key: 0,
2819
+ class: d(["tabula-grid-rh-mark", qr(e)])
2820
+ }, null, 2)) : r("", !0)], 46, vt))), 128)), Fn.value > 0 ? (h(), i("div", {
2821
+ key: 0,
2822
+ class: "tabula-grid-rh is-new",
2823
+ style: f({ transform: `translateY(${Pn.value}px)` }),
2824
+ onMousedown: No
2825
+ }, " + ", 36)) : r("", !0)], 4),
2826
+ a("div", {
2827
+ ref_key: "body",
2828
+ ref: He,
2829
+ class: "tabula-grid-body",
2830
+ "data-version": V.value,
2831
+ style: f({
2832
+ top: `${Ln.value}px`,
2833
+ left: `${K.value}px`,
2834
+ width: `${Mn.value}px`,
2835
+ height: `${Pn.value + Fn.value}px`
2836
+ }),
2837
+ onMousedown: xa,
2838
+ onDblclick: l[3] ||= (e) => _i()
2839
+ }, [
2840
+ z.value > 0 ? (h(), i("div", {
2841
+ key: 0,
2842
+ class: "tabula-grid-pinned",
2843
+ style: f({
2844
+ left: `${K.value}px`,
2845
+ width: `${Nn.value}px`,
2846
+ height: `${Pn.value}px`
2847
+ })
2848
+ }, [
2849
+ (h(!0), i(e, null, _($n.value, (t) => (h(), i("div", {
2850
+ key: t % Zn.value,
2851
+ class: d(["tabula-grid-row", { "is-locked": Wr(t) }]),
2852
+ role: "presentation",
2853
+ "data-row": t,
2854
+ style: f({ transform: `translateY(${t * W.value}px)` })
2855
+ }, [(h(!0), i(e, null, _(tr.value, (e) => (h(), i("div", {
2856
+ id: `${S(Le)}-${t}-${e}`,
2857
+ key: e,
2858
+ class: d(["tabula-grid-cell", [
2859
+ zn.value[e],
2860
+ Br(t, e),
2861
+ ur(t, e),
2862
+ Lr(t, e),
2863
+ Do(t, e),
2864
+ hr(t, e),
2865
+ _r(t, e)
2866
+ ]]),
2867
+ role: "gridcell",
2868
+ "aria-colindex": e + 1,
2869
+ "aria-selected": ti(t, e),
2870
+ "aria-readonly": !q(R.value[e]) || Wr(t) || void 0,
2871
+ "aria-invalid": Br(t, e) === "is-error" ? "true" : void 0,
2872
+ style: f(In.value[e]),
2873
+ title: Hr(t, e)
2874
+ }, b(sr(t, e)), 15, xt))), 128))], 14, bt))), 128)),
2875
+ oi.value.pinned ? (h(), i("div", {
2876
+ key: 0,
2877
+ class: "tabula-grid-range",
2878
+ style: f(oi.value.pinned)
2879
+ }, null, 4)) : r("", !0),
2880
+ J.value && li.value ? (h(), i("div", {
2881
+ key: 1,
2882
+ class: "tabula-grid-active",
2883
+ style: f(ui.value)
2884
+ }, null, 4)) : r("", !0),
2885
+ ci.value?.pinned ? (h(), i("div", {
2886
+ key: 2,
2887
+ class: "tabula-grid-fill-preview",
2888
+ style: f(ci.value.pinned)
2889
+ }, null, 4)) : r("", !0),
2890
+ si.value?.pinned ? (h(), i("div", {
2891
+ key: 3,
2892
+ class: "tabula-grid-fill",
2893
+ style: f(si.value.style),
2894
+ title: S(U)[c.locale].fillHandle,
2895
+ "aria-hidden": "true",
2896
+ onMousedown: O(pa, ["stop"]),
2897
+ onDblclick: O(ma, ["stop"])
2898
+ }, null, 44, St)) : r("", !0)
2899
+ ], 4)) : r("", !0),
2900
+ (h(!0), i(e, null, _($n.value, (t) => (h(), i("div", {
2901
+ key: t % Zn.value,
2902
+ class: d(["tabula-grid-row", { "is-locked": Wr(t) }]),
2903
+ role: "row",
2904
+ "aria-rowindex": t + 2,
2905
+ "data-row": t,
2906
+ "aria-owns": z.value > 0 ? tr.value.map((e) => `${S(Le)}-${t}-${e}`).join(" ") : void 0,
2907
+ style: f({ transform: `translateY(${t * W.value}px)` })
2908
+ }, [(h(!0), i(e, null, _(er.value, (e) => (h(), i("div", {
2909
+ id: ei(t, e) ? Qr.value : void 0,
2910
+ key: e % Qn.value,
2911
+ class: d(["tabula-grid-cell", [
2912
+ zn.value[e],
2913
+ Br(t, e),
2914
+ ur(t, e),
2915
+ Lr(t, e),
2916
+ Do(t, e),
2917
+ hr(t, e),
2918
+ _r(t, e)
2919
+ ]]),
2920
+ role: "gridcell",
2921
+ "aria-colindex": e + 1,
2922
+ "aria-selected": ti(t, e),
2923
+ "aria-readonly": !q(R.value[e]) || Wr(t) || void 0,
2924
+ "aria-invalid": Br(t, e) === "is-error" ? "true" : void 0,
2925
+ style: f(In.value[e]),
2926
+ title: Hr(t, e)
2927
+ }, b(sr(t, e)), 15, wt))), 128))], 14, Ct))), 128)),
2928
+ Fn.value > 0 ? (h(), i("div", {
2929
+ key: 1,
2930
+ class: "tabula-grid-new-row",
2931
+ role: "button",
2932
+ "aria-label": S(U)[c.locale].newRow,
2933
+ style: f({
2934
+ transform: `translateY(${Pn.value}px)`,
2935
+ height: `${Fn.value}px`
2936
+ }),
2937
+ onMousedown: O(No, ["stop"]),
2938
+ onDblclick: l[0] ||= O(() => {}, ["stop"])
2939
+ }, [a("span", {
2940
+ class: "tabula-grid-new-row-text",
2941
+ style: f({ left: `${K.value}px` }),
2942
+ textContent: b(S(U)[c.locale].newRow)
2943
+ }, null, 12, Et)], 44, Tt)) : r("", !0),
2944
+ oi.value.free ? (h(), i("div", {
2945
+ key: 2,
2946
+ class: "tabula-grid-range",
2947
+ style: f(oi.value.free)
2948
+ }, null, 4)) : r("", !0),
2949
+ J.value && !li.value ? (h(), i("div", {
2950
+ key: 3,
2951
+ class: "tabula-grid-active",
2952
+ style: f(ui.value)
2953
+ }, null, 4)) : r("", !0),
2954
+ ci.value?.free ? (h(), i("div", {
2955
+ key: 4,
2956
+ class: "tabula-grid-fill-preview",
2957
+ style: f(ci.value.free)
2958
+ }, null, 4)) : r("", !0),
2959
+ si.value && !si.value.pinned ? (h(), i("div", {
2960
+ key: 5,
2961
+ class: "tabula-grid-fill",
2962
+ style: f(si.value.style),
2963
+ title: S(U)[c.locale].fillHandle,
2964
+ "aria-hidden": "true",
2965
+ onMousedown: O(pa, ["stop"]),
2966
+ onDblclick: O(ma, ["stop"])
2967
+ }, null, 44, Dt)) : r("", !0),
2968
+ J.value ? te((h(), i("input", {
2969
+ key: 6,
2970
+ ref_key: "editor",
2971
+ ref: Ue,
2972
+ "onUpdate:modelValue": l[1] ||= (e) => X.value = e,
2973
+ class: d(["tabula-grid-input", Y.value ? ["is-editing", zn.value[Y.value.col]] : void 0]),
2974
+ style: f(Y.value ? pi.value : di.value),
2975
+ "aria-label": $r.value,
2976
+ role: ji.value ? "combobox" : void 0,
2977
+ "aria-autocomplete": ji.value ? "list" : void 0,
2978
+ "aria-expanded": ji.value ? Ai.value : void 0,
2979
+ "aria-controls": ji.value ? Di : void 0,
2980
+ "aria-activedescendant": Ai.value && Z.value >= 0 ? `${Di}-${Z.value}` : void 0,
2981
+ placeholder: Q.value ? `${Q.value.size} ${S(U)[c.locale].picked}` : void 0,
2982
+ autocomplete: "off",
2983
+ spellcheck: "false",
2984
+ onKeydown: bi,
2985
+ onInput: vi,
2986
+ onCompositionstart: yi,
2987
+ onBlur: xi,
2988
+ onMousedown: l[2] ||= O(() => {}, ["stop"])
2989
+ }, null, 46, Ot)), [[ee, X.value]]) : r("", !0)
2990
+ ], 44, yt)
2991
+ ], 4)], 544),
2992
+ s(Pe, {
2993
+ target: ze.value,
2994
+ "inset-top": Ln.value,
2995
+ "inset-left": K.value + Nn.value
2996
+ }, null, 8, [
2997
+ "target",
2998
+ "inset-top",
2999
+ "inset-left"
3000
+ ]),
3001
+ Fr.value ? (h(), i("div", {
3002
+ key: 0,
3003
+ class: "tabula-grid-totals",
3004
+ role: "row",
3005
+ style: f({ height: `${W.value}px` })
3006
+ }, [(h(!0), i(e, null, _([...tr.value, ...er.value.filter((e) => e >= z.value)], (t) => (h(), i(e, { key: t }, [Fr.value[t] === null ? r("", !0) : (h(), i("div", {
3007
+ key: 0,
3008
+ class: d(["tabula-grid-totals-cell", { "is-pinned": t < z.value }]),
3009
+ role: "gridcell",
3010
+ style: f(Ir(t))
3011
+ }, b(Fr.value[t]), 7))], 64))), 128)), a("div", {
3012
+ class: "tabula-grid-totals-kind",
3013
+ style: f({ width: `${K.value + (Fr.value[0] === null ? An.value[0] ?? 0 : 0)}px` })
3014
+ }, [a("button", {
3015
+ ref_key: "totalButton",
3016
+ ref: kr,
3017
+ type: "button",
3018
+ class: d(["tabula-grid-totals-pick", { "is-open": Dr.value }]),
3019
+ "aria-haspopup": "listbox",
3020
+ "aria-expanded": Dr.value !== null,
3021
+ "aria-label": S(U)[c.locale].totals,
3022
+ title: S(U)[c.locale].totals,
3023
+ onClick: l[4] ||= (e) => Dr.value ? Mr() : jr(),
3024
+ onKeydown: Pr
3025
+ }, [a("span", {
3026
+ class: "tabula-grid-totals-word",
3027
+ textContent: b(S(U)[c.locale][Tr[Er.value]])
3028
+ }, null, 8, At), l[21] ||= a("svg", {
3029
+ class: "tabula-grid-totals-chevron",
3030
+ viewBox: "0 0 24 24",
3031
+ "aria-hidden": "true"
3032
+ }, [a("path", { d: "m6 9 6 6 6-6" })], -1)], 42, kt)], 4)], 4)) : r("", !0),
3033
+ Dr.value ? (h(), i("ul", {
3034
+ key: 1,
3035
+ class: "tabula-grid-totals-menu",
3036
+ role: "listbox",
3037
+ "aria-label": S(U)[c.locale].totals,
3038
+ style: f({
3039
+ left: `${Dr.value.left}px`,
3040
+ bottom: `${Dr.value.bottom}px`,
3041
+ minWidth: `${Dr.value.width}px`
3042
+ })
3043
+ }, [(h(), i(e, null, _(wr, (e) => a("li", {
3044
+ key: e,
3045
+ role: "option",
3046
+ "aria-selected": e === Er.value,
3047
+ class: d({
3048
+ "is-active": e === Or.value,
3049
+ "is-selected": e === Er.value
3050
+ }),
3051
+ onMouseenter: (t) => Or.value = e,
3052
+ onClick: (t) => Nr(e)
3053
+ }, [a("span", { textContent: b(S(U)[c.locale][Tr[e]]) }, null, 8, Nt), e === Er.value ? (h(), i("svg", Pt, [...l[22] ||= [a("path", { d: "m5 12 5 5 9-10" }, null, -1)]])) : r("", !0)], 42, Mt)), 64))], 12, jt)) : r("", !0),
3054
+ Ai.value ? (h(), i("ul", {
3055
+ key: 2,
3056
+ id: Di,
3057
+ ref_key: "suggestionList",
3058
+ ref: Ge,
3059
+ class: d(["tabula-grid-list tabula-scroll", { "is-multiple": Q.value }]),
3060
+ role: "listbox",
3061
+ "aria-multiselectable": Q.value ? "true" : void 0,
3062
+ style: f(Ei.value ? {
3063
+ left: `${Ei.value.left}px`,
3064
+ top: `${Ei.value.top}px`,
3065
+ minWidth: `${Ei.value.width}px`
3066
+ } : { visibility: "hidden" })
3067
+ }, [
3068
+ (h(!0), i(e, null, _(wi.value, (e, t) => (h(), i("li", {
3069
+ id: `${Di}-${t}`,
3070
+ key: e.key,
3071
+ class: d(["tabula-grid-option", {
3072
+ "is-highlighted": t === Z.value,
3073
+ "is-disabled": e.disabled,
3074
+ "is-picked": Q.value?.has(e.key)
3075
+ }]),
3076
+ role: "option",
3077
+ "aria-selected": Q.value ? Q.value.has(e.key) : t === Z.value,
3078
+ "aria-disabled": e.disabled || void 0,
3079
+ onMousedown: O((e) => Bi(t), ["prevent"]),
3080
+ onMousemove: (n) => e.disabled || (Z.value = t)
3081
+ }, [
3082
+ Q.value ? (h(), i("span", Lt)) : r("", !0),
3083
+ a("span", Rt, b(e.label), 1),
3084
+ e.description ? (h(), i("span", zt, b(e.description), 1)) : r("", !0)
3085
+ ], 42, It))), 128)),
3086
+ Ti.value ? (h(), i("li", Bt, b(S(U)[c.locale][Ti.value]), 1)) : r("", !0),
3087
+ Q.value ? (h(), i("li", Vt, b(S(U)[c.locale].pickHint), 1)) : r("", !0)
3088
+ ], 14, Ft)) : r("", !0),
3089
+ Ai.value ? (h(), n(Pe, {
3090
+ key: 3,
3091
+ target: Ge.value,
3092
+ layer: 5
3093
+ }, null, 8, ["target"])) : r("", !0),
3094
+ Ha.value ? (h(), i("div", {
3095
+ key: 4,
3096
+ class: "tabula-grid-menu",
3097
+ role: "menu",
3098
+ "aria-label": S(U)[c.locale].columnMenu,
3099
+ style: f({
3100
+ left: `${Ha.value.left}px`,
3101
+ top: `${Ha.value.top}px`
3102
+ }),
3103
+ onKeydown: Ya
3104
+ }, [
3105
+ a("button", {
3106
+ type: "button",
3107
+ role: "menuitem",
3108
+ class: "tabula-grid-menu-sort-asc",
3109
+ onClick: l[5] ||= (e) => Ja("sortAsc")
3110
+ }, b(S(U)[c.locale].sortAsc), 1),
3111
+ a("button", {
3112
+ type: "button",
3113
+ role: "menuitem",
3114
+ class: "tabula-grid-menu-sort-desc",
3115
+ onClick: l[6] ||= (e) => Ja("sortDesc")
3116
+ }, b(S(U)[c.locale].sortDesc), 1),
3117
+ Xa(Ha.value.col) ? (h(), i("button", {
3118
+ key: 0,
3119
+ type: "button",
3120
+ role: "menuitem",
3121
+ class: "tabula-grid-menu-sort-clear",
3122
+ onClick: l[7] ||= (e) => Ja("sortClear")
3123
+ }, b(S(U)[c.locale].sortClear), 1)) : r("", !0),
3124
+ l[23] ||= a("span", {
3125
+ class: "tabula-grid-menu-line",
3126
+ role: "separator"
3127
+ }, null, -1),
3128
+ a("button", {
3129
+ type: "button",
3130
+ role: "menuitem",
3131
+ class: "tabula-grid-menu-filter",
3132
+ onClick: l[8] ||= (e) => Ja("filter")
3133
+ }, b(S(U)[c.locale].filter), 1),
3134
+ Za(Ha.value.col) ? (h(), i("button", {
3135
+ key: 1,
3136
+ type: "button",
3137
+ role: "menuitem",
3138
+ class: "tabula-grid-menu-filter-clear",
3139
+ onClick: l[9] ||= (e) => Ja("filterClear")
3140
+ }, b(S(U)[c.locale].filterClear), 1)) : r("", !0),
3141
+ l[24] ||= a("span", {
3142
+ class: "tabula-grid-menu-line",
3143
+ role: "separator"
3144
+ }, null, -1),
3145
+ a("button", {
3146
+ type: "button",
3147
+ role: "menuitem",
3148
+ class: "tabula-grid-menu-pin",
3149
+ onClick: l[10] ||= (e) => Ja(Ha.value.col < z.value ? "unpin" : "pin")
3150
+ }, b(Ha.value.col < z.value ? S(U)[c.locale].unpin : S(U)[c.locale].pin), 1),
3151
+ a("button", {
3152
+ type: "button",
3153
+ role: "menuitem",
3154
+ class: "tabula-grid-menu-hide",
3155
+ disabled: R.value.length <= 1,
3156
+ onClick: l[11] ||= (e) => Ja("hide")
3157
+ }, b(S(U)[c.locale].hide), 9, Ut),
3158
+ Wa.value > 0 ? (h(), i("button", {
3159
+ key: 2,
3160
+ type: "button",
3161
+ role: "menuitem",
3162
+ class: "tabula-grid-menu-show",
3163
+ onClick: l[12] ||= (e) => Ja("showHidden")
3164
+ }, b(S(U)[c.locale].showHidden) + " (" + b(Wa.value) + ") ", 1)) : r("", !0)
3165
+ ], 44, Ht)) : r("", !0),
3166
+ Fo.value ? (h(), i("div", {
3167
+ key: 5,
3168
+ class: "tabula-grid-menu tabula-grid-context",
3169
+ role: "menu",
3170
+ "aria-label": S(U)[c.locale].cellMenu,
3171
+ style: f({
3172
+ left: `${Fo.value.left}px`,
3173
+ top: `${Fo.value.top}px`
3174
+ }),
3175
+ onKeydown: qo,
3176
+ onContextmenu: l[14] ||= O(() => {}, ["prevent"])
3177
+ }, [
3178
+ Lo.value ? (h(), i("p", {
3179
+ key: 0,
3180
+ class: "tabula-grid-menu-note is-hint",
3181
+ role: "status",
3182
+ textContent: b(S(U)[c.locale].pasteRefused)
3183
+ }, null, 8, Gt)) : r("", !0),
3184
+ Fo.value.issues.length > 0 ? (h(), i(e, { key: 1 }, [(h(!0), i(e, null, _(Fo.value.issues, (e, t) => (h(), i("p", {
3185
+ key: t,
3186
+ class: "tabula-grid-menu-note",
3187
+ textContent: b(e)
3188
+ }, null, 8, Kt))), 128)), l[25] ||= a("span", {
3189
+ class: "tabula-grid-menu-line",
3190
+ role: "separator"
3191
+ }, null, -1)], 64)) : r("", !0),
3192
+ (h(!0), i(e, null, _(Vo.value, (t, n) => (h(), i(e, { key: t?.key ?? `line-${n}` }, [t === null ? (h(), i("span", qt)) : t.children?.length ? (h(), i("div", Jt, [a("button", {
3193
+ type: "button",
3194
+ role: "menuitem",
3195
+ "aria-haspopup": "menu",
3196
+ "aria-expanded": Io.value === t.key,
3197
+ "data-key": t.key,
3198
+ disabled: t.disabled,
3199
+ onClick: (e) => Go(t),
3200
+ onMouseenter: (e) => Io.value = t.key
3201
+ }, [a("span", { textContent: b(t.label) }, null, 8, Xt), l[26] ||= a("span", {
3202
+ class: "tabula-grid-menu-key",
3203
+ "aria-hidden": "true"
3204
+ }, "▸", -1)], 40, Yt), Io.value === t.key ? (h(), i("div", {
3205
+ key: 0,
3206
+ class: "tabula-grid-menu tabula-grid-submenu",
3207
+ role: "menu",
3208
+ "aria-label": t.label
3209
+ }, [(h(!0), i(e, null, _(t.children, (e) => (h(), i("button", {
3210
+ key: e.key,
3211
+ type: "button",
3212
+ role: "menuitem",
3213
+ disabled: e.disabled,
3214
+ onClick: (t) => Go(e)
3215
+ }, [a("span", { textContent: b(e.label) }, null, 8, $t), e.shortcut ? (h(), i("span", {
3216
+ key: 0,
3217
+ class: "tabula-grid-menu-key",
3218
+ textContent: b(e.shortcut)
3219
+ }, null, 8, en)) : r("", !0)], 8, Qt))), 128))], 8, Zt)) : r("", !0)])) : (h(), i("button", {
3220
+ key: 2,
3221
+ type: "button",
3222
+ role: "menuitem",
3223
+ "data-key": t.key,
3224
+ disabled: t.disabled,
3225
+ onClick: (e) => Go(t),
3226
+ onMouseenter: l[13] ||= (e) => Io.value = null
3227
+ }, [a("span", { textContent: b(t.label) }, null, 8, nn), t.shortcut ? (h(), i("span", {
3228
+ key: 0,
3229
+ class: "tabula-grid-menu-key",
3230
+ textContent: b(t.shortcut)
3231
+ }, null, 8, rn)) : r("", !0)], 40, tn))], 64))), 128))
3232
+ ], 44, Wt)) : r("", !0),
3233
+ $a.value ? (h(), i("div", {
3234
+ key: 6,
3235
+ class: "tabula-grid-filter",
3236
+ role: "dialog",
3237
+ "aria-label": `${S(U)[c.locale].filterTitle}: ${$a.value.field.label}`,
3238
+ style: f({
3239
+ left: `${$a.value.left}px`,
3240
+ top: `${$a.value.top}px`
3241
+ }),
3242
+ onKeydown: bo
3243
+ }, [
3244
+ a("strong", on, b($a.value.field.label), 1),
3245
+ $a.value.range ? (h(), i("div", sn, [a("label", null, [a("span", null, b(S(U)[c.locale].from), 1), te(a("input", {
3246
+ "onUpdate:modelValue": l[15] ||= (e) => no.value = e,
3247
+ class: "tabula-grid-filter-from",
3248
+ type: "text",
3249
+ autocomplete: "off"
3250
+ }, null, 512), [[ee, no.value]])]), a("label", null, [a("span", null, b(S(U)[c.locale].to), 1), te(a("input", {
3251
+ "onUpdate:modelValue": l[16] ||= (e) => ro.value = e,
3252
+ class: "tabula-grid-filter-to",
3253
+ type: "text",
3254
+ autocomplete: "off"
3255
+ }, null, 512), [[ee, ro.value]])])])) : r("", !0),
3256
+ io.value ? (h(), i("p", cn, b(io.value), 1)) : r("", !0),
3257
+ te(a("input", {
3258
+ "onUpdate:modelValue": l[17] ||= (e) => eo.value = e,
3259
+ class: "tabula-grid-filter-search",
3260
+ type: "search",
3261
+ autocomplete: "off",
3262
+ placeholder: S(U)[c.locale].search,
3263
+ "aria-label": S(U)[c.locale].search
3264
+ }, null, 8, ln), [[ee, eo.value]]),
3265
+ a("label", un, [a("input", {
3266
+ type: "checkbox",
3267
+ checked: co.value,
3268
+ indeterminate: lo.value && !co.value,
3269
+ onChange: ho
3270
+ }, null, 40, dn), o(" " + b(S(U)[c.locale].selectAll), 1)]),
3271
+ a("ul", {
3272
+ ref_key: "filterList",
3273
+ ref: Ke,
3274
+ class: "tabula-grid-filter-list tabula-scroll"
3275
+ }, [(h(!0), i(e, null, _(so.value, (e) => (h(), i("li", { key: e.key }, [a("label", null, [
3276
+ a("input", {
3277
+ type: "checkbox",
3278
+ checked: to.value.has(e.key),
3279
+ onChange: (t) => mo(e.key)
3280
+ }, null, 40, fn),
3281
+ a("span", pn, b(oo(e)), 1),
3282
+ a("span", mn, b(e.count), 1)
3283
+ ])]))), 128))], 512),
3284
+ s(Pe, { target: Ke.value }, null, 8, ["target"]),
3285
+ $a.value.more > 0 ? (h(), i("p", hn, " +" + b($a.value.more) + " " + b(S(U)[c.locale].moreValues), 1)) : r("", !0),
3286
+ a("div", gn, [
3287
+ a("button", {
3288
+ type: "button",
3289
+ class: "tabula-grid-filter-apply",
3290
+ onClick: vo
3291
+ }, b(S(U)[c.locale].apply), 1),
3292
+ a("button", {
3293
+ type: "button",
3294
+ class: "tabula-grid-filter-clear",
3295
+ onClick: yo
3296
+ }, b(S(U)[c.locale].clear), 1),
3297
+ a("button", {
3298
+ type: "button",
3299
+ class: "tabula-grid-filter-cancel",
3300
+ onClick: l[18] ||= (e) => po(!0)
3301
+ }, b(S(U)[c.locale].cancel), 1)
3302
+ ])
3303
+ ], 44, an)) : r("", !0),
3304
+ a("div", {
3305
+ ref_key: "headerProbe",
3306
+ ref: We,
3307
+ class: "tabula-grid-th tabula-grid-probe",
3308
+ "aria-hidden": "true"
3309
+ }, null, 512),
3310
+ a("div", {
3311
+ ref_key: "cellProbe",
3312
+ ref: qe,
3313
+ class: "tabula-grid-cell tabula-grid-probe",
3314
+ "aria-hidden": "true"
3315
+ }, null, 512)
3316
+ ], 46, $e));
3317
+ }
3318
+ }), W = ["data-tabula-theme", "aria-label"], An = ["aria-expanded", "aria-label"], jn = [
3319
+ "role",
3320
+ "aria-modal",
3321
+ "aria-label"
3322
+ ], G = {
3323
+ key: 0,
3324
+ class: "tabula-issues-handle",
3325
+ "aria-hidden": "true"
3326
+ }, Mn = { class: "tabula-issues-head" }, Nn = { class: "tabula-issues-titles" }, Pn = { class: "tabula-issues-title" }, Fn = { class: "tabula-issues-nav" }, K = ["disabled"], In = ["disabled"], Ln = ["aria-label"], Rn = { class: "tabula-issues-counts" }, zn = { class: "tabula-issues-count is-error" }, q = {
3327
+ key: 0,
3328
+ class: "tabula-issues-count is-warning"
3329
+ }, Bn = {
3330
+ key: 1,
3331
+ class: "tabula-issues-count is-stale"
3332
+ }, Vn = { class: "tabula-issues-rows" }, Hn = {
3333
+ key: 0,
3334
+ class: "tabula-issues-filter"
3335
+ }, Un = ["title"], Wn = {
3336
+ key: 1,
3337
+ class: "tabula-issues-none"
3338
+ }, Gn = ["onClick"], Kn = { class: "tabula-issues-line" }, qn = { class: "tabula-issues-where" }, Jn = ["textContent"], Yn = { class: "tabula-issues-source" }, Xn = ["textContent"], Zn = { class: "tabula-issues-text" }, Qn = {
3339
+ key: 1,
3340
+ class: "tabula-issues-recheck"
3341
+ }, $n = {
3342
+ key: 2,
3343
+ class: "tabula-issues-go",
3344
+ "aria-hidden": "true"
3345
+ }, er = {
3346
+ key: 0,
3347
+ class: "tabula-issues-more"
3348
+ }, tr = {
3349
+ key: 4,
3350
+ class: "tabula-issues-actions"
3351
+ }, nr = /* @__PURE__ */ c({
3352
+ __name: "TabulaIssues",
3353
+ props: /*@__PURE__*/ l({
3354
+ issues: {
3355
+ type: Object,
3356
+ required: !0
3357
+ },
3358
+ schema: {
3359
+ type: Object,
3360
+ required: !0
3361
+ },
3362
+ store: {
3363
+ type: Object,
3364
+ required: !0
3365
+ },
3366
+ locale: {
3367
+ type: String,
3368
+ default: "tr"
3369
+ },
3370
+ valueSettings: {
3371
+ type: Object,
3372
+ default: () => N.tr
3373
+ },
3374
+ theme: {
3375
+ type: String,
3376
+ default: "light"
3377
+ },
3378
+ limit: {
3379
+ type: Number,
3380
+ default: 500
3381
+ },
3382
+ variant: {
3383
+ type: String,
3384
+ default: "panel"
3385
+ },
3386
+ addressOf: {
3387
+ type: Function,
3388
+ default: void 0
3389
+ },
3390
+ nameField: {
3391
+ type: String,
3392
+ default: null
3393
+ },
3394
+ closable: {
3395
+ type: Boolean,
3396
+ default: !1
3397
+ }
3398
+ }, {
3399
+ onlyIssueRows: { type: Boolean },
3400
+ onlyIssueRowsModifiers: {},
3401
+ open: {
3402
+ type: Boolean,
3403
+ default: !1
3404
+ },
3405
+ openModifiers: {}
3406
+ }),
3407
+ emits: /*@__PURE__*/ l([
3408
+ "select",
3409
+ "refreshRows",
3410
+ "close"
3411
+ ], ["update:onlyIssueRows", "update:open"]),
3412
+ setup(s, { expose: c, emit: l }) {
3413
+ let u = s, f = l, p = w(s, "onlyIssueRows"), m = w(s, "open"), C = t(() => u.variant === "sheet");
3414
+ function ee() {
3415
+ m.value = !1, f("close");
3416
+ }
3417
+ let D = y(0), O = y(null);
3418
+ E(() => x(u.issues), (e, t, n) => {
3419
+ D.value++, n(e.subscribe(() => D.value++));
3420
+ }, { immediate: !0 });
3421
+ let k = t(() => (D.value, x(u.issues).issues())), A = t(() => (D.value, x(u.issues).summary())), j = t(() => k.value.slice(0, u.limit)), M = t(() => Ie[u.locale]), ne = g(null);
3422
+ function re(e) {
3423
+ if (e.rowId === null) return M.value.sheet ?? "";
3424
+ let t = x(u.store), n = x(u.schema);
3425
+ return [`${M.value.row} ${t.indexOf(e.rowId) + 1}`, e.field !== null && n.has(e.field) ? n.field(e.field).label : ""].filter(Boolean).join(" · ");
3426
+ }
3427
+ function ie(e) {
3428
+ return e.rowId !== null && e.field !== null && u.addressOf ? u.addressOf(e.rowId, e.field) : null;
3429
+ }
3430
+ function N(e) {
3431
+ let t = x(u.schema);
3432
+ if (e.rowId === null || u.nameField === null || !t.has(u.nameField)) return "";
3433
+ let n = x(u.store).get(e.rowId, u.nameField);
3434
+ return F(t.field(u.nameField), n, u.valueSettings);
3435
+ }
3436
+ function ae(e) {
3437
+ return [e.stale ? "is-stale" : `is-${e.severity}`, e.id === O.value ? "is-current" : ""];
3438
+ }
3439
+ function oe(e) {
3440
+ return e.source === "local" ? M.value.local ?? "" : M.value.server ?? "";
3441
+ }
3442
+ let se = t(() => {
3443
+ let e = A.value, t = [
3444
+ e.errors > 0 ? `${e.errors} ${M.value.errors}` : "",
3445
+ e.warnings > 0 ? `${e.warnings} ${M.value.warnings}` : "",
3446
+ e.stale > 0 ? `${e.stale} ${M.value.stale}` : ""
3447
+ ].filter(Boolean);
3448
+ return t.length > 0 ? t.join(" · ") : M.value.none ?? "";
3449
+ }), ce = t(() => {
3450
+ let e = A.value;
3451
+ return e.errors > 0 ? "is-error" : e.warnings > 0 ? "is-warning" : e.stale > 0 ? "is-stale" : "is-clear";
3452
+ });
3453
+ function le(e) {
3454
+ O.value = e.id, m.value = !1, f("select", e);
3455
+ }
3456
+ function ue(e) {
3457
+ let t = k.value;
3458
+ if (t.length === 0) return;
3459
+ let n = t.findIndex((e) => e.id === O.value), r = t[n < 0 ? e > 0 ? 0 : t.length - 1 : (n + e + t.length) % t.length];
3460
+ r && le(r);
3461
+ }
3462
+ return c({
3463
+ next: () => ue(1),
3464
+ previous: () => ue(-1)
3465
+ }), (t, c) => (h(), i("section", {
3466
+ class: d(["tabula-issues tabula-theme", {
3467
+ "is-sheet": C.value,
3468
+ "is-open": C.value && m.value
3469
+ }]),
3470
+ "data-tabula-theme": s.theme,
3471
+ "aria-label": M.value.title
3472
+ }, [
3473
+ C.value ? (h(), i("button", {
3474
+ key: 0,
3475
+ type: "button",
3476
+ class: d(["tabula-issues-bar", ce.value]),
3477
+ "aria-expanded": m.value,
3478
+ "aria-label": `${M.value.open}: ${se.value}`,
3479
+ onClick: c[0] ||= (e) => m.value = !0
3480
+ }, [
3481
+ c[6] ||= a("span", {
3482
+ class: "tabula-issues-dot",
3483
+ "aria-hidden": "true"
3484
+ }, null, -1),
3485
+ a("span", null, b(se.value), 1),
3486
+ c[7] ||= a("svg", {
3487
+ class: "tabula-issues-chevron",
3488
+ viewBox: "0 0 24 24",
3489
+ "aria-hidden": "true"
3490
+ }, [a("path", { d: "m6 15 6-6 6 6" })], -1)
3491
+ ], 10, An)) : r("", !0),
3492
+ C.value && m.value ? (h(), i("div", {
3493
+ key: 1,
3494
+ class: "tabula-issues-scrim",
3495
+ "aria-hidden": "true",
3496
+ onClick: c[1] ||= (e) => m.value = !1
3497
+ })) : r("", !0),
3498
+ !C.value || m.value ? (h(), i("div", {
3499
+ key: 2,
3500
+ class: "tabula-issues-body",
3501
+ role: C.value ? "dialog" : void 0,
3502
+ "aria-modal": C.value ? "true" : void 0,
3503
+ "aria-label": C.value ? M.value.title : void 0
3504
+ }, [
3505
+ C.value ? (h(), i("span", G)) : r("", !0),
3506
+ a("header", Mn, [
3507
+ a("div", Nn, [
3508
+ a("strong", Pn, b(M.value.title), 1),
3509
+ a("span", Fn, [a("button", {
3510
+ type: "button",
3511
+ disabled: k.value.length === 0,
3512
+ onClick: c[2] ||= (e) => ue(-1)
3513
+ }, b(M.value.previous), 9, K), a("button", {
3514
+ type: "button",
3515
+ disabled: k.value.length === 0,
3516
+ onClick: c[3] ||= (e) => ue(1)
3517
+ }, b(M.value.next), 9, In)]),
3518
+ C.value || s.closable ? (h(), i("button", {
3519
+ key: 0,
3520
+ type: "button",
3521
+ class: "tabula-issues-close",
3522
+ "aria-label": M.value.close,
3523
+ onClick: ee
3524
+ }, [...c[8] ||= [a("svg", {
3525
+ viewBox: "0 0 24 24",
3526
+ "aria-hidden": "true"
3527
+ }, [a("path", { d: "M18 6 6 18M6 6l12 12" })], -1)]], 8, Ln)) : r("", !0)
3528
+ ]),
3529
+ a("div", Rn, [
3530
+ a("span", zn, [c[9] ||= a("span", {
3531
+ class: "tabula-issues-dot",
3532
+ "aria-hidden": "true"
3533
+ }, null, -1), o(" " + b(A.value.errors) + " " + b(M.value.errors), 1)]),
3534
+ A.value.warnings > 0 ? (h(), i("span", q, [c[10] ||= a("span", {
3535
+ class: "tabula-issues-dot",
3536
+ "aria-hidden": "true"
3537
+ }, null, -1), o(" " + b(A.value.warnings) + " " + b(M.value.warnings), 1)])) : r("", !0),
3538
+ A.value.stale > 0 ? (h(), i("span", Bn, [c[11] ||= a("span", {
3539
+ class: "tabula-issues-dot",
3540
+ "aria-hidden": "true"
3541
+ }, null, -1), o(" " + b(A.value.stale) + " " + b(M.value.stale), 1)])) : r("", !0),
3542
+ a("span", Vn, b(A.value.rows) + " " + b(M.value.rows), 1)
3543
+ ]),
3544
+ p.value === void 0 ? r("", !0) : (h(), i("span", Hn, [a("label", null, [te(a("input", {
3545
+ "onUpdate:modelValue": c[4] ||= (e) => p.value = e,
3546
+ type: "checkbox"
3547
+ }, null, 512), [[T, p.value]]), o(" " + b(M.value.onlyIssueRows), 1)]), p.value ? (h(), i("button", {
3548
+ key: 0,
3549
+ type: "button",
3550
+ title: M.value.refreshHint,
3551
+ onClick: c[5] ||= (e) => f("refreshRows")
3552
+ }, b(M.value.refresh), 9, Un)) : r("", !0)]))
3553
+ ]),
3554
+ k.value.length === 0 ? (h(), i("p", Wn, b(M.value.none), 1)) : (h(), i("ul", {
3555
+ key: 2,
3556
+ ref_key: "list",
3557
+ ref: ne,
3558
+ class: "tabula-issues-list tabula-scroll"
3559
+ }, [(h(!0), i(e, null, _(j.value, (e) => (h(), i("li", { key: e.id }, [a("button", {
3560
+ type: "button",
3561
+ class: d(["tabula-issues-item", ae(e)]),
3562
+ onClick: (t) => le(e)
3563
+ }, [
3564
+ a("span", Kn, [
3565
+ c[12] ||= a("span", {
3566
+ class: "tabula-issues-dot",
3567
+ "aria-hidden": "true"
3568
+ }, null, -1),
3569
+ a("span", qn, b(re(e)), 1),
3570
+ ie(e) ? (h(), i("span", {
3571
+ key: 0,
3572
+ class: "tabula-issues-address",
3573
+ textContent: b(ie(e))
3574
+ }, null, 8, Jn)) : r("", !0),
3575
+ a("span", Yn, b(oe(e)), 1)
3576
+ ]),
3577
+ N(e) ? (h(), i("span", {
3578
+ key: 0,
3579
+ class: "tabula-issues-name",
3580
+ textContent: b(N(e))
3581
+ }, null, 8, Xn)) : r("", !0),
3582
+ a("span", Zn, b(S(Ve)(e, s.locale, s.valueSettings)), 1),
3583
+ e.stale ? (h(), i("span", Qn, b(M.value.recheck), 1)) : r("", !0),
3584
+ e.rowId === null ? r("", !0) : (h(), i("span", $n, b(M.value.goToCell), 1))
3585
+ ], 10, Gn)]))), 128)), k.value.length > j.value.length ? (h(), i("li", er, " +" + b(k.value.length - j.value.length) + " " + b(M.value.more), 1)) : r("", !0)], 512)),
3586
+ k.value.length > 0 ? (h(), n(Pe, {
3587
+ key: 3,
3588
+ target: ne.value
3589
+ }, null, 8, ["target"])) : r("", !0),
3590
+ t.$slots.actions ? (h(), i("div", tr, [v(t.$slots, "actions")])) : r("", !0)
3591
+ ], 8, jn)) : r("", !0)
3592
+ ], 10, W));
3593
+ }
3594
+ }), rr = ["data-tabula-theme", "aria-label"], ir = [
3595
+ "value",
3596
+ "aria-label",
3597
+ "aria-invalid",
3598
+ "title"
3599
+ ], ar = ["aria-label", "title"], or = ["textContent"], sr = [
3600
+ "value",
3601
+ "readonly",
3602
+ "aria-label",
3603
+ "onKeydown"
3604
+ ], cr = /* @__PURE__ */ c({
3605
+ __name: "TabulaFormulaBar",
3606
+ props: {
3607
+ grid: {
3608
+ type: Object,
3609
+ default: null
3610
+ },
3611
+ locale: {
3612
+ type: String,
3613
+ default: "tr"
3614
+ },
3615
+ theme: {
3616
+ type: String,
3617
+ default: "light"
3618
+ }
3619
+ },
3620
+ setup(n) {
3621
+ let r = n, o = t(() => ze[r.locale]), s = t(() => r.grid?.cell ?? null), c = t(() => s.value?.formula ?? null);
3622
+ function l(e) {
3623
+ let t = e === null ? -1 : s.value?.references.indexOf(e) ?? -1;
3624
+ return t < 0 ? void 0 : ["tabula-formula-ref", `tabula-ref-${t % 6}`];
3625
+ }
3626
+ let u = y(null), f = g(null), p = g(null), m = g(!1), v = t(() => f.value ?? s.value?.text ?? "");
3627
+ E(() => s.value?.address, () => {
3628
+ m.value = !1;
3629
+ });
3630
+ function x(e) {
3631
+ let t = s.value;
3632
+ t?.editable && (f.value === null && (u.value = {
3633
+ rowId: t.rowId,
3634
+ key: t.field.key
3635
+ }), f.value = e.target.value);
3636
+ }
3637
+ function S(e) {
3638
+ let t = u.value, n = f.value;
3639
+ f.value = null, u.value = null, t && n !== null && r.grid?.writeCell(t.rowId, t.key, n), e && r.grid?.focus();
3640
+ }
3641
+ function C() {
3642
+ f.value = null, u.value = null, r.grid?.focus();
3643
+ }
3644
+ function w(e) {
3645
+ if (e.key === "Enter") {
3646
+ e.preventDefault();
3647
+ let t = r.grid?.goToAddress(p.value ?? s.value?.address ?? "") ?? !1;
3648
+ m.value = !t, t && (p.value = null);
3649
+ } else e.key === "Escape" && (e.preventDefault(), p.value = null, m.value = !1, r.grid?.focus());
3650
+ }
3651
+ function T() {
3652
+ p.value = null, m.value = !1;
3653
+ }
3654
+ function ee(e) {
3655
+ e.target.select();
3656
+ }
3657
+ return (t, r) => (h(), i("div", {
3658
+ class: "tabula-formula tabula-theme",
3659
+ "data-tabula-theme": n.theme,
3660
+ role: "group",
3661
+ "aria-label": o.value.formulaBar
3662
+ }, [
3663
+ a("input", {
3664
+ class: d(["tabula-formula-address", { "is-wrong": m.value }]),
3665
+ type: "text",
3666
+ spellcheck: "false",
3667
+ autocomplete: "off",
3668
+ value: p.value ?? s.value?.address ?? "",
3669
+ "aria-label": o.value.address,
3670
+ "aria-invalid": m.value || void 0,
3671
+ title: m.value ? o.value.noAddress : o.value.addressHint,
3672
+ onFocus: ee,
3673
+ onInput: r[0] ||= (e) => p.value = e.target.value,
3674
+ onKeydown: w,
3675
+ onBlur: T
3676
+ }, null, 42, ir),
3677
+ r[4] ||= a("span", {
3678
+ class: "tabula-formula-fx",
3679
+ "aria-hidden": "true"
3680
+ }, "ƒx", -1),
3681
+ c.value === null ? (h(), i("input", {
3682
+ key: 1,
3683
+ class: "tabula-formula-value",
3684
+ type: "text",
3685
+ spellcheck: "false",
3686
+ autocomplete: "off",
3687
+ value: v.value,
3688
+ readonly: !s.value?.editable,
3689
+ "aria-label": o.value.value,
3690
+ onInput: x,
3691
+ onKeydown: [r[1] ||= D(O((e) => S(!0), ["prevent"]), ["enter"]), D(O(C, ["prevent"]), ["escape"])],
3692
+ onBlur: r[2] ||= (e) => S(!1)
3693
+ }, null, 40, sr)) : (h(), i("div", {
3694
+ key: 0,
3695
+ class: "tabula-formula-value is-formula",
3696
+ role: "textbox",
3697
+ "aria-readonly": "true",
3698
+ tabindex: "0",
3699
+ "aria-label": o.value.value,
3700
+ title: o.value.formulaHint
3701
+ }, [r[3] ||= a("span", null, "=", -1), (h(!0), i(e, null, _(c.value, (e, t) => (h(), i("span", {
3702
+ key: t,
3703
+ class: d(l(e.field)),
3704
+ textContent: b(e.text)
3705
+ }, null, 10, or))), 128))], 8, ar))
3706
+ ], 8, rr));
3707
+ }
3708
+ }), lr = ["data-tabula-theme", "aria-label"], ur = {
3709
+ key: 0,
3710
+ class: "tabula-status-start"
3711
+ }, dr = { class: "tabula-status-info" }, fr = { class: "tabula-status-rows" }, pr = { class: "tabula-status-selected" }, mr = { class: "tabula-status-address" }, hr = { class: "tabula-status-sum" }, gr = {
3712
+ key: 0,
3713
+ class: "tabula-status-average"
3714
+ }, _r = {
3715
+ key: 1,
3716
+ class: "tabula-status-end"
3717
+ }, vr = /* @__PURE__ */ c({
3718
+ __name: "TabulaStatusBar",
3719
+ props: {
3720
+ grid: {
3721
+ type: Object,
3722
+ default: null
3723
+ },
3724
+ locale: {
3725
+ type: String,
3726
+ default: "tr"
3727
+ },
3728
+ theme: {
3729
+ type: String,
3730
+ default: "light"
3731
+ }
3732
+ },
3733
+ setup(n) {
3734
+ let s = n, c = t(() => ze[s.locale]);
3735
+ function l(e) {
3736
+ return e.toLocaleString(s.locale === "tr" ? "tr-TR" : "en-US");
3737
+ }
3738
+ let u = t(() => {
3739
+ let e = s.grid?.rows;
3740
+ return e ? e.shown === e.total ? `${l(e.total)} ${c.value.rows}` : `${l(e.shown)} / ${l(e.total)} ${c.value.rows}` : "";
3741
+ }), d = t(() => {
3742
+ let e = s.grid?.issueSummary;
3743
+ return e ? e.errors + e.warnings : 0;
3744
+ }), f = t(() => s.grid?.selected ?? null), p = t(() => {
3745
+ let e = f.value, t = s.grid;
3746
+ return !t || !e || e.field === null || e.sum === null || e.rows * e.columns < 2 ? null : {
3747
+ sum: t.formatValue(e.field, e.sum),
3748
+ average: e.average === null ? null : t.formatValue(e.field, e.average)
3749
+ };
3750
+ });
3751
+ return (t, s) => (h(), i("div", {
3752
+ class: "tabula-status tabula-theme",
3753
+ "data-tabula-theme": n.theme,
3754
+ role: "group",
3755
+ "aria-label": c.value.statusBar
3756
+ }, [
3757
+ t.$slots.start ? (h(), i("div", ur, [v(t.$slots, "start")])) : r("", !0),
3758
+ a("div", dr, [
3759
+ a("span", fr, [o(b(u.value) + " ", 1), d.value > 0 ? (h(), i(e, { key: 0 }, [o("· " + b(l(d.value)) + " " + b(c.value.issues), 1)], 64)) : r("", !0)]),
3760
+ f.value ? (h(), i(e, { key: 0 }, [s[0] ||= a("span", {
3761
+ class: "tabula-status-sep",
3762
+ "aria-hidden": "true"
3763
+ }, null, -1), a("span", pr, [o(b(c.value.selected) + ": ", 1), a("span", mr, b(f.value.address), 1)])], 64)) : r("", !0),
3764
+ p.value ? (h(), i(e, { key: 1 }, [a("span", hr, [o(b(c.value.sum) + ": ", 1), a("strong", null, b(p.value.sum), 1)]), p.value.average ? (h(), i("span", gr, [o(b(c.value.average) + ": ", 1), a("strong", null, b(p.value.average), 1)])) : r("", !0)], 64)) : r("", !0)
3765
+ ]),
3766
+ t.$slots.end ? (h(), i("div", _r, [v(t.$slots, "end")])) : r("", !0)
3767
+ ], 8, lr));
3768
+ }
3769
+ }), yr = ["data-tabula-theme", "aria-label"], br = ["textContent"], xr = { class: "tabula-preview-counts" }, Sr = ["textContent"], Cr = ["textContent"], wr = ["textContent"], Tr = ["textContent"], Er = ["aria-label"], Dr = [
3770
+ "aria-pressed",
3771
+ "onClick",
3772
+ "textContent"
3773
+ ], Or = {
3774
+ key: 3,
3775
+ class: "tabula-preview-list"
3776
+ }, kr = ["data-row-id", "onClick"], Ar = { class: "tabula-preview-name" }, jr = ["textContent"], Mr = ["textContent"], Nr = ["textContent"], Pr = { class: "tabula-preview-changes" }, Fr = ["textContent"], Ir = ["textContent"], Lr = ["textContent"], Rr = ["textContent"], zr = ["textContent"], Br = ["textContent"], Vr = { key: 1 }, Hr = ["textContent"], Ur = /* @__PURE__ */ c({
3777
+ __name: "TabulaPreview",
3778
+ props: {
3779
+ session: {
3780
+ type: Object,
3781
+ required: !0
3782
+ },
3783
+ plan: {
3784
+ type: Object,
3785
+ required: !0
3786
+ },
3787
+ nameField: {
3788
+ type: String,
3789
+ default: null
3790
+ },
3791
+ locale: {
3792
+ type: String,
3793
+ default: "tr"
3794
+ },
3795
+ valueSettings: {
3796
+ type: Object,
3797
+ default: () => N.tr
3798
+ },
3799
+ theme: {
3800
+ type: String,
3801
+ default: "light"
3802
+ },
3803
+ limit: {
3804
+ type: Number,
3805
+ default: 100
3806
+ }
3807
+ },
3808
+ emits: ["select"],
3809
+ setup(n, { emit: o }) {
3810
+ let s = n, c = o, l = [
3811
+ "create",
3812
+ "update",
3813
+ "unchanged",
3814
+ "unknown"
3815
+ ], u = {
3816
+ all: "all",
3817
+ create: "filterCreate",
3818
+ update: "filterUpdate",
3819
+ unchanged: "filterUnchanged",
3820
+ unknown: "filterUnknown",
3821
+ warned: "filterWarned"
3822
+ }, f = g("all"), p = g(s.limit), m = t(() => H[s.locale]);
3823
+ E([() => s.plan, f], () => {
3824
+ p.value = s.limit;
3825
+ });
3826
+ let v = t(() => {
3827
+ let e = x(s.session), t = /* @__PURE__ */ new Map();
3828
+ for (let n of s.plan.rows) {
3829
+ let r = [...e.issues.rowIssues(n.rowId), ...e.schema.fields.flatMap((t) => e.issues.issuesAt(n.rowId, t.key))].filter((e) => e.severity === "warning" && !e.stale);
3830
+ r.length > 0 && t.set(n.rowId, r);
3831
+ }
3832
+ return t;
3833
+ }), y = t(() => s.plan.rows.length > 0 && s.plan.counts.unknown === s.plan.rows.length), S = t(() => {
3834
+ let e = [{
3835
+ key: "all",
3836
+ count: s.plan.rows.length
3837
+ }];
3838
+ for (let t of l) s.plan.counts[t] > 0 && e.push({
3839
+ key: t,
3840
+ count: s.plan.counts[t]
3841
+ });
3842
+ return v.value.size > 0 && e.push({
3843
+ key: "warned",
3844
+ count: v.value.size
3845
+ }), e;
3846
+ }), C = t(() => {
3847
+ let e = s.plan.rows;
3848
+ return f.value === "all" ? e : f.value === "warned" ? e.filter((e) => v.value.has(e.rowId)) : e.filter((e) => e.action === f.value);
3849
+ }), w = t(() => C.value.slice(0, p.value)), T = t(() => Math.min(s.limit, C.value.length - w.value.length));
3850
+ function ee(e) {
3851
+ let t = x(s.session);
3852
+ return s.nameField === null || !t.schema.has(s.nameField) ? "" : F(t.schema.field(s.nameField), t.store.get(e, s.nameField), s.valueSettings);
3853
+ }
3854
+ function te(e) {
3855
+ return `${m.value.row} ${x(s.session).store.indexOf(e) + 1}`;
3856
+ }
3857
+ function D(e) {
3858
+ let t = x(s.session).schema;
3859
+ return t.has(e.field) ? t.field(e.field).label : e.field;
3860
+ }
3861
+ function O(e, t) {
3862
+ let n = x(s.session).schema, r = n.has(e.field) ? F(n.field(e.field), t, s.valueSettings) : "";
3863
+ return r === "" ? m.value.empty ?? "" : r;
3864
+ }
3865
+ function k(e) {
3866
+ return e.action === "create" ? e.changes.filter((e) => e.field !== s.nameField) : e.changes;
3867
+ }
3868
+ function A(e) {
3869
+ return e === null || e === "";
3870
+ }
3871
+ function j(e) {
3872
+ switch (e.action) {
3873
+ case "unchanged": return m.value.same ?? "";
3874
+ case "unknown": return m.value.unknownRow ?? "";
3875
+ case "update": return e.changes.length === 0 ? m.value.noChanges ?? "" : "";
3876
+ default: return "";
3877
+ }
3878
+ }
3879
+ function M(e) {
3880
+ return `${s.plan.counts[e]} ${m.value[e]}`;
3881
+ }
3882
+ function ne(e, t) {
3883
+ let n = m.value[u[e]] ?? "";
3884
+ return e === "all" ? n : `${n} · ${t}`;
3885
+ }
3886
+ function re(e) {
3887
+ return Ve(e, s.locale, s.valueSettings);
3888
+ }
3889
+ return (t, o) => (h(), i("section", {
3890
+ class: "tabula-preview tabula-theme",
3891
+ "data-tabula-theme": n.theme,
3892
+ "aria-label": m.value.title
3893
+ }, [
3894
+ n.plan.current ? r("", !0) : (h(), i("p", {
3895
+ key: 0,
3896
+ class: "tabula-preview-stale",
3897
+ role: "status",
3898
+ textContent: b(m.value.stale)
3899
+ }, null, 8, br)),
3900
+ a("div", xr, [y.value ? (h(), i("span", {
3901
+ key: 0,
3902
+ class: "tabula-preview-chip is-unknown",
3903
+ textContent: b(`${n.plan.rows.length} ${m.value.sent}`)
3904
+ }, null, 8, Sr)) : (h(), i(e, { key: 1 }, _(l, (t) => (h(), i(e, { key: t }, [n.plan.counts[t] > 0 ? (h(), i("span", {
3905
+ key: 0,
3906
+ class: d(["tabula-preview-chip", `is-${t}`]),
3907
+ textContent: b(M(t))
3908
+ }, null, 10, Cr)) : r("", !0)], 64))), 64)), v.value.size > 0 ? (h(), i("span", {
3909
+ key: 2,
3910
+ class: "tabula-preview-chip is-warned",
3911
+ textContent: b(`${v.value.size} ${m.value.warned}`)
3912
+ }, null, 8, wr)) : r("", !0)]),
3913
+ y.value ? (h(), i("p", {
3914
+ key: 1,
3915
+ class: "tabula-preview-note",
3916
+ textContent: b(m.value.noPlan)
3917
+ }, null, 8, Tr)) : r("", !0),
3918
+ S.value.length > 2 ? (h(), i("div", {
3919
+ key: 2,
3920
+ class: "tabula-preview-filters",
3921
+ role: "group",
3922
+ "aria-label": m.value.filters
3923
+ }, [(h(!0), i(e, null, _(S.value, (e) => (h(), i("button", {
3924
+ key: e.key,
3925
+ type: "button",
3926
+ class: d({ "is-on": f.value === e.key }),
3927
+ "aria-pressed": f.value === e.key,
3928
+ onClick: (t) => f.value = e.key,
3929
+ textContent: b(ne(e.key, e.count))
3930
+ }, null, 10, Dr))), 128))], 8, Er)) : r("", !0),
3931
+ !y.value || v.value.size > 0 ? (h(), i("ul", Or, [
3932
+ (h(!0), i(e, null, _(w.value, (t) => (h(), i("li", { key: t.rowId }, [a("button", {
3933
+ type: "button",
3934
+ class: d(["tabula-preview-row", `is-${t.action}`]),
3935
+ "data-row-id": t.rowId,
3936
+ onClick: (e) => c("select", t.rowId)
3937
+ }, [
3938
+ a("span", Ar, [ee(t.rowId) ? (h(), i("strong", {
3939
+ key: 0,
3940
+ textContent: b(ee(t.rowId))
3941
+ }, null, 8, jr)) : r("", !0), a("span", {
3942
+ class: "tabula-preview-number",
3943
+ textContent: b(te(t.rowId))
3944
+ }, null, 8, Mr)]),
3945
+ a("span", {
3946
+ class: d(["tabula-preview-action", `is-${t.action}`]),
3947
+ textContent: b(m.value[`${t.action}One`])
3948
+ }, null, 10, Nr),
3949
+ a("span", Pr, [
3950
+ (h(!0), i(e, null, _(k(t), (n) => (h(), i("span", {
3951
+ key: n.field,
3952
+ class: "tabula-preview-change"
3953
+ }, [
3954
+ a("span", {
3955
+ class: "tabula-preview-field",
3956
+ textContent: b(D(n))
3957
+ }, null, 8, Fr),
3958
+ t.action === "update" ? (h(), i(e, { key: 0 }, [a("s", {
3959
+ class: d(["tabula-preview-before", { "is-empty": A(n.before) }]),
3960
+ textContent: b(O(n, n.before))
3961
+ }, null, 10, Ir), o[1] ||= a("span", {
3962
+ class: "tabula-preview-arrow",
3963
+ "aria-hidden": "true"
3964
+ }, "→", -1)], 64)) : r("", !0),
3965
+ a("strong", {
3966
+ class: d(["tabula-preview-after", { "is-empty": A(n.after) }]),
3967
+ textContent: b(O(n, n.after))
3968
+ }, null, 10, Lr)
3969
+ ]))), 128)),
3970
+ j(t) ? (h(), i("span", {
3971
+ key: 0,
3972
+ class: "tabula-preview-quiet",
3973
+ textContent: b(j(t))
3974
+ }, null, 8, Rr)) : r("", !0),
3975
+ (h(!0), i(e, null, _(v.value.get(t.rowId) ?? [], (e) => (h(), i("span", {
3976
+ key: e.id,
3977
+ class: "tabula-preview-warning",
3978
+ textContent: b(re(e))
3979
+ }, null, 8, zr))), 128))
3980
+ ])
3981
+ ], 10, kr)]))), 128)),
3982
+ C.value.length === 0 ? (h(), i("li", {
3983
+ key: 0,
3984
+ class: "tabula-preview-quiet",
3985
+ textContent: b(m.value.none)
3986
+ }, null, 8, Br)) : r("", !0),
3987
+ T.value > 0 ? (h(), i("li", Vr, [a("button", {
3988
+ type: "button",
3989
+ class: "tabula-preview-more",
3990
+ onClick: o[0] ||= (e) => p.value += n.limit,
3991
+ textContent: b((m.value.more ?? "").replace("{n}", String(T.value)))
3992
+ }, null, 8, Hr)])) : r("", !0)
3993
+ ])) : r("", !0)
3994
+ ], 8, yr));
3995
+ }
3996
+ }), Wr = ["data-tabula-theme"], Gr = ["textContent"], Kr = {
3997
+ class: "tabula-mapping-head",
3998
+ "aria-hidden": "true"
3999
+ }, qr = ["textContent"], Jr = ["textContent"], Yr = { class: "tabula-mapping-name" }, Xr = ["textContent"], J = ["textContent"], Zr = ["textContent"], Qr = { class: "tabula-mapping-target" }, $r = [
4000
+ "aria-label",
4001
+ "value",
4002
+ "onChange"
4003
+ ], ei = ["textContent"], ti = ["value", "textContent"], ni = { class: "tabula-mapping-notes" }, ri = ["textContent"], ii = ["textContent"], ai = ["textContent"], oi = ["textContent"], si = ["textContent"], ci = { class: "tabula-mapping-name" }, li = ["textContent"], ui = ["textContent"], di = ["textContent"], Y = { class: "tabula-mapping-target" }, X = ["textContent"], fi = { class: "tabula-mapping-notes" }, pi = ["textContent"], mi = ["textContent"], hi = { class: "tabula-mapping-target" }, gi = ["textContent"], _i = { class: "tabula-mapping-notes" }, vi = ["textContent"], yi = ["textContent"], bi = {
4004
+ key: 0,
4005
+ class: "tabula-mapping-same"
4006
+ }, xi = ["textContent"], Si = ["textContent"], Ci = ["textContent"], wi = /* @__PURE__ */ c({
4007
+ __name: "TabulaDraftMapping",
4008
+ props: /*@__PURE__*/ l({
4009
+ draft: {
4010
+ type: Object,
4011
+ required: !0
4012
+ },
4013
+ schema: {
4014
+ type: Object,
4015
+ required: !0
4016
+ },
4017
+ locale: {
4018
+ type: String,
4019
+ default: "tr"
4020
+ },
4021
+ valueSettings: {
4022
+ type: Object,
4023
+ default: () => N.tr
4024
+ },
4025
+ theme: {
4026
+ type: String,
4027
+ default: "light"
4028
+ }
4029
+ }, {
4030
+ rename: { default: () => ({}) },
4031
+ renameModifiers: {}
4032
+ }),
4033
+ emits: ["update:rename"],
4034
+ setup(n) {
4035
+ let o = n, s = w(n, "rename"), c = t(() => Le[o.locale]), l = t(() => x(o.schema)), u = t(() => ge(x(o.draft), l.value, {
4036
+ rename: s.value,
4037
+ settings: o.valueSettings
4038
+ })), f = t(() => Te(x(o.draft), l.value)), p = t(() => u.value.fields.filter((e) => !l.value.has(e.key))), m = t(() => u.value.fields.filter((e) => l.value.has(e.key) && l.value.field(e.key).type !== e.type)), g = t(() => u.value.fields.filter((e) => l.value.has(e.key) && l.value.field(e.key).type === e.type)), v = t(() => u.value.added.map((e) => l.value.field(e))), y = t(() => new Set(x(o.draft).fields.map((e) => e.key))), S = t(() => {
4039
+ let e = x(o.draft), t = new Intl.DateTimeFormat(o.locale === "tr" ? "tr-TR" : "en-GB", {
4040
+ dateStyle: "long",
4041
+ timeStyle: "short"
4042
+ }).format(new Date(e.savedAt));
4043
+ return k(c.value.saved, {
4044
+ date: t,
4045
+ rows: e.rows.length,
4046
+ from: e.schemaVersion,
4047
+ to: l.value.schemaVersion
4048
+ });
4049
+ }), C = t(() => {
4050
+ let e = p.value.filter((e) => e.target !== null).length, t = p.value.length - e;
4051
+ return [e > 0 ? k(c.value.mapped, { n: e }) : "", t > 0 ? k(c.value.dropped, { n: t }) : ""].filter(Boolean).join(" · ");
4052
+ });
4053
+ function T(e) {
4054
+ let t = new Set(Object.entries(s.value).flatMap(([t, n]) => t === e.key ? [] : [n]));
4055
+ return l.value.fields.filter((e) => !y.value.has(e.key) && !t.has(e.key)).map((t) => ({
4056
+ key: t.key,
4057
+ label: t.type === e.type ? t.label : `${t.label} (${c.value.otherType})`
4058
+ }));
4059
+ }
4060
+ function ee(e, t) {
4061
+ let n = { ...s.value };
4062
+ t === "" ? delete n[e.key] : n[e.key] = t, s.value = n;
4063
+ }
4064
+ function E(e) {
4065
+ return e.label ?? e.key;
4066
+ }
4067
+ function te(e) {
4068
+ return c.value[e] ?? e;
4069
+ }
4070
+ function D(e, t) {
4071
+ let n = e.target === null ? null : l.value.field(e.target);
4072
+ return n && Oe(n, t, o.valueSettings) === null ? F(n, t, o.valueSettings) : typeof t == "object" && t && !Array.isArray(t) && "label" in t ? String(t.label) : Array.isArray(t) ? t.join(", ") : String(t);
4073
+ }
4074
+ function O(e) {
4075
+ let t = e.samples.map((t) => D(e, t)).join(" · ");
4076
+ return e.filled > e.samples.length ? `${t} …` : t;
4077
+ }
4078
+ function k(e, t) {
4079
+ let n = new Intl.NumberFormat(o.locale === "tr" ? "tr-TR" : "en-GB");
4080
+ return (e ?? "").replace(/\{(\w+)\}/g, (e, r) => {
4081
+ let i = t[r];
4082
+ return typeof i == "number" ? n.format(i) : i ?? "";
4083
+ });
4084
+ }
4085
+ return (t, o) => (h(), i("section", {
4086
+ class: "tabula-mapping tabula-theme",
4087
+ "data-tabula-theme": n.theme
4088
+ }, [
4089
+ a("p", {
4090
+ class: "tabula-mapping-saved",
4091
+ textContent: b(S.value)
4092
+ }, null, 8, Gr),
4093
+ a("div", Kr, [
4094
+ a("span", { textContent: b(c.value.fromHead) }, null, 8, qr),
4095
+ o[0] ||= a("span", null, null, -1),
4096
+ a("span", { textContent: b(c.value.toHead) }, null, 8, Jr)
4097
+ ]),
4098
+ (h(!0), i(e, null, _(p.value, (t) => (h(), i("div", {
4099
+ key: t.key,
4100
+ class: "tabula-mapping-row"
4101
+ }, [
4102
+ a("span", Yr, [
4103
+ a("strong", { textContent: b(E(t)) }, null, 8, Xr),
4104
+ a("span", {
4105
+ class: "tabula-mapping-kind",
4106
+ textContent: b(`${te(t.type)} · ${t.key}`)
4107
+ }, null, 8, J),
4108
+ t.filled > 0 ? (h(), i("span", {
4109
+ key: 0,
4110
+ class: "tabula-mapping-samples",
4111
+ textContent: b(O(t))
4112
+ }, null, 8, Zr)) : r("", !0)
4113
+ ]),
4114
+ o[1] ||= a("span", {
4115
+ class: "tabula-mapping-arrow",
4116
+ "aria-hidden": "true"
4117
+ }, "→", -1),
4118
+ a("span", Qr, [a("select", {
4119
+ class: d(["tabula-mapping-select", {
4120
+ "is-dropped": t.target === null,
4121
+ "is-suggested": t.target !== null && f.value[t.key] === t.target
4122
+ }]),
4123
+ "aria-label": `${E(t)}: ${c.value.toHead}`,
4124
+ value: t.target ?? "",
4125
+ onChange: (e) => ee(t, e.target.value)
4126
+ }, [a("option", {
4127
+ value: "",
4128
+ textContent: b(c.value.drop)
4129
+ }, null, 8, ei), (h(!0), i(e, null, _(T(t), (e) => (h(), i("option", {
4130
+ key: e.key,
4131
+ value: e.key,
4132
+ textContent: b(e.label)
4133
+ }, null, 8, ti))), 128))], 42, $r), a("span", ni, [t.target === null ? (h(), i(e, { key: 0 }, [t.filled > 0 ? (h(), i("span", {
4134
+ key: 0,
4135
+ class: "tabula-mapping-tag is-lost",
4136
+ textContent: b(k(c.value.losing, { n: t.filled }))
4137
+ }, null, 8, ri)) : (h(), i("span", {
4138
+ key: 1,
4139
+ class: "tabula-mapping-quiet",
4140
+ textContent: b(c.value.noValues)
4141
+ }, null, 8, ii))], 64)) : (h(), i(e, { key: 1 }, [
4142
+ f.value[t.key] === t.target ? (h(), i("span", {
4143
+ key: 0,
4144
+ class: "tabula-mapping-tag is-suggested",
4145
+ textContent: b(c.value.suggested)
4146
+ }, null, 8, ai)) : r("", !0),
4147
+ a("span", {
4148
+ class: "tabula-mapping-quiet",
4149
+ textContent: b(k(c.value.moves, { n: t.filled }))
4150
+ }, null, 8, oi),
4151
+ t.unreadable > 0 ? (h(), i("span", {
4152
+ key: 1,
4153
+ class: "tabula-mapping-tag is-warned",
4154
+ textContent: b(k(c.value.unreadable, { n: t.unreadable }))
4155
+ }, null, 8, si)) : r("", !0)
4156
+ ], 64))])])
4157
+ ]))), 128)),
4158
+ (h(!0), i(e, null, _(m.value, (e) => (h(), i("div", {
4159
+ key: e.key,
4160
+ class: "tabula-mapping-row"
4161
+ }, [
4162
+ a("span", ci, [
4163
+ a("strong", { textContent: b(E(e)) }, null, 8, li),
4164
+ a("span", {
4165
+ class: "tabula-mapping-kind",
4166
+ textContent: b(e.key)
4167
+ }, null, 8, ui),
4168
+ e.filled > 0 ? (h(), i("span", {
4169
+ key: 0,
4170
+ class: "tabula-mapping-samples",
4171
+ textContent: b(O(e))
4172
+ }, null, 8, di)) : r("", !0)
4173
+ ]),
4174
+ o[2] ||= a("span", {
4175
+ class: "tabula-mapping-arrow",
4176
+ "aria-hidden": "true"
4177
+ }, "→", -1),
4178
+ a("span", Y, [a("strong", {
4179
+ class: "tabula-mapping-fixed",
4180
+ textContent: b(l.value.field(e.key).label)
4181
+ }, null, 8, X), a("span", fi, [a("span", {
4182
+ class: "tabula-mapping-tag is-warned",
4183
+ textContent: b(k(c.value.retyped, {
4184
+ from: te(e.type),
4185
+ to: te(l.value.field(e.key).type)
4186
+ }))
4187
+ }, null, 8, pi), e.unreadable > 0 ? (h(), i("span", {
4188
+ key: 0,
4189
+ class: "tabula-mapping-quiet",
4190
+ textContent: b(k(c.value.unreadable, { n: e.unreadable }))
4191
+ }, null, 8, mi)) : r("", !0)])])
4192
+ ]))), 128)),
4193
+ (h(!0), i(e, null, _(v.value, (e) => (h(), i("div", {
4194
+ key: e.key,
4195
+ class: "tabula-mapping-row"
4196
+ }, [
4197
+ o[3] ||= a("span", { class: "tabula-mapping-quiet" }, "—", -1),
4198
+ o[4] ||= a("span", {
4199
+ class: "tabula-mapping-arrow",
4200
+ "aria-hidden": "true"
4201
+ }, "→", -1),
4202
+ a("span", hi, [a("strong", {
4203
+ class: "tabula-mapping-fixed",
4204
+ textContent: b(e.label)
4205
+ }, null, 8, gi), a("span", _i, [a("span", {
4206
+ class: "tabula-mapping-tag is-new",
4207
+ textContent: b(c.value.added)
4208
+ }, null, 8, vi), a("span", {
4209
+ class: "tabula-mapping-quiet",
4210
+ textContent: b(c.value.addedNote)
4211
+ }, null, 8, yi)])])
4212
+ ]))), 128)),
4213
+ g.value.length > 0 ? (h(), i("p", bi, [a("span", {
4214
+ class: "tabula-mapping-tag",
4215
+ textContent: b(k(c.value.same, { n: g.value.length }))
4216
+ }, null, 8, xi), a("span", { textContent: b(g.value.map(E).join(", ")) }, null, 8, Si)])) : r("", !0),
4217
+ C.value ? (h(), i("p", {
4218
+ key: 1,
4219
+ class: "tabula-mapping-summary",
4220
+ role: "status",
4221
+ textContent: b(C.value)
4222
+ }, null, 8, Ci)) : r("", !0)
4223
+ ], 8, Wr));
4224
+ }
4225
+ }), Z = ["data-tabula-theme"], Ti = ["aria-label"], Ei = [
4226
+ "data-tab",
4227
+ "aria-selected",
4228
+ "aria-disabled",
4229
+ "tabindex",
4230
+ "onClick",
4231
+ "onPointerdown",
4232
+ "onDblclick",
4233
+ "onKeydown",
4234
+ "onContextmenu"
4235
+ ], Di = ["aria-label", "onKeydown"], Oi = ["textContent"], ki = [
4236
+ "title",
4237
+ "aria-label",
4238
+ "textContent"
4239
+ ], Ai = ["title", "aria-label"], Q = [
4240
+ "aria-label",
4241
+ "title",
4242
+ "aria-haspopup",
4243
+ "aria-expanded",
4244
+ "disabled"
4245
+ ], ji = ["aria-label"], Mi = ["onClick"], Ni = { class: "tabula-tabs-option" }, Pi = ["textContent"], Fi = ["textContent"], Ii = ["aria-label"], Li = ["textContent"], Ri = ["textContent"], zi = ["textContent"], Bi = ["disabled"], Vi = ["textContent"], Hi = ["textContent"], Ui = ["disabled"], Wi = ["textContent"], Gi = ["textContent"], Ki = ["disabled", "textContent"], qi = /* @__PURE__ */ c({
4246
+ __name: "TabulaSheetTabs",
4247
+ props: /*@__PURE__*/ l({
4248
+ tabs: {
4249
+ type: Array,
4250
+ required: !0
4251
+ },
4252
+ disabled: {
4253
+ type: Boolean,
4254
+ default: !1
4255
+ },
4256
+ locale: {
4257
+ type: String,
4258
+ default: "tr"
4259
+ },
4260
+ theme: {
4261
+ type: String,
4262
+ default: "light"
4263
+ },
4264
+ addOptions: {
4265
+ type: Array,
4266
+ default: () => []
4267
+ }
4268
+ }, {
4269
+ active: { required: !0 },
4270
+ activeModifiers: {}
4271
+ }),
4272
+ emits: /*@__PURE__*/ l([
4273
+ "add",
4274
+ "rename",
4275
+ "duplicate",
4276
+ "remove",
4277
+ "move"
4278
+ ], ["update:active"]),
4279
+ setup(n, { emit: o }) {
4280
+ let s = n, c = o, l = w(n, "active"), m = t(() => Re[s.locale]), v = g(null), y = g(null), x = g(""), S = g(null), C = g(null), T = g(null), E = null;
4281
+ function k(e) {
4282
+ !s.disabled && e !== l.value && (l.value = e);
4283
+ }
4284
+ function A(e) {
4285
+ let t = s.tabs.find((t) => t.id === e);
4286
+ !s.disabled && t && (F(), y.value = e, x.value = t.name, u(() => {
4287
+ let e = v.value?.querySelector(".tabula-tabs-rename");
4288
+ e?.focus(), e?.select();
4289
+ }));
4290
+ }
4291
+ function j() {
4292
+ let e = y.value, t = x.value.trim(), n = s.tabs.find((t) => t.id === e);
4293
+ y.value = null, e !== null && n && t !== "" && t !== n.name && c("rename", e, t), ne(e);
4294
+ }
4295
+ function M() {
4296
+ let e = y.value;
4297
+ y.value = null, ne(e);
4298
+ }
4299
+ function ne(e) {
4300
+ u(() => v.value?.querySelector(`[data-tab="${e ?? l.value}"]`)?.focus());
4301
+ }
4302
+ function re(e, t) {
4303
+ let n = s.tabs.findIndex((e) => e.id === t);
4304
+ if ((e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "ArrowRight" || e.key === "ArrowLeft")) ie(t, e.key === "ArrowRight" ? 1 : -1);
4305
+ else if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
4306
+ let t = s.tabs[(n + (e.key === "ArrowRight" ? 1 : -1) + s.tabs.length) % s.tabs.length];
4307
+ ne(t?.id ?? null);
4308
+ } else if (e.key === "Home" || e.key === "End") ne((e.key === "Home" ? s.tabs[0] : s.tabs[s.tabs.length - 1])?.id ?? null);
4309
+ else if (e.key === "Enter" || e.key === " ") k(t);
4310
+ else if (e.key === "F2") A(t);
4311
+ else if (e.key === "ContextMenu" || e.key === "F10" && e.shiftKey) {
4312
+ let n = e.currentTarget.getBoundingClientRect();
4313
+ P(t, n.left, n.top);
4314
+ } else return;
4315
+ e.preventDefault();
4316
+ }
4317
+ function ie(e, t) {
4318
+ let n = s.tabs.findIndex((t) => t.id === e), r = n + t;
4319
+ !s.disabled && n >= 0 && r >= 0 && r < s.tabs.length && (c("move", e, r), ne(e));
4320
+ }
4321
+ let N = g(null), ae = null, oe = !1;
4322
+ function se(e, t) {
4323
+ if (e.button !== 0 || s.disabled || y.value !== null || s.tabs.length < 2) return;
4324
+ let n = s.tabs.findIndex((e) => e.id === t), r = e.clientX;
4325
+ N.value = {
4326
+ id: t,
4327
+ from: n,
4328
+ to: n,
4329
+ moved: !1
4330
+ };
4331
+ let i = (e) => {
4332
+ let t = N.value;
4333
+ t && (t.moved || Math.abs(e.clientX - r) >= 5) && (N.value = {
4334
+ ...t,
4335
+ moved: !0,
4336
+ to: le(e.clientX, t.from)
4337
+ });
4338
+ }, a = () => {
4339
+ let e = N.value;
4340
+ ce(), e?.moved && (oe = !0, setTimeout(() => oe = !1, 0), e.to !== e.from && c("move", e.id, e.to));
4341
+ }, o = (e) => {
4342
+ e.key === "Escape" && (e.preventDefault(), ce());
4343
+ };
4344
+ window.addEventListener("pointermove", i), window.addEventListener("pointerup", a), window.addEventListener("pointercancel", ce), window.addEventListener("keydown", o, !0), ae = () => {
4345
+ window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", a), window.removeEventListener("pointercancel", ce), window.removeEventListener("keydown", o, !0);
4346
+ };
4347
+ }
4348
+ p(ce), p(F);
4349
+ function ce() {
4350
+ ae?.(), ae = null, N.value = null;
4351
+ }
4352
+ function le(e, t) {
4353
+ let n = [...v.value?.querySelectorAll(".tabula-tabs-tab") ?? []], r = n.length;
4354
+ for (let [t, i] of n.entries()) {
4355
+ let n = i.getBoundingClientRect();
4356
+ if (e < n.left + n.width / 2) {
4357
+ r = t;
4358
+ break;
4359
+ }
4360
+ }
4361
+ return r > t ? r - 1 : r;
4362
+ }
4363
+ function ue(e) {
4364
+ let t = N.value;
4365
+ if (!t?.moved || t.to === t.from) return;
4366
+ let n = t.to > t.from ? t.to + 1 : t.to;
4367
+ return n === e ? "is-drop-before" : n === s.tabs.length && e === s.tabs.length - 1 ? "is-drop-after" : void 0;
4368
+ }
4369
+ function de(e) {
4370
+ oe || k(e);
4371
+ }
4372
+ function fe(e, t) {
4373
+ e.preventDefault(), P(t, e.clientX, e.clientY);
4374
+ }
4375
+ function P(e, t, n) {
4376
+ if (s.disabled) return;
4377
+ F(), S.value = {
4378
+ id: e,
4379
+ left: t,
4380
+ top: n
4381
+ };
4382
+ let r = (e) => {
4383
+ e.target instanceof Element && e.target.closest(".tabula-tabs-menu") || F();
4384
+ };
4385
+ window.addEventListener("mousedown", r, !0), E = () => window.removeEventListener("mousedown", r, !0), u(() => {
4386
+ let e = v.value?.parentElement?.querySelector(".tabula-tabs-menu");
4387
+ if (!e || !S.value) return;
4388
+ let t = Math.max(8, Math.min(S.value.left, window.innerWidth - e.offsetWidth - 8)), n = Math.max(8, S.value.top - e.offsetHeight - 4);
4389
+ S.value = {
4390
+ ...S.value,
4391
+ left: t,
4392
+ top: n
4393
+ }, e.querySelector("button")?.focus();
4394
+ });
4395
+ }
4396
+ function F() {
4397
+ E?.(), E = null, S.value = null, C.value = null;
4398
+ }
4399
+ function pe() {
4400
+ if (s.disabled) return;
4401
+ if (s.addOptions.length === 0) {
4402
+ c("add");
4403
+ return;
4404
+ }
4405
+ if (C.value) {
4406
+ F();
4407
+ return;
4408
+ }
4409
+ let e = T.value?.getBoundingClientRect();
4410
+ F(), C.value = {
4411
+ left: e?.left ?? 0,
4412
+ top: e?.top ?? 0
4413
+ };
4414
+ let t = (e) => {
4415
+ let t = e.target instanceof Element ? e.target : null;
4416
+ !t?.closest(".tabula-tabs-menu") && !t?.closest(".tabula-tabs-add") && F();
4417
+ };
4418
+ window.addEventListener("mousedown", t, !0), E = () => window.removeEventListener("mousedown", t, !0), u(() => {
4419
+ let e = v.value?.parentElement?.querySelector(".tabula-tabs-menu.is-add");
4420
+ if (!e || !C.value) return;
4421
+ let t = Math.max(8, Math.min(C.value.left, window.innerWidth - e.offsetWidth - 8)), n = Math.max(8, C.value.top - e.offsetHeight - 4);
4422
+ C.value = {
4423
+ left: t,
4424
+ top: n
4425
+ }, e.querySelector("button")?.focus();
4426
+ });
4427
+ }
4428
+ function me(e) {
4429
+ F(), c("add", e);
4430
+ }
4431
+ function he(e) {
4432
+ let t = [...e.currentTarget.querySelectorAll("button")], n = t.indexOf(document.activeElement);
4433
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") t[(n + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus();
4434
+ else if (e.key === "Escape" || e.key === "Tab") F(), T.value?.focus();
4435
+ else return;
4436
+ e.preventDefault();
4437
+ }
4438
+ function ge(e) {
4439
+ let t = S.value?.id;
4440
+ F(), t && (e === "rename" ? A(t) : e === "duplicate" ? c("duplicate", t) : e === "left" || e === "right" ? ie(t, e === "right" ? 1 : -1) : c("remove", t));
4441
+ }
4442
+ function _e(e) {
4443
+ let t = [...e.currentTarget.querySelectorAll("button:not(:disabled)")], n = t.indexOf(document.activeElement);
4444
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") t[(n + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus();
4445
+ else if (e.key === "Escape" || e.key === "Tab") {
4446
+ let e = S.value?.id ?? null;
4447
+ F(), ne(e);
4448
+ } else return;
4449
+ e.preventDefault();
4450
+ }
4451
+ let ve = t(() => S.value ? s.tabs.findIndex((e) => e.id === S.value?.id) : -1), ye = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform);
4452
+ function be(e) {
4453
+ return ye ? `⌘⇧${e}` : `Ctrl+Shift+${e}`;
4454
+ }
4455
+ function xe(e) {
4456
+ return (m.value.errors ?? "").replace("{n}", String(e));
4457
+ }
4458
+ return (t, o) => (h(), i("div", {
4459
+ class: d(["tabula-tabs tabula-theme", { "is-disabled": n.disabled }]),
4460
+ "data-tabula-theme": n.theme
4461
+ }, [
4462
+ a("div", {
4463
+ ref_key: "list",
4464
+ ref: v,
4465
+ class: "tabula-tabs-list",
4466
+ role: "tablist",
4467
+ "aria-label": m.value.sheets
4468
+ }, [(h(!0), i(e, null, _(n.tabs, (e, t) => (h(), i("div", {
4469
+ key: e.id,
4470
+ class: d(["tabula-tabs-tab", [{
4471
+ "is-active": e.id === l.value,
4472
+ "is-dragging": N.value?.moved && N.value.id === e.id
4473
+ }, ue(t)]]),
4474
+ role: "tab",
4475
+ "data-tab": e.id,
4476
+ "aria-selected": e.id === l.value,
4477
+ "aria-disabled": n.disabled || void 0,
4478
+ tabindex: e.id === l.value ? 0 : -1,
4479
+ onClick: (t) => de(e.id),
4480
+ onPointerdown: (t) => se(t, e.id),
4481
+ onDblclick: (t) => A(e.id),
4482
+ onKeydown: (t) => re(t, e.id),
4483
+ onContextmenu: (t) => fe(t, e.id)
4484
+ }, [y.value === e.id ? te((h(), i("input", {
4485
+ key: 0,
4486
+ "onUpdate:modelValue": o[0] ||= (e) => x.value = e,
4487
+ class: "tabula-tabs-rename",
4488
+ type: "text",
4489
+ maxlength: "60",
4490
+ "aria-label": m.value.name,
4491
+ onKeydown: [
4492
+ D(O(j, ["prevent"]), ["enter"]),
4493
+ D(O(M, ["prevent"]), ["escape"]),
4494
+ o[1] ||= O(() => {}, ["stop"])
4495
+ ],
4496
+ onBlur: j,
4497
+ onClick: o[2] ||= O(() => {}, ["stop"])
4498
+ }, null, 40, Di)), [[ee, x.value]]) : (h(), i("span", {
4499
+ key: 1,
4500
+ class: "tabula-tabs-name",
4501
+ textContent: b(e.name)
4502
+ }, null, 8, Oi)), (e.errors ?? 0) > 0 ? (h(), i("span", {
4503
+ key: 2,
4504
+ class: "tabula-tabs-badge is-error",
4505
+ title: xe(e.errors ?? 0),
4506
+ "aria-label": xe(e.errors ?? 0),
4507
+ textContent: b(e.errors)
4508
+ }, null, 8, ki)) : e.done ? (h(), i("span", {
4509
+ key: 3,
4510
+ class: "tabula-tabs-badge is-done",
4511
+ title: m.value.done,
4512
+ "aria-label": m.value.done,
4513
+ textContent: "✓"
4514
+ }, null, 8, Ai)) : r("", !0)], 42, Ei))), 128))], 8, Ti),
4515
+ a("button", {
4516
+ ref_key: "addButton",
4517
+ ref: T,
4518
+ type: "button",
4519
+ class: "tabula-tabs-add",
4520
+ "aria-label": m.value.add,
4521
+ title: m.value.add,
4522
+ "aria-haspopup": n.addOptions.length > 0 ? "menu" : void 0,
4523
+ "aria-expanded": n.addOptions.length > 0 ? C.value !== null : void 0,
4524
+ disabled: n.disabled,
4525
+ onClick: pe
4526
+ }, " + ", 8, Q),
4527
+ C.value ? (h(), i("div", {
4528
+ key: 0,
4529
+ class: "tabula-tabs-menu is-add",
4530
+ role: "menu",
4531
+ "aria-label": m.value.add,
4532
+ style: f({
4533
+ left: `${C.value.left}px`,
4534
+ top: `${C.value.top}px`
4535
+ }),
4536
+ onKeydown: he,
4537
+ onContextmenu: o[3] ||= O(() => {}, ["prevent"])
4538
+ }, [(h(!0), i(e, null, _(n.addOptions, (e) => (h(), i("button", {
4539
+ key: e.key,
4540
+ type: "button",
4541
+ role: "menuitem",
4542
+ onClick: (t) => me(e.key)
4543
+ }, [a("span", Ni, [a("span", { textContent: b(e.label) }, null, 8, Pi), e.description ? (h(), i("span", {
4544
+ key: 0,
4545
+ class: "tabula-tabs-key",
4546
+ textContent: b(e.description)
4547
+ }, null, 8, Fi)) : r("", !0)])], 8, Mi))), 128))], 44, ji)) : r("", !0),
4548
+ S.value ? (h(), i("div", {
4549
+ key: 1,
4550
+ class: "tabula-tabs-menu",
4551
+ role: "menu",
4552
+ "aria-label": m.value.menu,
4553
+ style: f({
4554
+ left: `${S.value.left}px`,
4555
+ top: `${S.value.top}px`
4556
+ }),
4557
+ onKeydown: _e,
4558
+ onContextmenu: o[9] ||= O(() => {}, ["prevent"])
4559
+ }, [
4560
+ a("button", {
4561
+ type: "button",
4562
+ role: "menuitem",
4563
+ onClick: o[4] ||= (e) => ge("rename")
4564
+ }, [a("span", { textContent: b(m.value.rename) }, null, 8, Li), a("span", {
4565
+ class: "tabula-tabs-key",
4566
+ textContent: b(`F2 · ${m.value.doubleClick}`)
4567
+ }, null, 8, Ri)]),
4568
+ a("button", {
4569
+ type: "button",
4570
+ role: "menuitem",
4571
+ onClick: o[5] ||= (e) => ge("duplicate"),
4572
+ textContent: b(m.value.duplicate)
4573
+ }, null, 8, zi),
4574
+ a("button", {
4575
+ type: "button",
4576
+ role: "menuitem",
4577
+ disabled: ve.value <= 0,
4578
+ onClick: o[6] ||= (e) => ge("left")
4579
+ }, [a("span", { textContent: b(m.value.moveLeft) }, null, 8, Vi), a("span", {
4580
+ class: "tabula-tabs-key",
4581
+ textContent: b(be("←"))
4582
+ }, null, 8, Hi)], 8, Bi),
4583
+ a("button", {
4584
+ type: "button",
4585
+ role: "menuitem",
4586
+ disabled: ve.value >= n.tabs.length - 1,
4587
+ onClick: o[7] ||= (e) => ge("right")
4588
+ }, [a("span", { textContent: b(m.value.moveRight) }, null, 8, Wi), a("span", {
4589
+ class: "tabula-tabs-key",
4590
+ textContent: b(be("→"))
4591
+ }, null, 8, Gi)], 8, Ui),
4592
+ o[10] ||= a("span", {
4593
+ class: "tabula-tabs-line",
4594
+ role: "separator"
4595
+ }, null, -1),
4596
+ a("button", {
4597
+ type: "button",
4598
+ role: "menuitem",
4599
+ class: "is-danger",
4600
+ disabled: n.tabs.length <= 1,
4601
+ onClick: o[8] ||= (e) => ge("remove"),
4602
+ textContent: b(m.value.remove)
4603
+ }, null, 8, Ki)
4604
+ ], 44, Ii)) : r("", !0)
4605
+ ], 10, Z));
4606
+ }
4607
+ }), Ji = ["data-tabula-theme", "aria-label"], Yi = { class: "tabula-find-field" }, Xi = { class: "tabula-find-field" }, Zi = ["aria-label"], Qi = ["aria-pressed", "disabled"], $i = ["aria-pressed", "disabled"], ea = ["aria-pressed"], ta = [
4608
+ "aria-pressed",
4609
+ "title",
4610
+ "aria-label"
4611
+ ], na = ["aria-pressed", "title"], ra = {
4612
+ class: "tabula-find-count",
4613
+ role: "status"
4614
+ }, ia = ["aria-label", "disabled"], aa = ["aria-label", "disabled"], oa = { class: "tabula-find-actions" }, sa = {
4615
+ key: 0,
4616
+ class: "tabula-find-note",
4617
+ role: "status"
4618
+ }, ca = ["disabled"], la = ["disabled"], ua = ["aria-label"], da = 120, fa = /* @__PURE__ */ c({
4619
+ __name: "TabulaFind",
4620
+ props: /*@__PURE__*/ l({
4621
+ grid: {
4622
+ type: Object,
4623
+ default: null
4624
+ },
4625
+ store: {
4626
+ type: Object,
4627
+ required: !0
4628
+ },
4629
+ schema: {
4630
+ type: Object,
4631
+ required: !0
4632
+ },
4633
+ view: {
4634
+ type: Object,
4635
+ default: void 0
4636
+ },
4637
+ valueSettings: {
4638
+ type: Object,
4639
+ default: () => N.tr
4640
+ },
4641
+ locale: {
4642
+ type: String,
4643
+ default: "tr"
4644
+ },
4645
+ theme: {
4646
+ type: String,
4647
+ default: "light"
4648
+ }
4649
+ }, {
4650
+ open: {
4651
+ type: Boolean,
4652
+ default: !1
4653
+ },
4654
+ openModifiers: {},
4655
+ found: { default: null },
4656
+ foundModifiers: {}
4657
+ }),
4658
+ emits: /*@__PURE__*/ l(["replaced"], ["update:open", "update:found"]),
4659
+ setup(e, { emit: n }) {
4660
+ let o = e, s = n, c = w(e, "open"), l = w(e, "found"), d = t(() => Be[o.locale]), f = g(""), m = g(""), _ = g("sheet"), v = g(!1), S = g(!1), C = g(0), T = y([]), D = g(null), O = y([]), k = g(null), A = g(null), j = null, M = null, ne = t(() => k.value && o.schema.has(k.value) ? o.schema.field(k.value).label : null), re = t(() => f.value === "" ? "" : T.value.length === 0 ? d.value.none : (d.value.count ?? "").replace("{current}", String(C.value + 1)).replace("{total}", String(T.value.length)));
4661
+ function ie(e) {
4662
+ return JSON.stringify([e.rowId, e.field]);
4663
+ }
4664
+ function N() {
4665
+ return {
4666
+ settings: o.valueSettings,
4667
+ matchCase: v.value,
4668
+ whole: S.value,
4669
+ locale: o.locale === "tr" ? "tr-TR" : "en"
4670
+ };
4671
+ }
4672
+ function ae() {
4673
+ let e = x(o.store), t = x(o.schema), n = x(o.view), r = n ? Array.from({ length: n.size }, (e, t) => n.rowIdAt(t)).filter((e) => e !== void 0) : e.rowIds(), i = o.grid?.shownFields() ?? t.keys(), a;
4674
+ if (_.value === "selection") {
4675
+ let n = new Set(O.value.map(ie)), o = new Set(O.value.map((e) => e.rowId)), s = new Set(O.value.map((e) => e.field));
4676
+ a = P(e, t, r.filter((e) => o.has(e)), i.filter((e) => s.has(e)), f.value, N()).filter((e) => n.has(ie(e)));
4677
+ } else {
4678
+ let n = _.value === "column" ? k.value ? [k.value] : [] : i;
4679
+ a = P(e, t, r, n, f.value, N());
4680
+ }
4681
+ T.value = a, C.value = Math.min(C.value, Math.max(0, a.length - 1)), se();
4682
+ }
4683
+ function oe() {
4684
+ j !== null && clearTimeout(j), j = setTimeout(() => {
4685
+ j = null, ae();
4686
+ }, da);
4687
+ }
4688
+ function se() {
4689
+ l.value = c.value && f.value !== "" ? {
4690
+ cells: T.value,
4691
+ current: T.value[C.value] ?? null
4692
+ } : null;
4693
+ }
4694
+ function ce(e) {
4695
+ let t = T.value.length;
4696
+ t !== 0 && (C.value = (C.value + e + t) % t, se(), le());
4697
+ }
4698
+ function le() {
4699
+ let e = T.value[C.value];
4700
+ e && o.grid?.showCell(e.rowId, e.field);
4701
+ }
4702
+ function ue(e) {
4703
+ let t = be(x(o.store), x(o.schema), e, f.value, m.value, {
4704
+ ...N(),
4705
+ editable: (e, t) => o.grid?.canEdit(e, t) ?? !0
4706
+ });
4707
+ D.value = t.skipped > 0 ? `${(d.value.replaced ?? "").replace("{n}", String(t.replaced))} · ${(d.value.skipped ?? "").replace("{n}", String(t.skipped))}` : (d.value.replaced ?? "").replace("{n}", String(t.replaced)), s("replaced", t.replaced, t.skipped), ae();
4708
+ }
4709
+ function de() {
4710
+ let e = T.value[C.value];
4711
+ e && (ue([e]), le());
4712
+ }
4713
+ function fe() {
4714
+ ue(T.value);
4715
+ }
4716
+ function F() {
4717
+ c.value = !1, o.grid?.focus();
4718
+ }
4719
+ function pe(e) {
4720
+ e.key === "Enter" ? (e.preventDefault(), ce(e.shiftKey ? -1 : 1)) : e.key === "Escape" && (e.preventDefault(), F());
4721
+ }
4722
+ function me(e) {
4723
+ e.key === "Enter" ? (e.preventDefault(), de()) : e.key === "Escape" && (e.preventDefault(), F());
4724
+ }
4725
+ return E(f, () => {
4726
+ C.value = 0, D.value = null, oe();
4727
+ }), E([
4728
+ _,
4729
+ v,
4730
+ S
4731
+ ], () => {
4732
+ C.value = 0, ae();
4733
+ }), E(c, (e) => {
4734
+ M?.(), M = null, e ? (O.value = o.grid?.selectedCells() ?? [], k.value = o.grid?.selectedFields()[0] ?? null, _.value = O.value.length > 1 ? "selection" : "sheet", M = x(o.store).subscribe(() => oe()), ae(), u(() => {
4735
+ A.value?.focus(), A.value?.select();
4736
+ })) : (l.value = null, D.value = null);
4737
+ }, { immediate: !0 }), p(() => {
4738
+ M?.(), j !== null && clearTimeout(j);
4739
+ }), (t, n) => c.value ? (h(), i("div", {
4740
+ key: 0,
4741
+ class: "tabula-find tabula-theme",
4742
+ "data-tabula-theme": e.theme,
4743
+ role: "search",
4744
+ "aria-label": d.value.title
4745
+ }, [
4746
+ a("label", Yi, [a("span", null, b(d.value.find), 1), te(a("input", {
4747
+ ref_key: "findInput",
4748
+ ref: A,
4749
+ "onUpdate:modelValue": n[0] ||= (e) => f.value = e,
4750
+ type: "text",
4751
+ spellcheck: "false",
4752
+ onKeydown: pe
4753
+ }, null, 544), [[ee, f.value]])]),
4754
+ a("label", Xi, [a("span", null, b(d.value.replace), 1), te(a("input", {
4755
+ "onUpdate:modelValue": n[1] ||= (e) => m.value = e,
4756
+ type: "text",
4757
+ spellcheck: "false",
4758
+ onKeydown: me
4759
+ }, null, 544), [[ee, m.value]])]),
4760
+ a("span", {
4761
+ class: "tabula-find-scope",
4762
+ role: "group",
4763
+ "aria-label": d.value.where
4764
+ }, [
4765
+ a("button", {
4766
+ type: "button",
4767
+ "aria-pressed": _.value === "selection",
4768
+ disabled: O.value.length < 2,
4769
+ onClick: n[2] ||= (e) => _.value = "selection"
4770
+ }, b(d.value.selection), 9, Qi),
4771
+ a("button", {
4772
+ type: "button",
4773
+ "aria-pressed": _.value === "column",
4774
+ disabled: !k.value,
4775
+ onClick: n[3] ||= (e) => _.value = "column"
4776
+ }, b(ne.value ? `${d.value.column}: ${ne.value}` : d.value.column), 9, $i),
4777
+ a("button", {
4778
+ type: "button",
4779
+ "aria-pressed": _.value === "sheet",
4780
+ onClick: n[4] ||= (e) => _.value = "sheet"
4781
+ }, b(d.value.sheet), 9, ea)
4782
+ ], 8, Zi),
4783
+ a("button", {
4784
+ type: "button",
4785
+ class: "tabula-find-toggle",
4786
+ "aria-pressed": v.value,
4787
+ title: d.value.matchCase,
4788
+ "aria-label": d.value.matchCase,
4789
+ onClick: n[5] ||= (e) => v.value = !v.value
4790
+ }, " Aa ", 8, ta),
4791
+ a("button", {
4792
+ type: "button",
4793
+ class: "tabula-find-toggle",
4794
+ "aria-pressed": S.value,
4795
+ title: d.value.whole,
4796
+ onClick: n[6] ||= (e) => S.value = !S.value
4797
+ }, b(d.value.wholeShort), 9, na),
4798
+ a("span", ra, b(re.value), 1),
4799
+ a("button", {
4800
+ type: "button",
4801
+ class: "tabula-find-icon",
4802
+ "aria-label": d.value.previous,
4803
+ disabled: T.value.length === 0,
4804
+ onClick: n[7] ||= (e) => ce(-1)
4805
+ }, [...n[9] ||= [a("svg", {
4806
+ viewBox: "0 0 24 24",
4807
+ "aria-hidden": "true"
4808
+ }, [a("path", { d: "m18 15-6-6-6 6" })], -1)]], 8, ia),
4809
+ a("button", {
4810
+ type: "button",
4811
+ class: "tabula-find-icon",
4812
+ "aria-label": d.value.next,
4813
+ disabled: T.value.length === 0,
4814
+ onClick: n[8] ||= (e) => ce(1)
4815
+ }, [...n[10] ||= [a("svg", {
4816
+ viewBox: "0 0 24 24",
4817
+ "aria-hidden": "true"
4818
+ }, [a("path", { d: "m6 9 6 6 6-6" })], -1)]], 8, aa),
4819
+ a("span", oa, [
4820
+ D.value ? (h(), i("span", sa, b(D.value), 1)) : r("", !0),
4821
+ a("button", {
4822
+ type: "button",
4823
+ class: "tabula-find-button",
4824
+ disabled: T.value.length === 0,
4825
+ onClick: de
4826
+ }, b(d.value.replaceOne), 9, ca),
4827
+ a("button", {
4828
+ type: "button",
4829
+ class: "tabula-find-button is-primary",
4830
+ disabled: T.value.length === 0,
4831
+ onClick: fe
4832
+ }, b(d.value.replaceAll), 9, la),
4833
+ a("button", {
4834
+ type: "button",
4835
+ class: "tabula-find-icon",
4836
+ "aria-label": d.value.close,
4837
+ onClick: F
4838
+ }, [...n[11] ||= [a("svg", {
4839
+ viewBox: "0 0 24 24",
4840
+ "aria-hidden": "true"
4841
+ }, [a("path", { d: "M18 6 6 18M6 6l12 12" })], -1)]], 8, ua)
4842
+ ])
4843
+ ], 8, Ji)) : r("", !0);
4844
+ }
4845
+ });
4846
+ export { ze as BAR_TEXT, Le as DRAFT_TEXT, Be as FIND_TEXT, U as GRID_TEXT, Ie as PANEL_TEXT, H as PREVIEW_TEXT, Re as TABS_TEXT, wi as TabulaDraftMapping, fa as TabulaFind, cr as TabulaFormulaBar, kn as TabulaGrid, nr as TabulaIssues, Ur as TabulaPreview, qi as TabulaSheetTabs, vr as TabulaStatusBar, je as columnName, Je as dateExample, He as describeCheck, Ke as functionHelp, Ve as issueText, Me as parseAddress };
4847
+
4848
+ //# sourceMappingURL=index.js.map