@linkurious/ogma-annotations 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Polygon-DVFVmDbR.js → Polygon-BsnVN6js.js} +287 -277
- package/dist/index.js +6 -6
- package/dist/index.mjs +1898 -1748
- package/dist/types/index.d.ts +65 -3
- package/dist/types/ui.d.ts +8 -0
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +3 -3
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click", ut = "select", yt = "unselect", lt = "hover", ft = "unhover", gt = "remove",
|
|
1
|
+
const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click", ut = "select", yt = "unselect", lt = "hover", ft = "unhover", gt = "remove", pt = "add", ht = "cancelDrawing", xt = "completeDrawing", mt = "update", bt = "link", Tt = "history", wt = "data-annotation", Et = 5, It = 3, St = {
|
|
2
2
|
SHAPES: 1,
|
|
3
3
|
EDITOR: 2,
|
|
4
4
|
HANDLES: 3
|
|
5
|
-
},
|
|
5
|
+
}, T = "start", Ct = "end", Mt = {
|
|
6
6
|
default: "default",
|
|
7
7
|
move: "move",
|
|
8
8
|
pointer: "pointer",
|
|
@@ -21,7 +21,7 @@ const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click",
|
|
|
21
21
|
eResize: "e-resize",
|
|
22
22
|
sResize: "s-resize",
|
|
23
23
|
wResize: "w-resize"
|
|
24
|
-
},
|
|
24
|
+
}, w = "collapsed", B = "expanded", Nt = 1.2, z = 0.2, At = {
|
|
25
25
|
TEXT: "text",
|
|
26
26
|
NODE: "node",
|
|
27
27
|
BOX: "box",
|
|
@@ -35,11 +35,14 @@ const ot = -1, it = "dragging", at = "dragstart", ct = "dragend", dt = "click",
|
|
|
35
35
|
<path d="M12 6.00015H7.33333C6.97971 6.00015 6.64057 6.14063 6.39052 6.39068C6.14048 6.64072 6 6.97986 6 7.33348V16.6668C6 17.0204 6.14048 17.3596 6.39052 17.6096C6.64057 17.8597 6.97971 18.0002 7.33333 18.0002H16.6667C17.0203 18.0002 17.3594 17.8597 17.6095 17.6096C17.8595 17.3596 18 17.0204 18 16.6668V12.0002M16.25 5.75015C16.5152 5.48493 16.8749 5.33594 17.25 5.33594C17.6251 5.33594 17.9848 5.48493 18.25 5.75015C18.5152 6.01537 18.6642 6.37508 18.6642 6.75015C18.6642 7.12522 18.5152 7.48493 18.25 7.75015L12.2413 13.7595C12.083 13.9176 11.8875 14.0334 11.6727 14.0962L9.75733 14.6562C9.69997 14.6729 9.63916 14.6739 9.58127 14.6591C9.52339 14.6442 9.47055 14.6141 9.4283 14.5719C9.38604 14.5296 9.35593 14.4768 9.3411 14.4189C9.32627 14.361 9.32727 14.3002 9.344 14.2428L9.904 12.3275C9.96702 12.1129 10.083 11.9175 10.2413 11.7595L16.25 5.75015Z" stroke="#1A70E5" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
36
36
|
</svg>
|
|
37
37
|
`;
|
|
38
|
-
let g = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e,
|
|
38
|
+
let g = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, n) => (n &= 63, n < 36 ? e += n.toString(36) : n < 62 ? e += (n - 26).toString(36).toUpperCase() : n > 62 ? e += "-" : e += "_", e), "");
|
|
39
39
|
const G = "http://www.w3.org/2000/svg";
|
|
40
40
|
function Rt(t) {
|
|
41
41
|
return document.createElementNS(G, t);
|
|
42
42
|
}
|
|
43
|
+
function zt(t, e) {
|
|
44
|
+
t.appendChild(e);
|
|
45
|
+
}
|
|
43
46
|
function S(t) {
|
|
44
47
|
return t.geometry.bbox || H(t), t.geometry.bbox;
|
|
45
48
|
}
|
|
@@ -55,19 +58,19 @@ function D(t) {
|
|
|
55
58
|
height: e[3] - e[1]
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
|
-
function Y(t, e = !1,
|
|
61
|
+
function Y(t, e = !1, n = 1) {
|
|
59
62
|
if (t.geometry.type === "Point" && "width" in t.properties && "height" in t.properties) {
|
|
60
63
|
const [s, o] = t.geometry.coordinates;
|
|
61
64
|
let i = t.properties.width, a = t.properties.height;
|
|
62
|
-
return e && (i /=
|
|
65
|
+
return e && (i /= n, a /= n), {
|
|
63
66
|
x: s - i / 2,
|
|
64
67
|
y: o - a / 2
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
|
-
const
|
|
68
|
-
return { x:
|
|
70
|
+
const r = S(t);
|
|
71
|
+
return { x: r[0], y: r[1] };
|
|
69
72
|
}
|
|
70
|
-
function
|
|
73
|
+
function Dt(t) {
|
|
71
74
|
if (t.geometry.type === "Point")
|
|
72
75
|
return { x: t.geometry.coordinates[0], y: t.geometry.coordinates[1] };
|
|
73
76
|
const e = S(t);
|
|
@@ -75,57 +78,57 @@ function zt(t) {
|
|
|
75
78
|
}
|
|
76
79
|
function H(t) {
|
|
77
80
|
if (j(t)) {
|
|
78
|
-
const [e,
|
|
81
|
+
const [e, n] = t.geometry.coordinates[0], [r, s] = t.geometry.coordinates[1];
|
|
79
82
|
t.geometry.bbox = [
|
|
80
|
-
Math.min(e,
|
|
81
|
-
Math.min(
|
|
82
|
-
Math.max(e,
|
|
83
|
-
Math.max(
|
|
83
|
+
Math.min(e, r),
|
|
84
|
+
Math.min(n, s),
|
|
85
|
+
Math.max(e, r),
|
|
86
|
+
Math.max(n, s)
|
|
84
87
|
];
|
|
85
88
|
} else if (t.geometry.type === "Point" && "width" in t.properties && "height" in t.properties) {
|
|
86
|
-
const [e,
|
|
87
|
-
t.geometry.bbox = [e -
|
|
89
|
+
const [e, n] = t.geometry.coordinates, r = t.properties.width / 2, s = t.properties.height / 2;
|
|
90
|
+
t.geometry.bbox = [e - r, n - s, e + r, n + s];
|
|
88
91
|
} else if (t.geometry.type === "Polygon") {
|
|
89
92
|
const e = t.geometry.coordinates[0];
|
|
90
|
-
let
|
|
93
|
+
let n = Number.POSITIVE_INFINITY, r = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
|
|
91
94
|
for (const i of e) {
|
|
92
95
|
const a = i[0], c = i[1];
|
|
93
|
-
a <
|
|
96
|
+
a < n && (n = a), c < r && (r = c), a > s && (s = a), c > o && (o = c);
|
|
94
97
|
}
|
|
95
|
-
t.geometry.bbox = [
|
|
98
|
+
t.geometry.bbox = [n, r, s, o];
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
function
|
|
99
|
-
t.geometry.coordinates = [e +
|
|
101
|
+
function Ot(t, e, n, r, s) {
|
|
102
|
+
t.geometry.coordinates = [e + r / 2, n + s / 2], t.geometry.bbox = [e, n, e + r, n + s], t.properties.width = r, t.properties.height = s;
|
|
100
103
|
}
|
|
101
104
|
function W(t) {
|
|
102
|
-
const [e,
|
|
103
|
-
return { x: e, y:
|
|
105
|
+
const [e, n] = t.geometry.coordinates[0];
|
|
106
|
+
return { x: e, y: n };
|
|
104
107
|
}
|
|
105
108
|
function Ft(t, e) {
|
|
106
|
-
const [
|
|
107
|
-
return { x:
|
|
109
|
+
const [n, r] = t.geometry.coordinates[e === T ? 0 : 1];
|
|
110
|
+
return { x: n, y: r };
|
|
108
111
|
}
|
|
109
112
|
function X(t) {
|
|
110
|
-
const [e,
|
|
111
|
-
return { x: e, y:
|
|
113
|
+
const [e, n] = t.geometry.coordinates[1];
|
|
114
|
+
return { x: e, y: n };
|
|
112
115
|
}
|
|
113
|
-
function $(t, e,
|
|
114
|
-
t.geometry.coordinates[0] = [e,
|
|
116
|
+
function $(t, e, n) {
|
|
117
|
+
t.geometry.coordinates[0] = [e, n];
|
|
115
118
|
}
|
|
116
|
-
function v(t, e,
|
|
117
|
-
t.geometry.coordinates[1] = [e,
|
|
119
|
+
function v(t, e, n) {
|
|
120
|
+
t.geometry.coordinates[1] = [e, n];
|
|
118
121
|
}
|
|
119
122
|
function U(t) {
|
|
120
123
|
return { start: W(t), end: X(t) };
|
|
121
124
|
}
|
|
122
|
-
function Lt(t, e,
|
|
123
|
-
e ===
|
|
125
|
+
function Lt(t, e, n, r) {
|
|
126
|
+
e === T ? $(t, n, r) : v(t, n, r);
|
|
124
127
|
}
|
|
125
|
-
const
|
|
126
|
-
function
|
|
128
|
+
const Vt = (t) => parseInt(t.getAttribute("data-handle-id") || "-1");
|
|
129
|
+
function kt(t) {
|
|
127
130
|
return b(t).reduce(
|
|
128
|
-
(e,
|
|
131
|
+
(e, n) => (e[0] = Math.min(n[0], e[0]), e[1] = Math.min(n[1], e[1]), e[2] = Math.max(n[0], e[2]), e[3] = Math.max(n[1], e[3]), e),
|
|
129
132
|
[
|
|
130
133
|
Number.POSITIVE_INFINITY,
|
|
131
134
|
Number.POSITIVE_INFINITY,
|
|
@@ -137,15 +140,15 @@ function Vt(t) {
|
|
|
137
140
|
function q(t) {
|
|
138
141
|
return Array.isArray(t) && t.length === 2 && t.every(isFinite);
|
|
139
142
|
}
|
|
140
|
-
function
|
|
143
|
+
function Bt(t, e, n, r) {
|
|
141
144
|
for (let s = 0; s < t.coordinates.length; s++) {
|
|
142
145
|
const o = t.coordinates[s];
|
|
143
146
|
if (q(o))
|
|
144
|
-
o[0] =
|
|
147
|
+
o[0] = n + (o[0] - n) * e, o[1] = r + (o[1] - r) * e;
|
|
145
148
|
else
|
|
146
149
|
for (let i = 0; i < o.length; i++) {
|
|
147
150
|
const a = o[i];
|
|
148
|
-
a[0] =
|
|
151
|
+
a[0] = n + (a[0] - n) * e, a[1] = r + (a[1] - r) * e;
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
return t;
|
|
@@ -160,53 +163,53 @@ function b(t) {
|
|
|
160
163
|
else if (t.type == "LineString" || t.type == "MultiPoint")
|
|
161
164
|
e = t.coordinates;
|
|
162
165
|
else if (t.type == "Polygon" || t.type == "MultiLineString")
|
|
163
|
-
e = t.coordinates.reduce(function(
|
|
164
|
-
return
|
|
166
|
+
e = t.coordinates.reduce(function(n, r) {
|
|
167
|
+
return n.concat(r);
|
|
165
168
|
}, []);
|
|
166
169
|
else if (t.type == "MultiPolygon")
|
|
167
170
|
e = t.coordinates.reduce(
|
|
168
|
-
(
|
|
171
|
+
(n, r) => n.concat(r.reduce((s, o) => s.concat(o), [])),
|
|
169
172
|
[]
|
|
170
173
|
);
|
|
171
174
|
else if (t.type == "Feature")
|
|
172
|
-
if (V(t) ||
|
|
173
|
-
const
|
|
175
|
+
if (V(t) || L(t)) {
|
|
176
|
+
const n = S(t);
|
|
174
177
|
e = [
|
|
175
|
-
[
|
|
176
|
-
[
|
|
178
|
+
[n[0], n[1]],
|
|
179
|
+
[n[2], n[3]]
|
|
177
180
|
];
|
|
178
181
|
} else e = b(t.geometry);
|
|
179
182
|
else t.type == "GeometryCollection" ? e = t.geometries.reduce(
|
|
180
|
-
(
|
|
183
|
+
(n, r) => n.concat(b(r)),
|
|
181
184
|
[]
|
|
182
185
|
) : t.type == "FeatureCollection" && (e = t.features.reduce(
|
|
183
|
-
(
|
|
186
|
+
(n, r) => n.concat(b(r)),
|
|
184
187
|
[]
|
|
185
188
|
));
|
|
186
189
|
return e;
|
|
187
190
|
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
191
|
+
function Gt(t, e, n) {
|
|
192
|
+
const r = Math.atan2(t.y - e.y, t.x - e.x);
|
|
190
193
|
return {
|
|
191
|
-
x: e.x +
|
|
192
|
-
y: e.y +
|
|
194
|
+
x: e.x + n * Math.cos(r),
|
|
195
|
+
y: e.y + n * Math.sin(r)
|
|
193
196
|
};
|
|
194
197
|
}
|
|
195
|
-
function
|
|
198
|
+
function Yt(t, e) {
|
|
196
199
|
if (!e) return { x: t.clientX, y: t.clientY };
|
|
197
|
-
const
|
|
200
|
+
const n = e.getBoundingClientRect();
|
|
198
201
|
return {
|
|
199
|
-
x: t.clientX -
|
|
200
|
-
y: t.clientY -
|
|
202
|
+
x: t.clientX - n.left - e.clientLeft,
|
|
203
|
+
y: t.clientY - n.top - e.clientTop
|
|
201
204
|
};
|
|
202
205
|
}
|
|
203
|
-
function
|
|
206
|
+
function Ht(t, e) {
|
|
204
207
|
return t.startsWith("#") ? Z(t, e) : t.startsWith("rgb") ? K(t, e) : t;
|
|
205
208
|
}
|
|
206
|
-
function
|
|
209
|
+
function Wt(t) {
|
|
207
210
|
if (t.startsWith("#")) {
|
|
208
|
-
const e =
|
|
209
|
-
return { r, g:
|
|
211
|
+
const e = N(t), n = parseInt(e.slice(1, 3), 16), r = parseInt(e.slice(3, 5), 16), s = parseInt(e.slice(5, 7), 16);
|
|
212
|
+
return { r: n, g: r, b: s, a: 1 };
|
|
210
213
|
} else {
|
|
211
214
|
const e = t.match(
|
|
212
215
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
|
|
@@ -220,62 +223,62 @@ function Ht(t) {
|
|
|
220
223
|
};
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
|
-
function
|
|
226
|
+
function N(t) {
|
|
224
227
|
return t.length === 4 ? t.split("").map((e) => e + e).join("") : t;
|
|
225
228
|
}
|
|
226
229
|
function Z(t, e) {
|
|
227
|
-
const [
|
|
228
|
-
return `rgba(${
|
|
230
|
+
const [n, r, s] = N(t).match(/\w\w/g).map((o) => parseInt(o, 16));
|
|
231
|
+
return `rgba(${n}, ${r}, ${s}, ${e})`;
|
|
229
232
|
}
|
|
230
233
|
function K(t, e) {
|
|
231
|
-
const [
|
|
232
|
-
return `rgba(${
|
|
234
|
+
const [n, r, s] = t.match(/\d+/g).map((o) => parseInt(o, 10));
|
|
235
|
+
return `rgba(${n}, ${r}, ${s}, ${e})`;
|
|
233
236
|
}
|
|
234
|
-
function
|
|
237
|
+
function Xt() {
|
|
235
238
|
return typeof window < "u" ? window : void 0;
|
|
236
239
|
}
|
|
237
|
-
const
|
|
238
|
-
let
|
|
240
|
+
const $t = (t, e = 16, n = !1) => {
|
|
241
|
+
let r = !1, s = null;
|
|
239
242
|
const o = Math.max(1, Math.round(e * 60 / 1e3)), i = (a) => {
|
|
240
243
|
requestAnimationFrame(() => {
|
|
241
244
|
if (a > 1)
|
|
242
245
|
i(a - 1);
|
|
243
|
-
else if (
|
|
246
|
+
else if (r = !1, n && s !== null) {
|
|
244
247
|
const c = s;
|
|
245
|
-
s = null, t(...c),
|
|
248
|
+
s = null, t(...c), r = !0, i(o);
|
|
246
249
|
}
|
|
247
250
|
});
|
|
248
251
|
};
|
|
249
252
|
return (...a) => {
|
|
250
|
-
if (
|
|
251
|
-
|
|
253
|
+
if (r) {
|
|
254
|
+
n && (s = a);
|
|
252
255
|
return;
|
|
253
256
|
}
|
|
254
|
-
t(...a),
|
|
257
|
+
t(...a), r = !0, i(o);
|
|
255
258
|
};
|
|
256
|
-
},
|
|
257
|
-
let
|
|
259
|
+
}, vt = (t, e) => {
|
|
260
|
+
let n;
|
|
258
261
|
return (...s) => {
|
|
259
|
-
clearTimeout(
|
|
262
|
+
clearTimeout(n), n = setTimeout(() => t(...s), e);
|
|
260
263
|
};
|
|
261
264
|
};
|
|
262
|
-
function
|
|
263
|
-
let
|
|
264
|
-
return function(...
|
|
265
|
-
clearTimeout(
|
|
266
|
-
t.apply(this,
|
|
265
|
+
function Ut(t, e) {
|
|
266
|
+
let n;
|
|
267
|
+
return function(...r) {
|
|
268
|
+
clearTimeout(n), n = setTimeout(() => {
|
|
269
|
+
t.apply(this, r);
|
|
267
270
|
}, e);
|
|
268
271
|
};
|
|
269
272
|
}
|
|
270
|
-
function
|
|
271
|
-
if ((
|
|
272
|
-
const e = t.geometry.coordinates[0],
|
|
273
|
+
function qt(t) {
|
|
274
|
+
if ((L(t) || V(t)) && t.geometry.type === "Polygon") {
|
|
275
|
+
const e = t.geometry.coordinates[0], n = e[0][0], r = e[0][1], s = e[2][0], o = e[2][1], i = s - n, a = o - r, c = n + i / 2, d = r + a / 2;
|
|
273
276
|
return {
|
|
274
277
|
...t,
|
|
275
278
|
geometry: {
|
|
276
279
|
type: "Point",
|
|
277
280
|
coordinates: [c, d],
|
|
278
|
-
bbox: [
|
|
281
|
+
bbox: [n, r, s, o]
|
|
279
282
|
},
|
|
280
283
|
properties: {
|
|
281
284
|
...t.properties,
|
|
@@ -286,51 +289,51 @@ function Ut(t) {
|
|
|
286
289
|
}
|
|
287
290
|
return t;
|
|
288
291
|
}
|
|
289
|
-
function
|
|
290
|
-
let
|
|
292
|
+
function O(t, e) {
|
|
293
|
+
let n, r, s, o = 1;
|
|
291
294
|
const i = t.trim();
|
|
292
295
|
if (i.startsWith("#")) {
|
|
293
|
-
const y = (i.length === 4 ?
|
|
296
|
+
const y = (i.length === 4 ? N(i) : i).match(/#?(\w{2})(\w{2})(\w{2})/);
|
|
294
297
|
if (!y) return t;
|
|
295
|
-
|
|
298
|
+
n = parseInt(y[1], 16), r = parseInt(y[2], 16), s = parseInt(y[3], 16);
|
|
296
299
|
} else {
|
|
297
300
|
const u = i.match(
|
|
298
301
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/
|
|
299
302
|
);
|
|
300
303
|
if (!u) return t;
|
|
301
|
-
|
|
304
|
+
n = parseInt(u[1]), r = parseInt(u[2]), s = parseInt(u[3]), o = u[4] !== void 0 ? parseFloat(u[4]) : 1;
|
|
302
305
|
}
|
|
303
|
-
const a = e * 100, d = 0.299 *
|
|
304
|
-
return
|
|
306
|
+
const a = e * 100, d = 0.299 * n + 0.587 * r + 0.114 * s > 186 ? -a / 2 : a;
|
|
307
|
+
return n = Math.max(0, Math.min(255, n + Math.round(2.55 * d))), r = Math.max(0, Math.min(255, r + Math.round(2.55 * d))), s = Math.max(0, Math.min(255, s + Math.round(2.55 * d))), `rgba(${n},${r},${s},${o})`;
|
|
305
308
|
}
|
|
306
|
-
const
|
|
309
|
+
const Zt = (t) => O(t, z), Kt = (t) => O(t, -z), P = (t, e) => ({
|
|
307
310
|
x: t.x - e.x,
|
|
308
311
|
y: t.y - e.y
|
|
309
|
-
}),
|
|
312
|
+
}), F = (t) => Math.sqrt(t.x * t.x + t.y * t.y), Jt = (t) => ({
|
|
310
313
|
x: -t.x,
|
|
311
314
|
y: -t.y
|
|
312
315
|
}), R = (t) => {
|
|
313
|
-
const e =
|
|
316
|
+
const e = F(t);
|
|
314
317
|
return e === 0 ? { x: 0, y: 0 } : {
|
|
315
318
|
x: t.x / e,
|
|
316
319
|
y: t.y / e
|
|
317
320
|
};
|
|
318
|
-
},
|
|
321
|
+
}, Qt = (t, e) => ({
|
|
319
322
|
x: t.x + e.x,
|
|
320
323
|
y: t.y + e.y
|
|
321
|
-
}),
|
|
324
|
+
}), jt = (t, e) => ({
|
|
322
325
|
x: t.x * e,
|
|
323
326
|
y: t.y * e
|
|
324
|
-
}),
|
|
325
|
-
const
|
|
327
|
+
}), te = (t, e) => {
|
|
328
|
+
const n = Math.sin(e), r = Math.cos(e);
|
|
326
329
|
return {
|
|
327
|
-
x: t.x *
|
|
328
|
-
y: t.x *
|
|
330
|
+
x: t.x * r - t.y * n,
|
|
331
|
+
y: t.x * n + t.y * r
|
|
329
332
|
};
|
|
330
333
|
}, J = (t, e) => t.x * e.x + t.y * e.y, Q = (t, e) => t.x * e.y - t.y * e.x, j = (t) => t.properties.type === "arrow";
|
|
331
|
-
function
|
|
332
|
-
const { start:
|
|
333
|
-
return d > 0 && d < c && Math.abs(Q(o, R(a))) < i / 2 +
|
|
334
|
+
function ee(t, e, n) {
|
|
335
|
+
const { start: r, end: s } = U(t), o = P(e, r), i = t.properties.style.strokeWidth, a = P(s, r), c = F(a), d = J(o, R(a));
|
|
336
|
+
return d > 0 && d < c && Math.abs(Q(o, R(a))) < i / 2 + n;
|
|
334
337
|
}
|
|
335
338
|
const E = {
|
|
336
339
|
strokeType: "plain",
|
|
@@ -338,7 +341,7 @@ const E = {
|
|
|
338
341
|
strokeWidth: 1,
|
|
339
342
|
head: "none",
|
|
340
343
|
tail: "none"
|
|
341
|
-
},
|
|
344
|
+
}, ne = {
|
|
342
345
|
id: void 0,
|
|
343
346
|
// will be set by the editor
|
|
344
347
|
type: "Feature",
|
|
@@ -365,7 +368,7 @@ const E = {
|
|
|
365
368
|
// tail: 'arrow-plain',
|
|
366
369
|
// start: { x: 0, y: 0 },
|
|
367
370
|
// end: { x: 100, y: 100 }
|
|
368
|
-
}, tt = (t = 0, e = 0,
|
|
371
|
+
}, tt = (t = 0, e = 0, n = 0, r = 0, s = { ...E }) => ({
|
|
369
372
|
id: g(),
|
|
370
373
|
type: "Feature",
|
|
371
374
|
properties: {
|
|
@@ -379,12 +382,12 @@ const E = {
|
|
|
379
382
|
type: "LineString",
|
|
380
383
|
coordinates: [
|
|
381
384
|
[t, e],
|
|
382
|
-
[
|
|
385
|
+
[n, r]
|
|
383
386
|
]
|
|
384
387
|
}
|
|
385
|
-
}),
|
|
386
|
-
function re(t, e,
|
|
387
|
-
const o = Y(t), { width: i, height: a } = D(t), c = e.x - o.x, d = e.y - o.y, u = c *
|
|
388
|
+
}), L = (t) => t.properties.type === "box";
|
|
389
|
+
function re(t, e, n = 0, r = 1, s = 0) {
|
|
390
|
+
const o = Y(t), { width: i, height: a } = D(t), c = e.x - o.x, d = e.y - o.y, u = c * r - d * n, y = c * n + d * r;
|
|
388
391
|
return u > -s && u < i + s && y > -s && y < a + s;
|
|
389
392
|
}
|
|
390
393
|
const I = {
|
|
@@ -394,7 +397,7 @@ const I = {
|
|
|
394
397
|
boxShadow: "",
|
|
395
398
|
padding: 16,
|
|
396
399
|
strokeType: "plain"
|
|
397
|
-
},
|
|
400
|
+
}, se = {
|
|
398
401
|
id: void 0,
|
|
399
402
|
// will be set by the editor
|
|
400
403
|
type: "Feature",
|
|
@@ -410,21 +413,21 @@ const I = {
|
|
|
410
413
|
// center of 100x50 box
|
|
411
414
|
bbox: [0, 0, 100, 50]
|
|
412
415
|
}
|
|
413
|
-
},
|
|
416
|
+
}, oe = (t = 0, e = 0, n = 100, r = 50, s = { ...I }) => ({
|
|
414
417
|
id: g(),
|
|
415
418
|
type: "Feature",
|
|
416
419
|
properties: {
|
|
417
420
|
type: "box",
|
|
418
|
-
width:
|
|
419
|
-
height:
|
|
421
|
+
width: n,
|
|
422
|
+
height: r,
|
|
420
423
|
style: { ...I, ...s }
|
|
421
424
|
},
|
|
422
425
|
geometry: {
|
|
423
426
|
type: "Point",
|
|
424
|
-
coordinates: [t +
|
|
427
|
+
coordinates: [t + n / 2, e + r / 2]
|
|
425
428
|
// center
|
|
426
429
|
}
|
|
427
|
-
}), V = (t) => t.properties.type === "text",
|
|
430
|
+
}), V = (t) => t.properties.type === "text", M = {
|
|
428
431
|
font: "sans-serif",
|
|
429
432
|
fontSize: 18,
|
|
430
433
|
color: "#505050",
|
|
@@ -434,7 +437,7 @@ const I = {
|
|
|
434
437
|
padding: 16,
|
|
435
438
|
strokeType: "plain",
|
|
436
439
|
fixedSize: !1
|
|
437
|
-
},
|
|
440
|
+
}, ie = {
|
|
438
441
|
id: g(),
|
|
439
442
|
type: "Feature",
|
|
440
443
|
properties: {
|
|
@@ -442,7 +445,7 @@ const I = {
|
|
|
442
445
|
content: "",
|
|
443
446
|
width: 100,
|
|
444
447
|
height: 50,
|
|
445
|
-
style: { ...
|
|
448
|
+
style: { ...M }
|
|
446
449
|
},
|
|
447
450
|
geometry: {
|
|
448
451
|
type: "Point",
|
|
@@ -450,32 +453,32 @@ const I = {
|
|
|
450
453
|
// center of 100x50 box
|
|
451
454
|
bbox: [0, 0, 100, 50]
|
|
452
455
|
}
|
|
453
|
-
},
|
|
456
|
+
}, ae = (t = 0, e = 0, n = 100, r = 50, s = "", o = { ...M }) => ({
|
|
454
457
|
id: g(),
|
|
455
458
|
type: "Feature",
|
|
456
459
|
properties: {
|
|
457
460
|
type: "text",
|
|
458
461
|
content: s,
|
|
459
|
-
width:
|
|
460
|
-
height:
|
|
461
|
-
style: { ...
|
|
462
|
+
width: n,
|
|
463
|
+
height: r,
|
|
464
|
+
style: { ...M, ...o }
|
|
462
465
|
},
|
|
463
466
|
geometry: {
|
|
464
467
|
type: "Point",
|
|
465
|
-
coordinates: [t +
|
|
468
|
+
coordinates: [t + n / 2, e + r / 2],
|
|
466
469
|
// center
|
|
467
|
-
bbox: [t, e, t +
|
|
470
|
+
bbox: [t, e, t + n, e + r]
|
|
468
471
|
}
|
|
469
472
|
});
|
|
470
|
-
function et(t, e,
|
|
471
|
-
var
|
|
473
|
+
function et(t, e, n = 0, r = 0, s = 1, o = 1) {
|
|
474
|
+
var m;
|
|
472
475
|
const [i, a] = t.geometry.coordinates;
|
|
473
476
|
let { width: c, height: d } = D(t);
|
|
474
|
-
(
|
|
475
|
-
const u = c / 2, y = d / 2, l = e.x - i, f = e.y - a, h = l * s - f *
|
|
476
|
-
return h > -u -
|
|
477
|
+
(m = t.properties.style) != null && m.fixedSize && (c /= o, d /= o);
|
|
478
|
+
const u = c / 2, y = d / 2, l = e.x - i, f = e.y - a, h = l * s - f * r, x = l * r + f * s;
|
|
479
|
+
return h > -u - n && h < u + n && x > -y - n && x < y + n;
|
|
477
480
|
}
|
|
478
|
-
const
|
|
481
|
+
const ce = (t) => t.properties.type === "comment", p = {
|
|
479
482
|
// Box styling
|
|
480
483
|
background: "#FFFACD",
|
|
481
484
|
// Light yellow (sticky note color)
|
|
@@ -506,26 +509,28 @@ const ae = (t) => t.properties.type === "comment", m = {
|
|
|
506
509
|
shadow: !0,
|
|
507
510
|
expandOnSelect: !1,
|
|
508
511
|
// Fixed size (always screen-aligned)
|
|
509
|
-
fixedSize: !0
|
|
510
|
-
|
|
512
|
+
fixedSize: !0,
|
|
513
|
+
// Connector line behavior
|
|
514
|
+
connectorMode: "rigid"
|
|
515
|
+
}, C = {
|
|
511
516
|
mode: "expanded",
|
|
512
517
|
width: 200,
|
|
513
518
|
height: 60,
|
|
514
519
|
// Initial height, will auto-grow
|
|
515
|
-
style:
|
|
520
|
+
style: p
|
|
516
521
|
};
|
|
517
|
-
function
|
|
522
|
+
function nt(t, e, n, r) {
|
|
518
523
|
const s = {
|
|
519
524
|
type: "comment",
|
|
520
|
-
content:
|
|
521
|
-
mode: (
|
|
522
|
-
width: (
|
|
523
|
-
height: (
|
|
524
|
-
author:
|
|
525
|
-
timestamp:
|
|
525
|
+
content: n,
|
|
526
|
+
mode: (r == null ? void 0 : r.mode) ?? C.mode,
|
|
527
|
+
width: (r == null ? void 0 : r.width) ?? C.width,
|
|
528
|
+
height: (r == null ? void 0 : r.height) ?? C.height,
|
|
529
|
+
author: r == null ? void 0 : r.author,
|
|
530
|
+
timestamp: r == null ? void 0 : r.timestamp,
|
|
526
531
|
style: {
|
|
527
|
-
...
|
|
528
|
-
...
|
|
532
|
+
...p,
|
|
533
|
+
...r == null ? void 0 : r.style
|
|
529
534
|
}
|
|
530
535
|
};
|
|
531
536
|
return {
|
|
@@ -538,51 +543,54 @@ function rt(t, e, r, n) {
|
|
|
538
543
|
}
|
|
539
544
|
};
|
|
540
545
|
}
|
|
541
|
-
function
|
|
546
|
+
function de(t) {
|
|
542
547
|
return {
|
|
543
548
|
...t,
|
|
544
549
|
properties: {
|
|
545
550
|
...t.properties,
|
|
546
|
-
mode: t.properties.mode ===
|
|
551
|
+
mode: t.properties.mode === w ? B : w
|
|
547
552
|
}
|
|
548
553
|
};
|
|
549
554
|
}
|
|
550
|
-
function
|
|
551
|
-
if (t.properties.mode !==
|
|
555
|
+
function ue(t, e, n = 0, r, s, o = 1) {
|
|
556
|
+
if (t.properties.mode !== w)
|
|
552
557
|
return et(
|
|
553
558
|
t,
|
|
554
559
|
e,
|
|
555
|
-
r,
|
|
556
560
|
n,
|
|
561
|
+
r,
|
|
557
562
|
s,
|
|
558
563
|
o
|
|
559
564
|
);
|
|
560
|
-
const i = t.properties, a = { ...
|
|
565
|
+
const i = t.properties, a = { ...p, ...i.style };
|
|
561
566
|
let c = a.iconSize, d = a.iconSize;
|
|
562
567
|
a.fixedSize && (c /= o, d /= o);
|
|
563
568
|
const u = c / 2, y = d / 2, l = e.x - t.geometry.coordinates[0], f = e.y - t.geometry.coordinates[1];
|
|
564
|
-
return l >= -u -
|
|
565
|
-
}
|
|
566
|
-
function ue(t) {
|
|
567
|
-
const [e, r] = t.geometry.coordinates;
|
|
568
|
-
return { x: e, y: r };
|
|
569
|
+
return l >= -u - n && l <= u + n && f >= -y - n && f <= y + n;
|
|
569
570
|
}
|
|
570
571
|
function ye(t) {
|
|
571
|
-
const e
|
|
572
|
-
return
|
|
573
|
-
}
|
|
574
|
-
function nt(t, e = 80) {
|
|
575
|
-
const r = e / t.properties.width;
|
|
576
|
-
return Math.max(0.1, Math.min(1, r));
|
|
572
|
+
const [e, n] = t.geometry.coordinates;
|
|
573
|
+
return { x: e, y: n };
|
|
577
574
|
}
|
|
578
575
|
function le(t) {
|
|
579
|
-
const e = { ...
|
|
580
|
-
return e.
|
|
576
|
+
const e = t.properties, n = { ...p, ...e.style };
|
|
577
|
+
return e.mode === w ? { width: n.iconSize, height: n.iconSize } : { width: e.width, height: e.height };
|
|
581
578
|
}
|
|
582
|
-
function
|
|
583
|
-
const
|
|
584
|
-
|
|
579
|
+
function rt(t, e = 80) {
|
|
580
|
+
const n = e / t.properties.width;
|
|
581
|
+
return Math.max(0.1, Math.min(1, n));
|
|
582
|
+
}
|
|
583
|
+
function fe(t) {
|
|
584
|
+
return ({ ...p, ...t.properties.style }.connectorMode ?? "rigid") !== "elastic";
|
|
585
|
+
}
|
|
586
|
+
function ge(t) {
|
|
587
|
+
const e = { ...p, ...t.properties.style };
|
|
588
|
+
return e.collapseZoomThreshold !== void 0 ? e.collapseZoomThreshold : rt(t);
|
|
589
|
+
}
|
|
590
|
+
function pe(t, e, n, r, s = "", o) {
|
|
591
|
+
const i = nt(
|
|
585
592
|
n,
|
|
593
|
+
r,
|
|
586
594
|
s,
|
|
587
595
|
o == null ? void 0 : o.commentStyle
|
|
588
596
|
), a = {
|
|
@@ -590,59 +598,59 @@ function fe(t, e, r, n, s = "", o) {
|
|
|
590
598
|
head: "arrow",
|
|
591
599
|
// Default to arrow head
|
|
592
600
|
...o == null ? void 0 : o.arrowStyle
|
|
593
|
-
}, c = tt(
|
|
601
|
+
}, c = tt(n, r, t, e, a);
|
|
594
602
|
return c.properties.link = {
|
|
595
|
-
[
|
|
603
|
+
[T]: {
|
|
596
604
|
id: i.id,
|
|
597
|
-
side:
|
|
605
|
+
side: T,
|
|
598
606
|
type: "comment",
|
|
599
607
|
magnet: { x: 0, y: 0 }
|
|
600
608
|
}
|
|
601
609
|
}, { comment: i, arrow: c };
|
|
602
610
|
}
|
|
603
|
-
function
|
|
604
|
-
const d = t - i, u = e - a, y = i + d * o - u * s, l = a + d * s + u * o, f = i + (d +
|
|
605
|
-
return c[0] = Math.min(y, f,
|
|
611
|
+
function he(t, e, n, r, s, o, i, a, c) {
|
|
612
|
+
const d = t - i, u = e - a, y = i + d * o - u * s, l = a + d * s + u * o, f = i + (d + n) * o - u * s, h = a + (d + n) * s + u * o, x = i + (d + n) * o - (u + r) * s, m = a + (d + n) * s + (u + r) * o, A = i + d * o - (u + r) * s, _ = a + d * s + (u + r) * o;
|
|
613
|
+
return c[0] = Math.min(y, f, x, A), c[1] = Math.min(l, h, m, _), c[2] = Math.max(y, f, x, A), c[3] = Math.max(l, h, m, _), c;
|
|
606
614
|
}
|
|
607
|
-
function st(t, e,
|
|
608
|
-
const
|
|
615
|
+
function st(t, e, n) {
|
|
616
|
+
const r = n.x - e.x, s = n.y - e.y, o = r * r + s * s;
|
|
609
617
|
if (o === 0) {
|
|
610
618
|
const y = t.x - e.x, l = t.y - e.y;
|
|
611
619
|
return Math.sqrt(y * y + l * l);
|
|
612
620
|
}
|
|
613
|
-
let i = ((t.x - e.x) *
|
|
621
|
+
let i = ((t.x - e.x) * r + (t.y - e.y) * s) / o;
|
|
614
622
|
i = Math.max(0, Math.min(1, i));
|
|
615
|
-
const a = e.x + i *
|
|
623
|
+
const a = e.x + i * r, c = e.y + i * s, d = t.x - a, u = t.y - c;
|
|
616
624
|
return Math.sqrt(d * d + u * u);
|
|
617
625
|
}
|
|
618
|
-
const
|
|
619
|
-
function
|
|
620
|
-
const
|
|
626
|
+
const xe = (t) => t.properties.type === "polygon";
|
|
627
|
+
function me(t, e, n = 0) {
|
|
628
|
+
const r = t.geometry.coordinates[0], s = t.geometry.bbox;
|
|
621
629
|
if (s) {
|
|
622
630
|
const [i, a, c, d] = s;
|
|
623
|
-
if (e.x < i -
|
|
631
|
+
if (e.x < i - n || e.x > c + n || e.y < a - n || e.y > d + n)
|
|
624
632
|
return !1;
|
|
625
633
|
}
|
|
626
634
|
let o = !1;
|
|
627
|
-
for (let i = 0, a =
|
|
628
|
-
const c =
|
|
635
|
+
for (let i = 0, a = r.length - 1; i < r.length; a = i++) {
|
|
636
|
+
const c = r[i][0], d = r[i][1], u = r[a][0], y = r[a][1];
|
|
629
637
|
d > e.y != y > e.y && e.x < (u - c) * (e.y - d) / (y - d) + c && (o = !o);
|
|
630
638
|
}
|
|
631
639
|
if (o) return !0;
|
|
632
|
-
if (
|
|
633
|
-
for (let i = 0; i <
|
|
634
|
-
const [a, c] =
|
|
635
|
-
if (st(e, { x: a, y: c }, { x: d, y: u }) <=
|
|
640
|
+
if (n > 0)
|
|
641
|
+
for (let i = 0; i < r.length - 1; i++) {
|
|
642
|
+
const [a, c] = r[i], [d, u] = r[i + 1];
|
|
643
|
+
if (st(e, { x: a, y: c }, { x: d, y: u }) <= n) return !0;
|
|
636
644
|
}
|
|
637
645
|
return !1;
|
|
638
646
|
}
|
|
639
|
-
function
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
let
|
|
643
|
-
for (const [y, l] of
|
|
644
|
-
y <
|
|
645
|
-
const a = [
|
|
647
|
+
function be(t, e) {
|
|
648
|
+
const n = t[0];
|
|
649
|
+
n.length > 0 && (n[0][0] !== n[n.length - 1][0] || n[0][1] !== n[n.length - 1][1]) && n.push([n[0][0], n[0][1]]);
|
|
650
|
+
let r = 1 / 0, s = 1 / 0, o = -1 / 0, i = -1 / 0;
|
|
651
|
+
for (const [y, l] of n)
|
|
652
|
+
y < r && (r = y), y > o && (o = y), l < s && (s = l), l > i && (i = l);
|
|
653
|
+
const a = [r, s, o, i], { id: c, style: d, ...u } = e || {};
|
|
646
654
|
return {
|
|
647
655
|
type: "Feature",
|
|
648
656
|
id: c || g(),
|
|
@@ -666,114 +674,116 @@ const k = {
|
|
|
666
674
|
strokeColor: "#000000",
|
|
667
675
|
strokeWidth: 2,
|
|
668
676
|
background: "transparent"
|
|
669
|
-
},
|
|
677
|
+
}, Te = {
|
|
670
678
|
type: "polygon",
|
|
671
679
|
style: {
|
|
672
680
|
...k
|
|
673
681
|
}
|
|
674
682
|
};
|
|
675
683
|
export {
|
|
676
|
-
|
|
677
|
-
|
|
684
|
+
Y as $,
|
|
685
|
+
me as A,
|
|
678
686
|
H as B,
|
|
679
|
-
|
|
687
|
+
w as C,
|
|
680
688
|
xt as D,
|
|
681
689
|
at as E,
|
|
682
|
-
|
|
683
|
-
|
|
690
|
+
p as F,
|
|
691
|
+
M as G,
|
|
684
692
|
D as H,
|
|
685
|
-
|
|
693
|
+
Nt as I,
|
|
686
694
|
J,
|
|
687
695
|
It as K,
|
|
688
696
|
St as L,
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
697
|
+
fe as M,
|
|
698
|
+
ot as N,
|
|
699
|
+
le as O,
|
|
700
|
+
jt as P,
|
|
701
|
+
Qt as Q,
|
|
702
|
+
g as R,
|
|
703
|
+
T as S,
|
|
696
704
|
At as T,
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
705
|
+
$t as U,
|
|
706
|
+
P as V,
|
|
707
|
+
F as W,
|
|
708
|
+
re as X,
|
|
709
|
+
ue as Y,
|
|
710
|
+
et as Z,
|
|
711
|
+
S as _,
|
|
704
712
|
B as a,
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
713
|
+
W as a0,
|
|
714
|
+
X as a1,
|
|
715
|
+
U as a2,
|
|
716
|
+
R as a3,
|
|
717
|
+
Jt as a4,
|
|
718
|
+
zt as a5,
|
|
719
|
+
Rt as a6,
|
|
720
|
+
te as a7,
|
|
721
|
+
I as a8,
|
|
722
|
+
Zt as a9,
|
|
723
|
+
ie as aA,
|
|
724
|
+
kt as aB,
|
|
725
|
+
Gt as aC,
|
|
726
|
+
ye as aD,
|
|
727
|
+
ge as aE,
|
|
728
|
+
b as aF,
|
|
729
|
+
Vt as aG,
|
|
730
|
+
N as aH,
|
|
731
|
+
Z as aI,
|
|
732
|
+
Wt as aJ,
|
|
733
|
+
K as aK,
|
|
734
|
+
Bt as aL,
|
|
735
|
+
v as aM,
|
|
736
|
+
$ as aN,
|
|
737
|
+
Ot as aO,
|
|
738
|
+
de as aP,
|
|
739
|
+
k as aa,
|
|
740
|
+
Pt as ab,
|
|
741
|
+
_t as ac,
|
|
742
|
+
he as ad,
|
|
743
|
+
bt as ae,
|
|
744
|
+
Tt as af,
|
|
745
|
+
ut as ag,
|
|
746
|
+
yt as ah,
|
|
747
|
+
mt as ai,
|
|
748
|
+
gt as aj,
|
|
749
|
+
ht as ak,
|
|
750
|
+
wt as al,
|
|
751
|
+
lt as am,
|
|
752
|
+
ft as an,
|
|
753
|
+
z as ao,
|
|
754
|
+
O as ap,
|
|
755
|
+
rt as aq,
|
|
756
|
+
Ht as ar,
|
|
757
|
+
pe as as,
|
|
758
|
+
Kt as at,
|
|
759
|
+
vt as au,
|
|
760
|
+
Ut as av,
|
|
761
|
+
ne as aw,
|
|
762
|
+
se as ax,
|
|
763
|
+
C as ay,
|
|
764
|
+
Te as az,
|
|
755
765
|
ct as b,
|
|
756
|
-
|
|
766
|
+
Mt as c,
|
|
757
767
|
it as d,
|
|
758
|
-
|
|
768
|
+
Yt as e,
|
|
759
769
|
tt as f,
|
|
760
|
-
|
|
770
|
+
Xt as g,
|
|
761
771
|
E as h,
|
|
762
|
-
|
|
772
|
+
ce as i,
|
|
763
773
|
j,
|
|
764
|
-
|
|
774
|
+
Ct as k,
|
|
765
775
|
dt as l,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
776
|
+
ae as m,
|
|
777
|
+
oe as n,
|
|
778
|
+
be as o,
|
|
779
|
+
nt as p,
|
|
780
|
+
pt as q,
|
|
781
|
+
qt as r,
|
|
772
782
|
V as s,
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
783
|
+
L as t,
|
|
784
|
+
Dt as u,
|
|
785
|
+
xe as v,
|
|
786
|
+
ee as w,
|
|
777
787
|
Ft as x,
|
|
778
788
|
Lt as y,
|
|
779
789
|
Et as z
|