@jjlmoya/utils-astronomy 1.24.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/package.json +2 -2
  2. package/src/category/i18n/de.ts +57 -57
  3. package/src/category/i18n/en.ts +1 -1
  4. package/src/category/i18n/es.ts +1 -1
  5. package/src/category/i18n/fr.ts +58 -58
  6. package/src/category/i18n/it.ts +1 -1
  7. package/src/category/i18n/nl.ts +57 -57
  8. package/src/category/i18n/pl.ts +57 -57
  9. package/src/category/i18n/pt.ts +1 -1
  10. package/src/category/i18n/ru.ts +57 -57
  11. package/src/category/i18n/sv.ts +57 -57
  12. package/src/category/i18n/zh.ts +57 -57
  13. package/src/category/index.ts +30 -30
  14. package/src/category/seo.astro +15 -15
  15. package/src/components/PreviewNavSidebar.astro +116 -116
  16. package/src/components/PreviewToolbar.astro +143 -143
  17. package/src/data.ts +16 -16
  18. package/src/env.d.ts +5 -5
  19. package/src/index.ts +22 -22
  20. package/src/layouts/PreviewLayout.astro +122 -122
  21. package/src/pages/[locale].astro +251 -251
  22. package/src/pages/index.astro +4 -4
  23. package/src/tests/bibliography_wellformed_export.test.ts +46 -0
  24. package/src/tests/category_seo_quality.test.ts +74 -0
  25. package/src/tests/faq_count.test.ts +1 -1
  26. package/src/tests/mocks/astro_mock.js +2 -2
  27. package/src/tests/no_h1_in_components.test.ts +1 -1
  28. package/src/tests/seo_length.test.ts +1 -1
  29. package/src/tests/seo_parity.test.ts +2 -2
  30. package/src/tests/seo_translation_completeness.test.ts +75 -0
  31. package/src/tests/seo_wellformed_export.test.ts +65 -0
  32. package/src/tests/tool_structure.test.ts +71 -71
  33. package/src/tests/tool_validation.test.ts +146 -146
  34. package/src/tool/bortleVisualizer/bibliography.astro +14 -14
  35. package/src/tool/bortleVisualizer/bibliography.ts +8 -8
  36. package/src/tool/bortleVisualizer/i18n/pl.ts +159 -159
  37. package/src/tool/bortleVisualizer/i18n/ru.ts +159 -159
  38. package/src/tool/deepSpaceScope/bibliography.astro +14 -14
  39. package/src/tool/deepSpaceScope/component.astro +382 -382
  40. package/src/tool/deepSpaceScope/i18n/de.ts +172 -172
  41. package/src/tool/deepSpaceScope/i18n/ko.ts +172 -172
  42. package/src/tool/deepSpaceScope/i18n/pl.ts +172 -172
  43. package/src/tool/deepSpaceScope/i18n/ru.ts +172 -172
  44. package/src/tool/deepSpaceScope/i18n/zh.ts +172 -172
  45. package/src/tool/smartEyepieceCalculator/component.astro +125 -125
  46. package/src/tool/smartEyepieceCalculator/i18n/fr.ts +165 -165
  47. package/src/tool/smartEyepieceCalculator/i18n/ru.ts +165 -165
  48. package/src/tool/smartEyepieceCalculator/i18n/zh.ts +165 -165
  49. package/src/tool/starExposureCalculator/bibliography.astro +14 -14
  50. package/src/tool/starExposureCalculator/bibliography.ts +7 -7
  51. package/src/tool/starExposureCalculator/component.astro +249 -249
  52. package/src/tool/starExposureCalculator/i18n/pl.ts +156 -156
  53. package/src/tool/starExposureCalculator/i18n/ru.ts +156 -156
  54. package/src/tool/telescopeResolution/bibliography.astro +14 -14
  55. package/src/tool/telescopeResolution/component.astro +222 -222
  56. package/src/tool/telescopeResolution/i18n/de.ts +169 -169
  57. package/src/tool/telescopeResolution/i18n/en.ts +169 -169
  58. package/src/tool/telescopeResolution/i18n/es.ts +169 -169
  59. package/src/tool/telescopeResolution/i18n/fr.ts +169 -169
  60. package/src/tool/telescopeResolution/i18n/id.ts +169 -169
  61. package/src/tool/telescopeResolution/i18n/it.ts +169 -169
  62. package/src/tool/telescopeResolution/i18n/ja.ts +169 -169
  63. package/src/tool/telescopeResolution/i18n/ko.ts +169 -169
  64. package/src/tool/telescopeResolution/i18n/nl.ts +169 -169
  65. package/src/tool/telescopeResolution/i18n/pl.ts +169 -169
  66. package/src/tool/telescopeResolution/i18n/pt.ts +169 -169
  67. package/src/tool/telescopeResolution/i18n/ru.ts +169 -169
  68. package/src/tool/telescopeResolution/i18n/sv.ts +169 -169
  69. package/src/tool/telescopeResolution/i18n/tr.ts +169 -169
  70. package/src/tool/telescopeResolution/i18n/zh.ts +169 -169
@@ -1,249 +1,249 @@
1
- ---
2
- import type { StarExposureCalculatorUI } from './index';
3
- import type { KnownLocale } from '../../types';
4
-
5
- interface Props {
6
- ui: StarExposureCalculatorUI;
7
- locale?: KnownLocale;
8
- }
9
-
10
- const { ui } = Astro.props;
11
- ---
12
-
13
- <div class="star-calc-wrapper">
14
- <div class="star-calc-grid">
15
- <div class="star-calc-controls">
16
- <div class="star-mode-selector">
17
- <span class="star-mode-label">{ui.modeLabel}:</span>
18
- <div class="star-toggle-group">
19
- <button id="mode-classic" class="star-toggle-btn active" data-mode="classic">{ui.classicMode}</button>
20
- <button id="mode-npf" class="star-toggle-btn" data-mode="npf">{ui.npfMode}</button>
21
- </div>
22
- </div>
23
-
24
- <div class="star-control-group">
25
- <label class="star-control-label" for="sensor-type">{ui.sensorLabel}</label>
26
- <div class="star-select-wrapper">
27
- <select id="sensor-type" class="star-select">
28
- <option value="1.0">Full Frame (x1.0)</option>
29
- <option value="1.5">APS-C Nikon/Sony/Fuji (x1.5)</option>
30
- <option value="1.6">APS-C Canon (x1.6)</option>
31
- <option value="2.0">Micro Four Thirds (x2.0)</option>
32
- </select>
33
- <svg class="star-select-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
34
- <polyline points="6 9 12 15 18 9"></polyline>
35
- </svg>
36
- </div>
37
- </div>
38
-
39
- <div class="star-control-group">
40
- <label class="star-control-label" for="focal-length">{ui.focalLabel}</label>
41
- <div class="star-stepper">
42
- <button class="star-step-btn" data-action="dec" data-target="focal">-</button>
43
- <input type="number" id="focal-length" value="14" min="1" max="1000" class="star-stepper-input" />
44
- <button class="star-step-btn" data-action="inc" data-target="focal">+</button>
45
- </div>
46
- </div>
47
-
48
- <div id="npf-controls" class="star-npf-controls">
49
- <div class="star-control-group">
50
- <label class="star-control-label" for="aperture">{ui.apertureLabel}</label>
51
- <div class="star-stepper">
52
- <button class="star-step-btn" data-action="dec" data-target="aperture">-</button>
53
- <input type="number" id="aperture" value="2.8" step="0.1" min="0.5" max="32" class="star-stepper-input" />
54
- <button class="star-step-btn" data-action="inc" data-target="aperture">+</button>
55
- </div>
56
- </div>
57
- <div class="star-control-group">
58
- <label class="star-control-label" for="megapixels">{ui.megapixelsLabel}</label>
59
- <div class="star-stepper">
60
- <button class="star-step-btn" data-action="dec" data-target="megapixels">-</button>
61
- <input type="number" id="megapixels" value="24" min="1" max="150" class="star-stepper-input" />
62
- <button class="star-step-btn" data-action="inc" data-target="megapixels">+</button>
63
- </div>
64
- </div>
65
- </div>
66
-
67
- <div class="star-control-group">
68
- <label class="star-control-label">
69
- {ui.declinationLabel}: <span id="declination-value">0</span>°
70
- </label>
71
- <input type="range" id="declination" min="0" max="89" value="0" class="star-range" aria-label={ui.declinationLabel} />
72
- <div class="star-range-labels">
73
- <span>{ui.equatorLabel}</span>
74
- <span>{ui.poleLabel}</span>
75
- </div>
76
- </div>
77
- </div>
78
-
79
- <div class="star-results">
80
- <div class="star-result-main">
81
- <div class="star-time-display">
82
- <span id="result-time" class="star-time-value">35.7</span>
83
- <span class="star-time-unit">{ui.secondsUnit}</span>
84
- </div>
85
- <p id="result-text" class="star-result-text">{ui.resultText}</p>
86
- </div>
87
-
88
- <div class="star-simulation">
89
- <label class="star-sim-label">{ui.simLabel}</label>
90
- <div class="star-sim-container">
91
- <div class="star-sim-view">
92
- <div id="star-preview" class="star-point"></div>
93
- <div class="star-center-marker">+</div>
94
- </div>
95
- <div class="star-sim-info-row">
96
- <span id="sim-info" class="star-sim-info">{ui.pointStars}</span>
97
- </div>
98
- </div>
99
- <div class="star-sim-range-wrapper">
100
- <input type="range" id="sim-offset" min="1" max="5" step="0.1" value="1" class="star-range" aria-label={ui.simRangeLabel} />
101
- <span class="star-sim-range-label">{ui.simRangeLabel}</span>
102
- </div>
103
- </div>
104
- </div>
105
- </div>
106
- </div>
107
-
108
- <script define:vars={{ ui }} is:inline>
109
- window.__starCalcUI = ui;
110
- </script>
111
-
112
- <script>
113
- import { calculateExposureTime } from './logic';
114
- import type { SensorCropFactor } from './logic';
115
-
116
- const uiData = window.__starCalcUI;
117
-
118
- class StarCalculatorApp {
119
- mode = 'classic';
120
- focalLengthInput: HTMLInputElement;
121
- sensorSelect: HTMLSelectElement;
122
- apertureInput: HTMLInputElement;
123
- megapixelsInput: HTMLInputElement;
124
- declinationInput: HTMLInputElement;
125
- resultTimeDisplay: HTMLElement;
126
- declinationValueDisplay: HTMLElement;
127
- starPreview: HTMLElement;
128
- simOffsetInput: HTMLInputElement;
129
- npfControls: HTMLElement;
130
- modeBtns: NodeListOf<HTMLButtonElement>;
131
- stepBtns: NodeListOf<HTMLButtonElement>;
132
-
133
- constructor() {
134
- this.focalLengthInput = document.getElementById('focal-length') as HTMLInputElement;
135
- this.sensorSelect = document.getElementById('sensor-type') as HTMLSelectElement;
136
- this.apertureInput = document.getElementById('aperture') as HTMLInputElement;
137
- this.megapixelsInput = document.getElementById('megapixels') as HTMLInputElement;
138
- this.declinationInput = document.getElementById('declination') as HTMLInputElement;
139
- this.resultTimeDisplay = document.getElementById('result-time') as HTMLElement;
140
- this.declinationValueDisplay = document.getElementById('declination-value') as HTMLElement;
141
- this.starPreview = document.getElementById('star-preview') as HTMLElement;
142
- this.simOffsetInput = document.getElementById('sim-offset') as HTMLInputElement;
143
- this.npfControls = document.getElementById('npf-controls') as HTMLElement;
144
- this.modeBtns = document.querySelectorAll('.star-toggle-btn');
145
- this.stepBtns = document.querySelectorAll('.star-step-btn');
146
- this.init();
147
- }
148
-
149
- resolveStepInput(targetId: string | undefined): HTMLInputElement | null {
150
- if (targetId === 'focal') return this.focalLengthInput;
151
- if (targetId === 'aperture') return this.apertureInput;
152
- if (targetId === 'megapixels') return this.megapixelsInput;
153
- return null;
154
- }
155
-
156
- handleStepBtn(btn: HTMLButtonElement) {
157
- const action = btn.dataset.action;
158
- const targetId = btn.dataset.target;
159
- const input = this.resolveStepInput(targetId);
160
- if (!input) return;
161
- let val = parseFloat(input.value);
162
- const step = parseFloat(input.step) || 1;
163
- if (action === 'inc') val += step;
164
- if (action === 'dec') val -= step;
165
- input.value = Math.max(parseFloat(input.min) || 0, val).toFixed(targetId === 'aperture' ? 1 : 0);
166
- this.calculate();
167
- }
168
-
169
- bindModeButtons() {
170
- this.modeBtns.forEach((btn) => {
171
- btn.addEventListener('click', () => {
172
- this.modeBtns.forEach((b) => b.classList.remove('active'));
173
- btn.classList.add('active');
174
- this.mode = btn.dataset.mode || 'classic';
175
- if (this.npfControls) {
176
- this.npfControls.style.display = this.mode === 'npf' ? 'flex' : 'none';
177
- }
178
- this.calculate();
179
- });
180
- });
181
- }
182
-
183
- bindInputListeners() {
184
- this.stepBtns.forEach((btn) => btn.addEventListener('click', () => this.handleStepBtn(btn)));
185
- [this.focalLengthInput, this.apertureInput, this.megapixelsInput].forEach((inp) => {
186
- if (inp) inp.addEventListener('input', () => this.calculate());
187
- });
188
- if (this.sensorSelect) this.sensorSelect.addEventListener('change', () => this.calculate());
189
- if (this.declinationInput) {
190
- this.declinationInput.addEventListener('input', () => {
191
- if (this.declinationValueDisplay) {
192
- this.declinationValueDisplay.textContent = this.declinationInput.value;
193
- }
194
- this.calculate();
195
- });
196
- }
197
- if (this.simOffsetInput) {
198
- this.simOffsetInput.addEventListener('input', () => this.updateSimulation());
199
- }
200
- }
201
-
202
- init() {
203
- this.bindModeButtons();
204
- this.bindInputListeners();
205
- this.calculate();
206
- }
207
-
208
- getExposureParams() {
209
- return {
210
- mode: this.mode as 'classic' | 'npf',
211
- focalLength: parseFloat(this.focalLengthInput.value) || 1,
212
- cropFactor: parseFloat(this.sensorSelect.value) as SensorCropFactor,
213
- aperture: parseFloat(this.apertureInput?.value || '2.8'),
214
- megapixels: parseFloat(this.megapixelsInput?.value || '24'),
215
- declination: parseFloat(this.declinationInput.value) || 0,
216
- };
217
- }
218
-
219
- calculate() {
220
- if (!this.focalLengthInput || !this.sensorSelect || !this.declinationInput) return;
221
- const resultTime = calculateExposureTime(this.getExposureParams());
222
- if (this.resultTimeDisplay) {
223
- this.resultTimeDisplay.textContent = resultTime.toFixed(1);
224
- }
225
- this.updateSimulation();
226
- }
227
-
228
- updateSimulation() {
229
- if (!this.simOffsetInput || !this.starPreview) return;
230
- const excess = parseFloat(this.simOffsetInput.value);
231
- const trailLength = (excess - 1) * 20;
232
- const info = document.getElementById('sim-info');
233
- if (excess > 1.1) {
234
- this.starPreview.style.width = `${trailLength + 4}px`;
235
- this.starPreview.style.borderRadius = '2px';
236
- this.starPreview.classList.add('is-trail');
237
- if (info) info.textContent = uiData.trailStars;
238
- } else {
239
- this.starPreview.style.width = '4px';
240
- this.starPreview.style.borderRadius = '50%';
241
- this.starPreview.classList.remove('is-trail');
242
- if (info) info.textContent = uiData.pointStars;
243
- }
244
- }
245
- }
246
-
247
- new StarCalculatorApp();
248
- </script>
249
-
1
+ ---
2
+ import type { StarExposureCalculatorUI } from './index';
3
+ import type { KnownLocale } from '../../types';
4
+
5
+ interface Props {
6
+ ui: StarExposureCalculatorUI;
7
+ locale?: KnownLocale;
8
+ }
9
+
10
+ const { ui } = Astro.props;
11
+ ---
12
+
13
+ <div class="star-calc-wrapper">
14
+ <div class="star-calc-grid">
15
+ <div class="star-calc-controls">
16
+ <div class="star-mode-selector">
17
+ <span class="star-mode-label">{ui.modeLabel}:</span>
18
+ <div class="star-toggle-group">
19
+ <button id="mode-classic" class="star-toggle-btn active" data-mode="classic">{ui.classicMode}</button>
20
+ <button id="mode-npf" class="star-toggle-btn" data-mode="npf">{ui.npfMode}</button>
21
+ </div>
22
+ </div>
23
+
24
+ <div class="star-control-group">
25
+ <label class="star-control-label" for="sensor-type">{ui.sensorLabel}</label>
26
+ <div class="star-select-wrapper">
27
+ <select id="sensor-type" class="star-select">
28
+ <option value="1.0">Full Frame (x1.0)</option>
29
+ <option value="1.5">APS-C Nikon/Sony/Fuji (x1.5)</option>
30
+ <option value="1.6">APS-C Canon (x1.6)</option>
31
+ <option value="2.0">Micro Four Thirds (x2.0)</option>
32
+ </select>
33
+ <svg class="star-select-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
34
+ <polyline points="6 9 12 15 18 9"></polyline>
35
+ </svg>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="star-control-group">
40
+ <label class="star-control-label" for="focal-length">{ui.focalLabel}</label>
41
+ <div class="star-stepper">
42
+ <button class="star-step-btn" data-action="dec" data-target="focal">-</button>
43
+ <input type="number" id="focal-length" value="14" min="1" max="1000" class="star-stepper-input" />
44
+ <button class="star-step-btn" data-action="inc" data-target="focal">+</button>
45
+ </div>
46
+ </div>
47
+
48
+ <div id="npf-controls" class="star-npf-controls">
49
+ <div class="star-control-group">
50
+ <label class="star-control-label" for="aperture">{ui.apertureLabel}</label>
51
+ <div class="star-stepper">
52
+ <button class="star-step-btn" data-action="dec" data-target="aperture">-</button>
53
+ <input type="number" id="aperture" value="2.8" step="0.1" min="0.5" max="32" class="star-stepper-input" />
54
+ <button class="star-step-btn" data-action="inc" data-target="aperture">+</button>
55
+ </div>
56
+ </div>
57
+ <div class="star-control-group">
58
+ <label class="star-control-label" for="megapixels">{ui.megapixelsLabel}</label>
59
+ <div class="star-stepper">
60
+ <button class="star-step-btn" data-action="dec" data-target="megapixels">-</button>
61
+ <input type="number" id="megapixels" value="24" min="1" max="150" class="star-stepper-input" />
62
+ <button class="star-step-btn" data-action="inc" data-target="megapixels">+</button>
63
+ </div>
64
+ </div>
65
+ </div>
66
+
67
+ <div class="star-control-group">
68
+ <label class="star-control-label">
69
+ {ui.declinationLabel}: <span id="declination-value">0</span>°
70
+ </label>
71
+ <input type="range" id="declination" min="0" max="89" value="0" class="star-range" aria-label={ui.declinationLabel} />
72
+ <div class="star-range-labels">
73
+ <span>{ui.equatorLabel}</span>
74
+ <span>{ui.poleLabel}</span>
75
+ </div>
76
+ </div>
77
+ </div>
78
+
79
+ <div class="star-results">
80
+ <div class="star-result-main">
81
+ <div class="star-time-display">
82
+ <span id="result-time" class="star-time-value">35.7</span>
83
+ <span class="star-time-unit">{ui.secondsUnit}</span>
84
+ </div>
85
+ <p id="result-text" class="star-result-text">{ui.resultText}</p>
86
+ </div>
87
+
88
+ <div class="star-simulation">
89
+ <label class="star-sim-label">{ui.simLabel}</label>
90
+ <div class="star-sim-container">
91
+ <div class="star-sim-view">
92
+ <div id="star-preview" class="star-point"></div>
93
+ <div class="star-center-marker">+</div>
94
+ </div>
95
+ <div class="star-sim-info-row">
96
+ <span id="sim-info" class="star-sim-info">{ui.pointStars}</span>
97
+ </div>
98
+ </div>
99
+ <div class="star-sim-range-wrapper">
100
+ <input type="range" id="sim-offset" min="1" max="5" step="0.1" value="1" class="star-range" aria-label={ui.simRangeLabel} />
101
+ <span class="star-sim-range-label">{ui.simRangeLabel}</span>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </div>
107
+
108
+ <script define:vars={{ ui }} is:inline>
109
+ window.__starCalcUI = ui;
110
+ </script>
111
+
112
+ <script>
113
+ import { calculateExposureTime } from './logic';
114
+ import type { SensorCropFactor } from './logic';
115
+
116
+ const uiData = window.__starCalcUI;
117
+
118
+ class StarCalculatorApp {
119
+ mode = 'classic';
120
+ focalLengthInput: HTMLInputElement;
121
+ sensorSelect: HTMLSelectElement;
122
+ apertureInput: HTMLInputElement;
123
+ megapixelsInput: HTMLInputElement;
124
+ declinationInput: HTMLInputElement;
125
+ resultTimeDisplay: HTMLElement;
126
+ declinationValueDisplay: HTMLElement;
127
+ starPreview: HTMLElement;
128
+ simOffsetInput: HTMLInputElement;
129
+ npfControls: HTMLElement;
130
+ modeBtns: NodeListOf<HTMLButtonElement>;
131
+ stepBtns: NodeListOf<HTMLButtonElement>;
132
+
133
+ constructor() {
134
+ this.focalLengthInput = document.getElementById('focal-length') as HTMLInputElement;
135
+ this.sensorSelect = document.getElementById('sensor-type') as HTMLSelectElement;
136
+ this.apertureInput = document.getElementById('aperture') as HTMLInputElement;
137
+ this.megapixelsInput = document.getElementById('megapixels') as HTMLInputElement;
138
+ this.declinationInput = document.getElementById('declination') as HTMLInputElement;
139
+ this.resultTimeDisplay = document.getElementById('result-time') as HTMLElement;
140
+ this.declinationValueDisplay = document.getElementById('declination-value') as HTMLElement;
141
+ this.starPreview = document.getElementById('star-preview') as HTMLElement;
142
+ this.simOffsetInput = document.getElementById('sim-offset') as HTMLInputElement;
143
+ this.npfControls = document.getElementById('npf-controls') as HTMLElement;
144
+ this.modeBtns = document.querySelectorAll('.star-toggle-btn');
145
+ this.stepBtns = document.querySelectorAll('.star-step-btn');
146
+ this.init();
147
+ }
148
+
149
+ resolveStepInput(targetId: string | undefined): HTMLInputElement | null {
150
+ if (targetId === 'focal') return this.focalLengthInput;
151
+ if (targetId === 'aperture') return this.apertureInput;
152
+ if (targetId === 'megapixels') return this.megapixelsInput;
153
+ return null;
154
+ }
155
+
156
+ handleStepBtn(btn: HTMLButtonElement) {
157
+ const action = btn.dataset.action;
158
+ const targetId = btn.dataset.target;
159
+ const input = this.resolveStepInput(targetId);
160
+ if (!input) return;
161
+ let val = parseFloat(input.value);
162
+ const step = parseFloat(input.step) || 1;
163
+ if (action === 'inc') val += step;
164
+ if (action === 'dec') val -= step;
165
+ input.value = Math.max(parseFloat(input.min) || 0, val).toFixed(targetId === 'aperture' ? 1 : 0);
166
+ this.calculate();
167
+ }
168
+
169
+ bindModeButtons() {
170
+ this.modeBtns.forEach((btn) => {
171
+ btn.addEventListener('click', () => {
172
+ this.modeBtns.forEach((b) => b.classList.remove('active'));
173
+ btn.classList.add('active');
174
+ this.mode = btn.dataset.mode || 'classic';
175
+ if (this.npfControls) {
176
+ this.npfControls.style.display = this.mode === 'npf' ? 'flex' : 'none';
177
+ }
178
+ this.calculate();
179
+ });
180
+ });
181
+ }
182
+
183
+ bindInputListeners() {
184
+ this.stepBtns.forEach((btn) => btn.addEventListener('click', () => this.handleStepBtn(btn)));
185
+ [this.focalLengthInput, this.apertureInput, this.megapixelsInput].forEach((inp) => {
186
+ if (inp) inp.addEventListener('input', () => this.calculate());
187
+ });
188
+ if (this.sensorSelect) this.sensorSelect.addEventListener('change', () => this.calculate());
189
+ if (this.declinationInput) {
190
+ this.declinationInput.addEventListener('input', () => {
191
+ if (this.declinationValueDisplay) {
192
+ this.declinationValueDisplay.textContent = this.declinationInput.value;
193
+ }
194
+ this.calculate();
195
+ });
196
+ }
197
+ if (this.simOffsetInput) {
198
+ this.simOffsetInput.addEventListener('input', () => this.updateSimulation());
199
+ }
200
+ }
201
+
202
+ init() {
203
+ this.bindModeButtons();
204
+ this.bindInputListeners();
205
+ this.calculate();
206
+ }
207
+
208
+ getExposureParams() {
209
+ return {
210
+ mode: this.mode as 'classic' | 'npf',
211
+ focalLength: parseFloat(this.focalLengthInput.value) || 1,
212
+ cropFactor: parseFloat(this.sensorSelect.value) as SensorCropFactor,
213
+ aperture: parseFloat(this.apertureInput?.value || '2.8'),
214
+ megapixels: parseFloat(this.megapixelsInput?.value || '24'),
215
+ declination: parseFloat(this.declinationInput.value) || 0,
216
+ };
217
+ }
218
+
219
+ calculate() {
220
+ if (!this.focalLengthInput || !this.sensorSelect || !this.declinationInput) return;
221
+ const resultTime = calculateExposureTime(this.getExposureParams());
222
+ if (this.resultTimeDisplay) {
223
+ this.resultTimeDisplay.textContent = resultTime.toFixed(1);
224
+ }
225
+ this.updateSimulation();
226
+ }
227
+
228
+ updateSimulation() {
229
+ if (!this.simOffsetInput || !this.starPreview) return;
230
+ const excess = parseFloat(this.simOffsetInput.value);
231
+ const trailLength = (excess - 1) * 20;
232
+ const info = document.getElementById('sim-info');
233
+ if (excess > 1.1) {
234
+ this.starPreview.style.width = `${trailLength + 4}px`;
235
+ this.starPreview.style.borderRadius = '2px';
236
+ this.starPreview.classList.add('is-trail');
237
+ if (info) info.textContent = uiData.trailStars;
238
+ } else {
239
+ this.starPreview.style.width = '4px';
240
+ this.starPreview.style.borderRadius = '50%';
241
+ this.starPreview.classList.remove('is-trail');
242
+ if (info) info.textContent = uiData.pointStars;
243
+ }
244
+ }
245
+ }
246
+
247
+ new StarCalculatorApp();
248
+ </script>
249
+