@umituz/web-ai 1.0.3 → 1.0.4

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/PromptBuilder-B5Lm1znm.d.ts +215 -0
  4. package/dist/PromptBuilder-DIUZlfV6.d.cts +215 -0
  5. package/dist/{cancellation-error-DwHrDKBz.d.cts → cancellation-error-Cj7fJyCg.d.cts} +3 -3
  6. package/dist/{cancellation-error-CKcZRhFg.d.ts → cancellation-error-CkMn5Kft.d.ts} +3 -3
  7. package/dist/chat/index.cjs.map +1 -1
  8. package/dist/chat/index.d.cts +3 -3
  9. package/dist/chat/index.d.ts +3 -3
  10. package/dist/chat/index.js.map +1 -1
  11. package/dist/{chat.service-CL1qtYxe.d.cts → chat.service-9M-KpLo-.d.cts} +1 -1
  12. package/dist/{chat.service-q05GnhEm.d.ts → chat.service-B4FLFxR1.d.ts} +1 -1
  13. package/dist/content/index.cjs +759 -400
  14. package/dist/content/index.cjs.map +1 -1
  15. package/dist/content/index.d.cts +165 -219
  16. package/dist/content/index.d.ts +165 -219
  17. package/dist/content/index.js +702 -401
  18. package/dist/content/index.js.map +1 -1
  19. package/dist/{create-ai-9PW752z8.d.ts → create-ai-0eZFFqTw.d.ts} +1 -1
  20. package/dist/{create-ai-CXYKPK6G.d.cts → create-ai-BrKR_5fQ.d.cts} +1 -1
  21. package/dist/hooks/index.cjs +2 -0
  22. package/dist/hooks/index.cjs.map +1 -1
  23. package/dist/hooks/index.d.cts +9 -9
  24. package/dist/hooks/index.d.ts +9 -9
  25. package/dist/hooks/index.js +1 -1
  26. package/dist/hooks/index.js.map +1 -1
  27. package/dist/index-BUVULo3h.d.ts +177 -0
  28. package/dist/index-BulSkB2L.d.cts +177 -0
  29. package/dist/index.cjs +1727 -15
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +8 -5
  32. package/dist/index.d.ts +8 -5
  33. package/dist/index.js +1690 -15
  34. package/dist/index.js.map +1 -1
  35. package/dist/{provider.factory-DfDfk0dK.d.ts → provider.factory-BwPnqSEU.d.ts} +3 -1
  36. package/dist/{provider.factory-BxsfK4WW.d.cts → provider.factory-DyfJtR8M.d.cts} +3 -1
  37. package/dist/providers/index.cjs +9 -0
  38. package/dist/providers/index.cjs.map +1 -1
  39. package/dist/providers/index.d.cts +10 -8
  40. package/dist/providers/index.d.ts +10 -8
  41. package/dist/providers/index.js +7 -1
  42. package/dist/providers/index.js.map +1 -1
  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,3 +1,61 @@
1
+ // src/content/domain/types/index.ts
2
+ var PLATFORM_SPECS = {
3
+ twitter: {
4
+ maxLength: 280,
5
+ style: "concise, engaging, thread-friendly",
6
+ emojiSupport: true,
7
+ hashtagSupport: true,
8
+ imageSupport: true,
9
+ videoSupport: true,
10
+ maxHashtags: 5
11
+ },
12
+ linkedin: {
13
+ maxLength: 3e3,
14
+ style: "professional, insightful, industry-focused",
15
+ emojiSupport: true,
16
+ hashtagSupport: true,
17
+ imageSupport: true,
18
+ videoSupport: true,
19
+ maxHashtags: 5
20
+ },
21
+ instagram: {
22
+ maxLength: 2200,
23
+ style: "visual, engaging, emoji-rich",
24
+ emojiSupport: true,
25
+ hashtagSupport: true,
26
+ imageSupport: true,
27
+ videoSupport: true,
28
+ maxHashtags: 30
29
+ },
30
+ threads: {
31
+ maxLength: 500,
32
+ style: "conversational, community-driven",
33
+ emojiSupport: true,
34
+ hashtagSupport: true,
35
+ imageSupport: true,
36
+ videoSupport: true,
37
+ maxHashtags: 5
38
+ },
39
+ tiktok: {
40
+ maxLength: 150,
41
+ style: "catchy, trending, short-form",
42
+ emojiSupport: true,
43
+ hashtagSupport: true,
44
+ imageSupport: false,
45
+ videoSupport: true,
46
+ maxHashtags: 5
47
+ },
48
+ facebook: {
49
+ maxLength: 63206,
50
+ style: "conversational, engaging, shareable",
51
+ emojiSupport: true,
52
+ hashtagSupport: true,
53
+ imageSupport: true,
54
+ videoSupport: true,
55
+ maxHashtags: 5
56
+ }
57
+ };
58
+
1
59
  // src/content/domain/calculations/ContentCreditCost.ts
2
60
  var CREDIT_COSTS = {
3
61
  "text-to-image": { standard: 1, hd: 2, "4k": 4 },
@@ -174,27 +232,407 @@ var AIError = class _AIError extends Error {
174
232
  metadata: this.metadata
175
233
  };
176
234
  }
177
- };
178
-
179
- // src/content/domain/errors/AIErrors.ts
180
- var ValidationError = class extends AIError {
181
- constructor(message) {
182
- super(message, "VALIDATION_ERROR");
183
- this.name = "ValidationError";
235
+ };
236
+
237
+ // src/content/domain/errors/AIErrors.ts
238
+ var ValidationError = class extends AIError {
239
+ constructor(message) {
240
+ super(message, "VALIDATION_ERROR");
241
+ this.name = "ValidationError";
242
+ }
243
+ };
244
+ var ProviderUnavailableError = class extends AIError {
245
+ constructor(providerId) {
246
+ super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
247
+ this.name = "ProviderUnavailableError";
248
+ }
249
+ };
250
+ var ProviderQuotaExhaustedError = class extends AIError {
251
+ constructor(providerId) {
252
+ super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
253
+ this.name = "ProviderQuotaExhaustedError";
254
+ }
255
+ };
256
+
257
+ // src/content/domain/limits/ValidationLimits.ts
258
+ var ValidationLimits = {
259
+ TOPIC: {
260
+ MIN: 1,
261
+ MAX: 500
262
+ },
263
+ CONTENT: {
264
+ MIN: 1,
265
+ MAX: 1e4
266
+ },
267
+ KEYWORD: {
268
+ MAX_COUNT: 20,
269
+ MAX_LENGTH: 50
270
+ },
271
+ DURATION_SECONDS: {
272
+ MIN: 10,
273
+ MAX: 600
274
+ },
275
+ CALENDAR_DAYS: {
276
+ MIN: 1,
277
+ MAX: 90
278
+ },
279
+ HASHTAG_COUNT: {
280
+ MIN: 1,
281
+ MAX: 50
282
+ },
283
+ SEO_CONTENT_PREVIEW: 500,
284
+ BLOG_PROMPT_PREVIEW: 1e3,
285
+ AB_VARIANT_CONTENT_PREVIEW: 200
286
+ };
287
+
288
+ // src/content/domain/limits/SpeechPaceConfig.ts
289
+ var SpeechPaceConfig = {
290
+ WORDS_PER_SECOND: 2.5,
291
+ TOKENS_PER_SECOND: 10,
292
+ JSON_TOKEN_OVERHEAD: 500,
293
+ TOKENS_PER_CALENDAR_DAY: 150
294
+ };
295
+
296
+ // src/content/domain/limits/ProviderTimingConfig.ts
297
+ var ProviderTimingConfig = {
298
+ DEFAULT_TIMEOUT_MS: 3e4,
299
+ DEFAULT_RETRY_ATTEMPTS: 3,
300
+ FAL_TIMEOUT_MS: 12e4,
301
+ FAL_RETRY_ATTEMPTS: 2,
302
+ GEMINI_TIMEOUT_MS: 6e4,
303
+ GEMINI_RETRY_ATTEMPTS: 3,
304
+ GROQ_TIMEOUT_MS: 3e4,
305
+ GROQ_RETRY_ATTEMPTS: 3,
306
+ HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
307
+ RETRY_BACKOFF_BASE_MS: 1e3
308
+ };
309
+
310
+ // src/content/domain/limits/ModelDefaults.ts
311
+ var ModelDefaults = {
312
+ GROQ_TEXT: "llama-3.1-8b-instant",
313
+ GROQ_CHAT: "llama-3.1-8b-instant",
314
+ FAL_IMAGE: "fal-ai/flux/schnell",
315
+ FAL_VIDEO: "fal-ai/hunyuan-video/1",
316
+ FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
317
+ GEMINI_TEXT: "gemini-2.0-flash",
318
+ GEMINI_IMAGE: "imagen-4.0-generate-001",
319
+ PRUNA_IMAGE: "p-image",
320
+ PRUNA_IMAGE_EDIT: "p-image-edit",
321
+ PRUNA_VIDEO: "p-video"
322
+ };
323
+ var TextModelDefaults = {
324
+ TEXT_MODEL: "claude-sonnet-4-20250514",
325
+ MAX_TOKENS: 4096,
326
+ DEFAULT_TEMPERATURE: 0.7,
327
+ DEFAULT_TOP_P: 0.9
328
+ };
329
+
330
+ // src/content/domain/limits/RequestQueueConfig.ts
331
+ var RequestQueueConfig = {
332
+ MAX_CONCURRENT: 3,
333
+ MAX_QUEUE_SIZE: 50,
334
+ DEFAULT_TIMEOUT_MS: 3e4,
335
+ RETRY_DELAY_MS: 1e3,
336
+ RATE_LIMIT: {
337
+ ENABLED: true,
338
+ WINDOW_MS: 6e4,
339
+ MAX_REQUESTS_PER_WINDOW: 100
340
+ },
341
+ POLL_INTERVAL_MS: 100
342
+ };
343
+
344
+ // src/content/domain/limits/MemoryConfig.ts
345
+ var MemoryConfig = {
346
+ MANAGER: {
347
+ MAX_SIZE_BYTES: 50 * 1024 * 1024,
348
+ CLEANUP_THRESHOLD_RATIO: 0.8,
349
+ RETENTION_RATIO: 0.5
350
+ },
351
+ POOL: {
352
+ DEFAULT_MAX_SIZE: 100
353
+ },
354
+ EXPIRING_CACHE: {
355
+ DEFAULT_TTL_MS: 6e4,
356
+ CLEANUP_INTERVAL_MS: 6e4
357
+ }
358
+ };
359
+
360
+ // src/content/domain/calculations/SpeechPaceEstimate.ts
361
+ function estimateWordCountForDuration(durationSeconds) {
362
+ return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
363
+ }
364
+ function estimateTokenBudgetForDuration(durationSeconds) {
365
+ return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
366
+ }
367
+ function estimateTokenBudgetForCalendarDays(days) {
368
+ return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
369
+ }
370
+
371
+ // src/content/domain/calculations/SeoKeywordDensity.ts
372
+ function countKeywordOccurrences(content, keyword) {
373
+ if (!keyword) return 0;
374
+ const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
375
+ const matches = content.match(new RegExp(escaped, "gi"));
376
+ return matches ? matches.length : 0;
377
+ }
378
+ function countWordsInContent(content) {
379
+ const tokens = content.split(/\s+/).filter(Boolean);
380
+ return tokens.length || 1;
381
+ }
382
+ function calculateKeywordDensity(content, keyword) {
383
+ const totalWords = countWordsInContent(content);
384
+ const occurrences = countKeywordOccurrences(content, keyword);
385
+ return occurrences / totalWords * 100;
386
+ }
387
+
388
+ // src/content/domain/calculations/AbTestImprovementRatio.ts
389
+ function calculateImprovementPercentage(scoreA, scoreB) {
390
+ const higher = Math.max(scoreA, scoreB);
391
+ const lower = Math.min(scoreA, scoreB);
392
+ if (lower <= 0) {
393
+ return "100";
394
+ }
395
+ const delta = (higher / lower - 1) * 100;
396
+ return Math.abs(delta).toFixed(0);
397
+ }
398
+ function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
399
+ return scoreA > scoreB ? idA : idB;
400
+ }
401
+
402
+ // src/content/domain/calculations/RetryBackoffDelay.ts
403
+ function calculateRetryBackoffDelayMs(attemptIndex) {
404
+ return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
405
+ }
406
+
407
+ // src/content/domain/calculations/ContentCalendarDateOffset.ts
408
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
409
+ function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
410
+ return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
411
+ }
412
+
413
+ // src/content/domain/calculations/DefaultModelSelection.ts
414
+ function resolveDefaultPrunaModel(generationType) {
415
+ switch (generationType) {
416
+ case "image-to-image":
417
+ return ModelDefaults.PRUNA_IMAGE_EDIT;
418
+ case "image-to-video":
419
+ return ModelDefaults.PRUNA_VIDEO;
420
+ case "text-to-image":
421
+ return ModelDefaults.PRUNA_IMAGE;
422
+ case "text-to-video":
423
+ return ModelDefaults.PRUNA_VIDEO;
424
+ }
425
+ }
426
+
427
+ // src/content/domain/predicates/KeywordProminenceClassifier.ts
428
+ var HIGH_DENSITY_THRESHOLD = 2;
429
+ var MEDIUM_DENSITY_THRESHOLD = 1;
430
+ function classifyKeywordProminence(densityPercent) {
431
+ if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
432
+ if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
433
+ return "low";
434
+ }
435
+ function isUnderutilizedKeyword(densityPercent) {
436
+ return densityPercent < 1;
437
+ }
438
+
439
+ // src/content/domain/predicates/HashtagPriorityRanker.ts
440
+ var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
441
+ function resolveHashtagBudget(platform) {
442
+ return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
443
+ }
444
+ function rankAndTrimHashtags(hashtags, budget) {
445
+ if (hashtags.length <= budget) return [...hashtags];
446
+ return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
447
+ }
448
+
449
+ // src/content/domain/predicates/PlatformSpecResolver.ts
450
+ var FALLBACK_SPEC = {
451
+ maxLength: 280,
452
+ style: "concise, engaging, audience-friendly",
453
+ emojiSupport: true,
454
+ hashtagSupport: true,
455
+ imageSupport: true,
456
+ videoSupport: true,
457
+ maxHashtags: 5
458
+ };
459
+ function resolvePlatformSpec(platform) {
460
+ return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
461
+ }
462
+ function resolveMaxContentLength(platform, override) {
463
+ return override ?? resolvePlatformSpec(platform).maxLength;
464
+ }
465
+
466
+ // src/content/domain/predicates/ScoreRangeGuard.ts
467
+ var SCORE_MIN = 0;
468
+ var SCORE_MAX = 100;
469
+ var SCORE_FALLBACK = 50;
470
+ var CONFIDENCE_MIN = 0;
471
+ var CONFIDENCE_MAX = 1;
472
+ var CONFIDENCE_FALLBACK = 0.5;
473
+ function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
474
+ if (!Number.isFinite(score)) return fallback;
475
+ return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
476
+ }
477
+ function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
478
+ if (!Number.isFinite(confidence)) return fallback;
479
+ return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
480
+ }
481
+
482
+ // src/content/domain/predicates/AbTestConfidence.ts
483
+ var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
484
+
485
+ // src/content/domain/predicates/ProviderCostEstimator.ts
486
+ var FAL_FIXED_COST = 1;
487
+ var GROQ_FREE_TIER_COST = 0;
488
+ var GEMINI_IMAGE_COST = 0.02;
489
+ var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
490
+ var PRUNA_FIXED_COST = 1;
491
+ var UNKNOWN_PROVIDER_COST = 0;
492
+ function estimateGroqGenerationCost(_request) {
493
+ return GROQ_FREE_TIER_COST;
494
+ }
495
+ function estimateFalGenerationCost(_request) {
496
+ return FAL_FIXED_COST;
497
+ }
498
+ function estimateGeminiGenerationCost(request) {
499
+ if (request.type === "image") return GEMINI_IMAGE_COST;
500
+ return GEMINI_TEXT_PER_1K_CHARS_COST;
501
+ }
502
+ function estimatePrunaGenerationCost() {
503
+ return PRUNA_FIXED_COST;
504
+ }
505
+ function estimateUnknownProviderCost() {
506
+ return UNKNOWN_PROVIDER_COST;
507
+ }
508
+
509
+ // src/content/domain/predicates/FalImageRenderingOptions.ts
510
+ var FAL_FORMAT_TO_IMAGE_SIZE = {
511
+ square: "square_hd",
512
+ landscape: "landscape_16_9",
513
+ portrait: "portrait_9_16",
514
+ story: "portrait_9_16",
515
+ banner: "landscape_16_9"
516
+ };
517
+ var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
518
+ var FAL_QUALITY_TO_STEPS = {
519
+ standard: 4,
520
+ high: 6,
521
+ ultra: 8
522
+ };
523
+ var FAL_DEFAULT_QUALITY_STEPS = 6;
524
+ function resolveFalImageSize(format) {
525
+ if (!format) return FAL_DEFAULT_IMAGE_SIZE;
526
+ return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
527
+ }
528
+ function resolveFalInferenceSteps(quality) {
529
+ if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
530
+ return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
531
+ }
532
+
533
+ // src/content/domain/validation/TopicTextValidator.ts
534
+ function validateTopicText(topic) {
535
+ if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
536
+ throw new ValidationError("Topic cannot be empty");
537
+ }
538
+ const trimmed = topic.trim();
539
+ if (trimmed.length > ValidationLimits.TOPIC.MAX) {
540
+ throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
541
+ }
542
+ return trimmed;
543
+ }
544
+
545
+ // src/content/domain/validation/ContentBodyValidator.ts
546
+ function validateContentBody(content) {
547
+ if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
548
+ throw new ValidationError("Content cannot be empty");
549
+ }
550
+ const trimmed = content.trim();
551
+ if (trimmed.length > ValidationLimits.CONTENT.MAX) {
552
+ throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
553
+ }
554
+ return trimmed;
555
+ }
556
+ function truncateForSeoPreview(content) {
557
+ return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
558
+ }
559
+ function truncateForBlogPromptPreview(content) {
560
+ return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
561
+ }
562
+ function truncateForAbVariantPreview(content) {
563
+ return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
564
+ }
565
+
566
+ // src/content/domain/validation/KeywordListValidator.ts
567
+ function validateKeywordList(keywords) {
568
+ if (!Array.isArray(keywords)) {
569
+ throw new ValidationError("Keywords must be an array");
570
+ }
571
+ if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
572
+ throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
573
+ }
574
+ return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
575
+ const trimmed = keyword.trim();
576
+ if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
577
+ const preview = trimmed.substring(0, 20);
578
+ throw new ValidationError(
579
+ `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
580
+ );
581
+ }
582
+ return trimmed;
583
+ });
584
+ }
585
+
586
+ // src/content/domain/validation/DurationSecondsValidator.ts
587
+ function validateDurationSeconds(duration) {
588
+ if (!Number.isFinite(duration)) {
589
+ throw new ValidationError(
590
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
591
+ );
592
+ }
593
+ if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
594
+ throw new ValidationError(
595
+ `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
596
+ );
597
+ }
598
+ return duration;
599
+ }
600
+
601
+ // src/content/domain/validation/CalendarDaysValidator.ts
602
+ function validateCalendarDays(days) {
603
+ if (!Number.isFinite(days)) {
604
+ throw new ValidationError(
605
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
606
+ );
607
+ }
608
+ if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
609
+ throw new ValidationError(
610
+ `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
611
+ );
184
612
  }
185
- };
186
- var ProviderUnavailableError = class extends AIError {
187
- constructor(providerId) {
188
- super(`Provider ${providerId} is not available`, "PROVIDER_UNAVAILABLE");
189
- this.name = "ProviderUnavailableError";
613
+ return days;
614
+ }
615
+
616
+ // src/content/domain/validation/HashtagCountValidator.ts
617
+ function validateHashtagCount(count) {
618
+ if (!Number.isFinite(count)) {
619
+ throw new ValidationError(
620
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
621
+ );
190
622
  }
191
- };
192
- var ProviderQuotaExhaustedError = class extends AIError {
193
- constructor(providerId) {
194
- super(`Provider ${providerId} quota exhausted`, "PROVIDER_QUOTA_EXHAUSTED");
195
- this.name = "ProviderQuotaExhaustedError";
623
+ if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
624
+ throw new ValidationError(
625
+ `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
626
+ );
196
627
  }
197
- };
628
+ return Math.floor(count);
629
+ }
630
+
631
+ // src/content/domain/utils/IdGenerator.ts
632
+ function generateId(prefix) {
633
+ const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
634
+ return prefix ? `${prefix}-${id}` : id;
635
+ }
198
636
 
199
637
  // src/core/errors/groq-error.ts
200
638
  var GroqError = class extends AIError {
@@ -263,18 +701,6 @@ function isTextProvider(provider) {
263
701
  return provider.capabilities.includes("text");
264
702
  }
265
703
 
266
- // src/content/domain/limits/ProviderTimingConfig.ts
267
- var ProviderTimingConfig = {
268
- DEFAULT_TIMEOUT_MS: 3e4,
269
- DEFAULT_RETRY_ATTEMPTS: 3,
270
- FAL_TIMEOUT_MS: 12e4,
271
- FAL_RETRY_ATTEMPTS: 2,
272
- GEMINI_TIMEOUT_MS: 6e4,
273
- GEMINI_RETRY_ATTEMPTS: 3,
274
- HEALTH_CHECK_TTL_MS: 5 * 60 * 1e3,
275
- RETRY_BACKOFF_BASE_MS: 1e3
276
- };
277
-
278
704
  // src/providers/factory/provider.factory.ts
279
705
  var ProviderFactory = class {
280
706
  providers = /* @__PURE__ */ new Map();
@@ -2048,11 +2474,6 @@ function findLastIndex2(items, predicate) {
2048
2474
  return -1;
2049
2475
  }
2050
2476
 
2051
- // src/content/domain/calculations/RetryBackoffDelay.ts
2052
- function calculateRetryBackoffDelayMs(attemptIndex) {
2053
- return ProviderTimingConfig.RETRY_BACKOFF_BASE_MS * Math.pow(2, attemptIndex);
2054
- }
2055
-
2056
2477
  // src/providers/base/base.provider.ts
2057
2478
  var BaseProvider = class {
2058
2479
  config;
@@ -2101,26 +2522,6 @@ var BaseProvider = class {
2101
2522
  }
2102
2523
  };
2103
2524
 
2104
- // src/content/domain/predicates/ProviderCostEstimator.ts
2105
- var FAL_FIXED_COST = 1;
2106
- var GEMINI_IMAGE_COST = 0.02;
2107
- var GEMINI_TEXT_PER_1K_CHARS_COST = 1e-4;
2108
- function estimateFalGenerationCost(_request) {
2109
- return FAL_FIXED_COST;
2110
- }
2111
- function estimateGeminiGenerationCost(request) {
2112
- if (request.type === "image") return GEMINI_IMAGE_COST;
2113
- return GEMINI_TEXT_PER_1K_CHARS_COST;
2114
- }
2115
-
2116
- // src/content/domain/limits/ModelDefaults.ts
2117
- var ModelDefaults = {
2118
- FAL_IMAGE: "fal-ai/flux/schnell",
2119
- FAL_VIDEO: "fal-ai/hunyuan-video/1",
2120
- FAL_IMAGE_TO_VIDEO: "fal-ai/fast-animatediff/image-to-video",
2121
- GEMINI_TEXT: "gemini-2.0-flash",
2122
- GEMINI_IMAGE: "imagen-4.0-generate-001"};
2123
-
2124
2525
  // src/providers/gemini/gemini.provider.ts
2125
2526
  var GEMINI_TIERS = {
2126
2527
  fast: "gemini-2.0-flash-lite",
@@ -2357,146 +2758,6 @@ function findLastIndex3(items, predicate) {
2357
2758
  return -1;
2358
2759
  }
2359
2760
 
2360
- // src/content/domain/predicates/KeywordProminenceClassifier.ts
2361
- var HIGH_DENSITY_THRESHOLD = 2;
2362
- var MEDIUM_DENSITY_THRESHOLD = 1;
2363
- function classifyKeywordProminence(densityPercent) {
2364
- if (densityPercent > HIGH_DENSITY_THRESHOLD) return "high";
2365
- if (densityPercent > MEDIUM_DENSITY_THRESHOLD) return "medium";
2366
- return "low";
2367
- }
2368
- function isUnderutilizedKeyword(densityPercent) {
2369
- return densityPercent < 1;
2370
- }
2371
-
2372
- // src/content/domain/types/index.ts
2373
- var PLATFORM_SPECS = {
2374
- twitter: {
2375
- maxLength: 280,
2376
- style: "concise, engaging, thread-friendly",
2377
- emojiSupport: true,
2378
- hashtagSupport: true,
2379
- imageSupport: true,
2380
- videoSupport: true,
2381
- maxHashtags: 5
2382
- },
2383
- linkedin: {
2384
- maxLength: 3e3,
2385
- style: "professional, insightful, industry-focused",
2386
- emojiSupport: true,
2387
- hashtagSupport: true,
2388
- imageSupport: true,
2389
- videoSupport: true,
2390
- maxHashtags: 5
2391
- },
2392
- instagram: {
2393
- maxLength: 2200,
2394
- style: "visual, engaging, emoji-rich",
2395
- emojiSupport: true,
2396
- hashtagSupport: true,
2397
- imageSupport: true,
2398
- videoSupport: true,
2399
- maxHashtags: 30
2400
- },
2401
- threads: {
2402
- maxLength: 500,
2403
- style: "conversational, community-driven",
2404
- emojiSupport: true,
2405
- hashtagSupport: true,
2406
- imageSupport: true,
2407
- videoSupport: true,
2408
- maxHashtags: 5
2409
- },
2410
- tiktok: {
2411
- maxLength: 150,
2412
- style: "catchy, trending, short-form",
2413
- emojiSupport: true,
2414
- hashtagSupport: true,
2415
- imageSupport: false,
2416
- videoSupport: true,
2417
- maxHashtags: 5
2418
- },
2419
- facebook: {
2420
- maxLength: 63206,
2421
- style: "conversational, engaging, shareable",
2422
- emojiSupport: true,
2423
- hashtagSupport: true,
2424
- imageSupport: true,
2425
- videoSupport: true,
2426
- maxHashtags: 5
2427
- }
2428
- };
2429
-
2430
- // src/content/domain/predicates/HashtagPriorityRanker.ts
2431
- var DEFAULT_HASHTAG_BUDGET = Number.MAX_SAFE_INTEGER;
2432
- function resolveHashtagBudget(platform) {
2433
- return PLATFORM_SPECS[platform]?.maxHashtags ?? DEFAULT_HASHTAG_BUDGET;
2434
- }
2435
- function rankAndTrimHashtags(hashtags, budget) {
2436
- if (hashtags.length <= budget) return [...hashtags];
2437
- return [...hashtags].sort((a, b) => b.length - a.length).slice(0, budget);
2438
- }
2439
-
2440
- // src/content/domain/predicates/PlatformSpecResolver.ts
2441
- var FALLBACK_SPEC = {
2442
- maxLength: 280,
2443
- style: "concise, engaging, audience-friendly",
2444
- emojiSupport: true,
2445
- hashtagSupport: true,
2446
- imageSupport: true,
2447
- videoSupport: true,
2448
- maxHashtags: 5
2449
- };
2450
- function resolvePlatformSpec(platform) {
2451
- return PLATFORM_SPECS[platform] ?? FALLBACK_SPEC;
2452
- }
2453
- function resolveMaxContentLength(platform, override) {
2454
- return override ?? resolvePlatformSpec(platform).maxLength;
2455
- }
2456
-
2457
- // src/content/domain/predicates/ScoreRangeGuard.ts
2458
- var SCORE_MIN = 0;
2459
- var SCORE_MAX = 100;
2460
- var SCORE_FALLBACK = 50;
2461
- var CONFIDENCE_MIN = 0;
2462
- var CONFIDENCE_MAX = 1;
2463
- var CONFIDENCE_FALLBACK = 0.5;
2464
- function clampScoreToValidRange(score, fallback = SCORE_FALLBACK) {
2465
- if (!Number.isFinite(score)) return fallback;
2466
- return Math.max(SCORE_MIN, Math.min(SCORE_MAX, score));
2467
- }
2468
- function clampConfidenceToValidRange(confidence, fallback = CONFIDENCE_FALLBACK) {
2469
- if (!Number.isFinite(confidence)) return fallback;
2470
- return Math.max(CONFIDENCE_MIN, Math.min(CONFIDENCE_MAX, confidence));
2471
- }
2472
-
2473
- // src/content/domain/predicates/AbTestConfidence.ts
2474
- var AB_TEST_DEFAULT_CONFIDENCE = 0.7;
2475
-
2476
- // src/content/domain/predicates/FalImageRenderingOptions.ts
2477
- var FAL_FORMAT_TO_IMAGE_SIZE = {
2478
- square: "square_hd",
2479
- landscape: "landscape_16_9",
2480
- portrait: "portrait_9_16",
2481
- story: "portrait_9_16",
2482
- banner: "landscape_16_9"
2483
- };
2484
- var FAL_DEFAULT_IMAGE_SIZE = "square_hd";
2485
- var FAL_QUALITY_TO_STEPS = {
2486
- standard: 4,
2487
- high: 6,
2488
- ultra: 8
2489
- };
2490
- var FAL_DEFAULT_QUALITY_STEPS = 6;
2491
- function resolveFalImageSize(format) {
2492
- if (!format) return FAL_DEFAULT_IMAGE_SIZE;
2493
- return FAL_FORMAT_TO_IMAGE_SIZE[format] ?? FAL_DEFAULT_IMAGE_SIZE;
2494
- }
2495
- function resolveFalInferenceSteps(quality) {
2496
- if (!quality) return FAL_DEFAULT_QUALITY_STEPS;
2497
- return FAL_QUALITY_TO_STEPS[quality] ?? FAL_DEFAULT_QUALITY_STEPS;
2498
- }
2499
-
2500
2761
  // src/providers/fal/fal.provider.ts
2501
2762
  var FalProvider = class extends BaseProvider {
2502
2763
  id = "fal";
@@ -3563,39 +3824,20 @@ function createAI(config = {}) {
3563
3824
  });
3564
3825
  if (config.anthropic?.apiKey) {
3565
3826
  factory.register(new AnthropicProvider(config.anthropic));
3566
- }
3567
- if (config.groq?.apiKey) {
3568
- factory.register(new GroqProvider(config.groq));
3569
- }
3570
- if (config.gemini?.apiKey) {
3571
- factory.register(new GeminiProvider({ ...config.gemini, enabled: true }));
3572
- }
3573
- if (config.fal?.apiKey) {
3574
- factory.register(new FalProvider({ ...config.fal, enabled: true }));
3575
- }
3576
- if (config.pruna?.apiKey) {
3577
- factory.register(new PrunaProvider({ ...config.pruna, enabled: true }));
3578
- }
3579
- return factory;
3580
- }
3581
-
3582
- // src/content/domain/limits/SpeechPaceConfig.ts
3583
- var SpeechPaceConfig = {
3584
- WORDS_PER_SECOND: 2.5,
3585
- TOKENS_PER_SECOND: 10,
3586
- JSON_TOKEN_OVERHEAD: 500,
3587
- TOKENS_PER_CALENDAR_DAY: 150
3588
- };
3589
-
3590
- // src/content/domain/calculations/SpeechPaceEstimate.ts
3591
- function estimateWordCountForDuration(durationSeconds) {
3592
- return Math.floor(durationSeconds * SpeechPaceConfig.WORDS_PER_SECOND);
3593
- }
3594
- function estimateTokenBudgetForDuration(durationSeconds) {
3595
- return durationSeconds * SpeechPaceConfig.TOKENS_PER_SECOND + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3596
- }
3597
- function estimateTokenBudgetForCalendarDays(days) {
3598
- return days * SpeechPaceConfig.TOKENS_PER_CALENDAR_DAY + SpeechPaceConfig.JSON_TOKEN_OVERHEAD;
3827
+ }
3828
+ if (config.groq?.apiKey) {
3829
+ factory.register(new GroqProvider(config.groq));
3830
+ }
3831
+ if (config.gemini?.apiKey) {
3832
+ factory.register(new GeminiProvider({ ...config.gemini, enabled: true }));
3833
+ }
3834
+ if (config.fal?.apiKey) {
3835
+ factory.register(new FalProvider({ ...config.fal, enabled: true }));
3836
+ }
3837
+ if (config.pruna?.apiKey) {
3838
+ factory.register(new PrunaProvider({ ...config.pruna, enabled: true }));
3839
+ }
3840
+ return factory;
3599
3841
  }
3600
3842
 
3601
3843
  // src/content/application/prompts/PromptBuilder.ts
@@ -3908,75 +4150,6 @@ Return only the JSON:
3908
4150
  }
3909
4151
  };
3910
4152
 
3911
- // src/content/domain/limits/ValidationLimits.ts
3912
- var ValidationLimits = {
3913
- TOPIC: {
3914
- MIN: 1,
3915
- MAX: 500
3916
- },
3917
- CONTENT: {
3918
- MIN: 1,
3919
- MAX: 1e4
3920
- },
3921
- KEYWORD: {
3922
- MAX_COUNT: 20,
3923
- MAX_LENGTH: 50
3924
- },
3925
- DURATION_SECONDS: {
3926
- MIN: 10,
3927
- MAX: 600
3928
- },
3929
- CALENDAR_DAYS: {
3930
- MIN: 1,
3931
- MAX: 90
3932
- },
3933
- HASHTAG_COUNT: {
3934
- MIN: 1,
3935
- MAX: 50
3936
- },
3937
- SEO_CONTENT_PREVIEW: 500,
3938
- BLOG_PROMPT_PREVIEW: 1e3,
3939
- AB_VARIANT_CONTENT_PREVIEW: 200
3940
- };
3941
-
3942
- // src/content/domain/validation/TopicTextValidator.ts
3943
- function validateTopicText(topic) {
3944
- if (typeof topic !== "string" || topic.trim().length < ValidationLimits.TOPIC.MIN) {
3945
- throw new ValidationError("Topic cannot be empty");
3946
- }
3947
- const trimmed = topic.trim();
3948
- if (trimmed.length > ValidationLimits.TOPIC.MAX) {
3949
- throw new ValidationError(`Topic exceeds maximum length of ${ValidationLimits.TOPIC.MAX} characters`);
3950
- }
3951
- return trimmed;
3952
- }
3953
-
3954
- // src/content/domain/validation/KeywordListValidator.ts
3955
- function validateKeywordList(keywords) {
3956
- if (!Array.isArray(keywords)) {
3957
- throw new ValidationError("Keywords must be an array");
3958
- }
3959
- if (keywords.length > ValidationLimits.KEYWORD.MAX_COUNT) {
3960
- throw new ValidationError(`Cannot process more than ${ValidationLimits.KEYWORD.MAX_COUNT} keywords`);
3961
- }
3962
- return keywords.filter((k) => typeof k === "string" && k.trim().length > 0).map((keyword) => {
3963
- const trimmed = keyword.trim();
3964
- if (trimmed.length > ValidationLimits.KEYWORD.MAX_LENGTH) {
3965
- const preview = trimmed.substring(0, 20);
3966
- throw new ValidationError(
3967
- `Keyword "${preview}..." exceeds maximum length of ${ValidationLimits.KEYWORD.MAX_LENGTH} characters`
3968
- );
3969
- }
3970
- return trimmed;
3971
- });
3972
- }
3973
-
3974
- // src/content/domain/utils/IdGenerator.ts
3975
- function generateId(prefix) {
3976
- const id = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 11)}`;
3977
- return prefix ? `${prefix}-${id}` : id;
3978
- }
3979
-
3980
4153
  // src/content/application/services/BlogService.ts
3981
4154
  var BlogService = class {
3982
4155
  constructor(executor) {
@@ -4013,6 +4186,17 @@ var BlogService = class {
4013
4186
  };
4014
4187
  }
4015
4188
  };
4189
+
4190
+ // src/content/infrastructure/utils/requestQueue.ts
4191
+ ({
4192
+ maxConcurrent: RequestQueueConfig.MAX_CONCURRENT,
4193
+ maxQueueSize: RequestQueueConfig.MAX_QUEUE_SIZE,
4194
+ defaultTimeout: RequestQueueConfig.DEFAULT_TIMEOUT_MS,
4195
+ retryDelay: RequestQueueConfig.RETRY_DELAY_MS,
4196
+ enableRateLimit: RequestQueueConfig.RATE_LIMIT.ENABLED,
4197
+ rateLimitWindow: RequestQueueConfig.RATE_LIMIT.WINDOW_MS,
4198
+ rateLimitMaxRequests: RequestQueueConfig.RATE_LIMIT.MAX_REQUESTS_PER_WINDOW
4199
+ });
4016
4200
  async function batchRequest(requests, options = {}) {
4017
4201
  const {
4018
4202
  concurrency = 3,
@@ -4044,21 +4228,6 @@ async function batchRequest(requests, options = {}) {
4044
4228
  return results;
4045
4229
  }
4046
4230
 
4047
- // src/content/domain/validation/HashtagCountValidator.ts
4048
- function validateHashtagCount(count) {
4049
- if (!Number.isFinite(count)) {
4050
- throw new ValidationError(
4051
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4052
- );
4053
- }
4054
- if (count < ValidationLimits.HASHTAG_COUNT.MIN || count > ValidationLimits.HASHTAG_COUNT.MAX) {
4055
- throw new ValidationError(
4056
- `Hashtag count must be between ${ValidationLimits.HASHTAG_COUNT.MIN} and ${ValidationLimits.HASHTAG_COUNT.MAX}`
4057
- );
4058
- }
4059
- return Math.floor(count);
4060
- }
4061
-
4062
4231
  // src/content/application/services/SocialService.ts
4063
4232
  var MULTI_PLATFORMS = [
4064
4233
  "twitter",
@@ -4136,21 +4305,6 @@ var SocialService = class {
4136
4305
  }
4137
4306
  };
4138
4307
 
4139
- // src/content/domain/validation/DurationSecondsValidator.ts
4140
- function validateDurationSeconds(duration) {
4141
- if (!Number.isFinite(duration)) {
4142
- throw new ValidationError(
4143
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4144
- );
4145
- }
4146
- if (duration < ValidationLimits.DURATION_SECONDS.MIN || duration > ValidationLimits.DURATION_SECONDS.MAX) {
4147
- throw new ValidationError(
4148
- `Duration must be between ${ValidationLimits.DURATION_SECONDS.MIN} and ${ValidationLimits.DURATION_SECONDS.MAX} seconds`
4149
- );
4150
- }
4151
- return duration;
4152
- }
4153
-
4154
4308
  // src/content/application/services/VideoScriptService.ts
4155
4309
  var buildScriptResult = (parsed, duration) => {
4156
4310
  const script = parsed.script ?? "";
@@ -4205,27 +4359,6 @@ var VideoScriptService = class {
4205
4359
  }
4206
4360
  };
4207
4361
 
4208
- // src/content/domain/validation/ContentBodyValidator.ts
4209
- function validateContentBody(content) {
4210
- if (typeof content !== "string" || content.trim().length < ValidationLimits.CONTENT.MIN) {
4211
- throw new ValidationError("Content cannot be empty");
4212
- }
4213
- const trimmed = content.trim();
4214
- if (trimmed.length > ValidationLimits.CONTENT.MAX) {
4215
- throw new ValidationError(`Content exceeds maximum length of ${ValidationLimits.CONTENT.MAX} characters`);
4216
- }
4217
- return trimmed;
4218
- }
4219
- function truncateForSeoPreview(content) {
4220
- return content.substring(0, ValidationLimits.SEO_CONTENT_PREVIEW);
4221
- }
4222
- function truncateForBlogPromptPreview(content) {
4223
- return content.substring(0, ValidationLimits.BLOG_PROMPT_PREVIEW);
4224
- }
4225
- function truncateForAbVariantPreview(content) {
4226
- return content.substring(0, ValidationLimits.AB_VARIANT_CONTENT_PREVIEW);
4227
- }
4228
-
4229
4362
  // src/content/application/services/AnalysisService.ts
4230
4363
  var DEFAULT_SENTIMENT = {
4231
4364
  sentiment: "neutral",
@@ -4278,23 +4411,6 @@ var AnalysisService = class {
4278
4411
  }
4279
4412
  };
4280
4413
 
4281
- // src/content/domain/calculations/SeoKeywordDensity.ts
4282
- function countKeywordOccurrences(content, keyword) {
4283
- if (!keyword) return 0;
4284
- const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4285
- const matches = content.match(new RegExp(escaped, "gi"));
4286
- return matches ? matches.length : 0;
4287
- }
4288
- function countWordsInContent(content) {
4289
- const tokens = content.split(/\s+/).filter(Boolean);
4290
- return tokens.length || 1;
4291
- }
4292
- function calculateKeywordDensity(content, keyword) {
4293
- const totalWords = countWordsInContent(content);
4294
- const occurrences = countKeywordOccurrences(content, keyword);
4295
- return occurrences / totalWords * 100;
4296
- }
4297
-
4298
4414
  // src/content/application/services/SeoService.ts
4299
4415
  var DEFAULT_SEO_SCORE = {
4300
4416
  keywordDensity: 50,
@@ -4371,20 +4487,6 @@ var SeoService = class {
4371
4487
  }
4372
4488
  };
4373
4489
 
4374
- // src/content/domain/calculations/AbTestImprovementRatio.ts
4375
- function calculateImprovementPercentage(scoreA, scoreB) {
4376
- const higher = Math.max(scoreA, scoreB);
4377
- const lower = Math.min(scoreA, scoreB);
4378
- if (lower <= 0) {
4379
- return "100";
4380
- }
4381
- const delta = (higher / lower - 1) * 100;
4382
- return Math.abs(delta).toFixed(0);
4383
- }
4384
- function selectHigherScoreVariantId(scoreA, scoreB, idA = "A", idB = "B") {
4385
- return scoreA > scoreB ? idA : idB;
4386
- }
4387
-
4388
4490
  // src/content/application/services/ABTestService.ts
4389
4491
  var DEFAULT_PREDICTION = {
4390
4492
  variantId: "",
@@ -4486,27 +4588,6 @@ var ImagePromptService = class {
4486
4588
  }
4487
4589
  };
4488
4590
 
4489
- // src/content/domain/validation/CalendarDaysValidator.ts
4490
- function validateCalendarDays(days) {
4491
- if (!Number.isFinite(days)) {
4492
- throw new ValidationError(
4493
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4494
- );
4495
- }
4496
- if (days < ValidationLimits.CALENDAR_DAYS.MIN || days > ValidationLimits.CALENDAR_DAYS.MAX) {
4497
- throw new ValidationError(
4498
- `Days must be between ${ValidationLimits.CALENDAR_DAYS.MIN} and ${ValidationLimits.CALENDAR_DAYS.MAX}`
4499
- );
4500
- }
4501
- return days;
4502
- }
4503
-
4504
- // src/content/domain/calculations/ContentCalendarDateOffset.ts
4505
- var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
4506
- function resolveCalendarEntryDate(dayIndex, baseTimestamp = Date.now()) {
4507
- return new Date(baseTimestamp + (dayIndex - 1) * ONE_DAY_MS);
4508
- }
4509
-
4510
4591
  // src/content/application/services/ContentCalendarService.ts
4511
4592
  var toCalendarEntry = (item) => ({
4512
4593
  date: resolveCalendarEntryDate(item.day),
@@ -4817,6 +4898,226 @@ var AIContentService = class {
4817
4898
  }
4818
4899
  };
4819
4900
 
4820
- export { ABTestService, AIContentService, AIError, ASPECT_RATIO_OPTIONS, ASPECT_RATIO_VALUES, AnalysisService, BlogService, ContentCalendarService, CREDIT_COSTS as GENERATION_COSTS, GenerationExecutor, IMAGE_QUALITY_OPTIONS, IMAGE_QUALITY_VALUES, ImagePromptService, MOTION_OPTIONS, MediaGenerationService, PromptBuilder, ProviderQuotaExhaustedError, ProviderUnavailableError, STYLE_PRESETS, SeoService, SocialService, VIDEO_DURATION_OPTIONS, VIDEO_DURATION_OPTIONS_SECONDS, VIDEO_QUALITY_OPTIONS, VIDEO_QUALITY_VALUES, ValidationError, VideoScriptService, calculateContentCreditCost as calculateCreditCost, getDimensionsForAspectRatio, getRecommendedQuality };
4901
+ // src/wizard/content.wizard.ts
4902
+ var CONTENT_WIZARD_STEPS = [
4903
+ {
4904
+ id: "select-type",
4905
+ label: "Select Type",
4906
+ icon: "Layers",
4907
+ description: "Choose the type of content you want to generate",
4908
+ validate: (data) => Boolean(data.contentType)
4909
+ },
4910
+ {
4911
+ id: "input-topic",
4912
+ label: "Topic",
4913
+ icon: "Lightbulb",
4914
+ description: "Enter your topic or idea",
4915
+ validate: (data) => {
4916
+ const topic = data.topic;
4917
+ return typeof topic === "string" && topic.length > 0;
4918
+ }
4919
+ },
4920
+ {
4921
+ id: "configure",
4922
+ label: "Configure",
4923
+ icon: "Settings",
4924
+ description: "Set tone, audience, and platform",
4925
+ validate: (data) => {
4926
+ const d = data;
4927
+ return Boolean(d.tone && d.targetAudience);
4928
+ }
4929
+ },
4930
+ {
4931
+ id: "advanced",
4932
+ label: "Advanced",
4933
+ icon: "Sliders",
4934
+ description: "Additional options and optimizations",
4935
+ optional: true
4936
+ },
4937
+ {
4938
+ id: "preview",
4939
+ label: "Preview",
4940
+ icon: "Eye",
4941
+ description: "Review your settings before generation"
4942
+ },
4943
+ {
4944
+ id: "generating",
4945
+ label: "Generating",
4946
+ icon: "Sparkles",
4947
+ description: "AI is generating your content"
4948
+ },
4949
+ {
4950
+ id: "results",
4951
+ label: "Results",
4952
+ icon: "CheckCircle",
4953
+ description: "Your generated content is ready"
4954
+ }
4955
+ ];
4956
+ function buildContentRequest(data) {
4957
+ switch (data.contentType) {
4958
+ case "blog":
4959
+ return {
4960
+ topic: data.topic ?? "",
4961
+ blogType: "tutorial",
4962
+ targetKeywords: data.keywords ?? [],
4963
+ tone: data.tone ?? "professional",
4964
+ wordCount: data.wordCount ?? 1e3,
4965
+ targetAudience: data.targetAudience ?? "",
4966
+ seoOptimization: data.seoOptimization ?? false,
4967
+ includeImages: data.includeImages ?? false,
4968
+ includeSchema: false
4969
+ };
4970
+ case "social":
4971
+ return {
4972
+ topic: data.topic ?? "",
4973
+ platform: data.platform ?? "twitter",
4974
+ tone: data.tone ?? "casual",
4975
+ hashtags: true,
4976
+ targetAudience: data.targetAudience,
4977
+ includeCallToAction: data.includeCallToAction
4978
+ };
4979
+ case "script":
4980
+ return {
4981
+ topic: data.topic ?? "",
4982
+ tone: data.tone ?? "professional",
4983
+ duration: data.duration ?? 60,
4984
+ targetAudience: data.targetAudience ?? "",
4985
+ includeVisuals: true,
4986
+ includeCallToAction: data.includeCallToAction ?? false
4987
+ };
4988
+ default:
4989
+ throw new Error(`Unsupported content type: ${data.contentType}`);
4990
+ }
4991
+ }
4992
+
4993
+ // src/wizard/image.wizard.ts
4994
+ var IMAGE_WIZARD_STEPS = [
4995
+ {
4996
+ id: "input-prompt",
4997
+ label: "Describe Image",
4998
+ icon: "Image",
4999
+ description: "Describe the image you want to create",
5000
+ validate: (data) => {
5001
+ const prompt = data.prompt;
5002
+ return typeof prompt === "string" && prompt.length > 0;
5003
+ }
5004
+ },
5005
+ {
5006
+ id: "select-style",
5007
+ label: "Style",
5008
+ icon: "Palette",
5009
+ description: "Choose the artistic style",
5010
+ validate: (data) => Boolean(data.style)
5011
+ },
5012
+ {
5013
+ id: "configure",
5014
+ label: "Configure",
5015
+ icon: "Settings",
5016
+ description: "Set format, quality, and quantity",
5017
+ validate: (data) => {
5018
+ const d = data;
5019
+ return Boolean(d.format && d.quality);
5020
+ }
5021
+ },
5022
+ {
5023
+ id: "advanced",
5024
+ label: "Advanced",
5025
+ icon: "Sliders",
5026
+ description: "Color palette and platform optimization",
5027
+ optional: true
5028
+ },
5029
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5030
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your image" },
5031
+ { id: "results", label: "Results", icon: "Image", description: "Your generated image is ready" }
5032
+ ];
5033
+ function buildImageRequest(data) {
5034
+ return {
5035
+ type: "image",
5036
+ prompt: data.prompt ?? "",
5037
+ style: data.style,
5038
+ format: data.format,
5039
+ quality: data.quality,
5040
+ quantity: data.quantity ?? 1
5041
+ };
5042
+ }
5043
+
5044
+ // src/wizard/video.wizard.ts
5045
+ var validateSource = (data) => {
5046
+ const d = data;
5047
+ if (d.generationType === "text-to-video") {
5048
+ return typeof d.prompt === "string" && d.prompt.length > 0;
5049
+ }
5050
+ if (d.generationType === "image-to-video") {
5051
+ return typeof d.imageUrl === "string" && d.imageUrl.length > 0;
5052
+ }
5053
+ if (d.generationType === "video-to-video") {
5054
+ return typeof d.sourceVideoUrl === "string" && d.sourceVideoUrl.length > 0 && typeof d.prompt === "string" && d.prompt.length > 0;
5055
+ }
5056
+ return false;
5057
+ };
5058
+ var VIDEO_WIZARD_STEPS = [
5059
+ {
5060
+ id: "select-type",
5061
+ label: "Select Type",
5062
+ icon: "Video",
5063
+ description: "Choose video generation type",
5064
+ validate: (data) => Boolean(data.generationType)
5065
+ },
5066
+ {
5067
+ id: "input-source",
5068
+ label: "Source",
5069
+ icon: "FileInput",
5070
+ description: "Provide your source (prompt, image, or video)",
5071
+ validate: validateSource
5072
+ },
5073
+ {
5074
+ id: "configure",
5075
+ label: "Configure",
5076
+ icon: "Settings",
5077
+ description: "Set duration, aspect ratio, and style",
5078
+ validate: (data) => {
5079
+ const d = data;
5080
+ return Boolean(d.duration && d.aspectRatio);
5081
+ }
5082
+ },
5083
+ { id: "advanced", label: "Advanced", icon: "Sliders", description: "Additional video options", optional: true },
5084
+ { id: "preview", label: "Preview", icon: "Eye", description: "Review your settings" },
5085
+ { id: "generating", label: "Generating", icon: "Sparkles", description: "AI is creating your video" },
5086
+ { id: "results", label: "Results", icon: "Video", description: "Your generated video is ready" }
5087
+ ];
5088
+ function buildVideoRequest(data) {
5089
+ switch (data.generationType) {
5090
+ case "text-to-video":
5091
+ return {
5092
+ type: "video",
5093
+ prompt: data.prompt ?? "",
5094
+ duration: data.duration ?? 5,
5095
+ aspectRatio: data.aspectRatio ?? "16:9",
5096
+ style: data.style,
5097
+ quality: data.quality
5098
+ };
5099
+ case "image-to-video":
5100
+ return {
5101
+ type: "video",
5102
+ imageUrl: data.imageUrl ?? "",
5103
+ prompt: data.prompt,
5104
+ duration: data.duration ?? 5,
5105
+ motion: data.motion ?? "medium",
5106
+ camera: data.camera ?? "static"
5107
+ };
5108
+ case "video-to-video":
5109
+ return {
5110
+ type: "video",
5111
+ sourceVideoUrl: data.sourceVideoUrl ?? "",
5112
+ prompt: data.prompt ?? "",
5113
+ styleTransfer: data.styleTransfer,
5114
+ enhanceQuality: data.enhanceQuality
5115
+ };
5116
+ default:
5117
+ throw new Error(`Unsupported generation type: ${data.generationType}`);
5118
+ }
5119
+ }
5120
+
5121
+ export { ABTestService, AB_TEST_DEFAULT_CONFIDENCE, AIContentService, AIError, ASPECT_RATIO_OPTIONS, ASPECT_RATIO_VALUES, AnalysisService, BlogService, CONTENT_WIZARD_STEPS, CREDIT_COSTS, ContentCalendarService, DEFAULT_CREDIT_COST, DEFAULT_HASHTAG_BUDGET, CREDIT_COSTS as GENERATION_COSTS, GenerationExecutor, IMAGE_QUALITY_OPTIONS, IMAGE_QUALITY_VALUES, IMAGE_WIZARD_STEPS, ImagePromptService, MOTION_OPTIONS, MediaGenerationService, MemoryConfig, ModelDefaults, PLATFORM_SPECS, PromptBuilder, ProviderQuotaExhaustedError, ProviderTimingConfig, ProviderUnavailableError, RequestQueueConfig, STYLE_PRESETS, SeoService, SocialService, SpeechPaceConfig, TextModelDefaults, VIDEO_DURATION_OPTIONS, VIDEO_DURATION_OPTIONS_SECONDS, VIDEO_QUALITY_OPTIONS, VIDEO_QUALITY_VALUES, VIDEO_WIZARD_STEPS, ValidationError, ValidationLimits, VideoScriptService, buildContentRequest, buildImageRequest, buildVideoRequest, calculateContentCreditCost, calculateContentCreditCost as calculateCreditCost, calculateImprovementPercentage, calculateKeywordDensity, calculateRetryBackoffDelayMs, clampConfidenceToValidRange, clampScoreToValidRange, classifyKeywordProminence, countKeywordOccurrences, countWordsInContent, estimateFalGenerationCost, estimateGeminiGenerationCost, estimateGroqGenerationCost, estimatePrunaGenerationCost, estimateTokenBudgetForCalendarDays, estimateTokenBudgetForDuration, estimateUnknownProviderCost, estimateWordCountForDuration, generateId, getDimensionsForAspectRatio, getRecommendedQuality, isUnderutilizedKeyword, rankAndTrimHashtags, recommendQualityForAspectRatio, resolveCalendarEntryDate, resolveDefaultPrunaModel, resolveDimensionsForAspectRatio, resolveFalImageSize, resolveFalInferenceSteps, resolveHashtagBudget, resolveMaxContentLength, resolvePlatformSpec, selectHigherScoreVariantId, toQualityTier, truncateForAbVariantPreview, truncateForBlogPromptPreview, truncateForSeoPreview, validateCalendarDays, validateContentBody, validateDurationSeconds, validateHashtagCount, validateKeywordList, validateTopicText };
4821
5122
  //# sourceMappingURL=index.js.map
4822
5123
  //# sourceMappingURL=index.js.map