@ziztechnology/dial-library 0.0.4 → 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.
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,39 +430,221 @@ 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;
444
+ };
445
+ /**
446
+ * Waits for a valid Runtime-injected configuration using bounded polling.
447
+ * It never installs official fallbacks implicitly.
448
+ */
449
+ const waitForDrivingExpressionsConfig = (options = {}) => {
450
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig", "called", { options });
451
+ const timeoutMs = requireNonNegativeFinite("timeoutMs", options.timeoutMs ?? 3e3);
452
+ const pollIntervalMs = requirePositiveFinite$1("pollIntervalMs", options.pollIntervalMs ?? 100);
453
+ const { signal } = options;
454
+ return new Promise((resolve, reject) => {
455
+ const deadlineMs = Date.now() + timeoutMs;
456
+ let timer;
457
+ let settled = false;
458
+ const cleanup = () => {
459
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.cleanup", "called", {
460
+ timer,
461
+ settled
462
+ });
463
+ if (timer !== void 0) {
464
+ globalThis.clearTimeout(timer);
465
+ timer = void 0;
466
+ }
467
+ signal?.removeEventListener("abort", handleAbort);
468
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.cleanup", "returned");
469
+ };
470
+ const finish = (config) => {
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
+ }
479
+ settled = true;
480
+ cleanup();
481
+ resolve(config);
482
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.finish", "resolved", { config });
483
+ };
484
+ const fail = (error) => {
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
+ }
493
+ settled = true;
494
+ cleanup();
495
+ reject(error);
496
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.fail", "rejected", error);
497
+ };
498
+ const handleAbort = () => {
499
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.handleAbort", "called");
500
+ fail(createAbortError$1());
501
+ };
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
+ };
508
+ const poll = () => {
509
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.poll", "called", { settled });
510
+ if (settled) {
511
+ dialSdkDebugWarn(DEBUG_MODULE$3, "waitForDrivingExpressionsConfig.poll", "ignored");
512
+ return;
513
+ }
514
+ if (signal?.aborted) {
515
+ handleAbort();
516
+ return;
517
+ }
518
+ const config = read();
519
+ if (config !== null) {
520
+ finish(config);
521
+ return;
522
+ }
523
+ const remainingMs = deadlineMs - Date.now();
524
+ if (remainingMs <= 0) {
525
+ finish(null);
526
+ return;
527
+ }
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
+ });
533
+ };
534
+ signal?.addEventListener("abort", handleAbort, { once: true });
535
+ poll();
536
+ });
258
537
  };
259
538
  /** Original resolver behavior: missing legacy slots fall back to STEADY_DRIVING. */
260
- 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
+ };
261
548
  /** Strict resolver used by the player; official fallbacks are opt-in. */
262
549
  const resolveDrivingExpressionStrict = (config, status, fallbacks) => {
550
+ dialSdkDebugWarn(DEBUG_MODULE$3, "resolveDrivingExpressionStrict", "called", {
551
+ config,
552
+ status,
553
+ fallbacks
554
+ });
263
555
  const configured = config.states[status];
264
- 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
+ }
265
560
  const fallback = fallbacks?.[status];
266
- if (fallback !== void 0) return fallback;
267
- 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;
268
568
  };
269
569
  const isPublicDrivingMediaUrl = (value) => {
570
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "called", { value });
270
571
  try {
271
572
  const url = new URL(value);
272
- if (url.protocol !== "https:" || url.username !== "" || url.password !== "") return false;
273
- if (!isPublicHostname(url.hostname)) return false;
274
- 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 });
275
596
  return true;
276
- } catch {
597
+ } catch (error) {
598
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicDrivingMediaUrl", "returned after URL parse error", {
599
+ result: false,
600
+ error
601
+ });
277
602
  return false;
278
603
  }
279
604
  };
280
605
  const isPublicHostname = (rawHostname) => {
606
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "called", { rawHostname });
281
607
  const hostname = rawHostname.toLowerCase().replace(/^\[|\]$/gu, "").replace(/\.+$/gu, "");
282
- if (hostname === "") return false;
608
+ if (hostname === "") {
609
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isPublicHostname", "returned", {
610
+ result: false,
611
+ hostname
612
+ });
613
+ return false;
614
+ }
283
615
  const ipv4 = parseIpv4(hostname);
284
- 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
+ }
285
625
  const ipv6 = parseIpv6(hostname);
286
- if (ipv6 !== null) return !isRestrictedIpv6(ipv6);
287
- if (!hostname.includes(".")) return false;
288
- 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;
289
648
  };
290
649
  const INTERNAL_HOST_SUFFIXES = [
291
650
  "corp",
@@ -300,57 +659,108 @@ const INTERNAL_HOST_SUFFIXES = [
300
659
  "private"
301
660
  ];
302
661
  const parseIpv4 = (hostname) => {
662
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv4", "called", { hostname });
303
663
  const parts = hostname.split(".");
304
- 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
+ }
305
668
  const octets = parts.map(Number);
306
- if (octets.some((octet) => octet > 255)) return null;
307
- 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;
308
688
  };
309
- 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;
310
689
  const parseIpv6 = (hostname) => {
311
- 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
+ }
312
695
  let normalized = hostname;
313
696
  if (normalized.includes(".")) {
314
697
  const lastColon = normalized.lastIndexOf(":");
315
698
  const ipv4 = parseIpv4(normalized.slice(lastColon + 1));
316
- 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
+ }
317
703
  normalized = `${normalized.slice(0, lastColon)}:${(ipv4[0] << 8 | ipv4[1]).toString(16)}:${(ipv4[2] << 8 | ipv4[3]).toString(16)}`;
318
704
  }
319
705
  const halves = normalized.split("::");
320
- 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
+ }
321
713
  const left = halves[0] === "" ? [] : halves[0].split(":");
322
714
  const right = halves.length === 1 || halves[1] === "" ? [] : halves[1].split(":");
323
- 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
+ }
324
723
  const omitted = 8 - left.length - right.length;
325
- 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
+ }
326
731
  const groups = [
327
732
  ...left,
328
733
  ...Array.from({ length: omitted }, () => "0"),
329
734
  ...right
330
735
  ].map((part) => Number.parseInt(part, 16));
331
- 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
+ }
332
743
  const bytes = /* @__PURE__ */ new Uint8Array(16);
333
744
  groups.forEach((group, index) => {
334
745
  bytes[index * 2] = group >>> 8;
335
746
  bytes[index * 2 + 1] = group & 255;
336
747
  });
748
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseIpv6", "returned", { result: bytes });
337
749
  return bytes;
338
750
  };
339
751
  const isRestrictedIpv6 = (bytes) => {
340
- const allZeroPrefix = (length) => bytes.subarray(0, length).every((value) => value === 0);
341
- if (bytes.every((value) => value === 0)) return true;
342
- if (allZeroPrefix(15) && bytes[15] === 1) return true;
343
- if (allZeroPrefix(12)) return true;
344
- if (allZeroPrefix(10) && bytes[10] === 255 && bytes[11] === 255) return true;
345
- if (bytes[0] === 0 && bytes[1] === 100 && bytes[2] === 255 && bytes[3] === 155) return true;
346
- if ((bytes[0] & 254) === 252) return true;
347
- if (bytes[0] === 254 && (bytes[1] & 192) === 128) return true;
348
- if (bytes[0] === 255) return true;
349
- if (bytes[0] === 1 && bytes.subarray(1, 8).every((value) => value === 0)) return true;
350
- if (bytes[0] === 32 && bytes[1] === 1 && bytes[2] === 13 && bytes[3] === 184) return true;
351
- if (bytes[0] === 32 && bytes[1] === 1 && bytes[2] <= 1) return true;
352
- if (bytes[0] === 32 && bytes[1] === 2) return true;
353
- 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;
354
764
  };
355
765
  const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
356
766
  "expires",
@@ -386,12 +796,19 @@ const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
386
796
  "x-oss-signature"
387
797
  ]);
388
798
  const parseDrivingExpressionMedia = (raw, status, options) => {
799
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "called", {
800
+ raw,
801
+ status,
802
+ options
803
+ });
389
804
  if (typeof raw === "string" && options.allowLegacyImageUrls) {
390
805
  assertPublicUrl(raw, status, "url");
391
- return {
806
+ const result = {
392
807
  kind: "image",
393
808
  url: raw
394
809
  };
810
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned legacy image", { result });
811
+ return result;
395
812
  }
396
813
  if (!isRecord$1(raw) || typeof raw.kind !== "string") throw invalidMedia(status, "media must be a structured object with a supported kind");
397
814
  const mediaAssetId = parseMediaAssetId(raw.mediaAssetId, status);
@@ -401,7 +818,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
401
818
  "duration"
402
819
  ]);
403
820
  switch (raw.kind) {
404
- case "emoji":
821
+ case "emoji": {
405
822
  assertFieldsAbsent(raw, status, [
406
823
  "mediaAssetId",
407
824
  "url",
@@ -410,10 +827,13 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
410
827
  "mimeType"
411
828
  ]);
412
829
  if (typeof raw.text !== "string" || !isOneVisibleGrapheme(raw.text)) throw invalidMedia(status, "emoji.text must contain exactly one visible grapheme");
413
- return {
830
+ const result = {
414
831
  kind: "emoji",
415
832
  text: raw.text.trim()
416
833
  };
834
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned emoji", { result });
835
+ return result;
836
+ }
417
837
  case "image": {
418
838
  assertFieldsAbsent(raw, status, [
419
839
  "text",
@@ -422,25 +842,29 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
422
842
  ]);
423
843
  const url = parseRequiredUrl(raw.url, status, "url");
424
844
  const mimeType = parseOptionalString(raw.mimeType, status, "mimeType");
425
- return compact({
845
+ const result = compact({
426
846
  kind: "image",
427
847
  mediaAssetId,
428
848
  url,
429
849
  mimeType
430
850
  });
851
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned image", { result });
852
+ return result;
431
853
  }
432
854
  case "video": {
433
855
  assertFieldsAbsent(raw, status, ["text", "motionUrl"]);
434
856
  const url = parseRequiredUrl(raw.url, status, "url");
435
857
  const coverUrl = parseOptionalUrl(raw.coverUrl, status, "coverUrl");
436
858
  const mimeType = parseOptionalString(raw.mimeType, status, "mimeType");
437
- return compact({
859
+ const result = compact({
438
860
  kind: "video",
439
861
  mediaAssetId,
440
862
  url,
441
863
  coverUrl,
442
864
  mimeType
443
865
  });
866
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned video", { result });
867
+ return result;
444
868
  }
445
869
  case "live_photo": {
446
870
  assertFieldsAbsent(raw, status, [
@@ -450,12 +874,14 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
450
874
  ]);
451
875
  const coverUrl = parseRequiredUrl(raw.coverUrl, status, "coverUrl");
452
876
  const motionUrl = parseRequiredUrl(raw.motionUrl, status, "motionUrl");
453
- return compact({
877
+ const result = compact({
454
878
  kind: "live_photo",
455
879
  mediaAssetId,
456
880
  coverUrl,
457
881
  motionUrl
458
882
  });
883
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned live photo", { result });
884
+ return result;
459
885
  }
460
886
  case "tgs": {
461
887
  assertFieldsAbsent(raw, status, [
@@ -465,74 +891,228 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
465
891
  ]);
466
892
  const url = parseRequiredUrl(raw.url, status, "url");
467
893
  const coverUrl = parseOptionalUrl(raw.coverUrl, status, "coverUrl");
468
- return compact({
894
+ const result = compact({
469
895
  kind: "tgs",
470
896
  mediaAssetId,
471
897
  url,
472
898
  coverUrl
473
899
  });
900
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseDrivingExpressionMedia", "returned TGS", { result });
901
+ return result;
474
902
  }
475
903
  default: throw invalidMedia(status, `unsupported media kind: ${raw.kind}`);
476
904
  }
477
905
  };
478
906
  const parseJsonObject = (raw) => {
907
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseJsonObject", "called", { raw });
479
908
  let value = raw;
480
909
  if (typeof value === "string") try {
481
910
  value = JSON.parse(value);
482
- } catch {
483
- 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;
484
918
  }
485
- 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 });
486
925
  return value;
487
926
  };
488
927
  const readRuntimeDrivingExpressionsValue = () => {
928
+ dialSdkDebugWarn(DEBUG_MODULE$3, "readRuntimeDrivingExpressionsValue", "called");
489
929
  const runtimeGlobal = globalThis;
490
- 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
+ }
491
935
  const faceConfig = runtimeGlobal.__TOOOONY_FACE_CONFIG__;
492
- if (!isRecord$1(faceConfig)) return void 0;
493
- if (faceConfig.drivingExpressions !== void 0) return faceConfig.drivingExpressions;
494
- 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;
495
948
  };
496
949
  const parseMediaAssetId = (raw, status) => {
497
- 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
+ }
498
958
  if (!Number.isSafeInteger(raw) || raw <= 0) throw invalidMedia(status, "mediaAssetId must be a positive safe integer when present");
499
- return raw;
959
+ const result = raw;
960
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseMediaAssetId", "returned", { result });
961
+ return result;
500
962
  };
501
963
  const assertFieldsAbsent = (value, status, fields) => {
964
+ dialSdkDebugWarn(DEBUG_MODULE$3, "assertFieldsAbsent", "called", {
965
+ value,
966
+ status,
967
+ fields
968
+ });
502
969
  const present = fields.find((field) => Object.prototype.hasOwnProperty.call(value, field));
503
- 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");
504
976
  };
505
977
  const parseRequiredUrl = (raw, status, field) => {
506
- 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
+ }
507
988
  assertPublicUrl(raw, status, field);
989
+ dialSdkDebugWarn(DEBUG_MODULE$3, "parseRequiredUrl", "returned", { result: raw });
508
990
  return raw;
509
991
  };
510
992
  const parseOptionalUrl = (raw, status, field) => {
511
- if (raw === void 0) return void 0;
512
- 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;
513
1005
  };
514
1006
  const parseOptionalString = (raw, status, field) => {
515
- 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
+ }
516
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 });
517
1018
  return raw;
518
1019
  };
519
1020
  const assertPublicUrl = (value, status, field) => {
520
- 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");
521
1032
  };
522
1033
  const isOneVisibleGrapheme = (value) => {
1034
+ dialSdkDebugWarn(DEBUG_MODULE$3, "isOneVisibleGrapheme", "called", { value });
523
1035
  const trimmed = value.trim();
524
- 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
+ }
525
1043
  const Segmenter = Intl.Segmenter;
526
- 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;
527
1060
  };
528
- const invalidMedia = (status, detail) => new DrivingExpressionsConfigError("DRIVING_EXPRESSION_INVALID_MEDIA", `Invalid driving expression for ${status}: ${detail}`, status);
529
1061
  const compact = (value) => {
1062
+ dialSdkDebugWarn(DEBUG_MODULE$3, "compact", "called", { value });
530
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 });
1065
+ return value;
1066
+ };
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
+ };
1075
+ const requireNonNegativeFinite = (name, value) => {
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 });
1086
+ return value;
1087
+ };
1088
+ const requirePositiveFinite$1 = (name, value) => {
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 });
531
1099
  return value;
532
1100
  };
533
- const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1101
+ const createAbortError$1 = () => {
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
+ }
1108
+ const error = /* @__PURE__ */ new Error("The operation was aborted");
1109
+ error.name = "AbortError";
1110
+ dialSdkDebugWarn(DEBUG_MODULE$3, "createAbortError", "returned Error", { result: error });
1111
+ return error;
1112
+ };
534
1113
  //#endregion
535
1114
  //#region src/sensor/page_lifecycle.ts
1115
+ const DEBUG_MODULE$2 = "page_lifecycle.ts";
536
1116
  const subscribers = /* @__PURE__ */ new Set();
537
1117
  let installedWindow = null;
538
1118
  let installedDocument = null;
@@ -543,6 +1123,7 @@ let hadOwnResumeHook = false;
543
1123
  let pauseHook = null;
544
1124
  let resumeHook = null;
545
1125
  const subscribeDrivingPageLifecycle = (pause, resume) => {
1126
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle", "called", { subscriberCount: subscribers.size });
546
1127
  const subscriber = {
547
1128
  pause,
548
1129
  resume
@@ -551,15 +1132,29 @@ const subscribeDrivingPageLifecycle = (pause, resume) => {
551
1132
  if (subscribers.size === 1) installLifecycleHooks();
552
1133
  if (isDrivingPageHidden()) safeInvoke(pause);
553
1134
  let subscribed = true;
1135
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle", "subscribed", { subscriberCount: subscribers.size });
554
1136
  return () => {
555
- 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
+ }
556
1142
  subscribed = false;
557
1143
  subscribers.delete(subscriber);
558
1144
  if (subscribers.size === 0) uninstallLifecycleHooks();
1145
+ dialSdkDebugWarn(DEBUG_MODULE$2, "subscribeDrivingPageLifecycle.unsubscribe", "returned", { subscriberCount: subscribers.size });
559
1146
  };
560
1147
  };
561
- 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
+ };
562
1156
  const installLifecycleHooks = () => {
1157
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "called");
563
1158
  installedDocument = typeof document === "undefined" ? null : document;
564
1159
  installedWindow = typeof window === "undefined" ? null : window;
565
1160
  installedDocument?.addEventListener("visibilitychange", handleVisibilityChange);
@@ -569,29 +1164,43 @@ const installLifecycleHooks = () => {
569
1164
  installedWindow?.addEventListener("resume", dispatchResume);
570
1165
  installedWindow?.addEventListener("toooony-device-sensors-release", dispatchPause);
571
1166
  installedWindow?.addEventListener("toooony-device-sensors-resume", dispatchResume);
572
- if (!installedWindow) return;
1167
+ if (!installedWindow) {
1168
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "returned without window");
1169
+ return;
1170
+ }
573
1171
  hadOwnPauseHook = Object.prototype.hasOwnProperty.call(installedWindow, "__watchFaceRuntimePause");
574
1172
  hadOwnResumeHook = Object.prototype.hasOwnProperty.call(installedWindow, "__watchFaceRuntimeResume");
575
1173
  previousPauseHook = installedWindow.__watchFaceRuntimePause;
576
1174
  previousResumeHook = installedWindow.__watchFaceRuntimeResume;
577
1175
  pauseHook = function(...args) {
1176
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimePauseHook", "called", { args });
578
1177
  try {
579
- 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;
580
1181
  } finally {
581
1182
  dispatchPause();
582
1183
  }
583
1184
  };
584
1185
  resumeHook = function(...args) {
1186
+ dialSdkDebugWarn(DEBUG_MODULE$2, "runtimeResumeHook", "called", { args });
585
1187
  try {
586
- 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;
587
1191
  } finally {
588
1192
  dispatchResume();
589
1193
  }
590
1194
  };
591
1195
  installedWindow.__watchFaceRuntimePause = pauseHook;
592
1196
  installedWindow.__watchFaceRuntimeResume = resumeHook;
1197
+ dialSdkDebugWarn(DEBUG_MODULE$2, "installLifecycleHooks", "returned", {
1198
+ hadOwnPauseHook,
1199
+ hadOwnResumeHook
1200
+ });
593
1201
  };
594
1202
  const uninstallLifecycleHooks = () => {
1203
+ dialSdkDebugWarn(DEBUG_MODULE$2, "uninstallLifecycleHooks", "called");
595
1204
  installedDocument?.removeEventListener("visibilitychange", handleVisibilityChange);
596
1205
  installedWindow?.removeEventListener("pagehide", dispatchPause);
597
1206
  installedWindow?.removeEventListener("freeze", dispatchPause);
@@ -611,26 +1220,46 @@ const uninstallLifecycleHooks = () => {
611
1220
  hadOwnResumeHook = false;
612
1221
  pauseHook = null;
613
1222
  resumeHook = null;
1223
+ dialSdkDebugWarn(DEBUG_MODULE$2, "uninstallLifecycleHooks", "returned");
614
1224
  };
615
1225
  const handleVisibilityChange = () => {
1226
+ dialSdkDebugWarn(DEBUG_MODULE$2, "handleVisibilityChange", "called");
616
1227
  if (isDrivingPageHidden()) dispatchPause();
617
1228
  else dispatchResume();
1229
+ dialSdkDebugWarn(DEBUG_MODULE$2, "handleVisibilityChange", "returned");
618
1230
  };
619
1231
  const dispatchPause = () => {
1232
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchPause", "called", { subscriberCount: subscribers.size });
620
1233
  for (const subscriber of [...subscribers]) safeInvoke(subscriber.pause);
1234
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchPause", "returned");
621
1235
  };
622
1236
  const dispatchResume = () => {
623
- 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
+ }
624
1242
  for (const subscriber of [...subscribers]) safeInvoke(subscriber.resume);
1243
+ dialSdkDebugWarn(DEBUG_MODULE$2, "dispatchResume", "returned");
625
1244
  };
626
1245
  const safeInvoke = (callback) => {
1246
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "called");
627
1247
  try {
628
1248
  callback();
629
- } catch {}
1249
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "returned");
1250
+ } catch (error) {
1251
+ dialSdkDebugWarn(DEBUG_MODULE$2, "safeInvoke", "callback threw", error);
1252
+ }
630
1253
  };
631
1254
  //#endregion
632
1255
  //#region src/sensor/driving_status_controller.ts
633
- 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
+ };
634
1263
  var DefaultDrivingStatusController = class {
635
1264
  constructor(options) {
636
1265
  this.listeners = /* @__PURE__ */ new Set();
@@ -650,16 +1279,34 @@ var DefaultDrivingStatusController = class {
650
1279
  this.pendingRead = null;
651
1280
  this.unsubscribePageLifecycle = null;
652
1281
  this.handleLifecyclePause = () => {
653
- 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
+ }
654
1290
  this.lifecycleSuspended = true;
655
1291
  this.deactivatePolling();
656
1292
  this.resetTransientRecognition();
1293
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecyclePause", "returned");
657
1294
  };
658
1295
  this.handleLifecycleResume = () => {
659
- 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
+ }
660
1305
  this.lifecycleSuspended = false;
661
1306
  this.activatePolling();
1307
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.handleLifecycleResume", "returned");
662
1308
  };
1309
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.constructor", "called", { options });
663
1310
  this.sensorProvider = options.sensorProvider ?? defaultSensorProvider;
664
1311
  this.pollIntervalMs = requirePositiveFinite("pollIntervalMs", options.pollIntervalMs ?? 200);
665
1312
  this.unavailableFallbackMs = requirePositiveFinite("unavailableFallbackMs", options.unavailableFallbackMs ?? 3e3);
@@ -672,23 +1319,51 @@ var DefaultDrivingStatusController = class {
672
1319
  this.status = initialStatus;
673
1320
  this.baseStatus = isBaseStatus(initialStatus) ? initialStatus : "STOPPED";
674
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
+ });
675
1330
  }
676
1331
  start() {
677
- 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
+ }
678
1340
  this.requestedRunning = true;
679
1341
  this.attachLifecycleListeners();
680
1342
  if (!this.lifecycleSuspended) this.activatePolling();
1343
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.start", "returned", this.getSnapshot());
681
1344
  }
682
1345
  stop() {
683
- 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
+ }
684
1354
  this.requestedRunning = false;
685
1355
  this.lifecycleSuspended = false;
686
1356
  this.detachLifecycleListeners();
687
1357
  this.deactivatePolling();
688
1358
  this.resetTransientRecognition();
1359
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.stop", "returned", this.getSnapshot());
689
1360
  }
690
1361
  destroy() {
691
- 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
+ }
692
1367
  if (this.requestedRunning) this.stop();
693
1368
  else {
694
1369
  this.detachLifecycleListeners();
@@ -698,9 +1373,10 @@ var DefaultDrivingStatusController = class {
698
1373
  this.listeners.clear();
699
1374
  this.metricWindow.length = 0;
700
1375
  this.motionWindow.length = 0;
1376
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.destroy", "returned", this.getSnapshot());
701
1377
  }
702
1378
  getSnapshot() {
703
- return {
1379
+ const result = {
704
1380
  lifecycle: this.destroyed ? "destroyed" : this.polling ? "running" : "stopped",
705
1381
  status: this.status,
706
1382
  candidate: this.candidate,
@@ -710,25 +1386,59 @@ var DefaultDrivingStatusController = class {
710
1386
  unavailableSinceMs: this.unavailableSinceMs,
711
1387
  tuningVersion: this.tuning.version
712
1388
  };
1389
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.getSnapshot", "returned", { result });
1390
+ return result;
713
1391
  }
714
1392
  subscribe(listener) {
715
- 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
+ }
716
1401
  this.listeners.add(listener);
717
1402
  let subscribed = true;
1403
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.subscribe", "subscribed", { listenerCount: this.listeners.size });
718
1404
  return () => {
719
- 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
+ }
720
1410
  subscribed = false;
721
1411
  this.listeners.delete(listener);
1412
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.unsubscribe", "returned", { listenerCount: this.listeners.size });
722
1413
  };
723
1414
  }
724
1415
  activatePolling() {
725
- 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
+ }
726
1427
  this.polling = true;
727
1428
  this.generation += 1;
728
1429
  this.schedulePoll(0, this.generation);
1430
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.activatePolling", "returned", { generation: this.generation });
729
1431
  }
730
1432
  deactivatePolling() {
731
- 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
+ }
732
1442
  this.polling = false;
733
1443
  this.generation += 1;
734
1444
  if (this.timer !== void 0) {
@@ -737,34 +1447,77 @@ var DefaultDrivingStatusController = class {
737
1447
  }
738
1448
  this.pendingRead?.abort();
739
1449
  this.pendingRead = null;
1450
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.deactivatePolling", "returned", { generation: this.generation });
740
1451
  }
741
1452
  schedulePoll(delayMs, generation) {
742
- 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
+ }
743
1464
  this.timer = this.clock.setTimeout(() => {
1465
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll.callback", "called", { generation });
744
1466
  this.timer = void 0;
745
1467
  this.poll(generation);
746
1468
  }, delayMs);
1469
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.schedulePoll", "scheduled", {
1470
+ delayMs,
1471
+ generation,
1472
+ timer: this.timer
1473
+ });
747
1474
  }
748
1475
  async poll(generation) {
749
- 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
+ }
750
1486
  const pendingRead = new AbortController();
751
1487
  this.pendingRead = pendingRead;
752
1488
  try {
753
1489
  const payload = await this.sensorProvider(pendingRead.signal);
754
- 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
+ }
755
1495
  const metrics = extractDrivingSnapshotMetrics(payload, this.tuning);
756
1496
  const accelerometerSample = extractFreshAccelerometerSample(payload, this.tuning.maxSampleAgeMs);
757
1497
  if (metrics === null || accelerometerSample === null) this.processUnavailable("invalid_or_stale_snapshot");
758
1498
  else this.processAvailable(metrics, accelerometerSample);
759
1499
  } catch (error) {
760
- 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
+ }
761
1505
  this.processUnavailable("provider_error");
762
1506
  } finally {
763
1507
  if (this.pendingRead === pendingRead) this.pendingRead = null;
764
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
+ });
765
1514
  }
766
1515
  }
767
1516
  processAvailable(rawMetrics, accelerometerSample) {
1517
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processAvailable", "called", {
1518
+ rawMetrics,
1519
+ accelerometerSample
1520
+ });
768
1521
  const now = this.clock.now();
769
1522
  this.lastAvailableAtMs = now;
770
1523
  this.unavailableSinceMs = null;
@@ -781,18 +1534,42 @@ var DefaultDrivingStatusController = class {
781
1534
  const motionIntensity = this.recordMotionSample(accelerometerSample, rawMetrics.capturedAtMs);
782
1535
  const nextCandidate = classifyControllerCandidate(rawMetrics, smoothedMetrics, motionIntensity, this.status, this.baseStatus, this.tuning);
783
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
+ });
784
1544
  }
785
1545
  recordMotionSample(sample, capturedAtMs) {
1546
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.recordMotionSample", "called", {
1547
+ sample,
1548
+ capturedAtMs,
1549
+ motionWindow: this.motionWindow
1550
+ });
786
1551
  if (!this.motionWindow.some((existing) => existing.sampledAtMs === sample.sampledAtMs)) {
787
1552
  this.motionWindow.push(sample);
788
1553
  this.motionWindow.sort((left, right) => left.sampledAtMs - right.sampledAtMs);
789
1554
  }
790
1555
  const cutoffMs = capturedAtMs - this.tuning.motionWindowMs;
791
1556
  while (this.motionWindow[0] && this.motionWindow[0].sampledAtMs <= cutoffMs) this.motionWindow.shift();
792
- if (this.motionWindow.length < this.tuning.motionMinimumSamples) return null;
793
- 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;
794
1570
  }
795
1571
  processUnavailable(category) {
1572
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processUnavailable", "called", { category });
796
1573
  const now = this.clock.now();
797
1574
  if (this.unavailableSinceMs === null) this.unavailableSinceMs = now;
798
1575
  const unavailableForMs = Math.max(0, now - this.unavailableSinceMs);
@@ -806,7 +1583,13 @@ var DefaultDrivingStatusController = class {
806
1583
  category,
807
1584
  tuningVersion: this.tuning.version
808
1585
  });
809
- 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
+ }
810
1593
  this.fallbackApplied = true;
811
1594
  this.emitDiagnostic({
812
1595
  type: "fallback_to_stopped",
@@ -815,10 +1598,22 @@ var DefaultDrivingStatusController = class {
815
1598
  tuningVersion: this.tuning.version
816
1599
  });
817
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
+ });
818
1605
  }
819
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
+ });
820
1614
  if (nextCandidate === this.status) {
821
1615
  this.setCandidate(null, now);
1616
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "returned current status");
822
1617
  return;
823
1618
  }
824
1619
  if (nextCandidate !== this.candidate) {
@@ -826,7 +1621,14 @@ var DefaultDrivingStatusController = class {
826
1621
  this.candidateConfirmationCount = 1;
827
1622
  this.heldCandidate = null;
828
1623
  } else this.candidateConfirmationCount += 1;
829
- 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
+ }
830
1632
  const elapsedMs = Math.max(0, now - this.statusCommittedAtMs);
831
1633
  const remainingMs = Math.max(0, this.tuning.minimumDisplayMs[this.status] - elapsedMs);
832
1634
  const canPreempt = CAR_RUNNING_STATUS_PRIORITY[nextCandidate] > CAR_RUNNING_STATUS_PRIORITY[this.status];
@@ -842,13 +1644,31 @@ var DefaultDrivingStatusController = class {
842
1644
  tuningVersion: this.tuning.version
843
1645
  });
844
1646
  }
1647
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "held by minimum duration", {
1648
+ nextCandidate,
1649
+ remainingMs
1650
+ });
845
1651
  return;
846
1652
  }
847
1653
  this.commit(nextCandidate, now, "candidate_confirmed");
1654
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.processCandidate", "returned after commit", { snapshot: this.getSnapshot() });
848
1655
  }
849
1656
  commit(nextStatus, now, reason, force = false) {
850
- if (!force && nextStatus === this.status) return;
851
- 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
+ }
852
1672
  const previousStatus = this.status;
853
1673
  this.status = nextStatus;
854
1674
  if (isBaseStatus(nextStatus)) this.baseStatus = nextStatus;
@@ -871,10 +1691,21 @@ var DefaultDrivingStatusController = class {
871
1691
  reason,
872
1692
  tuningVersion: this.tuning.version
873
1693
  });
1694
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.commit", "returned", {
1695
+ event,
1696
+ listenerCount: this.listeners.size,
1697
+ snapshot: this.getSnapshot()
1698
+ });
874
1699
  }
875
1700
  setCandidate(candidate, now) {
1701
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "called", {
1702
+ candidate,
1703
+ now,
1704
+ currentCandidate: this.candidate
1705
+ });
876
1706
  if (candidate === this.candidate) {
877
1707
  if (candidate === null) this.candidateConfirmationCount = 0;
1708
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "returned unchanged", { candidateConfirmationCount: this.candidateConfirmationCount });
878
1709
  return;
879
1710
  }
880
1711
  const previousCandidate = this.candidate;
@@ -888,8 +1719,17 @@ var DefaultDrivingStatusController = class {
888
1719
  previousCandidate,
889
1720
  tuningVersion: this.tuning.version
890
1721
  });
1722
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.setCandidate", "returned", {
1723
+ candidate,
1724
+ previousCandidate
1725
+ });
891
1726
  }
892
1727
  resetTransientRecognition() {
1728
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.resetTransientRecognition", "called", {
1729
+ metricWindow: this.metricWindow,
1730
+ motionWindow: this.motionWindow,
1731
+ candidate: this.candidate
1732
+ });
893
1733
  this.metricWindow.length = 0;
894
1734
  this.motionWindow.length = 0;
895
1735
  this.candidate = null;
@@ -897,54 +1737,144 @@ var DefaultDrivingStatusController = class {
897
1737
  this.unavailableSinceMs = null;
898
1738
  this.fallbackApplied = false;
899
1739
  this.heldCandidate = null;
1740
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.resetTransientRecognition", "returned");
900
1741
  }
901
1742
  emitDiagnostic(event) {
1743
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.emitDiagnostic", "called", {
1744
+ event,
1745
+ hasListener: this.onDiagnostic !== void 0
1746
+ });
902
1747
  if (this.onDiagnostic) safeCall(this.onDiagnostic, event);
1748
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.emitDiagnostic", "returned", { event });
903
1749
  }
904
1750
  attachLifecycleListeners() {
905
- 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
+ }
906
1759
  this.unsubscribePageLifecycle = subscribeDrivingPageLifecycle(this.handleLifecyclePause, this.handleLifecycleResume);
1760
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.attachLifecycleListeners", "returned");
907
1761
  }
908
1762
  detachLifecycleListeners() {
1763
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.detachLifecycleListeners", "called", { attached: this.unsubscribePageLifecycle !== null });
909
1764
  this.unsubscribePageLifecycle?.();
910
1765
  this.unsubscribePageLifecycle = null;
1766
+ dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingStatusController.detachLifecycleListeners", "returned");
911
1767
  }
912
1768
  };
913
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
+ });
914
1778
  const entry = classifyEntryCandidate(raw, smoothed, motionIntensity, baseStatus, tuning);
915
- if (!retainsCurrentStatus(raw, smoothed, motionIntensity, current, tuning)) return entry;
916
- if (entry === current) return current;
917
- if (CAR_RUNNING_STATUS_PRIORITY[entry] > CAR_RUNNING_STATUS_PRIORITY[current]) return entry;
918
- if (isOppositeTurn(entry, current)) return entry;
919
- if ((entry === "STOPPED" || entry === "STEADY_DRIVING") && (current === "STOPPED" || current === "STEADY_DRIVING")) return entry;
920
- 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;
921
1787
  };
922
1788
  const classifyEntryCandidate = (raw, smoothed, motionIntensity, baseStatus, tuning) => {
923
- if (raw.longitudinal <= -tuning.rapidLongitudinalThreshold) return "SUDDEN_BRAKING";
924
- if (raw.longitudinal >= tuning.rapidLongitudinalThreshold) return "RAPID_ACCELERATION";
925
- if (Math.abs(smoothed.yaw) >= tuning.turnYawThreshold) return smoothed.yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
926
- if (Math.abs(smoothed.lateral) >= tuning.turnLateralThreshold) return smoothed.lateral < 0 ? "LEFT_TURN" : "RIGHT_TURN";
927
- if (smoothed.longitudinal <= -tuning.longitudinalThreshold) return "BRAKING";
928
- if (smoothed.longitudinal >= tuning.longitudinalThreshold) return "ACCELERATION";
929
- if (motionIntensity === null) return baseStatus;
930
- if (motionIntensity > tuning.drivingMotionThreshold || smoothed.gyroMagnitude > tuning.stoppedGyroThreshold) return "STEADY_DRIVING";
931
- if (motionIntensity < tuning.stoppedMotionThreshold) return "STOPPED";
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 });
932
1835
  return baseStatus;
933
1836
  };
934
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
+ });
935
1845
  const ratio = tuning.hysteresisRatio;
1846
+ let result;
936
1847
  switch (current) {
937
- case "SUDDEN_BRAKING": return raw.longitudinal <= -tuning.rapidLongitudinalThreshold * ratio;
938
- case "RAPID_ACCELERATION": return raw.longitudinal >= tuning.rapidLongitudinalThreshold * ratio;
939
- case "LEFT_TURN": return smoothed.yaw >= tuning.turnYawThreshold * ratio || smoothed.lateral <= -tuning.turnLateralThreshold * ratio;
940
- case "RIGHT_TURN": return smoothed.yaw <= -tuning.turnYawThreshold * ratio || smoothed.lateral >= tuning.turnLateralThreshold * ratio;
941
- case "BRAKING": return smoothed.longitudinal <= -tuning.longitudinalThreshold * ratio;
942
- case "ACCELERATION": return smoothed.longitudinal >= tuning.longitudinalThreshold * ratio;
943
- case "STOPPED": return (motionIntensity === null || motionIntensity <= tuning.drivingMotionThreshold) && smoothed.gyroMagnitude <= tuning.stoppedGyroThreshold;
944
- 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;
945
1872
  }
1873
+ dialSdkDebugWarn(DEBUG_MODULE$1, "retainsCurrentStatus", "returned", { result });
1874
+ return result;
946
1875
  };
947
1876
  const averageMetrics = (metrics) => {
1877
+ dialSdkDebugWarn(DEBUG_MODULE$1, "averageMetrics", "called", { metrics });
948
1878
  const result = {
949
1879
  capturedAtMs: metrics[metrics.length - 1]?.capturedAtMs ?? 0,
950
1880
  longitudinal: 0,
@@ -966,25 +1896,45 @@ const averageMetrics = (metrics) => {
966
1896
  result.yaw /= count;
967
1897
  result.motionIntensity /= count;
968
1898
  result.gyroMagnitude /= count;
1899
+ dialSdkDebugWarn(DEBUG_MODULE$1, "averageMetrics", "returned", { result });
969
1900
  return result;
970
1901
  };
971
1902
  const extractFreshAccelerometerSample = (info, maxSampleAgeMs) => {
1903
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "called", {
1904
+ info,
1905
+ maxSampleAgeMs
1906
+ });
972
1907
  const metric = info?.accelerometer;
973
- 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
+ }
974
1912
  const ageMs = info.capturedAtMs - metric.sampledAtMs;
975
- 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
+ }
976
1920
  const { x, y, z } = metric.value;
977
1921
  if (![
978
1922
  x,
979
1923
  y,
980
1924
  z
981
- ].every(Number.isFinite)) return null;
982
- return {
1925
+ ].every(Number.isFinite)) {
1926
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned invalid vector", { result: null });
1927
+ return null;
1928
+ }
1929
+ const result = {
983
1930
  sampledAtMs: metric.sampledAtMs,
984
1931
  value: metric.value
985
1932
  };
1933
+ dialSdkDebugWarn(DEBUG_MODULE$1, "extractFreshAccelerometerSample", "returned", { result });
1934
+ return result;
986
1935
  };
987
1936
  const combinedAxisStandardDeviation = (samples) => {
1937
+ dialSdkDebugWarn(DEBUG_MODULE$1, "combinedAxisStandardDeviation", "called", { samples });
988
1938
  const count = samples.length;
989
1939
  let meanX = 0;
990
1940
  let meanY = 0;
@@ -1005,34 +1955,117 @@ const combinedAxisStandardDeviation = (samples) => {
1005
1955
  varianceY += (sample.value.y - meanY) ** 2;
1006
1956
  varianceZ += (sample.value.z - meanZ) ** 2;
1007
1957
  }
1008
- 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;
1009
1969
  };
1010
1970
  const defaultSensorProvider = () => {
1971
+ dialSdkDebugWarn(DEBUG_MODULE$1, "defaultSensorProvider", "called");
1011
1972
  const runtimeGlobal = globalThis;
1012
- if (typeof runtimeGlobal.unifiedSensorInfo !== "function") return Promise.reject(/* @__PURE__ */ new Error("window.unifiedSensorInfo is unavailable"));
1013
- 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
+ }
1014
1986
  };
1015
1987
  const systemClock = {
1016
- now: () => Date.now(),
1017
- setTimeout: (callback, delayMs) => globalThis.setTimeout(callback, delayMs),
1018
- 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;
1019
2031
  };
1020
- const isOppositeTurn = (candidate, current) => candidate === "LEFT_TURN" && current === "RIGHT_TURN" || candidate === "RIGHT_TURN" && current === "LEFT_TURN";
1021
- const isBaseStatus = (status) => status === "STOPPED" || status === "STEADY_DRIVING";
1022
- const isAbortError$1 = (error) => error instanceof Error && error.name === "AbortError";
1023
2032
  const requirePositiveFinite = (name, value) => {
1024
- 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 });
1025
2043
  return value;
1026
2044
  };
1027
2045
  const safeCall = (callback, value) => {
2046
+ dialSdkDebugWarn(DEBUG_MODULE$1, "safeCall", "called", { value });
1028
2047
  try {
1029
2048
  callback(value);
1030
- } 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");
1031
2056
  };
1032
- const noop = () => {};
1033
2057
  //#endregion
1034
2058
  //#region src/sensor/driving_expression_player.ts
1035
- 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
+ };
1036
2069
  var DefaultDrivingExpressionPlayer = class {
1037
2070
  constructor(container, options) {
1038
2071
  this.status = null;
@@ -1054,16 +2087,34 @@ var DefaultDrivingExpressionPlayer = class {
1054
2087
  this.activeTgs = null;
1055
2088
  this.unsubscribePageLifecycle = null;
1056
2089
  this.handleLifecyclePause = () => {
1057
- 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
+ }
1058
2095
  this.lifecycleSuspended = true;
1059
2096
  this.updatePauseState();
2097
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "returned");
1060
2098
  };
1061
2099
  this.handleLifecycleResume = () => {
1062
- 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
+ }
1063
2105
  this.lifecycleSuspended = false;
1064
2106
  this.updatePauseState();
2107
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "returned");
1065
2108
  };
1066
- 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
+ }
1067
2118
  this.container = container;
1068
2119
  this.document = container.ownerDocument;
1069
2120
  this.config = options.config;
@@ -1078,9 +2129,25 @@ var DefaultDrivingExpressionPlayer = class {
1078
2129
  this.maxTgsJsonBytes = positiveFinite("maxTgsJsonBytes", options.maxTgsJsonBytes ?? 8 * 1024 * 1024);
1079
2130
  this.maxTgsLayers = positiveFinite("maxTgsLayers", options.maxTgsLayers ?? 500);
1080
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
+ });
1081
2141
  }
1082
2142
  async show(status) {
1083
- 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
+ }
1084
2151
  this.status = status;
1085
2152
  const operation = this.beginOperation();
1086
2153
  const configured = this.config.states[status];
@@ -1088,36 +2155,59 @@ var DefaultDrivingExpressionPlayer = class {
1088
2155
  const fallback = this.fallbacks?.[status];
1089
2156
  if (fallback === void 0) {
1090
2157
  this.handleFailure(status, null, new DrivingExpressionResolutionError(status), "invalid_config", operation, false);
2158
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned after missing config");
1091
2159
  return;
1092
2160
  }
1093
2161
  this.desiredMedia = fallback;
1094
2162
  if (this.paused) {
1095
2163
  this.phase = "idle";
2164
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred fallback while paused");
1096
2165
  return;
1097
2166
  }
1098
2167
  this.renderFallback(status, fallback);
2168
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned fallback", { snapshot: this.getSnapshot() });
1099
2169
  return;
1100
2170
  }
1101
2171
  const media = normalizeMedia(configured);
1102
2172
  this.desiredMedia = media;
1103
2173
  if (this.paused) {
1104
2174
  this.phase = "idle";
2175
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred media while paused", { media });
1105
2176
  return;
1106
2177
  }
1107
2178
  await this.load(status, media, operation);
2179
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "resolved", {
2180
+ status,
2181
+ media,
2182
+ snapshot: this.getSnapshot()
2183
+ });
1108
2184
  }
1109
2185
  pause() {
1110
- 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
+ }
1111
2191
  this.userPaused = true;
1112
2192
  this.updatePauseState();
2193
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "returned", this.getSnapshot());
1113
2194
  }
1114
2195
  resume() {
1115
- 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
+ }
1116
2201
  this.userPaused = false;
1117
2202
  this.updatePauseState();
2203
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "returned", this.getSnapshot());
1118
2204
  }
1119
2205
  destroy() {
1120
- 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
+ }
1121
2211
  this.destroyed = true;
1122
2212
  this.unsubscribePageLifecycle?.();
1123
2213
  this.unsubscribePageLifecycle = null;
@@ -1131,17 +2221,24 @@ var DefaultDrivingExpressionPlayer = class {
1131
2221
  this.phase = "idle";
1132
2222
  this.mediaKind = null;
1133
2223
  this.errorCategory = null;
2224
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "returned", this.getSnapshot());
1134
2225
  }
1135
2226
  getSnapshot() {
1136
- return {
2227
+ const result = {
1137
2228
  lifecycle: this.destroyed ? "destroyed" : this.paused ? "paused" : "active",
1138
2229
  status: this.status,
1139
2230
  phase: this.phase,
1140
2231
  mediaKind: this.mediaKind,
1141
2232
  errorCategory: this.errorCategory
1142
2233
  };
2234
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getSnapshot", "returned", { result });
2235
+ return result;
1143
2236
  }
1144
2237
  beginOperation() {
2238
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "called", {
2239
+ operation: this.operation,
2240
+ snapshot: this.getSnapshot()
2241
+ });
1145
2242
  this.operation += 1;
1146
2243
  this.failedOperation = null;
1147
2244
  this.cancelPendingWork();
@@ -1150,17 +2247,28 @@ var DefaultDrivingExpressionPlayer = class {
1150
2247
  this.phase = "loading";
1151
2248
  this.mediaKind = null;
1152
2249
  this.errorCategory = null;
2250
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "returned", { operation: this.operation });
1153
2251
  return this.operation;
1154
2252
  }
1155
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
+ });
1156
2260
  const shouldPause = this.userPaused || this.lifecycleSuspended;
1157
- if (shouldPause === this.paused) return;
2261
+ if (shouldPause === this.paused) {
2262
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "ignored unchanged state");
2263
+ return;
2264
+ }
1158
2265
  this.paused = shouldPause;
1159
2266
  if (shouldPause) {
1160
2267
  this.operation += 1;
1161
2268
  this.cancelPendingWork();
1162
2269
  this.activeVideo?.pause();
1163
2270
  this.activeTgs?.pause?.();
2271
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "paused", this.getSnapshot());
1164
2272
  return;
1165
2273
  }
1166
2274
  if (this.phase === "ready") {
@@ -1173,23 +2281,33 @@ var DefaultDrivingExpressionPlayer = class {
1173
2281
  video.play().catch((error) => this.handleActiveVideoFailure(video, status, media, operation, "decode", error));
1174
2282
  }
1175
2283
  this.activeTgs?.play?.();
2284
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "resumed ready media");
1176
2285
  return;
1177
2286
  }
1178
2287
  if (this.status !== null && this.desiredMedia !== null) {
1179
2288
  const operation = this.beginOperation();
1180
2289
  this.load(this.status, this.desiredMedia, operation);
1181
2290
  }
2291
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "returned", this.getSnapshot());
1182
2292
  }
1183
2293
  async load(status, media, operation) {
2294
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "called", {
2295
+ status,
2296
+ media,
2297
+ operation
2298
+ });
1184
2299
  const startedAt = Date.now();
1185
2300
  this.mediaKind = media.kind;
1186
2301
  if (media.kind === "emoji") {
1187
2302
  this.renderEmoji(media.text);
1188
2303
  this.markReady(status, media.kind, startedAt, operation);
2304
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved emoji", { snapshot: this.getSnapshot() });
1189
2305
  return;
1190
2306
  }
1191
- if (firstInvalidMediaUrl(media) !== null) {
2307
+ const invalidUrl = firstInvalidMediaUrl(media);
2308
+ if (invalidUrl !== null) {
1192
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 });
1193
2311
  return;
1194
2312
  }
1195
2313
  const loadAbort = new AbortController();
@@ -1212,26 +2330,67 @@ var DefaultDrivingExpressionPlayer = class {
1212
2330
  await this.loadTgs(media.url, loadAbort.signal, operation);
1213
2331
  break;
1214
2332
  }
1215
- 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
+ }
1216
2340
  this.markReady(status, media.kind, startedAt, operation);
1217
2341
  this.startPreloading(status, operation);
2342
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved", {
2343
+ status,
2344
+ media,
2345
+ operation,
2346
+ snapshot: this.getSnapshot()
2347
+ });
1218
2348
  } catch (error) {
1219
- 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
+ }
1220
2357
  this.handleFailure(status, media, error, categorizeMediaError(error), operation);
1221
2358
  } finally {
1222
2359
  loadAbort.abort();
1223
2360
  if (this.loadAbort === loadAbort) this.loadAbort = null;
2361
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "completed", { operation });
1224
2362
  }
1225
2363
  }
1226
2364
  async loadImage(url, signal, operation) {
2365
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "called", {
2366
+ url,
2367
+ signal,
2368
+ operation
2369
+ });
1227
2370
  const image = this.createImage();
1228
2371
  await waitForElementEvent(image, "load", "error", signal, this.loadTimeoutMs, () => {
1229
2372
  image.src = url;
1230
2373
  });
1231
- if (!this.isCurrent(operation)) return;
2374
+ if (!this.isCurrent(operation)) {
2375
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "discarded", { operation });
2376
+ return;
2377
+ }
1232
2378
  this.container.replaceChildren(image);
2379
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "resolved", {
2380
+ url,
2381
+ operation,
2382
+ image
2383
+ });
1233
2384
  }
1234
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
+ });
1235
2394
  const video = this.getReusableVideo();
1236
2395
  resetVideo(video);
1237
2396
  video.preload = "auto";
@@ -1240,25 +2399,55 @@ var DefaultDrivingExpressionPlayer = class {
1240
2399
  video.src = url;
1241
2400
  video.load();
1242
2401
  });
1243
- if (!this.isCurrent(operation)) return;
2402
+ if (!this.isCurrent(operation)) {
2403
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "discarded", { operation });
2404
+ return;
2405
+ }
1244
2406
  video.currentTime = 0;
1245
2407
  this.container.replaceChildren(video);
1246
2408
  this.activeVideo = video;
1247
2409
  this.attachActiveVideoFailureListeners(video, status, media, operation);
1248
2410
  await video.play();
2411
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "resolved", {
2412
+ url,
2413
+ operation,
2414
+ video
2415
+ });
1249
2416
  }
1250
2417
  async loadLivePhoto(media, status, signal, operation) {
2418
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "called", {
2419
+ media,
2420
+ status,
2421
+ signal,
2422
+ operation
2423
+ });
1251
2424
  this.renderConfiguredFallback(status, false);
1252
2425
  const cover = this.createImage();
1253
2426
  await waitForElementEvent(cover, "load", "error", signal, this.loadTimeoutMs, () => {
1254
2427
  cover.src = media.coverUrl;
1255
2428
  });
1256
- if (!this.isCurrent(operation)) return;
2429
+ if (!this.isCurrent(operation)) {
2430
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "discarded", { operation });
2431
+ return;
2432
+ }
1257
2433
  this.container.replaceChildren(cover);
1258
2434
  await this.loadVideo(media.motionUrl, void 0, status, media, signal, operation);
2435
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "resolved", {
2436
+ media,
2437
+ operation
2438
+ });
1259
2439
  }
1260
2440
  async loadTgs(url, signal, operation) {
1261
- 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
+ }
1262
2451
  const response = await withTimeout(this.fetchImplementation(url, {
1263
2452
  credentials: "omit",
1264
2453
  mode: "cors",
@@ -1266,6 +2455,12 @@ var DefaultDrivingExpressionPlayer = class {
1266
2455
  }), this.loadTimeoutMs, signal);
1267
2456
  if (!response.ok) throw new MediaPlayerError("network", `TGS request failed with HTTP ${response.status}`);
1268
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
+ });
1269
2464
  if (!SUPPORTED_TGS_CONTENT_TYPES.has(contentType)) throw new MediaPlayerError("unsupported", `Unsupported TGS Content-Type: ${contentType || "missing"}`);
1270
2465
  const contentLength = Number(response.headers.get("content-length"));
1271
2466
  if (Number.isFinite(contentLength) && contentLength > this.maxTgsCompressedBytes) throw new MediaPlayerError("decode", "TGS compressed payload exceeds the configured limit");
@@ -1276,8 +2471,13 @@ var DefaultDrivingExpressionPlayer = class {
1276
2471
  let animationData;
1277
2472
  try {
1278
2473
  animationData = JSON.parse(new TextDecoder().decode(bytes));
1279
- } catch {
1280
- 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;
1281
2481
  }
1282
2482
  validateTgsAnimation(animationData, this.maxTgsLayers);
1283
2483
  const host = this.document.createElement("div");
@@ -1285,33 +2485,72 @@ var DefaultDrivingExpressionPlayer = class {
1285
2485
  const handle = await withTimeout(Promise.resolve(this.tgsRenderer(host, animationData, signal)), this.loadTimeoutMs, signal);
1286
2486
  if (!this.isCurrent(operation)) {
1287
2487
  handle.destroy();
2488
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "discarded", { operation });
1288
2489
  return;
1289
2490
  }
1290
2491
  this.activeTgs = handle;
1291
2492
  this.container.replaceChildren(host);
2493
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "resolved", {
2494
+ url,
2495
+ operation,
2496
+ animationData,
2497
+ host
2498
+ });
1292
2499
  }
1293
2500
  renderLoadingPlaceholder(status, coverUrl, operation, signal) {
2501
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "called", {
2502
+ status,
2503
+ coverUrl,
2504
+ operation,
2505
+ signal
2506
+ });
1294
2507
  this.renderConfiguredFallback(status, false);
1295
- if (!coverUrl) return;
2508
+ if (!coverUrl) {
2509
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned no cover");
2510
+ return;
2511
+ }
1296
2512
  const cover = this.createImage();
1297
2513
  waitForElementEvent(cover, "load", "error", signal, this.loadTimeoutMs, () => {
1298
2514
  cover.src = coverUrl;
1299
2515
  }).then(() => {
2516
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.then", "called", {
2517
+ operation,
2518
+ cover
2519
+ });
1300
2520
  if (this.isCurrent(operation) && this.phase === "loading") this.container.replaceChildren(cover);
1301
- }).catch(() => {
2521
+ }).catch((error) => {
2522
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.catch", "called", {
2523
+ operation,
2524
+ error
2525
+ });
1302
2526
  if (this.isCurrent(operation) && this.phase === "loading") this.renderConfiguredFallback(status, false);
1303
2527
  });
2528
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned");
1304
2529
  }
1305
2530
  renderConfiguredFallback(status, report = true) {
2531
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "called", {
2532
+ status,
2533
+ report
2534
+ });
1306
2535
  const fallback = this.fallbacks?.[status];
1307
2536
  if (!fallback) {
1308
2537
  this.container.replaceChildren();
2538
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", { result: false });
1309
2539
  return false;
1310
2540
  }
1311
2541
  this.renderFallback(status, fallback, report);
2542
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
2543
+ result: true,
2544
+ fallback
2545
+ });
1312
2546
  return true;
1313
2547
  }
1314
2548
  renderFallback(status, fallback, report = true) {
2549
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "called", {
2550
+ status,
2551
+ fallback,
2552
+ report
2553
+ });
1315
2554
  if (report) {
1316
2555
  this.phase = "fallback";
1317
2556
  this.mediaKind = fallback.kind;
@@ -1328,8 +2567,10 @@ var DefaultDrivingExpressionPlayer = class {
1328
2567
  status,
1329
2568
  kind: fallback.kind
1330
2569
  });
2570
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "returned", { snapshot: this.getSnapshot() });
1331
2571
  }
1332
2572
  renderEmoji(text) {
2573
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "called", { text });
1333
2574
  const emoji = this.document.createElement("span");
1334
2575
  emoji.textContent = text;
1335
2576
  emoji.setAttribute("role", "img");
@@ -1345,9 +2586,19 @@ var DefaultDrivingExpressionPlayer = class {
1345
2586
  width: "100%"
1346
2587
  });
1347
2588
  this.container.replaceChildren(emoji);
2589
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "returned", { emoji });
1348
2590
  }
1349
2591
  markReady(status, kind, startedAt, operation) {
1350
- 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
+ }
1351
2602
  this.phase = "ready";
1352
2603
  this.mediaKind = kind;
1353
2604
  this.errorCategory = null;
@@ -1357,9 +2608,21 @@ var DefaultDrivingExpressionPlayer = class {
1357
2608
  kind,
1358
2609
  elapsedMs: Math.max(0, Date.now() - startedAt)
1359
2610
  });
2611
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "returned", this.getSnapshot());
1360
2612
  }
1361
2613
  handleFailure(status, media, error, category, operation, scheduleRetry = true) {
1362
- 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
+ }
1363
2626
  this.failedOperation = operation;
1364
2627
  this.stopActiveVideo();
1365
2628
  this.phase = "error";
@@ -1371,22 +2634,51 @@ var DefaultDrivingExpressionPlayer = class {
1371
2634
  category,
1372
2635
  message: safeErrorMessage(error)
1373
2636
  });
1374
- if (!this.renderConfiguredFallback(status)) {
2637
+ const fallbackApplied = this.renderConfiguredFallback(status);
2638
+ if (!fallbackApplied) {
1375
2639
  this.phase = "error";
1376
2640
  this.errorCategory = category;
1377
2641
  }
1378
2642
  if (scheduleRetry && media !== null) this.scheduleRetry(status, media, operation);
2643
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "returned", {
2644
+ fallbackApplied,
2645
+ snapshot: this.getSnapshot()
2646
+ });
1379
2647
  }
1380
2648
  scheduleRetry(status, media, failedOperation) {
1381
- 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
+ }
1382
2658
  this.retryTimer = globalThis.setTimeout(() => {
2659
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "called", {
2660
+ status,
2661
+ media,
2662
+ failedOperation
2663
+ });
1383
2664
  this.retryTimer = void 0;
1384
- 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
+ }
1385
2669
  const operation = this.beginOperation();
1386
2670
  this.load(status, media, operation);
1387
2671
  }, this.retryBackoffMs);
2672
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "scheduled", {
2673
+ retryTimer: this.retryTimer,
2674
+ retryBackoffMs: this.retryBackoffMs
2675
+ });
1388
2676
  }
1389
2677
  startPreloading(currentStatus, operation) {
2678
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "called", {
2679
+ currentStatus,
2680
+ operation
2681
+ });
1390
2682
  this.preloadAbort?.abort();
1391
2683
  const preloadAbort = new AbortController();
1392
2684
  this.preloadAbort = preloadAbort;
@@ -1396,8 +2688,18 @@ var DefaultDrivingExpressionPlayer = class {
1396
2688
  ...CAR_RUNNING_STATUSES
1397
2689
  ].filter((status, index, all) => all.indexOf(status) === index);
1398
2690
  (async () => {
2691
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "started", {
2692
+ statuses,
2693
+ operation
2694
+ });
1399
2695
  for (const status of statuses) {
1400
- 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
+ }
1401
2703
  const configured = this.config.states[status];
1402
2704
  if (configured === void 0 || status === currentStatus) continue;
1403
2705
  const media = normalizeMedia(configured);
@@ -1409,20 +2711,34 @@ var DefaultDrivingExpressionPlayer = class {
1409
2711
  image.src = hintUrl;
1410
2712
  });
1411
2713
  image.removeAttribute("src");
1412
- } 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
+ });
1413
2724
  if (preloadAbort.signal.aborted) return;
1414
2725
  }
1415
2726
  }
2727
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "completed", { operation });
1416
2728
  })();
2729
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "returned", { statuses });
1417
2730
  }
1418
2731
  createImage() {
2732
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "called");
1419
2733
  const image = this.document.createElement("img");
1420
2734
  image.alt = "";
1421
2735
  image.decoding = "async";
1422
2736
  styleMediaElement(image, this.fit);
2737
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "returned", { image });
1423
2738
  return image;
1424
2739
  }
1425
2740
  getReusableVideo() {
2741
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "called", { hasReusableVideo: this.reusableVideo !== null });
1426
2742
  if (!this.reusableVideo) {
1427
2743
  this.reusableVideo = this.document.createElement("video");
1428
2744
  this.reusableVideo.muted = true;
@@ -1432,52 +2748,105 @@ var DefaultDrivingExpressionPlayer = class {
1432
2748
  this.reusableVideo.setAttribute("playsinline", "");
1433
2749
  styleMediaElement(this.reusableVideo, this.fit);
1434
2750
  }
2751
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "returned", { video: this.reusableVideo });
1435
2752
  return this.reusableVideo;
1436
2753
  }
1437
2754
  attachActiveVideoFailureListeners(video, status, media, operation) {
2755
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "called", {
2756
+ video,
2757
+ status,
2758
+ media,
2759
+ operation
2760
+ });
1438
2761
  this.detachActiveVideoFailureListeners();
1439
2762
  let attached = true;
1440
2763
  const cleanup = () => {
1441
- if (!attached) return;
2764
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "called", { attached });
2765
+ if (!attached) {
2766
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "ignored");
2767
+ return;
2768
+ }
1442
2769
  attached = false;
1443
2770
  video.removeEventListener("error", handleError);
1444
2771
  video.removeEventListener("stalled", handleStalled);
1445
2772
  if (this.activeVideoListenersCleanup === cleanup) this.activeVideoListenersCleanup = null;
2773
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "returned");
1446
2774
  };
1447
2775
  const failed = (category, event) => {
2776
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerFailed", "called", {
2777
+ category,
2778
+ event,
2779
+ attached
2780
+ });
1448
2781
  if (!attached) return;
1449
2782
  this.handleActiveVideoFailure(video, status, media, operation, category, new MediaPlayerError(category, `${event.type} after video playback started`));
1450
2783
  };
1451
- const handleError = (event) => failed("decode", event);
1452
- 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
+ };
1453
2792
  video.addEventListener("error", handleError);
1454
2793
  video.addEventListener("stalled", handleStalled);
1455
2794
  this.activeVideoListenersCleanup = cleanup;
2795
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "returned");
1456
2796
  }
1457
2797
  handleActiveVideoFailure(video, status, media, operation, category, error) {
1458
- 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
+ }
1459
2810
  this.stopActiveVideo();
1460
2811
  this.handleFailure(status, media, error, category, operation);
2812
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "returned");
1461
2813
  }
1462
2814
  detachActiveVideoFailureListeners() {
2815
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "called");
1463
2816
  const cleanup = this.activeVideoListenersCleanup;
1464
2817
  this.activeVideoListenersCleanup = null;
1465
2818
  cleanup?.();
2819
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "returned");
1466
2820
  }
1467
2821
  stopActiveVideo() {
2822
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "called", { activeVideo: this.activeVideo });
1468
2823
  this.detachActiveVideoFailureListeners();
1469
- if (!this.activeVideo) return;
2824
+ if (!this.activeVideo) {
2825
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned no active video");
2826
+ return;
2827
+ }
1470
2828
  resetVideo(this.activeVideo);
1471
2829
  this.activeVideo = null;
2830
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned");
1472
2831
  }
1473
2832
  releaseActiveMedia() {
2833
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "called", {
2834
+ activeVideo: this.activeVideo,
2835
+ activeTgs: this.activeTgs
2836
+ });
1474
2837
  this.stopActiveVideo();
1475
2838
  if (this.activeTgs) {
1476
2839
  safeDestroy(this.activeTgs);
1477
2840
  this.activeTgs = null;
1478
2841
  }
2842
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "returned");
1479
2843
  }
1480
2844
  cancelPendingWork() {
2845
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "called", {
2846
+ hasLoad: this.loadAbort !== null,
2847
+ hasPreload: this.preloadAbort !== null,
2848
+ retryTimer: this.retryTimer
2849
+ });
1481
2850
  this.loadAbort?.abort();
1482
2851
  this.loadAbort = null;
1483
2852
  this.detachActiveVideoFailureListeners();
@@ -1488,22 +2857,46 @@ var DefaultDrivingExpressionPlayer = class {
1488
2857
  globalThis.clearTimeout(this.retryTimer);
1489
2858
  this.retryTimer = void 0;
1490
2859
  }
2860
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "returned");
1491
2861
  }
1492
2862
  isCurrent(operation) {
1493
- 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;
1494
2872
  }
1495
2873
  emitDiagnostic(event) {
1496
- 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
+ }
1497
2882
  try {
1498
2883
  this.onDiagnostic(event);
1499
- } catch {}
2884
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned", { event });
2885
+ } catch (error) {
2886
+ dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "listener threw", error);
2887
+ }
1500
2888
  }
1501
2889
  };
1502
2890
  var MediaPlayerError = class extends Error {
1503
2891
  constructor(category, message) {
2892
+ dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "called", {
2893
+ category,
2894
+ message
2895
+ });
1504
2896
  super(message);
1505
2897
  this.name = "MediaPlayerError";
1506
2898
  this.category = category;
2899
+ dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "created", { error: this });
1507
2900
  }
1508
2901
  };
1509
2902
  const SUPPORTED_TGS_CONTENT_TYPES = /* @__PURE__ */ new Set([
@@ -1513,11 +2906,19 @@ const SUPPORTED_TGS_CONTENT_TYPES = /* @__PURE__ */ new Set([
1513
2906
  "application/x-gzip",
1514
2907
  "application/x-tgsticker"
1515
2908
  ]);
1516
- const normalizeMedia = (media) => typeof media === "string" ? {
1517
- kind: "image",
1518
- url: media
1519
- } : 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
+ };
1520
2920
  const firstInvalidMediaUrl = (media) => {
2921
+ dialSdkDebugWarn(DEBUG_MODULE, "firstInvalidMediaUrl", "called", { media });
1521
2922
  let values;
1522
2923
  switch (media.kind) {
1523
2924
  case "emoji":
@@ -1534,75 +2935,129 @@ const firstInvalidMediaUrl = (media) => {
1534
2935
  values = [media.url, media.coverUrl];
1535
2936
  break;
1536
2937
  }
1537
- 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;
1538
2944
  };
1539
2945
  const mediaPreloadHint = (media) => {
2946
+ dialSdkDebugWarn(DEBUG_MODULE, "mediaPreloadHint", "called", { media });
2947
+ let result;
1540
2948
  switch (media.kind) {
1541
- case "image": return media.url;
2949
+ case "image":
2950
+ result = media.url;
2951
+ break;
1542
2952
  case "video":
1543
- case "tgs": return media.coverUrl;
1544
- case "live_photo": return media.coverUrl;
1545
- case "emoji": return;
1546
- }
1547
- };
1548
- const waitForElementEvent = (element, successEvent, failureEvent, signal, timeoutMs, start) => new Promise((resolve, reject) => {
1549
- let timer;
1550
- const cleanup = () => {
1551
- element.removeEventListener(successEvent, handleSuccess);
1552
- element.removeEventListener(failureEvent, handleFailure);
1553
- signal.removeEventListener("abort", handleAbort);
1554
- if (timer !== void 0) globalThis.clearTimeout(timer);
1555
- };
1556
- const handleSuccess = () => {
1557
- cleanup();
1558
- resolve();
1559
- };
1560
- const handleFailure = () => {
1561
- cleanup();
1562
- reject(new MediaPlayerError("decode", `${failureEvent} while loading media`));
1563
- };
1564
- const handleAbort = () => {
1565
- cleanup();
1566
- reject(createAbortError());
1567
- };
1568
- element.addEventListener(successEvent, handleSuccess, { once: true });
1569
- element.addEventListener(failureEvent, handleFailure, { once: true });
1570
- signal.addEventListener("abort", handleAbort, { once: true });
1571
- timer = globalThis.setTimeout(() => {
1572
- cleanup();
1573
- reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
1574
- }, timeoutMs);
1575
- try {
1576
- start();
1577
- } catch (error) {
1578
- cleanup();
1579
- 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;
1580
2962
  }
1581
- });
1582
- const withTimeout = (promise, timeoutMs, signal) => new Promise((resolve, reject) => {
1583
- let timer;
1584
- const cleanup = () => {
1585
- signal.removeEventListener("abort", handleAbort);
1586
- if (timer !== void 0) globalThis.clearTimeout(timer);
1587
- };
1588
- const handleAbort = () => {
1589
- cleanup();
1590
- reject(createAbortError());
1591
- };
1592
- signal.addEventListener("abort", handleAbort, { once: true });
1593
- timer = globalThis.setTimeout(() => {
1594
- cleanup();
1595
- reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
1596
- }, timeoutMs);
1597
- promise.then((value) => {
1598
- cleanup();
1599
- resolve(value);
1600
- }, (error) => {
1601
- cleanup();
1602
- 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
1603
2973
  });
1604
- });
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
+ };
1605
3055
  const defaultTgsRenderer = async (container, animationData, signal) => {
3056
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "called", {
3057
+ container,
3058
+ animationData,
3059
+ signal
3060
+ });
1606
3061
  if (signal.aborted) throw createAbortError();
1607
3062
  const module = await import("lottie-web/build/player/lottie_light.js");
1608
3063
  if (signal.aborted) throw createAbortError();
@@ -1616,47 +3071,80 @@ const defaultTgsRenderer = async (container, animationData, signal) => {
1616
3071
  });
1617
3072
  await new Promise((resolve, reject) => {
1618
3073
  const ready = () => {
3074
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.ready", "called");
1619
3075
  cleanup();
1620
3076
  resolve();
1621
3077
  };
1622
3078
  const failed = () => {
3079
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.failed", "called");
1623
3080
  cleanup();
1624
3081
  reject(new MediaPlayerError("decode", "Lottie could not initialize the TGS animation"));
1625
3082
  };
1626
3083
  const aborted = () => {
3084
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.aborted", "called");
1627
3085
  cleanup();
1628
3086
  animation.destroy();
1629
3087
  reject(createAbortError());
1630
3088
  };
1631
3089
  const cleanup = () => {
3090
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "called");
1632
3091
  animation.removeEventListener("DOMLoaded", ready);
1633
3092
  animation.removeEventListener("data_failed", failed);
1634
3093
  signal.removeEventListener("abort", aborted);
3094
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "returned");
1635
3095
  };
1636
3096
  animation.addEventListener("DOMLoaded", ready);
1637
3097
  animation.addEventListener("data_failed", failed);
1638
3098
  signal.addEventListener("abort", aborted, { once: true });
1639
3099
  });
1640
- return {
1641
- destroy: () => animation.destroy(),
1642
- pause: () => animation.pause(),
1643
- play: () => animation.play(),
1644
- 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
+ }
1645
3117
  };
3118
+ dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "resolved", { result });
3119
+ return result;
1646
3120
  };
1647
3121
  function validateTgsAnimation(value, maxLayers) {
3122
+ dialSdkDebugWarn(DEBUG_MODULE, "validateTgsAnimation", "called", {
3123
+ value,
3124
+ maxLayers
3125
+ });
1648
3126
  if (!isRecord(value) || !Array.isArray(value.layers)) throw new MediaPlayerError("decode", "TGS animation does not contain a layers array");
1649
3127
  if (value.layers.length > maxLayers) throw new MediaPlayerError("decode", "TGS animation has too many layers");
1650
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");
1651
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");
1652
3131
  }
1653
3132
  const gunzipWithLimit = (compressed, maxOutputBytes) => {
3133
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "called", {
3134
+ compressed,
3135
+ maxOutputBytes
3136
+ });
1654
3137
  if (compressed.byteLength < 18) throw new MediaPlayerError("decode", "TGS gzip payload is truncated");
1655
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");
1656
3139
  const chunks = [];
1657
3140
  let outputBytes = 0;
1658
3141
  try {
1659
3142
  const gunzip = new Gunzip((chunk) => {
3143
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit.onChunk", "called", {
3144
+ chunk,
3145
+ outputBytes,
3146
+ maxOutputBytes
3147
+ });
1660
3148
  outputBytes += chunk.byteLength;
1661
3149
  if (outputBytes > maxOutputBytes) throw new MediaPlayerError("decode", "TGS JSON payload exceeds the configured limit");
1662
3150
  if (chunk.byteLength > 0) chunks.push(chunk);
@@ -1667,8 +3155,11 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
1667
3155
  gunzip.push(compressed.subarray(offset, end), end === compressed.byteLength);
1668
3156
  }
1669
3157
  } catch (error) {
3158
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "caught error", error);
1670
3159
  if (error instanceof MediaPlayerError) throw error;
1671
- 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;
1672
3163
  }
1673
3164
  const output = new Uint8Array(outputBytes);
1674
3165
  let offset = 0;
@@ -1676,17 +3167,29 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
1676
3167
  output.set(chunk, offset);
1677
3168
  offset += chunk.byteLength;
1678
3169
  }
3170
+ dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "returned", {
3171
+ output,
3172
+ outputBytes
3173
+ });
1679
3174
  return output;
1680
3175
  };
1681
3176
  const resetVideo = (video) => {
3177
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "called", { video });
1682
3178
  video.pause();
1683
3179
  video.removeAttribute("src");
1684
3180
  video.removeAttribute("type");
1685
3181
  try {
1686
3182
  video.load();
1687
- } catch {}
3183
+ } catch (error) {
3184
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "load threw", error);
3185
+ }
3186
+ dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "returned", { video });
1688
3187
  };
1689
3188
  const styleMediaElement = (element, fit) => {
3189
+ dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "called", {
3190
+ element,
3191
+ fit
3192
+ });
1690
3193
  Object.assign(element.style, {
1691
3194
  display: "block",
1692
3195
  height: "100%",
@@ -1695,40 +3198,86 @@ const styleMediaElement = (element, fit) => {
1695
3198
  objectFit: fit,
1696
3199
  width: "100%"
1697
3200
  });
3201
+ dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "returned", { element });
1698
3202
  };
1699
3203
  const categorizeMediaError = (error) => {
1700
- if (error instanceof MediaPlayerError) return error.category;
1701
- if (error instanceof TypeError) return "network";
1702
- 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;
1703
3210
  };
1704
3211
  const safeErrorMessage = (error) => {
3212
+ dialSdkDebugWarn(DEBUG_MODULE, "safeErrorMessage", "called", { error });
1705
3213
  const message = error instanceof Error ? error.message : String(error);
1706
- 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;
1707
3231
  };
1708
- const redactUrlQueries = (message) => message.replace(/https:\/\/[^\s"'<>]+/gu, (candidate) => {
1709
- try {
1710
- const url = new URL(candidate);
1711
- return `${url.origin}${url.pathname}`;
1712
- } catch {
1713
- return "[url]";
1714
- }
1715
- });
1716
3232
  const createAbortError = () => {
1717
- 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
+ }
1718
3239
  const error = /* @__PURE__ */ new Error("Aborted");
1719
3240
  error.name = "AbortError";
3241
+ dialSdkDebugWarn(DEBUG_MODULE, "createAbortError", "returned Error", { result: error });
1720
3242
  return error;
1721
3243
  };
1722
- 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
+ };
1723
3252
  const positiveFinite = (name, value) => {
1724
- 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 });
1725
3263
  return value;
1726
3264
  };
1727
3265
  const safeDestroy = (handle) => {
3266
+ dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "called", { handle });
1728
3267
  try {
1729
3268
  handle.destroy();
1730
- } 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;
1731
3281
  };
1732
- const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1733
3282
  //#endregion
1734
- 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 };
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 };