@nice2dev/ui-math 1.1.10 → 1.2.1

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/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- var T = Object.defineProperty;
2
- var R = (e, t, r) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var M = (e, t, r) => R(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
- import { NiceAppShell, NiceIcon } from "@nice2dev/ui";
6
- import { NiceTutorialButton, resolveTutorial, resolveCssColor, NiceIcon as NiceIcon$1 } from "@nice2dev/ui-core";
7
- import React, { createContext, useMemo, useContext, useState, useRef, useCallback, useEffect } from "react";
8
- const translations = {
1
+ var pe = Object.defineProperty;
2
+ var ue = (e, t, r) => t in e ? pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var T = (e, t, r) => ue(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as d, jsxs as v, Fragment as oe } from "react/jsx-runtime";
5
+ import { NiceAppShell as ge, NiceIcon as X } from "@nice2dev/ui";
6
+ import { NiceTutorialButton as xe, resolveTutorial as me, resolveCssColor as I, NiceIcon as G } from "@nice2dev/ui-core";
7
+ import ye, { useMemo as he, useContext as j, createContext as F, useState as P, useRef as U, useCallback as R, useEffect as V } from "react";
8
+ const J = {
9
9
  en: {
10
10
  "calculator.matrixA": "Matrix A",
11
11
  "calculator.matrixB": "Matrix B",
@@ -21,7 +21,12 @@ const translations = {
21
21
  "editor.clear": "Clear",
22
22
  "editor.recognize": "Recognize",
23
23
  "editor.recognizing": "Recognizing...",
24
- "editor.handwritingNote": "Draw your equation above. Handwriting recognition requires external API integration."
24
+ "editor.latexInput": "LaTeX Input",
25
+ "editor.handwriting": "Handwriting",
26
+ "editor.handwritingNote": "Draw your equation above. Handwriting recognition requires external API integration.",
27
+ "editor.templates": "Templates",
28
+ "editor.copyLatex": "Copy LaTeX",
29
+ "plotter.close": "Close"
25
30
  },
26
31
  pl: {
27
32
  "calculator.matrixA": "Macierz A",
@@ -38,7 +43,12 @@ const translations = {
38
43
  "editor.clear": "Wyczyść",
39
44
  "editor.recognize": "Rozpoznaj",
40
45
  "editor.recognizing": "Rozpoznawanie...",
41
- "editor.handwritingNote": "Narysuj równanie powyżej. Rozpoznawanie pisma wymaga zewnętrznej integracji API."
46
+ "editor.latexInput": "Wpis LaTeX",
47
+ "editor.handwriting": "Pismo odręczne",
48
+ "editor.handwritingNote": "Narysuj równanie powyżej. Rozpoznawanie pisma wymaga zewnętrznej integracji API.",
49
+ "editor.templates": "Szablony",
50
+ "editor.copyLatex": "Kopiuj LaTeX",
51
+ "plotter.close": "Zamknij"
42
52
  },
43
53
  de: {
44
54
  "calculator.matrixA": "Matrix A",
@@ -55,7 +65,12 @@ const translations = {
55
65
  "editor.clear": "Löschen",
56
66
  "editor.recognize": "Erkennen",
57
67
  "editor.recognizing": "Erkennung läuft...",
58
- "editor.handwritingNote": "Zeichnen Sie Ihre Gleichung oben. Die Handschrifterkennung erfordert eine externe API-Integration."
68
+ "editor.latexInput": "LaTeX-Eingabe",
69
+ "editor.handwriting": "Handschrift",
70
+ "editor.handwritingNote": "Zeichnen Sie Ihre Gleichung oben. Die Handschrifterkennung erfordert eine externe API-Integration.",
71
+ "editor.templates": "Vorlagen",
72
+ "editor.copyLatex": "LaTeX kopieren",
73
+ "plotter.close": "Schließen"
59
74
  },
60
75
  fr: {
61
76
  "calculator.matrixA": "Matrice A",
@@ -72,7 +87,12 @@ const translations = {
72
87
  "editor.clear": "Effacer",
73
88
  "editor.recognize": "Reconnaître",
74
89
  "editor.recognizing": "Reconnaissance...",
75
- "editor.handwritingNote": "Dessinez votre équation ci-dessus. La reconnaissance d'écriture nécessite une intégration API externe."
90
+ "editor.latexInput": "Saisie LaTeX",
91
+ "editor.handwriting": "Écriture manuscrite",
92
+ "editor.handwritingNote": "Dessinez votre équation ci-dessus. La reconnaissance d'écriture nécessite une intégration API externe.",
93
+ "editor.templates": "Modèles",
94
+ "editor.copyLatex": "Copier le LaTeX",
95
+ "plotter.close": "Fermer"
76
96
  },
77
97
  es: {
78
98
  "calculator.matrixA": "Matriz A",
@@ -89,7 +109,12 @@ const translations = {
89
109
  "editor.clear": "Borrar",
90
110
  "editor.recognize": "Reconocer",
91
111
  "editor.recognizing": "Reconociendo...",
92
- "editor.handwritingNote": "Dibuja tu ecuación arriba. El reconocimiento de escritura requiere integración con una API externa."
112
+ "editor.latexInput": "Entrada LaTeX",
113
+ "editor.handwriting": "Escritura a mano",
114
+ "editor.handwritingNote": "Dibuja tu ecuación arriba. El reconocimiento de escritura requiere integración con una API externa.",
115
+ "editor.templates": "Plantillas",
116
+ "editor.copyLatex": "Copiar LaTeX",
117
+ "plotter.close": "Cerrar"
93
118
  },
94
119
  it: {
95
120
  "calculator.matrixA": "Matrice A",
@@ -106,7 +131,12 @@ const translations = {
106
131
  "editor.clear": "Cancella",
107
132
  "editor.recognize": "Riconosci",
108
133
  "editor.recognizing": "Riconoscimento...",
109
- "editor.handwritingNote": "Disegna la tua equazione qui sopra. Il riconoscimento della scrittura richiede un’integrazione API esterna."
134
+ "editor.latexInput": "Input LaTeX",
135
+ "editor.handwriting": "Scrittura a mano",
136
+ "editor.handwritingNote": "Disegna la tua equazione qui sopra. Il riconoscimento della scrittura richiede un’integrazione API esterna.",
137
+ "editor.templates": "Modelli",
138
+ "editor.copyLatex": "Copia LaTeX",
139
+ "plotter.close": "Chiudi"
110
140
  },
111
141
  pt: {
112
142
  "calculator.matrixA": "Matriz A",
@@ -123,7 +153,12 @@ const translations = {
123
153
  "editor.clear": "Limpar",
124
154
  "editor.recognize": "Reconhecer",
125
155
  "editor.recognizing": "A reconhecer...",
126
- "editor.handwritingNote": "Desenhe a sua equação acima. O reconhecimento de escrita requer integração com uma API externa."
156
+ "editor.latexInput": "Entrada LaTeX",
157
+ "editor.handwriting": "Escrita à mão",
158
+ "editor.handwritingNote": "Desenhe a sua equação acima. O reconhecimento de escrita requer integração com uma API externa.",
159
+ "editor.templates": "Modelos",
160
+ "editor.copyLatex": "Copiar LaTeX",
161
+ "plotter.close": "Fechar"
127
162
  },
128
163
  cs: {
129
164
  "calculator.matrixA": "Matice A",
@@ -140,7 +175,12 @@ const translations = {
140
175
  "editor.clear": "Vymazat",
141
176
  "editor.recognize": "Rozpoznat",
142
177
  "editor.recognizing": "Rozpoznávání...",
143
- "editor.handwritingNote": "Nakreslete svou rovnici výše. Rozpoznávání rukopisu vyžaduje externí integraci API."
178
+ "editor.latexInput": "Zadání LaTeX",
179
+ "editor.handwriting": "Rukopis",
180
+ "editor.handwritingNote": "Nakreslete svou rovnici výše. Rozpoznávání rukopisu vyžaduje externí integraci API.",
181
+ "editor.templates": "Šablony",
182
+ "editor.copyLatex": "Kopírovat LaTeX",
183
+ "plotter.close": "Zavřít"
144
184
  },
145
185
  uk: {
146
186
  "calculator.matrixA": "Матриця A",
@@ -157,23 +197,28 @@ const translations = {
157
197
  "editor.clear": "Очистити",
158
198
  "editor.recognize": "Розпізнати",
159
199
  "editor.recognizing": "Розпізнавання...",
160
- "editor.handwritingNote": "Намалюйте своє рівняння вище. Розпізнавання рукопису потребує зовнішньої інтеграції з API."
161
- }
162
- }, I18nContext = createContext({
200
+ "editor.latexInput": "Введення LaTeX",
201
+ "editor.handwriting": "Рукопис",
202
+ "editor.handwritingNote": "Намалюйте своє рівняння вище. Розпізнавання рукопису потребує зовнішньої інтеграції з API.",
203
+ "editor.templates": "Шаблони",
204
+ "editor.copyLatex": "Копіювати LaTeX",
205
+ "plotter.close": "Закрити"
206
+ }
207
+ }, ae = /* @__PURE__ */ F({
163
208
  locale: "en",
164
209
  t: (e, t) => t ?? e
165
210
  });
166
- function NiceI18nProvider({ locale: e = "en", overrides: t, children: r }) {
167
- const a = useMemo(() => {
168
- const o = { ...translations.en, ...translations[e], ...t };
169
- return { locale: e, t: (i, l) => o[i] ?? l ?? i };
211
+ function Qe({ locale: e = "en", overrides: t, children: r }) {
212
+ const o = he(() => {
213
+ const a = { ...J.en, ...J[e], ...t };
214
+ return { locale: e, t: (i, c) => a[i] ?? c ?? i };
170
215
  }, [e, t]);
171
- return React.createElement(I18nContext.Provider, { value: a }, r);
216
+ return ye.createElement(ae.Provider, { value: o }, r);
172
217
  }
173
- function useNiceTranslation() {
174
- return useContext(I18nContext);
218
+ function L() {
219
+ return j(ae);
175
220
  }
176
- const MATH_EDITOR_TOUR = [
221
+ const fe = [
177
222
  {
178
223
  target: ".nice-math-editor",
179
224
  titleKey: "tutorial.mathEditor.intro.title",
@@ -182,7 +227,7 @@ const MATH_EDITOR_TOUR = [
182
227
  content: "Write equations as LaTeX or insert symbols from the palette; switch to handwriting input, and preview the rendered formula live.",
183
228
  placement: "auto"
184
229
  }
185
- ], MATH_SYMBOLS = [
230
+ ], be = [
186
231
  // Greek lowercase
187
232
  { name: "alpha", latex: "\\alpha", category: "greek", preview: "α" },
188
233
  { name: "beta", latex: "\\beta", category: "greek", preview: "β" },
@@ -359,10 +404,10 @@ const MATH_EDITOR_TOUR = [
359
404
  preview: "{ }"
360
405
  }
361
406
  ];
362
- function getSymbolsByCategory(e) {
363
- return MATH_SYMBOLS.filter((t) => t.category === e);
407
+ function ve(e) {
408
+ return be.filter((t) => t.category === e);
364
409
  }
365
- const EQUATION_TEMPLATES = [
410
+ const we = [
366
411
  // Basic
367
412
  { name: "Fraction", latex: "\\frac{a}{b}", category: "basic" },
368
413
  { name: "Square root", latex: "\\sqrt{x}", category: "basic" },
@@ -421,11 +466,11 @@ const EQUATION_TEMPLATES = [
421
466
  category: "physics"
422
467
  }
423
468
  ];
424
- class MathEditorService {
469
+ class ke {
425
470
  constructor(t = {}) {
426
- M(this, "equations", /* @__PURE__ */ new Map());
427
- M(this, "config");
428
- M(this, "nextNumber");
471
+ T(this, "equations", /* @__PURE__ */ new Map());
472
+ T(this, "config");
473
+ T(this, "nextNumber");
429
474
  this.config = {
430
475
  enableNumbering: t.enableNumbering ?? !0,
431
476
  startNumber: t.startNumber ?? 1,
@@ -434,7 +479,7 @@ class MathEditorService {
434
479
  }
435
480
  /** Create new equation */
436
481
  createEquation(t, r) {
437
- const a = {
482
+ const o = {
438
483
  id: this.generateId(),
439
484
  latex: t,
440
485
  label: r,
@@ -442,17 +487,17 @@ class MathEditorService {
442
487
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
443
488
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
444
489
  };
445
- return this.equations.set(a.id, a), a;
490
+ return this.equations.set(o.id, o), o;
446
491
  }
447
492
  /** Update equation */
448
- updateEquation(t, r, a) {
449
- const o = this.equations.get(t);
450
- if (!o)
493
+ updateEquation(t, r, o) {
494
+ const a = this.equations.get(t);
495
+ if (!a)
451
496
  throw new Error(`Equation not found: ${t}`);
452
497
  const n = {
453
- ...o,
498
+ ...a,
454
499
  latex: r,
455
- label: a ?? o.label,
500
+ label: o ?? a.label,
456
501
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
457
502
  };
458
503
  return this.equations.set(t, n), n;
@@ -488,14 +533,14 @@ class MathEditorService {
488
533
  }
489
534
  /** Parse LaTeX and extract equations */
490
535
  parseLatex(t) {
491
- const r = [], a = /\\\[([\s\S]*?)\\\]/g;
492
- let o;
493
- for (; (o = a.exec(t)) !== null; )
494
- r.push(this.createEquation(o[1].trim()));
536
+ const r = [], o = /\\\[([\s\S]*?)\\\]/g;
537
+ let a;
538
+ for (; (a = o.exec(t)) !== null; )
539
+ r.push(this.createEquation(a[1].trim()));
495
540
  const n = /\\begin\{equation\}([\s\S]*?)\\end\{equation\}/g;
496
- for (; (o = n.exec(t)) !== null; ) {
497
- const i = o[1].match(/\\label\{([^}]+)\}/), l = o[1].replace(/\\label\{[^}]+\}/, "").trim();
498
- r.push(this.createEquation(l, i == null ? void 0 : i[1]));
541
+ for (; (a = n.exec(t)) !== null; ) {
542
+ const i = a[1].match(/\\label\{([^}]+)\}/), c = a[1].replace(/\\label\{[^}]+\}/, "").trim();
543
+ r.push(this.createEquation(c, i == null ? void 0 : i[1]));
499
544
  }
500
545
  return r;
501
546
  }
@@ -503,24 +548,24 @@ class MathEditorService {
503
548
  return Date.now().toString(36) + Math.random().toString(36).substring(2, 8);
504
549
  }
505
550
  }
506
- function createMathEditorService(e) {
507
- return new MathEditorService(e);
551
+ function Je(e) {
552
+ return new ke(e);
508
553
  }
509
- async function recognizeHandwriting(e) {
554
+ async function Ce(e) {
510
555
  return await new Promise((r) => setTimeout(r, 500)), {
511
- latex: e.reduce((r, a) => r + a.points.length, 0) > 50 ? "\\sqrt{x^2 + y^2}" : "x",
556
+ latex: e.reduce((r, o) => r + o.points.length, 0) > 50 ? "\\sqrt{x^2 + y^2}" : "x",
512
557
  confidence: 0.85,
513
558
  alternatives: ["x", "X", "\\times"]
514
559
  };
515
560
  }
516
- const MathEditorContext = createContext(null);
517
- function useMathEditor() {
518
- const e = useContext(MathEditorContext);
561
+ const ne = /* @__PURE__ */ F(null);
562
+ function W() {
563
+ const e = j(ne);
519
564
  if (!e)
520
565
  throw new Error("useMathEditor must be used within MathEditorProvider");
521
566
  return e;
522
567
  }
523
- const styles$3 = {
568
+ const A = {
524
569
  toolbar: {
525
570
  display: "flex",
526
571
  gap: "8px",
@@ -603,108 +648,110 @@ const styles$3 = {
603
648
  cursor: "crosshair"
604
649
  }
605
650
  };
606
- function NiceMathEditor({
651
+ function et({
607
652
  service: e,
608
653
  initialLatex: t = "",
609
654
  onChange: r,
610
- className: a,
611
- style: o,
655
+ className: o,
656
+ style: a,
612
657
  tutorial: n
613
658
  }) {
614
- const { t: i } = useNiceTranslation(), [l, p] = useState(t), [s, d] = useState("input"), g = useRef(null), y = useCallback(
615
- (f) => {
616
- p(f), r == null || r(f);
659
+ const { t: i } = L(), [c, u] = P(t), [s, p] = P("input"), m = U(null), y = R(
660
+ (b) => {
661
+ u(b), r == null || r(b);
617
662
  },
618
663
  [r]
619
- ), h = useCallback(
620
- (f) => {
621
- const c = g.current;
622
- if (!c) {
623
- y(l + f);
664
+ ), f = R(
665
+ (b) => {
666
+ const l = m.current;
667
+ if (!l) {
668
+ y(c + b);
624
669
  return;
625
670
  }
626
- const x = c.selectionStart, b = c.selectionEnd, k = l.slice(0, x) + f + l.slice(b);
627
- y(k), setTimeout(() => {
628
- c.focus(), c.selectionStart = c.selectionEnd = x + f.length;
671
+ const g = l.selectionStart, w = l.selectionEnd, M = c.slice(0, g) + b + c.slice(w);
672
+ y(M), setTimeout(() => {
673
+ l.focus(), l.selectionStart = l.selectionEnd = g + b.length;
629
674
  }, 0);
630
675
  },
631
- [l, y]
632
- ), w = useCallback(
633
- (f) => {
634
- h(f.latex);
676
+ [c, y]
677
+ ), C = R(
678
+ (b) => {
679
+ f(b.latex);
635
680
  },
636
- [h]
637
- ), u = {
681
+ [f]
682
+ ), x = {
638
683
  service: e,
639
- latex: l,
684
+ latex: c,
640
685
  setLatex: y,
641
- insertSymbol: h,
642
- insertTemplate: w,
686
+ insertSymbol: f,
687
+ insertTemplate: C,
643
688
  mode: s,
644
- setMode: d
689
+ setMode: p
645
690
  };
646
- return /* @__PURE__ */ jsx(MathEditorContext.Provider, { value: u, children: /* @__PURE__ */ jsxs(
647
- NiceAppShell,
691
+ return /* @__PURE__ */ d(ne.Provider, { value: x, children: /* @__PURE__ */ v(
692
+ ge,
648
693
  {
649
694
  flush: !0,
650
- className: `nice-math-editor ${a ?? ""}`,
651
- style: { position: "relative", ...o },
652
- toolbar: /* @__PURE__ */ jsx(Toolbar$1, {}),
653
- sidebar: /* @__PURE__ */ jsx(SymbolPalette, {}),
695
+ className: `nice-math-editor ${o ?? ""}`,
696
+ style: { position: "relative", ...a },
697
+ toolbar: /* @__PURE__ */ d(Pe, {}),
698
+ sidebar: /* @__PURE__ */ d(Me, {}),
654
699
  children: [
655
- /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ jsx(NiceTutorialButton, { steps: resolveTutorial(n, MATH_EDITOR_TOUR) }) }),
656
- /* @__PURE__ */ jsx("div", { style: styles$3.editor, children: s === "input" ? /* @__PURE__ */ jsxs(Fragment, { children: [
657
- /* @__PURE__ */ jsx(
700
+ /* @__PURE__ */ d("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ d(xe, { steps: me(n, fe) }) }),
701
+ /* @__PURE__ */ d("div", { style: A.editor, children: s === "input" ? /* @__PURE__ */ v(oe, { children: [
702
+ /* @__PURE__ */ d(
658
703
  "textarea",
659
704
  {
660
- ref: g,
661
- value: l,
662
- onChange: (f) => y(f.target.value),
705
+ ref: m,
706
+ value: c,
707
+ onChange: (b) => y(b.target.value),
663
708
  placeholder: i("editor.latexPlaceholder", "Enter LaTeX equation..."),
664
- style: styles$3.input
709
+ style: A.input
665
710
  }
666
711
  ),
667
- /* @__PURE__ */ jsx(LatexPreview, { latex: l })
668
- ] }) : /* @__PURE__ */ jsx(HandwritingCanvas, {}) })
712
+ /* @__PURE__ */ d(Se, { latex: c })
713
+ ] }) : /* @__PURE__ */ d(Be, {}) })
669
714
  ]
670
715
  }
671
716
  ) });
672
717
  }
673
- function Toolbar$1() {
674
- const { mode: e, setMode: t, latex: r, insertTemplate: a } = useMathEditor(), [o, n] = useState(!1);
675
- return /* @__PURE__ */ jsxs("div", { style: styles$3.toolbar, children: [
676
- /* @__PURE__ */ jsxs(
718
+ function Pe() {
719
+ const { t: e } = L(), { mode: t, setMode: r, latex: o, insertTemplate: a } = W(), [n, i] = P(!1);
720
+ return /* @__PURE__ */ v("div", { style: A.toolbar, children: [
721
+ /* @__PURE__ */ v(
677
722
  "button",
678
723
  {
679
- onClick: () => t("input"),
724
+ onClick: () => r("input"),
680
725
  style: {
681
- ...styles$3.button,
682
- backgroundColor: e === "input" ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-bg-tertiary, #9e9e9e)",
726
+ ...A.button,
727
+ backgroundColor: t === "input" ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-bg-tertiary, #9e9e9e)",
683
728
  // the inactive state sits on a theme surface: theme text, not the button's white
684
- color: e === "input" ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text-primary, #fff)"
729
+ color: t === "input" ? "var(--nice-color-white, #fff)" : "var(--nice-text-primary, #fff)"
685
730
  },
686
731
  children: [
687
- /* @__PURE__ */ jsx(NiceIcon, { name: "keyboard", size: 14 }),
688
- " LaTeX Input"
732
+ /* @__PURE__ */ d(X, { name: "keyboard", size: 14 }),
733
+ " ",
734
+ e("editor.latexInput", "LaTeX Input")
689
735
  ]
690
736
  }
691
737
  ),
692
- /* @__PURE__ */ jsxs(
738
+ /* @__PURE__ */ v(
693
739
  "button",
694
740
  {
695
- onClick: () => t("handwriting"),
741
+ onClick: () => r("handwriting"),
696
742
  style: {
697
- ...styles$3.button,
698
- backgroundColor: e === "handwriting" ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-bg-tertiary, #9e9e9e)",
699
- color: e === "handwriting" ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text-primary, #fff)"
743
+ ...A.button,
744
+ backgroundColor: t === "handwriting" ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-bg-tertiary, #9e9e9e)",
745
+ color: t === "handwriting" ? "var(--nice-color-white, #fff)" : "var(--nice-text-primary, #fff)"
700
746
  },
701
747
  children: [
702
- /* @__PURE__ */ jsx(NiceIcon, { name: "pen", size: 14 }),
703
- " Handwriting"
748
+ /* @__PURE__ */ d(X, { name: "pen", size: 14 }),
749
+ " ",
750
+ e("editor.handwriting", "Handwriting")
704
751
  ]
705
752
  }
706
753
  ),
707
- /* @__PURE__ */ jsx(
754
+ /* @__PURE__ */ d(
708
755
  "div",
709
756
  {
710
757
  style: {
@@ -714,13 +761,15 @@ function Toolbar$1() {
714
761
  }
715
762
  }
716
763
  ),
717
- /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
718
- /* @__PURE__ */ jsxs("button", { onClick: () => n(!o), style: styles$3.button, children: [
719
- /* @__PURE__ */ jsx(NiceIcon, { name: "ruler", size: 14 }),
720
- " Templates ",
721
- /* @__PURE__ */ jsx(NiceIcon, { name: "chevron-down", size: 12 })
764
+ /* @__PURE__ */ v("div", { style: { position: "relative" }, children: [
765
+ /* @__PURE__ */ v("button", { onClick: () => i(!n), style: A.button, children: [
766
+ /* @__PURE__ */ d(X, { name: "ruler", size: 14 }),
767
+ " ",
768
+ e("editor.templates", "Templates"),
769
+ " ",
770
+ /* @__PURE__ */ d(X, { name: "chevron-down", size: 12 })
722
771
  ] }),
723
- o && /* @__PURE__ */ jsx(
772
+ n && /* @__PURE__ */ d(
724
773
  "div",
725
774
  {
726
775
  style: {
@@ -737,24 +786,24 @@ function Toolbar$1() {
737
786
  overflow: "auto"
738
787
  },
739
788
  children: ["basic", "calculus", "algebra", "geometry", "statistics", "physics"].map(
740
- (i) => /* @__PURE__ */ jsxs("div", { children: [
741
- /* @__PURE__ */ jsx("div", { style: styles$3.categoryHeader, children: i }),
742
- EQUATION_TEMPLATES.filter((l) => l.category === i).map((l) => /* @__PURE__ */ jsxs(
789
+ (c) => /* @__PURE__ */ v("div", { children: [
790
+ /* @__PURE__ */ d("div", { style: A.categoryHeader, children: c }),
791
+ we.filter((u) => u.category === c).map((u) => /* @__PURE__ */ v(
743
792
  "div",
744
793
  {
745
794
  onClick: () => {
746
- a(l), n(!1);
795
+ a(u), i(!1);
747
796
  },
748
797
  style: {
749
798
  padding: "8px 12px",
750
799
  cursor: "pointer",
751
800
  borderBottom: "1px solid var(--nice-border, #eee)"
752
801
  },
753
- onMouseOver: (p) => p.target.style.backgroundColor = "var(--nice-bg-secondary, #f5f5f5)",
754
- onMouseOut: (p) => p.target.style.backgroundColor = "transparent",
802
+ onMouseOver: (s) => s.target.style.backgroundColor = "var(--nice-bg-secondary, #f5f5f5)",
803
+ onMouseOut: (s) => s.target.style.backgroundColor = "transparent",
755
804
  children: [
756
- /* @__PURE__ */ jsx("div", { style: { fontWeight: 500 }, children: l.name }),
757
- /* @__PURE__ */ jsxs(
805
+ /* @__PURE__ */ d("div", { style: { fontWeight: 500 }, children: u.name }),
806
+ /* @__PURE__ */ v(
758
807
  "div",
759
808
  {
760
809
  style: {
@@ -763,36 +812,37 @@ function Toolbar$1() {
763
812
  fontFamily: "monospace"
764
813
  },
765
814
  children: [
766
- l.latex.substring(0, 40),
767
- l.latex.length > 40 ? "..." : ""
815
+ u.latex.substring(0, 40),
816
+ u.latex.length > 40 ? "..." : ""
768
817
  ]
769
818
  }
770
819
  )
771
820
  ]
772
821
  },
773
- l.name
822
+ u.name
774
823
  ))
775
- ] }, i)
824
+ ] }, c)
776
825
  )
777
826
  }
778
827
  )
779
828
  ] }),
780
- /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
781
- /* @__PURE__ */ jsxs(
829
+ /* @__PURE__ */ d("div", { style: { flex: 1 } }),
830
+ /* @__PURE__ */ v(
782
831
  "button",
783
832
  {
784
- onClick: () => navigator.clipboard.writeText(r),
785
- style: { ...styles$3.button, backgroundColor: "var(--nice-success, #4caf50)" },
833
+ onClick: () => navigator.clipboard.writeText(o),
834
+ style: { ...A.button, backgroundColor: "var(--nice-success, #4caf50)" },
786
835
  children: [
787
- /* @__PURE__ */ jsx(NiceIcon, { name: "copy", size: 14 }),
788
- " Copy LaTeX"
836
+ /* @__PURE__ */ d(X, { name: "copy", size: 14 }),
837
+ " ",
838
+ e("editor.copyLatex", "Copy LaTeX")
789
839
  ]
790
840
  }
791
841
  )
792
842
  ] });
793
843
  }
794
- function SymbolPalette() {
795
- const { insertSymbol: e } = useMathEditor(), [t, r] = useState("greek"), a = [
844
+ function Me() {
845
+ const { insertSymbol: e } = W(), [t, r] = P("greek"), o = [
796
846
  "greek",
797
847
  "operators",
798
848
  "relations",
@@ -804,9 +854,9 @@ function SymbolPalette() {
804
854
  "logic",
805
855
  "calculus",
806
856
  "matrices"
807
- ], o = getSymbolsByCategory(t);
808
- return /* @__PURE__ */ jsxs("div", { style: styles$3.sidebar, children: [
809
- /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", padding: "8px", gap: "4px" }, children: a.map((n) => /* @__PURE__ */ jsx(
857
+ ], a = ve(t);
858
+ return /* @__PURE__ */ v("div", { style: A.sidebar, children: [
859
+ /* @__PURE__ */ d("div", { style: { display: "flex", flexWrap: "wrap", padding: "8px", gap: "4px" }, children: o.map((n) => /* @__PURE__ */ d(
810
860
  "button",
811
861
  {
812
862
  onClick: () => r(n),
@@ -816,18 +866,18 @@ function SymbolPalette() {
816
866
  border: "1px solid var(--nice-border, #ddd)",
817
867
  borderRadius: "4px",
818
868
  backgroundColor: t === n ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-bg, #fff)",
819
- color: t === n ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text, #333)",
869
+ color: t === n ? "var(--nice-color-white, #fff)" : "var(--nice-text, #333)",
820
870
  cursor: "pointer"
821
871
  },
822
872
  children: n
823
873
  },
824
874
  n
825
875
  )) }),
826
- /* @__PURE__ */ jsx("div", { style: styles$3.symbolGrid, children: o.map((n) => /* @__PURE__ */ jsx(
876
+ /* @__PURE__ */ d("div", { style: A.symbolGrid, children: a.map((n) => /* @__PURE__ */ d(
827
877
  "button",
828
878
  {
829
879
  onClick: () => e(n.latex),
830
- style: styles$3.symbolButton,
880
+ style: A.symbolButton,
831
881
  title: `${n.name}: ${n.latex}`,
832
882
  children: n.preview || n.latex
833
883
  },
@@ -835,122 +885,122 @@ function SymbolPalette() {
835
885
  )) })
836
886
  ] });
837
887
  }
838
- function LatexPreview({ latex: e }) {
839
- return /* @__PURE__ */ jsxs("div", { style: styles$3.preview, children: [
840
- /* @__PURE__ */ jsx(
888
+ function Se({ latex: e }) {
889
+ return /* @__PURE__ */ v("div", { style: A.preview, children: [
890
+ /* @__PURE__ */ d(
841
891
  "div",
842
892
  {
843
893
  style: { fontSize: "12px", color: "var(--nice-text-secondary, #666)", marginBottom: "8px" },
844
894
  children: "Preview (requires KaTeX/MathJax integration):"
845
895
  }
846
896
  ),
847
- /* @__PURE__ */ jsx("code", { style: { fontSize: "16px" }, children: e || "(empty)" })
897
+ /* @__PURE__ */ d("code", { style: { fontSize: "16px" }, children: e || "(empty)" })
848
898
  ] });
849
899
  }
850
- function HandwritingCanvas() {
851
- const { t: e } = useNiceTranslation(), { setLatex: t, setMode: r } = useMathEditor(), a = useRef(null), [o, n] = useState([]), [i, l] = useState([]), [p, s] = useState(!1), [d, g] = useState(!1), y = (c) => {
852
- const x = a.current;
853
- if (!x)
900
+ function Be() {
901
+ const { t: e } = L(), { setLatex: t, setMode: r } = W(), o = U(null), [a, n] = P([]), [i, c] = P([]), [u, s] = P(!1), [p, m] = P(!1), y = (l) => {
902
+ const g = o.current;
903
+ if (!g)
854
904
  return;
855
905
  s(!0);
856
- const b = x.getBoundingClientRect();
857
- l([
906
+ const w = g.getBoundingClientRect();
907
+ c([
858
908
  {
859
- x: c.clientX - b.left,
860
- y: c.clientY - b.top,
861
- pressure: c.pressure,
909
+ x: l.clientX - w.left,
910
+ y: l.clientY - w.top,
911
+ pressure: l.pressure,
862
912
  timestamp: Date.now()
863
913
  }
864
914
  ]);
865
- }, h = (c) => {
866
- if (!p)
915
+ }, f = (l) => {
916
+ if (!u)
867
917
  return;
868
- const x = a.current, b = x == null ? void 0 : x.getContext("2d");
869
- if (!x || !b)
918
+ const g = o.current, w = g == null ? void 0 : g.getContext("2d");
919
+ if (!g || !w)
870
920
  return;
871
- const k = x.getBoundingClientRect(), m = {
872
- x: c.clientX - k.left,
873
- y: c.clientY - k.top,
874
- pressure: c.pressure,
921
+ const M = g.getBoundingClientRect(), h = {
922
+ x: l.clientX - M.left,
923
+ y: l.clientY - M.top,
924
+ pressure: l.pressure,
875
925
  timestamp: Date.now()
876
926
  };
877
- if (l((v) => [...v, m]), i.length > 0) {
878
- const v = i[i.length - 1];
879
- b.beginPath(), b.moveTo(v.x, v.y), b.lineTo(m.x, m.y), b.strokeStyle = resolveCssColor("var(--nice-text, #000)", b.canvas), b.lineWidth = 2, b.lineCap = "round", b.stroke();
927
+ if (c((k) => [...k, h]), i.length > 0) {
928
+ const k = i[i.length - 1];
929
+ w.beginPath(), w.moveTo(k.x, k.y), w.lineTo(h.x, h.y), w.strokeStyle = I("var(--nice-text, #000)", w.canvas), w.lineWidth = 2, w.lineCap = "round", w.stroke();
880
930
  }
881
- }, w = () => {
882
- if (p) {
931
+ }, C = () => {
932
+ if (u) {
883
933
  if (s(!1), i.length > 1) {
884
- const c = {
934
+ const l = {
885
935
  id: Date.now().toString(),
886
936
  points: [...i]
887
937
  };
888
- n((x) => [...x, c]);
938
+ n((g) => [...g, l]);
889
939
  }
890
- l([]);
940
+ c([]);
891
941
  }
892
- }, u = () => {
893
- const c = a.current, x = c == null ? void 0 : c.getContext("2d");
894
- x && c && x.clearRect(0, 0, c.width, c.height), n([]);
895
- }, f = async () => {
896
- if (o.length !== 0) {
897
- g(!0);
942
+ }, x = () => {
943
+ const l = o.current, g = l == null ? void 0 : l.getContext("2d");
944
+ g && l && g.clearRect(0, 0, l.width, l.height), n([]);
945
+ }, b = async () => {
946
+ if (a.length !== 0) {
947
+ m(!0);
898
948
  try {
899
- const c = await recognizeHandwriting(o);
900
- t(c.latex), r("input");
949
+ const l = await Ce(a);
950
+ t(l.latex), r("input");
901
951
  } finally {
902
- g(!1);
952
+ m(!1);
903
953
  }
904
954
  }
905
955
  };
906
- return useEffect(() => {
907
- const c = a.current;
908
- c && (c.width = c.offsetWidth, c.height = 200);
909
- }, []), /* @__PURE__ */ jsxs("div", { children: [
910
- /* @__PURE__ */ jsx(
956
+ return V(() => {
957
+ const l = o.current;
958
+ l && (l.width = l.offsetWidth, l.height = 200);
959
+ }, []), /* @__PURE__ */ v("div", { children: [
960
+ /* @__PURE__ */ d(
911
961
  "canvas",
912
962
  {
913
- ref: a,
914
- style: styles$3.canvas,
963
+ ref: o,
964
+ style: A.canvas,
915
965
  onPointerDown: y,
916
- onPointerMove: h,
917
- onPointerUp: w,
918
- onPointerLeave: w
966
+ onPointerMove: f,
967
+ onPointerUp: C,
968
+ onPointerLeave: C
919
969
  }
920
970
  ),
921
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", marginTop: "12px" }, children: [
922
- /* @__PURE__ */ jsx(
971
+ /* @__PURE__ */ v("div", { style: { display: "flex", gap: "8px", marginTop: "12px" }, children: [
972
+ /* @__PURE__ */ d(
923
973
  "button",
924
974
  {
925
- onClick: u,
926
- style: { ...styles$3.button, backgroundColor: "var(--nice-danger, #f44336)" },
975
+ onClick: x,
976
+ style: { ...A.button, backgroundColor: "var(--nice-danger, #f44336)" },
927
977
  children: e("editor.clear", "Clear")
928
978
  }
929
979
  ),
930
- /* @__PURE__ */ jsx(
980
+ /* @__PURE__ */ d(
931
981
  "button",
932
982
  {
933
- onClick: f,
934
- disabled: o.length === 0 || d,
935
- style: styles$3.button,
936
- children: d ? e("editor.recognizing", "Recognizing...") : e("editor.recognize", "Recognize")
983
+ onClick: b,
984
+ disabled: a.length === 0 || p,
985
+ style: A.button,
986
+ children: p ? e("editor.recognizing", "Recognizing...") : e("editor.recognize", "Recognize")
937
987
  }
938
988
  )
939
989
  ] }),
940
- /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: "var(--nice-text-secondary, #666)", marginTop: "8px" }, children: e(
990
+ /* @__PURE__ */ d("p", { style: { fontSize: "12px", color: "var(--nice-text-secondary, #666)", marginTop: "8px" }, children: e(
941
991
  "editor.handwritingNote",
942
992
  "Draw your equation above. Handwriting recognition requires external API integration."
943
993
  ) })
944
994
  ] });
945
995
  }
946
- const mathConstants = {
996
+ const $e = {
947
997
  pi: Math.PI,
948
998
  PI: Math.PI,
949
999
  e: Math.E,
950
1000
  E: Math.E,
951
1001
  phi: (1 + Math.sqrt(5)) / 2,
952
1002
  tau: Math.PI * 2
953
- }, mathFunctions = {
1003
+ }, Re = {
954
1004
  sin: Math.sin,
955
1005
  cos: Math.cos,
956
1006
  tan: Math.tan,
@@ -982,15 +1032,19 @@ const mathConstants = {
982
1032
  cot: (e) => 1 / Math.tan(e),
983
1033
  ln: Math.log
984
1034
  };
985
- class ExpressionParser {
986
- constructor() {
987
- M(this, "pos", 0);
988
- M(this, "expr", "");
1035
+ class ie {
1036
+ constructor(t = {}) {
1037
+ T(this, "pos", 0);
1038
+ T(this, "expr", "");
1039
+ T(this, "options");
1040
+ this.options = t;
989
1041
  }
990
1042
  parse(t) {
991
- this.expr = t.replace(/\s+/g, ""), this.pos = 0;
1043
+ this.expr = t.replace(/\s+/g, "").replace(/×/g, "*").replace(/÷/g, "/").replace(/−/g, "-").replace(/π/g, "pi").replace(/√(\d+(?:\.\d+)?)/g, "sqrt($1)").replace(/√/g, "sqrt"), this.pos = 0;
992
1044
  const r = this.parseAddSub();
993
- return (a) => this.evaluate(r, { ...mathConstants, ...a });
1045
+ if (this.options.strict && this.pos < this.expr.length)
1046
+ throw new Error(`Unexpected "${this.expr.slice(this.pos)}"`);
1047
+ return (o) => this.evaluate(r, o);
994
1048
  }
995
1049
  parseAddSub() {
996
1050
  let t = this.parseMulDiv();
@@ -999,102 +1053,126 @@ class ExpressionParser {
999
1053
  if (r !== "+" && r !== "-")
1000
1054
  break;
1001
1055
  this.pos++;
1002
- const a = this.parseMulDiv();
1003
- t = { type: "binary", op: r, left: t, right: a };
1056
+ const o = this.parseMulDiv();
1057
+ t = { type: "binary", op: r, left: t, right: o };
1004
1058
  }
1005
1059
  return t;
1006
1060
  }
1007
1061
  parseMulDiv() {
1008
- let t = this.parsePower();
1062
+ let t = this.parseUnary();
1009
1063
  for (; this.pos < this.expr.length; ) {
1010
1064
  const r = this.expr[this.pos];
1011
- if (r !== "*" && r !== "/")
1065
+ if (r === "*" || r === "/")
1066
+ this.pos++, t = { type: "binary", op: r, left: t, right: this.parseUnary() };
1067
+ else if (/[0-9a-zA-Z_(]/.test(r))
1068
+ t = { type: "binary", op: "*", left: t, right: this.parsePower() };
1069
+ else
1012
1070
  break;
1013
- this.pos++;
1014
- const a = this.parsePower();
1015
- t = { type: "binary", op: r, left: t, right: a };
1016
- }
1017
- return t;
1018
- }
1019
- parsePower() {
1020
- let t = this.parseUnary();
1021
- for (; this.pos < this.expr.length && this.expr[this.pos] === "^"; ) {
1022
- this.pos++;
1023
- const r = this.parseUnary();
1024
- t = { type: "binary", op: "^", left: t, right: r };
1025
1071
  }
1026
1072
  return t;
1027
1073
  }
1028
1074
  parseUnary() {
1029
- return this.expr[this.pos] === "-" ? (this.pos++, { type: "unary", op: "-", arg: this.parseUnary() }) : (this.expr[this.pos] === "+" && this.pos++, this.parsePrimary());
1075
+ return this.expr[this.pos] === "-" ? (this.pos++, { type: "unary", arg: this.parseUnary() }) : this.expr[this.pos] === "+" ? (this.pos++, this.parseUnary()) : this.parsePower();
1076
+ }
1077
+ parsePower() {
1078
+ const t = this.parsePrimary();
1079
+ return this.expr[this.pos] === "^" ? (this.pos++, { type: "binary", op: "^", left: t, right: this.parseUnary() }) : t;
1030
1080
  }
1031
1081
  parsePrimary() {
1032
1082
  if (this.expr[this.pos] === "(") {
1033
1083
  this.pos++;
1034
- const a = this.parseAddSub();
1035
- return this.expr[this.pos] === ")" && this.pos++, a;
1084
+ const o = this.parseAddSub();
1085
+ if (this.expr[this.pos] === ")")
1086
+ this.pos++;
1087
+ else if (this.options.strict)
1088
+ throw new Error('Missing ")"');
1089
+ return o;
1036
1090
  }
1037
- const t = this.expr.slice(this.pos).match(/^(\d+\.?\d*)/);
1091
+ const t = this.expr.slice(this.pos).match(/^(\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/);
1038
1092
  if (t)
1039
- return this.pos += t[1].length, { type: "number", value: parseFloat(t[1]) };
1093
+ return this.pos += t[0].length, { type: "number", value: parseFloat(t[0]) };
1040
1094
  const r = this.expr.slice(this.pos).match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
1041
1095
  if (r) {
1042
- const a = r[1];
1043
- if (this.pos += a.length, this.expr[this.pos] === "(") {
1096
+ const o = r[1];
1097
+ if (this.pos += o.length, this.expr[this.pos] === "(") {
1044
1098
  this.pos++;
1045
- const o = [];
1099
+ const a = [];
1046
1100
  for (; this.expr[this.pos] !== ")" && this.pos < this.expr.length; )
1047
- o.push(this.parseAddSub()), this.expr[this.pos] === "," && this.pos++;
1048
- return this.expr[this.pos] === ")" && this.pos++, { type: "call", name: a, args: o };
1101
+ if (a.push(this.parseAddSub()), this.expr[this.pos] === ",")
1102
+ this.pos++;
1103
+ else if (this.expr[this.pos] !== ")")
1104
+ break;
1105
+ if (this.expr[this.pos] === ")")
1106
+ this.pos++;
1107
+ else if (this.options.strict)
1108
+ throw new Error('Missing ")"');
1109
+ return { type: "call", name: o, args: a };
1049
1110
  }
1050
- return { type: "variable", name: a };
1111
+ return { type: "variable", name: o };
1051
1112
  }
1113
+ if (this.options.strict)
1114
+ throw new Error(
1115
+ this.pos < this.expr.length ? `Unexpected "${this.expr[this.pos]}"` : "Unexpected end"
1116
+ );
1052
1117
  return { type: "number", value: 0 };
1053
1118
  }
1119
+ /** A name from a table, honouring `ignoreCase`. */
1120
+ lookup(t, r) {
1121
+ if (r in t)
1122
+ return t[r];
1123
+ if (this.options.ignoreCase) {
1124
+ const o = r.toLowerCase(), a = Object.keys(t).find((n) => n.toLowerCase() === o);
1125
+ return a === void 0 ? void 0 : t[a];
1126
+ }
1127
+ }
1054
1128
  evaluate(t, r) {
1055
1129
  switch (t.type) {
1056
1130
  case "number":
1057
1131
  return t.value;
1058
- case "variable":
1132
+ case "variable": {
1059
1133
  if (t.name in r)
1060
1134
  return r[t.name];
1135
+ const o = this.lookup({ ...$e, ...this.options.constants }, t.name);
1136
+ if (o !== void 0)
1137
+ return o;
1061
1138
  throw new Error(`Unknown variable: ${t.name}`);
1139
+ }
1062
1140
  case "unary":
1063
- return t.op === "-" ? -this.evaluate(t.arg, r) : this.evaluate(t.arg, r);
1141
+ return -this.evaluate(t.arg, r);
1064
1142
  case "binary": {
1065
- const a = this.evaluate(t.left, r), o = this.evaluate(t.right, r);
1143
+ const o = this.evaluate(t.left, r), a = this.evaluate(t.right, r);
1066
1144
  switch (t.op) {
1067
1145
  case "+":
1068
- return a + o;
1146
+ return o + a;
1069
1147
  case "-":
1070
- return a - o;
1148
+ return o - a;
1071
1149
  case "*":
1072
- return a * o;
1150
+ return o * a;
1073
1151
  case "/":
1074
- return a / o;
1152
+ return o / a;
1075
1153
  case "^":
1076
- return Math.pow(a, o);
1154
+ return Math.pow(o, a);
1077
1155
  default:
1078
1156
  return 0;
1079
1157
  }
1080
1158
  }
1081
1159
  case "call": {
1082
- const a = mathFunctions[t.name];
1083
- if (!a)
1160
+ const o = this.lookup({ ...Re, ...this.options.functions }, t.name);
1161
+ if (!o)
1084
1162
  throw new Error(`Unknown function: ${t.name}`);
1085
- const o = t.args.map((n) => this.evaluate(n, r));
1086
- return a(...o);
1163
+ const a = t.args.map((n) => this.evaluate(n, r));
1164
+ return o(...a);
1087
1165
  }
1088
1166
  default:
1089
1167
  return 0;
1090
1168
  }
1091
1169
  }
1092
1170
  }
1093
- class GraphService {
1171
+ class Te {
1094
1172
  constructor(t = {}) {
1095
- M(this, "plots", /* @__PURE__ */ new Map());
1096
- M(this, "parser", new ExpressionParser());
1097
- M(this, "config");
1173
+ T(this, "plots", /* @__PURE__ */ new Map());
1174
+ T(this, "parser", new ie());
1175
+ T(this, "config");
1098
1176
  this.config = {
1099
1177
  defaultResolution: t.defaultResolution ?? 200,
1100
1178
  maxResolution: t.maxResolution ?? 1e3
@@ -1120,11 +1198,11 @@ class GraphService {
1120
1198
  }
1121
1199
  /** Update a plot */
1122
1200
  updatePlot(t, r) {
1123
- const a = this.plots.get(t);
1124
- if (!a)
1201
+ const o = this.plots.get(t);
1202
+ if (!o)
1125
1203
  throw new Error(`Plot not found: ${t}`);
1126
- const o = { ...a, ...r, id: a.id };
1127
- return this.plots.set(t, o), o;
1204
+ const a = { ...o, ...r, id: o.id };
1205
+ return this.plots.set(t, a), a;
1128
1206
  }
1129
1207
  /** Remove a plot */
1130
1208
  removePlot(t) {
@@ -1139,41 +1217,41 @@ class GraphService {
1139
1217
  return this.plots.get(t);
1140
1218
  }
1141
1219
  /** Compute 2D function points */
1142
- compute2DFunction(t, r, a, o) {
1143
- const n = this.parser.parse(t), i = [], l = (r.max - r.min) / a;
1144
- for (let p = 0; p <= a; p++) {
1145
- const s = r.min + p * l;
1220
+ compute2DFunction(t, r, o, a) {
1221
+ const n = this.parser.parse(t), i = [], c = (r.max - r.min) / o;
1222
+ for (let u = 0; u <= o; u++) {
1223
+ const s = r.min + u * c;
1146
1224
  try {
1147
- const d = n({ x: s, ...o });
1148
- Number.isFinite(d) && i.push({ x: s, y: d });
1225
+ const p = n({ x: s, ...a });
1226
+ Number.isFinite(p) && i.push({ x: s, y: p });
1149
1227
  } catch {
1150
1228
  }
1151
1229
  }
1152
1230
  return i;
1153
1231
  }
1154
1232
  /** Compute 2D parametric curve */
1155
- compute2DParametric(t, r, a, o, n) {
1156
- const i = this.parser.parse(t), l = this.parser.parse(r), p = [], s = (a.max - a.min) / o;
1157
- for (let d = 0; d <= o; d++) {
1158
- const g = a.min + d * s;
1233
+ compute2DParametric(t, r, o, a, n) {
1234
+ const i = this.parser.parse(t), c = this.parser.parse(r), u = [], s = (o.max - o.min) / a;
1235
+ for (let p = 0; p <= a; p++) {
1236
+ const m = o.min + p * s;
1159
1237
  try {
1160
- const y = i({ t: g, ...n }), h = l({ t: g, ...n });
1161
- Number.isFinite(y) && Number.isFinite(h) && p.push({ x: y, y: h });
1238
+ const y = i({ t: m, ...n }), f = c({ t: m, ...n });
1239
+ Number.isFinite(y) && Number.isFinite(f) && u.push({ x: y, y: f });
1162
1240
  } catch {
1163
1241
  }
1164
1242
  }
1165
- return p;
1243
+ return u;
1166
1244
  }
1167
1245
  /** Compute 2D polar curve */
1168
- compute2DPolar(t, r, a, o) {
1169
- const n = this.parser.parse(t), i = [], l = (r.max - r.min) / a;
1170
- for (let p = 0; p <= a; p++) {
1171
- const s = r.min + p * l;
1246
+ compute2DPolar(t, r, o, a) {
1247
+ const n = this.parser.parse(t), i = [], c = (r.max - r.min) / o;
1248
+ for (let u = 0; u <= o; u++) {
1249
+ const s = r.min + u * c;
1172
1250
  try {
1173
- const d = n({ theta: s, t: s, ...o });
1174
- if (Number.isFinite(d)) {
1175
- const g = d * Math.cos(s), y = d * Math.sin(s);
1176
- i.push({ x: g, y });
1251
+ const p = n({ theta: s, t: s, ...a });
1252
+ if (Number.isFinite(p)) {
1253
+ const m = p * Math.cos(s), y = p * Math.sin(s);
1254
+ i.push({ x: m, y });
1177
1255
  }
1178
1256
  } catch {
1179
1257
  }
@@ -1181,88 +1259,88 @@ class GraphService {
1181
1259
  return i;
1182
1260
  }
1183
1261
  /** Compute 3D surface points */
1184
- compute3DSurface(t, r, a, o, n) {
1185
- const i = this.parser.parse(t), l = [], p = (r.max - r.min) / o, s = (a.max - a.min) / o;
1186
- for (let d = 0; d <= o; d++) {
1187
- const g = [], y = r.min + d * p;
1188
- for (let h = 0; h <= o; h++) {
1189
- const w = a.min + h * s;
1262
+ compute3DSurface(t, r, o, a, n) {
1263
+ const i = this.parser.parse(t), c = [], u = (r.max - r.min) / a, s = (o.max - o.min) / a;
1264
+ for (let p = 0; p <= a; p++) {
1265
+ const m = [], y = r.min + p * u;
1266
+ for (let f = 0; f <= a; f++) {
1267
+ const C = o.min + f * s;
1190
1268
  try {
1191
- const u = i({ x: y, y: w, ...n });
1192
- Number.isFinite(u) ? g.push({ x: y, y: w, z: u }) : g.push({ x: y, y: w, z: 0 });
1269
+ const x = i({ x: y, y: C, ...n });
1270
+ Number.isFinite(x) ? m.push({ x: y, y: C, z: x }) : m.push({ x: y, y: C, z: 0 });
1193
1271
  } catch {
1194
- g.push({ x: y, y: w, z: 0 });
1272
+ m.push({ x: y, y: C, z: 0 });
1195
1273
  }
1196
1274
  }
1197
- l.push(g);
1275
+ c.push(m);
1198
1276
  }
1199
- return l;
1277
+ return c;
1200
1278
  }
1201
1279
  /** Export plot data as SVG */
1202
- exportSVG(t, r, a, o) {
1203
- const i = a - 80, l = o - 80, p = (g) => 40 + (g - r.xRange.min) / (r.xRange.max - r.xRange.min) * i, s = (g) => o - 40 - (g - r.yRange.min) / (r.yRange.max - r.yRange.min) * l, d = [
1204
- `<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o}">`,
1280
+ exportSVG(t, r, o, a) {
1281
+ const i = o - 80, c = a - 80, u = (m) => 40 + (m - r.xRange.min) / (r.xRange.max - r.xRange.min) * i, s = (m) => a - 40 - (m - r.yRange.min) / (r.yRange.max - r.yRange.min) * c, p = [
1282
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${a}">`,
1205
1283
  `<rect width="100%" height="100%" fill="rgb(${r.backgroundColor.r},${r.backgroundColor.g},${r.backgroundColor.b})"/>`
1206
1284
  ];
1207
1285
  if (r.showGrid) {
1208
- d.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');
1209
- for (let g = Math.ceil(r.xRange.min); g <= r.xRange.max; g++) {
1210
- const y = p(g);
1211
- d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${o - 40}"/>`);
1286
+ p.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');
1287
+ for (let m = Math.ceil(r.xRange.min); m <= r.xRange.max; m++) {
1288
+ const y = u(m);
1289
+ p.push(`<line x1="${y}" y1="40" x2="${y}" y2="${a - 40}"/>`);
1212
1290
  }
1213
- for (let g = Math.ceil(r.yRange.min); g <= r.yRange.max; g++) {
1214
- const y = s(g);
1215
- d.push(`<line x1="40" y1="${y}" x2="${a - 40}" y2="${y}"/>`);
1291
+ for (let m = Math.ceil(r.yRange.min); m <= r.yRange.max; m++) {
1292
+ const y = s(m);
1293
+ p.push(`<line x1="40" y1="${y}" x2="${o - 40}" y2="${y}"/>`);
1216
1294
  }
1217
- d.push("</g>");
1295
+ p.push("</g>");
1218
1296
  }
1219
1297
  if (r.showAxes) {
1220
- d.push('<g stroke="var(--nice-text, #333)" stroke-width="1">');
1221
- const g = s(0), y = p(0);
1222
- d.push(`<line x1="40" y1="${g}" x2="${a - 40}" y2="${g}"/>`), d.push(`<line x1="${y}" y1="40" x2="${y}" y2="${o - 40}"/>`), d.push("</g>");
1298
+ p.push('<g stroke="var(--nice-text, #333)" stroke-width="1">');
1299
+ const m = s(0), y = u(0);
1300
+ p.push(`<line x1="40" y1="${m}" x2="${o - 40}" y2="${m}"/>`), p.push(`<line x1="${y}" y1="40" x2="${y}" y2="${a - 40}"/>`), p.push("</g>");
1223
1301
  }
1224
- for (const g of t.filter((y) => y.visible))
1225
- if (g.type === "2d-function") {
1226
- const y = this.compute2DFunction(g.expression, r.xRange, g.resolution || 200);
1302
+ for (const m of t.filter((y) => y.visible))
1303
+ if (m.type === "2d-function") {
1304
+ const y = this.compute2DFunction(m.expression, r.xRange, m.resolution || 200);
1227
1305
  if (y.length > 0) {
1228
- const h = y.map((w, u) => `${u === 0 ? "M" : "L"}${p(w.x)},${s(w.y)}`).join(" ");
1229
- d.push(
1230
- `<path d="${h}" fill="none" stroke="rgb(${g.color.r},${g.color.g},${g.color.b})" stroke-width="${g.lineWidth}"/>`
1306
+ const f = y.map((C, x) => `${x === 0 ? "M" : "L"}${u(C.x)},${s(C.y)}`).join(" ");
1307
+ p.push(
1308
+ `<path d="${f}" fill="none" stroke="rgb(${m.color.r},${m.color.g},${m.color.b})" stroke-width="${m.lineWidth}"/>`
1231
1309
  );
1232
1310
  }
1233
1311
  }
1234
- return r.showLabels && (d.push(
1235
- `<text x="${a / 2}" y="${o - 10}" text-anchor="middle" font-size="12">x</text>`
1236
- ), d.push(
1237
- `<text x="10" y="${o / 2}" text-anchor="middle" font-size="12" transform="rotate(-90,10,${o / 2})">y</text>`
1238
- )), d.push("</svg>"), d.join(`
1312
+ return r.showLabels && (p.push(
1313
+ `<text x="${o / 2}" y="${a - 10}" text-anchor="middle" font-size="12">x</text>`
1314
+ ), p.push(
1315
+ `<text x="10" y="${a / 2}" text-anchor="middle" font-size="12" transform="rotate(-90,10,${a / 2})">y</text>`
1316
+ )), p.push("</svg>"), p.join(`
1239
1317
  `);
1240
1318
  }
1241
1319
  /** Export as PNG (data URL) */
1242
- async exportPNG(t, r, a, o) {
1243
- const n = this.exportSVG(t, r, a, o);
1244
- return new Promise((i, l) => {
1245
- const p = new Image();
1246
- p.onload = () => {
1320
+ async exportPNG(t, r, o, a) {
1321
+ const n = this.exportSVG(t, r, o, a);
1322
+ return new Promise((i, c) => {
1323
+ const u = new Image();
1324
+ u.onload = () => {
1247
1325
  const s = document.createElement("canvas");
1248
- s.width = a, s.height = o;
1249
- const d = s.getContext("2d");
1250
- if (!d) {
1251
- l(new Error("Could not get canvas context"));
1326
+ s.width = o, s.height = a;
1327
+ const p = s.getContext("2d");
1328
+ if (!p) {
1329
+ c(new Error("Could not get canvas context"));
1252
1330
  return;
1253
1331
  }
1254
- d.drawImage(p, 0, 0), i(s.toDataURL("image/png"));
1255
- }, p.onerror = l, p.src = "data:image/svg+xml;base64," + btoa(n);
1332
+ p.drawImage(u, 0, 0), i(s.toDataURL("image/png"));
1333
+ }, u.onerror = c, u.src = "data:image/svg+xml;base64," + btoa(n);
1256
1334
  });
1257
1335
  }
1258
1336
  generateId() {
1259
1337
  return Date.now().toString(36) + Math.random().toString(36).substring(2, 8);
1260
1338
  }
1261
1339
  }
1262
- function createGraphService(e) {
1263
- return new GraphService(e);
1340
+ function tt(e) {
1341
+ return new Te(e);
1264
1342
  }
1265
- const FUNCTION_PRESETS = [
1343
+ const ee = [
1266
1344
  // Basic
1267
1345
  { name: "Linear", expression: "x", type: "2d-function", category: "basic" },
1268
1346
  { name: "Quadratic", expression: "x^2", type: "2d-function", category: "basic" },
@@ -1345,14 +1423,14 @@ const FUNCTION_PRESETS = [
1345
1423
  type: "3d-surface",
1346
1424
  category: "3d"
1347
1425
  }
1348
- ], GraphContext = createContext(null);
1349
- function useGraph() {
1350
- const e = useContext(GraphContext);
1426
+ ], se = /* @__PURE__ */ F(null);
1427
+ function Y() {
1428
+ const e = j(se);
1351
1429
  if (!e)
1352
1430
  throw new Error("useGraph must be used within GraphProvider");
1353
1431
  return e;
1354
1432
  }
1355
- const styles$2 = {
1433
+ const $ = {
1356
1434
  container: {
1357
1435
  display: "flex",
1358
1436
  height: "100%",
@@ -1411,14 +1489,14 @@ const styles$2 = {
1411
1489
  backgroundColor: "var(--nice-bg-secondary, #fafafa)"
1412
1490
  }
1413
1491
  };
1414
- function NiceGraphPlotter({
1492
+ function rt({
1415
1493
  service: e,
1416
1494
  width: t = 800,
1417
1495
  height: r = 600,
1418
- className: a,
1419
- style: o
1496
+ className: o,
1497
+ style: a
1420
1498
  }) {
1421
- const [n, i] = useState([]), [l, p] = useState({
1499
+ const [n, i] = P([]), [c, u] = P({
1422
1500
  xRange: { min: -10, max: 10 },
1423
1501
  yRange: { min: -10, max: 10 },
1424
1502
  zRange: { min: -5, max: 5 },
@@ -1429,63 +1507,63 @@ function NiceGraphPlotter({
1429
1507
  cameraRotationX: 30,
1430
1508
  cameraRotationY: 45,
1431
1509
  cameraDistance: 5
1432
- }), [s, d] = useState({
1510
+ }), [s, p] = P({
1433
1511
  isPlaying: !1,
1434
1512
  parameter: "a",
1435
1513
  currentValue: 0,
1436
1514
  minValue: -5,
1437
1515
  maxValue: 5,
1438
1516
  speed: 1
1439
- }), g = useCallback(() => {
1517
+ }), m = R(() => {
1440
1518
  i(e.getPlots());
1441
- }, [e]), y = useCallback((x) => {
1442
- p((b) => ({ ...b, ...x }));
1443
- }, []), h = useCallback((x) => {
1444
- d((b) => ({ ...b, ...x }));
1445
- }, []), w = useCallback(
1446
- (x) => {
1447
- e.addPlot(x), g();
1519
+ }, [e]), y = R((g) => {
1520
+ u((w) => ({ ...w, ...g }));
1521
+ }, []), f = R((g) => {
1522
+ p((w) => ({ ...w, ...g }));
1523
+ }, []), C = R(
1524
+ (g) => {
1525
+ e.addPlot(g), m();
1448
1526
  },
1449
- [e, g]
1450
- ), u = useCallback(
1451
- (x) => {
1452
- e.removePlot(x), g();
1527
+ [e, m]
1528
+ ), x = R(
1529
+ (g) => {
1530
+ e.removePlot(g), m();
1453
1531
  },
1454
- [e, g]
1455
- ), f = useCallback(
1456
- (x, b) => {
1457
- e.updatePlot(x, b), g();
1532
+ [e, m]
1533
+ ), b = R(
1534
+ (g, w) => {
1535
+ e.updatePlot(g, w), m();
1458
1536
  },
1459
- [e, g]
1460
- ), c = {
1537
+ [e, m]
1538
+ ), l = {
1461
1539
  service: e,
1462
1540
  plots: n,
1463
- view: l,
1541
+ view: c,
1464
1542
  setView: y,
1465
- addPlot: w,
1466
- removePlot: u,
1467
- updatePlot: f,
1543
+ addPlot: C,
1544
+ removePlot: x,
1545
+ updatePlot: b,
1468
1546
  animation: s,
1469
- setAnimation: h,
1470
- refresh: g
1547
+ setAnimation: f,
1548
+ refresh: m
1471
1549
  };
1472
- return /* @__PURE__ */ jsx(GraphContext.Provider, { value: c, children: /* @__PURE__ */ jsxs("div", { className: a, style: { ...styles$2.container, ...o }, children: [
1473
- /* @__PURE__ */ jsxs("div", { style: styles$2.sidebar, children: [
1474
- /* @__PURE__ */ jsx(PlotControls, {}),
1475
- /* @__PURE__ */ jsx(PlotList, {})
1550
+ return /* @__PURE__ */ d(se.Provider, { value: l, children: /* @__PURE__ */ v("div", { className: o, style: { ...$.container, ...a }, children: [
1551
+ /* @__PURE__ */ v("div", { style: $.sidebar, children: [
1552
+ /* @__PURE__ */ d(Ae, {}),
1553
+ /* @__PURE__ */ d(ze, {})
1476
1554
  ] }),
1477
- /* @__PURE__ */ jsxs("div", { style: styles$2.main, children: [
1478
- /* @__PURE__ */ jsx(GraphToolbar, { width: t, height: r }),
1479
- /* @__PURE__ */ jsx(Canvas2D, { width: t, height: r })
1555
+ /* @__PURE__ */ v("div", { style: $.main, children: [
1556
+ /* @__PURE__ */ d(Ee, { width: t, height: r }),
1557
+ /* @__PURE__ */ d(Ie, { width: t, height: r })
1480
1558
  ] })
1481
1559
  ] }) });
1482
1560
  }
1483
- function PlotControls() {
1484
- const { t: e } = useNiceTranslation(), { addPlot: t } = useGraph(), [r, a] = useState("sin(x)"), [o, n] = useState("2d-function"), [i, l] = useState("cos(x)"), p = () => {
1561
+ function Ae() {
1562
+ const { t: e } = L(), { addPlot: t } = Y(), [r, o] = P("sin(x)"), [a, n] = P("2d-function"), [i, c] = P("cos(x)"), u = () => {
1485
1563
  t({
1486
- type: o,
1564
+ type: a,
1487
1565
  expression: r,
1488
- expressionY: o === "2d-parametric" ? i : void 0,
1566
+ expressionY: a === "2d-parametric" ? i : void 0,
1489
1567
  color: {
1490
1568
  r: Math.floor(Math.random() * 200),
1491
1569
  g: Math.floor(Math.random() * 200),
@@ -1493,52 +1571,52 @@ function PlotControls() {
1493
1571
  }
1494
1572
  });
1495
1573
  };
1496
- return /* @__PURE__ */ jsxs("div", { style: { padding: "12px", borderBottom: "1px solid var(--nice-border, #e0e0e0)" }, children: [
1497
- /* @__PURE__ */ jsx("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ jsxs(
1574
+ return /* @__PURE__ */ v("div", { style: { padding: "12px", borderBottom: "1px solid var(--nice-border, #e0e0e0)" }, children: [
1575
+ /* @__PURE__ */ d("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ v(
1498
1576
  "select",
1499
1577
  {
1500
- value: o,
1578
+ value: a,
1501
1579
  onChange: (s) => n(s.target.value),
1502
- style: { ...styles$2.input, width: "100%" },
1580
+ style: { ...$.input, width: "100%" },
1503
1581
  children: [
1504
- /* @__PURE__ */ jsx("option", { value: "2d-function", children: "y = f(x)" }),
1505
- /* @__PURE__ */ jsx("option", { value: "2d-parametric", children: "Parametric (x(t), y(t))" }),
1506
- /* @__PURE__ */ jsx("option", { value: "2d-polar", children: "Polar r = f(θ)" }),
1507
- /* @__PURE__ */ jsx("option", { value: "3d-surface", children: "3D Surface z = f(x,y)" })
1582
+ /* @__PURE__ */ d("option", { value: "2d-function", children: "y = f(x)" }),
1583
+ /* @__PURE__ */ d("option", { value: "2d-parametric", children: "Parametric (x(t), y(t))" }),
1584
+ /* @__PURE__ */ d("option", { value: "2d-polar", children: "Polar r = f(θ)" }),
1585
+ /* @__PURE__ */ d("option", { value: "3d-surface", children: "3D Surface z = f(x,y)" })
1508
1586
  ]
1509
1587
  }
1510
1588
  ) }),
1511
- /* @__PURE__ */ jsx("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ jsx(
1589
+ /* @__PURE__ */ d("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ d(
1512
1590
  "input",
1513
1591
  {
1514
1592
  type: "text",
1515
1593
  value: r,
1516
- onChange: (s) => a(s.target.value),
1517
- placeholder: o === "2d-parametric" ? "x(t) = ..." : "Expression...",
1518
- style: { ...styles$2.input, width: "100%" }
1594
+ onChange: (s) => o(s.target.value),
1595
+ placeholder: a === "2d-parametric" ? "x(t) = ..." : "Expression...",
1596
+ style: { ...$.input, width: "100%" }
1519
1597
  }
1520
1598
  ) }),
1521
- o === "2d-parametric" && /* @__PURE__ */ jsx("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ jsx(
1599
+ a === "2d-parametric" && /* @__PURE__ */ d("div", { style: { marginBottom: "8px" }, children: /* @__PURE__ */ d(
1522
1600
  "input",
1523
1601
  {
1524
1602
  type: "text",
1525
1603
  value: i,
1526
- onChange: (s) => l(s.target.value),
1604
+ onChange: (s) => c(s.target.value),
1527
1605
  placeholder: "y(t) = ...",
1528
- style: { ...styles$2.input, width: "100%" }
1606
+ style: { ...$.input, width: "100%" }
1529
1607
  }
1530
1608
  ) }),
1531
- /* @__PURE__ */ jsx("button", { onClick: p, style: { ...styles$2.button, width: "100%" }, children: "+ Add Plot" }),
1532
- /* @__PURE__ */ jsxs(
1609
+ /* @__PURE__ */ d("button", { onClick: u, style: { ...$.button, width: "100%" }, children: "+ Add Plot" }),
1610
+ /* @__PURE__ */ v(
1533
1611
  "select",
1534
1612
  {
1535
1613
  onChange: (s) => {
1536
- const d = FUNCTION_PRESETS.find((g) => g.name === s.target.value);
1537
- d && t({
1538
- type: d.type,
1539
- expression: d.expression,
1540
- expressionY: d.expressionY,
1541
- label: d.name,
1614
+ const p = ee.find((m) => m.name === s.target.value);
1615
+ p && t({
1616
+ type: p.type,
1617
+ expression: p.expression,
1618
+ expressionY: p.expressionY,
1619
+ label: p.name,
1542
1620
  color: {
1543
1621
  r: Math.floor(Math.random() * 200),
1544
1622
  g: Math.floor(Math.random() * 200),
@@ -1546,24 +1624,24 @@ function PlotControls() {
1546
1624
  }
1547
1625
  });
1548
1626
  },
1549
- style: { ...styles$2.input, width: "100%", marginTop: "8px" },
1627
+ style: { ...$.input, width: "100%", marginTop: "8px" },
1550
1628
  value: "",
1551
1629
  children: [
1552
- /* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: e("plotter.quickAdd", "Quick add preset...") }),
1553
- ["basic", "trigonometric", "exponential", "parametric", "polar", "3d"].map((s) => /* @__PURE__ */ jsx("optgroup", { label: s.charAt(0).toUpperCase() + s.slice(1), children: FUNCTION_PRESETS.filter((d) => d.category === s).map((d) => /* @__PURE__ */ jsxs("option", { value: d.name, children: [
1554
- d.name,
1630
+ /* @__PURE__ */ d("option", { value: "", disabled: !0, children: e("plotter.quickAdd", "Quick add preset...") }),
1631
+ ["basic", "trigonometric", "exponential", "parametric", "polar", "3d"].map((s) => /* @__PURE__ */ d("optgroup", { label: s.charAt(0).toUpperCase() + s.slice(1), children: ee.filter((p) => p.category === s).map((p) => /* @__PURE__ */ v("option", { value: p.name, children: [
1632
+ p.name,
1555
1633
  ": ",
1556
- d.expression
1557
- ] }, d.name)) }, s))
1634
+ p.expression
1635
+ ] }, p.name)) }, s))
1558
1636
  ]
1559
1637
  }
1560
1638
  )
1561
1639
  ] });
1562
1640
  }
1563
- function PlotList() {
1564
- const { t: e } = useNiceTranslation(), { plots: t, removePlot: r, updatePlot: a } = useGraph();
1565
- return /* @__PURE__ */ jsxs("div", { style: styles$2.plotList, children: [
1566
- t.length === 0 && /* @__PURE__ */ jsx(
1641
+ function ze() {
1642
+ const { t: e } = L(), { plots: t, removePlot: r, updatePlot: o } = Y();
1643
+ return /* @__PURE__ */ v("div", { style: $.plotList, children: [
1644
+ t.length === 0 && /* @__PURE__ */ d(
1567
1645
  "div",
1568
1646
  {
1569
1647
  style: {
@@ -1574,32 +1652,33 @@ function PlotList() {
1574
1652
  children: e("plotter.noPlots", "No plots added yet")
1575
1653
  }
1576
1654
  ),
1577
- t.map((o) => /* @__PURE__ */ jsxs("div", { style: styles$2.plotItem, children: [
1578
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" }, children: [
1579
- /* @__PURE__ */ jsx(
1655
+ t.map((a) => /* @__PURE__ */ v("div", { style: $.plotItem, children: [
1656
+ /* @__PURE__ */ v("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" }, children: [
1657
+ /* @__PURE__ */ d(
1580
1658
  "input",
1581
1659
  {
1582
1660
  type: "checkbox",
1583
- checked: o.visible,
1584
- onChange: (n) => a(o.id, { visible: n.target.checked })
1661
+ checked: a.visible,
1662
+ onChange: (n) => o(a.id, { visible: n.target.checked })
1585
1663
  }
1586
1664
  ),
1587
- /* @__PURE__ */ jsx(
1665
+ /* @__PURE__ */ d(
1588
1666
  "div",
1589
1667
  {
1590
1668
  style: {
1591
1669
  width: "16px",
1592
1670
  height: "16px",
1593
1671
  borderRadius: "3px",
1594
- backgroundColor: `rgb(${o.color.r},${o.color.g},${o.color.b})`
1672
+ backgroundColor: `rgb(${a.color.r},${a.color.g},${a.color.b})`
1595
1673
  }
1596
1674
  }
1597
1675
  ),
1598
- /* @__PURE__ */ jsx("span", { style: { flex: 1, fontWeight: 500 }, children: o.label || o.expression }),
1599
- /* @__PURE__ */ jsx(
1676
+ /* @__PURE__ */ d("span", { style: { flex: 1, fontWeight: 500 }, children: a.label || a.expression }),
1677
+ /* @__PURE__ */ d(
1600
1678
  "button",
1601
1679
  {
1602
- onClick: () => r(o.id),
1680
+ "aria-label": e("plotter.close", "Close"),
1681
+ onClick: () => r(a.id),
1603
1682
  style: {
1604
1683
  padding: "2px 6px",
1605
1684
  backgroundColor: "var(--nice-danger, #f44336)",
@@ -1609,11 +1688,11 @@ function PlotList() {
1609
1688
  cursor: "pointer",
1610
1689
  fontSize: "12px"
1611
1690
  },
1612
- children: "×"
1691
+ children: /* @__PURE__ */ d(G, { name: "close", size: 14 })
1613
1692
  }
1614
1693
  )
1615
1694
  ] }),
1616
- /* @__PURE__ */ jsx(
1695
+ /* @__PURE__ */ d(
1617
1696
  "div",
1618
1697
  {
1619
1698
  style: {
@@ -1621,79 +1700,79 @@ function PlotList() {
1621
1700
  color: "var(--nice-text-secondary, #666)",
1622
1701
  fontFamily: "monospace"
1623
1702
  },
1624
- children: o.type === "2d-parametric" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1703
+ children: a.type === "2d-parametric" ? /* @__PURE__ */ v(oe, { children: [
1625
1704
  "x(t) = ",
1626
- o.expression,
1627
- /* @__PURE__ */ jsx("br", {}),
1705
+ a.expression,
1706
+ /* @__PURE__ */ d("br", {}),
1628
1707
  "y(t) = ",
1629
- o.expressionY
1630
- ] }) : o.expression
1708
+ a.expressionY
1709
+ ] }) : a.expression
1631
1710
  }
1632
1711
  )
1633
- ] }, o.id))
1712
+ ] }, a.id))
1634
1713
  ] });
1635
1714
  }
1636
- function GraphToolbar({ width: e, height: t }) {
1637
- const { t: r } = useNiceTranslation(), { service: a, plots: o, view: n, setView: i } = useGraph(), l = () => {
1638
- const s = a.exportSVG(o, n, e, t), d = new Blob([s], { type: "image/svg+xml" }), g = URL.createObjectURL(d), y = document.createElement("a");
1639
- y.href = g, y.download = "graph.svg", y.click(), URL.revokeObjectURL(g);
1640
- }, p = async () => {
1641
- const s = await a.exportPNG(o, n, e, t), d = document.createElement("a");
1642
- d.href = s, d.download = "graph.png", d.click();
1715
+ function Ee({ width: e, height: t }) {
1716
+ const { t: r } = L(), { service: o, plots: a, view: n, setView: i } = Y(), c = () => {
1717
+ const s = o.exportSVG(a, n, e, t), p = new Blob([s], { type: "image/svg+xml" }), m = URL.createObjectURL(p), y = document.createElement("a");
1718
+ y.href = m, y.download = "graph.svg", y.click(), URL.revokeObjectURL(m);
1719
+ }, u = async () => {
1720
+ const s = await o.exportPNG(a, n, e, t), p = document.createElement("a");
1721
+ p.href = s, p.download = "graph.png", p.click();
1643
1722
  };
1644
- return /* @__PURE__ */ jsxs("div", { style: styles$2.toolbar, children: [
1645
- /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px" }, children: [
1723
+ return /* @__PURE__ */ v("div", { style: $.toolbar, children: [
1724
+ /* @__PURE__ */ v("label", { style: { fontSize: "12px" }, children: [
1646
1725
  "X: [",
1647
1726
  " ",
1648
- /* @__PURE__ */ jsx(
1727
+ /* @__PURE__ */ d(
1649
1728
  "input",
1650
1729
  {
1651
1730
  type: "number",
1652
1731
  value: n.xRange.min,
1653
1732
  onChange: (s) => i({ xRange: { ...n.xRange, min: Number(s.target.value) } }),
1654
- style: { ...styles$2.input, width: "50px" }
1733
+ style: { ...$.input, width: "50px" }
1655
1734
  }
1656
1735
  ),
1657
1736
  ",",
1658
1737
  " ",
1659
- /* @__PURE__ */ jsx(
1738
+ /* @__PURE__ */ d(
1660
1739
  "input",
1661
1740
  {
1662
1741
  type: "number",
1663
1742
  value: n.xRange.max,
1664
1743
  onChange: (s) => i({ xRange: { ...n.xRange, max: Number(s.target.value) } }),
1665
- style: { ...styles$2.input, width: "50px" }
1744
+ style: { ...$.input, width: "50px" }
1666
1745
  }
1667
1746
  ),
1668
1747
  "]"
1669
1748
  ] }),
1670
- /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px" }, children: [
1749
+ /* @__PURE__ */ v("label", { style: { fontSize: "12px" }, children: [
1671
1750
  "Y: [",
1672
1751
  " ",
1673
- /* @__PURE__ */ jsx(
1752
+ /* @__PURE__ */ d(
1674
1753
  "input",
1675
1754
  {
1676
1755
  type: "number",
1677
1756
  value: n.yRange.min,
1678
1757
  onChange: (s) => i({ yRange: { ...n.yRange, min: Number(s.target.value) } }),
1679
- style: { ...styles$2.input, width: "50px" }
1758
+ style: { ...$.input, width: "50px" }
1680
1759
  }
1681
1760
  ),
1682
1761
  ",",
1683
1762
  " ",
1684
- /* @__PURE__ */ jsx(
1763
+ /* @__PURE__ */ d(
1685
1764
  "input",
1686
1765
  {
1687
1766
  type: "number",
1688
1767
  value: n.yRange.max,
1689
1768
  onChange: (s) => i({ yRange: { ...n.yRange, max: Number(s.target.value) } }),
1690
- style: { ...styles$2.input, width: "50px" }
1769
+ style: { ...$.input, width: "50px" }
1691
1770
  }
1692
1771
  ),
1693
1772
  "]"
1694
1773
  ] }),
1695
- /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px" }, children: [
1696
- /* @__PURE__ */ jsx(
1774
+ /* @__PURE__ */ v("label", { style: { fontSize: "12px" }, children: [
1775
+ /* @__PURE__ */ d(
1697
1776
  "input",
1698
1777
  {
1699
1778
  type: "checkbox",
@@ -1703,8 +1782,8 @@ function GraphToolbar({ width: e, height: t }) {
1703
1782
  ),
1704
1783
  r("plotter.grid", "Grid")
1705
1784
  ] }),
1706
- /* @__PURE__ */ jsxs("label", { style: { fontSize: "12px" }, children: [
1707
- /* @__PURE__ */ jsx(
1785
+ /* @__PURE__ */ v("label", { style: { fontSize: "12px" }, children: [
1786
+ /* @__PURE__ */ d(
1708
1787
  "input",
1709
1788
  {
1710
1789
  type: "checkbox",
@@ -1714,112 +1793,112 @@ function GraphToolbar({ width: e, height: t }) {
1714
1793
  ),
1715
1794
  r("plotter.axes", "Axes")
1716
1795
  ] }),
1717
- /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
1718
- /* @__PURE__ */ jsxs(
1796
+ /* @__PURE__ */ d("div", { style: { flex: 1 } }),
1797
+ /* @__PURE__ */ v(
1719
1798
  "button",
1720
1799
  {
1721
- onClick: l,
1722
- style: { ...styles$2.button, backgroundColor: "var(--nice-success, #4caf50)" },
1800
+ onClick: c,
1801
+ style: { ...$.button, backgroundColor: "var(--nice-success, #4caf50)" },
1723
1802
  children: [
1724
- /* @__PURE__ */ jsx(NiceIcon$1, { name: "download", size: 14 }),
1803
+ /* @__PURE__ */ d(G, { name: "download", size: 14 }),
1725
1804
  " SVG"
1726
1805
  ]
1727
1806
  }
1728
1807
  ),
1729
- /* @__PURE__ */ jsxs(
1808
+ /* @__PURE__ */ v(
1730
1809
  "button",
1731
1810
  {
1732
- onClick: p,
1733
- style: { ...styles$2.button, backgroundColor: "var(--nice-warning, #ff9800)" },
1811
+ onClick: u,
1812
+ style: { ...$.button, backgroundColor: "var(--nice-warning, #ff9800)" },
1734
1813
  children: [
1735
- /* @__PURE__ */ jsx(NiceIcon$1, { name: "download", size: 14 }),
1814
+ /* @__PURE__ */ d(G, { name: "download", size: 14 }),
1736
1815
  " PNG"
1737
1816
  ]
1738
1817
  }
1739
1818
  )
1740
1819
  ] });
1741
1820
  }
1742
- function Canvas2D({ width: e, height: t }) {
1743
- const r = useRef(null), { service: a, plots: o, view: n, animation: i } = useGraph(), l = 40;
1744
- return useEffect(() => {
1745
- const p = r.current, s = p == null ? void 0 : p.getContext("2d");
1746
- if (!p || !s)
1821
+ function Ie({ width: e, height: t }) {
1822
+ const r = U(null), { service: o, plots: a, view: n, animation: i } = Y(), c = 40;
1823
+ return V(() => {
1824
+ const u = r.current, s = u == null ? void 0 : u.getContext("2d");
1825
+ if (!u || !s)
1747
1826
  return;
1748
1827
  s.fillStyle = `rgb(${n.backgroundColor.r},${n.backgroundColor.g},${n.backgroundColor.b})`, s.fillRect(0, 0, e, t);
1749
- const d = e - l * 2, g = t - l * 2, y = (u) => l + (u - n.xRange.min) / (n.xRange.max - n.xRange.min) * d, h = (u) => t - l - (u - n.yRange.min) / (n.yRange.max - n.yRange.min) * g;
1828
+ const p = e - c * 2, m = t - c * 2, y = (x) => c + (x - n.xRange.min) / (n.xRange.max - n.xRange.min) * p, f = (x) => t - c - (x - n.yRange.min) / (n.yRange.max - n.yRange.min) * m;
1750
1829
  if (n.showGrid) {
1751
- s.strokeStyle = resolveCssColor("var(--nice-border, #e0e0e0)", s.canvas), s.lineWidth = 0.5;
1752
- for (let u = Math.ceil(n.xRange.min); u <= n.xRange.max; u++) {
1753
- const f = y(u);
1754
- s.beginPath(), s.moveTo(f, l), s.lineTo(f, t - l), s.stroke();
1830
+ s.strokeStyle = I("var(--nice-border, #e0e0e0)", s.canvas), s.lineWidth = 0.5;
1831
+ for (let x = Math.ceil(n.xRange.min); x <= n.xRange.max; x++) {
1832
+ const b = y(x);
1833
+ s.beginPath(), s.moveTo(b, c), s.lineTo(b, t - c), s.stroke();
1755
1834
  }
1756
- for (let u = Math.ceil(n.yRange.min); u <= n.yRange.max; u++) {
1757
- const f = h(u);
1758
- s.beginPath(), s.moveTo(l, f), s.lineTo(e - l, f), s.stroke();
1835
+ for (let x = Math.ceil(n.yRange.min); x <= n.yRange.max; x++) {
1836
+ const b = f(x);
1837
+ s.beginPath(), s.moveTo(c, b), s.lineTo(e - c, b), s.stroke();
1759
1838
  }
1760
1839
  }
1761
1840
  if (n.showAxes) {
1762
- s.strokeStyle = resolveCssColor("var(--nice-text, #333)", s.canvas), s.lineWidth = 1;
1763
- const u = h(0);
1764
- s.beginPath(), s.moveTo(l, u), s.lineTo(e - l, u), s.stroke();
1765
- const f = y(0);
1766
- if (s.beginPath(), s.moveTo(f, l), s.lineTo(f, t - l), s.stroke(), n.showLabels) {
1767
- s.fillStyle = resolveCssColor("var(--nice-text, #333)", s.canvas), s.font = "12px sans-serif", s.textAlign = "center", s.fillText("x", e - l + 15, u + 4), s.fillText("y", f, l - 10), s.font = "10px sans-serif";
1768
- for (let c = Math.ceil(n.xRange.min); c <= n.xRange.max; c++)
1769
- c !== 0 && s.fillText(String(c), y(c), u + 15);
1770
- for (let c = Math.ceil(n.yRange.min); c <= n.yRange.max; c++)
1771
- c !== 0 && (s.textAlign = "right", s.fillText(String(c), f - 5, h(c) + 4));
1841
+ s.strokeStyle = I("var(--nice-text, #333)", s.canvas), s.lineWidth = 1;
1842
+ const x = f(0);
1843
+ s.beginPath(), s.moveTo(c, x), s.lineTo(e - c, x), s.stroke();
1844
+ const b = y(0);
1845
+ if (s.beginPath(), s.moveTo(b, c), s.lineTo(b, t - c), s.stroke(), n.showLabels) {
1846
+ s.fillStyle = I("var(--nice-text, #333)", s.canvas), s.font = "12px sans-serif", s.textAlign = "center", s.fillText("x", e - c + 15, x + 4), s.fillText("y", b, c - 10), s.font = "10px sans-serif";
1847
+ for (let l = Math.ceil(n.xRange.min); l <= n.xRange.max; l++)
1848
+ l !== 0 && s.fillText(String(l), y(l), x + 15);
1849
+ for (let l = Math.ceil(n.yRange.min); l <= n.yRange.max; l++)
1850
+ l !== 0 && (s.textAlign = "right", s.fillText(String(l), b - 5, f(l) + 4));
1772
1851
  }
1773
1852
  }
1774
- const w = i.isPlaying ? { [i.parameter]: i.currentValue } : {};
1775
- for (const u of o.filter((f) => f.visible)) {
1776
- const f = `rgb(${u.color.r},${u.color.g},${u.color.b})`;
1777
- s.strokeStyle = f, s.lineWidth = u.lineWidth || 2;
1778
- let c = [];
1779
- switch (u.type) {
1853
+ const C = i.isPlaying ? { [i.parameter]: i.currentValue } : {};
1854
+ for (const x of a.filter((b) => b.visible)) {
1855
+ const b = `rgb(${x.color.r},${x.color.g},${x.color.b})`;
1856
+ s.strokeStyle = b, s.lineWidth = x.lineWidth || 2;
1857
+ let l = [];
1858
+ switch (x.type) {
1780
1859
  case "2d-function":
1781
- c = a.compute2DFunction(
1782
- u.expression,
1860
+ l = o.compute2DFunction(
1861
+ x.expression,
1783
1862
  n.xRange,
1784
- u.resolution || 200,
1785
- w
1863
+ x.resolution || 200,
1864
+ C
1786
1865
  );
1787
1866
  break;
1788
1867
  case "2d-parametric":
1789
- c = a.compute2DParametric(
1790
- u.expression,
1791
- u.expressionY || "sin(t)",
1792
- u.parameterRange || { min: 0, max: 2 * Math.PI },
1793
- u.resolution || 200,
1794
- w
1868
+ l = o.compute2DParametric(
1869
+ x.expression,
1870
+ x.expressionY || "sin(t)",
1871
+ x.parameterRange || { min: 0, max: 2 * Math.PI },
1872
+ x.resolution || 200,
1873
+ C
1795
1874
  );
1796
1875
  break;
1797
1876
  case "2d-polar":
1798
- c = a.compute2DPolar(
1799
- u.expression,
1800
- u.parameterRange || { min: 0, max: 2 * Math.PI },
1801
- u.resolution || 200,
1802
- w
1877
+ l = o.compute2DPolar(
1878
+ x.expression,
1879
+ x.parameterRange || { min: 0, max: 2 * Math.PI },
1880
+ x.resolution || 200,
1881
+ C
1803
1882
  );
1804
1883
  break;
1805
1884
  }
1806
- if (c.length > 0) {
1885
+ if (l.length > 0) {
1807
1886
  s.beginPath();
1808
- let x = !1;
1809
- for (const b of c) {
1810
- const k = y(b.x), m = h(b.y);
1811
- if (m < 0 || m > t) {
1812
- x = !1;
1887
+ let g = !1;
1888
+ for (const w of l) {
1889
+ const M = y(w.x), h = f(w.y);
1890
+ if (h < 0 || h > t) {
1891
+ g = !1;
1813
1892
  continue;
1814
1893
  }
1815
- x ? s.lineTo(k, m) : (s.moveTo(k, m), x = !0);
1894
+ g ? s.lineTo(M, h) : (s.moveTo(M, h), g = !0);
1816
1895
  }
1817
1896
  s.stroke();
1818
1897
  }
1819
1898
  }
1820
- }, [o, n, i, a, e, t]), /* @__PURE__ */ jsx("canvas", { ref: r, width: e, height: t, style: styles$2.canvas });
1899
+ }, [a, n, i, o, e, t]), /* @__PURE__ */ d("canvas", { ref: r, width: e, height: t, style: $.canvas });
1821
1900
  }
1822
- const UNITS = [
1901
+ const O = [
1823
1902
  // Length
1824
1903
  { name: "Meter", symbol: "m", category: "Length", toBase: (e) => e, fromBase: (e) => e },
1825
1904
  {
@@ -2089,12 +2168,12 @@ const UNITS = [
2089
2168
  fromBase: (e) => e / 1099511627776
2090
2169
  },
2091
2170
  { name: "Bit", symbol: "bit", category: "Data", toBase: (e) => e / 8, fromBase: (e) => e * 8 }
2092
- ], MatrixOps = {
2171
+ ], z = {
2093
2172
  create(e, t, r = 0) {
2094
- const a = [];
2095
- for (let o = 0; o < e; o++)
2096
- a.push(new Array(t).fill(r));
2097
- return { rows: e, cols: t, data: a };
2173
+ const o = [];
2174
+ for (let a = 0; a < e; a++)
2175
+ o.push(new Array(t).fill(r));
2176
+ return { rows: e, cols: t, data: o };
2098
2177
  },
2099
2178
  identity(e) {
2100
2179
  const t = this.create(e, e);
@@ -2106,45 +2185,45 @@ const UNITS = [
2106
2185
  if (e.rows !== t.rows || e.cols !== t.cols)
2107
2186
  throw new Error("Matrix dimensions must match for addition");
2108
2187
  const r = this.create(e.rows, e.cols);
2109
- for (let a = 0; a < e.rows; a++)
2110
- for (let o = 0; o < e.cols; o++)
2111
- r.data[a][o] = e.data[a][o] + t.data[a][o];
2188
+ for (let o = 0; o < e.rows; o++)
2189
+ for (let a = 0; a < e.cols; a++)
2190
+ r.data[o][a] = e.data[o][a] + t.data[o][a];
2112
2191
  return r;
2113
2192
  },
2114
2193
  subtract(e, t) {
2115
2194
  if (e.rows !== t.rows || e.cols !== t.cols)
2116
2195
  throw new Error("Matrix dimensions must match for subtraction");
2117
2196
  const r = this.create(e.rows, e.cols);
2118
- for (let a = 0; a < e.rows; a++)
2119
- for (let o = 0; o < e.cols; o++)
2120
- r.data[a][o] = e.data[a][o] - t.data[a][o];
2197
+ for (let o = 0; o < e.rows; o++)
2198
+ for (let a = 0; a < e.cols; a++)
2199
+ r.data[o][a] = e.data[o][a] - t.data[o][a];
2121
2200
  return r;
2122
2201
  },
2123
2202
  multiply(e, t) {
2124
2203
  if (e.cols !== t.rows)
2125
2204
  throw new Error("Matrix A columns must equal Matrix B rows for multiplication");
2126
2205
  const r = this.create(e.rows, t.cols);
2127
- for (let a = 0; a < e.rows; a++)
2128
- for (let o = 0; o < t.cols; o++) {
2206
+ for (let o = 0; o < e.rows; o++)
2207
+ for (let a = 0; a < t.cols; a++) {
2129
2208
  let n = 0;
2130
2209
  for (let i = 0; i < e.cols; i++)
2131
- n += e.data[a][i] * t.data[i][o];
2132
- r.data[a][o] = n;
2210
+ n += e.data[o][i] * t.data[i][a];
2211
+ r.data[o][a] = n;
2133
2212
  }
2134
2213
  return r;
2135
2214
  },
2136
2215
  scalar(e, t) {
2137
2216
  const r = this.create(e.rows, e.cols);
2138
- for (let a = 0; a < e.rows; a++)
2139
- for (let o = 0; o < e.cols; o++)
2140
- r.data[a][o] = e.data[a][o] * t;
2217
+ for (let o = 0; o < e.rows; o++)
2218
+ for (let a = 0; a < e.cols; a++)
2219
+ r.data[o][a] = e.data[o][a] * t;
2141
2220
  return r;
2142
2221
  },
2143
2222
  transpose(e) {
2144
2223
  const t = this.create(e.cols, e.rows);
2145
2224
  for (let r = 0; r < e.rows; r++)
2146
- for (let a = 0; a < e.cols; a++)
2147
- t.data[a][r] = e.data[r][a];
2225
+ for (let o = 0; o < e.cols; o++)
2226
+ t.data[o][r] = e.data[r][o];
2148
2227
  return t;
2149
2228
  },
2150
2229
  determinant(e) {
@@ -2160,29 +2239,29 @@ const UNITS = [
2160
2239
  return t;
2161
2240
  },
2162
2241
  minor(e, t, r) {
2163
- const a = this.create(e.rows - 1, e.cols - 1);
2164
- let o = 0;
2242
+ const o = this.create(e.rows - 1, e.cols - 1);
2243
+ let a = 0;
2165
2244
  for (let n = 0; n < e.rows; n++) {
2166
2245
  if (n === t)
2167
2246
  continue;
2168
2247
  let i = 0;
2169
- for (let l = 0; l < e.cols; l++)
2170
- l !== r && (a.data[o][i] = e.data[n][l], i++);
2171
- o++;
2248
+ for (let c = 0; c < e.cols; c++)
2249
+ c !== r && (o.data[a][i] = e.data[n][c], i++);
2250
+ a++;
2172
2251
  }
2173
- return a;
2252
+ return o;
2174
2253
  },
2175
2254
  inverse(e) {
2176
2255
  const t = this.determinant(e);
2177
2256
  if (t === 0)
2178
2257
  throw new Error("Matrix is singular, cannot compute inverse");
2179
- const r = e.rows, a = this.create(r, r);
2180
- for (let o = 0; o < r; o++)
2258
+ const r = e.rows, o = this.create(r, r);
2259
+ for (let a = 0; a < r; a++)
2181
2260
  for (let n = 0; n < r; n++) {
2182
- const i = Math.pow(-1, o + n), l = this.determinant(this.minor(e, o, n));
2183
- a.data[n][o] = i * l;
2261
+ const i = Math.pow(-1, a + n), c = this.determinant(this.minor(e, a, n));
2262
+ o.data[n][a] = i * c;
2184
2263
  }
2185
- return this.scalar(a, 1 / t);
2264
+ return this.scalar(o, 1 / t);
2186
2265
  },
2187
2266
  trace(e) {
2188
2267
  if (e.rows !== e.cols)
@@ -2195,17 +2274,17 @@ const UNITS = [
2195
2274
  eigenvalues2x2(e) {
2196
2275
  if (e.rows !== 2 || e.cols !== 2)
2197
2276
  throw new Error("Only 2x2 matrices supported for eigenvalues");
2198
- const t = e.data[0][0], r = e.data[0][1], a = e.data[1][0], o = e.data[1][1], n = t + o, i = t * o - r * a, l = n * n - 4 * i;
2199
- if (l < 0)
2277
+ const t = e.data[0][0], r = e.data[0][1], o = e.data[1][0], a = e.data[1][1], n = t + a, i = t * a - r * o, c = n * n - 4 * i;
2278
+ if (c < 0)
2200
2279
  throw new Error("Complex eigenvalues not supported");
2201
- const p = Math.sqrt(l);
2202
- return [(n + p) / 2, (n - p) / 2];
2280
+ const u = Math.sqrt(c);
2281
+ return [(n + u) / 2, (n - u) / 2];
2203
2282
  },
2204
2283
  toString(e, t = 4) {
2205
- return e.data.map((r) => "[ " + r.map((a) => a.toFixed(t).padStart(10)).join(" ") + " ]").join(`
2284
+ return e.data.map((r) => "[ " + r.map((o) => o.toFixed(t).padStart(10)).join(" ") + " ]").join(`
2206
2285
  `);
2207
2286
  }
2208
- }, CalculusOps = {
2287
+ }, te = {
2209
2288
  /** Numerical derivative at a point */
2210
2289
  derivative(e, t, r = 1e-7) {
2211
2290
  return (e(t + r) - e(t - r)) / (2 * r);
@@ -2215,27 +2294,27 @@ const UNITS = [
2215
2294
  return (e(t + r) - 2 * e(t) + e(t - r)) / (r * r);
2216
2295
  },
2217
2296
  /** Numerical integration using Simpson's rule */
2218
- integrate(e, t, r, a = 1e3) {
2219
- a % 2 !== 0 && a++;
2220
- const o = (r - t) / a;
2297
+ integrate(e, t, r, o = 1e3) {
2298
+ o % 2 !== 0 && o++;
2299
+ const a = (r - t) / o;
2221
2300
  let n = e(t) + e(r);
2222
- for (let i = 1; i < a; i++) {
2223
- const l = t + i * o;
2224
- n += i % 2 === 0 ? 2 * e(l) : 4 * e(l);
2301
+ for (let i = 1; i < o; i++) {
2302
+ const c = t + i * a;
2303
+ n += i % 2 === 0 ? 2 * e(c) : 4 * e(c);
2225
2304
  }
2226
- return o / 3 * n;
2305
+ return a / 3 * n;
2227
2306
  },
2228
2307
  /** Find root using Newton-Raphson method */
2229
- findRoot(e, t, r = 1e-10, a = 100) {
2230
- let o = t;
2231
- for (let n = 0; n < a; n++) {
2232
- const i = e(o);
2308
+ findRoot(e, t, r = 1e-10, o = 100) {
2309
+ let a = t;
2310
+ for (let n = 0; n < o; n++) {
2311
+ const i = e(a);
2233
2312
  if (Math.abs(i) < r)
2234
- return o;
2235
- const l = this.derivative(e, o);
2236
- if (l === 0)
2313
+ return a;
2314
+ const c = this.derivative(e, a);
2315
+ if (c === 0)
2237
2316
  throw new Error("Derivative is zero, Newton-Raphson failed");
2238
- o = o - i / l;
2317
+ a = a - i / c;
2239
2318
  }
2240
2319
  throw new Error("Newton-Raphson did not converge");
2241
2320
  },
@@ -2247,13 +2326,13 @@ const UNITS = [
2247
2326
  return "1";
2248
2327
  const t = e.match(/^x\^(\d+)$/);
2249
2328
  if (t) {
2250
- const a = parseInt(t[1], 10);
2251
- return a === 1 ? "1" : a === 2 ? "2*x" : `${a}*x^${a - 1}`;
2329
+ const o = parseInt(t[1], 10);
2330
+ return o === 1 ? "1" : o === 2 ? "2*x" : `${o}*x^${o - 1}`;
2252
2331
  }
2253
2332
  const r = e.match(/^(-?\d+\.?\d*)\*x\^(\d+)$/);
2254
2333
  if (r) {
2255
- const a = parseFloat(r[1]), o = parseInt(r[2], 10), n = a * o;
2256
- return o === 1 ? String(n) : o === 2 ? `${n}*x` : `${n}*x^${o - 1}`;
2334
+ const o = parseFloat(r[1]), a = parseInt(r[2], 10), n = o * a;
2335
+ return a === 1 ? String(n) : a === 2 ? `${n}*x` : `${n}*x^${a - 1}`;
2257
2336
  }
2258
2337
  return e === "sin(x)" ? "cos(x)" : e === "cos(x)" ? "-sin(x)" : e === "e^x" || e === "exp(x)" ? "e^x" : e === "ln(x)" ? "1/x" : `d/dx(${e})`;
2259
2338
  },
@@ -2272,48 +2351,64 @@ const UNITS = [
2272
2351
  },
2273
2352
  /** Solve quadratic equation ax² + bx + c = 0 */
2274
2353
  solveQuadratic(e, t, r) {
2275
- const a = t * t - 4 * e * r;
2276
- if (a < 0)
2354
+ const o = t * t - 4 * e * r;
2355
+ if (o < 0)
2277
2356
  throw new Error("No real solutions (complex roots)");
2278
- if (a === 0)
2357
+ if (o === 0)
2279
2358
  return [-t / (2 * e)];
2280
- const o = Math.sqrt(a);
2281
- return [(-t + o) / (2 * e), (-t - o) / (2 * e)];
2359
+ const a = Math.sqrt(o);
2360
+ return [(-t + a) / (2 * e), (-t - a) / (2 * e)];
2282
2361
  }
2283
2362
  };
2284
- class CalculatorService {
2285
- constructor(e = {}) {
2286
- M(this, "history", []);
2287
- M(this, "memory", 0);
2288
- M(this, "variables", /* @__PURE__ */ new Map());
2289
- M(this, "config");
2363
+ class Le {
2364
+ constructor(t = {}) {
2365
+ T(this, "history", []);
2366
+ T(this, "memory", 0);
2367
+ T(this, "variables", /* @__PURE__ */ new Map());
2368
+ T(this, "config");
2290
2369
  this.config = {
2291
- precision: e.precision ?? 12,
2292
- angleUnit: e.angleUnit ?? "rad"
2370
+ precision: t.precision ?? 12,
2371
+ angleUnit: t.angleUnit ?? "rad"
2293
2372
  };
2294
2373
  }
2295
- /** Evaluate expression */
2296
- evaluate(expression) {
2297
- let expr = expression.replace(/π|pi/gi, String(Math.PI)).replace(/e(?![xp])/gi, String(Math.E)).replace(/\^/g, "**").replace(/√/g, "Math.sqrt").replace(/sin/gi, "Math.sin").replace(/cos/gi, "Math.cos").replace(/tan/gi, "Math.tan").replace(/asin/gi, "Math.asin").replace(/acos/gi, "Math.acos").replace(/atan/gi, "Math.atan").replace(/sinh/gi, "Math.sinh").replace(/cosh/gi, "Math.cosh").replace(/tanh/gi, "Math.tanh").replace(/log10/gi, "Math.log10").replace(/log2/gi, "Math.log2").replace(/ln/gi, "Math.log").replace(/log\b/gi, "Math.log10").replace(/exp/gi, "Math.exp").replace(/sqrt/gi, "Math.sqrt").replace(/cbrt/gi, "Math.cbrt").replace(/abs/gi, "Math.abs").replace(/floor/gi, "Math.floor").replace(/ceil/gi, "Math.ceil").replace(/round/gi, "Math.round").replace(/pow/gi, "Math.pow").replace(/min/gi, "Math.min").replace(/max/gi, "Math.max");
2298
- for (const [e, t] of this.variables)
2299
- expr = expr.replace(new RegExp(`\\b${e}\\b`, "g"), String(t));
2374
+ /**
2375
+ * Evaluate an expression — parsed by {@link ExpressionParser}, never run as code (until 1.2.0 a
2376
+ * chain of regex replacements fed `new Function`: `asin` came out as `aMath.sin`, `ceil` lost
2377
+ * its `e` to Euler's number, a result in exponent notation summed wrongly, and any text ran).
2378
+ * `log` is base 10 like the key, `ln` natural; trig functions follow `angleUnit`.
2379
+ */
2380
+ evaluate(t) {
2381
+ const r = this.config.angleUnit === "deg", o = (c) => r ? c * Math.PI / 180 : c, a = (c) => r ? c * 180 / Math.PI : c, n = new ie({
2382
+ strict: !0,
2383
+ ignoreCase: !0,
2384
+ functions: {
2385
+ log: Math.log10,
2386
+ sin: (c) => Math.sin(o(c)),
2387
+ cos: (c) => Math.cos(o(c)),
2388
+ tan: (c) => Math.tan(o(c)),
2389
+ asin: (c) => a(Math.asin(c)),
2390
+ acos: (c) => a(Math.acos(c)),
2391
+ atan: (c) => a(Math.atan(c))
2392
+ }
2393
+ });
2394
+ let i;
2300
2395
  try {
2301
- const result = eval(expr);
2302
- if (typeof result != "number" || !Number.isFinite(result))
2303
- throw new Error("Invalid result");
2304
- return result;
2305
- } catch (e) {
2306
- throw new Error(`Invalid expression: ${e.message}`);
2396
+ i = n.parse(t)(Object.fromEntries(this.variables));
2397
+ } catch (c) {
2398
+ throw new Error(`Invalid expression: ${c.message}`);
2307
2399
  }
2400
+ if (!Number.isFinite(i))
2401
+ throw new Error("Invalid expression: Invalid result");
2402
+ return i;
2308
2403
  }
2309
2404
  /** Add to history */
2310
- addHistory(e, t, r) {
2405
+ addHistory(t, r, o) {
2311
2406
  this.history.unshift({
2312
2407
  id: Date.now().toString(36),
2313
- expression: e,
2314
- result: t,
2408
+ expression: t,
2409
+ result: r,
2315
2410
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2316
- mode: r
2411
+ mode: o
2317
2412
  }), this.history.length > 100 && this.history.pop();
2318
2413
  }
2319
2414
  /** Get history */
@@ -2325,67 +2420,67 @@ class CalculatorService {
2325
2420
  this.history = [];
2326
2421
  }
2327
2422
  /** Memory operations */
2328
- memoryStore(e) {
2329
- this.memory = e;
2423
+ memoryStore(t) {
2424
+ this.memory = t;
2330
2425
  }
2331
2426
  memoryRecall() {
2332
2427
  return this.memory;
2333
2428
  }
2334
- memoryAdd(e) {
2335
- this.memory += e;
2429
+ memoryAdd(t) {
2430
+ this.memory += t;
2336
2431
  }
2337
2432
  memoryClear() {
2338
2433
  this.memory = 0;
2339
2434
  }
2340
2435
  /** Variable operations */
2341
- setVariable(e, t) {
2342
- this.variables.set(e, t);
2436
+ setVariable(t, r) {
2437
+ this.variables.set(t, r);
2343
2438
  }
2344
- getVariable(e) {
2345
- return this.variables.get(e);
2439
+ getVariable(t) {
2440
+ return this.variables.get(t);
2346
2441
  }
2347
2442
  /** Convert between number bases */
2348
- convertBase(e, t, r) {
2349
- const a = { BIN: 2, OCT: 8, DEC: 10, HEX: 16 }, o = parseInt(e, a[t]);
2350
- if (isNaN(o))
2443
+ convertBase(t, r, o) {
2444
+ const a = { BIN: 2, OCT: 8, DEC: 10, HEX: 16 }, n = parseInt(t, a[r]);
2445
+ if (isNaN(n))
2351
2446
  throw new Error("Invalid number for base conversion");
2352
- return o.toString(a[r]).toUpperCase();
2447
+ return n.toString(a[o]).toUpperCase();
2353
2448
  }
2354
2449
  /** Convert units */
2355
- convertUnits(e, t, r) {
2356
- const a = UNITS.find((i) => i.symbol === t), o = UNITS.find((i) => i.symbol === r);
2357
- if (!a || !o)
2450
+ convertUnits(t, r, o) {
2451
+ const a = O.find((c) => c.symbol === r), n = O.find((c) => c.symbol === o);
2452
+ if (!a || !n)
2358
2453
  throw new Error("Unknown unit");
2359
- if (a.category !== o.category)
2454
+ if (a.category !== n.category)
2360
2455
  throw new Error("Cannot convert between different unit categories");
2361
- const n = a.toBase(e);
2362
- return o.fromBase(n);
2456
+ const i = a.toBase(t);
2457
+ return n.fromBase(i);
2363
2458
  }
2364
2459
  /** Get units by category */
2365
- getUnitsByCategory(e) {
2366
- return UNITS.filter((t) => t.category === e);
2460
+ getUnitsByCategory(t) {
2461
+ return O.filter((r) => r.category === t);
2367
2462
  }
2368
2463
  /** Get all unit categories */
2369
2464
  getUnitCategories() {
2370
- return [...new Set(UNITS.map((e) => e.category))];
2465
+ return [...new Set(O.map((t) => t.category))];
2371
2466
  }
2372
2467
  /** Format number with precision */
2373
- format(e) {
2374
- const t = this.config.precision;
2375
- return Math.abs(e) < 1e-10 ? "0" : Math.abs(e) > 1e10 || Math.abs(e) < 1e-6 ? e.toExponential(t) : parseFloat(e.toPrecision(t)).toString();
2468
+ format(t) {
2469
+ const r = this.config.precision;
2470
+ return Math.abs(t) < 1e-10 ? "0" : Math.abs(t) > 1e10 || Math.abs(t) < 1e-6 ? t.toExponential(r) : parseFloat(t.toPrecision(r)).toString();
2376
2471
  }
2377
2472
  }
2378
- function createCalculatorService(e) {
2379
- return new CalculatorService(e);
2473
+ function ot(e) {
2474
+ return new Le(e);
2380
2475
  }
2381
- const CalculatorContext = createContext(null);
2382
- function useCalculator() {
2383
- const e = useContext(CalculatorContext);
2476
+ const ce = /* @__PURE__ */ F(null);
2477
+ function N() {
2478
+ const e = j(ce);
2384
2479
  if (!e)
2385
2480
  throw new Error("useCalculator must be used within CalculatorProvider");
2386
2481
  return e;
2387
2482
  }
2388
- const styles$1 = {
2483
+ const B = {
2389
2484
  container: {
2390
2485
  width: "400px",
2391
2486
  fontFamily: "'Inter', sans-serif",
@@ -2430,7 +2525,7 @@ const styles$1 = {
2430
2525
  padding: "20px",
2431
2526
  border: "none",
2432
2527
  backgroundColor: "var(--nice-border, #3c3c3c)",
2433
- color: "var(--nice-text-on-primary, #fff)",
2528
+ color: "var(--nice-color-white, #fff)",
2434
2529
  fontSize: "18px",
2435
2530
  cursor: "pointer",
2436
2531
  transition: "background-color 0.1s"
@@ -2440,52 +2535,52 @@ const styles$1 = {
2440
2535
  color: "var(--nice-text, #000)"
2441
2536
  },
2442
2537
  keyFunction: {
2443
- backgroundColor: "#505050"
2538
+ backgroundColor: "var(--nice-bg-tertiary, #505050)"
2444
2539
  }
2445
2540
  };
2446
- function NiceCalculator({
2541
+ function at({
2447
2542
  service: e,
2448
2543
  className: t,
2449
2544
  style: r
2450
2545
  }) {
2451
- const [a, o] = useState("0"), [n, i] = useState("standard"), [l, p] = useState([]), [s, d] = useState(!1), g = useCallback(
2452
- (u) => {
2453
- s && /[0-9.]/.test(u) ? (o(u), d(!1)) : (o((f) => f === "0" && u !== "." ? u : f + u), d(!1));
2546
+ const [o, a] = P("0"), [n, i] = P("standard"), [c, u] = P([]), [s, p] = P(!1), m = R(
2547
+ (x) => {
2548
+ s && /[0-9.]/.test(x) ? (a(x), p(!1)) : (a((b) => b === "0" && x !== "." ? x : b + x), p(!1));
2454
2549
  },
2455
2550
  [s]
2456
- ), y = useCallback(() => {
2457
- o("0"), d(!1);
2458
- }, []), h = useCallback(() => {
2551
+ ), y = R(() => {
2552
+ a("0"), p(!1);
2553
+ }, []), f = R(() => {
2459
2554
  try {
2460
- const u = e.evaluate(a), f = e.format(u);
2461
- e.addHistory(a, f, n), p(e.getHistory()), o(f), d(!0);
2555
+ const x = e.evaluate(o), b = e.format(x);
2556
+ e.addHistory(o, b, n), u(e.getHistory()), a(b), p(!0);
2462
2557
  } catch {
2463
- o("Error"), d(!0);
2558
+ a("Error"), p(!0);
2464
2559
  }
2465
- }, [a, n, e]), w = {
2560
+ }, [o, n, e]), C = {
2466
2561
  service: e,
2467
- display: a,
2468
- setDisplay: o,
2562
+ display: o,
2563
+ setDisplay: a,
2469
2564
  mode: n,
2470
2565
  setMode: i,
2471
- history: l,
2472
- calculate: h,
2473
- appendDigit: g,
2566
+ history: c,
2567
+ calculate: f,
2568
+ appendDigit: m,
2474
2569
  clear: y
2475
2570
  };
2476
- return /* @__PURE__ */ jsx(CalculatorContext.Provider, { value: w, children: /* @__PURE__ */ jsxs("div", { className: t, style: { ...styles$1.container, ...r }, children: [
2477
- /* @__PURE__ */ jsx(ModeSelector, {}),
2478
- /* @__PURE__ */ jsx(Display, {}),
2479
- n === "standard" && /* @__PURE__ */ jsx(StandardKeypad, {}),
2480
- n === "scientific" && /* @__PURE__ */ jsx(ScientificKeypad, {}),
2481
- n === "programmer" && /* @__PURE__ */ jsx(ProgrammerKeypad, {}),
2482
- n === "matrix" && /* @__PURE__ */ jsx(MatrixMode, {}),
2483
- n === "calculus" && /* @__PURE__ */ jsx(CalculusMode, {}),
2484
- n === "units" && /* @__PURE__ */ jsx(UnitsMode, {})
2571
+ return /* @__PURE__ */ d(ce.Provider, { value: C, children: /* @__PURE__ */ v("div", { className: t, style: { ...B.container, ...r }, children: [
2572
+ /* @__PURE__ */ d(De, {}),
2573
+ /* @__PURE__ */ d(qe, {}),
2574
+ n === "standard" && /* @__PURE__ */ d(le, {}),
2575
+ n === "scientific" && /* @__PURE__ */ d(Ne, {}),
2576
+ n === "programmer" && /* @__PURE__ */ d(Xe, {}),
2577
+ n === "matrix" && /* @__PURE__ */ d(Ge, {}),
2578
+ n === "calculus" && /* @__PURE__ */ d(je, {}),
2579
+ n === "units" && /* @__PURE__ */ d(Fe, {})
2485
2580
  ] }) });
2486
2581
  }
2487
- function ModeSelector() {
2488
- const { mode: e, setMode: t } = useCalculator(), r = [
2582
+ function De() {
2583
+ const { mode: e, setMode: t } = N(), r = [
2489
2584
  { id: "standard", label: "Standard" },
2490
2585
  { id: "scientific", label: "Scientific" },
2491
2586
  { id: "programmer", label: "Programmer" },
@@ -2493,61 +2588,61 @@ function ModeSelector() {
2493
2588
  { id: "calculus", label: "Calculus" },
2494
2589
  { id: "units", label: "Units" }
2495
2590
  ];
2496
- return /* @__PURE__ */ jsx("div", { style: styles$1.modeSelector, children: r.map((a) => /* @__PURE__ */ jsx(
2591
+ return /* @__PURE__ */ d("div", { style: B.modeSelector, children: r.map((o) => /* @__PURE__ */ d(
2497
2592
  "button",
2498
2593
  {
2499
- onClick: () => t(a.id),
2594
+ onClick: () => t(o.id),
2500
2595
  style: {
2501
- ...styles$1.modeButton,
2502
- backgroundColor: e === a.id ? "var(--nice-primary-hover, #1976d2)" : "transparent",
2503
- color: e === a.id ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text-secondary, #888)"
2596
+ ...B.modeButton,
2597
+ backgroundColor: e === o.id ? "var(--nice-primary-hover, #1976d2)" : "transparent",
2598
+ color: e === o.id ? "var(--nice-color-white, #fff)" : "var(--nice-text-secondary, #888)"
2504
2599
  },
2505
- children: a.label
2600
+ children: o.label
2506
2601
  },
2507
- a.id
2602
+ o.id
2508
2603
  )) });
2509
2604
  }
2510
- function Display() {
2511
- const { display: e } = useCalculator();
2512
- return /* @__PURE__ */ jsx("div", { style: styles$1.display, children: /* @__PURE__ */ jsx("div", { style: styles$1.displayText, children: e }) });
2605
+ function qe() {
2606
+ const { display: e } = N();
2607
+ return /* @__PURE__ */ d("div", { style: B.display, children: /* @__PURE__ */ d("div", { style: B.displayText, children: e }) });
2513
2608
  }
2514
- function StandardKeypad() {
2515
- const { appendDigit: e, clear: t, calculate: r, setDisplay: a, display: o } = useCalculator(), n = [
2516
- { label: "AC", action: t, style: styles$1.keyFunction },
2609
+ function le() {
2610
+ const { appendDigit: e, clear: t, calculate: r, setDisplay: o, display: a } = N(), n = [
2611
+ { label: "AC", action: t, style: B.keyFunction },
2517
2612
  {
2518
2613
  label: "±",
2519
- action: () => a(o.startsWith("-") ? o.slice(1) : "-" + o),
2520
- style: styles$1.keyFunction
2614
+ action: () => o(a.startsWith("-") ? a.slice(1) : "-" + a),
2615
+ style: B.keyFunction
2521
2616
  },
2522
- { label: "%", action: () => e("/100"), style: styles$1.keyFunction },
2523
- { label: "÷", action: () => e("/"), style: styles$1.keyOperator },
2617
+ { label: "%", action: () => e("/100"), style: B.keyFunction },
2618
+ { label: "÷", action: () => e("/"), style: B.keyOperator },
2524
2619
  { label: "7", action: () => e("7") },
2525
2620
  { label: "8", action: () => e("8") },
2526
2621
  { label: "9", action: () => e("9") },
2527
- { label: "×", action: () => e("*"), style: styles$1.keyOperator },
2622
+ { label: "×", action: () => e("*"), style: B.keyOperator },
2528
2623
  { label: "4", action: () => e("4") },
2529
2624
  { label: "5", action: () => e("5") },
2530
2625
  { label: "6", action: () => e("6") },
2531
- { label: "−", action: () => e("-"), style: styles$1.keyOperator },
2626
+ { label: "−", action: () => e("-"), style: B.keyOperator },
2532
2627
  { label: "1", action: () => e("1") },
2533
2628
  { label: "2", action: () => e("2") },
2534
2629
  { label: "3", action: () => e("3") },
2535
- { label: "+", action: () => e("+"), style: styles$1.keyOperator },
2630
+ { label: "+", action: () => e("+"), style: B.keyOperator },
2536
2631
  { label: "0", action: () => e("0") },
2537
2632
  { label: ".", action: () => e(".") },
2538
- { label: "⌫", action: () => a(o.length > 1 ? o.slice(0, -1) : "0") },
2539
- { label: "=", action: r, style: styles$1.keyOperator }
2633
+ { label: "⌫", action: () => o(a.length > 1 ? a.slice(0, -1) : "0") },
2634
+ { label: "=", action: r, style: B.keyOperator }
2540
2635
  ];
2541
- return /* @__PURE__ */ jsx("div", { style: styles$1.keypad, children: n.map((i, l) => /* @__PURE__ */ jsx("button", { onClick: i.action, style: { ...styles$1.key, ...i.style || {} }, children: i.label }, l)) });
2636
+ return /* @__PURE__ */ d("div", { style: B.keypad, children: n.map((i, c) => /* @__PURE__ */ d("button", { onClick: i.action, style: { ...B.key, ...i.style || {} }, children: i.label }, c)) });
2542
2637
  }
2543
- function ScientificKeypad() {
2638
+ function Ne() {
2544
2639
  const {
2545
2640
  appendDigit: e,
2546
2641
  clear: t,
2547
2642
  calculate: r,
2548
- setDisplay: a,
2549
- display: o
2550
- } = useCalculator(), n = [
2643
+ setDisplay: o,
2644
+ display: a
2645
+ } = N(), n = [
2551
2646
  { label: "sin", action: () => e("sin(") },
2552
2647
  { label: "cos", action: () => e("cos(") },
2553
2648
  { label: "tan", action: () => e("tan(") },
@@ -2559,37 +2654,37 @@ function ScientificKeypad() {
2559
2654
  { label: "xʸ", action: () => e("^") },
2560
2655
  { label: "√", action: () => e("sqrt(") },
2561
2656
  { label: "eˣ", action: () => e("exp(") }
2562
- ], l = [
2657
+ ], c = [
2563
2658
  { label: "(", action: () => e("(") },
2564
2659
  { label: ")", action: () => e(")") },
2565
2660
  { label: "π", action: () => e("π") },
2566
2661
  { label: "e", action: () => e("e") },
2567
2662
  { label: "AC", action: t }
2568
2663
  ];
2569
- return /* @__PURE__ */ jsxs("div", { children: [
2570
- /* @__PURE__ */ jsx("div", { style: { ...styles$1.keypad, gridTemplateColumns: "repeat(5, 1fr)" }, children: [...n, ...i, ...l].map((p, s) => /* @__PURE__ */ jsx(
2664
+ return /* @__PURE__ */ v("div", { children: [
2665
+ /* @__PURE__ */ d("div", { style: { ...B.keypad, gridTemplateColumns: "repeat(5, 1fr)" }, children: [...n, ...i, ...c].map((u, s) => /* @__PURE__ */ d(
2571
2666
  "button",
2572
2667
  {
2573
- onClick: p.action,
2574
- style: { ...styles$1.key, ...styles$1.keyFunction, padding: "12px" },
2575
- children: p.label
2668
+ onClick: u.action,
2669
+ style: { ...B.key, ...B.keyFunction, padding: "12px" },
2670
+ children: u.label
2576
2671
  },
2577
2672
  s
2578
2673
  )) }),
2579
- /* @__PURE__ */ jsx(StandardKeypad, {})
2674
+ /* @__PURE__ */ d(le, {})
2580
2675
  ] });
2581
2676
  }
2582
- function ProgrammerKeypad() {
2583
- const { display: e, setDisplay: t, service: r } = useCalculator(), [a, o] = useState("DEC"), n = (l) => {
2677
+ function Xe() {
2678
+ const { display: e, setDisplay: t, service: r } = N(), [o, a] = P("DEC"), n = (c) => {
2584
2679
  try {
2585
- const p = r.convertBase(e, a, l);
2586
- t(p), o(l);
2680
+ const u = r.convertBase(e, o, c);
2681
+ t(u), a(c);
2587
2682
  } catch {
2588
2683
  t("Error");
2589
2684
  }
2590
- }, i = a === "HEX" ? ["A", "B", "C", "D", "E", "F"] : [];
2591
- return /* @__PURE__ */ jsxs("div", { children: [
2592
- /* @__PURE__ */ jsx(
2685
+ }, i = o === "HEX" ? ["A", "B", "C", "D", "E", "F"] : [];
2686
+ return /* @__PURE__ */ v("div", { children: [
2687
+ /* @__PURE__ */ d(
2593
2688
  "div",
2594
2689
  {
2595
2690
  style: {
@@ -2598,35 +2693,35 @@ function ProgrammerKeypad() {
2598
2693
  padding: "8px",
2599
2694
  backgroundColor: "var(--nice-bg-secondary, #252525)"
2600
2695
  },
2601
- children: ["BIN", "OCT", "DEC", "HEX"].map((l) => /* @__PURE__ */ jsx(
2696
+ children: ["BIN", "OCT", "DEC", "HEX"].map((c) => /* @__PURE__ */ d(
2602
2697
  "button",
2603
2698
  {
2604
- onClick: () => n(l),
2699
+ onClick: () => n(c),
2605
2700
  style: {
2606
2701
  flex: 1,
2607
2702
  padding: "8px",
2608
2703
  border: "none",
2609
2704
  borderRadius: "4px",
2610
- backgroundColor: a === l ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-border, #3c3c3c)",
2611
- color: "var(--nice-text-on-primary, #fff)",
2705
+ backgroundColor: o === c ? "var(--nice-primary-hover, #1976d2)" : "var(--nice-border, #3c3c3c)",
2706
+ color: "var(--nice-color-white, #fff)",
2612
2707
  cursor: "pointer"
2613
2708
  },
2614
- children: l
2709
+ children: c
2615
2710
  },
2616
- l
2711
+ c
2617
2712
  ))
2618
2713
  }
2619
2714
  ),
2620
- i.length > 0 && /* @__PURE__ */ jsx("div", { style: { ...styles$1.keypad, gridTemplateColumns: "repeat(6, 1fr)" }, children: i.map((l) => /* @__PURE__ */ jsx(
2715
+ i.length > 0 && /* @__PURE__ */ d("div", { style: { ...B.keypad, gridTemplateColumns: "repeat(6, 1fr)" }, children: i.map((c) => /* @__PURE__ */ d(
2621
2716
  "button",
2622
2717
  {
2623
- onClick: () => t(e === "0" ? l : e + l),
2624
- style: styles$1.key,
2625
- children: l
2718
+ onClick: () => t(e === "0" ? c : e + c),
2719
+ style: B.key,
2720
+ children: c
2626
2721
  },
2627
- l
2722
+ c
2628
2723
  )) }),
2629
- /* @__PURE__ */ jsx("div", { style: { ...styles$1.keypad, gridTemplateColumns: "repeat(4, 1fr)" }, children: [
2724
+ /* @__PURE__ */ d("div", { style: { ...B.keypad, gridTemplateColumns: "repeat(4, 1fr)" }, children: [
2630
2725
  "7",
2631
2726
  "8",
2632
2727
  "9",
@@ -2643,63 +2738,63 @@ function ProgrammerKeypad() {
2643
2738
  "NOT",
2644
2739
  "<<",
2645
2740
  ">>"
2646
- ].map((l) => {
2647
- const p = ["AND", "OR", "XOR", "NOT", "<<", ">>"].includes(l);
2648
- return /* @__PURE__ */ jsx(
2741
+ ].map((c) => {
2742
+ const u = ["AND", "OR", "XOR", "NOT", "<<", ">>"].includes(c);
2743
+ return /* @__PURE__ */ d(
2649
2744
  "button",
2650
2745
  {
2651
- onClick: () => t(e === "0" ? l : e + l),
2652
- style: { ...styles$1.key, ...p ? styles$1.keyFunction : {} },
2653
- children: l
2746
+ onClick: () => t(e === "0" ? c : e + c),
2747
+ style: { ...B.key, ...u ? B.keyFunction : {} },
2748
+ children: c
2654
2749
  },
2655
- l
2750
+ c
2656
2751
  );
2657
2752
  }) })
2658
2753
  ] });
2659
2754
  }
2660
- function MatrixMode() {
2661
- const { t: e } = useNiceTranslation(), [t, r] = useState(MatrixOps.create(2, 2)), [a, o] = useState(MatrixOps.create(2, 2)), [n, i] = useState(""), l = (s, d, g, y, h) => {
2662
- const w = { ...s, data: s.data.map((u) => [...u]) };
2663
- w.data[g][y] = parseFloat(h) || 0, d(w);
2664
- }, p = [
2665
- { label: "A + B", fn: () => MatrixOps.toString(MatrixOps.add(t, a)) },
2666
- { label: "A - B", fn: () => MatrixOps.toString(MatrixOps.subtract(t, a)) },
2667
- { label: "A × B", fn: () => MatrixOps.toString(MatrixOps.multiply(t, a)) },
2668
- { label: "det(A)", fn: () => MatrixOps.determinant(t).toFixed(4) },
2669
- { label: "Aᵀ", fn: () => MatrixOps.toString(MatrixOps.transpose(t)) },
2670
- { label: "A⁻¹", fn: () => MatrixOps.toString(MatrixOps.inverse(t)) }
2755
+ function Ge() {
2756
+ const { t: e } = L(), [t, r] = P(z.create(2, 2)), [o, a] = P(z.create(2, 2)), [n, i] = P(""), c = (s, p, m, y, f) => {
2757
+ const C = { ...s, data: s.data.map((x) => [...x]) };
2758
+ C.data[m][y] = parseFloat(f) || 0, p(C);
2759
+ }, u = [
2760
+ { label: "A + B", fn: () => z.toString(z.add(t, o)) },
2761
+ { label: "A - B", fn: () => z.toString(z.subtract(t, o)) },
2762
+ { label: "A × B", fn: () => z.toString(z.multiply(t, o)) },
2763
+ { label: "det(A)", fn: () => z.determinant(t).toFixed(4) },
2764
+ { label: "Aᵀ", fn: () => z.toString(z.transpose(t)) },
2765
+ { label: "A⁻¹", fn: () => z.toString(z.inverse(t)) }
2671
2766
  ];
2672
- return /* @__PURE__ */ jsxs("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2673
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "12px", marginBottom: "12px" }, children: [
2674
- /* @__PURE__ */ jsxs("div", { children: [
2675
- /* @__PURE__ */ jsx("div", { style: { color: "var(--nice-text-secondary, #888)", marginBottom: "4px" }, children: e("calculator.matrixA", "Matrix A") }),
2676
- /* @__PURE__ */ jsx(
2677
- MatrixInput,
2767
+ return /* @__PURE__ */ v("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2768
+ /* @__PURE__ */ v("div", { style: { display: "flex", gap: "12px", marginBottom: "12px" }, children: [
2769
+ /* @__PURE__ */ v("div", { children: [
2770
+ /* @__PURE__ */ d("div", { style: { color: "var(--nice-text-secondary, #888)", marginBottom: "4px" }, children: e("calculator.matrixA", "Matrix A") }),
2771
+ /* @__PURE__ */ d(
2772
+ re,
2678
2773
  {
2679
2774
  matrix: t,
2680
- onChange: (s, d, g) => l(t, r, s, d, g)
2775
+ onChange: (s, p, m) => c(t, r, s, p, m)
2681
2776
  }
2682
2777
  )
2683
2778
  ] }),
2684
- /* @__PURE__ */ jsxs("div", { children: [
2685
- /* @__PURE__ */ jsx("div", { style: { color: "var(--nice-text-secondary, #888)", marginBottom: "4px" }, children: e("calculator.matrixB", "Matrix B") }),
2686
- /* @__PURE__ */ jsx(
2687
- MatrixInput,
2779
+ /* @__PURE__ */ v("div", { children: [
2780
+ /* @__PURE__ */ d("div", { style: { color: "var(--nice-text-secondary, #888)", marginBottom: "4px" }, children: e("calculator.matrixB", "Matrix B") }),
2781
+ /* @__PURE__ */ d(
2782
+ re,
2688
2783
  {
2689
- matrix: a,
2690
- onChange: (s, d, g) => l(a, o, s, d, g)
2784
+ matrix: o,
2785
+ onChange: (s, p, m) => c(o, a, s, p, m)
2691
2786
  }
2692
2787
  )
2693
2788
  ] })
2694
2789
  ] }),
2695
- /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap", marginBottom: "12px" }, children: p.map((s) => /* @__PURE__ */ jsx(
2790
+ /* @__PURE__ */ d("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap", marginBottom: "12px" }, children: u.map((s) => /* @__PURE__ */ d(
2696
2791
  "button",
2697
2792
  {
2698
2793
  onClick: () => {
2699
2794
  try {
2700
2795
  i(s.fn());
2701
- } catch (d) {
2702
- i(d.message);
2796
+ } catch (p) {
2797
+ i(p.message);
2703
2798
  }
2704
2799
  },
2705
2800
  style: {
@@ -2714,7 +2809,7 @@ function MatrixMode() {
2714
2809
  },
2715
2810
  s.label
2716
2811
  )) }),
2717
- n && /* @__PURE__ */ jsx(
2812
+ n && /* @__PURE__ */ d(
2718
2813
  "pre",
2719
2814
  {
2720
2815
  style: {
@@ -2727,41 +2822,41 @@ function MatrixMode() {
2727
2822
  )
2728
2823
  ] });
2729
2824
  }
2730
- function MatrixInput({
2825
+ function re({
2731
2826
  matrix: e,
2732
2827
  onChange: t
2733
2828
  }) {
2734
- return /* @__PURE__ */ jsx(
2829
+ return /* @__PURE__ */ d(
2735
2830
  "div",
2736
2831
  {
2737
2832
  style: { display: "grid", gridTemplateColumns: `repeat(${e.cols}, 50px)`, gap: "4px" },
2738
2833
  children: e.data.map(
2739
- (r, a) => r.map((o, n) => /* @__PURE__ */ jsx(
2834
+ (r, o) => r.map((a, n) => /* @__PURE__ */ d(
2740
2835
  "input",
2741
2836
  {
2742
2837
  type: "number",
2743
- value: o,
2744
- onChange: (i) => t(a, n, i.target.value),
2838
+ value: a,
2839
+ onChange: (i) => t(o, n, i.target.value),
2745
2840
  style: {
2746
2841
  width: "100%",
2747
2842
  padding: "4px",
2748
2843
  textAlign: "center",
2749
2844
  backgroundColor: "var(--nice-border, #3c3c3c)",
2750
- color: "var(--nice-text-on-primary, #fff)",
2845
+ color: "var(--nice-color-white, #fff)",
2751
2846
  border: "1px solid var(--nice-border-color, #555)",
2752
2847
  borderRadius: "4px"
2753
2848
  }
2754
2849
  },
2755
- `${a}-${n}`
2850
+ `${o}-${n}`
2756
2851
  ))
2757
2852
  )
2758
2853
  }
2759
2854
  );
2760
2855
  }
2761
- function CalculusMode() {
2762
- const { t: e } = useNiceTranslation(), [t, r] = useState("x^2"), [a, o] = useState("");
2763
- return /* @__PURE__ */ jsxs("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2764
- /* @__PURE__ */ jsx(
2856
+ function je() {
2857
+ const { t: e } = L(), [t, r] = P("x^2"), [o, a] = P("");
2858
+ return /* @__PURE__ */ v("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2859
+ /* @__PURE__ */ d(
2765
2860
  "input",
2766
2861
  {
2767
2862
  type: "text",
@@ -2773,17 +2868,17 @@ function CalculusMode() {
2773
2868
  padding: "8px",
2774
2869
  marginBottom: "12px",
2775
2870
  backgroundColor: "var(--nice-border, #3c3c3c)",
2776
- color: "var(--nice-text-on-primary, #fff)",
2871
+ color: "var(--nice-color-white, #fff)",
2777
2872
  border: "1px solid var(--nice-border-color, #555)",
2778
2873
  borderRadius: "4px"
2779
2874
  }
2780
2875
  }
2781
2876
  ),
2782
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap", marginBottom: "12px" }, children: [
2783
- /* @__PURE__ */ jsx(
2877
+ /* @__PURE__ */ v("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap", marginBottom: "12px" }, children: [
2878
+ /* @__PURE__ */ d(
2784
2879
  "button",
2785
2880
  {
2786
- onClick: () => o(`d/dx(${t}) = ${CalculusOps.symbolicDerivative(t)}`),
2881
+ onClick: () => a(`d/dx(${t}) = ${te.symbolicDerivative(t)}`),
2787
2882
  style: {
2788
2883
  padding: "8px 12px",
2789
2884
  backgroundColor: "var(--nice-success, #4caf50)",
@@ -2795,10 +2890,10 @@ function CalculusMode() {
2795
2890
  children: e("calculator.differentiate", "Differentiate")
2796
2891
  }
2797
2892
  ),
2798
- /* @__PURE__ */ jsx(
2893
+ /* @__PURE__ */ d(
2799
2894
  "button",
2800
2895
  {
2801
- onClick: () => o(`∫(${t})dx = ${CalculusOps.symbolicIntegral(t)}`),
2896
+ onClick: () => a(`∫(${t})dx = ${te.symbolicIntegral(t)}`),
2802
2897
  style: {
2803
2898
  padding: "8px 12px",
2804
2899
  backgroundColor: "var(--nice-primary, #2196f3)",
@@ -2811,7 +2906,7 @@ function CalculusMode() {
2811
2906
  }
2812
2907
  )
2813
2908
  ] }),
2814
- a && /* @__PURE__ */ jsx(
2909
+ o && /* @__PURE__ */ d(
2815
2910
  "div",
2816
2911
  {
2817
2912
  style: {
@@ -2821,108 +2916,108 @@ function CalculusMode() {
2821
2916
  backgroundColor: "var(--nice-bg, #1e1e1e)",
2822
2917
  borderRadius: "4px"
2823
2918
  },
2824
- children: a
2919
+ children: o
2825
2920
  }
2826
2921
  )
2827
2922
  ] });
2828
2923
  }
2829
- function UnitsMode() {
2830
- const { t: e } = useNiceTranslation(), { service: t } = useCalculator(), [r, a] = useState("1"), [o, n] = useState("m"), [i, l] = useState("ft"), [p, s] = useState("Length"), [d, g] = useState(""), y = t.getUnitCategories(), h = t.getUnitsByCategory(p), w = () => {
2924
+ function Fe() {
2925
+ const { t: e } = L(), { service: t } = N(), [r, o] = P("1"), [a, n] = P("m"), [i, c] = P("ft"), [u, s] = P("Length"), [p, m] = P(""), y = t.getUnitCategories(), f = t.getUnitsByCategory(u), C = () => {
2831
2926
  try {
2832
- const u = t.convertUnits(parseFloat(r), o, i);
2833
- g(`${r} ${o} = ${t.format(u)} ${i}`);
2834
- } catch (u) {
2835
- g(u.message);
2927
+ const x = t.convertUnits(parseFloat(r), a, i);
2928
+ m(`${r} ${a} = ${t.format(x)} ${i}`);
2929
+ } catch (x) {
2930
+ m(x.message);
2836
2931
  }
2837
2932
  };
2838
- return /* @__PURE__ */ jsxs("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2839
- /* @__PURE__ */ jsx(
2933
+ return /* @__PURE__ */ v("div", { style: { padding: "12px", backgroundColor: "var(--nice-bg-secondary, #252525)" }, children: [
2934
+ /* @__PURE__ */ d(
2840
2935
  "select",
2841
2936
  {
2842
- value: p,
2843
- onChange: (u) => {
2844
- s(u.target.value);
2845
- const f = t.getUnitsByCategory(u.target.value);
2846
- f.length >= 2 && (n(f[0].symbol), l(f[1].symbol));
2937
+ value: u,
2938
+ onChange: (x) => {
2939
+ s(x.target.value);
2940
+ const b = t.getUnitsByCategory(x.target.value);
2941
+ b.length >= 2 && (n(b[0].symbol), c(b[1].symbol));
2847
2942
  },
2848
2943
  style: {
2849
2944
  width: "100%",
2850
2945
  padding: "8px",
2851
2946
  marginBottom: "12px",
2852
2947
  backgroundColor: "var(--nice-border, #3c3c3c)",
2853
- color: "var(--nice-text-on-primary, #fff)",
2948
+ color: "var(--nice-color-white, #fff)",
2854
2949
  border: "1px solid var(--nice-border-color, #555)",
2855
2950
  borderRadius: "4px"
2856
2951
  },
2857
- children: y.map((u) => /* @__PURE__ */ jsx("option", { value: u, children: u }, u))
2952
+ children: y.map((x) => /* @__PURE__ */ d("option", { value: x, children: x }, x))
2858
2953
  }
2859
2954
  ),
2860
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "12px" }, children: [
2861
- /* @__PURE__ */ jsx(
2955
+ /* @__PURE__ */ v("div", { style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "12px" }, children: [
2956
+ /* @__PURE__ */ d(
2862
2957
  "input",
2863
2958
  {
2864
2959
  type: "number",
2865
2960
  value: r,
2866
- onChange: (u) => a(u.target.value),
2961
+ onChange: (x) => o(x.target.value),
2867
2962
  style: {
2868
2963
  flex: 1,
2869
2964
  padding: "8px",
2870
2965
  backgroundColor: "var(--nice-border, #3c3c3c)",
2871
- color: "var(--nice-text-on-primary, #fff)",
2966
+ color: "var(--nice-color-white, #fff)",
2872
2967
  border: "1px solid var(--nice-border-color, #555)",
2873
2968
  borderRadius: "4px"
2874
2969
  }
2875
2970
  }
2876
2971
  ),
2877
- /* @__PURE__ */ jsx(
2972
+ /* @__PURE__ */ d(
2878
2973
  "select",
2879
2974
  {
2880
- value: o,
2881
- onChange: (u) => n(u.target.value),
2975
+ value: a,
2976
+ onChange: (x) => n(x.target.value),
2882
2977
  style: {
2883
2978
  padding: "8px",
2884
2979
  backgroundColor: "var(--nice-border, #3c3c3c)",
2885
- color: "var(--nice-text-on-primary, #fff)",
2980
+ color: "var(--nice-color-white, #fff)",
2886
2981
  border: "1px solid var(--nice-border-color, #555)",
2887
2982
  borderRadius: "4px"
2888
2983
  },
2889
- children: h.map((u) => /* @__PURE__ */ jsxs("option", { value: u.symbol, children: [
2890
- u.name,
2984
+ children: f.map((x) => /* @__PURE__ */ v("option", { value: x.symbol, children: [
2985
+ x.name,
2891
2986
  " (",
2892
- u.symbol,
2987
+ x.symbol,
2893
2988
  ")"
2894
- ] }, u.symbol))
2989
+ ] }, x.symbol))
2895
2990
  }
2896
2991
  )
2897
2992
  ] }),
2898
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "12px" }, children: [
2899
- /* @__PURE__ */ jsx("span", { style: { color: "var(--nice-text-secondary, #888)" }, children: "→" }),
2900
- /* @__PURE__ */ jsx(
2993
+ /* @__PURE__ */ v("div", { style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "12px" }, children: [
2994
+ /* @__PURE__ */ d("span", { style: { color: "var(--nice-text-secondary, #888)" }, children: /* @__PURE__ */ d(G, { name: "arrow-right", size: 12 }) }),
2995
+ /* @__PURE__ */ d(
2901
2996
  "select",
2902
2997
  {
2903
2998
  value: i,
2904
- onChange: (u) => l(u.target.value),
2999
+ onChange: (x) => c(x.target.value),
2905
3000
  style: {
2906
3001
  flex: 1,
2907
3002
  padding: "8px",
2908
3003
  backgroundColor: "var(--nice-border, #3c3c3c)",
2909
- color: "var(--nice-text-on-primary, #fff)",
3004
+ color: "var(--nice-color-white, #fff)",
2910
3005
  border: "1px solid var(--nice-border-color, #555)",
2911
3006
  borderRadius: "4px"
2912
3007
  },
2913
- children: h.map((u) => /* @__PURE__ */ jsxs("option", { value: u.symbol, children: [
2914
- u.name,
3008
+ children: f.map((x) => /* @__PURE__ */ v("option", { value: x.symbol, children: [
3009
+ x.name,
2915
3010
  " (",
2916
- u.symbol,
3011
+ x.symbol,
2917
3012
  ")"
2918
- ] }, u.symbol))
3013
+ ] }, x.symbol))
2919
3014
  }
2920
3015
  )
2921
3016
  ] }),
2922
- /* @__PURE__ */ jsx(
3017
+ /* @__PURE__ */ d(
2923
3018
  "button",
2924
3019
  {
2925
- onClick: w,
3020
+ onClick: C,
2926
3021
  style: {
2927
3022
  width: "100%",
2928
3023
  padding: "12px",
@@ -2936,7 +3031,7 @@ function UnitsMode() {
2936
3031
  children: e("calculator.convert", "Convert")
2937
3032
  }
2938
3033
  ),
2939
- d && /* @__PURE__ */ jsx(
3034
+ p && /* @__PURE__ */ d(
2940
3035
  "div",
2941
3036
  {
2942
3037
  style: {
@@ -2945,12 +3040,12 @@ function UnitsMode() {
2945
3040
  fontSize: "18px",
2946
3041
  textAlign: "center"
2947
3042
  },
2948
- children: d
3043
+ children: p
2949
3044
  }
2950
3045
  )
2951
3046
  ] });
2952
3047
  }
2953
- const GeoMath = {
3048
+ const E = {
2954
3049
  /** Distance between two points */
2955
3050
  distance(e, t) {
2956
3051
  return Math.sqrt((t.x - e.x) ** 2 + (t.y - e.y) ** 2);
@@ -2961,8 +3056,8 @@ const GeoMath = {
2961
3056
  },
2962
3057
  /** Angle between three points (vertex at p2) */
2963
3058
  angle(e, t, r) {
2964
- const a = Math.atan2(e.y - t.y, e.x - t.x);
2965
- let n = Math.atan2(r.y - t.y, r.x - t.x) - a;
3059
+ const o = Math.atan2(e.y - t.y, e.x - t.x);
3060
+ let n = Math.atan2(r.y - t.y, r.x - t.x) - o;
2966
3061
  return n < 0 && (n += 2 * Math.PI), n;
2967
3062
  },
2968
3063
  /** Angle in degrees */
@@ -2971,79 +3066,79 @@ const GeoMath = {
2971
3066
  },
2972
3067
  /** Point on line closest to given point */
2973
3068
  closestPointOnLine(e, t, r) {
2974
- const a = t.x - e.x, o = t.y - e.y, n = ((r.x - e.x) * a + (r.y - e.y) * o) / (a * a + o * o);
2975
- return { x: e.x + n * a, y: e.y + n * o };
3069
+ const o = t.x - e.x, a = t.y - e.y, n = ((r.x - e.x) * o + (r.y - e.y) * a) / (o * o + a * a);
3070
+ return { x: e.x + n * o, y: e.y + n * a };
2976
3071
  },
2977
3072
  /** Line-line intersection */
2978
- lineIntersection(e, t, r, a) {
2979
- const o = (e.x - t.x) * (r.y - a.y) - (e.y - t.y) * (r.x - a.x);
2980
- if (Math.abs(o) < 1e-10)
3073
+ lineIntersection(e, t, r, o) {
3074
+ const a = (e.x - t.x) * (r.y - o.y) - (e.y - t.y) * (r.x - o.x);
3075
+ if (Math.abs(a) < 1e-10)
2981
3076
  return null;
2982
- const n = ((e.x - r.x) * (r.y - a.y) - (e.y - r.y) * (r.x - a.x)) / o;
3077
+ const n = ((e.x - r.x) * (r.y - o.y) - (e.y - r.y) * (r.x - o.x)) / a;
2983
3078
  return {
2984
3079
  x: e.x + n * (t.x - e.x),
2985
3080
  y: e.y + n * (t.y - e.y)
2986
3081
  };
2987
3082
  },
2988
3083
  /** Circle-line intersection */
2989
- circleLineIntersection(e, t, r, a) {
2990
- const o = a.x - r.x, n = a.y - r.y, i = r.x - e.x, l = r.y - e.y, p = o * o + n * n, s = 2 * (i * o + l * n), d = i * i + l * l - t * t, g = s * s - 4 * p * d;
2991
- if (g < 0)
3084
+ circleLineIntersection(e, t, r, o) {
3085
+ const a = o.x - r.x, n = o.y - r.y, i = r.x - e.x, c = r.y - e.y, u = a * a + n * n, s = 2 * (i * a + c * n), p = i * i + c * c - t * t, m = s * s - 4 * u * p;
3086
+ if (m < 0)
2992
3087
  return [];
2993
- const y = Math.sqrt(g), h = (-s - y) / (2 * p), w = (-s + y) / (2 * p), u = [];
2994
- return h >= 0 && h <= 1 && u.push({ x: r.x + h * o, y: r.y + h * n }), w >= 0 && w <= 1 && Math.abs(w - h) > 1e-10 && u.push({ x: r.x + w * o, y: r.y + w * n }), u;
3088
+ const y = Math.sqrt(m), f = (-s - y) / (2 * u), C = (-s + y) / (2 * u), x = [];
3089
+ return f >= 0 && f <= 1 && x.push({ x: r.x + f * a, y: r.y + f * n }), C >= 0 && C <= 1 && Math.abs(C - f) > 1e-10 && x.push({ x: r.x + C * a, y: r.y + C * n }), x;
2995
3090
  },
2996
3091
  /** Circle-circle intersection */
2997
- circleCircleIntersection(e, t, r, a) {
2998
- const o = this.distance(e, r);
2999
- if (o > t + a || o < Math.abs(t - a) || o === 0)
3092
+ circleCircleIntersection(e, t, r, o) {
3093
+ const a = this.distance(e, r);
3094
+ if (a > t + o || a < Math.abs(t - o) || a === 0)
3000
3095
  return [];
3001
- const n = (t * t - a * a + o * o) / (2 * o), i = Math.sqrt(t * t - n * n), l = e.x + n * (r.x - e.x) / o, p = e.y + n * (r.y - e.y) / o;
3096
+ const n = (t * t - o * o + a * a) / (2 * a), i = Math.sqrt(t * t - n * n), c = e.x + n * (r.x - e.x) / a, u = e.y + n * (r.y - e.y) / a;
3002
3097
  return [
3003
- { x: l + i * (r.y - e.y) / o, y: p - i * (r.x - e.x) / o },
3004
- { x: l - i * (r.y - e.y) / o, y: p + i * (r.x - e.x) / o }
3098
+ { x: c + i * (r.y - e.y) / a, y: u - i * (r.x - e.x) / a },
3099
+ { x: c - i * (r.y - e.y) / a, y: u + i * (r.x - e.x) / a }
3005
3100
  ];
3006
3101
  },
3007
3102
  /** Perpendicular line through point */
3008
3103
  perpendicularThrough(e, t, r) {
3009
3104
  this.closestPointOnLine(e, t, r);
3010
- const a = t.x - e.x, o = t.y - e.y;
3105
+ const o = t.x - e.x, a = t.y - e.y;
3011
3106
  return {
3012
3107
  p1: r,
3013
- p2: { x: r.x - o, y: r.y + a }
3108
+ p2: { x: r.x - a, y: r.y + o }
3014
3109
  };
3015
3110
  },
3016
3111
  /** Parallel line through point */
3017
3112
  parallelThrough(e, t, r) {
3018
- const a = t.x - e.x, o = t.y - e.y;
3113
+ const o = t.x - e.x, a = t.y - e.y;
3019
3114
  return {
3020
3115
  p1: r,
3021
- p2: { x: r.x + a, y: r.y + o }
3116
+ p2: { x: r.x + o, y: r.y + a }
3022
3117
  };
3023
3118
  },
3024
3119
  /** Angle bisector */
3025
3120
  angleBisector(e, t, r) {
3026
- const a = Math.atan2(e.y - t.y, e.x - t.x), o = Math.atan2(r.y - t.y, r.x - t.x);
3027
- let n = (a + o) / 2;
3028
- return Math.abs(o - a) > Math.PI && (n += Math.PI), {
3121
+ const o = Math.atan2(e.y - t.y, e.x - t.x), a = Math.atan2(r.y - t.y, r.x - t.x);
3122
+ let n = (o + a) / 2;
3123
+ return Math.abs(a - o) > Math.PI && (n += Math.PI), {
3029
3124
  x: t.x + Math.cos(n),
3030
3125
  y: t.y + Math.sin(n)
3031
3126
  };
3032
3127
  },
3033
3128
  /** Reflect point over line */
3034
3129
  reflect(e, t, r) {
3035
- const a = this.closestPointOnLine(t, r, e);
3130
+ const o = this.closestPointOnLine(t, r, e);
3036
3131
  return {
3037
- x: 2 * a.x - e.x,
3038
- y: 2 * a.y - e.y
3132
+ x: 2 * o.x - e.x,
3133
+ y: 2 * o.y - e.y
3039
3134
  };
3040
3135
  },
3041
3136
  /** Rotate point around center */
3042
3137
  rotate(e, t, r) {
3043
- const a = Math.cos(r), o = Math.sin(r), n = e.x - t.x, i = e.y - t.y;
3138
+ const o = Math.cos(r), a = Math.sin(r), n = e.x - t.x, i = e.y - t.y;
3044
3139
  return {
3045
- x: t.x + n * a - i * o,
3046
- y: t.y + n * o + i * a
3140
+ x: t.x + n * o - i * a,
3141
+ y: t.y + n * a + i * o
3047
3142
  };
3048
3143
  },
3049
3144
  /** Translate point */
@@ -3061,9 +3156,9 @@ const GeoMath = {
3061
3156
  polygonArea(e) {
3062
3157
  let t = 0;
3063
3158
  const r = e.length;
3064
- for (let a = 0; a < r; a++) {
3065
- const o = (a + 1) % r;
3066
- t += e[a].x * e[o].y, t -= e[o].x * e[a].y;
3159
+ for (let o = 0; o < r; o++) {
3160
+ const a = (o + 1) % r;
3161
+ t += e[o].x * e[a].y, t -= e[a].x * e[o].y;
3067
3162
  }
3068
3163
  return Math.abs(t) / 2;
3069
3164
  },
@@ -3071,23 +3166,23 @@ const GeoMath = {
3071
3166
  polygonPerimeter(e) {
3072
3167
  let t = 0;
3073
3168
  const r = e.length;
3074
- for (let a = 0; a < r; a++) {
3075
- const o = (a + 1) % r;
3076
- t += this.distance(e[a], e[o]);
3169
+ for (let o = 0; o < r; o++) {
3170
+ const a = (o + 1) % r;
3171
+ t += this.distance(e[o], e[a]);
3077
3172
  }
3078
3173
  return t;
3079
3174
  },
3080
3175
  /** Triangle circumcenter */
3081
3176
  circumcenter(e, t, r) {
3082
- const a = 2 * (e.x * (t.y - r.y) + t.x * (r.y - e.y) + r.x * (e.y - t.y)), o = ((e.x ** 2 + e.y ** 2) * (t.y - r.y) + (t.x ** 2 + t.y ** 2) * (r.y - e.y) + (r.x ** 2 + r.y ** 2) * (e.y - t.y)) / a, n = ((e.x ** 2 + e.y ** 2) * (r.x - t.x) + (t.x ** 2 + t.y ** 2) * (e.x - r.x) + (r.x ** 2 + r.y ** 2) * (t.x - e.x)) / a;
3083
- return { x: o, y: n };
3177
+ const o = 2 * (e.x * (t.y - r.y) + t.x * (r.y - e.y) + r.x * (e.y - t.y)), a = ((e.x ** 2 + e.y ** 2) * (t.y - r.y) + (t.x ** 2 + t.y ** 2) * (r.y - e.y) + (r.x ** 2 + r.y ** 2) * (e.y - t.y)) / o, n = ((e.x ** 2 + e.y ** 2) * (r.x - t.x) + (t.x ** 2 + t.y ** 2) * (e.x - r.x) + (r.x ** 2 + r.y ** 2) * (t.x - e.x)) / o;
3178
+ return { x: a, y: n };
3084
3179
  },
3085
3180
  /** Triangle incenter */
3086
3181
  incenter(e, t, r) {
3087
- const a = this.distance(e, t), o = this.distance(t, r), n = this.distance(r, e), i = a + o + n;
3182
+ const o = this.distance(e, t), a = this.distance(t, r), n = this.distance(r, e), i = o + a + n;
3088
3183
  return {
3089
- x: (o * e.x + n * t.x + a * r.x) / i,
3090
- y: (o * e.y + n * t.y + a * r.y) / i
3184
+ x: (a * e.x + n * t.x + o * r.x) / i,
3185
+ y: (a * e.y + n * t.y + o * r.y) / i
3091
3186
  };
3092
3187
  },
3093
3188
  /** Triangle centroid */
@@ -3098,15 +3193,15 @@ const GeoMath = {
3098
3193
  };
3099
3194
  }
3100
3195
  };
3101
- class GeometryService {
3196
+ class Oe {
3102
3197
  constructor() {
3103
- M(this, "elements", /* @__PURE__ */ new Map());
3104
- M(this, "nextLabel", 1);
3198
+ T(this, "elements", /* @__PURE__ */ new Map());
3199
+ T(this, "nextLabel", 1);
3105
3200
  }
3106
3201
  /** Add element */
3107
3202
  addElement(t) {
3108
- const r = this.generateId(), a = { ...t, id: r };
3109
- return this.elements.set(r, a), a;
3203
+ const r = this.generateId(), o = { ...t, id: r };
3204
+ return this.elements.set(r, o), o;
3110
3205
  }
3111
3206
  /** Get element */
3112
3207
  getElement(t) {
@@ -3119,15 +3214,15 @@ class GeometryService {
3119
3214
  }
3120
3215
  /** Update element */
3121
3216
  updateElement(t, r) {
3122
- const a = this.elements.get(t);
3123
- a && this.elements.set(t, { ...a, ...r, id: t, type: a.type });
3217
+ const o = this.elements.get(t);
3218
+ o && this.elements.set(t, { ...o, ...r, id: t, type: o.type });
3124
3219
  }
3125
3220
  /** Delete element */
3126
3221
  deleteElement(t) {
3127
3222
  var r;
3128
3223
  this.elements.delete(t);
3129
- for (const [a, o] of this.elements)
3130
- (r = o.dependencies) != null && r.includes(t) && this.deleteElement(a);
3224
+ for (const [o, a] of this.elements)
3225
+ (r = a.dependencies) != null && r.includes(t) && this.deleteElement(o);
3131
3226
  }
3132
3227
  /** Get all elements */
3133
3228
  getAllElements() {
@@ -3142,12 +3237,12 @@ class GeometryService {
3142
3237
  this.elements.clear(), this.nextLabel = 1;
3143
3238
  }
3144
3239
  /** Create point */
3145
- createPoint(t, r, a) {
3240
+ createPoint(t, r, o) {
3146
3241
  return this.addElement({
3147
3242
  type: "point",
3148
3243
  x: t,
3149
3244
  y: r,
3150
- label: a ?? this.getNextLabel(),
3245
+ label: o ?? this.getNextLabel(),
3151
3246
  color: { r: 0, g: 0, b: 0 },
3152
3247
  visible: !0,
3153
3248
  selected: !1,
@@ -3232,65 +3327,65 @@ class GeometryService {
3232
3327
  }
3233
3328
  /** Create midpoint */
3234
3329
  createMidpoint(t, r) {
3235
- const a = this.getPoint(t), o = this.getPoint(r);
3236
- if (!a || !o)
3330
+ const o = this.getPoint(t), a = this.getPoint(r);
3331
+ if (!o || !a)
3237
3332
  return null;
3238
- const n = GeoMath.midpoint(a, o), i = this.createPoint(n.x, n.y);
3333
+ const n = E.midpoint(o, a), i = this.createPoint(n.x, n.y);
3239
3334
  return i.dependencies = [t, r], i.color = { r: 0, g: 150, b: 0 }, i;
3240
3335
  }
3241
3336
  /** Create perpendicular */
3242
- createPerpendicular(t, r, a) {
3243
- const o = this.getPoint(t), n = this.getPoint(r), i = this.getPoint(a);
3244
- if (!o || !n || !i)
3337
+ createPerpendicular(t, r, o) {
3338
+ const a = this.getPoint(t), n = this.getPoint(r), i = this.getPoint(o);
3339
+ if (!a || !n || !i)
3245
3340
  return null;
3246
- const l = GeoMath.perpendicularThrough(o, n, i), p = this.createPoint(l.p2.x, l.p2.y), s = this.createLine(a, p.id);
3247
- return s.dependencies = [t, r, a], s;
3341
+ const c = E.perpendicularThrough(a, n, i), u = this.createPoint(c.p2.x, c.p2.y), s = this.createLine(o, u.id);
3342
+ return s.dependencies = [t, r, o], s;
3248
3343
  }
3249
3344
  /** Create parallel */
3250
- createParallel(t, r, a) {
3251
- const o = this.getPoint(t), n = this.getPoint(r), i = this.getPoint(a);
3252
- if (!o || !n || !i)
3345
+ createParallel(t, r, o) {
3346
+ const a = this.getPoint(t), n = this.getPoint(r), i = this.getPoint(o);
3347
+ if (!a || !n || !i)
3253
3348
  return null;
3254
- const l = GeoMath.parallelThrough(o, n, i), p = this.createPoint(l.p2.x, l.p2.y), s = this.createLine(a, p.id);
3255
- return s.dependencies = [t, r, a], s;
3349
+ const c = E.parallelThrough(a, n, i), u = this.createPoint(c.p2.x, c.p2.y), s = this.createLine(o, u.id);
3350
+ return s.dependencies = [t, r, o], s;
3256
3351
  }
3257
3352
  /** Create intersection point */
3258
3353
  createIntersection(t, r) {
3259
- const a = this.elements.get(t), o = this.elements.get(r);
3260
- if (!a || !o)
3354
+ const o = this.elements.get(t), a = this.elements.get(r);
3355
+ if (!o || !a)
3261
3356
  return [];
3262
3357
  const n = [], i = (s) => {
3263
3358
  if (s.type === "line" || s.type === "segment" || s.type === "ray") {
3264
- const d = s, g = this.getPoint(d.point1Id ?? d.originId), y = this.getPoint(d.point2Id ?? d.throughId);
3265
- if (g && y)
3266
- return [g, y];
3359
+ const p = s, m = this.getPoint(p.point1Id ?? p.originId), y = this.getPoint(p.point2Id ?? p.throughId);
3360
+ if (m && y)
3361
+ return [m, y];
3267
3362
  }
3268
3363
  return null;
3269
- }, l = i(a), p = i(o);
3270
- if (l && p) {
3271
- const s = GeoMath.lineIntersection(l[0], l[1], p[0], p[1]);
3364
+ }, c = i(o), u = i(a);
3365
+ if (c && u) {
3366
+ const s = E.lineIntersection(c[0], c[1], u[0], u[1]);
3272
3367
  if (s) {
3273
- const d = this.createPoint(s.x, s.y);
3274
- d.dependencies = [t, r], d.color = { r: 255, g: 0, b: 0 }, n.push(d);
3368
+ const p = this.createPoint(s.x, s.y);
3369
+ p.dependencies = [t, r], p.color = { r: 255, g: 0, b: 0 }, n.push(p);
3275
3370
  }
3276
3371
  }
3277
- if (a.type === "circle" && p) {
3278
- const s = a, d = this.getPoint(s.centerId);
3279
- if (d) {
3280
- const g = GeoMath.circleLineIntersection(d, s.radius, p[0], p[1]);
3281
- for (const y of g) {
3282
- const h = this.createPoint(y.x, y.y);
3283
- h.dependencies = [t, r], h.color = { r: 255, g: 0, b: 0 }, n.push(h);
3372
+ if (o.type === "circle" && u) {
3373
+ const s = o, p = this.getPoint(s.centerId);
3374
+ if (p) {
3375
+ const m = E.circleLineIntersection(p, s.radius, u[0], u[1]);
3376
+ for (const y of m) {
3377
+ const f = this.createPoint(y.x, y.y);
3378
+ f.dependencies = [t, r], f.color = { r: 255, g: 0, b: 0 }, n.push(f);
3284
3379
  }
3285
3380
  }
3286
3381
  }
3287
- if (a.type === "circle" && o.type === "circle") {
3288
- const s = a, d = o, g = this.getPoint(s.centerId), y = this.getPoint(d.centerId);
3289
- if (g && y) {
3290
- const h = GeoMath.circleCircleIntersection(g, s.radius, y, d.radius);
3291
- for (const w of h) {
3292
- const u = this.createPoint(w.x, w.y);
3293
- u.dependencies = [t, r], u.color = { r: 255, g: 0, b: 0 }, n.push(u);
3382
+ if (o.type === "circle" && a.type === "circle") {
3383
+ const s = o, p = a, m = this.getPoint(s.centerId), y = this.getPoint(p.centerId);
3384
+ if (m && y) {
3385
+ const f = E.circleCircleIntersection(m, s.radius, y, p.radius);
3386
+ for (const C of f) {
3387
+ const x = this.createPoint(C.x, C.y);
3388
+ x.dependencies = [t, r], x.color = { r: 255, g: 0, b: 0 }, n.push(x);
3294
3389
  }
3295
3390
  }
3296
3391
  }
@@ -3300,23 +3395,23 @@ class GeometryService {
3300
3395
  calculateMeasurement(t, r) {
3301
3396
  switch (t) {
3302
3397
  case "distance": {
3303
- const a = this.getPoint(r[0]), o = this.getPoint(r[1]);
3304
- if (a && o)
3305
- return GeoMath.distance(a, o);
3398
+ const o = this.getPoint(r[0]), a = this.getPoint(r[1]);
3399
+ if (o && a)
3400
+ return E.distance(o, a);
3306
3401
  break;
3307
3402
  }
3308
3403
  case "angle": {
3309
- const a = this.getPoint(r[0]), o = this.getPoint(r[1]), n = this.getPoint(r[2]);
3310
- if (a && o && n)
3311
- return GeoMath.angleDegrees(a, o, n);
3404
+ const o = this.getPoint(r[0]), a = this.getPoint(r[1]), n = this.getPoint(r[2]);
3405
+ if (o && a && n)
3406
+ return E.angleDegrees(o, a, n);
3312
3407
  break;
3313
3408
  }
3314
3409
  case "area":
3315
3410
  case "perimeter": {
3316
- const a = this.elements.get(r[0]);
3317
- if ((a == null ? void 0 : a.type) === "polygon") {
3318
- const o = a.pointIds.map((n) => this.getPoint(n)).filter(Boolean);
3319
- return t === "area" ? GeoMath.polygonArea(o) : GeoMath.polygonPerimeter(o);
3411
+ const o = this.elements.get(r[0]);
3412
+ if ((o == null ? void 0 : o.type) === "polygon") {
3413
+ const a = o.pointIds.map((n) => this.getPoint(n)).filter(Boolean);
3414
+ return t === "area" ? E.polygonArea(a) : E.polygonPerimeter(a);
3320
3415
  }
3321
3416
  break;
3322
3417
  }
@@ -3324,76 +3419,76 @@ class GeometryService {
3324
3419
  return 0;
3325
3420
  }
3326
3421
  /** Export to SVG */
3327
- exportSVG(t, r, a) {
3328
- const o = [
3422
+ exportSVG(t, r, o) {
3423
+ const a = [
3329
3424
  `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${r}" viewBox="0 0 ${t} ${r}">`
3330
3425
  ];
3331
- o.push(
3332
- `<rect width="100%" height="100%" fill="rgb(${a.backgroundColor.r},${a.backgroundColor.g},${a.backgroundColor.b})"/>`
3426
+ a.push(
3427
+ `<rect width="100%" height="100%" fill="rgb(${o.backgroundColor.r},${o.backgroundColor.g},${o.backgroundColor.b})"/>`
3333
3428
  );
3334
- const n = (i, l) => ({
3335
- x: t / 2 + (i - a.centerX) * a.scale,
3336
- y: r / 2 - (l - a.centerY) * a.scale
3429
+ const n = (i, c) => ({
3430
+ x: t / 2 + (i - o.centerX) * o.scale,
3431
+ y: r / 2 - (c - o.centerY) * o.scale
3337
3432
  });
3338
- if (a.showGrid) {
3339
- o.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');
3340
- for (let i = Math.floor(-t / 2 / a.scale + a.centerX); i <= t / 2 / a.scale + a.centerX; i += a.gridSpacing) {
3341
- const l = n(i, 0);
3342
- o.push(`<line x1="${l.x}" y1="0" x2="${l.x}" y2="${r}"/>`);
3433
+ if (o.showGrid) {
3434
+ a.push('<g stroke="var(--nice-border, #ddd)" stroke-width="0.5">');
3435
+ for (let i = Math.floor(-t / 2 / o.scale + o.centerX); i <= t / 2 / o.scale + o.centerX; i += o.gridSpacing) {
3436
+ const c = n(i, 0);
3437
+ a.push(`<line x1="${c.x}" y1="0" x2="${c.x}" y2="${r}"/>`);
3343
3438
  }
3344
- for (let i = Math.floor(-r / 2 / a.scale + a.centerY); i <= r / 2 / a.scale + a.centerY; i += a.gridSpacing) {
3345
- const l = n(0, i);
3346
- o.push(`<line x1="0" y1="${l.y}" x2="${t}" y2="${l.y}"/>`);
3439
+ for (let i = Math.floor(-r / 2 / o.scale + o.centerY); i <= r / 2 / o.scale + o.centerY; i += o.gridSpacing) {
3440
+ const c = n(0, i);
3441
+ a.push(`<line x1="0" y1="${c.y}" x2="${t}" y2="${c.y}"/>`);
3347
3442
  }
3348
- o.push("</g>");
3443
+ a.push("</g>");
3349
3444
  }
3350
- if (a.showAxes) {
3445
+ if (o.showAxes) {
3351
3446
  const i = n(0, 0);
3352
- o.push('<g stroke="var(--nice-text, #333)" stroke-width="1">'), o.push(`<line x1="0" y1="${i.y}" x2="${t}" y2="${i.y}"/>`), o.push(`<line x1="${i.x}" y1="0" x2="${i.x}" y2="${r}"/>`), o.push("</g>");
3447
+ a.push('<g stroke="var(--nice-text, #333)" stroke-width="1">'), a.push(`<line x1="0" y1="${i.y}" x2="${t}" y2="${i.y}"/>`), a.push(`<line x1="${i.x}" y1="0" x2="${i.x}" y2="${r}"/>`), a.push("</g>");
3353
3448
  }
3354
3449
  for (const i of this.getAllElements()) {
3355
3450
  if (!i.visible)
3356
3451
  continue;
3357
- const l = `rgb(${i.color.r},${i.color.g},${i.color.b})`;
3452
+ const c = `rgb(${i.color.r},${i.color.g},${i.color.b})`;
3358
3453
  switch (i.type) {
3359
3454
  case "point": {
3360
- const p = n(i.x, i.y);
3361
- o.push(`<circle cx="${p.x}" cy="${p.y}" r="${i.size}" fill="${l}"/>`), i.label && o.push(`<text x="${p.x + 8}" y="${p.y - 8}" font-size="12">${i.label}</text>`);
3455
+ const u = n(i.x, i.y);
3456
+ a.push(`<circle cx="${u.x}" cy="${u.y}" r="${i.size}" fill="${c}"/>`), i.label && a.push(`<text x="${u.x + 8}" y="${u.y - 8}" font-size="12">${i.label}</text>`);
3362
3457
  break;
3363
3458
  }
3364
3459
  case "segment": {
3365
- const p = this.getPoint(i.point1Id), s = this.getPoint(i.point2Id);
3366
- if (p && s) {
3367
- const d = n(p.x, p.y), g = n(s.x, s.y);
3368
- o.push(
3369
- `<line x1="${d.x}" y1="${d.y}" x2="${g.x}" y2="${g.y}" stroke="${l}" stroke-width="${i.width}"/>`
3460
+ const u = this.getPoint(i.point1Id), s = this.getPoint(i.point2Id);
3461
+ if (u && s) {
3462
+ const p = n(u.x, u.y), m = n(s.x, s.y);
3463
+ a.push(
3464
+ `<line x1="${p.x}" y1="${p.y}" x2="${m.x}" y2="${m.y}" stroke="${c}" stroke-width="${i.width}"/>`
3370
3465
  );
3371
3466
  }
3372
3467
  break;
3373
3468
  }
3374
3469
  case "circle": {
3375
- const p = this.getPoint(i.centerId);
3376
- if (p) {
3377
- const s = n(p.x, p.y), d = i.radius * a.scale, g = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
3378
- o.push(
3379
- `<circle cx="${s.x}" cy="${s.y}" r="${d}" fill="${g}" stroke="${l}" stroke-width="${i.width}"/>`
3470
+ const u = this.getPoint(i.centerId);
3471
+ if (u) {
3472
+ const s = n(u.x, u.y), p = i.radius * o.scale, m = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
3473
+ a.push(
3474
+ `<circle cx="${s.x}" cy="${s.y}" r="${p}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`
3380
3475
  );
3381
3476
  }
3382
3477
  break;
3383
3478
  }
3384
3479
  case "polygon": {
3385
- const p = i.pointIds.map((s) => this.getPoint(s)).filter(Boolean);
3386
- if (p.length > 0) {
3387
- const d = p.map((y) => n(y.x, y.y)).map((y, h) => `${h === 0 ? "M" : "L"}${y.x},${y.y}`).join(" ") + " Z", g = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
3388
- o.push(
3389
- `<path d="${d}" fill="${g}" stroke="${l}" stroke-width="${i.width}"/>`
3480
+ const u = i.pointIds.map((s) => this.getPoint(s)).filter(Boolean);
3481
+ if (u.length > 0) {
3482
+ const p = u.map((y) => n(y.x, y.y)).map((y, f) => `${f === 0 ? "M" : "L"}${y.x},${y.y}`).join(" ") + " Z", m = i.fill ? `rgba(${i.fill.r},${i.fill.g},${i.fill.b},${i.fill.a ?? 0.2})` : "none";
3483
+ a.push(
3484
+ `<path d="${p}" fill="${m}" stroke="${c}" stroke-width="${i.width}"/>`
3390
3485
  );
3391
3486
  }
3392
3487
  break;
3393
3488
  }
3394
3489
  }
3395
3490
  }
3396
- return o.push("</svg>"), o.join(`
3491
+ return a.push("</svg>"), a.join(`
3397
3492
  `);
3398
3493
  }
3399
3494
  generateId() {
@@ -3404,17 +3499,17 @@ class GeometryService {
3404
3499
  return this.nextLabel++, r < 26 ? t[r] : t[r % 26] + Math.floor(r / 26);
3405
3500
  }
3406
3501
  }
3407
- function createGeometryService() {
3408
- return new GeometryService();
3502
+ function nt() {
3503
+ return new Oe();
3409
3504
  }
3410
- const GeometryContext = createContext(null);
3411
- function useGeometry() {
3412
- const e = useContext(GeometryContext);
3505
+ const de = /* @__PURE__ */ F(null);
3506
+ function H() {
3507
+ const e = j(de);
3413
3508
  if (!e)
3414
3509
  throw new Error("useGeometry must be used within GeometryProvider");
3415
3510
  return e;
3416
3511
  }
3417
- const styles = {
3512
+ const q = {
3418
3513
  container: {
3419
3514
  display: "flex",
3420
3515
  height: "100%",
@@ -3463,14 +3558,14 @@ const styles = {
3463
3558
  color: "var(--nice-text-secondary, #666)"
3464
3559
  }
3465
3560
  };
3466
- function NiceGeometry({
3561
+ function it({
3467
3562
  service: e,
3468
3563
  width: t = 800,
3469
3564
  height: r = 600,
3470
- className: a,
3471
- style: o
3565
+ className: o,
3566
+ style: a
3472
3567
  }) {
3473
- const [n, i] = useState([]), [l, p] = useState("point"), [s, d] = useState([]), [g, y] = useState({
3568
+ const [n, i] = P([]), [c, u] = P("point"), [s, p] = P([]), [m, y] = P({
3474
3569
  centerX: 0,
3475
3570
  centerY: 0,
3476
3571
  scale: 40,
@@ -3480,35 +3575,35 @@ function NiceGeometry({
3480
3575
  snapToGrid: !0,
3481
3576
  snapToPoints: !0,
3482
3577
  backgroundColor: { r: 255, g: 255, b: 255 }
3483
- }), h = useCallback(() => {
3578
+ }), f = R(() => {
3484
3579
  i(e.getAllElements());
3485
- }, [e]), w = useCallback((f) => {
3486
- y((c) => ({ ...c, ...f }));
3580
+ }, [e]), C = R((b) => {
3581
+ y((l) => ({ ...l, ...b }));
3487
3582
  }, []);
3488
- useEffect(() => {
3489
- h();
3490
- }, [h]);
3491
- const u = {
3583
+ V(() => {
3584
+ f();
3585
+ }, [f]);
3586
+ const x = {
3492
3587
  service: e,
3493
3588
  elements: n,
3494
- tool: l,
3495
- setTool: p,
3496
- view: g,
3497
- setView: w,
3589
+ tool: c,
3590
+ setTool: u,
3591
+ view: m,
3592
+ setView: C,
3498
3593
  selectedIds: s,
3499
- setSelectedIds: d,
3500
- refresh: h
3594
+ setSelectedIds: p,
3595
+ refresh: f
3501
3596
  };
3502
- return /* @__PURE__ */ jsx(GeometryContext.Provider, { value: u, children: /* @__PURE__ */ jsxs("div", { className: a, style: { ...styles.container, ...o }, children: [
3503
- /* @__PURE__ */ jsx(Toolbar, {}),
3504
- /* @__PURE__ */ jsxs("div", { style: styles.main, children: [
3505
- /* @__PURE__ */ jsx(Canvas, { width: t, height: r }),
3506
- /* @__PURE__ */ jsx(StatusBar, { width: t, height: r })
3597
+ return /* @__PURE__ */ d(de.Provider, { value: x, children: /* @__PURE__ */ v("div", { className: o, style: { ...q.container, ...a }, children: [
3598
+ /* @__PURE__ */ d(Ue, {}),
3599
+ /* @__PURE__ */ v("div", { style: q.main, children: [
3600
+ /* @__PURE__ */ d(Ve, { width: t, height: r }),
3601
+ /* @__PURE__ */ d(Ye, { width: t, height: r })
3507
3602
  ] })
3508
3603
  ] }) });
3509
3604
  }
3510
- function Toolbar() {
3511
- const { tool: e, setTool: t } = useGeometry(), r = [
3605
+ function Ue() {
3606
+ const { tool: e, setTool: t } = H(), r = [
3512
3607
  { id: "select", icon: "cursor", title: "Select" },
3513
3608
  { id: "point", icon: "•", title: "Point" },
3514
3609
  { id: "segment", icon: "—", title: "Segment" },
@@ -3525,205 +3620,208 @@ function Toolbar() {
3525
3620
  { id: "rotate", icon: "refresh", title: "Rotate" },
3526
3621
  { id: "measure", icon: "ruler", title: "Measure" }
3527
3622
  ];
3528
- return /* @__PURE__ */ jsx("div", { style: styles.toolbar, children: r.map((a) => /* @__PURE__ */ jsx(
3623
+ return /* @__PURE__ */ d("div", { style: q.toolbar, children: r.map((o) => /* @__PURE__ */ d(
3529
3624
  "button",
3530
3625
  {
3531
- onClick: () => t(a.id),
3532
- title: a.title,
3626
+ onClick: () => t(o.id),
3627
+ title: o.title,
3533
3628
  style: {
3534
- ...styles.toolButton,
3535
- backgroundColor: e === a.id ? "var(--nice-primary-hover, #1976d2)" : "transparent",
3536
- color: e === a.id ? "var(--nice-text-on-primary, #fff)" : "var(--nice-text, #333)"
3629
+ ...q.toolButton,
3630
+ backgroundColor: e === o.id ? "var(--nice-primary-hover, #1976d2)" : "transparent",
3631
+ color: e === o.id ? "var(--nice-color-white, #fff)" : "var(--nice-text, #333)"
3537
3632
  },
3538
- children: /^[a-z][a-z0-9-]*$/.test(a.icon) ? /* @__PURE__ */ jsx(NiceIcon$1, { name: a.icon, size: 16 }) : a.icon
3633
+ children: /^[a-z][a-z0-9-]*$/.test(o.icon) ? /* @__PURE__ */ d(G, { name: o.icon, size: 16 }) : o.icon
3539
3634
  },
3540
- a.id
3635
+ o.id
3541
3636
  )) });
3542
3637
  }
3543
- function Canvas({ width: e, height: t }) {
3544
- const r = useRef(null), { service: a, elements: o, tool: n, view: i, selectedIds: l, setSelectedIds: p, refresh: s } = useGeometry(), [d, g] = useState([]), y = useCallback(
3545
- (f, c) => {
3546
- const x = (f - e / 2) / i.scale + i.centerX, b = -(c - t / 2) / i.scale + i.centerY;
3638
+ function Ve({ width: e, height: t }) {
3639
+ const r = U(null), { service: o, elements: a, tool: n, view: i, selectedIds: c, setSelectedIds: u, refresh: s } = H(), [p, m] = P([]), y = R(
3640
+ (b, l) => {
3641
+ const g = (b - e / 2) / i.scale + i.centerX, w = -(l - t / 2) / i.scale + i.centerY;
3547
3642
  return i.snapToGrid ? {
3548
- x: Math.round(x / i.gridSpacing) * i.gridSpacing,
3549
- y: Math.round(b / i.gridSpacing) * i.gridSpacing
3550
- } : { x, y: b };
3643
+ x: Math.round(g / i.gridSpacing) * i.gridSpacing,
3644
+ y: Math.round(w / i.gridSpacing) * i.gridSpacing
3645
+ } : { x: g, y: w };
3551
3646
  },
3552
3647
  [e, t, i]
3553
- ), h = useCallback(
3554
- (f, c) => ({
3555
- x: e / 2 + (f - i.centerX) * i.scale,
3556
- y: t / 2 - (c - i.centerY) * i.scale
3648
+ ), f = R(
3649
+ (b, l) => ({
3650
+ x: e / 2 + (b - i.centerX) * i.scale,
3651
+ y: t / 2 - (l - i.centerY) * i.scale
3557
3652
  }),
3558
3653
  [e, t, i]
3559
- ), w = useCallback(
3560
- (f) => {
3561
- var b;
3562
- const c = (b = r.current) == null ? void 0 : b.getBoundingClientRect();
3563
- if (!c)
3654
+ ), C = R(
3655
+ (b) => {
3656
+ var w;
3657
+ const l = (w = r.current) == null ? void 0 : w.getBoundingClientRect();
3658
+ if (!l)
3564
3659
  return;
3565
- const x = y(f.clientX - c.left, f.clientY - c.top);
3660
+ const g = y(b.clientX - l.left, b.clientY - l.top);
3566
3661
  switch (n) {
3567
3662
  case "point": {
3568
- a.createPoint(x.x, x.y), s();
3663
+ o.createPoint(g.x, g.y), s();
3569
3664
  break;
3570
3665
  }
3571
3666
  case "segment":
3572
3667
  case "line":
3573
3668
  case "ray": {
3574
- const k = u(x);
3575
- if (k)
3576
- g((m) => {
3577
- const v = [...m, k.id];
3578
- return v.length === 2 ? (n === "segment" ? a.createSegment(v[0], v[1]) : n === "line" ? a.createLine(v[0], v[1]) : n === "ray" && a.createRay(v[0], v[1]), s(), []) : v;
3669
+ const M = x(g);
3670
+ if (M)
3671
+ m((h) => {
3672
+ const k = [...h, M.id];
3673
+ return k.length === 2 ? (n === "segment" ? o.createSegment(k[0], k[1]) : n === "line" ? o.createLine(k[0], k[1]) : n === "ray" && o.createRay(k[0], k[1]), s(), []) : k;
3579
3674
  });
3580
3675
  else {
3581
- const m = a.createPoint(x.x, x.y);
3582
- g((v) => {
3583
- const C = [...v, m.id];
3584
- return C.length === 2 ? (n === "segment" ? a.createSegment(C[0], C[1]) : n === "line" ? a.createLine(C[0], C[1]) : n === "ray" && a.createRay(C[0], C[1]), s(), []) : C;
3676
+ const h = o.createPoint(g.x, g.y);
3677
+ m((k) => {
3678
+ const S = [...k, h.id];
3679
+ return S.length === 2 ? (n === "segment" ? o.createSegment(S[0], S[1]) : n === "line" ? o.createLine(S[0], S[1]) : n === "ray" && o.createRay(S[0], S[1]), s(), []) : S;
3585
3680
  }), s();
3586
3681
  }
3587
3682
  break;
3588
3683
  }
3589
3684
  case "circle": {
3590
- const k = u(x);
3591
- if (k)
3592
- g((m) => {
3593
- if (m.length === 0)
3594
- return [k.id];
3595
- const v = a.getPoint(m[0]);
3596
- if (v) {
3597
- const C = GeoMath.distance(v, x);
3598
- a.createCircle(m[0], C), s();
3685
+ const M = x(g);
3686
+ if (M)
3687
+ m((h) => {
3688
+ if (h.length === 0)
3689
+ return [M.id];
3690
+ const k = o.getPoint(h[0]);
3691
+ if (k) {
3692
+ const S = E.distance(k, g);
3693
+ o.createCircle(h[0], S), s();
3599
3694
  }
3600
3695
  return [];
3601
3696
  });
3602
- else if (d.length === 1) {
3603
- const m = a.getPoint(d[0]);
3604
- if (m) {
3605
- const v = GeoMath.distance(m, x);
3606
- a.createCircle(d[0], v), s(), g([]);
3697
+ else if (p.length === 1) {
3698
+ const h = o.getPoint(p[0]);
3699
+ if (h) {
3700
+ const k = E.distance(h, g);
3701
+ o.createCircle(p[0], k), s(), m([]);
3607
3702
  }
3608
3703
  } else {
3609
- const m = a.createPoint(x.x, x.y);
3610
- g([m.id]), s();
3704
+ const h = o.createPoint(g.x, g.y);
3705
+ m([h.id]), s();
3611
3706
  }
3612
3707
  break;
3613
3708
  }
3614
3709
  case "midpoint": {
3615
- const k = u(x);
3616
- k && g((m) => {
3617
- const v = [...m, k.id];
3618
- return v.length === 2 ? (a.createMidpoint(v[0], v[1]), s(), []) : v;
3710
+ const M = x(g);
3711
+ M && m((h) => {
3712
+ const k = [...h, M.id];
3713
+ return k.length === 2 ? (o.createMidpoint(k[0], k[1]), s(), []) : k;
3619
3714
  });
3620
3715
  break;
3621
3716
  }
3622
3717
  case "select": {
3623
- const k = u(x);
3624
- p(k ? [k.id] : []);
3718
+ const M = x(g);
3719
+ u(M ? [M.id] : []);
3625
3720
  break;
3626
3721
  }
3627
3722
  }
3628
3723
  },
3629
- [n, a, s, y, d, p]
3630
- ), u = (f) => {
3631
- for (const x of o)
3632
- if (x.type === "point" && GeoMath.distance(x, f) < 0.5)
3633
- return x;
3724
+ [n, o, s, y, p, u]
3725
+ ), x = (b) => {
3726
+ for (const g of a)
3727
+ if (g.type === "point" && E.distance(g, b) < 0.5)
3728
+ return g;
3634
3729
  };
3635
- return useEffect(() => {
3636
- const f = r.current, c = f == null ? void 0 : f.getContext("2d");
3637
- if (!(!f || !c)) {
3638
- if (c.fillStyle = `rgb(${i.backgroundColor.r},${i.backgroundColor.g},${i.backgroundColor.b})`, c.fillRect(0, 0, e, t), i.showGrid) {
3639
- c.strokeStyle = resolveCssColor("var(--nice-border, #e0e0e0)", c.canvas), c.lineWidth = 0.5;
3640
- const x = i.gridSpacing * i.scale, b = (e / 2 - i.centerX * i.scale) % x, k = (t / 2 + i.centerY * i.scale) % x;
3641
- for (let m = b; m < e; m += x)
3642
- c.beginPath(), c.moveTo(m, 0), c.lineTo(m, t), c.stroke();
3643
- for (let m = k; m < t; m += x)
3644
- c.beginPath(), c.moveTo(0, m), c.lineTo(e, m), c.stroke();
3730
+ return V(() => {
3731
+ const b = r.current, l = b == null ? void 0 : b.getContext("2d");
3732
+ if (!(!b || !l)) {
3733
+ if (l.fillStyle = `rgb(${i.backgroundColor.r},${i.backgroundColor.g},${i.backgroundColor.b})`, l.fillRect(0, 0, e, t), i.showGrid) {
3734
+ l.strokeStyle = I("var(--nice-border, #e0e0e0)", l.canvas), l.lineWidth = 0.5;
3735
+ const g = i.gridSpacing * i.scale, w = (e / 2 - i.centerX * i.scale) % g, M = (t / 2 + i.centerY * i.scale) % g;
3736
+ for (let h = w; h < e; h += g)
3737
+ l.beginPath(), l.moveTo(h, 0), l.lineTo(h, t), l.stroke();
3738
+ for (let h = M; h < t; h += g)
3739
+ l.beginPath(), l.moveTo(0, h), l.lineTo(e, h), l.stroke();
3645
3740
  }
3646
3741
  if (i.showAxes) {
3647
- const x = h(0, 0);
3648
- c.strokeStyle = resolveCssColor("var(--nice-text, #333)", c.canvas), c.lineWidth = 1, c.beginPath(), c.moveTo(0, x.y), c.lineTo(e, x.y), c.stroke(), c.beginPath(), c.moveTo(x.x, 0), c.lineTo(x.x, t), c.stroke();
3742
+ const g = f(0, 0);
3743
+ l.strokeStyle = I("var(--nice-text, #333)", l.canvas), l.lineWidth = 1, l.beginPath(), l.moveTo(0, g.y), l.lineTo(e, g.y), l.stroke(), l.beginPath(), l.moveTo(g.x, 0), l.lineTo(g.x, t), l.stroke();
3649
3744
  }
3650
- for (const x of o) {
3651
- if (!x.visible)
3745
+ for (const g of a) {
3746
+ if (!g.visible)
3652
3747
  continue;
3653
- const b = `rgb(${x.color.r},${x.color.g},${x.color.b})`, k = l.includes(x.id);
3654
- switch (x.type) {
3748
+ const w = `rgb(${g.color.r},${g.color.g},${g.color.b})`, M = c.includes(g.id);
3749
+ switch (g.type) {
3655
3750
  case "point": {
3656
- const m = h(x.x, x.y);
3657
- c.beginPath(), c.arc(m.x, m.y, k ? x.size + 2 : x.size, 0, 2 * Math.PI), c.fillStyle = k ? resolveCssColor("var(--nice-primary-hover, #1976d2)", c.canvas) : b, c.fill(), x.label && (c.fillStyle = resolveCssColor("var(--nice-text, #333)", c.canvas), c.font = "12px sans-serif", c.fillText(x.label, m.x + 8, m.y - 8));
3751
+ const h = f(g.x, g.y);
3752
+ l.beginPath(), l.arc(h.x, h.y, M ? g.size + 2 : g.size, 0, 2 * Math.PI), l.fillStyle = M ? I("var(--nice-primary-hover, #1976d2)", l.canvas) : w, l.fill(), g.label && (l.fillStyle = I("var(--nice-text, #333)", l.canvas), l.font = "12px sans-serif", l.fillText(g.label, h.x + 8, h.y - 8));
3658
3753
  break;
3659
3754
  }
3660
3755
  case "segment": {
3661
- const m = a.getPoint(x.point1Id), v = a.getPoint(x.point2Id);
3662
- if (m && v) {
3663
- const C = h(m.x, m.y), S = h(v.x, v.y);
3664
- c.strokeStyle = b, c.lineWidth = x.width, c.beginPath(), c.moveTo(C.x, C.y), c.lineTo(S.x, S.y), c.stroke();
3756
+ const h = o.getPoint(g.point1Id), k = o.getPoint(g.point2Id);
3757
+ if (h && k) {
3758
+ const S = f(h.x, h.y), D = f(k.x, k.y);
3759
+ l.strokeStyle = w, l.lineWidth = g.width, l.beginPath(), l.moveTo(S.x, S.y), l.lineTo(D.x, D.y), l.stroke();
3665
3760
  }
3666
3761
  break;
3667
3762
  }
3668
3763
  case "line": {
3669
- const m = a.getPoint(x.point1Id), v = a.getPoint(x.point2Id);
3670
- if (m && v) {
3671
- const C = v.x - m.x, S = v.y - m.y, P = -1e3, j = 1e3, $ = h(m.x + P * C, m.y + P * S), B = h(m.x + j * C, m.y + j * S);
3672
- c.strokeStyle = b, c.lineWidth = x.width, c.beginPath(), c.moveTo($.x, $.y), c.lineTo(B.x, B.y), c.stroke();
3764
+ const h = o.getPoint(g.point1Id), k = o.getPoint(g.point2Id);
3765
+ if (h && k) {
3766
+ const S = k.x - h.x, D = k.y - h.y, _ = -1e3, K = 1e3, Z = f(h.x + _ * S, h.y + _ * D), Q = f(h.x + K * S, h.y + K * D);
3767
+ l.strokeStyle = w, l.lineWidth = g.width, l.beginPath(), l.moveTo(Z.x, Z.y), l.lineTo(Q.x, Q.y), l.stroke();
3673
3768
  }
3674
3769
  break;
3675
3770
  }
3676
3771
  case "circle": {
3677
- const m = a.getPoint(x.centerId);
3678
- if (m) {
3679
- const v = h(m.x, m.y), C = x.radius * i.scale;
3680
- c.beginPath(), c.arc(v.x, v.y, C, 0, 2 * Math.PI), x.fill && (c.fillStyle = `rgba(${x.fill.r},${x.fill.g},${x.fill.b},${x.fill.a ?? 0.2})`, c.fill()), c.strokeStyle = b, c.lineWidth = x.width, c.stroke();
3772
+ const h = o.getPoint(g.centerId);
3773
+ if (h) {
3774
+ const k = f(h.x, h.y), S = g.radius * i.scale;
3775
+ l.beginPath(), l.arc(k.x, k.y, S, 0, 2 * Math.PI), g.fill && (l.fillStyle = `rgba(${g.fill.r},${g.fill.g},${g.fill.b},${g.fill.a ?? 0.2})`, l.fill()), l.strokeStyle = w, l.lineWidth = g.width, l.stroke();
3681
3776
  }
3682
3777
  break;
3683
3778
  }
3684
3779
  case "polygon": {
3685
- const m = x.pointIds.map((v) => a.getPoint(v)).filter(Boolean);
3686
- if (m.length > 0) {
3687
- c.beginPath();
3688
- const v = h(m[0].x, m[0].y);
3689
- c.moveTo(v.x, v.y);
3690
- for (let C = 1; C < m.length; C++) {
3691
- const S = h(m[C].x, m[C].y);
3692
- c.lineTo(S.x, S.y);
3780
+ const h = g.pointIds.map((k) => o.getPoint(k)).filter(Boolean);
3781
+ if (h.length > 0) {
3782
+ l.beginPath();
3783
+ const k = f(h[0].x, h[0].y);
3784
+ l.moveTo(k.x, k.y);
3785
+ for (let S = 1; S < h.length; S++) {
3786
+ const D = f(h[S].x, h[S].y);
3787
+ l.lineTo(D.x, D.y);
3693
3788
  }
3694
- c.closePath(), x.fill && (c.fillStyle = `rgba(${x.fill.r},${x.fill.g},${x.fill.b},${x.fill.a ?? 0.2})`, c.fill()), c.strokeStyle = b, c.lineWidth = x.width, c.stroke();
3789
+ l.closePath(), g.fill && (l.fillStyle = `rgba(${g.fill.r},${g.fill.g},${g.fill.b},${g.fill.a ?? 0.2})`, l.fill()), l.strokeStyle = w, l.lineWidth = g.width, l.stroke();
3695
3790
  }
3696
3791
  break;
3697
3792
  }
3698
3793
  }
3699
3794
  }
3700
- if (d.length > 0) {
3701
- c.fillStyle = "rgba(25, 118, 210, 0.3)";
3702
- for (const x of d) {
3703
- const b = a.getPoint(x);
3704
- if (b) {
3705
- const k = h(b.x, b.y);
3706
- c.beginPath(), c.arc(k.x, k.y, 12, 0, 2 * Math.PI), c.fill();
3795
+ if (p.length > 0) {
3796
+ l.fillStyle = I(
3797
+ "var(--nice-primary-tint-30, rgba(25, 118, 210, 0.3))",
3798
+ l.canvas
3799
+ );
3800
+ for (const g of p) {
3801
+ const w = o.getPoint(g);
3802
+ if (w) {
3803
+ const M = f(w.x, w.y);
3804
+ l.beginPath(), l.arc(M.x, M.y, 12, 0, 2 * Math.PI), l.fill();
3707
3805
  }
3708
3806
  }
3709
3807
  }
3710
3808
  }
3711
- }, [o, i, e, t, l, d, a, h]), /* @__PURE__ */ jsx(
3809
+ }, [a, i, e, t, c, p, o, f]), /* @__PURE__ */ d(
3712
3810
  "canvas",
3713
3811
  {
3714
3812
  ref: r,
3715
3813
  width: e,
3716
3814
  height: t,
3717
- style: styles.canvas,
3718
- onClick: w
3815
+ style: q.canvas,
3816
+ onClick: C
3719
3817
  }
3720
3818
  );
3721
3819
  }
3722
- function StatusBar({
3820
+ function Ye({
3723
3821
  width: e,
3724
3822
  height: t
3725
3823
  }) {
3726
- const { tool: r, elements: a, view: o, service: n } = useGeometry(), [i, l] = useState(null), p = {
3824
+ const { tool: r, elements: o, view: a, service: n } = H(), [i, c] = P(null), u = {
3727
3825
  select: "Select",
3728
3826
  point: "Point",
3729
3827
  line: "Line",
@@ -3745,56 +3843,56 @@ function StatusBar({
3745
3843
  dilate: "Dilate",
3746
3844
  measure: "Measure",
3747
3845
  text: "Text"
3748
- }, s = a.filter((d) => d.type === "point").length;
3749
- return /* @__PURE__ */ jsxs("div", { style: styles.statusBar, children: [
3750
- /* @__PURE__ */ jsxs("span", { children: [
3846
+ }, s = o.filter((p) => p.type === "point").length;
3847
+ return /* @__PURE__ */ v("div", { style: q.statusBar, children: [
3848
+ /* @__PURE__ */ v("span", { children: [
3751
3849
  "Tool: ",
3752
- p[r]
3850
+ u[r]
3753
3851
  ] }),
3754
- /* @__PURE__ */ jsx("span", { style: { margin: "0 16px" }, children: "|" }),
3755
- /* @__PURE__ */ jsxs("span", { children: [
3852
+ /* @__PURE__ */ d("span", { style: { margin: "0 16px" }, children: "|" }),
3853
+ /* @__PURE__ */ v("span", { children: [
3756
3854
  "Objects: ",
3757
- a.length
3855
+ o.length
3758
3856
  ] }),
3759
- /* @__PURE__ */ jsx("span", { style: { margin: "0 16px" }, children: "|" }),
3760
- /* @__PURE__ */ jsxs("span", { children: [
3857
+ /* @__PURE__ */ d("span", { style: { margin: "0 16px" }, children: "|" }),
3858
+ /* @__PURE__ */ v("span", { children: [
3761
3859
  "Points: ",
3762
3860
  s
3763
3861
  ] }),
3764
- /* @__PURE__ */ jsx("span", { style: { margin: "0 16px" }, children: "|" }),
3765
- /* @__PURE__ */ jsxs("span", { children: [
3862
+ /* @__PURE__ */ d("span", { style: { margin: "0 16px" }, children: "|" }),
3863
+ /* @__PURE__ */ v("span", { children: [
3766
3864
  "Scale: ",
3767
- o.scale.toFixed(1),
3865
+ a.scale.toFixed(1),
3768
3866
  "x"
3769
3867
  ] })
3770
3868
  ] });
3771
3869
  }
3772
3870
  export {
3773
- CalculatorService,
3774
- CalculusOps,
3775
- EQUATION_TEMPLATES,
3776
- ExpressionParser,
3777
- FUNCTION_PRESETS,
3778
- GeoMath,
3779
- GeometryService,
3780
- GraphService,
3781
- MATH_SYMBOLS,
3782
- MathEditorService,
3783
- MatrixOps,
3784
- NiceCalculator,
3785
- NiceGeometry,
3786
- NiceGraphPlotter,
3787
- NiceI18nProvider,
3788
- NiceMathEditor,
3789
- createCalculatorService,
3790
- createGeometryService,
3791
- createGraphService,
3792
- createMathEditorService,
3793
- getSymbolsByCategory,
3794
- recognizeHandwriting,
3795
- useCalculator,
3796
- useGeometry,
3797
- useGraph,
3798
- useMathEditor,
3799
- useNiceTranslation
3871
+ Le as CalculatorService,
3872
+ te as CalculusOps,
3873
+ we as EQUATION_TEMPLATES,
3874
+ ie as ExpressionParser,
3875
+ ee as FUNCTION_PRESETS,
3876
+ E as GeoMath,
3877
+ Oe as GeometryService,
3878
+ Te as GraphService,
3879
+ be as MATH_SYMBOLS,
3880
+ ke as MathEditorService,
3881
+ z as MatrixOps,
3882
+ at as NiceCalculator,
3883
+ it as NiceGeometry,
3884
+ rt as NiceGraphPlotter,
3885
+ Qe as NiceI18nProvider,
3886
+ et as NiceMathEditor,
3887
+ ot as createCalculatorService,
3888
+ nt as createGeometryService,
3889
+ tt as createGraphService,
3890
+ Je as createMathEditorService,
3891
+ ve as getSymbolsByCategory,
3892
+ Ce as recognizeHandwriting,
3893
+ N as useCalculator,
3894
+ H as useGeometry,
3895
+ Y as useGraph,
3896
+ W as useMathEditor,
3897
+ L as useNiceTranslation
3800
3898
  };