@djangocfg/ext-support 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +233 -0
  2. package/dist/chunk-AZ4LWZB7.js +2630 -0
  3. package/dist/hooks.cjs +2716 -0
  4. package/dist/hooks.d.cts +255 -0
  5. package/dist/hooks.d.ts +255 -0
  6. package/dist/hooks.js +1 -0
  7. package/dist/index.cjs +2693 -0
  8. package/dist/index.d.cts +1392 -0
  9. package/dist/index.d.ts +1392 -0
  10. package/dist/index.js +1 -0
  11. package/package.json +80 -0
  12. package/src/api/generated/ext_support/_utils/fetchers/ext_support__support.ts +642 -0
  13. package/src/api/generated/ext_support/_utils/fetchers/index.ts +28 -0
  14. package/src/api/generated/ext_support/_utils/hooks/ext_support__support.ts +237 -0
  15. package/src/api/generated/ext_support/_utils/hooks/index.ts +28 -0
  16. package/src/api/generated/ext_support/_utils/schemas/Message.schema.ts +21 -0
  17. package/src/api/generated/ext_support/_utils/schemas/MessageCreate.schema.ts +15 -0
  18. package/src/api/generated/ext_support/_utils/schemas/MessageCreateRequest.schema.ts +15 -0
  19. package/src/api/generated/ext_support/_utils/schemas/MessageRequest.schema.ts +15 -0
  20. package/src/api/generated/ext_support/_utils/schemas/PaginatedMessageList.schema.ts +24 -0
  21. package/src/api/generated/ext_support/_utils/schemas/PaginatedTicketList.schema.ts +24 -0
  22. package/src/api/generated/ext_support/_utils/schemas/PatchedMessageRequest.schema.ts +15 -0
  23. package/src/api/generated/ext_support/_utils/schemas/PatchedTicketRequest.schema.ts +18 -0
  24. package/src/api/generated/ext_support/_utils/schemas/Sender.schema.ts +21 -0
  25. package/src/api/generated/ext_support/_utils/schemas/Ticket.schema.ts +21 -0
  26. package/src/api/generated/ext_support/_utils/schemas/TicketRequest.schema.ts +18 -0
  27. package/src/api/generated/ext_support/_utils/schemas/index.ts +29 -0
  28. package/src/api/generated/ext_support/api-instance.ts +131 -0
  29. package/src/api/generated/ext_support/client.ts +301 -0
  30. package/src/api/generated/ext_support/enums.ts +45 -0
  31. package/src/api/generated/ext_support/errors.ts +116 -0
  32. package/src/api/generated/ext_support/ext_support__support/client.ts +151 -0
  33. package/src/api/generated/ext_support/ext_support__support/index.ts +2 -0
  34. package/src/api/generated/ext_support/ext_support__support/models.ts +165 -0
  35. package/src/api/generated/ext_support/http.ts +103 -0
  36. package/src/api/generated/ext_support/index.ts +273 -0
  37. package/src/api/generated/ext_support/logger.ts +259 -0
  38. package/src/api/generated/ext_support/retry.ts +175 -0
  39. package/src/api/generated/ext_support/schema.json +1049 -0
  40. package/src/api/generated/ext_support/storage.ts +161 -0
  41. package/src/api/generated/ext_support/validation-events.ts +133 -0
  42. package/src/api/index.ts +9 -0
  43. package/src/config.ts +20 -0
  44. package/src/contexts/SupportContext.tsx +250 -0
  45. package/src/contexts/SupportExtensionProvider.tsx +38 -0
  46. package/src/contexts/types.ts +26 -0
  47. package/src/hooks/index.ts +33 -0
  48. package/src/index.ts +39 -0
  49. package/src/layouts/SupportLayout/README.md +91 -0
  50. package/src/layouts/SupportLayout/SupportLayout.tsx +179 -0
  51. package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +155 -0
  52. package/src/layouts/SupportLayout/components/MessageInput.tsx +92 -0
  53. package/src/layouts/SupportLayout/components/MessageList.tsx +312 -0
  54. package/src/layouts/SupportLayout/components/TicketCard.tsx +96 -0
  55. package/src/layouts/SupportLayout/components/TicketList.tsx +153 -0
  56. package/src/layouts/SupportLayout/components/index.ts +6 -0
  57. package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +258 -0
  58. package/src/layouts/SupportLayout/context/index.ts +2 -0
  59. package/src/layouts/SupportLayout/events.ts +33 -0
  60. package/src/layouts/SupportLayout/hooks/index.ts +2 -0
  61. package/src/layouts/SupportLayout/hooks/useInfiniteMessages.ts +115 -0
  62. package/src/layouts/SupportLayout/hooks/useInfiniteTickets.ts +88 -0
  63. package/src/layouts/SupportLayout/index.ts +6 -0
  64. package/src/layouts/SupportLayout/types.ts +21 -0
  65. package/src/utils/logger.ts +14 -0
@@ -0,0 +1,2630 @@
1
+ import { createConsola, consola } from 'consola';
2
+ import pRetry, { AbortError } from 'p-retry';
3
+ import { z } from 'zod';
4
+ import { createExtensionAPI } from '@djangocfg/ext-base/api';
5
+ import React7, { createContext, useContext, useState, useCallback, useEffect, useRef } from 'react';
6
+ import useSWR, { useSWRConfig } from 'swr';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+ import { useAuth } from '@djangocfg/api/auth';
9
+ import useSWRInfinite from 'swr/infinite';
10
+ import { Card, cn, CardContent, Badge, Skeleton, ScrollArea, Button, useToast, Textarea, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Form, FormField, FormItem, FormLabel, FormControl, Input, FormMessage, Avatar, AvatarImage, AvatarFallback, ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@djangocfg/ui-nextjs';
11
+ import { Clock, MessageSquare, Loader2, Send, Plus, Headphones, User, ArrowLeft, LifeBuoy } from 'lucide-react';
12
+ import { useForm } from 'react-hook-form';
13
+ import { zodResolver } from '@hookform/resolvers/zod';
14
+
15
+ var __defProp = Object.defineProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+
21
+ // src/api/generated/ext_support/ext_support__support/client.ts
22
+ var ExtSupportSupport = class {
23
+ client;
24
+ constructor(client) {
25
+ this.client = client;
26
+ }
27
+ /**
28
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
29
+ * or Session). Staff users can see all tickets, regular users see only
30
+ * their own.
31
+ */
32
+ async ticketsList(...args) {
33
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
34
+ let params;
35
+ if (isParamsObject) {
36
+ params = args[0];
37
+ } else {
38
+ params = { page: args[0], page_size: args[1] };
39
+ }
40
+ const response = await this.client.request("GET", "/cfg/support/tickets/", { params });
41
+ return response;
42
+ }
43
+ /**
44
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
45
+ * or Session). Staff users can see all tickets, regular users see only
46
+ * their own.
47
+ */
48
+ async ticketsCreate(data) {
49
+ const response = await this.client.request("POST", "/cfg/support/tickets/", { body: data });
50
+ return response;
51
+ }
52
+ /**
53
+ * ViewSet for managing support messages. Requires authenticated user (JWT
54
+ * or Session). Users can only access messages for their own tickets.
55
+ */
56
+ async ticketsMessagesList(...args) {
57
+ const ticket_uuid = args[0];
58
+ const isParamsObject = args.length === 2 && typeof args[1] === "object" && args[1] !== null && !Array.isArray(args[1]);
59
+ let params;
60
+ if (isParamsObject) {
61
+ params = args[1];
62
+ } else {
63
+ params = { page: args[1], page_size: args[2] };
64
+ }
65
+ const response = await this.client.request("GET", `/cfg/support/tickets/${ticket_uuid}/messages/`, { params });
66
+ return response;
67
+ }
68
+ /**
69
+ * ViewSet for managing support messages. Requires authenticated user (JWT
70
+ * or Session). Users can only access messages for their own tickets.
71
+ */
72
+ async ticketsMessagesCreate(ticket_uuid, data) {
73
+ const response = await this.client.request("POST", `/cfg/support/tickets/${ticket_uuid}/messages/`, { body: data });
74
+ return response;
75
+ }
76
+ /**
77
+ * ViewSet for managing support messages. Requires authenticated user (JWT
78
+ * or Session). Users can only access messages for their own tickets.
79
+ */
80
+ async ticketsMessagesRetrieve(ticket_uuid, uuid) {
81
+ const response = await this.client.request("GET", `/cfg/support/tickets/${ticket_uuid}/messages/${uuid}/`);
82
+ return response;
83
+ }
84
+ /**
85
+ * ViewSet for managing support messages. Requires authenticated user (JWT
86
+ * or Session). Users can only access messages for their own tickets.
87
+ */
88
+ async ticketsMessagesUpdate(ticket_uuid, uuid, data) {
89
+ const response = await this.client.request("PUT", `/cfg/support/tickets/${ticket_uuid}/messages/${uuid}/`, { body: data });
90
+ return response;
91
+ }
92
+ /**
93
+ * ViewSet for managing support messages. Requires authenticated user (JWT
94
+ * or Session). Users can only access messages for their own tickets.
95
+ */
96
+ async ticketsMessagesPartialUpdate(ticket_uuid, uuid, data) {
97
+ const response = await this.client.request("PATCH", `/cfg/support/tickets/${ticket_uuid}/messages/${uuid}/`, { body: data });
98
+ return response;
99
+ }
100
+ /**
101
+ * ViewSet for managing support messages. Requires authenticated user (JWT
102
+ * or Session). Users can only access messages for their own tickets.
103
+ */
104
+ async ticketsMessagesDestroy(ticket_uuid, uuid) {
105
+ await this.client.request("DELETE", `/cfg/support/tickets/${ticket_uuid}/messages/${uuid}/`);
106
+ return;
107
+ }
108
+ /**
109
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
110
+ * or Session). Staff users can see all tickets, regular users see only
111
+ * their own.
112
+ */
113
+ async ticketsRetrieve(uuid) {
114
+ const response = await this.client.request("GET", `/cfg/support/tickets/${uuid}/`);
115
+ return response;
116
+ }
117
+ /**
118
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
119
+ * or Session). Staff users can see all tickets, regular users see only
120
+ * their own.
121
+ */
122
+ async ticketsUpdate(uuid, data) {
123
+ const response = await this.client.request("PUT", `/cfg/support/tickets/${uuid}/`, { body: data });
124
+ return response;
125
+ }
126
+ /**
127
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
128
+ * or Session). Staff users can see all tickets, regular users see only
129
+ * their own.
130
+ */
131
+ async ticketsPartialUpdate(uuid, data) {
132
+ const response = await this.client.request("PATCH", `/cfg/support/tickets/${uuid}/`, { body: data });
133
+ return response;
134
+ }
135
+ /**
136
+ * ViewSet for managing support tickets. Requires authenticated user (JWT
137
+ * or Session). Staff users can see all tickets, regular users see only
138
+ * their own.
139
+ */
140
+ async ticketsDestroy(uuid) {
141
+ await this.client.request("DELETE", `/cfg/support/tickets/${uuid}/`);
142
+ return;
143
+ }
144
+ };
145
+
146
+ // src/api/generated/ext_support/ext_support__support/models.ts
147
+ var models_exports = {};
148
+
149
+ // src/api/generated/ext_support/http.ts
150
+ var FetchAdapter = class {
151
+ async request(request) {
152
+ const { method, url, headers, body, params, formData } = request;
153
+ let finalUrl = url;
154
+ if (params) {
155
+ const searchParams = new URLSearchParams();
156
+ Object.entries(params).forEach(([key, value]) => {
157
+ if (value !== null && value !== void 0) {
158
+ searchParams.append(key, String(value));
159
+ }
160
+ });
161
+ const queryString = searchParams.toString();
162
+ if (queryString) {
163
+ finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
164
+ }
165
+ }
166
+ const finalHeaders = { ...headers };
167
+ let requestBody;
168
+ if (formData) {
169
+ requestBody = formData;
170
+ } else if (body) {
171
+ finalHeaders["Content-Type"] = "application/json";
172
+ requestBody = JSON.stringify(body);
173
+ }
174
+ const response = await fetch(finalUrl, {
175
+ method,
176
+ headers: finalHeaders,
177
+ body: requestBody,
178
+ credentials: "include"
179
+ // Include Django session cookies
180
+ });
181
+ let data = null;
182
+ const contentType = response.headers.get("content-type");
183
+ if (response.status !== 204 && contentType?.includes("application/json")) {
184
+ data = await response.json();
185
+ } else if (response.status !== 204) {
186
+ data = await response.text();
187
+ }
188
+ const responseHeaders = {};
189
+ response.headers.forEach((value, key) => {
190
+ responseHeaders[key] = value;
191
+ });
192
+ return {
193
+ data,
194
+ status: response.status,
195
+ statusText: response.statusText,
196
+ headers: responseHeaders
197
+ };
198
+ }
199
+ };
200
+
201
+ // src/api/generated/ext_support/errors.ts
202
+ var APIError = class extends Error {
203
+ constructor(statusCode, statusText, response, url, message) {
204
+ super(message || `HTTP ${statusCode}: ${statusText}`);
205
+ this.statusCode = statusCode;
206
+ this.statusText = statusText;
207
+ this.response = response;
208
+ this.url = url;
209
+ this.name = "APIError";
210
+ }
211
+ /**
212
+ * Get error details from response.
213
+ * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
214
+ */
215
+ get details() {
216
+ if (typeof this.response === "object" && this.response !== null) {
217
+ return this.response;
218
+ }
219
+ return null;
220
+ }
221
+ /**
222
+ * Get field-specific validation errors from DRF.
223
+ * Returns: { "field_name": ["error1", "error2"], ... }
224
+ */
225
+ get fieldErrors() {
226
+ const details = this.details;
227
+ if (!details) return null;
228
+ const fieldErrors = {};
229
+ for (const [key, value] of Object.entries(details)) {
230
+ if (Array.isArray(value)) {
231
+ fieldErrors[key] = value;
232
+ }
233
+ }
234
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
235
+ }
236
+ /**
237
+ * Get single error message from DRF.
238
+ * Checks for "detail", "message", or first field error.
239
+ */
240
+ get errorMessage() {
241
+ const details = this.details;
242
+ if (!details) return this.message;
243
+ if (details.detail) {
244
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
245
+ }
246
+ if (details.message) {
247
+ return String(details.message);
248
+ }
249
+ const fieldErrors = this.fieldErrors;
250
+ if (fieldErrors) {
251
+ const firstField = Object.keys(fieldErrors)[0];
252
+ if (firstField) {
253
+ return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
254
+ }
255
+ }
256
+ return this.message;
257
+ }
258
+ // Helper methods for common HTTP status codes
259
+ get isValidationError() {
260
+ return this.statusCode === 400;
261
+ }
262
+ get isAuthError() {
263
+ return this.statusCode === 401;
264
+ }
265
+ get isPermissionError() {
266
+ return this.statusCode === 403;
267
+ }
268
+ get isNotFoundError() {
269
+ return this.statusCode === 404;
270
+ }
271
+ get isServerError() {
272
+ return this.statusCode >= 500 && this.statusCode < 600;
273
+ }
274
+ };
275
+ var NetworkError = class extends Error {
276
+ constructor(message, url, originalError) {
277
+ super(message);
278
+ this.url = url;
279
+ this.originalError = originalError;
280
+ this.name = "NetworkError";
281
+ }
282
+ };
283
+ var DEFAULT_CONFIG = {
284
+ enabled: process.env.NODE_ENV !== "production",
285
+ logRequests: true,
286
+ logResponses: true,
287
+ logErrors: true,
288
+ logBodies: true,
289
+ logHeaders: false
290
+ };
291
+ var SENSITIVE_HEADERS = [
292
+ "authorization",
293
+ "cookie",
294
+ "set-cookie",
295
+ "x-api-key",
296
+ "x-csrf-token"
297
+ ];
298
+ var APILogger = class {
299
+ config;
300
+ consola;
301
+ constructor(config = {}) {
302
+ this.config = { ...DEFAULT_CONFIG, ...config };
303
+ this.consola = config.consola || createConsola({
304
+ level: this.config.enabled ? 4 : 0
305
+ });
306
+ }
307
+ /**
308
+ * Enable logging
309
+ */
310
+ enable() {
311
+ this.config.enabled = true;
312
+ }
313
+ /**
314
+ * Disable logging
315
+ */
316
+ disable() {
317
+ this.config.enabled = false;
318
+ }
319
+ /**
320
+ * Update configuration
321
+ */
322
+ setConfig(config) {
323
+ this.config = { ...this.config, ...config };
324
+ }
325
+ /**
326
+ * Filter sensitive headers
327
+ */
328
+ filterHeaders(headers) {
329
+ if (!headers) return {};
330
+ const filtered = {};
331
+ Object.keys(headers).forEach((key) => {
332
+ const lowerKey = key.toLowerCase();
333
+ if (SENSITIVE_HEADERS.includes(lowerKey)) {
334
+ filtered[key] = "***";
335
+ } else {
336
+ filtered[key] = headers[key] || "";
337
+ }
338
+ });
339
+ return filtered;
340
+ }
341
+ /**
342
+ * Log request
343
+ */
344
+ logRequest(request) {
345
+ if (!this.config.enabled || !this.config.logRequests) return;
346
+ const { method, url, headers, body } = request;
347
+ this.consola.start(`${method} ${url}`);
348
+ if (this.config.logHeaders && headers) {
349
+ this.consola.debug("Headers:", this.filterHeaders(headers));
350
+ }
351
+ if (this.config.logBodies && body) {
352
+ this.consola.debug("Body:", body);
353
+ }
354
+ }
355
+ /**
356
+ * Log response
357
+ */
358
+ logResponse(request, response) {
359
+ if (!this.config.enabled || !this.config.logResponses) return;
360
+ const { method, url } = request;
361
+ const { status, statusText, data, duration } = response;
362
+ this.consola.success(
363
+ `${method} ${url} ${status} ${statusText} (${duration}ms)`
364
+ );
365
+ if (this.config.logBodies && data) {
366
+ this.consola.debug("Response:", data);
367
+ }
368
+ }
369
+ /**
370
+ * Log error
371
+ */
372
+ logError(request, error) {
373
+ if (!this.config.enabled || !this.config.logErrors) return;
374
+ const { method, url } = request;
375
+ const { message, statusCode, fieldErrors, duration } = error;
376
+ this.consola.error(
377
+ `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
378
+ );
379
+ this.consola.error("Message:", message);
380
+ if (fieldErrors && Object.keys(fieldErrors).length > 0) {
381
+ this.consola.error("Field Errors:");
382
+ Object.entries(fieldErrors).forEach(([field, errors]) => {
383
+ errors.forEach((err) => {
384
+ this.consola.error(` \u2022 ${field}: ${err}`);
385
+ });
386
+ });
387
+ }
388
+ }
389
+ /**
390
+ * Log general info
391
+ */
392
+ info(message, ...args) {
393
+ if (!this.config.enabled) return;
394
+ this.consola.info(message, ...args);
395
+ }
396
+ /**
397
+ * Log warning
398
+ */
399
+ warn(message, ...args) {
400
+ if (!this.config.enabled) return;
401
+ this.consola.warn(message, ...args);
402
+ }
403
+ /**
404
+ * Log error
405
+ */
406
+ error(message, ...args) {
407
+ if (!this.config.enabled) return;
408
+ this.consola.error(message, ...args);
409
+ }
410
+ /**
411
+ * Log debug
412
+ */
413
+ debug(message, ...args) {
414
+ if (!this.config.enabled) return;
415
+ this.consola.debug(message, ...args);
416
+ }
417
+ /**
418
+ * Log success
419
+ */
420
+ success(message, ...args) {
421
+ if (!this.config.enabled) return;
422
+ this.consola.success(message, ...args);
423
+ }
424
+ /**
425
+ * Create a sub-logger with prefix
426
+ */
427
+ withTag(tag) {
428
+ return this.consola.withTag(tag);
429
+ }
430
+ };
431
+ new APILogger();
432
+ var DEFAULT_RETRY_CONFIG = {
433
+ retries: 3,
434
+ factor: 2,
435
+ minTimeout: 1e3,
436
+ maxTimeout: 6e4,
437
+ randomize: true,
438
+ onFailedAttempt: () => {
439
+ }
440
+ };
441
+ function shouldRetry(error) {
442
+ if (error instanceof NetworkError) {
443
+ return true;
444
+ }
445
+ if (error instanceof APIError) {
446
+ const status = error.statusCode;
447
+ if (status >= 500 && status < 600) {
448
+ return true;
449
+ }
450
+ if (status === 429) {
451
+ return true;
452
+ }
453
+ return false;
454
+ }
455
+ return true;
456
+ }
457
+ async function withRetry(fn, config) {
458
+ const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
459
+ return pRetry(
460
+ async () => {
461
+ try {
462
+ return await fn();
463
+ } catch (error) {
464
+ if (!shouldRetry(error)) {
465
+ throw new AbortError(error);
466
+ }
467
+ throw error;
468
+ }
469
+ },
470
+ {
471
+ retries: finalConfig.retries,
472
+ factor: finalConfig.factor,
473
+ minTimeout: finalConfig.minTimeout,
474
+ maxTimeout: finalConfig.maxTimeout,
475
+ randomize: finalConfig.randomize,
476
+ onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
477
+ const pRetryError = error;
478
+ finalConfig.onFailedAttempt({
479
+ error: pRetryError,
480
+ attemptNumber: pRetryError.attemptNumber,
481
+ retriesLeft: pRetryError.retriesLeft
482
+ });
483
+ } : void 0
484
+ }
485
+ );
486
+ }
487
+
488
+ // src/api/generated/ext_support/client.ts
489
+ var APIClient = class {
490
+ baseUrl;
491
+ httpClient;
492
+ logger = null;
493
+ retryConfig = null;
494
+ // Sub-clients
495
+ ext_support_support;
496
+ constructor(baseUrl, options) {
497
+ this.baseUrl = baseUrl.replace(/\/$/, "");
498
+ this.httpClient = options?.httpClient || new FetchAdapter();
499
+ if (options?.loggerConfig !== void 0) {
500
+ this.logger = new APILogger(options.loggerConfig);
501
+ }
502
+ if (options?.retryConfig !== void 0) {
503
+ this.retryConfig = options.retryConfig;
504
+ }
505
+ this.ext_support_support = new ExtSupportSupport(this);
506
+ }
507
+ /**
508
+ * Get CSRF token from cookies (for SessionAuthentication).
509
+ *
510
+ * Returns null if cookie doesn't exist (JWT-only auth).
511
+ */
512
+ getCsrfToken() {
513
+ const name = "csrftoken";
514
+ const value = `; ${document.cookie}`;
515
+ const parts = value.split(`; ${name}=`);
516
+ if (parts.length === 2) {
517
+ return parts.pop()?.split(";").shift() || null;
518
+ }
519
+ return null;
520
+ }
521
+ /**
522
+ * Make HTTP request with Django CSRF and session handling.
523
+ * Automatically retries on network errors and 5xx server errors.
524
+ */
525
+ async request(method, path, options) {
526
+ if (this.retryConfig) {
527
+ return withRetry(() => this._makeRequest(method, path, options), {
528
+ ...this.retryConfig,
529
+ onFailedAttempt: (info) => {
530
+ if (this.logger) {
531
+ this.logger.warn(
532
+ `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
533
+ );
534
+ }
535
+ this.retryConfig?.onFailedAttempt?.(info);
536
+ }
537
+ });
538
+ }
539
+ return this._makeRequest(method, path, options);
540
+ }
541
+ /**
542
+ * Internal request method (without retry wrapper).
543
+ * Used by request() method with optional retry logic.
544
+ */
545
+ async _makeRequest(method, path, options) {
546
+ const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
547
+ const startTime = Date.now();
548
+ const headers = {
549
+ ...options?.headers || {}
550
+ };
551
+ if (!options?.formData && !headers["Content-Type"]) {
552
+ headers["Content-Type"] = "application/json";
553
+ }
554
+ if (this.logger) {
555
+ this.logger.logRequest({
556
+ method,
557
+ url,
558
+ headers,
559
+ body: options?.formData || options?.body,
560
+ timestamp: startTime
561
+ });
562
+ }
563
+ try {
564
+ const response = await this.httpClient.request({
565
+ method,
566
+ url,
567
+ headers,
568
+ params: options?.params,
569
+ body: options?.body,
570
+ formData: options?.formData
571
+ });
572
+ const duration = Date.now() - startTime;
573
+ if (response.status >= 400) {
574
+ const error = new APIError(
575
+ response.status,
576
+ response.statusText,
577
+ response.data,
578
+ url
579
+ );
580
+ if (this.logger) {
581
+ this.logger.logError(
582
+ {
583
+ method,
584
+ url,
585
+ headers,
586
+ body: options?.formData || options?.body,
587
+ timestamp: startTime
588
+ },
589
+ {
590
+ message: error.message,
591
+ statusCode: response.status,
592
+ duration,
593
+ timestamp: Date.now()
594
+ }
595
+ );
596
+ }
597
+ throw error;
598
+ }
599
+ if (this.logger) {
600
+ this.logger.logResponse(
601
+ {
602
+ method,
603
+ url,
604
+ headers,
605
+ body: options?.formData || options?.body,
606
+ timestamp: startTime
607
+ },
608
+ {
609
+ status: response.status,
610
+ statusText: response.statusText,
611
+ data: response.data,
612
+ duration,
613
+ timestamp: Date.now()
614
+ }
615
+ );
616
+ }
617
+ return response.data;
618
+ } catch (error) {
619
+ const duration = Date.now() - startTime;
620
+ if (error instanceof APIError) {
621
+ throw error;
622
+ }
623
+ const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
624
+ if (this.logger) {
625
+ if (isCORSError) {
626
+ this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
627
+ this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
628
+ this.logger.error(` \u2192 Configure security_domains parameter on the server`);
629
+ } else {
630
+ this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
631
+ this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
632
+ }
633
+ }
634
+ if (typeof window !== "undefined") {
635
+ try {
636
+ if (isCORSError) {
637
+ window.dispatchEvent(new CustomEvent("cors-error", {
638
+ detail: {
639
+ url,
640
+ method,
641
+ error: error instanceof Error ? error.message : String(error),
642
+ timestamp: /* @__PURE__ */ new Date()
643
+ },
644
+ bubbles: true,
645
+ cancelable: false
646
+ }));
647
+ } else {
648
+ window.dispatchEvent(new CustomEvent("network-error", {
649
+ detail: {
650
+ url,
651
+ method,
652
+ error: error instanceof Error ? error.message : String(error),
653
+ timestamp: /* @__PURE__ */ new Date()
654
+ },
655
+ bubbles: true,
656
+ cancelable: false
657
+ }));
658
+ }
659
+ } catch (eventError) {
660
+ }
661
+ }
662
+ const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
663
+ if (this.logger) {
664
+ this.logger.logError(
665
+ {
666
+ method,
667
+ url,
668
+ headers,
669
+ body: options?.formData || options?.body,
670
+ timestamp: startTime
671
+ },
672
+ {
673
+ message: networkError.message,
674
+ duration,
675
+ timestamp: Date.now()
676
+ }
677
+ );
678
+ }
679
+ throw networkError;
680
+ }
681
+ }
682
+ };
683
+
684
+ // src/api/generated/ext_support/storage.ts
685
+ var LocalStorageAdapter = class {
686
+ logger;
687
+ constructor(logger2) {
688
+ this.logger = logger2;
689
+ }
690
+ getItem(key) {
691
+ try {
692
+ if (typeof window !== "undefined" && window.localStorage) {
693
+ const value = localStorage.getItem(key);
694
+ this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
695
+ return value;
696
+ }
697
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
698
+ } catch (error) {
699
+ this.logger?.error("LocalStorage.getItem failed:", error);
700
+ }
701
+ return null;
702
+ }
703
+ setItem(key, value) {
704
+ try {
705
+ if (typeof window !== "undefined" && window.localStorage) {
706
+ localStorage.setItem(key, value);
707
+ this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
708
+ } else {
709
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
710
+ }
711
+ } catch (error) {
712
+ this.logger?.error("LocalStorage.setItem failed:", error);
713
+ }
714
+ }
715
+ removeItem(key) {
716
+ try {
717
+ if (typeof window !== "undefined" && window.localStorage) {
718
+ localStorage.removeItem(key);
719
+ this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
720
+ } else {
721
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
722
+ }
723
+ } catch (error) {
724
+ this.logger?.error("LocalStorage.removeItem failed:", error);
725
+ }
726
+ }
727
+ };
728
+ var CookieStorageAdapter = class {
729
+ logger;
730
+ constructor(logger2) {
731
+ this.logger = logger2;
732
+ }
733
+ getItem(key) {
734
+ try {
735
+ if (typeof document === "undefined") {
736
+ this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
737
+ return null;
738
+ }
739
+ const value = `; ${document.cookie}`;
740
+ const parts = value.split(`; ${key}=`);
741
+ if (parts.length === 2) {
742
+ const result = parts.pop()?.split(";").shift() || null;
743
+ this.logger?.debug(`CookieStorage.getItem("${key}"): ${result ? "found" : "not found"}`);
744
+ return result;
745
+ }
746
+ this.logger?.debug(`CookieStorage.getItem("${key}"): not found`);
747
+ } catch (error) {
748
+ this.logger?.error("CookieStorage.getItem failed:", error);
749
+ }
750
+ return null;
751
+ }
752
+ setItem(key, value) {
753
+ try {
754
+ if (typeof document !== "undefined") {
755
+ document.cookie = `${key}=${value}; path=/; max-age=31536000`;
756
+ this.logger?.debug(`CookieStorage.setItem("${key}"): success`);
757
+ } else {
758
+ this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
759
+ }
760
+ } catch (error) {
761
+ this.logger?.error("CookieStorage.setItem failed:", error);
762
+ }
763
+ }
764
+ removeItem(key) {
765
+ try {
766
+ if (typeof document !== "undefined") {
767
+ document.cookie = `${key}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
768
+ this.logger?.debug(`CookieStorage.removeItem("${key}"): success`);
769
+ } else {
770
+ this.logger?.warn("Cookies not available: document is undefined (SSR context?)");
771
+ }
772
+ } catch (error) {
773
+ this.logger?.error("CookieStorage.removeItem failed:", error);
774
+ }
775
+ }
776
+ };
777
+ var MemoryStorageAdapter = class {
778
+ storage = /* @__PURE__ */ new Map();
779
+ logger;
780
+ constructor(logger2) {
781
+ this.logger = logger2;
782
+ }
783
+ getItem(key) {
784
+ const value = this.storage.get(key) || null;
785
+ this.logger?.debug(`MemoryStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
786
+ return value;
787
+ }
788
+ setItem(key, value) {
789
+ this.storage.set(key, value);
790
+ this.logger?.debug(`MemoryStorage.setItem("${key}"): success`);
791
+ }
792
+ removeItem(key) {
793
+ this.storage.delete(key);
794
+ this.logger?.debug(`MemoryStorage.removeItem("${key}"): success`);
795
+ }
796
+ };
797
+
798
+ // src/api/generated/ext_support/enums.ts
799
+ var enums_exports = {};
800
+ __export(enums_exports, {
801
+ PatchedTicketRequestStatus: () => PatchedTicketRequestStatus,
802
+ TicketRequestStatus: () => TicketRequestStatus,
803
+ TicketStatus: () => TicketStatus
804
+ });
805
+ var PatchedTicketRequestStatus = /* @__PURE__ */ ((PatchedTicketRequestStatus2) => {
806
+ PatchedTicketRequestStatus2["OPEN"] = "open";
807
+ PatchedTicketRequestStatus2["WAITING_FOR_USER"] = "waiting_for_user";
808
+ PatchedTicketRequestStatus2["WAITING_FOR_ADMIN"] = "waiting_for_admin";
809
+ PatchedTicketRequestStatus2["RESOLVED"] = "resolved";
810
+ PatchedTicketRequestStatus2["CLOSED"] = "closed";
811
+ return PatchedTicketRequestStatus2;
812
+ })(PatchedTicketRequestStatus || {});
813
+ var TicketStatus = /* @__PURE__ */ ((TicketStatus2) => {
814
+ TicketStatus2["OPEN"] = "open";
815
+ TicketStatus2["WAITING_FOR_USER"] = "waiting_for_user";
816
+ TicketStatus2["WAITING_FOR_ADMIN"] = "waiting_for_admin";
817
+ TicketStatus2["RESOLVED"] = "resolved";
818
+ TicketStatus2["CLOSED"] = "closed";
819
+ return TicketStatus2;
820
+ })(TicketStatus || {});
821
+ var TicketRequestStatus = /* @__PURE__ */ ((TicketRequestStatus2) => {
822
+ TicketRequestStatus2["OPEN"] = "open";
823
+ TicketRequestStatus2["WAITING_FOR_USER"] = "waiting_for_user";
824
+ TicketRequestStatus2["WAITING_FOR_ADMIN"] = "waiting_for_admin";
825
+ TicketRequestStatus2["RESOLVED"] = "resolved";
826
+ TicketRequestStatus2["CLOSED"] = "closed";
827
+ return TicketRequestStatus2;
828
+ })(TicketRequestStatus || {});
829
+
830
+ // src/api/generated/ext_support/_utils/schemas/index.ts
831
+ var schemas_exports = {};
832
+ __export(schemas_exports, {
833
+ MessageCreateRequestSchema: () => MessageCreateRequestSchema,
834
+ MessageCreateSchema: () => MessageCreateSchema,
835
+ MessageRequestSchema: () => MessageRequestSchema,
836
+ MessageSchema: () => MessageSchema,
837
+ PaginatedMessageListSchema: () => PaginatedMessageListSchema,
838
+ PaginatedTicketListSchema: () => PaginatedTicketListSchema,
839
+ PatchedMessageRequestSchema: () => PatchedMessageRequestSchema,
840
+ PatchedTicketRequestSchema: () => PatchedTicketRequestSchema,
841
+ SenderSchema: () => SenderSchema,
842
+ TicketRequestSchema: () => TicketRequestSchema,
843
+ TicketSchema: () => TicketSchema
844
+ });
845
+ var SenderSchema = z.object({
846
+ id: z.int(),
847
+ display_username: z.string(),
848
+ email: z.email(),
849
+ avatar: z.string().nullable(),
850
+ initials: z.string(),
851
+ is_staff: z.boolean(),
852
+ is_superuser: z.boolean()
853
+ });
854
+
855
+ // src/api/generated/ext_support/_utils/schemas/Message.schema.ts
856
+ var MessageSchema = z.object({
857
+ uuid: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
858
+ ticket: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
859
+ sender: SenderSchema,
860
+ is_from_author: z.boolean(),
861
+ text: z.string(),
862
+ created_at: z.iso.datetime()
863
+ });
864
+ var MessageCreateSchema = z.object({
865
+ text: z.string()
866
+ });
867
+ var MessageCreateRequestSchema = z.object({
868
+ text: z.string().min(1)
869
+ });
870
+ var MessageRequestSchema = z.object({
871
+ text: z.string().min(1)
872
+ });
873
+ var PaginatedMessageListSchema = z.object({
874
+ count: z.int(),
875
+ page: z.int(),
876
+ pages: z.int(),
877
+ page_size: z.int(),
878
+ has_next: z.boolean(),
879
+ has_previous: z.boolean(),
880
+ next_page: z.int().nullable().optional(),
881
+ previous_page: z.int().nullable().optional(),
882
+ results: z.array(MessageSchema)
883
+ });
884
+ var TicketSchema = z.object({
885
+ uuid: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
886
+ user: z.int(),
887
+ subject: z.string().max(255),
888
+ status: z.nativeEnum(TicketStatus).optional(),
889
+ created_at: z.iso.datetime(),
890
+ unanswered_messages_count: z.int()
891
+ });
892
+
893
+ // src/api/generated/ext_support/_utils/schemas/PaginatedTicketList.schema.ts
894
+ var PaginatedTicketListSchema = z.object({
895
+ count: z.int(),
896
+ page: z.int(),
897
+ pages: z.int(),
898
+ page_size: z.int(),
899
+ has_next: z.boolean(),
900
+ has_previous: z.boolean(),
901
+ next_page: z.int().nullable().optional(),
902
+ previous_page: z.int().nullable().optional(),
903
+ results: z.array(TicketSchema)
904
+ });
905
+ var PatchedMessageRequestSchema = z.object({
906
+ text: z.string().min(1).optional()
907
+ });
908
+ var PatchedTicketRequestSchema = z.object({
909
+ user: z.int().optional(),
910
+ subject: z.string().min(1).max(255).optional(),
911
+ status: z.nativeEnum(PatchedTicketRequestStatus).optional()
912
+ });
913
+ var TicketRequestSchema = z.object({
914
+ user: z.int(),
915
+ subject: z.string().min(1).max(255),
916
+ status: z.nativeEnum(TicketRequestStatus).optional()
917
+ });
918
+
919
+ // src/api/generated/ext_support/validation-events.ts
920
+ function dispatchValidationError(detail) {
921
+ if (typeof window === "undefined") {
922
+ return;
923
+ }
924
+ try {
925
+ const event = new CustomEvent("zod-validation-error", {
926
+ detail,
927
+ bubbles: true,
928
+ cancelable: false
929
+ });
930
+ window.dispatchEvent(event);
931
+ } catch (error) {
932
+ console.warn("Failed to dispatch validation error event:", error);
933
+ }
934
+ }
935
+ function onValidationError(callback) {
936
+ if (typeof window === "undefined") {
937
+ return () => {
938
+ };
939
+ }
940
+ const handler = (event) => {
941
+ if (event instanceof CustomEvent) {
942
+ callback(event.detail);
943
+ }
944
+ };
945
+ window.addEventListener("zod-validation-error", handler);
946
+ return () => {
947
+ window.removeEventListener("zod-validation-error", handler);
948
+ };
949
+ }
950
+ function formatZodError(error) {
951
+ const issues = error.issues.map((issue, index) => {
952
+ const path = issue.path.join(".") || "root";
953
+ const parts = [`${index + 1}. ${path}: ${issue.message}`];
954
+ if ("expected" in issue && issue.expected) {
955
+ parts.push(` Expected: ${issue.expected}`);
956
+ }
957
+ if ("received" in issue && issue.received) {
958
+ parts.push(` Received: ${issue.received}`);
959
+ }
960
+ return parts.join("\n");
961
+ });
962
+ return issues.join("\n");
963
+ }
964
+
965
+ // src/api/generated/ext_support/_utils/fetchers/index.ts
966
+ var fetchers_exports = {};
967
+ __export(fetchers_exports, {
968
+ createSupportTicketsCreate: () => createSupportTicketsCreate,
969
+ createSupportTicketsMessagesCreate: () => createSupportTicketsMessagesCreate,
970
+ deleteSupportTicketsDestroy: () => deleteSupportTicketsDestroy,
971
+ deleteSupportTicketsMessagesDestroy: () => deleteSupportTicketsMessagesDestroy,
972
+ getSupportTicketsList: () => getSupportTicketsList,
973
+ getSupportTicketsMessagesList: () => getSupportTicketsMessagesList,
974
+ getSupportTicketsMessagesRetrieve: () => getSupportTicketsMessagesRetrieve,
975
+ getSupportTicketsRetrieve: () => getSupportTicketsRetrieve,
976
+ partialUpdateSupportTicketsMessagesPartialUpdate: () => partialUpdateSupportTicketsMessagesPartialUpdate,
977
+ partialUpdateSupportTicketsPartialUpdate: () => partialUpdateSupportTicketsPartialUpdate,
978
+ updateSupportTicketsMessagesUpdate: () => updateSupportTicketsMessagesUpdate,
979
+ updateSupportTicketsUpdate: () => updateSupportTicketsUpdate
980
+ });
981
+
982
+ // src/api/generated/ext_support/api-instance.ts
983
+ var globalAPI = null;
984
+ function getAPIInstance() {
985
+ if (!globalAPI) {
986
+ throw new Error(
987
+ 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })'
988
+ );
989
+ }
990
+ return globalAPI;
991
+ }
992
+ function isAPIConfigured() {
993
+ return globalAPI !== null;
994
+ }
995
+ function configureAPI(config) {
996
+ globalAPI = new API(config.baseUrl, config.options);
997
+ if (config.token) {
998
+ globalAPI.setToken(config.token, config.refreshToken);
999
+ }
1000
+ return globalAPI;
1001
+ }
1002
+ function reconfigureAPI(updates) {
1003
+ const instance = getAPIInstance();
1004
+ if (updates.baseUrl) {
1005
+ instance.setBaseUrl(updates.baseUrl);
1006
+ }
1007
+ if (updates.token) {
1008
+ instance.setToken(updates.token, updates.refreshToken);
1009
+ }
1010
+ return instance;
1011
+ }
1012
+ function clearAPITokens() {
1013
+ const instance = getAPIInstance();
1014
+ instance.clearTokens();
1015
+ }
1016
+ function resetAPI() {
1017
+ if (globalAPI) {
1018
+ globalAPI.clearTokens();
1019
+ }
1020
+ globalAPI = null;
1021
+ }
1022
+
1023
+ // src/api/generated/ext_support/_utils/fetchers/ext_support__support.ts
1024
+ async function getSupportTicketsList(params, client) {
1025
+ const api = client || getAPIInstance();
1026
+ const response = await api.ext_support_support.ticketsList(params?.page, params?.page_size);
1027
+ try {
1028
+ return PaginatedTicketListSchema.parse(response);
1029
+ } catch (error) {
1030
+ consola.error("\u274C Zod Validation Failed");
1031
+ consola.box(`getSupportTicketsList
1032
+ Path: /cfg/support/tickets/
1033
+ Method: GET`);
1034
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1035
+ consola.error("Validation Issues:");
1036
+ error.issues.forEach((issue, index) => {
1037
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1038
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1039
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1040
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1041
+ });
1042
+ }
1043
+ consola.error("Response data:", response);
1044
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1045
+ try {
1046
+ const event = new CustomEvent("zod-validation-error", {
1047
+ detail: {
1048
+ operation: "getSupportTicketsList",
1049
+ path: "/cfg/support/tickets/",
1050
+ method: "GET",
1051
+ error,
1052
+ response,
1053
+ timestamp: /* @__PURE__ */ new Date()
1054
+ },
1055
+ bubbles: true,
1056
+ cancelable: false
1057
+ });
1058
+ window.dispatchEvent(event);
1059
+ } catch (eventError) {
1060
+ consola.warn("Failed to dispatch validation error event:", eventError);
1061
+ }
1062
+ }
1063
+ throw error;
1064
+ }
1065
+ }
1066
+ async function createSupportTicketsCreate(data, client) {
1067
+ const api = client || getAPIInstance();
1068
+ const response = await api.ext_support_support.ticketsCreate(data);
1069
+ try {
1070
+ return TicketSchema.parse(response);
1071
+ } catch (error) {
1072
+ consola.error("\u274C Zod Validation Failed");
1073
+ consola.box(`createSupportTicketsCreate
1074
+ Path: /cfg/support/tickets/
1075
+ Method: POST`);
1076
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1077
+ consola.error("Validation Issues:");
1078
+ error.issues.forEach((issue, index) => {
1079
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1080
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1081
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1082
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1083
+ });
1084
+ }
1085
+ consola.error("Response data:", response);
1086
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1087
+ try {
1088
+ const event = new CustomEvent("zod-validation-error", {
1089
+ detail: {
1090
+ operation: "createSupportTicketsCreate",
1091
+ path: "/cfg/support/tickets/",
1092
+ method: "POST",
1093
+ error,
1094
+ response,
1095
+ timestamp: /* @__PURE__ */ new Date()
1096
+ },
1097
+ bubbles: true,
1098
+ cancelable: false
1099
+ });
1100
+ window.dispatchEvent(event);
1101
+ } catch (eventError) {
1102
+ consola.warn("Failed to dispatch validation error event:", eventError);
1103
+ }
1104
+ }
1105
+ throw error;
1106
+ }
1107
+ }
1108
+ async function getSupportTicketsMessagesList(ticket_uuid, params, client) {
1109
+ const api = client || getAPIInstance();
1110
+ const response = await api.ext_support_support.ticketsMessagesList(ticket_uuid, params?.page, params?.page_size);
1111
+ try {
1112
+ return PaginatedMessageListSchema.parse(response);
1113
+ } catch (error) {
1114
+ consola.error("\u274C Zod Validation Failed");
1115
+ consola.box(`getSupportTicketsMessagesList
1116
+ Path: /cfg/support/tickets/{ticket_uuid}/messages/
1117
+ Method: GET`);
1118
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1119
+ consola.error("Validation Issues:");
1120
+ error.issues.forEach((issue, index) => {
1121
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1122
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1123
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1124
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1125
+ });
1126
+ }
1127
+ consola.error("Response data:", response);
1128
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1129
+ try {
1130
+ const event = new CustomEvent("zod-validation-error", {
1131
+ detail: {
1132
+ operation: "getSupportTicketsMessagesList",
1133
+ path: "/cfg/support/tickets/{ticket_uuid}/messages/",
1134
+ method: "GET",
1135
+ error,
1136
+ response,
1137
+ timestamp: /* @__PURE__ */ new Date()
1138
+ },
1139
+ bubbles: true,
1140
+ cancelable: false
1141
+ });
1142
+ window.dispatchEvent(event);
1143
+ } catch (eventError) {
1144
+ consola.warn("Failed to dispatch validation error event:", eventError);
1145
+ }
1146
+ }
1147
+ throw error;
1148
+ }
1149
+ }
1150
+ async function createSupportTicketsMessagesCreate(ticket_uuid, data, client) {
1151
+ const api = client || getAPIInstance();
1152
+ const response = await api.ext_support_support.ticketsMessagesCreate(ticket_uuid, data);
1153
+ try {
1154
+ return MessageCreateSchema.parse(response);
1155
+ } catch (error) {
1156
+ consola.error("\u274C Zod Validation Failed");
1157
+ consola.box(`createSupportTicketsMessagesCreate
1158
+ Path: /cfg/support/tickets/{ticket_uuid}/messages/
1159
+ Method: POST`);
1160
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1161
+ consola.error("Validation Issues:");
1162
+ error.issues.forEach((issue, index) => {
1163
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1164
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1165
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1166
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1167
+ });
1168
+ }
1169
+ consola.error("Response data:", response);
1170
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1171
+ try {
1172
+ const event = new CustomEvent("zod-validation-error", {
1173
+ detail: {
1174
+ operation: "createSupportTicketsMessagesCreate",
1175
+ path: "/cfg/support/tickets/{ticket_uuid}/messages/",
1176
+ method: "POST",
1177
+ error,
1178
+ response,
1179
+ timestamp: /* @__PURE__ */ new Date()
1180
+ },
1181
+ bubbles: true,
1182
+ cancelable: false
1183
+ });
1184
+ window.dispatchEvent(event);
1185
+ } catch (eventError) {
1186
+ consola.warn("Failed to dispatch validation error event:", eventError);
1187
+ }
1188
+ }
1189
+ throw error;
1190
+ }
1191
+ }
1192
+ async function getSupportTicketsMessagesRetrieve(ticket_uuid, uuid, client) {
1193
+ const api = client || getAPIInstance();
1194
+ const response = await api.ext_support_support.ticketsMessagesRetrieve(ticket_uuid, uuid);
1195
+ try {
1196
+ return MessageSchema.parse(response);
1197
+ } catch (error) {
1198
+ consola.error("\u274C Zod Validation Failed");
1199
+ consola.box(`getSupportTicketsMessagesRetrieve
1200
+ Path: /cfg/support/tickets/{ticket_uuid}/messages/{uuid}/
1201
+ Method: GET`);
1202
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1203
+ consola.error("Validation Issues:");
1204
+ error.issues.forEach((issue, index) => {
1205
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1206
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1207
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1208
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1209
+ });
1210
+ }
1211
+ consola.error("Response data:", response);
1212
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1213
+ try {
1214
+ const event = new CustomEvent("zod-validation-error", {
1215
+ detail: {
1216
+ operation: "getSupportTicketsMessagesRetrieve",
1217
+ path: "/cfg/support/tickets/{ticket_uuid}/messages/{uuid}/",
1218
+ method: "GET",
1219
+ error,
1220
+ response,
1221
+ timestamp: /* @__PURE__ */ new Date()
1222
+ },
1223
+ bubbles: true,
1224
+ cancelable: false
1225
+ });
1226
+ window.dispatchEvent(event);
1227
+ } catch (eventError) {
1228
+ consola.warn("Failed to dispatch validation error event:", eventError);
1229
+ }
1230
+ }
1231
+ throw error;
1232
+ }
1233
+ }
1234
+ async function updateSupportTicketsMessagesUpdate(ticket_uuid, uuid, data, client) {
1235
+ const api = client || getAPIInstance();
1236
+ const response = await api.ext_support_support.ticketsMessagesUpdate(ticket_uuid, uuid, data);
1237
+ try {
1238
+ return MessageSchema.parse(response);
1239
+ } catch (error) {
1240
+ consola.error("\u274C Zod Validation Failed");
1241
+ consola.box(`updateSupportTicketsMessagesUpdate
1242
+ Path: /cfg/support/tickets/{ticket_uuid}/messages/{uuid}/
1243
+ Method: PUT`);
1244
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1245
+ consola.error("Validation Issues:");
1246
+ error.issues.forEach((issue, index) => {
1247
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1248
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1249
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1250
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1251
+ });
1252
+ }
1253
+ consola.error("Response data:", response);
1254
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1255
+ try {
1256
+ const event = new CustomEvent("zod-validation-error", {
1257
+ detail: {
1258
+ operation: "updateSupportTicketsMessagesUpdate",
1259
+ path: "/cfg/support/tickets/{ticket_uuid}/messages/{uuid}/",
1260
+ method: "PUT",
1261
+ error,
1262
+ response,
1263
+ timestamp: /* @__PURE__ */ new Date()
1264
+ },
1265
+ bubbles: true,
1266
+ cancelable: false
1267
+ });
1268
+ window.dispatchEvent(event);
1269
+ } catch (eventError) {
1270
+ consola.warn("Failed to dispatch validation error event:", eventError);
1271
+ }
1272
+ }
1273
+ throw error;
1274
+ }
1275
+ }
1276
+ async function partialUpdateSupportTicketsMessagesPartialUpdate(ticket_uuid, uuid, data, client) {
1277
+ const api = client || getAPIInstance();
1278
+ const response = await api.ext_support_support.ticketsMessagesPartialUpdate(ticket_uuid, uuid, data);
1279
+ try {
1280
+ return MessageSchema.parse(response);
1281
+ } catch (error) {
1282
+ consola.error("\u274C Zod Validation Failed");
1283
+ consola.box(`partialUpdateSupportTicketsMessagesPartialUpdate
1284
+ Path: /cfg/support/tickets/{ticket_uuid}/messages/{uuid}/
1285
+ Method: PATCH`);
1286
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1287
+ consola.error("Validation Issues:");
1288
+ error.issues.forEach((issue, index) => {
1289
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1290
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1291
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1292
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1293
+ });
1294
+ }
1295
+ consola.error("Response data:", response);
1296
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1297
+ try {
1298
+ const event = new CustomEvent("zod-validation-error", {
1299
+ detail: {
1300
+ operation: "partialUpdateSupportTicketsMessagesPartialUpdate",
1301
+ path: "/cfg/support/tickets/{ticket_uuid}/messages/{uuid}/",
1302
+ method: "PATCH",
1303
+ error,
1304
+ response,
1305
+ timestamp: /* @__PURE__ */ new Date()
1306
+ },
1307
+ bubbles: true,
1308
+ cancelable: false
1309
+ });
1310
+ window.dispatchEvent(event);
1311
+ } catch (eventError) {
1312
+ consola.warn("Failed to dispatch validation error event:", eventError);
1313
+ }
1314
+ }
1315
+ throw error;
1316
+ }
1317
+ }
1318
+ async function deleteSupportTicketsMessagesDestroy(ticket_uuid, uuid, client) {
1319
+ const api = client || getAPIInstance();
1320
+ const response = await api.ext_support_support.ticketsMessagesDestroy(ticket_uuid, uuid);
1321
+ return response;
1322
+ }
1323
+ async function getSupportTicketsRetrieve(uuid, client) {
1324
+ const api = client || getAPIInstance();
1325
+ const response = await api.ext_support_support.ticketsRetrieve(uuid);
1326
+ try {
1327
+ return TicketSchema.parse(response);
1328
+ } catch (error) {
1329
+ consola.error("\u274C Zod Validation Failed");
1330
+ consola.box(`getSupportTicketsRetrieve
1331
+ Path: /cfg/support/tickets/{uuid}/
1332
+ Method: GET`);
1333
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1334
+ consola.error("Validation Issues:");
1335
+ error.issues.forEach((issue, index) => {
1336
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1337
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1338
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1339
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1340
+ });
1341
+ }
1342
+ consola.error("Response data:", response);
1343
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1344
+ try {
1345
+ const event = new CustomEvent("zod-validation-error", {
1346
+ detail: {
1347
+ operation: "getSupportTicketsRetrieve",
1348
+ path: "/cfg/support/tickets/{uuid}/",
1349
+ method: "GET",
1350
+ error,
1351
+ response,
1352
+ timestamp: /* @__PURE__ */ new Date()
1353
+ },
1354
+ bubbles: true,
1355
+ cancelable: false
1356
+ });
1357
+ window.dispatchEvent(event);
1358
+ } catch (eventError) {
1359
+ consola.warn("Failed to dispatch validation error event:", eventError);
1360
+ }
1361
+ }
1362
+ throw error;
1363
+ }
1364
+ }
1365
+ async function updateSupportTicketsUpdate(uuid, data, client) {
1366
+ const api = client || getAPIInstance();
1367
+ const response = await api.ext_support_support.ticketsUpdate(uuid, data);
1368
+ try {
1369
+ return TicketSchema.parse(response);
1370
+ } catch (error) {
1371
+ consola.error("\u274C Zod Validation Failed");
1372
+ consola.box(`updateSupportTicketsUpdate
1373
+ Path: /cfg/support/tickets/{uuid}/
1374
+ Method: PUT`);
1375
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1376
+ consola.error("Validation Issues:");
1377
+ error.issues.forEach((issue, index) => {
1378
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1379
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1380
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1381
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1382
+ });
1383
+ }
1384
+ consola.error("Response data:", response);
1385
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1386
+ try {
1387
+ const event = new CustomEvent("zod-validation-error", {
1388
+ detail: {
1389
+ operation: "updateSupportTicketsUpdate",
1390
+ path: "/cfg/support/tickets/{uuid}/",
1391
+ method: "PUT",
1392
+ error,
1393
+ response,
1394
+ timestamp: /* @__PURE__ */ new Date()
1395
+ },
1396
+ bubbles: true,
1397
+ cancelable: false
1398
+ });
1399
+ window.dispatchEvent(event);
1400
+ } catch (eventError) {
1401
+ consola.warn("Failed to dispatch validation error event:", eventError);
1402
+ }
1403
+ }
1404
+ throw error;
1405
+ }
1406
+ }
1407
+ async function partialUpdateSupportTicketsPartialUpdate(uuid, data, client) {
1408
+ const api = client || getAPIInstance();
1409
+ const response = await api.ext_support_support.ticketsPartialUpdate(uuid, data);
1410
+ try {
1411
+ return TicketSchema.parse(response);
1412
+ } catch (error) {
1413
+ consola.error("\u274C Zod Validation Failed");
1414
+ consola.box(`partialUpdateSupportTicketsPartialUpdate
1415
+ Path: /cfg/support/tickets/{uuid}/
1416
+ Method: PATCH`);
1417
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1418
+ consola.error("Validation Issues:");
1419
+ error.issues.forEach((issue, index) => {
1420
+ consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1421
+ consola.error(` \u251C\u2500 Message: ${issue.message}`);
1422
+ if (issue.expected) consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1423
+ if (issue.received) consola.error(` \u2514\u2500 Received: ${issue.received}`);
1424
+ });
1425
+ }
1426
+ consola.error("Response data:", response);
1427
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1428
+ try {
1429
+ const event = new CustomEvent("zod-validation-error", {
1430
+ detail: {
1431
+ operation: "partialUpdateSupportTicketsPartialUpdate",
1432
+ path: "/cfg/support/tickets/{uuid}/",
1433
+ method: "PATCH",
1434
+ error,
1435
+ response,
1436
+ timestamp: /* @__PURE__ */ new Date()
1437
+ },
1438
+ bubbles: true,
1439
+ cancelable: false
1440
+ });
1441
+ window.dispatchEvent(event);
1442
+ } catch (eventError) {
1443
+ consola.warn("Failed to dispatch validation error event:", eventError);
1444
+ }
1445
+ }
1446
+ throw error;
1447
+ }
1448
+ }
1449
+ async function deleteSupportTicketsDestroy(uuid, client) {
1450
+ const api = client || getAPIInstance();
1451
+ const response = await api.ext_support_support.ticketsDestroy(uuid);
1452
+ return response;
1453
+ }
1454
+
1455
+ // src/api/generated/ext_support/index.ts
1456
+ var TOKEN_KEY = "auth_token";
1457
+ var REFRESH_TOKEN_KEY = "refresh_token";
1458
+ var API = class {
1459
+ baseUrl;
1460
+ _client;
1461
+ _token = null;
1462
+ _refreshToken = null;
1463
+ storage;
1464
+ options;
1465
+ // Sub-clients
1466
+ ext_support_support;
1467
+ constructor(baseUrl, options) {
1468
+ this.baseUrl = baseUrl;
1469
+ this.options = options;
1470
+ const logger2 = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
1471
+ this.storage = options?.storage || new LocalStorageAdapter(logger2);
1472
+ this._loadTokensFromStorage();
1473
+ this._client = new APIClient(this.baseUrl, {
1474
+ retryConfig: this.options?.retryConfig,
1475
+ loggerConfig: this.options?.loggerConfig
1476
+ });
1477
+ this._injectAuthHeader();
1478
+ this.ext_support_support = this._client.ext_support_support;
1479
+ }
1480
+ _loadTokensFromStorage() {
1481
+ this._token = this.storage.getItem(TOKEN_KEY);
1482
+ this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
1483
+ }
1484
+ _reinitClients() {
1485
+ this._client = new APIClient(this.baseUrl, {
1486
+ retryConfig: this.options?.retryConfig,
1487
+ loggerConfig: this.options?.loggerConfig
1488
+ });
1489
+ this._injectAuthHeader();
1490
+ this.ext_support_support = this._client.ext_support_support;
1491
+ }
1492
+ _injectAuthHeader() {
1493
+ const originalRequest = this._client.request.bind(this._client);
1494
+ this._client.request = async (method, path, options) => {
1495
+ const token = this.getToken();
1496
+ const mergedOptions = {
1497
+ ...options,
1498
+ headers: {
1499
+ ...options?.headers || {},
1500
+ ...token ? { "Authorization": `Bearer ${token}` } : {}
1501
+ }
1502
+ };
1503
+ return originalRequest(method, path, mergedOptions);
1504
+ };
1505
+ }
1506
+ /**
1507
+ * Get current JWT token
1508
+ */
1509
+ getToken() {
1510
+ return this.storage.getItem(TOKEN_KEY);
1511
+ }
1512
+ /**
1513
+ * Get current refresh token
1514
+ */
1515
+ getRefreshToken() {
1516
+ return this.storage.getItem(REFRESH_TOKEN_KEY);
1517
+ }
1518
+ /**
1519
+ * Set JWT token and refresh token
1520
+ * @param token - JWT access token
1521
+ * @param refreshToken - JWT refresh token (optional)
1522
+ */
1523
+ setToken(token, refreshToken) {
1524
+ this._token = token;
1525
+ this.storage.setItem(TOKEN_KEY, token);
1526
+ if (refreshToken) {
1527
+ this._refreshToken = refreshToken;
1528
+ this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
1529
+ }
1530
+ this._reinitClients();
1531
+ }
1532
+ /**
1533
+ * Clear all tokens
1534
+ */
1535
+ clearTokens() {
1536
+ this._token = null;
1537
+ this._refreshToken = null;
1538
+ this.storage.removeItem(TOKEN_KEY);
1539
+ this.storage.removeItem(REFRESH_TOKEN_KEY);
1540
+ this._reinitClients();
1541
+ }
1542
+ /**
1543
+ * Check if user is authenticated
1544
+ */
1545
+ isAuthenticated() {
1546
+ return !!this.getToken();
1547
+ }
1548
+ /**
1549
+ * Update base URL and reinitialize clients
1550
+ * @param url - New base URL
1551
+ */
1552
+ setBaseUrl(url) {
1553
+ this.baseUrl = url;
1554
+ this._reinitClients();
1555
+ }
1556
+ /**
1557
+ * Get current base URL
1558
+ */
1559
+ getBaseUrl() {
1560
+ return this.baseUrl;
1561
+ }
1562
+ /**
1563
+ * Get OpenAPI schema path
1564
+ * @returns Path to the OpenAPI schema JSON file
1565
+ *
1566
+ * Note: The OpenAPI schema is available in the schema.json file.
1567
+ * You can load it dynamically using:
1568
+ * ```typescript
1569
+ * const schema = await fetch('./schema.json').then(r => r.json());
1570
+ * // or using fs in Node.js:
1571
+ * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1572
+ * ```
1573
+ */
1574
+ getSchemaPath() {
1575
+ return "./schema.json";
1576
+ }
1577
+ };
1578
+ var apiSupport = createExtensionAPI(API);
1579
+ function useSupportTicketsList(params, client) {
1580
+ return useSWR(
1581
+ params ? ["cfg-support-tickets", params] : "cfg-support-tickets",
1582
+ () => getSupportTicketsList(params, client)
1583
+ );
1584
+ }
1585
+ function useCreateSupportTicketsCreate() {
1586
+ const { mutate } = useSWRConfig();
1587
+ return async (data, client) => {
1588
+ const result = await createSupportTicketsCreate(data, client);
1589
+ mutate("cfg-support-tickets");
1590
+ return result;
1591
+ };
1592
+ }
1593
+ function useSupportTicketsMessagesList(ticket_uuid, params, client) {
1594
+ return useSWR(
1595
+ ["cfg-support-tickets-messages", ticket_uuid],
1596
+ () => getSupportTicketsMessagesList(ticket_uuid, params, client)
1597
+ );
1598
+ }
1599
+ function useCreateSupportTicketsMessagesCreate() {
1600
+ const { mutate } = useSWRConfig();
1601
+ return async (ticket_uuid, data, client) => {
1602
+ const result = await createSupportTicketsMessagesCreate(ticket_uuid, data, client);
1603
+ mutate("cfg-support-tickets-messages");
1604
+ return result;
1605
+ };
1606
+ }
1607
+ function useSupportTicketsMessagesRetrieve(ticket_uuid, uuid, client) {
1608
+ return useSWR(
1609
+ ["cfg-support-tickets-message", ticket_uuid],
1610
+ () => getSupportTicketsMessagesRetrieve(ticket_uuid, uuid, client)
1611
+ );
1612
+ }
1613
+ function useUpdateSupportTicketsMessagesUpdate() {
1614
+ const { mutate } = useSWRConfig();
1615
+ return async (ticket_uuid, uuid, data, client) => {
1616
+ const result = await updateSupportTicketsMessagesUpdate(ticket_uuid, uuid, data, client);
1617
+ mutate("cfg-support-tickets-messages");
1618
+ mutate("cfg-support-tickets-message");
1619
+ return result;
1620
+ };
1621
+ }
1622
+ function usePartialUpdateSupportTicketsMessagesPartialUpdate() {
1623
+ const { mutate } = useSWRConfig();
1624
+ return async (ticket_uuid, uuid, data, client) => {
1625
+ const result = await partialUpdateSupportTicketsMessagesPartialUpdate(ticket_uuid, uuid, data, client);
1626
+ mutate("cfg-support-tickets-messages-partial");
1627
+ return result;
1628
+ };
1629
+ }
1630
+ function useDeleteSupportTicketsMessagesDestroy() {
1631
+ const { mutate } = useSWRConfig();
1632
+ return async (ticket_uuid, uuid, client) => {
1633
+ const result = await deleteSupportTicketsMessagesDestroy(ticket_uuid, uuid, client);
1634
+ mutate("cfg-support-tickets-messages");
1635
+ mutate("cfg-support-tickets-message");
1636
+ return result;
1637
+ };
1638
+ }
1639
+ function useSupportTicketsRetrieve(uuid, client) {
1640
+ return useSWR(
1641
+ ["cfg-support-ticket", uuid],
1642
+ () => getSupportTicketsRetrieve(uuid, client)
1643
+ );
1644
+ }
1645
+ function useUpdateSupportTicketsUpdate() {
1646
+ const { mutate } = useSWRConfig();
1647
+ return async (uuid, data, client) => {
1648
+ const result = await updateSupportTicketsUpdate(uuid, data, client);
1649
+ mutate("cfg-support-tickets");
1650
+ mutate("cfg-support-ticket");
1651
+ return result;
1652
+ };
1653
+ }
1654
+ function usePartialUpdateSupportTicketsPartialUpdate() {
1655
+ const { mutate } = useSWRConfig();
1656
+ return async (uuid, data, client) => {
1657
+ const result = await partialUpdateSupportTicketsPartialUpdate(uuid, data, client);
1658
+ mutate("cfg-support-tickets-partial");
1659
+ return result;
1660
+ };
1661
+ }
1662
+ function useDeleteSupportTicketsDestroy() {
1663
+ const { mutate } = useSWRConfig();
1664
+ return async (uuid, client) => {
1665
+ const result = await deleteSupportTicketsDestroy(uuid, client);
1666
+ mutate("cfg-support-tickets");
1667
+ mutate("cfg-support-ticket");
1668
+ return result;
1669
+ };
1670
+ }
1671
+ var SupportContext = createContext(void 0);
1672
+ function SupportProvider({ children }) {
1673
+ const {
1674
+ data: ticketsData,
1675
+ error: ticketsError,
1676
+ isLoading: isLoadingTickets,
1677
+ mutate: mutateTickets
1678
+ } = useSupportTicketsList({ page: 1, page_size: 1 });
1679
+ const refreshTickets = async () => {
1680
+ await mutateTickets();
1681
+ };
1682
+ const createTicketMutation = useCreateSupportTicketsCreate();
1683
+ const updateTicketMutation = useUpdateSupportTicketsUpdate();
1684
+ usePartialUpdateSupportTicketsPartialUpdate();
1685
+ const deleteTicketMutation = useDeleteSupportTicketsDestroy();
1686
+ const createMessageMutation = useCreateSupportTicketsMessagesCreate();
1687
+ const updateMessageMutation = useUpdateSupportTicketsMessagesUpdate();
1688
+ usePartialUpdateSupportTicketsMessagesPartialUpdate();
1689
+ const deleteMessageMutation = useDeleteSupportTicketsMessagesDestroy();
1690
+ const getTicket = async (uuid) => {
1691
+ const { data } = useSupportTicketsRetrieve(uuid);
1692
+ return data;
1693
+ };
1694
+ const createTicket = async (data) => {
1695
+ const result = await createTicketMutation(data);
1696
+ await refreshTickets();
1697
+ return result;
1698
+ };
1699
+ const updateTicket = async (uuid, data) => {
1700
+ const result = await updateTicketMutation(uuid, data);
1701
+ await refreshTickets();
1702
+ return result;
1703
+ };
1704
+ const partialUpdateTicket = async (uuid, data) => {
1705
+ const result = await updateTicketMutation(uuid, data);
1706
+ await refreshTickets();
1707
+ return result;
1708
+ };
1709
+ const deleteTicket = async (uuid) => {
1710
+ await deleteTicketMutation(uuid);
1711
+ await refreshTickets();
1712
+ };
1713
+ const getMessages = async (ticketUuid) => {
1714
+ const { data } = useSupportTicketsMessagesList(ticketUuid, { page: 1, page_size: 100 });
1715
+ return data?.results;
1716
+ };
1717
+ const getMessage = async (ticketUuid, messageUuid) => {
1718
+ const { data } = useSupportTicketsMessagesRetrieve(
1719
+ ticketUuid,
1720
+ messageUuid
1721
+ );
1722
+ return data;
1723
+ };
1724
+ const createMessage = async (ticketUuid, data) => {
1725
+ const result = await createMessageMutation(ticketUuid, data);
1726
+ return result;
1727
+ };
1728
+ const updateMessage = async (ticketUuid, messageUuid, data) => {
1729
+ const result = await updateMessageMutation(
1730
+ ticketUuid,
1731
+ messageUuid,
1732
+ data
1733
+ );
1734
+ return result;
1735
+ };
1736
+ const partialUpdateMessage = async (ticketUuid, messageUuid, data) => {
1737
+ const result = await updateMessageMutation(
1738
+ ticketUuid,
1739
+ messageUuid,
1740
+ data
1741
+ );
1742
+ return result;
1743
+ };
1744
+ const deleteMessage = async (ticketUuid, messageUuid) => {
1745
+ await deleteMessageMutation(ticketUuid, messageUuid);
1746
+ };
1747
+ const refreshMessages = async (ticketUuid) => {
1748
+ await refreshTickets();
1749
+ };
1750
+ const value = {
1751
+ tickets: ticketsData?.results,
1752
+ isLoadingTickets,
1753
+ ticketsError,
1754
+ refreshTickets,
1755
+ getTicket,
1756
+ createTicket,
1757
+ updateTicket,
1758
+ partialUpdateTicket,
1759
+ deleteTicket,
1760
+ getMessages,
1761
+ getMessage,
1762
+ createMessage,
1763
+ updateMessage,
1764
+ partialUpdateMessage,
1765
+ deleteMessage,
1766
+ refreshMessages
1767
+ };
1768
+ return /* @__PURE__ */ jsx(SupportContext.Provider, { value, children });
1769
+ }
1770
+ function useSupportContext() {
1771
+ const context = useContext(SupportContext);
1772
+ if (!context) {
1773
+ throw new Error("useSupportContext must be used within SupportProvider");
1774
+ }
1775
+ return context;
1776
+ }
1777
+
1778
+ // src/layouts/SupportLayout/events.ts
1779
+ var SUPPORT_LAYOUT_EVENTS = {
1780
+ // Dialog events
1781
+ OPEN_CREATE_DIALOG: "support-layout:open-create-dialog",
1782
+ CLOSE_CREATE_DIALOG: "support-layout:close-create-dialog",
1783
+ // Ticket events
1784
+ TICKET_SELECTED: "support-layout:ticket-selected",
1785
+ TICKET_CREATED: "support-layout:ticket-created",
1786
+ // Message events
1787
+ MESSAGE_SENT: "support-layout:message-sent"
1788
+ };
1789
+ var openCreateTicketDialog = () => {
1790
+ if (typeof window !== "undefined") {
1791
+ window.dispatchEvent(new CustomEvent(SUPPORT_LAYOUT_EVENTS.OPEN_CREATE_DIALOG));
1792
+ }
1793
+ };
1794
+ var closeCreateTicketDialog = () => {
1795
+ if (typeof window !== "undefined") {
1796
+ window.dispatchEvent(new CustomEvent(SUPPORT_LAYOUT_EVENTS.CLOSE_CREATE_DIALOG));
1797
+ }
1798
+ };
1799
+ var PAGE_SIZE = 20;
1800
+ function useInfiniteTickets() {
1801
+ const getKey = (pageIndex, previousPageData) => {
1802
+ if (previousPageData && !previousPageData.has_next) return null;
1803
+ if (pageIndex === 0) return ["cfg-support-tickets-infinite", 1, PAGE_SIZE];
1804
+ return ["cfg-support-tickets-infinite", pageIndex + 1, PAGE_SIZE];
1805
+ };
1806
+ const fetcher = async ([, page, pageSize]) => {
1807
+ return getSupportTicketsList(
1808
+ { page, page_size: pageSize }
1809
+ );
1810
+ };
1811
+ const {
1812
+ data,
1813
+ error,
1814
+ isLoading,
1815
+ isValidating,
1816
+ size,
1817
+ setSize,
1818
+ mutate
1819
+ } = useSWRInfinite(getKey, fetcher, {
1820
+ revalidateFirstPage: false,
1821
+ parallel: false
1822
+ });
1823
+ const tickets = data ? data.flatMap((page) => page.results) : [];
1824
+ const hasMore = data && data[data.length - 1]?.has_next;
1825
+ const totalCount = data && data[data.length - 1]?.count;
1826
+ const isLoadingMore = isValidating && data && typeof data[size - 1] !== "undefined";
1827
+ const loadMore = () => {
1828
+ if (hasMore && !isLoadingMore) {
1829
+ setSize(size + 1);
1830
+ }
1831
+ };
1832
+ const refresh = async () => {
1833
+ await mutate();
1834
+ };
1835
+ return {
1836
+ tickets,
1837
+ isLoading,
1838
+ isLoadingMore: isLoadingMore || false,
1839
+ error,
1840
+ hasMore: hasMore || false,
1841
+ totalCount: totalCount || 0,
1842
+ loadMore,
1843
+ refresh
1844
+ };
1845
+ }
1846
+ var PAGE_SIZE2 = 20;
1847
+ function useInfiniteMessages(ticketUuid) {
1848
+ const getKey = (pageIndex, previousPageData) => {
1849
+ if (!ticketUuid) return null;
1850
+ if (previousPageData && !previousPageData.has_next) return null;
1851
+ if (pageIndex === 0) return ["cfg-support-messages-infinite", ticketUuid, 1, PAGE_SIZE2];
1852
+ return ["cfg-support-messages-infinite", ticketUuid, pageIndex + 1, PAGE_SIZE2];
1853
+ };
1854
+ const fetcher = async ([, ticket_uuid, page, pageSize]) => {
1855
+ return getSupportTicketsMessagesList(
1856
+ ticket_uuid,
1857
+ { page, page_size: pageSize }
1858
+ );
1859
+ };
1860
+ const {
1861
+ data,
1862
+ error,
1863
+ isLoading,
1864
+ isValidating,
1865
+ size,
1866
+ setSize,
1867
+ mutate
1868
+ } = useSWRInfinite(getKey, fetcher, {
1869
+ revalidateFirstPage: false,
1870
+ parallel: false
1871
+ });
1872
+ const messages = data ? data.flatMap((page) => page.results) : [];
1873
+ const hasMore = data && data[data.length - 1]?.has_next;
1874
+ const totalCount = data && data[data.length - 1]?.count;
1875
+ const isLoadingMore = !!(isValidating && data && typeof data[size - 1] !== "undefined");
1876
+ const loadMore = () => {
1877
+ if (hasMore && !isLoadingMore) {
1878
+ setSize(size + 1);
1879
+ }
1880
+ };
1881
+ const refresh = async () => {
1882
+ await mutate();
1883
+ };
1884
+ const addMessage = (message) => {
1885
+ if (!data || !data[0]) return;
1886
+ const newData = [...data];
1887
+ const firstPage = newData[0];
1888
+ if (firstPage) {
1889
+ newData[0] = {
1890
+ ...firstPage,
1891
+ results: [message, ...firstPage.results],
1892
+ count: firstPage.count + 1,
1893
+ page: firstPage.page || 1,
1894
+ pages: firstPage.pages || 1
1895
+ };
1896
+ }
1897
+ mutate(newData, false);
1898
+ };
1899
+ return {
1900
+ messages,
1901
+ isLoading,
1902
+ isLoadingMore: isLoadingMore || false,
1903
+ error,
1904
+ hasMore: hasMore || false,
1905
+ totalCount: totalCount || 0,
1906
+ loadMore,
1907
+ refresh,
1908
+ addMessage
1909
+ };
1910
+ }
1911
+ var SupportLayoutContext = createContext(void 0);
1912
+ function SupportLayoutProvider({ children }) {
1913
+ const support = useSupportContext();
1914
+ const { user } = useAuth();
1915
+ const [uiState, setUIState] = useState({
1916
+ selectedTicketUuid: null,
1917
+ isCreateDialogOpen: false,
1918
+ viewMode: "list"
1919
+ });
1920
+ const selectedTicket = support.tickets?.find((t) => t.uuid === uiState.selectedTicketUuid);
1921
+ const {
1922
+ messages: selectedTicketMessages,
1923
+ isLoading: isLoadingMessages,
1924
+ isLoadingMore: isLoadingMoreMessages,
1925
+ hasMore: hasMoreMessages,
1926
+ totalCount: totalMessagesCount,
1927
+ loadMore: loadMoreMessages,
1928
+ refresh: refreshMessages,
1929
+ addMessage: addMessageOptimistically
1930
+ } = useInfiniteMessages(selectedTicket?.uuid || null);
1931
+ const selectTicket = useCallback(async (ticket) => {
1932
+ setUIState((prev) => ({ ...prev, selectedTicketUuid: ticket?.uuid || null }));
1933
+ if (ticket?.uuid) {
1934
+ window.dispatchEvent(
1935
+ new CustomEvent(SUPPORT_LAYOUT_EVENTS.TICKET_SELECTED, { detail: { ticket } })
1936
+ );
1937
+ }
1938
+ }, []);
1939
+ const createTicket = useCallback(async (data) => {
1940
+ if (!user?.id) {
1941
+ throw new Error("User must be authenticated to create tickets");
1942
+ }
1943
+ const ticket = await support.createTicket({
1944
+ user: user.id,
1945
+ subject: data.subject
1946
+ });
1947
+ if (ticket.uuid && data.message) {
1948
+ await support.createMessage(ticket.uuid, {
1949
+ text: data.message
1950
+ });
1951
+ }
1952
+ setUIState((prev) => ({ ...prev, isCreateDialogOpen: false }));
1953
+ await support.refreshTickets();
1954
+ window.dispatchEvent(
1955
+ new CustomEvent(SUPPORT_LAYOUT_EVENTS.TICKET_CREATED, { detail: { ticket } })
1956
+ );
1957
+ setUIState((prev) => ({ ...prev, selectedTicketUuid: ticket.uuid }));
1958
+ window.dispatchEvent(
1959
+ new CustomEvent(SUPPORT_LAYOUT_EVENTS.TICKET_SELECTED, { detail: { ticket } })
1960
+ );
1961
+ }, [support, user]);
1962
+ const sendMessage = useCallback(async (message) => {
1963
+ if (!selectedTicket?.uuid) return;
1964
+ const messageData = {
1965
+ text: message
1966
+ };
1967
+ const newMessage = await support.createMessage(selectedTicket.uuid, messageData);
1968
+ if (newMessage) {
1969
+ const fullMessage = {
1970
+ uuid: newMessage.uuid || `temp-${Date.now()}`,
1971
+ ticket: selectedTicket.uuid,
1972
+ sender: {
1973
+ id: user?.id || 0,
1974
+ display_username: user?.display_username || "",
1975
+ email: user?.email || "",
1976
+ avatar: user?.avatar || null,
1977
+ initials: user?.initials || "",
1978
+ is_staff: user?.is_staff || false,
1979
+ is_superuser: user?.is_superuser || false
1980
+ },
1981
+ is_from_author: true,
1982
+ text: message,
1983
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
1984
+ };
1985
+ addMessageOptimistically(fullMessage);
1986
+ }
1987
+ await refreshMessages();
1988
+ window.dispatchEvent(
1989
+ new CustomEvent(SUPPORT_LAYOUT_EVENTS.MESSAGE_SENT, { detail: { message: newMessage } })
1990
+ );
1991
+ }, [selectedTicket, support, user, addMessageOptimistically, refreshMessages]);
1992
+ const openCreateDialog = useCallback(() => {
1993
+ setUIState((prev) => ({ ...prev, isCreateDialogOpen: true }));
1994
+ }, []);
1995
+ const closeCreateDialog = useCallback(() => {
1996
+ setUIState((prev) => ({ ...prev, isCreateDialogOpen: false }));
1997
+ }, []);
1998
+ const getUnreadCount = useCallback(() => {
1999
+ return support.tickets?.reduce((count, ticket) => count + (ticket.unanswered_messages_count || 0), 0) || 0;
2000
+ }, [support.tickets]);
2001
+ useEffect(() => {
2002
+ const handleOpenDialog = () => openCreateDialog();
2003
+ const handleCloseDialog = () => closeCreateDialog();
2004
+ window.addEventListener(SUPPORT_LAYOUT_EVENTS.OPEN_CREATE_DIALOG, handleOpenDialog);
2005
+ window.addEventListener(SUPPORT_LAYOUT_EVENTS.CLOSE_CREATE_DIALOG, handleCloseDialog);
2006
+ return () => {
2007
+ window.removeEventListener(SUPPORT_LAYOUT_EVENTS.OPEN_CREATE_DIALOG, handleOpenDialog);
2008
+ window.removeEventListener(SUPPORT_LAYOUT_EVENTS.CLOSE_CREATE_DIALOG, handleCloseDialog);
2009
+ };
2010
+ }, [openCreateDialog, closeCreateDialog]);
2011
+ const value = {
2012
+ tickets: support.tickets,
2013
+ isLoadingTickets: support.isLoadingTickets,
2014
+ ticketsError: support.ticketsError,
2015
+ selectedTicket,
2016
+ selectedTicketMessages,
2017
+ isLoadingMessages,
2018
+ isLoadingMoreMessages,
2019
+ hasMoreMessages,
2020
+ totalMessagesCount,
2021
+ loadMoreMessages,
2022
+ uiState,
2023
+ selectTicket,
2024
+ createTicket,
2025
+ sendMessage,
2026
+ refreshTickets: support.refreshTickets,
2027
+ refreshMessages,
2028
+ openCreateDialog,
2029
+ closeCreateDialog,
2030
+ getUnreadCount
2031
+ };
2032
+ return /* @__PURE__ */ jsx(SupportLayoutContext.Provider, { value, children });
2033
+ }
2034
+ function useSupportLayoutContext() {
2035
+ const context = useContext(SupportLayoutContext);
2036
+ if (!context) {
2037
+ throw new Error("useSupportLayoutContext must be used within SupportLayoutProvider");
2038
+ }
2039
+ return context;
2040
+ }
2041
+ var getStatusBadgeVariant = (status) => {
2042
+ switch (status) {
2043
+ case "open":
2044
+ return "default";
2045
+ case "waiting_for_user":
2046
+ return "secondary";
2047
+ case "waiting_for_admin":
2048
+ return "outline";
2049
+ case "resolved":
2050
+ return "outline";
2051
+ case "closed":
2052
+ return "secondary";
2053
+ default:
2054
+ return "default";
2055
+ }
2056
+ };
2057
+ var formatRelativeTime = (date) => {
2058
+ if (!date) return "N/A";
2059
+ const now = /* @__PURE__ */ new Date();
2060
+ const messageDate = new Date(date);
2061
+ const diffInSeconds = Math.floor((now.getTime() - messageDate.getTime()) / 1e3);
2062
+ if (diffInSeconds < 60) return "Just now";
2063
+ if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
2064
+ if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
2065
+ if (diffInSeconds < 604800) return `${Math.floor(diffInSeconds / 86400)}d ago`;
2066
+ return new Date(date).toLocaleDateString("en-US", {
2067
+ year: "numeric",
2068
+ month: "short",
2069
+ day: "numeric"
2070
+ });
2071
+ };
2072
+ var TicketCard = ({ ticket, isSelected, onClick }) => {
2073
+ return /* @__PURE__ */ jsx(
2074
+ Card,
2075
+ {
2076
+ className: cn(
2077
+ "cursor-pointer transition-all duration-200 ease-out",
2078
+ "hover:bg-accent/50 hover:shadow-md hover:scale-[1.02]",
2079
+ "active:scale-[0.98]",
2080
+ isSelected && "bg-accent border-primary shadow-sm"
2081
+ ),
2082
+ onClick,
2083
+ children: /* @__PURE__ */ jsxs(CardContent, { className: "p-4", children: [
2084
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-2", children: [
2085
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-sm line-clamp-2 flex-1", children: ticket.subject }),
2086
+ (ticket.unanswered_messages_count || 0) > 0 && /* @__PURE__ */ jsx(
2087
+ Badge,
2088
+ {
2089
+ variant: "destructive",
2090
+ className: "ml-2 shrink-0 animate-pulse",
2091
+ children: ticket.unanswered_messages_count
2092
+ }
2093
+ )
2094
+ ] }),
2095
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2096
+ /* @__PURE__ */ jsx(Badge, { variant: getStatusBadgeVariant(ticket.status || "open"), className: "text-xs", children: ticket.status || "open" }),
2097
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2098
+ /* @__PURE__ */ jsx(Clock, { className: "h-3 w-3" }),
2099
+ /* @__PURE__ */ jsx("span", { children: formatRelativeTime(ticket.created_at) })
2100
+ ] })
2101
+ ] }) })
2102
+ ] })
2103
+ }
2104
+ );
2105
+ };
2106
+ var TicketList = () => {
2107
+ const { selectedTicket, selectTicket } = useSupportLayoutContext();
2108
+ const {
2109
+ tickets,
2110
+ isLoading,
2111
+ isLoadingMore,
2112
+ hasMore,
2113
+ loadMore,
2114
+ totalCount,
2115
+ refresh
2116
+ } = useInfiniteTickets();
2117
+ const scrollRef = useRef(null);
2118
+ const observerRef = useRef(null);
2119
+ const loadMoreRef = useRef(null);
2120
+ useEffect(() => {
2121
+ const handleTicketCreated = () => {
2122
+ refresh();
2123
+ };
2124
+ window.addEventListener(SUPPORT_LAYOUT_EVENTS.TICKET_CREATED, handleTicketCreated);
2125
+ return () => {
2126
+ window.removeEventListener(SUPPORT_LAYOUT_EVENTS.TICKET_CREATED, handleTicketCreated);
2127
+ };
2128
+ }, [refresh]);
2129
+ useEffect(() => {
2130
+ if (observerRef.current) {
2131
+ observerRef.current.disconnect();
2132
+ }
2133
+ observerRef.current = new IntersectionObserver(
2134
+ (entries) => {
2135
+ if (entries[0]?.isIntersecting && hasMore && !isLoadingMore) {
2136
+ loadMore();
2137
+ }
2138
+ },
2139
+ { threshold: 0.1 }
2140
+ );
2141
+ if (loadMoreRef.current) {
2142
+ observerRef.current.observe(loadMoreRef.current);
2143
+ }
2144
+ return () => {
2145
+ if (observerRef.current) {
2146
+ observerRef.current.disconnect();
2147
+ }
2148
+ };
2149
+ }, [hasMore, isLoadingMore, loadMore]);
2150
+ if (isLoading) {
2151
+ return /* @__PURE__ */ jsx("div", { className: "p-4 space-y-2", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
2152
+ Skeleton,
2153
+ {
2154
+ className: "h-24 w-full animate-pulse",
2155
+ style: { animationDelay: `${i * 100}ms` }
2156
+ }
2157
+ ) }, i)) });
2158
+ }
2159
+ if (!tickets || tickets.length === 0) {
2160
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full p-8 text-center animate-in fade-in zoom-in-95 duration-300", children: [
2161
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-16 w-16 text-muted-foreground mb-4 animate-bounce" }),
2162
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "No tickets yet" }),
2163
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-sm", children: "Create your first support ticket to get help from our team" })
2164
+ ] });
2165
+ }
2166
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", viewportRef: scrollRef, children: /* @__PURE__ */ jsxs("div", { className: "p-4 space-y-2", children: [
2167
+ tickets.map((ticket, index) => /* @__PURE__ */ jsx(
2168
+ "div",
2169
+ {
2170
+ className: "animate-in fade-in slide-in-from-left-2 duration-300",
2171
+ style: { animationDelay: `${Math.min(index, 10) * 50}ms` },
2172
+ children: /* @__PURE__ */ jsx(
2173
+ TicketCard,
2174
+ {
2175
+ ticket,
2176
+ isSelected: selectedTicket?.uuid === ticket.uuid,
2177
+ onClick: () => selectTicket(ticket)
2178
+ }
2179
+ )
2180
+ },
2181
+ ticket.uuid
2182
+ )),
2183
+ /* @__PURE__ */ jsx("div", { ref: loadMoreRef, className: "h-2" }),
2184
+ isLoadingMore && /* @__PURE__ */ jsx("div", { className: "flex justify-center py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
2185
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
2186
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Loading more tickets..." })
2187
+ ] }) }),
2188
+ hasMore && !isLoadingMore && /* @__PURE__ */ jsx("div", { className: "flex justify-center pt-2 pb-4", children: /* @__PURE__ */ jsxs(
2189
+ Button,
2190
+ {
2191
+ variant: "outline",
2192
+ size: "sm",
2193
+ onClick: loadMore,
2194
+ className: "text-xs",
2195
+ children: [
2196
+ "Load more (",
2197
+ totalCount > 0 ? `${tickets.length}/${totalCount}` : "",
2198
+ ")"
2199
+ ]
2200
+ }
2201
+ ) }),
2202
+ !hasMore && tickets.length > 0 && /* @__PURE__ */ jsxs("div", { className: "text-center py-4 text-sm text-muted-foreground", children: [
2203
+ "All ",
2204
+ totalCount,
2205
+ " tickets loaded"
2206
+ ] })
2207
+ ] }) });
2208
+ };
2209
+ var formatTime = (date) => {
2210
+ if (!date) return "";
2211
+ return new Date(date).toLocaleTimeString("en-US", {
2212
+ hour: "2-digit",
2213
+ minute: "2-digit"
2214
+ });
2215
+ };
2216
+ var formatDate = (date) => {
2217
+ if (!date) return "";
2218
+ return new Date(date).toLocaleDateString("en-US", {
2219
+ year: "numeric",
2220
+ month: "short",
2221
+ day: "numeric"
2222
+ });
2223
+ };
2224
+ var MessageBubble = ({ message, isFromUser, currentUser }) => {
2225
+ const sender = message.sender;
2226
+ return /* @__PURE__ */ jsxs(
2227
+ "div",
2228
+ {
2229
+ className: `flex gap-3 ${isFromUser ? "justify-end" : "justify-start"}
2230
+ animate-in fade-in slide-in-from-bottom-2 duration-300`,
2231
+ children: [
2232
+ !isFromUser && /* @__PURE__ */ jsx(Avatar, { className: "h-8 w-8 shrink-0", children: sender?.avatar ? /* @__PURE__ */ jsx(AvatarImage, { src: sender.avatar, alt: sender.display_username || "Support" }) : /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-primary text-primary-foreground", children: sender?.is_staff ? /* @__PURE__ */ jsx(Headphones, { className: "h-4 w-4" }) : sender?.display_username?.charAt(0)?.toUpperCase() || sender?.initials || "S" }) }),
2233
+ /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-1 flex-1 max-w-[80%] ${isFromUser ? "items-end" : "items-start"}`, children: [
2234
+ !isFromUser && sender && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground px-1", children: [
2235
+ sender.display_username || sender.email || "Support Team",
2236
+ sender.is_staff && " (Staff)"
2237
+ ] }),
2238
+ /* @__PURE__ */ jsx(
2239
+ Card,
2240
+ {
2241
+ className: `${isFromUser ? "bg-primary text-primary-foreground" : "bg-muted"} transition-all duration-200 hover:shadow-md`,
2242
+ children: /* @__PURE__ */ jsx(CardContent, { className: "p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-wrap break-words", children: message.text }) })
2243
+ }
2244
+ ),
2245
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground px-1", children: formatTime(message.created_at) })
2246
+ ] }),
2247
+ isFromUser && /* @__PURE__ */ jsx(Avatar, { className: "h-8 w-8 shrink-0", children: currentUser?.avatar ? /* @__PURE__ */ jsx(AvatarImage, { src: currentUser.avatar, alt: currentUser.display_username || currentUser.email || "You" }) : /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-primary/10 text-primary font-semibold", children: currentUser?.display_username?.charAt(0)?.toUpperCase() || currentUser?.email?.charAt(0)?.toUpperCase() || currentUser?.initials || /* @__PURE__ */ jsx(User, { className: "h-4 w-4" }) }) })
2248
+ ]
2249
+ }
2250
+ );
2251
+ };
2252
+ var MessageList = () => {
2253
+ const { selectedTicket } = useSupportLayoutContext();
2254
+ const { user } = useAuth();
2255
+ const {
2256
+ messages,
2257
+ isLoading,
2258
+ isLoadingMore,
2259
+ hasMore,
2260
+ totalCount,
2261
+ loadMore
2262
+ } = useInfiniteMessages(selectedTicket?.uuid || null);
2263
+ const scrollRef = useRef(null);
2264
+ const scrollAreaRef = useRef(null);
2265
+ const observerRef = useRef(null);
2266
+ const loadMoreRef = useRef(null);
2267
+ const firstRender = useRef(true);
2268
+ useEffect(() => {
2269
+ if (observerRef.current) {
2270
+ observerRef.current.disconnect();
2271
+ }
2272
+ observerRef.current = new IntersectionObserver(
2273
+ (entries) => {
2274
+ if (entries[0]?.isIntersecting && hasMore && !isLoadingMore) {
2275
+ loadMore();
2276
+ }
2277
+ },
2278
+ { threshold: 0.1 }
2279
+ );
2280
+ if (loadMoreRef.current) {
2281
+ observerRef.current.observe(loadMoreRef.current);
2282
+ }
2283
+ return () => {
2284
+ if (observerRef.current) {
2285
+ observerRef.current.disconnect();
2286
+ }
2287
+ };
2288
+ }, [hasMore, isLoadingMore, loadMore]);
2289
+ useEffect(() => {
2290
+ if (firstRender.current && messages.length > 0) {
2291
+ const scrollContainer = scrollAreaRef.current?.querySelector("[data-radix-scroll-area-viewport]");
2292
+ if (scrollContainer) {
2293
+ scrollContainer.scrollTop = scrollContainer.scrollHeight;
2294
+ }
2295
+ firstRender.current = false;
2296
+ }
2297
+ }, [messages]);
2298
+ const handleLoadMore = useCallback(() => {
2299
+ const scrollContainer = scrollAreaRef.current?.querySelector("[data-radix-scroll-area-viewport]");
2300
+ const previousHeight = scrollContainer?.scrollHeight || 0;
2301
+ loadMore();
2302
+ setTimeout(() => {
2303
+ if (scrollContainer) {
2304
+ const newHeight = scrollContainer.scrollHeight;
2305
+ scrollContainer.scrollTop = newHeight - previousHeight;
2306
+ }
2307
+ }, 100);
2308
+ }, [loadMore]);
2309
+ if (!selectedTicket) {
2310
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full p-8 text-center animate-in fade-in zoom-in-95 duration-300", children: [
2311
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-16 w-16 text-muted-foreground mb-4 animate-bounce" }),
2312
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "No ticket selected" }),
2313
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-sm", children: "Select a ticket from the list to view the conversation" })
2314
+ ] });
2315
+ }
2316
+ if (isLoading) {
2317
+ return /* @__PURE__ */ jsx("div", { className: "p-6 space-y-4", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs(
2318
+ "div",
2319
+ {
2320
+ className: "flex gap-3 animate-pulse",
2321
+ style: { animationDelay: `${i * 100}ms` },
2322
+ children: [
2323
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8 rounded-full" }),
2324
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-16 flex-1 max-w-[70%]" })
2325
+ ]
2326
+ },
2327
+ i
2328
+ )) });
2329
+ }
2330
+ if (!messages || messages.length === 0) {
2331
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full p-8 text-center animate-in fade-in zoom-in-95 duration-300", children: [
2332
+ /* @__PURE__ */ jsx(MessageSquare, { className: "h-16 w-16 text-muted-foreground mb-4 animate-bounce" }),
2333
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "No messages yet" }),
2334
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground max-w-sm", children: "Start the conversation by sending a message below" })
2335
+ ] });
2336
+ }
2337
+ return /* @__PURE__ */ jsx(ScrollArea, { className: "h-full bg-muted/50", viewportRef: scrollAreaRef, children: /* @__PURE__ */ jsxs("div", { className: "p-6 space-y-4", ref: scrollRef, children: [
2338
+ /* @__PURE__ */ jsx("div", { ref: loadMoreRef, className: "h-2" }),
2339
+ isLoadingMore && /* @__PURE__ */ jsx("div", { className: "flex justify-center py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-muted-foreground", children: [
2340
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
2341
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Loading older messages..." })
2342
+ ] }) }),
2343
+ hasMore && !isLoadingMore && /* @__PURE__ */ jsx("div", { className: "flex justify-center pt-2 pb-4", children: /* @__PURE__ */ jsxs(
2344
+ Button,
2345
+ {
2346
+ variant: "outline",
2347
+ size: "sm",
2348
+ onClick: handleLoadMore,
2349
+ className: "text-xs",
2350
+ children: [
2351
+ "Load older messages (",
2352
+ totalCount > 0 ? `${messages.length}/${totalCount}` : "",
2353
+ ")"
2354
+ ]
2355
+ }
2356
+ ) }),
2357
+ messages.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 my-4", children: [
2358
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" }),
2359
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: formatDate(messages[0]?.created_at) }),
2360
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" })
2361
+ ] }),
2362
+ messages.map((message, index) => {
2363
+ const isFromUser = message.sender?.id && user?.id && String(message.sender.id) === String(user.id) || message.sender?.email && user?.email && message.sender.email === user.email || message.is_from_author && selectedTicket?.user && user?.id && String(selectedTicket.user) === String(user.id);
2364
+ const previousMessage = index > 0 ? messages[index - 1] : null;
2365
+ const showDateSeparator = previousMessage && new Date(previousMessage.created_at || "").toDateString() !== new Date(message.created_at || "").toDateString();
2366
+ return /* @__PURE__ */ jsxs(React7.Fragment, { children: [
2367
+ showDateSeparator && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 my-4", children: [
2368
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" }),
2369
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: formatDate(message.created_at) }),
2370
+ /* @__PURE__ */ jsx("div", { className: "flex-1 h-px bg-border" })
2371
+ ] }),
2372
+ /* @__PURE__ */ jsx("div", { style: { animationDelay: `${Math.min(index, 10) * 50}ms` }, children: /* @__PURE__ */ jsx(
2373
+ MessageBubble,
2374
+ {
2375
+ message,
2376
+ isFromUser: !!isFromUser,
2377
+ currentUser: user
2378
+ }
2379
+ ) })
2380
+ ] }, message.uuid);
2381
+ })
2382
+ ] }) });
2383
+ };
2384
+ var isDevelopment = process.env.NODE_ENV === "development";
2385
+ var showLogs = isDevelopment;
2386
+ var logger = createConsola({
2387
+ level: showLogs ? 4 : 1
2388
+ }).withTag("ext-support");
2389
+ var supportLogger = logger;
2390
+ var MessageInput = () => {
2391
+ const { selectedTicket, sendMessage } = useSupportLayoutContext();
2392
+ const { toast } = useToast();
2393
+ const [message, setMessage] = useState("");
2394
+ const [isSending, setIsSending] = useState(false);
2395
+ const handleSubmit = async (e) => {
2396
+ e.preventDefault();
2397
+ if (!message.trim() || !selectedTicket) return;
2398
+ setIsSending(true);
2399
+ try {
2400
+ await sendMessage(message.trim());
2401
+ setMessage("");
2402
+ toast({
2403
+ title: "Success",
2404
+ description: "Message sent successfully"
2405
+ });
2406
+ } catch (error) {
2407
+ supportLogger.error("Failed to send message:", error);
2408
+ toast({
2409
+ title: "Error",
2410
+ description: "Failed to send message",
2411
+ variant: "destructive"
2412
+ });
2413
+ } finally {
2414
+ setIsSending(false);
2415
+ }
2416
+ };
2417
+ const handleKeyDown = (e) => {
2418
+ if (e.key === "Enter" && !e.shiftKey) {
2419
+ e.preventDefault();
2420
+ handleSubmit(e);
2421
+ }
2422
+ };
2423
+ if (!selectedTicket) {
2424
+ return null;
2425
+ }
2426
+ const canSendMessage = selectedTicket.status !== "closed";
2427
+ return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "p-4 border-t bg-background/50 backdrop-blur-sm flex-shrink-0", children: [
2428
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
2429
+ /* @__PURE__ */ jsx(
2430
+ Textarea,
2431
+ {
2432
+ value: message,
2433
+ onChange: (e) => setMessage(e.target.value),
2434
+ onKeyDown: handleKeyDown,
2435
+ placeholder: canSendMessage ? "Type your message... (Shift+Enter for new line)" : "This ticket is closed",
2436
+ className: "min-h-[60px] max-h-[200px] transition-all duration-200 \n focus:ring-2 focus:ring-primary/20",
2437
+ disabled: !canSendMessage || isSending
2438
+ }
2439
+ ),
2440
+ /* @__PURE__ */ jsx(
2441
+ Button,
2442
+ {
2443
+ type: "submit",
2444
+ size: "icon",
2445
+ disabled: !message.trim() || !canSendMessage || isSending,
2446
+ className: "shrink-0 transition-all duration-200 \n hover:scale-110 active:scale-95 disabled:scale-100",
2447
+ children: /* @__PURE__ */ jsx(Send, { className: "h-4 w-4" })
2448
+ }
2449
+ )
2450
+ ] }),
2451
+ !canSendMessage && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-2 animate-in fade-in slide-in-from-top-1 duration-200", children: "This ticket is closed. You cannot send new messages." })
2452
+ ] });
2453
+ };
2454
+ var createTicketSchema = z.object({
2455
+ subject: z.string().min(1, "Subject is required").max(200, "Subject too long"),
2456
+ message: z.string().min(1, "Message is required").max(5e3, "Message too long")
2457
+ });
2458
+ var CreateTicketDialog = () => {
2459
+ const { uiState, createTicket, closeCreateDialog } = useSupportLayoutContext();
2460
+ const { toast } = useToast();
2461
+ const [isSubmitting, setIsSubmitting] = React7.useState(false);
2462
+ const form = useForm({
2463
+ resolver: zodResolver(createTicketSchema),
2464
+ defaultValues: {
2465
+ subject: "",
2466
+ message: ""
2467
+ }
2468
+ });
2469
+ const onSubmit = async (data) => {
2470
+ setIsSubmitting(true);
2471
+ try {
2472
+ await createTicket(data);
2473
+ form.reset();
2474
+ toast({
2475
+ title: "Success",
2476
+ description: "Support ticket created successfully"
2477
+ });
2478
+ } catch (error) {
2479
+ supportLogger.error("Failed to create ticket:", error);
2480
+ toast({
2481
+ title: "Error",
2482
+ description: "Failed to create ticket. Please try again.",
2483
+ variant: "destructive"
2484
+ });
2485
+ } finally {
2486
+ setIsSubmitting(false);
2487
+ }
2488
+ };
2489
+ const handleClose = () => {
2490
+ form.reset();
2491
+ closeCreateDialog();
2492
+ };
2493
+ return /* @__PURE__ */ jsx(Dialog, { open: uiState.isCreateDialogOpen, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[600px] animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
2494
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
2495
+ /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
2496
+ /* @__PURE__ */ jsx(Plus, { className: "h-5 w-5" }),
2497
+ "Create Support Ticket"
2498
+ ] }),
2499
+ /* @__PURE__ */ jsx(DialogDescription, { children: "Describe your issue and we'll help you resolve it as quickly as possible." })
2500
+ ] }),
2501
+ /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-6", children: [
2502
+ /* @__PURE__ */ jsx(
2503
+ FormField,
2504
+ {
2505
+ control: form.control,
2506
+ name: "subject",
2507
+ render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
2508
+ /* @__PURE__ */ jsx(FormLabel, { children: "Subject" }),
2509
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, { placeholder: "Brief description of your issue...", ...field }) }),
2510
+ /* @__PURE__ */ jsx(FormMessage, {})
2511
+ ] })
2512
+ }
2513
+ ),
2514
+ /* @__PURE__ */ jsx(
2515
+ FormField,
2516
+ {
2517
+ control: form.control,
2518
+ name: "message",
2519
+ render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
2520
+ /* @__PURE__ */ jsx(FormLabel, { children: "Message" }),
2521
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
2522
+ Textarea,
2523
+ {
2524
+ placeholder: "Describe your issue in detail. Include any error messages, steps to reproduce, or relevant information...",
2525
+ className: "min-h-[120px]",
2526
+ ...field
2527
+ }
2528
+ ) }),
2529
+ /* @__PURE__ */ jsx(FormMessage, {})
2530
+ ] })
2531
+ }
2532
+ ),
2533
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-3 pt-4", children: [
2534
+ /* @__PURE__ */ jsx(
2535
+ Button,
2536
+ {
2537
+ type: "button",
2538
+ variant: "outline",
2539
+ onClick: handleClose,
2540
+ disabled: isSubmitting,
2541
+ children: "Cancel"
2542
+ }
2543
+ ),
2544
+ /* @__PURE__ */ jsx(Button, { type: "submit", disabled: isSubmitting, children: isSubmitting ? /* @__PURE__ */ jsxs(Fragment, { children: [
2545
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 mr-2 animate-spin" }),
2546
+ "Creating..."
2547
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2548
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
2549
+ "Create Ticket"
2550
+ ] }) })
2551
+ ] })
2552
+ ] }) })
2553
+ ] }) });
2554
+ };
2555
+ var SupportLayoutContent = () => {
2556
+ const { selectedTicket, selectTicket, openCreateDialog, getUnreadCount } = useSupportLayoutContext();
2557
+ const [isMobile, setIsMobile] = React7.useState(false);
2558
+ React7.useEffect(() => {
2559
+ const checkMobile = () => setIsMobile(window.innerWidth <= 768);
2560
+ checkMobile();
2561
+ window.addEventListener("resize", checkMobile);
2562
+ return () => window.removeEventListener("resize", checkMobile);
2563
+ }, []);
2564
+ const unreadCount = getUnreadCount();
2565
+ if (isMobile) {
2566
+ return /* @__PURE__ */ jsxs("div", { className: "h-screen flex flex-col overflow-hidden", children: [
2567
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b bg-background flex-shrink-0", children: [
2568
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
2569
+ selectedTicket ? /* @__PURE__ */ jsx(
2570
+ Button,
2571
+ {
2572
+ variant: "ghost",
2573
+ size: "sm",
2574
+ onClick: () => selectTicket(null),
2575
+ className: "p-1",
2576
+ children: /* @__PURE__ */ jsx(ArrowLeft, { className: "h-5 w-5" })
2577
+ }
2578
+ ) : /* @__PURE__ */ jsx(LifeBuoy, { className: "h-6 w-6 text-primary" }),
2579
+ /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold", children: selectedTicket ? selectedTicket.subject : "Support" }),
2580
+ unreadCount > 0 && !selectedTicket && /* @__PURE__ */ jsx("div", { className: "h-5 w-5 bg-red-500 text-white text-xs rounded-full flex items-center justify-center", children: unreadCount })
2581
+ ] }),
2582
+ !selectedTicket && /* @__PURE__ */ jsxs(Button, { onClick: openCreateDialog, size: "sm", children: [
2583
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
2584
+ "New Ticket"
2585
+ ] })
2586
+ ] }),
2587
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: selectedTicket ? (
2588
+ // Show messages when ticket is selected
2589
+ /* @__PURE__ */ jsxs("div", { className: "h-full flex flex-col", children: [
2590
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(MessageList, {}) }),
2591
+ /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(MessageInput, {}) })
2592
+ ] })
2593
+ ) : (
2594
+ // Show ticket list when no ticket is selected
2595
+ /* @__PURE__ */ jsx(TicketList, {})
2596
+ ) }),
2597
+ /* @__PURE__ */ jsx(CreateTicketDialog, {})
2598
+ ] });
2599
+ }
2600
+ return /* @__PURE__ */ jsxs("div", { className: "h-screen flex flex-col overflow-hidden", children: [
2601
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-6 border-b bg-background flex-shrink-0", children: [
2602
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2603
+ /* @__PURE__ */ jsx(LifeBuoy, { className: "h-7 w-7 text-primary" }),
2604
+ /* @__PURE__ */ jsxs("div", { children: [
2605
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: "Support Center" }),
2606
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Get help from our support team" })
2607
+ ] }),
2608
+ unreadCount > 0 && /* @__PURE__ */ jsx("div", { className: "h-6 w-6 bg-red-500 text-white text-sm rounded-full flex items-center justify-center", children: unreadCount })
2609
+ ] }),
2610
+ /* @__PURE__ */ jsxs(Button, { onClick: openCreateDialog, children: [
2611
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-2" }),
2612
+ "New Ticket"
2613
+ ] })
2614
+ ] }),
2615
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxs(ResizablePanelGroup, { direction: "horizontal", className: "h-full", children: [
2616
+ /* @__PURE__ */ jsx(ResizablePanel, { defaultSize: 35, minSize: 25, maxSize: 50, children: /* @__PURE__ */ jsx("div", { className: "h-full border-r overflow-hidden", children: /* @__PURE__ */ jsx(TicketList, {}) }) }),
2617
+ /* @__PURE__ */ jsx(ResizableHandle, { withHandle: true, className: "hover:bg-accent transition-colors" }),
2618
+ /* @__PURE__ */ jsx(ResizablePanel, { defaultSize: 65, minSize: 50, children: /* @__PURE__ */ jsxs("div", { className: "h-full flex flex-col overflow-hidden", children: [
2619
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(MessageList, {}) }),
2620
+ /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(MessageInput, {}) })
2621
+ ] }) })
2622
+ ] }) }),
2623
+ /* @__PURE__ */ jsx(CreateTicketDialog, {})
2624
+ ] });
2625
+ };
2626
+ var SupportLayout = () => {
2627
+ return /* @__PURE__ */ jsx("div", { className: "h-screen w-full overflow-hidden", children: /* @__PURE__ */ jsx(SupportProvider, { children: /* @__PURE__ */ jsx(SupportLayoutProvider, { children: /* @__PURE__ */ jsx(SupportLayoutContent, {}) }) }) });
2628
+ };
2629
+
2630
+ export { API, APIClient, APIError, APILogger, CookieStorageAdapter, CreateTicketDialog, DEFAULT_RETRY_CONFIG, FetchAdapter, LocalStorageAdapter, MemoryStorageAdapter, MessageCreateRequestSchema, MessageCreateSchema, MessageInput, MessageList, MessageRequestSchema, MessageSchema, NetworkError, PaginatedMessageListSchema, PaginatedTicketListSchema, PatchedMessageRequestSchema, PatchedTicketRequestSchema, REFRESH_TOKEN_KEY, SUPPORT_LAYOUT_EVENTS, SenderSchema, SupportLayout, SupportLayoutProvider, SupportProvider, TOKEN_KEY, TicketCard, TicketList, TicketRequestSchema, TicketSchema, apiSupport, clearAPITokens, closeCreateTicketDialog, configureAPI, createSupportTicketsCreate, createSupportTicketsMessagesCreate, deleteSupportTicketsDestroy, deleteSupportTicketsMessagesDestroy, dispatchValidationError, enums_exports, fetchers_exports, formatZodError, getAPIInstance, getSupportTicketsList, getSupportTicketsMessagesList, getSupportTicketsMessagesRetrieve, getSupportTicketsRetrieve, isAPIConfigured, models_exports, onValidationError, openCreateTicketDialog, partialUpdateSupportTicketsMessagesPartialUpdate, partialUpdateSupportTicketsPartialUpdate, reconfigureAPI, resetAPI, schemas_exports, shouldRetry, updateSupportTicketsMessagesUpdate, updateSupportTicketsUpdate, useCreateSupportTicketsCreate, useCreateSupportTicketsMessagesCreate, useDeleteSupportTicketsDestroy, useDeleteSupportTicketsMessagesDestroy, useInfiniteMessages, useInfiniteTickets, usePartialUpdateSupportTicketsMessagesPartialUpdate, usePartialUpdateSupportTicketsPartialUpdate, useSupportContext, useSupportLayoutContext, useSupportTicketsList, useSupportTicketsMessagesList, useSupportTicketsMessagesRetrieve, useSupportTicketsRetrieve, useUpdateSupportTicketsMessagesUpdate, useUpdateSupportTicketsUpdate, withRetry };