@copio/sdk 0.1.2 → 0.1.4
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/LICENSE +661 -0
- package/LICENSE-COMMERCIAL.md +43 -0
- package/README.md +155 -147
- package/THIRD_PARTY_NOTICES.md +416 -0
- package/dist/adapters/image/canvas2d-adapter.js +1 -1
- package/dist/adapters/image/index.js +1 -1
- package/dist/adapters/image/null-image-processor-adapter.js +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/indexeddb-adapter.js +1 -1
- package/dist/adapters/memory-adapter.js +1 -1
- package/dist/adapters/ocr/index.js +1 -1
- package/dist/adapters/ocr/null-ocr-adapter.js +1 -1
- package/dist/adapters/ocr/tesseract-wasm-adapter.js +1 -1
- package/dist/adapters/pdf/index.js +1 -1
- package/dist/adapters/pdf/null-pdf-adapter.js +1 -1
- package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
- package/dist/adapters/storage/index.js +1 -1
- package/dist/adapters/storage/indexeddb-adapter.js +1 -1
- package/dist/adapters/storage/memory-adapter.js +1 -1
- package/dist/adapters/sync/index.js +1 -1
- package/dist/adapters/sync/null-sync-adapter.js +1 -1
- package/dist/adapters/sync/peerjs-adapter.js +1 -1
- package/dist/cdn.js +56 -1276
- package/dist/{chunk-A5G52Q2W.js → chunk-2AB5L3Y2.js} +2 -2
- package/dist/{chunk-DGGK5KEX.js → chunk-4ICUYKSR.js} +2 -2
- package/dist/{chunk-E7JYVRJA.js → chunk-5OTO5WFV.js} +2 -2
- package/dist/{chunk-N4R55VRR.js → chunk-6DSLE3AY.js} +1 -1
- package/dist/chunk-DIU5BGU5.js +2 -0
- package/dist/chunk-FAVTIE3M.js +8 -0
- package/dist/chunk-FFRDPFTS.js +1395 -0
- package/dist/chunk-FQRADJY6.js +2 -0
- package/dist/{chunk-N7Q34F2P.js → chunk-G5EUMLYT.js} +4 -4
- package/dist/{chunk-IUBYFIV6.js → chunk-GGERQ3CJ.js} +11 -11
- package/dist/chunk-IBF5HCYT.js +2 -0
- package/dist/{chunk-PVNRK4OH.js → chunk-J7HWZNIP.js} +2 -2
- package/dist/chunk-K4NR6OAC.js +2 -0
- package/dist/{chunk-SH4P4XSZ.js → chunk-KH5JE65X.js} +2 -2
- package/dist/chunk-L4OVZN23.js +2 -0
- package/dist/chunk-MEE2NNYB.js +2 -0
- package/dist/{chunk-KIMVF5UG.js → chunk-NEEWG3OP.js} +1 -1
- package/dist/chunk-NQW6FFN7.js +50 -0
- package/dist/{chunk-YHLOPPXM.js → chunk-O6FQFVKY.js} +1 -1
- package/dist/{chunk-B7HT2X67.js → chunk-U3V3VZGO.js} +2 -2
- package/dist/{chunk-HN3336JN.js → chunk-ULTSZWZO.js} +1 -1
- package/dist/{chunk-BKZEOOH4.js → chunk-WETG2JD7.js} +2 -2
- package/dist/{chunk-V2FP4EEH.js → chunk-YNY65JUJ.js} +1 -1
- package/dist/chunk-ZT72PD2C.js +2 -0
- package/dist/core.js +1 -1
- package/dist/custom-elements.json +464 -1812
- package/dist/export.js +1 -1
- package/dist/index.js +11 -19
- package/dist/ocr.js +1 -1
- package/dist/scanner.js +24 -1257
- package/dist/sync.js +1 -1
- package/dist/types/js/adapters/storage/blob-store.d.ts +48 -0
- package/dist/types/js/adapters/storage/index.d.ts +11 -4
- package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +46 -9
- package/dist/types/js/adapters/storage/memory-adapter.d.ts +7 -0
- package/dist/types/js/adapters/storage/opfs-adapter.d.ts +160 -0
- package/dist/types/js/adapters/storage/storage-port.d.ts +7 -0
- package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +0 -2
- package/dist/types/js/services/doc-repository.d.ts +1 -0
- package/dist/types/js/services/export-utils.d.ts +8 -12
- package/dist/types/js/services/ocr-service.d.ts +2 -1
- package/dist/types/js/utils/module-loader.d.ts +0 -6
- package/dist/types/js/utils/utils.d.ts +5 -3
- package/dist/types/sdk/core.d.ts +13 -2
- package/dist/types/sdk/elements.d.ts +0 -12
- package/dist/types/sdk/events.d.ts +4 -4
- package/dist/types/sdk/index.d.ts +3 -9
- package/dist/types/sdk/models.d.ts +66 -0
- package/dist/types/sdk/scanner.d.ts +2 -7
- package/dist/types/sdk/styles.d.ts +1 -1
- package/dist/types/sdk/version.d.ts +1 -1
- package/package.json +4 -3
- package/sdk/cdn.js +1 -0
- package/sdk/core.js +60 -0
- package/sdk/events.js +3 -2
- package/sdk/index.js +4 -9
- package/sdk/license.js +1 -0
- package/sdk/models.js +79 -3
- package/sdk/scanner.js +50 -19
- package/sdk/styles.js +12 -5
- package/sdk/sync.js +1 -0
- package/sdk/version.js +2 -1
- package/dist/chunk-36F637QU.js +0 -2
- package/dist/chunk-4JPEWIT4.js +0 -2
- package/dist/chunk-B2EK6INF.js +0 -2
- package/dist/chunk-B5BEYYR2.js +0 -8
- package/dist/chunk-G65H4ZTJ.js +0 -2
- package/dist/chunk-HS6GDZIS.js +0 -2
- package/dist/chunk-IZOWC74B.js +0 -2601
- package/dist/chunk-K6YP7EET.js +0 -8
- package/dist/chunk-LI54F6PA.js +0 -2
- package/dist/chunk-OI4WCW7E.js +0 -2
- package/dist/chunk-UCV3MQ6I.js +0 -33
- package/dist/chunk-XEN5VKAV.js +0 -19
- package/dist/types/js/components/copio-header.d.ts +0 -19
- package/dist/types/js/components/copio-loader.d.ts +0 -6
- package/dist/types/js/core/store.d.ts +0 -2
- package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +0 -9
- package/dist/types/js/routes/doc/copio-carousel.d.ts +0 -43
- package/dist/types/js/routes/doc/copio-images.d.ts +0 -37
- package/dist/types/js/routes/home/copio-row.d.ts +0 -49
- package/dist/types/js/styles/cropper-styles.d.ts +0 -5
package/sdk/models.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0
|
|
1
2
|
/**
|
|
2
3
|
* Core Domain Models & Entities (CPO-045 Hexagonal Architecture)
|
|
3
4
|
*
|
|
@@ -21,8 +22,9 @@ export function normalizeEditStack(edits = {}) {
|
|
|
21
22
|
|
|
22
23
|
/** @type {0|90|180|270} */
|
|
23
24
|
let rotate = 0;
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const rawRot = edits?.rotate !== undefined ? edits.rotate : edits?.rotation;
|
|
26
|
+
if (rawRot !== undefined) {
|
|
27
|
+
const r = ((Math.round(Number(rawRot) / 90) * 90) % 360 + 360) % 360;
|
|
26
28
|
if (r === 90 || r === 180 || r === 270) {
|
|
27
29
|
rotate = /** @type {0|90|180|270} */ (r);
|
|
28
30
|
}
|
|
@@ -40,13 +42,78 @@ export function normalizeEditStack(edits = {}) {
|
|
|
40
42
|
*/
|
|
41
43
|
export function hasActiveEdits(edits) {
|
|
42
44
|
if (!edits) return false;
|
|
45
|
+
const rot = edits.rotate !== undefined ? edits.rotate : edits.rotation;
|
|
43
46
|
return Boolean(
|
|
44
47
|
edits.crop ||
|
|
45
|
-
(
|
|
48
|
+
(rot && rot !== 0) ||
|
|
46
49
|
(edits.filter && edits.filter !== 'none')
|
|
47
50
|
);
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
const roundCoord = (n) => Math.round(n * 1e6) / 1e6;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Transforms normalized crop coordinates through a clockwise rotation angle (0, 90, 180, 270).
|
|
57
|
+
* @param {{ x: number, y: number, w: number, h: number } | null} crop
|
|
58
|
+
* @param {number} [rotation=0] - Clockwise rotation angle in degrees
|
|
59
|
+
* @returns {{ x: number, y: number, w: number, h: number } | null}
|
|
60
|
+
*/
|
|
61
|
+
export function rotateCrop(crop, rotation = 0) {
|
|
62
|
+
if (!crop) return null;
|
|
63
|
+
const rot = ((Math.round(Number(rotation) / 90) * 90) % 360 + 360) % 360;
|
|
64
|
+
const { x, y, w, h } = crop;
|
|
65
|
+
if (rot === 90) {
|
|
66
|
+
return {
|
|
67
|
+
x: roundCoord(Math.max(0, Math.min(1, 1 - y - h))),
|
|
68
|
+
y: roundCoord(Math.max(0, Math.min(1, x))),
|
|
69
|
+
w: roundCoord(Math.max(0.01, Math.min(1, h))),
|
|
70
|
+
h: roundCoord(Math.max(0.01, Math.min(1, w))),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (rot === 180) {
|
|
74
|
+
return {
|
|
75
|
+
x: roundCoord(Math.max(0, Math.min(1, 1 - x - w))),
|
|
76
|
+
y: roundCoord(Math.max(0, Math.min(1, 1 - y - h))),
|
|
77
|
+
w: roundCoord(Math.max(0.01, Math.min(1, w))),
|
|
78
|
+
h: roundCoord(Math.max(0.01, Math.min(1, h))),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (rot === 270) {
|
|
82
|
+
return {
|
|
83
|
+
x: roundCoord(Math.max(0, Math.min(1, y))),
|
|
84
|
+
y: roundCoord(Math.max(0, Math.min(1, 1 - x - w))),
|
|
85
|
+
w: roundCoord(Math.max(0.01, Math.min(1, h))),
|
|
86
|
+
h: roundCoord(Math.max(0.01, Math.min(1, w))),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
x: roundCoord(Math.max(0, Math.min(1, x))),
|
|
91
|
+
y: roundCoord(Math.max(0, Math.min(1, y))),
|
|
92
|
+
w: roundCoord(Math.max(0.01, Math.min(1, w))),
|
|
93
|
+
h: roundCoord(Math.max(0.01, Math.min(1, h))),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Maps normalized crop coordinates on an original unrotated image to a rotated canvas coordinate frame.
|
|
99
|
+
* @param {{ x: number, y: number, w: number, h: number } | null} crop
|
|
100
|
+
* @param {number} [rotation=0]
|
|
101
|
+
* @returns {{ x: number, y: number, w: number, h: number } | null}
|
|
102
|
+
*/
|
|
103
|
+
export function cropOriginalToRotated(crop, rotation = 0) {
|
|
104
|
+
return rotateCrop(crop, rotation);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Maps normalized crop coordinates on a rotated canvas back to original unrotated image coordinates.
|
|
109
|
+
* @param {{ x: number, y: number, w: number, h: number } | null} crop
|
|
110
|
+
* @param {number} [rotation=0]
|
|
111
|
+
* @returns {{ x: number, y: number, w: number, h: number } | null}
|
|
112
|
+
*/
|
|
113
|
+
export function cropRotatedToOriginal(crop, rotation = 0) {
|
|
114
|
+
return rotateCrop(crop, -rotation);
|
|
115
|
+
}
|
|
116
|
+
|
|
50
117
|
/**
|
|
51
118
|
* Page domain entity.
|
|
52
119
|
*/
|
|
@@ -62,6 +129,9 @@ export class Page {
|
|
|
62
129
|
* @param {number} [data.orientation]
|
|
63
130
|
* @param {string|null} [data.ocrText]
|
|
64
131
|
* @param {number|null} [data.ocrConfidence]
|
|
132
|
+
* @param {Array<Object>|null} [data.ocrWords]
|
|
133
|
+
* @param {number|null} [data.ocrWidth]
|
|
134
|
+
* @param {number|null} [data.ocrHeight]
|
|
65
135
|
*/
|
|
66
136
|
constructor(data) {
|
|
67
137
|
this.id = data.id;
|
|
@@ -73,6 +143,9 @@ export class Page {
|
|
|
73
143
|
this.orientation = data.orientation || 1;
|
|
74
144
|
this.ocrText = data.ocrText || null;
|
|
75
145
|
this.ocrConfidence = data.ocrConfidence ?? null;
|
|
146
|
+
this.ocrWords = Array.isArray(data.ocrWords) ? data.ocrWords : null;
|
|
147
|
+
this.ocrWidth = typeof data.ocrWidth === 'number' ? data.ocrWidth : null;
|
|
148
|
+
this.ocrHeight = typeof data.ocrHeight === 'number' ? data.ocrHeight : null;
|
|
76
149
|
}
|
|
77
150
|
|
|
78
151
|
get isModified() {
|
|
@@ -90,6 +163,9 @@ export class Page {
|
|
|
90
163
|
orientation: this.orientation,
|
|
91
164
|
ocrText: this.ocrText,
|
|
92
165
|
ocrConfidence: this.ocrConfidence,
|
|
166
|
+
ocrWords: this.ocrWords,
|
|
167
|
+
ocrWidth: this.ocrWidth,
|
|
168
|
+
ocrHeight: this.ocrHeight,
|
|
93
169
|
};
|
|
94
170
|
}
|
|
95
171
|
}
|
package/sdk/scanner.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0
|
|
1
2
|
/**
|
|
2
3
|
* Copio Scanner Web Component (CPO-034, CPO-035, CPO-036, CPO-037, CPO-038, CPO-045)
|
|
3
4
|
*
|
|
4
5
|
* Embeddable, zero-config two-stage (viewfinder ↔ workbench) document scanner
|
|
5
6
|
* acting as the primary Driving UI Adapter over the headless CopioEngine.
|
|
6
7
|
*/
|
|
7
|
-
import { CopioEngine } from './core.js';
|
|
8
|
+
import { CopioEngine, cropRotatedToOriginal, cropOriginalToRotated } from './core.js';
|
|
8
9
|
import { COPIO_EVENTS, dispatchCopioEvent } from './events.js';
|
|
9
|
-
import { CopioImages } from '../js/routes/doc/copio-images.js';
|
|
10
|
-
import { CopioCarousel } from '../js/routes/doc/copio-carousel.js';
|
|
11
|
-
import { CopioAddEditDialog } from '../js/routes/add-edit/copio-add-edit-dialog.js';
|
|
12
|
-
import { CopioRow } from '../js/routes/home/copio-row.js';
|
|
13
|
-
import { CopioHeader } from '../js/components/copio-header.js';
|
|
14
|
-
import { CopioLoader } from '../js/components/copio-loader.js';
|
|
15
10
|
import { setAssetBase } from '../js/utils/module-loader.js';
|
|
16
11
|
import { setContainer, getContainer } from '../js/services/notify.js';
|
|
17
12
|
import { scannerCss, getScannerStyleSheet, adoptScannerStyles } from './styles.js';
|
|
@@ -472,11 +467,13 @@ export class CopioScanner extends BaseElement {
|
|
|
472
467
|
|
|
473
468
|
// Card switcher buttons
|
|
474
469
|
shadow.getElementById('btn-card-front')?.addEventListener('click', () => {
|
|
470
|
+
this.#cropMode = false;
|
|
475
471
|
this.#activePageIndex = 0;
|
|
476
472
|
this.#syncView();
|
|
477
473
|
});
|
|
478
474
|
|
|
479
475
|
shadow.getElementById('btn-card-back')?.addEventListener('click', () => {
|
|
476
|
+
this.#cropMode = false;
|
|
480
477
|
this.#activePageIndex = 1;
|
|
481
478
|
this.#syncView();
|
|
482
479
|
});
|
|
@@ -705,12 +702,30 @@ export class CopioScanner extends BaseElement {
|
|
|
705
702
|
}
|
|
706
703
|
}
|
|
707
704
|
|
|
708
|
-
//
|
|
705
|
+
// Viewport container state
|
|
706
|
+
const viewport = shadow.getElementById('canvas-viewport');
|
|
707
|
+
if (viewport) {
|
|
708
|
+
viewport.classList.toggle('is-cropping', this.#cropMode);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// Image in viewport: in crop mode show uncropped original with active rotation and filter (WYSIWYG)
|
|
709
712
|
const stageImg = /** @type {HTMLImageElement|null} */ (shadow.getElementById('stage-img'));
|
|
710
713
|
if (stageImg) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
+
if (this.#cropMode) {
|
|
715
|
+
const rot = activePage.edits?.rotate || 0;
|
|
716
|
+
const filter = activePage.edits?.filter || 'none';
|
|
717
|
+
const originalSrc = activePage.originalSrc || activePage.src || '';
|
|
718
|
+
if (rot !== 0 || filter !== 'none') {
|
|
719
|
+
const preview = this.#engine
|
|
720
|
+
? await this.#engine.renderEdits(originalSrc, { rotate: rot, filter })
|
|
721
|
+
: originalSrc;
|
|
722
|
+
stageImg.src = preview || originalSrc;
|
|
723
|
+
} else {
|
|
724
|
+
stageImg.src = originalSrc;
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
stageImg.src = activePage.src || activePage.originalSrc || '';
|
|
728
|
+
}
|
|
714
729
|
}
|
|
715
730
|
|
|
716
731
|
let cropLayer = shadow.getElementById('crop-layer');
|
|
@@ -737,7 +752,11 @@ export class CopioScanner extends BaseElement {
|
|
|
737
752
|
this.#bindCropHandles();
|
|
738
753
|
}
|
|
739
754
|
cropLayer.style.display = 'block';
|
|
740
|
-
|
|
755
|
+
const rot = activePage.edits?.rotate || 0;
|
|
756
|
+
const priorCrop = activePage.edits?.crop;
|
|
757
|
+
this.#draftCrop = priorCrop
|
|
758
|
+
? cropOriginalToRotated(priorCrop, rot)
|
|
759
|
+
: { x: 0.05, y: 0.05, w: 0.9, h: 0.9 };
|
|
741
760
|
this.#updateCropBoxUi();
|
|
742
761
|
} else if (cropLayer) {
|
|
743
762
|
cropLayer.remove();
|
|
@@ -909,6 +928,11 @@ export class CopioScanner extends BaseElement {
|
|
|
909
928
|
const activePage = pages[this.#activePageIndex];
|
|
910
929
|
if (!activePage) return;
|
|
911
930
|
|
|
931
|
+
if (this.#cropMode) {
|
|
932
|
+
this.#cropMode = false;
|
|
933
|
+
this.#draftCrop = null;
|
|
934
|
+
}
|
|
935
|
+
|
|
912
936
|
const currentRotate = activePage.edits?.rotate || 0;
|
|
913
937
|
const newRotate = (currentRotate + 90) % 360;
|
|
914
938
|
|
|
@@ -923,6 +947,11 @@ export class CopioScanner extends BaseElement {
|
|
|
923
947
|
const activePage = pages[this.#activePageIndex];
|
|
924
948
|
if (!activePage) return;
|
|
925
949
|
|
|
950
|
+
if (this.#cropMode) {
|
|
951
|
+
this.#cropMode = false;
|
|
952
|
+
this.#draftCrop = null;
|
|
953
|
+
}
|
|
954
|
+
|
|
926
955
|
const currentFilter = activePage.edits?.filter || 'none';
|
|
927
956
|
const newFilter = currentFilter === 'bw' ? 'none' : 'bw';
|
|
928
957
|
|
|
@@ -942,8 +971,10 @@ export class CopioScanner extends BaseElement {
|
|
|
942
971
|
const draft = this.#draftCrop;
|
|
943
972
|
this.#draftCrop = null;
|
|
944
973
|
if (draft) {
|
|
974
|
+
const rot = activePage.edits?.rotate || 0;
|
|
975
|
+
const originalCrop = cropRotatedToOriginal(draft, rot);
|
|
945
976
|
await this.#engine.applyEdit(this.#targetDocId, activePage.id, {
|
|
946
|
-
crop:
|
|
977
|
+
crop: originalCrop,
|
|
947
978
|
});
|
|
948
979
|
}
|
|
949
980
|
} else {
|
|
@@ -1191,6 +1222,11 @@ export class CopioScanner extends BaseElement {
|
|
|
1191
1222
|
return this.#deleteActivePageWithUndo();
|
|
1192
1223
|
}
|
|
1193
1224
|
|
|
1225
|
+
setCameraStream(stream) {
|
|
1226
|
+
this.#stopCameraStream();
|
|
1227
|
+
this.#cameraStream = stream;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1194
1230
|
get features() {
|
|
1195
1231
|
return this.#engine ? this.#engine.features : [];
|
|
1196
1232
|
}
|
|
@@ -1495,6 +1531,7 @@ export class CopioScanner extends BaseElement {
|
|
|
1495
1531
|
type: 'pdf',
|
|
1496
1532
|
format: 'pdf',
|
|
1497
1533
|
blob,
|
|
1534
|
+
searchable: !!opts.searchable,
|
|
1498
1535
|
docId: this.docId,
|
|
1499
1536
|
});
|
|
1500
1537
|
return blob;
|
|
@@ -1583,12 +1620,6 @@ if (typeof customElements !== 'undefined' && !customElements.get('copio-scanner'
|
|
|
1583
1620
|
}
|
|
1584
1621
|
|
|
1585
1622
|
export {
|
|
1586
|
-
CopioImages,
|
|
1587
|
-
CopioCarousel,
|
|
1588
|
-
CopioAddEditDialog,
|
|
1589
|
-
CopioRow,
|
|
1590
|
-
CopioHeader,
|
|
1591
|
-
CopioLoader,
|
|
1592
1623
|
COPIO_EVENTS,
|
|
1593
1624
|
dispatchCopioEvent,
|
|
1594
1625
|
scannerCss,
|
package/sdk/styles.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0
|
|
1
2
|
/**
|
|
2
3
|
* Copio Scanner Encapsulated Styles & Design Tokens (CPO-032 / CPO-038)
|
|
3
4
|
*
|
|
@@ -790,6 +791,7 @@ export const scannerCss = `
|
|
|
790
791
|
overflow-x: auto;
|
|
791
792
|
min-height: 80px;
|
|
792
793
|
flex-shrink: 0;
|
|
794
|
+
scrollbar-width: thin;
|
|
793
795
|
}
|
|
794
796
|
|
|
795
797
|
.copio-filmstrip-scroll {
|
|
@@ -812,10 +814,13 @@ export const scannerCss = `
|
|
|
812
814
|
height: 70px;
|
|
813
815
|
border-radius: var(--copio-radius-sm);
|
|
814
816
|
overflow: hidden;
|
|
815
|
-
background: #
|
|
817
|
+
background: var(--copio-color-surface-elevated, #1c2736);
|
|
816
818
|
border: 2px solid var(--copio-color-border);
|
|
817
819
|
cursor: pointer;
|
|
818
820
|
transition: all var(--copio-transition-fast);
|
|
821
|
+
display: flex;
|
|
822
|
+
align-items: center;
|
|
823
|
+
justify-content: center;
|
|
819
824
|
}
|
|
820
825
|
|
|
821
826
|
.copio-filmstrip-item.is-active .copio-thumb-container {
|
|
@@ -863,9 +868,11 @@ export const scannerCss = `
|
|
|
863
868
|
}
|
|
864
869
|
|
|
865
870
|
.copio-thumb-img {
|
|
866
|
-
width: 100%;
|
|
867
|
-
height: 100%;
|
|
868
|
-
|
|
871
|
+
max-width: 100%;
|
|
872
|
+
max-height: 100%;
|
|
873
|
+
width: auto;
|
|
874
|
+
height: auto;
|
|
875
|
+
object-fit: contain;
|
|
869
876
|
}
|
|
870
877
|
|
|
871
878
|
/* Edit Action Toolbar & Primary Completion Dock */
|
|
@@ -1161,7 +1168,7 @@ export const scannerCss = `
|
|
|
1161
1168
|
}
|
|
1162
1169
|
.copio-thumb-container {
|
|
1163
1170
|
width: 112px;
|
|
1164
|
-
height:
|
|
1171
|
+
height: 140px;
|
|
1165
1172
|
}
|
|
1166
1173
|
.copio-toolbar,
|
|
1167
1174
|
.copio-controls-dock {
|
package/sdk/sync.js
CHANGED
package/sdk/version.js
CHANGED
package/dist/chunk-36F637QU.js
DELETED
package/dist/chunk-4JPEWIT4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as Da}from"./chunk-LI54F6PA.js";var $t=t=>typeof t;var ja=$t(""),hn=$t(!0),Fa=$t(0),fn=$t($t),Oe="type",qt="default",ms="Listener",xa="Result",Ms="add",Ut="Has",ve="Ids",Wt="Table",Ea=Wt+"s",wn=Wt+ve,oe="Row",Qa=oe+"Count",za=oe+ve,pn="Sorted"+oe+ve,Ie="Cell",Ke=Ie+ve,Ge="Value",ka=Ge+"s",bn=Ge+ve,ot=t=>""+t;var yn=(t,s="",r)=>t.split(s,r),Vs=globalThis,es=Math,Cs=es.max,Ls=es.min,In=es.floor,Ba=isFinite,J=t=>t==null,it=(t,s,r)=>J(t)?r?.():s(t),Wa=t=>t==ja||t==hn,Cn=t=>$t(t)==ja,xt=t=>$t(t)==fn,ie=t=>Array.isArray(t),Ds=(t,s,r)=>t.slice(s,r),Vt=t=>t.length,$a=()=>{};var vs=async(t,s,r)=>{try{return await t()}catch(o){s?.(o)}},xs=(t,s)=>t.includes(s),Ye=(t,s)=>t.every(s),Oa=(t,s)=>Vt(t)===Vt(s)&&Ye(t,((r,o)=>s[o]===r)),Ha=(t,s)=>Ye(t,((r,o)=>o==0||s(t[o-1],r)<=0)),Es=(t,s)=>t.sort(s),St=(t,s)=>t.forEach(s),Yt=(t,s)=>t.map(s),Aa=t=>_a(t,((s,r)=>s+r),0),Ce=t=>Vt(t)==0,_a=(t,s,r)=>t.reduce(s,r),Rt=(t,...s)=>t.push(...s),Pa=t=>t.pop(),qa=t=>t.shift(),ne=t=>{let s=$t(t);return Wa(s)||s==Fa&&Ba(t)?s:void 0};var Xe=(t,s,r,o,l)=>J(l)?t.delCell(s,r,o,!0):t.setCell(s,r,o,l),ks=(t,s,r)=>J(r)?t.delValue(s):t.setValue(s,r),Js=t=>s=>_a(le(s),((r,o)=>r+t(o)),0),ce=t=>t?.size??0,Xt=Js(ce),Jt=Js(Xt),Ts=Js(Jt),dt=(t,s)=>t?.has(s)??!1,E=t=>J(t)||ce(t)==0,le=t=>[...t?.values()??[]],re=t=>t.clear(),V=(t,s)=>t?.forEach(s),kt=(t,s)=>t?.delete(s),Ot=Object,Ja=t=>Ot.getPrototypeOf(t),Ln=Ot.isFrozen,Ua=Ot.entries,Ze=t=>!J(t)&&it(Ja(t),(s=>s==Ot.prototype||J(Ja(s))),(()=>!0)),vn=Ot.keys,de=Ot.freeze,Tn=(t=[])=>Ot.fromEntries(t),ye=(t,s)=>s in t,Ka=(t,s)=>(delete t[s],t),Rn=(t,s)=>St(Ua(t),(([r,o])=>s(o,r))),Pt=(t,s)=>Tn(((r,o)=>Yt(Ua(r),(([l,d])=>o(d,l))))(t,((r,o)=>[o,s(r,o)]))),Et=t=>Ze(t)&&(s=>Vt(vn(s)))(t)==0;var zt=(t,s,r,o=0)=>J(t)||!Ze(t)||!o&&Et(t)||Ln(t)?(r?.(),!1):(Rn(t,((l,d)=>{s(l,d)||Ka(t,d)})),!!o||!Et(t)),h=t=>new Map(t),Gt=t=>[...t?.keys()??[]],u=(t,s)=>t?.get(s),pt=(t,s)=>V(t,((r,o)=>s(o,r))),L=(t,s,r)=>J(r)?(kt(t,s),t):t?.set(s,r),ct=(t,s,r,o)=>(dt(t,s)?o?.(u(t,s)):L(t,s,r()),u(t,s)),Kt=(t,s,r,o=L)=>(Pt(s,((l,d)=>r(t,d,l))),pt(t,(l=>ye(s,l)?0:o(t,l))),t),Tt=(t,s,r,o)=>{let l={};return V(t,((d,p)=>{if(!r?.(d,p)){let v=s?s(d,p):d;o?.(v)||(l[p]=v)}})),l},Hs=(t,s,r)=>Tt(t,(o=>Tt(o,s,r)),E,Et),_e=(t,s,r)=>Tt(t,(o=>Hs(o,s,r)),E,Et),Bt=(t,s)=>{let r=h();return V(t,((o,l)=>r.set(l,s?.(o)??o))),r},As=t=>Bt(t,Bt),Rs=t=>Bt(t,As),Le=(t,s,r,o,l=0)=>it((r?ct:u)(t,s[l],l>Vt(s)-2?r:h),(d=>{if(l>Vt(s)-2)return o?.(d)&&L(t,s[l]),d;let p=Le(d,s,r,o,l+1);return E(d)&&L(t,s[l]),p})),bt=t=>new Set(ie(t)||J(t)?t:[t]),gt=(t,s)=>t?.add(s),ss=(t,s,r,o,l)=>{let d=t.hasRow,p=h(),v=h(),P=h(),D=h(),R=h(),C=h(),_=(I,x,...K)=>{let S=ct(C,I,bt);return St(K,(q=>gt(S,q)&&x&&t.callListener(q))),K},H=(I,...x)=>it(u(C,I),(K=>{St(Ce(x)?le(K):x,(S=>{t.delListener(S),kt(K,S)})),E(K)&&L(C,I)})),Z=(I,x)=>{L(p,I,x),dt(v,I)||(L(v,I,s()),L(D,I,h()),L(R,I,h()),l(P))},et=I=>{L(p,I),L(v,I),L(D,I),L(R,I),H(I),l(P)};return[()=>t,()=>Gt(p),I=>pt(v,I),I=>dt(v,I),I=>u(p,I),I=>u(v,I),(I,x)=>L(v,I,x),Z,(I,x,K,S,q)=>{Z(I,x);let st=h(),f=h(),c=u(D,I),y=u(R,I),F=A=>{let W=lt=>t.getCell(x,A,lt),nt=u(c,A),rt=d(x,A)?r(S(W,A)):void 0;if(nt===rt||ie(nt)&&ie(rt)&&Oa(nt,rt)||L(st,A,[nt,rt]),!J(q)){let lt=u(y,A),Q=d(x,A)?q(W,A):void 0;lt!=Q&&L(f,A,Q)}},B=A=>{K((()=>{V(st,(([,W],nt)=>L(c,nt,W))),V(f,((W,nt)=>L(y,nt,W)))}),st,f,c,y,A),re(st),re(f)};pt(c,F),t.hasTable(x)&&St(t.getRowIds(x),(A=>{dt(c,A)||F(A)})),B(!0),H(I),_(I,0,t.addRowListener(x,null,((A,W,nt)=>F(nt))),t.addTableListener(x,(()=>B())))},et,I=>o(I,P),()=>pt(C,et),_,H]},ts=(t,s)=>Cn(t)?r=>r(t):t??(()=>s??""),Te=(t,s)=>{let r=new WeakMap;return o=>{r.has(o)||r.set(o,t(o));let l=r.get(o);return s?.(l),l}},Sn=/^\d+$/,Ga=()=>{let t=[],s=0;return[r=>(r?qa(t):null)??""+s++,r=>{Sn.test(r)&&Vt(t)<1e3&&Rt(t,r)}]},Re=t=>{let s,[r,o]=Ga(),l=h();return[(d,p,v,P=[],D=()=>[])=>{s??=t();let R=r(1);return L(l,R,[d,p,v,P,D]),gt(Le(p,v??[""],bt),R),R},(d,p,...v)=>St(((P,D=[""])=>{let R=[],C=(_,H)=>H==Vt(D)?Rt(R,_):D[H]===null?V(_,(Z=>C(Z,H+1))):St([D[H],null],(Z=>C(u(_,Z),H+1)));return C(P,0),R})(d,p),(P=>V(P,(D=>u(l,D)[0](s,...p??[],...v))))),d=>it(u(l,d),(([,p,v])=>(Le(p,v??[""],void 0,(P=>(kt(P,d),E(P)?1:0))),L(l,d),o(d),v))),d=>it(u(l,d),(([p,,v=[],P,D])=>{let R=(...C)=>{let _=Vt(C);_==Vt(v)?p(s,...C,...D(C)):J(v[_])?St(P[_]?.(...C)??[],(H=>R(...C,H))):R(...C,v[_])};R()}))]},tr=Te((t=>{let s,r,o,l=100,d=h(),p=h(),v=1,P=h(),D=h(),[R,C,_]=Re((()=>Q)),H=h(),Z=h(),et=[],I=[],x=(w,M)=>{v=0,t.transaction((()=>{let[tt,U]=u(H,M);V(tt,((m,N)=>V(m,((z,G)=>V(z,((j,$)=>Xe(t,N,G,$,j[w]))))))),V(U,((m,N)=>ks(t,N,m[w])))})),v=1},K=w=>{L(H,w),L(Z,w),C(D,[w])},S=(w,M)=>St(((tt,U)=>tt.splice(0,U))(w,M??Vt(w)),K),q=()=>S(et,Vt(et)-l),st=()=>it(s,(()=>{Rt(et,s),q(),S(I),s=void 0,o=1})),f=()=>{s=Pa(et),o=1},c,y,F=(w="")=>(J(s)&&(s=""+r++,L(H,s,[d,p]),rt(s,w),d=h(),p=h(),o=1),s),B=()=>{Ce(et)||(((w,...M)=>{w.unshift(...M)})(I,F()),x(0,s),s=Pa(et),o=1)},A=()=>{Ce(I)||(Rt(et,s),s=qa(I),x(1,s),o=1)},W=()=>{o&&(C(P),o=0)},nt=w=>{let M=F(w);return W(),M},rt=(w,M)=>(lt(w)&&u(Z,w)!==M&&(L(Z,w,M),C(D,[w])),Q),lt=w=>dt(H,w),Q={setSize:w=>(l=w,q(),Q),addCheckpoint:nt,setCheckpoint:rt,getStore:()=>t,getCheckpointIds:()=>[[...et],s,[...I]],forEachCheckpoint:w=>pt(Z,w),hasCheckpoint:lt,getCheckpoint:w=>u(Z,w),goBackward:()=>(B(),W(),Q),goForward:()=>(A(),W(),Q),goTo:w=>{let M=xs(et,w)?B:xs(I,w)?A:null;for(;!J(M)&&w!=s;)M();return W(),Q},addCheckpointIdsListener:w=>R(w,P),addCheckpointListener:(w,M)=>R(M,D,[w]),delListener:w=>(_(w),Q),clear:()=>(S(et),S(I),J(s)||K(s),s=void 0,r=0,nt(),Q),clearForward:()=>(Ce(I)||(S(I),C(P)),Q),destroy:()=>{t.delListener(c),t.delListener(y)},getListenerStats:()=>({checkpointIds:Xt(P),checkpoint:Xt(D)}),_registerListeners:()=>{c=t.addCellListener(null,null,null,((w,M,tt,U,m,N)=>{if(v){st();let z=ct(d,M,h),G=ct(z,tt,h),j=ct(G,U,(()=>[N,void 0]));j[1]=m,j[0]===m&&E(L(G,U))&&E(L(z,tt))&&E(L(d,M))&&f(),W()}})),y=t.addValueListener(null,((w,M,tt,U)=>{if(v){st();let m=ct(p,M,(()=>[U,void 0]));m[1]=tt,m[0]===tt&&E(L(p,M))&&f(),W()}}))}};return de(Q.clear())}),(t=>t._registerListeners())),mn=yn("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"),er=h(Yt(mn,((t,s)=>[t,s])));var sr=Vs.crypto?t=>Vs.crypto.getRandomValues(t):t=>Yt(t,(()=>In(256*es.random())));var Mn=JSON.stringify,Ss=JSON.parse,ae=t=>Mn(t,((s,r)=>{return o=Map,r instanceof o?Ot.fromEntries([...r]):r;var o})),ar=new Vs.TextEncoder;var nr=2**36,rr=2**30,or=2**24,ir=2**18;var Ya=(t,s)=>(t??0)<(s??0)?-1:1,lr=Te((t=>{let s=h(),r=h(),[o,l,d]=Re((()=>K)),[p,v,P,D,R,C,_,,H,Z,et,I]=ss(t,h,(S=>J(S)?"":ie(S)?Yt(S,ot):ot(S)),o,l),x=(S,q,st)=>{let f=R(S);V(st,((c,y)=>q(y,(F=>V(c,(B=>F(B,(A=>t.forEachCell(f,B,A)))))))))},K={setIndexDefinition:(S,q,st,f,c,y=Ya)=>{let F=J(c)?void 0:([B],[A])=>c(B,A);return H(S,q,((B,A,W,nt,rt,lt)=>{let Q=0,w=bt(),M=bt(),tt=C(S);if(V(A,(([U,m],N)=>{let z=bt(U),G=bt(m);V(z,(j=>kt(G,j)?kt(z,j):0)),V(z,(j=>{gt(w,j),it(u(tt,j),($=>{kt($,N),E($)&&(L(tt,j),Q=1)}))})),V(G,(j=>{gt(w,j),dt(tt,j)||(L(tt,j,bt()),Q=1),gt(u(tt,j),N),J(f)||gt(M,j)}))})),B(),E(rt)||(lt?pt(tt,(U=>gt(M,U))):pt(W,(U=>it(u(nt,U),(m=>St(ie(m)?m:[m],(N=>gt(M,N))))))),V(M,(U=>{let m=(z,G)=>y(u(rt,z),u(rt,G),U),N=[...u(tt,U)];Ha(N,m)||(L(tt,U,bt(Es(N,m))),gt(w,U))}))),(Q||lt)&&!J(F)){let U=[...tt];Ha(U,F)||(_(S,h(Es(U,F))),Q=1)}Q&&l(s,[S]),V(w,(U=>l(r,[S,U])))}),ts(st),it(f,ts)),K},delIndexDefinition:S=>(Z(S),K),getStore:p,getIndexIds:v,forEachIndex:S=>P(((q,st)=>S(q,(f=>x(q,f,st))))),forEachSlice:(S,q)=>x(S,q,C(S)),hasIndex:D,hasSlice:(S,q)=>dt(C(S),q),getTableId:R,getSliceIds:S=>Gt(C(S)),getSliceRowIds:(S,q)=>le(u(C(S),q)),addIndexIdsListener:et,addSliceIdsListener:(S,q)=>o(q,s,[S]),addSliceRowIdsListener:(S,q,st)=>o(st,r,[S,q]),delListener:S=>(d(S),K),destroy:I,getListenerStats:()=>({sliceIds:Xt(s),sliceRowIds:Jt(r)})};return de(K)}));var qe=t=>[t,t],ft=(t,s=Xt)=>s(t[0])+s(t[1]),wt=()=>[h(),h()],Na=t=>[...t],Ue=([t,s])=>t===s,be=(t,s,r)=>L(t,s,u(t,s)==-r?void 0:r),Se=()=>{let t,s,r=!1,o=!1,l=0,d=[],p=h(),v=h(),P=h(),D=h(),R=h(),C=h(),_=h(),H=h(),Z=h(),et=h(),I=h(),x=h(),K=h(),S=h(),q=bt(),st=h(),f=h(),c=h(),y=h(),F=wt(),B=wt(),A=wt(),W=wt(),nt=wt(),rt=wt(),lt=wt(),Q=wt(),w=wt(),M=wt(),tt=wt(),U=wt(),m=wt(),N=wt(),z=wt(),G=wt(),j=wt(),$=wt(),T=wt(),at=wt(),ut=wt(),vt=wt(),It=h(),Ct=wt(),[yt,X,mt,Nt]=Re((()=>Lt)),jt=e=>{if(!zt(e,((n,i)=>xs([Oe,qt],i))))return!1;let a=e[Oe];return!(!Wa(a)&&a!=Fa)&&(ne(e[qt])!=a&&Ka(e,qt),!0)},gs=ie,Ve=(e,a)=>(!t||dt(I,a)||Ft(a))&&zt(e,((n,i)=>_t(a,i,n)),(()=>Ft(a))),_t=(e,a,n,i)=>zt(i?n:Ws(n,e,a),((g,b)=>it(De(e,a,b,g),(k=>(n[b]=k,!0)),(()=>!1))),(()=>Ft(e,a))),De=(e,a,n,i)=>t?it(u(u(I,e),n),(g=>ne(i)!=g[Oe]?Ft(e,a,n,i,g[qt]):i),(()=>Ft(e,a,n,i))):J(ne(i))?Ft(e,a,n,i):i,ge=(e,a)=>zt(a?e:un(e),((n,i)=>it(Bs(i,n),(g=>(e[i]=g,!0)),(()=>!1))),(()=>fe())),Bs=(e,a)=>s?it(u(K,e),(n=>ne(a)!=n[Oe]?fe(e,a,n[qt]):a),(()=>fe(e,a))):J(ne(a))?fe(e,a):a,Ws=(e,a,n)=>(it(u(x,a),(([i,g])=>{V(i,((b,k)=>{ye(e,k)||(e[k]=b)})),V(g,(b=>{ye(e,b)||Ft(a,n,b)}))})),e),un=e=>(s&&(V(S,((a,n)=>{ye(e,n)||(e[n]=a)})),V(q,(a=>{ye(e,a)||fe(a)}))),e),$s=e=>Kt(I,e,((a,n,i)=>{let g=h(),b=bt();Kt(ct(I,n,h),i,((k,O,Y)=>{L(k,O,Y),it(Y[qt],(At=>L(g,O,At)),(()=>gt(b,O)))})),L(x,n,[g,b])}),((a,n)=>{L(I,n),L(x,n)})),Os=e=>Kt(K,e,((a,n,i)=>{L(K,n,i),it(i[qt],(g=>L(S,n,g)),(()=>gt(q,n)))}),((a,n)=>{L(K,n),L(S,n),kt(q,n)})),_s=e=>Et(e)?ze():Fe(e),qs=e=>Kt(c,e,((a,n,i)=>xe(n,i)),((a,n)=>Ys(n))),xe=(e,a)=>Kt(ct(c,e,(()=>(ea(e,1),L(st,e,Ga()),L(f,e,h()),h()))),a,((n,i,g)=>he(e,n,i,g)),((n,i)=>Xs(e,n,i))),he=(e,a,n,i,g)=>Kt(ct(a,n,(()=>(sa(e,n,1),h()))),i,((b,k,O)=>hs(e,n,b,k,O)),((b,k)=>Zs(e,a,n,b,k,g))),hs=(e,a,n,i,g)=>{dt(n,i)||aa(e,a,i,1);let b=u(n,i);g!==b&&(na(e,a,i,b,g),L(n,i,g))},Us=(e,a,n,i,g)=>it(u(a,n),(b=>hs(e,n,b,i,g)),(()=>he(e,a,n,Ws({[i]:g},e,n)))),Ks=e=>Et(e)?Be():Qe(e),Gs=e=>Kt(y,e,((a,n,i)=>Ee(n,i)),((a,n)=>ta(n))),Ee=(e,a)=>{dt(y,e)||ra(e,1);let n=u(y,e);a!==n&&(oa(e,n,a),L(y,e,a))},ke=e=>u(c,e)??xe(e,{}),Ys=e=>xe(e,{}),Xs=(e,a,n)=>{let[,i]=u(st,e);i(n),he(e,a,n,{},!0)},Zs=(e,a,n,i,g,b)=>{let k=u(u(x,e)?.[0],g);if(!J(k)&&!b)return hs(e,n,i,g,k);let O=Y=>{na(e,n,Y,u(i,Y)),aa(e,n,Y,-1),L(i,Y)};J(k)?O(g):pt(i,O),E(i)&&(sa(e,n,-1),E(L(a,n))&&(ea(e,-1),L(c,e),L(st,e),L(f,e)))},ta=e=>{let a=u(S,e);if(!J(a))return Ee(e,a);oa(e,u(y,e)),ra(e,-1),L(y,e)},ea=(e,a)=>be(p,e,a),sa=(e,a,n)=>be(ct(D,e,h),a,n)&&L(P,e,ct(P,e,(()=>0))+n),aa=(e,a,n,i)=>{let g=u(f,e),b=u(g,n)??0;(b==0&&i==1||b==1&&i==-1)&&be(ct(v,e,h),n,i),L(g,n,b!=-i?b+i:null),be(ct(ct(R,e,h),a,h),n,i)},na=(e,a,n,i,g)=>{ct(ct(ct(C,e,h),a,h),n,(()=>[i,0]))[1]=g,d[3]?.(e,a,n,g)},ra=(e,a)=>be(_,e,a),oa=(e,a,n)=>{ct(H,e,(()=>[a,0]))[1]=n,d[4]?.(e,n)},Ft=(e,a,n,i,g)=>(Rt(ct(ct(ct(Z,e,h),a,h),n,(()=>[])),i),g),fe=(e,a,n)=>(Rt(ct(et,e,(()=>[])),a),n),He=(e,a,n)=>it(u(u(u(C,e),a),n),(([i,g])=>[!0,i,g]),(()=>[!1,...qe(Pe(e,a,n))])),ia=e=>it(u(H,e),(([a,n])=>[!0,a,n]),(()=>[!1,...qe(Je(e))])),la=e=>E(Z)||E(G[e])?0:V(e?Rs(Z):Z,((a,n)=>V(a,((i,g)=>V(i,((b,k)=>X(G[e],[n,g,k],b))))))),ca=e=>E(et)||E(j[e])?0:V(e?Bt(et):et,((a,n)=>X(j[e],[n],a))),we=(e,a,n,i)=>{if(!E(e))return X(a,i,(()=>Tt(e))),pt(e,((g,b)=>X(n,[...i??[],g],b==1))),1},da=e=>{let a=Ne();a!=r&&X(F[e],void 0,a);let n=E(M[e]),i=E(m[e])&&E(N[e])&&E(w[e])&&E(tt[e])&&E(rt[e])&&E(lt[e])&&E(Q[e])&&n&&E(A[e])&&E(W[e]),g=E(z[e])&&E(U[e])&&E(nt[e])&&E(B[e]);if(!i||!g){let b=e?[Bt(p),As(v),Bt(P),As(D),Rs(R),Rs(C)]:[p,v,P,D,R,C];if(!i){we(b[0],A[e],W[e]),V(b[1],((O,Y)=>we(O,rt[e],lt[e],[Y]))),V(b[2],((O,Y)=>{O!=0&&X(Q[e],[Y],fa(Y))}));let k=bt();V(b[3],((O,Y)=>{we(O,w[e],tt[e],[Y])&&!n&&(X(M[e],[Y,null]),gt(k,Y))})),n||V(b[5],((O,Y)=>{if(!dt(k,Y)){let At=bt();V(O,(Qt=>V(Qt,(([We,$e],pe)=>$e!==We?gt(At,pe):kt(Qt,pe))))),V(At,(Qt=>X(M[e],[Y,Qt])))}})),V(b[4],((O,Y)=>V(O,((At,Qt)=>we(At,m[e],N[e],[Y,Qt])))))}if(!g){let k;V(b[5],((O,Y)=>{let At;V(O,((Qt,We)=>{let $e;V(Qt,(([pe,Va],gn)=>{Va!==pe&&(X(z[e],[Y,We,gn],Va,pe,He),k=At=$e=1)})),$e&&X(U[e],[Y,We],He)})),At&&X(nt[e],[Y],He)})),k&&X(B[e],void 0,He)}}},ua=e=>{let a=je();a!=o&&X($[e],void 0,a);let n=E(at[e])&&E(ut[e]),i=E(vt[e])&&E(T[e]);if(!n||!i){let g=e?[Bt(_),Bt(H)]:[_,H];if(n||we(g[0],at[e],ut[e]),!i){let b;V(g[1],(([k,O],Y)=>{O!==k&&(X(vt[e],[Y],O,k,ia),b=1)})),b&&X(T[e],void 0,ia)}}},ht=(e,...a)=>(Is((()=>e(...Yt(a,ot)))),Lt),ga=(e,a,n,i,g)=>{let b=Ae(e,a,...n);return yt((()=>{let k=Ae(e,a,...n);Oa(k,b)||(b=k,i(Lt,e,a,...n,b))}),M[g?1:0],[e,a],[Mt])},fs=()=>_e(c),Mt=()=>Gt(c),ha=e=>Gt(u(f,ot(e))),fa=e=>ce(u(c,ot(e))),se=e=>Gt(u(c,ot(e))),Ae=(e,a,n,i=0,g)=>{return Ze(e)?Ae(e.tableId,e.cellId,e.descending,e.offset,e.limit):Yt(Ds(Es((b=u(c,ot(e)),k=(O,Y)=>[J(a)?Y:u(O,ot(a)),Y],Yt([...b?.entries()??[]],(([O,Y])=>k(Y,O)))),(([O],[Y])=>Ya(O,Y)*(n?-1:1))),i,J(g)?g:i+g),(([,O])=>O));var b,k},ws=(e,a)=>Gt(u(u(c,ot(e)),ot(a))),Pe=(e,a,n)=>u(u(u(c,ot(e)),ot(a)),ot(n)),ps=()=>Tt(y),bs=()=>Gt(y),Je=e=>u(y,ot(e)),Ne=()=>!E(c),wa=e=>dt(c,ot(e)),pa=(e,a)=>dt(u(f,ot(e)),ot(a)),ba=(e,a)=>dt(u(c,ot(e)),ot(a)),ya=(e,a,n)=>dt(u(u(c,ot(e)),ot(a)),ot(n)),je=()=>!E(y),Ia=e=>dt(y,ot(e)),Fe=e=>ht((()=>(a=>zt(a,Ve,Ft))(e)?qs(e):0)),Qe=e=>ht((()=>ge(e)?Gs(e):0)),Ca=e=>(vs((()=>_s(Ss(e)))),Lt),La=e=>ht((()=>{if((t=zt(e,(a=>zt(a,jt))))&&($s(e),!E(c))){let a=fs();ze(),Fe(a)}})),va=e=>ht((()=>{if(s=(a=>zt(a,jt))(e)){let a=ps();ys(),Be(),s=!0,Os(e),Qe(a)}})),ze=()=>ht((()=>qs({}))),Ta=e=>ht((a=>dt(c,a)?Ys(a):0),e),Ra=(e,a)=>ht(((n,i)=>it(u(c,n),(g=>dt(g,i)?Xs(n,g,i):0))),e,a),Be=()=>ht((()=>Gs({}))),Sa=()=>ht((()=>{$s({}),t=!1})),ys=()=>ht((()=>{Os({}),s=!1})),Is=(e,a)=>{if(l!=-1){ma();let n=e();return Ma(a),n}},ma=()=>(l!=-1&&l++,l==1&&(d[0]?.(),X(It)),Lt),Ma=e=>(l>0&&(l--,l==0&&(l=1,la(1),E(C)||da(1),ca(1),E(H)||ua(1),e?.(Lt)&&(V(C,((a,n)=>V(a,((i,g)=>V(i,(([b],k)=>Xe(Lt,n,g,k,b))))))),re(C),V(H,(([a],n)=>ks(Lt,n,a))),re(H)),X(Ct[0],void 0),l=-1,la(0),E(C)||da(0),ca(0),E(H)||ua(0),d[1]?.(),X(Ct[1],void 0),d[2]?.(),l=0,r=Ne(),o=je(),St([p,v,P,D,R,C,Z,_,H,et],re))),Lt),Lt={getContent:()=>[fs(),ps()],getTables:fs,getTableIds:Mt,getTable:e=>Hs(u(c,ot(e))),getTableCellIds:ha,getRowCount:fa,getRowIds:se,getSortedRowIds:Ae,getRow:(e,a)=>Tt(u(u(c,ot(e)),ot(a))),getCellIds:ws,getCell:Pe,getValues:ps,getValueIds:bs,getValue:Je,hasTables:Ne,hasTable:wa,hasTableCell:pa,hasRow:ba,hasCell:ya,hasValues:je,hasValue:Ia,getTablesJson:()=>ae(c),getValuesJson:()=>ae(y),getJson:()=>ae([c,y]),getTablesSchemaJson:()=>ae(I),getValuesSchemaJson:()=>ae(K),getSchemaJson:()=>ae([I,K]),hasTablesSchema:()=>t,hasValuesSchema:()=>s,setContent:e=>ht((()=>{let a=xt(e)?e():e;gs(a)&&(([n,i])=>{(Et(n)?ze:Fe)(n),(Et(i)?Be:Qe)(i)})(a)})),setTables:Fe,setTable:(e,a)=>ht((n=>Ve(a,n)?xe(n,a):0),e),setRow:(e,a,n)=>ht(((i,g)=>_t(i,g,n)?he(i,ke(i),g,n):0),e,a),addRow:(e,a,n=!0)=>Is((()=>{let i;return _t(e,i,a)&&(e=ot(e),he(e,ke(e),i=((g,b)=>{let[k]=u(st,g),O;do O=k(b);while(dt(u(c,g),O));return O})(e,n?1:0),a)),i})),setPartialRow:(e,a,n)=>ht(((i,g)=>{if(_t(i,g,n,1)){let b=ke(i);Pt(n,((k,O)=>Us(i,b,g,O,k)))}}),e,a),setCell:(e,a,n,i)=>ht(((g,b,k)=>it(De(g,b,k,xt(i)?i(Pe(g,b,k)):i),(O=>Us(g,ke(g),b,k,O)))),e,a,n),setValues:Qe,setPartialValues:e=>ht((()=>ge(e,1)?Pt(e,((a,n)=>Ee(n,a))):0)),setValue:(e,a)=>ht((n=>it(Bs(n,xt(a)?a(Je(n)):a),(i=>Ee(n,i)))),e),applyChanges:e=>ht((()=>{Pt(e[0],((a,n)=>J(a)?Ta(n):Pt(a,((i,g)=>J(i)?Ra(n,g):Pt(i,((b,k)=>Xe(Lt,n,g,k,b))))))),Pt(e[1],((a,n)=>ks(Lt,n,a)))})),setTablesJson:Ca,setValuesJson:e=>(vs((()=>Ks(Ss(e)))),Lt),setJson:e=>ht((()=>vs((()=>{let[a,n]=Ss(e);_s(a),Ks(n)}),(()=>Ca(e))))),setTablesSchema:La,setValuesSchema:va,setSchema:(e,a)=>ht((()=>{La(e),va(a)})),delTables:ze,delTable:Ta,delRow:Ra,delCell:(e,a,n,i)=>ht(((g,b,k)=>it(u(c,g),(O=>it(u(O,b),(Y=>dt(Y,k)?Zs(g,O,b,Y,k,i):0))))),e,a,n),delValues:Be,delValue:e=>ht((a=>dt(y,a)?ta(a):0),e),delTablesSchema:Sa,delValuesSchema:ys,delSchema:()=>ht((()=>{Sa(),ys()})),transaction:Is,startTransaction:ma,getTransactionChanges:()=>[Tt(C,((e,a)=>u(p,a)===-1?void 0:Tt(e,((n,i)=>u(u(D,a),i)===-1?void 0:Tt(n,(([,g])=>g),(g=>Ue(g)))),E,Et)),E,Et),Tt(H,(([,e])=>e),(e=>Ue(e))),1],getTransactionLog:()=>[!E(C),!E(H),_e(C,Na,Ue),_e(Z),Tt(H,Na,Ue),Tt(et),Tt(p),Hs(D),_e(R),Tt(_)],finishTransaction:Ma,forEachTable:e=>V(c,((a,n)=>e(n,(i=>V(a,((g,b)=>i(b,(k=>pt(g,k))))))))),forEachTableCell:(e,a)=>pt(u(f,ot(e)),a),forEachRow:(e,a)=>V(u(c,ot(e)),((n,i)=>a(i,(g=>pt(n,g))))),forEachCell:(e,a,n)=>pt(u(u(c,ot(e)),ot(a)),n),forEachValue:e=>pt(y,e),addSortedRowIdsListener:(e,a,n,i,g,b,k)=>Ze(e)?ga(e.tableId,e.cellId,[e.descending??!1,e.offset??0,e.limit],a,n):ga(e,a,[n,i,g],b,k),addStartTransactionListener:e=>yt(e,It),addWillFinishTransactionListener:e=>yt(e,Ct[0]),addDidFinishTransactionListener:e=>yt(e,Ct[1]),callListener:e=>(Nt(e),Lt),delListener:e=>(mt(e),Lt),getListenerStats:()=>({hasTables:ft(F),tables:ft(B),tableIds:ft(A),hasTable:ft(W),table:ft(nt),tableCellIds:ft(rt),hasTableCell:ft(lt,Jt),rowCount:ft(Q),rowIds:ft(w),sortedRowIds:ft(M),hasRow:ft(tt,Jt),row:ft(U,Jt),cellIds:ft(m,Jt),hasCell:ft(N,Ts),cell:ft(z,Ts),invalidCell:ft(G,Ts),hasValues:ft($),values:ft(T),valueIds:ft(at),hasValue:ft(ut),value:ft(vt),invalidValue:ft(j),transaction:Xt(It)+ft(Ct)}),isMergeable:()=>!1,createStore:Se,addListener:yt,callListeners:X,setInternalListeners:(e,a,n,i,g)=>d=[e,a,n,i,g]};return Pt({[Ut+Ea]:[0,F,[],()=>[Ne()]],[Ea]:[0,B],[wn]:[0,A],[Ut+Wt]:[1,W,[Mt],e=>[wa(...e)]],[Wt]:[1,nt,[Mt]],[Wt+Ke]:[1,rt,[Mt]],[Ut+Wt+Ie]:[2,lt,[Mt,ha],e=>[pa(...e)]],[Qa]:[1,Q,[Mt]],[za]:[1,w,[Mt]],[Ut+oe]:[2,tt,[Mt,se],e=>[ba(...e)]],[oe]:[2,U,[Mt,se]],[Ke]:[2,m,[Mt,se]],[Ut+Ie]:[3,N,[Mt,se,ws],e=>[ya(...e)]],[Ie]:[3,z,[Mt,se,ws],e=>qe(Pe(...e))],InvalidCell:[3,G],[Ut+ka]:[0,$,[],()=>[je()]],[ka]:[0,T],[bn]:[0,at],[Ut+Ge]:[1,ut,[bs],e=>[Ia(...e)]],[Ge]:[1,vt,[bs],e=>qe(Je(e[0]))],InvalidValue:[1,j]},(([e,a,n,i],g)=>{Lt[Ms+g+ms]=(...b)=>yt(b[e],a[b[e+1]?1:0],e>0?Ds(b,0,e):void 0,n,i)})),de(Lt)};var Ps=h([["avg",[(t,s)=>Aa(t)/s,(t,s,r)=>t+(s-t)/(r+1),(t,s,r)=>t+(t-s)/(r-1),(t,s,r,o)=>t+(s-r)/o]],["max",[t=>Cs(...t),(t,s)=>Cs(s,t),(t,s)=>s==t?void 0:t,(t,s,r)=>r==t?void 0:Cs(s,t)]],["min",[t=>Ls(...t),(t,s)=>Ls(s,t),(t,s)=>s==t?void 0:t,(t,s,r)=>r==t?void 0:Ls(s,t)]],["sum",[t=>Aa(t),(t,s)=>t+s,(t,s)=>t-s,(t,s,r)=>t-r+s]]]),Xa=(t,s,r,o,l,d=!1)=>{if(E(r))return;let[p,v,P,D]=l;return d||=J(t),V(o,(([R,C])=>{d||(t=J(R)?v?.(t,C,s++):J(C)?P?.(t,R,s--):D?.(t,C,R,s),d||=J(t))})),d?p(le(r),ce(r)):t},cr=Te((t=>{let s=h(),[r,o,l]=Re((()=>I)),[d,p,v,P,D,R,C,,_,H,Z,et]=ss(t,$a,(x=>isNaN(x)||J(x)||x===!0||x===!1||x===""?void 0:1*x),r,o),I={setMetricDefinition:(x,K,S,q,st,f,c)=>{let y=xt(S)?[S,st,f,c]:u(Ps,S)??u(Ps,"sum");return _(x,K,((F,B,A,W,nt,rt)=>{let lt=R(x),Q=ce(W);rt||=J(lt),F();let w=Xa(lt,Q,W,B,y,rt);Ba(w)||(w=void 0),w!=lt&&(C(x,w),o(s,[x],w,lt))}),ts(q,1)),I},delMetricDefinition:x=>(H(x),I),getStore:d,getMetricIds:p,forEachMetric:v,hasMetric:P,getTableId:D,getMetric:R,addMetricIdsListener:Z,addMetricListener:(x,K)=>r(K,s,[x]),delListener:x=>(l(x),I),destroy:et,getListenerStats:()=>({metric:Xt(s)})};return de(I)})),dr=Te((t=>{let s=t.createStore,r=s(),o=s(),l=h(),{addListener:d,callListeners:p,delListener:v}=o,[P,D,R,C,_,,,H,,Z,et,I,x,K]=ss(t,(()=>!0),$a,d,p),S=(c,y,...F)=>St(F,(B=>gt(ct(ct(l,y,h),c,bt),B))),q=c=>{it(u(l,c),(y=>{pt(y,((F,B)=>V(B,(A=>F.delListener(A))))),re(y)})),St([o,r],(y=>y.delTable(c)))},st=(c,y,F)=>S(y,c,y.addStartTransactionListener(F.startTransaction),y.addDidFinishTransactionListener((()=>F.finishTransaction()))),f={setQueryDefinition:(c,y,F)=>{H(c,y),q(c);let B=[],A=[[null,[y,null,null,[],h()]]],W=[],nt=[],rt=[];F({select:(m,N)=>{let z=xt(m)?[Vt(B)+"",m]:[J(N)?m:N,G=>G(m,N)];return Rt(B,z),{as:G=>z[0]=G}},join:(m,N,z)=>{let G=J(z)||xt(N)?null:N,j=J(G)?N:z,$=[m,[m,G,xt(j)?j:T=>T(j),[],h()]];return Rt(A,$),{as:T=>$[0]=T}},where:(m,N,z)=>Rt(W,xt(m)?m:J(z)?G=>G(m)===N:G=>G(m,N)===z),group:(m,N,z,G,j)=>{let $=[m,[m,xt(N)?[N,z,G,j]:u(Ps,N)??[(T,at)=>at]]];return Rt(nt,$),{as:T=>$[0]=T}},having:(m,N)=>Rt(rt,xt(m)?m:z=>z(m)===N)});let lt=h(B);if(E(lt))return f;let Q=h(A);pt(Q,((m,[,N])=>it(u(Q,N),(({3:z})=>J(m)?0:Rt(z,m)))));let w=h(nt),M=r;if(E(w)&&Ce(rt))M=o;else{st(c,M,o);let m=h();pt(w,((j,[$,T])=>gt(ct(m,$,bt),[j,T])));let N=bt();pt(lt,(j=>dt(m,j)?0:gt(N,j)));let z=h(),G=(j,$,T,at)=>it(j,(([ut,vt,It,Ct])=>{pt($,((yt,[X])=>{let mt=ct(ut,yt,h),Nt=u(mt,T),jt=at?void 0:X;if(Nt!==jt){let gs=bt([[Nt,jt]]),Ve=ce(mt);L(mt,T,jt),V(u(m,yt),(([_t,De])=>{let ge=Xa(Ct[_t],Ve,mt,gs,De);Ct[_t]=J(ne(ge))?null:ge}))}})),E(vt)||!Ye(rt,(yt=>yt((X=>Ct[X]))))?o.delRow(c,It):J(It)?j[2]=o.addRow(c,Ct):o.setRow(c,It,Ct)}));S(M,c,M.addRowListener(c,null,((j,$,T,at)=>{let ut=[],vt=[],It=h(),Ct=M.hasRow(c,T),yt=!Ct;V(N,(X=>{let[mt,Nt,jt]=at(c,T,X);Rt(ut,Nt),Rt(vt,jt),yt||=mt})),pt(m,(X=>{let[mt,,Nt]=at(c,T,X);(yt||mt)&&L(It,X,[Nt])})),yt&&G(Le(z,ut,void 0,(([,X])=>(kt(X,T),E(X)))),It,T,1),Ct&&G(Le(z,vt,(()=>{let X={};return V(N,(mt=>X[mt]=M.getCell(c,T,mt))),[h(),bt(),void 0,X]}),(([,X])=>{gt(X,T)})),It,T)})))}st(c,t,M);let tt=(m,N,z,G)=>{let j=$=>t.getCell(N,z,$);St(G,($=>{let[T,,at,ut,vt]=u(Q,$),It=at?.(j,m),[Ct,yt]=u(vt,m)??[];It!=Ct&&(J(yt)||K(c,yt),L(vt,m,J(It)?null:[It,...x(c,1,t.addRowListener(T,It,(()=>tt(m,T,It,ut))))]))})),($=>{let T=(at,ut)=>t.getCell(...J(ut)?[y,$,at]:at===y?[y,$,ut]:[u(Q,at)?.[0],u(u(Q,at)?.[4],$)?.[0],ut]);M.transaction((()=>Ye(W,(at=>at(T)))?pt(lt,((at,ut)=>Xe(M,c,$,at,ut(T,$)))):M.delRow(c,$)))})(m)},{3:U}=u(Q,null);return M.transaction((()=>x(c,1,t.addRowListener(y,null,((m,N,z)=>{t.hasRow(y,z)?tt(z,y,z,U):(M.delRow(c,z),V(Q,(({4:G})=>it(u(G,z),(([,j])=>{K(c,j),L(G,z)})))))}))))),f},delQueryDefinition:c=>(q(c),Z(c),f),getStore:P,getQueryIds:D,forEachQuery:R,hasQuery:C,getTableId:_,addQueryIdsListener:c=>et((()=>c(f))),delListener:c=>(v(c),f),destroy:I,getListenerStats:()=>{let{tables:c,tableIds:y,transaction:F,...B}=o.getListenerStats();return B}};return Pt({[Wt]:[1,1],[Wt+Ke]:[0,1],[Qa]:[0,1],[za]:[0,1],[pn]:[0,5],[oe]:[1,2],[Ke]:[0,2],[Ie]:[1,3]},(([c,y],F)=>{St(c?["get","has","forEach"]:["get"],(B=>f[B+xa+F]=(...A)=>o[B+F](...A))),f[Ms+xa+F+ms]=(...B)=>o[Ms+F+ms](...Ds(B,0,y),((A,...W)=>B[y](f,...W)),!0)})),de(f)})),ur=Te((t=>{let s=h(),r=h(),o=h(),l=h(),[d,p,v]=Re((()=>st)),[P,D,R,C,_,H,,,Z,et,I,x]=ss(t,(()=>[h(),h(),h(),h()]),(f=>J(f)?void 0:f+""),d,p),K=(f,c,y)=>it(H(f),(([F,,B])=>{if(!dt(B,c)){let A=bt();if(_(f)!=q(f))gt(A,c);else{let W=c;for(;!J(W)&&!dt(A,W);)gt(A,W),W=u(F,W)}if(y)return A;L(B,c,A)}return u(B,c)})),S=(f,c)=>it(H(f),(([,,y])=>L(y,c))),q=f=>u(s,f),st={setRelationshipDefinition:(f,c,y,F)=>(L(s,f,y),Z(f,c,((B,A)=>{let W=bt(),nt=bt(),rt=bt(),[lt,Q]=H(f);V(A,(([w,M],tt)=>{J(w)||(gt(nt,w),it(u(Q,w),(U=>{kt(U,tt),E(U)&&L(Q,w)}))),J(M)||(gt(nt,M),dt(Q,M)||L(Q,M,bt()),gt(u(Q,M),tt)),gt(W,tt),L(lt,tt,M),pt(u(l,f),(U=>{dt(K(f,U),tt)&>(rt,U)}))})),B(),V(W,(w=>p(r,[f,w]))),V(nt,(w=>p(o,[f,w]))),V(rt,(w=>{S(f,w),p(l,[f,w])}))}),ts(F)),st),delRelationshipDefinition:f=>(L(s,f),et(f),st),getStore:P,getRelationshipIds:D,forEachRelationship:f=>R((c=>f(c,(y=>t.forEachRow(_(c),y))))),hasRelationship:C,getLocalTableId:_,getRemoteTableId:q,getRemoteRowId:(f,c)=>u(H(f)?.[0],c),getLocalRowIds:(f,c)=>le(u(H(f)?.[1],c)),getLinkedRowIds:(f,c)=>J(H(f))?[c]:le(K(f,c,!0)),addRelationshipIdsListener:I,addRemoteRowIdListener:(f,c,y)=>d(y,r,[f,c]),addLocalRowIdsListener:(f,c,y)=>d(y,o,[f,c]),addLinkedRowIdsListener:(f,c,y)=>(K(f,c),d(y,l,[f,c])),delListener:f=>(S(...v(f)??[]),st),destroy:x,getListenerStats:()=>({remoteRowId:Jt(r),localRowIds:Jt(o),linkedRowIds:Jt(l)})};return de(st)}));var en=Promise,Vn=globalThis,Za=Vn.window,Dn=1e3,xn=(t,s,r)=>setInterval(t,s*Dn),En=clearInterval,Ht=t=>t==null,is=(t,s,r)=>Ht(t)?r?.():s(t),js=t=>Array.isArray(t),te=t=>t.length,kn=(t,s)=>t.test(s),sn=t=>new en(t),an=async t=>en.all(t),nn=t=>{throw new Error(t)},Zt=async(t,s,r)=>{try{return await t()}catch(o){s?.(o)}},Fs=(t,s)=>t.forEach(s),me=(t,s)=>t.map(s),Hn=(t,s)=>t.splice(0,s),ls=(t,...s)=>t.push(...s),rn=t=>t.shift(),ue=Object,tn=t=>ue.getPrototypeOf(t),An=ue.entries,Pn=t=>!Ht(t)&&is(tn(t),s=>s==ue.prototype||Ht(tn(s)),()=>!0),Jn=ue.keys,Nn=ue.freeze,jn=(t=[])=>ue.fromEntries(t),Fn=(t,s)=>s in t,Qn=(t,s)=>me(An(t),([r,o])=>s(o,r)),zn=t=>te(Jn(t)),as=t=>Pn(t)&&zn(t)==0,Bn=t=>t?.size??0,Wn=(t,s)=>t?.has(s)??!1,on=t=>Ht(t)||Bn(t)==0,ln=(t,s)=>t?.forEach(s),cn=(t,s)=>t?.delete(s),Me=t=>new Map(t),Dt=(t,s)=>t?.get(s),ee=(t,s,r)=>Ht(r)?(cn(t,s),t):t?.set(s,r),Qs=(t,s,r,o)=>(Wn(t,s)?o?.(Dt(t,s)):ee(t,s,r()),Dt(t,s)),zs=(t,s,r,o,l=0)=>is((r?Qs:Dt)(t,s[l],l>te(s)-2?r:Me),d=>{if(l>te(s)-2)return o?.(d)&&ee(t,s[l]),d;let p=zs(d,s,r,o,l+1);return on(d)&&ee(t,s[l]),p}),$n=/^\d+$/,On=()=>{let t=[],s=0;return[r=>(r?rn(t):null)??""+s++,r=>{kn($n,r)&&te(t)<1e3&&ls(t,r)}]},_n=t=>new Set(js(t)||Ht(t)?t:[t]),qn=(t,s)=>t?.add(s),Un=(t,s=[""])=>{let r=[],o=(l,d)=>d==te(s)?ls(r,l):s[d]===null?ln(l,p=>o(p,d+1)):Fs([s[d],null],p=>o(Dt(l,p),d+1));return o(t,0),r},Kn=t=>{let s,[r,o]=On(),l=Me();return[(d,p,v,P=[],D=()=>[])=>{s??=t();let R=r(1);return ee(l,R,[d,p,v,P,D]),qn(zs(p,v??[""],_n),R),R},(d,p,...v)=>Fs(Un(d,p),P=>ln(P,D=>Dt(l,D)[0](s,...p??[],...v))),d=>is(Dt(l,d),([,p,v])=>(zs(p,v??[""],void 0,P=>(cn(P,d),on(P)?1:0)),ee(l,d),o(d),v)),d=>is(Dt(l,d),([p,,v=[],P,D])=>{let R=(...C)=>{let _=te(C);_==te(v)?p(s,...C,...D(C)):Ht(v[_])?Fs(P[_]?.(...C)??[],H=>R(...C,H)):R(...C,v[_])};R()})]},ns=Me(),rs=Me(),Gn=(t=1,s,r)=>t!=1&&s.isMergeable()?[1,s.getMergeableContent,()=>s.getTransactionMergeableChanges(!r),([[o],[l]])=>!as(o)||!as(l),s.setDefaultContent]:t!=2?[0,s.getContent,s.getTransactionChanges,([o,l])=>!as(o)||!as(l),s.setContent]:nn("Store type not supported by this Persister"),Yn=(t,s,r,o,l,d,p,v={},P=0,D=[])=>{let R=0,C=0,_=0,H,Z,et;Qs(ns,D,()=>0),Qs(rs,D,()=>[]);let I=Me(),[x,K,S,q,st]=Gn(p,t,P),[f,c,y]=Kn(()=>$),F=T=>{T!=R&&(R=T,c(I,void 0,R))},B=async()=>{if(!Dt(ns,D)){for(ee(ns,D,1);!Ht(H=rn(Dt(rs,D)));)await Zt(H,d);ee(ns,D,0)}},A=T=>{(x&&js(T?.[0])?T?.[2]===1?t.applyMergeableChanges:t.setMergeableContent:T?.[2]===1?t.applyChanges:t.setContent)(T)},W=async T=>(R!=2&&(F(1),C++,await j(async()=>{await Zt(async()=>{let at=await s();js(at)?A(at):T?st(T):nn(`Content is not an array: ${at}`)},()=>{T&&st(T)}),F(0)})),$),nt=async T=>(rt(),await W(T),await Zt(async()=>Z=await o(async(at,ut)=>{ut||at?R!=2&&(F(1),C++,A(ut??at),F(0)):await W()}),d),$),rt=async()=>(Z&&(await Zt(()=>l(Z),d),Z=void 0),$),lt=()=>!Ht(Z),Q=async T=>(R!=1&&(F(2),_++,await j(async()=>{await Zt(()=>r(K,T),d),F(0)})),$),w=async()=>(M(),await Q(),et=t.addDidFinishTransactionListener(()=>{let T=S();q(T)&&Q(T)}),$),M=async()=>(et&&(t.delListener(et),et=void 0),$),tt=()=>!Ht(et),U=async(T,at=!1)=>{let[ut,vt]=at?[w,nt]:[nt,w];return await ut(T),await vt(T),$},m=async(T=!1)=>{let[at,ut]=T?[M,rt]:[rt,M];return await at(),await ut(),$},N=()=>R,z=T=>f(T,I),G=T=>(y(T),t),j=async(...T)=>(ls(Dt(rs,D),...T),await B(),$),$={load:W,startAutoLoad:nt,stopAutoLoad:rt,isAutoLoading:lt,save:Q,startAutoSave:w,stopAutoSave:M,isAutoSaving:tt,startAutoPersisting:U,stopAutoPersisting:m,getStatus:N,addStatusListener:z,delListener:G,schedule:j,getStore:()=>t,destroy:()=>(Hn(Dt(rs,D)),m()),getStats:()=>({loads:C,saves:_}),...v};return Nn($)},Ns=["t","v"],Xn={keyPath:"k"},Zn=async(t,s)=>{let r=Qn(s,(o,l)=>os(t,"put",{k:l,v:o}));me(await os(t,"getAllKeys"),o=>Fn(s,o)?0:ls(r,os(t,"delete",o))),await an(r)},os=async(t,s,r)=>sn((o,l)=>{let d=t[s](r);d.onsuccess=()=>o(d.result),d.onerror=()=>l(`objectStore.${s} error`)}),cs=(t,s,r=1,o)=>{let l=async(d,p=[],v=0)=>sn((P,D)=>{let R=(Za?Za.indexedDB:indexedDB).open(s,v?2:void 0);R.onupgradeneeded=()=>v&&me(Ns,C=>Zt(()=>R.result.createObjectStore(C,Xn))),R.onsuccess=()=>Zt(async()=>{let C=R.result.transaction(Ns,"readwrite"),_=await an(me(Ns,(H,Z)=>d(C.objectStore(H),p[Z])));R.result.close(),P(_)},C=>{R.result.close(),D(C)}),R.onerror=()=>D("indexedDB.open error")});return Yn(t,async()=>await l(async d=>jn(me(await os(d,"getAll"),({k:p,v})=>[p,v]))),d=>l((p,v)=>Zn(p,v),d(),1),d=>xn(d,r),d=>En(d),o,1,{getDbName:()=>s})};var ds=Se();ds.setTable("docs",{});var us=cs(ds,"copio-db");us.startAutoLoad();us.startAutoSave();var dn=class extends Da{#t=null;#e=null;#s="copio-db";#n=!1;constructor(s={}){super(),s.dbName&&s.dbName!=="copio-db"?(this.#s=s.dbName,this.#t=s.store||Se(),this.#t.setTable("docs",{}),this.#e=s.persister||cs(this.#t,this.#s),this.#n=!0):(this.#t=s.store||ds,this.#e=s.persister||us,this.#s="copio-db")}get store(){return this.#t}get persister(){return this.#e}async init(){return this.#n?(await this.#e.load(),this.#e.startAutoLoad(),this.#e.startAutoSave()):await this.#e.load(),{kind:"indexeddb",persistent:!0}}listDocsSync(){let s=this.#t.getTable("docs");return Object.entries(s||{}).map(([r,o])=>({id:r,name:o.name||"",pages:this.#a(o.pages)}))}async listDocs(){return this.listDocsSync()}getDocSync(s){if(!this.#t.hasRow("docs",s))return null;let r=this.#t.getRow("docs",s);return{id:s,name:r.name||"",pages:this.#a(r.pages)}}async getDoc(s){return this.getDocSync(s)}async saveDoc(s,r){if(!s)throw new Error("Cannot save document without an ID");let o=Array.isArray(r.pages)?r.pages:this.#a(r.pages);this.#t.setRow("docs",s,{name:r.name||"",pages:JSON.stringify(o)})}async deleteDoc(s){this.#t.delRow("docs",s)}async savePage(s,r,o){let l=await this.getDoc(s);if(!l)throw new Error(`Document ${s} not found`);let d=l.pages.findIndex(p=>p.id===r);if(d>=0)typeof o=="object"&&o!==null&&!(o instanceof Blob)?l.pages[d]={...l.pages[d],...o}:l.pages[d]={...l.pages[d],src:o};else{let p=typeof o=="object"&&o!==null&&!(o instanceof Blob)?{id:r,...o}:{id:r,src:o};l.pages.push(p)}await this.saveDoc(s,l)}async getPage(s,r){let o=await this.getDoc(s);if(!o)return null;let l=o.pages.find(d=>d.id===r);return l?l.src??l:null}async deletePage(s,r){let o=await this.getDoc(s);o&&(o.pages=o.pages.filter(l=>l.id!==r),await this.saveDoc(s,o))}subscribe(s){let r=this.#t.addTableListener("docs",s);return()=>{this.#t.delListener(r)}}#a(s){if(Array.isArray(s))return s;if(typeof s=="string")try{return JSON.parse(s)}catch{return[]}return[]}};export{dn as a};
|
|
2
|
-
//# sourceMappingURL=chunk-4JPEWIT4.js.map
|
package/dist/chunk-B2EK6INF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-YHLOPPXM.js";import{c as e}from"./chunk-K6YP7EET.js";import{a}from"./chunk-IUBYFIV6.js";var s=class extends t{async exportDocumentAsPdf(r,o,n={}){return e(r,o,n)}async renderPdfPagesToDataUrls(r){let o=r instanceof ArrayBuffer?r:await r.arrayBuffer();return a(o)}};export{s as a};
|
|
2
|
-
//# sourceMappingURL=chunk-B2EK6INF.js.map
|
package/dist/chunk-B5BEYYR2.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{d as y}from"./chunk-V2FP4EEH.js";import{c as b,k as x}from"./chunk-G65H4ZTJ.js";var A=[{code:"eng",label:"English",flag:"\u{1F1EC}\u{1F1E7}"},{code:"spa",label:"Spanish (Espa\xF1ol)",flag:"\u{1F1EA}\u{1F1F8}"},{code:"fra",label:"French (Fran\xE7ais)",flag:"\u{1F1EB}\u{1F1F7}"},{code:"deu",label:"German (Deutsch)",flag:"\u{1F1E9}\u{1F1EA}"},{code:"ita",label:"Italian (Italiano)",flag:"\u{1F1EE}\u{1F1F9}"},{code:"por",label:"Portuguese (Portugu\xEAs)",flag:"\u{1F1F5}\u{1F1F9}"},{code:"nld",label:"Dutch (Nederlands)",flag:"\u{1F1F3}\u{1F1F1}"},{code:"pol",label:"Polish (Polski)",flag:"\u{1F1F5}\u{1F1F1}"},{code:"rus",label:"Russian (\u0420\u0443\u0441\u0441\u043A\u0438\u0439)",flag:"\u{1F1F7}\u{1F1FA}"},{code:"chi_sim",label:"Chinese Simplified (\u7B80\u4F53\u4E2D\u6587)",flag:"\u{1F1E8}\u{1F1F3}"},{code:"chi_tra",label:"Chinese Traditional (\u7E41\u9AD4\u4E2D\u6587)",flag:"\u{1F1F9}\u{1F1FC}"},{code:"jpn",label:"Japanese (\u65E5\u672C\u8A9E)",flag:"\u{1F1EF}\u{1F1F5}"},{code:"kor",label:"Korean (\uD55C\uAD6D\uC5B4)",flag:"\u{1F1F0}\u{1F1F7}"},{code:"ara",label:"Arabic (\u0627\u0644\u0639\u0631\u0628\u064A\u0629)",flag:"\u{1F1F8}\u{1F1E6}"},{code:"hin",label:"Hindi (\u0939\u093F\u0928\u094D\u0926\u0940)",flag:"\u{1F1EE}\u{1F1F3}"},{code:"tur",label:"Turkish (T\xFCrk\xE7e)",flag:"\u{1F1F9}\u{1F1F7}"},{code:"vie",label:"Vietnamese (Ti\u1EBFng Vi\u1EC7t)",flag:"\u{1F1FB}\u{1F1F3}"}],c=null,m=null,d=null;function C(e){return e==="eng"?b("assets/tessdata"):"https://tessdata.projectnaptha.com/4.0.0_fast"}function k(e,u=0){let t=Math.round((u||0)*100);switch(e){case"loading tesseract core":return`Downloading OCR engine... ${t>0?t+"%":""}`.trim();case"initializing tesseract":return"Initializing OCR engine...";case"loading language traineddata":case"loaded language traineddata":return`Loading language data... ${t>0?t+"%":""}`.trim();case"initializing api":return"Preparing text recognition...";case"recognizing text":return`Recognizing text... ${t}%`;default:return e&&e.includes("recognizing")?`Recognizing text... ${t}%`:e?`${e.charAt(0).toUpperCase()+e.slice(1)}...`:"Processing..."}}async function E(e="eng",u=null){if(d=u,c&&m===e)return c;if(c){try{await c.terminate()}catch(a){console.warn("Error terminating old OCR worker:",a)}c=null,m=null}let t=null;if(typeof window<"u"&&!window.Tesseract){d&&typeof d=="function"&&d({status:"downloading-engine",progress:.05,message:"Downloading OCR engine..."});try{t=await y.progress({message:"Downloading OCR engine...",total:100,done:0})}catch{}}let s,g;try{s=await x();let a=C(e);g=await s.createWorker(e,1,{workerPath:b("js/lib/tesseract-worker.min.js"),corePath:b("js/lib/tesseract-core"),langPath:a,logger:o=>{if(t&&o.status==="loading tesseract core"){let n=Math.round((o.progress||0)*100);t.update(n,100,`Downloading OCR engine... ${n>0?n+"%":""}`.trim())}if(d&&typeof d=="function"){let n=k(o.status,o.progress);d({status:o.status,progress:typeof o.progress=="number"?o.progress:0,message:n,raw:o})}}})}finally{t?.close()}return c=g,m=e,c}async function O(e,u={}){let{lang:t="eng",onProgress:i=null,abortSignal:s=null}=u;if(s?.aborted){let n=new Error("OCR operation cancelled by user");throw n.name="AbortError",n}i&&i({status:"starting",progress:.05,message:"Starting OCR engine..."});let g=await E(t,i);if(s?.aborted){let n=new Error("OCR operation cancelled by user");throw n.name="AbortError",n}i&&i({status:"recognizing text",progress:.2,message:"Recognizing text..."});let a=null,o=new Promise((n,l)=>{s&&(a=()=>{T();let r=new Error("OCR operation cancelled by user");r.name="AbortError",l(r)},s.addEventListener("abort",a,{once:!0}))});try{let l=(await Promise.race([g.recognize(e),o]))?.data||{},r=(l.text||"").trim(),p=Math.round(l.confidence||0);return i&&i({status:"done",progress:1,message:"Text recognition complete!"}),{text:r,confidence:p,words:l.words||[],lines:l.lines||[],paragraphs:l.paragraphs||[],hocr:l.hocr||""}}finally{s&&a&&s.removeEventListener("abort",a)}}async function v(e,u={}){let{lang:t="eng",onPageProgress:i=null,abortSignal:s=null}=u,g=(e||[]).filter(r=>r.type!=="markdown"&&r.src);if(g.length===0)return{pagesResults:[],combinedText:"",averageConfidence:0,empty:!0};let a=[],o=0;for(let r=0;r<g.length;r++){if(s?.aborted){let f=new Error("OCR operation cancelled by user");throw f.name="AbortError",f}let p=g[r],h=r+1,w=g.length,P=await O(p.src,{lang:t,abortSignal:s,onProgress:f=>{if(i){let R=(r+(f.progress||0))/w;i({pageIndex:r,pageNumber:h,totalPages:w,pageProgress:f.progress||0,overallProgress:R,message:`Page ${h} of ${w}: ${f.message}`})}}});a.push({pageId:p.id,pageIndex:r,pageNumber:h,...P}),o+=P.confidence}let n=a.map(r=>a.length>1?`## Page ${r.pageNumber}
|
|
2
|
-
|
|
3
|
-
${r.text}`:r.text).join(`
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
`),l=Math.round(o/a.length);return{pagesResults:a,combinedText:n,averageConfidence:l}}async function T(){if(c){try{await c.terminate()}catch(e){console.warn("Error during OCR worker termination:",e)}c=null,m=null,d=null}}export{A as a,E as b,O as c,v as d,T as e};
|
|
8
|
-
//# sourceMappingURL=chunk-B5BEYYR2.js.map
|
package/dist/chunk-G65H4ZTJ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var c=".";function l(){return c}function m(n){typeof n=="string"&&(c=n.replace(/\/+$/,"")||".")}function w(n){if(!n)return"";if(/^(https?:|\/\/|data:|blob:)/i.test(n))return n;let e=n.replace(/^\/+/,""),t=c;return!t||t==="."?e:`${t}/${e}`}var s=new Map;function r(n,e){let t=e();if(t)return Promise.resolve(t);if(s.has(n))return s.get(n);let p=new Promise((i,d)=>{if(typeof document>"u"){d(new Error(`Cannot load script "${n}" in an environment without DOM document.`));return}let a=w(n),u=document.querySelector(`script[src="${a}"], script[src="${n}"]`);if(u){if(e()){i(e());return}u.addEventListener("load",()=>i(e()),{once:!0}),u.addEventListener("error",()=>d(new Error(`Failed to load "${n}": Network error`)),{once:!0});return}let o=document.createElement("script");o.src=a,o.async=!0,o.onload=()=>{let f=e();i(f)},o.onerror=()=>{s.delete(n),o.remove(),d(new Error(`Failed to load script "${n}": Network error`))},document.head.appendChild(o)});return s.set(n,p),p}async function j(){return r("js/lib/cropper.js",()=>window.Cropper)}async function x(){return r("js/lib/pdfkit.js",()=>window.PDFDocument)}async function y(){return r("js/lib/jszip.min.js",()=>window.JSZip)}async function P(){return r("js/lib/marked.min.js",()=>window.marked)}async function $(){return r("js/lib/peerjs.min.js",()=>window.Peer)}async function g(){return r("js/lib/qrcode.js",()=>window.qrcode)}async function E(){return r("js/lib/tesseract.min.js",()=>window.Tesseract)}export{l as a,m as b,w as c,r as d,j as e,x as f,y as g,P as h,$ as i,g as j,E as k};
|
|
2
|
-
//# sourceMappingURL=chunk-G65H4ZTJ.js.map
|
package/dist/chunk-HS6GDZIS.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as I,b as p,c as T,l as O}from"./chunk-N7Q34F2P.js";import{a as C}from"./chunk-SH4P4XSZ.js";import{a as w}from"./chunk-36F637QU.js";import{a as d}from"./chunk-B7HT2X67.js";import{a as f}from"./chunk-E7JYVRJA.js";import{a as F,b as S}from"./chunk-G65H4ZTJ.js";var l=class{#e=null;#t=new Map;#s=new Map;constructor(e=w()){this.#e=e}get adapter(){return this.#e}get store(){return this.#e?.store??null}async init(){return this.#e.init()}listDocsSync(){return typeof this.#e.listDocsSync=="function"?this.#e.listDocsSync().map(t=>{let s=this.#i(t.pages);return{id:t.id,name:t.name||"",pageCount:s.length,pages:s}}):[]}async listDocs(){return(await this.#e.listDocs()).map(t=>{let s=this.#i(t.pages);return{id:t.id,name:t.name||"",pageCount:s.length,pages:s}})}getDocSync(e){if(!e)return null;if(typeof this.#e.getDocSync=="function"){let r=this.#e.getDocSync(e);return r?{id:r.id,name:r.name||"",pages:this.#i(r.pages)}:null}let s=this.listDocsSync().find(r=>r.id===e);return s?{id:s.id,name:s.name,pages:s.pages||[]}:null}async getDoc(e){return this.getDocSync(e)}async createDoc(e="Untitled Document",t=[]){let s=p(),r=this.#i(t),n={id:s,name:e||"Untitled Document",pages:r};return await this.#e.saveDoc(s,n),n}async saveDoc(e,t){if(!e)throw new Error("Cannot save document without an ID");let s=this.#i(t.pages);await this.#e.saveDoc(e,{id:e,name:t.name||"",pages:s})}async renameDoc(e,t){let s=await this.getDoc(e);if(!s)throw new Error(`Document "${e}" not found`);s.name=t,await this.saveDoc(e,s)}async deleteDoc(e,{soft:t=!0,timeoutMs:s=5e3}={}){if(!e)return;let r=this.getDocSync(e);if(r){if(this.#o(e),await this.#e.deleteDoc(e),t&&s>0){let n=setTimeout(async()=>{this.#t.delete(e)},s);this.#t.set(e,{doc:r,timerId:n})}return{id:e,name:r.name,undo:()=>this.undoDeleteDoc(e)}}}#o(e){if(this.#t.has(e)){let t=this.#t.get(e);clearTimeout(t.timerId),this.#t.delete(e)}}async undoDeleteDoc(e){let t=this.#t.get(e);return t?(clearTimeout(t.timerId),this.#t.delete(e),await this.#e.saveDoc(e,t.doc),t.doc):null}isSoftDeletedDoc(e){return this.#t.has(e)}async addPages(e,t){let s=await this.getDoc(e);if(!s)throw new Error(`Document "${e}" not found`);let r=Array.isArray(t)?t:[t];s.pages.push(...r),await this.saveDoc(e,s)}async updatePage(e,t,s){let r=await this.getDoc(e);if(!r)throw new Error(`Document "${e}" not found`);let n=r.pages.findIndex(i=>i.id===t);if(n===-1)throw new Error(`Page "${t}" not found in document "${e}"`);r.pages[n]={...r.pages[n],...s},await this.saveDoc(e,r)}async reorderPages(e,t){let s=await this.getDoc(e);if(!s)throw new Error(`Document "${e}" not found`);let r=new Map(s.pages.map(i=>[i.id,i])),n=[];for(let i of t)r.has(i)&&(n.push(r.get(i)),r.delete(i));for(let i of r.values())n.push(i);s.pages=n,await this.saveDoc(e,s)}async deletePage(e,t,{soft:s=!0,timeoutMs:r=5e3}={}){let n=await this.getDoc(e);if(!n)throw new Error(`Document "${e}" not found`);let i=n.pages.findIndex(u=>u.id===t);if(i===-1)return;let[a]=n.pages.splice(i,1);await this.saveDoc(e,n);let h=`${e}:${t}`;if(this.#d(h),!s||r<=0){if(typeof this.#e.deletePage=="function")try{await this.#e.deletePage(e,t)}catch(u){console.warn("[DocRepository] Adapter deletePage error:",u)}return}let c=setTimeout(async()=>{if(this.#s.delete(h),typeof this.#e.deletePage=="function")try{await this.#e.deletePage(e,t)}catch(u){console.warn("[DocRepository] Adapter deletePage error:",u)}},r);return this.#s.set(h,{docId:e,pageId:t,page:a,index:i,timerId:c}),{docId:e,pageId:t,undo:()=>this.undoDeletePage(e,t)}}#d(e){if(this.#s.has(e)){let t=this.#s.get(e);clearTimeout(t.timerId),this.#s.delete(e)}}async undoDeletePage(e,t){let s=`${e}:${t}`,r=this.#s.get(s);if(!r)return null;clearTimeout(r.timerId),this.#s.delete(s);let n=await this.getDoc(e);if(!n)return null;let i=Math.min(r.index,n.pages.length);return n.pages.splice(i,0,r.page),await this.saveDoc(e,n),r.page}isSoftDeletedPage(e,t){return this.#s.has(`${e}:${t}`)}subscribe(e){return this.#e.subscribe(e)}async getAllDocs(){let e=await this.listDocs(),t={};for(let s of e)t[s.id]=s;return t}async exportAll(){let e=await this.listDocs(),t={};for(let s of e)t[s.id]={name:s.name,pages:JSON.stringify(s.pages)};return t}async importDocs(e){let t=0;for(let[s,r]of Object.entries(e||{})){await this.getDoc(s)||t++;let i=this.#i(r.pages);await this.saveDoc(s,{name:r.name||"",pages:i})}return t}#i(e){if(Array.isArray(e))return[...e];if(typeof e=="string")try{return JSON.parse(e)}catch{return[]}return[]}},R=new l;var B="2026-11-01T16:24:14.013Z",U="0.1.2";function x(o={}){let e=o&&o.crop&&typeof o.crop=="object"?{x:Math.max(0,Math.min(1,Number(o.crop.x)||0)),y:Math.max(0,Math.min(1,Number(o.crop.y)||0)),w:Math.max(0,Math.min(1,Number(o.crop.w)||1)),h:Math.max(0,Math.min(1,Number(o.crop.h)||1))}:null,t=0;if(o&&o.rotate!==void 0){let r=(Math.round(Number(o.rotate)/90)*90%360+360)%360;(r===90||r===180||r===270)&&(t=r)}let s=o&&o.filter==="bw"?"bw":"none";return{crop:e,rotate:t,filter:s}}function L(o){return o?!!(o.crop||o.rotate&&o.rotate!==0||o.filter&&o.filter!=="none"):!1}var m=class{constructor(e){this.id=e.id,this.src=e.src,this.originalSrc=e.originalSrc||e.src,this.edits=x(e.edits),this.name=e.name||"Page",this.type=e.type||"image",this.orientation=e.orientation||1,this.ocrText=e.ocrText||null,this.ocrConfidence=e.ocrConfidence??null}get isModified(){return L(this.edits)}toJSON(){return{id:this.id,src:this.src,originalSrc:this.originalSrc,edits:this.edits,name:this.name,type:this.type,orientation:this.orientation,ocrText:this.ocrText,ocrConfidence:this.ocrConfidence}}},E=class{constructor(e){this.id=e.id,this.name=e.name||"Untitled Document",this.pages=Array.isArray(e.pages)?e.pages.map(t=>t instanceof m?t:new m(t)):[],this.createdAt=e.createdAt||Date.now(),this.updatedAt=e.updatedAt||Date.now()}get pageCount(){return this.pages.length}toJSON(){return{id:this.id,name:this.name,pages:this.pages.map(e=>e.toJSON()),createdAt:this.createdAt,updatedAt:this.updatedAt}}},P=class{constructor(e={}){this.mode=e.mode==="single"?"single":"batch",this.aspect=e.aspect||"auto",this.docId=e.docId||null,this.maxPages=Math.max(0,Number(e.maxPages)||0),this.stage="viewfinder",this.activePageIndex=0,this.history=[],this.future=[]}pushHistory(e){this.history.push(e),this.future=[],this.history.length>50&&this.history.shift()}undo(){if(this.history.length===0)return null;let e=this.history.pop();return this.future.push(e),e}redo(){if(this.future.length===0)return null;let e=this.future.pop();return this.history.push(e),e}};var $={PAGE_ADDED:"copio:page-added",PAGE_REMOVED:"copio:page-removed",PAGES_CHANGED:"copio:pages-changed",SCAN_COMPLETE:"copio:scan-complete",EXPORT_PROGRESS:"copio:export-progress",EXPORT_COMPLETE:"copio:export-complete",OCR_COMPLETE:"copio:ocr-complete",SYNC_CONNECTED:"copio:sync-connected",ERROR:"copio:error"};function k(o,e,t={}){let s=new CustomEvent(e,{bubbles:!0,composed:!0,cancelable:!0,detail:t});return o&&typeof o.dispatchEvent=="function"&&o.dispatchEvent(s),s}var _=["crop","rotate","filter","ocr","export","sync"],v=["pdf","zip","png","jpg"],A=["eng"],b={};function pe(o,e){!o||!e||(b[o]=e,typeof globalThis<"u"&&(globalThis.__copio_services__=globalThis.__copio_services__||{},globalThis.__copio_services__[o]=e))}function g(o){return b[o]?b[o]:typeof globalThis<"u"&&globalThis.__copio_services__?.[o]?globalThis.__copio_services__[o]:null}function z(o){return o?o instanceof Set?new Set(o):Array.isArray(o)?new Set(o.map(e=>String(e).trim().toLowerCase()).filter(Boolean)):typeof o=="string"?new Set(o.split(/[\s,]+/).map(e=>e.trim().toLowerCase()).filter(Boolean)):new Set(_):new Set(_)}function y(o,e){return o?Array.isArray(o)?o.map(t=>String(t).trim().toLowerCase()).filter(Boolean):typeof o=="string"?o.split(/[\s,]+/).map(t=>t.trim().toLowerCase()).filter(Boolean):[...e]:[...e]}var N=class{#e=new Set(_);#t=[...v];#s=[...A];#o=0;#d="";#i=null;#r=null;#l={};#n=!0;#h=!0;#a=null;#c=new Map;#u=new Map;constructor(e={}){this.#i=e.storage||w(e),this.#r=e.repository||new l(this.#i),e.services&&(this.#l={...e.services}),e.imageProcessor?(this.#a=e.imageProcessor,this.#l.imageProcessor=e.imageProcessor):this.getService("imageProcessor")?this.#a=this.getService("imageProcessor"):typeof document<"u"?this.#a=new O:this.#a=new C,e.features!==void 0&&this.setFeatures(e.features),e.exportFormats!==void 0&&(this.#t=y(e.exportFormats,v)),e.ocrLanguages!==void 0&&(this.#s=y(e.ocrLanguages,A)),e.maxPages!==void 0&&(this.#o=Math.max(0,Number(e.maxPages)||0)),e.assetBase!==void 0&&S(e.assetBase),e.licenseKey!==void 0&&(this.#d=String(e.licenseKey||"")),e.ocr!==void 0?this.ocr=!!e.ocr:e.features!==void 0&&!this.hasFeature("ocr")&&(this.ocr=!1),e.pdf!==void 0?this.pdf=!!e.pdf:e.exportFormats!==void 0&&!this.#t.includes("pdf")&&(this.pdf=!1)}async init(){return this.#i.init()}setService(e,t){this.#l[e]=t}getService(e){return this.#l[e]||g(e)}hasFeature(e){return e?this.#e.has(String(e).trim().toLowerCase()):!1}get features(){return Array.from(this.#e)}setFeatures(e){this.#e=z(e),this.hasFeature("ocr")?(this.#n=!0,this.getService("ocr")instanceof d&&this.setService("ocr",g("ocr"))):(this.#n=!1,this.setService("ocr",new d))}enableFeature(e){if(e){let t=String(e).trim().toLowerCase();this.#e.add(t),t==="ocr"&&(this.#n=!0,this.getService("ocr")instanceof d&&this.setService("ocr",g("ocr")))}}disableFeature(e){if(e){let t=String(e).trim().toLowerCase();this.#e.delete(t),t==="ocr"&&(this.#n=!1,this.setService("ocr",new d))}}get ocr(){return this.#n&&this.hasFeature("ocr")}set ocr(e){this.#n=!!e,this.#n?(this.enableFeature("ocr"),this.getService("ocr")instanceof d&&this.setService("ocr",g("ocr"))):(this.disableFeature("ocr"),this.setService("ocr",new d))}get pdf(){return this.#h&&this.#t.includes("pdf")}set pdf(e){this.#h=!!e,this.#h?(this.#t.includes("pdf")||this.#t.push("pdf"),this.getService("pdf")instanceof f&&this.setService("pdf",g("pdf"))):(this.#t=this.#t.filter(t=>t!=="pdf"),this.setService("pdf",new f))}get exportFormats(){return[...this.#t]}set exportFormats(e){this.#t=y(e,v),this.#t.includes("pdf")?(this.#h=!0,this.getService("pdf")instanceof f&&this.setService("pdf",g("pdf"))):(this.#h=!1,this.setService("pdf",new f))}get ocrLanguages(){return[...this.#s]}set ocrLanguages(e){this.#s=y(e,A)}get maxPages(){return this.#o}set maxPages(e){this.#o=Math.max(0,Number(e)||0)}get assetBase(){return F()}set assetBase(e){S(e)}get licenseKey(){return this.#d}set licenseKey(e){this.#d=String(e||"")}get storage(){return this.#i}setStorage(e){e&&(this.#i=e,this.#r=new l(this.#i))}#g(e,t){this.#c.has(e)||this.#c.set(e,[]);let s=this.#c.get(e);s.push(t),s.length>50&&s.shift(),this.#u.has(e)&&(this.#u.get(e).length=0)}get imageProcessor(){return this.#a}setImageProcessor(e){e&&(this.#a=e,this.setService("imageProcessor",e))}get docs(){return this.#r}async listDocuments(){return this.#r.listDocs()}async getDocument(e){return this.#r.getDoc(e)}async createDocument(e,t){return this.#r.createDoc(e,t)}async deleteDocument(e,t={}){return this.#r.deleteDoc(e,t)}async undoDeleteDocument(e){return this.#r.undoDeleteDoc(e)}async renameDocument(e,t){return this.#r.renameDoc(e,t)}async addPages(e,t){return this.#r.addPages(e,t)}async deletePage(e,t,s={}){return this.#g(e,{type:"delete",pageId:t}),this.#r.deletePage(e,t,s)}async undoDeletePage(e,t){return this.#r.undoDeletePage(e,t)}async updatePage(e,t,s){return this.#r.updatePage(e,t,s)}async reorderPages(e,t){let s=await this.getDocument(e),r=s?.pages?s.pages.map(n=>n.id):[];return this.#g(e,{type:"reorder",priorOrder:r,newOrder:[...t]}),this.#r.reorderPages(e,t)}async#p(e){if(e)return e;let t=await this.listDocuments();return t.length>0?t[0].id:null}async applyEdit(e,t,s){let r=await this.#p(e),n=r?await this.getDocument(r):null;if(!n||!n.pages)throw new Error(`Document with ID "${r||e}" not found`);let i=n.pages.find(M=>M.id===t);if(!i)throw new Error(`Page with ID "${t}" not found in document "${r}"`);let a={...i.edits||{crop:null,rotate:0,filter:"none"}},h=i.src,c=x({...a,...s}),u=i.originalSrc||i.src,D=u;return this.#a&&(D=await this.#a.renderEdits(u,c)),await this.updatePage(r,t,{originalSrc:u,src:D,edits:c}),this.#g(r,{type:"edit",pageId:t,priorEdits:a,priorSrc:h,newEdits:c,newSrc:D}),{...i,originalSrc:u,src:D,edits:c}}async undo(e){let t=await this.#p(e),s=t?this.#c.get(t):null;if(!s||s.length===0)return null;let r=s.pop();return this.#u.has(t)||this.#u.set(t,[]),this.#u.get(t).push(r),r.type==="edit"?(await this.updatePage(t,r.pageId,{edits:r.priorEdits,src:r.priorSrc}),{type:"edit",pageId:r.pageId,restoredEdits:r.priorEdits}):r.type==="delete"?(await this.undoDeletePage(t,r.pageId),{type:"delete",pageId:r.pageId}):r.type==="reorder"?(await this.#r.reorderPages(t,r.priorOrder),{type:"reorder",priorOrder:r.priorOrder}):r}async redo(e){let t=await this.#p(e),s=t?this.#u.get(t):null;if(!s||s.length===0)return null;let r=s.pop();return this.#c.has(t)||this.#c.set(t,[]),this.#c.get(t).push(r),r.type==="edit"?(await this.updatePage(t,r.pageId,{edits:r.newEdits,src:r.newSrc}),{type:"edit",pageId:r.pageId,appliedEdits:r.newEdits}):r.type==="delete"?(await this.deletePage(t,r.pageId),{type:"delete",pageId:r.pageId}):r.type==="reorder"?(await this.reorderPages(t,r.newOrder),{type:"reorder",newOrder:r.newOrder}):r}subscribe(e){return this.#r.subscribe(e)}async addFiles(e,t=null){if(!e||e.length===0)return[];let s=Array.from(e),r=[];for(let i of s)if(i.type==="application/pdf"){let a=this.getService("pdf");if(a&&typeof a.renderPdfPagesToDataUrls=="function"){let h=await a.renderPdfPagesToDataUrls(i);for(let c of h)r.push({id:p(),src:c,originalSrc:c,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:i.name||"PDF Page"})}else console.warn("PDF import service (PdfPort) not registered. Skipping PDF file.")}else if(i.type&&i.type.startsWith("image/")){let a=await T(i),h=null;try{h=await I(i)}catch{}r.push({id:p(),src:a,originalSrc:a,edits:{crop:null,rotation:0,filter:"none"},type:"image",name:i.name||"Captured Image",orientation:h})}if(r.length===0)return[];let n=t;if(n)await this.getDocument(n)||await this.#r.saveDoc(n,{name:"Scanned Document",pages:[]});else{let i=await this.listDocuments();i.length>0?n=i[0].id:n=(await this.createDocument("Scanned Document",[])).id}if(this.#o>0){let i=(await this.getDocument(n))?.pages||[],a=Math.max(0,this.#o-i.length);if(a<=0)throw new Error(`Maximum page limit (${this.#o}) reached`);r.splice(a)}return await this.addPages(n,r),r}async getPages(e=null){let t=e;if(!t){let r=await this.listDocuments();if(r.length===0)return[];t=r[0].id}return(await this.getDocument(t))?.pages||[]}async clear(e=null){let t=e;if(!t){let r=await this.listDocuments();if(r.length===0)return;t=r[0].id}let s=await this.getDocument(t);if(!(!s||!s.pages))for(let r of s.pages)await this.deletePage(t,r.id)}async#f(e){if(Array.isArray(e))return{docName:"document",pages:e,docId:null};if(typeof e=="string"){let s=await this.getDocument(e);return{docName:s?.name||"document",pages:s?.pages||[],docId:e}}let t=await this.listDocuments();if(t.length>0){let s=await this.getDocument(t[0].id);return{docName:s?.name||"document",pages:s?.pages||[],docId:t[0].id}}return{docName:"document",pages:[],docId:null}}async exportPdf(e,t={}){if(!this.hasFeature("export")){let i=new Error('Feature "export" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}if(!this.#h||!this.#t.includes("pdf")){let i=new Error('Feature "pdf" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}let{docName:s,pages:r}=await this.#f(e),n=this.getService("pdf")||this.getService("export");if(!n||typeof n.exportDocumentAsPdf!="function")throw new Error("Export service (PdfPort) is not registered. Import @copio/sdk or register an exportService.");return n.exportDocumentAsPdf(s,r,{download:!1,showProgress:!1,...t})}async exportZip(e,t={}){if(!this.hasFeature("export")){let i=new Error('Feature "export" is disabled');throw Object.assign(i,{code:"FEATURE_DISABLED"}),i}let{docName:s,pages:r}=await this.#f(e),n=this.getService("export");if(!n||typeof n.exportDocumentAsImages!="function")throw new Error("Export service is not registered. Import @copio/sdk or register an exportService.");return n.exportDocumentAsImages(s,r,{download:!1,showProgress:!1,...t})}async runOcr(e,t=null,s={}){if(!this.#n||!this.hasFeature("ocr")){let c=new Error('Feature "ocr" is disabled');throw Object.assign(c,{code:"FEATURE_DISABLED"}),c}let{pages:r}=await this.#f(e),n=r;t&&(n=r.filter(c=>c.id===t));let i=this.getService("ocr");if(!i||typeof i.recognizeDocumentPages!="function")throw new Error("OCR service (OcrPort) is not registered. Import @copio/sdk or register an ocrService.");let a=s.lang||this.#s[0]||"eng",h=await i.recognizeDocumentPages(n,{lang:a,...s});return{text:h.combinedText,...h}}async sync(e={}){if(!this.hasFeature("sync")){let s=new Error('Feature "sync" is disabled');throw Object.assign(s,{code:"FEATURE_DISABLED"}),s}let t=this.getService("sync");if(!t)throw new Error("Sync service (SyncPort) is not registered. Import @copio/sdk or register a syncService.");return new t(this.#r,e.onStateChange)}};export{l as a,R as b,B as c,U as d,x as e,L as f,m as g,E as h,P as i,$ as j,k,_ as l,v as m,A as n,pe as o,g as p,N as q};
|
|
2
|
-
//# sourceMappingURL=chunk-HS6GDZIS.js.map
|