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