med-viewer-sdk 0.1.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 (87) hide show
  1. package/README.md +253 -0
  2. package/dist/adapters/vue/MedViewer.d.ts +17 -0
  3. package/dist/adapters/vue/index.d.ts +2 -0
  4. package/dist/core/AnnoAnnotator.d.ts +15 -0
  5. package/dist/core/BaseAnnotator.d.ts +33 -0
  6. package/dist/core/ColorAdjustPlugin.d.ts +29 -0
  7. package/dist/core/Coords.d.ts +6 -0
  8. package/dist/core/Engine.d.ts +57 -0
  9. package/dist/core/KonvaAnnotator.d.ts +36 -0
  10. package/dist/core/Scalebar.d.ts +42 -0
  11. package/dist/core/SelectionPlugin.d.ts +102 -0
  12. package/dist/core/Toolbar.d.ts +32 -0
  13. package/dist/med-viewer-sdk.d.ts +6 -0
  14. package/dist/med-viewer-sdk.mjs +14248 -0
  15. package/dist/med-viewer-sdk.umd.js +2 -0
  16. package/dist/style.css +1 -0
  17. package/package.json +34 -0
  18. package/src/adapters/vue/MedViewer.ts +37 -0
  19. package/src/adapters/vue/index.ts +4 -0
  20. package/src/assets/icons/button_grouphover.png +0 -0
  21. package/src/assets/icons/button_hover.png +0 -0
  22. package/src/assets/icons/button_pressed.png +0 -0
  23. package/src/assets/icons/button_rest.png +0 -0
  24. package/src/assets/icons/flip_grouphover.png +0 -0
  25. package/src/assets/icons/flip_hover.png +0 -0
  26. package/src/assets/icons/flip_pressed.png +0 -0
  27. package/src/assets/icons/flip_rest.png +0 -0
  28. package/src/assets/icons/fullpage_grouphover.png +0 -0
  29. package/src/assets/icons/fullpage_hover.png +0 -0
  30. package/src/assets/icons/fullpage_pressed.png +0 -0
  31. package/src/assets/icons/fullpage_rest.png +0 -0
  32. package/src/assets/icons/home_grouphover.png +0 -0
  33. package/src/assets/icons/home_hover.png +0 -0
  34. package/src/assets/icons/home_pressed.png +0 -0
  35. package/src/assets/icons/home_rest.png +0 -0
  36. package/src/assets/icons/next_grouphover.png +0 -0
  37. package/src/assets/icons/next_hover.png +0 -0
  38. package/src/assets/icons/next_pressed.png +0 -0
  39. package/src/assets/icons/next_rest.png +0 -0
  40. package/src/assets/icons/previous_grouphover.png +0 -0
  41. package/src/assets/icons/previous_hover.png +0 -0
  42. package/src/assets/icons/previous_pressed.png +0 -0
  43. package/src/assets/icons/previous_rest.png +0 -0
  44. package/src/assets/icons/rotateleft_grouphover.png +0 -0
  45. package/src/assets/icons/rotateleft_hover.png +0 -0
  46. package/src/assets/icons/rotateleft_pressed.png +0 -0
  47. package/src/assets/icons/rotateleft_rest.png +0 -0
  48. package/src/assets/icons/rotateright_grouphover.png +0 -0
  49. package/src/assets/icons/rotateright_hover.png +0 -0
  50. package/src/assets/icons/rotateright_pressed.png +0 -0
  51. package/src/assets/icons/rotateright_rest.png +0 -0
  52. package/src/assets/icons/selection_cancel_grouphover.png +0 -0
  53. package/src/assets/icons/selection_cancel_hover.png +0 -0
  54. package/src/assets/icons/selection_cancel_pressed.png +0 -0
  55. package/src/assets/icons/selection_cancel_rest.png +0 -0
  56. package/src/assets/icons/selection_confirm_grouphover.png +0 -0
  57. package/src/assets/icons/selection_confirm_hover.png +0 -0
  58. package/src/assets/icons/selection_confirm_pressed.png +0 -0
  59. package/src/assets/icons/selection_confirm_rest.png +0 -0
  60. package/src/assets/icons/selection_grouphover.png +0 -0
  61. package/src/assets/icons/selection_hover.png +0 -0
  62. package/src/assets/icons/selection_pressed.png +0 -0
  63. package/src/assets/icons/selection_rest.png +0 -0
  64. package/src/assets/icons/tool_anno.png +0 -0
  65. package/src/assets/icons/tool_selection.png +0 -0
  66. package/src/assets/icons/zoomin_grouphover.png +0 -0
  67. package/src/assets/icons/zoomin_hover.png +0 -0
  68. package/src/assets/icons/zoomin_pressed.png +0 -0
  69. package/src/assets/icons/zoomin_rest.png +0 -0
  70. package/src/assets/icons/zoomout_grouphover.png +0 -0
  71. package/src/assets/icons/zoomout_hover.png +0 -0
  72. package/src/assets/icons/zoomout_pressed.png +0 -0
  73. package/src/assets/icons/zoomout_rest.png +0 -0
  74. package/src/core/AnnoAnnotator.ts +102 -0
  75. package/src/core/BaseAnnotator.ts +43 -0
  76. package/src/core/ColorAdjustPlugin.ts +256 -0
  77. package/src/core/Coords.ts +9 -0
  78. package/src/core/Engine.ts +246 -0
  79. package/src/core/KonvaAnnotator.ts +185 -0
  80. package/src/core/Scalebar.ts +87 -0
  81. package/src/core/SelectionPlugin.ts +252 -0
  82. package/src/core/Toolbar.ts +370 -0
  83. package/src/index.ts +21 -0
  84. package/src/plugins/ShapeLabelsFormatter.js +435 -0
  85. package/src/plugins/openseadragon-scalebar.js +592 -0
  86. package/src/plugins/openseadragon-selection.js +657 -0
  87. package/src/types/type.d.ts +9 -0
@@ -0,0 +1,657 @@
1
+ import OpenSeadragon from "openseadragon";
2
+
3
+ (() => {
4
+ (function (t) {
5
+ "use strict";
6
+ ((t.SelectionOverlay = function (s, c) {
7
+ (t.Overlay.apply(this, arguments),
8
+ t.isPlainObject(s)
9
+ ? (this.rotation = s.location.rotation || 0)
10
+ : (this.rotation = c.rotation || 0));
11
+ }),
12
+ (t.SelectionOverlay.prototype = t.extend(
13
+ Object.create(t.Overlay.prototype),
14
+ {
15
+ drawHTML: function () {
16
+ (t.Overlay.prototype.drawHTML.apply(this, arguments),
17
+ (this.style.transform =
18
+ this.style.transform.replace(/ ?rotate\(.+rad\)/, "") +
19
+ " rotate(" +
20
+ this.rotation +
21
+ "rad)"));
22
+ },
23
+ update: function (s) {
24
+ (t.Overlay.prototype.update.apply(this, arguments),
25
+ (this.rotation = s.rotation || 0));
26
+ },
27
+ },
28
+ )));
29
+ })(OpenSeadragon);
30
+ (function (t) {
31
+ "use strict";
32
+ ((t.SelectionRect = function (s, c, g, m, y) {
33
+ (t.Rect.apply(this, [s, c, g, m]), (this.rotation = y || 0));
34
+ }),
35
+ (t.SelectionRect.fromRect = function (s) {
36
+ return new t.SelectionRect(s.x, s.y, s.width, s.height);
37
+ }),
38
+ (t.SelectionRect.prototype = t.extend(Object.create(t.Rect.prototype), {
39
+ clone: function () {
40
+ return new t.SelectionRect(
41
+ this.x,
42
+ this.y,
43
+ this.width,
44
+ this.height,
45
+ this.rotation,
46
+ );
47
+ },
48
+ equals: function (s) {
49
+ return (
50
+ t.Rect.prototype.equals.apply(this, [s]) &&
51
+ this.rotation === s.rotation
52
+ );
53
+ },
54
+ toString: function () {
55
+ return (
56
+ "[" +
57
+ Math.round(this.x * 100) / 100 +
58
+ "," +
59
+ Math.round(this.y * 100) / 100 +
60
+ "," +
61
+ Math.round(this.width * 100) / 100 +
62
+ "x" +
63
+ Math.round(this.height * 100) / 100 +
64
+ "@" +
65
+ Math.round(this.rotation * 100) / 100 +
66
+ "]"
67
+ );
68
+ },
69
+ swapWidthHeight: function () {
70
+ let s = this.clone();
71
+ return (
72
+ (s.width = this.height),
73
+ (s.height = this.width),
74
+ (s.x += (this.width - this.height) / 2),
75
+ (s.y += (this.height - this.width) / 2),
76
+ s
77
+ );
78
+ },
79
+ getDegreeRotation: function () {
80
+ return this.rotation * (180 / Math.PI);
81
+ },
82
+ getAngleFromCenter: function (s) {
83
+ let c = s.minus(this.getCenter());
84
+ return Math.atan2(c.x, c.y);
85
+ },
86
+ round: function () {
87
+ return new t.SelectionRect(
88
+ Math.round(this.x),
89
+ Math.round(this.y),
90
+ Math.round(this.width),
91
+ Math.round(this.height),
92
+ this.rotation,
93
+ );
94
+ },
95
+ normalize: function () {
96
+ let s = this.clone();
97
+ return (
98
+ s.width < 0 && ((s.x += s.width), (s.width *= -1)),
99
+ s.height < 0 && ((s.y += s.height), (s.height *= -1)),
100
+ (s.rotation %= Math.PI),
101
+ s
102
+ );
103
+ },
104
+ fitsIn: function (s) {
105
+ let c = this.normalize(),
106
+ g = [
107
+ c.getTopLeft(),
108
+ c.getTopRight(),
109
+ c.getBottomRight(),
110
+ c.getBottomLeft(),
111
+ ],
112
+ m = c.getCenter(),
113
+ y = c.getDegreeRotation(),
114
+ f = s.getBottomRight();
115
+ for (let d = 0; d < 4; d++)
116
+ if (
117
+ ((g[d] = g[d].rotate(y, m)),
118
+ g[d].x < s.x || g[d].x > f.x || g[d].y < s.y || g[d].y > f.y)
119
+ )
120
+ return !1;
121
+ return !0;
122
+ },
123
+ reduceRotation: function () {
124
+ let s;
125
+ return (
126
+ this.rotation < Math.PI / -4
127
+ ? ((s = this.swapWidthHeight()), (s.rotation += Math.PI / 2))
128
+ : this.rotation > Math.PI / 4
129
+ ? ((s = this.swapWidthHeight()), (s.rotation -= Math.PI / 2))
130
+ : (s = this.clone()),
131
+ s
132
+ );
133
+ },
134
+ })));
135
+ })(OpenSeadragon);
136
+ (function (t) {
137
+ "use strict";
138
+ if (!t.version || t.version.major < 3)
139
+ throw new Error(
140
+ "This version of OpenSeadragonSelection requires OpenSeadragon version 2.0.0+",
141
+ );
142
+ ((t.Viewer.prototype.selection = function (i) {
143
+ return (
144
+ (!this.selectionInstance || i) &&
145
+ ((i = i || {}),
146
+ (i.viewer = this),
147
+ (this.selectionInstance = new t.Selection(i))),
148
+ this.selectionInstance
149
+ );
150
+ }),
151
+ (t.Selection = function (i) {
152
+ (t.extend(
153
+ !0,
154
+ this,
155
+ {
156
+ viewer: null,
157
+ isSelecting: !1,
158
+ buttonActiveImg: !1,
159
+ rectDone: !0,
160
+ element: null,
161
+ toggleButton: null,
162
+ showSelectionControl: !0,
163
+ showConfirmDenyButtons: !0,
164
+ styleConfirmDenyButtons: !0,
165
+ returnPixelCoordinates: !0,
166
+ keyboardShortcut: "c",
167
+ rect: null,
168
+ allowRotation: !0,
169
+ startRotated: !1,
170
+ startRotatedHeight: 0.1,
171
+ restrictToImage: !1,
172
+ cropMinimumSize: !1,
173
+ cropMinimumWidth: 0,
174
+ cropMinimumHeight: 0,
175
+ onSelection: null,
176
+ onSelectionCanceled: null,
177
+ onSelectionChange: null,
178
+ onSelectionToggled: null,
179
+ prefixUrl: null,
180
+ navImages: {
181
+ selection: {
182
+ REST: "selection_rest.png",
183
+ GROUP: "selection_grouphover.png",
184
+ HOVER: "selection_hover.png",
185
+ DOWN: "selection_pressed.png",
186
+ },
187
+ selectionConfirm: {
188
+ REST: "selection_confirm_rest.png",
189
+ GROUP: "selection_confirm_grouphover.png",
190
+ HOVER: "selection_confirm_hover.png",
191
+ DOWN: "selection_confirm_pressed.png",
192
+ },
193
+ selectionCancel: {
194
+ REST: "selection_cancel_rest.png",
195
+ GROUP: "selection_cancel_grouphover.png",
196
+ HOVER: "selection_cancel_hover.png",
197
+ DOWN: "selection_cancel_pressed.png",
198
+ },
199
+ },
200
+ borderStyle: { width: "1px", color: "#fff" },
201
+ handleStyle: {
202
+ top: "50%",
203
+ left: "50%",
204
+ width: "6px",
205
+ height: "6px",
206
+ margin: "-4px 0 0 -4px",
207
+ background: "#000",
208
+ border: "1px solid #ccc",
209
+ },
210
+ cornersStyle: {
211
+ width: "6px",
212
+ height: "6px",
213
+ background: "#000",
214
+ border: "1px solid #ccc",
215
+ },
216
+ },
217
+ i,
218
+ ),
219
+ t.extend(!0, this.navImages, this.viewer.navImages),
220
+ this.element ||
221
+ ((this.element = t.makeNeutralElement("div")),
222
+ (this.element.style.background = "rgba(0, 0, 0, 0.1)"),
223
+ (this.element.className = "selection-box")),
224
+ (this.borders = this.borders || []));
225
+ let e,
226
+ n = [];
227
+ for (let r = 0; r < 4; r++)
228
+ (this.borders[r] ||
229
+ ((this.borders[r] = t.makeNeutralElement("div")),
230
+ (this.borders[r].className = "border-" + r),
231
+ (this.borders[r].style.position = "absolute"),
232
+ (this.borders[r].style.width = this.borderStyle.width),
233
+ (this.borders[r].style.height = this.borderStyle.width),
234
+ (this.borders[r].style.background = this.borderStyle.color)),
235
+ (e = t.makeNeutralElement("div")),
236
+ (e.className = "border-" + r + "-handle"),
237
+ (e.style.position = "absolute"),
238
+ (e.style.top = this.handleStyle.top),
239
+ (e.style.left = this.handleStyle.left),
240
+ (e.style.width = this.handleStyle.width),
241
+ (e.style.height = this.handleStyle.height),
242
+ (e.style.margin = this.handleStyle.margin),
243
+ (e.style.background = this.handleStyle.background),
244
+ (e.style.border = this.handleStyle.border),
245
+ new t.MouseTracker({
246
+ element: this.borders[r],
247
+ dragHandler: d.bind(this, r),
248
+ dragEndHandler: p.bind(this, r),
249
+ }),
250
+ (n[r] = t.makeNeutralElement("div")),
251
+ (n[r].className = "corner-" + r + "-handle"),
252
+ (n[r].style.position = "absolute"),
253
+ (n[r].style.width = this.cornersStyle.width),
254
+ (n[r].style.height = this.cornersStyle.height),
255
+ (n[r].style.background = this.cornersStyle.background),
256
+ (n[r].style.border = this.cornersStyle.border),
257
+ new t.MouseTracker({
258
+ element: n[r],
259
+ dragHandler: d.bind(this, r + 0.5),
260
+ dragEndHandler: p.bind(this, r),
261
+ }),
262
+ this.borders[r].appendChild(e),
263
+ this.element.appendChild(this.borders[r]),
264
+ setTimeout(this.element.appendChild.bind(this.element, n[r]), 0));
265
+ ((this.borders[0].style.top = 0),
266
+ (this.borders[0].style.width = "100%"),
267
+ (this.borders[1].style.right = 0),
268
+ (this.borders[1].style.height = "100%"),
269
+ (this.borders[2].style.bottom = 0),
270
+ (this.borders[2].style.width = "100%"),
271
+ (this.borders[3].style.left = 0),
272
+ (this.borders[3].style.height = "100%"),
273
+ (n[0].style.top = "-3px"),
274
+ (n[0].style.left = "-3px"),
275
+ (n[1].style.top = "-3px"),
276
+ (n[1].style.right = "-3px"),
277
+ (n[2].style.bottom = "-3px"),
278
+ (n[2].style.right = "-3px"),
279
+ (n[3].style.bottom = "-3px"),
280
+ (n[3].style.left = "-3px"),
281
+ this.overlay ||
282
+ (this.overlay = new t.SelectionOverlay(
283
+ this.element,
284
+ this.rect || new t.SelectionRect(),
285
+ )),
286
+ (this.innerTracker = new t.MouseTracker({
287
+ element: this.element,
288
+ clickTimeThreshold: this.viewer.clickTimeThreshold,
289
+ clickDistThreshold: this.viewer.clickDistThreshold,
290
+ dragHandler: t.delegate(this, y),
291
+ dragEndHandler: t.delegate(this, f),
292
+ clickHandler: t.delegate(this, m),
293
+ })),
294
+ this.viewer.addHandler("canvas-click", m.bind(this)),
295
+ this.viewer.addHandler("canvas-drag", c.bind(this)),
296
+ this.viewer.addHandler("canvas-drag-end", g.bind(this)),
297
+ this.keyboardShortcut &&
298
+ t.addEvent(
299
+ this.viewer.container,
300
+ "keypress",
301
+ t.delegate(this, b),
302
+ !1,
303
+ ));
304
+ let o = this.prefixUrl || this.viewer.prefixUrl || "",
305
+ h = this.viewer.buttons && this.viewer.buttonGroup.buttons,
306
+ a = h ? this.viewer.buttonGroup.buttons[0] : null,
307
+ u = a ? a.onFocus : null,
308
+ l = a ? a.onBlur : null;
309
+ if (
310
+ (this.showSelectionControl &&
311
+ ((this.toggleButton = new t.Button({
312
+ element: this.toggleButton
313
+ ? t.getElement(this.toggleButton)
314
+ : null,
315
+ clickTimeThreshold: this.viewer.clickTimeThreshold,
316
+ clickDistThreshold: this.viewer.clickDistThreshold,
317
+ tooltip:
318
+ t.getString("Tooltips.SelectionToggle") || "Toggle selection",
319
+ srcRest: o + this.navImages.selection.REST,
320
+ srcGroup: o + this.navImages.selection.GROUP,
321
+ srcHover: o + this.navImages.selection.HOVER,
322
+ srcDown: o + this.navImages.selection.DOWN,
323
+ onRelease: this.toggleState.bind(this),
324
+ onFocus: u,
325
+ onBlur: l,
326
+ })),
327
+ h &&
328
+ (this.viewer.buttonGroup.buttons.push(this.toggleButton),
329
+ this.viewer.buttonGroup.element.appendChild(
330
+ this.toggleButton.element,
331
+ )),
332
+ this.toggleButton.imgDown &&
333
+ ((this.buttonActiveImg = this.toggleButton.imgDown.cloneNode(!0)),
334
+ this.toggleButton.element.appendChild(this.buttonActiveImg))),
335
+ this.showConfirmDenyButtons)
336
+ ) {
337
+ this.confirmButton = new t.Button({
338
+ element: this.confirmButton
339
+ ? t.getElement(this.confirmButton)
340
+ : null,
341
+ clickTimeThreshold: this.viewer.clickTimeThreshold,
342
+ clickDistThreshold: this.viewer.clickDistThreshold,
343
+ tooltip:
344
+ t.getString("Tooltips.SelectionConfirm") || "Confirm selection",
345
+ srcRest: o + this.navImages.selectionConfirm.REST,
346
+ srcGroup: o + this.navImages.selectionConfirm.GROUP,
347
+ srcHover: o + this.navImages.selectionConfirm.HOVER,
348
+ srcDown: o + this.navImages.selectionConfirm.DOWN,
349
+ onRelease: this.confirm.bind(this),
350
+ onFocus: u,
351
+ onBlur: l,
352
+ });
353
+ let r = this.confirmButton.element;
354
+ (r.classList.add("confirm-button"),
355
+ this.element.appendChild(r),
356
+ (this.cancelButton = new t.Button({
357
+ element: this.cancelButton
358
+ ? t.getElement(this.cancelButton)
359
+ : null,
360
+ clickTimeThreshold: this.viewer.clickTimeThreshold,
361
+ clickDistThreshold: this.viewer.clickDistThreshold,
362
+ tooltip:
363
+ t.getString("Tooltips.SelectionCancel") || "Cancel selection",
364
+ srcRest: o + this.navImages.selectionCancel.REST,
365
+ srcGroup: o + this.navImages.selectionCancel.GROUP,
366
+ srcHover: o + this.navImages.selectionCancel.HOVER,
367
+ srcDown: o + this.navImages.selectionCancel.DOWN,
368
+ onRelease: this.cancel.bind(this),
369
+ onFocus: u,
370
+ onBlur: l,
371
+ })));
372
+ let w = this.cancelButton.element;
373
+ (w.classList.add("cancel-button"),
374
+ this.element.appendChild(w),
375
+ this.styleConfirmDenyButtons &&
376
+ ((r.style.position = "absolute"),
377
+ (r.style.top = "50%"),
378
+ (r.style.left = "50%"),
379
+ (r.style.transform = "translate(-100%, -50%)"),
380
+ (w.style.position = "absolute"),
381
+ (w.style.top = "50%"),
382
+ (w.style.left = "50%"),
383
+ (w.style.transform = "translate(0, -50%)")));
384
+ }
385
+ (this.viewer.addHandler("selection", this.onSelection),
386
+ this.viewer.addHandler("selection_cancel", this.onSelectionCanceled),
387
+ this.viewer.addHandler("selection_change", this.onSelectionChange),
388
+ this.viewer.addHandler("selection_toggle", this.onSelectionToggled),
389
+ this.viewer.addHandler("open", this.draw.bind(this)),
390
+ this.viewer.addHandler("animation", this.draw.bind(this)),
391
+ this.viewer.addHandler("resize", this.draw.bind(this)),
392
+ this.viewer.addHandler("rotate", this.draw.bind(this)));
393
+ }),
394
+ t.extend(t.Selection.prototype, t.ControlDock.prototype, {
395
+ toggleState: function () {
396
+ return this.setState(!this.isSelecting);
397
+ },
398
+ setState: function (i) {
399
+ return (
400
+ (this.isSelecting = i),
401
+ i ? this.draw() : this.undraw(),
402
+ this.buttonActiveImg &&
403
+ (this.buttonActiveImg.style.visibility = i
404
+ ? "visible"
405
+ : "hidden"),
406
+ this.viewer.raiseEvent("selection_toggle", { enabled: i }),
407
+ this
408
+ );
409
+ },
410
+ setAllowRotation: function (i) {
411
+ this.allowRotation = i;
412
+ },
413
+ enable: function () {
414
+ return this.setState(!0);
415
+ },
416
+ disable: function () {
417
+ return this.setState(!1);
418
+ },
419
+ draw: function () {
420
+ return (
421
+ this.rect &&
422
+ (this.overlay.update(this.rect.normalize()),
423
+ this.overlay.drawHTML(
424
+ this.viewer.drawer.container,
425
+ this.viewer.viewport,
426
+ ),
427
+ this.viewer.raiseEvent(
428
+ "selection_change",
429
+ this.getCurrentRect(),
430
+ )),
431
+ this
432
+ );
433
+ },
434
+ undraw: function () {
435
+ return (this.overlay.destroy(), (this.rect = null), this);
436
+ },
437
+ confirm: function () {
438
+ return (
439
+ this.rect &&
440
+ (this.viewer.raiseEvent("selection", this.getCurrentRect()),
441
+ this.undraw()),
442
+ this
443
+ );
444
+ },
445
+ getCurrentRect: function () {
446
+ let i = this.rect.normalize();
447
+ if (this.returnPixelCoordinates) {
448
+ let e = this.viewer.viewport.viewportToImageRectangle(i);
449
+ ((e = t.SelectionRect.fromRect(e).round()),
450
+ (e.rotation = i.rotation),
451
+ (i = e));
452
+ }
453
+ return i;
454
+ },
455
+ cancel: function () {
456
+ return (
457
+ this.viewer.raiseEvent("selection_cancel", !1),
458
+ this.undraw()
459
+ );
460
+ },
461
+ }));
462
+ function s(i) {
463
+ if (i.cropMinimumSize === !0) {
464
+ let e = i.viewer.viewport.imageToViewportCoordinates(
465
+ i.cropMinimumWidth,
466
+ i.cropMinimumHeight,
467
+ );
468
+ ((i.rect.width = i.rect.width < e.x ? e.x : i.rect.width),
469
+ (i.rect.height = i.rect.height < e.y ? e.y : i.rect.height));
470
+ }
471
+ }
472
+ function c(i) {
473
+ if (
474
+ ((i.preventDefaultAction =
475
+ this.isSelecting &&
476
+ (this.rect === null || !this.rectDone || this.allowRotation)),
477
+ !this.isSelecting)
478
+ )
479
+ return;
480
+ let e = this.viewer.viewport.deltaPointsFromPixels(i.delta, !0),
481
+ n = this.viewer.viewport.pointFromPixel(i.position, !0),
482
+ o = new t.Point(n.x - e.x, n.y - e.y);
483
+ if (this.rect) {
484
+ let h;
485
+ if (
486
+ ((this.restrictToImage || this.cropMinimumSize) &&
487
+ (h = this.rect.clone()),
488
+ this.rectDone)
489
+ ) {
490
+ if (this.allowRotation) {
491
+ let u = this.rect.getAngleFromCenter(o),
492
+ l = this.rect.getAngleFromCenter(n);
493
+ this.rect.rotation = (this.rect.rotation + u - l) % Math.PI;
494
+ }
495
+ } else
496
+ this.startRotated
497
+ ? (this.rect = v(
498
+ this.rotatedStartPoint,
499
+ n,
500
+ this.startRotatedHeight,
501
+ ))
502
+ : ((this.rect.width += e.x), (this.rect.height += e.y));
503
+ let a = this.viewer.world.getHomeBounds();
504
+ this.restrictToImage &&
505
+ !this.rect.fitsIn(new t.Rect(0, 0, a.width, a.height)) &&
506
+ (this.rect = h);
507
+ } else {
508
+ if (this.restrictToImage) {
509
+ if (!x(this, o)) return;
510
+ S(e, n);
511
+ }
512
+ (this.startRotated
513
+ ? ((this.rotatedStartPoint = o),
514
+ (this.rect = v(o, n, this.startRotatedHeight)))
515
+ : (this.rect = new t.SelectionRect(o.x, o.y, e.x, e.y)),
516
+ (this.rectDone = !1));
517
+ }
518
+ (s(this), this.draw());
519
+ }
520
+ function g() {
521
+ this.rect !== null &&
522
+ (this.rect.width < 0 &&
523
+ ((this.rect.x += this.rect.width),
524
+ (this.rect.width = Math.abs(this.rect.width))),
525
+ this.rect.height < 0 &&
526
+ ((this.rect.y += this.rect.height),
527
+ (this.rect.height = Math.abs(this.rect.height))),
528
+ this.viewer.setMouseNavEnabled(!0),
529
+ (this.rectDone = !0));
530
+ }
531
+ function m() {
532
+ this.viewer.canvas.focus();
533
+ }
534
+ function y(i) {
535
+ t.addClass(this.element, "dragging");
536
+ let e = this.viewer.viewport.deltaPointsFromPixels(i.delta, !0);
537
+ ((this.rect.x += e.x), (this.rect.y += e.y));
538
+ let n = this.viewer.world.getHomeBounds();
539
+ (this.restrictToImage &&
540
+ !this.rect.fitsIn(new t.Rect(0, 0, n.width, n.height)) &&
541
+ ((this.rect.x -= e.x), (this.rect.y -= e.y)),
542
+ s(this),
543
+ this.draw());
544
+ }
545
+ function f() {
546
+ t.removeClass(this.element, "dragging");
547
+ }
548
+ function d(i, e) {
549
+ let n = this.rect.getDegreeRotation(),
550
+ o =
551
+ this.restrictToImage || this.cropMinimumSize
552
+ ? this.rect.clone()
553
+ : null,
554
+ h = e.delta,
555
+ a;
556
+ switch (
557
+ (n !== 0 &&
558
+ ((h = h.rotate(-1 * n, new t.Point(0, 0))),
559
+ (a = this.rect.getCenter())),
560
+ (h = this.viewer.viewport.deltaPointsFromPixels(h, !0)),
561
+ i)
562
+ ) {
563
+ case 0:
564
+ ((this.rect.y += h.y), (this.rect.height -= h.y));
565
+ break;
566
+ case 1:
567
+ this.rect.width += h.x;
568
+ break;
569
+ case 2:
570
+ this.rect.height += h.y;
571
+ break;
572
+ case 3:
573
+ ((this.rect.x += h.x), (this.rect.width -= h.x));
574
+ break;
575
+ case 0.5:
576
+ ((this.rect.y += h.y),
577
+ (this.rect.height -= h.y),
578
+ (this.rect.x += h.x),
579
+ (this.rect.width -= h.x));
580
+ break;
581
+ case 1.5:
582
+ ((this.rect.y += h.y),
583
+ (this.rect.height -= h.y),
584
+ (this.rect.width += h.x));
585
+ break;
586
+ case 2.5:
587
+ ((this.rect.width += h.x), (this.rect.height += h.y));
588
+ break;
589
+ case 3.5:
590
+ ((this.rect.height += h.y),
591
+ (this.rect.x += h.x),
592
+ (this.rect.width -= h.x));
593
+ break;
594
+ }
595
+ if (n !== 0) {
596
+ let l = this.rect.getCenter();
597
+ ((h = l.rotate(n, a).minus(l)),
598
+ (this.rect.x += h.x),
599
+ (this.rect.y += h.y));
600
+ }
601
+ let u = this.viewer.world.getHomeBounds();
602
+ (this.restrictToImage &&
603
+ !this.rect.fitsIn(new t.Rect(0, 0, u.width, u.height)) &&
604
+ (this.rect = o),
605
+ s(this),
606
+ this.draw());
607
+ }
608
+ function p() {
609
+ (this.rect.width < 0 &&
610
+ ((this.rect.x += this.rect.width),
611
+ (this.rect.width = Math.abs(this.rect.width))),
612
+ this.rect.height < 0 &&
613
+ ((this.rect.y += this.rect.height),
614
+ (this.rect.height = Math.abs(this.rect.height))));
615
+ }
616
+ function b(i) {
617
+ let e = i.keyCode ? i.keyCode : i.charCode;
618
+ e === 13
619
+ ? this.confirm()
620
+ : String.fromCharCode(e) === this.keyboardShortcut &&
621
+ this.toggleState();
622
+ }
623
+ function v(i, e, n) {
624
+ if (i.x > e.x) {
625
+ let w = i;
626
+ ((i = e), (e = w));
627
+ }
628
+ let o = e.minus(i),
629
+ h = i.distanceTo(e),
630
+ a = -1 * Math.atan2(o.x, o.y) + Math.PI / 2,
631
+ u = new t.Point(o.x / 2 + i.x, o.y / 2 + i.y),
632
+ l = new t.SelectionRect(u.x - h / 2, u.y - n / 2, h, n, a),
633
+ r = new t.Point(0, n);
634
+ return (
635
+ (r = r.rotate(l.getDegreeRotation(), new t.Point(0, 0))),
636
+ (l.x += r.x / 2),
637
+ (l.y += r.y / 2),
638
+ l
639
+ );
640
+ }
641
+ function x(i, e) {
642
+ let n = i.viewer.world.getHomeBounds();
643
+ return e.x >= 0 && e.x <= n.width && e.y >= 0 && e.y <= n.height;
644
+ }
645
+ function S(i, e) {
646
+ let n;
647
+ for (let o in { x: 0, y: 0 })
648
+ ((n = e[o] - i[o]),
649
+ n < 1 &&
650
+ n > 0 &&
651
+ (e[o] > 1
652
+ ? ((i[o] -= e[o] - 1), (e[o] = 1))
653
+ : e[o] < 0 && ((i[o] -= e[o]), (e[o] = 0))));
654
+ }
655
+ })(OpenSeadragon);
656
+ })();
657
+ //# sourceMappingURL=openseadragonselection.js.map
@@ -0,0 +1,9 @@
1
+
2
+ declare module 'annotorious-openseadragon-ld';
3
+ declare module '@silence_top/annotorious-openseadragon-ld';
4
+
5
+ declare module '*.png' {
6
+ const value: string;
7
+ export default value;
8
+ }
9
+