@plurid/plurid-engine 0.0.0-2 → 0.0.0-20

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 (60) hide show
  1. package/distribution/index.d.mts +734 -0
  2. package/distribution/index.d.ts +734 -3
  3. package/distribution/index.js +3317 -2495
  4. package/distribution/index.js.map +1 -1
  5. package/distribution/index.mjs +3426 -0
  6. package/distribution/index.mjs.map +1 -0
  7. package/package.json +71 -79
  8. package/distribution/data/constants/index.d.ts +0 -1
  9. package/distribution/data/interfaces/index.d.ts +0 -4
  10. package/distribution/functions/index.d.ts +0 -2
  11. package/distribution/functions/navigate/index.d.ts +0 -1
  12. package/distribution/functions/template/index.d.ts +0 -1
  13. package/distribution/index.es.js +0 -2590
  14. package/distribution/index.es.js.map +0 -1
  15. package/distribution/modules/general/configuration/index.d.ts +0 -2
  16. package/distribution/modules/general/index.d.ts +0 -3
  17. package/distribution/modules/general/tree/index.d.ts +0 -6
  18. package/distribution/modules/index.d.ts +0 -9
  19. package/distribution/modules/interaction/direction/index.d.ts +0 -2
  20. package/distribution/modules/interaction/index.d.ts +0 -5
  21. package/distribution/modules/interaction/mathematics/matrix/index.d.ts +0 -31
  22. package/distribution/modules/interaction/mathematics/quaternion/index.d.ts +0 -79
  23. package/distribution/modules/interaction/mathematics/transform/index.d.ts +0 -69
  24. package/distribution/modules/internationalization/index.d.ts +0 -3
  25. package/distribution/modules/planes/index.d.ts +0 -2
  26. package/distribution/modules/planes/logic/index.d.ts +0 -6
  27. package/distribution/modules/planes/registrar/index.d.ts +0 -3
  28. package/distribution/modules/planes/registrar/object.d.ts +0 -14
  29. package/distribution/modules/planes/registrar/utilities.d.ts +0 -6
  30. package/distribution/modules/routing/IsoMatcher/index.d.ts +0 -44
  31. package/distribution/modules/routing/IsoMatcher/interfaces.d.ts +0 -57
  32. package/distribution/modules/routing/Parser/index.d.ts +0 -21
  33. package/distribution/modules/routing/Parser/interfaces.d.ts +0 -31
  34. package/distribution/modules/routing/Parser/logic.d.ts +0 -68
  35. package/distribution/modules/routing/index.d.ts +0 -7
  36. package/distribution/modules/routing/logic/general/index.d.ts +0 -6
  37. package/distribution/modules/routing/logic/index.d.ts +0 -3
  38. package/distribution/modules/routing/logic/utilities/index.d.ts +0 -29
  39. package/distribution/modules/routing/logic/validity/index.d.ts +0 -3
  40. package/distribution/modules/space/index.d.ts +0 -6
  41. package/distribution/modules/space/layout/column.d.ts +0 -3
  42. package/distribution/modules/space/layout/faceToFace.d.ts +0 -3
  43. package/distribution/modules/space/layout/index.d.ts +0 -6
  44. package/distribution/modules/space/layout/row.d.ts +0 -3
  45. package/distribution/modules/space/layout/sheaves.d.ts +0 -3
  46. package/distribution/modules/space/layout/zigZag.d.ts +0 -3
  47. package/distribution/modules/space/location/index.d.ts +0 -2
  48. package/distribution/modules/space/location/logic.d.ts +0 -22
  49. package/distribution/modules/space/tree/index.d.ts +0 -3
  50. package/distribution/modules/space/tree/logic.d.ts +0 -32
  51. package/distribution/modules/space/tree/object.d.ts +0 -13
  52. package/distribution/modules/space/utilities/index.d.ts +0 -16
  53. package/distribution/modules/space/view/index.d.ts +0 -2
  54. package/distribution/modules/space/view/logic.d.ts +0 -13
  55. package/distribution/modules/state/compute/index.d.ts +0 -3
  56. package/distribution/modules/state/compute/space/index.d.ts +0 -3
  57. package/distribution/modules/state/compute/themes/index.d.ts +0 -3
  58. package/distribution/modules/state/index.d.ts +0 -3
  59. package/distribution/modules/state/local/index.d.ts +0 -3
  60. package/distribution/modules/utilities/index.d.ts +0 -1
@@ -1,2590 +0,0 @@
1
- import { defaultConfiguration, compareTypes, defaultTreePlane, internationalization, ROOTS_GAP, LAYOUT_TYPES, PLANE_DEFAULT_ANGLE, PLURID_ROUTER_LOCATION_CHANGED } from "@plurid/plurid-data";
2
-
3
- import { objects, uuid, mathematics } from "@plurid/plurid-functions";
4
-
5
- import themes, { THEME_NAMES } from "@plurid/plurid-themes";
6
-
7
- const specifiedOrDefault = (path, type, configuration) => {
8
- const item = objects.getNested(configuration, path);
9
- if (typeof item === type) {
10
- return item;
11
- }
12
- return objects.getNested(defaultConfiguration, path);
13
- };
14
-
15
- const resolveTheme = (theme, type) => {
16
- if (!theme) {
17
- return "plurid";
18
- }
19
- if (typeof theme === "string") {
20
- return theme;
21
- }
22
- if (typeof theme !== "object") {
23
- return "plurid";
24
- }
25
- const {general: general, interaction: interaction} = theme;
26
- if (type === "general" && general) {
27
- return general;
28
- }
29
- if (type === "interaction" && interaction) {
30
- return interaction;
31
- }
32
- return "plurid";
33
- };
34
-
35
- const merge = (configuration, target) => {
36
- var _a, _b, _c, _d, _e;
37
- const targetConfiguration = Object.assign(Object.assign({}, defaultConfiguration), target);
38
- if (!configuration) {
39
- return Object.assign({}, targetConfiguration);
40
- }
41
- const layout = configuration && configuration.space && typeof configuration.space.layout === "object" ? configuration.space.layout : targetConfiguration.space.layout;
42
- const mergedConfiguration = Object.assign(Object.assign({}, targetConfiguration), {
43
- global: {
44
- micro: specifiedOrDefault("global.micro", "boolean", configuration),
45
- transparentUI: specifiedOrDefault("global.transparentUI", "boolean", configuration),
46
- language: specifiedOrDefault("global.language", "string", configuration),
47
- render: specifiedOrDefault("global.render", "string", configuration),
48
- theme: {
49
- general: resolveTheme((_a = configuration.global) === null || _a === void 0 ? void 0 : _a.theme, "general"),
50
- interaction: resolveTheme((_b = configuration.global) === null || _b === void 0 ? void 0 : _b.theme, "interaction")
51
- }
52
- },
53
- elements: Object.assign(Object.assign({}, targetConfiguration.elements), {
54
- toolbar: {
55
- show: specifiedOrDefault("elements.toolbar.show", "boolean", configuration),
56
- opaque: specifiedOrDefault("elements.toolbar.opaque", "boolean", configuration),
57
- conceal: specifiedOrDefault("elements.toolbar.conceal", "boolean", configuration),
58
- transformIcons: specifiedOrDefault("elements.toolbar.transformIcons", "boolean", configuration),
59
- transformButtons: specifiedOrDefault("elements.toolbar.transformButtons", "boolean", configuration),
60
- toggledDrawers: configuration.elements && configuration.elements.toolbar && configuration.elements.toolbar.toggledDrawers ? configuration.elements.toolbar.toggledDrawers : targetConfiguration.elements.toolbar.toggledDrawers
61
- },
62
- viewcube: {
63
- show: specifiedOrDefault("elements.viewcube.show", "boolean", configuration),
64
- opaque: specifiedOrDefault("elements.viewcube.opaque", "boolean", configuration),
65
- conceal: specifiedOrDefault("elements.viewcube.conceal", "boolean", configuration),
66
- buttons: specifiedOrDefault("elements.viewcube.buttons", "boolean", configuration)
67
- },
68
- plane: {
69
- width: specifiedOrDefault("elements.plane.width", "number", configuration),
70
- opacity: specifiedOrDefault("elements.plane.opacity", "number", configuration),
71
- controls: {
72
- show: specifiedOrDefault("elements.plane.controls.show", "boolean", configuration),
73
- pathbar: {
74
- domainURL: specifiedOrDefault("elements.plane.controls.pathbar.domainURL", "boolean", configuration)
75
- }
76
- }
77
- },
78
- switch: {
79
- show: (_e = (_d = (_c = configuration === null || configuration === void 0 ? void 0 : configuration.elements) === null || _c === void 0 ? void 0 : _c.switch) === null || _d === void 0 ? void 0 : _d.show) !== null && _e !== void 0 ? _e : false
80
- }
81
- }),
82
- space: Object.assign(Object.assign({}, targetConfiguration.space), {
83
- layout: layout,
84
- camera: specifiedOrDefault("space.camera", "string", configuration),
85
- perspective: specifiedOrDefault("space.perspective", "number", configuration),
86
- opaque: specifiedOrDefault("space.opaque", "boolean", configuration),
87
- fadeInTime: specifiedOrDefault("space.fadeInTime", "number", configuration),
88
- center: specifiedOrDefault("space.center", "boolean", configuration),
89
- transformOrigin: {
90
- show: specifiedOrDefault("space.transformOrigin.show", "boolean", configuration),
91
- size: specifiedOrDefault("space.transformOrigin.size", "string", configuration)
92
- },
93
- transformLocks: {
94
- rotationX: specifiedOrDefault("space.transformLocks.rotationX", "boolean", configuration),
95
- rotationY: specifiedOrDefault("space.transformLocks.rotationY", "boolean", configuration),
96
- translationX: specifiedOrDefault("space.transformLocks.translationX", "boolean", configuration),
97
- translationY: specifiedOrDefault("space.transformLocks.translationY", "boolean", configuration),
98
- translationZ: specifiedOrDefault("space.transformLocks.translationZ", "boolean", configuration),
99
- scale: specifiedOrDefault("space.transformLocks.scale", "boolean", configuration)
100
- },
101
- transformMode: specifiedOrDefault("space.transformMode", "string", configuration),
102
- transformMultimode: specifiedOrDefault("space.transformMultimode", "boolean", configuration),
103
- transformTouch: specifiedOrDefault("space.transformTouch", "string", configuration),
104
- firstPerson: specifiedOrDefault("space.firstPerson", "boolean", configuration)
105
- }),
106
- network: {
107
- host: specifiedOrDefault("network.host", "string", configuration),
108
- protocol: specifiedOrDefault("network.protocol", "string", configuration)
109
- },
110
- development: {
111
- planeDebugger: specifiedOrDefault("development.planeDebugger", "boolean", configuration),
112
- spaceDebugger: specifiedOrDefault("development.spaceDebugger", "boolean", configuration)
113
- }
114
- });
115
- return mergedConfiguration;
116
- };
117
-
118
- var index$i = Object.freeze({
119
- __proto__: null,
120
- merge: merge
121
- });
122
-
123
- const extractPathname = location => {
124
- const queryIndex = location.indexOf("?");
125
- const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
126
- const fragmentIndex = noQueryPath.indexOf("#:~:");
127
- const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
128
- return noFragmentPath;
129
- };
130
-
131
- const extractParametersAndMatch = (location, route) => {
132
- const routeElements = splitPath(route);
133
- const parameters = [];
134
- routeElements.forEach((routeElement => {
135
- if (routeElement[0] === ":") {
136
- parameters.push(routeElement);
137
- } else {
138
- parameters.push("");
139
- }
140
- }));
141
- const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
142
- if (comparingPath !== route) {
143
- return {
144
- match: false,
145
- parameters: {},
146
- elements: locationElements
147
- };
148
- }
149
- const parametersValues = extractParametersValues(parameters, locationElements);
150
- return {
151
- match: true,
152
- parameters: parametersValues,
153
- elements: locationElements
154
- };
155
- };
156
-
157
- const extractParametersValues = (parameters, pathElements) => {
158
- const parametersValues = {};
159
- parameters.forEach(((parameter, index) => {
160
- if (parameter) {
161
- const parameterKey = parameter.slice(1);
162
- parametersValues[parameterKey] = pathElements[index];
163
- }
164
- }));
165
- return parametersValues;
166
- };
167
-
168
- const computeComparingPath = (path, parameters) => {
169
- const pathname = extractPathname(path);
170
- const locationElements = splitPath(pathname);
171
- const comparingPathElements = [ ...locationElements ];
172
- for (const index of locationElements.keys()) {
173
- if (parameters[index]) {
174
- comparingPathElements[index] = parameters[index];
175
- }
176
- }
177
- const comparingPath = comparingPathElements.join("/");
178
- return {
179
- locationElements: locationElements,
180
- comparingPath: comparingPath
181
- };
182
- };
183
-
184
- const splitPath = path => path.split("/").filter((i => i !== ""));
185
-
186
- const extractQuery = path => {
187
- const fragmentIndex = path.indexOf("#:~:");
188
- const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
189
- const querySplit = noFragmentPath.split("?");
190
- if (querySplit.length === 2) {
191
- const queryValues = {};
192
- const query = querySplit[1];
193
- const queryItems = query.split("&");
194
- for (const item of queryItems) {
195
- const queryValue = item.split("=");
196
- const id = queryValue[0];
197
- const value = decodeURIComponent(queryValue[1]);
198
- queryValues[id] = value;
199
- }
200
- return queryValues;
201
- } else {
202
- return {};
203
- }
204
- };
205
-
206
- const extractFragments = location => {
207
- if (!location) {
208
- return {
209
- texts: [],
210
- elements: []
211
- };
212
- }
213
- const split = location.split("#:~:");
214
- const fragmentsValues = split[1];
215
- if (!fragmentsValues) {
216
- return {
217
- texts: [],
218
- elements: []
219
- };
220
- }
221
- const fragmentItems = fragmentsValues.split("&");
222
- const textFragments = [];
223
- const elementFragments = [];
224
- for (const item of fragmentItems) {
225
- const parsedFragment = parseFragment(item);
226
- if (parsedFragment) {
227
- switch (parsedFragment.type) {
228
- case "text":
229
- textFragments.push(parsedFragment);
230
- break;
231
-
232
- case "element":
233
- elementFragments.push(parsedFragment);
234
- break;
235
- }
236
- }
237
- }
238
- return {
239
- texts: textFragments,
240
- elements: elementFragments
241
- };
242
- };
243
-
244
- const parseFragment = fragment => {
245
- const fragmentData = fragment.split("=");
246
- const fragmentType = fragmentData[0];
247
- const fragmentValues = fragmentData[1];
248
- switch (fragmentType.toLowerCase()) {
249
- case "text":
250
- {
251
- const textValues = fragmentValues.split(",");
252
- const textStart = textValues[0];
253
- const textEnd = textValues[1];
254
- const textOccurence = extractOccurence(textValues[2]);
255
- if (!textStart) {
256
- return;
257
- }
258
- return {
259
- type: "text",
260
- start: textStart,
261
- end: textEnd || "",
262
- occurence: textOccurence
263
- };
264
- }
265
-
266
- case "element":
267
- {
268
- const elementValues = fragmentValues.split(",");
269
- const elementID = elementValues[0];
270
- const elementOccurence = extractOccurence(elementValues[1]);
271
- if (!elementID) {
272
- return;
273
- }
274
- return {
275
- type: "element",
276
- id: elementID,
277
- occurence: elementOccurence
278
- };
279
- }
280
- }
281
- return undefined;
282
- };
283
-
284
- const extractOccurence = occurence => {
285
- if (!occurence) {
286
- return 0;
287
- }
288
- const occurenceMatch = occurence.match(/\[(\d*)\]/);
289
- const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
290
- return occurenceValue;
291
- };
292
-
293
- const stringInsertInitial = (value, insert) => {
294
- if (!value.startsWith(insert)) {
295
- value = insert + value;
296
- }
297
- return value;
298
- };
299
-
300
- const stringRemoveTrailing = (value, trail) => {
301
- if (value.endsWith(trail)) {
302
- value = value.slice(0, value.length - trail.length);
303
- }
304
- return value;
305
- };
306
-
307
- const PATH_SEPARATOR = "/";
308
-
309
- const PTTP_PROTOCOL = "pttp://";
310
-
311
- const cleanupPath = value => {
312
- value = stringInsertInitial(value, PATH_SEPARATOR);
313
- value = stringRemoveTrailing(value, PATH_SEPARATOR);
314
- return value;
315
- };
316
-
317
- const computePlaneAddress = (plane, route, origin = "origin") => {
318
- const cleanPlane = extractPathname(plane);
319
- const planeAddressType = checkPlaneAddressType(cleanPlane);
320
- switch (planeAddressType) {
321
- case "http":
322
- case "https":
323
- case "pttp":
324
- return cleanPlane;
325
- }
326
- origin = stringRemoveTrailing(origin, "/");
327
- const absolutePlane = isAbsolutePlane(plane);
328
- const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
329
- const planeAddress = PTTP_PROTOCOL + origin + path;
330
- return planeAddress;
331
- };
332
-
333
- const isAbsolutePlane = value => value[0] === "/";
334
-
335
- const checkPlaneAddressType = value => {
336
- value = value.toLowerCase().trim();
337
- if (value.startsWith(PTTP_PROTOCOL)) {
338
- return "pttp";
339
- }
340
- if (value.startsWith("https://")) {
341
- return "https";
342
- }
343
- if (value.startsWith("http://")) {
344
- return "http";
345
- }
346
- return "relative";
347
- };
348
-
349
- const checkParameterLength = (parameter, length, compareType) => {
350
- const parameterLength = parameter.length;
351
- switch (compareType) {
352
- case compareTypes.equal:
353
- return parameterLength === length;
354
-
355
- case compareTypes.equalLessThan:
356
- return parameterLength <= length;
357
-
358
- case compareTypes.lessThan:
359
- return parameterLength < length;
360
-
361
- case compareTypes.equalGreaterThan:
362
- return parameterLength >= length;
363
-
364
- case compareTypes.greaterThan:
365
- return parameterLength > length;
366
-
367
- default:
368
- return parameterLength <= length;
369
- }
370
- };
371
-
372
- const checkValidPath = (validationParameters, parameters) => {
373
- if (validationParameters) {
374
- for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
375
- const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
376
- const paramaterValue = parameters[parameterKey];
377
- if (!paramaterValue) {
378
- return false;
379
- }
380
- if (startsWith && !paramaterValue.startsWith(startsWith)) {
381
- return false;
382
- }
383
- if (endsWith && !paramaterValue.endsWith(endsWith)) {
384
- return false;
385
- }
386
- if (includes && !includes.includes(paramaterValue)) {
387
- return false;
388
- }
389
- if (length) {
390
- const validLength = checkParameterLength(paramaterValue, length, lengthType);
391
- return validLength;
392
- }
393
- }
394
- }
395
- return true;
396
- };
397
-
398
- const cleanPathElement = path => {
399
- if (path[0] === "/") {
400
- return path.slice(1);
401
- }
402
- return path;
403
- };
404
-
405
- var index$h = Object.freeze({
406
- __proto__: null,
407
- cleanPathElement: cleanPathElement
408
- });
409
-
410
- const mapPathsToRoutes = (paths, view) => {
411
- const routes = [];
412
- for (const [key, path] of Object.entries(paths)) {
413
- const pathView = view[key];
414
- if (pathView) {
415
- const route = {
416
- value: ""
417
- };
418
- routes.push(route);
419
- }
420
- }
421
- return routes;
422
- };
423
-
424
- const pluridLinkPathDivider = route => {
425
- const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
426
- const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
427
- const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
428
- let protocol = windowProtocol;
429
- const host = {
430
- value: windowHost,
431
- controlled: false
432
- };
433
- const path = {
434
- value: "",
435
- parameters: {},
436
- query: {}
437
- };
438
- const space = {
439
- value: "",
440
- parameters: {},
441
- query: {}
442
- };
443
- const universe = {
444
- value: "",
445
- parameters: {},
446
- query: {}
447
- };
448
- const cluster = {
449
- value: "",
450
- parameters: {},
451
- query: {}
452
- };
453
- const plane = {
454
- value: "",
455
- parameters: {},
456
- query: {},
457
- fragments: {
458
- texts: [],
459
- elements: []
460
- }
461
- };
462
- const valid = false;
463
- if (split.length === 0 || split.length > 7) {
464
- const url = {
465
- protocol: {
466
- value: protocol,
467
- secure: true
468
- },
469
- host: host,
470
- path: path,
471
- space: space,
472
- universe: universe,
473
- cluster: cluster,
474
- plane: plane,
475
- valid: valid
476
- };
477
- return url;
478
- }
479
- if (route.startsWith("/://")) {
480
- const routeSplit = split.slice(1);
481
- switch (routeSplit.length) {
482
- case 1:
483
- path.value = routeSplit[0];
484
- break;
485
-
486
- case 5:
487
- path.value = routeSplit[0];
488
- space.value = routeSplit[1];
489
- universe.value = routeSplit[2];
490
- cluster.value = routeSplit[3];
491
- plane.value = routeSplit[4];
492
- break;
493
- }
494
- const url = {
495
- protocol: {
496
- value: protocol,
497
- secure: true
498
- },
499
- host: host,
500
- path: path,
501
- space: space,
502
- universe: universe,
503
- cluster: cluster,
504
- plane: plane,
505
- valid: true
506
- };
507
- return url;
508
- }
509
- if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
510
- switch (split.length) {
511
- case 1:
512
- plane.value = split[0];
513
- break;
514
-
515
- case 2:
516
- cluster.value = split[0];
517
- plane.value = split[1];
518
- break;
519
-
520
- case 3:
521
- universe.value = split[0];
522
- cluster.value = split[1];
523
- plane.value = split[2];
524
- break;
525
-
526
- case 4:
527
- space.value = split[0];
528
- universe.value = split[1];
529
- cluster.value = split[2];
530
- plane.value = split[3];
531
- break;
532
-
533
- case 5:
534
- path.value = split[0];
535
- space.value = split[1];
536
- universe.value = split[2];
537
- cluster.value = split[3];
538
- plane.value = split[4];
539
- break;
540
-
541
- case 6:
542
- host.value = split[0];
543
- path.value = split[1];
544
- space.value = split[2];
545
- universe.value = split[3];
546
- cluster.value = split[4];
547
- plane.value = split[5];
548
- break;
549
-
550
- default:
551
- const url = {
552
- protocol: {
553
- value: protocol,
554
- secure: true
555
- },
556
- host: host,
557
- path: path,
558
- space: space,
559
- universe: universe,
560
- cluster: cluster,
561
- plane: plane,
562
- valid: valid
563
- };
564
- return url;
565
- }
566
- } else {
567
- switch (split.length) {
568
- case 3:
569
- protocol = split[0];
570
- host.value = split[1];
571
- path.value = split[2];
572
- break;
573
-
574
- case 7:
575
- protocol = split[0];
576
- host.value = split[1];
577
- path.value = split[2];
578
- space.value = split[3];
579
- universe.value = split[4];
580
- cluster.value = split[5];
581
- plane.value = split[6];
582
- break;
583
-
584
- default:
585
- const url = {
586
- protocol: {
587
- value: protocol,
588
- secure: true
589
- },
590
- host: host,
591
- path: path,
592
- space: space,
593
- universe: universe,
594
- cluster: cluster,
595
- plane: plane,
596
- valid: valid
597
- };
598
- return url;
599
- }
600
- }
601
- const url = {
602
- protocol: {
603
- value: protocol,
604
- secure: true
605
- },
606
- host: host,
607
- path: path,
608
- space: space,
609
- universe: universe,
610
- cluster: cluster,
611
- plane: plane,
612
- valid: true
613
- };
614
- return url;
615
- };
616
-
617
- const resolveRoute = (route, protocol, host) => {
618
- const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
619
- const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
620
- const divisions = pluridLinkPathDivider(route);
621
- const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
622
- const protocolDivision = divisions.protocol.value || windowProtocol;
623
- const hostDivision = divisions.host.value ? divisions.host : {
624
- value: windowHost,
625
- controlled: true
626
- };
627
- const path = divisions.path.value ? divisions.path : {
628
- value: defaultPathname,
629
- parameters: {},
630
- query: {}
631
- };
632
- const space = divisions.space.value ? divisions.space : {
633
- value: "s",
634
- parameters: {},
635
- query: {}
636
- };
637
- const universe = divisions.universe.value ? divisions.universe : {
638
- value: "u",
639
- parameters: {},
640
- query: {}
641
- };
642
- const cluster = divisions.cluster.value ? divisions.cluster : {
643
- value: "c",
644
- parameters: {},
645
- query: {}
646
- };
647
- const plane = divisions.plane;
648
- const separator = "://";
649
- if (!plane.value && route !== "/") {
650
- const resolvers = [ protocolDivision, hostDivision.value, path.value ];
651
- const absoluteRoute = resolvers.join(separator);
652
- return {
653
- protocol: protocolDivision,
654
- host: hostDivision,
655
- path: path,
656
- space: space,
657
- universe: universe,
658
- cluster: cluster,
659
- plane: plane,
660
- route: absoluteRoute
661
- };
662
- }
663
- [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
664
- return {
665
- protocol: "",
666
- host: "",
667
- path: path,
668
- space: "",
669
- universe: "",
670
- cluster: "",
671
- plane: "",
672
- route: route
673
- };
674
- };
675
-
676
- const createTreePlane = (contextPlane, documentPlane) => {
677
- const routeDivisions = pluridLinkPathDivider(contextPlane.path);
678
- const treePlane = Object.assign(Object.assign({}, defaultTreePlane), {
679
- routeDivisions: routeDivisions,
680
- sourceID: contextPlane.id,
681
- planeID: uuid.generate(),
682
- route: contextPlane.path,
683
- show: true
684
- });
685
- return treePlane;
686
- };
687
-
688
- const updateTreePlane$1 = (tree, page) => {
689
- const updatedTree = tree.map((treePlane => {
690
- if (treePlane.planeID === page.planeID) {
691
- return Object.assign({}, page);
692
- }
693
- if (treePlane.children) {
694
- return Object.assign(Object.assign({}, treePlane), {
695
- children: updateTreePlane$1(treePlane.children, page)
696
- });
697
- }
698
- return treePlane;
699
- }));
700
- return updatedTree;
701
- };
702
-
703
- const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
704
- const updatedTree = tree.map((treePlane => {
705
- if (treePlane.planeID === planeID) {
706
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
707
- linkCoordinates: linkCoordinates
708
- });
709
- return updatedPlane;
710
- }
711
- if (treePlane.children) {
712
- const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
713
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
714
- children: updatedChildren
715
- });
716
- return updatedPlane;
717
- }
718
- return treePlane;
719
- }));
720
- return updatedTree;
721
- };
722
-
723
- var index$g = Object.freeze({
724
- __proto__: null,
725
- createTreePlane: createTreePlane,
726
- updateTreePlane: updateTreePlane$1,
727
- updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
728
- });
729
-
730
- var index$f = Object.freeze({
731
- __proto__: null,
732
- configuration: index$i,
733
- tree: index$g
734
- });
735
-
736
- const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
737
- let direction = "left";
738
- const wheelDeltaX = deltas.deltaX;
739
- const wheelDeltaY = deltas.deltaY;
740
- const absWheelDeltaX = Math.abs(wheelDeltaX);
741
- const absWheelDeltaY = Math.abs(wheelDeltaY);
742
- if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
743
- direction = "left";
744
- }
745
- if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
746
- direction = "right";
747
- }
748
- if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
749
- direction = "up";
750
- }
751
- if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
752
- direction = "down";
753
- }
754
- return direction;
755
- };
756
-
757
- var index$e = Object.freeze({
758
- __proto__: null,
759
- getWheelDirection: getWheelDirection
760
- });
761
-
762
- const degToRad = deg => deg * .01745329252;
763
-
764
- const radToDeg = rad => rad * 57.2957795131;
765
-
766
- const makeQuaternion = (x, y, z, w) => ({
767
- x: x,
768
- y: y,
769
- z: z,
770
- w: w
771
- });
772
-
773
- const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
774
-
775
- function inverseQuaternion(quaternion) {
776
- return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
777
- }
778
-
779
- function conjugateQuaternion(quaternion) {
780
- return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
781
- }
782
-
783
- function computeQuaternionFromEulers(alpha, beta, gamma) {
784
- const x = beta;
785
- const y = gamma;
786
- const z = alpha;
787
- const cX = Math.cos(x / 2);
788
- const cY = Math.cos(y / 2);
789
- const cZ = Math.cos(z / 2);
790
- const sX = Math.sin(x / 2);
791
- const sY = Math.sin(y / 2);
792
- const sZ = Math.sin(z / 2);
793
- const xQ = sX * cY * cZ - cX * sY * sZ;
794
- const yQ = cX * sY * cZ + sX * cY * sZ;
795
- const zQ = cX * cY * sZ + sX * sY * cZ;
796
- const wQ = cX * cY * cZ - sX * sY * sZ;
797
- return makeQuaternion(xQ, yQ, zQ, wQ);
798
- }
799
-
800
- function quaternionFromAxisAngle(x, y, z, angle) {
801
- const q = zeroQuaternion();
802
- const halfAngle = angle / 2;
803
- q.x = x * Math.sin(halfAngle);
804
- q.y = y * Math.sin(halfAngle);
805
- q.z = z * Math.sin(halfAngle);
806
- q.w = Math.cos(halfAngle);
807
- return q;
808
- }
809
-
810
- function quaternionMultiply(quaternionArray) {
811
- const temporaryQuaternion = quaternionArray[0];
812
- const copyQuaternion = {
813
- x: temporaryQuaternion.x,
814
- y: temporaryQuaternion.y,
815
- z: temporaryQuaternion.z,
816
- w: temporaryQuaternion.w
817
- };
818
- for (let i = 1; i < quaternionArray.length; i++) {
819
- const secondaryTemporaryQuaternion = quaternionArray[i];
820
- const nextQuaternion = {
821
- x: secondaryTemporaryQuaternion.x,
822
- y: secondaryTemporaryQuaternion.y,
823
- z: secondaryTemporaryQuaternion.z,
824
- w: secondaryTemporaryQuaternion.w
825
- };
826
- const w = copyQuaternion.w * nextQuaternion.w - copyQuaternion.x * nextQuaternion.x - copyQuaternion.y * nextQuaternion.y - copyQuaternion.z * nextQuaternion.z;
827
- const x = copyQuaternion.x * nextQuaternion.w + copyQuaternion.w * nextQuaternion.x + copyQuaternion.y * nextQuaternion.z - copyQuaternion.z * nextQuaternion.y;
828
- const y = copyQuaternion.y * nextQuaternion.w + copyQuaternion.w * nextQuaternion.y + copyQuaternion.z * nextQuaternion.x - copyQuaternion.x * nextQuaternion.z;
829
- const z = copyQuaternion.z * nextQuaternion.w + copyQuaternion.w * nextQuaternion.z + copyQuaternion.x * nextQuaternion.y - copyQuaternion.y * nextQuaternion.x;
830
- copyQuaternion.x = x;
831
- copyQuaternion.y = y;
832
- copyQuaternion.z = z;
833
- copyQuaternion.w = w;
834
- }
835
- return copyQuaternion;
836
- }
837
-
838
- function rotatePointViaQuaternion(pointRotate, quaternion) {
839
- const temporaryQuaternion = {
840
- x: pointRotate[0],
841
- y: pointRotate[1],
842
- z: pointRotate[2],
843
- w: 0
844
- };
845
- const rotatedPoint = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
846
- return {
847
- x: rotatedPoint.x,
848
- y: rotatedPoint.y,
849
- z: rotatedPoint.z,
850
- w: rotatedPoint.w
851
- };
852
- }
853
-
854
- function makeRotationMatrixFromQuaternion(quaternion) {
855
- const num = quaternion.x * 2;
856
- const num2 = quaternion.y * 2;
857
- const num3 = quaternion.z * 2;
858
- const num4 = quaternion.x * num;
859
- const num5 = quaternion.y * num2;
860
- const num6 = quaternion.z * num3;
861
- const num7 = quaternion.x * num2;
862
- const num8 = quaternion.x * num3;
863
- const num9 = quaternion.y * num3;
864
- const num10 = quaternion.w * num;
865
- const num11 = quaternion.w * num2;
866
- const num12 = quaternion.w * num3;
867
- return [ 1 - (num5 + num6), num7 - num12, num8 + num11, 0, num7 + num12, 1 - (num4 + num6), num9 - num10, 0, num8 - num11, num9 + num10, 1 - (num4 + num5), 0, 0, 0, 0, 1 ];
868
- }
869
-
870
- var index$d = Object.freeze({
871
- __proto__: null,
872
- degToRad: degToRad,
873
- radToDeg: radToDeg,
874
- makeQuaternion: makeQuaternion,
875
- zeroQuaternion: zeroQuaternion,
876
- inverseQuaternion: inverseQuaternion,
877
- conjugateQuaternion: conjugateQuaternion,
878
- computeQuaternionFromEulers: computeQuaternionFromEulers,
879
- quaternionFromAxisAngle: quaternionFromAxisAngle,
880
- quaternionMultiply: quaternionMultiply,
881
- rotatePointViaQuaternion: rotatePointViaQuaternion,
882
- makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
883
- });
884
-
885
- function rotateMatrix(xAngle, yAngle, zAngle = 0) {
886
- const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
887
- const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
888
- const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
889
- const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
890
- const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
891
- return rotationMatrix;
892
- }
893
-
894
- function translateMatrix(x, y, z) {
895
- return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
896
- }
897
-
898
- function scaleMatrix(s) {
899
- return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
900
- }
901
-
902
- function multiplyMatrices(matrixA, matrixB) {
903
- const result = [];
904
- const a00 = matrixA[0];
905
- const a01 = matrixA[1];
906
- const a02 = matrixA[2];
907
- const a03 = matrixA[3];
908
- const a10 = matrixA[4];
909
- const a11 = matrixA[5];
910
- const a12 = matrixA[6];
911
- const a13 = matrixA[7];
912
- const a20 = matrixA[8];
913
- const a21 = matrixA[9];
914
- const a22 = matrixA[10];
915
- const a23 = matrixA[11];
916
- const a30 = matrixA[12];
917
- const a31 = matrixA[13];
918
- const a32 = matrixA[14];
919
- const a33 = matrixA[15];
920
- let b0 = matrixB[0];
921
- let b1 = matrixB[1];
922
- let b2 = matrixB[2];
923
- let b3 = matrixB[3];
924
- result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
925
- result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
926
- result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
927
- result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
928
- b0 = matrixB[4];
929
- b1 = matrixB[5];
930
- b2 = matrixB[6];
931
- b3 = matrixB[7];
932
- result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
933
- result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
934
- result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
935
- result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
936
- b0 = matrixB[8];
937
- b1 = matrixB[9];
938
- b2 = matrixB[10];
939
- b3 = matrixB[11];
940
- result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
941
- result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
942
- result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
943
- result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
944
- b0 = matrixB[12];
945
- b1 = matrixB[13];
946
- b2 = matrixB[14];
947
- b3 = matrixB[15];
948
- result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
949
- result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
950
- result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
951
- result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
952
- return result;
953
- }
954
-
955
- function multiplyArrayOfMatrices(matrices) {
956
- let inputMatrix = matrices[0];
957
- for (let i = 1; i < matrices.length; i++) {
958
- inputMatrix = multiplyMatrices(inputMatrix, matrices[i]);
959
- }
960
- return inputMatrix;
961
- }
962
-
963
- function matrixArrayToCSSMatrix(array) {
964
- return "matrix3d(" + array.join(",") + ")";
965
- }
966
-
967
- var index$c = Object.freeze({
968
- __proto__: null,
969
- rotateMatrix: rotateMatrix,
970
- translateMatrix: translateMatrix,
971
- scaleMatrix: scaleMatrix,
972
- multiplyMatrices: multiplyMatrices,
973
- multiplyArrayOfMatrices: multiplyArrayOfMatrices,
974
- matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
975
- });
976
-
977
- function getMatrixValues(matrix3d) {
978
- const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
979
- const matrixValuesInt = [];
980
- for (let i = 0; i < matrixValues.length; i++) {
981
- matrixValuesInt[i] = parseFloat(matrixValues[i]);
982
- }
983
- return matrixValuesInt;
984
- }
985
-
986
- function getRotationMatrix(matrix3d) {
987
- const valuesMatrix = getMatrixValues(matrix3d);
988
- const scale = getScalationValue(matrix3d);
989
- if (valuesMatrix.length === 16) {
990
- for (let i = 0; i < 11; i++) {
991
- valuesMatrix[i] /= scale;
992
- }
993
- } else if (valuesMatrix.length === 6) {
994
- for (let i = 0; i < 4; i++) {
995
- valuesMatrix[i] /= scale;
996
- }
997
- }
998
- const rotationMatrix = valuesMatrix;
999
- return rotationMatrix;
1000
- }
1001
-
1002
- function getTranslationMatrix(matrix3d) {
1003
- const valuesMatrix = getMatrixValues(matrix3d);
1004
- let translationMatrix;
1005
- if (valuesMatrix.length === 16) {
1006
- translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
1007
- } else if (valuesMatrix.length === 6) {
1008
- translationMatrix = getMatrixValues(matrix3d).slice(4);
1009
- }
1010
- return translationMatrix;
1011
- }
1012
-
1013
- function getScalationValue(matrix3d) {
1014
- const valuesMatrix = getMatrixValues(matrix3d);
1015
- let temp = 0;
1016
- let scale;
1017
- if (valuesMatrix.length === 16) {
1018
- const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
1019
- scale = 0;
1020
- for (const el of scaleMatrix) {
1021
- scale += parseFloat(el) * parseFloat(el);
1022
- }
1023
- scale = parseFloat(Math.sqrt(scale).toPrecision(4));
1024
- } else if (valuesMatrix.length === 6) {
1025
- temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
1026
- scale = parseFloat(Math.sqrt(temp).toPrecision(4));
1027
- }
1028
- return scale;
1029
- }
1030
-
1031
- function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
1032
- const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
1033
- return matrixArrayToCSSMatrix(transformMatrix);
1034
- }
1035
-
1036
- function getTransformRotate(matrix3d) {
1037
- const pi = Math.PI;
1038
- const values = getRotationMatrix(matrix3d);
1039
- let rotateX = 0;
1040
- let rotateY = 0;
1041
- if (values.length === 6) {
1042
- const cosa = values[0];
1043
- const sina = values[1];
1044
- if (cosa === 1 && sina === 0) {
1045
- rotateX = Math.asin(sina);
1046
- rotateY = Math.acos(cosa);
1047
- }
1048
- }
1049
- if (values.length === 16) {
1050
- const cosaX1 = values[5];
1051
- const sinaX3 = values[9];
1052
- if (sinaX3 <= 0) {
1053
- rotateX = Math.acos(cosaX1);
1054
- }
1055
- if (sinaX3 > 0) {
1056
- rotateX = 2 * pi - Math.acos(cosaX1);
1057
- }
1058
- const cosaY1 = values[0];
1059
- const sinaY2 = values[2];
1060
- if (sinaY2 <= 0) {
1061
- rotateY = Math.acos(cosaY1);
1062
- }
1063
- if (sinaY2 > 0) {
1064
- rotateY = 2 * pi - Math.acos(cosaY1);
1065
- }
1066
- rotateX = Math.atan2(values[9], values[5]);
1067
- rotateY = Math.atan2(values[2], values[0]);
1068
- }
1069
- return {
1070
- rotateX: rotateX,
1071
- rotateY: rotateY,
1072
- rotateZ: 0
1073
- };
1074
- }
1075
-
1076
- function getTransformTranslate(matrix3d) {
1077
- const values = getTranslationMatrix(matrix3d);
1078
- const translateX = values[0];
1079
- const translateY = values[1];
1080
- const translateZ = values[2];
1081
- return {
1082
- translateX: translateX,
1083
- translateY: translateY,
1084
- translateZ: translateZ
1085
- };
1086
- }
1087
-
1088
- function getTransformScale(matrix3d) {
1089
- const scale = getScalationValue(matrix3d);
1090
- return {
1091
- scale: scale
1092
- };
1093
- }
1094
-
1095
- function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
1096
- const transformRotate = getTransformRotate(matrix3d);
1097
- const rotateX = transformRotate.rotateX;
1098
- let rotateY = transformRotate.rotateY;
1099
- const rotateZ = transformRotate.rotateZ;
1100
- const transformTranslate = getTransformTranslate(matrix3d);
1101
- const translateX = transformTranslate.translateX;
1102
- const translateY = transformTranslate.translateY;
1103
- const translateZ = transformTranslate.translateZ;
1104
- const scale = getTransformScale(matrix3d).scale;
1105
- let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1106
- const valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1107
- const valScalationMatrix = scaleMatrix(scale);
1108
- if (direction === "left") {
1109
- rotateY -= angleIncrement;
1110
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1111
- }
1112
- if (direction === "right") {
1113
- rotateY += angleIncrement;
1114
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1115
- }
1116
- if (direction === "up") {
1117
- rotateY -= angleIncrement;
1118
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1119
- }
1120
- if (direction === "down") {
1121
- rotateY += angleIncrement;
1122
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
1123
- }
1124
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1125
- return transformedMatrix3d;
1126
- }
1127
-
1128
- function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
1129
- const transformRotate = getTransformRotate(matrix3d);
1130
- const rotateX = transformRotate.rotateX;
1131
- const rotateY = transformRotate.rotateY;
1132
- const rotateZ = transformRotate.rotateZ;
1133
- const transformTranslate = getTransformTranslate(matrix3d);
1134
- let translateX = transformTranslate.translateX;
1135
- let translateY = transformTranslate.translateY;
1136
- const translateZ = transformTranslate.translateZ;
1137
- const scale = getTransformScale(matrix3d).scale;
1138
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1139
- let valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1140
- const valScalationMatrix = scaleMatrix(scale);
1141
- scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
1142
- if (direction === "left") {
1143
- translateX += linearIncrement;
1144
- valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1145
- }
1146
- if (direction === "right") {
1147
- translateX -= linearIncrement;
1148
- valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1149
- }
1150
- if (direction === "up") {
1151
- translateY += linearIncrement;
1152
- valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1153
- }
1154
- if (direction === "down") {
1155
- translateY -= linearIncrement;
1156
- valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1157
- }
1158
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1159
- return transformedMatrix3d;
1160
- }
1161
-
1162
- function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
1163
- const transformRotate = getTransformRotate(matrix3d);
1164
- const rotateX = transformRotate.rotateX;
1165
- const rotateY = transformRotate.rotateY;
1166
- const rotateZ = transformRotate.rotateZ;
1167
- const transformTranslate = getTransformTranslate(matrix3d);
1168
- const translateX = transformTranslate.translateX;
1169
- const translateY = transformTranslate.translateY;
1170
- const translateZ = transformTranslate.translateZ;
1171
- let scale = getTransformScale(matrix3d).scale;
1172
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1173
- const valTranslationMatrix = translateMatrix(translateX, translateY, translateZ);
1174
- let valScalationMatrix = scaleMatrix(scale);
1175
- if (direction === "up") {
1176
- scale -= scaleIncrement;
1177
- if (scale < .1) {
1178
- scale = .1;
1179
- }
1180
- valScalationMatrix = scaleMatrix(scale);
1181
- }
1182
- if (direction === "down") {
1183
- scale += scaleIncrement;
1184
- if (scale > 4) {
1185
- scale = 4;
1186
- }
1187
- valScalationMatrix = scaleMatrix(scale);
1188
- }
1189
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1190
- return transformedMatrix3d;
1191
- }
1192
-
1193
- var index$b = Object.freeze({
1194
- __proto__: null,
1195
- getMatrixValues: getMatrixValues,
1196
- getRotationMatrix: getRotationMatrix,
1197
- getTranslationMatrix: getTranslationMatrix,
1198
- getScalationValue: getScalationValue,
1199
- setTransform: setTransform,
1200
- getTransformRotate: getTransformRotate,
1201
- getTransformTranslate: getTransformTranslate,
1202
- getTransformScale: getTransformScale,
1203
- rotatePlurid: rotatePlurid,
1204
- translatePlurid: translatePlurid,
1205
- scalePlurid: scalePlurid
1206
- });
1207
-
1208
- var index$a = Object.freeze({
1209
- __proto__: null,
1210
- direction: index$e,
1211
- matrix: index$c,
1212
- quaternion: index$d,
1213
- transform: index$b
1214
- });
1215
-
1216
- const internatiolate = (lamguage, field) => internationalization[lamguage][field];
1217
-
1218
- const resolvePluridPlaneData = plane => {
1219
- if (Array.isArray(plane)) {
1220
- const [route, component, options] = plane;
1221
- return Object.assign({
1222
- route: route,
1223
- component: component
1224
- }, options);
1225
- }
1226
- return plane;
1227
- };
1228
-
1229
- const resolvePluridRoutePlaneData = plane => {
1230
- if (Array.isArray(plane)) {
1231
- const [value, component, options] = plane;
1232
- return Object.assign({
1233
- value: value,
1234
- component: component
1235
- }, options);
1236
- }
1237
- return plane;
1238
- };
1239
-
1240
- const createInternalStatePlane = plane => {
1241
- const planeData = resolvePluridPlaneData(plane);
1242
- const statePlane = {
1243
- id: uuid.generate(),
1244
- path: planeData.route
1245
- };
1246
- return statePlane;
1247
- };
1248
-
1249
- const createInternalContextPlane = plane => {
1250
- const planeData = resolvePluridPlaneData(plane);
1251
- const {route: route, component: component} = planeData;
1252
- const contextPlane = {
1253
- id: uuid.generate(),
1254
- path: route,
1255
- component: component
1256
- };
1257
- return contextPlane;
1258
- };
1259
-
1260
- const getPluridPlaneIDByData = element => {
1261
- if (!element) {
1262
- return "";
1263
- }
1264
- const parent = element.parentElement;
1265
- if (parent && parent.dataset.pluridPlane) {
1266
- return parent.dataset.pluridPlane;
1267
- }
1268
- return getPluridPlaneIDByData(parent);
1269
- };
1270
-
1271
- class IsoMatcher {
1272
- constructor(data, origin = "origin") {
1273
- this.routesIndex = new Map;
1274
- this.planesIndex = new Map;
1275
- this.routesKeys = [];
1276
- this.planesKeys = [];
1277
- this.origin = origin;
1278
- this.updateIndexes(data.routes || [], data.routePlanes || [], data.planes || []);
1279
- }
1280
- match(path, context = "plane") {
1281
- switch (context) {
1282
- case "plane":
1283
- return this.matchPlane(path);
1284
-
1285
- case "route":
1286
- return this.matchRoute(path);
1287
- }
1288
- }
1289
- index(data) {
1290
- this.updateIndexes(data.routes || [], data.routePlanes || [], data.planes || []);
1291
- }
1292
- clear() {
1293
- this.routesIndex = new Map;
1294
- this.planesIndex = new Map;
1295
- this.routesKeys = [];
1296
- this.planesKeys = [];
1297
- }
1298
- getPlanesIndex() {
1299
- return this.planesIndex;
1300
- }
1301
- updateIndexes(routes, routePlanes, planes) {
1302
- this.indexPlanes(planes, "Plane");
1303
- this.indexPlanes(routePlanes, "RoutePlane");
1304
- for (const route of routes) {
1305
- if (route.planes) {
1306
- this.indexPlanes(route.planes, "RoutePlane", route.value);
1307
- }
1308
- this.routesIndex.set(route.value, {
1309
- data: Object.assign({}, route)
1310
- });
1311
- }
1312
- this.routesKeys = Array.from(this.routesIndex.keys());
1313
- this.planesKeys = Array.from(this.planesIndex.keys());
1314
- }
1315
- indexPlanes(planes, kind, parent) {
1316
- for (const plane of planes) {
1317
- const planeData = kind === "Plane" ? resolvePluridPlaneData(plane) : resolvePluridRoutePlaneData(plane);
1318
- const address = computePlaneAddress(kind === "Plane" ? planeData.route : planeData.value, parent, this.origin);
1319
- const indexedPlane = {
1320
- kind: kind,
1321
- data: Object.assign({}, planeData)
1322
- };
1323
- if (parent) {
1324
- indexedPlane["parent"] = parent;
1325
- }
1326
- this.planesIndex.set(address, indexedPlane);
1327
- }
1328
- }
1329
- matchPlane(value) {
1330
- const planeAddress = computePlaneAddress(value, undefined, this.origin);
1331
- const plane = this.planesIndex.get(planeAddress);
1332
- if (plane) {
1333
- const query = extractQuery(value);
1334
- const fragments = extractFragments(value);
1335
- const match = {
1336
- value: planeAddress,
1337
- fragments: fragments,
1338
- query: query,
1339
- parameters: {}
1340
- };
1341
- if (plane.kind === "Plane") {
1342
- const {kind: kind, data: data, parent: parent} = plane;
1343
- const result = {
1344
- kind: kind,
1345
- data: data,
1346
- parent: parent,
1347
- match: match
1348
- };
1349
- return result;
1350
- }
1351
- if (plane.kind === "RoutePlane") {
1352
- const {kind: kind, data: data, parent: parent} = plane;
1353
- const result = {
1354
- kind: kind,
1355
- data: data,
1356
- parent: parent,
1357
- match: match
1358
- };
1359
- return result;
1360
- }
1361
- }
1362
- for (const planePath of this.planesKeys) {
1363
- const normalizedPlanePath = planePath.replace("pttp://", "");
1364
- const normalizedPlaneAddress = planeAddress.replace("pttp://", "");
1365
- const planePathSplit = normalizedPlanePath.split("/");
1366
- const planeAddressSplit = normalizedPlaneAddress.split("/");
1367
- if (planePathSplit[0] !== planeAddressSplit[0]) {
1368
- continue;
1369
- }
1370
- if (planePathSplit.length !== planeAddressSplit.length) {
1371
- continue;
1372
- }
1373
- const parametersAndMatch = extractParametersAndMatch(normalizedPlaneAddress, normalizedPlanePath);
1374
- if (parametersAndMatch.match) {
1375
- const plane = this.planesIndex.get(planePath);
1376
- if (!plane) {
1377
- return;
1378
- }
1379
- const {parameters: parameters} = parametersAndMatch;
1380
- const validPath = checkValidPath(plane.data.parameters, parameters);
1381
- if (!validPath) {
1382
- return;
1383
- }
1384
- const query = extractQuery(value);
1385
- const fragments = extractFragments(value);
1386
- const match = {
1387
- value: planeAddress,
1388
- fragments: fragments,
1389
- query: query,
1390
- parameters: parameters
1391
- };
1392
- if (plane.kind === "Plane") {
1393
- const {kind: kind, data: data, parent: parent} = plane;
1394
- const result = {
1395
- kind: kind,
1396
- data: data,
1397
- parent: parent,
1398
- match: match
1399
- };
1400
- return result;
1401
- }
1402
- if (plane.kind === "RoutePlane") {
1403
- const {kind: kind, data: data, parent: parent} = plane;
1404
- const result = {
1405
- kind: kind,
1406
- data: data,
1407
- parent: parent,
1408
- match: match
1409
- };
1410
- return result;
1411
- }
1412
- }
1413
- }
1414
- return;
1415
- }
1416
- matchRoute(value) {
1417
- const route = this.routesIndex.get(value);
1418
- if (route) {
1419
- const query = extractQuery(value);
1420
- const result = {
1421
- kind: "Route",
1422
- data: route.data,
1423
- match: {
1424
- value: value,
1425
- query: query,
1426
- parameters: {}
1427
- }
1428
- };
1429
- return result;
1430
- }
1431
- for (const routePath of this.routesKeys) {
1432
- const routeSplit = routePath.split("/");
1433
- const valueSplit = value.split("/");
1434
- if (routeSplit.length !== valueSplit.length) {
1435
- continue;
1436
- }
1437
- const parametersAndMatch = extractParametersAndMatch(value.slice(1), routePath.slice(1));
1438
- if (parametersAndMatch.match) {
1439
- const route = this.routesIndex.get(routePath);
1440
- if (!route) {
1441
- return;
1442
- }
1443
- const {parameters: parameters} = parametersAndMatch;
1444
- const validPath = checkValidPath(route.data.parameters, parameters);
1445
- if (!validPath) {
1446
- return;
1447
- }
1448
- const query = extractQuery(value);
1449
- const match = {
1450
- value: value,
1451
- query: query,
1452
- parameters: parameters
1453
- };
1454
- if (route) {
1455
- const result = {
1456
- kind: "Route",
1457
- data: route.data,
1458
- match: match
1459
- };
1460
- return result;
1461
- }
1462
- }
1463
- }
1464
- const routePlane = this.matchPlane(value);
1465
- if (routePlane) {
1466
- const result = {
1467
- kind: "RoutePlane",
1468
- data: routePlane.data,
1469
- match: {
1470
- value: value,
1471
- query: routePlane.match.query,
1472
- parameters: routePlane.match.parameters
1473
- }
1474
- };
1475
- return result;
1476
- }
1477
- return;
1478
- }
1479
- }
1480
-
1481
- class Parser {
1482
- constructor(location, path, options) {
1483
- this.location = location;
1484
- this.path = path;
1485
- this.options = this.handleOptions(options);
1486
- }
1487
- handleOptions(options) {
1488
- const parserOptions = {
1489
- fragment: (options === null || options === void 0 ? void 0 : options.fragment) || true
1490
- };
1491
- return parserOptions;
1492
- }
1493
- extractPathname() {
1494
- const pathname = extractPathname(this.location);
1495
- return pathname;
1496
- }
1497
- extractParametersAndMatch() {
1498
- const parametersAndMatch = extractParametersAndMatch(this.location, this.path.value);
1499
- return parametersAndMatch;
1500
- }
1501
- extractQuery() {
1502
- const query = extractQuery(this.location);
1503
- return query;
1504
- }
1505
- extractFragments() {
1506
- const fragments = this.options.fragment ? extractFragments(this.location) : extractFragments();
1507
- return fragments;
1508
- }
1509
- extract() {
1510
- const pathname = this.extractPathname();
1511
- const {match: match, parameters: parameters, elements: elements} = this.extractParametersAndMatch();
1512
- const query = this.extractQuery();
1513
- const queryData = Object.entries(query).map((([key, value]) => key + "=" + value)).join("&");
1514
- const queryString = queryData ? "?" + queryData : "";
1515
- const fragments = this.extractFragments();
1516
- const parserResponse = {
1517
- path: this.path,
1518
- pathname: pathname,
1519
- elements: elements,
1520
- match: match,
1521
- parameters: parameters,
1522
- query: query,
1523
- fragments: fragments,
1524
- route: pathname + queryString
1525
- };
1526
- return parserResponse;
1527
- }
1528
- }
1529
-
1530
- var index$9 = Object.freeze({
1531
- __proto__: null,
1532
- IsoMatcher: IsoMatcher,
1533
- RouteParser: Parser,
1534
- extractQuery: extractQuery,
1535
- stringInsertInitial: stringInsertInitial,
1536
- stringRemoveTrailing: stringRemoveTrailing,
1537
- cleanupPath: cleanupPath,
1538
- computePlaneAddress: computePlaneAddress,
1539
- isAbsolutePlane: isAbsolutePlane,
1540
- checkPlaneAddressType: checkPlaneAddressType,
1541
- checkParameterLength: checkParameterLength,
1542
- checkValidPath: checkValidPath,
1543
- mapPathsToRoutes: mapPathsToRoutes,
1544
- pluridLinkPathDivider: pluridLinkPathDivider,
1545
- resolveRoute: resolveRoute
1546
- });
1547
-
1548
- class PluridPlanesRegistrar {
1549
- constructor(planes) {
1550
- this.isoMatcher = new IsoMatcher({
1551
- planes: planes
1552
- });
1553
- }
1554
- register(planes) {
1555
- this.isoMatcher.index({
1556
- planes: planes
1557
- });
1558
- }
1559
- identify() {
1560
- const planes = this.isoMatcher.getPlanesIndex();
1561
- return [ ...planes.keys() ];
1562
- }
1563
- get(route) {
1564
- const match = this.isoMatcher.match(route);
1565
- if (match) {
1566
- const absoluteRoute = match.kind === "Plane" ? match.data.route : match.data.value;
1567
- const registeredPlane = {
1568
- route: {
1569
- absolute: absoluteRoute
1570
- },
1571
- component: match.data.component
1572
- };
1573
- return registeredPlane;
1574
- }
1575
- return;
1576
- }
1577
- getAll() {
1578
- const planes = this.isoMatcher.getPlanesIndex();
1579
- const all = new Map;
1580
- for (const [path, plane] of planes) {
1581
- const absoluteRoute = plane.kind === "Plane" ? plane.data.route : plane.data.value;
1582
- const registeredPlane = {
1583
- route: {
1584
- absolute: absoluteRoute
1585
- },
1586
- component: plane.data.component
1587
- };
1588
- all.set(path, registeredPlane);
1589
- }
1590
- return all;
1591
- }
1592
- }
1593
-
1594
- const registerPlanes = (planes, planesRegistrar) => {
1595
- if (!planes) {
1596
- return;
1597
- }
1598
- if (planesRegistrar) {
1599
- planesRegistrar.register(planes);
1600
- return;
1601
- }
1602
- if (typeof window === "undefined") {
1603
- return;
1604
- }
1605
- if (typeof window.__pluridPlanesRegistrar__ === "undefined") {
1606
- const pluridPlanesRegistrar = new PluridPlanesRegistrar;
1607
- window.__pluridPlanesRegistrar__ = pluridPlanesRegistrar;
1608
- window.__pluridPlanesRegistrar__.register(planes);
1609
- return;
1610
- }
1611
- window.__pluridPlanesRegistrar__.register(planes);
1612
- return;
1613
- };
1614
-
1615
- const getPlanesRegistrar = planesRegistrar => {
1616
- if (planesRegistrar) {
1617
- return planesRegistrar;
1618
- }
1619
- if (typeof window !== "undefined") {
1620
- if (window.__pluridPlanesRegistrar__ !== undefined) {
1621
- return window.__pluridPlanesRegistrar__;
1622
- }
1623
- }
1624
- return;
1625
- };
1626
-
1627
- const getRegisteredPlanes = planesRegistrar => {
1628
- if (planesRegistrar) {
1629
- return planesRegistrar.getAll();
1630
- }
1631
- if (typeof window !== "undefined") {
1632
- if (window.__pluridPlanesRegistrar__ !== undefined) {
1633
- return window.__pluridPlanesRegistrar__.getAll();
1634
- }
1635
- }
1636
- return new Map;
1637
- };
1638
-
1639
- const getRegisteredPlane = (route, planesRegistrar) => {
1640
- if (planesRegistrar) {
1641
- return planesRegistrar.get(route);
1642
- }
1643
- if (typeof window !== "undefined") {
1644
- if (window.__pluridPlanesRegistrar__ !== undefined) {
1645
- return window.__pluridPlanesRegistrar__.get(route);
1646
- }
1647
- }
1648
- return;
1649
- };
1650
-
1651
- var index$8 = Object.freeze({
1652
- __proto__: null,
1653
- resolvePluridPlaneData: resolvePluridPlaneData,
1654
- resolvePluridRoutePlaneData: resolvePluridRoutePlaneData,
1655
- createInternalStatePlane: createInternalStatePlane,
1656
- createInternalContextPlane: createInternalContextPlane,
1657
- getPluridPlaneIDByData: getPluridPlaneIDByData,
1658
- registerPlanes: registerPlanes,
1659
- getPlanesRegistrar: getPlanesRegistrar,
1660
- getRegisteredPlanes: getRegisteredPlanes,
1661
- getRegisteredPlane: getRegisteredPlane,
1662
- Registrar: PluridPlanesRegistrar
1663
- });
1664
-
1665
- const computeSpaceSize = tree => {
1666
- let width = 0;
1667
- let height = 0;
1668
- let depth = 0;
1669
- const topCorner = {
1670
- x: 0,
1671
- y: 0,
1672
- z: 0
1673
- };
1674
- tree.map((treePage => {
1675
- const spaceWidth = treePage.location.translateX + treePage.width;
1676
- if (spaceWidth > width) {
1677
- width = spaceWidth;
1678
- }
1679
- const spaceHeight = treePage.location.translateY + treePage.height;
1680
- if (spaceHeight > height) {
1681
- height = spaceHeight;
1682
- }
1683
- const spaceDepth = treePage.location.translateZ;
1684
- if (spaceDepth > depth) {
1685
- depth = spaceDepth;
1686
- }
1687
- }));
1688
- return {
1689
- width: width,
1690
- height: height,
1691
- depth: depth,
1692
- topCorner: topCorner
1693
- };
1694
- };
1695
-
1696
- const findPage = (view, pages) => {
1697
- for (const page of pages) {
1698
- if (page.route === view) {
1699
- return page;
1700
- }
1701
- }
1702
- return;
1703
- };
1704
-
1705
- const splitIntoGroups = (data, length) => {
1706
- const initialArray = [ ...data ];
1707
- const groups = [];
1708
- while (initialArray.length) {
1709
- const group = initialArray.splice(0, length);
1710
- groups.push(group);
1711
- }
1712
- return groups;
1713
- };
1714
-
1715
- const getTreePlaneByPlaneID = (tree, planeID) => {
1716
- let _page = null;
1717
- for (const page of tree) {
1718
- if (page.planeID === planeID) {
1719
- _page = page;
1720
- }
1721
- if (page.children && !_page) {
1722
- _page = getTreePlaneByPlaneID(page.children, planeID);
1723
- }
1724
- if (_page) {
1725
- break;
1726
- }
1727
- }
1728
- return _page;
1729
- };
1730
-
1731
- var index$7 = Object.freeze({
1732
- __proto__: null,
1733
- computeSpaceSize: computeSpaceSize,
1734
- findPage: findPage,
1735
- splitIntoGroups: splitIntoGroups,
1736
- getTreePlaneByPlaneID: getTreePlaneByPlaneID
1737
- });
1738
-
1739
- const toRadians$1 = mathematics.geometry.toRadians;
1740
-
1741
- const computePath = (tree, planeID) => {
1742
- const path = [];
1743
- const page = getTreePlaneByPlaneID(tree, planeID);
1744
- if (page) {
1745
- path.push(Object.assign({}, page));
1746
- let parentID = page.parentPlaneID;
1747
- if (!parentID) {
1748
- return path;
1749
- }
1750
- while (parentID) {
1751
- const parentPage = getTreePlaneByPlaneID(tree, parentID);
1752
- if (parentPage) {
1753
- const page = Object.assign({}, parentPage);
1754
- page.children = [];
1755
- path.push(page);
1756
- parentID = parentPage.parentPlaneID;
1757
- }
1758
- }
1759
- }
1760
- return path.reverse();
1761
- };
1762
-
1763
- const computePluridPlaneLocation = (linkCoordinates, treePageParent, bridgeLength = 100, linkPlaneAngle = 90) => {
1764
- const parentAngleRadians = toRadians$1(treePageParent.location.rotateY);
1765
- const linkPoint = {
1766
- x: treePageParent.location.translateX + linkCoordinates.x * Math.cos(parentAngleRadians),
1767
- z: treePageParent.location.translateZ - linkCoordinates.x * Math.sin(parentAngleRadians)
1768
- };
1769
- const linkAngleRadians = toRadians$1(linkPlaneAngle + treePageParent.location.rotateY);
1770
- const x = linkPoint.x + bridgeLength * Math.cos(linkAngleRadians);
1771
- const z = linkPoint.z - bridgeLength * Math.sin(linkAngleRadians);
1772
- const y = treePageParent.location.translateY + linkCoordinates.y;
1773
- const locationCoordinates = {
1774
- x: x,
1775
- y: y,
1776
- z: z
1777
- };
1778
- return locationCoordinates;
1779
- };
1780
-
1781
- const recomputeChildrenLocation = page => {
1782
- if (!page.children) {
1783
- return [];
1784
- }
1785
- const updatedChildren = [];
1786
- for (const child of page.children) {
1787
- if (child.linkCoordinates) {
1788
- const location = computePluridPlaneLocation(child.linkCoordinates, page, child.bridgeLength, child.planeAngle);
1789
- const updatedChild = Object.assign(Object.assign({}, child), {
1790
- location: Object.assign(Object.assign({}, child.location), {
1791
- translateX: location.x,
1792
- translateY: location.y,
1793
- translateZ: location.z
1794
- })
1795
- });
1796
- const children = updatedChild.children ? recomputeChildrenLocation(updatedChild) : [];
1797
- const updatedChildWithChildren = Object.assign(Object.assign({}, updatedChild), {
1798
- children: children
1799
- });
1800
- updatedChildren.push(updatedChildWithChildren);
1801
- }
1802
- }
1803
- return updatedChildren;
1804
- };
1805
-
1806
- var index$6 = Object.freeze({
1807
- __proto__: null,
1808
- computePath: computePath,
1809
- computePluridPlaneLocation: computePluridPlaneLocation,
1810
- recomputeChildrenLocation: recomputeChildrenLocation
1811
- });
1812
-
1813
- const computeColumnLayout = (roots, columns = 1, columnLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
1814
- const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
1815
- const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
1816
- const tree = [];
1817
- const configurationWidth = configuration.elements.plane.width;
1818
- const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
1819
- const height = windowInnerHeight;
1820
- const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
1821
- const length = columnLength || Math.ceil(roots.length / columns);
1822
- for (const [index, root] of roots.entries()) {
1823
- const rowIndex = index % length;
1824
- const columnIndex = Math.floor(index / length);
1825
- const translateX = columnIndex * (width + gapValue);
1826
- const translateY = rowIndex * (height + gapValue);
1827
- const treePage = Object.assign(Object.assign({}, root), {
1828
- location: {
1829
- translateX: translateX,
1830
- translateY: translateY,
1831
- translateZ: 0,
1832
- rotateX: 0,
1833
- rotateY: 0
1834
- }
1835
- });
1836
- const children = recomputeChildrenLocation(treePage);
1837
- const treePageWithChildren = Object.assign(Object.assign({}, treePage), {
1838
- children: children
1839
- });
1840
- tree.push(treePageWithChildren);
1841
- }
1842
- return tree;
1843
- };
1844
-
1845
- const computeRowLayout = (roots, rows = 1, rowLength, gap = ROOTS_GAP, configuration = defaultConfiguration) => {
1846
- const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
1847
- const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
1848
- const tree = [];
1849
- const configurationWidth = configuration.elements.plane.width;
1850
- const width = mathematics.numbers.checkIntegerNonUnit(configurationWidth) ? configurationWidth : configurationWidth * windowInnerWidth;
1851
- const height = windowInnerHeight;
1852
- const gapValue = mathematics.numbers.checkIntegerNonUnit(gap) ? gap : gap * width;
1853
- const length = rowLength || Math.ceil(roots.length / rows);
1854
- for (const [index, root] of roots.entries()) {
1855
- const rowIndex = Math.floor(index / length);
1856
- const columnIndex = index % length;
1857
- const translateX = columnIndex * (width + gapValue);
1858
- const translateY = rowIndex * (height + gapValue);
1859
- const treePage = Object.assign(Object.assign({}, root), {
1860
- location: {
1861
- translateX: translateX,
1862
- translateY: translateY,
1863
- translateZ: 0,
1864
- rotateX: 0,
1865
- rotateY: 0
1866
- }
1867
- });
1868
- const children = recomputeChildrenLocation(treePage);
1869
- const treePageWithChildren = Object.assign(Object.assign({}, treePage), {
1870
- children: children
1871
- });
1872
- tree.push(treePageWithChildren);
1873
- }
1874
- return tree;
1875
- };
1876
-
1877
- const toRadians = mathematics.geometry.toRadians;
1878
-
1879
- const computeFaceToFaceTranslateZ = (width, angle, first) => {
1880
- if (first) {
1881
- return width * Math.sin(toRadians(angle));
1882
- }
1883
- return 0;
1884
- };
1885
-
1886
- const computeFaceToFaceTranslateX = (width, angle, gap, first, index) => {
1887
- const firstTranslateX = width * Math.cos(toRadians(angle));
1888
- if (first) {
1889
- return firstTranslateX;
1890
- }
1891
- const value = width * (index - 1) + 2 * firstTranslateX + gap * index;
1892
- return value;
1893
- };
1894
-
1895
- const computeFaceToFaceRotateY = (angle, first, last) => {
1896
- const rotateY = first ? angle : last ? -angle : 0;
1897
- return rotateY;
1898
- };
1899
-
1900
- const computeFaceToFaceLayout = (roots, angle = 45, gap = 0, middle = 0, configuration = defaultConfiguration) => {
1901
- const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
1902
- const windowInnerHeight = typeof window === "undefined" ? 840 : window.innerHeight;
1903
- const tree = [];
1904
- const width = mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
1905
- const height = windowInnerHeight;
1906
- const planeAngle = 90 - angle / 2;
1907
- const columns = 2 + middle;
1908
- const rows = splitIntoGroups(roots, columns);
1909
- const gapValue = Number.isInteger(gap) ? gap : gap * width;
1910
- for (const [index, row] of rows.entries()) {
1911
- const translateY = index * height;
1912
- for (const [index, page] of row.entries()) {
1913
- const first = index === 0;
1914
- const last = index === columns - 1;
1915
- const translateZ = computeFaceToFaceTranslateZ(width, planeAngle, first);
1916
- const translateX = computeFaceToFaceTranslateX(width, planeAngle, gapValue, first, index);
1917
- const rotateY = computeFaceToFaceRotateY(planeAngle, first, last);
1918
- const treePage = Object.assign(Object.assign({}, page), {
1919
- location: {
1920
- translateX: translateX,
1921
- translateY: translateY,
1922
- translateZ: translateZ,
1923
- rotateX: 0,
1924
- rotateY: rotateY
1925
- }
1926
- });
1927
- const children = recomputeChildrenLocation(treePage);
1928
- const treePageWithChildren = Object.assign(Object.assign({}, treePage), {
1929
- children: children
1930
- });
1931
- tree.push(treePageWithChildren);
1932
- }
1933
- }
1934
- return tree;
1935
- };
1936
-
1937
- const computeSheavesLayout = (roots, depth = .3, offsetX = 0, offsetY = 0, configuration = defaultConfiguration) => {
1938
- const windowInnerWidth = typeof window === "undefined" ? 1440 : window.innerWidth;
1939
- const tree = [];
1940
- mathematics.numbers.checkIntegerNonUnit(configuration.elements.plane.width) ? configuration.elements.plane.width : configuration.elements.plane.width * windowInnerWidth;
1941
- for (const [index, page] of roots.entries()) {
1942
- const translateX = 0;
1943
- const translateY = 0;
1944
- const treePage = Object.assign(Object.assign({}, page), {
1945
- location: {
1946
- translateX: translateX,
1947
- translateY: translateY,
1948
- translateZ: 0,
1949
- rotateX: 0,
1950
- rotateY: 0
1951
- }
1952
- });
1953
- const children = recomputeChildrenLocation(treePage);
1954
- const treePageWithChildren = Object.assign(Object.assign({}, treePage), {
1955
- children: children
1956
- });
1957
- tree.push(treePageWithChildren);
1958
- }
1959
- return tree;
1960
- };
1961
-
1962
- const computeZigZagLayout = (pages, angle = 45, configuration = defaultConfiguration) => {
1963
- const tree = [];
1964
- const singleColumnedRoots = computeColumnLayout(pages, 1);
1965
- for (const [index, page] of singleColumnedRoots.entries()) {
1966
- const value = index % 2 === 0 ? 1 : -1;
1967
- page.location.rotateY = value * angle;
1968
- const children = recomputeChildrenLocation(page);
1969
- const treePageWithChildren = Object.assign(Object.assign({}, page), {
1970
- children: children
1971
- });
1972
- tree.push(Object.assign({}, treePageWithChildren));
1973
- }
1974
- return tree;
1975
- };
1976
-
1977
- var index$5 = Object.freeze({
1978
- __proto__: null,
1979
- computeColumnLayout: computeColumnLayout,
1980
- computeRowLayout: computeRowLayout,
1981
- computeFaceToFaceLayout: computeFaceToFaceLayout,
1982
- computeSheavesLayout: computeSheavesLayout,
1983
- computeZigZagLayout: computeZigZagLayout
1984
- });
1985
-
1986
- const resolveViewItem = (planes, view, configuration) => {
1987
- const {protocol: protocol, host: host} = configuration.network;
1988
- const viewData = typeof view === "string" ? view : view.plane;
1989
- const viewAddress = computePlaneAddress(viewData);
1990
- const iPlanes = planes.values();
1991
- const pluridPlanes = [];
1992
- for (const iPlane of iPlanes) {
1993
- const plane = {
1994
- route: iPlane.route.absolute,
1995
- component: iPlane.component
1996
- };
1997
- pluridPlanes.push(plane);
1998
- }
1999
- const isoMatcher = new IsoMatcher({
2000
- planes: pluridPlanes
2001
- });
2002
- const match = isoMatcher.match(viewData);
2003
- if (match) {
2004
- const route = match.match.value;
2005
- const treePlane = {
2006
- sourceID: route,
2007
- planeID: uuid.generate(),
2008
- route: viewAddress,
2009
- routeDivisions: {
2010
- protocol: {
2011
- value: "",
2012
- secure: false
2013
- },
2014
- host: {
2015
- value: host,
2016
- controlled: true
2017
- },
2018
- path: {
2019
- parameters: {},
2020
- query: {},
2021
- value: ""
2022
- },
2023
- space: {
2024
- parameters: {},
2025
- query: {},
2026
- value: ""
2027
- },
2028
- universe: {
2029
- parameters: {},
2030
- query: {},
2031
- value: ""
2032
- },
2033
- cluster: {
2034
- parameters: {},
2035
- query: {},
2036
- value: ""
2037
- },
2038
- plane: {
2039
- parameters: {},
2040
- fragments: {
2041
- elements: [],
2042
- texts: []
2043
- },
2044
- query: {},
2045
- value: ""
2046
- },
2047
- valid: true
2048
- },
2049
- height: 0,
2050
- width: 0,
2051
- location: {
2052
- translateX: 0,
2053
- translateY: 0,
2054
- translateZ: 0,
2055
- rotateX: 0,
2056
- rotateY: 0
2057
- },
2058
- show: true
2059
- };
2060
- return treePlane;
2061
- }
2062
- return;
2063
- };
2064
-
2065
- const computeSpaceTree = (planes, view, configuration) => {
2066
- const treePlanes = [];
2067
- for (const viewItem of view) {
2068
- const treePlane = resolveViewItem(planes, viewItem, configuration);
2069
- if (treePlane) {
2070
- treePlanes.push(treePlane);
2071
- }
2072
- }
2073
- switch (configuration.space.layout.type) {
2074
- case LAYOUT_TYPES.COLUMNS:
2075
- {
2076
- const {columns: columns, columnLength: columnLength, gap: gap} = configuration.space.layout;
2077
- const columnLayoutTree = computeColumnLayout(treePlanes, columns, columnLength, gap, configuration);
2078
- return columnLayoutTree;
2079
- }
2080
-
2081
- case LAYOUT_TYPES.ROWS:
2082
- {
2083
- const {rows: rows, rowLength: rowLength, gap: gap} = configuration.space.layout;
2084
- const rowLayoutTree = computeRowLayout(treePlanes, rows, rowLength, gap, configuration);
2085
- return rowLayoutTree;
2086
- }
2087
-
2088
- case LAYOUT_TYPES.ZIG_ZAG:
2089
- {
2090
- const {angle: angle} = configuration.space.layout;
2091
- const zigzagLayoutTree = computeZigZagLayout(treePlanes, angle, configuration);
2092
- return zigzagLayoutTree;
2093
- }
2094
-
2095
- case LAYOUT_TYPES.FACE_TO_FACE:
2096
- {
2097
- const {angle: angle, gap: gap, middle: middle} = configuration.space.layout;
2098
- const faceToFaceLayoutTree = computeFaceToFaceLayout(treePlanes, angle, gap, middle, configuration);
2099
- return faceToFaceLayoutTree;
2100
- }
2101
-
2102
- case LAYOUT_TYPES.SHEAVES:
2103
- {
2104
- const {depth: depth, offsetX: offsetX, offsetY: offsetY} = configuration.space.layout;
2105
- const sheavesLayoutTree = computeSheavesLayout(treePlanes, depth, offsetX, offsetY, configuration);
2106
- return sheavesLayoutTree;
2107
- }
2108
-
2109
- case LAYOUT_TYPES.META:
2110
- {
2111
- return [];
2112
- }
2113
-
2114
- default:
2115
- return [];
2116
- }
2117
- };
2118
-
2119
- const isParametric = (viewRoute, planeRoute) => true;
2120
-
2121
- const matchForParameters = (viewRoute, planeRoute) => {
2122
- const splitViewRoute = viewRoute.split("://");
2123
- const splitPlaneRoute = planeRoute.split("://");
2124
- splitViewRoute[2];
2125
- splitPlaneRoute[2];
2126
- };
2127
-
2128
- const assignPagesFromView = (planes, view) => {
2129
- if (!view) {
2130
- return planes;
2131
- }
2132
- const tree = [];
2133
- for (const viewPlane of view) {
2134
- if (typeof viewPlane === "string") {
2135
- for (const plane of planes) {
2136
- if (viewPlane === plane.sourceID) {
2137
- tree.push(plane);
2138
- }
2139
- if (isParametric(viewPlane, plane.sourceID)) {
2140
- const parametricPlane = Object.assign({}, plane);
2141
- parametricPlane.routeDivisions.plane.parameters.id = "one";
2142
- parametricPlane.routeDivisions.plane.value = "one";
2143
- parametricPlane.route = viewPlane;
2144
- tree.push(parametricPlane);
2145
- }
2146
- }
2147
- }
2148
- }
2149
- return tree;
2150
- };
2151
-
2152
- const updateTreePlane = (tree, updatedPage) => {
2153
- const updatedTree = tree.map((page => {
2154
- if (page.planeID === updatedPage.planeID) {
2155
- return updatedPage;
2156
- }
2157
- if (page.children) {
2158
- const pageTree = updateTreePlane(page.children, updatedPage);
2159
- page.children = pageTree;
2160
- return page;
2161
- }
2162
- return page;
2163
- }));
2164
- return updatedTree;
2165
- };
2166
-
2167
- const updateTreeWithNewPlane = (planeRoute, parentPlaneID, linkCoordinates, tree, planesRegistry, configuration) => {
2168
- const parentPlane = getTreePlaneByPlaneID(tree, parentPlaneID);
2169
- if (!parentPlane) {
2170
- return {
2171
- pluridPlaneID: "",
2172
- updatedTree: tree
2173
- };
2174
- }
2175
- const location = computePluridPlaneLocation(linkCoordinates, parentPlane);
2176
- const treePlane = resolveViewItem(planesRegistry, planeRoute, configuration);
2177
- if (!treePlane) {
2178
- return {
2179
- pluridPlaneID: "",
2180
- updatedTree: tree
2181
- };
2182
- }
2183
- const updatedTreePlane = Object.assign(Object.assign({}, treePlane), {
2184
- parentPlaneID: parentPlaneID,
2185
- location: {
2186
- translateX: location.x,
2187
- translateY: location.y,
2188
- translateZ: location.z,
2189
- rotateX: 0,
2190
- rotateY: parentPlane.location.rotateY + PLANE_DEFAULT_ANGLE
2191
- },
2192
- bridgeLength: 100,
2193
- planeAngle: 90,
2194
- linkCoordinates: linkCoordinates
2195
- });
2196
- const updatedParentPlane = Object.assign({}, parentPlane);
2197
- if (updatedParentPlane.children) {
2198
- updatedParentPlane.children.push(updatedTreePlane);
2199
- } else {
2200
- updatedParentPlane.children = [ updatedTreePlane ];
2201
- }
2202
- const updatedTree = updateTreePlane(tree, updatedParentPlane);
2203
- return {
2204
- pluridPlaneID: updatedTreePlane.planeID,
2205
- updatedTree: updatedTree
2206
- };
2207
- };
2208
-
2209
- const updateTreeWithNewPage = (tree, treePageParentPlaneID, pagePath, pageID, linkCoordinates, parameters) => {
2210
- const treePageParent = getTreePlaneByPlaneID(tree, treePageParentPlaneID);
2211
- if (treePageParent) {
2212
- const location = computePluridPlaneLocation(linkCoordinates, treePageParent);
2213
- const planeID = uuid.generate();
2214
- const newTreePlane = {
2215
- sourceID: pageID,
2216
- route: pagePath,
2217
- routeDivisions: {
2218
- protocol: {
2219
- value: "",
2220
- secure: false
2221
- },
2222
- host: {
2223
- value: "",
2224
- controlled: false
2225
- },
2226
- path: {
2227
- value: "",
2228
- parameters: {},
2229
- query: {}
2230
- },
2231
- space: {
2232
- value: "",
2233
- parameters: {},
2234
- query: {}
2235
- },
2236
- universe: {
2237
- value: "",
2238
- parameters: {},
2239
- query: {}
2240
- },
2241
- cluster: {
2242
- value: "",
2243
- parameters: {},
2244
- query: {}
2245
- },
2246
- plane: {
2247
- value: "",
2248
- parameters: {},
2249
- query: {},
2250
- fragments: {
2251
- texts: [],
2252
- elements: []
2253
- }
2254
- },
2255
- valid: false
2256
- },
2257
- planeID: planeID,
2258
- width: 0,
2259
- height: 0,
2260
- parentPlaneID: treePageParentPlaneID,
2261
- location: {
2262
- translateX: location.x,
2263
- translateY: location.y,
2264
- translateZ: location.z,
2265
- rotateX: 0,
2266
- rotateY: treePageParent.location.rotateY + PLANE_DEFAULT_ANGLE
2267
- },
2268
- show: true,
2269
- bridgeLength: 100,
2270
- planeAngle: 90,
2271
- linkCoordinates: linkCoordinates
2272
- };
2273
- const updatedTreePlaneParent = Object.assign({}, treePageParent);
2274
- if (updatedTreePlaneParent.children) {
2275
- updatedTreePlaneParent.children.push(newTreePlane);
2276
- } else {
2277
- updatedTreePlaneParent.children = [ newTreePlane ];
2278
- }
2279
- const updatedTree = updateTreePlane(tree, updatedTreePlaneParent);
2280
- return {
2281
- pluridPlaneID: planeID,
2282
- updatedTree: updatedTree
2283
- };
2284
- }
2285
- return {
2286
- pluridPlaneID: "",
2287
- updatedTree: tree
2288
- };
2289
- };
2290
-
2291
- const removePageFromTree = (tree, pluridPlaneID) => {
2292
- const updatedTree = tree.filter((page => {
2293
- if (page.planeID === pluridPlaneID) {
2294
- return false;
2295
- }
2296
- if (page.children) {
2297
- const pageTree = removePageFromTree(page.children, pluridPlaneID);
2298
- page.children = pageTree;
2299
- return page;
2300
- }
2301
- return page;
2302
- }));
2303
- return updatedTree;
2304
- };
2305
-
2306
- const toggleChildren = children => {
2307
- const updatedChildren = children.map((child => {
2308
- if (child.children) {
2309
- const updatedChild = Object.assign(Object.assign({}, child), {
2310
- show: !child.show,
2311
- children: toggleChildren(child.children)
2312
- });
2313
- return updatedChild;
2314
- }
2315
- const updatedChild = Object.assign(Object.assign({}, child), {
2316
- show: !child.show
2317
- });
2318
- return updatedChild;
2319
- }));
2320
- return updatedChildren;
2321
- };
2322
-
2323
- const togglePlaneFromTree = (tree, pluridPlaneID) => {
2324
- const updatedTree = [];
2325
- for (const page of tree) {
2326
- if (page.planeID === pluridPlaneID) {
2327
- const updatedPage = Object.assign(Object.assign({}, page), {
2328
- show: !page.show,
2329
- children: []
2330
- });
2331
- updatedTree.push(updatedPage);
2332
- continue;
2333
- }
2334
- if (page.children) {
2335
- const pageTree = togglePlaneFromTree(page.children, pluridPlaneID);
2336
- page.children = [ ...pageTree ];
2337
- updatedTree.push(page);
2338
- continue;
2339
- }
2340
- updatedTree.push(page);
2341
- }
2342
- return updatedTree;
2343
- };
2344
-
2345
- var logic = Object.freeze({
2346
- __proto__: null,
2347
- resolveViewItem: resolveViewItem,
2348
- computeSpaceTree: computeSpaceTree,
2349
- isParametric: isParametric,
2350
- matchForParameters: matchForParameters,
2351
- assignPagesFromView: assignPagesFromView,
2352
- updateTreePlane: updateTreePlane,
2353
- updateTreeWithNewPlane: updateTreeWithNewPlane,
2354
- updateTreeWithNewPage: updateTreeWithNewPage,
2355
- removePageFromTree: removePageFromTree,
2356
- toggleChildren: toggleChildren,
2357
- togglePlaneFromTree: togglePlaneFromTree
2358
- });
2359
-
2360
- class Tree {
2361
- constructor(data) {
2362
- this.data = data;
2363
- }
2364
- compute() {
2365
- const {planes: planes, view: view, configuration: configuration} = this.data;
2366
- return computeSpaceTree(planes, view, configuration);
2367
- }
2368
- }
2369
-
2370
- var index$4 = Object.freeze({
2371
- __proto__: null,
2372
- Tree: Tree,
2373
- logic: logic
2374
- });
2375
-
2376
- const computeViewTree = (pages, view) => {
2377
- const viewTree = [];
2378
- for (const pageView of view) {
2379
- const page = pages.find((p => p.route === pageView));
2380
- if (page) {
2381
- viewTree.push(page);
2382
- }
2383
- }
2384
- return viewTree;
2385
- };
2386
-
2387
- const computeCulledView = (pages, view, location, radius = 8e3) => {
2388
- const culledView = [];
2389
- for (const viewPage of view) {
2390
- const path = typeof viewPage === "string" ? viewPage : viewPage.plane;
2391
- const page = findPage(path, pages);
2392
- if (!page) {
2393
- return;
2394
- }
2395
- const pageInView = checkPageInView(page, location, radius);
2396
- if (pageInView) {
2397
- culledView.push(page.route);
2398
- }
2399
- }
2400
- return culledView;
2401
- };
2402
-
2403
- const checkPageInView = (page, location, radius) => {
2404
- const radiusLeft = location.translationX < 0 ? Math.abs(location.translationX) - radius : -1 * location.translationX - radius;
2405
- const radiusRight = location.translationX < 0 ? Math.abs(location.translationX) + radius : -1 * location.translationX + radius;
2406
- const locationX = page.location.translateX;
2407
- const radiusTop = location.translationY < 0 ? Math.abs(location.translationY) - radius : -1 * location.translationY - radius;
2408
- const radiusBottom = location.translationY < 0 ? Math.abs(location.translationY) + radius : -1 * location.translationY + radius;
2409
- const locationY = page.location.translateY;
2410
- const inViewOnX = radiusLeft <= locationX && locationX <= radiusRight;
2411
- const inViewOnY = radiusTop <= locationY && locationY <= radiusBottom;
2412
- if (inViewOnX && inViewOnY) {
2413
- return true;
2414
- }
2415
- return false;
2416
- };
2417
-
2418
- var index$3 = Object.freeze({
2419
- __proto__: null,
2420
- computeViewTree: computeViewTree,
2421
- computeCulledView: computeCulledView,
2422
- checkPageInView: checkPageInView
2423
- });
2424
-
2425
- var index$2 = Object.freeze({
2426
- __proto__: null,
2427
- layout: index$5,
2428
- location: index$6,
2429
- tree: index$4,
2430
- utilities: index$7,
2431
- view: index$3
2432
- });
2433
-
2434
- const resolveSpace = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState) => {
2435
- const registeredPlanes = getRegisteredPlanes(planesRegistrar);
2436
- const spaceTree = new Tree({
2437
- planes: registeredPlanes,
2438
- configuration: configuration,
2439
- view: view
2440
- });
2441
- const computedTree = spaceTree.compute();
2442
- const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2443
- loading: true,
2444
- animatedTransform: false,
2445
- transformTime: 450,
2446
- scale: 1,
2447
- rotationX: 0,
2448
- rotationY: 0,
2449
- translationX: 0,
2450
- translationY: 0,
2451
- translationZ: 0,
2452
- activeUniverseID: "",
2453
- camera: {
2454
- x: 0,
2455
- y: 0,
2456
- z: 0
2457
- },
2458
- viewSize: {
2459
- width: 771,
2460
- height: 764
2461
- },
2462
- spaceSize: {
2463
- width: 771,
2464
- height: 764,
2465
- depth: 0,
2466
- topCorner: {
2467
- x: 0,
2468
- y: 0,
2469
- z: 0
2470
- }
2471
- },
2472
- culledView: []
2473
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.space), contextState === null || contextState === void 0 ? void 0 : contextState.space), localState === null || localState === void 0 ? void 0 : localState.space), currentState === null || currentState === void 0 ? void 0 : currentState.space), {
2474
- view: view,
2475
- initialTree: computedTree,
2476
- tree: computedTree
2477
- });
2478
- if (currentState) {
2479
- stateSpace.translationX = currentState.space.translationX;
2480
- stateSpace.translationY = currentState.space.translationY;
2481
- stateSpace.translationZ = currentState.space.translationZ;
2482
- stateSpace.rotationX = currentState.space.rotationX;
2483
- stateSpace.rotationY = currentState.space.rotationY;
2484
- stateSpace.scale = currentState.space.scale;
2485
- }
2486
- if (localState && !currentState) {
2487
- stateSpace.translationX = localState.space.translationX;
2488
- stateSpace.translationY = localState.space.translationY;
2489
- stateSpace.translationZ = localState.space.translationZ;
2490
- stateSpace.rotationX = localState.space.rotationX;
2491
- stateSpace.rotationY = localState.space.rotationY;
2492
- stateSpace.scale = localState.space.scale;
2493
- }
2494
- return stateSpace;
2495
- };
2496
-
2497
- const resolveThemes = (configuration, precomputedState) => {
2498
- let generalTheme;
2499
- let interactionTheme;
2500
- if (typeof configuration.global.theme === "object") {
2501
- const {general: general, interaction: interaction} = configuration.global.theme;
2502
- if (typeof general === "string") {
2503
- if (Object.keys(THEME_NAMES).includes(general)) {
2504
- generalTheme = themes[general];
2505
- }
2506
- }
2507
- if (typeof interaction === "string") {
2508
- if (Object.keys(THEME_NAMES).includes(interaction)) {
2509
- interactionTheme = themes[interaction];
2510
- }
2511
- }
2512
- } else {
2513
- if (Object.keys(THEME_NAMES).includes(configuration.global.theme)) {
2514
- generalTheme = themes[configuration.global.theme];
2515
- interactionTheme = themes[configuration.global.theme];
2516
- }
2517
- }
2518
- const stateThemes = Object.assign({
2519
- general: generalTheme || themes.plurid,
2520
- interaction: interactionTheme || themes.plurid
2521
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.themes);
2522
- return stateThemes;
2523
- };
2524
-
2525
- const compute = (view, configuration, planesRegistrar, currentState, localState, precomputedState, contextState) => {
2526
- const specifiedConfiguration = merge(configuration);
2527
- const stateConfiguration = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, specifiedConfiguration), precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.configuration), contextState === null || contextState === void 0 ? void 0 : contextState.configuration), localState === null || localState === void 0 ? void 0 : localState.configuration), currentState === null || currentState === void 0 ? void 0 : currentState.configuration);
2528
- const stateSpace = resolveSpace(view, stateConfiguration, planesRegistrar, currentState, localState, precomputedState, contextState);
2529
- const stateThemes = resolveThemes(stateConfiguration, precomputedState);
2530
- const state = {
2531
- configuration: Object.assign({}, stateConfiguration),
2532
- shortcuts: Object.assign({
2533
- global: true
2534
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.shortcuts),
2535
- space: Object.assign({}, stateSpace),
2536
- themes: Object.assign({}, stateThemes),
2537
- ui: Object.assign(Object.assign({
2538
- toolbarScrollPosition: 0
2539
- }, precomputedState === null || precomputedState === void 0 ? void 0 : precomputedState.ui), contextState === null || contextState === void 0 ? void 0 : contextState.ui)
2540
- };
2541
- return state;
2542
- };
2543
-
2544
- const load = (id, useLocalStorage) => {
2545
- if (!useLocalStorage) {
2546
- return;
2547
- }
2548
- if (typeof localStorage === "undefined") {
2549
- return;
2550
- }
2551
- try {
2552
- const stateID = id || "default";
2553
- const stateData = localStorage.getItem("pluridState-" + stateID);
2554
- if (!stateData) {
2555
- return;
2556
- }
2557
- const state = JSON.parse(stateData);
2558
- return state;
2559
- } catch (error) {
2560
- return;
2561
- }
2562
- };
2563
-
2564
- var index$1 = Object.freeze({
2565
- __proto__: null,
2566
- load: load
2567
- });
2568
-
2569
- var index = Object.freeze({
2570
- __proto__: null,
2571
- compute: compute,
2572
- local: index$1
2573
- });
2574
-
2575
- const cleanTemplate = template => template.replace(/(?:\r\n|\r|\n)/g, " ").replace(/ +/g, " ").trim();
2576
-
2577
- const pluridRouterNavigate = path => {
2578
- if (!CustomEvent || !window) {
2579
- return;
2580
- }
2581
- const event = new CustomEvent(PLURID_ROUTER_LOCATION_CHANGED, {
2582
- detail: {
2583
- path: path
2584
- }
2585
- });
2586
- window.dispatchEvent(event);
2587
- };
2588
-
2589
- export { cleanTemplate, index$f as general, index$a as interaction, internatiolate, index$8 as planes, pluridRouterNavigate, index$9 as routing, index$2 as space, index as state, index$h as utilities };
2590
- //# sourceMappingURL=index.es.js.map