@plurid/plurid-engine 0.0.0-14 → 0.0.0-17

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.
@@ -60,1337 +60,1337 @@ var index$k = Object.freeze({
60
60
  merge: merge
61
61
  });
62
62
 
63
- const updateTreePlane$1 = (tree, page) => {
64
- const updatedTree = tree.map((treePlane => {
65
- if (treePlane.planeID === page.planeID) {
66
- return Object.assign({}, page);
67
- }
68
- if (treePlane.children) {
69
- return Object.assign(Object.assign({}, treePlane), {
70
- children: updateTreePlane$1(treePlane.children, page)
71
- });
63
+ const extractPathname = location => {
64
+ const queryIndex = location.indexOf("?");
65
+ const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
66
+ const fragmentIndex = noQueryPath.indexOf("#:~:");
67
+ const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
68
+ return noFragmentPath;
69
+ };
70
+
71
+ const extractParametersAndMatch = (location, route) => {
72
+ const routeElements = splitPath(route);
73
+ const parameters = [];
74
+ routeElements.forEach((routeElement => {
75
+ if (routeElement[0] === ":") {
76
+ parameters.push(routeElement);
77
+ } else {
78
+ parameters.push("");
72
79
  }
73
- return treePlane;
74
80
  }));
75
- return updatedTree;
81
+ const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
82
+ if (comparingPath !== route) {
83
+ return {
84
+ match: false,
85
+ parameters: {},
86
+ elements: locationElements
87
+ };
88
+ }
89
+ const parametersValues = extractParametersValues(parameters, locationElements);
90
+ return {
91
+ match: true,
92
+ parameters: parametersValues,
93
+ elements: locationElements
94
+ };
76
95
  };
77
96
 
78
- const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
79
- const updatedTree = tree.map((treePlane => {
80
- if (treePlane.planeID === planeID) {
81
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
82
- linkCoordinates: linkCoordinates
83
- });
84
- return updatedPlane;
85
- }
86
- if (treePlane.children) {
87
- const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
88
- const updatedPlane = Object.assign(Object.assign({}, treePlane), {
89
- children: updatedChildren
90
- });
91
- return updatedPlane;
97
+ const extractParametersValues = (parameters, pathElements) => {
98
+ const parametersValues = {};
99
+ parameters.forEach(((parameter, index) => {
100
+ if (parameter) {
101
+ const parameterKey = parameter.slice(1);
102
+ parametersValues[parameterKey] = pathElements[index];
92
103
  }
93
- return treePlane;
94
104
  }));
95
- return updatedTree;
105
+ return parametersValues;
96
106
  };
97
107
 
98
- var index$j = Object.freeze({
99
- __proto__: null,
100
- updateTreePlane: updateTreePlane$1,
101
- updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
102
- });
108
+ const computeComparingPath = (path, parameters) => {
109
+ const pathname = extractPathname(path);
110
+ const locationElements = splitPath(pathname);
111
+ const comparingPathElements = [ ...locationElements ];
112
+ for (const index of locationElements.keys()) {
113
+ if (parameters[index]) {
114
+ comparingPathElements[index] = parameters[index];
115
+ }
116
+ }
117
+ const comparingPath = comparingPathElements.join("/");
118
+ return {
119
+ locationElements: locationElements,
120
+ comparingPath: comparingPath
121
+ };
122
+ };
103
123
 
104
- var index$i = Object.freeze({
105
- __proto__: null,
106
- configuration: index$k,
107
- tree: index$j
108
- });
124
+ const splitPath = path => path.split("/").filter((i => i !== ""));
109
125
 
110
- const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
111
- let direction = "left";
112
- const wheelDeltaX = deltas.deltaX;
113
- const wheelDeltaY = deltas.deltaY;
114
- const absWheelDeltaX = Math.abs(wheelDeltaX);
115
- const absWheelDeltaY = Math.abs(wheelDeltaY);
116
- if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
117
- direction = "left";
126
+ const extractQuery = path => {
127
+ const fragmentIndex = path.indexOf("#:~:");
128
+ const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
129
+ const querySplit = noFragmentPath.split("?");
130
+ if (querySplit.length === 2) {
131
+ const queryValues = {};
132
+ const query = querySplit[1];
133
+ const queryItems = query.split("&");
134
+ for (const item of queryItems) {
135
+ const queryValue = item.split("=");
136
+ const id = queryValue[0];
137
+ const value = decodeURIComponent(queryValue[1]);
138
+ queryValues[id] = value;
139
+ }
140
+ return queryValues;
141
+ } else {
142
+ return {};
118
143
  }
119
- if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
120
- direction = "right";
144
+ };
145
+
146
+ const extractFragments = location => {
147
+ if (!location) {
148
+ return {
149
+ texts: [],
150
+ elements: []
151
+ };
121
152
  }
122
- if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
123
- direction = "up";
153
+ const split = location.split("#:~:");
154
+ const fragmentsValues = split[1];
155
+ if (!fragmentsValues) {
156
+ return {
157
+ texts: [],
158
+ elements: []
159
+ };
124
160
  }
125
- if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
126
- direction = "down";
161
+ const fragmentItems = fragmentsValues.split("&");
162
+ const textFragments = [];
163
+ const elementFragments = [];
164
+ for (const item of fragmentItems) {
165
+ const parsedFragment = parseFragment(item);
166
+ if (parsedFragment) {
167
+ switch (parsedFragment.type) {
168
+ case "text":
169
+ textFragments.push(parsedFragment);
170
+ break;
171
+
172
+ case "element":
173
+ elementFragments.push(parsedFragment);
174
+ break;
175
+ }
176
+ }
127
177
  }
128
- return direction;
178
+ return {
179
+ texts: textFragments,
180
+ elements: elementFragments
181
+ };
129
182
  };
130
183
 
131
- var index$h = Object.freeze({
132
- __proto__: null,
133
- getWheelDirection: getWheelDirection
134
- });
135
-
136
- const degToRad = deg => deg * .01745329252;
184
+ const parseFragment = fragment => {
185
+ const fragmentData = fragment.split("=");
186
+ const fragmentType = fragmentData[0];
187
+ const fragmentValues = fragmentData[1];
188
+ switch (fragmentType.toLowerCase()) {
189
+ case "text":
190
+ {
191
+ const textValues = fragmentValues.split(",");
192
+ const textStart = textValues[0];
193
+ const textEnd = textValues[1];
194
+ const textOccurence = extractOccurence(textValues[2]);
195
+ if (!textStart) {
196
+ return;
197
+ }
198
+ return {
199
+ type: "text",
200
+ start: textStart,
201
+ end: textEnd || "",
202
+ occurence: textOccurence
203
+ };
204
+ }
137
205
 
138
- const radToDeg = rad => rad * 57.2957795131;
206
+ case "element":
207
+ {
208
+ const elementValues = fragmentValues.split(",");
209
+ const elementID = elementValues[0];
210
+ const elementOccurence = extractOccurence(elementValues[1]);
211
+ if (!elementID) {
212
+ return;
213
+ }
214
+ return {
215
+ type: "element",
216
+ id: elementID,
217
+ occurence: elementOccurence
218
+ };
219
+ }
220
+ }
221
+ return undefined;
222
+ };
139
223
 
140
- const makeQuaternion = (x, y, z, w) => ({
141
- x: x,
142
- y: y,
143
- z: z,
144
- w: w
145
- });
224
+ const extractOccurence = occurence => {
225
+ if (!occurence) {
226
+ return 0;
227
+ }
228
+ const occurenceMatch = occurence.match(/\[(\d*)\]/);
229
+ const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
230
+ return occurenceValue;
231
+ };
146
232
 
147
- const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
233
+ const stringInsertInitial = (value, insert) => {
234
+ if (!value.startsWith(insert)) {
235
+ value = insert + value;
236
+ }
237
+ return value;
238
+ };
148
239
 
149
- function inverseQuaternion(quaternion) {
150
- return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
151
- }
240
+ const stringRemoveTrailing = (value, trail) => {
241
+ if (value.endsWith(trail)) {
242
+ value = value.slice(0, value.length - trail.length);
243
+ }
244
+ return value;
245
+ };
152
246
 
153
- function conjugateQuaternion(quaternion) {
154
- return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
155
- }
247
+ const PATH_SEPARATOR = "/";
156
248
 
157
- function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
158
- const x = radians ? beta : degToRad(beta);
159
- const y = radians ? gamma : degToRad(gamma);
160
- const z = radians ? alpha : degToRad(alpha);
161
- const cX = Math.cos(x / 2);
162
- const cY = Math.cos(y / 2);
163
- const cZ = Math.cos(z / 2);
164
- const sX = Math.sin(x / 2);
165
- const sY = Math.sin(y / 2);
166
- const sZ = Math.sin(z / 2);
167
- const xQ = sX * cY * cZ - cX * sY * sZ;
168
- const yQ = cX * sY * cZ + sX * cY * sZ;
169
- const zQ = cX * cY * sZ + sX * sY * cZ;
170
- const wQ = cX * cY * cZ - sX * sY * sZ;
171
- return makeQuaternion(xQ, yQ, zQ, wQ);
172
- }
249
+ const cleanupPath = value => {
250
+ value = stringInsertInitial(value, PATH_SEPARATOR);
251
+ value = stringRemoveTrailing(value, PATH_SEPARATOR);
252
+ return value;
253
+ };
173
254
 
174
- function quaternionFromAxisAngle(x, y, z, angle) {
175
- const q = zeroQuaternion();
176
- const halfAngle = angle / 2;
177
- const sine = Math.sin(halfAngle);
178
- q.x = x * sine;
179
- q.y = y * sine;
180
- q.z = z * sine;
181
- q.w = Math.cos(halfAngle);
182
- return q;
183
- }
184
-
185
- function quaternionMultiply(quaternionArray) {
186
- const firstQuaternion = quaternionArray[0];
187
- const valueQuaternion = Object.assign({}, firstQuaternion);
188
- for (let i = 1; i < quaternionArray.length; i++) {
189
- const nextQuaternion = quaternionArray[i];
190
- const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
191
- const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
192
- const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
193
- const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
194
- valueQuaternion.x = x;
195
- valueQuaternion.y = y;
196
- valueQuaternion.z = z;
197
- valueQuaternion.w = w;
255
+ const computePlaneAddress = (plane, route, origin = "origin") => {
256
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
257
+ origin = location.host;
198
258
  }
199
- return valueQuaternion;
200
- }
201
-
202
- function rotatePointViaQuaternion(pointRotate, quaternion) {
203
- const temporaryQuaternion = {
204
- x: pointRotate[0],
205
- y: pointRotate[1],
206
- z: pointRotate[2],
207
- w: 0
208
- };
209
- const rotatedPointQuaternion = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
210
- return rotatedPointQuaternion;
211
- }
259
+ const cleanPlane = extractPathname(plane);
260
+ const planeAddressType = checkPlaneAddressType(cleanPlane);
261
+ switch (planeAddressType) {
262
+ case "http":
263
+ case "https":
264
+ case "pttp":
265
+ return cleanPlane;
266
+ }
267
+ origin = stringRemoveTrailing(origin, "/");
268
+ const absolutePlane = isAbsolutePlane(plane);
269
+ const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
270
+ const planeAddress = pluridData.protocols.plurid + origin + path;
271
+ return planeAddress;
272
+ };
212
273
 
213
- function makeRotationMatrixFromQuaternion(quaternion) {
214
- const num = quaternion.x * 2;
215
- const num2 = quaternion.y * 2;
216
- const num3 = quaternion.z * 2;
217
- const num4 = quaternion.x * num;
218
- const num5 = quaternion.y * num2;
219
- const num6 = quaternion.z * num3;
220
- const num7 = quaternion.x * num2;
221
- const num8 = quaternion.x * num3;
222
- const num9 = quaternion.y * num3;
223
- const num10 = quaternion.w * num;
224
- const num11 = quaternion.w * num2;
225
- const num12 = quaternion.w * num3;
226
- 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 ];
227
- }
274
+ const isAbsolutePlane = value => value[0] === "/";
228
275
 
229
- var index$g = Object.freeze({
230
- __proto__: null,
231
- degToRad: degToRad,
232
- radToDeg: radToDeg,
233
- makeQuaternion: makeQuaternion,
234
- zeroQuaternion: zeroQuaternion,
235
- inverseQuaternion: inverseQuaternion,
236
- conjugateQuaternion: conjugateQuaternion,
237
- computeQuaternionFromEulers: computeQuaternionFromEulers,
238
- quaternionFromAxisAngle: quaternionFromAxisAngle,
239
- quaternionMultiply: quaternionMultiply,
240
- rotatePointViaQuaternion: rotatePointViaQuaternion,
241
- makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
242
- });
276
+ const checkPlaneAddressType = value => {
277
+ value = value.toLowerCase().trim();
278
+ if (value.startsWith(pluridData.protocols.plurid)) {
279
+ return "pttp";
280
+ }
281
+ if (value.startsWith(pluridData.protocols.https)) {
282
+ return pluridData.HTTPS_PROTOCOL;
283
+ }
284
+ if (value.startsWith(pluridData.protocols.http)) {
285
+ return pluridData.HTTP_PROTOCOL;
286
+ }
287
+ return "relative";
288
+ };
243
289
 
244
- function rotateMatrix(xAngle, yAngle, zAngle = 0) {
245
- const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
246
- const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
247
- const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
248
- const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
249
- const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
250
- return rotationMatrix;
251
- }
290
+ const removeTrailingSlash = value => {
291
+ if (value.endsWith("/") && value.length > 1) {
292
+ return value.slice(0, value.length - 1);
293
+ }
294
+ return value;
295
+ };
252
296
 
253
- function translateMatrix$1(x, y, z) {
254
- return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
255
- }
297
+ const cleanPathValue = value => {
298
+ const queryStart = value.indexOf("?");
299
+ if (queryStart < 0) {
300
+ return removeTrailingSlash(value);
301
+ }
302
+ return removeTrailingSlash(value.substring(0, queryStart));
303
+ };
256
304
 
257
- function scaleMatrix$1(s) {
258
- return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
259
- }
305
+ const checkParameterLength = (parameter, length, compareType) => {
306
+ const parameterLength = parameter.length;
307
+ switch (compareType) {
308
+ case pluridData.compareTypes.equal:
309
+ return parameterLength === length;
260
310
 
261
- function multiplyMatrices$1(matrixA, matrixB) {
262
- const result = [];
263
- const a00 = matrixA[0];
264
- const a01 = matrixA[1];
265
- const a02 = matrixA[2];
266
- const a03 = matrixA[3];
267
- const a10 = matrixA[4];
268
- const a11 = matrixA[5];
269
- const a12 = matrixA[6];
270
- const a13 = matrixA[7];
271
- const a20 = matrixA[8];
272
- const a21 = matrixA[9];
273
- const a22 = matrixA[10];
274
- const a23 = matrixA[11];
275
- const a30 = matrixA[12];
276
- const a31 = matrixA[13];
277
- const a32 = matrixA[14];
278
- const a33 = matrixA[15];
279
- let b0 = matrixB[0];
280
- let b1 = matrixB[1];
281
- let b2 = matrixB[2];
282
- let b3 = matrixB[3];
283
- result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
284
- result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
285
- result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
286
- result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
287
- b0 = matrixB[4];
288
- b1 = matrixB[5];
289
- b2 = matrixB[6];
290
- b3 = matrixB[7];
291
- result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
292
- result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
293
- result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
294
- result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
295
- b0 = matrixB[8];
296
- b1 = matrixB[9];
297
- b2 = matrixB[10];
298
- b3 = matrixB[11];
299
- result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
300
- result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
301
- result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
302
- result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
303
- b0 = matrixB[12];
304
- b1 = matrixB[13];
305
- b2 = matrixB[14];
306
- b3 = matrixB[15];
307
- result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
308
- result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
309
- result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
310
- result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
311
- return result;
312
- }
311
+ case pluridData.compareTypes.equalLessThan:
312
+ return parameterLength <= length;
313
313
 
314
- function multiplyArrayOfMatrices(matrices) {
315
- let inputMatrix = matrices[0];
316
- for (let i = 1; i < matrices.length; i++) {
317
- inputMatrix = multiplyMatrices$1(inputMatrix, matrices[i]);
318
- }
319
- return inputMatrix;
320
- }
314
+ case pluridData.compareTypes.lessThan:
315
+ return parameterLength < length;
321
316
 
322
- function matrixArrayToCSSMatrix(array) {
323
- return "matrix3d(" + array.join(",") + ")";
324
- }
317
+ case pluridData.compareTypes.equalGreaterThan:
318
+ return parameterLength >= length;
325
319
 
326
- var index$f = Object.freeze({
327
- __proto__: null,
328
- rotateMatrix: rotateMatrix,
329
- translateMatrix: translateMatrix$1,
330
- scaleMatrix: scaleMatrix$1,
331
- multiplyMatrices: multiplyMatrices$1,
332
- multiplyArrayOfMatrices: multiplyArrayOfMatrices,
333
- matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
334
- });
320
+ case pluridData.compareTypes.greaterThan:
321
+ return parameterLength > length;
335
322
 
336
- const getInitialMatrix = () => {
337
- const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
338
- return matrix;
323
+ default:
324
+ return parameterLength <= length;
325
+ }
339
326
  };
340
327
 
341
- const multiplyMatrices = (m1, m2) => {
342
- const result = [];
343
- for (let i = 0; i < m1.length; i++) {
344
- result[i] = [];
345
- for (let j = 0; j < m2[0].length; j++) {
346
- let sum = 0;
347
- for (let k = 0; k < m1[0].length; k++) {
348
- sum += m1[i][k] * m2[k][j];
328
+ const checkValidPath = (validationParameters, parameters) => {
329
+ if (validationParameters) {
330
+ for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
331
+ const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
332
+ const paramaterValue = parameters[parameterKey];
333
+ if (!paramaterValue) {
334
+ return false;
335
+ }
336
+ if (startsWith && !paramaterValue.startsWith(startsWith)) {
337
+ return false;
338
+ }
339
+ if (endsWith && !paramaterValue.endsWith(endsWith)) {
340
+ return false;
341
+ }
342
+ if (includes && !includes.includes(paramaterValue)) {
343
+ return false;
344
+ }
345
+ if (length) {
346
+ const validLength = checkParameterLength(paramaterValue, length, lengthType);
347
+ return validLength;
349
348
  }
350
- result[i][j] = sum;
351
349
  }
352
350
  }
353
- return result;
351
+ return true;
354
352
  };
355
353
 
356
- const multiplyMatricesArray = matrices => {
357
- if (matrices.length < 2) {
358
- throw new Error("invalid number of matrices");
354
+ const cleanPathElement = path => {
355
+ if (path[0] === "/") {
356
+ return path.slice(1);
359
357
  }
360
- const first = matrices[0];
361
- let result = first;
362
- for (const [index, matrix] of matrices.entries()) {
363
- if (index === 0) {
364
- continue;
365
- }
366
- result = multiplyMatrices(result, matrix);
367
- }
368
- return result;
369
- };
370
-
371
- const arrayToMatrix = array => {
372
- const matrix = [];
373
- for (let i = 0; i < array.length; i += 4) {
374
- const row = [];
375
- row.push(array[i]);
376
- row.push(array[i + 1]);
377
- row.push(array[i + 2]);
378
- row.push(array[i + 3]);
379
- matrix.push(row);
380
- }
381
- return matrix;
358
+ return path;
382
359
  };
383
360
 
384
- const matrixToArray = matrix => matrix.flat();
361
+ var index$j = Object.freeze({
362
+ __proto__: null,
363
+ cleanPathElement: cleanPathElement
364
+ });
385
365
 
386
- const matrix3DToMatrix = value => {
387
- const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
388
- return arrayToMatrix(values);
366
+ const mapPathsToRoutes = (paths, view) => {
367
+ const routes = [];
368
+ for (const [key, path] of Object.entries(paths)) {
369
+ const pathView = view[key];
370
+ if (pathView) {
371
+ const route = {
372
+ value: ""
373
+ };
374
+ routes.push(route);
375
+ }
376
+ }
377
+ return routes;
389
378
  };
390
379
 
391
- const printMatrix = (matrix, name) => {
392
- const normalize = value => {
393
- if (value === 1 || value === 0) {
394
- return value + " ";
395
- }
396
- if (value > 0) {
397
- return value.toFixed(2) + " ";
380
+ const pluridLinkPathDivider = route => {
381
+ const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
382
+ const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
383
+ const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
384
+ let protocol = windowProtocol;
385
+ const host = {
386
+ value: windowHost,
387
+ controlled: false
388
+ };
389
+ const path = {
390
+ value: "",
391
+ parameters: {},
392
+ query: {}
393
+ };
394
+ const space = {
395
+ value: "",
396
+ parameters: {},
397
+ query: {}
398
+ };
399
+ const universe = {
400
+ value: "",
401
+ parameters: {},
402
+ query: {}
403
+ };
404
+ const cluster = {
405
+ value: "",
406
+ parameters: {},
407
+ query: {}
408
+ };
409
+ const plane = {
410
+ value: "",
411
+ parameters: {},
412
+ query: {},
413
+ fragments: {
414
+ texts: [],
415
+ elements: []
398
416
  }
399
- return value.toFixed(2) + " ";
400
417
  };
401
- console.log("matrix", name + ":");
402
- for (const row of matrix) {
403
- console.log(normalize(row[0]), normalize(row[1]), normalize(row[2]), normalize(row[3]));
418
+ const valid = false;
419
+ if (split.length === 0 || split.length > 7) {
420
+ const url = {
421
+ protocol: {
422
+ value: protocol,
423
+ secure: true
424
+ },
425
+ host: host,
426
+ path: path,
427
+ space: space,
428
+ universe: universe,
429
+ cluster: cluster,
430
+ plane: plane,
431
+ valid: valid
432
+ };
433
+ return url;
404
434
  }
405
- console.log(`matrix3d(${matrix.flat().join(",")})`);
406
- console.log();
407
- };
435
+ if (route.startsWith("/://")) {
436
+ const routeSplit = split.slice(1);
437
+ switch (routeSplit.length) {
438
+ case 1:
439
+ path.value = routeSplit[0];
440
+ break;
408
441
 
409
- const rotateXMatrix = angle => {
410
- const x = Math.cos(angle);
411
- const y = -1 * Math.sin(angle);
412
- const z = Math.sin(angle);
413
- const m = [ [ 1, 0, 0, 0 ], [ 0, x, y, 0 ], [ 0, z, x, 0 ], [ 0, 0, 0, 1 ] ];
414
- return m;
415
- };
442
+ case 5:
443
+ path.value = routeSplit[0];
444
+ space.value = routeSplit[1];
445
+ universe.value = routeSplit[2];
446
+ cluster.value = routeSplit[3];
447
+ plane.value = routeSplit[4];
448
+ break;
449
+ }
450
+ const url = {
451
+ protocol: {
452
+ value: protocol,
453
+ secure: true
454
+ },
455
+ host: host,
456
+ path: path,
457
+ space: space,
458
+ universe: universe,
459
+ cluster: cluster,
460
+ plane: plane,
461
+ valid: true
462
+ };
463
+ return url;
464
+ }
465
+ if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
466
+ switch (split.length) {
467
+ case 1:
468
+ plane.value = split[0];
469
+ break;
416
470
 
417
- const rotateYMatrix = angle => {
418
- const x = Math.cos(angle);
419
- const y = -1 * Math.sin(angle);
420
- const z = Math.sin(angle);
421
- const m = [ [ x, 0, z, 0 ], [ 0, 1, 0, 0 ], [ y, 0, x, 0 ], [ 0, 0, 0, 1 ] ];
422
- return m;
423
- };
471
+ case 2:
472
+ cluster.value = split[0];
473
+ plane.value = split[1];
474
+ break;
424
475
 
425
- const rotateZMatrix = angle => {
426
- const x = Math.cos(angle);
427
- const y = -1 * Math.sin(angle);
428
- const z = Math.sin(angle);
429
- const m = [ [ x, y, 0, 0 ], [ z, x, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
430
- return m;
431
- };
476
+ case 3:
477
+ universe.value = split[0];
478
+ cluster.value = split[1];
479
+ plane.value = split[2];
480
+ break;
432
481
 
433
- const translateMatrix = (x = 0, y = 0, z = 0) => {
434
- const m = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ x, y, z, 1 ] ];
435
- return m;
436
- };
482
+ case 4:
483
+ space.value = split[0];
484
+ universe.value = split[1];
485
+ cluster.value = split[2];
486
+ plane.value = split[3];
487
+ break;
437
488
 
438
- const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
489
+ case 5:
490
+ path.value = split[0];
491
+ space.value = split[1];
492
+ universe.value = split[2];
493
+ cluster.value = split[3];
494
+ plane.value = split[4];
495
+ break;
439
496
 
440
- function rotationMatrixFromQuaternion(quaternion) {
441
- const num = quaternion.x * 2;
442
- const num2 = quaternion.y * 2;
443
- const num3 = quaternion.z * 2;
444
- const num4 = quaternion.x * num;
445
- const num5 = quaternion.y * num2;
446
- const num6 = quaternion.z * num3;
447
- const num7 = quaternion.x * num2;
448
- const num8 = quaternion.x * num3;
449
- const num9 = quaternion.y * num3;
450
- const num10 = quaternion.w * num;
451
- const num11 = quaternion.w * num2;
452
- const num12 = quaternion.w * num3;
453
- 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 ] ];
454
- }
497
+ case 6:
498
+ host.value = split[0];
499
+ path.value = split[1];
500
+ space.value = split[2];
501
+ universe.value = split[3];
502
+ cluster.value = split[4];
503
+ plane.value = split[5];
504
+ break;
455
505
 
456
- const matrixToCSSMatrix = matrix => {
457
- const value = matrix.flat().join(",");
458
- return `matrix3d(${value})`;
459
- };
506
+ default:
507
+ const url = {
508
+ protocol: {
509
+ value: protocol,
510
+ secure: true
511
+ },
512
+ host: host,
513
+ path: path,
514
+ space: space,
515
+ universe: universe,
516
+ cluster: cluster,
517
+ plane: plane,
518
+ valid: valid
519
+ };
520
+ return url;
521
+ }
522
+ } else {
523
+ switch (split.length) {
524
+ case 3:
525
+ protocol = split[0];
526
+ host.value = split[1];
527
+ path.value = split[2];
528
+ break;
460
529
 
461
- const identityMatrix = () => {
462
- const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
463
- return matrix;
464
- };
530
+ case 7:
531
+ protocol = split[0];
532
+ host.value = split[1];
533
+ path.value = split[2];
534
+ space.value = split[3];
535
+ universe.value = split[4];
536
+ cluster.value = split[5];
537
+ plane.value = split[6];
538
+ break;
465
539
 
466
- const inverseMatrix = matrix => {
467
- const cols = 4;
468
- const rows = 4;
469
- const A = [ ...matrix ];
470
- const B = identityMatrix();
471
- let r;
472
- let s;
473
- let f;
474
- let temp;
475
- for (let c = 0; c < cols; c++) {
476
- let ABig = Math.abs(A[c][c]);
477
- let rBig = c;
478
- r = c + 1;
479
- while (r < rows) {
480
- if (Math.abs(A[r][c]) > ABig) {
481
- ABig = Math.abs(A[r][c]);
482
- rBig = r;
483
- }
484
- r++;
540
+ default:
541
+ const url = {
542
+ protocol: {
543
+ value: protocol,
544
+ secure: true
545
+ },
546
+ host: host,
547
+ path: path,
548
+ space: space,
549
+ universe: universe,
550
+ cluster: cluster,
551
+ plane: plane,
552
+ valid: valid
553
+ };
554
+ return url;
485
555
  }
486
- if (ABig === 0) {
487
- throw Error("Cannot calculate inverse, determinant is zero");
556
+ }
557
+ const url = {
558
+ protocol: {
559
+ value: protocol,
560
+ secure: true
561
+ },
562
+ host: host,
563
+ path: path,
564
+ space: space,
565
+ universe: universe,
566
+ cluster: cluster,
567
+ plane: plane,
568
+ valid: true
569
+ };
570
+ return url;
571
+ };
572
+
573
+ const resolveRoute = (route, protocol, host) => {
574
+ const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
575
+ const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
576
+ const divisions = pluridLinkPathDivider(route);
577
+ const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
578
+ const protocolDivision = divisions.protocol.value || windowProtocol;
579
+ const hostDivision = divisions.host.value ? divisions.host : {
580
+ value: windowHost,
581
+ controlled: true
582
+ };
583
+ const path = divisions.path.value ? divisions.path : {
584
+ value: defaultPathname,
585
+ parameters: {},
586
+ query: {}
587
+ };
588
+ const space = divisions.space.value ? divisions.space : {
589
+ value: "s",
590
+ parameters: {},
591
+ query: {}
592
+ };
593
+ const universe = divisions.universe.value ? divisions.universe : {
594
+ value: "u",
595
+ parameters: {},
596
+ query: {}
597
+ };
598
+ const cluster = divisions.cluster.value ? divisions.cluster : {
599
+ value: "c",
600
+ parameters: {},
601
+ query: {}
602
+ };
603
+ const plane = divisions.plane;
604
+ const separator = "://";
605
+ if (!plane.value && route !== "/") {
606
+ const resolvers = [ protocolDivision, hostDivision.value, path.value ];
607
+ const absoluteRoute = resolvers.join(separator);
608
+ return {
609
+ protocol: protocolDivision,
610
+ host: hostDivision,
611
+ path: path,
612
+ space: space,
613
+ universe: universe,
614
+ cluster: cluster,
615
+ plane: plane,
616
+ route: absoluteRoute
617
+ };
618
+ }
619
+ [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
620
+ return {
621
+ protocol: "",
622
+ host: "",
623
+ path: path,
624
+ space: "",
625
+ universe: "",
626
+ cluster: "",
627
+ plane: "",
628
+ route: route
629
+ };
630
+ };
631
+
632
+ const updateTreePlane$1 = (tree, page) => {
633
+ const updatedTree = tree.map((treePlane => {
634
+ if (treePlane.planeID === page.planeID) {
635
+ return Object.assign({}, page);
488
636
  }
489
- r = rBig;
490
- if (r !== c) {
491
- temp = A[c];
492
- A[c] = A[r];
493
- A[r] = temp;
494
- temp = B[c];
495
- B[c] = B[r];
496
- B[r] = temp;
637
+ if (treePlane.children) {
638
+ return Object.assign(Object.assign({}, treePlane), {
639
+ children: updateTreePlane$1(treePlane.children, page)
640
+ });
497
641
  }
498
- const Ac = A[c];
499
- const Bc = B[c];
500
- for (r = 0; r < rows; r++) {
501
- const Ar = A[r];
502
- const Br = B[r];
503
- if (r !== c) {
504
- if (Ar[c] !== 0) {
505
- f = -Ar[c] / Ac[c];
506
- for (s = c; s < cols; s++) {
507
- Ar[s] = Ar[s] + f * Ac[s];
508
- }
509
- for (s = 0; s < cols; s++) {
510
- Br[s] = Br[s] + f * Bc[s];
511
- }
512
- }
513
- } else {
514
- f = Ac[c];
515
- for (s = c; s < cols; s++) {
516
- Ar[s] = Ar[s] / f;
517
- }
518
- for (s = 0; s < cols; s++) {
519
- Br[s] = Br[s] / f;
520
- }
521
- }
642
+ return treePlane;
643
+ }));
644
+ return updatedTree;
645
+ };
646
+
647
+ const updateTreeByPlaneIDWithLinkCoordinates = (tree, planeID, linkCoordinates) => {
648
+ const updatedTree = tree.map((treePlane => {
649
+ if (treePlane.planeID === planeID) {
650
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
651
+ linkCoordinates: linkCoordinates
652
+ });
653
+ return updatedPlane;
522
654
  }
523
- }
524
- return B;
655
+ if (treePlane.children) {
656
+ const updatedChildren = updateTreeByPlaneIDWithLinkCoordinates(treePlane.children, planeID, linkCoordinates);
657
+ const updatedPlane = Object.assign(Object.assign({}, treePlane), {
658
+ children: updatedChildren
659
+ });
660
+ return updatedPlane;
661
+ }
662
+ return treePlane;
663
+ }));
664
+ return updatedTree;
525
665
  };
526
666
 
527
- var index$e = Object.freeze({
667
+ var index$i = Object.freeze({
528
668
  __proto__: null,
529
- getInitialMatrix: getInitialMatrix,
530
- multiplyMatrices: multiplyMatrices,
531
- multiplyMatricesArray: multiplyMatricesArray,
532
- arrayToMatrix: arrayToMatrix,
533
- matrixToArray: matrixToArray,
534
- matrix3DToMatrix: matrix3DToMatrix,
535
- printMatrix: printMatrix,
536
- rotateXMatrix: rotateXMatrix,
537
- rotateYMatrix: rotateYMatrix,
538
- rotateZMatrix: rotateZMatrix,
539
- translateMatrix: translateMatrix,
540
- scaleMatrix: scaleMatrix,
541
- rotationMatrixFromQuaternion: rotationMatrixFromQuaternion,
542
- matrixToCSSMatrix: matrixToCSSMatrix,
543
- identityMatrix: identityMatrix,
544
- inverseMatrix: inverseMatrix
669
+ updateTreePlane: updateTreePlane$1,
670
+ updateTreeByPlaneIDWithLinkCoordinates: updateTreeByPlaneIDWithLinkCoordinates
545
671
  });
546
672
 
547
- function getMatrixValues(matrix3d) {
548
- const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
549
- const matrixValuesInt = [];
550
- for (let i = 0; i < matrixValues.length; i++) {
551
- matrixValuesInt[i] = parseFloat(matrixValues[i]);
673
+ var index$h = Object.freeze({
674
+ __proto__: null,
675
+ configuration: index$k,
676
+ tree: index$i
677
+ });
678
+
679
+ const getWheelDirection = (deltas, ABSTHRESHOLD = 10, THRESHOLD = 0) => {
680
+ let direction = "left";
681
+ const wheelDeltaX = deltas.deltaX;
682
+ const wheelDeltaY = deltas.deltaY;
683
+ const absWheelDeltaX = Math.abs(wheelDeltaX);
684
+ const absWheelDeltaY = Math.abs(wheelDeltaY);
685
+ if (wheelDeltaX > THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
686
+ direction = "left";
552
687
  }
553
- return matrixValuesInt;
688
+ if (wheelDeltaX < THRESHOLD && absWheelDeltaY < ABSTHRESHOLD && absWheelDeltaX > absWheelDeltaY) {
689
+ direction = "right";
690
+ }
691
+ if (wheelDeltaY > THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
692
+ direction = "up";
693
+ }
694
+ if (wheelDeltaY < THRESHOLD && absWheelDeltaX < ABSTHRESHOLD && absWheelDeltaY > absWheelDeltaX) {
695
+ direction = "down";
696
+ }
697
+ return direction;
698
+ };
699
+
700
+ var index$g = Object.freeze({
701
+ __proto__: null,
702
+ getWheelDirection: getWheelDirection
703
+ });
704
+
705
+ const degToRad = deg => deg * .01745329252;
706
+
707
+ const radToDeg = rad => rad * 57.2957795131;
708
+
709
+ const makeQuaternion = (x, y, z, w) => ({
710
+ x: x,
711
+ y: y,
712
+ z: z,
713
+ w: w
714
+ });
715
+
716
+ const zeroQuaternion = () => makeQuaternion(0, 0, 0, 0);
717
+
718
+ function inverseQuaternion(quaternion) {
719
+ return makeQuaternion(quaternion.x, quaternion.y, quaternion.z, -quaternion.w);
554
720
  }
555
721
 
556
- function getRotationMatrix(matrix3d) {
557
- const valuesMatrix = getMatrixValues(matrix3d);
558
- const scale = getScalationValue(matrix3d);
559
- if (valuesMatrix.length === 16) {
560
- for (let i = 0; i < 11; i++) {
561
- valuesMatrix[i] /= scale;
562
- }
563
- } else if (valuesMatrix.length === 6) {
564
- for (let i = 0; i < 4; i++) {
565
- valuesMatrix[i] /= scale;
566
- }
567
- }
568
- const rotationMatrix = valuesMatrix;
569
- return rotationMatrix;
722
+ function conjugateQuaternion(quaternion) {
723
+ return makeQuaternion(-quaternion.x, -quaternion.y, -quaternion.z, quaternion.w);
570
724
  }
571
725
 
572
- function getTranslationMatrix(matrix3d) {
573
- const valuesMatrix = getMatrixValues(matrix3d);
574
- let translationMatrix;
575
- if (valuesMatrix.length === 16) {
576
- translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
577
- } else if (valuesMatrix.length === 6) {
578
- translationMatrix = getMatrixValues(matrix3d).slice(4);
579
- }
580
- return translationMatrix;
581
- }
582
-
583
- function getScalationValue(matrix3d) {
584
- const valuesMatrix = getMatrixValues(matrix3d);
585
- let temp = 0;
586
- let scale;
587
- if (valuesMatrix.length === 16) {
588
- const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
589
- scale = 0;
590
- for (const el of scaleMatrix) {
591
- scale += parseFloat(el) * parseFloat(el);
592
- }
593
- scale = parseFloat(Math.sqrt(scale).toPrecision(4));
594
- } else if (valuesMatrix.length === 6) {
595
- temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
596
- scale = parseFloat(Math.sqrt(temp).toPrecision(4));
597
- }
598
- return scale;
726
+ function computeQuaternionFromEulers(alpha, beta, gamma, radians = true) {
727
+ const x = radians ? beta : degToRad(beta);
728
+ const y = radians ? gamma : degToRad(gamma);
729
+ const z = radians ? alpha : degToRad(alpha);
730
+ const cX = Math.cos(x / 2);
731
+ const cY = Math.cos(y / 2);
732
+ const cZ = Math.cos(z / 2);
733
+ const sX = Math.sin(x / 2);
734
+ const sY = Math.sin(y / 2);
735
+ const sZ = Math.sin(z / 2);
736
+ const xQ = sX * cY * cZ - cX * sY * sZ;
737
+ const yQ = cX * sY * cZ + sX * cY * sZ;
738
+ const zQ = cX * cY * sZ + sX * sY * cZ;
739
+ const wQ = cX * cY * cZ - sX * sY * sZ;
740
+ return makeQuaternion(xQ, yQ, zQ, wQ);
599
741
  }
600
742
 
601
- function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
602
- const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
603
- return matrixArrayToCSSMatrix(transformMatrix);
743
+ function quaternionFromAxisAngle(x, y, z, angle) {
744
+ const q = zeroQuaternion();
745
+ const halfAngle = angle / 2;
746
+ const sine = Math.sin(halfAngle);
747
+ q.x = x * sine;
748
+ q.y = y * sine;
749
+ q.z = z * sine;
750
+ q.w = Math.cos(halfAngle);
751
+ return q;
604
752
  }
605
753
 
606
- function getTransformRotate(matrix3d) {
607
- const pi = Math.PI;
608
- const values = getRotationMatrix(matrix3d);
609
- let rotateX = 0;
610
- let rotateY = 0;
611
- if (values.length === 6) {
612
- const cosa = values[0];
613
- const sina = values[1];
614
- if (cosa === 1 && sina === 0) {
615
- rotateX = Math.asin(sina);
616
- rotateY = Math.acos(cosa);
617
- }
618
- }
619
- if (values.length === 16) {
620
- const cosaX1 = values[5];
621
- const sinaX3 = values[9];
622
- if (sinaX3 <= 0) {
623
- rotateX = Math.acos(cosaX1);
624
- }
625
- if (sinaX3 > 0) {
626
- rotateX = 2 * pi - Math.acos(cosaX1);
627
- }
628
- const cosaY1 = values[0];
629
- const sinaY2 = values[2];
630
- if (sinaY2 <= 0) {
631
- rotateY = Math.acos(cosaY1);
632
- }
633
- if (sinaY2 > 0) {
634
- rotateY = 2 * pi - Math.acos(cosaY1);
635
- }
636
- rotateX = Math.atan2(values[9], values[5]);
637
- rotateY = Math.atan2(values[2], values[0]);
754
+ function quaternionMultiply(quaternionArray) {
755
+ const firstQuaternion = quaternionArray[0];
756
+ const valueQuaternion = Object.assign({}, firstQuaternion);
757
+ for (let i = 1; i < quaternionArray.length; i++) {
758
+ const nextQuaternion = quaternionArray[i];
759
+ const w = valueQuaternion.w * nextQuaternion.w - valueQuaternion.x * nextQuaternion.x - valueQuaternion.y * nextQuaternion.y - valueQuaternion.z * nextQuaternion.z;
760
+ const x = valueQuaternion.x * nextQuaternion.w + valueQuaternion.w * nextQuaternion.x + valueQuaternion.y * nextQuaternion.z - valueQuaternion.z * nextQuaternion.y;
761
+ const y = valueQuaternion.y * nextQuaternion.w + valueQuaternion.w * nextQuaternion.y + valueQuaternion.z * nextQuaternion.x - valueQuaternion.x * nextQuaternion.z;
762
+ const z = valueQuaternion.z * nextQuaternion.w + valueQuaternion.w * nextQuaternion.z + valueQuaternion.x * nextQuaternion.y - valueQuaternion.y * nextQuaternion.x;
763
+ valueQuaternion.x = x;
764
+ valueQuaternion.y = y;
765
+ valueQuaternion.z = z;
766
+ valueQuaternion.w = w;
638
767
  }
639
- return {
640
- rotateX: rotateX,
641
- rotateY: rotateY,
642
- rotateZ: 0
643
- };
768
+ return valueQuaternion;
644
769
  }
645
770
 
646
- function getTransformTranslate(matrix3d) {
647
- const values = getTranslationMatrix(matrix3d);
648
- const translateX = values[0];
649
- const translateY = values[1];
650
- const translateZ = values[2];
651
- return {
652
- translateX: translateX,
653
- translateY: translateY,
654
- translateZ: translateZ
771
+ function rotatePointViaQuaternion(pointRotate, quaternion) {
772
+ const temporaryQuaternion = {
773
+ x: pointRotate[0],
774
+ y: pointRotate[1],
775
+ z: pointRotate[2],
776
+ w: 0
655
777
  };
778
+ const rotatedPointQuaternion = quaternionMultiply([ quaternion, temporaryQuaternion, conjugateQuaternion(quaternion) ]);
779
+ return rotatedPointQuaternion;
656
780
  }
657
781
 
658
- function getTransformScale(matrix3d) {
659
- const scale = getScalationValue(matrix3d);
660
- return {
661
- scale: scale
662
- };
782
+ function makeRotationMatrixFromQuaternion(quaternion) {
783
+ const num = quaternion.x * 2;
784
+ const num2 = quaternion.y * 2;
785
+ const num3 = quaternion.z * 2;
786
+ const num4 = quaternion.x * num;
787
+ const num5 = quaternion.y * num2;
788
+ const num6 = quaternion.z * num3;
789
+ const num7 = quaternion.x * num2;
790
+ const num8 = quaternion.x * num3;
791
+ const num9 = quaternion.y * num3;
792
+ const num10 = quaternion.w * num;
793
+ const num11 = quaternion.w * num2;
794
+ const num12 = quaternion.w * num3;
795
+ 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 ];
663
796
  }
664
797
 
665
- function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
666
- const transformRotate = getTransformRotate(matrix3d);
667
- const rotateX = transformRotate.rotateX;
668
- let rotateY = transformRotate.rotateY;
669
- const rotateZ = transformRotate.rotateZ;
670
- const transformTranslate = getTransformTranslate(matrix3d);
671
- const translateX = transformTranslate.translateX;
672
- const translateY = transformTranslate.translateY;
673
- const translateZ = transformTranslate.translateZ;
674
- const scale = getTransformScale(matrix3d).scale;
675
- let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
676
- const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
677
- const valScalationMatrix = scaleMatrix$1(scale);
678
- if (direction === "left") {
679
- rotateY -= angleIncrement;
680
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
681
- }
682
- if (direction === "right") {
683
- rotateY += angleIncrement;
684
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
685
- }
686
- if (direction === "up") {
687
- rotateY -= angleIncrement;
688
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
689
- }
690
- if (direction === "down") {
691
- rotateY += angleIncrement;
692
- valRotationMatrix = rotateMatrix(rotateX, rotateY);
693
- }
694
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
695
- return transformedMatrix3d;
696
- }
798
+ var index$f = Object.freeze({
799
+ __proto__: null,
800
+ degToRad: degToRad,
801
+ radToDeg: radToDeg,
802
+ makeQuaternion: makeQuaternion,
803
+ zeroQuaternion: zeroQuaternion,
804
+ inverseQuaternion: inverseQuaternion,
805
+ conjugateQuaternion: conjugateQuaternion,
806
+ computeQuaternionFromEulers: computeQuaternionFromEulers,
807
+ quaternionFromAxisAngle: quaternionFromAxisAngle,
808
+ quaternionMultiply: quaternionMultiply,
809
+ rotatePointViaQuaternion: rotatePointViaQuaternion,
810
+ makeRotationMatrixFromQuaternion: makeRotationMatrixFromQuaternion
811
+ });
697
812
 
698
- function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
699
- const transformRotate = getTransformRotate(matrix3d);
700
- const rotateX = transformRotate.rotateX;
701
- const rotateY = transformRotate.rotateY;
702
- const rotateZ = transformRotate.rotateZ;
703
- const transformTranslate = getTransformTranslate(matrix3d);
704
- let translateX = transformTranslate.translateX;
705
- let translateY = transformTranslate.translateY;
706
- const translateZ = transformTranslate.translateZ;
707
- const scale = getTransformScale(matrix3d).scale;
708
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
709
- let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
710
- const valScalationMatrix = scaleMatrix$1(scale);
711
- scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
712
- if (direction === "left") {
713
- translateX += linearIncrement;
714
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
715
- }
716
- if (direction === "right") {
717
- translateX -= linearIncrement;
718
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
719
- }
720
- if (direction === "up") {
721
- translateY += linearIncrement;
722
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
723
- }
724
- if (direction === "down") {
725
- translateY -= linearIncrement;
726
- valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
727
- }
728
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
729
- return transformedMatrix3d;
813
+ function rotateMatrix(xAngle, yAngle, zAngle = 0) {
814
+ const xQuaternion = computeQuaternionFromEulers(0, xAngle, 0);
815
+ const yQuaternion = computeQuaternionFromEulers(0, 0, yAngle);
816
+ const zQuaternion = computeQuaternionFromEulers(zAngle, 0, 0);
817
+ const quartenionMultiplication = quaternionMultiply([ yQuaternion, xQuaternion, zQuaternion ]);
818
+ const rotationMatrix = makeRotationMatrixFromQuaternion(quartenionMultiplication);
819
+ return rotationMatrix;
730
820
  }
731
821
 
732
- function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
733
- const transformRotate = getTransformRotate(matrix3d);
734
- const rotateX = transformRotate.rotateX;
735
- const rotateY = transformRotate.rotateY;
736
- const rotateZ = transformRotate.rotateZ;
737
- const transformTranslate = getTransformTranslate(matrix3d);
738
- const translateX = transformTranslate.translateX;
739
- const translateY = transformTranslate.translateY;
740
- const translateZ = transformTranslate.translateZ;
741
- let scale = getTransformScale(matrix3d).scale;
742
- const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
743
- const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
744
- let valScalationMatrix = scaleMatrix$1(scale);
745
- if (direction === "up") {
746
- scale -= scaleIncrement;
747
- if (scale < .1) {
748
- scale = .1;
749
- }
750
- valScalationMatrix = scaleMatrix$1(scale);
751
- }
752
- if (direction === "down") {
753
- scale += scaleIncrement;
754
- if (scale > 4) {
755
- scale = 4;
756
- }
757
- valScalationMatrix = scaleMatrix$1(scale);
758
- }
759
- const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
760
- return transformedMatrix3d;
822
+ function translateMatrix$1(x, y, z) {
823
+ return [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1 ];
761
824
  }
762
825
 
763
- var index$d = Object.freeze({
764
- __proto__: null,
765
- getMatrixValues: getMatrixValues,
766
- getRotationMatrix: getRotationMatrix,
767
- getTranslationMatrix: getTranslationMatrix,
768
- getScalationValue: getScalationValue,
769
- setTransform: setTransform,
770
- getTransformRotate: getTransformRotate,
771
- getTransformTranslate: getTransformTranslate,
772
- getTransformScale: getTransformScale,
773
- rotatePlurid: rotatePlurid,
774
- translatePlurid: translatePlurid,
775
- scalePlurid: scalePlurid
776
- });
826
+ function scaleMatrix$1(s) {
827
+ return [ s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1 ];
828
+ }
777
829
 
778
- var index$c = Object.freeze({
779
- __proto__: null,
780
- general: index$e,
781
- matrix3d: index$d
782
- });
830
+ function multiplyMatrices$1(matrixA, matrixB) {
831
+ const result = [];
832
+ const a00 = matrixA[0];
833
+ const a01 = matrixA[1];
834
+ const a02 = matrixA[2];
835
+ const a03 = matrixA[3];
836
+ const a10 = matrixA[4];
837
+ const a11 = matrixA[5];
838
+ const a12 = matrixA[6];
839
+ const a13 = matrixA[7];
840
+ const a20 = matrixA[8];
841
+ const a21 = matrixA[9];
842
+ const a22 = matrixA[10];
843
+ const a23 = matrixA[11];
844
+ const a30 = matrixA[12];
845
+ const a31 = matrixA[13];
846
+ const a32 = matrixA[14];
847
+ const a33 = matrixA[15];
848
+ let b0 = matrixB[0];
849
+ let b1 = matrixB[1];
850
+ let b2 = matrixB[2];
851
+ let b3 = matrixB[3];
852
+ result[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
853
+ result[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
854
+ result[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
855
+ result[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
856
+ b0 = matrixB[4];
857
+ b1 = matrixB[5];
858
+ b2 = matrixB[6];
859
+ b3 = matrixB[7];
860
+ result[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
861
+ result[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
862
+ result[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
863
+ result[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
864
+ b0 = matrixB[8];
865
+ b1 = matrixB[9];
866
+ b2 = matrixB[10];
867
+ b3 = matrixB[11];
868
+ result[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
869
+ result[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
870
+ result[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
871
+ result[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
872
+ b0 = matrixB[12];
873
+ b1 = matrixB[13];
874
+ b2 = matrixB[14];
875
+ b3 = matrixB[15];
876
+ result[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
877
+ result[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
878
+ result[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
879
+ result[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
880
+ return result;
881
+ }
783
882
 
784
- var index$b = Object.freeze({
883
+ function multiplyArrayOfMatrices(matrices) {
884
+ let inputMatrix = matrices[0];
885
+ for (let i = 1; i < matrices.length; i++) {
886
+ inputMatrix = multiplyMatrices$1(inputMatrix, matrices[i]);
887
+ }
888
+ return inputMatrix;
889
+ }
890
+
891
+ function matrixArrayToCSSMatrix(array) {
892
+ return "matrix3d(" + array.join(",") + ")";
893
+ }
894
+
895
+ var index$e = Object.freeze({
785
896
  __proto__: null,
786
- direction: index$h,
787
- matrix: index$f,
788
- quaternion: index$g,
789
- transform: index$c
897
+ rotateMatrix: rotateMatrix,
898
+ translateMatrix: translateMatrix$1,
899
+ scaleMatrix: scaleMatrix$1,
900
+ multiplyMatrices: multiplyMatrices$1,
901
+ multiplyArrayOfMatrices: multiplyArrayOfMatrices,
902
+ matrixArrayToCSSMatrix: matrixArrayToCSSMatrix
790
903
  });
791
904
 
792
- const internatiolate = (lamguage, field) => pluridData.internationalization[lamguage][field];
905
+ const getInitialMatrix = () => {
906
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
907
+ return matrix;
908
+ };
793
909
 
794
- const resolvePluridPlaneData = plane => {
795
- if (Array.isArray(plane)) {
796
- const [route, component, options] = plane;
797
- return Object.assign({
798
- route: route,
799
- component: component
800
- }, options);
910
+ const multiplyMatrices = (m1, m2) => {
911
+ const result = [];
912
+ for (let i = 0; i < m1.length; i++) {
913
+ result[i] = [];
914
+ for (let j = 0; j < m2[0].length; j++) {
915
+ let sum = 0;
916
+ for (let k = 0; k < m1[0].length; k++) {
917
+ sum += m1[i][k] * m2[k][j];
918
+ }
919
+ result[i][j] = sum;
920
+ }
801
921
  }
802
- return plane;
922
+ return result;
803
923
  };
804
924
 
805
- const resolvePluridRoutePlaneData = plane => {
806
- if (Array.isArray(plane)) {
807
- const [value, component, options] = plane;
808
- return Object.assign({
809
- value: value,
810
- component: component
811
- }, options);
925
+ const multiplyMatricesArray = matrices => {
926
+ if (matrices.length < 2) {
927
+ throw new Error("invalid number of matrices");
812
928
  }
813
- return plane;
929
+ const first = matrices[0];
930
+ let result = first;
931
+ for (const [index, matrix] of matrices.entries()) {
932
+ if (index === 0) {
933
+ continue;
934
+ }
935
+ result = multiplyMatrices(result, matrix);
936
+ }
937
+ return result;
814
938
  };
815
939
 
816
- const getPluridPlaneIDByData = element => {
817
- if (!element) {
818
- return "";
819
- }
820
- const parent = element.parentElement;
821
- if (parent && parent.dataset.pluridPlane) {
822
- return parent.dataset.pluridPlane;
940
+ const arrayToMatrix = array => {
941
+ const matrix = [];
942
+ for (let i = 0; i < array.length; i += 4) {
943
+ const row = [];
944
+ row.push(array[i]);
945
+ row.push(array[i + 1]);
946
+ row.push(array[i + 2]);
947
+ row.push(array[i + 3]);
948
+ matrix.push(row);
823
949
  }
824
- return getPluridPlaneIDByData(parent);
950
+ return matrix;
825
951
  };
826
952
 
827
- const extractPathname = location => {
828
- const queryIndex = location.indexOf("?");
829
- const noQueryPath = queryIndex === -1 ? location : location.substring(0, queryIndex);
830
- const fragmentIndex = noQueryPath.indexOf("#:~:");
831
- const noFragmentPath = fragmentIndex === -1 ? noQueryPath : noQueryPath.substring(0, fragmentIndex);
832
- return noFragmentPath;
953
+ const matrixToArray = matrix => matrix.flat();
954
+
955
+ const matrix3DToMatrix = value => {
956
+ const values = value.replace("matrix3d(", "").replace(")", "").split(",").map((val => parseFloat(val)));
957
+ return arrayToMatrix(values);
833
958
  };
834
959
 
835
- const extractParametersAndMatch = (location, route) => {
836
- const routeElements = splitPath(route);
837
- const parameters = [];
838
- routeElements.forEach((routeElement => {
839
- if (routeElement[0] === ":") {
840
- parameters.push(routeElement);
841
- } else {
842
- parameters.push("");
960
+ const printMatrix = (matrix, name) => {
961
+ const normalize = value => {
962
+ if (value === 1 || value === 0) {
963
+ return value + " ";
843
964
  }
844
- }));
845
- const {locationElements: locationElements, comparingPath: comparingPath} = computeComparingPath(location, parameters);
846
- if (comparingPath !== route) {
847
- return {
848
- match: false,
849
- parameters: {},
850
- elements: locationElements
851
- };
852
- }
853
- const parametersValues = extractParametersValues(parameters, locationElements);
854
- return {
855
- match: true,
856
- parameters: parametersValues,
857
- elements: locationElements
965
+ if (value > 0) {
966
+ return value.toFixed(2) + " ";
967
+ }
968
+ return value.toFixed(2) + " ";
858
969
  };
970
+ console.log("matrix", name + ":");
971
+ for (const row of matrix) {
972
+ console.log(normalize(row[0]), normalize(row[1]), normalize(row[2]), normalize(row[3]));
973
+ }
974
+ console.log(`matrix3d(${matrix.flat().join(",")})`);
975
+ console.log();
859
976
  };
860
977
 
861
- const extractParametersValues = (parameters, pathElements) => {
862
- const parametersValues = {};
863
- parameters.forEach(((parameter, index) => {
864
- if (parameter) {
865
- const parameterKey = parameter.slice(1);
866
- parametersValues[parameterKey] = pathElements[index];
867
- }
868
- }));
869
- return parametersValues;
978
+ const rotateXMatrix = angle => {
979
+ const x = Math.cos(angle);
980
+ const y = -1 * Math.sin(angle);
981
+ const z = Math.sin(angle);
982
+ const m = [ [ 1, 0, 0, 0 ], [ 0, x, y, 0 ], [ 0, z, x, 0 ], [ 0, 0, 0, 1 ] ];
983
+ return m;
870
984
  };
871
985
 
872
- const computeComparingPath = (path, parameters) => {
873
- const pathname = extractPathname(path);
874
- const locationElements = splitPath(pathname);
875
- const comparingPathElements = [ ...locationElements ];
876
- for (const index of locationElements.keys()) {
877
- if (parameters[index]) {
878
- comparingPathElements[index] = parameters[index];
879
- }
880
- }
881
- const comparingPath = comparingPathElements.join("/");
882
- return {
883
- locationElements: locationElements,
884
- comparingPath: comparingPath
885
- };
986
+ const rotateYMatrix = angle => {
987
+ const x = Math.cos(angle);
988
+ const y = -1 * Math.sin(angle);
989
+ const z = Math.sin(angle);
990
+ const m = [ [ x, 0, z, 0 ], [ 0, 1, 0, 0 ], [ y, 0, x, 0 ], [ 0, 0, 0, 1 ] ];
991
+ return m;
886
992
  };
887
993
 
888
- const splitPath = path => path.split("/").filter((i => i !== ""));
994
+ const rotateZMatrix = angle => {
995
+ const x = Math.cos(angle);
996
+ const y = -1 * Math.sin(angle);
997
+ const z = Math.sin(angle);
998
+ const m = [ [ x, y, 0, 0 ], [ z, x, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
999
+ return m;
1000
+ };
889
1001
 
890
- const extractQuery = path => {
891
- const fragmentIndex = path.indexOf("#:~:");
892
- const noFragmentPath = fragmentIndex === -1 ? path : path.substring(0, fragmentIndex);
893
- const querySplit = noFragmentPath.split("?");
894
- if (querySplit.length === 2) {
895
- const queryValues = {};
896
- const query = querySplit[1];
897
- const queryItems = query.split("&");
898
- for (const item of queryItems) {
899
- const queryValue = item.split("=");
900
- const id = queryValue[0];
901
- const value = decodeURIComponent(queryValue[1]);
902
- queryValues[id] = value;
903
- }
904
- return queryValues;
905
- } else {
906
- return {};
907
- }
1002
+ const translateMatrix = (x = 0, y = 0, z = 0) => {
1003
+ const m = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ x, y, z, 1 ] ];
1004
+ return m;
908
1005
  };
909
1006
 
910
- const extractFragments = location => {
911
- if (!location) {
912
- return {
913
- texts: [],
914
- elements: []
915
- };
916
- }
917
- const split = location.split("#:~:");
918
- const fragmentsValues = split[1];
919
- if (!fragmentsValues) {
920
- return {
921
- texts: [],
922
- elements: []
923
- };
924
- }
925
- const fragmentItems = fragmentsValues.split("&");
926
- const textFragments = [];
927
- const elementFragments = [];
928
- for (const item of fragmentItems) {
929
- const parsedFragment = parseFragment(item);
930
- if (parsedFragment) {
931
- switch (parsedFragment.type) {
932
- case "text":
933
- textFragments.push(parsedFragment);
934
- break;
1007
+ const scaleMatrix = s => [ [ s, 0, 0, 0 ], [ 0, s, 0, 0 ], [ 0, 0, s, 0 ], [ 0, 0, 0, 1 ] ];
935
1008
 
936
- case "element":
937
- elementFragments.push(parsedFragment);
938
- break;
939
- }
940
- }
941
- }
942
- return {
943
- texts: textFragments,
944
- elements: elementFragments
945
- };
1009
+ function rotationMatrixFromQuaternion(quaternion) {
1010
+ const num = quaternion.x * 2;
1011
+ const num2 = quaternion.y * 2;
1012
+ const num3 = quaternion.z * 2;
1013
+ const num4 = quaternion.x * num;
1014
+ const num5 = quaternion.y * num2;
1015
+ const num6 = quaternion.z * num3;
1016
+ const num7 = quaternion.x * num2;
1017
+ const num8 = quaternion.x * num3;
1018
+ const num9 = quaternion.y * num3;
1019
+ const num10 = quaternion.w * num;
1020
+ const num11 = quaternion.w * num2;
1021
+ const num12 = quaternion.w * num3;
1022
+ 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 ] ];
1023
+ }
1024
+
1025
+ const matrixToCSSMatrix = matrix => {
1026
+ const value = matrix.flat().join(",");
1027
+ return `matrix3d(${value})`;
946
1028
  };
947
1029
 
948
- const parseFragment = fragment => {
949
- const fragmentData = fragment.split("=");
950
- const fragmentType = fragmentData[0];
951
- const fragmentValues = fragmentData[1];
952
- switch (fragmentType.toLowerCase()) {
953
- case "text":
954
- {
955
- const textValues = fragmentValues.split(",");
956
- const textStart = textValues[0];
957
- const textEnd = textValues[1];
958
- const textOccurence = extractOccurence(textValues[2]);
959
- if (!textStart) {
960
- return;
1030
+ const identityMatrix = () => {
1031
+ const matrix = [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ];
1032
+ return matrix;
1033
+ };
1034
+
1035
+ const inverseMatrix = matrix => {
1036
+ const cols = 4;
1037
+ const rows = 4;
1038
+ const A = [ ...matrix ];
1039
+ const B = identityMatrix();
1040
+ let r;
1041
+ let s;
1042
+ let f;
1043
+ let temp;
1044
+ for (let c = 0; c < cols; c++) {
1045
+ let ABig = Math.abs(A[c][c]);
1046
+ let rBig = c;
1047
+ r = c + 1;
1048
+ while (r < rows) {
1049
+ if (Math.abs(A[r][c]) > ABig) {
1050
+ ABig = Math.abs(A[r][c]);
1051
+ rBig = r;
961
1052
  }
962
- return {
963
- type: "text",
964
- start: textStart,
965
- end: textEnd || "",
966
- occurence: textOccurence
967
- };
1053
+ r++;
968
1054
  }
969
-
970
- case "element":
971
- {
972
- const elementValues = fragmentValues.split(",");
973
- const elementID = elementValues[0];
974
- const elementOccurence = extractOccurence(elementValues[1]);
975
- if (!elementID) {
976
- return;
1055
+ if (ABig === 0) {
1056
+ throw Error("Cannot calculate inverse, determinant is zero");
1057
+ }
1058
+ r = rBig;
1059
+ if (r !== c) {
1060
+ temp = A[c];
1061
+ A[c] = A[r];
1062
+ A[r] = temp;
1063
+ temp = B[c];
1064
+ B[c] = B[r];
1065
+ B[r] = temp;
1066
+ }
1067
+ const Ac = A[c];
1068
+ const Bc = B[c];
1069
+ for (r = 0; r < rows; r++) {
1070
+ const Ar = A[r];
1071
+ const Br = B[r];
1072
+ if (r !== c) {
1073
+ if (Ar[c] !== 0) {
1074
+ f = -Ar[c] / Ac[c];
1075
+ for (s = c; s < cols; s++) {
1076
+ Ar[s] = Ar[s] + f * Ac[s];
1077
+ }
1078
+ for (s = 0; s < cols; s++) {
1079
+ Br[s] = Br[s] + f * Bc[s];
1080
+ }
1081
+ }
1082
+ } else {
1083
+ f = Ac[c];
1084
+ for (s = c; s < cols; s++) {
1085
+ Ar[s] = Ar[s] / f;
1086
+ }
1087
+ for (s = 0; s < cols; s++) {
1088
+ Br[s] = Br[s] / f;
1089
+ }
977
1090
  }
978
- return {
979
- type: "element",
980
- id: elementID,
981
- occurence: elementOccurence
982
- };
983
1091
  }
984
1092
  }
985
- return undefined;
1093
+ return B;
986
1094
  };
987
1095
 
988
- const extractOccurence = occurence => {
989
- if (!occurence) {
990
- return 0;
1096
+ var index$d = Object.freeze({
1097
+ __proto__: null,
1098
+ getInitialMatrix: getInitialMatrix,
1099
+ multiplyMatrices: multiplyMatrices,
1100
+ multiplyMatricesArray: multiplyMatricesArray,
1101
+ arrayToMatrix: arrayToMatrix,
1102
+ matrixToArray: matrixToArray,
1103
+ matrix3DToMatrix: matrix3DToMatrix,
1104
+ printMatrix: printMatrix,
1105
+ rotateXMatrix: rotateXMatrix,
1106
+ rotateYMatrix: rotateYMatrix,
1107
+ rotateZMatrix: rotateZMatrix,
1108
+ translateMatrix: translateMatrix,
1109
+ scaleMatrix: scaleMatrix,
1110
+ rotationMatrixFromQuaternion: rotationMatrixFromQuaternion,
1111
+ matrixToCSSMatrix: matrixToCSSMatrix,
1112
+ identityMatrix: identityMatrix,
1113
+ inverseMatrix: inverseMatrix
1114
+ });
1115
+
1116
+ function getMatrixValues(matrix3d) {
1117
+ const matrixValues = matrix3d.split("(")[1].split(")")[0].split(",");
1118
+ const matrixValuesInt = [];
1119
+ for (let i = 0; i < matrixValues.length; i++) {
1120
+ matrixValuesInt[i] = parseFloat(matrixValues[i]);
991
1121
  }
992
- const occurenceMatch = occurence.match(/\[(\d*)\]/);
993
- const occurenceValue = occurenceMatch ? parseInt(occurenceMatch[1]) : 0;
994
- return occurenceValue;
995
- };
1122
+ return matrixValuesInt;
1123
+ }
996
1124
 
997
- const stringInsertInitial = (value, insert) => {
998
- if (!value.startsWith(insert)) {
999
- value = insert + value;
1125
+ function getRotationMatrix(matrix3d) {
1126
+ const valuesMatrix = getMatrixValues(matrix3d);
1127
+ const scale = getScalationValue(matrix3d);
1128
+ if (valuesMatrix.length === 16) {
1129
+ for (let i = 0; i < 11; i++) {
1130
+ valuesMatrix[i] /= scale;
1131
+ }
1132
+ } else if (valuesMatrix.length === 6) {
1133
+ for (let i = 0; i < 4; i++) {
1134
+ valuesMatrix[i] /= scale;
1135
+ }
1000
1136
  }
1001
- return value;
1002
- };
1137
+ const rotationMatrix = valuesMatrix;
1138
+ return rotationMatrix;
1139
+ }
1003
1140
 
1004
- const stringRemoveTrailing = (value, trail) => {
1005
- if (value.endsWith(trail)) {
1006
- value = value.slice(0, value.length - trail.length);
1141
+ function getTranslationMatrix(matrix3d) {
1142
+ const valuesMatrix = getMatrixValues(matrix3d);
1143
+ let translationMatrix;
1144
+ if (valuesMatrix.length === 16) {
1145
+ translationMatrix = getMatrixValues(matrix3d).slice(12, 15);
1146
+ } else if (valuesMatrix.length === 6) {
1147
+ translationMatrix = getMatrixValues(matrix3d).slice(4);
1007
1148
  }
1008
- return value;
1009
- };
1149
+ return translationMatrix;
1150
+ }
1010
1151
 
1011
- const PATH_SEPARATOR = "/";
1152
+ function getScalationValue(matrix3d) {
1153
+ const valuesMatrix = getMatrixValues(matrix3d);
1154
+ let temp = 0;
1155
+ let scale;
1156
+ if (valuesMatrix.length === 16) {
1157
+ const scaleMatrix = getMatrixValues(matrix3d).slice(0, 4);
1158
+ scale = 0;
1159
+ for (const el of scaleMatrix) {
1160
+ scale += parseFloat(el) * parseFloat(el);
1161
+ }
1162
+ scale = parseFloat(Math.sqrt(scale).toPrecision(4));
1163
+ } else if (valuesMatrix.length === 6) {
1164
+ temp = valuesMatrix[0] * valuesMatrix[0] + valuesMatrix[1] * valuesMatrix[1];
1165
+ scale = parseFloat(Math.sqrt(temp).toPrecision(4));
1166
+ }
1167
+ return scale;
1168
+ }
1012
1169
 
1013
- const cleanupPath = value => {
1014
- value = stringInsertInitial(value, PATH_SEPARATOR);
1015
- value = stringRemoveTrailing(value, PATH_SEPARATOR);
1016
- return value;
1017
- };
1170
+ function setTransform(rotationMatrix, translationMatrix, scalationMatrix) {
1171
+ const transformMatrix = multiplyArrayOfMatrices([ translationMatrix, rotationMatrix, scalationMatrix ]);
1172
+ return matrixArrayToCSSMatrix(transformMatrix);
1173
+ }
1018
1174
 
1019
- const computePlaneAddress = (plane, route, origin = "origin") => {
1020
- if (origin === "origin" && typeof location !== "undefined") {
1021
- origin = location.host;
1022
- }
1023
- const cleanPlane = extractPathname(plane);
1024
- const planeAddressType = checkPlaneAddressType(cleanPlane);
1025
- switch (planeAddressType) {
1026
- case "http":
1027
- case "https":
1028
- case "pttp":
1029
- return cleanPlane;
1175
+ function getTransformRotate(matrix3d) {
1176
+ const pi = Math.PI;
1177
+ const values = getRotationMatrix(matrix3d);
1178
+ let rotateX = 0;
1179
+ let rotateY = 0;
1180
+ if (values.length === 6) {
1181
+ const cosa = values[0];
1182
+ const sina = values[1];
1183
+ if (cosa === 1 && sina === 0) {
1184
+ rotateX = Math.asin(sina);
1185
+ rotateY = Math.acos(cosa);
1186
+ }
1030
1187
  }
1031
- origin = stringRemoveTrailing(origin, "/");
1032
- const absolutePlane = isAbsolutePlane(plane);
1033
- const path = route && route !== "/" ? absolutePlane ? cleanupPath(cleanPlane) : cleanupPath(route) + cleanupPath(cleanPlane) : cleanupPath(cleanPlane);
1034
- const planeAddress = pluridData.protocols.plurid + origin + path;
1035
- return planeAddress;
1036
- };
1188
+ if (values.length === 16) {
1189
+ const cosaX1 = values[5];
1190
+ const sinaX3 = values[9];
1191
+ if (sinaX3 <= 0) {
1192
+ rotateX = Math.acos(cosaX1);
1193
+ }
1194
+ if (sinaX3 > 0) {
1195
+ rotateX = 2 * pi - Math.acos(cosaX1);
1196
+ }
1197
+ const cosaY1 = values[0];
1198
+ const sinaY2 = values[2];
1199
+ if (sinaY2 <= 0) {
1200
+ rotateY = Math.acos(cosaY1);
1201
+ }
1202
+ if (sinaY2 > 0) {
1203
+ rotateY = 2 * pi - Math.acos(cosaY1);
1204
+ }
1205
+ rotateX = Math.atan2(values[9], values[5]);
1206
+ rotateY = Math.atan2(values[2], values[0]);
1207
+ }
1208
+ return {
1209
+ rotateX: rotateX,
1210
+ rotateY: rotateY,
1211
+ rotateZ: 0
1212
+ };
1213
+ }
1037
1214
 
1038
- const isAbsolutePlane = value => value[0] === "/";
1215
+ function getTransformTranslate(matrix3d) {
1216
+ const values = getTranslationMatrix(matrix3d);
1217
+ const translateX = values[0];
1218
+ const translateY = values[1];
1219
+ const translateZ = values[2];
1220
+ return {
1221
+ translateX: translateX,
1222
+ translateY: translateY,
1223
+ translateZ: translateZ
1224
+ };
1225
+ }
1039
1226
 
1040
- const checkPlaneAddressType = value => {
1041
- value = value.toLowerCase().trim();
1042
- if (value.startsWith(pluridData.protocols.plurid)) {
1043
- return "pttp";
1044
- }
1045
- if (value.startsWith(pluridData.protocols.https)) {
1046
- return pluridData.HTTPS_PROTOCOL;
1047
- }
1048
- if (value.startsWith(pluridData.protocols.http)) {
1049
- return pluridData.HTTP_PROTOCOL;
1050
- }
1051
- return "relative";
1052
- };
1227
+ function getTransformScale(matrix3d) {
1228
+ const scale = getScalationValue(matrix3d);
1229
+ return {
1230
+ scale: scale
1231
+ };
1232
+ }
1053
1233
 
1054
- const removeTrailingSlash = value => {
1055
- if (value.endsWith("/") && value.length > 1) {
1056
- return value.slice(0, value.length - 1);
1234
+ function rotatePlurid(matrix3d, direction = "", angleIncrement = .07) {
1235
+ const transformRotate = getTransformRotate(matrix3d);
1236
+ const rotateX = transformRotate.rotateX;
1237
+ let rotateY = transformRotate.rotateY;
1238
+ const rotateZ = transformRotate.rotateZ;
1239
+ const transformTranslate = getTransformTranslate(matrix3d);
1240
+ const translateX = transformTranslate.translateX;
1241
+ const translateY = transformTranslate.translateY;
1242
+ const translateZ = transformTranslate.translateZ;
1243
+ const scale = getTransformScale(matrix3d).scale;
1244
+ let valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1245
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1246
+ const valScalationMatrix = scaleMatrix$1(scale);
1247
+ if (direction === "left") {
1248
+ rotateY -= angleIncrement;
1249
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1057
1250
  }
1058
- return value;
1059
- };
1060
-
1061
- const cleanPathValue = value => {
1062
- const queryStart = value.indexOf("?");
1063
- if (queryStart < 0) {
1064
- return removeTrailingSlash(value);
1251
+ if (direction === "right") {
1252
+ rotateY += angleIncrement;
1253
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1065
1254
  }
1066
- return removeTrailingSlash(value.substring(0, queryStart));
1067
- };
1068
-
1069
- const checkParameterLength = (parameter, length, compareType) => {
1070
- const parameterLength = parameter.length;
1071
- switch (compareType) {
1072
- case pluridData.compareTypes.equal:
1073
- return parameterLength === length;
1074
-
1075
- case pluridData.compareTypes.equalLessThan:
1076
- return parameterLength <= length;
1077
-
1078
- case pluridData.compareTypes.lessThan:
1079
- return parameterLength < length;
1080
-
1081
- case pluridData.compareTypes.equalGreaterThan:
1082
- return parameterLength >= length;
1083
-
1084
- case pluridData.compareTypes.greaterThan:
1085
- return parameterLength > length;
1086
-
1087
- default:
1088
- return parameterLength <= length;
1255
+ if (direction === "up") {
1256
+ rotateY -= angleIncrement;
1257
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1089
1258
  }
1090
- };
1091
-
1092
- const checkValidPath = (validationParameters, parameters) => {
1093
- if (validationParameters) {
1094
- for (const [parameterKey, parameterData] of Object.entries(validationParameters)) {
1095
- const {length: length, lengthType: lengthType, startsWith: startsWith, endsWith: endsWith, includes: includes} = parameterData;
1096
- const paramaterValue = parameters[parameterKey];
1097
- if (!paramaterValue) {
1098
- return false;
1099
- }
1100
- if (startsWith && !paramaterValue.startsWith(startsWith)) {
1101
- return false;
1102
- }
1103
- if (endsWith && !paramaterValue.endsWith(endsWith)) {
1104
- return false;
1105
- }
1106
- if (includes && !includes.includes(paramaterValue)) {
1107
- return false;
1108
- }
1109
- if (length) {
1110
- const validLength = checkParameterLength(paramaterValue, length, lengthType);
1111
- return validLength;
1112
- }
1113
- }
1259
+ if (direction === "down") {
1260
+ rotateY += angleIncrement;
1261
+ valRotationMatrix = rotateMatrix(rotateX, rotateY);
1114
1262
  }
1115
- return true;
1116
- };
1263
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1264
+ return transformedMatrix3d;
1265
+ }
1117
1266
 
1118
- const cleanPathElement = path => {
1119
- if (path[0] === "/") {
1120
- return path.slice(1);
1267
+ function translatePlurid(matrix3d, direction = "", linearIncrement = 50) {
1268
+ const transformRotate = getTransformRotate(matrix3d);
1269
+ const rotateX = transformRotate.rotateX;
1270
+ const rotateY = transformRotate.rotateY;
1271
+ const rotateZ = transformRotate.rotateZ;
1272
+ const transformTranslate = getTransformTranslate(matrix3d);
1273
+ let translateX = transformTranslate.translateX;
1274
+ let translateY = transformTranslate.translateY;
1275
+ const translateZ = transformTranslate.translateZ;
1276
+ const scale = getTransformScale(matrix3d).scale;
1277
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1278
+ let valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1279
+ const valScalationMatrix = scaleMatrix$1(scale);
1280
+ scale < .5 ? linearIncrement = 50 : linearIncrement = 30;
1281
+ if (direction === "left") {
1282
+ translateX += linearIncrement;
1283
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1121
1284
  }
1122
- return path;
1123
- };
1124
-
1125
- var index$a = Object.freeze({
1126
- __proto__: null,
1127
- cleanPathElement: cleanPathElement
1128
- });
1129
-
1130
- const mapPathsToRoutes = (paths, view) => {
1131
- const routes = [];
1132
- for (const [key, path] of Object.entries(paths)) {
1133
- const pathView = view[key];
1134
- if (pathView) {
1135
- const route = {
1136
- value: ""
1137
- };
1138
- routes.push(route);
1139
- }
1285
+ if (direction === "right") {
1286
+ translateX -= linearIncrement;
1287
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1140
1288
  }
1141
- return routes;
1142
- };
1143
-
1144
- const pluridLinkPathDivider = route => {
1145
- const windowProtocol = typeof window === "undefined" ? "http" : window.location.protocol.replace(":", "");
1146
- const windowHost = typeof window === "undefined" ? "localhost:63000" : window.location.host;
1147
- const split = route.split("://").filter((value => value !== "")).map((value => cleanPathElement(value)));
1148
- let protocol = windowProtocol;
1149
- const host = {
1150
- value: windowHost,
1151
- controlled: false
1152
- };
1153
- const path = {
1154
- value: "",
1155
- parameters: {},
1156
- query: {}
1157
- };
1158
- const space = {
1159
- value: "",
1160
- parameters: {},
1161
- query: {}
1162
- };
1163
- const universe = {
1164
- value: "",
1165
- parameters: {},
1166
- query: {}
1167
- };
1168
- const cluster = {
1169
- value: "",
1170
- parameters: {},
1171
- query: {}
1172
- };
1173
- const plane = {
1174
- value: "",
1175
- parameters: {},
1176
- query: {},
1177
- fragments: {
1178
- texts: [],
1179
- elements: []
1180
- }
1181
- };
1182
- const valid = false;
1183
- if (split.length === 0 || split.length > 7) {
1184
- const url = {
1185
- protocol: {
1186
- value: protocol,
1187
- secure: true
1188
- },
1189
- host: host,
1190
- path: path,
1191
- space: space,
1192
- universe: universe,
1193
- cluster: cluster,
1194
- plane: plane,
1195
- valid: valid
1196
- };
1197
- return url;
1289
+ if (direction === "up") {
1290
+ translateY += linearIncrement;
1291
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1198
1292
  }
1199
- if (route.startsWith("/://")) {
1200
- const routeSplit = split.slice(1);
1201
- switch (routeSplit.length) {
1202
- case 1:
1203
- path.value = routeSplit[0];
1204
- break;
1293
+ if (direction === "down") {
1294
+ translateY -= linearIncrement;
1295
+ valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1296
+ }
1297
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1298
+ return transformedMatrix3d;
1299
+ }
1205
1300
 
1206
- case 5:
1207
- path.value = routeSplit[0];
1208
- space.value = routeSplit[1];
1209
- universe.value = routeSplit[2];
1210
- cluster.value = routeSplit[3];
1211
- plane.value = routeSplit[4];
1212
- break;
1301
+ function scalePlurid(matrix3d, direction = "", scaleIncrement = .05) {
1302
+ const transformRotate = getTransformRotate(matrix3d);
1303
+ const rotateX = transformRotate.rotateX;
1304
+ const rotateY = transformRotate.rotateY;
1305
+ const rotateZ = transformRotate.rotateZ;
1306
+ const transformTranslate = getTransformTranslate(matrix3d);
1307
+ const translateX = transformTranslate.translateX;
1308
+ const translateY = transformTranslate.translateY;
1309
+ const translateZ = transformTranslate.translateZ;
1310
+ let scale = getTransformScale(matrix3d).scale;
1311
+ const valRotationMatrix = rotateMatrix(rotateX, rotateY, rotateZ);
1312
+ const valTranslationMatrix = translateMatrix$1(translateX, translateY, translateZ);
1313
+ let valScalationMatrix = scaleMatrix$1(scale);
1314
+ if (direction === "up") {
1315
+ scale -= scaleIncrement;
1316
+ if (scale < .1) {
1317
+ scale = .1;
1213
1318
  }
1214
- const url = {
1215
- protocol: {
1216
- value: protocol,
1217
- secure: true
1218
- },
1219
- host: host,
1220
- path: path,
1221
- space: space,
1222
- universe: universe,
1223
- cluster: cluster,
1224
- plane: plane,
1225
- valid: true
1226
- };
1227
- return url;
1319
+ valScalationMatrix = scaleMatrix$1(scale);
1228
1320
  }
1229
- if (split[0] !== "http" && split[0] !== "https" && split[0] !== "chrome-extension") {
1230
- switch (split.length) {
1231
- case 1:
1232
- plane.value = split[0];
1233
- break;
1234
-
1235
- case 2:
1236
- cluster.value = split[0];
1237
- plane.value = split[1];
1238
- break;
1239
-
1240
- case 3:
1241
- universe.value = split[0];
1242
- cluster.value = split[1];
1243
- plane.value = split[2];
1244
- break;
1321
+ if (direction === "down") {
1322
+ scale += scaleIncrement;
1323
+ if (scale > 4) {
1324
+ scale = 4;
1325
+ }
1326
+ valScalationMatrix = scaleMatrix$1(scale);
1327
+ }
1328
+ const transformedMatrix3d = setTransform(valRotationMatrix, valTranslationMatrix, valScalationMatrix);
1329
+ return transformedMatrix3d;
1330
+ }
1245
1331
 
1246
- case 4:
1247
- space.value = split[0];
1248
- universe.value = split[1];
1249
- cluster.value = split[2];
1250
- plane.value = split[3];
1251
- break;
1332
+ var index$c = Object.freeze({
1333
+ __proto__: null,
1334
+ getMatrixValues: getMatrixValues,
1335
+ getRotationMatrix: getRotationMatrix,
1336
+ getTranslationMatrix: getTranslationMatrix,
1337
+ getScalationValue: getScalationValue,
1338
+ setTransform: setTransform,
1339
+ getTransformRotate: getTransformRotate,
1340
+ getTransformTranslate: getTransformTranslate,
1341
+ getTransformScale: getTransformScale,
1342
+ rotatePlurid: rotatePlurid,
1343
+ translatePlurid: translatePlurid,
1344
+ scalePlurid: scalePlurid
1345
+ });
1252
1346
 
1253
- case 5:
1254
- path.value = split[0];
1255
- space.value = split[1];
1256
- universe.value = split[2];
1257
- cluster.value = split[3];
1258
- plane.value = split[4];
1259
- break;
1347
+ var index$b = Object.freeze({
1348
+ __proto__: null,
1349
+ general: index$d,
1350
+ matrix3d: index$c
1351
+ });
1260
1352
 
1261
- case 6:
1262
- host.value = split[0];
1263
- path.value = split[1];
1264
- space.value = split[2];
1265
- universe.value = split[3];
1266
- cluster.value = split[4];
1267
- plane.value = split[5];
1268
- break;
1353
+ var index$a = Object.freeze({
1354
+ __proto__: null,
1355
+ direction: index$g,
1356
+ matrix: index$e,
1357
+ quaternion: index$f,
1358
+ transform: index$b
1359
+ });
1269
1360
 
1270
- default:
1271
- const url = {
1272
- protocol: {
1273
- value: protocol,
1274
- secure: true
1275
- },
1276
- host: host,
1277
- path: path,
1278
- space: space,
1279
- universe: universe,
1280
- cluster: cluster,
1281
- plane: plane,
1282
- valid: valid
1283
- };
1284
- return url;
1285
- }
1286
- } else {
1287
- switch (split.length) {
1288
- case 3:
1289
- protocol = split[0];
1290
- host.value = split[1];
1291
- path.value = split[2];
1292
- break;
1361
+ const internatiolate = (lamguage, field) => pluridData.internationalization[lamguage][field];
1293
1362
 
1294
- case 7:
1295
- protocol = split[0];
1296
- host.value = split[1];
1297
- path.value = split[2];
1298
- space.value = split[3];
1299
- universe.value = split[4];
1300
- cluster.value = split[5];
1301
- plane.value = split[6];
1302
- break;
1363
+ const resolvePluridPlaneData = plane => {
1364
+ if (Array.isArray(plane)) {
1365
+ const [route, component, options] = plane;
1366
+ return Object.assign({
1367
+ route: route,
1368
+ component: component
1369
+ }, options);
1370
+ }
1371
+ return plane;
1372
+ };
1303
1373
 
1304
- default:
1305
- const url = {
1306
- protocol: {
1307
- value: protocol,
1308
- secure: true
1309
- },
1310
- host: host,
1311
- path: path,
1312
- space: space,
1313
- universe: universe,
1314
- cluster: cluster,
1315
- plane: plane,
1316
- valid: valid
1317
- };
1318
- return url;
1319
- }
1374
+ const resolvePluridRoutePlaneData = plane => {
1375
+ if (Array.isArray(plane)) {
1376
+ const [value, component, options] = plane;
1377
+ return Object.assign({
1378
+ value: value,
1379
+ component: component
1380
+ }, options);
1320
1381
  }
1321
- const url = {
1322
- protocol: {
1323
- value: protocol,
1324
- secure: true
1325
- },
1326
- host: host,
1327
- path: path,
1328
- space: space,
1329
- universe: universe,
1330
- cluster: cluster,
1331
- plane: plane,
1332
- valid: true
1333
- };
1334
- return url;
1382
+ return plane;
1335
1383
  };
1336
1384
 
1337
- const resolveRoute = (route, protocol, host) => {
1338
- const windowProtocol = typeof window === "undefined" ? protocol || "http" : window.location.protocol.replace(":", "");
1339
- const windowHost = typeof window === "undefined" ? host || "localhost:63000" : window.location.host;
1340
- const divisions = pluridLinkPathDivider(route);
1341
- const defaultPathname = typeof window !== "undefined" ? window.location.pathname === "/" ? "p" : window.location.pathname.slice(1) : divisions.path.value ? divisions.path.value : "p";
1342
- const protocolDivision = divisions.protocol.value || windowProtocol;
1343
- const hostDivision = divisions.host.value ? divisions.host : {
1344
- value: windowHost,
1345
- controlled: true
1346
- };
1347
- const path = divisions.path.value ? divisions.path : {
1348
- value: defaultPathname,
1349
- parameters: {},
1350
- query: {}
1351
- };
1352
- const space = divisions.space.value ? divisions.space : {
1353
- value: "s",
1354
- parameters: {},
1355
- query: {}
1356
- };
1357
- const universe = divisions.universe.value ? divisions.universe : {
1358
- value: "u",
1359
- parameters: {},
1360
- query: {}
1361
- };
1362
- const cluster = divisions.cluster.value ? divisions.cluster : {
1363
- value: "c",
1364
- parameters: {},
1365
- query: {}
1366
- };
1367
- const plane = divisions.plane;
1368
- const separator = "://";
1369
- if (!plane.value && route !== "/") {
1370
- const resolvers = [ protocolDivision, hostDivision.value, path.value ];
1371
- const absoluteRoute = resolvers.join(separator);
1372
- return {
1373
- protocol: protocolDivision,
1374
- host: hostDivision,
1375
- path: path,
1376
- space: space,
1377
- universe: universe,
1378
- cluster: cluster,
1379
- plane: plane,
1380
- route: absoluteRoute
1381
- };
1385
+ const getPluridPlaneIDByData = element => {
1386
+ if (!element) {
1387
+ return "";
1382
1388
  }
1383
- [ protocolDivision, hostDivision.value, path.value, space.value, universe.value, cluster.value, cleanPathElement(plane.value) ];
1384
- return {
1385
- protocol: "",
1386
- host: "",
1387
- path: path,
1388
- space: "",
1389
- universe: "",
1390
- cluster: "",
1391
- plane: "",
1392
- route: route
1393
- };
1389
+ const parent = element.parentElement;
1390
+ if (parent && parent.dataset.pluridPlane) {
1391
+ return parent.dataset.pluridPlane;
1392
+ }
1393
+ return getPluridPlaneIDByData(parent);
1394
1394
  };
1395
1395
 
1396
1396
  class IsoMatcher {
@@ -1399,7 +1399,7 @@ class IsoMatcher {
1399
1399
  this.planesIndex = new Map;
1400
1400
  this.routesKeys = [];
1401
1401
  this.planesKeys = [];
1402
- if (origin === "origin" && typeof location !== "undefined") {
1402
+ if (origin === "origin" && typeof location !== "undefined" && location.host) {
1403
1403
  this.origin = location.host;
1404
1404
  } else {
1405
1405
  this.origin = origin;
@@ -2665,7 +2665,7 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2665
2665
  view: view
2666
2666
  }, hostname);
2667
2667
  const computedTree = spaceTree.compute();
2668
- const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign({
2668
+ const stateSpace = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2669
2669
  loading: true,
2670
2670
  animatedTransform: false,
2671
2671
  transformTime: 450,
@@ -2675,6 +2675,7 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2675
2675
  translationX: 0,
2676
2676
  translationY: 0,
2677
2677
  translationZ: 0,
2678
+ transform: "matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)",
2678
2679
  activeUniverseID: "",
2679
2680
  camera: {
2680
2681
  x: 0,
@@ -2696,9 +2697,13 @@ const resolveSpace = (view, configuration, planesRegistrar, currentState, localS
2696
2697
  }
2697
2698
  },
2698
2699
  culledView: [],
2699
- view: view,
2700
+ activePlaneID: "",
2701
+ isolatePlane: "",
2702
+ lastClosedPlane: "",
2700
2703
  tree: computedTree
2701
- }, 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);
2704
+ }, 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), {
2705
+ view: view
2706
+ });
2702
2707
  if (currentState) {
2703
2708
  stateSpace.translationX = currentState.space.translationX;
2704
2709
  stateSpace.translationY = currentState.space.translationY;
@@ -2817,9 +2822,9 @@ const pluridRouterNavigate = path => {
2817
2822
 
2818
2823
  exports.cleanTemplate = cleanTemplate;
2819
2824
 
2820
- exports.general = index$i;
2825
+ exports.general = index$h;
2821
2826
 
2822
- exports.interaction = index$b;
2827
+ exports.interaction = index$a;
2823
2828
 
2824
2829
  exports.internatiolate = internatiolate;
2825
2830
 
@@ -2833,5 +2838,5 @@ exports.space = index$2;
2833
2838
 
2834
2839
  exports.state = index;
2835
2840
 
2836
- exports.utilities = index$a;
2841
+ exports.utilities = index$j;
2837
2842
  //# sourceMappingURL=index.js.map