@pie-qti/player-elements 0.1.13 → 0.1.14
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/chunk-foFoljWS.js +23 -0
- package/dist/constants.d.ts +2 -0
- package/dist/define-Bnro1F0n.js +53668 -0
- package/dist/define-Bnro1F0n.js.map +1 -0
- package/dist/dist-B0-Hobtf.js +492 -0
- package/dist/dist-B0-Hobtf.js.map +1 -0
- package/dist/dist-CPQf4exh.js +220 -0
- package/dist/dist-CPQf4exh.js.map +1 -0
- package/dist/dist-DkT5jq7f.js +7461 -0
- package/dist/dist-DkT5jq7f.js.map +1 -0
- package/dist/element-TO8a6VNu.js +22021 -0
- package/dist/element-TO8a6VNu.js.map +1 -0
- package/dist/elements/BaseSvelteMountElement.d.ts +3 -1
- package/dist/elements/QtiSectionPlayerSplitPaneElement.d.ts +31 -0
- package/dist/elements/QtiSectionPlayerVerticalElement.d.ts +5 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/{mathlive.min-2KqNdJi1-CCoBJw8d.js → mathlive.min-CAPebTxM-FLQp-YPM.js} +3973 -3978
- package/dist/mathlive.min-CAPebTxM-FLQp-YPM.js.map +1 -0
- package/dist/pie-tool-calculator-N9OP39tS.js +2309 -0
- package/dist/pie-tool-calculator-N9OP39tS.js.map +1 -0
- package/dist/{plugins-BsW7NNYi.js → plugins-uoPa6dIu.js} +32617 -39544
- package/dist/plugins-uoPa6dIu.js.map +1 -0
- package/dist/register.js +1 -1
- package/dist/register.js.map +1 -1
- package/dist/sre-Bx59_vxW.js +17220 -0
- package/dist/sre-Bx59_vxW.js.map +1 -0
- package/dist/tool-tts-inline-CHCzENwP.js +2641 -0
- package/dist/tool-tts-inline-CHCzENwP.js.map +1 -0
- package/package.json +5 -4
- package/dist/auto-render-s0W2CzD_.js +0 -22079
- package/dist/auto-render-s0W2CzD_.js.map +0 -1
- package/dist/define-uFzOfyZV.js +0 -38647
- package/dist/define-uFzOfyZV.js.map +0 -1
- package/dist/mathlive.min-2KqNdJi1-CCoBJw8d.js.map +0 -1
- package/dist/plugins-BsW7NNYi.js.map +0 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
//#region ../../node_modules/.bun/@pie-players+pie-calculator-desmos@0.3.53/node_modules/@pie-players/pie-calculator-desmos/dist/desmos-provider.js
|
|
2
|
+
var e = class {
|
|
3
|
+
providerId = "desmos";
|
|
4
|
+
providerName = "Desmos";
|
|
5
|
+
supportedTypes = [
|
|
6
|
+
"basic",
|
|
7
|
+
"scientific",
|
|
8
|
+
"graphing"
|
|
9
|
+
];
|
|
10
|
+
version = "1.10";
|
|
11
|
+
initialized = !1;
|
|
12
|
+
apiKey;
|
|
13
|
+
proxyEndpoint;
|
|
14
|
+
isDevelopment = !1;
|
|
15
|
+
onTelemetry;
|
|
16
|
+
async emitTelemetry(e, t) {
|
|
17
|
+
try {
|
|
18
|
+
await this.onTelemetry?.(e, t);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.warn("[DesmosProvider] telemetry callback failed:", e);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getApiKey() {
|
|
24
|
+
return this.apiKey;
|
|
25
|
+
}
|
|
26
|
+
async loadDesmosScript() {
|
|
27
|
+
return new Promise((e, t) => {
|
|
28
|
+
let n = document.createElement("script");
|
|
29
|
+
n.src = this.apiKey ? `https://www.desmos.com/api/v1.10/calculator.js?apiKey=${this.apiKey}` : "https://www.desmos.com/api/v1.10/calculator.js", n.async = !0, n.onload = () => {
|
|
30
|
+
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : t(/* @__PURE__ */ Error("Desmos API loaded but window.Desmos is undefined"));
|
|
31
|
+
}, n.onerror = () => {
|
|
32
|
+
t(/* @__PURE__ */ Error("Failed to load Desmos API from CDN"));
|
|
33
|
+
}, document.head.appendChild(n);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async initialize(e) {
|
|
37
|
+
if (!this.initialized) {
|
|
38
|
+
if (this.onTelemetry = e?.onTelemetry, typeof window > "u") throw Error("Desmos calculators can only be initialized in the browser");
|
|
39
|
+
if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
|
|
40
|
+
this.proxyEndpoint = e.proxyEndpoint;
|
|
41
|
+
let t = Date.now();
|
|
42
|
+
await this.emitTelemetry("pie-tool-backend-call-start", {
|
|
43
|
+
toolId: "calculator",
|
|
44
|
+
backend: "desmos",
|
|
45
|
+
operation: "proxy-auth-fetch"
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
let n = await fetch(e.proxyEndpoint);
|
|
49
|
+
if (!n.ok) throw Error(`Proxy endpoint returned ${n.status}`);
|
|
50
|
+
let r = await n.json();
|
|
51
|
+
this.apiKey = r.apiKey, await this.emitTelemetry("pie-tool-backend-call-success", {
|
|
52
|
+
toolId: "calculator",
|
|
53
|
+
backend: "desmos",
|
|
54
|
+
operation: "proxy-auth-fetch",
|
|
55
|
+
duration: Date.now() - t
|
|
56
|
+
}), console.log("[DesmosProvider] Initialized with server-side proxy (SECURE)");
|
|
57
|
+
} catch (e) {
|
|
58
|
+
throw await this.emitTelemetry("pie-tool-backend-call-error", {
|
|
59
|
+
toolId: "calculator",
|
|
60
|
+
backend: "desmos",
|
|
61
|
+
operation: "proxy-auth-fetch",
|
|
62
|
+
duration: Date.now() - t,
|
|
63
|
+
errorType: "CalculatorProxyAuthError",
|
|
64
|
+
message: e instanceof Error ? e.message : String(e)
|
|
65
|
+
}), Error(`[DesmosProvider] Failed to fetch API key from proxy: ${e}`);
|
|
66
|
+
}
|
|
67
|
+
} else e?.apiKey ? (this.apiKey = e.apiKey, this.isDevelopment ? console.log("[DesmosProvider] Initialized with direct API key (DEVELOPMENT MODE)") : console.error("⚠️ [DesmosProvider] SECURITY WARNING: API key exposed in client-side code!\nThis is insecure for production. Use proxyEndpoint instead.\nSee: https://pie-players.dev/docs/calculator-desmos#security")) : console.warn("[DesmosProvider] No API key or proxy endpoint provided.\nProduction usage requires authentication. Obtain API key from https://www.desmos.com/api\nRecommended: Use proxyEndpoint for production, apiKey for development only.");
|
|
68
|
+
if (!window.Desmos) {
|
|
69
|
+
console.log("[DesmosProvider] Loading Desmos API library...");
|
|
70
|
+
let e = Date.now();
|
|
71
|
+
await this.emitTelemetry("pie-tool-library-load-start", {
|
|
72
|
+
toolId: "calculator",
|
|
73
|
+
backend: "desmos",
|
|
74
|
+
operation: "desmos-script-load"
|
|
75
|
+
});
|
|
76
|
+
try {
|
|
77
|
+
await this.loadDesmosScript(), await this.emitTelemetry("pie-tool-library-load-success", {
|
|
78
|
+
toolId: "calculator",
|
|
79
|
+
backend: "desmos",
|
|
80
|
+
operation: "desmos-script-load",
|
|
81
|
+
duration: Date.now() - e
|
|
82
|
+
});
|
|
83
|
+
} catch (t) {
|
|
84
|
+
throw await this.emitTelemetry("pie-tool-library-load-error", {
|
|
85
|
+
toolId: "calculator",
|
|
86
|
+
backend: "desmos",
|
|
87
|
+
operation: "desmos-script-load",
|
|
88
|
+
duration: Date.now() - e,
|
|
89
|
+
errorType: "ToolLibraryLoadError",
|
|
90
|
+
message: t instanceof Error ? t.message : String(t)
|
|
91
|
+
}), t;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.initialized = !0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async createCalculator(e, n, r) {
|
|
98
|
+
if (this.initialized || await this.initialize(), !this.supportsType(e)) throw Error(`Desmos does not support calculator type: ${e}`);
|
|
99
|
+
return new t(this, e, n, r, this.apiKey);
|
|
100
|
+
}
|
|
101
|
+
supportsType(e) {
|
|
102
|
+
return this.supportedTypes.includes(e);
|
|
103
|
+
}
|
|
104
|
+
destroy() {
|
|
105
|
+
this.initialized = !1, this.onTelemetry = void 0;
|
|
106
|
+
}
|
|
107
|
+
getCapabilities() {
|
|
108
|
+
return {
|
|
109
|
+
supportsHistory: !1,
|
|
110
|
+
supportsGraphing: !0,
|
|
111
|
+
supportsExpressions: !0,
|
|
112
|
+
canExport: !0,
|
|
113
|
+
maxPrecision: 15,
|
|
114
|
+
inputMethods: [
|
|
115
|
+
"keyboard",
|
|
116
|
+
"mouse",
|
|
117
|
+
"touch"
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}, t = class {
|
|
122
|
+
provider;
|
|
123
|
+
type;
|
|
124
|
+
Desmos;
|
|
125
|
+
calculator;
|
|
126
|
+
container;
|
|
127
|
+
constructor(e, t, n, r, i) {
|
|
128
|
+
if (this.provider = e, this.type = t, this.container = n, this.Desmos = window.Desmos, !this.Desmos) throw Error("Desmos API not available");
|
|
129
|
+
this._initializeCalculator(r, i);
|
|
130
|
+
}
|
|
131
|
+
_initializeCalculator(e, t) {
|
|
132
|
+
let n = {
|
|
133
|
+
...e?.desmos || {},
|
|
134
|
+
apiKey: t || e?.desmos?.apiKey
|
|
135
|
+
};
|
|
136
|
+
switch (e?.restrictedMode && Object.assign(n, {
|
|
137
|
+
expressionsTopbar: !1,
|
|
138
|
+
settingsMenu: !1,
|
|
139
|
+
zoomButtons: !1,
|
|
140
|
+
expressions: !1,
|
|
141
|
+
links: !1
|
|
142
|
+
}), this.type) {
|
|
143
|
+
case "graphing":
|
|
144
|
+
this.calculator = this.Desmos.GraphingCalculator(this.container, n);
|
|
145
|
+
break;
|
|
146
|
+
case "scientific":
|
|
147
|
+
this.calculator = this.Desmos.ScientificCalculator(this.container, n);
|
|
148
|
+
break;
|
|
149
|
+
case "basic":
|
|
150
|
+
this.calculator = this.Desmos.FourFunctionCalculator(this.container, n);
|
|
151
|
+
break;
|
|
152
|
+
default: throw Error(`Unsupported calculator type: ${this.type}`);
|
|
153
|
+
}
|
|
154
|
+
console.log(`[DesmosCalculator] Created ${this.type} calculator`);
|
|
155
|
+
}
|
|
156
|
+
getValue() {
|
|
157
|
+
if (this.type === "graphing" && this.calculator.getState) {
|
|
158
|
+
let e = this.calculator.getState();
|
|
159
|
+
return JSON.stringify(e);
|
|
160
|
+
}
|
|
161
|
+
return "";
|
|
162
|
+
}
|
|
163
|
+
setValue(e) {
|
|
164
|
+
if (this.type === "graphing" && this.calculator.setState) try {
|
|
165
|
+
let t = JSON.parse(e);
|
|
166
|
+
this.calculator.setState(t);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
console.error("[DesmosCalculator] Failed to set state:", e);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
clear() {
|
|
172
|
+
this.calculator.setBlank && this.calculator.setBlank();
|
|
173
|
+
}
|
|
174
|
+
async evaluate(e) {
|
|
175
|
+
return this.type === "graphing" ? new Promise((t) => {
|
|
176
|
+
let n = `eval_${Date.now()}`;
|
|
177
|
+
this.calculator.setExpression({
|
|
178
|
+
id: n,
|
|
179
|
+
latex: e
|
|
180
|
+
}), setTimeout(() => {
|
|
181
|
+
let r = this.calculator.HelperExpression({ latex: e }).numericValue || e;
|
|
182
|
+
this.calculator.removeExpression({ id: n }), t(String(r));
|
|
183
|
+
}, 100);
|
|
184
|
+
}) : e;
|
|
185
|
+
}
|
|
186
|
+
resize() {
|
|
187
|
+
this.calculator.resize && this.calculator.resize();
|
|
188
|
+
}
|
|
189
|
+
focus() {
|
|
190
|
+
try {
|
|
191
|
+
if (this.type === "graphing" && typeof this.calculator?.focusFirstExpression == "function") {
|
|
192
|
+
this.calculator.focusFirstExpression();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.container.querySelector(".dcg-mq-editable-field[tabindex=\"0\"], textarea, [contenteditable=\"true\"], [tabindex]:not([tabindex=\"-1\"])")?.focus();
|
|
196
|
+
} catch (e) {
|
|
197
|
+
console.warn("[DesmosCalculator] focus() failed:", e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exportState() {
|
|
201
|
+
let e = {};
|
|
202
|
+
return this.type === "graphing" && this.calculator.getState && (e = this.calculator.getState()), {
|
|
203
|
+
type: this.type,
|
|
204
|
+
provider: "desmos",
|
|
205
|
+
value: this.getValue(),
|
|
206
|
+
providerState: e
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
importState(e) {
|
|
210
|
+
if (e.provider !== "desmos") throw Error(`Cannot import state from provider: ${e.provider}`);
|
|
211
|
+
e.providerState && this.calculator.setState ? this.calculator.setState(e.providerState) : e.value && this.setValue(e.value);
|
|
212
|
+
}
|
|
213
|
+
destroy() {
|
|
214
|
+
this.calculator && this.calculator.destroy && this.calculator.destroy(), this.container.replaceChildren(), console.log("[DesmosCalculator] destroyed");
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
//#endregion
|
|
218
|
+
export { e as DesmosCalculatorProvider };
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=dist-CPQf4exh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-CPQf4exh.js","names":[],"sources":["../../../node_modules/.bun/@pie-players+pie-calculator-desmos@0.3.53/node_modules/@pie-players/pie-calculator-desmos/dist/desmos-provider.js"],"sourcesContent":["/**\n * Desmos Calculator Provider\n * Implementation of CalculatorProvider for Desmos calculators\n *\n * Supports: Basic, Scientific, and Graphing calculators\n * Based on Desmos API v1.10+\n * Requires: Desmos API key (obtain from https://www.desmos.com/api)\n *\n * SECURITY BEST PRACTICE:\n * - Development: Pass apiKey directly for local testing\n * - Production: Use proxyEndpoint to keep API key server-side\n *\n * Example server-side proxy (Express.js):\n * ```\n * app.get('/api/desmos/token', requireAuth, (req, res) => {\n * res.json({ apiKey: process.env.DESMOS_API_KEY });\n * });\n * ```\n */\n/**\n * Desmos Calculator Provider Implementation\n */\nexport class DesmosCalculatorProvider {\n providerId = \"desmos\";\n providerName = \"Desmos\";\n supportedTypes = [\n \"basic\",\n \"scientific\",\n \"graphing\",\n ];\n version = \"1.10\";\n initialized = false;\n apiKey;\n proxyEndpoint;\n isDevelopment = false;\n onTelemetry;\n async emitTelemetry(eventName, payload) {\n try {\n await this.onTelemetry?.(eventName, payload);\n }\n catch (error) {\n console.warn(\"[DesmosProvider] telemetry callback failed:\", error);\n }\n }\n /**\n * Get the configured API key\n * @internal Used internally by calculator instances\n */\n getApiKey() {\n return this.apiKey;\n }\n /**\n * Dynamically load the Desmos calculator library\n * @private\n */\n async loadDesmosScript() {\n return new Promise((resolve, reject) => {\n const script = document.createElement(\"script\");\n // Include API key in script URL if available\n const scriptUrl = this.apiKey\n ? `https://www.desmos.com/api/v1.10/calculator.js?apiKey=${this.apiKey}`\n : \"https://www.desmos.com/api/v1.10/calculator.js\";\n script.src = scriptUrl;\n script.async = true;\n script.onload = () => {\n if (window.Desmos) {\n console.log(\"[DesmosProvider] Desmos API loaded successfully\");\n resolve();\n }\n else {\n reject(new Error(\"Desmos API loaded but window.Desmos is undefined\"));\n }\n };\n script.onerror = () => {\n reject(new Error(\"Failed to load Desmos API from CDN\"));\n };\n document.head.appendChild(script);\n });\n }\n /**\n * Initialize Desmos library\n * @param config Configuration with API key (development) or proxy endpoint (production)\n */\n async initialize(config) {\n if (this.initialized)\n return;\n this.onTelemetry = config?.onTelemetry;\n // SSR guard\n if (typeof window === \"undefined\") {\n throw new Error(\"Desmos calculators can only be initialized in the browser\");\n }\n // Determine if we're in development mode\n this.isDevelopment =\n process.env.NODE_ENV === \"development\" ||\n typeof process === \"undefined\" ||\n !process.env.NODE_ENV;\n // Configure API access pattern\n if (config?.proxyEndpoint) {\n // Production pattern: server-side proxy\n this.proxyEndpoint = config.proxyEndpoint;\n const authStartedAt = Date.now();\n await this.emitTelemetry(\"pie-tool-backend-call-start\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"proxy-auth-fetch\",\n });\n try {\n const response = await fetch(config.proxyEndpoint);\n if (!response.ok) {\n throw new Error(`Proxy endpoint returned ${response.status}`);\n }\n const data = await response.json();\n this.apiKey = data.apiKey;\n await this.emitTelemetry(\"pie-tool-backend-call-success\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"proxy-auth-fetch\",\n duration: Date.now() - authStartedAt,\n });\n console.log(\"[DesmosProvider] Initialized with server-side proxy (SECURE)\");\n }\n catch (error) {\n await this.emitTelemetry(\"pie-tool-backend-call-error\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"proxy-auth-fetch\",\n duration: Date.now() - authStartedAt,\n errorType: \"CalculatorProxyAuthError\",\n message: error instanceof Error ? error.message : String(error),\n });\n throw new Error(`[DesmosProvider] Failed to fetch API key from proxy: ${error}`);\n }\n }\n else if (config?.apiKey) {\n // Development pattern: direct API key\n this.apiKey = config.apiKey;\n // Security warning in production\n if (!this.isDevelopment) {\n console.error(\"⚠️ [DesmosProvider] SECURITY WARNING: API key exposed in client-side code!\\n\" +\n \"This is insecure for production. Use proxyEndpoint instead.\\n\" +\n \"See: https://pie-players.dev/docs/calculator-desmos#security\");\n }\n else {\n console.log(\"[DesmosProvider] Initialized with direct API key (DEVELOPMENT MODE)\");\n }\n }\n else {\n // No API key provided\n console.warn(\"[DesmosProvider] No API key or proxy endpoint provided.\\n\" +\n \"Production usage requires authentication. Obtain API key from https://www.desmos.com/api\\n\" +\n \"Recommended: Use proxyEndpoint for production, apiKey for development only.\");\n }\n // Load Desmos API if not already loaded\n if (!window.Desmos) {\n console.log(\"[DesmosProvider] Loading Desmos API library...\");\n const libraryLoadStartedAt = Date.now();\n await this.emitTelemetry(\"pie-tool-library-load-start\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"desmos-script-load\",\n });\n try {\n await this.loadDesmosScript();\n await this.emitTelemetry(\"pie-tool-library-load-success\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"desmos-script-load\",\n duration: Date.now() - libraryLoadStartedAt,\n });\n }\n catch (error) {\n await this.emitTelemetry(\"pie-tool-library-load-error\", {\n toolId: \"calculator\",\n backend: \"desmos\",\n operation: \"desmos-script-load\",\n duration: Date.now() - libraryLoadStartedAt,\n errorType: \"ToolLibraryLoadError\",\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n }\n this.initialized = true;\n }\n /**\n * Create a calculator instance\n */\n async createCalculator(type, container, config) {\n if (!this.initialized) {\n await this.initialize();\n }\n if (!this.supportsType(type)) {\n throw new Error(`Desmos does not support calculator type: ${type}`);\n }\n return new DesmosCalculator(this, type, container, config, this.apiKey);\n }\n /**\n * Check if type is supported\n */\n supportsType(type) {\n return this.supportedTypes.includes(type);\n }\n /**\n * Cleanup\n */\n destroy() {\n this.initialized = false;\n this.onTelemetry = undefined;\n }\n /**\n * Get provider capabilities\n */\n getCapabilities() {\n return {\n supportsHistory: false, // Desmos doesn't expose history API\n supportsGraphing: true,\n supportsExpressions: true,\n canExport: true,\n maxPrecision: 15,\n inputMethods: [\"keyboard\", \"mouse\", \"touch\"],\n };\n }\n}\n/**\n * Desmos Calculator Instance\n */\nclass DesmosCalculator {\n provider;\n type;\n Desmos;\n calculator;\n container;\n constructor(provider, type, container, config, apiKey) {\n this.provider = provider;\n this.type = type;\n this.container = container;\n this.Desmos = window.Desmos;\n if (!this.Desmos) {\n throw new Error(\"Desmos API not available\");\n }\n this._initializeCalculator(config, apiKey);\n }\n _initializeCalculator(config, apiKey) {\n // Merge Desmos-specific config with defaults\n const desmosConfig = {\n ...(config?.desmos || {}),\n apiKey: apiKey || config?.desmos?.apiKey,\n };\n // Apply restricted mode if specified\n if (config?.restrictedMode) {\n Object.assign(desmosConfig, {\n expressionsTopbar: false,\n settingsMenu: false,\n zoomButtons: false,\n expressions: false,\n links: false,\n });\n }\n // Create appropriate calculator type\n switch (this.type) {\n case \"graphing\":\n this.calculator = this.Desmos.GraphingCalculator(this.container, desmosConfig);\n break;\n case \"scientific\":\n this.calculator = this.Desmos.ScientificCalculator(this.container, desmosConfig);\n break;\n case \"basic\":\n this.calculator = this.Desmos.FourFunctionCalculator(this.container, desmosConfig);\n break;\n default:\n throw new Error(`Unsupported calculator type: ${this.type}`);\n }\n console.log(`[DesmosCalculator] Created ${this.type} calculator`);\n }\n getValue() {\n // For graphing calculator, get the state\n if (this.type === \"graphing\" && this.calculator.getState) {\n const state = this.calculator.getState();\n return JSON.stringify(state);\n }\n // For other calculators, return empty (Desmos doesn't expose value API)\n return \"\";\n }\n setValue(value) {\n // For graphing calculator, set the state\n if (this.type === \"graphing\" && this.calculator.setState) {\n try {\n const state = JSON.parse(value);\n this.calculator.setState(state);\n }\n catch (error) {\n console.error(\"[DesmosCalculator] Failed to set state:\", error);\n }\n }\n }\n clear() {\n if (this.calculator.setBlank) {\n this.calculator.setBlank();\n }\n }\n async evaluate(expression) {\n // Desmos doesn't provide a direct evaluate API\n // For graphing calculator, add expression and observe\n if (this.type === \"graphing\") {\n return new Promise((resolve) => {\n const id = `eval_${Date.now()}`;\n this.calculator.setExpression({ id, latex: expression });\n // Give Desmos time to process\n setTimeout(() => {\n const helperExpression = this.calculator.HelperExpression({\n latex: expression,\n });\n const result = helperExpression.numericValue || expression;\n this.calculator.removeExpression({ id });\n resolve(String(result));\n }, 100);\n });\n }\n return expression;\n }\n resize() {\n if (this.calculator.resize) {\n this.calculator.resize();\n }\n }\n focus() {\n try {\n if (this.type === \"graphing\" &&\n typeof this.calculator?.focusFirstExpression === \"function\") {\n this.calculator.focusFirstExpression();\n return;\n }\n const target = this.container.querySelector('.dcg-mq-editable-field[tabindex=\"0\"], textarea, [contenteditable=\"true\"], [tabindex]:not([tabindex=\"-1\"])');\n target?.focus();\n }\n catch (error) {\n console.warn(\"[DesmosCalculator] focus() failed:\", error);\n }\n }\n exportState() {\n let providerState = {};\n if (this.type === \"graphing\" && this.calculator.getState) {\n providerState = this.calculator.getState();\n }\n return {\n type: this.type,\n provider: \"desmos\",\n value: this.getValue(),\n providerState,\n };\n }\n importState(state) {\n if (state.provider !== \"desmos\") {\n throw new Error(`Cannot import state from provider: ${state.provider}`);\n }\n if (state.providerState && this.calculator.setState) {\n this.calculator.setState(state.providerState);\n }\n else if (state.value) {\n this.setValue(state.value);\n }\n }\n destroy() {\n if (this.calculator && this.calculator.destroy) {\n this.calculator.destroy();\n }\n this.container.replaceChildren();\n console.log(\"[DesmosCalculator] destroyed\");\n }\n}\n//# sourceMappingURL=desmos-provider.js.map"],"x_google_ignoreList":[0],"mappings":";AAsBA,IAAa,IAAb,MAAsC;CAClC,aAAa;CACb,eAAe;CACf,iBAAiB;EACb;EACA;EACA;EACH;CACD,UAAU;CACV,cAAc;CACd;CACA;CACA,gBAAgB;CAChB;CACA,MAAM,cAAc,GAAW,GAAS;AACpC,MAAI;AACA,SAAM,KAAK,cAAc,GAAW,EAAQ;WAEzC,GAAO;AACV,WAAQ,KAAK,+CAA+C,EAAM;;;CAO1E,YAAY;AACR,SAAO,KAAK;;CAMhB,MAAM,mBAAmB;AACrB,SAAO,IAAI,SAAS,GAAS,MAAW;GACpC,IAAM,IAAS,SAAS,cAAc,SAAS;AAmB/C,GAdA,EAAO,MAHW,KAAK,SACjB,yDAAyD,KAAK,WAC9D,kDAEN,EAAO,QAAQ,IACf,EAAO,eAAe;AAClB,IAAI,OAAO,UACP,QAAQ,IAAI,kDAAkD,EAC9D,GAAS,IAGT,EAAO,gBAAI,MAAM,mDAAmD,CAAC;MAG7E,EAAO,gBAAgB;AACnB,MAAO,gBAAI,MAAM,qCAAqC,CAAC;MAE3D,SAAS,KAAK,YAAY,EAAO;IACnC;;CAMN,MAAM,WAAW,GAAQ;AACjB,YAAK,aAIT;OAFA,KAAK,cAAc,GAAQ,aAEvB,OAAO,SAAW,IAClB,OAAU,MAAM,4DAA4D;AAQhF,OALA,KAAK,gBAAA,QAAA,IAAA,aACwB,iBACrB,OAAO,UAAY,OACnB,CAAA,QAAA,IAAA,UAEJ,GAAQ,eAAe;AAEvB,SAAK,gBAAgB,EAAO;IAC5B,IAAM,IAAgB,KAAK,KAAK;AAChC,UAAM,KAAK,cAAc,+BAA+B;KACpD,QAAQ;KACR,SAAS;KACT,WAAW;KACd,CAAC;AACF,QAAI;KACA,IAAM,IAAW,MAAM,MAAM,EAAO,cAAc;AAClD,SAAI,CAAC,EAAS,GACV,OAAU,MA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