triiiceratops 0.9.12 → 0.10.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.
Files changed (136) hide show
  1. package/dist/ArrowCounterClockwise-aFffCOKw.js +136 -0
  2. package/dist/X-DZEgXrJ8.js +877 -0
  3. package/dist/annotation_tool_point-CZKsj4Nk.js +290 -0
  4. package/dist/components/AnnotationOverlay.svelte +179 -86
  5. package/dist/components/DemoHeader.svelte +12 -0
  6. package/dist/components/LeftFab.svelte +21 -9
  7. package/dist/components/OSDViewer.svelte +24 -4
  8. package/dist/components/SearchPanel.svelte +4 -1
  9. package/dist/components/TriiiceratopsViewer.svelte +114 -47
  10. package/dist/components/TriiiceratopsViewer.svelte.d.ts +5 -5
  11. package/dist/components/TriiiceratopsViewerElement.svelte +2 -2
  12. package/dist/components/TriiiceratopsViewerElement.svelte.d.ts +2 -2
  13. package/dist/custom-element.d.ts +10 -0
  14. package/dist/custom-element.js +13 -0
  15. package/dist/image_filters_reset-BEIf-_QA.js +108 -0
  16. package/dist/index.d.ts +1 -2
  17. package/dist/index.js +0 -1
  18. package/dist/paraglide/messages/_index.d.ts +31 -0
  19. package/dist/paraglide/messages/_index.js +32 -1
  20. package/dist/paraglide/messages/annotation_editor_add_content.d.ts +4 -0
  21. package/dist/paraglide/messages/annotation_editor_add_content.js +34 -0
  22. package/dist/paraglide/messages/annotation_editor_cancel.d.ts +4 -0
  23. package/dist/paraglide/messages/annotation_editor_cancel.js +34 -0
  24. package/dist/paraglide/messages/annotation_editor_create_mode.d.ts +4 -0
  25. package/dist/paraglide/messages/annotation_editor_create_mode.js +34 -0
  26. package/dist/paraglide/messages/annotation_editor_delete.d.ts +4 -0
  27. package/dist/paraglide/messages/annotation_editor_delete.js +34 -0
  28. package/dist/paraglide/messages/annotation_editor_delete_message.d.ts +4 -0
  29. package/dist/paraglide/messages/annotation_editor_delete_message.js +34 -0
  30. package/dist/paraglide/messages/annotation_editor_delete_title.d.ts +4 -0
  31. package/dist/paraglide/messages/annotation_editor_delete_title.js +34 -0
  32. package/dist/paraglide/messages/annotation_editor_delete_tooltip.d.ts +4 -0
  33. package/dist/paraglide/messages/annotation_editor_delete_tooltip.js +34 -0
  34. package/dist/paraglide/messages/annotation_editor_edit_mode.d.ts +4 -0
  35. package/dist/paraglide/messages/annotation_editor_edit_mode.js +34 -0
  36. package/dist/paraglide/messages/annotation_editor_edit_section.d.ts +4 -0
  37. package/dist/paraglide/messages/annotation_editor_edit_section.js +34 -0
  38. package/dist/paraglide/messages/annotation_editor_instruction_create.d.ts +4 -0
  39. package/dist/paraglide/messages/annotation_editor_instruction_create.js +34 -0
  40. package/dist/paraglide/messages/annotation_editor_instruction_edit.d.ts +4 -0
  41. package/dist/paraglide/messages/annotation_editor_instruction_edit.js +34 -0
  42. package/dist/paraglide/messages/annotation_editor_link_placeholder.d.ts +4 -0
  43. package/dist/paraglide/messages/annotation_editor_link_placeholder.js +34 -0
  44. package/dist/paraglide/messages/annotation_editor_redo.d.ts +4 -0
  45. package/dist/paraglide/messages/annotation_editor_redo.js +34 -0
  46. package/dist/paraglide/messages/annotation_editor_save.d.ts +4 -0
  47. package/dist/paraglide/messages/annotation_editor_save.js +34 -0
  48. package/dist/paraglide/messages/annotation_editor_tag_placeholder.d.ts +4 -0
  49. package/dist/paraglide/messages/annotation_editor_tag_placeholder.js +34 -0
  50. package/dist/paraglide/messages/annotation_editor_text_placeholder.d.ts +4 -0
  51. package/dist/paraglide/messages/annotation_editor_text_placeholder.js +34 -0
  52. package/dist/paraglide/messages/annotation_editor_title.d.ts +4 -0
  53. package/dist/paraglide/messages/annotation_editor_title.js +34 -0
  54. package/dist/paraglide/messages/annotation_editor_tool_label.d.ts +4 -0
  55. package/dist/paraglide/messages/annotation_editor_tool_label.js +34 -0
  56. package/dist/paraglide/messages/annotation_editor_undo.d.ts +4 -0
  57. package/dist/paraglide/messages/annotation_editor_undo.js +34 -0
  58. package/dist/paraglide/messages/annotation_tool_point.d.ts +4 -0
  59. package/dist/paraglide/messages/annotation_tool_point.js +34 -0
  60. package/dist/paraglide/messages/annotation_tool_polygon.d.ts +4 -0
  61. package/dist/paraglide/messages/annotation_tool_polygon.js +34 -0
  62. package/dist/paraglide/messages/annotation_tool_rectangle.d.ts +4 -0
  63. package/dist/paraglide/messages/annotation_tool_rectangle.js +34 -0
  64. package/dist/paraglide/messages/image_adjustments_title.d.ts +4 -0
  65. package/dist/paraglide/messages/image_adjustments_title.js +34 -0
  66. package/dist/paraglide/messages/image_filters_brightness.d.ts +4 -0
  67. package/dist/paraglide/messages/image_filters_brightness.js +34 -0
  68. package/dist/paraglide/messages/image_filters_contrast.d.ts +4 -0
  69. package/dist/paraglide/messages/image_filters_contrast.js +34 -0
  70. package/dist/paraglide/messages/image_filters_effects.d.ts +4 -0
  71. package/dist/paraglide/messages/image_filters_effects.js +34 -0
  72. package/dist/paraglide/messages/image_filters_grayscale.d.ts +4 -0
  73. package/dist/paraglide/messages/image_filters_grayscale.js +34 -0
  74. package/dist/paraglide/messages/image_filters_invert.d.ts +4 -0
  75. package/dist/paraglide/messages/image_filters_invert.js +34 -0
  76. package/dist/paraglide/messages/image_filters_reset.d.ts +4 -0
  77. package/dist/paraglide/messages/image_filters_reset.js +34 -0
  78. package/dist/paraglide/messages/image_filters_saturation.d.ts +4 -0
  79. package/dist/paraglide/messages/image_filters_saturation.js +34 -0
  80. package/dist/paraglide/messages/plugins_tooltip.js +1 -1
  81. package/dist/paraglide/messages/settings_transparent_background.d.ts +4 -0
  82. package/dist/paraglide/messages/settings_transparent_background.js +34 -0
  83. package/dist/plugins/annotation-editor/AnnotationEditorController.svelte +166 -0
  84. package/dist/plugins/annotation-editor/AnnotationEditorController.svelte.d.ts +9 -0
  85. package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte +315 -0
  86. package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte.d.ts +24 -0
  87. package/dist/plugins/annotation-editor/AnnotationManager.svelte.d.ts +39 -0
  88. package/dist/plugins/annotation-editor/AnnotationManager.svelte.js +433 -0
  89. package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.d.ts +20 -0
  90. package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.js +67 -0
  91. package/dist/plugins/annotation-editor/adapters/index.d.ts +2 -0
  92. package/dist/plugins/annotation-editor/adapters/index.js +1 -0
  93. package/dist/plugins/annotation-editor/adapters/types.d.ts +23 -0
  94. package/dist/plugins/annotation-editor/adapters/types.js +1 -0
  95. package/dist/plugins/annotation-editor/iife-entry.d.ts +15 -0
  96. package/dist/plugins/annotation-editor/iife-entry.js +35 -0
  97. package/dist/plugins/annotation-editor/index.d.ts +41 -0
  98. package/dist/plugins/annotation-editor/index.js +57 -0
  99. package/dist/plugins/annotation-editor/loader.svelte.d.ts +7 -0
  100. package/dist/plugins/annotation-editor/loader.svelte.js +32 -0
  101. package/dist/plugins/annotation-editor/types.d.ts +41 -0
  102. package/dist/plugins/annotation-editor/types.js +13 -0
  103. package/dist/plugins/annotation-editor.js +32824 -0
  104. package/dist/plugins/image-manipulation/ImageManipulationController.svelte +54 -0
  105. package/dist/plugins/image-manipulation/ImageManipulationController.svelte.d.ts +6 -0
  106. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte +19 -9
  107. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +1 -0
  108. package/dist/plugins/image-manipulation/iife-entry.d.ts +13 -0
  109. package/dist/plugins/image-manipulation/iife-entry.js +17 -0
  110. package/dist/plugins/image-manipulation/index.d.ts +15 -1
  111. package/dist/plugins/image-manipulation/index.js +21 -1
  112. package/dist/plugins/image-manipulation.js +265 -0
  113. package/dist/state/i18n.svelte.js +4 -2
  114. package/dist/state/manifests.svelte.d.ts +5 -0
  115. package/dist/state/manifests.svelte.js +42 -13
  116. package/dist/state/viewer.svelte.d.ts +14 -13
  117. package/dist/state/viewer.svelte.js +63 -74
  118. package/dist/triiiceratops-bundle.js +3208 -3124
  119. package/dist/triiiceratops-element.iife.js +99 -0
  120. package/dist/triiiceratops.css +1 -1
  121. package/dist/types/config.d.ts +5 -0
  122. package/dist/types/plugin.d.ts +21 -62
  123. package/dist/types/plugin.js +1 -23
  124. package/dist/utils/annotationAdapter.d.ts +12 -1
  125. package/dist/utils/annotationAdapter.js +98 -39
  126. package/package.json +13 -6
  127. package/dist/chunks/TriiiceratopsViewer-DpZQA17w.js +0 -10435
  128. package/dist/chunks/openseadragon-5MHeYuQz.js +0 -12427
  129. package/dist/components/TriiiceratopsViewerElementImage.svelte +0 -143
  130. package/dist/components/TriiiceratopsViewerElementImage.svelte.d.ts +0 -27
  131. package/dist/custom-element-image.d.ts +0 -1
  132. package/dist/custom-element-image.js +0 -2
  133. package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.d.ts +0 -19
  134. package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.js +0 -87
  135. package/dist/triiiceratops-element-image.js +0 -555
  136. package/dist/triiiceratops-element.js +0 -114
@@ -0,0 +1,877 @@
1
+ var Et = Object.defineProperty;
2
+ var dt = (a) => {
3
+ throw TypeError(a);
4
+ };
5
+ var Dt = (a, t, s) => t in a ? Et(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
6
+ var gt = (a, t, s) => Dt(a, typeof t != "symbol" ? t + "" : t, s), Rt = (a, t, s) => t.has(a) || dt("Cannot " + s);
7
+ var n = (a, t, s) => (Rt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), h = (a, t, s) => t.has(a) ? dt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s);
8
+ import * as e from "svelte/internal/client";
9
+ import * as Gt from "manifesto.js";
10
+ import "svelte/internal/disclose-version";
11
+ import { hasContext as Tt, getContext as Bt } from "svelte";
12
+ var E, D;
13
+ class jt {
14
+ constructor() {
15
+ h(this, E, e.state(e.proxy({})));
16
+ h(this, D, e.state(e.proxy(/* @__PURE__ */ new Map())));
17
+ }
18
+ get manifests() {
19
+ return e.get(n(this, E));
20
+ }
21
+ set manifests(t) {
22
+ e.set(n(this, E), t, !0);
23
+ }
24
+ get userAnnotations() {
25
+ return e.get(n(this, D));
26
+ }
27
+ set userAnnotations(t) {
28
+ e.set(n(this, D), t, !0);
29
+ }
30
+ // === User Annotations API ===
31
+ userAnnotationKey(t, s) {
32
+ return `${t}::${s}`;
33
+ }
34
+ setUserAnnotations(t, s, i) {
35
+ const r = this.userAnnotationKey(t, s), u = new Map(this.userAnnotations);
36
+ u.set(r, i), this.userAnnotations = u;
37
+ }
38
+ clearUserAnnotations(t, s) {
39
+ const i = this.userAnnotationKey(t, s);
40
+ if (this.userAnnotations.has(i)) {
41
+ const r = new Map(this.userAnnotations);
42
+ r.delete(i), this.userAnnotations = r;
43
+ }
44
+ }
45
+ getUserAnnotations(t, s) {
46
+ const i = this.userAnnotationKey(t, s);
47
+ return this.userAnnotations.get(i) ?? [];
48
+ }
49
+ // === Manifest Fetching ===
50
+ async fetchManifest(t) {
51
+ if (!this.manifests[t]) {
52
+ this.manifests[t] = { isFetching: !0 };
53
+ try {
54
+ const s = await fetch(t);
55
+ if (!s.ok)
56
+ throw new Error(`HTTP error! status: ${s.status}`);
57
+ const i = await s.json(), r = Gt.parseManifest(i);
58
+ this.manifests[t] = { json: i, manifesto: r, isFetching: !1 };
59
+ } catch (s) {
60
+ this.manifests[t] = { error: s.message, isFetching: !1 };
61
+ }
62
+ }
63
+ }
64
+ getManifest(t) {
65
+ const s = this.manifests[t];
66
+ return s == null ? void 0 : s.manifesto;
67
+ }
68
+ async fetchAnnotationList(t) {
69
+ if (!this.manifests[t])
70
+ try {
71
+ const s = await fetch(t);
72
+ if (s.ok) {
73
+ const i = await s.json();
74
+ this.manifests[t] = { json: i };
75
+ } else
76
+ console.error(`Failed to fetch annotation list: ${t}`);
77
+ } catch (s) {
78
+ console.error(`Error fetching annotation list: ${t}`, s);
79
+ }
80
+ }
81
+ getCanvases(t) {
82
+ const s = this.getManifest(t);
83
+ if (!s)
84
+ return [];
85
+ const i = s.getSequences();
86
+ return !i || !i.length ? [] : i[0].getCanvases();
87
+ }
88
+ getAnnotations(t, s) {
89
+ const i = this.manualGetAnnotations(t, s), r = this.getUserAnnotations(t, s);
90
+ return [...i, ...r];
91
+ }
92
+ // We can refactor this to use Manifesto's resource handling later if needed.
93
+ manualGetAnnotations(t, s) {
94
+ const i = this.getManifest(t);
95
+ if (!i) return [];
96
+ const r = i.getSequences()[0].getCanvasById(s);
97
+ if (!r) return [];
98
+ const u = r.__jsonld;
99
+ let v = [];
100
+ const A = (c) => c.resources || c.items || [];
101
+ return u.otherContent && u.otherContent.forEach((c) => {
102
+ const d = c["@id"] || c.id;
103
+ if (d && !c.resources) {
104
+ const w = this.manifests[d];
105
+ if (w) {
106
+ if (w.json) {
107
+ const _ = A(w.json);
108
+ v.push(..._);
109
+ }
110
+ } else
111
+ this.fetchAnnotationList(d);
112
+ } else c.resources && v.push(...c.resources);
113
+ }), u.annotations && u.annotations.forEach((c) => {
114
+ const d = c.id || c["@id"];
115
+ if (d && !c.items) {
116
+ const w = this.manifests[d];
117
+ if (w) {
118
+ if (w.json) {
119
+ const _ = A(w.json);
120
+ v.push(..._);
121
+ }
122
+ } else
123
+ this.fetchAnnotationList(d);
124
+ } else c.items && v.push(...c.items);
125
+ }), v;
126
+ }
127
+ }
128
+ E = new WeakMap(), D = new WeakMap();
129
+ const k = new jt();
130
+ var R, G, T, B, j, O, V, F, N, Q, Z, q, z, H, U, K, $, W, J, X, Y, tt, et, st, nt;
131
+ class ne {
132
+ constructor(t = null, s = null, i = []) {
133
+ h(this, R, e.state(null));
134
+ h(this, G, e.state(null));
135
+ h(this, T, e.state(!1));
136
+ h(this, B, e.state(!1));
137
+ h(this, j, e.state(!1));
138
+ h(this, O, e.state(!1));
139
+ h(this, V, e.state(!1));
140
+ h(this, F, e.state(!1));
141
+ h(this, N, e.state("bottom"));
142
+ h(this, Q, e.state(e.proxy(/* @__PURE__ */ new Set())));
143
+ h(this, Z, e.state(e.proxy({})));
144
+ h(
145
+ this,
146
+ q,
147
+ // Gallery State (Lifted for persistence during re-docking)
148
+ e.state(e.proxy({ x: 20, y: 100 }))
149
+ );
150
+ h(this, z, e.state(e.proxy({ width: 300, height: 400 })));
151
+ h(this, H, e.state(!1));
152
+ h(this, U, e.state(e.proxy({ x: 0, y: 0 })));
153
+ h(this, K, e.state(null));
154
+ h(this, $, e.state(null));
155
+ gt(this, "eventTarget", null);
156
+ h(this, W, e.state(""));
157
+ h(this, J, e.state(e.proxy([])));
158
+ h(this, X, e.state(!1));
159
+ h(this, Y, e.state(!1));
160
+ h(this, tt, e.state(e.proxy([])));
161
+ h(
162
+ this,
163
+ et,
164
+ // ==================== PLUGIN STATE ====================
165
+ /** Plugin-registered menu buttons */
166
+ e.state(e.proxy([]))
167
+ );
168
+ h(this, st, e.state(e.proxy([])));
169
+ h(this, nt, e.state(null));
170
+ gt(this, "pluginEventHandlers", /* @__PURE__ */ new Map());
171
+ this.manifestId = t || null, this.canvasId = s || null, this.manifestId && k.fetchManifest(this.manifestId);
172
+ for (const r of i)
173
+ this.registerPlugin(r);
174
+ }
175
+ get manifestId() {
176
+ return e.get(n(this, R));
177
+ }
178
+ set manifestId(t) {
179
+ e.set(n(this, R), t, !0);
180
+ }
181
+ get canvasId() {
182
+ return e.get(n(this, G));
183
+ }
184
+ set canvasId(t) {
185
+ e.set(n(this, G), t, !0);
186
+ }
187
+ get showAnnotations() {
188
+ return e.get(n(this, T));
189
+ }
190
+ set showAnnotations(t) {
191
+ e.set(n(this, T), t, !0);
192
+ }
193
+ get showThumbnailGallery() {
194
+ return e.get(n(this, B));
195
+ }
196
+ set showThumbnailGallery(t) {
197
+ e.set(n(this, B), t, !0);
198
+ }
199
+ get isGalleryDockedBottom() {
200
+ return e.get(n(this, j));
201
+ }
202
+ set isGalleryDockedBottom(t) {
203
+ e.set(n(this, j), t, !0);
204
+ }
205
+ get isGalleryDockedRight() {
206
+ return e.get(n(this, O));
207
+ }
208
+ set isGalleryDockedRight(t) {
209
+ e.set(n(this, O), t, !0);
210
+ }
211
+ get isFullScreen() {
212
+ return e.get(n(this, V));
213
+ }
214
+ set isFullScreen(t) {
215
+ e.set(n(this, V), t, !0);
216
+ }
217
+ get showMetadataDialog() {
218
+ return e.get(n(this, F));
219
+ }
220
+ set showMetadataDialog(t) {
221
+ e.set(n(this, F), t, !0);
222
+ }
223
+ get dockSide() {
224
+ return e.get(n(this, N));
225
+ }
226
+ set dockSide(t) {
227
+ e.set(n(this, N), t, !0);
228
+ }
229
+ get visibleAnnotationIds() {
230
+ return e.get(n(this, Q));
231
+ }
232
+ set visibleAnnotationIds(t) {
233
+ e.set(n(this, Q), t, !0);
234
+ }
235
+ get config() {
236
+ return e.get(n(this, Z));
237
+ }
238
+ set config(t) {
239
+ e.set(n(this, Z), t, !0);
240
+ }
241
+ get showRightMenu() {
242
+ return this.config.showRightMenu ?? !0;
243
+ }
244
+ get showLeftMenu() {
245
+ return this.config.showLeftMenu ?? !0;
246
+ }
247
+ get showCanvasNav() {
248
+ return this.config.showCanvasNav ?? !0;
249
+ }
250
+ get galleryPosition() {
251
+ return e.get(n(this, q));
252
+ }
253
+ set galleryPosition(t) {
254
+ e.set(n(this, q), t, !0);
255
+ }
256
+ get gallerySize() {
257
+ return e.get(n(this, z));
258
+ }
259
+ set gallerySize(t) {
260
+ e.set(n(this, z), t, !0);
261
+ }
262
+ get isGalleryDragging() {
263
+ return e.get(n(this, H));
264
+ }
265
+ set isGalleryDragging(t) {
266
+ e.set(n(this, H), t, !0);
267
+ }
268
+ get galleryDragOffset() {
269
+ return e.get(n(this, U));
270
+ }
271
+ set galleryDragOffset(t) {
272
+ e.set(n(this, U), t, !0);
273
+ }
274
+ get dragOverSide() {
275
+ return e.get(n(this, K));
276
+ }
277
+ set dragOverSide(t) {
278
+ e.set(n(this, K), t, !0);
279
+ }
280
+ get galleryCenterPanelRect() {
281
+ return e.get(n(this, $));
282
+ }
283
+ set galleryCenterPanelRect(t) {
284
+ e.set(n(this, $), t, !0);
285
+ }
286
+ setEventTarget(t) {
287
+ this.eventTarget = t;
288
+ }
289
+ /**
290
+ * Get current state as a plain object snapshot.
291
+ * Safe to use outside Svelte's reactive system.
292
+ * NOTE: We calculate currentCanvasIndex inline to avoid triggering the canvases getter
293
+ * which can cause infinite loops when it auto-sets canvasId.
294
+ */
295
+ getSnapshot() {
296
+ let t = -1;
297
+ return this.manifestId && this.canvasId && (t = k.getCanvases(this.manifestId).findIndex((i) => (i.id || i["@id"] || (i.getCanvasId ? i.getCanvasId() : null) || (i.getId ? i.getId() : null)) === this.canvasId)), {
298
+ manifestId: this.manifestId,
299
+ canvasId: this.canvasId,
300
+ currentCanvasIndex: t,
301
+ showAnnotations: this.showAnnotations,
302
+ showThumbnailGallery: this.showThumbnailGallery,
303
+ showSearchPanel: this.showSearchPanel,
304
+ searchQuery: this.searchQuery,
305
+ isFullScreen: this.isFullScreen,
306
+ dockSide: this.dockSide
307
+ };
308
+ }
309
+ /**
310
+ * Dispatch a state change event to the web component.
311
+ * No-op if eventTarget is null (Svelte component usage).
312
+ *
313
+ * Uses queueMicrotask to dispatch asynchronously AFTER the current
314
+ * reactive cycle completes, preventing infinite update loops.
315
+ */
316
+ dispatchStateChange(t = "statechange") {
317
+ console.log(`[ViewerState] Dispatching ${t}`, JSON.stringify(this.getSnapshot())), this.eventTarget && queueMicrotask(() => {
318
+ var s;
319
+ (s = this.eventTarget) == null || s.dispatchEvent(new CustomEvent(t, { detail: this.getSnapshot(), bubbles: !0, composed: !0 }));
320
+ });
321
+ }
322
+ get manifest() {
323
+ return this.manifestId ? k.getManifest(this.manifestId) : null;
324
+ }
325
+ get canvases() {
326
+ if (!this.manifestId) return [];
327
+ const t = k.getCanvases(this.manifestId);
328
+ return t.length > 0 && !this.canvasId && setTimeout(
329
+ () => {
330
+ !this.canvasId && t.length > 0 && (this.canvasId = t[0].id);
331
+ },
332
+ 0
333
+ ), t;
334
+ }
335
+ get currentCanvasIndex() {
336
+ return this.canvasId ? this.canvases.findIndex((t) => (t.id || t["@id"] || (t.getCanvasId ? t.getCanvasId() : null) || (t.getId ? t.getId() : null)) === this.canvasId) : this.canvases.length > 0 ? 0 : -1;
337
+ }
338
+ get hasNext() {
339
+ return this.currentCanvasIndex < this.canvases.length - 1;
340
+ }
341
+ get hasPrevious() {
342
+ return this.currentCanvasIndex > 0;
343
+ }
344
+ nextCanvas() {
345
+ if (this.hasNext) {
346
+ const t = this.currentCanvasIndex + 1, s = this.canvases[t];
347
+ this.setCanvas(s.id);
348
+ }
349
+ }
350
+ previousCanvas() {
351
+ if (this.hasPrevious) {
352
+ const t = this.currentCanvasIndex - 1, s = this.canvases[t];
353
+ this.setCanvas(s.id);
354
+ }
355
+ }
356
+ setManifest(t) {
357
+ this.manifestId = t, this.canvasId = null, k.fetchManifest(t), this.dispatchStateChange("manifestchange");
358
+ }
359
+ setCanvas(t) {
360
+ this.canvasId = t, this.dispatchStateChange("canvaschange");
361
+ }
362
+ updateConfig(t) {
363
+ var i;
364
+ const s = this.config;
365
+ if (this.config = t, t.gallery && (t.gallery.open !== void 0 && (this.showThumbnailGallery = t.gallery.open), t.gallery.dockPosition !== void 0 && (this.dockSide = t.gallery.dockPosition)), t.search) {
366
+ t.search.open !== void 0 && (this.showSearchPanel = t.search.open);
367
+ const r = t.search.query, u = (i = s.search) == null ? void 0 : i.query;
368
+ r !== void 0 && r !== u && r !== this.searchQuery && this._performSearch(r);
369
+ }
370
+ t.annotations && t.annotations.open !== void 0 && (this.showAnnotations = t.annotations.open);
371
+ }
372
+ toggleAnnotations() {
373
+ this.showAnnotations = !this.showAnnotations, this.dispatchStateChange();
374
+ }
375
+ toggleThumbnailGallery() {
376
+ this.showThumbnailGallery = !this.showThumbnailGallery, this.dispatchStateChange();
377
+ }
378
+ toggleFullScreen() {
379
+ if (document.fullscreenElement)
380
+ document.exitFullscreen();
381
+ else {
382
+ const t = document.getElementById("triiiceratops-viewer");
383
+ t && t.requestFullscreen().catch((s) => {
384
+ console.warn("Fullscreen request failed", s);
385
+ });
386
+ }
387
+ }
388
+ toggleMetadataDialog() {
389
+ this.showMetadataDialog = !this.showMetadataDialog;
390
+ }
391
+ get searchQuery() {
392
+ return e.get(n(this, W));
393
+ }
394
+ set searchQuery(t) {
395
+ e.set(n(this, W), t, !0);
396
+ }
397
+ get searchResults() {
398
+ return e.get(n(this, J));
399
+ }
400
+ set searchResults(t) {
401
+ e.set(n(this, J), t, !0);
402
+ }
403
+ get isSearching() {
404
+ return e.get(n(this, X));
405
+ }
406
+ set isSearching(t) {
407
+ e.set(n(this, X), t, !0);
408
+ }
409
+ get showSearchPanel() {
410
+ return e.get(n(this, Y));
411
+ }
412
+ set showSearchPanel(t) {
413
+ e.set(n(this, Y), t, !0);
414
+ }
415
+ toggleSearchPanel() {
416
+ this.showSearchPanel = !this.showSearchPanel, this.showSearchPanel || (this.searchAnnotations = []), this.dispatchStateChange();
417
+ }
418
+ get searchAnnotations() {
419
+ return e.get(n(this, tt));
420
+ }
421
+ set searchAnnotations(t) {
422
+ e.set(n(this, tt), t, !0);
423
+ }
424
+ get currentCanvasSearchAnnotations() {
425
+ return this.canvasId ? this.searchAnnotations.filter((t) => t.canvasId === this.canvasId) : [];
426
+ }
427
+ async search(t) {
428
+ this.dispatchStateChange(), await this._performSearch(t), this.dispatchStateChange();
429
+ }
430
+ async _performSearch(t) {
431
+ var s, i;
432
+ if (t.trim()) {
433
+ this.isSearching = !0, this.searchQuery = t, this.searchResults = [];
434
+ try {
435
+ const r = this.manifest;
436
+ if (!r) throw new Error("No manifest loaded");
437
+ let u = r.getService("http://iiif.io/api/search/1/search") || r.getService("http://iiif.io/api/search/0/search");
438
+ if (u || r.__jsonld && r.__jsonld.service && (u = (Array.isArray(r.__jsonld.service) ? r.__jsonld.service : [r.__jsonld.service]).find((l) => l.profile === "http://iiif.io/api/search/1/search" || l.profile === "http://iiif.io/api/search/0/search")), !u) {
439
+ console.warn("No IIIF search service found in manifest"), this.isSearching = !1;
440
+ return;
441
+ }
442
+ const A = `${u.id || u["@id"]}?q=${encodeURIComponent(t)}`, c = await fetch(A);
443
+ if (!c.ok) throw new Error("Search request failed");
444
+ const d = await c.json(), w = d.resources || [], _ = [], at = (o) => {
445
+ const l = typeof o == "string" ? o : o["@id"] || o.id;
446
+ if (!l) return null;
447
+ const g = l.split("#xywh=");
448
+ if (g.length < 2) return null;
449
+ const m = g[1].split(",").map(Number);
450
+ return m.length === 4 ? m : null;
451
+ };
452
+ if (d.hits)
453
+ for (const o of d.hits) {
454
+ const l = o.annotations || [], g = /* @__PURE__ */ new Map();
455
+ for (const m of l) {
456
+ const f = w.find((p) => p["@id"] === m || p.id === m);
457
+ if (f && f.on) {
458
+ const p = typeof f.on == "string" ? f.on : f.on["@id"] || f.on.id, y = p.split("#")[0], S = at(p), L = this.canvases.findIndex((I) => I.id === y);
459
+ if (L >= 0) {
460
+ if (!g.has(L)) {
461
+ const I = this.canvases[L];
462
+ let x = "Canvas " + (L + 1);
463
+ try {
464
+ if (I.getLabel) {
465
+ const b = I.getLabel();
466
+ Array.isArray(b) && b.length > 0 ? x = b[0].value : typeof b == "string" && (x = b);
467
+ } else I.label && (typeof I.label == "string" ? x = I.label : Array.isArray(I.label) && (x = (s = I.label[0]) == null ? void 0 : s.value));
468
+ } catch {
469
+ }
470
+ g.set(L, { label: String(x), bounds: [] });
471
+ }
472
+ S && g.get(L).bounds.push(S);
473
+ }
474
+ }
475
+ }
476
+ for (const [m, f] of g)
477
+ _.push({
478
+ type: "hit",
479
+ before: o.before,
480
+ match: o.match,
481
+ after: o.after,
482
+ canvasIndex: m,
483
+ canvasLabel: f.label,
484
+ // Store all bounds for this hit on this canvas
485
+ allBounds: f.bounds,
486
+ // Keep first bounds for backwards compatibility
487
+ bounds: f.bounds.length > 0 ? f.bounds[0] : null
488
+ });
489
+ }
490
+ else if (w.length > 0)
491
+ for (const o of w) {
492
+ const l = typeof o.on == "string" ? o.on : o.on["@id"] || o.on.id, g = l.split("#")[0], m = at(l), f = this.canvases.findIndex((p) => p.id === g);
493
+ if (f >= 0) {
494
+ const p = this.canvases[f];
495
+ let y = "Canvas " + (f + 1);
496
+ try {
497
+ if (p.getLabel) {
498
+ const S = p.getLabel();
499
+ Array.isArray(S) && S.length > 0 ? y = S[0].value : typeof S == "string" && (y = S);
500
+ } else p.label && (typeof p.label == "string" ? y = p.label : Array.isArray(p.label) && (y = (i = p.label[0]) == null ? void 0 : i.value));
501
+ } catch {
502
+ }
503
+ _.push({
504
+ type: "resource",
505
+ match: o.resource && o.resource.chars ? o.resource.chars : o.chars || "",
506
+ canvasIndex: f,
507
+ canvasLabel: String(y),
508
+ bounds: m
509
+ });
510
+ }
511
+ }
512
+ this.searchResults = _;
513
+ let ut = 0;
514
+ this.searchAnnotations = _.flatMap((o) => {
515
+ const l = this.canvases[o.canvasIndex];
516
+ return (o.allBounds && o.allBounds.length > 0 ? o.allBounds : o.bounds ? [o.bounds] : []).map((m) => {
517
+ const f = `${l.id}#xywh=${m.join(",")}`;
518
+ return {
519
+ "@id": `urn:search-hit:${ut++}`,
520
+ "@type": "oa:Annotation",
521
+ motivation: "sc:painting",
522
+ on: f,
523
+ canvasId: l.id,
524
+ resource: { "@type": "cnt:ContentAsText", chars: o.match },
525
+ // Flag to identify styling in Overlay?
526
+ // Or just standard rendering.
527
+ isSearchHit: !0
528
+ };
529
+ });
530
+ });
531
+ } catch (r) {
532
+ console.error("Search error:", r);
533
+ } finally {
534
+ this.isSearching = !1;
535
+ }
536
+ }
537
+ }
538
+ get pluginMenuButtons() {
539
+ return e.get(n(this, et));
540
+ }
541
+ set pluginMenuButtons(t) {
542
+ e.set(n(this, et), t, !0);
543
+ }
544
+ get pluginPanels() {
545
+ return e.get(n(this, st));
546
+ }
547
+ set pluginPanels(t) {
548
+ e.set(n(this, st), t, !0);
549
+ }
550
+ get osdViewer() {
551
+ return e.get(n(this, nt));
552
+ }
553
+ set osdViewer(t) {
554
+ e.set(n(this, nt), t);
555
+ }
556
+ registerPlugin(t) {
557
+ const s = t.id || `plugin-${Math.random().toString(36).substr(2, 9)}`;
558
+ let i = e.state(!1);
559
+ const r = {
560
+ id: `${s}:toggle`,
561
+ icon: t.icon,
562
+ tooltip: t.name,
563
+ onClick: () => {
564
+ e.set(i, !e.get(i));
565
+ },
566
+ isActive: () => e.get(i),
567
+ order: 200
568
+ // Default order for simple plugins
569
+ }, u = {
570
+ id: `${s}:panel`,
571
+ component: t.panel,
572
+ position: t.position || "left",
573
+ isVisible: () => e.get(i),
574
+ props: {
575
+ ...t.props,
576
+ // Pass isOpen state and closer to component
577
+ isOpen: e.get(i),
578
+ close: () => {
579
+ e.set(i, !1);
580
+ }
581
+ }
582
+ };
583
+ this.pluginMenuButtons = [...this.pluginMenuButtons, r], this.pluginPanels = [...this.pluginPanels, u], t.onInit && t.onInit(this);
584
+ }
585
+ /**
586
+ * Unregister a plugin's UI components by ID prefix.
587
+ * Note: This cleans up the menu button and panel, but doesn't remove listeners attached by the plugin itself
588
+ * since we don't have a handle on the plugin instance or its cleanup function anymore.
589
+ * Plugins should manage their own cleanup via component lifecycle (onDestroy) if possible.
590
+ */
591
+ unregisterPlugin(t) {
592
+ this.pluginMenuButtons = this.pluginMenuButtons.filter((s) => !s.id.startsWith(`${t}:`)), this.pluginPanels = this.pluginPanels.filter((s) => !s.id.startsWith(`${t}:`));
593
+ }
594
+ /**
595
+ * Notify that OSD viewer is ready.
596
+ * With the component-based system, we don't notify plugins individually.
597
+ * Instead, plugins should use the OSDViewer instance from context or listen for 'osd-ready' event (if we emitted one).
598
+ * But since we have direct access to osdViewer in this state, components can just react to it.
599
+ */
600
+ notifyOSDReady(t) {
601
+ this.osdViewer = t;
602
+ }
603
+ /**
604
+ * Cleanup everything.
605
+ */
606
+ destroyAllPlugins() {
607
+ this.pluginMenuButtons = [], this.pluginPanels = [], this.pluginEventHandlers.clear();
608
+ }
609
+ }
610
+ R = new WeakMap(), G = new WeakMap(), T = new WeakMap(), B = new WeakMap(), j = new WeakMap(), O = new WeakMap(), V = new WeakMap(), F = new WeakMap(), N = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), q = new WeakMap(), z = new WeakMap(), H = new WeakMap(), U = new WeakMap(), K = new WeakMap(), $ = new WeakMap(), W = new WeakMap(), J = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), st = new WeakMap(), nt = new WeakMap();
611
+ const ae = "triiiceratops:viewerState";
612
+ let pt = Symbol("phosphor-svelte");
613
+ function Ot() {
614
+ return Tt(pt) ? Bt(pt) : {};
615
+ }
616
+ const Vt = "en", ft = (
617
+ /** @type {const} */
618
+ ["en", "de"]
619
+ ), mt = "PARAGLIDE_LOCALE", Ft = 3456e4, yt = [
620
+ "cookie",
621
+ "globalVariable",
622
+ "baseLocale"
623
+ ];
624
+ globalThis.__paraglide = {};
625
+ let ht, vt = !1, wt = () => {
626
+ let a;
627
+ for (const t of yt) {
628
+ if (t === "cookie")
629
+ a = qt();
630
+ else if (t === "baseLocale")
631
+ a = Vt;
632
+ else if (t === "globalVariable" && ht !== void 0)
633
+ a = ht;
634
+ else if (bt(t) && ct.has(t)) {
635
+ const s = ct.get(t);
636
+ if (s) {
637
+ const i = s.getLocale();
638
+ if (i instanceof Promise)
639
+ continue;
640
+ a = i;
641
+ }
642
+ }
643
+ if (a !== void 0) {
644
+ const s = Zt(a);
645
+ return vt || (ht = s, vt = !0, St(s, { reload: !1 })), s;
646
+ }
647
+ }
648
+ throw new Error("No locale found. Read the docs https://inlang.com/m/gerre34r/library-inlang-paraglideJs/errors#no-locale-found");
649
+ };
650
+ const Nt = (a) => {
651
+ window.location.reload();
652
+ };
653
+ let St = (a, t) => {
654
+ const s = {
655
+ reload: !0,
656
+ ...t
657
+ };
658
+ let i;
659
+ try {
660
+ i = wt();
661
+ } catch {
662
+ }
663
+ const r = [];
664
+ for (const v of yt)
665
+ if (v === "globalVariable")
666
+ ht = a;
667
+ else if (v === "cookie") {
668
+ if (typeof document > "u" || typeof window > "u")
669
+ continue;
670
+ const A = `${mt}=${a}; path=/; max-age=${Ft}`;
671
+ document.cookie = A;
672
+ } else {
673
+ if (v === "baseLocale")
674
+ continue;
675
+ if (bt(v) && ct.has(v)) {
676
+ const A = ct.get(v);
677
+ if (A) {
678
+ let c = A.setLocale(a);
679
+ c instanceof Promise && (c = c.catch((d) => {
680
+ throw new Error(`Custom strategy "${v}" setLocale failed.`, {
681
+ cause: d
682
+ });
683
+ }), r.push(c));
684
+ }
685
+ }
686
+ }
687
+ const u = () => {
688
+ s.reload && window.location && a !== i && Nt();
689
+ };
690
+ if (r.length)
691
+ return Promise.all(r).then(() => {
692
+ u();
693
+ });
694
+ u();
695
+ };
696
+ const ie = (a) => {
697
+ St = /** @type {SetLocaleFn} */
698
+ a;
699
+ };
700
+ function Qt(a) {
701
+ return typeof a != "string" ? !1 : a ? ft.some((t) => t.toLowerCase() === a.toLowerCase()) : !1;
702
+ }
703
+ function Zt(a) {
704
+ if (typeof a != "string")
705
+ throw new Error(`Invalid locale: ${a}. Expected a string.`);
706
+ const t = a.toLowerCase(), s = ft.find((i) => i.toLowerCase() === t);
707
+ if (!s)
708
+ throw new Error(`Invalid locale: ${a}. Expected one of: ${ft.join(", ")}`);
709
+ return s;
710
+ }
711
+ function qt() {
712
+ if (typeof document > "u" || !document.cookie)
713
+ return;
714
+ const a = document.cookie.match(new RegExp(`(^| )${mt}=([^;]+)`)), t = a == null ? void 0 : a[2];
715
+ if (Qt(t))
716
+ return t;
717
+ }
718
+ const ct = /* @__PURE__ */ new Map();
719
+ function bt(a) {
720
+ return typeof a == "string" && /^custom-[A-Za-z0-9_-]+$/.test(a);
721
+ }
722
+ const zt = (
723
+ /** @type {(inputs: {}) => LocalizedString} */
724
+ () => (
725
+ /** @type {LocalizedString} */
726
+ "Close"
727
+ )
728
+ ), Ht = (
729
+ /** @type {(inputs: {}) => LocalizedString} */
730
+ () => (
731
+ /** @type {LocalizedString} */
732
+ "Schließen"
733
+ )
734
+ ), re = /* @__NO_SIDE_EFFECTS__ */ (a = {}, t = {}) => (t.locale ?? wt()) === "en" ? zt() : Ht();
735
+ var Ut = e.from_svg('<path d="M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"></path>'), Kt = e.from_svg('<path d="M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z" opacity="0.2"></path><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>', 1), $t = e.from_svg('<path d="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'), Wt = e.from_svg('<path d="M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z"></path>'), Jt = e.from_svg('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>'), Xt = e.from_svg('<path d="M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z"></path>'), Yt = e.from_svg('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');
736
+ function oe(a, t) {
737
+ e.push(t, !0);
738
+ const s = Ot();
739
+ let i = e.rest_props(t, ["$$slots", "$$events", "$$legacy", "children"]), r = e.derived(() => t.weight ?? s.weight ?? "regular"), u = e.derived(() => t.color ?? s.color ?? "currentColor"), v = e.derived(() => t.size ?? s.size ?? "1em"), A = e.derived(() => t.mirrored ?? s.mirrored ?? !1);
740
+ function c(l) {
741
+ let { weight: g, color: m, size: f, mirrored: p, ...y } = l;
742
+ return y;
743
+ }
744
+ var d = Yt();
745
+ e.attribute_effect(
746
+ d,
747
+ (l, g) => ({
748
+ xmlns: "http://www.w3.org/2000/svg",
749
+ role: "img",
750
+ width: e.get(v),
751
+ height: e.get(v),
752
+ fill: e.get(u),
753
+ transform: e.get(A) ? "scale(-1, 1)" : void 0,
754
+ viewBox: "0 0 256 256",
755
+ ...l,
756
+ ...g
757
+ }),
758
+ [() => c(s), () => c(i)]
759
+ );
760
+ var w = e.child(d);
761
+ {
762
+ var _ = (l) => {
763
+ var g = e.comment(), m = e.first_child(g);
764
+ e.snippet(m, () => t.children), e.append(l, g);
765
+ };
766
+ e.if(w, (l) => {
767
+ t.children && l(_);
768
+ });
769
+ }
770
+ var at = e.sibling(w, 2);
771
+ {
772
+ var ut = (l) => {
773
+ var g = Ut();
774
+ e.append(l, g);
775
+ }, o = (l) => {
776
+ var g = e.comment(), m = e.first_child(g);
777
+ {
778
+ var f = (y) => {
779
+ var S = Kt();
780
+ e.next(), e.append(y, S);
781
+ }, p = (y) => {
782
+ var S = e.comment(), L = e.first_child(S);
783
+ {
784
+ var I = (b) => {
785
+ var it = $t();
786
+ e.append(b, it);
787
+ }, x = (b) => {
788
+ var it = e.comment(), At = e.first_child(it);
789
+ {
790
+ var It = (M) => {
791
+ var rt = Wt();
792
+ e.append(M, rt);
793
+ }, _t = (M) => {
794
+ var rt = e.comment(), Lt = e.first_child(rt);
795
+ {
796
+ var xt = (C) => {
797
+ var ot = Jt();
798
+ e.append(C, ot);
799
+ }, Mt = (C) => {
800
+ var ot = e.comment(), Ct = e.first_child(ot);
801
+ {
802
+ var Pt = (P) => {
803
+ var lt = Xt();
804
+ e.append(P, lt);
805
+ }, kt = (P) => {
806
+ var lt = e.text();
807
+ lt.nodeValue = (console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'), ""), e.append(P, lt);
808
+ };
809
+ e.if(
810
+ Ct,
811
+ (P) => {
812
+ e.get(r) === "thin" ? P(Pt) : P(kt, !1);
813
+ },
814
+ !0
815
+ );
816
+ }
817
+ e.append(C, ot);
818
+ };
819
+ e.if(
820
+ Lt,
821
+ (C) => {
822
+ e.get(r) === "regular" ? C(xt) : C(Mt, !1);
823
+ },
824
+ !0
825
+ );
826
+ }
827
+ e.append(M, rt);
828
+ };
829
+ e.if(
830
+ At,
831
+ (M) => {
832
+ e.get(r) === "light" ? M(It) : M(_t, !1);
833
+ },
834
+ !0
835
+ );
836
+ }
837
+ e.append(b, it);
838
+ };
839
+ e.if(
840
+ L,
841
+ (b) => {
842
+ e.get(r) === "fill" ? b(I) : b(x, !1);
843
+ },
844
+ !0
845
+ );
846
+ }
847
+ e.append(y, S);
848
+ };
849
+ e.if(
850
+ m,
851
+ (y) => {
852
+ e.get(r) === "duotone" ? y(f) : y(p, !1);
853
+ },
854
+ !0
855
+ );
856
+ }
857
+ e.append(l, g);
858
+ };
859
+ e.if(at, (l) => {
860
+ e.get(r) === "bold" ? l(ut) : l(o, !1);
861
+ });
862
+ }
863
+ e.reset(d), e.append(a, d), e.pop();
864
+ }
865
+ export {
866
+ jt as M,
867
+ ae as V,
868
+ oe as X,
869
+ wt as a,
870
+ ne as b,
871
+ re as c,
872
+ Ot as g,
873
+ ft as l,
874
+ k as m,
875
+ ie as o,
876
+ St as s
877
+ };