@umituz/web-ai 1.0.3 → 1.0.5

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 (47) hide show
  1. package/dist/{AIErrors-B2ogd1PB.d.ts → AIErrors-CLjXRty-.d.ts} +99 -92
  2. package/dist/{AIErrors-C5EasV_c.d.cts → AIErrors-DjZXUiLT.d.cts} +99 -92
  3. package/dist/{cancellation-error-DwHrDKBz.d.cts → cancellation-error-Cj7fJyCg.d.cts} +3 -3
  4. package/dist/{cancellation-error-CKcZRhFg.d.ts → cancellation-error-CkMn5Kft.d.ts} +3 -3
  5. package/dist/chat/index.cjs.map +1 -1
  6. package/dist/chat/index.d.cts +3 -3
  7. package/dist/chat/index.d.ts +3 -3
  8. package/dist/chat/index.js.map +1 -1
  9. package/dist/{chat.service-CL1qtYxe.d.cts → chat.service-9M-KpLo-.d.cts} +1 -1
  10. package/dist/{chat.service-q05GnhEm.d.ts → chat.service-B4FLFxR1.d.ts} +1 -1
  11. package/dist/content/index.cjs +1047 -490
  12. package/dist/content/index.cjs.map +1 -1
  13. package/dist/content/index.d.cts +165 -219
  14. package/dist/content/index.d.ts +165 -219
  15. package/dist/content/index.js +983 -491
  16. package/dist/content/index.js.map +1 -1
  17. package/dist/{create-ai-9PW752z8.d.ts → create-ai-0eZFFqTw.d.ts} +1 -1
  18. package/dist/{create-ai-CXYKPK6G.d.cts → create-ai-BrKR_5fQ.d.cts} +1 -1
  19. package/dist/hooks/index.cjs +66 -8
  20. package/dist/hooks/index.cjs.map +1 -1
  21. package/dist/hooks/index.d.cts +21 -11
  22. package/dist/hooks/index.d.ts +21 -11
  23. package/dist/hooks/index.js +65 -9
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/index-BUVULo3h.d.ts +177 -0
  26. package/dist/index-BulSkB2L.d.cts +177 -0
  27. package/dist/index.cjs +1800 -15
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +8 -5
  30. package/dist/index.d.ts +8 -5
  31. package/dist/index.js +1757 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/{provider.factory-DfDfk0dK.d.ts → provider.factory-BwPnqSEU.d.ts} +3 -1
  34. package/dist/{provider.factory-BxsfK4WW.d.cts → provider.factory-DyfJtR8M.d.cts} +3 -1
  35. package/dist/providers/index.cjs +9 -0
  36. package/dist/providers/index.cjs.map +1 -1
  37. package/dist/providers/index.d.cts +10 -8
  38. package/dist/providers/index.d.ts +10 -8
  39. package/dist/providers/index.js +7 -1
  40. package/dist/providers/index.js.map +1 -1
  41. package/dist/requestQueue-CkJ6Xc9K.d.cts +261 -0
  42. package/dist/requestQueue-CvxWxC-z.d.ts +261 -0
  43. package/dist/wizard/index.d.cts +2 -86
  44. package/dist/wizard/index.d.ts +2 -86
  45. package/package.json +16 -1
  46. package/dist/ContentGeneration-B6iK2B33.d.cts +0 -93
  47. package/dist/ContentGeneration-B6iK2B33.d.ts +0 -93
@@ -1,5 +1,63 @@
1
1
  'use strict';
2
2
 
3
+ // src/content/domain/types/index.ts
4
+ var PLATFORM_SPECS = {
5
+ twitter: {
6
+ maxLength: 280,
7
+ style: "concise, engaging, thread-friendly",
8
+ emojiSupport: true,
9
+ hashtagSupport: true,
10
+ imageSupport: true,
11
+ videoSupport: true,
12
+ maxHashtags: 5
13
+ },
14
+ linkedin: {
15
+ maxLength: 3e3,
16
+ style: "professional, insightful, industry-focused",
17
+ emojiSupport: true,
18
+ hashtagSupport: true,
19
+ imageSupport: true,
20
+ videoSupport: true,
21
+ maxHashtags: 5
22
+ },
23
+ instagram: {
24
+ maxLength: 2200,
25
+ style: "visual, engaging, emoji-rich",
26
+ emojiSupport: true,
27
+ hashtagSupport: true,
28
+ imageSupport: true,
29
+ videoSupport: true,
30
+ maxHashtags: 30
31
+ },
32
+ threads: {
33
+ maxLength: 500,
34
+ style: "conversational, community-driven",
35
+ emojiSupport: true,
36
+ hashtagSupport: true,
37
+ imageSupport: true,
38
+ videoSupport: true,
39
+ maxHashtags: 5
40
+ },
41
+ tiktok: {
42
+ maxLength: 150,
43
+ style: "catchy, trending, short-form",
44
+ emojiSupport: true,
45
+ hashtagSupport: true,
46
+ imageSupport: false,
47
+ videoSupport: true,
48
+ maxHashtags: 5
49
+ },
50
+ facebook: {
51
+ maxLength: 63206,
52
+ style: "conversational, engaging, shareable",
53
+ emojiSupport: true,
54
+ hashtagSupport: true,
55
+ imageSupport: true,
56
+ videoSupport: true,
57
+ maxHashtags: 5
58
+ }
59
+ };
60
+
3
61
  // src/content/domain/calculations/ContentCreditCost.ts
4
62
  var CREDIT_COSTS = {
5
63
  "text-to-image": { standard: 1, hd: 2, "4k": 4 },
@@ -155,48 +213,428 @@ var AIError = class _AIError extends Error {
155
213
  this.cause = cause;
156
214
  this.metadata = metadata;
157
215
  }
158
- static from(error, fallbackCode = "UNKNOWN") {
159
- if (error instanceof _AIError) return error;
160
- if (error instanceof Error) {
161
- const code = mapMessageToCode(error.message, fallbackCode);
162
- return new _AIError(error.message, code, error);
163
- }
164
- return new _AIError(String(error), fallbackCode, error);
216
+ static from(error, fallbackCode = "UNKNOWN") {
217
+ if (error instanceof _AIError) return error;
218
+ if (error instanceof Error) {
219
+ const code = mapMessageToCode(error.message, fallbackCode);
220
+ return new _AIError(error.message, code, error);
221
+ }
222
+ return new _AIError(String(error), fallbackCode, error);
223
+ }
224
+ toString() {
225
+ const statusPart = typeof this.metadata.status === "number" ? ` (HTTP ${this.metadata.status})` : "";
226
+ return `${this.name} [${this.type}]: ${this.message}${statusPart}`;
227
+ }
228
+ toJSON() {
229
+ return {
230
+ name: this.name,
231
+ type: this.type,
232
+ code: this.code,
233
+ message: this.message,
234
+ metadata: this.metadata
235
+ };
236
+ }
237
+ };
238
+
239
+ // src/content/domain/errors/AIErrors.ts
240
+ var ValidationError = class extends AIError {
241
+ constructor(message) {
242
+ super(message, "VALIDATION_ERROR");
243
+ this.name = "ValidationError";
244
+ }
245
+ };
246
+ var ProviderUnavailableError = class extends AIError {
247
+ constructor(providerId) {
248
+ super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
249
+ this.name = "ProviderUnavailableError";
250
+ }
251
+ };
252
+ var ProviderQuotaExhaustedError = class extends AIError {
253
+ constructor(providerId) {
254
+ super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
255
+ this.name = "ProviderQuotaExhaustedError";
256
+ }
257
+ };
258
+
259
+ // src/content/domain/limits/ValidationLimits.ts
260
+ var ValidationLimits = {
261
+ TOPIC: {
262
+ MIN: 1,
263
+ MAX: 500
264
+ },
265
+ CONTENT: {
266
+ MIN: 1,
267
+ MAX: 1e4
268
+ },
269
+ KEYWORD: {
270
+ MAX_COUNT: 20,
271
+ MAX_LENGTH: 50
272
+ },
273
+ DURATION_SECONDS: {
274
+ MIN: 10,
275
+ MAX: 600
276
+ },
277
+ CALENDAR_DAYS: {
278
+ MIN: 1,
279
+ MAX: 90
280
+ },
281
+ HASHTAG_COUNT: {
282
+ MIN: 1,
283
+ MAX: 50
284
+ },
285
+ SEO_CONTENT_PREVIEW: 500,
286
+ BLOG_PROMPT_PREVIEW: 1e3,
287
+ AB_VARIANT_CONTENT_PREVIEW: 200
288
+ };
289
+
290
+ // src/content/domain/limits/SpeechPaceConfig.ts
291
+ var SpeechPaceConfig = {
292
+ WORDS_PER_SECOND: 2.5,
293
+ TOKENS_PER_SECOND: 10,
294
+ JSON_TOKEN_OVERHEAD: 500,
295
+ TOKENS_PER_CALENDAR_DAY: 150
296
+ };
297
+
298
+ // src/content/domain/limits/ProviderTimingConfig.ts
299
+ var ProviderTimingConfig = {
300
+ DEFAULT_TIMEOUT_MS: 3e4,
301
+ DEFAULT_RETRY_ATTEMPTS: 3,
302
+ FAL_TIMEOUT_MS: 12e4,
303
+ FAL_RETRY_ATTEMPTS: 2,
304
+ GEMINI_TIMEOUT_MS: 6e4,
305
+ GEMINI_RETRY_ATTEMPTS: 3,
306
+ GROQ_TIMEOUT_MS: 3e4,
307
+ GROQ_RETRY_ATTEMPTS: 3,
308
+ HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
309
+ RETRY_BACKOFF_BASE_MS: 1e3
310
+ };
311
+
312
+ // src/content/domain/limits/ModelDefaults.ts
313
+ var ModelDefaults = {
314
+ GROQ_TEXT: "llama-3.1-8b-instant",
315
+ GROQ_CHAT: "llama-3.1-8b-instant",
316
+ FAL_IMAGE: "fal-ai/flux/schnell",
317
+ FAL_VIDEO: "fal-ai/hunyuan-video/1",
318
+ FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
319
+ GEMINI_TEXT: "gemini-2.0-flash",
320
+ GEMINI_IMAGE: "imagen-4.0-generate-001",
321
+ PRUNA_IMAGE: "p-image",
322
+ PRUNA_IMAGE_EDIT: "p-image-edit",
323
+ PRUNA_VIDEO: "p-video"
324
+ };
325
+ var TextModelDefaults = {
326
+ TEXT_MODEL: "claude-sonnet-4-20250514",
327
+ MAX_TOKENS: 4096,
328
+ DEFAULT_TEMPERATURE: 0.7,
329
+ DEFAULT_TOP_P: 0.9
330
+ };
331
+
332
+ // src/content/domain/limits/RequestQueueConfig.ts
333
+ var RequestQueueConfig = {
334
+ MAX_CONCURRENT: 3,
335
+ MAX_QUEUE_SIZE: 50,
336
+ DEFAULT_TIMEOUT_MS: 3e4,
337
+ RETRY_DELAY_MS: 1e3,
338
+ RATE_LIMIT: {
339
+ ENABLED: true,
340
+ WINDOW_MS: 6e4,
341
+ MAX_REQUESTS_PER_WINDOW: 100
342
+ },
343
+ POLL_INTERVAL_MS: 100
344
+ };
345
+
346
+ // src/content/domain/limits/MemoryConfig.ts
347
+ var MemoryConfig = {
348
+ MANAGER: {
349
+ MAX_SIZE_BYTES: 50 * 1024 * 1024,
350
+ CLEANUP_THRESHOLD_RATIO: 0.8,
351
+ RETENTION_RATIO: 0.5
352
+ },
353
+ POOL: {
354
+ DEFAULT_MAX_SIZE: 100
355
+ },
356
+ EXPIRING_CACHE: {
357
+ DEFAULT_TTL_MS: 6e4,
358
+ CLEANUP_INTERVAL_MS: 6e4
359
+ }
360
+ };
361
+
362
+ // src/content/domain/calculations/SpeechPaceEstimate.ts
363
+ function estimateWordCountForDuration(durationSeconds) {
364
+ return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
365
+ }
366
+ function estimateTokenBudgetForDuration(durationSeconds) {
367
+ return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
368
+ }
369
+ function estimateTokenBudgetForCalendarDays(days) {
370
+ return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
371
+ }
372
+
373
+ // src/content/domain/calculations/SeoKeywordDensity.ts
374
+ function countKeywordOccurrences(content, keyword) {
375
+ if (!keyword) return 0;
376
+ const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
377
+ const matches = content.match(new RegExp(escaped, "gi"));
378
+ return matches ? matches.length : 0;
379
+ }
380
+ function countWordsInContent(content) {
381
+ const tokens = content.split(/\s+/).filter(Boolean);
382
+ return tokens.length || 1;
383
+ }
384
+ function calculateKeywordDensity(content, keyword) {
385
+ const totalWords = countWordsInContent(content);
386
+ const occurrences = countKeywordOccurrences(content, keyword);
387
+ return occurrences / totalWords * 100;
388
+ }
389
+
390
+ // src/content/domain/calculations/AbTestImprovementRatio.ts
391
+ function calculateImprovementPercentage(scoreA, scoreB) {
392
+ const higher = Math.max(scoreA, scoreB);
393
+ const lower = Math.min(scoreA, scoreB);
394
+ if (lower <= 0) {
395
+ return "100";
396
+ }
397
+ const delta = (higher / lower - 1) * 100;
398
+ return Math.abs(delta).toFixed(0);
399
+ }
400
+ function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
401
+ return scoreA > scoreB ? idA : idB;
402
+ }
403
+
404
+ // src/content/domain/calculations/RetryBackoffDelay.ts
405
+ function calculateRetryBackoffDelayMs(attemptIndex) {
406
+ return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
407
+ }
408
+
409
+ // src/content/domain/calculations/ContentCalendarDateOffset.ts
410
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
411
+ function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
412
+ return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
413
+ }
414
+
415
+ // src/content/domain/calculations/DefaultModelSelection.ts
416
+ function resolveDefaultPrunaModel(generationType) {
417
+ switch (generationType) {
418
+ case "image-to-image":
419
+ return ModelDefaults.PRUNA_IMAGE_EDIT;
420
+ case "image-to-video":
421
+ return ModelDefaults.PRUNA_VIDEO;
422
+ case "text-to-image":
423
+ return ModelDefaults.PRUNA_IMAGE;
424
+ case "text-to-video":
425
+ return ModelDefaults.PRUNA_VIDEO;
426
+ }
427
+ }
428
+
429
+ // src/content/domain/predicates/KeywordProminenceClassifier.ts
430
+ var HIGH_DENSITY_THRESHOLD = 2;
431
+ var MEDIUM_DENSITY_THRESHOLD = 1;
432
+ function classifyKeywordProminence(densityPercent) {
433
+ if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
434
+ if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
435
+ return "low";
436
+ }
437
+ function isUnderutilizedKeyword(densityPercent) {
438
+ return densityPercent < 1;
439
+ }
440
+
441
+ // src/content/domain/predicates/HashtagPriorityRanker.ts
442
+ var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
443
+ function resolveHashtagBudget(platform) {
444
+ return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
445
+ }
446
+ function rankAndTrimHashtags(hashtags, budget) {
447
+ if (hashtags.length <= budget) return [...hashtags];
448
+ return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
449
+ }
450
+
451
+ // src/content/domain/predicates/PlatformSpecResolver.ts
452
+ var FALLBACK_SPEC = {
453
+ maxLength: 280,
454
+ style: "concise, engaging, audience-friendly",
455
+ emojiSupport: true,
456
+ hashtagSupport: true,
457
+ imageSupport: true,
458
+ videoSupport: true,
459
+ maxHashtags: 5
460
+ };
461
+ function resolvePlatformSpec(platform) {
462
+ return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
463
+ }
464
+ function resolveMaxContentLength(platform, override) {
465
+ return override ?? resolvePlatformSpec(platform).maxLength;
466
+ }
467
+
468
+ // src/content/domain/predicates/ScoreRangeGuard.ts
469
+ var SCORE_MIN = 0;
470
+ var SCORE_MAX = 100;
471
+ var SCORE_FALLBACK = 50;
472
+ var CONFIDENCE_MIN = 0;
473
+ var CONFIDENCE_MAX = 1;
474
+ var CONFIDENCE_FALLBACK = 0.5;
475
+ function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
476
+ if (!Number.isFinite(score)) return fallback;
477
+ return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
478
+ }
479
+ function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
480
+ if (!Number.isFinite(confidence)) return fallback;
481
+ return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
482
+ }
483
+
484
+ // src/content/domain/predicates/AbTestConfidence.ts
485
+ var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
486
+
487
+ // src/content/domain/predicates/ProviderCostEstimator.ts
488
+ var FAL_FIXED_COST = 1;
489
+ var GROQ_FREE_TIER_COST = 0;
490
+ var GEMINI_IMAGE_COST = 0.02;
491
+ var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
492
+ var PRUNA_FIXED_COST = 1;
493
+ var UNKNOWN_PROVIDER_COST = 0;
494
+ function estimateGroqGenerationCost(_request) {
495
+ return GROQ_FREE_TIER_COST;
496
+ }
497
+ function estimateFalGenerationCost(_request) {
498
+ return FAL_FIXED_COST;
499
+ }
500
+ function estimateGeminiGenerationCost(request) {
501
+ if (request.type === "image") return GEMINI_IMAGE_COST;
502
+ return GEMINI_TEXT_PER_1K_CHARS_COST;
503
+ }
504
+ function estimatePrunaGenerationCost() {
505
+ return PRUNA_FIXED_COST;
506
+ }
507
+ function estimateUnknownProviderCost() {
508
+ return UNKNOWN_PROVIDER_COST;
509
+ }
510
+
511
+ // src/content/domain/predicates/FalImageRenderingOptions.ts
512
+ var FAL_FORMAT_TO_IMAGE_SIZE = {
513
+ square: "square_hd",
514
+ landscape: "landscape_16_9",
515
+ portrait: "portrait_9_16",
516
+ story: "portrait_9_16",
517
+ banner: "landscape_16_9"
518
+ };
519
+ var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
520
+ var FAL_QUALITY_TO_STEPS = {
521
+ standard: 4,
522
+ high: 6,
523
+ ultra: 8
524
+ };
525
+ var FAL_DEFAULT_QUALITY_STEPS = 6;
526
+ function resolveFalImageSize(format) {
527
+ if (!format) return FAL_DEFAULT_IMAGE_SIZE;
528
+ return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
529
+ }
530
+ function resolveFalInferenceSteps(quality) {
531
+ if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
532
+ return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
533
+ }
534
+
535
+ // src/content/domain/validation/TopicTextValidator.ts
536
+ function validateTopicText(topic) {
537
+ if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
538
+ throw new ValidationError("Topic cannot be empty");
539
+ }
540
+ const trimmed = topic.trim();
541
+ if (trimmed.length > ValidationLimits.TOPIC.MAX) {
542
+ throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
543
+ }
544
+ return trimmed;
545
+ }
546
+
547
+ // src/content/domain/validation/ContentBodyValidator.ts
548
+ function validateContentBody(content) {
549
+ if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
550
+ throw new ValidationError("Content cannot be empty");
551
+ }
552
+ const trimmed = content.trim();
553
+ if (trimmed.length > ValidationLimits.CONTENT.MAX) {
554
+ throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
555
+ }
556
+ return trimmed;
557
+ }
558
+ function truncateForSeoPreview(content) {
559
+ return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
560
+ }
561
+ function truncateForBlogPromptPreview(content) {
562
+ return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
563
+ }
564
+ function truncateForAbVariantPreview(content) {
565
+ return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
566
+ }
567
+
568
+ // src/content/domain/validation/KeywordListValidator.ts
569
+ function validateKeywordList(keywords) {
570
+ if (!Array.isArray(keywords)) {
571
+ throw new ValidationError("Keywords must be an array");
572
+ }
573
+ if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
574
+ throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
575
+ }
576
+ return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
577
+ const trimmed = keyword.trim();
578
+ if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
579
+ const preview = trimmed.substring(0, 20);
580
+ throw new ValidationError(
581
+ `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
582
+ );
583
+ }
584
+ return trimmed;
585
+ });
586
+ }
587
+
588
+ // src/content/domain/validation/DurationSecondsValidator.ts
589
+ function validateDurationSeconds(duration) {
590
+ if (!Number.isFinite(duration)) {
591
+ throw new ValidationError(
592
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
593
+ );
594
+ }
595
+ if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
596
+ throw new ValidationError(
597
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
598
+ );
165
599
  }
166
- toString() {
167
- const statusPart = typeof this.metadata.status === "number" ? ` (HTTP ${this.metadata.status})` : "";
168
- return `${this.name} [${this.type}]: ${this.message}${statusPart}`;
600
+ return duration;
601
+ }
602
+
603
+ // src/content/domain/validation/CalendarDaysValidator.ts
604
+ function validateCalendarDays(days) {
605
+ if (!Number.isFinite(days)) {
606
+ throw new ValidationError(
607
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
608
+ );
169
609
  }
170
- toJSON() {
171
- return {
172
- name: this.name,
173
- type: this.type,
174
- code: this.code,
175
- message: this.message,
176
- metadata: this.metadata
177
- };
610
+ if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
611
+ throw new ValidationError(
612
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
613
+ );
178
614
  }
179
- };
615
+ return days;
616
+ }
180
617
 
181
- // src/content/domain/errors/AIErrors.ts
182
- var ValidationError = class extends AIError {
183
- constructor(message) {
184
- super(message, "VALIDATION_ERROR");
185
- this.name = "ValidationError";
186
- }
187
- };
188
- var ProviderUnavailableError = class extends AIError {
189
- constructor(providerId) {
190
- super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
191
- this.name = "ProviderUnavailableError";
618
+ // src/content/domain/validation/HashtagCountValidator.ts
619
+ function validateHashtagCount(count) {
620
+ if (!Number.isFinite(count)) {
621
+ throw new ValidationError(
622
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
623
+ );
192
624
  }
193
- };
194
- var ProviderQuotaExhaustedError = class extends AIError {
195
- constructor(providerId) {
196
- super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
197
- this.name = "ProviderQuotaExhaustedError";
625
+ if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
626
+ throw new ValidationError(
627
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
628
+ );
198
629
  }
199
- };
630
+ return Math.floor(count);
631
+ }
632
+
633
+ // src/content/domain/utils/IdGenerator.ts
634
+ function generateId(prefix) {
635
+ const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
636
+ return prefix ? `${prefix}-${id}` : id;
637
+ }
200
638
 
201
639
  // src/core/errors/groq-error.ts
202
640
  var GroqError = class extends AIError {
@@ -265,18 +703,6 @@ function isTextProvider(provider) {
265
703
  return provider.capabilities.includes("text");
266
704
  }
267
705
 
268
- // src/content/domain/limits/ProviderTimingConfig.ts
269
- var ProviderTimingConfig = {
270
- DEFAULT_TIMEOUT_MS: 3e4,
271
- DEFAULT_RETRY_ATTEMPTS: 3,
272
- FAL_TIMEOUT_MS: 12e4,
273
- FAL_RETRY_ATTEMPTS: 2,
274
- GEMINI_TIMEOUT_MS: 6e4,
275
- GEMINI_RETRY_ATTEMPTS: 3,
276
- HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
277
- RETRY_BACKOFF_BASE_MS: 1e3
278
- };
279
-
280
706
  // src/providers/factory/provider.factory.ts
281
707
  var ProviderFactory = class {
282
708
  providers = /* @__PURE__ */ new Map();
@@ -2050,11 +2476,6 @@ function findLastIndex2(items, predicate) {
2050
2476
  return -1;
2051
2477
  }
2052
2478
 
2053
- // src/content/domain/calculations/RetryBackoffDelay.ts
2054
- function calculateRetryBackoffDelayMs(attemptIndex) {
2055
- return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
2056
- }
2057
-
2058
2479
  // src/providers/base/base.provider.ts
2059
2480
  var BaseProvider = class {
2060
2481
  config;
@@ -2103,26 +2524,6 @@ var BaseProvider = class {
2103
2524
  }
2104
2525
  };
2105
2526
 
2106
- // src/content/domain/predicates/ProviderCostEstimator.ts
2107
- var FAL_FIXED_COST = 1;
2108
- var GEMINI_IMAGE_COST = 0.02;
2109
- var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
2110
- function estimateFalGenerationCost(_request) {
2111
- return FAL_FIXED_COST;
2112
- }
2113
- function estimateGeminiGenerationCost(request) {
2114
- if (request.type === "image") return GEMINI_IMAGE_COST;
2115
- return GEMINI_TEXT_PER_1K_CHARS_COST;
2116
- }
2117
-
2118
- // src/content/domain/limits/ModelDefaults.ts
2119
- var ModelDefaults = {
2120
- FAL_IMAGE: "fal-ai/flux/schnell",
2121
- FAL_VIDEO: "fal-ai/hunyuan-video/1",
2122
- FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
2123
- GEMINI_TEXT: "gemini-2.0-flash",
2124
- GEMINI_IMAGE: "imagen-4.0-generate-001"};
2125
-
2126
2527
  // src/providers/gemini/gemini.provider.ts
2127
2528
  var GEMINI_TIERS = {
2128
2529
  fast: "gemini-2.0-flash-lite",
@@ -2282,221 +2683,81 @@ var GeminiProvider = class extends BaseProvider {
2282
2683
  throw new AIError(
2283
2684
  classifyHttpStatus(response.status),
2284
2685
  `Gemini image generation error (${response.status}): ${message}`,
2285
- void 0,
2286
- { status: response.status }
2287
- );
2288
- }
2289
- const data = await response.json();
2290
- const imageData = data.candidates?.[0]?.content?.parts?.[0]?.inlineData;
2291
- if (!imageData) {
2292
- throw new AIError("SERVER_ERROR" /* SERVER_ERROR */, "No image data in Gemini response");
2293
- }
2294
- const url = `data:${imageData.mimeType};base64,${imageData.data}`;
2295
- return {
2296
- id: Date.now().toString(),
2297
- type: "image",
2298
- url,
2299
- metadata: {
2300
- provider: "gemini",
2301
- model: this.models.image,
2302
- mimeType: imageData.mimeType
2303
- },
2304
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
2305
- };
2306
- } catch (error) {
2307
- throw new Error(`Gemini image generation failed: ${error instanceof Error ? error.message : "Unknown error"}`);
2308
- }
2309
- }
2310
- async generateVideo(_request) {
2311
- throw new Error("Gemini provider does not support video generation");
2312
- }
2313
- async imageToVideo(_request) {
2314
- throw new Error("Gemini provider does not support image-to-video conversion");
2315
- }
2316
- async videoToVideo(_request) {
2317
- throw new Error("Gemini provider does not support video-to-video conversion");
2318
- }
2319
- authHeaders() {
2320
- return {
2321
- "Content-Type": "application/json",
2322
- "x-goog-api-key": this.config.apiKey
2323
- };
2324
- }
2325
- buildImagePrompt(request) {
2326
- let prompt = request.prompt;
2327
- if (request.style) {
2328
- const styles = {
2329
- realistic: "photorealistic, highly detailed, 8k resolution",
2330
- cartoon: "cartoon style, colorful, animated",
2331
- abstract: "abstract art, modern, artistic",
2332
- minimalist: "minimalist, clean, simple",
2333
- vintage: "vintage style, retro, classic"
2334
- };
2335
- prompt += `, ${styles[request.style]}`;
2336
- }
2337
- if (request.quality === "ultra") {
2338
- prompt += ", ultra high quality, masterpiece";
2339
- }
2340
- return prompt;
2341
- }
2342
- };
2343
- function toGeminiContents(messages) {
2344
- return messages.filter((message) => message.role !== "system" && message.content.length > 0).map((message) => ({
2345
- role: message.role === "assistant" ? "model" : "user",
2346
- parts: [{ text: message.content }]
2347
- }));
2348
- }
2349
- function mapGeminiFinishReason(reason) {
2350
- if (reason === "STOP") return "stop";
2351
- if (reason === "MAX_TOKENS") return "length";
2352
- if (reason === "SAFETY" || reason === "PROHIBITED_CONTENT") return "content_filter";
2353
- return void 0;
2354
- }
2355
- function findLastIndex3(items, predicate) {
2356
- for (let i = items.length - 1; i >= 0; i--) {
2357
- if (predicate(items[i])) return i;
2358
- }
2359
- return -1;
2360
- }
2361
-
2362
- // src/content/domain/predicates/KeywordProminenceClassifier.ts
2363
- var HIGH_DENSITY_THRESHOLD = 2;
2364
- var MEDIUM_DENSITY_THRESHOLD = 1;
2365
- function classifyKeywordProminence(densityPercent) {
2366
- if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
2367
- if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
2368
- return "low";
2369
- }
2370
- function isUnderutilizedKeyword(densityPercent) {
2371
- return densityPercent < 1;
2372
- }
2373
-
2374
- // src/content/domain/types/index.ts
2375
- var PLATFORM_SPECS = {
2376
- twitter: {
2377
- maxLength: 280,
2378
- style: "concise, engaging, thread-friendly",
2379
- emojiSupport: true,
2380
- hashtagSupport: true,
2381
- imageSupport: true,
2382
- videoSupport: true,
2383
- maxHashtags: 5
2384
- },
2385
- linkedin: {
2386
- maxLength: 3e3,
2387
- style: "professional, insightful, industry-focused",
2388
- emojiSupport: true,
2389
- hashtagSupport: true,
2390
- imageSupport: true,
2391
- videoSupport: true,
2392
- maxHashtags: 5
2393
- },
2394
- instagram: {
2395
- maxLength: 2200,
2396
- style: "visual, engaging, emoji-rich",
2397
- emojiSupport: true,
2398
- hashtagSupport: true,
2399
- imageSupport: true,
2400
- videoSupport: true,
2401
- maxHashtags: 30
2402
- },
2403
- threads: {
2404
- maxLength: 500,
2405
- style: "conversational, community-driven",
2406
- emojiSupport: true,
2407
- hashtagSupport: true,
2408
- imageSupport: true,
2409
- videoSupport: true,
2410
- maxHashtags: 5
2411
- },
2412
- tiktok: {
2413
- maxLength: 150,
2414
- style: "catchy, trending, short-form",
2415
- emojiSupport: true,
2416
- hashtagSupport: true,
2417
- imageSupport: false,
2418
- videoSupport: true,
2419
- maxHashtags: 5
2420
- },
2421
- facebook: {
2422
- maxLength: 63206,
2423
- style: "conversational, engaging, shareable",
2424
- emojiSupport: true,
2425
- hashtagSupport: true,
2426
- imageSupport: true,
2427
- videoSupport: true,
2428
- maxHashtags: 5
2686
+ void 0,
2687
+ { status: response.status }
2688
+ );
2689
+ }
2690
+ const data = await response.json();
2691
+ const imageData = data.candidates?.[0]?.content?.parts?.[0]?.inlineData;
2692
+ if (!imageData) {
2693
+ throw new AIError("SERVER_ERROR" /* SERVER_ERROR */, "No image data in Gemini response");
2694
+ }
2695
+ const url = `data:${imageData.mimeType};base64,${imageData.data}`;
2696
+ return {
2697
+ id: Date.now().toString(),
2698
+ type: "image",
2699
+ url,
2700
+ metadata: {
2701
+ provider: "gemini",
2702
+ model: this.models.image,
2703
+ mimeType: imageData.mimeType
2704
+ },
2705
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
2706
+ };
2707
+ } catch (error) {
2708
+ throw new Error(`Gemini image generation failed: ${error instanceof Error ? error.message : "Unknown error"}`);
2709
+ }
2710
+ }
2711
+ async generateVideo(_request) {
2712
+ throw new Error("Gemini provider does not support video generation");
2713
+ }
2714
+ async imageToVideo(_request) {
2715
+ throw new Error("Gemini provider does not support image-to-video conversion");
2716
+ }
2717
+ async videoToVideo(_request) {
2718
+ throw new Error("Gemini provider does not support video-to-video conversion");
2719
+ }
2720
+ authHeaders() {
2721
+ return {
2722
+ "Content-Type": "application/json",
2723
+ "x-goog-api-key": this.config.apiKey
2724
+ };
2725
+ }
2726
+ buildImagePrompt(request) {
2727
+ let prompt = request.prompt;
2728
+ if (request.style) {
2729
+ const styles = {
2730
+ realistic: "photorealistic, highly detailed, 8k resolution",
2731
+ cartoon: "cartoon style, colorful, animated",
2732
+ abstract: "abstract art, modern, artistic",
2733
+ minimalist: "minimalist, clean, simple",
2734
+ vintage: "vintage style, retro, classic"
2735
+ };
2736
+ prompt += `, ${styles[request.style]}`;
2737
+ }
2738
+ if (request.quality === "ultra") {
2739
+ prompt += ", ultra high quality, masterpiece";
2740
+ }
2741
+ return prompt;
2429
2742
  }
2430
2743
  };
2431
-
2432
- // src/content/domain/predicates/HashtagPriorityRanker.ts
2433
- var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
2434
- function resolveHashtagBudget(platform) {
2435
- return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
2436
- }
2437
- function rankAndTrimHashtags(hashtags, budget) {
2438
- if (hashtags.length <= budget) return [...hashtags];
2439
- return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
2440
- }
2441
-
2442
- // src/content/domain/predicates/PlatformSpecResolver.ts
2443
- var FALLBACK_SPEC = {
2444
- maxLength: 280,
2445
- style: "concise, engaging, audience-friendly",
2446
- emojiSupport: true,
2447
- hashtagSupport: true,
2448
- imageSupport: true,
2449
- videoSupport: true,
2450
- maxHashtags: 5
2451
- };
2452
- function resolvePlatformSpec(platform) {
2453
- return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
2454
- }
2455
- function resolveMaxContentLength(platform, override) {
2456
- return override ?? resolvePlatformSpec(platform).maxLength;
2457
- }
2458
-
2459
- // src/content/domain/predicates/ScoreRangeGuard.ts
2460
- var SCORE_MIN = 0;
2461
- var SCORE_MAX = 100;
2462
- var SCORE_FALLBACK = 50;
2463
- var CONFIDENCE_MIN = 0;
2464
- var CONFIDENCE_MAX = 1;
2465
- var CONFIDENCE_FALLBACK = 0.5;
2466
- function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
2467
- if (!Number.isFinite(score)) return fallback;
2468
- return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
2469
- }
2470
- function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
2471
- if (!Number.isFinite(confidence)) return fallback;
2472
- return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
2744
+ function toGeminiContents(messages) {
2745
+ return messages.filter((message) => message.role !== "system" && message.content.length > 0).map((message) => ({
2746
+ role: message.role === "assistant" ? "model" : "user",
2747
+ parts: [{ text: message.content }]
2748
+ }));
2473
2749
  }
2474
-
2475
- // src/content/domain/predicates/AbTestConfidence.ts
2476
- var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
2477
-
2478
- // src/content/domain/predicates/FalImageRenderingOptions.ts
2479
- var FAL_FORMAT_TO_IMAGE_SIZE = {
2480
- square: "square_hd",
2481
- landscape: "landscape_16_9",
2482
- portrait: "portrait_9_16",
2483
- story: "portrait_9_16",
2484
- banner: "landscape_16_9"
2485
- };
2486
- var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
2487
- var FAL_QUALITY_TO_STEPS = {
2488
- standard: 4,
2489
- high: 6,
2490
- ultra: 8
2491
- };
2492
- var FAL_DEFAULT_QUALITY_STEPS = 6;
2493
- function resolveFalImageSize(format) {
2494
- if (!format) return FAL_DEFAULT_IMAGE_SIZE;
2495
- return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
2750
+ function mapGeminiFinishReason(reason) {
2751
+ if (reason === "STOP") return "stop";
2752
+ if (reason === "MAX_TOKENS") return "length";
2753
+ if (reason === "SAFETY" || reason === "PROHIBITED_CONTENT") return "content_filter";
2754
+ return void 0;
2496
2755
  }
2497
- function resolveFalInferenceSteps(quality) {
2498
- if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
2499
- return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
2756
+ function findLastIndex3(items, predicate) {
2757
+ for (let i = items.length - 1; i >= 0; i--) {
2758
+ if (predicate(items[i])) return i;
2759
+ }
2760
+ return -1;
2500
2761
  }
2501
2762
 
2502
2763
  // src/providers/fal/fal.provider.ts
@@ -3581,25 +3842,6 @@ function createAI(config = {}) {
3581
3842
  return factory;
3582
3843
  }
3583
3844
 
3584
- // src/content/domain/limits/SpeechPaceConfig.ts
3585
- var SpeechPaceConfig = {
3586
- WORDS_PER_SECOND: 2.5,
3587
- TOKENS_PER_SECOND: 10,
3588
- JSON_TOKEN_OVERHEAD: 500,
3589
- TOKENS_PER_CALENDAR_DAY: 150
3590
- };
3591
-
3592
- // src/content/domain/calculations/SpeechPaceEstimate.ts
3593
- function estimateWordCountForDuration(durationSeconds) {
3594
- return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
3595
- }
3596
- function estimateTokenBudgetForDuration(durationSeconds) {
3597
- return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3598
- }
3599
- function estimateTokenBudgetForCalendarDays(days) {
3600
- return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3601
- }
3602
-
3603
3845
  // src/content/application/prompts/PromptBuilder.ts
3604
3846
  var PromptBuilder = class {
3605
3847
  static blogPost(input) {
@@ -3910,75 +4152,6 @@ Return only the JSON:
3910
4152
  }
3911
4153
  };
3912
4154
 
3913
- // src/content/domain/limits/ValidationLimits.ts
3914
- var ValidationLimits = {
3915
- TOPIC: {
3916
- MIN: 1,
3917
- MAX: 500
3918
- },
3919
- CONTENT: {
3920
- MIN: 1,
3921
- MAX: 1e4
3922
- },
3923
- KEYWORD: {
3924
- MAX_COUNT: 20,
3925
- MAX_LENGTH: 50
3926
- },
3927
- DURATION_SECONDS: {
3928
- MIN: 10,
3929
- MAX: 600
3930
- },
3931
- CALENDAR_DAYS: {
3932
- MIN: 1,
3933
- MAX: 90
3934
- },
3935
- HASHTAG_COUNT: {
3936
- MIN: 1,
3937
- MAX: 50
3938
- },
3939
- SEO_CONTENT_PREVIEW: 500,
3940
- BLOG_PROMPT_PREVIEW: 1e3,
3941
- AB_VARIANT_CONTENT_PREVIEW: 200
3942
- };
3943
-
3944
- // src/content/domain/validation/TopicTextValidator.ts
3945
- function validateTopicText(topic) {
3946
- if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
3947
- throw new ValidationError("Topic cannot be empty");
3948
- }
3949
- const trimmed = topic.trim();
3950
- if (trimmed.length > ValidationLimits.TOPIC.MAX) {
3951
- throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
3952
- }
3953
- return trimmed;
3954
- }
3955
-
3956
- // src/content/domain/validation/KeywordListValidator.ts
3957
- function validateKeywordList(keywords) {
3958
- if (!Array.isArray(keywords)) {
3959
- throw new ValidationError("Keywords must be an array");
3960
- }
3961
- if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
3962
- throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
3963
- }
3964
- return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
3965
- const trimmed = keyword.trim();
3966
- if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
3967
- const preview = trimmed.substring(0, 20);
3968
- throw new ValidationError(
3969
- `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
3970
- );
3971
- }
3972
- return trimmed;
3973
- });
3974
- }
3975
-
3976
- // src/content/domain/utils/IdGenerator.ts
3977
- function generateId(prefix) {
3978
- const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
3979
- return prefix ? `${prefix}-${id}` : id;
3980
- }
3981
-
3982
4155
  // src/content/application/services/BlogService.ts
3983
4156
  var BlogService = class {
3984
4157
  constructor(executor) {
@@ -4000,20 +4173,164 @@ var BlogService = class {
4000
4173
  includeSchema: request.includeSchema,
4001
4174
  includeImages: request.includeImages
4002
4175
  });
4003
- const parsed = await this.executor.runJson(
4004
- prompt,
4005
- {},
4006
- { maxTokens: request.wordCount * 2, temperature: 0.7 }
4176
+ const parsed = await this.executor.runJson(
4177
+ prompt,
4178
+ {},
4179
+ { maxTokens: request.wordCount * 2, temperature: 0.7 }
4180
+ );
4181
+ return {
4182
+ id: generateId("blog"),
4183
+ ...parsed,
4184
+ blogType: request.blogType,
4185
+ tone: request.tone,
4186
+ wordCount: request.wordCount,
4187
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
4188
+ };
4189
+ }
4190
+ };
4191
+
4192
+ // src/content/infrastructure/utils/requestQueue.ts
4193
+ var RequestPriority = /* @__PURE__ */ ((RequestPriority2) => {
4194
+ RequestPriority2[RequestPriority2["LOW"] = 0] = "LOW";
4195
+ RequestPriority2[RequestPriority2["NORMAL"] = 1] = "NORMAL";
4196
+ RequestPriority2[RequestPriority2["HIGH"] = 2] = "HIGH";
4197
+ RequestPriority2[RequestPriority2["URGENT"] = 3] = "URGENT";
4198
+ return RequestPriority2;
4199
+ })(RequestPriority || {});
4200
+ var DEFAULT_CONFIG = {
4201
+ maxConcurrent: RequestQueueConfig.MAX_CONCURRENT,
4202
+ maxQueueSize: RequestQueueConfig.MAX_QUEUE_SIZE,
4203
+ defaultTimeout: RequestQueueConfig.DEFAULT_TIMEOUT_MS,
4204
+ retryDelay: RequestQueueConfig.RETRY_DELAY_MS,
4205
+ enableRateLimit: RequestQueueConfig.RATE_LIMIT.ENABLED,
4206
+ rateLimitWindow: RequestQueueConfig.RATE_LIMIT.WINDOW_MS,
4207
+ rateLimitMaxRequests: RequestQueueConfig.RATE_LIMIT.MAX_REQUESTS_PER_WINDOW
4208
+ };
4209
+ var RequestQueue2 = class {
4210
+ queue = [];
4211
+ running = /* @__PURE__ */ new Set();
4212
+ config;
4213
+ requestHistory = [];
4214
+ isProcessing = false;
4215
+ constructor(config = {}) {
4216
+ this.config = { ...DEFAULT_CONFIG, ...config };
4217
+ }
4218
+ async add(fn, priority = 1 /* NORMAL */, maxRetries = 3) {
4219
+ if (this.queue.length >= this.config.maxQueueSize) {
4220
+ throw new Error("Queue is full");
4221
+ }
4222
+ return new Promise((resolve, reject) => {
4223
+ const request = {
4224
+ id: generateId("req"),
4225
+ priority,
4226
+ timestamp: Date.now(),
4227
+ fn,
4228
+ resolve,
4229
+ reject,
4230
+ retries: 0,
4231
+ maxRetries
4232
+ };
4233
+ this.queue.push(request);
4234
+ this.sortQueue();
4235
+ if (!this.isProcessing) {
4236
+ this.process();
4237
+ }
4238
+ });
4239
+ }
4240
+ sortQueue() {
4241
+ this.queue.sort((a, b) => {
4242
+ if (a.priority !== b.priority) {
4243
+ return b.priority - a.priority;
4244
+ }
4245
+ return a.timestamp - b.timestamp;
4246
+ });
4247
+ }
4248
+ async process() {
4249
+ if (this.isProcessing) return;
4250
+ this.isProcessing = true;
4251
+ while (this.queue.length > 0 || this.running.size > 0) {
4252
+ while (this.queue.length > 0 && this.running.size < this.config.maxConcurrent) {
4253
+ if (this.config.enableRateLimit && !this.canMakeRequest()) {
4254
+ break;
4255
+ }
4256
+ const request = this.queue.shift();
4257
+ if (!request) break;
4258
+ this.running.add(request.id);
4259
+ this.executeRequest(request);
4260
+ }
4261
+ await new Promise((resolve) => setTimeout(resolve, RequestQueueConfig.POLL_INTERVAL_MS));
4262
+ }
4263
+ this.isProcessing = false;
4264
+ }
4265
+ canMakeRequest() {
4266
+ const now = Date.now();
4267
+ const windowStart = now - this.config.rateLimitWindow;
4268
+ this.requestHistory = this.requestHistory.filter(
4269
+ (timestamp) => timestamp > windowStart
4007
4270
  );
4271
+ return this.requestHistory.length < this.config.rateLimitMaxRequests;
4272
+ }
4273
+ async executeRequest(request) {
4274
+ try {
4275
+ if (this.config.enableRateLimit) {
4276
+ this.requestHistory.push(Date.now());
4277
+ }
4278
+ const result = await this.withTimeout(
4279
+ request.fn,
4280
+ this.config.defaultTimeout
4281
+ );
4282
+ request.resolve(result);
4283
+ } catch (error) {
4284
+ if (request.retries < request.maxRetries) {
4285
+ request.retries++;
4286
+ const delay = this.config.retryDelay * request.retries;
4287
+ setTimeout(() => {
4288
+ this.queue.unshift(request);
4289
+ this.sortQueue();
4290
+ }, delay);
4291
+ } else {
4292
+ request.reject(error);
4293
+ }
4294
+ } finally {
4295
+ this.running.delete(request.id);
4296
+ }
4297
+ }
4298
+ async withTimeout(fn, timeout) {
4299
+ const controller = new AbortController();
4300
+ let timeoutId;
4301
+ const timeoutPromise = new Promise((_, reject) => {
4302
+ timeoutId = setTimeout(() => {
4303
+ controller.abort();
4304
+ reject(new Error("Request timeout"));
4305
+ }, timeout);
4306
+ });
4307
+ try {
4308
+ const result = await Promise.race([fn(controller.signal), timeoutPromise]);
4309
+ return result;
4310
+ } finally {
4311
+ if (timeoutId) clearTimeout(timeoutId);
4312
+ }
4313
+ }
4314
+ getStats() {
4008
4315
  return {
4009
- id: generateId("blog"),
4010
- ...parsed,
4011
- blogType: request.blogType,
4012
- tone: request.tone,
4013
- wordCount: request.wordCount,
4014
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
4316
+ queued: this.queue.length,
4317
+ running: this.running.size,
4318
+ rateLimitRemaining: this.config.enableRateLimit ? this.config.rateLimitMaxRequests - this.requestHistory.filter(
4319
+ (timestamp) => Date.now() - timestamp < this.config.rateLimitWindow
4320
+ ).length : Infinity
4015
4321
  };
4016
4322
  }
4323
+ clear() {
4324
+ for (const request of this.queue) {
4325
+ request.reject(new Error("Queue cleared"));
4326
+ }
4327
+ this.queue = [];
4328
+ }
4329
+ async drain() {
4330
+ while (this.running.size > 0) {
4331
+ await new Promise((resolve) => setTimeout(resolve, RequestQueueConfig.POLL_INTERVAL_MS));
4332
+ }
4333
+ }
4017
4334
  };
4018
4335
  async function batchRequest(requests, options = {}) {
4019
4336
  const {
@@ -4046,21 +4363,6 @@ async function batchRequest(requests, options = {}) {
4046
4363
  return results;
4047
4364
  }
4048
4365
 
4049
- // src/content/domain/validation/HashtagCountValidator.ts
4050
- function validateHashtagCount(count) {
4051
- if (!Number.isFinite(count)) {
4052
- throw new ValidationError(
4053
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4054
- );
4055
- }
4056
- if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
4057
- throw new ValidationError(
4058
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4059
- );
4060
- }
4061
- return Math.floor(count);
4062
- }
4063
-
4064
4366
  // src/content/application/services/SocialService.ts
4065
4367
  var MULTI_PLATFORMS = [
4066
4368
  "twitter",
@@ -4138,21 +4440,6 @@ var SocialService = class {
4138
4440
  }
4139
4441
  };
4140
4442
 
4141
- // src/content/domain/validation/DurationSecondsValidator.ts
4142
- function validateDurationSeconds(duration) {
4143
- if (!Number.isFinite(duration)) {
4144
- throw new ValidationError(
4145
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4146
- );
4147
- }
4148
- if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
4149
- throw new ValidationError(
4150
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4151
- );
4152
- }
4153
- return duration;
4154
- }
4155
-
4156
4443
  // src/content/application/services/VideoScriptService.ts
4157
4444
  var buildScriptResult = (parsed, duration) => {
4158
4445
  const script = parsed.script ?? "";
@@ -4207,27 +4494,6 @@ var VideoScriptService = class {
4207
4494
  }
4208
4495
  };
4209
4496
 
4210
- // src/content/domain/validation/ContentBodyValidator.ts
4211
- function validateContentBody(content) {
4212
- if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
4213
- throw new ValidationError("Content cannot be empty");
4214
- }
4215
- const trimmed = content.trim();
4216
- if (trimmed.length > ValidationLimits.CONTENT.MAX) {
4217
- throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
4218
- }
4219
- return trimmed;
4220
- }
4221
- function truncateForSeoPreview(content) {
4222
- return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
4223
- }
4224
- function truncateForBlogPromptPreview(content) {
4225
- return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
4226
- }
4227
- function truncateForAbVariantPreview(content) {
4228
- return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
4229
- }
4230
-
4231
4497
  // src/content/application/services/AnalysisService.ts
4232
4498
  var DEFAULT_SENTIMENT = {
4233
4499
  sentiment: "neutral",
@@ -4280,23 +4546,6 @@ var AnalysisService = class {
4280
4546
  }
4281
4547
  };
4282
4548
 
4283
- // src/content/domain/calculations/SeoKeywordDensity.ts
4284
- function countKeywordOccurrences(content, keyword) {
4285
- if (!keyword) return 0;
4286
- const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4287
- const matches = content.match(new RegExp(escaped, "gi"));
4288
- return matches ? matches.length : 0;
4289
- }
4290
- function countWordsInContent(content) {
4291
- const tokens = content.split(/\s+/).filter(Boolean);
4292
- return tokens.length || 1;
4293
- }
4294
- function calculateKeywordDensity(content, keyword) {
4295
- const totalWords = countWordsInContent(content);
4296
- const occurrences = countKeywordOccurrences(content, keyword);
4297
- return occurrences / totalWords * 100;
4298
- }
4299
-
4300
4549
  // src/content/application/services/SeoService.ts
4301
4550
  var DEFAULT_SEO_SCORE = {
4302
4551
  keywordDensity: 50,
@@ -4373,20 +4622,6 @@ var SeoService = class {
4373
4622
  }
4374
4623
  };
4375
4624
 
4376
- // src/content/domain/calculations/AbTestImprovementRatio.ts
4377
- function calculateImprovementPercentage(scoreA, scoreB) {
4378
- const higher = Math.max(scoreA, scoreB);
4379
- const lower = Math.min(scoreA, scoreB);
4380
- if (lower <= 0) {
4381
- return "100";
4382
- }
4383
- const delta = (higher / lower - 1) * 100;
4384
- return Math.abs(delta).toFixed(0);
4385
- }
4386
- function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
4387
- return scoreA > scoreB ? idA : idB;
4388
- }
4389
-
4390
4625
  // src/content/application/services/ABTestService.ts
4391
4626
  var DEFAULT_PREDICTION = {
4392
4627
  variantId: "",
@@ -4488,27 +4723,6 @@ var ImagePromptService = class {
4488
4723
  }
4489
4724
  };
4490
4725
 
4491
- // src/content/domain/validation/CalendarDaysValidator.ts
4492
- function validateCalendarDays(days) {
4493
- if (!Number.isFinite(days)) {
4494
- throw new ValidationError(
4495
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4496
- );
4497
- }
4498
- if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
4499
- throw new ValidationError(
4500
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4501
- );
4502
- }
4503
- return days;
4504
- }
4505
-
4506
- // src/content/domain/calculations/ContentCalendarDateOffset.ts
4507
- var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
4508
- function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
4509
- return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
4510
- }
4511
-
4512
4726
  // src/content/application/services/ContentCalendarService.ts
4513
4727
  var toCalendarEntry = (item) => ({
4514
4728
  date: resolveCalendarEntryDate(item.day),
@@ -4601,7 +4815,10 @@ function safeJSONParse(text, fallback, onError) {
4601
4815
  const positionMatch = error.message.match(/position (\d+)/);
4602
4816
  const position = positionMatch ? parseInt(positionMatch[1], 10) : -1;
4603
4817
  if (position > 0) {
4604
- text.substring(Math.max(0, position - 50), position + 50);
4818
+ const context = text.substring(Math.max(0, position - 50), position + 50);
4819
+ onError?.(`JSON parse error at position ${position}: "${context}"`);
4820
+ } else {
4821
+ onError?.(`JSON parse error: ${error.message}`);
4605
4822
  }
4606
4823
  }
4607
4824
  return fallback;
@@ -4628,9 +4845,23 @@ function extractJSON(text) {
4628
4845
  function parseAIResponse(response, fallback, onError) {
4629
4846
  const json = extractJSON(response);
4630
4847
  if (!json) {
4848
+ onError?.("No JSON payload found in response");
4631
4849
  return fallback;
4632
4850
  }
4633
- return safeJSONParse(json, fallback);
4851
+ return safeJSONParse(json, fallback, onError);
4852
+ }
4853
+ function isValidJSON(text) {
4854
+ const trimmed = text.trim();
4855
+ if (trimmed.length === 0) return false;
4856
+ if (!(trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]"))) {
4857
+ return false;
4858
+ }
4859
+ try {
4860
+ JSON.parse(trimmed);
4861
+ return true;
4862
+ } catch {
4863
+ return false;
4864
+ }
4634
4865
  }
4635
4866
 
4636
4867
  // src/content/application/services/GenerationExecutor.ts
@@ -4691,7 +4922,48 @@ function toAIProviderConfig(config) {
4691
4922
  ...pruna ? { pruna } : {}
4692
4923
  };
4693
4924
  }
4694
- var buildServices = (configOrGenerator) => {
4925
+ var buildServices = (configOrGenerator, model, customGenerator) => {
4926
+ if (customGenerator) {
4927
+ const executor2 = new GenerationExecutor(customGenerator);
4928
+ const emptyFactory = new ProviderFactory({
4929
+ priority: [],
4930
+ fallbackEnabled: false
4931
+ });
4932
+ return {
4933
+ providerFactory: emptyFactory,
4934
+ blogService: new BlogService(executor2),
4935
+ socialService: new SocialService(executor2),
4936
+ videoScriptService: new VideoScriptService(executor2),
4937
+ analysisService: new AnalysisService(executor2),
4938
+ seoService: new SeoService(executor2),
4939
+ abTestService: new ABTestService(executor2),
4940
+ imagePromptService: new ImagePromptService(executor2),
4941
+ contentCalendarService: new ContentCalendarService(executor2),
4942
+ mediaGenerationService: new MediaGenerationService(emptyFactory)
4943
+ };
4944
+ }
4945
+ if (typeof configOrGenerator === "string") {
4946
+ const aiConfig = {
4947
+ anthropic: {
4948
+ apiKey: configOrGenerator,
4949
+ ...model ? { models: { balanced: model } } : {}
4950
+ }
4951
+ };
4952
+ const factory2 = createAI(aiConfig);
4953
+ const executor2 = new GenerationExecutor(factory2);
4954
+ return {
4955
+ providerFactory: factory2,
4956
+ blogService: new BlogService(executor2),
4957
+ socialService: new SocialService(executor2),
4958
+ videoScriptService: new VideoScriptService(executor2),
4959
+ analysisService: new AnalysisService(executor2),
4960
+ seoService: new SeoService(executor2),
4961
+ abTestService: new ABTestService(executor2),
4962
+ imagePromptService: new ImagePromptService(executor2),
4963
+ contentCalendarService: new ContentCalendarService(executor2),
4964
+ mediaGenerationService: new MediaGenerationService(factory2)
4965
+ };
4966
+ }
4695
4967
  if (isTextGenerator(configOrGenerator)) {
4696
4968
  const executor2 = new GenerationExecutor(configOrGenerator);
4697
4969
  const emptyFactory = new ProviderFactory({
@@ -4737,8 +5009,8 @@ var AIContentService = class {
4737
5009
  imagePromptService;
4738
5010
  contentCalendarService;
4739
5011
  mediaGenerationService;
4740
- constructor(configOrGenerator) {
4741
- const bundle = buildServices(configOrGenerator);
5012
+ constructor(configOrGenerator, model, textGenerator) {
5013
+ const bundle = buildServices(configOrGenerator, model, textGenerator);
4742
5014
  this.providerFactory = bundle.providerFactory;
4743
5015
  this.blogService = bundle.blogService;
4744
5016
  this.socialService = bundle.socialService;
@@ -4819,35 +5091,320 @@ var AIContentService = class {
4819
5091
  }
4820
5092
  };
4821
5093
 
5094
+ // src/wizard/content.wizard.ts
5095
+ var CONTENT_WIZARD_STEPS = [
5096
+ {
5097
+ id: "select-type",
5098
+ label: "Select Type",
5099
+ icon: "Layers",
5100
+ description: "Choose the type of content you want to generate",
5101
+ validate: (data) => Boolean(data.contentType)
5102
+ },
5103
+ {
5104
+ id: "input-topic",
5105
+ label: "Topic",
5106
+ icon: "Lightbulb",
5107
+ description: "Enter your topic or idea",
5108
+ validate: (data) => {
5109
+ const topic = data.topic;
5110
+ return typeof topic === "string" && topic.length > 0;
5111
+ }
5112
+ },
5113
+ {
5114
+ id: "configure",
5115
+ label: "Configure",
5116
+ icon: "Settings",
5117
+ description: "Set tone, audience, and platform",
5118
+ validate: (data) => {
5119
+ const d = data;
5120
+ return Boolean(d.tone && d.targetAudience);
5121
+ }
5122
+ },
5123
+ {
5124
+ id: "advanced",
5125
+ label: "Advanced",
5126
+ icon: "Sliders",
5127
+ description: "Additional options and optimizations",
5128
+ optional: true
5129
+ },
5130
+ {
5131
+ id: "preview",
5132
+ label: "Preview",
5133
+ icon: "Eye",
5134
+ description: "Review your settings before generation"
5135
+ },
5136
+ {
5137
+ id: "generating",
5138
+ label: "Generating",
5139
+ icon: "Sparkles",
5140
+ description: "AI is generating your content"
5141
+ },
5142
+ {
5143
+ id: "results",
5144
+ label: "Results",
5145
+ icon: "CheckCircle",
5146
+ description: "Your generated content is ready"
5147
+ }
5148
+ ];
5149
+ function buildContentRequest(data) {
5150
+ switch (data.contentType) {
5151
+ case "blog":
5152
+ return {
5153
+ topic: data.topic ?? "",
5154
+ blogType: "tutorial",
5155
+ targetKeywords: data.keywords ?? [],
5156
+ tone: data.tone ?? "professional",
5157
+ wordCount: data.wordCount ?? 1e3,
5158
+ targetAudience: data.targetAudience ?? "",
5159
+ seoOptimization: data.seoOptimization ?? false,
5160
+ includeImages: data.includeImages ?? false,
5161
+ includeSchema: false
5162
+ };
5163
+ case "social":
5164
+ return {
5165
+ topic: data.topic ?? "",
5166
+ platform: data.platform ?? "twitter",
5167
+ tone: data.tone ?? "casual",
5168
+ hashtags: true,
5169
+ targetAudience: data.targetAudience,
5170
+ includeCallToAction: data.includeCallToAction
5171
+ };
5172
+ case "script":
5173
+ return {
5174
+ topic: data.topic ?? "",
5175
+ tone: data.tone ?? "professional",
5176
+ duration: data.duration ?? 60,
5177
+ targetAudience: data.targetAudience ?? "",
5178
+ includeVisuals: true,
5179
+ includeCallToAction: data.includeCallToAction ?? false
5180
+ };
5181
+ default:
5182
+ throw new Error(`Unsupported content type: ${data.contentType}`);
5183
+ }
5184
+ }
5185
+
5186
+ // src/wizard/image.wizard.ts
5187
+ var IMAGE_WIZARD_STEPS = [
5188
+ {
5189
+ id: "input-prompt",
5190
+ label: "Describe Image",
5191
+ icon: "Image",
5192
+ description: "Describe the image you want to create",
5193
+ validate: (data) => {
5194
+ const prompt = data.prompt;
5195
+ return typeof prompt === "string" && prompt.length > 0;
5196
+ }
5197
+ },
5198
+ {
5199
+ id: "select-style",
5200
+ label: "Style",
5201
+ icon: "Palette",
5202
+ description: "Choose the artistic style",
5203
+ validate: (data) => Boolean(data.style)
5204
+ },
5205
+ {
5206
+ id: "configure",
5207
+ label: "Configure",
5208
+ icon: "Settings",
5209
+ description: "Set format, quality, and quantity",
5210
+ validate: (data) => {
5211
+ const d = data;
5212
+ return Boolean(d.format && d.quality);
5213
+ }
5214
+ },
5215
+ {
5216
+ id: "advanced",
5217
+ label: "Advanced",
5218
+ icon: "Sliders",
5219
+ description: "Color palette and platform optimization",
5220
+ optional: true
5221
+ },
5222
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5223
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your image" },
5224
+ { id: "results", label: "Results", icon: "Image", description: "Your generated image is ready" }
5225
+ ];
5226
+ function buildImageRequest(data) {
5227
+ return {
5228
+ type: "image",
5229
+ prompt: data.prompt ?? "",
5230
+ style: data.style,
5231
+ format: data.format,
5232
+ quality: data.quality,
5233
+ quantity: data.quantity ?? 1
5234
+ };
5235
+ }
5236
+
5237
+ // src/wizard/video.wizard.ts
5238
+ var validateSource = (data) => {
5239
+ const d = data;
5240
+ if (d.generationType === "text-to-video") {
5241
+ return typeof d.prompt === "string" && d.prompt.length > 0;
5242
+ }
5243
+ if (d.generationType === "image-to-video") {
5244
+ return typeof d.imageUrl === "string" && d.imageUrl.length > 0;
5245
+ }
5246
+ if (d.generationType === "video-to-video") {
5247
+ return typeof d.sourceVideoUrl === "string" && d.sourceVideoUrl.length > 0 && typeof d.prompt === "string" && d.prompt.length > 0;
5248
+ }
5249
+ return false;
5250
+ };
5251
+ var VIDEO_WIZARD_STEPS = [
5252
+ {
5253
+ id: "select-type",
5254
+ label: "Select Type",
5255
+ icon: "Video",
5256
+ description: "Choose video generation type",
5257
+ validate: (data) => Boolean(data.generationType)
5258
+ },
5259
+ {
5260
+ id: "input-source",
5261
+ label: "Source",
5262
+ icon: "FileInput",
5263
+ description: "Provide your source (prompt, image, or video)",
5264
+ validate: validateSource
5265
+ },
5266
+ {
5267
+ id: "configure",
5268
+ label: "Configure",
5269
+ icon: "Settings",
5270
+ description: "Set duration, aspect ratio, and style",
5271
+ validate: (data) => {
5272
+ const d = data;
5273
+ return Boolean(d.duration && d.aspectRatio);
5274
+ }
5275
+ },
5276
+ { id: "advanced", label: "Advanced", icon: "Sliders", description: "Additional video options", optional: true },
5277
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5278
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your video" },
5279
+ { id: "results", label: "Results", icon: "Video", description: "Your generated video is ready" }
5280
+ ];
5281
+ function buildVideoRequest(data) {
5282
+ switch (data.generationType) {
5283
+ case "text-to-video":
5284
+ return {
5285
+ type: "video",
5286
+ prompt: data.prompt ?? "",
5287
+ duration: data.duration ?? 5,
5288
+ aspectRatio: data.aspectRatio ?? "16:9",
5289
+ style: data.style,
5290
+ quality: data.quality
5291
+ };
5292
+ case "image-to-video":
5293
+ return {
5294
+ type: "video",
5295
+ imageUrl: data.imageUrl ?? "",
5296
+ prompt: data.prompt,
5297
+ duration: data.duration ?? 5,
5298
+ motion: data.motion ?? "medium",
5299
+ camera: data.camera ?? "static"
5300
+ };
5301
+ case "video-to-video":
5302
+ return {
5303
+ type: "video",
5304
+ sourceVideoUrl: data.sourceVideoUrl ?? "",
5305
+ prompt: data.prompt ?? "",
5306
+ styleTransfer: data.styleTransfer,
5307
+ enhanceQuality: data.enhanceQuality
5308
+ };
5309
+ default:
5310
+ throw new Error(`Unsupported generation type: ${data.generationType}`);
5311
+ }
5312
+ }
5313
+
4822
5314
  exports.ABTestService = ABTestService;
5315
+ exports.AB_TEST_DEFAULT_CONFIDENCE = AB_TEST_DEFAULT_CONFIDENCE;
4823
5316
  exports.AIContentService = AIContentService;
4824
5317
  exports.AIError = AIError;
4825
5318
  exports.ASPECT_RATIO_OPTIONS = ASPECT_RATIO_OPTIONS;
4826
5319
  exports.ASPECT_RATIO_VALUES = ASPECT_RATIO_VALUES;
4827
5320
  exports.AnalysisService = AnalysisService;
4828
5321
  exports.BlogService = BlogService;
5322
+ exports.CONTENT_WIZARD_STEPS = CONTENT_WIZARD_STEPS;
5323
+ exports.CREDIT_COSTS = CREDIT_COSTS;
4829
5324
  exports.ContentCalendarService = ContentCalendarService;
5325
+ exports.ContentRequestQueue = RequestQueue2;
5326
+ exports.DEFAULT_CREDIT_COST = DEFAULT_CREDIT_COST;
5327
+ exports.DEFAULT_HASHTAG_BUDGET = DEFAULT_HASHTAG_BUDGET;
4830
5328
  exports.GENERATION_COSTS = CREDIT_COSTS;
4831
5329
  exports.GenerationExecutor = GenerationExecutor;
4832
5330
  exports.IMAGE_QUALITY_OPTIONS = IMAGE_QUALITY_OPTIONS;
4833
5331
  exports.IMAGE_QUALITY_VALUES = IMAGE_QUALITY_VALUES;
5332
+ exports.IMAGE_WIZARD_STEPS = IMAGE_WIZARD_STEPS;
4834
5333
  exports.ImagePromptService = ImagePromptService;
4835
5334
  exports.MOTION_OPTIONS = MOTION_OPTIONS;
4836
5335
  exports.MediaGenerationService = MediaGenerationService;
5336
+ exports.MemoryConfig = MemoryConfig;
5337
+ exports.ModelDefaults = ModelDefaults;
5338
+ exports.PLATFORM_SPECS = PLATFORM_SPECS;
4837
5339
  exports.PromptBuilder = PromptBuilder;
4838
5340
  exports.ProviderQuotaExhaustedError = ProviderQuotaExhaustedError;
5341
+ exports.ProviderTimingConfig = ProviderTimingConfig;
4839
5342
  exports.ProviderUnavailableError = ProviderUnavailableError;
5343
+ exports.RequestPriority = RequestPriority;
5344
+ exports.RequestQueueConfig = RequestQueueConfig;
4840
5345
  exports.STYLE_PRESETS = STYLE_PRESETS;
4841
5346
  exports.SeoService = SeoService;
4842
5347
  exports.SocialService = SocialService;
5348
+ exports.SpeechPaceConfig = SpeechPaceConfig;
5349
+ exports.TextModelDefaults = TextModelDefaults;
4843
5350
  exports.VIDEO_DURATION_OPTIONS = VIDEO_DURATION_OPTIONS;
4844
5351
  exports.VIDEO_DURATION_OPTIONS_SECONDS = VIDEO_DURATION_OPTIONS_SECONDS;
4845
5352
  exports.VIDEO_QUALITY_OPTIONS = VIDEO_QUALITY_OPTIONS;
4846
5353
  exports.VIDEO_QUALITY_VALUES = VIDEO_QUALITY_VALUES;
5354
+ exports.VIDEO_WIZARD_STEPS = VIDEO_WIZARD_STEPS;
4847
5355
  exports.ValidationError = ValidationError;
5356
+ exports.ValidationLimits = ValidationLimits;
4848
5357
  exports.VideoScriptService = VideoScriptService;
5358
+ exports.batchRequest = batchRequest;
5359
+ exports.buildContentRequest = buildContentRequest;
5360
+ exports.buildImageRequest = buildImageRequest;
5361
+ exports.buildVideoRequest = buildVideoRequest;
5362
+ exports.calculateContentCreditCost = calculateContentCreditCost;
4849
5363
  exports.calculateCreditCost = calculateContentCreditCost;
5364
+ exports.calculateImprovementPercentage = calculateImprovementPercentage;
5365
+ exports.calculateKeywordDensity = calculateKeywordDensity;
5366
+ exports.calculateRetryBackoffDelayMs = calculateRetryBackoffDelayMs;
5367
+ exports.clampConfidenceToValidRange = clampConfidenceToValidRange;
5368
+ exports.clampScoreToValidRange = clampScoreToValidRange;
5369
+ exports.classifyKeywordProminence = classifyKeywordProminence;
5370
+ exports.countKeywordOccurrences = countKeywordOccurrences;
5371
+ exports.countWordsInContent = countWordsInContent;
5372
+ exports.estimateFalGenerationCost = estimateFalGenerationCost;
5373
+ exports.estimateGeminiGenerationCost = estimateGeminiGenerationCost;
5374
+ exports.estimateGroqGenerationCost = estimateGroqGenerationCost;
5375
+ exports.estimatePrunaGenerationCost = estimatePrunaGenerationCost;
5376
+ exports.estimateTokenBudgetForCalendarDays = estimateTokenBudgetForCalendarDays;
5377
+ exports.estimateTokenBudgetForDuration = estimateTokenBudgetForDuration;
5378
+ exports.estimateUnknownProviderCost = estimateUnknownProviderCost;
5379
+ exports.estimateWordCountForDuration = estimateWordCountForDuration;
5380
+ exports.extractJSON = extractJSON;
5381
+ exports.generateId = generateId;
4850
5382
  exports.getDimensionsForAspectRatio = getDimensionsForAspectRatio;
4851
5383
  exports.getRecommendedQuality = getRecommendedQuality;
5384
+ exports.isUnderutilizedKeyword = isUnderutilizedKeyword;
5385
+ exports.isValidJSON = isValidJSON;
5386
+ exports.parseAIResponse = parseAIResponse;
5387
+ exports.rankAndTrimHashtags = rankAndTrimHashtags;
5388
+ exports.recommendQualityForAspectRatio = recommendQualityForAspectRatio;
5389
+ exports.resolveCalendarEntryDate = resolveCalendarEntryDate;
5390
+ exports.resolveDefaultPrunaModel = resolveDefaultPrunaModel;
5391
+ exports.resolveDimensionsForAspectRatio = resolveDimensionsForAspectRatio;
5392
+ exports.resolveFalImageSize = resolveFalImageSize;
5393
+ exports.resolveFalInferenceSteps = resolveFalInferenceSteps;
5394
+ exports.resolveHashtagBudget = resolveHashtagBudget;
5395
+ exports.resolveMaxContentLength = resolveMaxContentLength;
5396
+ exports.resolvePlatformSpec = resolvePlatformSpec;
5397
+ exports.safeJSONParse = safeJSONParse;
5398
+ exports.selectHigherScoreVariantId = selectHigherScoreVariantId;
5399
+ exports.toQualityTier = toQualityTier;
5400
+ exports.truncateForAbVariantPreview = truncateForAbVariantPreview;
5401
+ exports.truncateForBlogPromptPreview = truncateForBlogPromptPreview;
5402
+ exports.truncateForSeoPreview = truncateForSeoPreview;
5403
+ exports.validateCalendarDays = validateCalendarDays;
5404
+ exports.validateContentBody = validateContentBody;
5405
+ exports.validateDurationSeconds = validateDurationSeconds;
5406
+ exports.validateHashtagCount = validateHashtagCount;
5407
+ exports.validateKeywordList = validateKeywordList;
5408
+ exports.validateTopicText = validateTopicText;
4852
5409
  //# sourceMappingURL=index.cjs.map
4853
5410
  //# sourceMappingURL=index.cjs.map