@zumer/orbit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/orbit.js ADDED
@@ -0,0 +1,586 @@
1
+
2
+ /*
3
+ * orbit
4
+ * v.0.0.1
5
+ * Author Juan Martin Muda - Zumerlab
6
+ * License MIT
7
+ **/
8
+ (() => {
9
+ // src/js/orbit-progress.js
10
+ var OrbitProgress = class extends HTMLElement {
11
+ constructor() {
12
+ super();
13
+ this.attachShadow({ mode: "open" });
14
+ this.shadowRoot.innerHTML = `
15
+ <style>
16
+ :host {
17
+ display: block;
18
+
19
+ }
20
+ svg {
21
+ width: 100%;
22
+ height: 100%;
23
+ overflow: visible;
24
+ pointer-events: none;
25
+ }
26
+ svg * {
27
+ pointer-events: stroke;
28
+ }
29
+ .progress-bar {
30
+ fill: transparent;
31
+ stroke: var(--o-progress-color);
32
+ transition: stroke 0.3s;
33
+ }
34
+ .progress-bg {
35
+ stroke: var(--o-bg-color, transparent);
36
+ }
37
+ :host(:hover) .progress-bar {
38
+ stroke: var(--o-hover-progress-color, var(--o-progress-color));
39
+
40
+ }
41
+ </style>
42
+ <svg viewBox="0 0 100 100">
43
+ <defs></defs>
44
+ <path class="progress-bg"></path>
45
+ <path class="progress-bar"></path>
46
+ </svg>
47
+ `;
48
+ }
49
+ connectedCallback() {
50
+ this.update();
51
+ const observer = new MutationObserver((mutations) => {
52
+ mutations.forEach((mutation) => {
53
+ this.update();
54
+ });
55
+ });
56
+ observer.observe(this, { attributes: true, childList: true });
57
+ }
58
+ update() {
59
+ const { shape } = this.getAttributes();
60
+ const svg = this.shadowRoot.querySelector("svg");
61
+ const defs = this.createDefs();
62
+ if (shape !== "none") {
63
+ defs.appendChild(this.createMarker("head", "end"));
64
+ defs.appendChild(this.createMarker("tail", "start"));
65
+ }
66
+ const progressBg = this.shadowRoot.querySelector(".progress-bg");
67
+ const progressBar = this.shadowRoot.querySelector(".progress-bar");
68
+ this.updateArc(progressBg, true);
69
+ this.updateArc(progressBar, false);
70
+ svg.querySelector("defs").replaceWith(defs);
71
+ }
72
+ createSVGElement() {
73
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
74
+ svg.setAttribute("viewBox", "0 0 100 100");
75
+ svg.setAttribute("width", this.getAttribute("width") || "100%");
76
+ svg.setAttribute("height", this.getAttribute("height") || "100%");
77
+ return svg;
78
+ }
79
+ updateArc(arc, full) {
80
+ const {
81
+ strokeWidth,
82
+ realRadius,
83
+ ellipseX,
84
+ ellipseY,
85
+ progressBarColor,
86
+ progressBgColor,
87
+ maxAngle,
88
+ shape
89
+ } = this.getAttributes();
90
+ const angle = this.getProgressAngle(maxAngle, full);
91
+ const { d } = this.calculateArcParameters(angle, realRadius, ellipseX, ellipseY);
92
+ arc.setAttribute("d", d);
93
+ arc.setAttribute("stroke", full ? progressBgColor : progressBarColor);
94
+ arc.setAttribute("fill", "transparent");
95
+ if (shape !== "none") {
96
+ arc.setAttribute("marker-end", "url(#head)");
97
+ arc.setAttribute("marker-start", "url(#tail)");
98
+ }
99
+ arc.setAttribute("stroke-width", strokeWidth);
100
+ arc.setAttribute("vector-effect", "non-scaling-stroke");
101
+ }
102
+ getAttributes() {
103
+ const orbitRadius = parseFloat(
104
+ getComputedStyle(this).getPropertyValue("r") || 0
105
+ );
106
+ const range = parseFloat(
107
+ getComputedStyle(this).getPropertyValue("--o-range") || 360
108
+ );
109
+ const ellipseX = parseFloat(
110
+ getComputedStyle(this).getPropertyValue("--o-ellipse-x") || 1
111
+ );
112
+ const ellipseY = parseFloat(
113
+ getComputedStyle(this).getPropertyValue("--o-ellipse-y") || 1
114
+ );
115
+ const progress = parseFloat(
116
+ getComputedStyle(this).getPropertyValue("--o-progress") || this.getAttribute("value") || 0
117
+ );
118
+ const shape = this.getAttribute("shape") || "none";
119
+ const progressBarColor = this.getAttribute("bar-color");
120
+ const progressBgColor = this.getAttribute("bgcolor") || "transparent";
121
+ const strokeWidth = parseFloat(
122
+ getComputedStyle(this).getPropertyValue("stroke-width") || 1
123
+ );
124
+ let strokeWithPercentage = strokeWidth / 2 * 100 / orbitRadius / 2;
125
+ let innerOuter = strokeWithPercentage;
126
+ if (this.classList.contains("outer-orbit")) {
127
+ innerOuter = strokeWithPercentage * 2;
128
+ }
129
+ if (this.classList.contains("quarter-outer-orbit")) {
130
+ innerOuter = strokeWithPercentage * 1.75;
131
+ }
132
+ if (this.classList.contains("inner-orbit")) {
133
+ innerOuter = 0;
134
+ }
135
+ if (this.classList.contains("quarter-inner-orbit")) {
136
+ innerOuter = strokeWithPercentage * 0.75;
137
+ }
138
+ const realRadius = 50 + innerOuter - strokeWithPercentage;
139
+ const maxAngle = range;
140
+ return {
141
+ orbitRadius,
142
+ ellipseX,
143
+ ellipseY,
144
+ progress,
145
+ progressBarColor,
146
+ progressBgColor,
147
+ strokeWidth,
148
+ realRadius,
149
+ maxAngle,
150
+ shape
151
+ };
152
+ }
153
+ getProgressAngle(maxAngle, full) {
154
+ const progress = parseFloat(
155
+ getComputedStyle(this).getPropertyValue("--o-progress") || this.getAttribute("value") || 0
156
+ );
157
+ const maxValue = parseFloat(this.getAttribute("max")) || 100;
158
+ return full ? (maxValue - 1e-5) / maxValue * maxAngle : progress / maxValue * maxAngle;
159
+ }
160
+ calculateArcParameters(angle, realRadius, ellipseX, ellipseY) {
161
+ const radiusX = realRadius / ellipseX;
162
+ const radiusY = realRadius / ellipseY;
163
+ const startX = 50 + radiusX * Math.cos(-Math.PI / 2);
164
+ const startY = 50 + radiusY * Math.sin(-Math.PI / 2);
165
+ const endX = 50 + radiusX * Math.cos((angle - 90) * Math.PI / 180);
166
+ const endY = 50 + radiusY * Math.sin((angle - 90) * Math.PI / 180);
167
+ const largeArcFlag = angle <= 180 ? 0 : 1;
168
+ const d = `M ${startX},${startY} A ${radiusX},${radiusY} 0 ${largeArcFlag} 1 ${endX},${endY}`;
169
+ return { startX, startY, endX, endY, largeArcFlag, d };
170
+ }
171
+ createDefs() {
172
+ const defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
173
+ return defs;
174
+ }
175
+ createMarker(id, position = "end") {
176
+ const { shape } = this.getAttributes();
177
+ const marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
178
+ marker.setAttribute("id", id);
179
+ marker.setAttribute("viewBox", "0 0 10 10");
180
+ if (position === "start" && shape !== "circle") {
181
+ marker.setAttribute("refX", "2");
182
+ } else if (position === "start" && shape === "circle") {
183
+ marker.setAttribute("refX", "5");
184
+ } else {
185
+ marker.setAttribute("refX", "0.1");
186
+ }
187
+ marker.setAttribute("refY", "5");
188
+ marker.setAttribute("markerWidth", "1");
189
+ marker.setAttribute("markerHeight", "1");
190
+ marker.setAttribute("orient", "auto");
191
+ marker.setAttribute("markerUnits", "strokeWidth");
192
+ marker.setAttribute("fill", "context-stroke");
193
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
194
+ const shapes = {
195
+ arrow: {
196
+ head: "M 0 0 L 2 5 L 0 10 z",
197
+ tail: "M 2 0 L 0 0 L 1 5 L 0 10 L 2 10 L 2 5 z"
198
+ },
199
+ slash: {
200
+ head: "M 0 0 L 0 0 L 1 5 L 2 10 L 0 10 L 0 5 z",
201
+ tail: "M 2 0 L 0 0 L 1 5 L 2 10 L 2 10 L 2 5 z"
202
+ },
203
+ backslash: {
204
+ head: "M 0 0 L 2 0 L 1 5 L 0 10 L 0 10 L 0 5 z",
205
+ tail: "M 2 0 L 2 0 L 1 5 L 0 10 L 2 10 L 2 5 z"
206
+ },
207
+ circle: {
208
+ head: "M 0 0 C 7 0 7 10 0 10 z",
209
+ tail: "M 6 0 C -1 0 -1 10 6 10 z"
210
+ },
211
+ zigzag: {
212
+ head: "M 1 0 L 0 0 L 0 5 L 0 10 L 1 10 L 2 7 L 1 5 L 2 3 z",
213
+ tail: "M 0 0 L 2 0 L 2 5 L 2 10 L 0 10 L 1 7 L 0 5 L 1 3 z"
214
+ }
215
+ };
216
+ if (position === "end") {
217
+ path.setAttribute("d", shapes[shape].head);
218
+ } else {
219
+ path.setAttribute("d", shapes[shape].tail);
220
+ }
221
+ marker.appendChild(path);
222
+ return marker;
223
+ }
224
+ };
225
+
226
+ // src/js/orbit-sector.js
227
+ var template = document.createElement("template");
228
+ template.innerHTML = `
229
+ <style>
230
+ :host {
231
+ display: inline-block;
232
+ }
233
+ svg {
234
+ width: 100%;
235
+ height: 100%;
236
+ overflow: visible;
237
+ pointer-events: none;
238
+ }
239
+ svg * {
240
+ pointer-events: stroke;
241
+ }
242
+ .sector {
243
+ stroke: var(--o-sector-color, var(--o-cyan-light));
244
+ transition: stroke 0.3s;
245
+ }
246
+
247
+ :host(:hover) .sector {
248
+ stroke: var(--o-hover-sector-color, var(--o-sector-color));
249
+
250
+ }
251
+ </style>
252
+ <svg viewBox="0 0 100 100">
253
+ <defs></defs>
254
+ <path class="sector" vector-effect="non-scaling-stroke" fill="transparent"></path>
255
+ </svg>
256
+ `;
257
+ var OrbitSector = class extends HTMLElement {
258
+ constructor() {
259
+ super();
260
+ this.attachShadow({ mode: "open" });
261
+ this.shadowRoot.appendChild(template.content.cloneNode(true));
262
+ }
263
+ connectedCallback() {
264
+ this.update();
265
+ const observer = new MutationObserver((mutations) => {
266
+ mutations.forEach((mutation) => {
267
+ this.update();
268
+ });
269
+ });
270
+ observer.observe(this, { attributes: true, childList: true });
271
+ }
272
+ update() {
273
+ const { shape } = this.getAttributes();
274
+ const svg = this.shadowRoot.querySelector("svg");
275
+ const path = this.shadowRoot.querySelector("path");
276
+ const defs = this.shadowRoot.querySelector("defs");
277
+ if (shape !== "none") {
278
+ defs.innerHTML = "";
279
+ defs.appendChild(this.createMarker("head", "end"));
280
+ defs.appendChild(this.createMarker("tail", "start"));
281
+ path.setAttribute("marker-end", "url(#head)");
282
+ path.setAttribute("marker-start", "url(#tail)");
283
+ }
284
+ const { strokeWidth, realRadius, sectorColor, gap } = this.getAttributes();
285
+ const angle = this.calculateAngle();
286
+ const { d } = this.calculateArcParameters(angle, realRadius, gap);
287
+ path.setAttribute("d", d);
288
+ path.setAttribute("stroke", sectorColor);
289
+ path.setAttribute("stroke-width", strokeWidth);
290
+ }
291
+ getAttributes() {
292
+ const orbitRadius = parseFloat(getComputedStyle(this).getPropertyValue("r") || 0);
293
+ const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap") || 1e-3);
294
+ const shape = this.getAttribute("shape") || "none";
295
+ const sectorColor = this.getAttribute("sector-color");
296
+ const rawAngle = getComputedStyle(this).getPropertyValue("--o-angle");
297
+ const strokeWidth = parseFloat(getComputedStyle(this).getPropertyValue("stroke-width") || 1);
298
+ const strokeWithPercentage = strokeWidth / 2 * 100 / orbitRadius / 2;
299
+ let innerOuter = strokeWithPercentage;
300
+ if (this.classList.contains("outer-orbit")) {
301
+ innerOuter = strokeWithPercentage * 2;
302
+ }
303
+ if (this.classList.contains("quarter-outer-orbit")) {
304
+ innerOuter = strokeWithPercentage * 1.75;
305
+ }
306
+ if (this.classList.contains("inner-orbit")) {
307
+ innerOuter = 0;
308
+ }
309
+ if (this.classList.contains("quarter-inner-orbit")) {
310
+ innerOuter = strokeWithPercentage * 0.75;
311
+ }
312
+ const realRadius = 50 + innerOuter - strokeWithPercentage;
313
+ const sectorAngle = calcularExpresionCSS(rawAngle);
314
+ return {
315
+ orbitRadius,
316
+ strokeWidth,
317
+ realRadius,
318
+ sectorColor,
319
+ gap,
320
+ sectorAngle,
321
+ shape
322
+ };
323
+ }
324
+ calculateAngle() {
325
+ const { sectorAngle, gap } = this.getAttributes();
326
+ return sectorAngle - gap;
327
+ }
328
+ calculateArcParameters(angle, realRadius, gap) {
329
+ const radiusX = realRadius / 1;
330
+ const radiusY = realRadius / 1;
331
+ const startX = 50 + radiusX * Math.cos(-Math.PI / 2);
332
+ const startY = 50 + radiusY * Math.sin(-Math.PI / 2);
333
+ const endX = 50 + radiusX * Math.cos((angle - 90) * Math.PI / 180);
334
+ const endY = 50 + radiusY * Math.sin((angle - 90) * Math.PI / 180);
335
+ const largeArcFlag = angle <= 180 ? 0 : 1;
336
+ const d = `M ${startX},${startY} A ${radiusX},${radiusY} 0 ${largeArcFlag} 1 ${endX},${endY}`;
337
+ return { startX, startY, endX, endY, largeArcFlag, d };
338
+ }
339
+ createMarker(id, position = "end") {
340
+ const { shape } = this.getAttributes();
341
+ const marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
342
+ marker.setAttribute("id", id);
343
+ marker.setAttribute("viewBox", "0 0 10 10");
344
+ position === "start" && shape !== "circle" ? marker.setAttribute("refX", "2") : position === "start" && shape === "circle" ? marker.setAttribute("refX", "5") : marker.setAttribute("refX", "0.1");
345
+ marker.setAttribute("refY", "5");
346
+ marker.setAttribute("markerWidth", "1");
347
+ marker.setAttribute("markerHeight", "1");
348
+ marker.setAttribute("orient", "auto");
349
+ marker.setAttribute("markerUnits", "strokeWidth");
350
+ marker.setAttribute("fill", "context-stroke");
351
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
352
+ const shapes = {
353
+ arrow: {
354
+ head: "M 0 0 L 2 5 L 0 10 z",
355
+ tail: "M 2 0 L 0 0 L 1 5 L 0 10 L 2 10 L 2 5 z"
356
+ },
357
+ slash: {
358
+ head: "M 0 0 L 0 0 L 1 5 L 2 10 L 0 10 L 0 5 z",
359
+ tail: "M 2 0 L 0 0 L 1 5 L 2 10 L 2 10 L 2 5 z"
360
+ },
361
+ backslash: {
362
+ head: "M 0 0 L 2 0 L 1 5 L 0 10 L 0 10 L 0 5 z",
363
+ tail: "M 2 0 L 2 0 L 1 5 L 0 10 L 2 10 L 2 5 z"
364
+ },
365
+ circle: {
366
+ head: "M 0 0 C 7 0 7 10 0 10 z",
367
+ tail: "M 6 0 C -1 0 -1 10 6 10 z"
368
+ },
369
+ zigzag: {
370
+ head: "M 1 0 L 0 0 L 0 5 L 0 10 L 1 10 L 2 7 L 1 5 L 2 3 z",
371
+ tail: "M 0 0 L 2 0 L 2 5 L 2 10 L 0 10 L 1 7 L 0 5 L 1 3 z"
372
+ }
373
+ };
374
+ position === "end" ? path.setAttribute("d", shapes[shape].head) : path.setAttribute("d", shapes[shape].tail);
375
+ marker.appendChild(path);
376
+ return marker;
377
+ }
378
+ };
379
+ function calcularExpresionCSS(cssExpression) {
380
+ const match = cssExpression.match(/calc\(\s*([\d.]+)deg\s*\/\s*\(\s*(\d+)\s*-\s*(\d+)\s*\)\s*\)/);
381
+ if (match) {
382
+ const value = parseFloat(match[1]);
383
+ const divisor = parseInt(match[2]) - parseInt(match[3]);
384
+ if (!isNaN(value) && !isNaN(divisor) && divisor !== 0) {
385
+ return value / divisor;
386
+ }
387
+ }
388
+ }
389
+
390
+ // src/js/orbit-label.js
391
+ var OrbitLabel = class extends HTMLElement {
392
+ constructor() {
393
+ super();
394
+ this.attachShadow({ mode: "open" });
395
+ const template2 = document.createElement("template");
396
+ template2.innerHTML = `
397
+ <svg viewBox="0 0 100 100" >
398
+ <path id="orbitPath" fill="none" vector-effect="non-scaling-stroke"></path>
399
+ <text>
400
+ <textPath href="#orbitPath" alignment-baseline="middle"></textPath>
401
+ </text>
402
+ </svg>
403
+ <style>
404
+ :host {
405
+ display: inline-block;
406
+
407
+ }
408
+ svg {
409
+ width: 100%;
410
+ height: 100%;
411
+ overflow: visible;
412
+ pointer-events: none;
413
+
414
+ }
415
+ svg * {
416
+ pointer-events: stroke;
417
+ }
418
+
419
+ path {
420
+ fill: transparent;
421
+ stroke: var(--o-label-color);
422
+ transition: stroke 0.3s;
423
+ }
424
+
425
+ :host(:hover) path {
426
+ stroke: var(--o-hover-label-color, var(--o-label-color));
427
+
428
+ }
429
+
430
+
431
+ </style>
432
+ `;
433
+ this.shadowRoot.appendChild(template2.content.cloneNode(true));
434
+ }
435
+ connectedCallback() {
436
+ this.update();
437
+ const observer = new MutationObserver((mutations) => {
438
+ mutations.forEach((mutation) => {
439
+ this.update();
440
+ });
441
+ });
442
+ observer.observe(this, { attributes: true, childList: true });
443
+ }
444
+ update() {
445
+ const path = this.shadowRoot.getElementById("orbitPath");
446
+ const text = this.shadowRoot.querySelector("text");
447
+ const textPath = this.shadowRoot.querySelector("textPath");
448
+ const { d, strokeWidth, lineCap } = this.getPathAttributes();
449
+ path.setAttribute("d", d);
450
+ path.setAttribute("stroke-width", strokeWidth);
451
+ path.setAttribute("stroke-linecap", lineCap);
452
+ const { length, fontSize, textAnchor, fitRange } = this.getTextAttributes();
453
+ if (textAnchor === "start") {
454
+ textPath.setAttribute("startOffset", "0%");
455
+ textPath.setAttribute("text-anchor", "start");
456
+ } else if (textAnchor === "middle") {
457
+ textPath.setAttribute("startOffset", "50%");
458
+ textPath.setAttribute("text-anchor", "middle");
459
+ } else if (textAnchor === "end") {
460
+ textPath.setAttribute("startOffset", "100%");
461
+ textPath.setAttribute("text-anchor", "end");
462
+ }
463
+ if (fitRange) {
464
+ textPath.parentElement.setAttribute("textLength", path.getTotalLength());
465
+ }
466
+ text.style.fontSize = `calc(${fontSize} * (100 / (${length}) * (12 / var(--o-orbit-number) ))`;
467
+ textPath.textContent = this.textContent.trim();
468
+ }
469
+ getPathAttributes() {
470
+ const { realRadius, gap, labelBgColor, flip, lineCap, strokeWidth } = this.getAttributes();
471
+ const angle = this.calculateAngle();
472
+ const { d } = this.calculateArcParameters(angle, realRadius, gap, flip);
473
+ return { d, strokeWidth, labelBgColor, lineCap };
474
+ }
475
+ getTextAttributes() {
476
+ const { length, fontSize, textAnchor, fitRange } = this.getAttributes();
477
+ return { length, fontSize, textAnchor, fitRange };
478
+ }
479
+ getAttributes() {
480
+ const orbitRadius = parseFloat(getComputedStyle(this).getPropertyValue("r") || 0);
481
+ const flip = this.hasAttribute("flip");
482
+ const fitRange = this.hasAttribute("fit-range");
483
+ const lineCap = getComputedStyle(this).getPropertyValue("--o-linecap") || "butt";
484
+ const gap = parseFloat(getComputedStyle(this).getPropertyValue("--o-gap") || 1e-3);
485
+ const length = parseFloat(getComputedStyle(this).getPropertyValue("--o-length"));
486
+ const textAnchor = this.getAttribute("text-anchor") || "start";
487
+ const fontSize = getComputedStyle(this).getPropertyValue("font-size") || getComputedStyle(this).getPropertyValue("--font-size");
488
+ const rawAngle = getComputedStyle(this).getPropertyValue("--o-angle");
489
+ const strokeWidth = parseFloat(getComputedStyle(this).getPropertyValue("stroke-width") || 1);
490
+ let strokeWithPercentage = strokeWidth / 2 * 100 / orbitRadius / 2;
491
+ let innerOuter = strokeWithPercentage;
492
+ if (this.classList.contains("outer-orbit")) {
493
+ innerOuter = strokeWithPercentage * 2;
494
+ }
495
+ if (this.classList.contains("quarter-outer-orbit")) {
496
+ innerOuter = strokeWithPercentage * 1.75;
497
+ }
498
+ if (this.classList.contains("inner-orbit")) {
499
+ innerOuter = 0;
500
+ }
501
+ if (this.classList.contains("quarter-inner-orbit")) {
502
+ innerOuter = strokeWithPercentage * 0.75;
503
+ }
504
+ const realRadius = 50 + innerOuter - strokeWithPercentage;
505
+ const labelAngle = calcularExpresionCSS2(rawAngle);
506
+ return {
507
+ orbitRadius,
508
+ strokeWidth,
509
+ realRadius,
510
+ length,
511
+ fontSize,
512
+ gap,
513
+ labelAngle,
514
+ flip,
515
+ textAnchor,
516
+ lineCap,
517
+ fitRange
518
+ };
519
+ }
520
+ calculateAngle() {
521
+ const { labelAngle, gap } = this.getAttributes();
522
+ return labelAngle - gap;
523
+ }
524
+ calculateArcParameters(angle, realRadius, gap, flip) {
525
+ const radiusX = realRadius / 1;
526
+ const radiusY = realRadius / 1;
527
+ let startX, startY, endX, endY, largeArcFlag, d;
528
+ if (flip) {
529
+ startX = 50 - gap + radiusX * Math.cos(-Math.PI / 2);
530
+ startY = 50 + radiusY * Math.sin(-Math.PI / 2);
531
+ endX = 50 + radiusX * Math.cos((270 - angle) * Math.PI / 180);
532
+ endY = 50 + radiusY * Math.sin((270 - angle) * Math.PI / 180);
533
+ largeArcFlag = angle <= 180 ? 0 : 1;
534
+ d = `M ${startX},${startY} A ${radiusX},${radiusY} 0 ${largeArcFlag} 0 ${endX},${endY}`;
535
+ } else {
536
+ startX = 50 + gap + radiusX * Math.cos(-Math.PI / 2);
537
+ startY = 50 + radiusY * Math.sin(-Math.PI / 2);
538
+ endX = 50 + radiusX * Math.cos((angle - 90) * Math.PI / 180);
539
+ endY = 50 + radiusY * Math.sin((angle - 90) * Math.PI / 180);
540
+ largeArcFlag = angle <= 180 ? 0 : 1;
541
+ d = `M ${startX},${startY} A ${radiusX},${radiusY} 0 ${largeArcFlag} 1 ${endX},${endY}`;
542
+ }
543
+ return { startX, startY, endX, endY, largeArcFlag, d };
544
+ }
545
+ };
546
+ function calcularExpresionCSS2(cssExpression) {
547
+ const match = cssExpression.match(/calc\(\s*([\d.]+)deg\s*\/\s*\(\s*(\d+)\s*-\s*(\d+)\s*\)\s*\)/);
548
+ if (match) {
549
+ const value = parseFloat(match[1]);
550
+ const divisor = parseInt(match[2]) - parseInt(match[3]);
551
+ if (!isNaN(value) && !isNaN(divisor) && divisor !== 0) {
552
+ return value / divisor;
553
+ }
554
+ }
555
+ }
556
+
557
+ // src/js/orbit-resize.js
558
+ var Orbit = {};
559
+ Orbit = {
560
+ resize: (parentElementSelector) => {
561
+ const parentElement = document.querySelector(parentElementSelector);
562
+ if (!parentElement) {
563
+ console.error(`No se encontr\xF3 ning\xFAn elemento con el selector ${parentElementSelector}`);
564
+ return;
565
+ }
566
+ const resizeObserver = new ResizeObserver((entries) => {
567
+ for (let entry of entries) {
568
+ const { width } = entry.contentRect;
569
+ const childElement = parentElement.querySelector(".orbit-zone");
570
+ if (childElement) {
571
+ childElement.style.setProperty("--o-length", `${width}px`);
572
+ } else {
573
+ console.error("No se encontr\xF3 ning\xFAn elemento hijo con la clase .child-element");
574
+ }
575
+ }
576
+ });
577
+ resizeObserver.observe(parentElement);
578
+ }
579
+ };
580
+
581
+ // src/orbit.js
582
+ customElements.define("o-progress", OrbitProgress);
583
+ customElements.define("o-sector", OrbitSector);
584
+ customElements.define("o-label", OrbitLabel);
585
+ window.Orbit = Orbit;
586
+ })();