@ziztechnology/dial-library 0.0.5 → 0.0.6

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 (2) hide show
  1. package/dist/index.mjs +1768 -290
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,32 @@
1
1
  import { Gunzip } from "fflate";
2
+ //#region src/helper/debugger.ts
3
+ const stringifyDebugData = (data) => {
4
+ const seen = /* @__PURE__ */ new WeakSet();
5
+ return JSON.stringify(data, (_key, value) => {
6
+ if (value instanceof Error) return {
7
+ name: value.name,
8
+ message: value.message,
9
+ stack: value.stack
10
+ };
11
+ if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
12
+ if (typeof value === "bigint") return value.toString();
13
+ if (typeof value === "object" && value !== null) {
14
+ if (seen.has(value)) return "[Circular]";
15
+ seen.add(value);
16
+ }
17
+ return value;
18
+ }) ?? String(data);
19
+ };
20
+ const dialSdkDebugWarn = (moduleName, scope, phase, data) => {
21
+ const message = `[DIAL_SDK_DEBUG - ${moduleName}] ${scope}: ${phase}`;
22
+ try {
23
+ if (data === void 0) console.warn(message);
24
+ else console.warn(message, stringifyDebugData(data));
25
+ } catch {}
26
+ };
27
+ //#endregion
2
28
  //#region src/sensor/check_status.ts
29
+ const DEBUG_MODULE$5 = "check_status.ts";
3
30
  const DEFAULT_DRIVING_STATUS_TUNING = Object.freeze({
4
31
  version: "driving-status-v1",
5
32
  maxSampleAgeMs: 1e3,
@@ -36,12 +63,23 @@ const DEFAULT_DRIVING_STATUS_TUNING = Object.freeze({
36
63
  })
37
64
  });
38
65
  const classifyDrivingSnapshot = (info, tuningOverrides) => {
66
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingSnapshot", "called", {
67
+ info,
68
+ tuningOverrides
69
+ });
39
70
  const tuning = resolveDrivingStatusTuning(tuningOverrides);
40
71
  const metrics = extractDrivingSnapshotMetrics(info, tuning);
41
- return metrics === null ? null : classifyDrivingMetrics(metrics, tuning);
72
+ const result = metrics === null ? null : classifyDrivingMetrics(metrics, tuning);
73
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingSnapshot", "returned", {
74
+ tuning,
75
+ metrics,
76
+ result
77
+ });
78
+ return result;
42
79
  };
43
80
  const checkRunningStatus = classifyDrivingSnapshot;
44
81
  const resolveDrivingStatusTuning = (overrides = {}) => {
82
+ dialSdkDebugWarn(DEBUG_MODULE$5, "resolveDrivingStatusTuning", "called", { overrides });
45
83
  const tuning = {
46
84
  ...DEFAULT_DRIVING_STATUS_TUNING,
47
85
  ...overrides,
@@ -70,19 +108,36 @@ const resolveDrivingStatusTuning = (overrides = {}) => {
70
108
  if (!Number.isFinite(tuning.hysteresisRatio) || tuning.hysteresisRatio <= 0 || tuning.hysteresisRatio >= 1) throw new RangeError("hysteresisRatio must be greater than 0 and less than 1");
71
109
  for (const [status, value] of Object.entries(tuning.confirmationSamples)) if (!Number.isInteger(value) || value < 1) throw new RangeError(`confirmationSamples.${status} must be a positive integer`);
72
110
  for (const [status, value] of Object.entries(tuning.minimumDisplayMs)) if (!Number.isFinite(value) || value < 0) throw new RangeError(`minimumDisplayMs.${status} must be a non-negative finite number`);
111
+ dialSdkDebugWarn(DEBUG_MODULE$5, "resolveDrivingStatusTuning", "returned", { tuning });
73
112
  return tuning;
74
113
  };
75
114
  const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUNING) => {
76
- if (!info || !Number.isFinite(info.capturedAtMs)) return null;
115
+ dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "called", {
116
+ info,
117
+ tuning
118
+ });
119
+ if (!info || !Number.isFinite(info.capturedAtMs)) {
120
+ dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned invalid capture time", { info });
121
+ return null;
122
+ }
77
123
  const linearAcceleration = availableFreshVector(info.linearAcceleration, info.capturedAtMs, tuning.maxSampleAgeMs);
78
124
  const gyroscope = availableFreshVector(info.gyroscope, info.capturedAtMs, tuning.maxSampleAgeMs);
79
- if (linearAcceleration === null || gyroscope === null) return null;
125
+ if (linearAcceleration === null || gyroscope === null) {
126
+ dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned unavailable vectors", {
127
+ linearAcceleration,
128
+ gyroscope
129
+ });
130
+ return null;
131
+ }
80
132
  const longitudinal = -linearAcceleration.z;
81
133
  const lateral = linearAcceleration.x;
82
134
  const yaw = gyroscope.y;
83
135
  const motionIntensity = info.motionIntensity === void 0 ? vectorMagnitude(linearAcceleration) : availableFreshNumber(info.motionIntensity, info.capturedAtMs, tuning.maxSampleAgeMs);
84
- if (motionIntensity === null) return null;
85
- return {
136
+ if (motionIntensity === null) {
137
+ dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned unavailable motion intensity", { motionIntensity: info.motionIntensity });
138
+ return null;
139
+ }
140
+ const result = {
86
141
  capturedAtMs: info.capturedAtMs,
87
142
  longitudinal,
88
143
  lateral,
@@ -90,44 +145,144 @@ const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUN
90
145
  motionIntensity,
91
146
  gyroMagnitude: vectorMagnitude(gyroscope)
92
147
  };
148
+ dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned", { result });
149
+ return result;
93
150
  };
94
151
  const classifyDrivingMetrics = (metrics, tuning = DEFAULT_DRIVING_STATUS_TUNING) => {
152
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "called", {
153
+ metrics,
154
+ tuning
155
+ });
95
156
  const { longitudinal, lateral, yaw, motionIntensity, gyroMagnitude } = metrics;
96
- if (longitudinal <= -tuning.rapidLongitudinalThreshold) return "SUDDEN_BRAKING";
97
- if (longitudinal >= tuning.rapidLongitudinalThreshold) return "RAPID_ACCELERATION";
98
- if (Math.abs(yaw) >= tuning.turnYawThreshold) return yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
99
- if (Math.abs(lateral) >= tuning.turnLateralThreshold) return lateral < 0 ? "LEFT_TURN" : "RIGHT_TURN";
100
- if (longitudinal <= -tuning.longitudinalThreshold) return "BRAKING";
101
- if (longitudinal >= tuning.longitudinalThreshold) return "ACCELERATION";
102
- if (motionIntensity < tuning.drivingMotionThreshold && gyroMagnitude <= tuning.stoppedGyroThreshold) return "STOPPED";
157
+ if (longitudinal <= -tuning.rapidLongitudinalThreshold) {
158
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "SUDDEN_BRAKING" });
159
+ return "SUDDEN_BRAKING";
160
+ }
161
+ if (longitudinal >= tuning.rapidLongitudinalThreshold) {
162
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "RAPID_ACCELERATION" });
163
+ return "RAPID_ACCELERATION";
164
+ }
165
+ if (Math.abs(yaw) >= tuning.turnYawThreshold) {
166
+ const result = yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
167
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", {
168
+ result,
169
+ basis: "yaw"
170
+ });
171
+ return result;
172
+ }
173
+ if (Math.abs(lateral) >= tuning.turnLateralThreshold) {
174
+ const result = lateral < 0 ? "LEFT_TURN" : "RIGHT_TURN";
175
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", {
176
+ result,
177
+ basis: "lateral"
178
+ });
179
+ return result;
180
+ }
181
+ if (longitudinal <= -tuning.longitudinalThreshold) {
182
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "BRAKING" });
183
+ return "BRAKING";
184
+ }
185
+ if (longitudinal >= tuning.longitudinalThreshold) {
186
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "ACCELERATION" });
187
+ return "ACCELERATION";
188
+ }
189
+ if (motionIntensity < tuning.drivingMotionThreshold && gyroMagnitude <= tuning.stoppedGyroThreshold) {
190
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "STOPPED" });
191
+ return "STOPPED";
192
+ }
193
+ dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingMetrics", "returned", { result: "STEADY_DRIVING" });
103
194
  return "STEADY_DRIVING";
104
195
  };
105
196
  const availableFreshVector = (metric, capturedAtMs, maxSampleAgeMs) => {
106
- if (!metric?.available || !isFresh(metric.sampledAtMs, capturedAtMs, maxSampleAgeMs)) return null;
197
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshVector", "called", {
198
+ metric,
199
+ capturedAtMs,
200
+ maxSampleAgeMs
201
+ });
202
+ if (!metric?.available || !isFresh(metric.sampledAtMs, capturedAtMs, maxSampleAgeMs)) {
203
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshVector", "returned", { result: null });
204
+ return null;
205
+ }
107
206
  const { x, y, z } = metric.value;
108
- return [
207
+ const result = [
109
208
  x,
110
209
  y,
111
210
  z
112
211
  ].every(Number.isFinite) ? metric.value : null;
212
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshVector", "returned", { result });
213
+ return result;
113
214
  };
114
215
  const availableFreshNumber = (metric, capturedAtMs, maxSampleAgeMs) => {
115
- if (!metric?.available || !isFresh(metric.sampledAtMs, capturedAtMs, maxSampleAgeMs)) return null;
116
- return Number.isFinite(metric.value) && metric.value >= 0 ? metric.value : null;
216
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshNumber", "called", {
217
+ metric,
218
+ capturedAtMs,
219
+ maxSampleAgeMs
220
+ });
221
+ if (!metric?.available || !isFresh(metric.sampledAtMs, capturedAtMs, maxSampleAgeMs)) {
222
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshNumber", "returned", { result: null });
223
+ return null;
224
+ }
225
+ const result = Number.isFinite(metric.value) && metric.value >= 0 ? metric.value : null;
226
+ dialSdkDebugWarn(DEBUG_MODULE$5, "availableFreshNumber", "returned", { result });
227
+ return result;
117
228
  };
118
229
  const isFresh = (sampledAtMs, capturedAtMs, maxSampleAgeMs) => {
119
- if (sampledAtMs === null || !Number.isFinite(sampledAtMs)) return false;
230
+ dialSdkDebugWarn(DEBUG_MODULE$5, "isFresh", "called", {
231
+ sampledAtMs,
232
+ capturedAtMs,
233
+ maxSampleAgeMs
234
+ });
235
+ if (sampledAtMs === null || !Number.isFinite(sampledAtMs)) {
236
+ dialSdkDebugWarn(DEBUG_MODULE$5, "isFresh", "returned", { result: false });
237
+ return false;
238
+ }
120
239
  const age = capturedAtMs - sampledAtMs;
121
- return age >= 0 && age <= maxSampleAgeMs;
240
+ const result = age >= 0 && age <= maxSampleAgeMs;
241
+ dialSdkDebugWarn(DEBUG_MODULE$5, "isFresh", "returned", {
242
+ age,
243
+ result
244
+ });
245
+ return result;
246
+ };
247
+ const vectorMagnitude = ({ x, y, z }) => {
248
+ const result = Math.hypot(x, y, z);
249
+ dialSdkDebugWarn(DEBUG_MODULE$5, "vectorMagnitude", "returned", {
250
+ x,
251
+ y,
252
+ z,
253
+ result
254
+ });
255
+ return result;
122
256
  };
123
- const vectorMagnitude = ({ x, y, z }) => Math.hypot(x, y, z);
124
257
  const assertPositiveFinite = (name, value) => {
125
- if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be a positive finite number`);
258
+ dialSdkDebugWarn(DEBUG_MODULE$5, "assertPositiveFinite", "called", {
259
+ name,
260
+ value
261
+ });
262
+ if (!Number.isFinite(value) || value <= 0) {
263
+ const error = /* @__PURE__ */ new RangeError(`${name} must be a positive finite number`);
264
+ dialSdkDebugWarn(DEBUG_MODULE$5, "assertPositiveFinite", "threw", error);
265
+ throw error;
266
+ }
267
+ dialSdkDebugWarn(DEBUG_MODULE$5, "assertPositiveFinite", "returned");
126
268
  };
127
269
  //#endregion
128
270
  //#region src/sensor/unified_info.ts
271
+ const DEBUG_MODULE$4 = "unified_info.ts";
129
272
  const unifiedSensorInfo = () => {
130
- return window.unifiedSensorInfo();
273
+ dialSdkDebugWarn(DEBUG_MODULE$4, "unifiedSensorInfo", "called");
274
+ try {
275
+ return window.unifiedSensorInfo().then((payload) => {
276
+ dialSdkDebugWarn(DEBUG_MODULE$4, "unifiedSensorInfo", "resolved", { payload });
277
+ return payload;
278
+ }, (error) => {
279
+ dialSdkDebugWarn(DEBUG_MODULE$4, "unifiedSensorInfo", "rejected", error);
280
+ throw error;
281
+ });
282
+ } catch (error) {
283
+ dialSdkDebugWarn(DEBUG_MODULE$4, "unifiedSensorInfo", "threw", error);
284
+ throw error;
285
+ }
131
286
  };
132
287
  //#endregion
133
288
  //#region src/sensor/constants.ts
@@ -172,6 +327,7 @@ const CAR_RUNNING_STATUS_PRIORITY = {
172
327
  };
173
328
  //#endregion
174
329
  //#region src/sensor/driving_expressions.ts
330
+ const DEBUG_MODULE$3 = "driving_expressions.ts";
175
331
  const OFFICIAL_DRIVING_EXPRESSION_FALLBACKS = Object.freeze({
176
332
  STOPPED: Object.freeze({
177
333
  kind: "emoji",
@@ -212,20 +368,32 @@ const OFFICIAL_DRIVING_EXPRESSIONS_CONFIG = Object.freeze({
212
368
  });
213
369
  var DrivingExpressionsConfigError = class extends Error {
214
370
  constructor(code, message, state) {
371
+ dialSdkDebugWarn(DEBUG_MODULE$3, "DrivingExpressionsConfigError.constructor", "called", {
372
+ code,
373
+ message,
374
+ state
375
+ });
215
376
  super(message);
216
377
  this.name = "DrivingExpressionsConfigError";
217
378
  this.code = code;
218
379
  this.state = state;
380
+ dialSdkDebugWarn(DEBUG_MODULE$3, "DrivingExpressionsConfigError.constructor", "created", { error: this });
219
381
  }
220
382
  };
221
383
  var DrivingExpressionResolutionError = class extends Error {
222
384
  constructor(status) {
385
+ dialSdkDebugWarn(DEBUG_MODULE$3, "DrivingExpressionResolutionError.constructor", "called", { status });
223
386
  super(`No driving expression is configured for ${status}`);
224
387
  this.name = "DrivingExpressionResolutionError";
225
388
  this.status = status;
389
+ dialSdkDebugWarn(DEBUG_MODULE$3, "DrivingExpressionResolutionError.constructor", "created", { error: this });
226
390
  }
227
391
  };
228
392
  const parseDrivingExpressionsConfig = (raw, options = {}) => {
393
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionsConfig", "called", {
394
+ raw,
395
+ options
396
+ });
229
397
  const parsed = parseJsonObject(raw);
230
398
  if (parsed.schemaVersion !== 1 || !isRecord$1(parsed.states)) throw new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions must use schemaVersion 1 and contain a states object");
231
399
  const knownStatuses = new Set(CAR_RUNNING_STATUSES);
@@ -236,15 +404,24 @@ const parseDrivingExpressionsConfig = (raw, options = {}) => {
236
404
  if (!Object.prototype.hasOwnProperty.call(parsed.states, status)) throw new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INCOMPLETE", `drivingExpressions.states is missing ${status}`, status);
237
405
  states[status] = parseDrivingExpressionMedia(parsed.states[status], status, options);
238
406
  }
239
- return {
407
+ const result = {
240
408
  schemaVersion: 1,
241
409
  states
242
410
  };
411
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionsConfig", "returned", { result });
412
+ return result;
243
413
  };
244
414
  const tryParseDrivingExpressionsConfig = (raw, options) => {
415
+ dialSdkDebugWarn(DEBUG_MODULE$3, "tryParseDrivingExpressionsConfig", "called", {
416
+ raw,
417
+ options
418
+ });
245
419
  try {
246
- return parseDrivingExpressionsConfig(raw, options);
247
- } catch {
420
+ const result = parseDrivingExpressionsConfig(raw, options);
421
+ dialSdkDebugWarn(DEBUG_MODULE$3, "tryParseDrivingExpressionsConfig", "returned", { result });
422
+ return result;
423
+ } catch (error) {
424
+ dialSdkDebugWarn(DEBUG_MODULE$3, "tryParseDrivingExpressionsConfig", "returned null after parse error", error);
248
425
  return null;
249
426
  }
250
427
  };
@@ -253,14 +430,24 @@ const tryParseDrivingExpressionsConfig = (raw, options) => {
253
430
  * It never installs official fallbacks implicitly.
254
431
  */
255
432
  const readDrivingExpressionsConfig = (raw, options) => {
433
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readDrivingExpressionsConfig", "called", {
434
+ raw,
435
+ options
436
+ });
256
437
  const source = raw === void 0 ? readRuntimeDrivingExpressionsValue() : raw;
257
- return source === void 0 ? null : tryParseDrivingExpressionsConfig(source, options);
438
+ const result = source === void 0 ? null : tryParseDrivingExpressionsConfig(source, options);
439
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readDrivingExpressionsConfig", "returned", {
440
+ source,
441
+ result
442
+ });
443
+ return result;
258
444
  };
259
445
  /**
260
446
  * Waits for a valid Runtime-injected configuration using bounded polling.
261
447
  * It never installs official fallbacks implicitly.
262
448
  */
263
449
  const waitForDrivingExpressionsConfig = (options = {}) => {
450
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig", "called", { options });
264
451
  const timeoutMs = requireNonNegativeFinite("timeoutMs", options.timeoutMs ?? 3e3);
265
452
  const pollIntervalMs = requirePositiveFinite$1("pollIntervalMs", options.pollIntervalMs ?? 100);
266
453
  const { signal } = options;
@@ -269,30 +456,61 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
269
456
  let timer;
270
457
  let settled = false;
271
458
  const cleanup = () => {
459
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.cleanup", "called", {
460
+ timer,
461
+ settled
462
+ });
272
463
  if (timer !== void 0) {
273
464
  globalThis.clearTimeout(timer);
274
465
  timer = void 0;
275
466
  }
276
467
  signal?.removeEventListener("abort", handleAbort);
468
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.cleanup", "returned");
277
469
  };
278
470
  const finish = (config) => {
279
- if (settled) return;
471
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.finish", "called", {
472
+ config,
473
+ settled
474
+ });
475
+ if (settled) {
476
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.finish", "ignored");
477
+ return;
478
+ }
280
479
  settled = true;
281
480
  cleanup();
282
481
  resolve(config);
482
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.finish", "resolved", { config });
283
483
  };
284
484
  const fail = (error) => {
285
- if (settled) return;
485
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.fail", "called", {
486
+ error,
487
+ settled
488
+ });
489
+ if (settled) {
490
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.fail", "ignored");
491
+ return;
492
+ }
286
493
  settled = true;
287
494
  cleanup();
288
495
  reject(error);
496
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.fail", "rejected", error);
289
497
  };
290
498
  const handleAbort = () => {
499
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.handleAbort", "called");
291
500
  fail(createAbortError$1());
292
501
  };
293
- const read = () => readDrivingExpressionsConfig(void 0, options.parseOptions);
502
+ const read = () => {
503
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.read", "called");
504
+ const result = readDrivingExpressionsConfig(void 0, options.parseOptions);
505
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.read", "returned", { result });
506
+ return result;
507
+ };
294
508
  const poll = () => {
295
- if (settled) return;
509
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.poll", "called", { settled });
510
+ if (settled) {
511
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.poll", "ignored");
512
+ return;
513
+ }
296
514
  if (signal?.aborted) {
297
515
  handleAbort();
298
516
  return;
@@ -308,41 +526,125 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
308
526
  return;
309
527
  }
310
528
  timer = globalThis.setTimeout(poll, Math.min(pollIntervalMs, remainingMs));
529
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.poll", "scheduled", {
530
+ remainingMs,
531
+ delayMs: Math.min(pollIntervalMs, remainingMs)
532
+ });
311
533
  };
312
534
  signal?.addEventListener("abort", handleAbort, { once: true });
313
535
  poll();
314
536
  });
315
537
  };
316
538
  /** Original resolver behavior: missing legacy slots fall back to STEADY_DRIVING. */
317
- const resolveDrivingExpression = (config, status) => config.states[status] ?? config.states.STEADY_DRIVING;
539
+ const resolveDrivingExpression = (config, status) => {
540
+ const result = config.states[status] ?? config.states.STEADY_DRIVING;
541
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpression", "returned", {
542
+ config,
543
+ status,
544
+ result
545
+ });
546
+ return result;
547
+ };
318
548
  /** Strict resolver used by the player; official fallbacks are opt-in. */
319
549
  const resolveDrivingExpressionStrict = (config, status, fallbacks) => {
550
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpressionStrict", "called", {
551
+ config,
552
+ status,
553
+ fallbacks
554
+ });
320
555
  const configured = config.states[status];
321
- if (configured !== void 0) return configured;
556
+ if (configured !== void 0) {
557
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpressionStrict", "returned configured media", { configured });
558
+ return configured;
559
+ }
322
560
  const fallback = fallbacks?.[status];
323
- if (fallback !== void 0) return fallback;
324
- throw new DrivingExpressionResolutionError(status);
561
+ if (fallback !== void 0) {
562
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpressionStrict", "returned fallback media", { fallback });
563
+ return fallback;
564
+ }
565
+ const error = new DrivingExpressionResolutionError(status);
566
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpressionStrict", "threw", error);
567
+ throw error;
325
568
  };
326
569
  const isPublicDrivingMediaUrl = (value) => {
570
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "called", { value });
327
571
  try {
328
572
  const url = new URL(value);
329
- if (url.protocol !== "https:" || url.username !== "" || url.password !== "") return false;
330
- if (!isPublicHostname(url.hostname)) return false;
331
- for (const key of url.searchParams.keys()) if (TEMPORARY_SIGNATURE_QUERY_KEYS.has(key.toLowerCase())) return false;
573
+ if (url.protocol !== "https:" || url.username !== "" || url.password !== "") {
574
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned", {
575
+ result: false,
576
+ reason: "protocol_or_auth"
577
+ });
578
+ return false;
579
+ }
580
+ if (!isPublicHostname(url.hostname)) {
581
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned", {
582
+ result: false,
583
+ reason: "hostname"
584
+ });
585
+ return false;
586
+ }
587
+ for (const key of url.searchParams.keys()) if (TEMPORARY_SIGNATURE_QUERY_KEYS.has(key.toLowerCase())) {
588
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned", {
589
+ result: false,
590
+ reason: "temporary_signature",
591
+ key
592
+ });
593
+ return false;
594
+ }
595
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned", { result: true });
332
596
  return true;
333
- } catch {
597
+ } catch (error) {
598
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned after URL parse error", {
599
+ result: false,
600
+ error
601
+ });
334
602
  return false;
335
603
  }
336
604
  };
337
605
  const isPublicHostname = (rawHostname) => {
606
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "called", { rawHostname });
338
607
  const hostname = rawHostname.toLowerCase().replace(/^\[|\]$/gu, "").replace(/\.+$/gu, "");
339
- if (hostname === "") return false;
608
+ if (hostname === "") {
609
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned", {
610
+ result: false,
611
+ hostname
612
+ });
613
+ return false;
614
+ }
340
615
  const ipv4 = parseIpv4(hostname);
341
- if (ipv4 !== null) return !isRestrictedIpv4(ipv4);
616
+ if (ipv4 !== null) {
617
+ const result = !isRestrictedIpv4(ipv4);
618
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned IPv4 result", {
619
+ hostname,
620
+ ipv4,
621
+ result
622
+ });
623
+ return result;
624
+ }
342
625
  const ipv6 = parseIpv6(hostname);
343
- if (ipv6 !== null) return !isRestrictedIpv6(ipv6);
344
- if (!hostname.includes(".")) return false;
345
- return !INTERNAL_HOST_SUFFIXES.some((suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`));
626
+ if (ipv6 !== null) {
627
+ const result = !isRestrictedIpv6(ipv6);
628
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned IPv6 result", {
629
+ hostname,
630
+ ipv6,
631
+ result
632
+ });
633
+ return result;
634
+ }
635
+ if (!hostname.includes(".")) {
636
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned", {
637
+ hostname,
638
+ result: false
639
+ });
640
+ return false;
641
+ }
642
+ const result = !INTERNAL_HOST_SUFFIXES.some((suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`));
643
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned DNS result", {
644
+ hostname,
645
+ result
646
+ });
647
+ return result;
346
648
  };
347
649
  const INTERNAL_HOST_SUFFIXES = [
348
650
  "corp",
@@ -357,57 +659,108 @@ const INTERNAL_HOST_SUFFIXES = [
357
659
  "private"
358
660
  ];
359
661
  const parseIpv4 = (hostname) => {
662
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv4", "called", { hostname });
360
663
  const parts = hostname.split(".");
361
- if (parts.length !== 4 || parts.some((part) => !/^\d{1,3}$/u.test(part))) return null;
664
+ if (parts.length !== 4 || parts.some((part) => !/^\d{1,3}$/u.test(part))) {
665
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv4", "returned", { result: null });
666
+ return null;
667
+ }
362
668
  const octets = parts.map(Number);
363
- if (octets.some((octet) => octet > 255)) return null;
364
- return octets;
669
+ if (octets.some((octet) => octet > 255)) {
670
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv4", "returned", {
671
+ result: null,
672
+ octets
673
+ });
674
+ return null;
675
+ }
676
+ const result = octets;
677
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv4", "returned", { result });
678
+ return result;
679
+ };
680
+ const isRestrictedIpv4 = (value) => {
681
+ const [a, b, c] = value;
682
+ const result = a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 0 && c === 2 || a === 192 && b === 31 && c === 196 || a === 192 && b === 52 && c === 193 || a === 192 && b === 88 && c === 99 || a === 192 && b === 168 || a === 192 && b === 175 && c === 48 || a === 198 && (b === 18 || b === 19) || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113 || a >= 224;
683
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isRestrictedIpv4", "returned", {
684
+ value,
685
+ result
686
+ });
687
+ return result;
365
688
  };
366
- const isRestrictedIpv4 = ([a, b, c]) => a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 0 && c === 2 || a === 192 && b === 31 && c === 196 || a === 192 && b === 52 && c === 193 || a === 192 && b === 88 && c === 99 || a === 192 && b === 168 || a === 192 && b === 175 && c === 48 || a === 198 && (b === 18 || b === 19) || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113 || a >= 224;
367
689
  const parseIpv6 = (hostname) => {
368
- if (!hostname.includes(":")) return null;
690
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "called", { hostname });
691
+ if (!hostname.includes(":")) {
692
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned", { result: null });
693
+ return null;
694
+ }
369
695
  let normalized = hostname;
370
696
  if (normalized.includes(".")) {
371
697
  const lastColon = normalized.lastIndexOf(":");
372
698
  const ipv4 = parseIpv4(normalized.slice(lastColon + 1));
373
- if (ipv4 === null) return null;
699
+ if (ipv4 === null) {
700
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned invalid embedded IPv4", { result: null });
701
+ return null;
702
+ }
374
703
  normalized = `${normalized.slice(0, lastColon)}:${(ipv4[0] << 8 | ipv4[1]).toString(16)}:${(ipv4[2] << 8 | ipv4[3]).toString(16)}`;
375
704
  }
376
705
  const halves = normalized.split("::");
377
- if (halves.length > 2) return null;
706
+ if (halves.length > 2) {
707
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned invalid halves", {
708
+ result: null,
709
+ halves
710
+ });
711
+ return null;
712
+ }
378
713
  const left = halves[0] === "" ? [] : halves[0].split(":");
379
714
  const right = halves.length === 1 || halves[1] === "" ? [] : halves[1].split(":");
380
- if ([...left, ...right].some((part) => !/^[\da-f]{1,4}$/u.test(part))) return null;
715
+ if ([...left, ...right].some((part) => !/^[\da-f]{1,4}$/u.test(part))) {
716
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned invalid group", {
717
+ result: null,
718
+ left,
719
+ right
720
+ });
721
+ return null;
722
+ }
381
723
  const omitted = 8 - left.length - right.length;
382
- if (halves.length === 1 && omitted !== 0 || halves.length === 2 && omitted < 1) return null;
724
+ if (halves.length === 1 && omitted !== 0 || halves.length === 2 && omitted < 1) {
725
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned invalid omission", {
726
+ result: null,
727
+ omitted
728
+ });
729
+ return null;
730
+ }
383
731
  const groups = [
384
732
  ...left,
385
733
  ...Array.from({ length: omitted }, () => "0"),
386
734
  ...right
387
735
  ].map((part) => Number.parseInt(part, 16));
388
- if (groups.length !== 8) return null;
736
+ if (groups.length !== 8) {
737
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned invalid group count", {
738
+ result: null,
739
+ groups
740
+ });
741
+ return null;
742
+ }
389
743
  const bytes = /* @__PURE__ */ new Uint8Array(16);
390
744
  groups.forEach((group, index) => {
391
745
  bytes[index * 2] = group >>> 8;
392
746
  bytes[index * 2 + 1] = group & 255;
393
747
  });
748
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned", { result: bytes });
394
749
  return bytes;
395
750
  };
396
751
  const isRestrictedIpv6 = (bytes) => {
397
- const allZeroPrefix = (length) => bytes.subarray(0, length).every((value) => value === 0);
398
- if (bytes.every((value) => value === 0)) return true;
399
- if (allZeroPrefix(15) && bytes[15] === 1) return true;
400
- if (allZeroPrefix(12)) return true;
401
- if (allZeroPrefix(10) && bytes[10] === 255 && bytes[11] === 255) return true;
402
- if (bytes[0] === 0 && bytes[1] === 100 && bytes[2] === 255 && bytes[3] === 155) return true;
403
- if ((bytes[0] & 254) === 252) return true;
404
- if (bytes[0] === 254 && (bytes[1] & 192) === 128) return true;
405
- if (bytes[0] === 255) return true;
406
- if (bytes[0] === 1 && bytes.subarray(1, 8).every((value) => value === 0)) return true;
407
- if (bytes[0] === 32 && bytes[1] === 1 && bytes[2] === 13 && bytes[3] === 184) return true;
408
- if (bytes[0] === 32 && bytes[1] === 1 && bytes[2] <= 1) return true;
409
- if (bytes[0] === 32 && bytes[1] === 2) return true;
410
- return bytes[0] === 63 && bytes[1] === 254;
752
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isRestrictedIpv6", "called", { bytes });
753
+ const allZeroPrefix = (length) => {
754
+ const result = bytes.subarray(0, length).every((value) => value === 0);
755
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isRestrictedIpv6.allZeroPrefix", "returned", {
756
+ length,
757
+ result
758
+ });
759
+ return result;
760
+ };
761
+ const result = bytes.every((value) => value === 0) || allZeroPrefix(15) && bytes[15] === 1 || allZeroPrefix(12) || allZeroPrefix(10) && bytes[10] === 255 && bytes[11] === 255 || bytes[0] === 0 && bytes[1] === 100 && bytes[2] === 255 && bytes[3] === 155 || (bytes[0] & 254) === 252 || bytes[0] === 254 && (bytes[1] & 192) === 128 || bytes[0] === 255 || bytes[0] === 1 && bytes.subarray(1, 8).every((value) => value === 0) || bytes[0] === 32 && bytes[1] === 1 && bytes[2] === 13 && bytes[3] === 184 || bytes[0] === 32 && bytes[1] === 1 && bytes[2] <= 1 || bytes[0] === 32 && bytes[1] === 2 || bytes[0] === 63 && bytes[1] === 254;
762
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isRestrictedIpv6", "returned", { result });
763
+ return result;
411
764
  };
412
765
  const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
413
766
  "expires",
@@ -443,12 +796,19 @@ const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
443
796
  "x-oss-signature"
444
797
  ]);
445
798
  const parseDrivingExpressionMedia = (raw, status, options) => {
799
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "called", {
800
+ raw,
801
+ status,
802
+ options
803
+ });
446
804
  if (typeof raw === "string" && options.allowLegacyImageUrls) {
447
805
  assertPublicUrl(raw, status, "url");
448
- return {
806
+ const result = {
449
807
  kind: "image",
450
808
  url: raw
451
809
  };
810
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned legacy image", { result });
811
+ return result;
452
812
  }
453
813
  if (!isRecord$1(raw) || typeof raw.kind !== "string") throw invalidMedia(status, "media must be a structured object with a supported kind");
454
814
  const mediaAssetId = parseMediaAssetId(raw.mediaAssetId, status);
@@ -458,7 +818,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
458
818
  "duration"
459
819
  ]);
460
820
  switch (raw.kind) {
461
- case "emoji":
821
+ case "emoji": {
462
822
  assertFieldsAbsent(raw, status, [
463
823
  "mediaAssetId",
464
824
  "url",
@@ -467,10 +827,13 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
467
827
  "mimeType"
468
828
  ]);
469
829
  if (typeof raw.text !== "string" || !isOneVisibleGrapheme(raw.text)) throw invalidMedia(status, "emoji.text must contain exactly one visible grapheme");
470
- return {
830
+ const result = {
471
831
  kind: "emoji",
472
832
  text: raw.text.trim()
473
833
  };
834
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned emoji", { result });
835
+ return result;
836
+ }
474
837
  case "image": {
475
838
  assertFieldsAbsent(raw, status, [
476
839
  "text",
@@ -479,25 +842,29 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
479
842
  ]);
480
843
  const url = parseRequiredUrl(raw.url, status, "url");
481
844
  const mimeType = parseOptionalString(raw.mimeType, status, "mimeType");
482
- return compact({
845
+ const result = compact({
483
846
  kind: "image",
484
847
  mediaAssetId,
485
848
  url,
486
849
  mimeType
487
850
  });
851
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned image", { result });
852
+ return result;
488
853
  }
489
854
  case "video": {
490
855
  assertFieldsAbsent(raw, status, ["text", "motionUrl"]);
491
856
  const url = parseRequiredUrl(raw.url, status, "url");
492
857
  const coverUrl = parseOptionalUrl(raw.coverUrl, status, "coverUrl");
493
858
  const mimeType = parseOptionalString(raw.mimeType, status, "mimeType");
494
- return compact({
859
+ const result = compact({
495
860
  kind: "video",
496
861
  mediaAssetId,
497
862
  url,
498
863
  coverUrl,
499
864
  mimeType
500
865
  });
866
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned video", { result });
867
+ return result;
501
868
  }
502
869
  case "live_photo": {
503
870
  assertFieldsAbsent(raw, status, [
@@ -507,12 +874,14 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
507
874
  ]);
508
875
  const coverUrl = parseRequiredUrl(raw.coverUrl, status, "coverUrl");
509
876
  const motionUrl = parseRequiredUrl(raw.motionUrl, status, "motionUrl");
510
- return compact({
877
+ const result = compact({
511
878
  kind: "live_photo",
512
879
  mediaAssetId,
513
880
  coverUrl,
514
881
  motionUrl
515
882
  });
883
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned live photo", { result });
884
+ return result;
516
885
  }
517
886
  case "tgs": {
518
887
  assertFieldsAbsent(raw, status, [
@@ -522,88 +891,228 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
522
891
  ]);
523
892
  const url = parseRequiredUrl(raw.url, status, "url");
524
893
  const coverUrl = parseOptionalUrl(raw.coverUrl, status, "coverUrl");
525
- return compact({
894
+ const result = compact({
526
895
  kind: "tgs",
527
896
  mediaAssetId,
528
897
  url,
529
898
  coverUrl
530
899
  });
900
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned TGS", { result });
901
+ return result;
531
902
  }
532
903
  default: throw invalidMedia(status, `unsupported media kind: ${raw.kind}`);
533
904
  }
534
905
  };
535
906
  const parseJsonObject = (raw) => {
907
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseJsonObject", "called", { raw });
536
908
  let value = raw;
537
909
  if (typeof value === "string") try {
538
910
  value = JSON.parse(value);
539
- } catch {
540
- throw new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions is not valid JSON");
911
+ } catch (cause) {
912
+ const error = new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions is not valid JSON");
913
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseJsonObject", "threw", {
914
+ error,
915
+ cause
916
+ });
917
+ throw error;
541
918
  }
542
- if (!isRecord$1(value)) throw new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions must be a JSON object or JSON object string");
919
+ if (!isRecord$1(value)) {
920
+ const error = new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions must be a JSON object or JSON object string");
921
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseJsonObject", "threw", error);
922
+ throw error;
923
+ }
924
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseJsonObject", "returned", { value });
543
925
  return value;
544
926
  };
545
927
  const readRuntimeDrivingExpressionsValue = () => {
928
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "called");
546
929
  const runtimeGlobal = globalThis;
547
- if (runtimeGlobal.__TOOOONY_DRIVING_EXPRESSIONS__ !== void 0) return runtimeGlobal.__TOOOONY_DRIVING_EXPRESSIONS__;
930
+ if (runtimeGlobal.__TOOOONY_DRIVING_EXPRESSIONS__ !== void 0) {
931
+ const result = runtimeGlobal.__TOOOONY_DRIVING_EXPRESSIONS__;
932
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "returned typed injection", { result });
933
+ return result;
934
+ }
548
935
  const faceConfig = runtimeGlobal.__TOOOONY_FACE_CONFIG__;
549
- if (!isRecord$1(faceConfig)) return void 0;
550
- if (faceConfig.drivingExpressions !== void 0) return faceConfig.drivingExpressions;
551
- return isRecord$1(faceConfig.values) ? faceConfig.values.drivingExpressions : void 0;
936
+ if (!isRecord$1(faceConfig)) {
937
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "returned", { result: void 0 });
938
+ return;
939
+ }
940
+ if (faceConfig.drivingExpressions !== void 0) {
941
+ const result = faceConfig.drivingExpressions;
942
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "returned face config", { result });
943
+ return result;
944
+ }
945
+ const result = isRecord$1(faceConfig.values) ? faceConfig.values.drivingExpressions : void 0;
946
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "returned legacy face config", { result });
947
+ return result;
552
948
  };
553
949
  const parseMediaAssetId = (raw, status) => {
554
- if (raw === void 0) return void 0;
950
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseMediaAssetId", "called", {
951
+ raw,
952
+ status
953
+ });
954
+ if (raw === void 0) {
955
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseMediaAssetId", "returned", { result: void 0 });
956
+ return;
957
+ }
555
958
  if (!Number.isSafeInteger(raw) || raw <= 0) throw invalidMedia(status, "mediaAssetId must be a positive safe integer when present");
556
- return raw;
959
+ const result = raw;
960
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseMediaAssetId", "returned", { result });
961
+ return result;
557
962
  };
558
963
  const assertFieldsAbsent = (value, status, fields) => {
964
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertFieldsAbsent", "called", {
965
+ value,
966
+ status,
967
+ fields
968
+ });
559
969
  const present = fields.find((field) => Object.prototype.hasOwnProperty.call(value, field));
560
- if (present !== void 0) throw invalidMedia(status, `${present} is not allowed for this media kind`);
970
+ if (present !== void 0) {
971
+ const error = invalidMedia(status, `${present} is not allowed for this media kind`);
972
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertFieldsAbsent", "threw", error);
973
+ throw error;
974
+ }
975
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertFieldsAbsent", "returned");
561
976
  };
562
977
  const parseRequiredUrl = (raw, status, field) => {
563
- if (typeof raw !== "string" || raw.length === 0) throw invalidMedia(status, `${field} is required`);
978
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseRequiredUrl", "called", {
979
+ raw,
980
+ status,
981
+ field
982
+ });
983
+ if (typeof raw !== "string" || raw.length === 0) {
984
+ const error = invalidMedia(status, `${field} is required`);
985
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseRequiredUrl", "threw", error);
986
+ throw error;
987
+ }
564
988
  assertPublicUrl(raw, status, field);
989
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseRequiredUrl", "returned", { result: raw });
565
990
  return raw;
566
991
  };
567
992
  const parseOptionalUrl = (raw, status, field) => {
568
- if (raw === void 0) return void 0;
569
- return parseRequiredUrl(raw, status, field);
993
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalUrl", "called", {
994
+ raw,
995
+ status,
996
+ field
997
+ });
998
+ if (raw === void 0) {
999
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalUrl", "returned", { result: void 0 });
1000
+ return;
1001
+ }
1002
+ const result = parseRequiredUrl(raw, status, field);
1003
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalUrl", "returned", { result });
1004
+ return result;
570
1005
  };
571
1006
  const parseOptionalString = (raw, status, field) => {
572
- if (raw === void 0) return void 0;
1007
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalString", "called", {
1008
+ raw,
1009
+ status,
1010
+ field
1011
+ });
1012
+ if (raw === void 0) {
1013
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalString", "returned", { result: void 0 });
1014
+ return;
1015
+ }
573
1016
  if (typeof raw !== "string" || raw.trim() === "" || raw.length > 255) throw invalidMedia(status, `${field} must be a non-empty string of at most 255 characters`);
1017
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseOptionalString", "returned", { result: raw });
574
1018
  return raw;
575
1019
  };
576
1020
  const assertPublicUrl = (value, status, field) => {
577
- if (!isPublicDrivingMediaUrl(value)) throw new DrivingExpressionsConfigError("MEDIA_URL_NOT_PUBLIC_HTTPS", `${status}.${field} must be a long-lived public HTTPS URL`, status);
1021
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertPublicUrl", "called", {
1022
+ value,
1023
+ status,
1024
+ field
1025
+ });
1026
+ if (!isPublicDrivingMediaUrl(value)) {
1027
+ const error = new DrivingExpressionsConfigError("MEDIA_URL_NOT_PUBLIC_HTTPS", `${status}.${field} must be a long-lived public HTTPS URL`, status);
1028
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertPublicUrl", "threw", error);
1029
+ throw error;
1030
+ }
1031
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertPublicUrl", "returned");
578
1032
  };
579
1033
  const isOneVisibleGrapheme = (value) => {
1034
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isOneVisibleGrapheme", "called", { value });
580
1035
  const trimmed = value.trim();
581
- if (trimmed === "" || trimmed.length > 32) return false;
1036
+ if (trimmed === "" || trimmed.length > 32) {
1037
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isOneVisibleGrapheme", "returned", {
1038
+ result: false,
1039
+ trimmed
1040
+ });
1041
+ return false;
1042
+ }
582
1043
  const Segmenter = Intl.Segmenter;
583
- return (Segmenter ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(trimmed)) : Array.from(trimmed)).length === 1;
1044
+ const graphemes = Segmenter ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(trimmed)) : Array.from(trimmed);
1045
+ const result = graphemes.length === 1;
1046
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isOneVisibleGrapheme", "returned", {
1047
+ graphemes,
1048
+ result
1049
+ });
1050
+ return result;
1051
+ };
1052
+ const invalidMedia = (status, detail) => {
1053
+ const result = new DrivingExpressionsConfigError("DRIVING_EXPRESSION_INVALID_MEDIA", `Invalid driving expression for ${status}: ${detail}`, status);
1054
+ dialSdkDebugWarn(DEBUG_MODULE$3, "invalidMedia", "returned", {
1055
+ status,
1056
+ detail,
1057
+ result
1058
+ });
1059
+ return result;
584
1060
  };
585
- const invalidMedia = (status, detail) => new DrivingExpressionsConfigError("DRIVING_EXPRESSION_INVALID_MEDIA", `Invalid driving expression for ${status}: ${detail}`, status);
586
1061
  const compact = (value) => {
1062
+ dialSdkDebugWarn(DEBUG_MODULE$3, "compact", "called", { value });
587
1063
  for (const key of Object.keys(value)) if (value[key] === void 0) delete value[key];
1064
+ dialSdkDebugWarn(DEBUG_MODULE$3, "compact", "returned", { result: value });
588
1065
  return value;
589
1066
  };
590
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1067
+ const isRecord$1 = (value) => {
1068
+ const result = typeof value === "object" && value !== null && !Array.isArray(value);
1069
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isRecord", "returned", {
1070
+ value,
1071
+ result
1072
+ });
1073
+ return result;
1074
+ };
591
1075
  const requireNonNegativeFinite = (name, value) => {
592
- if (!Number.isFinite(value) || value < 0) throw new RangeError(`${name} must be a non-negative finite number`);
1076
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requireNonNegativeFinite", "called", {
1077
+ name,
1078
+ value
1079
+ });
1080
+ if (!Number.isFinite(value) || value < 0) {
1081
+ const error = /* @__PURE__ */ new RangeError(`${name} must be a non-negative finite number`);
1082
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requireNonNegativeFinite", "threw", error);
1083
+ throw error;
1084
+ }
1085
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requireNonNegativeFinite", "returned", { result: value });
593
1086
  return value;
594
1087
  };
595
1088
  const requirePositiveFinite$1 = (name, value) => {
596
- if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be a positive finite number`);
1089
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requirePositiveFinite", "called", {
1090
+ name,
1091
+ value
1092
+ });
1093
+ if (!Number.isFinite(value) || value <= 0) {
1094
+ const error = /* @__PURE__ */ new RangeError(`${name} must be a positive finite number`);
1095
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requirePositiveFinite", "threw", error);
1096
+ throw error;
1097
+ }
1098
+ dialSdkDebugWarn(DEBUG_MODULE$3, "requirePositiveFinite", "returned", { result: value });
597
1099
  return value;
598
1100
  };
599
1101
  const createAbortError$1 = () => {
600
- if (typeof DOMException === "function") return new DOMException("The operation was aborted", "AbortError");
1102
+ dialSdkDebugWarn(DEBUG_MODULE$3, "createAbortError", "called");
1103
+ if (typeof DOMException === "function") {
1104
+ const result = new DOMException("The operation was aborted", "AbortError");
1105
+ dialSdkDebugWarn(DEBUG_MODULE$3, "createAbortError", "returned DOMException", { result });
1106
+ return result;
1107
+ }
601
1108
  const error = /* @__PURE__ */ new Error("The operation was aborted");
602
1109
  error.name = "AbortError";
1110
+ dialSdkDebugWarn(DEBUG_MODULE$3, "createAbortError", "returned Error", { result: error });
603
1111
  return error;
604
1112
  };
605
1113
  //#endregion
606
1114
  //#region src/sensor/page_lifecycle.ts
1115
+ const DEBUG_MODULE$2 = "page_lifecycle.ts";
607
1116
  const subscribers = /* @__PURE__ */ new Set();
608
1117
  let installedWindow = null;
609
1118
  let installedDocument = null;
@@ -614,6 +1123,7 @@ let hadOwnResumeHook = false;
614
1123
  let pauseHook = null;
615
1124
  let resumeHook = null;
616
1125
  const subscribeDrivingPageLifecycle = (pause, resume) => {
1126
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle", "called", { subscriberCount: subscribers.size });
617
1127
  const subscriber = {
618
1128
  pause,
619
1129
  resume
@@ -622,15 +1132,29 @@ const subscribeDrivingPageLifecycle = (pause, resume) => {
622
1132
  if (subscribers.size === 1) installLifecycleHooks();
623
1133
  if (isDrivingPageHidden()) safeInvoke(pause);
624
1134
  let subscribed = true;
1135
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle", "subscribed", { subscriberCount: subscribers.size });
625
1136
  return () => {
626
- if (!subscribed) return;
1137
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle.unsubscribe", "called", { subscribed });
1138
+ if (!subscribed) {
1139
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle.unsubscribe", "ignored");
1140
+ return;
1141
+ }
627
1142
  subscribed = false;
628
1143
  subscribers.delete(subscriber);
629
1144
  if (subscribers.size === 0) uninstallLifecycleHooks();
1145
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle.unsubscribe", "returned", { subscriberCount: subscribers.size });
630
1146
  };
631
1147
  };
632
- const isDrivingPageHidden = () => typeof document !== "undefined" && document.visibilityState === "hidden";
1148
+ const isDrivingPageHidden = () => {
1149
+ const result = typeof document !== "undefined" && document.visibilityState === "hidden";
1150
+ dialSdkDebugWarn(DEBUG_MODULE$2, "isDrivingPageHidden", "returned", {
1151
+ visibilityState: typeof document === "undefined" ? void 0 : document.visibilityState,
1152
+ result
1153
+ });
1154
+ return result;
1155
+ };
633
1156
  const installLifecycleHooks = () => {
1157
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "called");
634
1158
  installedDocument = typeof document === "undefined" ? null : document;
635
1159
  installedWindow = typeof window === "undefined" ? null : window;
636
1160
  installedDocument?.addEventListener("visibilitychange", handleVisibilityChange);
@@ -640,29 +1164,43 @@ const installLifecycleHooks = () => {
640
1164
  installedWindow?.addEventListener("resume", dispatchResume);
641
1165
  installedWindow?.addEventListener("toooony-device-sensors-release", dispatchPause);
642
1166
  installedWindow?.addEventListener("toooony-device-sensors-resume", dispatchResume);
643
- if (!installedWindow) return;
1167
+ if (!installedWindow) {
1168
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "returned without window");
1169
+ return;
1170
+ }
644
1171
  hadOwnPauseHook = Object.prototype.hasOwnProperty.call(installedWindow, "__watchFaceRuntimePause");
645
1172
  hadOwnResumeHook = Object.prototype.hasOwnProperty.call(installedWindow, "__watchFaceRuntimeResume");
646
1173
  previousPauseHook = installedWindow.__watchFaceRuntimePause;
647
1174
  previousResumeHook = installedWindow.__watchFaceRuntimeResume;
648
1175
  pauseHook = function(...args) {
1176
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimePauseHook", "called", { args });
649
1177
  try {
650
- return typeof previousPauseHook === "function" ? previousPauseHook.apply(this, args) : void 0;
1178
+ const result = typeof previousPauseHook === "function" ? previousPauseHook.apply(this, args) : void 0;
1179
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimePauseHook", "returned", { result });
1180
+ return result;
651
1181
  } finally {
652
1182
  dispatchPause();
653
1183
  }
654
1184
  };
655
1185
  resumeHook = function(...args) {
1186
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimeResumeHook", "called", { args });
656
1187
  try {
657
- return typeof previousResumeHook === "function" ? previousResumeHook.apply(this, args) : void 0;
1188
+ const result = typeof previousResumeHook === "function" ? previousResumeHook.apply(this, args) : void 0;
1189
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimeResumeHook", "returned", { result });
1190
+ return result;
658
1191
  } finally {
659
1192
  dispatchResume();
660
1193
  }
661
1194
  };
662
1195
  installedWindow.__watchFaceRuntimePause = pauseHook;
663
1196
  installedWindow.__watchFaceRuntimeResume = resumeHook;
1197
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "returned", {
1198
+ hadOwnPauseHook,
1199
+ hadOwnResumeHook
1200
+ });
664
1201
  };
665
1202
  const uninstallLifecycleHooks = () => {
1203
+ dialSdkDebugWarn(DEBUG_MODULE$2, "uninstallLifecycleHooks", "called");
666
1204
  installedDocument?.removeEventListener("visibilitychange", handleVisibilityChange);
667
1205
  installedWindow?.removeEventListener("pagehide", dispatchPause);
668
1206
  installedWindow?.removeEventListener("freeze", dispatchPause);
@@ -682,26 +1220,46 @@ const uninstallLifecycleHooks = () => {
682
1220
  hadOwnResumeHook = false;
683
1221
  pauseHook = null;
684
1222
  resumeHook = null;
1223
+ dialSdkDebugWarn(DEBUG_MODULE$2, "uninstallLifecycleHooks", "returned");
685
1224
  };
686
1225
  const handleVisibilityChange = () => {
1226
+ dialSdkDebugWarn(DEBUG_MODULE$2, "handleVisibilityChange", "called");
687
1227
  if (isDrivingPageHidden()) dispatchPause();
688
1228
  else dispatchResume();
1229
+ dialSdkDebugWarn(DEBUG_MODULE$2, "handleVisibilityChange", "returned");
689
1230
  };
690
1231
  const dispatchPause = () => {
1232
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchPause", "called", { subscriberCount: subscribers.size });
691
1233
  for (const subscriber of [...subscribers]) safeInvoke(subscriber.pause);
1234
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchPause", "returned");
692
1235
  };
693
1236
  const dispatchResume = () => {
694
- if (isDrivingPageHidden()) return;
1237
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchResume", "called", { subscriberCount: subscribers.size });
1238
+ if (isDrivingPageHidden()) {
1239
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchResume", "ignored while hidden");
1240
+ return;
1241
+ }
695
1242
  for (const subscriber of [...subscribers]) safeInvoke(subscriber.resume);
1243
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchResume", "returned");
696
1244
  };
697
1245
  const safeInvoke = (callback) => {
1246
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "called");
698
1247
  try {
699
1248
  callback();
700
- } catch {}
1249
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "returned");
1250
+ } catch (error) {
1251
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "callback threw", error);
1252
+ }
701
1253
  };
702
1254
  //#endregion
703
1255
  //#region src/sensor/driving_status_controller.ts
704
- const createDrivingStatusController = (options = {}) => new DefaultDrivingStatusController(options);
1256
+ const DEBUG_MODULE$1 = "driving_status_controller.ts";
1257
+ const createDrivingStatusController = (options = {}) => {
1258
+ dialSdkDebugWarn(DEBUG_MODULE$1, "createDrivingStatusController", "called", { options });
1259
+ const result = new DefaultDrivingStatusController(options);
1260
+ dialSdkDebugWarn(DEBUG_MODULE$1, "createDrivingStatusController", "returned", { snapshot: result.getSnapshot() });
1261
+ return result;
1262
+ };
705
1263
  var DefaultDrivingStatusController = class {
706
1264
  constructor(options) {
707
1265
  this.listeners = /* @__PURE__ */ new Set();
@@ -721,16 +1279,34 @@ var DefaultDrivingStatusController = class {
721
1279
  this.pendingRead = null;
722
1280
  this.unsubscribePageLifecycle = null;
723
1281
  this.handleLifecyclePause = () => {
724
- if (!this.requestedRunning || this.lifecycleSuspended) return;
1282
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecyclePause", "called", {
1283
+ requestedRunning: this.requestedRunning,
1284
+ lifecycleSuspended: this.lifecycleSuspended
1285
+ });
1286
+ if (!this.requestedRunning || this.lifecycleSuspended) {
1287
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecyclePause", "ignored");
1288
+ return;
1289
+ }
725
1290
  this.lifecycleSuspended = true;
726
1291
  this.deactivatePolling();
727
1292
  this.resetTransientRecognition();
1293
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecyclePause", "returned");
728
1294
  };
729
1295
  this.handleLifecycleResume = () => {
730
- if (!this.requestedRunning || !this.lifecycleSuspended || this.destroyed || isDrivingPageHidden()) return;
1296
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecycleResume", "called", {
1297
+ requestedRunning: this.requestedRunning,
1298
+ lifecycleSuspended: this.lifecycleSuspended,
1299
+ destroyed: this.destroyed
1300
+ });
1301
+ if (!this.requestedRunning || !this.lifecycleSuspended || this.destroyed || isDrivingPageHidden()) {
1302
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecycleResume", "ignored");
1303
+ return;
1304
+ }
731
1305
  this.lifecycleSuspended = false;
732
1306
  this.activatePolling();
1307
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecycleResume", "returned");
733
1308
  };
1309
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.constructor", "called", { options });
734
1310
  this.sensorProvider = options.sensorProvider ?? defaultSensorProvider;
735
1311
  this.pollIntervalMs = requirePositiveFinite("pollIntervalMs", options.pollIntervalMs ?? 200);
736
1312
  this.unavailableFallbackMs = requirePositiveFinite("unavailableFallbackMs", options.unavailableFallbackMs ?? 3e3);
@@ -743,23 +1319,51 @@ var DefaultDrivingStatusController = class {
743
1319
  this.status = initialStatus;
744
1320
  this.baseStatus = isBaseStatus(initialStatus) ? initialStatus : "STOPPED";
745
1321
  this.statusCommittedAtMs = this.clock.now();
1322
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.constructor", "created", {
1323
+ initialStatus,
1324
+ baseStatus: this.baseStatus,
1325
+ pollIntervalMs: this.pollIntervalMs,
1326
+ unavailableFallbackMs: this.unavailableFallbackMs,
1327
+ tuning: this.tuning,
1328
+ managePageLifecycle: this.managePageLifecycle
1329
+ });
746
1330
  }
747
1331
  start() {
748
- if (this.destroyed || this.requestedRunning) return;
1332
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.start", "called", this.getSnapshot());
1333
+ if (this.destroyed || this.requestedRunning) {
1334
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.start", "ignored", {
1335
+ destroyed: this.destroyed,
1336
+ requestedRunning: this.requestedRunning
1337
+ });
1338
+ return;
1339
+ }
749
1340
  this.requestedRunning = true;
750
1341
  this.attachLifecycleListeners();
751
1342
  if (!this.lifecycleSuspended) this.activatePolling();
1343
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.start", "returned", this.getSnapshot());
752
1344
  }
753
1345
  stop() {
754
- if (this.destroyed || !this.requestedRunning) return;
1346
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.stop", "called", this.getSnapshot());
1347
+ if (this.destroyed || !this.requestedRunning) {
1348
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.stop", "ignored", {
1349
+ destroyed: this.destroyed,
1350
+ requestedRunning: this.requestedRunning
1351
+ });
1352
+ return;
1353
+ }
755
1354
  this.requestedRunning = false;
756
1355
  this.lifecycleSuspended = false;
757
1356
  this.detachLifecycleListeners();
758
1357
  this.deactivatePolling();
759
1358
  this.resetTransientRecognition();
1359
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.stop", "returned", this.getSnapshot());
760
1360
  }
761
1361
  destroy() {
762
- if (this.destroyed) return;
1362
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.destroy", "called", this.getSnapshot());
1363
+ if (this.destroyed) {
1364
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.destroy", "ignored");
1365
+ return;
1366
+ }
763
1367
  if (this.requestedRunning) this.stop();
764
1368
  else {
765
1369
  this.detachLifecycleListeners();
@@ -769,9 +1373,10 @@ var DefaultDrivingStatusController = class {
769
1373
  this.listeners.clear();
770
1374
  this.metricWindow.length = 0;
771
1375
  this.motionWindow.length = 0;
1376
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.destroy", "returned", this.getSnapshot());
772
1377
  }
773
1378
  getSnapshot() {
774
- return {
1379
+ const result = {
775
1380
  lifecycle: this.destroyed ? "destroyed" : this.polling ? "running" : "stopped",
776
1381
  status: this.status,
777
1382
  candidate: this.candidate,
@@ -781,25 +1386,59 @@ var DefaultDrivingStatusController = class {
781
1386
  unavailableSinceMs: this.unavailableSinceMs,
782
1387
  tuningVersion: this.tuning.version
783
1388
  };
1389
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.getSnapshot", "returned", { result });
1390
+ return result;
784
1391
  }
785
1392
  subscribe(listener) {
786
- if (this.destroyed) return noop;
1393
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.subscribe", "called", {
1394
+ destroyed: this.destroyed,
1395
+ listenerCount: this.listeners.size
1396
+ });
1397
+ if (this.destroyed) {
1398
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.subscribe", "returned noop");
1399
+ return noop;
1400
+ }
787
1401
  this.listeners.add(listener);
788
1402
  let subscribed = true;
1403
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.subscribe", "subscribed", { listenerCount: this.listeners.size });
789
1404
  return () => {
790
- if (!subscribed) return;
1405
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.unsubscribe", "called", { subscribed });
1406
+ if (!subscribed) {
1407
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.unsubscribe", "ignored");
1408
+ return;
1409
+ }
791
1410
  subscribed = false;
792
1411
  this.listeners.delete(listener);
1412
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.unsubscribe", "returned", { listenerCount: this.listeners.size });
793
1413
  };
794
1414
  }
795
1415
  activatePolling() {
796
- if (this.destroyed || this.polling || !this.requestedRunning || this.lifecycleSuspended) return;
1416
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.activatePolling", "called", {
1417
+ destroyed: this.destroyed,
1418
+ polling: this.polling,
1419
+ requestedRunning: this.requestedRunning,
1420
+ lifecycleSuspended: this.lifecycleSuspended,
1421
+ generation: this.generation
1422
+ });
1423
+ if (this.destroyed || this.polling || !this.requestedRunning || this.lifecycleSuspended) {
1424
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.activatePolling", "ignored");
1425
+ return;
1426
+ }
797
1427
  this.polling = true;
798
1428
  this.generation += 1;
799
1429
  this.schedulePoll(0, this.generation);
1430
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.activatePolling", "returned", { generation: this.generation });
800
1431
  }
801
1432
  deactivatePolling() {
802
- if (!this.polling && this.timer === void 0 && this.pendingRead === null) return;
1433
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.deactivatePolling", "called", {
1434
+ polling: this.polling,
1435
+ timer: this.timer,
1436
+ hasPendingRead: this.pendingRead !== null
1437
+ });
1438
+ if (!this.polling && this.timer === void 0 && this.pendingRead === null) {
1439
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.deactivatePolling", "ignored");
1440
+ return;
1441
+ }
803
1442
  this.polling = false;
804
1443
  this.generation += 1;
805
1444
  if (this.timer !== void 0) {
@@ -808,34 +1447,77 @@ var DefaultDrivingStatusController = class {
808
1447
  }
809
1448
  this.pendingRead?.abort();
810
1449
  this.pendingRead = null;
1450
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.deactivatePolling", "returned", { generation: this.generation });
811
1451
  }
812
1452
  schedulePoll(delayMs, generation) {
813
- if (!this.polling || generation !== this.generation || this.timer !== void 0) return;
1453
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll", "called", {
1454
+ delayMs,
1455
+ generation,
1456
+ currentGeneration: this.generation,
1457
+ polling: this.polling,
1458
+ timer: this.timer
1459
+ });
1460
+ if (!this.polling || generation !== this.generation || this.timer !== void 0) {
1461
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll", "ignored");
1462
+ return;
1463
+ }
814
1464
  this.timer = this.clock.setTimeout(() => {
1465
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll.callback", "called", { generation });
815
1466
  this.timer = void 0;
816
1467
  this.poll(generation);
817
1468
  }, delayMs);
1469
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll", "scheduled", {
1470
+ delayMs,
1471
+ generation,
1472
+ timer: this.timer
1473
+ });
818
1474
  }
819
1475
  async poll(generation) {
820
- if (!this.polling || generation !== this.generation || this.pendingRead !== null) return;
1476
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "called", {
1477
+ generation,
1478
+ currentGeneration: this.generation,
1479
+ polling: this.polling,
1480
+ hasPendingRead: this.pendingRead !== null
1481
+ });
1482
+ if (!this.polling || generation !== this.generation || this.pendingRead !== null) {
1483
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "ignored");
1484
+ return;
1485
+ }
821
1486
  const pendingRead = new AbortController();
822
1487
  this.pendingRead = pendingRead;
823
1488
  try {
824
1489
  const payload = await this.sensorProvider(pendingRead.signal);
825
- if (!this.polling || generation !== this.generation || pendingRead.signal.aborted) return;
1490
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "provider resolved", { payload });
1491
+ if (!this.polling || generation !== this.generation || pendingRead.signal.aborted) {
1492
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "discarded provider result");
1493
+ return;
1494
+ }
826
1495
  const metrics = extractDrivingSnapshotMetrics(payload, this.tuning);
827
1496
  const accelerometerSample = extractFreshAccelerometerSample(payload, this.tuning.maxSampleAgeMs);
828
1497
  if (metrics === null || accelerometerSample === null) this.processUnavailable("invalid_or_stale_snapshot");
829
1498
  else this.processAvailable(metrics, accelerometerSample);
830
1499
  } catch (error) {
831
- if (!this.polling || generation !== this.generation || pendingRead.signal.aborted || isAbortError$1(error)) return;
1500
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "provider rejected", error);
1501
+ if (!this.polling || generation !== this.generation || pendingRead.signal.aborted || isAbortError$1(error)) {
1502
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "ignored rejection");
1503
+ return;
1504
+ }
832
1505
  this.processUnavailable("provider_error");
833
1506
  } finally {
834
1507
  if (this.pendingRead === pendingRead) this.pendingRead = null;
835
1508
  if (this.polling && generation === this.generation) this.schedulePoll(this.pollIntervalMs, generation);
1509
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.poll", "completed", {
1510
+ generation,
1511
+ polling: this.polling,
1512
+ currentGeneration: this.generation
1513
+ });
836
1514
  }
837
1515
  }
838
1516
  processAvailable(rawMetrics, accelerometerSample) {
1517
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processAvailable", "called", {
1518
+ rawMetrics,
1519
+ accelerometerSample
1520
+ });
839
1521
  const now = this.clock.now();
840
1522
  this.lastAvailableAtMs = now;
841
1523
  this.unavailableSinceMs = null;
@@ -852,18 +1534,42 @@ var DefaultDrivingStatusController = class {
852
1534
  const motionIntensity = this.recordMotionSample(accelerometerSample, rawMetrics.capturedAtMs);
853
1535
  const nextCandidate = classifyControllerCandidate(rawMetrics, smoothedMetrics, motionIntensity, this.status, this.baseStatus, this.tuning);
854
1536
  this.processCandidate(nextCandidate, now);
1537
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processAvailable", "returned", {
1538
+ rawMetrics,
1539
+ smoothedMetrics,
1540
+ motionIntensity,
1541
+ nextCandidate,
1542
+ snapshot: this.getSnapshot()
1543
+ });
855
1544
  }
856
1545
  recordMotionSample(sample, capturedAtMs) {
1546
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.recordMotionSample", "called", {
1547
+ sample,
1548
+ capturedAtMs,
1549
+ motionWindow: this.motionWindow
1550
+ });
857
1551
  if (!this.motionWindow.some((existing) => existing.sampledAtMs === sample.sampledAtMs)) {
858
1552
  this.motionWindow.push(sample);
859
1553
  this.motionWindow.sort((left, right) => left.sampledAtMs - right.sampledAtMs);
860
1554
  }
861
1555
  const cutoffMs = capturedAtMs - this.tuning.motionWindowMs;
862
1556
  while (this.motionWindow[0] && this.motionWindow[0].sampledAtMs <= cutoffMs) this.motionWindow.shift();
863
- if (this.motionWindow.length < this.tuning.motionMinimumSamples) return null;
864
- return combinedAxisStandardDeviation(this.motionWindow);
1557
+ if (this.motionWindow.length < this.tuning.motionMinimumSamples) {
1558
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.recordMotionSample", "returned warmup", {
1559
+ result: null,
1560
+ motionWindow: this.motionWindow
1561
+ });
1562
+ return null;
1563
+ }
1564
+ const result = combinedAxisStandardDeviation(this.motionWindow);
1565
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.recordMotionSample", "returned", {
1566
+ result,
1567
+ motionWindow: this.motionWindow
1568
+ });
1569
+ return result;
865
1570
  }
866
1571
  processUnavailable(category) {
1572
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processUnavailable", "called", { category });
867
1573
  const now = this.clock.now();
868
1574
  if (this.unavailableSinceMs === null) this.unavailableSinceMs = now;
869
1575
  const unavailableForMs = Math.max(0, now - this.unavailableSinceMs);
@@ -877,7 +1583,13 @@ var DefaultDrivingStatusController = class {
877
1583
  category,
878
1584
  tuningVersion: this.tuning.version
879
1585
  });
880
- if (unavailableForMs < this.unavailableFallbackMs || this.fallbackApplied) return;
1586
+ if (unavailableForMs < this.unavailableFallbackMs || this.fallbackApplied) {
1587
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processUnavailable", "returned while holding", {
1588
+ unavailableForMs,
1589
+ fallbackApplied: this.fallbackApplied
1590
+ });
1591
+ return;
1592
+ }
881
1593
  this.fallbackApplied = true;
882
1594
  this.emitDiagnostic({
883
1595
  type: "fallback_to_stopped",
@@ -886,10 +1598,22 @@ var DefaultDrivingStatusController = class {
886
1598
  tuningVersion: this.tuning.version
887
1599
  });
888
1600
  this.commit("STOPPED", now, "unavailable_fallback", true);
1601
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processUnavailable", "returned after fallback", {
1602
+ unavailableForMs,
1603
+ snapshot: this.getSnapshot()
1604
+ });
889
1605
  }
890
1606
  processCandidate(nextCandidate, now) {
1607
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "called", {
1608
+ nextCandidate,
1609
+ now,
1610
+ currentStatus: this.status,
1611
+ candidate: this.candidate,
1612
+ candidateConfirmationCount: this.candidateConfirmationCount
1613
+ });
891
1614
  if (nextCandidate === this.status) {
892
1615
  this.setCandidate(null, now);
1616
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "returned current status");
893
1617
  return;
894
1618
  }
895
1619
  if (nextCandidate !== this.candidate) {
@@ -897,7 +1621,14 @@ var DefaultDrivingStatusController = class {
897
1621
  this.candidateConfirmationCount = 1;
898
1622
  this.heldCandidate = null;
899
1623
  } else this.candidateConfirmationCount += 1;
900
- if (this.candidateConfirmationCount < this.tuning.confirmationSamples[nextCandidate]) return;
1624
+ if (this.candidateConfirmationCount < this.tuning.confirmationSamples[nextCandidate]) {
1625
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "awaiting confirmation", {
1626
+ nextCandidate,
1627
+ candidateConfirmationCount: this.candidateConfirmationCount,
1628
+ required: this.tuning.confirmationSamples[nextCandidate]
1629
+ });
1630
+ return;
1631
+ }
901
1632
  const elapsedMs = Math.max(0, now - this.statusCommittedAtMs);
902
1633
  const remainingMs = Math.max(0, this.tuning.minimumDisplayMs[this.status] - elapsedMs);
903
1634
  const canPreempt = CAR_RUNNING_STATUS_PRIORITY[nextCandidate] > CAR_RUNNING_STATUS_PRIORITY[this.status];
@@ -913,13 +1644,31 @@ var DefaultDrivingStatusController = class {
913
1644
  tuningVersion: this.tuning.version
914
1645
  });
915
1646
  }
1647
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "held by minimum duration", {
1648
+ nextCandidate,
1649
+ remainingMs
1650
+ });
916
1651
  return;
917
1652
  }
918
1653
  this.commit(nextCandidate, now, "candidate_confirmed");
1654
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "returned after commit", { snapshot: this.getSnapshot() });
919
1655
  }
920
1656
  commit(nextStatus, now, reason, force = false) {
921
- if (!force && nextStatus === this.status) return;
922
- if (nextStatus === this.status) return;
1657
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.commit", "called", {
1658
+ nextStatus,
1659
+ now,
1660
+ reason,
1661
+ force,
1662
+ currentStatus: this.status
1663
+ });
1664
+ if (!force && nextStatus === this.status) {
1665
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.commit", "ignored unchanged status");
1666
+ return;
1667
+ }
1668
+ if (nextStatus === this.status) {
1669
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.commit", "ignored forced unchanged status");
1670
+ return;
1671
+ }
923
1672
  const previousStatus = this.status;
924
1673
  this.status = nextStatus;
925
1674
  if (isBaseStatus(nextStatus)) this.baseStatus = nextStatus;
@@ -942,10 +1691,21 @@ var DefaultDrivingStatusController = class {
942
1691
  reason,
943
1692
  tuningVersion: this.tuning.version
944
1693
  });
1694
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.commit", "returned", {
1695
+ event,
1696
+ listenerCount: this.listeners.size,
1697
+ snapshot: this.getSnapshot()
1698
+ });
945
1699
  }
946
1700
  setCandidate(candidate, now) {
1701
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "called", {
1702
+ candidate,
1703
+ now,
1704
+ currentCandidate: this.candidate
1705
+ });
947
1706
  if (candidate === this.candidate) {
948
1707
  if (candidate === null) this.candidateConfirmationCount = 0;
1708
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "returned unchanged", { candidateConfirmationCount: this.candidateConfirmationCount });
949
1709
  return;
950
1710
  }
951
1711
  const previousCandidate = this.candidate;
@@ -959,8 +1719,17 @@ var DefaultDrivingStatusController = class {
959
1719
  previousCandidate,
960
1720
  tuningVersion: this.tuning.version
961
1721
  });
1722
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "returned", {
1723
+ candidate,
1724
+ previousCandidate
1725
+ });
962
1726
  }
963
1727
  resetTransientRecognition() {
1728
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.resetTransientRecognition", "called", {
1729
+ metricWindow: this.metricWindow,
1730
+ motionWindow: this.motionWindow,
1731
+ candidate: this.candidate
1732
+ });
964
1733
  this.metricWindow.length = 0;
965
1734
  this.motionWindow.length = 0;
966
1735
  this.candidate = null;
@@ -968,54 +1737,144 @@ var DefaultDrivingStatusController = class {
968
1737
  this.unavailableSinceMs = null;
969
1738
  this.fallbackApplied = false;
970
1739
  this.heldCandidate = null;
1740
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.resetTransientRecognition", "returned");
971
1741
  }
972
1742
  emitDiagnostic(event) {
1743
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.emitDiagnostic", "called", {
1744
+ event,
1745
+ hasListener: this.onDiagnostic !== void 0
1746
+ });
973
1747
  if (this.onDiagnostic) safeCall(this.onDiagnostic, event);
1748
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.emitDiagnostic", "returned", { event });
974
1749
  }
975
1750
  attachLifecycleListeners() {
976
- if (!this.managePageLifecycle || this.unsubscribePageLifecycle !== null) return;
1751
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.attachLifecycleListeners", "called", {
1752
+ managePageLifecycle: this.managePageLifecycle,
1753
+ attached: this.unsubscribePageLifecycle !== null
1754
+ });
1755
+ if (!this.managePageLifecycle || this.unsubscribePageLifecycle !== null) {
1756
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.attachLifecycleListeners", "ignored");
1757
+ return;
1758
+ }
977
1759
  this.unsubscribePageLifecycle = subscribeDrivingPageLifecycle(this.handleLifecyclePause, this.handleLifecycleResume);
1760
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.attachLifecycleListeners", "returned");
978
1761
  }
979
1762
  detachLifecycleListeners() {
1763
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.detachLifecycleListeners", "called", { attached: this.unsubscribePageLifecycle !== null });
980
1764
  this.unsubscribePageLifecycle?.();
981
1765
  this.unsubscribePageLifecycle = null;
1766
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.detachLifecycleListeners", "returned");
982
1767
  }
983
1768
  };
984
1769
  const classifyControllerCandidate = (raw, smoothed, motionIntensity, current, baseStatus, tuning) => {
1770
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyControllerCandidate", "called", {
1771
+ raw,
1772
+ smoothed,
1773
+ motionIntensity,
1774
+ current,
1775
+ baseStatus,
1776
+ tuning
1777
+ });
985
1778
  const entry = classifyEntryCandidate(raw, smoothed, motionIntensity, baseStatus, tuning);
986
- if (!retainsCurrentStatus(raw, smoothed, motionIntensity, current, tuning)) return entry;
987
- if (entry === current) return current;
988
- if (CAR_RUNNING_STATUS_PRIORITY[entry] > CAR_RUNNING_STATUS_PRIORITY[current]) return entry;
989
- if (isOppositeTurn(entry, current)) return entry;
990
- if ((entry === "STOPPED" || entry === "STEADY_DRIVING") && (current === "STOPPED" || current === "STEADY_DRIVING")) return entry;
991
- return current;
1779
+ const retained = retainsCurrentStatus(raw, smoothed, motionIntensity, current, tuning);
1780
+ const result = !retained || CAR_RUNNING_STATUS_PRIORITY[entry] > CAR_RUNNING_STATUS_PRIORITY[current] || isOppositeTurn(entry, current) || (entry === "STOPPED" || entry === "STEADY_DRIVING") && (current === "STOPPED" || current === "STEADY_DRIVING") ? entry : current;
1781
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyControllerCandidate", "returned", {
1782
+ entry,
1783
+ retained,
1784
+ result
1785
+ });
1786
+ return result;
992
1787
  };
993
1788
  const classifyEntryCandidate = (raw, smoothed, motionIntensity, baseStatus, tuning) => {
994
- if (raw.longitudinal <= -tuning.rapidLongitudinalThreshold) return "SUDDEN_BRAKING";
995
- if (raw.longitudinal >= tuning.rapidLongitudinalThreshold) return "RAPID_ACCELERATION";
996
- if (Math.abs(smoothed.yaw) >= tuning.turnYawThreshold) return smoothed.yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
997
- if (Math.abs(smoothed.lateral) >= tuning.turnLateralThreshold) return smoothed.lateral < 0 ? "LEFT_TURN" : "RIGHT_TURN";
998
- if (smoothed.longitudinal <= -tuning.longitudinalThreshold) return "BRAKING";
999
- if (smoothed.longitudinal >= tuning.longitudinalThreshold) return "ACCELERATION";
1000
- if (motionIntensity === null) return baseStatus;
1001
- if (motionIntensity > tuning.drivingMotionThreshold || smoothed.gyroMagnitude > tuning.stoppedGyroThreshold) return "STEADY_DRIVING";
1002
- if (motionIntensity < tuning.stoppedMotionThreshold) return "STOPPED";
1003
- return baseStatus;
1789
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "called", {
1790
+ raw,
1791
+ smoothed,
1792
+ motionIntensity,
1793
+ baseStatus,
1794
+ tuning
1795
+ });
1796
+ if (raw.longitudinal <= -tuning.rapidLongitudinalThreshold) {
1797
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "SUDDEN_BRAKING" });
1798
+ return "SUDDEN_BRAKING";
1799
+ }
1800
+ if (raw.longitudinal >= tuning.rapidLongitudinalThreshold) {
1801
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "RAPID_ACCELERATION" });
1802
+ return "RAPID_ACCELERATION";
1803
+ }
1804
+ if (Math.abs(smoothed.yaw) >= tuning.turnYawThreshold) {
1805
+ const result = smoothed.yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
1806
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result });
1807
+ return result;
1808
+ }
1809
+ if (Math.abs(smoothed.lateral) >= tuning.turnLateralThreshold) {
1810
+ const result = smoothed.lateral < 0 ? "LEFT_TURN" : "RIGHT_TURN";
1811
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result });
1812
+ return result;
1813
+ }
1814
+ if (smoothed.longitudinal <= -tuning.longitudinalThreshold) {
1815
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "BRAKING" });
1816
+ return "BRAKING";
1817
+ }
1818
+ if (smoothed.longitudinal >= tuning.longitudinalThreshold) {
1819
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "ACCELERATION" });
1820
+ return "ACCELERATION";
1821
+ }
1822
+ if (motionIntensity === null) {
1823
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned base status", { result: baseStatus });
1824
+ return baseStatus;
1825
+ }
1826
+ if (motionIntensity > tuning.drivingMotionThreshold || smoothed.gyroMagnitude > tuning.stoppedGyroThreshold) {
1827
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "STEADY_DRIVING" });
1828
+ return "STEADY_DRIVING";
1829
+ }
1830
+ if (motionIntensity < tuning.stoppedMotionThreshold) {
1831
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned", { result: "STOPPED" });
1832
+ return "STOPPED";
1833
+ }
1834
+ dialSdkDebugWarn(DEBUG_MODULE$1, "classifyEntryCandidate", "returned base status", { result: baseStatus });
1835
+ return baseStatus;
1004
1836
  };
1005
1837
  const retainsCurrentStatus = (raw, smoothed, motionIntensity, current, tuning) => {
1838
+ dialSdkDebugWarn(DEBUG_MODULE$1, "retainsCurrentStatus", "called", {
1839
+ raw,
1840
+ smoothed,
1841
+ motionIntensity,
1842
+ current,
1843
+ tuning
1844
+ });
1006
1845
  const ratio = tuning.hysteresisRatio;
1846
+ let result;
1007
1847
  switch (current) {
1008
- case "SUDDEN_BRAKING": return raw.longitudinal <= -tuning.rapidLongitudinalThreshold * ratio;
1009
- case "RAPID_ACCELERATION": return raw.longitudinal >= tuning.rapidLongitudinalThreshold * ratio;
1010
- case "LEFT_TURN": return smoothed.yaw >= tuning.turnYawThreshold * ratio || smoothed.lateral <= -tuning.turnLateralThreshold * ratio;
1011
- case "RIGHT_TURN": return smoothed.yaw <= -tuning.turnYawThreshold * ratio || smoothed.lateral >= tuning.turnLateralThreshold * ratio;
1012
- case "BRAKING": return smoothed.longitudinal <= -tuning.longitudinalThreshold * ratio;
1013
- case "ACCELERATION": return smoothed.longitudinal >= tuning.longitudinalThreshold * ratio;
1014
- case "STOPPED": return (motionIntensity === null || motionIntensity <= tuning.drivingMotionThreshold) && smoothed.gyroMagnitude <= tuning.stoppedGyroThreshold;
1015
- case "STEADY_DRIVING": return motionIntensity === null || motionIntensity >= tuning.stoppedMotionThreshold || smoothed.gyroMagnitude > tuning.stoppedGyroThreshold;
1848
+ case "SUDDEN_BRAKING":
1849
+ result = raw.longitudinal <= -tuning.rapidLongitudinalThreshold * ratio;
1850
+ break;
1851
+ case "RAPID_ACCELERATION":
1852
+ result = raw.longitudinal >= tuning.rapidLongitudinalThreshold * ratio;
1853
+ break;
1854
+ case "LEFT_TURN":
1855
+ result = smoothed.yaw >= tuning.turnYawThreshold * ratio || smoothed.lateral <= -tuning.turnLateralThreshold * ratio;
1856
+ break;
1857
+ case "RIGHT_TURN":
1858
+ result = smoothed.yaw <= -tuning.turnYawThreshold * ratio || smoothed.lateral >= tuning.turnLateralThreshold * ratio;
1859
+ break;
1860
+ case "BRAKING":
1861
+ result = smoothed.longitudinal <= -tuning.longitudinalThreshold * ratio;
1862
+ break;
1863
+ case "ACCELERATION":
1864
+ result = smoothed.longitudinal >= tuning.longitudinalThreshold * ratio;
1865
+ break;
1866
+ case "STOPPED":
1867
+ result = (motionIntensity === null || motionIntensity <= tuning.drivingMotionThreshold) && smoothed.gyroMagnitude <= tuning.stoppedGyroThreshold;
1868
+ break;
1869
+ case "STEADY_DRIVING":
1870
+ result = motionIntensity === null || motionIntensity >= tuning.stoppedMotionThreshold || smoothed.gyroMagnitude > tuning.stoppedGyroThreshold;
1871
+ break;
1016
1872
  }
1873
+ dialSdkDebugWarn(DEBUG_MODULE$1, "retainsCurrentStatus", "returned", { result });
1874
+ return result;
1017
1875
  };
1018
1876
  const averageMetrics = (metrics) => {
1877
+ dialSdkDebugWarn(DEBUG_MODULE$1, "averageMetrics", "called", { metrics });
1019
1878
  const result = {
1020
1879
  capturedAtMs: metrics[metrics.length - 1]?.capturedAtMs ?? 0,
1021
1880
  longitudinal: 0,
@@ -1037,25 +1896,45 @@ const averageMetrics = (metrics) => {
1037
1896
  result.yaw /= count;
1038
1897
  result.motionIntensity /= count;
1039
1898
  result.gyroMagnitude /= count;
1899
+ dialSdkDebugWarn(DEBUG_MODULE$1, "averageMetrics", "returned", { result });
1040
1900
  return result;
1041
1901
  };
1042
1902
  const extractFreshAccelerometerSample = (info, maxSampleAgeMs) => {
1903
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "called", {
1904
+ info,
1905
+ maxSampleAgeMs
1906
+ });
1043
1907
  const metric = info?.accelerometer;
1044
- if (!metric?.available || !Number.isFinite(info.capturedAtMs) || !Number.isFinite(metric.sampledAtMs)) return null;
1908
+ if (!metric?.available || !Number.isFinite(info.capturedAtMs) || !Number.isFinite(metric.sampledAtMs)) {
1909
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned", { result: null });
1910
+ return null;
1911
+ }
1045
1912
  const ageMs = info.capturedAtMs - metric.sampledAtMs;
1046
- if (ageMs < 0 || ageMs > maxSampleAgeMs) return null;
1913
+ if (ageMs < 0 || ageMs > maxSampleAgeMs) {
1914
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned stale sample", {
1915
+ result: null,
1916
+ ageMs
1917
+ });
1918
+ return null;
1919
+ }
1047
1920
  const { x, y, z } = metric.value;
1048
1921
  if (![
1049
1922
  x,
1050
1923
  y,
1051
1924
  z
1052
- ].every(Number.isFinite)) return null;
1053
- return {
1925
+ ].every(Number.isFinite)) {
1926
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned invalid vector", { result: null });
1927
+ return null;
1928
+ }
1929
+ const result = {
1054
1930
  sampledAtMs: metric.sampledAtMs,
1055
1931
  value: metric.value
1056
1932
  };
1933
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned", { result });
1934
+ return result;
1057
1935
  };
1058
1936
  const combinedAxisStandardDeviation = (samples) => {
1937
+ dialSdkDebugWarn(DEBUG_MODULE$1, "combinedAxisStandardDeviation", "called", { samples });
1059
1938
  const count = samples.length;
1060
1939
  let meanX = 0;
1061
1940
  let meanY = 0;
@@ -1076,34 +1955,117 @@ const combinedAxisStandardDeviation = (samples) => {
1076
1955
  varianceY += (sample.value.y - meanY) ** 2;
1077
1956
  varianceZ += (sample.value.z - meanZ) ** 2;
1078
1957
  }
1079
- return Math.sqrt((varianceX + varianceY + varianceZ) / count);
1958
+ const result = Math.sqrt((varianceX + varianceY + varianceZ) / count);
1959
+ dialSdkDebugWarn(DEBUG_MODULE$1, "combinedAxisStandardDeviation", "returned", {
1960
+ meanX,
1961
+ meanY,
1962
+ meanZ,
1963
+ varianceX,
1964
+ varianceY,
1965
+ varianceZ,
1966
+ result
1967
+ });
1968
+ return result;
1080
1969
  };
1081
1970
  const defaultSensorProvider = () => {
1971
+ dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "called");
1082
1972
  const runtimeGlobal = globalThis;
1083
- if (typeof runtimeGlobal.unifiedSensorInfo !== "function") return Promise.reject(/* @__PURE__ */ new Error("window.unifiedSensorInfo is unavailable"));
1084
- return runtimeGlobal.unifiedSensorInfo();
1973
+ if (typeof runtimeGlobal.unifiedSensorInfo !== "function") {
1974
+ const error = /* @__PURE__ */ new Error("window.unifiedSensorInfo is unavailable");
1975
+ dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "rejected", error);
1976
+ return Promise.reject(error);
1977
+ }
1978
+ try {
1979
+ const result = runtimeGlobal.unifiedSensorInfo();
1980
+ result.then((payload) => dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "resolved", { payload }), (error) => dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "rejected", error));
1981
+ return result;
1982
+ } catch (error) {
1983
+ dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "threw", error);
1984
+ throw error;
1985
+ }
1085
1986
  };
1086
1987
  const systemClock = {
1087
- now: () => Date.now(),
1088
- setTimeout: (callback, delayMs) => globalThis.setTimeout(callback, delayMs),
1089
- clearTimeout: (handle) => globalThis.clearTimeout(handle)
1988
+ now: () => {
1989
+ const result = Date.now();
1990
+ dialSdkDebugWarn(DEBUG_MODULE$1, "systemClock.now", "returned", { result });
1991
+ return result;
1992
+ },
1993
+ setTimeout: (callback, delayMs) => {
1994
+ const result = globalThis.setTimeout(callback, delayMs);
1995
+ dialSdkDebugWarn(DEBUG_MODULE$1, "systemClock.setTimeout", "returned", {
1996
+ delayMs,
1997
+ result
1998
+ });
1999
+ return result;
2000
+ },
2001
+ clearTimeout: (handle) => {
2002
+ dialSdkDebugWarn(DEBUG_MODULE$1, "systemClock.clearTimeout", "called", { handle });
2003
+ globalThis.clearTimeout(handle);
2004
+ dialSdkDebugWarn(DEBUG_MODULE$1, "systemClock.clearTimeout", "returned");
2005
+ }
2006
+ };
2007
+ const isOppositeTurn = (candidate, current) => {
2008
+ const result = candidate === "LEFT_TURN" && current === "RIGHT_TURN" || candidate === "RIGHT_TURN" && current === "LEFT_TURN";
2009
+ dialSdkDebugWarn(DEBUG_MODULE$1, "isOppositeTurn", "returned", {
2010
+ candidate,
2011
+ current,
2012
+ result
2013
+ });
2014
+ return result;
2015
+ };
2016
+ const isBaseStatus = (status) => {
2017
+ const result = status === "STOPPED" || status === "STEADY_DRIVING";
2018
+ dialSdkDebugWarn(DEBUG_MODULE$1, "isBaseStatus", "returned", {
2019
+ status,
2020
+ result
2021
+ });
2022
+ return result;
2023
+ };
2024
+ const isAbortError$1 = (error) => {
2025
+ const result = error instanceof Error && error.name === "AbortError";
2026
+ dialSdkDebugWarn(DEBUG_MODULE$1, "isAbortError", "returned", {
2027
+ error,
2028
+ result
2029
+ });
2030
+ return result;
1090
2031
  };
1091
- const isOppositeTurn = (candidate, current) => candidate === "LEFT_TURN" && current === "RIGHT_TURN" || candidate === "RIGHT_TURN" && current === "LEFT_TURN";
1092
- const isBaseStatus = (status) => status === "STOPPED" || status === "STEADY_DRIVING";
1093
- const isAbortError$1 = (error) => error instanceof Error && error.name === "AbortError";
1094
2032
  const requirePositiveFinite = (name, value) => {
1095
- if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be a positive finite number`);
2033
+ dialSdkDebugWarn(DEBUG_MODULE$1, "requirePositiveFinite", "called", {
2034
+ name,
2035
+ value
2036
+ });
2037
+ if (!Number.isFinite(value) || value <= 0) {
2038
+ const error = /* @__PURE__ */ new RangeError(`${name} must be a positive finite number`);
2039
+ dialSdkDebugWarn(DEBUG_MODULE$1, "requirePositiveFinite", "threw", error);
2040
+ throw error;
2041
+ }
2042
+ dialSdkDebugWarn(DEBUG_MODULE$1, "requirePositiveFinite", "returned", { result: value });
1096
2043
  return value;
1097
2044
  };
1098
2045
  const safeCall = (callback, value) => {
2046
+ dialSdkDebugWarn(DEBUG_MODULE$1, "safeCall", "called", { value });
1099
2047
  try {
1100
2048
  callback(value);
1101
- } catch {}
2049
+ dialSdkDebugWarn(DEBUG_MODULE$1, "safeCall", "returned");
2050
+ } catch (error) {
2051
+ dialSdkDebugWarn(DEBUG_MODULE$1, "safeCall", "callback threw", error);
2052
+ }
2053
+ };
2054
+ const noop = () => {
2055
+ dialSdkDebugWarn(DEBUG_MODULE$1, "noop", "called and returned");
1102
2056
  };
1103
- const noop = () => {};
1104
2057
  //#endregion
1105
2058
  //#region src/sensor/driving_expression_player.ts
1106
- const createDrivingExpressionPlayer = (container, options) => new DefaultDrivingExpressionPlayer(container, options);
2059
+ const DEBUG_MODULE = "driving_expression_player.ts";
2060
+ const createDrivingExpressionPlayer = (container, options) => {
2061
+ dialSdkDebugWarn(DEBUG_MODULE, "createDrivingExpressionPlayer", "called", {
2062
+ container,
2063
+ options
2064
+ });
2065
+ const result = new DefaultDrivingExpressionPlayer(container, options);
2066
+ dialSdkDebugWarn(DEBUG_MODULE, "createDrivingExpressionPlayer", "returned", { snapshot: result.getSnapshot() });
2067
+ return result;
2068
+ };
1107
2069
  var DefaultDrivingExpressionPlayer = class {
1108
2070
  constructor(container, options) {
1109
2071
  this.status = null;
@@ -1125,16 +2087,34 @@ var DefaultDrivingExpressionPlayer = class {
1125
2087
  this.activeTgs = null;
1126
2088
  this.unsubscribePageLifecycle = null;
1127
2089
  this.handleLifecyclePause = () => {
1128
- if (this.destroyed || this.lifecycleSuspended) return;
2090
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "called");
2091
+ if (this.destroyed || this.lifecycleSuspended) {
2092
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "ignored");
2093
+ return;
2094
+ }
1129
2095
  this.lifecycleSuspended = true;
1130
2096
  this.updatePauseState();
2097
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "returned");
1131
2098
  };
1132
2099
  this.handleLifecycleResume = () => {
1133
- if (this.destroyed || !this.lifecycleSuspended) return;
2100
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "called");
2101
+ if (this.destroyed || !this.lifecycleSuspended) {
2102
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "ignored");
2103
+ return;
2104
+ }
1134
2105
  this.lifecycleSuspended = false;
1135
2106
  this.updatePauseState();
2107
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "returned");
1136
2108
  };
1137
- if (!container || typeof container.replaceChildren !== "function") throw new TypeError("container must be an HTMLElement-like DOM container");
2109
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "called", {
2110
+ container,
2111
+ options
2112
+ });
2113
+ if (!container || typeof container.replaceChildren !== "function") {
2114
+ const error = /* @__PURE__ */ new TypeError("container must be an HTMLElement-like DOM container");
2115
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "threw", error);
2116
+ throw error;
2117
+ }
1138
2118
  this.container = container;
1139
2119
  this.document = container.ownerDocument;
1140
2120
  this.config = options.config;
@@ -1149,9 +2129,25 @@ var DefaultDrivingExpressionPlayer = class {
1149
2129
  this.maxTgsJsonBytes = positiveFinite("maxTgsJsonBytes", options.maxTgsJsonBytes ?? 8 * 1024 * 1024);
1150
2130
  this.maxTgsLayers = positiveFinite("maxTgsLayers", options.maxTgsLayers ?? 500);
1151
2131
  if (options.managePageLifecycle ?? true) this.unsubscribePageLifecycle = subscribeDrivingPageLifecycle(this.handleLifecyclePause, this.handleLifecycleResume);
2132
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "created", {
2133
+ loadTimeoutMs: this.loadTimeoutMs,
2134
+ retryBackoffMs: this.retryBackoffMs,
2135
+ fit: this.fit,
2136
+ maxTgsCompressedBytes: this.maxTgsCompressedBytes,
2137
+ maxTgsJsonBytes: this.maxTgsJsonBytes,
2138
+ maxTgsLayers: this.maxTgsLayers,
2139
+ managesPageLifecycle: this.unsubscribePageLifecycle !== null
2140
+ });
1152
2141
  }
1153
2142
  async show(status) {
1154
- if (this.destroyed || status === this.status && this.phase !== "idle") return;
2143
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "called", {
2144
+ status,
2145
+ snapshot: this.getSnapshot()
2146
+ });
2147
+ if (this.destroyed || status === this.status && this.phase !== "idle") {
2148
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "ignored");
2149
+ return;
2150
+ }
1155
2151
  this.status = status;
1156
2152
  const operation = this.beginOperation();
1157
2153
  const configured = this.config.states[status];
@@ -1159,36 +2155,59 @@ var DefaultDrivingExpressionPlayer = class {
1159
2155
  const fallback = this.fallbacks?.[status];
1160
2156
  if (fallback === void 0) {
1161
2157
  this.handleFailure(status, null, new DrivingExpressionResolutionError(status), "invalid_config", operation, false);
2158
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned after missing config");
1162
2159
  return;
1163
2160
  }
1164
2161
  this.desiredMedia = fallback;
1165
2162
  if (this.paused) {
1166
2163
  this.phase = "idle";
2164
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred fallback while paused");
1167
2165
  return;
1168
2166
  }
1169
2167
  this.renderFallback(status, fallback);
2168
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned fallback", { snapshot: this.getSnapshot() });
1170
2169
  return;
1171
2170
  }
1172
2171
  const media = normalizeMedia(configured);
1173
2172
  this.desiredMedia = media;
1174
2173
  if (this.paused) {
1175
2174
  this.phase = "idle";
2175
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred media while paused", { media });
1176
2176
  return;
1177
2177
  }
1178
2178
  await this.load(status, media, operation);
2179
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "resolved", {
2180
+ status,
2181
+ media,
2182
+ snapshot: this.getSnapshot()
2183
+ });
1179
2184
  }
1180
2185
  pause() {
1181
- if (this.destroyed || this.userPaused) return;
2186
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "called", this.getSnapshot());
2187
+ if (this.destroyed || this.userPaused) {
2188
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "ignored");
2189
+ return;
2190
+ }
1182
2191
  this.userPaused = true;
1183
2192
  this.updatePauseState();
2193
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "returned", this.getSnapshot());
1184
2194
  }
1185
2195
  resume() {
1186
- if (this.destroyed || !this.userPaused) return;
2196
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "called", this.getSnapshot());
2197
+ if (this.destroyed || !this.userPaused) {
2198
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "ignored");
2199
+ return;
2200
+ }
1187
2201
  this.userPaused = false;
1188
2202
  this.updatePauseState();
2203
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "returned", this.getSnapshot());
1189
2204
  }
1190
2205
  destroy() {
1191
- if (this.destroyed) return;
2206
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "called", this.getSnapshot());
2207
+ if (this.destroyed) {
2208
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "ignored");
2209
+ return;
2210
+ }
1192
2211
  this.destroyed = true;
1193
2212
  this.unsubscribePageLifecycle?.();
1194
2213
  this.unsubscribePageLifecycle = null;
@@ -1202,17 +2221,24 @@ var DefaultDrivingExpressionPlayer = class {
1202
2221
  this.phase = "idle";
1203
2222
  this.mediaKind = null;
1204
2223
  this.errorCategory = null;
2224
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "returned", this.getSnapshot());
1205
2225
  }
1206
2226
  getSnapshot() {
1207
- return {
2227
+ const result = {
1208
2228
  lifecycle: this.destroyed ? "destroyed" : this.paused ? "paused" : "active",
1209
2229
  status: this.status,
1210
2230
  phase: this.phase,
1211
2231
  mediaKind: this.mediaKind,
1212
2232
  errorCategory: this.errorCategory
1213
2233
  };
2234
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getSnapshot", "returned", { result });
2235
+ return result;
1214
2236
  }
1215
2237
  beginOperation() {
2238
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "called", {
2239
+ operation: this.operation,
2240
+ snapshot: this.getSnapshot()
2241
+ });
1216
2242
  this.operation += 1;
1217
2243
  this.failedOperation = null;
1218
2244
  this.cancelPendingWork();
@@ -1221,17 +2247,28 @@ var DefaultDrivingExpressionPlayer = class {
1221
2247
  this.phase = "loading";
1222
2248
  this.mediaKind = null;
1223
2249
  this.errorCategory = null;
2250
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "returned", { operation: this.operation });
1224
2251
  return this.operation;
1225
2252
  }
1226
2253
  updatePauseState() {
2254
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "called", {
2255
+ userPaused: this.userPaused,
2256
+ lifecycleSuspended: this.lifecycleSuspended,
2257
+ paused: this.paused,
2258
+ snapshot: this.getSnapshot()
2259
+ });
1227
2260
  const shouldPause = this.userPaused || this.lifecycleSuspended;
1228
- if (shouldPause === this.paused) return;
2261
+ if (shouldPause === this.paused) {
2262
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "ignored unchanged state");
2263
+ return;
2264
+ }
1229
2265
  this.paused = shouldPause;
1230
2266
  if (shouldPause) {
1231
2267
  this.operation += 1;
1232
2268
  this.cancelPendingWork();
1233
2269
  this.activeVideo?.pause();
1234
2270
  this.activeTgs?.pause?.();
2271
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "paused", this.getSnapshot());
1235
2272
  return;
1236
2273
  }
1237
2274
  if (this.phase === "ready") {
@@ -1244,23 +2281,33 @@ var DefaultDrivingExpressionPlayer = class {
1244
2281
  video.play().catch((error) => this.handleActiveVideoFailure(video, status, media, operation, "decode", error));
1245
2282
  }
1246
2283
  this.activeTgs?.play?.();
2284
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "resumed ready media");
1247
2285
  return;
1248
2286
  }
1249
2287
  if (this.status !== null && this.desiredMedia !== null) {
1250
2288
  const operation = this.beginOperation();
1251
2289
  this.load(this.status, this.desiredMedia, operation);
1252
2290
  }
2291
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "returned", this.getSnapshot());
1253
2292
  }
1254
2293
  async load(status, media, operation) {
2294
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "called", {
2295
+ status,
2296
+ media,
2297
+ operation
2298
+ });
1255
2299
  const startedAt = Date.now();
1256
2300
  this.mediaKind = media.kind;
1257
2301
  if (media.kind === "emoji") {
1258
2302
  this.renderEmoji(media.text);
1259
2303
  this.markReady(status, media.kind, startedAt, operation);
2304
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved emoji", { snapshot: this.getSnapshot() });
1260
2305
  return;
1261
2306
  }
1262
- if (firstInvalidMediaUrl(media) !== null) {
2307
+ const invalidUrl = firstInvalidMediaUrl(media);
2308
+ if (invalidUrl !== null) {
1263
2309
  this.handleFailure(status, media, /* @__PURE__ */ new Error("One or more media URLs are not long-lived public HTTPS URLs"), "invalid_config", operation);
2310
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "returned invalid URL", { invalidUrl });
1264
2311
  return;
1265
2312
  }
1266
2313
  const loadAbort = new AbortController();
@@ -1283,26 +2330,67 @@ var DefaultDrivingExpressionPlayer = class {
1283
2330
  await this.loadTgs(media.url, loadAbort.signal, operation);
1284
2331
  break;
1285
2332
  }
1286
- if (!this.isCurrent(operation) || this.failedOperation === operation) return;
2333
+ if (!this.isCurrent(operation) || this.failedOperation === operation) {
2334
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "discarded completed load", {
2335
+ operation,
2336
+ failedOperation: this.failedOperation
2337
+ });
2338
+ return;
2339
+ }
1287
2340
  this.markReady(status, media.kind, startedAt, operation);
1288
2341
  this.startPreloading(status, operation);
2342
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved", {
2343
+ status,
2344
+ media,
2345
+ operation,
2346
+ snapshot: this.getSnapshot()
2347
+ });
1289
2348
  } catch (error) {
1290
- if (!this.isCurrent(operation) || isAbortError(error)) return;
2349
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "caught error", {
2350
+ error,
2351
+ operation
2352
+ });
2353
+ if (!this.isCurrent(operation) || isAbortError(error)) {
2354
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "ignored error");
2355
+ return;
2356
+ }
1291
2357
  this.handleFailure(status, media, error, categorizeMediaError(error), operation);
1292
2358
  } finally {
1293
2359
  loadAbort.abort();
1294
2360
  if (this.loadAbort === loadAbort) this.loadAbort = null;
2361
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "completed", { operation });
1295
2362
  }
1296
2363
  }
1297
2364
  async loadImage(url, signal, operation) {
2365
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "called", {
2366
+ url,
2367
+ signal,
2368
+ operation
2369
+ });
1298
2370
  const image = this.createImage();
1299
2371
  await waitForElementEvent(image, "load", "error", signal, this.loadTimeoutMs, () => {
1300
2372
  image.src = url;
1301
2373
  });
1302
- if (!this.isCurrent(operation)) return;
2374
+ if (!this.isCurrent(operation)) {
2375
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "discarded", { operation });
2376
+ return;
2377
+ }
1303
2378
  this.container.replaceChildren(image);
2379
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "resolved", {
2380
+ url,
2381
+ operation,
2382
+ image
2383
+ });
1304
2384
  }
1305
2385
  async loadVideo(url, mimeType, status, media, signal, operation) {
2386
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "called", {
2387
+ url,
2388
+ mimeType,
2389
+ status,
2390
+ media,
2391
+ signal,
2392
+ operation
2393
+ });
1306
2394
  const video = this.getReusableVideo();
1307
2395
  resetVideo(video);
1308
2396
  video.preload = "auto";
@@ -1311,25 +2399,55 @@ var DefaultDrivingExpressionPlayer = class {
1311
2399
  video.src = url;
1312
2400
  video.load();
1313
2401
  });
1314
- if (!this.isCurrent(operation)) return;
2402
+ if (!this.isCurrent(operation)) {
2403
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "discarded", { operation });
2404
+ return;
2405
+ }
1315
2406
  video.currentTime = 0;
1316
2407
  this.container.replaceChildren(video);
1317
2408
  this.activeVideo = video;
1318
2409
  this.attachActiveVideoFailureListeners(video, status, media, operation);
1319
2410
  await video.play();
2411
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "resolved", {
2412
+ url,
2413
+ operation,
2414
+ video
2415
+ });
1320
2416
  }
1321
2417
  async loadLivePhoto(media, status, signal, operation) {
2418
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "called", {
2419
+ media,
2420
+ status,
2421
+ signal,
2422
+ operation
2423
+ });
1322
2424
  this.renderConfiguredFallback(status, false);
1323
2425
  const cover = this.createImage();
1324
2426
  await waitForElementEvent(cover, "load", "error", signal, this.loadTimeoutMs, () => {
1325
2427
  cover.src = media.coverUrl;
1326
2428
  });
1327
- if (!this.isCurrent(operation)) return;
2429
+ if (!this.isCurrent(operation)) {
2430
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "discarded", { operation });
2431
+ return;
2432
+ }
1328
2433
  this.container.replaceChildren(cover);
1329
2434
  await this.loadVideo(media.motionUrl, void 0, status, media, signal, operation);
2435
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "resolved", {
2436
+ media,
2437
+ operation
2438
+ });
1330
2439
  }
1331
2440
  async loadTgs(url, signal, operation) {
1332
- if (!this.fetchImplementation) throw new MediaPlayerError("unsupported", "fetch is unavailable");
2441
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "called", {
2442
+ url,
2443
+ signal,
2444
+ operation
2445
+ });
2446
+ if (!this.fetchImplementation) {
2447
+ const error = new MediaPlayerError("unsupported", "fetch is unavailable");
2448
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "threw", error);
2449
+ throw error;
2450
+ }
1333
2451
  const response = await withTimeout(this.fetchImplementation(url, {
1334
2452
  credentials: "omit",
1335
2453
  mode: "cors",
@@ -1337,6 +2455,12 @@ var DefaultDrivingExpressionPlayer = class {
1337
2455
  }), this.loadTimeoutMs, signal);
1338
2456
  if (!response.ok) throw new MediaPlayerError("network", `TGS request failed with HTTP ${response.status}`);
1339
2457
  const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
2458
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "received response", {
2459
+ ok: response.ok,
2460
+ status: response.status,
2461
+ contentType,
2462
+ contentLength: response.headers.get("content-length")
2463
+ });
1340
2464
  if (!SUPPORTED_TGS_CONTENT_TYPES.has(contentType)) throw new MediaPlayerError("unsupported", `Unsupported TGS Content-Type: ${contentType || "missing"}`);
1341
2465
  const contentLength = Number(response.headers.get("content-length"));
1342
2466
  if (Number.isFinite(contentLength) && contentLength > this.maxTgsCompressedBytes) throw new MediaPlayerError("decode", "TGS compressed payload exceeds the configured limit");
@@ -1347,8 +2471,13 @@ var DefaultDrivingExpressionPlayer = class {
1347
2471
  let animationData;
1348
2472
  try {
1349
2473
  animationData = JSON.parse(new TextDecoder().decode(bytes));
1350
- } catch {
1351
- throw new MediaPlayerError("decode", "TGS JSON is malformed");
2474
+ } catch (cause) {
2475
+ const error = new MediaPlayerError("decode", "TGS JSON is malformed");
2476
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "threw", {
2477
+ error,
2478
+ cause
2479
+ });
2480
+ throw error;
1352
2481
  }
1353
2482
  validateTgsAnimation(animationData, this.maxTgsLayers);
1354
2483
  const host = this.document.createElement("div");
@@ -1356,33 +2485,72 @@ var DefaultDrivingExpressionPlayer = class {
1356
2485
  const handle = await withTimeout(Promise.resolve(this.tgsRenderer(host, animationData, signal)), this.loadTimeoutMs, signal);
1357
2486
  if (!this.isCurrent(operation)) {
1358
2487
  handle.destroy();
2488
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "discarded", { operation });
1359
2489
  return;
1360
2490
  }
1361
2491
  this.activeTgs = handle;
1362
2492
  this.container.replaceChildren(host);
2493
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "resolved", {
2494
+ url,
2495
+ operation,
2496
+ animationData,
2497
+ host
2498
+ });
1363
2499
  }
1364
2500
  renderLoadingPlaceholder(status, coverUrl, operation, signal) {
2501
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "called", {
2502
+ status,
2503
+ coverUrl,
2504
+ operation,
2505
+ signal
2506
+ });
1365
2507
  this.renderConfiguredFallback(status, false);
1366
- if (!coverUrl) return;
2508
+ if (!coverUrl) {
2509
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned no cover");
2510
+ return;
2511
+ }
1367
2512
  const cover = this.createImage();
1368
2513
  waitForElementEvent(cover, "load", "error", signal, this.loadTimeoutMs, () => {
1369
2514
  cover.src = coverUrl;
1370
2515
  }).then(() => {
2516
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.then", "called", {
2517
+ operation,
2518
+ cover
2519
+ });
1371
2520
  if (this.isCurrent(operation) && this.phase === "loading") this.container.replaceChildren(cover);
1372
- }).catch(() => {
2521
+ }).catch((error) => {
2522
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.catch", "called", {
2523
+ operation,
2524
+ error
2525
+ });
1373
2526
  if (this.isCurrent(operation) && this.phase === "loading") this.renderConfiguredFallback(status, false);
1374
2527
  });
2528
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned");
1375
2529
  }
1376
2530
  renderConfiguredFallback(status, report = true) {
2531
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "called", {
2532
+ status,
2533
+ report
2534
+ });
1377
2535
  const fallback = this.fallbacks?.[status];
1378
2536
  if (!fallback) {
1379
2537
  this.container.replaceChildren();
2538
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", { result: false });
1380
2539
  return false;
1381
2540
  }
1382
2541
  this.renderFallback(status, fallback, report);
2542
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
2543
+ result: true,
2544
+ fallback
2545
+ });
1383
2546
  return true;
1384
2547
  }
1385
2548
  renderFallback(status, fallback, report = true) {
2549
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "called", {
2550
+ status,
2551
+ fallback,
2552
+ report
2553
+ });
1386
2554
  if (report) {
1387
2555
  this.phase = "fallback";
1388
2556
  this.mediaKind = fallback.kind;
@@ -1399,8 +2567,10 @@ var DefaultDrivingExpressionPlayer = class {
1399
2567
  status,
1400
2568
  kind: fallback.kind
1401
2569
  });
2570
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "returned", { snapshot: this.getSnapshot() });
1402
2571
  }
1403
2572
  renderEmoji(text) {
2573
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "called", { text });
1404
2574
  const emoji = this.document.createElement("span");
1405
2575
  emoji.textContent = text;
1406
2576
  emoji.setAttribute("role", "img");
@@ -1416,9 +2586,19 @@ var DefaultDrivingExpressionPlayer = class {
1416
2586
  width: "100%"
1417
2587
  });
1418
2588
  this.container.replaceChildren(emoji);
2589
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "returned", { emoji });
1419
2590
  }
1420
2591
  markReady(status, kind, startedAt, operation) {
1421
- if (!this.isCurrent(operation) || this.failedOperation === operation) return;
2592
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "called", {
2593
+ status,
2594
+ kind,
2595
+ startedAt,
2596
+ operation
2597
+ });
2598
+ if (!this.isCurrent(operation) || this.failedOperation === operation) {
2599
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "ignored");
2600
+ return;
2601
+ }
1422
2602
  this.phase = "ready";
1423
2603
  this.mediaKind = kind;
1424
2604
  this.errorCategory = null;
@@ -1428,9 +2608,21 @@ var DefaultDrivingExpressionPlayer = class {
1428
2608
  kind,
1429
2609
  elapsedMs: Math.max(0, Date.now() - startedAt)
1430
2610
  });
2611
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "returned", this.getSnapshot());
1431
2612
  }
1432
2613
  handleFailure(status, media, error, category, operation, scheduleRetry = true) {
1433
- if (!this.isCurrent(operation) || this.failedOperation === operation) return;
2614
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "called", {
2615
+ status,
2616
+ media,
2617
+ error,
2618
+ category,
2619
+ operation,
2620
+ scheduleRetry
2621
+ });
2622
+ if (!this.isCurrent(operation) || this.failedOperation === operation) {
2623
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "ignored");
2624
+ return;
2625
+ }
1434
2626
  this.failedOperation = operation;
1435
2627
  this.stopActiveVideo();
1436
2628
  this.phase = "error";
@@ -1442,22 +2634,51 @@ var DefaultDrivingExpressionPlayer = class {
1442
2634
  category,
1443
2635
  message: safeErrorMessage(error)
1444
2636
  });
1445
- if (!this.renderConfiguredFallback(status)) {
2637
+ const fallbackApplied = this.renderConfiguredFallback(status);
2638
+ if (!fallbackApplied) {
1446
2639
  this.phase = "error";
1447
2640
  this.errorCategory = category;
1448
2641
  }
1449
2642
  if (scheduleRetry && media !== null) this.scheduleRetry(status, media, operation);
2643
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "returned", {
2644
+ fallbackApplied,
2645
+ snapshot: this.getSnapshot()
2646
+ });
1450
2647
  }
1451
2648
  scheduleRetry(status, media, failedOperation) {
1452
- if (this.destroyed || this.paused || !this.isCurrent(failedOperation)) return;
2649
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "called", {
2650
+ status,
2651
+ media,
2652
+ failedOperation
2653
+ });
2654
+ if (this.destroyed || this.paused || !this.isCurrent(failedOperation)) {
2655
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "ignored");
2656
+ return;
2657
+ }
1453
2658
  this.retryTimer = globalThis.setTimeout(() => {
2659
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "called", {
2660
+ status,
2661
+ media,
2662
+ failedOperation
2663
+ });
1454
2664
  this.retryTimer = void 0;
1455
- if (this.destroyed || this.paused || this.status !== status || !this.isCurrent(failedOperation)) return;
2665
+ if (this.destroyed || this.paused || this.status !== status || !this.isCurrent(failedOperation)) {
2666
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "ignored");
2667
+ return;
2668
+ }
1456
2669
  const operation = this.beginOperation();
1457
2670
  this.load(status, media, operation);
1458
2671
  }, this.retryBackoffMs);
2672
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "scheduled", {
2673
+ retryTimer: this.retryTimer,
2674
+ retryBackoffMs: this.retryBackoffMs
2675
+ });
1459
2676
  }
1460
2677
  startPreloading(currentStatus, operation) {
2678
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "called", {
2679
+ currentStatus,
2680
+ operation
2681
+ });
1461
2682
  this.preloadAbort?.abort();
1462
2683
  const preloadAbort = new AbortController();
1463
2684
  this.preloadAbort = preloadAbort;
@@ -1467,8 +2688,18 @@ var DefaultDrivingExpressionPlayer = class {
1467
2688
  ...CAR_RUNNING_STATUSES
1468
2689
  ].filter((status, index, all) => all.indexOf(status) === index);
1469
2690
  (async () => {
2691
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "started", {
2692
+ statuses,
2693
+ operation
2694
+ });
1470
2695
  for (const status of statuses) {
1471
- if (!this.isCurrent(operation) || preloadAbort.signal.aborted) return;
2696
+ if (!this.isCurrent(operation) || preloadAbort.signal.aborted) {
2697
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "cancelled", {
2698
+ status,
2699
+ operation
2700
+ });
2701
+ return;
2702
+ }
1472
2703
  const configured = this.config.states[status];
1473
2704
  if (configured === void 0 || status === currentStatus) continue;
1474
2705
  const media = normalizeMedia(configured);
@@ -1480,20 +2711,34 @@ var DefaultDrivingExpressionPlayer = class {
1480
2711
  image.src = hintUrl;
1481
2712
  });
1482
2713
  image.removeAttribute("src");
1483
- } catch {
2714
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preloaded", {
2715
+ status,
2716
+ hintUrl
2717
+ });
2718
+ } catch (error) {
2719
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preload failed", {
2720
+ status,
2721
+ hintUrl,
2722
+ error
2723
+ });
1484
2724
  if (preloadAbort.signal.aborted) return;
1485
2725
  }
1486
2726
  }
2727
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "completed", { operation });
1487
2728
  })();
2729
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "returned", { statuses });
1488
2730
  }
1489
2731
  createImage() {
2732
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "called");
1490
2733
  const image = this.document.createElement("img");
1491
2734
  image.alt = "";
1492
2735
  image.decoding = "async";
1493
2736
  styleMediaElement(image, this.fit);
2737
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "returned", { image });
1494
2738
  return image;
1495
2739
  }
1496
2740
  getReusableVideo() {
2741
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "called", { hasReusableVideo: this.reusableVideo !== null });
1497
2742
  if (!this.reusableVideo) {
1498
2743
  this.reusableVideo = this.document.createElement("video");
1499
2744
  this.reusableVideo.muted = true;
@@ -1503,52 +2748,105 @@ var DefaultDrivingExpressionPlayer = class {
1503
2748
  this.reusableVideo.setAttribute("playsinline", "");
1504
2749
  styleMediaElement(this.reusableVideo, this.fit);
1505
2750
  }
2751
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "returned", { video: this.reusableVideo });
1506
2752
  return this.reusableVideo;
1507
2753
  }
1508
2754
  attachActiveVideoFailureListeners(video, status, media, operation) {
2755
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "called", {
2756
+ video,
2757
+ status,
2758
+ media,
2759
+ operation
2760
+ });
1509
2761
  this.detachActiveVideoFailureListeners();
1510
2762
  let attached = true;
1511
2763
  const cleanup = () => {
1512
- if (!attached) return;
2764
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "called", { attached });
2765
+ if (!attached) {
2766
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "ignored");
2767
+ return;
2768
+ }
1513
2769
  attached = false;
1514
2770
  video.removeEventListener("error", handleError);
1515
2771
  video.removeEventListener("stalled", handleStalled);
1516
2772
  if (this.activeVideoListenersCleanup === cleanup) this.activeVideoListenersCleanup = null;
2773
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "returned");
1517
2774
  };
1518
2775
  const failed = (category, event) => {
2776
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerFailed", "called", {
2777
+ category,
2778
+ event,
2779
+ attached
2780
+ });
1519
2781
  if (!attached) return;
1520
2782
  this.handleActiveVideoFailure(video, status, media, operation, category, new MediaPlayerError(category, `${event.type} after video playback started`));
1521
2783
  };
1522
- const handleError = (event) => failed("decode", event);
1523
- const handleStalled = (event) => failed("network", event);
2784
+ const handleError = (event) => {
2785
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleVideoError", "called", { event });
2786
+ failed("decode", event);
2787
+ };
2788
+ const handleStalled = (event) => {
2789
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleVideoStalled", "called", { event });
2790
+ failed("network", event);
2791
+ };
1524
2792
  video.addEventListener("error", handleError);
1525
2793
  video.addEventListener("stalled", handleStalled);
1526
2794
  this.activeVideoListenersCleanup = cleanup;
2795
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "returned");
1527
2796
  }
1528
2797
  handleActiveVideoFailure(video, status, media, operation, category, error) {
1529
- if (this.activeVideo !== video || !this.isCurrent(operation)) return;
2798
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "called", {
2799
+ video,
2800
+ status,
2801
+ media,
2802
+ operation,
2803
+ category,
2804
+ error
2805
+ });
2806
+ if (this.activeVideo !== video || !this.isCurrent(operation)) {
2807
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "ignored");
2808
+ return;
2809
+ }
1530
2810
  this.stopActiveVideo();
1531
2811
  this.handleFailure(status, media, error, category, operation);
2812
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "returned");
1532
2813
  }
1533
2814
  detachActiveVideoFailureListeners() {
2815
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "called");
1534
2816
  const cleanup = this.activeVideoListenersCleanup;
1535
2817
  this.activeVideoListenersCleanup = null;
1536
2818
  cleanup?.();
2819
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "returned");
1537
2820
  }
1538
2821
  stopActiveVideo() {
2822
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "called", { activeVideo: this.activeVideo });
1539
2823
  this.detachActiveVideoFailureListeners();
1540
- if (!this.activeVideo) return;
2824
+ if (!this.activeVideo) {
2825
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned no active video");
2826
+ return;
2827
+ }
1541
2828
  resetVideo(this.activeVideo);
1542
2829
  this.activeVideo = null;
2830
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned");
1543
2831
  }
1544
2832
  releaseActiveMedia() {
2833
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "called", {
2834
+ activeVideo: this.activeVideo,
2835
+ activeTgs: this.activeTgs
2836
+ });
1545
2837
  this.stopActiveVideo();
1546
2838
  if (this.activeTgs) {
1547
2839
  safeDestroy(this.activeTgs);
1548
2840
  this.activeTgs = null;
1549
2841
  }
2842
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "returned");
1550
2843
  }
1551
2844
  cancelPendingWork() {
2845
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "called", {
2846
+ hasLoad: this.loadAbort !== null,
2847
+ hasPreload: this.preloadAbort !== null,
2848
+ retryTimer: this.retryTimer
2849
+ });
1552
2850
  this.loadAbort?.abort();
1553
2851
  this.loadAbort = null;
1554
2852
  this.detachActiveVideoFailureListeners();
@@ -1559,22 +2857,46 @@ var DefaultDrivingExpressionPlayer = class {
1559
2857
  globalThis.clearTimeout(this.retryTimer);
1560
2858
  this.retryTimer = void 0;
1561
2859
  }
2860
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "returned");
1562
2861
  }
1563
2862
  isCurrent(operation) {
1564
- return !this.destroyed && !this.paused && operation === this.operation;
2863
+ const result = !this.destroyed && !this.paused && operation === this.operation;
2864
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.isCurrent", "returned", {
2865
+ operation,
2866
+ currentOperation: this.operation,
2867
+ destroyed: this.destroyed,
2868
+ paused: this.paused,
2869
+ result
2870
+ });
2871
+ return result;
1565
2872
  }
1566
2873
  emitDiagnostic(event) {
1567
- if (!this.onDiagnostic) return;
2874
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "called", {
2875
+ event,
2876
+ hasListener: this.onDiagnostic !== void 0
2877
+ });
2878
+ if (!this.onDiagnostic) {
2879
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned no listener");
2880
+ return;
2881
+ }
1568
2882
  try {
1569
2883
  this.onDiagnostic(event);
1570
- } catch {}
2884
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned", { event });
2885
+ } catch (error) {
2886
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "listener threw", error);
2887
+ }
1571
2888
  }
1572
2889
  };
1573
2890
  var MediaPlayerError = class extends Error {
1574
2891
  constructor(category, message) {
2892
+ dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "called", {
2893
+ category,
2894
+ message
2895
+ });
1575
2896
  super(message);
1576
2897
  this.name = "MediaPlayerError";
1577
2898
  this.category = category;
2899
+ dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "created", { error: this });
1578
2900
  }
1579
2901
  };
1580
2902
  const SUPPORTED_TGS_CONTENT_TYPES = /* @__PURE__ */ new Set([
@@ -1584,11 +2906,19 @@ const SUPPORTED_TGS_CONTENT_TYPES = /* @__PURE__ */ new Set([
1584
2906
  "application/x-gzip",
1585
2907
  "application/x-tgsticker"
1586
2908
  ]);
1587
- const normalizeMedia = (media) => typeof media === "string" ? {
1588
- kind: "image",
1589
- url: media
1590
- } : media;
2909
+ const normalizeMedia = (media) => {
2910
+ const result = typeof media === "string" ? {
2911
+ kind: "image",
2912
+ url: media
2913
+ } : media;
2914
+ dialSdkDebugWarn(DEBUG_MODULE, "normalizeMedia", "returned", {
2915
+ media,
2916
+ result
2917
+ });
2918
+ return result;
2919
+ };
1591
2920
  const firstInvalidMediaUrl = (media) => {
2921
+ dialSdkDebugWarn(DEBUG_MODULE, "firstInvalidMediaUrl", "called", { media });
1592
2922
  let values;
1593
2923
  switch (media.kind) {
1594
2924
  case "emoji":
@@ -1605,75 +2935,129 @@ const firstInvalidMediaUrl = (media) => {
1605
2935
  values = [media.url, media.coverUrl];
1606
2936
  break;
1607
2937
  }
1608
- return values.find((value) => typeof value === "string" && !isPublicDrivingMediaUrl(value)) ?? null;
2938
+ const result = values.find((value) => typeof value === "string" && !isPublicDrivingMediaUrl(value)) ?? null;
2939
+ dialSdkDebugWarn(DEBUG_MODULE, "firstInvalidMediaUrl", "returned", {
2940
+ values,
2941
+ result
2942
+ });
2943
+ return result;
1609
2944
  };
1610
2945
  const mediaPreloadHint = (media) => {
2946
+ dialSdkDebugWarn(DEBUG_MODULE, "mediaPreloadHint", "called", { media });
2947
+ let result;
1611
2948
  switch (media.kind) {
1612
- case "image": return media.url;
2949
+ case "image":
2950
+ result = media.url;
2951
+ break;
1613
2952
  case "video":
1614
- case "tgs": return media.coverUrl;
1615
- case "live_photo": return media.coverUrl;
1616
- case "emoji": return;
1617
- }
1618
- };
1619
- const waitForElementEvent = (element, successEvent, failureEvent, signal, timeoutMs, start) => new Promise((resolve, reject) => {
1620
- let timer;
1621
- const cleanup = () => {
1622
- element.removeEventListener(successEvent, handleSuccess);
1623
- element.removeEventListener(failureEvent, handleFailure);
1624
- signal.removeEventListener("abort", handleAbort);
1625
- if (timer !== void 0) globalThis.clearTimeout(timer);
1626
- };
1627
- const handleSuccess = () => {
1628
- cleanup();
1629
- resolve();
1630
- };
1631
- const handleFailure = () => {
1632
- cleanup();
1633
- reject(new MediaPlayerError("decode", `${failureEvent} while loading media`));
1634
- };
1635
- const handleAbort = () => {
1636
- cleanup();
1637
- reject(createAbortError());
1638
- };
1639
- element.addEventListener(successEvent, handleSuccess, { once: true });
1640
- element.addEventListener(failureEvent, handleFailure, { once: true });
1641
- signal.addEventListener("abort", handleAbort, { once: true });
1642
- timer = globalThis.setTimeout(() => {
1643
- cleanup();
1644
- reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
1645
- }, timeoutMs);
1646
- try {
1647
- start();
1648
- } catch (error) {
1649
- cleanup();
1650
- reject(error);
2953
+ case "tgs":
2954
+ result = media.coverUrl;
2955
+ break;
2956
+ case "live_photo":
2957
+ result = media.coverUrl;
2958
+ break;
2959
+ case "emoji":
2960
+ result = void 0;
2961
+ break;
1651
2962
  }
1652
- });
1653
- const withTimeout = (promise, timeoutMs, signal) => new Promise((resolve, reject) => {
1654
- let timer;
1655
- const cleanup = () => {
1656
- signal.removeEventListener("abort", handleAbort);
1657
- if (timer !== void 0) globalThis.clearTimeout(timer);
1658
- };
1659
- const handleAbort = () => {
1660
- cleanup();
1661
- reject(createAbortError());
1662
- };
1663
- signal.addEventListener("abort", handleAbort, { once: true });
1664
- timer = globalThis.setTimeout(() => {
1665
- cleanup();
1666
- reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
1667
- }, timeoutMs);
1668
- promise.then((value) => {
1669
- cleanup();
1670
- resolve(value);
1671
- }, (error) => {
1672
- cleanup();
1673
- reject(error);
2963
+ dialSdkDebugWarn(DEBUG_MODULE, "mediaPreloadHint", "returned", { result });
2964
+ return result;
2965
+ };
2966
+ const waitForElementEvent = (element, successEvent, failureEvent, signal, timeoutMs, start) => {
2967
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "called", {
2968
+ element,
2969
+ successEvent,
2970
+ failureEvent,
2971
+ signal,
2972
+ timeoutMs
1674
2973
  });
1675
- });
2974
+ const result = new Promise((resolve, reject) => {
2975
+ let timer;
2976
+ const cleanup = () => {
2977
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.cleanup", "called", { timer });
2978
+ element.removeEventListener(successEvent, handleSuccess);
2979
+ element.removeEventListener(failureEvent, handleFailure);
2980
+ signal.removeEventListener("abort", handleAbort);
2981
+ if (timer !== void 0) globalThis.clearTimeout(timer);
2982
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.cleanup", "returned");
2983
+ };
2984
+ const handleSuccess = () => {
2985
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleSuccess", "called", { successEvent });
2986
+ cleanup();
2987
+ resolve();
2988
+ };
2989
+ const handleFailure = () => {
2990
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleFailure", "called", { failureEvent });
2991
+ cleanup();
2992
+ reject(new MediaPlayerError("decode", `${failureEvent} while loading media`));
2993
+ };
2994
+ const handleAbort = () => {
2995
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleAbort", "called");
2996
+ cleanup();
2997
+ reject(createAbortError());
2998
+ };
2999
+ element.addEventListener(successEvent, handleSuccess, { once: true });
3000
+ element.addEventListener(failureEvent, handleFailure, { once: true });
3001
+ signal.addEventListener("abort", handleAbort, { once: true });
3002
+ timer = globalThis.setTimeout(() => {
3003
+ dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.timeout", "called", { timeoutMs });
3004
+ cleanup();
3005
+ reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
3006
+ }, timeoutMs);
3007
+ try {
3008
+ start();
3009
+ } catch (error) {
3010
+ cleanup();
3011
+ reject(error);
3012
+ }
3013
+ });
3014
+ result.then(() => dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "resolved"), (error) => dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "rejected", error));
3015
+ return result;
3016
+ };
3017
+ const withTimeout = (promise, timeoutMs, signal) => {
3018
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "called", {
3019
+ promise,
3020
+ timeoutMs,
3021
+ signal
3022
+ });
3023
+ const result = new Promise((resolve, reject) => {
3024
+ let timer;
3025
+ const cleanup = () => {
3026
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.cleanup", "called", { timer });
3027
+ signal.removeEventListener("abort", handleAbort);
3028
+ if (timer !== void 0) globalThis.clearTimeout(timer);
3029
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.cleanup", "returned");
3030
+ };
3031
+ const handleAbort = () => {
3032
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.handleAbort", "called");
3033
+ cleanup();
3034
+ reject(createAbortError());
3035
+ };
3036
+ signal.addEventListener("abort", handleAbort, { once: true });
3037
+ timer = globalThis.setTimeout(() => {
3038
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.timeout", "called", { timeoutMs });
3039
+ cleanup();
3040
+ reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
3041
+ }, timeoutMs);
3042
+ promise.then((value) => {
3043
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.promiseResolved", "called", { value });
3044
+ cleanup();
3045
+ resolve(value);
3046
+ }, (error) => {
3047
+ dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.promiseRejected", "called", { error });
3048
+ cleanup();
3049
+ reject(error);
3050
+ });
3051
+ });
3052
+ result.then((value) => dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "resolved", { value }), (error) => dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "rejected", error));
3053
+ return result;
3054
+ };
1676
3055
  const defaultTgsRenderer = async (container, animationData, signal) => {
3056
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "called", {
3057
+ container,
3058
+ animationData,
3059
+ signal
3060
+ });
1677
3061
  if (signal.aborted) throw createAbortError();
1678
3062
  const module = await import("lottie-web/build/player/lottie_light.js");
1679
3063
  if (signal.aborted) throw createAbortError();
@@ -1687,47 +3071,80 @@ const defaultTgsRenderer = async (container, animationData, signal) => {
1687
3071
  });
1688
3072
  await new Promise((resolve, reject) => {
1689
3073
  const ready = () => {
3074
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.ready", "called");
1690
3075
  cleanup();
1691
3076
  resolve();
1692
3077
  };
1693
3078
  const failed = () => {
3079
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.failed", "called");
1694
3080
  cleanup();
1695
3081
  reject(new MediaPlayerError("decode", "Lottie could not initialize the TGS animation"));
1696
3082
  };
1697
3083
  const aborted = () => {
3084
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.aborted", "called");
1698
3085
  cleanup();
1699
3086
  animation.destroy();
1700
3087
  reject(createAbortError());
1701
3088
  };
1702
3089
  const cleanup = () => {
3090
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "called");
1703
3091
  animation.removeEventListener("DOMLoaded", ready);
1704
3092
  animation.removeEventListener("data_failed", failed);
1705
3093
  signal.removeEventListener("abort", aborted);
3094
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "returned");
1706
3095
  };
1707
3096
  animation.addEventListener("DOMLoaded", ready);
1708
3097
  animation.addEventListener("data_failed", failed);
1709
3098
  signal.addEventListener("abort", aborted, { once: true });
1710
3099
  });
1711
- return {
1712
- destroy: () => animation.destroy(),
1713
- pause: () => animation.pause(),
1714
- play: () => animation.play(),
1715
- restart: () => animation.goToAndPlay(0, true)
3100
+ const result = {
3101
+ destroy: () => {
3102
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.destroy", "called");
3103
+ animation.destroy();
3104
+ },
3105
+ pause: () => {
3106
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.pause", "called");
3107
+ animation.pause();
3108
+ },
3109
+ play: () => {
3110
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.play", "called");
3111
+ animation.play();
3112
+ },
3113
+ restart: () => {
3114
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.restart", "called");
3115
+ animation.goToAndPlay(0, true);
3116
+ }
1716
3117
  };
3118
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "resolved", { result });
3119
+ return result;
1717
3120
  };
1718
3121
  function validateTgsAnimation(value, maxLayers) {
3122
+ dialSdkDebugWarn(DEBUG_MODULE, "validateTgsAnimation", "called", {
3123
+ value,
3124
+ maxLayers
3125
+ });
1719
3126
  if (!isRecord(value) || !Array.isArray(value.layers)) throw new MediaPlayerError("decode", "TGS animation does not contain a layers array");
1720
3127
  if (value.layers.length > maxLayers) throw new MediaPlayerError("decode", "TGS animation has too many layers");
1721
3128
  if (typeof value.fr === "number" && (!Number.isFinite(value.fr) || value.fr <= 0 || value.fr > 120)) throw new MediaPlayerError("decode", "TGS animation frame rate is outside the supported range");
1722
3129
  if (typeof value.ip === "number" && typeof value.op === "number" && (value.op <= value.ip || value.op - value.ip > 3e4)) throw new MediaPlayerError("decode", "TGS animation duration is outside the supported range");
3130
+ dialSdkDebugWarn(DEBUG_MODULE, "validateTgsAnimation", "returned");
1723
3131
  }
1724
3132
  const gunzipWithLimit = (compressed, maxOutputBytes) => {
3133
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "called", {
3134
+ compressed,
3135
+ maxOutputBytes
3136
+ });
1725
3137
  if (compressed.byteLength < 18) throw new MediaPlayerError("decode", "TGS gzip payload is truncated");
1726
3138
  if (new DataView(compressed.buffer, compressed.byteOffset + compressed.byteLength - 4, 4).getUint32(0, true) > maxOutputBytes) throw new MediaPlayerError("decode", "TGS JSON payload exceeds the configured limit");
1727
3139
  const chunks = [];
1728
3140
  let outputBytes = 0;
1729
3141
  try {
1730
3142
  const gunzip = new Gunzip((chunk) => {
3143
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit.onChunk", "called", {
3144
+ chunk,
3145
+ outputBytes,
3146
+ maxOutputBytes
3147
+ });
1731
3148
  outputBytes += chunk.byteLength;
1732
3149
  if (outputBytes > maxOutputBytes) throw new MediaPlayerError("decode", "TGS JSON payload exceeds the configured limit");
1733
3150
  if (chunk.byteLength > 0) chunks.push(chunk);
@@ -1738,8 +3155,11 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
1738
3155
  gunzip.push(compressed.subarray(offset, end), end === compressed.byteLength);
1739
3156
  }
1740
3157
  } catch (error) {
3158
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "caught error", error);
1741
3159
  if (error instanceof MediaPlayerError) throw error;
1742
- throw new MediaPlayerError("decode", "TGS gzip decompression failed");
3160
+ const wrapped = new MediaPlayerError("decode", "TGS gzip decompression failed");
3161
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "threw", wrapped);
3162
+ throw wrapped;
1743
3163
  }
1744
3164
  const output = new Uint8Array(outputBytes);
1745
3165
  let offset = 0;
@@ -1747,17 +3167,29 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
1747
3167
  output.set(chunk, offset);
1748
3168
  offset += chunk.byteLength;
1749
3169
  }
3170
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "returned", {
3171
+ output,
3172
+ outputBytes
3173
+ });
1750
3174
  return output;
1751
3175
  };
1752
3176
  const resetVideo = (video) => {
3177
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "called", { video });
1753
3178
  video.pause();
1754
3179
  video.removeAttribute("src");
1755
3180
  video.removeAttribute("type");
1756
3181
  try {
1757
3182
  video.load();
1758
- } catch {}
3183
+ } catch (error) {
3184
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "load threw", error);
3185
+ }
3186
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "returned", { video });
1759
3187
  };
1760
3188
  const styleMediaElement = (element, fit) => {
3189
+ dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "called", {
3190
+ element,
3191
+ fit
3192
+ });
1761
3193
  Object.assign(element.style, {
1762
3194
  display: "block",
1763
3195
  height: "100%",
@@ -1766,40 +3198,86 @@ const styleMediaElement = (element, fit) => {
1766
3198
  objectFit: fit,
1767
3199
  width: "100%"
1768
3200
  });
3201
+ dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "returned", { element });
1769
3202
  };
1770
3203
  const categorizeMediaError = (error) => {
1771
- if (error instanceof MediaPlayerError) return error.category;
1772
- if (error instanceof TypeError) return "network";
1773
- return "decode";
3204
+ const result = error instanceof MediaPlayerError ? error.category : error instanceof TypeError ? "network" : "decode";
3205
+ dialSdkDebugWarn(DEBUG_MODULE, "categorizeMediaError", "returned", {
3206
+ error,
3207
+ result
3208
+ });
3209
+ return result;
1774
3210
  };
1775
3211
  const safeErrorMessage = (error) => {
3212
+ dialSdkDebugWarn(DEBUG_MODULE, "safeErrorMessage", "called", { error });
1776
3213
  const message = error instanceof Error ? error.message : String(error);
1777
- return redactUrlQueries(message).slice(0, 240);
3214
+ const result = redactUrlQueries(message).slice(0, 240);
3215
+ dialSdkDebugWarn(DEBUG_MODULE, "safeErrorMessage", "returned", { result });
3216
+ return result;
3217
+ };
3218
+ const redactUrlQueries = (message) => {
3219
+ dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries", "called", { message });
3220
+ const result = message.replace(/https:\/\/[^\s"'<>]+/gu, (candidate) => {
3221
+ dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries.replace", "called", { candidate });
3222
+ try {
3223
+ const url = new URL(candidate);
3224
+ return `${url.origin}${url.pathname}`;
3225
+ } catch {
3226
+ return "[url]";
3227
+ }
3228
+ });
3229
+ dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries", "returned", { result });
3230
+ return result;
1778
3231
  };
1779
- const redactUrlQueries = (message) => message.replace(/https:\/\/[^\s"'<>]+/gu, (candidate) => {
1780
- try {
1781
- const url = new URL(candidate);
1782
- return `${url.origin}${url.pathname}`;
1783
- } catch {
1784
- return "[url]";
1785
- }
1786
- });
1787
3232
  const createAbortError = () => {
1788
- if (typeof DOMException !== "undefined") return new DOMException("Aborted", "AbortError");
3233
+ dialSdkDebugWarn(DEBUG_MODULE, "createAbortError", "called");
3234
+ if (typeof DOMException !== "undefined") {
3235
+ const result = new DOMException("Aborted", "AbortError");
3236
+ dialSdkDebugWarn(DEBUG_MODULE, "createAbortError", "returned DOMException", { result });
3237
+ return result;
3238
+ }
1789
3239
  const error = /* @__PURE__ */ new Error("Aborted");
1790
3240
  error.name = "AbortError";
3241
+ dialSdkDebugWarn(DEBUG_MODULE, "createAbortError", "returned Error", { result: error });
1791
3242
  return error;
1792
3243
  };
1793
- const isAbortError = (error) => error instanceof Error && error.name === "AbortError";
3244
+ const isAbortError = (error) => {
3245
+ const result = error instanceof Error && error.name === "AbortError";
3246
+ dialSdkDebugWarn(DEBUG_MODULE, "isAbortError", "returned", {
3247
+ error,
3248
+ result
3249
+ });
3250
+ return result;
3251
+ };
1794
3252
  const positiveFinite = (name, value) => {
1795
- if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be a positive finite number`);
3253
+ dialSdkDebugWarn(DEBUG_MODULE, "positiveFinite", "called", {
3254
+ name,
3255
+ value
3256
+ });
3257
+ if (!Number.isFinite(value) || value <= 0) {
3258
+ const error = /* @__PURE__ */ new RangeError(`${name} must be a positive finite number`);
3259
+ dialSdkDebugWarn(DEBUG_MODULE, "positiveFinite", "threw", error);
3260
+ throw error;
3261
+ }
3262
+ dialSdkDebugWarn(DEBUG_MODULE, "positiveFinite", "returned", { result: value });
1796
3263
  return value;
1797
3264
  };
1798
3265
  const safeDestroy = (handle) => {
3266
+ dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "called", { handle });
1799
3267
  try {
1800
3268
  handle.destroy();
1801
- } catch {}
3269
+ dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "returned");
3270
+ } catch (error) {
3271
+ dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "destroy threw", error);
3272
+ }
3273
+ };
3274
+ const isRecord = (value) => {
3275
+ const result = typeof value === "object" && value !== null && !Array.isArray(value);
3276
+ dialSdkDebugWarn(DEBUG_MODULE, "isRecord", "returned", {
3277
+ value,
3278
+ result
3279
+ });
3280
+ return result;
1802
3281
  };
1803
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1804
3282
  //#endregion
1805
3283
  export { BATTERY_HEALTH_LABELS, CAR_RUNNING_LABELS, CAR_RUNNING_STATUSES, CAR_RUNNING_STATUS_PRIORITY, DEFAULT_DRIVING_STATUS_TUNING, DrivingExpressionResolutionError, DrivingExpressionsConfigError, OFFICIAL_DRIVING_EXPRESSIONS_CONFIG, OFFICIAL_DRIVING_EXPRESSION_FALLBACKS, checkRunningStatus, classifyDrivingMetrics, classifyDrivingSnapshot, createDrivingExpressionPlayer, createDrivingStatusController, extractDrivingSnapshotMetrics, isPublicDrivingMediaUrl, parseDrivingExpressionsConfig, readDrivingExpressionsConfig, resolveDrivingExpression, resolveDrivingExpressionStrict, resolveDrivingStatusTuning, tryParseDrivingExpressionsConfig, unifiedSensorInfo, waitForDrivingExpressionsConfig };