@sapia-ai/chatbot-v3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/EmbeddedVideoPlayer-SaMMfDIW.js +1277 -0
  2. package/dist/EmbeddedVideoPlayer-SaMMfDIW.js.map +1 -0
  3. package/dist/Preview-Db-hgkTh.js +83 -0
  4. package/dist/Preview-Db-hgkTh.js.map +1 -0
  5. package/dist/api/client.d.ts +60 -0
  6. package/dist/api/config.d.ts +18 -0
  7. package/dist/api/constants.d.ts +5 -0
  8. package/dist/api/index.d.ts +5 -0
  9. package/dist/api/sse.d.ts +12 -0
  10. package/dist/api/types/branding.d.ts +17 -0
  11. package/dist/api/types/messages.d.ts +148 -0
  12. package/dist/api/types/responses.d.ts +106 -0
  13. package/dist/api.js +2 -0
  14. package/dist/classPrivateFieldSet2-DtQPURVD.js +32 -0
  15. package/dist/core/bubbles/convert.d.ts +18 -0
  16. package/dist/core/bubbles/types.d.ts +55 -0
  17. package/dist/core/constants.d.ts +14 -0
  18. package/dist/core/events.d.ts +44 -0
  19. package/dist/core/i18n/fallback.d.ts +2 -0
  20. package/dist/core/i18n/languages.d.ts +11 -0
  21. package/dist/core/i18n/translator.d.ts +13 -0
  22. package/dist/core/interview.d.ts +207 -0
  23. package/dist/core/media/mimeTypes.d.ts +10 -0
  24. package/dist/core/media/recorder.d.ts +61 -0
  25. package/dist/core/persistence.d.ts +4 -0
  26. package/dist/core/store.d.ts +49 -0
  27. package/dist/core/theme/branding.d.ts +6 -0
  28. package/dist/core/theme/cssVariables.d.ts +16 -0
  29. package/dist/core/theme/types.d.ts +11 -0
  30. package/dist/core/validation/phoneCountries.d.ts +21 -0
  31. package/dist/core/validation/pii.d.ts +30 -0
  32. package/dist/dash.all.min-DZ1yEcJk.js +27302 -0
  33. package/dist/dash.all.min-DZ1yEcJk.js.map +1 -0
  34. package/dist/defineProperty-DiFpLzd2.js +39 -0
  35. package/dist/dist-BSi28_cP.js +702 -0
  36. package/dist/dist-BSi28_cP.js.map +1 -0
  37. package/dist/dist-DGBYKC8c.js +14327 -0
  38. package/dist/dist-DGBYKC8c.js.map +1 -0
  39. package/dist/dist-FvHBWiRa.js +76 -0
  40. package/dist/dist-FvHBWiRa.js.map +1 -0
  41. package/dist/embed/compat.d.ts +82 -0
  42. package/dist/embed/constants.d.ts +2 -0
  43. package/dist/embed/createChatbot.d.ts +22 -0
  44. package/dist/fix-webm-duration-BW9Fbdzt.js +1057 -0
  45. package/dist/fix-webm-duration-BW9Fbdzt.js.map +1 -0
  46. package/dist/hls-mBncGwsE.js +18657 -0
  47. package/dist/hls-mBncGwsE.js.map +1 -0
  48. package/dist/index.d.ts +7 -0
  49. package/dist/index.js +4428 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/max-Btet1snX.js +12212 -0
  52. package/dist/max-Btet1snX.js.map +1 -0
  53. package/dist/messages-C4jqrtSG.js +187 -0
  54. package/dist/messages-C4jqrtSG.js.map +1 -0
  55. package/dist/react/AnswerInput.d.ts +21 -0
  56. package/dist/react/SapiaChatbot.d.ts +23 -0
  57. package/dist/react/bubbleViewModel.d.ts +50 -0
  58. package/dist/react/strings.d.ts +98 -0
  59. package/dist/react/useBeforeUnload.d.ts +5 -0
  60. package/dist/react/useVideoRecorder.d.ts +24 -0
  61. package/dist/react-BGJ7Szvq.js +216 -0
  62. package/dist/react-BGJ7Szvq.js.map +1 -0
  63. package/dist/react-BMxM8TWJ.js +192 -0
  64. package/dist/react-BMxM8TWJ.js.map +1 -0
  65. package/dist/react-BVzcquey.js +457 -0
  66. package/dist/react-BVzcquey.js.map +1 -0
  67. package/dist/react-BrCGR7Ca.js +2208 -0
  68. package/dist/react-BrCGR7Ca.js.map +1 -0
  69. package/dist/react-Bujo1aK5.js +334 -0
  70. package/dist/react-Bujo1aK5.js.map +1 -0
  71. package/dist/react-CRTg4gz8.js +367 -0
  72. package/dist/react-CRTg4gz8.js.map +1 -0
  73. package/dist/react-GXf8sbzf.js +311 -0
  74. package/dist/react-GXf8sbzf.js.map +1 -0
  75. package/dist/react-lp7yfM94.js +371 -0
  76. package/dist/react-lp7yfM94.js.map +1 -0
  77. package/dist/sapia-chatbot.css +3 -0
  78. package/dist/sapia.d.ts +4 -0
  79. package/dist/ui/chat/ChatBubble/ChatBubble.d.ts +47 -0
  80. package/dist/ui/chat/ChatLog/ChatLog.d.ts +33 -0
  81. package/dist/ui/chat/TypingIndicator/TypingIndicator.d.ts +17 -0
  82. package/dist/ui/chat/types.d.ts +71 -0
  83. package/dist/ui/constants.d.ts +2 -0
  84. package/dist/ui/inputs/DropdownInput/DropdownInput.d.ts +18 -0
  85. package/dist/ui/inputs/OptionList/OptionList.d.ts +18 -0
  86. package/dist/ui/inputs/PhoneAnswerInput/PhoneAnswerInput.d.ts +19 -0
  87. package/dist/ui/inputs/SliderInput/SliderInput.d.ts +19 -0
  88. package/dist/ui/inputs/TextAnswerInput/TextAnswerInput.d.ts +32 -0
  89. package/dist/ui/inputs/VideoRecorder/VideoRecorder.d.ts +54 -0
  90. package/dist/ui/media/EmbeddedVideo/EmbeddedVideo.d.ts +11 -0
  91. package/dist/ui/media/EmbeddedVideo/EmbeddedVideoPlayer.d.ts +16 -0
  92. package/dist/ui/media/EmbeddedVideo/VimeoPlayer.d.ts +20 -0
  93. package/dist/ui/media/UploadProgress/UploadProgress.d.ts +7 -0
  94. package/dist/ui/media/VideoPlayer/VideoPlayer.d.ts +13 -0
  95. package/dist/ui/primitives/Button/Button.d.ts +6 -0
  96. package/dist/ui/primitives/Dialog/Dialog.d.ts +16 -0
  97. package/dist/ui/richText.d.ts +6 -0
  98. package/dist/ui/shell/AccessVerificationForm/AccessVerificationForm.d.ts +21 -0
  99. package/dist/ui/shell/CopyLinkButton/CopyLinkButton.d.ts +11 -0
  100. package/dist/ui/shell/DoneScreen/DoneScreen.d.ts +15 -0
  101. package/dist/ui/shell/Header/Header.d.ts +13 -0
  102. package/dist/ui/shell/PreparingScreen/PreparingScreen.d.ts +9 -0
  103. package/dist/ui/shell/ProgressBar/ProgressBar.d.ts +9 -0
  104. package/dist/ui/shell/WelcomeScreen/WelcomeScreen.d.ts +22 -0
  105. package/dist/ui/shell/WidgetRoot/WidgetRoot.d.ts +12 -0
  106. package/dist-umd/sapia-chatbot.umd.js +3655 -0
  107. package/dist-umd/sapia-chatbot.umd.js.map +1 -0
  108. package/package.json +94 -0
@@ -0,0 +1,10 @@
1
+ /** Preferred recording mimeTypes, best first (vp8/opus webm, then mp4 for Safari). */
2
+ export declare const VIDEO_MIME_CANDIDATES: readonly ["video/webm;codecs=vp8,opus", "video/webm;codecs=vp9,opus", "video/webm", "video/mp4"];
3
+ export declare const AUDIO_MIME_CANDIDATES: readonly ["audio/webm;codecs=opus", "audio/webm", "audio/mp4"];
4
+ export type MimeSupportCheck = (mimeType: string) => boolean;
5
+ /** First supported candidate, or undefined to let the browser pick its default. */
6
+ export declare const negotiateMimeType: (candidates: readonly string[], isSupported: MimeSupportCheck) => string | undefined;
7
+ /** File extension for a recorded blob's mimeType (mp4 vs webm). */
8
+ export declare const extensionForMimeType: (mimeType: string | undefined) => string;
9
+ /** webm duration metadata needs the fix-webm-duration patch; mp4 does not. */
10
+ export declare const needsWebmDurationFix: (mimeType: string | undefined) => boolean;
@@ -0,0 +1,61 @@
1
+ import { MimeSupportCheck } from './mimeTypes';
2
+ export type RecorderPhase = 'idle' | 'preview' | 'recording' | 'review' | 'error';
3
+ export type RecorderState = {
4
+ phase: RecorderPhase;
5
+ /** Seconds elapsed in the current recording. */
6
+ elapsedSeconds: number;
7
+ /** Recorded result, available in the review phase. */
8
+ result?: {
9
+ blob: Blob;
10
+ extension: string;
11
+ durationSeconds: number;
12
+ };
13
+ error?: string;
14
+ };
15
+ export type RecorderMedia = 'video' | 'audio';
16
+ export type RecorderDeps = {
17
+ /** Max recording length in seconds; auto-stops when reached. */
18
+ maxSeconds: number;
19
+ media?: RecorderMedia;
20
+ /** Resolves a camera/mic stream (navigator.mediaDevices.getUserMedia). */
21
+ getStream: (constraints: MediaStreamConstraints) => Promise<MediaStream>;
22
+ /** Constructs a MediaRecorder (injected for tests). */
23
+ createRecorder: (stream: MediaStream, options: MediaRecorderOptions) => MediaRecorder;
24
+ isTypeSupported: MimeSupportCheck;
25
+ /** Repairs webm duration metadata; defaults to fix-webm-duration (lazy). */
26
+ fixWebmDuration?: (blob: Blob, durationMs: number) => Promise<Blob>;
27
+ /** Wall-clock source (injected for deterministic tests). */
28
+ now?: () => number;
29
+ onChange?: (state: RecorderState) => void;
30
+ };
31
+ /** Legacy bitrates (App.tsx monkey-patch): 240p-ish video, 64 kbps audio. */
32
+ export declare const VIDEO_BITS_PER_SECOND = 400000;
33
+ export declare const AUDIO_BITS_PER_SECOND = 64000;
34
+ export declare class MediaRecorderController {
35
+ private readonly deps;
36
+ private state;
37
+ private stream?;
38
+ private recorder?;
39
+ private chunks;
40
+ private mimeType?;
41
+ private startedAt;
42
+ private timer?;
43
+ private readonly media;
44
+ private readonly now;
45
+ private readonly fixWebmDuration;
46
+ constructor(deps: RecorderDeps);
47
+ getState(): RecorderState;
48
+ getStream(): MediaStream | undefined;
49
+ /** Request camera/mic and enter preview. */
50
+ openCamera(): Promise<void>;
51
+ startRecording(): void;
52
+ stopRecording(): void;
53
+ /** Discard the recording and return to preview to re-record. */
54
+ reset(): void;
55
+ /** Stop tracks and release the camera/mic. */
56
+ dispose(): void;
57
+ private tick;
58
+ private finalize;
59
+ private clearTimer;
60
+ private setState;
61
+ }
@@ -0,0 +1,4 @@
1
+ /** Returns a still-valid verified email for the assessment, or undefined. */
2
+ export declare const getVerifiedEmail: (assessmentId: string, now?: number) => string | undefined;
3
+ /** Persist a verified email for the assessment with the 30-minute legacy TTL. */
4
+ export declare const saveVerifiedEmail: (assessmentId: string, candidateEmail: string, now?: number) => void;
@@ -0,0 +1,49 @@
1
+ import { StoreApi } from 'zustand/vanilla';
2
+ import { AssessmentStatus } from '../api/types/messages';
3
+ import { Branding } from '../api/types/branding';
4
+ import { MessageBubble } from './bubbles/types';
5
+ export type InterviewPhase = 'idle' | 'verifying' | 'access-required' | 'starting' | 'welcome' | 'active' | 'ended' | 'failed';
6
+ export type InterviewState = {
7
+ phase: InterviewPhase;
8
+ assessmentStatus?: AssessmentStatus;
9
+ bubbles: MessageBubble[];
10
+ /** Agent typing animation visible. */
11
+ typing: boolean;
12
+ /** Id of the agent bubble currently streaming in (drives the live caret); undefined when idle. */
13
+ streamingBubbleId?: string;
14
+ /** An answer submission is in flight. */
15
+ sendingAnswer: boolean;
16
+ numOfNormalQuestion: number;
17
+ numOfNormalAnswer: number;
18
+ branding?: Branding;
19
+ /** Candidate display name for the welcome/done screens (optional; from /start/ats). */
20
+ candidateName?: string;
21
+ /** Role/position title for the welcome + header (optional; falls back to branding.title). */
22
+ roleTitle?: string;
23
+ /** Candidate's detected ISO country code; seeds the phone PII default. */
24
+ candidateCountryCode?: string;
25
+ /** Question whose previously-submitted answer is being re-edited (null = not editing). */
26
+ editingQuestionId?: string;
27
+ /** Masked email shown on the access-verification gate. */
28
+ emailHint?: string;
29
+ /** Whether to show "email does not match" on the access gate. */
30
+ accessEmailMismatch?: boolean;
31
+ /** Access verification request in flight. */
32
+ verifyingAccess?: boolean;
33
+ /** AGC (automated-content) detection attempt count + whether another check is allowed. */
34
+ agcAttempt?: number;
35
+ allowNextAgcDetection?: boolean;
36
+ /** Show the AGC warning modal (automated content suspected on submit). */
37
+ showAgcWarning?: boolean;
38
+ /** Interview language (resolved); drives translations + text direction. */
39
+ language?: string;
40
+ /** Fetched translation file (flat key/value); undefined → bundled fallback only. */
41
+ translations?: Record<string, string>;
42
+ lastError?: {
43
+ type: string;
44
+ message: string;
45
+ };
46
+ };
47
+ export type InterviewStore = StoreApi<InterviewState>;
48
+ export declare const INITIAL_INTERVIEW_STATE: InterviewState;
49
+ export declare const createInterviewStore: () => InterviewStore;
@@ -0,0 +1,6 @@
1
+ import { Branding } from '../../api/types/branding';
2
+ import { Theme } from './types';
3
+ /** Converts the branding payload (theme array + font) into a Theme object. */
4
+ export declare const brandingToTheme: (branding?: Branding) => Theme;
5
+ /** Merge two themes; `override` (host setTheme) wins per field over `base` (branding). */
6
+ export declare const mergeThemes: (base: Theme | undefined, override: Theme | undefined) => Theme;
@@ -0,0 +1,16 @@
1
+ import { Theme } from './types';
2
+ export declare const CSS_VAR_HEADER_BG = "--sc-header-bg";
3
+ export declare const CSS_VAR_HEADER_FG = "--sc-header-fg";
4
+ export declare const CSS_VAR_QUESTION_BG = "--sc-question-bg";
5
+ export declare const CSS_VAR_QUESTION_FG = "--sc-question-fg";
6
+ export declare const CSS_VAR_RESPONSE_BG = "--sc-response-bg";
7
+ export declare const CSS_VAR_RESPONSE_FG = "--sc-response-fg";
8
+ export declare const CSS_VAR_BUTTON_BG = "--sc-button-bg";
9
+ export declare const CSS_VAR_BUTTON_FG = "--sc-button-fg";
10
+ export declare const CSS_VAR_FONT_FAMILY = "--sc-font-family";
11
+ export type CssVariableMap = Record<string, string>;
12
+ /**
13
+ * Converts a host/branding Theme into CSS custom properties applied on the
14
+ * widget root. Pure function — testable without DOM.
15
+ */
16
+ export declare const themeToCssVariables: (theme: Theme | undefined) => CssVariableMap;
@@ -0,0 +1,11 @@
1
+ export type ThemeSection = {
2
+ backgroundColor?: string;
3
+ fontColor?: string;
4
+ };
5
+ export type Theme = {
6
+ header?: ThemeSection;
7
+ question?: ThemeSection;
8
+ response?: ThemeSection;
9
+ button?: ThemeSection;
10
+ fontFamily?: string;
11
+ };
@@ -0,0 +1,21 @@
1
+ import { Region } from '../../api/config';
2
+ export type PhoneCountry = {
3
+ /** ISO 3166-1 alpha-2, e.g. "AU". */
4
+ code: string;
5
+ /** Calling code without "+", e.g. "61". */
6
+ callingCode: string;
7
+ /** Localized display name, e.g. "Australia". */
8
+ name: string;
9
+ /** Flag emoji derived from the country code. */
10
+ flag: string;
11
+ };
12
+ /** Legacy REGION_AREA_MAP: default phone country per backend region. */
13
+ export declare const DEFAULT_COUNTRY_BY_REGION: Record<Region, string>;
14
+ export declare const DEFAULT_PHONE_COUNTRY = "AU";
15
+ /** Loads libphonenumber metadata on demand and builds the sorted country list. */
16
+ export declare const loadPhoneCountries: (locale?: string) => Promise<PhoneCountry[]>;
17
+ /** Initial country: candidate's detected country, else the region default. */
18
+ export declare const resolveDefaultPhoneCountry: ({ candidateCountryCode, region, }: {
19
+ candidateCountryCode?: string;
20
+ region?: Region;
21
+ }) => string;
@@ -0,0 +1,30 @@
1
+ import { PiiQuestionType } from '../../api/types/messages';
2
+ import { ExtractHumanNameType } from '../../api/types/responses';
3
+ export declare const PII_ERROR_KEYS: {
4
+ readonly email: "fi_error_piiEmail";
5
+ readonly fullName: "fi_error_piiFullName";
6
+ readonly firstName: "fi_error_piiFirstName";
7
+ readonly lastName: "fi_error_piiLastName";
8
+ readonly phoneNumber: "fi_error_piiPhoneNumber";
9
+ };
10
+ export type PiiErrorKey = (typeof PII_ERROR_KEYS)[keyof typeof PII_ERROR_KEYS];
11
+ export type PiiValidationResult = {
12
+ ok: true;
13
+ text: string;
14
+ } | {
15
+ ok: false;
16
+ errorKey: PiiErrorKey;
17
+ possiblePhoneNumber?: boolean;
18
+ };
19
+ export declare const EXTRACT_TYPE_BY_PII: Partial<Record<PiiQuestionType, ExtractHumanNameType>>;
20
+ export declare const validateEmail: (text: string) => PiiValidationResult;
21
+ export declare const validateName: (piiType: PiiQuestionType, text: string) => PiiValidationResult;
22
+ /** True when the answer likely contains more than the asked-for name part. */
23
+ export declare const needsNameExtraction: (piiType: PiiQuestionType, text: string) => boolean;
24
+ /**
25
+ * Validates a national phone number against the selected country and
26
+ * normalizes to E.164 (legacy submits phoneNumber.number). `possiblePhoneNumber`
27
+ * mirrors the legacy INVALID_PHONE_NUMBER log trigger (possible but invalid).
28
+ */
29
+ export declare const validatePhone: (text: string, countryCode: string) => Promise<PiiValidationResult>;
30
+ export declare const isNamePiiType: (piiType?: PiiQuestionType) => boolean;