{"version":3,"file":"index.cjs","names":["z","z","ElevenLabsVoiceNames: ElevenLabsVoiceName[]","ElevenLabsVoiceIds: ElevenLabsVoiceId[]","z","z","options: AiFlowAssistantOptions"],"sources":["../src/sdk/model/barge-in.model.ts","../../shared/dist/index.js","../src/sdk/model/tts.model.ts","../src/sdk/model/actions.model.ts","../src/sdk/model/events.model.ts","../src/sdk/assistant/assistant.ts"],"sourcesContent":["import z from \"zod\";\n\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport enum BargeInStrategy {\n  /**\n   * No barge-in, play the audio fully and directly\n   */\n  NONE = \"none\",\n  /**\n   * No auto barge-in, only manual barge-in via API\n   */\n  MANUAL = \"manual\",\n  /**\n   * Barge in if user words exceed 3 characters or the configured minimum_characters\n   */\n  MINIMUM_CHARACTERS = \"minimum_characters\",\n}\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nexport const BargeInConfigSchema = z.object({\n  strategy: z.enum(BargeInStrategy),\n  minimum_characters: z\n    .number()\n    .min(1)\n    .optional()\n    .describe(\"Minimum number of characters to detect barge-in\"),\n  allow_after_ms: z\n    .number()\n    .min(0)\n    .optional()\n    .describe(\n      \"Allow barge-in only after this many milliseconds (to avoid cutting off the beginning of the audio)\",\n    ),\n});\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type BargeInConfig = z.infer<typeof BargeInConfigSchema>;\n","//#region src/model/elevenlabs.voices.model.ts\nconst ELEVENLABS_VOICES = [\n\t{\n\t\tid: \"21m00Tcm4TlvDq8ikWAM\",\n\t\tname: \"Rachel\",\n\t\tdescription: \"Matter-of-fact, personable woman. Great for conversational use cases.\",\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"29vD33N1CtxCmqQRPOHJ\",\n\t\tname: \"Drew\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"2EiwWnXFnvU5JabPnv8n\",\n\t\tname: \"Clyde\",\n\t\tdescription: \"Great for character use-cases\",\n\t\tverifiedLocales: [\"en-US\"]\n\t},\n\t{\n\t\tid: \"5Q0t7uMcjvnagumLfvZi\",\n\t\tname: \"Paul\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"9BWtsMINqrJLrRacOk9x\",\n\t\tname: \"Aria\",\n\t\tdescription: \"A middle-aged female with an African-American accent. Calm with a hint of rasp.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"tr-TR\"\n\t\t]\n\t},\n\t{\n\t\tid: \"AZnzlk1XvdvUeBnXmlld\",\n\t\tname: \"Domi\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"CYw3kZ02Hs0563khs1Fj\",\n\t\tname: \"Dave\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"CwhRBWXzGAHq8TQ4Fs17\",\n\t\tname: \"Roger\",\n\t\tdescription: \"Easy going and perfect for casual conversations.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"de-DE\",\n\t\t\t\"nl-NL\"\n\t\t]\n\t},\n\t{\n\t\tid: \"D38z5RcWu1voky8WS1ja\",\n\t\tname: \"Fin\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"EXAVITQu4vr4xnSDxMaL\",\n\t\tname: \"Sarah\",\n\t\tdescription: \"Young adult woman with a confident and warm, mature quality and a reassuring, professional tone.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"ErXwobaYiN019PkySvjV\",\n\t\tname: \"Antoni\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"FGY2WhTYpPnrIDTdsKH5\",\n\t\tname: \"Laura\",\n\t\tdescription: \"This young adult female voice delivers sunny enthusiasm with a quirky attitude.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"de-DE\"\n\t\t]\n\t},\n\t{\n\t\tid: \"GBv7mTt0atIp3Br8iCZE\",\n\t\tname: \"Thomas\",\n\t\tdescription: \"Soft and subdued male voice, optimal for narrations or meditations\",\n\t\tverifiedLocales: [\"en-US\"]\n\t},\n\t{\n\t\tid: \"IKne3meq5aSn9XLyUdCD\",\n\t\tname: \"Charlie\",\n\t\tdescription: \"A young Australian male with a confident and energetic voice.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-AU\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"fil-PH\"\n\t\t]\n\t},\n\t{\n\t\tid: \"JBFqnCBsd6RMkjVDRZzb\",\n\t\tname: \"George\",\n\t\tdescription: \"Warm resonance that instantly captivates listeners.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-GB\",\n\t\t\t\"fr-FR\",\n\t\t\t\"ja-JP\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"fil-PH\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"LcfcDJNUP1GQjkzn1xUU\",\n\t\tname: \"Emily\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"MF3mGyEYCl7XYWbV9V6O\",\n\t\tname: \"Elli\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"N2lVS1w4EtoT3dr4eOWO\",\n\t\tname: \"Callum\",\n\t\tdescription: \"Deceptively gravelly, yet unsettling edge.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"ODq5zmih8GrVes37Dizd\",\n\t\tname: \"Patrick\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"SAz9YHcvj6GT2YYXdXww\",\n\t\tname: \"River\",\n\t\tdescription: \"A relaxed, neutral voice ready for narrations or conversational projects.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"it-IT\",\n\t\t\t\"fr-FR\",\n\t\t\t\"cmn-CN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"SOYHLrjzK2X1ezoPC6cr\",\n\t\tname: \"Harry\",\n\t\tdescription: \"An animated warrior ready to charge forward.\",\n\t\tverifiedLocales: [\"en-US\"]\n\t},\n\t{\n\t\tid: \"TX3LPaxmHKxFdv7VOQHJ\",\n\t\tname: \"Liam\",\n\t\tdescription: \"A young adult with energy and warmth - suitable for reels and shorts.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"de-DE\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"pl-PL\",\n\t\t\t\"tr-TR\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"ThT5KcBeYPX3keUQqHPh\",\n\t\tname: \"Dorothy\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"TxGEqnHWrfWFTfGW9XjX\",\n\t\tname: \"Josh\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"VR6AewLTigWG4xSOukaG\",\n\t\tname: \"Arnold\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"XB0fDUnXU5powFXDhCwa\",\n\t\tname: \"Charlotte\",\n\t\tdescription: \"Sensual and raspy, she's ready to voice your temptress in video games.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"sv-SE\"\n\t\t]\n\t},\n\t{\n\t\tid: \"Xb7hH8MSUJpSbSDYk0k2\",\n\t\tname: \"Alice\",\n\t\tdescription: \"Clear and engaging, friendly woman with a British accent suitable for e-learning.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-GB\",\n\t\t\t\"it-IT\",\n\t\t\t\"fr-FR\",\n\t\t\t\"ja-JP\",\n\t\t\t\"pl-PL\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"XrExE9yKIg1WjnnlVkGX\",\n\t\tname: \"Matilda\",\n\t\tdescription: \"A professional woman with a pleasing alto pitch. Suitable for many use cases.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"it-IT\",\n\t\t\t\"fr-FR\",\n\t\t\t\"de-DE\"\n\t\t]\n\t},\n\t{\n\t\tid: \"ZQe5CZNOzWyzPSCn5a3c\",\n\t\tname: \"James\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"Zlb1dXrM653N07WRdFW3\",\n\t\tname: \"Joseph\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"bIHbv24MWmeRgasZH58o\",\n\t\tname: \"Will\",\n\t\tdescription: \"Conversational and laid back.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"de-DE\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"fil-PH\",\n\t\t\t\"sk-SK\",\n\t\t\t\"sv-SE\"\n\t\t]\n\t},\n\t{\n\t\tid: \"bVMeCyTHy58xNoL34h3p\",\n\t\tname: \"Jeremy\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"cgSgspJ2msm6clMCkdW9\",\n\t\tname: \"Jessica\",\n\t\tdescription: \"Young and popular, this playful American female voice is perfect for trendy content.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"ja-JP\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"de-DE\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"cjVigY5qzO86Huf0OWal\",\n\t\tname: \"Eric\",\n\t\tdescription: \"A smooth tenor pitch from a man in his 40s - perfect for agentic use cases.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"de-DE\",\n\t\t\t\"sk-SK\"\n\t\t]\n\t},\n\t{\n\t\tid: \"flq6f7yk4E4fJM5XTYuZ\",\n\t\tname: \"Michael\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"g5CIjZEefAph4nQFvHAz\",\n\t\tname: \"Ethan\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"iP95p4xoKVk53GoZ742B\",\n\t\tname: \"Chris\",\n\t\tdescription: \"Natural and real, this down-to-earth voice is great across many use-cases.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"sv-SE\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"jBpfuIE2acCO8z3wKNLl\",\n\t\tname: \"Gigi\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"jsCqWAovK2LkecY7zXl4\",\n\t\tname: \"Freya\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"nPczCjzI2devNBz1zQrb\",\n\t\tname: \"Brian\",\n\t\tdescription: \"Middle-aged man with a resonant and comforting tone. Great for narrations and advertisements.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"de-DE\",\n\t\t\t\"nl-NL\",\n\t\t\t\"sk-SK\",\n\t\t\t\"ro-RO\",\n\t\t\t\"hi-IN\"\n\t\t]\n\t},\n\t{\n\t\tid: \"oWAxZDx7w5VEj9dCyTzz\",\n\t\tname: \"Grace\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"onwK4e9ZLuTAKqWW03F9\",\n\t\tname: \"Daniel\",\n\t\tdescription: \"A strong voice perfect for delivering a professional broadcast or news story.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-GB\",\n\t\t\t\"de-DE\",\n\t\t\t\"tr-TR\"\n\t\t]\n\t},\n\t{\n\t\tid: \"pFZP5JQG7iQjIQuC4Bku\",\n\t\tname: \"Lily\",\n\t\tdescription: \"Velvety British female voice delivers news and narrations with warmth and clarity.\",\n\t\tverifiedLocales: [\n\t\t\t\"it-IT\",\n\t\t\t\"de-DE\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"cs-CZ\",\n\t\t\t\"nl-NL\",\n\t\t\t\"pl-PL\"\n\t\t]\n\t},\n\t{\n\t\tid: \"pMsXgVXv3BLzUgSXRplE\",\n\t\tname: \"Serena\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"pNInz6obpgDQGcFmaJgB\",\n\t\tname: \"Adam\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"piTKgcLEGmPE4e6mEKli\",\n\t\tname: \"Nicole\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"pqHfZKP75CvOlQylNhV4\",\n\t\tname: \"Bill\",\n\t\tdescription: \"Friendly and comforting voice ready to narrate your stories.\",\n\t\tverifiedLocales: [\n\t\t\t\"en-US\",\n\t\t\t\"fr-FR\",\n\t\t\t\"cmn-CN\",\n\t\t\t\"de-DE\",\n\t\t\t\"cs-CZ\"\n\t\t]\n\t},\n\t{\n\t\tid: \"t0jbNlBVZ17f02VDIeMI\",\n\t\tname: \"Jessie\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"yoZ06aMxZJJ28mfd3POQ\",\n\t\tname: \"Sam\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"z9fAnlkpzviPz146aGWa\",\n\t\tname: \"Glinda\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"zcAOhNBS3c14rBihAFp1\",\n\t\tname: \"Giovanni\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t},\n\t{\n\t\tid: \"zrHiDhphv9ZnVXBqCLjz\",\n\t\tname: \"Mimi\",\n\t\tdescription: null,\n\t\tverifiedLocales: []\n\t}\n];\n\n//#endregion\n//#region src/model/events.model.ts\nlet SessionEventType = /* @__PURE__ */ function(SessionEventType$1) {\n\tSessionEventType$1[\"HTTP_MESSAGE\"] = \"http:message\";\n\tSessionEventType$1[\"HTTP_MESSAGE_ERROR\"] = \"http:message:error\";\n\tSessionEventType$1[\"WEBSOCKET_MESSAGE\"] = \"websocket:message\";\n\tSessionEventType$1[\"WEBSOCKET_MESSAGE_ERROR\"] = \"websocket:message:error\";\n\tSessionEventType$1[\"WEBSOCKET_ERROR\"] = \"websocket:error\";\n\tSessionEventType$1[\"WEBSOCKET_CLOSED\"] = \"websocket:closed\";\n\tSessionEventType$1[\"TRANSCRIBER_CLOSE\"] = \"transcriber:close\";\n\tSessionEventType$1[\"TRANSCRIBER_CREATE\"] = \"transcriber:create\";\n\tSessionEventType$1[\"TRANSCRIBER_STARTED\"] = \"transcriber:started\";\n\tSessionEventType$1[\"TRANSCRIBER_STOPPED\"] = \"transcriber:stopped\";\n\tSessionEventType$1[\"TRANSCRIBER_CANCELED\"] = \"transcriber:canceled\";\n\tSessionEventType$1[\"TRANSCRIBER_SPEECH_START\"] = \"transcriber:speech:start\";\n\tSessionEventType$1[\"TRANSCRIBER_SPEECH_END\"] = \"transcriber:speech:end\";\n\tSessionEventType$1[\"TRANSCRIBER_SPEECH_RECOGNIZED\"] = \"transcriber:speech:recognized\";\n\tSessionEventType$1[\"TRANSCRIBER_CONTINUOUS_RECOGNITION_STARTED\"] = \"transcriber:continuous-recognition:started\";\n\tSessionEventType$1[\"TRANSCRIBER_CONTINUOUS_RECOGNITION_FAILED\"] = \"transcriber:continuous-recognition:failed\";\n\tSessionEventType$1[\"SYNTHESIS_CREATED\"] = \"synthesis:created\";\n\tSessionEventType$1[\"SYNTHESIS_FAILED\"] = \"synthesis:failed\";\n\tSessionEventType$1[\"BARGE_IN\"] = \"barge_in\";\n\tSessionEventType$1[\"CALL_HANGUP\"] = \"call:hangup\";\n\tSessionEventType$1[\"CALL_TRANSFER\"] = \"call:transfer\";\n\tSessionEventType$1[\"CALL_GATHER_DTMF\"] = \"call:gather_dtmf\";\n\tSessionEventType$1[\"CALL_DTMF\"] = \"call:dtmf\";\n\tSessionEventType$1[\"CALL_ERROR\"] = \"call:error\";\n\treturn SessionEventType$1;\n}({});\n\n//#endregion\n//#region src/model/sessions.model.ts\nlet SessionDirection = /* @__PURE__ */ function(SessionDirection$1) {\n\tSessionDirection$1[\"INBOUND\"] = \"inbound\";\n\tSessionDirection$1[\"OUTBOUND\"] = \"outbound\";\n\treturn SessionDirection$1;\n}({});\nlet TranscriptionProvider = /* @__PURE__ */ function(TranscriptionProvider$1) {\n\tTranscriptionProvider$1[\"AZURE\"] = \"azure\";\n\tTranscriptionProvider$1[\"ELEVEN_LABS\"] = \"eleven_labs\";\n\tTranscriptionProvider$1[\"DEEPGRAM\"] = \"deepgram\";\n\treturn TranscriptionProvider$1;\n}({});\n\n//#endregion\n//#region src/util/filter.util.ts\nfunction onlyUnique(value, index, self) {\n\treturn self.indexOf(value) === index;\n}\nfunction notEmpty(value) {\n\treturn value !== null && value !== undefined;\n}\n\n//#endregion\n//#region src/util/sleep.util.ts\nasync function sleep(ms) {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n//#endregion\nexport { ELEVENLABS_VOICES, SessionDirection, SessionEventType, TranscriptionProvider, notEmpty, onlyUnique, sleep };\n//# sourceMappingURL=index.js.map","import {\n  ELEVENLABS_VOICES,\n  type ElevenLabsVoiceId,\n  type ElevenLabsVoiceName,\n} from \"@sipgate-ai-flow/shared\";\nimport z from \"zod\";\n\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport enum AiFlowApiActionType {\n  SPEAK = \"speak\",\n  AUDIO = \"audio\",\n  HANGUP = \"hangup\",\n  DTMF = \"dtmf\",\n  BARGE_IN = \"barge_in\",\n  TRANSFER = \"transfer\",\n}\n\nexport enum TtsProvider {\n  AZURE = \"azure\",\n  ELEVEN_LABS = \"eleven_labs\",\n}\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nexport const TtsConfigAzureSchema = z.strictObject({\n  provider: z.literal(TtsProvider.AZURE),\n  language: z\n    .string()\n    .optional()\n    .describe('Language code (BCP-47), e.g. \"en-US\" or \"de-DE\")'),\n  voice: z.string().optional().describe(\"Voice name\"),\n});\n\nconst ElevenLabsVoiceNames: ElevenLabsVoiceName[] = ELEVENLABS_VOICES.map(\n  (v) => v.name as ElevenLabsVoiceName,\n);\nconst ElevenLabsVoiceIds: ElevenLabsVoiceId[] = ELEVENLABS_VOICES.map(\n  (v) => v.id as ElevenLabsVoiceId,\n);\n\nexport const TtsConfigElevenLabsSchema = z.strictObject({\n  provider: z.literal(TtsProvider.ELEVEN_LABS),\n  voice: z.object({\n    id: z.literal(ElevenLabsVoiceIds).optional().describe(\"Voice ID\"),\n    name: z.literal(ElevenLabsVoiceNames).optional().describe(\"Voice name\"),\n  }),\n});\n\nexport const TtsConfigSchema = z.discriminatedUnion(\"provider\", [\n  TtsConfigAzureSchema,\n  TtsConfigElevenLabsSchema,\n]);\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type TtsConfigAzure = z.infer<typeof TtsConfigAzureSchema>;\n\nexport type TtsConfigElevenLabs = z.infer<typeof TtsConfigElevenLabsSchema>;\n\nexport type TtsConfig = TtsConfigAzure | TtsConfigElevenLabs;\n","import z from \"zod\";\nimport { BargeInConfigSchema } from \"./barge-in.model\";\nimport { TtsConfigSchema } from \"./tts.model\";\n\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport enum AiFlowActionType {\n  SPEAK = \"speak\",\n  AUDIO = \"audio\",\n  HANGUP = \"hangup\",\n  DTMF = \"dtmf\",\n  BARGE_IN = \"barge_in\",\n  TRANSFER = \"transfer\",\n  GATHER_DTMF = \"gather_dtmf\",\n}\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nexport const AiFlowBaseActionSchema = z.object({\n  session_id: z.uuid().describe(\"Session ID\"),\n});\n\nexport const AiFlowActionSpeakSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.SPEAK),\n  text: z.string().optional().describe(\"Text to speak\"),\n  ssml: z\n    .string()\n    .optional()\n    .describe(\n      \"SSML text (used if no `text` is provided). Note: SSML syntax may vary between TTS providers\",\n    ),\n  tts: TtsConfigSchema.optional().describe(\"TTS provider configuration\"),\n  barge_in: BargeInConfigSchema.optional().describe(\n    \"Barge-in configuration for this turn\",\n  ),\n});\n\nexport const AiFlowActionAudioSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.AUDIO),\n  /**\n   * Base64 encoded audio data (WAV format, 8kHz, mono)\n   */\n  audio: z\n    .string()\n    .describe(\"Base64 encoded audio data (WAV format, 8kHz, mono)\"),\n  barge_in: BargeInConfigSchema.optional().describe(\n    \"Barge-in configuration for this turn\",\n  ),\n});\n\nexport const AiFlowActionHangupSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.HANGUP),\n});\n\nexport const AiFlowActionDtmfSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.DTMF),\n  dtmf: z.number().min(0).max(9).describe(\"DTMF digit to send (0-9)\"),\n});\n\nexport const AiFlowActionBargeInSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.BARGE_IN),\n});\n\nexport const AiFlowActionTransferSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.TRANSFER),\n  target_phone_number: z\n    .string()\n    .describe(\"Target phone number to transfer to\"),\n  caller_id_name: z.string().describe(\"Caller ID name for the transfer\"),\n  caller_id_number: z.string().describe(\"Caller ID number for the transfer\"),\n});\n\nexport const AiFlowActionGatherDtmfSchema = AiFlowBaseActionSchema.extend({\n  type: z.literal(AiFlowActionType.GATHER_DTMF),\n  allowed_gathered_characters: z\n    .string()\n    .describe(\n      \"Characters that are allowed as input. All other characters will be ignored. Allowed characters are: 0-9, #, *. The characters can be specified in any order. Default: 0123456789\",\n    )\n    .default(\"0123456789\"),\n  audio_url: z\n    .url()\n    .optional()\n    .describe(\"URL of the audio to play when gathering DTMF input\"),\n  finish_on_key: z\n    .string()\n    .describe(\"The key that will signal the end of DTMF input. Default: #\")\n    .default(\"#\"),\n  num_characters: z\n    .number()\n    .describe(\"Maximum number of characters to gather. Default: 1\")\n    .default(1),\n  timeout_ms: z\n    .number()\n    .describe(\n      \"Number of milliseconds to wait for input before timing out. Default: 5000\",\n    )\n    .default(5000),\n});\n\nexport const AiFlowActionSchema = z.discriminatedUnion(\"type\", [\n  AiFlowActionSpeakSchema,\n  AiFlowActionAudioSchema,\n  AiFlowActionHangupSchema,\n  AiFlowActionDtmfSchema,\n  AiFlowActionBargeInSchema,\n  AiFlowActionTransferSchema,\n  AiFlowActionGatherDtmfSchema,\n]);\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type AiFlowBaseAction = z.infer<typeof AiFlowBaseActionSchema>;\n\nexport type AiFlowActionSpeak = z.infer<typeof AiFlowActionSpeakSchema>;\n\nexport type AiFlowActionAudio = z.infer<typeof AiFlowActionAudioSchema>;\n\nexport type AiFlowActionHangup = z.infer<typeof AiFlowActionHangupSchema>;\n\nexport type AiFlowActionDtmf = z.infer<typeof AiFlowActionDtmfSchema>;\n\nexport type AiFlowActionBargeIn = z.infer<typeof AiFlowActionBargeInSchema>;\n\nexport type AiFlowActionTransfer = z.infer<typeof AiFlowActionTransferSchema>;\n\nexport type AiFlowActionGatherDtmf = z.infer<\n  typeof AiFlowActionGatherDtmfSchema\n>;\n\nexport type AiFlowAction = z.infer<typeof AiFlowActionSchema>;\n","import z from \"zod\";\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport enum AiFlowEventType {\n  ASSISTANT_SPEAK = \"assistant_speak\",\n  ASSISTANT_SPEECH_ENDED = \"assistant_speech_ended\",\n  USER_SPEAK = \"user_speak\",\n  USER_BARGE_IN = \"user_barge_in\",\n  SESSION_START = \"session_start\",\n  SESSION_END = \"session_end\",\n}\n\nexport enum SessionDirection {\n  INBOUND = \"inbound\",\n  OUTBOUND = \"outbound\",\n}\n\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport const AiFlowEventSessionInfoSchema = z.object({\n  id: z.uuid().describe(\"Unique session identifier\"),\n  account_id: z.string().describe(\"Account ID for this flow session\"),\n  phone_number: z.string().describe(\"Phone number for this flow session\"),\n  direction: z\n    .enum(SessionDirection)\n    .optional()\n    .describe(\"Direction of the call\"),\n  // from_account_id: z\n  //   .string()\n  //   .optional()\n  //   .describe(\"sipgate account id of the caller if available\"),\n  from_phone_number: z.string().describe(\"Phone number of the caller\"),\n  // to_account_id: z\n  //   .string()\n  //   .optional()\n  //   .describe(\"sipgate account id of the callee if available\"),\n  to_phone_number: z.string().describe(\"Phone number of the callee\"),\n});\n\nexport const AiFlowBaseEventSchema = z.object({\n  session: AiFlowEventSessionInfoSchema,\n});\n\nexport const AiFlowEventUserSpeakSchema = AiFlowBaseEventSchema.extend({\n  type: z.literal(AiFlowEventType.USER_SPEAK),\n  text: z.string().describe(\"Recognized user speech text\"),\n});\n\nexport const AiFlowEventSessionStartSchema = AiFlowBaseEventSchema.extend({\n  type: z.literal(AiFlowEventType.SESSION_START),\n});\n\nexport const AiFlowEventUserBargeInSchema = AiFlowBaseEventSchema.extend({\n  type: z.literal(AiFlowEventType.USER_BARGE_IN),\n  text: z.string().describe(\"Recognized user speech text\"),\n});\n\nexport const AiFlowEventAssistantSpeakSchema = AiFlowBaseEventSchema.extend({\n  type: z.literal(AiFlowEventType.ASSISTANT_SPEAK),\n  text: z.string().optional().describe(\"Text to be spoken by the assistant\"),\n  /**\n   * SSML text (used if no `text` is provided)\n   * Note: SSML syntax may vary between TTS providers\n   */\n  ssml: z\n    .string()\n    .optional()\n    .describe(\"SSML text to be spoken by the assistant\"),\n  duration_ms: z.number().describe(\"Duration of the speech in milliseconds\"),\n  speech_started_at: z\n    .number()\n    .describe(\n      \"Timestamp (in milliseconds since epoch) when the speech started\",\n    ),\n});\n\nexport const AiFlowEventAssistantSpeechEndedSchema =\n  AiFlowBaseEventSchema.extend({\n    type: z.literal(AiFlowEventType.ASSISTANT_SPEECH_ENDED),\n  });\n\nexport const AiFlowEventSessionEndSchema = AiFlowBaseEventSchema.extend({\n  type: z.literal(AiFlowEventType.SESSION_END),\n});\n\nexport const AiFlowEventSchema = z.discriminatedUnion(\"type\", [\n  AiFlowEventUserSpeakSchema,\n  AiFlowEventSessionStartSchema,\n  AiFlowEventUserBargeInSchema,\n  AiFlowEventAssistantSpeakSchema,\n  AiFlowEventAssistantSpeechEndedSchema,\n  AiFlowEventSessionEndSchema,\n]);\n\n// ============================================================================\n// Enums\n// ============================================================================\n\nexport type AiFlowEventSessionInfo = z.infer<\n  typeof AiFlowEventSessionInfoSchema\n>;\n\nexport type AiFlowEventUserSpeak = z.infer<typeof AiFlowEventUserSpeakSchema>;\n\nexport type AiFlowEventUserBargeIn = z.infer<\n  typeof AiFlowEventUserBargeInSchema\n>;\n\nexport type AiFlowEventAssistantSpeak = z.infer<\n  typeof AiFlowEventAssistantSpeakSchema\n>;\n\nexport type AiFlowEventAssistantSpeechEnded = z.infer<\n  typeof AiFlowEventAssistantSpeechEndedSchema\n>;\n\nexport type AiFlowEventSessionStart = z.infer<\n  typeof AiFlowEventSessionStartSchema\n>;\n\nexport type AiFlowEventSessionEnd = z.infer<typeof AiFlowEventSessionEndSchema>;\n\nexport type AiFlowEvent = z.infer<typeof AiFlowEventSchema>;\n","import type { Request, Response } from \"express\";\nimport type WebSocket from \"ws\";\nimport {\n  AiFlowAction,\n  AiFlowEvent,\n  AiFlowEventAssistantSpeak,\n  AiFlowEventAssistantSpeechEnded,\n  AiFlowEventSessionEnd,\n  AiFlowEventSessionStart,\n  AiFlowEventUserBargeIn,\n  AiFlowEventUserSpeak,\n} from \"../model\";\nimport { AiFlowActionType, AiFlowEventType } from \"../model\";\n\ntype InvocationResponseType =\n  | AiFlowAction\n  | AiFlowAction[]\n  | string\n  | null\n  | undefined;\n\nexport type AiFlowAssistantOptions = {\n  apiKey?: string;\n  debug?: boolean;\n\n  onUserSpeak?: (\n    event: AiFlowEventUserSpeak,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n\n  onAssistantSpeak?: (\n    event: AiFlowEventAssistantSpeak,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n\n  onAssistantSpeechEnded?: (\n    event: AiFlowEventAssistantSpeechEnded,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n\n  onSessionStart?: (\n    event: AiFlowEventSessionStart,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n\n  onSessionEnd?: (\n    event: AiFlowEventSessionEnd,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n\n  onUserBargeIn?: (\n    event: AiFlowEventUserBargeIn,\n    ws?: WebSocket,\n  ) => Promise<InvocationResponseType> | Promise<void>;\n};\n\nexport class AiFlowAssistant {\n  constructor(private options: AiFlowAssistantOptions) {}\n\n  static create(options: AiFlowAssistantOptions) {\n    return new AiFlowAssistant(options);\n  }\n\n  private log(...args: unknown[]) {\n    if (this.options.debug) {\n      // biome-ignore lint/suspicious/noConsole: logging\n      console.log(\"[Ai Flow]\", ...args);\n    }\n  }\n\n  private onResult(\n    event: AiFlowEvent,\n    result?: InvocationResponseType | null,\n  ): AiFlowAction | AiFlowAction[] | null {\n    if (!result) {\n      return null;\n    }\n\n    if (typeof result === \"string\") {\n      return {\n        type: AiFlowActionType.SPEAK,\n        session_id: event.session.id,\n        text: result,\n      };\n    }\n\n    return result;\n  }\n\n  private async onSessionStartEvent(\n    event: AiFlowEventSessionStart,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onSessionStart) {\n      const result = await this.options.onSessionStart(event, ws);\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n    return null;\n  }\n\n  private async onUserSpeakEvent(\n    event: AiFlowEventUserSpeak,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onUserSpeak) {\n      const result = await this.options.onUserSpeak(event, ws);\n\n      if (typeof result === \"string\") {\n        // convert to speak action\n        return {\n          type: AiFlowActionType.SPEAK,\n          session_id: event.session.id,\n          text: result,\n        };\n      }\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n    return null;\n  }\n\n  private async onAssistantSpeakEvent(\n    event: AiFlowEventAssistantSpeak,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onAssistantSpeak) {\n      const result = await this.options.onAssistantSpeak(event, ws);\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n    return null;\n  }\n\n  private async onAssistantSpeechEndedEvent(\n    event: AiFlowEventAssistantSpeechEnded,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onAssistantSpeechEnded) {\n      const result = await this.options.onAssistantSpeechEnded(event, ws);\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n    return null;\n  }\n\n  private async onSessionEndEvent(\n    event: AiFlowEventSessionEnd,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onSessionEnd) {\n      const result = await this.options.onSessionEnd(event, ws);\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n\n    return null;\n  }\n\n  private async onUserBargeInEvent(\n    event: AiFlowEventUserBargeIn,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    if (this.options.onUserBargeIn) {\n      const result = await this.options.onUserBargeIn(event, ws);\n\n      if (!result) {\n        return null;\n      }\n\n      return this.onResult(event, result);\n    }\n    return null;\n  }\n\n  public async onEvent(\n    event: AiFlowEvent,\n    ws?: WebSocket,\n  ): Promise<AiFlowAction | AiFlowAction[] | null> {\n    this.log(\"Received event:\", event.type, event);\n    switch (event?.type) {\n      case AiFlowEventType.SESSION_START: {\n        return this.onSessionStartEvent(event, ws);\n      }\n      case AiFlowEventType.USER_SPEAK: {\n        return this.onUserSpeakEvent(event, ws);\n      }\n      case AiFlowEventType.ASSISTANT_SPEAK: {\n        return this.onAssistantSpeakEvent(event, ws);\n      }\n      case AiFlowEventType.ASSISTANT_SPEECH_ENDED: {\n        return this.onAssistantSpeechEndedEvent(event, ws);\n      }\n      case AiFlowEventType.SESSION_END: {\n        return this.onSessionEndEvent(event, ws);\n      }\n      case AiFlowEventType.USER_BARGE_IN: {\n        return this.onUserBargeInEvent(event, ws);\n      }\n      default: {\n        return this.onResult(event, null);\n      }\n    }\n  }\n\n  public express() {\n    return async (req: Request, res: Response) => {\n      const event = req.body as AiFlowEvent;\n      const actions = await this.onEvent(event);\n      if (actions) {\n        this.log(\"Sending actions:\", { actions });\n        return res.send(actions);\n      }\n      return res.sendStatus(200);\n    };\n  }\n\n  public ws(ws: WebSocket) {\n    return async (message: WebSocket.RawData) => {\n      const event = JSON.parse(message.toString()) as AiFlowEvent;\n      const actions = await this.onEvent(event, ws);\n      if (actions) {\n        this.log(\"Sending actions:\", actions);\n        ws.send(JSON.stringify(actions));\n      }\n    };\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAY,8DAAL;;;;AAIL;;;;AAIA;;;;AAIA;;;AAOF,MAAa,sBAAsBA,YAAE,OAAO;CAC1C,UAAUA,YAAE,KAAK,gBAAgB;CACjC,oBAAoBA,YACjB,QAAQ,CACR,IAAI,EAAE,CACN,UAAU,CACV,SAAS,kDAAkD;CAC9D,gBAAgBA,YACb,QAAQ,CACR,IAAI,EAAE,CACN,UAAU,CACV,SACC,qGACD;CACJ,CAAC;;;;ACtCF,MAAM,oBAAoB;CACzB;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,CAAC,QAAQ;EAC1B;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,CAAC,QAAQ;EAC1B;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,CAAC,QAAQ;EAC1B;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB;GAChB;GACA;GACA;GACA;GACA;GACA;EACD;CACD;EACC,IAAI;EACJ,MAAM;EACN,aAAa;EACb,iBAAiB,EAAE;EACnB;CAC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